use std::sync::Arc;
use std::sync::atomic::AtomicBool;
use axum::extract::FromRef;
use axum_extra::extract::cookie::Key;
use sl_glw::GlwEventCache;
use sl_map_apis::map_tiles::MapTileCache;
use sl_map_apis::region::RegionNameToGridCoordinatesCache;
use tokio::sync::Mutex;
use crate::config::Config;
use crate::fonts::FontDirectory;
use crate::jobs::JobStore;
#[derive(Clone, Debug)]
#[expect(
clippy::module_name_repetitions,
reason = "`AppState` is the conventional name for axum shared state and would be ambiguous as just `State`"
)]
pub struct AppState {
pub map_tile_cache: Arc<Mutex<MapTileCache>>,
pub region_cache: Arc<Mutex<RegionNameToGridCoordinatesCache>>,
pub jobs: Arc<JobStore>,
pub config: Arc<Config>,
pub db: sqlx::SqlitePool,
pub cookie_key: Key,
pub library_cleanup_dirty: Arc<AtomicBool>,
pub glw_event_cache: Arc<Mutex<GlwEventCache>>,
pub fonts: Arc<FontDirectory>,
}
impl FromRef<AppState> for Key {
fn from_ref(input: &AppState) -> Self {
input.cookie_key.clone()
}
}