import { Sound, SoundCloud, Spotify } 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 {
  AUDIO_INSERT_AUDIO_MODAL_ID,
  AUDIO_INSERT_SOUNDCLOUD_MODAL_ID,
  AUDIO_INSERT_SPOTIFY_MODAL_ID
} from "./consts.js";
import {
  INSERT_AUDIO_BUTTON,
  INSERT_SOUNDCLOUD_BUTTON,
  INSERT_SPOTIFY_BUTTON
} from "./data-hooks.js";
import { RICOS_DEFAULTS } from "./defaults.js";
import { InsertModal } from "./modals/insert-modal.js";
import { audioButtonsTypes } from "./types.js";
const toolbarsToAddIn = [
  TOOLBARS.FOOTER,
  TOOLBARS.SIDE,
  TOOLBARS.MOBILE
];
const getAddButtons = (config, services) => {
  const { exposeButtons = [audioButtonsTypes.audio], disableDownload = true } = config || {};
  const {
    modals,
    context: { isMobile }
  } = services;
  const toggleInsertModal = ({
    referenceElement,
    id,
    embedType
  }) => {
    modals?.togglePluginPanel({
      id,
      Component: InsertModal,
      componentProps: {
        componentData: { ...RICOS_DEFAULTS, disableDownload },
        modalId: id,
        embedType
      },
      isMobile,
      positioning: {
        referenceElement,
        placement: "bottom"
      },
      mobileLayout: "drawer"
    });
  };
  const buttonsMap = {
    [audioButtonsTypes.audio]: {
      id: `${Node_Type.AUDIO}.audio`,
      label: INSERT_PLUGIN_BUTTONS.AUDIO,
      dataHook: INSERT_AUDIO_BUTTON,
      icon: Sound,
      tooltip: "AudioPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: AUDIO_INSERT_AUDIO_MODAL_ID,
          embedType: false,
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "Audio_plugin_search_tags"
      }
    },
    [audioButtonsTypes.soundCloud]: {
      id: `${Node_Type.AUDIO}.soundCloud`,
      label: INSERT_PLUGIN_BUTTONS.SOUND_CLOUD,
      dataHook: INSERT_SOUNDCLOUD_BUTTON,
      icon: SoundCloud,
      tooltip: "SoundCloudPlugin_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: AUDIO_INSERT_SOUNDCLOUD_MODAL_ID,
          embedType: true,
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "SoundCloud_plugin_search_tags",
        group: "embed"
      }
    },
    [audioButtonsTypes.spotify]: {
      id: `${Node_Type.AUDIO}.spotify`,
      label: INSERT_PLUGIN_BUTTONS.SPOTIFY,
      dataHook: INSERT_SPOTIFY_BUTTON,
      icon: Spotify,
      tooltip: "Spotify_InsertButton_Tooltip",
      toolbars: toolbarsToAddIn,
      command: ({ referenceElement }) => {
        toggleInsertModal({
          id: AUDIO_INSERT_SPOTIFY_MODAL_ID,
          embedType: true,
          referenceElement
        });
        return true;
      },
      menuConfig: {
        tags: "AudioPlugin_InsertButton",
        group: "embed"
      }
    }
  };
  return lodash.compact(exposeButtons.map((buttonType) => buttonsMap[buttonType]));
};
export {
  getAddButtons,
  toolbarsToAddIn
};
//# sourceMappingURL=get-add-buttons.js.map
