"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AlertBox2 = exports.cssClass = exports.AlertBox2Type = void 0;
var classnames = require("classnames");
var React = require("react");
var react_1 = require("react");
var FontAwesome = require("react-fontawesome");
require("./AlertBox2.less");
var AlertBox2Type;
(function (AlertBox2Type) {
    AlertBox2Type["CRITICAL"] = "critical";
    AlertBox2Type["CAUTION"] = "caution";
    AlertBox2Type["SUCCESS"] = "success";
    AlertBox2Type["INFO"] = "info";
    AlertBox2Type["SUPPORT"] = "support";
})(AlertBox2Type = exports.AlertBox2Type || (exports.AlertBox2Type = {}));
var FA_ICON_MAP = {
    critical: "exclamation-circle",
    caution: "exclamation-triangle",
    success: "thumbs-up",
    info: "exclamation-circle",
    support: "life-ring",
};
exports.cssClass = {
    CONTAINER: "AlertBox2",
    CONTENT_CONTAINER: "AlertBox2--contentContainer",
    CONTENT_CONTAINER_WITH_BUTTONS: "AlertBox2--contentContainer--withButtons",
    ICON: "AlertBox2--icon",
    CONTENT: "AlertBox2--content",
    CLOSE_BUTTON: "AlertBox2--closeButton",
};
/**
 * TODO: Add short description.
 */
exports.AlertBox2 = function (_a) {
    var children = _a.children, className = _a.className, type = _a.type, buttons = _a.buttons, isCloseable = _a.isCloseable, iconOverride = _a.iconOverride, onClose = _a.onClose;
    var _b = react_1.useState(false), isClosed = _b[0], setIsClosed = _b[1];
    react_1.useEffect(function () {
        setIsClosed(false);
    }, [children, type, isCloseable]);
    if (isClosed) {
        return null;
    }
    var icon = iconOverride || (React.createElement(FontAwesome, { className: classnames(exports.cssClass.ICON, "AlertBox2--icon--" + type), fixedWidth: true, name: FA_ICON_MAP[type] }));
    return (React.createElement("div", { className: classnames(exports.cssClass.CONTAINER, "AlertBox2--" + type, className) },
        React.createElement("div", { className: classnames(exports.cssClass.CONTENT_CONTAINER, !!buttons && exports.cssClass.CONTENT_CONTAINER_WITH_BUTTONS) },
            React.createElement("div", null, icon),
            React.createElement("div", { className: exports.cssClass.CONTENT }, children)),
        React.createElement("div", { className: "AlertBox2--buttons" },
            buttons,
            isCloseable && (React.createElement("button", { "aria-label": "Close", className: exports.cssClass.CLOSE_BUTTON, onClick: function () {
                    if (onClose) {
                        onClose();
                    }
                    setIsClosed(true);
                } }, "\u2715")))));
};
