use std::sync::LazyLock;
use crate::js::{self, Value};
pub const DASHBOARD_JS: &str = include_str!("../assets/dashboard.js");
pub const DASHBOARD_CSS: &str = include_str!("../assets/dashboard.css");
pub const WORLD_JSON: &str = include_str!("../assets/world.json");
pub const TRACKER: &str = include_str!("../assets/tracker.js");
pub const PICKER: &str = include_str!("../assets/picker.js");
const BUILD: &str = include_str!("../assets/build.json");
const LOCALES_JSON: &str = include_str!("../assets/locales.json");
pub struct Build {
pub dashboard_hash: String,
pub world_hash: String,
pub locales_hash: String,
pub tracker_hash: String,
}
pub static BUILD_INFO: LazyLock<Build> = LazyLock::new(|| {
let v = js::parse(BUILD).expect("assets/build.json is JSON");
let s = |k: &str| js::str_or_empty(v.get(k));
Build {
dashboard_hash: s("dashboardHash"),
world_hash: s("worldHash"),
locales_hash: s("localesHash"),
tracker_hash: s("trackerHash"),
}
});
pub static LOCALE_TEXTS: LazyLock<Vec<(String, String)>> = LazyLock::new(|| {
let v = js::parse(LOCALES_JSON).expect("assets/locales.json is JSON");
let Value::Object(o) = v else { return Vec::new() };
o.iter().map(|(k, v)| (k.to_string(), js::str_or_empty(Some(v)))).collect()
});
pub fn locales() -> impl Iterator<Item = &'static (String, String)> {
LOCALE_TEXTS.iter().filter(|(k, _)| k != "en")
}