import { UmbDocumentCreateBlueprintRepository } from './repository/document-create-blueprint.repository.js';
import { UMB_CREATE_BLUEPRINT_MODAL } from './constants.js';
import { UmbEntityActionBase } from '../../../../core/entity-action/index.js';
import { umbOpenModal } from '../../../../core/modal/index.js';
export class UmbDocumentCreateBlueprintEntityAction extends UmbEntityActionBase {
    #repository = new UmbDocumentCreateBlueprintRepository(this);
    constructor(host, args) {
        super(host, args);
    }
    async execute() {
        if (!this.args.unique)
            throw new Error('Unique is required');
        const value = await umbOpenModal(this, UMB_CREATE_BLUEPRINT_MODAL, {
            data: { unique: this.args.unique },
        });
        const { name, parent } = value;
        if (!name)
            return;
        await this.#repository.create({ name, parent, document: { id: this.args.unique } });
    }
}
export default UmbDocumentCreateBlueprintEntityAction;
