<?php

declare(strict_types=1);

namespace Apexl\Io\Admin\Display;

use Apexl\Io\Admin\Display\Controllers\AdminDisplayController;
use Apexl\Io\Admin\Enums\Permissions\Admin;
use Apexl\Io\Menu\Interfaces\ProvidesMenuItemsInterface;
use Apexl\Io\Menu\Services\MenuManager;
use Apexl\Io\Module;
use Apexl\Io\System\Interfaces\ProvidesRoutesInterface;
use Apexl\Io\User\Middleware\RoutePermissionMiddleware;

readonly class AdminDisplayModule extends Module implements ProvidesMenuItemsInterface, ProvidesRoutesInterface
{
    public function routes(): void
    {
        // Main Admin dashboard
                $this->get('/admin/dashboard', AdminDisplayController::class)
                    ->setName('adminDisplay.dashboard')
            ->add(new RoutePermissionMiddleware(Admin::ADMINISTER));
    }

    public function menuItems(MenuManager $menuManager): void
    {
        // Navigation Menu
        $menuManager->addToMenu('adminDisplay.dashboard', [
            'title' => 'Administration Dashboard',
            'icon' => 'shield-alt',
            'weight' => 100,
        ]);

        // Configuration Links
        $menuManager->addToMenu('adminDisplay.configuration', [
            'title' => 'Configuration',
            'icon' => 'cogs',
            'weight' => -12,
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.configuration.ad.update', [
            'title' => 'Allowed Domains',
            'weight' => -9,
            'icon' => 'globe',
            'parent' => 'adminDisplay.configuration',
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.configuration.installation.update', [
            'title' => 'Installation',
            'weight' => -8,
            'icon' => 'box-up',
            'parent' => 'adminDisplay.configuration',
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.configuration.sessions.update', [
            'title' => 'Sessions',
            'weight' => -7,
            'icon' => 'address-card',
            'parent' => 'adminDisplay.configuration',
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.configuration.email.update', [
            'title' => 'Email',
            'weight' => -6,
            'icon' => 'envelope',
            'parent' => 'adminDisplay.configuration',
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.configuration.site.update', [
            'title' => 'Site',
            'weight' => -5,
            'icon' => 'browser',
            'parent' => 'adminDisplay.configuration',
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.configuration.databases.update', [
            'title' => 'Databases',
            'weight' => -4,
            'icon' => 'database',
            'parent' => 'adminDisplay.configuration',
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.configuration.metadata.update', [
            'title' => 'Metadata',
            'weight' => -3,
            'icon' => 'info-square',
            'parent' => 'adminDisplay.configuration',
        ], 'administration');

        // System Links
        $menuManager->addToMenu('adminDisplay.system', [
            'title' => 'System',
            'icon' => 'cogs',
            'weight' => -11,
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.system.extentions', [
            'title' => 'Extentions',
            'weight' => -10,
            'icon' => 'boxes-alt',
            'parent' => 'adminDisplay.system',
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.system.maintinance', [
            'title' => 'Access Control',
            'weight' => -9,
            'icon' => 'tools',
            'parent' => 'adminDisplay.system',
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.system.force-logout', [
            'title' => 'Force Logout',
            'weight' => -8,
            'icon' => 'sign-out',
            'parent' => 'adminDisplay.system',
        ], 'administration');

        $menuManager->addToMenu('adminDisplay.system.api-routes', [
            'title' => 'API Routes',
            'weight' => -7,
            'icon' => 'sitemap',
            'parent' => 'adminDisplay.system',
        ], 'administration');

        // Reporting Links
        $menuManager->addToMenu('adminDisplay.reporting', [
            'title' => 'Reporting',
            'icon' => 'bug',
            'weight' => -12,
        ], 'administration');
    }
}
