"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__, {
    buildQuickviewPreviewBar: ()=>buildQuickviewPreviewBar
});
const buildQuickviewPreviewBar = (words, highlightKeywords, iframe)=>{
    if (!iframe) return;
    const documentWriter = iframe.contentDocument;
    if (!documentWriter) return;
    const bar = buildPreviewBar(documentWriter);
    if (highlightKeywords.highlightNone) return void bar.remove();
    const docHeight = documentWriter.body.scrollHeight;
    Object.values(words).forEach((word)=>{
        word.elements.forEach((wordElement)=>{
            const previewUnit = buildPreviewUnit(documentWriter, word, wordElement, docHeight, highlightKeywords);
            bar.appendChild(previewUnit);
        });
    });
    documentWriter.body.appendChild(bar);
};
const buildPreviewBar = (documentWriter)=>{
    const previewBarId = 'CoveoPreviewBar';
    const bar = documentWriter.getElementById(previewBarId) || documentWriter.createElement('div');
    bar.id = previewBarId;
    bar.innerHTML = '';
    bar.style.position = 'fixed';
    bar.style.top = '0';
    bar.style.right = '0';
    bar.style.width = '15px';
    bar.style.height = '100%';
    bar.setAttribute('aria-hidden', 'true');
    return bar;
};
const buildPreviewUnit = (documentWriter, word, wordElement, docHeight, highlightKeywords)=>{
    const previewUnit = documentWriter.createElement('div');
    if (highlightKeywords.keywords[word.text]?.enabled === false) {
        previewUnit.style.display = 'none';
        return previewUnit;
    }
    const elementPosition = wordElement.getBoundingClientRect().top;
    previewUnit.style.position = 'absolute';
    previewUnit.style.top = `${elementPosition / docHeight * 100}%`;
    previewUnit.style.width = '100%';
    previewUnit.style.height = '1px';
    previewUnit.style.border = `1px solid ${word.previewBorderColor}`;
    previewUnit.style.backgroundColor = word.color;
    return previewUnit;
};
exports.buildQuickviewPreviewBar = __webpack_exports__.buildQuickviewPreviewBar;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "buildQuickviewPreviewBar"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
