"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, {
  createLinkPreviewTestkit: () => createLinkPreviewTestkit
});
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_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_testkit2 = require("./../plugin-html/testkit.js");
var import_testkit3 = require("./../plugin-link/testkit.js");
var import_testkit4 = require("./../ui-components/testkit.js");
var import_data_hooks2 = require("./data-hooks.js");
var import_get_add_buttons = require("./get-add-buttons.js");
const createLinkPreviewTestkit = (getBase) => {
  const getLinkPreviewContainer = async (index, options) => {
    const previews = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.LINK_PREVIEW_VIEWER), options);
    return previews.at(index);
  };
  const getInsertSocialEmbedModal = async (options) => await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SOCIAL_EMBED_MODAL), options);
  const createInputDriver = (selector) => ({
    ...(0, import_unidriver.InputUniDriver)(getBase().$(selector), getBase()),
    waitForElement: async () => {
      await getBase().$(selector).wait();
    }
  });
  const getSettingsModal = () => getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_MODAL));
  return {
    content: {
      atIndex: (index) => {
        return {
          exists: async (options) => {
            try {
              const preview = await getLinkPreviewContainer(index, options);
              return preview.exists();
            } catch {
              return false;
            }
          },
          click: async () => {
            const linkPreview = await getLinkPreviewContainer(index);
            await linkPreview.click();
          },
          hover: async () => {
            const preview = await getLinkPreviewContainer(index);
            await preview.hover();
          },
          ...(0, import_testkit.createFigureTestkit)(getBase, index)
        };
      },
      socialEmbed: (0, import_testkit2.createHtmlTestkit)(getBase).content,
      linkEmbed: (0, import_testkit3.createLinkTestkit)(getBase).content
    },
    insertSocialEmbedModal: {
      exists: async (options) => {
        try {
          const socialEmbed = await getInsertSocialEmbedModal(options);
          return socialEmbed.exists();
        } catch {
          return false;
        }
      },
      urlInput: (0, import_unidriver.InputUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SOCIAL_EMBED_MODAL_INPUT)), getBase()),
      submitButton: (0, import_unidriver.ButtonUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SOCIAL_EMBED_MODAL_SUBMIT_BTN)),
        getBase()
      )
    },
    settingsModal: {
      ...getSettingsModal(),
      exists: async () => getSettingsModal().exists(),
      waitForElement: async () => {
        await getSettingsModal().wait();
      }
    },
    tabs: {
      ...(0, import_unidriver.TabsUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_TABS)), getBase()),
      waitForElement: async () => {
        const tabs = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_TABS));
        await tabs.wait();
      }
    },
    design: {
      imageDisplayToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_IMAGE_DISPLAY_TOGGLE)),
        getBase()
      ),
      imagePositionLeft: (0, import_unidriver.ThumbnailUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_IMAGE_POSITION_LEFT_THUMBNAIL)),
        getBase()
      ),
      imagePositionTop: (0, import_unidriver.ThumbnailUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_IMAGE_POSITION_TOP_THUMBNAIL)),
        getBase()
      ),
      imagePositionRight: (0, import_unidriver.ThumbnailUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_IMAGE_POSITION_RIGHT_THUMBNAIL)),
        getBase()
      ),
      titleColorPicker: (0, import_unidriver.FillPreviewUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_TITLE_COLOR_PICKER_TRIGGER)),
        getBase()
      ),
      subtitleColorPicker: (0, import_unidriver.FillPreviewUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_SUBTITLE_COLOR_PICKER_TRIGGER)),
        getBase()
      ),
      linkColorPicker: (0, import_unidriver.FillPreviewUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_LINK_COLOR_PICKER_TRIGGER)),
        getBase()
      ),
      backgroundColorPicker: (0, import_unidriver.FillPreviewUniDriver)(
        getBase().$(`${(0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_BACKGROUND_COLOR_TRIGGER)}`),
        getBase()
      ),
      borderColorPicker: (0, import_unidriver.FillPreviewUniDriver)(
        getBase().$(`${(0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_BORDER_COLOR_TRIGGER)}`),
        getBase()
      ),
      borderWidthInput: createInputDriver((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_BORDER_WIDTH_INPUT)),
      cornerRadiusInput: createInputDriver((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.SETTINGS_LINKPREVIEW_CORNER_RADIUS_INPUT)),
      colorPickerModal: (0, import_testkit4.createNewColorPickerUniDriver)(getBase)
    },
    toolbars: {
      createAddButtonToolbars: (getAddButtonToolbarBase) => ({
        clickInstagram: async () => {
          const instagramButton = await getAddButtonToolbarBase().get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_INSTAGRAM_BUTTON)
          );
          await instagramButton.click();
        },
        clickTiktok: async () => {
          const tikTokButton = await getAddButtonToolbarBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_TIKTOK_BUTTON));
          await tikTokButton.click();
        },
        clickTwitter: async () => {
          const twitterButton = await getAddButtonToolbarBase().get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_TWITTER_BUTTON)
          );
          await twitterButton.click();
        },
        toolbarsToAddIn: import_get_add_buttons.toolbarsToAddIn
      }),
      createPluginToolbar: (getPluginToolbarBase) => ({
        openSettingsModal: async () => {
          const settings = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.LINK_PREVIEW).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SETTINGS_BUTTON)
          );
          await settings.click();
        },
        clickConvertToLink: async () => {
          const convertButton = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.EMBED).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.PLUGIN_TOOLBAR_REPLACE_TO_LINK_BUTTON)
          );
          await convertButton.click();
        },
        clickDelete: async () => {
          const deleteButton = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.EMBED).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_DELETE_BUTTON)
          );
          await deleteButton.click();
        },
        exists: async () => {
          const pluginToolbar = getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.EMBED);
          return pluginToolbar.exists();
        }
      })
    }
  };
};
//# sourceMappingURL=testkit.js.map
