// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: download.darkworld.site.getState
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::download_darkworld::site::get_state;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct GetStateOutput<'a> {
    #[serde(flatten)]
    #[serde(borrow)]
    pub value: jacquard_common::types::value::Data<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Output<'a> {
    #[serde(borrow)]
    pub favorite_albums: Vec<CowStr<'a>>,
    #[serde(borrow)]
    pub favorite_artists: Vec<CowStr<'a>>,
    #[serde(borrow)]
    pub favorite_deltarune_characters: Vec<CowStr<'a>>,
    #[serde(borrow)]
    pub favorite_games: Vec<CowStr<'a>>,
    ///Named title color mode for the site.
    #[serde(borrow)]
    pub title_colors: OutputTitleColors<'a>,
    ///Whether to show Susie instead of Kris in prophecy content.
    pub use_susie_prophecy: bool,
}

/// Named title color mode for the site.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum OutputTitleColors<'a> {
    None,
    Enby,
    Trans,
    Pan,
    Latvia,
    Other(CowStr<'a>),
}

impl<'a> OutputTitleColors<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::None => "none",
            Self::Enby => "enby",
            Self::Trans => "trans",
            Self::Pan => "pan",
            Self::Latvia => "latvia",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for OutputTitleColors<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "none" => Self::None,
            "enby" => Self::Enby,
            "trans" => Self::Trans,
            "pan" => Self::Pan,
            "latvia" => Self::Latvia,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for OutputTitleColors<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "none" => Self::None,
            "enby" => Self::Enby,
            "trans" => Self::Trans,
            "pan" => Self::Pan,
            "latvia" => Self::Latvia,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> core::fmt::Display for OutputTitleColors<'a> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<'a> AsRef<str> for OutputTitleColors<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<'a> serde::Serialize for OutputTitleColors<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for OutputTitleColors<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for OutputTitleColors<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for OutputTitleColors<'_> {
    type Output = OutputTitleColors<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            OutputTitleColors::None => OutputTitleColors::None,
            OutputTitleColors::Enby => OutputTitleColors::Enby,
            OutputTitleColors::Trans => OutputTitleColors::Trans,
            OutputTitleColors::Pan => OutputTitleColors::Pan,
            OutputTitleColors::Latvia => OutputTitleColors::Latvia,
            OutputTitleColors::Other(v) => OutputTitleColors::Other(v.into_static()),
        }
    }
}

/// XRPC request marker type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct GetState;
/// Response type for download.darkworld.site.getState
pub struct GetStateResponse;
impl jacquard_common::xrpc::XrpcResp for GetStateResponse {
    const NSID: &'static str = "download.darkworld.site.getState";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = GetStateOutput<'de>;
    type Err<'de> = jacquard_common::xrpc::GenericError<'de>;
}

impl jacquard_common::xrpc::XrpcRequest for GetState {
    const NSID: &'static str = "download.darkworld.site.getState";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetStateResponse;
}

/// Endpoint type for download.darkworld.site.getState
pub struct GetStateRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetStateRequest {
    const PATH: &'static str = "/xrpc/download.darkworld.site.getState";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<'de> = GetState;
    type Response = GetStateResponse;
}

