{"version":3,"file":"Counter.CUdZgcbB.mjs","names":["useState","useMemo","_Fragment"],"sources":["https:/framerusercontent.com/modules/W2xGE54Zay1aIfsNX1yk/sjiiZGNK9czycd8NT0Kg/Counter.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";import{motion}from\"framer-motion\";import{useEffect,useMemo,useState}from\"react\";/**\n * @framerDisableUnlink\n *\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function Counter({number,direction,format,font,color,transition,animate,onCompleted}){const[formattedNumber,setFormattedNumber]=useState(number);const yFrom=direction===\"up\"?100:-100;const generateData=length=>{return[...Array.from({length},()=>[...Array(10).keys()])];};useEffect(()=>{setFormattedNumber(new Intl.NumberFormat(format.locale||document.documentElement.lang,{useGrouping:format.grouping,minimumFractionDigits:format.fractionDigits}).format(number));},[number]);const renderItems=useMemo(()=>{const data=generateData(formattedNumber.length);let delay=0;return data.map((item,rowIndex)=>{const current=formattedNumber[rowIndex];const isNumber=Number.isInteger(parseInt(current,10));// delay = Math.max(0, (data.length - rowIndex) / data.length)\ndelay=(data.length-1-rowIndex)/(data.length-1)*.4;return /*#__PURE__*/_jsx(_Fragment,{children:isNumber&&RenderTarget.current()!==RenderTarget.canvas?/*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",overflowY:\"clip\"},children:item.map((item,colIndex)=>{delay+=.1;let yTo;if(animate){if(item===Number(current)){yTo=0;}else{if(item>Number(current)){yTo=yFrom;}else{yTo=yFrom*-1;}}}else{yTo=item===0?0:yFrom;}const isLastDigit=rowIndex===data.length-1&&item===Number(current);return /*#__PURE__*/_jsx(motion.div,{style:colIndex>0?{position:\"absolute\",top:0,y:`${yFrom}%`}:undefined,transition:{...transition,delay:delay+transition.delay},whileInView:animate?{y:`${yTo}%`}:undefined,onAnimationComplete:()=>{if(isLastDigit&&onCompleted){onCompleted();/*setTimeout(\n                                                    () => onCompleted(),\n                                                    transition.delay\n                                                )*/}},viewport:{once:true},children:colIndex},colIndex);})},rowIndex):current});});},[animate,formattedNumber]);return /*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",fontFamily:font.fontFamily,fontWeight:font.fontWeight,fontStyle:font.fontStyle,fontSize:font.fontSize,lineHeight:font.lineHeight,letterSpacing:font.letterSpacing,fontVariant:\"tabular-nums\",color},children:[format.prefix&&/*#__PURE__*/_jsx(\"div\",{style:{whiteSpace:\"pre-wrap\"},children:format.prefix}),renderItems,format.suffix&&/*#__PURE__*/_jsx(\"div\",{style:{whiteSpace:\"pre-wrap\"},children:format.suffix})]});}addPropertyControls(Counter,{number:{type:ControlType.Number,displayStepper:true,defaultValue:99},direction:{type:ControlType.Enum,defaultValue:\"up\",options:[\"up\",\"down\"],optionTitles:[\"Up\",\"Down\"],displaySegmentedControl:true},format:{type:ControlType.Object,controls:{locale:{type:ControlType.String},fractionDigits:{type:ControlType.Number,defaultValue:0,min:0,max:20},grouping:{type:ControlType.Enum,defaultValue:\"auto\",segmentedControlDirection:\"vertical\",options:[\"auto\",\"always\",false],optionTitles:[\"Auto\",\"Always\",\"None\"]},prefix:{type:ControlType.String},suffix:{type:ControlType.String}}},font:{type:ControlType.Font,controls:\"extended\",displayFontSize:true,displayTextAlignment:false,defaultFontType:\"sans-serif\",defaultValue:{fontSize:16,lineHeight:1}},color:{type:ControlType.Color,defaultValue:\"#000\"},transition:{type:ControlType.Transition,defaultValue:{duration:.6,delay:0,ease:[.23,1,.32,1]},hidden(props){return!props.animate;}},animate:{type:ControlType.Boolean,enabledTitle:\"Yes\",disabledTitle:\"No\"},onCompleted:{type:ControlType.EventHandler}});Counter.displayName=\"002 Counter\";\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Counter\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\",\"framerDisable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