// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: net.anisota.beta.game.inventory
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

#[allow(unused_imports)]
use alloc::collections::BTreeMap;

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::CowStr;

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, 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};
use crate::net_anisota::beta::game::inventory;
/// Beta version: Record representing an item in a player's game inventory

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Inventory<'a> {
    ///When the item was acquired
    pub acquired_at: Datetime,
    ///When the record was created
    pub created_at: Datetime,
    ///Unique identifier for the item from gameItems.json
    #[serde(borrow)]
    pub item_id: CowStr<'a>,
    ///Display name of the item
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub item_name: Option<CowStr<'a>>,
    ///Type category of the item (consumable, tool, equipment, etc.)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub item_type: Option<CowStr<'a>>,
    ///Base value of the item in game currency
    #[serde(skip_serializing_if = "Option::is_none")]
    pub item_value: Option<i64>,
    ///When the record was last modified
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_modified: Option<Datetime>,
    ///URI of the game.log record that documents the acquisition of this item
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub log_record_uri: Option<CowStr<'a>>,
    ///Maximum stack size for this item
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max_stack: Option<i64>,
    ///Additional item-specific data (stats, attributes, enchantments, etc.)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub metadata: Option<Data<'a>>,
    ///Number of items in the stack
    pub quantity: i64,
    ///Rarity level of the item
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub rarity: Option<CowStr<'a>>,
    ///How the item was acquired
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub source: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub source_details: Option<inventory::SourceDetails<'a>>,
    ///Whether this item can be stacked with others of the same type
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stackable: Option<bool>,
}

/// 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 InventoryGetRecordOutput<'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: Inventory<'a>,
}

/// Additional details about how the item was acquired

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct SourceDetails<'a> {
    ///URI of the game card that provided this item
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub game_card_uri: Option<CowStr<'a>>,
    ///ID of the quest that rewarded this item
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub quest_id: Option<CowStr<'a>>,
    ///Daily reward streak when item was acquired
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reward_streak: Option<i64>,
}

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct InventoryRecord;
impl XrpcResp for InventoryRecord {
    const NSID: &'static str = "net.anisota.beta.game.inventory";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = InventoryGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

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

impl Collection for Inventory<'_> {
    const NSID: &'static str = "net.anisota.beta.game.inventory";
    type Record = InventoryRecord;
}

impl Collection for InventoryRecord {
    const NSID: &'static str = "net.anisota.beta.game.inventory";
    type Record = InventoryRecord;
}

