// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.fitsky.workout
//
// This file was automatically generated from Lexicon schemas.
// Any manual changes will be overwritten on the next regeneration.

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

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

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::types::blob::BlobRef;
use jacquard_common::types::collection::{Collection, RecordError};
use jacquard_common::types::string::{AtUri, Cid, Datetime};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon, open_union};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::app_fitsky::workout;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct CardioDetails<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub calories: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cardio_zones: Option<workout::CardioZoneData<'a>>,
    ///Distance in meters
    #[serde(skip_serializing_if = "Option::is_none")]
    pub distance_meters: Option<i64>,
    ///Elevation gain in meters
    #[serde(skip_serializing_if = "Option::is_none")]
    pub elevation_gain_meters: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub heart_rate: Option<workout::HeartRateData<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub heart_rate_samples: Option<Vec<workout::HeartRateSample<'a>>>,
    ///Pace in seconds per kilometer
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pace_seconds_per_km: Option<i64>,
    ///GPS route points recorded during the workout
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub route_points: Option<Vec<workout::RoutePoint<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub steps: Option<i64>,
}

/// Time in seconds spent in each heart rate zone

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct CardioZoneData<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub zone1_rest: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub zone2_easy: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub zone3_aerobic: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub zone4_threshold: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub zone5_max: Option<i64>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Exercise<'a> {
    #[serde(borrow)]
    pub name: CowStr<'a>,
    #[serde(borrow)]
    pub sets: Vec<workout::ExerciseSet<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ExerciseSet<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub reps: Option<i64>,
    ///Weight in grams
    #[serde(skip_serializing_if = "Option::is_none")]
    pub weight_grams: Option<i64>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct FlexibilityDetails<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub calories: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cardio_zones: Option<workout::CardioZoneData<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub heart_rate: Option<workout::HeartRateData<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub heart_rate_samples: Option<Vec<workout::HeartRateSample<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub intensity: Option<FlexibilityDetailsIntensity<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub movements: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub steps: Option<i64>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum FlexibilityDetailsIntensity<'a> {
    Light,
    Moderate,
    Intense,
    Other(CowStr<'a>),
}

impl<'a> FlexibilityDetailsIntensity<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Light => "light",
            Self::Moderate => "moderate",
            Self::Intense => "intense",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for FlexibilityDetailsIntensity<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "light" => Self::Light,
            "moderate" => Self::Moderate,
            "intense" => Self::Intense,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for FlexibilityDetailsIntensity<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "light" => Self::Light,
            "moderate" => Self::Moderate,
            "intense" => Self::Intense,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for FlexibilityDetailsIntensity<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for FlexibilityDetailsIntensity<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for FlexibilityDetailsIntensity<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for FlexibilityDetailsIntensity<'_> {
    type Output = FlexibilityDetailsIntensity<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            FlexibilityDetailsIntensity::Light => FlexibilityDetailsIntensity::Light,
            FlexibilityDetailsIntensity::Moderate => {
                FlexibilityDetailsIntensity::Moderate
            }
            FlexibilityDetailsIntensity::Intense => FlexibilityDetailsIntensity::Intense,
            FlexibilityDetailsIntensity::Other(v) => {
                FlexibilityDetailsIntensity::Other(v.into_static())
            }
        }
    }
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct HeartRateData<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub avg: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub min: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub resting: Option<i64>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct HeartRateSample<'a> {
    pub bpm: i64,
    pub timestamp: Datetime,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct HiitSportsDetails<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub calories: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cardio_zones: Option<workout::CardioZoneData<'a>>,
    ///Distance in meters
    #[serde(skip_serializing_if = "Option::is_none")]
    pub distance_meters: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub heart_rate: Option<workout::HeartRateData<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub heart_rate_samples: Option<Vec<workout::HeartRateSample<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub intensity: Option<HiitSportsDetailsIntensity<'a>>,
    ///Pace in seconds per kilometer
    #[serde(skip_serializing_if = "Option::is_none")]
    pub pace_seconds_per_km: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub rounds: Option<i64>,
    ///GPS route points recorded during the workout
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub route_points: Option<Vec<workout::RoutePoint<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub sport: Option<CowStr<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub steps: Option<i64>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum HiitSportsDetailsIntensity<'a> {
    Light,
    Moderate,
    Intense,
    Other(CowStr<'a>),
}

impl<'a> HiitSportsDetailsIntensity<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Light => "light",
            Self::Moderate => "moderate",
            Self::Intense => "intense",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for HiitSportsDetailsIntensity<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "light" => Self::Light,
            "moderate" => Self::Moderate,
            "intense" => Self::Intense,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for HiitSportsDetailsIntensity<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "light" => Self::Light,
            "moderate" => Self::Moderate,
            "intense" => Self::Intense,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for HiitSportsDetailsIntensity<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for HiitSportsDetailsIntensity<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for HiitSportsDetailsIntensity<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for HiitSportsDetailsIntensity<'_> {
    type Output = HiitSportsDetailsIntensity<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            HiitSportsDetailsIntensity::Light => HiitSportsDetailsIntensity::Light,
            HiitSportsDetailsIntensity::Moderate => HiitSportsDetailsIntensity::Moderate,
            HiitSportsDetailsIntensity::Intense => HiitSportsDetailsIntensity::Intense,
            HiitSportsDetailsIntensity::Other(v) => {
                HiitSportsDetailsIntensity::Other(v.into_static())
            }
        }
    }
}

