Comparing version 0.7.91 to 0.7.92
@@ -6,3 +6,3 @@ { | ||
"chrome_latest", | ||
"firefox_latest", | ||
"firefox_previous", | ||
"safari_previous", | ||
@@ -9,0 +9,0 @@ "safari_latest", |
@@ -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.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); | ||
(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=++X}function o(n,t){return this instanceof o?(u.call(this),void(!t&&P.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=++nn,this.initialDesc=this.desc}function h(){var n=arguments.length<=0||void 0===arguments[0]?[]:arguments[0];this.unsubscribe=P.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=P.bind(this.subscribe,this),this.handleEvent=P.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?(P.isFunction(n)&&(r=t,t=n,n=e.empty),f.call(this,n),this.dispatcher=new l(t,r),void tn(this)):new p(n,t,r)}function v(n,t,r){l.call(this,t,r),this.property=n,this.subscribe=P.bind(this.subscribe,this),this.current=Q,this.currentValueRootId=void 0,this.propertyEnded=!1}function d(n,t,r){f.call(this,n),this.dispatcher=new v(this,t,r),tn(this)}function b(){return this instanceof b?(this.unsubAll=P.bind(this.unsubAll,this),this.subscribeAll=P.bind(this.subscribeAll,this),this.guardedSink=P.bind(this.guardedSink,this),this.sink=void 0,this.subscriptions=[],this.ended=!1,void p.call(this,new w.Desc(w,"Bus",[]),this.subscribeAll)):new b}function y(n){return[n,K()]}function m(n){this.observable=n}var g=Array.prototype.slice,w={toString:function(){return"Bacon"}};w.version="0.7.92";var E=("undefined"!=typeof global&&null!==global?global:this).Error,S=function(){},D=function(n,t){return n},A=function(n){return n.slice(0)},O=Array.isArray||function(n){return n instanceof Array},M=function(n){return n&&n._isObservable},k=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},I=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},x=function(n){return"undefined"!=typeof Symbol&&Symbol[n]?Symbol[n]:"undefined"!=typeof Symbol&&"function"==typeof Symbol["for"]?Symbol[n]=Symbol["for"](n):"@@"+n},P={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 O(n)?n:[n]},contains:function(n,t){return-1!==P.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]?P.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]?P.id:arguments[1],e=0;e<n.length;e++)if(t=n[e],r(t))return!0;return!1},without:function(n,t){return P.filter(function(t){return t!==n},t)},remove:function(n,t){var r=P.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 P.fold(t,[],function(t,r){return t.concat(n(r))})},cached:function(n){var t=Q;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 _++,null==n?"undefined":P.isFunction(n)?"function":O(n)?_>5?"[..]":"["+P.map(P.toString,n).toString()+"]":null!=(null!=n?n.toString:void 0)&&n.toString!==Object.prototype.toString?n.toString():"object"==typeof n?_>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(P.toString(r)+":"+P.toString(e)));return t}(),"{"+t+"}"):n}finally{_--}}},_=0;w._=P;var W=w.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=P.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===w.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}}();k(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:P.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}),I(t,n),k(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}),I(r,n),k(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)},k(e.prototype,{_isDesc:!0,deps:function(){return this.cached||(this.cached=H([this.context].concat(this.args))),this.cached},toString:function(){return P.toString(this.context)+"."+P.toString(this.method)+"("+P.map(P.toString,this.args)+")"}});var T=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)},V=function(n,t){return t.desc=n,t},H=function(n){return O(n)?P.flatMap(H,n):M(n)?[n]:("undefined"!=typeof n&&null!==n?n._isSource:void 0)?[n.obs]:[]};w.Desc=e,w.Desc.empty=new w.Desc("","",[]);var B=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))}},F=function(n){return n=Array.prototype.slice.call(n),U.apply(void 0,n)},C=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))}},N=function(n){return function(t){return function(r){if("undefined"!=typeof r&&null!==r){var e=r[t];return P.isFunction(e)?e.apply(r,n):e}}}},q=function(n,t){var r=n.slice(1).split("."),e=P.map(N(t),r);return function(n){for(var t,r=0;r<e.length;r++)t=e[r],n=t(n);return n}},L=function(n){return"string"==typeof n&&n.length>1&&"."===n.charAt(0)},U=B(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 P.isFunction(n)?r.length?C(n,r):n:L(n)?q(n,r):P.always(n)}),z=function(n,t){return U.apply(void 0,[n].concat(t))},j=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=z(t,r),e.call(n,t)},R=function(n){if(P.isFunction(n))return n;if(L(n)){var t=$(n);return function(n,r){return n[t](r)}}throw new E("not a function or a field key: "+n)},$=function(n){return n.slice(1)};k(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):Q},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 Q={_isNone:!0,getOrElse:function(n){return n},filter:function(){return Q},map:function(){return Q},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},Z=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)};w.noMore="<no-more>",w.more="<more>";var X=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()},I(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 P.toString(this.value())},o.prototype.log=function(){return this.value()},o.prototype._isNext=!0,I(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)},I(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>"},I(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> "+P.toString(this.error)},w.Event=u,w.Initial=s,w.Next=o,w.End=a,w.Error=c;var G=function(n){return new s(n,!0)},J=function(n){return new o(n,!0)},K=function(){return new a},Y=function(n){return n&&n._isEvent?n:J(n)},nn=0,tn=function(){};k(f.prototype,{_isObservable:!0,subscribe:function(n){return W.wrappedSubscribe(this,n)},subscribeInternal:function(n){return this.dispatcher.subscribe(n)},onValue:function(){var n=F(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=F(arguments);return this.subscribe(function(t){return t.isError()?n(t.error):void 0})},onEnd:function(){var n=F(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=T.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,w.Observable=f,k(h.prototype,{add:function(n){var t=this;if(!this.unsubscribed){var r=!1,e=S;this.starting.push(n);var i=function(){return t.unsubscribed?void 0:(r=!0,t.remove(e),P.remove(n,t.starting))};return e=n(this.unsubscribe,i),this.unsubscribed||r?e():this.subscriptions.push(e),P.remove(n,this.starting),e}},remove:function(n){return this.unsubscribed?void 0:void 0!==P.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()}}),w.CompositeUnsubscribe=h,l.prototype.hasSubscribers=function(){return this.subscriptions.length>0},l.prototype.removeSub=function(n){return this.subscriptions=P.without(n,this.subscriptions),this.subscriptions},l.prototype.push=function(n){return n.isEnd()&&(this.ended=!0),W.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===w.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),w.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()?w.more:(this.unsubscribeFromSource(),w.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(K()),S):(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))},w.Dispatcher=l,I(p,f),k(p.prototype,{_isEventStream:!0,toProperty:function(n){var t=0===arguments.length?Q:Z(function(){return n}),r=this.dispatcher,e=new w.Desc(this,"toProperty",[n]);return new d(e,function(n){var e=!1,u=!1,o=S,a=w.more,c=function(){return e?void 0:t.forEach(function(t){return e=!0,a=n(new s(t)),a===w.noMore?(o(),o=S,S):void 0})};return o=r.subscribe(function(r){return r.hasValue()?r.isInitial()&&!u?(t=new i(function(){return r.value()}),w.more):(r.isInitial()||c(),e=!0,t=new i(r),n(r)):(r.isEnd()&&(a=c()),a!==w.noMore?n(r):void 0)}),u=!0,c(),o})},toEventStream:function(){return this},withHandler:function(n){return new p(new w.Desc(this,"withHandler",[n]),this.dispatcher.subscribe,n)}}),w.EventStream=p,w.never=function(){return new p(T(w,"never"),function(n){return n(K()),S})},w.when=function(){if(0===arguments.length)return w.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=P.toArray(arguments[i]),a=en(arguments[i+1]),c={f:a,ixs:[]},f=!1,h=0;h<s.length;h++){o=s[h];var l=P.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 w.never();r=P.map(n.fromObservable,r);var b=P.any(r,function(n){return n.flatten})&&rn(P.map(function(n){return n.obs},r)),y=new w.Desc(w,"when",u),m=new p(y,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 W.whenDoneWith(m,p)},l=function(){if(!(t.length>0))return w.more;for(var i,o=w.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=P.filter(a,t)),o===w.noMore?o:l()}},p=function(){var t=l();return i&&(P.all(r,o)||P.all(e,s))&&(t=w.noMore,n(K())),t===w.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}),b||W.hasWaiters()?h():p());return e===w.noMore&&f(),e||w.more})}};return new w.CompositeUnsubscribe(function(){for(var n,t=[],e=0;e<r.length;e++)n=r[e],t.push(c(n));return t}()).unsubscribe});return m};var rn=function(n){var t=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],r=function(n){if(P.contains(t,n))return!0;var e=n.internalDeps();return e.length?(t.push(n),P.any(e,r)):(t.push(n),!1)};return P.any(n,r)},en=function(n){return P.isFunction(n)?n:P.always(n)};w.groupSimultaneous=function(){for(var n=arguments.length,t=Array(n),e=0;n>e;e++)t[e]=arguments[e];1===t.length&&O(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 V(new w.Desc(w,"groupSimultaneous",t),w.when(i,function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return t}))},I(v,l),k(v.prototype,{push:function(n){return n.isEnd()&&(this.propertyEnded=!0),n.hasValue()&&(this.current=new i(n),this.currentValueRootId=W.currentEventId()),l.prototype.push.call(this,n)},maybeSubSource:function(n,t){return t===w.noMore?S:this.propertyEnded?(n(K()),S):l.prototype.subscribe.call(this,n)},subscribe:function(n){var t=this,r=w.more;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=W.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?(W.whenDoneWith(this.property,function(){return t.currentValueRootId===i?n(G(t.current.get().value())):void 0}),this.maybeSubSource(n,r)):(W.inTransaction(void 0,this,function(){return r=n(G(this.current.get().value()))},[]),this.maybeSubSource(n,r))}return this.maybeSubSource(n,r)}}),I(d,f),k(d.prototype,{_isProperty:!0,changes:function(){var n=this;return new p(new w.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 w.Desc(this,"withHandler",[n]),this.dispatcher.subscribe,n)},toProperty:function(){return this},toEventStream:function(){var n=this;return new p(new w.Desc(this,"toEventStream",[]),function(t){return n.dispatcher.subscribe(function(n){return n.isInitial()&&(n=n.toNext()),t(n)})})}}),w.Property=d,w.constant=function(n){return new d(new w.Desc(w,"constant",[n]),function(t){return t(G(n)),t(K()),S})},w.fromBinder=function(n){var t=arguments.length<=1||void 0===arguments[1]?P.id:arguments[1],r=new w.Desc(w,"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);O(s)&&(null!=(n=P.last(s))?n._isEvent:void 0)||(s=[s]);for(var a,c=w.more,f=0;f<s.length;f++)if(a=s[f],c=r(a=Y(a)),c===w.noMore||a.isEnd())return u(),c;return c});return i&&u(),u})},w.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 j(this,n,r,function(n){return V(new w.Desc(this,"map",[n]),this.withHandler(function(t){return this.push(t.fmap(n))}))})};var un=function(n){return O(n[0])?n[0]:Array.prototype.slice.call(n)},on=function(n){return P.isFunction(n[0])?[un(Array.prototype.slice.call(n,1)),n[0]]:[un(Array.prototype.slice.call(n,0,n.length-1)),P.last(n)]};w.combineAsArray=function(){var t=un(arguments);if(t.length){for(var r=[],e=0;e<t.length;e++){var i=M(t[e])?t[e]:w.constant(t[e]);r.push(new n(i,!0))}return V(new w.Desc(w,"combineAsArray",t),w.when(r,function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return t}).toProperty())}return w.constant([])},w.onValues=function(){return w.combineAsArray(Array.prototype.slice.call(arguments,0,arguments.length-1)).onValues(arguments[arguments.length-1])},w.combineWith=function(){var n=on(arguments),t=n[0],r=n[1],e=new w.Desc(w,"combineWith",[r].concat(t));return V(e,w.combineAsArray(t).map(function(n){return r.apply(void 0,n)}))},w.Observable.prototype.combine=function(n,t){var r=R(t),e=new w.Desc(this,"combine",[n,t]);return V(e,w.combineAsArray(this,n).map(function(n){return r(n[0],n[1])}))},w.Observable.prototype.withStateMachine=function(n,t){var r=n,e=new w.Desc(this,"withStateMachine",[n,t]);return V(e,this.withHandler(function(n){var e=t(r,n),i=e[0],u=e[1];r=i;for(var o,s=w.more,a=0;a<u.length;a++)if(o=u[a],s=this.push(o),s===w.noMore)return s;return s}))};var sn=function(n,t){return n===t},an=function(n){return"undefined"!=typeof n&&null!==n?n._isNone:!1};w.Observable.prototype.skipDuplicates=function(){var n=arguments.length<=0||void 0===arguments[0]?sn:arguments[0],t=new w.Desc(this,"skipDuplicates",[]);return V(t,this.withStateMachine(Q,function(t,r){return r.hasValue()?r.isInitial()||an(t)||!n(t.get(),r.value())?[new i(r.value()),[r]]:[t,[]]:[t,[r]]}))},w.Observable.prototype.awaiting=function(n){var t=new w.Desc(this,"awaiting",[n]);return V(t,w.groupSimultaneous(this,n).map(function(n){return 0===n[1].length}).toProperty(!1).skipDuplicates())},w.Observable.prototype.not=function(){return V(new w.Desc(this,"not",[]),this.map(function(n){return!n}))},w.Property.prototype.and=function(n){return V(new w.Desc(this,"and",[n]),this.combine(n,function(n,t){return n&&t}))},w.Property.prototype.or=function(n){return V(new w.Desc(this,"or",[n]),this.combine(n,function(n,t){return n||t}))},w.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()}},w.EventStream.prototype.bufferWithTime=function(n){return V(new w.Desc(this,"bufferWithTime",[n]),this.bufferWithTimeOrCount(n,Number.MAX_VALUE))},w.EventStream.prototype.bufferWithCount=function(n){return V(new w.Desc(this,"bufferWithCount",[n]),this.bufferWithTimeOrCount(void 0,n))},w.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 w.Desc(this,"bufferWithTimeOrCount",[n,t]);return V(e,this.buffer(n,r,r))},w.EventStream.prototype.buffer=function(n){var t=arguments.length<=1||void 0===arguments[1]?S:arguments[1],r=arguments.length<=2||void 0===arguments[2]?S:arguments[2],e={scheduled:null,end:void 0,values:[],flush:function(){if(this.scheduled&&(w.scheduler.clearTimeout(this.scheduled),this.scheduled=null),this.values.length>0){var n=this.values;this.values=[];var t=this.push(J(n));if(null!=this.end)return this.push(this.end);if(t!==w.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=w.more;if(!P.isFunction(n)){var u=n;n=function(n){return w.scheduler.setTimeout(n,u)}}return V(new w.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}))},w.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 j(this,n,r,function(n){return V(new w.Desc(this,"filter",[n]),this.withHandler(function(t){return t.filter(n)?this.push(t):w.more}))})},w.once=function(n){return new p(new e(w,"once",[n]),function(t){return t(Y(n)),t(K()),S})},w.EventStream.prototype.concat=function(n){var t=this;return new p(new w.Desc(t,"concat",[n]),function(r){var e=S,i=t.dispatcher.subscribe(function(t){return t.isEnd()?e=n.dispatcher.subscribe(r):r(t)});return function(){return i(),e()}})},w.Observable.prototype.flatMap=function(){return hn(this,cn(arguments))},w.Observable.prototype.flatMapFirst=function(){return hn(this,cn(arguments),!0)};var cn=function(n){return 1===n.length&&M(n[0])?P.always(n[0]):F(n)},fn=function(n){return M(n)?n:w.once(n)},hn=function(n,t,r,e){var i=[n],u=[],o=new w.Desc(n,"flatMap"+(r?"First":""),[t]),s=new p(o,function(i){var o=new h,s=[],a=function(n){var r=fn(t(n.value()));return u.push(r),o.add(function(n,t){return r.dispatcher.subscribe(function(e){if(e.isEnd())return P.remove(r,u),c(),f(t),w.noMore;("undefined"!=typeof e&&null!==e?e._isInitial:void 0)&&(e=e.toNext());var o=i(e);return o===w.noMore&&n(),o})})},c=function(){var n=s.shift();return n?a(n):void 0},f=function(n){return n(),o.empty()?i(K()):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?w.more:o.unsubscribed?w.noMore:e&&o.count()>e?s.push(n):a(n)})}),o.unsubscribe});return s.internalDeps=function(){return u.length?i.concat(u):i},s};w.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 w.Desc(this,"flatMapWithConcurrencyLimit",[n].concat(r));return V(i,hn(this,cn(r),!1,n))},w.Observable.prototype.flatMapConcat=function(){var n=new w.Desc(this,"flatMapConcat",Array.prototype.slice.call(arguments,0));return V(n,this.flatMapWithConcurrencyLimit.apply(this,[1].concat(g.call(arguments))))},w.later=function(n,t){return V(new w.Desc(w,"later",[n,t]),w.fromBinder(function(r){var e=function(){return r([t,K()])},i=w.scheduler.setTimeout(e,n);return function(){return w.scheduler.clearTimeout(i)}}))},w.Observable.prototype.bufferingThrottle=function(n){var t=new w.Desc(this,"bufferingThrottle",[n]);return V(t,this.flatMapConcat(function(t){return w.once(t).concat(w.later(n).filter(!1))}))},w.Property.prototype.bufferingThrottle=function(){return w.Observable.prototype.bufferingThrottle.apply(this,arguments).toProperty()},I(b,p),k(b.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(K());else{this.sink=n;for(var t,r=A(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),w.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(K()):void 0},push:function(n){return this.ended||"function"!=typeof this.sink?void 0:this.sink(J(n))},error:function(n){return"function"==typeof this.sink?this.sink(new c(n)):void 0}}),w.Bus=b;var ln=function(n,t){return B(function(r){for(var e=C(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 V(new w.Desc(w,n,[r].concat(u)),w.combineAsArray(u).flatMap(e))})};w.fromCallback=ln("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 w.fromBinder(function(t){return z(n,r)(t),S},function(n){return[n,K()]})}),w.fromNodeCallback=ln("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 w.fromBinder(function(t){return z(n,r)(t),S},function(n,t){return n?[new c(n),K()]:[t,K()]})}),w.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 O(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(M(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 P.each(n,s)}var f=[],h=[];return c(n),V(new w.Desc(w,"combineTemplate",[n]),w.combineAsArray(h).map(a))};var pn=function(n,t){var r=new p(T(n,"justInitValue"),function(t){var e=void 0,i=n.dispatcher.subscribe(function(n){return n.isEnd()||(e=n),w.noMore});return W.whenDoneWith(r,function(){return"undefined"!=typeof e&&null!==e&&t(e),t(K())}),i});return r.concat(t).toProperty()};w.Observable.prototype.mapEnd=function(){var n=F(arguments);return V(new w.Desc(this,"mapEnd",[n]),this.withHandler(function(t){return t.isEnd()?(this.push(J(n(t))),this.push(K()),w.noMore):this.push(t)}))},w.Observable.prototype.skipErrors=function(){return V(new w.Desc(this,"skipErrors",[]),this.withHandler(function(n){return n.isError()?w.more:this.push(n)}))},w.EventStream.prototype.takeUntil=function(n){var t={};return V(new w.Desc(this,"takeUntil",[n]),w.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(K());for(var u,o=w.more,s=0;s<e.length;s++)u=e[s],o=u===t?this.push(K()):this.push(J(u));return o}return this.push(n)}))},w.Property.prototype.takeUntil=function(n){var t=this.changes().takeUntil(n);return V(new w.Desc(this,"takeUntil",[n]),pn(this,t))},w.Observable.prototype.flatMapLatest=function(){var n=cn(arguments),t=this.toEventStream();return V(new w.Desc(this,"flatMapLatest",[n]),t.flatMap(function(r){return fn(n(r)).takeUntil(t)}))},w.Property.prototype.delayChanges=function(n,t){return V(n,pn(this,t(this.changes())))},w.EventStream.prototype.delayChanges=function(n,t){return V(n,t(this))},w.Observable.prototype.delay=function(n){return this.delayChanges(new w.Desc(this,"delay",[n]),function(t){return t.flatMap(function(t){return w.later(n,t)})})},w.Observable.prototype.debounce=function(n){return this.delayChanges(new w.Desc(this,"debounce",[n]),function(t){return t.flatMapLatest(function(t){return w.later(n,t)})})},w.Observable.prototype.debounceImmediate=function(n){return this.delayChanges(new w.Desc(this,"debounceImmediate",[n]),function(t){return t.flatMapFirst(function(t){return w.once(t).concat(w.later(n).filter(!1))})})},w.Observable.prototype.decode=function(n){return V(new w.Desc(this,"decode",[n]),this.combine(w.combineTemplate(n),function(n,t){return t[n]}))},w.Observable.prototype.scan=function(n,t){ | ||
var r,e=this;t=R(t);var u=Z(n),o=!1,a=function(n){var a=!1,c=S,f=w.more,h=function(){return a?void 0:u.forEach(function(t){return a=o=!0,f=n(new s(function(){return t})),f===w.noMore?(c(),c=S):void 0})};return c=e.dispatcher.subscribe(function(r){if(r.hasValue()){if(o&&r.isInitial())return w.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!==w.noMore?n(r):void 0}),W.whenDoneWith(r,h),c};return r=new d(new w.Desc(this,"scan",[n,t]),a)},w.Observable.prototype.diff=function(n,t){return t=R(t),V(new w.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]}))},w.Observable.prototype.doAction=function(){var n=F(arguments);return V(new w.Desc(this,"doAction",[n]),this.withHandler(function(t){return t.hasValue()&&n(t.value()),this.push(t)}))},w.Observable.prototype.doEnd=function(){var n=F(arguments);return V(new w.Desc(this,"doEnd",[n]),this.withHandler(function(t){return t.isEnd()&&n(),this.push(t)}))},w.Observable.prototype.doError=function(){var n=F(arguments);return V(new w.Desc(this,"doError",[n]),this.withHandler(function(t){return t.isError()&&n(t.error),this.push(t)}))},w.Observable.prototype.doLog=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return V(new w.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)}))},w.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 j(this,n,r,function(n){return V(new w.Desc(this,"endOnError",[]),this.withHandler(function(t){return t.isError()&&n(t.error)?(this.push(t),this.push(K())):this.push(t)}))})},f.prototype.errors=function(){return V(new w.Desc(this,"errors",[]),this.filter(function(){return!1}))},w.Observable.prototype.take=function(n){return 0>=n?w.never():V(new w.Desc(this,"take",[n]),this.withHandler(function(t){return t.hasValue()?(n--,n>0?this.push(t):(0===n&&this.push(t),this.push(K()),w.noMore)):this.push(t)}))},w.Observable.prototype.first=function(){return V(new w.Desc(this,"first",[]),this.take(1))},w.Observable.prototype.mapError=function(){var n=F(arguments);return V(new w.Desc(this,"mapError",[n]),this.withHandler(function(t){return t.isError()?this.push(J(n(t.error))):this.push(t)}))},w.Observable.prototype.flatMapError=function(n){var t=new w.Desc(this,"flatMapError",[n]);return V(t,this.mapError(function(n){return new c(n)}).flatMap(function(t){return t instanceof c?n(t.error):w.once(t)}))},w.EventStream.prototype.flatScan=function(n,t){var r=n;return this.flatMapConcat(function(n){return fn(t(r,n)).doAction(function(n){return r=n})}).toProperty(n)},w.EventStream.prototype.sampledBy=function(n,t){return V(new w.Desc(this,"sampledBy",[n,t]),this.toProperty().sampledBy(n,t))},w.Property.prototype.sampledBy=function(t,r){var e=!1;"undefined"!=typeof r&&null!==r?r=R(r):(e=!0,r=function(n){return n.value()});var i=new n(this,!1,e),u=new n(t,!0,e),o=w.when([i,u],r),s=t._isProperty?o.toProperty():o;return V(new w.Desc(this,"sampledBy",[t,r]),s)},w.Property.prototype.sample=function(n){return V(new w.Desc(this,"sample",[n]),this.sampledBy(w.interval(n,{})))},w.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 j(this,n,r,function(n){return V(new w.Desc(this,"map",[n]),this.withHandler(function(t){return this.push(t.fmap(n))}))})},w.Observable.prototype.fold=function(n,t){return V(new w.Desc(this,"fold",[n,t]),this.scan(n,t).sampledBy(this.filter(!1).mapEnd().toProperty()))},f.prototype.reduce=f.prototype.fold;var vn=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"],["bind","unbind"]],dn=function(n){for(var t,r=0;r<vn.length;r++){t=vn[r];var e=[n[t[0]],n[t[1]]];if(e[0]&&e[1])return e}for(var i=0;i<vn.length;i++){t=vn[i];var u=n[t[0]];if(u)return[u,function(){}]}throw new c("No suitable event methods in "+n)};w.fromEventTarget=function(n,t,r){var e=dn(n),i=e[0],u=e[1],o=new w.Desc(w,"fromEvent",[n,t]);return V(o,w.fromBinder(function(r){return i.call(n,t,r),function(){return u.call(n,t,r)}},r))},w.fromEvent=w.fromEventTarget,w.fromPoll=function(n,t){var r=new w.Desc(w,"fromPoll",[n,t]);return V(r,w.fromBinder(function(t){var r=w.scheduler.setInterval(t,n);return function(){return w.scheduler.clearInterval(r)}},t))},w.fromPromise=function(n,t){var r=arguments.length<=2||void 0===arguments[2]?y:arguments[2];return V(new w.Desc(w,"fromPromise",[n]),w.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))},w.Observable.prototype.groupBy=function(n){var t=arguments.length<=1||void 0===arguments[1]?w._.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=w.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})},w.fromArray=function(n){if(n.length){var t=0;return new p(new w.Desc(w,"fromArray",[n]),function(r){var e=!1,i=w.more,u=!1,o=!1,s=function(){if(o=!0,!u){for(u=!0;o;)if(o=!1,i!==w.noMore&&!e){var a=n[t++];i=r(Y(a)),i!==w.noMore&&(t===n.length?r(K()):W.afterTransaction(s))}return u=!1}};return s(),function(){return e=!0}})}return V(new w.Desc(w,"fromArray",n),w.never())},w.EventStream.prototype.holdWhen=function(n){var t=!1,r=[],e=this,i=!1;return new p(new w.Desc(this,"holdWhen",[n]),function(u){var o=new h,s=!1,a=function(n){return"function"==typeof n&&n(),o.empty()&&s?u(K()):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(J(n)));return i&&(t.push(u(K())),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})},w.interval=function(n){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return V(new w.Desc(w,"interval",[n,t]),w.fromPoll(n,function(){return J(t)}))},w.$={},w.$.asEventStream=function(n,t,r){var e=this;return P.isFunction(t)&&(r=t,t=void 0),V(new w.Desc(this.selector||this,"asEventStream",[n]),w.fromBinder(function(r){return e.on(n,t,r),function(){return e.off(n,t,r)}},r))},"undefined"!=typeof jQuery&&jQuery&&(jQuery.fn.asEventStream=w.$.asEventStream),"undefined"!=typeof Zepto&&Zepto&&(Zepto.fn.asEventStream=w.$.asEventStream),w.Observable.prototype.last=function(){var n;return V(new w.Desc(this,"last",[]),this.withHandler(function(t){return t.isEnd()?(n&&this.push(n),this.push(K()),w.noMore):void(n=t)}))},w.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},w.EventStream.prototype.merge=function(n){var t=this;return V(new w.Desc(t,"merge",[n]),w.mergeAll(this,n))},w.mergeAll=function(){var n=un(arguments);return n.length?new p(new w.Desc(w,"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(K()):w.more;var u=t(e);return u===w.noMore&&i(),u})}},i=P.map(e,n);return new w.CompositeUnsubscribe(i).unsubscribe}):w.never()},w.repeatedly=function(n,t){var r=0;return V(new w.Desc(w,"repeatedly",[n,t]),w.fromPoll(n,function(){return t[r++%t.length]}))},w.repeat=function(n){var t=0;return w.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!==w.noMore;)i=n(t++),u=!1,i?s=i.subscribeInternal(e):r(K());return u=!0}var u=!1,o=w.more,s=function(){};return i(),function(){return s()}})},w.retry=function(n){if(!P.isFunction(n.source))throw new E("'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 V(new w.Desc(w,"retry",[n]),w.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=w.later(i(c)).filter(!1);return e++,f.concat(w.once().flatMap(a))}return a()}))},w.sequentially=function(n,t){var r=0;return V(new w.Desc(w,"sequentially",[n,t]),w.fromPoll(n,function(){var n=t[r++];return r<t.length?n:r===t.length?[n,K()]:K()}))},w.Observable.prototype.skip=function(n){return V(new w.Desc(this,"skip",[n]),this.withHandler(function(t){return t.hasValue()&&n>0?(n--,w.more):this.push(t)}))},w.EventStream.prototype.skipUntil=function(n){var t=n.take(1).map(!0).toProperty(!1);return V(new w.Desc(this,"skipUntil",[n]),this.filter(t))},w.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 j(this,n,e,function(n){return V(new w.Desc(this,"skipWhile",[n]),this.withHandler(function(r){return!t&&r.hasValue()&&n(r.value())?w.more:(r.hasValue()&&(t=!0),this.push(r))}))})},w.Observable.prototype.slidingWindow=function(n){var t=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return V(new w.Desc(this,"slidingWindow",[n,t]),this.scan([],function(t,r){return t.concat([r]).slice(-n)}).filter(function(n){return n.length>=t}))};var bn=[],tn=function(n){if(bn.length&&!tn.running)try{tn.running=!0,bn.forEach(function(t){t(n)})}finally{delete tn.running}};w.spy=function(n){return bn.push(n)},w.Property.prototype.startWith=function(n){return V(new w.Desc(this,"startWith",[n]),this.scan(n,function(n,t){return t}))},w.EventStream.prototype.startWith=function(n){return V(new w.Desc(this,"startWith",[n]),w.once(n).concat(this))},w.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 j(this,n,r,function(n){return V(new w.Desc(this,"takeWhile",[n]),this.withHandler(function(t){return t.filter(n)?this.push(t):(this.push(K()),w.noMore)}))})},w.Observable.prototype.throttle=function(n){return this.delayChanges(new w.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 E("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),w.noMore})})},f.prototype.toPromise=function(n){return this.last().firstToPromise(n)},w["try"]=function(n){return function(t){try{return w.once(n(t))}catch(r){return new w.Error(r)}}},w.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]=P.always(e[u])),e[u]=t(e[u]),u-=2;return V(new w.Desc(w,"update",[n].concat(e)),w.when.apply(w,e).scan(n,function(n,t){return t(n)}))},w.zipAsArray=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];var e=un(t);return V(new w.Desc(w,"zipAsArray",e),w.zipWith(e,function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];return t}))},w.zipWith=function(){for(var n=arguments.length,t=Array(n),r=0;n>r;r++)t[r]=arguments[r];var e=on(t),i=e[0],u=e[1];return i=P.map(function(n){return n.toEventStream()},i),V(new w.Desc(w,"zipWith",[u].concat(i)),w.when(i,u))},w.Observable.prototype.zip=function(n,t){return V(new w.Desc(this,"zip",[n]),w.zipWith([this,n],t||Array))},m.prototype.subscribe=function(n,t,r){var e="function"==typeof n?{next:n,error:t,complete:r}:n,i={closed:!1,unsubscribe:function(){i.closed=!0,u()}},u=this.observable.subscribe(function(n){n.isError()?(e.error&&e.error(n.error),i.unsubscribe()):n.isEnd()?(i.closed=!0,e.complete&&e.complete()):e.next&&e.next(n.value())});return i},m.prototype[x("observable")]=function(){return this},w.Observable.prototype.toESObservable=function(){return new m(this)},w.Observable.prototype[x("observable")]=w.Observable.prototype.toESObservable,w.fromESObservable=function(n){var t;t=n[x("observable")]?n[x("observable")]():n;var r=new w.Desc(w,"fromESObservable",[t]);return new w.EventStream(r,function(n){var r=t.subscribe({error:function(){n(new w.Error),n(new w.End)},next:function(t){n(new w.Next(t,!0))},complete:function(){n(new w.End)}});return r.unsubscribe?function(){r.unsubscribe()}:r})},"undefined"!=typeof define&&null!==define&&null!=define.amd?(define([],function(){return w}),"undefined"!=typeof this&&null!==this&&(this.Bacon=w)):"undefined"!=typeof module&&null!==module&&null!=module.exports?(module.exports=w,w.Bacon=w):this.Bacon=w}).call(this); |
{ | ||
"name": "baconjs", | ||
"description": "A small functional reactive programming lib for JavaScript.", | ||
"version": "0.7.91", | ||
"version": "0.7.92", | ||
"keywords": [ | ||
@@ -35,2 +35,3 @@ "bacon.js", | ||
"babel": "^5.8.23", | ||
"rxjs": "^5.2.0", | ||
"benchmark": "1.0.0", | ||
@@ -65,3 +66,5 @@ "bluebird": "^2", | ||
"sinon": "^1.12.2", | ||
"uglify-js": "^2.4.16" | ||
"uglify-js": "^2.4.16", | ||
"when": "^3.6.4", | ||
"zen-observable": "^0.4.0" | ||
}, | ||
@@ -68,0 +71,0 @@ "repository": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
357630
6801
2011
34