import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Button } from '../../Button';
import { Dialog } from '../../Dialog';
import { DialogActions } from '../../DialogActions';
import { Paper } from '../../Paper';
import { TreeList } from '../../Tree';
import { Typography } from '../../Typography';
import { SEARCH_FIELD_HELPER_TEXT } from './constants';
import { ErrorMessage } from './ErrorMessage';
import { Loader } from './Loader';
import { NoData } from './NoData';
import { SearchSuggestion } from './SearchSuggestion';
import { StyledDialogContent, StyledSearchField, TreeListWrapper, UserHintWrapper, } from './styles';
import { useLogic } from './useLogic';
export const OptionsModal = (props) => {
    const { isNoResult, searchFieldProps, modalProps, treeListProps, cancelButtonProps, confirmButtonProps, handleRetry, isShowUserHint, isShowModalLoader, isShowSearchFieldLoader, isShowSearchSuggestion, isLoadingError, treeProps, loadingErrorMsg, } = useLogic(props);
    const renderComponent = () => {
        if (isShowSearchSuggestion) {
            return _jsx(SearchSuggestion, {});
        }
        if (isShowModalLoader) {
            return _jsx(Loader, {});
        }
        if (isLoadingError) {
            return (_jsx(ErrorMessage, { loadingErrorMsg: loadingErrorMsg, onRetry: handleRetry }));
        }
        if (isNoResult) {
            return _jsx(NoData, {});
        }
        return (_jsx(TreeList, { ...treeProps, ...treeListProps }));
    };
    return (_jsxs(Dialog, { ...modalProps, children: [_jsxs(StyledDialogContent, { "$size": modalProps.size, children: [_jsx(StyledSearchField, { fullWidth: true, ...searchFieldProps, isLoading: isShowSearchFieldLoader, helperText: SEARCH_FIELD_HELPER_TEXT }), _jsx(Paper, { variant: "outlined", children: _jsxs(TreeListWrapper, { children: [renderComponent(), isShowUserHint && (_jsx(UserHintWrapper, { children: _jsx(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" }) }))] }) })] }), _jsxs(DialogActions, { children: [_jsx(Button, { variant: "text", ...cancelButtonProps, children: "\u041E\u0442\u043C\u0435\u043D\u0430" }), _jsx(Button, { ...confirmButtonProps, children: "\u0412\u044B\u0431\u0440\u0430\u0442\u044C" })] })] }));
};
