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

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

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

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

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
/// A single wearing review of a fragrance

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(
    rename_all = "camelCase",
    rename = "social.drydown.review",
    tag = "$type",
    bound(deserialize = "S: Deserialize<'de> + BosStr")
)]
pub struct Review<S: BosStr = DefaultStr> {
    ///Final: Depth and evolution (1-5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub complexity: Option<i64>,
    ///Timestamp when the review was created
    pub created_at: Datetime,
    ///Mid-Wear: How it smells after settling (1-5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub drydown_rating: Option<i64>,
    ///Elevation in meters above sea level
    #[serde(skip_serializing_if = "Option::is_none")]
    pub elevation: Option<i64>,
    ///Final: How it smells at the end (1-5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub end_rating: Option<i64>,
    ///Reference to the social.drydown.fragrance record
    pub fragrance: AtUri<S>,
    ///Final: Total duration (1-5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub longevity: Option<i64>,
    ///Mid-Wear: Scent bubble radius during mid-wear (1-5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub mid_projection: Option<i64>,
    ///First Impression: Immediate scent bubble radius (1-5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub opening_projection: Option<i64>,
    ///First Impression: How it smells immediately (1-5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub opening_rating: Option<i64>,
    ///Final: Holistic 'Gut Score' (1-5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub overall_rating: Option<i64>,
    ///Mid-Wear: Trail left behind (1-5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sillage: Option<i64>,
    ///Temperature in Celsius at Stage 1 * 10 (e.g. 225 = 22.5°C)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stage1_temp: Option<i64>,
    ///Timestamp when Stage 2 was completed (for accurate temperature)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stage2_completed_at: Option<Datetime>,
    ///Temperature in Celsius at Stage 2 * 10 (e.g. 225 = 22.5°C)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stage2_temp: Option<i64>,
    ///Temperature in Celsius at Stage 3 * 10 (e.g. 225 = 22.5°C)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub stage3_temp: Option<i64>,
    ///Written review (max 255 graphemes)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub text: Option<S>,
    ///Daily maximum UV index (0-11+)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub uv_index: Option<i64>,
    ///User opted in to weather data collection
    #[serde(skip_serializing_if = "Option::is_none")]
    pub weather_opt_in: Option<bool>,
    ///Calculated final score * 1000 (e.g. 4250 = 4.25)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub weighted_score: Option<i64>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

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

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

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

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

#[derive(Debug, Serialize, Deserialize)]
pub struct ReviewRecord;
impl XrpcResp for ReviewRecord {
    const NSID: &'static str = "social.drydown.review";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = ReviewGetRecordOutput<S>;
    type Err = RecordError;
}

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

impl<S: BosStr> Collection for Review<S> {
    const NSID: &'static str = "social.drydown.review";
    type Record = ReviewRecord;
}

impl Collection for ReviewRecord {
    const NSID: &'static str = "social.drydown.review";
    type Record = ReviewRecord;
}

impl<S: BosStr> LexiconSchema for Review<S> {
    fn nsid() -> &'static str {
        "social.drydown.review"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_social_drydown_review()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.complexity {
            if *value > 5i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("complexity"),
                    max: 5i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.complexity {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("complexity"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.drydown_rating {
            if *value > 5i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("drydown_rating"),
                    max: 5i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.drydown_rating {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("drydown_rating"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.end_rating {
            if *value > 5i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("end_rating"),
                    max: 5i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.end_rating {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("end_rating"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.longevity {
            if *value > 5i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("longevity"),
                    max: 5i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.longevity {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("longevity"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.mid_projection {
            if *value > 5i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("mid_projection"),
                    max: 5i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.mid_projection {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("mid_projection"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.opening_projection {
            if *value > 5i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("opening_projection"),
                    max: 5i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.opening_projection {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("opening_projection"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.opening_rating {
            if *value > 5i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("opening_rating"),
                    max: 5i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.opening_rating {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("opening_rating"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.overall_rating {
            if *value > 5i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("overall_rating"),
                    max: 5i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.overall_rating {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("overall_rating"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.sillage {
            if *value > 5i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("sillage"),
                    max: 5i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.sillage {
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("sillage"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.text {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 3000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("text"),
                    max: 3000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.text {
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 255usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("text"),
                        max: 255usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.uv_index {
            if *value > 11i64 {
                return Err(ConstraintError::Maximum {
                    path: ValidationPath::from_field("uv_index"),
                    max: 11i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.uv_index {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("uv_index"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

pub mod review_state {

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

/// Builder for constructing an instance of this type.
pub struct ReviewBuilder<St: review_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<i64>,
        Option<Datetime>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<AtUri<S>>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<i64>,
        Option<Datetime>,
        Option<i64>,
        Option<i64>,
        Option<S>,
        Option<i64>,
        Option<bool>,
        Option<i64>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> Review<S> {
    /// Create a new builder for this type
    pub fn builder() -> ReviewBuilder<review_state::Empty, S> {
        ReviewBuilder::builder()
    }
}

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

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

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `complexity` field (optional)
    pub fn complexity(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `complexity` field to an Option value (optional)
    pub fn maybe_complexity(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `drydownRating` field (optional)
    pub fn drydown_rating(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `drydownRating` field to an Option value (optional)
    pub fn maybe_drydown_rating(mut self, value: Option<i64>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `elevation` field (optional)
    pub fn elevation(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.3 = value.into();
        self
    }
    /// Set the `elevation` field to an Option value (optional)
    pub fn maybe_elevation(mut self, value: Option<i64>) -> Self {
        self._fields.3 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `endRating` field (optional)
    pub fn end_rating(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `endRating` field to an Option value (optional)
    pub fn maybe_end_rating(mut self, value: Option<i64>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St, S: BosStr> ReviewBuilder<St, S>
where
    St: review_state::State,
    St::Fragrance: review_state::IsUnset,
{
    /// Set the `fragrance` field (required)
    pub fn fragrance(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> ReviewBuilder<review_state::SetFragrance<St>, S> {
        self._fields.5 = Option::Some(value.into());
        ReviewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `longevity` field (optional)
    pub fn longevity(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `longevity` field to an Option value (optional)
    pub fn maybe_longevity(mut self, value: Option<i64>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `midProjection` field (optional)
    pub fn mid_projection(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `midProjection` field to an Option value (optional)
    pub fn maybe_mid_projection(mut self, value: Option<i64>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `openingProjection` field (optional)
    pub fn opening_projection(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `openingProjection` field to an Option value (optional)
    pub fn maybe_opening_projection(mut self, value: Option<i64>) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `openingRating` field (optional)
    pub fn opening_rating(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `openingRating` field to an Option value (optional)
    pub fn maybe_opening_rating(mut self, value: Option<i64>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `overallRating` field (optional)
    pub fn overall_rating(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.10 = value.into();
        self
    }
    /// Set the `overallRating` field to an Option value (optional)
    pub fn maybe_overall_rating(mut self, value: Option<i64>) -> Self {
        self._fields.10 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `sillage` field (optional)
    pub fn sillage(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `sillage` field to an Option value (optional)
    pub fn maybe_sillage(mut self, value: Option<i64>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `stage1Temp` field (optional)
    pub fn stage1_temp(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `stage1Temp` field to an Option value (optional)
    pub fn maybe_stage1_temp(mut self, value: Option<i64>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `stage2CompletedAt` field (optional)
    pub fn stage2_completed_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `stage2CompletedAt` field to an Option value (optional)
    pub fn maybe_stage2_completed_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `stage2Temp` field (optional)
    pub fn stage2_temp(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `stage2Temp` field to an Option value (optional)
    pub fn maybe_stage2_temp(mut self, value: Option<i64>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `stage3Temp` field (optional)
    pub fn stage3_temp(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `stage3Temp` field to an Option value (optional)
    pub fn maybe_stage3_temp(mut self, value: Option<i64>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `text` field (optional)
    pub fn text(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.16 = value.into();
        self
    }
    /// Set the `text` field to an Option value (optional)
    pub fn maybe_text(mut self, value: Option<S>) -> Self {
        self._fields.16 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `uvIndex` field (optional)
    pub fn uv_index(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.17 = value.into();
        self
    }
    /// Set the `uvIndex` field to an Option value (optional)
    pub fn maybe_uv_index(mut self, value: Option<i64>) -> Self {
        self._fields.17 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `weatherOptIn` field (optional)
    pub fn weather_opt_in(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.18 = value.into();
        self
    }
    /// Set the `weatherOptIn` field to an Option value (optional)
    pub fn maybe_weather_opt_in(mut self, value: Option<bool>) -> Self {
        self._fields.18 = value;
        self
    }
}

impl<St: review_state::State, S: BosStr> ReviewBuilder<St, S> {
    /// Set the `weightedScore` field (optional)
    pub fn weighted_score(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.19 = value.into();
        self
    }
    /// Set the `weightedScore` field to an Option value (optional)
    pub fn maybe_weighted_score(mut self, value: Option<i64>) -> Self {
        self._fields.19 = value;
        self
    }
}

impl<St, S: BosStr> ReviewBuilder<St, S>
where
    St: review_state::State,
    St::CreatedAt: review_state::IsSet,
    St::Fragrance: review_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Review<S> {
        Review {
            complexity: self._fields.0,
            created_at: self._fields.1.unwrap(),
            drydown_rating: self._fields.2,
            elevation: self._fields.3,
            end_rating: self._fields.4,
            fragrance: self._fields.5.unwrap(),
            longevity: self._fields.6,
            mid_projection: self._fields.7,
            opening_projection: self._fields.8,
            opening_rating: self._fields.9,
            overall_rating: self._fields.10,
            sillage: self._fields.11,
            stage1_temp: self._fields.12,
            stage2_completed_at: self._fields.13,
            stage2_temp: self._fields.14,
            stage3_temp: self._fields.15,
            text: self._fields.16,
            uv_index: self._fields.17,
            weather_opt_in: self._fields.18,
            weighted_score: self._fields.19,
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> Review<S> {
        Review {
            complexity: self._fields.0,
            created_at: self._fields.1.unwrap(),
            drydown_rating: self._fields.2,
            elevation: self._fields.3,
            end_rating: self._fields.4,
            fragrance: self._fields.5.unwrap(),
            longevity: self._fields.6,
            mid_projection: self._fields.7,
            opening_projection: self._fields.8,
            opening_rating: self._fields.9,
            overall_rating: self._fields.10,
            sillage: self._fields.11,
            stage1_temp: self._fields.12,
            stage2_completed_at: self._fields.13,
            stage2_temp: self._fields.14,
            stage3_temp: self._fields.15,
            text: self._fields.16,
            uv_index: self._fields.17,
            weather_opt_in: self._fields.18,
            weighted_score: self._fields.19,
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_social_drydown_review() -> 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("social.drydown.review"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(
                        CowStr::new_static("A single wearing review of a fragrance"),
                    ),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("fragrance"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("complexity"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(5i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Timestamp when the review was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("drydownRating"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(5i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("elevation"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("endRating"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(5i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("fragrance"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Reference to the social.drydown.fragrance record",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::AtUri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("longevity"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(5i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("midProjection"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(5i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("openingProjection"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(5i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("openingRating"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(5i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("overallRating"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(5i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("sillage"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(1i64),
                                    maximum: Some(5i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("stage1Temp"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("stage2CompletedAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Timestamp when Stage 2 was completed (for accurate temperature)",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("stage2Temp"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("stage3Temp"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("text"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Written review (max 255 graphemes)"),
                                    ),
                                    max_length: Some(3000usize),
                                    max_graphemes: Some(255usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("uvIndex"),
                                LexObjectProperty::Integer(LexInteger {
                                    minimum: Some(0i64),
                                    maximum: Some(11i64),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("weatherOptIn"),
                                LexObjectProperty::Boolean(LexBoolean {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("weightedScore"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}