"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var use_create_ricos_toolbar_exports = {};
__export(use_create_ricos_toolbar_exports, {
  useCreateRicosToolbar: () => useCreateRicosToolbar
});
module.exports = __toCommonJS(use_create_ricos_toolbar_exports);
var import_react = require("react");
var import_ricos_context = require("./../../../ricos-context/index.js");
var import_ricos_modals = require("./../../../ricos-modals/index.js");
var import_ricos_toolbar = require("../../ricos-toolbar.js");
var import_toolbar_item_creator = require("../../toolbar-item-creator.js");
const useCreateRicosToolbar = (itemConfig) => {
  const { content } = (0, import_react.useContext)(import_ricos_context.RicosContext);
  const editorQuery = (0, import_react.useContext)(import_ricos_context.EditorQueryContext);
  const {
    adapter: { tiptapEditor },
    getPublicCommands
  } = (0, import_react.useContext)(import_ricos_context.EditorContext);
  const modalService = (0, import_ricos_modals.useModalService)();
  const toolbar = (0, import_react.useMemo)(() => {
    return import_ricos_toolbar.RicosToolbar.create({
      toolbarItemCreators: itemConfig.map((config) => import_toolbar_item_creator.ToolbarItemCreator.create(config)),
      content,
      tiptapEditor,
      editorQuery,
      modalService,
      publicCommands: getPublicCommands()
    });
  }, [itemConfig, content, tiptapEditor, modalService]);
  if (toolbar.shouldCreateToolbarItems()) {
    toolbar.createToolbarItems();
  }
  toolbar.update();
  return toolbar;
};
//# sourceMappingURL=use-create-ricos-toolbar.js.map
