// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: sh.weaver.notebook.theme
//
// 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::{Did, AtUri, Cid};
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::com_atproto::repo::strong_ref::StrongRef;
use crate::sh_weaver::notebook::theme;
/// Custom syntax highlighting theme file (sublime text/textmate theme format)

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct CodeThemeFile<'a> {
    #[serde(borrow)]
    pub content: BlobRef<'a>,
    #[serde(borrow)]
    pub did: Did<'a>,
    #[serde(borrow)]
    pub name: CowStr<'a>,
}

pub type CodeThemeName<'a> = CowStr<'a>;

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Font<'a> {
    ///Font for a notebook
    #[serde(borrow)]
    pub value: FontValue<'a>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum FontValue<'a> {
    #[serde(rename = "sh.weaver.notebook.theme#fontName")]
    FontName(Box<theme::FontName<'a>>),
    #[serde(rename = "sh.weaver.notebook.theme#fontFile")]
    FontFile(Box<theme::FontFile<'a>>),
}

/// Custom woff(2) or ttf font file

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct FontFile<'a> {
    #[serde(borrow)]
    pub content: BlobRef<'a>,
    #[serde(borrow)]
    pub did: Did<'a>,
    #[serde(borrow)]
    pub name: CowStr<'a>,
}

pub type FontName<'a> = CowStr<'a>;
/// Theme for a notebook

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct Theme<'a> {
    ///Syntax highlighting theme for dark mode
    #[serde(borrow)]
    pub dark_code_theme: ThemeDarkCodeTheme<'a>,
    ///Reference to a dark colour scheme
    #[serde(borrow)]
    pub dark_scheme: StrongRef<'a>,
    /// Defaults to `"auto"`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_theme_default_theme")]
    #[serde(borrow)]
    pub default_theme: Option<CowStr<'a>>,
    ///Fonts to be used in the notebook. Can specify a name or list of names (will load if available) or a file or list of files for each. Empty lists will use site defaults.
    #[serde(borrow)]
    pub fonts: ThemeFonts<'a>,
    ///Syntax highlighting theme for light mode
    #[serde(borrow)]
    pub light_code_theme: ThemeLightCodeTheme<'a>,
    ///Reference to a light colour scheme
    #[serde(borrow)]
    pub light_scheme: StrongRef<'a>,
    #[serde(borrow)]
    pub spacing: ThemeSpacing<'a>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ThemeDarkCodeTheme<'a> {
    #[serde(rename = "sh.weaver.notebook.theme#codeThemeName")]
    CodeThemeName(Box<theme::CodeThemeName<'a>>),
    #[serde(rename = "sh.weaver.notebook.theme#codeThemeFile")]
    CodeThemeFile(Box<theme::CodeThemeFile<'a>>),
}

/// Fonts to be used in the notebook. Can specify a name or list of names (will load if available) or a file or list of files for each. Empty lists will use site defaults.

#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase")]
pub struct ThemeFonts<'a> {
    #[serde(borrow)]
    pub body: Vec<crate::sh_weaver::notebook::theme::Font<'a>>,
    #[serde(borrow)]
    pub heading: Vec<crate::sh_weaver::notebook::theme::Font<'a>>,
    #[serde(borrow)]
    pub monospace: Vec<crate::sh_weaver::notebook::theme::Font<'a>>,
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type")]
#[serde(bound(deserialize = "'de: 'a"))]
pub enum ThemeLightCodeTheme<'a> {
    #[serde(rename = "sh.weaver.notebook.theme#codeThemeName")]
    CodeThemeName(Box<theme::CodeThemeName<'a>>),
    #[serde(rename = "sh.weaver.notebook.theme#codeThemeFile")]
    CodeThemeFile(Box<theme::CodeThemeFile<'a>>),
}


#[lexicon]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase")]
pub struct ThemeSpacing<'a> {
    #[serde(borrow)]
    pub base_size: CowStr<'a>,
    #[serde(borrow)]
    pub line_height: CowStr<'a>,
    #[serde(borrow)]
    pub scale: CowStr<'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 ThemeGetRecordOutput<'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: Theme<'a>,
}

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

impl<'a> LexiconSchema for CodeThemeFile<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "codeThemeFile"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.content;
            {
                let size = value.blob().size;
                if size > 20000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("content"),
                        max: 20000usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.content;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["*/*"];
                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("content"),
                        accepted: vec!["*/*".to_string()],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

impl<'a> LexiconSchema for Font<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "font"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<'a> LexiconSchema for FontFile<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "fontFile"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.content;
            {
                let size = value.blob().size;
                if size > 20000usize {
                    return Err(ConstraintError::BlobTooLarge {
                        path: ValidationPath::from_field("content"),
                        max: 20000usize,
                        actual: size,
                    });
                }
            }
        }
        {
            let value = &self.content;
            {
                let mime = value.blob().mime_type.as_str();
                let accepted: &[&str] = &["*/*"];
                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("content"),
                        accepted: vec!["*/*".to_string()],
                        actual: mime.to_string(),
                    });
                }
            }
        }
        Ok(())
    }
}

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

