<?php

namespace App\Providers\Filament;

use App\Filament\Pages\Reserve;
use Filament\View\PanelsRenderHook;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
use Illuminate\Routing\Middleware\SubstituteBindings;
use Illuminate\Session\Middleware\StartSession;
use Illuminate\View\Middleware\ShareErrorsFromSession;

class PublicPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->id('public')
            ->path('boka')
            ->colors([
                'primary' => Color::hex('#0080bb'),
            ])
            ->brandName('vBytes')
            ->brandLogo(asset('img/logo.png'))
            ->brandLogoHeight('2rem')
            // ?v= tvingar webbläsare att hämta om ikonen; höj siffran vid byte
            ->favicon(asset('img/favicon-32.png') . '?v=2')
            ->topNavigation()
            ->navigation(false)
            ->darkMode(true)
            ->renderHook(
                PanelsRenderHook::TOPBAR_END,
                fn () => \Illuminate\Support\Facades\Blade::render('<x-filament-panels::theme-switcher />'),
            )
            ->pages([
                Reserve::class,
            ])
            ->middleware([
                EncryptCookies::class,
                AddQueuedCookiesToResponse::class,
                StartSession::class,
                ShareErrorsFromSession::class,
                VerifyCsrfToken::class,
                SubstituteBindings::class,
                DisableBladeIconComponents::class,
                DispatchServingFilamentEvent::class,
            ]);
    }
}
