Socket
Socket
Sign inDemoInstall

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.95 to 1.0.0

readme/common.coffee

2

build-deps.js

@@ -49,3 +49,3 @@ var _ = require("lodash");

if (_.includes(resolving, pieceName)) {
throw new Error("circular dependency resolving " + piece + "; stack: " + resolving.join(""));
return [] // circular dep, break here
}

@@ -52,0 +52,0 @@

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

(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);
(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=++G}function o(t,n){if(!(this instanceof o))return new o(t,n);u.call(this),!n&&_.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=++nt,this.initialDesc=this.desc}function h(){var t=arguments.length<=0||void 0===arguments[0]?[]:arguments[0];this.unsubscribe=_.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=_.bind(this.subscribe,this),this.handleEvent=_.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);_.isFunction(t)&&(r=n,n=t,t=e.empty),f.call(this,t),this.dispatcher=new l(n,r),rt(this)}function v(t,n,r){l.call(this,n,r),this.property=t,this.subscribe=_.bind(this.subscribe,this),this.current=Z,this.currentValueRootId=void 0,this.propertyEnded=!1}function d(t,n,r){f.call(this,t),this.dispatcher=new v(this,n,r),rt(this)}function b(t,n){var r=new p(V(t,"justInitValue"),function(n){var e=void 0,i=t.dispatcher.subscribe(function(t){return t.isEnd()||(e=t),E.noMore});return T.whenDoneWith(r,function(){return void 0!==e&&null!==e&&n(e),n(Y())}),i});return r.concat(n).toProperty()}function y(){if(!(this instanceof y))return new y;this.unsubAll=_.bind(this.unsubAll,this),this.subscribeAll=_.bind(this.subscribeAll,this),this.guardedSink=_.bind(this.guardedSink,this),this.sink=void 0,this.subscriptions=[],this.ended=!1,p.call(this,new E.Desc(E,"Bus",[]),this.subscribeAll)}function m(t){return[t,Y()]}function g(t){this.observable=t}var w=Array.prototype.slice,E={toString:function(){return"Bacon"}};E.version="1.0.0";var S=("undefined"!=typeof global&&null!==global?global:this).Error,D=function(){},A=function(t,n){return t},O=function(t){return t.slice(0)},M=Array.isArray||function(t){return t instanceof Array},k=function(t){return t&&t._isObservable},I=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},x=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},P=function(t){return"undefined"!=typeof Symbol&&Symbol[t]?Symbol[t]:"undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol[t]=Symbol.for(t):"@@"+t},_={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 M(t)?t:[t]},contains:function(t,n){return-1!==_.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]?_.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]?_.id:arguments[1],e=0;e<t.length;e++)if(n=t[e],r(n))return!0;return!1},without:function(t,n){return _.filter(function(n){return n!==t},n)},remove:function(t,n){var r=_.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 _.fold(n,[],function(n,r){return n.concat(t(r))})},cached:function(t){var n=Z;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 W++,null==t?"undefined":_.isFunction(t)?"function":M(t)?W>5?"[..]":"["+_.map(_.toString,t).toString()+"]":null!=(null!=t?t.toString:void 0)&&t.toString!==Object.prototype.toString?t.toString():"object"==typeof t?W>5?"{..}":"{"+function(){var i=[];for(n in t)e.call(t,n)&&(r=function(){try{return t[n]}catch(t){return t}}(),i.push(_.toString(n)+":"+_.toString(r)));return i}()+"}":t}finally{W--}}},W=0;E._=_;var T=E.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=_.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)===E.noMore)return u()}})}),e&&i(),u};return{whenDoneWith:h,hasWaiters:function(){return i.length>0},inTransaction:d,currentEventId:b,wrappedSubscribe:y,afterTransaction:f}}();I(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:_.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}),x(n,t),I(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}),x(r,t),I(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)},I(e.prototype,{_isDesc:!0,deps:function(){return this.cached||(this.cached=B([this.context].concat(this.args))),this.cached},toString:function(){return _.toString(this.context)+"."+_.toString(this.method)+"("+_.map(_.toString,this.args)+")"}});var V=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)},H=function(t,n){return n.desc=t,n},B=function(t){return M(t)?_.flatMap(B,t):k(t)?[t]:(void 0!==t&&null!==t?t._isSource:void 0)?[t.obs]:[]};E.Desc=e,E.Desc.empty=new E.Desc("","",[]);var F=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))}},C=function(t){return t=Array.prototype.slice.call(t),j.apply(void 0,t)},N=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))}},q=function(t){return function(n){return function(r){if(void 0!==r&&null!==r){var e=r[n];return _.isFunction(e)?e.apply(r,t):e}}}},L=function(t,n){var r=t.slice(1).split("."),e=_.map(q(n),r);return function(t){for(var n,r=0;r<e.length;r++)n=e[r],t=n(t);return t}},U=function(t){return"string"==typeof t&&t.length>1&&"."===t.charAt(0)},j=F(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 _.isFunction(t)?r.length?N(t,r):t:U(t)?L(t,r):_.always(t)}),z=function(t,n){return j.apply(void 0,[t].concat(n))},Q=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=z(n,r),e.call(t,n)},R=function(t){if(_.isFunction(t))return t;if(U(t)){var n=$(t);return function(t,r){return t[n](r)}}throw new S("not a function or a field key: "+t)},$=function(t){return t.slice(1)};I(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):Z},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 Z={_isNone:!0,getOrElse:function(t){return t},filter:function(){return Z},map:function(){return Z},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},X=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)};E.noMore="<no-more>",E.more="<more>";var G=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()},x(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 _.toString(this.value())},o.prototype.log=function(){return this.value()},o.prototype._isNext=!0,x(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)},x(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>"},x(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> "+_.toString(this.error)},E.Event=u,E.Initial=s,E.Next=o,E.End=c,E.Error=a;var J=function(t){return new s(t,!0)},K=function(t){return new o(t,!0)},Y=function(){return new c},tt=function(t){return t&&t._isEvent?t:K(t)},nt=0,rt=function(){};I(f.prototype,{_isObservable:!0,subscribe:function(t){return T.wrappedSubscribe(this,t)},subscribeInternal:function(t){return this.dispatcher.subscribe(t)},onValue:function(){var t=C(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=C(arguments);return this.subscribe(function(n){if(n.isError())return t(n.error)})},onEnd:function(){var t=C(arguments);return this.subscribe(function(n){if(n.isEnd())return t()})},name:function(t){return this._name=t,this},withDescription:function(){return this.desc=V.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,E.Observable=f,I(h.prototype,{add:function(t){var n=this;if(!this.unsubscribed){var r=!1,e=D;this.starting.push(t);var i=function(){if(!n.unsubscribed)return r=!0,n.remove(e),_.remove(t,n.starting)};return e=t(this.unsubscribe,i),this.unsubscribed||r?e():this.subscriptions.push(e),_.remove(t,this.starting),e}},remove:function(t){if(!this.unsubscribed)return void 0!==_.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()}}),E.CompositeUnsubscribe=h,l.prototype.hasSubscribers=function(){return this.subscriptions.length>0},l.prototype.removeSub=function(t){return this.subscriptions=_.without(t,this.subscriptions),this.subscriptions},l.prototype.push=function(t){return t.isEnd()&&(this.ended=!0),T.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)===E.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),E.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()?E.more:(this.unsubscribeFromSource(),E.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(Y()),D):(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))},E.Dispatcher=l,x(p,f),I(p.prototype,{_isEventStream:!0,toProperty:function(t){var n=0===arguments.length?Z:X(function(){return t}),r=this.dispatcher;return new d(new E.Desc(this,"toProperty",[t]),function(t){var e=!1,u=!1,o=D,c=E.more,a=function(){if(!e)return n.forEach(function(n){if(e=!0,(c=t(new s(n)))===E.noMore)return o(),o=D,D})};return o=r.subscribe(function(r){return r.hasValue()?r.isInitial()&&!u?(n=new i(function(){return r.value()}),E.more):(r.isInitial()||a(),e=!0,n=new i(r),t(r)):(r.isEnd()&&(c=a()),c!==E.noMore?t(r):void 0)}),u=!0,a(),o})},toEventStream:function(){return this},withHandler:function(t){return new p(new E.Desc(this,"withHandler",[t]),this.dispatcher.subscribe,t)}}),E.EventStream=p,E.never=function(){return new p(V(E,"never"),function(t){return t(Y()),D})},E.when=function(){if(0===arguments.length)return E.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=_.toArray(arguments[i]),c=it(arguments[i+1]),a={f:c,ixs:[]},f=!1,h=0;h<s.length;h++){o=s[h];var l=_.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 E.never();r=_.map(t.fromObservable,r);var b=_.any(r,function(t){return t.flatten})&&et(_.map(function(t){return t.obs},r)),y=new E.Desc(E,"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 T.whenDoneWith(m,p)},l=function(){if(!(n.length>0))return E.more;for(var i,o=E.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=_.filter(c,n)),o===E.noMore?o:l()}},p=function(){var n=l();return i&&(_.all(r,o)||_.all(e,s))&&(n=E.noMore,t(Y())),n===E.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||T.hasWaiters()?h():p());return e===E.noMore&&f(),e||E.more})}};return new E.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 et=function(t){var n=arguments.length<=1||void 0===arguments[1]?[]:arguments[1],r=function(t){if(_.contains(n,t))return!0;var e=t.internalDeps();return e.length?(n.push(t),_.any(e,r)):(n.push(t),!1)};return _.any(t,r)},it=function(t){return _.isFunction(t)?t:_.always(t)};E.groupSimultaneous=function(){for(var t=arguments.length,n=Array(t),e=0;e<t;e++)n[e]=arguments[e];1===n.length&&M(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 H(new E.Desc(E,"groupSimultaneous",n),E.when(i,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}))},x(v,l),I(v.prototype,{push:function(t){return t.isEnd()&&(this.propertyEnded=!0),t.hasValue()&&(this.current=new i(t),this.currentValueRootId=T.currentEventId()),l.prototype.push.call(this,t)},maybeSubSource:function(t,n){return n===E.noMore?D:this.propertyEnded?(t(Y()),D):l.prototype.subscribe.call(this,t)},subscribe:function(t){var n=this,r=E.more;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=T.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?(T.whenDoneWith(this.property,function(){if(n.currentValueRootId===i)return t(J(n.current.get().value()))}),this.maybeSubSource(t,r)):(T.inTransaction(void 0,this,function(){return r=t(J(this.current.get().value()))},[]),this.maybeSubSource(t,r))}return this.maybeSubSource(t,r)}}),x(d,f),I(d.prototype,{_isProperty:!0,changes:function(){var t=this;return new p(new E.Desc(this,"changes",[]),function(n){return t.dispatcher.subscribe(function(t){if(!t.isInitial())return n(t)})})},withHandler:function(t){return new d(new E.Desc(this,"withHandler",[t]),this.dispatcher.subscribe,t)},toProperty:function(){return this},toEventStream:function(){var t=this;return new p(new E.Desc(this,"toEventStream",[]),function(n){return t.dispatcher.subscribe(function(t){return t.isInitial()&&(t=t.toNext()),n(t)})})}}),E.Property=d,E.constant=function(t){return new d(new E.Desc(E,"constant",[t]),function(n){return n(J(t)),n(Y()),D})},E.fromBinder=function(t){var n=arguments.length<=1||void 0===arguments[1]?_.id:arguments[1];return new p(new E.Desc(E,"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);M(s)&&(null!=(t=_.last(s))?t._isEvent:void 0)||(s=[s]);for(var c,a=E.more,f=0;f<s.length;f++)if(c=s[f],(a=r(c=tt(c)))===E.noMore||c.isEnd())return u(),a;return a});return i&&u(),u})},E.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 Q(this,t,r,function(t){return H(new E.Desc(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})};var ut=function(t){return M(t[0])?t[0]:Array.prototype.slice.call(t)},ot=function(t){return _.isFunction(t[0])?[ut(Array.prototype.slice.call(t,1)),t[0]]:[ut(Array.prototype.slice.call(t,0,t.length-1)),_.last(t)]};E.combineAsArray=function(){var n=ut(arguments);if(n.length){for(var r=[],e=0;e<n.length;e++){var i=k(n[e])?n[e]:E.constant(n[e]);r.push(new t(i,!0))}return H(new E.Desc(E,"combineAsArray",n),E.when(r,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}).toProperty())}return E.constant([])},E.onValues=function(){return E.combineAsArray(Array.prototype.slice.call(arguments,0,arguments.length-1)).onValues(arguments[arguments.length-1])},E.combineWith=function(){var t=ot(arguments),n=t[0],r=t[1],e=new E.Desc(E,"combineWith",[r].concat(n));return H(e,E.combineAsArray(n).map(function(t){return r.apply(void 0,t)}))},E.Observable.prototype.combine=function(t,n){var r=R(n),e=new E.Desc(this,"combine",[t,n]);return H(e,E.combineAsArray(this,t).map(function(t){return r(t[0],t[1])}))},E.Observable.prototype.withStateMachine=function(t,n){var r=t,e=new E.Desc(this,"withStateMachine",[t,n]);return H(e,this.withHandler(function(t){var e=n(r,t),i=e[0],u=e[1];r=i;for(var o,s=E.more,c=0;c<u.length;c++)if(o=u[c],(s=this.push(o))===E.noMore)return s;return s}))};var st=function(t,n){return t===n},ct=function(t){return void 0!==t&&null!==t&&t._isNone};E.Observable.prototype.skipDuplicates=function(){var t=arguments.length<=0||void 0===arguments[0]?st:arguments[0],n=new E.Desc(this,"skipDuplicates",[]);return H(n,this.withStateMachine(Z,function(n,r){return r.hasValue()?r.isInitial()||ct(n)||!t(n.get(),r.value())?[new i(r.value()),[r]]:[n,[]]:[n,[r]]}))},E.Observable.prototype.awaiting=function(t){var n=new E.Desc(this,"awaiting",[t]);return H(n,E.groupSimultaneous(this,t).map(function(t){return 0===t[1].length}).toProperty(!1).skipDuplicates())},E.Observable.prototype.not=function(){return H(new E.Desc(this,"not",[]),this.map(function(t){return!t}))},E.Property.prototype.and=function(t){return H(new E.Desc(this,"and",[t]),this.combine(t,function(t,n){return t&&n}))},E.Property.prototype.or=function(t){return H(new E.Desc(this,"or",[t]),this.combine(t,function(t,n){return t||n}))},E.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()}},E.EventStream.prototype.bufferWithTime=function(t){return H(new E.Desc(this,"bufferWithTime",[t]),this.bufferWithTimeOrCount(t,Number.MAX_VALUE))},E.EventStream.prototype.bufferWithCount=function(t){return H(new E.Desc(this,"bufferWithCount",[t]),this.bufferWithTimeOrCount(void 0,t))},E.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 E.Desc(this,"bufferWithTimeOrCount",[t,n]);return H(e,this.buffer(t,r,r))},E.EventStream.prototype.buffer=function(t){var n=arguments.length<=1||void 0===arguments[1]?D:arguments[1],r=arguments.length<=2||void 0===arguments[2]?D:arguments[2],e={scheduled:null,end:void 0,values:[],flush:function(){if(this.scheduled&&(E.scheduler.clearTimeout(this.scheduled),this.scheduled=null),this.values.length>0){var t=this.values;this.values=[];var n=this.push(K(t));if(null!=this.end)return this.push(this.end);if(n!==E.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=E.more;if(!_.isFunction(t)){var u=t;t=function(t){return E.scheduler.setTimeout(t,u)}}return H(new E.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}))},E.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 Q(this,t,r,function(t){return H(new E.Desc(this,"filter",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):E.more}))})},E.once=function(t){return new p(new e(E,"once",[t]),function(n){return n(tt(t)),n(Y()),D})},E.EventStream.prototype.concat=function(t){var n=this;return new p(new E.Desc(n,"concat",[t]),function(r){var e=D,i=n.dispatcher.subscribe(function(n){return n.isEnd()?e=t.toEventStream().dispatcher.subscribe(r):r(n)});return function(){return i(),e()}})},E.Property.prototype.concat=function(t){return b(this,this.changes().concat(t))},E.concatAll=function(){var t=ut(arguments);return t.length?H(new E.Desc(E,"concatAll",t),_.fold(_.tail(t),_.head(t).toEventStream(),function(t,n){return t.concat(n)})):E.never()},E.Observable.prototype.flatMap=function(){return ht(this,at(arguments))},E.Observable.prototype.flatMapFirst=function(){return ht(this,at(arguments),!0)};var at=function(t){return 1===t.length&&k(t[0])?_.always(t[0]):C(t)},ft=function(t){return k(t)?t:E.once(t)},ht=function(t,n,r,e){var i=[t],u=[],o=new E.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 _.remove(r,u),a(),f(n),E.noMore;(void 0!==e&&null!==e?e._isInitial:void 0)&&(e=e.toNext());var o=i(e);return o===E.noMore&&t(),o})})},a=function(){var t=s.shift();if(t)return c(t)},f=function(t){if(t(),o.empty())return i(Y())};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?E.more:o.unsubscribed?E.noMore:e&&o.count()>e?s.push(t):c(t)})}),o.unsubscribe});return s.internalDeps=function(){return u.length?i.concat(u):i},s};E.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 E.Desc(this,"flatMapWithConcurrencyLimit",[t].concat(r));return H(i,ht(this,at(r),!1,t))},E.Observable.prototype.flatMapConcat=function(){var t=new E.Desc(this,"flatMapConcat",Array.prototype.slice.call(arguments,0));return H(t,this.flatMapWithConcurrencyLimit.apply(this,[1].concat(w.call(arguments))))},E.later=function(t,n){return H(new E.Desc(E,"later",[t,n]),E.fromBinder(function(r){var e=function(){return r([n,Y()])},i=E.scheduler.setTimeout(e,t);return function(){return E.scheduler.clearTimeout(i)}}))},E.Observable.prototype.bufferingThrottle=function(t){var n=new E.Desc(this,"bufferingThrottle",[t]);return H(n,this.flatMapConcat(function(n){return E.once(n).concat(E.later(t).filter(!1))}))},E.Property.prototype.bufferingThrottle=function(){return E.Observable.prototype.bufferingThrottle.apply(this,arguments).toProperty()},x(y,p),I(y.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(Y());else{this.sink=t;for(var n,r=O(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),E.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(Y())},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(K(t))}finally{if(n&&this.pushQueue){for(var r=0;r<this.pushQueue.length;){var t=this.pushQueue[r];this.sink(K(t)),r++}this.pushQueue=null}this.pushing=!1}}},error:function(t){if("function"==typeof this.sink)return this.sink(new a(t))}}),E.Bus=y;var lt=function(t,n){return F(function(r){for(var e=N(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 H(new E.Desc(E,t,[r].concat(u)),E.combineAsArray(u).flatMap(e))})};E.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 E.fromBinder(function(n){return z(t,r)(n),D},function(t){return[t,Y()]})}),E.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 E.fromBinder(function(n){return z(t,r)(n),D},function(t,n){return t?[new a(t),Y()]:[n,Y()]})}),E.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 M(t)?[]:{}}function o(t,n){return function(e){var i=u(n);r(e,t,i),e.push(i)}}function s(t){if(k(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(k(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){_.each(t,c)}var h=[],l=[],p=s(t)?(f(t),E.combineAsArray(l).map(a)):E.constant(t);return H(new E.Desc(E,"combineTemplate",[t]),p)},E.Observable.prototype.mapEnd=function(){var t=C(arguments);return H(new E.Desc(this,"mapEnd",[t]),this.withHandler(function(n){return n.isEnd()?(this.push(K(t(n))),this.push(Y()),E.noMore):this.push(n)}))},E.Observable.prototype.skipErrors=function(){return H(new E.Desc(this,"skipErrors",[]),this.withHandler(function(t){return t.isError()?E.more:this.push(t)}))},E.EventStream.prototype.takeUntil=function(t){var n={};return H(new E.Desc(this,"takeUntil",[t]),E.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(Y());for(var i,u=E.more,o=0;o<e.length;o++)i=e[o],u=i===n?this.push(Y()):this.push(K(i));return u}return this.push(t)}))},E.Property.prototype.takeUntil=function(t){var n=this.changes().takeUntil(t);return H(new E.Desc(this,"takeUntil",[t]),b(this,n))},E.Observable.prototype.flatMapLatest=function(){var t=at(arguments),n=this.toEventStream();return H(new E.Desc(this,"flatMapLatest",[t]),n.flatMap(function(r){return ft(t(r)).takeUntil(n)}))},
E.Property.prototype.delayChanges=function(t,n){return H(t,b(this,n(this.changes())))},E.EventStream.prototype.delayChanges=function(t,n){return H(t,n(this))},E.Observable.prototype.delay=function(t){return this.delayChanges(new E.Desc(this,"delay",[t]),function(n){return n.flatMap(function(n){return E.later(t,n)})})},E.Observable.prototype.debounce=function(t){return this.delayChanges(new E.Desc(this,"debounce",[t]),function(n){return n.flatMapLatest(function(n){return E.later(t,n)})})},E.Observable.prototype.debounceImmediate=function(t){return this.delayChanges(new E.Desc(this,"debounceImmediate",[t]),function(n){return n.flatMapFirst(function(n){return E.once(n).concat(E.later(t).filter(!1))})})},E.Observable.prototype.decode=function(t){return H(new E.Desc(this,"decode",[t]),this.combine(E.combineTemplate(t),function(t,n){return n[t]}))},E.Observable.prototype.scan=function(t,n){var r,e=this;n=R(n);var u=X(t),o=!1,c=function(t){var c=!1,a=D,f=E.more,h=function(){if(!c)return u.forEach(function(n){if(c=o=!0,(f=t(new s(function(){return n})))===E.noMore)return a(),a=D})};return a=e.dispatcher.subscribe(function(r){if(r.hasValue()){if(o&&r.isInitial())return E.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!==E.noMore)return t(r)}),T.whenDoneWith(r,h),a};return r=new d(new E.Desc(this,"scan",[t,n]),c)},E.Observable.prototype.diff=function(t,n){return n=R(n),H(new E.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]}))},E.Observable.prototype.doAction=function(){var t=C(arguments);return H(new E.Desc(this,"doAction",[t]),this.withHandler(function(n){return n.hasValue()&&t(n.value()),this.push(n)}))},E.Observable.prototype.doEnd=function(){var t=C(arguments);return H(new E.Desc(this,"doEnd",[t]),this.withHandler(function(n){return n.isEnd()&&t(),this.push(n)}))},E.Observable.prototype.doError=function(){var t=C(arguments);return H(new E.Desc(this,"doError",[t]),this.withHandler(function(n){return n.isError()&&t(n.error),this.push(n)}))},E.Observable.prototype.doLog=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return H(new E.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)}))},E.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 Q(this,t,r,function(t){return H(new E.Desc(this,"endOnError",[]),this.withHandler(function(n){return n.isError()&&t(n.error)?(this.push(n),this.push(Y())):this.push(n)}))})},f.prototype.errors=function(){return H(new E.Desc(this,"errors",[]),this.filter(function(){return!1}))},E.Observable.prototype.take=function(t){return t<=0?E.never():H(new E.Desc(this,"take",[t]),this.withHandler(function(n){return n.hasValue()?(t--,t>0?this.push(n):(0===t&&this.push(n),this.push(Y()),E.noMore)):this.push(n)}))},E.Observable.prototype.first=function(){return H(new E.Desc(this,"first",[]),this.take(1))},E.Observable.prototype.mapError=function(){var t=C(arguments);return H(new E.Desc(this,"mapError",[t]),this.withHandler(function(n){return n.isError()?this.push(K(t(n.error))):this.push(n)}))},E.Observable.prototype.flatMapError=function(t){var n=new E.Desc(this,"flatMapError",[t]);return H(n,this.mapError(function(t){return new a(t)}).flatMap(function(n){return n instanceof a?t(n.error):E.once(n)}))},E.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)},E.EventStream.prototype.sampledBy=function(t,n){return H(new E.Desc(this,"sampledBy",[t,n]),this.toProperty().sampledBy(t,n))},E.Property.prototype.sampledBy=function(n,r){var e=!1;void 0!==r&&null!==r?r=R(r):(e=!0,r=function(t){return t.value()});var i=new t(this,!1,e),u=new t(n,!0,e),o=E.when([i,u],r),s=n._isProperty?o.toProperty():o;return H(new E.Desc(this,"sampledBy",[n,r]),s)},E.Property.prototype.sample=function(t){return H(new E.Desc(this,"sample",[t]),this.sampledBy(E.interval(t,{})))},E.Observable.prototype.map=function(t){if(t&&t._isProperty)return t.sampledBy(this,A);for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return Q(this,t,r,function(t){return H(new E.Desc(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})},E.Observable.prototype.fold=function(t,n){return H(new E.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)};E.fromEventTarget=function(t,n,r){var e=vt(t),i=e[0],u=e[1],o=new E.Desc(E,"fromEvent",[t,n]);return H(o,E.fromBinder(function(r){return i.call(t,n,r),function(){return u.call(t,n,r)}},r))},E.fromEvent=E.fromEventTarget,E.fromPoll=function(t,n){var r=new E.Desc(E,"fromPoll",[t,n]);return H(r,E.fromBinder(function(n){var r=E.scheduler.setInterval(n,t);return function(){return E.scheduler.clearInterval(r)}},n))},E.fromPromise=function(t,n){var r=arguments.length<=2||void 0===arguments[2]?m:arguments[2];return H(new E.Desc(E,"fromPromise",[t]),E.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))},E.Observable.prototype.groupBy=function(t){var n=arguments.length<=1||void 0===arguments[1]?E._.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=E.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})},E.fromArray=function(t){if(t.length){var n=0,r=new p(new E.Desc(E,"fromArray",[t]),function(e){function i(){if(c=!0,!s){for(s=!0;c;)if(c=!1,o!==E.noMore&&!u){var a=t[n++];o=e(tt(a)),o!==E.noMore&&(n===t.length?e(Y()):T.afterTransaction(r,i))}return s=!1}}var u=!1,o=E.more,s=!1,c=!1;return i(),function(){return u=!0}});return r}return H(new E.Desc(E,"fromArray",t),E.never())},E.EventStream.prototype.holdWhen=function(t){var n=!1,r=[],e=this,i=!1;return new p(new E.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(Y())};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(K(t)));return i&&(n.push(u(Y())),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})},E.interval=function(t){var n=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return H(new E.Desc(E,"interval",[t,n]),E.fromPoll(t,function(){return K(n)}))},E.$={},E.$.asEventStream=function(t,n,r){var e=this;return _.isFunction(n)&&(r=n,n=void 0),H(new E.Desc(this.selector||this,"asEventStream",[t]),E.fromBinder(function(r){return e.on(t,n,r),function(){return e.off(t,n,r)}},r))},"undefined"!=typeof jQuery&&jQuery&&(jQuery.fn.asEventStream=E.$.asEventStream),"undefined"!=typeof Zepto&&Zepto&&(Zepto.fn.asEventStream=E.$.asEventStream),E.Observable.prototype.last=function(){var t;return H(new E.Desc(this,"last",[]),this.withHandler(function(n){if(n.isEnd())return t&&this.push(t),this.push(Y()),E.noMore;t=n}))},E.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},E.EventStream.prototype.merge=function(t){var n=this;return H(new E.Desc(n,"merge",[t]),E.mergeAll(this,t))},E.mergeAll=function(){var t=ut(arguments);return t.length?new p(new E.Desc(E,"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(Y()):E.more;var u=n(e);return u===E.noMore&&i(),u})}},i=_.map(e,t);return new E.CompositeUnsubscribe(i).unsubscribe}):E.never()},E.repeatedly=function(t,n){var r=0;return H(new E.Desc(E,"repeatedly",[t,n]),E.fromPoll(t,function(){return n[r++%n.length]}))},E.repeat=function(t){var n=0;return E.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!==E.noMore;)i=t(n++),u=!1,i?s=i.subscribeInternal(e):r(Y());return u=!0}var u=!1,o=E.more,s=function(){};return i(),function(){return s()}})},E.retry=function(t){if(!_.isFunction(t.source))throw new S("'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 H(new E.Desc(E,"retry",[t]),E.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=E.later(i(a)).filter(!1);return e++,f.concat(E.once().flatMap(c))}return c()}))},E.sequentially=function(t,n){var r=0;return H(new E.Desc(E,"sequentially",[t,n]),E.fromPoll(t,function(){var t=n[r++];return r<n.length?t:r===n.length?[t,Y()]:Y()}))},E.Observable.prototype.skip=function(t){return H(new E.Desc(this,"skip",[t]),this.withHandler(function(n){return n.hasValue()&&t>0?(t--,E.more):this.push(n)}))},E.EventStream.prototype.skipUntil=function(t){var n=t.take(1).map(!0).toProperty(!1);return H(new E.Desc(this,"skipUntil",[t]),this.filter(n))},E.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 Q(this,t,e,function(t){return H(new E.Desc(this,"skipWhile",[t]),this.withHandler(function(r){return!n&&r.hasValue()&&t(r.value())?E.more:(r.hasValue()&&(n=!0),this.push(r))}))})},E.Observable.prototype.slidingWindow=function(t){var n=arguments.length<=1||void 0===arguments[1]?0:arguments[1];return H(new E.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=[],rt=function(t){if(dt.length&&!rt.running)try{rt.running=!0,dt.forEach(function(n){n(t)})}finally{delete rt.running}};E.spy=function(t){return dt.push(t)},E.Property.prototype.startWith=function(t){return H(new E.Desc(this,"startWith",[t]),this.scan(t,function(t,n){return n}))},E.EventStream.prototype.startWith=function(t){return H(new E.Desc(this,"startWith",[t]),E.once(t).concat(this))},E.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 Q(this,t,r,function(t){return H(new E.Desc(this,"takeWhile",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):(this.push(Y()),E.noMore)}))})},E.Observable.prototype.throttle=function(t){return this.delayChanges(new E.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 S("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),E.noMore})})},f.prototype.toPromise=function(t){return this.last().firstToPromise(t)},E.try=function(t){return function(n){try{return E.once(t(n))}catch(t){return new E.Error(t)}}},E.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]=_.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 H(new E.Desc(E,"update",[t].concat(r)),E.when.apply(E,r).scan(t,function(t,n){return n(t)}))},E.zipAsArray=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];var e=ut(n);return H(new E.Desc(E,"zipAsArray",e),E.zipWith(e,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}))},E.zipWith=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];var e=ot(n),i=e[0],u=e[1];return i=_.map(function(t){return t.toEventStream()},i),H(new E.Desc(E,"zipWith",[u].concat(i)),E.when(i,u))},E.Observable.prototype.zip=function(t,n){return H(new E.Desc(this,"zip",[t]),E.zipWith([this,t],n||Array))},g.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},g.prototype[P("observable")]=function(){return this},E.Observable.prototype.toESObservable=function(){return new g(this)},E.Observable.prototype[P("observable")]=E.Observable.prototype.toESObservable,E.fromESObservable=function(t){var n;n=t[P("observable")]?t[P("observable")]():t;var r=new E.Desc(E,"fromESObservable",[n]);return new E.EventStream(r,function(t){var r=n.subscribe({error:function(){t(new E.Error),t(new E.End)},next:function(n){t(new E.Next(n,!0))},complete:function(){t(new E.End)}});return r.unsubscribe?function(){r.unsubscribe()}:r})},"undefined"!=typeof define&&null!==define&&null!=define.amd?(define([],function(){return E}),void 0!==this&&null!==this&&(this.Bacon=E)):"undefined"!=typeof module&&null!==module&&null!=module.exports?(module.exports=E,E.Bacon=E):this.Bacon=E}).call(this);
{
"name": "baconjs",
"description": "A small functional reactive programming lib for JavaScript.",
"version": "0.7.95",
"version": "1.0.0",
"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