"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 __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importStar(require("react"));
var toast_style_1 = __importDefault(require("./toast.style"));
var Toast = function (_a) {
    var item = _a.item;
    var message = item.message, opened = item.opened, type = item.type, forceClose = item.forceClose;
    var _b = react_1.useState(false), opening = _b[0], setOpening = _b[1];
    var _c = react_1.useState(false), closing = _c[0], setClosing = _c[1];
    react_1.useEffect(function () {
        if (opened) {
            setOpening(true);
        }
        else {
            setClosing(true);
            setOpening(false);
        }
    }, [opened]);
    return (react_1.default.createElement(toast_style_1.default, null,
        react_1.default.createElement("div", { className: "ds-toast-container alert " + (closing && 'closing') + " " + (opening && 'opening'), onClick: forceClose },
            react_1.default.createElement("div", { className: "ds-toast" },
                type && (react_1.default.createElement("div", { className: "icon " + type },
                    type === 'error' && react_1.default.createElement("i", { className: "fas fa-exclamation-circle" }),
                    type === 'danger' && react_1.default.createElement("i", { className: "fas fa-exclamation" }),
                    type === 'warning' && react_1.default.createElement("i", { className: "fas fa-exclamation-triangle" }))),
                react_1.default.createElement("div", { className: "message" }, message),
                react_1.default.createElement("div", { className: "close" },
                    react_1.default.createElement("i", { className: "fas fa-times" }))))));
};
exports.default = Toast;
//# sourceMappingURL=toast.js.map