/* 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 { FlowSet } from "./FlowSet";
import { FlowSetFromJSON } from "./FlowSet";
import type { UserFieldsEnum } from "./UserFieldsEnum";
import { UserFieldsEnumFromJSON, UserFieldsEnumToJSON } from "./UserFieldsEnum";

/**
 * IdentificationStage Serializer
 * @export
 * @interface IdentificationStage
 */
export interface IdentificationStage {
    /**
     *
     * @type {string}
     * @memberof IdentificationStage
     */
    readonly pk: string;
    /**
     *
     * @type {string}
     * @memberof IdentificationStage
     */
    name: string;
    /**
     * Get object type so that we know how to edit the object
     * @type {string}
     * @memberof IdentificationStage
     */
    readonly component: string;
    /**
     * Return object's verbose_name
     * @type {string}
     * @memberof IdentificationStage
     */
    readonly verboseName: string;
    /**
     * Return object's plural verbose_name
     * @type {string}
     * @memberof IdentificationStage
     */
    readonly verboseNamePlural: string;
    /**
     * Return internal model name
     * @type {string}
     * @memberof IdentificationStage
     */
    readonly metaModelName: string;
    /**
     *
     * @type {Array<FlowSet>}
     * @memberof IdentificationStage
     */
    readonly flowSet: Array<FlowSet>;
    /**
     * Fields of the user object to match against. (Hold shift to select multiple options)
     * @type {Array<UserFieldsEnum>}
     * @memberof IdentificationStage
     */
    userFields?: Array<UserFieldsEnum>;
    /**
     * When set, shows a password field, instead of showing the password field as separate step.
     * @type {string}
     * @memberof IdentificationStage
     */
    passwordStage?: string | null;
    /**
     * When set, adds functionality exactly like a Captcha stage, but baked into the Identification stage.
     * @type {string}
     * @memberof IdentificationStage
     */
    captchaStage?: string | null;
    /**
     * When enabled, user fields are matched regardless of their casing.
     * @type {boolean}
     * @memberof IdentificationStage
     */
    caseInsensitiveMatching?: boolean;
    /**
     * When a valid username/email has been entered, and this option is enabled, the user's username and avatar will be shown. Otherwise, the text that the user entered will be shown
     * @type {boolean}
     * @memberof IdentificationStage
     */
    showMatchedUser?: boolean;
    /**
     * Optional enrollment flow, which is linked at the bottom of the page.
     * @type {string}
     * @memberof IdentificationStage
     */
    enrollmentFlow?: string | null;
    /**
     * Optional recovery flow, which is linked at the bottom of the page.
     * @type {string}
     * @memberof IdentificationStage
     */
    recoveryFlow?: string | null;
    /**
     * Optional passwordless flow, which is linked at the bottom of the page.
     * @type {string}
     * @memberof IdentificationStage
     */
    passwordlessFlow?: string | null;
    /**
     * Specify which sources should be shown.
     * @type {Array<string>}
     * @memberof IdentificationStage
     */
    sources?: Array<string>;
    /**
     *
     * @type {boolean}
     * @memberof IdentificationStage
     */
    showSourceLabels?: boolean;
    /**
     * When enabled, the stage will succeed and continue even when incorrect user info is entered.
     * @type {boolean}
     * @memberof IdentificationStage
     */
    pretendUserExists?: boolean;
    /**
     * Show the user the 'Remember me on this device' toggle, allowing repeat users to skip straight to entering their password.
     * @type {boolean}
     * @memberof IdentificationStage
     */
    enableRememberMe?: boolean;
    /**
     * When set, and conditional WebAuthn is available, allow the user to use their passkey as a first factor.
     * @type {string}
     * @memberof IdentificationStage
     */
    webauthnStage?: string | null;
}

/**
 * Check if a given object implements the IdentificationStage interface.
 */
export function instanceOfIdentificationStage(value: object): value is IdentificationStage {
    if (!("pk" in value) || value["pk"] === undefined) return false;
    if (!("name" in value) || value["name"] === undefined) return false;
    if (!("component" in value) || value["component"] === undefined) return false;
    if (!("verboseName" in value) || value["verboseName"] === undefined) return false;
    if (!("verboseNamePlural" in value) || value["verboseNamePlural"] === undefined) return false;
    if (!("metaModelName" in value) || value["metaModelName"] === undefined) return false;
    if (!("flowSet" in value) || value["flowSet"] === undefined) return false;
    return true;
}

export function IdentificationStageFromJSON(json: any): IdentificationStage {
    return IdentificationStageFromJSONTyped(json, false);
}

export function IdentificationStageFromJSONTyped(
    json: any,
    ignoreDiscriminator: boolean,
): IdentificationStage {
    if (json == null) {
        return json;
    }
    return {
        pk: json["pk"],
        name: json["name"],
        component: json["component"],
        verboseName: json["verbose_name"],
        verboseNamePlural: json["verbose_name_plural"],
        metaModelName: json["meta_model_name"],
        flowSet: (json["flow_set"] as Array<any>).map(FlowSetFromJSON),
        userFields:
            json["user_fields"] == null
                ? undefined
                : (json["user_fields"] as Array<any>).map(UserFieldsEnumFromJSON),
        passwordStage: json["password_stage"] == null ? undefined : json["password_stage"],
        captchaStage: json["captcha_stage"] == null ? undefined : json["captcha_stage"],
        caseInsensitiveMatching:
            json["case_insensitive_matching"] == null
                ? undefined
                : json["case_insensitive_matching"],
        showMatchedUser: json["show_matched_user"] == null ? undefined : json["show_matched_user"],
        enrollmentFlow: json["enrollment_flow"] == null ? undefined : json["enrollment_flow"],
        recoveryFlow: json["recovery_flow"] == null ? undefined : json["recovery_flow"],
        passwordlessFlow: json["passwordless_flow"] == null ? undefined : json["passwordless_flow"],
        sources: json["sources"] == null ? undefined : json["sources"],
        showSourceLabels:
            json["show_source_labels"] == null ? undefined : json["show_source_labels"],
        pretendUserExists:
            json["pretend_user_exists"] == null ? undefined : json["pretend_user_exists"],
        enableRememberMe:
            json["enable_remember_me"] == null ? undefined : json["enable_remember_me"],
        webauthnStage: json["webauthn_stage"] == null ? undefined : json["webauthn_stage"],
    };
}

export function IdentificationStageToJSON(json: any): IdentificationStage {
    return IdentificationStageToJSONTyped(json, false);
}

export function IdentificationStageToJSONTyped(
    value?: Omit<
        IdentificationStage,
        "pk" | "component" | "verbose_name" | "verbose_name_plural" | "meta_model_name" | "flow_set"
    > | null,
    ignoreDiscriminator: boolean = false,
): any {
    if (value == null) {
        return value;
    }

    return {
        name: value["name"],
        user_fields:
            value["userFields"] == null
                ? undefined
                : (value["userFields"] as Array<any>).map(UserFieldsEnumToJSON),
        password_stage: value["passwordStage"],
        captcha_stage: value["captchaStage"],
        case_insensitive_matching: value["caseInsensitiveMatching"],
        show_matched_user: value["showMatchedUser"],
        enrollment_flow: value["enrollmentFlow"],
        recovery_flow: value["recoveryFlow"],
        passwordless_flow: value["passwordlessFlow"],
        sources: value["sources"],
        show_source_labels: value["showSourceLabels"],
        pretend_user_exists: value["pretendUserExists"],
        enable_remember_me: value["enableRememberMe"],
        webauthn_stage: value["webauthnStage"],
    };
}
