{"version":3,"file":"Counter.CE0_mBTb.mjs","names":["useState","useRef","__esmMin","init_npm_react_18_3_1","_e","de","init_jsx_runtime","c","p","ce","motion","init_framer_motion_DhsWWWsN","init_framer_D6uXRwWs","addPropertyControls","ControlType","Counter","count","setCount","parseNumber","start","isVisible","setIsVisible","containerRef","rafRef","startTimestampRef","fromRef","toRef","end","runningRef","value","s","hasDot","hasComma","normalized","n","observer","entry","parsedStart","parsedEnd","startOnViewport","durationMs","speedPercent","incrementPrecision","incrementType","loopRequested","loop","cancel","animateOnce","step","timestamp","elapsed","t","duration","current","from","to","fixed","onComplete","startAnimation","restartOnViewport","gapSize","textSize","selectedFont","textColor","prefixText","prefixFont","prefixColor","decimalSeparatorType","number","suffixText","suffixFont","suffixColor","init_Counter"],"sources":["https:/framerusercontent.com/modules/amaXGtFxLPxvyGfq6grp/lTSM8pOOFYRKKWOhjmWW/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\";export function Counter({start=\"0\",end=\"1000\",speedPercent=100,gapSize=4,prefixText=\"\",suffixText=\"\",prefixFont,suffixFont,prefixColor,suffixColor,loop=false,decimalSeparatorType=\"comma\",textSize=36,selectedFont={fontFamily:\"Inter\",fontWeight:500,systemFont:true},textColor=\"#D3D3D3\",startOnViewport=false,restartOnViewport=false,incrementType=\"integer\"}){const[count,setCount]=useState(()=>parseNumber(start));const[isVisible,setIsVisible]=useState(false);const containerRef=useRef(null);const rafRef=useRef(null);const startTimestampRef=useRef(null);const fromRef=useRef(parseNumber(start));const toRef=useRef(parseNumber(end));const runningRef=useRef(false);function parseNumber(value){if(typeof value===\"number\")return value;if(typeof value!==\"string\")return 0;const s=value.trim();if(s===\"\")return 0;const hasDot=s.indexOf(\".\")!==-1;const hasComma=s.indexOf(\",\")!==-1;let normalized=s;if(hasDot&&hasComma){normalized=s.replace(/,/g,\"\");}else if(hasComma&&!hasDot){normalized=s.replace(/,/g,\".\");}else{normalized=s.replace(/,/g,\"\");}const n=parseFloat(normalized);return Number.isFinite(n)?n:0;}useEffect(()=>{const observer=new IntersectionObserver(([entry])=>{setIsVisible(entry.isIntersecting);});if(containerRef.current)observer.observe(containerRef.current);return()=>observer.disconnect();},[]);useEffect(()=>{const parsedStart=parseNumber(start);const parsedEnd=parseNumber(end);fromRef.current=parsedStart;toRef.current=parsedEnd;setCount(parsedStart);},[start,end]);useEffect(()=>{if(!(isVisible||!startOnViewport))return;if(fromRef.current===toRef.current)return;const safeSpeed=typeof speedPercent===\"number\"&&speedPercent>0?speedPercent:100;const durationMs=100/safeSpeed*1e3;const incrementPrecision=incrementType===\"integer\"?0:1;let loopRequested=loop;let cancel=false;const animateOnce=(from,to,duration,onComplete)=>{runningRef.current=true;startTimestampRef.current=null;const step=timestamp=>{if(cancel)return;if(!startTimestampRef.current)startTimestampRef.current=timestamp;const elapsed=timestamp-startTimestampRef.current;const t=Math.min(1,elapsed/duration);const current=from+(to-from)*t;const fixed=incrementPrecision===0?Math.round(current):Math.round(current*10)/10;setCount(fixed>=to?to:fixed);if(t<1){rafRef.current=requestAnimationFrame(step);}else{runningRef.current=false;if(onComplete)onComplete();}};rafRef.current=requestAnimationFrame(step);};const startAnimation=()=>{animateOnce(fromRef.current,toRef.current,durationMs,()=>{if(cancel)return;if(loopRequested){fromRef.current=parseNumber(start);toRef.current=parseNumber(end);startAnimation();}});};startAnimation();return()=>{cancel=true;if(rafRef.current)cancelAnimationFrame(rafRef.current);rafRef.current=null;runningRef.current=false;};},[isVisible,startOnViewport,restartOnViewport,speedPercent,incrementType,loop,start,end]);useEffect(()=>{if(restartOnViewport&&isVisible){setCount(parseNumber(start));}},[isVisible,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\",fontSize:`${textSize}px`,fontFamily:selectedFont.fontFamily,fontWeight:selectedFont.fontWeight,color:textColor,letterSpacing:\"-0.07em\",lineHeight:\"100%\"},children:[prefixText&&/*#__PURE__*/_jsx(\"span\",{style:{fontFamily:prefixFont?.fontFamily,fontWeight:prefixFont?.fontWeight,color:prefixColor,lineHeight:\"100%\"},children:prefixText}),/*#__PURE__*/_jsx(\"span\",{style:{lineHeight:\"100%\"},children:formatNumber(count)}),suffixText&&/*#__PURE__*/_jsx(\"span\",{style:{fontFamily:suffixFont?.fontFamily,fontWeight:suffixFont?.fontWeight,color:suffixColor,lineHeight:\"100%\"},children:suffixText})]});}addPropertyControls(Counter,{startOnViewport:{type:ControlType.Boolean,title:\"Viewport\",defaultValue:false},restartOnViewport:{type:ControlType.Boolean,title:\"Replay\",defaultValue:false},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:\"Font Color\"},start:{type:ControlType.String,title:\"Start (text)\",defaultValue:\"0\"},end:{type:ControlType.String,title:\"End (text)\",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\"]},prefixText:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\"},prefixFont:{title:\"Prefix Font\",type:ControlType.Font},prefixColor:{type:ControlType.Color,title:\"Prefix Color\"},suffixText:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\"},suffixFont:{type:ControlType.Font},suffixColor:{type:ControlType.Color,title:\"Suffix Color\"},gapSize:{type:ControlType.Number,title:\"Gap Size\",defaultValue:4,min:0,max:100},speedPercent:{type:ControlType.Number,title:\"Speed (%)\",defaultValue:100,min:1,max:1e3,step:1},loop:{type:ControlType.Boolean,title:\"Loop Animation\",defaultValue:false}});\nexport const __FramerMetadata__ = {\"exports\":{\"Counter\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Counter.map"],"mappings":"A,gPAA4L,SAAgBe,EAAQ,CAAC,QAAM,IAAI,MAAI,OAAO,eAAa,IAAI,UAAQ,EAAE,aAAW,GAAG,aAAW,GAAG,aAAW,aAAW,cAAY,cAAY,OAAK,GAAM,uBAAqB,QAAQ,WAAS,GAAG,eAAa,CAAC,WAAW,QAAQ,WAAW,IAAI,WAAW,EAAI,EAAE,YAAU,UAAU,kBAAgB,GAAM,oBAAkB,GAAM,gBAAc,WAAW,CAAC,GAAK,CAACC,EAAMC,GAAUjB,MAAakB,EAAYC,CAAK,CAAC,EAAO,CAACC,EAAUC,GAAcrB,EAAS,EAAK,EAAQsB,EAAarB,EAAO,IAAI,EAAQsB,EAAOtB,EAAO,IAAI,EAAQuB,EAAkBvB,EAAO,IAAI,EAAQwB,EAAQxB,EAAOiB,EAAYC,CAAK,CAAC,EAAQO,EAAMzB,EAAOiB,EAAYS,CAAG,CAAC,EAAQC,EAAW3B,EAAO,EAAK,EAAE,SAASiB,EAAY,EAAM,CAAC,GAAG,OAAOW,GAAQ,SAAS,OAAOA,EAAM,GAAG,OAAOA,GAAQ,SAAS,MAAO,GAAE,IAAMC,EAAED,EAAM,KAAK,EAAE,GAAGC,IAAI,GAAG,MAAO,GAAE,IAAMC,EAAOD,EAAE,QAAQ,GAAG,IAAI,GAASE,EAASF,EAAE,QAAQ,GAAG,IAAI,GAAOG,EAAWH,EAAE,AAAoHG,EAAjHF,GAAQC,EAAqBF,EAAE,QAAQ,KAAK,EAAE,EAAWE,GAAU,CAACD,EAAmBD,EA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