<?php

declare(strict_types=1);

namespace App\Framework\Router;

use App\Framework\Attributes\Singleton;

/**
 * Type-safe route helper for generating URLs with specific route enums
 */
#[Singleton]
final readonly class RouteHelper
{
    public function __construct(
        private UrlGenerator $urlGenerator
    ) {
    }

    /**
     * Generate URL for web routes
     *
     * @param array<string, mixed> $params
     */
    public function web(WebRoutes $route, array $params = [], bool $absolute = false): string
    {
        return $this->urlGenerator->route($route, $params, $absolute);
    }

    /**
     * Generate URL for API routes
     *
     * @param array<string, mixed> $params
     */
    public function api(ApiRoutes $route, array $params = [], bool $absolute = false): string
    {
        return $this->urlGenerator->route($route, $params, $absolute);
    }

    /**
     * Generate URL for admin routes
     *
     * @param array<string, mixed> $params
     */
    public function admin(AdminRoutes $route, array $params = [], bool $absolute = false): string
    {
        return $this->urlGenerator->route($route, $params, $absolute);
    }

    /**
     * Generate URL for health routes
     *
     * @param array<string, mixed> $params
     */
    public function health(HealthRoutes $route, array $params = [], bool $absolute = false): string
    {
        return $this->urlGenerator->route($route, $params, $absolute);
    }

    /**
     * Generate URL for media routes
     *
     * @param array<string, mixed> $params
     */
    public function media(MediaRoutes $route, array $params = [], bool $absolute = false): string
    {
        return $this->urlGenerator->route($route, $params, $absolute);
    }

    /**
     * Generate URL for any route implementing RouteNameInterface
     *
     * @param array<string, mixed> $params
     */
    public function any(RouteNameInterface $route, array $params = [], bool $absolute = false): string
    {
        return $this->urlGenerator->route($route, $params, $absolute);
    }

    /**
     * Generate absolute URL for web routes
     *
     * @param array<string, mixed> $params
     */
    public function absoluteWeb(WebRoutes $route, array $params = []): string
    {
        return $this->web($route, $params, true);
    }

    /**
     * Generate absolute URL for API routes
     *
     * @param array<string, mixed> $params
     */
    public function absoluteApi(ApiRoutes $route, array $params = []): string
    {
        return $this->api($route, $params, true);
    }

    /**
     * Generate absolute URL for admin routes
     *
     * @param array<string, mixed> $params
     */
    public function absoluteAdmin(AdminRoutes $route, array $params = []): string
    {
        return $this->admin($route, $params, true);
    }

    /**
     * Check if current route matches given web route
     */
    public function isCurrentWeb(WebRoutes $route): bool
    {
        return $this->urlGenerator->isCurrentRoute($route);
    }

    /**
     * Check if current route matches given API route
     */
    public function isCurrentApi(ApiRoutes $route): bool
    {
        return $this->urlGenerator->isCurrentRoute($route);
    }

    /**
     * Check if current route matches given admin route
     */
    public function isCurrentAdmin(AdminRoutes $route): bool
    {
        return $this->urlGenerator->isCurrentRoute($route);
    }

    /**
     * Check if current route matches any route
     */
    public function isCurrent(RouteNameInterface $route): bool
    {
        return $this->urlGenerator->isCurrentRoute($route);
    }
}