impl<'a> LexiconSchema for Output<'a> {
    fn nsid() -> &'static str {
        "download.darkworld.site.getState"
    }
    fn def_name() -> &'static str {
        "output"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_download_darkworld_site_getState()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod output_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type TitleColors;
        type FavoriteArtists;
        type FavoriteAlbums;
        type FavoriteGames;
        type FavoriteDeltaruneCharacters;
        type UseSusieProphecy;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type TitleColors = Unset;
        type FavoriteArtists = Unset;
        type FavoriteAlbums = Unset;
        type FavoriteGames = Unset;
        type FavoriteDeltaruneCharacters = Unset;
        type UseSusieProphecy = Unset;
    }
    ///State transition - sets the `title_colors` field to Set
    pub struct SetTitleColors<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTitleColors<S> {}
    impl<S: State> State for SetTitleColors<S> {
        type TitleColors = Set<members::title_colors>;
        type FavoriteArtists = S::FavoriteArtists;
        type FavoriteAlbums = S::FavoriteAlbums;
        type FavoriteGames = S::FavoriteGames;
        type FavoriteDeltaruneCharacters = S::FavoriteDeltaruneCharacters;
        type UseSusieProphecy = S::UseSusieProphecy;
    }
    ///State transition - sets the `favorite_artists` field to Set
    pub struct SetFavoriteArtists<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetFavoriteArtists<S> {}
    impl<S: State> State for SetFavoriteArtists<S> {
        type TitleColors = S::TitleColors;
        type FavoriteArtists = Set<members::favorite_artists>;
        type FavoriteAlbums = S::FavoriteAlbums;
        type FavoriteGames = S::FavoriteGames;
        type FavoriteDeltaruneCharacters = S::FavoriteDeltaruneCharacters;
        type UseSusieProphecy = S::UseSusieProphecy;
    }
    ///State transition - sets the `favorite_albums` field to Set
    pub struct SetFavoriteAlbums<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetFavoriteAlbums<S> {}
    impl<S: State> State for SetFavoriteAlbums<S> {
        type TitleColors = S::TitleColors;
        type FavoriteArtists = S::FavoriteArtists;
        type FavoriteAlbums = Set<members::favorite_albums>;
        type FavoriteGames = S::FavoriteGames;
        type FavoriteDeltaruneCharacters = S::FavoriteDeltaruneCharacters;
        type UseSusieProphecy = S::UseSusieProphecy;
    }
    ///State transition - sets the `favorite_games` field to Set
    pub struct SetFavoriteGames<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetFavoriteGames<S> {}
    impl<S: State> State for SetFavoriteGames<S> {
        type TitleColors = S::TitleColors;
        type FavoriteArtists = S::FavoriteArtists;
        type FavoriteAlbums = S::FavoriteAlbums;
        type FavoriteGames = Set<members::favorite_games>;
        type FavoriteDeltaruneCharacters = S::FavoriteDeltaruneCharacters;
        type UseSusieProphecy = S::UseSusieProphecy;
    }
    ///State transition - sets the `favorite_deltarune_characters` field to Set
    pub struct SetFavoriteDeltaruneCharacters<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetFavoriteDeltaruneCharacters<S> {}
    impl<S: State> State for SetFavoriteDeltaruneCharacters<S> {
        type TitleColors = S::TitleColors;
        type FavoriteArtists = S::FavoriteArtists;
        type FavoriteAlbums = S::FavoriteAlbums;
        type FavoriteGames = S::FavoriteGames;
        type FavoriteDeltaruneCharacters = Set<members::favorite_deltarune_characters>;
        type UseSusieProphecy = S::UseSusieProphecy;
    }
    ///State transition - sets the `use_susie_prophecy` field to Set
    pub struct SetUseSusieProphecy<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetUseSusieProphecy<S> {}
    impl<S: State> State for SetUseSusieProphecy<S> {
        type TitleColors = S::TitleColors;
        type FavoriteArtists = S::FavoriteArtists;
        type FavoriteAlbums = S::FavoriteAlbums;
        type FavoriteGames = S::FavoriteGames;
        type FavoriteDeltaruneCharacters = S::FavoriteDeltaruneCharacters;
        type UseSusieProphecy = Set<members::use_susie_prophecy>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `title_colors` field
        pub struct title_colors(());
        ///Marker type for the `favorite_artists` field
        pub struct favorite_artists(());
        ///Marker type for the `favorite_albums` field
        pub struct favorite_albums(());
        ///Marker type for the `favorite_games` field
        pub struct favorite_games(());
        ///Marker type for the `favorite_deltarune_characters` field
        pub struct favorite_deltarune_characters(());
        ///Marker type for the `use_susie_prophecy` field
        pub struct use_susie_prophecy(());
    }
}

/// Builder for constructing an instance of this type
pub struct OutputBuilder<'a, S: output_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<Vec<CowStr<'a>>>,
        Option<OutputTitleColors<'a>>,
        Option<bool>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Output<'a> {
    /// Create a new builder for this type
    pub fn new() -> OutputBuilder<'a, output_state::Empty> {
        OutputBuilder::new()
    }
}

