Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

baconjs

Package Overview
Dependencies
Maintainers
2
Versions
224
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

baconjs - npm Package Compare versions

Comparing version 0.7.94 to 0.7.95

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc