{"version":3,"file":"CountdownNumber.BFrmdmx0.mjs","names":["useState","useRef","useMemo","p"],"sources":["https:/framerusercontent.com/modules/Eh6Wn3ADYnSvuEXWIZfM/OLsFXX7YkGdX8vilnZK3/CountdownNumber.js"],"sourcesContent":["// CountdownNumber animation with customizable number, color, size, font, and fixed dollar sign\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useRef,useState,startTransition,useMemo}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";import{useInView}from\"framer-motion\";/**\n * CountdownNumber Number Animation with Dollar Sign\n *\n * @framerSupportedLayoutWidth auto\n * @framerSupportedLayoutHeight auto\n */export default function CountdownNumber(props){const{from,to,duration,color,font,showDecimals,decimals,style}=props;const isStatic=useIsStaticRenderer();const[value,setValue]=useState(from);const raf=useRef();const startTime=useRef();const containerRef=useRef(null);const inView=useInView(containerRef,{once:false,amount:.01});useEffect(()=>{if(isStatic||!inView){startTransition(()=>setValue(to));return;}startTransition(()=>setValue(from));function animate(ts){if(!startTime.current)startTime.current=ts;const elapsed=ts-startTime.current;const progress=Math.min(elapsed/(duration*1e3),1);const current=from+(to-from)*progress;startTransition(()=>setValue(current));if(progress<1){raf.current=requestAnimationFrame(animate);}else{startTransition(()=>setValue(to));}}raf.current=requestAnimationFrame(animate);return()=>{if(raf.current)cancelAnimationFrame(raf.current);startTime.current=undefined;};},[from,to,duration,isStatic,inView]);const formatted=useMemo(()=>{if(showDecimals){return value.toLocaleString(undefined,{minimumFractionDigits:decimals,maximumFractionDigits:decimals});}return Math.round(value).toLocaleString();},[value,showDecimals,decimals]);return /*#__PURE__*/_jsxs(\"div\",{ref:containerRef,style:{display:\"flex\",alignItems:\"center\",color,...font,...style,width:\"max-content\",position:\"relative\"},children:[/*#__PURE__*/_jsx(\"span\",{style:{marginRight:4,fontWeight:font?.variant===\"Bold\"?700:undefined,fontSize:font?.fontSize,lineHeight:font?.lineHeight,letterSpacing:font?.letterSpacing},\"aria-hidden\":\"true\",children:\"$\"}),/*#__PURE__*/_jsx(\"span\",{style:{fontWeight:font?.variant===\"Bold\"?700:undefined,fontSize:font?.fontSize,lineHeight:font?.lineHeight,letterSpacing:font?.letterSpacing},children:formatted})]});}addPropertyControls(CountdownNumber,{from:{type:ControlType.Number,title:\"From\",defaultValue:1e3,min:0,max:1e6,step:.01},to:{type:ControlType.Number,title:\"To\",defaultValue:0,min:0,max:1e6,step:.01},duration:{type:ControlType.Number,title:\"Duration (s)\",defaultValue:2,min:.1,max:10,step:.1},color:{type:ControlType.Color,title:\"Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"}},showDecimals:{type:ControlType.Boolean,title:\"Show Decimals\",defaultValue:false,enabledTitle:\"Yes\",disabledTitle:\"No\"},decimals:{type:ControlType.Number,title:\"Decimals\",defaultValue:2,min:0,max:6,step:1,hidden:p=>!p.showDecimals}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountdownNumber\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"auto\",\"framerSupportedLayoutHeight\":\"auto\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CountdownNumber.map"],"mappings":"uQAMG,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,OAAK,KAAG,WAAS,QAAM,OAAK,eAAa,WAAS,SAAO,EAAY,EAAS,GAAqB,CAAM,CAAC,EAAM,GAAUA,EAAS,EAAK,CAAO,EAAIC,GAAQ,CAAO,EAAUA,GAAQ,CAAO,EAAaA,EAAO,KAAK,CAAO,EAAO,EAAU,EAAa,CAAC,KAAK,GAAM,OAAO,IAAI,CAAC,CAAC,MAAc,CAAC,GAAG,GAAU,CAAC,EAAO,CAAC,MAAoB,EAAS,EAAG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