/* tslint:disable */
/* eslint-disable */
/**
 * authentik
 * Making authentication simple.
 *
 * The version of the OpenAPI document: 2026.5.0-rc1
 * Contact: hello@goauthentik.io
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import type { AppleChallengeResponseRequest } from "./AppleChallengeResponseRequest";
import {
    AppleChallengeResponseRequestFromJSONTyped,
    AppleChallengeResponseRequestToJSON,
} from "./AppleChallengeResponseRequest";
import type { AuthenticatorDuoChallengeResponseRequest } from "./AuthenticatorDuoChallengeResponseRequest";
import {
    AuthenticatorDuoChallengeResponseRequestFromJSONTyped,
    AuthenticatorDuoChallengeResponseRequestToJSON,
} from "./AuthenticatorDuoChallengeResponseRequest";
import type { AuthenticatorEmailChallengeResponseRequest } from "./AuthenticatorEmailChallengeResponseRequest";
import {
    AuthenticatorEmailChallengeResponseRequestFromJSONTyped,
    AuthenticatorEmailChallengeResponseRequestToJSON,
} from "./AuthenticatorEmailChallengeResponseRequest";
import type { AuthenticatorSMSChallengeResponseRequest } from "./AuthenticatorSMSChallengeResponseRequest";
import {
    AuthenticatorSMSChallengeResponseRequestFromJSONTyped,
    AuthenticatorSMSChallengeResponseRequestToJSON,
} from "./AuthenticatorSMSChallengeResponseRequest";
import type { AuthenticatorStaticChallengeResponseRequest } from "./AuthenticatorStaticChallengeResponseRequest";
import {
    AuthenticatorStaticChallengeResponseRequestFromJSONTyped,
    AuthenticatorStaticChallengeResponseRequestToJSON,
} from "./AuthenticatorStaticChallengeResponseRequest";
import type { AuthenticatorTOTPChallengeResponseRequest } from "./AuthenticatorTOTPChallengeResponseRequest";
import {
    AuthenticatorTOTPChallengeResponseRequestFromJSONTyped,
    AuthenticatorTOTPChallengeResponseRequestToJSON,
} from "./AuthenticatorTOTPChallengeResponseRequest";
import type { AuthenticatorValidationChallengeResponseRequest } from "./AuthenticatorValidationChallengeResponseRequest";
import {
    AuthenticatorValidationChallengeResponseRequestFromJSONTyped,
    AuthenticatorValidationChallengeResponseRequestToJSON,
} from "./AuthenticatorValidationChallengeResponseRequest";
import type { AuthenticatorWebAuthnChallengeResponseRequest } from "./AuthenticatorWebAuthnChallengeResponseRequest";
import {
    AuthenticatorWebAuthnChallengeResponseRequestFromJSONTyped,
    AuthenticatorWebAuthnChallengeResponseRequestToJSON,
} from "./AuthenticatorWebAuthnChallengeResponseRequest";
import type { AutoSubmitChallengeResponseRequest } from "./AutoSubmitChallengeResponseRequest";
import {
    AutoSubmitChallengeResponseRequestFromJSONTyped,
    AutoSubmitChallengeResponseRequestToJSON,
} from "./AutoSubmitChallengeResponseRequest";
import type { CaptchaChallengeResponseRequest } from "./CaptchaChallengeResponseRequest";
import {
    CaptchaChallengeResponseRequestFromJSONTyped,
    CaptchaChallengeResponseRequestToJSON,
} from "./CaptchaChallengeResponseRequest";
import type { ConsentChallengeResponseRequest } from "./ConsentChallengeResponseRequest";
import {
    ConsentChallengeResponseRequestFromJSONTyped,
    ConsentChallengeResponseRequestToJSON,
} from "./ConsentChallengeResponseRequest";
import type { DummyChallengeResponseRequest } from "./DummyChallengeResponseRequest";
import {
    DummyChallengeResponseRequestFromJSONTyped,
    DummyChallengeResponseRequestToJSON,
} from "./DummyChallengeResponseRequest";
import type { EmailChallengeResponseRequest } from "./EmailChallengeResponseRequest";
import {
    EmailChallengeResponseRequestFromJSONTyped,
    EmailChallengeResponseRequestToJSON,
} from "./EmailChallengeResponseRequest";
import type { EndpointAgentChallengeResponseRequest } from "./EndpointAgentChallengeResponseRequest";
import {
    EndpointAgentChallengeResponseRequestFromJSONTyped,
    EndpointAgentChallengeResponseRequestToJSON,
} from "./EndpointAgentChallengeResponseRequest";
import type { FrameChallengeResponseRequest } from "./FrameChallengeResponseRequest";
import {
    FrameChallengeResponseRequestFromJSONTyped,
    FrameChallengeResponseRequestToJSON,
} from "./FrameChallengeResponseRequest";
import type { IdentificationChallengeResponseRequest } from "./IdentificationChallengeResponseRequest";
import {
    IdentificationChallengeResponseRequestFromJSONTyped,
    IdentificationChallengeResponseRequestToJSON,
} from "./IdentificationChallengeResponseRequest";
import type { IframeLogoutChallengeResponseRequest } from "./IframeLogoutChallengeResponseRequest";
import {
    IframeLogoutChallengeResponseRequestFromJSONTyped,
    IframeLogoutChallengeResponseRequestToJSON,
} from "./IframeLogoutChallengeResponseRequest";
import type { NativeLogoutChallengeResponseRequest } from "./NativeLogoutChallengeResponseRequest";
import {
    NativeLogoutChallengeResponseRequestFromJSONTyped,
    NativeLogoutChallengeResponseRequestToJSON,
} from "./NativeLogoutChallengeResponseRequest";
import type { OAuthDeviceCodeChallengeResponseRequest } from "./OAuthDeviceCodeChallengeResponseRequest";
import {
    OAuthDeviceCodeChallengeResponseRequestFromJSONTyped,
    OAuthDeviceCodeChallengeResponseRequestToJSON,
} from "./OAuthDeviceCodeChallengeResponseRequest";
import type { OAuthDeviceCodeFinishChallengeResponseRequest } from "./OAuthDeviceCodeFinishChallengeResponseRequest";
import {
    OAuthDeviceCodeFinishChallengeResponseRequestFromJSONTyped,
    OAuthDeviceCodeFinishChallengeResponseRequestToJSON,
} from "./OAuthDeviceCodeFinishChallengeResponseRequest";
import type { PasswordChallengeResponseRequest } from "./PasswordChallengeResponseRequest";
import {
    PasswordChallengeResponseRequestFromJSONTyped,
    PasswordChallengeResponseRequestToJSON,
} from "./PasswordChallengeResponseRequest";
import type { PlexAuthenticationChallengeResponseRequest } from "./PlexAuthenticationChallengeResponseRequest";
import {
    PlexAuthenticationChallengeResponseRequestFromJSONTyped,
    PlexAuthenticationChallengeResponseRequestToJSON,
} from "./PlexAuthenticationChallengeResponseRequest";
import type { PromptChallengeResponseRequest } from "./PromptChallengeResponseRequest";
import {
    PromptChallengeResponseRequestFromJSONTyped,
    PromptChallengeResponseRequestToJSON,
} from "./PromptChallengeResponseRequest";
import type { RedirectChallengeResponseRequest } from "./RedirectChallengeResponseRequest";
import {
    RedirectChallengeResponseRequestFromJSONTyped,
    RedirectChallengeResponseRequestToJSON,
} from "./RedirectChallengeResponseRequest";
import type { TelegramChallengeResponseRequest } from "./TelegramChallengeResponseRequest";
import {
    TelegramChallengeResponseRequestFromJSONTyped,
    TelegramChallengeResponseRequestToJSON,
} from "./TelegramChallengeResponseRequest";
import type { UserLoginChallengeResponseRequest } from "./UserLoginChallengeResponseRequest";
import {
    UserLoginChallengeResponseRequestFromJSONTyped,
    UserLoginChallengeResponseRequestToJSON,
} from "./UserLoginChallengeResponseRequest";

/**
 * @type FlowChallengeResponseRequest
 *
 * @export
 */
