"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ErrorsPanel = void 0;
var react_1 = __importStar(require("react"));
var classnames_1 = __importDefault(require("classnames"));
var Accordion_1 = __importDefault(require("@mui/material/Accordion"));
var AccordionSummary_1 = __importDefault(require("@mui/material/AccordionSummary"));
var AccordionDetails_1 = __importDefault(require("@mui/material/AccordionDetails"));
var ExpandMore_1 = __importDefault(require("@mui/icons-material/ExpandMore"));
var Typography_1 = __importDefault(require("@mui/material/Typography"));
var styles_1 = require("./styles");
exports.ErrorsPanel = (0, react_1.memo)(function (_a) {
    var panels = _a.panels, expandedPanelId = _a.expandedPanelId, onToggle = _a.onToggle, ErrorComponent = _a.ErrorComponent, _b = _a.alwaysShowLink, alwaysShowLink = _b === void 0 ? false : _b;
    var styles = (0, styles_1.useStyles)();
    return panels.length > 0 ? (react_1.default.createElement("div", null, panels.map(function (_a) {
        var id = _a.id, icon = _a.icon, title = _a.title, items = _a.items, accordionClassName = _a.accordionClassName, accordionDetailsClassName = _a.accordionDetailsClassName;
        return (react_1.default.createElement(Accordion_1.default, { key: id, square: true, expanded: expandedPanelId === id, onChange: onToggle(id), className: accordionClassName, classes: { root: styles.accordion, expanded: styles.accordionExpanded } },
            react_1.default.createElement(AccordionSummary_1.default, { classes: {
                    root: styles.accordionSummary,
                    expanded: styles.accordionSummaryExpanded,
                    content: styles.accordionSummaryContent
                }, expandIcon: react_1.default.createElement(ExpandMore_1.default, null) },
                icon,
                react_1.default.createElement(Typography_1.default, { className: styles.accordionSummaryHeading }, title)),
            react_1.default.createElement(AccordionDetails_1.default, { className: (0, classnames_1.default)(styles.accordionDetails, accordionDetailsClassName) }, items.map(function (error, i) { return (react_1.default.createElement(ErrorComponent, { key: i, error: error, alwaysShowLink: alwaysShowLink }) //NOSONAR
            ); }))));
    }))) : null;
});
exports.ErrorsPanel.displayName = 'ErrorsPanel';
