"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__, {
    formatHumanReadable: ()=>formatHumanReadable,
    formatNumberLocalized: ()=>formatNumberLocalized
});
const field_utils_cjs_namespaceObject = require("../../../../utils/field-utils.cjs");
const formatHumanReadable = ({ manualRanges, field, i18n, facetValue, logger, formatter })=>{
    const manualRangeLabel = manualRanges.find((range)=>areRangesEqual(range, facetValue))?.label;
    return manualRangeLabel ? (0, field_utils_cjs_namespaceObject.getFieldValueCaption)(field, manualRangeLabel, i18n) : i18n.t('to', {
        start: formatNumberLocalized(facetValue.start, i18n, logger, formatter),
        end: formatNumberLocalized(facetValue.end, i18n, logger, formatter)
    });
};
const formatNumberLocalized = (value, i18n, logger, formatter)=>{
    try {
        return formatter(value, i18n.languages);
    } catch (error) {
        logger.error(`atomic-numeric-facet facet value "${value}" could not be formatted correctly.`, error);
        return value;
    }
};
const areRangesEqual = (firstRange, secondRange)=>firstRange.start === secondRange.start && firstRange.end === secondRange.end && firstRange.endInclusive === secondRange.endInclusive;
exports.formatHumanReadable = __webpack_exports__.formatHumanReadable;
exports.formatNumberLocalized = __webpack_exports__.formatNumberLocalized;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "formatHumanReadable",
    "formatNumberLocalized"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
