//! Asset catalog, database, thumbnails, materials, and prefab overrides.

pub mod animation;
pub mod asset_db;
mod catalog;
mod import;
pub mod materials;
pub mod operators;
pub mod prefab_overrides;
pub mod static_mesh;
pub mod thumbnails;

pub use catalog::*;
pub use thumbnails::{
    draw_asset_cell_with, gltf_skinned_primitive_labels, invalidate_on_catalog_refresh, kind_icon,
    prefetch_asset_thumbnails, prefetch_folder_thumbnails, AssetThumbnailCache,
    ThumbnailCacheSnapshot, ThumbnailState, ThumbnailStudio, ThumbnailsPlugin,
};

/// Refreshes both generated contracts derived from one imported model source.
pub fn refresh_model_artifacts(
    record: &mut asset_db::AssetRecord,
) -> Result<static_mesh::StaticMeshManifest, String> {
    let static_mesh = static_mesh::refresh_static_mesh_artifact(record);
    let animation = animation::refresh_animation_artifact(record);
    match (static_mesh, animation) {
        (Ok(static_mesh), Ok(_)) => Ok(static_mesh),
        (Err(static_error), Ok(_)) => Err(format!("static mesh processor failed: {static_error}")),
        (Ok(_), Err(animation_error)) => {
            Err(format!("animation processor failed: {animation_error}"))
        }
        (Err(static_error), Err(animation_error)) => Err(format!(
            "static mesh processor failed: {static_error}; animation processor failed: {animation_error}"
        )),
    }
}
