{"version":3,"file":"CountdownTimer.D0z4XTEE.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/MwDGY1L5V0LngtCroS7e/pioGp2GDgAJiCr3HLoEf/CountdownTimer.js"],"sourcesContent":["// CountdownTimer timer component that counts down to a specific date\nimport{jsx as _jsx,jsxs as _jsxs}from\"react/jsx-runtime\";import{useEffect,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/**\n * CountdownTimer Timer\n *\n * @framerIntrinsicWidth 400\n * @framerIntrinsicHeight 120\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function CountdownTimer(props){const{targetDate,showDays=true,showHours=true,showMinutes=true,showSeconds=true,backgroundColor,textColor,labelColor,font,labelFont,separator,gap=20,alignment=\"center\",textElement=\"div\"}=props;const[timeRemaining,setTimeRemaining]=useState({days:0,hours:0,minutes:0,seconds:0,isExpired:false});useEffect(()=>{if(typeof window===\"undefined\")return;const calculateTimeRemaining=()=>{const now=new Date().getTime();const target=new Date(targetDate).getTime();const difference=target-now;if(difference<=0){startTransition(()=>setTimeRemaining({days:0,hours:0,minutes:0,seconds:0,isExpired:true}));return;}const days=Math.floor(difference/(1e3*60*60*24));const hours=Math.floor(difference%(1e3*60*60*24)/(1e3*60*60));const minutes=Math.floor(difference%(1e3*60*60)/(1e3*60));const seconds=Math.floor(difference%(1e3*60)/1e3);startTransition(()=>setTimeRemaining({days,hours,minutes,seconds,isExpired:false}));};calculateTimeRemaining();const interval=setInterval(calculateTimeRemaining,1e3);return()=>clearInterval(interval);},[targetDate]);const formatNumber=num=>{return num.toString().padStart(2,\"0\");};const timeUnits=[{value:timeRemaining.days,label:\"Days\",show:showDays},{value:timeRemaining.hours,label:\"Hours\",show:showHours},{value:timeRemaining.minutes,label:\"Minutes\",show:showMinutes},{value:timeRemaining.seconds,label:\"Seconds\",show:showSeconds}].filter(unit=>unit.show);const isFixedWidth=props?.style&&props.style.width===\"100%\";const alignmentMap={left:\"flex-start\",center:\"center\",right:\"flex-end\"};const NumberElement=textElement;const LabelElement=textElement;return /*#__PURE__*/_jsx(\"div\",{style:{...props.style,position:\"relative\",...isFixedWidth?{...props?.style}:{minWidth:\"max-content\"},backgroundColor,display:\"flex\",alignItems:\"center\",justifyContent:alignmentMap[alignment],gap,padding:20,borderRadius:8},children:timeRemaining.isExpired?/*#__PURE__*/_jsx(NumberElement,{style:{...font,color:textColor,margin:0},children:\"Time's up!\"}):timeUnits.map((unit,index)=>/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",gap},children:[/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",alignItems:\"center\",gap:gap/2},children:[/*#__PURE__*/_jsx(NumberElement,{style:{...font,color:textColor,margin:0},children:formatNumber(unit.value)}),/*#__PURE__*/_jsx(LabelElement,{style:{...labelFont,color:labelColor,margin:0},children:unit.label})]}),index<timeUnits.length-1&&/*#__PURE__*/_jsx(NumberElement,{style:{...font,color:textColor,margin:0},children:separator})]},unit.label))});}addPropertyControls(CountdownTimer,{targetDate:{type:ControlType.Date,title:\"Target Date\",displayTime:true},textElement:{type:ControlType.Enum,title:\"Text Element\",options:[\"p\",\"h1\",\"h2\",\"h3\",\"h4\",\"h5\",\"h6\",\"span\",\"div\"],optionTitles:[\"P\",\"H1\",\"H2\",\"H3\",\"H4\",\"H5\",\"H6\",\"Span\",\"Div\"],defaultValue:\"div\",displaySegmentedControl:false},alignment:{type:ControlType.Enum,title:\"Alignment\",options:[\"left\",\"center\",\"right\"],optionTitles:[\"Left\",\"Center\",\"Right\"],defaultValue:\"center\",displaySegmentedControl:true},gap:{type:ControlType.Number,title:\"Gap\",defaultValue:20,min:0,max:100,step:1,unit:\"px\"},showDays:{type:ControlType.Boolean,title:\"Show Days\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},showHours:{type:ControlType.Boolean,title:\"Show Hours\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},showMinutes:{type:ControlType.Boolean,title:\"Show Minutes\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},showSeconds:{type:ControlType.Boolean,title:\"Show Seconds\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"},separator:{type:ControlType.String,title:\"Separator\",defaultValue:\":\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#000000\"},labelColor:{type:ControlType.Color,title:\"Label Color\",defaultValue:\"#CCCCCC\"},font:{type:ControlType.Font,title:\"Number Font\",defaultValue:{fontSize:\"40px\",variant:\"Bold\",letterSpacing:\"-0.04em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},labelFont:{type:ControlType.Font,title:\"Label Font\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountdownTimer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerIntrinsicHeight\":\"120\",\"framerIntrinsicWidth\":\"400\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CountdownTimer.map"],"mappings":"6MASG,SAAwB,EAAe,EAAM,CAAC,GAAK,CAAC,aAAW,WAAS,GAAK,YAAU,GAAK,cAAY,GAAK,cAAY,GAAK,kBAAgB,YAAU,aAAW,OAAK,YAAU,YAAU,MAAI,GAAG,YAAU,SAAS,cAAY,OAAO,EAAW,CAAC,EAAc,GAAkBA,EAAS,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,GAAM,CAAC,CAAC,MAAc,CAAC,GAAU,IAAS,OAAY,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