"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.swatchesDriverFactory = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _FillPreviewUni = require("../FillPreview/FillPreview.uni.driver");
var _constants = require("./constants");
var swatchesDriverFactory = base => {
  var _getSwatch = /*#__PURE__*/function () {
    var _ref = (0, _asyncToGenerator2.default)(function* (index) {
      return base.$$('[data-hook="color-swatches-swatch"]').get(index);
    });
    return function getSwatch(_x) {
      return _ref.apply(this, arguments);
    };
  }();
  var getEmptySwatch = /*#__PURE__*/function () {
    var _ref2 = (0, _asyncToGenerator2.default)(function* () {
      return base.$("[data-hook=\"".concat(_constants.dataHooks.empty, "\"]"));
    });
    return function getEmptySwatch() {
      return _ref2.apply(this, arguments);
    };
  }();
  return {
    exists: function () {
      var _exists = (0, _asyncToGenerator2.default)(function* () {
        return base.exists();
      });
      function exists() {
        return _exists.apply(this, arguments);
      }
      return exists;
    }(),
    /** Get swatch count */
    getSwatchCount: function () {
      var _getSwatchCount = (0, _asyncToGenerator2.default)(function* () {
        return base.$$('[data-hook="color-swatches-swatch"]').count();
      });
      function getSwatchCount() {
        return _getSwatchCount.apply(this, arguments);
      }
      return getSwatchCount;
    }(),
    /** Get swatch at given index */
    getSwatch: function () {
      var _getSwatch2 = (0, _asyncToGenerator2.default)(function* (index) {
        return (0, _FillPreviewUni.fillPreviewDriverFactory)(yield _getSwatch(index));
      });
      function getSwatch(_x2) {
        return _getSwatch2.apply(this, arguments);
      }
      return getSwatch;
    }(),
    /** Click empty swatch */
    clickEmptySwatch: function () {
      var _clickEmptySwatch = (0, _asyncToGenerator2.default)(function* () {
        return (0, _FillPreviewUni.fillPreviewDriverFactory)(yield getEmptySwatch()).click();
      });
      function clickEmptySwatch() {
        return _clickEmptySwatch.apply(this, arguments);
      }
      return clickEmptySwatch;
    }(),
    /** Test if swatch is selected at given index */
    isSwatchSelectedAt: function () {
      var _isSwatchSelectedAt = (0, _asyncToGenerator2.default)(function* (index) {
        return (0, _FillPreviewUni.fillPreviewDriverFactory)(yield _getSwatch(index)).isSelected();
      });
      function isSwatchSelectedAt(_x3) {
        return _isSwatchSelectedAt.apply(this, arguments);
      }
      return isSwatchSelectedAt;
    }(),
    /** Test if empty swatch is selected */
    isEmptySwatchSelected: function () {
      var _isEmptySwatchSelected = (0, _asyncToGenerator2.default)(function* () {
        return (0, _FillPreviewUni.fillPreviewDriverFactory)(yield getEmptySwatch()).isSelected();
      });
      function isEmptySwatchSelected() {
        return _isEmptySwatchSelected.apply(this, arguments);
      }
      return isEmptySwatchSelected;
    }(),
    addButtonExists: function () {
      var _addButtonExists = (0, _asyncToGenerator2.default)(function* () {
        return base.$$('[data-hook="color-preview-add-button"]').count() === 1;
      });
      function addButtonExists() {
        return _addButtonExists.apply(this, arguments);
      }
      return addButtonExists;
    }()
  };
};
exports.swatchesDriverFactory = swatchesDriverFactory;
//# sourceMappingURL=Swatches.uni.driver.js.map