#[derive(Debug, Serialize, Deserialize)]
pub struct ThemeRecord;
impl XrpcResp for ThemeRecord {
    const NSID: &'static str = "sh.weaver.notebook.theme";
    const ENCODING: &'static str = "application/json";
    type Output<'de> = ThemeGetRecordOutput<'de>;
    type Err<'de> = RecordError<'de>;
}

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

impl Collection for Theme<'_> {
    const NSID: &'static str = "sh.weaver.notebook.theme";
    type Record = ThemeRecord;
}

impl Collection for ThemeRecord {
    const NSID: &'static str = "sh.weaver.notebook.theme";
    type Record = ThemeRecord;
}

impl<'a> LexiconSchema for Theme<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

/// Builder for constructing an instance of this type
pub struct CodeThemeFileBuilder<'a, S: code_theme_file_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<BlobRef<'a>>, Option<Did<'a>>, Option<CowStr<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> CodeThemeFile<'a> {
    /// Create a new builder for this type
    pub fn new() -> CodeThemeFileBuilder<'a, code_theme_file_state::Empty> {
        CodeThemeFileBuilder::new()
    }
}

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

impl<'a, S> CodeThemeFileBuilder<'a, S>
where
    S: code_theme_file_state::State,
    S::Content: code_theme_file_state::IsUnset,
{
    /// Set the `content` field (required)
    pub fn content(
        mut self,
        value: impl Into<BlobRef<'a>>,
    ) -> CodeThemeFileBuilder<'a, code_theme_file_state::SetContent<S>> {
        self._fields.0 = Option::Some(value.into());
        CodeThemeFileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> CodeThemeFileBuilder<'a, S>
where
    S: code_theme_file_state::State,
    S::Did: code_theme_file_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> CodeThemeFileBuilder<'a, code_theme_file_state::SetDid<S>> {
        self._fields.1 = Option::Some(value.into());
        CodeThemeFileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

impl<'a, S> CodeThemeFileBuilder<'a, S>
where
    S: code_theme_file_state::State,
    S::Content: code_theme_file_state::IsSet,
    S::Name: code_theme_file_state::IsSet,
    S::Did: code_theme_file_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> CodeThemeFile<'a> {
        CodeThemeFile {
            content: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            name: 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>,
        >,
    ) -> CodeThemeFile<'a> {
        CodeThemeFile {
            content: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            name: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_sh_weaver_notebook_theme() -> 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("sh.weaver.notebook.theme"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("codeThemeFile"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Custom syntax highlighting theme file (sublime text/textmate theme format)",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("name"), SmolStr::new_static("did"),
                            SmolStr::new_static("content")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("content"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("codeThemeName"),
                LexUserType::String(LexString { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("font"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("value")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("value"),
                            LexObjectProperty::Union(LexRefUnion {
                                description: Some(
                                    CowStr::new_static("Font for a notebook"),
                                ),
                                refs: vec![
                                    CowStr::new_static("#fontName"),
                                    CowStr::new_static("#fontFile")
                                ],
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("fontFile"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static("Custom woff(2) or ttf font file"),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("name"), SmolStr::new_static("did"),
                            SmolStr::new_static("content")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("content"),
                            LexObjectProperty::Blob(LexBlob { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("did"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Did),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("name"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("fontName"),
                LexUserType::String(LexString { ..Default::default() }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Record(LexRecord {
                    description: Some(CowStr::new_static("Theme for a notebook")),
                    key: Some(CowStr::new_static("tid")),
                    record: LexRecordRecord::Object(LexObject {
                        required: Some(
                            vec![
                                SmolStr::new_static("darkScheme"),
                                SmolStr::new_static("lightScheme"),
                                SmolStr::new_static("fonts"),
                                SmolStr::new_static("spacing"),
                                SmolStr::new_static("darkCodeTheme"),
                                SmolStr::new_static("lightCodeTheme")
                            ],
                        ),
                        properties: {
                            #[allow(unused_mut)]
                            let mut map = BTreeMap::new();
                            map.insert(
                                SmolStr::new_static("darkCodeTheme"),
                                LexObjectProperty::Union(LexRefUnion {
                                    description: Some(
                                        CowStr::new_static(
                                            "Syntax highlighting theme for dark mode",
                                        ),
                                    ),
                                    refs: vec![
                                        CowStr::new_static("#codeThemeName"),
                                        CowStr::new_static("#codeThemeFile")
                                    ],
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("darkScheme"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("defaultTheme"),
                                LexObjectProperty::String(LexString {
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("fonts"),
                                LexObjectProperty::Object(LexObject {
                                    description: Some(
                                        CowStr::new_static(
                                            "Fonts to be used in the notebook. Can specify a name or list of names (will load if available) or a file or list of files for each. Empty lists will use site defaults.",
                                        ),
                                    ),
                                    required: Some(
                                        vec![
                                            SmolStr::new_static("body"), SmolStr::new_static("heading"),
                                            SmolStr::new_static("monospace")
                                        ],
                                    ),
                                    properties: {
                                        #[allow(unused_mut)]
                                        let mut map = BTreeMap::new();
                                        map.insert(
                                            SmolStr::new_static("body"),
                                            LexObjectProperty::Array(LexArray {
                                                items: LexArrayItem::Ref(LexRef {
                                                    r#ref: CowStr::new_static("#font"),
                                                    ..Default::default()
                                                }),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("heading"),
                                            LexObjectProperty::Array(LexArray {
                                                items: LexArrayItem::Ref(LexRef {
                                                    r#ref: CowStr::new_static("#font"),
                                                    ..Default::default()
                                                }),
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("monospace"),
                                            LexObjectProperty::Array(LexArray {
                                                items: LexArrayItem::Ref(LexRef {
                                                    r#ref: CowStr::new_static("#font"),
                                                    ..Default::default()
                                                }),
                                                ..Default::default()
                                            }),
                                        );
                                        map
                                    },
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lightCodeTheme"),
                                LexObjectProperty::Union(LexRefUnion {
                                    description: Some(
                                        CowStr::new_static(
                                            "Syntax highlighting theme for light mode",
                                        ),
                                    ),
                                    refs: vec![
                                        CowStr::new_static("#codeThemeName"),
                                        CowStr::new_static("#codeThemeFile")
                                    ],
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("lightScheme"),
                                LexObjectProperty::Ref(LexRef {
                                    r#ref: CowStr::new_static("com.atproto.repo.strongRef"),
                                    ..Default::default()
                                }),
                            );
                            map.insert(
                                SmolStr::new_static("spacing"),
                                LexObjectProperty::Object(LexObject {
                                    required: Some(
                                        vec![
                                            SmolStr::new_static("baseSize"),
                                            SmolStr::new_static("lineHeight"),
                                            SmolStr::new_static("scale")
                                        ],
                                    ),
                                    properties: {
                                        #[allow(unused_mut)]
                                        let mut map = BTreeMap::new();
                                        map.insert(
                                            SmolStr::new_static("baseSize"),
                                            LexObjectProperty::String(LexString {
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("lineHeight"),
                                            LexObjectProperty::String(LexString {
                                                ..Default::default()
                                            }),
                                        );
                                        map.insert(
                                            SmolStr::new_static("scale"),
                                            LexObjectProperty::String(LexString {
                                                ..Default::default()
                                            }),
                                        );
                                        map
                                    },
                                    ..Default::default()
                                }),
                            );
                            map
                        },
                        ..Default::default()
                    }),
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

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

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

impl<'a> Font<'a> {
    /// Create a new builder for this type
    pub fn new() -> FontBuilder<'a, font_state::Empty> {
        FontBuilder::new()
    }
}

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

impl<'a, S> FontBuilder<'a, S>
where
    S: font_state::State,
    S::Value: font_state::IsUnset,
{
    /// Set the `value` field (required)
    pub fn value(
        mut self,
        value: impl Into<FontValue<'a>>,
    ) -> FontBuilder<'a, font_state::SetValue<S>> {
        self._fields.0 = Option::Some(value.into());
        FontBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> FontBuilder<'a, S>
where
    S: font_state::State,
    S::Value: font_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Font<'a> {
        Font {
            value: self._fields.0.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>,
        >,
    ) -> Font<'a> {
        Font {
            value: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

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

/// Builder for constructing an instance of this type
pub struct FontFileBuilder<'a, S: font_file_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (Option<BlobRef<'a>>, Option<Did<'a>>, Option<CowStr<'a>>),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> FontFile<'a> {
    /// Create a new builder for this type
    pub fn new() -> FontFileBuilder<'a, font_file_state::Empty> {
        FontFileBuilder::new()
    }
}

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

impl<'a, S> FontFileBuilder<'a, S>
where
    S: font_file_state::State,
    S::Content: font_file_state::IsUnset,
{
    /// Set the `content` field (required)
    pub fn content(
        mut self,
        value: impl Into<BlobRef<'a>>,
    ) -> FontFileBuilder<'a, font_file_state::SetContent<S>> {
        self._fields.0 = Option::Some(value.into());
        FontFileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> FontFileBuilder<'a, S>
where
    S: font_file_state::State,
    S::Did: font_file_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<'a>>,
    ) -> FontFileBuilder<'a, font_file_state::SetDid<S>> {
        self._fields.1 = Option::Some(value.into());
        FontFileBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

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

impl<'a, S> FontFileBuilder<'a, S>
where
    S: font_file_state::State,
    S::Name: font_file_state::IsSet,
    S::Did: font_file_state::IsSet,
    S::Content: font_file_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> FontFile<'a> {
        FontFile {
            content: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            name: 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>,
        >,
    ) -> FontFile<'a> {
        FontFile {
            content: self._fields.0.unwrap(),
            did: self._fields.1.unwrap(),
            name: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn _default_theme_default_theme() -> Option<CowStr<'static>> {
    Some(CowStr::from("auto"))
}

impl<'a> LexiconSchema for ThemeFonts<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "ThemeFonts"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod theme_fonts_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 Heading;
        type Monospace;
        type Body;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Heading = Unset;
        type Monospace = Unset;
        type Body = Unset;
    }
    ///State transition - sets the `heading` field to Set
    pub struct SetHeading<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetHeading<S> {}
    impl<S: State> State for SetHeading<S> {
        type Heading = Set<members::heading>;
        type Monospace = S::Monospace;
        type Body = S::Body;
    }
    ///State transition - sets the `monospace` field to Set
    pub struct SetMonospace<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetMonospace<S> {}
    impl<S: State> State for SetMonospace<S> {
        type Heading = S::Heading;
        type Monospace = Set<members::monospace>;
        type Body = S::Body;
    }
    ///State transition - sets the `body` field to Set
    pub struct SetBody<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetBody<S> {}
    impl<S: State> State for SetBody<S> {
        type Heading = S::Heading;
        type Monospace = S::Monospace;
        type Body = Set<members::body>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `heading` field
        pub struct heading(());
        ///Marker type for the `monospace` field
        pub struct monospace(());
        ///Marker type for the `body` field
        pub struct body(());
    }
}

/// Builder for constructing an instance of this type
pub struct ThemeFontsBuilder<'a, S: theme_fonts_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
        Option<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
        Option<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> ThemeFonts<'a> {
    /// Create a new builder for this type
    pub fn new() -> ThemeFontsBuilder<'a, theme_fonts_state::Empty> {
        ThemeFontsBuilder::new()
    }
}

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

impl<'a, S> ThemeFontsBuilder<'a, S>
where
    S: theme_fonts_state::State,
    S::Body: theme_fonts_state::IsUnset,
{
    /// Set the `body` field (required)
    pub fn body(
        mut self,
        value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
    ) -> ThemeFontsBuilder<'a, theme_fonts_state::SetBody<S>> {
        self._fields.0 = Option::Some(value.into());
        ThemeFontsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ThemeFontsBuilder<'a, S>
where
    S: theme_fonts_state::State,
    S::Heading: theme_fonts_state::IsUnset,
{
    /// Set the `heading` field (required)
    pub fn heading(
        mut self,
        value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
    ) -> ThemeFontsBuilder<'a, theme_fonts_state::SetHeading<S>> {
        self._fields.1 = Option::Some(value.into());
        ThemeFontsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ThemeFontsBuilder<'a, S>
where
    S: theme_fonts_state::State,
    S::Monospace: theme_fonts_state::IsUnset,
{
    /// Set the `monospace` field (required)
    pub fn monospace(
        mut self,
        value: impl Into<Vec<crate::sh_weaver::notebook::theme::Font<'a>>>,
    ) -> ThemeFontsBuilder<'a, theme_fonts_state::SetMonospace<S>> {
        self._fields.2 = Option::Some(value.into());
        ThemeFontsBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ThemeFontsBuilder<'a, S>
where
    S: theme_fonts_state::State,
    S::Heading: theme_fonts_state::IsSet,
    S::Monospace: theme_fonts_state::IsSet,
    S::Body: theme_fonts_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> ThemeFonts<'a> {
        ThemeFonts {
            body: self._fields.0.unwrap(),
            heading: self._fields.1.unwrap(),
            monospace: 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>,
        >,
    ) -> ThemeFonts<'a> {
        ThemeFonts {
            body: self._fields.0.unwrap(),
            heading: self._fields.1.unwrap(),
            monospace: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

impl<'a> LexiconSchema for ThemeSpacing<'a> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.theme"
    }
    fn def_name() -> &'static str {
        "ThemeSpacing"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_theme()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

pub mod theme_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 Fonts;
        type DarkScheme;
        type Spacing;
        type LightScheme;
        type DarkCodeTheme;
        type LightCodeTheme;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Fonts = Unset;
        type DarkScheme = Unset;
        type Spacing = Unset;
        type LightScheme = Unset;
        type DarkCodeTheme = Unset;
        type LightCodeTheme = Unset;
    }
    ///State transition - sets the `fonts` field to Set
    pub struct SetFonts<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetFonts<S> {}
    impl<S: State> State for SetFonts<S> {
        type Fonts = Set<members::fonts>;
        type DarkScheme = S::DarkScheme;
        type Spacing = S::Spacing;
        type LightScheme = S::LightScheme;
        type DarkCodeTheme = S::DarkCodeTheme;
        type LightCodeTheme = S::LightCodeTheme;
    }
    ///State transition - sets the `dark_scheme` field to Set
    pub struct SetDarkScheme<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDarkScheme<S> {}
    impl<S: State> State for SetDarkScheme<S> {
        type Fonts = S::Fonts;
        type DarkScheme = Set<members::dark_scheme>;
        type Spacing = S::Spacing;
        type LightScheme = S::LightScheme;
        type DarkCodeTheme = S::DarkCodeTheme;
        type LightCodeTheme = S::LightCodeTheme;
    }
    ///State transition - sets the `spacing` field to Set
    pub struct SetSpacing<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetSpacing<S> {}
    impl<S: State> State for SetSpacing<S> {
        type Fonts = S::Fonts;
        type DarkScheme = S::DarkScheme;
        type Spacing = Set<members::spacing>;
        type LightScheme = S::LightScheme;
        type DarkCodeTheme = S::DarkCodeTheme;
        type LightCodeTheme = S::LightCodeTheme;
    }
    ///State transition - sets the `light_scheme` field to Set
    pub struct SetLightScheme<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLightScheme<S> {}
    impl<S: State> State for SetLightScheme<S> {
        type Fonts = S::Fonts;
        type DarkScheme = S::DarkScheme;
        type Spacing = S::Spacing;
        type LightScheme = Set<members::light_scheme>;
        type DarkCodeTheme = S::DarkCodeTheme;
        type LightCodeTheme = S::LightCodeTheme;
    }
    ///State transition - sets the `dark_code_theme` field to Set
    pub struct SetDarkCodeTheme<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetDarkCodeTheme<S> {}
    impl<S: State> State for SetDarkCodeTheme<S> {
        type Fonts = S::Fonts;
        type DarkScheme = S::DarkScheme;
        type Spacing = S::Spacing;
        type LightScheme = S::LightScheme;
        type DarkCodeTheme = Set<members::dark_code_theme>;
        type LightCodeTheme = S::LightCodeTheme;
    }
    ///State transition - sets the `light_code_theme` field to Set
    pub struct SetLightCodeTheme<S: State = Empty>(PhantomData<fn() -> S>);
    impl<S: State> sealed::Sealed for SetLightCodeTheme<S> {}
    impl<S: State> State for SetLightCodeTheme<S> {
        type Fonts = S::Fonts;
        type DarkScheme = S::DarkScheme;
        type Spacing = S::Spacing;
        type LightScheme = S::LightScheme;
        type DarkCodeTheme = S::DarkCodeTheme;
        type LightCodeTheme = Set<members::light_code_theme>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `fonts` field
        pub struct fonts(());
        ///Marker type for the `dark_scheme` field
        pub struct dark_scheme(());
        ///Marker type for the `spacing` field
        pub struct spacing(());
        ///Marker type for the `light_scheme` field
        pub struct light_scheme(());
        ///Marker type for the `dark_code_theme` field
        pub struct dark_code_theme(());
        ///Marker type for the `light_code_theme` field
        pub struct light_code_theme(());
    }
}

/// Builder for constructing an instance of this type
pub struct ThemeBuilder<'a, S: theme_state::State> {
    _state: PhantomData<fn() -> S>,
    _fields: (
        Option<ThemeDarkCodeTheme<'a>>,
        Option<StrongRef<'a>>,
        Option<CowStr<'a>>,
        Option<ThemeFonts<'a>>,
        Option<ThemeLightCodeTheme<'a>>,
        Option<StrongRef<'a>>,
        Option<ThemeSpacing<'a>>,
    ),
    _lifetime: PhantomData<&'a ()>,
}

impl<'a> Theme<'a> {
    /// Create a new builder for this type
    pub fn new() -> ThemeBuilder<'a, theme_state::Empty> {
        ThemeBuilder::new()
    }
}

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

impl<'a, S> ThemeBuilder<'a, S>
where
    S: theme_state::State,
    S::DarkCodeTheme: theme_state::IsUnset,
{
    /// Set the `darkCodeTheme` field (required)
    pub fn dark_code_theme(
        mut self,
        value: impl Into<ThemeDarkCodeTheme<'a>>,
    ) -> ThemeBuilder<'a, theme_state::SetDarkCodeTheme<S>> {
        self._fields.0 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ThemeBuilder<'a, S>
where
    S: theme_state::State,
    S::DarkScheme: theme_state::IsUnset,
{
    /// Set the `darkScheme` field (required)
    pub fn dark_scheme(
        mut self,
        value: impl Into<StrongRef<'a>>,
    ) -> ThemeBuilder<'a, theme_state::SetDarkScheme<S>> {
        self._fields.1 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S: theme_state::State> ThemeBuilder<'a, S> {
    /// Set the `defaultTheme` field (optional)
    pub fn default_theme(mut self, value: impl Into<Option<CowStr<'a>>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `defaultTheme` field to an Option value (optional)
    pub fn maybe_default_theme(mut self, value: Option<CowStr<'a>>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<'a, S> ThemeBuilder<'a, S>
where
    S: theme_state::State,
    S::Fonts: theme_state::IsUnset,
{
    /// Set the `fonts` field (required)
    pub fn fonts(
        mut self,
        value: impl Into<ThemeFonts<'a>>,
    ) -> ThemeBuilder<'a, theme_state::SetFonts<S>> {
        self._fields.3 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ThemeBuilder<'a, S>
where
    S: theme_state::State,
    S::LightCodeTheme: theme_state::IsUnset,
{
    /// Set the `lightCodeTheme` field (required)
    pub fn light_code_theme(
        mut self,
        value: impl Into<ThemeLightCodeTheme<'a>>,
    ) -> ThemeBuilder<'a, theme_state::SetLightCodeTheme<S>> {
        self._fields.4 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ThemeBuilder<'a, S>
where
    S: theme_state::State,
    S::LightScheme: theme_state::IsUnset,
{
    /// Set the `lightScheme` field (required)
    pub fn light_scheme(
        mut self,
        value: impl Into<StrongRef<'a>>,
    ) -> ThemeBuilder<'a, theme_state::SetLightScheme<S>> {
        self._fields.5 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ThemeBuilder<'a, S>
where
    S: theme_state::State,
    S::Spacing: theme_state::IsUnset,
{
    /// Set the `spacing` field (required)
    pub fn spacing(
        mut self,
        value: impl Into<ThemeSpacing<'a>>,
    ) -> ThemeBuilder<'a, theme_state::SetSpacing<S>> {
        self._fields.6 = Option::Some(value.into());
        ThemeBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _lifetime: PhantomData,
        }
    }
}

impl<'a, S> ThemeBuilder<'a, S>
where
    S: theme_state::State,
    S::Fonts: theme_state::IsSet,
    S::DarkScheme: theme_state::IsSet,
    S::Spacing: theme_state::IsSet,
    S::LightScheme: theme_state::IsSet,
    S::DarkCodeTheme: theme_state::IsSet,
    S::LightCodeTheme: theme_state::IsSet,
{
    /// Build the final struct
    pub fn build(self) -> Theme<'a> {
        Theme {
            dark_code_theme: self._fields.0.unwrap(),
            dark_scheme: self._fields.1.unwrap(),
            default_theme: self._fields.2.or_else(|| Some(CowStr::from("auto"))),
            fonts: self._fields.3.unwrap(),
            light_code_theme: self._fields.4.unwrap(),
            light_scheme: self._fields.5.unwrap(),
            spacing: self._fields.6.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>,
        >,
    ) -> Theme<'a> {
        Theme {
            dark_code_theme: self._fields.0.unwrap(),
            dark_scheme: self._fields.1.unwrap(),
            default_theme: self._fields.2.or_else(|| Some(CowStr::from("auto"))),
            fonts: self._fields.3.unwrap(),
            light_code_theme: self._fields.4.unwrap(),
            light_scheme: self._fields.5.unwrap(),
            spacing: self._fields.6.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}