{"version":3,"file":"Counter.DsllaaMe.mjs","names":["useState","useRef","useEffect","_jsxs","_jsx","__esmMin","init_npm_react_18_3_1","_e","p","c","init_jsx_runtime","ce","de","addPropertyControls","init_framer_ChujFWHC","ControlType","motion","init_framer_motion_1EwlFBEG","Counter","start","end","speedPercent","gapSize","prefixText","suffixText","prefixFont","suffixFont","prefixColor","suffixColor","loop","decimalSeparatorType","textSize","selectedFont","textColor","startOnViewport","restartOnViewport","incrementType","count","setCount","parseNumber","isVisible","setIsVisible","containerRef","rafRef","startTimestampRef","fromRef","toRef","runningRef","value","s","hasDot","hasComma","normalized","n","observer","entry","parsedStart","parsedEnd","durationMs","incrementPrecision","loopRequested","cancel","animateOnce","from","to","duration","onComplete","step","timestamp","elapsed","t","current","fixed","startAnimation","number","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,SAAgBkB,EAAQ,CAACC,QAAM,IAAIC,MAAI,OAAOC,eAAa,IAAIC,UAAQ,EAAEC,aAAW,GAAGC,aAAW,GAAGC,aAAWC,aAAWC,cAAYC,cAAYC,OAAK,GAAMC,uBAAqB,QAAQC,WAAS,GAAGC,eAAa,CAAC,WAAW,QAAQ,WAAW,IAAI,WAAW,EAAI,EAAEC,YAAU,UAAUC,kBAAgB,GAAMC,oBAAkB,GAAMC,gBAAc,WAAW,CAAC,GAAK,CAACC,EAAMC,GAAUtC,MAAauC,EAAYpB,CAAK,CAAC,EAAO,CAACqB,EAAUC,GAAczC,EAAS,EAAK,EAAQ0C,EAAazC,EAAO,IAAI,EAAQ0C,EAAO1C,EAAO,IAAI,EAAQ2C,EAAkB3C,EAAO,IAAI,EAAQ4C,EAAQ5C,EAAOsC,EAAYpB,CAAK,CAAC,EAAQ2B,EAAM7C,EAAOsC,EAAYnB,CAAG,CAAC,EAAQ2B,EAAW9C,EAAO,EAAK,EAAE,SAASsC,EAAYS,EAAM,CAAC,GAAG,OAAOA,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,EAAsHG,EAAjHF,GAAQC,EAAqBF,EAAE,QA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