UNPKG

phaser3-rex-plugins

Version:
1 lines 630 kB
var t,e;t=void 0,e=function(){class t{constructor(t){this.scene=t,this.displayList=t.sys.displayList,this.updateList=t.sys.updateList,t.events.once("destroy",this.destroy,this)}destroy(){this.scene=null,this.displayList=null,this.updateList=null}static register(e,i){t.prototype[e]=i}}var e={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 i=Phaser.Scene;var s=function(t){return t instanceof i},r=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 n=Phaser.Game;var a=function(t){return t instanceof n},o=function(t){return null==t||"object"!=typeof t?null:a(t)?t:a(t.game)?t.game:s(t)?t.sys.game:s(t.scene)?t.scene.sys.game:void 0};const h=Phaser.Utils.Objects.GetValue;class l{constructor(t,e){this.setParent(t),this.isShutdown=!1,this.setEventEmitter(h(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){return this.parent=t,this.scene=r(t),this.game=o(t),this}}Object.assign(l.prototype,e);const d=Phaser.Utils.Objects.GetValue;class c extends l{constructor(t,e){super(t,e),this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setTickingMode(d(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=u[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 u={no:0,lazy:1,always:2};var p=function(t){return void 0!==t.displayWidth?t.displayWidth:t.width},g=function(t){return void 0!==t.displayHeight?t.displayHeight:t.height};const v=Phaser.Geom.Rectangle,f=Phaser.Math.Vector2,m=Phaser.Math.RotateAround,b=Phaser.GameObjects.Container;var y=function(t,e){if(void 0===e?e=new v:!0===e&&(void 0===x&&(x=new v),e=x),t.getBounds&&!(t instanceof b))return t.getBounds(e);var i,s,r,n,a,o,h,l;if(t.parentContainer){var d=t.parentContainer.getBoundsTransformMatrix();C(t,e),d.transformPoint(e.x,e.y,e),i=e.x,s=e.y,w(t,e),d.transformPoint(e.x,e.y,e),r=e.x,n=e.y,O(t,e),d.transformPoint(e.x,e.y,e),a=e.x,o=e.y,S(t,e),d.transformPoint(e.x,e.y,e),h=e.x,l=e.y}else C(t,e),i=e.x,s=e.y,w(t,e),r=e.x,n=e.y,O(t,e),a=e.x,o=e.y,S(t,e),h=e.x,l=e.y;return e.x=Math.min(i,r,a,h),e.y=Math.min(s,n,o,l),e.width=Math.max(i,r,a,h)-e.x,e.height=Math.max(s,n,o,l)-e.y,e},x=void 0,C=function(t,e,i){return void 0===e?e=new f:!0===e&&(void 0===k&&(k=new f),e=k),t.getTopLeft?t.getTopLeft(e,i):(e.x=t.x-p(t)*t.originX,e.y=t.y-g(t)*t.originY,P(t,e,i))},w=function(t,e,i){return void 0===e?e=new f:!0===e&&(void 0===k&&(k=new f),e=k),t.getTopRight?t.getTopRight(e,i):(e.x=t.x-p(t)*t.originX+p(t),e.y=t.y-g(t)*t.originY,P(t,e,i))},O=function(t,e,i){return void 0===e?e=new f:!0===e&&(void 0===k&&(k=new f),e=k),t.getBottomLeft?t.getBottomLeft(e,i):(e.x=t.x-p(t)*t.originX,e.y=t.y-g(t)*t.originY+g(t),P(t,e,i))},S=function(t,e,i){return void 0===e?e=new f:!0===e&&(void 0===k&&(k=new f),e=k),t.getBottomRight?t.getBottomRight(e,i):(e.x=t.x-p(t)*t.originX+p(t),e.y=t.y-g(t)*t.originY+g(t),P(t,e,i))},T=function(t,e,i){void 0===e?e=new f:!0===e&&(void 0===k&&(k=new f),e=k);var s=p(t),r=g(t);return e.x=t.x+s*(.5-t.originX),e.y=t.y+r*(.5-t.originY),P(t,e,i)},k=void 0,P=function(t,e,i){return void 0===i&&(i=!1),0!==t.rotation&&m(e,t.x,t.y,t.rotation),i&&t.parentContainer&&t.parentContainer.getBoundsTransformMatrix().transformPoint(e.x,e.y,e),e},M=function(t,e,i,s,r){return!(!t||s&&!s(t,e,i)||!y(t,!0).contains(e,i)||r&&!r(t,e,i))},_=function(t,e,i){var s=t.camera;return s?(void 0===i?i={}:!0===i&&(i=E),s===e?(i.x=t.worldX,i.y=t.worldY):s.getWorldPoint(t.x,t.y,i),i):null},E={},R=function(t,e,i,s){return function(t,e,i,s,r){var n,a=t.scene.sys.cameras.main,o=0===t.scrollFactorX&&0===t.scrollFactorY;if(e)return o?i(t,e.x,e.y,s,r):!!(n=_(e,a,!0))&&i(t,n.x,n.y,s,r);for(var h=t.scene.input.manager,l=h.pointersTotal,d=h.pointers,c=0;c<l;c++)if(e=d[c],o){if(i(t,e.x,e.y,s,r))return!0}else{if(!(n=_(e,a,!0)))continue;if(i(t,n.x,n.y,s,r))return!0}return!1}(t,e,M,i,s)};const L=Phaser.Utils.Objects.GetValue;class D extends c{constructor(t,e){var i=r(t);i===t&&(t=void 0),super(i,e),this.gameObject=t,t&&t.setInteractive(L(e,"inputConfig",void 0)),this._enable=void 0,this.resetFromJSON(e),this.boot()}resetFromJSON(t){return this.setEnable(L(t,"enable",!0)),this.setDetectBounds(),void 0===this.gameObject?this.setDetectBounds(L(t,"bounds",void 0)):this.setDetectBounds(),this.tracerState=B,this.pointer=void 0,this.lastPointer=void 0,this.movedState=!1,this.isTouchingAnyObject=!1,this}boot(){super.boot(),this.gameObject?this.gameObject.on("pointerdown",this.onPointerDown,this):this.scene.input.on("pointerdown",this.onPointerDown,this),this.scene.input.on("pointerup",this.onPointerUp,this),this.scene.input.on("gameout",this.dragCancel,this),this.scene.input.on("pointermove",this.onPointerMove,this),this.scene.sys.events.once("shutdown",this.destroy,this)}shutdown(t){this.scene&&(this.gameObject||this.scene.input.off("pointerdown",this.onPointerDown,this),this.scene.input.off("pointerup",this.onPointerUp,this),this.scene.input.off("gameout",this.dragCancel,this),this.scene.input.off("pointermove",this.onPointerMove,this),this.scene.sys.events.off("shutdown",this.destroy,this),this.gameObject=void 0,this.bounds=void 0,this.pointer=void 0,this.lastPointer=void 0,this.movedState=!1,super.shutdown(t))}get enable(){return this._enable}set enable(t){if(this._enable!==t)return t||this.dragCancel(),this._enable=t,this}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}setDetectBounds(t){return this.bounds=t,this}toggleEnable(){return this.setEnable(!this.enable),this}onPointerDown(t,e){this.enable&&void 0===this.pointer&&(!this.bounds||this.bounds.contains(t.x,t.y))&&this.pointer!==t&&(this.pointer=t,this.pointerCamera=t.camera,this.lastPointer=t,this.movedState=!1,this.tracerState=I,void 0===this.gameObject&&(this.isTouchingAnyObject=e.length>0),this.onDragStart())}onPointerUp(t){this.enable&&(!this.bounds||this.bounds.contains(t.x,t.y))&&this.pointer===t&&(this.pointer=void 0,this.pointerCamera=void 0,this.movedState=!1,this.tracerState=B,this.onDragEnd())}onPointerMove(t){if(this.enable&&t.isDown){var e=!this.bounds||this.bounds.contains(t.x,t.y),i=this.pointer===t;!i&&e||(i&&!e?this.onPointerUp(t):(this.movedState||(this.movedState=t.x!==t.downX||t.y!==t.downY),this.movedState&&this.onDrag()))}}dragCancel(){return this.tracerState===I&&this.onDragEnd(),this.pointer=void 0,this.tracerState=B,this}onDragStart(){this.emit("dragstart",this)}onDragEnd(){this.emit("dragend",this)}onDrag(){this.emit("drag",this)}preUpdate(t,e){}postUpdate(t,e){}startTicking(){super.startTicking(),this.scene.sys.events.on("preupdate",this.preUpdate,this),this.scene.sys.events.on("postupdate",this.postUpdate,this)}stopTicking(){super.stopTicking(),this.scene&&(this.scene.sys.events.off("preupdate",this.preUpdate,this),this.scene.sys.events.off("postupdate",this.postUpdate,this))}setRecongizedStateObject(t){return this.recongizedState=t,this}get state(){return this.recongizedState.state}set state(t){this.recongizedState.state=t}cancel(){return this.state=A,this}isPointerInGameObject(t,e,i){var s=this.lastPointer;return!!s&&R(t,s,e,i)}}const B=0,I=1,A="IDLE";function W(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Y={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function s(){}function r(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function n(t,e,s,n,a){if("function"!=typeof s)throw new TypeError("The listener must be a function");var o=new r(s,n||t,a),h=i?i+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new s:delete t._events[e]}function o(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(i=!1)),o.prototype.eventNames=function(){var t,s,r=[];if(0===this._eventsCount)return r;for(s in t=this._events)e.call(t,s)&&r.push(i?s.slice(1):s);return Object.getOwnPropertySymbols?r.concat(Object.getOwnPropertySymbols(t)):r},o.prototype.listeners=function(t){var e=i?i+t:t,s=this._events[e];if(!s)return[];if(s.fn)return[s.fn];for(var r=0,n=s.length,a=new Array(n);r<n;r++)a[r]=s[r].fn;return a},o.prototype.listenerCount=function(t){var e=i?i+t:t,s=this._events[e];return s?s.fn?1:s.length:0},o.prototype.emit=function(t,e,s,r,n,a){var o=i?i+t:t;if(!this._events[o])return!1;var h,l,d=this._events[o],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(t,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,e),!0;case 3:return d.fn.call(d.context,e,s),!0;case 4:return d.fn.call(d.context,e,s,r),!0;case 5:return d.fn.call(d.context,e,s,r,n),!0;case 6:return d.fn.call(d.context,e,s,r,n,a),!0}for(l=1,h=new Array(c-1);l<c;l++)h[l-1]=arguments[l];d.fn.apply(d.context,h)}else{var u,p=d.length;for(l=0;l<p;l++)switch(d[l].once&&this.removeListener(t,d[l].fn,void 0,!0),c){case 1:d[l].fn.call(d[l].context);break;case 2:d[l].fn.call(d[l].context,e);break;case 3:d[l].fn.call(d[l].context,e,s);break;case 4:d[l].fn.call(d[l].context,e,s,r);break;default:if(!h)for(u=1,h=new Array(c-1);u<c;u++)h[u-1]=arguments[u];d[l].fn.apply(d[l].context,h)}}return!0},o.prototype.on=function(t,e,i){return n(this,t,e,i,!1)},o.prototype.once=function(t,e,i){return n(this,t,e,i,!0)},o.prototype.removeListener=function(t,e,s,r){var n=i?i+t:t;if(!this._events[n])return this;if(!e)return a(this,n),this;var o=this._events[n];if(o.fn)o.fn!==e||r&&!o.once||s&&o.context!==s||a(this,n);else{for(var h=0,l=[],d=o.length;h<d;h++)(o[h].fn!==e||r&&!o[h].once||s&&o[h].context!==s)&&l.push(o[h]);l.length?this._events[n]=1===l.length?l[0]:l:a(this,n)}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 s,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}(Y);var j=W(Y.exports);let z=class extends j{shutdown(){this.removeAllListeners()}destroy(){this.removeAllListeners()}};var X={setEventEmitter(t,e){return void 0===e&&(e=z),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):[]}},F=function(t,e,i,s){var r=t&&("object"==typeof t||"function"==typeof t),n=s&&("object"==typeof s||"function"==typeof s);if(!r&&!n)return i;var a=String(e);if(r&&a in t)return t[a];if(n&&a in s)return s[a];if(-1===a.indexOf("."))return i;var o=a.split(".");if(r){var h=H(t,o,i);if(h.found)return h.value}if(n){var l=H(s,o,i);if(l.found)return l.value}return i},H=function(t,e,i){for(var s=t,r=i,n=0,a=e.length;n<a;n++){var o=e[n];if(!s||"object"!=typeof s&&"function"!=typeof s||!(o in s))return V.found=!1,V;s=r=s[o]}return V.found=!0,V.value=r,V},V={};const G=["next","exit","enter"];let U=class{constructor(t){var e=F(t,"states",void 0);e&&this.addStates(e);var i=F(t,"extend",void 0);if(i)for(var s in i)this.hasOwnProperty(s)&&void 0!==this[s]||(this[s]=i[s]);var r=F(t,"eventEmitter",void 0),n=F(t,"EventEmitterClass",void 0);this.setEventEmitter(r,n),this._stateLock=!1,this.resetFromJSON(t)}shutdown(){this.destroyEventEmitter()}destroy(){this.shutdown()}resetFromJSON(t){this.setEnable(F(t,"enable",!0)),this.start(F(t,"start",void 0));var e=F(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,i=this[e];i&&i.call(this),this.emit(e,this)}if(this._stateLock=!1,null!=this._state){var s="enter_"+this._state,r=this[s];r&&r.call(this),this.emit(s,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 G}addState(t,e){"string"!=typeof t&&(t=(e=t).name);for(var i=this.stateProperties,s=0,r=i.length;s<r;s++){var n=i[s],a=e[n];a&&(this[`${n}_${t}`]=a)}return this}addStates(t){if(Array.isArray(t))for(var e=0,i=t.length;e<i;e++)this.addState(t[e]);else for(var s in t)this.addState(s,t[s]);return this}runMethod(t,e,i,s,r,n){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,s);case 5:return a.call(this,e,i,s,r);case 6:return a.call(this,e,i,s,r,n)}for(var h=new Array(o-1),l=1;l<o;l++)h[l-1]=arguments[l];return a.apply(this,h)}}};Object.assign(U.prototype,X);var N=function(t,e,i,s,r){void 0===r&&(r=!1);var n=t._events[e];if(!n)return!1;for(var a=0,o=n.length;a<o;a++){var h=n[a];if(h.fn===i&&h.context===s&&h.once===r)return!0}return!1};const $=["next","exit","enter","update","preupdate","postupdate"];class K extends U{shutdown(){this.stopUpdate(),this.stopPreUpdate(),this.stopPostUpdate(),this._scene=void 0,super.shutdown()}resetFromJSON(t){return super.resetFromJSON(t),this._scene=F(t,"scene",void 0),this}get stateProperties(){return $}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 N(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 N(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 N(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}}const Z=Phaser.Utils.Objects.GetValue,J=Phaser.Math.Distance.Between;class q extends D{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{enter:function(){i.stop(),i.tapsCount=0,i.x=0,i.y=0,i.worldX=0,i.worldY=0,i.lastPointer=void 0},exit:function(){var t=i.lastPointer;i.x=t.x,i.y=t.y,i.worldX=t.worldX,i.worldY=t.worldY}},BEGIN:{enter:function(){i.start(),i.tapsCount=0,i.emit("tappingstart",i,i.gameObject,i.lastPointer)}},RECOGNIZED:{enter:function(){i.start(),i.emit("tap",i,i.gameObject,i.lastPointer),i.emit(`${i.tapsCount}tap`,i,i.gameObject,i.lastPointer)}}},init:function(){this.state=Q},eventEmitter:!1};this.setRecongizedStateObject(new K(s))}resetFromJSON(t){super.resetFromJSON(t),this.setHoldTime(Z(t,"time",250)),this.setTapInterval(Z(t,"tapInterval",200)),this.setDragThreshold(Z(t,"threshold",9)),this.setTapOffset(Z(t,"tapOffset",10));var e=Z(t,"taps",void 0);return void 0!==e?this.setTaps(e):(this.setMaxTaps(Z(t,"maxTaps",void 0)),this.setMinTaps(Z(t,"minTaps",void 0))),this}onDragStart(){switch(this.state){case Q:this.state=tt;break;case tt:var t=this.lastPointer;J(t.upX,t.upY,t.x,t.y)>this.tapOffset&&(this.state=et,this.state=tt);break;case et:this.state=tt}}onDragEnd(){this.state===tt&&(this.tapsCount++,this.emit("tapping",this,this.gameObject,this.lastPointer),void 0!==this.maxTaps&&this.tapsCount===this.maxTaps&&(this.state=et))}onDrag(){this.state!==Q&&this.pointer.getDistance()>this.dragThreshold&&(this.state=Q)}preUpdate(t,e){if(this.isRunning&&this.enable&&this.state===tt){var i=this.lastPointer;i.isDown?t-i.downTime>this.holdTime&&(this.state=Q):t-i.upTime>this.tapInterval&&(void 0===this.minTaps||this.tapsCount>=this.minTaps?this.state=et:this.state=Q)}}postUpdate(t,e){this.isRunning&&this.enable&&this.state===et&&(this.state=Q)}get isTapping(){return this.state===et}get isTapped(){return this.isTapping}setHoldTime(t){return this.holdTime=t,this}setTapInterval(t){return this.tapInterval=t,this}setDragThreshold(t){return this.dragThreshold=t,this}setTapOffset(t){return this.tapOffset=t,this}setMaxTaps(t){return this.maxTaps=t,this}setMinTaps(t){return this.minTaps=t,this}setTaps(t,e){return void 0===e&&(e=t),this.setMinTaps(t).setMaxTaps(e),this}}const Q="IDLE",tt="BEGIN",et="RECOGNIZED",it=Phaser.Utils.Objects.GetValue;class st extends D{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{enter:function(){i.x=0,i.y=0,i.worldX=0,i.worldY=0,i.lastPointer=void 0},exit:function(){var t=i.lastPointer;i.x=t.x,i.y=t.y,i.worldX=t.worldX,i.worldY=t.worldY}},BEGIN:{enter:function(){i.start()},exit:function(){i.stop()}},RECOGNIZED:{enter:function(){i.emit("pressstart",i,i.gameObject,i.lastPointer)},exit:function(){i.emit("pressend",i,i.gameObject,i.lastPointer)}}},init:function(){this.state=rt},eventEmitter:!1};this.setRecongizedStateObject(new K(s))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(it(t,"threshold",9)),this.setHoldTime(it(t,"time",251)),this}onDragStart(){this.state=nt,0===this.holdTime&&(this.state=at)}onDragEnd(){this.state=rt}onDrag(){this.state!==rt&&this.pointer.getDistance()>this.dragThreshold&&(this.state=rt)}preUpdate(t,e){this.isRunning&&this.enable&&this.state===nt&&t-this.pointer.downTime>=this.holdTime&&(this.state=at)}get isPressing(){return this.state===at}get isPressed(){return this.isPressing}setHoldTime(t){return this.holdTime=t,this}setDragThreshold(t){return this.dragThreshold=t,this}}const rt="IDLE",nt="BEGIN",at="RECOGNIZED",ot=Phaser.Utils.Objects.GetValue;class ht extends D{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{},BEGIN:{enter:function(){var t=i.pointer;i.startX=t.x,i.startY=t.y,i.startWorldX=t.worldX,i.startWorldY=t.worldY}},RECOGNIZED:{enter:function(){i.emit("panstart",i,i.gameObject,i.lastPointer)},exit:function(){var t=i.lastPointer;i.endX=t.x,i.endY=t.y;var e=_(t,i.pointerCamera,!0);i.endWorldX=e.x,i.endWorldY=e.y,i.emit("panend",i,i.gameObject,i.lastPointer)}}},init:function(){this.state=lt},eventEmitter:!1};this.setRecongizedStateObject(new K(s))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(ot(t,"threshold",10)),this}onDragStart(){this.state=dt,0===this.dragThreshold&&(this.state=ct)}onDragEnd(){this.state=lt}onDrag(){switch(this.state){case dt:if(this.pointer.getDistance()>=this.dragThreshold){this.state=ct,this.dx=0,this.dy=0,this.dWorldX=0,this.dWorldY=0;var t=this.pointer;this.x=t.x,this.y=t.y,this.worldX=t.worldX,this.worldY=t.worldY}break;case ct:var e=this.pointerCamera,i=this.pointer.position,s=this.pointer.prevPosition;this.dx=i.x-s.x,this.dy=i.y-s.y,this.dWorldX=this.dx/e.zoom,this.dWorldY=this.dy/e.zoom,t=this.pointer,this.x=t.x,this.y=t.y;var r=_(t,e,!0);this.worldX=r.x,this.worldY=r.y,this.emit("pan",this,this.gameObject,this.lastPointer)}}get isPanning(){return this.state===ct}get isPanned(){return this.isPanning}setDragThreshold(t){return this.dragThreshold=t,this}}const lt="IDLE",dt="BEGIN",ct="RECOGNIZED";var ut=function(t){return o(t).loop.delta};const pt=Phaser.Math.Distance.Between,gt=Phaser.Math.Angle.Between;var vt={getDt:function(){return ut(this.scene)},getVelocity:function(){var t=this.pointer.position,e=this.pointer.prevPosition;return pt(e.x,e.y,t.x,t.y)/(.001*this.getDt())},getVelocityX:function(){var t=this.pointer.position,e=this.pointer.prevPosition;return Math.abs(t.x-e.x)/(.001*this.getDt())},getVelocityY:function(){var t=this.pointer.position,e=this.pointer.prevPosition;return Math.abs(t.y-e.y)/(.001*this.getDt())},getVelocityAngle:function(){var t=this.pointer.position,e=this.pointer.prevPosition;return gt(e.x,e.y,t.x,t.y)}},ft={"up&down":0,"left&right":1,"4dir":2,"8dir":3},mt={};const bt=Phaser.Utils.Objects.GetValue,yt=Phaser.Math.RadToDeg;class xt extends D{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{enter:function(){i.x=0,i.y=0,i.worldX=0,i.worldY=0},exit:function(){var t=i.lastPointer;i.x=t.x,i.y=t.y,i.worldX=t.worldX,i.worldY=t.worldY}},BEGIN:{enter:function(){i.validDrag=!1}},RECOGNIZED:{enter:function(){i.start(),i.updateDirectionStates(),i.emit("swipe",i,i.gameObject,i.lastPointer)},exit:function(){i.stop(),i.clearDirectionStates()}}},init:function(){this.state=Ct},eventEmitter:!1};this.setRecongizedStateObject(new K(s)),this.clearDirectionStates()}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(bt(t,"threshold",10)),this.setVelocityThreshold(bt(t,"velocityThreshold",1e3)),this.setDirectionMode(bt(t,"dir","8dir")),this}onDragStart(){this.state=wt}onDragEnd(){this.state=Ct}onDrag(){this.state===wt&&(this.validDrag||(this.validDrag=0===this.dragThreshold||this.pointer.getDistance()>=this.dragThreshold),this.validDrag&&this.dragVelocity>this.velocityThreshold&&(this.state=Ot))}postUpdate(t,e){this.isRunning&&this.enable&&this.state===Ot&&(this.state=Ct)}get isSwiping(){return this.state===Ot}get isSwiped(){return this.isSwiping}get dragVelocity(){var t;switch(this.dirMode){case 0:t=this.getVelocityY();break;case 1:t=this.getVelocityX();break;default:t=this.getVelocity()}return t}setDragThreshold(t){return this.dragThreshold=t,this}setVelocityThreshold(t){return this.velocityThreshold=t,this}setDirectionMode(t){return"string"==typeof t&&(t=ft[t]),this.dirMode=t,this}updateDirectionStates(){return function(t,e,i){switch(void 0===i?i={}:!0===i&&(i=mt),i.left=!1,i.right=!1,i.up=!1,i.down=!1,t=(t+360)%360,e){case 0:t<180?i.down=!0:i.up=!0;break;case 1:t>90&&t<=270?i.left=!0:i.right=!0;break;case 2:t>45&&t<=135?i.down=!0:t>135&&t<=225?i.left=!0:t>225&&t<=315?i.up=!0:i.right=!0;break;case 3:t>22.5&&t<=67.5?(i.down=!0,i.right=!0):t>67.5&&t<=112.5?i.down=!0:t>112.5&&t<=157.5?(i.down=!0,i.left=!0):t>157.5&&t<=202.5?i.left=!0:t>202.5&&t<=247.5?(i.left=!0,i.up=!0):t>247.5&&t<=292.5?i.up=!0:t>292.5&&t<=337.5?(i.up=!0,i.right=!0):i.right=!0}}(yt(this.getVelocityAngle()),this.dirMode,this),this}clearDirectionStates(){return this.left=!1,this.right=!1,this.up=!1,this.down=!1,this}}Object.assign(xt.prototype,vt);const Ct="IDLE",wt="BEGIN",Ot="RECOGNIZED";var St=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];return t};const Tt=Phaser.Utils.Objects.GetValue,kt=Phaser.Utils.Array.SpliceOne,Pt=Phaser.Math.Distance.Between,Mt=Phaser.Math.Angle.Between;class _t{constructor(t,e){var i=r(t);i===t&&(t=void 0);var s=i.input.manager.pointersTotal-1;s<2&&i.input.addPointer(2-s),this.scene=i,this.gameObject=t,t&&t.setInteractive(Tt(e,"inputConfig",void 0)),this.setEventEmitter(Tt(e,"eventEmitter",void 0)),this._enable=void 0,this.pointers=[],this.movedState={},this.resetFromJSON(e),this.boot()}resetFromJSON(t){return this.setEnable(Tt(t,"enable",!0)),this.bounds=Tt(t,"bounds",void 0),this.tracerState=Rt,this.pointers.length=0,St(this.movedState),this}boot(){this.gameObject?this.gameObject.on("pointerdown",this.onPointerDown,this):this.scene.input.on("pointerdown",this.onPointerDown,this),this.scene.input.on("pointerup",this.onPointerUp,this),this.scene.input.on("gameout",this.dragCancel,this),this.scene.input.on("pointermove",this.onPointerMove,this),this.scene.sys.events.once("shutdown",this.destroy,this)}shutdown(){this.scene&&(this.destroyEventEmitter(),this.pointers.length=0,St(this.movedState),this.gameObject||this.scene.input.off("pointerdown",this.onPointerDown,this),this.scene.input.off("pointerup",this.onPointerUp,this),this.scene.input.off("gameout",this.dragCancel,this),this.scene.input.off("pointermove",this.onPointerMove,this),this.scene.sys.events.off("shutdown",this.destroy,this),this.scene=void 0,this.gameObject=void 0)}destroy(){this.shutdown()}get enable(){return this._enable}set enable(t){if(this._enable!==t)return t||this.dragCancel(),this._enable=t,this}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}toggleEnable(){return this.setEnable(!this.enable),this}onPointerDown(t){if(this.enable&&2!==this.pointers.length&&(!this.bounds||this.bounds.contains(t.x,t.y))&&-1===this.pointers.indexOf(t))switch(this.movedState[t.id]=!1,this.pointers.push(t),this.pointerCamera=t.camera,this.tracerState){case Rt:this.tracerState=Lt,this.onDrag1Start();break;case Lt:this.tracerState=Dt,this.onDrag2Start()}}onPointerUp(t){if(this.enable&&(!this.bounds||this.bounds.contains(t.x,t.y))){var e=this.pointers.indexOf(t);if(-1!==e)switch(delete this.movedState[t.id],kt(this.pointers,e),this.tracerState){case Lt:this.tracerState=Rt,this.onDrag1End();break;case Dt:this.tracerState=Lt,this.onDrag2End(),this.onDrag1Start()}}}onPointerMove(t){if(this.enable&&t.isDown){var e=!this.bounds||this.bounds.contains(t.x,t.y),i=-1!==this.pointers.indexOf(t);if(!i&&e);else if(i&&!e)this.onPointerUp(t);else if(this.movedState[t.id]||(this.movedState[t.id]=t.x!==t.downX||t.y!==t.downY),this.movedState[t.id])switch(this.tracerState){case Lt:this.onDrag1();break;case Dt:this.onDrag2()}}}dragCancel(){return this.tracerState===Dt&&this.onDrag2End(),this.pointers.length=0,St(this.movedState),this.tracerState=Rt,this}onDrag1Start(){this.emit("drag1start",this)}onDrag1End(){this.emit("drag1end",this)}onDrag1(){this.emit("drag1",this)}onDrag2Start(){this.emit("drag2start",this)}onDrag2End(){this.emit("drag2end",this)}onDrag2(){this.emit("drag2",this)}get distanceBetween(){if(this.tracerState!==Dt)return 0;var t=this.pointers[0],e=this.pointers[1];return Pt(t.x,t.y,e.x,e.y)}get angleBetween(){if(this.tracerState!==Dt)return 0;var t=this.pointers[0],e=this.pointers[1];return Mt(t.x,t.y,e.x,e.y)}get drag1Vector(){var t=this.pointers[0];if(t&&this.movedState[t.id]){var e=t.position,i=t.prevPosition;Et.x=e.x-i.x,Et.y=e.y-i.y}else Et.x=0,Et.y=0;return Et}get centerX(){if(this.tracerState!==Dt)return 0;var t=this.pointers[0].position,e=this.pointers[1].position;return(t.x+e.x)/2}get centerY(){if(this.tracerState!==Dt)return 0;var t=this.pointers[0].position,e=this.pointers[1].position;return(t.y+e.y)/2}get prevCenterX(){if(this.tracerState!==Dt)return 0;var t=this.movedState[this.pointers[0].id]?this.pointers[0].prevPosition:this.pointers[0].position,e=this.movedState[this.pointers[1].id]?this.pointers[1].prevPosition:this.pointers[1].position;return(t.x+e.x)/2}get prevCenterY(){if(this.tracerState!==Dt)return 0;var t=this.movedState[this.pointers[0].id]?this.pointers[0].prevPosition:this.pointers[0].position,e=this.movedState[this.pointers[1].id]?this.pointers[1].prevPosition:this.pointers[1].position;return(t.y+e.y)/2}get movementCenterX(){return this.centerX-this.prevCenterX}get movementCenterY(){return this.centerY-this.prevCenterY}setRecongizedStateObject(t){return this.recongizedState=t,this}get state(){return this.recongizedState.state}set state(t){this.recongizedState.state=t}cancel(){return this.state=Bt,this}isPointer0InGameObject(t,e,i){var s=this.pointers[0];return!!s&&R(t,s,e,i)}isPointer1InGameObject(t,e,i){var s=this.pointers[1];return!!s&&R(t,s,e,i)}}Object.assign(_t.prototype,e);var Et={};const Rt=0,Lt=1,Dt=2,Bt="IDLE",It=Phaser.Utils.Objects.GetValue;class At extends _t{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{enter:function(){i.prevDistance=void 0,i.scaleFactor=1}},BEGIN:{},RECOGNIZED:{enter:function(){i.emit("pinchstart",i)},exit:function(){i.emit("pinchend",i)}}},init:function(){this.state=Wt},eventEmitter:!1};this.setRecongizedStateObject(new K(s))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(It(t,"threshold",0)),this}onDrag2Start(){this.scaleFactor=1,this.prevDistance=this.distanceBetween,this.state=Yt,0===this.dragThreshold&&(this.state=jt)}onDrag2End(){this.state=Wt}onDrag2(){switch(this.state){case Yt:if(this.pointers[0].getDistance()>=this.dragThreshold&&this.pointers[1].getDistance()>=this.dragThreshold){var t=this.distanceBetween;this.scaleFactor=t/this.prevDistance,this.prevDistance=t,this.state=jt}break;case jt:t=this.distanceBetween,this.scaleFactor=t/this.prevDistance,this.emit("pinch",this),this.prevDistance=t}}get isPinching(){return this.state===jt}get isPinched(){return this.isPinching}setDragThreshold(t){return this.dragThreshold=t,this}}const Wt="IDLE",Yt="BEGIN",jt="RECOGNIZED",zt=Phaser.Math.RotateAround;var Xt=function(t,e,i,s){return zt(t,e,i,s),t.rotation+=s,t},Ft={};const Ht=Phaser.Utils.Objects.GetValue,Vt=Phaser.Math.Angle.WrapDegrees,Gt=Phaser.Math.Angle.ShortestBetween,Ut=Phaser.Math.RadToDeg,Nt=Phaser.Math.DegToRad;var $t={spinObject:function(t,e){if(!this.isRotation)return this;void 0===e&&(e=this.pointers[0].camera);var i=this.movementCenterX,s=this.movementCenterY,r=function(t,e,i,s){return void 0===s?s={}:!0===s&&(s=Ft),i.getWorldPoint(t,e,s),s}(this.centerX,this.centerY,e,!0),n=r.x,a=r.y,o=this.rotation;if(Array.isArray(t))for(var h=t,l=0,d=h.length;l<d;l++)(t=h[l]).x+=i,t.y+=s,Xt(t,n,a,o);else t.x+=i,t.y+=s,Xt(t,n,a,o);return this}};Object.assign(class extends _t{constructor(t,e){super(t,e);var i=this,s={states:{IDLE:{enter:function(){i.prevAngle=void 0,i.angle=0}},BEGIN:{},RECOGNIZED:{enter:function(){i.emit("rotatestart",i)},exit:function(){i.emit("rotateend",i)}}},init:function(){this.state=Kt},eventEmitter:!1};this.setRecongizedStateObject(new K(s))}resetFromJSON(t){return super.resetFromJSON(t),this.setDragThreshold(Ht(t,"threshold",0)),this}onDrag2Start(){this.prevAngle=Vt(Ut(this.angleBetween)),this.state=Zt,0===this.dragThreshold&&(this.state=Jt)}onDrag2End(){this.state=Kt}onDrag2(){switch(this.state){case Zt:if(this.pointers[0].getDistance()>=this.dragThreshold&&this.pointers[1].getDistance()>=this.dragThreshold){var t=Vt(Ut(this.angleBetween));this.angle=Gt(this.prevAngle,t),this.prevAngle=t,this.state=Jt}break;case Jt:t=Vt(Ut(this.angleBetween)),this.angle=Gt(this.prevAngle,t),this.prevAngle=t,this.emit("rotate",this)}}get isRotating(){return this.state===Jt}get isRotated(){return this.isRotating}get rotation(){return Nt(this.angle)}setDragThreshold(t){return this.dragThreshold=t,this}}.prototype,$t);const Kt="IDLE",Zt="BEGIN",Jt="RECOGNIZED";var qt=function(t,e){var i,s=t.cameras;if(void 0===e)i=s.main;else switch(typeof e){case"string":i=s.getCamera(e);break;case"number":i=s.cameras[e];break;default:i=e}return i};const Qt=Phaser.Utils.Objects.GetValue;class te extends l{constructor(t,e){void 0===e&&(e={}),super(t,e),this.inputTarget=Qt(e,"inputTarget",t),this.pan=new ht(this.inputTarget);var i=qt(t,Qt(e,"camera"));this.setCamera(i).setEnable(Qt(e,"enable",!0)),this.boot()}boot(){this.pan.on("pan",(function(t){var e=this.camera;if(e){var i=e.zoom;e.scrollX-=t.dx/i,e.scrollY-=t.dy/i}}),this).on("panstart",(function(){this.emit("panstart")}),this).on("panend",(function(){this.emit("panend")}),this)}shutdown(t){this.isShutdown||(this.inputTarget=void 0,this.pan.destroy(),this.pan=void 0,super.shutdown(t))}setCamera(t){return this.camera=t,this}get enable(){return this.pan.enable}set enable(t){this.pan.enable=t}setEnable=function(t){return void 0===t&&(t=!0),this.enable=t,this};get isPanning(){return this.pan.isPanning}}const ee=Phaser.Utils.Objects.GetValue;class ie extends l{constructor(t,e){void 0===e&&(e={}),super(t,e),this.inputTarget=ee(e,"inputTarget",t),this.pinch=new At(this.inputTarget);var i=qt(t,ee(e,"camera"));this.setCamera(i).setEnable(ee(e,"enable",!0)).setMinZoom(ee(e,"minZoom",void 0)).setMaxZoom(ee(e,"maxZoom",void 0)).setFocusEnable(ee(e,"focusEnable",!0)),this.boot()}boot(){this.focusWorldX=void 0,this.focusWorldY=void 0,this.pinch.on("pinchstart",(function(t){var e=t.pointers[0],i=t.pointers[1];this.focusEnable&&void 0===this.focusWorldX&&(this.focusWorldX=.5*(e.worldX+i.worldX),this.focusWorldY=.5*(e.worldY+i.worldY)),this.emit("pinchstart")}),this).on("pinch",(function(t){var e=this.camera;if(e){var i=e.zoom*t.scaleFactor;if(void 0!==this.minZoom&&i<this.minZoom&&(i=this.minZoom),void 0!==this.maxZoom&&i>this.maxZoom&&(i=this.maxZoom),e.zoom=i,e.preRender(),this.focusEnable){var s=t.pointers[0],r=t.pointers[1],n=.5*(s.x+r.x),a=.5*(s.y+r.y),o=e.getWorldPoint(n,a);e.scrollX-=o.x-this.focusWorldX,e.scrollY-=o.y-this.focusWorldY}}}),this).on("pinchend",(function(){this.focusWorldX=void 0,this.focusWorldY=void 0,this.emit("pinchend")}),this)}shutdown(t){this.isShutdown||(this.inputTarget=void 0,this.pinch.destroy(),this.pinch=void 0,super.shutdown(t))}setCamera(t){return this.camera=t,this}get enable(){return this.pinch.enable}set enable(t){this.pinch.enable=t}setEnable=function(t){return void 0===t&&(t=!0),this.enable=t,this};setMinZoom(t){return this.minZoom=t,this}setMaxZoom(t){return this.maxZoom=t,this}setFocusEnable(t){return this.focusEnable=t,this}get isPinching(){return this.pinch.isPinching}}const se=Phaser.Input.Keyboard.Key,re=Phaser.Input.Keyboard.KeyCodes,ne=["up","down","left","right"];class ae{constructor(t){this.scene=t,this.keys={},this.cursorKeys={},this.noKeyDown=!0;for(var e=0,i=ne.length;e<i;e++){var s=ne[e];this.addKey(s),this.cursorKeys[s]=this.keys[s]}}shutdown(t){for(var e in this.scene=void 0,this.keys)this.keys[e].destroy();this.keys=void 0,this.cursorKeys=void 0}destroy(t){shutdown(t)}createCursorKeys(){return this.cursorKeys}setKeyState(t,e){var i=this.keys[t];return i.enabled?(e&&(this.noKeyDown=!1),i.isDown!==e&&(oe.timeStamp=Date.now(),oe.keyCode=i.keyCode,e?i.onDown(oe):i.onUp(oe)),this):this}clearAllKeysState(){for(var t in this.noKeyDown=!0,this.keys)this.setKeyState(t,!1);return this}getKeyState(t){return this.keys[t]}get upKeyDown(){return this.keys.up.isDown}get downKeyDown(){return this.keys.down.isDown}get leftKeyDown(){return this.keys.left.isDown}get rightKeyDown(){return this.keys.right.isDown}get anyKeyDown(){return!this.noKeyDown}addKey(t,e){return void 0===e&&(e=t),"string"==typeof e&&(e=e.toUpperCase(),re.hasOwnProperty(e)&&(e=re[e])),this.keys[t]=new se(this.scene,e),this}addKeys(t){for(var e=0,i=t.length;e<i;e++)this.addKey(t[e]);return this}}var oe={timeStamp:0,keyCode:0,altKey:!1,ctrlKey:!1,shiftKey:!1,metaKey:!1,location:0};const he=Phaser.Cameras.Scene2D.BaseCamera,le=Phaser.Geom.Rectangle;var de=function(t,e,i){return e instanceof he||(i=e,e=void 0),void 0===i?i=new le:!0===i&&(i=ce),e?t.scale.getViewPort(e,i):t.scale.getViewPort(i)},ce=new le;const ue=Phaser.Utils.Objects.GetValue;class pe extends ae{constructor(t,e){super(t),this.scene=t,this._enable=void 0,this.setEnable(ue(e,"enable",!0)),this.setSensitiveDistance(ue(e,"sensitiveDistance",20));var i=ue(e,"bounds",void 0);void 0===i?(i=de(t),this.autoUpdateViewportBounds=!0):this.autoUpdateViewportBounds=!1,this.setBounds(i),this.pointerOutGameReleaseEnable=ue(e,"pointerOutGameRelease",!0),this.pointerOutBoundsReleaseEnable=ue(e,"pointerOutBoundsRelease",!1),this.boot()}boot(){this.scene.input.on("pointermove",this.onPointerMove,this),this.pointerOutGameReleaseEnable&&this.scene.input.on("gameout",this.clearAllKeysState,this),this.autoUpdateViewportBounds&&this.scene.scale.on("resize",this.updateBoundsByViewport,this),this.scene.sys.events.once("shutdown",this.destroy,this)}shutdown(){this.scene&&(this.scene.input.off("pointermove",this.onPointerMove,this),this.pointerOutGameReleaseEnable&&this.scene.input.off("gameout",this.clearAllKeysState,this),this.autoUpdateViewportBounds&&this.scene.scale.off("resize",this.updateBoundsByViewport,this),this.scene.sys.events.off("shutdown",this.destroy,this),this.scene=void 0,super.shutdown())}destroy(){this.shutdown()}updateBoundsByViewport(){de(this.scene,this.bounds)}get enable(){return this._enable}set enable(t){if(this._enable!==t)return t||this.clearAllKeysState(),this._enable=t,this}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}toggleEnable(){return this.setEnable(!this.enable),this}setBounds(t){return this.bounds=t,this}getBounds(){return this.bounds}setSensitiveDistance(t){return this.sensitiveDistance=t,this}onPointerMove(t){if(this.enable){var e=t.x,i=t.y,s=this.bounds.left,r=this.bounds.right,n=this.bounds.top,a=this.bounds.bottom,o=this.sensitiveDistance,h=e>=s&&e<=s+o,l=e<=r&&e>=r-o,d=i>=n&&i<=n+o,c=i<=a&&i>=a-o;this.pointerOutBoundsReleaseEnable||(h|=e<s,l|=e>r,d|=i<n,c|=i>a),this.setKeyState("left",h),this.setKeyState("right",l),this.setKeyState("up",d),this.setKeyState("down",c)}}get up(){return this.upKeyDown}get down(){return this.downKeyDown}get left(){return this.leftKeyDown}get right(){return this.rightKeyDown}get noKey(){return this.noKeyDown}}const ge=Phaser.Utils.Objects.GetValue;class ve extends l{constructor(t,e){void 0===e&&(e={}),super(t,e),this.cursorAtBounds=new pe(t);var i=this.cursorAtBounds.createCursorKeys();this.cameraController=new Phaser.Cameras.Controls.SmoothedKeyControl({left:i.left,right:i.right,up:i.up,down:i.down,acceleration:.06,drag:.003,maxSpeed:.3});var s=qt(t,ge(e,"camera"));this.setCamera(s).setEnable(ge(e,"enable",!0)),this.boot()}boot(){this.scene.events.on("preupdate",this.updateCameraController,this)}shutdown(t){this.isShutdown||(this.scene.events.off("preupdate",this.updateCameraController,this),this.cursorAtBounds.destroy(),this.cameraController.destroy(),super.shutdown(t))}get camera(){return this.cameraController.camera}set camera(t){this.cameraController.setCamera(t),t?this.cameraController.start():this.cameraController.stop()}setCamera(t){return this.camera=t,this}get enable(){return this.cursorAtBounds.enable}set enable(t){this.cursorAtBounds.enable=t}setEnable(t){return void 0===t&&(t=!0),this.enable=t,this}updateCameraController(t,e){this.cameraController.update(e)}}const fe=Phaser.Utils.Objects.GetValue;class me extends c{constructor(t,e){super(t,e);var i=this.scene?"update":"step";this.tickEventName=fe(e,"tickEventName",i),this.isSceneTicker=!be(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 be=function(t){return"step"===t||"poststep"===t};const ye=Phaser.Utils.Objects.GetValue,xe=Phaser.Math.Clamp;class Ce{constructor(t){this.resetFromJSON(t)}resetFromJSON(t){this.state=ye(t,"state",we),this.timeScale=ye(t,"timeScale",1),this.delay=ye(t,"delay",0),this.repeat=ye(t,"repeat",0),this.repeatCounter=ye(t,"repeatCounter",0),this.repeatDelay=ye(t,"repeatDelay",0),this.duration=ye(t,"duration",0),this.nowTime=ye(t,"nowTime",0),this.justRestart=ye(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?Se:Oe,this.repeatCounter=0,this}stop(){return this.state=we,this}update(t,e){this.state!==we&&this.state!==ke&&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=Te)):(this.nowTime=this.duration,this.state=ke):this.nowTime>=0&&(this.state=Se))}get t(){var t;switch(this.state){case we:case Oe:case Te:t=0;break;case Se:t=this.nowTime/this.duration;break;case ke:t=1}return xe(t,0,1)}set t(t){(t=xe(t,-1,1))<0?(this.state=Oe,this.nowTime=-this.delay*t):(this.state=Se,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++)}setT(t){return this.t=t,this}get isIdle(){return this.state===we}get isDelay(){return this.state===Oe}get isCountDown(){return this.state===Se}get isRunning(){return this.state===Oe||this.state===Se}get isDone(){return this.state===ke}get isOddIteration(){return!(1&~this.repeatCounter)}get isEvenIteration(){return!(1&this.repeatCounter)}}const we=0,Oe=1,Se=2,Te=3,ke=-1;class Pe extends me{constructor(t,e){super(t,e),this.timer=new Ce}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 Me=Phaser.Utils.Objects.GetValue,_e=Phaser.Utils.Objects.GetAdvancedValue,Ee=Phaser.Tweens.Builders.GetEaseFunction;class Re extends Pe{resetFromJSON(t){return this.timer.resetFromJSON(Me(t,"timer")),this.setEnable(Me(t,"enable",!0)),this.setTarget(Me(t,"target",this.parent)),this.setDelay(_e(t,"delay",0)),this.setDuration(_e(t,"duration",1e3)),this.setEase(Me(t,"ease","Linear")),this.setRepeat(Me(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 Le=Phaser.Math.Linear;class De extends Re{constructor(t,e){super(t,e),this.resetFromJSON(e)}start(t){return this.stop(),this.startZoomValue=this.target.zoom,this.endZoomValue=t,this.timer.setDuration(this.duration),super.start(),this}updateTarget(t,e){var i=this.parent;!function(t,e,i,s){if(void 0!==i){var r=t.getWorldPoint(i,s);t.zoom=e,t.preRender();var n=t.getWorldPoint(i,s);t.scrollX-=n.x-r.x,t.scrollY-=n.y-r.y}else t.zoom=e}(t,Le(this.startZoomValue,this.endZoomValue,e.t),i.focusLocalX,i.focusLocalY)}}const Be=Phaser.Utils.Objects.GetValue;Phaser.Math.Clamp;class Ie extends l{constructor(t,e){void 0===e&&(e={}),super(t,e),this.easeZoom=new De(this);var i=qt(t,Be(e,"camera"));this.setEnable(Be(e,"enable",!0)).setMinZoom(Be(e,"minZoom")).setMaxZoom(Be(e,"maxZoom")).setZoomStep(Be(e,"zoomStep",.1)).setEaseDuration(Be(e,"easeDuration",200)).setCamera(i),this.boot()}boot(){this.scene.input.on("wheel",this.onWheel,this)}shutdown(t){this.isShutdown||(this.scene.input.off("wheel",this.onWheel,this),this.easeZoom.destroy(),this.easeZoom=void 0,this.inputTarget=void 0,super.shutdown(t))}setCamera(t){return this.camera=t,this.resetZoomLevel(),this.easeZoom.stop().setTarget(t||null),this}setEnable=function(t){return void 0===t&&(t=!0),this.enable=t,this};setMinZoom(t){return this.minZoom=t,this}setMaxZoom(t){return this.maxZoom=t,this}setZoomStep(t){return this.zoomStep=t,this}setEaseDuration(t){return this.easeDuration=t,this.easeZoom.setDuration(t),this}resetZoomLevel(){var t=this.camera;return t?(this.zoomLevel=Math.round(Ae(t.zoom,this.zoomStep)),this.zoom=t.zoom,this):(this.zoomLevel=void 0,this)}onWheel(t,e,i,s,r,n){var a=this.camera;if(this.enable&&a){var o=void 0!==this.minZoom,h=void 0!==this.maxZoom;o&&this.zoom<=this.minZoom&&s>0||h&&this.zoom>=this.maxZoom&&s<0||(this.zoomLevel+=s<0?1:-1,this.zoom=We(this.zoomLevel,this.zoomStep),o&&this.zoom<this.minZoom&&(this.zoom=this.minZoom),h&&this.zoom>this.maxZoom&&(this.zoom=this.maxZoom),this.focusLocalX=t.x,this.focusLocalY=t.y,this.easeZoom.start(this.zoom))}}}var Ae=function(t,e){return t>=1?Math.log(t)/Math.log(1+e):-Math.log(t)/Math.log(1-e)},We=function(t,e){return t>=0?Math.pow(1+e,t):Math.pow(1-e,-t)};function Ye(t){if(null===t||"object"!=typeof t)return t;if(Array.isArray(t))return t.map((t=>Ye(t)));if(t instanceof Date)return new Date(t);if(t instanceof RegExp)return new RegExp(t);if(Object.getPrototypeOf(t)!==Object.prototype)return t;const e={};for(let i in t)t.hasOwnProperty(i)&&(e[i]=Ye(t[i]));return e}const je=Phaser.Utils.Objects.GetValue;class ze extends l{constructor(t,e){super(t,e=void 0===e?{}:Ye(e)),this._enable=!0,this._camera=void 0;var i,s=je(e,"minZoom"),r=je(e,"maxZoom");je(e,"boundsScroll",!0)&&(this.boundsScroll=new ve(t,{camera:je(e,"camera"),enable:je(e,"boundsScrollEnable",!0)})),je(e,"mouseWheelZoom",!0)&&(this.mouseWheelZoom=new Ie(t,{camera:je(e,"camera"),enable:je(e,"mouseWheelZoomEnable",!0),zoomStep:je(e,"mouseWheelZoomStep",.1),minZoom:je(e,"mouseWheelZoomMin",s),maxZoom:je(e,"mouseWheelZoomMax",r)})),je(e,"pinchZoom",!0)&&(this.pinchZoom=new ie(t,{camera:je(e,"camera"),inputTarget:je(e,"inputTarget",t),enable:je(e,"pinchZoomEnable",!0),minZoom:je(e,"pinchZoomMin",s),maxZoom:je(e,"pinchZoomMax",r),focusEnable:je(e,"pinchZoomFocusEnable",!0)})),je(e,"panScroll",!0)&&(this.panScroll=new te(t,{camera:je(e,"camera"),inputTarget:je(e,"inputTarget",t),enable:je(e,"panScrollEnable",!0)})),this.setEnable(je(e,"enable",!0)),this.pinchZoom&&this.panScroll&&this.pinchZoom.on("pinchstart",(function(){i=this.panScroll.enable,this.panScroll.setEnable(!1)}),this).on("pinchend",(function(){this.panScroll.setEnable(i)}),this)}destroy(t){this.panScroll&&this.panScroll.destroy(t),this.pinchZoom&&this.pinchZoom.destroy(t),this.boundsScroll&&this.boundsScroll.destroy(t),this.mouseWheelZoom&&this.mo