{"version":3,"file":"NumberCounter.xDiibtpN.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/0wLUxAWo95o4Xh3sjvIh/GeZfESt1LSZPCtEmyw0u/NumberCounter.js"],"sourcesContent":["// Number counter component with customizable prefix, suffix, separator, and animation\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{motion,useInView}from\"framer-motion\";/**\n * Number Counter\n *\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 60\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function NumberCounter(props){const{start=0,end=100,separator=\"comma\",incrementType=\"integer\",prefix=\"\",prefixFont,prefixColor=\"#000000\",suffix=\"\",suffixFont,suffixColor=\"#000000\",font,fontColor=\"#000000\",gapSize=0,speed=120,loopAnimation=false,replay=false}=props;const isStatic=useIsStaticRenderer();const ref=useRef(null);const isInView=useInView(ref,{once:!loopAnimation&&!replay});const[displayValue,setDisplayValue]=useState(start);const rafRef=useRef(null);useEffect(()=>{if(isStatic){setDisplayValue(end);return;}if(rafRef.current)cancelAnimationFrame(rafRef.current);if(!isInView){if(loopAnimation||replay)setDisplayValue(start);return;}// speed range 10–300, mapped to duration 3000ms–100ms\nconst duration=Math.max(100,3200-speed*10);const startTime=performance.now();const range=end-start;const tick=now=>{const elapsed=now-startTime;const progress=Math.min(elapsed/duration,1);const current=start+range*progress;startTransition(()=>setDisplayValue(current));if(progress<1){rafRef.current=requestAnimationFrame(tick);}else{setDisplayValue(end);}};rafRef.current=requestAnimationFrame(tick);return()=>{if(rafRef.current)cancelAnimationFrame(rafRef.current);};},[isInView,end,start,speed,loopAnimation,replay,isStatic]);const formatNumber=value=>{let integerPart;let decimalPart;if(incrementType===\"integer\"){integerPart=Math.floor(value).toString();decimalPart=undefined;}else{// Detect decimal places from end value\nconst endStr=end.toString();const endDecimalPlaces=endStr.includes(\".\")?endStr.split(\".\")[1].length:0;const numStr=value.toFixed(endDecimalPlaces);[integerPart,decimalPart]=numStr.split(\".\");}// Choose separator characters for thousands and decimal parts\nlet thousandSep=\"\";let decimalSep=\".\";switch(separator){case\"comma\":thousandSep=\",\";decimalSep=\".\";break;case\"dot\":// European style: 1.234,56\nthousandSep=\".\";decimalSep=\",\";break;case\"space\":thousandSep=\" \";decimalSep=\".\";break;case\"none\":default:thousandSep=\"\";decimalSep=\".\";break;}const formattedInteger=thousandSep?integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g,thousandSep):integerPart;return decimalPart!==undefined?`${formattedInteger}${decimalSep}${decimalPart}`:formattedInteger;};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,position:\"relative\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",gap:`${gapSize}px`,...!isFixedWidth&&{width:\"max-content\"},...!isFixedHeight&&{height:\"max-content\"}},children:[prefix&&/*#__PURE__*/_jsx(\"span\",{style:{...prefixFont,color:prefixColor},children:prefix}),/*#__PURE__*/_jsx(motion.span,{style:{...font,color:fontColor},children:formatNumber(displayValue)}),suffix&&/*#__PURE__*/_jsx(\"span\",{style:{...suffixFont,color:suffixColor},children:suffix})]});}addPropertyControls(NumberCounter,{replay:{type:ControlType.Boolean,title:\"Replay\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"40px\",fontWeight:\"700\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},fontColor:{type:ControlType.Color,title:\"Font Color\",defaultValue:\"#000000\"},start:{type:ControlType.Number,title:\"Start\",defaultValue:0,step:.01},end:{type:ControlType.Number,title:\"End\",defaultValue:100,step:.01},separator:{type:ControlType.Enum,title:\"Separator\",options:[\"comma\",\"dot\",\"space\",\"none\"],optionTitles:[\"Comma\",\"Dot\",\"Space\",\"None\"],defaultValue:\"comma\"},incrementType:{type:ControlType.Enum,title:\"Increment Type\",options:[\"integer\",\"decimal\"],optionTitles:[\"Integer\",\"Decimal\"],defaultValue:\"integer\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\"},prefixFont:{type:ControlType.Font,title:\"Prefix Font\",defaultValue:{fontSize:\"40px\",fontWeight:\"700\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\",hidden:({prefix})=>!prefix||prefix.length===0},prefixColor:{type:ControlType.Color,title:\"Prefix Color\",defaultValue:\"#000000\",hidden:({prefix})=>!prefix||prefix.length===0},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\"},suffixFont:{type:ControlType.Font,title:\"Suffix Font\",defaultValue:{fontSize:\"40px\",fontWeight:\"700\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\",hidden:({suffix})=>!suffix||suffix.length===0},suffixColor:{type:ControlType.Color,title:\"Suffix Color\",defaultValue:\"#000000\",hidden:({suffix})=>!suffix||suffix.length===0},gapSize:{type:ControlType.Number,title:\"Gap Size\",defaultValue:0,min:0,max:50,step:1,unit:\"px\"},speed:{type:ControlType.Number,title:\"Speed (%)\",defaultValue:120,min:10,max:300,step:10},loopAnimation:{type:ControlType.Boolean,title:\"Loop Animation\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumberCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\",\"framerIntrinsicWidth\":\"200\",\"framerIntrinsicHeight\":\"60\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberCounter.map"],"mappings":"uQASG,S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