{"version":3,"file":"CountdownTimer.BU2EfcUU.mjs","names":["useState","useRef"],"sources":["https:/framerusercontent.com/modules/88SC8dKx3AVFGiuky5GA/ka7jTgq2jxVJZbRt7IeI/CountdownTimer.js"],"sourcesContent":["// Countdown timer that resets automatically with configurable time and font selection\nimport{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useState,startTransition,useRef}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * Countdown Timer\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 100\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function CountdownTimer(props){const{hours=1,minutes=0,seconds=23,backgroundColor=\"#000000\",textColor=\"#FFFFFF\",font,showDays=false,showHours=true,showMinutes=true,showSeconds=true,style}=props;const totalSeconds=hours*3600+minutes*60+seconds;const[timeLeft,setTimeLeft]=useState(totalSeconds);const containerRef=useRef(null);const[scale,setScale]=useState(1);useEffect(()=>{if(timeLeft<=0){startTransition(()=>setTimeLeft(totalSeconds));return;}const timer=setInterval(()=>{startTransition(()=>{setTimeLeft(prev=>{if(prev<=1){return totalSeconds;}return prev-1;});});},1e3);return()=>clearInterval(timer);},[timeLeft,totalSeconds]);useEffect(()=>{const updateScale=()=>{if(containerRef.current&&style?.width===\"100%\"){const containerWidth=containerRef.current.offsetWidth;const baseWidth=400;const newScale=containerWidth/baseWidth;startTransition(()=>setScale(newScale));}else{startTransition(()=>setScale(1));}};updateScale();if(typeof window!==\"undefined\"){window.addEventListener(\"resize\",updateScale);return()=>window.removeEventListener(\"resize\",updateScale);}},[style?.width]);const displayHours=Math.floor(timeLeft/3600);const displayMinutes=Math.floor(timeLeft%3600/60);const displaySeconds=timeLeft%60;const displayDays=Math.floor(timeLeft/86400);const displayHoursInDay=Math.floor(timeLeft%86400/3600);const formatNumber=num=>String(num).padStart(2,\"0\");// Build time string based on visibility toggles\nconst timeSegments=[];if(showDays){timeSegments.push(formatNumber(displayDays));if(showHours)timeSegments.push(formatNumber(displayHoursInDay));}else{if(showHours)timeSegments.push(formatNumber(displayHours));}if(showMinutes)timeSegments.push(formatNumber(displayMinutes));if(showSeconds)timeSegments.push(formatNumber(displaySeconds));const timeString=timeSegments.length>0?timeSegments.join(\":\"):\"00\";const isRelativeWidth=style?.width===\"100%\";// Extract base font size from font prop\nconst baseFontSize=typeof font?.fontSize===\"string\"?parseFloat(font.fontSize):typeof font?.fontSize===\"number\"?font.fontSize:80;// Calculate scaled font size\nconst scaledFontSize=isRelativeWidth?baseFontSize*scale:baseFontSize;return /*#__PURE__*/_jsx(\"div\",{ref:containerRef,style:{...style,width:\"100%\",height:\"100%\",display:\"flex\",alignItems:\"center\",justifyContent:\"center\",backgroundColor,overflow:\"hidden\",position:\"relative\"},children:/*#__PURE__*/_jsx(\"span\",{style:{color:textColor,...font,fontSize:`${scaledFontSize}px`,whiteSpace:\"nowrap\",transform:\"none\",transformOrigin:\"center\"},children:timeString})});}addPropertyControls(CountdownTimer,{showDays:{type:ControlType.Boolean,title:\"Show Days\",defaultValue:false,enabledTitle:\"On\",disabledTitle:\"Off\"},showHours:{type:ControlType.Boolean,title:\"Show Hours\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},showMinutes:{type:ControlType.Boolean,title:\"Show Minutes\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},showSeconds:{type:ControlType.Boolean,title:\"Show Seconds\",defaultValue:true,enabledTitle:\"On\",disabledTitle:\"Off\"},hours:{type:ControlType.Number,title:\"Hours\",defaultValue:1,min:0,max:23,step:1,displayStepper:true},minutes:{type:ControlType.Number,title:\"Minutes\",defaultValue:0,min:0,max:59,step:1,displayStepper:true},seconds:{type:ControlType.Number,title:\"Seconds\",defaultValue:23,min:0,max:59,step:1,displayStepper:true},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#000000\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#FFFFFF\"},font:{type:ControlType.Font,title:\"Font\",defaultValue:{fontSize:\"80px\",variant:\"Bold\",letterSpacing:\"-0.02em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountdownTimer\",\"slots\":[],\"annotations\":{\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerIntrinsicHeight\":\"100\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerIntrinsicWidth\":\"400\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CountdownTimer.map"],"mappings":"8MASG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,QAAM,EAAE,UAAQ,EAAE,UAAQ,GAAG,kBAAgB,UAAU,YAAU,UAAU,OAAK,WAAS,GAAM,YAAU,GAAK,cAAY,GAAK,cAAY,GAAK,SAAO,EAAY,EAAa,EAAM,KAAK,EAAQ,GAAG,EAAa,CAAC,EAAS,GAAaA,EAAS,EAAa,CAAO,EAAaC,EAAO,KAAK,CAAM,CAAC,EAAM,GAAUD,EAAS,EAAE,CAAC,MAAc,CAAC,GAAG,GAAU,EAAE,CAAC,MAAoB,EAAY,EAAa,CAAC,CAAC,OAAQ,IAAM,EAAM,gBAAgB,CAAC,MAAoB,CAAC,EAAY,GAAU,GAAM,EAAU,EAAqB,EAAK,EAAI,EAAG,EAAG,IAAI,CAAC,UAAU,cAAc,EAAM,EAAG,CAAC,EAAS,EAAa,CAAC,CAAC,MAAc,CAAC,IAAM,MAAgB,CAAC,GAAG,EAAa,SAAS,GAAO,QAAQ,OAAO,CAA2E,IAAM,EAA3D,EAAa,QAAQ,YAA4B,IAA4C,MAAoB,EAAS,EAAS,CAAC,MAAO,MAAoB,EAAS,EAAE,CAAC,EAAkB,GAAd,GAAa,CAAW,IAAS,OAA2D,OAA9C,EAAO,iBAAiB,SAAS,EAAY,KAAW,EAAO,oBAAoB,SAAS,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