<?php

namespace Fotogenic_AI;

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

/**
 * Single manifest source for Studio targets. JSON-safe array of targets for dropdown and gating.
 * No behavior change; only data shape for Studio shell.
 */
final class Studio_Targets_Manifest {

	/**
	 * Get targets for Studio dropdown and client gating. Arrays and scalars only (JSON serializable).
	 *
	 * @return array<int, array{id: string, label: string, enabled: bool, reason: string, isDefault: bool}>
	 */
	public static function get_targets(): array {
		$wc_status = Plugin::instance()->compat()->woocommerce_status();
		$wc_active = $wc_status['available'];
		$wc_reason = $wc_active ? '' : $wc_status['message'];
		return [
			[
				'id'        => 'product',
				'label'     => $wc_active
					? __( 'Product (WooCommerce)', 'fotogenic-ai' )
					: __( 'Product (WooCommerce unavailable)', 'fotogenic-ai' ),
				'enabled'   => $wc_active,
				'reason'    => $wc_reason,
				'isDefault' => true,
			],
			[
				'id'        => 'campaign',
				'label'     => __( 'Campaign Set', 'fotogenic-ai' ),
				'enabled'   => current_user_can( 'upload_files' ),
				'reason'    => current_user_can( 'upload_files' ) ? '' : __( 'No permission', 'fotogenic-ai' ),
				'isDefault' => false,
			],
			[
				'id'        => 'enhance',
				'label'     => __( 'Increase Resolution', 'fotogenic-ai' ),
				'enabled'   => current_user_can( 'upload_files' ),
				'reason'    => current_user_can( 'upload_files' ) ? '' : __( 'No permission', 'fotogenic-ai' ),
				'isDefault' => false,
			],
			[
				'id'        => 'product_bulk',
				'label'     => $wc_active
					? __( 'Product Bulk (WooCommerce)', 'fotogenic-ai' )
					: __( 'Product Bulk (WooCommerce unavailable)', 'fotogenic-ai' ),
				'enabled'   => $wc_active,
				'reason'    => $wc_reason,
				'isDefault' => false,
			],
			[
				'id'        => 'media',
				'label'     => __( 'Media library', 'fotogenic-ai' ),
				'enabled'   => current_user_can( 'upload_files' ),
				'reason'    => current_user_can( 'upload_files' ) ? '' : __( 'No permission', 'fotogenic-ai' ),
				'isDefault' => false,
			],
			[
				'id'        => 'post',
				'label'     => __( 'Post', 'fotogenic-ai' ),
				'enabled'   => current_user_can( 'edit_posts' ),
				'reason'    => current_user_can( 'edit_posts' ) ? '' : __( 'No permission', 'fotogenic-ai' ),
				'isDefault' => false,
			],
			[
				'id'        => 'page',
				'label'     => __( 'Page', 'fotogenic-ai' ),
				'enabled'   => current_user_can( 'edit_pages' ),
				'reason'    => current_user_can( 'edit_pages' ) ? '' : __( 'No permission', 'fotogenic-ai' ),
				'isDefault' => false,
			],
		];
	}
}
