import { Node_Type } from "./../ricos-types/index.js";
const downloadFile = (url, fileName) => {
  fetch(url, {
    method: "GET"
  }).then((response) => response.blob()).then((blob) => {
    const url2 = window.URL.createObjectURL(blob);
    const a = document.createElement("a");
    a.href = url2;
    a.download = fileName;
    document.body.appendChild(a);
    a.click();
    a.remove();
  });
};
const getAudioSrc = (src, config) => {
  if (src?.url) {
    return src.url;
  }
  if (typeof src === "object") {
    if (config && config.getAudioUrl) {
      return config.getAudioUrl(src);
    } else {
      console.error("must set getAudioUrl in plugin config when using custom audio source!", src);
    }
  }
  return src;
};
const playbackRates = [
  {
    text: "0.25",
    rate: 0.25
  },
  {
    text: "0.5",
    rate: 0.5
  },
  {
    text: "0.75",
    rate: 0.75
  },
  {
    text: "Normal",
    rate: 1
  },
  {
    text: "1.25",
    rate: 1.25
  },
  {
    text: "1.5",
    rate: 1.5
  },
  {
    text: "1.75",
    rate: 1.75
  },
  {
    text: "2",
    rate: 2
  }
];
const AUDIO_ACTION_NAMES = {
  fileDownloaded: "fileDownloaded",
  playAudio: "playAudio",
  changeTitle: "changeTitle",
  changeCreator: "changeCreator",
  changeCover: "changeCover",
  downloadAudio: "downloadAudio"
};
const AUDIO_BI_VALUES = {
  PLAY: "play",
  PAUSE: "pause",
  PLAYBACK_COMPLETED: "playbackCompleted",
  YES: "yes",
  NO: "no",
  click: "Click"
};
const AUDIO_TYPES = { custom: "File Upload", spotify: "Spotify", soundCloud: "SoundCloud" };
const audioFileTypes = ".mp3,.pcm,.wav,.aiff,.aif,.aac,.ogg,.wma,.m4a,.flac";
const INSERT_AUDIO_MODAL_ID = "AUDIO.insert";
const AUDIO_SETTINGS_MODAL_ID = "AUDIO.settings";
const AUDIO_INSERT_AUDIO_MODAL_ID = "AUDIO.insertAudio";
const AUDIO_INSERT_SPOTIFY_MODAL_ID = "AUDIO.insertSpotify";
const AUDIO_INSERT_SOUNDCLOUD_MODAL_ID = "AUDIO.insertSoundCloud";
const AUDIO_REPLACE_MODAL_ID = "AUDIO.replace";
const AUDIO_BUTTONS = {
  size: `${Node_Type.AUDIO}.size`,
  alignment: `${Node_Type.AUDIO}.alignment`
};
export {
  AUDIO_ACTION_NAMES,
  AUDIO_BI_VALUES,
  AUDIO_BUTTONS,
  AUDIO_INSERT_AUDIO_MODAL_ID,
  AUDIO_INSERT_SOUNDCLOUD_MODAL_ID,
  AUDIO_INSERT_SPOTIFY_MODAL_ID,
  AUDIO_REPLACE_MODAL_ID,
  AUDIO_SETTINGS_MODAL_ID,
  AUDIO_TYPES,
  INSERT_AUDIO_MODAL_ID,
  audioFileTypes,
  downloadFile,
  getAudioSrc,
  playbackRates
};
//# sourceMappingURL=consts.js.map
