"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__, {
    HIGHLIGHT_PREFIX: ()=>external_iframe_parser_cjs_namespaceObject.HIGHLIGHT_PREFIX,
    QuickviewWordHighlight: ()=>QuickviewWordHighlight,
    getWordsHighlights: ()=>external_iframe_parser_cjs_namespaceObject.getWordsHighlights
});
const external_color_parser_cjs_namespaceObject = require("./color-parser.cjs");
const external_iframe_parser_cjs_namespaceObject = require("./iframe-parser.cjs");
class QuickviewWordHighlight {
    addElement(element) {
        this.elements.push(element);
    }
    get occurrences() {
        return this.elements.length;
    }
    navigateForward() {
        this.currentNavigationPosition++;
        if (this.currentNavigationPosition >= this.elements.length) this.currentNavigationPosition = 0;
        this.highlightNavigation();
        this.putElementIntoView();
        return this.elements[this.currentNavigationPosition];
    }
    navigateBackward() {
        this.currentNavigationPosition--;
        if (this.currentNavigationPosition < 0) this.currentNavigationPosition = this.elements.length - 1;
        this.highlightNavigation();
        this.putElementIntoView();
        return this.elements[this.currentNavigationPosition];
    }
    highlightNavigation() {
        const currentElement = this.elements[this.currentNavigationPosition];
        const otherElements = this.elements.filter((el)=>el !== currentElement);
        currentElement.style.color = this.color;
        currentElement.style.backgroundColor = this.focusedColor;
        otherElements.forEach((element)=>{
            element.style.color = '';
            element.style.backgroundColor = this.color;
        });
    }
    putElementIntoView() {
        const element = this.elements[this.currentNavigationPosition];
        element.scrollIntoView();
    }
    constructor(indexIdentifier, text, color, element){
        this.indexIdentifier = indexIdentifier;
        this.text = text;
        this.color = color;
        this.elements = [];
        this.currentNavigationPosition = -1;
        this.addElement(element);
        const colorParser = new external_color_parser_cjs_namespaceObject.ColorParser(color);
        this.focusedColor = colorParser.rgbInverted();
        this.previewBorderColor = colorParser.rgbSaturated();
    }
}
exports.HIGHLIGHT_PREFIX = __webpack_exports__.HIGHLIGHT_PREFIX;
exports.QuickviewWordHighlight = __webpack_exports__.QuickviewWordHighlight;
exports.getWordsHighlights = __webpack_exports__.getWordsHighlights;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "HIGHLIGHT_PREFIX",
    "QuickviewWordHighlight",
    "getWordsHighlights"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
