{"version":3,"file":"Counter_code_.CemqBg0r.mjs","names":[],"sources":["https:/framerusercontent.com/modules/UvJwIGa05Sq3TgdMAbT0/i0TQ0Q2AceXyM97IePIb/Counter_code_.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:\"flex-start\",alignItems:\"flex-start\",width:\"100%\",height:\"auto\",lineHeight:1,padding:0,margin:0}};export function Counter(props){const{start,end,duration,speed,gapSize,prefixText,suffixText,prefixFont,suffixFont,prefixColor,suffixColor,loop,decimalSeparatorType,textSize,selectedFont,textColor,startOnViewport,restartOnViewport,incrementType}=props;const[count,setCount]=useState(start);const[isVisible,setIsVisible]=useState(!startOnViewport);const containerRef=useRef(null);useEffect(()=>{if(!startOnViewport)return;const observer=new IntersectionObserver(entries=>{const entry=entries[0];setIsVisible(entry.isIntersecting);},{threshold:.1});if(containerRef.current){observer.observe(containerRef.current);}return()=>{if(containerRef.current){observer.unobserve(containerRef.current);}};},[startOnViewport]);useEffect(()=>{if(restartOnViewport&&isVisible){setCount(start);}},[isVisible,restartOnViewport,start]);useEffect(()=>{if(!isVisible&&startOnViewport||start===end)return;let animationFrame;let startTime;const animationDuration=speed===\"custom\"?duration:Math.max(500,Math.min(3e3,Math.abs(end-start)*30));const animateCount=timestamp=>{if(!startTime)startTime=timestamp;const elapsed=timestamp-startTime;const progress=Math.min(elapsed/animationDuration,1);const easedProgress=1-Math.pow(1-progress,3);const currentCount=start+(end-start)*easedProgress;const nextCount=incrementType===\"integer\"?Math.floor(currentCount):parseFloat(currentCount.toFixed(2));setCount(nextCount);if(progress<1){animationFrame=requestAnimationFrame(animateCount);}else if(loop&&(!startOnViewport||isVisible)){setTimeout(()=>setCount(start),500);}};animationFrame=requestAnimationFrame(animateCount);return()=>{cancelAnimationFrame(animationFrame);};},[start,end,isVisible,loop,duration,speed,startOnViewport,incrementType]);const formatNumber=number=>{const absNumber=Math.abs(number);if(absNumber>=1e4){if(decimalSeparatorType===\"comma\"){return number.toLocaleString(\"en-US\");}else if(decimalSeparatorType===\"period\"){return number.toLocaleString(\"en-US\").replace(/,/g,\".\");}}return incrementType===\"integer\"?Math.floor(number).toString():number.toFixed(2);};return /*#__PURE__*/_jsxs(motion.div,{ref:containerRef,style:{...CounterStyles.container,gap:`${gapSize}px`,flexDirection:\"row\",fontSize:`${textSize}px`,fontFamily:selectedFont.fontFamily,fontWeight:selectedFont.fontWeight,color:textColor},children:[prefixText&&/*#__PURE__*/_jsx(\"span\",{style:{fontFamily:prefixFont.fontFamily,fontWeight:prefixFont.fontWeight,color:prefixColor,whiteSpace:\"nowrap\",margin:0,padding:0,lineHeight:1},children:prefixText}),/*#__PURE__*/_jsx(\"span\",{style:{whiteSpace:\"nowrap\",margin:0,padding:0,lineHeight:1},children:formatNumber(count)}),suffixText&&/*#__PURE__*/_jsx(\"span\",{style:{fontFamily:suffixFont.fontFamily,fontWeight:suffixFont.fontWeight,color:suffixColor,whiteSpace:\"nowrap\",margin:0,padding:0,lineHeight:1},children:suffixText})]});}Counter.defaultProps={start:0,end:100,speed:\"auto\",duration:2e3,prefixText:\"\",suffixText:\"\",loop:false,decimalSeparatorType:\"comma\",textSize:36,selectedFont:{fontFamily:\"Inter\",fontWeight:500,systemFont:true},textColor:\"#D3D3D3\",startOnViewport:false,incrementType:\"integer\",restartOnViewport:false,gapSize:0};addPropertyControls(Counter,{start:{type:ControlType.Number,title:\"Start Number\",defaultValue:0,displayStepper:true},end:{type:ControlType.Number,title:\"End Number\",defaultValue:100,displayStepper:true},speed:{type:ControlType.Enum,title:\"Speed Mode\",defaultValue:\"auto\",options:[\"auto\",\"custom\"],optionTitles:[\"Auto\",\"Custom Duration\"]},duration:{type:ControlType.Number,title:\"Duration (ms)\",defaultValue:2e3,min:100,max:1e4,step:100,hidden:props=>props.speed!==\"custom\"},loop:{type:ControlType.Boolean,title:\"Loop Animation\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},startOnViewport:{type:ControlType.Boolean,title:\"Viewport\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},restartOnViewport:{type:ControlType.Boolean,title:\"Replay\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},incrementType:{type:ControlType.Enum,title:\"Number Type\",defaultValue:\"integer\",options:[\"integer\",\"decimal\"],optionTitles:[\"Integer\",\"Decimal\"]},decimalSeparatorType:{type:ControlType.Enum,title:\"Separator (for ≥10,000)\",defaultValue:\"comma\",options:[\"comma\",\"period\",\"none\"],optionTitles:[\"Comma (10,000)\",\"Period (10.000)\",\"None (10000)\"]},selectedFont:{title:\"Font\",type:ControlType.Font,defaultValue:{fontFamily:\"Inter\",fontWeight:500,systemFont:true}},textSize:{title:\"Font Size\",type:ControlType.Number,min:8,max:240,step:1},textColor:{type:ControlType.Color,title:\"Text Color\"},prefixText:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\"},prefixFont:{title:\"Prefix Font\",type:ControlType.Font,defaultValue:{fontFamily:\"Inter\",fontWeight:500,systemFont:true}},prefixColor:{type:ControlType.Color,title:\"Prefix Color\"},suffixText:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\"},suffixFont:{title:\"Suffix Font\",type:ControlType.Font,defaultValue:{fontFamily:\"Inter\",fontWeight:500,systemFont:true}},suffixColor:{type:ControlType.Color,title:\"Suffix Color\"},gapSize:{type:ControlType.Number,title:\"Gap Size\",defaultValue:0,min:0,max:100,step:1}});\nexport const __FramerMetadata__ = {\"exports\":{\"Counter\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Counter_code_.map"],"mappings":"yWAA4V,SAAgB,EAAQ,EAAM,CAAC,GAAK,CAAC,QAAM,MAAI,WAAS,QAAM,UAAQ,aAAW,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