"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MToolbarFilePopup = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const commands_1 = require("../../../markup/commands/index.js");
const ToolbarFilePopup_1 = require("../custom/ToolbarFilePopup.js");
const context_1 = require("./context.js");
const MToolbarFilePopup = ({ focus, onClick, hide, anchorElement, editor, className, }) => {
    const { uploadHandler } = (0, context_1.useMarkupToolbarContext)();
    return ((0, jsx_runtime_1.jsx)(ToolbarFilePopup_1.ToolbarFilePopup, { hide: hide, focus: focus, onClick: onClick, anchorElement: anchorElement, className: className, onSubmit: (fileParams) => (0, commands_1.insertFiles)([fileParams])(editor.cm), uploadHandler: uploadHandler, onSuccessUpload: (res) => {
            (0, commands_1.insertFiles)(res.success.map(({ result, file }) => ({
                src: result.url,
                name: result.name ?? file.name,
                type: result.type ?? file.type,
            })))(editor.cm);
        } }));
};
exports.MToolbarFilePopup = MToolbarFilePopup;
//# sourceMappingURL=MToolbarFilePopup.js.map
