@props([
    'route' => null,
    'params' => [], // <-- Nuevo: parámetros de la ruta
    'href'  => null,
    'icon'  => null,
])

@php
    // Construir la URL final
    $url = $href ?? ($route ? route($route, $params) : '#');

    // Verificar si la ruta y los parámetros coinciden
    $active = false;
    if ($route && request()->routeIs($route)) {
        $currentParams = request()->route()->parameters();
        $active = !array_diff_assoc($params, $currentParams);
    } elseif ($href) {
        $active = request()->url() === $href;
    }

    $activeStyles = $active ? 'active' : '';
@endphp

<a href="{{ $url }}"
   {{ $attributes->merge(['class' => "item-menu-nav $activeStyles"]) }}>
    @if ($icon)
        <x-dynamic-component :component="'icons.' . $icon" />
    @endif
    <span class="text-current">
        {{ $slot }}
    </span>
</a>