text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexfadeplugin=e()}(this,function(){"use strict";function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function t(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function a(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function h(i){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}();return function(){var t,e=u(i);if(r){var n=u(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return a(this,t)}}function c(t,e,n){return(c="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(n):r.value}})(t,e,n||t)}function l(t){return t instanceof r}var e={setEventEmitter:function(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]}},r=Phaser.Scene,f=Phaser.GameObjects.GameObject,p=Phaser.Utils.Objects.GetValue,v=function(){function r(t,e){var n;s(this,r),this.parent=t,this.scene=l(n=t)?n:n.scene&&l(n.scene)?n.scene:n.parent&&n.parent.scene&&l(n.parent.scene)?n.parent.scene:void 0;var i=p(e,"eventEmitter",!1);!0===i&&(i=void 0),this.setEventEmitter(i),this.boot()}return t(r,[{key:"boot",value:function(){this.parent instanceof f?this.parent.once&&this.parent.on("destroy",this.destroy,this):l(this.parent)&&this.parent.events.once("shutdown",this.destroy,this)}},{key:"shutdown",value:function(){return this.stop(),l(this.parent)&&this.parent.events.off("shutdown",this.destroy,this),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this}},{key:"destroy",value:function(){return this.shutdown(),this}},{key:"start",value:function(t){return this.isRunning||(this.tween=this.scene.tweens.add(t).on("complete",this.complete,this),!1===this.getEventEmitter()&&this.setEventEmitter(this.tween)),this}},{key:"restart",value:function(){return this.stop().start(),this}},{key:"stop",value:function(){return this.tween&&(this.getEventEmitter()===this.tween&&this.setEventEmitter(!1),this.tween.remove(),this.tween=void 0),this}},{key:"complete",value:function(){return this.stop(),this.getEventEmitter()&&this.emit("complete"),this}},{key:"isRunning",get:function(){return!!this.tween}}]),r}();Object.assign(v.prototype,e);var d=Phaser.Utils.Objects.GetValue,m=Phaser.Utils.Objects.GetAdvancedValue,y=function(){o(r,v);var i=h(r);function r(t,e){var n;return s(this,r),(n=i.call(this,t)).gameObject=t,n.alphaStart=void 0,n.alphaEnd=void 0,n.resetFromJSON(e),n}return t(r,[{key:"resetFromJSON",value:function(t){return this.setMode(d(t,"mode",0)),this.setAlphaRange(m(t,"start",this.gameObject.alpha),m(t,"end",0)),this.setDelay(m(t,"delay",0)),this.setDuration(m(t,"duration",1e3)),this}},{key:"toJSON",value:function(){return{mode:this.mode,start:this.alphaStart,end:this.alphaEnd,delay:this.delay,duration:this.duration}}},{key:"shutdown",value:function(){return c(u(r.prototype),"shutdown",this).call(this),this.gameObject=void 0,this}},{key:"setMode",value:function(t){return"string"==typeof t&&(t=E[t]),this.mode=t,this}},{key:"setAlphaRange",value:function(t,e){return this.alphaStart=t,this.alphaEnd=e,this}},{key:"setDelay",value:function(t){return this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"start",value:function(){if(this.isRunning)return this;this.gameObject.setAlpha(this.alphaStart);var t={targets:this.gameObject,alpha:this.alphaEnd,delay:this.delay,duration:this.duration,ease:"Linear",yoyo:2==this.mode,repeat:2==this.mode?-1:0,onComplete:function(){1===this.mode&&this.gameObject.destroy()},onCompleteScope:this};return c(u(r.prototype),"start",this).call(this,t),this}}]),r}(),E={stop:0,destroy:1,yoyo:2},_={},g=function(){o(n,Phaser.Plugins.BasePlugin);var e=h(n);function n(t){return s(this,n),e.call(this,t)}return t(n,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this)}},{key:"add",value:function(t,e){return new y(t,e)}}]),n}(),b={fadeOutDestroy:function(t,e,n,i){return n instanceof y&&(i=n,n=void 0),void 0===n&&(n=!0),_.mode=n?1:0,_.end=0,_.duration=e,void 0===i?i=new y(t,_):i.resetFromJSON(_),i.restart(),i}};return Object.assign(g.prototype,b),g});
  