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

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

#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{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::progress;
/// Record representing a player's level progression and game statistics

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "net.anisota.beta.game.progress",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Progress<S: BosStr = DefaultStr> {
    ///URI of the card that was advanced when triggerSource is card_advance
    #[serde(skip_serializing_if = "Option::is_none")]
    pub card_uri: Option<S>,
    ///When the progress record was created
    pub created_at: Datetime,
    ///Current stamina level when this progress was recorded (decimal string, e.g. '85.5')
    #[serde(skip_serializing_if = "Option::is_none")]
    pub current_stamina: Option<S>,
    ///Current player level
    pub level: i64,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub metadata: Option<progress::Metadata<S>>,
    ///Previous level before this update (for tracking level progression)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub previous_level: Option<i64>,
    ///Progress percentage to the next level (decimal string, e.g. '75.5')
    pub progress_percentage: S,
    ///URIs of related game log records that contributed to this progress
    #[serde(skip_serializing_if = "Option::is_none")]
    pub related_log_uris: Option<Vec<S>>,
    ///Session ID when this progress was recorded (for linking with log records)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub session_id: Option<S>,
    ///URI of the session record when this progress was recorded
    #[serde(skip_serializing_if = "Option::is_none")]
    pub session_uri: Option<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stats: Option<progress::Stats<S>>,
    ///Total experience points accumulated
    pub total_xp: i64,
    ///What action triggered this progress save
    #[serde(skip_serializing_if = "Option::is_none")]
    pub trigger_source: Option<S>,
    ///Experience points gained since the last progress save
    #[serde(skip_serializing_if = "Option::is_none")]
    pub xp_gained_since_last_save: Option<i64>,
    ///Experience points needed to reach the next level
    pub xp_to_next_level: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Typed wrapper for GetRecord response with this collection's record type.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ProgressGetRecordOutput<S: BosStr = DefaultStr> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<Cid<S>>,
    pub uri: AtUri<S>,
    pub value: Progress<S>,
}

