// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: com.suibari.atsumeat.sticker
//
// 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::{Did, 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};
/// Definition of a sticker

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "com.suibari.atsumeat.sticker",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Sticker<S: BosStr = DefaultStr> {
    ///The image content, either a string URL (for CDN/Blob) or a BlobRef.
    pub image: Data<S>,
    ///Type of the image source.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub image_type: Option<StickerImageType<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub message: Option<S>,
    ///Identifier for the sticker model. 'default' for avatar stickers, 'cid:<cid>' for custom stickers.
    pub model: S,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<S>,
    ///The timestamp when this sticker was obtained.
    pub obtained_at: Datetime,
    ///The DID of the user from whom this sticker was obtained (for provenance).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub obtained_from: Option<Did<S>>,
    ///The DID of the original creator/minter of this sticker.
    pub original_owner: Did<S>,
    ///The shape of the sticker canvas.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub shape: Option<StickerShape<S>>,
    ///Cryptographic signature from the server verifying the sticker's authenticity/provenance.
    pub signature: S,
    ///The original JSON payload that was signed by the server.
    pub signed_payload: S,
    ///The DID of the user depicted in the sticker, if applicable (e.g. for avatar stickers).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub subject_did: Option<Did<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<Vec<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Type of the image source.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum StickerImageType<S: BosStr = DefaultStr> {
    Avatar,
    Custom,
    Other(S),
}

impl<S: BosStr> StickerImageType<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Avatar => "avatar",
            Self::Custom => "custom",
            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() {
            "avatar" => Self::Avatar,
            "custom" => Self::Custom,
            _ => Self::Other(s),
        }
    }
}

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

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

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

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

/// The shape of the sticker canvas.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum StickerShape<S: BosStr = DefaultStr> {
    Circle,
    Square,
    Rectangle,
    Star,
    Heart,
    Diamond,
    Butterfly,
    Transparent,
    Other(S),
}

impl<S: BosStr> StickerShape<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Circle => "circle",
            Self::Square => "square",
            Self::Rectangle => "rectangle",
            Self::Star => "star",
            Self::Heart => "heart",
            Self::Diamond => "diamond",
            Self::Butterfly => "butterfly",
            Self::Transparent => "transparent",
            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() {
            "circle" => Self::Circle,
            "square" => Self::Square,
            "rectangle" => Self::Rectangle,
            "star" => Self::Star,
            "heart" => Self::Heart,
            "diamond" => Self::Diamond,
            "butterfly" => Self::Butterfly,
            "transparent" => Self::Transparent,
            _ => Self::Other(s),
        }
    }
}

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

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

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

impl<S: BosStr> jacquard_common::IntoStatic for StickerShape<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = StickerShape<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            StickerShape::Circle => StickerShape::Circle,
            StickerShape::Square => StickerShape::Square,
            StickerShape::Rectangle => StickerShape::Rectangle,
            StickerShape::Star => StickerShape::Star,
            StickerShape::Heart => StickerShape::Heart,
            StickerShape::Diamond => StickerShape::Diamond,
            StickerShape::Butterfly => StickerShape::Butterfly,
            StickerShape::Transparent => StickerShape::Transparent,
            StickerShape::Other(v) => StickerShape::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 StickerGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Sticker<S>,
}

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct StickerRecord;
impl XrpcResp for StickerRecord {
    const NSID: &'static str = "com.suibari.atsumeat.sticker";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = StickerGetRecordOutput<S>;
    type Err = RecordError;
}

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

impl<S: BosStr> Collection for Sticker<S> {
    const NSID: &'static str = "com.suibari.atsumeat.sticker";
    type Record = StickerRecord;
}

impl Collection for StickerRecord {
    const NSID: &'static str = "com.suibari.atsumeat.sticker";
    type Record = StickerRecord;
}