export type FlowChallengeResponseRequest =
    | ({ component: "ak-provider-iframe-logout" } & IframeLogoutChallengeResponseRequest)
    | ({ component: "ak-provider-oauth2-device-code" } & OAuthDeviceCodeChallengeResponseRequest)
    | ({
          component: "ak-provider-oauth2-device-code-finish";
      } & OAuthDeviceCodeFinishChallengeResponseRequest)
    | ({ component: "ak-provider-saml-native-logout" } & NativeLogoutChallengeResponseRequest)
    | ({ component: "ak-source-oauth-apple" } & AppleChallengeResponseRequest)
    | ({ component: "ak-source-plex" } & PlexAuthenticationChallengeResponseRequest)
    | ({ component: "ak-source-telegram" } & TelegramChallengeResponseRequest)
    | ({ component: "ak-stage-authenticator-duo" } & AuthenticatorDuoChallengeResponseRequest)
    | ({ component: "ak-stage-authenticator-email" } & AuthenticatorEmailChallengeResponseRequest)
    | ({ component: "ak-stage-authenticator-sms" } & AuthenticatorSMSChallengeResponseRequest)
    | ({ component: "ak-stage-authenticator-static" } & AuthenticatorStaticChallengeResponseRequest)
    | ({ component: "ak-stage-authenticator-totp" } & AuthenticatorTOTPChallengeResponseRequest)
    | ({
          component: "ak-stage-authenticator-validate";
      } & AuthenticatorValidationChallengeResponseRequest)
    | ({
          component: "ak-stage-authenticator-webauthn";
      } & AuthenticatorWebAuthnChallengeResponseRequest)
    | ({ component: "ak-stage-autosubmit" } & AutoSubmitChallengeResponseRequest)
    | ({ component: "ak-stage-captcha" } & CaptchaChallengeResponseRequest)
    | ({ component: "ak-stage-consent" } & ConsentChallengeResponseRequest)
    | ({ component: "ak-stage-dummy" } & DummyChallengeResponseRequest)
    | ({ component: "ak-stage-email" } & EmailChallengeResponseRequest)
    | ({ component: "ak-stage-endpoint-agent" } & EndpointAgentChallengeResponseRequest)
    | ({ component: "ak-stage-identification" } & IdentificationChallengeResponseRequest)
    | ({ component: "ak-stage-password" } & PasswordChallengeResponseRequest)
    | ({ component: "ak-stage-prompt" } & PromptChallengeResponseRequest)
    | ({ component: "ak-stage-user-login" } & UserLoginChallengeResponseRequest)
    | ({ component: "xak-flow-frame" } & FrameChallengeResponseRequest)
    | ({ component: "xak-flow-redirect" } & RedirectChallengeResponseRequest);

