"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__, {
    collapseFacetsAfter: ()=>collapseFacetsAfter,
    getAutomaticFacetGenerator: ()=>getAutomaticFacetGenerator,
    getFacetsInChildren: ()=>getFacetsInChildren,
    isAutomaticFacetGenerator: ()=>isAutomaticFacetGenerator,
    shouldDisplayInputForFacetRange: ()=>shouldDisplayInputForFacetRange,
    sortFacetVisibility: ()=>sortFacetVisibility,
    triageFacetsByParents: ()=>triageFacetsByParents
});
function shouldDisplayInputForFacetRange(facetRange) {
    const { hasInput, hasInputRange, searchStatusState, facetValues } = facetRange;
    if (!hasInput) return false;
    if (hasInputRange) return true;
    if (!searchStatusState.hasResults) return false;
    const onlyValuesWithResultsOrActive = facetValues.filter((value)=>value.numberOfResults || 'idle' !== value.state) || [];
    if (!onlyValuesWithResultsOrActive.length) return false;
    return true;
}
function sortFacetVisibility(facetElements, facetInfoMap) {
    const visibleFacets = [];
    const invisibleFacets = [];
    facetElements.forEach((facet)=>{
        if (facetInfoMap[facet.facetId] && facetInfoMap[facet.facetId].isHidden()) invisibleFacets.push(facet);
        else visibleFacets.push(facet);
    });
    return {
        visibleFacets,
        invisibleFacets
    };
}
function collapseFacetsAfter(facets, visibleFacetsCount) {
    if (-1 === visibleFacetsCount) return;
    facets.forEach((facet, index)=>{
        facet.isCollapsed = index + 1 > visibleFacetsCount;
    });
}
function isAutomaticFacetGenerator(element) {
    return 'ATOMIC-AUTOMATIC-FACET-GENERATOR' === element.tagName;
}
function isPseudoFacet(el) {
    return 'facetId' in el;
}
function getFacetsInChildren(parent) {
    const facets = Array.from(parent.children).filter((child)=>isPseudoFacet(child));
    return facets;
}
function getAutomaticFacetGenerator(parent) {
    return Array.from(parent.children).find(isAutomaticFacetGenerator);
}
function findFacetParent(facet, parents) {
    for(let i = 0; i < parents.length; i++)if (parents[i]?.contains(facet)) return parents[i];
    return null;
}
function triageFacetsByParents(facets, ...parents) {
    const sortedFacets = new Map(parents.concat([
        null
    ]).map((parent)=>[
            parent,
            []
        ]));
    for (const facet of facets){
        const parent = findFacetParent(facet, parents);
        sortedFacets.get(parent).push(facet);
    }
    return sortedFacets;
}
exports.collapseFacetsAfter = __webpack_exports__.collapseFacetsAfter;
exports.getAutomaticFacetGenerator = __webpack_exports__.getAutomaticFacetGenerator;
exports.getFacetsInChildren = __webpack_exports__.getFacetsInChildren;
exports.isAutomaticFacetGenerator = __webpack_exports__.isAutomaticFacetGenerator;
exports.shouldDisplayInputForFacetRange = __webpack_exports__.shouldDisplayInputForFacetRange;
exports.sortFacetVisibility = __webpack_exports__.sortFacetVisibility;
exports.triageFacetsByParents = __webpack_exports__.triageFacetsByParents;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "collapseFacetsAfter",
    "getAutomaticFacetGenerator",
    "getFacetsInChildren",
    "isAutomaticFacetGenerator",
    "shouldDisplayInputForFacetRange",
    "sortFacetVisibility",
    "triageFacetsByParents"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
