'use client';
"use strict";
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
    if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
    return cooked;
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (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.prototype.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 jsx_runtime_1 = require("react/jsx-runtime");
var react_1 = __importDefault(require("react"));
var stores_1 = require("../../hooks/stores");
var styles_1 = __importStar(require("../../utils/styles"));
var Container = styles_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n  position: fixed;\n  top: 80px;\n  left: 0;\n  width: 100%;\n  height: 0;\n  display: flex;\n  justify-content: center;\n  pointer-events: none;\n  z-index: ", ";\n"], ["\n  position: fixed;\n  top: 80px;\n  left: 0;\n  width: 100%;\n  height: 0;\n  display: flex;\n  justify-content: center;\n  pointer-events: none;\n  z-index: ", ";\n"])), styles_1.theme.zIndex.tooltip);
var ToastContainer = styles_1.default.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n  margin: auto;\n  opacity: ", ";\n  transition: opacity ", " ease-in-out;\n  animation: ", "\n    ", " ease-in-out forwards;\n"], ["\n  margin: auto;\n  opacity: ", ";\n  transition: opacity ", " ease-in-out;\n  animation: ", "\n    ", " ease-in-out forwards;\n"])), function (_a) {
    var $isDisplay = _a.$isDisplay;
    return ($isDisplay ? 1 : 0);
}, styles_1.theme.duration, function (_a) {
    var $isDisplay = _a.$isDisplay;
    return $isDisplay
        ? styles_1.theme.keyframe.snackbar.slideDown
        : styles_1.theme.keyframe.snackbar.slideUp;
}, styles_1.theme.duration);
exports.default = react_1.default.memo(function () {
    var toast = (0, stores_1.useToastStore)().toast;
    var _a = react_1.default.useState(toast), cachedToast = _a[0], setCachedToast = _a[1];
    react_1.default.useEffect(function () {
        if (!toast)
            return;
        setCachedToast(toast);
    }, [toast]);
    return (!!(cachedToast === null || cachedToast === void 0 ? void 0 : cachedToast.content) && ((0, jsx_runtime_1.jsx)(Container, { children: (0, jsx_runtime_1.jsx)(ToastContainer, { "$isDisplay": !!toast, children: cachedToast.content }) })));
});
var templateObject_1, templateObject_2;
//# sourceMappingURL=ToastProvider.js.map