import { validateInDev } from '../../utils/dev.mjs';

class HeadlessB2BDiscoveryClient {
    _networkClient;
    _subscriptionService;
    organizations;
    intermediateSessions;
    constructor(_networkClient, _subscriptionService){
        this._networkClient = _networkClient;
        this._subscriptionService = _subscriptionService;
        this.organizations = {
            list: async ()=>this._networkClient.fetchSDK({
                    url: '/b2b/discovery/organizations',
                    body: {
                        intermediate_session_token: await this._subscriptionService.getIntermediateSessionToken() || undefined
                    },
                    method: 'POST'
                }),
            create: this._subscriptionService.withUpdateSession(async (data)=>{
                validateInDev('stytch.discovery.organizations.create', data, {
                    session_duration_minutes: 'number',
                    organization_name: 'optionalString',
                    organization_slug: 'optionalString',
                    organization_logo_url: 'optionalString',
                    sso_jit_provisioning: 'optionalString',
                    email_allowed_domains: 'optionalStringArray',
                    email_invites: 'optionalString',
                    auth_methods: 'optionalString',
                    allowed_auth_methods: 'optionalStringArray',
                    mfa_policy: 'optionalString'
                });
                const requestBody = {
                    ...data,
                    intermediate_session_token: await this._subscriptionService.getIntermediateSessionToken() || undefined
                };
                return this._networkClient.fetchSDK({
                    url: '/b2b/discovery/organizations/create',
                    body: requestBody,
                    method: 'POST'
                });
            })
        };
        this.intermediateSessions = {
            exchange: this._subscriptionService.withUpdateSession(async (data)=>{
                validateInDev('stytch.discovery.intermediateSessions.exchange', data, {
                    organization_id: 'string',
                    session_duration_minutes: 'number',
                    locale: 'optionalString'
                });
                const requestBody = {
                    ...data,
                    intermediate_session_token: this._subscriptionService.getIntermediateSessionToken() || undefined
                };
                return this._networkClient.fetchSDK({
                    url: '/b2b/discovery/intermediate_sessions/exchange',
                    body: requestBody,
                    method: 'POST'
                });
            })
        };
    }
}

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