// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: coop.hypha.spores.site.section
//
// 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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
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};
/// A single site section for spores.garden. Each section is a record in a collection.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Section<'a> {
    ///Collection NSID to display (for type=collection)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub collection: Option<CowStr<'a>>,
    ///Content for block sections
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub content: Option<CowStr<'a>>,
    ///Content format
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub format: Option<SectionFormat<'a>>,
    ///If true, hides the section header in display mode
    #[serde(skip_serializing_if = "Option::is_none")]
    pub hide_header: Option<bool>,
    ///Layout to use for rendering
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub layout: Option<SectionLayout<'a>>,
    ///Maximum records to display
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
    ///Specific record URIs to display (for type=records)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub records: Option<Vec<AtUri<'a>>>,
    ///AT-URI of the referenced record (for content/profile sections)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub r#ref: Option<AtUri<'a>>,
    ///Record key within the collection to display (e.g. 'self' for profile)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub rkey: Option<CowStr<'a>>,
    ///Section title
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub title: Option<CowStr<'a>>,
    ///Section type
    #[serde(borrow)]
    pub r#type: SectionType<'a>,
}

/// Content format

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SectionFormat<'a> {
    Markdown,
    Html,
    Text,
    Other(CowStr<'a>),
}

impl<'a> SectionFormat<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Markdown => "markdown",
            Self::Html => "html",
            Self::Text => "text",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for SectionFormat<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "markdown" => Self::Markdown,
            "html" => Self::Html,
            "text" => Self::Text,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for SectionFormat<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "markdown" => Self::Markdown,
            "html" => Self::Html,
            "text" => Self::Text,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for SectionFormat<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, 'a> serde::Deserialize<'de> for SectionFormat<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for SectionFormat<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for SectionFormat<'_> {
    type Output = SectionFormat<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            SectionFormat::Markdown => SectionFormat::Markdown,
            SectionFormat::Html => SectionFormat::Html,
            SectionFormat::Text => SectionFormat::Text,
            SectionFormat::Other(v) => SectionFormat::Other(v.into_static()),
        }
    }
}

/// Layout to use for rendering

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SectionLayout<'a> {
    Post,
    Card,
    Image,
    Link,
    Links,
    List,
    Profile,
    Raw,
    Other(CowStr<'a>),
}

impl<'a> SectionLayout<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Post => "post",
            Self::Card => "card",
            Self::Image => "image",
            Self::Link => "link",
            Self::Links => "links",
            Self::List => "list",
            Self::Profile => "profile",
            Self::Raw => "raw",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for SectionLayout<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "post" => Self::Post,
            "card" => Self::Card,
            "image" => Self::Image,
            "link" => Self::Link,
            "links" => Self::Links,
            "list" => Self::List,
            "profile" => Self::Profile,
            "raw" => Self::Raw,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for SectionLayout<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "post" => Self::Post,
            "card" => Self::Card,
            "image" => Self::Image,
            "link" => Self::Link,
            "links" => Self::Links,
            "list" => Self::List,
            "profile" => Self::Profile,
            "raw" => Self::Raw,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for SectionLayout<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, 'a> serde::Deserialize<'de> for SectionLayout<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for SectionLayout<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for SectionLayout<'_> {
    type Output = SectionLayout<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            SectionLayout::Post => SectionLayout::Post,
            SectionLayout::Card => SectionLayout::Card,
            SectionLayout::Image => SectionLayout::Image,
            SectionLayout::Link => SectionLayout::Link,
            SectionLayout::Links => SectionLayout::Links,
            SectionLayout::List => SectionLayout::List,
            SectionLayout::Profile => SectionLayout::Profile,
            SectionLayout::Raw => SectionLayout::Raw,
            SectionLayout::Other(v) => SectionLayout::Other(v.into_static()),
        }
    }
}

/// Section type

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SectionType<'a> {
    Collection,
    Records,
    Content,
    Block,
    Profile,
    ShareToBluesky,
    CollectedFlowers,
    Other(CowStr<'a>),
}

