"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (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.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CollapsableCard = void 0;
const react_1 = __importStar(require("react"));
const Box_1 = require("../Box");
const Flex_1 = require("../Flex");
const Heading_1 = require("../Heading");
const IconCircled_1 = require("../IconCircled");
const icons_1 = require("../../assets/images/icons");
const variants = {
    light: { bg: 'white', borderRadius: '3', boxShadow: '5', p: '4', mb: '1' },
    transparent: {},
};
exports.CollapsableCard = (props) => {
    const { title, defaultOpen, clickable = true, onClick, children, variant = 'light' } = props, restProps = __rest(props, ["title", "defaultOpen", "clickable", "onClick", "children", "variant"]);
    const [isOpen, setIsOpen] = react_1.useState(!!defaultOpen);
    const toggle = () => {
        const newState = !isOpen;
        setIsOpen(newState);
        if (onClick)
            onClick(newState);
    };
    const clickableProps = {
        onClick: toggle,
        style: { cursor: 'pointer' },
    };
    return (react_1.default.createElement(Box_1.Box, Object.assign({}, variants[variant], restProps),
        react_1.default.createElement(Flex_1.Flex, Object.assign({ justifyContent: "space-between" }, (clickable ? clickableProps : {})),
            react_1.default.createElement(Box_1.Box, { mr: "24px" },
                react_1.default.createElement(Heading_1.Heading, { variant: "h5" }, title)),
            react_1.default.createElement(Box_1.Box, null,
                react_1.default.createElement(IconCircled_1.IconCircled, Object.assign({ Asset: icons_1.SvgChevron, scale: 0.75, width: 32, height: 32, color: isOpen ? 'brandMain' : 'gray.3', bg: isOpen ? 'brandLightest' : 'gray.4', rotate: isOpen ? undefined : '180deg' }, (clickable ? {} : clickableProps))))),
        isOpen && react_1.default.createElement(Box_1.Box, { mt: "4" }, children)));
};
//# sourceMappingURL=CollapsableCard.js.map