"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MoreAttributesEditor = void 0;
var react_1 = __importDefault(require("react"));
var classnames_1 = __importDefault(require("classnames"));
var ui_i18n_1 = __importDefault(require("ui-i18n"));
var react_context_selector_1 = require("@fluentui/react-context-selector");
var MoreAttributesButton_1 = require("../../../../../../MoreAttributesButton");
var ChangeRequestEditorContext_1 = require("../../../../contexts/ChangeRequestEditorContext");
var merge_1 = require("../../../../helpers/merge");
var editors_module_css_1 = __importDefault(require("../editors.module.css"));
var MoreAttributesEditor_module_css_1 = __importDefault(require("./MoreAttributesEditor.module.css"));
var emptyLineIds = [];
var MoreAttributesEditor = function (_a) {
    var _b;
    var data = _a.data, onApply = _a.onApply, change = _a.change, parent = _a.parent;
    var lineIds = (change === null || change === void 0 ? void 0 : change.lineIds) || (0, merge_1.extractLineIds)(change === null || change === void 0 ? void 0 : change.newValue) || emptyLineIds;
    var isLineRejected = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) {
        return context.getIsLineRejected(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]);
    });
    var isParentLineRejected = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) {
        return context.getIsParentLineRejected(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]);
    });
    var label = ui_i18n_1.default.text('More attributes');
    var isRejected = isLineRejected || isParentLineRejected;
    return (react_1.default.createElement("div", { className: (0, classnames_1.default)(editors_module_css_1.default.attributeRow, (_b = {}, _b[MoreAttributesEditor_module_css_1.default.rejectedRow] = isRejected, _b)), "data-reltio-id": "more-attributes-editor" },
        react_1.default.createElement("div", { className: editors_module_css_1.default.labelColumn }),
        react_1.default.createElement("div", { className: (0, classnames_1.default)(editors_module_css_1.default.valueColumn, MoreAttributesEditor_module_css_1.default.moreAttributesButton) },
            react_1.default.createElement(MoreAttributesButton_1.MoreAttributesButton, { label: label, popupTitle: label, data: data, parent: parent, onApply: onApply, disabled: isRejected }))));
};
exports.MoreAttributesEditor = MoreAttributesEditor;
