"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__, {
    useMarkdownShortcuts: ()=>useMarkdownShortcuts
});
const external_react_namespaceObject = require("react");
const index_cjs_namespaceObject = require("./markdown-formatting/index.cjs");
function useMarkdownShortcuts(textAreaRef, onFormat) {
    return (0, external_react_namespaceObject.useCallback)((e)=>{
        const textarea = textAreaRef.current;
        if (!textarea) return;
        const metaOrCtrl = e.metaKey || e.ctrlKey;
        if (!metaOrCtrl) return;
        let formatFn = null;
        if ('b' !== e.key || e.shiftKey) if ('i' !== e.key || e.shiftKey) {
            if ('x' === e.key && e.shiftKey) formatFn = index_cjs_namespaceObject.toggleStrikethrough;
        } else formatFn = index_cjs_namespaceObject.toggleItalic;
        else formatFn = index_cjs_namespaceObject.toggleBold;
        if (formatFn) {
            e.preventDefault();
            const input = {
                value: textarea.value,
                selectionStart: textarea.selectionStart,
                selectionEnd: textarea.selectionEnd
            };
            onFormat(formatFn(input));
        }
    }, [
        textAreaRef,
        onFormat
    ]);
}
exports.useMarkdownShortcuts = __webpack_exports__.useMarkdownShortcuts;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "useMarkdownShortcuts"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