impl<'a> SectionType<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Collection => "collection",
            Self::Records => "records",
            Self::Content => "content",
            Self::Block => "block",
            Self::Profile => "profile",
            Self::ShareToBluesky => "share-to-bluesky",
            Self::CollectedFlowers => "collected-flowers",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for SectionType<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "collection" => Self::Collection,
            "records" => Self::Records,
            "content" => Self::Content,
            "block" => Self::Block,
            "profile" => Self::Profile,
            "share-to-bluesky" => Self::ShareToBluesky,
            "collected-flowers" => Self::CollectedFlowers,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for SectionType<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "collection" => Self::Collection,
            "records" => Self::Records,
            "content" => Self::Content,
            "block" => Self::Block,
            "profile" => Self::Profile,
            "share-to-bluesky" => Self::ShareToBluesky,
            "collected-flowers" => Self::CollectedFlowers,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

impl<'a> AsRef<str> for SectionType<'a> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

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

impl<'de, 'a> serde::Deserialize<'de> for SectionType<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for SectionType<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for SectionType<'_> {
    type Output = SectionType<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            SectionType::Collection => SectionType::Collection,
            SectionType::Records => SectionType::Records,
            SectionType::Content => SectionType::Content,
            SectionType::Block => SectionType::Block,
            SectionType::Profile => SectionType::Profile,
            SectionType::ShareToBluesky => SectionType::ShareToBluesky,
            SectionType::CollectedFlowers => SectionType::CollectedFlowers,
            SectionType::Other(v) => SectionType::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 SectionGetRecordOutput<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cid: Option<Cid<'a>>,
    #[serde(borrow)]
    pub uri: AtUri<'a>,
    #[serde(borrow)]
    pub value: Section<'a>,
}

impl<'a> Section<'a> {
    pub fn uri(
        uri: impl Into<CowStr<'a>>,
    ) -> Result<RecordUri<'a, SectionRecord>, UriError> {
        RecordUri::try_from_uri(AtUri::new_cow(uri.into())?)
    }
}

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

#[derive(Debug, Serialize, Deserialize)]
pub struct SectionRecord;
impl XrpcResp for SectionRecord {
    const NSID: &'static str = "coop.hypha.spores.site.section";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = SectionGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

impl From<SectionGetRecordOutput<'_>> for Section<'_> {
    fn from(output: SectionGetRecordOutput<'_>) -> Self {
        use jacquard_common::IntoStatic;
        output.value.into_static()
    }
}

impl Collection for Section<'_> {
    const NSID: &'static str = "coop.hypha.spores.site.section";
    type Record = SectionRecord;
}

impl Collection for SectionRecord {
    const NSID: &'static str = "coop.hypha.spores.site.section";
    type Record = SectionRecord;
}

impl<'a> LexiconSchema for Section<'a> {
    fn nsid() -> &'static str {
        "coop.hypha.spores.site.section"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_coop_hypha_spores_site_section()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.content {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("content"),
                    max: 500000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.content {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 50000usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("content"),
                        max: 50000usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.limit {
            if *value > 100i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("limit"),
                    max: 100i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.limit {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("limit"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.title {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("title"),
                    max: 2000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.title {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 200usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("title"),
                        max: 200usize,
                        actual: count,
                    });
                }
            }
        }
        Ok(())
    }
}

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

/// Builder for constructing an instance of this type
pub struct SectionBuilder<'a, S: section_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<SectionFormat<'a>>,
        Option<bool>,
        Option<SectionLayout<'a>>,
        Option<i64>,
        Option<Vec<AtUri<'a>>>,
        Option<AtUri<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<SectionType<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Section<'a> {
    /// Create a new builder for this type
    pub fn new() -> SectionBuilder<'a, section_state::Empty> {
        SectionBuilder::new()
    }
}

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

