{"version":3,"file":"CountdownBanner.CWpIBcAI.mjs","names":["useMemo","useState"],"sources":["https:/framerusercontent.com/modules/d50luGI23y4AZ1NsVLJ6/2TMSLwz1MVoxKqQF3eUW/CountdownBanner.js"],"sourcesContent":["import{jsx as _jsx}from\"react/jsx-runtime\";import{useEffect,useMemo,useState,startTransition}from\"react\";import{addPropertyControls,ControlType}from\"framer\";/*\nUser instructions: Create a Framer component that looks like the provided countdown image and behaves as a countdown timer.\n\n@framerIntrinsicWidth 280\n@framerIntrinsicHeight 24\n\n@framerSupportedLayoutWidth any-prefer-fixed\n@framerSupportedLayoutHeight any-prefer-fixed\n*/export default function CountdownBanner(props){const{label,endTime,showEndedMessage,endedLabel,backgroundColor,textColor,font,style}=props;const initialTarget=useMemo(()=>{if(endTime){const parsed=new Date(endTime);if(!isNaN(parsed.getTime()))return parsed.getTime();}return Date.now()+30*60*1e3;},[endTime]);const[targetTime,setTargetTime]=useState(initialTarget);const[now,setNow]=useState(Date.now());useEffect(()=>{startTransition(()=>setTargetTime(initialTarget));},[initialTarget]);useEffect(()=>{if(typeof window===\"undefined\")return;const id=window.setInterval(()=>{const current=Date.now();startTransition(()=>setNow(current));},1e3);return()=>{if(typeof window!==\"undefined\"){window.clearInterval(id);}};},[]);const remainingMs=Math.max(0,targetTime-now);const{days,hours,minutes,seconds}=useMemo(()=>{const totalSeconds=Math.floor(remainingMs/1e3);const d=Math.floor(totalSeconds/86400);const h=Math.floor(totalSeconds%86400/3600);const m=Math.floor(totalSeconds%3600/60);const s=totalSeconds%60;return{days:d,hours:h,minutes:m,seconds:s};},[remainingMs]);const pad2=n=>n<10?`0${n}`:`${n}`;const countdownText=remainingMs===0&&showEndedMessage?endedLabel:`${label} ${pad2(days)}d : ${pad2(hours)}h : ${pad2(minutes)}m : ${pad2(seconds)}s`;const isFixedWidth=style&&style.width===\"100%\";return /*#__PURE__*/_jsx(\"div\",{style:{position:\"relative\",display:\"inline-flex\",alignItems:\"center\",justifyContent:\"center\",padding:0,backgroundColor,color:textColor,whiteSpace:\"nowrap\",...isFixedWidth?{width:\"100%\"}:{width:\"max-content\"},...font,...style},\"aria-live\":\"polite\",role:\"status\",children:/*#__PURE__*/_jsx(\"span\",{children:countdownText})});}addPropertyControls(CountdownBanner,{label:{type:ControlType.String,title:\"Prefix\",defaultValue:\"This offer ends in\"},endTime:{type:ControlType.Date,title:\"End Time\",displayTime:true,defaultValue:new Date(Date.now()+30*60*1e3).toJSON()},showEndedMessage:{type:ControlType.Boolean,title:\"When Ended\",defaultValue:true,enabledTitle:\"Show Text\",disabledTitle:\"Stay at 00:00\"},endedLabel:{type:ControlType.String,title:\"Ended Text\",defaultValue:\"This offer has ended\",hidden:props=>!props.showEndedMessage},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#F5FFFF\"},textColor:{type:ControlType.Color,title:\"Text\",defaultValue:\"#FF3B00\"},font:{type:ControlType.Font,title:\"Font\",controls:\"extended\",defaultFontType:\"sans-serif\",defaultValue:{fontSize:\"14px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"}}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountdownBanner\",\"slots\":[],\"annotations\":{\"framerIntrinsicWidth\":\"280\",\"framerIntrinsicHeight\":\"24\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CountdownBanner.map"],"mappings":"8MAQE,SAAwB,EAAgB,EAAM,CAAC,GAAK,CAAC,QAAM,UAAQ,mBAAiB,aAAW,kBAAgB,YAAU,OAAK,SAAO,EAAY,EAAcA,MAAY,CAAC,GAAG,EAAQ,CAAC,IAAM,EAAO,IAAI,KAAK,EAAQ,CAAC,GAAG,CAAC,MAAM,EAAO,SAAS,CAAC,CAAC,OAAO,EAAO,SAAS,CAAE,OAAO,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