<?php
/**
 * Currency Catalog for Vareon Calculator Suite Lite
 *
 * Returns supported ISO currency codes with their symbols and labels.
 * Used by settings UI and sanitization.
 *
 * @package Vareon_Calculator_Suite_Lite
 */

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

if ( ! function_exists( 'vareoncalc_get_currency_catalog' ) ) {
	/**
	 * Get the catalog of supported currencies
	 *
	 * @return array Associative array keyed by ISO code
	 */
	function vareoncalc_get_currency_catalog() {
		return array(
			'USD' => array(
				'symbol' => '$',
				'label'  => 'US Dollar (USD)',
			),
			'EUR' => array(
				'symbol' => '€',
				'label'  => 'Euro (EUR)',
			),
			'GBP' => array(
				'symbol' => '£',
				'label'  => 'British Pound (GBP)',
			),
			'JPY' => array(
				'symbol' => '¥',
				'label'  => 'Japanese Yen (JPY)',
			),
			'CNY' => array(
				'symbol' => '¥',
				'label'  => 'Chinese Yuan (CNY)',
			),
			'INR' => array(
				'symbol' => '₹',
				'label'  => 'Indian Rupee (INR)',
			),
			'AUD' => array(
				'symbol' => 'A$',
				'label'  => 'Australian Dollar (AUD)',
			),
			'CAD' => array(
				'symbol' => 'C$',
				'label'  => 'Canadian Dollar (CAD)',
			),
			'CHF' => array(
				'symbol' => 'CHF',
				'label'  => 'Swiss Franc (CHF)',
			),
			'HKD' => array(
				'symbol' => 'HK$',
				'label'  => 'Hong Kong Dollar (HKD)',
			),
			'SGD' => array(
				'symbol' => 'S$',
				'label'  => 'Singapore Dollar (SGD)',
			),
			'SEK' => array(
				'symbol' => 'kr',
				'label'  => 'Swedish Krona (SEK)',
			),
			'KRW' => array(
				'symbol' => '₩',
				'label'  => 'South Korean Won (KRW)',
			),
			'NOK' => array(
				'symbol' => 'kr',
				'label'  => 'Norwegian Krone (NOK)',
			),
			'NZD' => array(
				'symbol' => 'NZ$',
				'label'  => 'New Zealand Dollar (NZD)',
			),
			'MXN' => array(
				'symbol' => 'MX$',
				'label'  => 'Mexican Peso (MXN)',
			),
			'ZAR' => array(
				'symbol' => 'R',
				'label'  => 'South African Rand (ZAR)',
			),
			'BRL' => array(
				'symbol' => 'R$',
				'label'  => 'Brazilian Real (BRL)',
			),
			'RUB' => array(
				'symbol' => '₽',
				'label'  => 'Russian Ruble (RUB)',
			),
			'TRY' => array(
				'symbol' => '₺',
				'label'  => 'Turkish Lira (TRY)',
			),
			'PLN' => array(
				'symbol' => 'zł',
				'label'  => 'Polish Zloty (PLN)',
			),
			'THB' => array(
				'symbol' => '฿',
				'label'  => 'Thai Baht (THB)',
			),
			'IDR' => array(
				'symbol' => 'Rp',
				'label'  => 'Indonesian Rupiah (IDR)',
			),
			'MYR' => array(
				'symbol' => 'RM',
				'label'  => 'Malaysian Ringgit (MYR)',
			),
			'PHP' => array(
				'symbol' => '₱',
				'label'  => 'Philippine Peso (PHP)',
			),
			'CZK' => array(
				'symbol' => 'Kč',
				'label'  => 'Czech Koruna (CZK)',
			),
			'ILS' => array(
				'symbol' => '₪',
				'label'  => 'Israeli Shekel (ILS)',
			),
			'AED' => array(
				'symbol' => 'د.إ',
				'label'  => 'UAE Dirham (AED)',
			),
			'SAR' => array(
				'symbol' => '﷼',
				'label'  => 'Saudi Riyal (SAR)',
			),
			'DKK' => array(
				'symbol' => 'kr',
				'label'  => 'Danish Krone (DKK)',
			),
			'CLP' => array(
				'symbol' => 'CLP$',
				'label'  => 'Chilean Peso (CLP)',
			),
			'COP' => array(
				'symbol' => 'COL$',
				'label'  => 'Colombian Peso (COP)',
			),
			'ARS' => array(
				'symbol' => 'ARS$',
				'label'  => 'Argentine Peso (ARS)',
			),
			'VND' => array(
				'symbol' => '₫',
				'label'  => 'Vietnamese Dong (VND)',
			),
			'EGP' => array(
				'symbol' => 'E£',
				'label'  => 'Egyptian Pound (EGP)',
			),
			'NGN' => array(
				'symbol' => '₦',
				'label'  => 'Nigerian Naira (NGN)',
			),
			'PKR' => array(
				'symbol' => '₨',
				'label'  => 'Pakistani Rupee (PKR)',
			),
			'BDT' => array(
				'symbol' => '৳',
				'label'  => 'Bangladeshi Taka (BDT)',
			),
			'UAH' => array(
				'symbol' => '₴',
				'label'  => 'Ukrainian Hryvnia (UAH)',
			),
			'RON' => array(
				'symbol' => 'lei',
				'label'  => 'Romanian Leu (RON)',
			),
			'HUF' => array(
				'symbol' => 'Ft',
				'label'  => 'Hungarian Forint (HUF)',
			),
			'BGN' => array(
				'symbol' => 'лв',
				'label'  => 'Bulgarian Lev (BGN)',
			),
			'HRK' => array(
				'symbol' => 'kn',
				'label'  => 'Croatian Kuna (HRK)',
			),
			'ISK' => array(
				'symbol' => 'kr',
				'label'  => 'Icelandic Krona (ISK)',
			),
			'TWD' => array(
				'symbol' => 'NT$',
				'label'  => 'Taiwan Dollar (TWD)',
			),
			'KES' => array(
				'symbol' => 'KSh',
				'label'  => 'Kenyan Shilling (KES)',
			),
			'GHS' => array(
				'symbol' => '₵',
				'label'  => 'Ghanaian Cedi (GHS)',
			),
			'MAD' => array(
				'symbol' => 'د.م.',
				'label'  => 'Moroccan Dirham (MAD)',
			),
			'QAR' => array(
				'symbol' => 'ر.ق',
				'label'  => 'Qatari Riyal (QAR)',
			),
			'KWD' => array(
				'symbol' => 'د.ك',
				'label'  => 'Kuwaiti Dinar (KWD)',
			),
			'BHD' => array(
				'symbol' => '.د.ب',
				'label'  => 'Bahraini Dinar (BHD)',
			),
			'OMR' => array(
				'symbol' => 'ر.ع.',
				'label'  => 'Omani Rial (OMR)',
			),
			'JOD' => array(
				'symbol' => 'د.ا',
				'label'  => 'Jordanian Dinar (JOD)',
			),
			'LKR' => array(
				'symbol' => 'Rs',
				'label'  => 'Sri Lankan Rupee (LKR)',
			),
			'NPR' => array(
				'symbol' => 'रू',
				'label'  => 'Nepalese Rupee (NPR)',
			),
			'PEN' => array(
				'symbol' => 'S/',
				'label'  => 'Peruvian Sol (PEN)',
			),
		);
	}
}

if ( ! function_exists( 'vareoncalc_get_currency_symbol' ) ) {
	/**
	 * Get the symbol for a given ISO currency code
	 *
	 * @param string $code ISO currency code.
	 * @return string|null Symbol or null if not found.
	 */
	function vareoncalc_get_currency_symbol( $code ) {
		$catalog = vareoncalc_get_currency_catalog();
		return isset( $catalog[ $code ] ) ? $catalog[ $code ]['symbol'] : null;
	}
}

if ( ! function_exists( 'vareoncalc_get_currency_code_by_symbol' ) ) {
	/**
	 * Get the currency code for a given symbol (first match)
	 *
	 * @param string $symbol Currency symbol.
	 * @return string|null Currency code or null if not found.
	 */
	function vareoncalc_get_currency_code_by_symbol( $symbol ) {
		$catalog = vareoncalc_get_currency_catalog();
		foreach ( $catalog as $code => $data ) {
			if ( $data['symbol'] === $symbol ) {
				return $code;
			}
		}
		return null;
	}
}
