{"version":3,"file":"Counter.Mq6CDNHb.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/SpwMvrtZhALVpsAMXbLZ/yujBQBrEzv7iUylVhaFJ/Counter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useState,useEffect,useRef}from\"react\";import{motion}from\"framer-motion\";import{addPropertyControls,ControlType}from\"framer\";const CounterStyles={container:{display:\"flex\",justifyContent:\"center\",alignItems:\"center\"}};/**\n * @framerDisableUnlink\n */export function Counter(props){const{start,end,speed,gapSize,prefixText,suffixText,loop,decimalSeparatorType,selectedFont,textColor,startOnViewport,incrementType}=props;const[count,setCount]=useState(start);const[isVisible,setIsVisible]=useState(false);const containerRef=useRef(null);useEffect(()=>{const observer=new IntersectionObserver(entries=>{const entry=entries[0];setIsVisible(entry.isIntersecting);});if(containerRef.current){observer.observe(containerRef.current);}return()=>{if(containerRef.current){observer.unobserve(containerRef.current);}};},[]);useEffect(()=>{if(isVisible||!startOnViewport&&start!==end){const totalDifference=Math.abs(end-start);// Dynamic step calculation with maximum of 1000 steps\nlet animationSteps;if(totalDifference<=100){animationSteps=totalDifference// For small numbers, use 1 step per unit\n;}else if(totalDifference<=1e3){animationSteps=Math.ceil(totalDifference/2)// For medium numbers\n;}else if(totalDifference<=1e4){animationSteps=Math.ceil(totalDifference/10)// Larger numbers\n;}else{animationSteps=1e3// Cap at 1000 steps for very large numbers\n;}// Ensure minimum steps for smooth animation\nanimationSteps=Math.max(animationSteps,20);// Ensure maximum steps\nanimationSteps=Math.min(animationSteps,1e3);const incrementPerStep=totalDifference/animationSteps;const intervalDuration=speed*1e3/animationSteps;let currentStep=0;const updateCount=()=>{currentStep++;if(currentStep>=animationSteps){setCount(end)// Ensure we end exactly at the target\n;return;}const newValue=start+incrementPerStep*currentStep*(end>start?1:-1);// Handle decimal vs integer display\nif(incrementType===\"integer\"){setCount(Math.round(newValue));}else{setCount(parseFloat(newValue.toFixed(1)));}};const intervalId=setInterval(updateCount,intervalDuration);return()=>{clearInterval(intervalId);};}else if(startOnViewport&&isVisible){setCount(start);}},[start,end,loop,isVisible,speed,startOnViewport,incrementType]);const formatNumber=number=>{if(decimalSeparatorType===\"comma\"){return number.toLocaleString(\"en-US\");}else if(decimalSeparatorType===\"period\"){return number.toLocaleString(\"en-US\").replace(/,/g,\".\");}else{return number.toFixed(incrementType===\"integer\"?0:1);}};return /*#__PURE__*/_jsxs(motion.div,{ref:containerRef,style:{...CounterStyles.container,gap:`${gapSize}px`,flexDirection:\"row\",alignItems:\"center\",fontSize:selectedFont.fontSize,fontFamily:selectedFont.fontFamily,fontWeight:selectedFont.fontWeight,lineHeight:selectedFont.lineHeight,color:textColor},children:[/*#__PURE__*/_jsx(\"span\",{style:{fontSize:selectedFont.fontSize,fontFamily:selectedFont.fontFamily,fontWeight:selectedFont.fontWeight,lineHeight:selectedFont.lineHeight,color:textColor},children:prefixText}),/*#__PURE__*/_jsx(\"span\",{children:formatNumber(count)}),/*#__PURE__*/_jsx(\"span\",{style:{fontSize:selectedFont.fontSize,fontFamily:selectedFont.fontFamily,fontWeight:selectedFont.fontWeight,lineHeight:selectedFont.lineHeight,color:textColor},children:suffixText})]});}Counter.defaultProps={start:0,end:100,speed:2,prefixText:\"\",suffixText:\"\",loop:false,decimalSeparatorType:\"comma\",selectedFont:{fontFamily:\"Inter\",fontWeight:500,systemFont:true},textColor:\"#D3D3D3\",startOnViewport:false,incrementType:\"integer\"};addPropertyControls(Counter,{startOnViewport:{type:ControlType.Boolean,title:\"Viewport\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},selectedFont:{title:\"Font\",type:ControlType.Font,controls:\"extended\"},textColor:{type:ControlType.Color,title:\"Font Color\"},start:{type:ControlType.Number,title:\"Start Number\",defaultValue:0,displayStepper:true},end:{type:ControlType.Number,title:\"End Number\",defaultValue:10,displayStepper:true},decimalSeparatorType:{type:ControlType.Enum,title:\"Separator\",defaultValue:\"comma\",options:[\"comma\",\"period\",\"none\"],optionTitles:[\"Comma (1,000)\",\"Decimal (1.000)\",\"None\"]},incrementType:{type:ControlType.Enum,title:\"Increment Type\",defaultValue:\"integer\",options:[\"integer\",\"decimal\"],optionTitles:[\"Integer\",\"Decimal\"]},prefixText:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\"},suffixText:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\"},gapSize:{type:ControlType.Number,title:\"Gap Size\",defaultValue:4,min:0,max:100,step:4},speed:{type:ControlType.Number,title:\"Duration (seconds)\",defaultValue:2,min:.1,max:10,step:.1},loop:{type:ControlType.Boolean,title:\"Loop Animation\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"Counter\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerDisableUnlink\":\"\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Counter.map"],"mappings":"gPAEG,SAAgB,EAAQ,EAAM,CAAC,GAAK,CAAC,QAAM,MAAI,QAAM,UAAQ,aAAW,aAAW,OAAK,uBAAqB,eAAa,YAAU,kBAAgB,iBAAe,EAAW,CAAC,EAAM,GAAUA,EAAS,CAAK,EAAO,CAAC,EAAU,GAAcA,EAAS,EAAK,EAAQ,EAAaC,EAAO,IAAI,EAAE,MAAc,CAAC,IAAM,EAAS,IAAI,qBAAqB,GAAS,CAAC,IAAM,EAAM,EAAQ,GAAG,EAAa,EAAM,cAAc,CAAE,CAAC,EAAmE,OAA9D,EAAa,SAAS,EAAS,QAAQ,EAAa,OAAO,MAAa,CAAI,EAAa,SAAS,EAAS,UAAU,EAAa,OAAO,CAAG,CAAE,EAAE,CAAC,CAAC,EAAE,MAAc,CAAC,GAAG,GAAW,CAAC,GAAiB,IAAQ,EAAI,CAAC,IAAM,EAAgB,KAAK,IAAI,EAAI,CAAK,EACrpB,EAAe,AAGZ,EAHe,GAAiB,IA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