// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: garden.lexicon.exultant-zebra.tile
//
// 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::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Nsid, Cid};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_bsky::richtext::facet::Facet;
use crate::garden_lexicon::exultant_zebra::masl::Masl;
use crate::garden_lexicon::exultant_zebra::masl::Resource;
use crate::garden_lexicon::exultant_zebra::tile;
/// Declares the AT Protocol interactions a tile performs. Methods listed here gate which XRPC calls the tile is allowed to attempt (the user must still grant per-method consent). Collections and services are informational metadata for display and auditing.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Interactions<'a> {
    ///Repository collection NSIDs this tile reads from or writes to.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub collections: Option<Vec<Nsid<'a>>>,
    ///XRPC method NSIDs this tile may call. When present, the tile runtime restricts XRPC calls to only these methods. When absent, all server-allowed methods may be called (with user consent).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub methods: Option<Vec<CowStr<'a>>>,
    ///AT Protocol service proxy targets this tile interacts with, identified by DID and service endpoint fragment.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub services: Option<Vec<CowStr<'a>>>,
}

/// A tile with a name and associated resource or bundle.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Tile<'a> {
    ///Declared aspect ratio for tile rendering.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub aspect_ratio: Option<TileAspectRatio<'a>>,
    ///The tile content, either a single resource or a bundle.
    #[serde(borrow)]
    pub content: TileContent<'a>,
    ///Optional rich text description of the tile.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub description: Option<CowStr<'a>>,
    ///Rich text facets for the description (links, mentions, hashtags).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub facets: Option<Vec<Facet<'a>>>,
    ///Optional icon image for the tile.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub icon: Option<BlobRef<'a>>,
    ///Declaration of the XRPC methods, collections, and services this tile interacts with.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub interactions: Option<tile::Interactions<'a>>,
    ///Optional loading screen image for the tile.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub loading_image: Option<BlobRef<'a>>,
    ///The name of the tile.
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Input parameters this tile accepts. When present, the tile runtime shows a configuration form for required parameters without defaults before loading the tile.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub params: Option<Vec<tile::Param<'a>>>,
}

/// Declared aspect ratio for tile rendering.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TileAspectRatio<'a> {
    _11,
    _21,
    _31,
    _12,
    _13,
    Other(CowStr<'a>),
}

impl<'a> TileAspectRatio<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::_11 => "1:1",
            Self::_21 => "2:1",
            Self::_31 => "3:1",
            Self::_12 => "1:2",
            Self::_13 => "1:3",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for TileAspectRatio<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "1:1" => Self::_11,
            "2:1" => Self::_21,
            "3:1" => Self::_31,
            "1:2" => Self::_12,
            "1:3" => Self::_13,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for TileAspectRatio<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "1:1" => Self::_11,
            "2:1" => Self::_21,
            "3:1" => Self::_31,
            "1:2" => Self::_12,
            "1:3" => Self::_13,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

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

impl jacquard_common::IntoStatic for TileAspectRatio<'_> {
    type Output = TileAspectRatio<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            TileAspectRatio::_11 => TileAspectRatio::_11,
            TileAspectRatio::_21 => TileAspectRatio::_21,
            TileAspectRatio::_31 => TileAspectRatio::_31,
            TileAspectRatio::_12 => TileAspectRatio::_12,
            TileAspectRatio::_13 => TileAspectRatio::_13,
            TileAspectRatio::Other(v) => TileAspectRatio::Other(v.into_static()),
        }
    }
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum TileContent<'a> {
    #[serde(rename = "garden.lexicon.exultant-zebra.masl#resource")]
    MaslResource(Box<Resource<'a>>),
    #[serde(rename = "garden.lexicon.exultant-zebra.masl#main")]
    Masl(Box<Masl<'a>>),
}

/// 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 TileGetRecordOutput<'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: Tile<'a>,
}

/// Declares an input parameter for a tile, similar to XRPC query parameters.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Param<'a> {
    ///Default value for this parameter, encoded as a string.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub default: Option<CowStr<'a>>,
    ///Human-readable description of this parameter.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub description: Option<CowStr<'a>>,
    ///Parameter name, used as a URL search param key. Must not start with an underscore.
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Whether this parameter must be provided before loading the tile.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub required: Option<bool>,
    ///Parameter value type.
    #[serde(borrow)]
    pub r#type: ParamType<'a>,
}

/// Parameter value type.

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum ParamType<'a> {
    String,
    Integer,
    Boolean,
    Other(CowStr<'a>),
}

