import { withoutDefaults } from '../util';
import { cairoDataExtensionUnsuccessfulUpdateInServer, cairoModalCtaClicked, cairoTryAgainClicked, } from '@wix/bex-utils/@wix/bi-logger-os-data/v2';
import { formatPermissionsForBi } from './formatPermissionsForBi';
export class FieldOperationsBIReporter {
    constructor(params) {
        this.reportArchiveFieldModalCtaClicked = (ctaName) => {
            this.reportBi(withoutDefaults(cairoModalCtaClicked)({
                ctaName,
                modalName: 'Archive custom field',
            }));
        };
        this.reportDeleteFieldModalCtaClicked = (ctaName) => {
            this.reportBi(withoutDefaults(cairoModalCtaClicked)({
                ctaName,
                modalName: 'Delete custom field',
            }));
        };
        this.reportArchiveFieldFailed = ({ origin, formValues, }) => {
            if (!formValues) {
                return;
            }
            this.reportBi(withoutDefaults(cairoDataExtensionUnsuccessfulUpdateInServer)({
                actionName: 'Archive',
                errorType: 'Technical issue',
                origin,
                permissions: formatPermissionsForBi(formValues),
                fieldType: formValues.type,
                fieldName: formValues.name,
                key: formValues.key,
            }));
        };
        this.reportArchiveTryAgain = () => {
            this.reportBi(withoutDefaults(cairoTryAgainClicked)({
                actionName: 'Archive custom field',
                loaction: 'toast',
            }));
        };
        this.reportRestoreFieldFailed = ({ origin, formValues, }) => {
            if (!formValues) {
                return;
            }
            this.reportBi(withoutDefaults(cairoDataExtensionUnsuccessfulUpdateInServer)({
                actionName: 'Restore',
                errorType: 'Technical issue',
                origin,
                permissions: formatPermissionsForBi(formValues),
                fieldType: formValues.type,
                fieldName: formValues.name,
                key: formValues.key,
            }));
        };
        this.reportRestoreTryAgain = () => {
            this.reportBi(withoutDefaults(cairoTryAgainClicked)({
                actionName: 'Restore custom field',
                loaction: 'toast',
            }));
        };
        const { reportBi } = params;
        this.reportBi = reportBi;
    }
}
//# sourceMappingURL=FieldOperationsBIReporter.js.map