"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useLogic = void 0;
const react_1 = require("react");
const constants_1 = require("../../constants");
const useLogic = ({ item, renderItem, recentlyExpandedIds, }) => {
    const deleteRecentlyExpandedId = () => {
        item.meta.parentId &&
            recentlyExpandedIds.current?.delete(item.meta.parentId);
    };
    (0, react_1.useEffect)(() => {
        return () => {
            deleteRecentlyExpandedId();
        };
    }, []);
    const onAnimationEnd = () => {
        deleteRecentlyExpandedId();
    };
    const classname = (0, react_1.useMemo)(() => {
        if (item?.meta.parentId &&
            recentlyExpandedIds.current?.has(item?.meta.parentId)) {
            return constants_1.infiniteTreeListClassnames.addAnimation;
        }
        return '';
    }, [item.id]);
    return { item, renderItem, classname, onAnimationEnd };
};
exports.useLogic = useLogic;
