"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__, {
    detectActiveFormats: ()=>detectActiveFormats,
    activeFormatsEqual: ()=>activeFormatsEqual
});
const external_listFormatting_cjs_namespaceObject = require("./listFormatting.cjs");
function activeFormatsEqual(a, b) {
    return a.bold === b.bold && a.italic === b.italic && a.strikethrough === b.strikethrough && a.bulletList === b.bulletList && a.numberedList === b.numberedList;
}
function detectActiveFormats(input) {
    const { value, selectionStart } = input;
    const lineStart = value.lastIndexOf('\n', selectionStart - 1) + 1;
    let lineEnd = value.indexOf('\n', selectionStart);
    if (-1 === lineEnd) lineEnd = value.length;
    const currentLine = value.slice(lineStart, lineEnd);
    const cursorInLine = selectionStart - lineStart;
    const textBefore = currentLine.slice(0, cursorInLine);
    const textAfter = currentLine.slice(cursorInLine);
    const bold = /\*\*(?:[^*\n]|\*(?!\*))*$/.test(textBefore) && /^(?:[^*\n]|\*(?!\*))*\*\*/.test(textAfter);
    const strikethrough = /~~[^~\n]*$/.test(textBefore) && /^[^~\n]*~~/.test(textAfter);
    const italicBefore = /(?<!\*)\*(?!\*)(?:[^*\n]|\*\*)*$/.test(textBefore);
    const italicAfter = /^(?:[^*\n]|\*\*)*(?<!\*)\*(?!\*)/.test(textAfter);
    let italic = italicBefore && italicAfter;
    if (!italic && bold) {
        const beforeStars = /(\*{3,})[^*\n]*$/.exec(textBefore);
        const afterStars = /^[^*\n]*(\*{3,})/.exec(textAfter);
        if (beforeStars && afterStars && beforeStars[1].length % 2 === 1 && afterStars[1].length % 2 === 1) italic = true;
    }
    return {
        bold,
        italic,
        strikethrough,
        bulletList: external_listFormatting_cjs_namespaceObject.BULLET_PREFIX.test(currentLine),
        numberedList: external_listFormatting_cjs_namespaceObject.NUMBERED_PREFIX.test(currentLine)
    };
}
exports.activeFormatsEqual = __webpack_exports__.activeFormatsEqual;
exports.detectActiveFormats = __webpack_exports__.detectActiveFormats;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "activeFormatsEqual",
    "detectActiveFormats"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
