"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__, {
    getItemDisplayClasses: ()=>getItemDisplayClasses,
    getItemLayoutClasses: ()=>getItemLayoutClasses,
    getItemListDisplayClasses: ()=>getItemListDisplayClasses
});
const external_item_layout_sections_cjs_namespaceObject = require("./item-layout-sections.cjs");
function getDisplayClass(display) {
    switch(display){
        case 'grid':
            return 'display-grid';
        case 'table':
            return 'display-table';
        default:
            return 'display-list';
    }
}
function getDensityClass(density) {
    switch(density){
        case 'comfortable':
            return 'density-comfortable';
        case 'compact':
            return 'density-compact';
        default:
            return 'density-normal';
    }
}
function getImageClass(image) {
    switch(image){
        case 'large':
            return 'image-large';
        case 'small':
            return 'image-small';
        case 'none':
            return 'image-none';
        default:
            return 'image-icon';
    }
}
function getItemListDisplayClasses(display, density, image, isLoading, isAppLoading) {
    const classes = getItemDisplayClasses(display, density, image);
    if (isLoading) classes.push('loading');
    if (isAppLoading) classes.push('placeholder');
    return classes.join(' ');
}
function getItemDisplayClasses(display, density, image) {
    const classes = [
        getDisplayClass(display),
        getDensityClass(density),
        getImageClass(image)
    ];
    return classes;
}
function getSection(children, section) {
    return Array.from(children).find((element)=>element.tagName.toLowerCase() === section);
}
function getImageSizeFromSections(children) {
    const imageSize = getSection(children, 'atomic-result-section-visual')?.getAttribute('image-size');
    if (!imageSize) return;
    return imageSize;
}
function getItemLayoutClasses(config, HTMLContent) {
    const classes = getItemDisplayClasses(config.display, config.density, getImageSizeFromSections(config.children) ?? config.imageSize);
    if (HTMLContent ? (0, external_item_layout_sections_cjs_namespaceObject.containsSections)(HTMLContent) : (0, external_item_layout_sections_cjs_namespaceObject.containsSections)(config.children)) classes.push('with-sections');
    return classes;
}
exports.getItemDisplayClasses = __webpack_exports__.getItemDisplayClasses;
exports.getItemLayoutClasses = __webpack_exports__.getItemLayoutClasses;
exports.getItemListDisplayClasses = __webpack_exports__.getItemListDisplayClasses;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "getItemDisplayClasses",
    "getItemLayoutClasses",
    "getItemListDisplayClasses"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
