// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: social.showcase.profile.profile
//
// 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::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime, UriValue};
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::social_showcase::ShowcaseItem;
/// User profile record

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "social.showcase.profile.profile",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Profile<S: BosStr = DefaultStr> {
    ///Custom accent color hex code (e.g. #2e4a6e)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub accent_color: Option<S>,
    ///Avatar image blob (1000x1000px max)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub avatar: Option<BlobRef<S>>,
    ///Banner image blob (3000x1000px max)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub banner: Option<BlobRef<S>>,
    ///Profile description
    #[serde(skip_serializing_if = "Option::is_none")]
    pub bio: Option<S>,
    ///Total number of collections  Defaults to `0`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_profile_collection_count")]
    pub collection_count: Option<i64>,
    pub created_at: Datetime,
    ///User's DID
    pub did: S,
    ///Display name
    #[serde(skip_serializing_if = "Option::is_none")]
    pub display_name: Option<S>,
    ///User's handle
    pub handle: S,
    ///Total number of items in the user's library  Defaults to `0`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_profile_item_count")]
    pub item_count: Option<i64>,
    ///Schema version for migrations (defaults to 1 if missing)  Defaults to `1`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_profile_schema_version")]
    pub schema_version: Option<i64>,
    ///Featured showcase items
    #[serde(skip_serializing_if = "Option::is_none")]
    pub showcase: Option<Vec<ShowcaseItem<S>>>,
    ///Profile tags for discovery (max 10)
    pub tags: Vec<S>,
    ///Profile theme preset name
    #[serde(skip_serializing_if = "Option::is_none")]
    pub theme: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub updated_at: Option<Datetime>,
    ///External website URL
    #[serde(skip_serializing_if = "Option::is_none")]
    pub website: Option<UriValue<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// 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 ProfileGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Profile<S>,
}

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct ProfileRecord;
impl XrpcResp for ProfileRecord {
    const NSID: &'static str = "social.showcase.profile.profile";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = ProfileGetRecordOutput<S>;
    type Err = RecordError;
}

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

impl<S: BosStr> Collection for Profile<S> {
    const NSID: &'static str = "social.showcase.profile.profile";
    type Record = ProfileRecord;
}

impl Collection for ProfileRecord {
    const NSID: &'static str = "social.showcase.profile.profile";
    type Record = ProfileRecord;
}

