from __future__ import annotations

from .builders import _validate_unique_attrs, _zone
from .geozone import GeoZone

__all__ = ["load_market_zones"]

MARKET_ZONES = [
    ("PJM_AEP", "PJM AEP", 39.9612, -82.9988, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-AEP",), "coord_source": "seed: module (representative hub point; not authoritative polygon centroid)", "coord_kind": "representative_point", "confidence": "medium"}),
    ("PJM_ATSI", "PJM ATSI", 40.7, -81.0, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-ATSI",), "coord_source": "seed: module (representative hub point; not authoritative polygon centroid)"}),
    ("PJM_COMED", "PJM ComEd", 41.8, -88.0, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("PJM-COMED",), "coord_source": "seed: module (representative hub point; not authoritative polygon centroid)"}),
    ("PJM_DOM", "PJM Dominion", 37.5, -77.5, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-DOM", "PJM_DOMINION"), "coord_source": "seed: module (representative zone point; not authoritative polygon centroid)"}),
    ("PJM_DUQ", "PJM Duquesne", 40.4, -80.0, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-DUQ",)}),
    ("PJM_EKPC", "PJM EKPC", 37.8, -84.3, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-EKPC",)}),
    ("PJM_JCPL", "PJM JCP&L", 40.2, -74.5, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-JCPL",)}),
    ("PJM_METED", "PJM Met-Ed", 40.3, -76.0, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-METED",)}),
    ("PJM_PECO", "PJM PECO", 39.9, -75.2, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-PECO",)}),
    ("PJM_PENELEC", "PJM Penelec", 41.2, -78.0, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-PENELEC",)}),
    ("PJM_PPL", "PJM PPL", 40.6, -75.5, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-PPL",)}),
    ("PJM_PSEG", "PJM PSEG", 40.7, -74.2, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-PSEG",)}),
    ("PJM_RECO", "PJM RECO", 41.1, -74.6, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-RECO",)}),
    ("PJM_WEST", "PJM West Hub", 40.5, -80.5, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-WEST", "PJM_WEST_HUB")}),
    ("PJM_EAST", "PJM East Hub", 40.0, -74.8, {"country_iso": "US", "country_name": "United States", "aliases": ("PJM-EAST", "PJM_EAST_HUB")}),
    ("MISO_NORTH", "MISO North", 46.0, -93.0, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("MISO-NORTH",)}),
    ("MISO_CENTRAL", "MISO Central", 40.5, -89.0, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("MISO-CENTRAL",)}),
    ("MISO_SOUTH", "MISO South", 33.0, -91.0, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("MISO-SOUTH",)}),
    ("MISO_ILLINOIS", "MISO Illinois Hub", 41.8, -87.6, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("MISO-ILLINOIS", "MISO_IL_HUB")}),
    ("MISO_INDIANA", "MISO Indiana Hub", 39.8, -86.2, {"country_iso": "US", "country_name": "United States", "aliases": ("MISO-INDIANA", "MISO_IN_HUB")}),
    ("MISO_MINNESOTA", "MISO Minnesota Hub", 44.9, -93.3, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("MISO-MINNESOTA", "MISO_MN_HUB")}),
    ("NP15", "CAISO NP15", 38.5816, -121.4944, {"tz": "America/Los_Angeles", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("CAISO_NP15",)}),
    ("SP15", "CAISO SP15", 34.0, -118.3, {"tz": "America/Los_Angeles", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("CAISO_SP15",)}),
    ("ZP26", "CAISO ZP26", 37.3, -120.5, {"tz": "America/Los_Angeles", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("CAISO_ZP26",)}),
    ("ERCOT_NORTH", "ERCOT North", 32.7767, -96.7970, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("ERCOT-NORTH",)}),
    ("ERCOT_SOUTH", "ERCOT South", 29.7604, -95.3698, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("ERCOT-SOUTH",)}),
    ("ERCOT_WEST", "ERCOT West", 31.8, -102.0, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("ERCOT-WEST",)}),
    ("ERCOT_HOUSTON", "ERCOT Houston", 29.7604, -95.3698, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("ERCOT-HOUSTON", "ERCOT_HB_HOUSTON")}),
    ("ERCOT_BUSAVG", "ERCOT Bus Average", 31.0, -99.0, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("ERCOT-BUSAVG", "ERCOT_BUS_AVG")}),
    ("ISONE_HUB", "ISO-NE Hub", 42.4, -71.1, {"country_iso": "US", "country_name": "United States", "aliases": ("ISONE-HUB", "ISO_NE_HUB", "NEPOOL_HUB")}),
    ("ISONE_CT", "ISO-NE Connecticut", 41.6, -72.7, {"country_iso": "US", "country_name": "United States", "aliases": ("ISONE-CT", "ISO_NE_CT")}),
    ("ISONE_ME", "ISO-NE Maine", 45.3, -69.4, {"country_iso": "US", "country_name": "United States", "aliases": ("ISONE-ME", "ISO_NE_ME")}),
    ("ISONE_NH", "ISO-NE New Hampshire", 43.2, -71.5, {"country_iso": "US", "country_name": "United States", "aliases": ("ISONE-NH", "ISO_NE_NH")}),
    ("ISONE_RI", "ISO-NE Rhode Island", 41.7, -71.5, {"country_iso": "US", "country_name": "United States", "aliases": ("ISONE-RI", "ISO_NE_RI")}),
    ("ISONE_VT", "ISO-NE Vermont", 44.0, -72.7, {"country_iso": "US", "country_name": "United States", "aliases": ("ISONE-VT", "ISO_NE_VT")}),
    ("ISONE_SEMASS", "ISO-NE SE Massachusetts", 41.9, -70.9, {"country_iso": "US", "country_name": "United States", "aliases": ("ISONE-SEMASS",)}),
    ("ISONE_WCMASS", "ISO-NE WC Massachusetts", 42.2, -71.8, {"country_iso": "US", "country_name": "United States", "aliases": ("ISONE-WCMASS",)}),
    ("ISONE_NEMASS", "ISO-NE NE Massachusetts", 42.4, -71.0, {"country_iso": "US", "country_name": "United States", "aliases": ("ISONE-NEMASS",)}),
    ("NYISO_NYC", "NYISO New York City", 40.7128, -74.0060, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO-NYC", "NYISO_ZONE_J")}),
    ("NYISO_WEST", "NYISO West", 42.9, -78.7, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO-WEST", "NYISO_ZONE_A")}),
    ("NYISO_GENESE", "NYISO Genesee", 43.1, -77.6, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO-GENESE", "NYISO_ZONE_B")}),
    ("NYISO_CENTRL", "NYISO Central", 43.0, -76.2, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO-CENTRL", "NYISO_ZONE_C")}),
    ("NYISO_NORTH", "NYISO North", 44.5, -73.5, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO-NORTH", "NYISO_ZONE_D")}),
    ("NYISO_MHK_VL", "NYISO Mohawk Valley", 43.0, -75.3, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO_ZONE_E", "NYISO-MHK-VL")}),
    ("NYISO_CAPITAL", "NYISO Capital", 42.7, -73.8, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO-CAPITAL", "NYISO_ZONE_F")}),
    ("NYISO_HUD_VL", "NYISO Hudson Valley", 41.7, -74.0, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO-HUD-VL", "NYISO_ZONE_G")}),
    ("NYISO_MILLWD", "NYISO Millwood", 41.2, -73.8, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO-MILLWD", "NYISO_ZONE_H")}),
    ("NYISO_DUNWOD", "NYISO Dunwoodie", 40.9, -73.9, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO-DUNWOD", "NYISO_ZONE_I")}),
    ("NYISO_LI", "NYISO Long Island", 40.8, -73.2, {"country_iso": "US", "country_name": "United States", "aliases": ("NYISO-LI", "NYISO_ZONE_K")}),
    ("SPP_NORTH", "SPP North", 42.0, -98.0, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("SPP-NORTH",)}),
    ("SPP_SOUTH", "SPP South", 35.0, -97.0, {"tz": "America/Chicago", "ccy": "USD", "country_iso": "US", "country_name": "United States", "aliases": ("SPP-SOUTH",)}),
    ("JEPX_HOKKAIDO", "JEPX Hokkaido", 43.0642, 141.3469, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-HOKKAIDO", "JAPAN_HOKKAIDO")}),
    ("JEPX_TOHOKU", "JEPX Tohoku", 38.2688, 140.8721, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-TOHOKU", "JAPAN_TOHOKU")}),
    ("JEPX_TOKYO", "JEPX Tokyo", 35.6762, 139.6503, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-TOKYO", "JAPAN_TOKYO")}),
    ("JEPX_CHUBU", "JEPX Chubu", 35.1802, 136.9066, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-CHUBU", "JAPAN_CHUBU")}),
    ("JEPX_HOKURIKU", "JEPX Hokuriku", 36.5947, 136.6256, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-HOKURIKU", "JAPAN_HOKURIKU")}),
    ("JEPX_KANSAI", "JEPX Kansai", 34.6937, 135.5023, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-KANSAI", "JAPAN_KANSAI")}),
    ("JEPX_CHUGOKU", "JEPX Chugoku", 34.3963, 132.4596, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-CHUGOKU", "JAPAN_CHUGOKU")}),
    ("JEPX_SHIKOKU", "JEPX Shikoku", 33.8416, 132.7658, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-SHIKOKU", "JAPAN_SHIKOKU")}),
    ("JEPX_KYUSHU", "JEPX Kyushu", 33.5902, 130.4017, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-KYUSHU", "JAPAN_KYUSHU")}),
    ("JEPX_OKINAWA", "JEPX Okinawa", 26.2124, 127.6809, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-OKINAWA", "JAPAN_OKINAWA")}),
    ("JEPX_SYSTEM", "JEPX System", 35.6762, 139.6503, {"country_iso": "JP", "country_name": "Japan", "aliases": ("JEPX-SYSTEM", "JAPAN_SYSTEM")}),
    ("AEMO_NSW", "AEMO New South Wales", -33.8688, 151.2093, {"country_iso": "AU", "country_name": "Australia", "aliases": ("AEMO-NSW", "NEM_NSW", "NSW1")}),
    ("AEMO_VIC", "AEMO Victoria", -37.8136, 144.9631, {"tz": "Australia/Melbourne", "ccy": "AUD", "country_iso": "AU", "country_name": "Australia", "aliases": ("AEMO-VIC", "NEM_VIC", "VIC1")}),
    ("AEMO_QLD", "AEMO Queensland", -27.4698, 153.0251, {"tz": "Australia/Brisbane", "ccy": "AUD", "country_iso": "AU", "country_name": "Australia", "aliases": ("AEMO-QLD", "NEM_QLD", "QLD1")}),
    ("AEMO_SA", "AEMO South Australia", -34.9285, 138.6007, {"tz": "Australia/Adelaide", "ccy": "AUD", "country_iso": "AU", "country_name": "Australia", "aliases": ("AEMO-SA", "NEM_SA", "SA1")}),
    ("AEMO_TAS", "AEMO Tasmania", -42.8821, 147.3272, {"tz": "Australia/Hobart", "ccy": "AUD", "country_iso": "AU", "country_name": "Australia", "aliases": ("AEMO-TAS", "NEM_TAS", "TAS1")}),
    ("IEX_NORTHERN", "IEX Northern Region", 28.6139, 77.2090, {"country_iso": "IN", "country_name": "India", "aliases": ("IEX-NORTHERN",)}),
    ("IEX_WESTERN", "IEX Western Region", 19.0760, 72.8777, {"country_iso": "IN", "country_name": "India", "aliases": ("IEX-WESTERN",)}),
    ("IEX_SOUTHERN", "IEX Southern Region", 13.0827, 80.2707, {"country_iso": "IN", "country_name": "India", "aliases": ("IEX-SOUTHERN",)}),
    ("IEX_EASTERN", "IEX Eastern Region", 22.5726, 88.3639, {"country_iso": "IN", "country_name": "India", "aliases": ("IEX-EASTERN",)}),
    ("IEX_NORTHEASTERN", "IEX North-Eastern Region", 26.1445, 91.7362, {"country_iso": "IN", "country_name": "India", "aliases": ("IEX-NORTHEASTERN",)}),
]


def load_market_zones() -> None:
    _validate_unique_attrs(MARKET_ZONES, "MARKET_ZONES")
    for attr, name, lat, lon, kwargs in MARKET_ZONES:
        setattr(GeoZone, attr, _zone(attr, name, lat, lon, **kwargs))