import { useOverflowed } from '../hooks/useOverflowed';
import { truncateString } from '../utils';
export const useLogic = ({ forwardedRef, children, visibleLastSymbolsCount = 0, rowsCount = 1, }) => {
    const canSlice = Boolean(children && typeof children === 'string');
    const hasVisibleLastSymbols = canSlice && visibleLastSymbolsCount > 0;
    const hasMultipleRows = hasVisibleLastSymbols ? false : rowsCount > 1;
    const { ref, isOverflowed } = useOverflowed(forwardedRef, hasMultipleRows, hasVisibleLastSymbols);
    const { firstPartLabel, secondPartLabel } = hasVisibleLastSymbols && typeof children === 'string'
        ? truncateString(visibleLastSymbolsCount, children)
        : { firstPartLabel: '', secondPartLabel: '' };
    const tooltipTitle = isOverflowed && children;
    return {
        hasVisibleLastSymbols,
        ref,
        firstPartLabel,
        secondPartLabel,
        hasMultipleRows,
        tooltipTitle,
    };
};
