import{o as t,c as i,X as a}from"../@vue/@vue.2e72eb65.js";const s=(t,i)=>{const a=t.__vccOpts||t;for(const[s,e]of i)a[s]=e;return a};let e=0;const l="webkit moz ms o".split(" ");let r,n;if("undefined"==typeof window)r=function(){},n=function(){};else{let t;r=window.requestAnimationFrame,n=window.cancelAnimationFrame;for(let i=0;i<l.length&&(!r||!n);i++)t=l[i],r=r||window[t+"RequestAnimationFrame"],n=n||window[t+"CancelAnimationFrame"]||window[t+"CancelRequestAnimationFrame"];r&&n||(r=function(t){const i=(new Date).getTime(),a=Math.max(0,16-(i-e)),s=window.setTimeout((()=>{t(i+a)}),a);return e=i+a,s},n=function(t){window.clearTimeout(t)})}const o=s({props:{startVal:{type:Number,required:!1,default:0},endVal:{type:Number,required:!1,default:2017},duration:{type:Number,required:!1,default:3e3},autoplay:{type:Boolean,required:!1,default:!0},decimals:{type:Number,required:!1,default:0,validator:t=>t>=0},decimal:{type:String,required:!1,default:"."},separator:{type:String,required:!1,default:","},prefix:{type:String,required:!1,default:""},suffix:{type:String,required:!1,default:""},useEasing:{type:Boolean,required:!1,default:!0},easingFn:{type:Function,default:(t,i,a,s)=>a*(1-Math.pow(2,-10*t/s))*1024/1023+i}},data(){return{localStartVal:this.startVal,displayValue:this.formatNumber(this.startVal),printVal:null,paused:!1,localDuration:this.duration,startTime:null,timestamp:null,remaining:null,rAF:null}},computed:{countDown(){return this.startVal>this.endVal}},watch:{startVal(){this.autoplay&&this.start()},endVal(){this.autoplay&&this.start()}},mounted(){this.autoplay&&this.start(),this.$emit("mountedCallback")},methods:{start(){this.localStartVal=this.startVal,this.startTime=null,this.localDuration=this.duration,this.paused=!1,this.rAF=r(this.count)},pauseResume(){this.paused?(this.resume(),this.paused=!1):(this.pause(),this.paused=!0)},pause(){n(this.rAF)},resume(){this.startTime=null,this.localDuration=+this.remaining,this.localStartVal=+this.printVal,r(this.count)},reset(){this.startTime=null,n(this.rAF),this.displayValue=this.formatNumber(this.startVal)},count(t){this.startTime||(this.startTime=t),this.timestamp=t;const i=t-this.startTime;this.remaining=this.localDuration-i,this.useEasing?this.countDown?this.printVal=this.localStartVal-this.easingFn(i,0,this.localStartVal-this.endVal,this.localDuration):this.printVal=this.easingFn(i,this.localStartVal,this.endVal-this.localStartVal,this.localDuration):this.countDown?this.printVal=this.localStartVal-(this.localStartVal-this.endVal)*(i/this.localDuration):this.printVal=this.localStartVal+(this.endVal-this.localStartVal)*(i/this.localDuration),this.countDown?this.printVal=this.printVal<this.endVal?this.endVal:this.printVal:this.printVal=this.printVal>this.endVal?this.endVal:this.printVal,this.displayValue=this.formatNumber(this.printVal),i<this.localDuration?this.rAF=r(this.count):this.$emit("callback")},isNumber:t=>!isNaN(parseFloat(t)),formatNumber(t){t=t.toFixed(this.decimals);const i=(t+="").split(".");let a=i[0];const s=i.length>1?this.decimal+i[1]:"",e=/(\d+)(\d{3})/;if(this.separator&&!this.isNumber(this.separator))for(;e.test(a);)a=a.replace(e,"$1"+this.separator+"$2");return this.prefix+a+s+this.suffix}},destroyed(){n(this.rAF)}},[["render",function(s,e,l,r,n,o){return t(),i("span",null,a(n.displayValue),1)}]]);export{o as C,s as _};
