{"version":3,"file":"Countdown_IMC.CJs2GCYn.mjs","names":["React.useState","React.useRef","React.Fragment","__esmMin","x","te","init_npm_react_18_3_1","_e","de","init_jsx_runtime","p","ce","init_framer_CaDWdxiz","addPropertyControls","ControlType","Countdown","userScale","props","calculateTimeLeft","target","targetDate","now","difference","timeLeft","setTimeLeft","scale","setScale","containerRef","contentRef","timer","updateScale","containerWidth","contentWidth","newScale","resizeObserver","formatTime","time","outerContainerStyle","containerStyle","boxStyle","boxColor","strokeColor","borderRadius","numberBaseStyle","font","colonStyle","colonColor","timeUnits","customColor","index","daysColor","textColor","value","init_Countdown_IMC"],"sources":["https:/framerusercontent.com/modules/blzqcL9SZ0PSQ8IdF9oK/Z6fK6lbGJUg9E2O5iiCS/Countdown_IMC.js"],"sourcesContent":["// Countdown timer component with customizable colors and date target\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import*as React from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * @framerSupportedLayoutWidth any\n * @framerSupportedLayoutHeight any\n */export default function Countdown(props){const{targetDate,boxColor,strokeColor,textColor,daysColor,colonColor,font,scale:userScale,borderRadius}=props;function calculateTimeLeft(){const target=new Date(targetDate);const now=new Date;if(isNaN(target.getTime())){return{days:0,hours:0,minutes:0,seconds:0};}const difference=+target-+now;if(difference>0){return{days:Math.floor(difference/(1e3*60*60*24)),hours:Math.floor(difference/(1e3*60*60)%24),minutes:Math.floor(difference/1e3/60%60),seconds:Math.floor(difference/1e3%60)};}return{days:0,hours:0,minutes:0,seconds:0};}const[timeLeft,setTimeLeft]=React.useState(()=>calculateTimeLeft());const[scale,setScale]=React.useState(1);const containerRef=React.useRef(null);const contentRef=React.useRef(null);React.useEffect(()=>{const timer=setInterval(()=>{React.startTransition(()=>{setTimeLeft(calculateTimeLeft());});},1e3);return()=>clearInterval(timer);},[targetDate]);React.useEffect(()=>{const updateScale=()=>{if(containerRef.current&&contentRef.current){const containerWidth=containerRef.current.offsetWidth;const contentWidth=contentRef.current.offsetWidth;if(contentWidth>0){const newScale=Math.min(1,containerWidth/contentWidth);React.startTransition(()=>{setScale(newScale);});}}};updateScale();const resizeObserver=new ResizeObserver(updateScale);if(containerRef.current){resizeObserver.observe(containerRef.current);}return()=>{resizeObserver.disconnect();};},[]);const formatTime=time=>time<10?`0${time}`:time;const outerContainerStyle={width:\"100%\",height:\"100%\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",overflow:\"hidden\"};const containerStyle={display:\"flex\",alignItems:\"center\",width:\"max-content\",transform:`scale(${scale*userScale})`,transformOrigin:\"center center\"};const boxStyle={display:\"flex\",justifyContent:\"center\",alignItems:\"center\",width:\"64px\",height:\"64px\",backgroundColor:boxColor,border:`1.5px solid ${strokeColor}`,borderRadius:`${borderRadius}px`,boxSizing:\"border-box\"};const numberBaseStyle={...font};const colonStyle={...font,margin:\"0 6px\",display:\"flex\",alignItems:\"center\",height:\"64px\",color:colonColor};const timeUnits=[timeLeft.days,timeLeft.hours,timeLeft.minutes,timeLeft.seconds];return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:outerContainerStyle,children:/*#__PURE__*/_jsx(\"div\",{ref:contentRef,style:containerStyle,children:timeUnits.map((value,index)=>{const customColor=index===0?daysColor:textColor;return /*#__PURE__*/_jsxs(React.Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{style:boxStyle,children:/*#__PURE__*/_jsx(\"span\",{style:{...numberBaseStyle,color:customColor},children:formatTime(value||0)})}),index<timeUnits.length-1&&/*#__PURE__*/_jsx(\"span\",{style:colonStyle,children:\":\"})]},index);})})});}addPropertyControls(Countdown,{targetDate:{type:ControlType.String,title:\"Target Date\",defaultValue:\"2025-12-31T00:00:00\",placeholder:\"YYYY-MM-DDTHH:MM:SS\"},scale:{type:ControlType.Number,title:\"Scale\",defaultValue:.9,min:.1,max:2,step:.1},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:8,min:0,max:32,step:1,unit:\"px\"},boxColor:{type:ControlType.Color,title:\"Box Background\",defaultValue:\"#FFFFFF\"},strokeColor:{type:ControlType.Color,title:\"Border Color\",defaultValue:\"#000000\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},daysColor:{type:ControlType.Color,title:\"Days Color\",defaultValue:\"#FA0030\"},colonColor:{type:ControlType.Color,title:\"Colon Color\",defaultValue:\"#000000\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"24px\",variant:\"Semibold\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"Countdown\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutWidth\":\"any\",\"framerContractVersion\":\"1\",\"framerSupportedLayoutHeight\":\"any\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Countdown_IMC.map"],"mappings":"A,wMAIG,SAAwBe,EAAU,EAAM,CAAC,GAAK,CAAC,aAAW,WAAS,cAAY,YAAU,YAAU,aAAW,OAAK,MAAMC,EAAU,gBAAcC,EAAM,SAASC,GAAmB,CAAC,IAAMC,EAAO,IAAI,KAAKC,CAAU,EAAQC,kBAAI,IAAI,KAAK,GAAG,MAAMF,EAAO,QAAQ,CAAC,EAAG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAG,IAAMG,EAAW,CAACH,EAAQE,EAAoM,OAA7LC,EAAW,EAAS,CAAC,KAAK,KAAK,MAAMA,EAAY,KAAa,EAAE,MAAM,KAAK,MAAMA,EAAY,KAAW,EAAE,EAAE,QAAQ,KAAK,MAAMA,EAAW,IAAI,GAAG,EAAE,EAAE,QAAQ,KAAK,MAAMA,EAAW,IAAI,EAAE,CAAC,EAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAE,CAAC,GAAK,CAACC,EAASC,GAAaxB,MAAmBk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