from .base import GEEDatasetEntry


# Define built-in datasets
BUILTIN_DATASETS = {
    "nightlights": GEEDatasetEntry(
        name="nightlights",
        collection="NOAA/VIIRS/DNB/MONTHLY_V1/VCMCFG",
        supported_bands=["avg_rad", "cf_cvg"],
        default_band="avg_rad",
        resolution=463.83,
        temporal_cadence="monthly",
        min_date="2012-04-01",
        max_date="2024-12-01",
        description="VIIRS Nighttime Day/Night Band monthly composites",
        source="NOAA",
        units={"avg_rad": "nanoWatts/cm2/sr", "cf_cvg": "percent"},
        recommended_reducer="mean",
        license="Public Domain",
    ),
    "global_human_modification": GEEDatasetEntry(
        name="global_human_modification",
        collection="CSP/HM/GlobalHumanModification",
        supported_bands=["gHM"],
        default_band="gHM",
        resolution=1000,
        temporal_cadence="single",
        min_date="2016-01-01",
        max_date="2016-12-31",
        description="Global Human Modification index (0-1 scale)",
        source="CSP",
        units={"gHM": "index"},
        recommended_reducer="mean",
    ),
    "population": GEEDatasetEntry(
        name="population",
        collection="CIESIN/GPWv411/GPW_Population_Density",
        supported_bands=["population_density"],
        default_band="population_density",
        resolution=927.67,
        temporal_cadence="yearly",
        min_date="2000-01-01",
        max_date="2020-01-01",
        description="Gridded Population of the World v4.11",
        source="CIESIN",
        units={"population_density": "persons/km²"},
        recommended_reducer="sum",
    ),
    "ghsl_built_up": GEEDatasetEntry(
        name="ghsl_built_up",
        collection="JRC/GHSL/P2023A/GHS_BUILT_S",
        supported_bands=["built_surface"],
        default_band="built_surface",
        resolution=100,
        temporal_cadence="yearly",
        min_date="1975-01-01",
        max_date="2030-01-01",
        description="Global Human Settlement Layer - Built-up surface",
        source="JRC",
        units={"built_surface": "m²"},
        recommended_reducer="sum",
    ),
    "building_height": GEEDatasetEntry(
        name="building_height",
        collection="JRC/GHSL/P2023A/GHS_BUILT_H",
        supported_bands=["built_height"],
        default_band="built_height",
        resolution=100.0,
        temporal_cadence="single",
        min_date="2018-01-01",
        max_date="2018-12-31",
        description="GHSL Global Building Height (2018) derived from Sentinel-1 and SRTM",
        source="JRC",
        units={"built_height": "meters"},
        recommended_reducer="mean",
    ),
    "landcover_modis": GEEDatasetEntry(
        name="landcover_modis",
        collection="MODIS/061/MCD12Q1",
        supported_bands=["LC_Type1", "LC_Type2", "LC_Type3"],
        default_band="LC_Type1",
        resolution=500,
        temporal_cadence="yearly",
        min_date="2001-01-01",
        max_date="2022-01-01",
        description="MODIS Land Cover Type Yearly Global",
        source="NASA",
        units={"LC_Type1": "class", "LC_Type2": "class", "LC_Type3": "class"},
        recommended_reducer="mode",
    ),
    "elevation": GEEDatasetEntry(
        name="elevation",
        collection="USGS/SRTMGL1_003",
        supported_bands=["elevation"],
        default_band="elevation",
        resolution=30,
        temporal_cadence="single",
        min_date="2000-02-11",
        max_date="2000-02-22",
        description="SRTM Digital Elevation Data Version 3.0",
        source="NASA/USGS",
        units={"elevation": "meters"},
        recommended_reducer="mean",
    ),
    "precipitation": GEEDatasetEntry(
        name="precipitation",
        collection="UCSB-CHG/CHIRPS/DAILY",
        supported_bands=["precipitation"],
        default_band="precipitation",
        resolution=5566,
        temporal_cadence="daily",
        min_date="1981-01-01",
        max_date="2025-12-31",
        description="CHIRPS Daily: Climate Hazards Center InfraRed Precipitation",
        source="UCSB/CHG",
        units={"precipitation": "mm/day"},
        recommended_reducer="sum",
    ),
    "surface_temp": GEEDatasetEntry(
        name="surface_temp",
        collection="ECMWF/ERA5_LAND/HOURLY",
        supported_bands=["temperature_2m", "total_precipitation"],
        default_band="temperature_2m",
        resolution=11132.0,
        temporal_cadence="hourly",
        min_date="1950-01-01",
        max_date="2026-01-24",
        description="ERA5-Land hourly data - accumulated to daily",
        source="ECMWF",
        units={"temperature_2m": "Kelvin", "total_precipitation": "m"},
        recommended_reducer="mean",
        license="Creative Commons Attribution 4.0",
    ),
    "ndvi": GEEDatasetEntry(
        name="ndvi",
        collection="MODIS/061/MOD13Q1",
        supported_bands=["NDVI", "EVI"],
        default_band="NDVI",
        resolution=250.0,
        temporal_cadence="monthly",  # 16-day composite
        min_date="2000-02-18",
        max_date="2025-12-31",
        description="MODIS Vegetation Indices 16-Day Global 250m",
        source="NASA LP DAAC",
        units={"NDVI": "index", "EVI": "index"},
        recommended_reducer="mean",
        license="Public Domain",
    ),
    "dynamic_world": GEEDatasetEntry(
        name="dynamic_world",
        collection="GOOGLE/DYNAMICWORLD/V1",
        supported_bands=["label"],
        default_band="label",
        resolution=10.0,
        temporal_cadence="daily",
        min_date="2015-06-27",
        max_date="2025-12-31",
        description="Dynamic World V1: Near real-time 10m Land Use/Land Cover",
        source="Google/WRI",
        units={"label": "class_index"},
        recommended_reducer="mode",
        license="CC-BY-4.0",
    ),
    "water_occurrence": GEEDatasetEntry(
        name="water_occurrence",
        collection="JRC/GSW1_4/GlobalSurfaceWater",
        supported_bands=["occurrence", "change_abs"],
        default_band="occurrence",
        resolution=30.0,
        temporal_cadence="single",
        min_date="1984-03-16",
        max_date="2021-12-31",
        description="Global Surface Water: Spatial and temporal distribution of surface water",
        source="JRC",
        units={"occurrence": "percent"},
        recommended_reducer="mean",
    ),
    "soil_moisture": GEEDatasetEntry(
        name="soil_moisture",
        collection="NASA/SMAP/SPL3SMP_E/006",
        supported_bands=["soil_moisture_am", "soil_moisture_pm"],
        default_band="soil_moisture_am",
        resolution=9000.0,
        temporal_cadence="daily",
        min_date="2015-03-31",
        max_date="2026-01-18",
        description="SMAP L3 Radiometer Global Daily 9 km Soil Moisture",
        source="NASA",
        units={"soil_moisture_am": "m³/m³"},
        recommended_reducer="mean",
        is_nrt=True,
    ),
    "active_fires": GEEDatasetEntry(
        name="active_fires",
        collection="FIRMS",
        supported_bands=["T21", "confidence", "line_number"],
        default_band="T21",
        resolution=375.0,
        temporal_cadence="daily",  # Sub-daily updates available
        min_date="2000-11-01",
        max_date="2026-02-06",  # NRT
        description="Near Real-Time Active Fire locations (VIIRS 375m)",
        source="NASA LANCE/FIRMS",
        units={"T21": "Kelvin"},
        recommended_reducer="max",
        is_nrt=True,
    ),
    "flood_history": GEEDatasetEntry(
        name="flood_history",
        collection="GLOBAL_FLOOD_DB/MODIS_EVENTS/V1",
        supported_bands=["flooded", "duration", "clear_views"],
        default_band="flooded",
        resolution=250.0,
        temporal_cadence="single",
        min_date="2000-01-01",
        max_date="2018-12-31",
        description="Global Flood Database: Observed flood extents from 2000-2018",
        source="Cloud to Street",
        units={"flooded": "binary"},
        recommended_reducer="max",
    ),
    "building_footprints": GEEDatasetEntry(
        name="building_footprints",
        collection="GOOGLE/Research/open-buildings/V3/polygons",
        supported_bands=["confidence", "area_in_meters"],
        default_band="confidence",
        resolution=0.5,  # Sub-meter precision
        temporal_cadence="single",
        min_date="2023-01-01",
        max_date="2023-12-31",
        description="Google Open Buildings V3: AI-derived building footprints",
        source="Google Research",
        units={"area_in_meters": "m²"},
        recommended_reducer="sum",
    ),
    "flood_risk": GEEDatasetEntry(
        name="flood_risk",
        collection="JRC/CEMS/GLOFAS/FloodHazard_v2_1",
        supported_bands=["RP10_depth", "RP100_depth", "RP500_depth"],
        default_band="RP100_depth",
        resolution=30.0,
        temporal_cadence="single",
        min_date="2023-01-01",
        max_date="2023-12-31",
        description="Global River Flood Hazard maps for 10, 100, and 500-year return periods",
        source="Copernicus EMS",
        units={"RP100_depth": "meters"},
        recommended_reducer="max",
    ),
}
