//! PAP-Compliant Path Resolution Wrapper
//!
//! This module provides compatibility wrapper around the new manifest-based
//! path resolution system for runtime contexts.

use std::path::PathBuf;

/// Re-export manifest types from the utils crate
#[cfg(feature = "manifest")]
pub use rustelo_utils::{get_manifest, ManifestError, ManifestResolver, RusteloManifest};

/// Compatibility function for legacy code - use manifest system
pub fn get_content_path() -> String {
    #[cfg(feature = "manifest")]
    {
        rustelo_utils::content_path_safe()
            .unwrap_or_else(|_| std::path::PathBuf::from("site/content"))
            .to_string_lossy()
            .to_string()
    }
    #[cfg(not(feature = "manifest"))]
    {
        "site/content".to_string()
    }
}

/// Compatibility function for legacy code - use manifest system
pub fn get_config_path() -> String {
    #[cfg(feature = "manifest")]
    {
        rustelo_utils::config_path_safe()
            .unwrap_or_else(|_| std::path::PathBuf::from("site/config"))
            .to_string_lossy()
            .to_string()
    }
    #[cfg(not(feature = "manifest"))]
    {
        "site/config".to_string()
    }
}

/// Compatibility function for legacy code - use manifest system
pub fn get_i18n_path() -> String {
    #[cfg(feature = "manifest")]
    {
        rustelo_utils::manifest::i18n_path_safe()
            .unwrap_or_else(|_| std::path::PathBuf::from("site/i18n"))
            .to_string_lossy()
            .to_string()
    }
    #[cfg(not(feature = "manifest"))]
    {
        "site/i18n".to_string()
    }
}

/// Get all paths from manifest
#[cfg(feature = "manifest")]
pub fn get_all_paths() -> Result<(PathBuf, PathBuf, PathBuf, PathBuf), ManifestError> {
    let manifest = get_manifest()?;
    Ok((
        manifest.get_path("content")?,
        manifest.get_path("config")?,
        manifest.get_path("i18n")?,
        manifest.get_path("assets")?,
    ))
}

/// Legacy compatibility - simple path structure for non-manifest builds
#[cfg(not(feature = "manifest"))]
pub fn get_all_paths() -> Result<(PathBuf, PathBuf, PathBuf, PathBuf), &'static str> {
    Ok((
        PathBuf::from("site/content"),
        PathBuf::from("site/config"),
        PathBuf::from("site/i18n"),
        PathBuf::from("public"),
    ))
}
