<?php
/**
 * GigaChat AI Models
 *
 * Constants and utilities for GigaChat text and image generation models
 *
 * @package SmartyPress_AI_Engine
 * @since 1.1.0
 */

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

/**
 * GigaChat Models class
 */
class SmartyPress_AI_GigaChat_Models {

	/**
	 * Current generation text models
	 */
	const GIGACHAT_2     = 'GigaChat-2';
	const GIGACHAT_2_PRO = 'GigaChat-2-Pro';
	const GIGACHAT_2_MAX = 'GigaChat-2-Max';

	/**
	 * Legacy text models
	 */
	const GIGACHAT     = 'GigaChat';
	const GIGACHAT_PRO = 'GigaChat-Pro';
	const GIGACHAT_MAX = 'GigaChat-Max';

	/**
	 * Check if model is valid for text generation
	 *
	 * @param string $model Model name.
	 * @return bool True if valid.
	 */
	public static function is_valid_model( $model ) {
		return in_array( $model, self::get_all_models(), true );
	}

	/**
	 * Get all text model identifiers
	 *
	 * @return array Model identifiers.
	 */
	public static function get_all_models() {
		return array(
			self::GIGACHAT_2,
			self::GIGACHAT_2_PRO,
			self::GIGACHAT_2_MAX,
			self::GIGACHAT,
			self::GIGACHAT_PRO,
			self::GIGACHAT_MAX,
		);
	}

	/**
	 * Get current generation models (recommended)
	 *
	 * @return array Model identifiers.
	 */
	public static function get_generation_models() {
		return array(
			self::GIGACHAT_2,
			self::GIGACHAT_2_PRO,
			self::GIGACHAT_2_MAX,
		);
	}

	/**
	 * Get text model descriptions with metadata
	 *
	 * @return array Models with name and metadata.
	 */
	public static function get_model_descriptions() {
		return array(
			self::GIGACHAT_2     => array(
				'name'      => 'GigaChat 2',
				'expensive' => false,
				'reasoning' => false,
			),
			self::GIGACHAT_2_PRO => array(
				'name'      => 'GigaChat 2 Pro',
				'expensive' => false,
				'reasoning' => false,
			),
			self::GIGACHAT_2_MAX => array(
				'name'      => 'GigaChat 2 Max',
				'expensive' => true,
				'reasoning' => true,
			),
			self::GIGACHAT       => array(
				'name'      => 'GigaChat (Legacy)',
				'expensive' => false,
				'reasoning' => false,
			),
			self::GIGACHAT_PRO   => array(
				'name'      => 'GigaChat Pro (Legacy)',
				'expensive' => false,
				'reasoning' => false,
			),
			self::GIGACHAT_MAX   => array(
				'name'      => 'GigaChat Max (Legacy)',
				'expensive' => true,
				'reasoning' => true,
			),
		);
	}

	/**
	 * Get available image models
	 *
	 * GigaChat generates images through the same chat/completions endpoint.
	 *
	 * @return array Image models.
	 */
	public static function get_image_models() {
		return array(
			'gigachat' => array(
				'name'        => 'GigaChat',
				'resolutions' => array( '1024x1024' ),
			),
		);
	}
}
