#[allow(unused_imports)]
use alloc::collections::BTreeMap;
#[allow(unused_imports)]
use core::marker::PhantomData;
use jacquard_common::{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, 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::pub_leaflet::blocks::header::Header;
use crate::pub_leaflet::blocks::image::Image;
use crate::pub_leaflet::blocks::text::Text;
use crate::pub_leaflet::blocks::unordered_list::UnorderedList;
use crate::pub_leaflet::blocks::ordered_list;
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListItem<S: BosStr = DefaultStr> {
#[serde(skip_serializing_if = "Option::is_none")]
pub children: Option<Vec<ordered_list::ListItem<S>>>,
pub content: ListItemContent<S>,
#[serde(skip_serializing_if = "Option::is_none")]
pub unordered_list_children: Option<UnorderedList<S>>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ListItemContent<S: BosStr = DefaultStr> {
#[serde(rename = "pub.leaflet.blocks.text")]
Text(Box<Text<S>>),
#[serde(rename = "pub.leaflet.blocks.header")]
Header(Box<Header<S>>),
#[serde(rename = "pub.leaflet.blocks.image")]
Image(Box<Image<S>>),
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct OrderedList<S: BosStr = DefaultStr> {
pub children: Vec<ordered_list::ListItem<S>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub start_index: Option<i64>,
#[serde(flatten, default, skip_serializing_if = "Option::is_none")]
pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}
impl<S: BosStr> LexiconSchema for ListItem<S> {
fn nsid() -> &'static str {
"pub.leaflet.blocks.orderedList"
}
fn def_name() -> &'static str {
"listItem"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_blocks_orderedList()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
impl<S: BosStr> LexiconSchema for OrderedList<S> {
fn nsid() -> &'static str {
"pub.leaflet.blocks.orderedList"
}
fn def_name() -> &'static str {
"main"
}
fn lexicon_doc() -> LexiconDoc<'static> {
lexicon_doc_pub_leaflet_blocks_orderedList()
}
fn validate(&self) -> Result<(), ConstraintError> {
Ok(())
}
}
pub mod list_item_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Content;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Content = Unset;
}
pub struct SetContent<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetContent<St> {}
impl<St: State> State for SetContent<St> {
type Content = Set<members::content>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct content(());
}
}
pub struct ListItemBuilder<S: BosStr, St: list_item_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (
Option<Vec<ordered_list::ListItem<S>>>,
Option<ListItemContent<S>>,
Option<UnorderedList<S>>,
),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> ListItem<S> {
pub fn new() -> ListItemBuilder<S, list_item_state::Empty> {
ListItemBuilder::new()
}
}
impl<S: BosStr> ListItemBuilder<S, list_item_state::Empty> {
pub fn new() -> Self {
ListItemBuilder {
_state: PhantomData,
_fields: (None, None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St: list_item_state::State> ListItemBuilder<S, St> {
pub fn children(
mut self,
value: impl Into<Option<Vec<ordered_list::ListItem<S>>>>,
) -> Self {
self._fields.0 = value.into();
self
}
pub fn maybe_children(
mut self,
value: Option<Vec<ordered_list::ListItem<S>>>,
) -> Self {
self._fields.0 = value;
self
}
}
impl<S: BosStr, St> ListItemBuilder<S, St>
where
St: list_item_state::State,
St::Content: list_item_state::IsUnset,
{
pub fn content(
mut self,
value: impl Into<ListItemContent<S>>,
) -> ListItemBuilder<S, list_item_state::SetContent<St>> {
self._fields.1 = Option::Some(value.into());
ListItemBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: list_item_state::State> ListItemBuilder<S, St> {
pub fn unordered_list_children(
mut self,
value: impl Into<Option<UnorderedList<S>>>,
) -> Self {
self._fields.2 = value.into();
self
}
pub fn maybe_unordered_list_children(
mut self,
value: Option<UnorderedList<S>>,
) -> Self {
self._fields.2 = value;
self
}
}
impl<S: BosStr, St> ListItemBuilder<S, St>
where
St: list_item_state::State,
St::Content: list_item_state::IsSet,
{
pub fn build(self) -> ListItem<S> {
ListItem {
children: self._fields.0,
content: self._fields.1.unwrap(),
unordered_list_children: self._fields.2,
extra_data: Default::default(),
}
}
pub fn build_with_data(self, extra_data: BTreeMap<SmolStr, Data<S>>) -> ListItem<S> {
ListItem {
children: self._fields.0,
content: self._fields.1.unwrap(),
unordered_list_children: self._fields.2,
extra_data: Some(extra_data),
}
}
}
fn lexicon_doc_pub_leaflet_blocks_orderedList() -> 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("pub.leaflet.blocks.orderedList"),
defs: {
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("listItem"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("content")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("children"),
LexObjectProperty::Array(LexArray {
description: Some(
CowStr::new_static(
"Nested ordered list items. Mutually exclusive with unorderedListChildren; if both are present, children takes precedence.",
),
),
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#listItem"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("content"),
LexObjectProperty::Union(LexRefUnion {
refs: vec![
CowStr::new_static("pub.leaflet.blocks.text"),
CowStr::new_static("pub.leaflet.blocks.header"),
CowStr::new_static("pub.leaflet.blocks.image")
],
..Default::default()
}),
);
map.insert(
SmolStr::new_static("unorderedListChildren"),
LexObjectProperty::Ref(LexRef {
r#ref: CowStr::new_static(
"pub.leaflet.blocks.unorderedList",
),
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map.insert(
SmolStr::new_static("main"),
LexUserType::Object(LexObject {
required: Some(vec![SmolStr::new_static("children")]),
properties: {
#[allow(unused_mut)]
let mut map = BTreeMap::new();
map.insert(
SmolStr::new_static("children"),
LexObjectProperty::Array(LexArray {
items: LexArrayItem::Ref(LexRef {
r#ref: CowStr::new_static("#listItem"),
..Default::default()
}),
..Default::default()
}),
);
map.insert(
SmolStr::new_static("startIndex"),
LexObjectProperty::Integer(LexInteger {
..Default::default()
}),
);
map
},
..Default::default()
}),
);
map
},
..Default::default()
}
}
pub mod ordered_list_state {
pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
#[allow(unused)]
use ::core::marker::PhantomData;
mod sealed {
pub trait Sealed {}
}
pub trait State: sealed::Sealed {
type Children;
}
pub struct Empty(());
impl sealed::Sealed for Empty {}
impl State for Empty {
type Children = Unset;
}
pub struct SetChildren<St: State = Empty>(PhantomData<fn() -> St>);
impl<St: State> sealed::Sealed for SetChildren<St> {}
impl<St: State> State for SetChildren<St> {
type Children = Set<members::children>;
}
#[allow(non_camel_case_types)]
pub mod members {
pub struct children(());
}
}
pub struct OrderedListBuilder<S: BosStr, St: ordered_list_state::State> {
_state: PhantomData<fn() -> St>,
_fields: (Option<Vec<ordered_list::ListItem<S>>>, Option<i64>),
_type: PhantomData<fn() -> S>,
}
impl<S: BosStr> OrderedList<S> {
pub fn new() -> OrderedListBuilder<S, ordered_list_state::Empty> {
OrderedListBuilder::new()
}
}
impl<S: BosStr> OrderedListBuilder<S, ordered_list_state::Empty> {
pub fn new() -> Self {
OrderedListBuilder {
_state: PhantomData,
_fields: (None, None),
_type: PhantomData,
}
}
}
impl<S: BosStr, St> OrderedListBuilder<S, St>
where
St: ordered_list_state::State,
St::Children: ordered_list_state::IsUnset,
{
pub fn children(
mut self,
value: impl Into<Vec<ordered_list::ListItem<S>>>,
) -> OrderedListBuilder<S, ordered_list_state::SetChildren<St>> {
self._fields.0 = Option::Some(value.into());
OrderedListBuilder {
_state: PhantomData,
_fields: self._fields,
_type: PhantomData,
}
}
}
impl<S: BosStr, St: ordered_list_state::State> OrderedListBuilder<S, St> {
pub fn start_index(mut self, value: impl Into<Option<i64>>) -> Self {
self._fields.1 = value.into();
self
}
pub fn maybe_start_index(mut self, value: Option<i64>) -> Self {
self._fields.1 = value;
self
}
}
impl<S: BosStr, St> OrderedListBuilder<S, St>
where
St: ordered_list_state::State,
St::Children: ordered_list_state::IsSet,
{
pub fn build(self) -> OrderedList<S> {
OrderedList {
children: self._fields.0.unwrap(),
start_index: self._fields.1,
extra_data: Default::default(),
}
}
pub fn build_with_data(
self,
extra_data: BTreeMap<SmolStr, Data<S>>,
) -> OrderedList<S> {
OrderedList {
children: self._fields.0.unwrap(),
start_index: self._fields.1,
extra_data: Some(extra_data),
}
}
}