#[derive(serde::Serialize)]
pub struct Notice {
    pub status: String,  //"info",
    pub message: String, //"test message",
    pub details: String, //"test details",
    pub priority: bool,  //false,
    pub url: String,     //"hottub:\/\/upgrade?source=hottub"
}

#[derive(serde::Serialize)]
pub struct Channel {
    pub id: String,              //"hottub",
    pub name: String,            //"Hot Tub Pro",
    pub description: String, //"Advanced search, filters, and more. Consider supporting the development of Hot Tub by upgrading to Hot Tub Pro.",
    pub premium: bool,       //true,
    pub favicon: String, //"https:\/\/www.google.com/s2/favicons?sz=64&domain=https:\/\/hottubapp.io",
    pub status: String,  //"active",
    pub categories: Vec<String>, //[],
    pub options: Vec<ChannelOption>,
    pub nsfw: bool, //true
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cacheDuration: Option<u32>, //Some(86400)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ytdlpCommand: Option<String>, //Some("yt-dlp --impersonate chrome-120")
}

#[derive(serde::Serialize, Debug, Clone)]
pub struct ChannelGroup {
    pub id: String,
    pub title: String,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub systemImage: Option<String>,
    pub channelIds: Vec<String>,
}

#[derive(serde::Serialize)]
pub struct ChannelOption {
    pub id: String,                 //"channels",
    pub title: String,              //"Sites",
    pub description: String,        //"Websites included in search results.",
    pub systemImage: String,        //"network",
    pub colorName: String,          //"purple",
    pub options: Vec<FilterOption>, //[],
    pub multiSelect: bool,          //true
}

#[derive(serde::Serialize, Debug, Clone)]
pub struct FilterOption {
    pub id: String,    //"sort",
    pub title: String, //"Sort",
}

#[derive(serde::Serialize)]
pub struct Options {
    pub id: String,          //"sort",
    pub title: String,       //"Sort",
    pub description: String, //"Sort the videos by new or old.",
    pub systemImage: String, //"sort.image",
    pub colorName: String,   //"blue",
    pub options: Vec<OptionValue>,
}

#[derive(serde::Serialize)]
pub struct OptionValue {
    pub id: String,                  //"new",
    pub title: String,               //"New",
    pub description: Option<String>, //"Sort the videos by new or old."
}

#[derive(serde::Serialize)]
pub struct Subscription {
    pub status: String, //"incomplete"
}

#[derive(serde::Serialize)]
pub struct CdnReferrer {
    pub hostContains: String,
    pub referer: String,
    pub origin: String,
}

impl Subscription {
    pub fn new() -> Self {
        Subscription {
            status: "incomplete".to_string(),
        }
    }
}

#[derive(serde::Serialize)]
pub struct Status {
    pub id: String,          //"spacemoehrehottub",
    pub name: String,        //"SpaceMoehre's Hot Tub",
    pub subtitle: String,    //"More sources, more videos, more fun!",
    pub description: String, //"SpaceMoehre's Hot Tub is a source for finding videos from various websites.",
    pub iconUrl: String,     //"https://hottubapp.io/files/hottub/appicon.png",
    pub color: String,       //"\#A700FF",
    pub status: String,      //"normal",
    pub notices: Vec<Notice>,
    pub channels: Vec<Channel>,
    pub subscription: Subscription,
    pub nsfw: bool,
    pub categories: Vec<String>,
    pub options: Vec<Options>,
    pub cdnReferrers: Vec<CdnReferrer>,
    pub filtersFooter: String, //"Help us improve our algorithms by selecting the categories that best describe you. These will not necessarily affect your search results, but will help us tailor the app to your interests."
}
impl Status {
    pub fn new() -> Self {
        Status {
            id: "spacemoehre".to_string(),
            name: "SpaceMoehre's Hot Tub".to_string(),
            subtitle: "More sources, more videos, more fun!".to_string(),
            description:
                "SpaceMoehre's Hot Tub is a source for finding videos from various websites."
                    .to_string(),
            iconUrl: "https://hottubapp.io/files/hottub/appicon.png".to_string(),
            color: "#FFA500".to_string(),
            status: "normal".to_string(),
            notices: vec![],
            channels: vec![],
            subscription: Subscription::new(),
            nsfw: true,
            categories: vec![],
            options: vec![],
            cdnReferrers: vec![CdnReferrer {
                hostContains: "phncdn".to_string(),
                referer: "https://www.pornhub.com/".to_string(),
                origin: "https://www.pornhub.com".to_string(),
            }],
            filtersFooter:
                "Help us improve our algorithms by giving us your feedback on the hottub discord."
                    .to_string(),
        }
    }
    pub fn add_channel(&mut self, channel: Channel) {
        self.channels.push(channel);
    }
}

#[derive(serde::Serialize)]
pub struct ChannelView {
    pub id: String,
    pub name: String,
    pub description: String,
    pub premium: bool,
    pub favicon: String,
    pub status: String,
    pub categories: Vec<String>,
    pub options: Vec<ChannelOption>,
    pub nsfw: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub groupKey: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sortOrder: Option<u32>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<Vec<String>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ytdlpCommand: Option<String>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cacheDuration: Option<u32>,
}

#[derive(serde::Serialize)]
pub struct StatusResponse {
    pub id: String,
    pub name: String,
    pub subtitle: String,
    pub description: String,
    pub iconUrl: String,
    pub color: String,
    pub status: String,
    pub notices: Vec<Notice>,
    pub channels: Vec<ChannelView>,
    pub channelGroups: Vec<ChannelGroup>,
    pub subscription: Subscription,
    pub nsfw: bool,
    pub categories: Vec<String>,
    pub options: Vec<Options>,
    pub cdnReferrers: Vec<CdnReferrer>,
    pub filtersFooter: String,
}