/// Additional metadata about this progress update

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Metadata<S: BosStr = DefaultStr> {
    ///Version of the client when this progress was recorded
    #[serde(skip_serializing_if = "Option::is_none")]
    pub client_version: Option<S>,
    ///Platform where the level up occurred (web, mobile, etc.)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub platform: Option<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Game-specific statistics and metrics

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Stats<S: BosStr = DefaultStr> {
    ///Total daily rewards claimed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub daily_rewards_claimed: Option<i64>,
    ///Total items collected
    #[serde(skip_serializing_if = "Option::is_none")]
    pub items_collected: Option<i64>,
    ///Date when posts read today was last updated (for daily reset tracking)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_post_read_date: Option<Datetime>,
    ///Posts read today (resets daily)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub posts_read_today: Option<i64>,
    ///Total posts read (all time, cumulative)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub posts_read_total: Option<i64>,
    ///Total posts viewed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub posts_viewed: Option<i64>,
    ///Total shuffles performed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub shuffles_performed: Option<i64>,
    ///Total specimens collected
    #[serde(skip_serializing_if = "Option::is_none")]
    pub specimens_collected: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

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

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

impl<S: BosStr> Collection for Progress<S> {
    const NSID: &'static str = "net.anisota.beta.game.progress";
    type Record = ProgressRecord;
}

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

impl<S: BosStr> LexiconSchema for Progress<S> {
    fn nsid() -> &'static str {
        "net.anisota.beta.game.progress"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_beta_game_progress()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.level;
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("level"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.previous_level {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("previous_level"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.total_xp;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("total_xp"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.xp_gained_since_last_save {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("xp_gained_since_last_save"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.xp_to_next_level;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("xp_to_next_level"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Metadata<S> {
    fn nsid() -> &'static str {
        "net.anisota.beta.game.progress"
    }
    fn def_name() -> &'static str {
        "metadata"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_beta_game_progress()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for Stats<S> {
    fn nsid() -> &'static str {
        "net.anisota.beta.game.progress"
    }
    fn def_name() -> &'static str {
        "stats"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_net_anisota_beta_game_progress()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.daily_rewards_claimed {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("daily_rewards_claimed"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.items_collected {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("items_collected"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.posts_read_today {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("posts_read_today"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.posts_read_total {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("posts_read_total"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.posts_viewed {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("posts_viewed"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.shuffles_performed {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("shuffles_performed"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.specimens_collected {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("specimens_collected"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

pub mod progress_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type CreatedAt;
        type Level;
        type ProgressPercentage;
        type TotalXp;
        type XpToNextLevel;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Level = Unset;
        type ProgressPercentage = Unset;
        type TotalXp = Unset;
        type XpToNextLevel = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type Level = St::Level;
        type ProgressPercentage = St::ProgressPercentage;
        type TotalXp = St::TotalXp;
        type XpToNextLevel = St::XpToNextLevel;
    }
    ///State transition - sets the `level` field to Set
    pub struct SetLevel<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLevel<St> {}
    impl<St: State> State for SetLevel<St> {
        type CreatedAt = St::CreatedAt;
        type Level = Set<members::level>;
        type ProgressPercentage = St::ProgressPercentage;
        type TotalXp = St::TotalXp;
        type XpToNextLevel = St::XpToNextLevel;
    }
    ///State transition - sets the `progress_percentage` field to Set
    pub struct SetProgressPercentage<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetProgressPercentage<St> {}
    impl<St: State> State for SetProgressPercentage<St> {
        type CreatedAt = St::CreatedAt;
        type Level = St::Level;
        type ProgressPercentage = Set<members::progress_percentage>;
        type TotalXp = St::TotalXp;
        type XpToNextLevel = St::XpToNextLevel;
    }
    ///State transition - sets the `total_xp` field to Set
    pub struct SetTotalXp<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTotalXp<St> {}
    impl<St: State> State for SetTotalXp<St> {
        type CreatedAt = St::CreatedAt;
        type Level = St::Level;
        type ProgressPercentage = St::ProgressPercentage;
        type TotalXp = Set<members::total_xp>;
        type XpToNextLevel = St::XpToNextLevel;
    }
    ///State transition - sets the `xp_to_next_level` field to Set
    pub struct SetXpToNextLevel<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetXpToNextLevel<St> {}
    impl<St: State> State for SetXpToNextLevel<St> {
        type CreatedAt = St::CreatedAt;
        type Level = St::Level;
        type ProgressPercentage = St::ProgressPercentage;
        type TotalXp = St::TotalXp;
        type XpToNextLevel = Set<members::xp_to_next_level>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `level` field
        pub struct level(());
        ///Marker type for the `progress_percentage` field
        pub struct progress_percentage(());
        ///Marker type for the `total_xp` field
        pub struct total_xp(());
        ///Marker type for the `xp_to_next_level` field
        pub struct xp_to_next_level(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ProgressBuilder<St: progress_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<Datetime>,
        Option<S>,
        Option<i64>,
        Option<progress::Metadata<S>>,
        Option<i64>,
        Option<S>,
        Option<Vec<S>>,
        Option<S>,
        Option<S>,
        Option<progress::Stats<S>>,
        Option<i64>,
        Option<S>,
        Option<i64>,
        Option<i64>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Progress<S> {
    /// Create a new builder for this type
    pub fn builder() -> ProgressBuilder<progress_state::Empty, S> {
        ProgressBuilder::builder()
    }
}

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

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

impl<St: progress_state::State, S: BosStr> ProgressBuilder<St, S> {
    /// Set the `cardUri` field (optional)
    pub fn card_uri(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `cardUri` field to an Option value (optional)
    pub fn maybe_card_uri(mut self, value: Option<S>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

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

impl<St, S: BosStr> ProgressBuilder<St, S>
where
    St: progress_state::State,
    St::Level: progress_state::IsUnset,
{
    /// Set the `level` field (required)
    pub fn level(
        mut self,
        value: impl Into<i64>,
    ) -> ProgressBuilder<progress_state::SetLevel<St>, S> {
        self._fields.3 = Option::Some(value.into());
        ProgressBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: progress_state::State, S: BosStr> ProgressBuilder<St, S> {
    /// Set the `metadata` field (optional)
    pub fn metadata(mut self, value: impl Into<Option<progress::Metadata<S>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `metadata` field to an Option value (optional)
    pub fn maybe_metadata(mut self, value: Option<progress::Metadata<S>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: progress_state::State, S: BosStr> ProgressBuilder<St, S> {
    /// Set the `previousLevel` field (optional)
    pub fn previous_level(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `previousLevel` field to an Option value (optional)
    pub fn maybe_previous_level(mut self, value: Option<i64>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St, S: BosStr> ProgressBuilder<St, S>
where
    St: progress_state::State,
    St::ProgressPercentage: progress_state::IsUnset,
{
    /// Set the `progressPercentage` field (required)
    pub fn progress_percentage(
        mut self,
        value: impl Into<S>,
    ) -> ProgressBuilder<progress_state::SetProgressPercentage<St>, S> {
        self._fields.6 = Option::Some(value.into());
        ProgressBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: progress_state::State, S: BosStr> ProgressBuilder<St, S> {
    /// Set the `relatedLogUris` field (optional)
    pub fn related_log_uris(mut self, value: impl Into<Option<Vec<S>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `relatedLogUris` field to an Option value (optional)
    pub fn maybe_related_log_uris(mut self, value: Option<Vec<S>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St: progress_state::State, S: BosStr> ProgressBuilder<St, S> {
    /// Set the `sessionId` field (optional)
    pub fn session_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `sessionId` field to an Option value (optional)
    pub fn maybe_session_id(mut self, value: Option<S>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St: progress_state::State, S: BosStr> ProgressBuilder<St, S> {
    /// Set the `sessionUri` field (optional)
    pub fn session_uri(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `sessionUri` field to an Option value (optional)
    pub fn maybe_session_uri(mut self, value: Option<S>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St: progress_state::State, S: BosStr> ProgressBuilder<St, S> {
    /// Set the `stats` field (optional)
    pub fn stats(mut self, value: impl Into<Option<progress::Stats<S>>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `stats` field to an Option value (optional)
    pub fn maybe_stats(mut self, value: Option<progress::Stats<S>>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St, S: BosStr> ProgressBuilder<St, S>
where
    St: progress_state::State,
    St::TotalXp: progress_state::IsUnset,
{
    /// Set the `totalXP` field (required)
    pub fn total_xp(
        mut self,
        value: impl Into<i64>,
    ) -> ProgressBuilder<progress_state::SetTotalXp<St>, S> {
        self._fields.11 = Option::Some(value.into());
        ProgressBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: progress_state::State, S: BosStr> ProgressBuilder<St, S> {
    /// Set the `triggerSource` field (optional)
    pub fn trigger_source(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `triggerSource` field to an Option value (optional)
    pub fn maybe_trigger_source(mut self, value: Option<S>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St: progress_state::State, S: BosStr> ProgressBuilder<St, S> {
    /// Set the `xpGainedSinceLastSave` field (optional)
    pub fn xp_gained_since_last_save(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `xpGainedSinceLastSave` field to an Option value (optional)
    pub fn maybe_xp_gained_since_last_save(mut self, value: Option<i64>) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<St, S: BosStr> ProgressBuilder<St, S>
where
    St: progress_state::State,
    St::XpToNextLevel: progress_state::IsUnset,
{
    /// Set the `xpToNextLevel` field (required)
    pub fn xp_to_next_level(
        mut self,
        value: impl Into<i64>,
    ) -> ProgressBuilder<progress_state::SetXpToNextLevel<St>, S> {
        self._fields.14 = Option::Some(value.into());
        ProgressBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ProgressBuilder<St, S>
where
    St: progress_state::State,
    St::CreatedAt: progress_state::IsSet,
    St::Level: progress_state::IsSet,
    St::ProgressPercentage: progress_state::IsSet,
    St::TotalXp: progress_state::IsSet,
    St::XpToNextLevel: progress_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Progress<S> {
        Progress {
            card_uri: self._fields.0,
            created_at: self._fields.1.unwrap(),
            current_stamina: self._fields.2,
            level: self._fields.3.unwrap(),
            metadata: self._fields.4,
            previous_level: self._fields.5,
            progress_percentage: self._fields.6.unwrap(),
            related_log_uris: self._fields.7,
            session_id: self._fields.8,
            session_uri: self._fields.9,
            stats: self._fields.10,
            total_xp: self._fields.11.unwrap(),
            trigger_source: self._fields.12,
            xp_gained_since_last_save: self._fields.13,
            xp_to_next_level: self._fields.14.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Progress<S> {
        Progress {
            card_uri: self._fields.0,
            created_at: self._fields.1.unwrap(),
            current_stamina: self._fields.2,
            level: self._fields.3.unwrap(),
            metadata: self._fields.4,
            previous_level: self._fields.5,
            progress_percentage: self._fields.6.unwrap(),
            related_log_uris: self._fields.7,
            session_id: self._fields.8,
            session_uri: self._fields.9,
            stats: self._fields.10,
            total_xp: self._fields.11.unwrap(),
            trigger_source: self._fields.12,
            xp_gained_since_last_save: self._fields.13,
            xp_to_next_level: self._fields.14.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_net_anisota_beta_game_progress() -> 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.progress"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static(
                            "Record representing a player's level progression and game statistics",
                        ),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("level"),
                                SmolStr::new_static("totalXP"),
                                SmolStr::new_static("progressPercentage"),
                                SmolStr::new_static("xpToNextLevel"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("cardUri"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "URI of the card that was advanced when triggerSource is card_advance",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When the progress record was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("currentStamina"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Current stamina level when this progress was recorded (decimal string, e.g. '85.5')",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("level"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("metadata"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#metadata"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("previousLevel"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("progressPercentage"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Progress percentage to the next level (decimal string, e.g. '75.5')",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("relatedLogUris"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "URIs of related game log records that contributed to this progress",
                                        ),
                                    ),
                                    items: LexArrayItem::String(LexString {
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sessionId"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Session ID when this progress was recorded (for linking with log records)",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sessionUri"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "URI of the session record when this progress was recorded",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("stats"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#stats"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("totalXP"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("triggerSource"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "What action triggered this progress save",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("xpGainedSinceLastSave"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("xpToNextLevel"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("metadata"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Additional metadata about this progress update",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("clientVersion"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Version of the client when this progress was recorded",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("platform"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Platform where the level up occurred (web, mobile, etc.)",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("stats"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Game-specific statistics and metrics"),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("dailyRewardsClaimed"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("itemsCollected"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lastPostReadDate"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Date when posts read today was last updated (for daily reset tracking)",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("postsReadToday"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("postsReadTotal"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("postsViewed"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("shufflesPerformed"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("specimensCollected"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}