/// A fitness workout record

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Workout<'a> {
    pub created_at: Datetime,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub details: Option<WorkoutDetails<'a>>,
    ///Duration in seconds
    pub duration: i64,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ended_at: Option<Datetime>,
    ///Progress milestones for linear workouts
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub milestones: Option<Vec<workout::Milestone<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub notes: Option<CowStr<'a>>,
    ///Open Graph preview image for social sharing
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub og_image: Option<BlobRef<'a>>,
    ///Reference to the workoutPlan used, if any
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub plan_uri: Option<AtUri<'a>>,
    pub started_at: Datetime,
    ///Whether the workout is in progress or finished. Omitted for legacy workouts (treat as completed).
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub status: Option<WorkoutStatus<'a>>,
    #[serde(borrow)]
    pub title: CowStr<'a>,
    #[serde(borrow)]
    pub r#type: WorkoutType<'a>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub visibility: Option<workout::VisibilitySettings<'a>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum WorkoutDetails<'a> {
    #[serde(rename = "app.fitsky.workout#cardioDetails")]
    CardioDetails(Box<workout::CardioDetails<'a>>),
    #[serde(rename = "app.fitsky.workout#strengthDetails")]
    StrengthDetails(Box<workout::StrengthDetails<'a>>),
    #[serde(rename = "app.fitsky.workout#flexibilityDetails")]
    FlexibilityDetails(Box<workout::FlexibilityDetails<'a>>),
    #[serde(rename = "app.fitsky.workout#hiitSportsDetails")]
    HiitSportsDetails(Box<workout::HiitSportsDetails<'a>>),
}

/// Whether the workout is in progress or finished. Omitted for legacy workouts (treat as completed).

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum WorkoutStatus<'a> {
    Active,
    Completed,
    Other(CowStr<'a>),
}

impl<'a> WorkoutStatus<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Active => "active",
            Self::Completed => "completed",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for WorkoutStatus<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "active" => Self::Active,
            "completed" => Self::Completed,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for WorkoutStatus<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "active" => Self::Active,
            "completed" => Self::Completed,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for WorkoutStatus<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for WorkoutStatus<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for WorkoutStatus<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

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


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum WorkoutType<'a> {
    Running,
    Cycling,
    Swimming,
    Walking,
    Weightlifting,
    Bodyweight,
    Yoga,
    Hiit,
    Sports,
    Stretching,
    Hiking,
    Other(CowStr<'a>),
}

impl<'a> WorkoutType<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Running => "running",
            Self::Cycling => "cycling",
            Self::Swimming => "swimming",
            Self::Walking => "walking",
            Self::Weightlifting => "weightlifting",
            Self::Bodyweight => "bodyweight",
            Self::Yoga => "yoga",
            Self::Hiit => "hiit",
            Self::Sports => "sports",
            Self::Stretching => "stretching",
            Self::Hiking => "hiking",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for WorkoutType<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "running" => Self::Running,
            "cycling" => Self::Cycling,
            "swimming" => Self::Swimming,
            "walking" => Self::Walking,
            "weightlifting" => Self::Weightlifting,
            "bodyweight" => Self::Bodyweight,
            "yoga" => Self::Yoga,
            "hiit" => Self::Hiit,
            "sports" => Self::Sports,
            "stretching" => Self::Stretching,
            "hiking" => Self::Hiking,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for WorkoutType<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "running" => Self::Running,
            "cycling" => Self::Cycling,
            "swimming" => Self::Swimming,
            "walking" => Self::Walking,
            "weightlifting" => Self::Weightlifting,
            "bodyweight" => Self::Bodyweight,
            "yoga" => Self::Yoga,
            "hiit" => Self::Hiit,
            "sports" => Self::Sports,
            "stretching" => Self::Stretching,
            "hiking" => Self::Hiking,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for WorkoutType<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for WorkoutType<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for WorkoutType<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for WorkoutType<'_> {
    type Output = WorkoutType<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            WorkoutType::Running => WorkoutType::Running,
            WorkoutType::Cycling => WorkoutType::Cycling,
            WorkoutType::Swimming => WorkoutType::Swimming,
            WorkoutType::Walking => WorkoutType::Walking,
            WorkoutType::Weightlifting => WorkoutType::Weightlifting,
            WorkoutType::Bodyweight => WorkoutType::Bodyweight,
            WorkoutType::Yoga => WorkoutType::Yoga,
            WorkoutType::Hiit => WorkoutType::Hiit,
            WorkoutType::Sports => WorkoutType::Sports,
            WorkoutType::Stretching => WorkoutType::Stretching,
            WorkoutType::Hiking => WorkoutType::Hiking,
            WorkoutType::Other(v) => WorkoutType::Other(v.into_static()),
        }
    }
}

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

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


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Milestone<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub note: Option<CowStr<'a>>,
    pub timestamp: Datetime,
    #[serde(borrow)]
    pub r#type: MilestoneType<'a>,
    ///Milestone value in meters
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value_meters: Option<i64>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum MilestoneType<'a> {
    Distance,
    Lap,
    Note,
    Other(CowStr<'a>),
}

