'use strict';

var React = require('react');
var Typography = require('./Typography-cjs.js');
var Button = require('./Button-cjs.js');
require('classnames');

var styles = {"header":"nrNh3feibg8-","spinning":"rcoGBsZN55M-"};

function ComboboxContentHeader(props) {
    const hasSelected = props.selectedCount > 0;
    const actionLabel = hasSelected ? "Clear" : "Select all";
    const label = getLabel(hasSelected, props.selectedCount, props.subjectNoun);
    const handleSelectAll = hasSelected ? props.onClearAll : props.onSelectAll;
    const showAction = hasSelected || props.hasOptionsVisible;
    return (React.createElement("div", { className: styles.header, "data-testid": "ATL-Combobox-Header" },
        React.createElement(Typography.Typography, { textColor: "heading", fontWeight: "semiBold" }, label),
        showAction && (React.createElement(Button.Button, { size: "small", label: actionLabel, type: "tertiary", onClick: handleSelectAll }))));
}
function getLabel(hasSelected, count, subjectNoun) {
    if (hasSelected) {
        return `${count} selected`;
    }
    if (subjectNoun) {
        return `Select ${subjectNoun}`;
    }
    return "Select";
}

exports.ComboboxContentHeader = ComboboxContentHeader;
