"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 get_toolbar_buttons_exports = {};
__export(get_toolbar_buttons_exports, {
  getToolbarButtons: () => getToolbarButtons
});
module.exports = __toCommonJS(get_toolbar_buttons_exports);
var import_consts = require("./../ricos-content/consts.js");
var import_create_delete_button = require("./../_shared/plugin-toolbar/create-delete-button.js");
var import_create_node_alignment_button = require("./../_shared/plugin-toolbar/create-node-alignment-button.js");
var import_create_replace_button = require("./../_shared/plugin-toolbar/create-replace-button.js");
var import_create_node_size_button = require("./../_shared/plugin-toolbar/node-size-button/create-node-size-button.js");
var import_create_separator = require("./../_shared/plugin-toolbar/separator/create-separator.js");
var import_is_visible_only_on_desktop = require("./../_shared/resolvers/is-visible-only-on-desktop.js");
var import_toolbars_v3 = require("./../toolbars-v3/index.js");
var import_constants = require("./constants.js");
var import_insert_modal = require("./modals/insert-modal.js");
const getToolbarButtons = (config, services) => {
  const {
    context: { isMobile }
  } = services;
  const sizeButton = (0, import_create_node_size_button.createNodeSizeButton)({
    services,
    modalId: import_constants.GIF_BUTTONS.size,
    options: ["SMALL", "CONTENT", "FULL_WIDTH", "ORIGINAL"]
  });
  const separator1 = (0, import_create_separator.createSeparator)({
    visible: (0, import_is_visible_only_on_desktop.isVisibleOnlyOnDesktop)(isMobile)
  });
  const alignmentButton = (0, import_create_node_alignment_button.createNodeAlignmentButton)({ services, modalId: import_constants.GIF_BUTTONS.alignment });
  const separator2 = (0, import_create_separator.createSeparator)({
    visible: (0, import_is_visible_only_on_desktop.isVisibleOnlyOnDesktop)(isMobile)
  });
  const replaceButton = (0, import_create_replace_button.createReplaceButton)({
    modalId: import_constants.gifModals.replace,
    command: ({ referenceElement, attributes: { selectedNode } }) => {
      const { modals } = services;
      modals?.togglePluginPanel({
        id: import_constants.gifModals.replace,
        Component: import_insert_modal.GiphyInsertModal,
        componentProps: {
          nodeId: selectedNode.attrs.id,
          modalId: import_constants.gifModals.replace,
          getGiphyUrl: config?.getGiphyUrl
        },
        positioning: {
          referenceElement: referenceElement?.closest(`[data-hook~=${import_toolbars_v3.FLOATING_PLUGIN_TOOLBAR}]`) ?? referenceElement,
          placement: "right-start"
        },
        isMobile,
        focusReturnElement: referenceElement
      });
    }
  });
  const separator3 = (0, import_create_separator.createSeparator)();
  const deleteButton = (0, import_create_delete_button.createDeleteButton)({
    command: (data) => {
      const figures = data.tiptapEditor.$nodes(import_consts.TIPTAP_FIGURE_TYPE);
      const selectedFigure = figures?.find((f) => {
        return f.firstChild?.node.attrs.id === data.attributes.selectedNode.attrs.id;
      });
      if (selectedFigure) {
        data.tiptapEditor.chain().focus().deleteNode(selectedFigure.attributes.id).run();
      }
    }
  });
  return [
    sizeButton,
    separator1,
    alignmentButton,
    separator2,
    replaceButton,
    separator3,
    deleteButton
  ];
};
//# sourceMappingURL=get-toolbar-buttons.js.map
