{"version":3,"file":"AnimatedCounter.DoaZvwpS.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/E6bIaKAzS9YJ7nsgRnuA/v5px7rbwBEdAjibiJqzg/AnimatedCounter.js"],"sourcesContent":["// AnimatedCounter component that animates from one number to another when in view, with prefix and suffix support\nimport{jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useInView}from\"framer-motion\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function AnimatedCounter(props){const{startValue,endValue,duration,prefix,suffix,textColor,backgroundColor,font,textAlign,width,height,paddingTop,paddingRight,paddingBottom,paddingLeft}=props;const[currentValue,setCurrentValue]=useState(startValue);const ref=useRef(null);const isInView=useInView(ref,{once:true});useEffect(()=>{if(isInView){const difference=endValue-startValue;const increment=difference/(duration*60)// 60fps\n;let current=startValue;const timer=setInterval(()=>{current+=increment;if(increment>0&&current>=endValue||increment<0&&current<=endValue){current=endValue;clearInterval(timer);}startTransition(()=>{setCurrentValue(Math.round(current));});},1e3/60);return()=>clearInterval(timer);}},[isInView,startValue,endValue,duration]);const isFixedWidth=props?.style&&props.style.width===\"100%\";const isFixedHeight=props?.style&&props.style.height===\"100%\";return /*#__PURE__*/_jsxs(\"div\",{ref:ref,style:{...props.style,width:isFixedWidth?\"100%\":`${width}px`,height:isFixedHeight?\"100%\":`${height}px`,backgroundColor,color:textColor,paddingTop:`${paddingTop}px`,paddingRight:`${paddingRight}px`,paddingBottom:`${paddingBottom}px`,paddingLeft:`${paddingLeft}px`,borderRadius:8,display:\"flex\",alignItems:\"center\",justifyContent:textAlign===\"left\"?\"flex-start\":textAlign===\"right\"?\"flex-end\":\"center\",textAlign,...font},children:[prefix,currentValue.toLocaleString(),suffix]});}addPropertyControls(AnimatedCounter,{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:.5,max:10,step:.1,unit:\"s\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%\"},textAlign:{type:ControlType.Enum,title:\"Text Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\",displaySegmentedControl:true},width:{type:ControlType.Number,title:\"Width\",defaultValue:200,min:50,max:800,step:10,unit:\"px\"},height:{type:ControlType.Number,title:\"Height\",defaultValue:80,min:30,max:300,step:10,unit:\"px\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"32px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},paddingTop:{type:ControlType.Number,title:\"Padding Top\",defaultValue:8,min:0,max:50,step:1,unit:\"px\"},paddingRight:{type:ControlType.Number,title:\"Padding Right\",defaultValue:16,min:0,max:50,step:1,unit:\"px\"},paddingBottom:{type:ControlType.Number,title:\"Padding Bottom\",defaultValue:8,min:0,max:50,step:1,unit:\"px\"},paddingLeft:{type:ControlType.Number,title:\"Padding Left\",defaultValue:16,min:0,max:50,step:1,unit:\"px\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AnimatedCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AnimatedCounter.map"],"mappings":"4WAIG,SAAwB,EAAgB,EAAM,CAAC,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