<?php

declare(strict_types=1);

namespace App\Providers;

use App\Composers\LatestSuggestedInformationComposer;
use App\Http\Livewire\Components\Informacia\Components\Form as HodnoteniaBackendComponentForm;
use App\Http\Livewire\Components\Informacia\Components\HodnotiaceTlacidla;
use App\Http\Livewire\Components\Informacia\Components\Zoznam as InformaciaBackendComponentZoznam;
use App\Http\Livewire\Components\Informacia\Hodnotenie\Components\Zoznam as HodnoteniaBackendComponentZoznam;
use App\Http\Livewire\Components\Informacia\Hodnotenie\Pages\Index as HodnoteniaBackendPageIndex;
use App\Http\Livewire\Components\Informacia\Pages\Index as InformaciaBackendPageIndex;
use App\Http\Livewire\Components\Informacia\Pages\Upravit as InformaciaBackendPageUpravit;
use App\Http\Livewire\Components\Informacia\Pages\Vytvorit as InformaciaBackendPageVytvorit;
use App\Http\Livewire\Frontend\Informacia\Components\Zoznam as InformaciaFrontendComponentZoznam;
use App\Http\Livewire\Frontend\Informacia\Pages\Index as InformaciaFrontendPageIndex;
use App\Http\View\Composers\UserNotificationComposer;
use App\View\Components\Badge;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;

/**
 * Class ViewServiceProvider
 */
final class ViewServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        Blade::component(Badge::class, 'badge');
        $this->loadLivewireComponents();
    }

    private function loadLivewireComponents(): void
    {
        // PAGES
        Livewire::component('pages.sprava.informacie.livewire.create', InformaciaBackendPageVytvorit::class);
        Livewire::component('pages.sprava.informacie.livewire.edit', InformaciaBackendPageUpravit::class);
        Livewire::component('pages.sprava.informacie.livewire.list', InformaciaBackendPageIndex::class);
        Livewire::component('pages.sprava.informacie.hodnotenia.livewire.list', HodnoteniaBackendPageIndex::class);
        Livewire::component('pages.frontend.informacia.livewire.index', InformaciaFrontendPageIndex::class);

        // COMPONENTS
        Livewire::component('pages.sprava.informacie.livewire.components.form', HodnoteniaBackendComponentForm::class);
        Livewire::component(
            'pages.sprava.informacie.livewire.components.zoznam',
            InformaciaBackendComponentZoznam::class,
        );
        Livewire::component(
            'pages.sprava.informacie.hodnotenia.livewire.components.zoznam',
            HodnoteniaBackendComponentZoznam::class,
        );
        Livewire::component('frontend.informacie.zoznam', InformaciaFrontendComponentZoznam::class);
        Livewire::component('components.hodnotenie.hodnotiace-tlacidla', HodnotiaceTlacidla::class);
    }

    public function register(): void
    {
        $this->registerComposers();
    }

    public function registerComposers(): void
    {
        View::composer('partials.navbar', UserNotificationComposer::class);
        View::composer('pages.plocha', LatestSuggestedInformationComposer::class);
    }
}
