"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = void 0;
var _unidriver = require("../../unidriver");
var _unidriver2 = require("@wix/design-system/dist/testkit/unidriver");
var _ManageTagsModalUni = require("../Tags/ManageTags/ManageTagsModal/ManageTagsModal.uni.driver");
var _CardContainerUni = _interopRequireDefault(require("../CardContainer/CardContainer.uni.driver"));
var _default = (base, body) => {
  const cardHeader = () => (0, _unidriver2.CardHeaderUniDriver)(base.$(`[data-hook="tags-widget-card-header"]`), base);
  const multiSelect = () => (0, _unidriver2.MultiSelectUniDriver)(base.$(`[data-hook="tags-widget-multi-select"]`), body);
  const manageTagsButton = () => {
    return (0, _unidriver2.ButtonUniDriver)(base.$(`[data-hook="manage-tags-cta"]`), body);
  };
  const assignTagsButton = () => {
    return (0, _unidriver2.TextButtonUniDriver)(base.$(`[data-hook="assign-tags-cta"]`), body);
  };
  const manageTagsModal = () => (0, _ManageTagsModalUni.ManageTagsModalUniDriver)(base, body);
  const cardContainer = () => (0, _CardContainerUni.default)(base, body);
  const getTagById = tagId => multiSelect().driver.getTagDriverByTagId(tagId);
  const selectOptionById = tagId => multiSelect().driver.selectOptionById(tagId);
  const readOnlyEmptyStateText = () => (0, _unidriver2.TextUniDriver)(base.$(`[data-hook="tags-widget-readonly-empty-state"]`), body);
  const getReadOnlyTagAt = index => (0, _unidriver2.TagUniDriver)(base.$$(`[data-hook="tags-widget-tag"]`).at(index), body);
  const numberOfReadOnlyTags = () => base.$$(`[data-hook="tags-widget-tag"]`).count();
  const inlineErrorText = () => {
    return (0, _unidriver2.TextUniDriver)(base.$(`[data-hook="tags-widget-error-text"]`), body);
  };
  const inlineRetryButton = () => {
    return (0, _unidriver2.TextButtonUniDriver)(base.$(`[data-hook="tags-widget-retry-button"]`), body);
  };
  return {
    manageTagsModal,
    modalExists: () => manageTagsModal().exists(),
    cardHeader: () => cardHeader(),
    title: () => cardHeader().title(),
    subtitle: () => cardHeader().subtitle(),
    inputPlaceholder: () => multiSelect().inputDriver.getPlaceholder(),
    numberOfTags: () => multiSelect().driver.numberOfTags(),
    optionsLength: () => multiSelect().dropdownLayoutDriver.optionsLength(),
    removeTag: async tagId => {
      const tag = await getTagById(tagId);
      await tag.removeTag();
    },
    optionContentAt: index => multiSelect().dropdownLayoutDriver.optionContentAt(index),
    clickAtOption: index => multiSelect().dropdownLayoutDriver.clickAtOption(index),
    enterText: text => multiSelect().inputDriver.enterText(text),
    getTagLabelAt: index => multiSelect().driver.getTagLabelAt(index),
    customSuffixExists: () => multiSelect().driver.customSuffixExists(),
    selectOptionById,
    selectAddTagOption: () => selectOptionById('add-item-option'),
    dropdownLayout: () => multiSelect().dropdownLayoutDriver,
    manageTagsButtonExists: () => manageTagsButton().exists(),
    clickManageTagsButton: () => manageTagsButton().click(),
    clickAssignTagsButton: () => assignTagsButton().click(),
    focus: () => multiSelect().inputDriver.focus(),
    blur: () => multiSelect().inputDriver.blur(),
    /** Returns the error state subtitle */
    getErrorSubtitle: () => cardContainer().getErrorState().getSubtitleText(),
    /** Clicks on try again button when error state visible */
    clickTryAgain: () => cardContainer().getErrorState().getRetryButton().click(),
    /** Gets try again button text */
    getTryAgainContent: () => cardContainer().getErrorState().getRetryButton().getButtonTextContent(),
    showsSkeletonHeader: () => cardContainer().showsSkeletonHeader(),
    getReadOnlyEmptyStateContent: () => readOnlyEmptyStateText().getText(),
    getReadOnlyTagAt,
    numberOfReadOnlyTags,
    /** Returns the error text */
    getInlineErrorText: () => inlineErrorText().getText(),
    /** Clicks on try again button when error state visible */
    clickInlineTryAgain: () => inlineRetryButton().click(),
    /** Gets try again button text */
    getInlineTryAgainText: () => inlineRetryButton().getButtonTextContent(),
    /** Return true id skeleton os shown */
    showsInlineSkeleton: () => base.$('[data-hook="tags-widget-skeleton"]').exists(),
    ...(0, _unidriver.baseUniDriverFactory)(base)
  };
};
exports.default = _default;
//# sourceMappingURL=TagsWidget.uni.driver.js.map