`).join('');
}
update() {
const now = new Date().getTime();
const distanceToStart = this.targetDate.getTime() - now;
const distanceToEnd = this.endDate.getTime() - now;
// Se passou do fim do evento
if (distanceToEnd 0) {
this.happening();
return;
}
// Countdown normal antes do evento
const values = {
days: Math.floor(distanceToStart / (1000 * 60 * 60 * 24)),
hours: Math.floor((distanceToStart % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)),
minutes: Math.floor((distanceToStart % (1000 * 60 * 60)) / (1000 * 60))
};
Object.keys(values).forEach(unit => {
const element = this.container.querySelector(`[data-unit="${unit}"]`);
if (element) {
const newValue = this.padZero(values[unit]);
if (this.isInitialized && this.previousValues[unit] !== newValue) {
this.animateChange(element, newValue);
} else {
element.textContent = newValue;
}
this.previousValues[unit] = newValue;
}
});
}
animateChange(element, newValue) {
element.classList.add('flip', 'flash');
setTimeout(() => {
element.textContent = newValue;
}, 300);
setTimeout(() => {
element.classList.remove('flip', 'flash');
}, 600);
}
padZero(num) {
return num.toString().padStart(2, '0');
}
formatEventDate() {
const weekdayFmt = new Intl.DateTimeFormat('pt-BR', { weekday: 'long' });
const dateFmt = new Intl.DateTimeFormat('pt-BR', {
day: 'numeric',
month: 'long',
year: 'numeric'
});
let weekday = weekdayFmt.format(this.targetDate);
weekday = weekday.charAt(0).toUpperCase() + weekday.slice(1);
const dateStr = dateFmt.format(this.targetDate);
const h = this.padZero(this.config.hour);
const m = this.padZero(this.config.minute);
const timeStr = `${h}h${m}`;
return { weekday, dateStr, timeStr };
}
createEventInfo() {
const { weekday, dateStr, timeStr } = this.formatEventDate();
const timeAria = timeStr.replace(/h(\d{2})/, (_, m) =>
m === '00' ? ' horas' : ` horas e ${m} minutos`);
const ariaLabel = `Evento em ${weekday.toLowerCase()}, ${dateStr}, às ${timeAria}`;
// Linha única de referência factual: "10 de junho de 2026 · 19h00"
const dateLine = document.createElement('p');
dateLine.className = 'event-info-line';
dateLine.setAttribute('role', 'text');
dateLine.setAttribute('aria-label', ariaLabel);
dateLine.innerHTML = `${dateStr}
·${timeStr}`;
this.wrapper.insertBefore(dateLine, this.container);
// Linha de local: "Ável Lounge | Rua Mostardeiro 266 / Moinhos de Vento - Porto Alegre/RS"
const { venue, street, area } = this.config.location;
const locationLine = document.createElement('p');
locationLine.className = 'event-info-line event-info-line--location';
locationLine.setAttribute('role', 'text');
locationLine.setAttribute('aria-label', `Local: ${venue}, ${street}, ${area}`);
locationLine.innerHTML = `${venue}
|${street}
${area}`;
this.wrapper.insertBefore(locationLine, this.container);
}
happening() {
if(this.intervalId) clearInterval(this.intervalId);
this.container.innerHTML = `
${this.config.happeningTitle}
`;
// Continua verificando se o evento terminou
this.intervalId = setInterval(() => {
const now = new Date().getTime();
const distanceToEnd = this.endDate.getTime() - now;
if (distanceToEnd
${this.config.finishedTitle}
`;
}
}
(function() {
function init() {
try {
new AvelCountdown(COUNTDOWN_CONFIG);
} catch(e) {
console.error('Countdown error:', e);
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();