<?php
    $url = $item->url;
    if (str_starts_with($url, '#')) {
        $href = route('home') . $url;
    } elseif (str_starts_with($url, 'http')) {
        $href = $url;
    } elseif (\Illuminate\Support\Facades\Route::has($url)) {
        $href = route($url);
    } else {
        $href = url($url);
    }
    $hasChildren = isset($item->children) && $item->children->isNotEmpty();
    $btnStyle = '';
    if ($item->color) {
        $dark = adjust_hex($item->color, -22);
        $btnStyle = '--btn-bg:' . e($item->color) . ';--btn-dark:' . $dark . ';background:var(--btn-bg);border-color:var(--btn-bg);';
    }
?>
<?php if($hasChildren): ?>
    <li class="nav-item dropdown<?php echo e($depth > 0 ? ' dropdown-submenu' : ' mega-dropdown'); ?>" id="navDrop-<?php echo e($item->id); ?>">
        <a class="nav-link dropdown-toggle<?php echo e($item->type === 'button' ? ' btn btn-brand' : ''); ?>" href="#" role="button" data-bs-toggle="dropdown" data-bs-display="static" aria-expanded="false" <?php if($item->type === 'button' && $btnStyle): ?> style="<?php echo e($btnStyle); ?>" <?php endif; ?>>
            <i class="bi <?php echo e($item->icon ?: 'bi-link-45deg'); ?> me-1"></i> <?php echo e($item->label); ?>

        </a>
        <div class="dropdown-menu mega-menu">
            <div class="mega-grid">
                <?php $__currentLoopData = $item->children; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $child): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <?php
                        $cUrl = $child->url;
                        if (str_starts_with($cUrl, '#')) { $cHref = route('home') . $cUrl; }
                        elseif (str_starts_with($cUrl, 'http')) { $cHref = $cUrl; }
                        elseif (\Illuminate\Support\Facades\Route::has($cUrl)) { $cHref = route($cUrl); }
                        else { $cHref = url($cUrl); }
                    ?>
                    <a href="<?php echo e($cHref); ?>" class="mega-card">
                        <span class="mega-card-icon bg-primary bg-opacity-10 text-primary">
                            <i class="bi <?php echo e($child->icon ?: 'bi-link-45deg'); ?>"></i>
                        </span>
                        <span class="mega-card-body">
                            <span class="mega-card-title"><?php echo e($child->label); ?></span>
                        </span>
                        <i class="bi bi-chevron-right mega-card-arrow"></i>
                    </a>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </div>
        </div>
    </li>
<?php else: ?>
    <li class="nav-item <?php echo e($item->type === 'button' && $depth === 0 ? 'ms-lg-1 mt-2 mt-lg-0' : ''); ?>">
        <?php if($depth > 0): ?>
            <a class="dropdown-item" href="<?php echo e($href); ?>">
                <?php if($item->icon): ?><i class="bi <?php echo e($item->icon); ?> me-1"></i><?php endif; ?> <?php echo e($item->label); ?>

            </a>
        <?php elseif($item->type === 'button'): ?>
            <a class="btn btn-brand" href="<?php echo e($href); ?>" <?php if($btnStyle): ?> style="<?php echo e($btnStyle); ?>" <?php endif; ?>><i class="bi <?php echo e($item->icon ?: 'bi-link-45deg'); ?> me-1"></i> <?php echo e($item->label); ?></a>
        <?php else: ?>
            <a class="nav-link" href="<?php echo e($href); ?>">
                <?php if($item->icon): ?><i class="bi <?php echo e($item->icon); ?> me-1"></i><?php endif; ?> <?php echo e($item->label); ?>

            </a>
        <?php endif; ?>
    </li>
<?php endif; ?><?php /**PATH /Applications/XAMPP/xamppfiles/htdocs/PROYECTOS/LARAVEL/paginaweb/resources/views/partials/nav-item.blade.php ENDPATH**/ ?>