impl<'a> OutputBuilder<'a, output_state::Empty> {
    /// Create a new builder with all fields unset
    pub fn new() -> Self {
        OutputBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None),
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> OutputBuilder<'a, S>
where
    S: output_state::State,
    S::FavoriteAlbums: output_state::IsUnset,
{
    /// Set the `favoriteAlbums` field (required)
    pub fn favorite_albums(
        mut self,
        value: impl Into<Vec<CowStr<'a>>>,
    ) -> OutputBuilder<'a, output_state::SetFavoriteAlbums<S>> {
        self._fields.0 = Option::Some(value.into());
        OutputBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> OutputBuilder<'a, S>
where
    S: output_state::State,
    S::FavoriteArtists: output_state::IsUnset,
{
    /// Set the `favoriteArtists` field (required)
    pub fn favorite_artists(
        mut self,
        value: impl Into<Vec<CowStr<'a>>>,
    ) -> OutputBuilder<'a, output_state::SetFavoriteArtists<S>> {
        self._fields.1 = Option::Some(value.into());
        OutputBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> OutputBuilder<'a, S>
where
    S: output_state::State,
    S::FavoriteDeltaruneCharacters: output_state::IsUnset,
{
    /// Set the `favoriteDeltaruneCharacters` field (required)
    pub fn favorite_deltarune_characters(
        mut self,
        value: impl Into<Vec<CowStr<'a>>>,
    ) -> OutputBuilder<'a, output_state::SetFavoriteDeltaruneCharacters<S>> {
        self._fields.2 = Option::Some(value.into());
        OutputBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> OutputBuilder<'a, S>
where
    S: output_state::State,
    S::FavoriteGames: output_state::IsUnset,
{
    /// Set the `favoriteGames` field (required)
    pub fn favorite_games(
        mut self,
        value: impl Into<Vec<CowStr<'a>>>,
    ) -> OutputBuilder<'a, output_state::SetFavoriteGames<S>> {
        self._fields.3 = Option::Some(value.into());
        OutputBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> OutputBuilder<'a, S>
where
    S: output_state::State,
    S::TitleColors: output_state::IsUnset,
{
    /// Set the `titleColors` field (required)
    pub fn title_colors(
        mut self,
        value: impl Into<OutputTitleColors<'a>>,
    ) -> OutputBuilder<'a, output_state::SetTitleColors<S>> {
        self._fields.4 = Option::Some(value.into());
        OutputBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> OutputBuilder<'a, S>
where
    S: output_state::State,
    S::UseSusieProphecy: output_state::IsUnset,
{
    /// Set the `useSusieProphecy` field (required)
    pub fn use_susie_prophecy(
        mut self,
        value: impl Into<bool>,
    ) -> OutputBuilder<'a, output_state::SetUseSusieProphecy<S>> {
        self._fields.5 = Option::Some(value.into());
        OutputBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> OutputBuilder<'a, S>
where
    S: output_state::State,
    S::TitleColors: output_state::IsSet,
    S::FavoriteArtists: output_state::IsSet,
    S::FavoriteAlbums: output_state::IsSet,
    S::FavoriteGames: output_state::IsSet,
    S::FavoriteDeltaruneCharacters: output_state::IsSet,
    S::UseSusieProphecy: output_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Output<'a> {
        Output {
            favorite_albums: self._fields.0.unwrap(),
            favorite_artists: self._fields.1.unwrap(),
            favorite_deltarune_characters: self._fields.2.unwrap(),
            favorite_games: self._fields.3.unwrap(),
            title_colors: self._fields.4.unwrap(),
            use_susie_prophecy: self._fields.5.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Output<'a> {
        Output {
            favorite_albums: self._fields.0.unwrap(),
            favorite_artists: self._fields.1.unwrap(),
            favorite_deltarune_characters: self._fields.2.unwrap(),
            favorite_games: self._fields.3.unwrap(),
            title_colors: self._fields.4.unwrap(),
            use_susie_prophecy: self._fields.5.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_download_darkworld_site_getState() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("download.darkworld.site.getState"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: None,
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("output"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("useSusieProphecy"),
                            SmolStr::new_static("titleColors"),
                            SmolStr::new_static("favoriteGames"),
                            SmolStr::new_static("favoriteArtists"),
                            SmolStr::new_static("favoriteAlbums"),
                            SmolStr::new_static("favoriteDeltaruneCharacters")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("favoriteAlbums"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("favoriteArtists"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("favoriteDeltaruneCharacters"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("favoriteGames"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("titleColors"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Named title color mode for the site."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("useSusieProphecy"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}