<?php

declare(strict_types=1);

namespace Maestro\Core\Http\Controllers;

use Maestro\Core\Support\CorePaths;
use Symfony\Component\HttpFoundation\BinaryFileResponse;

/**
 * Serves shipped Core branding files so hosts do not need to publish assets to public/.
 */
class CoreBrandingAssetController extends Controller
{
    /**
     * @var list<string>
     */
    private const ALLOWED_FILES = [
        'logo-sidebar-white.png',
        'logo-header.png',
        'logo-compact.png',
        'favicon.png',
    ];

    public function show(string $file): BinaryFileResponse
    {
        abort_unless(in_array($file, self::ALLOWED_FILES, true), 404);

        $absolute = CorePaths::brandingAssetPath($file);
        abort_unless($absolute !== null, 404);

        return response()->file($absolute);
    }
}
