{"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, SimpleInnerSubscriber, innerSubscribe } from '../innerSubscribe';\nexport function mergeScan(accumulator, seed) {\n  var concurrent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Number.POSITIVE_INFINITY;\n  return function (source) {\n    return source.lift(new MergeScanOperator(accumulator, seed, concurrent));\n  };\n}\nexport var MergeScanOperator = /*#__PURE__*/function () {\n  function MergeScanOperator(accumulator, seed, concurrent) {\n    _classCallCheck(this, MergeScanOperator);\n\n    this.accumulator = accumulator;\n    this.seed = seed;\n    this.concurrent = concurrent;\n  }\n\n  _createClass(MergeScanOperator, [{\n    key: \"call\",\n    value: function call(subscriber, source) {\n      return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));\n    }\n  }]);\n\n  return MergeScanOperator;\n}();\nexport var MergeScanSubscriber = /*#__PURE__*/function (_SimpleOuterSubscribe) {\n  _inherits(MergeScanSubscriber, _SimpleOuterSubscribe);\n\n  var _super = _createSuper(MergeScanSubscriber);\n\n  function MergeScanSubscriber(destination, accumulator, acc, concurrent) {\n    var _this;\n\n    _classCallCheck(this, MergeScanSubscriber);\n\n    _this = _super.call(this, destination);\n    _this.accumulator = accumulator;\n    _this.acc = acc;\n    _this.concurrent = concurrent;\n    _this.hasValue = false;\n    _this.hasCompleted = false;\n    _this.buffer = [];\n    _this.active = 0;\n    _this.index = 0;\n    return _this;\n  }\n\n  _createClass(MergeScanSubscriber, [{\n    key: \"_next\",\n    value: function _next(value) {\n      if (this.active < this.concurrent) {\n        var index = this.index++;\n        var destination = this.destination;\n        var ish;\n\n        try {\n          var accumulator = this.accumulator;\n          ish = accumulator(this.acc, value, index);\n        } catch (e) {\n          return destination.error(e);\n        }\n\n        this.active++;\n\n        this._innerSub(ish);\n      } else {\n        this.buffer.push(value);\n      }\n    }\n  }, {\n    key: \"_innerSub\",\n    value: function _innerSub(ish) {\n      var innerSubscriber = new SimpleInnerSubscriber(this);\n      var destination = this.destination;\n      destination.add(innerSubscriber);\n      var innerSubscription = innerSubscribe(ish, innerSubscriber);\n\n      if (innerSubscription !== innerSubscriber) {\n        destination.add(innerSubscription);\n      }\n    }\n  }, {\n    key: \"_complete\",\n    value: function _complete() {\n      this.hasCompleted = true;\n\n      if (this.active === 0 && this.buffer.length === 0) {\n        if (this.hasValue === false) {\n          this.destination.next(this.acc);\n        }\n\n        this.destination.complete();\n      }\n\n      this.unsubscribe();\n    }\n  }, {\n    key: \"notifyNext\",\n    value: function notifyNext(innerValue) {\n      var destination = this.destination;\n      this.acc = innerValue;\n      this.hasValue = true;\n      destination.next(innerValue);\n    }\n  }, {\n    key: \"notifyComplete\",\n    value: function notifyComplete() {\n      var buffer = this.buffer;\n      this.active--;\n\n      if (buffer.length > 0) {\n        this._next(buffer.shift());\n      } else if (this.active === 0 && this.hasCompleted) {\n        if (this.hasValue === false) {\n          this.destination.next(this.acc);\n        }\n\n        this.destination.complete();\n      }\n    }\n  }]);\n\n  return MergeScanSubscriber;\n}(SimpleOuterSubscriber); //# sourceMappingURL=mergeScan.js.map","map":null,"metadata":{},"sourceType":"module"}