(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", "@greenatom/icons", "./style"], 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 icons_1 = require("@greenatom/icons");
    var style_1 = require("./style");
    var Preloader = function (_a) {
        var progress = _a.progress, _b = _a.type, type = _b === void 0 ? "circular" : _b, isShowLabel = _a.isShowLabel, width = _a.width, height = _a.height, className = _a.className, children = _a.children;
        var getPreloader = (0, react_1.useMemo)(function () {
            if (type === "star") {
                return react_1.default.createElement(icons_1.IconStarloader, { width: 24, height: 24 });
            }
            else if (type === "circular") {
                return react_1.default.createElement(icons_1.IconLoading, { width: 24, height: 24 });
            }
            else {
                return children ? children : "Идет загрузка";
            }
        }, [type, isShowLabel]);
        return (react_1.default.createElement(style_1.PreloaderBase, { isShowLabel: isShowLabel, className: className, width: width, height: height },
            getPreloader,
            progress !== undefined && (react_1.default.createElement("div", { className: "progressbar" },
                isShowLabel && react_1.default.createElement(style_1.Label, null, String(progress) + "%"),
                react_1.default.createElement(style_1.ProgressBarStyle, null,
                    react_1.default.createElement(style_1.Filler, { progress: progress }))))));
    };
    exports.default = Preloader;
});
