"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.tooltipLegacyDriverFactory = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _Popover = require("../Popover/Popover.driver");
var tooltipLegacyDriverFactory = _ref => {
  var {
    element,
    eventTrigger
  } = _ref;
  var popoverDriver = (0, _Popover.popoverLegacyDriverFactory)({
    element,
    eventTrigger
  });
  return {
    /** returns true if trigger element exists on the DOM */
    exists: function () {
      var _exists = (0, _asyncToGenerator2.default)(function* () {
        return popoverDriver.exists();
      });
      function exists() {
        return _exists.apply(this, arguments);
      }
      return exists;
    }(),
    /** returns true if tooltip element exists on the DOM */
    tooltipExists: function () {
      var _tooltipExists = (0, _asyncToGenerator2.default)(function* () {
        return popoverDriver.isContentElementExists();
      });
      function tooltipExists() {
        return _tooltipExists.apply(this, arguments);
      }
      return tooltipExists;
    }(),
    /** mouse over the target element */
    mouseEnter: function () {
      var _mouseEnter = (0, _asyncToGenerator2.default)(function* () {
        return popoverDriver.mouseEnter();
      });
      function mouseEnter() {
        return _mouseEnter.apply(this, arguments);
      }
      return mouseEnter;
    }(),
    /** mouse leaves the target element */
    mouseLeave: function () {
      var _mouseLeave = (0, _asyncToGenerator2.default)(function* () {
        return popoverDriver.mouseLeave();
      });
      function mouseLeave() {
        return _mouseLeave.apply(this, arguments);
      }
      return mouseLeave;
    }(),
    /** clicks outside the tooltip target */
    clickOutside: function () {
      var _clickOutside = (0, _asyncToGenerator2.default)(function* () {
        return popoverDriver.clickOutside();
      });
      function clickOutside() {
        return _clickOutside.apply(this, arguments);
      }
      return clickOutside;
    }(),
    /** returns tooltips content value in string */
    getTooltipText: () => {
      popoverDriver.mouseEnter();
      try {
        var _popoverDriver$getCon;
        var text = (_popoverDriver$getCon = popoverDriver.getContentElement()) == null ? void 0 : _popoverDriver$getCon.textContent;
        // Clean yourself!
        popoverDriver.mouseLeave();
        return text;
      } catch (e) {
        return null;
      }
    },
    /**
     * Checks whether tooltip has a given size
     * @param {boolean} sizeName The tooltip size
     * @return {Promise<boolean>}
     */
    hasSize: sizeName => (element == null ? void 0 : element.getAttribute('data-size')) === sizeName
  };
};
exports.tooltipLegacyDriverFactory = tooltipLegacyDriverFactory;
//# sourceMappingURL=Tooltip.driver.js.map