<?php

declare(strict_types=1);

namespace App\Support\Badges\Domains;

use App\Support\Badges\BadgeCatalog;
use App\Support\Badges\BadgeMapper;
use App\Support\Badges\BadgeSpec;
use App\Support\Baselines\BaselineProfileStatus;

final class BaselineProfileStatusBadge implements BadgeMapper
{
    public function spec(mixed $value): BadgeSpec
    {
        $state = BadgeCatalog::normalizeState($value);
        $enum = BaselineProfileStatus::tryFrom($state);

        if ($enum === null) {
            return BadgeSpec::unknown();
        }

        return new BadgeSpec($enum->label(), $enum->color(), $enum->icon());
    }
}
