'use client'
import { __awaiter } from '../../../../../_virtual/_tslib.js';
import '@dynamic-labs-sdk/client';
import '@dynamic-labs/utils';
import '@dynamic-labs/sdk-api-core';
import '@dynamic-labs-sdk/client/core';
import 'react';
import 'eventemitter3';
import '../../../config/ApiEndpoint.js';
import '@dynamic-labs/iconic';
import '@dynamic-labs/wallet-connector-core';
import 'react/jsx-runtime';
import '../../ViewContext/ViewContext.js';
import '../../../shared/logger.js';
import '@dynamic-labs/wallet-book';
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-wallet/browser-wallet-client';
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
import '../../../store/state/primaryWalletId/primaryWalletId.js';
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
import '../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
import '../../../events/dynamicEvents.js';
import { createSmsVerification } from '../../../data/api/sms/sms.js';
import { buildSmsOtpHandler } from './buildSmsOtpHandler/buildSmsOtpHandler.js';
import { persistOtpVerificationState } from './otpVerificationStorage/otpVerificationStorage.js';

const createSmsHandler = (environmentId, embeddedWalletSessionKeys) => (phone, captchaToken) => __awaiter(void 0, void 0, void 0, function* () {
    const { verificationUUID } = yield createSmsVerification({
        captchaToken,
        environmentId,
        isoCountryCode: phone.iso2,
        phoneCountryCode: phone.dialCode,
        phoneNumber: phone.phone,
    });
    persistOtpVerificationState({
        captchaToken,
        destination: phone,
        type: 'sms',
        verificationUUID,
    });
    return buildSmsOtpHandler({
        captchaToken,
        embeddedWalletSessionKeys,
        environmentId,
        phone,
        verificationUUID,
    });
});

export { createSmsHandler };
