// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: tools.ozone.moderation.getAccountTimeline
//
// 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::Did;
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::tools_ozone::moderation::get_account_timeline;

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetAccountTimeline<S: BosStr = DefaultStr> {
    pub did: Did<S>,
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct GetAccountTimelineOutput<S: BosStr = DefaultStr> {
    pub timeline: Vec<get_account_timeline::TimelineItem<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,
    thiserror::Error,
    miette::Diagnostic
)]

#[serde(tag = "error", content = "message")]
pub enum GetAccountTimelineError {
    #[serde(rename = "RepoNotFound")]
    RepoNotFound(Option<SmolStr>),
    /// Catch-all for unknown error codes.
    #[serde(untagged)]
    Other { error: SmolStr, message: Option<SmolStr> },
}

impl core::fmt::Display for GetAccountTimelineError {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            Self::RepoNotFound(msg) => {
                write!(f, "RepoNotFound")?;
                if let Some(msg) = msg {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
            Self::Other { error, message } => {
                write!(f, "{}", error)?;
                if let Some(msg) = message {
                    write!(f, ": {}", msg)?;
                }
                Ok(())
            }
        }
    }
}


#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct TimelineItem<S: BosStr = DefaultStr> {
    pub day: S,
    pub summary: Vec<get_account_timeline::TimelineItemSummary<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 TimelineItemSummary<S: BosStr = DefaultStr> {
    pub count: i64,
    pub event_subject_type: TimelineItemSummaryEventSubjectType<S>,
    pub event_type: TimelineItemSummaryEventType<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TimelineItemSummaryEventSubjectType<S: BosStr = DefaultStr> {
    Account,
    Record,
    Chat,
    Other(S),
}

impl<S: BosStr> TimelineItemSummaryEventSubjectType<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::Account => "account",
            Self::Record => "record",
            Self::Chat => "chat",
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "account" => Self::Account,
            "record" => Self::Record,
            "chat" => Self::Chat,
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> core::fmt::Display for TimelineItemSummaryEventSubjectType<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> AsRef<str> for TimelineItemSummaryEventSubjectType<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> Serialize for TimelineItemSummaryEventSubjectType<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for TimelineItemSummaryEventSubjectType<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for TimelineItemSummaryEventSubjectType<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for TimelineItemSummaryEventSubjectType<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = TimelineItemSummaryEventSubjectType<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            TimelineItemSummaryEventSubjectType::Account => {
                TimelineItemSummaryEventSubjectType::Account
            }
            TimelineItemSummaryEventSubjectType::Record => {
                TimelineItemSummaryEventSubjectType::Record
            }
            TimelineItemSummaryEventSubjectType::Chat => {
                TimelineItemSummaryEventSubjectType::Chat
            }
            TimelineItemSummaryEventSubjectType::Other(v) => {
                TimelineItemSummaryEventSubjectType::Other(v.into_static())
            }
        }
    }
}


#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum TimelineItemSummaryEventType<S: BosStr = DefaultStr> {
    ModEventTakedown,
    ModEventReverseTakedown,
    ModEventComment,
    ModEventReport,
    ModEventLabel,
    ModEventAcknowledge,
    ModEventEscalate,
    ModEventMute,
    ModEventUnmute,
    ModEventMuteReporter,
    ModEventUnmuteReporter,
    ModEventEmail,
    ModEventResolveAppeal,
    ModEventDivert,
    ModEventTag,
    AccountEvent,
    IdentityEvent,
    RecordEvent,
    ModEventPriorityScore,
    RevokeAccountCredentialsEvent,
    AgeAssuranceEvent,
    AgeAssuranceOverrideEvent,
    TimelineEventPlcCreate,
    TimelineEventPlcOperation,
    TimelineEventPlcTombstone,
    AccountCreated,
    EmailConfirmed,
    PasswordUpdated,
    HandleUpdated,
    ScheduleTakedownEvent,
    CancelScheduledTakedownEvent,
    Other(S),
}

