<?php

namespace App\Support;

use App\Support\OpsUx\OperationSummaryKeys;

final class OperationCatalog
{
    /**
     * @return array<string, string>
     */
    public static function labels(): array
    {
        return [
            'policy.sync' => 'Policy sync',
            'policy.sync_one' => 'Policy sync',
            'policy.capture_snapshot' => 'Policy snapshot',
            'policy.delete' => 'Delete policies',
            'policy.unignore' => 'Restore policies',
            'policy.export' => 'Export policies to backup',
            'provider.connection.check' => 'Provider connection check',
            'inventory.sync' => 'Inventory sync',
            'compliance.snapshot' => 'Compliance snapshot',
            'directory_groups.sync' => 'Directory groups sync',
            'drift.generate' => 'Drift generation',
            'backup_set.add_policies' => 'Backup set update',
            'backup_set.remove_policies' => 'Backup set update',
            'backup_set.delete' => 'Archive backup sets',
            'backup_set.restore' => 'Restore backup sets',
            'backup_set.force_delete' => 'Delete backup sets',
            'backup_schedule.run_now' => 'Backup schedule run',
            'backup_schedule.retry' => 'Backup schedule retry',
            'restore.execute' => 'Restore execution',
            'restore_run.delete' => 'Delete restore runs',
            'restore_run.restore' => 'Restore restore runs',
            'restore_run.force_delete' => 'Force delete restore runs',
            'tenant.sync' => 'Tenant sync',
            'policy_version.prune' => 'Prune policy versions',
            'policy_version.restore' => 'Restore policy versions',
            'policy_version.force_delete' => 'Delete policy versions',
        ];
    }

    public static function label(string $operationType): string
    {
        $operationType = trim($operationType);

        if ($operationType === '') {
            return 'Operation';
        }

        return self::labels()[$operationType] ?? 'Unknown operation';
    }

    public static function expectedDurationSeconds(string $operationType): ?int
    {
        return match (trim($operationType)) {
            'policy.sync', 'policy.sync_one' => 90,
            'provider.connection.check' => 30,
            'policy.export' => 120,
            'inventory.sync' => 180,
            'compliance.snapshot' => 180,
            'directory_groups.sync' => 120,
            'drift.generate' => 240,
            default => null,
        };
    }

    /**
     * @return array<int, string>
     */
    public static function allowedSummaryKeys(): array
    {
        return OperationSummaryKeys::all();
    }
}
