use std::sync::LazyLock;
use base64::{engine::general_purpose, Engine as _};
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Constants {
pub(crate) image_ua: String,
pub(crate) api_ua: String,
pub(crate) os_ver: &'static str,
pub(crate) app_ver: &'static str,
pub(crate) os_name: &'static str,
}
pub static ANDROID_CONSTANTS: LazyLock<Constants> = LazyLock::new(|| {
Constants {
image_ua: "Dalvik/2.1.0 (Linux; U; Android 14; SM-A156E Build/UP1A.231005.007)".to_string(),
api_ua: "okhttp/4.9.0".to_string(),
os_ver: "34", app_ver: "1024",
os_name: "android",
}
});
pub static BASE_API: LazyLock<String> = LazyLock::new(|| {
String::from_utf8(
general_purpose::STANDARD
.decode("aHR0cHM6Ly9qdW1wZy1hcGkudG9reW8tY2RuLmNvbS9hcGk=")
.expect("Failed to decode base64 BASE_API"),
)
.expect("Invalid base64 string (BASE_API)")
});
pub static BASE_IMG: LazyLock<String> = LazyLock::new(|| {
String::from_utf8(
general_purpose::STANDARD
.decode("aHR0cHM6Ly9tYW5nYXBsdXMuc2h1ZWlzaGEuY28uanA=")
.expect("Failed to decode base64 BASE_IMG"),
)
.expect("Invalid base64 string (BASE_IMG)")
});
pub static BASE_HOST: LazyLock<String> = LazyLock::new(|| {
String::from_utf8(
general_purpose::STANDARD
.decode("bWFuZ2FwbHVzLnNodWVpc2hhLmNvLmpw")
.expect("Failed to decode base64 BASE_HOST"),
)
.expect("Invalid base64 string (BASE_HOST)")
});
pub static API_HOST: LazyLock<String> = LazyLock::new(|| {
String::from_utf8(
general_purpose::STANDARD
.decode("anVtcGctYXBpLnRva3lvLWNkbi5jb20=")
.expect("Failed to decode base64 API_HOST"),
)
.expect("Invalid base64 string (API_HOST)")
});
pub static IMAGE_HOST: LazyLock<String> = LazyLock::new(|| {
String::from_utf8(
general_purpose::STANDARD
.decode("bWFuZ2FwbHVzLnNodWVpc2hhLmNvLmpw")
.expect("Failed to decode base64 IMAGE_HOST"),
)
.expect("Invalid base64 string (IMAGE_HOST)")
});
pub fn get_constants(device_type: u8) -> &'static Constants {
match device_type {
1 => &ANDROID_CONSTANTS,
_ => panic!("Invalid device type"),
}
}