<?php

namespace App\Enums;

/**
 * Reaction slugs used in the database.
 * Emoji are only used for display — slugs are stored.
 */
enum ReactionType: string
{
    case ThumbsUp = 'thumbs_up';
    case Heart    = 'heart';
    case Fire     = 'fire';
    case Laugh    = 'laugh';
    case Clap     = 'clap';
    case Wow      = 'wow';

    /** Return the display emoji for this reaction. */
    public function emoji(): string
    {
        return match ($this) {
            self::ThumbsUp => '👍',
            self::Heart    => '❤️',
            self::Fire     => '🔥',
            self::Laugh    => '😂',
            self::Clap     => '👏',
            self::Wow      => '😮',
        };
    }

    /** Human-readable label. */
    public function label(): string
    {
        return match ($this) {
            self::ThumbsUp => 'Like',
            self::Heart    => 'Love',
            self::Fire     => 'Fire',
            self::Laugh    => 'Haha',
            self::Clap     => 'Clap',
            self::Wow      => 'Wow',
        };
    }

    /** All valid slugs — used for validation. */
    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }

    /** Full UI payload for the frontend. */
    public static function asMap(): array
    {
        $map = [];
        foreach (self::cases() as $case) {
            $map[$case->value] = [
                'slug'  => $case->value,
                'emoji' => $case->emoji(),
                'label' => $case->label(),
            ];
        }
        return $map;
    }
}
