{"version":3,"file":"NumberCounter.DBBHukZR.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/Wb2vlf4v8vQgO5atvYCz/h6GnFe7mJAJXXXywcSlY/NumberCounter.js"],"sourcesContent":["// Number counter that counts from a start number to an end number with decimal support\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useInView}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function NumberCounter(props){const{startNumber=0,endNumber=100,duration=2,decimals=0,prefix=\"\",suffix=\"\",separator=false,autoStart=true,textColor=\"#000000\",font,style}=props;const[currentNumber,setCurrentNumber]=useState(startNumber);const animationRef=useRef(null);const startTimeRef=useRef(null);const containerRef=useRef(null);const isInView=useInView(containerRef,{once:true});useEffect(()=>{if(!autoStart||!isInView){startTransition(()=>setCurrentNumber(startNumber));return;}const animate=timestamp=>{if(!startTimeRef.current){startTimeRef.current=timestamp;}const elapsed=timestamp-startTimeRef.current;const progress=Math.min(elapsed/(duration*1e3),1);// Easing function for smooth animation\nconst easeOutQuart=1-Math.pow(1-progress,4);const current=startNumber+(endNumber-startNumber)*easeOutQuart;startTransition(()=>setCurrentNumber(current));if(progress<1){animationRef.current=requestAnimationFrame(animate);}};animationRef.current=requestAnimationFrame(animate);return()=>{if(animationRef.current){cancelAnimationFrame(animationRef.current);}startTimeRef.current=null;};},[startNumber,endNumber,duration,autoStart,isInView]);const formatNumber=num=>{const fixed=num.toFixed(decimals);if(separator){const parts=fixed.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");return parts.join(\",\");}return fixed.replace(\".\",\",\");};const displayValue=`${prefix}${formatNumber(currentNumber)}${suffix}`;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,position:\"relative\",display:\"inline-block\",width:\"fit-content\"},children:/*#__PURE__*/_jsx(\"span\",{style:{color:textColor,...font},children:displayValue})});}addPropertyControls(NumberCounter,{startNumber:{type:ControlType.Number,title:\"Start Number\",defaultValue:0,step:.1,displayStepper:true},endNumber:{type:ControlType.Number,title:\"End Number\",defaultValue:100,step:.1,displayStepper:true},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,step:1,displayStepper:true},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%\"},separator:{type:ControlType.Boolean,title:\"Separator\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},autoStart:{type:ControlType.Boolean,title:\"Auto Start\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumberCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberCounter.map"],"mappings":"gPAIG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,cAAY,EAAE,YAAU,IAAI,WAAS,EAAE,WAAS,EAAE,SAAO,GAAG,SAAO,GAAG,YAAU,GAAM,YAAU,GAAK,YAAU,UAAU,OAAK,SAAO,EAAW,CAAC,EAAc,GAAkBA,EAAS,EAAY,CAAO,EAAaC,EAAO,KAAK,CAAO,EAAaA,EAAO,KAAK,CAAO,EAAaA,EAAO,KAAK,CAAO,EAAS,EA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