import { makeAutoObservable } from 'mobx';
import { ConditionalModalState } from './ConditionalModalState';
import { DataExtensionStateBIReporter } from './DataExtensionStateBIReporter';
export class DeleteFieldModalState {
    constructor(params) {
        this.biReporter = new DataExtensionStateBIReporter({
            reportBi: params.reportBi,
        });
        this.modal = new ConditionalModalState({
            onConfirm: async () => {
                if (!this.modal.value) {
                    return;
                }
                this.biReporter.reportDeleteFieldModalCtaClicked('Delete');
                await this.dataExtension.deleteField({
                    ...this.modal.value,
                    reportBi: this.biReporter.reportBi,
                });
                // Close archived panel if no items left
                const remainingItems = this.dataExtension.archivedItems;
                if (remainingItems.length === 0) {
                    this.dataExtension.closeArchivedPanel();
                }
            },
            onClose: () => {
                this.biReporter.reportDeleteFieldModalCtaClicked('Cancel');
            },
        });
        this.dataExtension = params.dataExtension;
        makeAutoObservable(this);
    }
}
//# sourceMappingURL=DeleteFieldModalState.js.map