impl<'a> LexiconSchema for Inventory<'a> {
    fn nsid() -> &'static str {
        "net.anisota.beta.game.inventory"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_beta_game_inventory()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.item_id;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("item_id"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.item_name {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("item_name"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.item_type {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 50usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("item_type"),
                    max: 50usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.item_value {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("item_value"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.max_stack {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("max_stack"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.quantity;
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("quantity"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for SourceDetails<'a> {
    fn nsid() -> &'static str {
        "net.anisota.beta.game.inventory"
    }
    fn def_name() -> &'static str {
        "sourceDetails"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_beta_game_inventory()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod inventory_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 AcquiredAt;
        type CreatedAt;
        type ItemId;
        type Quantity;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type AcquiredAt = Unset;
        type CreatedAt = Unset;
        type ItemId = Unset;
        type Quantity = Unset;
    }
    ///State transition - sets the `acquired_at` field to Set
    pub struct SetAcquiredAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetAcquiredAt<S> {}
    impl<S: State> State for SetAcquiredAt<S> {
        type AcquiredAt = Set<members::acquired_at>;
        type CreatedAt = S::CreatedAt;
        type ItemId = S::ItemId;
        type Quantity = S::Quantity;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetCreatedAt<S> {}
    impl<S: State> State for SetCreatedAt<S> {
        type AcquiredAt = S::AcquiredAt;
        type CreatedAt = Set<members::created_at>;
        type ItemId = S::ItemId;
        type Quantity = S::Quantity;
    }
    ///State transition - sets the `item_id` field to Set
    pub struct SetItemId<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetItemId<S> {}
    impl<S: State> State for SetItemId<S> {
        type AcquiredAt = S::AcquiredAt;
        type CreatedAt = S::CreatedAt;
        type ItemId = Set<members::item_id>;
        type Quantity = S::Quantity;
    }
    ///State transition - sets the `quantity` field to Set
    pub struct SetQuantity<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetQuantity<S> {}
    impl<S: State> State for SetQuantity<S> {
        type AcquiredAt = S::AcquiredAt;
        type CreatedAt = S::CreatedAt;
        type ItemId = S::ItemId;
        type Quantity = Set<members::quantity>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `acquired_at` field
        pub struct acquired_at(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `item_id` field
        pub struct item_id(());
        ///Marker type for the `quantity` field
        pub struct quantity(());
    }
}

/// Builder for constructing an instance of this type
pub struct InventoryBuilder<'a, S: inventory_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Datetime>,
        Option<Datetime>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<i64>,
        Option<Datetime>,
        Option<CowStr<'a>>,
        Option<i64>,
        Option<Data<'a>>,
        Option<i64>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<inventory::SourceDetails<'a>>,
        Option<bool>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Inventory<'a> {
    /// Create a new builder for this type
    pub fn new() -> InventoryBuilder<'a, inventory_state::Empty> {
        InventoryBuilder::new()
    }
}

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

impl<'a, S> InventoryBuilder<'a, S>
where
    S: inventory_state::State,
    S::AcquiredAt: inventory_state::IsUnset,
{
    /// Set the `acquiredAt` field (required)
    pub fn acquired_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> InventoryBuilder<'a, inventory_state::SetAcquiredAt<S>> {
        self._fields.0 = Option::Some(value.into());
        InventoryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> InventoryBuilder<'a, S>
where
    S: inventory_state::State,
    S::CreatedAt: inventory_state::IsUnset,
{
    /// Set the `createdAt` field (required)
    pub fn created_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> InventoryBuilder<'a, inventory_state::SetCreatedAt<S>> {
        self._fields.1 = Option::Some(value.into());
        InventoryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> InventoryBuilder<'a, S>
where
    S: inventory_state::State,
    S::ItemId: inventory_state::IsUnset,
{
    /// Set the `itemId` field (required)
    pub fn item_id(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> InventoryBuilder<'a, inventory_state::SetItemId<S>> {
        self._fields.2 = Option::Some(value.into());
        InventoryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: inventory_state::State> InventoryBuilder<'a, S> {
    /// Set the `itemName` field (optional)
    pub fn item_name(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `itemName` field to an Option value (optional)
    pub fn maybe_item_name(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.3 = value;
        self
    }
}

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

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

impl<'a, S: inventory_state::State> InventoryBuilder<'a, S> {
    /// Set the `lastModified` field (optional)
    pub fn last_modified(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `lastModified` field to an Option value (optional)
    pub fn maybe_last_modified(mut self, value: Option<Datetime>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S: inventory_state::State> InventoryBuilder<'a, S> {
    /// Set the `logRecordUri` field (optional)
    pub fn log_record_uri(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `logRecordUri` field to an Option value (optional)
    pub fn maybe_log_record_uri(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S: inventory_state::State> InventoryBuilder<'a, S> {
    /// Set the `maxStack` field (optional)
    pub fn max_stack(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `maxStack` field to an Option value (optional)
    pub fn maybe_max_stack(mut self, value: Option<i64>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<'a, S: inventory_state::State> InventoryBuilder<'a, S> {
    /// Set the `metadata` field (optional)
    pub fn metadata(mut self, value: impl Into<Option<Data<'a>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `metadata` field to an Option value (optional)
    pub fn maybe_metadata(mut self, value: Option<Data<'a>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<'a, S> InventoryBuilder<'a, S>
where
    S: inventory_state::State,
    S::Quantity: inventory_state::IsUnset,
{
    /// Set the `quantity` field (required)
    pub fn quantity(
        mut self,
        value: impl Into<i64>,
    ) -> InventoryBuilder<'a, inventory_state::SetQuantity<S>> {
        self._fields.10 = Option::Some(value.into());
        InventoryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: inventory_state::State> InventoryBuilder<'a, S> {
    /// Set the `rarity` field (optional)
    pub fn rarity(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `rarity` field to an Option value (optional)
    pub fn maybe_rarity(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<'a, S: inventory_state::State> InventoryBuilder<'a, S> {
    /// Set the `source` field (optional)
    pub fn source(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `source` field to an Option value (optional)
    pub fn maybe_source(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<'a, S: inventory_state::State> InventoryBuilder<'a, S> {
    /// Set the `sourceDetails` field (optional)
    pub fn source_details(
        mut self,
        value: impl Into<Option<inventory::SourceDetails<'a>>>,
    ) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `sourceDetails` field to an Option value (optional)
    pub fn maybe_source_details(
        mut self,
        value: Option<inventory::SourceDetails<'a>>,
    ) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<'a, S: inventory_state::State> InventoryBuilder<'a, S> {
    /// Set the `stackable` field (optional)
    pub fn stackable(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `stackable` field to an Option value (optional)
    pub fn maybe_stackable(mut self, value: Option<bool>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<'a, S> InventoryBuilder<'a, S>
where
    S: inventory_state::State,
    S::AcquiredAt: inventory_state::IsSet,
    S::CreatedAt: inventory_state::IsSet,
    S::ItemId: inventory_state::IsSet,
    S::Quantity: inventory_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Inventory<'a> {
        Inventory {
            acquired_at: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            item_id: self._fields.2.unwrap(),
            item_name: self._fields.3,
            item_type: self._fields.4,
            item_value: self._fields.5,
            last_modified: self._fields.6,
            log_record_uri: self._fields.7,
            max_stack: self._fields.8,
            metadata: self._fields.9,
            quantity: self._fields.10.unwrap(),
            rarity: self._fields.11,
            source: self._fields.12,
            source_details: self._fields.13,
            stackable: self._fields.14,
            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>>,
    ) -> Inventory<'a> {
        Inventory {
            acquired_at: self._fields.0.unwrap(),
            created_at: self._fields.1.unwrap(),
            item_id: self._fields.2.unwrap(),
            item_name: self._fields.3,
            item_type: self._fields.4,
            item_value: self._fields.5,
            last_modified: self._fields.6,
            log_record_uri: self._fields.7,
            max_stack: self._fields.8,
            metadata: self._fields.9,
            quantity: self._fields.10.unwrap(),
            rarity: self._fields.11,
            source: self._fields.12,
            source_details: self._fields.13,
            stackable: self._fields.14,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_net_anisota_beta_game_inventory() -> 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("net.anisota.beta.game.inventory"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "Beta version: Record representing an item in a player's game inventory",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("itemId"),
                                SmolStr::new_static("quantity"),
                                SmolStr::new_static("acquiredAt"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("acquiredAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the item was acquired"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the record was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("itemId"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Unique identifier for the item from gameItems.json",
                                        ),
                                    ),
                                    max_length: Some(100usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("itemName"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Display name of the item"),
                                    ),
                                    max_length: Some(200usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("itemType"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Type category of the item (consumable, tool, equipment, etc.)",
                                        ),
                                    ),
                                    max_length: Some(50usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("itemValue"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lastModified"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the record was last modified"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("logRecordUri"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "URI of the game.log record that documents the acquisition of this item",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("maxStack"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("metadata"),
                                LexObjectProperty::Unknown(LexUnknown {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("quantity"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("rarity"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Rarity level of the item"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("source"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("How the item was acquired"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sourceDetails"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#sourceDetails"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("stackable"),
                                LexObjectProperty::Boolean(LexBoolean {
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("sourceDetails"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Additional details about how the item was acquired",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("gameCardUri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "URI of the game card that provided this item",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("questId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "ID of the quest that rewarded this item",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rewardStreak"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}