// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.protoimsg.chat.room
//
// 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::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::types::value::Data;
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_protoimsg::chat::room;
/// Declares a chat room. Created by whoever starts the room.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "app.protoimsg.chat.room",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Room<S: BosStr = DefaultStr> {
    ///Broad category for room discovery (e.g., music, tech, gaming). Lowercased.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub category: Option<S>,
    ///Timestamp of room creation.
    pub created_at: Datetime,
    ///What the room is about.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<S>,
    ///Display name for the room.
    pub name: S,
    ///Room purpose categorization.
    pub purpose: RoomPurpose<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub settings: Option<room::RoomSettings<S>>,
    ///Room topic for sorting, filtering, and discovery.
    pub topic: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Room purpose categorization.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RoomPurpose<S: BosStr = DefaultStr> {
    Discussion,
    Event,
    Community,
    Support,
    Other(S),
}

impl<S: BosStr> RoomPurpose<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Discussion => "discussion",
            Self::Event => "event",
            Self::Community => "community",
            Self::Support => "support",
            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() {
            "discussion" => Self::Discussion,
            "event" => Self::Event,
            "community" => Self::Community,
            "support" => Self::Support,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for RoomPurpose<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 RoomPurpose<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 RoomPurpose<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for RoomPurpose<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = RoomPurpose<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            RoomPurpose::Discussion => RoomPurpose::Discussion,
            RoomPurpose::Event => RoomPurpose::Event,
            RoomPurpose::Community => RoomPurpose::Community,
            RoomPurpose::Support => RoomPurpose::Support,
            RoomPurpose::Other(v) => RoomPurpose::Other(v.into_static()),
        }
    }
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RoomGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Room<S>,
}

/// Configurable room settings.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct RoomSettings<S: BosStr = DefaultStr> {
    ///When true, only users on the room allowlist can send messages.  Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_room_settings_allowlist_enabled")]
    pub allowlist_enabled: Option<bool>,
    ///Minimum atproto account age in days to participate.  Defaults to `0`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_room_settings_min_account_age_days")]
    pub min_account_age_days: Option<i64>,
    ///Minimum seconds between messages per user. 0 = disabled.  Defaults to `0`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_room_settings_slow_mode_seconds")]
    pub slow_mode_seconds: Option<i64>,
    ///Room discoverability. public = listed in directory, unlisted = link only, private = invite only.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub visibility: Option<RoomSettingsVisibility<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Room discoverability. public = listed in directory, unlisted = link only, private = invite only.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum RoomSettingsVisibility<S: BosStr = DefaultStr> {
    Public,
    Unlisted,
    Private,
    Other(S),
}

impl<S: BosStr> RoomSettingsVisibility<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Public => "public",
            Self::Unlisted => "unlisted",
            Self::Private => "private",
            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() {
            "public" => Self::Public,
            "unlisted" => Self::Unlisted,
            "private" => Self::Private,
            _ => Self::Other(s),
        }
    }
}

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

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

impl<S: BosStr> Serialize for RoomSettingsVisibility<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 RoomSettingsVisibility<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 RoomSettingsVisibility<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for RoomSettingsVisibility<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = RoomSettingsVisibility<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            RoomSettingsVisibility::Public => RoomSettingsVisibility::Public,
            RoomSettingsVisibility::Unlisted => RoomSettingsVisibility::Unlisted,
            RoomSettingsVisibility::Private => RoomSettingsVisibility::Private,
            RoomSettingsVisibility::Other(v) => {
                RoomSettingsVisibility::Other(v.into_static())
            }
        }
    }
}

impl<S: BosStr> Room<S> {
    pub fn uri(uri: S) -> Result<RecordUri<S, RoomRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new(uri)?)
    }
}

/// Marker type for deserializing records from this collection.

#[derive(Debug, Serialize, Deserialize)]
pub struct RoomRecord;
impl XrpcResp for RoomRecord {
    const NSID: &'static str = "app.protoimsg.chat.room";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = RoomGetRecordOutput<S>;
    type Err = RecordError;
}

impl<S: BosStr> From<RoomGetRecordOutput<S>> for Room<S> {
    fn from(output: RoomGetRecordOutput<S>) -> Self {
        output.value
    }
}

impl<S: BosStr> Collection for Room<S> {
    const NSID: &'static str = "app.protoimsg.chat.room";
    type Record = RoomRecord;
}

impl Collection for RoomRecord {
    const NSID: &'static str = "app.protoimsg.chat.room";
    type Record = RoomRecord;
}

