"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = exports.badgeSelectUniDriverFactory = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _unidriver = require("../utils/test-utils/unidriver");
var _BadgeUni = require("../Badge/Badge.uni.driver");
var _PopoverNextUni = require("../PopoverNext/PopoverNext.uni.driver");
var DATA_ATTR = _interopRequireWildcard(require("./DataAttr"));
var _DropdownLayoutUni = require("../DropdownLayout/DropdownLayout.uni.driver");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var badgeSelectUniDriverFactory = (base, body) => {
  var popoverDriver = (0, _PopoverNextUni.popoverNextUniDriverFactory)(base, body);
  var badgeDriver = (0, _BadgeUni.badgeUniDriverFactory)((0, _unidriver.findByHook)(base, DATA_ATTR.DATA_BADGE));
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    exists: () => popoverDriver.exists(),
    /**
     * Clicks an option at given index
     * @param {number} index Position of the option
     * @returns {Promise<void>}
     */
    clickAtOption: function () {
      var _clickAtOption = (0, _asyncToGenerator2.default)(function* (index) {
        yield badgeDriver.click();
        var popoverCommonTestkit = () => (0, _PopoverNextUni.popoverNextUniDriverFactory)(base, body);
        var contentElement = yield popoverCommonTestkit().getContentElementUniDriver();
        var dropdownLayoutDriver = (0, _DropdownLayoutUni.dropdownLayoutDriverFactory)(contentElement.$("[data-hook=\"".concat(DATA_ATTR.DATA_DROPDOWN, "\"]")));
        yield dropdownLayoutDriver.clickAtOption(index);
      });
      function clickAtOption(_x) {
        return _clickAtOption.apply(this, arguments);
      }
      return clickAtOption;
    }(),
    /**
     * Gets badge text
     * @return {Promise<string>}
     */
    text: badgeDriver.text,
    /**
     * Gets badge type
     * @return {Promise<'solid' | 'outlined' | 'transparent'>}
     */
    getType: badgeDriver.getType,
    /**
     * Gets badge type
     * @return {Promise<'general' | 'standard' | 'danger' | 'success' | 'neutral' | 'neutralLight' | 'warning' | 'warningLight' | 'urgent' | 'neutralStandard' | 'neutralSuccess' | 'neutralDanger' | 'premium'>}
     */
    getSkin: badgeDriver.getSkin,
    /**
     * Gets badge size
     * @return {Promise<'medium' | 'small'>}
     */
    getSize: badgeDriver.getSize,
    /**
     * Checks whether the text is uppercase
     * @return {Promise<boolean>}
     */
    isUppercase: badgeDriver.isUppercase,
    /**
     * Checks whether badge is clickable
     * @return {Promise<boolean>}
     */
    hasClickCursor: badgeDriver.hasClickCursor
  });
};
exports.badgeSelectUniDriverFactory = badgeSelectUniDriverFactory;
var _default = exports.default = badgeSelectUniDriverFactory;
//# sourceMappingURL=BadgeSelect.uni.driver.js.map