export function FlowChallengeResponseRequestFromJSON(json: any): FlowChallengeResponseRequest {
    return FlowChallengeResponseRequestFromJSONTyped(json, false);
}

export function FlowChallengeResponseRequestFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): FlowChallengeResponseRequest {
    if (json == null) {
        return json;
    }
    switch (json["component"]) {
        case "ak-provider-iframe-logout":
            return Object.assign(
                {},
                IframeLogoutChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-provider-iframe-logout" } as const,
            );
        case "ak-provider-oauth2-device-code":
            return Object.assign(
                {},
                OAuthDeviceCodeChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-provider-oauth2-device-code" } as const,
            );
        case "ak-provider-oauth2-device-code-finish":
            return Object.assign(
                {},
                OAuthDeviceCodeFinishChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-provider-oauth2-device-code-finish" } as const,
            );
        case "ak-provider-saml-native-logout":
            return Object.assign(
                {},
                NativeLogoutChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-provider-saml-native-logout" } as const,
            );
        case "ak-source-oauth-apple":
            return Object.assign({}, AppleChallengeResponseRequestFromJSONTyped(json, true), {
                component: "ak-source-oauth-apple",
            } as const);
        case "ak-source-plex":
            return Object.assign(
                {},
                PlexAuthenticationChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-source-plex" } as const,
            );
        case "ak-source-telegram":
            return Object.assign({}, TelegramChallengeResponseRequestFromJSONTyped(json, true), {
                component: "ak-source-telegram",
            } as const);
        case "ak-stage-authenticator-duo":
            return Object.assign(
                {},
                AuthenticatorDuoChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-stage-authenticator-duo" } as const,
            );
        case "ak-stage-authenticator-email":
            return Object.assign(
                {},
                AuthenticatorEmailChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-stage-authenticator-email" } as const,
            );
        case "ak-stage-authenticator-sms":
            return Object.assign(
                {},
                AuthenticatorSMSChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-stage-authenticator-sms" } as const,
            );
        case "ak-stage-authenticator-static":
            return Object.assign(
                {},
                AuthenticatorStaticChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-stage-authenticator-static" } as const,
            );
        case "ak-stage-authenticator-totp":
            return Object.assign(
                {},
                AuthenticatorTOTPChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-stage-authenticator-totp" } as const,
            );
        case "ak-stage-authenticator-validate":
            return Object.assign(
                {},
                AuthenticatorValidationChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-stage-authenticator-validate" } as const,
            );
        case "ak-stage-authenticator-webauthn":
            return Object.assign(
                {},
                AuthenticatorWebAuthnChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-stage-authenticator-webauthn" } as const,
            );
        case "ak-stage-autosubmit":
            return Object.assign({}, AutoSubmitChallengeResponseRequestFromJSONTyped(json, true), {
                component: "ak-stage-autosubmit",
            } as const);
        case "ak-stage-captcha":
            return Object.assign({}, CaptchaChallengeResponseRequestFromJSONTyped(json, true), {
                component: "ak-stage-captcha",
            } as const);
        case "ak-stage-consent":
            return Object.assign({}, ConsentChallengeResponseRequestFromJSONTyped(json, true), {
                component: "ak-stage-consent",
            } as const);
        case "ak-stage-dummy":
            return Object.assign({}, DummyChallengeResponseRequestFromJSONTyped(json, true), {
                component: "ak-stage-dummy",
            } as const);
        case "ak-stage-email":
            return Object.assign({}, EmailChallengeResponseRequestFromJSONTyped(json, true), {
                component: "ak-stage-email",
            } as const);
        case "ak-stage-endpoint-agent":
            return Object.assign(
                {},
                EndpointAgentChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-stage-endpoint-agent" } as const,
            );
        case "ak-stage-identification":
            return Object.assign(
                {},
                IdentificationChallengeResponseRequestFromJSONTyped(json, true),
                { component: "ak-stage-identification" } as const,
            );
        case "ak-stage-password":
            return Object.assign({}, PasswordChallengeResponseRequestFromJSONTyped(json, true), {
                component: "ak-stage-password",
            } as const);
        case "ak-stage-prompt":
            return Object.assign({}, PromptChallengeResponseRequestFromJSONTyped(json, true), {
                component: "ak-stage-prompt",
            } as const);
        case "ak-stage-user-login":
            return Object.assign({}, UserLoginChallengeResponseRequestFromJSONTyped(json, true), {
                component: "ak-stage-user-login",
            } as const);
        case "xak-flow-frame":
            return Object.assign({}, FrameChallengeResponseRequestFromJSONTyped(json, true), {
                component: "xak-flow-frame",
            } as const);
        case "xak-flow-redirect":
            return Object.assign({}, RedirectChallengeResponseRequestFromJSONTyped(json, true), {
                component: "xak-flow-redirect",
            } as const);
        default:
            return json;
    }
}

