"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 dropdown_modal_uni_driver_exports = {};
__export(dropdown_modal_uni_driver_exports, {
  createDropdownModalUniDriver: () => createDropdownModalUniDriver
});
module.exports = __toCommonJS(dropdown_modal_uni_driver_exports);
var import_wix_rich_content_common = require("./../../wix-rich-content-common/index.js");
var import_data_hooks = require("../list-item-select/data-hooks.js");
var import_list_item_select_uni_driver = require("../list-item-select/list-item-select-uni-driver.js");
var import_data_hooks2 = require("./data-hooks.js");
const createDropdownModalUniDriver = (getBase, dropdownDataHook = import_data_hooks2.TOOLBAR_DROPDOWN_PANEL) => {
  const getDropdownModal = async () => getBase().$((0, import_wix_rich_content_common.dataHook)(dropdownDataHook));
  return {
    exists: async () => (await getDropdownModal()).exists(),
    waitForElement: async () => {
      await getBase().$((0, import_wix_rich_content_common.dataHook)(dropdownDataHook));
    },
    optionAtIndex: async (index) => {
      const dropdownModal = await getDropdownModal();
      const options = await dropdownModal.$$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.LIST_ITEM_SELECT));
      return (0, import_list_item_select_uni_driver.createListItemSelectDriver)(() => options.at(index));
    },
    optionByValue: async (value) => {
      const dropdownModal = await getDropdownModal();
      const options = await dropdownModal.$$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.LIST_ITEM_SELECT));
      const optionsByValue = options.filter(async (option) => {
        const listItem = (0, import_list_item_select_uni_driver.createListItemSelectDriver)(() => option);
        const title = await listItem.getTitle();
        return title.includes(value);
      });
      return (0, import_list_item_select_uni_driver.createListItemSelectDriver)(() => optionsByValue.at(0));
    },
    optionByDataHook: async (hook) => {
      const dropdownModal = await getDropdownModal();
      const option = dropdownModal.$(`[data-hook~="${hook}"]`);
      return (0, import_list_item_select_uni_driver.createListItemSelectDriver)(() => option);
    },
    getNativeElement: async () => {
      const dropdownModal = await getDropdownModal();
      return dropdownModal.getNative();
    },
    getSelectedOption: async () => {
      const dropdownModal = await getDropdownModal();
      const options = await dropdownModal.$$((0, import_wix_rich_content_common.dataHook)(import_data_hooks.LIST_ITEM_SELECT));
      const selectedOptions = options.filter(async (option) => {
        const listItem = (0, import_list_item_select_uni_driver.createListItemSelectDriver)(() => option);
        const isSelected = await listItem.isSelected();
        return isSelected;
      });
      return (0, import_list_item_select_uni_driver.createListItemSelectDriver)(() => selectedOptions.at(0));
    }
  };
};
//# sourceMappingURL=dropdown-modal-uni-driver.js.map
