import type { Locale } from "./locales";

/**
 * Store the visitor's language choice.
 *
 * The proxy reads this cookie when deciding where `/` goes (Blueprint 03). One
 * year, same-site, no personal data — and it is described in the privacy
 * notice as the single technical cookie the site sets.
 *
 * It lives in its own module rather than inside the navigation component so
 * the write is a plain function call from an event handler.
 */
export function rememberLocale(locale: Locale): void {
  if (typeof document === "undefined") return;
  document.cookie = `lang=${locale}; path=/; max-age=31536000; samesite=lax`;
}
