<?php

namespace Fotogenic_AI;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Own the exact output-quality contract for each billable workflow.
 */
final class Workflow_Quality_Catalog {
	private const WORKFLOW_QUALITIES = [
		'product_images'      => [ '1K', '2K', '4K' ],
		'campaign_set'        => [ '2K', '4K' ],
		'increase_resolution' => [ '2K' ],
	];

	/** @return string[] */
	public static function ids_for( string $workflow ): array {
		return self::WORKFLOW_QUALITIES[ $workflow ] ?? [];
	}

	public static function supports( string $workflow, string $quality ): bool {
		return in_array( strtoupper( trim( $quality ) ), self::ids_for( $workflow ), true );
	}

	/** @return array<int,array{id:string,label:string}> */
	public static function options_for( string $workflow, bool $include_4k ): array {
		$ids = array_filter(
			self::ids_for( $workflow ),
			static fn( string $quality ): bool => $include_4k || '4K' !== $quality
		);

		return array_map(
			static fn( string $quality ): array => [
				'id'    => $quality,
				'label' => $quality,
			],
			array_values( $ids )
		);
	}
}
