<?php

declare(strict_types=1);

namespace App\Support\Ui\ActionSurface\Enums;

enum ActionSurfaceType: string
{
    case CrudListFirstResource = 'crud_list_first_resource';
    case ReadOnlyRegistryReport = 'read_only_registry_report';
    case QueueReview = 'queue_review';
    case HistoryAudit = 'history_audit';
    case ConfigLite = 'config_lite';

    /**
     * @return array<int, ActionSurfaceInspectAffordance>
     */
    public function allowedInspectAffordances(): array
    {
        return match ($this) {
            self::CrudListFirstResource,
            self::ReadOnlyRegistryReport,
            self::ConfigLite => [
                ActionSurfaceInspectAffordance::ClickableRow,
                ActionSurfaceInspectAffordance::PrimaryLinkColumn,
            ],
            self::QueueReview,
            self::HistoryAudit => [
                ActionSurfaceInspectAffordance::ViewAction,
            ],
        };
    }

    public function allowsInspectAffordance(ActionSurfaceInspectAffordance $affordance): bool
    {
        return in_array($affordance, $this->allowedInspectAffordances(), true);
    }

    public function expectsExplicitInspect(): bool
    {
        return match ($this) {
            self::QueueReview,
            self::HistoryAudit => true,
            self::CrudListFirstResource,
            self::ReadOnlyRegistryReport,
            self::ConfigLite => false,
        };
    }

    public function supportsPrimaryLinkColumnException(): bool
    {
        return match ($this) {
            self::CrudListFirstResource,
            self::ReadOnlyRegistryReport,
            self::ConfigLite => true,
            self::QueueReview,
            self::HistoryAudit => false,
        };
    }
}
