//! # Routing Module (Future Crate: `rustelo_routing`)
//!
//! Modern routing system for client and SSR that works entirely with
//! TOML-based configuration and supports dynamic language detection.
//!
//! ## Future Crate Boundary
//!
//! **Status:** ✅ Ready for crate extraction
//! **Target Crate:** `rustelo_routing`
//! **Extracted:** Phase 1 completed - zero circular dependencies
//!
//! ### Dependencies (External)
//! - `rustelo_core_types` - Type definitions (already separate crate ✓)
//! - `rustelo_utils` - Utility functions (already separate crate ✓)
//! - `leptos` - Reactive framework
//! - `serde`, `toml` - Configuration parsing
//!
//! ### Dependencies (Internal - will become external)
//! - `crate::i18n` - Language registry (→ `rustelo_i18n`)
//! - `crate::content` - Content type resolution (→ `rustelo_content`)
//!
//! ## Public API
//!
//! This module's public API is stable and ready for external consumption.
//! All re-exports below constitute the stable interface.

pub mod cache;
pub mod components;
pub mod config;
pub mod core_types; // Core types and caches (prevents circular dependencies)
pub mod defs;
pub mod engine;
pub mod generated_access; // Access to generated code via traits
pub mod language;
pub mod mapping;
pub mod seo;
pub mod tracker;
pub mod traits;
pub mod url_generation;
pub mod utils;

// Re-export the core routing API
pub use cache::{
    cached_route_lookup, get_route_cache, init_route_cache, CacheStats, CachedRoute, RouteCache,
    RouteCacheConfig,
};
pub use config::get_routing_config;
// Re-export core routing types (from core_types module)
pub use core_types::{AlternateUrl, BreadcrumbItem, RouteInfo, SitemapEntry};
pub use defs::{NavigationData, Routable, RouteMetadata};
pub use engine::{
    get_language_switch_url, get_menu_navigation, get_route_breadcrumbs, get_routing_engine,
    get_sitemap_routes, get_toml_routes_for_language, is_valid_route, resolve_route,
    resolve_unified_route, NavigationItem, NavigationTarget, RouteMetadata as EngineRouteMetadata,
    RouteResolution, RoutingEngine,
};
pub use rustelo_core_types::{PageComponent, RouteComponent, RouteConfigToml, RoutesConfig};
// Re-export safe path functions (always available)
#[cfg(feature = "manifest")]
pub use rustelo_utils::{
    config_path_safe as get_config_path_buf_safe, content_path_safe as get_content_path_buf_safe,
    i18n_path_safe as get_i18n_path_buf_safe,
};
// Re-export manifest utilities when available
#[cfg(feature = "manifest")]
pub use rustelo_utils::{get_manifest, ManifestError, ManifestResolver, RusteloManifest};
// Re-export compatibility path functions (non-WASM only)
#[cfg(all(feature = "manifest", not(target_arch = "wasm32")))]
pub use rustelo_utils::{
    i18n_path as get_i18n_path_buf, manifest_config_path as get_config_path_buf,
    manifest_content_path as get_content_path_buf,
};
// Re-export available utilities from rustelo_utils (PAP-compliant)
pub use rustelo_utils::{
    normalize_category, normalize_tag, sanitize_html, title_to_slug, to_slug, validate_email,
    validate_file_path, validate_url,
};
pub use tracker::{
    get_tracker, init_navigation_tracker, track_navigation_event, track_route_resolution,
    NavigationEvent, NavigationEventType, NavigationTracker, NavigationTrackingConfig,
};
pub use traits::{ResolvedRoute, RouteHandler, RouteMetadataProvider, RouteRenderer, RouteResult};

// Compatibility wrappers for legacy string-based APIs (internal dependency)
pub use crate::path_resolution::{get_config_path, get_content_path, get_i18n_path};

// ============================================================================
// MODULE ORGANIZATION FOR FUTURE CRATE EXTRACTION
// ============================================================================
//
// ## Core Routing Modules (will be extracted to rustelo_routing crate)
// - cache        - Route caching and optimization
// - components   - Route component definitions
// - core_types   - Shared types and caches (ZERO circular dependencies ✓)
// - config       - Route configuration loading
// - defs         - Route definitions and metadata
// - engine       - Route resolution engine
// - language     - Language detection and switching
// - mapping      - Bidirectional route mappings
// - seo          - SEO utilities (sitemaps, breadcrumbs)
// - tracker      - Navigation tracking
// - traits       - Routing trait definitions
// - url_generation - URL generation utilities
// - utils        - Utility functions (facade pattern)
//
// ## External Dependencies (already separate)
// - rustelo_core_types  ✓
// - rustelo_utils       ✓
//
// ## Internal Dependencies (to be extracted later)
// - crate::i18n           → rustelo_i18n
// - crate::content        → rustelo_content
// - crate::path_resolution → rustelo_utils (or stay in core_lib)
//
// When extracting to rustelo_routing crate:
// 1. Create new crate: rustelo/crates/rustelo_routing/
// 2. Move all modules above to new crate
// 3. Update Cargo.toml dependencies
// 4. Change core_lib: `pub use rustelo_routing as routing;`
// 5. DONE - zero breaking changes due to re-export pattern
//
// ============================================================================
