"use strict";
exports.__esModule = true;
exports.CollapseIcon = exports.collapseIconPropDirection = void 0;
var tslib_1 = require("tslib");
/* eslint-disable jsx-a11y/no-static-element-interactions */
/* eslint-disable jsx-a11y/click-events-have-key-events */
require("./CollapseIcon.css");
var react_1 = (0, tslib_1.__importDefault)(require("react"));
var react_transition_group_1 = require("react-transition-group");
var Icon_1 = require("../../../icons/Icon/Icon");
var bem_1 = require("../../../utils/bem");
var cnForCssTransition_1 = require("../../../utils/cnForCssTransition");
exports.collapseIconPropDirection = [
    'up',
    'right',
    'down',
    'left',
    'upRight',
    'downRight',
    'upLeft',
    'downLeft',
];
var cnCollapseIcon = (0, bem_1.cn)('CollapseIcon');
var cssTransitionClassNames = (0, cnForCssTransition_1.cnForCssTransition)(cnCollapseIcon);
var animateTimeout = 300;
var CollapseIcon = function (props) {
    var size = props.size, Icon = props.icon, CloseIcon = props.closeIcon, direction = props.direction, closeDirection = props.closeDirection, isOpen = props.isOpen, className = props.className, onClick = props.onClick, otherProps = (0, tslib_1.__rest)(props, ["size", "icon", "closeIcon", "direction", "closeDirection", "isOpen", "className", "onClick"]);
    if (CloseIcon) {
        return (react_1["default"].createElement("span", { className: cnCollapseIcon('Wrapper', [(0, Icon_1.cnIcon)({ size: size }), className]), onClick: onClick },
            react_1["default"].createElement(react_transition_group_1.CSSTransition, { "in": !isOpen, unmountOnExit: true, classNames: cssTransitionClassNames, timeout: animateTimeout },
                react_1["default"].createElement(Icon, (0, tslib_1.__assign)({}, otherProps, { className: cnCollapseIcon({ withCloseIcon: true }), size: size }))),
            react_1["default"].createElement(react_transition_group_1.CSSTransition, { "in": isOpen, unmountOnExit: true, classNames: cssTransitionClassNames, timeout: animateTimeout },
                react_1["default"].createElement(CloseIcon, (0, tslib_1.__assign)({}, otherProps, { className: cnCollapseIcon({ withCloseIcon: true }), size: size })))));
    }
    return (react_1["default"].createElement(Icon, (0, tslib_1.__assign)({}, otherProps, { className: cnCollapseIcon({ isOpen: isOpen, direction: direction, closeDirection: closeDirection }, [className]), size: size })));
};
exports.CollapseIcon = CollapseIcon;
