<?php
/**
 * Free vs Pro feature gating.
 *
 * @package SKYNSMFA_Smart_Favorites
 */

declare( strict_types=1 );

namespace SKYNSMFA\Wishlist;

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


final class Feature_Gate {
	/**
	 * Whether Pro features are unlocked (valid Pro license; free core may still run via Pro bootstrap).
	 *
	 * @return bool
	 */
	public static function is_pro_active(): bool {
		return (bool) apply_filters( 'skynsmfa_is_pro_active', false );
	}

	/**
	 * Whether a wishlist page layout is available.
	 *
	 * @param string $layout table|grid|compact.
	 * @return bool
	 */
	public static function can_use_layout( string $layout ): bool {
		if ( in_array( $layout, array( 'table', 'grid' ), true ) ) {
			return true;
		}

		if ( 'compact' === $layout ) {
			return self::is_pro_active();
		}

		return false;
	}

	/**
	 * Resolve stored layout to an allowed layout for the current tier.
	 *
	 * @param string $layout Requested layout.
	 * @return string
	 */
	public static function resolve_page_layout( string $layout ): string {
		return self::can_use_layout( $layout ) ? $layout : 'table';
	}

	/**
	 * Bulk / add-all cart actions.
	 *
	 * @return bool
	 */
	public static function can_bulk_cart(): bool {
		return self::is_pro_active();
	}

	/**
	 * Analytics event logging and reports.
	 *
	 * @return bool
	 */
	public static function can_use_analytics(): bool {
		return self::is_pro_active();
	}

	/**
	 * Settings JSON export/import.
	 *
	 * @return bool
	 */
	public static function can_export_import(): bool {
		return self::is_pro_active();
	}

	/**
	 * WooCommerce product emails (stock / sale).
	 *
	 * @return bool
	 */
	public static function can_use_emails(): bool {
		return self::is_pro_active();
	}
}
