/* Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.*/ (function(a){function b(a){return a&&a.Object===Object?a:null}var c={"function":!0,object:!0},d=c[typeof exports]&&exports&&!exports.nodeType?exports:null,e=c[typeof module]&&module&&!module.nodeType?module:null,f=b(d&&e&&"object"==typeof global&&global),g=b(c[typeof self]&&self),h=b(c[typeof window]&&window),i=(e&&e.exports===d?d:null,b(c[typeof this]&&this)),j=f||h!==(i&&i.window)&&h||g||i||Function("return this")();"function"==typeof define&&define.amd?define(["./rx"],function(b,c){return a(j,c,b)}):"object"==typeof module&&module&&module.exports===d?module.exports=a(j,module.exports,require("./rx")):j.Rx=a(j,{},j.Rx)}).call(this,function(a,b,c,d){function e(a){return function(){try{return a.apply(this,arguments)}catch(b){return D.e=b,D}}}function f(a){return a.toArray()}function g(a,b){return a.groupJoin(this,b,t,function(a,b){return b})}function h(a){var b=this;return new v(function(c){var d=new r,e=new m,f=new o(e);return c.onNext(w(d,f)),e.add(b.subscribe(function(a){d.onNext(a)},function(a){d.onError(a),c.onError(a)},function(){d.onCompleted(),c.onCompleted()})),A(a)&&(a=C(a)),e.add(a.subscribe(function(a){d.onCompleted(),d=new r,c.onNext(w(d,f))},function(a){d.onError(a),c.onError(a)},function(){d.onCompleted(),c.onCompleted()})),f},b)}function i(a){var b=this;return new v(function(c){function d(){var b;try{b=a()}catch(f){return void c.onError(f)}A(b)&&(b=C(b));var i=new p;e.setDisposable(i),i.setDisposable(b.take(1).subscribe(z,function(a){h.onError(a),c.onError(a)},function(){h.onCompleted(),h=new r,c.onNext(w(h,g)),d()}))}var e=new q,f=new m(e),g=new o(f),h=new r;return c.onNext(w(h,g)),f.add(b.subscribe(function(a){h.onNext(a)},function(a){h.onError(a),c.onError(a)},function(){h.onCompleted(),c.onCompleted()})),d(),g},b)}var j=c.Observable,k=c.ObservableBase,l=c.internals.AbstractObserver,m=c.CompositeDisposable,n=c.BinaryDisposable,o=c.RefCountDisposable,p=c.SingleAssignmentDisposable,q=c.SerialDisposable,r=c.Subject,s=j.prototype,t=j.empty,u=j.never,v=c.AnonymousObservable,w=c.internals.addRef,x=c.internals.inherits,y=c.internals.bindCallback,z=c.helpers.noop,A=c.helpers.isPromise,B=c.helpers.isFunction,C=j.fromPromise,D={e:{}},E=c.internals.tryCatch=function(a){if(!B(a))throw new TypeError("fn must be a function");return e(a)},F=a.Map||function(){function a(){this.size=0,this._values=[],this._keys=[]}return a.prototype["delete"]=function(a){var b=this._keys.indexOf(a);return-1===b?!1:(this._values.splice(b,1),this._keys.splice(b,1),this.size--,!0)},a.prototype.get=function(a){var b=this._keys.indexOf(a);return-1===b?d:this._values[b]},a.prototype.set=function(a,b){var c=this._keys.indexOf(a);return-1===c?(this._keys.push(a),this._values.push(b),this.size++):this._values[c]=b,this},a.prototype.forEach=function(a,b){for(var c=0;c