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

#[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::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

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Progress<'a> {
    ///URI of the card that was advanced when triggerSource is card_advance
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub card_uri: Option<CowStr<'a>>,
    ///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")]
    #[serde(borrow)]
    pub current_stamina: Option<CowStr<'a>>,
    ///Current player level
    pub level: i64,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub metadata: Option<progress::Metadata<'a>>,
    ///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')
    #[serde(borrow)]
    pub progress_percentage: CowStr<'a>,
    ///URIs of related game log records that contributed to this progress
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub related_log_uris: Option<Vec<CowStr<'a>>>,
    ///Session ID when this progress was recorded (for linking with log records)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub session_id: Option<CowStr<'a>>,
    ///URI of the session record when this progress was recorded
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub session_uri: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub stats: Option<progress::Stats<'a>>,
    ///Total experience points accumulated
    pub total_xp: i64,
    ///What action triggered this progress save
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub trigger_source: Option<CowStr<'a>>,
    ///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,
}

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

/// Additional metadata about this progress update

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Metadata<'a> {
    ///Version of the client when this progress was recorded
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub client_version: Option<CowStr<'a>>,
    ///Platform where the level up occurred (web, mobile, etc.)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub platform: Option<CowStr<'a>>,
}

/// Game-specific statistics and metrics

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Stats<'a> {
    ///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>,
}

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

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

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

impl Collection for Progress<'_> {
    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<'a> LexiconSchema for Progress<'a> {
    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<'a> LexiconSchema for Metadata<'a> {
    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<'a> LexiconSchema for Stats<'a> {
    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 TotalXp;
        type XpToNextLevel;
        type Level;
        type CreatedAt;
        type ProgressPercentage;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type TotalXp = Unset;
        type XpToNextLevel = Unset;
        type Level = Unset;
        type CreatedAt = Unset;
        type ProgressPercentage = Unset;
    }
    ///State transition - sets the `total_xp` field to Set
    pub struct SetTotalXp<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTotalXp<S> {}
    impl<S: State> State for SetTotalXp<S> {
        type TotalXp = Set<members::total_xp>;
        type XpToNextLevel = S::XpToNextLevel;
        type Level = S::Level;
        type CreatedAt = S::CreatedAt;
        type ProgressPercentage = S::ProgressPercentage;
    }
    ///State transition - sets the `xp_to_next_level` field to Set
    pub struct SetXpToNextLevel<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetXpToNextLevel<S> {}
    impl<S: State> State for SetXpToNextLevel<S> {
        type TotalXp = S::TotalXp;
        type XpToNextLevel = Set<members::xp_to_next_level>;
        type Level = S::Level;
        type CreatedAt = S::CreatedAt;
        type ProgressPercentage = S::ProgressPercentage;
    }
    ///State transition - sets the `level` field to Set
    pub struct SetLevel<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLevel<S> {}
    impl<S: State> State for SetLevel<S> {
        type TotalXp = S::TotalXp;
        type XpToNextLevel = S::XpToNextLevel;
        type Level = Set<members::level>;
        type CreatedAt = S::CreatedAt;
        type ProgressPercentage = S::ProgressPercentage;
    }
    ///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 TotalXp = S::TotalXp;
        type XpToNextLevel = S::XpToNextLevel;
        type Level = S::Level;
        type CreatedAt = Set<members::created_at>;
        type ProgressPercentage = S::ProgressPercentage;
    }
    ///State transition - sets the `progress_percentage` field to Set
    pub struct SetProgressPercentage<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetProgressPercentage<S> {}
    impl<S: State> State for SetProgressPercentage<S> {
        type TotalXp = S::TotalXp;
        type XpToNextLevel = S::XpToNextLevel;
        type Level = S::Level;
        type CreatedAt = S::CreatedAt;
        type ProgressPercentage = Set<members::progress_percentage>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///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(());
        ///Marker type for the `level` field
        pub struct level(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `progress_percentage` field
        pub struct progress_percentage(());
    }
}

/// Builder for constructing an instance of this type
pub struct ProgressBuilder<'a, S: progress_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<CowStr<'a>>,
        Option<Datetime>,
        Option<CowStr<'a>>,
        Option<i64>,
        Option<progress::Metadata<'a>>,
        Option<i64>,
        Option<CowStr<'a>>,
        Option<Vec<CowStr<'a>>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<progress::Stats<'a>>,
        Option<i64>,
        Option<CowStr<'a>>,
        Option<i64>,
        Option<i64>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

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

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

impl<'a, S: progress_state::State> ProgressBuilder<'a, S> {
    /// Set the `cardUri` field (optional)
    pub fn card_uri(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<'a, S: progress_state::State> ProgressBuilder<'a, S> {
    /// Set the `currentStamina` field (optional)
    pub fn current_stamina(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

impl<'a, S: progress_state::State> ProgressBuilder<'a, S> {
    /// Set the `metadata` field (optional)
    pub fn metadata(mut self, value: impl Into<Option<progress::Metadata<'a>>>) -> 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<'a>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: progress_state::State> ProgressBuilder<'a, 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<'a, S> ProgressBuilder<'a, S>
where
    S: progress_state::State,
    S::ProgressPercentage: progress_state::IsUnset,
{
    /// Set the `progressPercentage` field (required)
    pub fn progress_percentage(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> ProgressBuilder<'a, progress_state::SetProgressPercentage<S>> {
        self._fields.6 = Option::Some(value.into());
        ProgressBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

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

impl<'a, S: progress_state::State> ProgressBuilder<'a, S> {
    /// Set the `sessionUri` field (optional)
    pub fn session_uri(mut self, value: impl Into<Option<CowStr<'a>>>) -> 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<CowStr<'a>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<'a, S: progress_state::State> ProgressBuilder<'a, S> {
    /// Set the `stats` field (optional)
    pub fn stats(mut self, value: impl Into<Option<progress::Stats<'a>>>) -> 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<'a>>) -> Self {
        self._fields.10 = value;
        self
    }
}

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

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

impl<'a, S: progress_state::State> ProgressBuilder<'a, 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<'a, S> ProgressBuilder<'a, S>
where
    S: progress_state::State,
    S::XpToNextLevel: progress_state::IsUnset,
{
    /// Set the `xpToNextLevel` field (required)
    pub fn xp_to_next_level(
        mut self,
        value: impl Into<i64>,
    ) -> ProgressBuilder<'a, progress_state::SetXpToNextLevel<S>> {
        self._fields.14 = Option::Some(value.into());
        ProgressBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ProgressBuilder<'a, S>
where
    S: progress_state::State,
    S::TotalXp: progress_state::IsSet,
    S::XpToNextLevel: progress_state::IsSet,
    S::Level: progress_state::IsSet,
    S::CreatedAt: progress_state::IsSet,
    S::ProgressPercentage: progress_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Progress<'a> {
        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<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Progress<'a> {
        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()
    }
}