<?php

declare(strict_types=1);

namespace App\Domain\Media;

use InvalidArgumentException;

enum ImageSize: string
{
    case SMALL = 'small';
    case MEDIUM = 'medium';
    case LARGE = 'large';
    case XLARGE = 'xlarge';

    public function getWidth(ImageVariantType $type): int
    {
        return match ([$type, $this]) {
            [ImageVariantType::THUMBNAIL, self::SMALL] => 150,
            [ImageVariantType::THUMBNAIL, self::MEDIUM] => 300,

            [ImageVariantType::GALLERY, self::SMALL] => 400,
            [ImageVariantType::GALLERY, self::MEDIUM] => 800,
            [ImageVariantType::GALLERY, self::LARGE] => 1200,

            [ImageVariantType::HERO, self::SMALL] => 768,
            [ImageVariantType::HERO, self::MEDIUM] => 1024,
            [ImageVariantType::HERO, self::LARGE] => 1920,
            [ImageVariantType::HERO, self::XLARGE] => 2560,

            default => throw new InvalidArgumentException("Invalid combination: {$type->value} - {$this->value}"),
        };
    }

    public function getBreakpoint(): ?int
    {
        return match ($this) {
            self::SMALL => 768,
            self::MEDIUM => 1024,
            self::LARGE => 1920,
            self::XLARGE => null, // Keine Breakpoint-Beschränkung
        };
    }
}