impl<'a> ParamType<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::String => "string",
            Self::Integer => "integer",
            Self::Boolean => "boolean",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for ParamType<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "string" => Self::String,
            "integer" => Self::Integer,
            "boolean" => Self::Boolean,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for ParamType<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "string" => Self::String,
            "integer" => Self::Integer,
            "boolean" => Self::Boolean,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

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

impl jacquard_common::IntoStatic for ParamType<'_> {
    type Output = ParamType<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            ParamType::String => ParamType::String,
            ParamType::Integer => ParamType::Integer,
            ParamType::Boolean => ParamType::Boolean,
            ParamType::Other(v) => ParamType::Other(v.into_static()),
        }
    }
}

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

impl<'a> LexiconSchema for Interactions<'a> {
    fn nsid() -> &'static str {
        "garden.lexicon.exultant-zebra.tile"
    }
    fn def_name() -> &'static str {
        "interactions"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_garden_lexicon_exultant_zebra_tile()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

#[derive(Debug, Serialize, Deserialize)]
pub struct TileRecord;
impl XrpcResp for TileRecord {
    const NSID: &'static str = "garden.lexicon.exultant-zebra.tile";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = TileGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

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

impl Collection for Tile<'_> {
    const NSID: &'static str = "garden.lexicon.exultant-zebra.tile";
    type Record = TileRecord;
}

impl Collection for TileRecord {
    const NSID: &'static str = "garden.lexicon.exultant-zebra.tile";
    type Record = TileRecord;
}

