/
rx.js
6 lines (5 loc) · 28 KB
/
rx.js
1
2
3
4
5
6
// 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(l0,m0){return l0===m0;};var h=function(l0){return l0;};var i=function(l0){return {Dispose:l0};};var j={Dispose:e};b.Disposable={Create:i,Empty:j};var k=b.BooleanDisposable=function(){var l0=false;this.GetIsDisposed=function(){return l0;};this.Dispose=function(){l0=true;};};var l=function(l0){var m0=false;l0.a++;this.Dispose=function(){var n0=false;if(!l0.b){if(!this.c){this.c=true;l0.a--;if(l0.a==0&&l0.d){l0.b=true;n0=true;}}}if(n0)l0.e.Dispose();};};var m=b.RefCountDisposable=function(l0){this.d=false;this.b=false;this.e=l0;this.a=0;this.Dispose=function(){var m0=false;if(!this.b){if(!this.d){this.d=true;if(this.a==0){this.b=true;m0=true;}}}if(m0)this.e.Dispose();};this.GetDisposable=function(){if(this.b)return j; else return new l(this);};};var n=b.CompositeDisposable=function(){var l0=new q();for(var m0=0;m0<arguments.length;m0++) l0.Add(arguments[m0]);var n0=false;this.GetCount=function(){return l0.GetCount();};this.Add=function(o0){if(!n0)l0.Add(o0); else o0.Dispose();};this.Remove=function(o0,p0){if(!n0){var q0=l0.Remove(o0);if(!p0&q0)o0.Dispose();}};this.Dispose=function(){if(!n0){n0=true;this.Clear();}};this.Clear=function(){for(var o0=0;o0<l0.GetCount();o0++) l0.GetItem(o0).Dispose();l0.Clear();};};var o=b.MutableDisposable=function(){var l0=false;var m0;this.Get=function(){return m0;},this.Replace=function(n0){if(l0&&n0!==a)n0.Dispose(); else{if(m0!==a)m0.Dispose();m0=n0;}};this.Dispose=function(){if(!l0){l0=true;if(m0!==a)m0.Dispose();}};};var p=function(l0){var m0=[];for(var n0=0;n0<l0.length;n0++) m0.push(l0[n0]);return m0;};var q=b.List=function(l0){var m0=[];var n0=0;var o0=l0!==a?l0:g;this.Add=function(p0){m0[n0]=p0;n0++;};this.RemoveAt=function(p0){if(p0<0||p0>=n0)throw d;if(p0==0){m0.shift();n0--;}else{for(var q0=p0;q0<n0-1;q0++) m0[q0]=m0[q0+1];n0--;delete m0[n0];}};this.IndexOf=function(p0){for(var q0=0;q0<n0;q0++){if(o0(p0,m0[q0]))return q0;}return -1;};this.Remove=function(p0){var q0=this.IndexOf(p0);if(q0==-1)return false;this.RemoveAt(q0);return true;};this.Clear=function(){m0=[];n0=0;};this.GetCount=function(){return n0;};this.GetItem=function(p0){if(p0<0||p0>=n0)throw d;return m0[p0];};this.SetItem=function(p0,q0){if(p0<0||p0>=n0)throw d;m0[p0]=q0;};this.ToArray=function(){var p0=[];for(var q0=0;q0<this.GetCount();q0++) p0.push(this.GetItem(q0));return p0;};};var r=b.Scheduler=function(l0,m0,n0){this.Schedule=l0;this.ScheduleWithTime=m0;this.Now=n0;this.ScheduleRecursive=function(o0){var p0=this;var q0=new n();var r0;r0=function(){o0(function(){var s0=false;var t0=false;var u0;u0=p0.Schedule(function(){r0();if(s0)q0.Remove(u0); else t0=true;});if(!t0){q0.Add(u0);s0=true;}});};q0.Add(p0.Schedule(r0));return q0;};this.ScheduleRecursiveWithTime=function(o0,p0){var q0=this;var r0=new n();var s0;s0=function(){o0(function(t0){var u0=false;var v0=false;var w0;w0=q0.ScheduleWithTime(function(){s0();if(u0)r0.Remove(w0); else v0=true;},t0);if(!v0){r0.Add(w0);u0=true;}});};r0.Add(q0.ScheduleWithTime(s0,p0));return r0;};};var s=new r(function(l0){if(this.f===a){try{this.f=new q();this.f.Add(l0);while(this.f.GetCount()>0){var m0=this.f.GetItem(0);this.f.RemoveAt(0);m0();}delete this.f;}catch(o0){delete this.f;throw o0;}return j;}else{this.f.Add(l0);var n0=this;return i(function(){if(n0.f!==a)n0.f.Remove(l0);});}},function(l0,m0){this.g(function(){while(this.Now()<m0);l0();});},f);s.g=function(l0){if(this.f===a)try{this.f=new q();l0();while(this.f.GetCount()>0){var m0=this.f.GetItem(0);this.f.RemoveAt(0);m0();}delete this.f;}catch(n0){delete this.f;throw n0;} else l0();};r.CurrentThread=s;var t=new r(function(l0){l0();return j;},function(l0,m0){while(this.Now<m0);l0();},f);r.Immediate=t;var u=new r(function(l0){var m0=c.setTimeout(l0,0);return i(function(){c.clearTimeout(m0);});},function(l0,m0){var n0=c.setTimeout(l0,m0);return i(function(){c.clearTimeout(n0);});},f);r.Timeout=u;var v=b.Observer=function(l0,m0,n0){this.OnNext=l0===a?e:l0;this.OnError=m0===a?function(o0){throw o0;}:m0;this.OnCompleted=n0===a?e:n0;this.AsObserver=function(){var o0=this;return new v(function(p0){o0.OnNext(p0);},function(p0){o0.OnError(p0);},function(){o0.OnCompleted();});};};var w=v.Create=function(l0,m0,n0){return new v(l0,m0,n0);};var x=b.Observable=function(l0){this.h=l0;};var y=x.CreateWithDisposable=function(l0){return new x(l0);};var z=x.Create=function(l0){return y(function(m0){return i(l0(m0));});};var A=function(){return this.Select(function(l0){return l0.Value;});};x.prototype={Subscribe:function(l0,m0,n0){var o0;if(arguments.length==0||arguments.length>1||typeof l0 =="function")o0=new v(l0,m0,n0); else o0=l0;return this.i(o0);},i:function(l0){var m0=false;var n0=new o();var o0=this;s.g(function(){var p0=new v(function(q0){if(!m0)l0.OnNext(q0);},function(q0){if(!m0){m0=true;n0.Dispose();l0.OnError(q0);}},function(){if(!m0){m0=true;n0.Dispose();l0.OnCompleted();}});n0.Replace(o0.h(p0));});return new n(n0,i(function(){m0=true;}));},Select:function(l0){var m0=this;return y(function(n0){var o0=0;return m0.Subscribe(new v(function(p0){var q0;try{q0=l0(p0,o0++);}catch(r0){n0.OnError(r0);return;}n0.OnNext(q0);},function(p0){n0.OnError(p0);},function(){n0.OnCompleted();}));});},Let:function(l0,m0){if(m0===a)return l0(this);var n0=this;return y(function(o0){var p0=m0();var q0;try{q0=l0(p0);}catch(u0){return F(u0).Subscribe(o0);}var r0=new o();var s0=new o();var t0=new n(s0,r0);r0.Replace(q0.Subscribe(function(u0){o0.OnNext(u0);},function(u0){o0.OnError(u0);t0.Dispose();},function(){o0.OnCompleted();t0.Dispose();}));s0.Replace(n0.Subscribe(p0));return t0;});},MergeObservable:function(){var l0=this;return y(function(m0){var n0=false;var o0=new n();var p0=new o();o0.Add(p0);p0.Replace(l0.Subscribe(function(q0){var r0=new o();o0.Add(r0);r0.Replace(q0.Subscribe(function(s0){m0.OnNext(s0);},function(s0){m0.OnError(s0);},function(){o0.Remove(r0);if(o0.GetCount()==1&&n0)m0.OnCompleted();}));},function(q0){m0.OnError(q0);},function(){n0=true;if(o0.GetCount()==1)m0.OnCompleted();}));return o0;});},j:function(l0,m0){var n0=p(m0);n0.unshift(this);return l0(n0);},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(l0,m0){var n0=this;return y(function(o0){var p0=false;var q0=[];var r0=[];var s0=false;var t0=false;var u0=new n();var v0=function(w0){u0.Dispose();q0=a;r0=a;o0.OnError(w0);};u0.Add(n0.Subscribe(function(w0){if(t0){o0.OnCompleted();return;}if(r0.length>0){var x0=r0.shift();var y0;try{y0=m0(w0,x0);}catch(z0){u0.Dispose();o0.OnError(z0);return;}o0.OnNext(y0);}else q0.push(w0);},v0,function(){if(t0){o0.OnCompleted();return;}s0=true;}));u0.Add(l0.Subscribe(function(w0){if(s0){o0.OnCompleted();return;}if(q0.length>0){var x0=q0.shift();var y0;try{y0=m0(x0,w0);}catch(z0){u0.Dispose();o0.OnError(z0);return;}o0.OnNext(y0);}else r0.push(w0);},v0,function(){if(s0){o0.OnCompleted();return;}t0=true;}));return u0;});},CombineLatest:function(l0,m0){var n0=this;return y(function(o0){var p0=false;var q0=false;var r0=false;var s0;var t0;var u0=false;var v0=false;var w0=new n();var x0=function(y0){w0.Dispose();o0.OnError(y0);};w0.Add(n0.Subscribe(function(y0){if(v0){o0.OnCompleted();return;}if(r0){var z0;try{z0=m0(y0,t0);}catch(A0){w0.Dispose();o0.OnError(A0);return;}o0.OnNext(z0);}s0=y0;q0=true;},x0,function(){if(v0){o0.OnCompleted();return;}u0=true;}));w0.Add(l0.Subscribe(function(y0){if(u0){o0.OnCompleted();return;}if(q0){var z0;try{z0=m0(s0,y0);}catch(A0){w0.Dispose();o0.OnError(A0);return;}o0.OnNext(z0);}t0=y0;r0=true;},x0,function(){if(u0){o0.OnCompleted();return;}v0=true;}));});},Switch:function(){var l0=this;return y(function(m0){var n0=false;var o0=new o();var p0=new o();p0.Replace(l0.Subscribe(function(q0){if(!n0){var r0=new o();r0.Replace(q0.Subscribe(function(s0){m0.OnNext(s0);},function(s0){p0.Dispose();o0.Dispose();m0.OnError(s0);},function(){o0.Replace(a);if(n0)m0.OnCompleted();}));o0.Replace(r0);}},function(q0){o0.Dispose();m0.OnError(q0);},function(){n0=true;if(o0.Get()===a)m0.OnCompleted();}));return new n(p0,o0);});},TakeUntil:function(l0){var m0=this;return y(function(n0){var o0=new n();o0.Add(l0.Subscribe(function(){n0.OnCompleted();o0.Dispose();},function(p0){n0.OnError(p0);},function(){}));o0.Add(m0.Subscribe(n0));return o0;});},SkipUntil:function(l0){var m0=this;return y(function(n0){var o0=true;var p0=new n();p0.Add(l0.Subscribe(function(){o0=false;},function(q0){n0.OnError(q0);},e));p0.Add(m0.Subscribe(new v(function(q0){if(!o0)n0.OnNext(q0);},function(q0){n0.OnError(q0);},function(){if(!o0)n0.OnCompleted();})));return p0;});},Scan1:function(l0){var m0=this;return I(function(){var n0;var o0=false;return m0.Select(function(p0){if(o0)n0=l0(n0,p0); else{n0=p0;o0=true;}return n0;});});},Scan:function(l0,m0){var n0=this;return I(function(){var o0;var p0=false;return n0.Select(function(q0){if(p0)o0=m0(o0,q0); else{o0=m0(l0,q0);p0=true;}return o0;});});},Scan0:function(l0,m0){var n0=this;return y(function(o0){var p0=l0;var q0=true;return n0.Subscribe(function(r0){if(q0){q0=false;o0.OnNext(p0);}try{p0=m0(p0,r0);}catch(s0){o0.OnError(s0);return;}o0.OnNext(p0);},function(r0){if(q0)o0.OnNext(p0);o0.OnError(r0);},function(){if(q0)o0.OnNext(p0);o0.OnCompleted();});});},Finally:function(l0){var m0=this;return z(function(n0){var o0=m0.Subscribe(n0);return function(){try{o0.Dispose();l0();}catch(p0){l0();throw p0;}};});},Do:function(l0,m0,n0){var o0;if(arguments.length==0||arguments.length>1||typeof l0 =="function")o0=new v(l0,m0!==a?m0:e,n0); else o0=l0;var p0=this;return y(function(q0){return p0.Subscribe(new v(function(r0){try{o0.OnNext(r0);}catch(s0){q0.OnError(s0);return;}q0.OnNext(r0);},function(r0){if(m0!==a)try{o0.OnError(r0);}catch(s0){q0.OnError(s0);return;}q0.OnError(r0);},function(){if(n0!==a)try{o0.OnCompleted();}catch(r0){q0.OnError(r0);return;}q0.OnCompleted();}));});},Where:function(l0){var m0=this;return y(function(n0){var o0=0;return m0.Subscribe(new v(function(p0){var q0=false;try{q0=l0(p0,o0++);}catch(r0){n0.OnError(r0);return;}if(q0)n0.OnNext(p0);},function(p0){n0.OnError(p0);},function(){n0.OnCompleted();}));});},Take:function(l0,m0){if(m0===a)m0=t;var n0=this;return y(function(o0){if(l0<=0){n0.Subscribe().Dispose();return H(m0).Subscribe(o0);}var p0=l0;return n0.Subscribe(new v(function(q0){if(p0-->0){o0.OnNext(q0);if(p0==0)o0.OnCompleted();}},function(q0){o0.OnError(q0);},function(){o0.OnCompleted();}));});},GroupBy:function(l0,m0,n0){if(l0===a)l0=h;if(m0===a)m0=h;if(n0===a)n0=function(p0){return p0.toString();};var o0=this;return y(function(p0){var q0={};var r0=new o();var s0=new m(r0);r0.Replace(o0.Subscribe(function(t0){var u0;try{u0=l0(t0);}catch(A0){for(var B0 in q0) q0[B0].OnError(A0);p0.OnError(A0);return;}var v0=false;var w0;try{var x0=n0(u0);if(q0[x0]===a){w0=new c0();q0[x0]=w0;v0=true;}else w0=q0[x0];}catch(A0){for(var B0 in q0) q0[B0].OnError(A0);p0.OnError(A0);return;}if(v0){var y0=y(function(A0){return new n(s0.GetDisposable(),w0.Subscribe(A0));});y0.Key=u0;p0.OnNext(y0);}var z0;try{z0=m0(t0);}catch(A0){for(var B0 in q0) q0[B0].OnError(A0);p0.OnError(A0);return;}w0.OnNext(z0);},function(t0){for(var u0 in q0) q0[u0].OnError(t0);p0.OnError(t0);},function(){for(var t0 in q0) q0[t0].OnCompleted();p0.OnCompleted();}));return s0;});},TakeWhile:function(l0){var m0=this;return y(function(n0){var o0=true;return m0.Subscribe(new v(function(p0){if(o0){try{o0=l0(p0);}catch(q0){n0.OnError(q0);return;}if(o0)n0.OnNext(p0); else n0.OnCompleted();}},function(p0){n0.OnError(p0);},function(){n0.OnCompleted();}));});},SkipWhile:function(l0){var m0=this;return y(function(n0){var o0=false;return m0.Subscribe(new v(function(p0){if(!o0)try{o0=!l0(p0);}catch(q0){n0.OnError(q0);return;}if(o0)n0.OnNext(p0);},function(p0){n0.OnError(p0);},function(){n0.OnCompleted();}));});},Skip:function(l0){var m0=this;return y(function(n0){var o0=l0;return m0.Subscribe(new v(function(p0){if(o0--<=0)n0.OnNext(p0);},function(p0){n0.OnError(p0);},function(){n0.OnCompleted();}));});},SelectMany:function(l0){return this.Select(l0).MergeObservable();},TimeInterval:function(l0){if(l0===a)l0=t;var m0=this;return I(function(){var n0=l0.Now();return m0.Select(function(o0){var p0=l0.Now();var q0=p0-n0;n0=p0;return {Interval:q0,Value:o0};});});},RemoveInterval:A,Timestamp:function(l0){if(l0===a)l0=t;return this.Select(function(m0){return {Timestamp:l0.Now(),Value:m0};});},RemoveTimestamp:A,Materialize:function(){var l0=this;return y(function(m0){return l0.Subscribe(new v(function(n0){m0.OnNext(new b0("N",n0));},function(n0){m0.OnNext(new b0("E",n0));m0.OnCompleted();},function(){m0.OnNext(new b0("C"));m0.OnCompleted();}));});},Dematerialize:function(){return this.SelectMany(function(l0){return l0;});},AsObservable:function(){var l0=this;return y(function(m0){return l0.Subscribe(m0);});},Delay:function(l0,m0){if(m0===a)m0=u;var n0=this;return y(function(o0){var p0=[];var q0=false;var r0=new o();var s0=n0.Materialize().Timestamp().Subscribe(function(t0){if(t0.Value.Kind=="E"){o0.OnError(t0.Value.Value);p0=[];if(q0)r0.Dispose();return;}p0.push({Timestamp:m0.Now()+l0,Value:t0.Value});if(!q0){r0.Replace(m0.ScheduleRecursiveWithTime(function(u0){var v0;do{v0=a;if(p0.length>0&&p0[0].Timestamp<=m0.Now())v0=p0.shift().Value;if(v0!==a)v0.Accept(o0);}while(v0!==a);if(p0.length>0){u0(Math.max(0,p0[0].Timestamp-m0.Now()));q0=true;}else q0=false;},l0));q0=true;}});return new n(s0,r0);});},Throttle:function(l0,m0){if(m0===a)m0=u;var n0=this;return y(function(o0){var p0;var q0=false;var r0=new o();var s0=0;var t0=n0.Subscribe(function(u0){q0=true;p0=u0;s0++;var v0=s0;r0.Replace(m0.ScheduleWithTime(function(){if(q0&&s0==v0)o0.OnNext(p0);q0=false;},l0));},function(u0){r0.Dispose();o0.OnError(u0);q0=false;s0++;},function(){r0.Dispose();if(q0)o0.OnNext(p0);o0.OnCompleted();q0=false;s0++;});return new n(t0,r0);});},Timeout:function(l0,m0,n0){if(n0===a)n0=u;if(m0===a)m0=F("Timeout",n0);var o0=this;return y(function(p0){var q0=new o();var r0=new o();var s0=0;var t0=s0;var u0=false;r0.Replace(n0.ScheduleWithTime(function(){u0=s0==t0;if(u0)q0.Replace(m0.Subscribe(p0));},l0));q0.Replace(o0.Subscribe(function(v0){var w0=0;if(!u0){s0++;w0=s0;p0.OnNext(v0);r0.Replace(n0.ScheduleWithTime(function(){u0=s0==w0;if(u0)q0.Replace(m0.Subscribe(p0));},l0));}},function(v0){if(!u0){s0++;p0.OnError(v0);}},function(){if(!u0){s0++;p0.OnCompleted();}}));return new n(q0,r0);});},Sample:function(l0,m0){if(m0===a)m0=u;var n0=this;return y(function(o0){var p0=false;var q0;var r0=false;var s0=new n();s0.Add(S(l0,m0).Subscribe(function(t0){if(p0){o0.OnNext(q0);p0=false;}if(r0)o0.OnCompleted();},function(t0){o0.OnError(t0);},function(){o0.OnCompleted();}));s0.Add(n0.Subscribe(function(t0){p0=true;q0=t0;},function(t0){o0.OnError(t0);s0.Dispose();},function(){r0=true;}));return s0;});},Repeat:function(l0,m0){var n0=this;if(m0===a)m0=t;if(l0===a)l0=-1;return y(function(o0){var p0=l0;var q0=new o();var r0=new n(q0);var s0=function(t0){q0.Replace(n0.Subscribe(function(u0){o0.OnNext(u0);},function(u0){o0.OnError(u0);},function(){if(p0>0){p0--;if(p0==0){o0.OnCompleted();return;}}t0();}));};r0.Add(m0.ScheduleRecursive(s0));return r0;});},Retry:function(l0,m0){var n0=this;if(m0===a)m0=t;if(l0===a)l0=-1;return y(function(o0){var p0=l0;var q0=new o();var r0=new n(q0);var s0=function(t0){q0.Replace(n0.Subscribe(function(u0){o0.OnNext(u0);},function(u0){if(p0>0){p0--;if(p0==0){o0.OnError(u0);return;}}t0();},function(){o0.OnCompleted();}));};r0.Add(m0.ScheduleRecursive(s0));return r0;});},BufferWithTime:function(l0,m0,n0){if(n0===a)n0=u;if(m0===a)m0=l0;var o0=this;return y(function(p0){var q0=new q();var r0=n0.Now();var s0=function(){var w0=[];for(var x0=0;x0<q0.GetCount();x0++){var y0=q0.GetItem(x0);if(y0.Timestamp-r0>=0)w0.push(y0.Value);}return w0;};var t0=new n();var u0=function(w0){p0.OnError(w0);};var v0=function(){p0.OnNext(s0());p0.OnCompleted();};t0.Add(o0.Subscribe(function(w0){q0.Add({Value:w0,Timestamp:n0.Now()});},u0,v0));t0.Add(U(l0,m0,n0).Subscribe(function(w0){var x0=s0();var y0=n0.Now()+m0-l0;while(q0.GetCount()>0&&q0.GetItem(0).Timestamp-y0<=0)q0.RemoveAt(0);p0.OnNext(x0);r0=y0;},u0,v0));return t0;});},BufferWithTimeOrCount:function(l0,m0,n0){if(n0===a)n0=u;var o0=this;return y(function(p0){var q0=0;var r0=new q();var s0=function(){p0.OnNext(r0.ToArray());r0.Clear();q0++;};var t0=new o();var u0;u0=function(w0){var x0=n0.ScheduleWithTime(function(){var y0=false;var z0=0;if(w0==q0){s0();z0=q0;y0=true;}if(y0)u0(z0);},l0);t0.Replace(x0);};u0(q0);var v0=o0.Subscribe(function(w0){var x0=false;var y0=0;r0.Add(w0);if(r0.GetCount()==m0){s0();y0=q0;x0=true;}if(x0)u0(y0);},function(w0){p0.OnError(w0);r0.Clear();},function(){p0.OnNext(r0.ToArray());q0++;p0.OnCompleted();r0.Clear();});return new n(v0,t0);});},BufferWithCount:function(l0,m0){if(m0===a)m0=l0;var n0=this;return y(function(o0){var p0=[];var q0=0;return n0.Subscribe(function(r0){if(q0==0)p0.push(r0); else q0--;var s0=p0.length;if(s0==l0){var t0=p0;p0=[];var u0=Math.min(m0,s0);for(var v0=u0;v0<s0;v0++) p0.push(t0[v0]);q0=Math.max(0,m0-l0);o0.OnNext(t0);}},function(r0){o0.OnError(r0);},function(){if(p0.length>0)o0.OnNext(p0);o0.OnCompleted();});});},StartWith:function(l0,m0){if(!(l0 instanceof Array))l0=[l0];if(m0===a)m0=t;var n0=this;return y(function(o0){var p0=new n();var q0=0;p0.Add(m0.ScheduleRecursive(function(r0){if(q0<l0.length){o0.OnNext(l0[q0]);q0++;r0();}else p0.Add(n0.Subscribe(o0));}));return p0;});},DistinctUntilChanged:function(l0,m0){if(l0===a)l0=h;if(m0===a)m0=g;var n0=this;return y(function(o0){var p0;var q0=false;return n0.Subscribe(function(r0){var s0;try{s0=l0(r0);}catch(u0){o0.OnError(u0);return;}var t0=false;if(q0)try{t0=m0(p0,s0);}catch(u0){o0.OnError(u0);return;}if(!q0||!t0){q0=true;p0=s0;o0.OnNext(r0);}},function(r0){o0.OnError(r0);},function(){o0.OnCompleted();});});},Publish:function(l0){if(l0===a)return new k0(this,new c0());var m0=this;return y(function(n0){var o0=new k0(m0,new c0());return new n(l0(o0).Subscribe(v),o0.Connect());});},Prune:function(l0,m0){if(m0===a)m0=s;if(l0===a)return new k0(this,new e0(m0));var n0=this;return y(function(o0){var p0=new k0(n0,new e0(m0));return new n(l0(p0).Subscribe(v),p0.Connect());});},Replay:function(l0,m0,n0,o0){if(o0===a)o0=s;if(l0===a)return new k0(this,new g0(m0,n0,o0));var p0=this;return y(function(q0){var r0=new k0(p0,new g0(m0,n0,o0));return new n(l0(r0).Subscribe(v),r0.Connect());});},SkipLast:function(l0){var m0=this;return y(function(n0){var o0=[];return m0.Subscribe(function(p0){o0.push(p0);if(o0.length>l0)n0.OnNext(o0.shift());},function(p0){n0.OnError(p0);},function(){n0.OnCompleted();});});},TakeLast:function(l0){var m0=this;return y(function(n0){var o0=[];return m0.Subscribe(function(p0){o0.push(p0);if(o0.length>l0)o0.shift();},function(p0){n0.OnError(p0);},function(){while(o0.length>0)n0.OnNext(o0.shift());n0.OnCompleted();});});}};var B=x.Merge=function(l0,m0){if(m0===a)m0=s;return D(l0,m0).MergeObservable();};var C=x.Concat=function(l0,m0){if(m0===a)m0=t;return y(function(n0){var o0=new o();var p0=0;var q0=m0.ScheduleRecursive(function(r0){if(p0<l0.length){var s0=l0[p0];p0++;o0.Replace(s0.Subscribe(function(t0){n0.OnNext(t0);},function(t0){n0.OnError(t0);},r0));}else n0.OnCompleted();});return new n(o0,q0);});};var D=x.FromArray=function(l0,m0){if(m0===a)m0=s;return y(function(n0){var o0=0;return m0.ScheduleRecursive(function(p0){if(o0<l0.length){n0.OnNext(l0[o0++]);p0();}else n0.OnCompleted();});});};var E=x.Return=function(l0,m0){if(m0===a)m0=s;return y(function(n0){return m0.Schedule(function(){n0.OnNext(l0);n0.OnCompleted();});});};var F=x.Throw=function(l0,m0){if(m0===a)m0=s;return y(function(n0){return m0.Schedule(function(){n0.OnError(l0);});});};var G=x.Never=function(){return y(function(l0){return j;});};var H=x.Empty=function(l0){if(l0===a)l0=s;return y(function(m0){return l0.Schedule(function(){m0.OnCompleted();});});};var I=x.Defer=function(l0){return y(function(m0){var n0;try{n0=l0();}catch(o0){m0.OnError(o0);return j;}return n0.Subscribe(m0);});};var J=x.Catch=function(l0,m0){if(m0===a)m0=t;return y(function(n0){var o0=new o();var p0=0;var q0=m0.ScheduleRecursive(function(r0){var s0=l0[p0];p0++;o0.Replace(s0.Subscribe(function(t0){n0.OnNext(t0);},function(t0){if(p0<l0.length)r0(); else n0.OnError(t0);},function(){n0.OnCompleted();}));});return new n(o0,q0);});};var K=x.Using=function(l0,m0){return y(function(n0){var o0;var p0=j;try{var q0=l0();if(q0!==a)p0=q0;o0=m0(q0);}catch(r0){return new n(Throw(r0).Subscribe(n0),p0);}return new n(o0.Subscribe(n0),p0);});};var L=x.Range=function(l0,m0,n0){if(n0===a)n0=s;var o0=l0+m0-1;return N(l0,function(p0){return p0<=o0;},h,function(p0){return p0+1;},n0);};var M=x.Repeat=function(l0,m0,n0){if(n0===a)n0=s;if(m0===a)m0=-1;var o0=m0;return y(function(p0){return n0.ScheduleRecursive(function(q0){p0.OnNext(l0);if(o0>0){o0--;if(o0==0){p0.OnCompleted();return;}}q0();});});};var N=x.Generate=function(l0,m0,n0,o0,p0){if(p0===a)p0=s;return y(function(q0){var r0=l0;var s0=true;return p0.ScheduleRecursive(function(t0){var u0=false;var v0;try{if(s0)s0=false; else r0=o0(r0);u0=m0(r0);if(u0)v0=n0(r0);}catch(w0){q0.OnError(w0);return;}if(u0){q0.OnNext(v0);t0();}else q0.OnCompleted();});});};var O=x.GenerateWithTime=function(l0,m0,n0,o0,p0,q0){if(q0===a)q0=u;return new y(function(r0){var s0=l0;var t0=true;var u0=false;var v0;var w0;return q0.ScheduleRecursiveWithTime(function(x0){if(u0)r0.OnNext(v0);try{if(t0)t0=false; else s0=p0(s0);u0=m0(s0);if(u0){v0=n0(s0);w0=o0(s0);}}catch(y0){r0.OnError(y0);return;}if(u0)x0(w0); else r0.OnCompleted();},0);});};var P=x.OnErrorResumeNext=function(l0,m0){if(m0===a)m0=t;return y(function(n0){var o0=new o();var p0=0;var q0=m0.ScheduleRecursive(function(r0){if(p0<l0.length){var s0=l0[p0];p0++;o0.Replace(s0.Subscribe(function(t0){n0.OnNext(t0);},r0,r0));}else n0.OnCompleted();});return new n(o0,q0);});};var Q=x.Amb=function(){var l0=arguments;return y(function(m0){var n0=new n();var o0=new o();o0.Replace(n0);var p0=false;for(var q0=0;q0<l0.length;q0++){var r0=l0[q0];var s0=new o();var t0=new v(function(u0){if(!p0){n0.Remove(this.k,true);n0.Dispose();o0.Replace(this.k);p0=true;}m0.OnNext(u0);},function(u0){m0.OnError(u0);o0.Dispose();},function(){m0.OnCompleted();o0.Dispose();});t0.k=s0;s0.Replace(r0.Subscribe(t0));n0.Add(s0);}return o0;});};var R=x.ForkJoin=function(){var l0=arguments;return y(function(m0){var n0=[];var o0=[];var p0=[];var q0=new n();for(var r0=0;r0<l0.length;r0++) (function(s0){q0.Add(l0[s0].Subscribe(function(t0){n0[s0]=true;p0[s0]=t0;},function(t0){m0.OnError(t0);},function(t0){if(!n0[s0]){m0.OnCompleted();p0=a;n0=a;}o0[s0]=true;var u0=true;for(var v0=0;v0<l0.length;v0++){if(!o0[v0])u0=false;}if(u0){m0.OnNext(p0);m0.OnCompleted();p0=a;o0=a;n0=a;}}));})(r0);return q0;});};var S=x.Interval=function(l0,m0){return U(l0,l0,m0);};var T=function(l0){return Math.max(0,l0);};var U=x.Timer=function(l0,m0,n0){if(n0===a)n0=u;if(l0===a)return G();if(l0 instanceof Date)return I(function(){return x.Timer(l0-new Date(),m0,n0);});var o0=T(l0);if(m0===a)return y(function(q0){return n0.ScheduleWithTime(function(){q0.OnNext(0);q0.OnCompleted();},o0);});var p0=T(m0);return y(function(q0){var r0=0;return n0.ScheduleRecursiveWithTime(function(s0){q0.OnNext(r0++);s0(p0);},o0);});};var V=x.While=function(l0,m0){return y(function(n0){var o0=new o();var p0=new n(o0);p0.Add(t.ScheduleRecursive(function(q0){var r0;try{r0=l0();}catch(s0){n0.OnError(s0);return;}if(r0)o0.Replace(m0.Subscribe(function(s0){n0.OnNext(s0);},function(s0){n0.OnError(s0);},function(){q0();})); else n0.OnCompleted();}));return p0;});};var W=x.If=function(l0,m0,n0){return I(function(){return l0()?m0:n0;});};var X=x.DoWhile=function(l0,m0){return C([l0,V(m0,l0)]);};var Y=x.Case=function(l0,m0,n0,o0){if(o0===a)o0=t;if(n0===a)n0=H(o0);return I(function(){var p0=m0[l0()];if(p0===a)p0=n0;return p0;});};var Z=x.For=function(l0,m0){return y(function(n0){var o0=new o();var p0=new n(o0);var q0=0;p0.Add(t.ScheduleRecursive(function(r0){if(q0<l0.length){var s0;try{s0=m0(l0[q0]);}catch(t0){n0.OnError(t0);return;}o0.Replace(s0.Subscribe(function(t0){n0.OnNext(t0);},function(t0){n0.OnError(t0);},function(){q0++;r0();}));}else n0.OnCompleted();}));return p0;});};var a0=x.Let=function(l0,m0){return I(function(){return m0(l0);});};var b0=b.Notification=function(l0,m0){this.Kind=l0;this.Value=m0;this.toString=function(){return this.Kind+": "+this.Value;};this.Accept=function(n0){switch(this.Kind){case "N":n0.OnNext(this.Value);break;case "E":n0.OnError(this.Value);break;case "C":n0.OnCompleted();break;}return j;};this.h=function(n0){var o0=this.Accept(n0);if(l0=="N")n0.OnCompleted();return o0;};};b0.prototype=new x;var c0=b.Subject=function(){var l0=new q();var m0=false;this.OnNext=function(n0){if(!m0){var o0=l0.ToArray();for(var p0=0;p0<o0.length;p0++){var q0=o0[p0];q0.OnNext(n0);}}};this.OnError=function(n0){if(!m0){var o0=l0.ToArray();for(var p0=0;p0<o0.length;p0++){var q0=o0[p0];q0.OnError(n0);}m0=true;l0.Clear();}};this.OnCompleted=function(){if(!m0){var n0=l0.ToArray();for(var o0=0;o0<n0.length;o0++){var p0=n0[o0];p0.OnCompleted();}m0=true;l0.Clear();}};this.h=function(n0){if(!m0){l0.Add(n0);return i(function(){l0.Remove(n0);});}else return j;};};c0.prototype=new x;for(var d0 in v.prototype) c0.prototype[d0]=v.prototype[d0];var e0=b.AsyncSubject=function(l0){var m0=new q();var n0;var o0=false;if(l0===a)l0=s;this.OnNext=function(p0){if(!o0)n0=new b0("N",p0);};this.OnError=function(p0){if(!o0){n0=new b0("E",p0);var q0=m0.ToArray();for(var r0=0;r0<q0.length;r0++){var s0=q0[r0];if(s0!==a)s0.OnError(p0);}o0=true;m0.Clear();}};this.OnCompleted=function(){if(!o0){if(n0===a)n0=new b0("C");var p0=m0.ToArray();for(var q0=0;q0<p0.length;q0++){var r0=p0[q0];if(r0!==a)n0.h(r0);}o0=true;m0.Clear();}};this.h=function(p0){if(!o0){m0.Add(p0);return i(function(){m0.Remove(p0);});}else return l0.Schedule(function(){n0.h(p0);});};};e0.prototype=new c0;var f0=b.BehaviorSubject=function(l0,m0){var n0=new g0(1,-1,m0);n0.OnNext(l0);return n0;};var g0=b.ReplaySubject=function(l0,m0,n0){var o0=new q();var p0=new q();var q0=false;if(n0===a)n0=s;var r0=m0>0;var s0=function(t0,u0){p0.Add({Value:new b0(t0,u0),Timestamp:n0.Now()});};this.l=function(){if(l0!==a)while(p0.GetCount()>l0)p0.RemoveAt(0);if(r0)while(p0.GetCount()>0&&n0.Now()-p0.GetItem(0).Timestamp>m0)p0.RemoveAt(0);};this.OnNext=function(t0){if(!q0){var u0=o0.ToArray();for(var v0=0;v0<u0.length;v0++){var w0=u0[v0];w0.OnNext(t0);}s0("N",t0);}};this.OnError=function(t0){if(!q0){var u0=o0.ToArray();for(var v0=0;v0<u0.length;v0++){var w0=u0[v0];w0.OnError(t0);}q0=true;o0.Clear();s0("E",t0);}};this.OnCompleted=function(){if(!q0){var t0=o0.ToArray();for(var u0=0;u0<t0.length;u0++){var v0=t0[u0];v0.OnCompleted();}q0=true;o0.Clear();s0("C");}};this.h=function(t0){var u0=new h0(this,t0);var v0=new n(u0);var w0=this;v0.Add(n0.Schedule(function(){if(!u0.m){w0.l();for(var x0=0;x0<p0.GetCount();x0++) p0.GetItem(x0).Value.Accept(t0);o0.Add(t0);u0.n=true;}}));return v0;};this.o=function(t0){o0.Remove(t0);};};g0.prototype=new c0;var h0=function(l0,m0){this.p=l0;this.q=m0;this.n=false;this.m=false;this.Dispose=function(){if(this.n)this.p.o(this.q);this.m=true;};};var i0=x.ToAsync=function(l0,m0){if(m0===a)m0=u;return function(){var n0=new e0(m0);var o0=function(){var r0;try{r0=l0.apply(this,arguments);}catch(s0){n0.OnError(s0);return;}n0.OnNext(r0);n0.OnCompleted();};var p0=this;var q0=p(arguments);m0.Schedule(function(){o0.apply(p0,q0);});return n0;};};var j0=x.Start=function(l0,m0,n0,o0){if(n0===a)n0=[];return i0(l0,o0).apply(m0,n0);};var k0=b.ConnectableObservable=function(l0,m0){if(m0===a)m0=new c0();this.p=m0;this.r=l0;this.s=false;this.t;this.Connect=function(){var n0;var o0=false;if(!this.s){this.s=true;var p0=this;n0=new n(i(function(){p0.s=false;}));this.t=n0;n0.Add(l0.Subscribe(this.p));}return this.t;};this.h=function(n0){return this.p.Subscribe(n0);};this.RefCount=function(){var n0=0;var o0=this;var p0;return z(function(q0){var r0=false;n0++;r0=n0==1;var s0=o0.Subscribe(q0);if(r0)p0=o0.Connect();return function(){s0.Dispose();n0--;if(n0==0)p0.Dispose();};});};};k0.prototype=new x;})();