impl<'a> MilestoneType<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Distance => "distance",
            Self::Lap => "lap",
            Self::Note => "note",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for MilestoneType<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "distance" => Self::Distance,
            "lap" => Self::Lap,
            "note" => Self::Note,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for MilestoneType<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "distance" => Self::Distance,
            "lap" => Self::Lap,
            "note" => Self::Note,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for MilestoneType<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for MilestoneType<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for MilestoneType<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for MilestoneType<'_> {
    type Output = MilestoneType<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            MilestoneType::Distance => MilestoneType::Distance,
            MilestoneType::Lap => MilestoneType::Lap,
            MilestoneType::Note => MilestoneType::Note,
            MilestoneType::Other(v) => MilestoneType::Other(v.into_static()),
        }
    }
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct RoutePoint<'a> {
    ///Latitude in microdegrees (degrees * 1,000,000)
    pub lat_e6: i64,
    ///Longitude in microdegrees (degrees * 1,000,000)
    pub lng_e6: i64,
    pub timestamp: Datetime,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct StrengthDetails<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    pub calories: Option<i64>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cardio_zones: Option<workout::CardioZoneData<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub exercises: Option<Vec<workout::Exercise<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub heart_rate: Option<workout::HeartRateData<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub heart_rate_samples: Option<Vec<workout::HeartRateSample<'a>>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub steps: Option<i64>,
}

/// Controls which fields are visible to other users in the Fitsky UI. Note: ATProto repos are public — this is UI-level privacy only.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct VisibilitySettings<'a> {
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub calories: Option<VisibilitySettingsCalories<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub cardio_zones: Option<VisibilitySettingsCardioZones<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub details: Option<VisibilitySettingsDetails<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub heart_rate: Option<VisibilitySettingsHeartRate<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub notes: Option<VisibilitySettingsNotes<'a>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub steps: Option<VisibilitySettingsSteps<'a>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum VisibilitySettingsCalories<'a> {
    Public,
    Private,
    Other(CowStr<'a>),
}

impl<'a> VisibilitySettingsCalories<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Public => "public",
            Self::Private => "private",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for VisibilitySettingsCalories<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for VisibilitySettingsCalories<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for VisibilitySettingsCalories<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for VisibilitySettingsCalories<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for VisibilitySettingsCalories<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

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


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum VisibilitySettingsCardioZones<'a> {
    Public,
    Private,
    Other(CowStr<'a>),
}

impl<'a> VisibilitySettingsCardioZones<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Public => "public",
            Self::Private => "private",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for VisibilitySettingsCardioZones<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for VisibilitySettingsCardioZones<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for VisibilitySettingsCardioZones<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for VisibilitySettingsCardioZones<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for VisibilitySettingsCardioZones<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl jacquard_common::IntoStatic for VisibilitySettingsCardioZones<'_> {
    type Output = VisibilitySettingsCardioZones<'static>;
    fn into_static(self) -> Self::Output {
        match self {
            VisibilitySettingsCardioZones::Public => {
                VisibilitySettingsCardioZones::Public
            }
            VisibilitySettingsCardioZones::Private => {
                VisibilitySettingsCardioZones::Private
            }
            VisibilitySettingsCardioZones::Other(v) => {
                VisibilitySettingsCardioZones::Other(v.into_static())
            }
        }
    }
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum VisibilitySettingsDetails<'a> {
    Public,
    Private,
    Other(CowStr<'a>),
}

impl<'a> VisibilitySettingsDetails<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Public => "public",
            Self::Private => "private",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for VisibilitySettingsDetails<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for VisibilitySettingsDetails<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for VisibilitySettingsDetails<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for VisibilitySettingsDetails<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for VisibilitySettingsDetails<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

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


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum VisibilitySettingsHeartRate<'a> {
    Public,
    Private,
    Other(CowStr<'a>),
}

impl<'a> VisibilitySettingsHeartRate<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Public => "public",
            Self::Private => "private",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for VisibilitySettingsHeartRate<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for VisibilitySettingsHeartRate<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for VisibilitySettingsHeartRate<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for VisibilitySettingsHeartRate<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for VisibilitySettingsHeartRate<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

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


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum VisibilitySettingsNotes<'a> {
    Public,
    Private,
    Other(CowStr<'a>),
}

impl<'a> VisibilitySettingsNotes<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Public => "public",
            Self::Private => "private",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for VisibilitySettingsNotes<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for VisibilitySettingsNotes<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for VisibilitySettingsNotes<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for VisibilitySettingsNotes<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for VisibilitySettingsNotes<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

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


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum VisibilitySettingsSteps<'a> {
    Public,
    Private,
    Other(CowStr<'a>),
}

impl<'a> VisibilitySettingsSteps<'a> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Public => "public",
            Self::Private => "private",
            Self::Other(s) => s.as_ref(),
        }
    }
}

