// assets/scripts/utils.js const ESCAPES = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; export const ANIMATION_MS = 280; export const FADE_MS = 180; export const MINUTES_PER_DAY = 1440; export function esc(str) { return String(str ?? '').replace(/[&<>"']/g, c => ESCAPES[c]); } export function createTranslator(namespace, defaults = {}) { return (key) => window[namespace]?.i18n?.[key] ?? defaults[key] ?? key; } export function removeWithAnimation(el, className) { el.classList.add(className); setTimeout(() => el.remove(), ANIMATION_MS); } export function animateIn(el, className) { requestAnimationFrame(() => requestAnimationFrame(() => { el.classList.remove(className); })); }