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C,SAAS,CAAC,IAAI,CAAC,CAAC;QAEzC,MAAM,CAAC;YACL,QAAQ,EAAE,CAAC;YACX,QAAQ,CAAC,WAAW,EAAE,CAAC;YACvB,EAAE,CAAC,CAAC,YAAY,IAAI,QAAQ,KAAK,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC;gBACjD,YAAY,CAAC,WAAW,EAAE,CAAC;YAC7B,CAAC;QACH,CAAC,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AAAA,CAAC","sourcesContent":["import { Observable } from '../Observable';\nimport { ReplaySubject } from '../ReplaySubject';\nimport { IScheduler } from '../Scheduler';\nimport { Subscription } from '../Subscription';\nimport { MonoTypeOperatorFunction } from '../interfaces';\nimport { Subscriber } from '../Subscriber';\n\n/**\n * @method shareReplay\n * @owner Observable\n */\nexport function shareReplay<T>(bufferSize?: number, windowTime?: number, scheduler?: IScheduler ): MonoTypeOperatorFunction<T> {\n return (source: Observable<T>) => source.lift(shareReplayOperator(bufferSize, windowTime, scheduler));\n}\n\nfunction shareReplayOperator<T>(bufferSize?: number, windowTime?: number, scheduler?: IScheduler) {\n let subject: ReplaySubject<T>;\n let refCount = 0;\n let subscription: Subscription;\n let hasError = false;\n let isComplete = false;\n\n return function shareReplayOperation(this: Subscriber<T>, source: Observable<T>) {\n refCount++;\n if (!subject || hasError) {\n hasError = false;\n subject = new ReplaySubject<T>(bufferSize, windowTime, scheduler);\n subscription = source.subscribe({\n next(value) { subject.next(value); },\n error(err) {\n hasError = true;\n subject.error(err);\n },\n complete() {\n isComplete = true;\n subject.complete();\n },\n });\n }\n\n const innerSub = subject.subscribe(this);\n\n return () => {\n refCount--;\n innerSub.unsubscribe();\n if (subscription && refCount === 0 && isComplete) {\n subscription.unsubscribe();\n }\n };\n };\n};\n"]}