import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
import _inherits from "@babel/runtime/helpers/inherits";
import _wrapNativeSuper from "@babel/runtime/helpers/wrapNativeSuper";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var tmpResolve;
var tmpReject;

/**
 * Creates a promise where resolve can be manually executed
 */
var ManualPromise = /*#__PURE__*/function (_Promise) {
  function ManualPromise(value) {
    var _this;
    _classCallCheck(this, ManualPromise);
    _this = _callSuper(this, ManualPromise, [function (resolve, reject) {
      tmpResolve = resolve;
      tmpReject = reject;
    }]);
    _defineProperty(_this, "_resolve", function () {});
    _defineProperty(_this, "_reject", function () {});
    _this.value = value;
    _this._resolve = tmpResolve;
    _this._reject = tmpReject;
    return _this;
  }
  _inherits(ManualPromise, _Promise);
  return _createClass(ManualPromise, [{
    key: "resolve",
    value: function resolve(value) {
      this._resolve(value !== null && value !== void 0 ? value : this.value);
      return this;
    }
  }, {
    key: "reject",
    value: function reject(err) {
      this._reject(err !== null && err !== void 0 ? err : new Error('Manually rejected'));
      return this;
    }
  }, {
    key: Symbol.toStringTag,
    get: function get() {
      return 'ManualPromise';
    }
  }], [{
    key: Symbol.species,
    get: function get() {
      return Promise;
    }
  }]);
}( /*#__PURE__*/_wrapNativeSuper(Promise));
export default ManualPromise;