"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 gallery_testkit_exports = {};
__export(gallery_testkit_exports, {
  createGalleryTestkit: () => createGalleryTestkit
});
module.exports = __toCommonJS(gallery_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_dropdown_modal_uni_driver = require("./../../_shared/dropdown-modal/dropdown-modal-uni-driver.js");
var import_create_link_modal_unidriver = require("./../../_shared/link-modal/create-link-modal-unidriver.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 createGalleryTestkit = (getBase) => {
  const getGallery = async (index, options) => {
    const galleries = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.ROOT), options);
    return galleries.at(index);
  };
  return {
    content: {
      atIndex: (index) => {
        return {
          exists: async (options) => {
            try {
              const gallery = await getGallery(index, options);
              return gallery.exists();
            } catch {
              return false;
            }
          },
          click: async () => {
            const gallery = await getGallery(index);
            await gallery.click();
          },
          itemsCount: async () => {
            const gallery = await getGallery(index);
            const items = await gallery.getAll((0, import_wix_rich_content_common.dataHook)("item-container"));
            return items.count();
          },
          hasSpoiler: async () => {
            try {
              const spoiler = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.SPOILER_CONTAINER));
              return spoiler.exists();
            } catch {
              return false;
            }
          },
          fullscreen: {
            waitForElement: async () => {
              const fullscreen = await getBase().get((0, import_wix_rich_content_common.dataHook)("fullscreen-root"));
              await fullscreen.wait();
            }
          },
          itemAtIndex: (itemIndex) => {
            const getGalleryItem = async () => {
              const gallery = await getGallery(index);
              const items = await gallery.getAll((0, import_wix_rich_content_common.dataHook)("item-container"));
              return items.at(itemIndex);
            };
            return {
              click: async () => {
                (await getGalleryItem()).click();
              }
            };
          }
        };
      }
    },
    settings: {
      tabs: {
        ...(0, import_unidriver.TabsUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_TABS)), getBase()),
        waitForElement: async () => {
          const tabs = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_TABS));
          await tabs.wait();
        }
      },
      mediaTab: {
        getItemAtIndex: async (index) => {
          const items = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_SETTINGS_SORTABLE_ITEMS));
          const item = items.at(index);
          return (0, import_unidriver.ThumbnailUniDriver)(item, getBase());
        },
        getItemCount: async () => {
          const items = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_SETTINGS_SORTABLE_ITEMS));
          return items.count();
        },
        plusButton: (0, import_unidriver.FileUploadUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_SETTINGS_ADD_MEDIA_INPUT)),
          getBase()
        ),
        selectAllButton: (0, import_unidriver.TextButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_SETTINGS_SELECT_ALL_ITEMS_BUTTON)),
          getBase()
        ),
        editButton: (0, import_unidriver.TextButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_SETTINGS_EDIT_ITEM_BUTTON)),
          getBase()
        ),
        deleteButton: (0, import_unidriver.TextButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_SETTINGS_DELETE_ITEMS_BUTTON)),
          getBase()
        )
      },
      layoutTab: {
        getLayoutSelectorThumbnail: async (type) => {
          const galleryLayout = await getBase().get(
            (0, import_wix_rich_content_common.dataHook)(`${import_data_hooks2.LAYOUT_SETTINGS_LAYOUT_THUMBNAIL}${type}`)
          );
          return (0, import_unidriver.ThumbnailUniDriver)(galleryLayout, getBase());
        },
        thumbnailCropSegmentedToggle: (0, import_unidriver.SegmentedToggleUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.LAYOUT_SETTINGS_THUMBNAIL_CROP_SEGMENTED_TOGGLE)),
          getBase()
        ),
        getImageRatioSelectorThumbnail: async (type) => {
          const option = await getBase().get(
            (0, import_wix_rich_content_common.dataHook)(`${import_data_hooks2.LAYOUT_SETTINGS_IMAGE_RATIO_THUMBNAIL}${type}`)
          );
          return (0, import_unidriver.ThumbnailUniDriver)(option, getBase());
        }
      },
      itemSettings: {
        carousel: (0, import_unidriver.CarouselUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_ITEM_SETTINGS_CAROUSEL)), getBase()),
        deleteButton: (0, import_unidriver.TextButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_ITEM_SETTINGS_DELETE_BUTTON)),
          getBase()
        ),
        linkButton: (0, import_unidriver.ButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_ITEM_SETTINGS_ADD_LINK_BUTTON)),
          getBase()
        ),
        captionInput: (0, import_unidriver.InputUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_ITEM_SETTINGS_CAPTION_INPUT)),
          getBase()
        ),
        altTextInput: (0, import_unidriver.InputUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.MEDIA_ITEM_SETTINGS_ALT_INPUT)),
          getBase()
        )
      },
      generalTab: {
        disableExpandToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.GENERAL_SETTINGS_EXPAND_TOGGLE)),
          getBase()
        ),
        disableDownloadToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.GENERAL_SETTINGS_DOWNLOAD_TOGGLE)),
          getBase()
        ),
        spoilerToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.GENERAL_SETTINGS_SPOILER_TOGGLE)),
          getBase()
        )
      },
      linkModal: (0, import_create_link_modal_unidriver.createLinkModalUnidriver)(getBase)
    },
    toolbars: {
      createAddButtonToolbars: (getAddButtonToolbarBase) => ({
        click: async () => {
          await (await getAddButtonToolbarBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_GALLERY_BUTTON))).click();
        },
        toolbarsToAddIn: import_get_add_buttons.toolbarsToAddIn
      }),
      createPluginToolbar: (getPluginToolbarBase) => ({
        clickLayoutSelectionDropdown: async () => {
          const settings = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.GALLERY).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.PLUGIN_TOOLBAR_LAYOUT_DROPDOWN_BUTTON)
          );
          await settings.click();
        },
        clickManageMedia: async () => {
          const settings = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.GALLERY).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.PLUGIN_TOOLBAR_MANAGE_MEDIA_BUTTON)
          );
          await settings.click();
        },
        clickGeneralSettings: async () => {
          const settings = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.GALLERY).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SETTINGS_BUTTON)
          );
          await settings.click();
        },
        clickDelete: async () => {
          const button = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.GALLERY).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_DELETE_BUTTON)
          );
          await button.click();
        },
        clickSizeDropdown: async () => {
          const dropdown = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.GALLERY).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SIZE_BUTTON)
          );
          await dropdown.click();
        },
        gallerySize: {
          clickSmall: async () => {
            const allignmentButton = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.SIZE_DROPDOWN_OPTION_SMALL));
            await allignmentButton.click();
          }
        },
        layoutSelectionDropdown: (0, import_dropdown_modal_uni_driver.createDropdownModalUniDriver)(getBase),
        exists: async () => {
          try {
            return getPluginToolbarBase(import_ricos_types.Node_Type.GALLERY).exists();
          } catch {
            return false;
          }
        }
      })
    }
  };
};
//# sourceMappingURL=gallery.testkit.js.map
