"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, {
  createImageTestkit: () => createImageTestkit
});
module.exports = __toCommonJS(testkit_exports);
var import_unidriver = require("@wix/design-system/dist/testkit/unidriver.js");
var import_testkit = require("./../plugin-figure/testkit.js");
var import_ricos_styles = require("./../ricos-styles/index.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("./../ui-components/color-picker/button-color-swatches/data-hooks.js");
var import_testkit2 = require("./../ui-components/testkit.js");
var import_data_hooks3 = require("./data-hooks.js");
var import_get_add_buttons = require("./get-add-buttons.js");
const createImageTestkit = (getBase) => {
  const getFigure = async (index, options) => {
    const figure = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(`figure-IMAGE`), options);
    return figure.at(index);
  };
  const getImage = async (index, options) => {
    return (await getFigure(index, options)).get((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.ROOT));
  };
  const getImageTag = async (index) => {
    const image = await getBase().getAll(`${(0, import_wix_rich_content_common.dataHook)(import_data_hooks3.ROOT)} img`);
    return image.at(index);
  };
  const getWowImageTag = async () => await getBase().get(`${(0, import_wix_rich_content_common.dataHook)(import_data_hooks3.ROOT)} wow-image`);
  return {
    content: {
      atIndex: (index) => {
        return {
          exists: async (options) => {
            try {
              const image = await getImage(index, options);
              return image.exists();
            } catch {
              return false;
            }
          },
          expandExists: async () => {
            const image = await getImage(index);
            return image.get((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.EXPAND_BUTTON)).then(
              () => true,
              () => false
            );
          },
          click: async () => {
            const image = await getImage(index);
            await image.click();
          },
          hover: async () => {
            const image = await getImage(index);
            await image.hover();
          },
          getText: async () => (await getImage(index)).text(),
          getAlt: async () => (await getImageTag(index))._prop("alt"),
          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;
            }
          },
          getStyle: async () => (await getImageTag(index)).attr("style"),
          clickExpand: async () => {
            const image = await getImage(index);
            (await image.get((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.EXPAND_BUTTON))).click();
          },
          getSrc: async () => (await getWowImageTag())._prop("id"),
          isLoading: async () => {
            const figure = await getFigure(index);
            return figure.get((0, import_wix_rich_content_common.dataHook)("loader")).then(
              () => true,
              () => false
            );
          },
          getNativeElement: async () => (await getImage(index)).getNative(),
          ...(0, import_testkit.createFigureTestkit)(getBase, index)
        };
      },
      fullscreen: {
        exists: async () => {
          return (await getBase().get((0, import_wix_rich_content_common.dataHook)("fullscreen-root"))).exists();
        }
      }
    },
    tabs: {
      ...(0, import_unidriver.TabsUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_IMAGE_TABS)), getBase()),
      waitForElement: async () => {
        const tabs = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_IMAGE_TABS));
        await tabs.wait();
      }
    },
    settings: {
      image: (0, import_unidriver.ImageUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_IMAGE_PREVIEW)), getBase()),
      isDecorativeToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_IS_DECORATIVE_TOGGLE)),
        getBase()
      ),
      disableExpandToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_DISABLE_EXPAND_TOGGLE)),
        getBase()
      ),
      disableDownloadToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_DISABLE_DOWNLOAD_TOGGLE)),
        getBase()
      ),
      spoilerToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_SPOILER_TOGGLE)),
        getBase()
      ),
      altTextInput: {
        ...(0, import_unidriver.InputUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_ALT_INPUT)), getBase()),
        waitForElement: async () => {
          await getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_ALT_INPUT)).wait();
        }
      }
    },
    design: {
      cornerRadiusInput: {
        ...(0, import_unidriver.InputUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_DESIGN_TAB_CORNER_RADIUS_INPUT)),
          getBase()
        ),
        waitForElement: async () => {
          await getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_DESIGN_TAB_CORNER_RADIUS_INPUT)).wait();
        }
      },
      borderWidthInput: {
        ...(0, import_unidriver.InputUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_DESIGN_TAB_BORDER_WIDTH_INPUT)), getBase()),
        waitForElement: async () => {
          await getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_DESIGN_TAB_BORDER_WIDTH_INPUT)).wait();
        }
      },
      borderColorPicker: (() => {
        const getFillPreview = () => getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.SETTINGS_DESIGN_TAB_BORDER_COLOR_PICKER)).$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SWATCH_TOGGLE));
        return {
          ...(0, import_unidriver.FillPreviewUniDriver)(getFillPreview(), getBase()),
          getColor: async () => {
            const el = await getFillPreview().$(`button`);
            const style = await el.prop("style");
            return (0, import_ricos_styles.toHexFormat)(style.getPropertyValue("--fill-preview-background-color-0"));
          }
        };
      })(),
      colorPickerModal: (0, import_testkit2.createNewColorPickerUniDriver)(getBase)
    },
    toolbars: {
      createAddButtonToolbars: (getAddButtonBase) => ({
        click: async () => {
          const imagePluginButton = await getAddButtonBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks3.INSERT_IMAGE_BUTTON));
          await imagePluginButton.click();
        },
        toolbarsToAddIn: import_get_add_buttons.imageAddToolbars
      }),
      createPluginToolbar: (getPluginToolbarBase) => ({
        settings: /* @__PURE__ */ (() => {
          const getElement = () => getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.IMAGE).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SETTINGS_BUTTON)
          );
          return {
            click: async () => {
              const button = await getElement();
              return button.click();
            },
            getElement
          };
        })(),
        delete: /* @__PURE__ */ (() => {
          const getElement = () => getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.IMAGE).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_DELETE_BUTTON)
          );
          return {
            click: async () => {
              const button = await getElement();
              return button.click();
            },
            getElement
          };
        })(),
        openLinkPanel: async () => {
          const button = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.IMAGE).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_LINK_BUTTON)
          );
          await button.click();
        },
        sizeDropdown: /* @__PURE__ */ (() => {
          const getElement = () => getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.IMAGE).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SIZE_BUTTON)
          );
          return {
            click: async () => {
              const dropdown = await getElement();
              return dropdown.click();
            },
            getElement
          };
        })(),
        imageSize: {
          clickSmall: async () => {
            const allignmentButton = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.SIZE_DROPDOWN_OPTION_SMALL));
            await allignmentButton.click();
          }
        },
        exists: async () => {
          try {
            return getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.IMAGE).exists();
          } catch {
            return false;
          }
        },
        setAsHeaderButtonExists: async () => {
          try {
            const button = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.IMAGE).get(
              (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SET_AS_HEADER_BUTTON)
            );
            return button.exists();
          } catch {
            return false;
          }
        },
        clickSetAsHeader: async () => {
          const button = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.IMAGE).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SET_AS_HEADER_BUTTON)
          );
          await button.click();
        },
        setAsFooterButtonExists: async () => {
          try {
            const button = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.IMAGE).get(
              (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SET_AS_FOOTER_BUTTON)
            );
            return button.exists();
          } catch {
            return false;
          }
        },
        clickSetAsFooter: async () => {
          const button = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.IMAGE).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SET_AS_FOOTER_BUTTON)
          );
          await button.click();
        }
      })
    }
  };
};
//# sourceMappingURL=testkit.js.map
