/* ============================================================ INDIC LEAGUE NEWS — Onboarding (two-step) Step 1: choose topics (min 3) Step 2: political inclination — pill OR quiz OR skip ============================================================ */ function Onboarding({ initialTopics = [], onComplete, onStartQuiz, prefilledPosition }) { const [step, setStep] = React.useState(1); const [topics, setTopics] = React.useState(new Set(initialTopics)); const [position, setPosition] = React.useState(prefilledPosition?.id || null); // If user came back from the quiz with a result, jump to step 2 React.useEffect(() => { if (prefilledPosition) { setStep(2); setPosition(prefilledPosition.id); } }, [prefilledPosition]); const toggleTopic = (id) => { window.IL_Sounds && window.IL_Sounds.tap(); window.IL_Util && window.IL_Util.Haptics.light(); setTopics(prev => { const next = new Set(prev); if (next.has(id)) next.delete(id); else next.add(id); return next; }); }; const goStep2 = () => { if (topics.size < 3) return; window.IL_Sounds && window.IL_Sounds.pick(); window.IL_Util && window.IL_Util.Haptics.medium(); setStep(2); }; const goBack = () => { window.IL_Sounds && window.IL_Sounds.tap(); setStep(1); }; const submitFinal = (positionId = position) => { const selectedTopics = Array.from(topics); let positionVal = null; let method = null; if (positionId) { const opt = window.IL_POLITICAL_OPTIONS.find(o => o.id === positionId); if (opt) { positionVal = opt.position; method = prefilledPosition ? 'quiz' : 'self_select'; } } window.IL_Util.Storage.set(window.IL_KEYS.topics, selectedTopics); window.IL_Util.Storage.set(window.IL_KEYS.political, { position: positionVal, method, label: window.IL_LABEL_FROM_SCORE(positionVal), }); window.IL_Sounds && window.IL_Sounds.success(); window.IL_Util && window.IL_Util.Haptics.success(); onComplete({ topics: selectedTopics, position: positionVal, method, }); }; const skipPolitical = () => { window.IL_Sounds && window.IL_Sounds.tap(); submitFinal(null); }; if (step === 1) { return (
1 of 2
Personalise your feed

What interests you?

Choose the topics you want us to cover. Pick at least 3 to continue.

{window.IL_TOPICS.map(t => ( toggleTopic(t.id)} /> ))}

{topics.size === 0 && 'Select 3 to continue'} {topics.size > 0 && topics.size < 3 && `Select ${3 - topics.size} more to continue`} {topics.size >= 3 && topics.size < window.IL_TOPICS.length && `${topics.size} topics selected — looking good`} {topics.size === window.IL_TOPICS.length && 'All topics selected — your feed will be wide open'}

); } // Step 2 — Political inclination return (
How do you see the world?

Let's understand your perspective

This helps us show you a balanced range of stories — we won't lock you in a bubble. You can change this anytime.

{window.IL_POLITICAL_OPTIONS.map(opt => ( { window.IL_Sounds && window.IL_Sounds.pick(); window.IL_Util && window.IL_Util.Haptics.pick(); setPosition(opt.id); }} /> ))}
OR

You'll see more stories from across the spectrum — not less of what you came for.

); } Object.assign(window, { Onboarding });