// @generated — Generated by `cargo xtask machine-codegen --all`.
#![allow(
    clippy::unwrap_used,
    clippy::expect_used,
    clippy::panic,
    clippy::implicit_clone,
    clippy::unnecessary_cast,
    clippy::redundant_clone,
    clippy::zero_sized_map_values
)]

pub fn schema() -> meerkat_machine_schema::MachineSchema {
    meerkat_machine_schema::catalog::dsl::dsl_auth_machine()
}

#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum AuthLifecyclePhase {
    #[default]
    #[serde(rename = "Valid")]
    Valid,
    #[serde(rename = "Expiring")]
    Expiring,
    #[serde(rename = "Expired")]
    Expired,
    #[serde(rename = "Refreshing")]
    Refreshing,
    #[serde(rename = "ReauthRequired")]
    ReauthRequired,
    #[serde(rename = "Released")]
    Released,
}
impl AuthLifecyclePhase {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Valid => "Valid",
            Self::Expiring => "Expiring",
            Self::Expired => "Expired",
            Self::Refreshing => "Refreshing",
            Self::ReauthRequired => "ReauthRequired",
            Self::Released => "Released",
        }
    }
}
impl std::convert::TryFrom<&str> for AuthLifecyclePhase {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Valid" => Ok(Self::Valid),
            "Expiring" => Ok(Self::Expiring),
            "Expired" => Ok(Self::Expired),
            "Refreshing" => Ok(Self::Refreshing),
            "ReauthRequired" => Ok(Self::ReauthRequired),
            "Released" => Ok(Self::Released),
            other => Err(format!("invalid AuthLifecyclePhase value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for AuthLifecyclePhase {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for AuthLifecyclePhase {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum CredentialUseDisposition {
    #[default]
    #[serde(rename = "Authorized")]
    Authorized,
    #[serde(rename = "RefreshRequired")]
    RefreshRequired,
    #[serde(rename = "RefreshDisallowed")]
    RefreshDisallowed,
    #[serde(rename = "ReauthRequired")]
    ReauthRequired,
    #[serde(rename = "LeaseAbsent")]
    LeaseAbsent,
    #[serde(rename = "AlreadyRefreshing")]
    AlreadyRefreshing,
}
impl CredentialUseDisposition {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::Authorized => "Authorized",
            Self::RefreshRequired => "RefreshRequired",
            Self::RefreshDisallowed => "RefreshDisallowed",
            Self::ReauthRequired => "ReauthRequired",
            Self::LeaseAbsent => "LeaseAbsent",
            Self::AlreadyRefreshing => "AlreadyRefreshing",
        }
    }
}
impl std::convert::TryFrom<&str> for CredentialUseDisposition {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "Authorized" => Ok(Self::Authorized),
            "RefreshRequired" => Ok(Self::RefreshRequired),
            "RefreshDisallowed" => Ok(Self::RefreshDisallowed),
            "ReauthRequired" => Ok(Self::ReauthRequired),
            "LeaseAbsent" => Ok(Self::LeaseAbsent),
            "AlreadyRefreshing" => Ok(Self::AlreadyRefreshing),
            other => Err(format!("invalid CredentialUseDisposition value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for CredentialUseDisposition {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for CredentialUseDisposition {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}
#[allow(non_camel_case_types)]
#[derive(
    Debug,
    Clone,
    Copy,
    Default,
    PartialEq,
    Eq,
    PartialOrd,
    Ord,
    Hash,
    serde::Serialize,
    serde::Deserialize,
)]
pub enum CredentialUseIntent {
    #[default]
    #[serde(rename = "UseCredential")]
    UseCredential,
    #[serde(rename = "HoldAuthority")]
    HoldAuthority,
    #[serde(rename = "BeginRefresh")]
    BeginRefresh,
}
impl CredentialUseIntent {
    pub fn as_str(&self) -> &'static str {
        match self {
            Self::UseCredential => "UseCredential",
            Self::HoldAuthority => "HoldAuthority",
            Self::BeginRefresh => "BeginRefresh",
        }
    }
}
impl std::convert::TryFrom<&str> for CredentialUseIntent {
    type Error = String;
    fn try_from(value: &str) -> Result<Self, Self::Error> {
        match value {
            "UseCredential" => Ok(Self::UseCredential),
            "HoldAuthority" => Ok(Self::HoldAuthority),
            "BeginRefresh" => Ok(Self::BeginRefresh),
            other => Err(format!("invalid CredentialUseIntent value `{other}`")),
        }
    }
}
impl std::convert::TryFrom<String> for CredentialUseIntent {
    type Error = String;
    fn try_from(value: String) -> Result<Self, Self::Error> {
        Self::try_from(value.as_str())
    }
}
impl std::fmt::Display for CredentialUseIntent {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}

