// @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;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Sticker<'a> {
    ///The image content, either a string URL (for CDN/Blob) or a BlobRef.
    #[serde(borrow)]
    pub image: Data<'a>,
    ///Type of the image source.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub image_type: Option<StickerImageType<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub message: Option<CowStr<'a>>,
    ///Identifier for the sticker model. 'default' for avatar stickers, 'cid:<cid>' for custom stickers.
    #[serde(borrow)]
    pub model: CowStr<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub name: Option<CowStr<'a>>,
    ///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")]
    #[serde(borrow)]
    pub obtained_from: Option<Did<'a>>,
    ///The DID of the original creator/minter of this sticker.
    #[serde(borrow)]
    pub original_owner: Did<'a>,
    ///The shape of the sticker canvas.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub shape: Option<StickerShape<'a>>,
    ///Cryptographic signature from the server verifying the sticker's authenticity/provenance.
    #[serde(borrow)]
    pub signature: CowStr<'a>,
    ///The original JSON payload that was signed by the server.
    #[serde(borrow)]
    pub signed_payload: CowStr<'a>,
    ///The DID of the user depicted in the sticker, if applicable (e.g. for avatar stickers).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub subject_did: Option<Did<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub tags: Option<Vec<CowStr<'a>>>,
}

/// Type of the image source.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum StickerImageType<'a> {
    Avatar,
    Custom,
    Other(CowStr<'a>),
}

impl<'a> StickerImageType<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Avatar => "avatar",
            Self::Custom => "custom",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for StickerImageType<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "avatar" => Self::Avatar,
            "custom" => Self::Custom,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for StickerImageType<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "avatar" => Self::Avatar,
            "custom" => Self::Custom,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

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

impl jacquard_common::IntoStatic for StickerImageType<'_> {
    type Output = StickerImageType<'static>;
    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<'a> {
    Circle,
    Square,
    Rectangle,
    Star,
    Heart,
    Diamond,
    Butterfly,
    Transparent,
    Other(CowStr<'a>),
}

impl<'a> StickerShape<'a> {
    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(),
        }
    }
}

impl<'a> From<&'a str> for StickerShape<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "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(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for StickerShape<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "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(CowStr::from(s)),
        }
    }
}

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

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

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

impl jacquard_common::IntoStatic for StickerShape<'_> {
    type Output = StickerShape<'static>;
    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<'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: Sticker<'a>,
}

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

/// 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<'de> = StickerGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

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

