UNPKG

phaser4-rex-plugins

Version:
2 lines (1 loc) 23.6 kB
var t,e;t=void 0,e=function(){var t={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 e=Phaser.Scene;var s=function(t){return t instanceof e},i=function(t){return null==t||"object"!=typeof t?null:s(t)?t:t.scene&&s(t.scene)?t.scene:t.parent&&t.parent.scene&&s(t.parent.scene)?t.parent.scene:null};const r=Phaser.Game;var n=function(t){return t instanceof r};const a=Phaser.Utils.Objects.GetValue;class h{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(a(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=i(t),this.game=null==(e=t)||"object"!=typeof e?null:n(e)?e:n(e.game)?e.game:s(e)?e.sys.game:s(e.scene)?e.scene.sys.game:void 0,this}}function o(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}Object.assign(h.prototype,t);var u={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,s="~";function i(){}function r(t,e,s){this.fn=t,this.context=e,this.once=s||!1}function n(t,e,i,n,a){if("function"!=typeof i)throw new TypeError("The listener must be a function");var h=new r(i,n||t,a),o=s?s+e:e;return t._events[o]?t._events[o].fn?t._events[o]=[t._events[o],h]:t._events[o].push(h):(t._events[o]=h,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function h(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(s=!1)),h.prototype.eventNames=function(){var t,i,r=[];if(0===this._eventsCount)return r;for(i in t=this._events)e.call(t,i)&&r.push(s?i.slice(1):i);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},h.prototype.listeners=function(t){var e=s?s+t:t,i=this._events[e];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,n=i.length,a=new Array(n);r<n;r++)a[r]=i[r].fn;return a},h.prototype.listenerCount=function(t){var e=s?s+t:t,i=this._events[e];return i?i.fn?1:i.length:0},h.prototype.emit=function(t,e,i,r,n,a){var h=s?s+t:t;if(!this._events[h])return!1;var o,u,l=this._events[h],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,i),!0;case 4:return l.fn.call(l.context,e,i,r),!0;case 5:return l.fn.call(l.context,e,i,r,n),!0;case 6:return l.fn.call(l.context,e,i,r,n,a),!0}for(u=1,o=new Array(c-1);u<c;u++)o[u-1]=arguments[u];l.fn.apply(l.context,o)}else{var p,v=l.length;for(u=0;u<v;u++)switch(l[u].once&&this.removeListener(t,l[u].fn,void 0,!0),c){case 1:l[u].fn.call(l[u].context);break;case 2:l[u].fn.call(l[u].context,e);break;case 3:l[u].fn.call(l[u].context,e,i);break;case 4:l[u].fn.call(l[u].context,e,i,r);break;default:if(!o)for(p=1,o=new Array(c-1);p<c;p++)o[p-1]=arguments[p];l[u].fn.apply(l[u].context,o)}}return!0},h.prototype.on=function(t,e,s){return n(this,t,e,s,!1)},h.prototype.once=function(t,e,s){return n(this,t,e,s,!0)},h.prototype.removeListener=function(t,e,i,r){var n=s?s+t:t;if(!this._events[n])return this;if(!e)return a(this,n),this;var h=this._events[n];if(h.fn)h.fn!==e||r&&!h.once||i&&h.context!==i||a(this,n);else{for(var o=0,u=[],l=h.length;o<l;o++)(h[o].fn!==e||r&&!h[o].once||i&&h[o].context!==i)&&u.push(h[o]);u.length?this._events[n]=1===u.length?u[0]:u:a(this,n)}return this},h.prototype.removeAllListeners=function(t){var e;return t?(e=s?s+t:t,this._events[e]&&a(this,e)):(this._events=new i,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=s,h.EventEmitter=h,t.exports=h}(u);var l=o(u.exports);class c extends l{shutdown(){this.removeAllListeners()}destroy(){this.removeAllListeners()}}var p={setEventEmitter(t,e){return void 0===e&&(e=c),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: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):[]}},v=function(t,e,s){if(!t||"number"==typeof t)return s;if("string"==typeof e){if(t.hasOwnProperty(e))return t[e];if(-1===e.indexOf("."))return s;e=e.split(".")}for(var i=e,r=t,n=s,a=0;a<i.length;a++){if(e=i[a],!r.hasOwnProperty(e)){n=s;break}r=n=r[e]}return n};const d=["next","exit","enter"];let m=class{constructor(t){var e=v(t,"states",void 0);e&&this.addStates(e);var s=v(t,"extend",void 0);if(s)for(var i in s)this.hasOwnProperty(i)&&void 0!==this[i]||(this[i]=s[i]);var r=v(t,"eventEmitter",void 0),n=v(t,"EventEmitterClass",void 0);this.setEventEmitter(r,n),this._stateLock=!1,this.resetFromJSON(t)}shutdown(){this.destroyEventEmitter()}destroy(){this.shutdown()}resetFromJSON(t){this.setEnable(v(t,"enable",!0)),this.start(v(t,"start",void 0));var e=v(t,"init",void 0);return e&&e.call(this),this}toJSON(){return{curState:this.state,prevState:this.prevState,enable:this.enable,start:this._start}}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}toggleEnable(){return this.setEnable(!this.enable),this}set state(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,s=this[e];s&&s.call(this),this.emit(e,this)}if(this._stateLock=!1,null!=this._state){var i="enter_"+this._state,r=this[i];r&&r.call(this),this.emit(i,this)}}}get state(){return this._state}get prevState(){return this._prevState}start(t){return this._start=t,this._prevState=void 0,this._state=t,this}goto(t){return null!=t&&(this.state=t),this}next(){var t,e=this["next_"+this.state];return e&&(t="string"==typeof e?e:e.call(this)),this.goto(t),this}get stateProperties(){return d}addState(t,e){"string"!=typeof t&&(t=(e=t).name);for(var s=this.stateProperties,i=0,r=s.length;i<r;i++){var n=s[i],a=e[n];a&&(this[`${n}_${t}`]=a)}return this}addStates(t){if(Array.isArray(t))for(var e=0,s=t.length;e<s;e++)this.addState(t[e]);else for(var i in t)this.addState(i,t[i]);return this}runMethod(t,e,s,i,r,n){var a=this[t+"_"+this.state];if(a){var h=arguments.length;switch(h){case 1:return a.call(this);case 2:return a.call(this,e);case 3:return a.call(this,e,s);case 4:return a.call(this,e,s,i);case 5:return a.call(this,e,s,i,r);case 6:return a.call(this,e,s,i,r,n)}for(var o=new Array(h-1),u=1;u<h;u++)o[u-1]=arguments[u];return a.apply(this,o)}}};Object.assign(m.prototype,p);var f=function(t,e,s,i,r){void 0===r&&(r=!1);var n=t._events[e];if(!n)return!1;for(var a=0,h=n.length;a<h;a++){var o=n[a];if(o.fn===s&&o.context===i&&o.once===r)return!0}return!1};const y=["next","exit","enter","update","preupdate","postupdate"];class _ extends m{shutdown(){this.stopUpdate(),this.stopPreUpdate(),this.stopPostUpdate(),this._scene=void 0,super.shutdown()}resetFromJSON(t){return super.resetFromJSON(t),this._scene=v(t,"scene",void 0),this}get stateProperties(){return y}update(t,e){this.runMethod("update",t,e)}preupdate(t,e){this.runMethod("preupdate",t,e)}postupdate(t,e){this.runMethod("postupdate",t,e)}startUpdate(t){t||(t=this._scene);var e=t.sys.events;return f(e,"update",this.update,this)||(this._scene=t,e.on("update",this.update,this)),this}stopUpdate(){return this._scene?(this._scene.sys.events.off("update",this.update,this),this):this}startPreUpdate(t){t||(t=this._scene);var e=t.sys.events;return f(e,"preupdate",this.preupdate,this)||(this._scene=t,e.on("preupdate",this.preupdate,this)),this}stopPreUpdate(){return this._scene?(this._scene.sys.events.off("preupdate",this.preupdate,this),this):this}startPostUpdate(t){t||(t=this._scene);var e=t.sys.events;return f(e,"postupdate",this.postupdate,this)||(this._scene=t,e.on("postupdate",this.postupdate,this)),this}stopPostUpdate(){return this._scene?(this._scene.sys.events.off("postupdate",this.postupdate,this),this):this}}class E extends _{constructor(t,e){super(e),this.parent=t;var s=e.initState||"IDLE";this.start(s)}init(){this.start("IDLE")}next_IDLE(){return"TRANS_OPNE"}next_TRANS_OPNE(){return"OPEN"}enter_TRANS_OPNE(){var t=this.parent;if(t.transitInTime>0){var e=t.runTransitionInCallback();t.delayCall(e,this.next,this)}else this.next()}exit_TRANS_OPNE(){this.parent.removeDelayCall()}next_OPEN(){return"TRANS_CLOSE"}enter_OPEN(){this.parent.onOpen()}exit_OPEN(){this.parent.removeDelayCall()}next_TRANS_CLOSE(){return"CLOSE"}enter_TRANS_CLOSE(){var t=this.parent;if(t.transitOutTime>0){var e=t.runTransitionOutCallback();t.delayCall(e,this.next,this)}else this.next()}exit_TRANS_CLOSE(){this.parent.removeDelayCall()}next_CLOSE(){return"TRANS_OPNE"}enter_CLOSE(){this.parent.onClose()}exit_CLOSE(){}canOpen(){return"IDLE"===this.state||"CLOSE"===this.state}canClose(){return"IDLE"===this.state||"OPEN"===this.state}}var g={delayCall(t,e,s){return this.delayCallTimer=function(t,e,s,r,n){var a=i(t);return a.time.delayedCall(e,(function(){a.game.events.once("poststep",(function(){s.call(r,n)}))}))}(this,t,e,s),this},removeDelayCall(){return this.delayCallTimer&&(this.delayCallTimer.remove(!1),this.delayCallTimer=void 0),this}},O=function(){},T={setTransitInTime(t){return this.transitInTime=t,this},setTransitOutTime(t){return this.transitOutTime=t,this},setTransitInCallback(t){return t||(t=O),this.transitInCallback=t,this},setTransitOutCallback(t){return t||(t=O),this.transitOutCallback=t,this}},S={runTransitionInCallback(){return this.transitInCallback(this.parent,this.transitInTime),this.transitInTime},onOpen(){},requestOpen(t,e){if(!this._state.canOpen())return this;this.openEventData=arguments.length>0?t:this.parent;var s=this.transitInTime;return void 0!==e&&(this.transitInTime=e),this._state.goto("TRANS_OPNE"),this.transitInTime=s,this}},w={runTransitionOutCallback(){return this.transitOutCallback(this.parent,this.transitOutTime),this.transitOutTime},onClose(){this.oneShotMode&&this.parent.destroy()},requestClose(t,e){if(!this._state.canClose)return this;this.closeEventData=arguments.length>0?t:this.parent;var s=this.transitOutTime;return void 0!==e&&(this.transitOutTime=e),this._state.goto("TRANS_CLOSE"),this.transitOutTime=s,this}},b={};Object.assign(b,g,T,S,w);const P=Phaser.Utils.Objects.GetValue;class C extends h{constructor(t,e){super(t,e),this.setTransitInTime(P(e,"duration.in",200)),this.setTransitOutTime(P(e,"duration.out",200)),this.setTransitInCallback(P(e,"transitIn")),this.setTransitOutCallback(P(e,"transitOut")),this.oneShotMode=P(e,"destroy",!1),this.delayCallTimer=void 0,this._state=new E(this,{eventEmitter:!1,initState:P(e,"initState","IDLE")}),this.openEventData=void 0,this.closeEventData=void 0}get state(){return this._state.state}shutdown(t){this.isShutdown||(this.transitInCallback=void 0,this.transitOutCallback=void 0,this.openEventData=void 0,this.closeEventData=void 0,this.removeDelayCall(),super.shutdown(t))}}Object.assign(C.prototype,b);const k=Phaser.Utils.Objects.GetValue;class x extends h{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(k(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=L[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 L={no:0,lazy:1,always:2},D=Phaser.Utils.Objects.GetValue;class N extends x{constructor(t,e){super(t,e);var s=this.scene?"update":"step";this.tickEventName=D(e,"tickEventName",s),this.isSceneTicker=!R(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 R=function(t){return"step"===t||"poststep"===t};const I=Phaser.Utils.Objects.GetValue,j=Phaser.Math.Clamp;class A{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=I(t,"state",U),this.timeScale=I(t,"timeScale",1),this.delay=I(t,"delay",0),this.repeat=I(t,"repeat",0),this.repeatCounter=I(t,"repeatCounter",0),this.repeatDelay=I(t,"repeatDelay",0),this.duration=I(t,"duration",0),this.nowTime=I(t,"nowTime",0),this.justRestart=I(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?M:F,this.repeatCounter=0,this}stop(){return this.state=U,this}update(t,e){this.state!==U&&this.state!==Y&&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=X)):(this.nowTime=this.duration,this.state=Y):this.nowTime>=0&&(this.state=M))}get t(){var t;switch(this.state){case U:case F:case X:t=0;break;case M:t=this.nowTime/this.duration;break;case Y:t=1}return j(t,0,1)}set t(t){(t=j(t,-1,1))<0?(this.state=F,this.nowTime=-this.delay*t):(this.state=M,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===U}get isDelay(){return this.state===F}get isCountDown(){return this.state===M}get isRunning(){return this.state===F||this.state===M}get isDone(){return this.state===Y}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const U=0,F=1,M=2,X=3,Y=-1;class J extends N{constructor(t,e){super(t,e),this.timer=new A}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 G=Phaser.Utils.Objects.GetValue,V=Phaser.Utils.Objects.GetAdvancedValue,q=Phaser.Tweens.Builders.GetEaseFunction;class z extends J{resetFromJSON(t){return this.timer.resetFromJSON(G(t,"timer")),this.setEnable(G(t,"enable",!0)),this.setTarget(G(t,"target",this.parent)),this.setDelay(V(t,"delay",0)),this.setDuration(V(t,"duration",1e3)),this.setEase(G(t,"ease","Linear")),this.setRepeat(G(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=q(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 s=this.target,i=this.timer;return i.update(t,e),i.isDelay||this.updateTarget(s,i),this.emit("update",s,this),i.isDone&&this.complete(),this}updateTarget(t,e){}}const B=Phaser.Utils.Objects.GetValue,$=Phaser.Utils.Objects.GetAdvancedValue,H=Phaser.Math.Linear;class K extends z{constructor(t,e){super(t,e),this.scaleStart={},this.scaleEnd={},this.resetFromJSON(e),this.boot()}resetFromJSON(t){return super.resetFromJSON(t),this.setMode(B(t,"mode",0)),this.setScaleRange($(t,"start",void 0),$(t,"end",0)),this}setMode(t){return"string"==typeof t&&(t=Q[t]),this.mode=t,this}setScaleRange(t,e){return"number"==typeof t?(this.startX=t,this.startY=t):(this.startX=$(t,"x",this.parent.scaleX),this.startY=$(t,"y",this.parent.scaleY)),"number"==typeof e?(this.endX=e,this.endY=e):(this.endX=$(e,"x",void 0),this.endY=$(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}start(){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),super.start(),this}updateTarget(t,e){var s=e.t;e.isOddIteration&&(s=1-s),s=this.easeFn(s),this.hasScaleX&&(t.scaleX=H(this.startX,this.endX,s)),this.hasScaleY&&(t.scaleY=H(this.startY,this.endY,s))}complete(){return super.complete(),1===this.mode&&this.parent.destroy(),this}}const Q={stop:0,destroy:1,yoyo:2};var W=function(t,e,s,i,r){var n,a;switch(void 0===i&&(i="Cubic"),s){case 0:case"x":n={x:0},a={x:t.scaleX};break;case 1:case"y":n={y:0},a={y:t.scaleY};break;default:n=0,a=t.scale}var h={mode:0,start:n,end:a,duration:e,ease:i};return void 0===r?r=new K(t,h):r.resetFromJSON(h),r.restart(),r},Z=function(t,e,s,i,r){void 0===i&&(i="Linear");var n={mode:0};switch(s){case 0:case"x":n.end={x:0};break;case 1:case"y":n.end={y:0};break;default:n.end=0}return n.duration=e,n.ease=i,void 0===r?r=new K(t,n):r.resetFromJSON(n),r.restart(),r};const tt=Phaser.Loader.FILE_POPULATED,et=Phaser.Utils.String.UUID;class st extends Phaser.Loader.File{constructor(t,e){e.hasOwnProperty("type")||(e.type="await"),e.hasOwnProperty("url")||(e.url=""),e.hasOwnProperty("key")||(e.key=et()),super(t,e)}load(){if(this.state===tt)this.loader.nextFile(this,!0);else{var t=this.config,e=t.callback,s=t.scope;if(e){var i=this,r=!1,n=function(){r||(setTimeout((function(){i.onLoad()}),0),r=!0)},a=function(){r||(setTimeout((function(){i.onError()}),0),r=!0)};s?e.call(s,n,a):e(n,a)}else this.onLoad()}}onLoad(){this.loader.nextFile(this,!0)}onError(){this.loader.nextFile(this,!1)}}const it=Phaser.Utils.Objects.IsPlainObject,rt=function(t,e){var s;return(s=t)&&"function"==typeof s?e={config:{callback:t,scope:e}}:it(t)?(e=t).hasOwnProperty("config")||(e={config:e}):e={key:t,config:e},this.addFile(new st(this,e)),this};Phaser.Loader.FileTypesManager.register("rexAwait",rt);var nt=function(t,e){void 0===e&&(e=0);var i=(t=function(t){return s(t)?t.load:t}(t)).totalToLoad-e;return 1-(t.list.size+t.inflight.size-e)/i};const at=Phaser.Utils.Objects.GetValue;class ht extends C{constructor(t,e){void 0===e&&(e={}),e.hasOwnProperty("transitIn")||(e.transitIn=W),e.hasOwnProperty("transitOut")||(e.transitOut=Z),e.destroy=!0,super(t,e),this.setProgressCallback(at(e,"progress")),this.start()}setProgressCallback(t){return t||(t=O),this.progressCallback=t,this}start(){var t=this;rt.call(this.scene.load,(function(e,s){t.once("close",e)})),this.requestOpen()}onOpen(){this.scene.load.on("progress",this.onProgress,this),this.emit("open",this.parent,this),super.onOpen(),this.onProgress()}onClose(){this.scene.load.off("progress",this.onProgress,this),this.emit("close",this.closeEventData),super.onClose()}onProgress(){var t=nt(this.scene,1);this.progressCallback(this.parent,t),this.emit("progress",t),1===t&&this.requestClose()}}class ot extends Phaser.Plugins.BasePlugin{constructor(t){super(t)}add(t,e){return new ht(t,e)}}return ot},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexloadingprogressplugin=e();