import { UmbDisableUserRepository } from '../../repository/index.js';
import { UMB_ACTION_EVENT_CONTEXT } from '../../../../core/action/index.js';
import { UmbEntityBulkActionBase } from '../../../../core/entity-bulk-action/index.js';
import { UmbRequestReloadChildrenOfEntityEvent } from '../../../../core/entity-action/index.js';
import { UMB_ENTITY_CONTEXT } from '../../../../core/entity/index.js';
export class UmbDisableUserEntityBulkAction extends UmbEntityBulkActionBase {
    async execute() {
        const repository = new UmbDisableUserRepository(this._host);
        await repository.disable(this.selection);
        const entityContext = await this.getContext(UMB_ENTITY_CONTEXT);
        if (!entityContext)
            throw new Error('Entity context not found');
        const entityType = entityContext.getEntityType();
        const unique = entityContext.getUnique();
        if (!entityType)
            throw new Error('Entity type not found');
        if (unique === undefined)
            throw new Error('Entity unique not found');
        const eventContext = await this.getContext(UMB_ACTION_EVENT_CONTEXT);
        if (!eventContext)
            throw new Error('Event context not found');
        const event = new UmbRequestReloadChildrenOfEntityEvent({
            entityType,
            unique,
        });
        eventContext.dispatchEvent(event);
    }
}
export { UmbDisableUserEntityBulkAction as api };
