import { CLOSE_ICON } from './icons.js';
import { logoLockup } from '../logo.js';
import { renderCornerRail } from '../cornerRail.js';
import { attachTooltips } from '../tooltip.js';
import { renderTopRail } from '../topRail.js';
import { api, apiUrl, ApiError } from '../api.js';
import { getUser } from '../auth.js';
import { parseCustomContent } from '../customText.js';
import { escapeHtml } from '../util.js';
const POLL_INTERVAL_MS = 4000;
// Connect Spotify -> poll what's currently playing -> fetch synced lyrics
// for it -> hand the result to onLyricsReady, which app.js implements by
// setting it as the active custom text and starting a game exactly like a
// manually-uploaded .lrc file would - this screen only produces that same
// {name, chunks, language, timed} shape, it doesn't play anything itself.
export function renderLyricsScreen(root, { onBack, onLyricsReady, onShowStats, onShowPlaceholder, onShowAccount, onShowLeaderboard, onShowFriends, onShowMultiplayer, onShowStore }) {
let status = 'checking';
let message = 'Checking sign-in...';
let lastTrackKey = null;
let pollTimer = null;
let stopped = false;
function bodyText() {
if (status === 'signed-out') return 'Sign in first - the Spotify connection is tied to your account.';
if (status === 'not-connected') return 'Connect your Spotify account to type along with whatever you\'re playing.';
if (status === 'not-configured') return message;
return message;
}
function render() {
root.innerHTML = `