<?php
/**
 * Countries repository for Local SEO.
 *
 * @package SEOvaultSEO\LocalSEO
 */

namespace SEOvaultSEO\LocalSEO;

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

class Countries {

	protected static $cache = null;

	public static function get_all() {
		if ( null !== self::$cache ) {
			return self::$cache;
		}

		self::$cache = array(
			''   => __( 'Choose a country', 'seovault-ai' ),
			'AX' => __( 'Aland Islands', 'seovault-ai' ),
			'AF' => __( 'Afghanistan', 'seovault-ai' ),
			'AL' => __( 'Albania', 'seovault-ai' ),
			'DZ' => __( 'Algeria', 'seovault-ai' ),
			'AD' => __( 'Andorra', 'seovault-ai' ),
			'AO' => __( 'Angola', 'seovault-ai' ),
			'AI' => __( 'Anguilla', 'seovault-ai' ),
			'AQ' => __( 'Antarctica', 'seovault-ai' ),
			'AG' => __( 'Antigua and Barbuda', 'seovault-ai' ),
			'AR' => __( 'Argentina', 'seovault-ai' ),
			'AM' => __( 'Armenia', 'seovault-ai' ),
			'AW' => __( 'Aruba', 'seovault-ai' ),
			'AU' => __( 'Australia', 'seovault-ai' ),
			'AT' => __( 'Austria', 'seovault-ai' ),
			'AZ' => __( 'Azerbaijan', 'seovault-ai' ),
			'BS' => __( 'Bahamas', 'seovault-ai' ),
			'BH' => __( 'Bahrain', 'seovault-ai' ),
			'BD' => __( 'Bangladesh', 'seovault-ai' ),
			'BB' => __( 'Barbados', 'seovault-ai' ),
			'BY' => __( 'Belarus', 'seovault-ai' ),
			'PW' => __( 'Belau', 'seovault-ai' ),
			'BE' => __( 'Belgium', 'seovault-ai' ),
			'BZ' => __( 'Belize', 'seovault-ai' ),
			'BJ' => __( 'Benin', 'seovault-ai' ),
			'BM' => __( 'Bermuda', 'seovault-ai' ),
			'BT' => __( 'Bhutan', 'seovault-ai' ),
			'BO' => __( 'Bolivia', 'seovault-ai' ),
			'BQ' => __( 'Bonaire, Sint Eustatius and Saba', 'seovault-ai' ),
			'BA' => __( 'Bosnia and Herzegovina', 'seovault-ai' ),
			'BW' => __( 'Botswana', 'seovault-ai' ),
			'BV' => __( 'Bouvet Island', 'seovault-ai' ),
			'BR' => __( 'Brazil', 'seovault-ai' ),
			'IO' => __( 'British Indian Ocean Territory', 'seovault-ai' ),
			'VG' => __( 'British Virgin Islands', 'seovault-ai' ),
			'BN' => __( 'Brunei', 'seovault-ai' ),
			'BG' => __( 'Bulgaria', 'seovault-ai' ),
			'BF' => __( 'Burkina Faso', 'seovault-ai' ),
			'BI' => __( 'Burundi', 'seovault-ai' ),
			'KH' => __( 'Cambodia', 'seovault-ai' ),
			'CM' => __( 'Cameroon', 'seovault-ai' ),
			'CA' => __( 'Canada', 'seovault-ai' ),
			'CV' => __( 'Cape Verde', 'seovault-ai' ),
			'KY' => __( 'Cayman Islands', 'seovault-ai' ),
			'CF' => __( 'Central African Republic', 'seovault-ai' ),
			'TD' => __( 'Chad', 'seovault-ai' ),
			'CL' => __( 'Chile', 'seovault-ai' ),
			'CN' => __( 'China', 'seovault-ai' ),
			'CX' => __( 'Christmas Island', 'seovault-ai' ),
			'CC' => __( 'Cocos (Keeling) Islands', 'seovault-ai' ),
			'CO' => __( 'Colombia', 'seovault-ai' ),
			'KM' => __( 'Comoros', 'seovault-ai' ),
			'CG' => __( 'Congo (Brazzaville)', 'seovault-ai' ),
			'CD' => __( 'Congo (Kinshasa)', 'seovault-ai' ),
			'CK' => __( 'Cook Islands', 'seovault-ai' ),
			'CR' => __( 'Costa Rica', 'seovault-ai' ),
			'HR' => __( 'Croatia', 'seovault-ai' ),
			'CU' => __( 'Cuba', 'seovault-ai' ),
			'CW' => __( 'Curacao', 'seovault-ai' ),
			'CY' => __( 'Cyprus', 'seovault-ai' ),
			'CZ' => __( 'Czech Republic', 'seovault-ai' ),
			'DK' => __( 'Denmark', 'seovault-ai' ),
			'DJ' => __( 'Djibouti', 'seovault-ai' ),
			'DM' => __( 'Dominica', 'seovault-ai' ),
			'DO' => __( 'Dominican Republic', 'seovault-ai' ),
			'EC' => __( 'Ecuador', 'seovault-ai' ),
			'EG' => __( 'Egypt', 'seovault-ai' ),
			'SV' => __( 'El Salvador', 'seovault-ai' ),
			'GQ' => __( 'Equatorial Guinea', 'seovault-ai' ),
			'ER' => __( 'Eritrea', 'seovault-ai' ),
			'EE' => __( 'Estonia', 'seovault-ai' ),
			'ET' => __( 'Ethiopia', 'seovault-ai' ),
			'FK' => __( 'Falkland Islands', 'seovault-ai' ),
			'FO' => __( 'Faroe Islands', 'seovault-ai' ),
			'FJ' => __( 'Fiji', 'seovault-ai' ),
			'FI' => __( 'Finland', 'seovault-ai' ),
			'FR' => __( 'France', 'seovault-ai' ),
			'GF' => __( 'French Guiana', 'seovault-ai' ),
			'PF' => __( 'French Polynesia', 'seovault-ai' ),
			'TF' => __( 'French Southern Territories', 'seovault-ai' ),
			'GA' => __( 'Gabon', 'seovault-ai' ),
			'GM' => __( 'Gambia', 'seovault-ai' ),
			'GE' => __( 'Georgia', 'seovault-ai' ),
			'DE' => __( 'Germany', 'seovault-ai' ),
			'GH' => __( 'Ghana', 'seovault-ai' ),
			'GI' => __( 'Gibraltar', 'seovault-ai' ),
			'GR' => __( 'Greece', 'seovault-ai' ),
			'GL' => __( 'Greenland', 'seovault-ai' ),
			'GD' => __( 'Grenada', 'seovault-ai' ),
			'GP' => __( 'Guadeloupe', 'seovault-ai' ),
			'GT' => __( 'Guatemala', 'seovault-ai' ),
			'GG' => __( 'Guernsey', 'seovault-ai' ),
			'GN' => __( 'Guinea', 'seovault-ai' ),
			'GW' => __( 'Guinea-Bissau', 'seovault-ai' ),
			'GY' => __( 'Guyana', 'seovault-ai' ),
			'HT' => __( 'Haiti', 'seovault-ai' ),
			'HM' => __( 'Heard Island and McDonald Islands', 'seovault-ai' ),
			'HN' => __( 'Honduras', 'seovault-ai' ),
			'HK' => __( 'Hong Kong', 'seovault-ai' ),
			'HU' => __( 'Hungary', 'seovault-ai' ),
			'IS' => __( 'Iceland', 'seovault-ai' ),
			'IN' => __( 'India', 'seovault-ai' ),
			'ID' => __( 'Indonesia', 'seovault-ai' ),
			'IR' => __( 'Iran', 'seovault-ai' ),
			'IQ' => __( 'Iraq', 'seovault-ai' ),
			'IM' => __( 'Isle of Man', 'seovault-ai' ),
			'IL' => __( 'Israel', 'seovault-ai' ),
			'IT' => __( 'Italy', 'seovault-ai' ),
			'CI' => __( 'Ivory Coast', 'seovault-ai' ),
			'JM' => __( 'Jamaica', 'seovault-ai' ),
			'JP' => __( 'Japan', 'seovault-ai' ),
			'JE' => __( 'Jersey', 'seovault-ai' ),
			'JO' => __( 'Jordan', 'seovault-ai' ),
			'KZ' => __( 'Kazakhstan', 'seovault-ai' ),
			'KE' => __( 'Kenya', 'seovault-ai' ),
			'KI' => __( 'Kiribati', 'seovault-ai' ),
			'KW' => __( 'Kuwait', 'seovault-ai' ),
			'KG' => __( 'Kyrgyzstan', 'seovault-ai' ),
			'LA' => __( 'Laos', 'seovault-ai' ),
			'LV' => __( 'Latvia', 'seovault-ai' ),
			'LB' => __( 'Lebanon', 'seovault-ai' ),
			'LS' => __( 'Lesotho', 'seovault-ai' ),
			'LR' => __( 'Liberia', 'seovault-ai' ),
			'LY' => __( 'Libya', 'seovault-ai' ),
			'LI' => __( 'Liechtenstein', 'seovault-ai' ),
			'LT' => __( 'Lithuania', 'seovault-ai' ),
			'LU' => __( 'Luxembourg', 'seovault-ai' ),
			'MO' => __( 'Macao S.A.R., China', 'seovault-ai' ),
			'MK' => __( 'Macedonia', 'seovault-ai' ),
			'MG' => __( 'Madagascar', 'seovault-ai' ),
			'MW' => __( 'Malawi', 'seovault-ai' ),
			'MY' => __( 'Malaysia', 'seovault-ai' ),
			'MV' => __( 'Maldives', 'seovault-ai' ),
			'ML' => __( 'Mali', 'seovault-ai' ),
			'MT' => __( 'Malta', 'seovault-ai' ),
			'MH' => __( 'Marshall Islands', 'seovault-ai' ),
			'MQ' => __( 'Martinique', 'seovault-ai' ),
			'MR' => __( 'Mauritania', 'seovault-ai' ),
			'MU' => __( 'Mauritius', 'seovault-ai' ),
			'YT' => __( 'Mayotte', 'seovault-ai' ),
			'MX' => __( 'Mexico', 'seovault-ai' ),
			'FM' => __( 'Micronesia', 'seovault-ai' ),
			'MD' => __( 'Republic of Moldova', 'seovault-ai' ),
			'MC' => __( 'Monaco', 'seovault-ai' ),
			'MN' => __( 'Mongolia', 'seovault-ai' ),
			'ME' => __( 'Montenegro', 'seovault-ai' ),
			'MS' => __( 'Montserrat', 'seovault-ai' ),
			'MA' => __( 'Morocco', 'seovault-ai' ),
			'MZ' => __( 'Mozambique', 'seovault-ai' ),
			'MM' => __( 'Myanmar', 'seovault-ai' ),
			'NA' => __( 'Namibia', 'seovault-ai' ),
			'NR' => __( 'Nauru', 'seovault-ai' ),
			'NP' => __( 'Nepal', 'seovault-ai' ),
			'NL' => __( 'Netherlands', 'seovault-ai' ),
			'AN' => __( 'Netherlands Antilles', 'seovault-ai' ),
			'NC' => __( 'New Caledonia', 'seovault-ai' ),
			'NZ' => __( 'New Zealand', 'seovault-ai' ),
			'NI' => __( 'Nicaragua', 'seovault-ai' ),
			'NE' => __( 'Niger', 'seovault-ai' ),
			'NG' => __( 'Nigeria', 'seovault-ai' ),
			'NU' => __( 'Niue', 'seovault-ai' ),
			'NF' => __( 'Norfolk Island', 'seovault-ai' ),
			'KP' => __( 'North Korea', 'seovault-ai' ),
			'NO' => __( 'Norway', 'seovault-ai' ),
			'OM' => __( 'Oman', 'seovault-ai' ),
			'PK' => __( 'Pakistan', 'seovault-ai' ),
			'PS' => __( 'Palestinian Territory', 'seovault-ai' ),
			'PA' => __( 'Panama', 'seovault-ai' ),
			'PG' => __( 'Papua New Guinea', 'seovault-ai' ),
			'PY' => __( 'Paraguay', 'seovault-ai' ),
			'PE' => __( 'Peru', 'seovault-ai' ),
			'PH' => __( 'Philippines', 'seovault-ai' ),
			'PN' => __( 'Pitcairn Islands', 'seovault-ai' ),
			'PL' => __( 'Poland', 'seovault-ai' ),
			'PT' => __( 'Portugal', 'seovault-ai' ),
			'QA' => __( 'Qatar', 'seovault-ai' ),
			'IE' => __( 'Republic of Ireland', 'seovault-ai' ),
			'RE' => __( 'Reunion', 'seovault-ai' ),
			'RO' => __( 'Romania', 'seovault-ai' ),
			'RU' => __( 'Russia', 'seovault-ai' ),
			'RW' => __( 'Rwanda', 'seovault-ai' ),
			'ST' => __( 'Sao Tome and Principe', 'seovault-ai' ),
			'BL' => __( 'Saint Barthelemy', 'seovault-ai' ),
			'SH' => __( 'Saint Helena', 'seovault-ai' ),
			'KN' => __( 'Saint Kitts and Nevis', 'seovault-ai' ),
			'LC' => __( 'Saint Lucia', 'seovault-ai' ),
			'SX' => __( 'Saint Martin (Dutch part)', 'seovault-ai' ),
			'MF' => __( 'Saint Martin (French part)', 'seovault-ai' ),
			'PM' => __( 'Saint Pierre and Miquelon', 'seovault-ai' ),
			'VC' => __( 'Saint Vincent and the Grenadines', 'seovault-ai' ),
			'SM' => __( 'San Marino', 'seovault-ai' ),
			'SA' => __( 'Saudi Arabia', 'seovault-ai' ),
			'SN' => __( 'Senegal', 'seovault-ai' ),
			'RS' => __( 'Serbia', 'seovault-ai' ),
			'SC' => __( 'Seychelles', 'seovault-ai' ),
			'SL' => __( 'Sierra Leone', 'seovault-ai' ),
			'SG' => __( 'Singapore', 'seovault-ai' ),
			'SK' => __( 'Slovakia', 'seovault-ai' ),
			'SI' => __( 'Slovenia', 'seovault-ai' ),
			'SB' => __( 'Solomon Islands', 'seovault-ai' ),
			'SO' => __( 'Somalia', 'seovault-ai' ),
			'ZA' => __( 'South Africa', 'seovault-ai' ),
			'GS' => __( 'South Georgia/Sandwich Islands', 'seovault-ai' ),
			'KR' => __( 'South Korea', 'seovault-ai' ),
			'SS' => __( 'South Sudan', 'seovault-ai' ),
			'ES' => __( 'Spain', 'seovault-ai' ),
			'LK' => __( 'Sri Lanka', 'seovault-ai' ),
			'SD' => __( 'Sudan', 'seovault-ai' ),
			'SR' => __( 'Suriname', 'seovault-ai' ),
			'SJ' => __( 'Svalbard and Jan Mayen', 'seovault-ai' ),
			'SZ' => __( 'Swaziland', 'seovault-ai' ),
			'SE' => __( 'Sweden', 'seovault-ai' ),
			'CH' => __( 'Switzerland', 'seovault-ai' ),
			'SY' => __( 'Syria', 'seovault-ai' ),
			'TW' => __( 'Taiwan', 'seovault-ai' ),
			'TJ' => __( 'Tajikistan', 'seovault-ai' ),
			'TZ' => __( 'Tanzania', 'seovault-ai' ),
			'TH' => __( 'Thailand', 'seovault-ai' ),
			'TL' => __( 'Timor-Leste', 'seovault-ai' ),
			'TG' => __( 'Togo', 'seovault-ai' ),
			'TK' => __( 'Tokelau', 'seovault-ai' ),
			'TO' => __( 'Tonga', 'seovault-ai' ),
			'TT' => __( 'Trinidad and Tobago', 'seovault-ai' ),
			'TN' => __( 'Tunisia', 'seovault-ai' ),
			'TR' => __( 'Turkey', 'seovault-ai' ),
			'TM' => __( 'Turkmenistan', 'seovault-ai' ),
			'TC' => __( 'Turks and Caicos Islands', 'seovault-ai' ),
			'TV' => __( 'Tuvalu', 'seovault-ai' ),
			'UG' => __( 'Uganda', 'seovault-ai' ),
			'UA' => __( 'Ukraine', 'seovault-ai' ),
			'AE' => __( 'United Arab Emirates', 'seovault-ai' ),
			'GB' => __( 'United Kingdom (UK)', 'seovault-ai' ),
			'US' => __( 'United States (US)', 'seovault-ai' ),
			'UY' => __( 'Uruguay', 'seovault-ai' ),
			'UZ' => __( 'Uzbekistan', 'seovault-ai' ),
			'VU' => __( 'Vanuatu', 'seovault-ai' ),
			'VA' => __( 'Vatican', 'seovault-ai' ),
			'VE' => __( 'Venezuela', 'seovault-ai' ),
			'VN' => __( 'Vietnam', 'seovault-ai' ),
			'WF' => __( 'Wallis and Futuna', 'seovault-ai' ),
			'EH' => __( 'Western Sahara', 'seovault-ai' ),
			'WS' => __( 'Western Samoa', 'seovault-ai' ),
			'YE' => __( 'Yemen', 'seovault-ai' ),
			'ZM' => __( 'Zambia', 'seovault-ai' ),
			'ZW' => __( 'Zimbabwe', 'seovault-ai' ),
		);

		return self::$cache;
	}

	public static function get_name( $code ) {
		$countries = self::get_all();
		if ( '' === $code || ! isset( $countries[ $code ] ) ) {
			return false;
		}
		return $countries[ $code ];
	}

	public static function is_valid( $code ) {
		$countries = self::get_all();
		return isset( $countries[ $code ] ) && '' !== $code;
	}
}