impl<S: BosStr> LexiconSchema for Room<S> {
    fn nsid() -> &'static str {
        "app.protoimsg.chat.room"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_protoimsg_chat_room()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.category {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("category"),
                    max: 50usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.description {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("description"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.topic;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("topic"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for RoomSettings<S> {
    fn nsid() -> &'static str {
        "app.protoimsg.chat.room"
    }
    fn def_name() -> &'static str {
        "roomSettings"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_protoimsg_chat_room()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.min_account_age_days {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("min_account_age_days"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.slow_mode_seconds {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("slow_mode_seconds"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

pub mod room_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 CreatedAt;
        type Name;
        type Purpose;
        type Topic;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Name = Unset;
        type Purpose = Unset;
        type Topic = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type Name = St::Name;
        type Purpose = St::Purpose;
        type Topic = St::Topic;
    }
    ///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 CreatedAt = St::CreatedAt;
        type Name = Set<members::name>;
        type Purpose = St::Purpose;
        type Topic = St::Topic;
    }
    ///State transition - sets the `purpose` field to Set
    pub struct SetPurpose<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPurpose<St> {}
    impl<St: State> State for SetPurpose<St> {
        type CreatedAt = St::CreatedAt;
        type Name = St::Name;
        type Purpose = Set<members::purpose>;
        type Topic = St::Topic;
    }
    ///State transition - sets the `topic` field to Set
    pub struct SetTopic<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTopic<St> {}
    impl<St: State> State for SetTopic<St> {
        type CreatedAt = St::CreatedAt;
        type Name = St::Name;
        type Purpose = St::Purpose;
        type Topic = Set<members::topic>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `name` field
        pub struct name(());
        ///Marker type for the `purpose` field
        pub struct purpose(());
        ///Marker type for the `topic` field
        pub struct topic(());
    }
}

/// Builder for constructing an instance of this type.
pub struct RoomBuilder<St: room_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<Datetime>,
        Option<S>,
        Option<S>,
        Option<RoomPurpose<S>>,
        Option<room::RoomSettings<S>>,
        Option<S>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Room<S> {
    /// Create a new builder for this type
    pub fn builder() -> RoomBuilder<room_state::Empty, S> {
        RoomBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> RoomBuilder<St, S>
where
    St: room_state::State,
    St::CreatedAt: room_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> RoomBuilder<room_state::SetCreatedAt<St>, S> {
        self._fields.1 = Option::Some(value.into());
        RoomBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

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

impl<St, S: BosStr> RoomBuilder<St, S>
where
    St: room_state::State,
    St::Purpose: room_state::IsUnset,
{
    /// Set the `purpose` field (required)
    pub fn purpose(
        mut self,
        value: impl Into<RoomPurpose<S>>,
    ) -> RoomBuilder<room_state::SetPurpose<St>, S> {
        self._fields.4 = Option::Some(value.into());
        RoomBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: room_state::State, S: BosStr> RoomBuilder<St, S> {
    /// Set the `settings` field (optional)
    pub fn settings(mut self, value: impl Into<Option<room::RoomSettings<S>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `settings` field to an Option value (optional)
    pub fn maybe_settings(mut self, value: Option<room::RoomSettings<S>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> RoomBuilder<St, S>
where
    St: room_state::State,
    St::Topic: room_state::IsUnset,
{
    /// Set the `topic` field (required)
    pub fn topic(
        mut self,
        value: impl Into<S>,
    ) -> RoomBuilder<room_state::SetTopic<St>, S> {
        self._fields.6 = Option::Some(value.into());
        RoomBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> RoomBuilder<St, S>
where
    St: room_state::State,
    St::CreatedAt: room_state::IsSet,
    St::Name: room_state::IsSet,
    St::Purpose: room_state::IsSet,
    St::Topic: room_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Room<S> {
        Room {
            category: self._fields.0,
            created_at: self._fields.1.unwrap(),
            description: self._fields.2,
            name: self._fields.3.unwrap(),
            purpose: self._fields.4.unwrap(),
            settings: self._fields.5,
            topic: self._fields.6.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>>) -> Room<S> {
        Room {
            category: self._fields.0,
            created_at: self._fields.1.unwrap(),
            description: self._fields.2,
            name: self._fields.3.unwrap(),
            purpose: self._fields.4.unwrap(),
            settings: self._fields.5,
            topic: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_protoimsg_chat_room() -> 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("app.protoimsg.chat.room"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "Declares a chat room. Created by whoever starts the room.",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("name"), SmolStr::new_static("topic"),
                                SmolStr::new_static("purpose"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("category"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Broad category for room discovery (e.g., music, tech, gaming). Lowercased.",
                                        ),
                                    ),
                                    max_length: Some(50usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Timestamp of room creation."),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("description"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("What the room is about."),
                                    ),
                                    max_length: Some(500usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Display name for the room."),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("purpose"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Room purpose categorization."),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("settings"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#roomSettings"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("topic"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Room topic for sorting, filtering, and discovery.",
                                        ),
                                    ),
                                    max_length: Some(200usize),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("roomSettings"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("Configurable room settings.")),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("allowlistEnabled"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("minAccountAgeDays"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("slowModeSeconds"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("visibility"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Room discoverability. public = listed in directory, unlisted = link only, private = invite only.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

fn _default_room_settings_allowlist_enabled() -> Option<bool> {
    Some(false)
}

fn _default_room_settings_min_account_age_days() -> Option<i64> {
    Some(0i64)
}

fn _default_room_settings_slow_mode_seconds() -> Option<i64> {
    Some(0i64)
}

impl Default for RoomSettings {
    fn default() -> Self {
        Self {
            allowlist_enabled: Some(false),
            min_account_age_days: Some(0i64),
            slow_mode_seconds: Some(0i64),
            visibility: None,
            extra_data: Default::default(),
        }
    }
}