// @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, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
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;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetStateOutput<S: BosStr = DefaultStr> {
    #[serde(flatten)]
    pub value: Data<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Output<S: BosStr = DefaultStr> {
    pub favorite_albums: Vec<S>,
    pub favorite_artists: Vec<S>,
    pub favorite_deltarune_characters: Vec<S>,
    pub favorite_games: Vec<S>,
    ///Named title color mode for the site.
    pub title_colors: OutputTitleColors<S>,
    ///Whether to show Susie instead of Kris in prophecy content.
    pub use_susie_prophecy: bool,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Named title color mode for the site.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum OutputTitleColors<S: BosStr = DefaultStr> {
    None,
    Enby,
    Trans,
    Pan,
    Latvia,
    Other(S),
}

impl<S: BosStr> OutputTitleColors<S> {
    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(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "none" => Self::None,
            "enby" => Self::Enby,
            "trans" => Self::Trans,
            "pan" => Self::Pan,
            "latvia" => Self::Latvia,
            _ => Self::Other(s),
        }
    }
}

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

impl<S: BosStr> AsRef<str> for OutputTitleColors<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de> for OutputTitleColors<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for OutputTitleColors<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for OutputTitleColors<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = OutputTitleColors<S::Output>;
    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()),
        }
    }
}

/** Request marker for the `download.darkworld.site.getState` query.

This endpoint has no request parameters or input body; send this marker with `jacquard::Client`.*/

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Copy)]
pub struct GetState;
/** Response marker for the `download.darkworld.site.getState` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetStateOutput<S>` for this endpoint.*/
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<S: BosStr> = GetStateOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

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 marker for the `download.darkworld.site.getState` query.

Path: `/xrpc/download.darkworld.site.getState`. The request payload type is `GetState`; use this marker with lower-level `XrpcEndpoint` APIs when you need endpoint metadata.*/
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<S: BosStr> = GetState;
    type Response = GetStateResponse;
}

