"use strict";
exports.__esModule = true;
exports.Collapse = exports.sizeTitleTagMap = exports.sizeLabelMap = exports.sizeIconMap = exports.cnCollapse = exports.collapsePropCloseDirectionIconDefault = exports.collapsePropDirectionIconDefault = exports.collapsePropDirectionIcon = exports.collapsePropIconPositionDefault = exports.collapsePropIconPosition = exports.collapsePropHorizontalSpace = exports.collapsePropViewDefault = exports.collapsePropView = exports.collapsePropSizeDefault = exports.collapsePropSize = void 0;
var tslib_1 = require("tslib");
// @ts-nocheck
require("./Collapse.css");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var IconAdd_1 = require("../../icons/IconAdd/IconAdd");
var IconRemove_1 = require("../../icons/IconRemove/IconRemove");
var bem_1 = require("../../utils/bem");
var getSizeByMap_1 = require("../../utils/getSizeByMap");
var Grid_1 = require("../Grid/Grid");
var Typography_1 = require("../Typography/Typography");
var CollapseIcon_1 = require("./CollapseIcon/CollapseIcon");
exports.collapsePropSize = ['m', 'l', 's', 'xs', '2xs'];
exports.collapsePropSizeDefault = exports.collapsePropSize[0];
exports.collapsePropView = ['primary', 'secondary'];
exports.collapsePropViewDefault = exports.collapsePropView[0];
exports.collapsePropHorizontalSpace = [
    '3xs',
    '6xl',
    '5xl',
    '4xl',
    '3xl',
    '2xl',
    'xl',
    'l',
    'm',
    's',
    'xs',
    '2xs',
];
exports.collapsePropIconPosition = ['left', 'right'];
exports.collapsePropIconPositionDefault = exports.collapsePropIconPosition[1];
exports.collapsePropDirectionIcon = CollapseIcon_1.collapseIconPropDirection;
exports.collapsePropDirectionIconDefault = exports.collapsePropDirectionIcon[0];
exports.collapsePropCloseDirectionIconDefault = exports.collapsePropDirectionIcon[2];
exports.cnCollapse = (0, bem_1.cn)('Collapse');
exports.sizeIconMap = {
    '2xs': 'xs',
    'xs': 'xs',
    's': 'xs',
    'm': 's',
    'l': 's'
};
exports.sizeLabelMap = {
    m: 'tiny',
    l: 'lg'
};
exports.sizeTitleTagMap = {
    l: 'h2',
    m: 'h3'
};
function renderSide(side) {
    var sides = side ? (0, tslib_1.__spreadArray)([], (0, tslib_1.__read)((Array.isArray(side) ? side : [side])), false) : [];
    return sides.map(function (item, index) { return (react_1["default"].createElement("div", { className: (0, exports.cnCollapse)('Side'), key: index }, item)); });
}
// eslint-disable-next-line @typescript-eslint/no-redeclare
exports.Collapse = react_1["default"].forwardRef(function (props, ref) {
    var label = props.label, _a = props.size, size = _a === void 0 ? exports.collapsePropSizeDefault : _a, _b = props.view, view = _b === void 0 ? exports.collapsePropViewDefault : _b, className = props.className, isOpen = props.isOpen, children = props.children, hoverEffect = props.hoverEffect, divider = props.divider, _c = props.icon, icon = _c === void 0 ? IconAdd_1.IconAdd : _c, _d = props.closeIcon, closeIcon = _d === void 0 ? IconRemove_1.IconRemove : _d, rightSide = props.rightSide, horizontalSpace = props.horizontalSpace, _e = props.iconPosition, iconPosition = _e === void 0 ? exports.collapsePropIconPositionDefault : _e, _f = props.directionIcon, directionIcon = _f === void 0 ? exports.collapsePropDirectionIconDefault : _f, _g = props.closeDirectionIcon, closeDirectionIcon = _g === void 0 ? exports.collapsePropCloseDirectionIconDefault : _g, style = props.style, position = props.position, otherProps = (0, tslib_1.__rest)(props, ["label", "size", "view", "className", "isOpen", "children", "hoverEffect", "divider", "icon", "closeIcon", "rightSide", "horizontalSpace", "iconPosition", "directionIcon", "closeDirectionIcon", "style", "position"]);
    return (react_1["default"].createElement("div", { ref: ref, className: (0, exports.cnCollapse)({ size: size, view: view, horizontalSpace: horizontalSpace }, [className]), style: style },
        react_1["default"].createElement("div", (0, tslib_1.__assign)({ className: (0, exports.cnCollapse)('Label', {
                hoverEffect: hoverEffect,
                divider: divider,
                iconPosition: iconPosition
            }) }, otherProps),
            react_1["default"].createElement(Grid_1.Grid, { breakpoints: { desktop: { cols: 12 } }, cols: "1" },
                react_1["default"].createElement(Grid_1.GridItem, { breakpoints: { desktop: { colStart: position !== null && position !== void 0 ? position : 1, col: 12 } }, className: (0, exports.cnCollapse)('Label-Inner'), col: "1" },
                    react_1["default"].createElement(CollapseIcon_1.CollapseIcon, { className: (0, exports.cnCollapse)('Icon', { position: iconPosition }), size: (0, getSizeByMap_1.getSizeByMap)(exports.sizeIconMap, size), icon: icon, closeIcon: closeIcon, isOpen: isOpen, direction: directionIcon, closeDirection: closeDirectionIcon }),
                    react_1["default"].createElement(Typography_1.Typography.Title, { className: (0, exports.cnCollapse)('LabelText'), view: view, size: (0, getSizeByMap_1.getSizeByMap)(exports.sizeLabelMap, size), as: (0, getSizeByMap_1.getSizeByMap)(exports.sizeTitleTagMap, size) }, label),
                    iconPosition === 'left' && renderSide(rightSide)))),
        react_1["default"].createElement("div", { className: (0, exports.cnCollapse)('Body', { isOpen: isOpen }) },
            react_1["default"].createElement("div", { className: (0, exports.cnCollapse)('Content') }, children))));
});
