// Copyright (c) Microsoft Corporation.  All rights reserved.
// This code is licensed by Microsoft Corporation under the terms
// of the MICROSOFT REACTIVE EXTENSIONS FOR JAVASCRIPT AND .NET LIBRARIES License.
// See http://go.microsoft.com/fwlink/?LinkId=186234.

(function(){var a;var b;var c=this;var d="Index out of range";if(typeof ProvideCustomRxRootObject =="undefined")b=c.Rx={}; else b=ProvideCustomRxRootObject();var e=function(){};var f=function(){return new Date().getTime();};var g=function(f0,g0){return f0===g0;};var h=function(f0){return f0;};var i=function(f0){return {Dispose:f0};};var j={Dispose:e};b.Disposable={Create:i,Empty:j};var k=b.BooleanDisposable=function(){var f0=false;this.GetIsDisposed=function(){return f0;};this.Dispose=function(){f0=true;};};var l=function(f0){var g0=false;f0.a++;this.Dispose=function(){var h0=false;if(!f0.b){if(!this.c){this.c=true;f0.a--;if(f0.a==0&&f0.d){f0.b=true;h0=true;}}}if(h0)f0.e.Dispose();};};var m=b.RefCountDisposable=function(f0){this.d=false;this.b=false;this.e=f0;this.a=0;this.Dispose=function(){var g0=false;if(!this.b){if(!this.d){this.d=true;if(this.a==0){this.b=true;g0=true;}}}if(g0)this.e.Dispose();};this.GetDisposable=function(){if(this.b)return j; else return new l(this);};};var n=b.CompositeDisposable=function(){var f0=new q();for(var g0=0;g0<arguments.length;g0++) f0.Add(arguments[g0]);var h0=false;this.GetCount=function(){return f0.GetCount();};this.Add=function(i0){if(!h0)f0.Add(i0); else i0.Dispose();};this.Remove=function(i0,j0){if(!h0){var k0=f0.Remove(i0);if(!j0&k0)i0.Dispose();}};this.Dispose=function(){if(!h0){h0=true;this.Clear();}};this.Clear=function(){for(var i0=0;i0<f0.GetCount();i0++) f0.GetItem(i0).Dispose();f0.Clear();};};var o=b.MutableDisposable=function(){var f0=false;var g0;this.Get=function(){return g0;},this.Replace=function(h0){if(f0)h0.Dispose(); else{if(g0!==a)g0.Dispose();g0=h0;}};this.Dispose=function(){if(!f0){f0=true;if(g0!==a)g0.Dispose();}};};var p=function(f0){var g0=[];for(var h0=0;h0<f0.length;h0++) g0.push(f0[h0]);return g0;};var q=b.List=function(f0){var g0=[];var h0=0;var i0=f0!==a?f0:g;this.Add=function(j0){g0[h0]=j0;h0++;};this.RemoveAt=function(j0){if(j0<0||j0>=h0)throw d;if(j0==0){g0.shift();h0--;}else{for(var k0=j0;k0<h0-1;k0++) g0[k0]=g0[k0+1];h0--;delete g0[h0];}};this.IndexOf=function(j0){for(var k0=0;k0<h0;k0++){if(i0(j0,g0[k0]))return k0;}return -1;};this.Remove=function(j0){var k0=this.IndexOf(j0);if(k0==-1)return false;this.RemoveAt(k0);return true;};this.Clear=function(){g0=[];h0=0;};this.GetCount=function(){return h0;};this.GetItem=function(j0){if(j0<0||j0>=h0)throw d;return g0[j0];};this.SetItem=function(j0,k0){if(j0<0||j0>=h0)throw d;g0[j0]=k0;};this.ToArray=function(){var j0=[];for(var k0=0;k0<this.GetCount();k0++) j0.push(this.GetItem(k0));return j0;};};var r=b.Scheduler=function(f0,g0,h0){this.Schedule=f0;this.ScheduleWithTime=g0;this.Now=h0;this.ScheduleRecursive=function(i0){var j0=this;var k0=new n();var l0;l0=function(){i0(function(){var m0=false;var n0=false;var o0;o0=j0.Schedule(function(){l0();if(m0)k0.Remove(o0); else n0=true;});if(!n0){k0.Add(o0);m0=true;}});};k0.Add(j0.Schedule(l0));return k0;};this.ScheduleRecursiveWithTime=function(i0,j0){var k0=this;var l0=new n();var m0;m0=function(){i0(function(n0){var o0=false;var p0=false;var q0;q0=k0.ScheduleWithTime(function(){m0();if(o0)l0.Remove(q0); else p0=true;},n0);if(!p0){l0.Add(q0);o0=true;}});};l0.Add(k0.ScheduleWithTime(m0,j0));return l0;};};var s=new r(function(f0){if(this.f===a){try{this.f=new q();this.f.Add(f0);while(this.f.GetCount()>0){var g0=this.f.GetItem(0);this.f.RemoveAt(0);g0();}delete this.f;}catch(i0){delete this.f;throw i0;}return j;}else{this.f.Add(f0);var h0=this;return i(function(){if(h0.f!==a)h0.f.Remove(f0);});}},function(f0,g0){this.g(function(){while(this.Now()<g0);f0();});},f);s.g=function(f0){if(this.f===a)try{this.f=new q();f0();while(this.f.GetCount()>0){var g0=this.f.GetItem(0);this.f.RemoveAt(0);g0();}delete this.f;}catch(h0){delete this.f;throw h0;} else f0();};r.CurrentThread=s;var t=new r(function(f0){f0();return j;},function(f0,g0){while(this.Now<g0);f0();},f);r.Immediate=t;var u=new r(function(f0){var g0=c.setTimeout(f0,0);return i(function(){c.clearTimeout(g0);});},function(f0,g0){var h0=c.setTimeout(f0,g0);return i(function(){c.clearTimeout(h0);});},f);r.Timeout=u;var v=b.Observer=function(f0,g0,h0){this.OnNext=f0===a?e:f0;this.OnError=g0===a?function(i0){throw i0;}:g0;this.OnCompleted=h0===a?e:h0;this.AsObserver=function(){var i0=this;return new v(function(j0){i0.OnNext(j0);},function(j0){i0.OnError(j0);},function(){i0.OnCompleted();});};};var w=v.Create=function(f0,g0,h0){return new v(f0,g0,h0);};var x=b.Observable=function(f0){this.h=f0;};var y=x.CreateWithDisposable=function(f0){return new x(f0);};var z=x.Create=function(f0){return y(function(g0){return i(f0(g0));});};var A=function(){return this.Select(function(f0){return f0.Value;});};x.prototype={Subscribe:function(f0,g0,h0){var i0;if(arguments.length==0||arguments.length>1||typeof f0 =="function")i0=new v(f0,g0,h0); else i0=f0;return this.i(i0);},i:function(f0){var g0=false;var h0=new o();var i0=this;s.g(function(){h0.Replace(i0.h(new v(function(j0){if(!g0)f0.OnNext(j0);},function(j0){if(!g0){g0=true;h0.Dispose();f0.OnError(j0);}},function(){if(!g0){g0=true;h0.Dispose();f0.OnCompleted();}})));});return h0;},Select:function(f0){var g0=this;return y(function(h0){var i0=0;return g0.Subscribe(new v(function(j0){var k0;try{k0=f0(j0,i0++);}catch(l0){h0.OnError(l0);return;}h0.OnNext(k0);},function(j0){h0.OnError(j0);},function(){h0.OnCompleted();}));});},Let:function(f0,g0){if(g0===a)return f0(this);var h0=this;return y(function(i0){var j0=g0();var k0;try{k0=f0(j0);}catch(o0){return F(o0).Subscribe(i0);}var l0=new o();var m0=new o();var n0=new n(m0,l0);l0.Replace(k0.Subscribe(function(o0){i0.OnNext(o0);},function(o0){i0.OnError(o0);n0.Dispose();},function(){i0.OnCompleted();n0.Dispose();}));m0.Replace(h0.Subscribe(j0));return n0;});},MergeObservable:function(){var f0=this;return y(function(g0){var h0=false;var i0=new n();var j0=new o();i0.Add(j0);j0.Replace(f0.Subscribe(function(k0){var l0=new o();i0.Add(l0);l0.Replace(k0.Subscribe(function(m0){g0.OnNext(m0);},function(m0){g0.OnError(m0);},function(){i0.Remove(l0);if(i0.GetCount()==1&&h0)g0.OnCompleted();}));},function(k0){g0.OnError(k0);},function(){h0=true;if(i0.GetCount()==1)g0.OnCompleted();}));return i0;});},j:function(f0,g0){var h0=p(g0);h0.unshift(this);return f0(h0);},Concat:function(){return this.j(C,arguments);},Merge:function(){return this.j(B,arguments);},Catch:function(){return this.j(J,arguments);},OnErrorResumeNext:function(){return this.j(P,arguments);},Zip:function(f0,g0){var h0=this;return y(function(i0){var j0=false;var k0=[];var l0=[];var m0=false;var n0=false;var o0=new n();var p0=function(q0){o0.Dispose();k0=a;l0=a;i0.OnError(q0);};o0.Add(h0.Subscribe(function(q0){if(n0){i0.OnCompleted();return;}if(l0.length>0){var r0=l0.shift();var s0;try{s0=g0(q0,r0);}catch(t0){o0.Dispose();i0.OnError(t0);return;}i0.OnNext(s0);}else k0.push(q0);},p0,function(){if(n0){i0.OnCompleted();return;}m0=true;}));o0.Add(f0.Subscribe(function(q0){if(m0){i0.OnCompleted();return;}if(k0.length>0){var r0=k0.shift();var s0;try{s0=g0(r0,q0);}catch(t0){o0.Dispose();i0.OnError(t0);return;}i0.OnNext(s0);}else l0.push(q0);},p0,function(){if(m0){i0.OnCompleted();return;}n0=true;}));return o0;});},CombineLatest:function(f0,g0){var h0=this;return y(function(i0){var j0=false;var k0=false;var l0=false;var m0;var n0;var o0=false;var p0=false;var q0=new n();var r0=function(s0){q0.Dispose();i0.OnError(s0);};q0.Add(h0.Subscribe(function(s0){if(p0){i0.OnCompleted();return;}if(l0){var t0;try{t0=g0(s0,n0);}catch(u0){q0.Dispose();i0.OnError(u0);return;}i0.OnNext(t0);}m0=s0;k0=true;},r0,function(){if(p0){i0.OnCompleted();return;}o0=true;}));q0.Add(f0.Subscribe(function(s0){if(o0){i0.OnCompleted();return;}if(k0){var t0;try{t0=g0(m0,s0);}catch(u0){q0.Dispose();i0.OnError(u0);return;}i0.OnNext(t0);}n0=s0;l0=true;},r0,function(){if(o0){i0.OnCompleted();return;}p0=true;}));});},Switch:function(){var f0=this;return y(function(g0){var h0=false;var i0=new o();var j0=new o();j0.Replace(f0.Subscribe(function(k0){if(!h0)i0.Replace(k0.Subscribe(function(l0){g0.OnNext(l0);},function(l0){j0.Dispose();i0.Dispose();g0.OnError(l0);},function(){i0.Replace(a);if(h0)g0.OnCompleted();}));},function(k0){i0.Dispose();g0.OnError(k0);},function(){h0=true;if(i0.Get()===a)g0.OnCompleted();}));return new n(j0,i0);});},TakeUntil:function(f0){var g0=this;return y(function(h0){var i0=new n();i0.Add(f0.Subscribe(function(){h0.OnCompleted();i0.Dispose();},function(j0){h0.OnError(j0);},function(){}));i0.Add(g0.Subscribe(h0));return i0;});},SkipUntil:function(f0){var g0=this;return y(function(h0){var i0=true;var j0=new n();j0.Add(f0.Subscribe(function(){i0=false;},function(k0){h0.OnError(k0);},e));j0.Add(g0.Subscribe(new v(function(k0){if(!i0)h0.OnNext(k0);},function(k0){h0.OnError(k0);},function(){if(!i0)h0.OnCompleted();})));return j0;});},Scan1:function(f0){var g0=this;return I(function(){var h0;var i0=false;return g0.Select(function(j0){if(i0)h0=f0(h0,j0); else{h0=j0;i0=true;}return h0;});});},Scan:function(f0,g0){var h0=this;return I(function(){var i0;var j0=false;return h0.Select(function(k0){if(j0)i0=g0(i0,k0); else{i0=g0(f0,k0);j0=true;}return i0;});});},Scan0:function(f0,g0){var h0=this;return y(function(i0){var j0=f0;var k0=true;return h0.Subscribe(function(l0){if(k0){k0=false;i0.OnNext(j0);}try{j0=g0(j0,l0);}catch(m0){i0.OnError(m0);return;}i0.OnNext(j0);},function(l0){if(k0)i0.OnNext(j0);i0.OnError(l0);},function(){if(k0)i0.OnNext(j0);i0.OnCompleted();});});},Finally:function(f0){var g0=this;return z(function(h0){var i0=g0.Subscribe(h0);return function(){try{i0.Dispose();f0();}catch(j0){f0();throw j0;}};});},Do:function(f0,g0,h0){var i0=this;return y(function(j0){return i0.Subscribe(new v(function(k0){if(f0!==a)f0(k0);j0.OnNext(k0);},function(k0){if(g0!==a)g0(k0);j0.OnError(k0);},function(){if(h0!==a)h0();j0.OnCompleted();}));});},Where:function(f0){var g0=this;return y(function(h0){var i0=0;return g0.Subscribe(new v(function(j0){var k0=false;try{k0=f0(j0,i0++);}catch(l0){h0.OnError(l0);return;}if(k0)h0.OnNext(j0);},function(j0){h0.OnError(j0);},function(){h0.OnCompleted();}));});},Take:function(f0,g0){if(g0===a)g0=t;var h0=this;return y(function(i0){if(f0<=0){h0.Subscribe().Dispose();return H(g0).Subscribe(i0);}var j0=f0;return h0.Subscribe(new v(function(k0){if(j0-->0){i0.OnNext(k0);if(j0==0)i0.OnCompleted();}},function(k0){i0.OnError(k0);},function(){i0.OnCompleted();}));});},GroupBy:function(f0,g0,h0){if(f0===a)f0=h;if(g0===a)g0=h;if(h0===a)h0=function(j0){return j0.toString();};var i0=this;return y(function(j0){var k0={};var l0=new o();var m0=new m(l0);l0.Replace(i0.Subscribe(function(n0){var o0;try{o0=f0(n0);}catch(u0){for(var v0 in k0) k0[v0].OnError(u0);j0.OnError(u0);return;}var p0=false;var q0;try{var r0=h0(o0);if(k0[r0]===a){q0=new W();k0[r0]=q0;p0=true;}else q0=k0[r0];}catch(u0){for(var v0 in k0) k0[v0].OnError(u0);j0.OnError(u0);return;}if(p0){var s0=y(function(u0){return new n(m0.GetDisposable(),q0.Subscribe(u0));});s0.Key=o0;j0.OnNext(s0);}var t0;try{t0=g0(n0);}catch(u0){for(var v0 in k0) k0[v0].OnError(u0);j0.OnError(u0);return;}q0.OnNext(t0);},function(n0){for(var o0 in k0) k0[o0].OnError(n0);j0.OnError(n0);},function(){for(var n0 in k0) k0[n0].OnCompleted();j0.OnCompleted();}));return m0;});},TakeWhile:function(f0){var g0=this;return y(function(h0){var i0=true;return g0.Subscribe(new v(function(j0){if(i0){try{i0=f0(j0);}catch(k0){h0.OnError(k0);return;}if(i0)h0.OnNext(j0); else h0.OnCompleted();}},function(j0){h0.OnError(j0);},function(){h0.OnCompleted();}));});},SkipWhile:function(f0){var g0=this;return y(function(h0){var i0=false;return g0.Subscribe(new v(function(j0){if(!i0)try{i0=!f0(j0);}catch(k0){h0.OnError(k0);return;}if(i0)h0.OnNext(j0);},function(j0){h0.OnError(j0);},function(){h0.OnCompleted();}));});},Skip:function(f0){var g0=this;return y(function(h0){var i0=f0;return g0.Subscribe(new v(function(j0){if(i0--<=0)h0.OnNext(j0);},function(j0){h0.OnError(j0);},function(){h0.OnCompleted();}));});},SelectMany:function(f0){return this.Select(f0).MergeObservable();},TimeInterval:function(f0){if(f0===a)f0=t;var g0=this;return I(function(){var h0=f0.Now();return g0.Select(function(i0){var j0=f0.Now();var k0=j0-h0;h0=j0;return {Interval:k0,Value:i0};});});},RemoveInterval:A,Timestamp:function(f0){if(f0===a)f0=t;return this.Select(function(g0){return {Timestamp:f0.Now(),Value:g0};});},RemoveTimestamp:A,Materialize:function(){var f0=this;return y(function(g0){return f0.Subscribe(new v(function(h0){g0.OnNext(new V("N",h0));},function(h0){g0.OnNext(new V("E",h0));g0.OnCompleted();},function(){g0.OnNext(new V("C"));g0.OnCompleted();}));});},Dematerialize:function(){return this.SelectMany(function(f0){return f0;});},AsObservable:function(){var f0=this;return y(function(g0){return f0.Subscribe(g0);});},Delay:function(f0,g0){if(g0===a)g0=u;var h0=this;return y(function(i0){var j0=[];var k0=false;var l0=new o();var m0=h0.Materialize().Timestamp().Subscribe(function(n0){if(n0.Value.Kind=="E"){i0.OnError(n0.Value.Value);j0=[];if(k0)l0.Dispose();return;}j0.push({Timestamp:g0.Now()+f0,Value:n0.Value});if(!k0){l0.Replace(g0.ScheduleRecursiveWithTime(function(o0){var p0;do{p0=a;if(j0.length>0&&j0[0].Timestamp<=g0.Now())p0=j0.shift().Value;if(p0!==a)p0.Accept(i0);}while(p0!==a);if(j0.length>0){o0(Math.max(0,j0[0].Timestamp-g0.Now()));k0=true;}else k0=false;},f0));k0=true;}});return new n(m0,l0);});},Throttle:function(f0,g0){if(g0===a)g0=u;var h0=this;return y(function(i0){var j0;var k0=false;var l0=new o();var m0=0;var n0=h0.Subscribe(function(o0){k0=true;j0=o0;m0++;var p0=m0;l0.Replace(g0.ScheduleWithTime(function(){if(k0&&m0==p0)i0.OnNext(j0);k0=false;},f0));},function(o0){l0.Dispose();i0.OnError(o0);k0=false;m0++;},function(){l0.Dispose();if(k0)i0.OnNext(j0);i0.OnCompleted();k0=false;m0++;});return new n(n0,l0);});},Timeout:function(f0,g0,h0){if(h0===a)h0=u;if(g0===a)g0=F("Timeout",h0);var i0=this;return y(function(j0){var k0=new o();var l0=new o();var m0=0;var n0=m0;var o0=false;l0.Replace(h0.ScheduleWithTime(function(){o0=m0==n0;if(o0)k0.Replace(g0.Subscribe(j0));},f0));k0.Replace(i0.Subscribe(function(p0){var q0=0;if(!o0){m0++;q0=m0;j0.OnNext(p0);l0.Replace(h0.ScheduleWithTime(function(){o0=m0==q0;if(o0)k0.Replace(g0.Subscribe(j0));},f0));}},function(p0){if(!o0){m0++;j0.OnError(p0);}},function(){if(!o0){m0++;j0.OnCompleted();}}));return new n(k0,l0);});},Sample:function(f0,g0){if(g0===a)g0=u;var h0=this;return y(function(i0){var j0=false;var k0;var l0=false;var m0=new n();m0.Add(S(f0,g0).Subscribe(function(n0){if(j0){i0.OnNext(k0);j0=false;}if(l0)i0.OnCompleted();},function(n0){i0.OnError(n0);},function(){i0.OnCompleted();}));m0.Add(h0.Subscribe(function(n0){j0=true;k0=n0;},function(n0){i0.OnError(n0);m0.Dispose();},function(){l0=true;}));return m0;});},Repeat:function(f0,g0){var h0=this;if(g0===a)g0=t;if(f0===a)f0=-1;return y(function(i0){var j0=f0;var k0=new o();var l0=new n(k0);var m0=function(n0){k0.Replace(h0.Subscribe(function(o0){i0.OnNext(o0);},function(o0){i0.OnError(o0);},function(){if(j0>0){j0--;if(j0==0){i0.OnCompleted();return;}}n0();}));};l0.Add(g0.ScheduleRecursive(m0));return l0;});},Retry:function(f0,g0){var h0=this;if(g0===a)g0=t;if(f0===a)f0=-1;return y(function(i0){var j0=f0;var k0=new o();var l0=new n(k0);var m0=function(n0){k0.Replace(h0.Subscribe(function(o0){i0.OnNext(o0);},function(o0){if(j0>0){j0--;if(j0==0){i0.OnError(o0);return;}}n0();},function(){i0.OnCompleted();}));};l0.Add(g0.ScheduleRecursive(m0));return l0;});},BufferWithTime:function(f0,g0,h0){if(h0===a)h0=u;if(g0===a)g0=f0;var i0=this;return y(function(j0){var k0=new q();var l0=h0.Now();var m0=function(){var q0=[];for(var r0=0;r0<k0.GetCount();r0++){var s0=k0.GetItem(r0);if(s0.Timestamp-l0>=0)q0.push(s0.Value);}return q0;};var n0=new n();var o0=function(q0){j0.OnError(q0);};var p0=function(){j0.OnNext(m0());j0.OnCompleted();};n0.Add(i0.Subscribe(function(q0){k0.Add({Value:q0,Timestamp:h0.Now()});},o0,p0));n0.Add(U(f0,g0,h0).Subscribe(function(q0){var r0=m0();var s0=h0.Now()+g0-f0;while(k0.GetCount()>0&&k0.GetItem(0).Timestamp-s0<=0)k0.RemoveAt(0);j0.OnNext(r0);l0=s0;},o0,p0));return n0;});},BufferWithTimeOrCount:function(f0,g0,h0){if(h0===a)h0=u;var i0=this;return y(function(j0){var k0=0;var l0=new q();var m0=function(){j0.OnNext(l0.ToArray());l0.Clear();k0++;};var n0=new o();var o0;o0=function(q0){var r0=h0.ScheduleWithTime(function(){var s0=false;var t0=0;if(q0==k0){m0();t0=k0;s0=true;}if(s0)o0(t0);},f0);n0.Replace(r0);};o0(k0);var p0=i0.Subscribe(function(q0){var r0=false;var s0=0;l0.Add(q0);if(l0.GetCount()==g0){m0();s0=k0;r0=true;}if(r0)o0(s0);},function(q0){j0.OnError(q0);l0.Clear();},function(){j0.OnNext(l0.ToArray());k0++;j0.OnCompleted();l0.Clear();});return new n(p0,n0);});},BufferWithCount:function(f0,g0){if(g0===a)g0=f0;var h0=this;return y(function(i0){var j0=[];var k0=0;return h0.Subscribe(function(l0){if(k0==0)j0.push(l0); else k0--;var m0=j0.length;if(m0==f0){var n0=j0;j0=[];var o0=Math.min(g0,m0);for(var p0=o0;p0<m0;p0++) j0.push(n0[p0]);k0=Math.max(0,g0-f0);i0.OnNext(n0);}},function(l0){i0.OnError(l0);},function(){if(j0.length>0)i0.OnNext(j0);i0.OnCompleted();});});},StartWith:function(f0,g0){if(!(f0 instanceof Array))f0=[f0];if(g0===a)g0=t;var h0=this;return y(function(i0){var j0=new n();var k0=0;j0.Add(g0.ScheduleRecursive(function(l0){if(k0<f0.length){i0.OnNext(f0[k0]);k0++;l0();}else j0.Add(h0.Subscribe(i0));}));return j0;});},DistinctUntilChanged:function(f0,g0){if(f0===a)f0=h;if(g0===a)g0=g;var h0=this;return y(function(i0){var j0;var k0=false;return h0.Subscribe(function(l0){var m0;try{m0=f0(l0);}catch(o0){i0.OnError(o0);return;}var n0=false;if(k0)try{n0=g0(j0,m0);}catch(o0){i0.OnError(o0);return;}if(!k0||!n0){k0=true;j0=m0;i0.OnNext(l0);}},function(l0){i0.OnError(l0);},function(){i0.OnCompleted();});});},Publish:function(f0){if(f0===a)return new e0(this,new W());var g0=this;return y(function(h0){var i0=new e0(g0,new W());return new n(f0(i0).Subscribe(v),i0.Connect());});},Prune:function(f0,g0){if(g0===a)g0=s;if(f0===a)return new e0(this,new Y(g0));var h0=this;return y(function(i0){var j0=new e0(h0,new Y(g0));return new n(f0(j0).Subscribe(v),j0.Connect());});},Replay:function(f0,g0,h0,i0){if(i0===a)i0=s;if(f0===a)return new e0(this,new a0(g0,h0,i0));var j0=this;return y(function(k0){var l0=new e0(j0,new a0(g0,h0,i0));return new n(f0(l0).Subscribe(v),l0.Connect());});},SkipLast:function(f0){var g0=this;return y(function(h0){var i0=[];return g0.Subscribe(function(j0){i0.push(j0);if(i0.length>f0)h0.OnNext(i0.shift());},function(j0){h0.OnError(j0);},function(){h0.OnCompleted();});});},TakeLast:function(f0){var g0=this;return y(function(h0){var i0=[];return g0.Subscribe(function(j0){i0.push(j0);if(i0.length>f0)i0.shift();},function(j0){h0.OnError(j0);},function(){while(i0.length>0)h0.OnNext(i0.shift());h0.OnCompleted();});});}};var B=x.Merge=function(f0,g0){if(g0===a)g0=s;return D(f0,g0).MergeObservable();};var C=x.Concat=function(f0,g0){if(g0===a)g0=t;return y(function(h0){var i0=new o();var j0=0;var k0=g0.ScheduleRecursive(function(l0){if(j0<f0.length){var m0=f0[j0];j0++;i0.Replace(m0.Subscribe(function(n0){h0.OnNext(n0);},function(n0){h0.OnError(n0);},l0));}else h0.OnCompleted();});return new n(i0,k0);});};var D=x.FromArray=function(f0,g0){if(g0===a)g0=s;return y(function(h0){var i0=0;return g0.ScheduleRecursive(function(j0){if(i0<f0.length){h0.OnNext(f0[i0++]);j0();}else h0.OnCompleted();});});};var E=x.Return=function(f0,g0){if(g0===a)g0=s;return y(function(h0){return g0.Schedule(function(){h0.OnNext(f0);h0.OnCompleted();});});};var F=x.Throw=function(f0,g0){if(g0===a)g0=s;return y(function(h0){return g0.Schedule(function(){h0.OnError(f0);});});};var G=x.Never=function(){return y(function(f0){return j;});};var H=x.Empty=function(f0){if(f0===a)f0=s;return y(function(g0){return f0.Schedule(function(){g0.OnCompleted();});});};var I=x.Defer=function(f0){return y(function(g0){var h0;try{h0=f0();}catch(i0){g0.OnError(i0);return e;}return h0.Subscribe(g0);});};var J=x.Catch=function(f0,g0){if(g0===a)g0=t;return y(function(h0){var i0=new o();var j0=0;var k0=g0.ScheduleRecursive(function(l0){var m0=f0[j0];j0++;i0.Replace(m0.Subscribe(function(n0){h0.OnNext(n0);},function(n0){if(j0<f0.length)l0(); else h0.OnError(n0);},function(){h0.OnCompleted();}));});return new n(i0,k0);});};var K=x.Using=function(f0,g0){return y(function(h0){var i0;var j0=j;try{var k0=f0();if(k0!==a)j0=k0;i0=g0(k0);}catch(l0){return new n(Throw(l0).Subscribe(h0),j0);}return new n(i0.Subscribe(h0),j0);});};var L=x.Range=function(f0,g0,h0){if(h0===a)h0=s;var i0=f0+g0-1;return N(f0,function(j0){return j0<=i0;},h,function(j0){return j0+1;},h0);};var M=x.Repeat=function(f0,g0,h0){if(h0===a)h0=s;if(g0===a)g0=-1;var i0=g0;return y(function(j0){return h0.ScheduleRecursive(function(k0){j0.OnNext(f0);if(i0>0){i0--;if(i0==0){j0.OnCompleted();return;}}k0();});});};var N=x.Generate=function(f0,g0,h0,i0,j0){if(j0===a)j0=s;return y(function(k0){var l0=f0;var m0=true;return j0.ScheduleRecursive(function(n0){var o0=false;var p0;try{if(m0)m0=false; else l0=i0(l0);o0=g0(l0);if(o0)p0=h0(l0);}catch(q0){k0.OnError(q0);return;}if(o0){k0.OnNext(p0);n0();}else k0.OnCompleted();});});};var O=x.GenerateWithTime=function(f0,g0,h0,i0,j0,k0){if(k0===a)k0=u;return new y(function(l0){var m0=f0;var n0=true;var o0=false;var p0;var q0;return k0.ScheduleRecursiveWithTime(function(r0){if(o0)l0.OnNext(p0);try{if(n0)n0=false; else m0=j0(m0);o0=g0(m0);if(o0){p0=h0(m0);q0=i0(m0);}}catch(s0){l0.OnError(s0);return;}if(o0)r0(q0); else l0.OnCompleted();},0);});};var P=x.OnErrorResumeNext=function(f0,g0){if(g0===a)g0=t;return y(function(h0){var i0=new o();var j0=0;var k0=g0.ScheduleRecursive(function(l0){if(j0<f0.length){var m0=f0[j0];j0++;i0.Replace(m0.Subscribe(function(n0){h0.OnNext(n0);},l0,l0));}else h0.OnCompleted();});return new n(i0,k0);});};var Q=x.Amb=function(){var f0=arguments;return y(function(g0){var h0=new n();var i0=new o();i0.Replace(h0);var j0=false;for(var k0=0;k0<f0.length;k0++){var l0=f0[k0];var m0=new o();var n0=new v(function(o0){g0.OnNext(o0);if(!j0){h0.Remove(this.k,true);h0.Dispose();i0.Replace(this.k);j0=true;}},function(o0){g0.OnError(o0);i0.Dispose();},function(){g0.OnCompleted();i0.Dispose();});n0.k=m0;m0.Replace(l0.Subscribe(n0));h0.Add(m0);}return i0;});};var R=x.ForkJoin=function(){var f0=arguments;return y(function(g0){var h0=[];var i0=[];var j0=[];var k0=new n();for(var l0=0;l0<f0.length;l0++) (function(m0){k0.Add(f0[m0].Subscribe(function(n0){h0[m0]=true;j0[m0]=n0;},function(n0){g0.OnError(n0);},function(n0){if(!h0[m0]){g0.OnCompleted();j0=a;h0=a;}i0[m0]=true;var o0=true;for(var p0=0;p0<f0.length;p0++){if(!i0[p0])o0=false;}if(o0){g0.OnNext(j0);g0.OnCompleted();j0=a;i0=a;h0=a;}}));})(l0);return k0;});};var S=x.Interval=function(f0,g0){return U(f0,f0,g0);};var T=function(f0){return Math.max(0,f0);};var U=x.Timer=function(f0,g0,h0){if(h0===a)h0=u;if(f0===a)return G();if(f0 instanceof Date)return I(function(){return x.Timer(f0-new Date(),g0,h0);});var i0=T(f0);if(g0===a)return y(function(k0){return h0.ScheduleWithTime(function(){k0.OnNext(0);k0.OnCompleted();},i0);});var j0=T(g0);return y(function(k0){var l0=0;return h0.ScheduleRecursiveWithTime(function(m0){k0.OnNext(l0++);m0(j0);},i0);});};var V=b.Notification=function(f0,g0){this.Kind=f0;this.Value=g0;this.toString=function(){return this.Kind+": "+this.Value;};this.Accept=function(h0){switch(this.Kind){case "N":h0.OnNext(this.Value);break;case "E":h0.OnError(this.Value);break;case "C":h0.OnCompleted();break;}return j;};this.h=function(h0){var i0=this.Accept(h0);if(f0=="N")h0.OnCompleted();return i0;};};V.prototype=new x;var W=b.Subject=function(){var f0=new q();var g0=false;this.OnNext=function(h0){if(!g0)for(var i0=0;i0<f0.GetCount();i0++){var j0=f0.GetItem(i0);j0.OnNext(h0);}};this.OnError=function(h0){if(!g0){for(var i0=0;i0<f0.GetCount();i0++){var j0=f0.GetItem(i0);j0.OnError(h0);}g0=true;f0.Clear();}};this.OnCompleted=function(){if(!g0){for(var h0=0;h0<f0.GetCount();h0++){var i0=f0.GetItem(h0);i0.OnCompleted();}g0=true;f0.Clear();}};this.h=function(h0){if(!g0){f0.Add(h0);return i(function(){f0.Remove(h0);});}else return j;};};W.prototype=new x;for(var X in v.prototype) W.prototype[X]=v.prototype[X];var Y=b.AsyncSubject=function(f0){var g0=new q();var h0;var i0=false;if(f0===a)f0=s;this.OnNext=function(j0){if(!i0)h0=new V("N",j0);};this.OnError=function(j0){if(!i0){h0=new V("E",j0);for(var k0=0;k0<g0.GetCount();k0++){var l0=g0.GetItem(k0);if(l0!==a)l0.OnError(j0);}i0=true;g0.Clear();}};this.OnCompleted=function(){if(!i0){if(h0===a)h0=new V("C");for(var j0=0;j0<g0.GetCount();j0++){var k0=g0.GetItem(j0);if(k0!==a)h0.h(k0);}i0=true;g0.Clear();}};this.h=function(j0){if(!i0){g0.Add(j0);return i(function(){g0.Remove(j0);});}else return f0.Schedule(function(){h0.h(j0);});};};Y.prototype=new W;var Z=b.BehaviorSubject=function(f0,g0){var h0=new a0(1,-1,g0);h0.OnNext(f0);return h0;};var a0=b.ReplaySubject=function(f0,g0,h0){var i0=new q();var j0=new q();var k0=false;if(h0===a)h0=s;var l0=g0>0;var m0=function(n0,o0){j0.Add({Value:new V(n0,o0),Timestamp:h0.Now()});};this.l=function(){if(f0!==a)while(j0.GetCount()>f0)j0.RemoveAt(0);if(l0)while(j0.GetCount()>0&&h0.Now()-j0.GetItem(0).Timestamp>g0)j0.RemoveAt(0);};this.OnNext=function(n0){if(!k0){for(var o0=0;o0<i0.GetCount();o0++){var p0=i0.GetItem(o0);p0.OnNext(n0);}m0("N",n0);}};this.OnError=function(n0){if(!k0){for(var o0=0;o0<i0.GetCount();o0++){var p0=i0.GetItem(o0);p0.OnError(n0);}k0=true;i0.Clear();m0("E",n0);}};this.OnCompleted=function(){if(!k0){for(var n0=0;n0<i0.GetCount();n0++){var o0=i0.GetItem(n0);o0.OnCompleted();}k0=true;i0.Clear();m0("C");}};this.h=function(n0){var o0=new b0(this,n0);var p0=new n(o0);var q0=this;p0.Add(h0.Schedule(function(){if(!o0.m){q0.l();for(var r0=0;r0<j0.GetCount();r0++) j0.GetItem(r0).Value.Accept(n0);i0.Add(n0);o0.n=true;}}));return p0;};this.o=function(n0){i0.Remove(n0);};};a0.prototype=new W;var b0=function(f0,g0){this.p=f0;this.q=g0;this.n=false;this.m=false;this.Dispose=function(){if(this.n)this.p.o(this.q);this.m=true;};};var c0=x.ToAsync=function(f0,g0){if(g0===a)g0=u;return function(){var h0=new Y(g0);var i0=function(){var l0;try{l0=f0.apply(this,arguments);}catch(m0){h0.OnError(m0);return;}h0.OnNext(l0);h0.OnCompleted();};var j0=this;var k0=p(arguments);g0.Schedule(function(){i0.apply(j0,k0);});return h0;};};var d0=x.Start=function(f0,g0,h0,i0){if(h0===a)h0=[];return c0(f0,i0).apply(g0,h0);};var e0=b.ConnectableObservable=function(f0,g0){if(g0===a)g0=new W();this.p=g0;this.r=f0;this.s=false;this.t;this.Connect=function(){var h0;var i0=false;if(!this.s){this.s=true;var j0=this;h0=new n(i(function(){j0.s=false;}));this.t=h0;h0.Add(f0.Subscribe(this.p));}return this.t;};this.h=function(h0){return this.p.Subscribe(h0);};this.RefCount=function(){var h0=0;var i0=this;var j0;return z(function(k0){var l0=false;h0++;l0=h0==1;var m0=i0.Subscribe(k0);if(l0)j0=i0.Connect();return function(){m0.Dispose();h0--;if(h0==0)j0.Dispose();};});};};e0.prototype=new x;})();
