"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "TreeList", {
    enumerable: true,
    get: function() {
        return TreeList;
    }
});
const _react = /*#__PURE__*/ _interop_require_default(require("react"));
const _utils = require("../../../../utils");
const _Comboboxstyles = require("../../Combobox.styles");
const _Comboboxtokens = require("../../Combobox.tokens");
const _VirtualList = require("../VirtualList/VirtualList");
const _Item = require("./ui/Item/Item");
const _TreeListstyles = require("./TreeList.styles");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
const TreeList = ({ items, listMaxHeight, onScroll, virtual, beforeList, afterList, emptyStateDescription })=>{
    if (virtual) {
        return /*#__PURE__*/ _react.default.createElement(VirtualTreeList, {
            items: items,
            listMaxHeight: listMaxHeight,
            onScroll: onScroll,
            beforeList: beforeList,
            afterList: afterList,
            emptyStateDescription: emptyStateDescription
        });
    }
    return /*#__PURE__*/ _react.default.createElement(_TreeListstyles.ListWrapper, null, /*#__PURE__*/ _react.default.createElement(_TreeListstyles.ScrollContainer, {
        listMaxHeight: listMaxHeight,
        onScroll: onScroll
    }, beforeList, (0, _utils.isEmpty)(items) ? /*#__PURE__*/ _react.default.createElement(_Comboboxstyles.StyledEmptyState, {
        className: _Comboboxtokens.classes.emptyStateWrapper,
        description: emptyStateDescription || 'Ничего не найдено'
    }) : /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, items?.map((item, index)=>{
        return /*#__PURE__*/ _react.default.createElement(_Item.Item, {
            key: index,
            item: item,
            pathToItem: [
                index
            ]
        });
    })), afterList));
};
const VirtualTreeList = ({ items = [], listMaxHeight, onScroll, beforeList, afterList, emptyStateDescription })=>{
    return /*#__PURE__*/ _react.default.createElement(_TreeListstyles.ListWrapper, null, beforeList, (0, _utils.isEmpty)(items) ? /*#__PURE__*/ _react.default.createElement(_Comboboxstyles.StyledEmptyState, {
        className: _Comboboxtokens.classes.emptyStateWrapper,
        description: emptyStateDescription || 'Ничего не найдено'
    }) : /*#__PURE__*/ _react.default.createElement(_VirtualList.VirtualList, {
        items: items,
        listMaxHeight: listMaxHeight,
        onScroll: onScroll,
        renderItem: (item, index)=>/*#__PURE__*/ _react.default.createElement(_Item.Item, {
                item: item,
                pathToItem: [
                    index
                ]
            })
    }), afterList);
};
