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).rexboxspinner=e()}(this,function(){"use strict";function s(t){return(s="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)}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(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,n.key,n)}}function r(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function t(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&&i(t,e)}function a(t){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(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 o(n){var s=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=a(n);if(s){var i=a(this).constructor;t=Reflect.construct(e,arguments,i)}else t=e.apply(this,arguments);return h(this,t)}}function u(t,e,i){return(u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=a(t)););return t}(t,e);if(n){var s=Object.getOwnPropertyDescriptor(n,e);return s.get?s.get.call(i):s.value}})(t,e,i||t)}var e=Phaser.GameObjects.Components.TransformMatrix,l=new e,f=new e,p=new e,v={camera:l,sprite:f,calc:p},d=function(t,e,i){var n=l,s=f,r=p;return s.applyITRS(t.x,t.y,t.rotation,t.scaleX,t.scaleY),n.copyFrom(e.matrix),i?(n.multiplyWithOffset(i,-e.scrollX*t.scrollFactorX,-e.scrollY*t.scrollFactorY),s.e=t.x,s.f=t.y):(s.e-=e.scrollX*t.scrollFactorX,s.f-=e.scrollY*t.scrollFactorY),n.multiply(s,r),v},y=Phaser.Renderer.Canvas.SetTransform,m={renderWebGL:function(t,e,i,n){e.dirty&&(e.updateData(),e.dirty=!1),i.addToRenderList(e);var s=t.pipelines.set(e.pipeline),r=d(e,i,n),a=s.calcMatrix.copyFrom(r.calc),h=e._displayOriginX,o=e._displayOriginY,u=i.alpha*e.alpha;t.pipelines.preBatch(e);for(var l=e.geom,c=0,f=l.length;c<f;c++)l[c].webglRender(s,a,u,h,o);t.pipelines.postBatch(e)},renderCanvas:function(t,e,i,n){e.dirty&&(e.updateData(),e.dirty=!1),i.addToRenderList(e);var s=t.currentContext;if(y(t,s,e,i,n)){for(var r=e._displayOriginX,a=e._displayOriginY,h=e.geom,o=0,u=h.length;o<u;o++)h[o].canvasRender(s,r,a);s.restore()}}},g=Phaser.GameObjects.Shape,k=Phaser.Utils.Array.Remove,E=function(){t(h,g);var a=o(h);function h(t,e,i,n,s){var r;return c(this,h),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=n),(r=a.call(this,t,"rexShapes",[]))._width=-1,r._height=-1,r.shapes={},r.setPosition(e,i),r.setSize(n,s),r.updateDisplayOrigin(),r.dirty=!0,r}return r(h,[{key:"width",get:function(){return this._width},set:function(t){this.setSize(t,this._height)}},{key:"height",get:function(){return this._height},set:function(t){this.setSize(this._width,t)}},{key:"setDirty",value:function(t){return void 0===t&&(t=!0),this.dirty=t,this}},{key:"setSize",value:function(t,e){this.dirty=this.dirty||this._width!==t||this._height!==e,this._width=t,this._height=e,this.updateDisplayOrigin();var i=this.input;return i&&!i.customHitArea&&(i.hitArea.width=t,i.hitArea.height=e),this}},{key:"resize",value:function(t,e){return this.setSize(t,e),this}},{key:"updateShapes",value:function(){}},{key:"updateData",value:function(){this.updateShapes();for(var t=this.geom,e=0,i=t.length;e<i;e++){var n=t[e];n.dirty&&n.updateData()}return this}},{key:"clear",value:function(){return this.geom.length=0,function(t){if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e]}(this.shapes),this}},{key:"getShape",value:function(t){return this.shapes[t]}},{key:"getShapes",value:function(){return this.geom}},{key:"addShape",value:function(t){this.geom.push(t);var e=t.name;return e&&(this.shapes[e]=t),this.dirty=!0,this}},{key:"deleteShape",value:function(t){var e=this.getShape(t);return e&&(delete this.shapes[t],k(this.geom,e)),this}}]),h}();Object.assign(E.prototype,m);function P(t){return t instanceof _}var w={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):[]}},_=Phaser.Scene,b=Phaser.Utils.Objects.GetValue,S=function(){function n(t,e){var i;c(this,n),this.parent=t,this.scene=null==(i=t)||"object"!==s(i)?null:P(i)?i:i.scene&&P(i.scene)?i.scene:i.parent&&i.parent.scene&&P(i.parent.scene)?i.parent.scene:void 0,this.isShutdown=!1,this.setEventEmitter(b(e,"eventEmitter",!0)),this.parent&&this.parent===this.scene?this.scene.events.once("shutdown",this.onSceneDestroy,this):this.parent&&this.parent.once&&this.parent.once("destroy",this.onParentDestroy,this)}return r(n,[{key:"shutdown",value:function(){this.isShutdown||(this.parent&&this.parent===this.scene?this.scene.events.off("shutdown",this.onSceneDestroy,this):this.parent&&this.parent.once&&this.parent.off("destroy",this.onParentDestroy,this),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this.isShutdown=!0)}},{key:"destroy",value:function(t){this.shutdown(t)}},{key:"onSceneDestroy",value:function(){this.destroy(!0)}},{key:"onParentDestroy",value:function(t,e){this.destroy(e)}}]),n}();Object.assign(S.prototype,w);var T=function(){t(n,S);var i=o(n);function n(t,e){return c(this,n),void 0===e&&(e={}),e.hasOwnProperty("eventEmitter")||(e.eventEmitter=!1),i.call(this,t,e)}return r(n,[{key:"shutdown",value:function(t){this.isShutdown||(this.stop(),u(a(n.prototype),"shutdown",this).call(this,t))}},{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:"pause",value:function(){return this.tween&&this.tween.pause(),this}},{key:"resume",value:function(){return this.tween&&this.tween.resume(),this}},{key:"complete",value:function(){return this.stop(),this.getEventEmitter()&&this.emit("complete"),this}},{key:"isRunning",get:function(){return!!this.tween}}]),n}(),D={start:function(t){return this.tweenTask||(this.tweenTask=new T(this)),void 0!==t&&(this.duration=t,this.tweenTask.stop()),this.tweenTask.isRunning||(this.setValue(0),this.tweenTask.start({targets:this,value:1,ease:this.ease,duration:this.duration,repeat:-1,yoyo:!1})),this},stop:function(){return this.tweenTask&&this.tweenTask.stop(),this},pause:function(){return this.tweenTask&&this.tweenTask.pause(),this},resume:function(){return this.tweenTask&&this.tweenTask.pause(),this}},C=Phaser.Utils.Objects.GetValue,R=function(){t(l,E);var u=o(l);function l(t,e){var i;c(this,l);var n=C(e,"x",0),s=C(e,"y",0),r=C(e,"width",64),a=C(e,"height",64);(i=u.call(this,t,n,s,r,a)).setDuration(C(e,"duration",1e3)),i.setEase(C(e,"ease","Linear"));var h=C(e,"color",16777215),o=C(e,"start",!0);return i.buildShapes(e),i.setColor(h),i.setValue(0),o&&i.start(),i}return r(l,[{key:"buildShapes",value:function(){}},{key:"centerX",get:function(){return this.width/2}},{key:"centerY",get:function(){return this.height/2}},{key:"radius",get:function(){return Math.min(this.centerX,this.centerY)}},{key:"color",get:function(){return this._color},set:function(t){this.dirty=this.dirty||this._color!==t,this._color=t,this.setShapesColor(t)}},{key:"setColor",value:function(t){return this.color=t,this}},{key:"setShapesColor",value:function(){}},{key:"value",get:function(){return this._value},set:function(t){t=Phaser.Math.Clamp(t,0,1),this.dirty=this.dirty||this._value!=t,this._value=t}},{key:"setValue",value:function(t){return this.value=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setEase",value:function(t){return this.ease=t,this}}]),l}();Object.assign(R.prototype,D);var O={fillStyle:function(t,e){return void 0===t?this.isFilled=!1:(void 0===e&&(e=1),this.isFilled=!0,this.fillColor=t,this.fillAlpha=e),this},lineStyle:function(t,e,i){return void 0===t||void 0===e?this.isStroked=!1:(void 0===i&&(i=1),this.isStroked=!0,this.lineWidth=t,this.strokeColor=e,this.strokeAlpha=i),this}},X={setData:function(t,e){return void 0===this.data&&(this.data={}),this.data[t]=e,this},getData:function(t,e){return void 0===this.data&&(this.data={}),this.data.hasOwnProperty(t)||(this.data[t]=e),this.data[t]}},Y=function(){function t(){c(this,t),this.name=void 0,this.dirty=!0,this.data=void 0,this.isFilled=!1,this.fillColor=void 0,this.fillAlpha=1,this.isStroked=!1,this.lineWidth=1,this.strokeColor=void 0,this.strokeAlpha=1}return r(t,[{key:"setName",value:function(t){return this.name=t,this}},{key:"reset",value:function(){return this.fillStyle(),this.lineStyle(),this}},{key:"webglRender",value:function(){}},{key:"canvasRender",value:function(){}},{key:"updateData",value:function(){}}]),t}();Object.assign(Y.prototype,O,X);function A(t,e,i){var n=i.length;if(2<=n){var s=i[n-2],r=i[n-1];if(t===s&&e===r)return i}return i.push(t,e),i}var x=Phaser.Renderer.WebGL.Utils,L=function(t,e,i,n,s,r){for(var a=x.getTintAppendFloatAlpha(i.fillColor,i.fillAlpha*n),h=i.pathData,o=i.pathIndexes,u=0;u<o.length;u+=3){var l=2*o[u],c=2*o[u+1],f=2*o[u+2],p=h[0+l]-s,v=h[1+l]-r,d=h[0+c]-s,y=h[1+c]-r,m=h[0+f]-s,g=h[1+f]-r,k=e.getX(p,v),E=e.getY(p,v),P=e.getX(d,y),w=e.getY(d,y),_=e.getX(m,g),b=e.getY(m,g);t.batchTri(i,k,E,P,w,_,b,0,0,1,1,a,a,a,2)}},j=Phaser.Renderer.WebGL.Utils,z=function(t,e,i,n,s){var r=t.strokeTint,a=j.getTintAppendFloatAlpha(e.strokeColor,e.strokeAlpha*i);r.TL=a,r.TR=a,r.BL=a,r.BR=a;var h=e.pathData,o=h.length-1,u=e.lineWidth,l=u/2,c=h[0]-n,f=h[1]-s;e.closePath||(o-=2);for(var p=2;p<o;p+=2){var v=h[p]-n,d=h[p+1]-s;t.batchLine(c,f,v,d,l,l,u,p-2,!!e.closePath&&p===o-1),c=v,f=d}},B=function(t,e,i,n){var s=i||e.fillColor,r=n||e.fillAlpha,a=(16711680&s)>>>16,h=(65280&s)>>>8,o=255&s;t.fillStyle="rgba("+a+","+h+","+o+","+r+")"},F=function(t,e,i,n){var s=i||e.strokeColor,r=n||e.strokeAlpha,a=(16711680&s)>>>16,h=(65280&s)>>>8,o=255&s;t.strokeStyle="rgba("+a+","+h+","+o+","+r+")",t.lineWidth=e.lineWidth},M=Phaser.Geom.Polygon.Earcut,W=function(){t(i,Y);var e=o(i);function i(){var t;return c(this,i),(t=e.call(this)).pathData=[],t.pathIndexes=[],t.closePath=!1,t}return r(i,[{key:"updateData",value:function(){return this.pathIndexes=M(this.pathData),this.dirty=!1,this}},{key:"webglRender",value:function(t,e,i,n,s){this.isFilled&&L(t,e,this,i,n,s),this.isStroked&&z(t,this,i,n,s)}},{key:"canvasRender",value:function(t,e,i){var n=this.pathData,s=n.length-1,r=n[0]-e,a=n[1]-i;t.beginPath(),t.moveTo(r,a),this.closePath||(s-=2);for(var h=2;h<s;h+=2){var o=n[h]-e,u=n[h+1]-i;t.lineTo(o,u)}this.closePath&&t.closePath(),this.isFilled&&(B(t,this),t.fill()),this.isStroked&&(F(t,this),t.stroke())}}]),i}(),G=Phaser.Math.DegToRad;Phaser.Math.DegToRad;var I=Phaser.Math.DegToRad,U=Phaser.Math.RotateAround,V=Phaser.Math.Interpolation.QuadraticBezier,N=Phaser.Math.Interpolation.CubicBezier,q=function(){t(i,W);var e=o(i);function i(){var t;return c(this,i),(t=e.call(this)).setIterations(32),t}return r(i,[{key:"iterations",get:function(){return this._iterations},set:function(t){this.dirty=this.dirty||this._iterations!==t,this._iterations=t}},{key:"setIterations",value:function(t){return this.iterations=t,this}},{key:"startAt",value:function(t,e){return this.dirty=!0,this.pathData.length=0,this.pathData.push(t,e),this.lastPointX=t,this.lastPointY=e,this}},{key:"lineTo",value:function(t,e,i){return void 0===i&&(i=!1),i&&(t+=this.lastPointX,e+=this.lastPointY),this.dirty=!0,this.pathData.push(t,e),this.lastPointX=t,this.lastPointY=e,this}},{key:"verticalLineTo",value:function(t,e){return this.lineTo(t,this.lastPointY,e),this}},{key:"horizontalLineTo",value:function(t,e){return this.lineTo(this.lastPointX,t,e),this}},{key:"ellipticalArc",value:function(t,e,i,n,s,r,a){void 0===a&&(a=!1),this.dirty=!0,function(t,e,i,n,s,r,a,h,o){a&&s<r&&(r-=360);var u=G(r-s)/h;s=G(s);for(var l=0;l<=h;l++){var c=s+u*l,f=t+i*Math.cos(c),p=e+n*Math.sin(c);A(f,p,o)}}(t,e,i,n,s,r,a,this.iterations,this.pathData);var h=this.pathData.length;return this.lastPointX=this.pathData[h-2],this.lastPointY=this.pathData[h-1],this}},{key:"arc",value:function(t,e,i,n,s,r){return this.ellipticalArc(t,e,i,i,n,s,r),this}},{key:"quadraticBezierTo",value:function(t,e,i,n){this.dirty=!0;for(var s=this.lastPointX,r=this.lastPointY,a=1,h=this.iterations-1;a<=h;a++){var o=a/h;this.pathData.push(V(o,s,t,i),V(o,r,e,n))}return this.lastPointX=i,this.lastPointY=n,this.lastCX=t,this.lastCY=e,this}},{key:"smoothQuadraticBezierTo",value:function(t,e){var i=2*this.lastPointX-this.lastCX,n=2*this.lastPointY-this.lastCY;return this.quadraticBezierTo(i,n,t,e)}},{key:"cubicBezierCurveTo",value:function(t,e,i,n,s,r){this.dirty=!0;for(var a=this.lastPointX,h=this.lastPointY,o=1,u=this.iterations-1;o<=u;o++){var l=o/u;this.pathData.push(N(l,a,t,i,s),N(l,h,e,n,r))}return this.lastPointX=s,this.lastPointY=r,this.lastCX=i,this.lastCY=n,this}},{key:"smoothCubicBezierCurveTo",value:function(t,e,i,n){var s=2*this.lastPointX-this.lastCX,r=2*this.lastPointY-this.lastCY;return this.cubicBezierCurveTo(s,r,t,e,i,n)}},{key:"close",value:function(){return this.dirty=!0,this.closePath=!0,this}},{key:"rotateAround",value:function(t,e,i){if(0===this.pathData.length)return this;i=I(i);for(var n={x:0,y:0},s=0,r=this.pathData.length-1;s<r;s+=2)n.x=this.pathData[s],n.y=this.pathData[s+1],U(n,t,e,i),this.pathData[s]=n.x,this.pathData[s+1]=n.y;var a=this.pathData.length;return this.lastPointX=this.pathData[a-2],this.lastPointY=this.pathData[a-1],void 0!==this.lastCX&&(n.x=this.lastCX,n.y=this.lastCY,U(n,t,e,i),this.lastCX=n.x,this.lastCY=n.y),this}}]),i}();return Phaser.Renderer.WebGL.Utils,Phaser.Renderer.WebGL.Utils,Phaser.Math.Linear,function(){t(s,R);var n=o(s);function s(t,e){var i;return c(this,s),(i=n.call(this,t,e)).type="rexSpinnerCube",i}return r(s,[{key:"buildShapes",value:function(){this.addShape((new q).setName("border")),this.addShape((new q).setName("fill"))}},{key:"updateShapes",value:function(){var t=this.centerX,e=this.centerY,i=.7*this.radius,n=t-i,s=t+i,r=e-i,a=e+i;if(this.getShape("border").lineStyle(2,this.color,1).startAt(n,r).lineTo(s,r).lineTo(s,a).lineTo(n,a).lineTo(n,r).close(),this.value<.5){var h=r+2*(.5-this.value)*i*2;this.getShape("fill").fillStyle(this.color,1).startAt(n,r).lineTo(s,r).lineTo(s,h).lineTo(n,h).lineTo(n,r).close()}else{var o=180*(2*(this.value-.5));this.getShape("border").rotateAround(t,e,o),this.getShape("fill").fillStyle().lineStyle()}}}]),s}()});
  