<?php
/**
 * Settings Routes
 *
 * Defines API routes for settings operations (appearance, dashboard).
 * Migrated from AppearanceSettings.php and DashboardSettings.php
 *
 * @package FleekDash V2.2
 * @since   V2.2 Refactoring
 */

namespace FleekDash\Routes\Groups;

use FleekDash\Libs\API\Route;
use FleekDash\Libs\API\RouteAuthMiddleware;
use FleekDash\Controllers\AppearanceSettingsController;
use FleekDash\Controllers\DashboardSettingsController;
use FleekDash\Controllers\EditorSettingsController;
use FleekDash\Controllers\LabsSettingsController;
use FleekDash\Controllers\LoginSettingsController;
use FleekDash\Controllers\NotificationsSettingsController;
use FleekDash\Services\LabsFeaturesService;

class SettingsRoutes
{
    public static function register(Route $_route) // NOSONAR php:S1172 - Route API callback signature
    {
        // Ensure Labs overrides service is ready
        LabsFeaturesService::init();

        // ===== Appearance Settings =====

        // Get appearance settings (authenticated users)
        Route::get('settings/appearance', [AppearanceSettingsController::class, 'getAppearanceSettings'],
            RouteAuthMiddleware::authenticated());

        // Update appearance settings (admin only)
        Route::post('settings/appearance', [AppearanceSettingsController::class, 'updateAppearanceSettings'],
            RouteAuthMiddleware::admin());

        // Upload logo (admin only)
        Route::post('settings/appearance/upload-logo', [AppearanceSettingsController::class, 'uploadLogo'],
            RouteAuthMiddleware::admin());

        // ===== Labs (Experimental Features) =====

        Route::get('settings/labs', [LabsSettingsController::class, 'getLabsSettings'],
            RouteAuthMiddleware::admin());

        Route::post('settings/labs', [LabsSettingsController::class, 'updateLabsSettings'],
            RouteAuthMiddleware::admin());

        // ===== Dashboard Settings =====

        // Get demo mode setting (admin only)
        Route::get('settings/demo-mode', [DashboardSettingsController::class, 'get_demo_mode_setting'],
            RouteAuthMiddleware::admin());

        // Update demo mode setting (admin only)
        Route::post('settings/demo-mode', [DashboardSettingsController::class, 'update_demo_mode_setting'],
            RouteAuthMiddleware::admin());

        // ===== Login Settings =====

        // Get login settings
        Route::get('settings/login', [LoginSettingsController::class, 'get_settings'],
            RouteAuthMiddleware::authenticated());

        // Update login settings
        Route::post('settings/login', [LoginSettingsController::class, 'update_settings'],
            RouteAuthMiddleware::admin());

        // Search pages
        Route::get('settings/login/pages', [LoginSettingsController::class, 'search_pages'],
            RouteAuthMiddleware::admin());

        // Create page
        Route::post('settings/login/create-page', [LoginSettingsController::class, 'create_page'],
            RouteAuthMiddleware::admin());

        // Search users
        Route::get('settings/login/users', [LoginSettingsController::class, 'search_users'],
            RouteAuthMiddleware::admin());

        // Upload illustration
        Route::post('settings/login/upload-illustration', [LoginSettingsController::class, 'upload_illustration'],
            RouteAuthMiddleware::admin());

        // ===== Notifications Settings =====

        Route::get('settings/notifications', [NotificationsSettingsController::class, 'getSettings'],
            RouteAuthMiddleware::authenticated());

        Route::post('settings/notifications', [NotificationsSettingsController::class, 'updateSettings'],
            RouteAuthMiddleware::admin());

        // ===== Editor Settings =====

        Route::get('settings/editor', [EditorSettingsController::class, 'getSettings'],
            RouteAuthMiddleware::authenticated());

        Route::post('settings/editor', [EditorSettingsController::class, 'updateSettings'],
            RouteAuthMiddleware::admin());
    }
}
