import { jsx as _jsx } from "react/jsx-runtime";
import { TreeItem as BaseTreeItem } from '../../TreeItem';
import { List } from './styles';
import { useLogic } from './useLogic';
export const TreeItem = (props) => {
    const { isSelected, isDefaultExpanded, isDisabled, disabledReason, nextLevel, handleChange, } = useLogic(props);
    const { item, prefixId, level, renderItem, value, isInitialExpanded, expandedLevel, chainToSelectedItem, disabledItems, onChange, isObjectMode, } = props;
    const { id, label, note, children = [], options } = item;
    if (children.length) {
        return (_jsx(BaseTreeItem, { id: id, prefixId: prefixId, isSelected: isSelected, isDefaultExpanded: isDefaultExpanded, isForceExpanded: options?.isForceExpanded, isDisabled: isDisabled, disabledReason: disabledReason, component: "li", label: label, renderItem: renderItem, note: note, level: level, onClick: handleChange, children: _jsx(List, { children: children.map((child) => (_jsx(TreeItem, { item: child, prefixId: prefixId, renderItem: renderItem, level: nextLevel, isInitialExpanded: isInitialExpanded, expandedLevel: expandedLevel, chainToSelectedItem: chainToSelectedItem, disabledItems: disabledItems, value: value, onChange: onChange, isObjectMode: isObjectMode }, child.id))) }) }));
    }
    return (_jsx(BaseTreeItem, { id: id, prefixId: prefixId, isSelected: isSelected, isDisabled: isDisabled, disabledReason: disabledReason, component: "li", label: label, renderItem: renderItem, note: note, level: level, onClick: handleChange }));
};
