"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__, {
    FormattingToolbar: ()=>FormattingToolbar
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_index_cjs_namespaceObject = require("../../index.cjs");
const external_react_namespaceObject = require("react");
const index_cjs_namespaceObject = require("../../../i18n/index.cjs");
const external_CanvasTooltip_cjs_namespaceObject = require("../CanvasTooltip.cjs");
const external_markdown_formatting_index_cjs_namespaceObject = require("./markdown-formatting/index.cjs");
const external_StickyNoteNode_styles_cjs_namespaceObject = require("./StickyNoteNode.styles.cjs");
const external_StickyNoteNode_utils_cjs_namespaceObject = require("./StickyNoteNode.utils.cjs");
const FormattingToolbarComponent = ({ textAreaRef, borderColor, activeFormats, onFormat })=>{
    const { _ } = (0, index_cjs_namespaceObject.useSafeLingui)();
    const mod = (0, external_StickyNoteNode_utils_cjs_namespaceObject.getModifierKey)();
    const shift = (0, external_StickyNoteNode_utils_cjs_namespaceObject.isMac)() ? '⇧' : '+Shift+';
    const applyFormat = (0, external_react_namespaceObject.useCallback)((formatFn)=>{
        const textarea = textAreaRef.current;
        if (!textarea) return;
        const input = {
            value: textarea.value,
            selectionStart: textarea.selectionStart,
            selectionEnd: textarea.selectionEnd
        };
        onFormat(formatFn(input));
        textarea.focus();
    }, [
        textAreaRef,
        onFormat
    ]);
    const handleBold = (0, external_react_namespaceObject.useCallback)(()=>applyFormat(external_markdown_formatting_index_cjs_namespaceObject.toggleBold), [
        applyFormat
    ]);
    const handleItalic = (0, external_react_namespaceObject.useCallback)(()=>applyFormat(external_markdown_formatting_index_cjs_namespaceObject.toggleItalic), [
        applyFormat
    ]);
    const handleStrikethrough = (0, external_react_namespaceObject.useCallback)(()=>applyFormat(external_markdown_formatting_index_cjs_namespaceObject.toggleStrikethrough), [
        applyFormat
    ]);
    const handleBulletList = (0, external_react_namespaceObject.useCallback)(()=>applyFormat(external_markdown_formatting_index_cjs_namespaceObject.toggleBulletList), [
        applyFormat
    ]);
    const handleNumberedList = (0, external_react_namespaceObject.useCallback)(()=>applyFormat(external_markdown_formatting_index_cjs_namespaceObject.toggleNumberedList), [
        applyFormat
    ]);
    const boldLabel = _({
        id: 'sticky-note.formatting.bold',
        message: 'Bold ({boldShortcut})',
        values: {
            boldShortcut: `${mod}+B`
        }
    });
    const italicLabel = _({
        id: 'sticky-note.formatting.italic',
        message: 'Italic ({italicShortcut})',
        values: {
            italicShortcut: `${mod}+I`
        }
    });
    const strikethroughLabel = _({
        id: 'sticky-note.formatting.strikethrough',
        message: 'Strikethrough ({strikethroughShortcut})',
        values: {
            strikethroughShortcut: `${mod}${shift}X`
        }
    });
    const bulletListLabel = _({
        id: 'sticky-note.formatting.bullet-list',
        message: 'Bullet list'
    });
    const numberedListLabel = _({
        id: 'sticky-note.formatting.numbered-list',
        message: 'Numbered list'
    });
    const toolbarLabel = _({
        id: 'sticky-note.formatting.toolbar',
        message: 'Text formatting'
    });
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingToolbarContainer, {
        role: "toolbar",
        "aria-label": toolbarLabel,
        borderColor: borderColor,
        onMouseDown: (e)=>e.preventDefault(),
        className: "nodrag nowheel",
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
                content: boldLabel,
                placement: "top",
                delay: true,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
                    isActive: activeFormats.bold,
                    onClick: handleBold,
                    "aria-label": boldLabel,
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
                        icon: "bold",
                        size: 14
                    })
                })
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
                content: italicLabel,
                placement: "top",
                delay: true,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
                    isActive: activeFormats.italic,
                    onClick: handleItalic,
                    "aria-label": italicLabel,
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
                        icon: "italic",
                        size: 14
                    })
                })
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
                content: strikethroughLabel,
                placement: "top",
                delay: true,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
                    isActive: activeFormats.strikethrough,
                    onClick: handleStrikethrough,
                    "aria-label": strikethroughLabel,
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
                        icon: "strikethrough",
                        size: 14
                    })
                })
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.ToolbarSeparator, {}),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
                content: bulletListLabel,
                placement: "top",
                delay: true,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
                    isActive: activeFormats.bulletList,
                    onClick: handleBulletList,
                    "aria-label": bulletListLabel,
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
                        icon: "list",
                        size: 14
                    })
                })
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
                content: numberedListLabel,
                placement: "top",
                delay: true,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_StickyNoteNode_styles_cjs_namespaceObject.FormattingButton, {
                    isActive: activeFormats.numberedList,
                    onClick: handleNumberedList,
                    "aria-label": numberedListLabel,
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
                        icon: "list-ordered",
                        size: 14
                    })
                })
            })
        ]
    });
};
const FormattingToolbar = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(FormattingToolbarComponent);
exports.FormattingToolbar = __webpack_exports__.FormattingToolbar;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "FormattingToolbar"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
