{"version":3,"file":"NumberCounter.CyKsojLO.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/r4OfFSnklx0KGPmkWZqh/fHWT66UWDFEj8dVUh0tZ/NumberCounter.js"],"sourcesContent":["import{jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";import{motion,useAnimation}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";import{containerStyles,fontStack,localeOptions}from\"https://framer.com/m/framer/default-utils.js@^0.45.0\";export default function TextCounter(props){const{fontFamily,fontSize,fontWeight,color,font,targetValue,duration,locale,prefix,showPrefix}=props;const[count,setCount]=useState(0);const controls=useAnimation();const maxCount=targetValue;const slowDownStart=maxCount-10;const totalDuration=duration*1e3;const ref=useRef(null);const[isVisible,setIsVisible]=useState(false);const calculateIntervalTime=currentCount=>{const slowDownStart=targetValue-10;if(currentCount>=slowDownStart){const slowProgress=(currentCount-slowDownStart+1)/(targetValue-slowDownStart);return slowProgress*slowProgress*duration*1e3/(targetValue-slowDownStart);}else{return duration*1e3/(targetValue-(targetValue-slowDownStart));}};useEffect(()=>{const observer=new IntersectionObserver(([entry])=>setIsVisible(entry.isIntersecting),{root:null,rootMargin:\"0px\",threshold:.1});if(ref.current)observer.observe(ref.current);return()=>{if(ref.current)observer.unobserve(ref.current);};},[ref]);useEffect(()=>{if(isVisible&&count<props.targetValue){const intervalTime=calculateIntervalTime(count);const timer=setTimeout(()=>setCount(count+1),intervalTime);return()=>clearTimeout(timer);}},[count,isVisible,props.targetValue]);useEffect(()=>{controls.start({opacity:1,transition:{duration:.5}});},[controls]);const componentStyle={...containerStyles,color,fontFamily:fontStack,fontWeight:500,fontSize:16,...font};return /*#__PURE__*/_jsxs(motion.div,{ref:ref,style:componentStyle,animate:controls,children:[showPrefix&&prefix,count.toLocaleString(locale)]});}TextCounter.defaultProps={duration:5,targetValue:1e3,color:\"#FFFFFF\",showPrefix:false,prefix:\"+\",locale:\"en\"};TextCounter.displayName=\"NumberCounter\";addPropertyControls(TextCounter,{targetValue:{title:\"Target\",type:ControlType.Number,displayStepper:true,defaultValue:TextCounter.defaultProps.targetValue},duration:{title:\"Duration\",type:ControlType.Number,displayStepper:true,step:.5,defaultValue:TextCounter.defaultProps.duration,unit:\"s\"},showPrefix:{title:\"Prefix\",type:ControlType.Boolean,enabledTitle:\"Show\",disabledTitle:\"Hide\",defaultValue:TextCounter.defaultProps.showPrefix},prefix:{title:\"\",type:ControlType.String,defaultValue:TextCounter.defaultProps.prefix,hidden:props=>props.showPrefix!==true},color:{title:\"Color\",type:ControlType.Color,defaultValue:TextCounter.defaultProps.color},font:{// @ts-expect-error – Internal\ntype:ControlType.Font,controls:\"extended\"},locale:{title:\"Locale\",type:ControlType.Enum,options:Object.keys(localeOptions).sort(),optionTitles:Object.keys(localeOptions).sort().map(key=>localeOptions[key]),defaultValue:TextCounter.defaultProps.locale}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TextCounter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberCounter.map"],"mappings":"+TAAuS,SAAwB,EAAY,EAAM,CAAC,GAAK,CAAC,aAAW,WAAS,aAAW,QAAM,OAAK,cAAY,WAAS,SAAO,SAAO,cAAY,EAAW,CAAC,EAAM,GAAUA,EAAS,EAAE,CAAO,EAAS,GAAc,CAAgB,EAAyC,GAAuB,EAAS,IAAI,IAAM,EAAIC,EAAO,KAAK,CAAM,CAAC,EAAU,GAAcD,EAAS,GAAM,CAAO,EAAsB,GAAc,CAAC,IAAM,EAAc,EAAY,GAAG,GAAG,GAAc,EAAc,CAAC,IAAM,GAAc,EAAa,EAAc,IAAI,EAAY,GAAe,OAAO,EAAa,EAAa,EAAS,KAAK,EAAY,QAAqB,OAAO,EAAS,KAAK,GAAa,EAAY,KAAmB,MAAc,CAAC,IAAM,EAAS,IAAI,sBAAsB,CAAC,KAAS,E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