<?php

namespace App\Providers;

use App\Models\Activity;
use App\Models\CashRecord;
use App\Models\Post;
use App\Models\User;
use App\Models\Vote;
use App\Observers\ActivityObserver;
use App\Observers\CashRecordObserver;
use App\Observers\PostObserver;
use App\Observers\UserObserver;
use App\Observers\VoteObserver;
use Filament\Support\Facades\FilamentView;
use Filament\View\PanelsRenderHook;
use Illuminate\Support\HtmlString;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        User::observe(UserObserver::class);
        CashRecord::observe(CashRecordObserver::class);
        Activity::observe(ActivityObserver::class);
        Vote::observe(VoteObserver::class);
        Post::observe(PostObserver::class);

        FilamentView::registerRenderHook(
            PanelsRenderHook::TOPBAR_LOGO_AFTER,
            fn () => new HtmlString(
                '<a href="/" target="_blank" title="Website Publik"
                    style="display:flex;align-items:center;color:#9ca3af;margin-left:1rem;padding-left:1rem;border-left:1px solid #9ca3af"
                    onmouseover="this.style.color=\'#4b5563\'" onmouseout="this.style.color=\'#9ca3af\'">
                    <svg xmlns="http://www.w3.org/2000/svg" style="height:2rem" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
                            d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418" />
                    </svg>
                </a>'
            )
        );
    }
}
