use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)")]
pub enum RoomMemberRole {
    #[sea_orm(string_value = "owner")]
    Owner,
    #[sea_orm(string_value = "admin")]
    Admin,
    #[sea_orm(string_value = "member")]
    Member,
    #[sea_orm(string_value = "guest")]
    Guest,
}

impl std::fmt::Display for RoomMemberRole {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            RoomMemberRole::Owner => write!(f, "owner"),
            RoomMemberRole::Admin => write!(f, "admin"),
            RoomMemberRole::Member => write!(f, "member"),
            RoomMemberRole::Guest => write!(f, "guest"),
        }
    }
}

#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)")]
pub enum MessageSenderType {
    #[sea_orm(string_value = "member")]
    Member,
    #[sea_orm(string_value = "admin")]
    Admin,
    #[sea_orm(string_value = "owner")]
    Owner,
    #[sea_orm(string_value = "ai")]
    Ai,
    #[sea_orm(string_value = "system")]
    System,
    #[sea_orm(string_value = "tool")]
    Tool,
    #[sea_orm(string_value = "guest")]
    Guest,
}

impl std::fmt::Display for MessageSenderType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            MessageSenderType::Member => write!(f, "member"),
            MessageSenderType::Admin => write!(f, "admin"),
            MessageSenderType::Owner => write!(f, "owner"),
            MessageSenderType::Ai => write!(f, "ai"),
            MessageSenderType::System => write!(f, "system"),
            MessageSenderType::Tool => write!(f, "tool"),
            MessageSenderType::Guest => write!(f, "guest"),
        }
    }
}

#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)")]
pub enum MessageContentType {
    #[sea_orm(string_value = "text")]
    Text,
    #[sea_orm(string_value = "image")]
    Image,
    #[sea_orm(string_value = "audio")]
    Audio,
    #[sea_orm(string_value = "video")]
    Video,
    #[sea_orm(string_value = "file")]
    File,
}

impl std::fmt::Display for MessageContentType {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            MessageContentType::Text => write!(f, "text"),
            MessageContentType::Image => write!(f, "image"),
            MessageContentType::Audio => write!(f, "audio"),
            MessageContentType::Video => write!(f, "video"),
            MessageContentType::File => write!(f, "file"),
        }
    }
}

#[derive(Clone, Debug, PartialEq, Eq, EnumIter, DeriveActiveEnum, Serialize, Deserialize)]
#[sea_orm(rs_type = "String", db_type = "String(StringLen::None)")]
pub enum ToolCallStatus {
    #[sea_orm(string_value = "pending")]
    Pending,
    #[sea_orm(string_value = "running")]
    Running,
    #[sea_orm(string_value = "success")]
    Success,
    #[sea_orm(string_value = "failed")]
    Failed,
    #[sea_orm(string_value = "retrying")]
    Retrying,
}

impl std::fmt::Display for ToolCallStatus {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            ToolCallStatus::Pending => write!(f, "pending"),
            ToolCallStatus::Running => write!(f, "running"),
            ToolCallStatus::Success => write!(f, "success"),
            ToolCallStatus::Failed => write!(f, "failed"),
            ToolCallStatus::Retrying => write!(f, "retrying"),
        }
    }
}

pub use room::Entity as Room;
pub use room_ai::Entity as RoomAi;
pub use room_category::Entity as RoomCategory;
pub use room_member::Entity as RoomMember;
pub use room_message::Entity as RoomMessage;
pub use room_message_edit_history::Entity as RoomMessageEditHistory;
pub use room_message_reaction::Entity as RoomMessageReaction;
pub use room_notifications::Entity as RoomNotification;
pub use room_notifications::NotificationType;
pub use room_pin::Entity as RoomPin;
pub use room_thread::Entity as RoomThread;
pub mod room;
pub mod room_ai;
pub mod room_category;
pub mod room_member;
pub mod room_message;
pub mod room_message_edit_history;
pub mod room_message_reaction;
pub mod room_notifications;
pub mod room_pin;
pub mod room_thread;
