// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: site.standard.theme.color
//
// 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;

#[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};

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Rgb<'a> {
    pub b: i64,
    pub g: i64,
    pub r: i64,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Rgba<'a> {
    pub a: i64,
    pub b: i64,
    pub g: i64,
    pub r: i64,
}

impl<'a> LexiconSchema for Rgb<'a> {
    fn nsid() -> &'static str {
        "site.standard.theme.color"
    }
    fn def_name() -> &'static str {
        "rgb"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_site_standard_theme_color()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.b;
            if *value > 255i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("b"),
                    max: 255i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.b;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("b"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.g;
            if *value > 255i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("g"),
                    max: 255i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.g;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("g"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.r;
            if *value > 255i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("r"),
                    max: 255i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.r;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("r"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Rgba<'a> {
    fn nsid() -> &'static str {
        "site.standard.theme.color"
    }
    fn def_name() -> &'static str {
        "rgba"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_site_standard_theme_color()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.a;
            if *value > 100i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("a"),
                    max: 100i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.a;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("a"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.b;
            if *value > 255i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("b"),
                    max: 255i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.b;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("b"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.g;
            if *value > 255i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("g"),
                    max: 255i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.g;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("g"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.r;
            if *value > 255i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("r"),
                    max: 255i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.r;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("r"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

pub mod rgb_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 R;
        type G;
        type B;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type R = Unset;
        type G = Unset;
        type B = Unset;
    }
    ///State transition - sets the `r` field to Set
    pub struct SetR<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetR<S> {}
    impl<S: State> State for SetR<S> {
        type R = Set<members::r>;
        type G = S::G;
        type B = S::B;
    }
    ///State transition - sets the `g` field to Set
    pub struct SetG<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetG<S> {}
    impl<S: State> State for SetG<S> {
        type R = S::R;
        type G = Set<members::g>;
        type B = S::B;
    }
    ///State transition - sets the `b` field to Set
    pub struct SetB<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetB<S> {}
    impl<S: State> State for SetB<S> {
        type R = S::R;
        type G = S::G;
        type B = Set<members::b>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `r` field
        pub struct r(());
        ///Marker type for the `g` field
        pub struct g(());
        ///Marker type for the `b` field
        pub struct b(());
    }
}

/// Builder for constructing an instance of this type
pub struct RgbBuilder<'a, S: rgb_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<i64>, Option<i64>, Option<i64>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Rgb<'a> {
    /// Create a new builder for this type
    pub fn new() -> RgbBuilder<'a, rgb_state::Empty> {
        RgbBuilder::new()
    }
}

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

impl<'a, S> RgbBuilder<'a, S>
where
    S: rgb_state::State,
    S::B: rgb_state::IsUnset,
{
    /// Set the `b` field (required)
    pub fn b(mut self, value: impl Into<i64>) -> RgbBuilder<'a, rgb_state::SetB<S>> {
        self._fields.0 = Option::Some(value.into());
        RgbBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RgbBuilder<'a, S>
where
    S: rgb_state::State,
    S::G: rgb_state::IsUnset,
{
    /// Set the `g` field (required)
    pub fn g(mut self, value: impl Into<i64>) -> RgbBuilder<'a, rgb_state::SetG<S>> {
        self._fields.1 = Option::Some(value.into());
        RgbBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RgbBuilder<'a, S>
where
    S: rgb_state::State,
    S::R: rgb_state::IsUnset,
{
    /// Set the `r` field (required)
    pub fn r(mut self, value: impl Into<i64>) -> RgbBuilder<'a, rgb_state::SetR<S>> {
        self._fields.2 = Option::Some(value.into());
        RgbBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RgbBuilder<'a, S>
where
    S: rgb_state::State,
    S::R: rgb_state::IsSet,
    S::G: rgb_state::IsSet,
    S::B: rgb_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Rgb<'a> {
        Rgb {
            b: self._fields.0.unwrap(),
            g: self._fields.1.unwrap(),
            r: self._fields.2.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>,
        >,
    ) -> Rgb<'a> {
        Rgb {
            b: self._fields.0.unwrap(),
            g: self._fields.1.unwrap(),
            r: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_site_standard_theme_color() -> 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("site.standard.theme.color"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("rgb"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("r"), SmolStr::new_static("g"),
                            SmolStr::new_static("b")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("b"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(255i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("g"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(255i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("r"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(255i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("rgba"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("r"), SmolStr::new_static("g"),
                            SmolStr::new_static("b"), SmolStr::new_static("a")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("a"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(100i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("b"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(255i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("g"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(255i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("r"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                maximum: Some(255i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod rgba_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 R;
        type A;
        type B;
        type G;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type R = Unset;
        type A = Unset;
        type B = Unset;
        type G = Unset;
    }
    ///State transition - sets the `r` field to Set
    pub struct SetR<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetR<S> {}
    impl<S: State> State for SetR<S> {
        type R = Set<members::r>;
        type A = S::A;
        type B = S::B;
        type G = S::G;
    }
    ///State transition - sets the `a` field to Set
    pub struct SetA<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetA<S> {}
    impl<S: State> State for SetA<S> {
        type R = S::R;
        type A = Set<members::a>;
        type B = S::B;
        type G = S::G;
    }
    ///State transition - sets the `b` field to Set
    pub struct SetB<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetB<S> {}
    impl<S: State> State for SetB<S> {
        type R = S::R;
        type A = S::A;
        type B = Set<members::b>;
        type G = S::G;
    }
    ///State transition - sets the `g` field to Set
    pub struct SetG<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetG<S> {}
    impl<S: State> State for SetG<S> {
        type R = S::R;
        type A = S::A;
        type B = S::B;
        type G = Set<members::g>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `r` field
        pub struct r(());
        ///Marker type for the `a` field
        pub struct a(());
        ///Marker type for the `b` field
        pub struct b(());
        ///Marker type for the `g` field
        pub struct g(());
    }
}

/// Builder for constructing an instance of this type
pub struct RgbaBuilder<'a, S: rgba_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<i64>, Option<i64>, Option<i64>, Option<i64>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Rgba<'a> {
    /// Create a new builder for this type
    pub fn new() -> RgbaBuilder<'a, rgba_state::Empty> {
        RgbaBuilder::new()
    }
}

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

impl<'a, S> RgbaBuilder<'a, S>
where
    S: rgba_state::State,
    S::A: rgba_state::IsUnset,
{
    /// Set the `a` field (required)
    pub fn a(mut self, value: impl Into<i64>) -> RgbaBuilder<'a, rgba_state::SetA<S>> {
        self._fields.0 = Option::Some(value.into());
        RgbaBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RgbaBuilder<'a, S>
where
    S: rgba_state::State,
    S::B: rgba_state::IsUnset,
{
    /// Set the `b` field (required)
    pub fn b(mut self, value: impl Into<i64>) -> RgbaBuilder<'a, rgba_state::SetB<S>> {
        self._fields.1 = Option::Some(value.into());
        RgbaBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RgbaBuilder<'a, S>
where
    S: rgba_state::State,
    S::G: rgba_state::IsUnset,
{
    /// Set the `g` field (required)
    pub fn g(mut self, value: impl Into<i64>) -> RgbaBuilder<'a, rgba_state::SetG<S>> {
        self._fields.2 = Option::Some(value.into());
        RgbaBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RgbaBuilder<'a, S>
where
    S: rgba_state::State,
    S::R: rgba_state::IsUnset,
{
    /// Set the `r` field (required)
    pub fn r(mut self, value: impl Into<i64>) -> RgbaBuilder<'a, rgba_state::SetR<S>> {
        self._fields.3 = Option::Some(value.into());
        RgbaBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RgbaBuilder<'a, S>
where
    S: rgba_state::State,
    S::R: rgba_state::IsSet,
    S::A: rgba_state::IsSet,
    S::B: rgba_state::IsSet,
    S::G: rgba_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Rgba<'a> {
        Rgba {
            a: self._fields.0.unwrap(),
            b: self._fields.1.unwrap(),
            g: self._fields.2.unwrap(),
            r: self._fields.3.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>,
        >,
    ) -> Rgba<'a> {
        Rgba {
            a: self._fields.0.unwrap(),
            b: self._fields.1.unwrap(),
            g: self._fields.2.unwrap(),
            r: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}