import { UmbUserRepositoryBase } from '../user-repository-base.js';
import { UmbUnlockUserServerDataSource } from './unlock-user.server.data-source.js';
import { UserStateModel } from '../../../../core/backend-api/index.js';
export class UmbUnlockUserRepository extends UmbUserRepositoryBase {
    #source;
    constructor(host) {
        super(host);
        this.#source = new UmbUnlockUserServerDataSource(host);
    }
    async unlock(ids) {
        if (ids.length === 0)
            throw new Error('User ids are missing');
        await this.init;
        const { data, error } = await this.#source.unlock(ids);
        if (!error) {
            ids.forEach((id) => {
                this.detailStore?.updateItem(id, { state: UserStateModel.ACTIVE, failedLoginAttempts: 0 });
            });
            const notification = { data: { message: `User unlocked` } };
            this.notificationContext?.peek('positive', notification);
        }
        return { data, error };
    }
}
export default UmbUnlockUserRepository;
