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