import { Catalog } from "@wix/wix-ui-icons-common";
import React from "react";
import { Node_Type } from "./../ricos-schema/next-schema/index.js";
import { PLUGIN_TOOLBAR_SETTINGS_BUTTON } from "./../_shared/data-hooks.js";
import { createDeleteButton } from "./../_shared/plugin-toolbar/create-delete-button.js";
import { createNodeAlignmentButton } from "./../_shared/plugin-toolbar/create-node-alignment-button.js";
import { createReplaceButton } from "./../_shared/plugin-toolbar/create-replace-button.js";
import { createSettingsButton } from "./../_shared/plugin-toolbar/create-settings-button.js";
import { createNodeSizeButton } from "./../_shared/plugin-toolbar/node-size-button/create-node-size-button.js";
import { createSeparator } from "./../_shared/plugin-toolbar/separator/create-separator.js";
import { getNodeInSelection } from "./../_shared/resolvers/get-node-in-selection.js";
import { FLOATING_PLUGIN_TOOLBAR } from "./../toolbars-v3/index.js";
import { verticalEmbedModals } from "./constants.js";
import { PLUGIN_TOOLBAR_UPDATE_BUTTON } from "./data-hooks.js";
import { InsertModal } from "./modals/insert-modal.js";
import { SettingsModal } from "./modals/settings-modal.js";
import { PresetsButton } from "./toolbar/presets-button.js";
import { UpdateInformationButton } from "./toolbar/update-information-button.js";
const getToolbarButtons = (config, services) => {
  const { modals } = services;
  const { isMobile } = services?.context ?? {};
  const presetsButton = {
    id: "VERTICAL_EMBED_PRESETS",
    type: "modal",
    dataHook: PLUGIN_TOOLBAR_SETTINGS_BUTTON,
    tooltip: "Embed_Vertical_Presets_Tooltip",
    icon: Catalog,
    command: ({ referenceElement, attributes: { selectedNode } }) => {
      if (modals?.isModalOpen(verticalEmbedModals.settings)) {
        modals?.closeModal(verticalEmbedModals.settings);
      }
      modals?.togglePluginPanel({
        id: verticalEmbedModals.presets,
        Component: SettingsModal,
        componentProps: {
          referenceElement,
          nodeId: selectedNode.attrs.id,
          initialViewMode: "presets",
          activeTab: "settings",
          config,
          modalId: verticalEmbedModals.presets
        },
        isMobile,
        positioning: {
          referenceElement: referenceElement?.closest(`[data-hook~=${FLOATING_PLUGIN_TOOLBAR}]`) ?? referenceElement,
          placement: "right-start"
        },
        focusReturnElement: referenceElement,
        onClickOutside: () => {
        }
      });
    },
    renderer: (toolbarItem) => /* @__PURE__ */ React.createElement(PresetsButton, { toolbarItem }),
    attributes: {
      selectedNode: getNodeInSelection,
      active: (_, { modals: modals2 }) => Boolean(modals2?.getModal(verticalEmbedModals.presets))
    }
  };
  const separator1 = createSeparator();
  const sizeButton = createNodeSizeButton({
    services,
    modalId: `${Node_Type.APP_EMBED}.size`,
    options: ["SMALL", "CONTENT", "FULL_WIDTH"]
  });
  const alignmentButton = createNodeAlignmentButton({
    services,
    modalId: "VERTICAL_EMBED_BUTTONS.alignment"
  });
  const updateInformationButton = {
    id: "UPDATE_INFORMATION",
    type: "toggle",
    attributes: {
      selectedNode: getNodeInSelection
    },
    dataHook: PLUGIN_TOOLBAR_UPDATE_BUTTON,
    tooltip: "Embed_Vertical_UpdateInformation_Tooltip",
    icon: () => null,
    command: () => {
    },
    renderer: (toolbarItem) => /* @__PURE__ */ React.createElement(UpdateInformationButton, { toolbarItem })
  };
  const replaceButton = createReplaceButton({
    modalId: verticalEmbedModals.replace,
    command: ({ referenceElement, attributes: { selectedNode } }) => {
      modals?.togglePluginPanel({
        id: verticalEmbedModals.replace,
        Component: InsertModal,
        componentProps: {
          modalId: verticalEmbedModals.replace,
          componentData: selectedNode.attrs,
          nodeId: selectedNode.attrs.id
        },
        isMobile,
        positioning: {
          referenceElement: referenceElement?.closest(`[data-hook~=${FLOATING_PLUGIN_TOOLBAR}]`) ?? referenceElement,
          placement: "right-start"
        },
        focusReturnElement: referenceElement
      });
    }
  });
  const settingsButton = createSettingsButton({
    modalId: verticalEmbedModals.settings,
    command: ({ referenceElement, attributes: { selectedNode } }) => {
      if (modals?.isModalOpen(verticalEmbedModals.presets)) {
        modals?.closeModal(verticalEmbedModals.presets);
      }
      modals?.togglePluginPanel({
        id: verticalEmbedModals.settings,
        Component: SettingsModal,
        componentProps: {
          referenceElement,
          nodeId: selectedNode.attrs.id,
          initialViewMode: "custom",
          activeTab: "settings",
          config,
          modalId: verticalEmbedModals.settings
        },
        isMobile,
        positioning: {
          referenceElement: referenceElement?.closest(`[data-hook~=${FLOATING_PLUGIN_TOOLBAR}]`) ?? referenceElement,
          placement: "right-start"
        },
        focusReturnElement: referenceElement,
        onClickOutside: () => {
        }
      });
    }
  });
  const separator2 = createSeparator();
  const deleteButton = createDeleteButton();
  return [
    presetsButton,
    separator1,
    sizeButton,
    alignmentButton,
    updateInformationButton,
    replaceButton,
    settingsButton,
    separator2,
    deleteButton
  ];
};
export {
  getToolbarButtons
};
//# sourceMappingURL=get-toolbar-buttons.js.map
