// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: io.kich.recipe.recipe
//
// 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, UriValue};
use jacquard_common::types::uri::{RecordUri, UriError};
use jacquard_common::xrpc::XrpcResp;
use jacquard_derive::{IntoStatic, lexicon};
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::com_atproto::repo::strong_ref::StrongRef;
use crate::io_kich::recipe::recipe;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Ingredient<'a> {
    ///[Deprecated] Amount needed in grams. Use measuredAmount/measuredUnit instead.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub grams: Option<i64>,
    ///Optional group name for organizing ingredients (e.g., 'For the sauce:', 'For the pasta:')
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub group: Option<CowStr<'a>>,
    ///Heuristic amount from parsed ingredient text (e.g., 2 in "2 cups")
    #[serde(skip_serializing_if = "Option::is_none")]
    pub heuristic_amount: Option<i64>,
    ///Heuristic unit from parsed ingredient text (e.g., cup, cookies)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub heuristic_unit: Option<CowStr<'a>>,
    ///Unique identifier for this ingredient
    #[serde(borrow)]
    pub id: CowStr<'a>,
    ///Whether this ingredient is detached (doesn't count towards recipe completeness)  Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_ingredient_is_detached")]
    pub is_detached: Option<bool>,
    ///Whether this ingredient is optional  Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_ingredient_is_optional")]
    pub is_optional: Option<bool>,
    ///Measured amount needed (e.g., 250, 1.5)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub measured_amount: Option<i64>,
    ///Measured unit (g, kg, oz, lb, ml)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub measured_unit: Option<CowStr<'a>>,
    ///Ingredient name
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Optional notes about this ingredient (e.g., original quantity)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub notes: Option<CowStr<'a>>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct InstructionStep<'a> {
    ///Unique identifier for this instruction step
    #[serde(borrow)]
    pub id: CowStr<'a>,
    ///Instruction text
    #[serde(borrow)]
    pub value: CowStr<'a>,
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Recipe<'a> {
    ///Cooking time in minutes
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cook_time_minutes: Option<i64>,
    ///When this recipe was created
    pub created_at: Datetime,
    ///Reference to the user who created this recipe
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub created_by: Option<StrongRef<'a>>,
    ///Recipe description
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub description: Option<CowStr<'a>>,
    ///Vector embedding for semantic similarity search (1024 dimensions, stored as JSON array of numbers)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub embedding: Option<CowStr<'a>>,
    ///[Deprecated] Image URL for the recipe. Use images blob array instead. Kept for legacy fallback.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub image_url: Option<UriValue<'a>>,
    ///Recipe images as blobs (hero first; preferred over imageUrl)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub images: Option<Vec<BlobRef<'a>>>,
    ///Recipe ingredients
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub ingredients: Option<Vec<recipe::Ingredient<'a>>>,
    ///Cooking instructions as an array of steps
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub instructions: Option<Vec<recipe::InstructionStep<'a>>>,
    ///Whether this recipe is private (only visible to household members)  Defaults to `false`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_recipe_is_private")]
    pub is_private: Option<bool>,
    ///Recipe name
    #[serde(borrow)]
    pub name: CowStr<'a>,
    ///Preparation time in minutes
    #[serde(skip_serializing_if = "Option::is_none")]
    pub prep_time_minutes: Option<i64>,
    ///Number of servings this recipe makes  Defaults to `1`.
    #[serde(default = "_default_recipe_servings")]
    pub servings: i64,
    ///Source name (book, magazine, blog)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub source: Option<CowStr<'a>>,
    ///Tags for categorizing the recipe
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub tags: Option<Vec<recipe::Tag<'a>>>,
    ///When this recipe was last updated
    #[serde(skip_serializing_if = "Option::is_none")]
    pub updated_at: Option<Datetime>,
    ///Source URL of the recipe
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub url: Option<UriValue<'a>>,
    ///Optional reference to the original recipe this is a variation of (for attribution and variation discovery)
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(borrow)]
    pub variation_of: Option<StrongRef<'a>>,
}

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


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct Tag<'a> {
    ///Tag identifier
    #[serde(borrow)]
    pub id: CowStr<'a>,
    ///Tag display name
    #[serde(borrow)]
    pub name: CowStr<'a>,
}

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

