<?php

namespace App\Modules\Navigation\Support;

use Illuminate\Support\Facades\Lang;

final class NavigationLabelResolver
{
    public static function label(array $entry): string
    {
        if (! empty($entry['label_key'])) {
            return (string) __($entry['label_key']);
        }

        return (string) ($entry['label'] ?? '');
    }

    public static function recentRouteLabel(string $routeName): string
    {
        $key = 'nav.recent_routes.'.$routeName;
        if (Lang::has($key)) {
            return (string) trans($key);
        }

        return (string) __('nav.fallback_page');
    }

    public static function signalRouteLabel(string $routeName): string
    {
        return match ($routeName) {
            'procurement.purchase-orders.index' => (string) __('dashboard.action_center.widgets.pending_po_drafts'),
            'procurement.goods-receipts.index' => (string) __('dashboard.action_center.widgets.draft_goods_receipts'),
            'sales.orders.index' => (string) __('dashboard.action_center.widgets.draft_sales_orders'),
            'operations.workflow-inbox.index' => (string) __('nav.mega.workflow_queue'),
            default => self::recentRouteLabel($routeName),
        };
    }
}
