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

vega-transforms

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-transforms - npm Package Compare versions

Comparing version 4.4.1 to 4.4.2

2

build/vega-transforms.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-dataflow"),require("vega-statistics"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-dataflow","vega-statistics","d3-array"],t):t(((e=e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.vega,e.d3)}(this,(function(e,t,n,i,a){"use strict";function r(e){return e&&e.length?1===e.length?e[0]:(t=e,function(e){for(var n=t.length,i=1,a=String(t[0](e));i<n;++i)a+="|"+t[i](e);return a}):function(){return""};var t}function s(e,t,n){return n||e+(t?"_"+t:"")}var u={values:d({name:"values",init:"cell.store = true;",set:"cell.data.values()",idx:-1}),count:d({name:"count",set:"cell.num"}),__count__:d({name:"count",set:"this.missing + this.valid"}),missing:d({name:"missing",set:"this.missing"}),valid:d({name:"valid",set:"this.valid"}),sum:d({name:"sum",init:"this.sum = 0;",add:"this.sum += +v;",rem:"this.sum -= v;",set:"this.sum"}),mean:d({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.valid ? this.mean : undefined"}),average:d({name:"average",set:"this.valid ? this.mean : undefined",req:["mean"],idx:1}),variance:d({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) : undefined",req:["mean"],idx:1}),variancep:d({name:"variancep",set:"this.valid > 1 ? this.dev / this.valid : undefined",req:["variance"],idx:2}),stdev:d({name:"stdev",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : undefined",req:["variance"],idx:2}),stdevp:d({name:"stdevp",set:"this.valid > 1 ? Math.sqrt(this.dev / this.valid) : undefined",req:["variance"],idx:2}),stderr:d({name:"stderr",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : undefined",req:["variance"],idx:2}),distinct:d({name:"distinct",set:"cell.data.distinct(this.get)",req:["values"],idx:3}),ci0:d({name:"ci0",set:"cell.data.ci0(this.get)",req:["values"],idx:3}),ci1:d({name:"ci1",set:"cell.data.ci1(this.get)",req:["values"],idx:3}),median:d({name:"median",set:"cell.data.q2(this.get)",req:["values"],idx:3}),q1:d({name:"q1",set:"cell.data.q1(this.get)",req:["values"],idx:3}),q3:d({name:"q3",set:"cell.data.q3(this.get)",req:["values"],idx:3}),argmin:d({name:"argmin",init:"this.argmin = undefined;",add:"if (v < this.min) this.argmin = t;",rem:"if (v <= this.min) this.argmin = undefined;",set:"this.argmin || cell.data.argmin(this.get)",req:["min"],str:["values"],idx:3}),argmax:d({name:"argmax",init:"this.argmax = undefined;",add:"if (v > this.max) this.argmax = t;",rem:"if (v >= this.max) this.argmax = undefined;",set:"this.argmax || cell.data.argmax(this.get)",req:["max"],str:["values"],idx:3}),min:d({name:"min",init:"this.min = undefined;",add:"if (v < this.min || this.min === undefined) this.min = v;",rem:"if (v <= this.min) this.min = NaN;",set:"this.min = (Number.isNaN(this.min) ? cell.data.min(this.get) : this.min)",str:["values"],idx:4}),max:d({name:"max",init:"this.max = undefined;",add:"if (v > this.max || this.max === undefined) this.max = v;",rem:"if (v >= this.max) this.max = NaN;",set:"this.max = (Number.isNaN(this.max) ? cell.data.max(this.get) : this.max)",str:["values"],idx:4})},o=Object.keys(u);function l(e,t){return u[e](t)}function d(e){return function(n){var i=t.extend({init:"",add:"",rem:"",idx:0},e);return i.out=n||e.name,i}}function f(e,t){return e.idx-t.idx}function m(e,n){var i=n||t.identity,a=function(e,t){var n,i=e.reduce((function e(n,i){function a(t){n[t]||e(n,n[t]=u[t]())}return i.req&&i.req.forEach(a),t&&i.str&&i.str.forEach(a),n}),e.reduce((function(e,t){return e[t.name]=t,e}),{})),a=[];for(n in i)a.push(i[n]);return a.sort(f)}(e,!0),r="var cell = this.cell; this.valid = 0; this.missing = 0;",s="this.cell = cell; this.init();",o="if(v==null){++this.missing; return;} if(v!==v) return; ++this.valid;",l="if(v==null){--this.missing; return;} if(v!==v) return; --this.valid;",d="var cell = this.cell;";return a.forEach((function(e){r+=e.init,o+=e.add,l+=e.rem})),e.slice().sort(f).forEach((function(e){d+="t["+t.stringValue(e.out)+"]="+e.set+";"})),d+="return t;",(s=Function("cell",s)).prototype.init=Function(r),s.prototype.add=Function("v","t",o),s.prototype.rem=Function("v","t",l),s.prototype.set=Function("t",d),s.prototype.get=i,s.fields=e.map((function(e){return e.out})),s}function c(e){this._key=e?t.field(e):n.tupleid,this.reset()}var h=c.prototype;function p(e){n.Transform.call(this,null,e),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}h.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null},h.add=function(e){this._add.push(e)},h.rem=function(e){this._rem.push(e)},h.values=function(){if(this._get=null,0===this._rem.length)return this._add;var e,t,n,i=this._add,a=this._rem,r=this._key,s=i.length,u=a.length,o=Array(s-u),l={};for(e=0;e<u;++e)l[r(a[e])]=1;for(e=0,t=0;e<s;++e)l[r(n=i[e])]?l[r(n)]=0:o[t++]=n;return this._rem=[],this._add=o},h.distinct=function(e){for(var n,i=this.values(),a=i.length,r={},s=0;--a>=0;)n=e(i[a])+"",t.hasOwnProperty(r,n)||(r[n]=1,++s);return s},h.extent=function(e){if(this._get!==e||!this._ext){var n=this.values(),i=t.extentIndex(n,e);this._ext=[n[i[0]],n[i[1]]],this._get=e}return this._ext},h.argmin=function(e){return this.extent(e)[0]||{}},h.argmax=function(e){return this.extent(e)[1]||{}},h.min=function(e){var t=this.extent(e)[0];return null!=t?e(t):void 0},h.max=function(e){var t=this.extent(e)[1];return null!=t?e(t):void 0},h.quartile=function(e){return this._get===e&&this._q||(this._q=i.quartiles(this.values(),e),this._get=e),this._q},h.q1=function(e){return this.quartile(e)[0]},h.q2=function(e){return this.quartile(e)[1]},h.q3=function(e){return this.quartile(e)[2]},h.ci=function(e){return this._get===e&&this._ci||(this._ci=i.bootstrapCI(this.values(),1e3,.05,e),this._get=e),this._ci},h.ci0=function(e){return this.ci(e)[0]},h.ci1=function(e){return this.ci(e)[1]},p.Definition={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:o},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]};var v=t.inherits(p,n.Transform);v.transform=function(e,t){var n=this,i=t.fork(t.NO_SOURCE|t.NO_FIELDS),a=e.modified();return n.stamp=i.stamp,n.value&&(a||t.modified(n._inputs,!0))?(n._prev=n.value,n.value=a?n.init(e):{},t.visit(t.SOURCE,e=>n.add(e))):(n.value=n.value||n.init(e),t.visit(t.REM,e=>n.rem(e)),t.visit(t.ADD,e=>n.add(e))),i.modifies(n._outputs),n._drop=!1!==e.drop,e.cross&&n._dims.length>1&&(n._drop=!1,n.cross()),n.changes(i)},v.cross=function(){var e=this,t=e.value,n=e._dnames,i=n.map((function(){return{}})),a=n.length;function r(e){var t,r,s,u;for(t in e)for(s=e[t].tuple,r=0;r<a;++r)i[r][u=s[n[r]]]=u}r(e._prev),r(t),function r(s,u,o){var l,d,f=n[o],m=i[o++];for(l in m)u[f]=m[l],d=s?s+"|"+l:l,o<a?r(d,u,o):t[d]||e.cell(d,u)}("",{},0)},v.init=function(e){var n=this._inputs=[],i=this._outputs=[],a={};function u(e){for(var i,r=t.array(t.accessorFields(e)),s=0,u=r.length;s<u;++s)a[i=r[s]]||(a[i]=1,n.push(i))}this._dims=t.array(e.groupby),this._dnames=this._dims.map((function(e){var n=t.accessorName(e);return u(e),i.push(n),n})),this.cellkey=e.key?e.key:r(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];var o,d,f,c,h,p,v=e.fields||[null],g=e.ops||["count"],y=e.as||[],_=v.length,x={};for(_!==g.length&&t.error("Unmatched number of fields and aggregate ops."),p=0;p<_;++p)o=v[p],d=g[p],null==o&&"count"!==d&&t.error("Null aggregate field specified."),h=s(d,c=t.accessorName(o),y[p]),i.push(h),"count"!==d?((f=x[c])||(u(o),(f=x[c]=[]).field=o,this._measures.push(f)),"count"!==d&&(this._countOnly=!1),f.push(l(d,h))):this._counts.push(h);return this._measures=this._measures.map((function(e){return m(e,e.field)})),{}},v.cellkey=r(),v.cell=function(e,t){var n=this.value[e];return n?0===n.num&&this._drop&&n.stamp<this.stamp?(n.stamp=this.stamp,this._adds[this._alen++]=n):n.stamp<this.stamp&&(n.stamp=this.stamp,this._mods[this._mlen++]=n):(n=this.value[e]=this.newcell(e,t),this._adds[this._alen++]=n),n},v.newcell=function(e,t){var n={key:e,num:0,agg:null,tuple:this.newtuple(t,this._prev&&this._prev[e]),stamp:this.stamp,store:!1};if(!this._countOnly){var i,a=this._measures,r=a.length;for(n.agg=Array(r),i=0;i<r;++i)n.agg[i]=new a[i](n)}return n.store&&(n.data=new c),n},v.newtuple=function(e,t){var i,a,r=this._dnames,s=this._dims,u={};for(i=0,a=s.length;i<a;++i)u[r[i]]=s[i](e);return t?n.replace(t.tuple,u):n.ingest(u)},v.add=function(e){var t,n,i,a=this.cellkey(e),r=this.cell(a,e);if(r.num+=1,!this._countOnly)for(r.store&&r.data.add(e),n=0,i=(t=r.agg).length;n<i;++n)t[n].add(t[n].get(e),e)},v.rem=function(e){var t,n,i,a=this.cellkey(e),r=this.cell(a,e);if(r.num-=1,!this._countOnly)for(r.store&&r.data.rem(e),n=0,i=(t=r.agg).length;n<i;++n)t[n].rem(t[n].get(e),e)},v.celltuple=function(e){var t,n,i,a=e.tuple,r=this._counts;for(e.store&&e.data.values(),n=0,i=r.length;n<i;++n)a[r[n]]=e.num;if(!this._countOnly)for(n=0,i=(t=e.agg).length;n<i;++n)t[n].set(a);return a},v.changes=function(e){var t,n,i,a,r=this._adds,s=this._mods,u=this._prev,o=this._drop,l=e.add,d=e.rem,f=e.mod;if(u)for(n in u)t=u[n],o&&!t.num||d.push(t.tuple);for(i=0,a=this._alen;i<a;++i)l.push(this.celltuple(r[i])),r[i]=null;for(i=0,a=this._mlen;i<a;++i)(0===(t=s[i]).num&&o?d:f).push(this.celltuple(t)),s[i]=null;return this._alen=this._mlen=0,this._prev=null,e};function g(e){n.Transform.call(this,null,e)}g.Definition={type:"Bin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"anchor",type:"number"},{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:"span",type:"number"},{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"]}]};var y=t.inherits(g,n.Transform);function _(e,n,i){var a=e,r=n||[],s=i||[],u={},o=0;return{add:function(e){s.push(e)},remove:function(e){u[a(e)]=++o},size:function(){return r.length},data:function(e,n){return o&&(r=r.filter((function(e){return!u[a(e)]})),u={},o=0),n&&e&&r.sort(e),s.length&&(r=e?t.merge(e,r,s.sort(e)):r.concat(s),s=[]),r}}}function x(e){n.Transform.call(this,[],e)}function b(e){n.Operator.call(this,null,O,e)}function O(e){return this.value&&!e.modified()?this.value:t.compare(e.fields,e.orders)}function D(e){n.Transform.call(this,null,e)}y.transform=function(e,n){var i,a=this._bins(e),r=a.start,s=a.step,u=e.as||["bin0","bin1"],o=u[0],l=u[1];return i=e.modified()?(n=n.reflow(!0)).SOURCE:n.modified(t.accessorFields(e.field))?n.ADD_MOD:n.ADD,n.visit(i,(function(e){var t=a(e);e[o]=t,e[l]=null==t?null:r+s*(1+(t-r)/s)})),n.modifies(u)},y._bins=function(e){if(this.value&&!e.modified())return this.value;var n,a,r=e.field,s=i.bin(e),u=s.start,o=s.stop,l=s.step;null!=(n=e.anchor)&&(a=n-(u+l*Math.floor((n-u)/l)),u+=a,o+=a);var d=function(e){var t=r(e);return null==t?null:(t=Math.max(u,Math.min(+t,o-l)),u+l*Math.floor(1e-14+(t-u)/l))};return d.start=u,d.stop=o,d.step=l,this.value=t.accessor(d,t.accessorFields(r),e.name||"bin_"+t.accessorName(r))},x.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},t.inherits(x,n.Transform).transform=function(e,t){var i=t.fork(t.ALL),a=_(n.tupleid,this.value,i.materialize(i.ADD).add),r=e.sort,s=t.changed()||r&&(e.modified("sort")||t.modified(r.fields));return i.visit(i.REM,a.remove),this.modified(s),this.value=i.source=a.data(n.stableCompare(r),s),t.source&&t.source.root&&(this.value.root=t.source.root),i},t.inherits(b,n.Operator),D.Definition={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"]}]};var E=t.inherits(D,n.Transform);function k(e){n.Transform.call(this,null,e)}E.transform=function(e,t){function n(t){return function(n){for(var i,a=function(e,t,n){switch(t){case"upper":e=e.toUpperCase();break;case"lower":e=e.toLowerCase()}return e.match(n)}(u(n),e.case,r)||[],o=0,l=a.length;o<l;++o)s.test(i=a[o])||t(i)}}var i=this._parameterCheck(e,t),a=this._counts,r=this._match,s=this._stop,u=e.field,o=e.as||["text","count"],l=n((function(e){a[e]=1+(a[e]||0)})),d=n((function(e){a[e]-=1}));return i?t.visit(t.SOURCE,l):(t.visit(t.ADD,l),t.visit(t.REM,d)),this._finish(t,o)},E._parameterCheck=function(e,t){var n=!1;return!e.modified("stopwords")&&this._stop||(this._stop=new RegExp("^"+(e.stopwords||"")+"$","i"),n=!0),!e.modified("pattern")&&this._match||(this._match=new RegExp(e.pattern||"[\\w']+","g"),n=!0),(e.modified("field")||t.modified(e.field.fields))&&(n=!0),n&&(this._counts={}),n},E._finish=function(e,t){var i,a,r,s=this._counts,u=this._tuples||(this._tuples={}),o=t[0],l=t[1],d=e.fork(e.NO_SOURCE|e.NO_FIELDS);for(i in s)a=u[i],r=s[i]||0,!a&&r?(u[i]=a=n.ingest({}),a[o]=i,a[l]=r,d.add.push(a)):0===r?(a&&d.rem.push(a),s[i]=null,u[i]=null):a[l]!==r&&(a[l]=r,d.mod.push(a));return d.modifies(t)},k.Definition={type:"Cross",metadata:{generates:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]},t.inherits(k,n.Transform).transform=function(e,i){var a=i.fork(i.NO_SOURCE),r=this.value,s=e.as||["a","b"],u=s[0],o=s[1];return!r||i.changed(i.ADD_REM)||e.modified("as")||e.modified("filter")?(r&&(a.rem=r),r=i.materialize(i.SOURCE).source,a.add=this.value=function(e,t,i,a){for(var r,s,u=[],o={},l=e.length,d=0;d<l;++d)for(o[t]=s=e[d],r=0;r<l;++r)o[i]=e[r],a(o)&&(u.push(n.ingest(o)),(o={})[t]=s);return u}(r,u,o,e.filter||t.truthy)):a.mod=r,a.source=this.value,a.modifies(s)};var q={kde:i.randomKDE,mixture:i.randomMixture,normal:i.randomNormal,lognormal:i.randomLogNormal,uniform:i.randomUniform},N="distributions",w="function",T="field";function R(e){n.Transform.call(this,null,e)}var C=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"lognormal"},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}]}],S={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:C},{name:"weights",type:"number",array:!0}]};function M(e,n){return e?e.map((function(e,i){return n[i]||t.accessorName(e)})):null}function U(e,t,n){var i,a,r,s,u,o,l=[],d=function(e){return e(s)};if(null==t)l.push(e.map(n));else for(i={},a=0,r=e.length;a<r;++a)s=e[a],(o=i[u=t.map(d)])||(i[u]=o=[],o.dims=u,l.push(o)),o.push(n(s));return l}R.Definition={type:"Density",metadata:{generates:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number"},{name:"minsteps",type:"number",default:25},{name:"maxsteps",type:"number",default:200},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:C.concat(S)},{name:"as",type:"string",array:!0,default:["value","density"]}]},t.inherits(R,n.Transform).transform=function(e,a){var r=a.fork(a.NO_SOURCE|a.NO_FIELDS);if(!this.value||a.changed()||e.modified()){var s=function e(n,i){var a=n[w];t.hasOwnProperty(q,a)||t.error("Unknown distribution function: "+a);var r=q[a]();for(var s in n)s===T?r.data((n.from||i()).map(n[s])):s===N?r[s](n[s].map((function(t){return e(t,i)}))):typeof r[s]===w&&r[s](n[s]);return r}(e.distribution,function(e){return function(){return e.materialize(e.SOURCE).source}}(a)),u=e.steps||e.minsteps||25,o=e.steps||e.maxsteps||200,l=e.method||"pdf";"pdf"!==l&&"cdf"!==l&&t.error("Invalid density method: "+l),e.extent||s.data||t.error("Missing density extent parameter."),l=s[l];var d=e.as||["value","density"],f=e.extent||t.extent(s.data()),m=i.sampleCurve(l,f,u,o).map(e=>{var t={};return t[d[0]]=e[0],t[d[1]]=e[1],n.ingest(t)});this.value&&(r.rem=this.value),this.value=r.add=r.source=m}return r};function A(e){n.Transform.call(this,null,e)}function F(e){n.Operator.call(this,null,z,e),this.modified(!0)}function z(e){var n=e.expr;return this.value&&!e.modified("expr")?this.value:t.accessor(t=>n(t,e),t.accessorFields(n),t.accessorName(n))}function L(e){n.Transform.call(this,[void 0,void 0],e)}function I(e,t){n.Operator.call(this,e),this.parent=t}A.Definition={type:"DotBin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"step",type:"number"},{name:"smooth",type:"boolean",default:!1},{name:"as",type:"string",default:"bin"}]},t.inherits(A,n.Transform).transform=function(e,a){if(this.value&&!e.modified()&&!a.changed())return a;const r=a.materialize(a.SOURCE).source,s=U(a.source,e.groupby,t.identity),u=e.smooth||!1,o=e.field,l=e.step||function(e,n){return t.span(t.extent(e,n))/30}(r,o),d=n.stableCompare((e,t)=>o(e)-o(t)),f=e.as||"bin",m=s.length;let c,h=1/0,p=-1/0,v=0;for(;v<m;++v){const e=s[v].sort(d);c=-1;for(const t of i.dotbin(e,l,u,o))t<h&&(h=t),t>p&&(p=t),e[++c][f]=t}return this.value={start:h,stop:p,step:l},a.reflow(!0).modifies(f)},t.inherits(F,n.Operator),L.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},t.inherits(L,n.Transform).transform=function(e,n){var i,a=this.value,r=e.field,s=a[0],u=a[1];if(((i=n.changed()||n.modified(r.fields)||e.modified("field"))||null==s)&&(s=1/0,u=-1/0),n.visit(i?n.SOURCE:n.ADD,(function(e){var t=r(e);null!=t&&((t=+t)<s&&(s=t),t>u&&(u=t))})),!Number.isFinite(s)||!Number.isFinite(u)){let e=t.accessorName(r);e&&(e=` for field "${e}"`),n.dataflow.warn(`Infinite extent${e}: [${s}, ${u}]`),s=u=void 0}this.value=[s,u]};var P=t.inherits(I,n.Operator);function j(e){n.Transform.call(this,{},e),this._keys=t.fastmap();var i=this._targets=[];i.active=0,i.forEach=function(e){for(var t=0,n=i.active;t<n;++t)e(i[t],t,i)}}P.connect=function(e){return this.targets().add(e),e.source=this},P.add=function(e){this.value.add.push(e)},P.rem=function(e){this.value.rem.push(e)},P.mod=function(e){this.value.mod.push(e)},P.init=function(e){this.value.init(e,e.NO_SOURCE)},P.evaluate=function(){return this.value};var $=t.inherits(j,n.Transform);function K(e){n.Operator.call(this,null,W,e)}function W(e){return this.value&&!e.modified()?this.value:t.isArray(e.name)?t.array(e.name).map((function(e){return t.field(e)})):t.field(e.name,e.as)}function B(e){n.Transform.call(this,t.fastmap(),e)}function J(e){n.Transform.call(this,[],e)}function Q(e){n.Transform.call(this,[],e)}function V(e){n.Transform.call(this,null,e)}function G(e){n.Transform.call(this,[],e)}$.activate=function(e){this._targets[this._targets.active++]=e},$.subflow=function(e,n,i,a){var r,s,u=this.value,o=t.hasOwnProperty(u,e)&&u[e];return o?o.value.stamp<i.stamp&&(o.init(i),this.activate(o)):(s=a||(s=this._group[e])&&s.tuple,o=(r=i.dataflow).add(new I(i.fork(i.NO_SOURCE),this)).connect(n(r,e,s)),u[e]=o,this.activate(o)),o},$.transform=function(e,t){var i=t.dataflow,a=this,r=e.key,s=e.subflow,u=this._keys,o=e.modified("key");function l(e){return a.subflow(e,s,t)}return this._group=e.group||{},this._targets.active=0,t.visit(t.REM,(function(e){var t=n.tupleid(e),i=u.get(t);void 0!==i&&(u.delete(t),l(i).rem(e))})),t.visit(t.ADD,(function(e){var t=r(e);u.set(n.tupleid(e),t),l(t).add(e)})),o||t.modified(r.fields)?t.visit(t.MOD,(function(e){var t=n.tupleid(e),i=u.get(t),a=r(e);i===a?l(a).mod(e):(u.set(t,a),l(i).rem(e),l(a).add(e))})):t.changed(t.MOD)&&t.visit(t.MOD,(function(e){l(u.get(n.tupleid(e))).mod(e)})),o&&t.visit(t.REFLOW,(function(e){var t=n.tupleid(e),i=u.get(t),a=r(e);i!==a&&(u.set(t,a),l(i).rem(e),l(a).add(e))})),u.empty>i.cleanThreshold&&i.runAfter(u.clean),t},t.inherits(K,n.Operator),B.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},t.inherits(B,n.Transform).transform=function(e,t){var i=t.dataflow,a=this.value,r=t.fork(),s=r.add,u=r.rem,o=r.mod,l=e.expr,d=!0;function f(t){var i=n.tupleid(t),r=l(t,e),f=a.get(i);r&&f?(a.delete(i),s.push(t)):r||f?d&&r&&!f&&o.push(t):(a.set(i,1),u.push(t))}return t.visit(t.REM,(function(e){var t=n.tupleid(e);a.has(t)?a.delete(t):u.push(e)})),t.visit(t.ADD,(function(t){l(t,e)?s.push(t):a.set(n.tupleid(t),1)})),t.visit(t.MOD,f),e.modified()&&(d=!1,t.visit(t.REFLOW,f)),a.empty>i.cleanThreshold&&i.runAfter(a.clean),r},J.Definition={type:"Flatten",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0}]},t.inherits(J,n.Transform).transform=function(e,t){var i=t.fork(t.NO_SOURCE),a=e.fields,r=M(a,e.as||[]),s=r.length;return i.rem=this.value,t.visit(t.SOURCE,(function(e){for(var t,u,o,l=a.map((function(t){return t(e)})),d=l.reduce((function(e,t){return Math.max(e,t.length)}),0),f=0;f<d;++f){for(u=n.derive(e),t=0;t<s;++t)u[r[t]]=null==(o=l[t][f])?null:o;i.add.push(u)}})),this.value=i.source=i.add,i.modifies(r)},Q.Definition={type:"Fold",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,length:2,default:["key","value"]}]},t.inherits(Q,n.Transform).transform=function(e,i){var a=i.fork(i.NO_SOURCE),r=e.fields,s=r.map(t.accessorName),u=e.as||["key","value"],o=u[0],l=u[1],d=r.length;return a.rem=this.value,i.visit(i.SOURCE,(function(e){for(var t,i=0;i<d;++i)(t=n.derive(e))[o]=s[i],t[l]=r[i](e),a.add.push(t)})),this.value=a.source=a.add,a.modifies(u)},V.Definition={type:"Formula",metadata:{modifies:!0},params:[{name:"expr",type:"expr",required:!0},{name:"as",type:"string",required:!0},{name:"initonly",type:"boolean"}]},t.inherits(V,n.Transform).transform=function(e,t){var n=e.expr,i=e.as,a=e.modified(),r=e.initonly?t.ADD:a?t.SOURCE:t.modified(n.fields)||t.modified(i)?t.ADD_MOD:t.ADD;return a&&(t=t.materialize().reflow(!0)),e.initonly||t.modifies(i),t.visit(r,t=>t[i]=n(t,e))},t.inherits(G,n.Transform).transform=function(e,t){var i,a,r,s=this.value,u=t.fork(t.ALL),o=e.size-s.length,l=e.generator;if(o>0){for(i=[];--o>=0;)i.push(r=n.ingest(l(e))),s.push(r);u.add=u.add.length?u.materialize(u.ADD).add.concat(i):i}else a=s.slice(0,-o),u.rem=u.rem.length?u.materialize(u.REM).rem.concat(a):a,s=s.slice(-o);return u.source=this.value=s,u};var H={value:"value",median:a.median,mean:a.mean,min:a.min,max:a.max},X=[];function Y(e){n.Transform.call(this,[],e)}function Z(e){p.call(this,e)}Y.Definition={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},t.inherits(Y,n.Transform).transform=function(e,i){var a,r,s,u,o,l,d,f,m,c,h=i.fork(i.ALL),p=function(e){var n,i=e.method||H.value;if(null!=H[i])return i===H.value?(n=void 0!==e.value?e.value:0,function(){return n}):H[i];t.error("Unrecognized imputation method: "+i)}(e),v=function(e){var t=e.field;return function(e){return e?t(e):NaN}}(e),g=t.accessorName(e.field),y=t.accessorName(e.key),_=(e.groupby||[]).map(t.accessorName),x=function(e,t,n,i){var a,r,s,u,o,l,d,f,m=function(e){return e(f)},c=[],h=i?i.slice():[],p={},v={};for(h.forEach((function(e,t){p[e]=t+1})),u=0,d=e.length;u<d;++u)f=e[u],l=n(f),o=p[l]||(p[l]=h.push(l)),r=(a=t?t.map(m):X)+"",(s=v[r])||(s=v[r]=[],c.push(s),s.values=a),s[o-1]=f;return c.domain=h,c}(i.source,e.groupby,e.key,e.keyvals),b=[],O=this.value,D=x.domain.length;for(o=0,f=x.length;o<f;++o)for(s=(a=x[o]).values,r=NaN,d=0;d<D;++d)if(null==a[d]){for(u=x.domain[d],c={_impute:!0},l=0,m=s.length;l<m;++l)c[_[l]]=s[l];c[y]=u,c[g]=Number.isNaN(r)?r=p(a,v):r,b.push(n.ingest(c))}return b.length&&(h.add=h.materialize(h.ADD).add.concat(b)),O.length&&(h.rem=h.materialize(h.REM).rem.concat(O)),this.value=b,h},Z.Definition={type:"JoinAggregate",metadata:{modifies:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"ops",type:"enum",array:!0,values:o},{name:"as",type:"string",null:!0,array:!0},{name:"key",type:"field"}]};var ee=t.inherits(Z,p);function te(e){n.Transform.call(this,null,e)}function ne(e){n.Operator.call(this,null,ie,e)}function ie(e){return this.value&&!e.modified()?this.value:t.key(e.fields,e.flat)}function ae(e){n.Transform.call(this,[],e)}function re(e,t,i){i.forEach(n.ingest);const a=t.fork(t.NO_FIELDS&t.NO_SOURCE);return a.rem=e.value,e.value=a.add=a.source=i,a}function se(e){n.Transform.call(this,{},e)}function ue(e){n.Operator.call(this,null,oe,e)}function oe(e){if(this.value&&!e.modified())return this.value;var t,n,i,a=1/0,r=-1/0,s=e.extents;for(t=0,n=s.length;t<n;++t)(i=s[t])[0]<a&&(a=i[0]),i[1]>r&&(r=i[1]);return[a,r]}function le(e){n.Operator.call(this,null,de,e)}function de(e){return this.value&&!e.modified()?this.value:e.values.reduce((function(e,t){return e.concat(t)}),[])}function fe(e){n.Transform.call(this,null,e)}function me(e){p.call(this,e)}ee.transform=function(e,n){var i,a=this,r=e.modified();return a.value&&(r||n.modified(a._inputs,!0))?(i=a.value=r?a.init(e):{},n.visit(n.SOURCE,(function(e){a.add(e)}))):(i=a.value=a.value||this.init(e),n.visit(n.REM,(function(e){a.rem(e)})),n.visit(n.ADD,(function(e){a.add(e)}))),a.changes(),n.visit(n.SOURCE,(function(e){t.extend(e,i[a.cellkey(e)].tuple)})),n.reflow(r).modifies(this._outputs)},ee.changes=function(){var e,t,n=this._adds,i=this._mods;for(e=0,t=this._alen;e<t;++e)this.celltuple(n[e]),n[e]=null;for(e=0,t=this._mlen;e<t;++e)this.celltuple(i[e]),i[e]=null;this._alen=this._mlen=0},te.Definition={type:"KDE",metadata:{generates:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"cumulative",type:"boolean",default:!1},{name:"counts",type:"boolean",default:!1},{name:"bandwidth",type:"number",default:0},{name:"extent",type:"number",array:!0,length:2},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"steps",type:"number"},{name:"minsteps",type:"number",default:25},{name:"maxsteps",type:"number",default:200},{name:"as",type:"string",array:!0,default:["value","density"]}]},t.inherits(te,n.Transform).transform=function(e,a){var r=a.fork(a.NO_SOURCE|a.NO_FIELDS);if(!this.value||a.changed()||e.modified()){const s=a.materialize(a.SOURCE).source,u=U(s,e.groupby,e.field),o=(e.groupby||[]).map(t.accessorName),l=e.bandwidth,d=e.cumulative?"cdf":"pdf",f=e.as||["value","density"],m=[];let c=e.extent,h=e.steps||e.minsteps||25,p=e.steps||e.maxsteps||200;"pdf"!==d&&"cdf"!==d&&t.error("Invalid density method: "+d),"shared"===e.resolve&&(c||(c=t.extent(s,e.field)),h=p=e.steps||p),u.forEach(a=>{const r=i.randomKDE(a,l)[d],s=e.counts?a.length:1,u=c||t.extent(a);i.sampleCurve(r,u,h,p).forEach(e=>{const t={};for(let e=0;e<o.length;++e)t[o[e]]=a.dims[e];t[f[0]]=e[0],t[f[1]]=e[1]*s,m.push(n.ingest(t))})}),this.value&&(r.rem=this.value),this.value=r.add=r.source=m}return r},t.inherits(ne,n.Operator),t.inherits(ae,n.Transform).transform=function(e,n){const i=n.dataflow;return e.values?re(this,n,i.parse(e.values,e.format)):i.request(e.url,e.format).then(e=>re(this,n,t.array(e.data)))},se.Definition={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"values",type:"field",array:!0},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0},{name:"default",default:null}]},t.inherits(se,n.Transform).transform=function(e,n){var i,a,r=n,s=e.as,u=e.fields,o=e.index,l=e.values,d=null==e.default?null:e.default,f=e.modified(),m=f?n.SOURCE:n.ADD,c=u.length;return l?(a=l.length,c>1&&!s&&t.error('Multi-field lookup requires explicit "as" parameter.'),s&&s.length!==c*a&&t.error('The "as" parameter has too few output field names.'),s=s||l.map(t.accessorName),i=function(e){for(var t,n,i=0,r=0;i<c;++i)if(null==(n=o.get(u[i](e))))for(t=0;t<a;++t,++r)e[s[r]]=d;else for(t=0;t<a;++t,++r)e[s[r]]=l[t](n)}):(s||t.error("Missing output field names."),i=function(e){for(var t,n=0;n<c;++n)t=o.get(u[n](e)),e[s[n]]=null==t?d:t}),f?r=n.reflow(!0):m|=u.some((function(e){return n.modified(e.fields)}))?n.MOD:0,n.visit(m,i),r.modifies(s)},t.inherits(ue,n.Operator),t.inherits(le,n.Operator),t.inherits(fe,n.Transform),fe.prototype.transform=function(e,t){return this.modified(e.modified()),this.value=e,t.fork(t.NO_SOURCE|t.NO_FIELDS)},me.Definition={type:"Pivot",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"value",type:"field",required:!0},{name:"op",type:"enum",values:o,default:"sum"},{name:"limit",type:"number",default:0},{name:"key",type:"field"}]};var ce=t.inherits(me,p);function he(e){j.call(this,e)}function pe(e){n.Transform.call(this,null,e)}function ve(e){n.Transform.call(this,null,e)}function ge(e){n.Transform.call(this,null,e)}ce._transform=ce.transform,ce.transform=function(e,n){return this._transform(function(e,n){var i=e.field,a=e.value,r=("count"===e.op?"__count__":e.op)||"sum",s=t.accessorFields(i).concat(t.accessorFields(a)),u=function(e,t,n){var i={},a=[];return n.visit(n.SOURCE,(function(t){var n=e(t);i[n]||(i[n]=1,a.push(n))})),a.sort((function(e,t){return(e<t||null==e)&&null!=t?-1:(e>t||null==t)&&null!=e?1:(t=t instanceof Date?+t:t,(e=e instanceof Date?+e:e)!==e&&t==t?-1:t!=t&&e==e?1:0)})),t?a.slice(0,t):a}(i,e.limit||0,n);n.changed()&&e.set("__pivot__",null,null,!0);return{key:e.key,groupby:e.groupby,ops:u.map((function(){return r})),fields:u.map((function(e){return function(e,n,i,a){return t.accessor((function(t){return n(t)===e?i(t):NaN}),a,e+"")}(e,i,a,s)})),as:u.map((function(e){return e+""})),modified:e.modified.bind(e)}}(e,n),n)},t.inherits(he,j).transform=function(e,i){var a=this,r=e.subflow,s=e.field;return(e.modified("field")||s&&i.modified(t.accessorFields(s)))&&t.error("PreFacet does not support field modification."),this._targets.active=0,i.visit(i.MOD,(function(e){var t=a.subflow(n.tupleid(e),r,i,e);s?s(e).forEach((function(e){t.mod(e)})):t.mod(e)})),i.visit(i.ADD,(function(e){var t=a.subflow(n.tupleid(e),r,i,e);s?s(e).forEach((function(e){t.add(n.ingest(e))})):t.add(e)})),i.visit(i.REM,(function(e){var t=a.subflow(n.tupleid(e),r,i,e);s?s(e).forEach((function(e){t.rem(e)})):t.rem(e)})),i},pe.Definition={type:"Project",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0},{name:"as",type:"string",null:!0,array:!0}]},t.inherits(pe,n.Transform).transform=function(e,t){var i,a,r=e.fields,s=M(e.fields,e.as||[]),u=r?function(e,t){return function(e,t,n,i){for(var a=0,r=n.length;a<r;++a)t[i[a]]=n[a](e);return t}(e,t,r,s)}:n.rederive;return this.value?a=this.value:(t=t.addAll(),a=this.value={}),i=t.fork(t.NO_SOURCE),t.visit(t.REM,(function(e){var t=n.tupleid(e);i.rem.push(a[t]),a[t]=null})),t.visit(t.ADD,(function(e){var t=u(e,n.ingest({}));a[n.tupleid(e)]=t,i.add.push(t)})),t.visit(t.MOD,(function(e){i.mod.push(u(e,a[n.tupleid(e)]))})),i},t.inherits(ve,n.Transform).transform=function(e,t){return this.value=e.value,e.modified("value")?t.fork(t.NO_SOURCE|t.NO_FIELDS):t.StopPropagation},ge.Definition={type:"Quantile",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"probs",type:"number",array:!0},{name:"step",type:"number",default:.01},{name:"as",type:"string",array:!0,default:["prob","value"]}]};var ye=t.inherits(ge,n.Transform);function _e(e){n.Transform.call(this,null,e)}function xe(e){n.Transform.call(this,[],e),this.count=0}function be(e){n.Transform.call(this,null,e)}function Oe(e){n.Transform.call(this,null,e),this.modified(!0)}function De(e){n.Transform.call(this,t.fastmap(),e)}function Ee(e){n.Transform.call(this,null,e)}ye.transform=function(e,r){var s=r.fork(r.NO_SOURCE|r.NO_FIELDS),u=e.as||["prob","value"];if(this.value&&!e.modified()&&!r.changed())return s.source=this.value,s;const o=U(r.materialize(r.SOURCE).source,e.groupby,e.field),l=(e.groupby||[]).map(t.accessorName),d=[],f=e.step||.01,m=e.probs||a.range(f/2,1-1e-14,f),c=m.length;return o.forEach(e=>{const t=i.quantiles(e,m);for(let i=0;i<c;++i){const a={};for(let t=0;t<l.length;++t)a[l[t]]=e.dims[t];a[u[0]]=m[i],a[u[1]]=t[i],d.push(n.ingest(a))}}),this.value&&(s.rem=this.value),this.value=s.add=s.source=d,s},t.inherits(_e,n.Transform).transform=function(e,t){var i,a;return this.value?a=this.value:(i=t=t.addAll(),a=this.value={}),e.derive&&(i=t.fork(t.NO_SOURCE),t.visit(t.REM,e=>{var t=n.tupleid(e);i.rem.push(a[t]),a[t]=null}),t.visit(t.ADD,e=>{var t=n.derive(e);a[n.tupleid(e)]=t,i.add.push(t)}),t.visit(t.MOD,e=>{i.mod.push(n.rederive(e,a[n.tupleid(e)]))}),t.mod.length&&(t.materialize(t.MOD),i.modifies(Object.keys(t.mod[0])))),i},xe.Definition={type:"Sample",metadata:{},params:[{name:"size",type:"number",default:1e3}]},t.inherits(xe,n.Transform).transform=function(e,t){var a=t.fork(t.NO_SOURCE),r=e.modified("size"),s=e.size,u=this.value,o=this.count,l=0,d=u.reduce((function(e,t){return e[n.tupleid(t)]=1,e}),{});function f(e){var t,r;u.length<s?u.push(e):(r=~~((o+1)*i.random()))<u.length&&r>=l&&(t=u[r],d[n.tupleid(t)]&&a.rem.push(t),u[r]=e),++o}if(t.rem.length&&(t.visit(t.REM,(function(e){var t=n.tupleid(e);d[t]&&(d[t]=-1,a.rem.push(e)),--o})),u=u.filter((function(e){return-1!==d[n.tupleid(e)]}))),(t.rem.length||r)&&u.length<s&&t.source&&(l=o=u.length,t.visit(t.SOURCE,(function(e){d[n.tupleid(e)]||f(e)})),l=-1),r&&u.length>s){for(var m=0,c=u.length-s;m<c;++m)d[n.tupleid(u[m])]=-1,a.rem.push(u[m]);u=u.slice(c)}return t.mod.length&&t.visit(t.MOD,(function(e){d[n.tupleid(e)]&&a.mod.push(e)})),t.add.length&&t.visit(t.ADD,f),(t.add.length||l<0)&&(a.add=u.filter((function(e){return!d[n.tupleid(e)]}))),this.count=o,this.value=a.source=u,a},be.Definition={type:"Sequence",metadata:{generates:!0,changes:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1},{name:"as",type:"string",default:"data"}]},t.inherits(be,n.Transform).transform=function(e,t){if(!this.value||e.modified()){var i=t.materialize().fork(t.MOD),r=e.as||"data";return i.rem=this.value?t.rem.concat(this.value):t.rem,this.value=a.range(e.start,e.stop,e.step||1).map((function(e){var t={};return t[r]=e,n.ingest(t)})),i.add=t.add.concat(this.value),i}},t.inherits(Oe,n.Transform).transform=function(e,t){return this.value=t.source,t.changed()?t.fork(t.NO_SOURCE|t.NO_FIELDS):t.StopPropagation},t.inherits(De,n.Transform).transform=function(e,t){var n=t.dataflow,i=e.field,a=this.value,r=!0;function s(e){a.set(i(e),e)}return e.modified("field")||t.modified(i.fields)?(a.clear(),t.visit(t.SOURCE,s)):t.changed()?(t.visit(t.REM,(function(e){a.delete(i(e))})),t.visit(t.ADD,s)):r=!1,this.modified(r),a.empty>n.cleanThreshold&&n.runAfter(a.clean),t.fork()},t.inherits(Ee,n.Transform).transform=function(e,t){(!this.value||e.modified("field")||e.modified("sort")||t.changed()||e.sort&&t.modified(e.sort.fields))&&(this.value=(e.sort?t.source.slice().sort(n.stableCompare(e.sort)):t.source).map(e.field))};const ke={row_number:function(){return{next:e=>e.index+1}},rank:function(){let e;return{init:()=>e=1,next:t=>{let n=t.index,i=t.data;return n&&t.compare(i[n-1],i[n])?e=n+1:e}}},dense_rank:function(){let e;return{init:()=>e=1,next:t=>{let n=t.index,i=t.data;return n&&t.compare(i[n-1],i[n])?++e:e}}},percent_rank:function(){let e=ke.rank(),t=e.next;return{init:e.init,next:e=>(t(e)-1)/(e.data.length-1)}},cume_dist:function(){let e;return{init:()=>e=0,next:t=>{let n=t.index,i=t.data,a=t.compare;if(e<n){for(;n+1<i.length&&!a(i[n],i[n+1]);)++n;e=n}return(1+e)/i.length}}},ntile:function(e,n){(n=+n)>0||t.error("ntile num must be greater than zero.");let i=ke.cume_dist(),a=i.next;return{init:i.init,next:e=>Math.ceil(n*a(e))}},lag:function(e,t){return t=+t||1,{next:n=>{let i=n.index-t;return i>=0?e(n.data[i]):null}}},lead:function(e,t){return t=+t||1,{next:n=>{let i=n.index+t,a=n.data;return i<a.length?e(a[i]):null}}},first_value:function(e){return{next:t=>e(t.data[t.i0])}},last_value:function(e){return{next:t=>e(t.data[t.i1-1])}},nth_value:function(e,n){return(n=+n)>0||t.error("nth_value nth must be greater than zero."),{next:t=>{let i=t.i0+(n-1);return i<t.i1?e(t.data[i]):null}}},prev_value:function(e){let t=null;return{next:n=>{let i=e(n.data[n.index]);return null!=i?t=i:t}}},next_value:function(e){let t=null,n=-1;return{next:i=>{let a=i.data;return i.index<=n?t:(n=function(e,t,n){for(let i=t.length;n<i;++n){if(null!=e(t[n]))return n}return-1}(e,a,i.index))<0?(n=a.length,t=null):t=e(a[n])}}}};var qe=Object.keys(ke);function Ne(e){let n=this,i=t.array(e.ops),a=t.array(e.fields),r=t.array(e.params),u=t.array(e.as),o=n.outputs=[],d=n.windows=[],f={},h={},p=!0,v=[],g=[];function y(e){t.array(t.accessorFields(e)).forEach(e=>f[e]=1)}y(e.sort),i.forEach((function(e,n){let i=a[n],f=t.accessorName(i),m=s(e,f,u[n]);if(y(i),o.push(m),t.hasOwnProperty(ke,e))d.push(function(e,n,i,a){let r=ke[e](n,i);return{init:r.init||t.zero,update:function(e,t){t[a]=r.next(e)}}}(e,a[n],r[n],m));else{if(null==i&&"count"!==e&&t.error("Null aggregate field specified."),"count"===e)return void v.push(m);p=!1;let n=h[f];n||((n=h[f]=[]).field=i,g.push(n)),n.push(l(e,m))}})),(v.length||g.length)&&(n.cell=function(e,t,n){e=e.map(e=>m(e,e.field));let i={num:0,agg:null,store:!1,count:t};if(!n)for(var a=e.length,r=i.agg=Array(a),s=0;s<a;++s)r[s]=new e[s](i);if(i.store)var u=i.data=new c;return i.add=function(e){if(i.num+=1,!n){u&&u.add(e);for(let t=0;t<a;++t)r[t].add(r[t].get(e),e)}},i.rem=function(e){if(i.num-=1,!n){u&&u.rem(e);for(let t=0;t<a;++t)r[t].rem(r[t].get(e),e)}},i.set=function(e){let a,s;for(u&&u.values(),a=0,s=t.length;a<s;++a)e[t[a]]=i.num;if(!n)for(a=0,s=r.length;a<s;++a)r[a].set(e)},i.init=function(){i.num=0,u&&u.reset();for(let e=0;e<a;++e)r[e].init()},i}(g,v,p)),n.inputs=Object.keys(f)}const we=Ne.prototype;function Te(e){n.Transform.call(this,{},e),this._mlen=0,this._mods=[]}we.init=function(){this.windows.forEach(e=>e.init()),this.cell&&this.cell.init()},we.update=function(e,t){let n,i=this.cell,a=this.windows,r=e.data,s=a&&a.length;if(i){for(n=e.p0;n<e.i0;++n)i.rem(r[n]);for(n=e.p1;n<e.i1;++n)i.add(r[n]);i.set(t)}for(n=0;n<s;++n)a[n].update(e,t)},Te.Definition={type:"Window",metadata:{modifies:!0},params:[{name:"sort",type:"compare"},{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:qe.concat(o)},{name:"params",type:"number",null:!0,array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"frame",type:"number",null:!0,array:!0,length:2,default:[null,0]},{name:"ignorePeers",type:"boolean",default:!1}]};var Re=t.inherits(Te,n.Transform);function Ce(e,n,i,r){var s=r.sort,u=s&&!r.ignorePeers,o=r.frame||[null,0],l=e.data(i),d=l.length,f=0,m=u?a.bisector(s):null,c={i0:0,i1:0,p0:0,p1:0,index:0,data:l,compare:s||t.constant(-1)};for(n.init();f<d;++f)Se(c,o,f,d),u&&Me(c,m),n.update(c,l[f])}function Se(e,t,n,i){e.p0=e.i0,e.p1=e.i1,e.i0=null==t[0]?0:Math.max(0,n-Math.abs(t[0])),e.i1=null==t[1]?i:Math.min(i,n+Math.abs(t[1])+1),e.index=n}function Me(e,t){var n=e.i0,i=e.i1-1,a=e.compare,r=e.data,s=r.length-1;n>0&&!a(r[n],r[n-1])&&(e.i0=t.left(r,r[n])),i<s&&!a(r[i],r[i+1])&&(e.i1=t.right(r,r[i]))}Re.transform=function(e,t){var i,a,s=this,u=s.state,o=e.modified(),l=n.stableCompare(e.sort);this.stamp=t.stamp,u&&!o||(u=s.state=new Ne(e));var d=r(e.groupby);function f(e){return s.group(d(e))}for(o||t.modified(u.inputs)?(s.value={},t.visit(t.SOURCE,(function(e){f(e).add(e)}))):(t.visit(t.REM,(function(e){f(e).remove(e)})),t.visit(t.ADD,(function(e){f(e).add(e)}))),i=0,a=s._mlen;i<a;++i)Ce(s._mods[i],u,l,e);return s._mlen=0,s._mods=[],t.reflow(o).modifies(u.outputs)},Re.group=function(e){var t=this.value[e];return t||((t=this.value[e]=_(n.tupleid)).stamp=-1),t.stamp<this.stamp&&(t.stamp=this.stamp,this._mods[this._mlen++]=t),t},e.aggregate=p,e.bin=g,e.collect=x,e.compare=b,e.countpattern=D,e.cross=k,e.density=R,e.dotbin=A,e.expression=F,e.extent=L,e.facet=j,e.field=K,e.filter=B,e.flatten=J,e.fold=Q,e.formula=V,e.generate=G,e.impute=Y,e.joinaggregate=Z,e.kde=te,e.key=ne,e.load=ae,e.lookup=se,e.multiextent=ue,e.multivalues=le,e.params=fe,e.pivot=me,e.prefacet=he,e.project=pe,e.proxy=ve,e.quantile=ge,e.relay=_e,e.sample=xe,e.sequence=be,e.sieve=Oe,e.subflow=I,e.tupleindex=De,e.values=Ee,e.window=Te,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-dataflow"),require("vega-statistics"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-dataflow","vega-statistics","d3-array"],t):t(((e=e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.vega,e.d3)}(this,(function(e,t,n,i,a){"use strict";function r(e){return e&&e.length?1===e.length?e[0]:(t=e,function(e){for(var n=t.length,i=1,a=String(t[0](e));i<n;++i)a+="|"+t[i](e);return a}):function(){return""};var t}function s(e,t,n){return n||e+(t?"_"+t:"")}var u={values:d({name:"values",init:"cell.store = true;",set:"cell.data.values()",idx:-1}),count:d({name:"count",set:"cell.num"}),__count__:d({name:"count",set:"this.missing + this.valid"}),missing:d({name:"missing",set:"this.missing"}),valid:d({name:"valid",set:"this.valid"}),sum:d({name:"sum",init:"this.sum = 0;",add:"this.sum += +v;",rem:"this.sum -= v;",set:"this.sum"}),mean:d({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.valid ? this.mean : undefined"}),average:d({name:"average",set:"this.valid ? this.mean : undefined",req:["mean"],idx:1}),variance:d({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) : undefined",req:["mean"],idx:1}),variancep:d({name:"variancep",set:"this.valid > 1 ? this.dev / this.valid : undefined",req:["variance"],idx:2}),stdev:d({name:"stdev",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid-1)) : undefined",req:["variance"],idx:2}),stdevp:d({name:"stdevp",set:"this.valid > 1 ? Math.sqrt(this.dev / this.valid) : undefined",req:["variance"],idx:2}),stderr:d({name:"stderr",set:"this.valid > 1 ? Math.sqrt(this.dev / (this.valid * (this.valid-1))) : undefined",req:["variance"],idx:2}),distinct:d({name:"distinct",set:"cell.data.distinct(this.get)",req:["values"],idx:3}),ci0:d({name:"ci0",set:"cell.data.ci0(this.get)",req:["values"],idx:3}),ci1:d({name:"ci1",set:"cell.data.ci1(this.get)",req:["values"],idx:3}),median:d({name:"median",set:"cell.data.q2(this.get)",req:["values"],idx:3}),q1:d({name:"q1",set:"cell.data.q1(this.get)",req:["values"],idx:3}),q3:d({name:"q3",set:"cell.data.q3(this.get)",req:["values"],idx:3}),argmin:d({name:"argmin",init:"this.argmin = undefined;",add:"if (v < this.min) this.argmin = t;",rem:"if (v <= this.min) this.argmin = undefined;",set:"this.argmin || cell.data.argmin(this.get)",req:["min"],str:["values"],idx:3}),argmax:d({name:"argmax",init:"this.argmax = undefined;",add:"if (v > this.max) this.argmax = t;",rem:"if (v >= this.max) this.argmax = undefined;",set:"this.argmax || cell.data.argmax(this.get)",req:["max"],str:["values"],idx:3}),min:d({name:"min",init:"this.min = undefined;",add:"if (v < this.min || this.min === undefined) this.min = v;",rem:"if (v <= this.min) this.min = NaN;",set:"this.min = (Number.isNaN(this.min) ? cell.data.min(this.get) : this.min)",str:["values"],idx:4}),max:d({name:"max",init:"this.max = undefined;",add:"if (v > this.max || this.max === undefined) this.max = v;",rem:"if (v >= this.max) this.max = NaN;",set:"this.max = (Number.isNaN(this.max) ? cell.data.max(this.get) : this.max)",str:["values"],idx:4})},o=Object.keys(u);function l(e,t){return u[e](t)}function d(e){return function(n){var i=t.extend({init:"",add:"",rem:"",idx:0},e);return i.out=n||e.name,i}}function f(e,t){return e.idx-t.idx}function m(e,n){var i=n||t.identity,a=function(e,t){var n,i=e.reduce((function e(n,i){function a(t){n[t]||e(n,n[t]=u[t]())}return i.req&&i.req.forEach(a),t&&i.str&&i.str.forEach(a),n}),e.reduce((function(e,t){return e[t.name]=t,e}),{})),a=[];for(n in i)a.push(i[n]);return a.sort(f)}(e,!0),r="var cell = this.cell; this.valid = 0; this.missing = 0;",s="this.cell = cell; this.init();",o="if(v==null){++this.missing; return;} if(v!==v) return; ++this.valid;",l="if(v==null){--this.missing; return;} if(v!==v) return; --this.valid;",d="var cell = this.cell;";return a.forEach((function(e){r+=e.init,o+=e.add,l+=e.rem})),e.slice().sort(f).forEach((function(e){d+="t["+t.stringValue(e.out)+"]="+e.set+";"})),d+="return t;",(s=Function("cell",s)).prototype.init=Function(r),s.prototype.add=Function("v","t",o),s.prototype.rem=Function("v","t",l),s.prototype.set=Function("t",d),s.prototype.get=i,s.fields=e.map((function(e){return e.out})),s}function c(e){this._key=e?t.field(e):n.tupleid,this.reset()}var h=c.prototype;function p(e){n.Transform.call(this,null,e),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}h.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null},h.add=function(e){this._add.push(e)},h.rem=function(e){this._rem.push(e)},h.values=function(){if(this._get=null,0===this._rem.length)return this._add;var e,t,n,i=this._add,a=this._rem,r=this._key,s=i.length,u=a.length,o=Array(s-u),l={};for(e=0;e<u;++e)l[r(a[e])]=1;for(e=0,t=0;e<s;++e)l[r(n=i[e])]?l[r(n)]=0:o[t++]=n;return this._rem=[],this._add=o},h.distinct=function(e){for(var n,i=this.values(),a=i.length,r={},s=0;--a>=0;)n=e(i[a])+"",t.hasOwnProperty(r,n)||(r[n]=1,++s);return s},h.extent=function(e){if(this._get!==e||!this._ext){var n=this.values(),i=t.extentIndex(n,e);this._ext=[n[i[0]],n[i[1]]],this._get=e}return this._ext},h.argmin=function(e){return this.extent(e)[0]||{}},h.argmax=function(e){return this.extent(e)[1]||{}},h.min=function(e){var t=this.extent(e)[0];return null!=t?e(t):void 0},h.max=function(e){var t=this.extent(e)[1];return null!=t?e(t):void 0},h.quartile=function(e){return this._get===e&&this._q||(this._q=i.quartiles(this.values(),e),this._get=e),this._q},h.q1=function(e){return this.quartile(e)[0]},h.q2=function(e){return this.quartile(e)[1]},h.q3=function(e){return this.quartile(e)[2]},h.ci=function(e){return this._get===e&&this._ci||(this._ci=i.bootstrapCI(this.values(),1e3,.05,e),this._get=e),this._ci},h.ci0=function(e){return this.ci(e)[0]},h.ci1=function(e){return this.ci(e)[1]},p.Definition={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:o},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]};var v=t.inherits(p,n.Transform);v.transform=function(e,t){var n=this,i=t.fork(t.NO_SOURCE|t.NO_FIELDS),a=e.modified();return n.stamp=i.stamp,n.value&&(a||t.modified(n._inputs,!0))?(n._prev=n.value,n.value=a?n.init(e):{},t.visit(t.SOURCE,e=>n.add(e))):(n.value=n.value||n.init(e),t.visit(t.REM,e=>n.rem(e)),t.visit(t.ADD,e=>n.add(e))),i.modifies(n._outputs),n._drop=!1!==e.drop,e.cross&&n._dims.length>1&&(n._drop=!1,n.cross()),n.changes(i)},v.cross=function(){var e=this,t=e.value,n=e._dnames,i=n.map((function(){return{}})),a=n.length;function r(e){var t,r,s,u;for(t in e)for(s=e[t].tuple,r=0;r<a;++r)i[r][u=s[n[r]]]=u}r(e._prev),r(t),function r(s,u,o){var l,d,f=n[o],m=i[o++];for(l in m)u[f]=m[l],d=s?s+"|"+l:l,o<a?r(d,u,o):t[d]||e.cell(d,u)}("",{},0)},v.init=function(e){var n=this._inputs=[],i=this._outputs=[],a={};function u(e){for(var i,r=t.array(t.accessorFields(e)),s=0,u=r.length;s<u;++s)a[i=r[s]]||(a[i]=1,n.push(i))}this._dims=t.array(e.groupby),this._dnames=this._dims.map((function(e){var n=t.accessorName(e);return u(e),i.push(n),n})),this.cellkey=e.key?e.key:r(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];var o,d,f,c,h,p,v=e.fields||[null],g=e.ops||["count"],y=e.as||[],_=v.length,x={};for(_!==g.length&&t.error("Unmatched number of fields and aggregate ops."),p=0;p<_;++p)o=v[p],d=g[p],null==o&&"count"!==d&&t.error("Null aggregate field specified."),h=s(d,c=t.accessorName(o),y[p]),i.push(h),"count"!==d?((f=x[c])||(u(o),(f=x[c]=[]).field=o,this._measures.push(f)),"count"!==d&&(this._countOnly=!1),f.push(l(d,h))):this._counts.push(h);return this._measures=this._measures.map((function(e){return m(e,e.field)})),{}},v.cellkey=r(),v.cell=function(e,t){var n=this.value[e];return n?0===n.num&&this._drop&&n.stamp<this.stamp?(n.stamp=this.stamp,this._adds[this._alen++]=n):n.stamp<this.stamp&&(n.stamp=this.stamp,this._mods[this._mlen++]=n):(n=this.value[e]=this.newcell(e,t),this._adds[this._alen++]=n),n},v.newcell=function(e,t){var n={key:e,num:0,agg:null,tuple:this.newtuple(t,this._prev&&this._prev[e]),stamp:this.stamp,store:!1};if(!this._countOnly){var i,a=this._measures,r=a.length;for(n.agg=Array(r),i=0;i<r;++i)n.agg[i]=new a[i](n)}return n.store&&(n.data=new c),n},v.newtuple=function(e,t){var i,a,r=this._dnames,s=this._dims,u={};for(i=0,a=s.length;i<a;++i)u[r[i]]=s[i](e);return t?n.replace(t.tuple,u):n.ingest(u)},v.add=function(e){var t,n,i,a=this.cellkey(e),r=this.cell(a,e);if(r.num+=1,!this._countOnly)for(r.store&&r.data.add(e),n=0,i=(t=r.agg).length;n<i;++n)t[n].add(t[n].get(e),e)},v.rem=function(e){var t,n,i,a=this.cellkey(e),r=this.cell(a,e);if(r.num-=1,!this._countOnly)for(r.store&&r.data.rem(e),n=0,i=(t=r.agg).length;n<i;++n)t[n].rem(t[n].get(e),e)},v.celltuple=function(e){var t,n,i,a=e.tuple,r=this._counts;for(e.store&&e.data.values(),n=0,i=r.length;n<i;++n)a[r[n]]=e.num;if(!this._countOnly)for(n=0,i=(t=e.agg).length;n<i;++n)t[n].set(a);return a},v.changes=function(e){var t,n,i,a,r=this._adds,s=this._mods,u=this._prev,o=this._drop,l=e.add,d=e.rem,f=e.mod;if(u)for(n in u)t=u[n],o&&!t.num||d.push(t.tuple);for(i=0,a=this._alen;i<a;++i)l.push(this.celltuple(r[i])),r[i]=null;for(i=0,a=this._mlen;i<a;++i)(0===(t=s[i]).num&&o?d:f).push(this.celltuple(t)),s[i]=null;return this._alen=this._mlen=0,this._prev=null,e};function g(e){n.Transform.call(this,null,e)}g.Definition={type:"Bin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"anchor",type:"number"},{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:"span",type:"number"},{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"]}]};var y=t.inherits(g,n.Transform);function _(e,n,i){var a=e,r=n||[],s=i||[],u={},o=0;return{add:function(e){s.push(e)},remove:function(e){u[a(e)]=++o},size:function(){return r.length},data:function(e,n){return o&&(r=r.filter((function(e){return!u[a(e)]})),u={},o=0),n&&e&&r.sort(e),s.length&&(r=e?t.merge(e,r,s.sort(e)):r.concat(s),s=[]),r}}}function x(e){n.Transform.call(this,[],e)}function b(e){n.Operator.call(this,null,O,e)}function O(e){return this.value&&!e.modified()?this.value:t.compare(e.fields,e.orders)}function D(e){n.Transform.call(this,null,e)}y.transform=function(e,n){var i,a=this._bins(e),r=a.start,s=a.step,u=e.as||["bin0","bin1"],o=u[0],l=u[1];return i=e.modified()?(n=n.reflow(!0)).SOURCE:n.modified(t.accessorFields(e.field))?n.ADD_MOD:n.ADD,n.visit(i,(function(e){var t=a(e);e[o]=t,e[l]=null==t?null:r+s*(1+(t-r)/s)})),n.modifies(u)},y._bins=function(e){if(this.value&&!e.modified())return this.value;var n,a,r=e.field,s=i.bin(e),u=s.start,o=s.stop,l=s.step;null!=(n=e.anchor)&&(a=n-(u+l*Math.floor((n-u)/l)),u+=a,o+=a);var d=function(e){var t=r(e);return null==t?null:(t=Math.max(u,Math.min(+t,o-l)),u+l*Math.floor(1e-14+(t-u)/l))};return d.start=u,d.stop=o,d.step=l,this.value=t.accessor(d,t.accessorFields(r),e.name||"bin_"+t.accessorName(r))},x.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},t.inherits(x,n.Transform).transform=function(e,t){var i=t.fork(t.ALL),a=_(n.tupleid,this.value,i.materialize(i.ADD).add),r=e.sort,s=t.changed()||r&&(e.modified("sort")||t.modified(r.fields));return i.visit(i.REM,a.remove),this.modified(s),this.value=i.source=a.data(n.stableCompare(r),s),t.source&&t.source.root&&(this.value.root=t.source.root),i},t.inherits(b,n.Operator),D.Definition={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"]}]};var E=t.inherits(D,n.Transform);function k(e){n.Transform.call(this,null,e)}E.transform=function(e,t){function n(t){return function(n){for(var i,a=function(e,t,n){switch(t){case"upper":e=e.toUpperCase();break;case"lower":e=e.toLowerCase()}return e.match(n)}(u(n),e.case,r)||[],o=0,l=a.length;o<l;++o)s.test(i=a[o])||t(i)}}var i=this._parameterCheck(e,t),a=this._counts,r=this._match,s=this._stop,u=e.field,o=e.as||["text","count"],l=n((function(e){a[e]=1+(a[e]||0)})),d=n((function(e){a[e]-=1}));return i?t.visit(t.SOURCE,l):(t.visit(t.ADD,l),t.visit(t.REM,d)),this._finish(t,o)},E._parameterCheck=function(e,t){var n=!1;return!e.modified("stopwords")&&this._stop||(this._stop=new RegExp("^"+(e.stopwords||"")+"$","i"),n=!0),!e.modified("pattern")&&this._match||(this._match=new RegExp(e.pattern||"[\\w']+","g"),n=!0),(e.modified("field")||t.modified(e.field.fields))&&(n=!0),n&&(this._counts={}),n},E._finish=function(e,t){var i,a,r,s=this._counts,u=this._tuples||(this._tuples={}),o=t[0],l=t[1],d=e.fork(e.NO_SOURCE|e.NO_FIELDS);for(i in s)a=u[i],r=s[i]||0,!a&&r?(u[i]=a=n.ingest({}),a[o]=i,a[l]=r,d.add.push(a)):0===r?(a&&d.rem.push(a),s[i]=null,u[i]=null):a[l]!==r&&(a[l]=r,d.mod.push(a));return d.modifies(t)},k.Definition={type:"Cross",metadata:{generates:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]},t.inherits(k,n.Transform).transform=function(e,i){var a=i.fork(i.NO_SOURCE),r=this.value,s=e.as||["a","b"],u=s[0],o=s[1];return!r||i.changed(i.ADD_REM)||e.modified("as")||e.modified("filter")?(r&&(a.rem=r),r=i.materialize(i.SOURCE).source,a.add=this.value=function(e,t,i,a){for(var r,s,u=[],o={},l=e.length,d=0;d<l;++d)for(o[t]=s=e[d],r=0;r<l;++r)o[i]=e[r],a(o)&&(u.push(n.ingest(o)),(o={})[t]=s);return u}(r,u,o,e.filter||t.truthy)):a.mod=r,a.source=this.value,a.modifies(s)};var q={kde:i.randomKDE,mixture:i.randomMixture,normal:i.randomNormal,lognormal:i.randomLogNormal,uniform:i.randomUniform},N="distributions",w="function",T="field";function R(e){n.Transform.call(this,null,e)}var C=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"lognormal"},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}]}],S={key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:C},{name:"weights",type:"number",array:!0}]};function M(e,n){return e?e.map((function(e,i){return n[i]||t.accessorName(e)})):null}function U(e,t,n){var i,a,r,s,u,o,l=[],d=function(e){return e(s)};if(null==t)l.push(e.map(n));else for(i={},a=0,r=e.length;a<r;++a)s=e[a],(o=i[u=t.map(d)])||(i[u]=o=[],o.dims=u,l.push(o)),o.push(n(s));return l}R.Definition={type:"Density",metadata:{generates:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number"},{name:"minsteps",type:"number",default:25},{name:"maxsteps",type:"number",default:200},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:C.concat(S)},{name:"as",type:"string",array:!0,default:["value","density"]}]},t.inherits(R,n.Transform).transform=function(e,a){var r=a.fork(a.NO_SOURCE|a.NO_FIELDS);if(!this.value||a.changed()||e.modified()){var s=function e(n,i){var a=n[w];t.hasOwnProperty(q,a)||t.error("Unknown distribution function: "+a);var r=q[a]();for(var s in n)s===T?r.data((n.from||i()).map(n[s])):s===N?r[s](n[s].map((function(t){return e(t,i)}))):typeof r[s]===w&&r[s](n[s]);return r}(e.distribution,function(e){return function(){return e.materialize(e.SOURCE).source}}(a)),u=e.steps||e.minsteps||25,o=e.steps||e.maxsteps||200,l=e.method||"pdf";"pdf"!==l&&"cdf"!==l&&t.error("Invalid density method: "+l),e.extent||s.data||t.error("Missing density extent parameter."),l=s[l];var d=e.as||["value","density"],f=e.extent||t.extent(s.data()),m=i.sampleCurve(l,f,u,o).map(e=>{var t={};return t[d[0]]=e[0],t[d[1]]=e[1],n.ingest(t)});this.value&&(r.rem=this.value),this.value=r.add=r.source=m}return r};function A(e){n.Transform.call(this,null,e)}function F(e){n.Operator.call(this,null,z,e),this.modified(!0)}function z(e){var n=e.expr;return this.value&&!e.modified("expr")?this.value:t.accessor(t=>n(t,e),t.accessorFields(n),t.accessorName(n))}function L(e){n.Transform.call(this,[void 0,void 0],e)}function I(e,t){n.Operator.call(this,e),this.parent=t}A.Definition={type:"DotBin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"step",type:"number"},{name:"smooth",type:"boolean",default:!1},{name:"as",type:"string",default:"bin"}]},t.inherits(A,n.Transform).transform=function(e,a){if(this.value&&!e.modified()&&!a.changed())return a;const r=a.materialize(a.SOURCE).source,s=U(a.source,e.groupby,t.identity),u=e.smooth||!1,o=e.field,l=e.step||function(e,n){return t.span(t.extent(e,n))/30}(r,o),d=n.stableCompare((e,t)=>o(e)-o(t)),f=e.as||"bin",m=s.length;let c,h=1/0,p=-1/0,v=0;for(;v<m;++v){const e=s[v].sort(d);c=-1;for(const t of i.dotbin(e,l,u,o))t<h&&(h=t),t>p&&(p=t),e[++c][f]=t}return this.value={start:h,stop:p,step:l},a.reflow(!0).modifies(f)},t.inherits(F,n.Operator),L.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},t.inherits(L,n.Transform).transform=function(e,n){var i,a=this.value,r=e.field,s=a[0],u=a[1];if(((i=n.changed()||n.modified(r.fields)||e.modified("field"))||null==s)&&(s=1/0,u=-1/0),n.visit(i?n.SOURCE:n.ADD,(function(e){var t=r(e);null!=t&&((t=+t)<s&&(s=t),t>u&&(u=t))})),!Number.isFinite(s)||!Number.isFinite(u)){let e=t.accessorName(r);e&&(e=` for field "${e}"`),n.dataflow.warn(`Infinite extent${e}: [${s}, ${u}]`),s=u=void 0}this.value=[s,u]};var P=t.inherits(I,n.Operator);function j(e){n.Transform.call(this,{},e),this._keys=t.fastmap();var i=this._targets=[];i.active=0,i.forEach=function(e){for(var t=0,n=i.active;t<n;++t)e(i[t],t,i)}}P.connect=function(e){return this.targets().add(e),e.source=this},P.add=function(e){this.value.add.push(e)},P.rem=function(e){this.value.rem.push(e)},P.mod=function(e){this.value.mod.push(e)},P.init=function(e){this.value.init(e,e.NO_SOURCE)},P.evaluate=function(){return this.value};var $=t.inherits(j,n.Transform);function K(e){n.Operator.call(this,null,W,e)}function W(e){return this.value&&!e.modified()?this.value:t.isArray(e.name)?t.array(e.name).map((function(e){return t.field(e)})):t.field(e.name,e.as)}function B(e){n.Transform.call(this,t.fastmap(),e)}function J(e){n.Transform.call(this,[],e)}function Q(e){n.Transform.call(this,[],e)}function V(e){n.Transform.call(this,null,e)}function G(e){n.Transform.call(this,[],e)}$.activate=function(e){this._targets[this._targets.active++]=e},$.subflow=function(e,n,i,a){var r,s,u=this.value,o=t.hasOwnProperty(u,e)&&u[e];return o?o.value.stamp<i.stamp&&(o.init(i),this.activate(o)):(s=a||(s=this._group[e])&&s.tuple,o=(r=i.dataflow).add(new I(i.fork(i.NO_SOURCE),this)).connect(n(r,e,s)),u[e]=o,this.activate(o)),o},$.transform=function(e,t){var i=t.dataflow,a=this,r=e.key,s=e.subflow,u=this._keys,o=e.modified("key");function l(e){return a.subflow(e,s,t)}return this._group=e.group||{},this._targets.active=0,t.visit(t.REM,(function(e){var t=n.tupleid(e),i=u.get(t);void 0!==i&&(u.delete(t),l(i).rem(e))})),t.visit(t.ADD,(function(e){var t=r(e);u.set(n.tupleid(e),t),l(t).add(e)})),o||t.modified(r.fields)?t.visit(t.MOD,(function(e){var t=n.tupleid(e),i=u.get(t),a=r(e);i===a?l(a).mod(e):(u.set(t,a),l(i).rem(e),l(a).add(e))})):t.changed(t.MOD)&&t.visit(t.MOD,(function(e){l(u.get(n.tupleid(e))).mod(e)})),o&&t.visit(t.REFLOW,(function(e){var t=n.tupleid(e),i=u.get(t),a=r(e);i!==a&&(u.set(t,a),l(i).rem(e),l(a).add(e))})),u.empty>i.cleanThreshold&&i.runAfter(u.clean),t},t.inherits(K,n.Operator),B.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},t.inherits(B,n.Transform).transform=function(e,t){var i=t.dataflow,a=this.value,r=t.fork(),s=r.add,u=r.rem,o=r.mod,l=e.expr,d=!0;function f(t){var i=n.tupleid(t),r=l(t,e),f=a.get(i);r&&f?(a.delete(i),s.push(t)):r||f?d&&r&&!f&&o.push(t):(a.set(i,1),u.push(t))}return t.visit(t.REM,(function(e){var t=n.tupleid(e);a.has(t)?a.delete(t):u.push(e)})),t.visit(t.ADD,(function(t){l(t,e)?s.push(t):a.set(n.tupleid(t),1)})),t.visit(t.MOD,f),e.modified()&&(d=!1,t.visit(t.REFLOW,f)),a.empty>i.cleanThreshold&&i.runAfter(a.clean),r},J.Definition={type:"Flatten",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0}]},t.inherits(J,n.Transform).transform=function(e,t){var i=t.fork(t.NO_SOURCE),a=e.fields,r=M(a,e.as||[]),s=r.length;return i.rem=this.value,t.visit(t.SOURCE,(function(e){for(var t,u,o,l=a.map((function(t){return t(e)})),d=l.reduce((function(e,t){return Math.max(e,t.length)}),0),f=0;f<d;++f){for(u=n.derive(e),t=0;t<s;++t)u[r[t]]=null==(o=l[t][f])?null:o;i.add.push(u)}})),this.value=i.source=i.add,i.modifies(r)},Q.Definition={type:"Fold",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0,length:2,default:["key","value"]}]},t.inherits(Q,n.Transform).transform=function(e,i){var a=i.fork(i.NO_SOURCE),r=e.fields,s=r.map(t.accessorName),u=e.as||["key","value"],o=u[0],l=u[1],d=r.length;return a.rem=this.value,i.visit(i.SOURCE,(function(e){for(var t,i=0;i<d;++i)(t=n.derive(e))[o]=s[i],t[l]=r[i](e),a.add.push(t)})),this.value=a.source=a.add,a.modifies(u)},V.Definition={type:"Formula",metadata:{modifies:!0},params:[{name:"expr",type:"expr",required:!0},{name:"as",type:"string",required:!0},{name:"initonly",type:"boolean"}]},t.inherits(V,n.Transform).transform=function(e,t){var n=e.expr,i=e.as,a=e.modified(),r=e.initonly?t.ADD:a?t.SOURCE:t.modified(n.fields)||t.modified(i)?t.ADD_MOD:t.ADD;return a&&(t=t.materialize().reflow(!0)),e.initonly||t.modifies(i),t.visit(r,t=>t[i]=n(t,e))},t.inherits(G,n.Transform).transform=function(e,t){var i,a,r,s=this.value,u=t.fork(t.ALL),o=e.size-s.length,l=e.generator;if(o>0){for(i=[];--o>=0;)i.push(r=n.ingest(l(e))),s.push(r);u.add=u.add.length?u.materialize(u.ADD).add.concat(i):i}else a=s.slice(0,-o),u.rem=u.rem.length?u.materialize(u.REM).rem.concat(a):a,s=s.slice(-o);return u.source=this.value=s,u};var H={value:"value",median:a.median,mean:a.mean,min:a.min,max:a.max},X=[];function Y(e){n.Transform.call(this,[],e)}function Z(e){p.call(this,e)}Y.Definition={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},t.inherits(Y,n.Transform).transform=function(e,i){var a,r,s,u,o,l,d,f,m,c,h=i.fork(i.ALL),p=function(e){var n,i=e.method||H.value;if(null!=H[i])return i===H.value?(n=void 0!==e.value?e.value:0,function(){return n}):H[i];t.error("Unrecognized imputation method: "+i)}(e),v=function(e){var t=e.field;return function(e){return e?t(e):NaN}}(e),g=t.accessorName(e.field),y=t.accessorName(e.key),_=(e.groupby||[]).map(t.accessorName),x=function(e,t,n,i){var a,r,s,u,o,l,d,f,m=function(e){return e(f)},c=[],h=i?i.slice():[],p={},v={};for(h.forEach((function(e,t){p[e]=t+1})),u=0,d=e.length;u<d;++u)f=e[u],l=n(f),o=p[l]||(p[l]=h.push(l)),r=(a=t?t.map(m):X)+"",(s=v[r])||(s=v[r]=[],c.push(s),s.values=a),s[o-1]=f;return c.domain=h,c}(i.source,e.groupby,e.key,e.keyvals),b=[],O=this.value,D=x.domain.length;for(o=0,f=x.length;o<f;++o)for(s=(a=x[o]).values,r=NaN,d=0;d<D;++d)if(null==a[d]){for(u=x.domain[d],c={_impute:!0},l=0,m=s.length;l<m;++l)c[_[l]]=s[l];c[y]=u,c[g]=Number.isNaN(r)?r=p(a,v):r,b.push(n.ingest(c))}return b.length&&(h.add=h.materialize(h.ADD).add.concat(b)),O.length&&(h.rem=h.materialize(h.REM).rem.concat(O)),this.value=b,h},Z.Definition={type:"JoinAggregate",metadata:{modifies:!0},params:[{name:"groupby",type:"field",array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"ops",type:"enum",array:!0,values:o},{name:"as",type:"string",null:!0,array:!0},{name:"key",type:"field"}]};var ee=t.inherits(Z,p);function te(e){n.Transform.call(this,null,e)}function ne(e){n.Operator.call(this,null,ie,e)}function ie(e){return this.value&&!e.modified()?this.value:t.key(e.fields,e.flat)}function ae(e){n.Transform.call(this,[],e)}function re(e,t,i){i.forEach(n.ingest);const a=t.fork(t.NO_FIELDS&t.NO_SOURCE);return a.rem=e.value,e.value=a.add=a.source=i,a}function se(e){n.Transform.call(this,{},e)}function ue(e){n.Operator.call(this,null,oe,e)}function oe(e){if(this.value&&!e.modified())return this.value;var t,n,i,a=1/0,r=-1/0,s=e.extents;for(t=0,n=s.length;t<n;++t)(i=s[t])[0]<a&&(a=i[0]),i[1]>r&&(r=i[1]);return[a,r]}function le(e){n.Operator.call(this,null,de,e)}function de(e){return this.value&&!e.modified()?this.value:e.values.reduce((function(e,t){return e.concat(t)}),[])}function fe(e){n.Transform.call(this,null,e)}function me(e){p.call(this,e)}ee.transform=function(e,n){var i,a=this,r=e.modified();return a.value&&(r||n.modified(a._inputs,!0))?(i=a.value=r?a.init(e):{},n.visit(n.SOURCE,(function(e){a.add(e)}))):(i=a.value=a.value||this.init(e),n.visit(n.REM,(function(e){a.rem(e)})),n.visit(n.ADD,(function(e){a.add(e)}))),a.changes(),n.visit(n.SOURCE,(function(e){t.extend(e,i[a.cellkey(e)].tuple)})),n.reflow(r).modifies(this._outputs)},ee.changes=function(){var e,t,n=this._adds,i=this._mods;for(e=0,t=this._alen;e<t;++e)this.celltuple(n[e]),n[e]=null;for(e=0,t=this._mlen;e<t;++e)this.celltuple(i[e]),i[e]=null;this._alen=this._mlen=0},te.Definition={type:"KDE",metadata:{generates:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"cumulative",type:"boolean",default:!1},{name:"counts",type:"boolean",default:!1},{name:"bandwidth",type:"number",default:0},{name:"extent",type:"number",array:!0,length:2},{name:"resolve",type:"enum",values:["shared","independent"],default:"independent"},{name:"steps",type:"number"},{name:"minsteps",type:"number",default:25},{name:"maxsteps",type:"number",default:200},{name:"as",type:"string",array:!0,default:["value","density"]}]},t.inherits(te,n.Transform).transform=function(e,a){var r=a.fork(a.NO_SOURCE|a.NO_FIELDS);if(!this.value||a.changed()||e.modified()){const s=a.materialize(a.SOURCE).source,u=U(s,e.groupby,e.field),o=(e.groupby||[]).map(t.accessorName),l=e.bandwidth,d=e.cumulative?"cdf":"pdf",f=e.as||["value","density"],m=[];let c=e.extent,h=e.steps||e.minsteps||25,p=e.steps||e.maxsteps||200;"pdf"!==d&&"cdf"!==d&&t.error("Invalid density method: "+d),"shared"===e.resolve&&(c||(c=t.extent(s,e.field)),h=p=e.steps||p),u.forEach(a=>{const r=i.randomKDE(a,l)[d],s=e.counts?a.length:1,u=c||t.extent(a);i.sampleCurve(r,u,h,p).forEach(e=>{const t={};for(let e=0;e<o.length;++e)t[o[e]]=a.dims[e];t[f[0]]=e[0],t[f[1]]=e[1]*s,m.push(n.ingest(t))})}),this.value&&(r.rem=this.value),this.value=r.add=r.source=m}return r},t.inherits(ne,n.Operator),t.inherits(ae,n.Transform).transform=function(e,n){const i=n.dataflow;return e.values?re(this,n,i.parse(e.values,e.format)):i.request(e.url,e.format).then(e=>re(this,n,t.array(e.data)))},se.Definition={type:"Lookup",metadata:{modifies:!0},params:[{name:"index",type:"index",params:[{name:"from",type:"data",required:!0},{name:"key",type:"field",required:!0}]},{name:"values",type:"field",array:!0},{name:"fields",type:"field",array:!0,required:!0},{name:"as",type:"string",array:!0},{name:"default",default:null}]},t.inherits(se,n.Transform).transform=function(e,n){var i,a,r=n,s=e.as,u=e.fields,o=e.index,l=e.values,d=null==e.default?null:e.default,f=e.modified(),m=f?n.SOURCE:n.ADD,c=u.length;return l?(a=l.length,c>1&&!s&&t.error('Multi-field lookup requires explicit "as" parameter.'),s&&s.length!==c*a&&t.error('The "as" parameter has too few output field names.'),s=s||l.map(t.accessorName),i=function(e){for(var t,n,i=0,r=0;i<c;++i)if(null==(n=o.get(u[i](e))))for(t=0;t<a;++t,++r)e[s[r]]=d;else for(t=0;t<a;++t,++r)e[s[r]]=l[t](n)}):(s||t.error("Missing output field names."),i=function(e){for(var t,n=0;n<c;++n)t=o.get(u[n](e)),e[s[n]]=null==t?d:t}),f?r=n.reflow(!0):m|=u.some((function(e){return n.modified(e.fields)}))?n.MOD:0,n.visit(m,i),r.modifies(s)},t.inherits(ue,n.Operator),t.inherits(le,n.Operator),t.inherits(fe,n.Transform),fe.prototype.transform=function(e,t){return this.modified(e.modified()),this.value=e,t.fork(t.NO_SOURCE|t.NO_FIELDS)},me.Definition={type:"Pivot",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"value",type:"field",required:!0},{name:"op",type:"enum",values:o,default:"sum"},{name:"limit",type:"number",default:0},{name:"key",type:"field"}]};var ce=t.inherits(me,p);function he(e){j.call(this,e)}function pe(e){n.Transform.call(this,null,e)}function ve(e){n.Transform.call(this,null,e)}function ge(e){n.Transform.call(this,null,e)}ce._transform=ce.transform,ce.transform=function(e,n){return this._transform(function(e,n){var i=e.field,a=e.value,r=("count"===e.op?"__count__":e.op)||"sum",s=t.accessorFields(i).concat(t.accessorFields(a)),u=function(e,t,n){var i={},a=[];return n.visit(n.SOURCE,(function(t){var n=e(t);i[n]||(i[n]=1,a.push(n))})),a.sort((function(e,t){return(e<t||null==e)&&null!=t?-1:(e>t||null==t)&&null!=e?1:(t=t instanceof Date?+t:t,(e=e instanceof Date?+e:e)!==e&&t==t?-1:t!=t&&e==e?1:0)})),t?a.slice(0,t):a}(i,e.limit||0,n);n.changed()&&e.set("__pivot__",null,null,!0);return{key:e.key,groupby:e.groupby,ops:u.map((function(){return r})),fields:u.map((function(e){return function(e,n,i,a){return t.accessor((function(t){return n(t)===e?i(t):NaN}),a,e+"")}(e,i,a,s)})),as:u.map((function(e){return e+""})),modified:e.modified.bind(e)}}(e,n),n)},t.inherits(he,j).transform=function(e,i){var a=this,r=e.subflow,s=e.field;return(e.modified("field")||s&&i.modified(t.accessorFields(s)))&&t.error("PreFacet does not support field modification."),this._targets.active=0,i.visit(i.MOD,(function(e){var t=a.subflow(n.tupleid(e),r,i,e);s?s(e).forEach((function(e){t.mod(e)})):t.mod(e)})),i.visit(i.ADD,(function(e){var t=a.subflow(n.tupleid(e),r,i,e);s?s(e).forEach((function(e){t.add(n.ingest(e))})):t.add(e)})),i.visit(i.REM,(function(e){var t=a.subflow(n.tupleid(e),r,i,e);s?s(e).forEach((function(e){t.rem(e)})):t.rem(e)})),i},pe.Definition={type:"Project",metadata:{generates:!0,changes:!0},params:[{name:"fields",type:"field",array:!0},{name:"as",type:"string",null:!0,array:!0}]},t.inherits(pe,n.Transform).transform=function(e,t){var i,a,r=e.fields,s=M(e.fields,e.as||[]),u=r?function(e,t){return function(e,t,n,i){for(var a=0,r=n.length;a<r;++a)t[i[a]]=n[a](e);return t}(e,t,r,s)}:n.rederive;return this.value?a=this.value:(t=t.addAll(),a=this.value={}),i=t.fork(t.NO_SOURCE),t.visit(t.REM,(function(e){var t=n.tupleid(e);i.rem.push(a[t]),a[t]=null})),t.visit(t.ADD,(function(e){var t=u(e,n.ingest({}));a[n.tupleid(e)]=t,i.add.push(t)})),t.visit(t.MOD,(function(e){i.mod.push(u(e,a[n.tupleid(e)]))})),i},t.inherits(ve,n.Transform).transform=function(e,t){return this.value=e.value,e.modified("value")?t.fork(t.NO_SOURCE|t.NO_FIELDS):t.StopPropagation},ge.Definition={type:"Quantile",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"field",type:"field",required:!0},{name:"probs",type:"number",array:!0},{name:"step",type:"number",default:.01},{name:"as",type:"string",array:!0,default:["prob","value"]}]};var ye=t.inherits(ge,n.Transform);function _e(e){n.Transform.call(this,null,e)}function xe(e){n.Transform.call(this,[],e),this.count=0}function be(e){n.Transform.call(this,null,e)}function Oe(e){n.Transform.call(this,null,e),this.modified(!0)}function De(e){n.Transform.call(this,t.fastmap(),e)}function Ee(e){n.Transform.call(this,null,e)}ye.transform=function(e,r){var s=r.fork(r.NO_SOURCE|r.NO_FIELDS),u=e.as||["prob","value"];if(this.value&&!e.modified()&&!r.changed())return s.source=this.value,s;const o=U(r.materialize(r.SOURCE).source,e.groupby,e.field),l=(e.groupby||[]).map(t.accessorName),d=[],f=e.step||.01,m=e.probs||a.range(f/2,1-1e-14,f),c=m.length;return o.forEach(e=>{const t=i.quantiles(e,m);for(let i=0;i<c;++i){const a={};for(let t=0;t<l.length;++t)a[l[t]]=e.dims[t];a[u[0]]=m[i],a[u[1]]=t[i],d.push(n.ingest(a))}}),this.value&&(s.rem=this.value),this.value=s.add=s.source=d,s},t.inherits(_e,n.Transform).transform=function(e,t){var i,a;return this.value?a=this.value:(i=t=t.addAll(),a=this.value={}),e.derive&&(i=t.fork(t.NO_SOURCE),t.visit(t.REM,e=>{var t=n.tupleid(e);i.rem.push(a[t]),a[t]=null}),t.visit(t.ADD,e=>{var t=n.derive(e);a[n.tupleid(e)]=t,i.add.push(t)}),t.visit(t.MOD,e=>{var t,r=a[n.tupleid(e)];for(t in e)r[t]=e[t],i.modifies(t);i.mod.push(r)})),i},xe.Definition={type:"Sample",metadata:{},params:[{name:"size",type:"number",default:1e3}]},t.inherits(xe,n.Transform).transform=function(e,t){var a=t.fork(t.NO_SOURCE),r=e.modified("size"),s=e.size,u=this.value,o=this.count,l=0,d=u.reduce((function(e,t){return e[n.tupleid(t)]=1,e}),{});function f(e){var t,r;u.length<s?u.push(e):(r=~~((o+1)*i.random()))<u.length&&r>=l&&(t=u[r],d[n.tupleid(t)]&&a.rem.push(t),u[r]=e),++o}if(t.rem.length&&(t.visit(t.REM,(function(e){var t=n.tupleid(e);d[t]&&(d[t]=-1,a.rem.push(e)),--o})),u=u.filter((function(e){return-1!==d[n.tupleid(e)]}))),(t.rem.length||r)&&u.length<s&&t.source&&(l=o=u.length,t.visit(t.SOURCE,(function(e){d[n.tupleid(e)]||f(e)})),l=-1),r&&u.length>s){for(var m=0,c=u.length-s;m<c;++m)d[n.tupleid(u[m])]=-1,a.rem.push(u[m]);u=u.slice(c)}return t.mod.length&&t.visit(t.MOD,(function(e){d[n.tupleid(e)]&&a.mod.push(e)})),t.add.length&&t.visit(t.ADD,f),(t.add.length||l<0)&&(a.add=u.filter((function(e){return!d[n.tupleid(e)]}))),this.count=o,this.value=a.source=u,a},be.Definition={type:"Sequence",metadata:{generates:!0,changes:!0},params:[{name:"start",type:"number",required:!0},{name:"stop",type:"number",required:!0},{name:"step",type:"number",default:1},{name:"as",type:"string",default:"data"}]},t.inherits(be,n.Transform).transform=function(e,t){if(!this.value||e.modified()){var i=t.materialize().fork(t.MOD),r=e.as||"data";return i.rem=this.value?t.rem.concat(this.value):t.rem,this.value=a.range(e.start,e.stop,e.step||1).map((function(e){var t={};return t[r]=e,n.ingest(t)})),i.add=t.add.concat(this.value),i}},t.inherits(Oe,n.Transform).transform=function(e,t){return this.value=t.source,t.changed()?t.fork(t.NO_SOURCE|t.NO_FIELDS):t.StopPropagation},t.inherits(De,n.Transform).transform=function(e,t){var n=t.dataflow,i=e.field,a=this.value,r=!0;function s(e){a.set(i(e),e)}return e.modified("field")||t.modified(i.fields)?(a.clear(),t.visit(t.SOURCE,s)):t.changed()?(t.visit(t.REM,(function(e){a.delete(i(e))})),t.visit(t.ADD,s)):r=!1,this.modified(r),a.empty>n.cleanThreshold&&n.runAfter(a.clean),t.fork()},t.inherits(Ee,n.Transform).transform=function(e,t){(!this.value||e.modified("field")||e.modified("sort")||t.changed()||e.sort&&t.modified(e.sort.fields))&&(this.value=(e.sort?t.source.slice().sort(n.stableCompare(e.sort)):t.source).map(e.field))};const ke={row_number:function(){return{next:e=>e.index+1}},rank:function(){let e;return{init:()=>e=1,next:t=>{let n=t.index,i=t.data;return n&&t.compare(i[n-1],i[n])?e=n+1:e}}},dense_rank:function(){let e;return{init:()=>e=1,next:t=>{let n=t.index,i=t.data;return n&&t.compare(i[n-1],i[n])?++e:e}}},percent_rank:function(){let e=ke.rank(),t=e.next;return{init:e.init,next:e=>(t(e)-1)/(e.data.length-1)}},cume_dist:function(){let e;return{init:()=>e=0,next:t=>{let n=t.index,i=t.data,a=t.compare;if(e<n){for(;n+1<i.length&&!a(i[n],i[n+1]);)++n;e=n}return(1+e)/i.length}}},ntile:function(e,n){(n=+n)>0||t.error("ntile num must be greater than zero.");let i=ke.cume_dist(),a=i.next;return{init:i.init,next:e=>Math.ceil(n*a(e))}},lag:function(e,t){return t=+t||1,{next:n=>{let i=n.index-t;return i>=0?e(n.data[i]):null}}},lead:function(e,t){return t=+t||1,{next:n=>{let i=n.index+t,a=n.data;return i<a.length?e(a[i]):null}}},first_value:function(e){return{next:t=>e(t.data[t.i0])}},last_value:function(e){return{next:t=>e(t.data[t.i1-1])}},nth_value:function(e,n){return(n=+n)>0||t.error("nth_value nth must be greater than zero."),{next:t=>{let i=t.i0+(n-1);return i<t.i1?e(t.data[i]):null}}},prev_value:function(e){let t=null;return{next:n=>{let i=e(n.data[n.index]);return null!=i?t=i:t}}},next_value:function(e){let t=null,n=-1;return{next:i=>{let a=i.data;return i.index<=n?t:(n=function(e,t,n){for(let i=t.length;n<i;++n){if(null!=e(t[n]))return n}return-1}(e,a,i.index))<0?(n=a.length,t=null):t=e(a[n])}}}};var qe=Object.keys(ke);function Ne(e){let n=this,i=t.array(e.ops),a=t.array(e.fields),r=t.array(e.params),u=t.array(e.as),o=n.outputs=[],d=n.windows=[],f={},h={},p=!0,v=[],g=[];function y(e){t.array(t.accessorFields(e)).forEach(e=>f[e]=1)}y(e.sort),i.forEach((function(e,n){let i=a[n],f=t.accessorName(i),m=s(e,f,u[n]);if(y(i),o.push(m),t.hasOwnProperty(ke,e))d.push(function(e,n,i,a){let r=ke[e](n,i);return{init:r.init||t.zero,update:function(e,t){t[a]=r.next(e)}}}(e,a[n],r[n],m));else{if(null==i&&"count"!==e&&t.error("Null aggregate field specified."),"count"===e)return void v.push(m);p=!1;let n=h[f];n||((n=h[f]=[]).field=i,g.push(n)),n.push(l(e,m))}})),(v.length||g.length)&&(n.cell=function(e,t,n){e=e.map(e=>m(e,e.field));let i={num:0,agg:null,store:!1,count:t};if(!n)for(var a=e.length,r=i.agg=Array(a),s=0;s<a;++s)r[s]=new e[s](i);if(i.store)var u=i.data=new c;return i.add=function(e){if(i.num+=1,!n){u&&u.add(e);for(let t=0;t<a;++t)r[t].add(r[t].get(e),e)}},i.rem=function(e){if(i.num-=1,!n){u&&u.rem(e);for(let t=0;t<a;++t)r[t].rem(r[t].get(e),e)}},i.set=function(e){let a,s;for(u&&u.values(),a=0,s=t.length;a<s;++a)e[t[a]]=i.num;if(!n)for(a=0,s=r.length;a<s;++a)r[a].set(e)},i.init=function(){i.num=0,u&&u.reset();for(let e=0;e<a;++e)r[e].init()},i}(g,v,p)),n.inputs=Object.keys(f)}const we=Ne.prototype;function Te(e){n.Transform.call(this,{},e),this._mlen=0,this._mods=[]}we.init=function(){this.windows.forEach(e=>e.init()),this.cell&&this.cell.init()},we.update=function(e,t){let n,i=this.cell,a=this.windows,r=e.data,s=a&&a.length;if(i){for(n=e.p0;n<e.i0;++n)i.rem(r[n]);for(n=e.p1;n<e.i1;++n)i.add(r[n]);i.set(t)}for(n=0;n<s;++n)a[n].update(e,t)},Te.Definition={type:"Window",metadata:{modifies:!0},params:[{name:"sort",type:"compare"},{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:qe.concat(o)},{name:"params",type:"number",null:!0,array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"frame",type:"number",null:!0,array:!0,length:2,default:[null,0]},{name:"ignorePeers",type:"boolean",default:!1}]};var Re=t.inherits(Te,n.Transform);function Ce(e,n,i,r){var s=r.sort,u=s&&!r.ignorePeers,o=r.frame||[null,0],l=e.data(i),d=l.length,f=0,m=u?a.bisector(s):null,c={i0:0,i1:0,p0:0,p1:0,index:0,data:l,compare:s||t.constant(-1)};for(n.init();f<d;++f)Se(c,o,f,d),u&&Me(c,m),n.update(c,l[f])}function Se(e,t,n,i){e.p0=e.i0,e.p1=e.i1,e.i0=null==t[0]?0:Math.max(0,n-Math.abs(t[0])),e.i1=null==t[1]?i:Math.min(i,n+Math.abs(t[1])+1),e.index=n}function Me(e,t){var n=e.i0,i=e.i1-1,a=e.compare,r=e.data,s=r.length-1;n>0&&!a(r[n],r[n-1])&&(e.i0=t.left(r,r[n])),i<s&&!a(r[i],r[i+1])&&(e.i1=t.right(r,r[i]))}Re.transform=function(e,t){var i,a,s=this,u=s.state,o=e.modified(),l=n.stableCompare(e.sort);this.stamp=t.stamp,u&&!o||(u=s.state=new Ne(e));var d=r(e.groupby);function f(e){return s.group(d(e))}for(o||t.modified(u.inputs)?(s.value={},t.visit(t.SOURCE,(function(e){f(e).add(e)}))):(t.visit(t.REM,(function(e){f(e).remove(e)})),t.visit(t.ADD,(function(e){f(e).add(e)}))),i=0,a=s._mlen;i<a;++i)Ce(s._mods[i],u,l,e);return s._mlen=0,s._mods=[],t.reflow(o).modifies(u.outputs)},Re.group=function(e){var t=this.value[e];return t||((t=this.value[e]=_(n.tupleid)).stamp=-1),t.stamp<this.stamp&&(t.stamp=this.stamp,this._mods[this._mlen++]=t),t},e.aggregate=p,e.bin=g,e.collect=x,e.compare=b,e.countpattern=D,e.cross=k,e.density=R,e.dotbin=A,e.expression=F,e.extent=L,e.facet=j,e.field=K,e.filter=B,e.flatten=J,e.fold=Q,e.formula=V,e.generate=G,e.impute=Y,e.joinaggregate=Z,e.kde=te,e.key=ne,e.load=ae,e.lookup=se,e.multiextent=ue,e.multivalues=le,e.params=fe,e.pivot=me,e.prefacet=he,e.project=pe,e.proxy=ve,e.quantile=ge,e.relay=_e,e.sample=xe,e.sequence=be,e.sieve=Oe,e.subflow=I,e.tupleindex=De,e.values=Ee,e.window=Te,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "vega-transforms",
"version": "4.4.1",
"version": "4.4.2",
"description": "Data processing transforms for Vega dataflows.",

@@ -34,7 +34,7 @@ "keywords": [

"d3-array": "^2.3.2",
"vega-dataflow": "^5.4.0",
"vega-dataflow": "^5.4.1",
"vega-statistics": "^1.6.0",
"vega-util": "^1.11.2"
},
"gitHead": "b1337d09ced5f517d54c8ec17fdf849651f5c16c"
"gitHead": "e9ce2c4394348a304ac8c00c1c36efdf66abbb46"
}

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

import {derive, rederive, Transform, tupleid} from 'vega-dataflow';
import {derive, Transform, tupleid} from 'vega-dataflow';
import {inherits} from 'vega-util';

@@ -46,11 +46,11 @@

pulse.visit(pulse.MOD, t => {
out.mod.push(rederive(t, lut[tupleid(t)]));
var dt = lut[tupleid(t)], k;
for (k in t) {
dt[k] = t[k];
// down stream writes may overwrite re-derived tuples
// conservatively mark all source fields as modified
out.modifies(k);
}
out.mod.push(dt);
});
if (pulse.mod.length) {
// down stream writes may overwrite re-derived tuples
// conservatively mark all source fields as modified
pulse.materialize(pulse.MOD);
out.modifies(Object.keys(pulse.mod[0]));
}
}

@@ -57,0 +57,0 @@

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc