// @generated by jacquard-lexicon. DO NOT EDIT.
//
// Lexicon: sh.weaver.notebook.getEntryNotebooks
//
// 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::{AtUri, Cid};
use jacquard_common::types::value::Data;
use jacquard_derive::IntoStatic;
use jacquard_lexicon::lexicon::LexiconDoc;
use jacquard_lexicon::schema::LexiconSchema;

#[allow(unused_imports)]
use jacquard_lexicon::validation::{ConstraintError, ValidationPath};
use serde::{Serialize, Deserialize};
use crate::sh_weaver::actor::ProfileViewBasic;
use crate::sh_weaver::notebook::get_entry_notebooks;

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


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

/// Reference to a notebook containing this entry.

#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, IntoStatic)]
#[serde(rename_all = "camelCase", bound(deserialize = "S: Deserialize<'de> + BosStr"))]
pub struct NotebookRef<S: BosStr = DefaultStr> {
    pub cid: Cid<S>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub owner: Option<ProfileViewBasic<S>>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub title: Option<S>,
    pub uri: AtUri<S>,
    #[serde(flatten, default, skip_serializing_if = "Option::is_none")]
    pub extra_data: Option<BTreeMap<SmolStr, Data<S>>>,
}

/** Response marker for the `sh.weaver.notebook.getEntryNotebooks` query.

Implements `jacquard_common::xrpc::XrpcResp`; successful bodies decode as `Self::Output<S>`, which is `GetEntryNotebooksOutput<S>` for this endpoint.*/
pub struct GetEntryNotebooksResponse;
impl jacquard_common::xrpc::XrpcResp for GetEntryNotebooksResponse {
    const NSID: &'static str = "sh.weaver.notebook.getEntryNotebooks";
    const ENCODING: &'static str = "application/json";
    type Output<S: BosStr> = GetEntryNotebooksOutput<S>;
    type Err = jacquard_common::xrpc::GenericError;
}

impl<S: BosStr> jacquard_common::xrpc::XrpcRequest for GetEntryNotebooks<S> {
    const NSID: &'static str = "sh.weaver.notebook.getEntryNotebooks";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Response = GetEntryNotebooksResponse;
}

/** Endpoint marker for the `sh.weaver.notebook.getEntryNotebooks` query.

Path: `/xrpc/sh.weaver.notebook.getEntryNotebooks`. The request payload type is `GetEntryNotebooks<S>`; send that request with `jacquard::Client` or use this marker through lower-level `XrpcEndpoint` APIs.*/
pub struct GetEntryNotebooksRequest;
impl jacquard_common::xrpc::XrpcEndpoint for GetEntryNotebooksRequest {
    const PATH: &'static str = "/xrpc/sh.weaver.notebook.getEntryNotebooks";
    const METHOD: jacquard_common::xrpc::XrpcMethod = jacquard_common::xrpc::XrpcMethod::Query;
    type Request<S: BosStr> = GetEntryNotebooks<S>;
    type Response = GetEntryNotebooksResponse;
}

impl<S: BosStr> LexiconSchema for NotebookRef<S> {
    fn nsid() -> &'static str {
        "sh.weaver.notebook.getEntryNotebooks"
    }
    fn def_name() -> &'static str {
        "notebookRef"
    }
    fn lexicon_doc() -> LexiconDoc<'static> {
        lexicon_doc_sh_weaver_notebook_getEntryNotebooks()
    }
    fn validate(&self) -> Result<(), ConstraintError> {
        Ok(())
    }
}

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

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

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

