// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: directory.evnt.event
//
// 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, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

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

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Address<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub addr: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub country_code: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub postal_code: Option<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 Coordinates<S: BosStr = DefaultStr> {
    pub lat: i64,
    pub lng: i64,
    #[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 EventComponent<S: BosStr = DefaultStr> {
    pub data: Data<S>,
    pub r#type: 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, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct EventInstance<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<Data<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub venue_ids: Option<Vec<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum EventStatus<S: BosStr = DefaultStr> {
    Planned,
    Uncertain,
    Postponed,
    Cancelled,
    Suspended,
    Other(S),
}

impl<S: BosStr> EventStatus<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Planned => "planned",
            Self::Uncertain => "uncertain",
            Self::Postponed => "postponed",
            Self::Cancelled => "cancelled",
            Self::Suspended => "suspended",
            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() {
            "planned" => Self::Planned,
            "uncertain" => Self::Uncertain,
            "postponed" => Self::Postponed,
            "cancelled" => Self::Cancelled,
            "suspended" => Self::Suspended,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for EventStatus<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 EventStatus<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> jacquard_common::IntoStatic for EventStatus<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = EventStatus<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            EventStatus::Planned => EventStatus::Planned,
            EventStatus::Uncertain => EventStatus::Uncertain,
            EventStatus::Postponed => EventStatus::Postponed,
            EventStatus::Cancelled => EventStatus::Cancelled,
            EventStatus::Suspended => EventStatus::Suspended,
            EventStatus::Other(v) => EventStatus::Other(v.into_static()),
        }
    }
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct OnlineVenue<S: BosStr = DefaultStr> {
    pub id: S,
    pub name: Data<S>,
    pub r#type: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub url: Option<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 PhysicalVenue<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub address: Option<Data<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub coordinates: Option<Data<S>>,
    pub id: S,
    pub name: Data<S>,
    pub r#type: 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 UnknownVenue<S: BosStr = DefaultStr> {
    pub id: S,
    pub name: Data<S>,
    pub r#type: 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 Event<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub components: Option<Vec<Data<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub instances: Option<Vec<Data<S>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub label: Option<Data<S>>,
    pub name: Data<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<Data<S>>,
    pub v: i64,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub venues: Option<Vec<EventVenuesItem<S>>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum EventVenuesItem<S: BosStr = DefaultStr> {}
impl<S: BosStr> LexiconSchema for Address<S> {
    fn nsid() -> &'static str {
        "directory.evnt.event"
    }
    fn def_name() -> &'static str {
        "Address"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_directory_evnt_event()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Coordinates<S> {
    fn nsid() -> &'static str {
        "directory.evnt.event"
    }
    fn def_name() -> &'static str {
        "Coordinates"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_directory_evnt_event()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventComponent<S> {
    fn nsid() -> &'static str {
        "directory.evnt.event"
    }
    fn def_name() -> &'static str {
        "EventComponent"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_directory_evnt_event()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for EventInstance<S> {
    fn nsid() -> &'static str {
        "directory.evnt.event"
    }
    fn def_name() -> &'static str {
        "EventInstance"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_directory_evnt_event()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for OnlineVenue<S> {
    fn nsid() -> &'static str {
        "directory.evnt.event"
    }
    fn def_name() -> &'static str {
        "OnlineVenue"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_directory_evnt_event()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for PhysicalVenue<S> {
    fn nsid() -> &'static str {
        "directory.evnt.event"
    }
    fn def_name() -> &'static str {
        "PhysicalVenue"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_directory_evnt_event()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for UnknownVenue<S> {
    fn nsid() -> &'static str {
        "directory.evnt.event"
    }
    fn def_name() -> &'static str {
        "UnknownVenue"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_directory_evnt_event()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Event<S> {
    fn nsid() -> &'static str {
        "directory.evnt.event"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_directory_evnt_event()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn lexicon_doc_directory_evnt_event() -> 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("directory.evnt.event"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("Address"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("addr"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("countryCode"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("postalCode"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("Coordinates"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("lat"), SmolStr::new_static("lng")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("lat"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lng"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("EventComponent"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("type"), SmolStr::new_static("data")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("data"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("EventInstance"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("end"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("start"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#eventStatus"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("venueIds"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("EventStatus"),
                LexUserType::String(LexString { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("OnlineVenue"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("id"), SmolStr::new_static("type"),
                            SmolStr::new_static("name")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("url"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("PhysicalVenue"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("id"), SmolStr::new_static("type"),
                            SmolStr::new_static("name")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("address"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#address"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("coordinates"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#coordinates"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("UnknownVenue"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("id"), SmolStr::new_static("type"),
                            SmolStr::new_static("name")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("v"), SmolStr::new_static("name")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("components"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#eventComponent"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("instances"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#eventInstance"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("label"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::Unknown(LexUnknown {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#eventStatus"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("v"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("venues"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Union(LexRefUnion {
                                    refs: vec![
                                        CowStr::new_static("#physicalVenue"),
                                        CowStr::new_static("#onlineVenue"),
                                        CowStr::new_static("#unknownVenue")
                                    ],
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod coordinates_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 Lat;
        type Lng;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Lat = Unset;
        type Lng = Unset;
    }
    ///State transition - sets the `lat` field to Set
    pub struct SetLat<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLat<St> {}
    impl<St: State> State for SetLat<St> {
        type Lat = Set<members::lat>;
        type Lng = St::Lng;
    }
    ///State transition - sets the `lng` field to Set
    pub struct SetLng<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLng<St> {}
    impl<St: State> State for SetLng<St> {
        type Lat = St::Lat;
        type Lng = Set<members::lng>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `lat` field
        pub struct lat(());
        ///Marker type for the `lng` field
        pub struct lng(());
    }
}

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

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

impl<S: BosStr> Coordinates<S> {
    /// Create a new builder for this type
    pub fn builder() -> CoordinatesBuilder<coordinates_state::Empty, S> {
        CoordinatesBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> CoordinatesBuilder<St, S>
where
    St: coordinates_state::State,
    St::Lat: coordinates_state::IsUnset,
{
    /// Set the `lat` field (required)
    pub fn lat(
        mut self,
        value: impl Into<i64>,
    ) -> CoordinatesBuilder<coordinates_state::SetLat<St>, S> {
        self._fields.0 = Option::Some(value.into());
        CoordinatesBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CoordinatesBuilder<St, S>
where
    St: coordinates_state::State,
    St::Lng: coordinates_state::IsUnset,
{
    /// Set the `lng` field (required)
    pub fn lng(
        mut self,
        value: impl Into<i64>,
    ) -> CoordinatesBuilder<coordinates_state::SetLng<St>, S> {
        self._fields.1 = Option::Some(value.into());
        CoordinatesBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> CoordinatesBuilder<St, S>
where
    St: coordinates_state::State,
    St::Lat: coordinates_state::IsSet,
    St::Lng: coordinates_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Coordinates<S> {
        Coordinates {
            lat: self._fields.0.unwrap(),
            lng: self._fields.1.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>>,
    ) -> Coordinates<S> {
        Coordinates {
            lat: self._fields.0.unwrap(),
            lng: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_component_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 Data;
        type Type;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Data = Unset;
        type Type = Unset;
    }
    ///State transition - sets the `data` field to Set
    pub struct SetData<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetData<St> {}
    impl<St: State> State for SetData<St> {
        type Data = Set<members::data>;
        type Type = St::Type;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetType<St> {}
    impl<St: State> State for SetType<St> {
        type Data = St::Data;
        type Type = Set<members::r#type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `data` field
        pub struct data(());
        ///Marker type for the `type` field
        pub struct r#type(());
    }
}

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

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

impl<S: BosStr> EventComponent<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventComponentBuilder<event_component_state::Empty, S> {
        EventComponentBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> EventComponentBuilder<St, S>
where
    St: event_component_state::State,
    St::Data: event_component_state::IsUnset,
{
    /// Set the `data` field (required)
    pub fn data(
        mut self,
        value: impl Into<Data<S>>,
    ) -> EventComponentBuilder<event_component_state::SetData<St>, S> {
        self._fields.0 = Option::Some(value.into());
        EventComponentBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventComponentBuilder<St, S>
where
    St: event_component_state::State,
    St::Type: event_component_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<S>,
    ) -> EventComponentBuilder<event_component_state::SetType<St>, S> {
        self._fields.1 = Option::Some(value.into());
        EventComponentBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> EventComponentBuilder<St, S>
where
    St: event_component_state::State,
    St::Data: event_component_state::IsSet,
    St::Type: event_component_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> EventComponent<S> {
        EventComponent {
            data: self._fields.0.unwrap(),
            r#type: self._fields.1.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>>,
    ) -> EventComponent<S> {
        EventComponent {
            data: self._fields.0.unwrap(),
            r#type: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod online_venue_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 Id;
        type Name;
        type Type;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Id = Unset;
        type Name = Unset;
        type Type = Unset;
    }
    ///State transition - sets the `id` field to Set
    pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetId<St> {}
    impl<St: State> State for SetId<St> {
        type Id = Set<members::id>;
        type Name = St::Name;
        type Type = St::Type;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Id = St::Id;
        type Name = Set<members::name>;
        type Type = St::Type;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetType<St> {}
    impl<St: State> State for SetType<St> {
        type Id = St::Id;
        type Name = St::Name;
        type Type = Set<members::r#type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `id` field
        pub struct id(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `type` field
        pub struct r#type(());
    }
}

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

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

impl<S: BosStr> OnlineVenue<S> {
    /// Create a new builder for this type
    pub fn builder() -> OnlineVenueBuilder<online_venue_state::Empty, S> {
        OnlineVenueBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> OnlineVenueBuilder<St, S>
where
    St: online_venue_state::State,
    St::Id: online_venue_state::IsUnset,
{
    /// Set the `id` field (required)
    pub fn id(
        mut self,
        value: impl Into<S>,
    ) -> OnlineVenueBuilder<online_venue_state::SetId<St>, S> {
        self._fields.0 = Option::Some(value.into());
        OnlineVenueBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> OnlineVenueBuilder<St, S>
where
    St: online_venue_state::State,
    St::Name: online_venue_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<Data<S>>,
    ) -> OnlineVenueBuilder<online_venue_state::SetName<St>, S> {
        self._fields.1 = Option::Some(value.into());
        OnlineVenueBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> OnlineVenueBuilder<St, S>
where
    St: online_venue_state::State,
    St::Type: online_venue_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<S>,
    ) -> OnlineVenueBuilder<online_venue_state::SetType<St>, S> {
        self._fields.2 = Option::Some(value.into());
        OnlineVenueBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: online_venue_state::State, S: BosStr> OnlineVenueBuilder<St, S> {
    /// Set the `url` field (optional)
    pub fn url(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `url` field to an Option value (optional)
    pub fn maybe_url(mut self, value: Option<S>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St, S: BosStr> OnlineVenueBuilder<St, S>
where
    St: online_venue_state::State,
    St::Id: online_venue_state::IsSet,
    St::Name: online_venue_state::IsSet,
    St::Type: online_venue_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> OnlineVenue<S> {
        OnlineVenue {
            id: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            r#type: self._fields.2.unwrap(),
            url: self._fields.3,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> OnlineVenue<S> {
        OnlineVenue {
            id: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            r#type: self._fields.2.unwrap(),
            url: self._fields.3,
            extra_data: Some(extra_data),
        }
    }
}

pub mod physical_venue_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 Id;
        type Name;
        type Type;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Id = Unset;
        type Name = Unset;
        type Type = Unset;
    }
    ///State transition - sets the `id` field to Set
    pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetId<St> {}
    impl<St: State> State for SetId<St> {
        type Id = Set<members::id>;
        type Name = St::Name;
        type Type = St::Type;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Id = St::Id;
        type Name = Set<members::name>;
        type Type = St::Type;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetType<St> {}
    impl<St: State> State for SetType<St> {
        type Id = St::Id;
        type Name = St::Name;
        type Type = Set<members::r#type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `id` field
        pub struct id(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `type` field
        pub struct r#type(());
    }
}

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

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

impl<S: BosStr> PhysicalVenue<S> {
    /// Create a new builder for this type
    pub fn builder() -> PhysicalVenueBuilder<physical_venue_state::Empty, S> {
        PhysicalVenueBuilder::builder()
    }
}

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

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

impl<St: physical_venue_state::State, S: BosStr> PhysicalVenueBuilder<St, S> {
    /// Set the `address` field (optional)
    pub fn address(mut self, value: impl Into<Option<Data<S>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `address` field to an Option value (optional)
    pub fn maybe_address(mut self, value: Option<Data<S>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: physical_venue_state::State, S: BosStr> PhysicalVenueBuilder<St, S> {
    /// Set the `coordinates` field (optional)
    pub fn coordinates(mut self, value: impl Into<Option<Data<S>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `coordinates` field to an Option value (optional)
    pub fn maybe_coordinates(mut self, value: Option<Data<S>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St, S: BosStr> PhysicalVenueBuilder<St, S>
where
    St: physical_venue_state::State,
    St::Id: physical_venue_state::IsUnset,
{
    /// Set the `id` field (required)
    pub fn id(
        mut self,
        value: impl Into<S>,
    ) -> PhysicalVenueBuilder<physical_venue_state::SetId<St>, S> {
        self._fields.2 = Option::Some(value.into());
        PhysicalVenueBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PhysicalVenueBuilder<St, S>
where
    St: physical_venue_state::State,
    St::Name: physical_venue_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<Data<S>>,
    ) -> PhysicalVenueBuilder<physical_venue_state::SetName<St>, S> {
        self._fields.3 = Option::Some(value.into());
        PhysicalVenueBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PhysicalVenueBuilder<St, S>
where
    St: physical_venue_state::State,
    St::Type: physical_venue_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<S>,
    ) -> PhysicalVenueBuilder<physical_venue_state::SetType<St>, S> {
        self._fields.4 = Option::Some(value.into());
        PhysicalVenueBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PhysicalVenueBuilder<St, S>
where
    St: physical_venue_state::State,
    St::Id: physical_venue_state::IsSet,
    St::Name: physical_venue_state::IsSet,
    St::Type: physical_venue_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> PhysicalVenue<S> {
        PhysicalVenue {
            address: self._fields.0,
            coordinates: self._fields.1,
            id: self._fields.2.unwrap(),
            name: self._fields.3.unwrap(),
            r#type: self._fields.4.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>>,
    ) -> PhysicalVenue<S> {
        PhysicalVenue {
            address: self._fields.0,
            coordinates: self._fields.1,
            id: self._fields.2.unwrap(),
            name: self._fields.3.unwrap(),
            r#type: self._fields.4.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod unknown_venue_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 Id;
        type Name;
        type Type;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Id = Unset;
        type Name = Unset;
        type Type = Unset;
    }
    ///State transition - sets the `id` field to Set
    pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetId<St> {}
    impl<St: State> State for SetId<St> {
        type Id = Set<members::id>;
        type Name = St::Name;
        type Type = St::Type;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Id = St::Id;
        type Name = Set<members::name>;
        type Type = St::Type;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetType<St> {}
    impl<St: State> State for SetType<St> {
        type Id = St::Id;
        type Name = St::Name;
        type Type = Set<members::r#type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `id` field
        pub struct id(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `type` field
        pub struct r#type(());
    }
}

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

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

impl<S: BosStr> UnknownVenue<S> {
    /// Create a new builder for this type
    pub fn builder() -> UnknownVenueBuilder<unknown_venue_state::Empty, S> {
        UnknownVenueBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> UnknownVenueBuilder<St, S>
where
    St: unknown_venue_state::State,
    St::Id: unknown_venue_state::IsUnset,
{
    /// Set the `id` field (required)
    pub fn id(
        mut self,
        value: impl Into<S>,
    ) -> UnknownVenueBuilder<unknown_venue_state::SetId<St>, S> {
        self._fields.0 = Option::Some(value.into());
        UnknownVenueBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> UnknownVenueBuilder<St, S>
where
    St: unknown_venue_state::State,
    St::Name: unknown_venue_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<Data<S>>,
    ) -> UnknownVenueBuilder<unknown_venue_state::SetName<St>, S> {
        self._fields.1 = Option::Some(value.into());
        UnknownVenueBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> UnknownVenueBuilder<St, S>
where
    St: unknown_venue_state::State,
    St::Type: unknown_venue_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<S>,
    ) -> UnknownVenueBuilder<unknown_venue_state::SetType<St>, S> {
        self._fields.2 = Option::Some(value.into());
        UnknownVenueBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> UnknownVenueBuilder<St, S>
where
    St: unknown_venue_state::State,
    St::Id: unknown_venue_state::IsSet,
    St::Name: unknown_venue_state::IsSet,
    St::Type: unknown_venue_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> UnknownVenue<S> {
        UnknownVenue {
            id: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            r#type: 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<SmolStr, Data<S>>,
    ) -> UnknownVenue<S> {
        UnknownVenue {
            id: self._fields.0.unwrap(),
            name: self._fields.1.unwrap(),
            r#type: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod event_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 Name;
        type V;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Name = Unset;
        type V = Unset;
    }
    ///State transition - sets the `name` field to Set
    pub struct SetName<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetName<St> {}
    impl<St: State> State for SetName<St> {
        type Name = Set<members::name>;
        type V = St::V;
    }
    ///State transition - sets the `v` field to Set
    pub struct SetV<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetV<St> {}
    impl<St: State> State for SetV<St> {
        type Name = St::Name;
        type V = Set<members::v>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `v` field
        pub struct v(());
    }
}

/// Builder for constructing an instance of this type.
pub struct EventBuilder<St: event_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Vec<Data<S>>>,
        Option<Vec<Data<S>>>,
        Option<Data<S>>,
        Option<Data<S>>,
        Option<Data<S>>,
        Option<i64>,
        Option<Vec<EventVenuesItem<S>>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Event<S> {
    /// Create a new builder for this type
    pub fn builder() -> EventBuilder<event_state::Empty, S> {
        EventBuilder::builder()
    }
}

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

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

impl<St: event_state::State, S: BosStr> EventBuilder<St, S> {
    /// Set the `components` field (optional)
    pub fn components(mut self, value: impl Into<Option<Vec<Data<S>>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `components` field to an Option value (optional)
    pub fn maybe_components(mut self, value: Option<Vec<Data<S>>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: event_state::State, S: BosStr> EventBuilder<St, S> {
    /// Set the `instances` field (optional)
    pub fn instances(mut self, value: impl Into<Option<Vec<Data<S>>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `instances` field to an Option value (optional)
    pub fn maybe_instances(mut self, value: Option<Vec<Data<S>>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: event_state::State, S: BosStr> EventBuilder<St, S> {
    /// Set the `label` field (optional)
    pub fn label(mut self, value: impl Into<Option<Data<S>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `label` field to an Option value (optional)
    pub fn maybe_label(mut self, value: Option<Data<S>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> EventBuilder<St, S>
where
    St: event_state::State,
    St::Name: event_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<Data<S>>,
    ) -> EventBuilder<event_state::SetName<St>, S> {
        self._fields.3 = Option::Some(value.into());
        EventBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: event_state::State, S: BosStr> EventBuilder<St, S> {
    /// Set the `status` field (optional)
    pub fn status(mut self, value: impl Into<Option<Data<S>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `status` field to an Option value (optional)
    pub fn maybe_status(mut self, value: Option<Data<S>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> EventBuilder<St, S>
where
    St: event_state::State,
    St::V: event_state::IsUnset,
{
    /// Set the `v` field (required)
    pub fn v(mut self, value: impl Into<i64>) -> EventBuilder<event_state::SetV<St>, S> {
        self._fields.5 = Option::Some(value.into());
        EventBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: event_state::State, S: BosStr> EventBuilder<St, S> {
    /// Set the `venues` field (optional)
    pub fn venues(mut self, value: impl Into<Option<Vec<EventVenuesItem<S>>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `venues` field to an Option value (optional)
    pub fn maybe_venues(mut self, value: Option<Vec<EventVenuesItem<S>>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St, S: BosStr> EventBuilder<St, S>
where
    St: event_state::State,
    St::Name: event_state::IsSet,
    St::V: event_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Event<S> {
        Event {
            components: self._fields.0,
            instances: self._fields.1,
            label: self._fields.2,
            name: self._fields.3.unwrap(),
            status: self._fields.4,
            v: self._fields.5.unwrap(),
            venues: self._fields.6,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Event<S> {
        Event {
            components: self._fields.0,
            instances: self._fields.1,
            label: self._fields.2,
            name: self._fields.3.unwrap(),
            status: self._fields.4,
            v: self._fields.5.unwrap(),
            venues: self._fields.6,
            extra_data: Some(extra_data),
        }
    }
}