{"version":3,"file":"NumberCounter.BFSRBo1B.mjs","names":["useState","useRef","__esmMin","te","_e","de","c","init_jsx_runtime","init_npm_react_18_3_1","ce","useInView","init_framer_BEr93sCn","addPropertyControls","ControlType","NumberCounter","props","count","setCount","startValue","hasAnimated","setHasAnimated","ref","isInView","animateOnce","animationRef","startTime","delay","endTime","duration","range","endValue","animate","now","progress","easeOutQuad","currentValue","displayValue","prefix","fixed","num","decimals","separator","parts","suffix","textColor","font","init_NumberCounter"],"sources":["https:/framerusercontent.com/modules/1VZ7xWwqokuPcr46eo8i/VXm3GrwuiQljj04gFYjG/NumberCounter.js"],"sourcesContent":["// Number counter component with animation, formatting options, and customizable appearance\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useInView}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function NumberCounter(props){const{startValue=0,endValue=100,duration=2,delay=0,prefix=\"\",suffix=\"\",separator=true,decimals=0,animateOnce=true,textColor=\"#000000\",backgroundColor=\"#FFFFFF\",font,padding=\"16px\",borderRadius=\"8px\"}=props;const[count,setCount]=useState(startValue);const[hasAnimated,setHasAnimated]=useState(false);const ref=useRef(null);const isInView=useInView(ref,{once:animateOnce,amount:.5});const animationRef=useRef(null);useEffect(()=>{if(!isInView||animateOnce&&hasAnimated){return;}const startTime=Date.now()+delay*1e3;const endTime=startTime+duration*1e3;const range=endValue-startValue;const animate=()=>{const now=Date.now();if(now<startTime){animationRef.current=requestAnimationFrame(animate);return;}if(now>=endTime){startTransition(()=>{setCount(endValue);setHasAnimated(true);});return;}const progress=(now-startTime)/(duration*1e3);const easeOutQuad=1-(1-progress)*(1-progress);const currentValue=startValue+range*easeOutQuad;startTransition(()=>{setCount(currentValue);});animationRef.current=requestAnimationFrame(animate);};animationRef.current=requestAnimationFrame(animate);return()=>{if(animationRef.current!==null){cancelAnimationFrame(animationRef.current);}};},[isInView,startValue,endValue,duration,delay,animateOnce,hasAnimated]);const formatNumber=num=>{const fixed=num.toFixed(decimals);if(!separator)return fixed;const parts=fixed.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");return parts.join(\".\");};const displayValue=`${prefix}${formatNumber(count)}${suffix}`;return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...props.style,position:\"relative\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",backgroundColor,color:textColor,padding,borderRadius,minWidth:\"max-content\",...font},children:/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"nowrap\"},children:displayValue})});}addPropertyControls(NumberCounter,{startValue:{type:ControlType.Number,title:\"Start Value\",defaultValue:0,step:1},endValue:{type:ControlType.Number,title:\"End Value\",defaultValue:100,step:1},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},delay:{type:ControlType.Number,title:\"Delay\",defaultValue:0,min:0,max:5,step:.1,unit:\"s\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%\"},separator:{type:ControlType.Boolean,title:\"Separator\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,step:1,displayStepper:true},animateOnce:{type:ControlType.Boolean,title:\"Animate Once\",defaultValue:true,enabledTitle:\"Once\",disabledTitle:\"Loop\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},padding:{type:ControlType.Padding,title:\"Padding\",defaultValue:\"16px\"},borderRadius:{type:ControlType.BorderRadius,title:\"Radius\",defaultValue:\"8px\"}});\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":"A,yOAIG,SAAwBc,EAAc,EAAM,CAAC,GAAK,CAAC,aAAW,EAAE,WAAS,IAAI,WAAS,EAAE,QAAM,EAAE,SAAO,GAAG,SAAO,GAAG,YAAU,GAAK,WAAS,EAAE,cAAY,GAAK,YAAU,UAAU,kBAAgB,UAAU,OAAK,UAAQ,OAAO,eAAa,OAAOC,EAAW,CAACC,EAAMC,GAAUjB,EAASkB,CAAU,EAAO,CAACC,EAAYC,GAAgBpB,EAAS,EAAK,EAAQqB,EAAIpB,EAAO,IAAI,EAAQqB,EAASZ,EAAUW,EAAI,CAAC,KAAKE,EAAY,OAAO,EAAE,CAAC,EAAQC,EAAavB,EAAO,IAAI,EAAEQ,MAAc,CAAC,GAAG,CAACa,GAAUC,GAAaJ,EAAa,OAAQ,IAAMM,EAAU,KAAK,IAAI,EAAEC,EAAM,IAAUC,EAAQF,EAAUG,EAAS,IAAUC,EAAMC,EAASZ,EAAiBa,MAAY,CAAC,IAAMC,EAAI,KAAK,IAAI,EAAE,GAAGA,EAAIP,EAAU,CAAC,EAAa,QAAQ,sBAAsBM,CAAO,EAAE,MAAO,CAAC,GAAGC,GAAKL,EAAQ,CAACxB,MAAoB,CAACc,EAASa,CAAQ,EAAEV,EAAe,EAAI,CAAE,CAAC,EAAE,MAAO,CAAC,IAAMa,GAAUD,EAAIP,IAAYG,EAAS,KAAWM,EAAY,GAAG,EAAED,IAAW,EAAEA,GAAgBE,EAAajB,EAAWW,EAAMK,EAAY/B,MAAoB,CAACc,EAASkB,CAAY,CAAE,CAAC,EAAE,EAAa,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