(() => { "use strict"; const root = document.getElementById("conferenceCountdown"); if (!root) return; const targetValue = root.dataset.eventDate; const targetTime = Date.parse(targetValue || ""); if (Number.isNaN(targetTime)) { console.warn("Conference countdown date is invalid:", targetValue); return; } const fields = { days: document.getElementById("days"), hours: document.getElementById("hours"), minutes: document.getElementById("minutes"), seconds: document.getElementById("seconds") }; const pad = (number, length = 2) => String(Math.max(0, number)).padStart(length, "0"); const render = () => { const remaining = Math.max(0, targetTime - Date.now()); const totalSeconds = Math.floor(remaining / 1000); const days = Math.floor(totalSeconds / 86400); const hours = Math.floor((totalSeconds % 86400) / 3600); const minutes = Math.floor((totalSeconds % 3600) / 60); const seconds = totalSeconds % 60; if (fields.days) fields.days.textContent = pad(days); if (fields.hours) fields.hours.textContent = pad(hours); if (fields.minutes) fields.minutes.textContent = pad(minutes); if (fields.seconds) fields.seconds.textContent = pad(seconds); root.setAttribute( "aria-label", remaining > 0 ? `${days} days, ${hours} hours, ${minutes} minutes and ${seconds} seconds until the conference` : "The conference countdown has ended" ); return remaining; }; render(); const timer = window.setInterval(() => { if (render() === 0) window.clearInterval(timer); }, 1000); })();