"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.WarnButton = void 0;
const react_1 = __importDefault(require("react"));
require("./warn-button.scss");
const Tooltip_1 = require("../tooltip/Tooltip");
const Button_1 = require("../button/Button");
const WarnButton = ({ message, icon, className, disabled, tooltip, iconOnly, onConfirmedClick, displayOptions, setDisplayOptions, withLabel, }) => {
    if (displayOptions === undefined || displayOptions === null) {
        ;
        [displayOptions, setDisplayOptions] = react_1.default.useState(false);
    }
    const viewAction = (react_1.default.createElement("div", { className: withLabel ? "warn-btn-group with-label" : "warn-btn-group", role: "group" },
        react_1.default.createElement("div", { className: "slide-in" },
            react_1.default.createElement(Button_1.Button, { className: "btn-warn-component cancel", iconSize: "12px", iconOnly: iconOnly, icon: "fa fa-times", color: "#fff", backgroundColor: "#c00342", onClick: () => setDisplayOptions((currentState) => !currentState), size: "xsmall", label: "cancel" }),
            react_1.default.createElement(Button_1.Button, { className: "btn-warn-component success", iconSize: "12px", icon: "fa fa-check", color: "#fff", iconOnly: iconOnly, backgroundColor: "#00b489", onClick: () => {
                    onConfirmedClick();
                    setDisplayOptions((currentState) => !currentState);
                }, size: "xsmall", label: "confirm" }))));
    const hideAction = (react_1.default.createElement("span", { className: disabled ? " disabled warn-btn-click" : "warn-btn-click" },
        react_1.default.createElement(Button_1.Button, { className: "btn-warn-component", iconSize: "12px", icon: "fa " + icon, label: message, onClick: () => setDisplayOptions((currentState) => !currentState), disabled: disabled })));
    const button = displayOptions ? viewAction : hideAction;
    return (react_1.default.createElement("div", { className: "warn-btn " + (className || "") }, tooltip
        ? (react_1.default.createElement(Tooltip_1.Tooltip, { flow: "up", tooltip: tooltip }, button))
        : button));
};
exports.WarnButton = WarnButton;
