Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-slot-counter

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-slot-counter - npm Package Compare versions

Comparing version 2.3.0 to 2.3.1

2

lib/index.esm.js
'use client';
import n,{memo as e,useState as t,useRef as r,useEffect as i,useMemo as u,useCallback as o,forwardRef as a,useImperativeHandle as l}from"react";var c=function(){return c=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},c.apply(this,arguments)};var s=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},d=function(n,e){for(var t=[],r=n;r<e;r+=1)t.push(r);return t},f=function(n,e){for(var t=[],r=n;r!==e;)t.push(r),10===(r+=1)&&(r=0);return t},m=function(n,e){var t=Math.random()*(e-n);return Math.floor(t+n)},v=function(n){for(var e,t=function(n,e,t){if(t||2===arguments.length)for(var r,i=0,u=e.length;i<u;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return n.concat(r||Array.prototype.slice.call(e))}([],n,!0),r=t.length-1;r>0;r-=1){var i=Math.floor(Math.random()*(r+1));e=[t[i],t[r]],t[r]=e[0],t[i]=e[1]}return t},h=function(n){return"number"==typeof n?n:(Array.isArray(n)?n.join(""):n).replace(/[,.]/g,"")},p=function(n){return"object"!=typeof n&&!Number.isNaN(h(n))},g=function(n){return"object"==typeof n};var y="index-module_slot_wrap__ZT-DX",b="index-module_slot__DpPgW",N="index-module_separator__7GhtE",C="index-module_numbers__sqlqm",_="index-module_num__j6XH3";!function(n,e){void 0===e&&(e={});var t=e.insertAt;if(n&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===t&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n))}}(".index-module_slot_wrap__ZT-DX {\n display: inline-block;\n white-space: nowrap;\n}\n\n.index-module_slot__DpPgW {\n display: inline-block;\n overflow: hidden;\n text-align: center;\n vertical-align: middle;\n will-change: transform;\n}\n\n.index-module_separator__7GhtE {\n display: inline-block;\n vertical-align: middle;\n text-align: center;\n}\n\n.index-module_numbers__sqlqm {\n display: block;\n}\n\n.index-module_num__j6XH3 {\n display: block;\n}");var x="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;var S=e((function(e){var o,a,l=e.isNew,d=e.charClassName,f=e.numbersRef,m=e.active,h=e.isChanged,p=e.effectiveDuration,g=e.delay,y=e.value,N=e.startValue,S=e.disableStartValue,A=e.dummyList,w=e.hasSequentialDummyList,E=e.hasInfiniteList,M=e.valueClassName,j=e.numberSlotClassName,T=e.numberClassName,D=e.reverse,O=e.sequentialAnimationMode,q=e.useMonospaceWidth,k=e.maxNumberWidth,L=e.onFontHeightChange,I=t(!1),P=I[0],R=I[1],V=t(y),W=V[0],B=V[1],F=r(),H=r(y),X=r(null),Y=t(0),z=Y[0],G=Y[1],Z=t(w?A:v(A)),J=Z[0],U=Z[1],K=t(!1),Q=K[0],$=K[1],nn=z*(A.length+1);x((function(){$(!0)}),[]),x((function(){var n,e;G(null!==(e=null===(n=X.current)||void 0===n?void 0:n.getBoundingClientRect().height)&&void 0!==e?e:0)}),[Q]),i((function(){m?requestAnimationFrame((function(){R(m)})):R(m)}),[m]),i((function(){var n=X.current;if(z&&n&&"undefined"!=typeof ResizeObserver){var e=new ResizeObserver((function(n){var e=n[0].contentRect.height;z!=e&&(null==L||L(e))}));return e.observe(n),function(){e.disconnect()}}}),[z,L]),u((function(){S&&(F.current=H.current)}),[S]),i((function(){P&&(F.current=H.current,H.current=y,setTimeout((function(){return B(y)}),O?0:1e3*p*1.3/A.length+1e3*g))}),[P,y,p,g,A.length,O]),i((function(){U(w?A:v(A))}),[y,A,w]);var en=function(){return J.map((function(e,t){return n.createElement("span",{key:t,className:s(_,T),"aria-hidden":"true"},e)}))},tn=D?W:null!=N?N:W;O&&(tn=D?W:null!==(o=null!=N?N:F.current)&&void 0!==o?o:W,O&&l&&(tn=""));var rn=D&&null!=N?N:W;return O&&(rn=D&&null!==(a=null!=N?N:F.current)&&void 0!==a?a:W),n.createElement("span",{className:s(b,d),style:{display:"inline-block",width:Q&&q?k:void 0,height:Q?z:void 0}},n.createElement("span",{ref:f,className:s(C,j),style:c({transition:"none",transform:D?"translateY(-".concat(nn,"px)"):"translateY(0px)"},P&&h&&{transform:D?"translateY(0px)":"translateY(-".concat(nn,"px)"),transition:"transform ".concat(p,"s ").concat(g,"s ease-in-out")})},Q?n.createElement(n.Fragment,null,n.createElement("span",{className:s(_,T),"aria-hidden":"true",style:{height:z}},tn),en(),n.createElement("span",{className:s(_,T,M),ref:X},rn),E?en():null):n.createElement("span",{className:s(_,T),"aria-hidden":"true"},null!=N?N:W)))}));var A=[",","."," "];var w=e(a((function(e,a){var c,v,b,C,_,w,E,M,j,T,D=e.value,O=e.startValue,q=e.startValueOnce,k=void 0!==q&&q,L=e.duration,I=void 0===L?.7:L,P=e.dummyCharacters,R=e.dummyCharacterCount,V=void 0===R?6:R,W=e.autoAnimationStart,B=void 0===W||W,F=e.containerClassName,H=e.charClassName,X=e.separatorClassName,Y=e.valueClassName,z=e.numberSlotClassName,G=e.numberClassName,Z=e.animateUnchanged,J=void 0!==Z&&Z,U=e.hasInfiniteList,K=void 0!==U&&U,Q=e.sequentialAnimationMode,$=void 0!==Q&&Q,nn=e.useMonospaceWidth,en=void 0!==nn&&nn,tn=e.direction,rn=e.debounceDelay,un=e.animateOnVisible,on=function(n,e){var r=t(n),u=r[0],o=r[1];return i((function(){if(0===e)return o(n);var t=setTimeout((function(){o(n)}),e);return function(){clearTimeout(t)}}),[n,e]),u}(D,null!=rn?rn:0),an=u((function(){return function(n){return Array.isArray(n)&&g(n[0])}(on)?"":"object"==typeof on?JSON.stringify(on):on.toString()}),[on]),ln=t(!1),cn=ln[0],sn=ln[1],dn=r(),fn=r(null),mn=r(null),vn=r(O),hn=u((function(){return"boolean"==typeof un?un:"object"==typeof un||void 0}),[un]),pn=u((function(){return"object"==typeof un?un.rootMargin:void 0}),[un]),gn=u((function(){return"object"==typeof un?un.triggerOnce:void 0}),[un]),yn=r(!0),bn=!hn&&B,Nn=r(null==O||bn?on:O),Cn=r(O),_n=r(0),xn=r(0),Sn=t([]),An=Sn[0],wn=Sn[1],En=r(),Mn=t(0),jn=Mn[0],Tn=Mn[1],Dn=t(),On=Dn[0],qn=Dn[1],kn=r(!1),Ln=null!=O&&(!k||_n.current<1),In=null!==(v=null===(c=dn.current)||void 0===c?void 0:c.dummyCharacterCount)&&void 0!==v?v:V,Pn=null!==(C=null===(b=dn.current)||void 0===b?void 0:b.duration)&&void 0!==C?C:I,Rn=o((function(){var n=mn.current;if(n&&en){var e=d(0,10).map((function(e){var t=document.createElement("span");t.className=null!=Y?Y:"",t.style.position="absolute",t.style.top="0",t.style.left="-9999px",t.style.visibility="hidden",t.textContent=e.toString(),n.appendChild(t);var r=t.getBoundingClientRect().width;return n.removeChild(t),r})),t=Math.max.apply(Math,e);qn(t)}}),[en,Y]);x((function(){var n;Rn(),null===(n=document.fonts)||void 0===n||n.ready.then((function(){Rn()}))}),[]),i((function(){wn(d(0,In-1).map((function(n){if(!P)return m(0,10);var e=n>=P.length?m(0,P.length):n;return P[e]})))}),[P,In]),Nn.current!==on&&kn.current&&xn.current>0&&(Cn.current=Nn.current,Nn.current=on);var Vn=Array.isArray(Cn.current)?Cn.current:null!==(w=null===(_=Cn.current)||void 0===_?void 0:_.toString().split(""))&&void 0!==w?w:[],Wn=Array.isArray(Nn.current)?Nn.current:null!==(M=null===(E=Nn.current)||void 0===E?void 0:E.toString().split(""))&&void 0!==M?M:[],Bn=Array.isArray(vn.current)?vn.current:null!==(T=null===(j=vn.current)||void 0===j?void 0:j.toString().split(""))&&void 0!==T?T:[],Fn=u((function(){return Array.isArray(on)?on:null==on?void 0:on.toString().split("")}),[on]),Hn=u((function(){return Array.isArray(O)?O:null==O?void 0:O.toString().split("")}),[O]),Xn=Vn.length!==Wn.length,Yn=[];Wn.forEach((function(n,e){var t=Wn.length-e-1,r=Ln?Bn:Vn;(Wn[t]!==r[t]||Xn||J)&&Yn.push(t)})),Yn.reverse();var zn=u((function(){return Math.min(.1,Pn/Fn.length)}),[Pn,Fn.length]),Gn=o((function(){En.current&&clearTimeout(En.current),sn(!1),_n.current=xn.current,_n.current+=1,En.current=setTimeout((function(){xn.current+=1,sn(!0)}),20)}),[]),Zn=o((function(n){var e=Ln?O:Cn.current;if(null==e||!p(e)||!p(on))return[];var t=e.toString().length,r=on.toString().length,i=t<r,u=Math.abs(t-r),o=Number(h(e.toString())),a=Number(h(on.toString())),l=Number(o.toString()[i?-u+n:u+n]||0),c=Number(a.toString()[n]||0);return c===l?[]:o<a?f((l+1)%10,c):f((c+1)%10,l)}),[Ln,on,O]),Jn=o((function(){Tn((function(n){return n+1})),Rn()}),[Rn]);i((function(){(kn.current||null!=Cn.current)&&(kn.current||null==vn.current)&&(kn.current||bn)&&Gn()}),[an,Gn,bn]),i((function(){bn&&Gn()}),[bn,Gn]),i((function(){requestAnimationFrame((function(){kn.current=!0}))}),[]),l(a,(function(){return{startAnimation:te,refreshStyles:Jn}}));var Un=null==O||bn||0!==_n.current?Fn:Hn||[],Kn=((null==Hn?void 0:Hn.length)||0)-Un.length,Qn=function(n){var e,t=r(n),u=r(t.current),a=n.join(","),l=null===(e=t.current)||void 0===e?void 0:e.join(",");return i((function(){l!==a&&(u.current=(null==l?void 0:l.split(","))||[],t.current=a.split(","))}),[a,l]),{getPrevDependencies:o((function(){return u.current}),[]),setPrevDependenciesToSameAsCurrent:o((function(){u.current=t.current}),[])}}(Un),$n=Qn.getPrevDependencies,ne=Qn.setPrevDependenciesToSameAsCurrent,ee=Un.length-$n().length,te=o((function(n){null==O||k||(Cn.current=void 0),dn.current=n,Gn(),ne()}),[O,k,Gn,ne]),re=u((function(){return n=function(){Jn()},e=0,function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];clearTimeout(t),t=setTimeout((function(){n.apply(void 0,r)}),e)};var n,e,t}),[Jn]);i((function(){if(hn&&fn.current){var n=new IntersectionObserver((function(t){t[0].isIntersecting&&yn.current&&(te(),yn.current=!1,gn&&(n.disconnect(),e.disconnect()))}),{rootMargin:pn,threshold:1}),e=new IntersectionObserver((function(n){n[0].isIntersecting||(yn.current=!0)}),{threshold:0});return n.observe(fn.current),e.observe(fn.current),function(){n.disconnect(),e.disconnect()}}}),[hn,pn,gn,te]);var ie=-1;return n.createElement("span",{key:jn,ref:fn,className:s(F,y)},Un.map((function(e,t){var r,i,u=Yn.includes(t),o=(u?Yn.indexOf(t):0)*zn,a=Cn.current,l=null!=O&&!!k&&_n.current>1,c=null!=on&&null!=a&&p(on)&&p(a)&&h(on)<h(a);if((null===(r=dn.current)||void 0===r?void 0:r.direction)&&(c="top-down"===(null===(i=dn.current)||void 0===i?void 0:i.direction)),tn&&(c="top-down"===tn),!g(e)&&A.includes(e))return n.createElement("span",{key:Wn.length-t-1,className:s(N,X)},e);var d=$&&(!bn||xn.current>1);return ie+=1,n.createElement(S,{key:Un.length-t-1,index:t,isNew:ee>0&&t<ee,maxNumberWidth:On,numbersRef:mn,active:cn,isChanged:u,charClassName:H,effectiveDuration:Pn,delay:o,value:e,startValue:l||null==Hn?void 0:Hn[t+Kn],disableStartValue:l,dummyList:d?Zn(ie):An,hasSequentialDummyList:d,hasInfiniteList:K,valueClassName:Y,numberSlotClassName:z,numberClassName:G,reverse:c,sequentialAnimationMode:$,useMonospaceWidth:en,onFontHeightChange:re})})))})));export{w as default};
import n,{memo as e,useState as t,useRef as r,useEffect as i,useMemo as u,useCallback as o,forwardRef as a,useImperativeHandle as l}from"react";var c=function(){return c=Object.assign||function(n){for(var e,t=1,r=arguments.length;t<r;t++)for(var i in e=arguments[t])Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);return n},c.apply(this,arguments)};var s=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return n.filter(Boolean).join(" ")},d=function(n,e){for(var t=[],r=n;r<e;r+=1)t.push(r);return t},f=function(n,e){for(var t=[],r=n;r!==e;)t.push(r),10===(r+=1)&&(r=0);return t},m=function(n,e){var t=Math.random()*(e-n);return Math.floor(t+n)},v=function(n){for(var e,t=function(n,e,t){if(t||2===arguments.length)for(var r,i=0,u=e.length;i<u;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return n.concat(r||Array.prototype.slice.call(e))}([],n,!0),r=t.length-1;r>0;r-=1){var i=Math.floor(Math.random()*(r+1));e=[t[i],t[r]],t[r]=e[0],t[i]=e[1]}return t},h=function(n){return"number"==typeof n?n:(Array.isArray(n)?n.join(""):n).replace(/[,.]/g,"")},p=function(n){return"object"!=typeof n&&!Number.isNaN(h(n))},g=function(n){return"object"==typeof n};var y="index-module_slot_wrap__ZT-DX",b="index-module_slot__DpPgW",N="index-module_separator__7GhtE",C="index-module_numbers__sqlqm",_="index-module_num__j6XH3";!function(n,e){void 0===e&&(e={});var t=e.insertAt;if(n&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===t&&r.firstChild?r.insertBefore(i,r.firstChild):r.appendChild(i),i.styleSheet?i.styleSheet.cssText=n:i.appendChild(document.createTextNode(n))}}(".index-module_slot_wrap__ZT-DX {\n display: inline-block;\n white-space: nowrap;\n}\n\n.index-module_slot__DpPgW {\n display: inline-block;\n overflow: hidden;\n text-align: center;\n vertical-align: middle;\n will-change: transform;\n}\n\n.index-module_separator__7GhtE {\n display: inline-block;\n vertical-align: middle;\n text-align: center;\n}\n\n.index-module_numbers__sqlqm {\n display: block;\n}\n\n.index-module_num__j6XH3 {\n display: block;\n}");var x="undefined"!=typeof window?n.useLayoutEffect:n.useEffect;var S=e((function(e){var o,a,l=e.isNew,d=e.charClassName,f=e.numbersRef,m=e.active,h=e.isChanged,p=e.effectiveDuration,g=e.delay,y=e.value,N=e.startValue,S=e.disableStartValue,A=e.dummyList,w=e.hasSequentialDummyList,E=e.hasInfiniteList,M=e.valueClassName,j=e.numberSlotClassName,T=e.numberClassName,D=e.reverse,O=e.sequentialAnimationMode,q=e.useMonospaceWidth,k=e.maxNumberWidth,L=e.onFontHeightChange,I=t(!1),P=I[0],R=I[1],V=t(y),W=V[0],B=V[1],F=r(),H=r(y),X=r(null),Y=t(0),z=Y[0],G=Y[1],Z=t(w?A:v(A)),J=Z[0],U=Z[1],K=t(!1),Q=K[0],$=K[1],nn=z*(A.length+1);x((function(){$(!0)}),[]),x((function(){var n,e;G(null!==(e=null===(n=X.current)||void 0===n?void 0:n.getBoundingClientRect().height)&&void 0!==e?e:0)}),[Q]),i((function(){m?requestAnimationFrame((function(){R(m)})):R(m)}),[m]),i((function(){var n=X.current;if(z&&n&&"undefined"!=typeof ResizeObserver){var e=new ResizeObserver((function(n){var e=n[0].contentRect.height;z!=e&&(null==L||L(e))}));return e.observe(n),function(){e.disconnect()}}}),[z,L]),u((function(){S&&(F.current=H.current)}),[S]),i((function(){P&&(F.current=H.current,H.current=y,setTimeout((function(){return B(y)}),O?0:1e3*p*1.3/A.length+1e3*g))}),[P,y,p,g,A.length,O]),i((function(){U(w?A:v(A))}),[y,A,w]);var en=function(){return J.map((function(e,t){return n.createElement("span",{key:t,className:s(_,T),"aria-hidden":"true"},e)}))},tn=D?W:null!=N?N:W;O&&(tn=D?W:null!==(o=null!=N?N:F.current)&&void 0!==o?o:W,O&&l&&(tn=""));var rn=D&&null!=N?N:W;return O&&(rn=D&&null!==(a=null!=N?N:F.current)&&void 0!==a?a:W),n.createElement("span",{className:s(b,d),style:{display:"inline-block",width:Q&&q?k:void 0,height:Q?z:void 0}},n.createElement("span",{ref:f,className:s(C,j),style:c({transition:"none",transform:D?"translateY(-".concat(nn,"px)"):"translateY(0px)"},P&&h&&{transform:D?"translateY(0px)":"translateY(-".concat(nn,"px)"),transition:"transform ".concat(p,"s ").concat(g,"s ease-in-out")})},Q?n.createElement(n.Fragment,null,n.createElement("span",{className:s(_,T),"aria-hidden":"true",style:{height:z}},tn),en(),n.createElement("span",{className:s(_,T,M),ref:X},rn),E?en():null):n.createElement("span",{className:s(_,T),"aria-hidden":"true"},null!=N?N:W)))}));var A=[",","."," "];var w=e(a((function(e,a){var c,v,b,C,_,w,E,M,j,T,D=e.value,O=e.startValue,q=e.startValueOnce,k=void 0!==q&&q,L=e.duration,I=void 0===L?.7:L,P=e.dummyCharacters,R=e.dummyCharacterCount,V=void 0===R?6:R,W=e.autoAnimationStart,B=void 0===W||W,F=e.containerClassName,H=e.charClassName,X=e.separatorClassName,Y=e.valueClassName,z=e.numberSlotClassName,G=e.numberClassName,Z=e.animateUnchanged,J=void 0!==Z&&Z,U=e.hasInfiniteList,K=void 0!==U&&U,Q=e.sequentialAnimationMode,$=void 0!==Q&&Q,nn=e.useMonospaceWidth,en=void 0!==nn&&nn,tn=e.direction,rn=e.debounceDelay,un=e.animateOnVisible,on=function(n,e){var r=t(n),u=r[0],o=r[1];return i((function(){if(0===e)return o(n);var t=setTimeout((function(){o(n)}),e);return function(){clearTimeout(t)}}),[n,e]),u}(D,null!=rn?rn:0),an=u((function(){return function(n){return Array.isArray(n)&&g(n[0])}(on)?"":"object"==typeof on?JSON.stringify(on):on.toString()}),[on]),ln=t(!1),cn=ln[0],sn=ln[1],dn=r(),fn=r(null),mn=r(null),vn=r(O),hn=u((function(){return"boolean"==typeof un?un:"object"==typeof un||void 0}),[un]),pn=u((function(){return"object"==typeof un?un.rootMargin:void 0}),[un]),gn=u((function(){return"object"==typeof un?un.triggerOnce:void 0}),[un]),yn=r(!0),bn=!hn&&B,Nn=r(null==O||bn?on:O),Cn=r(O),_n=r(0),xn=r(0),Sn=t([]),An=Sn[0],wn=Sn[1],En=r(),Mn=t(0),jn=Mn[0],Tn=Mn[1],Dn=t(),On=Dn[0],qn=Dn[1],kn=r(!1),Ln=null!=O&&(!k||_n.current<1),In=null!==(v=null===(c=dn.current)||void 0===c?void 0:c.dummyCharacterCount)&&void 0!==v?v:V,Pn=null!==(C=null===(b=dn.current)||void 0===b?void 0:b.duration)&&void 0!==C?C:I,Rn=o((function(){var n=mn.current;if(n){var e=d(0,10).map((function(e){var t=document.createElement("span");t.className=null!=Y?Y:"",t.style.position="absolute",t.style.top="0",t.style.left="-9999px",t.style.visibility="hidden",t.textContent=e.toString(),n.appendChild(t);var r=t.getBoundingClientRect().width;return n.removeChild(t),r})),t=Math.max.apply(Math,e);qn(t)}}),[Y]);x((function(){var n;Rn(),null===(n=document.fonts)||void 0===n||n.ready.then((function(){Rn()}))}),[]),i((function(){wn(d(0,In-1).map((function(n){if(!P)return m(0,10);var e=n>=P.length?m(0,P.length):n;return P[e]})))}),[P,In]),Nn.current!==on&&kn.current&&xn.current>0&&(Cn.current=Nn.current,Nn.current=on);var Vn=Array.isArray(Cn.current)?Cn.current:null!==(w=null===(_=Cn.current)||void 0===_?void 0:_.toString().split(""))&&void 0!==w?w:[],Wn=Array.isArray(Nn.current)?Nn.current:null!==(M=null===(E=Nn.current)||void 0===E?void 0:E.toString().split(""))&&void 0!==M?M:[],Bn=Array.isArray(vn.current)?vn.current:null!==(T=null===(j=vn.current)||void 0===j?void 0:j.toString().split(""))&&void 0!==T?T:[],Fn=u((function(){return Array.isArray(on)?on:null==on?void 0:on.toString().split("")}),[on]),Hn=u((function(){return Array.isArray(O)?O:null==O?void 0:O.toString().split("")}),[O]),Xn=Vn.length!==Wn.length,Yn=[];Wn.forEach((function(n,e){var t=Wn.length-e-1,r=Ln?Bn:Vn;(Wn[t]!==r[t]||Xn||J)&&Yn.push(t)})),Yn.reverse();var zn=u((function(){return Math.min(.1,Pn/Fn.length)}),[Pn,Fn.length]),Gn=o((function(){En.current&&clearTimeout(En.current),sn(!1),_n.current=xn.current,_n.current+=1,En.current=setTimeout((function(){xn.current+=1,sn(!0)}),20)}),[]),Zn=o((function(n){var e=Ln?O:Cn.current;if(null==e||!p(e)||!p(on))return[];var t=e.toString().length,r=on.toString().length,i=t<r,u=Math.abs(t-r),o=Number(h(e.toString())),a=Number(h(on.toString())),l=Number(o.toString()[i?-u+n:u+n]||0),c=Number(a.toString()[n]||0);return c===l?[]:o<a?f((l+1)%10,c):f((c+1)%10,l)}),[Ln,on,O]),Jn=o((function(){Tn((function(n){return n+1})),Rn()}),[Rn]);i((function(){(kn.current||null!=Cn.current)&&(kn.current||null==vn.current)&&(kn.current||bn)&&Gn()}),[an,Gn,bn]),i((function(){bn&&Gn()}),[bn,Gn]),i((function(){requestAnimationFrame((function(){kn.current=!0}))}),[]),l(a,(function(){return{startAnimation:te,refreshStyles:Jn}}));var Un=null==O||bn||0!==_n.current?Fn:Hn||[],Kn=((null==Hn?void 0:Hn.length)||0)-Un.length,Qn=function(n){var e,t=r(n),u=r(t.current),a=n.join(","),l=null===(e=t.current)||void 0===e?void 0:e.join(",");return i((function(){l!==a&&(u.current=(null==l?void 0:l.split(","))||[],t.current=a.split(","))}),[a,l]),{getPrevDependencies:o((function(){return u.current}),[]),setPrevDependenciesToSameAsCurrent:o((function(){u.current=t.current}),[])}}(Un),$n=Qn.getPrevDependencies,ne=Qn.setPrevDependenciesToSameAsCurrent,ee=Un.length-$n().length,te=o((function(n){null==O||k||(Cn.current=void 0),dn.current=n,Gn(),ne()}),[O,k,Gn,ne]),re=u((function(){return n=function(){Jn()},e=0,function(){for(var r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];clearTimeout(t),t=setTimeout((function(){n.apply(void 0,r)}),e)};var n,e,t}),[Jn]);i((function(){if(hn&&fn.current){var n=new IntersectionObserver((function(t){t[0].isIntersecting&&yn.current&&(te(),yn.current=!1,gn&&(n.disconnect(),e.disconnect()))}),{rootMargin:pn,threshold:1}),e=new IntersectionObserver((function(n){n[0].isIntersecting||(yn.current=!0)}),{threshold:0});return n.observe(fn.current),e.observe(fn.current),function(){n.disconnect(),e.disconnect()}}}),[hn,pn,gn,te]);var ie=-1;return n.createElement("span",{key:jn,ref:fn,className:s(F,y)},Un.map((function(e,t){var r,i,u=Yn.includes(t),o=(u?Yn.indexOf(t):0)*zn,a=Cn.current,l=null!=O&&!!k&&_n.current>1,c=null!=on&&null!=a&&p(on)&&p(a)&&h(on)<h(a);if((null===(r=dn.current)||void 0===r?void 0:r.direction)&&(c="top-down"===(null===(i=dn.current)||void 0===i?void 0:i.direction)),tn&&(c="top-down"===tn),!g(e)&&A.includes(e))return n.createElement("span",{key:Wn.length-t-1,className:s(N,X)},e);var d=$&&(!bn||xn.current>1);return ie+=1,n.createElement(S,{key:Un.length-t-1,index:t,isNew:ee>0&&t<ee,maxNumberWidth:On,numbersRef:mn,active:cn,isChanged:u,charClassName:H,effectiveDuration:Pn,delay:o,value:e,startValue:l||null==Hn?void 0:Hn[t+Kn],disableStartValue:l,dummyList:d?Zn(ie):An,hasSequentialDummyList:d,hasInfiniteList:K,valueClassName:Y,numberSlotClassName:z,numberClassName:G,reverse:c,sequentialAnimationMode:$,useMonospaceWidth:en,onFontHeightChange:re})})))})));export{w as default};
//# sourceMappingURL=index.esm.js.map
'use client';
"use strict";var e=require("react"),n=function(){return n=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var u in n=arguments[t])Object.prototype.hasOwnProperty.call(n,u)&&(e[u]=n[u]);return e},n.apply(this,arguments)};var t=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.filter(Boolean).join(" ")},r=function(e,n){for(var t=[],r=e;r<n;r+=1)t.push(r);return t},u=function(e,n){for(var t=[],r=e;r!==n;)t.push(r),10===(r+=1)&&(r=0);return t},i=function(e,n){var t=Math.random()*(n-e);return Math.floor(t+e)},a=function(e){for(var n,t=function(e,n,t){if(t||2===arguments.length)for(var r,u=0,i=n.length;u<i;u++)!r&&u in n||(r||(r=Array.prototype.slice.call(n,0,u)),r[u]=n[u]);return e.concat(r||Array.prototype.slice.call(n))}([],e,!0),r=t.length-1;r>0;r-=1){var u=Math.floor(Math.random()*(r+1));n=[t[u],t[r]],t[r]=n[0],t[u]=n[1]}return t},o=function(e){return"number"==typeof e?e:(Array.isArray(e)?e.join(""):e).replace(/[,.]/g,"")},l=function(e){return"object"!=typeof e&&!Number.isNaN(o(e))},s=function(e){return"object"==typeof e};var c="index-module_slot_wrap__ZT-DX",f="index-module_slot__DpPgW",d="index-module_separator__7GhtE",m="index-module_numbers__sqlqm",v="index-module_num__j6XH3";!function(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],u=document.createElement("style");u.type="text/css","top"===t&&r.firstChild?r.insertBefore(u,r.firstChild):r.appendChild(u),u.styleSheet?u.styleSheet.cssText=e:u.appendChild(document.createTextNode(e))}}(".index-module_slot_wrap__ZT-DX {\n display: inline-block;\n white-space: nowrap;\n}\n\n.index-module_slot__DpPgW {\n display: inline-block;\n overflow: hidden;\n text-align: center;\n vertical-align: middle;\n will-change: transform;\n}\n\n.index-module_separator__7GhtE {\n display: inline-block;\n vertical-align: middle;\n text-align: center;\n}\n\n.index-module_numbers__sqlqm {\n display: block;\n}\n\n.index-module_num__j6XH3 {\n display: block;\n}");var h="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;var p=e.memo((function(r){var u,i,o=r.isNew,l=r.charClassName,s=r.numbersRef,c=r.active,d=r.isChanged,p=r.effectiveDuration,g=r.delay,y=r.value,b=r.startValue,C=r.disableStartValue,N=r.dummyList,S=r.hasSequentialDummyList,_=r.hasInfiniteList,E=r.valueClassName,x=r.numberSlotClassName,A=r.numberClassName,M=r.reverse,R=r.sequentialAnimationMode,w=r.useMonospaceWidth,k=r.maxNumberWidth,j=r.onFontHeightChange,T=e.useState(!1),D=T[0],q=T[1],O=e.useState(y),I=O[0],L=O[1],P=e.useRef(),V=e.useRef(y),W=e.useRef(null),B=e.useState(0),F=B[0],H=B[1],X=e.useState(S?N:a(N)),Y=X[0],z=X[1],G=e.useState(!1),Z=G[0],J=G[1],U=F*(N.length+1);h((function(){J(!0)}),[]),h((function(){var e,n;H(null!==(n=null===(e=W.current)||void 0===e?void 0:e.getBoundingClientRect().height)&&void 0!==n?n:0)}),[Z]),e.useEffect((function(){c?requestAnimationFrame((function(){q(c)})):q(c)}),[c]),e.useEffect((function(){var e=W.current;if(F&&e&&"undefined"!=typeof ResizeObserver){var n=new ResizeObserver((function(e){var n=e[0].contentRect.height;F!=n&&(null==j||j(n))}));return n.observe(e),function(){n.disconnect()}}}),[F,j]),e.useMemo((function(){C&&(P.current=V.current)}),[C]),e.useEffect((function(){D&&(P.current=V.current,V.current=y,setTimeout((function(){return L(y)}),R?0:1e3*p*1.3/N.length+1e3*g))}),[D,y,p,g,N.length,R]),e.useEffect((function(){z(S?N:a(N))}),[y,N,S]);var K=function(){return Y.map((function(n,r){return e.createElement("span",{key:r,className:t(v,A),"aria-hidden":"true"},n)}))},Q=M?I:null!=b?b:I;R&&(Q=M?I:null!==(u=null!=b?b:P.current)&&void 0!==u?u:I,R&&o&&(Q=""));var $=M&&null!=b?b:I;return R&&($=M&&null!==(i=null!=b?b:P.current)&&void 0!==i?i:I),e.createElement("span",{className:t(f,l),style:{display:"inline-block",width:Z&&w?k:void 0,height:Z?F:void 0}},e.createElement("span",{ref:s,className:t(m,x),style:n({transition:"none",transform:M?"translateY(-".concat(U,"px)"):"translateY(0px)"},D&&d&&{transform:M?"translateY(0px)":"translateY(-".concat(U,"px)"),transition:"transform ".concat(p,"s ").concat(g,"s ease-in-out")})},Z?e.createElement(e.Fragment,null,e.createElement("span",{className:t(v,A),"aria-hidden":"true",style:{height:F}},Q),K(),e.createElement("span",{className:t(v,A,E),ref:W},$),_?K():null):e.createElement("span",{className:t(v,A),"aria-hidden":"true"},null!=b?b:I)))}));var g=[",","."," "];var y=e.memo(e.forwardRef((function(n,a){var f,m,v,y,b,C,N,S,_,E,x=n.value,A=n.startValue,M=n.startValueOnce,R=void 0!==M&&M,w=n.duration,k=void 0===w?.7:w,j=n.dummyCharacters,T=n.dummyCharacterCount,D=void 0===T?6:T,q=n.autoAnimationStart,O=void 0===q||q,I=n.containerClassName,L=n.charClassName,P=n.separatorClassName,V=n.valueClassName,W=n.numberSlotClassName,B=n.numberClassName,F=n.animateUnchanged,H=void 0!==F&&F,X=n.hasInfiniteList,Y=void 0!==X&&X,z=n.sequentialAnimationMode,G=void 0!==z&&z,Z=n.useMonospaceWidth,J=void 0!==Z&&Z,U=n.direction,K=n.debounceDelay,Q=n.animateOnVisible,$=function(n,t){var r=e.useState(n),u=r[0],i=r[1];return e.useEffect((function(){if(0===t)return i(n);var e=setTimeout((function(){i(n)}),t);return function(){clearTimeout(e)}}),[n,t]),u}(x,null!=K?K:0),ee=e.useMemo((function(){return function(e){return Array.isArray(e)&&s(e[0])}($)?"":"object"==typeof $?JSON.stringify($):$.toString()}),[$]),ne=e.useState(!1),te=ne[0],re=ne[1],ue=e.useRef(),ie=e.useRef(null),ae=e.useRef(null),oe=e.useRef(A),le=e.useMemo((function(){return"boolean"==typeof Q?Q:"object"==typeof Q||void 0}),[Q]),se=e.useMemo((function(){return"object"==typeof Q?Q.rootMargin:void 0}),[Q]),ce=e.useMemo((function(){return"object"==typeof Q?Q.triggerOnce:void 0}),[Q]),fe=e.useRef(!0),de=!le&&O,me=e.useRef(null==A||de?$:A),ve=e.useRef(A),he=e.useRef(0),pe=e.useRef(0),ge=e.useState([]),ye=ge[0],be=ge[1],Ce=e.useRef(),Ne=e.useState(0),Se=Ne[0],_e=Ne[1],Ee=e.useState(),xe=Ee[0],Ae=Ee[1],Me=e.useRef(!1),Re=null!=A&&(!R||he.current<1),we=null!==(m=null===(f=ue.current)||void 0===f?void 0:f.dummyCharacterCount)&&void 0!==m?m:D,ke=null!==(y=null===(v=ue.current)||void 0===v?void 0:v.duration)&&void 0!==y?y:k,je=e.useCallback((function(){var e=ae.current;if(e&&J){var n=r(0,10).map((function(n){var t=document.createElement("span");t.className=null!=V?V:"",t.style.position="absolute",t.style.top="0",t.style.left="-9999px",t.style.visibility="hidden",t.textContent=n.toString(),e.appendChild(t);var r=t.getBoundingClientRect().width;return e.removeChild(t),r})),t=Math.max.apply(Math,n);Ae(t)}}),[J,V]);h((function(){var e;je(),null===(e=document.fonts)||void 0===e||e.ready.then((function(){je()}))}),[]),e.useEffect((function(){be(r(0,we-1).map((function(e){if(!j)return i(0,10);var n=e>=j.length?i(0,j.length):e;return j[n]})))}),[j,we]),me.current!==$&&Me.current&&pe.current>0&&(ve.current=me.current,me.current=$);var Te=Array.isArray(ve.current)?ve.current:null!==(C=null===(b=ve.current)||void 0===b?void 0:b.toString().split(""))&&void 0!==C?C:[],De=Array.isArray(me.current)?me.current:null!==(S=null===(N=me.current)||void 0===N?void 0:N.toString().split(""))&&void 0!==S?S:[],qe=Array.isArray(oe.current)?oe.current:null!==(E=null===(_=oe.current)||void 0===_?void 0:_.toString().split(""))&&void 0!==E?E:[],Oe=e.useMemo((function(){return Array.isArray($)?$:null==$?void 0:$.toString().split("")}),[$]),Ie=e.useMemo((function(){return Array.isArray(A)?A:null==A?void 0:A.toString().split("")}),[A]),Le=Te.length!==De.length,Pe=[];De.forEach((function(e,n){var t=De.length-n-1,r=Re?qe:Te;(De[t]!==r[t]||Le||H)&&Pe.push(t)})),Pe.reverse();var Ve=e.useMemo((function(){return Math.min(.1,ke/Oe.length)}),[ke,Oe.length]),We=e.useCallback((function(){Ce.current&&clearTimeout(Ce.current),re(!1),he.current=pe.current,he.current+=1,Ce.current=setTimeout((function(){pe.current+=1,re(!0)}),20)}),[]),Be=e.useCallback((function(e){var n=Re?A:ve.current;if(null==n||!l(n)||!l($))return[];var t=n.toString().length,r=$.toString().length,i=t<r,a=Math.abs(t-r),s=Number(o(n.toString())),c=Number(o($.toString())),f=Number(s.toString()[i?-a+e:a+e]||0),d=Number(c.toString()[e]||0);return d===f?[]:s<c?u((f+1)%10,d):u((d+1)%10,f)}),[Re,$,A]),Fe=e.useCallback((function(){_e((function(e){return e+1})),je()}),[je]);e.useEffect((function(){(Me.current||null!=ve.current)&&(Me.current||null==oe.current)&&(Me.current||de)&&We()}),[ee,We,de]),e.useEffect((function(){de&&We()}),[de,We]),e.useEffect((function(){requestAnimationFrame((function(){Me.current=!0}))}),[]),e.useImperativeHandle(a,(function(){return{startAnimation:Je,refreshStyles:Fe}}));var He=null==A||de||0!==he.current?Oe:Ie||[],Xe=((null==Ie?void 0:Ie.length)||0)-He.length,Ye=function(n){var t,r=e.useRef(n),u=e.useRef(r.current),i=n.join(","),a=null===(t=r.current)||void 0===t?void 0:t.join(",");return e.useEffect((function(){a!==i&&(u.current=(null==a?void 0:a.split(","))||[],r.current=i.split(","))}),[i,a]),{getPrevDependencies:e.useCallback((function(){return u.current}),[]),setPrevDependenciesToSameAsCurrent:e.useCallback((function(){u.current=r.current}),[])}}(He),ze=Ye.getPrevDependencies,Ge=Ye.setPrevDependenciesToSameAsCurrent,Ze=He.length-ze().length,Je=e.useCallback((function(e){null==A||R||(ve.current=void 0),ue.current=e,We(),Ge()}),[A,R,We,Ge]),Ue=e.useMemo((function(){return e=function(){Fe()},n=0,function(){for(var r=[],u=0;u<arguments.length;u++)r[u]=arguments[u];clearTimeout(t),t=setTimeout((function(){e.apply(void 0,r)}),n)};var e,n,t}),[Fe]);e.useEffect((function(){if(le&&ie.current){var e=new IntersectionObserver((function(t){t[0].isIntersecting&&fe.current&&(Je(),fe.current=!1,ce&&(e.disconnect(),n.disconnect()))}),{rootMargin:se,threshold:1}),n=new IntersectionObserver((function(e){e[0].isIntersecting||(fe.current=!0)}),{threshold:0});return e.observe(ie.current),n.observe(ie.current),function(){e.disconnect(),n.disconnect()}}}),[le,se,ce,Je]);var Ke=-1;return e.createElement("span",{key:Se,ref:ie,className:t(I,c)},He.map((function(n,r){var u,i,a=Pe.includes(r),c=(a?Pe.indexOf(r):0)*Ve,f=ve.current,m=null!=A&&!!R&&he.current>1,v=null!=$&&null!=f&&l($)&&l(f)&&o($)<o(f);if((null===(u=ue.current)||void 0===u?void 0:u.direction)&&(v="top-down"===(null===(i=ue.current)||void 0===i?void 0:i.direction)),U&&(v="top-down"===U),!s(n)&&g.includes(n))return e.createElement("span",{key:De.length-r-1,className:t(d,P)},n);var h=G&&(!de||pe.current>1);return Ke+=1,e.createElement(p,{key:He.length-r-1,index:r,isNew:Ze>0&&r<Ze,maxNumberWidth:xe,numbersRef:ae,active:te,isChanged:a,charClassName:L,effectiveDuration:ke,delay:c,value:n,startValue:m||null==Ie?void 0:Ie[r+Xe],disableStartValue:m,dummyList:h?Be(Ke):ye,hasSequentialDummyList:h,hasInfiniteList:Y,valueClassName:V,numberSlotClassName:W,numberClassName:B,reverse:v,sequentialAnimationMode:G,useMonospaceWidth:J,onFontHeightChange:Ue})})))})));module.exports=y;
"use strict";var e=require("react"),n=function(){return n=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var u in n=arguments[t])Object.prototype.hasOwnProperty.call(n,u)&&(e[u]=n[u]);return e},n.apply(this,arguments)};var t=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.filter(Boolean).join(" ")},r=function(e,n){for(var t=[],r=e;r<n;r+=1)t.push(r);return t},u=function(e,n){for(var t=[],r=e;r!==n;)t.push(r),10===(r+=1)&&(r=0);return t},i=function(e,n){var t=Math.random()*(n-e);return Math.floor(t+e)},a=function(e){for(var n,t=function(e,n,t){if(t||2===arguments.length)for(var r,u=0,i=n.length;u<i;u++)!r&&u in n||(r||(r=Array.prototype.slice.call(n,0,u)),r[u]=n[u]);return e.concat(r||Array.prototype.slice.call(n))}([],e,!0),r=t.length-1;r>0;r-=1){var u=Math.floor(Math.random()*(r+1));n=[t[u],t[r]],t[r]=n[0],t[u]=n[1]}return t},o=function(e){return"number"==typeof e?e:(Array.isArray(e)?e.join(""):e).replace(/[,.]/g,"")},l=function(e){return"object"!=typeof e&&!Number.isNaN(o(e))},s=function(e){return"object"==typeof e};var c="index-module_slot_wrap__ZT-DX",f="index-module_slot__DpPgW",d="index-module_separator__7GhtE",m="index-module_numbers__sqlqm",v="index-module_num__j6XH3";!function(e,n){void 0===n&&(n={});var t=n.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],u=document.createElement("style");u.type="text/css","top"===t&&r.firstChild?r.insertBefore(u,r.firstChild):r.appendChild(u),u.styleSheet?u.styleSheet.cssText=e:u.appendChild(document.createTextNode(e))}}(".index-module_slot_wrap__ZT-DX {\n display: inline-block;\n white-space: nowrap;\n}\n\n.index-module_slot__DpPgW {\n display: inline-block;\n overflow: hidden;\n text-align: center;\n vertical-align: middle;\n will-change: transform;\n}\n\n.index-module_separator__7GhtE {\n display: inline-block;\n vertical-align: middle;\n text-align: center;\n}\n\n.index-module_numbers__sqlqm {\n display: block;\n}\n\n.index-module_num__j6XH3 {\n display: block;\n}");var h="undefined"!=typeof window?e.useLayoutEffect:e.useEffect;var p=e.memo((function(r){var u,i,o=r.isNew,l=r.charClassName,s=r.numbersRef,c=r.active,d=r.isChanged,p=r.effectiveDuration,g=r.delay,y=r.value,b=r.startValue,C=r.disableStartValue,N=r.dummyList,S=r.hasSequentialDummyList,_=r.hasInfiniteList,E=r.valueClassName,x=r.numberSlotClassName,A=r.numberClassName,M=r.reverse,R=r.sequentialAnimationMode,w=r.useMonospaceWidth,k=r.maxNumberWidth,j=r.onFontHeightChange,T=e.useState(!1),D=T[0],q=T[1],O=e.useState(y),I=O[0],L=O[1],P=e.useRef(),V=e.useRef(y),W=e.useRef(null),B=e.useState(0),F=B[0],H=B[1],X=e.useState(S?N:a(N)),Y=X[0],z=X[1],G=e.useState(!1),Z=G[0],J=G[1],U=F*(N.length+1);h((function(){J(!0)}),[]),h((function(){var e,n;H(null!==(n=null===(e=W.current)||void 0===e?void 0:e.getBoundingClientRect().height)&&void 0!==n?n:0)}),[Z]),e.useEffect((function(){c?requestAnimationFrame((function(){q(c)})):q(c)}),[c]),e.useEffect((function(){var e=W.current;if(F&&e&&"undefined"!=typeof ResizeObserver){var n=new ResizeObserver((function(e){var n=e[0].contentRect.height;F!=n&&(null==j||j(n))}));return n.observe(e),function(){n.disconnect()}}}),[F,j]),e.useMemo((function(){C&&(P.current=V.current)}),[C]),e.useEffect((function(){D&&(P.current=V.current,V.current=y,setTimeout((function(){return L(y)}),R?0:1e3*p*1.3/N.length+1e3*g))}),[D,y,p,g,N.length,R]),e.useEffect((function(){z(S?N:a(N))}),[y,N,S]);var K=function(){return Y.map((function(n,r){return e.createElement("span",{key:r,className:t(v,A),"aria-hidden":"true"},n)}))},Q=M?I:null!=b?b:I;R&&(Q=M?I:null!==(u=null!=b?b:P.current)&&void 0!==u?u:I,R&&o&&(Q=""));var $=M&&null!=b?b:I;return R&&($=M&&null!==(i=null!=b?b:P.current)&&void 0!==i?i:I),e.createElement("span",{className:t(f,l),style:{display:"inline-block",width:Z&&w?k:void 0,height:Z?F:void 0}},e.createElement("span",{ref:s,className:t(m,x),style:n({transition:"none",transform:M?"translateY(-".concat(U,"px)"):"translateY(0px)"},D&&d&&{transform:M?"translateY(0px)":"translateY(-".concat(U,"px)"),transition:"transform ".concat(p,"s ").concat(g,"s ease-in-out")})},Z?e.createElement(e.Fragment,null,e.createElement("span",{className:t(v,A),"aria-hidden":"true",style:{height:F}},Q),K(),e.createElement("span",{className:t(v,A,E),ref:W},$),_?K():null):e.createElement("span",{className:t(v,A),"aria-hidden":"true"},null!=b?b:I)))}));var g=[",","."," "];var y=e.memo(e.forwardRef((function(n,a){var f,m,v,y,b,C,N,S,_,E,x=n.value,A=n.startValue,M=n.startValueOnce,R=void 0!==M&&M,w=n.duration,k=void 0===w?.7:w,j=n.dummyCharacters,T=n.dummyCharacterCount,D=void 0===T?6:T,q=n.autoAnimationStart,O=void 0===q||q,I=n.containerClassName,L=n.charClassName,P=n.separatorClassName,V=n.valueClassName,W=n.numberSlotClassName,B=n.numberClassName,F=n.animateUnchanged,H=void 0!==F&&F,X=n.hasInfiniteList,Y=void 0!==X&&X,z=n.sequentialAnimationMode,G=void 0!==z&&z,Z=n.useMonospaceWidth,J=void 0!==Z&&Z,U=n.direction,K=n.debounceDelay,Q=n.animateOnVisible,$=function(n,t){var r=e.useState(n),u=r[0],i=r[1];return e.useEffect((function(){if(0===t)return i(n);var e=setTimeout((function(){i(n)}),t);return function(){clearTimeout(e)}}),[n,t]),u}(x,null!=K?K:0),ee=e.useMemo((function(){return function(e){return Array.isArray(e)&&s(e[0])}($)?"":"object"==typeof $?JSON.stringify($):$.toString()}),[$]),ne=e.useState(!1),te=ne[0],re=ne[1],ue=e.useRef(),ie=e.useRef(null),ae=e.useRef(null),oe=e.useRef(A),le=e.useMemo((function(){return"boolean"==typeof Q?Q:"object"==typeof Q||void 0}),[Q]),se=e.useMemo((function(){return"object"==typeof Q?Q.rootMargin:void 0}),[Q]),ce=e.useMemo((function(){return"object"==typeof Q?Q.triggerOnce:void 0}),[Q]),fe=e.useRef(!0),de=!le&&O,me=e.useRef(null==A||de?$:A),ve=e.useRef(A),he=e.useRef(0),pe=e.useRef(0),ge=e.useState([]),ye=ge[0],be=ge[1],Ce=e.useRef(),Ne=e.useState(0),Se=Ne[0],_e=Ne[1],Ee=e.useState(),xe=Ee[0],Ae=Ee[1],Me=e.useRef(!1),Re=null!=A&&(!R||he.current<1),we=null!==(m=null===(f=ue.current)||void 0===f?void 0:f.dummyCharacterCount)&&void 0!==m?m:D,ke=null!==(y=null===(v=ue.current)||void 0===v?void 0:v.duration)&&void 0!==y?y:k,je=e.useCallback((function(){var e=ae.current;if(e){var n=r(0,10).map((function(n){var t=document.createElement("span");t.className=null!=V?V:"",t.style.position="absolute",t.style.top="0",t.style.left="-9999px",t.style.visibility="hidden",t.textContent=n.toString(),e.appendChild(t);var r=t.getBoundingClientRect().width;return e.removeChild(t),r})),t=Math.max.apply(Math,n);Ae(t)}}),[V]);h((function(){var e;je(),null===(e=document.fonts)||void 0===e||e.ready.then((function(){je()}))}),[]),e.useEffect((function(){be(r(0,we-1).map((function(e){if(!j)return i(0,10);var n=e>=j.length?i(0,j.length):e;return j[n]})))}),[j,we]),me.current!==$&&Me.current&&pe.current>0&&(ve.current=me.current,me.current=$);var Te=Array.isArray(ve.current)?ve.current:null!==(C=null===(b=ve.current)||void 0===b?void 0:b.toString().split(""))&&void 0!==C?C:[],De=Array.isArray(me.current)?me.current:null!==(S=null===(N=me.current)||void 0===N?void 0:N.toString().split(""))&&void 0!==S?S:[],qe=Array.isArray(oe.current)?oe.current:null!==(E=null===(_=oe.current)||void 0===_?void 0:_.toString().split(""))&&void 0!==E?E:[],Oe=e.useMemo((function(){return Array.isArray($)?$:null==$?void 0:$.toString().split("")}),[$]),Ie=e.useMemo((function(){return Array.isArray(A)?A:null==A?void 0:A.toString().split("")}),[A]),Le=Te.length!==De.length,Pe=[];De.forEach((function(e,n){var t=De.length-n-1,r=Re?qe:Te;(De[t]!==r[t]||Le||H)&&Pe.push(t)})),Pe.reverse();var Ve=e.useMemo((function(){return Math.min(.1,ke/Oe.length)}),[ke,Oe.length]),We=e.useCallback((function(){Ce.current&&clearTimeout(Ce.current),re(!1),he.current=pe.current,he.current+=1,Ce.current=setTimeout((function(){pe.current+=1,re(!0)}),20)}),[]),Be=e.useCallback((function(e){var n=Re?A:ve.current;if(null==n||!l(n)||!l($))return[];var t=n.toString().length,r=$.toString().length,i=t<r,a=Math.abs(t-r),s=Number(o(n.toString())),c=Number(o($.toString())),f=Number(s.toString()[i?-a+e:a+e]||0),d=Number(c.toString()[e]||0);return d===f?[]:s<c?u((f+1)%10,d):u((d+1)%10,f)}),[Re,$,A]),Fe=e.useCallback((function(){_e((function(e){return e+1})),je()}),[je]);e.useEffect((function(){(Me.current||null!=ve.current)&&(Me.current||null==oe.current)&&(Me.current||de)&&We()}),[ee,We,de]),e.useEffect((function(){de&&We()}),[de,We]),e.useEffect((function(){requestAnimationFrame((function(){Me.current=!0}))}),[]),e.useImperativeHandle(a,(function(){return{startAnimation:Je,refreshStyles:Fe}}));var He=null==A||de||0!==he.current?Oe:Ie||[],Xe=((null==Ie?void 0:Ie.length)||0)-He.length,Ye=function(n){var t,r=e.useRef(n),u=e.useRef(r.current),i=n.join(","),a=null===(t=r.current)||void 0===t?void 0:t.join(",");return e.useEffect((function(){a!==i&&(u.current=(null==a?void 0:a.split(","))||[],r.current=i.split(","))}),[i,a]),{getPrevDependencies:e.useCallback((function(){return u.current}),[]),setPrevDependenciesToSameAsCurrent:e.useCallback((function(){u.current=r.current}),[])}}(He),ze=Ye.getPrevDependencies,Ge=Ye.setPrevDependenciesToSameAsCurrent,Ze=He.length-ze().length,Je=e.useCallback((function(e){null==A||R||(ve.current=void 0),ue.current=e,We(),Ge()}),[A,R,We,Ge]),Ue=e.useMemo((function(){return e=function(){Fe()},n=0,function(){for(var r=[],u=0;u<arguments.length;u++)r[u]=arguments[u];clearTimeout(t),t=setTimeout((function(){e.apply(void 0,r)}),n)};var e,n,t}),[Fe]);e.useEffect((function(){if(le&&ie.current){var e=new IntersectionObserver((function(t){t[0].isIntersecting&&fe.current&&(Je(),fe.current=!1,ce&&(e.disconnect(),n.disconnect()))}),{rootMargin:se,threshold:1}),n=new IntersectionObserver((function(e){e[0].isIntersecting||(fe.current=!0)}),{threshold:0});return e.observe(ie.current),n.observe(ie.current),function(){e.disconnect(),n.disconnect()}}}),[le,se,ce,Je]);var Ke=-1;return e.createElement("span",{key:Se,ref:ie,className:t(I,c)},He.map((function(n,r){var u,i,a=Pe.includes(r),c=(a?Pe.indexOf(r):0)*Ve,f=ve.current,m=null!=A&&!!R&&he.current>1,v=null!=$&&null!=f&&l($)&&l(f)&&o($)<o(f);if((null===(u=ue.current)||void 0===u?void 0:u.direction)&&(v="top-down"===(null===(i=ue.current)||void 0===i?void 0:i.direction)),U&&(v="top-down"===U),!s(n)&&g.includes(n))return e.createElement("span",{key:De.length-r-1,className:t(d,P)},n);var h=G&&(!de||pe.current>1);return Ke+=1,e.createElement(p,{key:He.length-r-1,index:r,isNew:Ze>0&&r<Ze,maxNumberWidth:xe,numbersRef:ae,active:te,isChanged:a,charClassName:L,effectiveDuration:ke,delay:c,value:n,startValue:m||null==Ie?void 0:Ie[r+Xe],disableStartValue:m,dummyList:h?Be(Ke):ye,hasSequentialDummyList:h,hasInfiniteList:Y,valueClassName:V,numberSlotClassName:W,numberClassName:B,reverse:v,sequentialAnimationMode:G,useMonospaceWidth:J,onFontHeightChange:Ue})})))})));module.exports=y;
//# sourceMappingURL=index.js.map
{
"name": "react-slot-counter",
"version": "2.3.0",
"version": "2.3.1",
"description": "Make Your Numbers Pop: Simple and Dynamic Counters for Your UI",

@@ -5,0 +5,0 @@ "author": "almond-bongbong",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc