"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.OptionsModal = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const Button_1 = require("../../Button");
const Dialog_1 = require("../../Dialog");
const DialogActions_1 = require("../../DialogActions");
const Paper_1 = require("../../Paper");
const Tree_1 = require("../../Tree");
const Typography_1 = require("../../Typography");
const constants_1 = require("./constants");
const ErrorMessage_1 = require("./ErrorMessage");
const Loader_1 = require("./Loader");
const NoData_1 = require("./NoData");
const SearchSuggestion_1 = require("./SearchSuggestion");
const styles_1 = require("./styles");
const useLogic_1 = require("./useLogic");
const OptionsModal = (props) => {
    const { isNoResult, searchFieldProps, modalProps, treeListProps, cancelButtonProps, confirmButtonProps, handleRetry, isShowUserHint, isShowModalLoader, isShowSearchFieldLoader, isShowSearchSuggestion, isLoadingError, treeProps, loadingErrorMsg, } = (0, useLogic_1.useLogic)(props);
    const renderComponent = () => {
        if (isShowSearchSuggestion) {
            return (0, jsx_runtime_1.jsx)(SearchSuggestion_1.SearchSuggestion, {});
        }
        if (isShowModalLoader) {
            return (0, jsx_runtime_1.jsx)(Loader_1.Loader, {});
        }
        if (isLoadingError) {
            return ((0, jsx_runtime_1.jsx)(ErrorMessage_1.ErrorMessage, { loadingErrorMsg: loadingErrorMsg, onRetry: handleRetry }));
        }
        if (isNoResult) {
            return (0, jsx_runtime_1.jsx)(NoData_1.NoData, {});
        }
        return ((0, jsx_runtime_1.jsx)(Tree_1.TreeList, { ...treeProps, ...treeListProps }));
    };
    return ((0, jsx_runtime_1.jsxs)(Dialog_1.Dialog, { ...modalProps, children: [(0, jsx_runtime_1.jsxs)(styles_1.StyledDialogContent, { "$size": modalProps.size, children: [(0, jsx_runtime_1.jsx)(styles_1.StyledSearchField, { fullWidth: true, ...searchFieldProps, isLoading: isShowSearchFieldLoader, helperText: constants_1.SEARCH_FIELD_HELPER_TEXT }), (0, jsx_runtime_1.jsx)(Paper_1.Paper, { variant: "outlined", children: (0, jsx_runtime_1.jsxs)(styles_1.TreeListWrapper, { children: [renderComponent(), isShowUserHint && ((0, jsx_runtime_1.jsx)(styles_1.UserHintWrapper, { children: (0, jsx_runtime_1.jsx)(Typography_1.Typography, { variant: "caption", color: "grey", colorIntensity: "600", children: "\u0423\u0442\u043E\u0447\u043D\u0438\u0442\u0435 \u0437\u0430\u043F\u0440\u043E\u0441 \u0434\u043B\u044F \u0431\u043E\u043B\u0435\u0435 \u043B\u0443\u0447\u0448\u0435\u0433\u043E \u0440\u0435\u0437\u0443\u043B\u044C\u0442\u0430\u0442\u0430 \u043F\u043E\u0438\u0441\u043A\u0430" }) }))] }) })] }), (0, jsx_runtime_1.jsxs)(DialogActions_1.DialogActions, { children: [(0, jsx_runtime_1.jsx)(Button_1.Button, { variant: "text", ...cancelButtonProps, children: "\u041E\u0442\u043C\u0435\u043D\u0430" }), (0, jsx_runtime_1.jsx)(Button_1.Button, { ...confirmButtonProps, children: "\u0412\u044B\u0431\u0440\u0430\u0442\u044C" })] })] }));
};
exports.OptionsModal = OptionsModal;
