//! Resolved types - what consumers see after resolution
//!
//! These types are similar to AST types but represent fully resolved,
//! validated entities with all cross-references resolved.

use crate::syntax::ast::{
    Field,
    Span,
};

/// A fully resolved file with all cross-references resolved
#[derive(Debug, Clone)]
pub struct ResolvedFile {
    pub declarations: Vec<ResolvedDeclaration>,
}

/// A resolved top-level declaration
#[derive(Debug, Clone)]
pub enum ResolvedDeclaration {
    Character(ResolvedCharacter),
    Template(ResolvedTemplate),
    LifeArc(ResolvedLifeArc),
    Schedule(ResolvedSchedule),
    Behavior(ResolvedBehavior),
    Institution(ResolvedInstitution),
    Relationship(ResolvedRelationship),
    Location(ResolvedLocation),
    Species(ResolvedSpecies),
    Enum(ResolvedEnum),
}

/// A resolved character with all template overrides applied
#[derive(Debug, Clone)]
pub struct ResolvedCharacter {
    pub name: String,
    pub species: Option<String>,
    pub fields: Vec<Field>,
    pub span: Span,
    /// Qualified path (e.g., characters::Martha)
    pub qualified_path: Vec<String>,
}

/// A resolved template definition
#[derive(Debug, Clone)]
pub struct ResolvedTemplate {
    pub name: String,
    pub fields: Vec<Field>,
    pub span: Span,
    pub qualified_path: Vec<String>,
}

/// A resolved life arc state machine
#[derive(Debug, Clone)]
pub struct ResolvedLifeArc {
    pub name: String,
    pub states: Vec<ResolvedArcState>,
    pub span: Span,
    pub qualified_path: Vec<String>,
}

#[derive(Debug, Clone)]
pub struct ResolvedArcState {
    pub name: String,
    pub transitions: Vec<ResolvedTransition>,
    pub span: Span,
}

#[derive(Debug, Clone)]
pub struct ResolvedTransition {
    pub to: String,
    /// Validated - target state exists
    pub target_state_index: usize,
    pub condition: crate::syntax::ast::Expr,
    pub span: Span,
}

/// A resolved schedule
#[derive(Debug, Clone)]
pub struct ResolvedSchedule {
    pub name: String,
    pub blocks: Vec<crate::syntax::ast::ScheduleBlock>,
    pub span: Span,
    pub qualified_path: Vec<String>,
}

/// A resolved behavior tree
#[derive(Debug, Clone)]
pub struct ResolvedBehavior {
    pub name: String,
    pub root: crate::syntax::ast::BehaviorNode,
    pub span: Span,
    pub qualified_path: Vec<String>,
}

/// A resolved institution
#[derive(Debug, Clone)]
pub struct ResolvedInstitution {
    pub name: String,
    pub fields: Vec<Field>,
    pub span: Span,
    pub qualified_path: Vec<String>,
}

/// A resolved relationship with both sides validated
#[derive(Debug, Clone)]
pub struct ResolvedRelationship {
    pub name: String,
    pub participants: Vec<crate::syntax::ast::Participant>,
    pub fields: Vec<Field>,
    pub span: Span,
    pub qualified_path: Vec<String>,
}

/// A resolved location
#[derive(Debug, Clone)]
pub struct ResolvedLocation {
    pub name: String,
    pub fields: Vec<Field>,
    pub span: Span,
    pub qualified_path: Vec<String>,
}

/// A resolved species
#[derive(Debug, Clone)]
pub struct ResolvedSpecies {
    pub name: String,
    pub fields: Vec<Field>,
    pub span: Span,
    pub qualified_path: Vec<String>,
}

/// A resolved enum
#[derive(Debug, Clone)]
pub struct ResolvedEnum {
    pub name: String,
    pub variants: Vec<String>,
    pub span: Span,
    pub qualified_path: Vec<String>,
}