impl<S: BosStr> LexiconSchema for Output<S> {
    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 FavoriteAlbums;
        type FavoriteArtists;
        type FavoriteDeltaruneCharacters;
        type FavoriteGames;
        type TitleColors;
        type UseSusieProphecy;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type FavoriteAlbums = Unset;
        type FavoriteArtists = Unset;
        type FavoriteDeltaruneCharacters = Unset;
        type FavoriteGames = Unset;
        type TitleColors = Unset;
        type UseSusieProphecy = Unset;
    }
    ///State transition - sets the `favorite_albums` field to Set
    pub struct SetFavoriteAlbums<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetFavoriteAlbums<St> {}
    impl<St: State> State for SetFavoriteAlbums<St> {
        type FavoriteAlbums = Set<members::favorite_albums>;
        type FavoriteArtists = St::FavoriteArtists;
        type FavoriteDeltaruneCharacters = St::FavoriteDeltaruneCharacters;
        type FavoriteGames = St::FavoriteGames;
        type TitleColors = St::TitleColors;
        type UseSusieProphecy = St::UseSusieProphecy;
    }
    ///State transition - sets the `favorite_artists` field to Set
    pub struct SetFavoriteArtists<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetFavoriteArtists<St> {}
    impl<St: State> State for SetFavoriteArtists<St> {
        type FavoriteAlbums = St::FavoriteAlbums;
        type FavoriteArtists = Set<members::favorite_artists>;
        type FavoriteDeltaruneCharacters = St::FavoriteDeltaruneCharacters;
        type FavoriteGames = St::FavoriteGames;
        type TitleColors = St::TitleColors;
        type UseSusieProphecy = St::UseSusieProphecy;
    }
    ///State transition - sets the `favorite_deltarune_characters` field to Set
    pub struct SetFavoriteDeltaruneCharacters<St: State = Empty>(
        PhantomData<fn() -> St>,
    );
    impl<St: State> sealed::Sealed for SetFavoriteDeltaruneCharacters<St> {}
    impl<St: State> State for SetFavoriteDeltaruneCharacters<St> {
        type FavoriteAlbums = St::FavoriteAlbums;
        type FavoriteArtists = St::FavoriteArtists;
        type FavoriteDeltaruneCharacters = Set<members::favorite_deltarune_characters>;
        type FavoriteGames = St::FavoriteGames;
        type TitleColors = St::TitleColors;
        type UseSusieProphecy = St::UseSusieProphecy;
    }
    ///State transition - sets the `favorite_games` field to Set
    pub struct SetFavoriteGames<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetFavoriteGames<St> {}
    impl<St: State> State for SetFavoriteGames<St> {
        type FavoriteAlbums = St::FavoriteAlbums;
        type FavoriteArtists = St::FavoriteArtists;
        type FavoriteDeltaruneCharacters = St::FavoriteDeltaruneCharacters;
        type FavoriteGames = Set<members::favorite_games>;
        type TitleColors = St::TitleColors;
        type UseSusieProphecy = St::UseSusieProphecy;
    }
    ///State transition - sets the `title_colors` field to Set
    pub struct SetTitleColors<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTitleColors<St> {}
    impl<St: State> State for SetTitleColors<St> {
        type FavoriteAlbums = St::FavoriteAlbums;
        type FavoriteArtists = St::FavoriteArtists;
        type FavoriteDeltaruneCharacters = St::FavoriteDeltaruneCharacters;
        type FavoriteGames = St::FavoriteGames;
        type TitleColors = Set<members::title_colors>;
        type UseSusieProphecy = St::UseSusieProphecy;
    }
    ///State transition - sets the `use_susie_prophecy` field to Set
    pub struct SetUseSusieProphecy<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUseSusieProphecy<St> {}
    impl<St: State> State for SetUseSusieProphecy<St> {
        type FavoriteAlbums = St::FavoriteAlbums;
        type FavoriteArtists = St::FavoriteArtists;
        type FavoriteDeltaruneCharacters = St::FavoriteDeltaruneCharacters;
        type FavoriteGames = St::FavoriteGames;
        type TitleColors = St::TitleColors;
        type UseSusieProphecy = Set<members::use_susie_prophecy>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `favorite_albums` field
        pub struct favorite_albums(());
        ///Marker type for the `favorite_artists` field
        pub struct favorite_artists(());
        ///Marker type for the `favorite_deltarune_characters` field
        pub struct favorite_deltarune_characters(());
        ///Marker type for the `favorite_games` field
        pub struct favorite_games(());
        ///Marker type for the `title_colors` field
        pub struct title_colors(());
        ///Marker type for the `use_susie_prophecy` field
        pub struct use_susie_prophecy(());
    }
}

/// Builder for constructing an instance of this type.
pub struct OutputBuilder<St: output_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Vec<S>>,
        Option<Vec<S>>,
        Option<Vec<S>>,
        Option<Vec<S>>,
        Option<OutputTitleColors<S>>,
        Option<bool>,
    ),
    _type: PhantomData<fn() -> S>,
}

impl Output<DefaultStr> {
    /// Create a new builder for this type, using the default string type (DefaultStr = SmolStr) if needed
    pub fn new() -> OutputBuilder<output_state::Empty, DefaultStr> {
        OutputBuilder::new()
    }
}

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

impl OutputBuilder<output_state::Empty, DefaultStr> {
    /// Create a new builder with all fields unset, using the default string type, if needed
    pub fn new() -> Self {
        OutputBuilder {
            _state: PhantomData,
            _fields: (None, None, None, None, None, None),
            _type: PhantomData,
        }
    }
}

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

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

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

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

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

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

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

impl<St, S: BosStr> OutputBuilder<St, S>
where
    St: output_state::State,
    St::FavoriteAlbums: output_state::IsSet,
    St::FavoriteArtists: output_state::IsSet,
    St::FavoriteDeltaruneCharacters: output_state::IsSet,
    St::FavoriteGames: output_state::IsSet,
    St::TitleColors: output_state::IsSet,
    St::UseSusieProphecy: output_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Output<S> {
        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<SmolStr, Data<S>>) -> Output<S> {
        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()
    }
}