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

vega-parser

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-parser - npm Package Compare versions

Comparing version 1.0.0-beta.4 to 1.0.0-beta.5

src/parsers/codegen.js

4

build/vega-parser.min.js

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

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-expression"),require("vega-dataflow")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-expression","vega-dataflow"],t):t(e.vega=e.vega||{},e.vega,e.vega,e.vega)}(this,function(e,t,n,a){"use strict";function i(e){return"_["+t.stringValue("$"+e)+"]"}function r(e,t,n){var a=De+e;!n.hasOwnProperty(a)&&t.getSignal(e)&&(n[a]=t.signalRef(e))}function o(e,t,n){var a=_e+e;if(!n.hasOwnProperty(a))try{n[a]=t.scaleRef(e)}catch(e){}}function l(e,t,n,a){var i=Fe+t;a.hasOwnProperty(i)||(a[i]=n.getData(e).indataRef(n,t))}function s(e,t,n){var a=Ce+e;n.hasOwnProperty(a)||(n[a]=t.getData(e).tuplesRef())}function u(e){return Ne.hasOwnProperty(e)}function d(e,t,n,a,i){for(var r,o=0,l=e.length;t<l;++t){if(r=e[t],i&&i.indexOf(r)>=0&&--o,r===n&&!o)return t;a&&a.indexOf(r)>=0&&++o}return t}function f(e){for(var t=[],n=0,a=e.length,i=0;i<a;)i=d(e,i,Ke,Je+Xe,He+Ye),t.push(e.substring(n,i).trim()),n=++i;if(0===t.length)throw"Empty event selector: "+e;return t}function c(e){return"["===e[0]?p(e):g(e)}function p(e){var t,n,a=1,i=e.length,r=1;if(r=d(e,r,He,Je),r===i)throw"Empty between selector: "+e;if(t=f(e.substring(a,r)),2!==t.length)throw"Between selector must have two elements: "+e;if(e=e.slice(r+1).trim(),e[0]!==Qe)throw"Expected '>' after between selector: "+e;return t=t.map(c),n=c(e.slice(1).trim()),n.between?{between:t,stream:n}:(n.between=t,n)}function g(e){var t,n,a={source:"view"},i=[],r=[0,0],o=0,l=0,s=e.length,f=0;if(e[s-1]===Ye){if(f=e.lastIndexOf(Xe),!(f>=0))throw"Unmatched right brace: "+e;try{r=h(e.substring(f+1,s-1))}catch(t){throw"Invalid throttle specification: "+e}e=e.slice(0,f).trim(),s=e.length,f=0}if(!s)throw e;if("@"===e[0]&&(o=++f),t=d(e,f,Ge),t<s&&(i.push(e.substring(l,t).trim()),l=f=++t),f=d(e,f,Je),f===s)i.push(e.substring(l,s).trim());else if(i.push(e.substring(l,f).trim()),n=[],l=++f,l===s)throw"Unmatched left bracket: "+e;for(;f<s;){if(f=d(e,f,He),f===s)throw"Unmatched left bracket: "+e;if(n.push(e.substring(l,f).trim()),f<s-1&&e[++f]!==Je)throw"Expected left bracket: "+e;l=++f}if(!(s=i.length)||Ze.test(i[s-1]))throw"Invalid event selector: "+e;return s>1?(a.type=i[1],o?a.markname=i[0].slice(1):u(i[0])?a.marktype=i[0]:a.source=i[0]):a.type=i[0],"!"===a.type.slice(-1)&&(a.consume=!0,a.type=a.type.slice(0,-1)),null!=n&&(a.filter=n),r[0]&&(a.throttle=r[0]),r[1]&&(a.debounce=r[1]),a}function h(e){var t=e.split(Ke);if(!e.length||t.length>2)throw e;return t.map(function(t){var n=+t;if(n!==n)throw e;return n})}function m(e,n){var a=e.merge?v:e.stream?y:e.type?b:t.error("Invalid stream specification: "+JSON.stringify(e));return a(e,n)}function v(e,t){var n=e.merge.map(function(e){return m(e,t)}),a=x({merge:n},e,t);return t.addStream(a).id}function y(e,t){var n=m(e.stream,t),a=x({stream:n},e,t);return t.addStream(a).id}function b(e,t){var n=t.event(e.source||et,e.type),a=x({stream:n},e,t);return 1===Object.keys(a).length?n:t.addStream(a).id}function x(e,n,a){var i,r;return(i=n.between)&&(2!==i.length&&t.error("Stream between parameter must have 2 entries."),e.between=[m(i[0],a),m(i[1],a)]),r=n.marktype||n.markname,(n.filter||r)&&(i=n.filter?t.array(n.filter):[],r&&i.push(k(n.marktype,n.markname)),e.filter=Me("("+i.join(")&&(")+")").$expr),null!=(i=n.throttle)&&(e.throttle=+i),null!=(i=n.debounce)&&(e.debounce=+i),n.consume&&(e.consume=!0),e}function k(e,t){var n="event.item";return n+(e&&"*"!==e?"&&"+n+".mark.marktype==='"+e+"'":"")+(t?"&&"+n+".mark.name==='"+t+"'":"")}function S(e,n){return t.isArray(e)?e.map(function(e){return S(e,n)}):t.isObject(e)?e.signal?n.signalRef(e.signal):t.error("Unsupported parameter object: "+JSON.stringify(e)):e}function w(e,n,a,i){var r,o,l;if(e.signal)r="datum",l=ut(e.signal,n,a,i);else if(e.group||e.parent){for(o=Math.max(1,e.level||1),r="item";o-- >0;)r+=".mark.group";e.parent?(l=e.parent,r+=".datum"):l=e.group}else e.datum?(r="datum",l=e.datum):t.error("Invalid field reference: "+JSON.stringify(e));return e.signal||(t.isString(l)?(i[l]=1,l=t.splitAccessPath(l).map(t.stringValue).join("][")):l=w(l,n,a,i)),r+"["+l+"]"}function R(e,n){if(!t.isString(e))return-1;var a=n.scaleType(e);return"band"===a||"point"===a?1:0}function z(e,n,a,i){var r;if(t.isString(e))r=_e+e,a.hasOwnProperty(r)||(a[r]=n.scaleRef(e)),r=t.stringValue(r);else{for(r in n.scales)a[_e+r]=n.scaleRef(r);r=t.stringValue(_e)+"+"+dt(e,n,a,i)}return"_["+r+"]"}function O(e,n,a,i){var r,o,l,s={},u="var o=item,datum=o.datum,$;";for(r in e)o=e[r],t.isArray(o)?u+=mt(r,o,i,a,s):(l=gt(r,o,i,a,s),u+=ht("o",r,l));return u+=lt(e,n),u+="return 1;",{$expr:u,$fields:Object.keys(s),$output:Object.keys(e)}}function $(e){return t.isObject(e)?e:{value:e}}function P(e,n){for(var a in n)"interactive"!==a&&(e[a]=t.extend(e[a]||{},n[a]));return e}function E(e,t,n,a,i){var r,o;i=i||{},i.encoders={$encode:r={}},e=j(e,t,n,a.config);for(o in e)r[o]=O(e[o],t,i,a);return i}function j(e,n,a,i){var r,o,l;if(i=i&&(a===yt?i.group:a===vt?i.mark&&i.mark[n]:null)){r={};for(o in i)l=D(o,e)||("fill"===o||"stroke"===o)&&(D("fill",e)||D("stroke",e)),l||(r[o]={value:i[o]});e=t.extend({},e),e.enter=t.extend(r,e.enter)}return e}function D(e,t){return t.enter&&t.enter[e]||t.update&&t.update[e]}function _(e,t,n,a){this.id=-1,this.type=e,this.value=t,this.params=n,a&&(this.parent=a)}function F(e,t,n,a){return new _(e,t,n,a)}function C(e,t){return F("Operator",e,t)}function A(e){return{$ref:e.id}}function W(e,t){return t?{$field:e,$name:t}:{$field:e}}function L(e,t){return{$compare:e,$order:t}}function M(e){return{$key:e}}function U(e){return t.isObject(e)?(e.order===tn?"-":"+")+V(e.op,e.field):""}function V(e,t){return(e&&e.signal?"$"+e.signal:e||"")+(e&&t?"_":"")+(t&&t.signal?"$"+t.signal:t||"")}function q(e){return e&&e.signal}function T(e){return function(t,n,a){return F(e,n,t||void 0,a)}}function B(e,t,n){var a,i,r,o={};for(i=0,r=e.params.length;i<r;++i)a=e.params[i],o[a.name]=N(a,t,n);return o}function N(e,n,a){var i,r=e.type;return"index"===r?J(e,n,a):"param"===r?H(e,n,a):"projection"===r?a.projectionRef(n[e.name]):(i=n[e.name],void 0===i?void(e.required&&t.error("Missing required parameter: "+e.name)):e.array&&!q(i)?i.map(function(t){return I(e,t,a)}):I(e,i,a))}function I(e,n,a){var i=e.type;if(q(n))return Q(i)?t.error("Expression references can not be signals."):Z(i)?a.fieldRef(n):ee(i)?a.compareRef(n):a.signalRef(n.signal);var r=e.expr||Z(i);return r&&Y(n)?Me(n.expr,a):r&&G(n)?W(n.field):Q(i)?Me(n,a):K(i)?A(a.getData(n).values):Z(i)?W(n):ee(i)?L(t.array(n.field),t.array(n.order)):n}function J(e,n,a){return t.isString(n.from)||t.error('Lookup "from" parameter must be a string literal.'),a.getData(n.from).lookupRef(a,n.key)}function H(e,n,a){var i=n[e.name];return e.array?(t.isArray(i)||t.error("Expected an array of sub-parameters. Instead: "+i),i.map(function(t){return X(e,t,a)})):X(e,i,a)}function X(e,n,a){var i,r,o,l,s;for(l=0,s=e.params.length;l<s;++l){r=e.params[l];for(o in r.key)if(r.key[o]!==n[o]){r=null;break}if(r)break}return r||t.error("Unsupported parameter: "+JSON.stringify(n)),i=t.extend(B(r,n,a),r.key),A(a.add(vn(i)))}function Y(e){return e&&e.expr}function G(e){return e&&e.field}function K(e){return"data"===e}function Q(e){return"expr"===e}function Z(e){return"field"===e}function ee(e){return"compare"===e}function te(e,t,n,a){this.scope=e,this.input=t,this.output=n,this.values=a,this.index={}}function ne(e){return t.isString(e)?e:null}function ae(e,t,n){var a,i=V(n.op,n.field);if(t.ops){for(var r=0,o=t.as.length;r<o;++r)if(t.as[r]===i)return}else t.ops=["count"],t.fields=[null],t.as=["count"];n.op&&(t.ops.push((a=n.op.signal)?e.signalRef(a):n.op),t.fields.push(e.fieldRef(n.field)),t.as.push(i))}function ie(e,t,n,a,i,r,o){var l,s,u=t[n]||(t[n]={}),d=U(r),f=ne(i);if(null!=f&&(e=t.scope,f+=d?"|"+d:"",l=u[f]),!l){var c=r?{field:Zt,pulse:t.countsRef(e,i,r)}:{field:e.fieldRef(i),pulse:A(t.output)};d&&(c.sort=e.sortRef(r)),s=e.add(F(a,void 0,c)),o&&(t.index[i]=s),l=A(s),null!=f&&(u[f]=l)}return l}function re(e,t){return null!=e?e:t}function oe(e,t,n){var a,i=+t.symbolSize;return a=n&&n.update&&n.update.fontSize,a||(a=n&&n.enter&&n.enter.fontSize),a&&(a=a.value),a||(a=+t.labelFontSize),e.size?{$expr:"Math.max(ceil(sqrt(_.scale(datum))),"+a+")"}:Math.max(Math.ceil(Math.sqrt(i)),a)}function le(e){return Wn.hasOwnProperty(e)}function se(e){return"quantile"===e}function ue(e,n){return t.isObject(e)?e.signal?n.signalRef(e.signal):t.error("Unsupported object: "+e):e}function de(e,n,a){if(e)return e.signal?a.signalRef(e.signal):(t.isArray(e)?fe:e.fields?pe:ce)(e,n,a)}function fe(e,t,n){return e.map(function(e){return ue(e,n)})}function ce(e,n,a){var i=a.getData(e.data);return i||t.error("Can not find data set: "+e.data),le(n.type)?i.valuesRef(a,e.field,he(e.sort,!1)):se(n.type)?i.domainRef(a,e.field):i.extentRef(a,e.field)}function pe(e,n,a){var i=e.data,r=e.fields.reduce(function(e,n){return e.push(t.isString(n)?{data:i,field:n}:n),e},[]);return(le(n.type)?ge:se(n.type)?me:ve)(e,a,r)}function ge(e,n,a){var i,r,o,l;return i=a.map(function(e){var a=n.getData(e.data);return a||t.error("Can not find data set: "+e.data),a.countsRef(n,e.field)}),r=n.add(nn({groupby:Zt,ops:["sum"],fields:[n.fieldRef("count")],as:["count"],pulse:i})),o=n.add(on({pulse:A(r)})),l=n.add(zn({field:Zt,sort:n.sortRef(he(e.sort,!0)),pulse:A(o)})),A(l)}function he(e,n){return e&&(e.field||e.op?e.field||"count"===e.op?n&&e.field?t.error("Multiple domain scales can not sort by field."):n&&e.op&&"count"!==e.op&&t.error("Multiple domain scales support op count only."):t.error("No field provided for sort aggregate op: "+e.op):t.isObject(e)?e.field="key":e={field:"key"}),e}function me(e,n,a){var i=a.map(function(e){var a=n.getData(e.data);return a||t.error("Can not find data set: "+e.data),a.domainRef(n,e.field)});return A(n.add(mn({values:i})))}function ve(e,n,a){var i=a.map(function(e){var a=n.getData(e.data);return a||t.error("Can not find data set: "+e.data),a.extentRef(n,e.field)});return A(n.add(hn({extents:i})))}function ye(e,n){var a=e.range,i=n.config.range;if(a.signal)return n.signalRef(a.signal);if(t.isString(a))i&&i.hasOwnProperty(a)?a=i[a]:"width"===a?a=[0,{signal:"width"}]:"height"===a?a=le(e.type)?[0,{signal:"height"}]:[{signal:"height"},0]:t.error("Unrecognized scale range value: "+a);else{if(le(e.type)&&!t.isArray(a))return de(a,e,n);t.isArray(a)||t.error("Unsupported range type: "+a)}return a.map(function(e){return ue(e,n)})}function be(e,t){var n=[];e.transform&&e.transform.forEach(function(e){n.push(On(e,t))}),e.on&&e.on.forEach(function(n){Dn(n,t,e.name)}),t.addDataPipeline(e.name,xe(e,t,n))}function xe(e,t,n){var a,i,r,o,l,s=[],u=null,d=!1,f=!1;for(e.values?s.push(u=ke({$ingest:e.values,$format:e.format})):e.url?s.push(u=ke({$request:e.url,$format:e.format})):e.source&&(a=t.getData(e.source),u=a.output,s.push(null)),i=0,r=n.length;i<r;++i)o=n[i],l=o.metadata,u||l.source||s.push(u=ke()),s.push(o),l.generates&&(f=!0),l.modifies&&!f&&(d=!0),l.source?u=o:l.changes&&(u=null);return a&&(s[0]=xn({derive:d,pulse:A(a.output)}),d&&s.splice(1,0,ke())),u||s.push(ke()),s.push(wn({})),s}function ke(e){var t=on({},e);return t.metadata={source:!0},t}function Se(e,t){return{scale:e.scale,range:t}}function we(e,n){var a,i,r,o,l;return n.background=e.background||n.config.background,l=A(n.root=n.add(C())),n.addSignal("width",e.width||-1),n.addSignal("height",e.height||-1),n.addSignal("padding",$e(e.padding)),t.array(e.signals).forEach(function(e){Jn[e.name]||Pe(e,n)}),i=n.add(on()),r=P({enter:{x:{value:0},y:{value:0}},update:{width:{signal:"width"},height:{signal:"height"}}},e.encode),r=n.add(un(E(r,Ue,yt,n,{pulse:A(i)}))),o=n.add(Rn({legendMargin:n.config.legendMargin,autosize:e.autosize||n.config.autosize,mark:l,pulse:A(r)})),n.pushState(A(r),A(o)),In(e,n,!0),a=n.add(rn({mark:l,pulse:A(o)})),a=n.add(kn({pulse:A(a)})),a=n.add(wn({pulse:A(a)})),n.addData("root",new te(n,i,i,a)),n}function Re(e){this.config=e,this.bindings=[],this.field={},this.signals={},this.lambdas={},this.scales={},this.events={},this.data={},this.streams=[],this.updates=[],this.operators=[],this.background=null,this._id=0,this._subid=0,this._nextsub=[0],this._parent=[],this._encode=[],this._markpath=[]}function ze(e){this.config=e.config,this.field=Object.create(e.field),this.signals=Object.create(e.signals),this.lambdas=Object.create(e.lambdas),this.scales=Object.create(e.scales),this.events=Object.create(e.events),this.data=Object.create(e.data),this.streams=[],this.updates=[],this.operators=[],this._id=0,this._subid=++e._nextsub[0],this._nextsub=e._nextsub,this._parent=e._parent.slice(),this._encode=e._encode.slice(),this._markpath=e._markpath}function Oe(){return{autosize:"pad",background:null,group:null,mark:{arc:{fill:"steelblue"},area:{fill:"steelblue"},image:null,line:{stroke:"steelblue"},path:{stroke:"steelblue"},rect:{fill:"steelblue"},rule:{stroke:"#000"},shape:{stroke:"steelblue"},symbol:{fill:"steelblue",size:64},text:{fill:"#000",font:"sans-serif",fontSize:11}},axis:{minExtent:0,maxExtent:200,bandPosition:.5,domainDefault:!0,domainWidth:1,domainColor:"#000",gridDefault:!1,gridWidth:1,gridColor:"#ddd",gridDash:[],gridOpacity:1,tickPadding:2,tickRound:!0,tickSize:5,tickWidth:1,tickColor:"#000",tickLabelColor:"#000",tickLabelFont:"sans-serif",tickLabelFontSize:10,titleAlign:"center",titlePadding:2,titleColor:"#000",titleFont:"sans-serif",titleFontSize:11,titleFontWeight:"bold"},legend:{orient:"right",offset:18,padding:0,entryPadding:5,titlePadding:5,gradientWidth:100,gradientHeight:20,gradientStrokeColor:"#ddd",gradientStrokeWidth:0,gradientLabelBaseline:"top",gradientLabelOffset:2,labelColor:"#000",labelFontSize:10,labelFont:"sans-serif",labelAlign:"left",labelBaseline:"middle",labelOffset:8,symbolType:"circle",symbolSize:100,symbolColor:"#888",symbolStrokeWidth:1.5,titleColor:"#000",titleFont:"sans-serif",titleFontSize:11,titleFontWeight:"bold",titleAlign:"left",titleBaseline:"top"},range:{category:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],symbol:["circle","square","triangle-up","cross","diamond","triangle-right","triangle-down","triangle-left"]}}}var $e=function(e){return t.isObject(e)?e:t.isNumber(e)?{top:e,bottom:e,left:e,right:e}:{top:0,left:0,bottom:0,right:0}},Pe=function(e,t){var n=t.addSignal(e.name,e.value);e.react===!1&&(n.react=!1),e.bind&&t.addBinding(e.name,e.bind)},Ee="Literal",je="Identifier",De="$",_e="%",Fe="@",Ce=":",Ae="event.vega.",We=function(e){var t=n.functions(e);return t.view=Ae+"view",t.item=Ae+"item",t.group=Ae+"group",t.xy=Ae+"xy",t.x=Ae+"x",t.y=Ae+"y",t.encode="this.encode",t.modify="this.modify",t.format="this.format",t.timeFormat="this.timeFormat",t.utcFormat="this.utcFormat",t.pad="this.pad",t.truncate="this.truncate",t.rgb="this.rgb",t.lab="this.lab",t.hcl="this.hcl",t.hsl="this.hsl",t.gradient="this.gradient",t.copy="this.scaleCopy",t.domain="this.domain",t.bandwidth="this.bandwidth",t.indata="this.indata",t.inrange="this.inrange",t.invert="this.scaleInvert",t.range="this.range",t.scale="this.scale",t.span="this.span",t.tuples="this.tuples",t.clampRange="this.clampRange",t.pinchDistance="this.pinchDistance",t.pinchAngle="this.pinchAngle",t.open="this.open",t.screen=function(){return"window.screen"},t.windowsize=function(){return"[window.innerWidth, window.innerHeight]"},t},Le=n.codegen({blacklist:["_"],whitelist:["datum","event"],fieldvar:"datum",globalvar:i,functions:We,constants:n.constants}),Me=function(e,a,i){var u,d,f={};try{u=n.parse(e)}catch(n){t.error("Expression parse error: "+e)}return u.visit(function(e){if("CallExpression"===e.type){var i=e.callee.name,r=e.arguments;switch(i){case"bandwidth":case"copy":case"domain":case"range":case"gradient":case"invert":case"scale":r[0].type===Ee?o(r[0].value,a,f):r[0].type===je&&(i=r[0].name,r[0]=new n.ASTNode(Ee),r[0].raw='{signal:"'+i+'"}');break;case"indata":r[0].type!==Ee&&t.error("First argument to indata must be a string literal."),r[1].type!==Ee&&t.error("Second argument to indata must be a string literal."),l(r[0].value,r[1].value,a,f);break;case"tuples":r[0].type!==Ee&&t.error("First argument to tuples must be a string literal."),s(r[0].value,a,f)}}}),d=Le(u),d.globals.forEach(function(e){r(e,a,f)}),{$expr:i?i+"return("+d.code+");":d.code,$fields:d.fields,$params:f}},Ue="group",Ve="rect",qe="rule",Te="symbol",Be="text",Ne=t.toSet(["*","arc","area","group","image","line","path","rect","rule","shape","symbol","text"]),Ie=function(e){return f(e.trim()).map(c)},Je="[",He="]",Xe="{",Ye="}",Ge=":",Ke=",",Qe=">",Ze=/[\[\]\{\}]/,et="view",tt=function(e,t){return e.signal?t.getSignal(e.signal).id:m(e,t)},nt="var datum=event.item&&event.item.datum;",at=function(e,n,a){var i,r=e.events,o=e.update,l=e.encode,s=[],u="";r||t.error("Signal update missing events specification."),t.isString(r)&&(r=Ie(r)),r=t.array(r).filter(function(e){return e.signal?(s.push(e),0):1}),r.length&&s.push(r.length>1?{merge:r}:r[0]),null!=l&&(o&&t.error("Signal encode and update are mutually exclusive."),o="encode(item(),"+t.stringValue(l)+")"),u=t.isString(o)?Me(o,n,nt):null!=o.expr?Me(o.expr,n,nt):null!=o.value?o.value:null!=o.signal?{$expr:"_.value",$params:{value:n.signalRef(o.signal)}}:t.error("Invalid signal update specification."),i={target:a,update:u},e.force&&(i.options={force:!0}),s.forEach(function(e){e={source:tt(e,n)},n.addUpdate(t.extend(e,i))})},it=function(e,t){var n=t.getSignal(e.name);if(e.update){var a=Me(e.update,t);n.update=a.$expr,n.params=a.$params}e.on&&e.on.forEach(function(e){at(e,t,n.id)})},rt=function(e,t){var n={};for(var a in e)"name"!==a&&(n[a]=S(e[a],t));t.addProjection(e.name,n)},ot=t.toSet(["rule"]),lt=function(e,t){var n="";return ot[t]?n:(e.x2&&(e.x?(n+="if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;",n+="o.width=o.x2-o.x;"):n+=e.width?"o.x=o.x2-o.width;":"o.x=o.x2;"),e.xc&&(n+=e.width?"o.x=o.xc-o.width/2;":"o.x=o.xc;"),e.y2&&(e.y?(n+="if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;",n+="o.height=o.y2-o.y;"):n+=e.height?"o.y=o.y2-o.height;":"o.y=o.y2;"),e.yc&&(n+=e.height?"o.y=o.yc-o.height/2;":"o.y=o.yc;"),n)},st=function(e,t,n,a){function i(e,i,r,o){var l=gt(null,i,t,n,a),s=gt(null,r,t,n,a),u=gt(null,o,t,n,a);return"this."+e+"("+[l,s,u].join(",")+").toString()"}return e.c?i("hcl",e.h,e.c,e.l):e.h||e.s?i("hsl",e.h,e.s,e.l):e.l||e.a?i("lab",e.l,e.a,e.b):e.r||e.g||e.b?i("rgb",e.r,e.g,e.b):null},ut=function(e,n,a,i){var r=Me(e,n);return r.$fields.forEach(function(e){i[e]=1}),t.extend(a,r.$params),r.$expr},dt=function(e,n,a,i){return w(t.isObject(e)?e:{datum:e},n,a,i)},ft=function(e,t,n,a,i){var r,o,l,s=z(e.scale,n,a,i);return null!=e.range?(r=+e.range,o=s+".range()",t=0===r?o+"[0]":"($="+o+","+(1===r?"$[$.length-1]":"$[0]+"+r+"*($[$.length-1]-$[0])")+")"):(t=null!=t?s+"("+t+")":null,e.band&&(l=R(e.scale,n))&&(o=s+".bandwidth",r=+e.band,r=o+"()"+(1===r?"":"*"+r),l<0&&(r="("+o+"?"+r+":0)"),t=(t?t+"+":"")+r,e.extra&&(t="(datum.extra?"+s+"(datum.extra.value):"+t+")")),null==t&&(t="0")),t},ct=function(e,n,a,i){return"this.gradient("+z(e.gradient,n,a,i)+","+t.stringValue(e.start)+","+t.stringValue(e.stop)+","+t.stringValue(e.count)+")"},pt=function(e,n,a,i){return t.isObject(e)?"("+gt(null,e,n,a,i)+")":e},gt=function(e,n,a,i,r){if(null!=n.gradient)return ct(n,a,i,r);var o=null!=n.color?st(n.color,a,i,r):null!=n.field?dt(n.field,a,i,r):null!=n.signal?ut(n.signal,a,i,r):null!=n.value?t.stringValue(n.value):null;return null!=n.scale&&(o=ft(n,o,a,i,r)),null!=n.exponent&&(o="Math.pow("+o+","+pt(n.exponent,a,i,r)+")"),null!=n.mult&&(o+="*"+pt(n.mult,a,i,r)),null!=n.offset&&(o+="+"+pt(n.offset,a,i,r)),n.round&&(o="Math.round("+o+")"),o},ht=function(e,n,a){return e+"["+t.stringValue(n)+"]="+a+";"},mt=function(e,t,n,a,i){var r="";return t.forEach(function(t){var o=gt(e,t,n,a,i);r+=t.test?ut(t.test,n,a,i)+"?"+o+":":o}),ht("o",e,r)},vt="mark",yt="frame",bt="scope",xt="axis",kt="axis-domain",St="axis-grid",wt="axis-label",Rt="axis-tick",zt="axis-title",Ot="legend",$t="legend-entry",Pt="legend-gradient",Et="legend-label",jt="legend-symbol",Dt="legend-title",_t=function(e,t,n,a,i,r){return{type:e,role:t,key:n,from:a,interactive:!(!r||!r.interactive),encode:P(i,r)}},Ft=function(e,t,n){var a={value:0},i={};return i.enter={opacity:a,x:a,y:a,width:{value:t.gradientWidth},height:{value:t.gradientHeight},stroke:{value:t.gradientStrokeColor},strokeWidth:{value:t.gradientStrokeWidth}},i.exit={opacity:a},i.update={x:a,y:a,width:{value:t.gradientWidth},height:{value:t.gradientHeight},fill:{gradient:e},opacity:{value:1}},_t(Ve,Pt,void 0,void 0,i,n)},Ct="top",At="left",Wt="right",Lt="bottom",Mt="index",Ut="label",Vt="perc",qt="size",Tt="total",Bt="value",Nt="datum."+Vt+'<=0?"left":datum.'+Vt+'>=1?"right":"center"',It=function(e,t,n,a){var i,r,o={value:0},l={};return l.enter=i={opacity:o,text:{field:Ut},fill:{value:t.labelColor},font:{value:t.labelFont},fontSize:{value:t.labelFontSize},baseline:{value:t.gradientLabelBaseline}},l.exit={opacity:o},l.update=r={opacity:{value:1}},i.x=r.x={field:Vt,mult:t.gradientWidth},i.y=r.y={value:t.gradientHeight,offset:t.gradientLabelOffset},i.align=r.align={expr:Nt},_t(Be,Et,Ut,a,l,n)},Jt=function(e,t,n,a){var i,r,o={value:0},l={};return l.enter=i={opacity:o,fill:{value:t.labelColor},text:{field:Ut},font:{value:t.labelFont},fontSize:{value:t.labelFontSize},align:{value:t.labelAlign},baseline:{value:t.labelBaseline}},l.exit={opacity:o},l.update=r={opacity:{value:1}},i.x=r.x={field:qt,offset:t.labelOffset},i.y=r.y={field:qt,mult:.5,offset:{field:Tt,offset:{field:{group:"entryPadding"},mult:{field:Mt}}}},_t(Be,Et,Ut,a,l,n)},Ht=function(e,t,n,a){var i,r,o={value:0},l={};return l.enter=i={opacity:o,shape:{value:t.symbolType},size:{value:t.symbolSize},strokeWidth:{value:t.symbolStrokeWidth}},e.fill||(i.stroke={value:t.symbolColor}),l.exit={opacity:o},l.update=r={opacity:{value:1}},i.x=r.x={field:qt,mult:.5},i.y=r.y={field:qt,mult:.5,offset:{field:Tt,offset:{field:{group:"entryPadding"},mult:{field:Mt}}}},["shape","size","fill","stroke","opacity"].forEach(function(t){e[t]&&(r[t]=i[t]={scale:e[t],field:Bt})}),_t(Te,jt,Ut,a,l,n)},Xt=function(e,t,n,a){var i={value:0},r={};return r.enter={x:{field:{group:"padding"}},y:{field:{group:"padding"}},opacity:i,fill:{value:t.titleColor},font:{value:t.titleFont},fontSize:{value:t.titleFontSize},fontWeight:{value:t.titleFontWeight},align:{value:t.titleAlign},baseline:{value:t.titleBaseline}},r.exit={opacity:i},r.update={opacity:{value:1},text:{field:"title"}},_t(Be,Dt,null,a,r,n)},Yt=function(e,t,n,a,i){return{type:Ue,role:e,from:t,interactive:n,encode:a,marks:i}},Gt=function(e){return e.role||(e.type===Ue&&(e.legends||e.axes)?bt:vt)},Kt=function(e){return{clip:e.clip||!1,interactive:e.interactive!==!1,marktype:e.type,name:e.name||void 0,role:Gt(e),zindex:+e.zindex||void 0}},Qt=function(e){return e},Zt=W("key"),en="ascending",tn="descending",nn=T("Aggregate"),an=T("AxisTicks"),rn=T("Bound"),on=T("Collect"),ln=T("Compare"),sn=T("DataJoin"),un=T("Encode"),dn=T("Facet"),fn=T("Field"),cn=T("Key"),pn=T("LegendEntries"),gn=T("Mark"),hn=T("MultiExtent"),mn=T("MultiValues"),vn=T("Params"),yn=T("PreFacet"),bn=T("Projection"),xn=T("Relay"),kn=T("Render"),Sn=T("Scale"),wn=T("Sieve"),Rn=T("ViewLayout"),zn=T("Values"),On=function(e,n){var i=a.definition(e.type);i||t.error("Unrecognized transform type: "+e.type);var r=F(i.type,null,B(i,e,n));return e.signal&&n.addSignal(e.signal,r),r.metadata=i.metadata||{},r},$n=function(e,n,a){var i,r,o,l;return e?(i=e.facet)&&(n||t.error("Only group marks can be faceted."),null!=i.field?l=A(a.getData(i.data).output):(r=a.keyRef(i.groupby),e.data||(o=On(t.extend({type:"aggregate",groupby:t.array(i.groupby)},i.aggregate)),o.params.key=r,o.params.pulse=A(a.getData(i.data).output),l=A(a.add(o))))):l=A(a.add(on(null,[{}]))),l||(l=e.$ref?e:A(e.mark?a.getData(Qt(e.mark)).output:a.getData(e.data).output)),{key:r,pulse:l}};te.fromEntries=function(e,t){var n=t.length,a=1,i=t[0],r=t[n-1],o=t[n-2];for(e.add(t[0]);a<n;++a)t[a].params.pulse=A(t[a-1]),e.add(t[a]);return new te(e,i,o,r)};var Pn=te.prototype;Pn.countsRef=function(e,t,n){var a,i,r,o=this,l=o.counts||(o.counts={}),s=ne(t);return null!=s&&(e=o.scope,a=l[s]),a?n&&n.field&&ae(e,a.agg.params,n):(r={groupby:e.fieldRef(t,"key"),pulse:A(o.output)},n&&n.field&&ae(e,r,n),i=e.add(nn(r)),a=e.add(on({pulse:A(i)})),a={agg:i,ref:A(a)},null!=s&&(l[s]=a)),a.ref},Pn.tuplesRef=function(){return A(this.values)},Pn.extentRef=function(e,t){return ie(e,this,"extent","Extent",t,!1)},Pn.domainRef=function(e,t){return ie(e,this,"domain","Values",t,!1)},Pn.valuesRef=function(e,t,n){return ie(e,this,"vals","Values",t,n||!0)},Pn.lookupRef=function(e,t){return ie(e,this,"lookup","TupleIndex",t,!1)},Pn.indataRef=function(e,t){return ie(e,this,"indata","TupleIndex",t,!0,!0)};var En=function(e,n,a){var i,r,o,l,s=e.from.facet,u=s.name,d=A(n.getData(s.data).output);s.name||t.error("Facet must have a name: "+JSON.stringify(s)),s.data||t.error("Facet must reference a data set: "+JSON.stringify(s)),s.field?l=n.add(yn({field:n.fieldRef(s.field),pulse:d})):s.groupby?l=n.add(dn({key:n.keyRef(s.groupby),group:a.pulse,pulse:d})):t.error("Facet must specify groupby or field: "+JSON.stringify(s)),i=n.fork(),r=i.add(on()),o=i.add(wn({pulse:A(r)})),i.addData(u,new te(i,r,r,o)),i.addSignal("parent",null),l.params.subflow={$subflow:In(e,i).toRuntime()}},jn=function(e,t,n){var a=t.add(yn({pulse:n.pulse})),i=t.fork();i.add(wn()),i.addSignal("parent",null),a.params.subflow={$subflow:In(e,i).toRuntime()}},Dn=function(e,t,n){var a,i,r=e.remove,o=e.insert,l=e.toggle,s=e.modify,u=e.values,d=t.add(C());a="if("+e.trigger+',modify("'+n+'",'+[o,r,l,s,u].map(function(e){return null==e?"null":e}).join(",")+"),0)",i=Me(a,t),d.update=i.$expr,d.params=i.$params},_n=function(e,n){var a,i,r,o,l,s,u,d,f,c,p=Gt(e),g=e.type===Ue,h=e.from&&e.from.facet,m=p===bt||p===yt;i=$n(e.from,g,n),a=n.add(sn(i)),a=r=n.add(on({pulse:A(a)})),a=n.add(gn({markdef:Kt(e),scenepath:{$itempath:n.markpath()},pulse:A(a)})),d=A(a),a=n.add(un(E(e.encode,e.type,p,n,{pulse:d}))),e.transform&&e.transform.forEach(function(e){var i=On(e,n);(i.metadata.generates||i.metadata.changes)&&t.error("Mark transforms should not generate new data."),i.params.pulse=A(a),n.add(a=i)}),a.params.parent=n.encode(),f=A(a),(h||m)&&(a=n.add(Rn({legendMargin:n.config.legendMargin,mark:d,pulse:f})),n.operators.pop(),n.pushState(f,A(a)),h?En(e,n,i):jn(e,n,i),n.popState(),n.operators.push(a)),o=n.add(rn({mark:d,pulse:A(a)})),c=A(o),!g||h||m||(n.pushState(f,c),p===vt?jn(e,n,i):In(e,n),n.popState()),l=n.add(kn({pulse:c})),s=n.add(wn({pulse:c},void 0,n.parent())),null!=e.name&&(u=Qt(e.name),n.addData(u,new te(n,r,l,s)),e.on&&e.on.forEach(function(e){(e.insert||e.remove||e.toggle)&&t.error("Marks only support modify triggers."),Dn(e,n,u)}))},Fn=function(e,n){var a,i,r,o,l,s,u,d,f=e.type||"symbol",c=n.config.legend,p=e.encode||{},g=!!e.interactive,h=e.size||e.shape||e.fill||e.stroke||e.opacity;return h||t.error("Missing valid scale for legend."),a={orient:re(e.orient,c.orient),title:e.title},i=A(n.add(on(null,[a]))),s=P({update:{offset:$(re(e.offset,c.offset)),padding:$(re(e.padding,c.padding)),titlePadding:$(re(e.titlePadding,c.titlePadding))}},p.legend),u={update:{x:{field:{group:"padding"}},y:{field:{group:"padding"}},entryPadding:$(re(e.entryPadding,c.entryPadding))}},"gradient"===f?(r=A(n.add(pn({type:"gradient",scale:n.scaleRef(h),count:n.property(e.count),values:n.property(e.values),formatSpecifier:n.property(e.format)}))),d=[Ft(h,c,p.gradient),It(e,c,p.labels,r)]):(r=A(n.add(pn({size:oe(e,c,p.labels),scale:n.scaleRef(h),count:n.property(e.count),values:n.property(e.values),formatSpecifier:n.property(e.formatSpecifier)}))),d=[Ht(e,c,p.symbols,r),Jt(e,c,p.labels,r)]),d=[Yt($t,i,g,u,d)],a.title&&(l=Xt(e,c,p.title,i),u.update.y.offset={field:{group:"titlePadding"},offset:l.encode.update.fontSize||l.encode.enter.fontSize},d.push(l)),o=Yt(Ot,i,g,s,d),e.zindex&&(o.zindex=e.zindex),_n(o,n)},Cn=["identity","ordinal","band","point","index","linear","pow","sqrt","log","sequential","time","utc","quantize","quantile","threshold"],An=t.toSet(Cn),Wn=t.toSet(Cn.slice(1,5)),Ln=function(e,n){var a,i,r=e.type||"linear";An.hasOwnProperty(r)||t.error("Unrecognized scale type: "+r),a={type:r,domain:de(e.domain,e,n)},null!=e.range&&(null!=e.bandSize&&t.error("Scale range and bandSize are mutually exclusive."),a.range=ye(e,n));for(i in e)a[i]||"name"===i||(a[i]=ue(e[i],n));n.addScale(e.name,a)},Mn=function(e,n){var a=n.config,i=e.orient,r=i===Ct||i===Lt?a.axisX:a.axisY,o=a["axis"+i[0].toUpperCase()+i.slice(1)],l="band"===n.scaleType(e.scale)&&a.axisBand;return r||o||l?t.extend({},a.axis,r,o,l):a.axis},Un=function(e,t,n,a){var i,r,o=e.orient,l={value:0},s={};return s.enter=i={opacity:l,stroke:{value:t.tickColor},strokeWidth:{value:t.tickWidth}},s.exit={opacity:l},s.update=r={opacity:{value:1}},o===Ct||o===Lt?(i.y=l,r.x=i.x=Se(e,0),r.x2=i.x2=Se(e,1)):(i.x=l,r.y=i.y=Se(e,0),r.y2=i.y2=Se(e,1)),_t(qe,kt,null,a,s,n)},Vn=function(e,t,n,a){var i,r,o,l,s=e.orient,u=s===At||s===Ct?1:-1,d=u*e.offset||0,f={value:0},c={};return c.enter=i={opacity:f,stroke:{value:t.gridColor},strokeWidth:{value:t.gridWidth},strokeDash:{value:t.gridDash}},c.exit=r={opacity:f},c.update=o={opacity:{value:t.gridOpacity}},l={scale:e.scale,field:Bt,band:t.bandPosition,round:t.tickRound,extra:t.tickExtra},s===Ct||s===Lt?(i.y={value:d},o.y2=i.y2={signal:"height",mult:u,offset:d},o.x=i.x=r.x=l):(i.x={value:d},o.x2=i.x2={signal:"width",mult:u,offset:d},o.y=i.y=r.y=l),_t(qe,St,Bt,a,c,n)},qn=function(e,t,n,a){var i,r,o,l,s,u=e.orient,d=u===At||u===Ct?-1:1,f=null!=e.tickSize?e.tickSize:t.tickSize,c={value:0},p={};return p.enter=i={opacity:c,stroke:{value:t.tickColor},strokeWidth:{value:t.tickWidth}},p.exit=r={opacity:c},p.update=o={opacity:{value:1}},l=$(f),l.mult=d,s={scale:e.scale,field:Bt,band:t.bandPosition,round:t.tickRound,extra:t.tickExtra},u===Ct||u===Lt?(o.y=i.y=c,o.y2=i.y2=l,o.x=i.x=r.x=s):(o.x=i.x=c,o.x2=i.x2=l,o.y=i.y=r.y=s),_t(qe,Rt,Ut,a,p,n)},Tn=function(e,t,n,a){var i,r,o,l,s,u=e.orient,d=u===At||u===Ct?-1:1,f=null!=e.tickSize?e.tickSize:t.tickSize,c=null!=e.tickPadding?e.tickPadding:t.tickPadding,p={value:0},g={};return g.enter=i={opacity:p,fill:{value:t.tickLabelColor},font:{value:t.tickLabelFont},fontSize:{value:t.tickLabelFontSize},text:{field:Ut}},g.exit=r={opacity:p},g.update=o={opacity:{value:1}},l=$(f),l.mult=d,l.offset=$(c),l.offset.mult=d,s={scale:e.scale,field:Bt,band:.5},u===Ct||u===Lt?(o.y=i.y=l,o.x=i.x=r.x=s,o.align={value:"center"},o.baseline={value:u===Ct?"bottom":"top"}):(o.x=i.x=l,o.y=i.y=r.y=s,o.align={value:u===Wt?"left":"right"},o.baseline={value:"middle"}),_t(Be,wt,Ut,a,g,n)},Bn=function(e,t,n,a){var i,r,o=e.orient,l=o===At||o===Ct?-1:1,s=o===Ct||o===Lt,u={};return u.enter={opacity:{value:0},fill:{value:t.titleColor},font:{value:t.titleFont},fontSize:{value:t.titleFontSize},fontWeight:{value:t.titleFontWeight},align:{value:t.titleAlign}},u.exit={opacity:{value:0}},u.update=i={opacity:{value:1},text:{field:"title"}},r={scale:e.scale,range:.5},s?(i.x=r,i.angle={value:0},i.baseline={value:o===Ct?"bottom":"top"}):(i.y=r,i.angle={value:90*l},i.baseline={value:"bottom"}),null!=t.titleAngle&&(i.angle={value:t.titleAngle}),null!=t.titleBaseline&&(i.baseline={value:t.titleBaseline}),null!=t.titleX?i.x={value:t.titleX}:s&&!D(n,"x")&&(u.enter.auto={value:!0}),null!=t.titleY?i.y={value:t.titleY}:s||D(n,"y")||(u.enter.auto={value:!0}),_t(Be,zt,null,a,u,n)},Nn=function(e,t){var n,a,i,r,o,l,s=Mn(e,t),u=e.encode||{},d=!!e.interactive;return n={orient:e.orient,domain:null!=e.domain?!!e.domain:s.domainDefault,grid:null!=e.grid?!!e.grid:s.gridDefault,title:e.title},a=A(t.add(on({},[n]))),o=P({update:{range:{expr:'abs(span(range("'+e.scale+'")))'},offset:$(e.offset||0),position:$(e.position||0),titlePadding:$(e.titlePadding||s.titlePadding),minExtent:$(e.minExtent||s.minExtent),maxExtent:$(e.maxExtent||s.maxExtent)}},u.axis),i=A(t.add(an({scale:t.scaleRef(e.scale),extra:s.tickExtra,count:t.property(e.count),
values:t.property(e.values),formatSpecifier:t.property(e.format)}))),l=[qn(e,s,u.ticks,i),Tn(e,s,u.labels,i)],n.grid&&l.unshift(Vn(e,s,u.grid,i)),n.domain&&l.push(Un(e,s,u.domain,a)),n.title&&l.push(Bn(e,s,u.title,a)),r=Yt(xt,a,d,o,l),e.zindex&&(r.zindex=e.zindex),_n(r,t)},In=function(e,n,a){var i=t.array(e.signals);return a||i.forEach(function(e){Pe(e,n)}),t.array(e.projections).forEach(function(e){rt(e,n)}),t.array(e.data).forEach(function(e){be(e,n)}),t.array(e.scales).forEach(function(e){Ln(e,n)}),i.forEach(function(e){it(e,n)}),n.parseLambdas(),t.array(e.axes).forEach(function(e){Nn(e,n)}),t.array(e.marks).forEach(function(e){_n(e,n)}),t.array(e.legends).forEach(function(e){Fn(e,n)}),n},Jn=t.toSet(["width","height","padding"]),Hn=Re.prototype=ze.prototype;Hn.fork=function(){return new ze(this)},Hn.toRuntime=function(){return this.finish(),{background:this.background,operators:this.operators,streams:this.streams,updates:this.updates,bindings:this.bindings}},Hn.id=function(){return(this._subid?this._subid+":":0)+this._id++},Hn.add=function(e){return this.operators.push(e),e.id=this.id(),e},Hn.addStream=function(e){return this.streams.push(e),e.id=this.id(),e},Hn.addUpdate=function(e){return this.updates.push(e),e},Hn.finish=function(){function e(e,t,n){var a,i;e&&(a=e.data||(e.data={}),i=a[t]||(a[t]=[]),i.push(n))}var t,n;this.root&&(this.root.root=!0);for(t in this.signals)this.signals[t].signal=t;for(t in this.scales)this.scales[t].scale=t;for(t in this.data){n=this.data[t],e(n.input,t,"input"),e(n.output,t,"output"),e(n.values,t,"values");for(var a in n.index)e(n.index[a],t,"index:"+a)}return this},Hn.pushState=function(e,t){this._encode.push(A(this.add(wn({pulse:e})))),this._parent.push(t),this._markpath.push(-1)},Hn.popState=function(){this._parent.pop(),this._encode.pop(),this._markpath.pop()},Hn.parent=function(){return t.peek(this._parent)},Hn.encode=function(){return t.peek(this._encode)},Hn.markpath=function(){var e=this._markpath;return++e[e.length-1],e.slice()},Hn.fieldRef=function(e,n){if(t.isString(e))return W(e,n);e.signal||t.error("Unsupported field reference: "+JSON.stringify(e));var a,i=e.signal,r=this.field[i];return r||(a={name:this.signalRef(i)},n&&(a.as=n),this.field[i]=r=A(this.add(fn(a)))),r},Hn.compareRef=function(e){function n(e){return q(e)?(i=!0,A(a[e.signal])):e}var a=this.signals,i=!1,r=t.array(e.field).map(n),o=t.array(e.order).map(n);return i?A(this.add(ln({fields:r,orders:o}))):L(r,o)},Hn.keyRef=function(e){function n(e){return q(e)?(i=!0,A(a[e.signal])):e}var a=this.signals,i=!1;return e=t.array(e).map(n),i?A(this.add(cn({fields:e}))):M(e)},Hn.sortRef=function(e){if(!e)return e;var t=[V(e.op,e.field),"_id"],n=e.order||en;return n.signal?A(this.add(ln({fields:t,orders:[n=this.signalRef(n.signal),n]}))):L(t,[n,n])},Hn.event=function(e,t){var n=e+":"+t;if(!this.events[n]){var a=this.id();this.streams.push({id:a,source:e,type:t}),this.events[n]=a}return this.events[n]},Hn.addSignal=function(e,n){this.signals.hasOwnProperty(e)&&t.error("Duplicate signal name: "+e);var a=n instanceof _?n:this.add(C(n));return this.signals[e]=a},Hn.getSignal=function(e){return this.signals[e]||t.error("Unrecognized signal name: "+e),this.signals[e]},Hn.signalRef=function(e){return this.signals[e]?A(this.signals[e]):(this.lambdas[e]||(this.lambdas[e]=this.add(C(null))),A(this.lambdas[e]))},Hn.parseLambdas=function(){for(var e=Object.keys(this.lambdas),t=0,n=e.length;t<n;++t){var a=e[t],i=Me(a,this),r=this.lambdas[a];r.params=i.$params,r.update=i.$expr}},Hn.property=function(e){return e&&e.signal?this.signalRef(e.signal):e},Hn.addBinding=function(e,n){this.bindings||t.error("Nested signals do not support binding."),this.bindings.push(t.extend({signal:e},n))},Hn.addScaleProj=function(e,n){this.scales.hasOwnProperty(e)&&t.error("Duplicate scale or projection name: "+e),this.scales[e]=this.add(n)},Hn.addScale=function(e,t){this.addScaleProj(e,Sn(t))},Hn.addProjection=function(e,t){this.addScaleProj(e,bn(t))},Hn.getScale=function(e){return this.scales[e]||t.error("Unrecognized scale name: "+e),this.scales[e]},Hn.projectionRef=Hn.scaleRef=function(e){return A(this.getScale(e))},Hn.projectionType=Hn.scaleType=function(e){return this.getScale(e).params.type},Hn.addData=function(e,n){this.data.hasOwnProperty(e)&&t.error("Duplicate data set name: "+e),this.data[e]=n},Hn.getData=function(e){return this.data[e]||t.error("Undefined data set name: "+e),this.data[e]},Hn.addDataPipeline=function(e,n){this.data.hasOwnProperty(e)&&t.error("Duplicate data set name: "+e),this.addData(e,te.fromEntries(this,n))};var Xn=function(e){var n,a=Oe();for(n in e)a[n]=t.isObject(a[n])?t.extend(a[n],e[n]):a[n]=e[n];return a},Yn=function(e,t){return we(e,new Re(Xn(t||e.config))).toRuntime()};e.parse=Yn,e.selector=Ie,e.signal=Pe,e.signalUpdates=it,e.stream=tt,e.MarkRole=vt,e.FrameRole=yt,e.ScopeRole=bt,e.AxisRole=xt,e.AxisDomainRole=kt,e.AxisGridRole=St,e.AxisLabelRole=wt,e.AxisTickRole=Rt,e.AxisTitleRole=zt,e.LegendRole=Ot,e.LegendEntryRole=$t,e.LegendLabelRole=Et,e.LegendSymbolRole=jt,e.LegendTitleRole=Dt,e.marktypes=Ne,e.isMarkType=u,e.Scope=Re,e.DataScope=te,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega-util"),require("vega-expression"),require("vega-scenegraph"),require("d3-color"),require("d3-format"),require("d3-time-format"),require("vega-dataflow")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-expression","vega-scenegraph","d3-color","d3-format","d3-time-format","vega-dataflow"],t):t(e.vega=e.vega||{},e.vega,e.vega,e.vega,e.d3,e.d3,e.d3,e.vega)}(this,function(e,t,n,a,r,i,o,l){"use strict";function u(e,n){var a=t.isString(e)?n.scales[e]:t.isObject(e)&&e.signal?n.signals[e.signal]:void 0;return a&&a.value}function s(e){var t={};return function(n,a){var r=t[n]||(t[n]=e(n));return r(a)}}function d(e){var t=n.functions(e);Te.forEach(function(e){t[e]=Ue+e});for(var a in Ne)t[a]=Ve+a;return t}function c(e,t,a,r){if(t[0].type===Ae){e=t[0].value;var i=Ce+e;if(!r.hasOwnProperty(i))try{r[i]=a.scaleRef(e)}catch(e){}}else t[0].type===We&&(e=t[0].name,t[0]=new n.ASTNode(Ae),t[0].raw='{signal:"'+e+'"}')}function f(e,n,a,r){n[0].type!==Ae&&t.error("First argument to indata must be a string literal."),n[1].type!==Ae&&t.error("Second argument to indata must be a string literal.");var i=n[0].value,o=n[1].value,l=Le+o;r.hasOwnProperty(l)||(r[l]=a.getData(i).indataRef(a,o))}function p(e,n,a,r){n[0].type!==Ae&&t.error("First argument to tuples must be a string literal.");var i=n[0].value,o=qe+i;r.hasOwnProperty(o)||(r[o]=a.getData(i).tuplesRef())}function g(){var e={indata:f,tuples:p};return Be.forEach(function(t){e[t]=c}),e}function h(e){return et.hasOwnProperty(e)}function m(e,t,n,a,r){for(var i,o=0,l=e.length;t<l;++t){if(i=e[t],r&&r.indexOf(i)>=0&&--o,i===n&&!o)return t;a&&a.indexOf(i)>=0&&++o}return t}function v(e){for(var t=[],n=0,a=e.length,r=0;r<a;)r=m(e,r,lt,nt+rt,at+it),t.push(e.substring(n,r).trim()),n=++r;if(0===t.length)throw"Empty event selector: "+e;return t}function y(e){return"["===e[0]?b(e):x(e)}function b(e){var t,n,a=1,r=e.length,i=1;if(i=m(e,i,at,nt),i===r)throw"Empty between selector: "+e;if(t=v(e.substring(a,i)),2!==t.length)throw"Between selector must have two elements: "+e;if(e=e.slice(i+1).trim(),e[0]!==ut)throw"Expected '>' after between selector: "+e;return t=t.map(y),n=y(e.slice(1).trim()),n.between?{between:t,stream:n}:(n.between=t,n)}function x(e){var t,n,a={source:"view"},r=[],i=[0,0],o=0,l=0,u=e.length,s=0;if(e[u-1]===it){if(s=e.lastIndexOf(rt),!(s>=0))throw"Unmatched right brace: "+e;try{i=k(e.substring(s+1,u-1))}catch(t){throw"Invalid throttle specification: "+e}e=e.slice(0,s).trim(),u=e.length,s=0}if(!u)throw e;if("@"===e[0]&&(o=++s),t=m(e,s,ot),t<u&&(r.push(e.substring(l,t).trim()),l=s=++t),s=m(e,s,nt),s===u)r.push(e.substring(l,u).trim());else if(r.push(e.substring(l,s).trim()),n=[],l=++s,l===u)throw"Unmatched left bracket: "+e;for(;s<u;){if(s=m(e,s,at),s===u)throw"Unmatched left bracket: "+e;if(n.push(e.substring(l,s).trim()),s<u-1&&e[++s]!==nt)throw"Expected left bracket: "+e;l=++s}if(!(u=r.length)||st.test(r[u-1]))throw"Invalid event selector: "+e;return u>1?(a.type=r[1],o?a.markname=r[0].slice(1):h(r[0])?a.marktype=r[0]:a.source=r[0]):a.type=r[0],"!"===a.type.slice(-1)&&(a.consume=!0,a.type=a.type.slice(0,-1)),null!=n&&(a.filter=n),i[0]&&(a.throttle=i[0]),i[1]&&(a.debounce=i[1]),a}function k(e){var t=e.split(lt);if(!e.length||t.length>2)throw e;return t.map(function(t){var n=+t;if(n!==n)throw e;return n})}function S(e,n){var a=e.merge?w:e.stream?R:e.type?z:t.error("Invalid stream specification: "+JSON.stringify(e));return a(e,n)}function w(e,t){var n=e.merge.map(function(e){return S(e,t)}),a=O({merge:n},e,t);return t.addStream(a).id}function R(e,t){var n=S(e.stream,t),a=O({stream:n},e,t);return t.addStream(a).id}function z(e,t){var n=t.event(e.source||dt,e.type),a=O({stream:n},e,t);return 1===Object.keys(a).length?n:t.addStream(a).id}function O(e,n,a){var r,i;return(r=n.between)&&(2!==r.length&&t.error("Stream between parameter must have 2 entries."),e.between=[S(r[0],a),S(r[1],a)]),i=n.marktype||n.markname,(n.filter||i)&&(r=n.filter?t.array(n.filter):[],i&&r.push($(n.marktype,n.markname)),e.filter=Ye("("+r.join(")&&(")+")").$expr),null!=(r=n.throttle)&&(e.throttle=+r),null!=(r=n.debounce)&&(e.debounce=+r),n.consume&&(e.consume=!0),e}function $(e,t){var n="event.item";return n+(e&&"*"!==e?"&&"+n+".mark.marktype==='"+e+"'":"")+(t?"&&"+n+".mark.name==='"+t+"'":"")}function E(e,n){return t.isArray(e)?e.map(function(e){return E(e,n)}):t.isObject(e)?e.signal?n.signalRef(e.signal):t.error("Unsupported parameter object: "+JSON.stringify(e)):e}function P(e,n,a,r){var i,o,l;if(e.signal)i="datum",l=bt(e.signal,n,a,r);else if(e.group||e.parent){for(o=Math.max(1,e.level||1),i="item";o-- >0;)i+=".mark.group";e.parent?(l=e.parent,i+=".datum"):l=e.group}else e.datum?(i="datum",l=e.datum):t.error("Invalid field reference: "+JSON.stringify(e));return e.signal||(t.isString(l)?(r[l]=1,l=t.splitAccessPath(l).map(t.stringValue).join("][")):l=P(l,n,a,r)),i+"["+l+"]"}function j(e,n){if(!t.isString(e))return-1;var a=n.scaleType(e);return"band"===a||"point"===a?1:0}function _(e,n,a,r){var i;if(t.isString(e))i=Ce+e,a.hasOwnProperty(i)||(a[i]=n.scaleRef(e)),i=t.stringValue(i);else{for(i in n.scales)a[Ce+i]=n.scaleRef(i);i=t.stringValue(Ce)+"+"+xt(e,n,a,r)}return"_["+i+"]"}function D(e,n,a,r){var i,o,l,u={},s="var o=item,datum=o.datum,$;";for(i in e)o=e[i],t.isArray(o)?s+=Ot(i,o,r,a,u):(l=Rt(i,o,r,a,u),s+=zt("o",i,l));return s+=vt(e,n),s+="return 1;",{$expr:s,$fields:Object.keys(u),$output:Object.keys(e)}}function F(e){return t.isObject(e)?e:{value:e}}function M(e,n){for(var a in n)"interactive"!==a&&(e[a]=t.extend(e[a]||{},n[a]));return e}function C(e,t,n,a,r){var i,o;r=r||{},r.encoders={$encode:i={}},e=A(e,t,n,a.config);for(o in e)i[o]=D(e[o],t,r,a);return r}function A(e,n,a,r){var i,o,l;if(r=r&&(a===Et?r.group:a===$t?r.mark&&r.mark[n]:null)){i={};for(o in r)l=W(o,e)||("fill"===o||"stroke"===o)&&(W("fill",e)||W("stroke",e)),l||(i[o]={value:r[o]});e=t.extend({},e),e.enter=t.extend(i,e.enter)}return e}function W(e,t){return t.enter&&t.enter[e]||t.update&&t.update[e]}function L(e,t,n,a){this.id=-1,this.type=e,this.value=t,this.params=n,a&&(this.parent=a)}function q(e,t,n,a){return new L(e,t,n,a)}function U(e,t){return q("Operator",e,t)}function V(e){return{$ref:e.id}}function T(e,t){return t?{$field:e,$name:t}:{$field:e}}function B(e,t){return{$compare:e,$order:t}}function N(e){return{$key:e}}function I(e){return t.isObject(e)?(e.order===fn?"-":"+")+J(e.op,e.field):""}function J(e,t){return(e&&e.signal?"$"+e.signal:e||"")+(e&&t?"_":"")+(t&&t.signal?"$"+t.signal:t||"")}function X(e){return e&&e.signal}function Y(e){return function(t,n,a){return q(e,n,t||void 0,a)}}function H(e,t,n){var a,r,i,o={};for(r=0,i=e.params.length;r<i;++r)a=e.params[r],o[a.name]=G(a,t,n);return o}function G(e,n,a){var r,i=e.type;return"index"===i?Q(e,n,a):"param"===i?Z(e,n,a):"projection"===i?a.projectionRef(n[e.name]):(r=n[e.name],void 0===r?void(e.required&&t.error("Missing required parameter: "+e.name)):e.array&&!X(r)?r.map(function(t){return K(e,t,a)}):K(e,r,a))}function K(e,n,a){var r=e.type;if(X(n))return re(r)?t.error("Expression references can not be signals."):ie(r)?a.fieldRef(n):oe(r)?a.compareRef(n):a.signalRef(n.signal);var i=e.expr||ie(r);return i&&te(n)?Ye(n.expr,a):i&&ne(n)?T(n.field):re(r)?Ye(n,a):ae(r)?V(a.getData(n).values):ie(r)?T(n):oe(r)?B(t.array(n.field),t.array(n.order)):n}function Q(e,n,a){return t.isString(n.from)||t.error('Lookup "from" parameter must be a string literal.'),a.getData(n.from).lookupRef(a,n.key)}function Z(e,n,a){var r=n[e.name];return e.array?(t.isArray(r)||t.error("Expected an array of sub-parameters. Instead: "+r),r.map(function(t){return ee(e,t,a)})):ee(e,r,a)}function ee(e,n,a){var r,i,o,l,u;for(l=0,u=e.params.length;l<u;++l){i=e.params[l];for(o in i.key)if(i.key[o]!==n[o]){i=null;break}if(i)break}return i||t.error("Unsupported parameter: "+JSON.stringify(n)),r=t.extend(H(i,n,a),i.key),V(a.add($n(r)))}function te(e){return e&&e.expr}function ne(e){return e&&e.field}function ae(e){return"data"===e}function re(e){return"expr"===e}function ie(e){return"field"===e}function oe(e){return"compare"===e}function le(e,t,n,a){this.scope=e,this.input=t,this.output=n,this.values=a,this.index={}}function ue(e){return t.isString(e)?e:null}function se(e,t,n){var a,r=J(n.op,n.field);if(t.ops){for(var i=0,o=t.as.length;i<o;++i)if(t.as[i]===r)return}else t.ops=["count"],t.fields=[null],t.as=["count"];n.op&&(t.ops.push((a=n.op.signal)?e.signalRef(a):n.op),t.fields.push(e.fieldRef(n.field)),t.as.push(r))}function de(e,t,n,a,r,i,o){var l,u,s=t[n]||(t[n]={}),d=I(i),c=ue(r);if(null!=c&&(e=t.scope,c+=d?"|"+d:"",l=s[c]),!l){var f=i?{field:dn,pulse:t.countsRef(e,r,i)}:{field:e.fieldRef(r),pulse:V(t.output)};d&&(f.sort=e.sortRef(i)),u=e.add(q(a,void 0,f)),o&&(t.index[r]=u),l=V(u),null!=c&&(s[c]=l)}return l}function ce(e,t){return null!=e?e:t}function fe(e,t,n){var a,r=+t.symbolSize;return a=n&&n.update&&n.update.fontSize,a||(a=n&&n.enter&&n.enter.fontSize),a&&(a=a.value),a||(a=+t.labelFontSize),e.size?{$expr:"Math.max(ceil(sqrt(_.scale(datum))),"+a+")"}:Math.max(Math.ceil(Math.sqrt(r)),a)}function pe(e){return Jn.hasOwnProperty(e)}function ge(e){return"quantile"===e}function he(e,n){return t.isObject(e)?e.signal?n.signalRef(e.signal):t.error("Unsupported object: "+e):e}function me(e,n,a){if(e)return e.signal?a.signalRef(e.signal):(t.isArray(e)?ve:e.fields?be:ye)(e,n,a)}function ve(e,t,n){return e.map(function(e){return he(e,n)})}function ye(e,n,a){var r=a.getData(e.data);return r||t.error("Can not find data set: "+e.data),pe(n.type)?r.valuesRef(a,e.field,ke(e.sort,!1)):ge(n.type)?r.domainRef(a,e.field):r.extentRef(a,e.field)}function be(e,n,a){var r=e.data,i=e.fields.reduce(function(e,n){return e.push(t.isString(n)?{data:r,field:n}:n),e},[]);return(pe(n.type)?xe:ge(n.type)?Se:we)(e,a,i)}function xe(e,n,a){var r,i,o,l;return r=a.map(function(e){var a=n.getData(e.data);return a||t.error("Can not find data set: "+e.data),a.countsRef(n,e.field)}),i=n.add(pn({groupby:dn,ops:["sum"],fields:[n.fieldRef("count")],as:["count"],pulse:r})),o=n.add(mn({pulse:V(i)})),l=n.add(Cn({field:dn,sort:n.sortRef(ke(e.sort,!0)),pulse:V(o)})),V(l)}function ke(e,n){return e&&(e.field||e.op?e.field||"count"===e.op?n&&e.field?t.error("Multiple domain scales can not sort by field."):n&&e.op&&"count"!==e.op&&t.error("Multiple domain scales support op count only."):t.error("No field provided for sort aggregate op: "+e.op):t.isObject(e)?e.field="key":e={field:"key"}),e}function Se(e,n,a){var r=a.map(function(e){var a=n.getData(e.data);return a||t.error("Can not find data set: "+e.data),a.domainRef(n,e.field)});return V(n.add(On({values:r})))}function we(e,n,a){var r=a.map(function(e){var a=n.getData(e.data);return a||t.error("Can not find data set: "+e.data),a.extentRef(n,e.field)});return V(n.add(zn({extents:r})))}function Re(e,n){var a=e.range,r=n.config.range;if(a.signal)return n.signalRef(a.signal);if(t.isString(a))r&&r.hasOwnProperty(a)?a=r[a]:"width"===a?a=[0,{signal:"width"}]:"height"===a?a=pe(e.type)?[0,{signal:"height"}]:[{signal:"height"},0]:t.error("Unrecognized scale range value: "+a);else{if(pe(e.type)&&!t.isArray(a))return me(a,e,n);t.isArray(a)||t.error("Unsupported range type: "+a)}return a.map(function(e){return he(e,n)})}function ze(e,t){var n=[];e.transform&&e.transform.forEach(function(e){n.push(An(e,t))}),e.on&&e.on.forEach(function(n){Vn(n,t,e.name)}),t.addDataPipeline(e.name,Oe(e,t,n))}function Oe(e,t,n){var a,r,i,o,l,u=[],s=null,d=!1,c=!1;for(e.values?u.push(s=$e({$ingest:e.values,$format:e.format})):e.url?u.push(s=$e({$request:e.url,$format:e.format})):e.source&&(a=t.getData(e.source),s=a.output,u.push(null)),r=0,i=n.length;r<i;++r)o=n[r],l=o.metadata,s||l.source||u.push(s=$e()),u.push(o),l.generates&&(c=!0),l.modifies&&!c&&(d=!0),l.source?s=o:l.changes&&(s=null);return a&&(u[0]=jn({derive:d,pulse:V(a.output)}),d&&u.splice(1,0,$e())),s||u.push($e()),u.push(Fn({})),u}function $e(e){var t=mn({},e);return t.metadata={source:!0},t}function Ee(e,t){return{scale:e.scale,range:t}}function Pe(e,n){var a,r,i,o,l;return n.background=e.background||n.config.background,l=V(n.root=n.add(U())),n.addSignal("width",e.width||-1),n.addSignal("height",e.height||-1),n.addSignal("padding",Fe(e.padding)),t.array(e.signals).forEach(function(e){na[e.name]||Me(e,n)}),r=n.add(mn()),i=M({enter:{x:{value:0},y:{value:0}},update:{width:{signal:"width"},height:{signal:"height"}}},e.encode),i=n.add(bn(C(i,He,Et,n,{pulse:V(r)}))),o=n.add(Mn({legendMargin:n.config.legendMargin,autosize:e.autosize||n.config.autosize,mark:l,pulse:V(i)})),n.pushState(V(i),V(o)),ta(e,n,!0),a=n.add(hn({mark:l,pulse:V(o)})),a=n.add(_n({pulse:V(a)})),a=n.add(Fn({pulse:V(a)})),n.addData("root",new le(n,r,r,a)),n}function je(e){this.config=e,this.bindings=[],this.field={},this.signals={},this.lambdas={},this.scales={},this.events={},this.data={},this.streams=[],this.updates=[],this.operators=[],this.background=null,this._id=0,this._subid=0,this._nextsub=[0],this._parent=[],this._encode=[],this._markpath=[]}function _e(e){this.config=e.config,this.field=Object.create(e.field),this.signals=Object.create(e.signals),this.lambdas=Object.create(e.lambdas),this.scales=Object.create(e.scales),this.events=Object.create(e.events),this.data=Object.create(e.data),this.streams=[],this.updates=[],this.operators=[],this._id=0,this._subid=++e._nextsub[0],this._nextsub=e._nextsub,this._parent=e._parent.slice(),this._encode=e._encode.slice(),this._markpath=e._markpath}function De(){return{autosize:"pad",background:null,group:null,mark:{arc:{fill:"steelblue"},area:{fill:"steelblue"},image:null,line:{stroke:"steelblue"},path:{stroke:"steelblue"},rect:{fill:"steelblue"},rule:{stroke:"#000"},shape:{stroke:"steelblue"},symbol:{fill:"steelblue",size:64},text:{fill:"#000",font:"sans-serif",fontSize:11}},axis:{minExtent:0,maxExtent:200,bandPosition:.5,domainDefault:!0,domainWidth:1,domainColor:"#000",gridDefault:!1,gridWidth:1,gridColor:"#ddd",gridDash:[],gridOpacity:1,tickPadding:2,tickRound:!0,tickSize:5,tickWidth:1,tickColor:"#000",tickLabelColor:"#000",tickLabelFont:"sans-serif",tickLabelFontSize:10,titleAlign:"center",titlePadding:2,titleColor:"#000",titleFont:"sans-serif",titleFontSize:11,titleFontWeight:"bold"},legend:{orient:"right",offset:18,padding:0,entryPadding:5,titlePadding:5,gradientWidth:100,gradientHeight:20,gradientStrokeColor:"#ddd",gradientStrokeWidth:0,gradientLabelBaseline:"top",gradientLabelOffset:2,labelColor:"#000",labelFontSize:10,labelFont:"sans-serif",labelAlign:"left",labelBaseline:"middle",labelOffset:8,symbolType:"circle",symbolSize:100,symbolColor:"#888",symbolStrokeWidth:1.5,titleColor:"#000",titleFont:"sans-serif",titleFontSize:11,titleFontWeight:"bold",titleAlign:"left",titleBaseline:"top"},range:{category:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],symbol:["circle","square","triangle-up","cross","diamond","triangle-right","triangle-down","triangle-left"]}}}var Fe=function(e){return t.isObject(e)?e:t.isNumber(e)?{top:e,bottom:e,left:e,right:e}:{top:0,left:0,bottom:0,right:0}},Me=function(e,t){var n=t.addSignal(e.name,e.value);e.react===!1&&(n.react=!1),e.bind&&t.addBinding(e.name,e.bind)},Ce="%",Ae="Literal",We="Identifier",Le="@",qe=":",Ue="event.vega.",Ve="this.",Te=["view","item","group","xy","x","y"],Be=["bandwidth","copy","domain","range","gradient","invert","scale"],Ne={format:s(i.format),timeFormat:s(o.timeFormat),utcFormat:s(o.utcFormat),pad:t.pad,truncate:t.truncate,rgb:r.rgb,lab:r.lab,hcl:r.hcl,hsl:r.hsl,gradient:a.scaleGradient,clampRange:function(e,t,n){var a,r=e[0],i=e[1];return i<r&&(a=i,i=r,r=a),a=i-r,[Math.min(Math.max(r,t),n-a),Math.min(Math.max(i,a),n)]},pinchDistance:function(){return"Math.sqrt(Math.pow(event.touches[0].clientX - event.touches[1].clientX, 2) + Math.pow(event.touches[0].clientY - event.touches[1].clientY, 2))"},pinchAngle:function(){return"Math.atan2(event.touches[1].clientY - event.touches[0].clientY,event.touches[1].clientX - event.touches[0].clientX)"},open:function(e,t){var n=this.context.dataflow;"undefined"!=typeof window&&window&&window.open?n.loader().sanitize(e,{context:"open",name:t}).then(function(e){window.open(e,t)}).catch(function(e){n.warn("Open url failed: "+e)}):n.warn("Open function can only be invoked in a browser.")},screen:function(){return window.screen},windowsize:function(){return[window.innerWidth,window.innerHeight]},span:function(e){return e[e.length-1]-e[0]},range:function(e,t){var n=u(e,(t||this).context);return n&&n.range?n.range():[0,0]},domain:function(e,t){var n=u(e,(t||this).context);return n?n.domain():[]},bandwidth:function(e,t){var n=u(e,(t||this).context);return n&&n.bandwidth?n.bandwidth():0},copy:function(e,t){var n=u(e,(t||this).context);return n?n.copy():void 0},scale:function(e,t,n){var a=u(e,(n||this).context);return a?a(t):void 0},invert:function(e,n,a){var r=u(e,(a||this).context);return r?t.isArray(n)?(r.invertRange||r.invert)(n):(r.invert||r.invertExtent)(n):void 0},tuples:function(e){var t=this.context.data[e];return t?t.values.value:[]},indata:function(e,t,n){var a=this.context.data[e]["index:"+t],r=a?a.value[n]:void 0;return r?r.count:r},inrange:function(e,t){var n,a=t[0],r=t[t.length-1];return a>r&&(n=a,a=r,r=n),a<=e&&e<=r},encode:function(e,t,n){if(e){var a=this.context.dataflow,r=e.mark.source;a.pulse(r,a.changeset().encode(e,t))}return void 0!==n?n:e},modify:function(e,n,a,r,i,o){var l,u,s=this.context.dataflow,d=this.context.data[e],c=d.input,f=d.changes,p=s.stamp();if(!(c.value.length||n||r))return 0;if((!f||f.stamp<p)&&(d.changes=f=s.changeset(),f.stamp=p,s.runAfter(function(){s.pulse(c,f).run()})),a&&f.remove(a===!0?t.truthy:a),n&&f.insert(n),r&&(l=function(e){for(u in r)if(e[u]!==r[u])return!1;return!0},c.value.filter(l).length?f.remove(l):f.insert(r)),i)for(u in o)f.modify(i,u,o[u]);return 1}},Ie={blacklist:["_"],whitelist:["datum","event"],fieldvar:"datum",globalvar:function(e){return"_["+t.stringValue("$"+e)+"]"},functions:d,constants:n.constants,visitors:g()},Je="$",Xe=n.codegen(Ie),Ye=function(e,a,r){var i,o,l={};try{i=n.parse(e)}catch(n){t.error("Expression parse error: "+e)}return i.visit(function(e){if("CallExpression"===e.type){var t=e.callee.name,n=Ie.visitors[t];n&&n(t,e.arguments,a,l)}}),o=Xe(i),o.globals.forEach(function(e){var t=Je+e;!l.hasOwnProperty(t)&&a.getSignal(e)&&(l[t]=a.signalRef(e))}),{$expr:r?r+"return("+o.code+");":o.code,$fields:o.fields,$params:l}},He="group",Ge="rect",Ke="rule",Qe="symbol",Ze="text",et=t.toSet(["*","arc","area","group","image","line","path","rect","rule","shape","symbol","text"]),tt=function(e){return v(e.trim()).map(y)},nt="[",at="]",rt="{",it="}",ot=":",lt=",",ut=">",st=/[\[\]\{\}]/,dt="view",ct=function(e,t){return e.signal?t.getSignal(e.signal).id:S(e,t)},ft="var datum=event.item&&event.item.datum;",pt=function(e,n,a){var r,i=e.events,o=e.update,l=e.encode,u=[],s="";i||t.error("Signal update missing events specification."),t.isString(i)&&(i=tt(i)),i=t.array(i).filter(function(e){return e.signal?(u.push(e),0):1}),i.length&&u.push(i.length>1?{merge:i}:i[0]),null!=l&&(o&&t.error("Signal encode and update are mutually exclusive."),o="encode(item(),"+t.stringValue(l)+")"),s=t.isString(o)?Ye(o,n,ft):null!=o.expr?Ye(o.expr,n,ft):null!=o.value?o.value:null!=o.signal?{$expr:"_.value",$params:{value:n.signalRef(o.signal)}}:t.error("Invalid signal update specification."),r={target:a,update:s},e.force&&(r.options={force:!0}),u.forEach(function(e){e={source:ct(e,n)},n.addUpdate(t.extend(e,r))})},gt=function(e,t){var n=t.getSignal(e.name);if(e.update){var a=Ye(e.update,t);n.update=a.$expr,n.params=a.$params}e.on&&e.on.forEach(function(e){pt(e,t,n.id)})},ht=function(e,t){var n={};for(var a in e)"name"!==a&&(n[a]=E(e[a],t));t.addProjection(e.name,n)},mt=t.toSet(["rule"]),vt=function(e,t){var n="";return mt[t]?n:(e.x2&&(e.x?(n+="if(o.x>o.x2)$=o.x,o.x=o.x2,o.x2=$;",n+="o.width=o.x2-o.x;"):n+=e.width?"o.x=o.x2-o.width;":"o.x=o.x2;"),e.xc&&(n+=e.width?"o.x=o.xc-o.width/2;":"o.x=o.xc;"),e.y2&&(e.y?(n+="if(o.y>o.y2)$=o.y,o.y=o.y2,o.y2=$;",n+="o.height=o.y2-o.y;"):n+=e.height?"o.y=o.y2-o.height;":"o.y=o.y2;"),e.yc&&(n+=e.height?"o.y=o.yc-o.height/2;":"o.y=o.yc;"),n)},yt=function(e,t,n,a){function r(e,r,i,o){var l=Rt(null,r,t,n,a),u=Rt(null,i,t,n,a),s=Rt(null,o,t,n,a);return"this."+e+"("+[l,u,s].join(",")+").toString()"}return e.c?r("hcl",e.h,e.c,e.l):e.h||e.s?r("hsl",e.h,e.s,e.l):e.l||e.a?r("lab",e.l,e.a,e.b):e.r||e.g||e.b?r("rgb",e.r,e.g,e.b):null},bt=function(e,n,a,r){var i=Ye(e,n);return i.$fields.forEach(function(e){r[e]=1}),t.extend(a,i.$params),i.$expr},xt=function(e,n,a,r){return P(t.isObject(e)?e:{datum:e},n,a,r)},kt=function(e,t,n,a,r){var i,o,l,u=_(e.scale,n,a,r);return null!=e.range?(i=+e.range,o=u+".range()",t=0===i?o+"[0]":"($="+o+","+(1===i?"$[$.length-1]":"$[0]+"+i+"*($[$.length-1]-$[0])")+")"):(t=null!=t?u+"("+t+")":null,e.band&&(l=j(e.scale,n))&&(o=u+".bandwidth",i=+e.band,i=o+"()"+(1===i?"":"*"+i),l<0&&(i="("+o+"?"+i+":0)"),t=(t?t+"+":"")+i,e.extra&&(t="(datum.extra?"+u+"(datum.extra.value):"+t+")")),null==t&&(t="0")),t},St=function(e,n,a,r){return"this.gradient("+_(e.gradient,n,a,r)+","+t.stringValue(e.start)+","+t.stringValue(e.stop)+","+t.stringValue(e.count)+")"},wt=function(e,n,a,r){return t.isObject(e)?"("+Rt(null,e,n,a,r)+")":e},Rt=function(e,n,a,r,i){if(null!=n.gradient)return St(n,a,r,i);var o=null!=n.color?yt(n.color,a,r,i):null!=n.field?xt(n.field,a,r,i):null!=n.signal?bt(n.signal,a,r,i):null!=n.value?t.stringValue(n.value):null;return null!=n.scale&&(o=kt(n,o,a,r,i)),null!=n.exponent&&(o="Math.pow("+o+","+wt(n.exponent,a,r,i)+")"),null!=n.mult&&(o+="*"+wt(n.mult,a,r,i)),null!=n.offset&&(o+="+"+wt(n.offset,a,r,i)),n.round&&(o="Math.round("+o+")"),o},zt=function(e,n,a){return e+"["+t.stringValue(n)+"]="+a+";"},Ot=function(e,t,n,a,r){var i="";return t.forEach(function(t){var o=Rt(e,t,n,a,r);i+=t.test?bt(t.test,n,a,r)+"?"+o+":":o}),zt("o",e,i)},$t="mark",Et="frame",Pt="scope",jt="axis",_t="axis-domain",Dt="axis-grid",Ft="axis-label",Mt="axis-tick",Ct="axis-title",At="legend",Wt="legend-entry",Lt="legend-gradient",qt="legend-label",Ut="legend-symbol",Vt="legend-title",Tt=function(e,t,n,a,r,i){return{type:e,role:t,key:n,from:a,interactive:!(!i||!i.interactive),encode:M(r,i)}},Bt=function(e,t,n){var a={value:0},r={};return r.enter={opacity:a,x:a,y:a,width:{value:t.gradientWidth},height:{value:t.gradientHeight},stroke:{value:t.gradientStrokeColor},strokeWidth:{value:t.gradientStrokeWidth}},r.exit={opacity:a},r.update={x:a,y:a,width:{value:t.gradientWidth},height:{value:t.gradientHeight},fill:{gradient:e},opacity:{value:1}},Tt(Ge,Lt,void 0,void 0,r,n)},Nt="top",It="left",Jt="right",Xt="bottom",Yt="index",Ht="label",Gt="perc",Kt="size",Qt="total",Zt="value",en="datum."+Gt+'<=0?"left":datum.'+Gt+'>=1?"right":"center"',tn=function(e,t,n,a){var r,i,o={value:0},l={};return l.enter=r={opacity:o,text:{field:Ht},fill:{value:t.labelColor},font:{value:t.labelFont},fontSize:{value:t.labelFontSize},baseline:{value:t.gradientLabelBaseline}},l.exit={opacity:o},l.update=i={opacity:{value:1}},r.x=i.x={field:Gt,mult:t.gradientWidth},r.y=i.y={value:t.gradientHeight,offset:t.gradientLabelOffset},r.align=i.align={signal:en},Tt(Ze,qt,Ht,a,l,n)},nn=function(e,t,n,a){var r,i,o={value:0},l={};return l.enter=r={opacity:o,fill:{value:t.labelColor},text:{field:Ht},font:{value:t.labelFont},fontSize:{value:t.labelFontSize},align:{value:t.labelAlign},baseline:{value:t.labelBaseline}},l.exit={opacity:o},l.update=i={opacity:{value:1}},r.x=i.x={field:Kt,offset:t.labelOffset},r.y=i.y={field:Kt,mult:.5,offset:{field:Qt,offset:{field:{group:"entryPadding"},mult:{field:Yt}}}},Tt(Ze,qt,Ht,a,l,n)},an=function(e,t,n,a){var r,i,o={value:0},l={};return l.enter=r={opacity:o,shape:{value:t.symbolType},size:{value:t.symbolSize},strokeWidth:{value:t.symbolStrokeWidth}},e.fill||(r.stroke={value:t.symbolColor}),l.exit={opacity:o},l.update=i={opacity:{value:1}},r.x=i.x={field:Kt,mult:.5},r.y=i.y={field:Kt,mult:.5,offset:{field:Qt,offset:{field:{group:"entryPadding"},mult:{field:Yt}}}},["shape","size","fill","stroke","opacity"].forEach(function(t){e[t]&&(i[t]=r[t]={scale:e[t],field:Zt})}),Tt(Qe,Ut,Ht,a,l,n)},rn=function(e,t,n,a){var r={value:0},i={};return i.enter={x:{field:{group:"padding"}},y:{field:{group:"padding"}},opacity:r,fill:{value:t.titleColor},font:{value:t.titleFont},fontSize:{value:t.titleFontSize},fontWeight:{value:t.titleFontWeight},align:{value:t.titleAlign},baseline:{value:t.titleBaseline}},i.exit={opacity:r},i.update={opacity:{value:1},text:{field:"title"}},Tt(Ze,Vt,null,a,i,n)},on=function(e,t,n,a,r){return{type:He,role:e,from:t,interactive:n,encode:a,marks:r}},ln=function(e){return e.role||(e.type===He&&(e.legends||e.axes)?Pt:$t)},un=function(e){return{clip:e.clip||!1,interactive:e.interactive!==!1,marktype:e.type,name:e.name||void 0,role:ln(e),zindex:+e.zindex||void 0}},sn=function(e){return e},dn=T("key"),cn="ascending",fn="descending",pn=Y("Aggregate"),gn=Y("AxisTicks"),hn=Y("Bound"),mn=Y("Collect"),vn=Y("Compare"),yn=Y("DataJoin"),bn=Y("Encode"),xn=Y("Facet"),kn=Y("Field"),Sn=Y("Key"),wn=Y("LegendEntries"),Rn=Y("Mark"),zn=Y("MultiExtent"),On=Y("MultiValues"),$n=Y("Params"),En=Y("PreFacet"),Pn=Y("Projection"),jn=Y("Relay"),_n=Y("Render"),Dn=Y("Scale"),Fn=Y("Sieve"),Mn=Y("ViewLayout"),Cn=Y("Values"),An=function(e,n){var a=l.definition(e.type);a||t.error("Unrecognized transform type: "+e.type);var r=q(a.type,null,H(a,e,n));return e.signal&&n.addSignal(e.signal,r),r.metadata=a.metadata||{},r},Wn=function(e,n,a){var r,i,o,l;return e?(r=e.facet)&&(n||t.error("Only group marks can be faceted."),null!=r.field?l=V(a.getData(r.data).output):(i=a.keyRef(r.groupby),e.data||(o=An(t.extend({type:"aggregate",groupby:t.array(r.groupby)},r.aggregate)),o.params.key=i,o.params.pulse=V(a.getData(r.data).output),l=V(a.add(o))))):l=V(a.add(mn(null,[{}]))),l||(l=e.$ref?e:V(e.mark?a.getData(sn(e.mark)).output:a.getData(e.data).output)),{key:i,pulse:l}};le.fromEntries=function(e,t){var n=t.length,a=1,r=t[0],i=t[n-1],o=t[n-2];for(e.add(t[0]);a<n;++a)t[a].params.pulse=V(t[a-1]),e.add(t[a]);return new le(e,r,o,i)};var Ln=le.prototype;Ln.countsRef=function(e,t,n){var a,r,i,o=this,l=o.counts||(o.counts={}),u=ue(t);return null!=u&&(e=o.scope,a=l[u]),a?n&&n.field&&se(e,a.agg.params,n):(i={groupby:e.fieldRef(t,"key"),pulse:V(o.output)},n&&n.field&&se(e,i,n),r=e.add(pn(i)),a=e.add(mn({pulse:V(r)})),a={agg:r,ref:V(a)},null!=u&&(l[u]=a)),a.ref},Ln.tuplesRef=function(){return V(this.values)},Ln.extentRef=function(e,t){return de(e,this,"extent","Extent",t,!1)},Ln.domainRef=function(e,t){return de(e,this,"domain","Values",t,!1)},Ln.valuesRef=function(e,t,n){return de(e,this,"vals","Values",t,n||!0)},Ln.lookupRef=function(e,t){return de(e,this,"lookup","TupleIndex",t,!1)},Ln.indataRef=function(e,t){return de(e,this,"indata","TupleIndex",t,!0,!0)};var qn=function(e,n,a){var r,i,o,l,u=e.from.facet,s=u.name,d=V(n.getData(u.data).output);u.name||t.error("Facet must have a name: "+JSON.stringify(u)),u.data||t.error("Facet must reference a data set: "+JSON.stringify(u)),u.field?l=n.add(En({field:n.fieldRef(u.field),pulse:d})):u.groupby?l=n.add(xn({key:n.keyRef(u.groupby),group:a.pulse,pulse:d})):t.error("Facet must specify groupby or field: "+JSON.stringify(u)),r=n.fork(),i=r.add(mn()),o=r.add(Fn({pulse:V(i)})),r.addData(s,new le(r,i,i,o)),r.addSignal("parent",null),l.params.subflow={$subflow:ta(e,r).toRuntime()}},Un=function(e,t,n){var a=t.add(En({pulse:n.pulse})),r=t.fork();r.add(Fn()),r.addSignal("parent",null),a.params.subflow={$subflow:ta(e,r).toRuntime()}},Vn=function(e,t,n){var a,r,i=e.remove,o=e.insert,l=e.toggle,u=e.modify,s=e.values,d=t.add(U());a="if("+e.trigger+',modify("'+n+'",'+[o,i,l,u,s].map(function(e){return null==e?"null":e}).join(",")+"),0)",r=Ye(a,t),d.update=r.$expr,d.params=r.$params},Tn=function(e,n){var a,r,i,o,l,u,s,d,c,f,p=ln(e),g=e.type===He,h=e.from&&e.from.facet,m=p===Pt||p===Et;r=Wn(e.from,g,n),a=n.add(yn(r)),a=i=n.add(mn({pulse:V(a)})),a=n.add(Rn({markdef:un(e),scenepath:{$itempath:n.markpath()},pulse:V(a)})),d=V(a),a=n.add(bn(C(e.encode,e.type,p,n,{pulse:d}))),e.transform&&e.transform.forEach(function(e){var r=An(e,n);(r.metadata.generates||r.metadata.changes)&&t.error("Mark transforms should not generate new data."),r.params.pulse=V(a),n.add(a=r)}),a.params.parent=n.encode(),c=V(a),(h||m)&&(a=n.add(Mn({legendMargin:n.config.legendMargin,mark:d,pulse:c})),n.operators.pop(),n.pushState(c,V(a)),h?qn(e,n,r):Un(e,n,r),n.popState(),n.operators.push(a)),o=n.add(hn({mark:d,pulse:V(a)})),f=V(o),!g||h||m||(n.pushState(c,f),p===$t?Un(e,n,r):ta(e,n),n.popState()),l=n.add(_n({pulse:f})),u=n.add(Fn({pulse:f},void 0,n.parent())),null!=e.name&&(s=sn(e.name),n.addData(s,new le(n,i,l,u)),e.on&&e.on.forEach(function(e){(e.insert||e.remove||e.toggle)&&t.error("Marks only support modify triggers."),Vn(e,n,s)}))},Bn=function(e,n){var a,r,i,o,l,u,s,d,c=e.type||"symbol",f=n.config.legend,p=e.encode||{},g=!!e.interactive,h=e.size||e.shape||e.fill||e.stroke||e.opacity;return h||t.error("Missing valid scale for legend."),a={orient:ce(e.orient,f.orient),title:e.title},r=V(n.add(mn(null,[a]))),u=M({update:{offset:F(ce(e.offset,f.offset)),padding:F(ce(e.padding,f.padding)),titlePadding:F(ce(e.titlePadding,f.titlePadding))}},p.legend),s={update:{x:{field:{group:"padding"}},y:{field:{group:"padding"}},entryPadding:F(ce(e.entryPadding,f.entryPadding))}},"gradient"===c?(i=V(n.add(wn({type:"gradient",scale:n.scaleRef(h),count:n.property(e.count),values:n.property(e.values),formatSpecifier:n.property(e.format)}))),d=[Bt(h,f,p.gradient),tn(e,f,p.labels,i)]):(i=V(n.add(wn({size:fe(e,f,p.labels),scale:n.scaleRef(h),count:n.property(e.count),values:n.property(e.values),formatSpecifier:n.property(e.formatSpecifier)}))),d=[an(e,f,p.symbols,i),nn(e,f,p.labels,i)]),d=[on(Wt,r,g,s,d)],a.title&&(l=rn(e,f,p.title,r),s.update.y.offset={field:{group:"titlePadding"},offset:l.encode.update.fontSize||l.encode.enter.fontSize},d.push(l)),o=on(At,r,g,u,d),e.zindex&&(o.zindex=e.zindex),Tn(o,n)},Nn=["identity","ordinal","band","point","index","linear","pow","sqrt","log","sequential","time","utc","quantize","quantile","threshold"],In=t.toSet(Nn),Jn=t.toSet(Nn.slice(1,5)),Xn=function(e,n){var a,r,i=e.type||"linear";In.hasOwnProperty(i)||t.error("Unrecognized scale type: "+i),a={type:i,domain:me(e.domain,e,n)},null!=e.range&&(null!=e.bandSize&&t.error("Scale range and bandSize are mutually exclusive."),a.range=Re(e,n));for(r in e)a[r]||"name"===r||(a[r]=he(e[r],n));n.addScale(e.name,a)},Yn=function(e,n){var a=n.config,r=e.orient,i=r===Nt||r===Xt?a.axisX:a.axisY,o=a["axis"+r[0].toUpperCase()+r.slice(1)],l="band"===n.scaleType(e.scale)&&a.axisBand;return i||o||l?t.extend({},a.axis,i,o,l):a.axis},Hn=function(e,t,n,a){var r,i,o=e.orient,l={value:0},u={};return u.enter=r={opacity:l,stroke:{value:t.tickColor},strokeWidth:{value:t.tickWidth}},u.exit={opacity:l},u.update=i={opacity:{value:1}},o===Nt||o===Xt?(r.y=l,i.x=r.x=Ee(e,0),i.x2=r.x2=Ee(e,1)):(r.x=l,i.y=r.y=Ee(e,0),i.y2=r.y2=Ee(e,1)),Tt(Ke,_t,null,a,u,n)},Gn=function(e,t,n,a){var r,i,o,l,u=e.orient,s=u===It||u===Nt?1:-1,d=s*e.offset||0,c={value:0},f={};return f.enter=r={opacity:c,stroke:{value:t.gridColor},strokeWidth:{value:t.gridWidth},strokeDash:{value:t.gridDash}},f.exit=i={opacity:c},f.update=o={opacity:{value:t.gridOpacity}},l={scale:e.scale,field:Zt,band:t.bandPosition,round:t.tickRound,extra:t.tickExtra},u===Nt||u===Xt?(r.y={value:d},o.y2=r.y2={signal:"height",mult:s,offset:d},o.x=r.x=i.x=l):(r.x={value:d},o.x2=r.x2={signal:"width",mult:s,offset:d},o.y=r.y=i.y=l),Tt(Ke,Dt,Zt,a,f,n)},Kn=function(e,t,n,a){var r,i,o,l,u,s=e.orient,d=s===It||s===Nt?-1:1,c=null!=e.tickSize?e.tickSize:t.tickSize,f={value:0},p={};return p.enter=r={opacity:f,stroke:{value:t.tickColor},strokeWidth:{value:t.tickWidth}},p.exit=i={opacity:f},p.update=o={opacity:{value:1}},l=F(c),l.mult=d,u={scale:e.scale,
field:Zt,band:t.bandPosition,round:t.tickRound,extra:t.tickExtra},s===Nt||s===Xt?(o.y=r.y=f,o.y2=r.y2=l,o.x=r.x=i.x=u):(o.x=r.x=f,o.x2=r.x2=l,o.y=r.y=i.y=u),Tt(Ke,Mt,Ht,a,p,n)},Qn=function(e,t,n,a){var r,i,o,l,u,s=e.orient,d=s===It||s===Nt?-1:1,c=null!=e.tickSize?e.tickSize:t.tickSize,f=null!=e.tickPadding?e.tickPadding:t.tickPadding,p={value:0},g={};return g.enter=r={opacity:p,fill:{value:t.tickLabelColor},font:{value:t.tickLabelFont},fontSize:{value:t.tickLabelFontSize},text:{field:Ht}},g.exit=i={opacity:p},g.update=o={opacity:{value:1}},l=F(c),l.mult=d,l.offset=F(f),l.offset.mult=d,u={scale:e.scale,field:Zt,band:.5},s===Nt||s===Xt?(o.y=r.y=l,o.x=r.x=i.x=u,o.align={value:"center"},o.baseline={value:s===Nt?"bottom":"top"}):(o.x=r.x=l,o.y=r.y=i.y=u,o.align={value:s===Jt?"left":"right"},o.baseline={value:"middle"}),Tt(Ze,Ft,Ht,a,g,n)},Zn=function(e,t,n,a){var r,i,o=e.orient,l=o===It||o===Nt?-1:1,u=o===Nt||o===Xt,s={};return s.enter={opacity:{value:0},fill:{value:t.titleColor},font:{value:t.titleFont},fontSize:{value:t.titleFontSize},fontWeight:{value:t.titleFontWeight},align:{value:t.titleAlign}},s.exit={opacity:{value:0}},s.update=r={opacity:{value:1},text:{field:"title"}},i={scale:e.scale,range:.5},u?(r.x=i,r.angle={value:0},r.baseline={value:o===Nt?"bottom":"top"}):(r.y=i,r.angle={value:90*l},r.baseline={value:"bottom"}),null!=t.titleAngle&&(r.angle={value:t.titleAngle}),null!=t.titleBaseline&&(r.baseline={value:t.titleBaseline}),null!=t.titleX?r.x={value:t.titleX}:u&&!W(n,"x")&&(s.enter.auto={value:!0}),null!=t.titleY?r.y={value:t.titleY}:u||W(n,"y")||(s.enter.auto={value:!0}),Tt(Ze,Ct,null,a,s,n)},ea=function(e,t){var n,a,r,i,o,l,u=Yn(e,t),s=e.encode||{},d=!!e.interactive;return n={orient:e.orient,domain:null!=e.domain?!!e.domain:u.domainDefault,grid:null!=e.grid?!!e.grid:u.gridDefault,title:e.title},a=V(t.add(mn({},[n]))),o=M({update:{range:{expr:'abs(span(range("'+e.scale+'")))'},offset:F(e.offset||0),position:F(e.position||0),titlePadding:F(e.titlePadding||u.titlePadding),minExtent:F(e.minExtent||u.minExtent),maxExtent:F(e.maxExtent||u.maxExtent)}},s.axis),r=V(t.add(gn({scale:t.scaleRef(e.scale),extra:u.tickExtra,count:t.property(e.count),values:t.property(e.values),formatSpecifier:t.property(e.format)}))),l=[Kn(e,u,s.ticks,r),Qn(e,u,s.labels,r)],n.grid&&l.unshift(Gn(e,u,s.grid,r)),n.domain&&l.push(Hn(e,u,s.domain,a)),n.title&&l.push(Zn(e,u,s.title,a)),i=on(jt,a,d,o,l),e.zindex&&(i.zindex=e.zindex),Tn(i,t)},ta=function(e,n,a){var r=t.array(e.signals);return a||r.forEach(function(e){Me(e,n)}),t.array(e.projections).forEach(function(e){ht(e,n)}),t.array(e.data).forEach(function(e){ze(e,n)}),t.array(e.scales).forEach(function(e){Xn(e,n)}),r.forEach(function(e){gt(e,n)}),n.parseLambdas(),t.array(e.axes).forEach(function(e){ea(e,n)}),t.array(e.marks).forEach(function(e){Tn(e,n)}),t.array(e.legends).forEach(function(e){Bn(e,n)}),n},na=t.toSet(["width","height","padding"]),aa=je.prototype=_e.prototype;aa.fork=function(){return new _e(this)},aa.toRuntime=function(){return this.finish(),{background:this.background,operators:this.operators,streams:this.streams,updates:this.updates,bindings:this.bindings}},aa.id=function(){return(this._subid?this._subid+":":0)+this._id++},aa.add=function(e){return this.operators.push(e),e.id=this.id(),e},aa.addStream=function(e){return this.streams.push(e),e.id=this.id(),e},aa.addUpdate=function(e){return this.updates.push(e),e},aa.finish=function(){function e(e,t,n){var a,r;e&&(a=e.data||(e.data={}),r=a[t]||(a[t]=[]),r.push(n))}var t,n;this.root&&(this.root.root=!0);for(t in this.signals)this.signals[t].signal=t;for(t in this.scales)this.scales[t].scale=t;for(t in this.data){n=this.data[t],e(n.input,t,"input"),e(n.output,t,"output"),e(n.values,t,"values");for(var a in n.index)e(n.index[a],t,"index:"+a)}return this},aa.pushState=function(e,t){this._encode.push(V(this.add(Fn({pulse:e})))),this._parent.push(t),this._markpath.push(-1)},aa.popState=function(){this._parent.pop(),this._encode.pop(),this._markpath.pop()},aa.parent=function(){return t.peek(this._parent)},aa.encode=function(){return t.peek(this._encode)},aa.markpath=function(){var e=this._markpath;return++e[e.length-1],e.slice()},aa.fieldRef=function(e,n){if(t.isString(e))return T(e,n);e.signal||t.error("Unsupported field reference: "+JSON.stringify(e));var a,r=e.signal,i=this.field[r];return i||(a={name:this.signalRef(r)},n&&(a.as=n),this.field[r]=i=V(this.add(kn(a)))),i},aa.compareRef=function(e){function n(e){return X(e)?(r=!0,V(a[e.signal])):e}var a=this.signals,r=!1,i=t.array(e.field).map(n),o=t.array(e.order).map(n);return r?V(this.add(vn({fields:i,orders:o}))):B(i,o)},aa.keyRef=function(e){function n(e){return X(e)?(r=!0,V(a[e.signal])):e}var a=this.signals,r=!1;return e=t.array(e).map(n),r?V(this.add(Sn({fields:e}))):N(e)},aa.sortRef=function(e){if(!e)return e;var t=[J(e.op,e.field),"_id"],n=e.order||cn;return n.signal?V(this.add(vn({fields:t,orders:[n=this.signalRef(n.signal),n]}))):B(t,[n,n])},aa.event=function(e,t){var n=e+":"+t;if(!this.events[n]){var a=this.id();this.streams.push({id:a,source:e,type:t}),this.events[n]=a}return this.events[n]},aa.addSignal=function(e,n){this.signals.hasOwnProperty(e)&&t.error("Duplicate signal name: "+e);var a=n instanceof L?n:this.add(U(n));return this.signals[e]=a},aa.getSignal=function(e){return this.signals[e]||t.error("Unrecognized signal name: "+e),this.signals[e]},aa.signalRef=function(e){return this.signals[e]?V(this.signals[e]):(this.lambdas[e]||(this.lambdas[e]=this.add(U(null))),V(this.lambdas[e]))},aa.parseLambdas=function(){for(var e=Object.keys(this.lambdas),t=0,n=e.length;t<n;++t){var a=e[t],r=Ye(a,this),i=this.lambdas[a];i.params=r.$params,i.update=r.$expr}},aa.property=function(e){return e&&e.signal?this.signalRef(e.signal):e},aa.addBinding=function(e,n){this.bindings||t.error("Nested signals do not support binding."),this.bindings.push(t.extend({signal:e},n))},aa.addScaleProj=function(e,n){this.scales.hasOwnProperty(e)&&t.error("Duplicate scale or projection name: "+e),this.scales[e]=this.add(n)},aa.addScale=function(e,t){this.addScaleProj(e,Dn(t))},aa.addProjection=function(e,t){this.addScaleProj(e,Pn(t))},aa.getScale=function(e){return this.scales[e]||t.error("Unrecognized scale name: "+e),this.scales[e]},aa.projectionRef=aa.scaleRef=function(e){return V(this.getScale(e))},aa.projectionType=aa.scaleType=function(e){return this.getScale(e).params.type},aa.addData=function(e,n){this.data.hasOwnProperty(e)&&t.error("Duplicate data set name: "+e),this.data[e]=n},aa.getData=function(e){return this.data[e]||t.error("Undefined data set name: "+e),this.data[e]},aa.addDataPipeline=function(e,n){this.data.hasOwnProperty(e)&&t.error("Duplicate data set name: "+e),this.addData(e,le.fromEntries(this,n))};var ra=function(e){var n,a=De();for(n in e)a[n]=t.isObject(a[n])?t.extend(a[n],e[n]):a[n]=e[n];return a},ia=function(e,t){return Pe(e,new je(ra(t||e.config))).toRuntime()};e.parse=ia,e.selector=tt,e.signal=Me,e.signalUpdates=gt,e.stream=ct,e.functionContext=Ne,e.MarkRole=$t,e.FrameRole=Et,e.ScopeRole=Pt,e.AxisRole=jt,e.AxisDomainRole=_t,e.AxisGridRole=Dt,e.AxisLabelRole=Ft,e.AxisTickRole=Mt,e.AxisTitleRole=Ct,e.LegendRole=At,e.LegendEntryRole=Wt,e.LegendLabelRole=qt,e.LegendSymbolRole=Ut,e.LegendTitleRole=Vt,e.marktypes=et,e.isMarkType=h,e.Scope=je,e.DataScope=le,Object.defineProperty(e,"__esModule",{value:!0})});

