(function(B){"object"===typeof exports&&"undefined"!==typeof module?module.exports=B():"function"===typeof define&&define.amd?define([],B):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).xstream=B()})(function(){return function d(e,h,f){function m(g,n){if(!h[g]){if(!e[g]){var p="function"==typeof require&&require;if(!n&&p)return p(g,!0);if(q)return q(g,!0);n=Error("Cannot find module '"+g+"'");throw n.code="MODULE_NOT_FOUND",n;}n=h[g]={exports:{}}; e[g][0].call(n.exports,function(c){var d=e[g][1][c];return m(d?d:c)},n,n.exports,d,e,h,f)}return h[g].exports}for(var q="function"==typeof require&&require,g=0;g=--this.ac){var b=this.out;b!==c&&b._c()}};return a}(),A=function(){function a(b,a,c){this.i=b;this.out=a;this.p=c;c.ils.push(this)}a.prototype._n=function(b){var a=this.p,l=this.out;l!==c&&a.up(b,this.i)&&(b=m(a.vals),l._n(b))};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c= function(){var b=this.p;b.out!==c&&0===--b.Nc&&b.out._c()};return a}(),u=function(){function a(b){this.type="combine";this.insArr=b;this.out=c;this.ils=[];this.Nc=this.Nn=0;this.vals=[]}a.prototype.up=function(b,a){var k=this.vals[a];k=this.Nn?k===c?--this.Nn:this.Nn:0;this.vals[a]=b;return 0===k};a.prototype._start=function(b){this.out=b;var a=this.insArr,l=this.Nc=this.Nn=a.length,d=this.vals=Array(l);if(0===l)b._n([]),b._c();else for(var e=0;e=this.max&&a._n(b)};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&b._c()};return a}(),J=function(){function a(b,a){this.out=b;this.op=a}a.prototype._n=function(){this.op.end()}; a.prototype._e=function(b){this.out._e(b)};a.prototype._c=function(){this.op.end()};return a}(),K=function(){function a(b,a){this.type="endWhen";this.ins=a;this.out=c;this.o=b;this.oil=v}a.prototype._start=function(b){this.out=b;this.o._add(this.oil=new J(b,this));this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.o._remove(this.oil);this.out=c;this.oil=v};a.prototype.end=function(){var b=this.out;b!==c&&b._c()};a.prototype._n=function(b){var a=this.out;a!==c&&a._n(b)}; a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){this.end()};return a}(),D=function(){function a(b,a){this.type="filter";this.ins=a;this.out=c;this.f=b}a.prototype._start=function(b){this.out=b;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c};a.prototype._n=function(b){var a=this.out;if(a!==c){var l=g(this,b,a);l!==c&&l&&a._n(b)}};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out; b!==c&&b._c()};return a}(),L=function(){function a(b,a){this.out=b;this.op=a}a.prototype._n=function(b){this.out._n(b)};a.prototype._e=function(b){this.out._e(b)};a.prototype._c=function(){this.op.inner=c;this.op.less()};return a}(),M=function(){function a(b){this.type="flatten";this.ins=b;this.out=c;this.open=!0;this.inner=c;this.il=v}a.prototype._start=function(b){this.out=b;this.open=!0;this.inner=c;this.il=v;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.inner!== c&&this.inner._remove(this.il);this.out=c;this.open=!0;this.inner=c;this.il=v};a.prototype.less=function(){var b=this.out;b!==c&&(this.open||this.inner!==c||b._c())};a.prototype._n=function(b){var a=this.out;if(a!==c){var l=this.inner,d=this.il;l!==c&&d!==v&&l._remove(d);(this.inner=b)._add(this.il=new L(a,this))}};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){this.open=!1;this.less()};return a}(),N=function(){function a(b,a,l){var k=this;this.type="fold";this.ins= l;this.out=c;this.f=function(a){return b(k.acc,a)};this.acc=this.seed=a}a.prototype._start=function(b){this.out=b;this.acc=this.seed;b._n(this.acc);this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c;this.acc=this.seed};a.prototype._n=function(b){var a=this.out;a!==c&&(b=g(this,b,a),b!==c&&a._n(this.acc=b))};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&b._c()};return a}(),O=function(){function a(b){this.type= "last";this.ins=b;this.out=c;this.has=!1;this.val=c}a.prototype._start=function(b){this.out=b;this.has=!1;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.val=this.out=c};a.prototype._n=function(b){this.has=!0;this.val=b};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&(this.has?(b._n(this.val),b._c()):b._e(Error("last() failed because input stream completed")))};return a}(),P=function(){function a(b,a){this.type= "map";this.ins=a;this.out=c;this.f=b}a.prototype._start=function(b){this.out=b;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c};a.prototype._n=function(b){var a=this.out;a!==c&&(b=g(this,b,a),b!==c&&a._n(b))};a.prototype._e=function(b){var a=this.out;a!==c&&a._e(b)};a.prototype._c=function(){var b=this.out;b!==c&&b._c()};return a}(),Q=function(){function a(b){this.type="remember";this.ins=b;this.out=c}a.prototype._start=function(b){this.out=b;this.ins._add(b)}; a.prototype._stop=function(){this.ins._remove(this.out);this.out=c};return a}(),R=function(){function a(b,a){this.type="replaceError";this.ins=a;this.out=c;this.f=b}a.prototype._start=function(b){this.out=b;this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this);this.out=c};a.prototype._n=function(b){var a=this.out;a!==c&&a._n(b)};a.prototype._e=function(b){var a=this.out;if(a!==c)try{this.ins._remove(this),(this.ins=this.f(b))._add(this)}catch(l){a._e(l)}};a.prototype._c=function(){var b= this.out;b!==c&&b._c()};return a}(),S=function(){function a(b,a){this.type="startWith";this.ins=b;this.out=c;this.val=a}a.prototype._start=function(b){this.out=b;this.out._n(this.val);this.ins._add(b)};a.prototype._stop=function(){this.ins._remove(this.out);this.out=c};return a}(),T=function(){function a(b,a){this.type="take";this.ins=a;this.out=c;this.max=b;this.taken=0}a.prototype._start=function(b){this.out=b;this.taken=0;0>=this.max?b._c():this.ins._add(this)};a.prototype._stop=function(){this.ins._remove(this); this.out=c};a.prototype._n=function(b){var a=this.out;if(a!==c){var l=++this.taken;l=d.length?(this._err=c,this._stopID=setTimeout(function(){return a._stopNow()})): 1===d.length&&this._pruneCycles())};a.prototype._pruneCycles=function(){this._hasNoSinks(this,[])&&this._remove(this._ils[0])};a.prototype._hasNoSinks=function(b,a){if(-1!==a.indexOf(b)||b.out===this)return!0;if(b.out&&b.out!==c)return this._hasNoSinks(b.out,a.concat(b));if(b._ils){for(var k=0,d=b._ils.length;k