import { HeadlessB2BOAuthClient as HeadlessB2BOAuthClient$1 } from '../../../core/src/HeadlessClients/b2b/HeadlessB2BOAuthClient.mjs';
import '../../../core/src/HeadlessClients/b2b/HeadlessB2BMagicLinkClient.mjs';
import '../../../core/src/HeadlessClients/b2b/HeadlessB2BPasswordsClient.mjs';
import '../../../core/src/HeadlessClients/HeadlessCryptoWalletClient.mjs';
import '../../../core/src/HeadlessClients/HeadlessMagicLinkClient.mjs';
import '../../../core/src/HeadlessClients/HeadlessPasswordClient.mjs';
import { DisabledDFPProtectedAuthProvider } from '../../../core/src/DFPProtectedAuthProvider.mjs';
import { OneTapPositions } from '../../../core/src/public/ui.mjs';
import { StytchSDKUsageError } from '../../../core/src/public/SDKErrors.mjs';

class HeadlessB2BOAuthClient extends HeadlessB2BOAuthClient$1 {
    _oneTap;
    constructor(_networkClient, _subscriptionService, _pkceManager, _dynamicConfig, _config, _dfpProtectedAuth = DisabledDFPProtectedAuthProvider(), _oneTap){
        super(_networkClient, _subscriptionService, _pkceManager, _dynamicConfig, _config, _dfpProtectedAuth), this._oneTap = _oneTap;
    }
    startOneTapDiscovery = async (options)=>{
        const clientResult = await this._oneTap.createOneTapClient();
        if (!clientResult.success) {
            throw new Error(`One Tap could not load: ${clientResult.reason}`);
        }
        const { client } = clientResult;
        const onSuccessCallback = this._oneTap.createOnDiscoverySuccessHandler({
            discoveryRedirectUrl: options.discovery_redirect_url,
            onSuccess: this._oneTap.redirectOnSuccess
        });
        return client.render({
            style: {
                position: OneTapPositions.floating
            },
            callback: onSuccessCallback,
            cancelOnTapOutside: options.cancel_on_tap_outside
        });
    };
    startOneTap = async (options)=>{
        if (!options.organization_id) {
            throw new StytchSDKUsageError('stytch.oauth.googleOneTap.start', 'organization_id is a required argument');
        }
        const clientResult = await this._oneTap.createOneTapClient();
        if (!clientResult.success) {
            throw new Error(`One Tap could not load: ${clientResult.reason}`);
        }
        const { client } = clientResult;
        const onSuccessCallback = this._oneTap.createOnSuccessHandler({
            organizationId: options.organization_id,
            signupRedirectUrl: options.signup_redirect_url,
            loginRedirectUrl: options.login_redirect_url,
            onSuccess: this._oneTap.redirectOnSuccess
        });
        return client.render({
            style: {
                position: OneTapPositions.floating
            },
            callback: onSuccessCallback,
            cancelOnTapOutside: options.cancel_on_tap_outside
        });
    };
    googleOneTap = {
        discovery: {
            start: this.startOneTapDiscovery
        },
        start: this.startOneTap
    };
}

export { HeadlessB2BOAuthClient };
//# sourceMappingURL=HeadlessB2BOAuthClient.mjs.map
