"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.dropdownBasePrivateDriverFactory = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _DropdownBaseUni = require("./DropdownBase.uni.driver");
var _DropdownLayoutUni = require("../DropdownLayout/DropdownLayout.uni.driver");
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 dropdownBasePrivateDriverFactory = (base, body) => {
  var byDataHook = dataHook => body.$("[data-hook=\"".concat(dataHook, "\"]"));
  var getDataHook = /*#__PURE__*/function () {
    var _ref = (0, _asyncToGenerator2.default)(function* () {
      return base.attr('data-hook');
    });
    return function getDataHook() {
      return _ref.apply(this, arguments);
    };
  }();
  var _getTargetElement = /*#__PURE__*/function () {
    var _ref2 = (0, _asyncToGenerator2.default)(function* () {
      var dataHook = yield getDataHook();
      return byDataHook("".concat(dataHook, "-trigger"));
    });
    return function getTargetElement() {
      return _ref2.apply(this, arguments);
    };
  }();
  var getContentElement = /*#__PURE__*/function () {
    var _ref3 = (0, _asyncToGenerator2.default)(function* () {
      var dataHook = yield getDataHook();
      return byDataHook("".concat(dataHook, "-content"));
    });
    return function getContentElement() {
      return _ref3.apply(this, arguments);
    };
  }();
  var dropdownLayout = (0, _DropdownLayoutUni.dropdownLayoutDriverFactory)(base, body);
  return _objectSpread(_objectSpread({}, (0, _DropdownBaseUni.dropdownBaseDriverFactory)(base, body)), {}, {
    /** Returns the native target element */
    getTargetElement: function () {
      var _getTargetElement2 = (0, _asyncToGenerator2.default)(function* () {
        return (yield _getTargetElement()).getNative();
      });
      function getTargetElement() {
        return _getTargetElement2.apply(this, arguments);
      }
      return getTargetElement;
    }(),
    /** Returns the native DropdownLayout element */
    getDropdownElement: function () {
      var _getDropdownElement = (0, _asyncToGenerator2.default)(function* () {
        return (yield getContentElement()).getNative();
      });
      function getDropdownElement() {
        return _getDropdownElement.apply(this, arguments);
      }
      return getDropdownElement;
    }(),
    /** Return `true` if the option is hovered by the mouse */
    isOptionHovered: function () {
      var _isOptionHovered = (0, _asyncToGenerator2.default)(function* (index) {
        return dropdownLayout.isOptionHovered(index);
      });
      function isOptionHovered(_x) {
        return _isOptionHovered.apply(this, arguments);
      }
      return isOptionHovered;
    }(),
    /** Return `true` if the option is selected */
    isOptionSelected: function () {
      var _isOptionSelected = (0, _asyncToGenerator2.default)(function* (index) {
        return dropdownLayout.isOptionSelected(index);
      });
      function isOptionSelected(_x2) {
        return _isOptionSelected.apply(this, arguments);
      }
      return isOptionSelected;
    }(),
    /** Trigger a keyDown event on the target element */
    keyDown: function () {
      var _keyDown = (0, _asyncToGenerator2.default)(function* (key) {
        return (yield _getTargetElement()).pressKey(key);
      });
      function keyDown(_x3) {
        return _keyDown.apply(this, arguments);
      }
      return keyDown;
    }(),
    /** Perform a mouseLeave on the target element */
    mouseLeaveTarget: function () {
      var _mouseLeaveTarget = (0, _asyncToGenerator2.default)(function* () {
        return (yield _getTargetElement()).mouse.leave();
      });
      function mouseLeaveTarget() {
        return _mouseLeaveTarget.apply(this, arguments);
      }
      return mouseLeaveTarget;
    }(),
    dropdownLayout,
    keyDownListItem: function () {
      var _keyDownListItem = (0, _asyncToGenerator2.default)(function* (position, key) {
        return dropdownLayout.keyDownListItem(position, key);
      });
      function keyDownListItem(_x4, _x5) {
        return _keyDownListItem.apply(this, arguments);
      }
      return keyDownListItem;
    }(),
    isListItemFocused: function () {
      var _isListItemFocused = (0, _asyncToGenerator2.default)(function* (position) {
        return dropdownLayout.isListItemFocused(position);
      });
      function isListItemFocused(_x6) {
        return _isListItemFocused.apply(this, arguments);
      }
      return isListItemFocused;
    }()
  });
};
exports.dropdownBasePrivateDriverFactory = dropdownBasePrivateDriverFactory;
//# sourceMappingURL=DropdownBase.private.uni.driver.js.map