import { VideoCamera, Youtube } from "@wix/wix-ui-icons-common";
import lodash from "lodash";
import { Node_Type } from "./../ricos-types/index.js";
import { INSERT_PLUGIN_BUTTONS, TOOLBARS } from "./../editor-common/index.js";
import {
  RICOS_DEFAULTS,
  VIDEO_INSERT_VIDEO_MODAL_ID,
  VIDEO_INSERT_YOUTUBE_MODAL_ID
} from "./constants.js";
import { INSERT_VIDEO_BUTTON, INSERT_YOUTUBE_BUTTON } from "./data-hooks.js";
import { InsertModal } from "./modals/insert-modal.js";
import { videoButtonsTypes } from "./types.js";
const toolbarsToAddIn = [
  TOOLBARS.FOOTER,
  TOOLBARS.SIDE,
  TOOLBARS.MOBILE
];
const getAddButtons = (config, services) => {
  const {
    disableDownloadDefault,
    getVideoUrl,
    exposeButtons = [videoButtonsTypes.video]
  } = config || {};
  const {
    modals,
    context: { isMobile }
  } = services;
  const modalBaseProps = {
    disableDownloadDefault,
    getVideoUrl
  };
  const buttonsMap = {
    [videoButtonsTypes.video]: {
      id: `${Node_Type.VIDEO}.video`,
      label: INSERT_PLUGIN_BUTTONS.VIDEO,
      dataHook: INSERT_VIDEO_BUTTON,
      icon: VideoCamera,
      tooltip: "VideoPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        modals?.togglePluginPanel({
          id: VIDEO_INSERT_VIDEO_MODAL_ID,
          Component: InsertModal,
          componentProps: {
            componentData: { ...RICOS_DEFAULTS },
            modalId: VIDEO_INSERT_VIDEO_MODAL_ID,
            ...modalBaseProps
          },
          isMobile,
          positioning: {
            referenceElement,
            placement: "bottom"
          },
          mobileLayout: "drawer"
        });
        return true;
      },
      menuConfig: {
        tags: "Video_plugin_search_tags"
      }
    },
    [videoButtonsTypes.youTube]: {
      id: `${Node_Type.VIDEO}.youTube`,
      label: INSERT_PLUGIN_BUTTONS.YOUTUBE,
      dataHook: INSERT_YOUTUBE_BUTTON,
      icon: Youtube,
      tooltip: "YouTubePlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        modals?.togglePluginPanel({
          id: VIDEO_INSERT_YOUTUBE_MODAL_ID,
          Component: InsertModal,
          componentProps: {
            componentData: { ...RICOS_DEFAULTS, type: videoButtonsTypes.youTube },
            modalId: VIDEO_INSERT_YOUTUBE_MODAL_ID,
            ...modalBaseProps
          },
          isMobile,
          positioning: {
            referenceElement,
            placement: "bottom"
          },
          mobileLayout: "drawer"
        });
        return true;
      },
      menuConfig: {
        tags: "YouTube_plugin_search_tags",
        group: "embed"
      }
    }
  };
  return lodash.compact(exposeButtons.map((buttonType) => buttonsMap[buttonType]));
};
export {
  getAddButtons,
  toolbarsToAddIn
};
//# sourceMappingURL=get-add-buttons.js.map
