"use strict";

exports.__esModule = true;
exports.PickerModalUniDriver = PickerModalUniDriver;
exports.default = void 0;
var _unidriver = require("@wix/wix-ui-test-utils/unidriver");
var _unidriver2 = require("../../unidriver");
var _PickerUni = require("../Picker/Picker.uni.driver");
var _unidriver3 = require("@wix/design-system/dist/testkit/unidriver");
var _PickerModalLayoutUni = require("./PickerModalLayout.uni.driver");
function PickerModalUniDriver(base, body, {
  dataHook
} = {}) {
  const modalBase = () => body.$(dataHook ? `.portal-${dataHook}-picker-modal` : '.portal-picker-modal-lazy-modal');
  const modal = () => (0, _unidriver3.ModalUniDriver)(modalBase(), modalBase());
  const layout = () => (0, _PickerModalLayoutUni.PickerModalLayoutUniDriver)(modalBase(), body);
  const picker = () => (0, _PickerUni.PickerUniDriver)(modalBase().$('[data-hook="picker"]'), body);
  const additionalStepDriver = () => {
    return {
      title: () => (0, _unidriver3.TextUniDriver)(modalBase().$('[data-hook="title"]'), body).getText(),
      subtitle: () => (0, _unidriver3.TextUniDriver)(modalBase().$('[data-hook="subtitle"]'), body).getText(),
      suffixText: () => (0, _unidriver3.TextUniDriver)(modalBase().$('[data-hook="suffix-text"]'), body).getText(),
      suffixNode: () => modalBase().$('[data-hook="suffix-node"]')
    };
  };
  const getNoResultsSubtitle = () => (0, _unidriver3.TextUniDriver)(body.$('[data-hook="picker-no-results-state-subtitle"]'), body);
  const getNoResultsResetButton = () => (0, _unidriver3.TextButtonUniDriver)(body.$('[data-hook="picker-no-results-state-reset-button"]'), body);
  return {
    ...(0, _unidriver2.baseUniDriverFactory)(base),
    isOpen: () => modal().isOpen(),
    wait: timeout => base.wait(timeout),
    modalLayoutExists: () => layout().exists(),
    pickerExists: () => picker().exists(),
    waitPicker: timeout => picker().wait(timeout),
    waitModalClosed: timeout => (0, _unidriver.waitFor)(async () => !(await picker().exists()), timeout),
    /** Indicates whether the modal is open */
    isModalOpen: () => modal().isOpen(),
    /** Get the modal layout title text */
    getTitleText: () => layout().getTitleText(),
    /** Get the modal layout subtitle text */
    getSubtitleText: () => layout().getSubtitleText(),
    /** Clear the search input */
    clearSearchTerm: () => layout().clearSearchTerm(),
    /** Enter a value to the search input */
    enterSearchTerm: value => layout().enterSearchTerm(value),
    /** Get the value of the search input  */
    getSearchTerm: () => layout().getSearchTerm(),
    /** Get the placeholder of the search input */
    getSearchPlaceholder: () => layout().getSearchPlaceholder(),
    searchExists: () => layout().searchExists(),
    waitSearchLoader: timeout => picker().waitSearchLoader(timeout),
    waitSearchLoaderRemoved: timeout => picker().waitSearchLoaderRemoved(timeout),
    floatingNotificationExists: () => picker().floatingNotificationExists(),
    /**
     * Get the text of the floating notification at the top of the list
     */
    getFloatingNotificationText: () => picker().getFloatingNotificationText(),
    waitInitialLoader: timeout => layout().waitInitialLoader(timeout),
    waitInitialLoaderRemoved: timeout => layout().waitInitialLoaderRemoved(timeout),
    /** Get the number of rows currently rendered inside the selector list */
    numberOfItemsInList: () => picker().numberOfItemsInList(),
    /** Get the number of selected rows */
    getTotalSelected: () => picker().getTotalSelected(),
    /**
     * Triggers "scroll" event on the list.
     */
    scrollDown: () => picker().scrollDown(),
    /**
     * Toggles selector of the item at the passed index.
     * @param {number} index Item index
     * @returns {Promise<void>} Resolves when selector is toggled.
     */
    toggleSelectorAt: index => picker().toggleSelectorAt(index),
    /**
     * Checks whether the selector of the item at the passed index is checked.
     * @param {number} index Item index
     * @returns {Promise<boolean>}
     */
    isSelectorCheckedAt: index => picker().isSelectorCheckedAt(index),
    /**
     * Checks whether the item at the passed index is disabled.
     * @param {number} index Item index
     * @returns {Promise<boolean>}
     */
    isListItemDisabledAt: index => picker().isListItemDisabledAt(index),
    /**
     * Wait for a item to be added to the list
     * @param index
     * @param timeout
     */
    waitListItemAt: (index, timeout) => picker().waitListItemAt(index, timeout),
    /**
     * Get the title text of a list item
     * @param index
     */
    getTitleTextAt: index => picker().getTitleTextAt(index),
    /** Indicates whether item checkbox is in indeterminate mode  */
    isIndeterminateAt: index => picker().isIndeterminateAt(index),
    /**
     * Get the sub-title text of a list item
     * @param index
     */
    getSubtitleTextAt: index => picker().getSubtitleTextAt(index),
    /**
     * Get the image element of a list item
     * @param index
     */
    getImageElementAt: index => picker().getImageElementAt(index),
    /**
     * Get the extra node element of a list item
     * @param index
     */
    getExtraNodeElementAt: index => picker().getExtraNodeElementAt(index),
    /**
     * Get the tooltip toggle text of a list item
     * @param index
     */
    getToggleTooltipTextAt: index => picker().getToggleTooltipTextAt(index),
    /**
     * Indicates whether the initial loader of the modal is shown
     */
    initialLoaderExists: () => layout().initialLoaderExists(),
    /** Get empty state within the modal that by a specific data hook */
    getEmptyStateByDataHook: dataHook => picker().getEmptyStateByDataHook(dataHook),
    /** Indicates whether the loader after search exists */
    searchLoaderExists: () => picker().searchLoaderExists(),
    /** Indicates whether the CTA button exists */
    ctaButtonExists: () => layout().ctaButtonExists(),
    /** Click the CTA button of the modal */
    clickCTAButton: () => layout().clickCTAButton(),
    /** Click the back button on the additional step */
    clickBackButton: () => layout().clickBackButton(),
    /** Indicates whether the back button exists on the additional step */
    backButtonExists: () => layout().backButtonExists(),
    /** Get the text of the suffix content if exists on the additional step */
    additionalStepSuffixText: () => additionalStepDriver().suffixText(),
    /** Get the node of the suffix content if exists on the additional step */
    additionalStepSuffixNode: () => additionalStepDriver().suffixNode(),
    /** Get the text of the item title on the additional step */
    additionalStepTitleText: () => additionalStepDriver().title(),
    /** Get the text of the item subtitle on the additional step */
    additionalStepSubtitleText: () => additionalStepDriver().subtitle(),
    /** Click modal cancel button **/
    clickCancelButton: () => layout().clickCancelButton(),
    /** Get the text of the cancel button */
    getCancelButtonText: () => layout().getCancelButtonText(),
    /** Indicates whether the cancel button exists */
    cancelButtonExists: () => layout().cancelButtonExists(),
    /** Click modal close (x) button **/
    clickCloseButton: () => layout().clickCloseButton(),
    /** Get the text of the CTA button */
    getCTAButtonText: () => layout().getCTAButtonText(),
    /** Indicates whether the CTA button is disabled */
    isCTAButtonDisabled: () => layout().isCTAButtonDisabled(),
    /** Get the error state before the modal content is fetched */
    getSplashErrorStateByDataHook: dataHook => layout().getErrorStateByDataHook(dataHook),
    /** Get the error state within the modal content */
    getErrorStateByDataHook: dataHook => picker().getEmptyStateByDataHook(dataHook),
    customContentButtonExists: () => layout().customContentButtonExists(),
    getCustomContentButtonText: () => layout().getCustomContentButtonText(),
    isCustomContentButtonDisabled: () => layout().isCustomContentButtonDisabled(),
    customContentButtonTooltipExists: () => layout().customContentButtonTooltipExists(),
    getCustomContentButtonTooltipText: () => layout().getCustomContentButtonTooltipText(),
    clickCustomContentButton: () => layout().clickCustomContentButton(),
    getMaxSelectionLabelText: () => layout().getMaxSelectionLabelText(),
    getSelectAllCheckbox: () => layout().getSelectAllCheckbox(),
    getSelectedItemsCountText: () => layout().getSelectedItemsCountText(),
    customNotificationExists: () => layout().customNotificationExists(),
    getFilterDropdown: filterName => layout().getFilterDropdown(filterName),
    filterDropdownExists: filterName => layout().filterDropdownExists(filterName),
    getSelectedFilterName: filterName => layout().getSelectedFilterName(filterName),
    selectFilterItem: (filterName, index) => layout().selectFilterItem(filterName, index),
    selectFilterItems: (filterName, ids) => layout().selectFilterItems(filterName, ids),
    getNoResultsSubtitle,
    getNoResultsResetButton
  };
}
var _default = exports.default = PickerModalUniDriver;
//# sourceMappingURL=PickerModal.uni.driver.js.map