{"version":3,"file":"AnimatedNumber.D8XUt4At.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/7RMt0xPIhnPlj7yMqoCw/mzUYLxoJC6udMS33P9ha/AnimatedNumber.js"],"sourcesContent":["// Animated number that animates when entering viewport from bottom, with controls for start, end, font, suffix, and animation\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView}from\"framer-motion\";/**\n * Animated Number (in-view)\n *\n * @framerIntrinsicWidth 180\n * @framerIntrinsicHeight 60\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function AnimatedNumber(props){const{start,end,duration,font,color,suffix,animation,style,decimalPlaces,useThousandsSeparator,thousandsSeparator,decimalSeparator,useCurrency,currencySymbol,currencyPosition,prefix,showPlusSign,useParenthesesForNegative}=props;const[value,setValue]=useState(start);const raf=useRef(null);const isStatic=useIsStaticRenderer();const wrapperRef=useRef(null);// Trigger as soon as the bottom of the layer enters the viewport\nconst inView=useInView(wrapperRef,{once:true,margin:\"0px 0px -10% 0px\"});// Easing functions\nfunction ease(t){switch(animation){case\"easeIn\":return t*t;case\"easeOut\":return t*(2-t);case\"easeInOut\":return t<.5?2*t*t:-1+(4-2*t)*t;default:return t;}}useEffect(()=>{if(isStatic||!inView){setValue(isStatic?end:start);return;}let startTime=null;if(raf.current)cancelAnimationFrame(raf.current);function animate(ts){if(startTime===null)startTime=ts;const elapsed=ts-startTime;const t=Math.min(1,elapsed/(duration*1e3));const eased=ease(t);const current=start+(end-start)*eased;startTransition(()=>setValue(current));if(t<1){raf.current=requestAnimationFrame(animate);}else{startTransition(()=>setValue(end));}}raf.current=requestAnimationFrame(animate);return()=>{if(raf.current)cancelAnimationFrame(raf.current);};// eslint-disable-next-line react-hooks/exhaustive-deps\n},[start,end,duration,animation,isStatic,inView]);// Format number with all options\nfunction formatNumber(num){// Round to decimal places\nconst rounded=Number(num.toFixed(decimalPlaces));// Split into integer and decimal parts\nconst parts=rounded.toString().split(\".\");let integerPart=parts[0];const decimalPart=parts[1]||\"\";// Add thousands separator\nif(useThousandsSeparator){integerPart=integerPart.replace(/\\B(?=(\\d{3})+(?!\\d))/g,thousandsSeparator);}// Combine with decimal separator\nlet formatted=integerPart;if(decimalPlaces>0){formatted+=decimalSeparator+decimalPart.padEnd(decimalPlaces,\"0\");}return formatted;}// Build final display string\nfunction getDisplayValue(){const isNegative=value<0;const absValue=Math.abs(value);const formattedNumber=formatNumber(absValue);let result=formattedNumber;// Add currency\nif(useCurrency){if(currencyPosition===\"before\"){result=currencySymbol+result;}else{result=result+currencySymbol;}}// Add prefix and suffix\nif(prefix)result=prefix+result;if(suffix)result=result+suffix;// Handle negative/positive signs\nif(isNegative){if(useParenthesesForNegative){result=\"(\"+result+\")\";}else{result=\"-\"+result;}}else if(showPlusSign&&value>0){result=\"+\"+result;}return result;}return /*#__PURE__*/_jsx(\"div\",{ref:wrapperRef,style:{display:\"inline-block\",width:\"max-content\",...style},children:/*#__PURE__*/_jsx(\"span\",{style:{...font,color,width:\"max-content\",display:\"inline-block\"},\"aria-label\":`Animated number: ${getDisplayValue()}`,children:getDisplayValue()})});}addPropertyControls(AnimatedNumber,{start:{type:ControlType.Number,title:\"Start\",defaultValue:0,min:-1e5,max:1e5,step:1},end:{type:ControlType.Number,title:\"End\",defaultValue:1244,min:-1e5,max:1e5,step:1},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:1.2,min:.1,max:10,step:.1,unit:\"s\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},decimalPlaces:{type:ControlType.Number,title:\"Decimal Places\",defaultValue:0,min:0,max:10,step:1,displayStepper:true},useThousandsSeparator:{type:ControlType.Boolean,title:\"Thousands Separator\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},thousandsSeparator:{type:ControlType.String,title:\"Separator\",defaultValue:\",\",placeholder:\",\",hidden:props=>!props.useThousandsSeparator},decimalSeparator:{type:ControlType.String,title:\"Decimal Separator\",defaultValue:\".\",placeholder:\".\",hidden:props=>props.decimalPlaces===0},useCurrency:{type:ControlType.Boolean,title:\"Currency\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},currencySymbol:{type:ControlType.String,title:\"Symbol\",defaultValue:\"$\",placeholder:\"$\",hidden:props=>!props.useCurrency},currencyPosition:{type:ControlType.Enum,title:\"Position\",options:[\"before\",\"after\"],optionTitles:[\"Before\",\"After\"],defaultValue:\"before\",displaySegmentedControl:true,hidden:props=>!props.useCurrency},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"e.g., +\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%\"},animation:{type:ControlType.Enum,title:\"Animation\",options:[\"linear\",\"easeIn\",\"easeOut\",\"easeInOut\"],optionTitles:[\"Linear\",\"Ease In\",\"Ease Out\",\"Ease In Out\"],defaultValue:\"easeOut\",displaySegmentedControl:true}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"AnimatedNumber\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"180\",\"framerIntrinsicHeight\":\"60\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./AnimatedNumber.map"],"mappings":"wPASG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,QAAM,MAAI,WAAS,OAAK,QAAM,SAAO,YAAU,QAAM,gBAAc,wBAAsB,qBAAmB,mBAAiB,cAAY,iBAAe,mBAAiB,SAAO,eAAa,6BAA2B,EAAW,CAAC,EAAM,GAA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