"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    renderFacetValueCheckbox: ()=>renderFacetValueCheckbox
});
const external_lit_namespaceObject = require("lit");
const keyed_js_namespaceObject = require("lit/directives/keyed.js");
const ref_js_namespaceObject = require("lit/directives/ref.js");
const ripple_utils_cjs_namespaceObject = require("../../../../utils/ripple-utils.cjs");
const utils_cjs_namespaceObject = require("../../../../utils/utils.cjs");
const external_checkbox_cjs_namespaceObject = require("../../checkbox.cjs");
const external_triStateCheckbox_cjs_namespaceObject = require("../../triStateCheckbox.cjs");
const facet_value_exclude_cjs_namespaceObject = require("../facet-value-exclude/facet-value-exclude.cjs");
const renderFacetValueCheckbox = ({ props })=>(children)=>{
        const id = (0, utils_cjs_namespaceObject.randomID)('facet-value-');
        const count = props.numberOfResults.toLocaleString(props.i18n.language);
        const ariaLabelAttributes = {
            value: props.displayValue,
            count: props.numberOfResults,
            formattedCount: count,
            interpolation: {
                escapeValue: false
            }
        };
        const selectedAriaLabel = props.i18n.t('facet-value', ariaLabelAttributes);
        const excludedAriaLabel = props.i18n.t('facet-value-exclude', ariaLabelAttributes);
        let labelRef;
        const isTriStateCheckbox = (props)=>'state' in props && 'isSelected' in props;
        const renderCheckbox = ()=>{
            const attributes = {
                id,
                onToggle: ()=>props.onClick(),
                part: 'value-checkbox',
                class: 'value-checkbox',
                ariaLabel: selectedAriaLabel,
                ref: props.buttonRef,
                onMouseDown: (e)=>(0, ripple_utils_cjs_namespaceObject.createRipple)(e, {
                        color: 'neutral',
                        parent: labelRef
                    }),
                iconPart: 'value-checkbox-icon'
            };
            if (isTriStateCheckbox(props)) return (0, external_triStateCheckbox_cjs_namespaceObject.renderTriStateCheckbox)({
                props: {
                    ...attributes,
                    state: props.state
                }
            });
            return (0, external_checkbox_cjs_namespaceObject.renderCheckbox)({
                props: {
                    ...attributes,
                    checked: props.isSelected
                }
            });
        };
        const renderExclusion = ()=>{
            if (isTriStateCheckbox(props)) return (0, facet_value_exclude_cjs_namespaceObject.renderFacetValueExclude)({
                props: {
                    onClick: ()=>props.onExclude?.(),
                    ariaLabel: excludedAriaLabel
                }
            });
        };
        return (0, external_lit_namespaceObject.html)`
      ${(0, keyed_js_namespaceObject.keyed)(props.displayValue, (0, external_lit_namespaceObject.html)`<li class="group relative flex items-center">
          ${renderCheckbox()}
          <label
            ${(0, ref_js_namespaceObject.ref)((ref)=>{
            labelRef = ref;
        })}
            .htmlFor=${id}
            part="value-checkbox-label"
            class="items-center"
            @mousedown=${(e)=>(0, ripple_utils_cjs_namespaceObject.createRipple)(e, {
                color: 'neutral'
            })}
            aria-hidden="true"
          >
            ${children}
            <span part="value-count" class="value-count">
              ${props.i18n.t('between-parentheses', {
            text: count
        })}
            </span>
          </label>
          ${renderExclusion()}
        </li>`)}
    `;
    };
exports.renderFacetValueCheckbox = __webpack_exports__.renderFacetValueCheckbox;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "renderFacetValueCheckbox"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
