{"version":3,"file":"NumberCounter.mxl74VQl.mjs","names":["useRef","useState"],"sources":["https:/framerusercontent.com/modules/AehBX4q26jjd3KCpmgv6/Hoz2F5DIIAvyguY8L3xS/NumberCounter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{useEffect,useRef,useState}from\"react\";/**\n * Number Counter\n *\n * Animates from 0 up to a target value when it scrolls into view.\n * Controls: value, prefix, suffix, speed, font (extended picker), font color.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight auto\n * @framerIntrinsicWidth 240\n * @framerIntrinsicHeight 80\n */export default function NumberCounter(props){const{value,prefix,suffix,speed,decimals,separator,startOnView,font,color,align,style}=props;const ref=useRef(null);const[display,setDisplay]=useState(0);const startedRef=useRef(false);const rafRef=useRef();const animate=()=>{if(startedRef.current)return;startedRef.current=true;const duration=Math.max(.1,speed)*1e3;const start=performance.now();const tick=now=>{const t=Math.min(1,(now-start)/duration);// easeOutCubic\nconst eased=1-Math.pow(1-t,3);setDisplay(value*eased);if(t<1)rafRef.current=requestAnimationFrame(tick);else setDisplay(value);};rafRef.current=requestAnimationFrame(tick);};useEffect(()=>{// Re-run when target/speed changes (e.g. editing in canvas)\nstartedRef.current=false;setDisplay(0);if(!startOnView){animate();return()=>rafRef.current&&cancelAnimationFrame(rafRef.current);}const el=ref.current;if(!el)return;const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{if(entry.isIntersecting){animate();observer.disconnect();}});},{threshold:.3});observer.observe(el);return()=>{observer.disconnect();rafRef.current&&cancelAnimationFrame(rafRef.current);};// eslint-disable-next-line react-hooks/exhaustive-deps\n},[value,speed,startOnView]);const formatted=formatNumber(display,decimals,separator);return /*#__PURE__*/_jsx(\"div\",{ref:ref,style:{// Framer's injected style (layout/size) goes FIRST so it can't\n// override the font settings below.\n...style,display:\"flex\",alignItems:\"center\",justifyContent:align===\"left\"?\"flex-start\":align===\"right\"?\"flex-end\":\"center\",width:\"100%\",height:\"100%\"},children:/*#__PURE__*/_jsxs(\"span\",{style:{whiteSpace:\"pre\",// Extended Font control supplies family, size, line-height,\n// weight, style, and letter-spacing as one style object.\n...font,color},children:[prefix,formatted,suffix]})});}function formatNumber(n,decimals,separator){const fixed=n.toFixed(decimals);const[intPart,decPart]=fixed.split(\".\");const withSep=separator?intPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g,separator):intPart;return decPart!=null?`${withSep}.${decPart}`:withSep;}NumberCounter.defaultProps={value:1e3,prefix:\"\",suffix:\"+\",speed:2,decimals:0,separator:\",\",startOnView:true,color:\"#111111\",align:\"center\"};addPropertyControls(NumberCounter,{value:{type:ControlType.Number,title:\"Value\",defaultValue:1e3,min:0,max:1e9,// Fractional step so the field accepts decimals; how many are shown\n// is governed by the Decimals control below.\nstep:.01,displayStepper:true},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"+\",placeholder:\"% / K / +\"},speed:{type:ControlType.Number,title:\"Speed\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\",displayStepper:true},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:0,min:0,max:4,step:1,displayStepper:true},separator:{type:ControlType.Enum,title:\"Separator\",defaultValue:\",\",options:[\",\",\".\",\" \",\"\"],optionTitles:[\"1,000\",\"1.000\",\"1 000\",\"1000\"],displaySegmentedControl:true},startOnView:{type:ControlType.Boolean,title:\"On Scroll\",defaultValue:true,enabledTitle:\"In View\",disabledTitle:\"On Load\"},font:{type:ControlType.Font,title:\"Font\",// Extended typography panel: family, weight, size, line-height, and\n// letter-spacing all live inside Framer's expanded font popover.\ncontrols:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:64,lineHeight:1.1,letterSpacing:0}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#111111\"},align:{type:ControlType.Enum,title:\"Align\",defaultValue:\"center\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumberCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"80\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"240\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberCounter.map"],"mappings":"+LAUG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,QAAM,SAAO,SAAO,QAAM,WAAS,YAAU,cAAY,OAAK,QAAM,QAAM,SAAO,EAAY,EAAIA,EAAO,IAAI,EAAO,CAAC,EAAQ,GAAYC,EAAS,CAAC,EAAQ,EAAWD,EAAO,EAAK,EAAQ,EAAOA,EAAO,EAAQ,MAAY,CAAC,GAAG,EAAW,QAAQ,OAAO,EAAW,QAAQ,GAAK,IAAM,EAAS,KAAK,IAAI,GAAG,CAAK,EAAE,IAAU,EAAM,YAAY,IAAI,EAAQ,EAAK,GAAK,CAAC,IAAM,EAAE,KAAK,IAAI,GAAG,EAAI,GAAO,CAAQ,EAC7b,EAAM,GAAW,EAAE,IAAE,EAAG,EAAW,EAAM,CAAK,EAAK,EAAE,EAAE,EAAO,QAAQ,sBAAsB,CAAI,EAAO,EAAW,CAAK,CAAE,EAAE,EAAO,QAAQ,sBAAsB,CAAI,CAAE,EAAE,MAAc,CACrJ,GAAvC,EAAW,QAAQ,GAAM,EAAW,CAAC,EAAK,CAAC,EAAuB,OAAV,EAAQ,MAAY,EAAO,SAAS,qBAAqB,EAAO,OAAO,EAAG,IAAM,EAAG,EAAI,QAAQ,GAAG,CAAC,EAAG,OAAO,IAAM,EAAS,IAAI,qBAAqB,GAAS,CAAC,EAAQ,QAAQ,GAAO,CAAI,EAAM,iBAAgB,EAAQ,EAAE,EA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