import SunIcon from "~/assets/images/public/weather/1.png";
import CloudIcon from "~/assets/images/public/weather/2.png";
import CloudSunIcon from "~/assets/images/public/weather/3.png";
import ThunderstormIcon from "~/assets/images/public/weather/4.png";
import MildRainIcon from "~/assets/images/public/weather/5.png";
import ModerateRainIcon from "~/assets/images/public/weather/6.png";
import HeavyRainIcon from "~/assets/images/public/weather/7.png";
import StormRainIcon from "~/assets/images/public/weather/8.png";
import SnowIcon from "~/assets/images/public/weather/9.png";
import ModerateSnowIcon from "~/assets/images/public/weather/10.png";
import HeavySnowIcon from "~/assets/images/public/weather/11.png";
import SnowRainIcon from "~/assets/images/public/weather/12.png";
import FogIcon from "~/assets/images/public/weather/13.png";
import HazeIcon from "~/assets/images/public/weather/14.png";
import DustIcon from "~/assets/images/public/weather/15.png";
import DuststormIcon from "~/assets/images/public/weather/16.png";

export const weatherIconMap = {
  晴天: SunIcon,
  晴: SunIcon,
  多云: CloudSunIcon,
  阴: CloudIcon,
  雷阵雨: ThunderstormIcon,
  小雨: MildRainIcon,
  中雨: ModerateRainIcon,
  大雨: HeavyRainIcon,
  暴雨: StormRainIcon,
  小雪: SnowIcon,
  中雪: ModerateSnowIcon,
  大雪: HeavySnowIcon,
  雨夹雪: SnowRainIcon,
  雾: FogIcon,
  霾: HazeIcon,
  浮尘: DustIcon,
  沙尘暴: DuststormIcon,
  默认: SunIcon,
};

export const getWeatherIcon = (weatherName) => {
  if (!weatherName)
    return weatherIconMap["默认"];

  for (const [key, icon] of Object.entries(weatherIconMap)) {
    if (weatherName.includes(key))
      return icon;
  }
  return weatherIconMap["默认"];
};

export const getAlertColor = (level) => {
  return { 蓝色预警: "#1E90FF", 黄色预警: "#FFA500", 橙色预警: "#FF4500", 红色预警: "#FF0000" }[level] || "#fff";
};