impl<'a> LexiconSchema for Tile<'a> {
    fn nsid() -> &'static str {
        "garden.lexicon.exultant-zebra.tile"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_garden_lexicon_exultant_zebra_tile()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.description {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 3000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("description"),
                    max: 3000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.icon {
            {
                let size = value.blob().size;
                if size > 1048576usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("icon"),
                        max: 1048576usize,
                        actual: size,
                    });
                }
            }
        }
        if let Some(ref value) = self.icon {
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/png", "image/jpeg"];
                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("icon"),
                        accepted: vec![
                            "image/png".to_string(), "image/jpeg".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        if let Some(ref value) = self.loading_image {
            {
                let size = value.blob().size;
                if size > 1048576usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("loading_image"),
                        max: 1048576usize,
                        actual: size,
                    });
                }
            }
        }
        if let Some(ref value) = self.loading_image {
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/png", "image/jpeg"];
                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("loading_image"),
                        accepted: vec![
                            "image/png".to_string(), "image/jpeg".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Param<'a> {
    fn nsid() -> &'static str {
        "garden.lexicon.exultant-zebra.tile"
    }
    fn def_name() -> &'static str {
        "param"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_garden_lexicon_exultant_zebra_tile()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.description {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 1000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("description"),
                    max: 1000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

fn lexicon_doc_garden_lexicon_exultant_zebra_tile() -> 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("garden.lexicon.exultant-zebra.tile"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("interactions"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Declares the AT Protocol interactions a tile performs. Methods listed here gate which XRPC calls the tile is allowed to attempt (the user must still grant per-method consent). Collections and services are informational metadata for display and auditing.",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("collections"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Repository collection NSIDs this tile reads from or writes to.",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Nsid),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("methods"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "XRPC method NSIDs this tile may call. When present, the tile runtime restricts XRPC calls to only these methods. When absent, all server-allowed methods may be called (with user consent).",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("services"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "AT Protocol service proxy targets this tile interacts with, identified by DID and service endpoint fragment.",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "A tile with a name and associated resource or bundle.",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("name"), SmolStr::new_static("content")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("aspectRatio"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Declared aspect ratio for tile rendering.",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("content"),
                                LexObjectProperty::Union(LexRefUnion {
                                    description: Some(
                                        CowStr::new_static(
                                            "The tile content, either a single resource or a bundle.",
                                        ),
                                    ),
                                    refs: vec![
                                        CowStr::new_static("garden.lexicon.exultant-zebra.masl#resource"),
                                        CowStr::new_static("garden.lexicon.exultant-zebra.masl#main")
                                    ],
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("description"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Optional rich text description of the tile.",
                                        ),
                                    ),
                                    max_length: Some(3000usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("facets"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Rich text facets for the description (links, mentions, hashtags).",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("app.bsky.richtext.facet"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("icon"),
                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("interactions"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#interactions"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("loadingImage"),
                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("The name of the tile."),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("params"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Input parameters this tile accepts. When present, the tile runtime shows a configuration form for required parameters without defaults before loading the tile.",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("#param"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("param"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Declares an input parameter for a tile, similar to XRPC query parameters.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("name"), SmolStr::new_static("type")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("default"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Default value for this parameter, encoded as a string.",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("description"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Human-readable description of this parameter.",
                                    ),
                                ),
                                max_length: Some(1000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Parameter name, used as a URL search param key. Must not start with an underscore.",
                                    ),
                                ),
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("required"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Parameter value type."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

/// Builder for constructing an instance of this type
pub struct TileBuilder<'a, S: tile_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<TileAspectRatio<'a>>,
        Option<TileContent<'a>>,
        Option<CowStr<'a>>,
        Option<Vec<Facet<'a>>>,
        Option<BlobRef<'a>>,
        Option<tile::Interactions<'a>>,
        Option<BlobRef<'a>>,
        Option<CowStr<'a>>,
        Option<Vec<tile::Param<'a>>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Tile<'a> {
    /// Create a new builder for this type
    pub fn new() -> TileBuilder<'a, tile_state::Empty> {
        TileBuilder::new()
    }
}

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

impl<'a, S: tile_state::State> TileBuilder<'a, S> {
    /// Set the `aspectRatio` field (optional)
    pub fn aspect_ratio(
        mut self,
        value: impl Into<Option<TileAspectRatio<'a>>>,
    ) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `aspectRatio` field to an Option value (optional)
    pub fn maybe_aspect_ratio(mut self, value: Option<TileAspectRatio<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> TileBuilder<'a, S>
where
    S: tile_state::State,
    S::Content: tile_state::IsUnset,
{
    /// Set the `content` field (required)
    pub fn content(
        mut self,
        value: impl Into<TileContent<'a>>,
    ) -> TileBuilder<'a, tile_state::SetContent<S>> {
        self._fields.1 = Option::Some(value.into());
        TileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

impl<'a, S: tile_state::State> TileBuilder<'a, S> {
    /// Set the `facets` field (optional)
    pub fn facets(mut self, value: impl Into<Option<Vec<Facet<'a>>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `facets` field to an Option value (optional)
    pub fn maybe_facets(mut self, value: Option<Vec<Facet<'a>>>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: tile_state::State> TileBuilder<'a, S> {
    /// Set the `icon` field (optional)
    pub fn icon(mut self, value: impl Into<Option<BlobRef<'a>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `icon` field to an Option value (optional)
    pub fn maybe_icon(mut self, value: Option<BlobRef<'a>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: tile_state::State> TileBuilder<'a, S> {
    /// Set the `interactions` field (optional)
    pub fn interactions(
        mut self,
        value: impl Into<Option<tile::Interactions<'a>>>,
    ) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `interactions` field to an Option value (optional)
    pub fn maybe_interactions(mut self, value: Option<tile::Interactions<'a>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: tile_state::State> TileBuilder<'a, S> {
    /// Set the `loadingImage` field (optional)
    pub fn loading_image(mut self, value: impl Into<Option<BlobRef<'a>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `loadingImage` field to an Option value (optional)
    pub fn maybe_loading_image(mut self, value: Option<BlobRef<'a>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S> TileBuilder<'a, S>
where
    S: tile_state::State,
    S::Name: tile_state::IsUnset,
{
    /// Set the `name` field (required)
    pub fn name(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> TileBuilder<'a, tile_state::SetName<S>> {
        self._fields.7 = Option::Some(value.into());
        TileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: tile_state::State> TileBuilder<'a, S> {
    /// Set the `params` field (optional)
    pub fn params(mut self, value: impl Into<Option<Vec<tile::Param<'a>>>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `params` field to an Option value (optional)
    pub fn maybe_params(mut self, value: Option<Vec<tile::Param<'a>>>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<'a, S> TileBuilder<'a, S>
where
    S: tile_state::State,
    S::Name: tile_state::IsSet,
    S::Content: tile_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Tile<'a> {
        Tile {
            aspect_ratio: self._fields.0,
            content: self._fields.1.unwrap(),
            description: self._fields.2,
            facets: self._fields.3,
            icon: self._fields.4,
            interactions: self._fields.5,
            loading_image: self._fields.6,
            name: self._fields.7.unwrap(),
            params: self._fields.8,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Tile<'a> {
        Tile {
            aspect_ratio: self._fields.0,
            content: self._fields.1.unwrap(),
            description: self._fields.2,
            facets: self._fields.3,
            icon: self._fields.4,
            interactions: self._fields.5,
            loading_image: self._fields.6,
            name: self._fields.7.unwrap(),
            params: self._fields.8,
            extra_data: Some(extra_data),
        }
    }
}