import{defineComponent as C,computed as f,reactive as V,ref as x,watch as y,onUnmounted as h,createVNode as N}from"vue";import S from"../_util/classNames.mjs";function p({prefixCls:t,value:n,current:u,offset:e=0}){let o;return e&&(o={position:"absolute",top:`${e}00%`,left:0}),N("p",{style:o,class:S(`${t}-only-unit`,{current:u})},[n])}function T(t,n,u){let e=t,o=0;for(;(e+10)%10!==n;)e+=u,o+=u;return o}const w=C({compatConfig:{MODE:3},name:"SingleNumber",props:{prefixCls:String,value:String,count:Number},setup(t){const n=f(()=>Number(t.value)),u=f(()=>Math.abs(t.count)),e=V({prevValue:n.value,prevCount:u.value}),o=()=>{e.prevValue=n.value,e.prevCount=u.value},s=x();return y(n,()=>{clearTimeout(s.value),s.value=setTimeout(()=>{o()},1e3)},{flush:"post"}),h(()=>{clearTimeout(s.value)}),()=>{let a,i={};const l=n.value;if(e.prevValue===l||Number.isNaN(l)||Number.isNaN(e.prevValue))a=[p({...t,current:!0})],i={transition:"none"};else{a=[];const d=l+10,c=[];for(let r=l;r<=d;r+=1)c.push(r);const m=c.findIndex(r=>r%10===e.prevValue);a=c.map((r,v)=>{const g=r%10;return p({...t,value:g,offset:v-m,current:v===m})});const b=e.prevCount<u.value?1:-1;i={transform:`translateY(${-T(e.prevValue,l,b)}00%)`}}return N("span",{class:`${t.prefixCls}-only`,style:i,onTransitionend:()=>o()},[a])}}});export{w as default};
