import { UMB_CURRENT_USER_CONTEXT } from '../current-user.context.token.js';
import { UmbCurrentUserRepository } from '../repository/index.js';
import { UmbActionBase } from '../../../core/action/index.js';
import { umbOpenModal } from '../../../core/modal/index.js';
import { UMB_CHANGE_PASSWORD_MODAL } from '../../change-password/index.js';
export class UmbChangePasswordCurrentUserAction extends UmbActionBase {
    #unique;
    constructor(host, args) {
        super(host, args);
        this.consumeContext(UMB_CURRENT_USER_CONTEXT, (context) => {
            this.observe(context?.unique, (unique) => {
                this.#unique = unique;
            }, 'umbEditCurrentUserActionObserver');
        });
    }
    async getHref() {
        return undefined;
    }
    async execute() {
        if (!this.#unique)
            return;
        const data = await umbOpenModal(this, UMB_CHANGE_PASSWORD_MODAL, {
            data: {
                user: {
                    unique: this.#unique,
                },
            },
        });
        const repository = new UmbCurrentUserRepository(this);
        await repository.changePassword(data.newPassword, data.oldPassword);
    }
}
export { UmbChangePasswordCurrentUserAction as api };
