<?php

namespace App\Enums;

use App\Traits\Enum\WithComment;
use App\Traits\Enum\WithValue;
use Filament\Support\Colors\Color;
use Filament\Support\Contracts\HasColor;
use Filament\Support\Contracts\HasLabel;

enum IssueSentiment: int implements HasColor, HasLabel
{
    use WithComment, WithValue;

    case POSITIVE = 1;
    case NEGATIVE = 2;
    case NEUTRAL = 3;
    case CRISIS = 4;

    public function getLabel(): ?string
    {
        return match ($this) {
            self::POSITIVE => 'Positif',
            self::NEGATIVE => 'Negatif',
            self::NEUTRAL => 'Netral',
            self::CRISIS => 'Krisis',
        };
    }

    public function getColor(): string|array|null
    {
        return match ($this) {
            self::POSITIVE => Color::Green,
            self::NEGATIVE => Color::Red,
            self::NEUTRAL => Color::Gray,
            self::CRISIS => Color::Orange,
        };
    }

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