export function FlowChallengeResponseRequestToJSON(json: any): any {
    return FlowChallengeResponseRequestToJSONTyped(json, false);
}

export function FlowChallengeResponseRequestToJSONTyped(
    value?: FlowChallengeResponseRequest | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }
    switch (value["component"]) {
        case "ak-provider-iframe-logout":
            return Object.assign({}, IframeLogoutChallengeResponseRequestToJSON(value), {
                component: "ak-provider-iframe-logout",
            } as const);
        case "ak-provider-oauth2-device-code":
            return Object.assign({}, OAuthDeviceCodeChallengeResponseRequestToJSON(value), {
                component: "ak-provider-oauth2-device-code",
            } as const);
        case "ak-provider-oauth2-device-code-finish":
            return Object.assign({}, OAuthDeviceCodeFinishChallengeResponseRequestToJSON(value), {
                component: "ak-provider-oauth2-device-code-finish",
            } as const);
        case "ak-provider-saml-native-logout":
            return Object.assign({}, NativeLogoutChallengeResponseRequestToJSON(value), {
                component: "ak-provider-saml-native-logout",
            } as const);
        case "ak-source-oauth-apple":
            return Object.assign({}, AppleChallengeResponseRequestToJSON(value), {
                component: "ak-source-oauth-apple",
            } as const);
        case "ak-source-plex":
            return Object.assign({}, PlexAuthenticationChallengeResponseRequestToJSON(value), {
                component: "ak-source-plex",
            } as const);
        case "ak-source-telegram":
            return Object.assign({}, TelegramChallengeResponseRequestToJSON(value), {
                component: "ak-source-telegram",
            } as const);
        case "ak-stage-authenticator-duo":
            return Object.assign({}, AuthenticatorDuoChallengeResponseRequestToJSON(value), {
                component: "ak-stage-authenticator-duo",
            } as const);
        case "ak-stage-authenticator-email":
            return Object.assign({}, AuthenticatorEmailChallengeResponseRequestToJSON(value), {
                component: "ak-stage-authenticator-email",
            } as const);
        case "ak-stage-authenticator-sms":
            return Object.assign({}, AuthenticatorSMSChallengeResponseRequestToJSON(value), {
                component: "ak-stage-authenticator-sms",
            } as const);
        case "ak-stage-authenticator-static":
            return Object.assign({}, AuthenticatorStaticChallengeResponseRequestToJSON(value), {
                component: "ak-stage-authenticator-static",
            } as const);
        case "ak-stage-authenticator-totp":
            return Object.assign({}, AuthenticatorTOTPChallengeResponseRequestToJSON(value), {
                component: "ak-stage-authenticator-totp",
            } as const);
        case "ak-stage-authenticator-validate":
            return Object.assign({}, AuthenticatorValidationChallengeResponseRequestToJSON(value), {
                component: "ak-stage-authenticator-validate",
            } as const);
        case "ak-stage-authenticator-webauthn":
            return Object.assign({}, AuthenticatorWebAuthnChallengeResponseRequestToJSON(value), {
                component: "ak-stage-authenticator-webauthn",
            } as const);
        case "ak-stage-autosubmit":
            return Object.assign({}, AutoSubmitChallengeResponseRequestToJSON(value), {
                component: "ak-stage-autosubmit",
            } as const);
        case "ak-stage-captcha":
            return Object.assign({}, CaptchaChallengeResponseRequestToJSON(value), {
                component: "ak-stage-captcha",
            } as const);
        case "ak-stage-consent":
            return Object.assign({}, ConsentChallengeResponseRequestToJSON(value), {
                component: "ak-stage-consent",
            } as const);
        case "ak-stage-dummy":
            return Object.assign({}, DummyChallengeResponseRequestToJSON(value), {
                component: "ak-stage-dummy",
            } as const);
        case "ak-stage-email":
            return Object.assign({}, EmailChallengeResponseRequestToJSON(value), {
                component: "ak-stage-email",
            } as const);
        case "ak-stage-endpoint-agent":
            return Object.assign({}, EndpointAgentChallengeResponseRequestToJSON(value), {
                component: "ak-stage-endpoint-agent",
            } as const);
        case "ak-stage-identification":
            return Object.assign({}, IdentificationChallengeResponseRequestToJSON(value), {
                component: "ak-stage-identification",
            } as const);
        case "ak-stage-password":
            return Object.assign({}, PasswordChallengeResponseRequestToJSON(value), {
                component: "ak-stage-password",
            } as const);
        case "ak-stage-prompt":
            return Object.assign({}, PromptChallengeResponseRequestToJSON(value), {
                component: "ak-stage-prompt",
            } as const);
        case "ak-stage-user-login":
            return Object.assign({}, UserLoginChallengeResponseRequestToJSON(value), {
                component: "ak-stage-user-login",
            } as const);
        case "xak-flow-frame":
            return Object.assign({}, FrameChallengeResponseRequestToJSON(value), {
                component: "xak-flow-frame",
            } as const);
        case "xak-flow-redirect":
            return Object.assign({}, RedirectChallengeResponseRequestToJSON(value), {
                component: "xak-flow-redirect",
            } as const);
        default:
            return value;
    }
}
