'use client'
import { __awaiter } from '../../../../../_virtual/_tslib.js';
import { useCallback } from 'react';
import { MFADeviceType, MfaBackupCodeAcknowledgement } from '@dynamic-labs/sdk-api-core';
import '@dynamic-labs-sdk/client/core';
import '../../../client/client.js';
import '@dynamic-labs-sdk/client';
import '../../../config/ApiEndpoint.js';
import '@dynamic-labs/iconic';
import '@dynamic-labs/wallet-connector-core';
import 'react/jsx-runtime';
import '../../../context/ViewContext/ViewContext.js';
import '../../../shared/logger.js';
import '@dynamic-labs/wallet-book';
import '@dynamic-labs/utils';
import '../../../utils/constants/colors.js';
import '../../../utils/constants/values.js';
import '../../../shared/consts/index.js';
import '@dynamic-labs/multi-wallet';
import 'react-international-phone';
import '../../../store/state/nonce/nonce.js';
import '@dynamic-labs/locale';
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
import '../../../store/state/primaryWalletId/primaryWalletId.js';
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
import '../../../events/dynamicEvents.js';
import { getUserProfile } from '../../../client/extension/user/getUserProfile/getUserProfile.js';
import { isMfaMethodEnabled } from '../../../utils/functions/isMfaMethodEnabled/isMfaMethodEnabled.js';
import { useGetUserMfaMethods } from '../../../utils/hooks/useGetUserMfaMethods/useGetUserMfaMethods.js';

const PASSKEY_OPTION = {
    Icon: undefined,
    descriptionKey: 'dyn_mfa.choose_device_view.passkey_description',
    labelKey: 'dyn_mfa.choose_device_view.passkey',
    type: MFADeviceType.Passkey,
};
const TOTP_OPTION = {
    Icon: undefined,
    descriptionKey: 'dyn_mfa.choose_device_view.authenticator_app_description',
    labelKey: 'dyn_mfa.choose_device_view.authenticator_app',
    type: MFADeviceType.Totp,
};
const BACKUP_CODE_OPTION = {
    Icon: undefined,
    descriptionKey: 'dyn_mfa.choose_device_view.backup_code_description',
    labelKey: 'dyn_mfa.choose_device_view.backup_code',
    type: 'backupCode',
};
const useGetMfaOptions = (isInitialSetup) => {
    const getUserMfaMethods = useGetUserMfaMethods();
    return useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
        const registeredMfaMethods = yield getUserMfaMethods();
        const showTotpOption = isInitialSetup
            ? isMfaMethodEnabled(MFADeviceType.Totp)
            : registeredMfaMethods.devices.length > 0;
        const showPasskeyOption = isInitialSetup
            ? isMfaMethodEnabled(MFADeviceType.Passkey)
            : registeredMfaMethods.passkeys.length > 0;
        if (!showTotpOption && !showPasskeyOption) {
            return [];
        }
        const mfaOptions = [];
        if (showPasskeyOption) {
            mfaOptions.push(PASSKEY_OPTION);
        }
        if (showTotpOption) {
            mfaOptions.push(TOTP_OPTION);
        }
        const user = getUserProfile();
        const shouldShowBackupCodeOption = !isInitialSetup &&
            (user === null || user === void 0 ? void 0 : user.mfaBackupCodeAcknowledgement) ===
                MfaBackupCodeAcknowledgement.Complete;
        if (shouldShowBackupCodeOption) {
            mfaOptions.push(BACKUP_CODE_OPTION);
        }
        return mfaOptions;
    }), [getUserMfaMethods, isInitialSetup]);
};

export { BACKUP_CODE_OPTION, PASSKEY_OPTION, TOTP_OPTION, useGetMfaOptions };