impl<'a> LexiconSchema for Ingredient<'a> {
    fn nsid() -> &'static str {
        "io.kich.recipe.recipe"
    }
    fn def_name() -> &'static str {
        "ingredient"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_kich_recipe_recipe()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for InstructionStep<'a> {
    fn nsid() -> &'static str {
        "io.kich.recipe.recipe"
    }
    fn def_name() -> &'static str {
        "instructionStep"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_kich_recipe_recipe()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

#[derive(Debug, Serialize, Deserialize)]
pub struct RecipeRecord;
impl XrpcResp for RecipeRecord {
    const NSID: &'static str = "io.kich.recipe.recipe";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = RecipeGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

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

impl Collection for Recipe<'_> {
    const NSID: &'static str = "io.kich.recipe.recipe";
    type Record = RecipeRecord;
}

impl Collection for RecipeRecord {
    const NSID: &'static str = "io.kich.recipe.recipe";
    type Record = RecipeRecord;
}

impl<'a> LexiconSchema for Recipe<'a> {
    fn nsid() -> &'static str {
        "io.kich.recipe.recipe"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_kich_recipe_recipe()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.images {
            #[allow(unused_comparisons)]
            if value.len() > 10usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("images"),
                    max: 10usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Tag<'a> {
    fn nsid() -> &'static str {
        "io.kich.recipe.recipe"
    }
    fn def_name() -> &'static str {
        "tag"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_io_kich_recipe_recipe()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn _default_ingredient_is_detached() -> Option<bool> {
    Some(false)
}

fn _default_ingredient_is_optional() -> Option<bool> {
    Some(false)
}

fn lexicon_doc_io_kich_recipe_recipe() -> 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("io.kich.recipe.recipe"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("ingredient"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("id"), SmolStr::new_static("name")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("grams"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("group"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Optional group name for organizing ingredients (e.g., 'For the sauce:', 'For the pasta:')",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heuristicAmount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("heuristicUnit"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Heuristic unit from parsed ingredient text (e.g., cup, cookies)",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Unique identifier for this ingredient"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("isDetached"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("isOptional"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("measuredAmount"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("measuredUnit"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Measured unit (g, kg, oz, lb, ml)"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Ingredient name")),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("notes"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Optional notes about this ingredient (e.g., original quantity)",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("instructionStep"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("id"), SmolStr::new_static("value")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Unique identifier for this instruction step",
                                    ),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("value"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Instruction text")),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("name"),
                                SmolStr::new_static("servings"),
                                SmolStr::new_static("createdAt")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("cookTimeMinutes"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When this recipe was created"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("createdBy"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("description"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("Recipe description")),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("embedding"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "Vector embedding for semantic similarity search (1024 dimensions, stored as JSON array of numbers)",
                                        ),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("imageUrl"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static(
                                            "[Deprecated] Image URL for the recipe. Use images blob array instead. Kept for legacy fallback.",
                                        ),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("images"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Recipe images as blobs (hero first; preferred over imageUrl)",
                                        ),
                                    ),
                                    items: LexArrayItem::Blob(LexBlob { ..Default::default() }),
                                    max_length: Some(10usize),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("ingredients"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(CowStr::new_static("Recipe ingredients")),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("#ingredient"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("instructions"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static(
                                            "Cooking instructions as an array of steps",
                                        ),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("#instructionStep"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("isPrivate"),
                                LexObjectProperty::Boolean(LexBoolean {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("name"),
                                LexObjectProperty::String(LexString {
                                    description: Some(CowStr::new_static("Recipe name")),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("prepTimeMinutes"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("servings"),
                                LexObjectProperty::Integer(LexInteger {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("source"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Source name (book, magazine, blog)"),
                                    ),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("tags"),
                                LexObjectProperty::Array(LexArray {
                                    description: Some(
                                        CowStr::new_static("Tags for categorizing the recipe"),
                                    ),
                                    items: LexArrayItem::Ref(LexRef {
                                        r#ref: CowStr::new_static("#tag"),
                                        ..Default::default()
                                    }),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("updatedAt"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("When this recipe was last updated"),
                                    ),
                                    format: Some(LexStringFormat::Datetime),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("url"),
                                LexObjectProperty::String(LexString {
                                    description: Some(
                                        CowStr::new_static("Source URL of the recipe"),
                                    ),
                                    format: Some(LexStringFormat::Uri),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("variationOf"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("tag"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("id"), SmolStr::new_static("name")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Tag identifier")),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Tag display name")),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

fn _default_recipe_is_private() -> Option<bool> {
    Some(false)
}

fn _default_recipe_servings() -> i64 {
    1i64
}

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

/// Builder for constructing an instance of this type
pub struct RecipeBuilder<'a, S: recipe_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<i64>,
        Option<Datetime>,
        Option<StrongRef<'a>>,
        Option<CowStr<'a>>,
        Option<CowStr<'a>>,
        Option<UriValue<'a>>,
        Option<Vec<BlobRef<'a>>>,
        Option<Vec<recipe::Ingredient<'a>>>,
        Option<Vec<recipe::InstructionStep<'a>>>,
        Option<bool>,
        Option<CowStr<'a>>,
        Option<i64>,
        Option<i64>,
        Option<CowStr<'a>>,
        Option<Vec<recipe::Tag<'a>>>,
        Option<Datetime>,
        Option<UriValue<'a>>,
        Option<StrongRef<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Recipe<'a> {
    /// Create a new builder for this type
    pub fn new() -> RecipeBuilder<'a, recipe_state::Empty> {
        RecipeBuilder::new()
    }
}

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

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `cookTimeMinutes` field (optional)
    pub fn cook_time_minutes(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `cookTimeMinutes` field to an Option value (optional)
    pub fn maybe_cook_time_minutes(mut self, value: Option<i64>) -> Self {
        self._fields.0 = value;
        self
    }
}

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

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `createdBy` field (optional)
    pub fn created_by(mut self, value: impl Into<Option<StrongRef<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `createdBy` field to an Option value (optional)
    pub fn maybe_created_by(mut self, value: Option<StrongRef<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

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

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

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `imageUrl` field (optional)
    pub fn image_url(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `imageUrl` field to an Option value (optional)
    pub fn maybe_image_url(mut self, value: Option<UriValue<'a>>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `images` field (optional)
    pub fn images(mut self, value: impl Into<Option<Vec<BlobRef<'a>>>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `images` field to an Option value (optional)
    pub fn maybe_images(mut self, value: Option<Vec<BlobRef<'a>>>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `ingredients` field (optional)
    pub fn ingredients(
        mut self,
        value: impl Into<Option<Vec<recipe::Ingredient<'a>>>>,
    ) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `ingredients` field to an Option value (optional)
    pub fn maybe_ingredients(
        mut self,
        value: Option<Vec<recipe::Ingredient<'a>>>,
    ) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `instructions` field (optional)
    pub fn instructions(
        mut self,
        value: impl Into<Option<Vec<recipe::InstructionStep<'a>>>>,
    ) -> Self {
        self._fields.8 = value.into();
        self
    }
    /// Set the `instructions` field to an Option value (optional)
    pub fn maybe_instructions(
        mut self,
        value: Option<Vec<recipe::InstructionStep<'a>>>,
    ) -> Self {
        self._fields.8 = value;
        self
    }
}

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `isPrivate` field (optional)
    pub fn is_private(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `isPrivate` field to an Option value (optional)
    pub fn maybe_is_private(mut self, value: Option<bool>) -> Self {
        self._fields.9 = value;
        self
    }
}

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

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `prepTimeMinutes` field (optional)
    pub fn prep_time_minutes(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `prepTimeMinutes` field to an Option value (optional)
    pub fn maybe_prep_time_minutes(mut self, value: Option<i64>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<'a, S> RecipeBuilder<'a, S>
where
    S: recipe_state::State,
    S::Servings: recipe_state::IsUnset,
{
    /// Set the `servings` field (required)
    pub fn servings(
        mut self,
        value: impl Into<i64>,
    ) -> RecipeBuilder<'a, recipe_state::SetServings<S>> {
        self._fields.12 = Option::Some(value.into());
        RecipeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `tags` field (optional)
    pub fn tags(mut self, value: impl Into<Option<Vec<recipe::Tag<'a>>>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `tags` field to an Option value (optional)
    pub fn maybe_tags(mut self, value: Option<Vec<recipe::Tag<'a>>>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `updatedAt` field (optional)
    pub fn updated_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.15 = value.into();
        self
    }
    /// Set the `updatedAt` field to an Option value (optional)
    pub fn maybe_updated_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.15 = value;
        self
    }
}

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `url` field (optional)
    pub fn url(mut self, value: impl Into<Option<UriValue<'a>>>) -> Self {
        self._fields.16 = value.into();
        self
    }
    /// Set the `url` field to an Option value (optional)
    pub fn maybe_url(mut self, value: Option<UriValue<'a>>) -> Self {
        self._fields.16 = value;
        self
    }
}

impl<'a, S: recipe_state::State> RecipeBuilder<'a, S> {
    /// Set the `variationOf` field (optional)
    pub fn variation_of(mut self, value: impl Into<Option<StrongRef<'a>>>) -> Self {
        self._fields.17 = value.into();
        self
    }
    /// Set the `variationOf` field to an Option value (optional)
    pub fn maybe_variation_of(mut self, value: Option<StrongRef<'a>>) -> Self {
        self._fields.17 = value;
        self
    }
}

impl<'a, S> RecipeBuilder<'a, S>
where
    S: recipe_state::State,
    S::Servings: recipe_state::IsSet,
    S::CreatedAt: recipe_state::IsSet,
    S::Name: recipe_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Recipe<'a> {
        Recipe {
            cook_time_minutes: self._fields.0,
            created_at: self._fields.1.unwrap(),
            created_by: self._fields.2,
            description: self._fields.3,
            embedding: self._fields.4,
            image_url: self._fields.5,
            images: self._fields.6,
            ingredients: self._fields.7,
            instructions: self._fields.8,
            is_private: self._fields.9.or_else(|| Some(false)),
            name: self._fields.10.unwrap(),
            prep_time_minutes: self._fields.11,
            servings: self._fields.12.unwrap(),
            source: self._fields.13,
            tags: self._fields.14,
            updated_at: self._fields.15,
            url: self._fields.16,
            variation_of: self._fields.17,
            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>,
        >,
    ) -> Recipe<'a> {
        Recipe {
            cook_time_minutes: self._fields.0,
            created_at: self._fields.1.unwrap(),
            created_by: self._fields.2,
            description: self._fields.3,
            embedding: self._fields.4,
            image_url: self._fields.5,
            images: self._fields.6,
            ingredients: self._fields.7,
            instructions: self._fields.8,
            is_private: self._fields.9.or_else(|| Some(false)),
            name: self._fields.10.unwrap(),
            prep_time_minutes: self._fields.11,
            servings: self._fields.12.unwrap(),
            source: self._fields.13,
            tags: self._fields.14,
            updated_at: self._fields.15,
            url: self._fields.16,
            variation_of: self._fields.17,
            extra_data: Some(extra_data),
        }
    }
}