vega-dataflow
Advanced tools
Comparing version 2.0.0-beta.9 to 2.0.0-beta.10
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-util"),require("vega-loader"),require("vega-statistics"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-loader","vega-statistics","d3-array"],e):e(t.vega=t.vega||{},t.vega,t.vega,t.vega,t.d3)}(this,function(t,e,i,n,r){"use strict";function a(t){var i=t||e.identity,n=[],r={};return n.add=function(t){var e=i(t);return r[e]||(r[e]=1,n.push(t)),n},n.remove=function(t){var e,a=i(t);return r[a]&&(r[a]=0,(e=n.indexOf(t))>=0&&n.splice(e,1)),n},n}function s(t){return t._id}function u(t,e){for(var i in t)"_id"!==i&&(e[i]=t[i]);return e}function o(t){var e=t===Object(t)?t:{data:t};return e._id||(e._id=++Vt),e}function l(t){return o(u(t,{}))}function d(t,e){return u(t,e)}function h(t,e){return e._id=t._id,e}function f(t){return t&&t.constructor===c}function c(){var t=[],i=[],n=[],r=[],a=[];return{constructor:c,insert:function(i){for(var n=e.array(i),r=0,a=n.length;r<a;++r)t.push(n[r]);return this},remove:function(t){for(var n=e.isFunction(t)?r:i,a=e.array(t),s=0,u=a.length;s<u;++s)n.push(a[s]);return this},modify:function(t,i,r){var s={field:i,value:e.constant(r)};return e.isFunction(t)?(s.filter=t,a.push(s)):(s.tuple=t,n.push(s)),this},encode:function(t,e){return n.push({tuple:t,field:e}),this},pulse:function(e,s){function u(t,i,n){n?t[i]=n(t):e.encode=i,l[t._id]=t}var l,d,h,f,c,m,p;for(d=0,h=t.length;d<h;++d)e.add.push(o(t[d]));for(l={},d=0,h=i.length;d<h;++d)m=i[d],l[m._id]=m;for(d=0,h=r.length;d<h;++d)c=r[d],s.forEach(function(t){c(t)&&(l[t._id]=t)});for(p in l)e.rem.push(l[p]);for(l={},d=0,h=n.length;d<h;++d)f=n[d],u(f.tuple,f.field,f.value),e.modifies(f.field);for(d=0,h=a.length;d<h;++d)f=a[d],c=f.filter,s.forEach(function(t){c(t)&&u(t,f.field,f.value)}),e.modifies(f.field);for(p in l)e.mod.push(l[p]);return e}}}function m(){Object.defineProperty(this,Bt,{writable:!0,value:{}})}function p(t,e){return(null!=e&&e>=0?e+":":"")+t}function v(t,e,i,n){this.id=++Ht,this.value=t,this.stamp=-1,this.rank=-1,this.qrank=-1,this.flags=0,e&&(this._update=e),i&&this.parameters(i,n)}function g(t){return function(e){var i=this.flags;return 0===arguments.length?!!(i&t):(this.flags=e?i|t:i&~t,this)}}function _(t,e,i){this.id=++ie,this.value=null,i&&(this.receive=i),t&&(this._filter=t),e&&(this._apply=e)}function y(t,e,i){return new _(t,e,i)}function x(t,i,n,r,a,s){var u,o,l=e.extend({},s,ae);e.isFunction(n)||(n=e.constant(n)),void 0===r?u=function(e){t.touch(n(e))}:e.isFunction(r)?(o=new v(null,r,a,!1),u=function(e){var i=n(e),r=(o.evaluate(e),o.value);f(r)?t.pulse(i,r,s):t.update(i,r,l)}):u=function(e){t.update(n(e),r,l)},i.apply(u)}function k(t,i,n,r,a,s){var u,o;void 0===r?o=n:(u=e.isFunction(r)?r:e.constant(r),r=n?function(t,e){var i=u(t,e);return n.skip()?i:n.skip(!0).value=i}:u,o=new v(null,r,a,!1),o.modified(s&&s.force),o.rank=0,n&&(o.skip(!0),o.value=n.value,o.targets().add(n))),i.targets().add(o)}function w(t){t.rank=++this._rank}function D(t){for(var e,i,n,r=[t];r.length;)if(this.rank(e=r.pop()),i=e._targets)for(n=i.length;--n>=0;)r.push(i[n])}function O(t,e,i){this.dataflow=t,this.stamp=null==e?-1:e,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=i||null}function q(t,e){return t?function(i,n){return t(i,n)&&e(i,n)}:e}function E(t,e){var i={};return t.visit(e,function(t){i[t._id]=1}),function(t){return i[t._id]?null:t}}function b(t,e){var i=e||ye;return this._pulse?this._enqueue(t):this._touched.add(t),i.skip&&t.skip(!0),this}function F(t,e,i){var n=i||ye;return(t.set(e)||n.force)&&this.touch(t,n),this}function A(t,e,i){var n=new O(this,this._clock+(this._pulse?0:1));return n.target=t,this._pulses[t.id]=e.pulse(n,t.value),this.touch(t,i||ye)}function R(t,e,n){return this.pulse(t,this.changeset().insert(i.read(e,n)))}function M(t){var e,i,n=new Promise(function(t,n){e=t,i=n});return n.requests=0,n.done=function(){0===--n.requests&&t.runAfter(function(){t._pending=null;try{t.run(),e(t)}catch(t){i(t)}})},t._pending=n}function S(t,e,i){var n=this,r=n._pending||M(n);r.requests+=1,n.loader().load(e,{context:"dataflow"}).then(function(e){n.ingest(t,e,i)},function(t){n.warn("Loading failed: "+e,t),r.done()}).then(r.done).catch(function(t){n.warn(t)})}function N(t,e,i,n){var r,a,s,u,o,l=this,d=0;for(this.dataflow=t,this.stamp=e,this.fields=null,this.encode=n||null,this.pulses=i,s=0,u=i.length;s<u;++s)if(r=i[s],r.stamp===e){if(r.fields){a=l.fields||(l.fields={});for(o in r.fields)a[o]=1}r.changed(l.ADD)&&(d|=l.ADD),r.changed(l.REM)&&(d|=l.REM),r.changed(l.MOD)&&(d|=l.MOD)}this.changes=d}function C(t){if(!this._touched.length)return 0;if(this._pending)return this.info("Awaiting requests, delaying dataflow run."),0;var i,n,r,s=this,u=0,o=s.logLevel();s._pulse=new O(s,++s._clock,t),o>=e.Info&&(r=Date.now(),s.debug("-- START PROPAGATION ("+s._clock+") -----")),s._touched.forEach(function(t){s._enqueue(t,!0)}),s._touched=a(e.id);try{for(;s._heap.size()>0;)i=s._heap.pop(),i.rank===i.qrank?(n=i.run(s._getPulse(i,t)),o>=e.Debug&&s.debug(i.id,n===ue?"STOP":n,i),n!==ue&&(s._pulse=n,i._targets&&i._targets.forEach(function(t){s._enqueue(t)})),++u):s._enqueue(i,!0)}catch(t){s.error(t)}if(s._pulses={},s._pulse=null,o>=e.Info&&(r=Date.now()-r,s.info("> Pulse "+s._clock+": "+u+" operators; "+r+"ms")),s._postrun.length){var l=s._postrun;s._postrun=[],l.forEach(function(t){try{t(s)}catch(t){s.error(t)}})}return u}function P(){return this._pending||Promise.resolve(this.run())}function U(t){if(this._pulse)this._postrun.push(t);else try{t(this)}catch(t){this.error(t)}}function L(t,e){var i=!this._pulses[t.id];i&&(this._pulses[t.id]=this._pulse),(i||e)&&(t.qrank=t.rank,this._heap.push(t))}function z(t,i){var n,r=t.source,a=this._clock;return r&&e.isArray(r)?(n=r.map(function(t){return t.pulse}),new N(this,a,n,i)):(r=r&&r.pulse,n=this._pulses[t.id],r&&r!==ue&&(r.stamp===a&&n.target!==t?n=r:n.source=r.source),n)}function I(t){this.cmp=t,this.nodes=[]}function T(t,e,i,n){var r,a,s;for(r=t[i];i>e&&(s=i-1>>1,a=t[s],n(r,a)<0);)t[i]=a,i=s;return t[i]=r}function j(t,e,i){for(var n,r=e,a=t.length,s=t[e],u=2*e+1;u<a;)n=u+1,n<a&&i(t[u],t[n])>=0&&(u=n),t[e]=t[u],e=u,u=2*e+1;return t[e]=s,T(t,r,e,i)}function W(){this._log=e.logger(),this._clock=0,this._rank=0,this._loader=i.loader(),this._touched=a(e.id),this._pulses={},this._pulse=null,this._heap=new I(function(t,e){return t.qrank-e.qrank}),this._postrun=[]}function G(t){return function(){return this._log[t].apply(this,arguments)}}function K(t,e){v.call(this,t,null,e)}function V(t,e){var i=t.type;B(i,t),$(i,e)}function B(t,e){return t=t&&t.toLowerCase(),arguments.length>1?(qe[t]=e,this):qe.hasOwnProperty(t)?qe[t]:null}function $(t,e){return arguments.length>1?(Oe[t]=e,this):Oe.hasOwnProperty(t)?Oe[t]:null}function H(t){this._key=t||"_id",this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null}function J(t,e){return be[t](e)}function Q(t){return function(i){var n=e.extend({init:"",add:"",rem:"",idx:0},t);return n.out=i||t.name,n}}function X(t,e){return t.idx-e.idx}function Y(t,e){function i(t,n){function r(e){t[e]||i(t,t[e]=be[e]())}return n.req&&n.req.forEach(r),e&&n.str&&n.str.forEach(r),t}var n,r=t.reduce(i,t.reduce(function(t,e){return t[e.name]=e,t},{})),a=[];for(n in r)a.push(r[n]);return a.sort(X)}function Z(t,i){var n=i||e.identity,r=Y(t,!0),a="this.cell = cell; this.tuple = t; this.valid = 0; this.missing = 0;",s="if(v==null){++this.missing; return;} if(v!==v) return; ++this.valid;",u="if(v==null){--this.missing; return;} if(v!==v) return; --this.valid;",o="var t = this.tuple; var cell = this.cell;";return r.forEach(function(t){t.idx<0?(a=t.init+a,s=t.add+s,u=t.rem+u):(a+=t.init,s+=t.add,u+=t.rem)}),t.slice().sort(X).forEach(function(t){o+="t['"+t.out+"']="+t.set+";"}),o+="return t;",a=Function("cell","t",a),a.prototype.add=Function("v","t",s),a.prototype.rem=Function("v","t",u),a.prototype.set=Function(o),a.prototype.get=n,a.fields=t.map(function(t){return t.out}),a}function tt(t){K.call(this,null,t),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}function et(t,e,i){return i||t+(e?"_"+e:"")}function it(t){var e,i=this._dims,n=i.length,r=String(i[0](t));for(e=1;e<n;++e)r+="|"+i[e](t);return r}function nt(t){K.call(this,null,t)}function rt(t){K.call(this,[],t)}function at(t){v.call(this,null,st,t)}function st(t){return this.value&&!t.modified()?this.value:e.compare(t.fields,t.orders)}function ut(t){K.call(this,null,t)}function ot(t,e,i){switch(e){case"upper":t=t.toUpperCase();break;case"lower":t=t.toLowerCase()}return t.match(i)}function lt(t){K.call(this,null,t)}function dt(t,e,i,n){for(var r,a,s=[],u={},l=t.length,d=0;d<l;++d)for(u[e]=a=t[d],r=0;r<l;++r)u[i]=t[r],n(u)&&(s.push(o(u)),u={},u[e]=a);return s}function ht(t,i){var n=t[Pe];Ne.hasOwnProperty(n)||e.error("Unknown distribution function: "+n);var r=Ne[n]();for(var a in t)a===Ue?r.data((t.from||i()).map(t[a])):a===Ce?r[a](t[a].map(function(t){return ht(t,i)})):typeof r[a]===Pe&&r[a](t[a]);return r}function ft(t){K.call(this,null,t)}function ct(t){return function(){return t.materialize(t.SOURCE).source}}function mt(t){K.call(this,[+(1/0),-(1/0)],t)}function pt(t,e){v.call(this,t),this.parent=e}function vt(t){K.call(this,{},t),this._keys=e.fastmap(),this._count=0;var i=this._targets=[];i.active=0,i.forEach=function(t){for(var e=0,n=i.active;e<n;++e)t(i[e],e,i)}}function gt(t){v.call(this,null,_t,t)}function _t(t){return this.value&&!t.modified()?this.value:e.isArray(t.name)?e.array(t.name).map(function(t){return e.field(t)}):e.field(t.name,t.as)}function yt(t){K.call(this,e.fastmap(),t)}function xt(t){K.call(this,{},t)}function kt(t){return t.fields.join("|")}function wt(t){K.call(this,null,t)}function Dt(t){K.call(this,[],t)}function Ot(t){K.call(this,[],t)}function qt(t){var i,n=t.method||Ve.value;return null!=Ve[n]?n===Ve.value?(i=void 0!==t.value?t.value:0,function(){return i}):Ve[n]:void e.error("Unrecognized imputation method: "+n)}function Et(t){var e=t.field;return function(t){return t?e(t):NaN}}function bt(t,e,i){var n,r,a,s,u,o,l,d,h,f=function(t){return t(h)},c=[],m=[],p={},v={};for(o=0,d=t.length;o<d;++o)h=t[o],r=(n=i.map(f))+"",l=p[r]||(p[r]=m.push(n)),s=(a=e?e.map(f):Be)+"",(u=v[s])||(u=v[s]=[],c.push(u),u.values=a),u[l-1]=h;return c.domain=m,c}function Ft(t){v.call(this,null,At,t)}function At(t){return this.value&&!t.modified()?this.value:e.key(t.fields)}function Rt(t){K.call(this,{},t)}function Mt(t){v.call(this,null,St,t)}function St(t){if(this.value&&!t.modified())return this.value;var e,i,n,r=+(1/0),a=-(1/0),s=t.extents;for(e=0,i=s.length;e<i;++e)n=s[e],n[0]<r&&(r=n[0]),n[1]>a&&(a=n[1]);return[r,a]}function Nt(t){v.call(this,null,Ct,t)}function Ct(t){return this.value&&!t.modified()?this.value:t.values.reduce(function(t,e){return t.concat(e)},[])}function Pt(t){K.call(this,null,t)}function Ut(t){vt.call(this,t)}function Lt(t){K.call(this,null,t)}function zt(t){K.call(this,[],t)}function It(t){K.call(this,null,t)}function Tt(t){K.call(this,null,t)}function jt(t){K.call(this,[],t),this.count=0}function Wt(t){K.call(this,null,t),this.modified(!0)}function Gt(t){K.call(this,e.fastmap(),t)}function Kt(t){K.call(this,null,t)}var Vt=1,Bt="_:mod:_",$t=m.prototype;$t.set=function(t,i,n,r){var a=this,s=a[t],u=a[Bt];return null!=i&&i>=0?(s[i]!==n||r)&&(s[i]=n,u[p(t,i)]=1,u[t]=1):(s!==n||r)&&(a[t]=n,u[t]=1,e.isArray(n)&&n.forEach(function(e,i){u[p(t,i)]=1})),a},$t.modified=function(t,i){var n,r=this[Bt];if(!arguments.length){for(n in r)if(r[n])return!0;return!1}if(e.isArray(t)){for(n=0;n<t.length;++n)if(r[t[n]])return!0;return!1}return!!r[p(t,i)]},$t.clear=function(){return this[Bt]={},this};var Ht=0,Jt="pulse",Qt=new m,Xt=1,Yt=2,Zt=v.prototype;Zt.targets=function(){return this._targets||(this._targets=a(e.id))},Zt.set=function(t){return this.value!==t?(this.value=t,1):0},Zt.skip=g(Xt),Zt.modified=g(Yt),Zt.parameters=function(t,i){function n(t,e,n){n instanceof v?(n!==o&&(i&&n.targets().add(o),h.push(n)),d.push({op:n,name:t,index:e})):l.set(t,e,n)}i=i!==!1;var r,a,s,u,o=this,l=o._argval=o._argval||new m,d=o._argops=o._argops||[],h=[];for(r in t)if(a=t[r],r===Jt)e.array(a).forEach(function(t){t instanceof v?t!==o&&(t.targets().add(o),h.push(t)):e.error("Pulse parameters must be operator instances.")}),o.source=a;else if(e.isArray(a))for(l.set(r,-1,Array(s=a.length)),u=0;u<s;++u)n(r,u,a[u]);else n(r,-1,a);return this.marshall().clear(),h},Zt.marshall=function(t){var e,i,n,r,a,s=this._argval||Qt,u=this._argops;if(u&&(n=u.length))for(i=0;i<n;++i)e=u[i],r=e.op,a=r.modified()&&r.stamp===t,s.set(e.name,e.index,r.value,a);return s},Zt.evaluate=function(t){if(this._update){var e=this.marshall(t.stamp),i=this._update(e,t);if(e.clear(),i!==this.value)this.value=i;else if(!this.modified())return t.StopPropagation}},Zt.run=function(t){if(t.stamp<=this.stamp)return t.StopPropagation;var e=this.skip()?(this.skip(!1),0):this.evaluate(t);return this.stamp=t.stamp,this.pulse=e||t};var te=function(t,i,n,r){var a=1,s=t instanceof v?t:t&&t.prototype instanceof v?new t:e.isFunction(t)?new v(null,t):(a=0,new v(t,i));return this.rank(s),a&&(r=n,n=i),n&&this.connect(s,s.parameters(n,r)),this.touch(s),s},ee=function(t,e){var i,n,r=t.rank;for(i=0,n=e.length;i<n;++i)if(r<e[i].rank)return void this.rerank(t)},ie=0,ne=_.prototype;ne._filter=e.truthy,ne._apply=e.identity,ne.targets=function(){return this._targets||(this._targets=a(e.id))},ne.consume=function(t){return arguments.length?(this._consume=!!t,this):!!this._consume},ne.receive=function(t){if(this._filter(t)){for(var e=this.value=this._apply(t),i=this._targets,n=i?i.length:0,r=0;r<n;++r)i[r].receive(e);this._consume&&(t.preventDefault(),t.stopPropagation())}},ne.filter=function(t){var e=y(t);return this.targets().add(e),e},ne.apply=function(t){var e=y(null,t);return this.targets().add(e),e},ne.merge=function(){var t=y();this.targets().add(t);for(var e=0,i=arguments.length;e<i;++e)arguments[e].targets().add(t);return t},ne.throttle=function(t){var e=-1;return this.filter(function(){var i=Date.now();return i-e>t?(e=i,1):0})},ne.debounce=function(t){function e(){var t=n.dataflow;i.receive(n),n=null,r=null,t&&t.run&&t.run()}var i=y(),n=null,r=null;return this.targets().add(y(null,null,function(i){n=i,r&&clearTimeout(r),r=setTimeout(e,t)})),i},ne.between=function(t,e){var i=!1;return t.targets().add(y(null,null,function(){i=!0})),e.targets().add(y(null,null,function(){i=!1})),this.filter(function(){return i})};var re=function(t,i,n,r){var a,s=this,u=y(n,r),o=function(t){t.dataflow=s,u.receive(t),s.run()};a="string"==typeof t&&"undefined"!=typeof document?document.querySelectorAll(t):e.array(t);for(var l=0,d=a.length;l<d;++l)a[l].addEventListener(i,o);return u},ae={skip:!0},se=function(t,e,i,n,r){var a=t instanceof v?k:x;return a(this,t,e,i,n,r),this},ue={},oe=1,le=2,de=4,he=oe|le,fe=oe|de,ce=oe|le|de,me=8,pe=16,ve=32,ge=64,_e=O.prototype;_e.StopPropagation=ue,_e.ADD=oe,_e.REM=le,_e.MOD=de,_e.ADD_REM=he,_e.ADD_MOD=fe,_e.ALL=ce,_e.REFLOW=me,_e.SOURCE=pe,_e.NO_SOURCE=ve,_e.NO_FIELDS=ge,_e.fork=function(t){return new O(this.dataflow).init(this,t)},_e.addAll=function(){var t=this;return this.source&&this.source.length!==this.add.length?(t=new O(this.dataflow).init(this),t.add=t.source,t):t},_e.init=function(t,e){var i=this;return i.stamp=t.stamp,i.encode=t.encode,!t.fields||e&ge||(i.fields=t.fields),i.add=e&oe?(i.addF=t.addF,t.add):(i.addF=null,[]),i.rem=e&le?(i.remF=t.remF,t.rem):(i.remF=null,[]),i.mod=e&de?(i.modF=t.modF,t.mod):(i.modF=null,[]),i.source=e&ve?(i.srcF=null,null):(i.srcF=t.srcF,t.source),i},_e.runAfter=function(t){this.dataflow.runAfter(t)},_e.changed=function(t){var e=t||ce;return e&oe&&this.add.length||e&le&&this.rem.length||e&de&&this.mod.length},_e.reflow=function(t){if(t)return this.fork(ce).reflow();var e=this.add.length,i=this.source&&this.source.length;return i&&i!==e&&(this.mod=this.source,e&&this.filter(de,E(this,oe))),this},_e.modifies=function(t){var i=e.array(t),n=this.fields||(this.fields={});return i.forEach(function(t){n[t]=!0}),this},_e.modified=function(t){var i=this.fields;return!(!this.mod.length||!i)&&(arguments.length?e.isArray(t)?t.some(function(t){return i[t]}):i[t]:!!i)},_e.filter=function(t,e){var i=this;return t&oe&&(i.addF=q(i.addF,e)),t&le&&(i.remF=q(i.remF,e)),t&de&&(i.modF=q(i.modF,e)),t&pe&&(i.srcF=q(i.srcF,e)),i},_e.materialize=function(t){t=t||ce;var e=this;return t&oe&&e.addF&&(e.add=e.add.filter(e.addF),e.addF=null),t&le&&e.remF&&(e.rem=e.rem.filter(e.remF),e.remF=null),t&de&&e.modF&&(e.mod=e.mod.filter(e.modF),e.modF=null),t&pe&&e.srcF&&(e.source=e.source.filter(e.srcF),e.srcF=null),e},_e.visit=function(t,i){var n,r,a=i;return t&pe?(e.visitArray(this.source,this.srcF,a),this):(t&oe&&e.visitArray(this.add,this.addF,a),t&le&&e.visitArray(this.rem,this.remF,a),t&de&&e.visitArray(this.mod,this.modF,a),t&me&&(n=this.source)&&(r=this.add.length+this.mod.length,r===n||(r?e.visitArray(n,E(this,fe),a):e.visitArray(n,this.srcF,a))),this)};var ye={skip:!1,force:!1},xe=e.inherits(N,O);xe.fork=function(){return arguments.length&&arguments[0]&O.prototype.ALL&&e.error("MultiPulse fork does not support tuple change sets."),new O(this.dataflow).init(this,0)},xe.changed=function(t){return this.changes&t},xe.modified=function(t){var i=this,n=i.fields;return n&&i.changes&i.MOD?e.isArray(t)?t.some(function(t){return n[t]}):n[t]:0},xe.filter=function(){e.error("MultiPulse does not support filtering.")},xe.materialize=function(){e.error("MultiPulse does not support materialization.")},xe.visit=function(t,e){var i,n,r=this.pulses;for(i=0,n=r.length;i<n;++i)r[i].stamp===this.stamp&&r[i].visit(t,e);return this};var ke=I.prototype;ke.size=function(){return this.nodes.length},ke.clear=function(){return this.nodes=[],this},ke.peek=function(){return this.nodes[0]},ke.push=function(t){var e=this.nodes;return e.push(t),T(e,0,e.length-1,this.cmp)},ke.pop=function(){var t,e=this.nodes,i=e.pop();return e.length?(t=e[0],e[0]=i,j(e,0,this.cmp)):t=i,t},ke.replace=function(t){var e=this.nodes,i=e[0];return e[0]=t,j(e,0,this.cmp),i},ke.pushpop=function(t){var e=this.nodes,i=e[0];return e.length&&this.cmp(i,t)<0&&(e[0]=t,t=i,j(e,0,this.cmp)),t};var we=W.prototype;we.stamp=function(){return this._clock},we.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},we.cleanThreshold=1e4,we.add=te,we.connect=ee,we.rank=w,we.rerank=D,we.pulse=A,we.touch=b,we.update=F,we.changeset=c,we.ingest=R,we.request=S,we.events=re,we.on=se,we.run=C,we.runAsync=P,we.runAfter=U,we._enqueue=L,we._getPulse=z,we.warn=G("warn"),we.info=G("info"),we.debug=G("debug"),we.logLevel=G("level"),we.error=function(t){throw t};var De=e.inherits(K,v);De.evaluate=function(t){var e=this.marshall(t.stamp),i=this.transform(e,t);return e.clear(),i},De.transform=function(){};var Oe={},qe={},Ee=H.prototype;Ee.add=function(t){this._add.push(t)},Ee.rem=function(t){this._rem.push(t)},Ee.values=function(){if(this._get=null,0===this._rem.length)return this._add;var t,e,i,n=this._add,r=this._rem,a=this._key,s=n.length,u=r.length,o=Array(s-u),l={};for(t=0;t<u;++t)l[r[t][a]]=1;for(t=0,e=0;t<s;++t)l[(i=n[t])[a]]?l[i[a]]=0:o[e++]=i;return this._rem=[],this._add=o},Ee.distinct=function(t){for(var e,i=this.values(),n=i.length,r={},a=0;--n>=0;)e=t(i[n])+"",r.hasOwnProperty(e)||(r[e]=1,++a);return a},Ee.extent=function(t){if(this._get!==t||!this._ext){var i=this.values(),n=e.extentIndex(i,t);this._ext=[i[n[0]],i[n[1]]],this._get=t}return this._ext},Ee.argmin=function(t){return this.extent(t)[0]||{}},Ee.argmax=function(t){return this.extent(t)[1]||{}},Ee.min=function(t){var e=this.extent(t)[0];return null!=e?t(e):+(1/0)},Ee.max=function(t){var e=this.extent(t)[1];return null!=e?t(e):-(1/0)},Ee.quartile=function(t){return this._get===t&&this._q||(this._q=n.quartiles(this.values(),t),this._get=t),this._q},Ee.q1=function(t){return this.quartile(t)[0]},Ee.q2=function(t){return this.quartile(t)[1]},Ee.q3=function(t){return this.quartile(t)[2]},Ee.ci=function(t){return this._get===t&&this._ci||(this._ci=n.bootstrapCI(this.values(),1e3,.05,t),this._get=t),this._ci},Ee.ci0=function(t){return this.ci(t)[0]},Ee.ci1=function(t){return this.ci(t)[1]};var be={values:Q({name:"values",init:"cell.store = true;",set:"cell.data.values()",idx:-1}),count:Q({name:"count",set:"cell.num"}),missing:Q({name:"missing",set:"this.missing"}),valid:Q({name:"valid",set:"this.valid"}),sum:Q({name:"sum",init:"this.sum = 0;",add:"this.sum += v;",rem:"this.sum -= v;",set:"this.sum"}),mean:Q({name:"mean",init:"this.mean = 0;",add:"var d = v - this.mean; this.mean += d / this.valid;",rem:"var d = v - this.mean; this.mean -= this.valid ? d / this.valid : this.mean;",set:"this.mean"}),average:Q({name:"average",set:"this.mean",req:["mean"],idx:1}),variance:Q({name:"variance",init:"this.dev = 0;",add:"this.dev += d * (v - this.mean);",rem:"this.dev -= d * (v - this.mean);",set:"this.valid > 1 ? this.dev / (this.valid-1) : 0",req:["mean"],idx:1}),variancep:Q({name:"variancep",set:"this.valid > 1 ? this.dev / this.valid : 0",req:["variance"],idx:2}),stdev:Q({name:"stdev",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : 0",req:["variance"],idx:2}),stdevp:Q({name:"stdevp",set:"this.valid > 1 ? Math.sqrt(this.dev / this.valid) : 0",req:["variance"],idx:2}),stderr:Q({name:"stderr",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : 0",req:["variance"],idx:2}),distinct:Q({name:"distinct",set:"cell.data.distinct(this.get)",req:["values"],idx:3}),ci0:Q({name:"ci0",set:"cell.data.ci0(this.get)",req:["values"],idx:3}),ci1:Q({name:"ci1",set:"cell.data.ci1(this.get)",req:["values"],idx:3}),median:Q({name:"median",set:"cell.data.q2(this.get)",req:["values"],idx:3}),q1:Q({name:"q1",set:"cell.data.q1(this.get)",req:["values"],idx:3}),q3:Q({name:"q3",set:"cell.data.q3(this.get)",req:["values"],idx:3}),argmin:Q({name:"argmin",add:"if (v < this.min) this.argmin = t;",rem:"if (v <= this.min) this.argmin = null;",set:"this.argmin || cell.data.argmin(this.get)",req:["min"],str:["values"],idx:3}),argmax:Q({name:"argmax",add:"if (v > this.max) this.argmax = t;",rem:"if (v >= this.max) this.argmax = null;",set:"this.argmax || cell.data.argmax(this.get)",req:["max"],str:["values"],idx:3}),min:Q({name:"min",init:"this.min = null;",add:"if (v < this.min || this.min === null) this.min = v;",rem:"if (v <= this.min) this.min = NaN;",set:"this.min = (isNaN(this.min) ? cell.data.min(this.get) : this.min)",str:["values"],idx:4}),max:Q({name:"max",init:"this.max = null;",add:"if (v > this.max || this.max === null) this.max = v;",rem:"if (v >= this.max) this.max = NaN;",set:"this.max = (isNaN(this.max) ? cell.data.max(this.get) : this.max)",str:["values"],idx:4})},Fe=e.inherits(tt,K);Fe.transform=function(t,e){var i,n=this,r=e.fork(e.NO_SOURCE|e.NO_FIELDS);return this.stamp=r.stamp,this.value&&((i=t.modified())||e.modified(this._inputs))?(this._prev=this.value,this.value=i?this.init(t):{},e.visit(e.SOURCE,function(t){n.add(t)})):(this.value=this.value||this.init(t),e.visit(e.REM,function(t){n.rem(t)}),e.visit(e.ADD,function(t){n.add(t)})),r.modifies(this._outputs),n._drop=t.drop!==!1,n.changes(r)},Fe.init=function(t){function i(t){for(var e,i=t.fields,r=0,s=i.length;r<s;++r)a[e=i[r]]||(a[e]=1,n.push(e))}var n=this._inputs=[],r=this._outputs=[],a={};this._dims=e.array(t.groupby),this._dnames=this._dims.map(function(t){var n=e.accessorName(t);return i(t),r.push(n),n}),this.cellkey=t.key?t.key:0===this._dims.length?function(){return""}:1===this._dims.length?this._dims[0]:it,this._countOnly=!0,this._counts=[],this._measures=[];var s,u,o,l,d,h,f=t.fields||[null],c=t.ops||["count"],m=t.as||[],p=f.length,v={};for(p!==c.length&&e.error("Unmatched number of fields and aggregate ops."),h=0;h<p;++h)s=f[h],u=c[h],null==s&&"count"!==u&&e.error("Null aggregate field specified."),l=e.accessorName(s),d=et(u,l,m[h]),r.push(d),"count"!==u?(o=v[l],o||(i(s),o=v[l]=[],o.field=s,this._measures.push(o)),"count"!==u&&(this._countOnly=!1),o.push(J(u,d))):this._counts.push(d);return this._measures=this._measures.map(function(t){return Z(t,t.field)}),{}},Fe.cellkey=it,Fe.cell=function(t,e){var i=this.value[t];return i?0===i.num&&this._drop&&i.stamp<this.stamp?(i.stamp=this.stamp,this._adds[this._alen++]=i):i.stamp<this.stamp&&(i.stamp=this.stamp,this._mods[this._mlen++]=i):(i=this.value[t]=this.newcell(t,e),this._adds[this._alen++]=i),i},Fe.newcell=function(t,e){var i={key:t,num:0,agg:null,tuple:this.newtuple(e,this._prev&&this._prev[t]),stamp:this.stamp,store:!1};if(!this._countOnly){var n,r=this._measures,a=r.length;for(i.agg=Array(a),n=0;n<a;++n)i.agg[n]=new r[n](i,i.tuple)}return i.store&&(i.data=new H),i},Fe.newtuple=function(t,e){var i,n,r=this._dnames,a=this._dims,s={};for(i=0,n=a.length;i<n;++i)s[r[i]]=a[i](t);return e?h(e.tuple,s):o(s)},Fe.add=function(t){var e,i,n,r=this.cellkey(t),a=this.cell(r,t);if(a.num+=1,!this._countOnly)for(a.store&&a.data.add(t),e=a.agg,i=0,n=e.length;i<n;++i)e[i].add(e[i].get(t),t)},Fe.rem=function(t){var e,i,n,r=this.cellkey(t),a=this.cell(r,t);if(a.num-=1,!this._countOnly)for(a.store&&a.data.rem(t),e=a.agg,i=0,n=e.length;i<n;++i)e[i].rem(e[i].get(t),t)},Fe.celltuple=function(t){var e,i,n,r=t.tuple,a=this._counts;for(t.store&&t.data.values(),i=0,n=a.length;i<n;++i)r[a[i]]=t.num;if(!this._countOnly)for(e=t.agg,i=0,n=e.length;i<n;++i)e[i].set();return r},Fe.changes=function(t){var e,i,n,r,a=this._adds,s=this._mods,u=this._prev,o=this._drop,l=t.add,d=t.rem,h=t.mod;if(u)for(i in u)d.push(u[i].tuple);for(n=0,r=this._alen;n<r;++n)l.push(this.celltuple(a[n])),a[n]=null;for(n=0,r=this._mlen;n<r;++n)e=s[n],(0===e.num&&o?d:h).push(this.celltuple(e)),s[n]=null;return this._alen=this._mlen=0,this._prev=null,t};var Ae=e.inherits(nt,K);Ae.transform=function(t,i){var n=this._bins(t),r=n.step,a=t.as||["bin0","bin1"],s=a[0],u=a[1],o=t.modified()?(i=i.reflow(!0),i.SOURCE):i.modified(e.accessorFields(t.field))?i.ADD_MOD:i.ADD;return i.visit(o,function(t){t[u]=(t[s]=n(t))+r}),i.modifies(a)},Ae._bins=function(t){if(this.value&&!t.modified())return this.value;var i=t.field,r=n.bin(t),a=r.start,s=r.step,u=function(t){var e=i(t);return null==e?null:a+s*Math.floor((+e-a)/s)};return u.step=s,this.value=e.accessor(u,e.accessorFields(i),t.name||"bin_"+e.accessorName(i))};var Re=e.inherits(rt,K);Re.transform=function(t,i){var n,r=i.fork(i.ALL),a=i.changed(i.ADD),s=i.changed(),u=t.sort,o=this.value,l=function(t){o.push(t)},d=0;return r.rem.length&&(n={},r.visit(r.REM,function(t){n[t._id]=1,++d}),o=o.filter(function(t){return!n[t._id]})),u?((t.modified("sort")||i.modified(u.fields))&&(o.sort(u),s=!0),a&&(o=e.merge(u,o,r.add.sort(u)))):a&&r.visit(r.ADD,l),this.modified(s),this.value=r.source=o,r},e.inherits(at,v);var Me=e.inherits(ut,K);Me.transform=function(t,e){function i(e){return function(i){for(var n,r=ot(u(i),t.case,a)||[],o=0,l=r.length;o<l;++o)s.test(n=r[o])||e(n)}}var n=this._parameterCheck(t,e),r=this._counts,a=this._match,s=this._stop,u=t.field,o=t.as||["text","count"],l=i(function(t){r[t]=1+(r[t]||0)}),d=i(function(t){r[t]-=1});return n?e.visit(e.SOURCE,l):(e.visit(e.ADD,l),e.visit(e.REM,d)),this._finish(e,o)},Me._parameterCheck=function(t,e){var i=!1;return!t.modified("stopwords")&&this._stop||(this._stop=new RegExp("^"+(t.stopwords||"")+"$","i"),i=!0),!t.modified("pattern")&&this._match||(this._match=new RegExp(t.pattern||"[\\w']+","g"),i=!0),(t.modified("field")||e.modified(t.field.fields))&&(i=!0),i&&(this._counts={}),i},Me._finish=function(t,e){var i,n,r,a=this._counts,s=this._tuples||(this._tuples={}),u=e[0],l=e[1],d=t.fork();for(i in a)n=s[i],r=a[i]||0,!n&&r?(s[i]=n=o({}),n[u]=i,n[l]=r,d.add.push(n)):0===r?(n&&d.rem.push(n),a[i]=null,s[i]=null):n[l]!==r&&(n[l]=r,d.mod.push(n));return d.modifies(e)};var Se=e.inherits(lt,K);Se.transform=function(t,i){var n=i.fork(i.NO_SOURCE),r=this.value,a=t.as||["a","b"],s=a[0],u=a[1],o=!r||i.changed(i.ADD_REM)||t.modified("as")||t.modified("filter");return o?(r&&(n.rem=r),n.add=this.value=dt(i.source,s,u,t.filter||e.truthy)):n.mod=r,n.source=this.value,n.modifies(a)};var Ne={kde:n.randomKDE,mixture:n.randomMixture,normal:n.randomNormal,uniform:n.randomUniform},Ce="distributions",Pe="function",Ue="field",Le=e.inherits(ft,K);Le.transform=function(t,i){var n=i.fork(i.NO_SOURCE|i.NO_FIELDS);if(!this.value||i.changed()||t.modified()){var a=ht(t.distribution,ct(i)),s=t.method||"pdf";"pdf"!==s&&"cdf"!==s&&e.error("Invalid density method: "+s),t.extent||a.data||e.error("Missing density extent parameter."),s=a[s];var u=t.as||["value","density"],l=t.extent||r.extent(a.data()),d=(l[1]-l[0])/(t.steps||100),h=r.range(l[0],l[1]+d/2,d).map(function(t){var e={};return e[u[0]]=t,e[u[1]]=s(t),o(e)});this.value&&(n.rem=this.value),this.value=n.add=n.source=h}return n};var ze=e.inherits(mt,K);ze.transform=function(t,e){var i,n=this.value,r=t.field,a=n[0],s=n[1],u=e.ADD;i=e.changed()||e.modified(r.fields)||t.modified("field"),i&&(u=e.SOURCE,a=+(1/0),s=-(1/0)),e.visit(u,function(t){var e=r(t);e<a&&(a=e),e>s&&(s=e)}),this.value=[a,s]};var Ie=e.inherits(pt,v);Ie.connect=function(t){return this.targets().add(t),t.source=this},Ie.add=function(t){this.value.add.push(t)},Ie.rem=function(t){this.value.rem.push(t)},Ie.mod=function(t){this.value.mod.push(t)},Ie.init=function(t){this.value.init(t,t.NO_SOURCE)},Ie.evaluate=function(){return this.value};var Te=e.inherits(vt,K);Te.activate=function(t){this._targets[this._targets.active++]=t},Te.subflow=function(t,e,i,n){var r,a,s=this.value,u=s.hasOwnProperty(t)&&s[t];return u?u.value.stamp<i.stamp&&(u.init(i),this.activate(u)):(a=n||(a=this._group[t])&&a.tuple,r=i.dataflow,u=r.add(new pt(i.fork(i.NO_SOURCE),this)).connect(e(r,t,this._count++,a)),s[t]=u,this.activate(u)),u},Te.transform=function(t,e){function i(t){return r.subflow(t,s,e)}var n=e.dataflow,r=this,a=t.key,s=t.subflow,u=this._keys,o=t.modified("key");return this._group=t.group||{},this._targets.active=0,e.visit(e.ADD,function(t){var e=a(t);u.set(t._id,e),i(e).add(t)}),e.visit(e.REM,function(t){var e=u.get(t._id);u.delete(t._id),i(e).rem(t)}),o||e.modified(a.fields)?e.visit(e.MOD,function(t){var e=u.get(t._id),n=a(t);e===n?i(n).mod(t):(u.set(t._id,n),i(e).rem(t),i(n).add(t))}):e.changed(e.MOD)&&e.visit(e.MOD,function(t){i(u.get(t._id)).mod(t)}),o&&e.visit(e.REFLOW,function(t){var e=u.get(t._id),n=a(t);e!==n&&(u.set(t._id,n),i(e).rem(t),i(n).add(t))}),u.empty>n.cleanThreshold&&n.runAfter(u.clean),e},e.inherits(gt,v);var je=e.inherits(yt,K);je.transform=function(t,e){function i(e){var i=l(e,t),n=r.get(e._id);i&&n?(r.delete(e._id),s.push(e)):i||n?d&&i&&!n&&o.push(e):(r.set(e._id,1),u.push(e))}var n=e.dataflow,r=this.value,a=e.fork(),s=a.add,u=a.rem,o=a.mod,l=t.expr,d=!0;return e.visit(e.REM,function(t){r.has(t._id)?r.delete(t._id):u.push(t)}),e.visit(e.ADD,function(e){l(e,t)?s.push(e):r.set(e._id,1)}),e.visit(e.MOD,i),t.modified()&&(d=!1,e.visit(e.REFLOW,i)),r.empty>n.cleanThreshold&&n.runAfter(r.clean),a};var We=e.inherits(xt,K);We.transform=function(t,e){function i(t){for(var e,i=a[t._id]=Array(m),n=0;n<m;++n)e=i[n]=l(t),e[h]=c[n],e[f]=u[n](t),v.add.push(e)}function n(t){for(var e,i=a[t._id],n=0;n<m;++n)_&1<<n&&(e=d(t,i[n],p),e[h]=c[n],e[f]=u[n](t),v.mod.push(e))}var r,a=this.value,s=t.modified("fields"),u=t.fields,o=t.as||["key","value"],h=o[0],f=o[1],c=u.map(kt),m=u.length,p=e.stamp,v=e.fork(e.NO_SOURCE),g=0,_=0;if(s){for(r in a)v.rem.push.apply(v.rem,a[r]);a=this.value={},e.visit(e.SOURCE,i)}else{for(e.visit(e.ADD,i);g<m;++g)e.modified(u[g].fields)&&(_|=1<<g);_&&e.visit(e.MOD,n),e.visit(e.REM,function(t){v.rem.push.apply(v.rem,a[t._id]),a[t._id]=null})}return v.modifies(o)};var Ge=e.inherits(wt,K);Ge.transform=function(t,e){function i(e){e[a]=r(e,t)}var n,r=t.expr,a=t.as;return t.modified()?e=e.materialize().reflow(!0).visit(e.SOURCE,i):(n=e.modified(r.fields),e.visit(n?e.ADD_MOD:e.ADD,i)),e.modifies(a)};var Ke=e.inherits(Dt,K);Ke.transform=function(t,e){ | ||
var i,n,r,a=this.value,s=e.fork(e.ALL),u=t.size-a.length,l=t.generator;if(u>0){for(i=[];--u>=0;)i.push(r=o(l(t))),a.push(r);s.add=s.add.length?s.materialize(s.ADD).add.concat(i):i}else n=a.slice(0,-u),s.rem=s.rem.length?s.materialize(s.REM).rem.concat(n):n,a=a.slice(-u);return s.source=this.value=a,s};var Ve={value:"value",median:r.median,mean:r.mean,min:r.min,max:r.max},Be=[],$e=e.inherits(Ot,K);$e.transform=function(t,i){var n,r,a,s,u,l,d,h,f,c,m=i.fork(i.ALL),p=qt(t),v=Et(t),g=e.accessorName(t.field),_=t.groupby.map(e.accessorName),y=t.orderby.map(e.accessorName),x=bt(i.source,t.groupby,t.orderby),k=[],w=this.value,D=x.domain.length;for(u=0,h=x.length;u<h;++u)for(n=x[u],a=n.values,r=NaN,d=0;d<D;++d)if(null==n[d]){for(s=x.domain[d],c={_impute:!0},l=0,f=a.length;l<f;++l)c[_[l]]=a[l];for(l=0,f=s.length;l<f;++l)c[y[l]]=s[l];c[g]=isNaN(r)?r=p(n,v):r,k.push(o(c))}return k.length&&(m.add=m.materialize(m.ADD).add.concat(k)),w.length&&(m.rem=m.materialize(m.REM).rem.concat(w)),this.value=k,m},e.inherits(Ft,v);var He=e.inherits(Rt,K);He.transform=function(t,e){var i,n,r,a,s=e,u=t.as,o=t.fields,l=t.index,d=null==t.default?null:t.default,h=t.modified(),f=e.ADD;return 1===o.length?(n=o[0],r=u[0],i=function(t){var e=l.get(n(t));t[r]=null==e?d:e}):i=function(t){for(var e,i=0,n=o.length;i<n;++i)e=l.get(o[i](t)),t[u[i]]=null==e?d:e},h?(f=e.SOURCE,s=e.reflow(!0)):(a=o.some(function(t){return e.modified(t.fields)}),f|=a?e.MOD:0),e.visit(f,i),s.modifies(u)},e.inherits(Mt,v),e.inherits(Nt,v),e.inherits(Pt,K),Pt.prototype.transform=function(t,e){return this.modified(t.modified()),this.value=t,e.fork(e.NO_SOURCE|e.NO_FIELDS)};var Je=e.inherits(Ut,vt);Je.transform=function(t,i){var n=this,r=t.subflow,a=t.field;return(t.modified("field")||a&&i.modified(a.fields))&&e.error("PreFacet does not support field modification."),this._targets.active=0,i.visit(i.ADD,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.add(o(t))}):e.add(t)}),i.visit(i.REM,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.rem(t)}):e.rem(t)}),i};var Qe=e.inherits(Lt,K);Qe.transform=function(t,e){return this.value=t.value,t.modified("value")?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation};var Xe=e.inherits(zt,K);Xe.transform=function(t,e){if(t.modified()){var i=e.materialize().fork(e.MOD);return i.rem=e.rem.concat(this.value),i.source=this.value=r.range(t.start,t.stop,t.step).map(o),i.add=e.add.concat(this.value),i}};var Ye=e.inherits(It,K);Ye.transform=function(t,i){i.source||e.error("Rank transform requires an upstream data source.");var n,r=t.normalize,a=t.field,s=t.as||"rank",u={},o=-1;return a?(i.visit(i.SOURCE,function(t){var e=a(t);null==u[e]&&(u[e]=++o)}),i.visit(i.SOURCE,r&&--o?function(t){t[s]=u[a(t)]/o}:function(t){t[s]=u[a(t)]})):(o+=i.source.length,n=-1,i.visit(i.SOURCE,r&&o?function(t){t[s]=++n/o}:function(t){t[s]=++n})),i.reflow(t.modified()).modifies(s)};var Ze=e.inherits(Tt,K);Ze.transform=function(t,e){var i,n=this.value||(i=e=e.addAll(),this.value={});return t.derive&&(i=e.fork(),e.visit(e.ADD,function(t){var e=l(t);n[t._id]=e,i.add.push(e)}),e.visit(e.MOD,function(t){i.mod.push(d(t,n[t._id]))}),e.visit(e.REM,function(t){i.rem.push(n[t._id]),n[t._id]=null})),i};var ti=e.inherits(jt,K);ti.transform=function(t,e){function i(t){var e,i;s.length<a?s.push(t):(i=~~(u*Math.random()),i<s.length&&i>=o&&(e=s[i],l[e._id]&&n.rem.push(e),s[i]=t)),++u}var n=e.fork(),r=t.modified("size"),a=t.size,s=this.value,u=this.count,o=0,l=s.reduce(function(t,e){return t[e._id]=1,t},{});if(e.rem.length&&(e.visit(e.REM,function(t){l[t._id]&&(l[t._id]=-1,n.rem.push(t)),--u}),s=s.filter(function(t){return l[t._id]!==-1})),(e.rem.length||r)&&s.length<a&&e.source&&(o=u=s.length,e.visit(e.SOURCE,function(t){l[t._id]||i(t)}),o=-1),r&&s.length>a){for(var d=0,h=s.length-a;d<h;++d)l[s[d]._id]=-1,n.rem.push(s[d]);s=s.slice(h)}return e.mod.length&&e.visit(e.MOD,function(t){l[t._id]&&n.mod.push(t)}),e.add.length&&e.visit(e.ADD,i),(e.add.length||o<0)&&(n.add=s.filter(function(t){return!l[t._id]})),this.count=u,this.value=n.source=s,n};var ei=e.inherits(Wt,K);ei.transform=function(t,e){return this.value=e.source,e.changed()?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation};var ii=e.inherits(Gt,K);ii.transform=function(t,e){function i(t){a.set(r(t),t)}var n=e.dataflow,r=t.field,a=this.value,s=!0;return t.modified("field")||e.modified(r.fields)?(a.clear(),e.visit(e.SOURCE,i)):e.changed()?(e.visit(e.REM,function(t){a.delete(r(t))}),e.visit(e.ADD,i)):s=!1,this.modified(s),a.empty>n.cleanThreshold&&n.runAfter(a.clean),e.fork()};var ni=e.inherits(Kt,K);ni.transform=function(t,e){var i=!this.value||t.modified("field")||t.modified("sort")||e.changed()||t.sort&&e.modified(t.sort.fields);i&&(this.value=(t.sort?e.source.slice().sort(t.sort):e.source).map(t.field))};var ri={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:["count","valid","missing","distinct","sum","mean","average","variance","variancep","stdev","stdevp","median","q1","q3","modeskew","min","max","argmin","argmax"]},{name:"as",type:"string",array:!0},{name:"drop",type:"boolean",default:!0},{name:"key",type:"field"}]},ai={type:"Bin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"maxbins",type:"number",default:20},{name:"base",type:"number",default:10},{name:"divide",type:"number",array:!0,default:[5,2]},{name:"extent",type:"number",array:!0,length:2,required:!0},{name:"step",type:"number"},{name:"steps",type:"number",array:!0},{name:"minstep",type:"number",default:0},{name:"nice",type:"boolean",default:!0},{name:"name",type:"string"},{name:"as",type:"string",array:!0,length:2,default:["bin0","bin1"]}]},si={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},ui={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]},oi={type:"Cross",metadata:{source:!0,generates:!0,changes:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]},li=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}],di={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:li},{name:"weights",type:"number",array:!0}]},hi={type:"Density",metadata:{generates:!0,source:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number",default:100},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:li.concat(di)},{name:"as",type:"string",array:!0}]},fi={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},ci={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},mi={type:"Fold",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,length:2,default:["key","value"]}]},pi={type:"Formula",metadata:{modifies:!0},params:[{name:"expr",type:"expr",required:!0},{name:"as",type:"string",required:!0}]},vi={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"orderby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},gi={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,required:!0},{name:"default",default:null}]},_i={type:"Range",metadata:{generates:!0,source:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1}],output:["value"]},yi={type:"Rank",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"normalize",type:"boolean",default:!1},{name:"as",type:"string",default:"rank"}]},xi={type:"Sample",metadata:{source:!0,changes:!0},params:[{name:"size",type:"number",default:1e3}]};V(ri,tt),V(ai,nt),V(si,rt),V(ui,ut),V(oi,lt),V(hi,ft),V(fi,mt),V(ci,yt),V(mi,xt),V(pi,wt),V(vi,Ot),V(gi,Rt),V(_i,zt),V(yi,It),V(xi,jt),$("Compare",at),$("Facet",vt),$("Field",gt),$("Generate",Dt),$("Key",Ft),$("MultiExtent",Mt),$("MultiValues",Nt),$("Params",Pt),$("PreFacet",Ut),$("Proxy",Lt),$("Relay",Tt),$("Sieve",Wt),$("Subflow",pt),$("TupleIndex",Gt),$("Values",Kt),t.UniqueList=a,t.changeset=c,t.isChangeSet=f,t.Dataflow=W,t.EventStream=_,t.Parameters=m,t.Pulse=O,t.MultiPulse=N,t.Operator=v,t.Transform=K,t.ingest=o,t.tupleid=s,t.definition=B,t.definitions=qe,t.register=V,t.transform=$,t.transforms=Oe,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-util"),require("vega-loader"),require("vega-statistics"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-loader","vega-statistics","d3-array"],e):e(t.vega=t.vega||{},t.vega,t.vega,t.vega,t.d3)}(this,function(t,e,i,n,r){"use strict";function a(t){var i=t||e.identity,n=[],r={};return n.add=function(t){var e=i(t);return r[e]||(r[e]=1,n.push(t)),n},n.remove=function(t){var e,a=i(t);return r[a]&&(r[a]=0,(e=n.indexOf(t))>=0&&n.splice(e,1)),n},n}function s(t){return t._id}function u(t,e){for(var i in t)"_id"!==i&&(e[i]=t[i]);return e}function o(t){var e=t===Object(t)?t:{data:t};return e._id||(e._id=++Kt),e}function l(t){return o(u(t,{}))}function d(t,e){return u(t,e)}function h(t,e){return e._id=t._id,e}function f(t){return t&&t.constructor===c}function c(){var t=[],i=[],n=[],r=[],a=[];return{constructor:c,insert:function(i){for(var n=e.array(i),r=0,a=n.length;r<a;++r)t.push(n[r]);return this},remove:function(t){for(var n=e.isFunction(t)?r:i,a=e.array(t),s=0,u=a.length;s<u;++s)n.push(a[s]);return this},modify:function(t,i,r){var s={field:i,value:e.constant(r)};return e.isFunction(t)?(s.filter=t,a.push(s)):(s.tuple=t,n.push(s)),this},encode:function(t,e){return n.push({tuple:t,field:e}),this},pulse:function(e,s){function u(t,i,n){n?t[i]=n(t):e.encode=i,l[t._id]=t}var l,d,h,f,c,m,p;for(d=0,h=t.length;d<h;++d)e.add.push(o(t[d]));for(l={},d=0,h=i.length;d<h;++d)m=i[d],l[m._id]=m;for(d=0,h=r.length;d<h;++d)c=r[d],s.forEach(function(t){c(t)&&(l[t._id]=t)});for(p in l)e.rem.push(l[p]);for(l={},d=0,h=n.length;d<h;++d)f=n[d],u(f.tuple,f.field,f.value),e.modifies(f.field);for(d=0,h=a.length;d<h;++d)f=a[d],c=f.filter,s.forEach(function(t){c(t)&&u(t,f.field,f.value)}),e.modifies(f.field);for(p in l)e.mod.push(l[p]);return e}}}function m(){Object.defineProperty(this,Vt,{writable:!0,value:{}})}function p(t,e,i,n){this.id=++$t,this.value=t,this.stamp=-1,this.rank=-1,this.qrank=-1,this.flags=0,e&&(this._update=e),i&&this.parameters(i,n)}function v(t){return function(e){var i=this.flags;return 0===arguments.length?!!(i&t):(this.flags=e?i|t:i&~t,this)}}function g(t,e,i){this.id=++ee,this.value=null,i&&(this.receive=i),t&&(this._filter=t),e&&(this._apply=e)}function _(t,e,i){return new g(t,e,i)}function y(t,i,n,r,a,s){var u,o,l=e.extend({},s,re);e.isFunction(n)||(n=e.constant(n)),void 0===r?u=function(e){t.touch(n(e))}:e.isFunction(r)?(o=new p(null,r,a,!1),u=function(e){var i=n(e),r=(o.evaluate(e),o.value);f(r)?t.pulse(i,r,s):t.update(i,r,l)}):u=function(e){t.update(n(e),r,l)},i.apply(u)}function x(t,i,n,r,a,s){var u,o;void 0===r?o=n:(u=e.isFunction(r)?r:e.constant(r),r=n?function(t,e){var i=u(t,e);return n.skip()?i:n.skip(!0).value=i}:u,o=new p(null,r,a,!1),o.modified(s&&s.force),o.rank=0,n&&(o.skip(!0),o.value=n.value,o.targets().add(n))),i.targets().add(o)}function k(t){t.rank=++this._rank}function w(t){for(var e,i,n,r=[t];r.length;)if(this.rank(e=r.pop()),i=e._targets)for(n=i.length;--n>=0;)r.push(i[n])}function D(t,e,i){this.dataflow=t,this.stamp=null==e?-1:e,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=i||null}function O(t,e){return t?function(i,n){return t(i,n)&&e(i,n)}:e}function q(t,e){var i={};return t.visit(e,function(t){i[t._id]=1}),function(t){return i[t._id]?null:t}}function b(t,e){var i=e||_e;return this._pulse?this._enqueue(t):this._touched.add(t),i.skip&&t.skip(!0),this}function E(t,e,i){var n=i||_e;return(t.set(e)||n.force)&&this.touch(t,n),this}function F(t,e,i){var n=new D(this,this._clock+(this._pulse?0:1));return n.target=t,this._pulses[t.id]=e.pulse(n,t.value),this.touch(t,i||_e)}function A(t,e,n){return this.pulse(t,this.changeset().insert(i.read(e,n)))}function R(t){var e,i,n=new Promise(function(t,n){e=t,i=n});return n.requests=0,n.done=function(){0===--n.requests&&t.runAfter(function(){t._pending=null;try{t.run(),e(t)}catch(t){i(t)}})},t._pending=n}function M(t,e,i){var n=this,r=n._pending||R(n);r.requests+=1,n.loader().load(e,{context:"dataflow"}).then(function(e){n.ingest(t,e,i)},function(t){n.warn("Loading failed: "+e,t),r.done()}).then(r.done).catch(function(t){n.warn(t)})}function S(t,e,i,n){var r,a,s,u,o,l=this,d=0;for(this.dataflow=t,this.stamp=e,this.fields=null,this.encode=n||null,this.pulses=i,s=0,u=i.length;s<u;++s)if(r=i[s],r.stamp===e){if(r.fields){a=l.fields||(l.fields={});for(o in r.fields)a[o]=1}r.changed(l.ADD)&&(d|=l.ADD),r.changed(l.REM)&&(d|=l.REM),r.changed(l.MOD)&&(d|=l.MOD)}this.changes=d}function N(t){if(!this._touched.length)return 0;if(this._pending)return this.info("Awaiting requests, delaying dataflow run."),0;var i,n,r,s=this,u=0,o=s.logLevel();s._pulse=new D(s,++s._clock,t),o>=e.Info&&(r=Date.now(),s.debug("-- START PROPAGATION ("+s._clock+") -----")),s._touched.forEach(function(t){s._enqueue(t,!0)}),s._touched=a(e.id);try{for(;s._heap.size()>0;)i=s._heap.pop(),i.rank===i.qrank?(n=i.run(s._getPulse(i,t)),o>=e.Debug&&s.debug(i.id,n===se?"STOP":n,i),n!==se&&(s._pulse=n,i._targets&&i._targets.forEach(function(t){s._enqueue(t)})),++u):s._enqueue(i,!0)}catch(t){s.error(t)}if(s._pulses={},s._pulse=null,o>=e.Info&&(r=Date.now()-r,s.info("> Pulse "+s._clock+": "+u+" operators; "+r+"ms")),s._postrun.length){var l=s._postrun;s._postrun=[],l.forEach(function(t){try{t(s)}catch(t){s.error(t)}})}return u}function C(){return this._pending||Promise.resolve(this.run())}function P(t){if(this._pulse)this._postrun.push(t);else try{t(this)}catch(t){this.error(t)}}function U(t,e){var i=!this._pulses[t.id];i&&(this._pulses[t.id]=this._pulse),(i||e)&&(t.qrank=t.rank,this._heap.push(t))}function L(t,i){var n,r=t.source,a=this._clock;return r&&e.isArray(r)?(n=r.map(function(t){return t.pulse}),new S(this,a,n,i)):(r=r&&r.pulse,n=this._pulses[t.id],r&&r!==se&&(r.stamp===a&&n.target!==t?n=r:n.source=r.source),n)}function z(t){this.cmp=t,this.nodes=[]}function I(t,e,i,n){var r,a,s;for(r=t[i];i>e&&(s=i-1>>1,a=t[s],n(r,a)<0);)t[i]=a,i=s;return t[i]=r}function T(t,e,i){for(var n,r=e,a=t.length,s=t[e],u=2*e+1;u<a;)n=u+1,n<a&&i(t[u],t[n])>=0&&(u=n),t[e]=t[u],e=u,u=2*e+1;return t[e]=s,I(t,r,e,i)}function j(){this._log=e.logger(),this._clock=0,this._rank=0,this._loader=i.loader(),this._touched=a(e.id),this._pulses={},this._pulse=null,this._heap=new z(function(t,e){return t.qrank-e.qrank}),this._postrun=[]}function W(t){return function(){return this._log[t].apply(this,arguments)}}function G(t,e){p.call(this,t,null,e)}function K(t,e){var i=t.type;V(i,t),B(i,e)}function V(t,e){return t=t&&t.toLowerCase(),arguments.length>1?(Oe[t]=e,this):Oe.hasOwnProperty(t)?Oe[t]:null}function B(t,e){return arguments.length>1?(De[t]=e,this):De.hasOwnProperty(t)?De[t]:null}function $(t){this._key=t||"_id",this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null}function H(t,e){return be[t](e)}function J(t){return function(i){var n=e.extend({init:"",add:"",rem:"",idx:0},t);return n.out=i||t.name,n}}function Q(t,e){return t.idx-e.idx}function X(t,e){function i(t,n){function r(e){t[e]||i(t,t[e]=be[e]())}return n.req&&n.req.forEach(r),e&&n.str&&n.str.forEach(r),t}var n,r=t.reduce(i,t.reduce(function(t,e){return t[e.name]=e,t},{})),a=[];for(n in r)a.push(r[n]);return a.sort(Q)}function Y(t,i){var n=i||e.identity,r=X(t,!0),a="this.cell = cell; this.tuple = t; this.valid = 0; this.missing = 0;",s="if(v==null){++this.missing; return;} if(v!==v) return; ++this.valid;",u="if(v==null){--this.missing; return;} if(v!==v) return; --this.valid;",o="var t = this.tuple; var cell = this.cell;";return r.forEach(function(t){t.idx<0?(a=t.init+a,s=t.add+s,u=t.rem+u):(a+=t.init,s+=t.add,u+=t.rem)}),t.slice().sort(Q).forEach(function(t){o+="t['"+t.out+"']="+t.set+";"}),o+="return t;",a=Function("cell","t",a),a.prototype.add=Function("v","t",s),a.prototype.rem=Function("v","t",u),a.prototype.set=Function(o),a.prototype.get=n,a.fields=t.map(function(t){return t.out}),a}function Z(t){G.call(this,null,t),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}function tt(t,e,i){return i||t+(e?"_"+e:"")}function et(t){var e,i=this._dims,n=i.length,r=String(i[0](t));for(e=1;e<n;++e)r+="|"+i[e](t);return r}function it(t){G.call(this,null,t)}function nt(t){G.call(this,[],t)}function rt(t){p.call(this,null,at,t)}function at(t){return this.value&&!t.modified()?this.value:e.compare(t.fields,t.orders)}function st(t){G.call(this,null,t)}function ut(t,e,i){switch(e){case"upper":t=t.toUpperCase();break;case"lower":t=t.toLowerCase()}return t.match(i)}function ot(t){G.call(this,null,t)}function lt(t,e,i,n){for(var r,a,s=[],u={},l=t.length,d=0;d<l;++d)for(u[e]=a=t[d],r=0;r<l;++r)u[i]=t[r],n(u)&&(s.push(o(u)),u={},u[e]=a);return s}function dt(t,i){var n=t[Ce];Se.hasOwnProperty(n)||e.error("Unknown distribution function: "+n);var r=Se[n]();for(var a in t)a===Pe?r.data((t.from||i()).map(t[a])):a===Ne?r[a](t[a].map(function(t){return dt(t,i)})):typeof r[a]===Ce&&r[a](t[a]);return r}function ht(t){G.call(this,null,t)}function ft(t){return function(){return t.materialize(t.SOURCE).source}}function ct(t){G.call(this,[+(1/0),-(1/0)],t)}function mt(t,e){p.call(this,t),this.parent=e}function pt(t){G.call(this,{},t),this._keys=e.fastmap(),this._count=0;var i=this._targets=[];i.active=0,i.forEach=function(t){for(var e=0,n=i.active;e<n;++e)t(i[e],e,i)}}function vt(t){p.call(this,null,gt,t)}function gt(t){return this.value&&!t.modified()?this.value:e.isArray(t.name)?e.array(t.name).map(function(t){return e.field(t)}):e.field(t.name,t.as)}function _t(t){G.call(this,e.fastmap(),t)}function yt(t){G.call(this,{},t)}function xt(t){return t.fields.join("|")}function kt(t){G.call(this,null,t)}function wt(t){G.call(this,[],t)}function Dt(t){G.call(this,[],t)}function Ot(t){var i,n=t.method||Ke.value;return null!=Ke[n]?n===Ke.value?(i=void 0!==t.value?t.value:0,function(){return i}):Ke[n]:void e.error("Unrecognized imputation method: "+n)}function qt(t){var e=t.field;return function(t){return t?e(t):NaN}}function bt(t,e,i){var n,r,a,s,u,o,l,d,h,f=function(t){return t(h)},c=[],m=[],p={},v={};for(o=0,d=t.length;o<d;++o)h=t[o],r=(n=i.map(f))+"",l=p[r]||(p[r]=m.push(n)),s=(a=e?e.map(f):Ve)+"",(u=v[s])||(u=v[s]=[],c.push(u),u.values=a),u[l-1]=h;return c.domain=m,c}function Et(t){p.call(this,null,Ft,t)}function Ft(t){return this.value&&!t.modified()?this.value:e.key(t.fields)}function At(t){G.call(this,{},t)}function Rt(t){p.call(this,null,Mt,t)}function Mt(t){if(this.value&&!t.modified())return this.value;var e,i,n,r=+(1/0),a=-(1/0),s=t.extents;for(e=0,i=s.length;e<i;++e)n=s[e],n[0]<r&&(r=n[0]),n[1]>a&&(a=n[1]);return[r,a]}function St(t){p.call(this,null,Nt,t)}function Nt(t){return this.value&&!t.modified()?this.value:t.values.reduce(function(t,e){return t.concat(e)},[])}function Ct(t){G.call(this,null,t)}function Pt(t){pt.call(this,t)}function Ut(t){G.call(this,null,t)}function Lt(t){G.call(this,[],t)}function zt(t){G.call(this,null,t)}function It(t){G.call(this,null,t)}function Tt(t){G.call(this,[],t),this.count=0}function jt(t){G.call(this,null,t),this.modified(!0)}function Wt(t){G.call(this,e.fastmap(),t)}function Gt(t){G.call(this,null,t)}var Kt=1,Vt="_:mod:_",Bt=m.prototype;Bt.set=function(t,i,n,r){var a=this,s=a[t],u=a[Vt];return null!=i&&i>=0?(s[i]!==n||r)&&(s[i]=n,u[i+":"+t]=-1,u[t]=-1):(s!==n||r)&&(a[t]=n,u[t]=e.isArray(n)?n.length:-1),a},Bt.modified=function(t,i){var n,r=this[Vt];if(!arguments.length){for(n in r)if(r[n])return!0;return!1}if(e.isArray(t)){for(n=0;n<t.length;++n)if(r[t[n]])return!0;return!1}return null!=i&&i>=0?i<r[t]||!!r[i+":"+t]:!!r[t]},Bt.clear=function(){return this[Vt]={},this};var $t=0,Ht="pulse",Jt=new m,Qt=1,Xt=2,Yt=p.prototype;Yt.targets=function(){return this._targets||(this._targets=a(e.id))},Yt.set=function(t){return this.value!==t?(this.value=t,1):0},Yt.skip=v(Qt),Yt.modified=v(Xt),Yt.parameters=function(t,i){function n(t,e,n){n instanceof p?(n!==o&&(i&&n.targets().add(o),h.push(n)),d.push({op:n,name:t,index:e})):l.set(t,e,n)}i=i!==!1;var r,a,s,u,o=this,l=o._argval=o._argval||new m,d=o._argops=o._argops||[],h=[];for(r in t)if(a=t[r],r===Ht)e.array(a).forEach(function(t){t instanceof p?t!==o&&(t.targets().add(o),h.push(t)):e.error("Pulse parameters must be operator instances.")}),o.source=a;else if(e.isArray(a))for(l.set(r,-1,Array(s=a.length)),u=0;u<s;++u)n(r,u,a[u]);else n(r,-1,a);return this.marshall().clear(),h},Yt.marshall=function(t){var e,i,n,r,a,s=this._argval||Jt,u=this._argops;if(u&&(n=u.length))for(i=0;i<n;++i)e=u[i],r=e.op,a=r.modified()&&r.stamp===t,s.set(e.name,e.index,r.value,a);return s},Yt.evaluate=function(t){if(this._update){var e=this.marshall(t.stamp),i=this._update(e,t);if(e.clear(),i!==this.value)this.value=i;else if(!this.modified())return t.StopPropagation}},Yt.run=function(t){if(t.stamp<=this.stamp)return t.StopPropagation;var e=this.skip()?(this.skip(!1),0):this.evaluate(t);return this.stamp=t.stamp,this.pulse=e||t};var Zt=function(t,i,n,r){var a=1,s=t instanceof p?t:t&&t.prototype instanceof p?new t:e.isFunction(t)?new p(null,t):(a=0,new p(t,i));return this.rank(s),a&&(r=n,n=i),n&&this.connect(s,s.parameters(n,r)),this.touch(s),s},te=function(t,e){var i,n,r=t.rank;for(i=0,n=e.length;i<n;++i)if(r<e[i].rank)return void this.rerank(t)},ee=0,ie=g.prototype;ie._filter=e.truthy,ie._apply=e.identity,ie.targets=function(){return this._targets||(this._targets=a(e.id))},ie.consume=function(t){return arguments.length?(this._consume=!!t,this):!!this._consume},ie.receive=function(t){if(this._filter(t)){for(var e=this.value=this._apply(t),i=this._targets,n=i?i.length:0,r=0;r<n;++r)i[r].receive(e);this._consume&&(t.preventDefault(),t.stopPropagation())}},ie.filter=function(t){var e=_(t);return this.targets().add(e),e},ie.apply=function(t){var e=_(null,t);return this.targets().add(e),e},ie.merge=function(){var t=_();this.targets().add(t);for(var e=0,i=arguments.length;e<i;++e)arguments[e].targets().add(t);return t},ie.throttle=function(t){var e=-1;return this.filter(function(){var i=Date.now();return i-e>t?(e=i,1):0})},ie.debounce=function(t){function e(){var t=n.dataflow;i.receive(n),n=null,r=null,t&&t.run&&t.run()}var i=_(),n=null,r=null;return this.targets().add(_(null,null,function(i){n=i,r&&clearTimeout(r),r=setTimeout(e,t)})),i},ie.between=function(t,e){var i=!1;return t.targets().add(_(null,null,function(){i=!0})),e.targets().add(_(null,null,function(){i=!1})),this.filter(function(){return i})};var ne=function(t,i,n,r){var a,s=this,u=_(n,r),o=function(t){t.dataflow=s,u.receive(t),s.run()};a="string"==typeof t&&"undefined"!=typeof document?document.querySelectorAll(t):e.array(t);for(var l=0,d=a.length;l<d;++l)a[l].addEventListener(i,o);return u},re={skip:!0},ae=function(t,e,i,n,r){var a=t instanceof p?x:y;return a(this,t,e,i,n,r),this},se={},ue=1,oe=2,le=4,de=ue|oe,he=ue|le,fe=ue|oe|le,ce=8,me=16,pe=32,ve=64,ge=D.prototype;ge.StopPropagation=se,ge.ADD=ue,ge.REM=oe,ge.MOD=le,ge.ADD_REM=de,ge.ADD_MOD=he,ge.ALL=fe,ge.REFLOW=ce,ge.SOURCE=me,ge.NO_SOURCE=pe,ge.NO_FIELDS=ve,ge.fork=function(t){return new D(this.dataflow).init(this,t)},ge.addAll=function(){var t=this;return this.source&&this.source.length!==this.add.length?(t=new D(this.dataflow).init(this),t.add=t.source,t):t},ge.init=function(t,e){var i=this;return i.stamp=t.stamp,i.encode=t.encode,!t.fields||e&ve||(i.fields=t.fields),i.add=e&ue?(i.addF=t.addF,t.add):(i.addF=null,[]),i.rem=e&oe?(i.remF=t.remF,t.rem):(i.remF=null,[]),i.mod=e&le?(i.modF=t.modF,t.mod):(i.modF=null,[]),i.source=e&pe?(i.srcF=null,null):(i.srcF=t.srcF,t.source),i},ge.runAfter=function(t){this.dataflow.runAfter(t)},ge.changed=function(t){var e=t||fe;return e&ue&&this.add.length||e&oe&&this.rem.length||e&le&&this.mod.length},ge.reflow=function(t){if(t)return this.fork(fe).reflow();var e=this.add.length,i=this.source&&this.source.length;return i&&i!==e&&(this.mod=this.source,e&&this.filter(le,q(this,ue))),this},ge.modifies=function(t){var i=e.array(t),n=this.fields||(this.fields={});return i.forEach(function(t){n[t]=!0}),this},ge.modified=function(t){var i=this.fields;return!(!this.mod.length||!i)&&(arguments.length?e.isArray(t)?t.some(function(t){return i[t]}):i[t]:!!i)},ge.filter=function(t,e){var i=this;return t&ue&&(i.addF=O(i.addF,e)),t&oe&&(i.remF=O(i.remF,e)),t&le&&(i.modF=O(i.modF,e)),t&me&&(i.srcF=O(i.srcF,e)),i},ge.materialize=function(t){t=t||fe;var e=this;return t&ue&&e.addF&&(e.add=e.add.filter(e.addF),e.addF=null),t&oe&&e.remF&&(e.rem=e.rem.filter(e.remF),e.remF=null),t&le&&e.modF&&(e.mod=e.mod.filter(e.modF),e.modF=null),t&me&&e.srcF&&(e.source=e.source.filter(e.srcF),e.srcF=null),e},ge.visit=function(t,i){var n,r,a=i;return t&me?(e.visitArray(this.source,this.srcF,a),this):(t&ue&&e.visitArray(this.add,this.addF,a),t&oe&&e.visitArray(this.rem,this.remF,a),t&le&&e.visitArray(this.mod,this.modF,a),t&ce&&(n=this.source)&&(r=this.add.length+this.mod.length,r===n.length||(r?e.visitArray(n,q(this,he),a):e.visitArray(n,this.srcF,a))),this)};var _e={skip:!1,force:!1},ye=e.inherits(S,D);ye.fork=function(){return arguments.length&&arguments[0]&D.prototype.ALL&&e.error("MultiPulse fork does not support tuple change sets."),new D(this.dataflow).init(this,0)},ye.changed=function(t){return this.changes&t},ye.modified=function(t){var i=this,n=i.fields;return n&&i.changes&i.MOD?e.isArray(t)?t.some(function(t){return n[t]}):n[t]:0},ye.filter=function(){e.error("MultiPulse does not support filtering.")},ye.materialize=function(){e.error("MultiPulse does not support materialization.")},ye.visit=function(t,e){var i,n,r=this.pulses;for(i=0,n=r.length;i<n;++i)r[i].stamp===this.stamp&&r[i].visit(t,e);return this};var xe=z.prototype;xe.size=function(){return this.nodes.length},xe.clear=function(){return this.nodes=[],this},xe.peek=function(){return this.nodes[0]},xe.push=function(t){var e=this.nodes;return e.push(t),I(e,0,e.length-1,this.cmp)},xe.pop=function(){var t,e=this.nodes,i=e.pop();return e.length?(t=e[0],e[0]=i,T(e,0,this.cmp)):t=i,t},xe.replace=function(t){var e=this.nodes,i=e[0];return e[0]=t,T(e,0,this.cmp),i},xe.pushpop=function(t){var e=this.nodes,i=e[0];return e.length&&this.cmp(i,t)<0&&(e[0]=t,t=i,T(e,0,this.cmp)),t};var ke=j.prototype;ke.stamp=function(){return this._clock},ke.loader=function(t){return arguments.length?(this._loader=t,this):this._loader},ke.cleanThreshold=1e4,ke.add=Zt,ke.connect=te,ke.rank=k,ke.rerank=w,ke.pulse=F,ke.touch=b,ke.update=E,ke.changeset=c,ke.ingest=A,ke.request=M,ke.events=ne,ke.on=ae,ke.run=N,ke.runAsync=C,ke.runAfter=P,ke._enqueue=U,ke._getPulse=L,ke.warn=W("warn"),ke.info=W("info"),ke.debug=W("debug"),ke.logLevel=W("level"),ke.error=function(t){throw t};var we=e.inherits(G,p);we.evaluate=function(t){var e=this.marshall(t.stamp),i=this.transform(e,t);return e.clear(),i},we.transform=function(){};var De={},Oe={},qe=$.prototype;qe.add=function(t){this._add.push(t)},qe.rem=function(t){this._rem.push(t)},qe.values=function(){if(this._get=null,0===this._rem.length)return this._add;var t,e,i,n=this._add,r=this._rem,a=this._key,s=n.length,u=r.length,o=Array(s-u),l={};for(t=0;t<u;++t)l[r[t][a]]=1;for(t=0,e=0;t<s;++t)l[(i=n[t])[a]]?l[i[a]]=0:o[e++]=i;return this._rem=[],this._add=o},qe.distinct=function(t){for(var e,i=this.values(),n=i.length,r={},a=0;--n>=0;)e=t(i[n])+"",r.hasOwnProperty(e)||(r[e]=1,++a);return a},qe.extent=function(t){if(this._get!==t||!this._ext){var i=this.values(),n=e.extentIndex(i,t);this._ext=[i[n[0]],i[n[1]]],this._get=t}return this._ext},qe.argmin=function(t){return this.extent(t)[0]||{}},qe.argmax=function(t){return this.extent(t)[1]||{}},qe.min=function(t){var e=this.extent(t)[0];return null!=e?t(e):+(1/0)},qe.max=function(t){var e=this.extent(t)[1];return null!=e?t(e):-(1/0)},qe.quartile=function(t){return this._get===t&&this._q||(this._q=n.quartiles(this.values(),t),this._get=t),this._q},qe.q1=function(t){return this.quartile(t)[0]},qe.q2=function(t){return this.quartile(t)[1]},qe.q3=function(t){return this.quartile(t)[2]},qe.ci=function(t){return this._get===t&&this._ci||(this._ci=n.bootstrapCI(this.values(),1e3,.05,t),this._get=t),this._ci},qe.ci0=function(t){return this.ci(t)[0]},qe.ci1=function(t){return this.ci(t)[1]};var be={values:J({name:"values",init:"cell.store = true;",set:"cell.data.values()",idx:-1}),count:J({name:"count",set:"cell.num"}),missing:J({name:"missing",set:"this.missing"}),valid:J({name:"valid",set:"this.valid"}),sum:J({name:"sum",init:"this.sum = 0;",add:"this.sum += v;",rem:"this.sum -= v;",set:"this.sum"}),mean:J({name:"mean",init:"this.mean = 0;",add:"var d = v - this.mean; this.mean += d / this.valid;",rem:"var d = v - this.mean; this.mean -= this.valid ? d / this.valid : this.mean;",set:"this.mean"}),average:J({name:"average",set:"this.mean",req:["mean"],idx:1}),variance:J({name:"variance",init:"this.dev = 0;",add:"this.dev += d * (v - this.mean);",rem:"this.dev -= d * (v - this.mean);",set:"this.valid > 1 ? this.dev / (this.valid-1) : 0",req:["mean"],idx:1}),variancep:J({name:"variancep",set:"this.valid > 1 ? this.dev / this.valid : 0",req:["variance"],idx:2}),stdev:J({name:"stdev",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : 0",req:["variance"],idx:2}),stdevp:J({name:"stdevp",set:"this.valid > 1 ? Math.sqrt(this.dev / this.valid) : 0",req:["variance"],idx:2}),stderr:J({name:"stderr",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : 0",req:["variance"],idx:2}),distinct:J({name:"distinct",set:"cell.data.distinct(this.get)",req:["values"],idx:3}),ci0:J({name:"ci0",set:"cell.data.ci0(this.get)",req:["values"],idx:3}),ci1:J({name:"ci1",set:"cell.data.ci1(this.get)",req:["values"],idx:3}),median:J({name:"median",set:"cell.data.q2(this.get)",req:["values"],idx:3}),q1:J({name:"q1",set:"cell.data.q1(this.get)",req:["values"],idx:3}),q3:J({name:"q3",set:"cell.data.q3(this.get)",req:["values"],idx:3}),argmin:J({name:"argmin",add:"if (v < this.min) this.argmin = t;",rem:"if (v <= this.min) this.argmin = null;",set:"this.argmin || cell.data.argmin(this.get)",req:["min"],str:["values"],idx:3}),argmax:J({name:"argmax",add:"if (v > this.max) this.argmax = t;",rem:"if (v >= this.max) this.argmax = null;",set:"this.argmax || cell.data.argmax(this.get)",req:["max"],str:["values"],idx:3}),min:J({name:"min",init:"this.min = null;",add:"if (v < this.min || this.min === null) this.min = v;",rem:"if (v <= this.min) this.min = NaN;",set:"this.min = (isNaN(this.min) ? cell.data.min(this.get) : this.min)",str:["values"],idx:4}),max:J({name:"max",init:"this.max = null;",add:"if (v > this.max || this.max === null) this.max = v;",rem:"if (v >= this.max) this.max = NaN;",set:"this.max = (isNaN(this.max) ? cell.data.max(this.get) : this.max)",str:["values"],idx:4})},Ee=e.inherits(Z,G);Ee.transform=function(t,e){var i,n=this,r=e.fork(e.NO_SOURCE|e.NO_FIELDS);return this.stamp=r.stamp,this.value&&((i=t.modified())||e.modified(this._inputs))?(this._prev=this.value,this.value=i?this.init(t):{},e.visit(e.SOURCE,function(t){n.add(t)})):(this.value=this.value||this.init(t),e.visit(e.REM,function(t){n.rem(t)}),e.visit(e.ADD,function(t){n.add(t)})),r.modifies(this._outputs),n._drop=t.drop!==!1,n.changes(r)},Ee.init=function(t){function i(t){for(var e,i=t.fields,r=0,s=i.length;r<s;++r)a[e=i[r]]||(a[e]=1,n.push(e))}var n=this._inputs=[],r=this._outputs=[],a={};this._dims=e.array(t.groupby),this._dnames=this._dims.map(function(t){var n=e.accessorName(t);return i(t),r.push(n),n}),this.cellkey=t.key?t.key:0===this._dims.length?function(){return""}:1===this._dims.length?this._dims[0]:et,this._countOnly=!0,this._counts=[],this._measures=[];var s,u,o,l,d,h,f=t.fields||[null],c=t.ops||["count"],m=t.as||[],p=f.length,v={};for(p!==c.length&&e.error("Unmatched number of fields and aggregate ops."),h=0;h<p;++h)s=f[h],u=c[h],null==s&&"count"!==u&&e.error("Null aggregate field specified."),l=e.accessorName(s),d=tt(u,l,m[h]),r.push(d),"count"!==u?(o=v[l],o||(i(s),o=v[l]=[],o.field=s,this._measures.push(o)),"count"!==u&&(this._countOnly=!1),o.push(H(u,d))):this._counts.push(d);return this._measures=this._measures.map(function(t){return Y(t,t.field)}),{}},Ee.cellkey=et,Ee.cell=function(t,e){var i=this.value[t];return i?0===i.num&&this._drop&&i.stamp<this.stamp?(i.stamp=this.stamp,this._adds[this._alen++]=i):i.stamp<this.stamp&&(i.stamp=this.stamp,this._mods[this._mlen++]=i):(i=this.value[t]=this.newcell(t,e),this._adds[this._alen++]=i),i},Ee.newcell=function(t,e){var i={key:t,num:0,agg:null,tuple:this.newtuple(e,this._prev&&this._prev[t]),stamp:this.stamp,store:!1};if(!this._countOnly){var n,r=this._measures,a=r.length;for(i.agg=Array(a),n=0;n<a;++n)i.agg[n]=new r[n](i,i.tuple)}return i.store&&(i.data=new $),i},Ee.newtuple=function(t,e){var i,n,r=this._dnames,a=this._dims,s={};for(i=0,n=a.length;i<n;++i)s[r[i]]=a[i](t);return e?h(e.tuple,s):o(s)},Ee.add=function(t){var e,i,n,r=this.cellkey(t),a=this.cell(r,t);if(a.num+=1,!this._countOnly)for(a.store&&a.data.add(t),e=a.agg,i=0,n=e.length;i<n;++i)e[i].add(e[i].get(t),t)},Ee.rem=function(t){var e,i,n,r=this.cellkey(t),a=this.cell(r,t);if(a.num-=1,!this._countOnly)for(a.store&&a.data.rem(t),e=a.agg,i=0,n=e.length;i<n;++i)e[i].rem(e[i].get(t),t)},Ee.celltuple=function(t){var e,i,n,r=t.tuple,a=this._counts;for(t.store&&t.data.values(),i=0,n=a.length;i<n;++i)r[a[i]]=t.num;if(!this._countOnly)for(e=t.agg,i=0,n=e.length;i<n;++i)e[i].set();return r},Ee.changes=function(t){var e,i,n,r,a=this._adds,s=this._mods,u=this._prev,o=this._drop,l=t.add,d=t.rem,h=t.mod;if(u)for(i in u)d.push(u[i].tuple);for(n=0,r=this._alen;n<r;++n)l.push(this.celltuple(a[n])),a[n]=null;for(n=0,r=this._mlen;n<r;++n)e=s[n],(0===e.num&&o?d:h).push(this.celltuple(e)),s[n]=null;return this._alen=this._mlen=0,this._prev=null,t};var Fe=e.inherits(it,G);Fe.transform=function(t,i){var n=this._bins(t),r=n.step,a=t.as||["bin0","bin1"],s=a[0],u=a[1],o=t.modified()?(i=i.reflow(!0),i.SOURCE):i.modified(e.accessorFields(t.field))?i.ADD_MOD:i.ADD;return i.visit(o,function(t){t[u]=(t[s]=n(t))+r}),i.modifies(a)},Fe._bins=function(t){if(this.value&&!t.modified())return this.value;var i=t.field,r=n.bin(t),a=r.start,s=r.step,u=function(t){var e=i(t);return null==e?null:a+s*Math.floor((+e-a)/s)};return u.step=s,this.value=e.accessor(u,e.accessorFields(i),t.name||"bin_"+e.accessorName(i))};var Ae=e.inherits(nt,G);Ae.transform=function(t,i){var n,r=i.fork(i.ALL),a=i.changed(i.ADD),s=i.changed(),u=t.sort,o=this.value,l=function(t){o.push(t)},d=0;return r.rem.length&&(n={},r.visit(r.REM,function(t){n[t._id]=1,++d}),o=o.filter(function(t){return!n[t._id]})),u?((t.modified("sort")||i.modified(u.fields))&&(o.sort(u),s=!0),a&&(o=e.merge(u,o,r.add.sort(u)))):a&&r.visit(r.ADD,l),this.modified(s),this.value=r.source=o,r},e.inherits(rt,p);var Re=e.inherits(st,G);Re.transform=function(t,e){function i(e){return function(i){for(var n,r=ut(u(i),t.case,a)||[],o=0,l=r.length;o<l;++o)s.test(n=r[o])||e(n)}}var n=this._parameterCheck(t,e),r=this._counts,a=this._match,s=this._stop,u=t.field,o=t.as||["text","count"],l=i(function(t){r[t]=1+(r[t]||0)}),d=i(function(t){r[t]-=1});return n?e.visit(e.SOURCE,l):(e.visit(e.ADD,l),e.visit(e.REM,d)),this._finish(e,o)},Re._parameterCheck=function(t,e){var i=!1;return!t.modified("stopwords")&&this._stop||(this._stop=new RegExp("^"+(t.stopwords||"")+"$","i"),i=!0),!t.modified("pattern")&&this._match||(this._match=new RegExp(t.pattern||"[\\w']+","g"),i=!0),(t.modified("field")||e.modified(t.field.fields))&&(i=!0),i&&(this._counts={}),i},Re._finish=function(t,e){var i,n,r,a=this._counts,s=this._tuples||(this._tuples={}),u=e[0],l=e[1],d=t.fork();for(i in a)n=s[i],r=a[i]||0,!n&&r?(s[i]=n=o({}),n[u]=i,n[l]=r,d.add.push(n)):0===r?(n&&d.rem.push(n),a[i]=null,s[i]=null):n[l]!==r&&(n[l]=r,d.mod.push(n));return d.modifies(e)};var Me=e.inherits(ot,G);Me.transform=function(t,i){var n=i.fork(i.NO_SOURCE),r=this.value,a=t.as||["a","b"],s=a[0],u=a[1],o=!r||i.changed(i.ADD_REM)||t.modified("as")||t.modified("filter");return o?(r&&(n.rem=r),n.add=this.value=lt(i.source,s,u,t.filter||e.truthy)):n.mod=r,n.source=this.value,n.modifies(a)};var Se={kde:n.randomKDE,mixture:n.randomMixture,normal:n.randomNormal,uniform:n.randomUniform},Ne="distributions",Ce="function",Pe="field",Ue=e.inherits(ht,G);Ue.transform=function(t,i){var n=i.fork(i.NO_SOURCE|i.NO_FIELDS);if(!this.value||i.changed()||t.modified()){var a=dt(t.distribution,ft(i)),s=t.method||"pdf";"pdf"!==s&&"cdf"!==s&&e.error("Invalid density method: "+s),t.extent||a.data||e.error("Missing density extent parameter."),s=a[s];var u=t.as||["value","density"],l=t.extent||r.extent(a.data()),d=(l[1]-l[0])/(t.steps||100),h=r.range(l[0],l[1]+d/2,d).map(function(t){var e={};return e[u[0]]=t,e[u[1]]=s(t),o(e)});this.value&&(n.rem=this.value),this.value=n.add=n.source=h}return n};var Le=e.inherits(ct,G);Le.transform=function(t,e){var i,n=this.value,r=t.field,a=n[0],s=n[1],u=e.ADD;i=e.changed()||e.modified(r.fields)||t.modified("field"),i&&(u=e.SOURCE,a=+(1/0),s=-(1/0)),e.visit(u,function(t){var e=r(t);e<a&&(a=e),e>s&&(s=e)}),this.value=[a,s]};var ze=e.inherits(mt,p);ze.connect=function(t){return this.targets().add(t),t.source=this},ze.add=function(t){this.value.add.push(t)},ze.rem=function(t){this.value.rem.push(t)},ze.mod=function(t){this.value.mod.push(t)},ze.init=function(t){this.value.init(t,t.NO_SOURCE)},ze.evaluate=function(){return this.value};var Ie=e.inherits(pt,G);Ie.activate=function(t){this._targets[this._targets.active++]=t},Ie.subflow=function(t,e,i,n){var r,a,s=this.value,u=s.hasOwnProperty(t)&&s[t];return u?u.value.stamp<i.stamp&&(u.init(i),this.activate(u)):(a=n||(a=this._group[t])&&a.tuple,r=i.dataflow,u=r.add(new mt(i.fork(i.NO_SOURCE),this)).connect(e(r,t,this._count++,a)),s[t]=u,this.activate(u)),u},Ie.transform=function(t,e){function i(t){return r.subflow(t,s,e)}var n=e.dataflow,r=this,a=t.key,s=t.subflow,u=this._keys,o=t.modified("key");return this._group=t.group||{},this._targets.active=0,e.visit(e.ADD,function(t){var e=a(t);u.set(t._id,e),i(e).add(t)}),e.visit(e.REM,function(t){var e=u.get(t._id);u.delete(t._id),i(e).rem(t)}),o||e.modified(a.fields)?e.visit(e.MOD,function(t){var e=u.get(t._id),n=a(t);e===n?i(n).mod(t):(u.set(t._id,n),i(e).rem(t),i(n).add(t))}):e.changed(e.MOD)&&e.visit(e.MOD,function(t){i(u.get(t._id)).mod(t)}),o&&e.visit(e.REFLOW,function(t){var e=u.get(t._id),n=a(t);e!==n&&(u.set(t._id,n),i(e).rem(t),i(n).add(t))}),u.empty>n.cleanThreshold&&n.runAfter(u.clean),e},e.inherits(vt,p);var Te=e.inherits(_t,G);Te.transform=function(t,e){function i(e){var i=l(e,t),n=r.get(e._id);i&&n?(r.delete(e._id),s.push(e)):i||n?d&&i&&!n&&o.push(e):(r.set(e._id,1),u.push(e))}var n=e.dataflow,r=this.value,a=e.fork(),s=a.add,u=a.rem,o=a.mod,l=t.expr,d=!0;return e.visit(e.REM,function(t){r.has(t._id)?r.delete(t._id):u.push(t)}),e.visit(e.ADD,function(e){l(e,t)?s.push(e):r.set(e._id,1)}),e.visit(e.MOD,i),t.modified()&&(d=!1,e.visit(e.REFLOW,i)),r.empty>n.cleanThreshold&&n.runAfter(r.clean),a};var je=e.inherits(yt,G);je.transform=function(t,e){function i(t){for(var e,i=a[t._id]=Array(m),n=0;n<m;++n)e=i[n]=l(t),e[h]=c[n],e[f]=u[n](t),v.add.push(e)}function n(t){for(var e,i=a[t._id],n=0;n<m;++n)_&1<<n&&(e=d(t,i[n],p),e[h]=c[n],e[f]=u[n](t),v.mod.push(e))}var r,a=this.value,s=t.modified("fields"),u=t.fields,o=t.as||["key","value"],h=o[0],f=o[1],c=u.map(xt),m=u.length,p=e.stamp,v=e.fork(e.NO_SOURCE),g=0,_=0;if(s){for(r in a)v.rem.push.apply(v.rem,a[r]);a=this.value={},e.visit(e.SOURCE,i)}else{for(e.visit(e.ADD,i);g<m;++g)e.modified(u[g].fields)&&(_|=1<<g);_&&e.visit(e.MOD,n),e.visit(e.REM,function(t){v.rem.push.apply(v.rem,a[t._id]),a[t._id]=null})}return v.modifies(o)};var We=e.inherits(kt,G);We.transform=function(t,e){function i(e){e[r]=n(e,t)}var n=t.expr,r=t.as,a=t.modified(),s=t.initonly?e.ADD:a?e.SOURCE:e.modified(n.fields)?e.ADD_MOD:e.ADD;return a&&(e=e.materialize().reflow(!0)),e.visit(s,i).modifies(r)};var Ge=e.inherits(wt,G);Ge.transform=function(t,e){var i,n,r,a=this.value,s=e.fork(e.ALL),u=t.size-a.length,l=t.generator; | ||
if(u>0){for(i=[];--u>=0;)i.push(r=o(l(t))),a.push(r);s.add=s.add.length?s.materialize(s.ADD).add.concat(i):i}else n=a.slice(0,-u),s.rem=s.rem.length?s.materialize(s.REM).rem.concat(n):n,a=a.slice(-u);return s.source=this.value=a,s};var Ke={value:"value",median:r.median,mean:r.mean,min:r.min,max:r.max},Ve=[],Be=e.inherits(Dt,G);Be.transform=function(t,i){var n,r,a,s,u,l,d,h,f,c,m=i.fork(i.ALL),p=Ot(t),v=qt(t),g=e.accessorName(t.field),_=t.groupby.map(e.accessorName),y=t.orderby.map(e.accessorName),x=bt(i.source,t.groupby,t.orderby),k=[],w=this.value,D=x.domain.length;for(u=0,h=x.length;u<h;++u)for(n=x[u],a=n.values,r=NaN,d=0;d<D;++d)if(null==n[d]){for(s=x.domain[d],c={_impute:!0},l=0,f=a.length;l<f;++l)c[_[l]]=a[l];for(l=0,f=s.length;l<f;++l)c[y[l]]=s[l];c[g]=isNaN(r)?r=p(n,v):r,k.push(o(c))}return k.length&&(m.add=m.materialize(m.ADD).add.concat(k)),w.length&&(m.rem=m.materialize(m.REM).rem.concat(w)),this.value=k,m},e.inherits(Et,p);var $e=e.inherits(At,G);$e.transform=function(t,e){var i,n,r,a,s=e,u=t.as,o=t.fields,l=t.index,d=null==t.default?null:t.default,h=t.modified(),f=e.ADD;return 1===o.length?(n=o[0],r=u[0],i=function(t){var e=l.get(n(t));t[r]=null==e?d:e}):i=function(t){for(var e,i=0,n=o.length;i<n;++i)e=l.get(o[i](t)),t[u[i]]=null==e?d:e},h?(f=e.SOURCE,s=e.reflow(!0)):(a=o.some(function(t){return e.modified(t.fields)}),f|=a?e.MOD:0),e.visit(f,i),s.modifies(u)},e.inherits(Rt,p),e.inherits(St,p),e.inherits(Ct,G),Ct.prototype.transform=function(t,e){return this.modified(t.modified()),this.value=t,e.fork(e.NO_SOURCE|e.NO_FIELDS)};var He=e.inherits(Pt,pt);He.transform=function(t,i){var n=this,r=t.subflow,a=t.field;return t.modified("field")&&e.error("PreFacet does not support field modification."),this._targets.active=0,i.visit(i.MOD,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.mod(t)}):e.mod(t)}),i.visit(i.ADD,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.add(o(t))}):e.add(t)}),i.visit(i.REM,function(t){var e=n.subflow(t._id,r,i,t);a?a(t).forEach(function(t){e.rem(t)}):e.rem(t)}),i};var Je=e.inherits(Ut,G);Je.transform=function(t,e){return this.value=t.value,t.modified("value")?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation};var Qe=e.inherits(Lt,G);Qe.transform=function(t,e){if(t.modified()){var i=e.materialize().fork(e.MOD);return i.rem=e.rem.concat(this.value),i.source=this.value=r.range(t.start,t.stop,t.step).map(o),i.add=e.add.concat(this.value),i}};var Xe=e.inherits(zt,G);Xe.transform=function(t,i){i.source||e.error("Rank transform requires an upstream data source.");var n,r=t.normalize,a=t.field,s=t.as||"rank",u={},o=-1;return a?(i.visit(i.SOURCE,function(t){var e=a(t);null==u[e]&&(u[e]=++o)}),i.visit(i.SOURCE,r&&--o?function(t){t[s]=u[a(t)]/o}:function(t){t[s]=u[a(t)]})):(o+=i.source.length,n=-1,i.visit(i.SOURCE,r&&o?function(t){t[s]=++n/o}:function(t){t[s]=++n})),i.reflow(t.modified()).modifies(s)};var Ye=e.inherits(It,G);Ye.transform=function(t,e){var i,n=this.value||(i=e=e.addAll(),this.value={});return t.derive&&(i=e.fork(),e.visit(e.ADD,function(t){var e=l(t);n[t._id]=e,i.add.push(e)}),e.visit(e.MOD,function(t){i.mod.push(d(t,n[t._id]))}),e.visit(e.REM,function(t){i.rem.push(n[t._id]),n[t._id]=null})),i};var Ze=e.inherits(Tt,G);Ze.transform=function(t,e){function i(t){var e,i;s.length<a?s.push(t):(i=~~(u*Math.random()),i<s.length&&i>=o&&(e=s[i],l[e._id]&&n.rem.push(e),s[i]=t)),++u}var n=e.fork(),r=t.modified("size"),a=t.size,s=this.value,u=this.count,o=0,l=s.reduce(function(t,e){return t[e._id]=1,t},{});if(e.rem.length&&(e.visit(e.REM,function(t){l[t._id]&&(l[t._id]=-1,n.rem.push(t)),--u}),s=s.filter(function(t){return l[t._id]!==-1})),(e.rem.length||r)&&s.length<a&&e.source&&(o=u=s.length,e.visit(e.SOURCE,function(t){l[t._id]||i(t)}),o=-1),r&&s.length>a){for(var d=0,h=s.length-a;d<h;++d)l[s[d]._id]=-1,n.rem.push(s[d]);s=s.slice(h)}return e.mod.length&&e.visit(e.MOD,function(t){l[t._id]&&n.mod.push(t)}),e.add.length&&e.visit(e.ADD,i),(e.add.length||o<0)&&(n.add=s.filter(function(t){return!l[t._id]})),this.count=u,this.value=n.source=s,n};var ti=e.inherits(jt,G);ti.transform=function(t,e){return this.value=e.source,e.changed()?e.fork(e.NO_SOURCE|e.NO_FIELDS):e.StopPropagation};var ei=e.inherits(Wt,G);ei.transform=function(t,e){function i(t){a.set(r(t),t)}var n=e.dataflow,r=t.field,a=this.value,s=!0;return t.modified("field")||e.modified(r.fields)?(a.clear(),e.visit(e.SOURCE,i)):e.changed()?(e.visit(e.REM,function(t){a.delete(r(t))}),e.visit(e.ADD,i)):s=!1,this.modified(s),a.empty>n.cleanThreshold&&n.runAfter(a.clean),e.fork()};var ii=e.inherits(Gt,G);ii.transform=function(t,e){var i=!this.value||t.modified("field")||t.modified("sort")||e.changed()||t.sort&&e.modified(t.sort.fields);i&&(this.value=(t.sort?e.source.slice().sort(t.sort):e.source).map(t.field))};var ni={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:["count","valid","missing","distinct","sum","mean","average","variance","variancep","stdev","stdevp","median","q1","q3","modeskew","min","max","argmin","argmax"]},{name:"as",type:"string",array:!0},{name:"drop",type:"boolean",default:!0},{name:"key",type:"field"}]},ri={type:"Bin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"maxbins",type:"number",default:20},{name:"base",type:"number",default:10},{name:"divide",type:"number",array:!0,default:[5,2]},{name:"extent",type:"number",array:!0,length:2,required:!0},{name:"step",type:"number"},{name:"steps",type:"number",array:!0},{name:"minstep",type:"number",default:0},{name:"nice",type:"boolean",default:!0},{name:"name",type:"string"},{name:"as",type:"string",array:!0,length:2,default:["bin0","bin1"]}]},ai={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},si={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]},ui={type:"Cross",metadata:{source:!0,generates:!0,changes:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]},oi=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}],li={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:oi},{name:"weights",type:"number",array:!0}]},di={type:"Density",metadata:{generates:!0,source:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number",default:100},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:oi.concat(li)},{name:"as",type:"string",array:!0}]},hi={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},fi={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},ci={type:"Fold",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,length:2,default:["key","value"]}]},mi={type:"Formula",metadata:{modifies:!0},params:[{name:"expr",type:"expr",required:!0},{name:"as",type:"string",required:!0},{name:"initonly",type:"boolean"}]},pi={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"orderby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},vi={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,required:!0},{name:"default",default:null}]},gi={type:"Range",metadata:{generates:!0,source:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1}],output:["value"]},_i={type:"Rank",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"normalize",type:"boolean",default:!1},{name:"as",type:"string",default:"rank"}]},yi={type:"Sample",metadata:{source:!0,changes:!0},params:[{name:"size",type:"number",default:1e3}]};K(ni,Z),K(ri,it),K(ai,nt),K(si,st),K(ui,ot),K(di,ht),K(hi,ct),K(fi,_t),K(ci,yt),K(mi,kt),K(pi,Dt),K(vi,At),K(gi,Lt),K(_i,zt),K(yi,Tt),B("Compare",rt),B("Facet",pt),B("Field",vt),B("Generate",wt),B("Key",Et),B("MultiExtent",Rt),B("MultiValues",St),B("Params",Ct),B("PreFacet",Pt),B("Proxy",Ut),B("Relay",It),B("Sieve",jt),B("Subflow",mt),B("TupleIndex",Wt),B("Values",Gt),t.UniqueList=a,t.changeset=c,t.isChangeSet=f,t.Dataflow=j,t.EventStream=g,t.Parameters=m,t.Pulse=D,t.MultiPulse=S,t.Operator=p,t.Transform=G,t.ingest=o,t.tupleid=s,t.definition=V,t.definitions=Oe,t.register=K,t.transform=B,t.transforms=De,Object.defineProperty(t,"__esModule",{value:!0})}); |
@@ -6,4 +6,5 @@ export default { | ||
{ "name": "expr", "type": "expr", "required": true }, | ||
{ "name": "as", "type": "string", "required": true } | ||
{ "name": "as", "type": "string", "required": true }, | ||
{ "name": "initonly", "type": "boolean" } | ||
] | ||
}; |
{ | ||
"name": "vega-dataflow", | ||
"version": "2.0.0-beta.9", | ||
"version": "2.0.0-beta.10", | ||
"description": "Reactive dataflow processing.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -15,6 +15,2 @@ import {isArray} from 'vega-util'; | ||
function key(name, index) { | ||
return (index != null && index >= 0 ? index + ':' : '') + name; | ||
} | ||
/** | ||
@@ -39,11 +35,8 @@ * Set a parameter value. If the parameter value changes, the parameter | ||
v[index] = value; | ||
mod[key(name, index)] = 1; | ||
mod[name] = 1; | ||
mod[index + ':' + name] = -1; | ||
mod[name] = -1; | ||
} | ||
} else if (v !== value || force) { | ||
o[name] = value; | ||
mod[name] = 1; | ||
if (isArray(value)) value.forEach(function(v, i) { | ||
mod[key(name, i)] = 1; | ||
}); | ||
mod[name] = isArray(value) ? value.length : -1; | ||
} | ||
@@ -75,3 +68,5 @@ | ||
} | ||
return !!mod[key(name, index)]; | ||
return (index != null && index >= 0) | ||
? (index < mod[name] || !!mod[index + ':' + name]) | ||
: !!mod[name]; | ||
}; | ||
@@ -78,0 +73,0 @@ |
@@ -316,3 +316,3 @@ import {array, isArray, visitArray} from 'vega-util'; | ||
sum = this.add.length + this.mod.length; | ||
if (sum === src) { | ||
if (sum === src.length) { | ||
// do nothing | ||
@@ -319,0 +319,0 @@ } else if (sum) { |
@@ -10,2 +10,4 @@ import Transform from '../Transform'; | ||
* @param {string} params.as - The field name under which to save the result. | ||
* @param {boolean} [params.initonly=false] - If true, the formula is applied to | ||
* added tuples only, and does not update in response to modifications. | ||
*/ | ||
@@ -21,3 +23,7 @@ export default function Formula(params) { | ||
as = _.as, | ||
mod; | ||
mod = _.modified(), | ||
flag = _.initonly ? pulse.ADD | ||
: mod ? pulse.SOURCE | ||
: pulse.modified(func.fields) ? pulse.ADD_MOD | ||
: pulse.ADD; | ||
@@ -28,11 +34,8 @@ function set(t) { | ||
if (_.modified()) { | ||
if (mod) { | ||
// parameters updated, need to reflow | ||
pulse = pulse.materialize().reflow(true).visit(pulse.SOURCE, set); | ||
} else { | ||
mod = pulse.modified(func.fields); | ||
pulse.visit(mod ? pulse.ADD_MOD : pulse.ADD, set); | ||
pulse = pulse.materialize().reflow(true); | ||
} | ||
return pulse.modifies(as); | ||
return pulse.visit(flag, set).modifies(as); | ||
}; |
@@ -25,3 +25,3 @@ import Facet from './Facet'; | ||
if (_.modified('field') || field && pulse.modified(field.fields)) { | ||
if (_.modified('field')) { | ||
error('PreFacet does not support field modification.'); | ||
@@ -32,2 +32,7 @@ } | ||
pulse.visit(pulse.MOD, function(t) { | ||
var sf = self.subflow(t._id, flow, pulse, t); | ||
field ? field(t).forEach(function(_) { sf.mod(_); }) : sf.mod(t); | ||
}); | ||
pulse.visit(pulse.ADD, function(t) { | ||
@@ -34,0 +39,0 @@ var sf = self.subflow(t._id, flow, pulse, t); |
@@ -7,2 +7,3 @@ import Transform from '../Transform'; | ||
* pulse contains some added, removed or modified tuples. | ||
* @param {object} params - The parameters for this operator. | ||
* @constructor | ||
@@ -9,0 +10,0 @@ */ |
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
287269
7381