const FOCUS_WORD_KEY = 'wordloop_focus_word_id'

export function setPracticeFocusWordId(wordId: number) {
  sessionStorage.setItem(FOCUS_WORD_KEY, String(wordId))
}

export function consumePracticeFocusWordId(): number | null {
  const raw = sessionStorage.getItem(FOCUS_WORD_KEY)
  sessionStorage.removeItem(FOCUS_WORD_KEY)
  if (!raw) return null
  const id = parseInt(raw, 10)
  return Number.isFinite(id) ? id : null
}
