class HeadlessB2BSelfClient {
    _networkClient;
    _apiNetworkClient;
    _subscriptionService;
    constructor(_networkClient, _apiNetworkClient, _subscriptionService){
        this._networkClient = _networkClient;
        this._apiNetworkClient = _apiNetworkClient;
        this._subscriptionService = _subscriptionService;
    }
    get = async ()=>{
        const resp = await this._networkClient.fetchSDK({
            url: `/b2b/organizations/members/me`,
            method: 'GET'
        });
        this._subscriptionService.updateMember(resp.member);
        return resp.member;
    };
    getSync = ()=>{
        return this._subscriptionService.getMember();
    };
    getInfo = ()=>({
            member: this.getSync(),
            fromCache: this._subscriptionService.getFromCache()
        });
    onChange = (callback)=>{
        return this._subscriptionService.subscribeToState((state)=>callback(state?.member ?? null));
    };
    update = async (data)=>{
        const resp = await this._networkClient.fetchSDK({
            url: '/b2b/organizations/members/update',
            body: data,
            method: 'PUT'
        });
        this._subscriptionService.updateMember(resp.member);
        return resp;
    };
    deleteMFAPhoneNumber = async ()=>{
        const resp = await this._networkClient.fetchSDK({
            url: '/b2b/organizations/members/deletePhoneNumber',
            method: 'DELETE'
        });
        this._subscriptionService.updateMember(resp.member);
        return resp;
    };
    deleteMFATOTP = async ()=>{
        const resp = await this._networkClient.fetchSDK({
            url: `/b2b/organizations/members/deleteTOTP`,
            method: 'DELETE'
        });
        this._subscriptionService.updateMember(resp.member);
        return resp;
    };
    deletePassword = async (passwordId)=>{
        const resp = await this._networkClient.fetchSDK({
            url: `/b2b/organizations/members/passwords/${passwordId}`,
            method: 'DELETE'
        });
        this._subscriptionService.updateMember(resp.member);
        return resp;
    };
    unlinkRetiredEmail = async (data)=>{
        const resp = await this._apiNetworkClient.fetchSDK({
            url: '/b2b/organizations/members/unlink_retired_email',
            method: 'POST',
            body: data
        });
        this._subscriptionService.updateMember(resp.member);
        return resp;
    };
    startEmailUpdate = async (data)=>{
        const resp = await this._apiNetworkClient.fetchSDK({
            url: '/b2b/organizations/members/start_email_update',
            method: 'POST',
            body: data
        });
        this._subscriptionService.updateMember(resp.member);
        return resp;
    };
    getConnectedApps = async ()=>{
        return this._networkClient.fetchSDK({
            url: '/b2b/organizations/members/connected_apps',
            method: 'GET'
        });
    };
    revokeConnectedApp = async (data)=>{
        return this._networkClient.fetchSDK({
            url: `/b2b/organizations/members/connected_apps/${data.connected_app_id}/revoke`,
            method: 'POST'
        });
    };
}

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