impl<S: BosStr> LexiconSchema for Profile<S> {
    fn nsid() -> &'static str {
        "social.showcase.profile.profile"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_showcase_profile_profile()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.accent_color {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 7usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("accent_color"),
                    max: 7usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.avatar {
            {
                let size = value.blob().size;
                if size > 1000000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("avatar"),
                        max: 1000000usize,
                        actual: size,
                    });
                }
            }
        }
        if let Some(ref value) = self.avatar {
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/png", "image/jpeg", "image/webp"];
                let matched = accepted
                    .iter()
                    .any(|pattern| {
                        if *pattern == "*/*" {
                            true
                        } else if pattern.ends_with("/*") {
                            let prefix = &pattern[..pattern.len() - 2];
                            mime.starts_with(prefix)
                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
                        } else {
                            mime == *pattern
                        }
                    });
                if !matched {
                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
                        path: ValidationPath::from_field("avatar"),
                        accepted: vec![
                            "image/png".to_string(), "image/jpeg".to_string(),
                            "image/webp".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        if let Some(ref value) = self.banner {
            {
                let size = value.blob().size;
                if size > 1000000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("banner"),
                        max: 1000000usize,
                        actual: size,
                    });
                }
            }
        }
        if let Some(ref value) = self.banner {
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/png", "image/jpeg", "image/webp"];
                let matched = accepted
                    .iter()
                    .any(|pattern| {
                        if *pattern == "*/*" {
                            true
                        } else if pattern.ends_with("/*") {
                            let prefix = &pattern[..pattern.len() - 2];
                            mime.starts_with(prefix)
                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
                        } else {
                            mime == *pattern
                        }
                    });
                if !matched {
                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
                        path: ValidationPath::from_field("banner"),
                        accepted: vec![
                            "image/png".to_string(), "image/jpeg".to_string(),
                            "image/webp".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        if let Some(ref value) = self.bio {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("bio"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.did;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2048usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("did"),
                    max: 2048usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.display_name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("display_name"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.handle;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 253usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("handle"),
                    max: 253usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.showcase {
            #[allow(unused_comparisons)]
            if value.len() > 4usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("showcase"),
                    max: 4usize,
                    actual: value.len(),
                });
            }
        }
        {
            let value = &self.tags;
            #[allow(unused_comparisons)]
            if value.len() > 10usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("tags"),
                    max: 10usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.theme {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("theme"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.website {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2048usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("website"),
                    max: 2048usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

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

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

fn _default_profile_schema_version() -> Option<i64> {
    Some(1i64)
}

pub mod profile_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 Did;
        type Handle;
        type Tags;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Did = Unset;
        type Handle = Unset;
        type Tags = 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 Did = St::Did;
        type Handle = St::Handle;
        type Tags = St::Tags;
    }
    ///State transition - sets the `did` field to Set
    pub struct SetDid<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetDid<St> {}
    impl<St: State> State for SetDid<St> {
        type CreatedAt = St::CreatedAt;
        type Did = Set<members::did>;
        type Handle = St::Handle;
        type Tags = St::Tags;
    }
    ///State transition - sets the `handle` field to Set
    pub struct SetHandle<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetHandle<St> {}
    impl<St: State> State for SetHandle<St> {
        type CreatedAt = St::CreatedAt;
        type Did = St::Did;
        type Handle = Set<members::handle>;
        type Tags = St::Tags;
    }
    ///State transition - sets the `tags` field to Set
    pub struct SetTags<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTags<St> {}
    impl<St: State> State for SetTags<St> {
        type CreatedAt = St::CreatedAt;
        type Did = St::Did;
        type Handle = St::Handle;
        type Tags = Set<members::tags>;
    }
    /// 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 `did` field
        pub struct did(());
        ///Marker type for the `handle` field
        pub struct handle(());
        ///Marker type for the `tags` field
        pub struct tags(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ProfileBuilder<St: profile_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<BlobRef<S>>,
        Option<BlobRef<S>>,
        Option<S>,
        Option<i64>,
        Option<Datetime>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<i64>,
        Option<i64>,
        Option<Vec<ShowcaseItem<S>>>,
        Option<Vec<S>>,
        Option<S>,
        Option<Datetime>,
        Option<UriValue<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Profile<S> {
    /// Create a new builder for this type
    pub fn builder() -> ProfileBuilder<profile_state::Empty, S> {
        ProfileBuilder::builder()
    }
}

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

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

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

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `avatar` field (optional)
    pub fn avatar(mut self, value: impl Into<Option<BlobRef<S>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `avatar` field to an Option value (optional)
    pub fn maybe_avatar(mut self, value: Option<BlobRef<S>>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

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

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `collectionCount` field (optional)
    pub fn collection_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `collectionCount` field to an Option value (optional)
    pub fn maybe_collection_count(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

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

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::Did: profile_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<S>,
    ) -> ProfileBuilder<profile_state::SetDid<St>, S> {
        self._fields.6 = Option::Some(value.into());
        ProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `displayName` field (optional)
    pub fn display_name(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `displayName` field to an Option value (optional)
    pub fn maybe_display_name(mut self, value: Option<S>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::Handle: profile_state::IsUnset,
{
    /// Set the `handle` field (required)
    pub fn handle(
        mut self,
        value: impl Into<S>,
    ) -> ProfileBuilder<profile_state::SetHandle<St>, S> {
        self._fields.8 = Option::Some(value.into());
        ProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `itemCount` field (optional)
    pub fn item_count(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `itemCount` field to an Option value (optional)
    pub fn maybe_item_count(mut self, value: Option<i64>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `schemaVersion` field (optional)
    pub fn schema_version(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `schemaVersion` field to an Option value (optional)
    pub fn maybe_schema_version(mut self, value: Option<i64>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `showcase` field (optional)
    pub fn showcase(mut self, value: impl Into<Option<Vec<ShowcaseItem<S>>>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `showcase` field to an Option value (optional)
    pub fn maybe_showcase(mut self, value: Option<Vec<ShowcaseItem<S>>>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::Tags: profile_state::IsUnset,
{
    /// Set the `tags` field (required)
    pub fn tags(
        mut self,
        value: impl Into<Vec<S>>,
    ) -> ProfileBuilder<profile_state::SetTags<St>, S> {
        self._fields.12 = Option::Some(value.into());
        ProfileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `theme` field (optional)
    pub fn theme(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `theme` field to an Option value (optional)
    pub fn maybe_theme(mut self, value: Option<S>) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `updatedAt` field (optional)
    pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `updatedAt` field to an Option value (optional)
    pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<St: profile_state::State, S: BosStr> ProfileBuilder<St, S> {
    /// Set the `website` field (optional)
    pub fn website(mut self, value: impl Into<Option<UriValue<S>>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `website` field to an Option value (optional)
    pub fn maybe_website(mut self, value: Option<UriValue<S>>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<St, S: BosStr> ProfileBuilder<St, S>
where
    St: profile_state::State,
    St::CreatedAt: profile_state::IsSet,
    St::Did: profile_state::IsSet,
    St::Handle: profile_state::IsSet,
    St::Tags: profile_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Profile<S> {
        Profile {
            accent_color: self._fields.0,
            avatar: self._fields.1,
            banner: self._fields.2,
            bio: self._fields.3,
            collection_count: self._fields.4.or_else(|| Some(0i64)),
            created_at: self._fields.5.unwrap(),
            did: self._fields.6.unwrap(),
            display_name: self._fields.7,
            handle: self._fields.8.unwrap(),
            item_count: self._fields.9.or_else(|| Some(0i64)),
            schema_version: self._fields.10.or_else(|| Some(1i64)),
            showcase: self._fields.11,
            tags: self._fields.12.unwrap(),
            theme: self._fields.13,
            updated_at: self._fields.14,
            website: self._fields.15,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Profile<S> {
        Profile {
            accent_color: self._fields.0,
            avatar: self._fields.1,
            banner: self._fields.2,
            bio: self._fields.3,
            collection_count: self._fields.4.or_else(|| Some(0i64)),
            created_at: self._fields.5.unwrap(),
            did: self._fields.6.unwrap(),
            display_name: self._fields.7,
            handle: self._fields.8.unwrap(),
            item_count: self._fields.9.or_else(|| Some(0i64)),
            schema_version: self._fields.10.or_else(|| Some(1i64)),
            showcase: self._fields.11,
            tags: self._fields.12.unwrap(),
            theme: self._fields.13,
            updated_at: self._fields.14,
            website: self._fields.15,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_social_showcase_profile_profile() -> 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("social.showcase.profile.profile"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(CowStr::new_static("User profile record")),
                    key: Some(CowStr::new_static("literal:self")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("did"), SmolStr::new_static("handle"),
                                SmolStr::new_static("tags"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("accentColor"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Custom accent color hex code (e.g. #2e4a6e)",
                                        ),
                                    ),
                                    max_length: Some(7usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("avatar"),
                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("banner"),
                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("bio"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Profile description"),
                                    ),
                                    max_length: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("collectionCount"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("did"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("User's DID")),
                                    max_length: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("displayName"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("Display name")),
                                    max_length: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("handle"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("User's handle")),
                                    max_length: Some(253usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("itemCount"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("schemaVersion"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("showcase"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static("Featured showcase items"),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static(
                                            "social.showcase.defs#showcaseItem",
                                        ),
                                        ..Default::default()
                                    }),
                                    max_length: Some(4usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("tags"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static("Profile tags for discovery (max 10)"),
                                    ),
                                    items: LexArrayItem::String(LexString {
                                        max_length: Some(64usize),
                                        ..Default::default()
                                    }),
                                    max_length: Some(10usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("theme"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Profile theme preset name"),
                                    ),
                                    max_length: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("updatedAt"),
                                LexObjectProperty::String(LexString {
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("website"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("External website URL"),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    max_length: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}