"""ISO 3166 country reference data."""

from __future__ import annotations

from dataclasses import dataclass

from finschema.errors import InvalidCountryError


@dataclass(frozen=True, slots=True)
class CountryInfo:
    alpha2: str
    alpha3: str
    numeric: str
    name: str
    region: str
    sub_region: str


COUNTRIES: dict[str, CountryInfo] = {
    "AD": CountryInfo("AD", "AND", "020", "Andorra", "Unknown", "Unknown"),
    "AE": CountryInfo("AE", "ARE", "784", "United Arab Emirates", "Unknown", "Unknown"),
    "AF": CountryInfo("AF", "AFG", "004", "Afghanistan", "Unknown", "Unknown"),
    "AG": CountryInfo("AG", "ATG", "028", "Antigua and Barbuda", "Unknown", "Unknown"),
    "AI": CountryInfo("AI", "AIA", "660", "Anguilla", "Unknown", "Unknown"),
    "AL": CountryInfo("AL", "ALB", "008", "Albania", "Unknown", "Unknown"),
    "AM": CountryInfo("AM", "ARM", "051", "Armenia", "Unknown", "Unknown"),
    "AO": CountryInfo("AO", "AGO", "024", "Angola", "Unknown", "Unknown"),
    "AQ": CountryInfo("AQ", "ATA", "010", "Antarctica", "Unknown", "Unknown"),
    "AR": CountryInfo("AR", "ARG", "032", "Argentina", "Unknown", "Unknown"),
    "AS": CountryInfo("AS", "ASM", "016", "American Samoa", "Unknown", "Unknown"),
    "AT": CountryInfo("AT", "AUT", "040", "Austria", "Europe", "Western Europe"),
    "AU": CountryInfo("AU", "AUS", "036", "Australia", "Oceania", "Australia and New Zealand"),
    "AW": CountryInfo("AW", "ABW", "533", "Aruba", "Unknown", "Unknown"),
    "AX": CountryInfo("AX", "ALA", "248", "Åland Islands", "Unknown", "Unknown"),
    "AZ": CountryInfo("AZ", "AZE", "031", "Azerbaijan", "Unknown", "Unknown"),
    "BA": CountryInfo("BA", "BIH", "070", "Bosnia and Herzegovina", "Unknown", "Unknown"),
    "BB": CountryInfo("BB", "BRB", "052", "Barbados", "Unknown", "Unknown"),
    "BD": CountryInfo("BD", "BGD", "050", "Bangladesh", "Unknown", "Unknown"),
    "BE": CountryInfo("BE", "BEL", "056", "Belgium", "Europe", "Western Europe"),
    "BF": CountryInfo("BF", "BFA", "854", "Burkina Faso", "Unknown", "Unknown"),
    "BG": CountryInfo("BG", "BGR", "100", "Bulgaria", "Europe", "Eastern Europe"),
    "BH": CountryInfo("BH", "BHR", "048", "Bahrain", "Asia", "Western Asia"),
    "BI": CountryInfo("BI", "BDI", "108", "Burundi", "Unknown", "Unknown"),
    "BJ": CountryInfo("BJ", "BEN", "204", "Benin", "Unknown", "Unknown"),
    "BL": CountryInfo("BL", "BLM", "652", "Saint Barthélemy", "Unknown", "Unknown"),
    "BM": CountryInfo("BM", "BMU", "060", "Bermuda", "Unknown", "Unknown"),
    "BN": CountryInfo("BN", "BRN", "096", "Brunei Darussalam", "Unknown", "Unknown"),
    "BO": CountryInfo("BO", "BOL", "068", "Bolivia, Plurinational State of", "Unknown", "Unknown"),
    "BQ": CountryInfo("BQ", "BES", "535", "Bonaire, Sint Eustatius and Saba", "Unknown", "Unknown"),
    "BR": CountryInfo("BR", "BRA", "076", "Brazil", "Americas", "South America"),
    "BS": CountryInfo("BS", "BHS", "044", "Bahamas", "Unknown", "Unknown"),
    "BT": CountryInfo("BT", "BTN", "064", "Bhutan", "Unknown", "Unknown"),
    "BV": CountryInfo("BV", "BVT", "074", "Bouvet Island", "Unknown", "Unknown"),
    "BW": CountryInfo("BW", "BWA", "072", "Botswana", "Unknown", "Unknown"),
    "BY": CountryInfo("BY", "BLR", "112", "Belarus", "Unknown", "Unknown"),
    "BZ": CountryInfo("BZ", "BLZ", "084", "Belize", "Unknown", "Unknown"),
    "CA": CountryInfo("CA", "CAN", "124", "Canada", "Americas", "Northern America"),
    "CC": CountryInfo("CC", "CCK", "166", "Cocos (Keeling) Islands", "Unknown", "Unknown"),
    "CD": CountryInfo(
        "CD", "COD", "180", "Congo, The Democratic Republic of the", "Unknown", "Unknown"
    ),
    "CF": CountryInfo("CF", "CAF", "140", "Central African Republic", "Unknown", "Unknown"),
    "CG": CountryInfo("CG", "COG", "178", "Congo", "Unknown", "Unknown"),
    "CH": CountryInfo("CH", "CHE", "756", "Switzerland", "Europe", "Western Europe"),
    "CI": CountryInfo("CI", "CIV", "384", "Côte d'Ivoire", "Unknown", "Unknown"),
    "CK": CountryInfo("CK", "COK", "184", "Cook Islands", "Unknown", "Unknown"),
    "CL": CountryInfo("CL", "CHL", "152", "Chile", "Unknown", "Unknown"),
    "CM": CountryInfo("CM", "CMR", "120", "Cameroon", "Unknown", "Unknown"),
    "CN": CountryInfo("CN", "CHN", "156", "China", "Asia", "Eastern Asia"),
    "CO": CountryInfo("CO", "COL", "170", "Colombia", "Unknown", "Unknown"),
    "CR": CountryInfo("CR", "CRI", "188", "Costa Rica", "Unknown", "Unknown"),
    "CU": CountryInfo("CU", "CUB", "192", "Cuba", "Unknown", "Unknown"),
    "CV": CountryInfo("CV", "CPV", "132", "Cabo Verde", "Unknown", "Unknown"),
    "CW": CountryInfo("CW", "CUW", "531", "Curaçao", "Unknown", "Unknown"),
    "CX": CountryInfo("CX", "CXR", "162", "Christmas Island", "Unknown", "Unknown"),
    "CY": CountryInfo("CY", "CYP", "196", "Cyprus", "Unknown", "Unknown"),
    "CZ": CountryInfo("CZ", "CZE", "203", "Czechia", "Europe", "Eastern Europe"),
    "DE": CountryInfo("DE", "DEU", "276", "Germany", "Europe", "Western Europe"),
    "DJ": CountryInfo("DJ", "DJI", "262", "Djibouti", "Unknown", "Unknown"),
    "DK": CountryInfo("DK", "DNK", "208", "Denmark", "Europe", "Northern Europe"),
    "DM": CountryInfo("DM", "DMA", "212", "Dominica", "Unknown", "Unknown"),
    "DO": CountryInfo("DO", "DOM", "214", "Dominican Republic", "Unknown", "Unknown"),
    "DZ": CountryInfo("DZ", "DZA", "012", "Algeria", "Unknown", "Unknown"),
    "EC": CountryInfo("EC", "ECU", "218", "Ecuador", "Unknown", "Unknown"),
    "EE": CountryInfo("EE", "EST", "233", "Estonia", "Unknown", "Unknown"),
    "EG": CountryInfo("EG", "EGY", "818", "Egypt", "Unknown", "Unknown"),
    "EH": CountryInfo("EH", "ESH", "732", "Western Sahara", "Unknown", "Unknown"),
    "ER": CountryInfo("ER", "ERI", "232", "Eritrea", "Unknown", "Unknown"),
    "ES": CountryInfo("ES", "ESP", "724", "Spain", "Europe", "Southern Europe"),
    "ET": CountryInfo("ET", "ETH", "231", "Ethiopia", "Unknown", "Unknown"),
    "FI": CountryInfo("FI", "FIN", "246", "Finland", "Europe", "Northern Europe"),
    "FJ": CountryInfo("FJ", "FJI", "242", "Fiji", "Unknown", "Unknown"),
    "FK": CountryInfo("FK", "FLK", "238", "Falkland Islands (Malvinas)", "Unknown", "Unknown"),
    "FM": CountryInfo("FM", "FSM", "583", "Micronesia, Federated States of", "Unknown", "Unknown"),
    "FO": CountryInfo("FO", "FRO", "234", "Faroe Islands", "Unknown", "Unknown"),
    "FR": CountryInfo("FR", "FRA", "250", "France", "Europe", "Western Europe"),
    "GA": CountryInfo("GA", "GAB", "266", "Gabon", "Unknown", "Unknown"),
    "GB": CountryInfo("GB", "GBR", "826", "United Kingdom", "Europe", "Northern Europe"),
    "GD": CountryInfo("GD", "GRD", "308", "Grenada", "Unknown", "Unknown"),
    "GE": CountryInfo("GE", "GEO", "268", "Georgia", "Unknown", "Unknown"),
    "GF": CountryInfo("GF", "GUF", "254", "French Guiana", "Unknown", "Unknown"),
    "GG": CountryInfo("GG", "GGY", "831", "Guernsey", "Unknown", "Unknown"),
    "GH": CountryInfo("GH", "GHA", "288", "Ghana", "Unknown", "Unknown"),
    "GI": CountryInfo("GI", "GIB", "292", "Gibraltar", "Unknown", "Unknown"),
    "GL": CountryInfo("GL", "GRL", "304", "Greenland", "Unknown", "Unknown"),
    "GM": CountryInfo("GM", "GMB", "270", "Gambia", "Unknown", "Unknown"),
    "GN": CountryInfo("GN", "GIN", "324", "Guinea", "Unknown", "Unknown"),
    "GP": CountryInfo("GP", "GLP", "312", "Guadeloupe", "Unknown", "Unknown"),
    "GQ": CountryInfo("GQ", "GNQ", "226", "Equatorial Guinea", "Unknown", "Unknown"),
    "GR": CountryInfo("GR", "GRC", "300", "Greece", "Unknown", "Unknown"),
    "GS": CountryInfo(
        "GS", "SGS", "239", "South Georgia and the South Sandwich Islands", "Unknown", "Unknown"
    ),
    "GT": CountryInfo("GT", "GTM", "320", "Guatemala", "Unknown", "Unknown"),
    "GU": CountryInfo("GU", "GUM", "316", "Guam", "Unknown", "Unknown"),
    "GW": CountryInfo("GW", "GNB", "624", "Guinea-Bissau", "Unknown", "Unknown"),
    "GY": CountryInfo("GY", "GUY", "328", "Guyana", "Unknown", "Unknown"),
    "HK": CountryInfo("HK", "HKG", "344", "Hong Kong", "Asia", "Eastern Asia"),
    "HM": CountryInfo(
        "HM", "HMD", "334", "Heard Island and McDonald Islands", "Unknown", "Unknown"
    ),
    "HN": CountryInfo("HN", "HND", "340", "Honduras", "Unknown", "Unknown"),
    "HR": CountryInfo("HR", "HRV", "191", "Croatia", "Unknown", "Unknown"),
    "HT": CountryInfo("HT", "HTI", "332", "Haiti", "Unknown", "Unknown"),
    "HU": CountryInfo("HU", "HUN", "348", "Hungary", "Europe", "Eastern Europe"),
    "ID": CountryInfo("ID", "IDN", "360", "Indonesia", "Unknown", "Unknown"),
    "IE": CountryInfo("IE", "IRL", "372", "Ireland", "Europe", "Northern Europe"),
    "IL": CountryInfo("IL", "ISR", "376", "Israel", "Asia", "Western Asia"),
    "IM": CountryInfo("IM", "IMN", "833", "Isle of Man", "Unknown", "Unknown"),
    "IN": CountryInfo("IN", "IND", "356", "India", "Asia", "Southern Asia"),
    "IO": CountryInfo("IO", "IOT", "086", "British Indian Ocean Territory", "Unknown", "Unknown"),
    "IQ": CountryInfo("IQ", "IRQ", "368", "Iraq", "Unknown", "Unknown"),
    "IR": CountryInfo("IR", "IRN", "364", "Iran, Islamic Republic of", "Unknown", "Unknown"),
    "IS": CountryInfo("IS", "ISL", "352", "Iceland", "Europe", "Northern Europe"),
    "IT": CountryInfo("IT", "ITA", "380", "Italy", "Europe", "Southern Europe"),
    "JE": CountryInfo("JE", "JEY", "832", "Jersey", "Unknown", "Unknown"),
    "JM": CountryInfo("JM", "JAM", "388", "Jamaica", "Unknown", "Unknown"),
    "JO": CountryInfo("JO", "JOR", "400", "Jordan", "Unknown", "Unknown"),
    "JP": CountryInfo("JP", "JPN", "392", "Japan", "Asia", "Eastern Asia"),
    "KE": CountryInfo("KE", "KEN", "404", "Kenya", "Unknown", "Unknown"),
    "KG": CountryInfo("KG", "KGZ", "417", "Kyrgyzstan", "Unknown", "Unknown"),
    "KH": CountryInfo("KH", "KHM", "116", "Cambodia", "Unknown", "Unknown"),
    "KI": CountryInfo("KI", "KIR", "296", "Kiribati", "Unknown", "Unknown"),
    "KM": CountryInfo("KM", "COM", "174", "Comoros", "Unknown", "Unknown"),
    "KN": CountryInfo("KN", "KNA", "659", "Saint Kitts and Nevis", "Unknown", "Unknown"),
    "KP": CountryInfo(
        "KP", "PRK", "408", "Korea, Democratic People's Republic of", "Unknown", "Unknown"
    ),
    "KR": CountryInfo("KR", "KOR", "410", "Korea, Republic of", "Asia", "Eastern Asia"),
    "KW": CountryInfo("KW", "KWT", "414", "Kuwait", "Asia", "Western Asia"),
    "KY": CountryInfo("KY", "CYM", "136", "Cayman Islands", "Unknown", "Unknown"),
    "KZ": CountryInfo("KZ", "KAZ", "398", "Kazakhstan", "Unknown", "Unknown"),
    "LA": CountryInfo("LA", "LAO", "418", "Lao People's Democratic Republic", "Unknown", "Unknown"),
    "LB": CountryInfo("LB", "LBN", "422", "Lebanon", "Unknown", "Unknown"),
    "LC": CountryInfo("LC", "LCA", "662", "Saint Lucia", "Unknown", "Unknown"),
    "LI": CountryInfo("LI", "LIE", "438", "Liechtenstein", "Unknown", "Unknown"),
    "LK": CountryInfo("LK", "LKA", "144", "Sri Lanka", "Unknown", "Unknown"),
    "LR": CountryInfo("LR", "LBR", "430", "Liberia", "Unknown", "Unknown"),
    "LS": CountryInfo("LS", "LSO", "426", "Lesotho", "Unknown", "Unknown"),
    "LT": CountryInfo("LT", "LTU", "440", "Lithuania", "Unknown", "Unknown"),
    "LU": CountryInfo("LU", "LUX", "442", "Luxembourg", "Europe", "Western Europe"),
    "LV": CountryInfo("LV", "LVA", "428", "Latvia", "Unknown", "Unknown"),
    "LY": CountryInfo("LY", "LBY", "434", "Libya", "Unknown", "Unknown"),
    "MA": CountryInfo("MA", "MAR", "504", "Morocco", "Africa", "Northern Africa"),
    "MC": CountryInfo("MC", "MCO", "492", "Monaco", "Unknown", "Unknown"),
    "MD": CountryInfo("MD", "MDA", "498", "Moldova, Republic of", "Unknown", "Unknown"),
    "ME": CountryInfo("ME", "MNE", "499", "Montenegro", "Unknown", "Unknown"),
    "MF": CountryInfo("MF", "MAF", "663", "Saint Martin (French part)", "Unknown", "Unknown"),
    "MG": CountryInfo("MG", "MDG", "450", "Madagascar", "Unknown", "Unknown"),
    "MH": CountryInfo("MH", "MHL", "584", "Marshall Islands", "Unknown", "Unknown"),
    "MK": CountryInfo("MK", "MKD", "807", "North Macedonia", "Unknown", "Unknown"),
    "ML": CountryInfo("ML", "MLI", "466", "Mali", "Unknown", "Unknown"),
    "MM": CountryInfo("MM", "MMR", "104", "Myanmar", "Unknown", "Unknown"),
    "MN": CountryInfo("MN", "MNG", "496", "Mongolia", "Unknown", "Unknown"),
    "MO": CountryInfo("MO", "MAC", "446", "Macao", "Unknown", "Unknown"),
    "MP": CountryInfo("MP", "MNP", "580", "Northern Mariana Islands", "Unknown", "Unknown"),
    "MQ": CountryInfo("MQ", "MTQ", "474", "Martinique", "Unknown", "Unknown"),
    "MR": CountryInfo("MR", "MRT", "478", "Mauritania", "Unknown", "Unknown"),
    "MS": CountryInfo("MS", "MSR", "500", "Montserrat", "Unknown", "Unknown"),
    "MT": CountryInfo("MT", "MLT", "470", "Malta", "Unknown", "Unknown"),
    "MU": CountryInfo("MU", "MUS", "480", "Mauritius", "Unknown", "Unknown"),
    "MV": CountryInfo("MV", "MDV", "462", "Maldives", "Unknown", "Unknown"),
    "MW": CountryInfo("MW", "MWI", "454", "Malawi", "Unknown", "Unknown"),
    "MX": CountryInfo("MX", "MEX", "484", "Mexico", "Americas", "Central America"),
    "MY": CountryInfo("MY", "MYS", "458", "Malaysia", "Asia", "South-eastern Asia"),
    "MZ": CountryInfo("MZ", "MOZ", "508", "Mozambique", "Unknown", "Unknown"),
    "NA": CountryInfo("NA", "NAM", "516", "Namibia", "Unknown", "Unknown"),
    "NC": CountryInfo("NC", "NCL", "540", "New Caledonia", "Unknown", "Unknown"),
    "NE": CountryInfo("NE", "NER", "562", "Niger", "Unknown", "Unknown"),
    "NF": CountryInfo("NF", "NFK", "574", "Norfolk Island", "Unknown", "Unknown"),
    "NG": CountryInfo("NG", "NGA", "566", "Nigeria", "Unknown", "Unknown"),
    "NI": CountryInfo("NI", "NIC", "558", "Nicaragua", "Unknown", "Unknown"),
    "NL": CountryInfo("NL", "NLD", "528", "Netherlands", "Europe", "Western Europe"),
    "NO": CountryInfo("NO", "NOR", "578", "Norway", "Europe", "Northern Europe"),
    "NP": CountryInfo("NP", "NPL", "524", "Nepal", "Unknown", "Unknown"),
    "NR": CountryInfo("NR", "NRU", "520", "Nauru", "Unknown", "Unknown"),
    "NU": CountryInfo("NU", "NIU", "570", "Niue", "Unknown", "Unknown"),
    "NZ": CountryInfo("NZ", "NZL", "554", "New Zealand", "Oceania", "Australia and New Zealand"),
    "OM": CountryInfo("OM", "OMN", "512", "Oman", "Unknown", "Unknown"),
    "PA": CountryInfo("PA", "PAN", "591", "Panama", "Unknown", "Unknown"),
    "PE": CountryInfo("PE", "PER", "604", "Peru", "Unknown", "Unknown"),
    "PF": CountryInfo("PF", "PYF", "258", "French Polynesia", "Unknown", "Unknown"),
    "PG": CountryInfo("PG", "PNG", "598", "Papua New Guinea", "Unknown", "Unknown"),
    "PH": CountryInfo("PH", "PHL", "608", "Philippines", "Asia", "South-eastern Asia"),
    "PK": CountryInfo("PK", "PAK", "586", "Pakistan", "Unknown", "Unknown"),
    "PL": CountryInfo("PL", "POL", "616", "Poland", "Europe", "Eastern Europe"),
    "PM": CountryInfo("PM", "SPM", "666", "Saint Pierre and Miquelon", "Unknown", "Unknown"),
    "PN": CountryInfo("PN", "PCN", "612", "Pitcairn", "Unknown", "Unknown"),
    "PR": CountryInfo("PR", "PRI", "630", "Puerto Rico", "Unknown", "Unknown"),
    "PS": CountryInfo("PS", "PSE", "275", "Palestine, State of", "Unknown", "Unknown"),
    "PT": CountryInfo("PT", "PRT", "620", "Portugal", "Europe", "Southern Europe"),
    "PW": CountryInfo("PW", "PLW", "585", "Palau", "Unknown", "Unknown"),
    "PY": CountryInfo("PY", "PRY", "600", "Paraguay", "Unknown", "Unknown"),
    "QA": CountryInfo("QA", "QAT", "634", "Qatar", "Asia", "Western Asia"),
    "RE": CountryInfo("RE", "REU", "638", "Réunion", "Unknown", "Unknown"),
    "RO": CountryInfo("RO", "ROU", "642", "Romania", "Europe", "Eastern Europe"),
    "RS": CountryInfo("RS", "SRB", "688", "Serbia", "Unknown", "Unknown"),
    "RU": CountryInfo("RU", "RUS", "643", "Russian Federation", "Unknown", "Unknown"),
    "RW": CountryInfo("RW", "RWA", "646", "Rwanda", "Unknown", "Unknown"),
    "SA": CountryInfo("SA", "SAU", "682", "Saudi Arabia", "Asia", "Western Asia"),
    "SB": CountryInfo("SB", "SLB", "090", "Solomon Islands", "Unknown", "Unknown"),
    "SC": CountryInfo("SC", "SYC", "690", "Seychelles", "Unknown", "Unknown"),
    "SD": CountryInfo("SD", "SDN", "729", "Sudan", "Unknown", "Unknown"),
    "SE": CountryInfo("SE", "SWE", "752", "Sweden", "Europe", "Northern Europe"),
    "SG": CountryInfo("SG", "SGP", "702", "Singapore", "Asia", "South-eastern Asia"),
    "SH": CountryInfo(
        "SH", "SHN", "654", "Saint Helena, Ascension and Tristan da Cunha", "Unknown", "Unknown"
    ),
    "SI": CountryInfo("SI", "SVN", "705", "Slovenia", "Unknown", "Unknown"),
    "SJ": CountryInfo("SJ", "SJM", "744", "Svalbard and Jan Mayen", "Unknown", "Unknown"),
    "SK": CountryInfo("SK", "SVK", "703", "Slovakia", "Unknown", "Unknown"),
    "SL": CountryInfo("SL", "SLE", "694", "Sierra Leone", "Unknown", "Unknown"),
    "SM": CountryInfo("SM", "SMR", "674", "San Marino", "Unknown", "Unknown"),
    "SN": CountryInfo("SN", "SEN", "686", "Senegal", "Unknown", "Unknown"),
    "SO": CountryInfo("SO", "SOM", "706", "Somalia", "Unknown", "Unknown"),
    "SR": CountryInfo("SR", "SUR", "740", "Suriname", "Unknown", "Unknown"),
    "SS": CountryInfo("SS", "SSD", "728", "South Sudan", "Unknown", "Unknown"),
    "ST": CountryInfo("ST", "STP", "678", "Sao Tome and Principe", "Unknown", "Unknown"),
    "SV": CountryInfo("SV", "SLV", "222", "El Salvador", "Unknown", "Unknown"),
    "SX": CountryInfo("SX", "SXM", "534", "Sint Maarten (Dutch part)", "Unknown", "Unknown"),
    "SY": CountryInfo("SY", "SYR", "760", "Syrian Arab Republic", "Unknown", "Unknown"),
    "SZ": CountryInfo("SZ", "SWZ", "748", "Eswatini", "Unknown", "Unknown"),
    "TC": CountryInfo("TC", "TCA", "796", "Turks and Caicos Islands", "Unknown", "Unknown"),
    "TD": CountryInfo("TD", "TCD", "148", "Chad", "Unknown", "Unknown"),
    "TF": CountryInfo("TF", "ATF", "260", "French Southern Territories", "Unknown", "Unknown"),
    "TG": CountryInfo("TG", "TGO", "768", "Togo", "Unknown", "Unknown"),
    "TH": CountryInfo("TH", "THA", "764", "Thailand", "Asia", "South-eastern Asia"),
    "TJ": CountryInfo("TJ", "TJK", "762", "Tajikistan", "Unknown", "Unknown"),
    "TK": CountryInfo("TK", "TKL", "772", "Tokelau", "Unknown", "Unknown"),
    "TL": CountryInfo("TL", "TLS", "626", "Timor-Leste", "Unknown", "Unknown"),
    "TM": CountryInfo("TM", "TKM", "795", "Turkmenistan", "Unknown", "Unknown"),
    "TN": CountryInfo("TN", "TUN", "788", "Tunisia", "Unknown", "Unknown"),
    "TO": CountryInfo("TO", "TON", "776", "Tonga", "Unknown", "Unknown"),
    "TR": CountryInfo("TR", "TUR", "792", "Türkiye", "Asia", "Western Asia"),
    "TT": CountryInfo("TT", "TTO", "780", "Trinidad and Tobago", "Unknown", "Unknown"),
    "TV": CountryInfo("TV", "TUV", "798", "Tuvalu", "Unknown", "Unknown"),
    "TW": CountryInfo("TW", "TWN", "158", "Taiwan, Province of China", "Asia", "Eastern Asia"),
    "TZ": CountryInfo("TZ", "TZA", "834", "Tanzania, United Republic of", "Unknown", "Unknown"),
    "UA": CountryInfo("UA", "UKR", "804", "Ukraine", "Europe", "Eastern Europe"),
    "UG": CountryInfo("UG", "UGA", "800", "Uganda", "Unknown", "Unknown"),
    "UM": CountryInfo(
        "UM", "UMI", "581", "United States Minor Outlying Islands", "Unknown", "Unknown"
    ),
    "US": CountryInfo("US", "USA", "840", "United States", "Americas", "Northern America"),
    "UY": CountryInfo("UY", "URY", "858", "Uruguay", "Americas", "South America"),
    "UZ": CountryInfo("UZ", "UZB", "860", "Uzbekistan", "Unknown", "Unknown"),
    "VA": CountryInfo("VA", "VAT", "336", "Holy See (Vatican City State)", "Unknown", "Unknown"),
    "VC": CountryInfo("VC", "VCT", "670", "Saint Vincent and the Grenadines", "Unknown", "Unknown"),
    "VE": CountryInfo(
        "VE", "VEN", "862", "Venezuela, Bolivarian Republic of", "Unknown", "Unknown"
    ),
    "VG": CountryInfo("VG", "VGB", "092", "Virgin Islands, British", "Unknown", "Unknown"),
    "VI": CountryInfo("VI", "VIR", "850", "Virgin Islands, U.S.", "Unknown", "Unknown"),
    "VN": CountryInfo("VN", "VNM", "704", "Viet Nam", "Unknown", "Unknown"),
    "VU": CountryInfo("VU", "VUT", "548", "Vanuatu", "Unknown", "Unknown"),
    "WF": CountryInfo("WF", "WLF", "876", "Wallis and Futuna", "Unknown", "Unknown"),
    "WS": CountryInfo("WS", "WSM", "882", "Samoa", "Unknown", "Unknown"),
    "YE": CountryInfo("YE", "YEM", "887", "Yemen", "Unknown", "Unknown"),
    "YT": CountryInfo("YT", "MYT", "175", "Mayotte", "Unknown", "Unknown"),
    "ZA": CountryInfo("ZA", "ZAF", "710", "South Africa", "Africa", "Southern Africa"),
    "ZM": CountryInfo("ZM", "ZMB", "894", "Zambia", "Unknown", "Unknown"),
    "ZW": CountryInfo("ZW", "ZWE", "716", "Zimbabwe", "Unknown", "Unknown"),
}

ISO_COUNTRY_CODES = frozenset(COUNTRIES.keys())
_ALPHA3_INDEX = {info.alpha3: info for info in COUNTRIES.values()}
_NUMERIC_INDEX = {info.numeric: info for info in COUNTRIES.values()}


def get_country_info(value: str) -> CountryInfo:
    normalized = str(value).upper().strip()
    if normalized in COUNTRIES:
        return COUNTRIES[normalized]
    if normalized in _ALPHA3_INDEX:
        return _ALPHA3_INDEX[normalized]
    if normalized in _NUMERIC_INDEX:
        return _NUMERIC_INDEX[normalized]
    raise InvalidCountryError(
        f"{normalized!r} is not a valid ISO 3166 country code",
        field="country",
        expected="ISO 3166 alpha-2, alpha-3 or numeric",
        actual=normalized,
        details={"country_code": normalized},
    )