impl<'a, S: section_state::State> SectionBuilder<'a, S> {
    /// Set the `collection` field (optional)
    pub fn collection(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `collection` field to an Option value (optional)
    pub fn maybe_collection(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S: section_state::State> SectionBuilder<'a, S> {
    /// Set the `content` field (optional)
    pub fn content(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `content` field to an Option value (optional)
    pub fn maybe_content(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S: section_state::State> SectionBuilder<'a, S> {
    /// Set the `format` field (optional)
    pub fn format(mut self, value: impl Into<Option<SectionFormat<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `format` field to an Option value (optional)
    pub fn maybe_format(mut self, value: Option<SectionFormat<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S: section_state::State> SectionBuilder<'a, S> {
    /// Set the `hideHeader` field (optional)
    pub fn hide_header(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `hideHeader` field to an Option value (optional)
    pub fn maybe_hide_header(mut self, value: Option<bool>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: section_state::State> SectionBuilder<'a, S> {
    /// Set the `layout` field (optional)
    pub fn layout(mut self, value: impl Into<Option<SectionLayout<'a>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `layout` field to an Option value (optional)
    pub fn maybe_layout(mut self, value: Option<SectionLayout<'a>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: section_state::State> SectionBuilder<'a, S> {
    /// Set the `limit` field (optional)
    pub fn limit(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `limit` field to an Option value (optional)
    pub fn maybe_limit(mut self, value: Option<i64>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: section_state::State> SectionBuilder<'a, S> {
    /// Set the `records` field (optional)
    pub fn records(mut self, value: impl Into<Option<Vec<AtUri<'a>>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `records` field to an Option value (optional)
    pub fn maybe_records(mut self, value: Option<Vec<AtUri<'a>>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S: section_state::State> SectionBuilder<'a, S> {
    /// Set the `ref` field (optional)
    pub fn r#ref(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `ref` field to an Option value (optional)
    pub fn maybe_ref(mut self, value: Option<AtUri<'a>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S: section_state::State> SectionBuilder<'a, S> {
    /// Set the `rkey` field (optional)
    pub fn rkey(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `rkey` field to an Option value (optional)
    pub fn maybe_rkey(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<'a, S: section_state::State> SectionBuilder<'a, S> {
    /// Set the `title` field (optional)
    pub fn title(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `title` field to an Option value (optional)
    pub fn maybe_title(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<'a, S> SectionBuilder<'a, S>
where
    S: section_state::State,
    S::Type: section_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<SectionType<'a>>,
    ) -> SectionBuilder<'a, section_state::SetType<S>> {
        self._fields.10 = Option::Some(value.into());
        SectionBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> SectionBuilder<'a, S>
where
    S: section_state::State,
    S::Type: section_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Section<'a> {
        Section {
            collection: self._fields.0,
            content: self._fields.1,
            format: self._fields.2,
            hide_header: self._fields.3,
            layout: self._fields.4,
            limit: self._fields.5,
            records: self._fields.6,
            r#ref: self._fields.7,
            rkey: self._fields.8,
            title: self._fields.9,
            r#type: self._fields.10.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Section<'a> {
        Section {
            collection: self._fields.0,
            content: self._fields.1,
            format: self._fields.2,
            hide_header: self._fields.3,
            layout: self._fields.4,
            limit: self._fields.5,
            records: self._fields.6,
            r#ref: self._fields.7,
            rkey: self._fields.8,
            title: self._fields.9,
            r#type: self._fields.10.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_coop_hypha_spores_site_section() -> 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("coop.hypha.spores.site.section"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A single site section for spores.garden. Each section is a record in a collection.",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(vec![SmolStr::new_static("type")]),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("collection"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Collection NSID to display (for type=collection)",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("content"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Content for block sections"),
                                    ),
                                    max_length: Some(500000usize),
                                    max_graphemes: Some(50000usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("format"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("Content format")),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("hideHeader"),
                                LexObjectProperty::Boolean(LexBoolean {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("layout"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Layout to use for rendering"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("limit"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(100i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("records"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Specific record URIs to display (for type=records)",
                                        ),
                                    ),
                                    items: LexArrayItem::String(LexString {
                                        format: Some(LexStringFormat::AtUri),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("ref"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "AT-URI of the referenced record (for content/profile sections)",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("rkey"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Record key within the collection to display (e.g. 'self' for profile)",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("title"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("Section title")),
                                    max_length: Some(2000usize),
                                    max_graphemes: Some(200usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("type"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("Section type")),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}