(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "tslib", "react", "../../../Button", "../../../typography/P2", "./styles"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var tslib_1 = require("tslib");
    var react_1 = (0, tslib_1.__importStar)(require("react"));
    var Button_1 = (0, tslib_1.__importDefault)(require("../../../Button"));
    var P2_1 = (0, tslib_1.__importDefault)(require("../../../typography/P2"));
    var styles_1 = require("./styles");
    var SnackBar = function (_a) {
        var message = _a.message, action = _a.action, closeSnackBar = _a.closeSnackBar, timeoutId = _a.timeoutId, id = _a.id, count = _a.count;
        (0, react_1.useEffect)(function () { return function () {
            timeoutId && clearTimeout(timeoutId);
        }; }, []);
        var onCloseSnackBar = function () {
            closeSnackBar === null || closeSnackBar === void 0 ? void 0 : closeSnackBar(id);
        };
        return (react_1.default.createElement(styles_1.SnackBarStyled, { className: "snack-bar" },
            react_1.default.createElement(P2_1.default, { type: "corvus", className: "snack-bar__text" }, message),
            action && (react_1.default.createElement(Button_1.default, { viewType: "link", size: "s", onClick: action.onClick || onCloseSnackBar, className: "action-button" }, action.text)),
            count && react_1.default.createElement(styles_1.SnackBarCounterStyled, null, count)));
    };
    exports.default = SnackBar;
});
