import { UmbUserRepositoryBase } from '../user-repository-base.js';
import { UmbChangeUserPasswordServerDataSource } from './change-user-password.server.data-source.js';
export class UmbChangeUserPasswordRepository extends UmbUserRepositoryBase {
    #changePasswordSource;
    constructor(host) {
        super(host);
        this.#changePasswordSource = new UmbChangeUserPasswordServerDataSource(host);
    }
    async changePassword(userId, newPassword) {
        if (!userId)
            throw new Error('User id is missing');
        if (!newPassword)
            throw new Error('New password is missing');
        await this.init;
        const { data, error } = await this.#changePasswordSource.changePassword(userId, newPassword);
        if (!error) {
            const notification = { data: { message: `Password changed` } };
            this.notificationContext?.peek('positive', notification);
        }
        return { data, error };
    }
}
export default UmbChangeUserPasswordRepository;
