Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / rxjs / bundles / rxjs.umd.js
1 /**
2   @license
3                                  Apache License
4                          Version 2.0, January 2004
5                       http://www.apache.org/licenses/
6
7  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
9  1. Definitions.
10
11     "License" shall mean the terms and conditions for use, reproduction,
12     and distribution as defined by Sections 1 through 9 of this document.
13
14     "Licensor" shall mean the copyright owner or entity authorized by
15     the copyright owner that is granting the License.
16
17     "Legal Entity" shall mean the union of the acting entity and all
18     other entities that control, are controlled by, or are under common
19     control with that entity. For the purposes of this definition,
20     "control" means (i) the power, direct or indirect, to cause the
21     direction or management of such entity, whether by contract or
22     otherwise, or (ii) ownership of fifty percent (50%) or more of the
23     outstanding shares, or (iii) beneficial ownership of such entity.
24
25     "You" (or "Your") shall mean an individual or Legal Entity
26     exercising permissions granted by this License.
27
28     "Source" form shall mean the preferred form for making modifications,
29     including but not limited to software source code, documentation
30     source, and configuration files.
31
32     "Object" form shall mean any form resulting from mechanical
33     transformation or translation of a Source form, including but
34     not limited to compiled object code, generated documentation,
35     and conversions to other media types.
36
37     "Work" shall mean the work of authorship, whether in Source or
38     Object form, made available under the License, as indicated by a
39     copyright notice that is included in or attached to the work
40     (an example is provided in the Appendix below).
41
42     "Derivative Works" shall mean any work, whether in Source or Object
43     form, that is based on (or derived from) the Work and for which the
44     editorial revisions, annotations, elaborations, or other modifications
45     represent, as a whole, an original work of authorship. For the purposes
46     of this License, Derivative Works shall not include works that remain
47     separable from, or merely link (or bind by name) to the interfaces of,
48     the Work and Derivative Works thereof.
49
50     "Contribution" shall mean any work of authorship, including
51     the original version of the Work and any modifications or additions
52     to that Work or Derivative Works thereof, that is intentionally
53     submitted to Licensor for inclusion in the Work by the copyright owner
54     or by an individual or Legal Entity authorized to submit on behalf of
55     the copyright owner. For the purposes of this definition, "submitted"
56     means any form of electronic, verbal, or written communication sent
57     to the Licensor or its representatives, including but not limited to
58     communication on electronic mailing lists, source code control systems,
59     and issue tracking systems that are managed by, or on behalf of, the
60     Licensor for the purpose of discussing and improving the Work, but
61     excluding communication that is conspicuously marked or otherwise
62     designated in writing by the copyright owner as "Not a Contribution."
63
64     "Contributor" shall mean Licensor and any individual or Legal Entity
65     on behalf of whom a Contribution has been received by Licensor and
66     subsequently incorporated within the Work.
67
68  2. Grant of Copyright License. Subject to the terms and conditions of
69     this License, each Contributor hereby grants to You a perpetual,
70     worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71     copyright license to reproduce, prepare Derivative Works of,
72     publicly display, publicly perform, sublicense, and distribute the
73     Work and such Derivative Works in Source or Object form.
74
75  3. Grant of Patent License. Subject to the terms and conditions of
76     this License, each Contributor hereby grants to You a perpetual,
77     worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78     (except as stated in this section) patent license to make, have made,
79     use, offer to sell, sell, import, and otherwise transfer the Work,
80     where such license applies only to those patent claims licensable
81     by such Contributor that are necessarily infringed by their
82     Contribution(s) alone or by combination of their Contribution(s)
83     with the Work to which such Contribution(s) was submitted. If You
84     institute patent litigation against any entity (including a
85     cross-claim or counterclaim in a lawsuit) alleging that the Work
86     or a Contribution incorporated within the Work constitutes direct
87     or contributory patent infringement, then any patent licenses
88     granted to You under this License for that Work shall terminate
89     as of the date such litigation is filed.
90
91  4. Redistribution. You may reproduce and distribute copies of the
92     Work or Derivative Works thereof in any medium, with or without
93     modifications, and in Source or Object form, provided that You
94     meet the following conditions:
95
96     (a) You must give any other recipients of the Work or
97         Derivative Works a copy of this License; and
98
99     (b) You must cause any modified files to carry prominent notices
100         stating that You changed the files; and
101
102     (c) You must retain, in the Source form of any Derivative Works
103         that You distribute, all copyright, patent, trademark, and
104         attribution notices from the Source form of the Work,
105         excluding those notices that do not pertain to any part of
106         the Derivative Works; and
107
108     (d) If the Work includes a "NOTICE" text file as part of its
109         distribution, then any Derivative Works that You distribute must
110         include a readable copy of the attribution notices contained
111         within such NOTICE file, excluding those notices that do not
112         pertain to any part of the Derivative Works, in at least one
113         of the following places: within a NOTICE text file distributed
114         as part of the Derivative Works; within the Source form or
115         documentation, if provided along with the Derivative Works; or,
116         within a display generated by the Derivative Works, if and
117         wherever such third-party notices normally appear. The contents
118         of the NOTICE file are for informational purposes only and
119         do not modify the License. You may add Your own attribution
120         notices within Derivative Works that You distribute, alongside
121         or as an addendum to the NOTICE text from the Work, provided
122         that such additional attribution notices cannot be construed
123         as modifying the License.
124
125     You may add Your own copyright statement to Your modifications and
126     may provide additional or different license terms and conditions
127     for use, reproduction, or distribution of Your modifications, or
128     for any such Derivative Works as a whole, provided Your use,
129     reproduction, and distribution of the Work otherwise complies with
130     the conditions stated in this License.
131
132  5. Submission of Contributions. Unless You explicitly state otherwise,
133     any Contribution intentionally submitted for inclusion in the Work
134     by You to the Licensor shall be under the terms and conditions of
135     this License, without any additional terms or conditions.
136     Notwithstanding the above, nothing herein shall supersede or modify
137     the terms of any separate license agreement you may have executed
138     with Licensor regarding such Contributions.
139
140  6. Trademarks. This License does not grant permission to use the trade
141     names, trademarks, service marks, or product names of the Licensor,
142     except as required for reasonable and customary use in describing the
143     origin of the Work and reproducing the content of the NOTICE file.
144
145  7. Disclaimer of Warranty. Unless required by applicable law or
146     agreed to in writing, Licensor provides the Work (and each
147     Contributor provides its Contributions) on an "AS IS" BASIS,
148     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149     implied, including, without limitation, any warranties or conditions
150     of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151     PARTICULAR PURPOSE. You are solely responsible for determining the
152     appropriateness of using or redistributing the Work and assume any
153     risks associated with Your exercise of permissions under this License.
154
155  8. Limitation of Liability. In no event and under no legal theory,
156     whether in tort (including negligence), contract, or otherwise,
157     unless required by applicable law (such as deliberate and grossly
158     negligent acts) or agreed to in writing, shall any Contributor be
159     liable to You for damages, including any direct, indirect, special,
160     incidental, or consequential damages of any character arising as a
161     result of this License or out of the use or inability to use the
162     Work (including but not limited to damages for loss of goodwill,
163     work stoppage, computer failure or malfunction, or any and all
164     other commercial damages or losses), even if such Contributor
165     has been advised of the possibility of such damages.
166
167  9. Accepting Warranty or Additional Liability. While redistributing
168     the Work or Derivative Works thereof, You may choose to offer,
169     and charge a fee for, acceptance of support, warranty, indemnity,
170     or other liability obligations and/or rights consistent with this
171     License. However, in accepting such obligations, You may act only
172     on Your own behalf and on Your sole responsibility, not on behalf
173     of any other Contributor, and only if You agree to indemnify,
174     defend, and hold each Contributor harmless for any liability
175     incurred by, or claims asserted against, such Contributor by reason
176     of your accepting any such warranty or additional liability.
177
178  END OF TERMS AND CONDITIONS
179
180  APPENDIX: How to apply the Apache License to your work.
181
182     To apply the Apache License to your work, attach the following
183     boilerplate notice, with the fields enclosed by brackets "[]"
184     replaced with your own identifying information. (Don't include
185     the brackets!)  The text should be enclosed in the appropriate
186     comment syntax for the file format. We also recommend that a
187     file or class name and description of purpose be included on the
188     same "printed page" as the copyright notice for easier
189     identification within third-party archives.
190
191  Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
192
193  Licensed under the Apache License, Version 2.0 (the "License");
194  you may not use this file except in compliance with the License.
195  You may obtain a copy of the License at
196
197      http://www.apache.org/licenses/LICENSE-2.0
198
199  Unless required by applicable law or agreed to in writing, software
200  distributed under the License is distributed on an "AS IS" BASIS,
201  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202  See the License for the specific language governing permissions and
203  limitations under the License.
204  
205
206  **/
207 /**
208   @license
209                                  Apache License
210                          Version 2.0, January 2004
211                       http://www.apache.org/licenses/
212
213  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
214
215  1. Definitions.
216
217     "License" shall mean the terms and conditions for use, reproduction,
218     and distribution as defined by Sections 1 through 9 of this document.
219
220     "Licensor" shall mean the copyright owner or entity authorized by
221     the copyright owner that is granting the License.
222
223     "Legal Entity" shall mean the union of the acting entity and all
224     other entities that control, are controlled by, or are under common
225     control with that entity. For the purposes of this definition,
226     "control" means (i) the power, direct or indirect, to cause the
227     direction or management of such entity, whether by contract or
228     otherwise, or (ii) ownership of fifty percent (50%) or more of the
229     outstanding shares, or (iii) beneficial ownership of such entity.
230
231     "You" (or "Your") shall mean an individual or Legal Entity
232     exercising permissions granted by this License.
233
234     "Source" form shall mean the preferred form for making modifications,
235     including but not limited to software source code, documentation
236     source, and configuration files.
237
238     "Object" form shall mean any form resulting from mechanical
239     transformation or translation of a Source form, including but
240     not limited to compiled object code, generated documentation,
241     and conversions to other media types.
242
243     "Work" shall mean the work of authorship, whether in Source or
244     Object form, made available under the License, as indicated by a
245     copyright notice that is included in or attached to the work
246     (an example is provided in the Appendix below).
247
248     "Derivative Works" shall mean any work, whether in Source or Object
249     form, that is based on (or derived from) the Work and for which the
250     editorial revisions, annotations, elaborations, or other modifications
251     represent, as a whole, an original work of authorship. For the purposes
252     of this License, Derivative Works shall not include works that remain
253     separable from, or merely link (or bind by name) to the interfaces of,
254     the Work and Derivative Works thereof.
255
256     "Contribution" shall mean any work of authorship, including
257     the original version of the Work and any modifications or additions
258     to that Work or Derivative Works thereof, that is intentionally
259     submitted to Licensor for inclusion in the Work by the copyright owner
260     or by an individual or Legal Entity authorized to submit on behalf of
261     the copyright owner. For the purposes of this definition, "submitted"
262     means any form of electronic, verbal, or written communication sent
263     to the Licensor or its representatives, including but not limited to
264     communication on electronic mailing lists, source code control systems,
265     and issue tracking systems that are managed by, or on behalf of, the
266     Licensor for the purpose of discussing and improving the Work, but
267     excluding communication that is conspicuously marked or otherwise
268     designated in writing by the copyright owner as "Not a Contribution."
269
270     "Contributor" shall mean Licensor and any individual or Legal Entity
271     on behalf of whom a Contribution has been received by Licensor and
272     subsequently incorporated within the Work.
273
274  2. Grant of Copyright License. Subject to the terms and conditions of
275     this License, each Contributor hereby grants to You a perpetual,
276     worldwide, non-exclusive, no-charge, royalty-free, irrevocable
277     copyright license to reproduce, prepare Derivative Works of,
278     publicly display, publicly perform, sublicense, and distribute the
279     Work and such Derivative Works in Source or Object form.
280
281  3. Grant of Patent License. Subject to the terms and conditions of
282     this License, each Contributor hereby grants to You a perpetual,
283     worldwide, non-exclusive, no-charge, royalty-free, irrevocable
284     (except as stated in this section) patent license to make, have made,
285     use, offer to sell, sell, import, and otherwise transfer the Work,
286     where such license applies only to those patent claims licensable
287     by such Contributor that are necessarily infringed by their
288     Contribution(s) alone or by combination of their Contribution(s)
289     with the Work to which such Contribution(s) was submitted. If You
290     institute patent litigation against any entity (including a
291     cross-claim or counterclaim in a lawsuit) alleging that the Work
292     or a Contribution incorporated within the Work constitutes direct
293     or contributory patent infringement, then any patent licenses
294     granted to You under this License for that Work shall terminate
295     as of the date such litigation is filed.
296
297  4. Redistribution. You may reproduce and distribute copies of the
298     Work or Derivative Works thereof in any medium, with or without
299     modifications, and in Source or Object form, provided that You
300     meet the following conditions:
301
302     (a) You must give any other recipients of the Work or
303         Derivative Works a copy of this License; and
304
305     (b) You must cause any modified files to carry prominent notices
306         stating that You changed the files; and
307
308     (c) You must retain, in the Source form of any Derivative Works
309         that You distribute, all copyright, patent, trademark, and
310         attribution notices from the Source form of the Work,
311         excluding those notices that do not pertain to any part of
312         the Derivative Works; and
313
314     (d) If the Work includes a "NOTICE" text file as part of its
315         distribution, then any Derivative Works that You distribute must
316         include a readable copy of the attribution notices contained
317         within such NOTICE file, excluding those notices that do not
318         pertain to any part of the Derivative Works, in at least one
319         of the following places: within a NOTICE text file distributed
320         as part of the Derivative Works; within the Source form or
321         documentation, if provided along with the Derivative Works; or,
322         within a display generated by the Derivative Works, if and
323         wherever such third-party notices normally appear. The contents
324         of the NOTICE file are for informational purposes only and
325         do not modify the License. You may add Your own attribution
326         notices within Derivative Works that You distribute, alongside
327         or as an addendum to the NOTICE text from the Work, provided
328         that such additional attribution notices cannot be construed
329         as modifying the License.
330
331     You may add Your own copyright statement to Your modifications and
332     may provide additional or different license terms and conditions
333     for use, reproduction, or distribution of Your modifications, or
334     for any such Derivative Works as a whole, provided Your use,
335     reproduction, and distribution of the Work otherwise complies with
336     the conditions stated in this License.
337
338  5. Submission of Contributions. Unless You explicitly state otherwise,
339     any Contribution intentionally submitted for inclusion in the Work
340     by You to the Licensor shall be under the terms and conditions of
341     this License, without any additional terms or conditions.
342     Notwithstanding the above, nothing herein shall supersede or modify
343     the terms of any separate license agreement you may have executed
344     with Licensor regarding such Contributions.
345
346  6. Trademarks. This License does not grant permission to use the trade
347     names, trademarks, service marks, or product names of the Licensor,
348     except as required for reasonable and customary use in describing the
349     origin of the Work and reproducing the content of the NOTICE file.
350
351  7. Disclaimer of Warranty. Unless required by applicable law or
352     agreed to in writing, Licensor provides the Work (and each
353     Contributor provides its Contributions) on an "AS IS" BASIS,
354     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
355     implied, including, without limitation, any warranties or conditions
356     of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
357     PARTICULAR PURPOSE. You are solely responsible for determining the
358     appropriateness of using or redistributing the Work and assume any
359     risks associated with Your exercise of permissions under this License.
360
361  8. Limitation of Liability. In no event and under no legal theory,
362     whether in tort (including negligence), contract, or otherwise,
363     unless required by applicable law (such as deliberate and grossly
364     negligent acts) or agreed to in writing, shall any Contributor be
365     liable to You for damages, including any direct, indirect, special,
366     incidental, or consequential damages of any character arising as a
367     result of this License or out of the use or inability to use the
368     Work (including but not limited to damages for loss of goodwill,
369     work stoppage, computer failure or malfunction, or any and all
370     other commercial damages or losses), even if such Contributor
371     has been advised of the possibility of such damages.
372
373  9. Accepting Warranty or Additional Liability. While redistributing
374     the Work or Derivative Works thereof, You may choose to offer,
375     and charge a fee for, acceptance of support, warranty, indemnity,
376     or other liability obligations and/or rights consistent with this
377     License. However, in accepting such obligations, You may act only
378     on Your own behalf and on Your sole responsibility, not on behalf
379     of any other Contributor, and only if You agree to indemnify,
380     defend, and hold each Contributor harmless for any liability
381     incurred by, or claims asserted against, such Contributor by reason
382     of your accepting any such warranty or additional liability.
383
384  END OF TERMS AND CONDITIONS
385
386  APPENDIX: How to apply the Apache License to your work.
387
388     To apply the Apache License to your work, attach the following
389     boilerplate notice, with the fields enclosed by brackets "[]"
390     replaced with your own identifying information. (Don't include
391     the brackets!)  The text should be enclosed in the appropriate
392     comment syntax for the file format. We also recommend that a
393     file or class name and description of purpose be included on the
394     same "printed page" as the copyright notice for easier
395     identification within third-party archives.
396
397  Copyright (c) 2015-2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors
398
399  Licensed under the Apache License, Version 2.0 (the "License");
400  you may not use this file except in compliance with the License.
401  You may obtain a copy of the License at
402
403      http://www.apache.org/licenses/LICENSE-2.0
404
405  Unless required by applicable law or agreed to in writing, software
406  distributed under the License is distributed on an "AS IS" BASIS,
407  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
408  See the License for the specific language governing permissions and
409  limitations under the License.
410  
411
412  **/
413 (function (global, factory) {
414     typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
415     typeof define === 'function' && define.amd ? define('rxjs', ['exports'], factory) :
416     (factory((global.rxjs = {})));
417 }(this, (function (exports) { 'use strict';
418
419     /*! *****************************************************************************\r
420     Copyright (c) Microsoft Corporation. All rights reserved.\r
421     Licensed under the Apache License, Version 2.0 (the "License"); you may not use\r
422     this file except in compliance with the License. You may obtain a copy of the\r
423     License at http://www.apache.org/licenses/LICENSE-2.0\r
424 \r
425     THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r
426     KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r
427     WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r
428     MERCHANTABLITY OR NON-INFRINGEMENT.\r
429 \r
430     See the Apache Version 2.0 License for specific language governing permissions\r
431     and limitations under the License.\r
432     ***************************************************************************** */\r
433     /* global Reflect, Promise */\r
434 \r
435     var extendStatics = Object.setPrototypeOf ||\r
436         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r
437         function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r
438 \r
439     function __extends(d, b) {\r
440         extendStatics(d, b);\r
441         function __() { this.constructor = d; }\r
442         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r
443     }\r
444 \r
445     var __assign = Object.assign || function __assign(t) {\r
446         for (var s, i = 1, n = arguments.length; i < n; i++) {\r
447             s = arguments[i];\r
448             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r
449         }\r
450         return t;\r
451     };\r
452 \r
453     function __rest(s, e) {\r
454         var t = {};\r
455         for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r
456             t[p] = s[p];\r
457         if (s != null && typeof Object.getOwnPropertySymbols === "function")\r
458             for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\r
459                 t[p[i]] = s[p[i]];\r
460         return t;\r
461     }
462
463     function isFunction(x) {
464         return typeof x === 'function';
465     }
466
467     var _enable_super_gross_mode_that_will_cause_bad_things = false;
468     var config = {
469         Promise: undefined,
470         set useDeprecatedSynchronousErrorHandling(value) {
471             if (value) {
472                 var error = new Error();
473                 console.warn('DEPRECATED! RxJS was set to use deprecated synchronous error handling behavior by code at: \n' + error.stack);
474             }
475             else if (_enable_super_gross_mode_that_will_cause_bad_things) {
476                 console.log('RxJS: Back to a better error behavior. Thank you. <3');
477             }
478             _enable_super_gross_mode_that_will_cause_bad_things = value;
479         },
480         get useDeprecatedSynchronousErrorHandling() {
481             return _enable_super_gross_mode_that_will_cause_bad_things;
482         },
483     };
484
485     function hostReportError(err) {
486         setTimeout(function () { throw err; }, 0);
487     }
488
489     var empty = {
490         closed: true,
491         next: function (value) { },
492         error: function (err) {
493             if (config.useDeprecatedSynchronousErrorHandling) {
494                 throw err;
495             }
496             else {
497                 hostReportError(err);
498             }
499         },
500         complete: function () { }
501     };
502
503     var isArray = (function () { return Array.isArray || (function (x) { return x && typeof x.length === 'number'; }); })();
504
505     function isObject(x) {
506         return x !== null && typeof x === 'object';
507     }
508
509     var UnsubscriptionErrorImpl = (function () {
510         function UnsubscriptionErrorImpl(errors) {
511             Error.call(this);
512             this.message = errors ?
513                 errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n  ') : '';
514             this.name = 'UnsubscriptionError';
515             this.errors = errors;
516             return this;
517         }
518         UnsubscriptionErrorImpl.prototype = Object.create(Error.prototype);
519         return UnsubscriptionErrorImpl;
520     })();
521     var UnsubscriptionError = UnsubscriptionErrorImpl;
522
523     var Subscription = (function () {
524         function Subscription(unsubscribe) {
525             this.closed = false;
526             this._parentOrParents = null;
527             this._subscriptions = null;
528             if (unsubscribe) {
529                 this._ctorUnsubscribe = true;
530                 this._unsubscribe = unsubscribe;
531             }
532         }
533         Subscription.prototype.unsubscribe = function () {
534             var errors;
535             if (this.closed) {
536                 return;
537             }
538             var _a = this, _parentOrParents = _a._parentOrParents, _ctorUnsubscribe = _a._ctorUnsubscribe, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
539             this.closed = true;
540             this._parentOrParents = null;
541             this._subscriptions = null;
542             if (_parentOrParents instanceof Subscription) {
543                 _parentOrParents.remove(this);
544             }
545             else if (_parentOrParents !== null) {
546                 for (var index = 0; index < _parentOrParents.length; ++index) {
547                     var parent_1 = _parentOrParents[index];
548                     parent_1.remove(this);
549                 }
550             }
551             if (isFunction(_unsubscribe)) {
552                 if (_ctorUnsubscribe) {
553                     this._unsubscribe = undefined;
554                 }
555                 try {
556                     _unsubscribe.call(this);
557                 }
558                 catch (e) {
559                     errors = e instanceof UnsubscriptionError ? flattenUnsubscriptionErrors(e.errors) : [e];
560                 }
561             }
562             if (isArray(_subscriptions)) {
563                 var index = -1;
564                 var len = _subscriptions.length;
565                 while (++index < len) {
566                     var sub = _subscriptions[index];
567                     if (isObject(sub)) {
568                         try {
569                             sub.unsubscribe();
570                         }
571                         catch (e) {
572                             errors = errors || [];
573                             if (e instanceof UnsubscriptionError) {
574                                 errors = errors.concat(flattenUnsubscriptionErrors(e.errors));
575                             }
576                             else {
577                                 errors.push(e);
578                             }
579                         }
580                     }
581                 }
582             }
583             if (errors) {
584                 throw new UnsubscriptionError(errors);
585             }
586         };
587         Subscription.prototype.add = function (teardown) {
588             var subscription = teardown;
589             if (!teardown) {
590                 return Subscription.EMPTY;
591             }
592             switch (typeof teardown) {
593                 case 'function':
594                     subscription = new Subscription(teardown);
595                 case 'object':
596                     if (subscription === this || subscription.closed || typeof subscription.unsubscribe !== 'function') {
597                         return subscription;
598                     }
599                     else if (this.closed) {
600                         subscription.unsubscribe();
601                         return subscription;
602                     }
603                     else if (!(subscription instanceof Subscription)) {
604                         var tmp = subscription;
605                         subscription = new Subscription();
606                         subscription._subscriptions = [tmp];
607                     }
608                     break;
609                 default: {
610                     throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
611                 }
612             }
613             var _parentOrParents = subscription._parentOrParents;
614             if (_parentOrParents === null) {
615                 subscription._parentOrParents = this;
616             }
617             else if (_parentOrParents instanceof Subscription) {
618                 if (_parentOrParents === this) {
619                     return subscription;
620                 }
621                 subscription._parentOrParents = [_parentOrParents, this];
622             }
623             else if (_parentOrParents.indexOf(this) === -1) {
624                 _parentOrParents.push(this);
625             }
626             else {
627                 return subscription;
628             }
629             var subscriptions = this._subscriptions;
630             if (subscriptions === null) {
631                 this._subscriptions = [subscription];
632             }
633             else {
634                 subscriptions.push(subscription);
635             }
636             return subscription;
637         };
638         Subscription.prototype.remove = function (subscription) {
639             var subscriptions = this._subscriptions;
640             if (subscriptions) {
641                 var subscriptionIndex = subscriptions.indexOf(subscription);
642                 if (subscriptionIndex !== -1) {
643                     subscriptions.splice(subscriptionIndex, 1);
644                 }
645             }
646         };
647         Subscription.EMPTY = (function (empty) {
648             empty.closed = true;
649             return empty;
650         }(new Subscription()));
651         return Subscription;
652     }());
653     function flattenUnsubscriptionErrors(errors) {
654         return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError) ? err.errors : err); }, []);
655     }
656
657     var rxSubscriber = (function () {
658         return typeof Symbol === 'function'
659             ? Symbol('rxSubscriber')
660             : '@@rxSubscriber_' + Math.random();
661     })();
662
663     var Subscriber = (function (_super) {
664         __extends(Subscriber, _super);
665         function Subscriber(destinationOrNext, error, complete) {
666             var _this = _super.call(this) || this;
667             _this.syncErrorValue = null;
668             _this.syncErrorThrown = false;
669             _this.syncErrorThrowable = false;
670             _this.isStopped = false;
671             switch (arguments.length) {
672                 case 0:
673                     _this.destination = empty;
674                     break;
675                 case 1:
676                     if (!destinationOrNext) {
677                         _this.destination = empty;
678                         break;
679                     }
680                     if (typeof destinationOrNext === 'object') {
681                         if (destinationOrNext instanceof Subscriber) {
682                             _this.syncErrorThrowable = destinationOrNext.syncErrorThrowable;
683                             _this.destination = destinationOrNext;
684                             destinationOrNext.add(_this);
685                         }
686                         else {
687                             _this.syncErrorThrowable = true;
688                             _this.destination = new SafeSubscriber(_this, destinationOrNext);
689                         }
690                         break;
691                     }
692                 default:
693                     _this.syncErrorThrowable = true;
694                     _this.destination = new SafeSubscriber(_this, destinationOrNext, error, complete);
695                     break;
696             }
697             return _this;
698         }
699         Subscriber.prototype[rxSubscriber] = function () { return this; };
700         Subscriber.create = function (next, error, complete) {
701             var subscriber = new Subscriber(next, error, complete);
702             subscriber.syncErrorThrowable = false;
703             return subscriber;
704         };
705         Subscriber.prototype.next = function (value) {
706             if (!this.isStopped) {
707                 this._next(value);
708             }
709         };
710         Subscriber.prototype.error = function (err) {
711             if (!this.isStopped) {
712                 this.isStopped = true;
713                 this._error(err);
714             }
715         };
716         Subscriber.prototype.complete = function () {
717             if (!this.isStopped) {
718                 this.isStopped = true;
719                 this._complete();
720             }
721         };
722         Subscriber.prototype.unsubscribe = function () {
723             if (this.closed) {
724                 return;
725             }
726             this.isStopped = true;
727             _super.prototype.unsubscribe.call(this);
728         };
729         Subscriber.prototype._next = function (value) {
730             this.destination.next(value);
731         };
732         Subscriber.prototype._error = function (err) {
733             this.destination.error(err);
734             this.unsubscribe();
735         };
736         Subscriber.prototype._complete = function () {
737             this.destination.complete();
738             this.unsubscribe();
739         };
740         Subscriber.prototype._unsubscribeAndRecycle = function () {
741             var _parentOrParents = this._parentOrParents;
742             this._parentOrParents = null;
743             this.unsubscribe();
744             this.closed = false;
745             this.isStopped = false;
746             this._parentOrParents = _parentOrParents;
747             return this;
748         };
749         return Subscriber;
750     }(Subscription));
751     var SafeSubscriber = (function (_super) {
752         __extends(SafeSubscriber, _super);
753         function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
754             var _this = _super.call(this) || this;
755             _this._parentSubscriber = _parentSubscriber;
756             var next;
757             var context = _this;
758             if (isFunction(observerOrNext)) {
759                 next = observerOrNext;
760             }
761             else if (observerOrNext) {
762                 next = observerOrNext.next;
763                 error = observerOrNext.error;
764                 complete = observerOrNext.complete;
765                 if (observerOrNext !== empty) {
766                     context = Object.create(observerOrNext);
767                     if (isFunction(context.unsubscribe)) {
768                         _this.add(context.unsubscribe.bind(context));
769                     }
770                     context.unsubscribe = _this.unsubscribe.bind(_this);
771                 }
772             }
773             _this._context = context;
774             _this._next = next;
775             _this._error = error;
776             _this._complete = complete;
777             return _this;
778         }
779         SafeSubscriber.prototype.next = function (value) {
780             if (!this.isStopped && this._next) {
781                 var _parentSubscriber = this._parentSubscriber;
782                 if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
783                     this.__tryOrUnsub(this._next, value);
784                 }
785                 else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
786                     this.unsubscribe();
787                 }
788             }
789         };
790         SafeSubscriber.prototype.error = function (err) {
791             if (!this.isStopped) {
792                 var _parentSubscriber = this._parentSubscriber;
793                 var useDeprecatedSynchronousErrorHandling = config.useDeprecatedSynchronousErrorHandling;
794                 if (this._error) {
795                     if (!useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
796                         this.__tryOrUnsub(this._error, err);
797                         this.unsubscribe();
798                     }
799                     else {
800                         this.__tryOrSetError(_parentSubscriber, this._error, err);
801                         this.unsubscribe();
802                     }
803                 }
804                 else if (!_parentSubscriber.syncErrorThrowable) {
805                     this.unsubscribe();
806                     if (useDeprecatedSynchronousErrorHandling) {
807                         throw err;
808                     }
809                     hostReportError(err);
810                 }
811                 else {
812                     if (useDeprecatedSynchronousErrorHandling) {
813                         _parentSubscriber.syncErrorValue = err;
814                         _parentSubscriber.syncErrorThrown = true;
815                     }
816                     else {
817                         hostReportError(err);
818                     }
819                     this.unsubscribe();
820                 }
821             }
822         };
823         SafeSubscriber.prototype.complete = function () {
824             var _this = this;
825             if (!this.isStopped) {
826                 var _parentSubscriber = this._parentSubscriber;
827                 if (this._complete) {
828                     var wrappedComplete = function () { return _this._complete.call(_this._context); };
829                     if (!config.useDeprecatedSynchronousErrorHandling || !_parentSubscriber.syncErrorThrowable) {
830                         this.__tryOrUnsub(wrappedComplete);
831                         this.unsubscribe();
832                     }
833                     else {
834                         this.__tryOrSetError(_parentSubscriber, wrappedComplete);
835                         this.unsubscribe();
836                     }
837                 }
838                 else {
839                     this.unsubscribe();
840                 }
841             }
842         };
843         SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
844             try {
845                 fn.call(this._context, value);
846             }
847             catch (err) {
848                 this.unsubscribe();
849                 if (config.useDeprecatedSynchronousErrorHandling) {
850                     throw err;
851                 }
852                 else {
853                     hostReportError(err);
854                 }
855             }
856         };
857         SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
858             if (!config.useDeprecatedSynchronousErrorHandling) {
859                 throw new Error('bad call');
860             }
861             try {
862                 fn.call(this._context, value);
863             }
864             catch (err) {
865                 if (config.useDeprecatedSynchronousErrorHandling) {
866                     parent.syncErrorValue = err;
867                     parent.syncErrorThrown = true;
868                     return true;
869                 }
870                 else {
871                     hostReportError(err);
872                     return true;
873                 }
874             }
875             return false;
876         };
877         SafeSubscriber.prototype._unsubscribe = function () {
878             var _parentSubscriber = this._parentSubscriber;
879             this._context = null;
880             this._parentSubscriber = null;
881             _parentSubscriber.unsubscribe();
882         };
883         return SafeSubscriber;
884     }(Subscriber));
885
886     function canReportError(observer) {
887         while (observer) {
888             var _a = observer, closed_1 = _a.closed, destination = _a.destination, isStopped = _a.isStopped;
889             if (closed_1 || isStopped) {
890                 return false;
891             }
892             else if (destination && destination instanceof Subscriber) {
893                 observer = destination;
894             }
895             else {
896                 observer = null;
897             }
898         }
899         return true;
900     }
901
902     function toSubscriber(nextOrObserver, error, complete) {
903         if (nextOrObserver) {
904             if (nextOrObserver instanceof Subscriber) {
905                 return nextOrObserver;
906             }
907             if (nextOrObserver[rxSubscriber]) {
908                 return nextOrObserver[rxSubscriber]();
909             }
910         }
911         if (!nextOrObserver && !error && !complete) {
912             return new Subscriber(empty);
913         }
914         return new Subscriber(nextOrObserver, error, complete);
915     }
916
917     var observable = (function () { return typeof Symbol === 'function' && Symbol.observable || '@@observable'; })();
918
919     function identity(x) {
920         return x;
921     }
922
923     function pipe() {
924         var fns = [];
925         for (var _i = 0; _i < arguments.length; _i++) {
926             fns[_i] = arguments[_i];
927         }
928         return pipeFromArray(fns);
929     }
930     function pipeFromArray(fns) {
931         if (fns.length === 0) {
932             return identity;
933         }
934         if (fns.length === 1) {
935             return fns[0];
936         }
937         return function piped(input) {
938             return fns.reduce(function (prev, fn) { return fn(prev); }, input);
939         };
940     }
941
942     var Observable = (function () {
943         function Observable(subscribe) {
944             this._isScalar = false;
945             if (subscribe) {
946                 this._subscribe = subscribe;
947             }
948         }
949         Observable.prototype.lift = function (operator) {
950             var observable$$1 = new Observable();
951             observable$$1.source = this;
952             observable$$1.operator = operator;
953             return observable$$1;
954         };
955         Observable.prototype.subscribe = function (observerOrNext, error, complete) {
956             var operator = this.operator;
957             var sink = toSubscriber(observerOrNext, error, complete);
958             if (operator) {
959                 sink.add(operator.call(sink, this.source));
960             }
961             else {
962                 sink.add(this.source || (config.useDeprecatedSynchronousErrorHandling && !sink.syncErrorThrowable) ?
963                     this._subscribe(sink) :
964                     this._trySubscribe(sink));
965             }
966             if (config.useDeprecatedSynchronousErrorHandling) {
967                 if (sink.syncErrorThrowable) {
968                     sink.syncErrorThrowable = false;
969                     if (sink.syncErrorThrown) {
970                         throw sink.syncErrorValue;
971                     }
972                 }
973             }
974             return sink;
975         };
976         Observable.prototype._trySubscribe = function (sink) {
977             try {
978                 return this._subscribe(sink);
979             }
980             catch (err) {
981                 if (config.useDeprecatedSynchronousErrorHandling) {
982                     sink.syncErrorThrown = true;
983                     sink.syncErrorValue = err;
984                 }
985                 if (canReportError(sink)) {
986                     sink.error(err);
987                 }
988                 else {
989                     console.warn(err);
990                 }
991             }
992         };
993         Observable.prototype.forEach = function (next, promiseCtor) {
994             var _this = this;
995             promiseCtor = getPromiseCtor(promiseCtor);
996             return new promiseCtor(function (resolve, reject) {
997                 var subscription;
998                 subscription = _this.subscribe(function (value) {
999                     try {
1000                         next(value);
1001                     }
1002                     catch (err) {
1003                         reject(err);
1004                         if (subscription) {
1005                             subscription.unsubscribe();
1006                         }
1007                     }
1008                 }, reject, resolve);
1009             });
1010         };
1011         Observable.prototype._subscribe = function (subscriber) {
1012             var source = this.source;
1013             return source && source.subscribe(subscriber);
1014         };
1015         Observable.prototype[observable] = function () {
1016             return this;
1017         };
1018         Observable.prototype.pipe = function () {
1019             var operations = [];
1020             for (var _i = 0; _i < arguments.length; _i++) {
1021                 operations[_i] = arguments[_i];
1022             }
1023             if (operations.length === 0) {
1024                 return this;
1025             }
1026             return pipeFromArray(operations)(this);
1027         };
1028         Observable.prototype.toPromise = function (promiseCtor) {
1029             var _this = this;
1030             promiseCtor = getPromiseCtor(promiseCtor);
1031             return new promiseCtor(function (resolve, reject) {
1032                 var value;
1033                 _this.subscribe(function (x) { return value = x; }, function (err) { return reject(err); }, function () { return resolve(value); });
1034             });
1035         };
1036         Observable.create = function (subscribe) {
1037             return new Observable(subscribe);
1038         };
1039         return Observable;
1040     }());
1041     function getPromiseCtor(promiseCtor) {
1042         if (!promiseCtor) {
1043             promiseCtor = config.Promise || Promise;
1044         }
1045         if (!promiseCtor) {
1046             throw new Error('no Promise impl found');
1047         }
1048         return promiseCtor;
1049     }
1050
1051     var ObjectUnsubscribedErrorImpl = (function () {
1052         function ObjectUnsubscribedErrorImpl() {
1053             Error.call(this);
1054             this.message = 'object unsubscribed';
1055             this.name = 'ObjectUnsubscribedError';
1056             return this;
1057         }
1058         ObjectUnsubscribedErrorImpl.prototype = Object.create(Error.prototype);
1059         return ObjectUnsubscribedErrorImpl;
1060     })();
1061     var ObjectUnsubscribedError = ObjectUnsubscribedErrorImpl;
1062
1063     var SubjectSubscription = (function (_super) {
1064         __extends(SubjectSubscription, _super);
1065         function SubjectSubscription(subject, subscriber) {
1066             var _this = _super.call(this) || this;
1067             _this.subject = subject;
1068             _this.subscriber = subscriber;
1069             _this.closed = false;
1070             return _this;
1071         }
1072         SubjectSubscription.prototype.unsubscribe = function () {
1073             if (this.closed) {
1074                 return;
1075             }
1076             this.closed = true;
1077             var subject = this.subject;
1078             var observers = subject.observers;
1079             this.subject = null;
1080             if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
1081                 return;
1082             }
1083             var subscriberIndex = observers.indexOf(this.subscriber);
1084             if (subscriberIndex !== -1) {
1085                 observers.splice(subscriberIndex, 1);
1086             }
1087         };
1088         return SubjectSubscription;
1089     }(Subscription));
1090
1091     var SubjectSubscriber = (function (_super) {
1092         __extends(SubjectSubscriber, _super);
1093         function SubjectSubscriber(destination) {
1094             var _this = _super.call(this, destination) || this;
1095             _this.destination = destination;
1096             return _this;
1097         }
1098         return SubjectSubscriber;
1099     }(Subscriber));
1100     var Subject = (function (_super) {
1101         __extends(Subject, _super);
1102         function Subject() {
1103             var _this = _super.call(this) || this;
1104             _this.observers = [];
1105             _this.closed = false;
1106             _this.isStopped = false;
1107             _this.hasError = false;
1108             _this.thrownError = null;
1109             return _this;
1110         }
1111         Subject.prototype[rxSubscriber] = function () {
1112             return new SubjectSubscriber(this);
1113         };
1114         Subject.prototype.lift = function (operator) {
1115             var subject = new AnonymousSubject(this, this);
1116             subject.operator = operator;
1117             return subject;
1118         };
1119         Subject.prototype.next = function (value) {
1120             if (this.closed) {
1121                 throw new ObjectUnsubscribedError();
1122             }
1123             if (!this.isStopped) {
1124                 var observers = this.observers;
1125                 var len = observers.length;
1126                 var copy = observers.slice();
1127                 for (var i = 0; i < len; i++) {
1128                     copy[i].next(value);
1129                 }
1130             }
1131         };
1132         Subject.prototype.error = function (err) {
1133             if (this.closed) {
1134                 throw new ObjectUnsubscribedError();
1135             }
1136             this.hasError = true;
1137             this.thrownError = err;
1138             this.isStopped = true;
1139             var observers = this.observers;
1140             var len = observers.length;
1141             var copy = observers.slice();
1142             for (var i = 0; i < len; i++) {
1143                 copy[i].error(err);
1144             }
1145             this.observers.length = 0;
1146         };
1147         Subject.prototype.complete = function () {
1148             if (this.closed) {
1149                 throw new ObjectUnsubscribedError();
1150             }
1151             this.isStopped = true;
1152             var observers = this.observers;
1153             var len = observers.length;
1154             var copy = observers.slice();
1155             for (var i = 0; i < len; i++) {
1156                 copy[i].complete();
1157             }
1158             this.observers.length = 0;
1159         };
1160         Subject.prototype.unsubscribe = function () {
1161             this.isStopped = true;
1162             this.closed = true;
1163             this.observers = null;
1164         };
1165         Subject.prototype._trySubscribe = function (subscriber) {
1166             if (this.closed) {
1167                 throw new ObjectUnsubscribedError();
1168             }
1169             else {
1170                 return _super.prototype._trySubscribe.call(this, subscriber);
1171             }
1172         };
1173         Subject.prototype._subscribe = function (subscriber) {
1174             if (this.closed) {
1175                 throw new ObjectUnsubscribedError();
1176             }
1177             else if (this.hasError) {
1178                 subscriber.error(this.thrownError);
1179                 return Subscription.EMPTY;
1180             }
1181             else if (this.isStopped) {
1182                 subscriber.complete();
1183                 return Subscription.EMPTY;
1184             }
1185             else {
1186                 this.observers.push(subscriber);
1187                 return new SubjectSubscription(this, subscriber);
1188             }
1189         };
1190         Subject.prototype.asObservable = function () {
1191             var observable = new Observable();
1192             observable.source = this;
1193             return observable;
1194         };
1195         Subject.create = function (destination, source) {
1196             return new AnonymousSubject(destination, source);
1197         };
1198         return Subject;
1199     }(Observable));
1200     var AnonymousSubject = (function (_super) {
1201         __extends(AnonymousSubject, _super);
1202         function AnonymousSubject(destination, source) {
1203             var _this = _super.call(this) || this;
1204             _this.destination = destination;
1205             _this.source = source;
1206             return _this;
1207         }
1208         AnonymousSubject.prototype.next = function (value) {
1209             var destination = this.destination;
1210             if (destination && destination.next) {
1211                 destination.next(value);
1212             }
1213         };
1214         AnonymousSubject.prototype.error = function (err) {
1215             var destination = this.destination;
1216             if (destination && destination.error) {
1217                 this.destination.error(err);
1218             }
1219         };
1220         AnonymousSubject.prototype.complete = function () {
1221             var destination = this.destination;
1222             if (destination && destination.complete) {
1223                 this.destination.complete();
1224             }
1225         };
1226         AnonymousSubject.prototype._subscribe = function (subscriber) {
1227             var source = this.source;
1228             if (source) {
1229                 return this.source.subscribe(subscriber);
1230             }
1231             else {
1232                 return Subscription.EMPTY;
1233             }
1234         };
1235         return AnonymousSubject;
1236     }(Subject));
1237
1238     function refCount() {
1239         return function refCountOperatorFunction(source) {
1240             return source.lift(new RefCountOperator(source));
1241         };
1242     }
1243     var RefCountOperator = (function () {
1244         function RefCountOperator(connectable) {
1245             this.connectable = connectable;
1246         }
1247         RefCountOperator.prototype.call = function (subscriber, source) {
1248             var connectable = this.connectable;
1249             connectable._refCount++;
1250             var refCounter = new RefCountSubscriber(subscriber, connectable);
1251             var subscription = source.subscribe(refCounter);
1252             if (!refCounter.closed) {
1253                 refCounter.connection = connectable.connect();
1254             }
1255             return subscription;
1256         };
1257         return RefCountOperator;
1258     }());
1259     var RefCountSubscriber = (function (_super) {
1260         __extends(RefCountSubscriber, _super);
1261         function RefCountSubscriber(destination, connectable) {
1262             var _this = _super.call(this, destination) || this;
1263             _this.connectable = connectable;
1264             return _this;
1265         }
1266         RefCountSubscriber.prototype._unsubscribe = function () {
1267             var connectable = this.connectable;
1268             if (!connectable) {
1269                 this.connection = null;
1270                 return;
1271             }
1272             this.connectable = null;
1273             var refCount = connectable._refCount;
1274             if (refCount <= 0) {
1275                 this.connection = null;
1276                 return;
1277             }
1278             connectable._refCount = refCount - 1;
1279             if (refCount > 1) {
1280                 this.connection = null;
1281                 return;
1282             }
1283             var connection = this.connection;
1284             var sharedConnection = connectable._connection;
1285             this.connection = null;
1286             if (sharedConnection && (!connection || sharedConnection === connection)) {
1287                 sharedConnection.unsubscribe();
1288             }
1289         };
1290         return RefCountSubscriber;
1291     }(Subscriber));
1292
1293     var ConnectableObservable = (function (_super) {
1294         __extends(ConnectableObservable, _super);
1295         function ConnectableObservable(source, subjectFactory) {
1296             var _this = _super.call(this) || this;
1297             _this.source = source;
1298             _this.subjectFactory = subjectFactory;
1299             _this._refCount = 0;
1300             _this._isComplete = false;
1301             return _this;
1302         }
1303         ConnectableObservable.prototype._subscribe = function (subscriber) {
1304             return this.getSubject().subscribe(subscriber);
1305         };
1306         ConnectableObservable.prototype.getSubject = function () {
1307             var subject = this._subject;
1308             if (!subject || subject.isStopped) {
1309                 this._subject = this.subjectFactory();
1310             }
1311             return this._subject;
1312         };
1313         ConnectableObservable.prototype.connect = function () {
1314             var connection = this._connection;
1315             if (!connection) {
1316                 this._isComplete = false;
1317                 connection = this._connection = new Subscription();
1318                 connection.add(this.source
1319                     .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
1320                 if (connection.closed) {
1321                     this._connection = null;
1322                     connection = Subscription.EMPTY;
1323                 }
1324             }
1325             return connection;
1326         };
1327         ConnectableObservable.prototype.refCount = function () {
1328             return refCount()(this);
1329         };
1330         return ConnectableObservable;
1331     }(Observable));
1332     var connectableObservableDescriptor = (function () {
1333         var connectableProto = ConnectableObservable.prototype;
1334         return {
1335             operator: { value: null },
1336             _refCount: { value: 0, writable: true },
1337             _subject: { value: null, writable: true },
1338             _connection: { value: null, writable: true },
1339             _subscribe: { value: connectableProto._subscribe },
1340             _isComplete: { value: connectableProto._isComplete, writable: true },
1341             getSubject: { value: connectableProto.getSubject },
1342             connect: { value: connectableProto.connect },
1343             refCount: { value: connectableProto.refCount }
1344         };
1345     })();
1346     var ConnectableSubscriber = (function (_super) {
1347         __extends(ConnectableSubscriber, _super);
1348         function ConnectableSubscriber(destination, connectable) {
1349             var _this = _super.call(this, destination) || this;
1350             _this.connectable = connectable;
1351             return _this;
1352         }
1353         ConnectableSubscriber.prototype._error = function (err) {
1354             this._unsubscribe();
1355             _super.prototype._error.call(this, err);
1356         };
1357         ConnectableSubscriber.prototype._complete = function () {
1358             this.connectable._isComplete = true;
1359             this._unsubscribe();
1360             _super.prototype._complete.call(this);
1361         };
1362         ConnectableSubscriber.prototype._unsubscribe = function () {
1363             var connectable = this.connectable;
1364             if (connectable) {
1365                 this.connectable = null;
1366                 var connection = connectable._connection;
1367                 connectable._refCount = 0;
1368                 connectable._subject = null;
1369                 connectable._connection = null;
1370                 if (connection) {
1371                     connection.unsubscribe();
1372                 }
1373             }
1374         };
1375         return ConnectableSubscriber;
1376     }(SubjectSubscriber));
1377     var RefCountSubscriber$1 = (function (_super) {
1378         __extends(RefCountSubscriber, _super);
1379         function RefCountSubscriber(destination, connectable) {
1380             var _this = _super.call(this, destination) || this;
1381             _this.connectable = connectable;
1382             return _this;
1383         }
1384         RefCountSubscriber.prototype._unsubscribe = function () {
1385             var connectable = this.connectable;
1386             if (!connectable) {
1387                 this.connection = null;
1388                 return;
1389             }
1390             this.connectable = null;
1391             var refCount$$1 = connectable._refCount;
1392             if (refCount$$1 <= 0) {
1393                 this.connection = null;
1394                 return;
1395             }
1396             connectable._refCount = refCount$$1 - 1;
1397             if (refCount$$1 > 1) {
1398                 this.connection = null;
1399                 return;
1400             }
1401             var connection = this.connection;
1402             var sharedConnection = connectable._connection;
1403             this.connection = null;
1404             if (sharedConnection && (!connection || sharedConnection === connection)) {
1405                 sharedConnection.unsubscribe();
1406             }
1407         };
1408         return RefCountSubscriber;
1409     }(Subscriber));
1410
1411     function groupBy(keySelector, elementSelector, durationSelector, subjectSelector) {
1412         return function (source) {
1413             return source.lift(new GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector));
1414         };
1415     }
1416     var GroupByOperator = (function () {
1417         function GroupByOperator(keySelector, elementSelector, durationSelector, subjectSelector) {
1418             this.keySelector = keySelector;
1419             this.elementSelector = elementSelector;
1420             this.durationSelector = durationSelector;
1421             this.subjectSelector = subjectSelector;
1422         }
1423         GroupByOperator.prototype.call = function (subscriber, source) {
1424             return source.subscribe(new GroupBySubscriber(subscriber, this.keySelector, this.elementSelector, this.durationSelector, this.subjectSelector));
1425         };
1426         return GroupByOperator;
1427     }());
1428     var GroupBySubscriber = (function (_super) {
1429         __extends(GroupBySubscriber, _super);
1430         function GroupBySubscriber(destination, keySelector, elementSelector, durationSelector, subjectSelector) {
1431             var _this = _super.call(this, destination) || this;
1432             _this.keySelector = keySelector;
1433             _this.elementSelector = elementSelector;
1434             _this.durationSelector = durationSelector;
1435             _this.subjectSelector = subjectSelector;
1436             _this.groups = null;
1437             _this.attemptedToUnsubscribe = false;
1438             _this.count = 0;
1439             return _this;
1440         }
1441         GroupBySubscriber.prototype._next = function (value) {
1442             var key;
1443             try {
1444                 key = this.keySelector(value);
1445             }
1446             catch (err) {
1447                 this.error(err);
1448                 return;
1449             }
1450             this._group(value, key);
1451         };
1452         GroupBySubscriber.prototype._group = function (value, key) {
1453             var groups = this.groups;
1454             if (!groups) {
1455                 groups = this.groups = new Map();
1456             }
1457             var group = groups.get(key);
1458             var element;
1459             if (this.elementSelector) {
1460                 try {
1461                     element = this.elementSelector(value);
1462                 }
1463                 catch (err) {
1464                     this.error(err);
1465                 }
1466             }
1467             else {
1468                 element = value;
1469             }
1470             if (!group) {
1471                 group = (this.subjectSelector ? this.subjectSelector() : new Subject());
1472                 groups.set(key, group);
1473                 var groupedObservable = new GroupedObservable(key, group, this);
1474                 this.destination.next(groupedObservable);
1475                 if (this.durationSelector) {
1476                     var duration = void 0;
1477                     try {
1478                         duration = this.durationSelector(new GroupedObservable(key, group));
1479                     }
1480                     catch (err) {
1481                         this.error(err);
1482                         return;
1483                     }
1484                     this.add(duration.subscribe(new GroupDurationSubscriber(key, group, this)));
1485                 }
1486             }
1487             if (!group.closed) {
1488                 group.next(element);
1489             }
1490         };
1491         GroupBySubscriber.prototype._error = function (err) {
1492             var groups = this.groups;
1493             if (groups) {
1494                 groups.forEach(function (group, key) {
1495                     group.error(err);
1496                 });
1497                 groups.clear();
1498             }
1499             this.destination.error(err);
1500         };
1501         GroupBySubscriber.prototype._complete = function () {
1502             var groups = this.groups;
1503             if (groups) {
1504                 groups.forEach(function (group, key) {
1505                     group.complete();
1506                 });
1507                 groups.clear();
1508             }
1509             this.destination.complete();
1510         };
1511         GroupBySubscriber.prototype.removeGroup = function (key) {
1512             this.groups.delete(key);
1513         };
1514         GroupBySubscriber.prototype.unsubscribe = function () {
1515             if (!this.closed) {
1516                 this.attemptedToUnsubscribe = true;
1517                 if (this.count === 0) {
1518                     _super.prototype.unsubscribe.call(this);
1519                 }
1520             }
1521         };
1522         return GroupBySubscriber;
1523     }(Subscriber));
1524     var GroupDurationSubscriber = (function (_super) {
1525         __extends(GroupDurationSubscriber, _super);
1526         function GroupDurationSubscriber(key, group, parent) {
1527             var _this = _super.call(this, group) || this;
1528             _this.key = key;
1529             _this.group = group;
1530             _this.parent = parent;
1531             return _this;
1532         }
1533         GroupDurationSubscriber.prototype._next = function (value) {
1534             this.complete();
1535         };
1536         GroupDurationSubscriber.prototype._unsubscribe = function () {
1537             var _a = this, parent = _a.parent, key = _a.key;
1538             this.key = this.parent = null;
1539             if (parent) {
1540                 parent.removeGroup(key);
1541             }
1542         };
1543         return GroupDurationSubscriber;
1544     }(Subscriber));
1545     var GroupedObservable = (function (_super) {
1546         __extends(GroupedObservable, _super);
1547         function GroupedObservable(key, groupSubject, refCountSubscription) {
1548             var _this = _super.call(this) || this;
1549             _this.key = key;
1550             _this.groupSubject = groupSubject;
1551             _this.refCountSubscription = refCountSubscription;
1552             return _this;
1553         }
1554         GroupedObservable.prototype._subscribe = function (subscriber) {
1555             var subscription = new Subscription();
1556             var _a = this, refCountSubscription = _a.refCountSubscription, groupSubject = _a.groupSubject;
1557             if (refCountSubscription && !refCountSubscription.closed) {
1558                 subscription.add(new InnerRefCountSubscription(refCountSubscription));
1559             }
1560             subscription.add(groupSubject.subscribe(subscriber));
1561             return subscription;
1562         };
1563         return GroupedObservable;
1564     }(Observable));
1565     var InnerRefCountSubscription = (function (_super) {
1566         __extends(InnerRefCountSubscription, _super);
1567         function InnerRefCountSubscription(parent) {
1568             var _this = _super.call(this) || this;
1569             _this.parent = parent;
1570             parent.count++;
1571             return _this;
1572         }
1573         InnerRefCountSubscription.prototype.unsubscribe = function () {
1574             var parent = this.parent;
1575             if (!parent.closed && !this.closed) {
1576                 _super.prototype.unsubscribe.call(this);
1577                 parent.count -= 1;
1578                 if (parent.count === 0 && parent.attemptedToUnsubscribe) {
1579                     parent.unsubscribe();
1580                 }
1581             }
1582         };
1583         return InnerRefCountSubscription;
1584     }(Subscription));
1585
1586     var BehaviorSubject = (function (_super) {
1587         __extends(BehaviorSubject, _super);
1588         function BehaviorSubject(_value) {
1589             var _this = _super.call(this) || this;
1590             _this._value = _value;
1591             return _this;
1592         }
1593         Object.defineProperty(BehaviorSubject.prototype, "value", {
1594             get: function () {
1595                 return this.getValue();
1596             },
1597             enumerable: true,
1598             configurable: true
1599         });
1600         BehaviorSubject.prototype._subscribe = function (subscriber) {
1601             var subscription = _super.prototype._subscribe.call(this, subscriber);
1602             if (subscription && !subscription.closed) {
1603                 subscriber.next(this._value);
1604             }
1605             return subscription;
1606         };
1607         BehaviorSubject.prototype.getValue = function () {
1608             if (this.hasError) {
1609                 throw this.thrownError;
1610             }
1611             else if (this.closed) {
1612                 throw new ObjectUnsubscribedError();
1613             }
1614             else {
1615                 return this._value;
1616             }
1617         };
1618         BehaviorSubject.prototype.next = function (value) {
1619             _super.prototype.next.call(this, this._value = value);
1620         };
1621         return BehaviorSubject;
1622     }(Subject));
1623
1624     var Action = (function (_super) {
1625         __extends(Action, _super);
1626         function Action(scheduler, work) {
1627             return _super.call(this) || this;
1628         }
1629         Action.prototype.schedule = function (state, delay) {
1630             if (delay === void 0) { delay = 0; }
1631             return this;
1632         };
1633         return Action;
1634     }(Subscription));
1635
1636     var AsyncAction = (function (_super) {
1637         __extends(AsyncAction, _super);
1638         function AsyncAction(scheduler, work) {
1639             var _this = _super.call(this, scheduler, work) || this;
1640             _this.scheduler = scheduler;
1641             _this.work = work;
1642             _this.pending = false;
1643             return _this;
1644         }
1645         AsyncAction.prototype.schedule = function (state, delay) {
1646             if (delay === void 0) { delay = 0; }
1647             if (this.closed) {
1648                 return this;
1649             }
1650             this.state = state;
1651             var id = this.id;
1652             var scheduler = this.scheduler;
1653             if (id != null) {
1654                 this.id = this.recycleAsyncId(scheduler, id, delay);
1655             }
1656             this.pending = true;
1657             this.delay = delay;
1658             this.id = this.id || this.requestAsyncId(scheduler, this.id, delay);
1659             return this;
1660         };
1661         AsyncAction.prototype.requestAsyncId = function (scheduler, id, delay) {
1662             if (delay === void 0) { delay = 0; }
1663             return setInterval(scheduler.flush.bind(scheduler, this), delay);
1664         };
1665         AsyncAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
1666             if (delay === void 0) { delay = 0; }
1667             if (delay !== null && this.delay === delay && this.pending === false) {
1668                 return id;
1669             }
1670             clearInterval(id);
1671             return undefined;
1672         };
1673         AsyncAction.prototype.execute = function (state, delay) {
1674             if (this.closed) {
1675                 return new Error('executing a cancelled action');
1676             }
1677             this.pending = false;
1678             var error = this._execute(state, delay);
1679             if (error) {
1680                 return error;
1681             }
1682             else if (this.pending === false && this.id != null) {
1683                 this.id = this.recycleAsyncId(this.scheduler, this.id, null);
1684             }
1685         };
1686         AsyncAction.prototype._execute = function (state, delay) {
1687             var errored = false;
1688             var errorValue = undefined;
1689             try {
1690                 this.work(state);
1691             }
1692             catch (e) {
1693                 errored = true;
1694                 errorValue = !!e && e || new Error(e);
1695             }
1696             if (errored) {
1697                 this.unsubscribe();
1698                 return errorValue;
1699             }
1700         };
1701         AsyncAction.prototype._unsubscribe = function () {
1702             var id = this.id;
1703             var scheduler = this.scheduler;
1704             var actions = scheduler.actions;
1705             var index = actions.indexOf(this);
1706             this.work = null;
1707             this.state = null;
1708             this.pending = false;
1709             this.scheduler = null;
1710             if (index !== -1) {
1711                 actions.splice(index, 1);
1712             }
1713             if (id != null) {
1714                 this.id = this.recycleAsyncId(scheduler, id, null);
1715             }
1716             this.delay = null;
1717         };
1718         return AsyncAction;
1719     }(Action));
1720
1721     var QueueAction = (function (_super) {
1722         __extends(QueueAction, _super);
1723         function QueueAction(scheduler, work) {
1724             var _this = _super.call(this, scheduler, work) || this;
1725             _this.scheduler = scheduler;
1726             _this.work = work;
1727             return _this;
1728         }
1729         QueueAction.prototype.schedule = function (state, delay) {
1730             if (delay === void 0) { delay = 0; }
1731             if (delay > 0) {
1732                 return _super.prototype.schedule.call(this, state, delay);
1733             }
1734             this.delay = delay;
1735             this.state = state;
1736             this.scheduler.flush(this);
1737             return this;
1738         };
1739         QueueAction.prototype.execute = function (state, delay) {
1740             return (delay > 0 || this.closed) ?
1741                 _super.prototype.execute.call(this, state, delay) :
1742                 this._execute(state, delay);
1743         };
1744         QueueAction.prototype.requestAsyncId = function (scheduler, id, delay) {
1745             if (delay === void 0) { delay = 0; }
1746             if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
1747                 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
1748             }
1749             return scheduler.flush(this);
1750         };
1751         return QueueAction;
1752     }(AsyncAction));
1753
1754     var Scheduler = (function () {
1755         function Scheduler(SchedulerAction, now) {
1756             if (now === void 0) { now = Scheduler.now; }
1757             this.SchedulerAction = SchedulerAction;
1758             this.now = now;
1759         }
1760         Scheduler.prototype.schedule = function (work, delay, state) {
1761             if (delay === void 0) { delay = 0; }
1762             return new this.SchedulerAction(this, work).schedule(state, delay);
1763         };
1764         Scheduler.now = function () { return Date.now(); };
1765         return Scheduler;
1766     }());
1767
1768     var AsyncScheduler = (function (_super) {
1769         __extends(AsyncScheduler, _super);
1770         function AsyncScheduler(SchedulerAction, now) {
1771             if (now === void 0) { now = Scheduler.now; }
1772             var _this = _super.call(this, SchedulerAction, function () {
1773                 if (AsyncScheduler.delegate && AsyncScheduler.delegate !== _this) {
1774                     return AsyncScheduler.delegate.now();
1775                 }
1776                 else {
1777                     return now();
1778                 }
1779             }) || this;
1780             _this.actions = [];
1781             _this.active = false;
1782             _this.scheduled = undefined;
1783             return _this;
1784         }
1785         AsyncScheduler.prototype.schedule = function (work, delay, state) {
1786             if (delay === void 0) { delay = 0; }
1787             if (AsyncScheduler.delegate && AsyncScheduler.delegate !== this) {
1788                 return AsyncScheduler.delegate.schedule(work, delay, state);
1789             }
1790             else {
1791                 return _super.prototype.schedule.call(this, work, delay, state);
1792             }
1793         };
1794         AsyncScheduler.prototype.flush = function (action) {
1795             var actions = this.actions;
1796             if (this.active) {
1797                 actions.push(action);
1798                 return;
1799             }
1800             var error;
1801             this.active = true;
1802             do {
1803                 if (error = action.execute(action.state, action.delay)) {
1804                     break;
1805                 }
1806             } while (action = actions.shift());
1807             this.active = false;
1808             if (error) {
1809                 while (action = actions.shift()) {
1810                     action.unsubscribe();
1811                 }
1812                 throw error;
1813             }
1814         };
1815         return AsyncScheduler;
1816     }(Scheduler));
1817
1818     var QueueScheduler = (function (_super) {
1819         __extends(QueueScheduler, _super);
1820         function QueueScheduler() {
1821             return _super !== null && _super.apply(this, arguments) || this;
1822         }
1823         return QueueScheduler;
1824     }(AsyncScheduler));
1825
1826     var queueScheduler = new QueueScheduler(QueueAction);
1827     var queue = queueScheduler;
1828
1829     var EMPTY = new Observable(function (subscriber) { return subscriber.complete(); });
1830     function empty$1(scheduler) {
1831         return scheduler ? emptyScheduled(scheduler) : EMPTY;
1832     }
1833     function emptyScheduled(scheduler) {
1834         return new Observable(function (subscriber) { return scheduler.schedule(function () { return subscriber.complete(); }); });
1835     }
1836
1837     function isScheduler(value) {
1838         return value && typeof value.schedule === 'function';
1839     }
1840
1841     var subscribeToArray = function (array) { return function (subscriber) {
1842         for (var i = 0, len = array.length; i < len && !subscriber.closed; i++) {
1843             subscriber.next(array[i]);
1844         }
1845         subscriber.complete();
1846     }; };
1847
1848     function scheduleArray(input, scheduler) {
1849         return new Observable(function (subscriber) {
1850             var sub = new Subscription();
1851             var i = 0;
1852             sub.add(scheduler.schedule(function () {
1853                 if (i === input.length) {
1854                     subscriber.complete();
1855                     return;
1856                 }
1857                 subscriber.next(input[i++]);
1858                 if (!subscriber.closed) {
1859                     sub.add(this.schedule());
1860                 }
1861             }));
1862             return sub;
1863         });
1864     }
1865
1866     function fromArray(input, scheduler) {
1867         if (!scheduler) {
1868             return new Observable(subscribeToArray(input));
1869         }
1870         else {
1871             return scheduleArray(input, scheduler);
1872         }
1873     }
1874
1875     function of() {
1876         var args = [];
1877         for (var _i = 0; _i < arguments.length; _i++) {
1878             args[_i] = arguments[_i];
1879         }
1880         var scheduler = args[args.length - 1];
1881         if (isScheduler(scheduler)) {
1882             args.pop();
1883             return scheduleArray(args, scheduler);
1884         }
1885         else {
1886             return fromArray(args);
1887         }
1888     }
1889
1890     function throwError(error, scheduler) {
1891         if (!scheduler) {
1892             return new Observable(function (subscriber) { return subscriber.error(error); });
1893         }
1894         else {
1895             return new Observable(function (subscriber) { return scheduler.schedule(dispatch, 0, { error: error, subscriber: subscriber }); });
1896         }
1897     }
1898     function dispatch(_a) {
1899         var error = _a.error, subscriber = _a.subscriber;
1900         subscriber.error(error);
1901     }
1902
1903     (function (NotificationKind) {
1904         NotificationKind["NEXT"] = "N";
1905         NotificationKind["ERROR"] = "E";
1906         NotificationKind["COMPLETE"] = "C";
1907     })(exports.NotificationKind || (exports.NotificationKind = {}));
1908     var Notification = (function () {
1909         function Notification(kind, value, error) {
1910             this.kind = kind;
1911             this.value = value;
1912             this.error = error;
1913             this.hasValue = kind === 'N';
1914         }
1915         Notification.prototype.observe = function (observer) {
1916             switch (this.kind) {
1917                 case 'N':
1918                     return observer.next && observer.next(this.value);
1919                 case 'E':
1920                     return observer.error && observer.error(this.error);
1921                 case 'C':
1922                     return observer.complete && observer.complete();
1923             }
1924         };
1925         Notification.prototype.do = function (next, error, complete) {
1926             var kind = this.kind;
1927             switch (kind) {
1928                 case 'N':
1929                     return next && next(this.value);
1930                 case 'E':
1931                     return error && error(this.error);
1932                 case 'C':
1933                     return complete && complete();
1934             }
1935         };
1936         Notification.prototype.accept = function (nextOrObserver, error, complete) {
1937             if (nextOrObserver && typeof nextOrObserver.next === 'function') {
1938                 return this.observe(nextOrObserver);
1939             }
1940             else {
1941                 return this.do(nextOrObserver, error, complete);
1942             }
1943         };
1944         Notification.prototype.toObservable = function () {
1945             var kind = this.kind;
1946             switch (kind) {
1947                 case 'N':
1948                     return of(this.value);
1949                 case 'E':
1950                     return throwError(this.error);
1951                 case 'C':
1952                     return empty$1();
1953             }
1954             throw new Error('unexpected notification kind value');
1955         };
1956         Notification.createNext = function (value) {
1957             if (typeof value !== 'undefined') {
1958                 return new Notification('N', value);
1959             }
1960             return Notification.undefinedValueNotification;
1961         };
1962         Notification.createError = function (err) {
1963             return new Notification('E', undefined, err);
1964         };
1965         Notification.createComplete = function () {
1966             return Notification.completeNotification;
1967         };
1968         Notification.completeNotification = new Notification('C');
1969         Notification.undefinedValueNotification = new Notification('N', undefined);
1970         return Notification;
1971     }());
1972
1973     function observeOn(scheduler, delay) {
1974         if (delay === void 0) { delay = 0; }
1975         return function observeOnOperatorFunction(source) {
1976             return source.lift(new ObserveOnOperator(scheduler, delay));
1977         };
1978     }
1979     var ObserveOnOperator = (function () {
1980         function ObserveOnOperator(scheduler, delay) {
1981             if (delay === void 0) { delay = 0; }
1982             this.scheduler = scheduler;
1983             this.delay = delay;
1984         }
1985         ObserveOnOperator.prototype.call = function (subscriber, source) {
1986             return source.subscribe(new ObserveOnSubscriber(subscriber, this.scheduler, this.delay));
1987         };
1988         return ObserveOnOperator;
1989     }());
1990     var ObserveOnSubscriber = (function (_super) {
1991         __extends(ObserveOnSubscriber, _super);
1992         function ObserveOnSubscriber(destination, scheduler, delay) {
1993             if (delay === void 0) { delay = 0; }
1994             var _this = _super.call(this, destination) || this;
1995             _this.scheduler = scheduler;
1996             _this.delay = delay;
1997             return _this;
1998         }
1999         ObserveOnSubscriber.dispatch = function (arg) {
2000             var notification = arg.notification, destination = arg.destination;
2001             notification.observe(destination);
2002             this.unsubscribe();
2003         };
2004         ObserveOnSubscriber.prototype.scheduleMessage = function (notification) {
2005             var destination = this.destination;
2006             destination.add(this.scheduler.schedule(ObserveOnSubscriber.dispatch, this.delay, new ObserveOnMessage(notification, this.destination)));
2007         };
2008         ObserveOnSubscriber.prototype._next = function (value) {
2009             this.scheduleMessage(Notification.createNext(value));
2010         };
2011         ObserveOnSubscriber.prototype._error = function (err) {
2012             this.scheduleMessage(Notification.createError(err));
2013             this.unsubscribe();
2014         };
2015         ObserveOnSubscriber.prototype._complete = function () {
2016             this.scheduleMessage(Notification.createComplete());
2017             this.unsubscribe();
2018         };
2019         return ObserveOnSubscriber;
2020     }(Subscriber));
2021     var ObserveOnMessage = (function () {
2022         function ObserveOnMessage(notification, destination) {
2023             this.notification = notification;
2024             this.destination = destination;
2025         }
2026         return ObserveOnMessage;
2027     }());
2028
2029     var ReplaySubject = (function (_super) {
2030         __extends(ReplaySubject, _super);
2031         function ReplaySubject(bufferSize, windowTime, scheduler) {
2032             if (bufferSize === void 0) { bufferSize = Number.POSITIVE_INFINITY; }
2033             if (windowTime === void 0) { windowTime = Number.POSITIVE_INFINITY; }
2034             var _this = _super.call(this) || this;
2035             _this.scheduler = scheduler;
2036             _this._events = [];
2037             _this._infiniteTimeWindow = false;
2038             _this._bufferSize = bufferSize < 1 ? 1 : bufferSize;
2039             _this._windowTime = windowTime < 1 ? 1 : windowTime;
2040             if (windowTime === Number.POSITIVE_INFINITY) {
2041                 _this._infiniteTimeWindow = true;
2042                 _this.next = _this.nextInfiniteTimeWindow;
2043             }
2044             else {
2045                 _this.next = _this.nextTimeWindow;
2046             }
2047             return _this;
2048         }
2049         ReplaySubject.prototype.nextInfiniteTimeWindow = function (value) {
2050             if (!this.isStopped) {
2051                 var _events = this._events;
2052                 _events.push(value);
2053                 if (_events.length > this._bufferSize) {
2054                     _events.shift();
2055                 }
2056             }
2057             _super.prototype.next.call(this, value);
2058         };
2059         ReplaySubject.prototype.nextTimeWindow = function (value) {
2060             if (!this.isStopped) {
2061                 this._events.push(new ReplayEvent(this._getNow(), value));
2062                 this._trimBufferThenGetEvents();
2063             }
2064             _super.prototype.next.call(this, value);
2065         };
2066         ReplaySubject.prototype._subscribe = function (subscriber) {
2067             var _infiniteTimeWindow = this._infiniteTimeWindow;
2068             var _events = _infiniteTimeWindow ? this._events : this._trimBufferThenGetEvents();
2069             var scheduler = this.scheduler;
2070             var len = _events.length;
2071             var subscription;
2072             if (this.closed) {
2073                 throw new ObjectUnsubscribedError();
2074             }
2075             else if (this.isStopped || this.hasError) {
2076                 subscription = Subscription.EMPTY;
2077             }
2078             else {
2079                 this.observers.push(subscriber);
2080                 subscription = new SubjectSubscription(this, subscriber);
2081             }
2082             if (scheduler) {
2083                 subscriber.add(subscriber = new ObserveOnSubscriber(subscriber, scheduler));
2084             }
2085             if (_infiniteTimeWindow) {
2086                 for (var i = 0; i < len && !subscriber.closed; i++) {
2087                     subscriber.next(_events[i]);
2088                 }
2089             }
2090             else {
2091                 for (var i = 0; i < len && !subscriber.closed; i++) {
2092                     subscriber.next(_events[i].value);
2093                 }
2094             }
2095             if (this.hasError) {
2096                 subscriber.error(this.thrownError);
2097             }
2098             else if (this.isStopped) {
2099                 subscriber.complete();
2100             }
2101             return subscription;
2102         };
2103         ReplaySubject.prototype._getNow = function () {
2104             return (this.scheduler || queue).now();
2105         };
2106         ReplaySubject.prototype._trimBufferThenGetEvents = function () {
2107             var now = this._getNow();
2108             var _bufferSize = this._bufferSize;
2109             var _windowTime = this._windowTime;
2110             var _events = this._events;
2111             var eventsCount = _events.length;
2112             var spliceCount = 0;
2113             while (spliceCount < eventsCount) {
2114                 if ((now - _events[spliceCount].time) < _windowTime) {
2115                     break;
2116                 }
2117                 spliceCount++;
2118             }
2119             if (eventsCount > _bufferSize) {
2120                 spliceCount = Math.max(spliceCount, eventsCount - _bufferSize);
2121             }
2122             if (spliceCount > 0) {
2123                 _events.splice(0, spliceCount);
2124             }
2125             return _events;
2126         };
2127         return ReplaySubject;
2128     }(Subject));
2129     var ReplayEvent = (function () {
2130         function ReplayEvent(time, value) {
2131             this.time = time;
2132             this.value = value;
2133         }
2134         return ReplayEvent;
2135     }());
2136
2137     var AsyncSubject = (function (_super) {
2138         __extends(AsyncSubject, _super);
2139         function AsyncSubject() {
2140             var _this = _super !== null && _super.apply(this, arguments) || this;
2141             _this.value = null;
2142             _this.hasNext = false;
2143             _this.hasCompleted = false;
2144             return _this;
2145         }
2146         AsyncSubject.prototype._subscribe = function (subscriber) {
2147             if (this.hasError) {
2148                 subscriber.error(this.thrownError);
2149                 return Subscription.EMPTY;
2150             }
2151             else if (this.hasCompleted && this.hasNext) {
2152                 subscriber.next(this.value);
2153                 subscriber.complete();
2154                 return Subscription.EMPTY;
2155             }
2156             return _super.prototype._subscribe.call(this, subscriber);
2157         };
2158         AsyncSubject.prototype.next = function (value) {
2159             if (!this.hasCompleted) {
2160                 this.value = value;
2161                 this.hasNext = true;
2162             }
2163         };
2164         AsyncSubject.prototype.error = function (error) {
2165             if (!this.hasCompleted) {
2166                 _super.prototype.error.call(this, error);
2167             }
2168         };
2169         AsyncSubject.prototype.complete = function () {
2170             this.hasCompleted = true;
2171             if (this.hasNext) {
2172                 _super.prototype.next.call(this, this.value);
2173             }
2174             _super.prototype.complete.call(this);
2175         };
2176         return AsyncSubject;
2177     }(Subject));
2178
2179     var nextHandle = 1;
2180     var RESOLVED = (function () { return Promise.resolve(); })();
2181     var activeHandles = {};
2182     function findAndClearHandle(handle) {
2183         if (handle in activeHandles) {
2184             delete activeHandles[handle];
2185             return true;
2186         }
2187         return false;
2188     }
2189     var Immediate = {
2190         setImmediate: function (cb) {
2191             var handle = nextHandle++;
2192             activeHandles[handle] = true;
2193             RESOLVED.then(function () { return findAndClearHandle(handle) && cb(); });
2194             return handle;
2195         },
2196         clearImmediate: function (handle) {
2197             findAndClearHandle(handle);
2198         },
2199     };
2200
2201     var AsapAction = (function (_super) {
2202         __extends(AsapAction, _super);
2203         function AsapAction(scheduler, work) {
2204             var _this = _super.call(this, scheduler, work) || this;
2205             _this.scheduler = scheduler;
2206             _this.work = work;
2207             return _this;
2208         }
2209         AsapAction.prototype.requestAsyncId = function (scheduler, id, delay) {
2210             if (delay === void 0) { delay = 0; }
2211             if (delay !== null && delay > 0) {
2212                 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
2213             }
2214             scheduler.actions.push(this);
2215             return scheduler.scheduled || (scheduler.scheduled = Immediate.setImmediate(scheduler.flush.bind(scheduler, null)));
2216         };
2217         AsapAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
2218             if (delay === void 0) { delay = 0; }
2219             if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
2220                 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
2221             }
2222             if (scheduler.actions.length === 0) {
2223                 Immediate.clearImmediate(id);
2224                 scheduler.scheduled = undefined;
2225             }
2226             return undefined;
2227         };
2228         return AsapAction;
2229     }(AsyncAction));
2230
2231     var AsapScheduler = (function (_super) {
2232         __extends(AsapScheduler, _super);
2233         function AsapScheduler() {
2234             return _super !== null && _super.apply(this, arguments) || this;
2235         }
2236         AsapScheduler.prototype.flush = function (action) {
2237             this.active = true;
2238             this.scheduled = undefined;
2239             var actions = this.actions;
2240             var error;
2241             var index = -1;
2242             var count = actions.length;
2243             action = action || actions.shift();
2244             do {
2245                 if (error = action.execute(action.state, action.delay)) {
2246                     break;
2247                 }
2248             } while (++index < count && (action = actions.shift()));
2249             this.active = false;
2250             if (error) {
2251                 while (++index < count && (action = actions.shift())) {
2252                     action.unsubscribe();
2253                 }
2254                 throw error;
2255             }
2256         };
2257         return AsapScheduler;
2258     }(AsyncScheduler));
2259
2260     var asapScheduler = new AsapScheduler(AsapAction);
2261     var asap = asapScheduler;
2262
2263     var asyncScheduler = new AsyncScheduler(AsyncAction);
2264     var async = asyncScheduler;
2265
2266     var AnimationFrameAction = (function (_super) {
2267         __extends(AnimationFrameAction, _super);
2268         function AnimationFrameAction(scheduler, work) {
2269             var _this = _super.call(this, scheduler, work) || this;
2270             _this.scheduler = scheduler;
2271             _this.work = work;
2272             return _this;
2273         }
2274         AnimationFrameAction.prototype.requestAsyncId = function (scheduler, id, delay) {
2275             if (delay === void 0) { delay = 0; }
2276             if (delay !== null && delay > 0) {
2277                 return _super.prototype.requestAsyncId.call(this, scheduler, id, delay);
2278             }
2279             scheduler.actions.push(this);
2280             return scheduler.scheduled || (scheduler.scheduled = requestAnimationFrame(function () { return scheduler.flush(null); }));
2281         };
2282         AnimationFrameAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
2283             if (delay === void 0) { delay = 0; }
2284             if ((delay !== null && delay > 0) || (delay === null && this.delay > 0)) {
2285                 return _super.prototype.recycleAsyncId.call(this, scheduler, id, delay);
2286             }
2287             if (scheduler.actions.length === 0) {
2288                 cancelAnimationFrame(id);
2289                 scheduler.scheduled = undefined;
2290             }
2291             return undefined;
2292         };
2293         return AnimationFrameAction;
2294     }(AsyncAction));
2295
2296     var AnimationFrameScheduler = (function (_super) {
2297         __extends(AnimationFrameScheduler, _super);
2298         function AnimationFrameScheduler() {
2299             return _super !== null && _super.apply(this, arguments) || this;
2300         }
2301         AnimationFrameScheduler.prototype.flush = function (action) {
2302             this.active = true;
2303             this.scheduled = undefined;
2304             var actions = this.actions;
2305             var error;
2306             var index = -1;
2307             var count = actions.length;
2308             action = action || actions.shift();
2309             do {
2310                 if (error = action.execute(action.state, action.delay)) {
2311                     break;
2312                 }
2313             } while (++index < count && (action = actions.shift()));
2314             this.active = false;
2315             if (error) {
2316                 while (++index < count && (action = actions.shift())) {
2317                     action.unsubscribe();
2318                 }
2319                 throw error;
2320             }
2321         };
2322         return AnimationFrameScheduler;
2323     }(AsyncScheduler));
2324
2325     var animationFrameScheduler = new AnimationFrameScheduler(AnimationFrameAction);
2326     var animationFrame = animationFrameScheduler;
2327
2328     var VirtualTimeScheduler = (function (_super) {
2329         __extends(VirtualTimeScheduler, _super);
2330         function VirtualTimeScheduler(SchedulerAction, maxFrames) {
2331             if (SchedulerAction === void 0) { SchedulerAction = VirtualAction; }
2332             if (maxFrames === void 0) { maxFrames = Number.POSITIVE_INFINITY; }
2333             var _this = _super.call(this, SchedulerAction, function () { return _this.frame; }) || this;
2334             _this.maxFrames = maxFrames;
2335             _this.frame = 0;
2336             _this.index = -1;
2337             return _this;
2338         }
2339         VirtualTimeScheduler.prototype.flush = function () {
2340             var _a = this, actions = _a.actions, maxFrames = _a.maxFrames;
2341             var error, action;
2342             while ((action = actions[0]) && action.delay <= maxFrames) {
2343                 actions.shift();
2344                 this.frame = action.delay;
2345                 if (error = action.execute(action.state, action.delay)) {
2346                     break;
2347                 }
2348             }
2349             if (error) {
2350                 while (action = actions.shift()) {
2351                     action.unsubscribe();
2352                 }
2353                 throw error;
2354             }
2355         };
2356         VirtualTimeScheduler.frameTimeFactor = 10;
2357         return VirtualTimeScheduler;
2358     }(AsyncScheduler));
2359     var VirtualAction = (function (_super) {
2360         __extends(VirtualAction, _super);
2361         function VirtualAction(scheduler, work, index) {
2362             if (index === void 0) { index = scheduler.index += 1; }
2363             var _this = _super.call(this, scheduler, work) || this;
2364             _this.scheduler = scheduler;
2365             _this.work = work;
2366             _this.index = index;
2367             _this.active = true;
2368             _this.index = scheduler.index = index;
2369             return _this;
2370         }
2371         VirtualAction.prototype.schedule = function (state, delay) {
2372             if (delay === void 0) { delay = 0; }
2373             if (!this.id) {
2374                 return _super.prototype.schedule.call(this, state, delay);
2375             }
2376             this.active = false;
2377             var action = new VirtualAction(this.scheduler, this.work);
2378             this.add(action);
2379             return action.schedule(state, delay);
2380         };
2381         VirtualAction.prototype.requestAsyncId = function (scheduler, id, delay) {
2382             if (delay === void 0) { delay = 0; }
2383             this.delay = scheduler.frame + delay;
2384             var actions = scheduler.actions;
2385             actions.push(this);
2386             actions.sort(VirtualAction.sortActions);
2387             return true;
2388         };
2389         VirtualAction.prototype.recycleAsyncId = function (scheduler, id, delay) {
2390             if (delay === void 0) { delay = 0; }
2391             return undefined;
2392         };
2393         VirtualAction.prototype._execute = function (state, delay) {
2394             if (this.active === true) {
2395                 return _super.prototype._execute.call(this, state, delay);
2396             }
2397         };
2398         VirtualAction.sortActions = function (a, b) {
2399             if (a.delay === b.delay) {
2400                 if (a.index === b.index) {
2401                     return 0;
2402                 }
2403                 else if (a.index > b.index) {
2404                     return 1;
2405                 }
2406                 else {
2407                     return -1;
2408                 }
2409             }
2410             else if (a.delay > b.delay) {
2411                 return 1;
2412             }
2413             else {
2414                 return -1;
2415             }
2416         };
2417         return VirtualAction;
2418     }(AsyncAction));
2419
2420     function noop() { }
2421
2422     function isObservable(obj) {
2423         return !!obj && (obj instanceof Observable || (typeof obj.lift === 'function' && typeof obj.subscribe === 'function'));
2424     }
2425
2426     var ArgumentOutOfRangeErrorImpl = (function () {
2427         function ArgumentOutOfRangeErrorImpl() {
2428             Error.call(this);
2429             this.message = 'argument out of range';
2430             this.name = 'ArgumentOutOfRangeError';
2431             return this;
2432         }
2433         ArgumentOutOfRangeErrorImpl.prototype = Object.create(Error.prototype);
2434         return ArgumentOutOfRangeErrorImpl;
2435     })();
2436     var ArgumentOutOfRangeError = ArgumentOutOfRangeErrorImpl;
2437
2438     var EmptyErrorImpl = (function () {
2439         function EmptyErrorImpl() {
2440             Error.call(this);
2441             this.message = 'no elements in sequence';
2442             this.name = 'EmptyError';
2443             return this;
2444         }
2445         EmptyErrorImpl.prototype = Object.create(Error.prototype);
2446         return EmptyErrorImpl;
2447     })();
2448     var EmptyError = EmptyErrorImpl;
2449
2450     var TimeoutErrorImpl = (function () {
2451         function TimeoutErrorImpl() {
2452             Error.call(this);
2453             this.message = 'Timeout has occurred';
2454             this.name = 'TimeoutError';
2455             return this;
2456         }
2457         TimeoutErrorImpl.prototype = Object.create(Error.prototype);
2458         return TimeoutErrorImpl;
2459     })();
2460     var TimeoutError = TimeoutErrorImpl;
2461
2462     function map(project, thisArg) {
2463         return function mapOperation(source) {
2464             if (typeof project !== 'function') {
2465                 throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
2466             }
2467             return source.lift(new MapOperator(project, thisArg));
2468         };
2469     }
2470     var MapOperator = (function () {
2471         function MapOperator(project, thisArg) {
2472             this.project = project;
2473             this.thisArg = thisArg;
2474         }
2475         MapOperator.prototype.call = function (subscriber, source) {
2476             return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
2477         };
2478         return MapOperator;
2479     }());
2480     var MapSubscriber = (function (_super) {
2481         __extends(MapSubscriber, _super);
2482         function MapSubscriber(destination, project, thisArg) {
2483             var _this = _super.call(this, destination) || this;
2484             _this.project = project;
2485             _this.count = 0;
2486             _this.thisArg = thisArg || _this;
2487             return _this;
2488         }
2489         MapSubscriber.prototype._next = function (value) {
2490             var result;
2491             try {
2492                 result = this.project.call(this.thisArg, value, this.count++);
2493             }
2494             catch (err) {
2495                 this.destination.error(err);
2496                 return;
2497             }
2498             this.destination.next(result);
2499         };
2500         return MapSubscriber;
2501     }(Subscriber));
2502
2503     function bindCallback(callbackFunc, resultSelector, scheduler) {
2504         if (resultSelector) {
2505             if (isScheduler(resultSelector)) {
2506                 scheduler = resultSelector;
2507             }
2508             else {
2509                 return function () {
2510                     var args = [];
2511                     for (var _i = 0; _i < arguments.length; _i++) {
2512                         args[_i] = arguments[_i];
2513                     }
2514                     return bindCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
2515                 };
2516             }
2517         }
2518         return function () {
2519             var args = [];
2520             for (var _i = 0; _i < arguments.length; _i++) {
2521                 args[_i] = arguments[_i];
2522             }
2523             var context = this;
2524             var subject;
2525             var params = {
2526                 context: context,
2527                 subject: subject,
2528                 callbackFunc: callbackFunc,
2529                 scheduler: scheduler,
2530             };
2531             return new Observable(function (subscriber) {
2532                 if (!scheduler) {
2533                     if (!subject) {
2534                         subject = new AsyncSubject();
2535                         var handler = function () {
2536                             var innerArgs = [];
2537                             for (var _i = 0; _i < arguments.length; _i++) {
2538                                 innerArgs[_i] = arguments[_i];
2539                             }
2540                             subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
2541                             subject.complete();
2542                         };
2543                         try {
2544                             callbackFunc.apply(context, args.concat([handler]));
2545                         }
2546                         catch (err) {
2547                             if (canReportError(subject)) {
2548                                 subject.error(err);
2549                             }
2550                             else {
2551                                 console.warn(err);
2552                             }
2553                         }
2554                     }
2555                     return subject.subscribe(subscriber);
2556                 }
2557                 else {
2558                     var state = {
2559                         args: args, subscriber: subscriber, params: params,
2560                     };
2561                     return scheduler.schedule(dispatch$1, 0, state);
2562                 }
2563             });
2564         };
2565     }
2566     function dispatch$1(state) {
2567         var _this = this;
2568         var args = state.args, subscriber = state.subscriber, params = state.params;
2569         var callbackFunc = params.callbackFunc, context = params.context, scheduler = params.scheduler;
2570         var subject = params.subject;
2571         if (!subject) {
2572             subject = params.subject = new AsyncSubject();
2573             var handler = function () {
2574                 var innerArgs = [];
2575                 for (var _i = 0; _i < arguments.length; _i++) {
2576                     innerArgs[_i] = arguments[_i];
2577                 }
2578                 var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
2579                 _this.add(scheduler.schedule(dispatchNext, 0, { value: value, subject: subject }));
2580             };
2581             try {
2582                 callbackFunc.apply(context, args.concat([handler]));
2583             }
2584             catch (err) {
2585                 subject.error(err);
2586             }
2587         }
2588         this.add(subject.subscribe(subscriber));
2589     }
2590     function dispatchNext(state) {
2591         var value = state.value, subject = state.subject;
2592         subject.next(value);
2593         subject.complete();
2594     }
2595
2596     function bindNodeCallback(callbackFunc, resultSelector, scheduler) {
2597         if (resultSelector) {
2598             if (isScheduler(resultSelector)) {
2599                 scheduler = resultSelector;
2600             }
2601             else {
2602                 return function () {
2603                     var args = [];
2604                     for (var _i = 0; _i < arguments.length; _i++) {
2605                         args[_i] = arguments[_i];
2606                     }
2607                     return bindNodeCallback(callbackFunc, scheduler).apply(void 0, args).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
2608                 };
2609             }
2610         }
2611         return function () {
2612             var args = [];
2613             for (var _i = 0; _i < arguments.length; _i++) {
2614                 args[_i] = arguments[_i];
2615             }
2616             var params = {
2617                 subject: undefined,
2618                 args: args,
2619                 callbackFunc: callbackFunc,
2620                 scheduler: scheduler,
2621                 context: this,
2622             };
2623             return new Observable(function (subscriber) {
2624                 var context = params.context;
2625                 var subject = params.subject;
2626                 if (!scheduler) {
2627                     if (!subject) {
2628                         subject = params.subject = new AsyncSubject();
2629                         var handler = function () {
2630                             var innerArgs = [];
2631                             for (var _i = 0; _i < arguments.length; _i++) {
2632                                 innerArgs[_i] = arguments[_i];
2633                             }
2634                             var err = innerArgs.shift();
2635                             if (err) {
2636                                 subject.error(err);
2637                                 return;
2638                             }
2639                             subject.next(innerArgs.length <= 1 ? innerArgs[0] : innerArgs);
2640                             subject.complete();
2641                         };
2642                         try {
2643                             callbackFunc.apply(context, args.concat([handler]));
2644                         }
2645                         catch (err) {
2646                             if (canReportError(subject)) {
2647                                 subject.error(err);
2648                             }
2649                             else {
2650                                 console.warn(err);
2651                             }
2652                         }
2653                     }
2654                     return subject.subscribe(subscriber);
2655                 }
2656                 else {
2657                     return scheduler.schedule(dispatch$2, 0, { params: params, subscriber: subscriber, context: context });
2658                 }
2659             });
2660         };
2661     }
2662     function dispatch$2(state) {
2663         var _this = this;
2664         var params = state.params, subscriber = state.subscriber, context = state.context;
2665         var callbackFunc = params.callbackFunc, args = params.args, scheduler = params.scheduler;
2666         var subject = params.subject;
2667         if (!subject) {
2668             subject = params.subject = new AsyncSubject();
2669             var handler = function () {
2670                 var innerArgs = [];
2671                 for (var _i = 0; _i < arguments.length; _i++) {
2672                     innerArgs[_i] = arguments[_i];
2673                 }
2674                 var err = innerArgs.shift();
2675                 if (err) {
2676                     _this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
2677                 }
2678                 else {
2679                     var value = innerArgs.length <= 1 ? innerArgs[0] : innerArgs;
2680                     _this.add(scheduler.schedule(dispatchNext$1, 0, { value: value, subject: subject }));
2681                 }
2682             };
2683             try {
2684                 callbackFunc.apply(context, args.concat([handler]));
2685             }
2686             catch (err) {
2687                 this.add(scheduler.schedule(dispatchError$1, 0, { err: err, subject: subject }));
2688             }
2689         }
2690         this.add(subject.subscribe(subscriber));
2691     }
2692     function dispatchNext$1(arg) {
2693         var value = arg.value, subject = arg.subject;
2694         subject.next(value);
2695         subject.complete();
2696     }
2697     function dispatchError$1(arg) {
2698         var err = arg.err, subject = arg.subject;
2699         subject.error(err);
2700     }
2701
2702     var OuterSubscriber = (function (_super) {
2703         __extends(OuterSubscriber, _super);
2704         function OuterSubscriber() {
2705             return _super !== null && _super.apply(this, arguments) || this;
2706         }
2707         OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
2708             this.destination.next(innerValue);
2709         };
2710         OuterSubscriber.prototype.notifyError = function (error, innerSub) {
2711             this.destination.error(error);
2712         };
2713         OuterSubscriber.prototype.notifyComplete = function (innerSub) {
2714             this.destination.complete();
2715         };
2716         return OuterSubscriber;
2717     }(Subscriber));
2718
2719     var InnerSubscriber = (function (_super) {
2720         __extends(InnerSubscriber, _super);
2721         function InnerSubscriber(parent, outerValue, outerIndex) {
2722             var _this = _super.call(this) || this;
2723             _this.parent = parent;
2724             _this.outerValue = outerValue;
2725             _this.outerIndex = outerIndex;
2726             _this.index = 0;
2727             return _this;
2728         }
2729         InnerSubscriber.prototype._next = function (value) {
2730             this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
2731         };
2732         InnerSubscriber.prototype._error = function (error) {
2733             this.parent.notifyError(error, this);
2734             this.unsubscribe();
2735         };
2736         InnerSubscriber.prototype._complete = function () {
2737             this.parent.notifyComplete(this);
2738             this.unsubscribe();
2739         };
2740         return InnerSubscriber;
2741     }(Subscriber));
2742
2743     var subscribeToPromise = function (promise) { return function (subscriber) {
2744         promise.then(function (value) {
2745             if (!subscriber.closed) {
2746                 subscriber.next(value);
2747                 subscriber.complete();
2748             }
2749         }, function (err) { return subscriber.error(err); })
2750             .then(null, hostReportError);
2751         return subscriber;
2752     }; };
2753
2754     function getSymbolIterator() {
2755         if (typeof Symbol !== 'function' || !Symbol.iterator) {
2756             return '@@iterator';
2757         }
2758         return Symbol.iterator;
2759     }
2760     var iterator = getSymbolIterator();
2761
2762     var subscribeToIterable = function (iterable) { return function (subscriber) {
2763         var iterator$$1 = iterable[iterator]();
2764         do {
2765             var item = void 0;
2766             try {
2767                 item = iterator$$1.next();
2768             }
2769             catch (err) {
2770                 subscriber.error(err);
2771                 return subscriber;
2772             }
2773             if (item.done) {
2774                 subscriber.complete();
2775                 break;
2776             }
2777             subscriber.next(item.value);
2778             if (subscriber.closed) {
2779                 break;
2780             }
2781         } while (true);
2782         if (typeof iterator$$1.return === 'function') {
2783             subscriber.add(function () {
2784                 if (iterator$$1.return) {
2785                     iterator$$1.return();
2786                 }
2787             });
2788         }
2789         return subscriber;
2790     }; };
2791
2792     var subscribeToObservable = function (obj) { return function (subscriber) {
2793         var obs = obj[observable]();
2794         if (typeof obs.subscribe !== 'function') {
2795             throw new TypeError('Provided object does not correctly implement Symbol.observable');
2796         }
2797         else {
2798             return obs.subscribe(subscriber);
2799         }
2800     }; };
2801
2802     var isArrayLike = (function (x) { return x && typeof x.length === 'number' && typeof x !== 'function'; });
2803
2804     function isPromise(value) {
2805         return !!value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
2806     }
2807
2808     var subscribeTo = function (result) {
2809         if (!!result && typeof result[observable] === 'function') {
2810             return subscribeToObservable(result);
2811         }
2812         else if (isArrayLike(result)) {
2813             return subscribeToArray(result);
2814         }
2815         else if (isPromise(result)) {
2816             return subscribeToPromise(result);
2817         }
2818         else if (!!result && typeof result[iterator] === 'function') {
2819             return subscribeToIterable(result);
2820         }
2821         else {
2822             var value = isObject(result) ? 'an invalid object' : "'" + result + "'";
2823             var msg = "You provided " + value + " where a stream was expected."
2824                 + ' You can provide an Observable, Promise, Array, or Iterable.';
2825             throw new TypeError(msg);
2826         }
2827     };
2828
2829     function subscribeToResult(outerSubscriber, result, outerValue, outerIndex, innerSubscriber) {
2830         if (innerSubscriber === void 0) { innerSubscriber = new InnerSubscriber(outerSubscriber, outerValue, outerIndex); }
2831         if (innerSubscriber.closed) {
2832             return undefined;
2833         }
2834         if (result instanceof Observable) {
2835             return result.subscribe(innerSubscriber);
2836         }
2837         return subscribeTo(result)(innerSubscriber);
2838     }
2839
2840     var NONE = {};
2841     function combineLatest() {
2842         var observables = [];
2843         for (var _i = 0; _i < arguments.length; _i++) {
2844             observables[_i] = arguments[_i];
2845         }
2846         var resultSelector = undefined;
2847         var scheduler = undefined;
2848         if (isScheduler(observables[observables.length - 1])) {
2849             scheduler = observables.pop();
2850         }
2851         if (typeof observables[observables.length - 1] === 'function') {
2852             resultSelector = observables.pop();
2853         }
2854         if (observables.length === 1 && isArray(observables[0])) {
2855             observables = observables[0];
2856         }
2857         return fromArray(observables, scheduler).lift(new CombineLatestOperator(resultSelector));
2858     }
2859     var CombineLatestOperator = (function () {
2860         function CombineLatestOperator(resultSelector) {
2861             this.resultSelector = resultSelector;
2862         }
2863         CombineLatestOperator.prototype.call = function (subscriber, source) {
2864             return source.subscribe(new CombineLatestSubscriber(subscriber, this.resultSelector));
2865         };
2866         return CombineLatestOperator;
2867     }());
2868     var CombineLatestSubscriber = (function (_super) {
2869         __extends(CombineLatestSubscriber, _super);
2870         function CombineLatestSubscriber(destination, resultSelector) {
2871             var _this = _super.call(this, destination) || this;
2872             _this.resultSelector = resultSelector;
2873             _this.active = 0;
2874             _this.values = [];
2875             _this.observables = [];
2876             return _this;
2877         }
2878         CombineLatestSubscriber.prototype._next = function (observable) {
2879             this.values.push(NONE);
2880             this.observables.push(observable);
2881         };
2882         CombineLatestSubscriber.prototype._complete = function () {
2883             var observables = this.observables;
2884             var len = observables.length;
2885             if (len === 0) {
2886                 this.destination.complete();
2887             }
2888             else {
2889                 this.active = len;
2890                 this.toRespond = len;
2891                 for (var i = 0; i < len; i++) {
2892                     var observable = observables[i];
2893                     this.add(subscribeToResult(this, observable, undefined, i));
2894                 }
2895             }
2896         };
2897         CombineLatestSubscriber.prototype.notifyComplete = function (unused) {
2898             if ((this.active -= 1) === 0) {
2899                 this.destination.complete();
2900             }
2901         };
2902         CombineLatestSubscriber.prototype.notifyNext = function (_outerValue, innerValue, outerIndex) {
2903             var values = this.values;
2904             var oldVal = values[outerIndex];
2905             var toRespond = !this.toRespond
2906                 ? 0
2907                 : oldVal === NONE ? --this.toRespond : this.toRespond;
2908             values[outerIndex] = innerValue;
2909             if (toRespond === 0) {
2910                 if (this.resultSelector) {
2911                     this._tryResultSelector(values);
2912                 }
2913                 else {
2914                     this.destination.next(values.slice());
2915                 }
2916             }
2917         };
2918         CombineLatestSubscriber.prototype._tryResultSelector = function (values) {
2919             var result;
2920             try {
2921                 result = this.resultSelector.apply(this, values);
2922             }
2923             catch (err) {
2924                 this.destination.error(err);
2925                 return;
2926             }
2927             this.destination.next(result);
2928         };
2929         return CombineLatestSubscriber;
2930     }(OuterSubscriber));
2931
2932     function scheduleObservable(input, scheduler) {
2933         return new Observable(function (subscriber) {
2934             var sub = new Subscription();
2935             sub.add(scheduler.schedule(function () {
2936                 var observable$$1 = input[observable]();
2937                 sub.add(observable$$1.subscribe({
2938                     next: function (value) { sub.add(scheduler.schedule(function () { return subscriber.next(value); })); },
2939                     error: function (err) { sub.add(scheduler.schedule(function () { return subscriber.error(err); })); },
2940                     complete: function () { sub.add(scheduler.schedule(function () { return subscriber.complete(); })); },
2941                 }));
2942             }));
2943             return sub;
2944         });
2945     }
2946
2947     function schedulePromise(input, scheduler) {
2948         return new Observable(function (subscriber) {
2949             var sub = new Subscription();
2950             sub.add(scheduler.schedule(function () { return input.then(function (value) {
2951                 sub.add(scheduler.schedule(function () {
2952                     subscriber.next(value);
2953                     sub.add(scheduler.schedule(function () { return subscriber.complete(); }));
2954                 }));
2955             }, function (err) {
2956                 sub.add(scheduler.schedule(function () { return subscriber.error(err); }));
2957             }); }));
2958             return sub;
2959         });
2960     }
2961
2962     function scheduleIterable(input, scheduler) {
2963         if (!input) {
2964             throw new Error('Iterable cannot be null');
2965         }
2966         return new Observable(function (subscriber) {
2967             var sub = new Subscription();
2968             var iterator$$1;
2969             sub.add(function () {
2970                 if (iterator$$1 && typeof iterator$$1.return === 'function') {
2971                     iterator$$1.return();
2972                 }
2973             });
2974             sub.add(scheduler.schedule(function () {
2975                 iterator$$1 = input[iterator]();
2976                 sub.add(scheduler.schedule(function () {
2977                     if (subscriber.closed) {
2978                         return;
2979                     }
2980                     var value;
2981                     var done;
2982                     try {
2983                         var result = iterator$$1.next();
2984                         value = result.value;
2985                         done = result.done;
2986                     }
2987                     catch (err) {
2988                         subscriber.error(err);
2989                         return;
2990                     }
2991                     if (done) {
2992                         subscriber.complete();
2993                     }
2994                     else {
2995                         subscriber.next(value);
2996                         this.schedule();
2997                     }
2998                 }));
2999             }));
3000             return sub;
3001         });
3002     }
3003
3004     function isInteropObservable(input) {
3005         return input && typeof input[observable] === 'function';
3006     }
3007
3008     function isIterable(input) {
3009         return input && typeof input[iterator] === 'function';
3010     }
3011
3012     function scheduled(input, scheduler) {
3013         if (input != null) {
3014             if (isInteropObservable(input)) {
3015                 return scheduleObservable(input, scheduler);
3016             }
3017             else if (isPromise(input)) {
3018                 return schedulePromise(input, scheduler);
3019             }
3020             else if (isArrayLike(input)) {
3021                 return scheduleArray(input, scheduler);
3022             }
3023             else if (isIterable(input) || typeof input === 'string') {
3024                 return scheduleIterable(input, scheduler);
3025             }
3026         }
3027         throw new TypeError((input !== null && typeof input || input) + ' is not observable');
3028     }
3029
3030     function from(input, scheduler) {
3031         if (!scheduler) {
3032             if (input instanceof Observable) {
3033                 return input;
3034             }
3035             return new Observable(subscribeTo(input));
3036         }
3037         else {
3038             return scheduled(input, scheduler);
3039         }
3040     }
3041
3042     var SimpleInnerSubscriber = (function (_super) {
3043         __extends(SimpleInnerSubscriber, _super);
3044         function SimpleInnerSubscriber(parent) {
3045             var _this = _super.call(this) || this;
3046             _this.parent = parent;
3047             return _this;
3048         }
3049         SimpleInnerSubscriber.prototype._next = function (value) {
3050             this.parent.notifyNext(value);
3051         };
3052         SimpleInnerSubscriber.prototype._error = function (error) {
3053             this.parent.notifyError(error);
3054             this.unsubscribe();
3055         };
3056         SimpleInnerSubscriber.prototype._complete = function () {
3057             this.parent.notifyComplete();
3058             this.unsubscribe();
3059         };
3060         return SimpleInnerSubscriber;
3061     }(Subscriber));
3062     var ComplexInnerSubscriber = (function (_super) {
3063         __extends(ComplexInnerSubscriber, _super);
3064         function ComplexInnerSubscriber(parent, outerValue, outerIndex) {
3065             var _this = _super.call(this) || this;
3066             _this.parent = parent;
3067             _this.outerValue = outerValue;
3068             _this.outerIndex = outerIndex;
3069             return _this;
3070         }
3071         ComplexInnerSubscriber.prototype._next = function (value) {
3072             this.parent.notifyNext(this.outerValue, value, this.outerIndex, this);
3073         };
3074         ComplexInnerSubscriber.prototype._error = function (error) {
3075             this.parent.notifyError(error);
3076             this.unsubscribe();
3077         };
3078         ComplexInnerSubscriber.prototype._complete = function () {
3079             this.parent.notifyComplete(this);
3080             this.unsubscribe();
3081         };
3082         return ComplexInnerSubscriber;
3083     }(Subscriber));
3084     var SimpleOuterSubscriber = (function (_super) {
3085         __extends(SimpleOuterSubscriber, _super);
3086         function SimpleOuterSubscriber() {
3087             return _super !== null && _super.apply(this, arguments) || this;
3088         }
3089         SimpleOuterSubscriber.prototype.notifyNext = function (innerValue) {
3090             this.destination.next(innerValue);
3091         };
3092         SimpleOuterSubscriber.prototype.notifyError = function (err) {
3093             this.destination.error(err);
3094         };
3095         SimpleOuterSubscriber.prototype.notifyComplete = function () {
3096             this.destination.complete();
3097         };
3098         return SimpleOuterSubscriber;
3099     }(Subscriber));
3100     var ComplexOuterSubscriber = (function (_super) {
3101         __extends(ComplexOuterSubscriber, _super);
3102         function ComplexOuterSubscriber() {
3103             return _super !== null && _super.apply(this, arguments) || this;
3104         }
3105         ComplexOuterSubscriber.prototype.notifyNext = function (_outerValue, innerValue, _outerIndex, _innerSub) {
3106             this.destination.next(innerValue);
3107         };
3108         ComplexOuterSubscriber.prototype.notifyError = function (error) {
3109             this.destination.error(error);
3110         };
3111         ComplexOuterSubscriber.prototype.notifyComplete = function (_innerSub) {
3112             this.destination.complete();
3113         };
3114         return ComplexOuterSubscriber;
3115     }(Subscriber));
3116     function innerSubscribe(result, innerSubscriber) {
3117         if (innerSubscriber.closed) {
3118             return undefined;
3119         }
3120         if (result instanceof Observable) {
3121             return result.subscribe(innerSubscriber);
3122         }
3123         return subscribeTo(result)(innerSubscriber);
3124     }
3125
3126     function mergeMap(project, resultSelector, concurrent) {
3127         if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3128         if (typeof resultSelector === 'function') {
3129             return function (source) { return source.pipe(mergeMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); }, concurrent)); };
3130         }
3131         else if (typeof resultSelector === 'number') {
3132             concurrent = resultSelector;
3133         }
3134         return function (source) { return source.lift(new MergeMapOperator(project, concurrent)); };
3135     }
3136     var MergeMapOperator = (function () {
3137         function MergeMapOperator(project, concurrent) {
3138             if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3139             this.project = project;
3140             this.concurrent = concurrent;
3141         }
3142         MergeMapOperator.prototype.call = function (observer, source) {
3143             return source.subscribe(new MergeMapSubscriber(observer, this.project, this.concurrent));
3144         };
3145         return MergeMapOperator;
3146     }());
3147     var MergeMapSubscriber = (function (_super) {
3148         __extends(MergeMapSubscriber, _super);
3149         function MergeMapSubscriber(destination, project, concurrent) {
3150             if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3151             var _this = _super.call(this, destination) || this;
3152             _this.project = project;
3153             _this.concurrent = concurrent;
3154             _this.hasCompleted = false;
3155             _this.buffer = [];
3156             _this.active = 0;
3157             _this.index = 0;
3158             return _this;
3159         }
3160         MergeMapSubscriber.prototype._next = function (value) {
3161             if (this.active < this.concurrent) {
3162                 this._tryNext(value);
3163             }
3164             else {
3165                 this.buffer.push(value);
3166             }
3167         };
3168         MergeMapSubscriber.prototype._tryNext = function (value) {
3169             var result;
3170             var index = this.index++;
3171             try {
3172                 result = this.project(value, index);
3173             }
3174             catch (err) {
3175                 this.destination.error(err);
3176                 return;
3177             }
3178             this.active++;
3179             this._innerSub(result);
3180         };
3181         MergeMapSubscriber.prototype._innerSub = function (ish) {
3182             var innerSubscriber = new SimpleInnerSubscriber(this);
3183             var destination = this.destination;
3184             destination.add(innerSubscriber);
3185             var innerSubscription = innerSubscribe(ish, innerSubscriber);
3186             if (innerSubscription !== innerSubscriber) {
3187                 destination.add(innerSubscription);
3188             }
3189         };
3190         MergeMapSubscriber.prototype._complete = function () {
3191             this.hasCompleted = true;
3192             if (this.active === 0 && this.buffer.length === 0) {
3193                 this.destination.complete();
3194             }
3195             this.unsubscribe();
3196         };
3197         MergeMapSubscriber.prototype.notifyNext = function (innerValue) {
3198             this.destination.next(innerValue);
3199         };
3200         MergeMapSubscriber.prototype.notifyComplete = function () {
3201             var buffer = this.buffer;
3202             this.active--;
3203             if (buffer.length > 0) {
3204                 this._next(buffer.shift());
3205             }
3206             else if (this.active === 0 && this.hasCompleted) {
3207                 this.destination.complete();
3208             }
3209         };
3210         return MergeMapSubscriber;
3211     }(SimpleOuterSubscriber));
3212     var flatMap = mergeMap;
3213
3214     function mergeAll(concurrent) {
3215         if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
3216         return mergeMap(identity, concurrent);
3217     }
3218
3219     function concatAll() {
3220         return mergeAll(1);
3221     }
3222
3223     function concat() {
3224         var observables = [];
3225         for (var _i = 0; _i < arguments.length; _i++) {
3226             observables[_i] = arguments[_i];
3227         }
3228         return concatAll()(of.apply(void 0, observables));
3229     }
3230
3231     function defer(observableFactory) {
3232         return new Observable(function (subscriber) {
3233             var input;
3234             try {
3235                 input = observableFactory();
3236             }
3237             catch (err) {
3238                 subscriber.error(err);
3239                 return undefined;
3240             }
3241             var source = input ? from(input) : empty$1();
3242             return source.subscribe(subscriber);
3243         });
3244     }
3245
3246     function forkJoin() {
3247         var sources = [];
3248         for (var _i = 0; _i < arguments.length; _i++) {
3249             sources[_i] = arguments[_i];
3250         }
3251         if (sources.length === 1) {
3252             var first_1 = sources[0];
3253             if (isArray(first_1)) {
3254                 return forkJoinInternal(first_1, null);
3255             }
3256             if (isObject(first_1) && Object.getPrototypeOf(first_1) === Object.prototype) {
3257                 var keys = Object.keys(first_1);
3258                 return forkJoinInternal(keys.map(function (key) { return first_1[key]; }), keys);
3259             }
3260         }
3261         if (typeof sources[sources.length - 1] === 'function') {
3262             var resultSelector_1 = sources.pop();
3263             sources = (sources.length === 1 && isArray(sources[0])) ? sources[0] : sources;
3264             return forkJoinInternal(sources, null).pipe(map(function (args) { return resultSelector_1.apply(void 0, args); }));
3265         }
3266         return forkJoinInternal(sources, null);
3267     }
3268     function forkJoinInternal(sources, keys) {
3269         return new Observable(function (subscriber) {
3270             var len = sources.length;
3271             if (len === 0) {
3272                 subscriber.complete();
3273                 return;
3274             }
3275             var values = new Array(len);
3276             var completed = 0;
3277             var emitted = 0;
3278             var _loop_1 = function (i) {
3279                 var source = from(sources[i]);
3280                 var hasValue = false;
3281                 subscriber.add(source.subscribe({
3282                     next: function (value) {
3283                         if (!hasValue) {
3284                             hasValue = true;
3285                             emitted++;
3286                         }
3287                         values[i] = value;
3288                     },
3289                     error: function (err) { return subscriber.error(err); },
3290                     complete: function () {
3291                         completed++;
3292                         if (completed === len || !hasValue) {
3293                             if (emitted === len) {
3294                                 subscriber.next(keys ?
3295                                     keys.reduce(function (result, key, i) { return (result[key] = values[i], result); }, {}) :
3296                                     values);
3297                             }
3298                             subscriber.complete();
3299                         }
3300                     }
3301                 }));
3302             };
3303             for (var i = 0; i < len; i++) {
3304                 _loop_1(i);
3305             }
3306         });
3307     }
3308
3309     function fromEvent(target, eventName, options, resultSelector) {
3310         if (isFunction(options)) {
3311             resultSelector = options;
3312             options = undefined;
3313         }
3314         if (resultSelector) {
3315             return fromEvent(target, eventName, options).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
3316         }
3317         return new Observable(function (subscriber) {
3318             function handler(e) {
3319                 if (arguments.length > 1) {
3320                     subscriber.next(Array.prototype.slice.call(arguments));
3321                 }
3322                 else {
3323                     subscriber.next(e);
3324                 }
3325             }
3326             setupSubscription(target, eventName, handler, subscriber, options);
3327         });
3328     }
3329     function setupSubscription(sourceObj, eventName, handler, subscriber, options) {
3330         var unsubscribe;
3331         if (isEventTarget(sourceObj)) {
3332             var source_1 = sourceObj;
3333             sourceObj.addEventListener(eventName, handler, options);
3334             unsubscribe = function () { return source_1.removeEventListener(eventName, handler, options); };
3335         }
3336         else if (isJQueryStyleEventEmitter(sourceObj)) {
3337             var source_2 = sourceObj;
3338             sourceObj.on(eventName, handler);
3339             unsubscribe = function () { return source_2.off(eventName, handler); };
3340         }
3341         else if (isNodeStyleEventEmitter(sourceObj)) {
3342             var source_3 = sourceObj;
3343             sourceObj.addListener(eventName, handler);
3344             unsubscribe = function () { return source_3.removeListener(eventName, handler); };
3345         }
3346         else if (sourceObj && sourceObj.length) {
3347             for (var i = 0, len = sourceObj.length; i < len; i++) {
3348                 setupSubscription(sourceObj[i], eventName, handler, subscriber, options);
3349             }
3350         }
3351         else {
3352             throw new TypeError('Invalid event target');
3353         }
3354         subscriber.add(unsubscribe);
3355     }
3356     function isNodeStyleEventEmitter(sourceObj) {
3357         return sourceObj && typeof sourceObj.addListener === 'function' && typeof sourceObj.removeListener === 'function';
3358     }
3359     function isJQueryStyleEventEmitter(sourceObj) {
3360         return sourceObj && typeof sourceObj.on === 'function' && typeof sourceObj.off === 'function';
3361     }
3362     function isEventTarget(sourceObj) {
3363         return sourceObj && typeof sourceObj.addEventListener === 'function' && typeof sourceObj.removeEventListener === 'function';
3364     }
3365
3366     function fromEventPattern(addHandler, removeHandler, resultSelector) {
3367         if (resultSelector) {
3368             return fromEventPattern(addHandler, removeHandler).pipe(map(function (args) { return isArray(args) ? resultSelector.apply(void 0, args) : resultSelector(args); }));
3369         }
3370         return new Observable(function (subscriber) {
3371             var handler = function () {
3372                 var e = [];
3373                 for (var _i = 0; _i < arguments.length; _i++) {
3374                     e[_i] = arguments[_i];
3375                 }
3376                 return subscriber.next(e.length === 1 ? e[0] : e);
3377             };
3378             var retValue;
3379             try {
3380                 retValue = addHandler(handler);
3381             }
3382             catch (err) {
3383                 subscriber.error(err);
3384                 return undefined;
3385             }
3386             if (!isFunction(removeHandler)) {
3387                 return undefined;
3388             }
3389             return function () { return removeHandler(handler, retValue); };
3390         });
3391     }
3392
3393     function generate(initialStateOrOptions, condition, iterate, resultSelectorOrObservable, scheduler) {
3394         var resultSelector;
3395         var initialState;
3396         if (arguments.length == 1) {
3397             var options = initialStateOrOptions;
3398             initialState = options.initialState;
3399             condition = options.condition;
3400             iterate = options.iterate;
3401             resultSelector = options.resultSelector || identity;
3402             scheduler = options.scheduler;
3403         }
3404         else if (resultSelectorOrObservable === undefined || isScheduler(resultSelectorOrObservable)) {
3405             initialState = initialStateOrOptions;
3406             resultSelector = identity;
3407             scheduler = resultSelectorOrObservable;
3408         }
3409         else {
3410             initialState = initialStateOrOptions;
3411             resultSelector = resultSelectorOrObservable;
3412         }
3413         return new Observable(function (subscriber) {
3414             var state = initialState;
3415             if (scheduler) {
3416                 return scheduler.schedule(dispatch$3, 0, {
3417                     subscriber: subscriber,
3418                     iterate: iterate,
3419                     condition: condition,
3420                     resultSelector: resultSelector,
3421                     state: state
3422                 });
3423             }
3424             do {
3425                 if (condition) {
3426                     var conditionResult = void 0;
3427                     try {
3428                         conditionResult = condition(state);
3429                     }
3430                     catch (err) {
3431                         subscriber.error(err);
3432                         return undefined;
3433                     }
3434                     if (!conditionResult) {
3435                         subscriber.complete();
3436                         break;
3437                     }
3438                 }
3439                 var value = void 0;
3440                 try {
3441                     value = resultSelector(state);
3442                 }
3443                 catch (err) {
3444                     subscriber.error(err);
3445                     return undefined;
3446                 }
3447                 subscriber.next(value);
3448                 if (subscriber.closed) {
3449                     break;
3450                 }
3451                 try {
3452                     state = iterate(state);
3453                 }
3454                 catch (err) {
3455                     subscriber.error(err);
3456                     return undefined;
3457                 }
3458             } while (true);
3459             return undefined;
3460         });
3461     }
3462     function dispatch$3(state) {
3463         var subscriber = state.subscriber, condition = state.condition;
3464         if (subscriber.closed) {
3465             return undefined;
3466         }
3467         if (state.needIterate) {
3468             try {
3469                 state.state = state.iterate(state.state);
3470             }
3471             catch (err) {
3472                 subscriber.error(err);
3473                 return undefined;
3474             }
3475         }
3476         else {
3477             state.needIterate = true;
3478         }
3479         if (condition) {
3480             var conditionResult = void 0;
3481             try {
3482                 conditionResult = condition(state.state);
3483             }
3484             catch (err) {
3485                 subscriber.error(err);
3486                 return undefined;
3487             }
3488             if (!conditionResult) {
3489                 subscriber.complete();
3490                 return undefined;
3491             }
3492             if (subscriber.closed) {
3493                 return undefined;
3494             }
3495         }
3496         var value;
3497         try {
3498             value = state.resultSelector(state.state);
3499         }
3500         catch (err) {
3501             subscriber.error(err);
3502             return undefined;
3503         }
3504         if (subscriber.closed) {
3505             return undefined;
3506         }
3507         subscriber.next(value);
3508         if (subscriber.closed) {
3509             return undefined;
3510         }
3511         return this.schedule(state);
3512     }
3513
3514     function iif(condition, trueResult, falseResult) {
3515         if (trueResult === void 0) { trueResult = EMPTY; }
3516         if (falseResult === void 0) { falseResult = EMPTY; }
3517         return defer(function () { return condition() ? trueResult : falseResult; });
3518     }
3519
3520     function isNumeric(val) {
3521         return !isArray(val) && (val - parseFloat(val) + 1) >= 0;
3522     }
3523
3524     function interval(period, scheduler) {
3525         if (period === void 0) { period = 0; }
3526         if (scheduler === void 0) { scheduler = async; }
3527         if (!isNumeric(period) || period < 0) {
3528             period = 0;
3529         }
3530         if (!scheduler || typeof scheduler.schedule !== 'function') {
3531             scheduler = async;
3532         }
3533         return new Observable(function (subscriber) {
3534             subscriber.add(scheduler.schedule(dispatch$4, period, { subscriber: subscriber, counter: 0, period: period }));
3535             return subscriber;
3536         });
3537     }
3538     function dispatch$4(state) {
3539         var subscriber = state.subscriber, counter = state.counter, period = state.period;
3540         subscriber.next(counter);
3541         this.schedule({ subscriber: subscriber, counter: counter + 1, period: period }, period);
3542     }
3543
3544     function merge() {
3545         var observables = [];
3546         for (var _i = 0; _i < arguments.length; _i++) {
3547             observables[_i] = arguments[_i];
3548         }
3549         var concurrent = Number.POSITIVE_INFINITY;
3550         var scheduler = null;
3551         var last = observables[observables.length - 1];
3552         if (isScheduler(last)) {
3553             scheduler = observables.pop();
3554             if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
3555                 concurrent = observables.pop();
3556             }
3557         }
3558         else if (typeof last === 'number') {
3559             concurrent = observables.pop();
3560         }
3561         if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable) {
3562             return observables[0];
3563         }
3564         return mergeAll(concurrent)(fromArray(observables, scheduler));
3565     }
3566
3567     var NEVER = new Observable(noop);
3568     function never() {
3569         return NEVER;
3570     }
3571
3572     function onErrorResumeNext() {
3573         var sources = [];
3574         for (var _i = 0; _i < arguments.length; _i++) {
3575             sources[_i] = arguments[_i];
3576         }
3577         if (sources.length === 0) {
3578             return EMPTY;
3579         }
3580         var first = sources[0], remainder = sources.slice(1);
3581         if (sources.length === 1 && isArray(first)) {
3582             return onErrorResumeNext.apply(void 0, first);
3583         }
3584         return new Observable(function (subscriber) {
3585             var subNext = function () { return subscriber.add(onErrorResumeNext.apply(void 0, remainder).subscribe(subscriber)); };
3586             return from(first).subscribe({
3587                 next: function (value) { subscriber.next(value); },
3588                 error: subNext,
3589                 complete: subNext,
3590             });
3591         });
3592     }
3593
3594     function pairs(obj, scheduler) {
3595         if (!scheduler) {
3596             return new Observable(function (subscriber) {
3597                 var keys = Object.keys(obj);
3598                 for (var i = 0; i < keys.length && !subscriber.closed; i++) {
3599                     var key = keys[i];
3600                     if (obj.hasOwnProperty(key)) {
3601                         subscriber.next([key, obj[key]]);
3602                     }
3603                 }
3604                 subscriber.complete();
3605             });
3606         }
3607         else {
3608             return new Observable(function (subscriber) {
3609                 var keys = Object.keys(obj);
3610                 var subscription = new Subscription();
3611                 subscription.add(scheduler.schedule(dispatch$5, 0, { keys: keys, index: 0, subscriber: subscriber, subscription: subscription, obj: obj }));
3612                 return subscription;
3613             });
3614         }
3615     }
3616     function dispatch$5(state) {
3617         var keys = state.keys, index = state.index, subscriber = state.subscriber, subscription = state.subscription, obj = state.obj;
3618         if (!subscriber.closed) {
3619             if (index < keys.length) {
3620                 var key = keys[index];
3621                 subscriber.next([key, obj[key]]);
3622                 subscription.add(this.schedule({ keys: keys, index: index + 1, subscriber: subscriber, subscription: subscription, obj: obj }));
3623             }
3624             else {
3625                 subscriber.complete();
3626             }
3627         }
3628     }
3629
3630     function not(pred, thisArg) {
3631         function notPred() {
3632             return !(notPred.pred.apply(notPred.thisArg, arguments));
3633         }
3634         notPred.pred = pred;
3635         notPred.thisArg = thisArg;
3636         return notPred;
3637     }
3638
3639     function filter(predicate, thisArg) {
3640         return function filterOperatorFunction(source) {
3641             return source.lift(new FilterOperator(predicate, thisArg));
3642         };
3643     }
3644     var FilterOperator = (function () {
3645         function FilterOperator(predicate, thisArg) {
3646             this.predicate = predicate;
3647             this.thisArg = thisArg;
3648         }
3649         FilterOperator.prototype.call = function (subscriber, source) {
3650             return source.subscribe(new FilterSubscriber(subscriber, this.predicate, this.thisArg));
3651         };
3652         return FilterOperator;
3653     }());
3654     var FilterSubscriber = (function (_super) {
3655         __extends(FilterSubscriber, _super);
3656         function FilterSubscriber(destination, predicate, thisArg) {
3657             var _this = _super.call(this, destination) || this;
3658             _this.predicate = predicate;
3659             _this.thisArg = thisArg;
3660             _this.count = 0;
3661             return _this;
3662         }
3663         FilterSubscriber.prototype._next = function (value) {
3664             var result;
3665             try {
3666                 result = this.predicate.call(this.thisArg, value, this.count++);
3667             }
3668             catch (err) {
3669                 this.destination.error(err);
3670                 return;
3671             }
3672             if (result) {
3673                 this.destination.next(value);
3674             }
3675         };
3676         return FilterSubscriber;
3677     }(Subscriber));
3678
3679     function partition(source, predicate, thisArg) {
3680         return [
3681             filter(predicate, thisArg)(new Observable(subscribeTo(source))),
3682             filter(not(predicate, thisArg))(new Observable(subscribeTo(source)))
3683         ];
3684     }
3685
3686     function race() {
3687         var observables = [];
3688         for (var _i = 0; _i < arguments.length; _i++) {
3689             observables[_i] = arguments[_i];
3690         }
3691         if (observables.length === 1) {
3692             if (isArray(observables[0])) {
3693                 observables = observables[0];
3694             }
3695             else {
3696                 return observables[0];
3697             }
3698         }
3699         return fromArray(observables, undefined).lift(new RaceOperator());
3700     }
3701     var RaceOperator = (function () {
3702         function RaceOperator() {
3703         }
3704         RaceOperator.prototype.call = function (subscriber, source) {
3705             return source.subscribe(new RaceSubscriber(subscriber));
3706         };
3707         return RaceOperator;
3708     }());
3709     var RaceSubscriber = (function (_super) {
3710         __extends(RaceSubscriber, _super);
3711         function RaceSubscriber(destination) {
3712             var _this = _super.call(this, destination) || this;
3713             _this.hasFirst = false;
3714             _this.observables = [];
3715             _this.subscriptions = [];
3716             return _this;
3717         }
3718         RaceSubscriber.prototype._next = function (observable) {
3719             this.observables.push(observable);
3720         };
3721         RaceSubscriber.prototype._complete = function () {
3722             var observables = this.observables;
3723             var len = observables.length;
3724             if (len === 0) {
3725                 this.destination.complete();
3726             }
3727             else {
3728                 for (var i = 0; i < len && !this.hasFirst; i++) {
3729                     var observable = observables[i];
3730                     var subscription = subscribeToResult(this, observable, undefined, i);
3731                     if (this.subscriptions) {
3732                         this.subscriptions.push(subscription);
3733                     }
3734                     this.add(subscription);
3735                 }
3736                 this.observables = null;
3737             }
3738         };
3739         RaceSubscriber.prototype.notifyNext = function (_outerValue, innerValue, outerIndex) {
3740             if (!this.hasFirst) {
3741                 this.hasFirst = true;
3742                 for (var i = 0; i < this.subscriptions.length; i++) {
3743                     if (i !== outerIndex) {
3744                         var subscription = this.subscriptions[i];
3745                         subscription.unsubscribe();
3746                         this.remove(subscription);
3747                     }
3748                 }
3749                 this.subscriptions = null;
3750             }
3751             this.destination.next(innerValue);
3752         };
3753         return RaceSubscriber;
3754     }(OuterSubscriber));
3755
3756     function range(start, count, scheduler) {
3757         if (start === void 0) { start = 0; }
3758         return new Observable(function (subscriber) {
3759             if (count === undefined) {
3760                 count = start;
3761                 start = 0;
3762             }
3763             var index = 0;
3764             var current = start;
3765             if (scheduler) {
3766                 return scheduler.schedule(dispatch$6, 0, {
3767                     index: index, count: count, start: start, subscriber: subscriber
3768                 });
3769             }
3770             else {
3771                 do {
3772                     if (index++ >= count) {
3773                         subscriber.complete();
3774                         break;
3775                     }
3776                     subscriber.next(current++);
3777                     if (subscriber.closed) {
3778                         break;
3779                     }
3780                 } while (true);
3781             }
3782             return undefined;
3783         });
3784     }
3785     function dispatch$6(state) {
3786         var start = state.start, index = state.index, count = state.count, subscriber = state.subscriber;
3787         if (index >= count) {
3788             subscriber.complete();
3789             return;
3790         }
3791         subscriber.next(start);
3792         if (subscriber.closed) {
3793             return;
3794         }
3795         state.index = index + 1;
3796         state.start = start + 1;
3797         this.schedule(state);
3798     }
3799
3800     function timer(dueTime, periodOrScheduler, scheduler) {
3801         if (dueTime === void 0) { dueTime = 0; }
3802         var period = -1;
3803         if (isNumeric(periodOrScheduler)) {
3804             period = Number(periodOrScheduler) < 1 && 1 || Number(periodOrScheduler);
3805         }
3806         else if (isScheduler(periodOrScheduler)) {
3807             scheduler = periodOrScheduler;
3808         }
3809         if (!isScheduler(scheduler)) {
3810             scheduler = async;
3811         }
3812         return new Observable(function (subscriber) {
3813             var due = isNumeric(dueTime)
3814                 ? dueTime
3815                 : (+dueTime - scheduler.now());
3816             return scheduler.schedule(dispatch$7, due, {
3817                 index: 0, period: period, subscriber: subscriber
3818             });
3819         });
3820     }
3821     function dispatch$7(state) {
3822         var index = state.index, period = state.period, subscriber = state.subscriber;
3823         subscriber.next(index);
3824         if (subscriber.closed) {
3825             return;
3826         }
3827         else if (period === -1) {
3828             return subscriber.complete();
3829         }
3830         state.index = index + 1;
3831         this.schedule(state, period);
3832     }
3833
3834     function using(resourceFactory, observableFactory) {
3835         return new Observable(function (subscriber) {
3836             var resource;
3837             try {
3838                 resource = resourceFactory();
3839             }
3840             catch (err) {
3841                 subscriber.error(err);
3842                 return undefined;
3843             }
3844             var result;
3845             try {
3846                 result = observableFactory(resource);
3847             }
3848             catch (err) {
3849                 subscriber.error(err);
3850                 return undefined;
3851             }
3852             var source = result ? from(result) : EMPTY;
3853             var subscription = source.subscribe(subscriber);
3854             return function () {
3855                 subscription.unsubscribe();
3856                 if (resource) {
3857                     resource.unsubscribe();
3858                 }
3859             };
3860         });
3861     }
3862
3863     function zip() {
3864         var observables = [];
3865         for (var _i = 0; _i < arguments.length; _i++) {
3866             observables[_i] = arguments[_i];
3867         }
3868         var resultSelector = observables[observables.length - 1];
3869         if (typeof resultSelector === 'function') {
3870             observables.pop();
3871         }
3872         return fromArray(observables, undefined).lift(new ZipOperator(resultSelector));
3873     }
3874     var ZipOperator = (function () {
3875         function ZipOperator(resultSelector) {
3876             this.resultSelector = resultSelector;
3877         }
3878         ZipOperator.prototype.call = function (subscriber, source) {
3879             return source.subscribe(new ZipSubscriber(subscriber, this.resultSelector));
3880         };
3881         return ZipOperator;
3882     }());
3883     var ZipSubscriber = (function (_super) {
3884         __extends(ZipSubscriber, _super);
3885         function ZipSubscriber(destination, resultSelector, values) {
3886             if (values === void 0) { values = Object.create(null); }
3887             var _this = _super.call(this, destination) || this;
3888             _this.resultSelector = resultSelector;
3889             _this.iterators = [];
3890             _this.active = 0;
3891             _this.resultSelector = (typeof resultSelector === 'function') ? resultSelector : undefined;
3892             return _this;
3893         }
3894         ZipSubscriber.prototype._next = function (value) {
3895             var iterators = this.iterators;
3896             if (isArray(value)) {
3897                 iterators.push(new StaticArrayIterator(value));
3898             }
3899             else if (typeof value[iterator] === 'function') {
3900                 iterators.push(new StaticIterator(value[iterator]()));
3901             }
3902             else {
3903                 iterators.push(new ZipBufferIterator(this.destination, this, value));
3904             }
3905         };
3906         ZipSubscriber.prototype._complete = function () {
3907             var iterators = this.iterators;
3908             var len = iterators.length;
3909             this.unsubscribe();
3910             if (len === 0) {
3911                 this.destination.complete();
3912                 return;
3913             }
3914             this.active = len;
3915             for (var i = 0; i < len; i++) {
3916                 var iterator$$1 = iterators[i];
3917                 if (iterator$$1.stillUnsubscribed) {
3918                     var destination = this.destination;
3919                     destination.add(iterator$$1.subscribe());
3920                 }
3921                 else {
3922                     this.active--;
3923                 }
3924             }
3925         };
3926         ZipSubscriber.prototype.notifyInactive = function () {
3927             this.active--;
3928             if (this.active === 0) {
3929                 this.destination.complete();
3930             }
3931         };
3932         ZipSubscriber.prototype.checkIterators = function () {
3933             var iterators = this.iterators;
3934             var len = iterators.length;
3935             var destination = this.destination;
3936             for (var i = 0; i < len; i++) {
3937                 var iterator$$1 = iterators[i];
3938                 if (typeof iterator$$1.hasValue === 'function' && !iterator$$1.hasValue()) {
3939                     return;
3940                 }
3941             }
3942             var shouldComplete = false;
3943             var args = [];
3944             for (var i = 0; i < len; i++) {
3945                 var iterator$$1 = iterators[i];
3946                 var result = iterator$$1.next();
3947                 if (iterator$$1.hasCompleted()) {
3948                     shouldComplete = true;
3949                 }
3950                 if (result.done) {
3951                     destination.complete();
3952                     return;
3953                 }
3954                 args.push(result.value);
3955             }
3956             if (this.resultSelector) {
3957                 this._tryresultSelector(args);
3958             }
3959             else {
3960                 destination.next(args);
3961             }
3962             if (shouldComplete) {
3963                 destination.complete();
3964             }
3965         };
3966         ZipSubscriber.prototype._tryresultSelector = function (args) {
3967             var result;
3968             try {
3969                 result = this.resultSelector.apply(this, args);
3970             }
3971             catch (err) {
3972                 this.destination.error(err);
3973                 return;
3974             }
3975             this.destination.next(result);
3976         };
3977         return ZipSubscriber;
3978     }(Subscriber));
3979     var StaticIterator = (function () {
3980         function StaticIterator(iterator$$1) {
3981             this.iterator = iterator$$1;
3982             this.nextResult = iterator$$1.next();
3983         }
3984         StaticIterator.prototype.hasValue = function () {
3985             return true;
3986         };
3987         StaticIterator.prototype.next = function () {
3988             var result = this.nextResult;
3989             this.nextResult = this.iterator.next();
3990             return result;
3991         };
3992         StaticIterator.prototype.hasCompleted = function () {
3993             var nextResult = this.nextResult;
3994             return Boolean(nextResult && nextResult.done);
3995         };
3996         return StaticIterator;
3997     }());
3998     var StaticArrayIterator = (function () {
3999         function StaticArrayIterator(array) {
4000             this.array = array;
4001             this.index = 0;
4002             this.length = 0;
4003             this.length = array.length;
4004         }
4005         StaticArrayIterator.prototype[iterator] = function () {
4006             return this;
4007         };
4008         StaticArrayIterator.prototype.next = function (value) {
4009             var i = this.index++;
4010             var array = this.array;
4011             return i < this.length ? { value: array[i], done: false } : { value: null, done: true };
4012         };
4013         StaticArrayIterator.prototype.hasValue = function () {
4014             return this.array.length > this.index;
4015         };
4016         StaticArrayIterator.prototype.hasCompleted = function () {
4017             return this.array.length === this.index;
4018         };
4019         return StaticArrayIterator;
4020     }());
4021     var ZipBufferIterator = (function (_super) {
4022         __extends(ZipBufferIterator, _super);
4023         function ZipBufferIterator(destination, parent, observable) {
4024             var _this = _super.call(this, destination) || this;
4025             _this.parent = parent;
4026             _this.observable = observable;
4027             _this.stillUnsubscribed = true;
4028             _this.buffer = [];
4029             _this.isComplete = false;
4030             return _this;
4031         }
4032         ZipBufferIterator.prototype[iterator] = function () {
4033             return this;
4034         };
4035         ZipBufferIterator.prototype.next = function () {
4036             var buffer = this.buffer;
4037             if (buffer.length === 0 && this.isComplete) {
4038                 return { value: null, done: true };
4039             }
4040             else {
4041                 return { value: buffer.shift(), done: false };
4042             }
4043         };
4044         ZipBufferIterator.prototype.hasValue = function () {
4045             return this.buffer.length > 0;
4046         };
4047         ZipBufferIterator.prototype.hasCompleted = function () {
4048             return this.buffer.length === 0 && this.isComplete;
4049         };
4050         ZipBufferIterator.prototype.notifyComplete = function () {
4051             if (this.buffer.length > 0) {
4052                 this.isComplete = true;
4053                 this.parent.notifyInactive();
4054             }
4055             else {
4056                 this.destination.complete();
4057             }
4058         };
4059         ZipBufferIterator.prototype.notifyNext = function (innerValue) {
4060             this.buffer.push(innerValue);
4061             this.parent.checkIterators();
4062         };
4063         ZipBufferIterator.prototype.subscribe = function () {
4064             return innerSubscribe(this.observable, new SimpleInnerSubscriber(this));
4065         };
4066         return ZipBufferIterator;
4067     }(SimpleOuterSubscriber));
4068
4069     function audit(durationSelector) {
4070         return function auditOperatorFunction(source) {
4071             return source.lift(new AuditOperator(durationSelector));
4072         };
4073     }
4074     var AuditOperator = (function () {
4075         function AuditOperator(durationSelector) {
4076             this.durationSelector = durationSelector;
4077         }
4078         AuditOperator.prototype.call = function (subscriber, source) {
4079             return source.subscribe(new AuditSubscriber(subscriber, this.durationSelector));
4080         };
4081         return AuditOperator;
4082     }());
4083     var AuditSubscriber = (function (_super) {
4084         __extends(AuditSubscriber, _super);
4085         function AuditSubscriber(destination, durationSelector) {
4086             var _this = _super.call(this, destination) || this;
4087             _this.durationSelector = durationSelector;
4088             _this.hasValue = false;
4089             return _this;
4090         }
4091         AuditSubscriber.prototype._next = function (value) {
4092             this.value = value;
4093             this.hasValue = true;
4094             if (!this.throttled) {
4095                 var duration = void 0;
4096                 try {
4097                     var durationSelector = this.durationSelector;
4098                     duration = durationSelector(value);
4099                 }
4100                 catch (err) {
4101                     return this.destination.error(err);
4102                 }
4103                 var innerSubscription = innerSubscribe(duration, new SimpleInnerSubscriber(this));
4104                 if (!innerSubscription || innerSubscription.closed) {
4105                     this.clearThrottle();
4106                 }
4107                 else {
4108                     this.add(this.throttled = innerSubscription);
4109                 }
4110             }
4111         };
4112         AuditSubscriber.prototype.clearThrottle = function () {
4113             var _a = this, value = _a.value, hasValue = _a.hasValue, throttled = _a.throttled;
4114             if (throttled) {
4115                 this.remove(throttled);
4116                 this.throttled = undefined;
4117                 throttled.unsubscribe();
4118             }
4119             if (hasValue) {
4120                 this.value = undefined;
4121                 this.hasValue = false;
4122                 this.destination.next(value);
4123             }
4124         };
4125         AuditSubscriber.prototype.notifyNext = function () {
4126             this.clearThrottle();
4127         };
4128         AuditSubscriber.prototype.notifyComplete = function () {
4129             this.clearThrottle();
4130         };
4131         return AuditSubscriber;
4132     }(SimpleOuterSubscriber));
4133
4134     function auditTime(duration, scheduler) {
4135         if (scheduler === void 0) { scheduler = async; }
4136         return audit(function () { return timer(duration, scheduler); });
4137     }
4138
4139     function buffer(closingNotifier) {
4140         return function bufferOperatorFunction(source) {
4141             return source.lift(new BufferOperator(closingNotifier));
4142         };
4143     }
4144     var BufferOperator = (function () {
4145         function BufferOperator(closingNotifier) {
4146             this.closingNotifier = closingNotifier;
4147         }
4148         BufferOperator.prototype.call = function (subscriber, source) {
4149             return source.subscribe(new BufferSubscriber(subscriber, this.closingNotifier));
4150         };
4151         return BufferOperator;
4152     }());
4153     var BufferSubscriber = (function (_super) {
4154         __extends(BufferSubscriber, _super);
4155         function BufferSubscriber(destination, closingNotifier) {
4156             var _this = _super.call(this, destination) || this;
4157             _this.buffer = [];
4158             _this.add(innerSubscribe(closingNotifier, new SimpleInnerSubscriber(_this)));
4159             return _this;
4160         }
4161         BufferSubscriber.prototype._next = function (value) {
4162             this.buffer.push(value);
4163         };
4164         BufferSubscriber.prototype.notifyNext = function () {
4165             var buffer = this.buffer;
4166             this.buffer = [];
4167             this.destination.next(buffer);
4168         };
4169         return BufferSubscriber;
4170     }(SimpleOuterSubscriber));
4171
4172     function bufferCount(bufferSize, startBufferEvery) {
4173         if (startBufferEvery === void 0) { startBufferEvery = null; }
4174         return function bufferCountOperatorFunction(source) {
4175             return source.lift(new BufferCountOperator(bufferSize, startBufferEvery));
4176         };
4177     }
4178     var BufferCountOperator = (function () {
4179         function BufferCountOperator(bufferSize, startBufferEvery) {
4180             this.bufferSize = bufferSize;
4181             this.startBufferEvery = startBufferEvery;
4182             if (!startBufferEvery || bufferSize === startBufferEvery) {
4183                 this.subscriberClass = BufferCountSubscriber;
4184             }
4185             else {
4186                 this.subscriberClass = BufferSkipCountSubscriber;
4187             }
4188         }
4189         BufferCountOperator.prototype.call = function (subscriber, source) {
4190             return source.subscribe(new this.subscriberClass(subscriber, this.bufferSize, this.startBufferEvery));
4191         };
4192         return BufferCountOperator;
4193     }());
4194     var BufferCountSubscriber = (function (_super) {
4195         __extends(BufferCountSubscriber, _super);
4196         function BufferCountSubscriber(destination, bufferSize) {
4197             var _this = _super.call(this, destination) || this;
4198             _this.bufferSize = bufferSize;
4199             _this.buffer = [];
4200             return _this;
4201         }
4202         BufferCountSubscriber.prototype._next = function (value) {
4203             var buffer = this.buffer;
4204             buffer.push(value);
4205             if (buffer.length == this.bufferSize) {
4206                 this.destination.next(buffer);
4207                 this.buffer = [];
4208             }
4209         };
4210         BufferCountSubscriber.prototype._complete = function () {
4211             var buffer = this.buffer;
4212             if (buffer.length > 0) {
4213                 this.destination.next(buffer);
4214             }
4215             _super.prototype._complete.call(this);
4216         };
4217         return BufferCountSubscriber;
4218     }(Subscriber));
4219     var BufferSkipCountSubscriber = (function (_super) {
4220         __extends(BufferSkipCountSubscriber, _super);
4221         function BufferSkipCountSubscriber(destination, bufferSize, startBufferEvery) {
4222             var _this = _super.call(this, destination) || this;
4223             _this.bufferSize = bufferSize;
4224             _this.startBufferEvery = startBufferEvery;
4225             _this.buffers = [];
4226             _this.count = 0;
4227             return _this;
4228         }
4229         BufferSkipCountSubscriber.prototype._next = function (value) {
4230             var _a = this, bufferSize = _a.bufferSize, startBufferEvery = _a.startBufferEvery, buffers = _a.buffers, count = _a.count;
4231             this.count++;
4232             if (count % startBufferEvery === 0) {
4233                 buffers.push([]);
4234             }
4235             for (var i = buffers.length; i--;) {
4236                 var buffer = buffers[i];
4237                 buffer.push(value);
4238                 if (buffer.length === bufferSize) {
4239                     buffers.splice(i, 1);
4240                     this.destination.next(buffer);
4241                 }
4242             }
4243         };
4244         BufferSkipCountSubscriber.prototype._complete = function () {
4245             var _a = this, buffers = _a.buffers, destination = _a.destination;
4246             while (buffers.length > 0) {
4247                 var buffer = buffers.shift();
4248                 if (buffer.length > 0) {
4249                     destination.next(buffer);
4250                 }
4251             }
4252             _super.prototype._complete.call(this);
4253         };
4254         return BufferSkipCountSubscriber;
4255     }(Subscriber));
4256
4257     function bufferTime(bufferTimeSpan) {
4258         var length = arguments.length;
4259         var scheduler = async;
4260         if (isScheduler(arguments[arguments.length - 1])) {
4261             scheduler = arguments[arguments.length - 1];
4262             length--;
4263         }
4264         var bufferCreationInterval = null;
4265         if (length >= 2) {
4266             bufferCreationInterval = arguments[1];
4267         }
4268         var maxBufferSize = Number.POSITIVE_INFINITY;
4269         if (length >= 3) {
4270             maxBufferSize = arguments[2];
4271         }
4272         return function bufferTimeOperatorFunction(source) {
4273             return source.lift(new BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler));
4274         };
4275     }
4276     var BufferTimeOperator = (function () {
4277         function BufferTimeOperator(bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
4278             this.bufferTimeSpan = bufferTimeSpan;
4279             this.bufferCreationInterval = bufferCreationInterval;
4280             this.maxBufferSize = maxBufferSize;
4281             this.scheduler = scheduler;
4282         }
4283         BufferTimeOperator.prototype.call = function (subscriber, source) {
4284             return source.subscribe(new BufferTimeSubscriber(subscriber, this.bufferTimeSpan, this.bufferCreationInterval, this.maxBufferSize, this.scheduler));
4285         };
4286         return BufferTimeOperator;
4287     }());
4288     var Context = (function () {
4289         function Context() {
4290             this.buffer = [];
4291         }
4292         return Context;
4293     }());
4294     var BufferTimeSubscriber = (function (_super) {
4295         __extends(BufferTimeSubscriber, _super);
4296         function BufferTimeSubscriber(destination, bufferTimeSpan, bufferCreationInterval, maxBufferSize, scheduler) {
4297             var _this = _super.call(this, destination) || this;
4298             _this.bufferTimeSpan = bufferTimeSpan;
4299             _this.bufferCreationInterval = bufferCreationInterval;
4300             _this.maxBufferSize = maxBufferSize;
4301             _this.scheduler = scheduler;
4302             _this.contexts = [];
4303             var context = _this.openContext();
4304             _this.timespanOnly = bufferCreationInterval == null || bufferCreationInterval < 0;
4305             if (_this.timespanOnly) {
4306                 var timeSpanOnlyState = { subscriber: _this, context: context, bufferTimeSpan: bufferTimeSpan };
4307                 _this.add(context.closeAction = scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
4308             }
4309             else {
4310                 var closeState = { subscriber: _this, context: context };
4311                 var creationState = { bufferTimeSpan: bufferTimeSpan, bufferCreationInterval: bufferCreationInterval, subscriber: _this, scheduler: scheduler };
4312                 _this.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, closeState));
4313                 _this.add(scheduler.schedule(dispatchBufferCreation, bufferCreationInterval, creationState));
4314             }
4315             return _this;
4316         }
4317         BufferTimeSubscriber.prototype._next = function (value) {
4318             var contexts = this.contexts;
4319             var len = contexts.length;
4320             var filledBufferContext;
4321             for (var i = 0; i < len; i++) {
4322                 var context_1 = contexts[i];
4323                 var buffer = context_1.buffer;
4324                 buffer.push(value);
4325                 if (buffer.length == this.maxBufferSize) {
4326                     filledBufferContext = context_1;
4327                 }
4328             }
4329             if (filledBufferContext) {
4330                 this.onBufferFull(filledBufferContext);
4331             }
4332         };
4333         BufferTimeSubscriber.prototype._error = function (err) {
4334             this.contexts.length = 0;
4335             _super.prototype._error.call(this, err);
4336         };
4337         BufferTimeSubscriber.prototype._complete = function () {
4338             var _a = this, contexts = _a.contexts, destination = _a.destination;
4339             while (contexts.length > 0) {
4340                 var context_2 = contexts.shift();
4341                 destination.next(context_2.buffer);
4342             }
4343             _super.prototype._complete.call(this);
4344         };
4345         BufferTimeSubscriber.prototype._unsubscribe = function () {
4346             this.contexts = null;
4347         };
4348         BufferTimeSubscriber.prototype.onBufferFull = function (context) {
4349             this.closeContext(context);
4350             var closeAction = context.closeAction;
4351             closeAction.unsubscribe();
4352             this.remove(closeAction);
4353             if (!this.closed && this.timespanOnly) {
4354                 context = this.openContext();
4355                 var bufferTimeSpan = this.bufferTimeSpan;
4356                 var timeSpanOnlyState = { subscriber: this, context: context, bufferTimeSpan: bufferTimeSpan };
4357                 this.add(context.closeAction = this.scheduler.schedule(dispatchBufferTimeSpanOnly, bufferTimeSpan, timeSpanOnlyState));
4358             }
4359         };
4360         BufferTimeSubscriber.prototype.openContext = function () {
4361             var context = new Context();
4362             this.contexts.push(context);
4363             return context;
4364         };
4365         BufferTimeSubscriber.prototype.closeContext = function (context) {
4366             this.destination.next(context.buffer);
4367             var contexts = this.contexts;
4368             var spliceIndex = contexts ? contexts.indexOf(context) : -1;
4369             if (spliceIndex >= 0) {
4370                 contexts.splice(contexts.indexOf(context), 1);
4371             }
4372         };
4373         return BufferTimeSubscriber;
4374     }(Subscriber));
4375     function dispatchBufferTimeSpanOnly(state) {
4376         var subscriber = state.subscriber;
4377         var prevContext = state.context;
4378         if (prevContext) {
4379             subscriber.closeContext(prevContext);
4380         }
4381         if (!subscriber.closed) {
4382             state.context = subscriber.openContext();
4383             state.context.closeAction = this.schedule(state, state.bufferTimeSpan);
4384         }
4385     }
4386     function dispatchBufferCreation(state) {
4387         var bufferCreationInterval = state.bufferCreationInterval, bufferTimeSpan = state.bufferTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler;
4388         var context = subscriber.openContext();
4389         var action = this;
4390         if (!subscriber.closed) {
4391             subscriber.add(context.closeAction = scheduler.schedule(dispatchBufferClose, bufferTimeSpan, { subscriber: subscriber, context: context }));
4392             action.schedule(state, bufferCreationInterval);
4393         }
4394     }
4395     function dispatchBufferClose(arg) {
4396         var subscriber = arg.subscriber, context = arg.context;
4397         subscriber.closeContext(context);
4398     }
4399
4400     function bufferToggle(openings, closingSelector) {
4401         return function bufferToggleOperatorFunction(source) {
4402             return source.lift(new BufferToggleOperator(openings, closingSelector));
4403         };
4404     }
4405     var BufferToggleOperator = (function () {
4406         function BufferToggleOperator(openings, closingSelector) {
4407             this.openings = openings;
4408             this.closingSelector = closingSelector;
4409         }
4410         BufferToggleOperator.prototype.call = function (subscriber, source) {
4411             return source.subscribe(new BufferToggleSubscriber(subscriber, this.openings, this.closingSelector));
4412         };
4413         return BufferToggleOperator;
4414     }());
4415     var BufferToggleSubscriber = (function (_super) {
4416         __extends(BufferToggleSubscriber, _super);
4417         function BufferToggleSubscriber(destination, openings, closingSelector) {
4418             var _this = _super.call(this, destination) || this;
4419             _this.closingSelector = closingSelector;
4420             _this.contexts = [];
4421             _this.add(subscribeToResult(_this, openings));
4422             return _this;
4423         }
4424         BufferToggleSubscriber.prototype._next = function (value) {
4425             var contexts = this.contexts;
4426             var len = contexts.length;
4427             for (var i = 0; i < len; i++) {
4428                 contexts[i].buffer.push(value);
4429             }
4430         };
4431         BufferToggleSubscriber.prototype._error = function (err) {
4432             var contexts = this.contexts;
4433             while (contexts.length > 0) {
4434                 var context_1 = contexts.shift();
4435                 context_1.subscription.unsubscribe();
4436                 context_1.buffer = null;
4437                 context_1.subscription = null;
4438             }
4439             this.contexts = null;
4440             _super.prototype._error.call(this, err);
4441         };
4442         BufferToggleSubscriber.prototype._complete = function () {
4443             var contexts = this.contexts;
4444             while (contexts.length > 0) {
4445                 var context_2 = contexts.shift();
4446                 this.destination.next(context_2.buffer);
4447                 context_2.subscription.unsubscribe();
4448                 context_2.buffer = null;
4449                 context_2.subscription = null;
4450             }
4451             this.contexts = null;
4452             _super.prototype._complete.call(this);
4453         };
4454         BufferToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue) {
4455             outerValue ? this.closeBuffer(outerValue) : this.openBuffer(innerValue);
4456         };
4457         BufferToggleSubscriber.prototype.notifyComplete = function (innerSub) {
4458             this.closeBuffer(innerSub.context);
4459         };
4460         BufferToggleSubscriber.prototype.openBuffer = function (value) {
4461             try {
4462                 var closingSelector = this.closingSelector;
4463                 var closingNotifier = closingSelector.call(this, value);
4464                 if (closingNotifier) {
4465                     this.trySubscribe(closingNotifier);
4466                 }
4467             }
4468             catch (err) {
4469                 this._error(err);
4470             }
4471         };
4472         BufferToggleSubscriber.prototype.closeBuffer = function (context) {
4473             var contexts = this.contexts;
4474             if (contexts && context) {
4475                 var buffer = context.buffer, subscription = context.subscription;
4476                 this.destination.next(buffer);
4477                 contexts.splice(contexts.indexOf(context), 1);
4478                 this.remove(subscription);
4479                 subscription.unsubscribe();
4480             }
4481         };
4482         BufferToggleSubscriber.prototype.trySubscribe = function (closingNotifier) {
4483             var contexts = this.contexts;
4484             var buffer = [];
4485             var subscription = new Subscription();
4486             var context = { buffer: buffer, subscription: subscription };
4487             contexts.push(context);
4488             var innerSubscription = subscribeToResult(this, closingNotifier, context);
4489             if (!innerSubscription || innerSubscription.closed) {
4490                 this.closeBuffer(context);
4491             }
4492             else {
4493                 innerSubscription.context = context;
4494                 this.add(innerSubscription);
4495                 subscription.add(innerSubscription);
4496             }
4497         };
4498         return BufferToggleSubscriber;
4499     }(OuterSubscriber));
4500
4501     function bufferWhen(closingSelector) {
4502         return function (source) {
4503             return source.lift(new BufferWhenOperator(closingSelector));
4504         };
4505     }
4506     var BufferWhenOperator = (function () {
4507         function BufferWhenOperator(closingSelector) {
4508             this.closingSelector = closingSelector;
4509         }
4510         BufferWhenOperator.prototype.call = function (subscriber, source) {
4511             return source.subscribe(new BufferWhenSubscriber(subscriber, this.closingSelector));
4512         };
4513         return BufferWhenOperator;
4514     }());
4515     var BufferWhenSubscriber = (function (_super) {
4516         __extends(BufferWhenSubscriber, _super);
4517         function BufferWhenSubscriber(destination, closingSelector) {
4518             var _this = _super.call(this, destination) || this;
4519             _this.closingSelector = closingSelector;
4520             _this.subscribing = false;
4521             _this.openBuffer();
4522             return _this;
4523         }
4524         BufferWhenSubscriber.prototype._next = function (value) {
4525             this.buffer.push(value);
4526         };
4527         BufferWhenSubscriber.prototype._complete = function () {
4528             var buffer = this.buffer;
4529             if (buffer) {
4530                 this.destination.next(buffer);
4531             }
4532             _super.prototype._complete.call(this);
4533         };
4534         BufferWhenSubscriber.prototype._unsubscribe = function () {
4535             this.buffer = undefined;
4536             this.subscribing = false;
4537         };
4538         BufferWhenSubscriber.prototype.notifyNext = function () {
4539             this.openBuffer();
4540         };
4541         BufferWhenSubscriber.prototype.notifyComplete = function () {
4542             if (this.subscribing) {
4543                 this.complete();
4544             }
4545             else {
4546                 this.openBuffer();
4547             }
4548         };
4549         BufferWhenSubscriber.prototype.openBuffer = function () {
4550             var closingSubscription = this.closingSubscription;
4551             if (closingSubscription) {
4552                 this.remove(closingSubscription);
4553                 closingSubscription.unsubscribe();
4554             }
4555             var buffer = this.buffer;
4556             if (this.buffer) {
4557                 this.destination.next(buffer);
4558             }
4559             this.buffer = [];
4560             var closingNotifier;
4561             try {
4562                 var closingSelector = this.closingSelector;
4563                 closingNotifier = closingSelector();
4564             }
4565             catch (err) {
4566                 return this.error(err);
4567             }
4568             closingSubscription = new Subscription();
4569             this.closingSubscription = closingSubscription;
4570             this.add(closingSubscription);
4571             this.subscribing = true;
4572             closingSubscription.add(innerSubscribe(closingNotifier, new SimpleInnerSubscriber(this)));
4573             this.subscribing = false;
4574         };
4575         return BufferWhenSubscriber;
4576     }(SimpleOuterSubscriber));
4577
4578     function catchError(selector) {
4579         return function catchErrorOperatorFunction(source) {
4580             var operator = new CatchOperator(selector);
4581             var caught = source.lift(operator);
4582             return (operator.caught = caught);
4583         };
4584     }
4585     var CatchOperator = (function () {
4586         function CatchOperator(selector) {
4587             this.selector = selector;
4588         }
4589         CatchOperator.prototype.call = function (subscriber, source) {
4590             return source.subscribe(new CatchSubscriber(subscriber, this.selector, this.caught));
4591         };
4592         return CatchOperator;
4593     }());
4594     var CatchSubscriber = (function (_super) {
4595         __extends(CatchSubscriber, _super);
4596         function CatchSubscriber(destination, selector, caught) {
4597             var _this = _super.call(this, destination) || this;
4598             _this.selector = selector;
4599             _this.caught = caught;
4600             return _this;
4601         }
4602         CatchSubscriber.prototype.error = function (err) {
4603             if (!this.isStopped) {
4604                 var result = void 0;
4605                 try {
4606                     result = this.selector(err, this.caught);
4607                 }
4608                 catch (err2) {
4609                     _super.prototype.error.call(this, err2);
4610                     return;
4611                 }
4612                 this._unsubscribeAndRecycle();
4613                 var innerSubscriber = new SimpleInnerSubscriber(this);
4614                 this.add(innerSubscriber);
4615                 var innerSubscription = innerSubscribe(result, innerSubscriber);
4616                 if (innerSubscription !== innerSubscriber) {
4617                     this.add(innerSubscription);
4618                 }
4619             }
4620         };
4621         return CatchSubscriber;
4622     }(SimpleOuterSubscriber));
4623
4624     function combineAll(project) {
4625         return function (source) { return source.lift(new CombineLatestOperator(project)); };
4626     }
4627
4628     function combineLatest$1() {
4629         var observables = [];
4630         for (var _i = 0; _i < arguments.length; _i++) {
4631             observables[_i] = arguments[_i];
4632         }
4633         var project = null;
4634         if (typeof observables[observables.length - 1] === 'function') {
4635             project = observables.pop();
4636         }
4637         if (observables.length === 1 && isArray(observables[0])) {
4638             observables = observables[0].slice();
4639         }
4640         return function (source) { return source.lift.call(from([source].concat(observables)), new CombineLatestOperator(project)); };
4641     }
4642
4643     function concat$1() {
4644         var observables = [];
4645         for (var _i = 0; _i < arguments.length; _i++) {
4646             observables[_i] = arguments[_i];
4647         }
4648         return function (source) { return source.lift.call(concat.apply(void 0, [source].concat(observables))); };
4649     }
4650
4651     function concatMap(project, resultSelector) {
4652         return mergeMap(project, resultSelector, 1);
4653     }
4654
4655     function concatMapTo(innerObservable, resultSelector) {
4656         return concatMap(function () { return innerObservable; }, resultSelector);
4657     }
4658
4659     function count(predicate) {
4660         return function (source) { return source.lift(new CountOperator(predicate, source)); };
4661     }
4662     var CountOperator = (function () {
4663         function CountOperator(predicate, source) {
4664             this.predicate = predicate;
4665             this.source = source;
4666         }
4667         CountOperator.prototype.call = function (subscriber, source) {
4668             return source.subscribe(new CountSubscriber(subscriber, this.predicate, this.source));
4669         };
4670         return CountOperator;
4671     }());
4672     var CountSubscriber = (function (_super) {
4673         __extends(CountSubscriber, _super);
4674         function CountSubscriber(destination, predicate, source) {
4675             var _this = _super.call(this, destination) || this;
4676             _this.predicate = predicate;
4677             _this.source = source;
4678             _this.count = 0;
4679             _this.index = 0;
4680             return _this;
4681         }
4682         CountSubscriber.prototype._next = function (value) {
4683             if (this.predicate) {
4684                 this._tryPredicate(value);
4685             }
4686             else {
4687                 this.count++;
4688             }
4689         };
4690         CountSubscriber.prototype._tryPredicate = function (value) {
4691             var result;
4692             try {
4693                 result = this.predicate(value, this.index++, this.source);
4694             }
4695             catch (err) {
4696                 this.destination.error(err);
4697                 return;
4698             }
4699             if (result) {
4700                 this.count++;
4701             }
4702         };
4703         CountSubscriber.prototype._complete = function () {
4704             this.destination.next(this.count);
4705             this.destination.complete();
4706         };
4707         return CountSubscriber;
4708     }(Subscriber));
4709
4710     function debounce(durationSelector) {
4711         return function (source) { return source.lift(new DebounceOperator(durationSelector)); };
4712     }
4713     var DebounceOperator = (function () {
4714         function DebounceOperator(durationSelector) {
4715             this.durationSelector = durationSelector;
4716         }
4717         DebounceOperator.prototype.call = function (subscriber, source) {
4718             return source.subscribe(new DebounceSubscriber(subscriber, this.durationSelector));
4719         };
4720         return DebounceOperator;
4721     }());
4722     var DebounceSubscriber = (function (_super) {
4723         __extends(DebounceSubscriber, _super);
4724         function DebounceSubscriber(destination, durationSelector) {
4725             var _this = _super.call(this, destination) || this;
4726             _this.durationSelector = durationSelector;
4727             _this.hasValue = false;
4728             return _this;
4729         }
4730         DebounceSubscriber.prototype._next = function (value) {
4731             try {
4732                 var result = this.durationSelector.call(this, value);
4733                 if (result) {
4734                     this._tryNext(value, result);
4735                 }
4736             }
4737             catch (err) {
4738                 this.destination.error(err);
4739             }
4740         };
4741         DebounceSubscriber.prototype._complete = function () {
4742             this.emitValue();
4743             this.destination.complete();
4744         };
4745         DebounceSubscriber.prototype._tryNext = function (value, duration) {
4746             var subscription = this.durationSubscription;
4747             this.value = value;
4748             this.hasValue = true;
4749             if (subscription) {
4750                 subscription.unsubscribe();
4751                 this.remove(subscription);
4752             }
4753             subscription = innerSubscribe(duration, new SimpleInnerSubscriber(this));
4754             if (subscription && !subscription.closed) {
4755                 this.add(this.durationSubscription = subscription);
4756             }
4757         };
4758         DebounceSubscriber.prototype.notifyNext = function () {
4759             this.emitValue();
4760         };
4761         DebounceSubscriber.prototype.notifyComplete = function () {
4762             this.emitValue();
4763         };
4764         DebounceSubscriber.prototype.emitValue = function () {
4765             if (this.hasValue) {
4766                 var value = this.value;
4767                 var subscription = this.durationSubscription;
4768                 if (subscription) {
4769                     this.durationSubscription = undefined;
4770                     subscription.unsubscribe();
4771                     this.remove(subscription);
4772                 }
4773                 this.value = undefined;
4774                 this.hasValue = false;
4775                 _super.prototype._next.call(this, value);
4776             }
4777         };
4778         return DebounceSubscriber;
4779     }(SimpleOuterSubscriber));
4780
4781     function debounceTime(dueTime, scheduler) {
4782         if (scheduler === void 0) { scheduler = async; }
4783         return function (source) { return source.lift(new DebounceTimeOperator(dueTime, scheduler)); };
4784     }
4785     var DebounceTimeOperator = (function () {
4786         function DebounceTimeOperator(dueTime, scheduler) {
4787             this.dueTime = dueTime;
4788             this.scheduler = scheduler;
4789         }
4790         DebounceTimeOperator.prototype.call = function (subscriber, source) {
4791             return source.subscribe(new DebounceTimeSubscriber(subscriber, this.dueTime, this.scheduler));
4792         };
4793         return DebounceTimeOperator;
4794     }());
4795     var DebounceTimeSubscriber = (function (_super) {
4796         __extends(DebounceTimeSubscriber, _super);
4797         function DebounceTimeSubscriber(destination, dueTime, scheduler) {
4798             var _this = _super.call(this, destination) || this;
4799             _this.dueTime = dueTime;
4800             _this.scheduler = scheduler;
4801             _this.debouncedSubscription = null;
4802             _this.lastValue = null;
4803             _this.hasValue = false;
4804             return _this;
4805         }
4806         DebounceTimeSubscriber.prototype._next = function (value) {
4807             this.clearDebounce();
4808             this.lastValue = value;
4809             this.hasValue = true;
4810             this.add(this.debouncedSubscription = this.scheduler.schedule(dispatchNext$2, this.dueTime, this));
4811         };
4812         DebounceTimeSubscriber.prototype._complete = function () {
4813             this.debouncedNext();
4814             this.destination.complete();
4815         };
4816         DebounceTimeSubscriber.prototype.debouncedNext = function () {
4817             this.clearDebounce();
4818             if (this.hasValue) {
4819                 var lastValue = this.lastValue;
4820                 this.lastValue = null;
4821                 this.hasValue = false;
4822                 this.destination.next(lastValue);
4823             }
4824         };
4825         DebounceTimeSubscriber.prototype.clearDebounce = function () {
4826             var debouncedSubscription = this.debouncedSubscription;
4827             if (debouncedSubscription !== null) {
4828                 this.remove(debouncedSubscription);
4829                 debouncedSubscription.unsubscribe();
4830                 this.debouncedSubscription = null;
4831             }
4832         };
4833         return DebounceTimeSubscriber;
4834     }(Subscriber));
4835     function dispatchNext$2(subscriber) {
4836         subscriber.debouncedNext();
4837     }
4838
4839     function defaultIfEmpty(defaultValue) {
4840         if (defaultValue === void 0) { defaultValue = null; }
4841         return function (source) { return source.lift(new DefaultIfEmptyOperator(defaultValue)); };
4842     }
4843     var DefaultIfEmptyOperator = (function () {
4844         function DefaultIfEmptyOperator(defaultValue) {
4845             this.defaultValue = defaultValue;
4846         }
4847         DefaultIfEmptyOperator.prototype.call = function (subscriber, source) {
4848             return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
4849         };
4850         return DefaultIfEmptyOperator;
4851     }());
4852     var DefaultIfEmptySubscriber = (function (_super) {
4853         __extends(DefaultIfEmptySubscriber, _super);
4854         function DefaultIfEmptySubscriber(destination, defaultValue) {
4855             var _this = _super.call(this, destination) || this;
4856             _this.defaultValue = defaultValue;
4857             _this.isEmpty = true;
4858             return _this;
4859         }
4860         DefaultIfEmptySubscriber.prototype._next = function (value) {
4861             this.isEmpty = false;
4862             this.destination.next(value);
4863         };
4864         DefaultIfEmptySubscriber.prototype._complete = function () {
4865             if (this.isEmpty) {
4866                 this.destination.next(this.defaultValue);
4867             }
4868             this.destination.complete();
4869         };
4870         return DefaultIfEmptySubscriber;
4871     }(Subscriber));
4872
4873     function isDate(value) {
4874         return value instanceof Date && !isNaN(+value);
4875     }
4876
4877     function delay(delay, scheduler) {
4878         if (scheduler === void 0) { scheduler = async; }
4879         var absoluteDelay = isDate(delay);
4880         var delayFor = absoluteDelay ? (+delay - scheduler.now()) : Math.abs(delay);
4881         return function (source) { return source.lift(new DelayOperator(delayFor, scheduler)); };
4882     }
4883     var DelayOperator = (function () {
4884         function DelayOperator(delay, scheduler) {
4885             this.delay = delay;
4886             this.scheduler = scheduler;
4887         }
4888         DelayOperator.prototype.call = function (subscriber, source) {
4889             return source.subscribe(new DelaySubscriber(subscriber, this.delay, this.scheduler));
4890         };
4891         return DelayOperator;
4892     }());
4893     var DelaySubscriber = (function (_super) {
4894         __extends(DelaySubscriber, _super);
4895         function DelaySubscriber(destination, delay, scheduler) {
4896             var _this = _super.call(this, destination) || this;
4897             _this.delay = delay;
4898             _this.scheduler = scheduler;
4899             _this.queue = [];
4900             _this.active = false;
4901             _this.errored = false;
4902             return _this;
4903         }
4904         DelaySubscriber.dispatch = function (state) {
4905             var source = state.source;
4906             var queue = source.queue;
4907             var scheduler = state.scheduler;
4908             var destination = state.destination;
4909             while (queue.length > 0 && (queue[0].time - scheduler.now()) <= 0) {
4910                 queue.shift().notification.observe(destination);
4911             }
4912             if (queue.length > 0) {
4913                 var delay_1 = Math.max(0, queue[0].time - scheduler.now());
4914                 this.schedule(state, delay_1);
4915             }
4916             else {
4917                 this.unsubscribe();
4918                 source.active = false;
4919             }
4920         };
4921         DelaySubscriber.prototype._schedule = function (scheduler) {
4922             this.active = true;
4923             var destination = this.destination;
4924             destination.add(scheduler.schedule(DelaySubscriber.dispatch, this.delay, {
4925                 source: this, destination: this.destination, scheduler: scheduler
4926             }));
4927         };
4928         DelaySubscriber.prototype.scheduleNotification = function (notification) {
4929             if (this.errored === true) {
4930                 return;
4931             }
4932             var scheduler = this.scheduler;
4933             var message = new DelayMessage(scheduler.now() + this.delay, notification);
4934             this.queue.push(message);
4935             if (this.active === false) {
4936                 this._schedule(scheduler);
4937             }
4938         };
4939         DelaySubscriber.prototype._next = function (value) {
4940             this.scheduleNotification(Notification.createNext(value));
4941         };
4942         DelaySubscriber.prototype._error = function (err) {
4943             this.errored = true;
4944             this.queue = [];
4945             this.destination.error(err);
4946             this.unsubscribe();
4947         };
4948         DelaySubscriber.prototype._complete = function () {
4949             this.scheduleNotification(Notification.createComplete());
4950             this.unsubscribe();
4951         };
4952         return DelaySubscriber;
4953     }(Subscriber));
4954     var DelayMessage = (function () {
4955         function DelayMessage(time, notification) {
4956             this.time = time;
4957             this.notification = notification;
4958         }
4959         return DelayMessage;
4960     }());
4961
4962     function delayWhen(delayDurationSelector, subscriptionDelay) {
4963         if (subscriptionDelay) {
4964             return function (source) {
4965                 return new SubscriptionDelayObservable(source, subscriptionDelay)
4966                     .lift(new DelayWhenOperator(delayDurationSelector));
4967             };
4968         }
4969         return function (source) { return source.lift(new DelayWhenOperator(delayDurationSelector)); };
4970     }
4971     var DelayWhenOperator = (function () {
4972         function DelayWhenOperator(delayDurationSelector) {
4973             this.delayDurationSelector = delayDurationSelector;
4974         }
4975         DelayWhenOperator.prototype.call = function (subscriber, source) {
4976             return source.subscribe(new DelayWhenSubscriber(subscriber, this.delayDurationSelector));
4977         };
4978         return DelayWhenOperator;
4979     }());
4980     var DelayWhenSubscriber = (function (_super) {
4981         __extends(DelayWhenSubscriber, _super);
4982         function DelayWhenSubscriber(destination, delayDurationSelector) {
4983             var _this = _super.call(this, destination) || this;
4984             _this.delayDurationSelector = delayDurationSelector;
4985             _this.completed = false;
4986             _this.delayNotifierSubscriptions = [];
4987             _this.index = 0;
4988             return _this;
4989         }
4990         DelayWhenSubscriber.prototype.notifyNext = function (outerValue, _innerValue, _outerIndex, _innerIndex, innerSub) {
4991             this.destination.next(outerValue);
4992             this.removeSubscription(innerSub);
4993             this.tryComplete();
4994         };
4995         DelayWhenSubscriber.prototype.notifyError = function (error, innerSub) {
4996             this._error(error);
4997         };
4998         DelayWhenSubscriber.prototype.notifyComplete = function (innerSub) {
4999             var value = this.removeSubscription(innerSub);
5000             if (value) {
5001                 this.destination.next(value);
5002             }
5003             this.tryComplete();
5004         };
5005         DelayWhenSubscriber.prototype._next = function (value) {
5006             var index = this.index++;
5007             try {
5008                 var delayNotifier = this.delayDurationSelector(value, index);
5009                 if (delayNotifier) {
5010                     this.tryDelay(delayNotifier, value);
5011                 }
5012             }
5013             catch (err) {
5014                 this.destination.error(err);
5015             }
5016         };
5017         DelayWhenSubscriber.prototype._complete = function () {
5018             this.completed = true;
5019             this.tryComplete();
5020             this.unsubscribe();
5021         };
5022         DelayWhenSubscriber.prototype.removeSubscription = function (subscription) {
5023             subscription.unsubscribe();
5024             var subscriptionIdx = this.delayNotifierSubscriptions.indexOf(subscription);
5025             if (subscriptionIdx !== -1) {
5026                 this.delayNotifierSubscriptions.splice(subscriptionIdx, 1);
5027             }
5028             return subscription.outerValue;
5029         };
5030         DelayWhenSubscriber.prototype.tryDelay = function (delayNotifier, value) {
5031             var notifierSubscription = subscribeToResult(this, delayNotifier, value);
5032             if (notifierSubscription && !notifierSubscription.closed) {
5033                 var destination = this.destination;
5034                 destination.add(notifierSubscription);
5035                 this.delayNotifierSubscriptions.push(notifierSubscription);
5036             }
5037         };
5038         DelayWhenSubscriber.prototype.tryComplete = function () {
5039             if (this.completed && this.delayNotifierSubscriptions.length === 0) {
5040                 this.destination.complete();
5041             }
5042         };
5043         return DelayWhenSubscriber;
5044     }(OuterSubscriber));
5045     var SubscriptionDelayObservable = (function (_super) {
5046         __extends(SubscriptionDelayObservable, _super);
5047         function SubscriptionDelayObservable(source, subscriptionDelay) {
5048             var _this = _super.call(this) || this;
5049             _this.source = source;
5050             _this.subscriptionDelay = subscriptionDelay;
5051             return _this;
5052         }
5053         SubscriptionDelayObservable.prototype._subscribe = function (subscriber) {
5054             this.subscriptionDelay.subscribe(new SubscriptionDelaySubscriber(subscriber, this.source));
5055         };
5056         return SubscriptionDelayObservable;
5057     }(Observable));
5058     var SubscriptionDelaySubscriber = (function (_super) {
5059         __extends(SubscriptionDelaySubscriber, _super);
5060         function SubscriptionDelaySubscriber(parent, source) {
5061             var _this = _super.call(this) || this;
5062             _this.parent = parent;
5063             _this.source = source;
5064             _this.sourceSubscribed = false;
5065             return _this;
5066         }
5067         SubscriptionDelaySubscriber.prototype._next = function (unused) {
5068             this.subscribeToSource();
5069         };
5070         SubscriptionDelaySubscriber.prototype._error = function (err) {
5071             this.unsubscribe();
5072             this.parent.error(err);
5073         };
5074         SubscriptionDelaySubscriber.prototype._complete = function () {
5075             this.unsubscribe();
5076             this.subscribeToSource();
5077         };
5078         SubscriptionDelaySubscriber.prototype.subscribeToSource = function () {
5079             if (!this.sourceSubscribed) {
5080                 this.sourceSubscribed = true;
5081                 this.unsubscribe();
5082                 this.source.subscribe(this.parent);
5083             }
5084         };
5085         return SubscriptionDelaySubscriber;
5086     }(Subscriber));
5087
5088     function dematerialize() {
5089         return function dematerializeOperatorFunction(source) {
5090             return source.lift(new DeMaterializeOperator());
5091         };
5092     }
5093     var DeMaterializeOperator = (function () {
5094         function DeMaterializeOperator() {
5095         }
5096         DeMaterializeOperator.prototype.call = function (subscriber, source) {
5097             return source.subscribe(new DeMaterializeSubscriber(subscriber));
5098         };
5099         return DeMaterializeOperator;
5100     }());
5101     var DeMaterializeSubscriber = (function (_super) {
5102         __extends(DeMaterializeSubscriber, _super);
5103         function DeMaterializeSubscriber(destination) {
5104             return _super.call(this, destination) || this;
5105         }
5106         DeMaterializeSubscriber.prototype._next = function (value) {
5107             value.observe(this.destination);
5108         };
5109         return DeMaterializeSubscriber;
5110     }(Subscriber));
5111
5112     function distinct(keySelector, flushes) {
5113         return function (source) { return source.lift(new DistinctOperator(keySelector, flushes)); };
5114     }
5115     var DistinctOperator = (function () {
5116         function DistinctOperator(keySelector, flushes) {
5117             this.keySelector = keySelector;
5118             this.flushes = flushes;
5119         }
5120         DistinctOperator.prototype.call = function (subscriber, source) {
5121             return source.subscribe(new DistinctSubscriber(subscriber, this.keySelector, this.flushes));
5122         };
5123         return DistinctOperator;
5124     }());
5125     var DistinctSubscriber = (function (_super) {
5126         __extends(DistinctSubscriber, _super);
5127         function DistinctSubscriber(destination, keySelector, flushes) {
5128             var _this = _super.call(this, destination) || this;
5129             _this.keySelector = keySelector;
5130             _this.values = new Set();
5131             if (flushes) {
5132                 _this.add(innerSubscribe(flushes, new SimpleInnerSubscriber(_this)));
5133             }
5134             return _this;
5135         }
5136         DistinctSubscriber.prototype.notifyNext = function () {
5137             this.values.clear();
5138         };
5139         DistinctSubscriber.prototype.notifyError = function (error) {
5140             this._error(error);
5141         };
5142         DistinctSubscriber.prototype._next = function (value) {
5143             if (this.keySelector) {
5144                 this._useKeySelector(value);
5145             }
5146             else {
5147                 this._finalizeNext(value, value);
5148             }
5149         };
5150         DistinctSubscriber.prototype._useKeySelector = function (value) {
5151             var key;
5152             var destination = this.destination;
5153             try {
5154                 key = this.keySelector(value);
5155             }
5156             catch (err) {
5157                 destination.error(err);
5158                 return;
5159             }
5160             this._finalizeNext(key, value);
5161         };
5162         DistinctSubscriber.prototype._finalizeNext = function (key, value) {
5163             var values = this.values;
5164             if (!values.has(key)) {
5165                 values.add(key);
5166                 this.destination.next(value);
5167             }
5168         };
5169         return DistinctSubscriber;
5170     }(SimpleOuterSubscriber));
5171
5172     function distinctUntilChanged(compare, keySelector) {
5173         return function (source) { return source.lift(new DistinctUntilChangedOperator(compare, keySelector)); };
5174     }
5175     var DistinctUntilChangedOperator = (function () {
5176         function DistinctUntilChangedOperator(compare, keySelector) {
5177             this.compare = compare;
5178             this.keySelector = keySelector;
5179         }
5180         DistinctUntilChangedOperator.prototype.call = function (subscriber, source) {
5181             return source.subscribe(new DistinctUntilChangedSubscriber(subscriber, this.compare, this.keySelector));
5182         };
5183         return DistinctUntilChangedOperator;
5184     }());
5185     var DistinctUntilChangedSubscriber = (function (_super) {
5186         __extends(DistinctUntilChangedSubscriber, _super);
5187         function DistinctUntilChangedSubscriber(destination, compare, keySelector) {
5188             var _this = _super.call(this, destination) || this;
5189             _this.keySelector = keySelector;
5190             _this.hasKey = false;
5191             if (typeof compare === 'function') {
5192                 _this.compare = compare;
5193             }
5194             return _this;
5195         }
5196         DistinctUntilChangedSubscriber.prototype.compare = function (x, y) {
5197             return x === y;
5198         };
5199         DistinctUntilChangedSubscriber.prototype._next = function (value) {
5200             var key;
5201             try {
5202                 var keySelector = this.keySelector;
5203                 key = keySelector ? keySelector(value) : value;
5204             }
5205             catch (err) {
5206                 return this.destination.error(err);
5207             }
5208             var result = false;
5209             if (this.hasKey) {
5210                 try {
5211                     var compare = this.compare;
5212                     result = compare(this.key, key);
5213                 }
5214                 catch (err) {
5215                     return this.destination.error(err);
5216                 }
5217             }
5218             else {
5219                 this.hasKey = true;
5220             }
5221             if (!result) {
5222                 this.key = key;
5223                 this.destination.next(value);
5224             }
5225         };
5226         return DistinctUntilChangedSubscriber;
5227     }(Subscriber));
5228
5229     function distinctUntilKeyChanged(key, compare) {
5230         return distinctUntilChanged(function (x, y) { return compare ? compare(x[key], y[key]) : x[key] === y[key]; });
5231     }
5232
5233     function throwIfEmpty(errorFactory) {
5234         if (errorFactory === void 0) { errorFactory = defaultErrorFactory; }
5235         return function (source) {
5236             return source.lift(new ThrowIfEmptyOperator(errorFactory));
5237         };
5238     }
5239     var ThrowIfEmptyOperator = (function () {
5240         function ThrowIfEmptyOperator(errorFactory) {
5241             this.errorFactory = errorFactory;
5242         }
5243         ThrowIfEmptyOperator.prototype.call = function (subscriber, source) {
5244             return source.subscribe(new ThrowIfEmptySubscriber(subscriber, this.errorFactory));
5245         };
5246         return ThrowIfEmptyOperator;
5247     }());
5248     var ThrowIfEmptySubscriber = (function (_super) {
5249         __extends(ThrowIfEmptySubscriber, _super);
5250         function ThrowIfEmptySubscriber(destination, errorFactory) {
5251             var _this = _super.call(this, destination) || this;
5252             _this.errorFactory = errorFactory;
5253             _this.hasValue = false;
5254             return _this;
5255         }
5256         ThrowIfEmptySubscriber.prototype._next = function (value) {
5257             this.hasValue = true;
5258             this.destination.next(value);
5259         };
5260         ThrowIfEmptySubscriber.prototype._complete = function () {
5261             if (!this.hasValue) {
5262                 var err = void 0;
5263                 try {
5264                     err = this.errorFactory();
5265                 }
5266                 catch (e) {
5267                     err = e;
5268                 }
5269                 this.destination.error(err);
5270             }
5271             else {
5272                 return this.destination.complete();
5273             }
5274         };
5275         return ThrowIfEmptySubscriber;
5276     }(Subscriber));
5277     function defaultErrorFactory() {
5278         return new EmptyError();
5279     }
5280
5281     function take(count) {
5282         return function (source) {
5283             if (count === 0) {
5284                 return empty$1();
5285             }
5286             else {
5287                 return source.lift(new TakeOperator(count));
5288             }
5289         };
5290     }
5291     var TakeOperator = (function () {
5292         function TakeOperator(total) {
5293             this.total = total;
5294             if (this.total < 0) {
5295                 throw new ArgumentOutOfRangeError;
5296             }
5297         }
5298         TakeOperator.prototype.call = function (subscriber, source) {
5299             return source.subscribe(new TakeSubscriber(subscriber, this.total));
5300         };
5301         return TakeOperator;
5302     }());
5303     var TakeSubscriber = (function (_super) {
5304         __extends(TakeSubscriber, _super);
5305         function TakeSubscriber(destination, total) {
5306             var _this = _super.call(this, destination) || this;
5307             _this.total = total;
5308             _this.count = 0;
5309             return _this;
5310         }
5311         TakeSubscriber.prototype._next = function (value) {
5312             var total = this.total;
5313             var count = ++this.count;
5314             if (count <= total) {
5315                 this.destination.next(value);
5316                 if (count === total) {
5317                     this.destination.complete();
5318                     this.unsubscribe();
5319                 }
5320             }
5321         };
5322         return TakeSubscriber;
5323     }(Subscriber));
5324
5325     function elementAt(index, defaultValue) {
5326         if (index < 0) {
5327             throw new ArgumentOutOfRangeError();
5328         }
5329         var hasDefaultValue = arguments.length >= 2;
5330         return function (source) { return source.pipe(filter(function (v, i) { return i === index; }), take(1), hasDefaultValue
5331             ? defaultIfEmpty(defaultValue)
5332             : throwIfEmpty(function () { return new ArgumentOutOfRangeError(); })); };
5333     }
5334
5335     function endWith() {
5336         var array = [];
5337         for (var _i = 0; _i < arguments.length; _i++) {
5338             array[_i] = arguments[_i];
5339         }
5340         return function (source) { return concat(source, of.apply(void 0, array)); };
5341     }
5342
5343     function every(predicate, thisArg) {
5344         return function (source) { return source.lift(new EveryOperator(predicate, thisArg, source)); };
5345     }
5346     var EveryOperator = (function () {
5347         function EveryOperator(predicate, thisArg, source) {
5348             this.predicate = predicate;
5349             this.thisArg = thisArg;
5350             this.source = source;
5351         }
5352         EveryOperator.prototype.call = function (observer, source) {
5353             return source.subscribe(new EverySubscriber(observer, this.predicate, this.thisArg, this.source));
5354         };
5355         return EveryOperator;
5356     }());
5357     var EverySubscriber = (function (_super) {
5358         __extends(EverySubscriber, _super);
5359         function EverySubscriber(destination, predicate, thisArg, source) {
5360             var _this = _super.call(this, destination) || this;
5361             _this.predicate = predicate;
5362             _this.thisArg = thisArg;
5363             _this.source = source;
5364             _this.index = 0;
5365             _this.thisArg = thisArg || _this;
5366             return _this;
5367         }
5368         EverySubscriber.prototype.notifyComplete = function (everyValueMatch) {
5369             this.destination.next(everyValueMatch);
5370             this.destination.complete();
5371         };
5372         EverySubscriber.prototype._next = function (value) {
5373             var result = false;
5374             try {
5375                 result = this.predicate.call(this.thisArg, value, this.index++, this.source);
5376             }
5377             catch (err) {
5378                 this.destination.error(err);
5379                 return;
5380             }
5381             if (!result) {
5382                 this.notifyComplete(false);
5383             }
5384         };
5385         EverySubscriber.prototype._complete = function () {
5386             this.notifyComplete(true);
5387         };
5388         return EverySubscriber;
5389     }(Subscriber));
5390
5391     function exhaust() {
5392         return function (source) { return source.lift(new SwitchFirstOperator()); };
5393     }
5394     var SwitchFirstOperator = (function () {
5395         function SwitchFirstOperator() {
5396         }
5397         SwitchFirstOperator.prototype.call = function (subscriber, source) {
5398             return source.subscribe(new SwitchFirstSubscriber(subscriber));
5399         };
5400         return SwitchFirstOperator;
5401     }());
5402     var SwitchFirstSubscriber = (function (_super) {
5403         __extends(SwitchFirstSubscriber, _super);
5404         function SwitchFirstSubscriber(destination) {
5405             var _this = _super.call(this, destination) || this;
5406             _this.hasCompleted = false;
5407             _this.hasSubscription = false;
5408             return _this;
5409         }
5410         SwitchFirstSubscriber.prototype._next = function (value) {
5411             if (!this.hasSubscription) {
5412                 this.hasSubscription = true;
5413                 this.add(innerSubscribe(value, new SimpleInnerSubscriber(this)));
5414             }
5415         };
5416         SwitchFirstSubscriber.prototype._complete = function () {
5417             this.hasCompleted = true;
5418             if (!this.hasSubscription) {
5419                 this.destination.complete();
5420             }
5421         };
5422         SwitchFirstSubscriber.prototype.notifyComplete = function () {
5423             this.hasSubscription = false;
5424             if (this.hasCompleted) {
5425                 this.destination.complete();
5426             }
5427         };
5428         return SwitchFirstSubscriber;
5429     }(SimpleOuterSubscriber));
5430
5431     function exhaustMap(project, resultSelector) {
5432         if (resultSelector) {
5433             return function (source) { return source.pipe(exhaustMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
5434         }
5435         return function (source) {
5436             return source.lift(new ExhaustMapOperator(project));
5437         };
5438     }
5439     var ExhaustMapOperator = (function () {
5440         function ExhaustMapOperator(project) {
5441             this.project = project;
5442         }
5443         ExhaustMapOperator.prototype.call = function (subscriber, source) {
5444             return source.subscribe(new ExhaustMapSubscriber(subscriber, this.project));
5445         };
5446         return ExhaustMapOperator;
5447     }());
5448     var ExhaustMapSubscriber = (function (_super) {
5449         __extends(ExhaustMapSubscriber, _super);
5450         function ExhaustMapSubscriber(destination, project) {
5451             var _this = _super.call(this, destination) || this;
5452             _this.project = project;
5453             _this.hasSubscription = false;
5454             _this.hasCompleted = false;
5455             _this.index = 0;
5456             return _this;
5457         }
5458         ExhaustMapSubscriber.prototype._next = function (value) {
5459             if (!this.hasSubscription) {
5460                 this.tryNext(value);
5461             }
5462         };
5463         ExhaustMapSubscriber.prototype.tryNext = function (value) {
5464             var result;
5465             var index = this.index++;
5466             try {
5467                 result = this.project(value, index);
5468             }
5469             catch (err) {
5470                 this.destination.error(err);
5471                 return;
5472             }
5473             this.hasSubscription = true;
5474             this._innerSub(result);
5475         };
5476         ExhaustMapSubscriber.prototype._innerSub = function (result) {
5477             var innerSubscriber = new SimpleInnerSubscriber(this);
5478             var destination = this.destination;
5479             destination.add(innerSubscriber);
5480             var innerSubscription = innerSubscribe(result, innerSubscriber);
5481             if (innerSubscription !== innerSubscriber) {
5482                 destination.add(innerSubscription);
5483             }
5484         };
5485         ExhaustMapSubscriber.prototype._complete = function () {
5486             this.hasCompleted = true;
5487             if (!this.hasSubscription) {
5488                 this.destination.complete();
5489             }
5490             this.unsubscribe();
5491         };
5492         ExhaustMapSubscriber.prototype.notifyNext = function (innerValue) {
5493             this.destination.next(innerValue);
5494         };
5495         ExhaustMapSubscriber.prototype.notifyError = function (err) {
5496             this.destination.error(err);
5497         };
5498         ExhaustMapSubscriber.prototype.notifyComplete = function () {
5499             this.hasSubscription = false;
5500             if (this.hasCompleted) {
5501                 this.destination.complete();
5502             }
5503         };
5504         return ExhaustMapSubscriber;
5505     }(SimpleOuterSubscriber));
5506
5507     function expand(project, concurrent, scheduler) {
5508         if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
5509         concurrent = (concurrent || 0) < 1 ? Number.POSITIVE_INFINITY : concurrent;
5510         return function (source) { return source.lift(new ExpandOperator(project, concurrent, scheduler)); };
5511     }
5512     var ExpandOperator = (function () {
5513         function ExpandOperator(project, concurrent, scheduler) {
5514             this.project = project;
5515             this.concurrent = concurrent;
5516             this.scheduler = scheduler;
5517         }
5518         ExpandOperator.prototype.call = function (subscriber, source) {
5519             return source.subscribe(new ExpandSubscriber(subscriber, this.project, this.concurrent, this.scheduler));
5520         };
5521         return ExpandOperator;
5522     }());
5523     var ExpandSubscriber = (function (_super) {
5524         __extends(ExpandSubscriber, _super);
5525         function ExpandSubscriber(destination, project, concurrent, scheduler) {
5526             var _this = _super.call(this, destination) || this;
5527             _this.project = project;
5528             _this.concurrent = concurrent;
5529             _this.scheduler = scheduler;
5530             _this.index = 0;
5531             _this.active = 0;
5532             _this.hasCompleted = false;
5533             if (concurrent < Number.POSITIVE_INFINITY) {
5534                 _this.buffer = [];
5535             }
5536             return _this;
5537         }
5538         ExpandSubscriber.dispatch = function (arg) {
5539             var subscriber = arg.subscriber, result = arg.result, value = arg.value, index = arg.index;
5540             subscriber.subscribeToProjection(result, value, index);
5541         };
5542         ExpandSubscriber.prototype._next = function (value) {
5543             var destination = this.destination;
5544             if (destination.closed) {
5545                 this._complete();
5546                 return;
5547             }
5548             var index = this.index++;
5549             if (this.active < this.concurrent) {
5550                 destination.next(value);
5551                 try {
5552                     var project = this.project;
5553                     var result = project(value, index);
5554                     if (!this.scheduler) {
5555                         this.subscribeToProjection(result, value, index);
5556                     }
5557                     else {
5558                         var state = { subscriber: this, result: result, value: value, index: index };
5559                         var destination_1 = this.destination;
5560                         destination_1.add(this.scheduler.schedule(ExpandSubscriber.dispatch, 0, state));
5561                     }
5562                 }
5563                 catch (e) {
5564                     destination.error(e);
5565                 }
5566             }
5567             else {
5568                 this.buffer.push(value);
5569             }
5570         };
5571         ExpandSubscriber.prototype.subscribeToProjection = function (result, value, index) {
5572             this.active++;
5573             var destination = this.destination;
5574             destination.add(innerSubscribe(result, new SimpleInnerSubscriber(this)));
5575         };
5576         ExpandSubscriber.prototype._complete = function () {
5577             this.hasCompleted = true;
5578             if (this.hasCompleted && this.active === 0) {
5579                 this.destination.complete();
5580             }
5581             this.unsubscribe();
5582         };
5583         ExpandSubscriber.prototype.notifyNext = function (innerValue) {
5584             this._next(innerValue);
5585         };
5586         ExpandSubscriber.prototype.notifyComplete = function () {
5587             var buffer = this.buffer;
5588             this.active--;
5589             if (buffer && buffer.length > 0) {
5590                 this._next(buffer.shift());
5591             }
5592             if (this.hasCompleted && this.active === 0) {
5593                 this.destination.complete();
5594             }
5595         };
5596         return ExpandSubscriber;
5597     }(SimpleOuterSubscriber));
5598
5599     function finalize(callback) {
5600         return function (source) { return source.lift(new FinallyOperator(callback)); };
5601     }
5602     var FinallyOperator = (function () {
5603         function FinallyOperator(callback) {
5604             this.callback = callback;
5605         }
5606         FinallyOperator.prototype.call = function (subscriber, source) {
5607             return source.subscribe(new FinallySubscriber(subscriber, this.callback));
5608         };
5609         return FinallyOperator;
5610     }());
5611     var FinallySubscriber = (function (_super) {
5612         __extends(FinallySubscriber, _super);
5613         function FinallySubscriber(destination, callback) {
5614             var _this = _super.call(this, destination) || this;
5615             _this.add(new Subscription(callback));
5616             return _this;
5617         }
5618         return FinallySubscriber;
5619     }(Subscriber));
5620
5621     function find(predicate, thisArg) {
5622         if (typeof predicate !== 'function') {
5623             throw new TypeError('predicate is not a function');
5624         }
5625         return function (source) { return source.lift(new FindValueOperator(predicate, source, false, thisArg)); };
5626     }
5627     var FindValueOperator = (function () {
5628         function FindValueOperator(predicate, source, yieldIndex, thisArg) {
5629             this.predicate = predicate;
5630             this.source = source;
5631             this.yieldIndex = yieldIndex;
5632             this.thisArg = thisArg;
5633         }
5634         FindValueOperator.prototype.call = function (observer, source) {
5635             return source.subscribe(new FindValueSubscriber(observer, this.predicate, this.source, this.yieldIndex, this.thisArg));
5636         };
5637         return FindValueOperator;
5638     }());
5639     var FindValueSubscriber = (function (_super) {
5640         __extends(FindValueSubscriber, _super);
5641         function FindValueSubscriber(destination, predicate, source, yieldIndex, thisArg) {
5642             var _this = _super.call(this, destination) || this;
5643             _this.predicate = predicate;
5644             _this.source = source;
5645             _this.yieldIndex = yieldIndex;
5646             _this.thisArg = thisArg;
5647             _this.index = 0;
5648             return _this;
5649         }
5650         FindValueSubscriber.prototype.notifyComplete = function (value) {
5651             var destination = this.destination;
5652             destination.next(value);
5653             destination.complete();
5654             this.unsubscribe();
5655         };
5656         FindValueSubscriber.prototype._next = function (value) {
5657             var _a = this, predicate = _a.predicate, thisArg = _a.thisArg;
5658             var index = this.index++;
5659             try {
5660                 var result = predicate.call(thisArg || this, value, index, this.source);
5661                 if (result) {
5662                     this.notifyComplete(this.yieldIndex ? index : value);
5663                 }
5664             }
5665             catch (err) {
5666                 this.destination.error(err);
5667             }
5668         };
5669         FindValueSubscriber.prototype._complete = function () {
5670             this.notifyComplete(this.yieldIndex ? -1 : undefined);
5671         };
5672         return FindValueSubscriber;
5673     }(Subscriber));
5674
5675     function findIndex(predicate, thisArg) {
5676         return function (source) { return source.lift(new FindValueOperator(predicate, source, true, thisArg)); };
5677     }
5678
5679     function first(predicate, defaultValue) {
5680         var hasDefaultValue = arguments.length >= 2;
5681         return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, take(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
5682     }
5683
5684     function ignoreElements() {
5685         return function ignoreElementsOperatorFunction(source) {
5686             return source.lift(new IgnoreElementsOperator());
5687         };
5688     }
5689     var IgnoreElementsOperator = (function () {
5690         function IgnoreElementsOperator() {
5691         }
5692         IgnoreElementsOperator.prototype.call = function (subscriber, source) {
5693             return source.subscribe(new IgnoreElementsSubscriber(subscriber));
5694         };
5695         return IgnoreElementsOperator;
5696     }());
5697     var IgnoreElementsSubscriber = (function (_super) {
5698         __extends(IgnoreElementsSubscriber, _super);
5699         function IgnoreElementsSubscriber() {
5700             return _super !== null && _super.apply(this, arguments) || this;
5701         }
5702         IgnoreElementsSubscriber.prototype._next = function (unused) {
5703         };
5704         return IgnoreElementsSubscriber;
5705     }(Subscriber));
5706
5707     function isEmpty() {
5708         return function (source) { return source.lift(new IsEmptyOperator()); };
5709     }
5710     var IsEmptyOperator = (function () {
5711         function IsEmptyOperator() {
5712         }
5713         IsEmptyOperator.prototype.call = function (observer, source) {
5714             return source.subscribe(new IsEmptySubscriber(observer));
5715         };
5716         return IsEmptyOperator;
5717     }());
5718     var IsEmptySubscriber = (function (_super) {
5719         __extends(IsEmptySubscriber, _super);
5720         function IsEmptySubscriber(destination) {
5721             return _super.call(this, destination) || this;
5722         }
5723         IsEmptySubscriber.prototype.notifyComplete = function (isEmpty) {
5724             var destination = this.destination;
5725             destination.next(isEmpty);
5726             destination.complete();
5727         };
5728         IsEmptySubscriber.prototype._next = function (value) {
5729             this.notifyComplete(false);
5730         };
5731         IsEmptySubscriber.prototype._complete = function () {
5732             this.notifyComplete(true);
5733         };
5734         return IsEmptySubscriber;
5735     }(Subscriber));
5736
5737     function takeLast(count) {
5738         return function takeLastOperatorFunction(source) {
5739             if (count === 0) {
5740                 return empty$1();
5741             }
5742             else {
5743                 return source.lift(new TakeLastOperator(count));
5744             }
5745         };
5746     }
5747     var TakeLastOperator = (function () {
5748         function TakeLastOperator(total) {
5749             this.total = total;
5750             if (this.total < 0) {
5751                 throw new ArgumentOutOfRangeError;
5752             }
5753         }
5754         TakeLastOperator.prototype.call = function (subscriber, source) {
5755             return source.subscribe(new TakeLastSubscriber(subscriber, this.total));
5756         };
5757         return TakeLastOperator;
5758     }());
5759     var TakeLastSubscriber = (function (_super) {
5760         __extends(TakeLastSubscriber, _super);
5761         function TakeLastSubscriber(destination, total) {
5762             var _this = _super.call(this, destination) || this;
5763             _this.total = total;
5764             _this.ring = new Array();
5765             _this.count = 0;
5766             return _this;
5767         }
5768         TakeLastSubscriber.prototype._next = function (value) {
5769             var ring = this.ring;
5770             var total = this.total;
5771             var count = this.count++;
5772             if (ring.length < total) {
5773                 ring.push(value);
5774             }
5775             else {
5776                 var index = count % total;
5777                 ring[index] = value;
5778             }
5779         };
5780         TakeLastSubscriber.prototype._complete = function () {
5781             var destination = this.destination;
5782             var count = this.count;
5783             if (count > 0) {
5784                 var total = this.count >= this.total ? this.total : this.count;
5785                 var ring = this.ring;
5786                 for (var i = 0; i < total; i++) {
5787                     var idx = (count++) % total;
5788                     destination.next(ring[idx]);
5789                 }
5790             }
5791             destination.complete();
5792         };
5793         return TakeLastSubscriber;
5794     }(Subscriber));
5795
5796     function last(predicate, defaultValue) {
5797         var hasDefaultValue = arguments.length >= 2;
5798         return function (source) { return source.pipe(predicate ? filter(function (v, i) { return predicate(v, i, source); }) : identity, takeLast(1), hasDefaultValue ? defaultIfEmpty(defaultValue) : throwIfEmpty(function () { return new EmptyError(); })); };
5799     }
5800
5801     function mapTo(value) {
5802         return function (source) { return source.lift(new MapToOperator(value)); };
5803     }
5804     var MapToOperator = (function () {
5805         function MapToOperator(value) {
5806             this.value = value;
5807         }
5808         MapToOperator.prototype.call = function (subscriber, source) {
5809             return source.subscribe(new MapToSubscriber(subscriber, this.value));
5810         };
5811         return MapToOperator;
5812     }());
5813     var MapToSubscriber = (function (_super) {
5814         __extends(MapToSubscriber, _super);
5815         function MapToSubscriber(destination, value) {
5816             var _this = _super.call(this, destination) || this;
5817             _this.value = value;
5818             return _this;
5819         }
5820         MapToSubscriber.prototype._next = function (x) {
5821             this.destination.next(this.value);
5822         };
5823         return MapToSubscriber;
5824     }(Subscriber));
5825
5826     function materialize() {
5827         return function materializeOperatorFunction(source) {
5828             return source.lift(new MaterializeOperator());
5829         };
5830     }
5831     var MaterializeOperator = (function () {
5832         function MaterializeOperator() {
5833         }
5834         MaterializeOperator.prototype.call = function (subscriber, source) {
5835             return source.subscribe(new MaterializeSubscriber(subscriber));
5836         };
5837         return MaterializeOperator;
5838     }());
5839     var MaterializeSubscriber = (function (_super) {
5840         __extends(MaterializeSubscriber, _super);
5841         function MaterializeSubscriber(destination) {
5842             return _super.call(this, destination) || this;
5843         }
5844         MaterializeSubscriber.prototype._next = function (value) {
5845             this.destination.next(Notification.createNext(value));
5846         };
5847         MaterializeSubscriber.prototype._error = function (err) {
5848             var destination = this.destination;
5849             destination.next(Notification.createError(err));
5850             destination.complete();
5851         };
5852         MaterializeSubscriber.prototype._complete = function () {
5853             var destination = this.destination;
5854             destination.next(Notification.createComplete());
5855             destination.complete();
5856         };
5857         return MaterializeSubscriber;
5858     }(Subscriber));
5859
5860     function scan(accumulator, seed) {
5861         var hasSeed = false;
5862         if (arguments.length >= 2) {
5863             hasSeed = true;
5864         }
5865         return function scanOperatorFunction(source) {
5866             return source.lift(new ScanOperator(accumulator, seed, hasSeed));
5867         };
5868     }
5869     var ScanOperator = (function () {
5870         function ScanOperator(accumulator, seed, hasSeed) {
5871             if (hasSeed === void 0) { hasSeed = false; }
5872             this.accumulator = accumulator;
5873             this.seed = seed;
5874             this.hasSeed = hasSeed;
5875         }
5876         ScanOperator.prototype.call = function (subscriber, source) {
5877             return source.subscribe(new ScanSubscriber(subscriber, this.accumulator, this.seed, this.hasSeed));
5878         };
5879         return ScanOperator;
5880     }());
5881     var ScanSubscriber = (function (_super) {
5882         __extends(ScanSubscriber, _super);
5883         function ScanSubscriber(destination, accumulator, _seed, hasSeed) {
5884             var _this = _super.call(this, destination) || this;
5885             _this.accumulator = accumulator;
5886             _this._seed = _seed;
5887             _this.hasSeed = hasSeed;
5888             _this.index = 0;
5889             return _this;
5890         }
5891         Object.defineProperty(ScanSubscriber.prototype, "seed", {
5892             get: function () {
5893                 return this._seed;
5894             },
5895             set: function (value) {
5896                 this.hasSeed = true;
5897                 this._seed = value;
5898             },
5899             enumerable: true,
5900             configurable: true
5901         });
5902         ScanSubscriber.prototype._next = function (value) {
5903             if (!this.hasSeed) {
5904                 this.seed = value;
5905                 this.destination.next(value);
5906             }
5907             else {
5908                 return this._tryNext(value);
5909             }
5910         };
5911         ScanSubscriber.prototype._tryNext = function (value) {
5912             var index = this.index++;
5913             var result;
5914             try {
5915                 result = this.accumulator(this.seed, value, index);
5916             }
5917             catch (err) {
5918                 this.destination.error(err);
5919             }
5920             this.seed = result;
5921             this.destination.next(result);
5922         };
5923         return ScanSubscriber;
5924     }(Subscriber));
5925
5926     function reduce(accumulator, seed) {
5927         if (arguments.length >= 2) {
5928             return function reduceOperatorFunctionWithSeed(source) {
5929                 return pipe(scan(accumulator, seed), takeLast(1), defaultIfEmpty(seed))(source);
5930             };
5931         }
5932         return function reduceOperatorFunction(source) {
5933             return pipe(scan(function (acc, value, index) { return accumulator(acc, value, index + 1); }), takeLast(1))(source);
5934         };
5935     }
5936
5937     function max(comparer) {
5938         var max = (typeof comparer === 'function')
5939             ? function (x, y) { return comparer(x, y) > 0 ? x : y; }
5940             : function (x, y) { return x > y ? x : y; };
5941         return reduce(max);
5942     }
5943
5944     function merge$1() {
5945         var observables = [];
5946         for (var _i = 0; _i < arguments.length; _i++) {
5947             observables[_i] = arguments[_i];
5948         }
5949         return function (source) { return source.lift.call(merge.apply(void 0, [source].concat(observables))); };
5950     }
5951
5952     function mergeMapTo(innerObservable, resultSelector, concurrent) {
5953         if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
5954         if (typeof resultSelector === 'function') {
5955             return mergeMap(function () { return innerObservable; }, resultSelector, concurrent);
5956         }
5957         if (typeof resultSelector === 'number') {
5958             concurrent = resultSelector;
5959         }
5960         return mergeMap(function () { return innerObservable; }, concurrent);
5961     }
5962
5963     function mergeScan(accumulator, seed, concurrent) {
5964         if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
5965         return function (source) { return source.lift(new MergeScanOperator(accumulator, seed, concurrent)); };
5966     }
5967     var MergeScanOperator = (function () {
5968         function MergeScanOperator(accumulator, seed, concurrent) {
5969             this.accumulator = accumulator;
5970             this.seed = seed;
5971             this.concurrent = concurrent;
5972         }
5973         MergeScanOperator.prototype.call = function (subscriber, source) {
5974             return source.subscribe(new MergeScanSubscriber(subscriber, this.accumulator, this.seed, this.concurrent));
5975         };
5976         return MergeScanOperator;
5977     }());
5978     var MergeScanSubscriber = (function (_super) {
5979         __extends(MergeScanSubscriber, _super);
5980         function MergeScanSubscriber(destination, accumulator, acc, concurrent) {
5981             var _this = _super.call(this, destination) || this;
5982             _this.accumulator = accumulator;
5983             _this.acc = acc;
5984             _this.concurrent = concurrent;
5985             _this.hasValue = false;
5986             _this.hasCompleted = false;
5987             _this.buffer = [];
5988             _this.active = 0;
5989             _this.index = 0;
5990             return _this;
5991         }
5992         MergeScanSubscriber.prototype._next = function (value) {
5993             if (this.active < this.concurrent) {
5994                 var index = this.index++;
5995                 var destination = this.destination;
5996                 var ish = void 0;
5997                 try {
5998                     var accumulator = this.accumulator;
5999                     ish = accumulator(this.acc, value, index);
6000                 }
6001                 catch (e) {
6002                     return destination.error(e);
6003                 }
6004                 this.active++;
6005                 this._innerSub(ish);
6006             }
6007             else {
6008                 this.buffer.push(value);
6009             }
6010         };
6011         MergeScanSubscriber.prototype._innerSub = function (ish) {
6012             var innerSubscriber = new SimpleInnerSubscriber(this);
6013             var destination = this.destination;
6014             destination.add(innerSubscriber);
6015             var innerSubscription = innerSubscribe(ish, innerSubscriber);
6016             if (innerSubscription !== innerSubscriber) {
6017                 destination.add(innerSubscription);
6018             }
6019         };
6020         MergeScanSubscriber.prototype._complete = function () {
6021             this.hasCompleted = true;
6022             if (this.active === 0 && this.buffer.length === 0) {
6023                 if (this.hasValue === false) {
6024                     this.destination.next(this.acc);
6025                 }
6026                 this.destination.complete();
6027             }
6028             this.unsubscribe();
6029         };
6030         MergeScanSubscriber.prototype.notifyNext = function (innerValue) {
6031             var destination = this.destination;
6032             this.acc = innerValue;
6033             this.hasValue = true;
6034             destination.next(innerValue);
6035         };
6036         MergeScanSubscriber.prototype.notifyComplete = function () {
6037             var buffer = this.buffer;
6038             this.active--;
6039             if (buffer.length > 0) {
6040                 this._next(buffer.shift());
6041             }
6042             else if (this.active === 0 && this.hasCompleted) {
6043                 if (this.hasValue === false) {
6044                     this.destination.next(this.acc);
6045                 }
6046                 this.destination.complete();
6047             }
6048         };
6049         return MergeScanSubscriber;
6050     }(SimpleOuterSubscriber));
6051
6052     function min(comparer) {
6053         var min = (typeof comparer === 'function')
6054             ? function (x, y) { return comparer(x, y) < 0 ? x : y; }
6055             : function (x, y) { return x < y ? x : y; };
6056         return reduce(min);
6057     }
6058
6059     function multicast(subjectOrSubjectFactory, selector) {
6060         return function multicastOperatorFunction(source) {
6061             var subjectFactory;
6062             if (typeof subjectOrSubjectFactory === 'function') {
6063                 subjectFactory = subjectOrSubjectFactory;
6064             }
6065             else {
6066                 subjectFactory = function subjectFactory() {
6067                     return subjectOrSubjectFactory;
6068                 };
6069             }
6070             if (typeof selector === 'function') {
6071                 return source.lift(new MulticastOperator(subjectFactory, selector));
6072             }
6073             var connectable = Object.create(source, connectableObservableDescriptor);
6074             connectable.source = source;
6075             connectable.subjectFactory = subjectFactory;
6076             return connectable;
6077         };
6078     }
6079     var MulticastOperator = (function () {
6080         function MulticastOperator(subjectFactory, selector) {
6081             this.subjectFactory = subjectFactory;
6082             this.selector = selector;
6083         }
6084         MulticastOperator.prototype.call = function (subscriber, source) {
6085             var selector = this.selector;
6086             var subject = this.subjectFactory();
6087             var subscription = selector(subject).subscribe(subscriber);
6088             subscription.add(source.subscribe(subject));
6089             return subscription;
6090         };
6091         return MulticastOperator;
6092     }());
6093
6094     function onErrorResumeNext$1() {
6095         var nextSources = [];
6096         for (var _i = 0; _i < arguments.length; _i++) {
6097             nextSources[_i] = arguments[_i];
6098         }
6099         if (nextSources.length === 1 && isArray(nextSources[0])) {
6100             nextSources = nextSources[0];
6101         }
6102         return function (source) { return source.lift(new OnErrorResumeNextOperator(nextSources)); };
6103     }
6104     var OnErrorResumeNextOperator = (function () {
6105         function OnErrorResumeNextOperator(nextSources) {
6106             this.nextSources = nextSources;
6107         }
6108         OnErrorResumeNextOperator.prototype.call = function (subscriber, source) {
6109             return source.subscribe(new OnErrorResumeNextSubscriber(subscriber, this.nextSources));
6110         };
6111         return OnErrorResumeNextOperator;
6112     }());
6113     var OnErrorResumeNextSubscriber = (function (_super) {
6114         __extends(OnErrorResumeNextSubscriber, _super);
6115         function OnErrorResumeNextSubscriber(destination, nextSources) {
6116             var _this = _super.call(this, destination) || this;
6117             _this.destination = destination;
6118             _this.nextSources = nextSources;
6119             return _this;
6120         }
6121         OnErrorResumeNextSubscriber.prototype.notifyError = function () {
6122             this.subscribeToNextSource();
6123         };
6124         OnErrorResumeNextSubscriber.prototype.notifyComplete = function () {
6125             this.subscribeToNextSource();
6126         };
6127         OnErrorResumeNextSubscriber.prototype._error = function (err) {
6128             this.subscribeToNextSource();
6129             this.unsubscribe();
6130         };
6131         OnErrorResumeNextSubscriber.prototype._complete = function () {
6132             this.subscribeToNextSource();
6133             this.unsubscribe();
6134         };
6135         OnErrorResumeNextSubscriber.prototype.subscribeToNextSource = function () {
6136             var next = this.nextSources.shift();
6137             if (!!next) {
6138                 var innerSubscriber = new SimpleInnerSubscriber(this);
6139                 var destination = this.destination;
6140                 destination.add(innerSubscriber);
6141                 var innerSubscription = innerSubscribe(next, innerSubscriber);
6142                 if (innerSubscription !== innerSubscriber) {
6143                     destination.add(innerSubscription);
6144                 }
6145             }
6146             else {
6147                 this.destination.complete();
6148             }
6149         };
6150         return OnErrorResumeNextSubscriber;
6151     }(SimpleOuterSubscriber));
6152
6153     function pairwise() {
6154         return function (source) { return source.lift(new PairwiseOperator()); };
6155     }
6156     var PairwiseOperator = (function () {
6157         function PairwiseOperator() {
6158         }
6159         PairwiseOperator.prototype.call = function (subscriber, source) {
6160             return source.subscribe(new PairwiseSubscriber(subscriber));
6161         };
6162         return PairwiseOperator;
6163     }());
6164     var PairwiseSubscriber = (function (_super) {
6165         __extends(PairwiseSubscriber, _super);
6166         function PairwiseSubscriber(destination) {
6167             var _this = _super.call(this, destination) || this;
6168             _this.hasPrev = false;
6169             return _this;
6170         }
6171         PairwiseSubscriber.prototype._next = function (value) {
6172             var pair;
6173             if (this.hasPrev) {
6174                 pair = [this.prev, value];
6175             }
6176             else {
6177                 this.hasPrev = true;
6178             }
6179             this.prev = value;
6180             if (pair) {
6181                 this.destination.next(pair);
6182             }
6183         };
6184         return PairwiseSubscriber;
6185     }(Subscriber));
6186
6187     function partition$1(predicate, thisArg) {
6188         return function (source) { return [
6189             filter(predicate, thisArg)(source),
6190             filter(not(predicate, thisArg))(source)
6191         ]; };
6192     }
6193
6194     function pluck() {
6195         var properties = [];
6196         for (var _i = 0; _i < arguments.length; _i++) {
6197             properties[_i] = arguments[_i];
6198         }
6199         var length = properties.length;
6200         if (length === 0) {
6201             throw new Error('list of properties cannot be empty.');
6202         }
6203         return function (source) { return map(plucker(properties, length))(source); };
6204     }
6205     function plucker(props, length) {
6206         var mapper = function (x) {
6207             var currentProp = x;
6208             for (var i = 0; i < length; i++) {
6209                 var p = currentProp != null ? currentProp[props[i]] : undefined;
6210                 if (p !== void 0) {
6211                     currentProp = p;
6212                 }
6213                 else {
6214                     return undefined;
6215                 }
6216             }
6217             return currentProp;
6218         };
6219         return mapper;
6220     }
6221
6222     function publish(selector) {
6223         return selector ?
6224             multicast(function () { return new Subject(); }, selector) :
6225             multicast(new Subject());
6226     }
6227
6228     function publishBehavior(value) {
6229         return function (source) { return multicast(new BehaviorSubject(value))(source); };
6230     }
6231
6232     function publishLast() {
6233         return function (source) { return multicast(new AsyncSubject())(source); };
6234     }
6235
6236     function publishReplay(bufferSize, windowTime, selectorOrScheduler, scheduler) {
6237         if (selectorOrScheduler && typeof selectorOrScheduler !== 'function') {
6238             scheduler = selectorOrScheduler;
6239         }
6240         var selector = typeof selectorOrScheduler === 'function' ? selectorOrScheduler : undefined;
6241         var subject = new ReplaySubject(bufferSize, windowTime, scheduler);
6242         return function (source) { return multicast(function () { return subject; }, selector)(source); };
6243     }
6244
6245     function race$1() {
6246         var observables = [];
6247         for (var _i = 0; _i < arguments.length; _i++) {
6248             observables[_i] = arguments[_i];
6249         }
6250         return function raceOperatorFunction(source) {
6251             if (observables.length === 1 && isArray(observables[0])) {
6252                 observables = observables[0];
6253             }
6254             return source.lift.call(race.apply(void 0, [source].concat(observables)));
6255         };
6256     }
6257
6258     function repeat(count) {
6259         if (count === void 0) { count = -1; }
6260         return function (source) {
6261             if (count === 0) {
6262                 return empty$1();
6263             }
6264             else if (count < 0) {
6265                 return source.lift(new RepeatOperator(-1, source));
6266             }
6267             else {
6268                 return source.lift(new RepeatOperator(count - 1, source));
6269             }
6270         };
6271     }
6272     var RepeatOperator = (function () {
6273         function RepeatOperator(count, source) {
6274             this.count = count;
6275             this.source = source;
6276         }
6277         RepeatOperator.prototype.call = function (subscriber, source) {
6278             return source.subscribe(new RepeatSubscriber(subscriber, this.count, this.source));
6279         };
6280         return RepeatOperator;
6281     }());
6282     var RepeatSubscriber = (function (_super) {
6283         __extends(RepeatSubscriber, _super);
6284         function RepeatSubscriber(destination, count, source) {
6285             var _this = _super.call(this, destination) || this;
6286             _this.count = count;
6287             _this.source = source;
6288             return _this;
6289         }
6290         RepeatSubscriber.prototype.complete = function () {
6291             if (!this.isStopped) {
6292                 var _a = this, source = _a.source, count = _a.count;
6293                 if (count === 0) {
6294                     return _super.prototype.complete.call(this);
6295                 }
6296                 else if (count > -1) {
6297                     this.count = count - 1;
6298                 }
6299                 source.subscribe(this._unsubscribeAndRecycle());
6300             }
6301         };
6302         return RepeatSubscriber;
6303     }(Subscriber));
6304
6305     function repeatWhen(notifier) {
6306         return function (source) { return source.lift(new RepeatWhenOperator(notifier)); };
6307     }
6308     var RepeatWhenOperator = (function () {
6309         function RepeatWhenOperator(notifier) {
6310             this.notifier = notifier;
6311         }
6312         RepeatWhenOperator.prototype.call = function (subscriber, source) {
6313             return source.subscribe(new RepeatWhenSubscriber(subscriber, this.notifier, source));
6314         };
6315         return RepeatWhenOperator;
6316     }());
6317     var RepeatWhenSubscriber = (function (_super) {
6318         __extends(RepeatWhenSubscriber, _super);
6319         function RepeatWhenSubscriber(destination, notifier, source) {
6320             var _this = _super.call(this, destination) || this;
6321             _this.notifier = notifier;
6322             _this.source = source;
6323             _this.sourceIsBeingSubscribedTo = true;
6324             return _this;
6325         }
6326         RepeatWhenSubscriber.prototype.notifyNext = function () {
6327             this.sourceIsBeingSubscribedTo = true;
6328             this.source.subscribe(this);
6329         };
6330         RepeatWhenSubscriber.prototype.notifyComplete = function () {
6331             if (this.sourceIsBeingSubscribedTo === false) {
6332                 return _super.prototype.complete.call(this);
6333             }
6334         };
6335         RepeatWhenSubscriber.prototype.complete = function () {
6336             this.sourceIsBeingSubscribedTo = false;
6337             if (!this.isStopped) {
6338                 if (!this.retries) {
6339                     this.subscribeToRetries();
6340                 }
6341                 if (!this.retriesSubscription || this.retriesSubscription.closed) {
6342                     return _super.prototype.complete.call(this);
6343                 }
6344                 this._unsubscribeAndRecycle();
6345                 this.notifications.next(undefined);
6346             }
6347         };
6348         RepeatWhenSubscriber.prototype._unsubscribe = function () {
6349             var _a = this, notifications = _a.notifications, retriesSubscription = _a.retriesSubscription;
6350             if (notifications) {
6351                 notifications.unsubscribe();
6352                 this.notifications = undefined;
6353             }
6354             if (retriesSubscription) {
6355                 retriesSubscription.unsubscribe();
6356                 this.retriesSubscription = undefined;
6357             }
6358             this.retries = undefined;
6359         };
6360         RepeatWhenSubscriber.prototype._unsubscribeAndRecycle = function () {
6361             var _unsubscribe = this._unsubscribe;
6362             this._unsubscribe = null;
6363             _super.prototype._unsubscribeAndRecycle.call(this);
6364             this._unsubscribe = _unsubscribe;
6365             return this;
6366         };
6367         RepeatWhenSubscriber.prototype.subscribeToRetries = function () {
6368             this.notifications = new Subject();
6369             var retries;
6370             try {
6371                 var notifier = this.notifier;
6372                 retries = notifier(this.notifications);
6373             }
6374             catch (e) {
6375                 return _super.prototype.complete.call(this);
6376             }
6377             this.retries = retries;
6378             this.retriesSubscription = innerSubscribe(retries, new SimpleInnerSubscriber(this));
6379         };
6380         return RepeatWhenSubscriber;
6381     }(SimpleOuterSubscriber));
6382
6383     function retry(count) {
6384         if (count === void 0) { count = -1; }
6385         return function (source) { return source.lift(new RetryOperator(count, source)); };
6386     }
6387     var RetryOperator = (function () {
6388         function RetryOperator(count, source) {
6389             this.count = count;
6390             this.source = source;
6391         }
6392         RetryOperator.prototype.call = function (subscriber, source) {
6393             return source.subscribe(new RetrySubscriber(subscriber, this.count, this.source));
6394         };
6395         return RetryOperator;
6396     }());
6397     var RetrySubscriber = (function (_super) {
6398         __extends(RetrySubscriber, _super);
6399         function RetrySubscriber(destination, count, source) {
6400             var _this = _super.call(this, destination) || this;
6401             _this.count = count;
6402             _this.source = source;
6403             return _this;
6404         }
6405         RetrySubscriber.prototype.error = function (err) {
6406             if (!this.isStopped) {
6407                 var _a = this, source = _a.source, count = _a.count;
6408                 if (count === 0) {
6409                     return _super.prototype.error.call(this, err);
6410                 }
6411                 else if (count > -1) {
6412                     this.count = count - 1;
6413                 }
6414                 source.subscribe(this._unsubscribeAndRecycle());
6415             }
6416         };
6417         return RetrySubscriber;
6418     }(Subscriber));
6419
6420     function retryWhen(notifier) {
6421         return function (source) { return source.lift(new RetryWhenOperator(notifier, source)); };
6422     }
6423     var RetryWhenOperator = (function () {
6424         function RetryWhenOperator(notifier, source) {
6425             this.notifier = notifier;
6426             this.source = source;
6427         }
6428         RetryWhenOperator.prototype.call = function (subscriber, source) {
6429             return source.subscribe(new RetryWhenSubscriber(subscriber, this.notifier, this.source));
6430         };
6431         return RetryWhenOperator;
6432     }());
6433     var RetryWhenSubscriber = (function (_super) {
6434         __extends(RetryWhenSubscriber, _super);
6435         function RetryWhenSubscriber(destination, notifier, source) {
6436             var _this = _super.call(this, destination) || this;
6437             _this.notifier = notifier;
6438             _this.source = source;
6439             return _this;
6440         }
6441         RetryWhenSubscriber.prototype.error = function (err) {
6442             if (!this.isStopped) {
6443                 var errors = this.errors;
6444                 var retries = this.retries;
6445                 var retriesSubscription = this.retriesSubscription;
6446                 if (!retries) {
6447                     errors = new Subject();
6448                     try {
6449                         var notifier = this.notifier;
6450                         retries = notifier(errors);
6451                     }
6452                     catch (e) {
6453                         return _super.prototype.error.call(this, e);
6454                     }
6455                     retriesSubscription = innerSubscribe(retries, new SimpleInnerSubscriber(this));
6456                 }
6457                 else {
6458                     this.errors = undefined;
6459                     this.retriesSubscription = undefined;
6460                 }
6461                 this._unsubscribeAndRecycle();
6462                 this.errors = errors;
6463                 this.retries = retries;
6464                 this.retriesSubscription = retriesSubscription;
6465                 errors.next(err);
6466             }
6467         };
6468         RetryWhenSubscriber.prototype._unsubscribe = function () {
6469             var _a = this, errors = _a.errors, retriesSubscription = _a.retriesSubscription;
6470             if (errors) {
6471                 errors.unsubscribe();
6472                 this.errors = undefined;
6473             }
6474             if (retriesSubscription) {
6475                 retriesSubscription.unsubscribe();
6476                 this.retriesSubscription = undefined;
6477             }
6478             this.retries = undefined;
6479         };
6480         RetryWhenSubscriber.prototype.notifyNext = function () {
6481             var _unsubscribe = this._unsubscribe;
6482             this._unsubscribe = null;
6483             this._unsubscribeAndRecycle();
6484             this._unsubscribe = _unsubscribe;
6485             this.source.subscribe(this);
6486         };
6487         return RetryWhenSubscriber;
6488     }(SimpleOuterSubscriber));
6489
6490     function sample(notifier) {
6491         return function (source) { return source.lift(new SampleOperator(notifier)); };
6492     }
6493     var SampleOperator = (function () {
6494         function SampleOperator(notifier) {
6495             this.notifier = notifier;
6496         }
6497         SampleOperator.prototype.call = function (subscriber, source) {
6498             var sampleSubscriber = new SampleSubscriber(subscriber);
6499             var subscription = source.subscribe(sampleSubscriber);
6500             subscription.add(innerSubscribe(this.notifier, new SimpleInnerSubscriber(sampleSubscriber)));
6501             return subscription;
6502         };
6503         return SampleOperator;
6504     }());
6505     var SampleSubscriber = (function (_super) {
6506         __extends(SampleSubscriber, _super);
6507         function SampleSubscriber() {
6508             var _this = _super !== null && _super.apply(this, arguments) || this;
6509             _this.hasValue = false;
6510             return _this;
6511         }
6512         SampleSubscriber.prototype._next = function (value) {
6513             this.value = value;
6514             this.hasValue = true;
6515         };
6516         SampleSubscriber.prototype.notifyNext = function () {
6517             this.emitValue();
6518         };
6519         SampleSubscriber.prototype.notifyComplete = function () {
6520             this.emitValue();
6521         };
6522         SampleSubscriber.prototype.emitValue = function () {
6523             if (this.hasValue) {
6524                 this.hasValue = false;
6525                 this.destination.next(this.value);
6526             }
6527         };
6528         return SampleSubscriber;
6529     }(SimpleOuterSubscriber));
6530
6531     function sampleTime(period, scheduler) {
6532         if (scheduler === void 0) { scheduler = async; }
6533         return function (source) { return source.lift(new SampleTimeOperator(period, scheduler)); };
6534     }
6535     var SampleTimeOperator = (function () {
6536         function SampleTimeOperator(period, scheduler) {
6537             this.period = period;
6538             this.scheduler = scheduler;
6539         }
6540         SampleTimeOperator.prototype.call = function (subscriber, source) {
6541             return source.subscribe(new SampleTimeSubscriber(subscriber, this.period, this.scheduler));
6542         };
6543         return SampleTimeOperator;
6544     }());
6545     var SampleTimeSubscriber = (function (_super) {
6546         __extends(SampleTimeSubscriber, _super);
6547         function SampleTimeSubscriber(destination, period, scheduler) {
6548             var _this = _super.call(this, destination) || this;
6549             _this.period = period;
6550             _this.scheduler = scheduler;
6551             _this.hasValue = false;
6552             _this.add(scheduler.schedule(dispatchNotification, period, { subscriber: _this, period: period }));
6553             return _this;
6554         }
6555         SampleTimeSubscriber.prototype._next = function (value) {
6556             this.lastValue = value;
6557             this.hasValue = true;
6558         };
6559         SampleTimeSubscriber.prototype.notifyNext = function () {
6560             if (this.hasValue) {
6561                 this.hasValue = false;
6562                 this.destination.next(this.lastValue);
6563             }
6564         };
6565         return SampleTimeSubscriber;
6566     }(Subscriber));
6567     function dispatchNotification(state) {
6568         var subscriber = state.subscriber, period = state.period;
6569         subscriber.notifyNext();
6570         this.schedule(state, period);
6571     }
6572
6573     function sequenceEqual(compareTo, comparator) {
6574         return function (source) { return source.lift(new SequenceEqualOperator(compareTo, comparator)); };
6575     }
6576     var SequenceEqualOperator = (function () {
6577         function SequenceEqualOperator(compareTo, comparator) {
6578             this.compareTo = compareTo;
6579             this.comparator = comparator;
6580         }
6581         SequenceEqualOperator.prototype.call = function (subscriber, source) {
6582             return source.subscribe(new SequenceEqualSubscriber(subscriber, this.compareTo, this.comparator));
6583         };
6584         return SequenceEqualOperator;
6585     }());
6586     var SequenceEqualSubscriber = (function (_super) {
6587         __extends(SequenceEqualSubscriber, _super);
6588         function SequenceEqualSubscriber(destination, compareTo, comparator) {
6589             var _this = _super.call(this, destination) || this;
6590             _this.compareTo = compareTo;
6591             _this.comparator = comparator;
6592             _this._a = [];
6593             _this._b = [];
6594             _this._oneComplete = false;
6595             _this.destination.add(compareTo.subscribe(new SequenceEqualCompareToSubscriber(destination, _this)));
6596             return _this;
6597         }
6598         SequenceEqualSubscriber.prototype._next = function (value) {
6599             if (this._oneComplete && this._b.length === 0) {
6600                 this.emit(false);
6601             }
6602             else {
6603                 this._a.push(value);
6604                 this.checkValues();
6605             }
6606         };
6607         SequenceEqualSubscriber.prototype._complete = function () {
6608             if (this._oneComplete) {
6609                 this.emit(this._a.length === 0 && this._b.length === 0);
6610             }
6611             else {
6612                 this._oneComplete = true;
6613             }
6614             this.unsubscribe();
6615         };
6616         SequenceEqualSubscriber.prototype.checkValues = function () {
6617             var _c = this, _a = _c._a, _b = _c._b, comparator = _c.comparator;
6618             while (_a.length > 0 && _b.length > 0) {
6619                 var a = _a.shift();
6620                 var b = _b.shift();
6621                 var areEqual = false;
6622                 try {
6623                     areEqual = comparator ? comparator(a, b) : a === b;
6624                 }
6625                 catch (e) {
6626                     this.destination.error(e);
6627                 }
6628                 if (!areEqual) {
6629                     this.emit(false);
6630                 }
6631             }
6632         };
6633         SequenceEqualSubscriber.prototype.emit = function (value) {
6634             var destination = this.destination;
6635             destination.next(value);
6636             destination.complete();
6637         };
6638         SequenceEqualSubscriber.prototype.nextB = function (value) {
6639             if (this._oneComplete && this._a.length === 0) {
6640                 this.emit(false);
6641             }
6642             else {
6643                 this._b.push(value);
6644                 this.checkValues();
6645             }
6646         };
6647         SequenceEqualSubscriber.prototype.completeB = function () {
6648             if (this._oneComplete) {
6649                 this.emit(this._a.length === 0 && this._b.length === 0);
6650             }
6651             else {
6652                 this._oneComplete = true;
6653             }
6654         };
6655         return SequenceEqualSubscriber;
6656     }(Subscriber));
6657     var SequenceEqualCompareToSubscriber = (function (_super) {
6658         __extends(SequenceEqualCompareToSubscriber, _super);
6659         function SequenceEqualCompareToSubscriber(destination, parent) {
6660             var _this = _super.call(this, destination) || this;
6661             _this.parent = parent;
6662             return _this;
6663         }
6664         SequenceEqualCompareToSubscriber.prototype._next = function (value) {
6665             this.parent.nextB(value);
6666         };
6667         SequenceEqualCompareToSubscriber.prototype._error = function (err) {
6668             this.parent.error(err);
6669             this.unsubscribe();
6670         };
6671         SequenceEqualCompareToSubscriber.prototype._complete = function () {
6672             this.parent.completeB();
6673             this.unsubscribe();
6674         };
6675         return SequenceEqualCompareToSubscriber;
6676     }(Subscriber));
6677
6678     function shareSubjectFactory() {
6679         return new Subject();
6680     }
6681     function share() {
6682         return function (source) { return refCount()(multicast(shareSubjectFactory)(source)); };
6683     }
6684
6685     function shareReplay(configOrBufferSize, windowTime, scheduler) {
6686         var config;
6687         if (configOrBufferSize && typeof configOrBufferSize === 'object') {
6688             config = configOrBufferSize;
6689         }
6690         else {
6691             config = {
6692                 bufferSize: configOrBufferSize,
6693                 windowTime: windowTime,
6694                 refCount: false,
6695                 scheduler: scheduler
6696             };
6697         }
6698         return function (source) { return source.lift(shareReplayOperator(config)); };
6699     }
6700     function shareReplayOperator(_a) {
6701         var _b = _a.bufferSize, bufferSize = _b === void 0 ? Number.POSITIVE_INFINITY : _b, _c = _a.windowTime, windowTime = _c === void 0 ? Number.POSITIVE_INFINITY : _c, useRefCount = _a.refCount, scheduler = _a.scheduler;
6702         var subject;
6703         var refCount = 0;
6704         var subscription;
6705         var hasError = false;
6706         var isComplete = false;
6707         return function shareReplayOperation(source) {
6708             refCount++;
6709             var innerSub;
6710             if (!subject || hasError) {
6711                 hasError = false;
6712                 subject = new ReplaySubject(bufferSize, windowTime, scheduler);
6713                 innerSub = subject.subscribe(this);
6714                 subscription = source.subscribe({
6715                     next: function (value) { subject.next(value); },
6716                     error: function (err) {
6717                         hasError = true;
6718                         subject.error(err);
6719                     },
6720                     complete: function () {
6721                         isComplete = true;
6722                         subscription = undefined;
6723                         subject.complete();
6724                     },
6725                 });
6726             }
6727             else {
6728                 innerSub = subject.subscribe(this);
6729             }
6730             this.add(function () {
6731                 refCount--;
6732                 innerSub.unsubscribe();
6733                 if (subscription && !isComplete && useRefCount && refCount === 0) {
6734                     subscription.unsubscribe();
6735                     subscription = undefined;
6736                     subject = undefined;
6737                 }
6738             });
6739         };
6740     }
6741
6742     function single(predicate) {
6743         return function (source) { return source.lift(new SingleOperator(predicate, source)); };
6744     }
6745     var SingleOperator = (function () {
6746         function SingleOperator(predicate, source) {
6747             this.predicate = predicate;
6748             this.source = source;
6749         }
6750         SingleOperator.prototype.call = function (subscriber, source) {
6751             return source.subscribe(new SingleSubscriber(subscriber, this.predicate, this.source));
6752         };
6753         return SingleOperator;
6754     }());
6755     var SingleSubscriber = (function (_super) {
6756         __extends(SingleSubscriber, _super);
6757         function SingleSubscriber(destination, predicate, source) {
6758             var _this = _super.call(this, destination) || this;
6759             _this.predicate = predicate;
6760             _this.source = source;
6761             _this.seenValue = false;
6762             _this.index = 0;
6763             return _this;
6764         }
6765         SingleSubscriber.prototype.applySingleValue = function (value) {
6766             if (this.seenValue) {
6767                 this.destination.error('Sequence contains more than one element');
6768             }
6769             else {
6770                 this.seenValue = true;
6771                 this.singleValue = value;
6772             }
6773         };
6774         SingleSubscriber.prototype._next = function (value) {
6775             var index = this.index++;
6776             if (this.predicate) {
6777                 this.tryNext(value, index);
6778             }
6779             else {
6780                 this.applySingleValue(value);
6781             }
6782         };
6783         SingleSubscriber.prototype.tryNext = function (value, index) {
6784             try {
6785                 if (this.predicate(value, index, this.source)) {
6786                     this.applySingleValue(value);
6787                 }
6788             }
6789             catch (err) {
6790                 this.destination.error(err);
6791             }
6792         };
6793         SingleSubscriber.prototype._complete = function () {
6794             var destination = this.destination;
6795             if (this.index > 0) {
6796                 destination.next(this.seenValue ? this.singleValue : undefined);
6797                 destination.complete();
6798             }
6799             else {
6800                 destination.error(new EmptyError);
6801             }
6802         };
6803         return SingleSubscriber;
6804     }(Subscriber));
6805
6806     function skip(count) {
6807         return function (source) { return source.lift(new SkipOperator(count)); };
6808     }
6809     var SkipOperator = (function () {
6810         function SkipOperator(total) {
6811             this.total = total;
6812         }
6813         SkipOperator.prototype.call = function (subscriber, source) {
6814             return source.subscribe(new SkipSubscriber(subscriber, this.total));
6815         };
6816         return SkipOperator;
6817     }());
6818     var SkipSubscriber = (function (_super) {
6819         __extends(SkipSubscriber, _super);
6820         function SkipSubscriber(destination, total) {
6821             var _this = _super.call(this, destination) || this;
6822             _this.total = total;
6823             _this.count = 0;
6824             return _this;
6825         }
6826         SkipSubscriber.prototype._next = function (x) {
6827             if (++this.count > this.total) {
6828                 this.destination.next(x);
6829             }
6830         };
6831         return SkipSubscriber;
6832     }(Subscriber));
6833
6834     function skipLast(count) {
6835         return function (source) { return source.lift(new SkipLastOperator(count)); };
6836     }
6837     var SkipLastOperator = (function () {
6838         function SkipLastOperator(_skipCount) {
6839             this._skipCount = _skipCount;
6840             if (this._skipCount < 0) {
6841                 throw new ArgumentOutOfRangeError;
6842             }
6843         }
6844         SkipLastOperator.prototype.call = function (subscriber, source) {
6845             if (this._skipCount === 0) {
6846                 return source.subscribe(new Subscriber(subscriber));
6847             }
6848             else {
6849                 return source.subscribe(new SkipLastSubscriber(subscriber, this._skipCount));
6850             }
6851         };
6852         return SkipLastOperator;
6853     }());
6854     var SkipLastSubscriber = (function (_super) {
6855         __extends(SkipLastSubscriber, _super);
6856         function SkipLastSubscriber(destination, _skipCount) {
6857             var _this = _super.call(this, destination) || this;
6858             _this._skipCount = _skipCount;
6859             _this._count = 0;
6860             _this._ring = new Array(_skipCount);
6861             return _this;
6862         }
6863         SkipLastSubscriber.prototype._next = function (value) {
6864             var skipCount = this._skipCount;
6865             var count = this._count++;
6866             if (count < skipCount) {
6867                 this._ring[count] = value;
6868             }
6869             else {
6870                 var currentIndex = count % skipCount;
6871                 var ring = this._ring;
6872                 var oldValue = ring[currentIndex];
6873                 ring[currentIndex] = value;
6874                 this.destination.next(oldValue);
6875             }
6876         };
6877         return SkipLastSubscriber;
6878     }(Subscriber));
6879
6880     function skipUntil(notifier) {
6881         return function (source) { return source.lift(new SkipUntilOperator(notifier)); };
6882     }
6883     var SkipUntilOperator = (function () {
6884         function SkipUntilOperator(notifier) {
6885             this.notifier = notifier;
6886         }
6887         SkipUntilOperator.prototype.call = function (destination, source) {
6888             return source.subscribe(new SkipUntilSubscriber(destination, this.notifier));
6889         };
6890         return SkipUntilOperator;
6891     }());
6892     var SkipUntilSubscriber = (function (_super) {
6893         __extends(SkipUntilSubscriber, _super);
6894         function SkipUntilSubscriber(destination, notifier) {
6895             var _this = _super.call(this, destination) || this;
6896             _this.hasValue = false;
6897             var innerSubscriber = new SimpleInnerSubscriber(_this);
6898             _this.add(innerSubscriber);
6899             _this.innerSubscription = innerSubscriber;
6900             var innerSubscription = innerSubscribe(notifier, innerSubscriber);
6901             if (innerSubscription !== innerSubscriber) {
6902                 _this.add(innerSubscription);
6903                 _this.innerSubscription = innerSubscription;
6904             }
6905             return _this;
6906         }
6907         SkipUntilSubscriber.prototype._next = function (value) {
6908             if (this.hasValue) {
6909                 _super.prototype._next.call(this, value);
6910             }
6911         };
6912         SkipUntilSubscriber.prototype.notifyNext = function () {
6913             this.hasValue = true;
6914             if (this.innerSubscription) {
6915                 this.innerSubscription.unsubscribe();
6916             }
6917         };
6918         SkipUntilSubscriber.prototype.notifyComplete = function () {
6919         };
6920         return SkipUntilSubscriber;
6921     }(SimpleOuterSubscriber));
6922
6923     function skipWhile(predicate) {
6924         return function (source) { return source.lift(new SkipWhileOperator(predicate)); };
6925     }
6926     var SkipWhileOperator = (function () {
6927         function SkipWhileOperator(predicate) {
6928             this.predicate = predicate;
6929         }
6930         SkipWhileOperator.prototype.call = function (subscriber, source) {
6931             return source.subscribe(new SkipWhileSubscriber(subscriber, this.predicate));
6932         };
6933         return SkipWhileOperator;
6934     }());
6935     var SkipWhileSubscriber = (function (_super) {
6936         __extends(SkipWhileSubscriber, _super);
6937         function SkipWhileSubscriber(destination, predicate) {
6938             var _this = _super.call(this, destination) || this;
6939             _this.predicate = predicate;
6940             _this.skipping = true;
6941             _this.index = 0;
6942             return _this;
6943         }
6944         SkipWhileSubscriber.prototype._next = function (value) {
6945             var destination = this.destination;
6946             if (this.skipping) {
6947                 this.tryCallPredicate(value);
6948             }
6949             if (!this.skipping) {
6950                 destination.next(value);
6951             }
6952         };
6953         SkipWhileSubscriber.prototype.tryCallPredicate = function (value) {
6954             try {
6955                 var result = this.predicate(value, this.index++);
6956                 this.skipping = Boolean(result);
6957             }
6958             catch (err) {
6959                 this.destination.error(err);
6960             }
6961         };
6962         return SkipWhileSubscriber;
6963     }(Subscriber));
6964
6965     function startWith() {
6966         var array = [];
6967         for (var _i = 0; _i < arguments.length; _i++) {
6968             array[_i] = arguments[_i];
6969         }
6970         var scheduler = array[array.length - 1];
6971         if (isScheduler(scheduler)) {
6972             array.pop();
6973             return function (source) { return concat(array, source, scheduler); };
6974         }
6975         else {
6976             return function (source) { return concat(array, source); };
6977         }
6978     }
6979
6980     var SubscribeOnObservable = (function (_super) {
6981         __extends(SubscribeOnObservable, _super);
6982         function SubscribeOnObservable(source, delayTime, scheduler) {
6983             if (delayTime === void 0) { delayTime = 0; }
6984             if (scheduler === void 0) { scheduler = asap; }
6985             var _this = _super.call(this) || this;
6986             _this.source = source;
6987             _this.delayTime = delayTime;
6988             _this.scheduler = scheduler;
6989             if (!isNumeric(delayTime) || delayTime < 0) {
6990                 _this.delayTime = 0;
6991             }
6992             if (!scheduler || typeof scheduler.schedule !== 'function') {
6993                 _this.scheduler = asap;
6994             }
6995             return _this;
6996         }
6997         SubscribeOnObservable.create = function (source, delay, scheduler) {
6998             if (delay === void 0) { delay = 0; }
6999             if (scheduler === void 0) { scheduler = asap; }
7000             return new SubscribeOnObservable(source, delay, scheduler);
7001         };
7002         SubscribeOnObservable.dispatch = function (arg) {
7003             var source = arg.source, subscriber = arg.subscriber;
7004             return this.add(source.subscribe(subscriber));
7005         };
7006         SubscribeOnObservable.prototype._subscribe = function (subscriber) {
7007             var delay = this.delayTime;
7008             var source = this.source;
7009             var scheduler = this.scheduler;
7010             return scheduler.schedule(SubscribeOnObservable.dispatch, delay, {
7011                 source: source, subscriber: subscriber
7012             });
7013         };
7014         return SubscribeOnObservable;
7015     }(Observable));
7016
7017     function subscribeOn(scheduler, delay) {
7018         if (delay === void 0) { delay = 0; }
7019         return function subscribeOnOperatorFunction(source) {
7020             return source.lift(new SubscribeOnOperator(scheduler, delay));
7021         };
7022     }
7023     var SubscribeOnOperator = (function () {
7024         function SubscribeOnOperator(scheduler, delay) {
7025             this.scheduler = scheduler;
7026             this.delay = delay;
7027         }
7028         SubscribeOnOperator.prototype.call = function (subscriber, source) {
7029             return new SubscribeOnObservable(source, this.delay, this.scheduler).subscribe(subscriber);
7030         };
7031         return SubscribeOnOperator;
7032     }());
7033
7034     function switchMap(project, resultSelector) {
7035         if (typeof resultSelector === 'function') {
7036             return function (source) { return source.pipe(switchMap(function (a, i) { return from(project(a, i)).pipe(map(function (b, ii) { return resultSelector(a, b, i, ii); })); })); };
7037         }
7038         return function (source) { return source.lift(new SwitchMapOperator(project)); };
7039     }
7040     var SwitchMapOperator = (function () {
7041         function SwitchMapOperator(project) {
7042             this.project = project;
7043         }
7044         SwitchMapOperator.prototype.call = function (subscriber, source) {
7045             return source.subscribe(new SwitchMapSubscriber(subscriber, this.project));
7046         };
7047         return SwitchMapOperator;
7048     }());
7049     var SwitchMapSubscriber = (function (_super) {
7050         __extends(SwitchMapSubscriber, _super);
7051         function SwitchMapSubscriber(destination, project) {
7052             var _this = _super.call(this, destination) || this;
7053             _this.project = project;
7054             _this.index = 0;
7055             return _this;
7056         }
7057         SwitchMapSubscriber.prototype._next = function (value) {
7058             var result;
7059             var index = this.index++;
7060             try {
7061                 result = this.project(value, index);
7062             }
7063             catch (error) {
7064                 this.destination.error(error);
7065                 return;
7066             }
7067             this._innerSub(result);
7068         };
7069         SwitchMapSubscriber.prototype._innerSub = function (result) {
7070             var innerSubscription = this.innerSubscription;
7071             if (innerSubscription) {
7072                 innerSubscription.unsubscribe();
7073             }
7074             var innerSubscriber = new SimpleInnerSubscriber(this);
7075             var destination = this.destination;
7076             destination.add(innerSubscriber);
7077             this.innerSubscription = innerSubscribe(result, innerSubscriber);
7078             if (this.innerSubscription !== innerSubscriber) {
7079                 destination.add(this.innerSubscription);
7080             }
7081         };
7082         SwitchMapSubscriber.prototype._complete = function () {
7083             var innerSubscription = this.innerSubscription;
7084             if (!innerSubscription || innerSubscription.closed) {
7085                 _super.prototype._complete.call(this);
7086             }
7087             this.unsubscribe();
7088         };
7089         SwitchMapSubscriber.prototype._unsubscribe = function () {
7090             this.innerSubscription = undefined;
7091         };
7092         SwitchMapSubscriber.prototype.notifyComplete = function () {
7093             this.innerSubscription = undefined;
7094             if (this.isStopped) {
7095                 _super.prototype._complete.call(this);
7096             }
7097         };
7098         SwitchMapSubscriber.prototype.notifyNext = function (innerValue) {
7099             this.destination.next(innerValue);
7100         };
7101         return SwitchMapSubscriber;
7102     }(SimpleOuterSubscriber));
7103
7104     function switchAll() {
7105         return switchMap(identity);
7106     }
7107
7108     function switchMapTo(innerObservable, resultSelector) {
7109         return resultSelector ? switchMap(function () { return innerObservable; }, resultSelector) : switchMap(function () { return innerObservable; });
7110     }
7111
7112     function takeUntil(notifier) {
7113         return function (source) { return source.lift(new TakeUntilOperator(notifier)); };
7114     }
7115     var TakeUntilOperator = (function () {
7116         function TakeUntilOperator(notifier) {
7117             this.notifier = notifier;
7118         }
7119         TakeUntilOperator.prototype.call = function (subscriber, source) {
7120             var takeUntilSubscriber = new TakeUntilSubscriber(subscriber);
7121             var notifierSubscription = innerSubscribe(this.notifier, new SimpleInnerSubscriber(takeUntilSubscriber));
7122             if (notifierSubscription && !takeUntilSubscriber.seenValue) {
7123                 takeUntilSubscriber.add(notifierSubscription);
7124                 return source.subscribe(takeUntilSubscriber);
7125             }
7126             return takeUntilSubscriber;
7127         };
7128         return TakeUntilOperator;
7129     }());
7130     var TakeUntilSubscriber = (function (_super) {
7131         __extends(TakeUntilSubscriber, _super);
7132         function TakeUntilSubscriber(destination) {
7133             var _this = _super.call(this, destination) || this;
7134             _this.seenValue = false;
7135             return _this;
7136         }
7137         TakeUntilSubscriber.prototype.notifyNext = function () {
7138             this.seenValue = true;
7139             this.complete();
7140         };
7141         TakeUntilSubscriber.prototype.notifyComplete = function () {
7142         };
7143         return TakeUntilSubscriber;
7144     }(SimpleOuterSubscriber));
7145
7146     function takeWhile(predicate, inclusive) {
7147         if (inclusive === void 0) { inclusive = false; }
7148         return function (source) {
7149             return source.lift(new TakeWhileOperator(predicate, inclusive));
7150         };
7151     }
7152     var TakeWhileOperator = (function () {
7153         function TakeWhileOperator(predicate, inclusive) {
7154             this.predicate = predicate;
7155             this.inclusive = inclusive;
7156         }
7157         TakeWhileOperator.prototype.call = function (subscriber, source) {
7158             return source.subscribe(new TakeWhileSubscriber(subscriber, this.predicate, this.inclusive));
7159         };
7160         return TakeWhileOperator;
7161     }());
7162     var TakeWhileSubscriber = (function (_super) {
7163         __extends(TakeWhileSubscriber, _super);
7164         function TakeWhileSubscriber(destination, predicate, inclusive) {
7165             var _this = _super.call(this, destination) || this;
7166             _this.predicate = predicate;
7167             _this.inclusive = inclusive;
7168             _this.index = 0;
7169             return _this;
7170         }
7171         TakeWhileSubscriber.prototype._next = function (value) {
7172             var destination = this.destination;
7173             var result;
7174             try {
7175                 result = this.predicate(value, this.index++);
7176             }
7177             catch (err) {
7178                 destination.error(err);
7179                 return;
7180             }
7181             this.nextOrComplete(value, result);
7182         };
7183         TakeWhileSubscriber.prototype.nextOrComplete = function (value, predicateResult) {
7184             var destination = this.destination;
7185             if (Boolean(predicateResult)) {
7186                 destination.next(value);
7187             }
7188             else {
7189                 if (this.inclusive) {
7190                     destination.next(value);
7191                 }
7192                 destination.complete();
7193             }
7194         };
7195         return TakeWhileSubscriber;
7196     }(Subscriber));
7197
7198     function tap(nextOrObserver, error, complete) {
7199         return function tapOperatorFunction(source) {
7200             return source.lift(new DoOperator(nextOrObserver, error, complete));
7201         };
7202     }
7203     var DoOperator = (function () {
7204         function DoOperator(nextOrObserver, error, complete) {
7205             this.nextOrObserver = nextOrObserver;
7206             this.error = error;
7207             this.complete = complete;
7208         }
7209         DoOperator.prototype.call = function (subscriber, source) {
7210             return source.subscribe(new TapSubscriber(subscriber, this.nextOrObserver, this.error, this.complete));
7211         };
7212         return DoOperator;
7213     }());
7214     var TapSubscriber = (function (_super) {
7215         __extends(TapSubscriber, _super);
7216         function TapSubscriber(destination, observerOrNext, error, complete) {
7217             var _this = _super.call(this, destination) || this;
7218             _this._tapNext = noop;
7219             _this._tapError = noop;
7220             _this._tapComplete = noop;
7221             _this._tapError = error || noop;
7222             _this._tapComplete = complete || noop;
7223             if (isFunction(observerOrNext)) {
7224                 _this._context = _this;
7225                 _this._tapNext = observerOrNext;
7226             }
7227             else if (observerOrNext) {
7228                 _this._context = observerOrNext;
7229                 _this._tapNext = observerOrNext.next || noop;
7230                 _this._tapError = observerOrNext.error || noop;
7231                 _this._tapComplete = observerOrNext.complete || noop;
7232             }
7233             return _this;
7234         }
7235         TapSubscriber.prototype._next = function (value) {
7236             try {
7237                 this._tapNext.call(this._context, value);
7238             }
7239             catch (err) {
7240                 this.destination.error(err);
7241                 return;
7242             }
7243             this.destination.next(value);
7244         };
7245         TapSubscriber.prototype._error = function (err) {
7246             try {
7247                 this._tapError.call(this._context, err);
7248             }
7249             catch (err) {
7250                 this.destination.error(err);
7251                 return;
7252             }
7253             this.destination.error(err);
7254         };
7255         TapSubscriber.prototype._complete = function () {
7256             try {
7257                 this._tapComplete.call(this._context);
7258             }
7259             catch (err) {
7260                 this.destination.error(err);
7261                 return;
7262             }
7263             return this.destination.complete();
7264         };
7265         return TapSubscriber;
7266     }(Subscriber));
7267
7268     var defaultThrottleConfig = {
7269         leading: true,
7270         trailing: false
7271     };
7272     function throttle(durationSelector, config) {
7273         if (config === void 0) { config = defaultThrottleConfig; }
7274         return function (source) { return source.lift(new ThrottleOperator(durationSelector, !!config.leading, !!config.trailing)); };
7275     }
7276     var ThrottleOperator = (function () {
7277         function ThrottleOperator(durationSelector, leading, trailing) {
7278             this.durationSelector = durationSelector;
7279             this.leading = leading;
7280             this.trailing = trailing;
7281         }
7282         ThrottleOperator.prototype.call = function (subscriber, source) {
7283             return source.subscribe(new ThrottleSubscriber(subscriber, this.durationSelector, this.leading, this.trailing));
7284         };
7285         return ThrottleOperator;
7286     }());
7287     var ThrottleSubscriber = (function (_super) {
7288         __extends(ThrottleSubscriber, _super);
7289         function ThrottleSubscriber(destination, durationSelector, _leading, _trailing) {
7290             var _this = _super.call(this, destination) || this;
7291             _this.destination = destination;
7292             _this.durationSelector = durationSelector;
7293             _this._leading = _leading;
7294             _this._trailing = _trailing;
7295             _this._hasValue = false;
7296             return _this;
7297         }
7298         ThrottleSubscriber.prototype._next = function (value) {
7299             this._hasValue = true;
7300             this._sendValue = value;
7301             if (!this._throttled) {
7302                 if (this._leading) {
7303                     this.send();
7304                 }
7305                 else {
7306                     this.throttle(value);
7307                 }
7308             }
7309         };
7310         ThrottleSubscriber.prototype.send = function () {
7311             var _a = this, _hasValue = _a._hasValue, _sendValue = _a._sendValue;
7312             if (_hasValue) {
7313                 this.destination.next(_sendValue);
7314                 this.throttle(_sendValue);
7315             }
7316             this._hasValue = false;
7317             this._sendValue = undefined;
7318         };
7319         ThrottleSubscriber.prototype.throttle = function (value) {
7320             var duration = this.tryDurationSelector(value);
7321             if (!!duration) {
7322                 this.add(this._throttled = innerSubscribe(duration, new SimpleInnerSubscriber(this)));
7323             }
7324         };
7325         ThrottleSubscriber.prototype.tryDurationSelector = function (value) {
7326             try {
7327                 return this.durationSelector(value);
7328             }
7329             catch (err) {
7330                 this.destination.error(err);
7331                 return null;
7332             }
7333         };
7334         ThrottleSubscriber.prototype.throttlingDone = function () {
7335             var _a = this, _throttled = _a._throttled, _trailing = _a._trailing;
7336             if (_throttled) {
7337                 _throttled.unsubscribe();
7338             }
7339             this._throttled = undefined;
7340             if (_trailing) {
7341                 this.send();
7342             }
7343         };
7344         ThrottleSubscriber.prototype.notifyNext = function () {
7345             this.throttlingDone();
7346         };
7347         ThrottleSubscriber.prototype.notifyComplete = function () {
7348             this.throttlingDone();
7349         };
7350         return ThrottleSubscriber;
7351     }(SimpleOuterSubscriber));
7352
7353     function throttleTime(duration, scheduler, config) {
7354         if (scheduler === void 0) { scheduler = async; }
7355         if (config === void 0) { config = defaultThrottleConfig; }
7356         return function (source) { return source.lift(new ThrottleTimeOperator(duration, scheduler, config.leading, config.trailing)); };
7357     }
7358     var ThrottleTimeOperator = (function () {
7359         function ThrottleTimeOperator(duration, scheduler, leading, trailing) {
7360             this.duration = duration;
7361             this.scheduler = scheduler;
7362             this.leading = leading;
7363             this.trailing = trailing;
7364         }
7365         ThrottleTimeOperator.prototype.call = function (subscriber, source) {
7366             return source.subscribe(new ThrottleTimeSubscriber(subscriber, this.duration, this.scheduler, this.leading, this.trailing));
7367         };
7368         return ThrottleTimeOperator;
7369     }());
7370     var ThrottleTimeSubscriber = (function (_super) {
7371         __extends(ThrottleTimeSubscriber, _super);
7372         function ThrottleTimeSubscriber(destination, duration, scheduler, leading, trailing) {
7373             var _this = _super.call(this, destination) || this;
7374             _this.duration = duration;
7375             _this.scheduler = scheduler;
7376             _this.leading = leading;
7377             _this.trailing = trailing;
7378             _this._hasTrailingValue = false;
7379             _this._trailingValue = null;
7380             return _this;
7381         }
7382         ThrottleTimeSubscriber.prototype._next = function (value) {
7383             if (this.throttled) {
7384                 if (this.trailing) {
7385                     this._trailingValue = value;
7386                     this._hasTrailingValue = true;
7387                 }
7388             }
7389             else {
7390                 this.add(this.throttled = this.scheduler.schedule(dispatchNext$3, this.duration, { subscriber: this }));
7391                 if (this.leading) {
7392                     this.destination.next(value);
7393                 }
7394                 else if (this.trailing) {
7395                     this._trailingValue = value;
7396                     this._hasTrailingValue = true;
7397                 }
7398             }
7399         };
7400         ThrottleTimeSubscriber.prototype._complete = function () {
7401             if (this._hasTrailingValue) {
7402                 this.destination.next(this._trailingValue);
7403                 this.destination.complete();
7404             }
7405             else {
7406                 this.destination.complete();
7407             }
7408         };
7409         ThrottleTimeSubscriber.prototype.clearThrottle = function () {
7410             var throttled = this.throttled;
7411             if (throttled) {
7412                 if (this.trailing && this._hasTrailingValue) {
7413                     this.destination.next(this._trailingValue);
7414                     this._trailingValue = null;
7415                     this._hasTrailingValue = false;
7416                 }
7417                 throttled.unsubscribe();
7418                 this.remove(throttled);
7419                 this.throttled = null;
7420             }
7421         };
7422         return ThrottleTimeSubscriber;
7423     }(Subscriber));
7424     function dispatchNext$3(arg) {
7425         var subscriber = arg.subscriber;
7426         subscriber.clearThrottle();
7427     }
7428
7429     function timeInterval(scheduler) {
7430         if (scheduler === void 0) { scheduler = async; }
7431         return function (source) { return defer(function () {
7432             return source.pipe(scan(function (_a, value) {
7433                 var current = _a.current;
7434                 return ({ value: value, current: scheduler.now(), last: current });
7435             }, { current: scheduler.now(), value: undefined, last: undefined }), map(function (_a) {
7436                 var current = _a.current, last = _a.last, value = _a.value;
7437                 return new TimeInterval(value, current - last);
7438             }));
7439         }); };
7440     }
7441     var TimeInterval = (function () {
7442         function TimeInterval(value, interval) {
7443             this.value = value;
7444             this.interval = interval;
7445         }
7446         return TimeInterval;
7447     }());
7448
7449     function timeoutWith(due, withObservable, scheduler) {
7450         if (scheduler === void 0) { scheduler = async; }
7451         return function (source) {
7452             var absoluteTimeout = isDate(due);
7453             var waitFor = absoluteTimeout ? (+due - scheduler.now()) : Math.abs(due);
7454             return source.lift(new TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler));
7455         };
7456     }
7457     var TimeoutWithOperator = (function () {
7458         function TimeoutWithOperator(waitFor, absoluteTimeout, withObservable, scheduler) {
7459             this.waitFor = waitFor;
7460             this.absoluteTimeout = absoluteTimeout;
7461             this.withObservable = withObservable;
7462             this.scheduler = scheduler;
7463         }
7464         TimeoutWithOperator.prototype.call = function (subscriber, source) {
7465             return source.subscribe(new TimeoutWithSubscriber(subscriber, this.absoluteTimeout, this.waitFor, this.withObservable, this.scheduler));
7466         };
7467         return TimeoutWithOperator;
7468     }());
7469     var TimeoutWithSubscriber = (function (_super) {
7470         __extends(TimeoutWithSubscriber, _super);
7471         function TimeoutWithSubscriber(destination, absoluteTimeout, waitFor, withObservable, scheduler) {
7472             var _this = _super.call(this, destination) || this;
7473             _this.absoluteTimeout = absoluteTimeout;
7474             _this.waitFor = waitFor;
7475             _this.withObservable = withObservable;
7476             _this.scheduler = scheduler;
7477             _this.scheduleTimeout();
7478             return _this;
7479         }
7480         TimeoutWithSubscriber.dispatchTimeout = function (subscriber) {
7481             var withObservable = subscriber.withObservable;
7482             subscriber._unsubscribeAndRecycle();
7483             subscriber.add(innerSubscribe(withObservable, new SimpleInnerSubscriber(subscriber)));
7484         };
7485         TimeoutWithSubscriber.prototype.scheduleTimeout = function () {
7486             var action = this.action;
7487             if (action) {
7488                 this.action = action.schedule(this, this.waitFor);
7489             }
7490             else {
7491                 this.add(this.action = this.scheduler.schedule(TimeoutWithSubscriber.dispatchTimeout, this.waitFor, this));
7492             }
7493         };
7494         TimeoutWithSubscriber.prototype._next = function (value) {
7495             if (!this.absoluteTimeout) {
7496                 this.scheduleTimeout();
7497             }
7498             _super.prototype._next.call(this, value);
7499         };
7500         TimeoutWithSubscriber.prototype._unsubscribe = function () {
7501             this.action = undefined;
7502             this.scheduler = null;
7503             this.withObservable = null;
7504         };
7505         return TimeoutWithSubscriber;
7506     }(SimpleOuterSubscriber));
7507
7508     function timeout(due, scheduler) {
7509         if (scheduler === void 0) { scheduler = async; }
7510         return timeoutWith(due, throwError(new TimeoutError()), scheduler);
7511     }
7512
7513     function timestamp(scheduler) {
7514         if (scheduler === void 0) { scheduler = async; }
7515         return map(function (value) { return new Timestamp(value, scheduler.now()); });
7516     }
7517     var Timestamp = (function () {
7518         function Timestamp(value, timestamp) {
7519             this.value = value;
7520             this.timestamp = timestamp;
7521         }
7522         return Timestamp;
7523     }());
7524
7525     function toArrayReducer(arr, item, index) {
7526         if (index === 0) {
7527             return [item];
7528         }
7529         arr.push(item);
7530         return arr;
7531     }
7532     function toArray() {
7533         return reduce(toArrayReducer, []);
7534     }
7535
7536     function window$1(windowBoundaries) {
7537         return function windowOperatorFunction(source) {
7538             return source.lift(new WindowOperator(windowBoundaries));
7539         };
7540     }
7541     var WindowOperator = (function () {
7542         function WindowOperator(windowBoundaries) {
7543             this.windowBoundaries = windowBoundaries;
7544         }
7545         WindowOperator.prototype.call = function (subscriber, source) {
7546             var windowSubscriber = new WindowSubscriber(subscriber);
7547             var sourceSubscription = source.subscribe(windowSubscriber);
7548             if (!sourceSubscription.closed) {
7549                 windowSubscriber.add(innerSubscribe(this.windowBoundaries, new SimpleInnerSubscriber(windowSubscriber)));
7550             }
7551             return sourceSubscription;
7552         };
7553         return WindowOperator;
7554     }());
7555     var WindowSubscriber = (function (_super) {
7556         __extends(WindowSubscriber, _super);
7557         function WindowSubscriber(destination) {
7558             var _this = _super.call(this, destination) || this;
7559             _this.window = new Subject();
7560             destination.next(_this.window);
7561             return _this;
7562         }
7563         WindowSubscriber.prototype.notifyNext = function () {
7564             this.openWindow();
7565         };
7566         WindowSubscriber.prototype.notifyError = function (error) {
7567             this._error(error);
7568         };
7569         WindowSubscriber.prototype.notifyComplete = function () {
7570             this._complete();
7571         };
7572         WindowSubscriber.prototype._next = function (value) {
7573             this.window.next(value);
7574         };
7575         WindowSubscriber.prototype._error = function (err) {
7576             this.window.error(err);
7577             this.destination.error(err);
7578         };
7579         WindowSubscriber.prototype._complete = function () {
7580             this.window.complete();
7581             this.destination.complete();
7582         };
7583         WindowSubscriber.prototype._unsubscribe = function () {
7584             this.window = null;
7585         };
7586         WindowSubscriber.prototype.openWindow = function () {
7587             var prevWindow = this.window;
7588             if (prevWindow) {
7589                 prevWindow.complete();
7590             }
7591             var destination = this.destination;
7592             var newWindow = this.window = new Subject();
7593             destination.next(newWindow);
7594         };
7595         return WindowSubscriber;
7596     }(SimpleOuterSubscriber));
7597
7598     function windowCount(windowSize, startWindowEvery) {
7599         if (startWindowEvery === void 0) { startWindowEvery = 0; }
7600         return function windowCountOperatorFunction(source) {
7601             return source.lift(new WindowCountOperator(windowSize, startWindowEvery));
7602         };
7603     }
7604     var WindowCountOperator = (function () {
7605         function WindowCountOperator(windowSize, startWindowEvery) {
7606             this.windowSize = windowSize;
7607             this.startWindowEvery = startWindowEvery;
7608         }
7609         WindowCountOperator.prototype.call = function (subscriber, source) {
7610             return source.subscribe(new WindowCountSubscriber(subscriber, this.windowSize, this.startWindowEvery));
7611         };
7612         return WindowCountOperator;
7613     }());
7614     var WindowCountSubscriber = (function (_super) {
7615         __extends(WindowCountSubscriber, _super);
7616         function WindowCountSubscriber(destination, windowSize, startWindowEvery) {
7617             var _this = _super.call(this, destination) || this;
7618             _this.destination = destination;
7619             _this.windowSize = windowSize;
7620             _this.startWindowEvery = startWindowEvery;
7621             _this.windows = [new Subject()];
7622             _this.count = 0;
7623             destination.next(_this.windows[0]);
7624             return _this;
7625         }
7626         WindowCountSubscriber.prototype._next = function (value) {
7627             var startWindowEvery = (this.startWindowEvery > 0) ? this.startWindowEvery : this.windowSize;
7628             var destination = this.destination;
7629             var windowSize = this.windowSize;
7630             var windows = this.windows;
7631             var len = windows.length;
7632             for (var i = 0; i < len && !this.closed; i++) {
7633                 windows[i].next(value);
7634             }
7635             var c = this.count - windowSize + 1;
7636             if (c >= 0 && c % startWindowEvery === 0 && !this.closed) {
7637                 windows.shift().complete();
7638             }
7639             if (++this.count % startWindowEvery === 0 && !this.closed) {
7640                 var window_1 = new Subject();
7641                 windows.push(window_1);
7642                 destination.next(window_1);
7643             }
7644         };
7645         WindowCountSubscriber.prototype._error = function (err) {
7646             var windows = this.windows;
7647             if (windows) {
7648                 while (windows.length > 0 && !this.closed) {
7649                     windows.shift().error(err);
7650                 }
7651             }
7652             this.destination.error(err);
7653         };
7654         WindowCountSubscriber.prototype._complete = function () {
7655             var windows = this.windows;
7656             if (windows) {
7657                 while (windows.length > 0 && !this.closed) {
7658                     windows.shift().complete();
7659                 }
7660             }
7661             this.destination.complete();
7662         };
7663         WindowCountSubscriber.prototype._unsubscribe = function () {
7664             this.count = 0;
7665             this.windows = null;
7666         };
7667         return WindowCountSubscriber;
7668     }(Subscriber));
7669
7670     function windowTime(windowTimeSpan) {
7671         var scheduler = async;
7672         var windowCreationInterval = null;
7673         var maxWindowSize = Number.POSITIVE_INFINITY;
7674         if (isScheduler(arguments[3])) {
7675             scheduler = arguments[3];
7676         }
7677         if (isScheduler(arguments[2])) {
7678             scheduler = arguments[2];
7679         }
7680         else if (isNumeric(arguments[2])) {
7681             maxWindowSize = Number(arguments[2]);
7682         }
7683         if (isScheduler(arguments[1])) {
7684             scheduler = arguments[1];
7685         }
7686         else if (isNumeric(arguments[1])) {
7687             windowCreationInterval = Number(arguments[1]);
7688         }
7689         return function windowTimeOperatorFunction(source) {
7690             return source.lift(new WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler));
7691         };
7692     }
7693     var WindowTimeOperator = (function () {
7694         function WindowTimeOperator(windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
7695             this.windowTimeSpan = windowTimeSpan;
7696             this.windowCreationInterval = windowCreationInterval;
7697             this.maxWindowSize = maxWindowSize;
7698             this.scheduler = scheduler;
7699         }
7700         WindowTimeOperator.prototype.call = function (subscriber, source) {
7701             return source.subscribe(new WindowTimeSubscriber(subscriber, this.windowTimeSpan, this.windowCreationInterval, this.maxWindowSize, this.scheduler));
7702         };
7703         return WindowTimeOperator;
7704     }());
7705     var CountedSubject = (function (_super) {
7706         __extends(CountedSubject, _super);
7707         function CountedSubject() {
7708             var _this = _super !== null && _super.apply(this, arguments) || this;
7709             _this._numberOfNextedValues = 0;
7710             return _this;
7711         }
7712         CountedSubject.prototype.next = function (value) {
7713             this._numberOfNextedValues++;
7714             _super.prototype.next.call(this, value);
7715         };
7716         Object.defineProperty(CountedSubject.prototype, "numberOfNextedValues", {
7717             get: function () {
7718                 return this._numberOfNextedValues;
7719             },
7720             enumerable: true,
7721             configurable: true
7722         });
7723         return CountedSubject;
7724     }(Subject));
7725     var WindowTimeSubscriber = (function (_super) {
7726         __extends(WindowTimeSubscriber, _super);
7727         function WindowTimeSubscriber(destination, windowTimeSpan, windowCreationInterval, maxWindowSize, scheduler) {
7728             var _this = _super.call(this, destination) || this;
7729             _this.destination = destination;
7730             _this.windowTimeSpan = windowTimeSpan;
7731             _this.windowCreationInterval = windowCreationInterval;
7732             _this.maxWindowSize = maxWindowSize;
7733             _this.scheduler = scheduler;
7734             _this.windows = [];
7735             var window = _this.openWindow();
7736             if (windowCreationInterval !== null && windowCreationInterval >= 0) {
7737                 var closeState = { subscriber: _this, window: window, context: null };
7738                 var creationState = { windowTimeSpan: windowTimeSpan, windowCreationInterval: windowCreationInterval, subscriber: _this, scheduler: scheduler };
7739                 _this.add(scheduler.schedule(dispatchWindowClose, windowTimeSpan, closeState));
7740                 _this.add(scheduler.schedule(dispatchWindowCreation, windowCreationInterval, creationState));
7741             }
7742             else {
7743                 var timeSpanOnlyState = { subscriber: _this, window: window, windowTimeSpan: windowTimeSpan };
7744                 _this.add(scheduler.schedule(dispatchWindowTimeSpanOnly, windowTimeSpan, timeSpanOnlyState));
7745             }
7746             return _this;
7747         }
7748         WindowTimeSubscriber.prototype._next = function (value) {
7749             var windows = this.windows;
7750             var len = windows.length;
7751             for (var i = 0; i < len; i++) {
7752                 var window_1 = windows[i];
7753                 if (!window_1.closed) {
7754                     window_1.next(value);
7755                     if (window_1.numberOfNextedValues >= this.maxWindowSize) {
7756                         this.closeWindow(window_1);
7757                     }
7758                 }
7759             }
7760         };
7761         WindowTimeSubscriber.prototype._error = function (err) {
7762             var windows = this.windows;
7763             while (windows.length > 0) {
7764                 windows.shift().error(err);
7765             }
7766             this.destination.error(err);
7767         };
7768         WindowTimeSubscriber.prototype._complete = function () {
7769             var windows = this.windows;
7770             while (windows.length > 0) {
7771                 var window_2 = windows.shift();
7772                 if (!window_2.closed) {
7773                     window_2.complete();
7774                 }
7775             }
7776             this.destination.complete();
7777         };
7778         WindowTimeSubscriber.prototype.openWindow = function () {
7779             var window = new CountedSubject();
7780             this.windows.push(window);
7781             var destination = this.destination;
7782             destination.next(window);
7783             return window;
7784         };
7785         WindowTimeSubscriber.prototype.closeWindow = function (window) {
7786             window.complete();
7787             var windows = this.windows;
7788             windows.splice(windows.indexOf(window), 1);
7789         };
7790         return WindowTimeSubscriber;
7791     }(Subscriber));
7792     function dispatchWindowTimeSpanOnly(state) {
7793         var subscriber = state.subscriber, windowTimeSpan = state.windowTimeSpan, window = state.window;
7794         if (window) {
7795             subscriber.closeWindow(window);
7796         }
7797         state.window = subscriber.openWindow();
7798         this.schedule(state, windowTimeSpan);
7799     }
7800     function dispatchWindowCreation(state) {
7801         var windowTimeSpan = state.windowTimeSpan, subscriber = state.subscriber, scheduler = state.scheduler, windowCreationInterval = state.windowCreationInterval;
7802         var window = subscriber.openWindow();
7803         var action = this;
7804         var context = { action: action, subscription: null };
7805         var timeSpanState = { subscriber: subscriber, window: window, context: context };
7806         context.subscription = scheduler.schedule(dispatchWindowClose, windowTimeSpan, timeSpanState);
7807         action.add(context.subscription);
7808         action.schedule(state, windowCreationInterval);
7809     }
7810     function dispatchWindowClose(state) {
7811         var subscriber = state.subscriber, window = state.window, context = state.context;
7812         if (context && context.action && context.subscription) {
7813             context.action.remove(context.subscription);
7814         }
7815         subscriber.closeWindow(window);
7816     }
7817
7818     function windowToggle(openings, closingSelector) {
7819         return function (source) { return source.lift(new WindowToggleOperator(openings, closingSelector)); };
7820     }
7821     var WindowToggleOperator = (function () {
7822         function WindowToggleOperator(openings, closingSelector) {
7823             this.openings = openings;
7824             this.closingSelector = closingSelector;
7825         }
7826         WindowToggleOperator.prototype.call = function (subscriber, source) {
7827             return source.subscribe(new WindowToggleSubscriber(subscriber, this.openings, this.closingSelector));
7828         };
7829         return WindowToggleOperator;
7830     }());
7831     var WindowToggleSubscriber = (function (_super) {
7832         __extends(WindowToggleSubscriber, _super);
7833         function WindowToggleSubscriber(destination, openings, closingSelector) {
7834             var _this = _super.call(this, destination) || this;
7835             _this.openings = openings;
7836             _this.closingSelector = closingSelector;
7837             _this.contexts = [];
7838             _this.add(_this.openSubscription = subscribeToResult(_this, openings, openings));
7839             return _this;
7840         }
7841         WindowToggleSubscriber.prototype._next = function (value) {
7842             var contexts = this.contexts;
7843             if (contexts) {
7844                 var len = contexts.length;
7845                 for (var i = 0; i < len; i++) {
7846                     contexts[i].window.next(value);
7847                 }
7848             }
7849         };
7850         WindowToggleSubscriber.prototype._error = function (err) {
7851             var contexts = this.contexts;
7852             this.contexts = null;
7853             if (contexts) {
7854                 var len = contexts.length;
7855                 var index = -1;
7856                 while (++index < len) {
7857                     var context_1 = contexts[index];
7858                     context_1.window.error(err);
7859                     context_1.subscription.unsubscribe();
7860                 }
7861             }
7862             _super.prototype._error.call(this, err);
7863         };
7864         WindowToggleSubscriber.prototype._complete = function () {
7865             var contexts = this.contexts;
7866             this.contexts = null;
7867             if (contexts) {
7868                 var len = contexts.length;
7869                 var index = -1;
7870                 while (++index < len) {
7871                     var context_2 = contexts[index];
7872                     context_2.window.complete();
7873                     context_2.subscription.unsubscribe();
7874                 }
7875             }
7876             _super.prototype._complete.call(this);
7877         };
7878         WindowToggleSubscriber.prototype._unsubscribe = function () {
7879             var contexts = this.contexts;
7880             this.contexts = null;
7881             if (contexts) {
7882                 var len = contexts.length;
7883                 var index = -1;
7884                 while (++index < len) {
7885                     var context_3 = contexts[index];
7886                     context_3.window.unsubscribe();
7887                     context_3.subscription.unsubscribe();
7888                 }
7889             }
7890         };
7891         WindowToggleSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
7892             if (outerValue === this.openings) {
7893                 var closingNotifier = void 0;
7894                 try {
7895                     var closingSelector = this.closingSelector;
7896                     closingNotifier = closingSelector(innerValue);
7897                 }
7898                 catch (e) {
7899                     return this.error(e);
7900                 }
7901                 var window_1 = new Subject();
7902                 var subscription = new Subscription();
7903                 var context_4 = { window: window_1, subscription: subscription };
7904                 this.contexts.push(context_4);
7905                 var innerSubscription = subscribeToResult(this, closingNotifier, context_4);
7906                 if (innerSubscription.closed) {
7907                     this.closeWindow(this.contexts.length - 1);
7908                 }
7909                 else {
7910                     innerSubscription.context = context_4;
7911                     subscription.add(innerSubscription);
7912                 }
7913                 this.destination.next(window_1);
7914             }
7915             else {
7916                 this.closeWindow(this.contexts.indexOf(outerValue));
7917             }
7918         };
7919         WindowToggleSubscriber.prototype.notifyError = function (err) {
7920             this.error(err);
7921         };
7922         WindowToggleSubscriber.prototype.notifyComplete = function (inner) {
7923             if (inner !== this.openSubscription) {
7924                 this.closeWindow(this.contexts.indexOf(inner.context));
7925             }
7926         };
7927         WindowToggleSubscriber.prototype.closeWindow = function (index) {
7928             if (index === -1) {
7929                 return;
7930             }
7931             var contexts = this.contexts;
7932             var context = contexts[index];
7933             var window = context.window, subscription = context.subscription;
7934             contexts.splice(index, 1);
7935             window.complete();
7936             subscription.unsubscribe();
7937         };
7938         return WindowToggleSubscriber;
7939     }(OuterSubscriber));
7940
7941     function windowWhen(closingSelector) {
7942         return function windowWhenOperatorFunction(source) {
7943             return source.lift(new WindowOperator$1(closingSelector));
7944         };
7945     }
7946     var WindowOperator$1 = (function () {
7947         function WindowOperator(closingSelector) {
7948             this.closingSelector = closingSelector;
7949         }
7950         WindowOperator.prototype.call = function (subscriber, source) {
7951             return source.subscribe(new WindowSubscriber$1(subscriber, this.closingSelector));
7952         };
7953         return WindowOperator;
7954     }());
7955     var WindowSubscriber$1 = (function (_super) {
7956         __extends(WindowSubscriber, _super);
7957         function WindowSubscriber(destination, closingSelector) {
7958             var _this = _super.call(this, destination) || this;
7959             _this.destination = destination;
7960             _this.closingSelector = closingSelector;
7961             _this.openWindow();
7962             return _this;
7963         }
7964         WindowSubscriber.prototype.notifyNext = function (_outerValue, _innerValue, _outerIndex, _innerIndex, innerSub) {
7965             this.openWindow(innerSub);
7966         };
7967         WindowSubscriber.prototype.notifyError = function (error) {
7968             this._error(error);
7969         };
7970         WindowSubscriber.prototype.notifyComplete = function (innerSub) {
7971             this.openWindow(innerSub);
7972         };
7973         WindowSubscriber.prototype._next = function (value) {
7974             this.window.next(value);
7975         };
7976         WindowSubscriber.prototype._error = function (err) {
7977             this.window.error(err);
7978             this.destination.error(err);
7979             this.unsubscribeClosingNotification();
7980         };
7981         WindowSubscriber.prototype._complete = function () {
7982             this.window.complete();
7983             this.destination.complete();
7984             this.unsubscribeClosingNotification();
7985         };
7986         WindowSubscriber.prototype.unsubscribeClosingNotification = function () {
7987             if (this.closingNotification) {
7988                 this.closingNotification.unsubscribe();
7989             }
7990         };
7991         WindowSubscriber.prototype.openWindow = function (innerSub) {
7992             if (innerSub === void 0) { innerSub = null; }
7993             if (innerSub) {
7994                 this.remove(innerSub);
7995                 innerSub.unsubscribe();
7996             }
7997             var prevWindow = this.window;
7998             if (prevWindow) {
7999                 prevWindow.complete();
8000             }
8001             var window = this.window = new Subject();
8002             this.destination.next(window);
8003             var closingNotifier;
8004             try {
8005                 var closingSelector = this.closingSelector;
8006                 closingNotifier = closingSelector();
8007             }
8008             catch (e) {
8009                 this.destination.error(e);
8010                 this.window.error(e);
8011                 return;
8012             }
8013             this.add(this.closingNotification = subscribeToResult(this, closingNotifier));
8014         };
8015         return WindowSubscriber;
8016     }(OuterSubscriber));
8017
8018     function withLatestFrom() {
8019         var args = [];
8020         for (var _i = 0; _i < arguments.length; _i++) {
8021             args[_i] = arguments[_i];
8022         }
8023         return function (source) {
8024             var project;
8025             if (typeof args[args.length - 1] === 'function') {
8026                 project = args.pop();
8027             }
8028             var observables = args;
8029             return source.lift(new WithLatestFromOperator(observables, project));
8030         };
8031     }
8032     var WithLatestFromOperator = (function () {
8033         function WithLatestFromOperator(observables, project) {
8034             this.observables = observables;
8035             this.project = project;
8036         }
8037         WithLatestFromOperator.prototype.call = function (subscriber, source) {
8038             return source.subscribe(new WithLatestFromSubscriber(subscriber, this.observables, this.project));
8039         };
8040         return WithLatestFromOperator;
8041     }());
8042     var WithLatestFromSubscriber = (function (_super) {
8043         __extends(WithLatestFromSubscriber, _super);
8044         function WithLatestFromSubscriber(destination, observables, project) {
8045             var _this = _super.call(this, destination) || this;
8046             _this.observables = observables;
8047             _this.project = project;
8048             _this.toRespond = [];
8049             var len = observables.length;
8050             _this.values = new Array(len);
8051             for (var i = 0; i < len; i++) {
8052                 _this.toRespond.push(i);
8053             }
8054             for (var i = 0; i < len; i++) {
8055                 var observable = observables[i];
8056                 _this.add(subscribeToResult(_this, observable, undefined, i));
8057             }
8058             return _this;
8059         }
8060         WithLatestFromSubscriber.prototype.notifyNext = function (_outerValue, innerValue, outerIndex) {
8061             this.values[outerIndex] = innerValue;
8062             var toRespond = this.toRespond;
8063             if (toRespond.length > 0) {
8064                 var found = toRespond.indexOf(outerIndex);
8065                 if (found !== -1) {
8066                     toRespond.splice(found, 1);
8067                 }
8068             }
8069         };
8070         WithLatestFromSubscriber.prototype.notifyComplete = function () {
8071         };
8072         WithLatestFromSubscriber.prototype._next = function (value) {
8073             if (this.toRespond.length === 0) {
8074                 var args = [value].concat(this.values);
8075                 if (this.project) {
8076                     this._tryProject(args);
8077                 }
8078                 else {
8079                     this.destination.next(args);
8080                 }
8081             }
8082         };
8083         WithLatestFromSubscriber.prototype._tryProject = function (args) {
8084             var result;
8085             try {
8086                 result = this.project.apply(this, args);
8087             }
8088             catch (err) {
8089                 this.destination.error(err);
8090                 return;
8091             }
8092             this.destination.next(result);
8093         };
8094         return WithLatestFromSubscriber;
8095     }(OuterSubscriber));
8096
8097     function zip$1() {
8098         var observables = [];
8099         for (var _i = 0; _i < arguments.length; _i++) {
8100             observables[_i] = arguments[_i];
8101         }
8102         return function zipOperatorFunction(source) {
8103             return source.lift.call(zip.apply(void 0, [source].concat(observables)));
8104         };
8105     }
8106
8107     function zipAll(project) {
8108         return function (source) { return source.lift(new ZipOperator(project)); };
8109     }
8110
8111
8112
8113     var _operators = /*#__PURE__*/Object.freeze({
8114         audit: audit,
8115         auditTime: auditTime,
8116         buffer: buffer,
8117         bufferCount: bufferCount,
8118         bufferTime: bufferTime,
8119         bufferToggle: bufferToggle,
8120         bufferWhen: bufferWhen,
8121         catchError: catchError,
8122         combineAll: combineAll,
8123         combineLatest: combineLatest$1,
8124         concat: concat$1,
8125         concatAll: concatAll,
8126         concatMap: concatMap,
8127         concatMapTo: concatMapTo,
8128         count: count,
8129         debounce: debounce,
8130         debounceTime: debounceTime,
8131         defaultIfEmpty: defaultIfEmpty,
8132         delay: delay,
8133         delayWhen: delayWhen,
8134         dematerialize: dematerialize,
8135         distinct: distinct,
8136         distinctUntilChanged: distinctUntilChanged,
8137         distinctUntilKeyChanged: distinctUntilKeyChanged,
8138         elementAt: elementAt,
8139         endWith: endWith,
8140         every: every,
8141         exhaust: exhaust,
8142         exhaustMap: exhaustMap,
8143         expand: expand,
8144         filter: filter,
8145         finalize: finalize,
8146         find: find,
8147         findIndex: findIndex,
8148         first: first,
8149         groupBy: groupBy,
8150         ignoreElements: ignoreElements,
8151         isEmpty: isEmpty,
8152         last: last,
8153         map: map,
8154         mapTo: mapTo,
8155         materialize: materialize,
8156         max: max,
8157         merge: merge$1,
8158         mergeAll: mergeAll,
8159         mergeMap: mergeMap,
8160         flatMap: flatMap,
8161         mergeMapTo: mergeMapTo,
8162         mergeScan: mergeScan,
8163         min: min,
8164         multicast: multicast,
8165         observeOn: observeOn,
8166         onErrorResumeNext: onErrorResumeNext$1,
8167         pairwise: pairwise,
8168         partition: partition$1,
8169         pluck: pluck,
8170         publish: publish,
8171         publishBehavior: publishBehavior,
8172         publishLast: publishLast,
8173         publishReplay: publishReplay,
8174         race: race$1,
8175         reduce: reduce,
8176         repeat: repeat,
8177         repeatWhen: repeatWhen,
8178         retry: retry,
8179         retryWhen: retryWhen,
8180         refCount: refCount,
8181         sample: sample,
8182         sampleTime: sampleTime,
8183         scan: scan,
8184         sequenceEqual: sequenceEqual,
8185         share: share,
8186         shareReplay: shareReplay,
8187         single: single,
8188         skip: skip,
8189         skipLast: skipLast,
8190         skipUntil: skipUntil,
8191         skipWhile: skipWhile,
8192         startWith: startWith,
8193         subscribeOn: subscribeOn,
8194         switchAll: switchAll,
8195         switchMap: switchMap,
8196         switchMapTo: switchMapTo,
8197         take: take,
8198         takeLast: takeLast,
8199         takeUntil: takeUntil,
8200         takeWhile: takeWhile,
8201         tap: tap,
8202         throttle: throttle,
8203         throttleTime: throttleTime,
8204         throwIfEmpty: throwIfEmpty,
8205         timeInterval: timeInterval,
8206         timeout: timeout,
8207         timeoutWith: timeoutWith,
8208         timestamp: timestamp,
8209         toArray: toArray,
8210         window: window$1,
8211         windowCount: windowCount,
8212         windowTime: windowTime,
8213         windowToggle: windowToggle,
8214         windowWhen: windowWhen,
8215         withLatestFrom: withLatestFrom,
8216         zip: zip$1,
8217         zipAll: zipAll
8218     });
8219
8220     var SubscriptionLog = (function () {
8221         function SubscriptionLog(subscribedFrame, unsubscribedFrame) {
8222             if (unsubscribedFrame === void 0) { unsubscribedFrame = Number.POSITIVE_INFINITY; }
8223             this.subscribedFrame = subscribedFrame;
8224             this.unsubscribedFrame = unsubscribedFrame;
8225         }
8226         return SubscriptionLog;
8227     }());
8228
8229     var SubscriptionLoggable = (function () {
8230         function SubscriptionLoggable() {
8231             this.subscriptions = [];
8232         }
8233         SubscriptionLoggable.prototype.logSubscribedFrame = function () {
8234             this.subscriptions.push(new SubscriptionLog(this.scheduler.now()));
8235             return this.subscriptions.length - 1;
8236         };
8237         SubscriptionLoggable.prototype.logUnsubscribedFrame = function (index) {
8238             var subscriptionLogs = this.subscriptions;
8239             var oldSubscriptionLog = subscriptionLogs[index];
8240             subscriptionLogs[index] = new SubscriptionLog(oldSubscriptionLog.subscribedFrame, this.scheduler.now());
8241         };
8242         return SubscriptionLoggable;
8243     }());
8244
8245     function applyMixins(derivedCtor, baseCtors) {
8246         for (var i = 0, len = baseCtors.length; i < len; i++) {
8247             var baseCtor = baseCtors[i];
8248             var propertyKeys = Object.getOwnPropertyNames(baseCtor.prototype);
8249             for (var j = 0, len2 = propertyKeys.length; j < len2; j++) {
8250                 var name_1 = propertyKeys[j];
8251                 derivedCtor.prototype[name_1] = baseCtor.prototype[name_1];
8252             }
8253         }
8254     }
8255
8256     var ColdObservable = (function (_super) {
8257         __extends(ColdObservable, _super);
8258         function ColdObservable(messages, scheduler) {
8259             var _this = _super.call(this, function (subscriber) {
8260                 var observable = this;
8261                 var index = observable.logSubscribedFrame();
8262                 var subscription = new Subscription();
8263                 subscription.add(new Subscription(function () {
8264                     observable.logUnsubscribedFrame(index);
8265                 }));
8266                 observable.scheduleMessages(subscriber);
8267                 return subscription;
8268             }) || this;
8269             _this.messages = messages;
8270             _this.subscriptions = [];
8271             _this.scheduler = scheduler;
8272             return _this;
8273         }
8274         ColdObservable.prototype.scheduleMessages = function (subscriber) {
8275             var messagesLength = this.messages.length;
8276             for (var i = 0; i < messagesLength; i++) {
8277                 var message = this.messages[i];
8278                 subscriber.add(this.scheduler.schedule(function (_a) {
8279                     var message = _a.message, subscriber = _a.subscriber;
8280                     message.notification.observe(subscriber);
8281                 }, message.frame, { message: message, subscriber: subscriber }));
8282             }
8283         };
8284         return ColdObservable;
8285     }(Observable));
8286     applyMixins(ColdObservable, [SubscriptionLoggable]);
8287
8288     var HotObservable = (function (_super) {
8289         __extends(HotObservable, _super);
8290         function HotObservable(messages, scheduler) {
8291             var _this = _super.call(this) || this;
8292             _this.messages = messages;
8293             _this.subscriptions = [];
8294             _this.scheduler = scheduler;
8295             return _this;
8296         }
8297         HotObservable.prototype._subscribe = function (subscriber) {
8298             var subject = this;
8299             var index = subject.logSubscribedFrame();
8300             var subscription = new Subscription();
8301             subscription.add(new Subscription(function () {
8302                 subject.logUnsubscribedFrame(index);
8303             }));
8304             subscription.add(_super.prototype._subscribe.call(this, subscriber));
8305             return subscription;
8306         };
8307         HotObservable.prototype.setup = function () {
8308             var subject = this;
8309             var messagesLength = subject.messages.length;
8310             for (var i = 0; i < messagesLength; i++) {
8311                 (function () {
8312                     var message = subject.messages[i];
8313                     subject.scheduler.schedule(function () { message.notification.observe(subject); }, message.frame);
8314                 })();
8315             }
8316         };
8317         return HotObservable;
8318     }(Subject));
8319     applyMixins(HotObservable, [SubscriptionLoggable]);
8320
8321     var defaultMaxFrame = 750;
8322     var TestScheduler = (function (_super) {
8323         __extends(TestScheduler, _super);
8324         function TestScheduler(assertDeepEqual) {
8325             var _this = _super.call(this, VirtualAction, defaultMaxFrame) || this;
8326             _this.assertDeepEqual = assertDeepEqual;
8327             _this.hotObservables = [];
8328             _this.coldObservables = [];
8329             _this.flushTests = [];
8330             _this.runMode = false;
8331             return _this;
8332         }
8333         TestScheduler.prototype.createTime = function (marbles) {
8334             var indexOf = marbles.indexOf('|');
8335             if (indexOf === -1) {
8336                 throw new Error('marble diagram for time should have a completion marker "|"');
8337             }
8338             return indexOf * TestScheduler.frameTimeFactor;
8339         };
8340         TestScheduler.prototype.createColdObservable = function (marbles, values, error) {
8341             if (marbles.indexOf('^') !== -1) {
8342                 throw new Error('cold observable cannot have subscription offset "^"');
8343             }
8344             if (marbles.indexOf('!') !== -1) {
8345                 throw new Error('cold observable cannot have unsubscription marker "!"');
8346             }
8347             var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
8348             var cold = new ColdObservable(messages, this);
8349             this.coldObservables.push(cold);
8350             return cold;
8351         };
8352         TestScheduler.prototype.createHotObservable = function (marbles, values, error) {
8353             if (marbles.indexOf('!') !== -1) {
8354                 throw new Error('hot observable cannot have unsubscription marker "!"');
8355             }
8356             var messages = TestScheduler.parseMarbles(marbles, values, error, undefined, this.runMode);
8357             var subject = new HotObservable(messages, this);
8358             this.hotObservables.push(subject);
8359             return subject;
8360         };
8361         TestScheduler.prototype.materializeInnerObservable = function (observable, outerFrame) {
8362             var _this = this;
8363             var messages = [];
8364             observable.subscribe(function (value) {
8365                 messages.push({ frame: _this.frame - outerFrame, notification: Notification.createNext(value) });
8366             }, function (err) {
8367                 messages.push({ frame: _this.frame - outerFrame, notification: Notification.createError(err) });
8368             }, function () {
8369                 messages.push({ frame: _this.frame - outerFrame, notification: Notification.createComplete() });
8370             });
8371             return messages;
8372         };
8373         TestScheduler.prototype.expectObservable = function (observable, subscriptionMarbles) {
8374             var _this = this;
8375             if (subscriptionMarbles === void 0) { subscriptionMarbles = null; }
8376             var actual = [];
8377             var flushTest = { actual: actual, ready: false };
8378             var subscriptionParsed = TestScheduler.parseMarblesAsSubscriptions(subscriptionMarbles, this.runMode);
8379             var subscriptionFrame = subscriptionParsed.subscribedFrame === Number.POSITIVE_INFINITY ?
8380                 0 : subscriptionParsed.subscribedFrame;
8381             var unsubscriptionFrame = subscriptionParsed.unsubscribedFrame;
8382             var subscription;
8383             this.schedule(function () {
8384                 subscription = observable.subscribe(function (x) {
8385                     var value = x;
8386                     if (x instanceof Observable) {
8387                         value = _this.materializeInnerObservable(value, _this.frame);
8388                     }
8389                     actual.push({ frame: _this.frame, notification: Notification.createNext(value) });
8390                 }, function (err) {
8391                     actual.push({ frame: _this.frame, notification: Notification.createError(err) });
8392                 }, function () {
8393                     actual.push({ frame: _this.frame, notification: Notification.createComplete() });
8394                 });
8395             }, subscriptionFrame);
8396             if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
8397                 this.schedule(function () { return subscription.unsubscribe(); }, unsubscriptionFrame);
8398             }
8399             this.flushTests.push(flushTest);
8400             var runMode = this.runMode;
8401             return {
8402                 toBe: function (marbles, values, errorValue) {
8403                     flushTest.ready = true;
8404                     flushTest.expected = TestScheduler.parseMarbles(marbles, values, errorValue, true, runMode);
8405                 }
8406             };
8407         };
8408         TestScheduler.prototype.expectSubscriptions = function (actualSubscriptionLogs) {
8409             var flushTest = { actual: actualSubscriptionLogs, ready: false };
8410             this.flushTests.push(flushTest);
8411             var runMode = this.runMode;
8412             return {
8413                 toBe: function (marbles) {
8414                     var marblesArray = (typeof marbles === 'string') ? [marbles] : marbles;
8415                     flushTest.ready = true;
8416                     flushTest.expected = marblesArray.map(function (marbles) {
8417                         return TestScheduler.parseMarblesAsSubscriptions(marbles, runMode);
8418                     });
8419                 }
8420             };
8421         };
8422         TestScheduler.prototype.flush = function () {
8423             var _this = this;
8424             var hotObservables = this.hotObservables;
8425             while (hotObservables.length > 0) {
8426                 hotObservables.shift().setup();
8427             }
8428             _super.prototype.flush.call(this);
8429             this.flushTests = this.flushTests.filter(function (test) {
8430                 if (test.ready) {
8431                     _this.assertDeepEqual(test.actual, test.expected);
8432                     return false;
8433                 }
8434                 return true;
8435             });
8436         };
8437         TestScheduler.parseMarblesAsSubscriptions = function (marbles, runMode) {
8438             var _this = this;
8439             if (runMode === void 0) { runMode = false; }
8440             if (typeof marbles !== 'string') {
8441                 return new SubscriptionLog(Number.POSITIVE_INFINITY);
8442             }
8443             var len = marbles.length;
8444             var groupStart = -1;
8445             var subscriptionFrame = Number.POSITIVE_INFINITY;
8446             var unsubscriptionFrame = Number.POSITIVE_INFINITY;
8447             var frame = 0;
8448             var _loop_1 = function (i) {
8449                 var nextFrame = frame;
8450                 var advanceFrameBy = function (count) {
8451                     nextFrame += count * _this.frameTimeFactor;
8452                 };
8453                 var c = marbles[i];
8454                 switch (c) {
8455                     case ' ':
8456                         if (!runMode) {
8457                             advanceFrameBy(1);
8458                         }
8459                         break;
8460                     case '-':
8461                         advanceFrameBy(1);
8462                         break;
8463                     case '(':
8464                         groupStart = frame;
8465                         advanceFrameBy(1);
8466                         break;
8467                     case ')':
8468                         groupStart = -1;
8469                         advanceFrameBy(1);
8470                         break;
8471                     case '^':
8472                         if (subscriptionFrame !== Number.POSITIVE_INFINITY) {
8473                             throw new Error('found a second subscription point \'^\' in a ' +
8474                                 'subscription marble diagram. There can only be one.');
8475                         }
8476                         subscriptionFrame = groupStart > -1 ? groupStart : frame;
8477                         advanceFrameBy(1);
8478                         break;
8479                     case '!':
8480                         if (unsubscriptionFrame !== Number.POSITIVE_INFINITY) {
8481                             throw new Error('found a second subscription point \'^\' in a ' +
8482                                 'subscription marble diagram. There can only be one.');
8483                         }
8484                         unsubscriptionFrame = groupStart > -1 ? groupStart : frame;
8485                         break;
8486                     default:
8487                         if (runMode && c.match(/^[0-9]$/)) {
8488                             if (i === 0 || marbles[i - 1] === ' ') {
8489                                 var buffer = marbles.slice(i);
8490                                 var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
8491                                 if (match) {
8492                                     i += match[0].length - 1;
8493                                     var duration = parseFloat(match[1]);
8494                                     var unit = match[2];
8495                                     var durationInMs = void 0;
8496                                     switch (unit) {
8497                                         case 'ms':
8498                                             durationInMs = duration;
8499                                             break;
8500                                         case 's':
8501                                             durationInMs = duration * 1000;
8502                                             break;
8503                                         case 'm':
8504                                             durationInMs = duration * 1000 * 60;
8505                                             break;
8506                                         default:
8507                                             break;
8508                                     }
8509                                     advanceFrameBy(durationInMs / this_1.frameTimeFactor);
8510                                     break;
8511                                 }
8512                             }
8513                         }
8514                         throw new Error('there can only be \'^\' and \'!\' markers in a ' +
8515                             'subscription marble diagram. Found instead \'' + c + '\'.');
8516                 }
8517                 frame = nextFrame;
8518                 out_i_1 = i;
8519             };
8520             var this_1 = this, out_i_1;
8521             for (var i = 0; i < len; i++) {
8522                 _loop_1(i);
8523                 i = out_i_1;
8524             }
8525             if (unsubscriptionFrame < 0) {
8526                 return new SubscriptionLog(subscriptionFrame);
8527             }
8528             else {
8529                 return new SubscriptionLog(subscriptionFrame, unsubscriptionFrame);
8530             }
8531         };
8532         TestScheduler.parseMarbles = function (marbles, values, errorValue, materializeInnerObservables, runMode) {
8533             var _this = this;
8534             if (materializeInnerObservables === void 0) { materializeInnerObservables = false; }
8535             if (runMode === void 0) { runMode = false; }
8536             if (marbles.indexOf('!') !== -1) {
8537                 throw new Error('conventional marble diagrams cannot have the ' +
8538                     'unsubscription marker "!"');
8539             }
8540             var len = marbles.length;
8541             var testMessages = [];
8542             var subIndex = runMode ? marbles.replace(/^[ ]+/, '').indexOf('^') : marbles.indexOf('^');
8543             var frame = subIndex === -1 ? 0 : (subIndex * -this.frameTimeFactor);
8544             var getValue = typeof values !== 'object' ?
8545                 function (x) { return x; } :
8546                 function (x) {
8547                     if (materializeInnerObservables && values[x] instanceof ColdObservable) {
8548                         return values[x].messages;
8549                     }
8550                     return values[x];
8551                 };
8552             var groupStart = -1;
8553             var _loop_2 = function (i) {
8554                 var nextFrame = frame;
8555                 var advanceFrameBy = function (count) {
8556                     nextFrame += count * _this.frameTimeFactor;
8557                 };
8558                 var notification = void 0;
8559                 var c = marbles[i];
8560                 switch (c) {
8561                     case ' ':
8562                         if (!runMode) {
8563                             advanceFrameBy(1);
8564                         }
8565                         break;
8566                     case '-':
8567                         advanceFrameBy(1);
8568                         break;
8569                     case '(':
8570                         groupStart = frame;
8571                         advanceFrameBy(1);
8572                         break;
8573                     case ')':
8574                         groupStart = -1;
8575                         advanceFrameBy(1);
8576                         break;
8577                     case '|':
8578                         notification = Notification.createComplete();
8579                         advanceFrameBy(1);
8580                         break;
8581                     case '^':
8582                         advanceFrameBy(1);
8583                         break;
8584                     case '#':
8585                         notification = Notification.createError(errorValue || 'error');
8586                         advanceFrameBy(1);
8587                         break;
8588                     default:
8589                         if (runMode && c.match(/^[0-9]$/)) {
8590                             if (i === 0 || marbles[i - 1] === ' ') {
8591                                 var buffer = marbles.slice(i);
8592                                 var match = buffer.match(/^([0-9]+(?:\.[0-9]+)?)(ms|s|m) /);
8593                                 if (match) {
8594                                     i += match[0].length - 1;
8595                                     var duration = parseFloat(match[1]);
8596                                     var unit = match[2];
8597                                     var durationInMs = void 0;
8598                                     switch (unit) {
8599                                         case 'ms':
8600                                             durationInMs = duration;
8601                                             break;
8602                                         case 's':
8603                                             durationInMs = duration * 1000;
8604                                             break;
8605                                         case 'm':
8606                                             durationInMs = duration * 1000 * 60;
8607                                             break;
8608                                         default:
8609                                             break;
8610                                     }
8611                                     advanceFrameBy(durationInMs / this_2.frameTimeFactor);
8612                                     break;
8613                                 }
8614                             }
8615                         }
8616                         notification = Notification.createNext(getValue(c));
8617                         advanceFrameBy(1);
8618                         break;
8619                 }
8620                 if (notification) {
8621                     testMessages.push({ frame: groupStart > -1 ? groupStart : frame, notification: notification });
8622                 }
8623                 frame = nextFrame;
8624                 out_i_2 = i;
8625             };
8626             var this_2 = this, out_i_2;
8627             for (var i = 0; i < len; i++) {
8628                 _loop_2(i);
8629                 i = out_i_2;
8630             }
8631             return testMessages;
8632         };
8633         TestScheduler.prototype.run = function (callback) {
8634             var prevFrameTimeFactor = TestScheduler.frameTimeFactor;
8635             var prevMaxFrames = this.maxFrames;
8636             TestScheduler.frameTimeFactor = 1;
8637             this.maxFrames = Number.POSITIVE_INFINITY;
8638             this.runMode = true;
8639             AsyncScheduler.delegate = this;
8640             var helpers = {
8641                 cold: this.createColdObservable.bind(this),
8642                 hot: this.createHotObservable.bind(this),
8643                 flush: this.flush.bind(this),
8644                 expectObservable: this.expectObservable.bind(this),
8645                 expectSubscriptions: this.expectSubscriptions.bind(this),
8646             };
8647             try {
8648                 var ret = callback(helpers);
8649                 this.flush();
8650                 return ret;
8651             }
8652             finally {
8653                 TestScheduler.frameTimeFactor = prevFrameTimeFactor;
8654                 this.maxFrames = prevMaxFrames;
8655                 this.runMode = false;
8656                 AsyncScheduler.delegate = undefined;
8657             }
8658         };
8659         return TestScheduler;
8660     }(VirtualTimeScheduler));
8661
8662
8663
8664     var _testing = /*#__PURE__*/Object.freeze({
8665         TestScheduler: TestScheduler
8666     });
8667
8668     var __window = typeof window !== 'undefined' && window;
8669     var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
8670         self instanceof WorkerGlobalScope && self;
8671     var __global = typeof global !== 'undefined' && global;
8672     var _root = __window || __global || __self;
8673     (function () {
8674         if (!_root) {
8675             throw new Error('RxJS could not find any global context (window, self, global)');
8676         }
8677     })();
8678
8679     function getCORSRequest() {
8680         if (_root.XMLHttpRequest) {
8681             return new _root.XMLHttpRequest();
8682         }
8683         else if (!!_root.XDomainRequest) {
8684             return new _root.XDomainRequest();
8685         }
8686         else {
8687             throw new Error('CORS is not supported by your browser');
8688         }
8689     }
8690     function getXMLHttpRequest() {
8691         if (_root.XMLHttpRequest) {
8692             return new _root.XMLHttpRequest();
8693         }
8694         else {
8695             var progId = void 0;
8696             try {
8697                 var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'];
8698                 for (var i = 0; i < 3; i++) {
8699                     try {
8700                         progId = progIds[i];
8701                         if (new _root.ActiveXObject(progId)) {
8702                             break;
8703                         }
8704                     }
8705                     catch (e) {
8706                     }
8707                 }
8708                 return new _root.ActiveXObject(progId);
8709             }
8710             catch (e) {
8711                 throw new Error('XMLHttpRequest is not supported by your browser');
8712             }
8713         }
8714     }
8715     function ajaxGet(url, headers) {
8716         if (headers === void 0) { headers = null; }
8717         return new AjaxObservable({ method: 'GET', url: url, headers: headers });
8718     }
8719     function ajaxPost(url, body, headers) {
8720         return new AjaxObservable({ method: 'POST', url: url, body: body, headers: headers });
8721     }
8722     function ajaxDelete(url, headers) {
8723         return new AjaxObservable({ method: 'DELETE', url: url, headers: headers });
8724     }
8725     function ajaxPut(url, body, headers) {
8726         return new AjaxObservable({ method: 'PUT', url: url, body: body, headers: headers });
8727     }
8728     function ajaxPatch(url, body, headers) {
8729         return new AjaxObservable({ method: 'PATCH', url: url, body: body, headers: headers });
8730     }
8731     var mapResponse = map(function (x, index) { return x.response; });
8732     function ajaxGetJSON(url, headers) {
8733         return mapResponse(new AjaxObservable({
8734             method: 'GET',
8735             url: url,
8736             responseType: 'json',
8737             headers: headers
8738         }));
8739     }
8740     var AjaxObservable = (function (_super) {
8741         __extends(AjaxObservable, _super);
8742         function AjaxObservable(urlOrRequest) {
8743             var _this = _super.call(this) || this;
8744             var request = {
8745                 async: true,
8746                 createXHR: function () {
8747                     return this.crossDomain ? getCORSRequest() : getXMLHttpRequest();
8748                 },
8749                 crossDomain: true,
8750                 withCredentials: false,
8751                 headers: {},
8752                 method: 'GET',
8753                 responseType: 'json',
8754                 timeout: 0
8755             };
8756             if (typeof urlOrRequest === 'string') {
8757                 request.url = urlOrRequest;
8758             }
8759             else {
8760                 for (var prop in urlOrRequest) {
8761                     if (urlOrRequest.hasOwnProperty(prop)) {
8762                         request[prop] = urlOrRequest[prop];
8763                     }
8764                 }
8765             }
8766             _this.request = request;
8767             return _this;
8768         }
8769         AjaxObservable.prototype._subscribe = function (subscriber) {
8770             return new AjaxSubscriber(subscriber, this.request);
8771         };
8772         AjaxObservable.create = (function () {
8773             var create = function (urlOrRequest) {
8774                 return new AjaxObservable(urlOrRequest);
8775             };
8776             create.get = ajaxGet;
8777             create.post = ajaxPost;
8778             create.delete = ajaxDelete;
8779             create.put = ajaxPut;
8780             create.patch = ajaxPatch;
8781             create.getJSON = ajaxGetJSON;
8782             return create;
8783         })();
8784         return AjaxObservable;
8785     }(Observable));
8786     var AjaxSubscriber = (function (_super) {
8787         __extends(AjaxSubscriber, _super);
8788         function AjaxSubscriber(destination, request) {
8789             var _this = _super.call(this, destination) || this;
8790             _this.request = request;
8791             _this.done = false;
8792             var headers = request.headers = request.headers || {};
8793             if (!request.crossDomain && !_this.getHeader(headers, 'X-Requested-With')) {
8794                 headers['X-Requested-With'] = 'XMLHttpRequest';
8795             }
8796             var contentTypeHeader = _this.getHeader(headers, 'Content-Type');
8797             if (!contentTypeHeader && !(_root.FormData && request.body instanceof _root.FormData) && typeof request.body !== 'undefined') {
8798                 headers['Content-Type'] = 'application/x-www-form-urlencoded; charset=UTF-8';
8799             }
8800             request.body = _this.serializeBody(request.body, _this.getHeader(request.headers, 'Content-Type'));
8801             _this.send();
8802             return _this;
8803         }
8804         AjaxSubscriber.prototype.next = function (e) {
8805             this.done = true;
8806             var _a = this, xhr = _a.xhr, request = _a.request, destination = _a.destination;
8807             var result;
8808             try {
8809                 result = new AjaxResponse(e, xhr, request);
8810             }
8811             catch (err) {
8812                 return destination.error(err);
8813             }
8814             destination.next(result);
8815         };
8816         AjaxSubscriber.prototype.send = function () {
8817             var _a = this, request = _a.request, _b = _a.request, user = _b.user, method = _b.method, url = _b.url, async = _b.async, password = _b.password, headers = _b.headers, body = _b.body;
8818             try {
8819                 var xhr = this.xhr = request.createXHR();
8820                 this.setupEvents(xhr, request);
8821                 if (user) {
8822                     xhr.open(method, url, async, user, password);
8823                 }
8824                 else {
8825                     xhr.open(method, url, async);
8826                 }
8827                 if (async) {
8828                     xhr.timeout = request.timeout;
8829                     xhr.responseType = request.responseType;
8830                 }
8831                 if ('withCredentials' in xhr) {
8832                     xhr.withCredentials = !!request.withCredentials;
8833                 }
8834                 this.setHeaders(xhr, headers);
8835                 if (body) {
8836                     xhr.send(body);
8837                 }
8838                 else {
8839                     xhr.send();
8840                 }
8841             }
8842             catch (err) {
8843                 this.error(err);
8844             }
8845         };
8846         AjaxSubscriber.prototype.serializeBody = function (body, contentType) {
8847             if (!body || typeof body === 'string') {
8848                 return body;
8849             }
8850             else if (_root.FormData && body instanceof _root.FormData) {
8851                 return body;
8852             }
8853             if (contentType) {
8854                 var splitIndex = contentType.indexOf(';');
8855                 if (splitIndex !== -1) {
8856                     contentType = contentType.substring(0, splitIndex);
8857                 }
8858             }
8859             switch (contentType) {
8860                 case 'application/x-www-form-urlencoded':
8861                     return Object.keys(body).map(function (key) { return encodeURIComponent(key) + "=" + encodeURIComponent(body[key]); }).join('&');
8862                 case 'application/json':
8863                     return JSON.stringify(body);
8864                 default:
8865                     return body;
8866             }
8867         };
8868         AjaxSubscriber.prototype.setHeaders = function (xhr, headers) {
8869             for (var key in headers) {
8870                 if (headers.hasOwnProperty(key)) {
8871                     xhr.setRequestHeader(key, headers[key]);
8872                 }
8873             }
8874         };
8875         AjaxSubscriber.prototype.getHeader = function (headers, headerName) {
8876             for (var key in headers) {
8877                 if (key.toLowerCase() === headerName.toLowerCase()) {
8878                     return headers[key];
8879                 }
8880             }
8881             return undefined;
8882         };
8883         AjaxSubscriber.prototype.setupEvents = function (xhr, request) {
8884             var progressSubscriber = request.progressSubscriber;
8885             function xhrTimeout(e) {
8886                 var _a = xhrTimeout, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
8887                 if (progressSubscriber) {
8888                     progressSubscriber.error(e);
8889                 }
8890                 var error;
8891                 try {
8892                     error = new AjaxTimeoutError(this, request);
8893                 }
8894                 catch (err) {
8895                     error = err;
8896                 }
8897                 subscriber.error(error);
8898             }
8899             xhr.ontimeout = xhrTimeout;
8900             xhrTimeout.request = request;
8901             xhrTimeout.subscriber = this;
8902             xhrTimeout.progressSubscriber = progressSubscriber;
8903             if (xhr.upload && 'withCredentials' in xhr) {
8904                 if (progressSubscriber) {
8905                     var xhrProgress_1;
8906                     xhrProgress_1 = function (e) {
8907                         var progressSubscriber = xhrProgress_1.progressSubscriber;
8908                         progressSubscriber.next(e);
8909                     };
8910                     if (_root.XDomainRequest) {
8911                         xhr.onprogress = xhrProgress_1;
8912                     }
8913                     else {
8914                         xhr.upload.onprogress = xhrProgress_1;
8915                     }
8916                     xhrProgress_1.progressSubscriber = progressSubscriber;
8917                 }
8918                 var xhrError_1;
8919                 xhrError_1 = function (e) {
8920                     var _a = xhrError_1, progressSubscriber = _a.progressSubscriber, subscriber = _a.subscriber, request = _a.request;
8921                     if (progressSubscriber) {
8922                         progressSubscriber.error(e);
8923                     }
8924                     var error;
8925                     try {
8926                         error = new AjaxError('ajax error', this, request);
8927                     }
8928                     catch (err) {
8929                         error = err;
8930                     }
8931                     subscriber.error(error);
8932                 };
8933                 xhr.onerror = xhrError_1;
8934                 xhrError_1.request = request;
8935                 xhrError_1.subscriber = this;
8936                 xhrError_1.progressSubscriber = progressSubscriber;
8937             }
8938             function xhrReadyStateChange(e) {
8939                 return;
8940             }
8941             xhr.onreadystatechange = xhrReadyStateChange;
8942             xhrReadyStateChange.subscriber = this;
8943             xhrReadyStateChange.progressSubscriber = progressSubscriber;
8944             xhrReadyStateChange.request = request;
8945             function xhrLoad(e) {
8946                 var _a = xhrLoad, subscriber = _a.subscriber, progressSubscriber = _a.progressSubscriber, request = _a.request;
8947                 if (this.readyState === 4) {
8948                     var status_1 = this.status === 1223 ? 204 : this.status;
8949                     var response = (this.responseType === 'text' ? (this.response || this.responseText) : this.response);
8950                     if (status_1 === 0) {
8951                         status_1 = response ? 200 : 0;
8952                     }
8953                     if (status_1 < 400) {
8954                         if (progressSubscriber) {
8955                             progressSubscriber.complete();
8956                         }
8957                         subscriber.next(e);
8958                         subscriber.complete();
8959                     }
8960                     else {
8961                         if (progressSubscriber) {
8962                             progressSubscriber.error(e);
8963                         }
8964                         var error = void 0;
8965                         try {
8966                             error = new AjaxError('ajax error ' + status_1, this, request);
8967                         }
8968                         catch (err) {
8969                             error = err;
8970                         }
8971                         subscriber.error(error);
8972                     }
8973                 }
8974             }
8975             xhr.onload = xhrLoad;
8976             xhrLoad.subscriber = this;
8977             xhrLoad.progressSubscriber = progressSubscriber;
8978             xhrLoad.request = request;
8979         };
8980         AjaxSubscriber.prototype.unsubscribe = function () {
8981             var _a = this, done = _a.done, xhr = _a.xhr;
8982             if (!done && xhr && xhr.readyState !== 4 && typeof xhr.abort === 'function') {
8983                 xhr.abort();
8984             }
8985             _super.prototype.unsubscribe.call(this);
8986         };
8987         return AjaxSubscriber;
8988     }(Subscriber));
8989     var AjaxResponse = (function () {
8990         function AjaxResponse(originalEvent, xhr, request) {
8991             this.originalEvent = originalEvent;
8992             this.xhr = xhr;
8993             this.request = request;
8994             this.status = xhr.status;
8995             this.responseType = xhr.responseType || request.responseType;
8996             this.response = parseXhrResponse(this.responseType, xhr);
8997         }
8998         return AjaxResponse;
8999     }());
9000     var AjaxErrorImpl = (function () {
9001         function AjaxErrorImpl(message, xhr, request) {
9002             Error.call(this);
9003             this.message = message;
9004             this.name = 'AjaxError';
9005             this.xhr = xhr;
9006             this.request = request;
9007             this.status = xhr.status;
9008             this.responseType = xhr.responseType || request.responseType;
9009             this.response = parseXhrResponse(this.responseType, xhr);
9010             return this;
9011         }
9012         AjaxErrorImpl.prototype = Object.create(Error.prototype);
9013         return AjaxErrorImpl;
9014     })();
9015     var AjaxError = AjaxErrorImpl;
9016     function parseJson(xhr) {
9017         if ('response' in xhr) {
9018             return xhr.responseType ? xhr.response : JSON.parse(xhr.response || xhr.responseText || 'null');
9019         }
9020         else {
9021             return JSON.parse(xhr.responseText || 'null');
9022         }
9023     }
9024     function parseXhrResponse(responseType, xhr) {
9025         switch (responseType) {
9026             case 'json':
9027                 return parseJson(xhr);
9028             case 'xml':
9029                 return xhr.responseXML;
9030             case 'text':
9031             default:
9032                 return ('response' in xhr) ? xhr.response : xhr.responseText;
9033         }
9034     }
9035     function AjaxTimeoutErrorImpl(xhr, request) {
9036         AjaxError.call(this, 'ajax timeout', xhr, request);
9037         this.name = 'AjaxTimeoutError';
9038         return this;
9039     }
9040     var AjaxTimeoutError = AjaxTimeoutErrorImpl;
9041
9042     var ajax = (function () { return AjaxObservable.create; })();
9043
9044
9045
9046     var _ajax = /*#__PURE__*/Object.freeze({
9047         ajax: ajax,
9048         AjaxResponse: AjaxResponse,
9049         AjaxError: AjaxError,
9050         AjaxTimeoutError: AjaxTimeoutError
9051     });
9052
9053     var DEFAULT_WEBSOCKET_CONFIG = {
9054         url: '',
9055         deserializer: function (e) { return JSON.parse(e.data); },
9056         serializer: function (value) { return JSON.stringify(value); },
9057     };
9058     var WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT = 'WebSocketSubject.error must be called with an object with an error code, and an optional reason: { code: number, reason: string }';
9059     var WebSocketSubject = (function (_super) {
9060         __extends(WebSocketSubject, _super);
9061         function WebSocketSubject(urlConfigOrSource, destination) {
9062             var _this = _super.call(this) || this;
9063             if (urlConfigOrSource instanceof Observable) {
9064                 _this.destination = destination;
9065                 _this.source = urlConfigOrSource;
9066             }
9067             else {
9068                 var config = _this._config = __assign({}, DEFAULT_WEBSOCKET_CONFIG);
9069                 _this._output = new Subject();
9070                 if (typeof urlConfigOrSource === 'string') {
9071                     config.url = urlConfigOrSource;
9072                 }
9073                 else {
9074                     for (var key in urlConfigOrSource) {
9075                         if (urlConfigOrSource.hasOwnProperty(key)) {
9076                             config[key] = urlConfigOrSource[key];
9077                         }
9078                     }
9079                 }
9080                 if (!config.WebSocketCtor && WebSocket) {
9081                     config.WebSocketCtor = WebSocket;
9082                 }
9083                 else if (!config.WebSocketCtor) {
9084                     throw new Error('no WebSocket constructor can be found');
9085                 }
9086                 _this.destination = new ReplaySubject();
9087             }
9088             return _this;
9089         }
9090         WebSocketSubject.prototype.lift = function (operator) {
9091             var sock = new WebSocketSubject(this._config, this.destination);
9092             sock.operator = operator;
9093             sock.source = this;
9094             return sock;
9095         };
9096         WebSocketSubject.prototype._resetState = function () {
9097             this._socket = null;
9098             if (!this.source) {
9099                 this.destination = new ReplaySubject();
9100             }
9101             this._output = new Subject();
9102         };
9103         WebSocketSubject.prototype.multiplex = function (subMsg, unsubMsg, messageFilter) {
9104             var self = this;
9105             return new Observable(function (observer) {
9106                 try {
9107                     self.next(subMsg());
9108                 }
9109                 catch (err) {
9110                     observer.error(err);
9111                 }
9112                 var subscription = self.subscribe(function (x) {
9113                     try {
9114                         if (messageFilter(x)) {
9115                             observer.next(x);
9116                         }
9117                     }
9118                     catch (err) {
9119                         observer.error(err);
9120                     }
9121                 }, function (err) { return observer.error(err); }, function () { return observer.complete(); });
9122                 return function () {
9123                     try {
9124                         self.next(unsubMsg());
9125                     }
9126                     catch (err) {
9127                         observer.error(err);
9128                     }
9129                     subscription.unsubscribe();
9130                 };
9131             });
9132         };
9133         WebSocketSubject.prototype._connectSocket = function () {
9134             var _this = this;
9135             var _a = this._config, WebSocketCtor = _a.WebSocketCtor, protocol = _a.protocol, url = _a.url, binaryType = _a.binaryType;
9136             var observer = this._output;
9137             var socket = null;
9138             try {
9139                 socket = protocol ?
9140                     new WebSocketCtor(url, protocol) :
9141                     new WebSocketCtor(url);
9142                 this._socket = socket;
9143                 if (binaryType) {
9144                     this._socket.binaryType = binaryType;
9145                 }
9146             }
9147             catch (e) {
9148                 observer.error(e);
9149                 return;
9150             }
9151             var subscription = new Subscription(function () {
9152                 _this._socket = null;
9153                 if (socket && socket.readyState === 1) {
9154                     socket.close();
9155                 }
9156             });
9157             socket.onopen = function (e) {
9158                 var _socket = _this._socket;
9159                 if (!_socket) {
9160                     socket.close();
9161                     _this._resetState();
9162                     return;
9163                 }
9164                 var openObserver = _this._config.openObserver;
9165                 if (openObserver) {
9166                     openObserver.next(e);
9167                 }
9168                 var queue = _this.destination;
9169                 _this.destination = Subscriber.create(function (x) {
9170                     if (socket.readyState === 1) {
9171                         try {
9172                             var serializer = _this._config.serializer;
9173                             socket.send(serializer(x));
9174                         }
9175                         catch (e) {
9176                             _this.destination.error(e);
9177                         }
9178                     }
9179                 }, function (e) {
9180                     var closingObserver = _this._config.closingObserver;
9181                     if (closingObserver) {
9182                         closingObserver.next(undefined);
9183                     }
9184                     if (e && e.code) {
9185                         socket.close(e.code, e.reason);
9186                     }
9187                     else {
9188                         observer.error(new TypeError(WEBSOCKETSUBJECT_INVALID_ERROR_OBJECT));
9189                     }
9190                     _this._resetState();
9191                 }, function () {
9192                     var closingObserver = _this._config.closingObserver;
9193                     if (closingObserver) {
9194                         closingObserver.next(undefined);
9195                     }
9196                     socket.close();
9197                     _this._resetState();
9198                 });
9199                 if (queue && queue instanceof ReplaySubject) {
9200                     subscription.add(queue.subscribe(_this.destination));
9201                 }
9202             };
9203             socket.onerror = function (e) {
9204                 _this._resetState();
9205                 observer.error(e);
9206             };
9207             socket.onclose = function (e) {
9208                 _this._resetState();
9209                 var closeObserver = _this._config.closeObserver;
9210                 if (closeObserver) {
9211                     closeObserver.next(e);
9212                 }
9213                 if (e.wasClean) {
9214                     observer.complete();
9215                 }
9216                 else {
9217                     observer.error(e);
9218                 }
9219             };
9220             socket.onmessage = function (e) {
9221                 try {
9222                     var deserializer = _this._config.deserializer;
9223                     observer.next(deserializer(e));
9224                 }
9225                 catch (err) {
9226                     observer.error(err);
9227                 }
9228             };
9229         };
9230         WebSocketSubject.prototype._subscribe = function (subscriber) {
9231             var _this = this;
9232             var source = this.source;
9233             if (source) {
9234                 return source.subscribe(subscriber);
9235             }
9236             if (!this._socket) {
9237                 this._connectSocket();
9238             }
9239             this._output.subscribe(subscriber);
9240             subscriber.add(function () {
9241                 var _socket = _this._socket;
9242                 if (_this._output.observers.length === 0) {
9243                     if (_socket && _socket.readyState === 1) {
9244                         _socket.close();
9245                     }
9246                     _this._resetState();
9247                 }
9248             });
9249             return subscriber;
9250         };
9251         WebSocketSubject.prototype.unsubscribe = function () {
9252             var _socket = this._socket;
9253             if (_socket && _socket.readyState === 1) {
9254                 _socket.close();
9255             }
9256             this._resetState();
9257             _super.prototype.unsubscribe.call(this);
9258         };
9259         return WebSocketSubject;
9260     }(AnonymousSubject));
9261
9262     function webSocket(urlConfigOrSource) {
9263         return new WebSocketSubject(urlConfigOrSource);
9264     }
9265
9266
9267
9268     var _webSocket = /*#__PURE__*/Object.freeze({
9269         webSocket: webSocket,
9270         WebSocketSubject: WebSocketSubject
9271     });
9272
9273     function fromFetch(input, initWithSelector) {
9274         if (initWithSelector === void 0) { initWithSelector = {}; }
9275         var selector = initWithSelector.selector, init = __rest(initWithSelector, ["selector"]);
9276         return new Observable(function (subscriber) {
9277             var controller = new AbortController();
9278             var signal = controller.signal;
9279             var abortable = true;
9280             var unsubscribed = false;
9281             var subscription = new Subscription();
9282             subscription.add(function () {
9283                 unsubscribed = true;
9284                 if (abortable) {
9285                     controller.abort();
9286                 }
9287             });
9288             var perSubscriberInit;
9289             if (init) {
9290                 if (init.signal) {
9291                     if (init.signal.aborted) {
9292                         controller.abort();
9293                     }
9294                     else {
9295                         var outerSignal_1 = init.signal;
9296                         var outerSignalHandler_1 = function () {
9297                             if (!signal.aborted) {
9298                                 controller.abort();
9299                             }
9300                         };
9301                         outerSignal_1.addEventListener('abort', outerSignalHandler_1);
9302                         subscription.add(function () { return outerSignal_1.removeEventListener('abort', outerSignalHandler_1); });
9303                     }
9304                 }
9305                 perSubscriberInit = __assign({}, init, { signal: signal });
9306             }
9307             else {
9308                 perSubscriberInit = { signal: signal };
9309             }
9310             fetch(input, perSubscriberInit).then(function (response) {
9311                 if (selector) {
9312                     subscription.add(from(selector(response)).subscribe(function (value) { return subscriber.next(value); }, function (err) {
9313                         abortable = false;
9314                         if (!unsubscribed) {
9315                             subscriber.error(err);
9316                         }
9317                     }, function () {
9318                         abortable = false;
9319                         subscriber.complete();
9320                     }));
9321                 }
9322                 else {
9323                     abortable = false;
9324                     subscriber.next(response);
9325                     subscriber.complete();
9326                 }
9327             }).catch(function (err) {
9328                 abortable = false;
9329                 if (!unsubscribed) {
9330                     subscriber.error(err);
9331                 }
9332             });
9333             return subscription;
9334         });
9335     }
9336
9337
9338
9339     var _fetch = /*#__PURE__*/Object.freeze({
9340         fromFetch: fromFetch
9341     });
9342
9343     var operators = _operators;
9344     var testing = _testing;
9345     var ajax$1 = _ajax;
9346     var webSocket$1 = _webSocket;
9347     var fetch$1 = _fetch;
9348
9349     exports.operators = operators;
9350     exports.testing = testing;
9351     exports.ajax = ajax$1;
9352     exports.webSocket = webSocket$1;
9353     exports.fetch = fetch$1;
9354     exports.Observable = Observable;
9355     exports.ConnectableObservable = ConnectableObservable;
9356     exports.GroupedObservable = GroupedObservable;
9357     exports.observable = observable;
9358     exports.Subject = Subject;
9359     exports.BehaviorSubject = BehaviorSubject;
9360     exports.ReplaySubject = ReplaySubject;
9361     exports.AsyncSubject = AsyncSubject;
9362     exports.asap = asap;
9363     exports.asapScheduler = asapScheduler;
9364     exports.async = async;
9365     exports.asyncScheduler = asyncScheduler;
9366     exports.queue = queue;
9367     exports.queueScheduler = queueScheduler;
9368     exports.animationFrame = animationFrame;
9369     exports.animationFrameScheduler = animationFrameScheduler;
9370     exports.VirtualTimeScheduler = VirtualTimeScheduler;
9371     exports.VirtualAction = VirtualAction;
9372     exports.Scheduler = Scheduler;
9373     exports.Subscription = Subscription;
9374     exports.Subscriber = Subscriber;
9375     exports.Notification = Notification;
9376     exports.pipe = pipe;
9377     exports.noop = noop;
9378     exports.identity = identity;
9379     exports.isObservable = isObservable;
9380     exports.ArgumentOutOfRangeError = ArgumentOutOfRangeError;
9381     exports.EmptyError = EmptyError;
9382     exports.ObjectUnsubscribedError = ObjectUnsubscribedError;
9383     exports.UnsubscriptionError = UnsubscriptionError;
9384     exports.TimeoutError = TimeoutError;
9385     exports.bindCallback = bindCallback;
9386     exports.bindNodeCallback = bindNodeCallback;
9387     exports.combineLatest = combineLatest;
9388     exports.concat = concat;
9389     exports.defer = defer;
9390     exports.empty = empty$1;
9391     exports.forkJoin = forkJoin;
9392     exports.from = from;
9393     exports.fromEvent = fromEvent;
9394     exports.fromEventPattern = fromEventPattern;
9395     exports.generate = generate;
9396     exports.iif = iif;
9397     exports.interval = interval;
9398     exports.merge = merge;
9399     exports.never = never;
9400     exports.of = of;
9401     exports.onErrorResumeNext = onErrorResumeNext;
9402     exports.pairs = pairs;
9403     exports.partition = partition;
9404     exports.race = race;
9405     exports.range = range;
9406     exports.throwError = throwError;
9407     exports.timer = timer;
9408     exports.using = using;
9409     exports.zip = zip;
9410     exports.scheduled = scheduled;
9411     exports.EMPTY = EMPTY;
9412     exports.NEVER = NEVER;
9413     exports.config = config;
9414
9415     Object.defineProperty(exports, '__esModule', { value: true });
9416
9417 })));
9418
9419 //# sourceMappingURL=rxjs.umd.js.map
9420