{"version":3,"file":"Counter.Cy28tX8L.mjs","names":["useState","useRef","useEffect","_jsxs","_jsx","__esmMin","init_npm_react_18_3_1","ce","c","init_jsx_runtime","p","_e","de","addPropertyControls","init_framer_B3LLf74D","ControlType","motion","init_framer_motion_1EwlFBEG","Counter","props","start","end","speed","gapSize","prefixText","suffixText","loop","decimalSeparatorType","selectedFont","textColor","startOnViewport","incrementType","count","setCount","isVisible","setIsVisible","containerRef","observer","entries","entry","totalDifference","animationSteps","incrementPerStep","intervalDuration","currentStep","intervalId","newValue","formatNumber","number","CounterStyles","init_Counter"],"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":"A,gPAEG,SAAgBkB,EAAQC,EAAM,CAAC,GAAK,CAACC,QAAMC,MAAIC,QAAMC,UAAQC,aAAWC,aAAWC,OAAKC,uBAAqBC,eAAaC,YAAUC,kBAAgBC,iBAAeZ,EAAW,CAACa,EAAMC,GAAUjC,EAASoB,CAAK,EAAO,CAACc,EAAUC,GAAcnC,EAAS,EAAK,EAAQoC,EAAanC,EAAO,IAAI,EAAEC,MAAc,CAAC,IAAMmC,EAAS,IAAI,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