'use strict';

var React = require('react');
var DataListSort = require('./DataListSort-cjs.js');
var DataListOverflowFade = require('./DataListOverflowFade-cjs.js');
var DataListContext = require('./DataListContext-cjs.js');
var DataList_utils = require('./DataList.utils-cjs.js');
var useResponsiveSizing = require('./useResponsiveSizing-cjs.js');

function useShowHeader() {
    const { headerVisibility } = DataListContext.useDataListContext();
    if (headerVisibility === undefined)
        return true;
    const sizes = useResponsiveSizing.useResponsiveSizing();
    const sizeKeys = Object.keys(sizes);
    const showHeader = sizeKeys.reduce((previous, breakpoint) => {
        const isHeaderVisible = headerVisibility[breakpoint] || false;
        const isBreakpointTriggered = sizes[breakpoint];
        return previous || (isBreakpointTriggered && isHeaderVisible);
    }, false);
    return showHeader;
}

// This component is meant to capture the props of the DataList.Filters
// eslint-disable-next-line @typescript-eslint/no-unused-vars
function DataListFilters(_) {
    return null;
}
/**
 * Renders the DataList.Filters component
 */
function InternalDataListFilters() {
    const { children: parentChildren } = DataListContext.useDataListContext();
    const showHeader = useShowHeader();
    const showSortButton = !showHeader;
    const component = DataList_utils.getCompoundComponent(parentChildren, DataListFilters);
    if (!showSortButton && !component)
        return null;
    const children = component === null || component === void 0 ? void 0 : component.props.children;
    return (React.createElement(DataListOverflowFade.DataListOverflowFade, null,
        children && children,
        showSortButton && React.createElement(DataListSort.DataListSort, null)));
}

exports.DataListFilters = DataListFilters;
exports.InternalDataListFilters = InternalDataListFilters;
