'use client'
import { __awaiter } from '../../../../../_virtual/_tslib.js';
import { useCallback } from 'react';
import { signInWithPasskey } from '@dynamic-labs-sdk/client';
import '../../../context/DynamicContext/useDynamicContext/useDynamicContext.js';
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
import '@dynamic-labs-sdk/client/core';
import '@dynamic-labs/sdk-api-core';
import 'eventemitter3';
import '@dynamic-labs/utils';
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 '../../constants/colors.js';
import '../../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-wallet/browser-wallet-client';
import '@dynamic-labs/locale';
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
import '../../../store/state/primaryWalletId/primaryWalletId.js';
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
import '../../../events/dynamicEvents.js';
import { generateSessionKeys } from '../../../client/extension/functions/generateSessionKeys/generateSessionKeys.js';

/**
 * Sign in with passkey
 *
 * @returns Function to sign in with a passkey, returns a VerifyResponse
 *
 * @example
 * ```tsx
 * const App = () => {
 *   const signInWithPasskey = useSignInWithPasskey();
 *
 *   return (
 *     <button
 *       onClick={() => signInWithPasskey()}
 *     >
 *       Sign in with passkey
 *     </button>
 *  );
 * }
 */
const useSignInWithPasskey = ({ relatedOriginRpId, } = {}) => {
    const { setCallback } = useInternalDynamicContext();
    return useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
        yield generateSessionKeys();
        const response = yield signInWithPasskey({ relatedOriginRpId });
        setCallback('authSuccess');
        return response;
    }), [relatedOriginRpId, setCallback]);
};

export { useSignInWithPasskey };
