import {
  DateChecked,
  DateCheckedSmall,
  Order,
  OrderSmall,
  WixBooking,
  WixBookingSmall
} from "@wix/wix-ui-icons-common";
import { AppEmbedData_AppType } from "./../ricos-schema/legacy/wix/rich_content/v1/index.js";
import {
  Node_Type,
  RicosPluginToolbarNames,
  quickActionsModalSections
} from "./../ricos-types/index.js";
import { posToDOMRect } from "./../tiptap/index.js";
import { appEmbedConverter } from "./app-embed-converter.js";
import { verticalEmbedModals } from "./constants.js";
import { DEFAULTS } from "./defaults.js";
import { getAddButtons } from "./get-add-buttons.js";
import { getToolbarButtons } from "./get-toolbar-buttons.js";
import { InsertModal } from "./modals/insert-modal.js";
import { tiptapExtensions } from "./tiptap/tiptap.js";
import { VERTICAL_EMBED_TYPE } from "./types.js";
const pluginVerticalEmbed = (config) => {
  const pluginConfig = { type: "verticalEmbed", ...DEFAULTS.config, ...config };
  return {
    config: pluginConfig,
    type: VERTICAL_EMBED_TYPE,
    tiptapExtensions,
    pmMarkConverters: [],
    pmNodeConverters: [appEmbedConverter],
    toolbar: {
      names: [RicosPluginToolbarNames.APP_EMBED],
      getButtons: (config2, services) => getToolbarButtons(config2, services)
    },
    getAddButtons: (config2, services) => getAddButtons(config2, services),
    getQuickActions: ({ pluginServices }) => {
      const isMobile = pluginServices?.context.isMobile;
      const toggleInsertModal = ({
        id,
        type,
        modalService,
        editor
      }) => modalService?.togglePluginPanel({
        id,
        Component: InsertModal,
        componentProps: {
          componentData: { type },
          modalId: id
        },
        positioning: {
          referenceElement: {
            getBoundingClientRect: () => posToDOMRect(
              editor.view,
              editor.view.state.selection.from,
              editor.view.state.selection.to
            )
          },
          placement: "bottom-start"
        },
        isMobile
      });
      return [
        {
          id: `${Node_Type.APP_EMBED}.product`,
          title: "QuickActionsPlugin_ActionTitle_Product",
          icon: isMobile ? Order : OrderSmall,
          section: quickActionsModalSections.EmbedWix,
          tags: [
            "item",
            "merchandise",
            "product card",
            "shop item",
            "e-commerce",
            "online store",
            "store item"
          ],
          command: ({ modalService, editor }) => {
            toggleInsertModal({
              id: verticalEmbedModals.insertProduct,
              type: AppEmbedData_AppType.PRODUCT,
              modalService,
              editor
            });
          }
        },
        {
          id: `${Node_Type.APP_EMBED}.event`,
          title: "QuickActionsPlugin_ActionTitle_Event",
          icon: isMobile ? DateChecked : DateCheckedSmall,
          section: quickActionsModalSections.EmbedWix,
          tags: ["calendar", "meeting", "appointment", "schedule", "date", "time"],
          command: ({ modalService, editor }) => {
            toggleInsertModal({
              id: verticalEmbedModals.insertEvent,
              type: AppEmbedData_AppType.EVENT,
              modalService,
              editor
            });
          }
        },
        {
          id: `${Node_Type.APP_EMBED}.service`,
          title: "QuickActionsPlugin_ActionTitle_Service",
          icon: isMobile ? WixBooking : WixBookingSmall,
          section: quickActionsModalSections.EmbedWix,
          tags: ["reservation", "appointment", "schedule", "time", "calendar", "ticket", "booking"],
          command: ({ modalService, editor }) => {
            toggleInsertModal({
              id: verticalEmbedModals.insertBooking,
              type: AppEmbedData_AppType.BOOKING,
              modalService,
              editor
            });
          }
        }
      ];
    }
  };
};
export {
  pluginVerticalEmbed
};
//# sourceMappingURL=editor.js.map

import { injectCss } from "./viewer-styles-inject.js";
injectCss();
