"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.loaderUniDriverFactory = 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 _TooltipUni = require("../Tooltip/Tooltip.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 getTextElement = element => element.$("[data-hook=\"loader-text\"]");
var getStatusIndicatorElement = element => element.$("[data-hook=\"loader-status-indicator\"]");
var loaderUniDriverFactory = (base, body) => {
  var tooltipSelector = '[data-hook="loader-tooltip"]';
  var tooltipTestkit = () => (0, _TooltipUni.tooltipDriverFactory)(base.$(tooltipSelector), body);
  return _objectSpread(_objectSpread({}, (0, _unidriver.baseUniDriverFactory)(base)), {}, {
    /** @deprecated Should be private */
    component: function () {
      var _component = (0, _asyncToGenerator2.default)(function* () {
        return base.getNative();
      });
      function component() {
        return _component.apply(this, arguments);
      }
      return component;
    }(),
    /** returns the loader color ('blue' or 'white') */
    getColor: function () {
      var _getColor = (0, _asyncToGenerator2.default)(function* () {
        return base.attr('data-color');
      });
      function getColor() {
        return _getColor.apply(this, arguments);
      }
      return getColor;
    }(),
    /** returns the element text */
    getText: function () {
      var _getText = (0, _asyncToGenerator2.default)(function* () {
        return getTextElement(base).text();
      });
      function getText() {
        return _getText.apply(this, arguments);
      }
      return getText;
    }(),
    /** true if the element has text */
    hasText: function () {
      var _hasText = (0, _asyncToGenerator2.default)(function* () {
        return getTextElement(base).exists();
      });
      function hasText() {
        return _hasText.apply(this, arguments);
      }
      return hasText;
    }(),
    /** true if the status indicator is rendered */
    statusIndicatorExists: function () {
      var _statusIndicatorExists = (0, _asyncToGenerator2.default)(function* () {
        return getStatusIndicatorElement(base).exists();
      });
      function statusIndicatorExists() {
        return _statusIndicatorExists.apply(this, arguments);
      }
      return statusIndicatorExists;
    }(),
    /** true when using the large loader */
    isLarge: function () {
      var _isLarge = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-size')) === 'large';
      });
      function isLarge() {
        return _isLarge.apply(this, arguments);
      }
      return isLarge;
    }(),
    /** true when using the medium loader */
    isMedium: function () {
      var _isMedium = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-size')) === 'medium';
      });
      function isMedium() {
        return _isMedium.apply(this, arguments);
      }
      return isMedium;
    }(),
    /** true when using the small loader */
    isSmall: function () {
      var _isSmall = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-size')) === 'small';
      });
      function isSmall() {
        return _isSmall.apply(this, arguments);
      }
      return isSmall;
    }(),
    /** true when using the tiny loader */
    isTiny: function () {
      var _isTiny = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-size')) === 'tiny';
      });
      function isTiny() {
        return _isTiny.apply(this, arguments);
      }
      return isTiny;
    }(),
    /** true when loader is in loading status */
    isLoading: function () {
      var _isLoading = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-status')) === 'loading';
      });
      function isLoading() {
        return _isLoading.apply(this, arguments);
      }
      return isLoading;
    }(),
    /** true when loader is in loading-with-errors status */
    isLoadingWithErrors: function () {
      var _isLoadingWithErrors = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-status')) === 'loadingWithErrors';
      });
      function isLoadingWithErrors() {
        return _isLoadingWithErrors.apply(this, arguments);
      }
      return isLoadingWithErrors;
    }(),
    /** true when loader is in error status */
    isError: function () {
      var _isError = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-status')) === 'error';
      });
      function isError() {
        return _isError.apply(this, arguments);
      }
      return isError;
    }(),
    /** true when loader is in success status */
    isSuccess: function () {
      var _isSuccess = (0, _asyncToGenerator2.default)(function* () {
        return (yield base.attr('data-status')) === 'success';
      });
      function isSuccess() {
        return _isSuccess.apply(this, arguments);
      }
      return isSuccess;
    }(),
    /** trigger the tooltip and returns the value of the tooltip message (async function) */
    getStatusMessage: function () {
      var _getStatusMessage = (0, _asyncToGenerator2.default)(function* () {
        var tooltipDriver = tooltipTestkit();
        yield tooltipDriver.mouseEnter();
        return tooltipDriver.getTooltipText();
      });
      function getStatusMessage() {
        return _getStatusMessage.apply(this, arguments);
      }
      return getStatusMessage;
    }()
  });
};
exports.loaderUniDriverFactory = loaderUniDriverFactory;
//# sourceMappingURL=Loader.uni.driver.js.map