"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var testkit_exports = {};
__export(testkit_exports, {
  createAudioTestkit: () => createAudioTestkit
});
module.exports = __toCommonJS(testkit_exports);
var import_unidriver = require("@wix/design-system/dist/testkit/unidriver.js");
var import_ricos_types = require("./../ricos-types/index.js");
var import_data_hooks = require("./../_shared/data-hooks.js");
var import_wix_rich_content_common = require("./../wix-rich-content-common/index.js");
var import_data_hooks2 = require("./data-hooks.js");
var import_get_add_buttons = require("./get-add-buttons.js");
const createAudioTestkit = (getBase) => {
  const getAudio = async (index, options) => {
    const audio = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.ROOT), options);
    return audio.at(index);
  };
  const getInsertAudioModal = async () => await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_AUDIO_MODAL));
  const getElementByTag = async (tag) => await getBase().get(`${(0, import_wix_rich_content_common.dataHook)(import_data_hooks2.ROOT)} ${tag}`);
  const getHTMLAudioElement = async (index, options) => {
    const htmlElement = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.ROOT), options);
    return htmlElement.at(index);
  };
  return {
    content: {
      atIndex: (index) => {
        return {
          uploadedAudio: {
            exists: async (options) => {
              try {
                const audio = await getAudio(index, options);
                return audio.exists();
              } catch {
                return false;
              }
            },
            click: async () => {
              const video = await getAudio(index);
              await video.click();
            },
            getSrc: async () => (await getElementByTag("audio")).attr("src"),
            imageExists: async () => {
              try {
                const audioImage = await getElementByTag("img");
                return audioImage.exists();
              } catch {
                return false;
              }
            },
            getTitle: async () => {
              const audio = await getAudio(index);
              const titleText = await audio.get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.AUDIO_TITLE));
              return titleText.text();
            },
            getCreator: async () => {
              const audio = await getAudio(index);
              const creatorText = await audio.get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.AUDIO_CREATOR));
              return creatorText.text();
            },
            contextMenu: {
              toggle: async () => {
                const audio = await getAudio(index);
                const contextMenu = await audio.get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.AUDIO_CONTEXT_MENU));
                return contextMenu.click();
              },
              items: {
                clickAt: async (index2) => {
                  const items = await getBase().getAll(
                    `${(0, import_wix_rich_content_common.dataHook)(import_data_hooks2.AUDIO_CONTEXT_COMMON_MENU)} button`
                  );
                  return items.at(index2).click();
                }
              }
            },
            playbackSpeedMenuExists: async () => {
              const playbackSpeed = await getElementByTag((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.AUDIO_PLAYBACK_SPEED_MENU));
              return playbackSpeed.exists();
            },
            getNativeElement: async () => {
              const audio = await getAudio(index);
              return audio.getNative();
            }
          },
          htmlElement: {
            waitForElement: async () => {
              const htmlElement = await getHTMLAudioElement(index);
              return htmlElement.wait();
            },
            exists: async (options) => {
              try {
                const htmlElement = await getHTMLAudioElement(index, options);
                return htmlElement.exists();
              } catch {
                return false;
              }
            }
          }
        };
      }
    },
    settings: {
      exists: async () => {
        try {
          const audioSettings = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_MODAL));
          return audioSettings.exists();
        } catch {
          return false;
        }
      },
      waitForElement: async () => {
        await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_MODAL));
      },
      titleInput: (0, import_unidriver.InputUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_AUDIO_NAME_INPUT)), getBase()),
      creatorInput: (0, import_unidriver.InputUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_AUTHOR_NAME_INPUT)), getBase()),
      coverImage: (0, import_unidriver.ImageViewerUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_AUDIO_COVER_IMAGE)),
        getBase()
      ),
      disableDownloadToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_DOWNLOAD_TOGGLE)),
        getBase()
      )
    },
    insertModal: {
      sourceSegmentedToggle: (0, import_unidriver.SegmentedToggleUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_AUDIO_MODAL_SOURCE_TOGGLE)),
        getBase()
      ),
      embedSection: {
        urlInput: (0, import_unidriver.InputUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.EMBED_TAB_URL_INPUT)), getBase()),
        submitButton: (0, import_unidriver.ButtonUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.EMBED_TAB_SUBMIT_BUTTON)), getBase())
      },
      uploadSection: {
        uploadButton: (0, import_unidriver.ButtonUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.UPLOAD_TAB_UPLOAD_BUTTON)), getBase())
      },
      waitForElement: async () => {
        const insertAudioModal = await getInsertAudioModal();
        await insertAudioModal.wait();
      }
    },
    toolbars: {
      createAddButtonToolbars: (getAddButtonToolbarBase) => ({
        clickSoundcloud: async () => {
          const soundcloudButton = await getAddButtonToolbarBase().get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_SOUNDCLOUD_BUTTON)
          );
          return soundcloudButton.click();
        },
        clickSpotify: async () => {
          const spotifyButton = await getAddButtonToolbarBase().get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_SPOTIFY_BUTTON)
          );
          return spotifyButton.click();
        },
        clickAudio: async () => {
          const audioPluginButton = await getAddButtonToolbarBase().get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_AUDIO_BUTTON)
          );
          return audioPluginButton.click();
        },
        toolbarsToAddIn: import_get_add_buttons.toolbarsToAddIn
      }),
      createPluginToolbar: (getPluginToolbarBase) => ({
        clickEdit: async () => {
          const editButton = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.AUDIO).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.PLUGIN_TOOLBAR_AUDIO_SETTINGS_BUTTON)
          );
          return editButton.click();
        },
        clickReplace: async () => {
          const replaceButton = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.AUDIO).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_REPLACE_BUTTON)
          );
          return replaceButton.click();
        },
        clickDelete: async () => {
          const deleteButton = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.AUDIO).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_DELETE_BUTTON)
          );
          return deleteButton.click();
        },
        exists: async () => {
          try {
            const pluginToolbar = getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.AUDIO);
            return pluginToolbar.exists();
          } catch {
            return false;
          }
        }
      })
    }
  };
};
//# sourceMappingURL=testkit.js.map
