"use client"; /** * Hand-off from a homework result to the New deck flow: the content travels in * sessionStorage and the wizard picks it up on mount, with the options step * pre-filled. One-shot, like the share-target payload. */ export type DeckSeed = { text: string; difficulty?: "easy" | "medium" | "hard"; count?: number; /** Wizard step to land on (chat's "turn into flashcards" opens options). */ step?: 1 | 2 | 3; }; const KEY = "freezmo.deck.seed.v1"; export function setDeckSeed(seed: DeckSeed): void { try { window.sessionStorage.setItem(KEY, JSON.stringify(seed)); } catch { /* private mode */ } } export function takeDeckSeed(): DeckSeed | null { try { const raw = window.sessionStorage.getItem(KEY); if (!raw) return null; window.sessionStorage.removeItem(KEY); const parsed = JSON.parse(raw) as DeckSeed; if (typeof parsed.text !== "string" || !parsed.text.trim()) return null; return parsed; } catch { return null; } }