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).rexovalspinner=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 o(t){return(o=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){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function d(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=o(n);if(s){var i=o(this).constructor;t=Reflect.construct(e,arguments,i)}else t=e.apply(this,arguments);return h(this,t)}}function f(t,e,i){return(f="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=o(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,k=new e,_=new e,w=new e,E={camera:k,sprite:_,calc:w},l=Phaser.Renderer.Canvas.SetTransform,a={renderWebGL:function(t,e,i,n){e.updateData(),i.addToRenderList(e);var s,r,h,a,o,u,l=t.pipelines.set(e.pipeline),c=(s=e,r=i,h=n,a=k,u=w,(o=_).applyITRS(s.x,s.y,s.rotation,s.scaleX,s.scaleY),a.copyFrom(r.matrix),h?(a.multiplyWithOffset(h,-r.scrollX*s.scrollFactorX,-r.scrollY*s.scrollFactorY),o.e=s.x,o.f=s.y):(o.e-=r.scrollX*s.scrollFactorX,o.f-=r.scrollY*s.scrollFactorY),a.multiply(o,u),E),d=l.calcMatrix.copyFrom(c.calc),f=e._displayOriginX,p=e._displayOriginY,v=i.alpha*e.alpha;t.pipelines.preBatch(e);for(var y=e.geom,g=0,m=y.length;g<m;g++)y[g].webglRender(l,d,v,f,p);t.pipelines.postBatch(e)},renderCanvas:function(t,e,i,n){e.updateData(),i.addToRenderList(e);var s=t.currentContext;if(l(t,s,e,i,n)){for(var r=e._displayOriginX,h=e._displayOriginY,a=e.geom,o=0,u=a.length;o<u;o++)a[o].canvasRender(s,r,h);s.restore()}}},u=Phaser.GameObjects.Shape,p=Phaser.Utils.Array.Remove,v=function(){t(a,u);var h=d(a);function a(t,e,i,n,s){var r;return c(this,a),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=n),(r=h.call(this,t,"rexShapes",[]))._width=-1,r._height=-1,r.dirty=!0,r.isSizeChanged=!0,r.shapes={},r.setPosition(e,i),r.setSize(n,s),r.updateDisplayOrigin(),r}return r(a,[{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.isSizeChanged=this.isSizeChanged||this._width!==t||this._height!==e,this.dirty=this.dirty||this.isSizeChanged,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:"setFillStyle",value:function(t,e){return void 0===e&&(e=1),this.dirty=this.dirty||this.fillColor!==t||this.fillAlpha!==e,f(o(a.prototype),"setFillStyle",this).call(this,t,e),this}},{key:"setStrokeStyle",value:function(t,e,i){return void 0===i&&(i=1),this.dirty=this.dirty||this.lineWidth!==t||this.strokeColor!==e||this.strokeAlpha!==i,f(o(a.prototype),"setStrokeStyle",this).call(this,t,e,i),this}},{key:"updateShapes",value:function(){}},{key:"updateData",value:function(){if(!this.dirty)return this;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.dirty=!1,this.isSizeChanged=!1,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],p(this.geom,e)),this}}]),a}();Object.assign(v.prototype,a);function y(t){return t instanceof m}var g={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):[]},eventNames:function(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}},m=Phaser.Scene,S=Phaser.Utils.Objects.GetValue,b=function(){function n(t,e){var i;c(this,n),this.parent=t,this.scene=null==(i=t)||"object"!==s(i)?null:y(i)?i:i.scene&&y(i.scene)?i.scene:i.parent&&i.parent.scene&&y(i.parent.scene)?i.parent.scene:void 0,this.isShutdown=!1,this.setEventEmitter(S(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(b.prototype,g);var P=function(){t(n,b);var i=d(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(),f(o(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(t){return this.stop().start(t),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 P(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.setDirty()),this},stop:function(){return this.tweenTask&&(this.tweenTask.stop(),this.setDirty()),this},pause:function(){return this.tweenTask&&(this.tweenTask.pause(),this.setDirty()),this},resume:function(){return this.tweenTask&&(this.tweenTask.pause(),this.setDirty()),this}},A=Phaser.Utils.Objects.GetValue,R=function(){t(l,v);var u=d(l);function l(t,e){var i;c(this,l);var n=A(e,"x",0),s=A(e,"y",0),r=A(e,"width",64),h=A(e,"height",64);(i=u.call(this,t,n,s,r,h)).setDuration(A(e,"duration",1e3)),i.setEase(A(e,"ease","Linear"));var a=A(e,"color",16777215),o=A(e,"start",!0);return i.buildShapes(e),i.setColor(a),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}},{key:"isRunning",get:function(){return!!this.tweenTask&&this.tweenTask.isRunning}}]),l}();Object.assign(R.prototype,D);var T={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}},O={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]}},C=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(C.prototype,T,O);function x(t,e,i,n){var s=i||e.fillColor,r=n||e.fillAlpha,h=(16711680&s)>>>16,a=(65280&s)>>>8,o=255&s;t.fillStyle="rgba("+h+","+a+","+o+","+r+")"}function X(t,e,i,n){var s=i||e.strokeColor,r=n||e.strokeAlpha,h=(16711680&s)>>>16,a=(65280&s)>>>8,o=255&s;t.strokeStyle="rgba("+h+","+a+","+o+","+r+")",t.lineWidth=e.lineWidth}function Y(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 j=Phaser.Renderer.WebGL.Utils,L=Phaser.Renderer.WebGL.Utils,F=Phaser.Geom.Polygon.Earcut,M=function(){t(i,C);var e=d(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=F(this.pathData),this}},{key:"webglRender",value:function(t,e,i,n,s){this.isFilled&&function(t,e,i,n,s,r){for(var h=j.getTintAppendFloatAlpha(i.fillColor,i.fillAlpha*n),a=i.pathData,o=i.pathIndexes,u=0;u<o.length;u+=3){var l=2*o[u],c=2*o[u+1],d=2*o[u+2],f=a[0+l]-s,p=a[1+l]-r,v=a[0+c]-s,y=a[1+c]-r,g=a[0+d]-s,m=a[1+d]-r,k=e.getX(f,p),_=e.getY(f,p),w=e.getX(v,y),E=e.getY(v,y),S=e.getX(g,m),b=e.getY(g,m);t.batchTri(i,k,_,w,E,S,b,0,0,1,1,h,h,h,2)}}(t,e,this,i,n,s),this.isStroked&&function(t,e,i,n,s){var r=t.strokeTint,h=L.getTintAppendFloatAlpha(e.strokeColor,e.strokeAlpha*i);r.TL=h,r.TR=h,r.BL=h,r.BR=h;var a=e.pathData,o=a.length-1,u=e.lineWidth,l=u/2,c=a[0]-n,d=a[1]-s;e.closePath||(o-=2);for(var f=2;f<o;f+=2){var p=a[f]-n,v=a[f+1]-s;t.batchLine(c,d,p,v,l,l,u,f-2,!!e.closePath&&f===o-1),c=p,d=v}}(t,this,i,n,s)}},{key:"canvasRender",value:function(t,e,i){var n=this.pathData,s=n.length-1,r=n[0]-e,h=n[1]-i;t.beginPath(),t.moveTo(r,h),this.closePath||(s-=2);for(var a=2;a<s;a+=2){var o=n[a]-e,u=n[a+1]-i;t.lineTo(o,u)}this.closePath&&t.closePath(),this.isFilled&&(x(t,this),t.fill()),this.isStroked&&(X(t,this),t.stroke())}}]),i}(),z=Phaser.Math.DegToRad,W=Phaser.Math.DegToRad,G=function(){t(l,M);var u=d(l);function l(t,e,i,n,s,r,h,a){var o;return c(this,l),void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===r&&(r=360),void 0===h&&(h=!1),void 0===a&&(a=!1),(o=u.call(this)).setCenterPosition(t,e),o.setRadius(i,n),o.setAngle(s,r,h),o.setPie(a),o.setIterations(32),o}return r(l,[{key:"x",get:function(){return this._x},set:function(t){this.dirty=this.dirty||this._x!==t,this._x=t}},{key:"y",get:function(){return this._y},set:function(t){this.dirty=this.dirty||this._y!==t,this._y=t}},{key:"setCenterPosition",value:function(t,e){return void 0===e&&(e=t),this.x=t,this.y=e,this}},{key:"radiusX",get:function(){return this._radiusX},set:function(t){this.dirty=this.dirty||this._radiusX!==t,this._radiusX=t}},{key:"radiusY",get:function(){return this._radiusY},set:function(t){this.dirty=this.dirty||this._radiusY!==t,this._radiusY=t}},{key:"setRadius",value:function(t,e){return void 0===e&&(e=t),this.radiusX=t,this.radiusY=e,this}},{key:"startAngle",get:function(){return this._startAngle},set:function(t){this.dirty=this.dirty||this._startAngle!==t,this._startAngle=t}},{key:"endAngle",get:function(){return this._endAngle},set:function(t){this.dirty=this.dirty||this._endAngle!==t,this._endAngle=t}},{key:"anticlockwise",get:function(){return this._anticlockwise},set:function(t){this.dirty=this.dirty||this._anticlockwise!==t,this._anticlockwise=t}},{key:"setAngle",value:function(t,e,i){return void 0===i&&(i=!1),this.startAngle=t,this.endAngle=e,this.anticlockwise=i,this}},{key:"pie",get:function(){return this._pie},set:function(t){this.dirty=this.dirty||this._pie!==t,this._pie=t}},{key:"setPie",value:function(t){return void 0===t&&(t=!0),this.pie=t,this}},{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:"updateData",value:function(){return this.pathData.length=0,this.pie&&this.pathData.push(this.x,this.y),function(t,e,i,n,s,r,h,a,o){h&&s<r?r-=360:!h&&r<s&&(r+=360);var u=z(r-s)/a;s=z(s);for(var l=0;l<=a;l++){var c=s+u*l,d=t+i*Math.cos(c),f=e+n*Math.sin(c);Y(d,f,o)}}(this.x,this.y,this.radiusX,this.radiusY,this.startAngle,this.endAngle,this.anticlockwise,this.iterations,this.pathData),this.pie&&this.pathData.push(this.x,this.y),this.pathData.push(this.pathData[0],this.pathData[1]),f(o(l.prototype),"updateData",this).call(this),this}},{key:"canvasRender",value:function(t,e,i){t.beginPath();var n=this.x-e,s=this.y-i,r=W(this.startAngle),h=W(this.endAngle);this.pie&&(t.moveTo(n,s),t.lineTo(n+Math.cos(r)*this.radiusX,s+Math.sin(r)*this.radiusY)),t.ellipse(n,s,this.radiusX,this.radiusY,0,r,h,this.anticlockwise),this.pie&&t.lineTo(n,s),this.isFilled&&(x(t,this),t.fill()),this.isStroked&&(X(t,this),t.stroke())}}]),l}(),B=function(){t(s,G);var n=d(s);function s(t,e,i){return c(this,s),n.call(this,t,e,i,i,0,360)}return s}();return Phaser.Math.Interpolation.QuadraticBezier,Phaser.Math.RotateAround,Phaser.Geom.Polygon,Phaser.Math.DegToRad,Phaser.Math.Distance.Between,Phaser.Math.Linear,Phaser.Renderer.WebGL.Utils,Phaser.Renderer.WebGL.Utils,function(){t(s,R);var n=d(s);function s(t,e){var i;return c(this,s),(i=n.call(this,t,e)).type="rexSpinnerOval",i}return r(s,[{key:"buildShapes",value:function(){this.addShape((new B).setName("track")),this.addShape((new G).setName("arc"))}},{key:"updateShapes",value:function(){var t=this.centerX,e=this.centerY,i=this.radius,n=Math.ceil(i/25),s=i-n/2;this.getShape("track").lineStyle(n,this.color,.5).setRadius(s).setCenterPosition(t,e);var r=360*this.value,h=60+r;this.getShape("arc").lineStyle(n,this.color,1).setRadius(s).setCenterPosition(t,e).setAngle(r,h)}}]),s}()});
  