"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 button_testkit_exports = {};
__export(button_testkit_exports, {
  createButtonTestkit: () => createButtonTestkit
});
module.exports = __toCommonJS(button_testkit_exports);
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");
var import_button_settings_uni_driver = require("./button-settings.uni.driver.js");
const createButtonTestkit = (buttonType, tag) => (getBase) => {
  const getButton = async (index, options) => {
    const button = await getBase().getAll(`${tag}${(0, import_wix_rich_content_common.dataHook)(import_data_hooks2.ROOT)}`, options);
    return button.at(index);
  };
  return {
    content: {
      atIndex: (index) => {
        return {
          exists: async (options) => {
            try {
              const button = await getButton(index, options);
              return button.exists();
            } catch {
              return false;
            }
          },
          click: async () => (await getButton(index)).click(),
          getText: async () => (await getButton(index)).text(),
          getLink: async () => (await getButton(index)).attr("href"),
          getStyles: async () => {
            const btn = await getButton(index);
            return await btn.attr("style");
          },
          getNativeElement: async () => {
            const file = await getButton(index);
            return file.getNative();
          }
        };
      }
    },
    toolbars: {
      createAddButtonToolbars: (getAddButtonToolbarBase) => ({
        click: async () => {
          const buttonPluginButton = await getAddButtonToolbarBase().get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_BUTTON_BUTTON)
          );
          await buttonPluginButton.click();
        },
        toolbarsToAddIn: import_get_add_buttons.toolbarsToAddIn
      }),
      createPluginToolbar: (getPluginToolbarBase) => ({
        openSettingsModal: async () => {
          const settings = await getPluginToolbarBase(buttonType).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_SETTINGS_BUTTON)
          );
          await settings.click();
        },
        openLinkModal: async () => {
          const link = await getPluginToolbarBase(buttonType).get(
            (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_LINK_BUTTON)
          );
          await link.click();
        },
        clickDelete: async () => {
          await (await getPluginToolbarBase(buttonType).get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_DELETE_BUTTON))).click();
        },
        clickAlignmentDropdown: async () => {
          await (await getPluginToolbarBase(buttonType).get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_ALIGNMENT_BUTTON))).click();
        },
        alignment: {
          clickLeft: async () => {
            await (await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.ALIGNMENT_DROPDOWN_OPTION_LEFT), {
              timeout: 5e3
            })).click();
          },
          toggleTextWrap: async () => {
            await (await getBase().get((0, import_wix_rich_content_common.dataHook)("toggle-switch-input"), {
              timeout: 5e3
            })).click();
          },
          isToggleTextWrapDisabled: async () => {
            return await (await getBase().get((0, import_wix_rich_content_common.dataHook)("toggle-switch-input"), {
              timeout: 5e3
            })).attr("readonly") !== null;
          }
        },
        exists: async () => {
          try {
            return getPluginToolbarBase(buttonType).exists();
          } catch {
            return false;
          }
        }
      })
    },
    ...(0, import_button_settings_uni_driver.createButtonSettingsUniDriver)(getBase)
  };
};
//# sourceMappingURL=button.testkit.js.map
