import { useTheme } from '../../../theme/hooks/useTheme';
import { getTypeInfo } from '../utils';
export const useLogic = ({ value, keyPath, checkExpanded, toggleExpanded, ...props }) => {
    const theme = useTheme();
    const { type, icon, color } = getTypeInfo(value, theme);
    const isExpandable = type === 'object' || type === 'array';
    const isExpanded = checkExpanded(keyPath);
    const getNestedKeyPath = (key) => {
        return `${keyPath}.${key}`;
    };
    const handleToggle = () => {
        if (isExpandable) {
            toggleExpanded(keyPath);
        }
    };
    return {
        icon,
        type,
        color,
        isExpandable,
        isExpanded,
        value,
        handleToggle,
        toggleExpanded,
        checkExpanded,
        getNestedKeyPath,
        ...props,
    };
};
