"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, {
  createAiTestkit: () => createAiTestkit
});
module.exports = __toCommonJS(testkit_exports);
var import_unidriver = require("@wix/design-system/dist/testkit/unidriver.js");
var import_dropdown_modal_uni_driver = require("./../_shared/dropdown-modal/dropdown-modal-uni-driver.js");
var import_wix_rich_content_common = require("./../wix-rich-content-common/index.js");
var import_data_hooks = require("./data-hooks.js");
const createAiTestkit = (getBase) => {
  return {
    content: {},
    contentModal: {
      getNativeElement: async () => {
        const modal = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_ROOT));
        return modal.getNative();
      },
      waitForElement: async () => {
        await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_ROOT));
      },
      exists: async () => {
        try {
          const sidePanelDriver = (0, import_unidriver.SidePanelUniDriver)(
            getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_ROOT)),
            getBase()
          );
          return sidePanelDriver.exists();
        } catch {
          return false;
        }
      },
      close: async () => {
        const sidePanelDriver = (0, import_unidriver.SidePanelUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_ROOT)), getBase());
        return sidePanelDriver.clickClose();
      },
      promptInput: (0, import_unidriver.InputAreaUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_PROMPT_INPUT)), getBase()),
      cancelButton: (0, import_unidriver.ButtonUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_CANCEL_BUTTON)), getBase()),
      submitButton: (0, import_unidriver.IconButtonUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_SUBMIT_BUTTON)), getBase()),
      promptsList: {
        atIndex: async (index) => {
          const allListItems = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_PROMPT_LIST_ITEM));
          const listItem = allListItems.at(index);
          return (0, import_unidriver.ListItemActionUniDriver)(listItem, getBase());
        },
        count: async () => {
          try {
            const allListItems = await getBase().getAll((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_PROMPT_LIST_ITEM));
            return allListItems.count();
          } catch {
            return 0;
          }
        }
      },
      loadingIndicator: {
        waitForElement: async () => {
          await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_LOADING_INDICATOR));
        },
        exists: () => getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_LOADING_INDICATOR)).exists()
      },
      result: {
        waitForElement: async () => {
          await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_RESULTS_CONTENT));
        },
        exists: () => {
          return getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_RESULTS_CONTENT)).exists();
        },
        atIndex: (index) => {
          const getContent = async () => {
            return await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_RESULTS_CONTENT));
          };
          return {
            waitForElement: async () => {
              (await getContent()).$$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_RESULTS_CONTENT_ITEM)).at(index);
            },
            content: async () => {
              return (await getContent()).$$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_RESULTS_CONTENT_ITEM)).at(index).text();
            },
            actions: {
              firstActionButton: async () => (0, import_unidriver.ButtonUniDriver)(
                (await getContent()).$$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_RESULTS_FIST_ACTION_BUTTON)).at(index),
                getBase()
              ),
              secondActionButton: async () => (0, import_unidriver.ButtonUniDriver)(
                (await getContent()).$$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_RESULTS_SECOND_ACTION_BUTTON)).at(index),
                getBase()
              ),
              actionsMenuTrigger: async () => (0, import_unidriver.IconButtonUniDriver)(
                (await getContent()).$$(`button${(0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_RESULTS_ACTIONS_POPOVER_TRIGGER)}`).at(index),
                getBase()
              ),
              actionsMenu: async () => (0, import_unidriver.PopoverMenuUniDriver)(
                (await getContent()).$$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_RESULTS_ACTIONS_POPOVER)).at(index),
                getBase()
              )
            }
          };
        }
      },
      error: {
        waitForElement: async () => {
          await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_ERROR_CONTAINER));
        },
        exists: () => getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_ERROR_CONTAINER)).exists(),
        retryButton: (0, import_unidriver.ButtonUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_ERROR_RETRY_BUTTON)), getBase()),
        cancelButton: (0, import_unidriver.ButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_ERROR_CANCEL_BUTTON)),
          getBase()
        )
      },
      noSelectionMessage: {
        waitForElement: async () => {
          await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_NO_SELECTION_CONTAINER));
        },
        exists: () => getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_NO_SELECTION_CONTAINER)).exists()
      }
    },
    imageModal: {
      getNativeElement: async () => {
        const modal = await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_ROOT));
        return modal.getNative();
      },
      waitForElement: async () => {
        await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_ROOT));
      },
      exists: async () => {
        try {
          const sidePanelDriver = (0, import_unidriver.SidePanelUniDriver)(
            getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_ROOT)),
            getBase()
          );
          return sidePanelDriver.exists();
        } catch {
          return false;
        }
      },
      close: async () => {
        const sidePanelDriver = (0, import_unidriver.SidePanelUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_ROOT)),
          getBase()
        );
        return sidePanelDriver.clickClose();
      },
      input: (0, import_unidriver.InputAreaUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_PROMPT_INPUT)), getBase()),
      cancelButton: (0, import_unidriver.ButtonUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_CANCEL_BUTTON)), getBase()),
      submitButton: (0, import_unidriver.ButtonUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_SUBMIT_BUTTON)), getBase()),
      imageStyle: (0, import_unidriver.PopoverMenuUniDriver)(
        getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_IMAGE_STYLE)),
        getBase()
      ),
      promptHelper: {
        popover: (0, import_unidriver.PopoverUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_PROMPT_HELPER_POPOVER)),
          getBase()
        ),
        closeButton: (0, import_unidriver.CloseButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_PROMPT_HELPER_POPOVER_CLOSE)),
          getBase()
        )
      },
      feed: {
        atIndex: (index) => {
          const getContent = async () => {
            return getBase().$$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_FEED_ITEM)).at(index);
          };
          return {
            exists: async () => {
              return (await getContent()).exists();
            },
            waitForElement: async () => {
              await (await getContent()).exists();
            },
            isLoading: async () => {
              return (await getContent()).$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_FEED_LOADER)).exists();
            },
            actions: {
              insertAbove: async () => (0, import_unidriver.ButtonUniDriver)(
                (await getContent()).$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_ACTION_INSERT_ABOVE)),
                getBase()
              ),
              insertBelow: async () => (0, import_unidriver.ButtonUniDriver)(
                (await getContent()).$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_ACTION_INSERT_BELOW)),
                getBase()
              ),
              insert: async () => (0, import_unidriver.ButtonUniDriver)(
                (await getContent()).$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_ACTION_INSERT)),
                getBase()
              )
            }
          };
        }
      },
      error: {
        waitForElement: async () => {
          await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_ERROR_CONTAINER));
        },
        exists: () => getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_ERROR_CONTAINER)).exists(),
        retryButton: (0, import_unidriver.ButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_ERROR_RETRY_BUTTON)),
          getBase()
        ),
        cancelButton: (0, import_unidriver.ButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_IMAGE_MODAL_ERROR_CANCEL_BUTTON)),
          getBase()
        )
      }
    },
    flowSelectionPopover: {
      waitForElement: async () => {
        await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_FLOW_SELECTION_POPOVER));
      },
      popover: (0, import_dropdown_modal_uni_driver.createDropdownModalUniDriver)(getBase, import_data_hooks.AI_FLOW_SELECTION_POPOVER)
    },
    discardModal: (0, import_unidriver.MessageModalLayoutUniDriver)(
      getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_DISCARD_MODAL)),
      getBase()
    ),
    toolbars: {
      createTextButtonToolbars: (getTextButtonToolbarBase) => {
        return {
          click: async () => {
            const button = await getTextButtonToolbarBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.TEXT_BUTTON_AI));
            await button.click();
          }
        };
      }
    },
    popover: {
      waitForElement: async () => {
        await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_MODAL_FLOATING_MENU_POPOVER));
      },
      popover: (0, import_dropdown_modal_uni_driver.createDropdownModalUniDriver)(getBase, import_data_hooks.AI_MODAL_FLOATING_MENU_POPOVER)
    },
    integrations: {
      captionTrigger: {
        button: (0, import_unidriver.IconButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_EXPORTS_CAPTION_TRIGGER_BUTTON)),
          getBase()
        )
      },
      altTextInput: {
        input: {
          waitForElement: async () => {
            await getBase().get((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_EXPORTS_ALT_TEXT_INPUT_AREA));
          },
          ...(0, import_unidriver.InputAreaUniDriver)(getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_EXPORTS_ALT_TEXT_INPUT_AREA)), getBase())
        },
        generateButton: (0, import_unidriver.TextButtonUniDriver)(
          getBase().$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.AI_EXPORTS_ALT_TEXT_GENERATE_BUTTON)),
          getBase()
        )
      }
    }
  };
};
//# sourceMappingURL=testkit.js.map
