use std::collections::HashMap;
use std::sync::OnceLock;
use super::multiavatar_data::{parse, Parts, Themes};
pub struct DataTables {
themes: HashMap<String, HashMap<String, Vec<String>>>,
parts: HashMap<String, HashMap<String, String>>,
}
impl DataTables {
pub fn instance() -> &'static DataTables {
static INSTANCE: OnceLock<DataTables> = OnceLock::new();
INSTANCE.get_or_init(|| {
let (Themes(themes), Parts(parts)) = parse();
DataTables { themes, parts }
})
}
pub fn colors_of(&self, part_key: &str, part_name: &str) -> Option<&Vec<String>> {
self.themes.get(part_key)?.get(part_name)
}
pub fn template_of(&self, part_v: &str, part_name: &str) -> Option<&str> {
self.parts.get(part_v)?.get(part_name).map(|s| s.as_str())
}
}