impl<'a> From<&'a str> for VisibilitySettingsSteps<'a> {
    fn from(s: &'a str) -> Self {
        match s {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

impl<'a> From<String> for VisibilitySettingsSteps<'a> {
    fn from(s: String) -> Self {
        match s.as_str() {
            "public" => Self::Public,
            "private" => Self::Private,
            _ => Self::Other(CowStr::from(s)),
        }
    }
}

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

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

impl<'a> serde::Serialize for VisibilitySettingsSteps<'a> {
    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
    where
        S: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, 'a> serde::Deserialize<'de> for VisibilitySettingsSteps<'a>
where
    'de: 'a,
{
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = <&'de str>::deserialize(deserializer)?;
        Ok(Self::from(s))
    }
}

impl<'a> Default for VisibilitySettingsSteps<'a> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

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

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

impl<'a> LexiconSchema for CardioDetails<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "cardioDetails"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.distance_meters {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("distance_meters"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.elevation_gain_meters {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("elevation_gain_meters"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.pace_seconds_per_km {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("pace_seconds_per_km"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for CardioZoneData<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "cardioZoneData"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for Exercise<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "exercise"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.name;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("name"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for ExerciseSet<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "exerciseSet"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.weight_grams {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("weight_grams"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for FlexibilityDetails<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "flexibilityDetails"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.intensity {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("intensity"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for HeartRateData<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "heartRateData"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for HeartRateSample<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "heartRateSample"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for HiitSportsDetails<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "hiitSportsDetails"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.distance_meters {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("distance_meters"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.intensity {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("intensity"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.pace_seconds_per_km {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("pace_seconds_per_km"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.sport {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 128usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("sport"),
                    max: 128usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

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

#[derive(Debug, Serialize, Deserialize)]
pub struct WorkoutRecord;
impl XrpcResp for WorkoutRecord {
    const NSID: &'static str = "app.fitsky.workout";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = WorkoutGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

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

impl Collection for Workout<'_> {
    const NSID: &'static str = "app.fitsky.workout";
    type Record = WorkoutRecord;
}

impl Collection for WorkoutRecord {
    const NSID: &'static str = "app.fitsky.workout";
    type Record = WorkoutRecord;
}

impl<'a> LexiconSchema for Workout<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.duration;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("duration"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.notes {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2048usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("notes"),
                    max: 2048usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.og_image {
            {
                let size = value.blob().size;
                if size > 1000000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("og_image"),
                        max: 1000000usize,
                        actual: size,
                    });
                }
            }
        }
        if let Some(ref value) = self.og_image {
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["image/png", "image/jpeg", "image/webp"];
                let matched = accepted
                    .iter()
                    .any(|pattern| {
                        if *pattern == "*/*" {
                            true
                        } else if pattern.ends_with("/*") {
                            let prefix = &pattern[..pattern.len() - 2];
                            mime.starts_with(prefix)
                                && mime.as_bytes().get(prefix.len()) == Some(&b'/')
                        } else {
                            mime == *pattern
                        }
                    });
                if !matched {
                    return Err(ConstraintError::BlobMimeTypeNotAccepted {
                        path: ValidationPath::from_field("og_image"),
                        accepted: vec![
                            "image/png".to_string(), "image/jpeg".to_string(),
                            "image/webp".to_string()
                        ],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        if let Some(ref value) = self.status {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("status"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.title;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 256usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("title"),
                    max: 256usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.r#type;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("type"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Milestone<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "milestone"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.note {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 512usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("note"),
                    max: 512usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.r#type;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("type"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.value_meters {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("value_meters"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for RoutePoint<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "routePoint"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for StrengthDetails<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "strengthDetails"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for VisibilitySettings<'a> {
    fn nsid() -> &'static str {
        "app.fitsky.workout"
    }
    fn def_name() -> &'static str {
        "visibilitySettings"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_fitsky_workout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.calories {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("calories"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.cardio_zones {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("cardio_zones"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.details {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("details"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.heart_rate {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("heart_rate"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.notes {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("notes"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.steps {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 64usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("steps"),
                    max: 64usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

fn lexicon_doc_app_fitsky_workout() -> 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("app.fitsky.workout"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("cardioDetails"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("calories"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cardioZones"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#cardioZoneData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("distanceMeters"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("elevationGainMeters"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heartRate"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#heartRateData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heartRateSamples"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#heartRateSample"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("paceSecondsPerKm"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("routePoints"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "GPS route points recorded during the workout",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#routePoint"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("steps"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("cardioZoneData"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Time in seconds spent in each heart rate zone",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("zone1Rest"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("zone2Easy"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("zone3Aerobic"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("zone4Threshold"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("zone5Max"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("exercise"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("name"), SmolStr::new_static("sets")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("sets"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#exerciseSet"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("exerciseSet"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("reps"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("weightGrams"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("flexibilityDetails"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("calories"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cardioZones"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#cardioZoneData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heartRate"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#heartRateData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heartRateSamples"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#heartRateSample"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("intensity"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("movements"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("steps"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("heartRateData"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("avg"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("max"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("min"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("resting"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("heartRateSample"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("timestamp"), SmolStr::new_static("bpm")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("bpm"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("timestamp"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("hiitSportsDetails"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("calories"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cardioZones"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#cardioZoneData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("distanceMeters"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heartRate"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#heartRateData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heartRateSamples"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#heartRateSample"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("intensity"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("paceSecondsPerKm"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("rounds"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("routePoints"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "GPS route points recorded during the workout",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#routePoint"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("sport"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(128usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("steps"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(CowStr::new_static("A fitness workout record")),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("type"), SmolStr::new_static("title"),
                                SmolStr::new_static("startedAt"),
                                SmolStr::new_static("duration"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("details"),
                                LexObjectProperty::Union(LexRefUnion {
                                    refs: vec![
                                        CowStr::new_static("#cardioDetails"),
                                        CowStr::new_static("#strengthDetails"),
                                        CowStr::new_static("#flexibilityDetails"),
                                        CowStr::new_static("#hiitSportsDetails")
                                    ],
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("duration"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("endedAt"),
                                LexObjectProperty::String(LexString {
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("milestones"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Progress milestones for linear workouts",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("#milestone"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("notes"),
                                LexObjectProperty::String(LexString {
                                    max_length: Some(2048usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("ogImage"),
                                LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                            );
                            map.insert(
                                SmolStr::new_static("planUri"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Reference to the workoutPlan used, if any",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("startedAt"),
                                LexObjectProperty::String(LexString {
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("status"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Whether the workout is in progress or finished. Omitted for legacy workouts (treat as completed).",
                                        ),
                                    ),
                                    max_length: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("title"),
                                LexObjectProperty::String(LexString {
                                    max_length: Some(256usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("type"),
                                LexObjectProperty::String(LexString {
                                    max_length: Some(64usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("visibility"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("#visibilitySettings"),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("milestone"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("type"), SmolStr::new_static("timestamp")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("note"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(512usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("timestamp"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("type"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("valueMeters"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("routePoint"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("latE6"), SmolStr::new_static("lngE6"),
                            SmolStr::new_static("timestamp")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("latE6"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("lngE6"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("timestamp"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Datetime),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("strengthDetails"),
                LexUserType::Object(LexObject {
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("calories"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cardioZones"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#cardioZoneData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("exercises"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#exercise"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heartRate"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static("#heartRateData"),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heartRateSamples"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#heartRateSample"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("steps"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("visibilitySettings"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Controls which fields are visible to other users in the Fitsky UI. Note: ATProto repos are public — this is UI-level privacy only.",
                        ),
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("calories"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cardioZones"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("details"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heartRate"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("notes"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("steps"),
                            LexObjectProperty::String(LexString {
                                max_length: Some(64usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

/// Builder for constructing an instance of this type
pub struct ExerciseBuilder<'a, S: exercise_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<CowStr<'a>>, Option<Vec<workout::ExerciseSet<'a>>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Exercise<'a> {
    /// Create a new builder for this type
    pub fn new() -> ExerciseBuilder<'a, exercise_state::Empty> {
        ExerciseBuilder::new()
    }
}

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

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

impl<'a, S> ExerciseBuilder<'a, S>
where
    S: exercise_state::State,
    S::Sets: exercise_state::IsUnset,
{
    /// Set the `sets` field (required)
    pub fn sets(
        mut self,
        value: impl Into<Vec<workout::ExerciseSet<'a>>>,
    ) -> ExerciseBuilder<'a, exercise_state::SetSets<S>> {
        self._fields.1 = Option::Some(value.into());
        ExerciseBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ExerciseBuilder<'a, S>
where
    S: exercise_state::State,
    S::Sets: exercise_state::IsSet,
    S::Name: exercise_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Exercise<'a> {
        Exercise {
            name: self._fields.0.unwrap(),
            sets: self._fields.1.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>,
        >,
    ) -> Exercise<'a> {
        Exercise {
            name: self._fields.0.unwrap(),
            sets: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod heart_rate_sample_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 Timestamp;
        type Bpm;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Timestamp = Unset;
        type Bpm = Unset;
    }
    ///State transition - sets the `timestamp` field to Set
    pub struct SetTimestamp<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTimestamp<S> {}
    impl<S: State> State for SetTimestamp<S> {
        type Timestamp = Set<members::timestamp>;
        type Bpm = S::Bpm;
    }
    ///State transition - sets the `bpm` field to Set
    pub struct SetBpm<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetBpm<S> {}
    impl<S: State> State for SetBpm<S> {
        type Timestamp = S::Timestamp;
        type Bpm = Set<members::bpm>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `timestamp` field
        pub struct timestamp(());
        ///Marker type for the `bpm` field
        pub struct bpm(());
    }
}

/// Builder for constructing an instance of this type
pub struct HeartRateSampleBuilder<'a, S: heart_rate_sample_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<i64>, Option<Datetime>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> HeartRateSample<'a> {
    /// Create a new builder for this type
    pub fn new() -> HeartRateSampleBuilder<'a, heart_rate_sample_state::Empty> {
        HeartRateSampleBuilder::new()
    }
}

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

impl<'a, S> HeartRateSampleBuilder<'a, S>
where
    S: heart_rate_sample_state::State,
    S::Bpm: heart_rate_sample_state::IsUnset,
{
    /// Set the `bpm` field (required)
    pub fn bpm(
        mut self,
        value: impl Into<i64>,
    ) -> HeartRateSampleBuilder<'a, heart_rate_sample_state::SetBpm<S>> {
        self._fields.0 = Option::Some(value.into());
        HeartRateSampleBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> HeartRateSampleBuilder<'a, S>
where
    S: heart_rate_sample_state::State,
    S::Timestamp: heart_rate_sample_state::IsUnset,
{
    /// Set the `timestamp` field (required)
    pub fn timestamp(
        mut self,
        value: impl Into<Datetime>,
    ) -> HeartRateSampleBuilder<'a, heart_rate_sample_state::SetTimestamp<S>> {
        self._fields.1 = Option::Some(value.into());
        HeartRateSampleBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> HeartRateSampleBuilder<'a, S>
where
    S: heart_rate_sample_state::State,
    S::Timestamp: heart_rate_sample_state::IsSet,
    S::Bpm: heart_rate_sample_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> HeartRateSample<'a> {
        HeartRateSample {
            bpm: self._fields.0.unwrap(),
            timestamp: self._fields.1.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>,
        >,
    ) -> HeartRateSample<'a> {
        HeartRateSample {
            bpm: self._fields.0.unwrap(),
            timestamp: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod workout_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 Duration;
        type StartedAt;
        type Type;
        type Title;
        type CreatedAt;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Duration = Unset;
        type StartedAt = Unset;
        type Type = Unset;
        type Title = Unset;
        type CreatedAt = Unset;
    }
    ///State transition - sets the `duration` field to Set
    pub struct SetDuration<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDuration<S> {}
    impl<S: State> State for SetDuration<S> {
        type Duration = Set<members::duration>;
        type StartedAt = S::StartedAt;
        type Type = S::Type;
        type Title = S::Title;
        type CreatedAt = S::CreatedAt;
    }
    ///State transition - sets the `started_at` field to Set
    pub struct SetStartedAt<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetStartedAt<S> {}
    impl<S: State> State for SetStartedAt<S> {
        type Duration = S::Duration;
        type StartedAt = Set<members::started_at>;
        type Type = S::Type;
        type Title = S::Title;
        type CreatedAt = S::CreatedAt;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetType<S> {}
    impl<S: State> State for SetType<S> {
        type Duration = S::Duration;
        type StartedAt = S::StartedAt;
        type Type = Set<members::r#type>;
        type Title = S::Title;
        type CreatedAt = S::CreatedAt;
    }
    ///State transition - sets the `title` field to Set
    pub struct SetTitle<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTitle<S> {}
    impl<S: State> State for SetTitle<S> {
        type Duration = S::Duration;
        type StartedAt = S::StartedAt;
        type Type = S::Type;
        type Title = Set<members::title>;
        type CreatedAt = S::CreatedAt;
    }
    ///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 Duration = S::Duration;
        type StartedAt = S::StartedAt;
        type Type = S::Type;
        type Title = S::Title;
        type CreatedAt = Set<members::created_at>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `duration` field
        pub struct duration(());
        ///Marker type for the `started_at` field
        pub struct started_at(());
        ///Marker type for the `type` field
        pub struct r#type(());
        ///Marker type for the `title` field
        pub struct title(());
        ///Marker type for the `created_at` field
        pub struct created_at(());
    }
}

/// Builder for constructing an instance of this type
pub struct WorkoutBuilder<'a, S: workout_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Datetime>,
        Option<WorkoutDetails<'a>>,
        Option<i64>,
        Option<Datetime>,
        Option<Vec<workout::Milestone<'a>>>,
        Option<CowStr<'a>>,
        Option<BlobRef<'a>>,
        Option<AtUri<'a>>,
        Option<Datetime>,
        Option<WorkoutStatus<'a>>,
        Option<CowStr<'a>>,
        Option<WorkoutType<'a>>,
        Option<workout::VisibilitySettings<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Workout<'a> {
    /// Create a new builder for this type
    pub fn new() -> WorkoutBuilder<'a, workout_state::Empty> {
        WorkoutBuilder::new()
    }
}

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

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

impl<'a, S: workout_state::State> WorkoutBuilder<'a, S> {
    /// Set the `details` field (optional)
    pub fn details(mut self, value: impl Into<Option<WorkoutDetails<'a>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `details` field to an Option value (optional)
    pub fn maybe_details(mut self, value: Option<WorkoutDetails<'a>>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<'a, S> WorkoutBuilder<'a, S>
where
    S: workout_state::State,
    S::Duration: workout_state::IsUnset,
{
    /// Set the `duration` field (required)
    pub fn duration(
        mut self,
        value: impl Into<i64>,
    ) -> WorkoutBuilder<'a, workout_state::SetDuration<S>> {
        self._fields.2 = Option::Some(value.into());
        WorkoutBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: workout_state::State> WorkoutBuilder<'a, S> {
    /// Set the `endedAt` field (optional)
    pub fn ended_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `endedAt` field to an Option value (optional)
    pub fn maybe_ended_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S: workout_state::State> WorkoutBuilder<'a, S> {
    /// Set the `milestones` field (optional)
    pub fn milestones(
        mut self,
        value: impl Into<Option<Vec<workout::Milestone<'a>>>>,
    ) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `milestones` field to an Option value (optional)
    pub fn maybe_milestones(
        mut self,
        value: Option<Vec<workout::Milestone<'a>>>,
    ) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<'a, S: workout_state::State> WorkoutBuilder<'a, S> {
    /// Set the `notes` field (optional)
    pub fn notes(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `notes` field to an Option value (optional)
    pub fn maybe_notes(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: workout_state::State> WorkoutBuilder<'a, S> {
    /// Set the `ogImage` field (optional)
    pub fn og_image(mut self, value: impl Into<Option<BlobRef<'a>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `ogImage` field to an Option value (optional)
    pub fn maybe_og_image(mut self, value: Option<BlobRef<'a>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S: workout_state::State> WorkoutBuilder<'a, S> {
    /// Set the `planUri` field (optional)
    pub fn plan_uri(mut self, value: impl Into<Option<AtUri<'a>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `planUri` field to an Option value (optional)
    pub fn maybe_plan_uri(mut self, value: Option<AtUri<'a>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S> WorkoutBuilder<'a, S>
where
    S: workout_state::State,
    S::StartedAt: workout_state::IsUnset,
{
    /// Set the `startedAt` field (required)
    pub fn started_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> WorkoutBuilder<'a, workout_state::SetStartedAt<S>> {
        self._fields.8 = Option::Some(value.into());
        WorkoutBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: workout_state::State> WorkoutBuilder<'a, S> {
    /// Set the `status` field (optional)
    pub fn status(mut self, value: impl Into<Option<WorkoutStatus<'a>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `status` field to an Option value (optional)
    pub fn maybe_status(mut self, value: Option<WorkoutStatus<'a>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<'a, S> WorkoutBuilder<'a, S>
where
    S: workout_state::State,
    S::Title: workout_state::IsUnset,
{
    /// Set the `title` field (required)
    pub fn title(
        mut self,
        value: impl Into<CowStr<'a>>,
    ) -> WorkoutBuilder<'a, workout_state::SetTitle<S>> {
        self._fields.10 = Option::Some(value.into());
        WorkoutBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> WorkoutBuilder<'a, S>
where
    S: workout_state::State,
    S::Type: workout_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<WorkoutType<'a>>,
    ) -> WorkoutBuilder<'a, workout_state::SetType<S>> {
        self._fields.11 = Option::Some(value.into());
        WorkoutBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: workout_state::State> WorkoutBuilder<'a, S> {
    /// Set the `visibility` field (optional)
    pub fn visibility(
        mut self,
        value: impl Into<Option<workout::VisibilitySettings<'a>>>,
    ) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `visibility` field to an Option value (optional)
    pub fn maybe_visibility(
        mut self,
        value: Option<workout::VisibilitySettings<'a>>,
    ) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<'a, S> WorkoutBuilder<'a, S>
where
    S: workout_state::State,
    S::Duration: workout_state::IsSet,
    S::StartedAt: workout_state::IsSet,
    S::Type: workout_state::IsSet,
    S::Title: workout_state::IsSet,
    S::CreatedAt: workout_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Workout<'a> {
        Workout {
            created_at: self._fields.0.unwrap(),
            details: self._fields.1,
            duration: self._fields.2.unwrap(),
            ended_at: self._fields.3,
            milestones: self._fields.4,
            notes: self._fields.5,
            og_image: self._fields.6,
            plan_uri: self._fields.7,
            started_at: self._fields.8.unwrap(),
            status: self._fields.9,
            title: self._fields.10.unwrap(),
            r#type: self._fields.11.unwrap(),
            visibility: self._fields.12,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<
            jacquard_common::deps::smol_str::SmolStr,
            jacquard_common::types::value::Data<'a>,
        >,
    ) -> Workout<'a> {
        Workout {
            created_at: self._fields.0.unwrap(),
            details: self._fields.1,
            duration: self._fields.2.unwrap(),
            ended_at: self._fields.3,
            milestones: self._fields.4,
            notes: self._fields.5,
            og_image: self._fields.6,
            plan_uri: self._fields.7,
            started_at: self._fields.8.unwrap(),
            status: self._fields.9,
            title: self._fields.10.unwrap(),
            r#type: self._fields.11.unwrap(),
            visibility: self._fields.12,
            extra_data: Some(extra_data),
        }
    }
}

pub mod milestone_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 Timestamp;
        type Type;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Timestamp = Unset;
        type Type = Unset;
    }
    ///State transition - sets the `timestamp` field to Set
    pub struct SetTimestamp<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTimestamp<S> {}
    impl<S: State> State for SetTimestamp<S> {
        type Timestamp = Set<members::timestamp>;
        type Type = S::Type;
    }
    ///State transition - sets the `type` field to Set
    pub struct SetType<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetType<S> {}
    impl<S: State> State for SetType<S> {
        type Timestamp = S::Timestamp;
        type Type = Set<members::r#type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `timestamp` field
        pub struct timestamp(());
        ///Marker type for the `type` field
        pub struct r#type(());
    }
}

/// Builder for constructing an instance of this type
pub struct MilestoneBuilder<'a, S: milestone_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<CowStr<'a>>,
        Option<Datetime>,
        Option<MilestoneType<'a>>,
        Option<i64>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Milestone<'a> {
    /// Create a new builder for this type
    pub fn new() -> MilestoneBuilder<'a, milestone_state::Empty> {
        MilestoneBuilder::new()
    }
}

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

impl<'a, S: milestone_state::State> MilestoneBuilder<'a, S> {
    /// Set the `note` field (optional)
    pub fn note(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `note` field to an Option value (optional)
    pub fn maybe_note(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<'a, S> MilestoneBuilder<'a, S>
where
    S: milestone_state::State,
    S::Timestamp: milestone_state::IsUnset,
{
    /// Set the `timestamp` field (required)
    pub fn timestamp(
        mut self,
        value: impl Into<Datetime>,
    ) -> MilestoneBuilder<'a, milestone_state::SetTimestamp<S>> {
        self._fields.1 = Option::Some(value.into());
        MilestoneBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> MilestoneBuilder<'a, S>
where
    S: milestone_state::State,
    S::Type: milestone_state::IsUnset,
{
    /// Set the `type` field (required)
    pub fn r#type(
        mut self,
        value: impl Into<MilestoneType<'a>>,
    ) -> MilestoneBuilder<'a, milestone_state::SetType<S>> {
        self._fields.2 = Option::Some(value.into());
        MilestoneBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: milestone_state::State> MilestoneBuilder<'a, S> {
    /// Set the `valueMeters` field (optional)
    pub fn value_meters(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `valueMeters` field to an Option value (optional)
    pub fn maybe_value_meters(mut self, value: Option<i64>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<'a, S> MilestoneBuilder<'a, S>
where
    S: milestone_state::State,
    S::Timestamp: milestone_state::IsSet,
    S::Type: milestone_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Milestone<'a> {
        Milestone {
            note: self._fields.0,
            timestamp: self._fields.1.unwrap(),
            r#type: self._fields.2.unwrap(),
            value_meters: self._fields.3,
            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>,
        >,
    ) -> Milestone<'a> {
        Milestone {
            note: self._fields.0,
            timestamp: self._fields.1.unwrap(),
            r#type: self._fields.2.unwrap(),
            value_meters: self._fields.3,
            extra_data: Some(extra_data),
        }
    }
}

pub mod route_point_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 LngE6;
        type LatE6;
        type Timestamp;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type LngE6 = Unset;
        type LatE6 = Unset;
        type Timestamp = Unset;
    }
    ///State transition - sets the `lng_e6` field to Set
    pub struct SetLngE6<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLngE6<S> {}
    impl<S: State> State for SetLngE6<S> {
        type LngE6 = Set<members::lng_e6>;
        type LatE6 = S::LatE6;
        type Timestamp = S::Timestamp;
    }
    ///State transition - sets the `lat_e6` field to Set
    pub struct SetLatE6<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLatE6<S> {}
    impl<S: State> State for SetLatE6<S> {
        type LngE6 = S::LngE6;
        type LatE6 = Set<members::lat_e6>;
        type Timestamp = S::Timestamp;
    }
    ///State transition - sets the `timestamp` field to Set
    pub struct SetTimestamp<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetTimestamp<S> {}
    impl<S: State> State for SetTimestamp<S> {
        type LngE6 = S::LngE6;
        type LatE6 = S::LatE6;
        type Timestamp = Set<members::timestamp>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `lng_e6` field
        pub struct lng_e6(());
        ///Marker type for the `lat_e6` field
        pub struct lat_e6(());
        ///Marker type for the `timestamp` field
        pub struct timestamp(());
    }
}

/// Builder for constructing an instance of this type
pub struct RoutePointBuilder<'a, S: route_point_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<i64>, Option<i64>, Option<Datetime>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> RoutePoint<'a> {
    /// Create a new builder for this type
    pub fn new() -> RoutePointBuilder<'a, route_point_state::Empty> {
        RoutePointBuilder::new()
    }
}

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

impl<'a, S> RoutePointBuilder<'a, S>
where
    S: route_point_state::State,
    S::LatE6: route_point_state::IsUnset,
{
    /// Set the `latE6` field (required)
    pub fn lat_e6(
        mut self,
        value: impl Into<i64>,
    ) -> RoutePointBuilder<'a, route_point_state::SetLatE6<S>> {
        self._fields.0 = Option::Some(value.into());
        RoutePointBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RoutePointBuilder<'a, S>
where
    S: route_point_state::State,
    S::LngE6: route_point_state::IsUnset,
{
    /// Set the `lngE6` field (required)
    pub fn lng_e6(
        mut self,
        value: impl Into<i64>,
    ) -> RoutePointBuilder<'a, route_point_state::SetLngE6<S>> {
        self._fields.1 = Option::Some(value.into());
        RoutePointBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RoutePointBuilder<'a, S>
where
    S: route_point_state::State,
    S::Timestamp: route_point_state::IsUnset,
{
    /// Set the `timestamp` field (required)
    pub fn timestamp(
        mut self,
        value: impl Into<Datetime>,
    ) -> RoutePointBuilder<'a, route_point_state::SetTimestamp<S>> {
        self._fields.2 = Option::Some(value.into());
        RoutePointBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> RoutePointBuilder<'a, S>
where
    S: route_point_state::State,
    S::LngE6: route_point_state::IsSet,
    S::LatE6: route_point_state::IsSet,
    S::Timestamp: route_point_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> RoutePoint<'a> {
        RoutePoint {
            lat_e6: self._fields.0.unwrap(),
            lng_e6: self._fields.1.unwrap(),
            timestamp: self._fields.2.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>,
        >,
    ) -> RoutePoint<'a> {
        RoutePoint {
            lat_e6: self._fields.0.unwrap(),
            lng_e6: self._fields.1.unwrap(),
            timestamp: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}