/** Client-only guard so users do not hammer Supabase auth email endpoints. */ const STORAGE_KEY = "yaltopia_forgot_password_cooldown_until"; /** Minimum wait between reset attempts from this browser */ export const RESET_EMAIL_COOLDOWN_MS = 120_000; export function getResetEmailCooldownRemainingMs(): number { if (typeof window === "undefined") return 0; const until = Number(localStorage.getItem(STORAGE_KEY) || 0); return Math.max(0, until - Date.now()); } export function startResetEmailCooldown(): void { if (typeof window === "undefined") return; localStorage.setItem( STORAGE_KEY, String(Date.now() + RESET_EMAIL_COOLDOWN_MS) ); } export function formatCooldownSeconds(ms: number): number { return Math.ceil(ms / 1000); }