// Tracks Reads completed in localStorage. Call markReadComplete() once a user
// has actually viewed a grade card or scan result — *not* on page load.
// InstallPrompt and PushPrompt use this counter to gate when they appear.

const READS_KEY = 'vyndr_reads_completed';

export function markReadComplete(): number {
  if (typeof window === 'undefined') return 0;
  const next = readsCompleted() + 1;
  window.localStorage.setItem(READS_KEY, String(next));
  return next;
}

export function readsCompleted(): number {
  if (typeof window === 'undefined') return 0;
  const raw = window.localStorage.getItem(READS_KEY);
  return raw ? parseInt(raw, 10) || 0 : 0;
}
