'use client'
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var React = require('react');
require('@dynamic-labs-sdk/client/core');
require('@dynamic-labs/sdk-api-core');
require('../../../client/client.cjs');
require('@dynamic-labs-sdk/client');
require('../../../config/ApiEndpoint.cjs');
require('@dynamic-labs/iconic');
require('@dynamic-labs/wallet-connector-core');
require('react/jsx-runtime');
require('../../../context/ViewContext/ViewContext.cjs');
require('../../../shared/logger.cjs');
require('@dynamic-labs/wallet-book');
require('@dynamic-labs/utils');
require('../../constants/colors.cjs');
require('../../constants/values.cjs');
require('../../../shared/consts/index.cjs');
require('../../../../../_virtual/_tslib.cjs');
require('@dynamic-labs/multi-wallet');
require('react-international-phone');
require('../../../store/state/nonce/nonce.cjs');
var isTurnkeyEnabled = require('../../functions/isTurnkeyEnabled/isTurnkeyEnabled.cjs');
require('@dynamic-labs/locale');
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
var usingV3Wallets = require('../../functions/usingV3Wallets/usingV3Wallets.cjs');
require('../../../events/dynamicEvents.cjs');
var useOnboardingCompleteUser = require('../../../client/extension/user/useOnboardingCompleteUser/useOnboardingCompleteUser.cjs');
var getProjectSettings = require('../../../client/extension/projectSettings/getProjectSettings/getProjectSettings.cjs');
var authMode = require('../../../store/state/authMode/authMode.cjs');

const useIsLoadingEmbeddedWallet = () => {
    const user = useOnboardingCompleteUser.useOnboardingCompleteUserProfile();
    const authMode$1 = authMode.useAuthMode();
    const projectSettings = getProjectSettings.getProjectSettings();
    // we only want to show the loading state if the user has no wallets at all, and is creating a waas wallet
    // for example if they sign up with phantom wallet, we don't want to show the loading state
    // always return false for connect-only mode, because verified credentials are not used in this mode
    // except when user is logging in with email and will get an embedded wallet
    const isLoadingEmbeddedWallet = React.useMemo(() => {
        var _a, _b;
        if (!usingV3Wallets.usingV3Wallets(projectSettings) ||
            !isTurnkeyEnabled.isTurnkeyEnabled(projectSettings)) {
            return false;
        }
        const isEmailLogin = (_a = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _a === void 0 ? void 0 : _a.some((credential) => credential.format === 'email');
        const hasWallet = (_b = user === null || user === void 0 ? void 0 : user.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.some((credential) => credential.format === 'blockchain');
        if (authMode$1 === 'connect-only') {
            if (isEmailLogin) {
                if (hasWallet) {
                    return false;
                }
                return true;
            }
            // login with injected wallet will already have a primary wallet set so we dont need to show loading state
            return false;
        }
        // If user has NO blockchain credential, then we show loading state
        return !hasWallet;
    }, [projectSettings, user, authMode$1]);
    return { isLoadingEmbeddedWallet };
};

exports.useIsLoadingEmbeddedWallet = useIsLoadingEmbeddedWallet;
