// Hymns tab — plays a saved YouTube link inline; right rail lists titles from settings. // "Ad-free" works via the browser's Google session: sign into the saved account once // (Google blocks programmatic password login), and a Premium account then plays embeds ad-free. function HymnsTab({ hymns, ytAccount }){ const [cur, setCur] = React.useState(null); // index const [session, setSession] = React.useState(()=> localStorage.getItem('cwa-ytsession') || ''); const playable = cur!=null ? window.ytId(hymns[cur] && hymns[cur].url) : null; const hasAccount = !!(ytAccount && ytAccount.user); const signedIn = !!session && session === (ytAccount && ytAccount.user); function signIn(){ const email = (ytAccount && ytAccount.user) || ''; // Open Google's own secure login with the saved email pre-filled (password is entered by the // user on Google's page — it cannot be auto-submitted). Once signed in here, embeds use it. const url = 'https://accounts.google.com/AccountChooser?continue=' + encodeURIComponent('https://www.youtube.com') + (email ? '&Email=' + encodeURIComponent(email) : ''); window.open(url, '_blank', 'noopener'); if(email){ localStorage.setItem('cwa-ytsession', email); setSession(email); } } function signOut(){ localStorage.removeItem('cwa-ytsession'); setSession(''); window.open('https://www.youtube.com/logout', '_blank', 'noopener'); } return (