{"version":3,"file":"Timer.DBBpzAdn.mjs","names":["useState"],"sources":["https:/framerusercontent.com/modules/oOWgPPFYYBrU0LY0533F/sQ611WMb0sIjidFNLK5N/Timer.js"],"sourcesContent":["/**\n * @framerDisableUnlink\n * @framerIntrinsicWidth 200\n * @framerIntrinsicHeight 50\n */import{jsx as _jsx}from\"react/jsx-runtime\";import{useState,useEffect}from\"react\";import{addPropertyControls,ControlType}from\"framer\";// --------------------------------------------------------------------\n// Shared Timer Singleton Logic\n// --------------------------------------------------------------------\n// We'll store a global list of \"subscribers\" that each get updated\n// whenever the countdown changes. This way, multiple instances of\n// the component can share the same timer and remain in sync.\nlet timerSubscribers=[];let timerInterval=null;/**\n * Calculate the number of seconds from now until midnight (00:00).\n */function getSecondsUntilMidnight(){const now=new Date;const midnight=new Date;midnight.setHours(24,0,0,0)// 24:00 of the current day\n;const diff=midnight.getTime()-now.getTime();return Math.max(0,Math.floor(diff/1e3));}/**\n * Start a shared interval that updates all subscribers once per second.\n * If the interval is already running, we do nothing.\n */function startSharedTimer(){if(!timerInterval){timerInterval=setInterval(()=>{const secondsLeft=getSecondsUntilMidnight();// Update each subscriber (each component instance)\ntimerSubscribers.forEach(callback=>callback(secondsLeft));},1e3);}}/**\n * Subscribe a callback to the shared timer.\n * Returns an unsubscribe function.\n */function subscribeToTimer(callback){timerSubscribers.push(callback);// Immediately invoke with current seconds left\ncallback(getSecondsUntilMidnight());// Start the shared timer if not already started\nstartSharedTimer();// Unsubscribe logic\nreturn()=>{timerSubscribers=timerSubscribers.filter(cb=>cb!==callback);// If no one is left subscribed, clear the interval\nif(timerSubscribers.length===0&&timerInterval){clearInterval(timerInterval);timerInterval=null;}};}/**\n * Helper to format seconds as HH:MM:SS.\n */function formatTime(seconds){const hours=Math.floor(seconds/3600);const minutes=Math.floor(seconds%3600/60);const secs=seconds%60;return[String(hours).padStart(2,\"0\"),String(minutes).padStart(2,\"0\"),String(secs).padStart(2,\"0\")].join(\":\");}/**\n * TimerComponent:\n * - Displays the time remaining until midnight.\n * - Multiple instances on the same page stay in sync automatically.\n */export default function TimerComponent(props){const{fontSize,fontColor,fontFamily,style}=props;// Local state that stores the current countdown value\nconst[secondsLeft,setSecondsLeft]=useState(getSecondsUntilMidnight());// Subscribe to the shared timer when the component mounts\nuseEffect(()=>{const unsubscribe=subscribeToTimer(setSecondsLeft);return unsubscribe;},[]);return /*#__PURE__*/_jsx(\"div\",{style:{fontSize,color:fontColor,fontFamily,...style},children:formatTime(secondsLeft)});}// --------------------------------------------------------------------\n// Default Props & Property Controls\n// --------------------------------------------------------------------\nTimerComponent.defaultProps={fontSize:24,fontColor:\"#000000\",fontFamily:\"Arial\",style:{}};addPropertyControls(TimerComponent,{fontSize:{type:ControlType.Number,title:\"Font Size\",defaultValue:24,min:10,max:100,unit:\"px\",displayStepper:true},fontColor:{type:ControlType.Color,title:\"Font Color\",defaultValue:\"#000000\"},fontFamily:{type:ControlType.String,title:\"Font Family\",defaultValue:\"Arial\"}});\nexport const __FramerMetadata__ = {\"exports\":{\"default\":{\"type\":\"reactComponent\",\"name\":\"TimerComponent\",\"slots\":[],\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./Timer.map"],"mappings":"0QAYG,SAAS,GAAyB,CAAC,IAAM,EAAI,IAAI,KAAW,EAAS,IAAI,KAAK,EAAS,SAAS,GAAG,EAAE,EAAE,EAAE,CAC3G,IAAM,EAAK,EAAS,SAAS,CAAC,EAAI,SAAS,CAAC,OAAO,KAAK,IAAI,EAAE,KAAK,MAAM,EAAK,IAAI,CAAC,CAGjF,SAAS,GAAkB,CAAC,AAAmB,IAAc,gBAAgB,CAAC,IAAM,EAAY,GAAyB,CAC5H,EAAiB,QAAQ,GAAU,EAAS,EAAY,CAAC,EAAG,IAAI,CAG7D,SAAS,EAAiB,EAAS,CAGtC,OAHuC,EAAiB,KAAK,EAAS,CACtE,EAAS,GAAyB,CAAC,CACnC,GAAkB,KACR,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