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

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

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

#[allow(unused_imports)]
use jacquard_common::deps::codegen::unicode_segmentation::UnicodeSegmentation;
use jacquard_common::deps::smol_str::SmolStr;
use jacquard_common::types::string::{Datetime, Language};
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::app_bsky::embed::external::ExternalRecord;
use crate::app_bsky::embed::images::Images;
use crate::app_bsky::embed::record::Record;
use crate::app_bsky::embed::record_with_media::RecordWithMedia;
use crate::app_bsky::embed::video::Video;
use crate::app_bsky::feed::threadgate::FollowerRule;
use crate::app_bsky::feed::threadgate::FollowingRule;
use crate::app_bsky::feed::threadgate::ListRule;
use crate::app_bsky::feed::threadgate::MentionRule;
use crate::app_bsky::richtext::facet::Facet;
use crate::com_atproto::label::SelfLabels;
use crate::app_chronosky::schedule::list_posts;
/// Image embed view with CID references. Similar to app.bsky.embed.images#view but includes cid on each image.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ImageView<S: BosStr = DefaultStr> {
    ///List of image views with CID references.
    pub images: Vec<list_posts::ImageViewImage<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Image view with CID for referencing in updatePost. Extends app.bsky.embed.images#viewImage with cid field.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic, Default)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ImageViewImage<S: BosStr = DefaultStr> {
    ///Alt text for the image.
    pub alt: S,
    ///CID of the image blob. Use this value with updatePost#imagesEmbed to reference this image without re-uploading.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<S>,
    ///Full-size URL for the image.
    pub fullsize: S,
    ///Thumbnail URL for the image.
    pub thumb: S,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListPosts<S: BosStr = DefaultStr> {
    /// Defaults to `20`. Min: 1. Max: 100.
    #[serde(default = "_default_limit")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub limit: Option<i64>,
    /// Defaults to `1`. Min: 1.
    #[serde(default = "_default_page")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub page: Option<i64>,
    /// (max length: 20)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<S>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ListPostsOutput<S: BosStr = DefaultStr> {
    pub pagination: list_posts::Pagination<S>,
    pub posts: Vec<list_posts::ScheduledPost<S>>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Pagination information.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct Pagination<S: BosStr = DefaultStr> {
    ///Posts per page.
    pub limit: i64,
    ///Current page number.
    pub page: i64,
    ///Total number of posts.
    pub total: i64,
    ///Total number of pages.
    pub total_pages: i64,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/// Scheduled post object with AT Protocol standard fields.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct ScheduledPost<S: BosStr = DefaultStr> {
    ///AT Protocol record key. Present after successful execution.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub at_rkey: Option<S>,
    ///AT Protocol post URI (at://did:plc:.../app.bsky.feed.post/...). Present after successful execution.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub at_uri: Option<S>,
    ///Child posts in thread. Only present for parent posts with children.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub children: Option<Vec<list_posts::ScheduledPost<S>>>,
    ///Post creation datetime (ISO 8601).
    pub created_at: Datetime,
    ///Embedded content such as images, external links, or quoted posts. For image embeds, returned as #imageView with thumb/fullsize URLs and CID references.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub embed: Option<ScheduledPostEmbed<S>>,
    ///Error message if execution failed. Present only when status is FAILED.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error_msg: Option<S>,
    ///Execution completion datetime (ISO 8601). Present only when status is COMPLETED or FAILED.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub executed_at: Option<Datetime>,
    ///Rich text facets for mentions, links, and hashtags (app.bsky.richtext.facet).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub facets: Option<Vec<Facet<S>>>,
    ///Post ID.
    pub id: S,
    ///Self-applied content labels for content warnings (AT Protocol standard).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub labels: Option<SelfLabels<S>>,
    ///Language codes for post content (app.bsky.feed.post#langs). ISO 639-1 or 639-3 codes.
    pub langs: Vec<Language>,
    ///Parent post ID for thread posts. Null for root posts.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub parent_post_id: Option<S>,
    ///CID for postgate record. Present after successful execution with postgate settings.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub postgate_cid: Option<S>,
    ///Whether to disable quote posts and embeds for this post (app.bsky.feed.postgate).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub postgate_disable_embedding: Option<bool>,
    ///AT Protocol URI for postgate record. Present after successful execution with postgate settings.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub postgate_uri: Option<S>,
    ///Number of execution retry attempts.
    pub retry_count: i64,
    ///Scheduled publication datetime (ISO 8601).
    pub scheduled_at: Datetime,
    ///Post status.
    pub status: S,
    ///Post content text (app.bsky.feed.post#text). May be empty if embeds are present.
    pub text: S,
    ///Thread depth level (0 for root post, 1 for direct reply, etc.).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thread_depth: Option<i64>,
    ///Position in thread (0-indexed). 0 for parent post, 1+ for children.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub thread_position: Option<i64>,
    ///CID for threadgate record. Present after successful execution with threadgate rules.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub threadgate_cid: Option<S>,
    ///Reply restriction rules (app.bsky.feed.threadgate). Defines who can reply to this post.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub threadgate_rules: Option<Vec<ScheduledPostThreadgateRulesItem<S>>>,
    ///AT Protocol URI for threadgate record. Present after successful execution with threadgate rules.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub threadgate_uri: Option<S>,
    ///Post last update datetime (ISO 8601).
    pub updated_at: Datetime,
    ///User ID who created this post.
    pub user_id: 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 ScheduledPostEmbed<S: BosStr = DefaultStr> {
    #[serde(rename = "app.bsky.embed.images")]
    Images(Box<Images<S>>),
    #[serde(rename = "app.chronosky.schedule.listPosts#imageView")]
    ImageView(Box<list_posts::ImageView<S>>),
    #[serde(rename = "app.bsky.embed.external")]
    External(Box<ExternalRecord<S>>),
    #[serde(rename = "app.bsky.embed.record")]
    Record(Box<Record<S>>),
    #[serde(rename = "app.bsky.embed.video")]
    Video(Box<Video<S>>),
    #[serde(rename = "app.bsky.embed.recordWithMedia")]
    RecordWithMedia(Box<RecordWithMedia<S>>),
}


#[open_union]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(tag = "$type", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub enum ScheduledPostThreadgateRulesItem<S: BosStr = DefaultStr> {
    #[serde(rename = "app.bsky.feed.threadgate#mentionRule")]
    ThreadgateMentionRule(Box<MentionRule<S>>),
    #[serde(rename = "app.bsky.feed.threadgate#followerRule")]
    ThreadgateFollowerRule(Box<FollowerRule<S>>),
    #[serde(rename = "app.bsky.feed.threadgate#followingRule")]
    ThreadgateFollowingRule(Box<FollowingRule<S>>),
    #[serde(rename = "app.bsky.feed.threadgate#listRule")]
    ThreadgateListRule(Box<ListRule<S>>),
}

impl<S: BosStr> LexiconSchema for ImageView<S> {
    fn nsid() -> &'static str {
        "app.chronosky.schedule.listPosts"
    }
    fn def_name() -> &'static str {
        "imageView"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_chronosky_schedule_listPosts()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.images;
            #[allow(unused_comparisons)]
            if value.len() > 4usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("images"),
                    max: 4usize,
                    actual: value.len(),
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ImageViewImage<S> {
    fn nsid() -> &'static str {
        "app.chronosky.schedule.listPosts"
    }
    fn def_name() -> &'static str {
        "imageViewImage"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_chronosky_schedule_listPosts()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.cid {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("cid"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

/** Response marker for the `app.chronosky.schedule.listPosts` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `ListPostsOutput<S>` for this endpoint.*/
pub struct ListPostsResponse;
impl jacquard_common::xrpc::XrpcResp for ListPostsResponse {
    const NSID: &'static str = "app.chronosky.schedule.listPosts";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = ListPostsOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for ListPosts<S> {
    const NSID: &'static str = "app.chronosky.schedule.listPosts";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = ListPostsResponse;
}

/** Endpoint marker for the `app.chronosky.schedule.listPosts` query.

Path: `/xrpc/app.chronosky.schedule.listPosts`. The request payload type is `ListPosts<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct ListPostsRequest;
impl jacquard_common::xrpc::XrpcEndpoint for ListPostsRequest {
    const PATH: &'static str = "/xrpc/app.chronosky.schedule.listPosts";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = ListPosts<S>;
    type Response = ListPostsResponse;
}

impl<S: BosStr> LexiconSchema for Pagination<S> {
    fn nsid() -> &'static str {
        "app.chronosky.schedule.listPosts"
    }
    fn def_name() -> &'static str {
        "pagination"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_chronosky_schedule_listPosts()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        {
            let value = &self.limit;
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("limit"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.page;
            if *value < 1i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("page"),
                    min: 1i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.total;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("total"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.total_pages;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("total_pages"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for ScheduledPost<S> {
    fn nsid() -> &'static str {
        "app.chronosky.schedule.listPosts"
    }
    fn def_name() -> &'static str {
        "scheduledPost"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_app_chronosky_schedule_listPosts()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        if let Some(ref value) = self.at_rkey {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("at_rkey"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.at_uri {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("at_uri"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.error_msg {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 2000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("error_msg"),
                    max: 2000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.id;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("id"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.langs;
            #[allow(unused_comparisons)]
            if value.len() > 3usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("langs"),
                    max: 3usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.parent_post_id {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("parent_post_id"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.postgate_cid {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("postgate_cid"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.postgate_uri {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("postgate_uri"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.retry_count;
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("retry_count"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        {
            let value = &self.status;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 20usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("status"),
                    max: 20usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.text;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 3000usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("text"),
                    max: 3000usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.text;
            {
                let count = UnicodeSegmentation::graphemes(value.as_ref(), true).count();
                if count > 300usize {
                    return Err(ConstraintError::MaxGraphemes {
                        path: ValidationPath::from_field("text"),
                        max: 300usize,
                        actual: count,
                    });
                }
            }
        }
        if let Some(ref value) = self.thread_depth {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("thread_depth"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.thread_position {
            if *value < 0i64 {
                return Err(ConstraintError::Minimum {
                    path: ValidationPath::from_field("thread_position"),
                    min: 0i64,
                    actual: *value,
                });
            }
        }
        if let Some(ref value) = self.threadgate_cid {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 100usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("threadgate_cid"),
                    max: 100usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        if let Some(ref value) = self.threadgate_rules {
            #[allow(unused_comparisons)]
            if value.len() > 5usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("threadgate_rules"),
                    max: 5usize,
                    actual: value.len(),
                });
            }
        }
        if let Some(ref value) = self.threadgate_uri {
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 500usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("threadgate_uri"),
                    max: 500usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        {
            let value = &self.user_id;
            #[allow(unused_comparisons)]
            if <str>::len(value.as_ref()) > 200usize {
                return Err(ConstraintError::MaxLength {
                    path: ValidationPath::from_field("user_id"),
                    max: 200usize,
                    actual: <str>::len(value.as_ref()),
                });
            }
        }
        Ok(())
    }
}

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

/// Builder for constructing an instance of this type.
pub struct ImageViewBuilder<St: image_view_state::State, S: BosStr = DefaultStr> {
    _state: PhantomData<fn() -> St>,
    _fields: (Option<Vec<list_posts::ImageViewImage<S>>>,),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ImageView<S> {
    /// Create a new builder for this type
    pub fn builder() -> ImageViewBuilder<image_view_state::Empty, S> {
        ImageViewBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> ImageViewBuilder<St, S>
where
    St: image_view_state::State,
    St::Images: image_view_state::IsUnset,
{
    /// Set the `images` field (required)
    pub fn images(
        mut self,
        value: impl Into<Vec<list_posts::ImageViewImage<S>>>,
    ) -> ImageViewBuilder<image_view_state::SetImages<St>, S> {
        self._fields.0 = Option::Some(value.into());
        ImageViewBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ImageViewBuilder<St, S>
where
    St: image_view_state::State,
    St::Images: image_view_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ImageView<S> {
        ImageView {
            images: 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<SmolStr, Data<S>>,
    ) -> ImageView<S> {
        ImageView {
            images: self._fields.0.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_app_chronosky_schedule_listPosts() -> 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.chronosky.schedule.listPosts"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("imageView"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Image embed view with CID references. Similar to app.bsky.embed.images#view but includes cid on each image.",
                        ),
                    ),
                    required: Some(vec![SmolStr::new_static("images")]),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("images"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "List of image views with CID references.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#imageViewImage"),
                                    ..Default::default()
                                }),
                                max_length: Some(4usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("imageViewImage"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Image view with CID for referencing in updatePost. Extends app.bsky.embed.images#viewImage with cid field.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("thumb"),
                            SmolStr::new_static("fullsize"), SmolStr::new_static("alt")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("alt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Alt text for the image."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "CID of the image blob. Use this value with updatePost#imagesEmbed to reference this image without re-uploading.",
                                    ),
                                ),
                                max_length: Some(200usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("fullsize"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Full-size URL for the image."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("thumb"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Thumbnail URL for the image."),
                                ),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("limit"),
                                    LexXrpcParametersProperty::Integer(LexInteger {
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("page"),
                                    LexXrpcParametersProperty::Integer(LexInteger {
                                        ..Default::default()
                                    }),
                                );
                                map.insert(
                                    SmolStr::new_static("status"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static("Filter by post status."),
                                        ),
                                        max_length: Some(20usize),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("pagination"),
                LexUserType::Object(LexObject {
                    description: Some(CowStr::new_static("Pagination information.")),
                    required: Some(
                        vec![
                            SmolStr::new_static("page"), SmolStr::new_static("limit"),
                            SmolStr::new_static("total"),
                            SmolStr::new_static("totalPages")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("limit"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(1i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("page"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(1i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("total"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("totalPages"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("scheduledPost"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Scheduled post object with AT Protocol standard fields.",
                        ),
                    ),
                    required: Some(
                        vec![
                            SmolStr::new_static("id"), SmolStr::new_static("userId"),
                            SmolStr::new_static("text"),
                            SmolStr::new_static("scheduledAt"),
                            SmolStr::new_static("status"),
                            SmolStr::new_static("createdAt"),
                            SmolStr::new_static("updatedAt"),
                            SmolStr::new_static("retryCount"),
                            SmolStr::new_static("langs")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("atRkey"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "AT Protocol record key. Present after successful execution.",
                                    ),
                                ),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("atUri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "AT Protocol post URI (at://did:plc:.../app.bsky.feed.post/...). Present after successful execution.",
                                    ),
                                ),
                                max_length: Some(500usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("children"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Child posts in thread. Only present for parent posts with children.",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#scheduledPost"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("createdAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Post creation datetime (ISO 8601)."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("embed"),
                            LexObjectProperty::Union(LexRefUnion {
                                description: Some(
                                    CowStr::new_static(
                                        "Embedded content such as images, external links, or quoted posts. For image embeds, returned as #imageView with thumb/fullsize URLs and CID references.",
                                    ),
                                ),
                                refs: vec![
                                    CowStr::new_static("app.bsky.embed.images"),
                                    CowStr::new_static("#imageView"),
                                    CowStr::new_static("app.bsky.embed.external"),
                                    CowStr::new_static("app.bsky.embed.record"),
                                    CowStr::new_static("app.bsky.embed.video"),
                                    CowStr::new_static("app.bsky.embed.recordWithMedia")
                                ],
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("errorMsg"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Error message if execution failed. Present only when status is FAILED.",
                                    ),
                                ),
                                max_length: Some(2000usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("executedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Execution completion datetime (ISO 8601). Present only when status is COMPLETED or FAILED.",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("facets"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Rich text facets for mentions, links, and hashtags (app.bsky.richtext.facet).",
                                    ),
                                ),
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("app.bsky.richtext.facet"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("id"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Post ID.")),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("labels"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "com.atproto.label.defs#selfLabels",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("langs"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Language codes for post content (app.bsky.feed.post#langs). ISO 639-1 or 639-3 codes.",
                                    ),
                                ),
                                items: LexArrayItem::String(LexString {
                                    format: Some(LexStringFormat::Language),
                                    ..Default::default()
                                }),
                                max_length: Some(3usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("parentPostId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Parent post ID for thread posts. Null for root posts.",
                                    ),
                                ),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("postgateCid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "CID for postgate record. Present after successful execution with postgate settings.",
                                    ),
                                ),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("postgateDisableEmbedding"),
                            LexObjectProperty::Boolean(LexBoolean {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("postgateUri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "AT Protocol URI for postgate record. Present after successful execution with postgate settings.",
                                    ),
                                ),
                                max_length: Some(500usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("retryCount"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("scheduledAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Scheduled publication datetime (ISO 8601).",
                                    ),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("status"),
                            LexObjectProperty::String(LexString {
                                description: Some(CowStr::new_static("Post status.")),
                                max_length: Some(20usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("text"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "Post content text (app.bsky.feed.post#text). May be empty if embeds are present.",
                                    ),
                                ),
                                max_length: Some(3000usize),
                                max_graphemes: Some(300usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("threadDepth"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("threadPosition"),
                            LexObjectProperty::Integer(LexInteger {
                                minimum: Some(0i64),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("threadgateCid"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "CID for threadgate record. Present after successful execution with threadgate rules.",
                                    ),
                                ),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("threadgateRules"),
                            LexObjectProperty::Array(LexArray {
                                description: Some(
                                    CowStr::new_static(
                                        "Reply restriction rules (app.bsky.feed.threadgate). Defines who can reply to this post.",
                                    ),
                                ),
                                items: LexArrayItem::Union(LexRefUnion {
                                    refs: vec![
                                        CowStr::new_static("app.bsky.feed.threadgate#mentionRule"),
                                        CowStr::new_static("app.bsky.feed.threadgate#followerRule"),
                                        CowStr::new_static("app.bsky.feed.threadgate#followingRule"),
                                        CowStr::new_static("app.bsky.feed.threadgate#listRule")
                                    ],
                                    ..Default::default()
                                }),
                                max_length: Some(5usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("threadgateUri"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static(
                                        "AT Protocol URI for threadgate record. Present after successful execution with threadgate rules.",
                                    ),
                                ),
                                max_length: Some(500usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("updatedAt"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("Post last update datetime (ISO 8601)."),
                                ),
                                format: Some(LexStringFormat::Datetime),
                                max_length: Some(100usize),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("userId"),
                            LexObjectProperty::String(LexString {
                                description: Some(
                                    CowStr::new_static("User ID who created this post."),
                                ),
                                max_length: Some(200usize),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

fn _default_limit() -> Option<i64> {
    Some(20i64)
}

fn _default_page() -> Option<i64> {
    Some(1i64)
}

pub mod list_posts_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 {}
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {}
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {}
}

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

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

impl<S: BosStr> ListPosts<S> {
    /// Create a new builder for this type
    pub fn builder() -> ListPostsBuilder<list_posts_state::Empty, S> {
        ListPostsBuilder::builder()
    }
}

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

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

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

impl<St: list_posts_state::State, S: BosStr> ListPostsBuilder<St, S> {
    /// Set the `page` field (optional)
    pub fn page(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `page` field to an Option value (optional)
    pub fn maybe_page(mut self, value: Option<i64>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: list_posts_state::State, S: BosStr> ListPostsBuilder<St, S> {
    /// Set the `status` field (optional)
    pub fn status(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `status` field to an Option value (optional)
    pub fn maybe_status(mut self, value: Option<S>) -> Self {
        self._fields.2 = value;
        self
    }
}

impl<St, S: BosStr> ListPostsBuilder<St, S>
where
    St: list_posts_state::State,
{
    /// Build the final struct.
    pub fn build(self) -> ListPosts<S> {
        ListPosts {
            limit: self._fields.0,
            page: self._fields.1,
            status: self._fields.2,
        }
    }
}

pub mod pagination_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 Limit;
        type Page;
        type Total;
        type TotalPages;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Limit = Unset;
        type Page = Unset;
        type Total = Unset;
        type TotalPages = Unset;
    }
    ///State transition - sets the `limit` field to Set
    pub struct SetLimit<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLimit<St> {}
    impl<St: State> State for SetLimit<St> {
        type Limit = Set<members::limit>;
        type Page = St::Page;
        type Total = St::Total;
        type TotalPages = St::TotalPages;
    }
    ///State transition - sets the `page` field to Set
    pub struct SetPage<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetPage<St> {}
    impl<St: State> State for SetPage<St> {
        type Limit = St::Limit;
        type Page = Set<members::page>;
        type Total = St::Total;
        type TotalPages = St::TotalPages;
    }
    ///State transition - sets the `total` field to Set
    pub struct SetTotal<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTotal<St> {}
    impl<St: State> State for SetTotal<St> {
        type Limit = St::Limit;
        type Page = St::Page;
        type Total = Set<members::total>;
        type TotalPages = St::TotalPages;
    }
    ///State transition - sets the `total_pages` field to Set
    pub struct SetTotalPages<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetTotalPages<St> {}
    impl<St: State> State for SetTotalPages<St> {
        type Limit = St::Limit;
        type Page = St::Page;
        type Total = St::Total;
        type TotalPages = Set<members::total_pages>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `limit` field
        pub struct limit(());
        ///Marker type for the `page` field
        pub struct page(());
        ///Marker type for the `total` field
        pub struct total(());
        ///Marker type for the `total_pages` field
        pub struct total_pages(());
    }
}

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

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

impl<S: BosStr> Pagination<S> {
    /// Create a new builder for this type
    pub fn builder() -> PaginationBuilder<pagination_state::Empty, S> {
        PaginationBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> PaginationBuilder<St, S>
where
    St: pagination_state::State,
    St::Limit: pagination_state::IsUnset,
{
    /// Set the `limit` field (required)
    pub fn limit(
        mut self,
        value: impl Into<i64>,
    ) -> PaginationBuilder<pagination_state::SetLimit<St>, S> {
        self._fields.0 = Option::Some(value.into());
        PaginationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PaginationBuilder<St, S>
where
    St: pagination_state::State,
    St::Page: pagination_state::IsUnset,
{
    /// Set the `page` field (required)
    pub fn page(
        mut self,
        value: impl Into<i64>,
    ) -> PaginationBuilder<pagination_state::SetPage<St>, S> {
        self._fields.1 = Option::Some(value.into());
        PaginationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PaginationBuilder<St, S>
where
    St: pagination_state::State,
    St::Total: pagination_state::IsUnset,
{
    /// Set the `total` field (required)
    pub fn total(
        mut self,
        value: impl Into<i64>,
    ) -> PaginationBuilder<pagination_state::SetTotal<St>, S> {
        self._fields.2 = Option::Some(value.into());
        PaginationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PaginationBuilder<St, S>
where
    St: pagination_state::State,
    St::TotalPages: pagination_state::IsUnset,
{
    /// Set the `totalPages` field (required)
    pub fn total_pages(
        mut self,
        value: impl Into<i64>,
    ) -> PaginationBuilder<pagination_state::SetTotalPages<St>, S> {
        self._fields.3 = Option::Some(value.into());
        PaginationBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> PaginationBuilder<St, S>
where
    St: pagination_state::State,
    St::Limit: pagination_state::IsSet,
    St::Page: pagination_state::IsSet,
    St::Total: pagination_state::IsSet,
    St::TotalPages: pagination_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> Pagination<S> {
        Pagination {
            limit: self._fields.0.unwrap(),
            page: self._fields.1.unwrap(),
            total: self._fields.2.unwrap(),
            total_pages: self._fields.3.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> Pagination<S> {
        Pagination {
            limit: self._fields.0.unwrap(),
            page: self._fields.1.unwrap(),
            total: self._fields.2.unwrap(),
            total_pages: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

pub mod scheduled_post_state {

    pub use crate::builder_types::{Set, Unset, IsSet, IsUnset};
    #[allow(unused)]
    use ::core::marker::PhantomData;
    mod sealed {
        pub trait Sealed {}
    }
    /// State trait tracking which required fields have been set
    pub trait State: sealed::Sealed {
        type CreatedAt;
        type Id;
        type Langs;
        type RetryCount;
        type ScheduledAt;
        type Status;
        type Text;
        type UpdatedAt;
        type UserId;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type CreatedAt = Unset;
        type Id = Unset;
        type Langs = Unset;
        type RetryCount = Unset;
        type ScheduledAt = Unset;
        type Status = Unset;
        type Text = Unset;
        type UpdatedAt = Unset;
        type UserId = Unset;
    }
    ///State transition - sets the `created_at` field to Set
    pub struct SetCreatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCreatedAt<St> {}
    impl<St: State> State for SetCreatedAt<St> {
        type CreatedAt = Set<members::created_at>;
        type Id = St::Id;
        type Langs = St::Langs;
        type RetryCount = St::RetryCount;
        type ScheduledAt = St::ScheduledAt;
        type Status = St::Status;
        type Text = St::Text;
        type UpdatedAt = St::UpdatedAt;
        type UserId = St::UserId;
    }
    ///State transition - sets the `id` field to Set
    pub struct SetId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetId<St> {}
    impl<St: State> State for SetId<St> {
        type CreatedAt = St::CreatedAt;
        type Id = Set<members::id>;
        type Langs = St::Langs;
        type RetryCount = St::RetryCount;
        type ScheduledAt = St::ScheduledAt;
        type Status = St::Status;
        type Text = St::Text;
        type UpdatedAt = St::UpdatedAt;
        type UserId = St::UserId;
    }
    ///State transition - sets the `langs` field to Set
    pub struct SetLangs<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetLangs<St> {}
    impl<St: State> State for SetLangs<St> {
        type CreatedAt = St::CreatedAt;
        type Id = St::Id;
        type Langs = Set<members::langs>;
        type RetryCount = St::RetryCount;
        type ScheduledAt = St::ScheduledAt;
        type Status = St::Status;
        type Text = St::Text;
        type UpdatedAt = St::UpdatedAt;
        type UserId = St::UserId;
    }
    ///State transition - sets the `retry_count` field to Set
    pub struct SetRetryCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetRetryCount<St> {}
    impl<St: State> State for SetRetryCount<St> {
        type CreatedAt = St::CreatedAt;
        type Id = St::Id;
        type Langs = St::Langs;
        type RetryCount = Set<members::retry_count>;
        type ScheduledAt = St::ScheduledAt;
        type Status = St::Status;
        type Text = St::Text;
        type UpdatedAt = St::UpdatedAt;
        type UserId = St::UserId;
    }
    ///State transition - sets the `scheduled_at` field to Set
    pub struct SetScheduledAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetScheduledAt<St> {}
    impl<St: State> State for SetScheduledAt<St> {
        type CreatedAt = St::CreatedAt;
        type Id = St::Id;
        type Langs = St::Langs;
        type RetryCount = St::RetryCount;
        type ScheduledAt = Set<members::scheduled_at>;
        type Status = St::Status;
        type Text = St::Text;
        type UpdatedAt = St::UpdatedAt;
        type UserId = St::UserId;
    }
    ///State transition - sets the `status` field to Set
    pub struct SetStatus<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetStatus<St> {}
    impl<St: State> State for SetStatus<St> {
        type CreatedAt = St::CreatedAt;
        type Id = St::Id;
        type Langs = St::Langs;
        type RetryCount = St::RetryCount;
        type ScheduledAt = St::ScheduledAt;
        type Status = Set<members::status>;
        type Text = St::Text;
        type UpdatedAt = St::UpdatedAt;
        type UserId = St::UserId;
    }
    ///State transition - sets the `text` field to Set
    pub struct SetText<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetText<St> {}
    impl<St: State> State for SetText<St> {
        type CreatedAt = St::CreatedAt;
        type Id = St::Id;
        type Langs = St::Langs;
        type RetryCount = St::RetryCount;
        type ScheduledAt = St::ScheduledAt;
        type Status = St::Status;
        type Text = Set<members::text>;
        type UpdatedAt = St::UpdatedAt;
        type UserId = St::UserId;
    }
    ///State transition - sets the `updated_at` field to Set
    pub struct SetUpdatedAt<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUpdatedAt<St> {}
    impl<St: State> State for SetUpdatedAt<St> {
        type CreatedAt = St::CreatedAt;
        type Id = St::Id;
        type Langs = St::Langs;
        type RetryCount = St::RetryCount;
        type ScheduledAt = St::ScheduledAt;
        type Status = St::Status;
        type Text = St::Text;
        type UpdatedAt = Set<members::updated_at>;
        type UserId = St::UserId;
    }
    ///State transition - sets the `user_id` field to Set
    pub struct SetUserId<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetUserId<St> {}
    impl<St: State> State for SetUserId<St> {
        type CreatedAt = St::CreatedAt;
        type Id = St::Id;
        type Langs = St::Langs;
        type RetryCount = St::RetryCount;
        type ScheduledAt = St::ScheduledAt;
        type Status = St::Status;
        type Text = St::Text;
        type UpdatedAt = St::UpdatedAt;
        type UserId = Set<members::user_id>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `created_at` field
        pub struct created_at(());
        ///Marker type for the `id` field
        pub struct id(());
        ///Marker type for the `langs` field
        pub struct langs(());
        ///Marker type for the `retry_count` field
        pub struct retry_count(());
        ///Marker type for the `scheduled_at` field
        pub struct scheduled_at(());
        ///Marker type for the `status` field
        pub struct status(());
        ///Marker type for the `text` field
        pub struct text(());
        ///Marker type for the `updated_at` field
        pub struct updated_at(());
        ///Marker type for the `user_id` field
        pub struct user_id(());
    }
}

/// Builder for constructing an instance of this type.
pub struct ScheduledPostBuilder<
    St: scheduled_post_state::State,
    S: BosStr = DefaultStr,
> {
    _state: PhantomData<fn() -> St>,
    _fields: (
        Option<S>,
        Option<S>,
        Option<Vec<list_posts::ScheduledPost<S>>>,
        Option<Datetime>,
        Option<ScheduledPostEmbed<S>>,
        Option<S>,
        Option<Datetime>,
        Option<Vec<Facet<S>>>,
        Option<S>,
        Option<SelfLabels<S>>,
        Option<Vec<Language>>,
        Option<S>,
        Option<S>,
        Option<bool>,
        Option<S>,
        Option<i64>,
        Option<Datetime>,
        Option<S>,
        Option<S>,
        Option<i64>,
        Option<i64>,
        Option<S>,
        Option<Vec<ScheduledPostThreadgateRulesItem<S>>>,
        Option<S>,
        Option<Datetime>,
        Option<S>,
    ),
    _type: PhantomData<fn() -> S>,
}

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

impl<S: BosStr> ScheduledPost<S> {
    /// Create a new builder for this type
    pub fn builder() -> ScheduledPostBuilder<scheduled_post_state::Empty, S> {
        ScheduledPostBuilder::builder()
    }
}

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

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

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `atRkey` field (optional)
    pub fn at_rkey(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.0 = value.into();
        self
    }
    /// Set the `atRkey` field to an Option value (optional)
    pub fn maybe_at_rkey(mut self, value: Option<S>) -> Self {
        self._fields.0 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `atUri` field (optional)
    pub fn at_uri(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `atUri` field to an Option value (optional)
    pub fn maybe_at_uri(mut self, value: Option<S>) -> Self {
        self._fields.1 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `children` field (optional)
    pub fn children(
        mut self,
        value: impl Into<Option<Vec<list_posts::ScheduledPost<S>>>>,
    ) -> Self {
        self._fields.2 = value.into();
        self
    }
    /// Set the `children` field to an Option value (optional)
    pub fn maybe_children(
        mut self,
        value: Option<Vec<list_posts::ScheduledPost<S>>>,
    ) -> Self {
        self._fields.2 = value;
        self
    }
}

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

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `embed` field (optional)
    pub fn embed(mut self, value: impl Into<Option<ScheduledPostEmbed<S>>>) -> Self {
        self._fields.4 = value.into();
        self
    }
    /// Set the `embed` field to an Option value (optional)
    pub fn maybe_embed(mut self, value: Option<ScheduledPostEmbed<S>>) -> Self {
        self._fields.4 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `errorMsg` field (optional)
    pub fn error_msg(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.5 = value.into();
        self
    }
    /// Set the `errorMsg` field to an Option value (optional)
    pub fn maybe_error_msg(mut self, value: Option<S>) -> Self {
        self._fields.5 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `executedAt` field (optional)
    pub fn executed_at(mut self, value: impl Into<Option<Datetime>>) -> Self {
        self._fields.6 = value.into();
        self
    }
    /// Set the `executedAt` field to an Option value (optional)
    pub fn maybe_executed_at(mut self, value: Option<Datetime>) -> Self {
        self._fields.6 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `facets` field (optional)
    pub fn facets(mut self, value: impl Into<Option<Vec<Facet<S>>>>) -> Self {
        self._fields.7 = value.into();
        self
    }
    /// Set the `facets` field to an Option value (optional)
    pub fn maybe_facets(mut self, value: Option<Vec<Facet<S>>>) -> Self {
        self._fields.7 = value;
        self
    }
}

impl<St, S: BosStr> ScheduledPostBuilder<St, S>
where
    St: scheduled_post_state::State,
    St::Id: scheduled_post_state::IsUnset,
{
    /// Set the `id` field (required)
    pub fn id(
        mut self,
        value: impl Into<S>,
    ) -> ScheduledPostBuilder<scheduled_post_state::SetId<St>, S> {
        self._fields.8 = Option::Some(value.into());
        ScheduledPostBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `labels` field (optional)
    pub fn labels(mut self, value: impl Into<Option<SelfLabels<S>>>) -> Self {
        self._fields.9 = value.into();
        self
    }
    /// Set the `labels` field to an Option value (optional)
    pub fn maybe_labels(mut self, value: Option<SelfLabels<S>>) -> Self {
        self._fields.9 = value;
        self
    }
}

impl<St, S: BosStr> ScheduledPostBuilder<St, S>
where
    St: scheduled_post_state::State,
    St::Langs: scheduled_post_state::IsUnset,
{
    /// Set the `langs` field (required)
    pub fn langs(
        mut self,
        value: impl Into<Vec<Language>>,
    ) -> ScheduledPostBuilder<scheduled_post_state::SetLangs<St>, S> {
        self._fields.10 = Option::Some(value.into());
        ScheduledPostBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `parentPostId` field (optional)
    pub fn parent_post_id(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.11 = value.into();
        self
    }
    /// Set the `parentPostId` field to an Option value (optional)
    pub fn maybe_parent_post_id(mut self, value: Option<S>) -> Self {
        self._fields.11 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `postgateCid` field (optional)
    pub fn postgate_cid(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.12 = value.into();
        self
    }
    /// Set the `postgateCid` field to an Option value (optional)
    pub fn maybe_postgate_cid(mut self, value: Option<S>) -> Self {
        self._fields.12 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `postgateDisableEmbedding` field (optional)
    pub fn postgate_disable_embedding(mut self, value: impl Into<Option<bool>>) -> Self {
        self._fields.13 = value.into();
        self
    }
    /// Set the `postgateDisableEmbedding` field to an Option value (optional)
    pub fn maybe_postgate_disable_embedding(mut self, value: Option<bool>) -> Self {
        self._fields.13 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `postgateUri` field (optional)
    pub fn postgate_uri(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.14 = value.into();
        self
    }
    /// Set the `postgateUri` field to an Option value (optional)
    pub fn maybe_postgate_uri(mut self, value: Option<S>) -> Self {
        self._fields.14 = value;
        self
    }
}

impl<St, S: BosStr> ScheduledPostBuilder<St, S>
where
    St: scheduled_post_state::State,
    St::RetryCount: scheduled_post_state::IsUnset,
{
    /// Set the `retryCount` field (required)
    pub fn retry_count(
        mut self,
        value: impl Into<i64>,
    ) -> ScheduledPostBuilder<scheduled_post_state::SetRetryCount<St>, S> {
        self._fields.15 = Option::Some(value.into());
        ScheduledPostBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduledPostBuilder<St, S>
where
    St: scheduled_post_state::State,
    St::ScheduledAt: scheduled_post_state::IsUnset,
{
    /// Set the `scheduledAt` field (required)
    pub fn scheduled_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> ScheduledPostBuilder<scheduled_post_state::SetScheduledAt<St>, S> {
        self._fields.16 = Option::Some(value.into());
        ScheduledPostBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduledPostBuilder<St, S>
where
    St: scheduled_post_state::State,
    St::Status: scheduled_post_state::IsUnset,
{
    /// Set the `status` field (required)
    pub fn status(
        mut self,
        value: impl Into<S>,
    ) -> ScheduledPostBuilder<scheduled_post_state::SetStatus<St>, S> {
        self._fields.17 = Option::Some(value.into());
        ScheduledPostBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduledPostBuilder<St, S>
where
    St: scheduled_post_state::State,
    St::Text: scheduled_post_state::IsUnset,
{
    /// Set the `text` field (required)
    pub fn text(
        mut self,
        value: impl Into<S>,
    ) -> ScheduledPostBuilder<scheduled_post_state::SetText<St>, S> {
        self._fields.18 = Option::Some(value.into());
        ScheduledPostBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `threadDepth` field (optional)
    pub fn thread_depth(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.19 = value.into();
        self
    }
    /// Set the `threadDepth` field to an Option value (optional)
    pub fn maybe_thread_depth(mut self, value: Option<i64>) -> Self {
        self._fields.19 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `threadPosition` field (optional)
    pub fn thread_position(mut self, value: impl Into<Option<i64>>) -> Self {
        self._fields.20 = value.into();
        self
    }
    /// Set the `threadPosition` field to an Option value (optional)
    pub fn maybe_thread_position(mut self, value: Option<i64>) -> Self {
        self._fields.20 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `threadgateCid` field (optional)
    pub fn threadgate_cid(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.21 = value.into();
        self
    }
    /// Set the `threadgateCid` field to an Option value (optional)
    pub fn maybe_threadgate_cid(mut self, value: Option<S>) -> Self {
        self._fields.21 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `threadgateRules` field (optional)
    pub fn threadgate_rules(
        mut self,
        value: impl Into<Option<Vec<ScheduledPostThreadgateRulesItem<S>>>>,
    ) -> Self {
        self._fields.22 = value.into();
        self
    }
    /// Set the `threadgateRules` field to an Option value (optional)
    pub fn maybe_threadgate_rules(
        mut self,
        value: Option<Vec<ScheduledPostThreadgateRulesItem<S>>>,
    ) -> Self {
        self._fields.22 = value;
        self
    }
}

impl<St: scheduled_post_state::State, S: BosStr> ScheduledPostBuilder<St, S> {
    /// Set the `threadgateUri` field (optional)
    pub fn threadgate_uri(mut self, value: impl Into<Option<S>>) -> Self {
        self._fields.23 = value.into();
        self
    }
    /// Set the `threadgateUri` field to an Option value (optional)
    pub fn maybe_threadgate_uri(mut self, value: Option<S>) -> Self {
        self._fields.23 = value;
        self
    }
}

impl<St, S: BosStr> ScheduledPostBuilder<St, S>
where
    St: scheduled_post_state::State,
    St::UpdatedAt: scheduled_post_state::IsUnset,
{
    /// Set the `updatedAt` field (required)
    pub fn updated_at(
        mut self,
        value: impl Into<Datetime>,
    ) -> ScheduledPostBuilder<scheduled_post_state::SetUpdatedAt<St>, S> {
        self._fields.24 = Option::Some(value.into());
        ScheduledPostBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduledPostBuilder<St, S>
where
    St: scheduled_post_state::State,
    St::UserId: scheduled_post_state::IsUnset,
{
    /// Set the `userId` field (required)
    pub fn user_id(
        mut self,
        value: impl Into<S>,
    ) -> ScheduledPostBuilder<scheduled_post_state::SetUserId<St>, S> {
        self._fields.25 = Option::Some(value.into());
        ScheduledPostBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> ScheduledPostBuilder<St, S>
where
    St: scheduled_post_state::State,
    St::CreatedAt: scheduled_post_state::IsSet,
    St::Id: scheduled_post_state::IsSet,
    St::Langs: scheduled_post_state::IsSet,
    St::RetryCount: scheduled_post_state::IsSet,
    St::ScheduledAt: scheduled_post_state::IsSet,
    St::Status: scheduled_post_state::IsSet,
    St::Text: scheduled_post_state::IsSet,
    St::UpdatedAt: scheduled_post_state::IsSet,
    St::UserId: scheduled_post_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> ScheduledPost<S> {
        ScheduledPost {
            at_rkey: self._fields.0,
            at_uri: self._fields.1,
            children: self._fields.2,
            created_at: self._fields.3.unwrap(),
            embed: self._fields.4,
            error_msg: self._fields.5,
            executed_at: self._fields.6,
            facets: self._fields.7,
            id: self._fields.8.unwrap(),
            labels: self._fields.9,
            langs: self._fields.10.unwrap(),
            parent_post_id: self._fields.11,
            postgate_cid: self._fields.12,
            postgate_disable_embedding: self._fields.13,
            postgate_uri: self._fields.14,
            retry_count: self._fields.15.unwrap(),
            scheduled_at: self._fields.16.unwrap(),
            status: self._fields.17.unwrap(),
            text: self._fields.18.unwrap(),
            thread_depth: self._fields.19,
            thread_position: self._fields.20,
            threadgate_cid: self._fields.21,
            threadgate_rules: self._fields.22,
            threadgate_uri: self._fields.23,
            updated_at: self._fields.24.unwrap(),
            user_id: self._fields.25.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> ScheduledPost<S> {
        ScheduledPost {
            at_rkey: self._fields.0,
            at_uri: self._fields.1,
            children: self._fields.2,
            created_at: self._fields.3.unwrap(),
            embed: self._fields.4,
            error_msg: self._fields.5,
            executed_at: self._fields.6,
            facets: self._fields.7,
            id: self._fields.8.unwrap(),
            labels: self._fields.9,
            langs: self._fields.10.unwrap(),
            parent_post_id: self._fields.11,
            postgate_cid: self._fields.12,
            postgate_disable_embedding: self._fields.13,
            postgate_uri: self._fields.14,
            retry_count: self._fields.15.unwrap(),
            scheduled_at: self._fields.16.unwrap(),
            status: self._fields.17.unwrap(),
            text: self._fields.18.unwrap(),
            thread_depth: self._fields.19,
            thread_position: self._fields.20,
            threadgate_cid: self._fields.21,
            threadgate_rules: self._fields.22,
            threadgate_uri: self._fields.23,
            updated_at: self._fields.24.unwrap(),
            user_id: self._fields.25.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}