{"version":3,"file":"Custom_Countown.DzGrFbus.mjs","names":["useState","useCallback","_Fragment"],"sources":["https:/framerusercontent.com/modules/h4CVs7BScvOAJww4XnXS/CWn0W2ijEl6TgUC0lMMf/Custom_Countown.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect,useCallback}from\"react\";import{addPropertyControls,ControlType,RenderTarget}from\"framer\";// Constants\nconst fontStack=`\"Inter\", system-ui, -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\"`;// Helper Functions\nconst calculateTimeLeft=(difference,digitCount)=>{if(difference>0){return{days:minTwoDigits(Math.floor(difference/(1e3*60*60*24)),digitCount),hours:minTwoDigits(Math.floor(difference/(1e3*60*60)%24),digitCount),minutes:minTwoDigits(Math.floor(difference/1e3/60%60),digitCount),seconds:minTwoDigits(Math.floor(difference/1e3%60),digitCount)};}return{days:0,hours:0,minutes:0,seconds:0};};function useForceRender(){const[,set]=useState(0);return useCallback(()=>set(v=>v+1),[]);}function minTwoDigits(number,digitCount){return digitCount?number:(number<10?\"0\":\"\")+number;}function wrapInSpan(colorValue,string,font){return /*#__PURE__*/_jsx(\"span\",{style:{color:colorValue,...font},children:string});}function createCountdownString(timeLeft,displayOptions,labels,spacing,labelColor,labelFont){let days=/*#__PURE__*/_jsxs(_Fragment,{children:[timeLeft.days,spacing.space,displayOptions.showHours?wrapInSpan(labelColor,`:`,labelFont):``]});let hours=displayOptions.showHours?/*#__PURE__*/_jsxs(_Fragment,{children:[timeLeft.hours,spacing.space,displayOptions.showMinutes?wrapInSpan(labelColor,`:`,labelFont):``]}):``;let minutes=displayOptions.showHours&&displayOptions.showMinutes?/*#__PURE__*/_jsxs(_Fragment,{children:[timeLeft.minutes,spacing.space,displayOptions.showSeconds?wrapInSpan(labelColor,`:`,labelFont):``]}):``;let seconds=displayOptions.showHours&&displayOptions.showMinutes&&displayOptions.showSeconds?timeLeft.seconds:``;if(!spacing.labelType){days=/*#__PURE__*/_jsxs(_Fragment,{children:[timeLeft.days,spacing.spaceForLabel,wrapInSpan(labelColor,labels.dayLabel,labelFont)]});hours=displayOptions.showHours?/*#__PURE__*/_jsxs(_Fragment,{children:[timeLeft.hours,spacing.spaceForLabel,wrapInSpan(labelColor,labels.hourLabel,labelFont)]}):``;minutes=displayOptions.showMinutes?/*#__PURE__*/_jsxs(_Fragment,{children:[timeLeft.minutes,spacing.spaceForLabel,wrapInSpan(labelColor,labels.minuteLabel,labelFont)]}):``;seconds=displayOptions.showSeconds?/*#__PURE__*/_jsxs(_Fragment,{children:[timeLeft.seconds,spacing.spaceForLabel,wrapInSpan(labelColor,labels.secondLabel,labelFont)]}):``;}return /*#__PURE__*/_jsxs(_Fragment,{children:[days,spacing.space,hours,spacing.space,minutes,spacing.space,seconds]});}// CountdownTimer Component\nexport default function CountdownTimer(props){const{date,pickTime,numberFont,labelFont,color,labelColor,displayProps,onComplete}=props;const{digitCount,labelType,numberSpace,labelSpace,dayLabel,hourLabel,minuteLabel,secondLabel,showHours,showMinutes,showSeconds,tabularFont}=displayProps;const{fontSize,fontFamily,fontWeight,fontStyle,textAlign,letterSpacing,lineHeight}=numberFont;const[visible,setIsVisible]=useState(false);const difference=+new Date(date).setUTCHours(pickTime)-+new Date;if(difference<=0){onComplete===null||onComplete===void 0?void 0:onComplete();}const isCanvas=RenderTarget.current()===RenderTarget.canvas;const render=useForceRender();useEffect(()=>{setIsVisible(true);if(isCanvas)return;const int=setInterval(()=>{render();},1e3);return()=>{clearInterval(int);};},[]);const timeLeft=calculateTimeLeft(difference,digitCount);const space=numberSpace?\"\":\" \";const spaceForLabel=labelSpace?\"\":\" \";const emptyString=`00:00:00:00`;const timeString=createCountdownString(timeLeft,{showHours,showMinutes,showSeconds},{dayLabel,hourLabel,minuteLabel,secondLabel},{space,spaceForLabel,labelType},labelColor,labelFont);return /*#__PURE__*/_jsx(\"p\",{suppressHydrationWarning:true,style:{color,fontFamily:fontStack,fontWeight:500,fontSize:16,lineHeight:1,...numberFont,margin:0,padding:0,visibility:visible?\"visible\":\"hidden\",fontVariantNumeric:tabularFont?\"tabular-nums\":\"normal\",whiteSpace:\"nowrap\"},children:difference>0?timeString:emptyString});}CountdownTimer.displayName=\"Countdown\";// Default Date Value\nconst defaultDate=new Date;defaultDate.setDate(defaultDate.getDate()+2);// Property Controls\naddPropertyControls(CountdownTimer,{date:{type:ControlType.Date,title:\"Date\",defaultValue:defaultDate.toISOString()},pickTime:{type:ControlType.Number,min:0,max:24,defaultValue:0,step:1,displayStepper:true,title:\"UTC\",unit:\":00\"},displayProps:{type:ControlType.Object,title:\"Style\",buttonTitle:\"Dots, Labels\",icon:\"boolean\",controls:{digitCount:{title:\"Digits\",type:ControlType.Boolean,enabledTitle:\"One\",disabledTitle:\"Two\",defaultValue:false},labelType:{title:\"Type\",type:ControlType.Boolean,enabledTitle:\"Dots\",disabledTitle:\"Custom\",defaultValue:true},numberSpace:{type:ControlType.Boolean,title:\"Number\",enabledTitle:\"Auto\",disabledTitle:\"Space\",defaultValue:false},labelSpace:{type:ControlType.Boolean,title:\"Label\",enabledTitle:\"Auto\",disabledTitle:\"Space\",defaultValue:true,hidden:props=>props.labelType},dayLabel:{type:ControlType.String,title:\"Days\",defaultValue:\"D\",placeholder:\"D\",hidden:props=>props.labelType},showHours:{title:\"Hours\",type:ControlType.Boolean,enabledTitle:\"Show\",disabledTitle:\"Hide\",defaultValue:true},hourLabel:{type:ControlType.String,title:\" \",defaultValue:\"H\",placeholder:\"H\",hidden:props=>props.labelType||!props.showHours},showMinutes:{title:\"Minutes\",type:ControlType.Boolean,enabledTitle:\"Show\",disabledTitle:\"Hide\",defaultValue:true,hidden:props=>!props.showHours},minuteLabel:{type:ControlType.String,title:\" \",defaultValue:\"M\",placeholder:\"M\",hidden:props=>props.labelType||!props.showHours||!props.showMinutes},showSeconds:{title:\"Seconds\",type:ControlType.Boolean,enabledTitle:\"Show\",disabledTitle:\"Hide\",defaultValue:true,hidden:props=>!props.showHours||!props.showMinutes},secondLabel:{type:ControlType.String,title:\" \",defaultValue:\"S\",placeholder:\"S\",hidden:props=>props.labelType||!props.showHours||!props.showMinutes||!props.showSeconds},tabularFont:{title:\"Tabular\",type:ControlType.Boolean,defaultValue:true}}},numberFont:{type:ControlType.Font,title:\"Number Font\",controls:\"extended\"},labelFont:{type:ControlType.Font,title:\"Label Font\",controls:\"extended\"},color:{type:ControlType.Color,defaultValue:\"#999\"},labelColor:{title:\"Label\",type:ControlType.Color,defaultValue:\"rgba(153,153,153,0.5)\"},onComplete:{type:ControlType.EventHandler}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountdownTimer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Custom_Countown.map"],"mappings":"6MAEmY,SAAS,GAAgB,CAAC,GAAK,EAAE,GAAKA,EAAS,EAAE,CAAC,OAAOC,MAAgB,EAAI,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,CAAE,SAAS,EAAa,EAAO,EAAW,CAAC,OAAO,EAAW,GAAQ,EAAO,GAAG,IAAI,IAAI,EAAQ,SAAS,EAAW,EAAW,EAAO,EAAK,CAAC,OAAoB,EAAK,OAAO,CAAC,MAAM,CAAC,MAAM,EAAW,GAAG,EAAK,CAAC,SAAS,EAAO,CAAC,CAAE,SAAS,EAAsB,EAAS,EAAe,EAAO,EAAQ,EAAW,EAAU,CAAC,IAAI,EAAkB,EAAMC,EAAU,CAAC,SAAS,CAAC,EAAS,KAAK,EAAQ,MAAM,EAAe,UAAU,EAAW,EAAW,IAAI,EAAU,CAAC,GAAG,CAAC,CAAC,CAAK,EAAM,EAAe,UAAuB,EAAMA,EAAU,CAAC,SAAS,CAAC,EAAS,MAAM,EAAQ,MAAM,EAAe,YAAY,EAAW,EA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