import{d as q,ac as n,e as k,b2 as E,q as v,Y as w,aM as M,a as o,o as P,c as R,t as $,T as z,V as H,bE as N,_ as U,__tla as X}from"./index-8dc1e40a.js";let y,Y=Promise.all([(()=>{try{return X}catch{}})()]).then(async()=>{y=U(q({name:"CountTo",__name:"CountTo",props:{startVal:n.number.def(0),endVal:n.number.def(2021),duration:n.number.def(3e3),autoplay:n.bool.def(!0),decimals:n.number.validate(i=>i>=0).def(0),decimal:n.string.def("."),separator:n.string.def(","),prefix:n.string.def(""),suffix:n.string.def(""),useEasing:n.bool.def(!0),easingFn:{type:Function,default:(i,m,p,V)=>p*(1-Math.pow(2,-10*i/V))*1024/1023+m}},emits:["mounted","callback"],setup(i,{expose:m,emit:p}){const{getPrefixCls:V}=H(),A=V("count-to"),t=i,T=p,d=e=>{const{decimals:s,decimal:u,separator:l,suffix:r,prefix:C}=t;e=Number(e).toFixed(s);const _=(e+="").split(".");let c=_[0];const h=_.length>1?u+_[1]:"",S=/(\d+)(\d{3})/;if(l&&!N(l))for(;S.test(c);)c=c.replace(S,"$1"+l+"$2");return C+c+h+r},a=k({localStartVal:t.startVal,displayValue:d(t.startVal),printVal:null,paused:!1,localDuration:t.duration,startTime:null,timestamp:null,remaining:null,rAF:null}),D=E(a,"displayValue");v(()=>{t.autoplay&&F(),T("mounted")});const f=w(()=>t.startVal>t.endVal);M([()=>t.startVal,()=>t.endVal],()=>{t.autoplay&&F()});const F=()=>{const{startVal:e,duration:s}=t;a.localStartVal=e,a.startTime=null,a.localDuration=s,a.paused=!1,a.rAF=requestAnimationFrame(g)},b=()=>{cancelAnimationFrame(a.rAF)},x=()=>{a.startTime=null,a.localDuration=+a.remaining,a.localStartVal=+a.printVal,requestAnimationFrame(g)},g=e=>{const{useEasing:s,easingFn:u,endVal:l}=t;a.startTime||(a.startTime=e),a.timestamp=e;const r=e-a.startTime;a.remaining=a.localDuration-r,s?o(f)?a.printVal=a.localStartVal-u(r,0,a.localStartVal-l,a.localDuration):a.printVal=u(r,a.localStartVal,l-a.localStartVal,a.localDuration):o(f)?a.printVal=a.localStartVal-(a.localStartVal-l)*(r/a.localDuration):a.printVal=a.localStartVal+(l-a.localStartVal)*(r/a.localDuration),o(f)?a.printVal=a.printVal<l?l:a.printVal:a.printVal=a.printVal>l?l:a.printVal,a.displayValue=d(a.printVal),r<a.localDuration?a.rAF=requestAnimationFrame(g):T("callback")};return m({pauseResume:()=>{a.paused?(x(),a.paused=!1):(b(),a.paused=!0)},reset:()=>{a.startTime=null,cancelAnimationFrame(a.rAF),a.displayValue=d(t.startVal)},start:F,pause:b}),(e,s)=>(P(),R("span",{class:z(o(A))},$(o(D)),3))}}),[["__file","/Users/RuHu.Xu/Desktop/mall-newfeifan-zx-admin/src/components/CountTo/src/CountTo.vue"]])});export{y as _,Y as __tla};
