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).rexsoundfadeplugin=e()}(this,function(){"use strict";function o(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 u(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 a(t){return(a=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 h(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function c(s){var o=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 t,e,n,i=a(s);if(o){var r=a(this).constructor;t=Reflect.construct(i,arguments,r)}else t=i.apply(this,arguments);return e=this,!(n=t)||"object"!=typeof n&&"function"!=typeof n?h(e):n}}function l(t,e,n){return(l="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=a(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 s(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,v=Phaser.Utils.Objects.GetValue,d=function(){function r(t,e){var n;o(this,r),this.parent=t,this.scene=s(n=t)?n:n.scene&&s(n.scene)?n.scene:n.parent&&n.parent.scene&&s(n.parent.scene)?n.parent.scene:void 0;var i=v(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):s(this.parent)&&this.parent.events.once("shutdown",this.destroy,this)}},{key:"shutdown",value:function(){return this.stop(),s(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(d.prototype,e);var m=Phaser.Utils.Objects.GetValue,p=Phaser.Utils.Objects.GetAdvancedValue,y=function(){u(s,d);var r=c(s);function s(t,e,n){var i;return o(this,s),(i=r.call(this,t)).sound=e,i.sound.on("destroy",i.destroy,h(i)),i.volume={},i.resetFromJSON(n),i}return t(s,[{key:"resetFromJSON",value:function(t){return this.setMode(m(t,"mode",0)),this.setVolumeRange(p(t,"volume.start",this.sound.volume),p(t,"volume.end",0)),this.setDelay(p(t,"delay",0)),this.setFadeOutTime(p(t,"duration",1e3)),this}},{key:"toJSON",value:function(){return{mode:this.mode,volume:this.volume,delay:this.delay,duration:this.duration}}},{key:"shutdown",value:function(){this.sound.off("destroy",this.destroy,this),this.sound=void 0,l(a(s.prototype),"shutdown",this).call(this)}},{key:"setMode",value:function(t){return"string"==typeof t&&(t=E[t]),this.mode=t,this}},{key:"setVolumeRange",value:function(t,e){return this.volume.start=t,this.volume.end=e,this}},{key:"setDelay",value:function(t){return this.delay=t,this}},{key:"setFadeOutTime",value:function(t){return this.duration=t,this}},{key:"start",value:function(){if(this.isRunning)return this;this.sound.setVolume(this.volume.start);var t={targets:this.sound,volume:this.volume.end,delay:this.delay,duration:this.duration,ease:"Linear",onComplete:function(){switch(this.mode){case 1:this.sound.stop();break;case 2:this.sound.destroy()}},onCompleteScope:this};return l(a(s.prototype),"start",this).call(this,t),this}}]),s}(),E={stop:1,destroy:2},_={volume:{}},g={volume:{}},w=function(t,e,n,i,r){var s;return void 0===i&&(i=1),void 0===r&&(r=0),_.mode=0,_.volume.start=r,_.volume.end=i,_.duration=n,"string"==typeof e&&(e=t.sound.add(e)),e.hasOwnProperty("_fade")?(s=e._fade).stop().resetFromJSON(_):(s=new y(t,e,_),e._fade=s),s.start(),e.isPlaying||e.setVolume(r).play(),e},O=function(t,e,n,i){var r;return void 0===i&&(i=!0),g.mode=i?2:1,g.volume.start=e.volume,g.volume.end=0,g.duration=n,e.hasOwnProperty("_fade")?(r=e._fade).stop().resetFromJSON(g):(r=new y(t,e,g),e._fade=r),r.start(),e.isPlaying||e.play(),e};return function(){u(n,Phaser.Plugins.BasePlugin);var e=c(n);function n(t){return o(this,n),e.call(this,t)}return t(n,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this)}},{key:"fadeIn",value:function(t,e,n,i,r){return w(t,e,n,i,r)}},{key:"fadeOut",value:function(t,e,n,i){return O(t,e,n,i)}}]),n}()});
  