{"version":3,"file":"Counter.DhFtGa25.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/6gPNfYaIANe2GMCz1ndH/B8soOj57BSzT5QJslejD/Counter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";import{useInView,useSpring,useMotionValue,motion}from\"framer-motion\";/**\n * Animated Counter\n *\n * Counts from 0 to target number when the component enters the viewport.\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function Counter(props){const{target=100,duration=2,suffix=\"\",prefix=\"\",font,textColor=\"#000000\",align=\"center\"}=props;const ref=useRef(null);const isInView=useInView(ref,{once:true});const hasAnimated=useRef(false);const motionValue=useMotionValue(0);const springValue=useSpring(motionValue,{duration:duration*1e3,bounce:0});const[displayValue,setDisplayValue]=useState(0);useEffect(()=>{if(!isInView||hasAnimated.current)return;hasAnimated.current=true;motionValue.set(target);},[isInView,target,motionValue]);useEffect(()=>{const unsubscribe=springValue.on(\"change\",latest=>{startTransition(()=>setDisplayValue(Math.round(latest)));});return()=>unsubscribe();},[springValue]);const alignMap={left:\"flex-start\",center:\"center\",right:\"flex-end\"};return /*#__PURE__*/_jsx(motion.div,{ref:ref,style:{display:\"flex\",justifyContent:alignMap[align],alignItems:\"center\",width:\"100%\",height:\"100%\"},children:/*#__PURE__*/_jsxs(\"span\",{style:{fontSize:font?.fontSize??\"64px\",fontWeight:font?.fontWeight??700,fontFamily:font?.fontFamily,letterSpacing:font?.letterSpacing,lineHeight:font?.lineHeight??\"1em\",fontStyle:font?.fontStyle,color:textColor,whiteSpace:\"nowrap\"},children:[prefix,displayValue.toLocaleString(),suffix]})});}addPropertyControls(Counter,{target:{type:ControlType.Number,title:\"Target\",defaultValue:100,min:0,max:1e6,step:1,displayStepper:true},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"64px\",variant:\"Bold\",letterSpacing:\"-0.03em\",lineHeight:\"1em\"}},textColor:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},align:{type:ControlType.Enum,title:\"Align\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\",displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Counter.map"],"mappings":"4QAOG,SAAwB,EAAQ,EAAM,CAAC,GAAK,CAAC,SAAO,IAAI,WAAS,EAAE,SAAO,GAAG,SAAO,GAAG,OAAK,YAAU,UAAU,QAAM,UAAU,EAAY,EAAIA,EAAO,KAAK,CAAO,EAAS,EAAU,EAAI,CAAC,KAAK,GAAK,CAAC,CAAO,EAAYA,EAAO,GAAM,CAAO,EAAY,EAAe,EAAE,CAAO,EAAY,EAAU,EAAY,CAAC,SAAS,EAAS,IAAI,OAAO,EAAE,CAAC,CAAM,CAAC,EAAa,GAAiBC,EAAS,EAAE,CAAsX,OAArX,MAAc,CAAI,CAAC,GAAU,EAAY,UAAe,EAAY,QAAQ,GAAK,EAAY,IAAI,EAAO,GAAG,CAAC,EAAS,EAAO,EAAY,CAAC,CAAC,MAAc,CAAC,IAAM,EAAY,EAAY,GAAG,SAAS,GAAQ,CAAC,MAAoB,EAAgB,KAAK,MAAM,EAAO,CAAC,CAAC,EAAG,CAAC,UAAU,GAAa,EAAG,CAAC,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