"use strict"; function escapeHtml(value) { return String(value) .replaceAll("&", "&") .replaceAll("<", "<") .replaceAll(">", ">") .replaceAll('"', """) .replaceAll("'", "'"); } function shell({ title, content, compact = false, user = null }) { const container = compact ? "max-w-md" : "max-w-5xl"; const authenticated = user?.authenticated; const userId = user?.userId; const authButtons = authenticated ? `
` : `
Sign in Get Started
`; const menuItems = `
  • How it works
  • Pricing
  • Dashboard
  • `; return ` ${escapeHtml(title)}
    ${content}
    `; } function renderLandingPage({ authenticated, userId }) { const primaryCta = authenticated ? `Open Dashboard` : `
    Start for Free Learn more
    `; return shell({ title: "XArtAudio | Turn X Articles into Audiobooks", user: { authenticated, userId }, content: `
    New Webhook-first automation

    Listen to X Articles.

    Mention our bot under any long-form X post. We'll convert it to audio and send you a link instantly.

    ${primaryCta}

    No credit card required • ${escapeHtml(userId ? `Logged in as @${userId}` : "Public access valid")}

    How it works

    Three simple steps to turn reading into listening.

    1. Mention the bot

    Reply to any long article on X with @XArtAudio.

    2. Processing

    Our webhook verifies the article and generates high-quality audio.

    3. Listen

    Receive a link to your audiobook. Listen anywhere, anytime.

    Simple Pricing

    Pay only for what you convert. Credits never expire.

    Pay-as-you-go

    $1 / 25k chars
    • High-quality Neural Voices
    • Permanent Storage
    • Shareable Links
    Get Started

    Credit Logic

    Base (up to 25k chars) 1 credit
    Additional 10k chars +1 credit
    Maximum article size 120k chars
    `, }); } function renderLoginPage({ returnTo = "/app", error = null }) { const errorBlock = error ? `` : ""; return shell({ title: "Sign in | XArtAudio", user: null, content: `

    Welcome back

    Sign in to your account to continue

    ${errorBlock}
    Email
    Create account
    X sign-in requires X_OAUTH_CLIENT_ID and X_OAUTH_CLIENT_SECRET.
    `, }); } function renderAppPage({ userId, summary, jobs, flash = null, showDeveloperActions = true }) { const flashMarkup = flash ? `` : ""; const jobsMarkup = jobs.length === 0 ? `

    No audiobooks yet

    Use the simulation form below to generate your first audiobook.

    ` : `
    ${jobs.map((job) => `
    ${escapeHtml(job.status)}
    ${job.creditsCharged} cr

    ${escapeHtml(job.article.title)}

    `).join("")}
    `; const developerActionsMarkup = showDeveloperActions ? `

    Developer Actions

    ` : ""; return shell({ title: "Dashboard | XArtAudio", user: { authenticated: true, userId }, content: `

    Dashboard

    Manage your credits and audiobooks

    ${flashMarkup}
    Available Credits
    ${summary.balance}
    For generating audio
    Audiobooks
    ${summary.totalJobs}
    Generated so far
    Total Spent
    ${summary.totalCreditsSpent}
    Lifetime credits

    Recent Audiobooks

    ${jobsMarkup}
    ${developerActionsMarkup}
    `, }); } function renderAudioPage({ audio, accessDecision, userId, playbackUrl = null }) { if (!audio) { return shell({ title: "Audio not found", compact: true, user: { authenticated: Boolean(userId), userId }, content: `
    Back to Dashboard
    `, }); } const action = accessDecision.allowed ? `` : accessDecision.reason === "auth_required" ? `

    Sign in to listen

    You need an account to unlock this audiobook.

    Sign in to unlock
    ` : `

    Unlock Audiobook

    Unlock this audiobook permanently for ${accessDecision.creditsRequired} credits.

    `; return shell({ title: `${escapeHtml(audio.articleTitle)} | XArtAudio`, compact: true, user: { authenticated: Boolean(userId), userId }, content: `
    Back to Dashboard
    Audiobook ${escapeHtml(audio.id.substring(0, 8))}

    ${escapeHtml(audio.articleTitle)}

    ${audio.durationSec}s duration
    ${action} ${accessDecision.allowed ? `

    Direct Stream URL

    ${escapeHtml(playbackUrl || `stream://${audio.storageKey}`)}
    ` : ""}
    `, }); } module.exports = { shell, renderLandingPage, renderLoginPage, renderAppPage, renderAudioPage, };