{"version":3,"file":"UrgencyTimer.Pq-C2QAc.mjs","names":["useState","useCallback","_Fragment"],"sources":["https:/framerusercontent.com/modules/dYT5OHM3GROnWmrQY7Ku/tZFuayHl3hUVBPZNaiSC/UrgencyTimer.js"],"sourcesContent":["// Urgency timer component that repeats and saves state in cookies\nimport{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{useState,useEffect,useCallback,startTransition}from\"react\";import{addPropertyControls,ControlType,useIsStaticRenderer}from\"framer\";/**\n * Urgency Timer Component\n * \n * A repeating countdown timer that saves state in cookies for consistency across sessions.\n * Perfect for creating urgency in sales, promotions, or time-sensitive content.\n *\n * @framerSupportedLayoutWidth any-prefer-fixed\n * @framerSupportedLayoutHeight any-prefer-fixed\n */export default function UrgencyTimer(props){const{hours=47,minutes=0,seconds=0,title=\"Limited Time Offer\",expiredMessage=\"Offer Expired!\",backgroundColor=\"#FFFFFF\",textColor=\"#374151\",accentColor=\"#111827\",titleFont,timerFont,messageFont,borderRadius=16,showProgress=true}=props;const isStatic=useIsStaticRenderer();const[timeLeft,setTimeLeft]=useState(0);const[isExpired,setIsExpired]=useState(false);const[totalDuration,setTotalDuration]=useState(0);// Cookie utilities\nconst setCookie=useCallback((name,value,days=365)=>{if(typeof document===\"undefined\")return;const expires=new Date;expires.setTime(expires.getTime()+days*24*60*60*1e3);document.cookie=`${name}=${value};expires=${expires.toUTCString()};path=/`;},[]);const getCookie=useCallback(name=>{if(typeof document===\"undefined\")return null;const nameEQ=name+\"=\";const ca=document.cookie.split(\";\");for(let i=0;i<ca.length;i++){let c=ca[i];while(c.charAt(0)===\" \")c=c.substring(1,c.length);if(c.indexOf(nameEQ)===0)return c.substring(nameEQ.length,c.length);}return null;},[]);// Initialize timer\nuseEffect(()=>{if(isStatic)return;const duration=hours*3600+minutes*60+seconds;setTotalDuration(duration);const cookieKey=`urgency-timer-${duration}`;const savedEndTime=getCookie(cookieKey);let endTime;if(savedEndTime){endTime=parseInt(savedEndTime,10);// Check if the saved timer has expired\nif(Date.now()>=endTime){// Timer expired, start a new cycle\nendTime=Date.now()+duration*1e3;setCookie(cookieKey,endTime.toString());}}else{// First time, create new timer\nendTime=Date.now()+duration*1e3;setCookie(cookieKey,endTime.toString());}const updateTimer=()=>{const now=Date.now();const remaining=Math.max(0,endTime-now);if(remaining===0||remaining<6e4){// Start new cycle immediately\nendTime=Date.now()+duration*1e3;setCookie(cookieKey,endTime.toString());startTransition(()=>{setIsExpired(false);setTimeLeft(duration);});}else{startTransition(()=>{setIsExpired(false);setTimeLeft(Math.ceil(remaining/1e3));});}};updateTimer();const interval=setInterval(updateTimer,1e3);return()=>clearInterval(interval);},[hours,minutes,seconds,isStatic,getCookie,setCookie]);// Format time display\nconst formatTime=useCallback(totalSeconds=>{const h=Math.floor(totalSeconds/3600);const m=Math.floor(totalSeconds%3600/60);const s=totalSeconds%60;if(h>0){return`${h.toString().padStart(2,\"0\")}:${m.toString().padStart(2,\"0\")}:${s.toString().padStart(2,\"0\")}`;}return`${m.toString().padStart(2,\"0\")}:${s.toString().padStart(2,\"0\")}`;},[]);// Format time labels\nconst formatTimeLabels=useCallback(totalSeconds=>{const h=Math.floor(totalSeconds/3600);const m=Math.floor(totalSeconds%3600/60);const s=totalSeconds%60;if(h>0){return[\"HOURS\",\"MINUTES\",\"SECONDS\"];}return[\"MINUTES\",\"SECONDS\"];},[]);// Calculate progress percentage\nconst progressPercentage=totalDuration>0?timeLeft/totalDuration*100:0;if(isStatic){const staticTime=hours*3600+minutes*60+seconds;return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,backgroundColor,borderRadius:16,padding:\"24px\",textAlign:\"center\",position:\"relative\",overflow:\"hidden\",boxShadow:backgroundColor===\"transparent\"||backgroundColor===\"rgba(0,0,0,0)\"?\"none\":\"0 2px 12px rgba(0,0,0,0.08)\",border:backgroundColor===\"transparent\"||backgroundColor===\"rgba(0,0,0,0)\"?\"1px solid rgba(0,0,0,0.1)\":\"none\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{...titleFont,color:textColor,marginBottom:\"16px\",fontSize:titleFont?.fontSize||\"16px\",opacity:.8},children:title}),/*#__PURE__*/_jsx(\"div\",{style:{...timerFont,color:\"#EF4444\",fontSize:timerFont?.fontSize||\"28px\",fontWeight:\"600\",marginBottom:\"8px\",fontFamily:\"ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace\",letterSpacing:\"0.05em\",animation:timeLeft<300?\"gentlePulse 2s ease-in-out infinite\":\"none\"},children:formatTime(staticTime)}),/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",justifyContent:\"space-between\",maxWidth:staticTime>=3600?\"180px\":\"120px\",margin:\"0 auto\",marginBottom:showProgress?\"16px\":\"0\"},children:formatTimeLabels(staticTime).map((label,index)=>/*#__PURE__*/_jsx(\"div\",{style:{fontSize:\"10px\",color:textColor,opacity:.6,fontWeight:\"500\",letterSpacing:\"0.5px\",textTransform:\"uppercase\",textAlign:\"center\",flex:1},children:label},label))}),showProgress&&/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"4px\",backgroundColor:\"#EF4444\",borderRadius:\"2px\",overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"div\",{style:{width:\"30%\",height:\"100%\",backgroundColor:accentColor,borderRadius:\"2px\",transition:\"width 1s ease-out\",opacity:.9}})})]});}return /*#__PURE__*/_jsxs(\"div\",{style:{...props.style,backgroundColor,borderRadius:16,padding:\"24px\",textAlign:\"center\",position:\"relative\",overflow:\"hidden\",boxShadow:backgroundColor===\"transparent\"||backgroundColor===\"rgba(0,0,0,0)\"?\"none\":\"0 2px 12px rgba(0,0,0,0.08)\",border:backgroundColor===\"transparent\"||backgroundColor===\"rgba(0,0,0,0)\"?\"1px solid rgba(0,0,0,0.1)\":\"none\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{...titleFont,color:textColor,marginBottom:\"16px\",fontSize:titleFont?.fontSize||\"16px\",opacity:.8},children:title}),isExpired?/*#__PURE__*/_jsx(\"div\",{style:{...messageFont,color:accentColor,fontSize:messageFont?.fontSize||\"20px\",fontWeight:\"500\",animation:\"fadeIn 0.5s ease-out\"},children:expiredMessage}):/*#__PURE__*/_jsxs(_Fragment,{children:[/*#__PURE__*/_jsx(\"div\",{style:{...timerFont,color:\"#EF4444\",fontSize:timerFont?.fontSize||\"28px\",fontWeight:\"600\",marginBottom:showProgress?\"16px\":\"0\",fontFamily:\"ui-monospace, 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace\",letterSpacing:\"0.05em\",animation:timeLeft<300?\"gentlePulse 2s ease-in-out infinite\":\"none\"},children:formatTime(timeLeft)}),showProgress&&/*#__PURE__*/_jsx(\"div\",{style:{width:\"100%\",height:\"4px\",backgroundColor:\"#EF4444\",borderRadius:\"2px\",overflow:\"hidden\"},children:/*#__PURE__*/_jsx(\"div\",{style:{width:`${progressPercentage}%`,height:\"100%\",backgroundColor:accentColor,borderRadius:\"2px\",transition:\"width 1s ease-out\",opacity:.9}})})]}),/*#__PURE__*/_jsx(\"style\",{children:`\n                    @keyframes fadeIn {\n                        from { opacity: 0; transform: translateY(4px); }\n                        to { opacity: 1; transform: translateY(0); }\n                    }\n                    @keyframes gentlePulse {\n                        0%, 100% { \n                            opacity: 1;\n                            transform: scale(1);\n                        }\n                        50% { \n                            opacity: 0.8;\n                            transform: scale(1.02);\n                        }\n                    }\n                `})]});}addPropertyControls(UrgencyTimer,{hours:{type:ControlType.Number,title:\"Hours\",defaultValue:47,min:0,max:999,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:0,min:0,max:59,step:1,displayStepper:true},title:{type:ControlType.String,title:\"Title\",defaultValue:\"Limited Time Offer\"},expiredMessage:{type:ControlType.String,title:\"Expired Message\",defaultValue:\"Offer Expired!\"},backgroundColor:{type:ControlType.Color,title:\"Background\",defaultValue:\"#FFFFFF\"},textColor:{type:ControlType.Color,title:\"Text Color\",defaultValue:\"#374151\"},accentColor:{type:ControlType.Color,title:\"Timer Color\",defaultValue:\"#111827\"},titleFont:{type:ControlType.Font,title:\"Title Font\",defaultValue:{fontSize:\"16px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.3em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},timerFont:{type:ControlType.Font,title:\"Timer Font\",defaultValue:{fontSize:\"28px\",variant:\"Semibold\",letterSpacing:\"0.05em\",lineHeight:\"1em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},messageFont:{type:ControlType.Font,title:\"Message Font\",defaultValue:{fontSize:\"20px\",variant:\"Medium\",letterSpacing:\"-0.01em\",lineHeight:\"1.2em\"},controls:\"extended\",defaultFontType:\"sans-serif\"},borderRadius:{type:ControlType.Number,title:\"Border Radius\",defaultValue:16,min:0,max:32,step:1,unit:\"px\"},showProgress:{type:ControlType.Boolean,title:\"Show Progress\",defaultValue:true,enabledTitle:\"Show\",disabledTitle:\"Hide\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"UrgencyTimer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\",\"framerSupportedLayoutWidth\":\"any-prefer-fixed\",\"framerSupportedLayoutHeight\":\"any-prefer-fixed\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./UrgencyTimer.map"],"mappings":"gUASG,SAAwB,EAAa,EAAM,CAAC,GAAK,CAAC,QAAM,GAAG,UAAQ,EAAE,UAAQ,EAAE,QAAM,qBAAqB,iBAAe,iBAAiB,kBAAgB,UAAU,YAAU,UAAU,cAAY,UAAU,YAAU,YAAU,cAAY,eAAa,GAAG,eAAa,GAAK,CAAC,EAAY,EAAS,IAA2B,CAAC,EAAS,EAAY,CAACA,EAAS,GAAQ,CAAC,EAAU,EAAa,CAACA,EAAS,IAAY,CAAC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