'use client'
'use strict';

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

var _tslib = require('../../../../../../_virtual/_tslib.cjs');
require('@dynamic-labs-sdk/client/core');
require('@dynamic-labs/sdk-api-core');
require('../../../../client/client.cjs');
require('react');
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('@dynamic-labs/multi-wallet');
require('react-international-phone');
require('../../../../store/state/nonce/nonce.cjs');
require('@dynamic-labs/locale');
require('../../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
var primaryWalletId = require('../../../../store/state/primaryWalletId/primaryWalletId.cjs');
var connectedWalletsInfo = require('../../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
require('../../../../events/dynamicEvents.cjs');
var getUserProfile = require('../../../../client/extension/user/getUserProfile/getUserProfile.cjs');

/**
 * Detects mismatch between wallet info.
 * If there is primary wallet id, but no user or connected wallets info,
 * it means it's in a bad state and we should log out.
 */
const handleWalletInfoOutOfSync = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ logout, }) {
    const primaryWalletId$1 = primaryWalletId.getPrimaryWalletId();
    if (!primaryWalletId$1) {
        return;
    }
    const user = getUserProfile.getUserProfile();
    const connectedWallets = connectedWalletsInfo.getConnectedWalletsInfo();
    if (user || connectedWallets.length > 0) {
        return;
    }
    yield logout('wallet info is out of sync', {
        connectedWallets,
        primaryWalletId: primaryWalletId$1,
        user,
    });
});

exports.handleWalletInfoOutOfSync = handleWalletInfoOutOfSync;
