"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, {
  createHtmlTestkit: () => createHtmlTestkit
});
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_prompt_input_area_unidriver = require("./../_shared/prompt-input-area/prompt-input-area-unidriver.js");
var import_wix_rich_content_common = require("./../wix-rich-content-common/index.js");
var import_testkit = require("./../ui-components/testkit.js");
var import_data_hooks2 = require("./data-hooks.js");
var import_get_add_buttons = require("./get-add-buttons.js");
const createHtmlTestkit = (getBase) => {
  const getHtml = async (index, options) => {
    const html = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.HTML_VIEWER_ROOT), options);
    return html.at(index);
  };
  const getIframe = async (index) => {
    const iframe = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.IFRAME_COMPONENT));
    return iframe.at(index);
  };
  const getAiWidget = async () => {
    return getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.AI_WIDGET_HTML_VIEWER));
  };
  return {
    content: {
      atIndex: (index) => {
        return {
          exists: async (options) => {
            try {
              const html = await getHtml(index, options);
              return html.exists();
            } catch {
              return false;
            }
          },
          getSrc: async () => (await getIframe(index)).attr("src"),
          getIframeNativeElement: async () => {
            const iframe = await getIframe(index);
            return iframe.getNative();
          },
          click: async () => {
            const html = await getHtml(index);
            await html.click();
          }
        };
      }
    },
    aiWidget: {
      promptInput: (0, import_prompt_input_area_unidriver.createPromptInputAreaUniDriver)(getBase, import_data_hooks2.PROMPT_INPUT_AREA),
      exists: async () => {
        try {
          return (await getAiWidget()).exists();
        } catch {
          return false;
        }
      },
      click: async () => {
        const widget = await getAiWidget();
        await widget.click();
      }
    },
    editHeightModal: {
      autoHeightToggle: (0, import_unidriver.ToggleSwitchUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.HTML_HEIGHT_AUTOHEIGHT_TOGGLE)),
        getBase()
      ),
      slider: (0, import_unidriver.SliderUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.HTML_DIMENSIONS_SLIDER)), getBase()),
      heightInput: (0, import_unidriver.NumberInputUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.HTML_DIMENSIONS_INPUT)), getBase()),
      waitForElement: async () => {
        const el = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.HTML_SLIDER_MODAL));
        await el.wait();
      }
    },
    editHtmlModal: {
      typeSegmentedToggle: (0, import_unidriver.SegmentedToggleUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.EDIT_PANEL_SEGMENTED_TOGGLE)),
        getBase()
      ),
      htmlInputArea: (0, import_unidriver.InputAreaUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.EDIT_PANEL_HTML_INPUT)), getBase()),
      urlInput: (0, import_unidriver.InputUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.EDIT_PANEL_URL_INPUT)), getBase()),
      waitForElement: async () => {
        const el = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.EDIT_PANEL));
        await el.wait();
      },
      ...(0, import_testkit.createFooterActionsUnidriver)(getBase)
    },
    toolbars: {
      createAddButtonToolbars: (getAddButtonBase) => ({
        clickHtml: async () => {
          const htmlButton = await getAddButtonBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_HTML_BUTTON));
          await htmlButton.click();
        },
        clickAdsense: async () => {
          const adsenseButton = await getAddButtonBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks2.INSERT_ADSENSE_BUTTON));
          await adsenseButton.click();
        },
        toolbarsToAddIn: import_get_add_buttons.toolbarsToAddIn
      }),
      createPluginToolbar: (getPluginToolbarBase) => {
        return {
          exists: async () => {
            try {
              return getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.HTML).exists();
            } catch {
              return false;
            }
          },
          clickEditHtml: async () => {
            const editHTMLButton = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.HTML).get(
              (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.PLUGIN_TOOLBAR_EDIT_HTML_BUTTON)
            );
            await editHTMLButton.click();
          },
          clickDelete: async () => {
            const deleteButton = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.HTML).get(
              (0, import_wix_rich_content_common.dataHook)(import_data_hooks.PLUGIN_TOOLBAR_DELETE_BUTTON)
            );
            await deleteButton.click();
          },
          clickEditHeight: async () => {
            const heightButton = await getPluginToolbarBase(import_ricos_types.RicosPluginToolbarNames.HTML).get(
              (0, import_wix_rich_content_common.dataHook)(import_data_hooks2.PLUGIN_TOOLBAR_CONTAINER_HEIGHT_BUTTON)
            );
            await heightButton.click();
          }
        };
      }
    }
  };
};
//# sourceMappingURL=testkit.js.map
