{"version":3,"file":"Counter.Ce9tIbOb.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/oXZE2cwyxfviMW5J1TjC/feYzRF5i0s3TwTP6FlcM/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\";/**\n * @framerDisableUnlink\n */export default function Counter({start=0,end=100,speed=100,gapSize=4,prefix={text:\"\",font:{fontSize:\"36px\",variant:\"Medium\",letterSpacing:\"-0.07em\",lineHeight:\"1em\"},color:\"#D3D3D3\"},suffix={text:\"\",font:{fontSize:\"36px\",variant:\"Medium\",letterSpacing:\"-0.07em\",lineHeight:\"1em\"},color:\"#D3D3D3\"},loop=false,decimalSeparatorType=\"comma\",selectedFont={fontFamily:\"Inter\",fontWeight:500,fontSize:\"36px\",letterSpacing:\"-0.07em\",lineHeight:\"1em\",variant:\"Medium\"},textColor=\"#D3D3D3\",playback={startOnViewport:false,restartOnViewport:false},incrementType=\"integer\"}){const[count,setCount]=useState(start);const[isVisible,setIsVisible]=useState(false);const containerRef=useRef(null);useEffect(()=>{const observer=new IntersectionObserver(([entry])=>{setIsVisible(entry.isIntersecting);});if(containerRef.current)observer.observe(containerRef.current);return()=>observer.disconnect();},[]);useEffect(()=>{if(!(isVisible||!playback.startOnViewport)||start===end)return;const increment=incrementType===\"integer\"?1:.1;const intervalId=setInterval(()=>{setCount(prev=>prev+increment>=end?end:parseFloat((prev+increment).toFixed(2)));},speed);return()=>clearInterval(intervalId);},[isVisible,start,end,speed,playback.startOnViewport,incrementType]);useEffect(()=>{if(playback.restartOnViewport&&isVisible)setCount(start);},[isVisible,playback.restartOnViewport,start]);const formatNumber=number=>{if(decimalSeparatorType===\"comma\")return number.toLocaleString(\"en-US\");if(decimalSeparatorType===\"period\")return number.toLocaleString(\"en-US\").replace(/,/g,\".\");return number.toFixed(incrementType===\"integer\"?0:1);};return /*#__PURE__*/_jsxs(motion.div,{ref:containerRef,style:{display:\"flex\",gap:`${gapSize}px`,alignItems:\"center\",...selectedFont,color:textColor},children:[prefix.text&&/*#__PURE__*/_jsx(\"span\",{style:{...prefix.font,color:prefix.color},children:prefix.text}),/*#__PURE__*/_jsx(\"span\",{children:formatNumber(count)}),suffix.text&&/*#__PURE__*/_jsx(\"span\",{style:{...suffix.font,color:suffix.color},children:suffix.text})]});}addPropertyControls(Counter,{playback:{type:ControlType.Object,title:\"Playback\",controls:{startOnViewport:{type:ControlType.Boolean,title:\"Play\",defaultValue:false,enabledTitle:\"On View\",disabledTitle:\"Appear\",description:\"Start counting when visible\"},restartOnViewport:{type:ControlType.Boolean,title:\"Replay\",defaultValue:false}}},selectedFont:{title:\"Font\",type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"36px\",variant:\"Medium\",letterSpacing:\"-0.07em\",lineHeight:\"1em\"}},textColor:{type:ControlType.Color,title:\"Font Color\"},start:{type:ControlType.Number,title:\"Start Number\",defaultValue:0},end:{type:ControlType.Number,title:\"End Number\",defaultValue:10},decimalSeparatorType:{type:ControlType.Enum,title:\"Separator\",defaultValue:\"comma\",options:[\"comma\",\"period\",\"none\"]},incrementType:{type:ControlType.Enum,title:\"Increment Type\",defaultValue:\"integer\",options:[\"integer\",\"decimal\"]},prefix:{type:ControlType.Object,title:\"Prefix\",controls:{text:{type:ControlType.String,title:\"Text\",defaultValue:\"\"},font:{title:\"Font\",type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"36px\",variant:\"Medium\",letterSpacing:\"-0.07em\",lineHeight:\"1em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#D3D3D3\"}}},suffix:{type:ControlType.Object,title:\"Suffix\",controls:{text:{type:ControlType.String,title:\"Text\",defaultValue:\"\"},font:{title:\"Font\",type:ControlType.Font,controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"36px\",variant:\"Medium\",letterSpacing:\"-0.07em\",lineHeight:\"1em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#D3D3D3\"}}},gapSize:{type:ControlType.Number,title:\"Gap Size\",defaultValue:4,min:0,max:100},speed:{type:ControlType.Number,title:\"Speed (ms)\",defaultValue:100,min:0,max:2e3},loop:{type:ControlType.Boolean,title:\"Loop Animation\",defaultValue:false,description:\"More resources at [Velox Themes](https://veloxthemes.com)\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Counter.map"],"mappings":"gPAEG,SAAwB,EAAQ,CAAC,QAAM,EAAE,MAAI,IAAI,QAAM,IAAI,UAAQ,EAAE,SAAO,CAAC,KAAK,GAAG,KAAK,CAAC,SAAS,OAAO,QAAQ,SAAS,cAAc,UAAU,WAAW,MAAM,CAAC,MAAM,UAAU,CAAC,SAAO,CAAC,KAAK,GAAG,KAAK,CAAC,SAAS,OAAO,QAAQ,SAAS,cAAc,UAAU,WAAW,MAAM,CAAC,MAAM,UAAU,CAAC,OAAK,GAAM,uBAAqB,QAAQ,eAAa,CAAC,WAAW,QAAQ,WAAW,IAAI,SAAS,OAAO,cAAc,UAAU,WAAW,MAAM,QAAQ,SAAS,CAAC,YAAU,UAAU,WAAS,CAAC,gBAAgB,GAAM,kBAAkB,GAAM,CAAC,gBAAc,WAAW,CAAC,GAAK,CAAC,EAAM,GAAUA,EAAS,EAAM,CAAM,CAAC,EAAU,GAAcA,EAAS,GAAM,CAAO,EAAaC,EAAO,KAAK,CAAC,MAAc,CAAC,IAAM,EAAS,IAAI,sBAAsB,CAAC,KAAS,CAAC,EAAa,EAAM,eAAe,EAAG,CAAgE,OAA5D,EAAa,SAAQ,EAAS,QAAQ,EAAa,QAAQ,KAAW,EAAS,YAAY,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