impl<S: BosStr> LexiconSchema for Sticker<S> {
    fn nsid() -> &'static str {
        "com.suibari.atsumeat.sticker"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_com_suibari_atsumeat_sticker()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.image_type {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("image_type"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.message {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 6400usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("message"),
                    max: 6400usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.message {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 640usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("message"),
                        max: 640usize,
                        actual: count,
                    });
                }
            }
        }
        {
            let value = &self.model;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("model"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 640usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 640usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.name {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 64usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("name"),
                        max: 64usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.shape {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("shape"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.signature;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2048usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("signature"),
                    max: 2048usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.signed_payload;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 10000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("signed_payload"),
                    max: 10000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.tags {
            #[allow(unused_comparisons)]
            if value.len() > 8usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("tags"),
                    max: 8usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

pub mod sticker_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 Image;
        type Model;
        type ObtainedAt;
        type OriginalOwner;
        type Signature;
        type SignedPayload;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Image = Unset;
        type Model = Unset;
        type ObtainedAt = Unset;
        type OriginalOwner = Unset;
        type Signature = Unset;
        type SignedPayload = Unset;
    }
    ///State transition - sets the `image` field to Set
    pub struct SetImage<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetImage<St> {}
    impl<St: State> State for SetImage<St> {
        type Image = Set<members::image>;
        type Model = St::Model;
        type ObtainedAt = St::ObtainedAt;
        type OriginalOwner = St::OriginalOwner;
        type Signature = St::Signature;
        type SignedPayload = St::SignedPayload;
    }
    ///State transition - sets the `model` field to Set
    pub struct SetModel<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetModel<St> {}
    impl<St: State> State for SetModel<St> {
        type Image = St::Image;
        type Model = Set<members::model>;
        type ObtainedAt = St::ObtainedAt;
        type OriginalOwner = St::OriginalOwner;
        type Signature = St::Signature;
        type SignedPayload = St::SignedPayload;
    }
    ///State transition - sets the `obtained_at` field to Set
    pub struct SetObtainedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetObtainedAt<St> {}
    impl<St: State> State for SetObtainedAt<St> {
        type Image = St::Image;
        type Model = St::Model;
        type ObtainedAt = Set<members::obtained_at>;
        type OriginalOwner = St::OriginalOwner;
        type Signature = St::Signature;
        type SignedPayload = St::SignedPayload;
    }
    ///State transition - sets the `original_owner` field to Set
    pub struct SetOriginalOwner<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetOriginalOwner<St> {}
    impl<St: State> State for SetOriginalOwner<St> {
        type Image = St::Image;
        type Model = St::Model;
        type ObtainedAt = St::ObtainedAt;
        type OriginalOwner = Set<members::original_owner>;
        type Signature = St::Signature;
        type SignedPayload = St::SignedPayload;
    }
    ///State transition - sets the `signature` field to Set
    pub struct SetSignature<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSignature<St> {}
    impl<St: State> State for SetSignature<St> {
        type Image = St::Image;
        type Model = St::Model;
        type ObtainedAt = St::ObtainedAt;
        type OriginalOwner = St::OriginalOwner;
        type Signature = Set<members::signature>;
        type SignedPayload = St::SignedPayload;
    }
    ///State transition - sets the `signed_payload` field to Set
    pub struct SetSignedPayload<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetSignedPayload<St> {}
    impl<St: State> State for SetSignedPayload<St> {
        type Image = St::Image;
        type Model = St::Model;
        type ObtainedAt = St::ObtainedAt;
        type OriginalOwner = St::OriginalOwner;
        type Signature = St::Signature;
        type SignedPayload = Set<members::signed_payload>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `image` field
        pub struct image(());
        ///Marker type for the `model` field
        pub struct model(());
        ///Marker type for the `obtained_at` field
        pub struct obtained_at(());
        ///Marker type for the `original_owner` field
        pub struct original_owner(());
        ///Marker type for the `signature` field
        pub struct signature(());
        ///Marker type for the `signed_payload` field
        pub struct signed_payload(());
    }
}

/// Builder for constructing an instance of this type.
pub struct StickerBuilder<St: sticker_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<Data<S>>,
        Option<StickerImageType<S>>,
        Option<S>,
        Option<S>,
        Option<S>,
        Option<Datetime>,
        Option<Did<S>>,
        Option<Did<S>>,
        Option<StickerShape<S>>,
        Option<S>,
        Option<S>,
        Option<Did<S>>,
        Option<Vec<S>>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Sticker<S> {
    /// Create a new builder for this type
    pub fn builder() -> StickerBuilder<sticker_state::Empty, S> {
        StickerBuilder::builder()
    }
}

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

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

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

impl<St: sticker_state::State, S: BosStr> StickerBuilder<St, S> {
    /// Set the `imageType` field (optional)
    pub fn image_type(mut self, value: impl Into<Option<StickerImageType<S>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `imageType` field to an Option value (optional)
    pub fn maybe_image_type(mut self, value: Option<StickerImageType<S>>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

impl<St, S: BosStr> StickerBuilder<St, S>
where
    St: sticker_state::State,
    St::Model: sticker_state::IsUnset,
{
    /// Set the `model` field (required)
    pub fn model(
        mut self,
        value: impl Into<S>,
    ) -> StickerBuilder<sticker_state::SetModel<St>, S> {
        self._fields.3 = Option::Some(value.into());
        StickerBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

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

impl<St, S: BosStr> StickerBuilder<St, S>
where
    St: sticker_state::State,
    St::ObtainedAt: sticker_state::IsUnset,
{
    /// Set the `obtainedAt` field (required)
    pub fn obtained_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> StickerBuilder<sticker_state::SetObtainedAt<St>, S> {
        self._fields.5 = Option::Some(value.into());
        StickerBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: sticker_state::State, S: BosStr> StickerBuilder<St, S> {
    /// Set the `obtainedFrom` field (optional)
    pub fn obtained_from(mut self, value: impl Into<Option<Did<S>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `obtainedFrom` field to an Option value (optional)
    pub fn maybe_obtained_from(mut self, value: Option<Did<S>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St, S: BosStr> StickerBuilder<St, S>
where
    St: sticker_state::State,
    St::OriginalOwner: sticker_state::IsUnset,
{
    /// Set the `originalOwner` field (required)
    pub fn original_owner(
        mut self,
        value: impl Into<Did<S>>,
    ) -> StickerBuilder<sticker_state::SetOriginalOwner<St>, S> {
        self._fields.7 = Option::Some(value.into());
        StickerBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: sticker_state::State, S: BosStr> StickerBuilder<St, S> {
    /// Set the `shape` field (optional)
    pub fn shape(mut self, value: impl Into<Option<StickerShape<S>>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `shape` field to an Option value (optional)
    pub fn maybe_shape(mut self, value: Option<StickerShape<S>>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St, S: BosStr> StickerBuilder<St, S>
where
    St: sticker_state::State,
    St::Signature: sticker_state::IsUnset,
{
    /// Set the `signature` field (required)
    pub fn signature(
        mut self,
        value: impl Into<S>,
    ) -> StickerBuilder<sticker_state::SetSignature<St>, S> {
        self._fields.9 = Option::Some(value.into());
        StickerBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> StickerBuilder<St, S>
where
    St: sticker_state::State,
    St::SignedPayload: sticker_state::IsUnset,
{
    /// Set the `signedPayload` field (required)
    pub fn signed_payload(
        mut self,
        value: impl Into<S>,
    ) -> StickerBuilder<sticker_state::SetSignedPayload<St>, S> {
        self._fields.10 = Option::Some(value.into());
        StickerBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: sticker_state::State, S: BosStr> StickerBuilder<St, S> {
    /// Set the `subjectDid` field (optional)
    pub fn subject_did(mut self, value: impl Into<Option<Did<S>>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `subjectDid` field to an Option value (optional)
    pub fn maybe_subject_did(mut self, value: Option<Did<S>>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St: sticker_state::State, S: BosStr> StickerBuilder<St, S> {
    /// Set the `tags` field (optional)
    pub fn tags(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `tags` field to an Option value (optional)
    pub fn maybe_tags(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St, S: BosStr> StickerBuilder<St, S>
where
    St: sticker_state::State,
    St::Image: sticker_state::IsSet,
    St::Model: sticker_state::IsSet,
    St::ObtainedAt: sticker_state::IsSet,
    St::OriginalOwner: sticker_state::IsSet,
    St::Signature: sticker_state::IsSet,
    St::SignedPayload: sticker_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Sticker<S> {
        Sticker {
            image: self._fields.0.unwrap(),
            image_type: self._fields.1,
            message: self._fields.2,
            model: self._fields.3.unwrap(),
            name: self._fields.4,
            obtained_at: self._fields.5.unwrap(),
            obtained_from: self._fields.6,
            original_owner: self._fields.7.unwrap(),
            shape: self._fields.8,
            signature: self._fields.9.unwrap(),
            signed_payload: self._fields.10.unwrap(),
            subject_did: self._fields.11,
            tags: self._fields.12,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Sticker<S> {
        Sticker {
            image: self._fields.0.unwrap(),
            image_type: self._fields.1,
            message: self._fields.2,
            model: self._fields.3.unwrap(),
            name: self._fields.4,
            obtained_at: self._fields.5.unwrap(),
            obtained_from: self._fields.6,
            original_owner: self._fields.7.unwrap(),
            shape: self._fields.8,
            signature: self._fields.9.unwrap(),
            signed_payload: self._fields.10.unwrap(),
            subject_did: self._fields.11,
            tags: self._fields.12,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_com_suibari_atsumeat_sticker() -> 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("com.suibari.atsumeat.sticker"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(CowStr::new_static("Definition of a sticker")),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("image"),
                                SmolStr::new_static("originalOwner"),
                                SmolStr::new_static("model"),
                                SmolStr::new_static("obtainedAt"),
                                SmolStr::new_static("signature"),
                                SmolStr::new_static("signedPayload")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("image"),
                                LexObjectProperty::Unknown(LexUnknown {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("imageType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Type of the image source."),
                                    ),
                                    max_length: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("message"),
                                LexObjectProperty::String(LexString {
                                    max_length: Some(6400usize),
                                    max_graphemes: Some(640usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("model"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Identifier for the sticker model. 'default' for avatar stickers, 'cid:<cid>' for custom stickers.",
                                        ),
                                    ),
                                    max_length: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    max_length: Some(640usize),
                                    max_graphemes: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("obtainedAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The timestamp when this sticker was obtained.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("obtainedFrom"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The DID of the user from whom this sticker was obtained (for provenance).",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Did),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("originalOwner"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The DID of the original creator/minter of this sticker.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Did),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("shape"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("The shape of the sticker canvas."),
                                    ),
                                    max_length: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("signature"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Cryptographic signature from the server verifying the sticker's authenticity/provenance.",
                                        ),
                                    ),
                                    max_length: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("signedPayload"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The original JSON payload that was signed by the server.",
                                        ),
                                    ),
                                    max_length: Some(10000usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("subjectDid"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "The DID of the user depicted in the sticker, if applicable (e.g. for avatar stickers).",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Did),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("tags"),
                                LexObjectProperty::Array(LexArray {
                                    items: LexArrayItem::String(LexString {
                                        max_length: Some(640usize),
                                        max_graphemes: Some(64usize),
                                        ..Default::default()
                                    }),
                                    max_length: Some(8usize),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}