import { jsx as _jsx } from "@emotion/react/jsx-runtime";
import { useContext, useCallback, } from 'react';
import { EngineContext } from '../../../../providers';
import { EventType } from '../../../../../events';
import { Tree as BaseTree } from '../../../../components';
export const Tree = ({ className, treeData, inspectedKey, selectedPaths, persistentStorageKey, draggable, onDrop, childrenFieldMap, }) => {
    const { world } = useContext(EngineContext);
    const handleSelect = useCallback((paths) => {
        world.dispatchEvent(EventType.SelectEntities, { paths });
    }, [world]);
    const handleInspect = useCallback((path) => {
        world.dispatchEvent(EventType.InspectEntity, { path });
    }, [world]);
    const handleClickOutside = useCallback(() => {
        world.dispatchEvent(EventType.SelectEntities, { paths: [] });
        world.dispatchEvent(EventType.InspectEntity, { path: undefined });
    }, [world]);
    return (_jsx(BaseTree, { className: className, inspectedKey: inspectedKey, selectedPaths: selectedPaths, onSelect: handleSelect, onInspect: handleInspect, onDrop: onDrop, onClickOutside: handleClickOutside, treeData: treeData, draggable: draggable, persistentStorageKey: persistentStorageKey, childrenFieldMap: childrenFieldMap }));
};
