<?php
/**
 * @var App\Entity\Station $station
 * @var App\Customization $customization
 * @var App\View\GlobalSections $sections
 * @var App\Http\RouterInterface $router
 * @var array $props
 * @var string $nowPlayingArtUri
 */

$this->layout(
    'minimal',
    [
        'page_class' => 'page-station-public-player station-' . $station->getShortName(),
        'title' => $this->e($station->getName()),
    ]
);

$this->fetch('frontend/public/partials/station-custom', ['station' => $station]);

// Register PWA service worker
$swJsRoute = $router->named('public:sw');

$sections->appendStart('head');
?>
    <link rel="manifest" href="<?= $router->fromHere('public:manifest') ?>">

    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="<?= $this->e($station->getName() ?? '') ?>">

    <meta property="og:title" content="<?= $this->e($station->getName() ?? '') ?>">
    <meta property="og:url" content="<?= $this->e($station->getUrl() ?? '') ?>">
    <meta property="og:image" content="<?= $nowPlayingArtUri ?>">

    <meta property="twitter:card" content="player">
    <meta property="twitter:player" content="<?= $router->named(
        'public:index',
        ['station_id' => $station->getShortName(), 'embed' => 'social'],
        [],
        true
    ) ?>">
    <meta property="twitter:player:width" content="400">
    <meta property="twitter:player:height" content="125">
<?php
$sections->end();

$sections->appendStart('bodyjs');
?>
    <script>
        $(function () {
            if ('serviceWorker' in navigator) {
                window.addEventListener('load', function () {
                    navigator.serviceWorker.register('<?=$swJsRoute ?>');
                });
            }
        });
    </script>
<?php
$sections->end();

echo $this->fetch(
    'partials/vue_body',
    [
        'component' => 'Vue_PublicFullPlayer',
        'id' => 'public-radio-player',
        'props' => $props,
    ]
);
