<?php
// Mocking Route and Laravel environment for breadcrumb logic test

function __($str) { return $str; }

class Route {
    public static $currentName = '';
    public static function currentRouteName() { return self::$currentName; }
}

function testBreadcrumbs($routeName) {
    Route::$currentName = $routeName;
    $links = [];
    $links[] = [
        'label' => __('Dashboard'),
        'url' => '/admin/dashboard',
        'active' => $routeName === 'admin.dashboard'
    ];

    $moduleMap = [
        'admin.warehouses' => __('Warehouse Management'),
        // ... simplified
    ];

    $foundModule = null;
    foreach ($moduleMap as $prefix => $label) {
        if (str_starts_with($routeName, $prefix)) {
            $foundModule = [
                'label' => $label, 
                'url' => '#',
                'active' => false
            ];
            break;
        }
    }

    if ($foundModule) {
        $links[] = $foundModule;
    }

    $segments = explode('.', $routeName);
    $lastSegment = end($segments);
    
    // Simplifed page labels
    $pageLabel = match($lastSegment) {
        'inventory' => __('Inventory Management'),
        'index' => 'Warehouse Overview',
        default => null,
    };

    if ($pageLabel) {
        $links[] = [
            'label' => $pageLabel,
            'active' => true
        ];
    }

    echo "Route: $routeName\n";
    foreach ($links as $link) {
        echo " - " . $link['label'] . ($link['active'] ? " (active)" : "") . "\n";
    }
    echo "\n";
}

testBreadcrumbs('admin.warehouses.inventory');
testBreadcrumbs('admin.warehouses.index');
