import { UserService } from '../../../../core/backend-api/index.js';
import { tryExecute } from '../../../../core/resources/index.js';
/**
 * A data source for User MFA items that fetches data from the server
 * @class UmbMfaServerDataSource
 */
export class UmbUserMfaServerDataSource {
    #host;
    /**
     * Creates an instance of UmbMfaServerDataSource.
     * @param {UmbControllerHost} host - The controller host for this controller to be appended to
     * @memberof UmbMfaServerDataSource
     */
    constructor(host) {
        this.#host = host;
    }
    /**
     * Request the MFA providers for a user
     * @param unique The unique id of the user
     * @memberof UmbMfaServerDataSource
     */
    requestMfaProviders(unique) {
        if (!unique)
            throw new Error('User id is missing');
        return tryExecute(this.#host, UserService.getUserById2Fa({
            path: { id: unique },
        }));
    }
    /**
     * Disables a MFA provider for a user
     * @param unique The unique id of the user
     * @param providerName The name of the provider
     * @memberof UmbMfaServerDataSource
     */
    disableMfaProvider(unique, providerName) {
        if (!unique)
            throw new Error('User id is missing');
        if (!providerName)
            throw new Error('Provider is missing');
        return tryExecute(this.#host, UserService.deleteUserById2FaByProviderName({
            path: { id: unique, providerName },
        }));
    }
}
