'use strict';

var useResponsiveSizing = require('./useResponsiveSizing-cjs.js');
var DataListContext = require('./DataListContext-cjs.js');

function useActiveLayout() {
    const { layoutBreakpoints, layouts } = DataListContext.useDataListContext();
    const breakpoints = useResponsiveSizing.useResponsiveSizing();
    const reversedLayoutBreakpoints = [...layoutBreakpoints].reverse();
    const activeBreakpoint = reversedLayoutBreakpoints.find(key => breakpoints[key]) ||
        layoutBreakpoints[0];
    const layout = layouts[activeBreakpoint];
    return { layout, activeBreakpoint };
}

exports.useActiveLayout = useActiveLayout;
