{"version":3,"file":"NumberCounter.DbR7nZu7.mjs","names":["useRef","useMemo","useState"],"sources":["https:/framerusercontent.com/modules/Nc5Mqo8wUEihFEUKcpYH/aTKiw6dscn7HShN1vgOa/NumberCounter.js"],"sourcesContent":["// Number Counter component with mechanical digit animation for Framer\n// Each digit animates separately with vertical sliding motion\n// Cascade delay between digits, in-view trigger, smooth upward-only animation\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,useRef,useMemo}from\"react\";import{motion,useInView,useSpring,useTransform}from\"framer-motion\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import React from\"react\";/**\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function NumberCounter(props){const{start=0,end=\"1.234\",duration=2,digitDelay=.05,prefix=\"\",suffix=\"\",font,color=\"#000000\",smoothness=100,bounce=0,style}=props;// Parse end value (remove dots for calculation)\nconst endNumeric=typeof end===\"string\"?parseInt(end.replace(/\\./g,\"\"),10):end;const endFormatted=typeof end===\"string\"?end:formatNumber(end);const containerRef=useRef(null);const isInView=useInView(containerRef,{amount:.3});const isStatic=RenderTarget.current()===RenderTarget.canvas||RenderTarget.current()===RenderTarget.thumbnail;const maxDigits=Math.max(String(Math.abs(start)).length,String(Math.abs(endNumeric)).replace(/\\./g,\"\").length);const startStr=String(Math.abs(start)).padStart(maxDigits,\"0\");const endStr=String(Math.abs(endNumeric)).padStart(maxDigits,\"0\");const displayValue=isStatic?endNumeric:endNumeric;const isNegative=displayValue<0;// Create digits array with dot positions from formatted end value\nconst digitsWithDots=useMemo(()=>{const result=[];const endClean=endFormatted.replace(/[^0-9]/g,\"\");let digitIndex=0;for(let i=0;i<endFormatted.length;i++){const char=endFormatted[i];if(char===\".\"){result.push({type:\"dot\"});}else if(!isNaN(parseInt(char,10))){result.push({type:\"digit\",startDigit:startStr[digitIndex],endDigit:endStr[digitIndex],index:digitIndex});digitIndex++;}}return result;},[startStr,endStr,endFormatted]);return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{display:\"flex\",alignItems:\"center\",gap:\"0.1em\",position:\"relative\",width:\"100%\",...style},children:[prefix&&/*#__PURE__*/_jsx(\"span\",{style:{...font,color,fontVariantNumeric:\"tabular-nums lining-nums\"},children:prefix}),isNegative&&/*#__PURE__*/_jsx(\"span\",{style:{...font,color,fontVariantNumeric:\"tabular-nums lining-nums\"},children:\"-\"}),/*#__PURE__*/_jsx(\"div\",{style:{display:\"inline-flex\",alignItems:\"center\"},children:digitsWithDots.map((item,idx)=>{if(item.type===\"dot\"){return /*#__PURE__*/_jsx(\"span\",{style:{...font,color,fontVariantNumeric:\"tabular-nums lining-nums\"},children:\".\"},`dot-${idx}`);}else{return /*#__PURE__*/_jsx(DigitColumn,{startDigit:item.startDigit,endDigit:item.endDigit,index:item.index,digitDelay:digitDelay,duration:duration,font:font,color:color,smoothness:smoothness,bounce:bounce,isStatic:isStatic,isInView:isInView},`digit-${item.index}`);}})}),suffix&&/*#__PURE__*/_jsx(\"span\",{style:{...font,color,fontVariantNumeric:\"tabular-nums lining-nums\"},children:suffix})]});}const DigitColumn=/*#__PURE__*/React.memo(function DigitColumn({startDigit,endDigit,index,digitDelay,duration,font,color,smoothness,bounce,isStatic,isInView}){const startNum=parseInt(startDigit,10);const endNum=parseInt(endDigit,10);const digitRef=useRef(null);const[digitHeight,setDigitHeight]=useState(40);useEffect(()=>{if(digitRef.current){const height=digitRef.current.offsetHeight;if(height>0){setDigitHeight(height);}}},[font]);const yMemoKey=`${digitHeight}-${startNum}-${endNum}`;const springConfig=useMemo(()=>({stiffness:smoothness,damping:bounce>0?30-bounce/100*20:30,mass:1}),[smoothness,bounce]);const motionValue=useSpring(isStatic?endNum:startNum,springConfig);useEffect(()=>{if(isStatic){motionValue.set(endNum);return;}if(!isInView){motionValue.set(startNum);return;}const timeout=setTimeout(()=>{motionValue.set(endNum);},index*digitDelay*1e3);return()=>clearTimeout(timeout);},[endNum,startNum,index,digitDelay,motionValue,isStatic,isInView]);const y=useTransform(motionValue,value=>{return-value*digitHeight;});return /*#__PURE__*/_jsx(\"div\",{ref:digitRef,style:{display:\"inline-block\",position:\"relative\",overflow:\"hidden\",height:\"1em\",minWidth:\"0.6em\",textAlign:\"center\",...font},children:/*#__PURE__*/_jsx(motion.div,{style:useMemo(()=>({y,display:\"flex\",flexDirection:\"column\",alignItems:\"center\"}),[yMemoKey,y]),children:[0,1,2,3,4,5,6,7,8,9].map(num=>/*#__PURE__*/_jsx(\"span\",{style:useMemo(()=>({...font,color,fontVariantNumeric:\"tabular-nums lining-nums\",height:digitHeight,display:\"flex\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\"}),[digitHeight,font,color]),children:num},num))})});});function easeOutCubic(t){return 1-Math.pow(1-t,3);}function easeOutBounce(t,bounceAmount){const n1=7.5625;const d1=2.75;const intensity=bounceAmount/100;if(t<1/d1){return n1*t*t*intensity+t*(1-intensity);}else if(t<2/d1){return(n1*(t-=1.5/d1)*t+.75)*intensity+t*(1-intensity);}else if(t<2.5/d1){return(n1*(t-=2.25/d1)*t+.9375)*intensity+t*(1-intensity);}else{return(n1*(t-=2.625/d1)*t+.984375)*intensity+t*(1-intensity);}}function formatNumber(num){const absNum=Math.abs(num);if(absNum>=1e3){return absNum.toString().replace(/\\B(?=(\\d{3})+(?!\\d))/g,\".\");}return absNum.toString();}addPropertyControls(NumberCounter,{start:{type:ControlType.Number,title:\"Start\",defaultValue:0,step:1},end:{type:ControlType.String,title:\"End\",defaultValue:\"1.234\",placeholder:\"1.000\"},duration:{type:ControlType.Number,title:\"Duration\",defaultValue:2,min:.1,max:10,step:.1,unit:\"s\"},digitDelay:{type:ControlType.Number,title:\"Digit Delay\",defaultValue:.05,min:0,max:.5,step:.01,unit:\"s\"},prefix:{type:ControlType.String,title:\"Prefix\",defaultValue:\"\",placeholder:\"$\"},suffix:{type:ControlType.String,title:\"Suffix\",defaultValue:\"\",placeholder:\"%\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"}},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},smoothness:{type:ControlType.Number,title:\"Smoothness\",defaultValue:100,min:1,max:300,step:10},bounce:{type:ControlType.Number,title:\"Bounce\",defaultValue:0,min:0,max:100,step:5,unit:\"%\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumberCounter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberCounter.map"],"mappings":"0RAMG,SAAwB,EAAc,EAAM,CAAC,GAAK,CAAC,QAAM,EAAE,MAAI,QAAQ,WAAS,EAAE,aAAW,IAAI,SAAO,GAAG,SAAO,GAAG,OAAK,QAAM,UAAU,aAAW,IAAI,SAAO,EAAE,SAAO,EACtK,EAAW,OAAO,GAAM,SAAS,SAAS,EAAI,QAAQ,MAAM,EAAE,EAAE,EAAE,EAAE,EAAU,EAAa,OAAO,GAAM,SAAS,EAAI,EAAa,CAAG,EAAQ,EAAaA,EAAO,IAAI,EAAQ,EAAS,EAAU,EAAa,CAAC,OAAO,EAAE,CAAC,EAAQ,EAAS,EAAa,QAAQ,IAAI,EAAa,QAAQ,EAAa,QAAQ,IAAI,EAAa,UAAgB,EAAU,KAAK,IAAI,OAAO,KAAK,IAAI,CAAK,CAAC,CAAC,CAAC,OAAO,OAAO,KAAK,IAAI,CAAU,CAAC,CAAC,CAAC,QAAQ,MAAM,EAAE,CAAC,CAAC,MAAM,EAAQ,EAAS,OAAO,KAAK,IAAI,CAAK,CAAC,CAAC,CAAC,SAAS,EAAU,GAAG,EAAQ,EAAO,OAAO,KAAK,IAAI,CAAU,CAA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