Comparing version 2.0.6 to 2.0.7
@@ -1,2 +0,2 @@ | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.Bacon=n()}(this,function(){"use strict";function t(){}function n(t){return t}function r(t){return t.slice(0)}function e(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}function i(t,n){function r(){}var e={}.hasOwnProperty;r.prototype=n.prototype,t.prototype=new r;for(var i in n)e.call(n,i)&&(t[i]=n[i]);return t}function u(t){return"undefined"!=typeof Symbol&&Symbol[t]?Symbol[t]:"undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol[t]=Symbol.for(t):"@@"+t}function o(t){this.value=t}function s(){this.id=++Wt}function c(t){if(!(this instanceof c))return new c(t);s.call(this),this.value=t}function f(t){if(!(this instanceof f))return new f(t);c.call(this,t)}function a(){if(!(this instanceof a))return new a;s.call(this)}function h(t){if(!(this instanceof h))return new h(t);this.error=t,s.call(this)}function p(t){return new f(t)}function l(t){return new c(t)}function d(){return new a}function v(t){return t&&t._isEvent?t:l(t)}function y(t){if(Ht.length&&!y.running)try{y.running=!0,Ht.forEach(function(n){n(t)})}finally{delete y.running}}function b(t,n,r){this.context=t,this.method=n,this.args=r}function g(t,n){var r=t||n;if(r&&r._isDesc)return t||n;for(var e=arguments.length,i=Array(e>2?e-2:0),u=2;u<e;u++)i[u-2]=arguments[u];return new b(t,n,i)}function w(t,n){return n.desc=t,n}function m(t){return _t(t)?Tt.flatMap(m,t):xt(t)?[t]:(void 0!==t&&null!==t?t._isSource:void 0)?[t.obs]:[]}function E(t,n){this._subscribe=t,this._handleEvent=n,this.subscribe=Tt.bind(this.subscribe,this),this.handleEvent=Tt.bind(this.handleEvent,this),this.pushing=!1,this.ended=!1,this.prevError=void 0,this.unsubSrc=void 0,this.subscriptions=[],this.queue=[]}function S(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))}}function A(t){return t=Array.prototype.slice.call(t),Nt.apply(void 0,t)}function k(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))}}function _(t){return function(n){return function(r){if(void 0!==r&&null!==r){var e=r[n];return Tt.isFunction(e)?e.apply(r,t):e}}}}function x(t,n){var r=t.slice(1).split("."),e=Tt.map(_(n),r);return function(t){for(var n,r=0;r<e.length;r++)n=e[r],t=n(t);return t}}function I(t){return"string"==typeof t&&t.length>1&&"."===t.charAt(0)}function M(t,n){return Nt.apply(void 0,[t].concat(n))}function T(t,n,r,e){if(n&&n._isProperty){var i=n.sampledBy(t,function(t,n){return[t,n]});return e.call(i,function(t){return t[0]}).map(function(t){return t[1]})}return n=M(n,r),e.call(t,n)}function O(t){if(Tt.isFunction(t))return t;if(I(t)){var n=W(t);return function(t,r){return t[n](r)}}throw new Error("not a function or a field key: "+t)}function W(t){return t.slice(1)}function P(t){this.desc=t,this.id=++Ft,this.initialDesc=this.desc}function V(t,n,r){E.call(this,n,r),this.property=t,this.subscribe=Tt.bind(this.subscribe,this),this.current=It,this.currentValueRootId=void 0,this.propertyEnded=!1}function H(t,n){return new D(t,N(It,n))}function D(t,n,r){P.call(this,t),this.dispatcher=new V(this,n,r),y(this)}function C(t,n,r,e){if(!(this instanceof C))return new C(t,n,r);Tt.isFunction(t)&&(r=n,n=t,t=Lt),e!==qt&&(n=B(this,n)),P.call(this,t),this.dispatcher=new E(n,r),y(this)}function B(t,n){var r=!1;return function(e){function i(){var t=o;o=null;for(var n=0;n<t.length;n++){var r=t[n];e(r)}}var u=Bt.isInTransaction();r=!0;var o;try{return n(function(n){if(!r&&!o)return e(n);o?o.push(n):(o=[n],u?Bt.soonButNotYet(t,i):jt.scheduler.setTimeout(i,0))})}finally{r=!1}}}function N(n,r){return function(e){var i=!1,u=!1,s=t,c=Vt,a=function(){if(!i)return n.forEach(function(n){if(i=!0,(c=e(new f(n)))===Pt)return s(),s=t,t})};return s=r(function(t){return t.hasValue?t.isInitial&&!u?(n=new o(t.value),Vt):(t.isInitial||a(),i=!0,n=new o(t.value),e(t)):(t.isEnd&&(c=a()),c!==Pt?e(t):void 0)}),u=!0,a(),s}}function F(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.unsubscribe=Tt.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 q(){return new C(g(jt,"never"),function(n){return n(d()),t})}function L(n){return new D(new b(jt,"constant",[n]),function(r){return r(p(n)),r(d()),t})}function j(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return T(this,t,r,function(t){return w(new b(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})}function Q(t,n){this.obs=t,this.sync=n,this.queue=[]}function U(){Q.apply(this,arguments)}function z(t){Q.call(this,t,!0)}function R(){return Z(C,arguments)}function Y(){return Z(H,arguments)}function $(t){for(var n=t.length,r=[],e=[],i=0,u=[];i<n;){u[i]=t[i],u[i+1]=t[i+1];for(var o,s=Tt.toArray(t[i]),c=G(t[i+1]),f={f:c,ixs:[]},a=!1,h=0;h<s.length;h++){o=s[h];var p=Tt.indexOf(r,o);a||(a=Q.isTrigger(o)),p<0&&(r.push(o),p=r.length-1);for(var l,d=0;d<f.ixs.length;d++)l=f.ixs[d],l.index===p&&l.count++;f.ixs.push({index:p,count:1})}s.length>0&&e.push(f),i+=2}return[r,e,u]}function Z(t,n){if(0===n.length)return q();var r=$(n),e=r[0],i=r[1],u=r[2];if(!e.length)return q();e=Tt.map(Q.fromObservable,e);var o=Tt.any(e,function(t){return t.flatten})&&X(Tt.map(function(t){return t.obs},e)),s=new b(jt,"when",u),c=t(s,function(t){function n(t){for(var n=0;n<t.ixs.length;n++){var r=t.ixs[n];if(!e[r.index].hasAtLeast(r.count))return!1}return!0}function r(t){for(var n=0;n<t.ixs.length;n++){var r=t.ixs[n];if(!e[r.index].mayHave(r.count))return!0}}function u(t){return!t.source.flatten}function s(s){return function(h){function p(){return Bt.whenDoneWith(c,v)}function l(){if(!(f.length>0))return Vt;for(var r,o=Vt,s=f.pop(),c=0;c<i.length;c++)if(r=i[c],n(r)){for(var a=[],h=0;h<r.ixs.length;h++){var p=e[r.ixs[h].index].consume();a.push(p.value)}var d=r.f.apply(null,a);return o=t(s.e.apply(d)),f.length&&(f=Tt.filter(u,f)),o===Pt?o:l()}}function v(){var n=l();return a&&(Tt.all(e,J)||Tt.all(i,r))&&(n=Pt,t(d())),n===Pt&&h(),n}return s.subscribe(function(n){if(n.isEnd)a=!0,s.markEnded(),p();else if(n.isError)var r=t(n);else s.push(n),s.sync&&(f.push({source:s,e:n}),o||Bt.hasWaiters()?p():v());return r===Pt&&h(),r||Vt})}}var f=[],a=!1;return new F(function(){for(var t,n=[],r=0;r<e.length;r++)t=e[r],n.push(s(t));return n}()).unsubscribe});return c}function X(t){function n(t){if(Tt.contains(r,t))return!0;var e=t.internalDeps();return e.length?(r.push(t),Tt.any(e,n)):(r.push(t),!1)}var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return Tt.any(t,n)}function G(t){return Tt.isFunction(t)?t:Tt.always(t)}function J(t){return!t.sync||t.ended}function K(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return tt(n)}function tt(t,n){1===t.length&&_t(t[0])&&(t=t[0]);var r=function(){for(var n=[],r=0;r<t.length;r++)n.push(new z(t[r]));return n}(),e=function(t,r){return new C(t,r,null,n)};return w(new b(jt,"groupSimultaneous",t),Z(e,[r,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}]))}function nt(t){return w(new b(this,"awaiting",[t]),tt([this,t],qt).map(function(t){return 0===t[1].length}).toProperty(!1).skipDuplicates())}function rt(t){return _t(t[0])?t[0]:Array.prototype.slice.call(t)}function et(t){return Tt.isFunction(t[0])?[rt(Array.prototype.slice.call(t,1)),t[0]]:[rt(Array.prototype.slice.call(t,0,t.length-1)),Tt.last(t)]}function it(n){var r=new C(new b(jt,"once",[n]),function(e){return Bt.soonButNotYet(r,function(){e(v(n)),e(d())}),t});return r}function ut(t){return 1===t.length&&xt(t[0])?Tt.always(t[0]):A(t)}function ot(t){return xt(t)?t:it(t)}function st(t,n){var r=new C(g(t,"justInitValue"),function(n){var e=void 0,i=t.dispatcher.subscribe(function(t){return t.isEnd||(e=t),Pt});return Bt.whenDoneWith(r,function(){return void 0!==e&&null!==e&&n(e),n(d())}),i},null,qt);return r.concat(n,qt).toProperty()}function ct(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Tt.id;return new C(new b(jt,"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);_t(s)&&(null!=(t=Tt.last(s))?t._isEvent:void 0)||(s=[s]);for(var c,f=jt.more,a=0;a<s.length;a++)if(c=s[a],(f=r(c=v(c)))===jt.noMore||c.isEnd)return u(),f;return f});return i&&u(),u})}function ft(t,n){return w(new b(jt,"later",[t,n]),ct(function(r){var e=function(){return r([n,d()])},i=jt.scheduler.setTimeout(e,t);return function(){return jt.scheduler.clearTimeout(i)}}))}function at(){if(!(this instanceof at))return new at;this.unsubAll=Tt.bind(this.unsubAll,this),this.subscribeAll=Tt.bind(this.subscribeAll,this),this.guardedSink=Tt.bind(this.guardedSink,this),this.sink=void 0,this.subscriptions=[],this.ended=!1,C.call(this,new b(jt,"Bus",[]),this.subscribeAll)}function ht(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 _t(t)?[]:{}}function o(t,n){return function(e){var i=u(n);r(e,t,i),e.push(i)}}function s(t){if(xt(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(xt(n))p.push(n),h.push(e(t,p.length-1));else if(s(n)){var r=function(t){t.pop()};h.push(o(t,n)),a(n),h.push(r)}else h.push(i(t,n))}function f(n){for(var r=u(t),e=[r],i=0;i<h.length;i++)(0,h[i])(e,n);return r}function a(t){Tt.each(t,c)}var h=[],p=[],l=s(t)?(a(t),jt.combineAsArray(p).map(f)):jt.constant(t);return w(new b(jt,"combineTemplate",[t]),l)}function pt(n,r){var e,i=this;r=O(r);var u=n,o=!1,s=function(n){var s=!1,c=t,a=Vt,h=function(){s||(s=o=!0,(a=n(new f(u)))===Pt&&(c(),c=t))};return c=i.dispatcher.subscribe(function(t){if(t.hasValue){if(o&&t.isInitial)return Vt;t.isInitial||h(),s=o=!0;var e=u,i=r(e,t.value);return u=i,n(t.apply(i))}if(t.isEnd&&(a=h()),a!==Pt)return n(t)}),Bt.whenDoneWith(e,h),c};return e=new D(new b(this,"scan",[n,r]),s)}function lt(t){this.observable=t}function dt(t,n,r){var e=$t(t),i=e[0],u=e[1];return w(new b(jt,"fromEvent",[t,n]),ct(function(r){return Tt.isFunction(n)?(n(i.bind(t),r),function(){return n(u.bind(t),r)}):(i.call(t,n,r),function(){return u.call(t,n,r)})},r))}function vt(t,n){return w(new b(jt,"fromPoll",[t,n]),ct(function(n){var r=jt.scheduler.setInterval(n,t);return function(){return jt.scheduler.clearInterval(r)}},n))}function yt(t){return[t,d()]}function bt(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:yt;return w(new b(jt,"fromPromise",[t]),ct(function(r){var e=t.then(r,function(t){return r(new h(t))});return e&&"function"==typeof e.done&&e.done(),n?function(){if("function"==typeof t.abort)return t.abort()}:function(){}},r))}function gt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return w(new b(jt,"interval",[t,n]),vt(t,function(){return l(n)}))}function wt(){var t=rt(arguments);return t.length?new C(new b(jt,"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(d()):Vt;var u=n(e);return u===Pt&&i(),u})}};return new F(Tt.map(e,t)).unsubscribe}):q()}function mt(t,n){var r=0;return w(new b(jt,"repeatedly",[t,n]),vt(t,function(){return n[r++%n.length]}))}function Et(t){var n=0;return ct(function(r){function e(t){return t.isEnd?u?i():u=!0:o=r(t)}function i(){var i;for(u=!0;u&&o!==Pt;)i=t(n++),u=!1,i?s=i.subscribeInternal(e):r(d());return u=!0}var u=!1,o=Vt,s=function(){};return i(),function(){return s()}})}function St(t,n){var r=0;return w(new b(jt,"sequentially",[t,n]),vt(t,function(){var t=n[r++];return r<n.length?t:r===n.length?[t,d()]:d()}))}function At(t){return function(n){try{return it(t(n))}catch(t){return new h(t)}}}function kt(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]=Tt.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 w(new b(jt,"update",[t].concat(r)),R.apply(void 0,r).scan(t,function(t,n){return n(t)}))}var _t=Array.isArray||function(t){return t instanceof Array},xt=function(t){return t&&t._isObservable};e(o.prototype,{_isSome:!0,getOrElse:function(){return this.value},get:function(){return this.value},filter:function(t){return t(this.value)?new o(this.value):It},map:function(t){return new o(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 It={_isNone:!0,getOrElse:function(t){return t},filter:function(){return It},map:function(){return It},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},Mt=function(t){return t&&(t._isSome||t.isNone)?t:new o(t)},Tt={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 _t(t)?t:[t]},contains:function(t,n){return-1!==Tt.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]?arguments[1]:Tt.id,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]?arguments[1]:Tt.id,e=0;e<t.length;e++)if(n=t[e],r(n))return!0;return!1},without:function(t,n){return Tt.filter(function(n){return n!==t},n)},remove:function(t,n){var r=Tt.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 Tt.fold(n,[],function(n,r){return n.concat(t(r))})},cached:function(t){var n=It;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 Ot++,null==t?"undefined":Tt.isFunction(t)?"function":_t(t)?Ot>5?"[..]":"["+Tt.map(Tt.toString,t).toString()+"]":null!=(null!=t?t.toString:void 0)&&t.toString!==Object.prototype.toString?t.toString():"object"==typeof t?Ot>5?"{..}":"{"+function(){var i=[];for(n in t)e.call(t,n)&&(r=function(){try{return t[n]}catch(t){return t}}(),i.push(Tt.toString(n)+":"+Tt.toString(r)));return i}()+"}":t}finally{Ot--}}},Ot=0,Wt=0;s.prototype._isEvent=!0,s.prototype.isEvent=!0,s.prototype.isEnd=!1,s.prototype.isInitial=!1,s.prototype.isNext=!1,s.prototype.isError=!1,s.prototype.hasValue=!1,s.prototype.filter=function(){return!0},s.prototype.inspect=function(){return this.toString()},s.prototype.log=function(){return this.toString()},s.prototype.toNext=function(){return this},i(c,s),c.prototype.isNext=!0,c.prototype.hasValue=!0,c.prototype.fmap=function(t){return this.apply(t(this.value))},c.prototype.apply=function(t){return new c(t)},c.prototype.filter=function(t){return t(this.value)},c.prototype.toString=function(){return Tt.toString(this.value)},c.prototype.log=function(){return this.value},c.prototype._isNext=!0,i(f,c),f.prototype._isInitial=!0,f.prototype.isInitial=!0,f.prototype.isNext=!1,f.prototype.apply=function(t){return new f(t)},f.prototype.toNext=function(){return new c(this.value)},i(a,s),a.prototype.isEnd=!0,a.prototype.fmap=function(){return this},a.prototype.apply=function(){return this},a.prototype.toString=function(){return"<end>"},i(h,s),h.prototype.isError=!0,h.prototype.fmap=function(){return this},h.prototype.apply=function(){return this},h.prototype.toString=function(){return"<error> "+Tt.toString(this.error)};var Pt="<no-more>",Vt="<more>",Ht=[],Dt=function(t){return Ht.push(t)};e(b.prototype,{_isDesc:!0,deps:function(){return this.cached||(this.cached=m([this.context].concat(this.args))),this.cached},toString:function(){var t=Tt.map(Tt.toString,this.args);return Tt.toString(this.context)+"."+Tt.toString(this.method)+"("+t+")"}});var Ct={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()}},Bt=function(){function t(){return Tt.toString({rootEvent:v,processingAfters:E,waiterObs:y,waiters:b,aftersStack:g,aftersStackHeight:w,flushed:m})}function n(t){t<=w||(g[t-1]||(g[t-1]=[[],0]),w=t)}function r(){return null!==v}function e(t,n){v?s(t,n):jt.scheduler.setTimeout(n,0)}function i(t,r){if(!v&&!E)return r();n(1);for(var e=0;e<w-1&&!u(t,g[e][0]);)e++;g[e][0].push([t,r]),v||o()}function u(t,n){for(var r=0;r<n.length;r++)if(n[r][0].id==t.id)return!0;return!1}function o(){var t=w;if(t){var r=!E;E=!0;try{for(;w>=t;){var e=g[w-1];if(!e)throw new Error("Unexpected stack top: "+e);var i=e[0],u=e[1];if(!(u<i.length)){e[0]=[],e[1]=0;break}var o=i[u],s=o[1];e[1]++,n(w+1);var c=!1;try{for(s(),c=!0;w>t&&0==g[w-1][0].length;)w--}finally{c||(g=[],w=0)}}}finally{r&&(E=!1)}}}function s(t,n){if(v){var r=b[t.id];return void 0===r||null===r?(r=b[t.id]=[n],y.push(t)):r.push(n)}return n()}function c(){for(;y.length>0;)f(0,!0);m={}}function f(t,n){var r=y[t],e=r.id,i=b[e];y.splice(t,1),delete b[e],n&&y.length>0&&a(r);for(var u=0;u<i.length;u++)(0,i[u])()}function a(t){if(!m[t.id]){for(var n,r=t.internalDeps(),e=0;e<r.length;e++)if(n=r[e],a(n),b[n.id]){var i=Tt.indexOf(y,n);f(i,!1)}m[t.id]=!0}}function h(t,n,r,e){if(v)return r.apply(n,e);v=t;try{var i=r.apply(n,e);c()}finally{v=null,o()}return i}function p(){return v?v.id:void 0}function l(t,n){function r(){return e=!0,o()}var e=!1,u=!1,o=function(){return u=!0};return o=t.dispatcher.subscribe(function(u){return i(t,function(){if(!e){if(n(u)===Pt)return r()}})}),u&&o(),r}function d(){return y.length>0}var v=null,y=[],b={},g=[],w=0,m={},E=!1;return{toString:t,whenDoneWith:s,hasWaiters:d,inTransaction:h,currentEventId:p,wrappedSubscribe:l,afterTransaction:i,soonButNotYet:e,isInTransaction:r}}();E.prototype.hasSubscribers=function(){return this.subscriptions.length>0},E.prototype.removeSub=function(t){return this.subscriptions=Tt.without(t,this.subscriptions),this.subscriptions},E.prototype.push=function(t){return t.isEnd&&(this.ended=!0),Bt.inTransaction(t,this,this.pushIt,[t])},E.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)===Pt||t.isEnd)&&this.removeSub(i)}return!0}catch(t){throw this.pushing=!1,this.queue=[],t}},E.prototype.pushIt=function(t){if(this.pushing)return this.queue.push(t),Vt;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()?Vt:(this.unsubscribeFromSource(),Pt)}},E.prototype.handleEvent=function(t){return this._handleEvent?this._handleEvent(t):this.push(t)},E.prototype.unsubscribeFromSource=function(){this.unsubSrc&&this.unsubSrc(),this.unsubSrc=void 0},E.prototype.subscribe=function(n){var r;return this.ended?(n(d()),t):(r={sink:n},this.subscriptions.push(r),1===this.subscriptions.length&&(this.unsubSrc=this._subscribe(this.handleEvent)),function(t){return function(){if(t.removeSub(r),!t.hasSubscribers())return t.unsubscribeFromSource()}}(this))};var Nt=S(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 Tt.isFunction(t)?r.length?k(t,r):t:I(t)?x(t,r):Tt.always(t)}),Ft=0;e(P.prototype,{_isObservable:!0,subscribe:function(t){return Bt.wrappedSubscribe(this,t)},subscribeInternal:function(t){return this.dispatcher.subscribe(t)},onValue:function(){var t=A(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=A(arguments);return this.subscribe(function(n){if(n.isError)return t(n.error)})},onEnd:function(){var t=A(arguments);return this.subscribe(function(n){if(n.isEnd)return t()})},name:function(t){return this._name=t,this},withDescription:function(){return this.desc=g.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()}}),P.prototype.assign=P.prototype.onValue,P.prototype.forEach=P.prototype.onValue,P.prototype.inspect=P.prototype.toString,i(V,E),e(V.prototype,{push:function(t){return t.isEnd&&(this.propertyEnded=!0),t.hasValue&&(this.current=new o(t),this.currentValueRootId=Bt.currentEventId()),E.prototype.push.call(this,t)},maybeSubSource:function(n,r){return r===jt.noMore?t:this.propertyEnded?(n(d()),t):E.prototype.subscribe.call(this,n)},subscribe:function(t){var n=this,r=jt.more;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=Bt.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?(Bt.whenDoneWith(this.property,function(){if(n.currentValueRootId===i)return t(p(n.current.get().value))}),this.maybeSubSource(t,r)):(Bt.inTransaction(void 0,this,function(){return r=t(p(this.current.get().value))},[]),this.maybeSubSource(t,r))}return this.maybeSubSource(t,r)}}),i(D,P),e(D.prototype,{_isProperty:!0,changes:function(){var t=this;return new C(new b(this,"changes",[]),function(n){return t.dispatcher.subscribe(function(t){if(!t.isInitial)return n(t)})})},withHandler:function(t){return new D(new b(this,"withHandler",[t]),this.dispatcher.subscribe,t)},toProperty:function(){return this}});var qt={forceAsync:!1},Lt=g("Bacon","new EventStream",[]);i(C,P),e(C.prototype,{_isEventStream:!0,toProperty:function(t){var n=0===arguments.length?It:Mt(t),r=this.dispatcher;return new D(new b(this,"toProperty",[t]),N(n,function(t){return r.subscribe(t)}))},toEventStream:function(){return this},withHandler:function(t){return new C(new b(this,"withHandler",[t]),this.dispatcher.subscribe,t,qt)}}),e(F.prototype,{add:function(n){var r=this;if(!this.unsubscribed){var e=!1,i=t;this.starting.push(n);var u=function(){if(!r.unsubscribed)return e=!0,r.remove(i),Tt.remove(n,r.starting)};return i=n(this.unsubscribe,u),this.unsubscribed||e?i():this.subscriptions.push(i),Tt.remove(n,this.starting),i}},remove:function(t){if(!this.unsubscribed)return void 0!==Tt.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()}});var jt={toString:function(){return"Bacon"},_:Tt,Event:s,Next:c,Initial:f,Error:h,End:a,noMore:Pt,more:Vt,Desc:b,spy:Dt,UpdateBarrier:Bt,scheduler:Ct,Dispatcher:E,Observable:P,EventStream:C,Property:D,CompositeUnsubscribe:F,never:q,constant:L,version:"2.0.6"};jt.Bacon=jt,P.prototype.map=j,P.prototype.withStateMachine=function(t,n){var r=t;return w(new b(this,"withStateMachine",[t,n]),this.withHandler(function(t){var e=n(r,t),i=e[0],u=e[1];r=i;for(var o,s=Vt,c=0;c<u.length;c++)if(o=u[c],(s=this.push(o))===Pt)return s;return s}))};var Qt=function(t,n){return t===n},Ut=function(t){return void 0!==t&&null!==t&&t._isNone};P.prototype.skipDuplicates=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Qt;return w(new b(this,"skipDuplicates",[]),this.withStateMachine(It,function(n,r){return r.hasValue?r.isInitial||Ut(n)||!t(n.get(),r.value)?[new o(r.value),[r]]:[n,[]]:[n,[r]]}))},e(Q.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.queue[0]},push:function(t){this.queue=[t]},mayHave:function(){return!0},hasAtLeast:function(){return this.queue.length},flatten:!0}),i(U,Q),e(U.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(z,Q),e(z.prototype,{consume:function(){var t=this.queue;return this.queue=[],{value:t}},push:function(t){return this.queue.push(t.value)},hasAtLeast:function(){return!0}}),Q.isTrigger=function(t){return null!=t&&(t._isSource?t.sync:t._isEventStream)},Q.fromObservable=function(t){return null!=t&&t._isSource?t:null!=t&&t._isProperty?new Q(t,!1):new U(t,!0)},jt.when=R,jt.groupSimultaneous=K,P.prototype.awaiting=nt,jt.combineAsArray=function(){var t=rt(arguments);if(t.length){for(var n=[],r=0;r<t.length;r++){var e=xt(t[r])?t[r]:jt.constant(t[r]);n.push(new Q(e,!0))}return w(new jt.Desc(jt,"combineAsArray",t),Y(n,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}))}return L([])},jt.onValues=function(){return jt.combineAsArray(Array.prototype.slice.call(arguments,0,arguments.length-1)).onValues(arguments[arguments.length-1])},jt.combineWith=function(){var t=et(arguments),n=t[0],r=t[1];return w(new b(jt,"combineWith",[r].concat(n)),jt.combineAsArray(n).map(function(t){return r.apply(void 0,t)}))},P.prototype.combine=function(t,n){var r=O(n);return w(new b(this,"combine",[t,n]),jt.combineAsArray(this,t).map(function(t){return r(t[0],t[1])}))},P.prototype.not=function(){return w(new b(this,"not",[]),this.map(function(t){return!t}))},D.prototype.and=function(t){return w(new b(this,"and",[t]),this.combine(t,function(t,n){return t&&n}))},D.prototype.or=function(t){return w(new b(this,"or",[t]),this.combine(t,function(t,n){return t||n}))},C.prototype.bufferWithTime=function(t){return w(new b(this,"bufferWithTime",[t]),this.bufferWithTimeOrCount(t,Number.MAX_VALUE))},C.prototype.bufferWithCount=function(t){return w(new b(this,"bufferWithCount",[t]),this.bufferWithTimeOrCount(void 0,t))},C.prototype.bufferWithTimeOrCount=function(t,n){var r=function(r){return r.values.length===n?r.flush():void 0!==t?r.schedule():void 0};return w(new b(this,"bufferWithTimeOrCount",[t,n]),this.buffer(t,r,r))},C.prototype.buffer=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i={scheduled:null,end:void 0,values:[],flush:function(){if(this.scheduled&&(jt.scheduler.clearTimeout(this.scheduled),this.scheduled=null),this.values.length>0){var t=this.values;this.values=[];var n=this.push(l(t));if(null!=this.end)return this.push(this.end);if(n!==Pt)return e(this)}else if(null!=this.end)return this.push(this.end)},schedule:function(){var t=this;if(!this.scheduled)return this.scheduled=n(function(){return t.flush()})}},u=Vt;if(!Tt.isFunction(n)){var o=n;n=function(t){return jt.scheduler.setTimeout(t,o)}}return w(new b(this,"buffer",[]),this.withHandler(function(t){var n=this;return i.push=function(t){return n.push(t)},t.isError?u=this.push(t):t.isEnd?(i.end=t,i.scheduled||i.flush()):(i.values.push(t.value),r(i)),u}))},P.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 T(this,t,r,function(t){return w(new b(this,"filter",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):Vt}))})},jt.once=it,P.prototype.flatMap_=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this,e=[r],i=[],u=this._isProperty,o=u?H:C,s=!1,c=o(n.desc||new b(this,"flatMap_",arguments),function(e){var o=new F,c=[],f=function(n){if(u&&n.isInitial){if(s)return Vt;s=!0}var r=ot(t(n));return i.push(r),o.add(function(t,n){return r.dispatcher.subscribe(function(u){if(u.isEnd)return Tt.remove(r,i),a(),h(n),Pt;u=u.toNext();var o=e(u);return o===Pt&&t(),o})})},a=function(){var t=c.shift();if(t)return f(t)},h=function(t){if(t(),o.empty())return e(d())};return o.add(function(t,i){return r.dispatcher.subscribe(function(t){return t.isEnd?h(i):t.isError&&!n.mapError?e(t):n.firstOnly&&o.count()>1?Vt:o.unsubscribed?Pt:n.limit&&o.count()>n.limit?c.push(t):f(t)})}),o.unsubscribe});return c.internalDeps=function(){return i.length?e.concat(i):e},c};var zt=function(t){return function(n){return t(n.value)}};P.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];return this.flatMap_(zt(ut(r)),{limit:t,desc:new b(this,"flatMapWithConcurrencyLimit",[t].concat(r))})},P.prototype.flatMapConcat=function(){return w(new b(this,"flatMapConcat",Array.prototype.slice.call(arguments,0)),this.flatMapWithConcurrencyLimit.apply(this,[1].concat(Array.prototype.slice.call(arguments))))},C.prototype.concat=function(n,r){var e=this;return new C(new b(e,"concat",[n]),function(r){var i=t,u=e.dispatcher.subscribe(function(t){return t.isEnd?i=n.toEventStream().dispatcher.subscribe(r):r(t)});return function(){return u(),i()}},null,r)},D.prototype.concat=function(t){return st(this,this.changes().concat(t))},jt.concatAll=function(){var t=rt(arguments);return t.length?w(new b(jt,"concatAll",t),Tt.fold(Tt.tail(t),Tt.head(t).toEventStream(),function(t,n){return t.concat(n)})):q()},jt.fromBinder=ct,jt.later=ft,P.prototype.bufferingThrottle=function(t){return w(new b(this,"bufferingThrottle",[t]),this.flatMapConcat(function(n){return it(n).concat(ft(t).filter(!1))}))},D.prototype.bufferingThrottle=function(){return P.prototype.bufferingThrottle.apply(this,arguments).toProperty()},i(at,C),e(at.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(d());else{this.sink=t;for(var n,e=r(this.subscriptions),i=0;i<e.length;i++)n=e[i],this.subscribeInput(n)}return this.unsubAll},guardedSink:function(t){var n=this;return function(r){return r.isEnd?(n.unsubscribeInput(t),jt.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(d())},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(l(t))}finally{if(n&&this.pushQueue){for(var r=0;r<this.pushQueue.length;){var e=this.pushQueue[r];this.sink(l(e)),r++} | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):t.Bacon=n()}(this,function(){"use strict";function t(){}function n(t){return t}function r(t){return t.slice(0)}function e(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}function i(t,n){function r(){}var e={}.hasOwnProperty;r.prototype=n.prototype,t.prototype=new r;for(var i in n)e.call(n,i)&&(t[i]=n[i]);return t}function u(t){return"undefined"!=typeof Symbol&&Symbol[t]?Symbol[t]:"undefined"!=typeof Symbol&&"function"==typeof Symbol.for?Symbol[t]=Symbol.for(t):"@@"+t}function o(t){this.value=t}function s(){this.id=++Wt}function c(t){if(!(this instanceof c))return new c(t);s.call(this),this.value=t}function f(t){if(!(this instanceof f))return new f(t);c.call(this,t)}function a(){if(!(this instanceof a))return new a;s.call(this)}function h(t){if(!(this instanceof h))return new h(t);this.error=t,s.call(this)}function p(t){return new f(t)}function l(t){return new c(t)}function d(){return new a}function v(t){return t&&t._isEvent?t:l(t)}function y(t){if(Ht.length&&!y.running)try{y.running=!0,Ht.forEach(function(n){n(t)})}finally{delete y.running}}function b(t,n,r){this.context=t,this.method=n,this.args=r}function g(t,n){var r=t||n;if(r&&r._isDesc)return t||n;for(var e=arguments.length,i=Array(e>2?e-2:0),u=2;u<e;u++)i[u-2]=arguments[u];return new b(t,n,i)}function w(t,n){return n.desc=t,n}function m(t){return _t(t)?Tt.flatMap(m,t):xt(t)?[t]:(void 0!==t&&null!==t?t._isSource:void 0)?[t.obs]:[]}function E(t,n){this._subscribe=t,this._handleEvent=n,this.subscribe=Tt.bind(this.subscribe,this),this.handleEvent=Tt.bind(this.handleEvent,this),this.pushing=!1,this.ended=!1,this.prevError=void 0,this.unsubSrc=void 0,this.subscriptions=[],this.queue=[]}function S(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))}}function A(t){return t=Array.prototype.slice.call(t),Nt.apply(void 0,t)}function k(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))}}function _(t){return function(n){return function(r){if(void 0!==r&&null!==r){var e=r[n];return Tt.isFunction(e)?e.apply(r,t):e}}}}function x(t,n){var r=t.slice(1).split("."),e=Tt.map(_(n),r);return function(t){for(var n,r=0;r<e.length;r++)n=e[r],t=n(t);return t}}function I(t){return"string"==typeof t&&t.length>1&&"."===t.charAt(0)}function M(t,n){return Nt.apply(void 0,[t].concat(n))}function T(t,n,r,e){if(n&&n._isProperty){var i=n.sampledBy(t,function(t,n){return[t,n]});return e.call(i,function(t){return t[0]}).map(function(t){return t[1]})}return n=M(n,r),e.call(t,n)}function O(t){if(Tt.isFunction(t))return t;if(I(t)){var n=W(t);return function(t,r){return t[n](r)}}throw new Error("not a function or a field key: "+t)}function W(t){return t.slice(1)}function P(t){this.desc=t,this.id=++Ft,this.initialDesc=this.desc}function V(t,n,r){E.call(this,n,r),this.property=t,this.subscribe=Tt.bind(this.subscribe,this),this.current=It,this.currentValueRootId=void 0,this.propertyEnded=!1}function H(t,n){return new D(t,N(It,n))}function D(t,n,r){P.call(this,t),this.dispatcher=new V(this,n,r),y(this)}function C(t,n,r,e){if(!(this instanceof C))return new C(t,n,r);Tt.isFunction(t)&&(r=n,n=t,t=Lt),e!==qt&&(n=B(this,n)),P.call(this,t),this.dispatcher=new E(n,r),y(this)}function B(t,n){var r=!1;return function(e){function i(){var t=o;o=null;for(var n=0;n<t.length;n++){var r=t[n];e(r)}}var u=Bt.isInTransaction();r=!0;var o;try{return n(function(n){if(!r&&!o)return e(n);o?o.push(n):(o=[n],u?Bt.soonButNotYet(t,i):jt.scheduler.setTimeout(i,0))})}finally{r=!1}}}function N(n,r){return function(e){var i=!1,u=!1,s=t,c=Vt,a=function(){if(!i)return n.forEach(function(n){if(i=!0,(c=e(new f(n)))===Pt)return s(),s=t,t})};return s=r(function(t){return t.hasValue?t.isInitial&&!u?(n=new o(t.value),Vt):(t.isInitial||a(),i=!0,n=new o(t.value),e(t)):(t.isEnd&&(c=a()),c!==Pt?e(t):void 0)}),u=!0,a(),s}}function F(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.unsubscribe=Tt.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 q(){return new C(g(jt,"never"),function(n){return n(d()),t})}function L(n){return new D(new b(jt,"constant",[n]),function(r){return r(p(n)),r(d()),t})}function j(t){for(var n=arguments.length,r=Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];return T(this,t,r,function(t){return w(new b(this,"map",[t]),this.withHandler(function(n){return this.push(n.fmap(t))}))})}function Q(t,n){this.obs=t,this.sync=n,this.queue=[]}function U(){Q.apply(this,arguments)}function z(t){Q.call(this,t,!0)}function R(){return Z(C,arguments)}function Y(){return Z(H,arguments)}function $(t){for(var n=t.length,r=[],e=[],i=0,u=[];i<n;){u[i]=t[i],u[i+1]=t[i+1];for(var o,s=Tt.toArray(t[i]),c=G(t[i+1]),f={f:c,ixs:[]},a=!1,h=0;h<s.length;h++){o=s[h];var p=Tt.indexOf(r,o);a||(a=Q.isTrigger(o)),p<0&&(r.push(o),p=r.length-1);for(var l,d=0;d<f.ixs.length;d++)l=f.ixs[d],l.index===p&&l.count++;f.ixs.push({index:p,count:1})}s.length>0&&e.push(f),i+=2}return[r,e,u]}function Z(t,n){if(0===n.length)return q();var r=$(n),e=r[0],i=r[1],u=r[2];if(!e.length)return q();e=Tt.map(Q.fromObservable,e);var o=Tt.any(e,function(t){return t.flatten})&&X(Tt.map(function(t){return t.obs},e)),s=new b(jt,"when",u),c=t(s,function(t){function n(t){for(var n=0;n<t.ixs.length;n++){var r=t.ixs[n];if(!e[r.index].hasAtLeast(r.count))return!1}return!0}function r(t){for(var n=0;n<t.ixs.length;n++){var r=t.ixs[n];if(!e[r.index].mayHave(r.count))return!0}}function u(t){return!t.source.flatten}function s(s){return function(h){function p(){return Bt.whenDoneWith(c,v)}function l(){if(!(f.length>0))return Vt;for(var r,o=Vt,s=f.pop(),c=0;c<i.length;c++)if(r=i[c],n(r)){for(var a=[],h=0;h<r.ixs.length;h++){var p=e[r.ixs[h].index].consume();a.push(p.value)}var d=r.f.apply(null,a);return o=t(s.e.apply(d)),f.length&&(f=Tt.filter(u,f)),o===Pt?o:l()}}function v(){var n=l();return a&&(Tt.all(e,J)||Tt.all(i,r))&&(n=Pt,t(d())),n===Pt&&h(),n}return s.subscribe(function(n){if(n.isEnd)a=!0,s.markEnded(),p();else if(n.isError)var r=t(n);else s.push(n),s.sync&&(f.push({source:s,e:n}),o||Bt.hasWaiters()?p():v());return r===Pt&&h(),r||Vt})}}var f=[],a=!1;return new F(function(){for(var t,n=[],r=0;r<e.length;r++)t=e[r],n.push(s(t));return n}()).unsubscribe});return c}function X(t){function n(t){if(Tt.contains(r,t))return!0;var e=t.internalDeps();return e.length?(r.push(t),Tt.any(e,n)):(r.push(t),!1)}var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return Tt.any(t,n)}function G(t){return Tt.isFunction(t)?t:Tt.always(t)}function J(t){return!t.sync||t.ended}function K(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return tt(n)}function tt(t,n){1===t.length&&_t(t[0])&&(t=t[0]);var r=function(){for(var n=[],r=0;r<t.length;r++)n.push(new z(t[r]));return n}(),e=function(t,r){return new C(t,r,null,n)};return w(new b(jt,"groupSimultaneous",t),Z(e,[r,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}]))}function nt(t){return w(new b(this,"awaiting",[t]),tt([this,t],qt).map(function(t){return 0===t[1].length}).toProperty(!1).skipDuplicates())}function rt(t){return _t(t[0])?t[0]:Array.prototype.slice.call(t)}function et(t){return Tt.isFunction(t[0])?[rt(Array.prototype.slice.call(t,1)),t[0]]:[rt(Array.prototype.slice.call(t,0,t.length-1)),Tt.last(t)]}function it(n){var r=new C(new b(jt,"once",[n]),function(e){return Bt.soonButNotYet(r,function(){e(v(n)),e(d())}),t});return r}function ut(t){return 1===t.length&&xt(t[0])?Tt.always(t[0]):A(t)}function ot(t){return xt(t)?t:it(t)}function st(t,n){var r=new C(g(t,"justInitValue"),function(n){var e=void 0,i=t.dispatcher.subscribe(function(t){return t.isEnd||(e=t),Pt});return Bt.whenDoneWith(r,function(){return void 0!==e&&null!==e&&n(e),n(d())}),i},null,qt);return r.concat(n,qt).toProperty()}function ct(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Tt.id;return new C(new b(jt,"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);_t(s)&&(null!=(t=Tt.last(s))?t._isEvent:void 0)||(s=[s]);for(var c,f=jt.more,a=0;a<s.length;a++)if(c=s[a],(f=r(c=v(c)))===jt.noMore||c.isEnd)return u(),f;return f});return i&&u(),u})}function ft(t,n){return w(new b(jt,"later",[t,n]),ct(function(r){var e=function(){return r([n,d()])},i=jt.scheduler.setTimeout(e,t);return function(){return jt.scheduler.clearTimeout(i)}}))}function at(){if(!(this instanceof at))return new at;this.unsubAll=Tt.bind(this.unsubAll,this),this.subscribeAll=Tt.bind(this.subscribeAll,this),this.guardedSink=Tt.bind(this.guardedSink,this),this.sink=void 0,this.subscriptions=[],this.ended=!1,C.call(this,new b(jt,"Bus",[]),this.subscribeAll)}function ht(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 _t(t)?[]:{}}function o(t,n){return function(e){var i=u(n);r(e,t,i),e.push(i)}}function s(t){if(xt(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(xt(n))p.push(n),h.push(e(t,p.length-1));else if(s(n)){var r=function(t){t.pop()};h.push(o(t,n)),a(n),h.push(r)}else h.push(i(t,n))}function f(n){for(var r=u(t),e=[r],i=0;i<h.length;i++)(0,h[i])(e,n);return r}function a(t){Tt.each(t,c)}var h=[],p=[],l=s(t)?(a(t),jt.combineAsArray(p).map(f)):jt.constant(t);return w(new b(jt,"combineTemplate",[t]),l)}function pt(n,r){var e,i=this;r=O(r);var u=n,o=!1,s=function(n){var s=!1,c=t,a=Vt,h=function(){s||(s=o=!0,(a=n(new f(u)))===Pt&&(c(),c=t))};return c=i.dispatcher.subscribe(function(t){if(t.hasValue){if(o&&t.isInitial)return Vt;t.isInitial||h(),s=o=!0;var e=u,i=r(e,t.value);return u=i,n(t.apply(i))}if(t.isEnd&&(a=h()),a!==Pt)return n(t)}),Bt.whenDoneWith(e,h),c};return e=new D(new b(this,"scan",[n,r]),s)}function lt(t){this.observable=t}function dt(t,n,r){var e=$t(t),i=e[0],u=e[1];return w(new b(jt,"fromEvent",[t,n]),ct(function(r){return Tt.isFunction(n)?(n(i.bind(t),r),function(){return n(u.bind(t),r)}):(i.call(t,n,r),function(){return u.call(t,n,r)})},r))}function vt(t,n){return w(new b(jt,"fromPoll",[t,n]),ct(function(n){var r=jt.scheduler.setInterval(n,t);return function(){return jt.scheduler.clearInterval(r)}},n))}function yt(t){return[t,d()]}function bt(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:yt;return w(new b(jt,"fromPromise",[t]),ct(function(r){var e=t.then(r,function(t){return r(new h(t))});return e&&"function"==typeof e.done&&e.done(),n?function(){if("function"==typeof t.abort)return t.abort()}:function(){}},r))}function gt(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return w(new b(jt,"interval",[t,n]),vt(t,function(){return l(n)}))}function wt(){var t=rt(arguments);return t.length?new C(new b(jt,"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(d()):Vt;var u=n(e);return u===Pt&&i(),u})}};return new F(Tt.map(e,t)).unsubscribe}):q()}function mt(t,n){var r=0;return w(new b(jt,"repeatedly",[t,n]),vt(t,function(){return n[r++%n.length]}))}function Et(t){var n=0;return ct(function(r){function e(t){return t.isEnd?u?i():u=!0:o=r(t)}function i(){var i;for(u=!0;u&&o!==Pt;)i=t(n++),u=!1,i?s=i.subscribeInternal(e):r(d());return u=!0}var u=!1,o=Vt,s=function(){};return i(),function(){return s()}})}function St(t,n){var r=0;return w(new b(jt,"sequentially",[t,n]),vt(t,function(){var t=n[r++];return r<n.length?t:r===n.length?[t,d()]:d()}))}function At(t){return function(n){try{return it(t(n))}catch(t){return new h(t)}}}function kt(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]=Tt.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 w(new b(jt,"update",[t].concat(r)),R.apply(void 0,r).scan(t,function(t,n){return n(t)}))}var _t=Array.isArray||function(t){return t instanceof Array},xt=function(t){return t&&t._isObservable};e(o.prototype,{_isSome:!0,getOrElse:function(){return this.value},get:function(){return this.value},filter:function(t){return t(this.value)?new o(this.value):It},map:function(t){return new o(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 It={_isNone:!0,getOrElse:function(t){return t},filter:function(){return It},map:function(){return It},forEach:function(){},isDefined:!1,toArray:function(){return[]},inspect:function(){return"None"},toString:function(){return this.inspect()}},Mt=function(t){return t&&(t._isSome||t.isNone)?t:new o(t)},Tt={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 _t(t)?t:[t]},contains:function(t,n){return-1!==Tt.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]?arguments[1]:Tt.id,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]?arguments[1]:Tt.id,e=0;e<t.length;e++)if(n=t[e],r(n))return!0;return!1},without:function(t,n){return Tt.filter(function(n){return n!==t},n)},remove:function(t,n){var r=Tt.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 Tt.fold(n,[],function(n,r){return n.concat(t(r))})},cached:function(t){var n=It;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 Ot++,null==t?"undefined":Tt.isFunction(t)?"function":_t(t)?Ot>5?"[..]":"["+Tt.map(Tt.toString,t).toString()+"]":null!=(null!=t?t.toString:void 0)&&t.toString!==Object.prototype.toString?t.toString():"object"==typeof t?Ot>5?"{..}":"{"+function(){var i=[];for(n in t)e.call(t,n)&&(r=function(){try{return t[n]}catch(t){return t}}(),i.push(Tt.toString(n)+":"+Tt.toString(r)));return i}()+"}":t}finally{Ot--}}},Ot=0,Wt=0;s.prototype._isEvent=!0,s.prototype.isEvent=!0,s.prototype.isEnd=!1,s.prototype.isInitial=!1,s.prototype.isNext=!1,s.prototype.isError=!1,s.prototype.hasValue=!1,s.prototype.filter=function(){return!0},s.prototype.inspect=function(){return this.toString()},s.prototype.log=function(){return this.toString()},s.prototype.toNext=function(){return this},i(c,s),c.prototype.isNext=!0,c.prototype.hasValue=!0,c.prototype.fmap=function(t){return this.apply(t(this.value))},c.prototype.apply=function(t){return new c(t)},c.prototype.filter=function(t){return t(this.value)},c.prototype.toString=function(){return Tt.toString(this.value)},c.prototype.log=function(){return this.value},c.prototype._isNext=!0,i(f,c),f.prototype._isInitial=!0,f.prototype.isInitial=!0,f.prototype.isNext=!1,f.prototype.apply=function(t){return new f(t)},f.prototype.toNext=function(){return new c(this.value)},i(a,s),a.prototype.isEnd=!0,a.prototype.fmap=function(){return this},a.prototype.apply=function(){return this},a.prototype.toString=function(){return"<end>"},i(h,s),h.prototype.isError=!0,h.prototype.fmap=function(){return this},h.prototype.apply=function(){return this},h.prototype.toString=function(){return"<error> "+Tt.toString(this.error)};var Pt="<no-more>",Vt="<more>",Ht=[],Dt=function(t){return Ht.push(t)};e(b.prototype,{_isDesc:!0,deps:function(){return this.cached||(this.cached=m([this.context].concat(this.args))),this.cached},toString:function(){var t=Tt.map(Tt.toString,this.args);return Tt.toString(this.context)+"."+Tt.toString(this.method)+"("+t+")"}});var Ct={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()}},Bt=function(){function t(){return Tt.toString({rootEvent:v,processingAfters:E,waiterObs:y,waiters:b,aftersStack:g,aftersStackHeight:w,flushed:m})}function n(t){t<=w||(g[t-1]||(g[t-1]=[[],0]),w=t)}function r(){return null!==v}function e(t,n){v?s(t,n):jt.scheduler.setTimeout(n,0)}function i(t,r){if(!v&&!E)return r();n(1);for(var e=0;e<w-1&&!u(t,g[e][0]);)e++;g[e][0].push([t,r]),v||o()}function u(t,n){for(var r=0;r<n.length;r++)if(n[r][0].id==t.id)return!0;return!1}function o(){var t=w;if(t){var r=!E;E=!0;try{for(;w>=t;){var e=g[w-1];if(!e)throw new Error("Unexpected stack top: "+e);var i=e[0],u=e[1];if(!(u<i.length)){e[0]=[],e[1]=0;break}var o=i[u],s=o[1];e[1]++,n(w+1);var c=!1;try{for(s(),c=!0;w>t&&0==g[w-1][0].length;)w--}finally{c||(g=[],w=0)}}}finally{r&&(E=!1)}}}function s(t,n){if(v){var r=b[t.id];return void 0===r||null===r?(r=b[t.id]=[n],y.push(t)):r.push(n)}return n()}function c(){for(;y.length>0;)f(0,!0);m={}}function f(t,n){var r=y[t],e=r.id,i=b[e];y.splice(t,1),delete b[e],n&&y.length>0&&a(r);for(var u=0;u<i.length;u++)(0,i[u])()}function a(t){if(!m[t.id]){for(var n,r=t.internalDeps(),e=0;e<r.length;e++)if(n=r[e],a(n),b[n.id]){var i=Tt.indexOf(y,n);f(i,!1)}m[t.id]=!0}}function h(t,n,r,e){if(v)return r.apply(n,e);v=t;try{var i=r.apply(n,e);c()}finally{v=null,o()}return i}function p(){return v?v.id:void 0}function l(t,n){function r(){return e=!0,o()}var e=!1,u=!1,o=function(){return u=!0};return o=t.dispatcher.subscribe(function(u){return i(t,function(){if(!e){if(n(u)===Pt)return r()}})}),u&&o(),r}function d(){return y.length>0}var v=null,y=[],b={},g=[],w=0,m={},E=!1;return{toString:t,whenDoneWith:s,hasWaiters:d,inTransaction:h,currentEventId:p,wrappedSubscribe:l,afterTransaction:i,soonButNotYet:e,isInTransaction:r}}();E.prototype.hasSubscribers=function(){return this.subscriptions.length>0},E.prototype.removeSub=function(t){return this.subscriptions=Tt.without(t,this.subscriptions),this.subscriptions},E.prototype.push=function(t){return t.isEnd&&(this.ended=!0),Bt.inTransaction(t,this,this.pushIt,[t])},E.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)===Pt||t.isEnd)&&this.removeSub(i)}return!0}catch(t){throw this.pushing=!1,this.queue=[],t}},E.prototype.pushIt=function(t){if(this.pushing)return this.queue.push(t),Vt;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()?Vt:(this.unsubscribeFromSource(),Pt)}},E.prototype.handleEvent=function(t){return this._handleEvent?this._handleEvent(t):this.push(t)},E.prototype.unsubscribeFromSource=function(){this.unsubSrc&&this.unsubSrc(),this.unsubSrc=void 0},E.prototype.subscribe=function(n){var r;return this.ended?(n(d()),t):(r={sink:n},this.subscriptions.push(r),1===this.subscriptions.length&&(this.unsubSrc=this._subscribe(this.handleEvent)),function(t){return function(){if(t.removeSub(r),!t.hasSubscribers())return t.unsubscribeFromSource()}}(this))};var Nt=S(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 Tt.isFunction(t)?r.length?k(t,r):t:I(t)?x(t,r):Tt.always(t)}),Ft=0;e(P.prototype,{_isObservable:!0,subscribe:function(t){return Bt.wrappedSubscribe(this,t)},subscribeInternal:function(t){return this.dispatcher.subscribe(t)},onValue:function(){var t=A(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=A(arguments);return this.subscribe(function(n){if(n.isError)return t(n.error)})},onEnd:function(){var t=A(arguments);return this.subscribe(function(n){if(n.isEnd)return t()})},name:function(t){return this._name=t,this},withDescription:function(){return this.desc=g.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()}}),P.prototype.assign=P.prototype.onValue,P.prototype.forEach=P.prototype.onValue,P.prototype.inspect=P.prototype.toString,i(V,E),e(V.prototype,{push:function(t){return t.isEnd&&(this.propertyEnded=!0),t.hasValue&&(this.current=new o(t),this.currentValueRootId=Bt.currentEventId()),E.prototype.push.call(this,t)},maybeSubSource:function(n,r){return r===jt.noMore?t:this.propertyEnded?(n(d()),t):E.prototype.subscribe.call(this,n)},subscribe:function(t){var n=this,r=jt.more;if(this.current.isDefined&&(this.hasSubscribers()||this.propertyEnded)){var e=Bt.currentEventId(),i=this.currentValueRootId;return!this.propertyEnded&&i&&e&&e!==i?(Bt.whenDoneWith(this.property,function(){if(n.currentValueRootId===i)return t(p(n.current.get().value))}),this.maybeSubSource(t,r)):(Bt.inTransaction(void 0,this,function(){return r=t(p(this.current.get().value))},[]),this.maybeSubSource(t,r))}return this.maybeSubSource(t,r)}}),i(D,P),e(D.prototype,{_isProperty:!0,changes:function(){var t=this;return new C(new b(this,"changes",[]),function(n){return t.dispatcher.subscribe(function(t){if(!t.isInitial)return n(t)})})},withHandler:function(t){return new D(new b(this,"withHandler",[t]),this.dispatcher.subscribe,t)},toProperty:function(){return this}});var qt={forceAsync:!1},Lt=g("Bacon","new EventStream",[]);i(C,P),e(C.prototype,{_isEventStream:!0,toProperty:function(t){var n=0===arguments.length?It:Mt(t),r=this.dispatcher;return new D(new b(this,"toProperty",[t]),N(n,function(t){return r.subscribe(t)}))},toEventStream:function(){return this},withHandler:function(t){return new C(new b(this,"withHandler",[t]),this.dispatcher.subscribe,t,qt)}}),e(F.prototype,{add:function(n){var r=this;if(!this.unsubscribed){var e=!1,i=t;this.starting.push(n);var u=function(){if(!r.unsubscribed)return e=!0,r.remove(i),Tt.remove(n,r.starting)};return i=n(this.unsubscribe,u),this.unsubscribed||e?i():this.subscriptions.push(i),Tt.remove(n,this.starting),i}},remove:function(t){if(!this.unsubscribed)return void 0!==Tt.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()}});var jt={toString:function(){return"Bacon"},_:Tt,Event:s,Next:c,Initial:f,Error:h,End:a,noMore:Pt,more:Vt,Desc:b,spy:Dt,UpdateBarrier:Bt,scheduler:Ct,Dispatcher:E,Observable:P,EventStream:C,Property:D,CompositeUnsubscribe:F,never:q,constant:L,version:"2.0.7"};jt.Bacon=jt,P.prototype.map=j,P.prototype.withStateMachine=function(t,n){var r=t;return w(new b(this,"withStateMachine",[t,n]),this.withHandler(function(t){var e=n(r,t),i=e[0],u=e[1];r=i;for(var o,s=Vt,c=0;c<u.length;c++)if(o=u[c],(s=this.push(o))===Pt)return s;return s}))};var Qt=function(t,n){return t===n},Ut=function(t){return void 0!==t&&null!==t&&t._isNone};P.prototype.skipDuplicates=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Qt;return w(new b(this,"skipDuplicates",[]),this.withStateMachine(It,function(n,r){return r.hasValue?r.isInitial||Ut(n)||!t(n.get(),r.value)?[new o(r.value),[r]]:[n,[]]:[n,[r]]}))},e(Q.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.queue[0]},push:function(t){this.queue=[t]},mayHave:function(){return!0},hasAtLeast:function(){return this.queue.length},flatten:!0}),i(U,Q),e(U.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(z,Q),e(z.prototype,{consume:function(){var t=this.queue;return this.queue=[],{value:t}},push:function(t){return this.queue.push(t.value)},hasAtLeast:function(){return!0}}),Q.isTrigger=function(t){return null!=t&&(t._isSource?t.sync:t._isEventStream)},Q.fromObservable=function(t){return null!=t&&t._isSource?t:null!=t&&t._isProperty?new Q(t,!1):new U(t,!0)},jt.when=R,jt.groupSimultaneous=K,P.prototype.awaiting=nt,jt.combineAsArray=function(){var t=rt(arguments);if(t.length){for(var n=[],r=0;r<t.length;r++){var e=xt(t[r])?t[r]:jt.constant(t[r]);n.push(new Q(e,!0))}return w(new jt.Desc(jt,"combineAsArray",t),Y(n,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}))}return L([])},jt.onValues=function(){return jt.combineAsArray(Array.prototype.slice.call(arguments,0,arguments.length-1)).onValues(arguments[arguments.length-1])},jt.combineWith=function(){var t=et(arguments),n=t[0],r=t[1];return w(new b(jt,"combineWith",[r].concat(n)),jt.combineAsArray(n).map(function(t){return r.apply(void 0,t)}))},P.prototype.combine=function(t,n){var r=O(n);return w(new b(this,"combine",[t,n]),jt.combineAsArray(this,t).map(function(t){return r(t[0],t[1])}))},P.prototype.not=function(){return w(new b(this,"not",[]),this.map(function(t){return!t}))},D.prototype.and=function(t){return w(new b(this,"and",[t]),this.combine(t,function(t,n){return t&&n}))},D.prototype.or=function(t){return w(new b(this,"or",[t]),this.combine(t,function(t,n){return t||n}))},C.prototype.bufferWithTime=function(t){return w(new b(this,"bufferWithTime",[t]),this.bufferWithTimeOrCount(t,Number.MAX_VALUE))},C.prototype.bufferWithCount=function(t){return w(new b(this,"bufferWithCount",[t]),this.bufferWithTimeOrCount(void 0,t))},C.prototype.bufferWithTimeOrCount=function(t,n){var r=function(r){return r.values.length===n?r.flush():void 0!==t?r.schedule():void 0};return w(new b(this,"bufferWithTimeOrCount",[t,n]),this.buffer(t,r,r))},C.prototype.buffer=function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,i={scheduled:null,end:void 0,values:[],flush:function(){if(this.scheduled&&(jt.scheduler.clearTimeout(this.scheduled),this.scheduled=null),this.values.length>0){var t=this.values;this.values=[];var n=this.push(l(t));if(null!=this.end)return this.push(this.end);if(n!==Pt)return e(this)}else if(null!=this.end)return this.push(this.end)},schedule:function(){var t=this;if(!this.scheduled)return this.scheduled=n(function(){return t.flush()})}},u=Vt;if(!Tt.isFunction(n)){var o=n;n=function(t){return jt.scheduler.setTimeout(t,o)}}return w(new b(this,"buffer",[]),this.withHandler(function(t){var n=this;return i.push=function(t){return n.push(t)},t.isError?u=this.push(t):t.isEnd?(i.end=t,i.scheduled||i.flush()):(i.values.push(t.value),r(i)),u}))},P.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 T(this,t,r,function(t){return w(new b(this,"filter",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):Vt}))})},jt.once=it,P.prototype.flatMap_=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=this,e=[r],i=[],u=this._isProperty,o=u?H:C,s=!1,c=o(n.desc||new b(this,"flatMap_",arguments),function(e){var o=new F,c=[],f=function(n){if(u&&n.isInitial){if(s)return Vt;s=!0}var r=ot(t(n));return i.push(r),o.add(function(t,n){return r.dispatcher.subscribe(function(u){if(u.isEnd)return Tt.remove(r,i),a(),h(n),Pt;u=u.toNext();var o=e(u);return o===Pt&&t(),o})})},a=function(){var t=c.shift();if(t)return f(t)},h=function(t){if(t(),o.empty())return e(d())};return o.add(function(t,i){return r.dispatcher.subscribe(function(t){return t.isEnd?h(i):t.isError&&!n.mapError?e(t):n.firstOnly&&o.count()>1?Vt:o.unsubscribed?Pt:n.limit&&o.count()>n.limit?c.push(t):f(t)})}),o.unsubscribe});return c.internalDeps=function(){return i.length?e.concat(i):e},c};var zt=function(t){return function(n){return t(n.value)}};P.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];return this.flatMap_(zt(ut(r)),{limit:t,desc:new b(this,"flatMapWithConcurrencyLimit",[t].concat(r))})},P.prototype.flatMapConcat=function(){return w(new b(this,"flatMapConcat",Array.prototype.slice.call(arguments,0)),this.flatMapWithConcurrencyLimit.apply(this,[1].concat(Array.prototype.slice.call(arguments))))},C.prototype.concat=function(n,r){var e=this;return new C(new b(e,"concat",[n]),function(r){var i=t,u=e.dispatcher.subscribe(function(t){return t.isEnd?i=n.toEventStream().dispatcher.subscribe(r):r(t)});return function(){return u(),i()}},null,r)},D.prototype.concat=function(t){return st(this,this.changes().concat(t))},jt.concatAll=function(){var t=rt(arguments);return t.length?w(new b(jt,"concatAll",t),Tt.fold(Tt.tail(t),Tt.head(t).toEventStream(),function(t,n){return t.concat(n)})):q()},jt.fromBinder=ct,jt.later=ft,P.prototype.bufferingThrottle=function(t){return w(new b(this,"bufferingThrottle",[t]),this.flatMapConcat(function(n){return it(n).concat(ft(t).filter(!1))}))},D.prototype.bufferingThrottle=function(){return P.prototype.bufferingThrottle.apply(this,arguments).toProperty()},i(at,C),e(at.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(d());else{this.sink=t;for(var n,e=r(this.subscriptions),i=0;i<e.length;i++)n=e[i],this.subscribeInput(n)}return this.unsubAll},guardedSink:function(t){var n=this;return function(r){return r.isEnd?(n.unsubscribeInput(t),jt.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(d())},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(l(t))}finally{if(n&&this.pushQueue){for(var r=0;r<this.pushQueue.length;){var e=this.pushQueue[r];this.sink(l(e)),r++} | ||
this.pushQueue=null}this.pushing=!1}}},error:function(t){if("function"==typeof this.sink)return this.sink(new h(t))}}),jt.Bus=at,P.prototype.flatMap=function(){return this.flatMap_(zt(ut(arguments)),{desc:new b(this,"flatMap",arguments)})};var Rt=function(t,n){return S(function(r){for(var e=k(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 w(new b(jt,t,[r].concat(u)),jt.combineAsArray(u).flatMap(e).changes())})};jt.fromCallback=Rt("fromCallback",function(n){for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;i<r;i++)e[i-1]=arguments[i];return ct(function(r){return M(n,e)(r),t},function(t){return[t,d()]})}),jt.fromNodeCallback=Rt("fromNodeCallback",function(n){for(var r=arguments.length,e=Array(r>1?r-1:0),i=1;i<r;i++)e[i-1]=arguments[i];return ct(function(r){return M(n,e)(r),t},function(t,n){return t?[new h(t),d()]:[n,d()]})}),jt.combineTemplate=ht,P.prototype.mapEnd=function(){var t=A(arguments);return w(new b(this,"mapEnd",[t]),this.withHandler(function(n){return n.isEnd?(this.push(l(t(n))),this.push(d()),Pt):this.push(n)}))},P.prototype.skipErrors=function(){return w(new b(this,"skipErrors",[]),this.withHandler(function(t){return t.isError?Vt:this.push(t)}))},P.prototype.takeUntil=function(t){var n={},r=tt([this.mapEnd(n),t.skipErrors()],qt);this instanceof D&&(r=r.toProperty());var e=r.withHandler(function(t){if(t.hasValue){var r=t.value,e=r[0];if(r[1].length)return this.push(d());for(var i,u=Vt,o=0;o<e.length;o++)i=e[o],u=i===n?this.push(d()):this.push(l(i));return u}return this.push(t)});return w(new b(this,"takeUntil",[t]),e)},P.prototype.flatMapLatest=function(){var t=ut(arguments),n=this._isProperty?this.toEventStream(qt):this,r=n.flatMap(function(r){return ot(t(r)).takeUntil(n)});return this._isProperty&&(r=r.toProperty()),w(new b(this,"flatMapLatest",[t]),r)},D.prototype.delayChanges=function(t,n){return w(t,st(this,n(this.changes())))},C.prototype.delayChanges=function(t,n){return w(t,n(this))},P.prototype.delay=function(t){return this.delayChanges(new b(this,"delay",[t]),function(n){return n.flatMap(function(n){return ft(t,n)})})},jt.Observable.prototype.debounce=function(t){return this.delayChanges(new b(this,"debounce",[t]),function(n){return n.flatMapLatest(function(n){return jt.later(t,n)})})},jt.Observable.prototype.debounceImmediate=function(t){return this.delayChanges(new b(this,"debounceImmediate",[t]),function(n){return n.flatMapFirst(function(n){return jt.once(n).concat(jt.later(t).filter(!1))})})},P.prototype.decode=function(t){return w(new b(this,"decode",[t]),this.combine(ht(t),function(t,n){return n[t]}))},P.prototype.scan=pt,P.prototype.diff=function(t,n){return n=O(n),w(new b(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]}))},P.prototype.doAction=function(){var t=A(arguments);return w(new b(this,"doAction",[t]),this.withHandler(function(n){return n.hasValue&&t(n.value),this.push(n)}))},P.prototype.doEnd=function(){var t=A(arguments);return w(new b(this,"doEnd",[t]),this.withHandler(function(n){return n.isEnd&&t(),this.push(n)}))},P.prototype.doError=function(){var t=A(arguments);return w(new b(this,"doError",[t]),this.withHandler(function(n){return n.isError&&t(n.error),this.push(n)}))},P.prototype.doLog=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return w(new b(this,"doLog",n),this.withHandler(function(t){if("undefined"!=typeof console&&null!==console&&"function"==typeof console.log){var r;(r=console).log.apply(r,n.concat([t.log()]))}return this.push(t)}))},P.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 T(this,t,r,function(t){return w(new b(this,"endOnError",[]),this.withHandler(function(n){return n.isError&&t(n.error)?(this.push(n),this.push(d())):this.push(n)}))})},P.prototype.errors=function(){return w(new b(this,"errors",[]),this.filter(function(){return!1}))},lt.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},lt.prototype[u("observable")]=function(){return this},P.prototype.toESObservable=function(){return new lt(this)},P.prototype[u("observable")]=P.prototype.toESObservable,P.prototype.take=function(t){return t<=0?q():w(new b(this,"take",[t]),this.withHandler(function(n){return n.hasValue?(t--,t>0?this.push(n):(0===t&&this.push(n),this.push(d()),Pt)):this.push(n)}))},P.prototype.first=function(){return w(new b(this,"first",[]),this.take(1))},P.prototype.flatMapEvent=function(){return this.flatMap_(ut(arguments),{mapError:!0,desc:new b(this,"flatMapEvent",arguments)})},P.prototype.flatMapFirst=function(){return this.flatMap_(zt(ut(arguments)),{firstOnly:!0,desc:new b(this,"flatMapFirst",arguments)})},P.prototype.mapError=function(){var t=A(arguments);return w(new b(this,"mapError",[t]),this.withHandler(function(n){return n.isError?this.push(l(t(n.error))):this.push(n)}))},P.prototype.flatMapError=function(t){return this.flatMap_(function(n){return n instanceof h?t(n.error):n},{mapError:!0,desc:new b(this,"flatMapError",[t])})},P.prototype.flatScan=function(t,n){var r=t;return this.flatMapConcat(function(t){return ot(n(r,t)).doAction(function(t){return r=t})}).toProperty(t)},C.prototype.sampledBy=function(t,n){return w(new b(this,"sampledBy",[t,n]),this.toProperty().sampledBy(t,n))},D.prototype.sampledBy=function(t,n){n=void 0!==n&&null!==n?O(n):jt._.id;var r=new Q(this,!1),e=new Q(t,!0),i=t._isProperty?Y:R,u=i([r,e],n);return w(new b(this,"sampledBy",[t,n]),u)},D.prototype.sample=function(t){return w(new b(this,"sample",[t]),this.sampledBy(jt.interval(t,{})))},P.prototype.map=function(t){return t&&t._isProperty?t.sampledBy(this,n):j.apply(this,arguments)},P.prototype.fold=function(t,n){return w(new b(this,"fold",[t,n]),this.scan(t,n).sampledBy(this.filter(!1).mapEnd().toProperty()))},P.prototype.reduce=P.prototype.fold,jt.fromArray=function(t){if(t.length){var n=0,r=new C(new b(jt,"fromArray",[t]),function(e){function i(){if(c=!0,!s){for(s=!0;c;)if(c=!1,o!==Pt&&!u){var f=t[n++];o=e(v(f)),o!==Pt&&(n===t.length?e(d()):Bt.afterTransaction(r,i))}return s=!1}}var u=!1,o=Vt,s=!1,c=!1;return Bt.soonButNotYet(r,i),function(){return u=!0}});return r}return w(new b(jt,"fromArray",t),q())},jt.fromESObservable=function(t){var n;return n=t[u("observable")]?t[u("observable")]():t,new C(new b(jt,"fromESObservable",[n]),function(t){var r=n.subscribe({error:function(){t(new jt.Error),t(new jt.End)},next:function(n){t(new jt.Next(n,!0))},complete:function(){t(new jt.End)}});return r.unsubscribe?function(){r.unsubscribe()}:r})};var Yt=[["addEventListener","removeEventListener"],["addListener","removeListener"],["on","off"],["bind","unbind"]],$t=function(t){for(var n,r=0;r<Yt.length;r++){n=Yt[r];var e=[t[n[0]],t[n[1]]];if(e[0]&&e[1])return e}for(var i=0;i<Yt.length;i++){n=Yt[i];var u=t[n[0]];if(u)return[u,function(){}]}throw new Error("No suitable event methods in "+t)};return jt.fromEvent=jt.fromEventTarget=dt,jt.fromPoll=vt,jt.fromPromise=bt,P.prototype.groupBy=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Tt.id,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=it(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})},C.prototype.holdWhen=function(t){var n=!1,r=[],e=this,i=!1;return new C(new b(this,"holdWhen",[t]),function(u){var o=new F,s=!1,c=function(t){if("function"==typeof t&&t(),o.empty()&&s)return u(d())};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(l(t)));return i&&(n.push(u(d())),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})},jt.interval=gt,jt.$={},jt.$.asEventStream=function(t,n,r){var e=this;return Tt.isFunction(n)&&(r=n,n=void 0),w(new b(this.selector||this,"asEventStream",[t]),ct(function(r){return e.on(t,n,r),function(){return e.off(t,n,r)}},r))},"undefined"!=typeof jQuery&&jQuery&&(jQuery.fn.asEventStream=jt.$.asEventStream),"undefined"!=typeof Zepto&&Zepto&&(Zepto.fn.asEventStream=jt.$.asEventStream),P.prototype.last=function(){var t;return w(new b(this,"last",[]),this.withHandler(function(n){if(n.isEnd)return t&&this.push(t),this.push(d()),Pt;t=n}))},P.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){if("undefined"!=typeof console&&"function"==typeof console.log){var r;(r=console).log.apply(r,n.concat([t.log()]))}}),this},C.prototype.merge=function(t){return w(new b(this,"merge",[t]),wt(this,t))},jt.mergeAll=wt,jt.repeatedly=mt,jt.repeat=Et,jt.retry=function(t){if(!Tt.isFunction(t.source))throw new Error("'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 w(new b(jt,"retry",[t]),jt.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 f={error:s.error,retriesDone:e},a=ft(i(f)).filter(!1);return e++,a.concat(jt.once().flatMap(c))}return c()}))},jt.sequentially=St,P.prototype.skip=function(t){return w(new b(this,"skip",[t]),this.withHandler(function(n){return n.hasValue&&t>0?(t--,Vt):this.push(n)}))},C.prototype.skipUntil=function(t){var n=t.take(1).map(!0).toProperty(!1);return w(new b(this,"skipUntil",[t]),this.filter(n))},C.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 T(this,t,e,function(t){return w(new b(this,"skipWhile",[t]),this.withHandler(function(r){return!n&&r.hasValue&&t(r.value)?Vt:(r.hasValue&&(n=!0),this.push(r))}))})},D.prototype.startWith=function(t){return w(new b(this,"startWith",[t]),this.scan(t,function(t,n){return n}))},C.prototype.startWith=function(t){return w(new b(this,"startWith",[t]),it(t).concat(this))},P.prototype.slidingWindow=function(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return w(new b(this,"slidingWindow",[t,n]),this.scan([],function(n,r){return n.concat([r]).slice(-t)}).filter(function(t){return t.length>=n}))},P.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 T(this,t,r,function(t){return w(new b(this,"takeWhile",[t]),this.withHandler(function(n){return n.filter(t)?this.push(n):(this.push(d()),Pt)}))})},P.prototype.throttle=function(t){return this.delayChanges(new b(this,"throttle",[t]),function(n){return n.bufferWithTime(t).map(function(t){return t[t.length-1]})})},D.prototype.toEventStream=function(t){var n=this;return new C(new b(this,"toEventStream",[]),function(t){return n.dispatcher.subscribe(function(n){return t(n.toNext())})},null,t)},P.prototype.firstToPromise=function(t){var n=this;if("function"!=typeof t){if("function"!=typeof Promise)throw new Error("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),Pt})})},P.prototype.toPromise=function(t){return this.last().firstToPromise(t)},jt.try=At,jt.update=kt,jt.zipAsArray=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];var e=rt(n);return w(new b(jt,"zipAsArray",e),jt.zipWith(e,function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return n}))},jt.zipWith=function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];var e=et(n),i=e[0],u=e[1];return i=Tt.map(function(t){return t.toEventStream()},i),w(new b(jt,"zipWith",[u].concat(i)),jt.when(i,u))},P.prototype.zip=function(t,n){return w(new b(this,"zip",[t]),jt.zipWith([this,t],n||Array))},jt}); |
{ | ||
"name": "baconjs", | ||
"description": "A small functional reactive programming lib for JavaScript.", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"keywords": [ | ||
@@ -80,3 +80,3 @@ "bacon.js", | ||
"sinon": "^1.12.2", | ||
"uglify-js": "^2.4.16", | ||
"uglify-js": "^2.6", | ||
"when": "^3.6.4", | ||
@@ -97,3 +97,3 @@ "zen-observable": "^0.4.0" | ||
"prepublish": "npm run lint && npm run dist && npm run readme", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"browsertest-bundle": "browsertest/browserify", | ||
@@ -100,0 +100,0 @@ "browsertest-open": "open browsertest/mocha.runner.html", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
462340