from gallery.sketch.weather.model import (
    Cloudness,
    Precipitation,
    Sky,
    WindDirection,
    WindDirectionDeg,
)


def wind_direction_icon(wind_direction_deg: float) -> str:
    wind_direction = WindDirectionDeg(wind_direction_deg).direction
    return {
        WindDirection.N: "⬇️",
        WindDirection.NE: "↙️",
        WindDirection.E: "⬅️",
        WindDirection.SE: "↖️",
        WindDirection.S: "⬆️",
        WindDirection.SW: "↗️",
        WindDirection.W: "➡️",
        WindDirection.NW: "↘️",
        WindDirection.CALM: "",
    }.get(wind_direction, wind_direction)


def cloudness_icon(sky: Sky) -> list[str]:
    main_icon = ""
    if sky.thunder:
        if sky.cloudness == Cloudness.CLEAR:
            main_icon = "🌩️"
        if sky.precipitation == Precipitation.NO:
            main_icon = "⚡"
        else:
            main_icon = "⛈️"
    elif sky.precipitation == Precipitation.NO:
        main_icon = {
            Cloudness.CLEAR: "☀️",
            Cloudness.PARTLY_CLOUDY: "🌤️",
            Cloudness.CLOUDY: "⛅",
            Cloudness.MAINLY_CLOUDY: "☁️",
        }[sky.cloudness]
    elif sky.precipitation in [Precipitation.SNOW, Precipitation.HEAVY_SNOW]:
        main_icon = "🌨️"
    else:
        main_icon = "🌧️"
    icons = [main_icon]
    if sky.fog:
        icons.append("🌫️")
    return icons