impl<S: BosStr> TimelineItemSummaryEventType<S> {
    pub fn as_str(&self) -> &str {
        match self {
            Self::ModEventTakedown => "tools.ozone.moderation.defs#modEventTakedown",
            Self::ModEventReverseTakedown => {
                "tools.ozone.moderation.defs#modEventReverseTakedown"
            }
            Self::ModEventComment => "tools.ozone.moderation.defs#modEventComment",
            Self::ModEventReport => "tools.ozone.moderation.defs#modEventReport",
            Self::ModEventLabel => "tools.ozone.moderation.defs#modEventLabel",
            Self::ModEventAcknowledge => {
                "tools.ozone.moderation.defs#modEventAcknowledge"
            }
            Self::ModEventEscalate => "tools.ozone.moderation.defs#modEventEscalate",
            Self::ModEventMute => "tools.ozone.moderation.defs#modEventMute",
            Self::ModEventUnmute => "tools.ozone.moderation.defs#modEventUnmute",
            Self::ModEventMuteReporter => {
                "tools.ozone.moderation.defs#modEventMuteReporter"
            }
            Self::ModEventUnmuteReporter => {
                "tools.ozone.moderation.defs#modEventUnmuteReporter"
            }
            Self::ModEventEmail => "tools.ozone.moderation.defs#modEventEmail",
            Self::ModEventResolveAppeal => {
                "tools.ozone.moderation.defs#modEventResolveAppeal"
            }
            Self::ModEventDivert => "tools.ozone.moderation.defs#modEventDivert",
            Self::ModEventTag => "tools.ozone.moderation.defs#modEventTag",
            Self::AccountEvent => "tools.ozone.moderation.defs#accountEvent",
            Self::IdentityEvent => "tools.ozone.moderation.defs#identityEvent",
            Self::RecordEvent => "tools.ozone.moderation.defs#recordEvent",
            Self::ModEventPriorityScore => {
                "tools.ozone.moderation.defs#modEventPriorityScore"
            }
            Self::RevokeAccountCredentialsEvent => {
                "tools.ozone.moderation.defs#revokeAccountCredentialsEvent"
            }
            Self::AgeAssuranceEvent => "tools.ozone.moderation.defs#ageAssuranceEvent",
            Self::AgeAssuranceOverrideEvent => {
                "tools.ozone.moderation.defs#ageAssuranceOverrideEvent"
            }
            Self::TimelineEventPlcCreate => {
                "tools.ozone.moderation.defs#timelineEventPlcCreate"
            }
            Self::TimelineEventPlcOperation => {
                "tools.ozone.moderation.defs#timelineEventPlcOperation"
            }
            Self::TimelineEventPlcTombstone => {
                "tools.ozone.moderation.defs#timelineEventPlcTombstone"
            }
            Self::AccountCreated => {
                "tools.ozone.hosting.getAccountHistory#accountCreated"
            }
            Self::EmailConfirmed => {
                "tools.ozone.hosting.getAccountHistory#emailConfirmed"
            }
            Self::PasswordUpdated => {
                "tools.ozone.hosting.getAccountHistory#passwordUpdated"
            }
            Self::HandleUpdated => "tools.ozone.hosting.getAccountHistory#handleUpdated",
            Self::ScheduleTakedownEvent => {
                "tools.ozone.moderation.defs#scheduleTakedownEvent"
            }
            Self::CancelScheduledTakedownEvent => {
                "tools.ozone.moderation.defs#cancelScheduledTakedownEvent"
            }
            Self::Other(s) => s.as_ref(),
        }
    }
    /// Construct from a string-like value, matching known values.
    pub fn from_value(s: S) -> Self {
        match s.as_ref() {
            "tools.ozone.moderation.defs#modEventTakedown" => Self::ModEventTakedown,
            "tools.ozone.moderation.defs#modEventReverseTakedown" => {
                Self::ModEventReverseTakedown
            }
            "tools.ozone.moderation.defs#modEventComment" => Self::ModEventComment,
            "tools.ozone.moderation.defs#modEventReport" => Self::ModEventReport,
            "tools.ozone.moderation.defs#modEventLabel" => Self::ModEventLabel,
            "tools.ozone.moderation.defs#modEventAcknowledge" => {
                Self::ModEventAcknowledge
            }
            "tools.ozone.moderation.defs#modEventEscalate" => Self::ModEventEscalate,
            "tools.ozone.moderation.defs#modEventMute" => Self::ModEventMute,
            "tools.ozone.moderation.defs#modEventUnmute" => Self::ModEventUnmute,
            "tools.ozone.moderation.defs#modEventMuteReporter" => {
                Self::ModEventMuteReporter
            }
            "tools.ozone.moderation.defs#modEventUnmuteReporter" => {
                Self::ModEventUnmuteReporter
            }
            "tools.ozone.moderation.defs#modEventEmail" => Self::ModEventEmail,
            "tools.ozone.moderation.defs#modEventResolveAppeal" => {
                Self::ModEventResolveAppeal
            }
            "tools.ozone.moderation.defs#modEventDivert" => Self::ModEventDivert,
            "tools.ozone.moderation.defs#modEventTag" => Self::ModEventTag,
            "tools.ozone.moderation.defs#accountEvent" => Self::AccountEvent,
            "tools.ozone.moderation.defs#identityEvent" => Self::IdentityEvent,
            "tools.ozone.moderation.defs#recordEvent" => Self::RecordEvent,
            "tools.ozone.moderation.defs#modEventPriorityScore" => {
                Self::ModEventPriorityScore
            }
            "tools.ozone.moderation.defs#revokeAccountCredentialsEvent" => {
                Self::RevokeAccountCredentialsEvent
            }
            "tools.ozone.moderation.defs#ageAssuranceEvent" => Self::AgeAssuranceEvent,
            "tools.ozone.moderation.defs#ageAssuranceOverrideEvent" => {
                Self::AgeAssuranceOverrideEvent
            }
            "tools.ozone.moderation.defs#timelineEventPlcCreate" => {
                Self::TimelineEventPlcCreate
            }
            "tools.ozone.moderation.defs#timelineEventPlcOperation" => {
                Self::TimelineEventPlcOperation
            }
            "tools.ozone.moderation.defs#timelineEventPlcTombstone" => {
                Self::TimelineEventPlcTombstone
            }
            "tools.ozone.hosting.getAccountHistory#accountCreated" => {
                Self::AccountCreated
            }
            "tools.ozone.hosting.getAccountHistory#emailConfirmed" => {
                Self::EmailConfirmed
            }
            "tools.ozone.hosting.getAccountHistory#passwordUpdated" => {
                Self::PasswordUpdated
            }
            "tools.ozone.hosting.getAccountHistory#handleUpdated" => Self::HandleUpdated,
            "tools.ozone.moderation.defs#scheduleTakedownEvent" => {
                Self::ScheduleTakedownEvent
            }
            "tools.ozone.moderation.defs#cancelScheduledTakedownEvent" => {
                Self::CancelScheduledTakedownEvent
            }
            _ => Self::Other(s),
        }
    }
}

