<?php

namespace App\Enums;

enum RequiredAttachmentEnum: int
{
    case ID_COPY        = 1;
    case PERSONAL_PHOTO = 2;

    public static function labels(): array
    {
        return [
            self::ID_COPY->value        => __('dashboard.id_copy'),
            self::PERSONAL_PHOTO->value => __('dashboard.personal_photo'),
        ];
    }

    public static function colors(): array
    {
        return [
            self::ID_COPY->value        => 'warning',
            self::PERSONAL_PHOTO->value => 'info',
        ];
    }

    public static function label(self|int|null $value): string
    {
        $key = $value instanceof self ? $value->value : $value;
        return self::labels()[$key] ?? '';
    }

    public static function color(self|int|null $value): string
    {
        $key = $value instanceof self ? $value->value : $value;
        return self::colors()[$key] ?? 'secondary';
    }

    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }

    public static function badge(self|int|null $value): string
    {
        $color = self::color($value);
        $label = self::label($value);
        return '<span class="badge bg-' . $color . '-subtle text-' . $color . '">' . $label . '</span>';
    }

    public static function options(): array
    {
        return collect(self::cases())->map(fn($case) => [
            'value' => $case->value,
            'label' => self::label($case),
        ])->toArray();
    }
}
