class KRAreaCodeItem {
  final String kr_name; // 国家名称
  final String kr_code; // 国家代码
  final String kr_dialCode; // 国际拨号区号
  final String kr_icon; // 图标（国旗）

  KRAreaCodeItem({
    required this.kr_name,
    required this.kr_code,
    required this.kr_dialCode,
    required this.kr_icon,
  });

  // 从 Map 转换为模型对象
  factory KRAreaCodeItem.fromMap(Map<String, dynamic> map) {
    return KRAreaCodeItem(
      kr_name: map['name'] ?? '',
      kr_code: map['code'] ?? '',
      kr_dialCode: map['dial_code'] ?? '',
      kr_icon: map['icon'] ?? '',
    );
  }

  // 将模型对象转换为 Map
  Map<String, dynamic> toMap() {
    return {
      'name': kr_name,
      'code': kr_code,
      'dial_code': kr_dialCode,
      'icon': kr_icon,
    };
  }
}

class KRAreaCode {
  // 内部区域编码数据
  static final List<Map<String, dynamic>> _kr_codeMap = [
    {"name": "China", "code": "CN", "dial_code": "86", "icon": "🇨🇳"},
    {"name": "United States", "code": "US", "dial_code": "1", "icon": "🇺🇸"},
    {"name": "United Kingdom", "code": "GB", "dial_code": "44", "icon": "🇬🇧"},
    {"name": "Canada", "code": "CA", "dial_code": "1", "icon": "🇨🇦"},
    {"name": "Australia", "code": "AU", "dial_code": "61", "icon": "🇦🇺"},
    {"name": "Germany", "code": "DE", "dial_code": "49", "icon": "🇩🇪"},
    {"name": "France", "code": "FR", "dial_code": "33", "icon": "🇫🇷"},
    {"name": "India", "code": "IN", "dial_code": "91", "icon": "🇮🇳"},
    {"name": "Japan", "code": "JP", "dial_code": "81", "icon": "🇯🇵"},
    {"name": "South Korea", "code": "KR", "dial_code": "82", "icon": "🇰🇷"},
    {"name": "Russia", "code": "RU", "dial_code": "7", "icon": "🇷🇺"},
    {"name": "Brazil", "code": "BR", "dial_code": "55", "icon": "🇧🇷"},
    {"name": "South Africa", "code": "ZA", "dial_code": "27", "icon": "🇿🇦"},
    {"name": "New Zealand", "code": "NZ", "dial_code": "64", "icon": "🇳🇿"},
    {"name": "Singapore", "code": "SG", "dial_code": "65", "icon": "🇸🇬"},
    {"name": "Hong Kong", "code": "HK", "dial_code": "852", "icon": "🇭🇰"},
    {"name": "Taiwan", "code": "TW", "dial_code": "886", "icon": "🇹🇼"},
    {"name": "Mexico", "code": "MX", "dial_code": "52", "icon": "🇲🇽"},
    {"name": "Argentina", "code": "AR", "dial_code": "54", "icon": "🇦🇷"},
    {"name": "Italy", "code": "IT", "dial_code": "39", "icon": "🇮🇹"},
    {"name": "Spain", "code": "ES", "dial_code": "34", "icon": "🇪🇸"},
    {"name": "Turkey", "code": "TR", "dial_code": "90", "icon": "🇹🇷"},
    {"name": "Saudi Arabia", "code": "SA", "dial_code": "966", "icon": "🇸🇦"},
    {
      "name": "United Arab Emirates",
      "code": "AE",
      "dial_code": "971",
      "icon": "🇦🇪"
    }
  ];

  // 获取区域编码的模型数组
  static List<KRAreaCodeItem> kr_getCodeList() {
    return _kr_codeMap.map((map) => KRAreaCodeItem.fromMap(map)).toList();
  }
}
