"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MetaInfoForm = void 0;
var react_1 = __importDefault(require("react"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var Box_1 = __importDefault(require("@mui/material/Box"));
var Divider_1 = __importDefault(require("@mui/material/Divider"));
var Button_1 = __importDefault(require("@mui/material/Button"));
var EditModeAttributesPager_1 = require("../../../EditModeAttributesPager");
var helpers_1 = require("../../helpers");
var styles_1 = require("./styles");
var MetaInfoForm = function (_a) {
    var attributeType = _a.attributeType, imageAttributeFieldsOrder = _a.imageAttributeFieldsOrder, attributeValue = _a.attributeValue, hasChanges = _a.hasChanges, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, onAddAttributes = _a.onAddAttributes, onCancel = _a.onCancel, onApply = _a.onApply, mode = _a.mode;
    var styles = (0, styles_1.useStyles)();
    var notSystemAttributesList = (0, helpers_1.getNotSystemAttributesList)(attributeValue, attributeType, imageAttributeFieldsOrder);
    var shouldShowActionButtons = notSystemAttributesList.length !== 0 || (notSystemAttributesList.length === 0 && hasChanges);
    return (react_1.default.createElement(Box_1.default, { className: styles.root },
        react_1.default.createElement(Box_1.default, { className: styles.form }, notSystemAttributesList.map(function (_a) {
            var attrType = _a.attrType, values = _a.values;
            return (react_1.default.createElement(EditModeAttributesPager_1.EditModeAttributesPager, { key: attrType.uri, parentUri: attributeValue.uri, attributeType: attrType, values: values, showEmptyEditors: (0, mdm_sdk_1.isTempUri)(attributeValue.uri), mode: mode, drawLines: false, onDeleteAttribute: onDeleteAttribute, onChangeAttribute: onChangeAttribute, onAddAttributes: onAddAttributes }));
        })),
        shouldShowActionButtons && (react_1.default.createElement(react_1.default.Fragment, null,
            react_1.default.createElement(Divider_1.default, { className: styles.divider }),
            react_1.default.createElement(Box_1.default, { className: styles.actions },
                react_1.default.createElement(Button_1.default, { disabled: !hasChanges, onClick: onCancel, className: styles.cancelButton }, ui_i18n_1.default.text('Cancel')),
                react_1.default.createElement(Button_1.default, { disabled: !hasChanges, onClick: onApply, color: "primary" }, ui_i18n_1.default.text('Apply')))))));
};
exports.MetaInfoForm = MetaInfoForm;
