//
//  AppConfig.swift
//  PhysicalWallPaper
//
//  Created by nkl on 2024/12/16.
//

import Foundation

class AppConfig {
    static var appName: String = {
        let appName = Bundle.main.infoDictionary?["CFBundleDisplayName"] as? String ?? "Dmanager"
        return appName
    }()
    
    static var appVersion: String = {
        return Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""
    }()
    
    static let appLanguage: String = {
        let systemLanguages = UserDefaults.standard.value(forKey: "AppleLanguages")
        var currentLanguage: String?
        if let arr = systemLanguages as? [String] {
            currentLanguage = arr.first
        } else if let str = systemLanguages as? String {
            currentLanguage = str
        }
        return currentLanguage ?? "en"
    }()
    
    static var isChinaRegion: Bool {
        let localeId = Locale.current.identifier
        return localeId.contains("_CN")
    }
    
    static var isEURegion : Bool {
        let EURegions: Set<String> = [
            "BE", "FR", "DE", "IT", "LU", "NL", "DK", "IE", "GB", "GR",
            "PT", "ES", "AT", "FI", "SE", "CY", "CZ", "EE", "HU", "LV",
            "LT", "MT", "PL", "SK", "SI", "RO", "BG",
        ]

        guard let currentRegionCode = Locale.current.regionCode else {
            print("无法确定当前地区")
            return false
        }

        return EURegions.contains(currentRegionCode)
    }
}
