{"ast":null,"code":"import _inherits from \"C:/Users/kgamal/Downloads/HijriGregorianDatepicker-master/HijriGregorianDatepicker-master/node_modules/@babel/runtime/helpers/esm/inherits\";\nimport _createSuper from \"C:/Users/kgamal/Downloads/HijriGregorianDatepicker-master/HijriGregorianDatepicker-master/node_modules/@babel/runtime/helpers/esm/createSuper\";\nimport _classCallCheck from \"C:/Users/kgamal/Downloads/HijriGregorianDatepicker-master/HijriGregorianDatepicker-master/node_modules/@babel/runtime/helpers/esm/classCallCheck\";\nimport _createClass from \"C:/Users/kgamal/Downloads/HijriGregorianDatepicker-master/HijriGregorianDatepicker-master/node_modules/@babel/runtime/helpers/esm/createClass\";\nimport { SimpleOuterSubscriber, innerSubscribe, SimpleInnerSubscriber } from '../innerSubscribe';\nexport var defaultThrottleConfig = {\n  leading: true,\n  trailing: false\n};\nexport function throttle(durationSelector) {\n  var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultThrottleConfig;\n  return function (source) {\n    return source.lift(new ThrottleOperator(durationSelector, !!config.leading, !!config.trailing));\n  };\n}\n\nvar ThrottleOperator = /*#__PURE__*/function () {\n  function ThrottleOperator(durationSelector, leading, trailing) {\n    _classCallCheck(this, ThrottleOperator);\n\n    this.durationSelector = durationSelector;\n    this.leading = leading;\n    this.trailing = trailing;\n  }\n\n  _createClass(ThrottleOperator, [{\n    key: \"call\",\n    value: function call(subscriber, source) {\n      return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));\n    }\n  }]);\n\n  return ThrottleOperator;\n}();\n\nvar ThrottleSubscriber = /*#__PURE__*/function (_SimpleOuterSubscribe) {\n  _inherits(ThrottleSubscriber, _SimpleOuterSubscribe);\n\n  var _super = _createSuper(ThrottleSubscriber);\n\n  function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {\n    var _this;\n\n    _classCallCheck(this, ThrottleSubscriber);\n\n    _this = _super.call(this, destination);\n    _this.destination = destination;\n    _this.durationSelector = durationSelector;\n    _this._leading = _leading;\n    _this._trailing = _trailing;\n    _this._hasValue = false;\n    return _this;\n  }\n\n  _createClass(ThrottleSubscriber, [{\n    key: \"_next\",\n    value: function _next(value) {\n      this._hasValue = true;\n      this._sendValue = value;\n\n      if (!this._throttled) {\n        if (this._leading) {\n          this.send();\n        } else {\n          this.throttle(value);\n        }\n      }\n    }\n  }, {\n    key: \"send\",\n    value: function send() {\n      var _hasValue = this._hasValue,\n          _sendValue = this._sendValue;\n\n      if (_hasValue) {\n        this.destination.next(_sendValue);\n        this.throttle(_sendValue);\n      }\n\n      this._hasValue = false;\n      this._sendValue = undefined;\n    }\n  }, {\n    key: \"throttle\",\n    value: function throttle(value) {\n      var duration = this.tryDurationSelector(value);\n\n      if (!!duration) {\n        this.add(this._throttled = innerSubscribe(duration, new SimpleInnerSubscriber(this)));\n      }\n    }\n  }, {\n    key: \"tryDurationSelector\",\n    value: function tryDurationSelector(value) {\n      try {\n        return this.durationSelector(value);\n      } catch (err) {\n        this.destination.error(err);\n        return null;\n      }\n    }\n  }, {\n    key: \"throttlingDone\",\n    value: function throttlingDone() {\n      var _throttled = this._throttled,\n          _trailing = this._trailing;\n\n      if (_throttled) {\n        _throttled.unsubscribe();\n      }\n\n      this._throttled = undefined;\n\n      if (_trailing) {\n        this.send();\n      }\n    }\n  }, {\n    key: \"notifyNext\",\n    value: function notifyNext() {\n      this.throttlingDone();\n    }\n  }, {\n    key: \"notifyComplete\",\n    value: function notifyComplete() {\n      this.throttlingDone();\n    }\n  }]);\n\n  return ThrottleSubscriber;\n}(SimpleOuterSubscriber); //# sourceMappingURL=throttle.js.map","map":null,"metadata":{},"sourceType":"module"}