{"version":3,"file":"Counter.C1zKyT8C.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/fDGKOcQA3wQo6eT2dLGP/yb7Tm7K73g3zhsd2VoHn/Counter.js"],"sourcesContent":["// Text counter that animates numbers counting up when the component appears in viewport\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType,useInView}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Counter(props){const{targetNumber=1e3,duration=2,prefix=\"\",suffix=\"\",decimals=0,separator=true,textColor=\"#000000\",font,style}=props;const[count,setCount]=useState(0);const ref=useRef(null);const isInView=useInView(ref,{once:true});const hasAnimated=useRef(false);useEffect(()=>{if(!isInView||hasAnimated.current)return;hasAnimated.current=true;const startTime=Date.now();const endTime=startTime+duration*1e3;const animate=()=>{const now=Date.now();const progress=Math.min((now-startTime)/(duration*1e3),1);// Easing function for smooth animation\nconst easeOutQuart=1-Math.pow(1-progress,4);const currentCount=easeOutQuart*targetNumber;startTransition(()=>{setCount(currentCount);});if(progress<1){requestAnimationFrame(animate);}else{startTransition(()=>{setCount(targetNumber);});}};requestAnimationFrame(animate);},[isInView,targetNumber,duration]);const formatNumber=num=>{const fixed=num.toFixed(decimals);if(!separator)return fixed;const parts=fixed.split(\".\");parts[0]=parts[0].replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");return parts.join(\".\");};return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{...style,position:\"relative\",width:\"max-content\",minWidth:\"max-content\"},children:/*#__PURE__*/_jsxs(\"span\",{style:{color:textColor,...font,whiteSpace:\"nowrap\"},children:[prefix,formatNumber(count),suffix]})});}addPropertyControls(Counter,{targetNumber:{type:ControlType.Number,title:\"Target Number\",defaultValue:1e3,min:0,step:1},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,step:1},separator:{type:ControlType.Boolean,title:\"Separator\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"+\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Counter.map"],"mappings":"iPAIG,SAAwB,EAAQ,EAAM,CAAC,GAAK,CAAC,eAAa,IAAI,WAAS,EAAE,SAAO,GAAG,SAAO,GAAG,WAAS,EAAE,YAAU,GAAK,YAAU,UAAU,OAAK,SAAO,EAAW,CAAC,EAAM,GAAUA,EAAS,EAAE,CAAO,EAAIC,EAAO,KAAK,CAAO,EAAS,EAAU,EAAI,CAAC,KAAK,GAAK,CAAC,CAAO,EAAYA,EAAO,GAAM,CAAC,MAAc,CAAC,GAAG,CAAC,GAAU,EAAY,QAAQ,OAAO,EAAY,QAAQ,GAAK,IAAM,EAAU,KAAK,KAAK,CAAe,EAAU,EAAS,IAAI,IAAM,MAAY,CAAC,IAAM,EAAI,KAAK,KAAK,CAAO,EAAS,KAAK,KAAK,EAAI,IAAY,EAAS,KAAK,EAAE,CACne,GAA/B,GAAW,EAAE,IAAS,GAAmC,EAAa,MAAoB,CAAC,EAAS,EAAa,EAAG,CAAI,EAAS,EAAG,sBAAsB,EAAQ,CAAO,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