phaser3-rex-plugins
Version:
2 lines (1 loc) • 38.3 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexmodalplugin=e();}(undefined,(function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(s=n.key,r=void 0,"symbol"==typeof(r=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(s,"string"))?r:String(r)),n);}var s,r;}function n(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e);}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function o(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function u(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return !1}}();return function(){var i,n=r(t);if(e){var s=r(this).constructor;i=Reflect.construct(n,arguments,s);}else i=n.apply(this,arguments);return function(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return o(t)}(this,i)}}function h(){return h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}(t,e);if(n){var s=Object.getOwnPropertyDescriptor(n,e);return s.get?s.get.call(arguments.length<3?t:i):s.value}},h.apply(this,arguments)}var l={setEventEmitter:function(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:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames:function(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}},c=Phaser.Scene,v=function(t){return t instanceof c},p=function(e){return null==e||"object"!==t(e)?null:v(e)?e:e.scene&&v(e.scene)?e.scene:e.parent&&e.parent.scene&&v(e.parent.scene)?e.parent.scene:null},f=Phaser.Game,y=function(t){return t instanceof f},d=Phaser.Utils.Objects.GetValue,m=function(){function i(t,n){e(this,i),this.setParent(t),this.isShutdown=!1,this.setEventEmitter(d(n,"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));}return n(i,[{key:"shutdown",value:function(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);}},{key:"destroy",value:function(t){this.shutdown(t);}},{key:"onEnvDestroy",value:function(){this.destroy(!0);}},{key:"onParentDestroy",value:function(t,e){this.destroy(e);}},{key:"setParent",value:function(e){var i;return this.parent=e,this.scene=p(e),this.game=null==(i=e)||"object"!==t(i)?null:y(i)?i:y(i.game)?i.game:v(i)?i.sys.game:v(i.scene)?i.scene.sys.game:void 0,this}}]),i}();function k(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}Object.assign(m.prototype,l);var _={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function n(){}function s(t,e,i){this.fn=t,this.context=e,this.once=i||!1;}function r(t,e,n,r,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new s(n,r||t,a),u=i?i+e:e;return t._events[u]?t._events[u].fn?t._events[u]=[t._events[u],o]:t._events[u].push(o):(t._events[u]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e];}function o(){this._events=new n,this._eventsCount=0;}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),o.prototype.eventNames=function(){var t,n,s=[];if(0===this._eventsCount)return s;for(n in t=this._events)e.call(t,n)&&s.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},o.prototype.listeners=function(t){var e=i?i+t:t,n=this._events[e];if(!n)return [];if(n.fn)return [n.fn];for(var s=0,r=n.length,a=new Array(r);s<r;s++)a[s]=n[s].fn;return a},o.prototype.listenerCount=function(t){var e=i?i+t:t,n=this._events[e];return n?n.fn?1:n.length:0},o.prototype.emit=function(t,e,n,s,r,a){var o=i?i+t:t;if(!this._events[o])return !1;var u,h,l=this._events[o],c=arguments.length;if(l.fn){switch(l.once&&this.removeListener(t,l.fn,void 0,!0),c){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,e),!0;case 3:return l.fn.call(l.context,e,n),!0;case 4:return l.fn.call(l.context,e,n,s),!0;case 5:return l.fn.call(l.context,e,n,s,r),!0;case 6:return l.fn.call(l.context,e,n,s,r,a),!0}for(h=1,u=new Array(c-1);h<c;h++)u[h-1]=arguments[h];l.fn.apply(l.context,u);}else {var v,p=l.length;for(h=0;h<p;h++)switch(l[h].once&&this.removeListener(t,l[h].fn,void 0,!0),c){case 1:l[h].fn.call(l[h].context);break;case 2:l[h].fn.call(l[h].context,e);break;case 3:l[h].fn.call(l[h].context,e,n);break;case 4:l[h].fn.call(l[h].context,e,n,s);break;default:if(!u)for(v=1,u=new Array(c-1);v<c;v++)u[v-1]=arguments[v];l[h].fn.apply(l[h].context,u);}}return !0},o.prototype.on=function(t,e,i){return r(this,t,e,i,!1)},o.prototype.once=function(t,e,i){return r(this,t,e,i,!0)},o.prototype.removeListener=function(t,e,n,s){var r=i?i+t:t;if(!this._events[r])return this;if(!e)return a(this,r),this;var o=this._events[r];if(o.fn)o.fn!==e||s&&!o.once||n&&o.context!==n||a(this,r);else {for(var u=0,h=[],l=o.length;u<l;u++)(o[u].fn!==e||s&&!o[u].once||n&&o[u].context!==n)&&h.push(o[u]);h.length?this._events[r]=1===h.length?h[0]:h:a(this,r);}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&a(this,e)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,t.exports=o;}(_);var E=function(t){s(r,t);var i=u(r);function r(){return e(this,r),i.apply(this,arguments)}return n(r,[{key:"shutdown",value:function(){this.removeAllListeners();}},{key:"destroy",value:function(){this.removeAllListeners();}}]),r}(k(_.exports)),g={setEventEmitter:function(t,e){return void 0===e&&(e=E),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames:function(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}},b=function(t,e,i){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return t[e];if(-1!==e.indexOf(".")){for(var n=e.split("."),s=t,r=i,a=0;a<n.length;a++){if(!s.hasOwnProperty(n[a])){r=i;break}r=s[n[a]],s=s[n[a]];}return r}return i}return i},O=["next","exit","enter"],S=function(){function t(i){e(this,t);var n=b(i,"states",void 0);n&&this.addStates(n);var s=b(i,"extend",void 0);if(s)for(var r in s)this.hasOwnProperty(r)&&void 0!==this[r]||(this[r]=s[r]);var a=b(i,"eventEmitter",void 0),o=b(i,"EventEmitterClass",void 0);this.setEventEmitter(a,o),this._stateLock=!1,this.resetFromJSON(i);}return n(t,[{key:"shutdown",value:function(){this.destroyEventEmitter();}},{key:"destroy",value:function(){this.shutdown();}},{key:"resetFromJSON",value:function(t){this.setEnable(b(t,"enable",!0)),this.start(b(t,"start",void 0));var e=b(t,"init",void 0);return e&&e.call(this),this}},{key:"toJSON",value:function(){return {curState:this.state,prevState:this.prevState,enable:this.enable,start:this._start}}},{key:"setEnable",value:function(t){return void 0===t&&(t=!0),this.enable=t,this}},{key:"toggleEnable",value:function(){return this.setEnable(!this.enable),this}},{key:"state",get:function(){return this._state},set:function(t){if(this.enable&&!this._stateLock&&this._state!==t){if(this._prevState=this._state,this._state=t,this._stateLock=!0,this.emit("statechange",this),null!=this._prevState){var e="exit_"+this._prevState,i=this[e];i&&i.call(this),this.emit(e,this);}if(this._stateLock=!1,null!=this._state){var n="enter_"+this._state,s=this[n];s&&s.call(this),this.emit(n,this);}}}},{key:"prevState",get:function(){return this._prevState}},{key:"start",value:function(t){return this._start=t,this._prevState=void 0,this._state=t,this}},{key:"goto",value:function(t){return null!=t&&(this.state=t),this}},{key:"next",value:function(){var t,e=this["next_"+this.state];return e&&(t="string"==typeof e?e:e.call(this)),this.goto(t),this}},{key:"stateProperties",get:function(){return O}},{key:"addState",value:function(t,e){"string"!=typeof t&&(t=(e=t).name);for(var i=this.stateProperties,n=0,s=i.length;n<s;n++){var r=i[n],a=e[r];a&&(this["".concat(r,"_").concat(t)]=a);}return this}},{key:"addStates",value:function(t){if(Array.isArray(t))for(var e=0,i=t.length;e<i;e++)this.addState(t[e]);else for(var n in t)this.addState(n,t[n]);return this}},{key:"runMethod",value:function(t,e,i,n,s,r){var a=this[t+"_"+this.state];if(a){var o=arguments.length;switch(o){case 1:return a.call(this);case 2:return a.call(this,e);case 3:return a.call(this,e,i);case 4:return a.call(this,e,i,n);case 5:return a.call(this,e,i,n,s);case 6:return a.call(this,e,i,n,s,r)}for(var u=new Array(o-1),h=1;h<o;h++)u[h-1]=arguments[h];return a.apply(this,u)}}}]),t}();Object.assign(S.prototype,g);var C=function(t,e,i,n,s){void 0===s&&(s=!1);var r=t._events[e];if(!r)return !1;for(var a=0,o=r.length;a<o;a++){var u=r[a];if(u.fn===i&&u.context===n&&u.once===s)return !0}return !1},w=["next","exit","enter","update","preupdate","postupdate"],T=function(t){s(a,t);var i=u(a);function a(){return e(this,a),i.apply(this,arguments)}return n(a,[{key:"shutdown",value:function(){this.stopUpdate(),this.stopPreUpdate(),this.stopPostUpdate(),this._scene=void 0,h(r(a.prototype),"shutdown",this).call(this);}},{key:"resetFromJSON",value:function(t){return h(r(a.prototype),"resetFromJSON",this).call(this,t),this._scene=b(t,"scene",void 0),this}},{key:"stateProperties",get:function(){return w}},{key:"update",value:function(t,e){this.runMethod("update",t,e);}},{key:"preupdate",value:function(t,e){this.runMethod("preupdate",t,e);}},{key:"postupdate",value:function(t,e){this.runMethod("postupdate",t,e);}},{key:"startUpdate",value:function(t){t||(t=this._scene);var e=t.sys.events;return C(e,"update",this.update,this)||(this._scene=t,e.on("update",this.update,this)),this}},{key:"stopUpdate",value:function(){return this._scene?(this._scene.sys.events.off("update",this.update,this),this):this}},{key:"startPreUpdate",value:function(t){t||(t=this._scene);var e=t.sys.events;return C(e,"preupdate",this.preupdate,this)||(this._scene=t,e.on("preupdate",this.preupdate,this)),this}},{key:"stopPreUpdate",value:function(){return this._scene?(this._scene.sys.events.off("preupdate",this.preupdate,this),this):this}},{key:"startPostUpdate",value:function(t){t||(t=this._scene);var e=t.sys.events;return C(e,"postupdate",this.postupdate,this)||(this._scene=t,e.on("postupdate",this.postupdate,this)),this}},{key:"stopPostUpdate",value:function(){return this._scene?(this._scene.sys.events.off("postupdate",this.postupdate,this),this):this}}]),a}(S),P=function(t){s(r,t);var i=u(r);function r(t,n){var s;e(this,r),(s=i.call(this,n)).parent=t;var a=n.initState||"IDLE";return s.start(a),s}return n(r,[{key:"init",value:function(){this.start("IDLE");}},{key:"next_IDLE",value:function(){return "TRANS_OPNE"}},{key:"next_TRANS_OPNE",value:function(){return "OPEN"}},{key:"enter_TRANS_OPNE",value:function(){var t=this.parent;if(t.transitInTime>0){var e=t.runTransitionInCallback();t.delayCall(e,this.next,this);}else this.next();}},{key:"exit_TRANS_OPNE",value:function(){this.parent.removeDelayCall();}},{key:"next_OPEN",value:function(){return "TRANS_CLOSE"}},{key:"enter_OPEN",value:function(){this.parent.onOpen();}},{key:"exit_OPEN",value:function(){this.parent.removeDelayCall();}},{key:"next_TRANS_CLOSE",value:function(){return "CLOSE"}},{key:"enter_TRANS_CLOSE",value:function(){var t=this.parent;if(t.transitOutTime>0){var e=t.runTransitionOutCallback();t.delayCall(e,this.next,this);}else this.next();}},{key:"exit_TRANS_CLOSE",value:function(){this.parent.removeDelayCall();}},{key:"next_CLOSE",value:function(){return "TRANS_OPNE"}},{key:"enter_CLOSE",value:function(){this.parent.onClose();}},{key:"exit_CLOSE",value:function(){}},{key:"canOpen",value:function(){return "IDLE"===this.state||"CLOSE"===this.state}},{key:"canClose",value:function(){return "IDLE"===this.state||"OPEN"===this.state}}]),r}(T),x={delayCall:function(t,e,i){return this.delayCallTimer=function(t,e,i,n,s){var r=p(t);return r.time.delayedCall(e,(function(){r.game.events.once("poststep",(function(){i.call(n,s);}));}))}(this,t,e,i),this},removeDelayCall:function(){return this.delayCallTimer&&(this.delayCallTimer.remove(!1),this.delayCallTimer=void 0),this}},R=function(){},D={setTransitInTime:function(t){return this.transitInTime=t,this},setTransitOutTime:function(t){return this.transitOutTime=t,this},setTransitInCallback:function(t){return t||(t=R),this.transitInCallback=t,this},setTransitOutCallback:function(t){return t||(t=R),this.transitOutCallback=t,this}},L={runTransitionInCallback:function(){return this.transitInCallback(this.parent,this.transitInTime),this.transitInTime},onOpen:function(){},requestOpen:function(t,e){if(!this._state.canOpen())return this;this.openEventData=arguments.length>0?t:this.parent;var i=this.transitInTime;return void 0!==e&&(this.transitInTime=e),this._state.goto("TRANS_OPNE"),this.transitInTime=i,this}},N={runTransitionOutCallback:function(){return this.transitOutCallback(this.parent,this.transitOutTime),this.transitOutTime},onClose:function(){this.oneShotMode&&this.parent.destroy();},requestClose:function(t,e){if(!this._state.canClose)return this;this.closeEventData=arguments.length>0?t:this.parent;var i=this.transitOutTime;return void 0!==e&&(this.transitOutTime=e),this._state.goto("TRANS_CLOSE"),this.transitOutTime=i,this}},j={};Object.assign(j,x,D,L,N);var A=Phaser.Utils.Objects.GetValue,I=function(t){s(a,t);var i=u(a);function a(t,n){var s;return e(this,a),(s=i.call(this,t,n)).setTransitInTime(A(n,"duration.in",200)),s.setTransitOutTime(A(n,"duration.out",200)),s.setTransitInCallback(A(n,"transitIn")),s.setTransitOutCallback(A(n,"transitOut")),s.oneShotMode=A(n,"destroy",!1),s.delayCallTimer=void 0,s._state=new P(o(s),{eventEmitter:!1,initState:A(n,"initState","IDLE")}),s.openEventData=void 0,s.closeEventData=void 0,s}return n(a,[{key:"state",get:function(){return this._state.state}},{key:"shutdown",value:function(t){this.isShutdown||(this.transitInCallback=void 0,this.transitOutCallback=void 0,this.openEventData=void 0,this.closeEventData=void 0,this.removeDelayCall(),h(r(a.prototype),"shutdown",this).call(this,t));}}]),a}(m);Object.assign(I.prototype,j);var M=function(t){s(a,t);var i=u(a);function a(t,n,s){var r;return e(this,a),(r=i.call(this,t,0,0,2,2,n,1)).setAlpha(s),r.setScrollFactor(0),r.boot(),r}return n(a,[{key:"boot",value:function(){this.scene.sys.events.on("prerender",this.resize,this);}},{key:"destroy",value:function(t){this.scene&&!this.ignoreDestroy&&(this.scene.sys.events.off("prerender",this.resize,this),h(r(a.prototype),"destroy",this).call(this,t));}},{key:"tint",get:function(){return this.fillColor},set:function(t){this.setFillStyle(t,this.fillAlpha);}},{key:"resize",value:function(){var t=this.scene,e=t.sys.scale.gameSize,i=t.sys.cameras.main,n=e.width,s=e.height,r=1/i.zoom,a=n/2,o=s/2,u=n*r,h=s*r;this.x===a&&this.y===o||this.setPosition(a,o),this.width===u&&this.height===h||this.setSize(u,h).setOrigin(.5);}}]),a}(Phaser.GameObjects.Rectangle),U=Phaser.Utils.Objects.GetValue,F=function(t){s(r,t);var i=u(r);function r(t,n){var s;return e(this,r),(s=i.call(this,t,{eventEmitter:!1})).resetFromJSON(n),s.boot(),s}return n(r,[{key:"resetFromJSON",value:function(t){return this.setHitAreaMode(U(t,"hitAreaMode",0)),this.setEnable(U(t,"enable",!0)),this.setStopMode(U(t,"stopAllLevels",!0)),this}},{key:"boot",value:function(){this.parent.on("pointerdown",(function(t,e,i,n){this.stopAllLevels&&n.stopPropagation();}),this).on("pointerup",(function(t,e,i,n){this.stopAllLevels&&n.stopPropagation();}),this).on("pointermove",(function(t,e,i,n){this.stopAllLevels&&n.stopPropagation();}),this).on("pointerover",(function(t,e,i,n){this.stopAllLevels&&n.stopPropagation();}),this).on("pointerout",(function(t,e){this.stopAllLevels&&e.stopPropagation();}),this);}},{key:"setHitAreaMode",value:function(t){"string"==typeof t&&(t=G[t]);var e=this.parent;return e.input&&e.removeInteractive(),0===t?e.setInteractive():e.setInteractive({hitArea:{},hitAreaCallback:function(){return !0}}),this}},{key:"setEnable",value:function(t){return void 0===t&&(t=!0),t?this.parent.setInteractive():this.parent.disableInteractive(),this.enable=t,this}},{key:"setStopMode",value:function(t){return void 0===t&&(t=!0),this.stopAllLevels=t,this}},{key:"toggleEnable",value:function(){return this.setEnable(!this.enable),this}}]),r}(m),G={default:0,fullWindow:1},X=Phaser.Utils.Objects.GetValue,J=function(t){s(r,t);var i=u(r);function r(t,n){var s;e(this,r);var a=X(n,"color",0),u=X(n,"alpha",.8);return (s=i.call(this,t,a,u)).touchEventStop=new F(o(s),{hitAreaMode:1}),s}return n(r)}(M),Y=Phaser.Utils.Objects.GetValue,V=function(t){s(a,t);var i=u(a);function a(t,n){var s;return e(this,a),(s=i.call(this,t,n))._isRunning=!1,s.isPaused=!1,s.tickingState=!1,s.setTickingMode(Y(n,"tickingMode",1)),s}return n(a,[{key:"boot",value:function(){2!==this.tickingMode||this.tickingState||this.startTicking();}},{key:"shutdown",value:function(t){this.isShutdown||(this.stop(),this.tickingState&&this.stopTicking(),h(r(a.prototype),"shutdown",this).call(this,t));}},{key:"setTickingMode",value:function(t){"string"==typeof t&&(t=B[t]),this.tickingMode=t;}},{key:"startTicking",value:function(){this.tickingState=!0;}},{key:"stopTicking",value:function(){this.tickingState=!1;}},{key:"isRunning",get:function(){return this._isRunning},set:function(t){this._isRunning!==t&&(this._isRunning=t,1===this.tickingMode&&t!=this.tickingState&&(t?this.startTicking():this.stopTicking()));}},{key:"start",value:function(){return this.isPaused=!1,this.isRunning=!0,this}},{key:"pause",value:function(){return this.isRunning&&(this.isPaused=!0,this.isRunning=!1),this}},{key:"resume",value:function(){return this.isPaused&&(this.isRunning=!0),this}},{key:"stop",value:function(){return this.isPaused=!1,this.isRunning=!1,this}},{key:"complete",value:function(){this.isPaused=!1,this.isRunning=!1,this.emit("complete",this.parent,this);}}]),a}(m),B={no:0,lazy:1,always:2},q=Phaser.Utils.Objects.GetValue,z=function(t){s(a,t);var i=u(a);function a(t,n){var s;e(this,a);var r=(s=i.call(this,t,n)).scene?"update":"step";return s.tickEventName=q(n,"tickEventName",r),s.isSceneTicker=!H(s.tickEventName),s}return n(a,[{key:"startTicking",value:function(){h(r(a.prototype),"startTicking",this).call(this),this.isSceneTicker?this.scene.sys.events.on(this.tickEventName,this.update,this):this.game.events.on(this.tickEventName,this.update,this);}},{key:"stopTicking",value:function(){h(r(a.prototype),"stopTicking",this).call(this),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);}}]),a}(V),H=function(t){return "step"===t||"poststep"===t},W=Phaser.Utils.Objects.GetValue,K=Phaser.Math.Clamp,Q=function(){function t(i){e(this,t),this.resetFromJSON(i);}return n(t,[{key:"resetFromJSON",value:function(t){this.state=W(t,"state",Z),this.timeScale=W(t,"timeScale",1),this.delay=W(t,"delay",0),this.repeat=W(t,"repeat",0),this.repeatCounter=W(t,"repeatCounter",0),this.repeatDelay=W(t,"repeatDelay",0),this.duration=W(t,"duration",0),this.nowTime=W(t,"nowTime",0),this.justRestart=W(t,"justRestart",!1);}},{key:"toJSON",value:function(){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}}},{key:"destroy",value:function(){}},{key:"setTimeScale",value:function(t){return this.timeScale=t,this}},{key:"setDelay",value:function(t){return void 0===t&&(t=0),this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setRepeat",value:function(t){return this.repeat=t,this}},{key:"setRepeatInfinity",value:function(){return this.repeat=-1,this}},{key:"setRepeatDelay",value:function(t){return this.repeatDelay=t,this}},{key:"start",value:function(){return this.nowTime=this.delay>0?-this.delay:0,this.state=this.nowTime>=0?tt:$,this.repeatCounter=0,this}},{key:"stop",value:function(){return this.state=Z,this}},{key:"update",value:function(t,e){this.state!==Z&&this.state!==it&&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=et)):(this.nowTime=this.duration,this.state=it):this.nowTime>=0&&(this.state=tt));}},{key:"t",get:function(){var t;switch(this.state){case Z:case $:case et:t=0;break;case tt:t=this.nowTime/this.duration;break;case it:t=1;}return K(t,0,1)},set:function(t){(t=K(t,-1,1))<0?(this.state=$,this.nowTime=-this.delay*t):(this.state=tt,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++);}},{key:"setT",value:function(t){return this.t=t,this}},{key:"isIdle",get:function(){return this.state===Z}},{key:"isDelay",get:function(){return this.state===$}},{key:"isCountDown",get:function(){return this.state===tt}},{key:"isRunning",get:function(){return this.state===$||this.state===tt}},{key:"isDone",get:function(){return this.state===it}},{key:"isOddIteration",get:function(){return 1==(1&this.repeatCounter)}},{key:"isEvenIteration",get:function(){return 0==(1&this.repeatCounter)}}]),t}(),Z=0,$=1,tt=2,et=3,it=-1,nt=function(t){s(a,t);var i=u(a);function a(t,n){var s;return e(this,a),(s=i.call(this,t,n)).timer=new Q,s}return n(a,[{key:"shutdown",value:function(t){this.isShutdown||(h(r(a.prototype),"shutdown",this).call(this,t),this.timer.destroy(),this.timer=void 0);}},{key:"start",value:function(){return this.timer.start(),h(r(a.prototype),"start",this).call(this),this}},{key:"stop",value:function(){return this.timer.stop(),h(r(a.prototype),"stop",this).call(this),this}},{key:"complete",value:function(){return this.timer.stop(),h(r(a.prototype),"complete",this).call(this),this}}]),a}(z),st=Phaser.Utils.Objects.GetValue,rt=Phaser.Utils.Objects.GetAdvancedValue,at=Phaser.Tweens.Builders.GetEaseFunction,ot=function(t){s(a,t);var i=u(a);function a(){return e(this,a),i.apply(this,arguments)}return n(a,[{key:"resetFromJSON",value:function(t){return this.timer.resetFromJSON(st(t,"timer")),this.setEnable(st(t,"enable",!0)),this.setTarget(st(t,"target",this.parent)),this.setDelay(rt(t,"delay",0)),this.setDuration(rt(t,"duration",1e3)),this.setEase(st(t,"ease","Linear")),this.setRepeat(st(t,"repeat",0)),this}},{key:"setEnable",value:function(t){return null==t&&(t=!0),this.enable=t,this}},{key:"setTarget",value:function(t){return void 0===t&&(t=this.parent),this.target=t,this}},{key:"setDelay",value:function(t){return this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setRepeat",value:function(t){return this.repeat=t,this}},{key:"setRepeatDelay",value:function(t){return this.repeatDelay=t,this}},{key:"setEase",value:function(t){return void 0===t&&(t="Linear"),this.ease=t,this.easeFn=at(t),this}},{key:"start",value:function(){return this.timer.isRunning||h(r(a.prototype),"start",this).call(this),this}},{key:"restart",value:function(){return this.timer.stop(),this.start.apply(this,arguments),this}},{key:"stop",value:function(t){return void 0===t&&(t=!1),h(r(a.prototype),"stop",this).call(this),t&&(this.timer.setT(1),this.updateGameObject(this.target,this.timer),this.complete()),this}},{key:"update",value:function(t,e){if(!this.isRunning||!this.enable||!this.parent.active)return this;var i=this.target,n=this.timer;return n.update(t,e),n.isDelay||this.updateGameObject(i,n),this.emit("update",i,this),n.isDone&&this.complete(),this}},{key:"updateGameObject",value:function(t,e){}}]),a}(nt),ut=Phaser.Utils.Objects.GetValue,ht=Phaser.Utils.Objects.GetAdvancedValue,lt=Phaser.Math.Linear,ct=function(t){s(a,t);var i=u(a);function a(t,n){var s;return e(this,a),(s=i.call(this,t,n)).scaleStart={},s.scaleEnd={},s.resetFromJSON(n),s.boot(),s}return n(a,[{key:"resetFromJSON",value:function(t){return h(r(a.prototype),"resetFromJSON",this).call(this,t),this.setMode(ut(t,"mode",0)),this.setScaleRange(ht(t,"start",void 0),ht(t,"end",0)),this}},{key:"setMode",value:function(t){return "string"==typeof t&&(t=vt[t]),this.mode=t,this}},{key:"setScaleRange",value:function(t,e){return "number"==typeof t?(this.startX=t,this.startY=t):(this.startX=ht(t,"x",this.parent.scaleX),this.startY=ht(t,"y",this.parent.scaleY)),"number"==typeof e?(this.endX=e,this.endY=e):(this.endX=ht(e,"x",void 0),this.endY=ht(e,"y",void 0)),this.hasScaleX=void 0!==this.startX&&void 0!==this.endX,this.hasScaleY=void 0!==this.startY&&void 0!==this.endY,this}},{key:"start",value:function(){if(this.timer.isRunning)return this;var t=this.parent;this.hasScaleX&&(t.scaleX=this.startX),this.hasScaleY&&(t.scaleY=this.startY);var e=this.repeat;return 2===this.mode&&-1!==e&&(e=2*(e+1)-1),this.timer.setDelay(this.delay).setDuration(this.duration).setRepeat(e),h(r(a.prototype),"start",this).call(this),this}},{key:"updateGameObject",value:function(t,e){var i=e.t;e.isOddIteration&&(i=1-i),i=this.easeFn(i),this.hasScaleX&&(t.scaleX=lt(this.startX,this.endX,i)),this.hasScaleY&&(t.scaleY=lt(this.startY,this.endY,i));}},{key:"complete",value:function(){return h(r(a.prototype),"complete",this).call(this),1===this.mode&&this.parent.destroy(),this}}]),a}(ot),vt={stop:0,destroy:1,yoyo:2},pt=Phaser.Utils.Objects.GetValue,ft=Phaser.Utils.Objects.GetAdvancedValue,yt=Phaser.Math.Linear,dt=function(t){s(a,t);var i=u(a);function a(t,n){var s;return e(this,a),(s=i.call(this,t,n)).resetFromJSON(n),s.boot(),s}return n(a,[{key:"resetFromJSON",value:function(t){return h(r(a.prototype),"resetFromJSON",this).call(this,t),this.setMode(pt(t,"mode",0)),this.setAlphaRange(ft(t,"start",this.parent.alpha),ft(t,"end",0)),this}},{key:"setMode",value:function(t){return "string"==typeof t&&(t=mt[t]),this.mode=t,this}},{key:"setAlphaRange",value:function(t,e){return this.alphaStart=t,this.alphaEnd=e,this}},{key:"start",value:function(){return this.timer.isRunning||(this.parent.setAlpha(this.alphaStart),this.timer.setDelay(this.delay).setDuration(this.duration).setRepeat(2===this.mode?-1:0),h(r(a.prototype),"start",this).call(this)),this}},{key:"updateGameObject",value:function(t,e){var i=e.t;e.isOddIteration&&(i=1-i),t.alpha=yt(this.alphaStart,this.alphaEnd,i);}},{key:"complete",value:function(){return h(r(a.prototype),"complete",this).call(this),1===this.mode&&this.parent.destroy(),this}}]),a}(ot),mt={stop:0,destroy:1,yoyo:2},kt=Phaser.Utils.Objects.IsPlainObject,_t=function(t,e,i,n){var s,r;kt(i)?(s=i.start,r=i.end):r=i,void 0===s&&(s=0),void 0===r&&(r=1);var a={mode:0,start:s,end:r,duration:e};return void 0===n?n=new dt(t,a):n.resetFromJSON(a),n.restart(),n},Et=function(t,e,i,n){i instanceof dt&&(n=i,i=void 0),void 0===i&&(i=!0);var s={mode:i?1:0,end:0,duration:e};return void 0===n?n=new dt(t,s):n.resetFromJSON(s),n.restart(),n},gt=function(t,e){void 0!==t._modalScaleSave?(t.scaleX=t._modalScaleSave,t.scaleY=t._modalScaleSave):t._modalScaleSave=t.scaleX,function(t,e,i,n,s){var r,a;switch(void 0===n&&(n="Cubic"),i){case 0:case"x":r={x:0},a={x:t.scaleX};break;case 1:case"y":r={y:0},a={y:t.scaleY};break;default:r=0,a=t.scale;}var o={mode:0,start:r,end:a,duration:e,ease:n};void 0===s?s=new ct(t,o):s.resetFromJSON(o),s.restart();}(t,e);},bt=function(t,e){!function(t,e,i,n,s,r){void 0===n&&(n="Linear"),s instanceof ct&&(r=s,s=void 0),void 0===s&&(s=!0);var a={};switch(a.mode=s?1:0,i){case 0:case"x":a.end={x:0};break;case 1:case"y":a.end={y:0};break;default:a.end=0;}a.duration=e,a.ease=n,void 0===r?r=new ct(t,a):r.resetFromJSON(a),r.restart();}(t,e,void 0,void 0,!1);},Ot=function(t,e){void 0!==t._modalAlphaSave?t.alpha=t._modalAlphaSave:t._modalAlphaSave=t.alpha,_t(t,e);},St=function(t,e){Et(t,e,!1);},Ct=function(t,e){void 0!==t._modalAlphaSave?t.alpha=t._modalAlphaSave:t._modalAlphaSave=t.alpha,_t(t,e,t.alpha);},wt=function(t,e){Et(t,e,!1);},Tt=function(t){return void 0!==t.displayWidth?t.displayWidth:t.width},Pt=function(t){return void 0!==t.displayHeight?t.displayHeight:t.height},xt=Phaser.Geom.Rectangle,Rt=Phaser.Math.Vector2,Dt=Phaser.Math.RotateAround,Lt=void 0,Nt=function(t,e,i){return void 0===e?e=new Rt:!0===e&&(void 0===Mt&&(Mt=new Rt),e=Mt),t.getTopLeft?t.getTopLeft(e):(e.x=t.x-Tt(t)*t.originX,e.y=t.y-Pt(t)*t.originY,Ut(t,e,i))},jt=function(t,e,i){return void 0===e?e=new Rt:!0===e&&(void 0===Mt&&(Mt=new Rt),e=Mt),t.getTopRight?t.getTopRight(e):(e.x=t.x-Tt(t)*t.originX+Tt(t),e.y=t.y-Pt(t)*t.originY,Ut(t,e,i))},At=function(t,e,i){return void 0===e?e=new Rt:!0===e&&(void 0===Mt&&(Mt=new Rt),e=Mt),t.getBottomLeft?t.getBottomLeft(e):(e.x=t.x-Tt(t)*t.originX,e.y=t.y-Pt(t)*t.originY+Pt(t),Ut(t,e,i))},It=function(t,e,i){return void 0===e?e=new Rt:!0===e&&(void 0===Mt&&(Mt=new Rt),e=Mt),t.getBottomRight?t.getBottomRight(e):(e.x=t.x-Tt(t)*t.originX+Tt(t),e.y=t.y-Pt(t)*t.originY+Pt(t),Ut(t,e,i))},Mt=void 0,Ut=function(t,e,i){(void 0===i&&(i=!1),0!==t.rotation&&Dt(e,t.x,t.y,t.rotation),i&&t.parentContainer)&&t.parentContainer.getBoundsTransformMatrix().transformPoint(e.x,e.y,e);return e},Ft=function(t,e,i,n,s){if(!t)return !1;if(n&&!n(t,e,i))return !1;var r=function(t,e){if(void 0===e?e=new xt:!0===e&&(void 0===Lt&&(Lt=new xt),e=Lt),t.getBounds)return t.getBounds(e);var i,n,s,r,a,o,u,h;if(t.parentContainer){var l=t.parentContainer.getBoundsTransformMatrix();Nt(t,e),l.transformPoint(e.x,e.y,e),i=e.x,n=e.y,jt(t,e),l.transformPoint(e.x,e.y,e),s=e.x,r=e.y,At(t,e),l.transformPoint(e.x,e.y,e),a=e.x,o=e.y,It(t,e),l.transformPoint(e.x,e.y,e),u=e.x,h=e.y;}else Nt(t,e),i=e.x,n=e.y,jt(t,e),s=e.x,r=e.y,At(t,e),a=e.x,o=e.y,It(t,e),u=e.x,h=e.y;return e.x=Math.min(i,s,a,u),e.y=Math.min(n,r,o,h),e.width=Math.max(i,s,a,u)-e.x,e.height=Math.max(n,r,o,h)-e.y,e}(t,!0);return !!r.contains(e,i)&&!(s&&!s(t,e,i))},Gt=Phaser.Utils.Objects.GetValue,Xt=function(t){s(a,t);var i=u(a);function a(t,n){var s;e(this,a),void 0===n&&(n={}),null==n.transitIn&&(n.transitIn=Jt.popUp),null==n.transitOut&&(n.transitOut=Jt.scaleDown),n.destroy=Gt(n,"destroy",!0),s=i.call(this,t,n);var r=Gt(n,"cover");s.cover=!1!==r?function(t,e){var i=t.scene,n=new J(i,e);return i.add.existing(n),t.isRexContainerLite?(t.pin(n,{syncPosition:!1,syncRotation:!1,syncScale:!1,syncAlpha:!1,syncScrollFactor:!1}),t.moveDepthBelow(n)):i.children.moveBelow(n,t),n}(t,r):void 0,s.cover&&(s.setCoverTransitInCallback(Gt(r,"transitIn",Ct)),s.setCoverTransitOutCallback(Gt(r,"transitOut",wt)));var u=Gt(n,"touchOutsideClose",!1),h=Gt(n,"duration.hold",-1),l=Gt(n,"timeOutClose",h>=0),c=Gt(n,"anyTouchClose",!1);return Gt(n,"manualClose",!1)&&(u=!1,c=!1,l=!1),c&&(u=!1),l?s.setDisplayTime(h):s.setDisplayTime(-1),c?s.once("open",s.anyTouchClose,o(s)):u&&s.once("open",s.touchOutsideClose,o(s)),Gt(n,"openOnStart",!0)&&s.delayCall(0,s.requestOpen,o(s)),s}return n(a,[{key:"shutdown",value:function(t){this.isShutdown||(this.cover||this.scene.input.off("pointerup",this.touchCloseCallback,this),this.cover&&!t&&(this.cover.destroy(),this.cover=void 0),h(r(a.prototype),"shutdown",this).call(this,t));}},{key:"touchOutsideClose",value:function(){return this.cover?this.cover.on("pointerup",this.touchCloseCallback,this):this.scene.input.on("pointerup",this.touchCloseCallback,this),this.clickOutsideTest=!0,this}},{key:"anyTouchClose",value:function(){return this.cover?this.cover.once("pointerup",this.touchCloseCallback,this):this.scene.input.once("pointerup",this.touchCloseCallback,this),this}},{key:"touchCloseCallback",value:function(t){this.clickOutsideTest&&Ft(this.parent,t.worldX,t.worldY)||this.requestClose();}},{key:"runTransitionInCallback",value:function(){var t=h(r(a.prototype),"runTransitionInCallback",this).call(this),e=this.cover;return e&&this.coverTransitInCallback&&this.coverTransitInCallback(e,t),t}},{key:"runTransitionOutCallback",value:function(){var t=h(r(a.prototype),"runTransitionOutCallback",this).call(this),e=this.cover;return e&&this.coverTransitOutCallback&&this.coverTransitOutCallback(e,t),t}},{key:"onOpen",value:function(){var t=this.displayTime;t>=0&&this.delayCall(t,this.requestClose,this),this.emit("open",this.parent,this),h(r(a.prototype),"onOpen",this).call(this);}},{key:"onClose",value:function(){this.emit("close",this.closeEventData),h(r(a.prototype),"onClose",this).call(this);}},{key:"setDisplayTime",value:function(t){return this.displayTime=t,this}},{key:"setTransitInCallback",value:function(t){switch("string"==typeof t&&(t=Jt[t]),t){case Jt.popUp:t=gt;break;case Jt.fadeIn:t=Ot;}return h(r(a.prototype),"setTransitInCallback",this).call(this,t),this}},{key:"setTransitOutCallback",value:function(t){switch("string"==typeof t&&(t=Jt[t]),t){case Jt.scaleDown:t=bt;break;case Jt.fadeOut:t=St;}return h(r(a.prototype),"setTransitOutCallback",this).call(this,t),this}},{key:"setCoverTransitInCallback",value:function(t){return this.coverTransitInCallback=t,this}},{key:"setCoverTransitOutCallback",value:function(t){return this.coverTransitOutCallback=t,this}}]),a}(I),Jt={popUp:0,fadeIn:1,scaleDown:0,fadeOut:1},Yt=function(t,e){var i=new Xt(t,e);return i.on("open",(function(){t.emit("modal.open",i);})),i.on("close",(function(e){t.emit("modal.close",e,i);})),t.on("modal.requestClose",i.requestClose,i),i};return function(t){s(r,Phaser.Plugins.BasePlugin);var i=u(r);function r(t){return e(this,r),i.call(this,t)}return n(r,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this);}},{key:"add",value:function(t,e){return new Xt(t,e)}},{key:"modal",value:function(t,e){return Yt(t,e)}},{key:"promise",value:function(t,e){return function(t,e){var i=Yt(t,e);return new Promise((function(t,e){i.once("close",(function(e){t(e);}));}))}(t,e)}},{key:"close",value:function(t,e){return function(t,e){t.emit("modal.requestClose",e);}(t,e)}}]),r}()}));