pub trait Context {}
pub struct EmptyContext;
impl Context for EmptyContext {}

#[allow(non_camel_case_types)]
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Phase {
    Valid,
    Expiring,
    Expired,
    Refreshing,
    ReauthRequired,
    Released,
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct State {
    pub phase: Phase,
    pub expires_at: Option<u64>,
    pub last_refresh: Option<u64>,
    pub refresh_attempt: u64,
    pub credential_present: bool,
    pub credential_generation: u64,
    pub credential_published_at_millis: Option<u64>,
    pub oauth_browser_flow_ids: std::collections::BTreeSet<String>,
    pub oauth_browser_flow_providers: std::collections::BTreeMap<String, String>,
    pub oauth_browser_flow_redirect_uris: std::collections::BTreeMap<String, String>,
    pub oauth_browser_flow_expires_at_millis: std::collections::BTreeMap<String, u64>,
    pub oauth_device_flow_ids: std::collections::BTreeSet<String>,
    pub oauth_device_flow_providers: std::collections::BTreeMap<String, String>,
    pub oauth_device_flow_expires_at_millis: std::collections::BTreeMap<String, u64>,
    pub oauth_device_poll_ids: std::collections::BTreeSet<String>,
    pub oauth_outstanding_flow_count: u64,
    pub release_draining: bool,
}
impl Default for State {
    fn default() -> Self {
        initial_state()
    }
}

pub mod inputs {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Acquire {
        pub expires_at_ts: Option<u64>,
        pub credential_published_at_millis: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct MarkExpiring {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ObserveCredentialFreshness {
        pub now_ts: u64,
        pub refresh_window_secs: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct BeginRefresh {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CompleteRefresh {
        pub new_expires_at: Option<u64>,
        pub now_ts: u64,
        pub credential_published_at_millis: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RefreshFailed {
        pub http_status: Option<u64>,
        pub oauth_error_code: Option<String>,
        pub local_credential_unusable: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct MarkReauthRequired {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ClearCredentialLifecycle {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ReleaseCredentialLifecycle {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct BeginRelease {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct Release {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RestoreAuthoritySnapshot {
        pub lifecycle_phase: AuthLifecyclePhase,
        pub expires_at: Option<u64>,
        pub last_refresh: Option<u64>,
        pub refresh_attempt: u64,
        pub credential_present: bool,
        pub credential_generation: u64,
        pub credential_published_at_millis: Option<u64>,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RestoreCredentialLifecycleSnapshot {
        pub lifecycle_phase: Option<AuthLifecyclePhase>,
        pub expires_at: Option<u64>,
        pub last_refresh: Option<u64>,
        pub refresh_attempt: u64,
        pub credential_present: bool,
        pub credential_generation: u64,
        pub credential_published_at_millis: Option<u64>,
        pub restored_oauth_membership_observed: bool,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RestoreOAuthBrowserFlow {
        pub flow_id: String,
        pub provider: Option<String>,
        pub redirect_uri: Option<String>,
        pub expires_at_millis: Option<u64>,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RestoreOAuthDeviceFlow {
        pub flow_id: String,
        pub provider: Option<String>,
        pub expires_at_millis: Option<u64>,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct RestoreOAuthDevicePoll {
        pub flow_id: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AdmitOAuthBrowserFlow {
        pub flow_id: String,
        pub provider: String,
        pub redirect_uri: String,
        pub expires_at_millis: u64,
        pub max_outstanding_flows: u64,
        pub observed_global_outstanding_flows: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct VerifyOAuthBrowserFlow {
        pub flow_id: String,
        pub provider: String,
        pub redirect_uri: String,
        pub now_millis: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ConsumeOAuthBrowserFlow {
        pub flow_id: String,
        pub provider: String,
        pub redirect_uri: String,
        pub now_millis: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ExpireOAuthBrowserFlow {
        pub flow_id: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct AdmitOAuthDeviceFlow {
        pub flow_id: String,
        pub provider: String,
        pub expires_at_millis: u64,
        pub max_outstanding_flows: u64,
        pub observed_global_outstanding_flows: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ConfirmOAuthDurableAdmission {
        pub observed_global_outstanding_flows: u64,
        pub max_outstanding_flows: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct VerifyOAuthDeviceFlow {
        pub flow_id: String,
        pub provider: String,
        pub now_millis: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct BeginOAuthDevicePoll {
        pub flow_id: String,
        pub provider: String,
        pub now_millis: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct FinishOAuthDevicePoll {
        pub flow_id: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ConsumeOAuthDeviceFlow {
        pub flow_id: String,
        pub provider: String,
        pub now_millis: u64,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ExpireOAuthDeviceFlow {
        pub flow_id: String,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveCredentialUseAdmission {
        pub intent: CredentialUseIntent,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct ResolveOAuthLoginCredentialDisposition {
        pub credential_present: bool,
        pub force_refresh: bool,
        pub refresh_allowed: bool,
    }
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Input {
    Acquire(inputs::Acquire),
    MarkExpiring(inputs::MarkExpiring),
    ObserveCredentialFreshness(inputs::ObserveCredentialFreshness),
    BeginRefresh(inputs::BeginRefresh),
    CompleteRefresh(inputs::CompleteRefresh),
    RefreshFailed(inputs::RefreshFailed),
    MarkReauthRequired(inputs::MarkReauthRequired),
    ClearCredentialLifecycle(inputs::ClearCredentialLifecycle),
    ReleaseCredentialLifecycle(inputs::ReleaseCredentialLifecycle),
    BeginRelease(inputs::BeginRelease),
    Release(inputs::Release),
    RestoreAuthoritySnapshot(inputs::RestoreAuthoritySnapshot),
    RestoreCredentialLifecycleSnapshot(inputs::RestoreCredentialLifecycleSnapshot),
    RestoreOAuthBrowserFlow(inputs::RestoreOAuthBrowserFlow),
    RestoreOAuthDeviceFlow(inputs::RestoreOAuthDeviceFlow),
    RestoreOAuthDevicePoll(inputs::RestoreOAuthDevicePoll),
    AdmitOAuthBrowserFlow(inputs::AdmitOAuthBrowserFlow),
    VerifyOAuthBrowserFlow(inputs::VerifyOAuthBrowserFlow),
    ConsumeOAuthBrowserFlow(inputs::ConsumeOAuthBrowserFlow),
    ExpireOAuthBrowserFlow(inputs::ExpireOAuthBrowserFlow),
    AdmitOAuthDeviceFlow(inputs::AdmitOAuthDeviceFlow),
    ConfirmOAuthDurableAdmission(inputs::ConfirmOAuthDurableAdmission),
    VerifyOAuthDeviceFlow(inputs::VerifyOAuthDeviceFlow),
    BeginOAuthDevicePoll(inputs::BeginOAuthDevicePoll),
    FinishOAuthDevicePoll(inputs::FinishOAuthDevicePoll),
    ConsumeOAuthDeviceFlow(inputs::ConsumeOAuthDeviceFlow),
    ExpireOAuthDeviceFlow(inputs::ExpireOAuthDeviceFlow),
    ResolveCredentialUseAdmission(inputs::ResolveCredentialUseAdmission),
    ResolveOAuthLoginCredentialDisposition(inputs::ResolveOAuthLoginCredentialDisposition),
}
impl Input {
    pub fn kind(&self) -> InputKind {
        match self {
            Self::Acquire(_) => InputKind::Acquire,
            Self::MarkExpiring(_) => InputKind::MarkExpiring,
            Self::ObserveCredentialFreshness(_) => InputKind::ObserveCredentialFreshness,
            Self::BeginRefresh(_) => InputKind::BeginRefresh,
            Self::CompleteRefresh(_) => InputKind::CompleteRefresh,
            Self::RefreshFailed(_) => InputKind::RefreshFailed,
            Self::MarkReauthRequired(_) => InputKind::MarkReauthRequired,
            Self::ClearCredentialLifecycle(_) => InputKind::ClearCredentialLifecycle,
            Self::ReleaseCredentialLifecycle(_) => InputKind::ReleaseCredentialLifecycle,
            Self::BeginRelease(_) => InputKind::BeginRelease,
            Self::Release(_) => InputKind::Release,
            Self::RestoreAuthoritySnapshot(_) => InputKind::RestoreAuthoritySnapshot,
            Self::RestoreCredentialLifecycleSnapshot(_) => {
                InputKind::RestoreCredentialLifecycleSnapshot
            }
            Self::RestoreOAuthBrowserFlow(_) => InputKind::RestoreOAuthBrowserFlow,
            Self::RestoreOAuthDeviceFlow(_) => InputKind::RestoreOAuthDeviceFlow,
            Self::RestoreOAuthDevicePoll(_) => InputKind::RestoreOAuthDevicePoll,
            Self::AdmitOAuthBrowserFlow(_) => InputKind::AdmitOAuthBrowserFlow,
            Self::VerifyOAuthBrowserFlow(_) => InputKind::VerifyOAuthBrowserFlow,
            Self::ConsumeOAuthBrowserFlow(_) => InputKind::ConsumeOAuthBrowserFlow,
            Self::ExpireOAuthBrowserFlow(_) => InputKind::ExpireOAuthBrowserFlow,
            Self::AdmitOAuthDeviceFlow(_) => InputKind::AdmitOAuthDeviceFlow,
            Self::ConfirmOAuthDurableAdmission(_) => InputKind::ConfirmOAuthDurableAdmission,
            Self::VerifyOAuthDeviceFlow(_) => InputKind::VerifyOAuthDeviceFlow,
            Self::BeginOAuthDevicePoll(_) => InputKind::BeginOAuthDevicePoll,
            Self::FinishOAuthDevicePoll(_) => InputKind::FinishOAuthDevicePoll,
            Self::ConsumeOAuthDeviceFlow(_) => InputKind::ConsumeOAuthDeviceFlow,
            Self::ExpireOAuthDeviceFlow(_) => InputKind::ExpireOAuthDeviceFlow,
            Self::ResolveCredentialUseAdmission(_) => InputKind::ResolveCredentialUseAdmission,
            Self::ResolveOAuthLoginCredentialDisposition(_) => {
                InputKind::ResolveOAuthLoginCredentialDisposition
            }
        }
    }
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum InputKind {
    Acquire,
    MarkExpiring,
    ObserveCredentialFreshness,
    BeginRefresh,
    CompleteRefresh,
    RefreshFailed,
    MarkReauthRequired,
    ClearCredentialLifecycle,
    ReleaseCredentialLifecycle,
    BeginRelease,
    Release,
    RestoreAuthoritySnapshot,
    RestoreCredentialLifecycleSnapshot,
    RestoreOAuthBrowserFlow,
    RestoreOAuthDeviceFlow,
    RestoreOAuthDevicePoll,
    AdmitOAuthBrowserFlow,
    VerifyOAuthBrowserFlow,
    ConsumeOAuthBrowserFlow,
    ExpireOAuthBrowserFlow,
    AdmitOAuthDeviceFlow,
    ConfirmOAuthDurableAdmission,
    VerifyOAuthDeviceFlow,
    BeginOAuthDevicePoll,
    FinishOAuthDevicePoll,
    ConsumeOAuthDeviceFlow,
    ExpireOAuthDeviceFlow,
    ResolveCredentialUseAdmission,
    ResolveOAuthLoginCredentialDisposition,
}

pub mod effects {
    #[allow(unused_imports)]
    use super::*;
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct EmitLifecycleEvent {
        pub new_state: AuthLifecyclePhase,
        pub expires_at: Option<u64>,
        pub credential_generation: u64,
        pub credential_published_at_millis: Option<u64>,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct WakeRefreshLoop {}
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CredentialUseAdmissionResolved {
        pub disposition: CredentialUseDisposition,
    }
    #[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
    pub struct CancelOAuthFlowsForRelease {
        pub browser_flow_ids: std::collections::BTreeSet<String>,
        pub device_flow_ids: std::collections::BTreeSet<String>,
    }
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum Effect {
    EmitLifecycleEvent(effects::EmitLifecycleEvent),
    WakeRefreshLoop(effects::WakeRefreshLoop),
    CredentialUseAdmissionResolved(effects::CredentialUseAdmissionResolved),
    CancelOAuthFlowsForRelease(effects::CancelOAuthFlowsForRelease),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum EffectKind {
    EmitLifecycleEvent,
    WakeRefreshLoop,
    CredentialUseAdmissionResolved,
    CancelOAuthFlowsForRelease,
}

#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum TransitionId {
    Acquire,
    MarkExpiring,
    ObserveCredentialFreshnessValid,
    ObserveCredentialFreshnessExpiringFromValid,
    ObserveCredentialFreshnessExpiredFromValid,
    ObserveCredentialFreshnessExpiring,
    ObserveCredentialFreshnessExpiredFromExpiring,
    ObserveCredentialFreshnessExpired,
    ObserveCredentialFreshnessRefreshing,
    ObserveCredentialFreshnessReauthRequired,
    ObserveCredentialFreshnessReleased,
    BeginRefreshFromValid,
    BeginRefreshFromExpiring,
    BeginRefreshFromExpired,
    CompleteRefresh,
    RefreshFailedTransient,
    RefreshFailedPermanent,
    MarkReauthRequiredFromValid,
    MarkReauthRequiredFromExpiring,
    MarkReauthRequiredFromExpired,
    MarkReauthRequiredFromRefreshing,
    ClearCredentialLifecycle,
    ReleaseCredentialLifecycleWithOAuth,
    ReleaseCredentialLifecycleWithoutOAuth,
    BeginReleaseDrainingOAuthFlowsValid,
    BeginReleaseDrainingOAuthFlowsExpiring,
    BeginReleaseDrainingOAuthFlowsExpired,
    BeginReleaseDrainingOAuthFlowsRefreshing,
    BeginReleaseDrainingOAuthFlowsReauthRequired,
    BeginReleaseWithoutOAuthFlowsValid,
    BeginReleaseWithoutOAuthFlowsExpiring,
    BeginReleaseWithoutOAuthFlowsExpired,
    BeginReleaseWithoutOAuthFlowsRefreshing,
    BeginReleaseWithoutOAuthFlowsReauthRequired,
    BeginReleaseReleased,
    Release,
    RestoreCredentialLifecycleSnapshotValid,
    RestoreCredentialLifecycleSnapshotExpiring,
    RestoreCredentialLifecycleSnapshotRefreshing,
    RestoreCredentialLifecycleSnapshotExpired,
    RestoreCredentialLifecycleSnapshotReauthRequired,
    RestoreCredentialLifecycleSnapshotNoCredentialWithOAuth,
    RestoreCredentialLifecycleSnapshotNoCredentialWithoutOAuth,
    RestoreAuthoritySnapshotValid,
    RestoreAuthoritySnapshotExpiring,
    RestoreAuthoritySnapshotRefreshing,
    RestoreAuthoritySnapshotExpired,
    RestoreAuthoritySnapshotReauthRequired,
    RestoreAuthoritySnapshotReleased,
    RestoreOAuthBrowserFlowValid,
    RestoreOAuthBrowserFlowExpiring,
    RestoreOAuthBrowserFlowExpired,
    RestoreOAuthBrowserFlowRefreshing,
    RestoreOAuthBrowserFlowReauthRequired,
    RestoreOAuthDeviceFlowValid,
    RestoreOAuthDeviceFlowExpiring,
    RestoreOAuthDeviceFlowExpired,
    RestoreOAuthDeviceFlowRefreshing,
    RestoreOAuthDeviceFlowReauthRequired,
    RestoreOAuthDevicePollValid,
    RestoreOAuthDevicePollExpiring,
    RestoreOAuthDevicePollExpired,
    RestoreOAuthDevicePollRefreshing,
    RestoreOAuthDevicePollReauthRequired,
    AdmitOAuthBrowserFlowValid,
    AdmitOAuthBrowserFlowExpiring,
    AdmitOAuthBrowserFlowExpired,
    AdmitOAuthBrowserFlowRefreshing,
    AdmitOAuthBrowserFlowReauthRequired,
    ReopenReleasedForOAuthBrowserFlowAdmission,
    VerifyOAuthBrowserFlowValid,
    VerifyOAuthBrowserFlowExpiring,
    VerifyOAuthBrowserFlowExpired,
    VerifyOAuthBrowserFlowRefreshing,
    VerifyOAuthBrowserFlowReauthRequired,
    ConsumeOAuthBrowserFlowValid,
    ConsumeOAuthBrowserFlowExpiring,
    ConsumeOAuthBrowserFlowExpired,
    ConsumeOAuthBrowserFlowRefreshing,
    ConsumeOAuthBrowserFlowReauthRequired,
    ExpireOAuthBrowserFlowValid,
    ExpireOAuthBrowserFlowExpiring,
    ExpireOAuthBrowserFlowExpired,
    ExpireOAuthBrowserFlowRefreshing,
    ExpireOAuthBrowserFlowReauthRequired,
    ExpireOAuthBrowserFlowAbsentValid,
    ExpireOAuthBrowserFlowAbsentExpiring,
    ExpireOAuthBrowserFlowAbsentExpired,
    ExpireOAuthBrowserFlowAbsentRefreshing,
    ExpireOAuthBrowserFlowAbsentReauthRequired,
    ExpireOAuthBrowserFlowReleased,
    AdmitOAuthDeviceFlowValid,
    AdmitOAuthDeviceFlowExpiring,
    AdmitOAuthDeviceFlowExpired,
    AdmitOAuthDeviceFlowRefreshing,
    AdmitOAuthDeviceFlowReauthRequired,
    ReopenReleasedForOAuthDeviceFlowAdmission,
    ConfirmOAuthDurableAdmissionValid,
    ConfirmOAuthDurableAdmissionExpiring,
    ConfirmOAuthDurableAdmissionExpired,
    ConfirmOAuthDurableAdmissionRefreshing,
    ConfirmOAuthDurableAdmissionReauthRequired,
    ConfirmOAuthDurableAdmissionReleased,
    VerifyOAuthDeviceFlowValid,
    VerifyOAuthDeviceFlowExpiring,
    VerifyOAuthDeviceFlowExpired,
    VerifyOAuthDeviceFlowRefreshing,
    VerifyOAuthDeviceFlowReauthRequired,
    BeginOAuthDevicePollValid,
    BeginOAuthDevicePollExpiring,
    BeginOAuthDevicePollExpired,
    BeginOAuthDevicePollRefreshing,
    BeginOAuthDevicePollReauthRequired,
    FinishOAuthDevicePollValid,
    FinishOAuthDevicePollExpiring,
    FinishOAuthDevicePollExpired,
    FinishOAuthDevicePollRefreshing,
    FinishOAuthDevicePollReauthRequired,
    FinishOAuthDevicePollAbsentValid,
    FinishOAuthDevicePollAbsentExpiring,
    FinishOAuthDevicePollAbsentExpired,
    FinishOAuthDevicePollAbsentRefreshing,
    FinishOAuthDevicePollAbsentReauthRequired,
    FinishOAuthDevicePollReleased,
    ConsumeOAuthDeviceFlowValid,
    ConsumeOAuthDeviceFlowExpiring,
    ConsumeOAuthDeviceFlowExpired,
    ConsumeOAuthDeviceFlowRefreshing,
    ConsumeOAuthDeviceFlowReauthRequired,
    ExpireOAuthDeviceFlowValid,
    ExpireOAuthDeviceFlowExpiring,
    ExpireOAuthDeviceFlowExpired,
    ExpireOAuthDeviceFlowRefreshing,
    ExpireOAuthDeviceFlowReauthRequired,
    ExpireOAuthDeviceFlowAbsentValid,
    ExpireOAuthDeviceFlowAbsentExpiring,
    ExpireOAuthDeviceFlowAbsentExpired,
    ExpireOAuthDeviceFlowAbsentRefreshing,
    ExpireOAuthDeviceFlowAbsentReauthRequired,
    ExpireOAuthDeviceFlowReleased,
    ResolveCredentialUseAdmissionValidUseAuthorizedValid,
    ResolveCredentialUseAdmissionValidHoldAuthorizedValid,
    ResolveCredentialUseAdmissionValidBeginRefreshValid,
    ResolveCredentialUseAdmissionValidNoCredentialValid,
    ResolveCredentialUseAdmissionExpiringUseRefreshExpiring,
    ResolveCredentialUseAdmissionExpiringHoldAuthorizedExpiring,
    ResolveCredentialUseAdmissionExpiringBeginRefreshExpiring,
    ResolveCredentialUseAdmissionExpiringNoCredentialExpiring,
    ResolveCredentialUseAdmissionExpiredUseRefreshExpired,
    ResolveCredentialUseAdmissionExpiredHoldRefreshExpired,
    ResolveCredentialUseAdmissionExpiredBeginRefreshExpired,
    ResolveCredentialUseAdmissionExpiredNoCredentialExpired,
    ResolveCredentialUseAdmissionRefreshingUseRefreshRefreshing,
    ResolveCredentialUseAdmissionRefreshingHoldAuthorizedRefreshing,
    ResolveCredentialUseAdmissionRefreshingBeginAlreadyRefreshingRefreshing,
    ResolveCredentialUseAdmissionRefreshingNoCredentialUseOrHoldRefreshing,
    ResolveCredentialUseAdmissionReauthRequiredReauthRequired,
    ResolveCredentialUseAdmissionReleasedReleased,
    ResolveOAuthLoginCredentialDispositionUseCachedValid,
    ResolveOAuthLoginCredentialDispositionRefreshValidValid,
    ResolveOAuthLoginCredentialDispositionRefreshDisallowedValidValid,
    ResolveOAuthLoginCredentialDispositionRefreshNonValidExpiring,
    ResolveOAuthLoginCredentialDispositionRefreshNonValidExpired,
    ResolveOAuthLoginCredentialDispositionRefreshNonValidRefreshing,
    ResolveOAuthLoginCredentialDispositionRefreshNonValidReauthRequired,
    ResolveOAuthLoginCredentialDispositionRefreshNonValidReleased,
    ResolveOAuthLoginCredentialDispositionRefreshDisallowedNonValidExpiring,
    ResolveOAuthLoginCredentialDispositionRefreshDisallowedNonValidExpired,
    ResolveOAuthLoginCredentialDispositionRefreshDisallowedNonValidRefreshing,
    ResolveOAuthLoginCredentialDispositionRefreshDisallowedNonValidReauthRequired,
    ResolveOAuthLoginCredentialDispositionRefreshDisallowedNonValidReleased,
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum GuardId {
    None,
}
#[allow(non_camel_case_types)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum HelperId {
    None,
}

#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct GuardRejection {
    pub transition_id: TransitionId,
    pub guard_id: GuardId,
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum TriggerDiscriminant {
    Input(InputKind),
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum TransitionRefusal {
    NoMatchingTransition {
        phase: Phase,
        trigger: TriggerDiscriminant,
    },
    GuardRejected {
        rejections: Vec<GuardRejection>,
    },
    AmbiguousTransition {
        transitions: Vec<TransitionId>,
    },
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum KernelError {
    ContextViolation {
        transition_id: TransitionId,
        detail: String,
    },
    HelperEvaluation {
        helper_id: HelperId,
        detail: String,
    },
    CodegenInvariant {
        detail: String,
    },
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum TransitionError {
    Refusal(TransitionRefusal),
    Kernel(KernelError),
}
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct Outcome {
    pub transition_id: TransitionId,
    pub next_state: State,
    pub effects: Vec<Effect>,
}

pub mod helpers {
    #[allow(unused_imports)]
    use super::*;
    pub fn none<C: Context>(_: &State, context: &C) -> Result<(), KernelError> {
        let _ = context;
        Ok(())
    }
}

pub fn initial_state() -> State {
    State {
        phase: Phase::Valid,
        expires_at: None,
        last_refresh: None,
        refresh_attempt: 0,
        credential_present: false,
        credential_generation: 0,
        credential_published_at_millis: None,
        oauth_browser_flow_ids: Default::default(),
        oauth_browser_flow_providers: Default::default(),
        oauth_browser_flow_redirect_uris: Default::default(),
        oauth_browser_flow_expires_at_millis: Default::default(),
        oauth_device_flow_ids: Default::default(),
        oauth_device_flow_providers: Default::default(),
        oauth_device_flow_expires_at_millis: Default::default(),
        oauth_device_poll_ids: Default::default(),
        oauth_outstanding_flow_count: 0,
        release_draining: false,
    }
}
