(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", "react-dom", "../Pallette/themes", "../ThemeProvider/ThemeProvider", "./Banner"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.getContainerBanner = exports.bannerShow = void 0;
    var tslib_1 = require("tslib");
    var react_1 = (0, tslib_1.__importDefault)(require("react"));
    var react_dom_1 = (0, tslib_1.__importDefault)(require("react-dom"));
    var themes_1 = require("../Pallette/themes");
    var ThemeProvider_1 = (0, tslib_1.__importDefault)(require("../ThemeProvider/ThemeProvider"));
    var Banner_1 = (0, tslib_1.__importDefault)(require("./Banner"));
    var bannerShow = function (property, theme, idContainer) {
        var container = (0, exports.getContainerBanner)(property.type, idContainer);
        var bannerClose = function () {
            react_dom_1.default.unmountComponentAtNode(container);
            container.remove();
        };
        var handlePrimaryClick = function () {
            var _a;
            (_a = property.onPrimaryClick) === null || _a === void 0 ? void 0 : _a.call(property);
            bannerClose();
        };
        react_dom_1.default.render(react_1.default.createElement(ThemeProvider_1.default, { theme: theme || themes_1.LIGHT_THEME },
            react_1.default.createElement(Banner_1.default, (0, tslib_1.__assign)({ onPrimaryClick: handlePrimaryClick }, property))), container);
        return bannerClose;
    };
    exports.bannerShow = bannerShow;
    var getContainerBanner = function (type, idContainer) {
        var _a;
        var container = document.createElement("div");
        if (idContainer) {
            var root = document.getElementById(idContainer);
            if (type === "shifting") {
                root === null || root === void 0 ? void 0 : root.prepend(container);
            }
            else {
                root === null || root === void 0 ? void 0 : root.appendChild(container);
            }
        }
        else if (type === "shifting") {
            (_a = document.body) === null || _a === void 0 ? void 0 : _a.prepend(container);
        }
        else {
            document.body.appendChild(container);
        }
        return container;
    };
    exports.getContainerBanner = getContainerBanner;
});