impl<S: BosStr> GetEntryNotebooks<S> {
    /// Create a new builder for this type
    pub fn builder() -> GetEntryNotebooksBuilder<get_entry_notebooks_state::Empty, S> {
        GetEntryNotebooksBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> GetEntryNotebooksBuilder<St, S>
where
    St: get_entry_notebooks_state::State,
    St::Entry: get_entry_notebooks_state::IsUnset,
{
    /// Set the `entry` field (required)
    pub fn entry(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> GetEntryNotebooksBuilder<get_entry_notebooks_state::SetEntry<St>, S> {
        self._fields.0 = Option::Some(value.into());
        GetEntryNotebooksBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> GetEntryNotebooksBuilder<St, S>
where
    St: get_entry_notebooks_state::State,
    St::Entry: get_entry_notebooks_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> GetEntryNotebooks<S> {
        GetEntryNotebooks {
            entry: self._fields.0.unwrap(),
        }
    }
}

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

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

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

impl<S: BosStr> NotebookRef<S> {
    /// Create a new builder for this type
    pub fn builder() -> NotebookRefBuilder<notebook_ref_state::Empty, S> {
        NotebookRefBuilder::builder()
    }
}

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

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

impl<St, S: BosStr> NotebookRefBuilder<St, S>
where
    St: notebook_ref_state::State,
    St::Cid: notebook_ref_state::IsUnset,
{
    /// Set the `cid` field (required)
    pub fn cid(
        mut self,
        value: impl Into<Cid<S>>,
    ) -> NotebookRefBuilder<notebook_ref_state::SetCid<St>, S> {
        self._fields.0 = Option::Some(value.into());
        NotebookRefBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St: notebook_ref_state::State, S: BosStr> NotebookRefBuilder<St, S> {
    /// Set the `owner` field (optional)
    pub fn owner(mut self, value: impl Into<Option<ProfileViewBasic<S>>>) -> Self {
        self._fields.1 = value.into();
        self
    }
    /// Set the `owner` field to an Option value (optional)
    pub fn maybe_owner(mut self, value: Option<ProfileViewBasic<S>>) -> Self {
        self._fields.1 = value;
        self
    }
}

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

impl<St, S: BosStr> NotebookRefBuilder<St, S>
where
    St: notebook_ref_state::State,
    St::Uri: notebook_ref_state::IsUnset,
{
    /// Set the `uri` field (required)
    pub fn uri(
        mut self,
        value: impl Into<AtUri<S>>,
    ) -> NotebookRefBuilder<notebook_ref_state::SetUri<St>, S> {
        self._fields.3 = Option::Some(value.into());
        NotebookRefBuilder {
            _state: PhantomData,
            _fields: self._fields,
            _type: PhantomData,
        }
    }
}

impl<St, S: BosStr> NotebookRefBuilder<St, S>
where
    St: notebook_ref_state::State,
    St::Cid: notebook_ref_state::IsSet,
    St::Uri: notebook_ref_state::IsSet,
{
    /// Build the final struct.
    pub fn build(self) -> NotebookRef<S> {
        NotebookRef {
            cid: self._fields.0.unwrap(),
            owner: self._fields.1,
            title: self._fields.2,
            uri: 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>>,
    ) -> NotebookRef<S> {
        NotebookRef {
            cid: self._fields.0.unwrap(),
            owner: self._fields.1,
            title: self._fields.2,
            uri: self._fields.3.unwrap(),
            extra_data: Some(extra_data),
        }
    }
}

fn lexicon_doc_sh_weaver_notebook_getEntryNotebooks() -> LexiconDoc<'static> {
    #[allow(unused_imports)]
    use jacquard_common::{CowStr, deps::smol_str::SmolStr, types::blob::MimeType};
    use jacquard_lexicon::lexicon::*;
    use alloc::collections::BTreeMap;
    LexiconDoc {
        lexicon: Lexicon::Lexicon1,
        id: CowStr::new_static("sh.weaver.notebook.getEntryNotebooks"),
        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("entry")]),
                            properties: {
                                #[allow(unused_mut)]
                                let mut map = BTreeMap::new();
                                map.insert(
                                    SmolStr::new_static("entry"),
                                    LexXrpcParametersProperty::String(LexString {
                                        description: Some(
                                            CowStr::new_static("AT URI of the entry"),
                                        ),
                                        format: Some(LexStringFormat::AtUri),
                                        ..Default::default()
                                    }),
                                );
                                map
                            },
                            ..Default::default()
                        }),
                    ),
                    ..Default::default()
                }),
            );
            map.insert(
                SmolStr::new_static("notebookRef"),
                LexUserType::Object(LexObject {
                    description: Some(
                        CowStr::new_static(
                            "Reference to a notebook containing this entry.",
                        ),
                    ),
                    required: Some(
                        vec![SmolStr::new_static("uri"), SmolStr::new_static("cid")],
                    ),
                    properties: {
                        #[allow(unused_mut)]
                        let mut map = BTreeMap::new();
                        map.insert(
                            SmolStr::new_static("cid"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::Cid),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("owner"),
                            LexObjectProperty::Ref(LexRef {
                                r#ref: CowStr::new_static(
                                    "sh.weaver.actor.defs#profileViewBasic",
                                ),
                                ..Default::default()
                            }),
                        );
                        map.insert(
                            SmolStr::new_static("title"),
                            LexObjectProperty::String(LexString { ..Default::default() }),
                        );
                        map.insert(
                            SmolStr::new_static("uri"),
                            LexObjectProperty::String(LexString {
                                format: Some(LexStringFormat::AtUri),
                                ..Default::default()
                            }),
                        );
                        map
                    },
                    ..Default::default()
                }),
            );
            map
        },
        ..Default::default()
    }
}