<?php

declare(strict_types=1);

require_once __DIR__ . '/helpers.php';

player_module_boot();

$headers = player_bulk_template_headers();
$sample = player_bulk_template_sample_row();

header('Content-Type: text/csv; charset=utf-8');
header('Content-Disposition: attachment; filename="player-bulk-template.csv"');

$output = fopen('php://output', 'wb');
if ($output === false) {
    exit;
}

fputcsv($output, $headers);
fputcsv($output, array_map(static fn(string $header): string => (string) ($sample[$header] ?? ''), $headers));

fclose($output);
exit;
