{"version":3,"file":"CountUpNumber.GTlLwn-R.mjs","names":["useMemo","useState","useRef"],"sources":["https:/framerusercontent.com/modules/5dj5vyasY7j2hr7xcQcf/zmcjP8o2koYoEBkARNMW/CountUpNumber.js"],"sourcesContent":["// User request: ensure the configured final value is always available as readable HTML text,\n// even if animation does not run, timing is delayed, or reduced motion prevents count-up,\n// while preserving visual design, controls, animation behavior, font/color controls, and prefix/suffix API.\n// CountUpNumber component that counts up from a start number to an end number when scrolled into view\n// Includes options for start/end numbers, font, color, prefix/suffix text, speed control, and easing\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,useRef,useMemo,startTransition}from\"react\";import{addPropertyControls,ControlType,useInView,useIsStaticRenderer}from\"framer\";/**\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function CountUpNumber(props){const{startNumber,endNumber,endDecimal,prefix,suffix,duration,easing,font,textColor,animateLast10}=props;const actualEndNumber=useMemo(()=>endDecimal?parseFloat(`${endNumber}.${endDecimal}`):endNumber,[endNumber,endDecimal]);const staticFinalValue=useMemo(()=>endDecimal?`${endNumber}.${endDecimal}`:endNumber.toString(),[endDecimal,endNumber]);const[count,setCount]=useState(actualEndNumber);const[prefersReducedMotion,setPrefersReducedMotion]=useState(false);const ref=useRef(null);const animationFrameRef=useRef(null);const isInView=useInView(ref);const isStatic=useIsStaticRenderer();// Easing functions\nconst easingFunctions={linear:t=>t,easeInQuad:t=>t*t,easeOutQuad:t=>t*(2-t),easeInOutQuad:t=>t<.5?2*t*t:-1+(4-2*t)*t,easeInCubic:t=>t*t*t,easeOutCubic:t=>--t*t*t+1,easeInOutCubic:t=>t<.5?4*t*t*t:(t-1)*(2*t-2)*(2*t-2)+1,easeInQuart:t=>t*t*t*t,easeOutQuart:t=>1- --t*t*t*t,easeInOutQuart:t=>t<.5?8*t*t*t*t:1-8*--t*t*t*t};useEffect(()=>{if(typeof window!==\"undefined\"&&typeof window.matchMedia===\"function\"){const mediaQuery=window.matchMedia(\"(prefers-reduced-motion: reduce)\");startTransition(()=>setPrefersReducedMotion(mediaQuery.matches));const handleChange=event=>{startTransition(()=>setPrefersReducedMotion(event.matches));};if(typeof mediaQuery.addEventListener===\"function\"){mediaQuery.addEventListener(\"change\",handleChange);return()=>mediaQuery.removeEventListener(\"change\",handleChange);}mediaQuery.addListener(handleChange);return()=>mediaQuery.removeListener(handleChange);}else{startTransition(()=>setPrefersReducedMotion(false));}},[]);useEffect(()=>{// Cancel any ongoing animation\nif(animationFrameRef.current!==null){cancelAnimationFrame(animationFrameRef.current);}if(isStatic||prefersReducedMotion){startTransition(()=>setCount(actualEndNumber));return;}if(!isInView){return;}const startTime=performance.now();// Determine the actual start number based on animateLast10 toggle\nconst actualStartNumber=animateLast10?Math.max(actualEndNumber-10,startNumber):startNumber;startTransition(()=>setCount(actualStartNumber));const range=actualEndNumber-actualStartNumber;const easeFn=easingFunctions[easing]||easingFunctions.linear;const animate=currentTime=>{const elapsed=currentTime-startTime;const progress=Math.min(elapsed/(duration*1e3),1);const easedProgress=easeFn(progress);const currentValue=actualStartNumber+range*easedProgress;startTransition(()=>setCount(currentValue));if(progress<1){animationFrameRef.current=requestAnimationFrame(animate);}else{// Ensure we end exactly at actualEndNumber\nstartTransition(()=>setCount(actualEndNumber));}};animationFrameRef.current=requestAnimationFrame(animate);return()=>{if(animationFrameRef.current!==null){cancelAnimationFrame(animationFrameRef.current);}};},[isInView,startNumber,duration,easing,animateLast10,actualEndNumber,isStatic,prefersReducedMotion]);// Format number to show exact decimal places based on endDecimal\nconst formatNumber=(num,decimalString)=>{if(!decimalString){return Math.floor(num).toString();}const decimalPlaces=decimalString.length;const multiplier=Math.pow(10,decimalPlaces);const truncated=Math.floor(num*multiplier)/multiplier;return truncated.toFixed(decimalPlaces);};// Static renderers and reduced-motion environments should always show the final configured value.\nconst finalDisplayValue=isStatic||prefersReducedMotion?staticFinalValue:formatNumber(count,endDecimal);const fullDisplayText=`${prefix}${finalDisplayValue}${suffix}`;return /*#__PURE__*/_jsx(\"div\",{ref:ref,role:\"text\",\"aria-label\":fullDisplayText,style:{...props.style,position:\"relative\",width:\"max-content\",minWidth:\"max-content\",color:textColor,...font},children:fullDisplayText});}addPropertyControls(CountUpNumber,{startNumber:{type:ControlType.Number,title:\"Start Number\",defaultValue:0,step:.01},endNumber:{type:ControlType.Number,title:\"End Number\",defaultValue:100,step:1,displayStepper:true},endDecimal:{type:ControlType.String,title:\"End Decimal\",defaultValue:\"\",placeholder:\"e.g. 00 or 50\"},animateLast10:{type:ControlType.Boolean,title:\"Animate Last 10\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"e.g. +\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"e.g. k\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.5,max:10,step:.5,unit:\"s\"},easing:{type:ControlType.Enum,title:\"Easing\",defaultValue:\"easeOutCubic\",options:[\"linear\",\"easeInQuad\",\"easeOutQuad\",\"easeInOutQuad\",\"easeInCubic\",\"easeOutCubic\",\"easeInOutCubic\",\"easeInQuart\",\"easeOutQuart\",\"easeInOutQuart\"],optionTitles:[\"Linear\",\"Ease In Quad\",\"Ease Out Quad\",\"Ease In Out Quad\",\"Ease In Cubic\",\"Ease Out Cubic\",\"Ease In Out Cubic\",\"Ease In Quart\",\"Ease Out Quart\",\"Ease In Out Quart\"]},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountUpNumber\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerContractVersion\":\"1\",\"framerSupport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