import sunny from '@/assets/images/weather-icons/sunny.png';
import overcast from '@/assets/images/weather-icons/overcast.png';
import partlyCloudy from '@/assets/images/weather-icons/partly-cloudy.png';
import scatteredClouds from '@/assets/images/weather-icons/scattered-clouds.png';
import mostlyCloudy from '@/assets/images/weather-icons/mostly-cloudy.png';
import thunderstorm from '@/assets/images/weather-icons/thunderstorm.png';
import shower from '@/assets/images/weather-icons/shower.png';
import heavyShower from '@/assets/images/weather-icons/heavy-shower.png';
import strongThunderstorm from '@/assets/images/weather-icons/strong-thunderstorm.png';
import severeThunderstormHail from '@/assets/images/weather-icons/severe-thunderstorm-hail.png';
import drizzle from '@/assets/images/weather-icons/drizzle.png';
import lightRain from '@/assets/images/weather-icons/light-rain.png';
import moderateRain from '@/assets/images/weather-icons/moderate-rain.png';
import heavyRain from '@/assets/images/weather-icons/heavy-rain.png';
import storm from '@/assets/images/weather-icons/storm.png';
import torrentialRain from '@/assets/images/weather-icons/torrential-rain.png';
import extremeTorrentialRain from '@/assets/images/weather-icons/extreme-torrential-rain.png';
import lightSnow from '@/assets/images/weather-icons/light-snow.png';
import moderateSnow from '@/assets/images/weather-icons/moderate-snow.png';
import heavySnow from '@/assets/images/weather-icons/heavy-snow.png';
import blizzard from '@/assets/images/weather-icons/blizzard.png';
import sleet from '@/assets/images/weather-icons/sleet.png';
import wintryMix from '@/assets/images/weather-icons/wintry-mix.png';
import typhoon from '@/assets/images/weather-icons/typhoon.png';
import tornado from '@/assets/images/weather-icons/tornado.png';
import windy from '@/assets/images/weather-icons/windy.png';
import defaultIcon from '@/assets/images/weather-icons/default.png';

/**
 * 天气类型英文标识符（Key）
 */
export type WeatherType =
  | 'sunny'
  | 'overcast'
  | 'partly-cloudy'
  | 'scattered-clouds'
  | 'mostly-cloudy'
  | 'thunderstorm'
  | 'shower'
  | 'heavy-shower'
  | 'strong-thunderstorm'
  | 'severe-thunderstorm-hail'
  | 'drizzle'
  | 'light-rain'
  | 'moderate-rain'
  | 'heavy-rain'
  | 'storm'
  | 'torrential-rain'
  | 'extreme-torrential-rain'
  | 'light-snow'
  | 'moderate-snow'
  | 'heavy-snow'
  | 'blizzard'
  | 'sleet'
  | 'wintry-mix'
  | 'typhoon'
  | 'tornado'
  | 'windy'
  | 'defaultIcon';

/**
 * 天气图标映射表
 */
export const weatherIcons: Record<WeatherType, string> = {
  sunny: sunny,
  overcast: overcast,
  'partly-cloudy': partlyCloudy,
  'scattered-clouds': scatteredClouds,
  'mostly-cloudy': mostlyCloudy,
  thunderstorm: thunderstorm,
  shower: shower,
  'heavy-shower': heavyShower,
  'strong-thunderstorm': strongThunderstorm,
  'severe-thunderstorm-hail': severeThunderstormHail,
  drizzle: drizzle,
  'light-rain': lightRain,
  'moderate-rain': moderateRain,
  'heavy-rain': heavyRain,
  storm: storm,
  'torrential-rain': torrentialRain,
  'extreme-torrential-rain': extremeTorrentialRain,
  'light-snow': lightSnow,
  'moderate-snow': moderateSnow,
  'heavy-snow': heavySnow,
  blizzard: blizzard,
  sleet: sleet,
  'wintry-mix': wintryMix,
  typhoon: typhoon,
  tornado: tornado,
  windy: windy,
  defaultIcon: defaultIcon,
};

/**
 * 中文天气名称到英文 Key 的映射表
 */
export const chineseToWeatherKey: Record<string, WeatherType> = {
  晴天: 'sunny',
  阴: 'overcast',
  晴间多云: 'partly-cloudy',
  少云: 'scattered-clouds',
  多云: 'mostly-cloudy',
  雷阵雨: 'thunderstorm',
  阵雨: 'shower',
  强阵雨: 'heavy-shower',
  强雷阵雨: 'strong-thunderstorm',
  强雷阵雨伴有冰雹: 'severe-thunderstorm-hail',
  细雨: 'drizzle',
  小雨: 'light-rain',
  中雨: 'moderate-rain',
  大雨: 'heavy-rain',
  暴雨: 'storm',
  大暴雨: 'torrential-rain',
  特大暴雨: 'extreme-torrential-rain',
  小雪: 'light-snow',
  中雪: 'moderate-snow',
  大雪: 'heavy-snow',
  暴雪: 'blizzard',
  雨夹雪: 'sleet',
  阵雨夹雪: 'wintry-mix',
  台风: 'typhoon',
  龙卷风: 'tornado',
  风: 'windy',
  暂无天气: 'defaultIcon',
};

// 反向映射：英文键 -> 中文
export const weatherKeyToChinese: Record<WeatherType, string> = Object.keys(chineseToWeatherKey).reduce((acc, key) => {
  const value = chineseToWeatherKey[key];
  acc[value] = key;
  return acc;
}, {} as Record<WeatherType, string>);
