import { useMemo } from 'react';
import { getFlattenColumns } from '../../utils';
export const useLogic = ({ sections, }) => {
    const leftColumns = sections.find((section) => section.position === 'left')?.columns;
    const rightColumns = sections.find((section) => section.position === 'right')?.columns;
    const pinnedContainerStyles = {
        '--left-columns-count': leftColumns
            ? getFlattenColumns(leftColumns).length
            : 0,
        '--right-columns-count': rightColumns
            ? getFlattenColumns(rightColumns).length
            : 0,
    };
    const sectionOffsets = useMemo(() => {
        const offsets = {};
        let currentOffset = 0;
        sections.forEach((section) => {
            offsets[section.position] = currentOffset;
            currentOffset += getFlattenColumns(section.columns).length;
        });
        return offsets;
    }, [sections]);
    return { pinnedContainerStyles, sectionOffsets };
};
