"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.mediaOverlayDriverFactory = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _unidriver = require("../utils/test-utils/unidriver");
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 mediaOverlayDriverFactory = base => {
  var getMediaUrl = /*#__PURE__*/function () {
    var _ref = (0, _asyncToGenerator2.default)(function* () {
      var style = yield base.attr('style');
      var matches = style && style.match(/url\("?([^"]*)"?\)/);
      return matches ? matches[1] : null;
    });
    return function getMediaUrl() {
      return _ref.apply(this, arguments);
    };
  }();
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    /** Hover on element. */
    hover: function () {
      var _hover = (0, _asyncToGenerator2.default)(function* () {
        return yield base.hover();
      });
      function hover() {
        return _hover.apply(this, arguments);
      }
      return hover;
    }(),
    /** Get media URL value. */
    getMediaUrl,
    /** Get custom media element node. */
    getMediaNode: function () {
      var _getMediaNode = (0, _asyncToGenerator2.default)(function* () {
        var mediaUrl = yield getMediaUrl();
        if (mediaUrl !== null) {
          return null;
        }
        return yield base.$(':first-child').getNative();
      });
      function getMediaNode() {
        return _getMediaNode.apply(this, arguments);
      }
      return getMediaNode;
    }(),
    /** Get default state skin. */
    getSkin: function () {
      var _getSkin = (0, _asyncToGenerator2.default)(function* () {
        return yield base.attr('data-skin');
      });
      function getSkin() {
        return _getSkin.apply(this, arguments);
      }
      return getSkin;
    }(),
    /** Get hover state skin. */
    getHoverSkin: function () {
      var _getHoverSkin = (0, _asyncToGenerator2.default)(function* () {
        return yield base.attr('data-hoverskin');
      });
      function getHoverSkin() {
        return _getHoverSkin.apply(this, arguments);
      }
      return getHoverSkin;
    }()
  });
};
exports.mediaOverlayDriverFactory = mediaOverlayDriverFactory;
//# sourceMappingURL=MediaOverlay.uni.driver.js.map