Socket
Socket
Sign inDemoInstall

baconjs

Package Overview
Dependencies
0
Maintainers
2
Versions
222
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.7.90 to 0.7.91

4

dist/Bacon.min.js

@@ -1,2 +0,2 @@

(function(){function n(n,t){var r=arguments.length<=2||void 0===arguments[2]?!1:arguments[2];this.obs=n,this.sync=t,this.lazy=r,this.queue=[]}function t(){n.apply(this,arguments)}function r(t){n.call(this,t,!0)}function e(n,t,r){this.context=n,this.method=t,this.args=r}function i(n){this.value=n}function u(){this.id=++Q}function o(n,t){return this instanceof o?(u.call(this),void(!t&&I.isFunction(n)||(null!=n?n._isNext:void 0)?(this.valueF=n,this.valueInternal=void 0):(this.valueF=void 0,this.valueInternal=n))):new o(n,t)}function s(n,t){return this instanceof s?void o.call(this,n,t):new s(n,t)}function a(){return this instanceof a?void u.call(this):new a}function c(n){return this instanceof c?(this.error=n,void u.call(this)):new c(n)}function f(n){this.desc=n,this.id=++K,this.initialDesc=this.desc}function h(){var n=arguments.length<=0||void 0===arguments[0]?[]:arguments[0];this.unsubscribe=I.bind(this.unsubscribe,this),this.unsubscribed=!1,this.subscriptions=[],this.starting=[];for(var t,r=0;r<n.length;r++)t=n[r],this.add(t)}function l(n,t){this._subscribe=n,this._handleEvent=t,this.subscribe=I.bind(this.subscribe,this),this.handleEvent=I.bind(this.handleEvent,this),this.pushing=!1,this.ended=!1,this.prevError=void 0,this.unsubSrc=void 0,this.subscriptions=[],this.queue=[]}function p(n,t,r){return this instanceof p?(I.isFunction(n)&&(r=t,t=n,n=e.empty),f.call(this,n),this.dispatcher=new l(t,r),void Y(this)):new p(n,t,r)}function v(n,t,r){l.call(this,t,r),this.property=n,this.subscribe=I.bind(this.subscribe,this),this.current=R,this.currentValueRootId=void 0,this.propertyEnded=!1}function d(n,t,r){f.call(this,n),this.dispatcher=new v(this,t,r),Y(this)}function y(){return this instanceof y?(this.unsubAll=I.bind(this.unsubAll,this),this.subscribeAll=I.bind(this.subscribeAll,this),this.guardedSink=I.bind(this.guardedSink,this),this.sink=void 0,this.subscriptions=[],this.ended=!1,void p.call(this,new g.Desc(g,"Bus",[]),this.subscribeAll)):new y}function m(n){return[n,G()]}var b=Array.prototype.slice,g={toString:function(){return"Bacon"}};g.version="0.7.90";var w=("undefined"!=typeof global&&null!==global?global:this).Error,E=function(){},D=function(n,t){return n},S=function(n){return n.slice(0)},A=Array.isArray||function(n){return n instanceof Array},O=function(n){return n&&n._isObservable},M=function(n){for(var t=arguments.length,r=1;t>1?t>r:r>t;t>1?r++:r--)for(var e in arguments[r])n[e]=arguments[r][e];return n},k=function(n,t){var r={}.hasOwnProperty,e=function(){};e.prototype=t.prototype,n.prototype=new e;for(var i in t)r.call(t,i)&&(n[i]=t[i]);return n},I={indexOf:function(){return Array.prototype.indexOf?function(n,t){return n.indexOf(t)}:function(n,t){for(var r,e=0;e<n.length;e++)if(r=n[e],t===r)return e;return-1}}(),indexWhere:function(n,t){for(var r,e=0;e<n.length;e++)if(r=n[e],t(r))return e;return-1},head:function(n){return n[0]},always:function(n){return function(){return n}},negate:function(n){return function(t){return!n(t)}},empty:function(n){return 0===n.length},tail:function(n){return n.slice(1,n.length)},filter:function(n,t){for(var r,e=[],i=0;i<t.length;i++)r=t[i],n(r)&&e.push(r);return e},map:function(n,t){return function(){for(var r,e=[],i=0;i<t.length;i++)r=t[i],e.push(n(r));return e}()},each:function(n,t){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var e=n[r];t(r,e)}},toArray:function(n){return A(n)?n:[n]},contains:function(n,t){return-1!==I.indexOf(n,t)},id:function(n){return n},last:function(n){return n[n.length-1]},all:function(n){for(var t,r=arguments.length<=1||void 0===arguments[1]?I.id:arguments[1],e=0;e<n.length;e++)if(t=n[e],!r(t))return!1;return!0},any:function(n){for(var t,r=arguments.length<=1||void 0===arguments[1]?I.id:arguments[1],e=0;e<n.length;e++)if(t=n[e],r(t))return!0;return!1},without:function(n,t){return I.filter(function(t){return t!==n},t)},remove:function(n,t){var r=I.indexOf(t,n);return r>=0?t.splice(r,1):void 0},fold:function(n,t,r){for(var e,i=0;i<n.length;i++)e=n[i],t=r(t,e);return t},flatMap:function(n,t){return I.fold(t,[],function(t,r){return t.concat(n(r))})},cached:function(n){var t=R;return function(){return("undefined"!=typeof t&&null!==t?t._isNone:void 0)&&(t=n(),n=void 0),t}},bind:function(n,t){return function(){return n.apply(t,arguments)}},isFunction:function(n){return"function"==typeof n},toString:function(n){var t,r,e,i={}.hasOwnProperty;try{return P++,null==n?"undefined":I.isFunction(n)?"function":A(n)?P>5?"[..]":"["+I.map(I.toString,n).toString()+"]":null!=(null!=n?n.toString:void 0)&&n.toString!==Object.prototype.toString?n.toString():"object"==typeof n?P>5?"{..}":(t=function(){var t=[];for(r in n)i.call(n,r)&&(e=function(){var t;try{return n[r]}catch(t){return t}}(),t.push(I.toString(r)+":"+I.toString(e)));return t}(),"{"+t+"}"):n}finally{P--}}},P=0;g._=I;var _=g.UpdateBarrier=function(){var n,t=[],r={},e=[],i=0,u={},o=function(t){return n?e.push(t):t()},s=function(e,i){if(n){var u=r[e.id];return"undefined"==typeof u||null===u?(u=r[e.id]=[i],t.push(e)):u.push(i)}return i()},a=function(){for(;t.length>0;)c(0,!0);u={}},c=function(n,e){var i=t[n],u=i.id,o=r[u];t.splice(n,1),delete r[u],e&&t.length>0&&f(i);for(var s,a=0;a<o.length;a++)(s=o[a])()},f=function(n){if(!u[n.id]){for(var e,i=n.internalDeps(),o=0;o<i.length;o++)if(e=i[o],f(e),r[e.id]){var s=I.indexOf(t,e);c(s,!1)}u[n.id]=!0}},h=function(t,r,u,o){if(n)return u.apply(r,o);n=t;try{var s=u.apply(r,o);a()}finally{for(n=void 0;i<e.length;){var c=e[i];i++,c()}i=0,e=[]}return s},l=function(){return n?n.id:void 0},p=function(n,t){var r=!1,e=!1,i=function(){return e=!0},u=function(){return r=!0,i()};return i=n.dispatcher.subscribe(function(n){return o(function(){if(!r){var e=t(n);if(e===g.noMore)return u()}})}),e&&i(),u},v=function(){return t.length>0};return{whenDoneWith:s,hasWaiters:v,inTransaction:h,currentEventId:l,wrappedSubscribe:p,afterTransaction:o}}();M(n.prototype,{_isSource:!0,subscribe:function(n){return this.obs.dispatcher.subscribe(n)},toString:function(){return this.obs.toString()},markEnded:function(){return this.ended=!0,!0},consume:function(){return this.lazy?{value:I.always(this.queue[0])}:this.queue[0]},push:function(n){return this.queue=[n],[n]},mayHave:function(){return!0},hasAtLeast:function(){return this.queue.length},flatten:!0}),k(t,n),M(t.prototype,{consume:function(){return this.queue.shift()},push:function(n){return this.queue.push(n)},mayHave:function(n){return!this.ended||this.queue.length>=n},hasAtLeast:function(n){return this.queue.length>=n},flatten:!1}),k(r,n),M(r.prototype,{consume:function(){var n=this.queue;return this.queue=[],{value:function(){return n}}},push:function(n){return this.queue.push(n.value())},hasAtLeast:function(){return!0}}),n.isTrigger=function(n){return(null!=n?n._isSource:void 0)?n.sync:null!=n?n._isEventStream:void 0},n.fromObservable=function(r){return(null!=r?r._isSource:void 0)?r:(null!=r?r._isProperty:void 0)?new n(r,!1):new t(r,!0)},M(e.prototype,{_isDesc:!0,deps:function(){return this.cached||(this.cached=T([this.context].concat(this.args))),this.cached},toString:function(){return I.toString(this.context)+"."+I.toString(this.method)+"("+I.map(I.toString,this.args)+")"}});var x=function(n,t){var r=n||t;if(r&&r._isDesc)return n||t;for(var i=arguments.length,u=Array(i>2?i-2:0),o=2;i>o;o++)u[o-2]=arguments[o];return new e(n,t,u)},W=function(n,t){return t.desc=n,t},T=function(n){return A(n)?I.flatMap(T,n):O(n)?[n]:("undefined"!=typeof n&&null!==n?n._isSource:void 0)?[n.obs]:[]};g.Desc=e,g.Desc.empty=new g.Desc("","",[]);var V=function(n){return function(t){for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];if("object"==typeof t&&e.length){var u=t,o=e[0];t=function(){return u[o].apply(u,arguments)},e=e.slice(1)}return n.apply(void 0,[t].concat(e))}},H=function(n){return n=Array.prototype.slice.call(n),N.apply(void 0,n)},B=function(n,t){return function(){for(var r=arguments.length,e=Array(r),i=0;r>i;i++)e[i]=arguments[i];return n.apply(void 0,t.concat(e))}},F=function(n){return function(t){return function(r){if("undefined"!=typeof r&&null!==r){var e=r[t];return I.isFunction(e)?e.apply(r,n):e}}}},C=function(n,t){var r=n.slice(1).split("."),e=I.map(F(t),r);return function(n){for(var t,r=0;r<e.length;r++)t=e[r],n=t(n);return n}},q=function(n){return"string"==typeof n&&n.length>1&&"."===n.charAt(0)},N=V(function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return I.isFunction(n)?r.length?B(n,r):n:q(n)?C(n,r):I.always(n)}),L=function(n,t){return N.apply(void 0,[n].concat(t))},U=function(n,t,r,e){if("undefined"!=typeof t&&null!==t?t._isProperty:void 0){var i=t.sampledBy(n,function(n,t){return[n,t]});return e.call(i,function(n){{var t=n[0];n[1]}return t}).map(function(n){var t=(n[0],n[1]);return t})}return t=L(t,r),e.call(n,t)},z=function(n){if(I.isFunction(n))return n;if(q(n)){var t=j(n);return function(n,r){return n[t](r)}}throw new w("not a function or a field key: "+n)},j=function(n){return n.slice(1)};M(i.prototype,{_isSome:!0,getOrElse:function(){return this.value},get:function(){return this.value},filter:function(n){return n(this.value)?new i(this.value):R},map:function(n){return new i(n(this.value))},forEach:function(n){return n(this.value)},isDefined:!0,toArray:function(){return[this.value]},inspect:function(){return"Some("+this.value+")"},toString:function(){return this.inspect()}});var R={_isNone:!0,getOrElse:function(n){return n},filter:function(){return R},map:function(){return R},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},$=function(n){return("undefined"!=typeof n&&null!==n?n._isSome:void 0)||("undefined"!=typeof n&&null!==n?n._isNone:void 0)?n:new i(n)};g.noMore="<no-more>",g.more="<more>";var Q=0;u.prototype._isEvent=!0,u.prototype.isEvent=function(){return!0},u.prototype.isEnd=function(){return!1},u.prototype.isInitial=function(){return!1},u.prototype.isNext=function(){return!1},u.prototype.isError=function(){return!1},u.prototype.hasValue=function(){return!1},u.prototype.filter=function(){return!0},u.prototype.inspect=function(){return this.toString()},u.prototype.log=function(){return this.toString()},k(o,u),o.prototype.isNext=function(){return!0},o.prototype.hasValue=function(){return!0},o.prototype.value=function(){var n;return(null!=(n=this.valueF)?n._isNext:void 0)?(this.valueInternal=this.valueF.value(),this.valueF=void 0):this.valueF&&(this.valueInternal=this.valueF(),this.valueF=void 0),this.valueInternal},o.prototype.fmap=function(n){var t,r;return this.valueInternal?(r=this.valueInternal,this.apply(function(){return n(r)})):(t=this,this.apply(function(){return n(t.value())}))},o.prototype.apply=function(n){return new o(n)},o.prototype.filter=function(n){return n(this.value())},o.prototype.toString=function(){return I.toString(this.value())},o.prototype.log=function(){return this.value()},o.prototype._isNext=!0,k(s,o),s.prototype._isInitial=!0,s.prototype.isInitial=function(){return!0},s.prototype.isNext=function(){return!1},s.prototype.apply=function(n){return new s(n)},s.prototype.toNext=function(){return new o(this)},k(a,u),a.prototype.isEnd=function(){return!0},a.prototype.fmap=function(){return this},a.prototype.apply=function(){return this},a.prototype.toString=function(){return"<end>"},k(c,u),c.prototype.isError=function(){return!0},c.prototype.fmap=function(){return this},c.prototype.apply=function(){return this},c.prototype.toString=function(){return"<error> "+I.toString(this.error)},g.Event=u,g.Initial=s,g.Next=o,g.End=a,g.Error=c;var Z=function(n){return new s(n,!0)},X=function(n){return new o(n,!0)},G=function(){return new a},J=function(n){return n&&n._isEvent?n:X(n)},K=0,Y=function(){};M(f.prototype,{_isObservable:!0,subscribe:function(n){return _.wrappedSubscribe(this,n)},subscribeInternal:function(n){return this.dispatcher.subscribe(n)},onValue:function(){var n=H(arguments);return this.subscribe(function(t){return t.hasValue()?n(t.value()):void 0})},onValues:function(n){return this.onValue(function(t){return n.apply(void 0,t)})},onError:function(){var n=H(arguments);return this.subscribe(function(t){return t.isError()?n(t.error):void 0})},onEnd:function(){var n=H(arguments);return this.subscribe(function(t){return t.isEnd()?n():void 0})},name:function(n){return this._name=n,this},withDescription:function(){return this.desc=x.apply(void 0,arguments),this},toString:function(){return this._name?this._name:this.desc.toString()},deps:function(){return this.desc.deps()},internalDeps:function(){return this.initialDesc.deps()}}),f.prototype.assign=f.prototype.onValue,f.prototype.forEach=f.prototype.onValue,f.prototype.inspect=f.prototype.toString,g.Observable=f,M(h.prototype,{add:function(n){var t=this;if(!this.unsubscribed){var r=!1,e=E;this.starting.push(n);var i=function(){return t.unsubscribed?void 0:(r=!0,t.remove(e),I.remove(n,t.starting))};return e=n(this.unsubscribe,i),this.unsubscribed||r?e():this.subscriptions.push(e),I.remove(n,this.starting),e}},remove:function(n){return this.unsubscribed?void 0:void 0!==I.remove(n,this.subscriptions)?n():void 0},unsubscribe:function(){if(!this.unsubscribed){this.unsubscribed=!0;for(var n=this.subscriptions,t=0;t<n.length;t++)n[t]();return this.subscriptions=[],this.starting=[],[]}},count:function(){return this.unsubscribed?0:this.subscriptions.length+this.starting.length},empty:function(){return 0===this.count()}}),g.CompositeUnsubscribe=h,l.prototype.hasSubscribers=function(){return this.subscriptions.length>0},l.prototype.removeSub=function(n){return this.subscriptions=I.without(n,this.subscriptions),this.subscriptions},l.prototype.push=function(n){return n.isEnd()&&(this.ended=!0),_.inTransaction(n,this,this.pushIt,[n])},l.prototype.pushToSubscriptions=function(n){try{for(var t=this.subscriptions,r=t.length,e=0;r>e;e++){var i=t[e],u=i.sink(n);(u===g.noMore||n.isEnd())&&this.removeSub(i)}return!0}catch(o){throw this.pushing=!1,this.queue=[],o}},l.prototype.pushIt=function(n){if(this.pushing)return this.queue.push(n),g.more;if(n!==this.prevError){for(n.isError()&&(this.prevError=n),this.pushing=!0,this.pushToSubscriptions(n),this.pushing=!1;this.queue.length;)n=this.queue.shift(),this.push(n);return this.hasSubscribers()?g.more:(this.unsubscribeFromSource(),g.noMore)}},l.prototype.handleEvent=function(n){return this._handleEvent?this._handleEvent(n):this.push(n)},l.prototype.unsubscribeFromSource=function(){this.unsubSrc&&this.unsubSrc(),this.unsubSrc=void 0},l.prototype.subscribe=function(n){var t;return this.ended?(n(G()),E):(t={sink:n},this.subscriptions.push(t),1===this.subscriptions.length&&(this.unsubSrc=this._subscribe(this.handleEvent)),function(n){return function(){return n.removeSub(t),n.hasSubscribers()?void 0:n.unsubscribeFromSource()}}(this))},g.Dispatcher=l,k(p,f),M(p.prototype,{_isEventStream:!0,toProperty:function(n){var t=0===arguments.length?R:$(function(){return n}),r=this.dispatcher,e=new g.Desc(this,"toProperty",[n]);return new d(e,function(n){var e=!1,u=!1,o=E,a=g.more,c=function(){return e?void 0:t.forEach(function(t){return e=!0,a=n(new s(t)),a===g.noMore?(o(),o=E,E):void 0})};return o=r.subscribe(function(r){return r.hasValue()?r.isInitial()&&!u?(t=new i(function(){return r.value()}),g.more):(r.isInitial()||c(),e=!0,t=new i(r),n(r)):(r.isEnd()&&(a=c()),a!==g.noMore?n(r):void 0)}),u=!0,c(),o})},toEventStream:function(){return this},withHandler:function(n){return new p(new g.Desc(this,"withHandler",[n]),this.dispatcher.subscribe,n)}}),g.EventStream=p,g.never=function(){return new p(x(g,"never"),function(n){return n(G()),E})},g.when=function(){if(0===arguments.length)return g.never();for(var t=arguments.length,r=[],e=[],i=0,u=[];t>i;){u[i]=arguments[i],u[i+1]=arguments[i+1];for(var o,s=I.toArray(arguments[i]),a=tn(arguments[i+1]),c={f:a,ixs:[]},f=!1,h=0;h<s.length;h++){o=s[h];var l=I.indexOf(r,o);f||(f=n.isTrigger(o)),0>l&&(r.push(o),l=r.length-1);for(var v,d=0;d<c.ixs.length;d++)v=c.ixs[d],v.index===l&&v.count++;c.ixs.push({index:l,count:1})}s.length>0&&e.push(c),i+=2}if(!r.length)return g.never();r=I.map(n.fromObservable,r);var y=I.any(r,function(n){return n.flatten})&&nn(I.map(function(n){return n.obs},r)),m=new g.Desc(g,"when",u),b=new p(m,function(n){var t=[],i=!1,u=function(n){for(var t,e=0;e<n.ixs.length;e++)if(t=n.ixs[e],!r[t.index].hasAtLeast(t.count))return!1;return!0},o=function(n){return!n.sync||n.ended},s=function(n){for(var t,e=0;e<n.ixs.length;e++)if(t=n.ixs[e],!r[t.index].mayHave(t.count))return!0},a=function(n){return!n.source.flatten},c=function(c){return function(f){var h=function(){return _.whenDoneWith(b,p)},l=function(){if(!(t.length>0))return g.more;for(var i,o=g.more,s=t.pop(),c=0;c<e.length;c++)if(i=e[c],u(i)){var f=function(){for(var n,t=[],e=0;e<i.ixs.length;e++)n=i.ixs[e],t.push(r[n.index].consume());return t}();return o=n(s.e.apply(function(){var n,t=function(){for(var n,t=[],r=0;r<f.length;r++)n=f[r],t.push(n.value());return t}();return(n=i).f.apply(n,t)})),t.length&&(t=I.filter(a,t)),o===g.noMore?o:l()}},p=function(){var t=l();return i&&(I.all(r,o)||I.all(e,s))&&(t=g.noMore,n(G())),t===g.noMore&&f(),t};return c.subscribe(function(r){if(r.isEnd())i=!0,c.markEnded(),h();else if(r.isError())var e=n(r);else c.push(r),c.sync&&(t.push({source:c,e:r}),y||_.hasWaiters()?h():p());return e===g.noMore&&f(),e||g.more})}};return new g.CompositeUnsubscribe(function(){for(var n,t=[],e=0;e<r.length;e++)n=r[e],t.push(c(n));return t}()).unsubscribe});return b};var nn=function(n){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],r=function(n){if(I.contains(t,n))return!0;var e=n.internalDeps();return e.length?(t.push(n),I.any(e,r)):(t.push(n),!1)};return I.any(n,r)},tn=function(n){return I.isFunction(n)?n:I.always(n)};g.groupSimultaneous=function(){for(var n=arguments.length,t=Array(n),e=0;n>e;e++)t[e]=arguments[e];1===t.length&&A(t[0])&&(t=t[0]);var i=function(){for(var n,e=[],i=0;i<t.length;i++)n=t[i],e.push(new r(n));return e}();return W(new g.Desc(g,"groupSimultaneous",t),g.when(i,function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return t}))},k(v,l),M(v.prototype,{push:function(n){return n.isEnd()&&(this.propertyEnded=!0),n.hasValue()&&(this.current=new i(n),this.currentValueRootId=_.currentEventId()),l.prototype.push.call(this,n)},maybeSubSource:function(n,t){return t===g.noMore?E:this.propertyEnded?(n(G()),E):l.prototype.subscribe.call(this,n)},subscribe:function(n){var t=this,r=g.more;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=_.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?(_.whenDoneWith(this.property,function(){return t.currentValueRootId===i?n(Z(t.current.get().value())):void 0}),this.maybeSubSource(n,r)):(_.inTransaction(void 0,this,function(){return r=n(Z(this.current.get().value()))},[]),this.maybeSubSource(n,r))}return this.maybeSubSource(n,r)}}),k(d,f),M(d.prototype,{_isProperty:!0,changes:function(){var n=this;return new p(new g.Desc(this,"changes",[]),function(t){return n.dispatcher.subscribe(function(n){return n.isInitial()?void 0:t(n)})})},withHandler:function(n){return new d(new g.Desc(this,"withHandler",[n]),this.dispatcher.subscribe,n)},toProperty:function(){return this},toEventStream:function(){var n=this;return new p(new g.Desc(this,"toEventStream",[]),function(t){return n.dispatcher.subscribe(function(n){return n.isInitial()&&(n=n.toNext()),t(n)})})}}),g.Property=d,g.constant=function(n){return new d(new g.Desc(g,"constant",[n]),function(t){return t(Z(n)),t(G()),E})},g.fromBinder=function(n){var t=arguments.length<=1||void 0===arguments[1]?I.id:arguments[1],r=new g.Desc(g,"fromBinder",[n,t]);return new p(r,function(r){var e=!1,i=!1,u=function(){return e?void 0:"undefined"!=typeof o&&null!==o?(o(),e=!0):i=!0},o=n(function(){for(var n,e=arguments.length,i=Array(e),o=0;e>o;o++)i[o]=arguments[o];var s=t.apply(this,i);A(s)&&(null!=(n=I.last(s))?n._isEvent:void 0)||(s=[s]);for(var a,c=g.more,f=0;f<s.length;f++)if(a=s[f],c=r(a=J(a)),c===g.noMore||a.isEnd())return u(),c;return c});return i&&u(),u})},g.Observable.prototype.map=function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return U(this,n,r,function(n){return W(new g.Desc(this,"map",[n]),this.withHandler(function(t){return this.push(t.fmap(n))}))})};var rn=function(n){return A(n[0])?n[0]:Array.prototype.slice.call(n)},en=function(n){return I.isFunction(n[0])?[rn(Array.prototype.slice.call(n,1)),n[0]]:[rn(Array.prototype.slice.call(n,0,n.length-1)),I.last(n)]};g.combineAsArray=function(){var t=rn(arguments);if(t.length){for(var r=[],e=0;e<t.length;e++){var i=O(t[e])?t[e]:g.constant(t[e]);r.push(new n(i,!0))}return W(new g.Desc(g,"combineAsArray",t),g.when(r,function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return t}).toProperty())}return g.constant([])},g.onValues=function(){return g.combineAsArray(Array.prototype.slice.call(arguments,0,arguments.length-1)).onValues(arguments[arguments.length-1])},g.combineWith=function(){var n=en(arguments),t=n[0],r=n[1],e=new g.Desc(g,"combineWith",[r].concat(t));return W(e,g.combineAsArray(t).map(function(n){return r.apply(void 0,n)}))},g.Observable.prototype.combine=function(n,t){var r=z(t),e=new g.Desc(this,"combine",[n,t]);return W(e,g.combineAsArray(this,n).map(function(n){return r(n[0],n[1])}))},g.Observable.prototype.withStateMachine=function(n,t){var r=n,e=new g.Desc(this,"withStateMachine",[n,t]);return W(e,this.withHandler(function(n){var e=t(r,n),i=e[0],u=e[1];r=i;for(var o,s=g.more,a=0;a<u.length;a++)if(o=u[a],s=this.push(o),s===g.noMore)return s;return s}))};var un=function(n,t){return n===t},on=function(n){return"undefined"!=typeof n&&null!==n?n._isNone:!1};g.Observable.prototype.skipDuplicates=function(){var n=arguments.length<=0||void 0===arguments[0]?un:arguments[0],t=new g.Desc(this,"skipDuplicates",[]);return W(t,this.withStateMachine(R,function(t,r){return r.hasValue()?r.isInitial()||on(t)||!n(t.get(),r.value())?[new i(r.value()),[r]]:[t,[]]:[t,[r]]}))},g.Observable.prototype.awaiting=function(n){var t=new g.Desc(this,"awaiting",[n]);return W(t,g.groupSimultaneous(this,n).map(function(n){return 0===n[1].length}).toProperty(!1).skipDuplicates())},g.Observable.prototype.not=function(){return W(new g.Desc(this,"not",[]),this.map(function(n){return!n}))},g.Property.prototype.and=function(n){return W(new g.Desc(this,"and",[n]),this.combine(n,function(n,t){return n&&t}))},g.Property.prototype.or=function(n){return W(new g.Desc(this,"or",[n]),this.combine(n,function(n,t){return n||t}))},g.scheduler={setTimeout:function(n,t){return setTimeout(n,t)},setInterval:function(n,t){return setInterval(n,t)},clearInterval:function(n){return clearInterval(n)},clearTimeout:function(n){return clearTimeout(n)},now:function(){return(new Date).getTime()}},g.EventStream.prototype.bufferWithTime=function(n){return W(new g.Desc(this,"bufferWithTime",[n]),this.bufferWithTimeOrCount(n,Number.MAX_VALUE))},g.EventStream.prototype.bufferWithCount=function(n){return W(new g.Desc(this,"bufferWithCount",[n]),this.bufferWithTimeOrCount(void 0,n))},g.EventStream.prototype.bufferWithTimeOrCount=function(n,t){var r=function(r){return r.values.length===t?r.flush():void 0!==n?r.schedule():void 0},e=new g.Desc(this,"bufferWithTimeOrCount",[n,t]);return W(e,this.buffer(n,r,r))},g.EventStream.prototype.buffer=function(n){var t=arguments.length<=1||void 0===arguments[1]?E:arguments[1],r=arguments.length<=2||void 0===arguments[2]?E:arguments[2],e={scheduled:null,end:void 0,values:[],flush:function(){if(this.scheduled&&(g.scheduler.clearTimeout(this.scheduled),this.scheduled=null),this.values.length>0){var n=this.values;this.values=[];var t=this.push(X(n));if(null!=this.end)return this.push(this.end);if(t!==g.noMore)return r(this)}else if(null!=this.end)return this.push(this.end)},schedule:function(){var t=this;return this.scheduled?void 0:this.scheduled=n(function(){return t.flush()})}},i=g.more;if(!I.isFunction(n)){var u=n;n=function(n){return g.scheduler.setTimeout(n,u)}}return W(new g.Desc(this,"buffer",[]),this.withHandler(function(n){var r=this;return e.push=function(n){return r.push(n)},n.isError()?i=this.push(n):n.isEnd()?(e.end=n,e.scheduled||e.flush()):(e.values.push(n.value()),t(e)),i}))},g.Observable.prototype.filter=function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return U(this,n,r,function(n){return W(new g.Desc(this,"filter",[n]),this.withHandler(function(t){return t.filter(n)?this.push(t):g.more}))})},g.once=function(n){return new p(new e(g,"once",[n]),function(t){return t(J(n)),t(G()),E})},g.EventStream.prototype.concat=function(n){var t=this;return new p(new g.Desc(t,"concat",[n]),function(r){var e=E,i=t.dispatcher.subscribe(function(t){return t.isEnd()?e=n.dispatcher.subscribe(r):r(t)});return function(){return i(),e()}})},g.Observable.prototype.flatMap=function(){return cn(this,sn(arguments))},g.Observable.prototype.flatMapFirst=function(){return cn(this,sn(arguments),!0)};var sn=function(n){return 1===n.length&&O(n[0])?I.always(n[0]):H(n)},an=function(n){return O(n)?n:g.once(n)},cn=function(n,t,r,e){var i=[n],u=[],o=new g.Desc(n,"flatMap"+(r?"First":""),[t]),s=new p(o,function(i){var o=new h,s=[],a=function(n){var r=an(t(n.value()));return u.push(r),o.add(function(n,t){return r.dispatcher.subscribe(function(e){if(e.isEnd())return I.remove(r,u),c(),f(t),g.noMore;("undefined"!=typeof e&&null!==e?e._isInitial:void 0)&&(e=e.toNext());var o=i(e);return o===g.noMore&&n(),o})})},c=function(){var n=s.shift();return n?a(n):void 0},f=function(n){return n(),o.empty()?i(G()):void 0};return o.add(function(t,u){return n.dispatcher.subscribe(function(n){return n.isEnd()?f(u):n.isError()?i(n):r&&o.count()>1?g.more:o.unsubscribed?g.noMore:e&&o.count()>e?s.push(n):a(n)})}),o.unsubscribe});return s.internalDeps=function(){return u.length?i.concat(u):i},s};g.Observable.prototype.flatMapWithConcurrencyLimit=function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];var i=new g.Desc(this,"flatMapWithConcurrencyLimit",[n].concat(r));return W(i,cn(this,sn(r),!1,n))},g.Observable.prototype.flatMapConcat=function(){var n=new g.Desc(this,"flatMapConcat",Array.prototype.slice.call(arguments,0));return W(n,this.flatMapWithConcurrencyLimit.apply(this,[1].concat(b.call(arguments))))},g.later=function(n,t){return W(new g.Desc(g,"later",[n,t]),g.fromBinder(function(r){var e=function(){return r([t,G()])},i=g.scheduler.setTimeout(e,n);return function(){return g.scheduler.clearTimeout(i)}}))},g.Observable.prototype.bufferingThrottle=function(n){var t=new g.Desc(this,"bufferingThrottle",[n]);return W(t,this.flatMapConcat(function(t){return g.once(t).concat(g.later(n).filter(!1))}))},g.Property.prototype.bufferingThrottle=function(){return g.Observable.prototype.bufferingThrottle.apply(this,arguments).toProperty()},k(y,p),M(y.prototype,{unsubAll:function(){for(var n,t=this.subscriptions,r=0;r<t.length;r++)n=t[r],"function"==typeof n.unsub&&n.unsub()},subscribeAll:function(n){if(this.ended)n(G());else{this.sink=n;for(var t,r=S(this.subscriptions),e=0;e<r.length;e++)t=r[e],this.subscribeInput(t)}return this.unsubAll},guardedSink:function(n){var t=this;return function(r){return r.isEnd()?(t.unsubscribeInput(n),g.noMore):t.sink(r)}},subscribeInput:function(n){return n.unsub=n.input.dispatcher.subscribe(this.guardedSink(n.input)),n.unsub},unsubscribeInput:function(n){for(var t,r=this.subscriptions,e=0;e<r.length;e++)if(t=r[e],t.input===n)return"function"==typeof t.unsub&&t.unsub(),void this.subscriptions.splice(e,1)},plug:function(n){var t=this;if(!this.ended){var r={input:n};return this.subscriptions.push(r),"undefined"!=typeof this.sink&&this.subscribeInput(r),function(){return t.unsubscribeInput(n)}}},end:function(){return this.ended=!0,this.unsubAll(),"function"==typeof this.sink?this.sink(G()):void 0},push:function(n){return this.ended||"function"!=typeof this.sink?void 0:this.sink(X(n))},error:function(n){return"function"==typeof this.sink?this.sink(new c(n)):void 0}}),g.Bus=y;var fn=function(n,t){return V(function(r){for(var e=B(t,[function(n,t){return r.apply(void 0,n.concat([t]))}]),i=arguments.length,u=Array(i>1?i-1:0),o=1;i>o;o++)u[o-1]=arguments[o];return W(new g.Desc(g,n,[r].concat(u)),g.combineAsArray(u).flatMap(e))})};g.fromCallback=fn("fromCallback",function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return g.fromBinder(function(t){return L(n,r)(t),E},function(n){return[n,G()]})}),g.fromNodeCallback=fn("fromNodeCallback",function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return g.fromBinder(function(t){return L(n,r)(t),E},function(n,t){return n?[new c(n),G()]:[t,G()]})}),g.combineTemplate=function(n){function t(n){return n[n.length-1]}function r(n,r,e){return t(n)[r]=e,e}function e(n,t){return function(e,i){return r(e,n,i[t])}}function i(n,t){return function(e){return r(e,n,t)}}function u(n){return A(n)?[]:{}}function o(n,t){return function(e){var i=u(t);return r(e,n,i),e.push(i)}}function s(n,t){if(O(t))return h.push(t),f.push(e(n,h.length-1));if(!t||t.constructor!=Object&&t.constructor!=Array)return f.push(i(n,t));var r=function(n){return n.pop()};return f.push(o(n,t)),c(t),f.push(r)}function a(t){for(var r,e=u(n),i=[e],o=0;o<f.length;o++)(r=f[o])(i,t);return e}function c(n){return I.each(n,s)}var f=[],h=[];return c(n),W(new g.Desc(g,"combineTemplate",[n]),g.combineAsArray(h).map(a))};var hn=function(n,t){var r=new p(x(n,"justInitValue"),function(t){var e=void 0,i=n.dispatcher.subscribe(function(n){return n.isEnd()||(e=n),g.noMore});return _.whenDoneWith(r,function(){return"undefined"!=typeof e&&null!==e&&t(e),t(G())}),i});return r.concat(t).toProperty()};g.Observable.prototype.mapEnd=function(){var n=H(arguments);return W(new g.Desc(this,"mapEnd",[n]),this.withHandler(function(t){return t.isEnd()?(this.push(X(n(t))),this.push(G()),g.noMore):this.push(t)}))},g.Observable.prototype.skipErrors=function(){return W(new g.Desc(this,"skipErrors",[]),this.withHandler(function(n){return n.isError()?g.more:this.push(n)}))},g.EventStream.prototype.takeUntil=function(n){var t={};return W(new g.Desc(this,"takeUntil",[n]),g.groupSimultaneous(this.mapEnd(t),n.skipErrors()).withHandler(function(n){if(n.hasValue()){var r=n.value(),e=r[0],i=r[1];if(i.length)return this.push(G());for(var u,o=g.more,s=0;s<e.length;s++)u=e[s],o=this.push(u===t?G():X(u));return o}return this.push(n)}))},g.Property.prototype.takeUntil=function(n){var t=this.changes().takeUntil(n);return W(new g.Desc(this,"takeUntil",[n]),hn(this,t))},g.Observable.prototype.flatMapLatest=function(){var n=sn(arguments),t=this.toEventStream();return W(new g.Desc(this,"flatMapLatest",[n]),t.flatMap(function(r){return an(n(r)).takeUntil(t)}))},g.Property.prototype.delayChanges=function(n,t){return W(n,hn(this,t(this.changes())))},g.EventStream.prototype.delayChanges=function(n,t){return W(n,t(this))},g.Observable.prototype.delay=function(n){return this.delayChanges(new g.Desc(this,"delay",[n]),function(t){return t.flatMap(function(t){return g.later(n,t)})})},g.Observable.prototype.debounce=function(n){return this.delayChanges(new g.Desc(this,"debounce",[n]),function(t){return t.flatMapLatest(function(t){return g.later(n,t)})})},g.Observable.prototype.debounceImmediate=function(n){return this.delayChanges(new g.Desc(this,"debounceImmediate",[n]),function(t){return t.flatMapFirst(function(t){return g.once(t).concat(g.later(n).filter(!1))})})},g.Observable.prototype.decode=function(n){return W(new g.Desc(this,"decode",[n]),this.combine(g.combineTemplate(n),function(n,t){return t[n]}))},g.Observable.prototype.scan=function(n,t){var r,e=this;t=z(t);var u=$(n),o=!1,a=function(n){var a=!1,c=E,f=g.more,h=function(){return a?void 0:u.forEach(function(t){return a=o=!0,f=n(new s(function(){return t})),f===g.noMore?(c(),
c=E):void 0})};return c=e.dispatcher.subscribe(function(r){if(r.hasValue()){if(o&&r.isInitial())return g.more;r.isInitial()||h(),a=o=!0;var e=u.getOrElse(void 0),s=t(e,r.value());return u=new i(s),n(r.apply(function(){return s}))}return r.isEnd()&&(f=h()),f!==g.noMore?n(r):void 0}),_.whenDoneWith(r,h),c};return r=new d(new g.Desc(this,"scan",[n,t]),a)},g.Observable.prototype.diff=function(n,t){return t=z(t),W(new g.Desc(this,"diff",[n,t]),this.scan([n],function(n,r){return[r,t(n[0],r)]}).filter(function(n){return 2===n.length}).map(function(n){return n[1]}))},g.Observable.prototype.doAction=function(){var n=H(arguments);return W(new g.Desc(this,"doAction",[n]),this.withHandler(function(t){return t.hasValue()&&n(t.value()),this.push(t)}))},g.Observable.prototype.doEnd=function(){var n=H(arguments);return W(new g.Desc(this,"doEnd",[n]),this.withHandler(function(t){return t.isEnd()&&n(),this.push(t)}))},g.Observable.prototype.doError=function(){var n=H(arguments);return W(new g.Desc(this,"doError",[n]),this.withHandler(function(t){return t.isError()&&n(t.error),this.push(t)}))},g.Observable.prototype.doLog=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return W(new g.Desc(this,"doLog",t),this.withHandler(function(n){return"undefined"!=typeof console&&null!==console&&"function"==typeof console.log&&console.log.apply(console,t.concat([n.log()])),this.push(n)}))},g.Observable.prototype.endOnError=function(n){("undefined"==typeof n||null===n)&&(n=!0);for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return U(this,n,r,function(n){return W(new g.Desc(this,"endOnError",[]),this.withHandler(function(t){return t.isError()&&n(t.error)?(this.push(t),this.push(G())):this.push(t)}))})},f.prototype.errors=function(){return W(new g.Desc(this,"errors",[]),this.filter(function(){return!1}))},g.Observable.prototype.take=function(n){return 0>=n?g.never():W(new g.Desc(this,"take",[n]),this.withHandler(function(t){return t.hasValue()?(n--,n>0?this.push(t):(0===n&&this.push(t),this.push(G()),g.noMore)):this.push(t)}))},g.Observable.prototype.first=function(){return W(new g.Desc(this,"first",[]),this.take(1))},g.Observable.prototype.mapError=function(){var n=H(arguments);return W(new g.Desc(this,"mapError",[n]),this.withHandler(function(t){return this.push(t.isError()?X(n(t.error)):t)}))},g.Observable.prototype.flatMapError=function(n){var t=new g.Desc(this,"flatMapError",[n]);return W(t,this.mapError(function(n){return new c(n)}).flatMap(function(t){return t instanceof c?n(t.error):g.once(t)}))},g.EventStream.prototype.flatScan=function(n,t){var r=n;return this.flatMapConcat(function(n){return an(t(r,n)).doAction(function(n){return r=n})}).toProperty(n)},g.EventStream.prototype.sampledBy=function(n,t){return W(new g.Desc(this,"sampledBy",[n,t]),this.toProperty().sampledBy(n,t))},g.Property.prototype.sampledBy=function(t,r){var e=!1;"undefined"!=typeof r&&null!==r?r=z(r):(e=!0,r=function(n){return n.value()});var i=new n(this,!1,e),u=new n(t,!0,e),o=g.when([i,u],r),s=t._isProperty?o.toProperty():o;return W(new g.Desc(this,"sampledBy",[t,r]),s)},g.Property.prototype.sample=function(n){return W(new g.Desc(this,"sample",[n]),this.sampledBy(g.interval(n,{})))},g.Observable.prototype.map=function(n){if(n&&n._isProperty)return n.sampledBy(this,D);for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return U(this,n,r,function(n){return W(new g.Desc(this,"map",[n]),this.withHandler(function(t){return this.push(t.fmap(n))}))})},g.Observable.prototype.fold=function(n,t){return W(new g.Desc(this,"fold",[n,t]),this.scan(n,t).sampledBy(this.filter(!1).mapEnd().toProperty()))},f.prototype.reduce=f.prototype.fold;var ln=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"],["bind","unbind"]],pn=function(n){for(var t,r=0;r<ln.length;r++){t=ln[r];var e=[n[t[0]],n[t[1]]];if(e[0]&&e[1])return e}for(var i=0;i<ln.length;i++){t=ln[i];var u=n[t[0]];if(u)return[u,function(){}]}throw new c("No suitable event methods in "+n)};g.fromEventTarget=function(n,t,r){var e=pn(n),i=e[0],u=e[1],o=new g.Desc(g,"fromEvent",[n,t]);return W(o,g.fromBinder(function(r){return i.call(n,t,r),function(){return u.call(n,t,r)}},r))},g.fromEvent=g.fromEventTarget,g.fromPoll=function(n,t){var r=new g.Desc(g,"fromPoll",[n,t]);return W(r,g.fromBinder(function(t){var r=g.scheduler.setInterval(t,n);return function(){return g.scheduler.clearInterval(r)}},t))},g.fromPromise=function(n,t){var r=arguments.length<=2||void 0===arguments[2]?m:arguments[2];return W(new g.Desc(g,"fromPromise",[n]),g.fromBinder(function(r){var e=n.then(r,function(n){return r(new c(n))});return e&&"function"==typeof e.done&&e.done(),t?function(){return"function"==typeof n.abort?n.abort():void 0}:function(){}},r))},g.Observable.prototype.groupBy=function(n){var t=arguments.length<=1||void 0===arguments[1]?g._.id:arguments[1],r={},e=this;return e.filter(function(t){return!r[n(t)]}).map(function(i){var u=n(i),o=e.filter(function(t){return n(t)===u}),s=g.once(i).concat(o),a=t(s,i).withHandler(function(n){return this.push(n),n.isEnd()?delete r[u]:void 0});return r[u]=a,a})},g.fromArray=function(n){if(n.length){var t=0;return new p(new g.Desc(g,"fromArray",[n]),function(r){var e=!1,i=g.more,u=!1,o=!1,s=function(){if(o=!0,!u){for(u=!0;o;)if(o=!1,i!==g.noMore&&!e){var a=n[t++];i=r(J(a)),i!==g.noMore&&(t===n.length?r(G()):_.afterTransaction(s))}return u=!1}};return s(),function(){return e=!0}})}return W(new g.Desc(g,"fromArray",n),g.never())},g.EventStream.prototype.holdWhen=function(n){var t=!1,r=[],e=this,i=!1;return new p(new g.Desc(this,"holdWhen",[n]),function(u){var o=new h,s=!1,a=function(n){return"function"==typeof n&&n(),o.empty()&&s?u(G()):void 0};return o.add(function(e,o){return n.subscribeInternal(function(n){if(!n.hasValue())return n.isEnd()?a(o):u(n);if(t=n.value(),!t){var e=r;return r=[],function(){for(var n,t=[],r=0;r<e.length;r++)n=e[r],t.push(u(X(n)));return i&&(t.push(u(G())),o()),t}()}})}),o.add(function(n,o){return e.subscribeInternal(function(n){return t&&n.hasValue()?r.push(n.value()):n.isEnd()&&r.length?(i=!0,a(o)):u(n)})}),s=!0,a(),o.unsubscribe})},g.interval=function(n){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return W(new g.Desc(g,"interval",[n,t]),g.fromPoll(n,function(){return X(t)}))},g.$={},g.$.asEventStream=function(n,t,r){var e=this;return I.isFunction(t)&&(r=t,t=void 0),W(new g.Desc(this.selector||this,"asEventStream",[n]),g.fromBinder(function(r){return e.on(n,t,r),function(){return e.off(n,t,r)}},r))},"undefined"!=typeof jQuery&&jQuery&&(jQuery.fn.asEventStream=g.$.asEventStream),"undefined"!=typeof Zepto&&Zepto&&(Zepto.fn.asEventStream=g.$.asEventStream),g.Observable.prototype.last=function(){var n;return W(new g.Desc(this,"last",[]),this.withHandler(function(t){return t.isEnd()?(n&&this.push(n),this.push(G()),g.noMore):void(n=t)}))},g.Observable.prototype.log=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return this.subscribe(function(n){"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,t.concat([n.log()]))}),this},g.EventStream.prototype.merge=function(n){var t=this;return W(new g.Desc(t,"merge",[n]),g.mergeAll(this,n))},g.mergeAll=function(){var n=rn(arguments);return n.length?new p(new g.Desc(g,"mergeAll",n),function(t){var r=0,e=function(e){return function(i){return e.dispatcher.subscribe(function(e){if(e.isEnd())return r++,r===n.length?t(G()):g.more;var u=t(e);return u===g.noMore&&i(),u})}},i=I.map(e,n);return new g.CompositeUnsubscribe(i).unsubscribe}):g.never()},g.repeatedly=function(n,t){var r=0;return W(new g.Desc(g,"repeatedly",[n,t]),g.fromPoll(n,function(){return t[r++%t.length]}))},g.repeat=function(n){var t=0;return g.fromBinder(function(r){function e(n){return n.isEnd()?u?i():u=!0:o=r(n)}function i(){var i;for(u=!0;u&&o!==g.noMore;)i=n(t++),u=!1,i?s=i.subscribeInternal(e):r(G());return u=!0}var u=!1,o=g.more,s=function(){};return i(),function(){return s()}})},g.retry=function(n){if(!I.isFunction(n.source))throw new w("'source' option has to be a function");var t=n.source,r=n.retries||0,e=0,i=n.delay||function(){return 0},u=n.isRetryable||function(){return!0},o=!1,s=null;return W(new g.Desc(g,"retry",[n]),g.repeat(function(){function n(){return t().endOnError().withHandler(function(n){return n.isError()?(s=n,u(s.error)&&(0===r||r>e)?void 0:(o=!0,this.push(n))):(n.hasValue()&&(s=null,o=!0),this.push(n))})}if(o)return null;if(s){var a={error:s.error,retriesDone:e},c=g.later(i(a)).filter(!1);return e++,c.concat(g.once().flatMap(n))}return n()}))},g.sequentially=function(n,t){var r=0;return W(new g.Desc(g,"sequentially",[n,t]),g.fromPoll(n,function(){var n=t[r++];return r<t.length?n:r===t.length?[n,G()]:G()}))},g.Observable.prototype.skip=function(n){return W(new g.Desc(this,"skip",[n]),this.withHandler(function(t){return t.hasValue()&&n>0?(n--,g.more):this.push(t)}))},g.EventStream.prototype.skipUntil=function(n){var t=n.take(1).map(!0).toProperty(!1);return W(new g.Desc(this,"skipUntil",[n]),this.filter(t))},g.EventStream.prototype.skipWhile=function(n){for(var t=!1,r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];return U(this,n,e,function(n){return W(new g.Desc(this,"skipWhile",[n]),this.withHandler(function(r){return!t&&r.hasValue()&&n(r.value())?g.more:(r.hasValue()&&(t=!0),this.push(r))}))})},g.Observable.prototype.slidingWindow=function(n){var t=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return W(new g.Desc(this,"slidingWindow",[n,t]),this.scan([],function(t,r){return t.concat([r]).slice(-n)}).filter(function(n){return n.length>=t}))};var vn=[],Y=function(n){if(vn.length&&!Y.running)try{Y.running=!0,vn.forEach(function(t){t(n)})}finally{delete Y.running}};g.spy=function(n){return vn.push(n)},g.Property.prototype.startWith=function(n){return W(new g.Desc(this,"startWith",[n]),this.scan(n,function(n,t){return t}))},g.EventStream.prototype.startWith=function(n){return W(new g.Desc(this,"startWith",[n]),g.once(n).concat(this))},g.Observable.prototype.takeWhile=function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return U(this,n,r,function(n){return W(new g.Desc(this,"takeWhile",[n]),this.withHandler(function(t){return t.filter(n)?this.push(t):(this.push(G()),g.noMore)}))})},g.Observable.prototype.throttle=function(n){return this.delayChanges(new g.Desc(this,"throttle",[n]),function(t){return t.bufferWithTime(n).map(function(n){return n[n.length-1]})})},f.prototype.firstToPromise=function(n){var t=this;if("function"!=typeof n){if("function"!=typeof Promise)throw new w("There isn't default Promise, use shim or parameter");n=Promise}return new n(function(n,r){return t.subscribe(function(t){return t.hasValue()&&n(t.value()),t.isError()&&r(t.error),g.noMore})})},f.prototype.toPromise=function(n){return this.last().firstToPromise(n)},g["try"]=function(n){return function(t){try{return g.once(n(t))}catch(r){return new g.Error(r)}}},g.update=function(n){function t(n){return function(){for(var t=arguments.length,r=Array(t),e=0;t>e;e++)r[e]=arguments[e];return function(t){return n.apply(void 0,[t].concat(r))}}}for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];for(var u=e.length-1;u>0;)e[u]instanceof Function||(e[u]=I.always(e[u])),e[u]=t(e[u]),u-=2;return W(new g.Desc(g,"update",[n].concat(e)),g.when.apply(g,e).scan(n,function(n,t){return t(n)}))},g.zipAsArray=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];var e=rn(t);return W(new g.Desc(g,"zipAsArray",e),g.zipWith(e,function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return t}))},g.zipWith=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];var e=en(t),i=e[0],u=e[1];return i=I.map(function(n){return n.toEventStream()},i),W(new g.Desc(g,"zipWith",[u].concat(i)),g.when(i,u))},g.Observable.prototype.zip=function(n,t){return W(new g.Desc(this,"zip",[n]),g.zipWith([this,n],t||Array))},"undefined"!=typeof define&&null!==define&&null!=define.amd?(define([],function(){return g}),"undefined"!=typeof this&&null!==this&&(this.Bacon=g)):"undefined"!=typeof module&&null!==module&&null!=module.exports?(module.exports=g,g.Bacon=g):this.Bacon=g}).call(this);
(function(){function n(n,t){var r=arguments.length<=2||void 0===arguments[2]?!1:arguments[2];this.obs=n,this.sync=t,this.lazy=r,this.queue=[]}function t(){n.apply(this,arguments)}function r(t){n.call(this,t,!0)}function e(n,t,r){this.context=n,this.method=t,this.args=r}function i(n){this.value=n}function u(){this.id=++Q}function o(n,t){return this instanceof o?(u.call(this),void(!t&&I.isFunction(n)||(null!=n?n._isNext:void 0)?(this.valueF=n,this.valueInternal=void 0):(this.valueF=void 0,this.valueInternal=n))):new o(n,t)}function s(n,t){return this instanceof s?void o.call(this,n,t):new s(n,t)}function a(){return this instanceof a?void u.call(this):new a}function c(n){return this instanceof c?(this.error=n,void u.call(this)):new c(n)}function f(n){this.desc=n,this.id=++K,this.initialDesc=this.desc}function h(){var n=arguments.length<=0||void 0===arguments[0]?[]:arguments[0];this.unsubscribe=I.bind(this.unsubscribe,this),this.unsubscribed=!1,this.subscriptions=[],this.starting=[];for(var t,r=0;r<n.length;r++)t=n[r],this.add(t)}function l(n,t){this._subscribe=n,this._handleEvent=t,this.subscribe=I.bind(this.subscribe,this),this.handleEvent=I.bind(this.handleEvent,this),this.pushing=!1,this.ended=!1,this.prevError=void 0,this.unsubSrc=void 0,this.subscriptions=[],this.queue=[]}function p(n,t,r){return this instanceof p?(I.isFunction(n)&&(r=t,t=n,n=e.empty),f.call(this,n),this.dispatcher=new l(t,r),void Y(this)):new p(n,t,r)}function v(n,t,r){l.call(this,t,r),this.property=n,this.subscribe=I.bind(this.subscribe,this),this.current=R,this.currentValueRootId=void 0,this.propertyEnded=!1}function d(n,t,r){f.call(this,n),this.dispatcher=new v(this,t,r),Y(this)}function y(){return this instanceof y?(this.unsubAll=I.bind(this.unsubAll,this),this.subscribeAll=I.bind(this.subscribeAll,this),this.guardedSink=I.bind(this.guardedSink,this),this.sink=void 0,this.subscriptions=[],this.ended=!1,void p.call(this,new g.Desc(g,"Bus",[]),this.subscribeAll)):new y}function m(n){return[n,G()]}var b=Array.prototype.slice,g={toString:function(){return"Bacon"}};g.version="0.7.91";var w=("undefined"!=typeof global&&null!==global?global:this).Error,E=function(){},D=function(n,t){return n},S=function(n){return n.slice(0)},A=Array.isArray||function(n){return n instanceof Array},O=function(n){return n&&n._isObservable},M=function(n){for(var t=arguments.length,r=1;t>1?t>r:r>t;t>1?r++:r--)for(var e in arguments[r])n[e]=arguments[r][e];return n},k=function(n,t){var r={}.hasOwnProperty,e=function(){};e.prototype=t.prototype,n.prototype=new e;for(var i in t)r.call(t,i)&&(n[i]=t[i]);return n},I={indexOf:function(){return Array.prototype.indexOf?function(n,t){return n.indexOf(t)}:function(n,t){for(var r,e=0;e<n.length;e++)if(r=n[e],t===r)return e;return-1}}(),indexWhere:function(n,t){for(var r,e=0;e<n.length;e++)if(r=n[e],t(r))return e;return-1},head:function(n){return n[0]},always:function(n){return function(){return n}},negate:function(n){return function(t){return!n(t)}},empty:function(n){return 0===n.length},tail:function(n){return n.slice(1,n.length)},filter:function(n,t){for(var r,e=[],i=0;i<t.length;i++)r=t[i],n(r)&&e.push(r);return e},map:function(n,t){return function(){for(var r,e=[],i=0;i<t.length;i++)r=t[i],e.push(n(r));return e}()},each:function(n,t){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var e=n[r];t(r,e)}},toArray:function(n){return A(n)?n:[n]},contains:function(n,t){return-1!==I.indexOf(n,t)},id:function(n){return n},last:function(n){return n[n.length-1]},all:function(n){for(var t,r=arguments.length<=1||void 0===arguments[1]?I.id:arguments[1],e=0;e<n.length;e++)if(t=n[e],!r(t))return!1;return!0},any:function(n){for(var t,r=arguments.length<=1||void 0===arguments[1]?I.id:arguments[1],e=0;e<n.length;e++)if(t=n[e],r(t))return!0;return!1},without:function(n,t){return I.filter(function(t){return t!==n},t)},remove:function(n,t){var r=I.indexOf(t,n);return r>=0?t.splice(r,1):void 0},fold:function(n,t,r){for(var e,i=0;i<n.length;i++)e=n[i],t=r(t,e);return t},flatMap:function(n,t){return I.fold(t,[],function(t,r){return t.concat(n(r))})},cached:function(n){var t=R;return function(){return("undefined"!=typeof t&&null!==t?t._isNone:void 0)&&(t=n(),n=void 0),t}},bind:function(n,t){return function(){return n.apply(t,arguments)}},isFunction:function(n){return"function"==typeof n},toString:function(n){var t,r,e,i={}.hasOwnProperty;try{return P++,null==n?"undefined":I.isFunction(n)?"function":A(n)?P>5?"[..]":"["+I.map(I.toString,n).toString()+"]":null!=(null!=n?n.toString:void 0)&&n.toString!==Object.prototype.toString?n.toString():"object"==typeof n?P>5?"{..}":(t=function(){var t=[];for(r in n)i.call(n,r)&&(e=function(){var t;try{return n[r]}catch(t){return t}}(),t.push(I.toString(r)+":"+I.toString(e)));return t}(),"{"+t+"}"):n}finally{P--}}},P=0;g._=I;var _=g.UpdateBarrier=function(){var n,t=[],r={},e=[],i=0,u={},o=function(t){return n?e.push(t):t()},s=function(e,i){if(n){var u=r[e.id];return"undefined"==typeof u||null===u?(u=r[e.id]=[i],t.push(e)):u.push(i)}return i()},a=function(){for(;t.length>0;)c(0,!0);u={}},c=function(n,e){var i=t[n],u=i.id,o=r[u];t.splice(n,1),delete r[u],e&&t.length>0&&f(i);for(var s,a=0;a<o.length;a++)(s=o[a])()},f=function(n){if(!u[n.id]){for(var e,i=n.internalDeps(),o=0;o<i.length;o++)if(e=i[o],f(e),r[e.id]){var s=I.indexOf(t,e);c(s,!1)}u[n.id]=!0}},h=function(t,r,u,o){if(n)return u.apply(r,o);n=t;try{var s=u.apply(r,o);a()}finally{for(n=void 0;i<e.length;){var c=e[i];i++,c()}i=0,e=[]}return s},l=function(){return n?n.id:void 0},p=function(n,t){var r=!1,e=!1,i=function(){return e=!0},u=function(){return r=!0,i()};return i=n.dispatcher.subscribe(function(n){return o(function(){if(!r){var e=t(n);if(e===g.noMore)return u()}})}),e&&i(),u},v=function(){return t.length>0};return{whenDoneWith:s,hasWaiters:v,inTransaction:h,currentEventId:l,wrappedSubscribe:p,afterTransaction:o}}();M(n.prototype,{_isSource:!0,subscribe:function(n){return this.obs.dispatcher.subscribe(n)},toString:function(){return this.obs.toString()},markEnded:function(){return this.ended=!0,!0},consume:function(){return this.lazy?{value:I.always(this.queue[0])}:this.queue[0]},push:function(n){return this.queue=[n],[n]},mayHave:function(){return!0},hasAtLeast:function(){return this.queue.length},flatten:!0}),k(t,n),M(t.prototype,{consume:function(){return this.queue.shift()},push:function(n){return this.queue.push(n)},mayHave:function(n){return!this.ended||this.queue.length>=n},hasAtLeast:function(n){return this.queue.length>=n},flatten:!1}),k(r,n),M(r.prototype,{consume:function(){var n=this.queue;return this.queue=[],{value:function(){return n}}},push:function(n){return this.queue.push(n.value())},hasAtLeast:function(){return!0}}),n.isTrigger=function(n){return(null!=n?n._isSource:void 0)?n.sync:null!=n?n._isEventStream:void 0},n.fromObservable=function(r){return(null!=r?r._isSource:void 0)?r:(null!=r?r._isProperty:void 0)?new n(r,!1):new t(r,!0)},M(e.prototype,{_isDesc:!0,deps:function(){return this.cached||(this.cached=T([this.context].concat(this.args))),this.cached},toString:function(){return I.toString(this.context)+"."+I.toString(this.method)+"("+I.map(I.toString,this.args)+")"}});var x=function(n,t){var r=n||t;if(r&&r._isDesc)return n||t;for(var i=arguments.length,u=Array(i>2?i-2:0),o=2;i>o;o++)u[o-2]=arguments[o];return new e(n,t,u)},W=function(n,t){return t.desc=n,t},T=function(n){return A(n)?I.flatMap(T,n):O(n)?[n]:("undefined"!=typeof n&&null!==n?n._isSource:void 0)?[n.obs]:[]};g.Desc=e,g.Desc.empty=new g.Desc("","",[]);var V=function(n){return function(t){for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];if("object"==typeof t&&e.length){var u=t,o=e[0];t=function(){return u[o].apply(u,arguments)},e=e.slice(1)}return n.apply(void 0,[t].concat(e))}},H=function(n){return n=Array.prototype.slice.call(n),N.apply(void 0,n)},B=function(n,t){return function(){for(var r=arguments.length,e=Array(r),i=0;r>i;i++)e[i]=arguments[i];return n.apply(void 0,t.concat(e))}},F=function(n){return function(t){return function(r){if("undefined"!=typeof r&&null!==r){var e=r[t];return I.isFunction(e)?e.apply(r,n):e}}}},C=function(n,t){var r=n.slice(1).split("."),e=I.map(F(t),r);return function(n){for(var t,r=0;r<e.length;r++)t=e[r],n=t(n);return n}},q=function(n){return"string"==typeof n&&n.length>1&&"."===n.charAt(0)},N=V(function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return I.isFunction(n)?r.length?B(n,r):n:q(n)?C(n,r):I.always(n)}),L=function(n,t){return N.apply(void 0,[n].concat(t))},U=function(n,t,r,e){if("undefined"!=typeof t&&null!==t?t._isProperty:void 0){var i=t.sampledBy(n,function(n,t){return[n,t]});return e.call(i,function(n){{var t=n[0];n[1]}return t}).map(function(n){var t=(n[0],n[1]);return t})}return t=L(t,r),e.call(n,t)},z=function(n){if(I.isFunction(n))return n;if(q(n)){var t=j(n);return function(n,r){return n[t](r)}}throw new w("not a function or a field key: "+n)},j=function(n){return n.slice(1)};M(i.prototype,{_isSome:!0,getOrElse:function(){return this.value},get:function(){return this.value},filter:function(n){return n(this.value)?new i(this.value):R},map:function(n){return new i(n(this.value))},forEach:function(n){return n(this.value)},isDefined:!0,toArray:function(){return[this.value]},inspect:function(){return"Some("+this.value+")"},toString:function(){return this.inspect()}});var R={_isNone:!0,getOrElse:function(n){return n},filter:function(){return R},map:function(){return R},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},$=function(n){return("undefined"!=typeof n&&null!==n?n._isSome:void 0)||("undefined"!=typeof n&&null!==n?n._isNone:void 0)?n:new i(n)};g.noMore="<no-more>",g.more="<more>";var Q=0;u.prototype._isEvent=!0,u.prototype.isEvent=function(){return!0},u.prototype.isEnd=function(){return!1},u.prototype.isInitial=function(){return!1},u.prototype.isNext=function(){return!1},u.prototype.isError=function(){return!1},u.prototype.hasValue=function(){return!1},u.prototype.filter=function(){return!0},u.prototype.inspect=function(){return this.toString()},u.prototype.log=function(){return this.toString()},k(o,u),o.prototype.isNext=function(){return!0},o.prototype.hasValue=function(){return!0},o.prototype.value=function(){var n;return(null!=(n=this.valueF)?n._isNext:void 0)?(this.valueInternal=this.valueF.value(),this.valueF=void 0):this.valueF&&(this.valueInternal=this.valueF(),this.valueF=void 0),this.valueInternal},o.prototype.fmap=function(n){var t,r;return this.valueInternal?(r=this.valueInternal,this.apply(function(){return n(r)})):(t=this,this.apply(function(){return n(t.value())}))},o.prototype.apply=function(n){return new o(n)},o.prototype.filter=function(n){return n(this.value())},o.prototype.toString=function(){return I.toString(this.value())},o.prototype.log=function(){return this.value()},o.prototype._isNext=!0,k(s,o),s.prototype._isInitial=!0,s.prototype.isInitial=function(){return!0},s.prototype.isNext=function(){return!1},s.prototype.apply=function(n){return new s(n)},s.prototype.toNext=function(){return new o(this)},k(a,u),a.prototype.isEnd=function(){return!0},a.prototype.fmap=function(){return this},a.prototype.apply=function(){return this},a.prototype.toString=function(){return"<end>"},k(c,u),c.prototype.isError=function(){return!0},c.prototype.fmap=function(){return this},c.prototype.apply=function(){return this},c.prototype.toString=function(){return"<error> "+I.toString(this.error)},g.Event=u,g.Initial=s,g.Next=o,g.End=a,g.Error=c;var Z=function(n){return new s(n,!0)},X=function(n){return new o(n,!0)},G=function(){return new a},J=function(n){return n&&n._isEvent?n:X(n)},K=0,Y=function(){};M(f.prototype,{_isObservable:!0,subscribe:function(n){return _.wrappedSubscribe(this,n)},subscribeInternal:function(n){return this.dispatcher.subscribe(n)},onValue:function(){var n=H(arguments);return this.subscribe(function(t){return t.hasValue()?n(t.value()):void 0})},onValues:function(n){return this.onValue(function(t){return n.apply(void 0,t)})},onError:function(){var n=H(arguments);return this.subscribe(function(t){return t.isError()?n(t.error):void 0})},onEnd:function(){var n=H(arguments);return this.subscribe(function(t){return t.isEnd()?n():void 0})},name:function(n){return this._name=n,this},withDescription:function(){return this.desc=x.apply(void 0,arguments),this},toString:function(){return this._name?this._name:this.desc.toString()},deps:function(){return this.desc.deps()},internalDeps:function(){return this.initialDesc.deps()}}),f.prototype.assign=f.prototype.onValue,f.prototype.forEach=f.prototype.onValue,f.prototype.inspect=f.prototype.toString,g.Observable=f,M(h.prototype,{add:function(n){var t=this;if(!this.unsubscribed){var r=!1,e=E;this.starting.push(n);var i=function(){return t.unsubscribed?void 0:(r=!0,t.remove(e),I.remove(n,t.starting))};return e=n(this.unsubscribe,i),this.unsubscribed||r?e():this.subscriptions.push(e),I.remove(n,this.starting),e}},remove:function(n){return this.unsubscribed?void 0:void 0!==I.remove(n,this.subscriptions)?n():void 0},unsubscribe:function(){if(!this.unsubscribed){this.unsubscribed=!0;for(var n=this.subscriptions,t=0;t<n.length;t++)n[t]();return this.subscriptions=[],this.starting=[],[]}},count:function(){return this.unsubscribed?0:this.subscriptions.length+this.starting.length},empty:function(){return 0===this.count()}}),g.CompositeUnsubscribe=h,l.prototype.hasSubscribers=function(){return this.subscriptions.length>0},l.prototype.removeSub=function(n){return this.subscriptions=I.without(n,this.subscriptions),this.subscriptions},l.prototype.push=function(n){return n.isEnd()&&(this.ended=!0),_.inTransaction(n,this,this.pushIt,[n])},l.prototype.pushToSubscriptions=function(n){try{for(var t=this.subscriptions,r=t.length,e=0;r>e;e++){var i=t[e],u=i.sink(n);(u===g.noMore||n.isEnd())&&this.removeSub(i)}return!0}catch(o){throw this.pushing=!1,this.queue=[],o}},l.prototype.pushIt=function(n){if(this.pushing)return this.queue.push(n),g.more;if(n!==this.prevError){for(n.isError()&&(this.prevError=n),this.pushing=!0,this.pushToSubscriptions(n),this.pushing=!1;this.queue.length;)n=this.queue.shift(),this.push(n);return this.hasSubscribers()?g.more:(this.unsubscribeFromSource(),g.noMore)}},l.prototype.handleEvent=function(n){return this._handleEvent?this._handleEvent(n):this.push(n)},l.prototype.unsubscribeFromSource=function(){this.unsubSrc&&this.unsubSrc(),this.unsubSrc=void 0},l.prototype.subscribe=function(n){var t;return this.ended?(n(G()),E):(t={sink:n},this.subscriptions.push(t),1===this.subscriptions.length&&(this.unsubSrc=this._subscribe(this.handleEvent)),function(n){return function(){return n.removeSub(t),n.hasSubscribers()?void 0:n.unsubscribeFromSource()}}(this))},g.Dispatcher=l,k(p,f),M(p.prototype,{_isEventStream:!0,toProperty:function(n){var t=0===arguments.length?R:$(function(){return n}),r=this.dispatcher,e=new g.Desc(this,"toProperty",[n]);return new d(e,function(n){var e=!1,u=!1,o=E,a=g.more,c=function(){return e?void 0:t.forEach(function(t){return e=!0,a=n(new s(t)),a===g.noMore?(o(),o=E,E):void 0})};return o=r.subscribe(function(r){return r.hasValue()?r.isInitial()&&!u?(t=new i(function(){return r.value()}),g.more):(r.isInitial()||c(),e=!0,t=new i(r),n(r)):(r.isEnd()&&(a=c()),a!==g.noMore?n(r):void 0)}),u=!0,c(),o})},toEventStream:function(){return this},withHandler:function(n){return new p(new g.Desc(this,"withHandler",[n]),this.dispatcher.subscribe,n)}}),g.EventStream=p,g.never=function(){return new p(x(g,"never"),function(n){return n(G()),E})},g.when=function(){if(0===arguments.length)return g.never();for(var t=arguments.length,r=[],e=[],i=0,u=[];t>i;){u[i]=arguments[i],u[i+1]=arguments[i+1];for(var o,s=I.toArray(arguments[i]),a=tn(arguments[i+1]),c={f:a,ixs:[]},f=!1,h=0;h<s.length;h++){o=s[h];var l=I.indexOf(r,o);f||(f=n.isTrigger(o)),0>l&&(r.push(o),l=r.length-1);for(var v,d=0;d<c.ixs.length;d++)v=c.ixs[d],v.index===l&&v.count++;c.ixs.push({index:l,count:1})}s.length>0&&e.push(c),i+=2}if(!r.length)return g.never();r=I.map(n.fromObservable,r);var y=I.any(r,function(n){return n.flatten})&&nn(I.map(function(n){return n.obs},r)),m=new g.Desc(g,"when",u),b=new p(m,function(n){var t=[],i=!1,u=function(n){for(var t,e=0;e<n.ixs.length;e++)if(t=n.ixs[e],!r[t.index].hasAtLeast(t.count))return!1;return!0},o=function(n){return!n.sync||n.ended},s=function(n){for(var t,e=0;e<n.ixs.length;e++)if(t=n.ixs[e],!r[t.index].mayHave(t.count))return!0},a=function(n){return!n.source.flatten},c=function(c){return function(f){var h=function(){return _.whenDoneWith(b,p)},l=function(){if(!(t.length>0))return g.more;for(var i,o=g.more,s=t.pop(),c=0;c<e.length;c++)if(i=e[c],u(i)){var f=function(){for(var n,t=[],e=0;e<i.ixs.length;e++)n=i.ixs[e],t.push(r[n.index].consume());return t}();return o=n(s.e.apply(function(){var n,t=function(){for(var n,t=[],r=0;r<f.length;r++)n=f[r],t.push(n.value());return t}();return(n=i).f.apply(n,t)})),t.length&&(t=I.filter(a,t)),o===g.noMore?o:l()}},p=function(){var t=l();return i&&(I.all(r,o)||I.all(e,s))&&(t=g.noMore,n(G())),t===g.noMore&&f(),t};return c.subscribe(function(r){if(r.isEnd())i=!0,c.markEnded(),h();else if(r.isError())var e=n(r);else c.push(r),c.sync&&(t.push({source:c,e:r}),y||_.hasWaiters()?h():p());return e===g.noMore&&f(),e||g.more})}};return new g.CompositeUnsubscribe(function(){for(var n,t=[],e=0;e<r.length;e++)n=r[e],t.push(c(n));return t}()).unsubscribe});return b};var nn=function(n){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],r=function(n){if(I.contains(t,n))return!0;var e=n.internalDeps();return e.length?(t.push(n),I.any(e,r)):(t.push(n),!1)};return I.any(n,r)},tn=function(n){return I.isFunction(n)?n:I.always(n)};g.groupSimultaneous=function(){for(var n=arguments.length,t=Array(n),e=0;n>e;e++)t[e]=arguments[e];1===t.length&&A(t[0])&&(t=t[0]);var i=function(){for(var n,e=[],i=0;i<t.length;i++)n=t[i],e.push(new r(n));return e}();return W(new g.Desc(g,"groupSimultaneous",t),g.when(i,function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return t}))},k(v,l),M(v.prototype,{push:function(n){return n.isEnd()&&(this.propertyEnded=!0),n.hasValue()&&(this.current=new i(n),this.currentValueRootId=_.currentEventId()),l.prototype.push.call(this,n)},maybeSubSource:function(n,t){return t===g.noMore?E:this.propertyEnded?(n(G()),E):l.prototype.subscribe.call(this,n)},subscribe:function(n){var t=this,r=g.more;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=_.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?(_.whenDoneWith(this.property,function(){return t.currentValueRootId===i?n(Z(t.current.get().value())):void 0}),this.maybeSubSource(n,r)):(_.inTransaction(void 0,this,function(){return r=n(Z(this.current.get().value()))},[]),this.maybeSubSource(n,r))}return this.maybeSubSource(n,r)}}),k(d,f),M(d.prototype,{_isProperty:!0,changes:function(){var n=this;return new p(new g.Desc(this,"changes",[]),function(t){return n.dispatcher.subscribe(function(n){return n.isInitial()?void 0:t(n)})})},withHandler:function(n){return new d(new g.Desc(this,"withHandler",[n]),this.dispatcher.subscribe,n)},toProperty:function(){return this},toEventStream:function(){var n=this;return new p(new g.Desc(this,"toEventStream",[]),function(t){return n.dispatcher.subscribe(function(n){return n.isInitial()&&(n=n.toNext()),t(n)})})}}),g.Property=d,g.constant=function(n){return new d(new g.Desc(g,"constant",[n]),function(t){return t(Z(n)),t(G()),E})},g.fromBinder=function(n){var t=arguments.length<=1||void 0===arguments[1]?I.id:arguments[1],r=new g.Desc(g,"fromBinder",[n,t]);return new p(r,function(r){var e=!1,i=!1,u=function(){return e?void 0:"undefined"!=typeof o&&null!==o?(o(),e=!0):i=!0},o=n(function(){for(var n,e=arguments.length,i=Array(e),o=0;e>o;o++)i[o]=arguments[o];var s=t.apply(this,i);A(s)&&(null!=(n=I.last(s))?n._isEvent:void 0)||(s=[s]);for(var a,c=g.more,f=0;f<s.length;f++)if(a=s[f],c=r(a=J(a)),c===g.noMore||a.isEnd())return u(),c;return c});return i&&u(),u})},g.Observable.prototype.map=function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return U(this,n,r,function(n){return W(new g.Desc(this,"map",[n]),this.withHandler(function(t){return this.push(t.fmap(n))}))})};var rn=function(n){return A(n[0])?n[0]:Array.prototype.slice.call(n)},en=function(n){return I.isFunction(n[0])?[rn(Array.prototype.slice.call(n,1)),n[0]]:[rn(Array.prototype.slice.call(n,0,n.length-1)),I.last(n)]};g.combineAsArray=function(){var t=rn(arguments);if(t.length){for(var r=[],e=0;e<t.length;e++){var i=O(t[e])?t[e]:g.constant(t[e]);r.push(new n(i,!0))}return W(new g.Desc(g,"combineAsArray",t),g.when(r,function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return t}).toProperty())}return g.constant([])},g.onValues=function(){return g.combineAsArray(Array.prototype.slice.call(arguments,0,arguments.length-1)).onValues(arguments[arguments.length-1])},g.combineWith=function(){var n=en(arguments),t=n[0],r=n[1],e=new g.Desc(g,"combineWith",[r].concat(t));return W(e,g.combineAsArray(t).map(function(n){return r.apply(void 0,n)}))},g.Observable.prototype.combine=function(n,t){var r=z(t),e=new g.Desc(this,"combine",[n,t]);return W(e,g.combineAsArray(this,n).map(function(n){return r(n[0],n[1])}))},g.Observable.prototype.withStateMachine=function(n,t){var r=n,e=new g.Desc(this,"withStateMachine",[n,t]);return W(e,this.withHandler(function(n){var e=t(r,n),i=e[0],u=e[1];r=i;for(var o,s=g.more,a=0;a<u.length;a++)if(o=u[a],s=this.push(o),s===g.noMore)return s;return s}))};var un=function(n,t){return n===t},on=function(n){return"undefined"!=typeof n&&null!==n?n._isNone:!1};g.Observable.prototype.skipDuplicates=function(){var n=arguments.length<=0||void 0===arguments[0]?un:arguments[0],t=new g.Desc(this,"skipDuplicates",[]);return W(t,this.withStateMachine(R,function(t,r){return r.hasValue()?r.isInitial()||on(t)||!n(t.get(),r.value())?[new i(r.value()),[r]]:[t,[]]:[t,[r]]}))},g.Observable.prototype.awaiting=function(n){var t=new g.Desc(this,"awaiting",[n]);return W(t,g.groupSimultaneous(this,n).map(function(n){return 0===n[1].length}).toProperty(!1).skipDuplicates())},g.Observable.prototype.not=function(){return W(new g.Desc(this,"not",[]),this.map(function(n){return!n}))},g.Property.prototype.and=function(n){return W(new g.Desc(this,"and",[n]),this.combine(n,function(n,t){return n&&t}))},g.Property.prototype.or=function(n){return W(new g.Desc(this,"or",[n]),this.combine(n,function(n,t){return n||t}))},g.scheduler={setTimeout:function(n,t){return setTimeout(n,t)},setInterval:function(n,t){return setInterval(n,t)},clearInterval:function(n){return clearInterval(n)},clearTimeout:function(n){return clearTimeout(n)},now:function(){return(new Date).getTime()}},g.EventStream.prototype.bufferWithTime=function(n){return W(new g.Desc(this,"bufferWithTime",[n]),this.bufferWithTimeOrCount(n,Number.MAX_VALUE))},g.EventStream.prototype.bufferWithCount=function(n){return W(new g.Desc(this,"bufferWithCount",[n]),this.bufferWithTimeOrCount(void 0,n))},g.EventStream.prototype.bufferWithTimeOrCount=function(n,t){var r=function(r){return r.values.length===t?r.flush():void 0!==n?r.schedule():void 0},e=new g.Desc(this,"bufferWithTimeOrCount",[n,t]);return W(e,this.buffer(n,r,r))},g.EventStream.prototype.buffer=function(n){var t=arguments.length<=1||void 0===arguments[1]?E:arguments[1],r=arguments.length<=2||void 0===arguments[2]?E:arguments[2],e={scheduled:null,end:void 0,values:[],flush:function(){if(this.scheduled&&(g.scheduler.clearTimeout(this.scheduled),this.scheduled=null),this.values.length>0){var n=this.values;this.values=[];var t=this.push(X(n));if(null!=this.end)return this.push(this.end);if(t!==g.noMore)return r(this)}else if(null!=this.end)return this.push(this.end)},schedule:function(){var t=this;return this.scheduled?void 0:this.scheduled=n(function(){return t.flush()})}},i=g.more;if(!I.isFunction(n)){var u=n;n=function(n){return g.scheduler.setTimeout(n,u)}}return W(new g.Desc(this,"buffer",[]),this.withHandler(function(n){var r=this;return e.push=function(n){return r.push(n)},n.isError()?i=this.push(n):n.isEnd()?(e.end=n,e.scheduled||e.flush()):(e.values.push(n.value()),t(e)),i}))},g.Observable.prototype.filter=function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return U(this,n,r,function(n){return W(new g.Desc(this,"filter",[n]),this.withHandler(function(t){return t.filter(n)?this.push(t):g.more}))})},g.once=function(n){return new p(new e(g,"once",[n]),function(t){return t(J(n)),t(G()),E})},g.EventStream.prototype.concat=function(n){var t=this;return new p(new g.Desc(t,"concat",[n]),function(r){var e=E,i=t.dispatcher.subscribe(function(t){return t.isEnd()?e=n.dispatcher.subscribe(r):r(t)});return function(){return i(),e()}})},g.Observable.prototype.flatMap=function(){return cn(this,sn(arguments))},g.Observable.prototype.flatMapFirst=function(){return cn(this,sn(arguments),!0)};var sn=function(n){return 1===n.length&&O(n[0])?I.always(n[0]):H(n)},an=function(n){return O(n)?n:g.once(n)},cn=function(n,t,r,e){var i=[n],u=[],o=new g.Desc(n,"flatMap"+(r?"First":""),[t]),s=new p(o,function(i){var o=new h,s=[],a=function(n){var r=an(t(n.value()));return u.push(r),o.add(function(n,t){return r.dispatcher.subscribe(function(e){if(e.isEnd())return I.remove(r,u),c(),f(t),g.noMore;("undefined"!=typeof e&&null!==e?e._isInitial:void 0)&&(e=e.toNext());var o=i(e);return o===g.noMore&&n(),o})})},c=function(){var n=s.shift();return n?a(n):void 0},f=function(n){return n(),o.empty()?i(G()):void 0};return o.add(function(t,u){return n.dispatcher.subscribe(function(n){return n.isEnd()?f(u):n.isError()?i(n):r&&o.count()>1?g.more:o.unsubscribed?g.noMore:e&&o.count()>e?s.push(n):a(n)})}),o.unsubscribe});return s.internalDeps=function(){return u.length?i.concat(u):i},s};g.Observable.prototype.flatMapWithConcurrencyLimit=function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];var i=new g.Desc(this,"flatMapWithConcurrencyLimit",[n].concat(r));return W(i,cn(this,sn(r),!1,n))},g.Observable.prototype.flatMapConcat=function(){var n=new g.Desc(this,"flatMapConcat",Array.prototype.slice.call(arguments,0));return W(n,this.flatMapWithConcurrencyLimit.apply(this,[1].concat(b.call(arguments))))},g.later=function(n,t){return W(new g.Desc(g,"later",[n,t]),g.fromBinder(function(r){var e=function(){return r([t,G()])},i=g.scheduler.setTimeout(e,n);return function(){return g.scheduler.clearTimeout(i)}}))},g.Observable.prototype.bufferingThrottle=function(n){var t=new g.Desc(this,"bufferingThrottle",[n]);return W(t,this.flatMapConcat(function(t){return g.once(t).concat(g.later(n).filter(!1))}))},g.Property.prototype.bufferingThrottle=function(){return g.Observable.prototype.bufferingThrottle.apply(this,arguments).toProperty()},k(y,p),M(y.prototype,{unsubAll:function(){for(var n,t=this.subscriptions,r=0;r<t.length;r++)n=t[r],"function"==typeof n.unsub&&n.unsub()},subscribeAll:function(n){if(this.ended)n(G());else{this.sink=n;for(var t,r=S(this.subscriptions),e=0;e<r.length;e++)t=r[e],this.subscribeInput(t)}return this.unsubAll},guardedSink:function(n){var t=this;return function(r){return r.isEnd()?(t.unsubscribeInput(n),g.noMore):t.sink(r)}},subscribeInput:function(n){return n.unsub=n.input.dispatcher.subscribe(this.guardedSink(n.input)),n.unsub},unsubscribeInput:function(n){for(var t,r=this.subscriptions,e=0;e<r.length;e++)if(t=r[e],t.input===n)return"function"==typeof t.unsub&&t.unsub(),void this.subscriptions.splice(e,1)},plug:function(n){var t=this;if(!this.ended){var r={input:n};return this.subscriptions.push(r),"undefined"!=typeof this.sink&&this.subscribeInput(r),function(){return t.unsubscribeInput(n)}}},end:function(){return this.ended=!0,this.unsubAll(),"function"==typeof this.sink?this.sink(G()):void 0},push:function(n){return this.ended||"function"!=typeof this.sink?void 0:this.sink(X(n))},error:function(n){return"function"==typeof this.sink?this.sink(new c(n)):void 0}}),g.Bus=y;var fn=function(n,t){return V(function(r){for(var e=B(t,[function(n,t){return r.apply(void 0,n.concat([t]))}]),i=arguments.length,u=Array(i>1?i-1:0),o=1;i>o;o++)u[o-1]=arguments[o];return W(new g.Desc(g,n,[r].concat(u)),g.combineAsArray(u).flatMap(e))})};g.fromCallback=fn("fromCallback",function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return g.fromBinder(function(t){return L(n,r)(t),E},function(n){return[n,G()]})}),g.fromNodeCallback=fn("fromNodeCallback",function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return g.fromBinder(function(t){return L(n,r)(t),E},function(n,t){return n?[new c(n),G()]:[t,G()]})}),g.combineTemplate=function(n){function t(n){return n[n.length-1]}function r(n,r,e){return t(n)[r]=e,e}function e(n,t){return function(e,i){return r(e,n,i[t])}}function i(n,t){return function(e){return r(e,n,t)}}function u(n){return A(n)?[]:{}}function o(n,t){return function(e){var i=u(t);return r(e,n,i),e.push(i)}}function s(n,t){if(O(t))return h.push(t),f.push(e(n,h.length-1));if(!t||t.constructor!=Object&&t.constructor!=Array)return f.push(i(n,t));var r=function(n){return n.pop()};return f.push(o(n,t)),c(t),f.push(r)}function a(t){for(var r,e=u(n),i=[e],o=0;o<f.length;o++)(r=f[o])(i,t);return e}function c(n){return I.each(n,s)}var f=[],h=[];return c(n),W(new g.Desc(g,"combineTemplate",[n]),g.combineAsArray(h).map(a))};var hn=function(n,t){var r=new p(x(n,"justInitValue"),function(t){var e=void 0,i=n.dispatcher.subscribe(function(n){return n.isEnd()||(e=n),g.noMore});return _.whenDoneWith(r,function(){return"undefined"!=typeof e&&null!==e&&t(e),t(G())}),i});return r.concat(t).toProperty()};g.Observable.prototype.mapEnd=function(){var n=H(arguments);return W(new g.Desc(this,"mapEnd",[n]),this.withHandler(function(t){return t.isEnd()?(this.push(X(n(t))),this.push(G()),g.noMore):this.push(t)}))},g.Observable.prototype.skipErrors=function(){return W(new g.Desc(this,"skipErrors",[]),this.withHandler(function(n){return n.isError()?g.more:this.push(n)}))},g.EventStream.prototype.takeUntil=function(n){var t={};return W(new g.Desc(this,"takeUntil",[n]),g.groupSimultaneous(this.mapEnd(t),n.skipErrors()).withHandler(function(n){if(n.hasValue()){var r=n.value(),e=r[0],i=r[1];if(i.length)return this.push(G());for(var u,o=g.more,s=0;s<e.length;s++)u=e[s],o=this.push(u===t?G():X(u));return o}return this.push(n)}))},g.Property.prototype.takeUntil=function(n){var t=this.changes().takeUntil(n);return W(new g.Desc(this,"takeUntil",[n]),hn(this,t))},g.Observable.prototype.flatMapLatest=function(){var n=sn(arguments),t=this.toEventStream();return W(new g.Desc(this,"flatMapLatest",[n]),t.flatMap(function(r){return an(n(r)).takeUntil(t)}))},g.Property.prototype.delayChanges=function(n,t){return W(n,hn(this,t(this.changes())))},g.EventStream.prototype.delayChanges=function(n,t){return W(n,t(this))},g.Observable.prototype.delay=function(n){return this.delayChanges(new g.Desc(this,"delay",[n]),function(t){return t.flatMap(function(t){return g.later(n,t)})})},g.Observable.prototype.debounce=function(n){return this.delayChanges(new g.Desc(this,"debounce",[n]),function(t){return t.flatMapLatest(function(t){return g.later(n,t)})})},g.Observable.prototype.debounceImmediate=function(n){return this.delayChanges(new g.Desc(this,"debounceImmediate",[n]),function(t){return t.flatMapFirst(function(t){return g.once(t).concat(g.later(n).filter(!1))})})},g.Observable.prototype.decode=function(n){return W(new g.Desc(this,"decode",[n]),this.combine(g.combineTemplate(n),function(n,t){return t[n]}))},g.Observable.prototype.scan=function(n,t){var r,e=this;t=z(t);var u=$(n),o=!1,a=function(n){var a=!1,c=E,f=g.more,h=function(){return a?void 0:u.forEach(function(t){return a=o=!0,f=n(new s(function(){return t})),f===g.noMore?(c(),
c=E):void 0})};return c=e.dispatcher.subscribe(function(r){if(r.hasValue()){if(o&&r.isInitial())return g.more;r.isInitial()||h(),a=o=!0;var e=u.getOrElse(void 0),s=t(e,r.value());return u=new i(s),n(r.apply(function(){return s}))}return r.isEnd()&&(f=h()),f!==g.noMore?n(r):void 0}),_.whenDoneWith(r,h),c};return r=new d(new g.Desc(this,"scan",[n,t]),a)},g.Observable.prototype.diff=function(n,t){return t=z(t),W(new g.Desc(this,"diff",[n,t]),this.scan([n],function(n,r){return[r,t(n[0],r)]}).filter(function(n){return 2===n.length}).map(function(n){return n[1]}))},g.Observable.prototype.doAction=function(){var n=H(arguments);return W(new g.Desc(this,"doAction",[n]),this.withHandler(function(t){return t.hasValue()&&n(t.value()),this.push(t)}))},g.Observable.prototype.doEnd=function(){var n=H(arguments);return W(new g.Desc(this,"doEnd",[n]),this.withHandler(function(t){return t.isEnd()&&n(),this.push(t)}))},g.Observable.prototype.doError=function(){var n=H(arguments);return W(new g.Desc(this,"doError",[n]),this.withHandler(function(t){return t.isError()&&n(t.error),this.push(t)}))},g.Observable.prototype.doLog=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return W(new g.Desc(this,"doLog",t),this.withHandler(function(n){return"undefined"!=typeof console&&null!==console&&"function"==typeof console.log&&console.log.apply(console,t.concat([n.log()])),this.push(n)}))},g.Observable.prototype.endOnError=function(n){("undefined"==typeof n||null===n)&&(n=!0);for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return U(this,n,r,function(n){return W(new g.Desc(this,"endOnError",[]),this.withHandler(function(t){return t.isError()&&n(t.error)?(this.push(t),this.push(G())):this.push(t)}))})},f.prototype.errors=function(){return W(new g.Desc(this,"errors",[]),this.filter(function(){return!1}))},g.Observable.prototype.take=function(n){return 0>=n?g.never():W(new g.Desc(this,"take",[n]),this.withHandler(function(t){return t.hasValue()?(n--,n>0?this.push(t):(0===n&&this.push(t),this.push(G()),g.noMore)):this.push(t)}))},g.Observable.prototype.first=function(){return W(new g.Desc(this,"first",[]),this.take(1))},g.Observable.prototype.mapError=function(){var n=H(arguments);return W(new g.Desc(this,"mapError",[n]),this.withHandler(function(t){return this.push(t.isError()?X(n(t.error)):t)}))},g.Observable.prototype.flatMapError=function(n){var t=new g.Desc(this,"flatMapError",[n]);return W(t,this.mapError(function(n){return new c(n)}).flatMap(function(t){return t instanceof c?n(t.error):g.once(t)}))},g.EventStream.prototype.flatScan=function(n,t){var r=n;return this.flatMapConcat(function(n){return an(t(r,n)).doAction(function(n){return r=n})}).toProperty(n)},g.EventStream.prototype.sampledBy=function(n,t){return W(new g.Desc(this,"sampledBy",[n,t]),this.toProperty().sampledBy(n,t))},g.Property.prototype.sampledBy=function(t,r){var e=!1;"undefined"!=typeof r&&null!==r?r=z(r):(e=!0,r=function(n){return n.value()});var i=new n(this,!1,e),u=new n(t,!0,e),o=g.when([i,u],r),s=t._isProperty?o.toProperty():o;return W(new g.Desc(this,"sampledBy",[t,r]),s)},g.Property.prototype.sample=function(n){return W(new g.Desc(this,"sample",[n]),this.sampledBy(g.interval(n,{})))},g.Observable.prototype.map=function(n){if(n&&n._isProperty)return n.sampledBy(this,D);for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return U(this,n,r,function(n){return W(new g.Desc(this,"map",[n]),this.withHandler(function(t){return this.push(t.fmap(n))}))})},g.Observable.prototype.fold=function(n,t){return W(new g.Desc(this,"fold",[n,t]),this.scan(n,t).sampledBy(this.filter(!1).mapEnd().toProperty()))},f.prototype.reduce=f.prototype.fold;var ln=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"],["bind","unbind"]],pn=function(n){for(var t,r=0;r<ln.length;r++){t=ln[r];var e=[n[t[0]],n[t[1]]];if(e[0]&&e[1])return e}for(var i=0;i<ln.length;i++){t=ln[i];var u=n[t[0]];if(u)return[u,function(){}]}throw new c("No suitable event methods in "+n)};g.fromEventTarget=function(n,t,r){var e=pn(n),i=e[0],u=e[1],o=new g.Desc(g,"fromEvent",[n,t]);return W(o,g.fromBinder(function(r){return i.call(n,t,r),function(){return u.call(n,t,r)}},r))},g.fromEvent=g.fromEventTarget,g.fromPoll=function(n,t){var r=new g.Desc(g,"fromPoll",[n,t]);return W(r,g.fromBinder(function(t){var r=g.scheduler.setInterval(t,n);return function(){return g.scheduler.clearInterval(r)}},t))},g.fromPromise=function(n,t){var r=arguments.length<=2||void 0===arguments[2]?m:arguments[2];return W(new g.Desc(g,"fromPromise",[n]),g.fromBinder(function(r){var e=n.then(r,function(n){return r(new c(n))});return e&&"function"==typeof e.done&&e.done(),t?function(){return"function"==typeof n.abort?n.abort():void 0}:function(){}},r))},g.Observable.prototype.groupBy=function(n){var t=arguments.length<=1||void 0===arguments[1]?g._.id:arguments[1],r={},e=this;return e.filter(function(t){return!r[n(t)]}).map(function(i){var u=n(i),o=e.filter(function(t){return n(t)===u}),s=g.once(i).concat(o),a=t(s,i).withHandler(function(n){return this.push(n),n.isEnd()?delete r[u]:void 0});return r[u]=a,a})},g.fromArray=function(n){if(n.length){var t=0;return new p(new g.Desc(g,"fromArray",[n]),function(r){var e=!1,i=g.more,u=!1,o=!1,s=function(){if(o=!0,!u){for(u=!0;o;)if(o=!1,i!==g.noMore&&!e){var a=n[t++];i=r(J(a)),i!==g.noMore&&(t===n.length?r(G()):_.afterTransaction(s))}return u=!1}};return s(),function(){return e=!0}})}return W(new g.Desc(g,"fromArray",n),g.never())},g.EventStream.prototype.holdWhen=function(n){var t=!1,r=[],e=this,i=!1;return new p(new g.Desc(this,"holdWhen",[n]),function(u){var o=new h,s=!1,a=function(n){return"function"==typeof n&&n(),o.empty()&&s?u(G()):void 0};return o.add(function(e,o){return n.subscribeInternal(function(n){if(!n.hasValue())return n.isEnd()?a(o):u(n);if(t=n.value(),!t){var e=r;return r=[],function(){for(var n,t=[],r=0;r<e.length;r++)n=e[r],t.push(u(X(n)));return i&&(t.push(u(G())),o()),t}()}})}),o.add(function(n,o){return e.subscribeInternal(function(n){return t&&n.hasValue()?r.push(n.value()):n.isEnd()&&r.length?(i=!0,a(o)):u(n)})}),s=!0,a(),o.unsubscribe})},g.interval=function(n){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return W(new g.Desc(g,"interval",[n,t]),g.fromPoll(n,function(){return X(t)}))},g.$={},g.$.asEventStream=function(n,t,r){var e=this;return I.isFunction(t)&&(r=t,t=void 0),W(new g.Desc(this.selector||this,"asEventStream",[n]),g.fromBinder(function(r){return e.on(n,t,r),function(){return e.off(n,t,r)}},r))},"undefined"!=typeof jQuery&&jQuery&&(jQuery.fn.asEventStream=g.$.asEventStream),"undefined"!=typeof Zepto&&Zepto&&(Zepto.fn.asEventStream=g.$.asEventStream),g.Observable.prototype.last=function(){var n;return W(new g.Desc(this,"last",[]),this.withHandler(function(t){return t.isEnd()?(n&&this.push(n),this.push(G()),g.noMore):void(n=t)}))},g.Observable.prototype.log=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return this.subscribe(function(n){"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,t.concat([n.log()]))}),this},g.EventStream.prototype.merge=function(n){var t=this;return W(new g.Desc(t,"merge",[n]),g.mergeAll(this,n))},g.mergeAll=function(){var n=rn(arguments);return n.length?new p(new g.Desc(g,"mergeAll",n),function(t){var r=0,e=function(e){return function(i){return e.dispatcher.subscribe(function(e){if(e.isEnd())return r++,r===n.length?t(G()):g.more;var u=t(e);return u===g.noMore&&i(),u})}},i=I.map(e,n);return new g.CompositeUnsubscribe(i).unsubscribe}):g.never()},g.repeatedly=function(n,t){var r=0;return W(new g.Desc(g,"repeatedly",[n,t]),g.fromPoll(n,function(){return t[r++%t.length]}))},g.repeat=function(n){var t=0;return g.fromBinder(function(r){function e(n){return n.isEnd()?u?i():u=!0:o=r(n)}function i(){var i;for(u=!0;u&&o!==g.noMore;)i=n(t++),u=!1,i?s=i.subscribeInternal(e):r(G());return u=!0}var u=!1,o=g.more,s=function(){};return i(),function(){return s()}})},g.retry=function(n){if(!I.isFunction(n.source))throw new w("'source' option has to be a function");var t=n.source,r=n.retries||0,e=0,i=n.delay||function(){return 0},u=n.isRetryable||function(){return!0},o=!1,s=null;return W(new g.Desc(g,"retry",[n]),g.repeat(function(n){function a(){return t(n).endOnError().withHandler(function(n){return n.isError()?(s=n,u(s.error)&&(0===r||r>e)?void 0:(o=!0,this.push(n))):(n.hasValue()&&(s=null,o=!0),this.push(n))})}if(o)return null;if(s){var c={error:s.error,retriesDone:e},f=g.later(i(c)).filter(!1);return e++,f.concat(g.once().flatMap(a))}return a()}))},g.sequentially=function(n,t){var r=0;return W(new g.Desc(g,"sequentially",[n,t]),g.fromPoll(n,function(){var n=t[r++];return r<t.length?n:r===t.length?[n,G()]:G()}))},g.Observable.prototype.skip=function(n){return W(new g.Desc(this,"skip",[n]),this.withHandler(function(t){return t.hasValue()&&n>0?(n--,g.more):this.push(t)}))},g.EventStream.prototype.skipUntil=function(n){var t=n.take(1).map(!0).toProperty(!1);return W(new g.Desc(this,"skipUntil",[n]),this.filter(t))},g.EventStream.prototype.skipWhile=function(n){for(var t=!1,r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];return U(this,n,e,function(n){return W(new g.Desc(this,"skipWhile",[n]),this.withHandler(function(r){return!t&&r.hasValue()&&n(r.value())?g.more:(r.hasValue()&&(t=!0),this.push(r))}))})},g.Observable.prototype.slidingWindow=function(n){var t=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return W(new g.Desc(this,"slidingWindow",[n,t]),this.scan([],function(t,r){return t.concat([r]).slice(-n)}).filter(function(n){return n.length>=t}))};var vn=[],Y=function(n){if(vn.length&&!Y.running)try{Y.running=!0,vn.forEach(function(t){t(n)})}finally{delete Y.running}};g.spy=function(n){return vn.push(n)},g.Property.prototype.startWith=function(n){return W(new g.Desc(this,"startWith",[n]),this.scan(n,function(n,t){return t}))},g.EventStream.prototype.startWith=function(n){return W(new g.Desc(this,"startWith",[n]),g.once(n).concat(this))},g.Observable.prototype.takeWhile=function(n){for(var t=arguments.length,r=Array(t>1?t-1:0),e=1;t>e;e++)r[e-1]=arguments[e];return U(this,n,r,function(n){return W(new g.Desc(this,"takeWhile",[n]),this.withHandler(function(t){return t.filter(n)?this.push(t):(this.push(G()),g.noMore)}))})},g.Observable.prototype.throttle=function(n){return this.delayChanges(new g.Desc(this,"throttle",[n]),function(t){return t.bufferWithTime(n).map(function(n){return n[n.length-1]})})},f.prototype.firstToPromise=function(n){var t=this;if("function"!=typeof n){if("function"!=typeof Promise)throw new w("There isn't default Promise, use shim or parameter");n=Promise}return new n(function(n,r){return t.subscribe(function(t){return t.hasValue()&&n(t.value()),t.isError()&&r(t.error),g.noMore})})},f.prototype.toPromise=function(n){return this.last().firstToPromise(n)},g["try"]=function(n){return function(t){try{return g.once(n(t))}catch(r){return new g.Error(r)}}},g.update=function(n){function t(n){return function(){for(var t=arguments.length,r=Array(t),e=0;t>e;e++)r[e]=arguments[e];return function(t){return n.apply(void 0,[t].concat(r))}}}for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;r>i;i++)e[i-1]=arguments[i];for(var u=e.length-1;u>0;)e[u]instanceof Function||(e[u]=I.always(e[u])),e[u]=t(e[u]),u-=2;return W(new g.Desc(g,"update",[n].concat(e)),g.when.apply(g,e).scan(n,function(n,t){return t(n)}))},g.zipAsArray=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];var e=rn(t);return W(new g.Desc(g,"zipAsArray",e),g.zipWith(e,function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return t}))},g.zipWith=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];var e=en(t),i=e[0],u=e[1];return i=I.map(function(n){return n.toEventStream()},i),W(new g.Desc(g,"zipWith",[u].concat(i)),g.when(i,u))},g.Observable.prototype.zip=function(n,t){return W(new g.Desc(this,"zip",[n]),g.zipWith([this,n],t||Array))},"undefined"!=typeof define&&null!==define&&null!=define.amd?(define([],function(){return g}),"undefined"!=typeof this&&null!==this&&(this.Bacon=g)):"undefined"!=typeof module&&null!==module&&null!=module.exports?(module.exports=g,g.Bacon=g):this.Bacon=g}).call(this);
{
"name": "baconjs",
"description": "A small functional reactive programming lib for JavaScript.",
"version": "0.7.90",
"version": "0.7.91",
"keywords": [

@@ -6,0 +6,0 @@ "bacon.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc