import { useEffect, useMemo } from 'react';
import { infiniteTreeListClassnames } from '../../constants';
export const useLogic = ({ item, renderItem, recentlyExpandedIds, }) => {
    const deleteRecentlyExpandedId = () => {
        item.meta.parentId &&
            recentlyExpandedIds.current?.delete(item.meta.parentId);
    };
    useEffect(() => {
        return () => {
            deleteRecentlyExpandedId();
        };
    }, []);
    const onAnimationEnd = () => {
        deleteRecentlyExpandedId();
    };
    const classname = useMemo(() => {
        if (item?.meta.parentId &&
            recentlyExpandedIds.current?.has(item?.meta.parentId)) {
            return infiniteTreeListClassnames.addAnimation;
        }
        return '';
    }, [item.id]);
    return { item, renderItem, classname, onAnimationEnd };
};