impl<S: BosStr> core::fmt::Display for TimelineItemSummaryEventType<S> {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        write!(f, "{}", self.as_str())
    }
}

impl<S: BosStr> AsRef<str> for TimelineItemSummaryEventType<S> {
    fn as_ref(&self) -> &str {
        self.as_str()
    }
}

impl<S: BosStr> Serialize for TimelineItemSummaryEventType<S> {
    fn serialize<Ser>(&self, serializer: Ser) -> Result<Ser::Ok, Ser::Error>
    where
        Ser: serde::Serializer,
    {
        serializer.serialize_str(self.as_str())
    }
}

impl<'de, S: Deserialize<'de> + BosStr> Deserialize<'de>
for TimelineItemSummaryEventType<S> {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let s = S::deserialize(deserializer)?;
        Ok(Self::from_value(s))
    }
}

impl<S: BosStr + Default> Default for TimelineItemSummaryEventType<S> {
    fn default() -> Self {
        Self::Other(Default::default())
    }
}

impl<S: BosStr> jacquard_common::IntoStatic for TimelineItemSummaryEventType<S>
where
    S: BosStr + jacquard_common::IntoStatic,
    S::Output: BosStr,
{
    type Output = TimelineItemSummaryEventType<S::Output>;
    fn into_static(self) -> Self::Output {
        match self {
            TimelineItemSummaryEventType::ModEventTakedown => {
                TimelineItemSummaryEventType::ModEventTakedown
            }
            TimelineItemSummaryEventType::ModEventReverseTakedown => {
                TimelineItemSummaryEventType::ModEventReverseTakedown
            }
            TimelineItemSummaryEventType::ModEventComment => {
                TimelineItemSummaryEventType::ModEventComment
            }
            TimelineItemSummaryEventType::ModEventReport => {
                TimelineItemSummaryEventType::ModEventReport
            }
            TimelineItemSummaryEventType::ModEventLabel => {
                TimelineItemSummaryEventType::ModEventLabel
            }
            TimelineItemSummaryEventType::ModEventAcknowledge => {
                TimelineItemSummaryEventType::ModEventAcknowledge
            }
            TimelineItemSummaryEventType::ModEventEscalate => {
                TimelineItemSummaryEventType::ModEventEscalate
            }
            TimelineItemSummaryEventType::ModEventMute => {
                TimelineItemSummaryEventType::ModEventMute
            }
            TimelineItemSummaryEventType::ModEventUnmute => {
                TimelineItemSummaryEventType::ModEventUnmute
            }
            TimelineItemSummaryEventType::ModEventMuteReporter => {
                TimelineItemSummaryEventType::ModEventMuteReporter
            }
            TimelineItemSummaryEventType::ModEventUnmuteReporter => {
                TimelineItemSummaryEventType::ModEventUnmuteReporter
            }
            TimelineItemSummaryEventType::ModEventEmail => {
                TimelineItemSummaryEventType::ModEventEmail
            }
            TimelineItemSummaryEventType::ModEventResolveAppeal => {
                TimelineItemSummaryEventType::ModEventResolveAppeal
            }
            TimelineItemSummaryEventType::ModEventDivert => {
                TimelineItemSummaryEventType::ModEventDivert
            }
            TimelineItemSummaryEventType::ModEventTag => {
                TimelineItemSummaryEventType::ModEventTag
            }
            TimelineItemSummaryEventType::AccountEvent => {
                TimelineItemSummaryEventType::AccountEvent
            }
            TimelineItemSummaryEventType::IdentityEvent => {
                TimelineItemSummaryEventType::IdentityEvent
            }
            TimelineItemSummaryEventType::RecordEvent => {
                TimelineItemSummaryEventType::RecordEvent
            }
            TimelineItemSummaryEventType::ModEventPriorityScore => {
                TimelineItemSummaryEventType::ModEventPriorityScore
            }
            TimelineItemSummaryEventType::RevokeAccountCredentialsEvent => {
                TimelineItemSummaryEventType::RevokeAccountCredentialsEvent
            }
            TimelineItemSummaryEventType::AgeAssuranceEvent => {
                TimelineItemSummaryEventType::AgeAssuranceEvent
            }
            TimelineItemSummaryEventType::AgeAssuranceOverrideEvent => {
                TimelineItemSummaryEventType::AgeAssuranceOverrideEvent
            }
            TimelineItemSummaryEventType::TimelineEventPlcCreate => {
                TimelineItemSummaryEventType::TimelineEventPlcCreate
            }
            TimelineItemSummaryEventType::TimelineEventPlcOperation => {
                TimelineItemSummaryEventType::TimelineEventPlcOperation
            }
            TimelineItemSummaryEventType::TimelineEventPlcTombstone => {
                TimelineItemSummaryEventType::TimelineEventPlcTombstone
            }
            TimelineItemSummaryEventType::AccountCreated => {
                TimelineItemSummaryEventType::AccountCreated
            }
            TimelineItemSummaryEventType::EmailConfirmed => {
                TimelineItemSummaryEventType::EmailConfirmed
            }
            TimelineItemSummaryEventType::PasswordUpdated => {
                TimelineItemSummaryEventType::PasswordUpdated
            }
            TimelineItemSummaryEventType::HandleUpdated => {
                TimelineItemSummaryEventType::HandleUpdated
            }
            TimelineItemSummaryEventType::ScheduleTakedownEvent => {
                TimelineItemSummaryEventType::ScheduleTakedownEvent
            }
            TimelineItemSummaryEventType::CancelScheduledTakedownEvent => {
                TimelineItemSummaryEventType::CancelScheduledTakedownEvent
            }
            TimelineItemSummaryEventType::Other(v) => {
                TimelineItemSummaryEventType::Other(v.into_static())
            }
        }
    }
}

