import { html, nothing } from "lit";
import { when } from "lit/directives/when.js";
import arrow_bottom_rounded from "../../../../images/arrow-bottom-rounded.js";
import arrow_top_rounded from "../../../../images/arrow-top-rounded.js";
import images_close from "../../../../images/close.js";
import "../../atomic-icon/atomic-icon.js";
import { renderButton } from "../../button.js";
import { renderHeading } from "../../heading.js";
const renderFacetHeader = ({ props })=>{
    const label = props.i18n.t(props.label);
    const expandFacet = props.i18n.t('expand-facet', {
        label
    });
    const collapseFacet = props.i18n.t('collapse-facet', {
        label
    });
    const clearFilters = props.i18n.t('clear-filters', {
        count: props.numberOfActiveValues
    });
    const clearFiltersForFacet = props.i18n.t('clear-filters-for-facet', {
        count: props.numberOfActiveValues,
        label
    });
    return html`
    ${renderButton({
        props: {
            part: 'label-button',
            style: 'text-transparent',
            class: 'flex w-full justify-between rounded-none px-2 py-1 text-lg font-bold',
            ariaLabel: props.isCollapsed ? expandFacet : collapseFacet,
            onClick: props.onToggleCollapse,
            ariaExpanded: props.isCollapsed ? 'false' : 'true',
            ref: (el)=>props.headerRef?.(el)
        }
    })(html`${renderHeading({
        props: {
            level: props.headingLevel,
            class: 'truncate'
        }
    })(html`${label}`)}
        <atomic-icon
          part="label-button-icon"
          class="ml-4 w-3 shrink-0 self-center"
          .icon=${props.isCollapsed ? arrow_bottom_rounded : arrow_top_rounded}
        ></atomic-icon>`)}
    ${when(props.onClearFilters && props.numberOfActiveValues > 0, ()=>html`${renderButton({
            props: {
                part: 'clear-button',
                style: 'text-primary',
                class: 'flex max-w-full items-baseline p-2 text-sm',
                ariaLabel: clearFiltersForFacet,
                onClick: props.onClearFilters
            }
        })(html`<atomic-icon
              part="clear-button-icon"
              class="mr-1 h-2 w-2"
              .icon=${images_close}
            ></atomic-icon>
            <span>${clearFilters}</span>`)}`, ()=>nothing)}
  `;
};
export { renderFacetHeader };
