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

pub mod agents;
pub mod event;
pub mod interview;
pub mod senate;
pub mod sim;
pub mod skill;
pub mod style;
pub mod vote;


#[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_common::types::value::Data;
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 SpriteSettings<'a> {
    ///0=right, 1=back, 2=left, 3=front
    #[serde(skip_serializing_if = "Option::is_none")]
    pub current_anim_direction: Option<i64>,
    ///Map of part name -> {red, green, blue, alpha}
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub part_color_settings: Option<Data<'a>>,
    ///Map of part name -> sprite path
    #[serde(borrow)]
    pub selected_options: Data<'a>,
}

impl<'a> LexiconSchema for SpriteSettings<'a> {
    fn nsid() -> &'static str {
        "org.simocracy.defs"
    }
    fn def_name() -> &'static str {
        "spriteSettings"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_org_simocracy_defs()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod sprite_settings_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 SelectedOptions;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type SelectedOptions = Unset;
    }
    ///State transition - sets the `selected_options` field to Set
    pub struct SetSelectedOptions<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSelectedOptions<S> {}
    impl<S: State> State for SetSelectedOptions<S> {
        type SelectedOptions = Set<members::selected_options>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `selected_options` field
        pub struct selected_options(());
    }
}

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

impl<'a> SpriteSettings<'a> {
    /// Create a new builder for this type
    pub fn new() -> SpriteSettingsBuilder<'a, sprite_settings_state::Empty> {
        SpriteSettingsBuilder::new()
    }
}

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

impl<'a, S: sprite_settings_state::State> SpriteSettingsBuilder<'a, S> {
    /// Set the `currentAnimDirection` field (optional)
    pub fn current_anim_direction(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `currentAnimDirection` field to an Option value (optional)
    pub fn maybe_current_anim_direction(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: sprite_settings_state::State> SpriteSettingsBuilder<'a, S> {
    /// Set the `partColorSettings` field (optional)
    pub fn part_color_settings(mut self, value: impl Into<Option<Data<'a>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `partColorSettings` field to an Option value (optional)
    pub fn maybe_part_color_settings(mut self, value: Option<Data<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S> SpriteSettingsBuilder<'a, S>
where
    S: sprite_settings_state::State,
    S::SelectedOptions: sprite_settings_state::IsUnset,
{
    /// Set the `selectedOptions` field (required)
    pub fn selected_options(
        mut self,
        value: impl Into<Data<'a>>,
    ) -> SpriteSettingsBuilder<'a, sprite_settings_state::SetSelectedOptions<S>> {
        self._fields.2 = Option::Some(value.into());
        SpriteSettingsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SpriteSettingsBuilder<'a, S>
where
    S: sprite_settings_state::State,
    S::SelectedOptions: sprite_settings_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> SpriteSettings<'a> {
        SpriteSettings {
            current_anim_direction: self._fields.0,
            part_color_settings: self._fields.1,
            selected_options: 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, Data<'a>>,
    ) -> SpriteSettings<'a> {
        SpriteSettings {
            current_anim_direction: self._fields.0,
            part_color_settings: self._fields.1,
            selected_options: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_org_simocracy_defs() -> 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("org.simocracy.defs"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("spriteSettings"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("selectedOptions")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("currentAnimDirection"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("partColorSettings"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("selectedOptions"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}