<?php

use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;

return Application::configure(basePath: dirname(__DIR__))
    ->withRouting(
        web: __DIR__.'/../routes/web.php',
        commands: __DIR__.'/../routes/console.php',
        health: '/up',
    )
    ->withMiddleware(function (Middleware $middleware) {
        // Add global middleware for module status checking
        $middleware->append(\App\Http\Middleware\CheckModuleStatus::class);
        
        // Add global middleware for theme support
        $middleware->append(\App\Http\Middleware\ThemeMiddleware::class);

        $middleware->alias([
            'admin'     => \App\Http\Middleware\IsAdmin::class,
            'editor'    => \App\Http\Middleware\IsEditor::class,
            'moderator' => \App\Http\Middleware\IsModerator::class,
            'sanitize'  => \App\Http\Middleware\SanitizeInput::class,
        ]);
    })
    ->withExceptions(function (Exceptions $exceptions) {
        //
    })->create();
