<?php

namespace App\Enums;

enum BookingStatus: string
{
    case Pending     = 'pending';
    case Confirmed   = 'confirmed';
    case Cancelled   = 'cancelled';
    case Completed   = 'completed';
    case NoShow      = 'no_show';
    case Rescheduled = 'rescheduled';
    case Archived    = 'archived';

    public function label(): string
    {
        return match ($this) {
            self::Pending     => 'Pendiente',
            self::Confirmed   => 'Confirmada',
            self::Cancelled   => 'Cancelada',
            self::Completed   => 'Atendida',
            self::NoShow      => 'No asistió',
            self::Rescheduled => 'Reprogramada',
            self::Archived    => 'Archivada',
        };
    }

    public function color(): string
    {
        return match ($this) {
            self::Pending     => 'amber',
            self::Confirmed   => 'sky',
            self::Cancelled   => 'rose',
            self::Completed   => 'emerald',
            self::NoShow      => 'gray',
            self::Rescheduled => 'indigo',
            self::Archived    => 'gray',
        };
    }

    public function icon(): string
    {
        return match ($this) {
            self::Pending     => 'clock',
            self::Confirmed   => 'check-circle',
            self::Cancelled   => 'x-circle',
            self::Completed   => 'check-badge',
            self::NoShow      => 'user-minus',
            self::Rescheduled => 'arrow-path',
            self::Archived    => 'archive-box',
        };
    }

    public function isFinal(): bool
    {
        return in_array($this, [self::Completed, self::Cancelled, self::NoShow, self::Archived], true);
    }

    public function isActive(): bool
    {
        return in_array($this, [self::Pending, self::Confirmed], true);
    }

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