@@ -8,2 +8,4 @@ export {default as parse} from './src/parse';

export {extendedFunctions as functionContext} from './src/parsers/codegen.js';
export {

@@ -10,0 +12,0 @@ MarkRole,

{
"name": "vega-parser",
"version": "1.0.0-beta.4",
"version": "1.0.0-beta.5",
"description": "Parse Vega specifications to runtime dataflows.",

@@ -25,3 +25,3 @@ "keywords": [

"build": "npm run test && uglifyjs build/vega-parser.js -c -m -o build/vega-parser.min.js",
"rollup": "rollup -f umd -g vega-dataflow:vega,vega-expression:vega,vega-util:vega -n vega -o build/vega-parser.js -- index.js",
"rollup": "rollup -f umd -g d3-color:d3,d3-format:d3,d3-time-format:d3,vega-dataflow:vega,vega-expression:vega,vega-scenegraph:vega,vega-util:vega -n vega -o build/vega-parser.js -- index.js",
"schema": "rollup -f umd -g vega-dataflow:vega,vega-util:vega -n vega.schema -o build/vega-schema.js -- schema/index.js",

@@ -34,4 +34,8 @@ "pretest": "rm -rf build && mkdir build && npm run rollup && npm run schema",

"dependencies": {
"d3-color": "1",
"d3-format": "1",
"d3-time-format": "2",
"vega-dataflow": ">=2.0.0-beta",
"vega-expression": "2",
"vega-scenegraph": ">=2.0.0-beta",
"vega-util": "1"

@@ -38,0 +42,0 @@ },

import field from './field';
import {scalePrefix} from '../expression';
import {scalePrefix} from '../codegen';
import {isString, stringValue} from 'vega-util';

@@ -4,0 +4,0 @@

@@ -1,121 +0,12 @@

import {
ASTNode,
parse,
codegen,
functions as baseFunctions,
constants
} from 'vega-expression';
import {error, stringValue} from 'vega-util';
import codegenParams from './codegen';
import {parse, codegen} from 'vega-expression';
import {error} from 'vega-util';
var Literal = 'Literal';
var Identifier = 'Identifier';
export var signalPrefix = '$';
export var scalePrefix = '%';
export var indexPrefix = '@';
export var tuplePrefix = ':';
export var eventPrefix = 'event.vega.';
export var generator = codegen(codegenParams);
function signalCode(id) {
return '_[' + stringValue('$' + id) + ']';
}
export var functions = function(codegen) {
var fn = baseFunctions(codegen);
// view-specific event information
fn.view = eventPrefix + 'view';
fn.item = eventPrefix + 'item';
fn.group = eventPrefix + 'group';
fn.xy = eventPrefix + 'xy';
fn.x = eventPrefix + 'x';
fn.y = eventPrefix + 'y';
fn.encode = 'this.encode';
fn.modify = 'this.modify';
// format functions
fn.format = 'this.format';
fn.timeFormat = 'this.timeFormat';
fn.utcFormat = 'this.utcFormat';
fn.pad = 'this.pad';
fn.truncate = 'this.truncate';
// color functions
fn.rgb = 'this.rgb';
fn.lab = 'this.lab';
fn.hcl = 'this.hcl';
fn.hsl = 'this.hsl';
fn.gradient = 'this.gradient';
// scales, projections, data
fn.copy = 'this.scaleCopy';
fn.domain = 'this.domain';
fn.bandwidth = 'this.bandwidth';
fn.indata = 'this.indata';
fn.inrange = 'this.inrange';
fn.invert = 'this.scaleInvert';
fn.range = 'this.range';
fn.scale = 'this.scale';
fn.span = 'this.span';
fn.tuples = 'this.tuples';
// interaction support
fn.clampRange = 'this.clampRange';
fn.pinchDistance = 'this.pinchDistance';
fn.pinchAngle = 'this.pinchAngle';
// environment functions
fn.open = 'this.open';
fn.screen = function() { return 'window.screen'; };
fn.windowsize = function() {
return '[window.innerWidth, window.innerHeight]';
};
return fn;
};
export var generator = codegen({
blacklist: ['_'],
whitelist: ['datum', 'event'],
fieldvar: 'datum',
globalvar: signalCode,
functions: functions,
constants: constants
});
function signal(name, scope, params) {
var signalName = signalPrefix + name;
if (!params.hasOwnProperty(signalName) && scope.getSignal(name)) {
params[signalName] = scope.signalRef(name);
}
}
function scale(name, scope, params) {
var scaleName = scalePrefix + name;
if (!params.hasOwnProperty(scaleName)) {
try {
params[scaleName] = scope.scaleRef(name);
} catch (err) {
// TODO: error handling? warning?
}
}
}
function index(data, field, scope, params) {
var indexName = indexPrefix + field;
if (!params.hasOwnProperty(indexName)) {
params[indexName] = scope.getData(data).indataRef(scope, field);
}
}
function tuples(data, scope, params) {
var dataName = tuplePrefix + data;
if (!params.hasOwnProperty(dataName)) {
params[dataName] = scope.getData(data).tuplesRef();
}
}
export default function(expr, scope, preamble) {
var params = {}, ast, gen;
// parse the expression to an abstract syntax tree (ast)
try {

@@ -127,35 +18,8 @@ ast = parse(expr);

// analyze ast for dependencies
// analyze ast function calls for dependencies
ast.visit(function visitor(node) {
if (node.type !== 'CallExpression') return;
var name = node.callee.name,
args = node.arguments;
switch (name) {
case 'bandwidth':
case 'copy':
case 'domain':
case 'range':
case 'gradient':
case 'invert':
case 'scale':
if (args[0].type === Literal) { // scale dependency
scale(args[0].value, scope, params);
} else if (args[0].type === Identifier) { // forward reference to signal
name = args[0].name;
args[0] = new ASTNode(Literal);
args[0].raw = '{signal:"' + name + '"}';
}
break;
case 'indata':
if (args[0].type !== Literal) error('First argument to indata must be a string literal.');
if (args[1].type !== Literal) error('Second argument to indata must be a string literal.');
index(args[0].value, args[1].value, scope, params);
break;
case 'tuples':
if (args[0].type !== Literal) error('First argument to tuples must be a string literal.');
tuples(args[0].value, scope, params);
break;
}
visit = codegenParams.visitors[name];
if (visit) visit(name, node.arguments, scope, params);
});

@@ -165,5 +29,12 @@

gen = generator(ast);
gen.globals.forEach(function(name) { signal(name, scope, params); });
// returned parsed expression
// collect signal dependencies
gen.globals.forEach(function(name) {
var signalName = signalPrefix + name;
if (!params.hasOwnProperty(signalName) && scope.getSignal(name)) {
params[signalName] = scope.signalRef(name);
}
});
// return generated expression code and dependencies
return {

@@ -170,0 +41,0 @@ $expr: preamble ? preamble + 'return(' + gen.code + ');' : gen.code,

@@ -40,5 +40,5 @@ import {Perc, Label} from './constants';

enter.align = update.align = {expr: alignExpr};
enter.align = update.align = {signal: alignExpr};
return guideMark(TextMark, LegendLabelRole, Label, dataRef, encode, userEncode);
}

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