{"version":3,"file":"NumberAnimator.DbdTOkzm.mjs","names":["useRef","useState","number","useEffect","_jsxs","__esmMin","init_npm_react_18_3_1","de","init_jsx_runtime","p","ce","_e","init_framer_BWzg2IRg","addPropertyControls","RenderTarget","ControlType","useInView","animate","motion","init_framer_motion_1EwlFBEG","NumberAnimator","props","ref","isInView","numberText","setNumberText","start","end","decimals","commas","rounding","fontColor","animation","currentAnimation","setCurrentAnimation","isCanvas","formatNumber","value","numberString","runAnimation","latest","init_NumberAnimator"],"sources":["https:/framerusercontent.com/modules/m7nj7pMdZAnJLM3LV8Sw/onjqdlOaK0PHEqSmsu0O/NumberAnimator.js"],"sourcesContent":["import{jsxs as _jsxs}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion,animate,useInView}from\"framer-motion\";import{useEffect,useState,useRef}from\"react\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n * @framerDisableUnlink\n */export default function NumberAnimator(props){const ref=useRef(null);const isInView=useInView(ref,{once:!props.animation.replay,amount:\"some\"});const[numberText,setNumberText]=useState(\"\");const{start,end,decimals,commas,rounding,fontColor,animation}=props;const[currentAnimation,setCurrentAnimation]=useState(null);const isCanvas=RenderTarget.current()===RenderTarget.canvas;function formatNumber(value){let number=value;let numberString=number.toFixed(decimals);if(commas){numberString=numberString.replace(/\\B(?=(\\d{3})+(?!\\d))/g,\",\");}return numberString;}function runAnimation(){if(!isCanvas){if(currentAnimation){currentAnimation.stop();}setCurrentAnimation(animate(start,end,{...animation.transition,onUpdate:latest=>{setNumberText(formatNumber(latest));}}));}}useEffect(()=>{if(animation.trigger==\"appear\"){runAnimation();}setNumberText(formatNumber(start));},[]);useEffect(()=>{if(isInView&&animation.trigger==\"layerInView\"){runAnimation();}},[isInView]);useEffect(()=>{if(animation.trigger==\"layerInView\"){if(isInView){runAnimation();}else{if(currentAnimation){currentAnimation.stop();}setNumberText(formatNumber(start));}}},[isInView]);return /*#__PURE__*/_jsxs(motion.p,{ref:ref,style:{userSelect:props.textSelect?\"auto\":\"none\",fontVariantNumeric:`${props.monospace?\"tabular-nums \":\"\"}${props.slashedZeros?\"slashed-zero\":\"\"}`,margin:0,...fontColor.mode==\"solid\"?{color:fontColor.color}:{WebkitBackgroundClip:\"text\",WebkitTextFillColor:\"transparent\",backgroundImage:`linear-gradient(${fontColor.angle}deg, ${fontColor.startColor}, ${fontColor.endColor})`},...props.font,...props.style},children:[props.prefix,isCanvas?formatNumber(end):numberText,props.suffix]});}NumberAnimator.displayName=\"Animated Number Counter\";addPropertyControls(NumberAnimator,{start:{type:ControlType.Number,defaultValue:0},end:{type:ControlType.Number,defaultValue:100},decimals:{type:ControlType.Number,defaultValue:0,min:0,max:3,step:1},commas:{type:ControlType.Boolean,defaultValue:true},fontColor:{type:ControlType.Object,controls:{mode:{type:ControlType.Enum,defaultValue:\"solid\",options:[\"solid\",\"gradient\"],optionTitles:[\"Solid\",\"Gradient\"],displaySegmentedControl:true},color:{type:ControlType.Color,defaultValue:\"#000\",hidden:props=>props.mode!=\"solid\"},startColor:{type:ControlType.Color,defaultValue:\"#000\",hidden:props=>props.mode!=\"gradient\"},endColor:{type:ControlType.Color,defaultValue:\"#FFF\",hidden:props=>props.mode!=\"gradient\"},angle:{type:ControlType.Number,defaultValue:180,min:-360,max:360,unit:\"\\xb0\",hidden:props=>props.mode!=\"gradient\"}}},font:{type:\"font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:16,lineHeight:1}},animation:{type:ControlType.Object,icon:\"effect\",controls:{trigger:{type:ControlType.Enum,defaultValue:\"layerInView\",options:[\"appear\",\"layerInView\"],optionTitles:[\"Appear\",\"Layer in View\"],displaySegmentedControl:true,segmentedControlDirection:\"vertical\"},replay:{type:ControlType.Boolean,defaultValue:true,hidden(props){return props.trigger!==\"layerInView\";}},transition:{type:ControlType.Transition}}},prefix:{type:ControlType.String},suffix:{type:ControlType.String},textSelect:{type:ControlType.Boolean,defaultValue:true},display:{type:ControlType.Object,buttonTitle:\"Options\",description:\"Component from [LaunchNow Design](https://launchnow.design/?utm_source=codecomponent)\",controls:{monospace:{type:ControlType.Boolean,defaultValue:false,description:\"Monospaced number characters.\"},slashedZeros:{type:ControlType.Boolean,defaultValue:false,description:\"Adds a diagonal slash through zeros if your font supports it.\"}}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"NumberAnimator\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerSupportedLayoutHeight\":\"any\",\"framerContractVersion\":\"1\",\"framerDisableUnlink\":\"\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./NumberAnimator.map"],"mappings":"A,+PAIG,SAAwBoB,EAAeC,EAAM,CAAC,IAAMC,EAAItB,EAAO,IAAI,EAAQuB,EAASP,EAAUM,EAAI,CAAC,KAAK,CAACD,EAAM,UAAU,OAAO,OAAO,MAAM,CAAC,EAAO,CAACG,EAAWC,GAAexB,EAAS,EAAE,EAAO,CAACyB,QAAMC,MAAIC,WAASC,SAAOC,WAASC,YAAUC,aAAWX,EAAW,CAACY,EAAiBC,GAAqBjC,EAAS,IAAI,EAAQkC,EAASrB,EAAa,QAAQ,IAAIA,EAAa,OAAO,SAASsB,EAAaC,EAAM,CAAkB,IAAIC,EAAapC,EAAO,QAAQ0B,CAAQ,EAA6E,OAAxEC,IAAQS,EAAaA,EAAa,QAAQ,wBAAwB,GAAG,GAAUA,CAAa,CAAC,SAASC,GAAc,CAAKJ,IAAaF,GAAkBA,EAAiB,KAAK,EAAGC,EAAoBjB,EAAQS,EAAMC,EAAI,CAAC,GAAGK,EAAU,WAAW,SAASQ,GAAQ,CAACf,EAAcW,EAAaI,CAAM,CAAC,CAAE,CAAC,CAAC,CAAC,EAAG,CAA4X,OAA3XrC,MAAc,CAAI6B,EAAU,SAAS,UAAUO,EAAa,EAAGd,EAAcW,EAAaV,CAAK,CAAC,CAAE,EAAE,CAAC,C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