/** Response marker for the `tools.ozone.moderation.getAccountTimeline` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetAccountTimelineOutput<S>` for this endpoint.*/
pub struct GetAccountTimelineResponse;
impl jacquard_common::xrpc::XrpcResp for GetAccountTimelineResponse {
    const NSID: &'static str = "tools.ozone.moderation.getAccountTimeline";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = GetAccountTimelineOutput<S>;
    type Err = GetAccountTimelineError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetAccountTimeline<S> {
    const NSID: &'static str = "tools.ozone.moderation.getAccountTimeline";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetAccountTimelineResponse;
}

/** Endpoint marker for the `tools.ozone.moderation.getAccountTimeline` query.

Path: `/xrpc/tools.ozone.moderation.getAccountTimeline`. The request payload type is `GetAccountTimeline<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct GetAccountTimelineRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetAccountTimelineRequest {
    const PATH: &'static str = "/xrpc/tools.ozone.moderation.getAccountTimeline";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = GetAccountTimeline<S>;
    type Response = GetAccountTimelineResponse;
}

impl<S: BosStr> LexiconSchema for TimelineItem<S> {
    fn nsid() -> &'static str {
        "tools.ozone.moderation.getAccountTimeline"
    }
    fn def_name() -> &'static str {
        "timelineItem"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_moderation_getAccountTimeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

impl<S: BosStr> LexiconSchema for TimelineItemSummary<S> {
    fn nsid() -> &'static str {
        "tools.ozone.moderation.getAccountTimeline"
    }
    fn def_name() -> &'static str {
        "timelineItemSummary"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_tools_ozone_moderation_getAccountTimeline()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

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

impl<S: BosStr> GetAccountTimeline<S> {
    /// Create a new builder for this type
    pub fn builder() -> GetAccountTimelineBuilder<get_account_timeline_state::Empty, S> {
        GetAccountTimelineBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> GetAccountTimelineBuilder<St, S>
where
    St: get_account_timeline_state::State,
    St::Did: get_account_timeline_state::IsUnset,
{
    /// Set the `did` field (required)
    pub fn did(
        mut self,
        value: impl Into<Did<S>>,
    ) -> GetAccountTimelineBuilder<get_account_timeline_state::SetDid<St>, S> {
        self._fields.0 = Option::Some(value.into());
        GetAccountTimelineBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> GetAccountTimelineBuilder<St, S>
where
    St: get_account_timeline_state::State,
    St::Did: get_account_timeline_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> GetAccountTimeline<S> {
        GetAccountTimeline {
            did: self._fields.0.unwrap(),
        }
    }
}

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

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

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

impl<S: BosStr> TimelineItem<S> {
    /// Create a new builder for this type
    pub fn builder() -> TimelineItemBuilder<timeline_item_state::Empty, S> {
        TimelineItemBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> TimelineItemBuilder<St, S>
where
    St: timeline_item_state::State,
    St::Day: timeline_item_state::IsUnset,
{
    /// Set the `day` field (required)
    pub fn day(
        mut self,
        value: impl Into<S>,
    ) -> TimelineItemBuilder<timeline_item_state::SetDay<St>, S> {
        self._fields.0 = Option::Some(value.into());
        TimelineItemBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TimelineItemBuilder<St, S>
where
    St: timeline_item_state::State,
    St::Summary: timeline_item_state::IsUnset,
{
    /// Set the `summary` field (required)
    pub fn summary(
        mut self,
        value: impl Into<Vec<get_account_timeline::TimelineItemSummary<S>>>,
    ) -> TimelineItemBuilder<timeline_item_state::SetSummary<St>, S> {
        self._fields.1 = Option::Some(value.into());
        TimelineItemBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TimelineItemBuilder<St, S>
where
    St: timeline_item_state::State,
    St::Day: timeline_item_state::IsSet,
    St::Summary: timeline_item_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> TimelineItem<S> {
        TimelineItem {
            day: self._fields.0.unwrap(),
            summary: self._fields.1.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>>,
    ) -> TimelineItem<S> {
        TimelineItem {
            day: self._fields.0.unwrap(),
            summary: self._fields.1.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_tools_ozone_moderation_getAccountTimeline() -> 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("tools.ozone.moderation.getAccountTimeline"),
        defs: {
            let mut map = BTreeMap::new();
            map.insert(
                SmolStr::new_static("main"),
                LexUserType::XrpcQuery(LexXrpcQuery {
                    parameters: Some(
                        LexXrpcQueryParameter::Params(LexXrpcParameters {
                            required: Some(vec![SmolStr::new_static("did")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("did"),
                                    LexXrpcParametersProperty::String(LexString {
                                        format: Some(LexStringFormat::Did),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("timelineItem"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![SmolStr::new_static("day"), SmolStr::new_static("summary")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("day"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("summary"),
                            LexObjectProperty::Array(LexArray {
                                items: LexArrayItem::Ref(LexRef {
                                    r#ref: CowStr::new_static("#timelineItemSummary"),
                                    ..Default::default()
                                }),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("timelineItemSummary"),
                LexUserType::Object(LexObject {
                    required: Some(
                        vec![
                            SmolStr::new_static("eventSubjectType"),
                            SmolStr::new_static("eventType"),
                            SmolStr::new_static("count")
                        ],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("count"),
                            LexObjectProperty::Integer(LexInteger {
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("eventSubjectType"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("eventType"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}

pub mod timeline_item_summary_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 Count;
        type EventSubjectType;
        type EventType;
    }
    /// Empty state - all required fields are unset
    pub struct Empty(());
    impl sealed::Sealed for Empty {}
    impl State for Empty {
        type Count = Unset;
        type EventSubjectType = Unset;
        type EventType = Unset;
    }
    ///State transition - sets the `count` field to Set
    pub struct SetCount<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetCount<St> {}
    impl<St: State> State for SetCount<St> {
        type Count = Set<members::count>;
        type EventSubjectType = St::EventSubjectType;
        type EventType = St::EventType;
    }
    ///State transition - sets the `event_subject_type` field to Set
    pub struct SetEventSubjectType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetEventSubjectType<St> {}
    impl<St: State> State for SetEventSubjectType<St> {
        type Count = St::Count;
        type EventSubjectType = Set<members::event_subject_type>;
        type EventType = St::EventType;
    }
    ///State transition - sets the `event_type` field to Set
    pub struct SetEventType<St: State = Empty>(PhantomData<fn() -> St>);
    impl<St: State> sealed::Sealed for SetEventType<St> {}
    impl<St: State> State for SetEventType<St> {
        type Count = St::Count;
        type EventSubjectType = St::EventSubjectType;
        type EventType = Set<members::event_type>;
    }
    /// Marker types for field names
    #[allow(non_camel_case_types)]
    pub mod members {
        ///Marker type for the `count` field
        pub struct count(());
        ///Marker type for the `event_subject_type` field
        pub struct event_subject_type(());
        ///Marker type for the `event_type` field
        pub struct event_type(());
    }
}

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

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

impl<S: BosStr> TimelineItemSummary<S> {
    /// Create a new builder for this type
    pub fn builder() -> TimelineItemSummaryBuilder<
        timeline_item_summary_state::Empty,
        S,
    > {
        TimelineItemSummaryBuilder::builder()
    }
}

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

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

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

impl<St, S: BosStr> TimelineItemSummaryBuilder<St, S>
where
    St: timeline_item_summary_state::State,
    St::EventSubjectType: timeline_item_summary_state::IsUnset,
{
    /// Set the `eventSubjectType` field (required)
    pub fn event_subject_type(
        mut self,
        value: impl Into<TimelineItemSummaryEventSubjectType<S>>,
    ) -> TimelineItemSummaryBuilder<
        timeline_item_summary_state::SetEventSubjectType<St>,
        S,
    > {
        self._fields.1 = Option::Some(value.into());
        TimelineItemSummaryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TimelineItemSummaryBuilder<St, S>
where
    St: timeline_item_summary_state::State,
    St::EventType: timeline_item_summary_state::IsUnset,
{
    /// Set the `eventType` field (required)
    pub fn event_type(
        mut self,
        value: impl Into<TimelineItemSummaryEventType<S>>,
    ) -> TimelineItemSummaryBuilder<timeline_item_summary_state::SetEventType<St>, S> {
        self._fields.2 = Option::Some(value.into());
        TimelineItemSummaryBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> TimelineItemSummaryBuilder<St, S>
where
    St: timeline_item_summary_state::State,
    St::Count: timeline_item_summary_state::IsSet,
    St::EventSubjectType: timeline_item_summary_state::IsSet,
    St::EventType: timeline_item_summary_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> TimelineItemSummary<S> {
        TimelineItemSummary {
            count: self._fields.0.unwrap(),
            event_subject_type: self._fields.1.unwrap(),
            event_type: self._fields.2.unwrap(),
            extra_data: Default::default(),
        }
    }
    /// Build the final struct with custom extra_data.
    pub fn build_with_data(
        self,
        extra_data: BTreeMap<SmolStr, Data<S>>,
    ) -> TimelineItemSummary<S> {
        TimelineItemSummary {
            count: self._fields.0.unwrap(),
            event_subject_type: self._fields.1.unwrap(),
            event_type: self._fields.2.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}