'use client'
'use strict';

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

var _tslib = require('../../../../../_virtual/_tslib.cjs');
var React = require('react');
var client = require('@dynamic-labs-sdk/client');
require('@dynamic-labs-sdk/client/core');
require('@dynamic-labs/sdk-api-core');
require('eventemitter3');
require('@dynamic-labs/utils');
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('../../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-wallet/browser-wallet-client');
require('@dynamic-labs/locale');
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
require('../../../events/dynamicEvents.cjs');
var getUserProfile = require('../../../client/extension/user/getUserProfile/getUserProfile.cjs');
var reconcilePrimaryWallet = require('../../functions/reconcilePrimaryWallet/reconcilePrimaryWallet.cjs');

/**
 * Refresh auth state
 * @returns A callback function that can be used to refresh the auth state
 */
const useRefreshAuth = () => React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
    yield client.refreshAuth();
    const user = getUserProfile.getUserProfile();
    if (!(user === null || user === void 0 ? void 0 : user.verifiedCredentials)) {
        throw new Error('useRefreshAuth resulted in an invalid user: no verified credentials found');
    }
    reconcilePrimaryWallet.reconcilePrimaryWallet(user);
    return user;
}), []);

exports.useRefreshAuth = useRefreshAuth;