impl Collection for Sticker<'_> {
    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<'a> LexiconSchema for Sticker<'a> {
    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 SignedPayload;
        type ObtainedAt;
        type Model;
        type OriginalOwner;
        type Signature;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Image = Unset;
        type SignedPayload = Unset;
        type ObtainedAt = Unset;
        type Model = Unset;
        type OriginalOwner = Unset;
        type Signature = Unset;
    }
    ///State transition - sets the `image` field to Set
    pub struct SetImage<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetImage<S> {}
    impl<S: State> State for SetImage<S> {
        type Image = Set<members::image>;
        type SignedPayload = S::SignedPayload;
        type ObtainedAt = S::ObtainedAt;
        type Model = S::Model;
        type OriginalOwner = S::OriginalOwner;
        type Signature = S::Signature;
    }
    ///State transition - sets the `signed_payload` field to Set
    pub struct SetSignedPayload<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSignedPayload<S> {}
    impl<S: State> State for SetSignedPayload<S> {
        type Image = S::Image;
        type SignedPayload = Set<members::signed_payload>;
        type ObtainedAt = S::ObtainedAt;
        type Model = S::Model;
        type OriginalOwner = S::OriginalOwner;
        type Signature = S::Signature;
    }
    ///State transition - sets the `obtained_at` field to Set
    pub struct SetObtainedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetObtainedAt<S> {}
    impl<S: State> State for SetObtainedAt<S> {
        type Image = S::Image;
        type SignedPayload = S::SignedPayload;
        type ObtainedAt = Set<members::obtained_at>;
        type Model = S::Model;
        type OriginalOwner = S::OriginalOwner;
        type Signature = S::Signature;
    }
    ///State transition - sets the `model` field to Set
    pub struct SetModel<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetModel<S> {}
    impl<S: State> State for SetModel<S> {
        type Image = S::Image;
        type SignedPayload = S::SignedPayload;
        type ObtainedAt = S::ObtainedAt;
        type Model = Set<members::model>;
        type OriginalOwner = S::OriginalOwner;
        type Signature = S::Signature;
    }
    ///State transition - sets the `original_owner` field to Set
    pub struct SetOriginalOwner<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetOriginalOwner<S> {}
    impl<S: State> State for SetOriginalOwner<S> {
        type Image = S::Image;
        type SignedPayload = S::SignedPayload;
        type ObtainedAt = S::ObtainedAt;
        type Model = S::Model;
        type OriginalOwner = Set<members::original_owner>;
        type Signature = S::Signature;
    }
    ///State transition - sets the `signature` field to Set
    pub struct SetSignature<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSignature<S> {}
    impl<S: State> State for SetSignature<S> {
        type Image = S::Image;
        type SignedPayload = S::SignedPayload;
        type ObtainedAt = S::ObtainedAt;
        type Model = S::Model;
        type OriginalOwner = S::OriginalOwner;
        type Signature = Set<members::signature>;
    }
    /// 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 `signed_payload` field
        pub struct signed_payload(());
        ///Marker type for the `obtained_at` field
        pub struct obtained_at(());
        ///Marker type for the `model` field
        pub struct model(());
        ///Marker type for the `original_owner` field
        pub struct original_owner(());
        ///Marker type for the `signature` field
        pub struct signature(());
    }
}

/// Builder for constructing an instance of this type
pub struct StickerBuilder<'a, S: sticker_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Data<'a>>,
        Option<StickerImageType<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<Datetime>,
        Option<Did<'a>>,
        Option<Did<'a>>,
        Option<StickerShape<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<Did<'a>>,
        Option<Vec<CowStr<'a>>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

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

impl<'a, S: sticker_state::State> StickerBuilder<'a, S> {
    /// Set the `imageType` field (optional)
    pub fn image_type(mut self, value: impl Into<Option<StickerImageType<'a>>>) -> 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<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

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

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

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

impl<'a, S: sticker_state::State> StickerBuilder<'a, S> {
    /// Set the `obtainedFrom` field (optional)
    pub fn obtained_from(mut self, value: impl Into<Option<Did<'a>>>) -> 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<'a>>) -> Self {
        self._fields.6 = value;
        self
    }
}

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

impl<'a, S: sticker_state::State> StickerBuilder<'a, S> {
    /// Set the `shape` field (optional)
    pub fn shape(mut self, value: impl Into<Option<StickerShape<'a>>>) -> 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<'a>>) -> Self {
        self._fields.8 = value;
        self
    }
}

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

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

impl<'a, S: sticker_state::State> StickerBuilder<'a, S> {
    /// Set the `subjectDid` field (optional)
    pub fn subject_did(mut self, value: impl Into<Option<Did<'a>>>) -> 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<'a>>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<'a, S: sticker_state::State> StickerBuilder<'a, S> {
    /// Set the `tags` field (optional)
    pub fn tags(mut self, value: impl Into<Option<Vec<CowStr<'a>>>>) -> 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<CowStr<'a>>>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<'a, S> StickerBuilder<'a, S>
where
    S: sticker_state::State,
    S::Image: sticker_state::IsSet,
    S::SignedPayload: sticker_state::IsSet,
    S::ObtainedAt: sticker_state::IsSet,
    S::Model: sticker_state::IsSet,
    S::OriginalOwner: sticker_state::IsSet,
    S::Signature: sticker_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Sticker<'a> {
        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<jacquard_common::deps::smol_str::SmolStr, Data<'a>>,
    ) -> Sticker<'a> {
        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()
    }
}