{"version":3,"file":"CountTimer.CuCb741B.mjs","names":["useState","useRef","_Fragment"],"sources":["https:/framerusercontent.com/modules/6qkOzDly50GDRYCqPL3B/cBDVlJtuurx3qK15Xoap/CountTimer.js"],"sourcesContent":["import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from\"react/jsx-runtime\";import{addPropertyControls,ControlType}from\"framer\";import{motion}from\"framer-motion\";import{useEffect,useRef,useState}from\"react\";// ─── localStorage helpers ─────────────────────────────────────────────────────\nfunction getDeadline(key){try{const raw=localStorage.getItem(key);return raw?parseInt(raw,10):null;}catch{return null;}}function setDeadline(key,ms){try{localStorage.setItem(key,String(ms));}catch{}}function clearDeadline(key){try{localStorage.removeItem(key);}catch{}}// ─── Single digit — re-mounts on change, plays enter animation ────────────────\nfunction FlipDigit({value}){return /*#__PURE__*/_jsx(motion.span,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.25,ease:[.16,1,.3,1]},style:{display:\"inline-block\",minWidth:\"0.55em\",textAlign:\"center\",fontSize:\"clamp(28px, 8vw, 52px)\",fontWeight:700,color:\"#b87d00\",lineHeight:1,letterSpacing:\"0.02em\",fontVariantNumeric:\"tabular-nums\"},children:value},value);}// ─── Time card ────────────────────────────────────────────────────────────────\nfunction TimeCard({value,label,index}){return /*#__PURE__*/_jsxs(motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{delay:index*.08,duration:.5,ease:[.16,1,.3,1]},whileHover:{scale:1.04,boxShadow:\"0 0 0 1px rgba(184,125,0,0.35), 0 8px 32px rgba(184,125,0,0.15)\"},style:{flex:1,position:\"relative\",display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",backgroundColor:\"#0d0d0d\",borderRadius:14,paddingTop:20,paddingBottom:16,paddingLeft:8,paddingRight:8,border:\"1px solid rgba(255,255,255,0.07)\",boxShadow:\"0 2px 8px rgba(0,0,0,0.45), 0 1px 2px rgba(0,0,0,0.6)\",overflow:\"hidden\",minWidth:0,cursor:\"default\"},children:[/*#__PURE__*/_jsx(\"div\",{style:{position:\"absolute\",top:0,left:\"20%\",right:\"20%\",height:2,borderRadius:\"0 0 4px 4px\",background:\"linear-gradient(90deg, transparent, #b87d00, transparent)\",opacity:.7}}),/*#__PURE__*/_jsxs(\"div\",{style:{display:\"flex\",flexDirection:\"row\",alignItems:\"center\",justifyContent:\"center\",gap:2,minHeight:56},children:[/*#__PURE__*/_jsx(FlipDigit,{value:value[0]}),/*#__PURE__*/_jsx(FlipDigit,{value:value[1]})]}),/*#__PURE__*/_jsx(\"span\",{style:{marginTop:10,fontSize:13,color:\"rgba(184,125,0,0.65)\",fontWeight:600,letterSpacing:\"0.05em\",userSelect:\"none\",fontFamily:\"'Noto Kufi Arabic', 'Segoe UI', Tahoma, Arial, sans-serif\"},children:label})]});}// ─── Pulsing separator ────────────────────────────────────────────────────────\nfunction Separator(){return /*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"column\",alignItems:\"center\",justifyContent:\"center\",gap:6,paddingLeft:10,paddingRight:10,paddingBottom:18,flexShrink:0},children:[0,1].map(i=>/*#__PURE__*/_jsx(motion.div,{animate:{opacity:[1,.2,1]},transition:{repeat:Infinity,duration:1.4,ease:\"easeInOut\",delay:i*.2},style:{width:5,height:5,borderRadius:\"50%\",backgroundColor:\"#b87d00\"}},i))});}// ─── Main component ───────────────────────────────────────────────────────────\nexport default function CountdownTimer({initialHours=24,storageKey=\"framer_countdown_deadline\",width=\"100%\",height=\"auto\"}){const totalMs=Math.max(1,Math.floor(initialHours))*3600*1e3;// Calculate initial timeLeft from stored deadline or create a new one\nfunction resolveInitialSeconds(){const stored=getDeadline(storageKey);if(stored!==null){const remaining=Math.floor((stored-Date.now())/1e3);if(remaining>0){// Valid ongoing timer — resume from remaining time\nreturn remaining;}else{// Expired — clear and start fresh\nclearDeadline(storageKey);}}// No stored deadline — create one and save it\nconst deadline=Date.now()+totalMs;setDeadline(storageKey,deadline);return Math.floor(totalMs/1e3);}const[timeLeft,setTimeLeft]=useState(resolveInitialSeconds);const intervalRef=useRef(null);// When initialHours prop changes on canvas, start fresh\nuseEffect(()=>{const stored=getDeadline(storageKey);// Only reset if no valid deadline exists\nif(!stored||stored<=Date.now()){const deadline=Date.now()+totalMs;setDeadline(storageKey,deadline);setTimeLeft(Math.floor(totalMs/1e3));}},[totalMs,storageKey]);// Tick — always derive timeLeft from deadline to stay accurate\nuseEffect(()=>{if(intervalRef.current)clearInterval(intervalRef.current);intervalRef.current=setInterval(()=>{const stored=getDeadline(storageKey);if(!stored){// No deadline in storage — create fresh\nconst deadline=Date.now()+totalMs;setDeadline(storageKey,deadline);setTimeLeft(Math.floor(totalMs/1e3));return;}const remaining=Math.floor((stored-Date.now())/1e3);if(remaining<=0){// Timer expired — clear storage, show 00:00:00\nclearDeadline(storageKey);setTimeLeft(0);if(intervalRef.current)clearInterval(intervalRef.current);}else{setTimeLeft(remaining);}},1e3);return()=>{if(intervalRef.current)clearInterval(intervalRef.current);};},[totalMs,storageKey]);const pad=n=>String(n).padStart(2,\"0\");const units=[{value:pad(Math.floor(timeLeft/3600)),label:\"ساعة\"},{value:pad(Math.floor(timeLeft%3600/60)),label:\"دقيقة\"},{value:pad(timeLeft%60),label:\"ثانية\"}];return /*#__PURE__*/_jsx(\"div\",{style:{direction:\"ltr\",display:\"flex\",justifyContent:\"center\",alignItems:\"center\",width,height,padding:16,backgroundColor:\"transparent\",fontFamily:\"'Noto Kufi Arabic', 'Segoe UI', Tahoma, Arial, sans-serif\",boxSizing:\"border-box\"},children:/*#__PURE__*/_jsx(\"div\",{style:{display:\"flex\",flexDirection:\"row\",alignItems:\"center\",justifyContent:\"center\",width:\"100%\",maxWidth:520},children:units.map((unit,i)=>/*#__PURE__*/_jsxs(_Fragment,{children:[i>0&&/*#__PURE__*/_jsx(Separator,{},`sep-${i}`),/*#__PURE__*/_jsx(TimeCard,{value:unit.value,label:unit.label,index:i},unit.label)]}))})});}// ─── Framer property controls ─────────────────────────────────────────────────\naddPropertyControls(CountdownTimer,{initialHours:{type:ControlType.Number,title:\"⏱ Hours\",defaultValue:24,min:1,max:999,step:1,displayStepper:true},storageKey:{type:ControlType.String,title:\"🔑 Storage Key\",defaultValue:\"framer_countdown_deadline\",placeholder:\"framer_countdown_deadline\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"CountdownTimer\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./CountTimer.map"],"mappings":"uPACA,SAAS,EAAY,EAAI,CAAC,GAAG,CAAC,IAAM,EAAI,aAAa,QAAQ,EAAI,CAAC,OAAO,EAAI,SAAS,EAAI,GAAG,CAAC,UAAW,CAAC,OAAO,MAAO,SAAS,EAAY,EAAI,EAAG,CAAC,GAAG,CAAC,aAAa,QAAQ,EAAI,OAAO,EAAG,CAAC,MAAO,GAAG,SAAS,EAAc,EAAI,CAAC,GAAG,CAAC,aAAa,WAAW,EAAI,MAAO,GAC1Q,SAAS,EAAU,CAAC,SAAO,CAAC,OAAoB,EAAK,EAAO,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,QAAQ,eAAe,SAAS,SAAS,UAAU,SAAS,SAAS,yBAAyB,WAAW,IAAI,MAAM,UAAU,WAAW,EAAE,cAAc,SAAS,mBAAmB,eAAe,CAAC,SAAS,EAAM,CAAC,EAAM,CACjY,SAAS,EAAS,CAAC,QAAM,QAAM,SAAO,CAAC,OAAoB,EAAM,EAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAM,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