<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

use Filament\Support\Facades\FilamentView;
use Illuminate\Support\Facades\Blade;
use Filament\View\PanelsRenderHook;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        \Livewire\Livewire::setUpdateRoute(function ($handle) {
            // This route will handle the actual request after Laravel strips the subfolder base path
            \Illuminate\Support\Facades\Route::post('/livewire/update', $handle);
            
            // This route will be named 'livewire.update' and used to generate the frontend URI
            return \Illuminate\Support\Facades\Route::post('/jejakwaris/public/livewire/update', $handle);
        });

        FilamentView::registerRenderHook(
            PanelsRenderHook::HEAD_END,
            fn (): string => Blade::render('<link rel="manifest" href="{{ asset(\'manifest.json\') }}">
<meta name="theme-color" content="#1b4332">
<link rel="apple-touch-icon" href="https://ui-avatars.com/api/?name=W&background=1b4332&color=d4af37&size=192">')
        );
    }
}
