// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: app.offprint.block.callout
//
// 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;
use jacquard_common::{CowStr, BosStr, DefaultStr, FromStaticStr};

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

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

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Callout<S: BosStr = DefaultStr> {
    ///Background color (CSS color value)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub color: Option<S>,
    ///Emoji icon for the callout  Defaults to `"💡"`.
    #[serde(skip_serializing_if = "Option::is_none")]
    #[serde(default = "_default_callout_emoji")]
    pub emoji: Option<S>,
    ///Facets for text formatting
    #[serde(skip_serializing_if = "Option::is_none")]
    pub facets: Option<Vec<Data<S>>>,
    ///The callout text content
    pub plaintext: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

impl<S: BosStr> LexiconSchema for Callout<S> {
    fn nsid() -> &'static str {
        "app.offprint.block.callout"
    }
    fn def_name() -> &'static str {
        "main"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_offprint_block_callout()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

fn _default_callout_emoji<S: FromStaticStr>() -> ::core::option::Option<S> {
    Some(S::from_static("💡"))
}

fn lexicon_doc_app_offprint_block_callout() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("app.offprint.block.callout"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::Object(LexObject {
                    required: Some(vec![SmolStr::new_static("plaintext")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("color"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Background color (CSS color value)"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("emoji"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Emoji icon for the callout"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("facets"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static("Facets for text formatting"),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("app.offprint.richtext.facet"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("plaintext"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("The callout text content"),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}