"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ContentState = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const Button_1 = require("../Button");
const ErrorBoundary_1 = require("../ErrorBoundary");
const LoadingPlaceholder_1 = require("../placeholders/LoadingPlaceholder");
const Placeholder_1 = require("../placeholders/Placeholder");
const Typography_1 = require("../Typography");
const useLogic_1 = require("./useLogic");
const ContentState = ({ isLoading, isError, isCustom, errorState, customState, children, loadingContent, loadingTitle, placeholderSize, isSmoothLoading, loadingPlaceholderClassname, }) => {
    const { imagesMap, isLoadingPhase, isShowLoader } = (0, useLogic_1.useLogic)({
        isLoading,
        isSmoothLoading,
    });
    if (isLoadingPhase) {
        return ((0, jsx_runtime_1.jsx)(LoadingPlaceholder_1.LoadingPlaceholder, { content: loadingContent, title: loadingTitle, isShowLoader: isShowLoader, className: loadingPlaceholderClassname }));
    }
    if (isCustom && customState) {
        return (0, jsx_runtime_1.jsx)(Placeholder_1.Placeholder, { ...customState });
    }
    if (isError && errorState) {
        const { title = 'Произошла ошибка', imgAlt, imgSrc = imagesMap.defaultErrorImgSrc, errorList, onRetry, actions = (0, jsx_runtime_1.jsx)(Button_1.Button, { onClick: onRetry, children: "\u041F\u043E\u043F\u0440\u043E\u0431\u043E\u0432\u0430\u0442\u044C \u0441\u043D\u043E\u0432\u0430" }), } = errorState;
        const description = errorList.map((errorMessage) => ((0, jsx_runtime_1.jsx)(Typography_1.Typography, { component: "p", children: errorMessage }, errorMessage)));
        return ((0, jsx_runtime_1.jsx)(Placeholder_1.Placeholder, { title: title, description: description, imgAlt: imgAlt, imgSrc: imgSrc, Actions: actions, size: placeholderSize }));
    }
    return (0, jsx_runtime_1.jsx)(ErrorBoundary_1.ErrorBoundary, { children: children });
};
exports.ContentState = ContentState;
