import React from "react";
import { isEmpty } from "../../../../utils";
import { StyledEmptyState } from "../../Combobox.styles";
import { classes } from "../../Combobox.tokens";
import { VirtualList } from "../VirtualList/VirtualList";
import { Item } from "./ui/Item/Item";
import { ListWrapper, ScrollContainer } from "./TreeList.styles";
export const TreeList = ({ items, listMaxHeight, onScroll, virtual, beforeList, afterList, emptyStateDescription })=>{
    if (virtual) {
        return /*#__PURE__*/ React.createElement(VirtualTreeList, {
            items: items,
            listMaxHeight: listMaxHeight,
            onScroll: onScroll,
            beforeList: beforeList,
            afterList: afterList,
            emptyStateDescription: emptyStateDescription
        });
    }
    return /*#__PURE__*/ React.createElement(ListWrapper, null, /*#__PURE__*/ React.createElement(ScrollContainer, {
        listMaxHeight: listMaxHeight,
        onScroll: onScroll
    }, beforeList, isEmpty(items) ? /*#__PURE__*/ React.createElement(StyledEmptyState, {
        className: classes.emptyStateWrapper,
        description: emptyStateDescription || 'Ничего не найдено'
    }) : /*#__PURE__*/ React.createElement(React.Fragment, null, items?.map((item, index)=>{
        return /*#__PURE__*/ React.createElement(Item, {
            key: index,
            item: item,
            pathToItem: [
                index
            ]
        });
    })), afterList));
};
const VirtualTreeList = ({ items = [], listMaxHeight, onScroll, beforeList, afterList, emptyStateDescription })=>{
    return /*#__PURE__*/ React.createElement(ListWrapper, null, beforeList, isEmpty(items) ? /*#__PURE__*/ React.createElement(StyledEmptyState, {
        className: classes.emptyStateWrapper,
        description: emptyStateDescription || 'Ничего не найдено'
    }) : /*#__PURE__*/ React.createElement(VirtualList, {
        items: items,
        listMaxHeight: listMaxHeight,
        onScroll: onScroll,
        renderItem: (item, index)=>/*#__PURE__*/ React.createElement(Item, {
                item: item,
                pathToItem: [
                    index
                ]
            })
    }), afterList);
};
