!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).vl={})}(this,function(e){"use strict";var t="3.3.0";function n(e,t,n){return e.fields=t||[],e.fname=n,e}function i(e){throw Error(e)}function r(e){var t,n,r,o=[],a=null,s=0,u=e.length,c="";function l(){o.push(c+e.substring(t,n)),c="",t=n+1}for(e+="",t=n=0;nt&&l(),s=t=n+1):"]"===r&&(s||i("Access path missing open bracket: "+e),s>0&&l(),s=0,t=n+1):n>t?l():t=n+1}return s&&i("Access path missing closing bracket: "+e),a&&i("Access path missing closing quote: "+e),n>t&&(n++,l()),o}var o=Array.isArray;function a(e){return e===Object(e)}function s(e){return"string"==typeof e}function u(e){return o(e)?"["+e.map(u)+"]":a(e)||s(e)?JSON.stringify(e).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):e}var c=[],l=(function(e,t){var i=r(e),o="return _["+i.map(u).join("][")+"];";n(Function("_",o),[e=1===i.length?i[0]:e],t||e)}("id"),n(function(e){return e},c,"identity"));n(function(){return 0},c,"zero"),n(function(){return 1},c,"one"),n(function(){return!0},c,"true"),n(function(){return!1},c,"false");function f(e,t,n){var i=[t].concat([].slice.call(n));console[e](...i)}var d=0,p=1,h=2,m=3,g=4;function y(e){return null!=e?o(e)?e:[e]:[]}function b(e){return"boolean"==typeof e}function v(e){return"number"==typeof e}function x(e){for(var t={},n=0,i=e.length;nO(e,t))}:D(e)?{or:e.or.map(e=>O(e,t))}:t(e)}const $=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var i,r,o,a=w(t),s=w(n);if(a&&s){if((r=t.length)!=n.length)return!1;for(i=r;0!=i--;)if(!e(t[i],n[i]))return!1;return!0}if(a!=s)return!1;var u=t instanceof Date,c=n instanceof Date;if(u!=c)return!1;if(u&&c)return t.getTime()==n.getTime();var l=t instanceof RegExp,f=n instanceof RegExp;if(l!=f)return!1;if(l&&f)return t.toString()==n.toString();var d=C(t);if((r=d.length)!==C(n).length)return!1;for(i=r;0!=i--;)if(!F.call(n,d[i]))return!1;for(i=r;0!=i--;)if(!e(t[o=d[i]],n[o]))return!1;return!0}return t!=t&&n!=n},B=A;function N(e,t){const n={};for(const i of t)e.hasOwnProperty(i)&&(n[i]=e[i]);return n}function j(e,t){const n=Object.assign({},e);for(const e of t)delete n[e];return n}Set.prototype.toJSON=function(){return`Set(${[...this].map(e=>E(e)).join(",")})`};const _=E;function T(e){if(v(e))return e;const t=s(e)?e:E(e);if(t.length<250)return t;let n=0;for(let e=0;e-1}function P(e,t){let n=0;for(const[i,r]of e.entries())if(t(r,i,n++))return!0;return!1}function U(e,t){let n=0;for(const[i,r]of e.entries())if(!t(r,i,n++))return!1;return!0}function M(e){return[].concat(...e)}function L(e,...t){for(const n of t)e=I(e,n);return e}function I(e,t){if("object"!=typeof t||null===t)return e;for(const n in t)t.hasOwnProperty(n)&&void 0!==t[n]&&("object"!=typeof t[n]||o(t[n])||null===t[n]?e[n]=t[n]:"object"!=typeof e[n]||null===e[n]?e[n]=L(o(t[n].constructor)?[]:{},t[n]):L(e[n],t[n]));return e}function q(e,t){const n=[],i={};let r;for(const o of e)(r=t(o))in i||(i[r]=1,n.push(o));return n}function W(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function H(e,t){for(const n of e)if(t.has(n))return!0;return!1}function G(e){const t=new Set;for(const n of e){const e=r(n).map((e,t)=>0===t?e:`[${e}]`);e.map((t,n)=>e.slice(0,n+1).join("")).forEach(e=>t.add(e))}return t}function Y(e,t){return H(G(e),G(t))}const V=Object.keys;function Q(e){const t=[];for(const n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t}function X(e){return V(e)}function J(e){return!0===e||!1===e}function Z(e){const t=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+t}function K(e,t){return k(e)?"!("+K(e.not,t)+")":S(e)?"("+e.and.map(e=>K(e,t)).join(") && (")+")":D(e)?"("+e.or.map(e=>K(e,t)).join(") || (")+")":t(e)}function ee(e,t){if(0===t.length)return!0;const n=t.shift();return ee(e[n],t)&&delete e[n],0===V(e).length}function te(e){return e.charAt(0).toUpperCase()+e.substr(1)}function ne(e,t="datum"){const n=r(e),i=[];for(let e=1;e<=n.length;e++){const r=`[${n.slice(0,e).map(u).join("][")}]`;i.push(`${t}${r}`)}return i.join(" && ")}function ie(e,t="datum"){return`${t}[${u(r(e).join("."))}]`}function re(e){return`${r(e).map(e=>e.replace(".","\\.")).join("\\.")}`}function oe(e){return`${r(e).join(".")}`}function ae(e){return e?r(e).length:0}function se(...e){for(const t of e)if(void 0!==t)return t}let ue=42;function ce(e){const t=++ue;return e?String(e)+t:t}function le(e){return fe(e)?e:`__${e}`}function fe(e){return 0===e.indexOf("__")}function de(e){return(e%360+360)%360}const pe="area",he="bar",me="line",ge="point",ye="rect",be="rule",ve="text",xe="tick",Ae="trail",we="circle",Ce="square",Fe="geoshape";function Ee(e){return R(["line","area","trail"],e)}const De=X({area:1,bar:1,line:1,point:1,text:1,tick:1,trail:1,rect:1,geoshape:1,rule:1,circle:1,square:1});function Se(e){return e.type}x(De);const ke=[].concat(["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit"],["fill","fillOpacity"]),Oe=["filled","color","tooltip"];function $e(e){return!!e.mark}class Be{constructor(e,t){this.name=e,this.run=t}hasMatchingType(e){return!!$e(e)&&(Se(t=e.mark)?t.type:t)===this.name;var t}}function Ne(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r1?"are":"is"} also specified.`},discreteChannelCannotEncode:function(e,t){return`Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${"ordinal"===t?"order":"magnitude"}.`},BAR_WITH_POINT_SCALE_AND_RANGESTEP_NULL:"Bar mark should not be used with point scale when rangeStep is null. Please use band scale instead.",lineWithRange:function(e,t){return`Line mark is for continuous lines and thus cannot be used with ${e&&t?"x2 and y2":e?"x2":"y2"}. We will use the rule mark (line segments) instead.`},orientOverridden:function(e,t){return`Specified orient "${e}" overridden with "${t}"`},CANNOT_UNION_CUSTOM_DOMAIN_WITH_FIELD_DOMAIN:"custom domain scale cannot be unioned with default field-based domain",cannotUseScalePropertyWithNonColor:function(e){return`Cannot use the scale property "${e}" with non-color channel.`},unaggregateDomainHasNoEffectForRawField:function(e){return`Using unaggregated domain with raw field has no effect (${_(e)}).`},unaggregateDomainWithNonSharedDomainOp:function(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`},unaggregatedDomainWithLogScale:function(e){return`Unaggregated domain is currently unsupported for log scale (${_(e)}).`},cannotApplySizeToNonOrientedMark:function(e){return`Cannot apply size to non-oriented mark "${e}".`},rangeStepDropped:function(e){return`rangeStep for "${e}" is dropped as top-level ${"x"===e?"width":"height"} is provided.`},scaleTypeNotWorkWithChannel:function(e,t,n){return`Channel "${e}" does not work with "${t}" scale. We are using "${n}" scale instead.`},scaleTypeNotWorkWithFieldDef:function(e,t){return`FieldDef does not work with "${e}" scale. We are using "${t}" scale instead.`},scalePropertyNotWorkWithScaleType:function(e,t,n){return`${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`},scaleTypeNotWorkWithMark:function(e,t){return`Scale type "${t}" does not work with mark "${e}".`},mergeConflictingProperty:function(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${_(n)} and ${_(i)}). Using ${_(n)}.`},independentScaleMeansIndependentGuide:function(e){return`Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.`},domainSortDropped:function(e){return`Dropping sort property ${_(e)} as unioned domains only support boolean or op 'count'.`},UNABLE_TO_MERGE_DOMAINS:"Unable to merge domains",MORE_THAN_ONE_SORT:"Domains that should be unioned has conflicting sort properties. Sort will be set to true.",INVALID_CHANNEL_FOR_AXIS:"Invalid channel for axis.",cannotStackRangedMark:function(e){return`Cannot stack "${e}" if there is already "${e}2"`},cannotStackNonLinearScale:function(e){return`Cannot stack non-linear scale (${e})`},stackNonSummativeAggregate:function(e){return`Stacking is applied even though the aggregate function is non-summative ("${e}")`},invalidTimeUnit:function(e,t){return`Invalid ${e}: ${_(t)}`},dayReplacedWithDate:function(e){return`Time unit "${e}" is not supported. We are replacing it with ${e.replace("day","date")}.`},droppedDay:function(e){return`Dropping day from datetime ${_(e)} as day cannot be combined with other units.`},errorBarCenterAndExtentAreNotNeeded:function(e,t){return`${t?"extent ":""}${t&&e?"and ":""}${e?"center ":""}${t&&e?"are ":"is "}not needed when data are aggregated.`},errorBarCenterIsUsedWithWrongExtent:function(e,t,n){return`${e} is not usually used with ${t} for ${n}.`},errorBarContinuousAxisHasCustomizedAggregate:function(e,t){return`Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.`},errorBarCenterIsNotNeeded:function(e,t){return`Center is not needed to be specified in ${t} when extent is ${e}.`},errorBand1DNotSupport:function(e){return`1D error band does not support ${e}`},channelRequiredForBinned:function(e){return`Channel ${e} is required for "binned" bin`},domainRequiredForThresholdScale:function(e){return`Domain for ${e} is required for threshold scale`}}),Ut=(Lt=h||d,{level:function(e){return arguments.length?(Lt=+e,this):Lt},error:function(){return Lt>=p&&f(Mt||"error","ERROR",arguments),this},warn:function(){return Lt>=h&&f(Mt||"warn","WARN",arguments),this},info:function(){return Lt>=m&&f(Mt||"log","INFO",arguments),this},debug:function(){return Lt>=g&&f(Mt||"log","DEBUG",arguments),this}});var Mt,Lt;let It=Ut;function qt(e){return It=e}function Wt(){return It=Ut}function Ht(...e){It.warn.apply(It,arguments)}function Gt(...e){It.debug.apply(It,arguments)}const Yt=2006;function Vt(e){return!!(e&&(e.year||e.quarter||e.month||e.date||e.day||e.hours||e.minutes||e.seconds||e.milliseconds))}const Qt=["january","february","march","april","may","june","july","august","september","october","november","december"],Xt=Qt.map(e=>e.substr(0,3)),Jt=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Zt=Jt.map(e=>e.substr(0,3));function Kt(e,t=!1){const n=[];if(t&&void 0!==e.day&&V(e).length>1&&(Ht(Pt.droppedDay(e)),delete(e=B(e)).day),void 0!==e.year?n.push(e.year):void 0!==e.day?n.push(Yt):n.push(0),void 0!==e.month){const i=t?function(e){if(v(e))return(e-1).toString();{const t=e.toLowerCase(),n=Qt.indexOf(t);if(-1!==n)return n+"";const i=t.substr(0,3),r=Xt.indexOf(i);if(-1!==r)return r+"";throw new Error(Pt.invalidTimeUnit("month",e))}}(e.month):e.month;n.push(i)}else if(void 0!==e.quarter){const i=t?function(e){if(v(e))return e>4&&Ht(Pt.invalidTimeUnit("quarter",e)),(e-1).toString();throw new Error(Pt.invalidTimeUnit("quarter",e))}(e.quarter):e.quarter;n.push(i+"*3")}else n.push(0);if(void 0!==e.date)n.push(e.date);else if(void 0!==e.day){const i=t?function(e){if(v(e))return e%7+"";{const t=e.toLowerCase(),n=Jt.indexOf(t);if(-1!==n)return n+"";const i=t.substr(0,3),r=Zt.indexOf(i);if(-1!==r)return r+"";throw new Error(Pt.invalidTimeUnit("day",e))}}(e.day):e.day;n.push(i+"+1")}else n.push(1);for(const t of["hours","minutes","seconds","milliseconds"])void 0!==e[t]?n.push(e[t]):n.push(0);return e.utc?`utc(${n.join(", ")})`:`datetime(${n.join(", ")})`}function en(e){return!!e.row||!!e.column}function tn(e){return void 0!==e.facet}var nn;!function(e){e.YEAR="year",e.MONTH="month",e.DAY="day",e.DATE="date",e.HOURS="hours",e.MINUTES="minutes",e.SECONDS="seconds",e.MILLISECONDS="milliseconds",e.YEARMONTH="yearmonth",e.YEARMONTHDATE="yearmonthdate",e.YEARMONTHDATEHOURS="yearmonthdatehours",e.YEARMONTHDATEHOURSMINUTES="yearmonthdatehoursminutes",e.YEARMONTHDATEHOURSMINUTESSECONDS="yearmonthdatehoursminutesseconds",e.MONTHDATE="monthdate",e.MONTHDATEHOURS="monthdatehours",e.HOURSMINUTES="hoursminutes",e.HOURSMINUTESSECONDS="hoursminutesseconds",e.MINUTESSECONDS="minutesseconds",e.SECONDSMILLISECONDS="secondsmilliseconds",e.QUARTER="quarter",e.YEARQUARTER="yearquarter",e.QUARTERMONTH="quartermonth",e.YEARQUARTERMONTH="yearquartermonth",e.UTCYEAR="utcyear",e.UTCMONTH="utcmonth",e.UTCDAY="utcday",e.UTCDATE="utcdate",e.UTCHOURS="utchours",e.UTCMINUTES="utcminutes",e.UTCSECONDS="utcseconds",e.UTCMILLISECONDS="utcmilliseconds",e.UTCYEARMONTH="utcyearmonth",e.UTCYEARMONTHDATE="utcyearmonthdate",e.UTCYEARMONTHDATEHOURS="utcyearmonthdatehours",e.UTCYEARMONTHDATEHOURSMINUTES="utcyearmonthdatehoursminutes",e.UTCYEARMONTHDATEHOURSMINUTESSECONDS="utcyearmonthdatehoursminutesseconds",e.UTCMONTHDATE="utcmonthdate",e.UTCMONTHDATEHOURS="utcmonthdatehours",e.UTCHOURSMINUTES="utchoursminutes",e.UTCHOURSMINUTESSECONDS="utchoursminutesseconds",e.UTCMINUTESSECONDS="utcminutesseconds",e.UTCSECONDSMILLISECONDS="utcsecondsmilliseconds",e.UTCQUARTER="utcquarter",e.UTCYEARQUARTER="utcyearquarter",e.UTCQUARTERMONTH="utcquartermonth",e.UTCYEARQUARTERMONTH="utcyearquartermonth"}(nn||(nn={}));const rn={year:1,quarter:1,month:1,day:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},on=X(rn);const an={utcyear:1,utcquarter:1,utcmonth:1,utcday:1,utcdate:1,utchours:1,utcminutes:1,utcseconds:1,utcmilliseconds:1};const sn={utcyearquarter:1,utcyearquartermonth:1,utcyearmonth:1,utcyearmonthdate:1,utcyearmonthdatehours:1,utcyearmonthdatehoursminutes:1,utcyearmonthdatehoursminutesseconds:1,utcquartermonth:1,utcmonthdate:1,utcmonthdatehours:1,utchoursminutes:1,utchoursminutesseconds:1,utcminutesseconds:1,utcsecondsmilliseconds:1},un=Object.assign({},an,sn);Object.assign({},rn,an,{yearquarter:1,yearquartermonth:1,yearmonth:1,yearmonthdate:1,yearmonthdatehours:1,yearmonthdatehoursminutes:1,yearmonthdatehoursminutesseconds:1,quartermonth:1,monthdate:1,monthdatehours:1,hoursminutes:1,hoursminutesseconds:1,minutesseconds:1,secondsmilliseconds:1},sn);function cn(e,t){const n=e.indexOf(t);return n>-1&&(t!==nn.SECONDS||0===n||"i"!==e.charAt(n-1))}function ln(e,t){const n=ne(t),i=un[e]?"utc":"";return Kt(on.reduce((t,r)=>(cn(e,r)&&(t[r]=function(e){return e===nn.QUARTER?`(${i}quarter(${n})-1)`:`${i}${e}(${n})`}(r)),t),{}))}function fn(e,t){if(!e)return;const n=[],i=cn(e,nn.YEAR);cn(e,nn.MONTH)&&n.push(!1!==t?"%b":"%B"),cn(e,nn.DAY)?n.push(t?"%a":"%A"):cn(e,nn.DATE)&&n.push("%d"+(i?",":"")),i&&n.push(t?"%y":"%Y");const r=[];cn(e,nn.HOURS)&&r.push("%H"),cn(e,nn.MINUTES)&&r.push("%M"),cn(e,nn.SECONDS)&&r.push("%S"),cn(e,nn.MILLISECONDS)&&r.push("%L");const o=[];return n.length>0&&o.push(n.join(" ")),r.length>0&&o.push(r.join(":")),o}function dn(e){return"day"!==e&&e.indexOf("day")>=0?(Ht(Pt.dayReplacedWithDate(e)),e.replace("day","date")):e}const pn={quantitative:1,ordinal:1,temporal:1,nominal:1,geojson:1},hn="quantitative",mn="ordinal",gn="temporal",yn="nominal",bn="geojson";function vn(e){const{field:t,timeUnit:n,bin:i,aggregate:r}=e;return Object.assign({},n?{timeUnit:n}:{},i?{bin:i}:{},r?{aggregate:r}:{},{field:t})}function xn(e){return!!e&&!!e.condition}function An(e){return!!e&&!!e.condition&&!o(e.condition)&&wn(e.condition)}function wn(e){return!(!e||!e.field&&"count"!==e.aggregate)}function Cn(e){return!!e&&(!!e.field&&!!e.type||"count"===e.aggregate)}function Fn(e){return wn(e)&&s(e.field)}function En(e){return e&&"value"in e&&void 0!==e.value}function Dn(e){return!(!e||!e.scale&&!e.sort)}function Sn(e){return!(!e||!e.axis&&!e.stack&&!e.impute)}function kn(e){return!!e&&!!e.legend}function On(e){return!!e&&!!e.format}function $n(e,t={}){let n=e.field;const i=t.prefix;let r=t.suffix,o="";if(function(e){return"count"===e.aggregate}(e))n=le("count");else{let i;if(!t.nofn)if(function(e){return!!e.op}(e))i=e.op;else{const{bin:a,aggregate:s,timeUnit:u}=e;Xn(a)?(i=Qn(a),r=(t.binSuffix||"")+(t.suffix||"")):s?Te(s)?(o=`.${n}`,n=`argmax_${s.argmax}`):_e(s)?(o=`.${n}`,n=`argmin_${s.argmin}`):i=String(s):u&&(i=String(u))}i&&(n=n?`${i}_${n}`:i)}return r&&(n=`${n}_${r}`),i&&(n=`${i}_${n}`),t.forAs?n:t.expr?ie(n,t.expr)+o:re(n)+o}function Bn(e){return!function(e){switch(e.type){case"nominal":case"ordinal":case"geojson":return!0;case"quantitative":return!!e.bin;case"temporal":return!1}throw new Error(Pt.invalidFieldType(e.type))}(e)}function Nn(e,t){const{field:n,bin:i,timeUnit:r,aggregate:o}=e;if("count"===o)return t.countTitle;if(Xn(i))return`${n} (binned)`;if(r){return`${n} (${function(e){return on.reduce((t,n)=>cn(e,n)?[...t,n]:t,[])}(r).join("-")})`}return o?Te(o)?`${n} for max ${o.argmax}`:_e(o)?`${n} for min ${o.argmin}`:`${te(o)} of ${n}`:n}const jn=(e,t)=>{switch(t.fieldTitle){case"plain":return e.field;case"functional":return function(e){const{aggregate:t,bin:n,timeUnit:i,field:r}=e;if(Te(t))return`${r} for argmax(${t.argmax})`;if(_e(t))return`${r} for argmin(${t.argmin})`;const o=t||i||Xn(n)&&"bin";return o?o.toUpperCase()+"("+r+")":r}(e);default:return Nn(e,t)}};let _n=jn;function Tn(e){_n=e}function zn(e,t,{allowDisabling:n,includeDefault:i=!0}){const r=(Rn(e)||{}).title,o=i?Pn(e,t):void 0;return n?se(r,e.title,o):r||e.title||o}function Rn(e){return Sn(e)&&e.axis?e.axis:kn(e)&&e.legend?e.legend:(t=e)&&t.header&&e.header?e.header:void 0;var t}function Pn(e,t){return _n(e,t)}function Un(e){return wn(e)?e:An(e)?e.condition:void 0}function Mn(e){return wn(e)?e:An(e)?e.condition:void 0}function Ln(e,t){if(s(e)||v(e)||b(e)){const n=s(e)?"string":v(e)?"number":"boolean";return Ht(Pt.primitiveChannelDef(t,n,e)),{value:e}}return wn(e)?In(e,t):An(e)?Object.assign({},e,{condition:In(e.condition,t)}):e}function In(e,t){const{aggregate:n,timeUnit:i,bin:r}=e;if(n&&!ze(n)&&!Te(n)&&!_e(n)){const t=Ne(e,["aggregate"]);Ht(Pt.invalidAggregate(n)),e=t}if(i&&(e=Object.assign({},e,{timeUnit:dn(i)})),Xn(r)&&(e=Object.assign({},e,{bin:qn(r,t)})),Jn(r)&&!R($t,t)&&Ht(`Channel ${t} should not be used with "binned" bin`),Cn(e)){const{type:t}=e,i=function(e){if(e)switch(e=e.toLowerCase()){case"q":case hn:return"quantitative";case"t":case gn:return"temporal";case"o":case mn:return"ordinal";case"n":case yn:return"nominal";case bn:return"geojson"}}(t);t!==i&&(e=Object.assign({},e,{type:i})),"quantitative"!==t&&Pe(n)&&(Ht(Pt.invalidFieldTypeForCountAggregate(t,n)),e=Object.assign({},e,{type:"quantitative"}))}else if(!Et(t)){const n=function(e,t){if(e.timeUnit)return"temporal";if(Xn(e.bin))return"quantitative";switch(Rt(t)){case"continuous":return"quantitative";case"discrete":case"flexible":return"nominal";default:return"quantitative"}}(e,t);Ht(Pt.missingFieldType(t,n)),e=Object.assign({},e,{type:n})}if(Cn(e)){const{compatible:n,warning:i}=function(e,t){const n=e.type;if("geojson"===n&&"shape"!==t)return{compatible:!1,warning:`Channel ${t} should not be used with a geojson data.`};switch(t){case"row":case"column":case"facet":return Bn(e)?{compatible:!1,warning:Pt.facetChannelShouldBeDiscrete(t)}:Wn;case"x":case"y":case"color":case"fill":case"stroke":case"text":case"detail":case"key":case"tooltip":case"href":return Wn;case"longitude":case"longitude2":case"latitude":case"latitude2":return n!==hn?{compatible:!1,warning:`Channel ${t} should be used with a quantitative field only, not ${e.type} field.`}:Wn;case"opacity":case"fillOpacity":case"strokeOpacity":case"strokeWidth":case"size":case"x2":case"y2":return"nominal"!==n||e.sort?Wn:{compatible:!1,warning:`Channel ${t} should not be used with an unsorted discrete field.`};case"shape":return R(["ordinal","nominal","geojson"],e.type)?Wn:{compatible:!1,warning:"Shape channel should be used with only either discrete or geojson data."};case"order":return"nominal"!==e.type||"sort"in e?Wn:{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}}throw new Error("channelCompatability not implemented for channel "+t)}(e,t);n||Ht(i)}return e}function qn(e,t){return b(e)?{maxbins:Kn(t)}:"binned"===e?{binned:!0}:e.maxbins||e.step?e:Object.assign({},e,{maxbins:Kn(t)})}const Wn={compatible:!0};function Hn(e){const t=Sn(e)&&e.axis&&e.axis.formatType||kn(e)&&e.legend&&e.legend.formatType||On(e)&&e.formatType;return"time"===t||!t&&function(e){return"temporal"===e.type||!!e.timeUnit}(e)}function Gn(e,{timeUnit:t,type:n,time:i,undefinedIfExprNotRequired:r}){let o;var a;return Vt(e)?o=Kt(e,!0):(s(e)||v(e))&&(t||"temporal"===n)&&(o=function(e){return!!rn[e]}(t)?Kt({[t]:e},!0):function(e){return!!an[e]}(t)?Gn(e,{timeUnit:(a=t,a.substr(3))}):`datetime(${JSON.stringify(e)})`),o?i?`time(${o})`:o:r?void 0:JSON.stringify(e)}function Yn(e,t){const{timeUnit:n,type:i}=e;return t.map(e=>{const t=Gn(e,{timeUnit:n,type:i,undefinedIfExprNotRequired:!0});return void 0!==t?{signal:t}:e})}function Vn(e,t){return Xn(e.bin)?Tt(t)&&R(["ordinal","nominal"],e.type):(console.warn("Only use this method with binned field defs"),!1)}function Qn(e){return b(e)&&(e=qn(e,void 0)),"bin"+V(e).map(t=>Z(`_${t}_${e[t]}`)).join("")}function Xn(e){return!0===e||Zn(e)&&!e.binned}function Jn(e){return"binned"===e||Zn(e)&&e.binned}function Zn(e){return a(e)}function Kn(e){switch(e){case Le:case Ie:case nt:case Ze:case Ke:case et:case at:case it:case rt:case ot:case tt:return 6;default:return 10}}function ei(e,t){const n=e&&e[t];return!!n&&(o(n)?P(n,e=>!!e.field):wn(n)||An(n))}function ti(e){return P(xt,t=>{if(ei(e,t)){const n=e[t];if(o(n))return P(n,e=>!!e.aggregate);{const e=Un(n);return e&&!!e.aggregate}}return!1})}function ni(e,t){const n=[],i=[],r=[],o=[],a={};return oi(e,(s,u)=>{if(wn(s)){const{field:c,aggregate:l,timeUnit:f,bin:d}=s,p=Ne(s,["field","aggregate","timeUnit","bin"]);if(l||f||d){const e=Rn(s),h=e&&e.title;let m=$n(s,{forAs:!0});const g=Object.assign({},h?[]:{title:zn(s,t,{allowDisabling:!0})},p,{field:m}),y="x"===u||"y"===u;if(l){let e;if(Te(l)?(e="argmax",m=$n({aggregate:"argmax",field:l.argmax},{forAs:!0}),g.field=`${m}.${c}`):_e(l)?(e="argmin",m=$n({aggregate:"argmin",field:l.argmin},{forAs:!0}),g.field=`${m}.${c}`):"boxplot"!==l&&"errorbar"!==l&&"errorband"!==l&&(e=l),e){const t={op:e,as:m};c&&(t.field=c),o.push(t)}}else if(Cn(s)&&Xn(d)){if(i.push({bin:d,field:c,as:m}),n.push($n(s,{binSuffix:"end"})),Vn(s,u)&&n.push($n(s,{binSuffix:"range"})),y){const e={field:m+"_end"};a[u+"2"]=e}g.bin="binned",Et(u)||(g.type="quantitative")}else if(f){r.push({timeUnit:f,field:c,as:m});const e=fn(f,t.axis.shortTimeLabels).join(" "),n=Cn(s)&&s.type!==gn&&"time";"text"===u||"tooltip"===u?(g.format=g.format||e,n&&(g.formatType=n)):!function(e){return!!St[e]}(u)?y&&(g.axis=Object.assign({format:e},n?{formatType:n}:{},g.axis)):g.legend=Object.assign({format:e},n?{formatType:n}:{},g.legend)}l||n.push(m),a[u]=g}else n.push(c),a[u]=e[u]}else a[u]=e[u]}),{bins:i,timeUnits:r,aggregate:o,groupby:n,encoding:a}}function ii(e,t){return V(e).reduce((n,i)=>{if(!Ct(i))return Ht(Pt.invalidEncodingChannel(i)),n;if(!function(e,t,n){const i=zt(t,n);if(!i)return!1;if("binned"===i){const n=e["x2"===t?"x":"y"];return!(!wn(n)||!wn(e[t])||"binned"!==n.bin)}return!0}(e,i,t))return Ht(Pt.incompatibleChannel(i,t)),n;if("size"===i&&"line"===t){const t=Mn(e[i]);if(t&&t.aggregate)return Ht(Pt.LINE_WITH_VARYING_SIZE),n}if("color"===i&&("fill"in e||"stroke"in e))return Ht(Pt.droppingColor("encoding",{fill:"fill"in e,stroke:"stroke"in e})),n;const r=e[i];if("detail"===i||"order"===i&&!o(r)&&!En(r)||"tooltip"===i&&o(r))r&&(n[i]=(o(r)?r:[r]).reduce((e,t)=>(wn(t)?e.push(In(t,i)):Ht(Pt.emptyFieldDef(t,i)),e),[]));else{if("tooltip"===i&&null===r)n[i]=null;else if(!wn(r)&&!En(r)&&!xn(r))return Ht(Pt.emptyFieldDef(r,i)),n;n[i]=Ln(r,i)}return n},{})}function ri(e){const t=[];for(const n of V(e))if(ei(e,n)){const i=e[n];(o(i)?i:[i]).forEach(e=>{wn(e)?t.push(e):An(e)&&t.push(e.condition)})}return t}function oi(e,t,n){if(e)for(const i of V(e)){const r=e[i];o(r)?r.forEach(e=>{t.call(n,e,i)}):t.call(n,r,i)}}function ai(e,t,n,i){return e?V(e).reduce((n,r)=>{const a=e[r];return o(a)?a.reduce((e,n)=>t.call(i,e,n,r),n):t.call(i,n,a,r)},n):n}function si(e,t,n,i=!0){return{tooltip:[...e.map(({fieldPrefix:e,titlePrefix:n})=>({field:e+t.field,type:t.type,title:n+(i?" of "+t.field:"")})),...ri(n)]}}function ui(e,t,n,i,r){const{scale:o,axis:a}=n;return({partName:u,mark:c,positionPrefix:l,endPositionPrefix:f,extraEncoding:d={}})=>{const p=a&&void 0!==a.title?void 0:void 0!==n.title?n.title:n.field;return ci(e,u,r,{mark:c,encoding:Object.assign({[t]:Object.assign({field:l+"_"+n.field,type:n.type},p?{title:p}:{},o?{scale:o}:{},a?{axis:a}:{})},s(f)?{[t+"2"]:{field:f+"_"+n.field,type:n.type}}:{},i,d)})}}function ci(e,t,n,i){const{clip:r,color:o,opacity:a}=e,s=e.type;return e[t]||void 0===e[t]&&n[t]?[Object.assign({},i,{mark:Object.assign({},n[t],r?{clip:r}:{},o?{color:o}:{},a?{opacity:a}:{},Se(i.mark)?i.mark:{type:i.mark},{style:`${s}-${t}`},b(e[t])?{}:e[t])})]:[]}function li(e,t,n){const{encoding:i}=e,r="vertical"===t?"y":"x",o=i[r],a=i[r+"2"],s=i[r+"Error"],u=i[r+"Error2"];return{continuousAxisChannelDef:fi(o,n),continuousAxisChannelDef2:fi(a,n),continuousAxisChannelDefError:fi(s,n),continuousAxisChannelDefError2:fi(u,n),continuousAxis:r}}function fi(e,t){if(e&&e.aggregate){const{aggregate:n}=e,i=Ne(e,["aggregate"]);return n!==t&&Ht(Pt.errorBarContinuousAxisHasCustomizedAggregate(n,t)),i}return e}function di(e,t){const{mark:n,encoding:i}=e;if(wn(i.x)&&Bn(i.x)){if(wn(i.y)&&Bn(i.y)){if(void 0===i.x.aggregate&&i.y.aggregate===t)return"vertical";if(void 0===i.y.aggregate&&i.x.aggregate===t)return"horizontal";if(i.x.aggregate===t&&i.y.aggregate===t)throw new Error("Both x and y cannot have aggregate");return Se(n)&&n.orient?n.orient:"vertical"}return"horizontal"}if(wn(i.y)&&Bn(i.y))return"vertical";throw new Error("Need a valid continuous axis for "+t+"s")}const pi="boxplot",hi=V({box:1,median:1,outliers:1,rule:1,ticks:1}),mi=new Be(pi,yi);function gi(e){return v(e)?"tukey":e}function yi(e,{config:t}){const{mark:n,encoding:i,selection:r,projection:s}=e,u=Ne(e,["mark","encoding","selection","projection"]),c=Se(n)?n:{type:n};r&&Ht(Pt.selectionNotSupported("boxplot"));const l=c.extent||t.boxplot.extent,f=se(c.size,t.boxplot.size),d=gi(l),{transform:p,continuousAxisChannelDef:h,continuousAxis:m,groupby:g,aggregate:y,encodingWithoutContinuousAxis:b,ticksOrient:v,customTooltipWithoutAggregatedField:x}=function(e,t,n){const i=di(e,pi),{continuousAxisChannelDef:r,continuousAxis:a}=li(e,i,pi),s=r.field,u=gi(t),c=[...bi(s),{op:"median",field:s,as:"mid_box_"+s},{op:"min",field:s,as:("min-max"===u?"lower_whisker_":"min_")+s},{op:"max",field:s,as:("min-max"===u?"upper_whisker_":"max_")+s}],l="min-max"===u||"tukey"===u?[]:[{calculate:`datum["upper_box_${s}"] - datum["lower_box_${s}"]`,as:"iqr_"+s},{calculate:`min(datum["upper_box_${s}"] + datum["iqr_${s}"] * ${t}, datum["max_${s}"])`,as:"upper_whisker_"+s},{calculate:`max(datum["lower_box_${s}"] - datum["iqr_${s}"] * ${t}, datum["min_${s}"])`,as:"lower_whisker_"+s}],f=e.encoding,d=a,p=(f[d],Ne(f,["symbol"==typeof d?d:d+""])),{customTooltipWithoutAggregatedField:h,filteredEncoding:m}=function(e){const{tooltip:t}=e,n=Ne(e,["tooltip"]);if(!t)return{filteredEncoding:e};let i,r;return o(t)?(t.forEach(e=>{e.aggregate?(i||(i=[]),i.push(e)):(r||(r=[]),r.push(e))}),i&&(n.tooltip=i)):t.aggregate?n.tooltip=t:r=t,o(r)&&1===r.length&&(r=r[0]),{customTooltipWithoutAggregatedField:r,filteredEncoding:n}}(p),{bins:g,timeUnits:y,aggregate:b,groupby:v,encoding:x}=ni(m,n),A="vertical"===i?"horizontal":"vertical";return{transform:[...g,...y,{aggregate:[...b,...c],groupby:v},...l],groupby:v,aggregate:b,continuousAxisChannelDef:r,continuousAxis:a,encodingWithoutContinuousAxis:x,ticksOrient:A,customTooltipWithoutAggregatedField:h}}(e,l,t),{color:A,size:w}=b,C=Ne(b,["color","size"]),F=e=>ui(c,m,h,e,t.boxplot),E=F(C),D=F(b),S=F(Object.assign({},C,w?{size:w}:{})),k=si([{fieldPrefix:"min-max"===d?"upper_whisker_":"max_",titlePrefix:"Max"},{fieldPrefix:"upper_box_",titlePrefix:"Q3"},{fieldPrefix:"mid_box_",titlePrefix:"Median"},{fieldPrefix:"lower_box_",titlePrefix:"Q1"},{fieldPrefix:"min-max"===d?"lower_whisker_":"min_",titlePrefix:"Min"}],h,b),O={type:"tick",color:"black",opacity:1,orient:v},$="min-max"===d?k:si([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],h,b),B=[...E({partName:"rule",mark:"rule",positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",extraEncoding:$}),...E({partName:"rule",mark:"rule",positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",extraEncoding:$}),...E({partName:"ticks",mark:O,positionPrefix:"lower_whisker",extraEncoding:$}),...E({partName:"ticks",mark:O,positionPrefix:"upper_whisker",extraEncoding:$})],N=[..."tukey"!==d?B:[],...D({partName:"box",mark:Object.assign({type:"bar"},f?{size:f}:{}),positionPrefix:"lower_box",endPositionPrefix:"upper_box",extraEncoding:k}),...S({partName:"median",mark:Object.assign({type:"tick"},a(t.boxplot.median)&&t.boxplot.median.color?{color:t.boxplot.median.color}:{},f?{size:f}:{},{orient:v}),positionPrefix:"mid_box",extraEncoding:k})];let j;if("min-max"!==d){const e=`datum["lower_box_${h.field}"]`,n=`datum["upper_box_${h.field}"]`,i=`(${n} - ${e})`,r=`${e} - ${l} * ${i}`,o=`${n} + ${l} * ${i}`,a=`datum["${h.field}"]`,s={joinaggregate:bi(h.field),groupby:g};let u=void 0;"tukey"===d&&(u={transform:[{filter:`(${r} <= ${a}) && (${a} <= ${o})`},{aggregate:[{op:"min",field:h.field,as:"lower_whisker_"+h.field},{op:"max",field:h.field,as:"upper_whisker_"+h.field},{op:"min",field:"lower_box_"+h.field,as:"lower_box_"+h.field},{op:"max",field:"upper_box_"+h.field,as:"upper_box_"+h.field},...y],groupby:g}],layer:B});const f=Ne(C,["tooltip"]),p=ci(c,"outliers",t.boxplot,{transform:[{filter:`(${a} < ${r}) || (${a} > ${o})`}],mark:"point",encoding:Object.assign({[m]:{field:h.field,type:h.type}},f,x?{tooltip:x}:{})})[0];p&&u?j={transform:[s],layer:[p,u]}:p?(j=p).transform.unshift(s):u&&(j=u).transform.unshift(s)}return j?Object.assign({},u,{layer:[...j?[j]:[],{transform:p,layer:N}]}):Object.assign({},u,{transform:(u.transform||[]).concat(p),layer:N})}function bi(e){return[{op:"q1",field:e,as:"lower_box_"+e},{op:"q3",field:e,as:"upper_box_"+e}]}const vi="errorbar",xi=V({ticks:1,rule:1}),Ai=new Be(vi,wi);function wi(e,{config:t}){const{transform:n,continuousAxisChannelDef:i,continuousAxis:r,encodingWithoutContinuousAxis:o,ticksOrient:a,markDef:s,outerSpec:u,tooltipEncoding:c}=Fi(e,vi,t),l=ui(s,r,i,o,t.errorbar),f={type:"tick",orient:a};return Object.assign({},u,{transform:n,layer:[...l({partName:"ticks",mark:f,positionPrefix:"lower",extraEncoding:c}),...l({partName:"ticks",mark:f,positionPrefix:"upper",extraEncoding:c}),...l({partName:"rule",mark:"rule",positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:c})]})}function Ci(e,t){const{encoding:n}=e;if(function(e){return(wn(e.x)||wn(e.y))&&!wn(e.x2)&&!wn(e.y2)&&!wn(e.xError)&&!wn(e.xError2)&&!wn(e.yError)&&!wn(e.yError2)}(n))return{orient:di(e,t),inputType:"raw"};const i=function(e){return wn(e.x2)||wn(e.y2)}(n),r=function(e){return wn(e.xError)||wn(e.xError2)||wn(e.yError)||wn(e.yError2)}(n),o=n.x,a=n.y;if(i){if(r)throw new Error(t+" cannot be both type aggregated-upper-lower and aggregated-error");const e=n.x2,i=n.y2;if(wn(e)&&wn(i))throw new Error(t+" cannot have both x2 and y2");if(wn(e)){if(wn(o)&&Bn(o))return{orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error("Both x and x2 have to be quantitative in "+t)}if(wn(i)){if(wn(a)&&Bn(a))return{orient:"vertical",inputType:"aggregated-upper-lower"};throw new Error("Both y and y2 have to be quantitative in "+t)}throw new Error("No ranged axis")}{const e=n.xError,i=n.xError2,r=n.yError,s=n.yError2;if(wn(i)&&!wn(e))throw new Error(t+" cannot have xError2 without xError");if(wn(s)&&!wn(r))throw new Error(t+" cannot have yError2 without yError");if(wn(e)&&wn(r))throw new Error(t+" cannot have both xError and yError with both are quantiative");if(wn(e)){if(wn(o)&&Bn(o))return{orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative")}if(wn(r)){if(wn(a)&&Bn(a))return{orient:"vertical",inputType:"aggregated-error"};throw new Error("All y, yError, and yError2 (if exist) have to be quantitative")}throw new Error("No ranged axis")}}function Fi(e,t,n){const{mark:i,encoding:r,selection:o,projection:a}=e,s=Ne(e,["mark","encoding","selection","projection"]),u=Se(i)?i:{type:i};o&&Ht(Pt.selectionNotSupported(t));const{orient:c,inputType:l}=Ci(e,t),{continuousAxisChannelDef:f,continuousAxisChannelDef2:d,continuousAxisChannelDefError:p,continuousAxisChannelDefError2:h,continuousAxis:m}=li(e,c,t),{errorBarSpecificAggregate:g,postAggregateCalculates:y,tooltipSummary:b,tooltipTitleWithFieldName:v}=function(e,t,n,i,r,o,a,s){let u=[],c=[];const l=t.field;let f,d=!1;if("raw"===o){const t=e.center?e.center:e.extent?"iqr"===e.extent?"median":"mean":s.errorbar.center,n=e.extent?e.extent:"mean"===t?"stderr":"iqr";if("median"===t!=("iqr"===n)&&Ht(Pt.errorBarCenterIsUsedWithWrongExtent(t,n,a)),"stderr"===n||"stdev"===n)u=[{op:n,field:l,as:"extent_"+l},{op:t,field:l,as:"center_"+l}],c=[{calculate:`datum["center_${l}"] + datum["extent_${l}"]`,as:"upper_"+l},{calculate:`datum["center_${l}"] - datum["extent_${l}"]`,as:"lower_"+l}],f=[{fieldPrefix:"center_",titlePrefix:te(t)},{fieldPrefix:"upper_",titlePrefix:Ei(t,n,"+")},{fieldPrefix:"lower_",titlePrefix:Ei(t,n,"-")}],d=!0;else{let t,i,r;e.center&&e.extent&&Ht(Pt.errorBarCenterIsNotNeeded(e.extent,a)),"ci"===n?(t="mean",i="ci0",r="ci1"):(t="median",i="q1",r="q3"),u=[{op:i,field:l,as:"lower_"+l},{op:r,field:l,as:"upper_"+l},{op:t,field:l,as:"center_"+l}],f=[{fieldPrefix:"upper_",titlePrefix:zn({field:l,aggregate:r,type:"quantitative"},s,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:zn({field:l,aggregate:i,type:"quantitative"},s,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:zn({field:l,aggregate:t,type:"quantitative"},s,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&Ht(Pt.errorBarCenterAndExtentAreNotNeeded(e.center,e.extent)),"aggregated-upper-lower"===o?(f=[],c=[{calculate:`datum["${n.field}"]`,as:"upper_"+l},{calculate:`datum["${l}"]`,as:"lower_"+l}]):"aggregated-error"===o&&(f=[{fieldPrefix:"",titlePrefix:l}],c=[{calculate:`datum["${l}"] + datum["${i.field}"]`,as:"upper_"+l}],r?c.push({calculate:`datum["${l}"] + datum["${r.field}"]`,as:"lower_"+l}):c.push({calculate:`datum["${l}"] - datum["${i.field}"]`,as:"lower_"+l}));for(const e of c)f.push({fieldPrefix:e.as.substring(0,6),titlePrefix:e.calculate.replace(new RegExp('datum\\[\\"',"g"),"").replace(new RegExp('\\"\\]',"g"),"")})}return{postAggregateCalculates:c,errorBarSpecificAggregate:u,tooltipSummary:f,tooltipTitleWithFieldName:d}}(u,f,d,p,h,l,t,n),x=m,A=(r[x],"x"===m?"x2":"y2"),w=(r[A],"x"===m?"xError":"yError"),C=(r[w],"x"===m?"xError2":"yError2"),F=(r[C],Ne(r,["symbol"==typeof x?x:x+"","symbol"==typeof A?A:A+"","symbol"==typeof w?w:w+"","symbol"==typeof C?C:C+""])),{bins:E,timeUnits:D,aggregate:S,groupby:k,encoding:O}=ni(F,n),$=[...S,...g],B="raw"!==l?[]:k,N=si(b,f,O,v);return{transform:[...s.transform||[],...E,...D,...$.length?[{aggregate:$,groupby:B}]:[],...y],groupby:B,continuousAxisChannelDef:f,continuousAxis:m,encodingWithoutContinuousAxis:O,ticksOrient:"vertical"===c?"horizontal":"vertical",markDef:u,outerSpec:s,tooltipEncoding:N}}function Ei(e,t,n){return te(e)+" "+n+" "+t}const Di="errorband",Si=V({band:1,borders:1}),ki=new Be(Di,Oi);function Oi(e,{config:t}){const{transform:n,continuousAxisChannelDef:i,continuousAxis:r,encodingWithoutContinuousAxis:o,markDef:a,outerSpec:s,tooltipEncoding:u}=Fi(e,Di,t),c=a,l=ui(c,r,i,o,t.errorband),f=void 0!==e.encoding.x&&void 0!==e.encoding.y;let d={type:f?"area":"rect"},p={type:f?"line":"rule"};const h=Object.assign({},c.interpolate?{interpolate:c.interpolate}:{},c.tension&&c.interpolate?{interpolate:c.tension}:{});return f?(d=Object.assign({},d,h),p=Object.assign({},p,h)):c.interpolate?Ht(Pt.errorBand1DNotSupport("interpolate")):c.tension&&Ht(Pt.errorBand1DNotSupport("tension")),Object.assign({},s,{transform:n,layer:[...l({partName:"band",mark:d,positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:u}),...l({partName:"borders",mark:p,positionPrefix:"lower",extraEncoding:u}),...l({partName:"borders",mark:p,positionPrefix:"upper",extraEncoding:u})]})}const $i={};function Bi(e,t,n){const i=new Be(e,t);$i[e]={normalizer:i,parts:n}}Bi(pi,yi,hi),Bi(vi,wi,xi),Bi(Di,Oi,Si);const Ni=["shortTimeLabels"],ji=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength"],_i={clipHeight:1,columnPadding:1,columns:1,cornerRadius:1,direction:1,fillColor:1,format:1,formatType:1,gradientLength:1,gradientOpacity:1,gradientStrokeColor:1,gradientStrokeWidth:1,gradientThickness:1,gridAlign:1,labelAlign:1,labelBaseline:1,labelColor:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labelSeparation:1,legendX:1,legendY:1,offset:1,orient:1,padding:1,rowPadding:1,strokeColor:1,symbolDash:1,symbolDashOffset:1,symbolFillColor:1,symbolOffset:1,symbolOpacity:1,symbolSize:1,symbolStrokeColor:1,symbolStrokeWidth:1,symbolType:1,tickCount:1,tickMinStep:1,title:1,titleAlign:1,titleAnchor:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleOpacity:1,titleOrient:1,titlePadding:1,type:1,values:1,zindex:1},Ti=Object.assign({},_i,{opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,encode:1}),zi=X(_i),Ri=X(Ti);var Pi;!function(e){e.LINEAR="linear",e.LOG="log",e.POW="pow",e.SQRT="sqrt",e.SYMLOG="symlog",e.TIME="time",e.UTC="utc",e.QUANTILE="quantile",e.QUANTIZE="quantize",e.THRESHOLD="threshold",e.BIN_ORDINAL="bin-ordinal",e.ORDINAL="ordinal",e.POINT="point",e.BAND="band"}(Pi||(Pi={}));const Ui={linear:"numeric",log:"numeric",pow:"numeric",sqrt:"numeric",symlog:"numeric",time:"time",utc:"time",ordinal:"ordinal","bin-ordinal":"bin-ordinal",point:"ordinal-position",band:"ordinal-position",quantile:"discretizing",quantize:"discretizing",threshold:"discretizing"},Mi=V(Ui);function Li(e,t){const n=Ui[e],i=Ui[t];return n===i||"ordinal-position"===n&&"time"===i||"ordinal-position"===i&&"time"===n}const Ii={linear:0,log:1,pow:1,sqrt:1,symlog:1,time:0,utc:0,point:10,band:11,ordinal:0,"bin-ordinal":0,quantile:0,quantize:0,threshold:0};function qi(e){return Ii[e]}const Wi=["linear","log","pow","sqrt","symlog","time","utc"],Hi=x(Wi),Gi=x(["quantile","quantize","threshold"]),Yi=x(Wi.concat(["quantile","quantize","threshold"])),Vi=x(["ordinal","bin-ordinal","point","band"]);function Qi(e){return e in Vi}function Xi(e){return e in Yi}function Ji(e){return e in Hi}function Zi(e){return e in Gi}const Ki={textXRangeStep:90,rangeStep:20,pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:9,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4};function er(e){return e&&e.selection}const tr=X(Ne({type:1,domain:1,range:1,rangeStep:1,scheme:1,bins:1,reverse:1,round:1,clamp:1,nice:1,base:1,exponent:1,constant:1,interpolate:1,zero:1,padding:1,paddingInner:1,paddingOuter:1},["type","domain","range","rangeStep","scheme"]));!function(){const e={};for(const t of xt)for(const n of V(pn))for(const i of Mi){const r=ar(t,n);or(t,i)&&rr(i,n)&&(e[r]=e[r]||[],e[r].push(i))}}();function nr(e,t){switch(t){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!R(["point","band","identity"],e);case"bins":return!R(["point","band","identity","ordinal"],e);case"round":return Ji(e)||"band"===e||"point"===e;case"padding":return Ji(e)||R(["point","band"],e);case"paddingOuter":case"rangeStep":return R(["point","band"],e);case"paddingInner":return"band"===e;case"clamp":return Ji(e);case"nice":return Ji(e)||"quantize"===e||"threshold"===e;case"exponent":return"pow"===e;case"base":return"log"===e;case"constant":return"symlog"===e;case"zero":return Xi(e)&&!R(["log","time","utc","threshold","quantile"],e)}throw new Error(`Invalid scale property ${t}.`)}function ir(e,t){switch(t){case"interpolate":case"scheme":return gt(e)?void 0:Pt.cannotUseScalePropertyWithNonColor(e);case"type":case"bins":case"domain":case"range":case"base":case"exponent":case"constant":case"nice":case"padding":case"paddingInner":case"paddingOuter":case"rangeStep":case"reverse":case"round":case"clamp":case"zero":return}throw new Error(`Invalid scale property "${t}".`)}function rr(e,t){return R([mn,yn],t)?void 0===e||Qi(e):t===gn?R([Pi.TIME,Pi.UTC,void 0],e):t!==hn||R([Pi.LOG,Pi.POW,Pi.SQRT,Pi.SYMLOG,Pi.QUANTILE,Pi.QUANTIZE,Pi.THRESHOLD,Pi.LINEAR,void 0],e)}function or(e,t){switch(e){case We:case He:return Ji(t)||R(["band","point"],t);case nt:case at:case it:case rt:case ot:return Ji(t)||Zi(t)||R(["band","point"],t);case Ze:case Ke:case et:return"band"!==t;case tt:return"ordinal"===t}return!1}function ar(e,t){return e+"_"+t}const sr="_vgsid_";function ur(e){return"interval"===e.type}const cr={single:{on:"click",fields:[sr],resolve:"global",empty:"all",clear:"dblclick"},multi:{on:"click",fields:[sr],toggle:"event.shiftKey",resolve:"global",empty:"all",clear:"dblclick"},interval:{on:"[mousedown, window:mouseup] > window:mousemove!",encodings:["x","y"],translate:"[mousedown, window:mouseup] > window:mousemove!",zoom:"wheel!",mark:{fill:"#333",fillOpacity:.125,stroke:"white"},resolve:"global",clear:"dblclick"}};function lr(e){return void 0!==e.concat}function fr(e){return void 0!==e.vconcat}function dr(e){return void 0!==e.hconcat}function pr(e){return void 0!==e.repeat}const hr=X({align:1,bounds:1,center:1,columns:1,spacing:1});function mr(e){const{anchor:t,frame:n,offset:i,orient:r,color:o}=e,a=Ne(e,["anchor","frame","offset","orient","color"]);return{mark:Object.assign({},a,o?{fill:o}:{}),nonMark:Object.assign({},t?{anchor:t}:{},n?{frame:n}:{},i?{offset:i}:{},r?{orient:r}:{})}}const gr={padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",invalidValues:"filter",view:{width:200,height:200},mark:{color:"#4c78a8",tooltip:{content:"encoding"}},area:{},bar:{binSpacing:1,continuousBandSize:5},circle:{},geoshape:{},line:{},point:{},rect:{},rule:{color:"black"},square:{},text:{color:"black"},tick:{thickness:1},trail:{},boxplot:{size:14,extent:1.5,box:{},median:{color:"white"},outliers:{},rule:{},ticks:null},errorbar:{center:"mean",rule:!0,ticks:!1},errorband:{band:{opacity:.3},borders:!1},scale:Ki,projection:{},axis:{},axisX:{},axisY:{},axisLeft:{},axisRight:{},axisTop:{},axisBottom:{},axisBand:{},legend:{gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64},header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:cr,style:{},title:{},facet:{spacing:20},repeat:{spacing:20},concat:{spacing:20}};function yr(e){return L(B(gr),e)}const br=["view",...De],vr=["padding","facet","concat","repeat","numberFormat","timeFormat","countTitle","header","stack","scale","selection","invalidValues","overlay"],xr=Object.assign({view:["width","height"]},{area:["line","point"],bar:["binSpacing","continuousBandSize","discreteBandSize"],line:["point"],text:["shortTimeLabels"],tick:["bandSize","thickness"]});function Ar(e){e=B(e);for(const t of vr)delete e[t];if(e.axis)for(const t of Ni)delete e.axis[t];if(e.legend){for(const t of Ni)delete e.legend[t];for(const t of ji)delete e.legend[t]}if(e.mark)for(const t of Oe)delete e.mark[t];for(const t of br){for(const n of Oe)delete e[t][n];const n=xr[t];if(n)for(const i of n)delete e[t][i];wr(e,t)}for(const t of V($i))delete e[t];wr(e,"title","group-title");for(const t in e)a(e[t])&&0===V(e[t]).length&&delete e[t];return V(e).length>0?e:void 0}function wr(e,t,n,i){const r="title"===t?mr(e.title).mark:i?e[t][i]:e[t];"view"===t&&(n="cell");const o=Object.assign({},r,e.style[t]);V(o).length>0&&(e.style[n||t]=o),i||delete e[t]}function Cr(e){return void 0!==e.layer}class Fr{map(e,t){return tn(e)?this.mapFacet(e,t):pr(e)?this.mapRepeat(e,t):dr(e)?this.mapHConcat(e,t):fr(e)?this.mapVConcat(e,t):lr(e)?this.mapConcat(e,t):this.mapLayerOrUnit(e,t)}mapLayerOrUnit(e,t){if(Cr(e))return this.mapLayer(e,t);if($e(e))return this.mapUnit(e,t);throw new Error(Pt.INVALID_SPEC)}mapLayer(e,t){return Object.assign({},e,{layer:e.layer.map(e=>this.mapLayerOrUnit(e,t))})}mapHConcat(e,t){return Object.assign({},e,{hconcat:e.hconcat.map(e=>this.map(e,t))})}mapVConcat(e,t){return Object.assign({},e,{vconcat:e.vconcat.map(e=>this.map(e,t))})}mapConcat(e,t){const{concat:n}=e,i=Ne(e,["concat"]);return Object.assign({},i,{concat:n.map(e=>this.map(e,t))})}mapFacet(e,t){return Object.assign({},e,{spec:this.map(e.spec,t)})}mapRepeat(e,t){return Object.assign({},e,{spec:this.map(e.spec,t)})}}const Er={zero:1,center:1,normalize:1};const Dr=[he,pe,be,ge,we,Ce,me,ve,xe],Sr=[he,pe];function kr(e,t,n,i={}){const r=Se(e)?e.type:e;if(!R(Dr,r))return null;const a=function(e){const t=e.x,n=e.y;if(wn(t)&&wn(n))if("quantitative"===t.type&&"quantitative"===n.type){if(t.stack)return"x";if(n.stack)return"y";if(!!t.aggregate!=!!n.aggregate)return t.aggregate?"x":"y"}else{if("quantitative"===t.type)return"x";if("quantitative"===n.type)return"y"}else{if(wn(t)&&"quantitative"===t.type)return"x";if(wn(n)&&"quantitative"===n.type)return"y"}}(t);if(!a)return null;const s=t[a],u=Fn(s)?$n(s,{}):void 0,c="x"===a?"y":"x",l=t[c],f=Fn(l)?$n(l,{}):void 0,d=kt.reduce((e,n)=>{if("tooltip"!==n&&ei(t,n)){const i=t[n];(o(i)?i:[i]).forEach(t=>{const i=Mn(t);if(i.aggregate)return;const r=Fn(i)?$n(i,{}):void 0;(!r||r!==f&&r!==u)&&e.push({channel:n,fieldDef:i})})}return e},[]);if(0===d.length)return null;let p;if(!(p=void 0!==s.stack?b(s.stack)?s.stack?"zero":null:s.stack:R(Sr,r)?se(n,"zero"):n)||!Er[p])return null;if(s.scale&&s.scale.type&&s.scale.type!==Pi.LINEAR){if(i.disallowNonLinearStack)return null;Ht(Pt.cannotStackNonLinearScale(s.scale.type))}return ei(t,a===We?Ge:Ye)?(void 0!==s.stack&&Ht(Pt.cannotStackRangedMark(a)),null):(s.aggregate&&!R(Ue,s.aggregate)&&Ht(Pt.stackNonSummativeAggregate(s.aggregate)),{groupbyChannel:l?c:void 0,fieldChannel:a,impute:Ee(r),stackBy:d,offset:p})}function Or(e){const t=Ne(e,["point","line"]);return V(t).length>1?t:t.type}function $r(e){for(const t of["line","area","rule","trail"])e[t]&&(e=Object.assign({},e,{[t]:j(e[t],["point","line"])}));return e}function Br(e,t={},n){return"transparent"===e.point?{opacity:0}:e.point?a(e.point)?e.point:{}:void 0!==e.point?null:t.point||n.shape?a(t.point)?t.point:{}:void 0}function Nr(e,t={}){return e.line?!0===e.line?{}:e.line:void 0!==e.line?null:t.line?!0===t.line?{}:t.line:void 0}class jr{constructor(){this.name="path-overlay"}hasMatchingType(e,t){if($e(e)){const{mark:n,encoding:i}=e,r=Se(n)?n:{type:n};switch(r.type){case"line":case"rule":case"trail":return!!Br(r,t[r.type],i);case"area":return!!Br(r,t[r.type],i)||!!Nr(r,t[r.type])}}return!1}run(e,t,n){const{config:i}=t,{selection:r,projection:o,encoding:a,mark:s}=e,u=Ne(e,["selection","projection","encoding","mark"]),c=Se(s)?s:{type:s},l=Br(c,i[c.type],a),f="area"===c.type&&Nr(c,i[c.type]),d=[Object.assign({},r?{selection:r}:{},{mark:Or(Object.assign({},c,"area"===c.type?{opacity:.7}:{})),encoding:j(a,["shape"])})],p=kr(c,a,i?i.stack:void 0);let h=a;if(p){const{fieldChannel:e,offset:t}=p;h=Object.assign({},a,{[e]:Object.assign({},a[e],t?{stack:t}:{})})}return f&&d.push(Object.assign({},o?{projection:o}:{},{mark:Object.assign({type:"line"},N(c,["clip","interpolate","tension"]),f),encoding:h})),l&&d.push(Object.assign({},o?{projection:o}:{},{mark:Object.assign({type:"point",opacity:1,filled:!0},N(c,["clip"]),l),encoding:h})),n(Object.assign({},u,{layer:d}),Object.assign({},t,{config:$r(i)}))}}class _r{constructor(){this.name="RuleForRangedLine"}hasMatchingType(e){if($e(e)){const{encoding:t,mark:n}=e;if("line"===n)for(const e of Ft){const n=t[Dt(e)];if(t[e]&&wn(n)&&"binned"!==n.bin)return!0}}return!1}run(e,t,n){const{encoding:i}=e;return Ht(Pt.lineWithRange(!!i.x2,!!i.y2)),n(Object.assign({},e,{mark:"rule"}),t)}}function Tr(e){const{parentEncoding:t,encoding:n}=e;if(t&&n){const e=V(t).reduce((e,t)=>(n[t]&&e.push(t),e),[]);e.length>0&&Ht(Pt.encodingOverridden(e))}const i=Object.assign({},t||{},n||{});return V(i).length>0?i:void 0}function zr(e){const{parentProjection:t,projection:n}=e;return t&&n&&Ht(Pt.projectionOverridden({parentProjection:t,projection:n})),n||t}function Rr(e,t){return void 0===t&&(t=yr(e.config)),function(e,t={}){return Pr.map(e,{config:t})}(e,t)}const Pr=new class extends Fr{constructor(){super(...arguments),this.nonFacetUnitNormalizers=[mi,Ai,ki,new jr,new _r]}map(e,t){if($e(e)){const n=ei(e.encoding,Le),i=ei(e.encoding,Ie),r=ei(e.encoding,qe);if(n||i||r)return this.mapFacetedUnit(e,t)}return super.map(e,t)}mapUnit(e,t){const{parentEncoding:n,parentProjection:i}=t;if(n||i)return this.mapUnitWithParentEncodingOrProjection(e,t);const r=this.mapLayerOrUnit.bind(this);for(const n of this.nonFacetUnitNormalizers)if(n.hasMatchingType(e,t.config))return n.run(e,t,r);return e}mapRepeat(e,t){const{repeat:n}=e;return!o(n)&&e.columns&&(e=j(e,["columns"]),Ht(Pt.columnsNotSupportByRowCol("repeat"))),Object.assign({},e,{spec:this.map(e.spec,t)})}mapFacet(e,t){const{facet:n}=e;return en(n)&&e.columns&&(e=j(e,["columns"]),Ht(Pt.columnsNotSupportByRowCol("facet"))),super.mapFacet(e,t)}mapUnitWithParentEncodingOrProjection(e,t){const{encoding:n,projection:i}=e,{parentEncoding:r,parentProjection:o,config:a}=t,s=zr({parentProjection:o,projection:i}),u=Tr({parentEncoding:r,encoding:n});return this.mapUnit(Object.assign({},e,s?{projection:s}:{},u?{encoding:u}:{}),{config:a})}mapFacetedUnit(e,t){const n=e.encoding,{row:i,column:r,facet:o}=n,a=Ne(n,["row","column","facet"]),{mark:s,width:u,projection:c,height:l,selection:f,encoding:d}=e,p=Ne(e,["mark","width","projection","height","selection","encoding"]);return o&&(i||r)&&Ht(Pt.facetChannelDropped([...i?[Le]:[],...r?[Ie]:[]])),this.mapFacet(Object.assign({},p,{facet:i||r?Object.assign({},i?{row:i}:{},r?{column:r}:{}):o,spec:Object.assign({},c?{projection:c}:{},{mark:s},u?{width:u}:{},l?{height:l}:{},{encoding:a},f?{selection:f}:{})}),t)}mapLayer(e,t){var{parentEncoding:n,parentProjection:i}=t,r=Ne(t,["parentEncoding","parentProjection"]);const{encoding:o,projection:a}=e,s=Ne(e,["encoding","projection"]),u=Object.assign({},r,{parentEncoding:Tr({parentEncoding:n,encoding:o}),parentProjection:zr({parentProjection:i,projection:a})});return super.mapLayer(s,u)}};function Ur(e){return s(e)?{type:e}:e||{}}const Mr=["background","padding"];function Lr(e){return Mr.reduce((t,n)=>(e&&void 0!==e[n]&&(t[n]=e[n]),t),{})}function Ir(e){return!!e.url}function qr(e){return!!e.values}function Wr(e){return!(!e.name||Ir(e)||qr(e)||Hr(e))}function Hr(e){return e&&(Gr(e)||Yr(e)||Vr(e))}function Gr(e){return!!e.sequence}function Yr(e){return!!e.sphere}function Vr(e){return!!e.graticule}const Qr="main",Xr="raw";function Jr(e){return e&&!!e.field&&void 0!==e.equal}function Zr(e){return e&&!!e.field&&void 0!==e.lt}function Kr(e){return e&&!!e.field&&void 0!==e.lte}function eo(e){return e&&!!e.field&&void 0!==e.gt}function to(e){return e&&!!e.field&&void 0!==e.gte}function no(e){return!!(e&&e.field&&o(e.range)&&2===e.range.length)}function io(e){return e&&!!e.field&&(o(e.oneOf)||o(e.in))}function ro(e){return io(e)||Jr(e)||no(e)||Zr(e)||eo(e)||Kr(e)||to(e)}function oo(e,t){return Gn(e,{timeUnit:t,time:!0})}function ao(e,t=!0){const{field:n,timeUnit:i}=e,r=i?"time("+ln(i,n)+")":$n(e,{expr:"datum"});if(Jr(e))return r+"==="+oo(e.equal,i);if(Zr(e)){return`${r}<${oo(e.lt,i)}`}if(eo(e)){return`${r}>${oo(e.gt,i)}`}if(Kr(e)){return`${r}<=${oo(e.lte,i)}`}if(to(e)){return`${r}>=${oo(e.gte,i)}`}if(io(e))return`indexof([${function(e,t){return e.map(e=>oo(e,t))}(e.oneOf,i).join(",")}], ${r}) !== -1`;if(function(e){return e&&!!e.field&&void 0!==e.valid}(e))return e.valid?`${r}!==null&&!isNaN(${r})`:`${r}===null||isNaN(${r})`;if(no(e)){const n=e.range[0],o=e.range[1];if(null!==n&&null!==o&&t)return"inrange("+r+", ["+oo(n,i)+", "+oo(o,i)+"])";const a=[];return null!==n&&a.push(`${r} >= ${oo(n,i)}`),null!==o&&a.push(`${r} <= ${oo(o,i)}`),a.length>0?a.join(" && "):"true"}throw new Error(`Invalid field predicate: ${JSON.stringify(e)}`)}function so(e){return ro(e)&&e.timeUnit?Object.assign({},e,{timeUnit:dn(e.timeUnit)}):e}function uo(e){return void 0!==e.filter}function co(e){return void 0!==e.lookup}function lo(e){return void 0!==e.sample}function fo(e){return void 0!==e.window}function po(e){return void 0!==e.joinaggregate}function ho(e){return void 0!==e.flatten}function mo(e){return void 0!==e.calculate}function go(e){return!!e.bin}function yo(e){return void 0!==e.impute}function bo(e){return void 0!==e.timeUnit}function vo(e){return void 0!==e.aggregate}function xo(e){return void 0!==e.stack}function Ao(e){return void 0!==e.fold}function wo(e){return!!e.signal}function Co(e){return!!e.step}function Fo(e){return!o(e)&&("field"in e&&"data"in e)}const Eo=X({opacity:1,fill:1,fillOpacity:1,stroke:1,strokeCap:1,strokeWidth:1,strokeOpacity:1,strokeDash:1,strokeDashOffset:1,strokeJoin:1,strokeMiterLimit:1,size:1,shape:1,interpolate:1,tension:1,orient:1,align:1,baseline:1,text:1,dir:1,dx:1,dy:1,ellipsis:1,limit:1,radius:1,theta:1,angle:1,font:1,fontSize:1,fontWeight:1,fontStyle:1,cursor:1,href:1,tooltip:1,cornerRadius:1,x:1,y:1,x2:1,y2:1}),Do=["domain","grid","labels","ticks","title"],So={grid:"grid",gridColor:"grid",gridDash:"grid",gridOpacity:"grid",gridScale:"grid",gridWidth:"grid",orient:"main",bandPosition:"both",domain:"main",domainColor:"main",domainOpacity:"main",domainWidth:"main",format:"main",formatType:"main",labelAlign:"main",labelAngle:"main",labelBaseline:"main",labelBound:"main",labelColor:"main",labelFlush:"main",labelFlushOffset:"main",labelFont:"main",labelFontSize:"main",labelFontWeight:"main",labelLimit:"main",labelOpacity:"main",labelOverlap:"main",labelPadding:"main",labels:"main",maxExtent:"main",minExtent:"main",offset:"main",position:"main",tickColor:"main",tickExtra:"main",tickOffset:"both",tickOpacity:"main",tickRound:"main",ticks:"main",tickSize:"main",title:"main",titleAlign:"main",titleAngle:"main",titleBaseline:"main",titleColor:"main",titleFont:"main",titleFontSize:"main",titleFontWeight:"main",titleLimit:"main",titleOpacity:"main",titlePadding:"main",titleX:"main",titleY:"main",tickWidth:"both",tickCount:"both",values:"both",scale:"both",zindex:"both"},ko={orient:1,bandPosition:1,domain:1,domainColor:1,domainDash:1,domainDashOffset:1,domainOpacity:1,domainWidth:1,format:1,formatType:1,grid:1,gridColor:1,gridDash:1,gridDashOffset:1,gridOpacity:1,gridWidth:1,labelAlign:1,labelAngle:1,labelBaseline:1,labelBound:1,labelColor:1,labelFlush:1,labelFlushOffset:1,labelFont:1,labelFontSize:1,labelFontStyle:1,labelFontWeight:1,labelLimit:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labels:1,labelSeparation:1,maxExtent:1,minExtent:1,offset:1,position:1,tickColor:1,tickCount:1,tickDash:1,tickDashOffset:1,tickExtra:1,tickMinStep:1,tickOffset:1,tickOpacity:1,tickRound:1,ticks:1,tickSize:1,tickWidth:1,title:1,titleAlign:1,titleAnchor:1,titleAngle:1,titleBaseline:1,titleColor:1,titleFont:1,titleFontSize:1,titleFontStyle:1,titleFontWeight:1,titleLimit:1,titleOpacity:1,titlePadding:1,titleX:1,titleY:1,values:1,zindex:1},Oo=Object.assign({},ko,{encoding:1});const $o=X(Object.assign({gridScale:1,scale:1},ko,{encode:1}));function Bo(e,t,n,i={header:!1}){const r=e.combine(),{orient:a,scale:s,title:u,zindex:c}=r,l=Ne(r,["orient","scale","title","zindex"]);if(V(l).forEach(e=>{const n=So[e];n&&n!==t&&"both"!==n&&delete l[e]}),"grid"===t){if(!l.grid)return;if(l.encode){const{grid:e}=l.encode;l.encode=Object.assign({},e?{grid:e}:{}),0===V(l.encode).length&&delete l.encode}return Object.assign({scale:s,orient:a},l,{domain:!1,labels:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:se(c,0)})}{if(!i.header&&e.mainExtracted)return;if(l.encode){for(const t of Do)e.hasAxisPart(t)||delete l.encode[t];0===V(l.encode).length&&delete l.encode}const t=function(e,t){return o(e)?e.map(e=>Pn(e,t)).join(", "):e}(u,n);return Object.assign({scale:s,orient:a,grid:!1},t?{title:t}:{},l,{zindex:se(c,1)})}}function No(e){const{axes:t}=e.component;for(const n of $t)if(t[n])for(const i of t[n])if(!i.get("gridScale")){const t="x"===n?"height":"width";return[{name:t,update:e.getSizeSignalRef(t).signal}]}return[]}const jo={titleAlign:"align",titleAnchor:"anchor",titleAngle:"angle",titleBaseline:"baseline",titleColor:"color",titleFont:"font",titleFontSize:"fontSize",titleFontWeight:"fontWeight",titleLimit:"limit",titleOrient:"orient",titlePadding:"offset"},_o={labelAlign:"align",labelAnchor:"anchor",labelAngle:"angle",labelColor:"color",labelFont:"font",labelFontSize:"fontSize",labelLimit:"limit",labelOrient:"orient",labelPadding:"offset"},To=V(jo),zo=V(_o),Ro="mean";function Po(e){return!(!e||"count"!==e.op&&!e.field)}function Uo(e){return!!e&&o(e)}function Mo(e,t,n,i,r){const o=[..."band"===r?["axisBand"]:[],"x"===n?"axisX":"axisY",...i?["axis"+i.substr(0,1).toUpperCase()+i.substr(1)]:[],"axis"];for(const n of o)if(t[n]&&void 0!==t[n][e])return t[n][e]}function Lo(e,t){return!Qi(e)&&!Xn(t.bin)}function Io(e,t){const n="x"===t?"y":"x";if(e.getScaleComponent(n))return e.scaleName(n)}function qo(e,t,n,i){if(void 0!==t.labelAngle)return de(t.labelAngle);{const t=Mo("labelAngle",e.config,n,Vo(n),e.getScaleComponent(n).get("type"));return void 0!==t?de(t):n===We&&R([yn,mn],i.type)?270:void 0}}function Wo(e,t){if(void 0!==e)return e=de(e),"top"===t||"bottom"===t?e<=45||315<=e?"top"===t?"bottom":"top":135<=e&&e<=225?"top"===t?"top":"bottom":"middle":e<=45||315<=e||135<=e&&e<=225?"middle":45<=e&&e<=135?"left"===t?"top":"bottom":"left"===t?"bottom":"top"}function Ho(e,t){if(void 0!==e)return e=de(e),"top"===t||"bottom"===t?e%180==0?"center":00&&(o&&(o+=" + ' ' + "),o+=i?`utcFormat(${t}, '${r.join(" ")}')`:`timeFormat(${t}, '${r.join(" ")}')`),o||void 0}(t,e,i,o)}function aa(e,t){return(o(e)?e:[e]).reduce((e,n)=>(e.field.push($n(n,t)),e.order.push(n.sort||"ascending"),e),{field:[],order:[]})}function sa(e,t){const n=[...e];return t.forEach(e=>{for(const t of n)if(_(t)===_(e))return;n.push(e)}),n}function ua(e,t){return e!==t&&t?e?e+", "+t:t:e}function ca(e,t){if(o(e.value)&&o(t.value))return{explicit:e.explicit,value:sa(e.value,t.value)};if(!o(e.value)&&!o(t.value))return{explicit:e.explicit,value:ua(e.value,t.value)};throw new Error("It should never reach here")}class la{constructor(e,t){this.debugName=t,this._children=[],this._parent=null,e&&(this.parent=e)}clone(){throw new Error("Cannot clone node")}hash(){return void 0===this._hash&&(this._hash=ce()),this._hash}producedFields(){return new Set}dependentFields(){return new Set}get parent(){return this._parent}set parent(e){this._parent=e,e&&e.addChild(this)}get children(){return this._children}numChildren(){return this._children.length}addChild(e,t){this._children.indexOf(e)>-1?console.warn("Attempt to add the same child twice."):void 0!==t?this._children.splice(t,0,e):this._children.push(e)}removeChild(e){const t=this._children.indexOf(e);return this._children.splice(t,1),t}remove(){let e=this._parent.removeChild(this);for(const t of this._children)t._parent=this._parent,this._parent.addChild(t,e++)}insertAsParentOf(e){const t=e.parent;t.removeChild(this),this.parent=t,e.parent=this}swapWithParent(){const e=this._parent,t=e.parent;for(const t of this._children)t.parent=e;this._children=[],e.removeChild(this),e.parent.removeChild(e),this.parent=t,e.parent=this}}class fa extends la{constructor(e,t,n,i){super(e,t),this.type=n,this.refCounts=i,this._source=this._name=t,!this.refCounts||this._name in this.refCounts||(this.refCounts[this._name]=0)}clone(){const e=new this.constructor;return e.debugName="clone_"+this.debugName,e._source=this._source,e._name="clone_"+this._name,e.type=this.type,e.refCounts=this.refCounts,e.refCounts[e._name]=0,e}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(e){this._source=e}}var da,pa,ha,ma,ga,ya="RawCode",ba="Literal",va="Property",xa="Identifier",Aa="ArrayExpression",wa="BinaryExpression",Ca="CallExpression",Fa="ConditionalExpression",Ea="LogicalExpression",Da="MemberExpression",Sa="ObjectExpression",ka="UnaryExpression";function Oa(e){this.type=e}Oa.prototype.visit=function(e){var t,n,i;if(e(this))return 1;for(n=0,i=(t=function(e){switch(e.type){case Aa:return e.elements;case wa:case Ea:return[e.left,e.right];case Ca:var t=e.arguments.slice();return t.unshift(e.callee),t;case Fa:return[e.test,e.consequent,e.alternate];case Da:return[e.object,e.property];case Sa:return e.properties;case va:return[e.key,e.value];case ka:return[e.argument];case xa:case ba:case ya:default:return[]}}(this)).length;n",da[Na]="Identifier",da[ja]="Keyword",da[_a]="Null",da[Ta]="Numeric",da[za]="Punctuator",da[Ra]="String",da[9]="RegularExpression";var Pa="ArrayExpression",Ua="BinaryExpression",Ma="CallExpression",La="ConditionalExpression",Ia="Identifier",qa="Literal",Wa="LogicalExpression",Ha="MemberExpression",Ga="ObjectExpression",Ya="Property",Va="UnaryExpression",Qa="Unexpected token %0",Xa="Unexpected number",Ja="Unexpected string",Za="Unexpected identifier",Ka="Unexpected reserved word",es="Unexpected end of input",ts="Invalid regular expression",ns="Invalid regular expression: missing /",is="Octal literals are not allowed in strict mode.",rs="Duplicate data property in object literal not allowed in strict mode",os="ILLEGAL",as="Disabled.",ss=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),us=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function cs(e,t){if(!e)throw new Error("ASSERT: "+t)}function ls(e){return e>=48&&e<=57}function fs(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function ds(e){return"01234567".indexOf(e)>=0}function ps(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0}function hs(e){return 10===e||13===e||8232===e||8233===e}function ms(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||92===e||e>=128&&ss.test(String.fromCharCode(e))}function gs(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&us.test(String.fromCharCode(e))}var ys={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1};function bs(){for(var e;ha1114111||"}"!==e)&&Ts({},Qa,os),t<=65535?String.fromCharCode(t):(n=55296+(t-65536>>10),i=56320+(t-65536&1023),String.fromCharCode(n,i))}function As(){var e,t;for(e=pa.charCodeAt(ha++),t=String.fromCharCode(e),92===e&&(117!==pa.charCodeAt(ha)&&Ts({},Qa,os),++ha,(e=vs("u"))&&"\\"!==e&&ms(e.charCodeAt(0))||Ts({},Qa,os),t=e);ha>>="===(i=pa.substr(ha,4))?{type:za,value:i,start:r,end:ha+=4}:">>>"===(n=i.substr(0,3))||"<<="===n||">>="===n?{type:za,value:n,start:r,end:ha+=3}:a===(t=n.substr(0,2))[1]&&"+-<>&|".indexOf(a)>=0||"=>"===t?{type:za,value:t,start:r,end:ha+=2}:"<>=!+-*%&|^/".indexOf(a)>=0?{type:za,value:a,start:r,end:++ha}:void Ts({},Qa,os)}function Fs(){var e,t,n;if(cs(ls((n=pa[ha]).charCodeAt(0))||"."===n,"Numeric literal must start with a decimal digit or a decimal point"),t=ha,e="","."!==n){if(e=pa[ha++],n=pa[ha],"0"===e){if("x"===n||"X"===n)return++ha,function(e){for(var t="";ha=0&&Ts({},ts,n),{value:n,literal:t}}(),i=function(e,t){var n=e;t.indexOf("u")>=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}/g,function(e,t){if(parseInt(t,16)<=1114111)return"x";Ts({},ts)}).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{return new RegExp(e,t)}catch(e){return null}}(t.value,n.value),{literal:t.literal+n.literal,value:i,regex:{pattern:t.value,flags:n.value},start:e,end:ha}}function Ds(){var e;return bs(),ha>=ma?{type:Ba,start:ha,end:ha}:ms(e=pa.charCodeAt(ha))?ws():40===e||41===e||59===e?Cs():39===e||34===e?function(){var e,t,n,i,r="",o=!1;for(cs("'"===(e=pa[ha])||'"'===e,"String literal must starts with a quote"),t=ha,++ha;ha=0&&ha":case"<=":case">=":case"instanceof":case"in":t=7;break;case"<<":case">>":case">>>":t=8;break;case"+":case"-":t=9;break;case"*":case"/":case"%":t=11}return t}function Zs(){var e,t;return e=function(){var e,t,n,i,r,o,a,s,u,c;if(e=ga,u=Xs(),0===(r=Js(i=ga)))return u;for(i.prec=r,Ss(),t=[e,ga],o=[u,i,a=Xs()];(r=Js(ga))>0;){for(;o.length>2&&r<=o[o.length-2].prec;)a=o.pop(),s=o.pop().value,u=o.pop(),t.pop(),n=Os(s,u,a),o.push(n);(i=Ss()).prec=r,o.push(i),t.push(ga),n=Xs(),o.push(n)}for(n=o[c=o.length-1],t.pop();c>1;)t.pop(),n=Os(o[c-1].value,o[c-2],n),c-=2;return n}(),Ps("?")&&(Ss(),t=Zs(),Rs(":"),e=function(e,t,n){var i=new Oa(La);return i.test=e,i.consequent=t,i.alternate=n,i}(e,t,Zs())),e}function Ks(){var e=Zs();if(Ps(","))throw new Error(as);return e}function eu(e){const t=function(e){ha=0,ma=(pa=e).length,ga=null,ks();var t=Ks();if(ga.type!==Ba)throw new Error("Unexpect token after expression.");return t}(e),n=new Set;return t.visit(e=>{"MemberExpression"===e.type&&function e(t){return"MemberExpression"===t.object.type?e(t.object):"datum"===t.object.name}(e)&&n.add(function e(t){const n=[];return"Identifier"===t.type?[t.name]:"Literal"===t.type?[t.value]:("MemberExpression"===t.type&&(n.push(...e(t.object)),n.push(...e(t.property))),n)}(e).slice(1).join("."))}),n}class tu extends la{constructor(e,t){super(e),this.transform=t,this._dependentFields=eu(this.transform.calculate)}clone(){return new tu(null,B(this.transform))}static parseAllForSortIndex(e,t){return t.forEachFieldDef((t,n)=>{if(Dn(t)&&Uo(t.sort)){const{field:i,timeUnit:r}=t,o=t.sort,a=o.map((e,t)=>`${ao({field:i,timeUnit:r,equal:e})} ? ${t} : `).join("")+o.length;e=new tu(e,{calculate:a,as:nu(t,n,{forAs:!0})})}}),e}producedFields(){return new Set([this.transform.as])}dependentFields(){return this._dependentFields}assemble(){return{type:"formula",expr:this.transform.calculate,as:this.transform.as}}hash(){return`Calculate ${T(this.transform)}`}}function nu(e,t,n){return $n(e,Object.assign({prefix:t,suffix:"sort_index"},n||{}))}function iu(e,t){return R(["top","bottom"],t)?"column":R(["left","right"],t)?"row":"row"===e?"row":"column"}function ru(e,t,n,i){const r="row"===i?n.headerRow:"column"===i?n.headerColumn:n.headerFacet;return se(t&&t.header?t.header[e]:void 0,r[e],n.header[e])}function ou(e,t,n,i){const r={};for(const o of e){const e=ru(o,t,n,i);void 0!==e&&(r[o]=e)}return r}const au=["row","column"],su=["header","footer"];function uu(e,t){const n=e.component.layoutHeaders[t].title,i=e.config?e.config:void 0,r=e.component.layoutHeaders[t].facetFieldDef?e.component.layoutHeaders[t].facetFieldDef:void 0,{titleAnchor:o,titleAngle:a,titleOrient:s}=ou(["titleAnchor","titleAngle","titleOrient"],r,i,t),u=iu(t,s);return{name:`${t}-title`,type:"group",role:`${u}-title`,title:Object.assign({text:n},"row"===t?{orient:"left"}:{},{style:"guide-title"},lu(a,u),cu(u,a,o),yu(i,r,t,To,jo))}}function cu(e,t,n="middle"){switch(n){case"start":return{align:"left"};case"end":return{align:"right"}}const i=Ho(t,"row"===e?"left":"top");return i?{align:i}:{}}function lu(e,t){const n=Wo(e,"row"===t?"left":"top");return n?{baseline:n}:{}}function fu(e,t){const n=e.component.layoutHeaders[t],i=[];for(const r of su)if(n[r])for(const o of n[r])i.push(hu(e,t,r,n,o));return i}function du(e,t){const{sort:n}=e;return Po(n)?{field:$n(n,{expr:"datum"}),order:n.order||"ascending"}:o(n)?{field:nu(e,t,{expr:"datum"}),order:"ascending"}:{field:$n(e,{expr:"datum"}),order:n||"ascending"}}function pu(e,t,n){const{format:i,labelAngle:r,labelAnchor:o,labelOrient:a}=ou(["format","labelAngle","labelAnchor","labelOrient"],e,n,t),s=iu(t,a);return Object.assign({text:ea(e,i,"parent",n)},"row"===t?{orient:"left"}:{},{style:"guide-label",frame:"group"},lu(r,s),cu(s,r,o),yu(n,e,t,zo,_o))}function hu(e,t,n,i,r){if(r){let o=null;const{facetFieldDef:a}=i,s=e.config?e.config:void 0;if(a&&r.labels){const{labelOrient:e}=ou(["labelOrient"],a,s,t);("row"===t&&!R(["top","bottom"],e)||"column"===t&&!R(["left","right"],e))&&(o=pu(a,t,s))}const u=Rf(e)&&!en(e.facet),c=r.axes,l=c&&c.length>0;if(o||l){const s="row"===t?"height":"width";return Object.assign({name:e.getName(`${t}_${n}`),type:"group",role:`${t}-${n}`},i.facetFieldDef?{from:{data:e.getName(t+"_domain")},sort:du(a,t)}:{},l&&u?{from:{data:e.getName(`facet_domain_${t}`)}}:{},o?{title:o}:{},r.sizeSignal?{encode:{update:{[s]:r.sizeSignal}}}:{},l?{axes:c}:{})}}return null}const mu={column:{start:0,end:1},row:{start:1,end:0}};function gu(e,t){return mu[t][e]}function yu(e,t,n,i,r){const o={};for(const a of i){if(!r[a])continue;const i=ru(a,t,e,n);void 0!==i&&(o[r[a]]=i)}return o}function bu(e){return[...vu(e,"width"),...vu(e,"height")]}function vu(e,t){const n="width"===t?"x":"y",i=e.component.layoutSize.get(t);if(!i||"merged"===i)return[];const r=e.getSizeSignalRef(t).signal;if("range-step"===i){const t=e.getScaleComponent(n);if(t){const i=t.get("type"),o=t.get("range");if(Qi(i)&&Co(o)){const i=e.scaleName(n);if(Rf(e.parent)){if("independent"===e.parent.component.resolve.scale[n])return[xu(i,o)]}return[xu(i,o),{name:r,update:Au(i,t,`domain('${i}').length`)}]}}throw new Error("layout size is range step although there is no rangeStep.")}return[{name:r,value:i}]}function xu(e,t){return{name:e+"_step",value:t.step}}function Au(e,t,n){const i=t.get("type"),r=t.get("padding"),o=se(t.get("paddingOuter"),r);let a=t.get("paddingInner");return`bandspace(${n}, ${a="band"===i?void 0!==a?a:r:1}, ${o}) * ${e}_step`}function wu(e,t,n){return Cu=t||Eu,Fu=n||Tu,Ru(e.trim()).map(Pu)}var Cu,Fu,Eu="view",Du="[",Su="]",ku="{",Ou="}",$u=":",Bu=",",Nu="@",ju=">",_u=/[[\]{}]/,Tu={"*":1,arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1};function zu(e,t,n,i,r){for(var o,a=0,s=e.length;t=0?--a:i&&i.indexOf(o)>=0&&++a}return t}function Ru(e){for(var t=[],n=0,i=e.length,r=0;r' after between selector: "+e;if(t=t.map(Pu),(n=Pu(e.slice(1).trim())).between)return{between:t,stream:n};n.between=t;return n}(e):function(e){var t,n,i={source:Cu},r=[],o=[0,0],a=0,s=0,u=e.length,c=0;if(e[u-1]===Ou){if(!((c=e.lastIndexOf(ku))>=0))throw"Unmatched right brace: "+e;try{o=function(e){var t=e.split(Bu);if(!e.length||t.length>2)throw e;return t.map(function(t){var n=+t;if(n!=n)throw e;return n})}(e.substring(c+1,u-1))}catch(t){throw"Invalid throttle specification: "+e}e=e.slice(0,c).trim(),u=e.length,c=0}if(!u)throw e;e[0]===Nu&&(a=++c);(t=zu(e,c,$u))1?(i.type=r[1],a?i.markname=r[0].slice(1):!function(e){return Fu.hasOwnProperty(e)}(r[0])?i.source=r[0]:i.marktype=r[0]):i.type=r[0];"!"===i.type.slice(-1)&&(i.consume=!0,i.type=i.type.slice(0,-1));null!=n&&(i.filter=n);o[0]&&(i.throttle=o[0]);o[1]&&(i.debounce=o[1]);return i}(e)}class Uu extends la{constructor(e,t){super(e),this.formula=t}clone(){return new Uu(null,B(this.formula))}static makeFromEncoding(e,t){const n=t.reduceFieldDef((e,t)=>{if(t.timeUnit){const n=$n(t,{forAs:!0});e[n]={as:n,timeUnit:t.timeUnit,field:t.field}}return e},{});return 0===V(n).length?null:new Uu(e,n)}static makeFromTransform(e,t){return new Uu(e,{[t.field]:{as:t.as,timeUnit:t.timeUnit,field:t.field}})}merge(e){this.formula=Object.assign({},this.formula,e.formula),e.remove()}producedFields(){return new Set(Q(this.formula).map(e=>e.as))}dependentFields(){return new Set(Q(this.formula).map(e=>e.field))}hash(){return`TimeUnit ${T(this.formula)}`}assemble(){return Q(this.formula).map(e=>({type:"formula",as:e.as,expr:ln(e.timeUnit,e.field)}))}}const Mu={has:e=>"interval"===e.type&&"global"===e.resolve&&e.bind&&"scales"===e.bind,parse:(e,t,n)=>{const i=Z(n.name),r=n.scales=[];for(const t of n.project.items){const n=t.channel;if(!Tt(n))continue;const o=e.getScaleComponent(n),a=o?o.get("type"):void 0;if(o&&Xi(a)){if(o.set("domainRaw",{signal:ne(t.field,i)},!0),r.push(t),e.repeater&&e.repeater.row===e.repeater.column){e.getScaleComponent(n===We?He:We).set("domainRaw",{signal:ne(t.field,i)},!0)}}else Ht(Pt.SCALE_BINDINGS_CONTINUOUS)}},topLevelSignals:(e,t,n)=>{const i=t.scales.filter(e=>!n.filter(t=>t.name===e.signals.data).length);if(!e.parent||!i.length)return n;const r=n.filter(e=>e.name===t.name)[0],o=r.update;if(o.indexOf(ec)>=0)r.update=`{${i.map(e=>`${u(e.field)}: ${e.signals.data}`).join(", ")}}`;else for(const e of i){const t=`, ${u(e.field)}: ${e.signals.data}`;o.indexOf(t)<0&&(r.update=o.substring(0,o.length-1)+t+"}")}return n.concat(i.map(e=>({name:e.signals.data})))},signals:(e,t,n)=>{if(e.parent)for(const e of t.scales){const t=n.filter(t=>t.name===e.signals.data)[0];t.push="outer",delete t.value,delete t.update}return n}};function Lu(e,t){return`domain(${u(e.scaleName(t))})`}const Iu="_tuple_fields";class qu{constructor(...e){this.items=e,this.has={}}}const Wu="_scale_trigger",Hu={signals:(e,t)=>{const n=t.name,i=n+Iu,r=Mu.has(t),o=[],a=[],s=[];if(t.translate&&!r){const e=`!event.item || event.item.mark.name !== ${u(n+"_brush")}`;Gu(t,(t,n)=>{const i=n.between[0].filter||(n.between[0].filter=[]);i.indexOf(e)<0&&i.push(e)})}t.project.items.forEach((n,i)=>{const r=n.channel;if(r!==We&&r!==He)return void Ht("Interval selections only support x and y encoding channels.");const c=t.init?t.init[i]:null,l=function(e,t,n,i){const r=n.channel,o=n.signals.visual,a=n.signals.data,s=Mu.has(t),c=u(e.scaleName(r)),l=e.getScaleComponent(r),f=l?l.get("type"):void 0,d=e=>`scale(${c}, ${e})`,p=e.getSizeSignalRef(r===We?"width":"height").signal,h=`${r}(unit)`,m=Gu(t,(e,t)=>[...e,{events:t.between[0],update:`[${h}, ${h}]`},{events:t,update:`[${o}[0], clamp(${h}, 0, ${p})]`}]);return m.push({events:{signal:t.name+Wu},update:Xi(f)?`[${d(`${a}[0]`)}, ${d(`${a}[1]`)}]`:"[0, 0]"}),s?[{name:a,on:[]}]:[Object.assign({name:o},i?{init:vc(i,d)}:{value:[]},{on:m}),Object.assign({name:a},i?{init:vc(i)}:{},{on:[{events:{signal:o},update:`${o}[0] === ${o}[1] ? null : invert(${c}, ${o})`}]})]}(e,t,n,c),f=n.signals.data,d=n.signals.visual,p=u(e.scaleName(r)),h=Xi(e.getScaleComponent(r).get("type"))?"+":"";o.push(...l),a.push(f),s.push({scaleName:e.scaleName(r),expr:`(!isArray(${f}) || `+`(${h}invert(${p}, ${d})[0] === ${h}${f}[0] && `+`${h}invert(${p}, ${d})[1] === ${h}${f}[1]))`})}),r||o.push({name:n+Wu,value:{},on:[{events:s.map(e=>({scale:e.scaleName})),update:s.map(e=>e.expr).join(" && ")+` ? ${n+Wu} : {}`}]});const c=t.init,l=`unit: ${ic(e)}, fields: ${i}, values`;return o.concat(Object.assign({name:n+Ju},c?{init:`{${l}: ${vc(c)}}`}:{},{on:[{events:[{signal:a.join(" || ")}],update:a.join(" && ")+` ? {${l}: [${a}]} : null`}]}))},modifyExpr:(e,t)=>{return t.name+Ju+", "+("global"===t.resolve?"true":`{unit: ${ic(e)}}`)},marks:(e,t,n)=>{const i=t.name,{x:r,y:o}=t.project.has,a=r&&r.signals.visual,s=o&&o.signals.visual,c=`data(${u(t.name+Xu)})`;if(Mu.has(t))return n;const l={x:void 0!==r?{signal:`${a}[0]`}:{value:0},y:void 0!==o?{signal:`${s}[0]`}:{value:0},x2:void 0!==r?{signal:`${a}[1]`}:{field:{group:"width"}},y2:void 0!==o?{signal:`${s}[1]`}:{field:{group:"height"}}};if("global"===t.resolve)for(const t of V(l))l[t]=[Object.assign({test:`${c}.length && ${c}[0].unit === ${ic(e)}`},l[t]),{value:0}];const f=t.mark,{fill:d,fillOpacity:p}=f,h=Ne(f,["fill","fillOpacity"]),m=V(h).reduce((e,t)=>(e[t]=[{test:[void 0!==r&&`${a}[0] !== ${a}[1]`,void 0!==o&&`${s}[0] !== ${s}[1]`].filter(e=>e).join(" && "),value:h[t]},{value:null}],e),{});return[{name:i+"_brush_bg",type:"rect",clip:!0,encode:{enter:{fill:{value:d},fillOpacity:{value:p}},update:l}},...n,{name:i+"_brush",type:"rect",clip:!0,encode:{enter:{fill:{value:"transparent"}},update:Object.assign({},l,m)}}]}};function Gu(e,t){return e.events.reduce((e,n)=>n.between?t(e,n):(Ht(`${n} is not an ordered event stream for interval selections`),e),[])}function Yu(e,t){const n=t.name,i=n+Iu,r=t.project,o="(item().isVoronoi ? datum.datum : datum)",a=r.items.map(t=>{const n=e.fieldDef(t.channel);return n&&n.bin?`[${ne(e.vgField(t.channel,{}),o)}, `+`${ne(e.vgField(t.channel,{binSuffix:"end"}),o)}]`:`${ne(t.field,o)}`}).join(", "),s=`unit: ${ic(e)}, fields: ${i}, values`,c=[{name:n+Ju,on:[{events:t.events,update:`datum && item().mark.marktype !== 'group' ? {${s}: [${a}]} : null`,force:!0}]}];if(t.init){const e=t.init.map(e=>{const t=vc(e);return`{${s}: ${t}}`});c.push({name:`${n}_init`,init:`modify(${u(t.name+Xu)}, [${e}])`})}return c}const Vu={signals:Yu,modifyExpr:(e,t)=>{return t.name+Ju+", "+("global"===t.resolve?"null":`{unit: ${ic(e)}}`)}},Qu={signals:Yu,modifyExpr:(e,t)=>{return t.name+Ju+", "+("global"===t.resolve?"true":`{unit: ${ic(e)}}`)}},Xu="_store",Ju="_tuple",Zu="_modify",Ku="_selection_domain_",ec="vlSelectionResolve",tc={single:Qu,multi:Vu,interval:Hu};function nc(e,t){const n=e.component.selection;for(const e in n)if(n.hasOwnProperty(e)){const i=n[e];t(i,tc[i.type])}}function ic(e){let t=u(e.name);const n=function(e){let t=e.parent;for(;t&&!Rf(t);)t=t.parent;return t}(e);if(n){const{facet:e}=n;for(const i of bt)e[i]&&(t+=` + '__facet_${i}_' + (${ne(n.vgField(i),"facet")})`)}return t}function rc(e){let t=!1;return nc(e,e=>{t=t||e.project.items.some(e=>e.field===sr)}),t}const oc={has:e=>"interval"!==e.type&&e.nearest,marks:(e,t,n)=>{const{x:i,y:r}=t.project.has,o=e.mark;if(Ee(o))return Ht(Pt.nearestNotSupportForContinuous(o)),n;const a={name:e.getName("voronoi"),type:"path",from:{data:e.getName("marks")},encode:{update:Object.assign({fill:{value:"transparent"},strokeWidth:{value:.35},stroke:{value:"transparent"},isVoronoi:{value:!0}},Vc(e,{reactiveGeom:!0}))},transform:[{type:"voronoi",x:{expr:i||!i&&!r?"datum.datum.x || 0":"0"},y:{expr:r||!i&&!r?"datum.datum.y || 0":"0"},size:[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]}]};let s=0,u=!1;return n.forEach((t,n)=>{const i=t.name||"";i===e.component.mark[0].name?s=n:i.indexOf("voronoi")>=0&&(u=!0)}),u||n.splice(s+1,0,a),n}},ac={has:e=>"single"===e.type&&"global"===e.resolve&&e.bind&&"scales"!==e.bind,topLevelSignals:(e,t,n)=>{const i=t.name,r=t.project,o=t.bind,a=t.init&&t.init[0],s=oc.has(t)?"(item().isVoronoi ? datum.datum : datum)":"datum";return r.items.forEach((e,r)=>{const u=Z(`${i}_${e.field}`);n.filter(e=>e.name===u).length||n.unshift(Object.assign({name:u},a?{init:vc(a[r])}:{value:null},{on:[{events:t.events,update:`datum && item().mark.marktype !== 'group' ? ${ne(e.field,s)} : null`}],bind:o[e.field]||o[e.channel]||o}))}),n},signals:(e,t,n)=>{const i=t.name,r=t.project,o=n.filter(e=>e.name===i+Ju)[0],a=i+Iu,s=r.items.map(e=>Z(`${i}_${e.field}`)),u=s.map(e=>`${e} !== null`).join(" && ");return s.length&&(o.update=`${u} ? {fields: ${a}, values: [${s.join(", ")}]} : null`),delete o.value,delete o.on,n}},sc={has:e=>"multi"===e.type&&e.toggle,signals:(e,t,n)=>n.concat({name:t.name+"_toggle",value:!1,on:[{events:t.events,update:t.toggle}]}),modifyExpr:(e,t)=>{const n=t.name+Ju,i=t.name+"_toggle";return`${i} ? null : ${n}, `+("global"===t.resolve?`${i} ? null : true, `:`${i} ? null : {unit: ${ic(e)}}, `)+`${i} ? ${n} : null`}},uc={has:e=>!1!==e.clear,parse:(e,t,n)=>{t.clear&&(n.clear=wu(t.clear,"scope"))},topLevelSignals:(e,t,n)=>(ac.has(t)&&t.project.items.forEach(e=>{const i=n.findIndex(n=>n.name===Z(`${t.name}_${e.field}`));-1!==i&&n[i].on.push({events:t.clear,update:"null"})}),n),signals:(e,t,n)=>{function i(e,i){-1!==e&&n[e].on&&n[e].on.push({events:t.clear,update:i})}if("interval"===t.type)t.project.items.forEach(e=>{const t=n.findIndex(t=>t.name===e.signals.visual);if(i(t,"[0, 0]"),-1===t){i(n.findIndex(t=>t.name===e.signals.data),"null")}});else{let e=n.findIndex(e=>e.name===t.name+Ju);i(e,"null"),sc.has(t)&&i(e=n.findIndex(e=>e.name===t.name+"_toggle"),"false")}return n}},cc="_translate_anchor",lc="_translate_delta",fc={has:e=>"interval"===e.type&&e.translate,signals:(e,t,n)=>{const i=t.name,r=Mu.has(t),o=i+cc,{x:a,y:s}=t.project.has;let u=wu(t.translate,"scope");return r||(u=u.map(e=>(e.between[0].markname=i+"_brush",e))),n.push({name:o,value:{},on:[{events:u.map(e=>e.between[0]),update:"{x: x(unit), y: y(unit)"+(void 0!==a?", extent_x: "+(r?Lu(e,We):`slice(${a.signals.visual})`):"")+(void 0!==s?", extent_y: "+(r?Lu(e,He):`slice(${s.signals.visual})`):"")+"}"}]},{name:i+lc,value:{},on:[{events:u,update:`{x: ${o}.x - x(unit), y: ${o}.y - y(unit)}`}]}),void 0!==a&&dc(e,t,a,"width",n),void 0!==s&&dc(e,t,s,"height",n),n}};function dc(e,t,n,i,r){const o=t.name,a=o+cc,s=o+lc,u=n.channel,c=Mu.has(t),l=r.filter(e=>e.name===n.signals[c?"data":"visual"])[0],f=e.getSizeSignalRef(i).signal,d=e.getScaleComponent(u),p=d.get("type"),h=`${a}.extent_${u}`,m=`${c?"log"===p?"panLog":"pow"===p?"panPow":"panLinear":"panLinear"}(${h}, ${`${c&&u===We?"-":""}${s}.${u} / `+(c?`${f}`:`span(${h})`)}`+(c&&"pow"===p?`, ${d.get("exponent")||1}`:"")+")";l.on.push({events:{signal:s},update:c?m:`clampRange(${m}, 0, ${f})`})}const pc="_zoom_anchor",hc="_zoom_delta",mc={has:e=>"interval"===e.type&&e.zoom,signals:(e,t,n)=>{const i=t.name,r=Mu.has(t),o=i+hc,{x:a,y:s}=t.project.has,c=u(e.scaleName(We)),l=u(e.scaleName(He));let f=wu(t.zoom,"scope");return r||(f=f.map(e=>(e.markname=i+"_brush",e))),n.push({name:i+pc,on:[{events:f,update:r?"{"+[c?`x: invert(${c}, x(unit))`:"",l?`y: invert(${l}, y(unit))`:""].filter(e=>!!e).join(", ")+"}":"{x: x(unit), y: y(unit)}"}]},{name:o,on:[{events:f,force:!0,update:"pow(1.001, event.deltaY * pow(16, event.deltaMode))"}]}),void 0!==a&&gc(e,t,a,"width",n),void 0!==s&&gc(e,t,s,"height",n),n}};function gc(e,t,n,i,r){const o=t.name,a=n.channel,s=Mu.has(t),u=r.filter(e=>e.name===n.signals[s?"data":"visual"])[0],c=e.getSizeSignalRef(i).signal,l=e.getScaleComponent(a),f=l.get("type"),d=s?Lu(e,a):u.name,p=o+hc,h=`${s?"log"===f?"zoomLog":"pow"===f?"zoomPow":"zoomLinear":"zoomLinear"}(${d}, ${`${o}${pc}.${a}`}, ${p}`+(s&&"pow"===f?`, ${l.get("exponent")||1}`:"")+")";u.on.push({events:{signal:p},update:s?h:`clampRange(${h}, 0, ${c})`})}const yc=[{has:()=>!0,parse:(e,t,n)=>{const i=n.name,r=n.project||(n.project=new qu),a={},s={},u=new Set,c=(e,t)=>{const n="visual"===t?e.channel:e.field;let r=Z(`${i}_${n}`);for(let e=1;u.has(r);e++)r=Z(`${i}_${n}_${e}`);return u.add(r),{[t]:r}};if(!t.fields&&!t.encodings){const n=e.config.selection[t.type];if(t.init)for(const e of y(t.init))for(const i of V(e))wt(i)?(t.encodings||(t.encodings=[])).push(i):ur(t)?(Ht('Interval selections should be initialized using "x" and/or "y" keys.'),t.encodings=n.encodings):(t.fields||(t.fields=[])).push(i);else t.encodings=n.encodings,t.fields=n.fields}for(const e of t.fields||[]){const t={type:"E",field:e};t.signals=Object.assign({},c(t,"data")),r.items.push(t)}for(const i of t.encodings||[]){const t=e.fieldDef(i);if(t){let o=t.field;if(t.timeUnit&&(s[o=e.vgField(i)]={as:o,field:t.field,timeUnit:t.timeUnit}),!a[o]){let s="E";if("interval"===n.type){Xi(e.getScaleComponent(i).get("type"))&&(s="R")}else t.bin&&(s="R-RE");const u={field:o,channel:i,type:s};u.signals=Object.assign({},c(u,"data"),c(u,"visual")),r.items.push(a[o]=u),r.has[i]=a[o]}}else Ht(Pt.cannotProjectOnChannelWithoutField(i))}if(t.init)if(Mu.has(n))Ht(Pt.NO_INIT_SCALE_BINDINGS);else{const e=e=>r.items.map(t=>void 0!==e[t.channel]?e[t.channel]:e[t.field]);if(ur(t))n.init=e(t.init);else{const i=o(t.init)?t.init:[t.init];n.init=i.map(e)}}V(s).length&&(r.timeUnit=new Uu(null,s))},signals:(e,t,n)=>{const i=t.name+Iu;return n.filter(e=>e.name===i).length?n:n.concat({name:i,value:t.project.items.map(e=>{return Ne(e,["signals"])})})}},sc,Mu,fc,mc,ac,oc,uc];function bc(e,t){for(const n of yc)n.has(e)&&t(n)}function vc(e,t=l){if(o(e)){return`[${e.map(e=>vc(e,t)).join(", ")}]`}return Vt(e)?t(Kt(e)):t(JSON.stringify(e))}function xc(e,t){return nc(e,(n,i)=>{t=i.marks?i.marks(e,n,t):t,bc(n,i=>{i.marks&&(t=i.marks(e,n,t))})}),t}function Ac(e,t,n){const i=[];const r=K(t,function(t){const r=Z(t),o=e.getSelectionComponent(r,t),a=u(r+Xu);if(o.project.timeUnit){const t=n||e.component.data.raw,i=o.project.timeUnit.clone();t.parent?i.insertAsParentOf(t):t.parent=i}return"none"!==o.empty&&i.push(a),`vlSelectionTest(${a}, datum`+("global"===o.resolve?")":`, ${u(o.resolve)})`)});return(i.length?"!("+i.map(e=>`length(data(${e}))`).join(" || ")+") || ":"")+`(${r})`}function wc(e,t,n){return K(t,t=>s(t)?t:function(e){return e&&e.selection}(t)?Ac(e,t.selection,n):ao(t))}function Cc(e){const{channel:t,channelDef:n,mark:i,scale:r}=e,o=_c(e);return wn(n)&&!Pe(n.aggregate)&&r&&Ji(r.get("type"))&&!1===r.get("zero")?Fc({fieldDef:n,channel:t,mark:i,ref:o}):o}function Fc({fieldDef:e,channel:t,mark:n,ref:i}){return Ee(n)?i:[Ec(e,t),i]}function Ec(e,t){const n=Dc(e,!0),i="x"===Dt(t)?{value:0}:{field:{group:"height"}};return Object.assign({test:n},i)}function Dc(e,t=!0){return`${e=s(e)?e:$n(e,{expr:"datum"})} ${t?"===":"!=="} null ${t?"||":"&&"} ${t?"":"!"}isNaN(${e})`}function Sc(e){const{channel:t,channelDef:n,scaleName:i,stack:r,offset:o}=e;return wn(n)&&r&&t===r.fieldChannel?Bc(n,i,{suffix:"end"},{offset:o}):Cc(e)}function kc({channel:e,channelDef:t,channel2Def:n,scaleName:i,scale:r,stack:o,mark:a,offset:s,defaultRef:u}){return wn(t)&&o&&e.charAt(0)===o.fieldChannel.charAt(0)?Bc(t,i,{suffix:"start"},{offset:s}):Cc({channel:e,channelDef:n,scaleName:i,scale:r,stack:o,mark:a,offset:s,defaultRef:u})}function Oc(e,t){const n=t[e+"Offset"];if(n)return n}function $c({channel:e,fieldDef:t,scaleName:n,mark:i,side:r,offset:o}){return Fc({fieldDef:t,channel:e,mark:i,ref:Bc(t,n,{binSuffix:"start"===r?void 0:"end"},o?{offset:o}:{})})}function Bc(e,t,n,i){const r=Object.assign({},t?{scale:t}:{},{field:$n(e,n)});if(i){const{offset:e,band:t}=i;return Object.assign({},r,e?{offset:e}:{},t?{band:t}:{})}return r}function Nc(e,t=!0){return{scale:e,band:t}}function jc({scaleName:e,fieldDef:t,fieldDef2:n,offset:i}){const r=$n(t,{expr:"datum"}),o=void 0!==n?$n(n,{expr:"datum"}):$n(t,{binSuffix:"end",expr:"datum"});return Object.assign({signal:`scale("${e}", (${r} + ${o}) / 2)`},i?{offset:i}:{})}function _c({channel:e,channelDef:t,channel2Def:n,scaleName:i,scale:r,stack:o,offset:a,defaultRef:s}){if(t){if(wn(t)){if(Cn(t)){if(Xn(t.bin))return R([We,He],e)&&t.type===hn?o&&o.impute?Bc(t,i,{binSuffix:"mid"},{offset:a}):jc({scaleName:i,fieldDef:t,offset:a}):Bc(t,i,Vn(t,e)?{binSuffix:"range"}:{},{offset:a});if(Jn(t.bin)){if(wn(n))return jc({scaleName:i,fieldDef:t,fieldDef2:n,offset:a});{const t=e===We?Ge:Ye;Ht(Pt.channelRequiredForBinned(t))}}}if(r){const e=r.get("type");if(Qi(e))return Bc(t,i,{binSuffix:"range"},"band"===e?{band:.5,offset:a}:{offset:a})}return Bc(t,i,{},{offset:a})}if(En(t)){const n=t.value,i=a?{offset:a}:{};return R(["x","x2"],e)&&"width"===n?Object.assign({field:{group:"width"}},i):R(["y","y2"],e)&&"height"===n?Object.assign({field:{group:"height"}},i):Object.assign({value:n},i)}}return function(e){return"function"==typeof e}(s)?s():s}function Tc(e,t,{reactiveGeom:n}){const i=[],r={};function o(o,a){const s=Dt(a);a!==s&&(o=Object.assign({},o,{type:e[s].type}));const c=zn(o,t,{allowDisabling:!1}),l=zc(o,t,n?"datum.datum":"datum").signal;r[c]||i.push(`${u(c)}: ${l}`),r[c]=!0}return oi(e,(e,t)=>{wn(e)?o(e,t):An(e)&&o(e.condition,t)}),i.length?{signal:`{${i.join(", ")}}`}:void 0}function zc(e,t,n="datum"){if(e){if(En(e))return{value:e.value};if(Cn(e))return ea(e,On(i=e)&&i.format?i.format:(Rn(i)||{}).format,n,t)}var i}function Rc(e){return Object.assign({},e,{mult:.5})}function Pc({markDef:e,config:t,defaultRef:n,channel:i,scaleName:r,scale:o,mark:a,checkBarAreaWithoutZero:u}){return()=>{const c=Dt(i),l=se(e[i],Zo(i,e,t));if(void 0!==l)return{value:l};if(s(n)){if(r){const e=o.get("type");if(R([Pi.LOG,Pi.TIME,Pi.UTC],e))!u||"bar"!==a&&"area"!==a||Ht(Pt.nonZeroScaleUsedWithLengthMark(a,c,{scaleType:e}));else{if(o.domainDefinitelyIncludesZero)return{scale:r,value:0};!u||"bar"!==a&&"area"!==a||Ht(Pt.nonZeroScaleUsedWithLengthMark(a,c,{zeroFalse:!1===o.explicit.zero}))}}return"zeroOrMin"===n?"x"===c?{value:0}:{field:{group:"height"}}:"x"===c?{field:{group:"width"}}:{value:0}}return n}}function Uc(e){return"transparent"!==e&&null!=e}function Mc(e){const{markDef:t,encoding:n,config:i}=e,{filled:r,type:o}=t,a={fill:Zo("fill",t,i),stroke:Zo("stroke",t,i),color:Zo("color",t,i)},s=R(["bar","point","circle","square","geoshape"],o)?"transparent":void 0,u=se(t.fill,a.fill,s),c=se(t.stroke,a.stroke),l=r?"fill":"stroke",f=Object.assign({},u?{fill:{value:u}}:{},c?{stroke:{value:c}}:{});return n.fill||n.stroke?(t.color&&Ht(Pt.droppingColor("property",{fill:"fill"in n,stroke:"stroke"in n})),Object.assign({},Gc("fill",e,{defaultValue:se(u,s)}),Gc("stroke",e,{defaultValue:c}))):n.color?Object.assign({},f,Gc("color",e,{vgChannel:l,defaultValue:se(t[l],t.color,a[l],a.color,r?s:void 0)})):Uc(t.fill)||Uc(t.stroke)?(t.color&&Ht(Pt.droppingColor("property",{fill:"fill"in t,stroke:"stroke"in t})),f):t.color?Object.assign({},f,{[l]:{value:t.color}}):Uc(a.fill)||Uc(a.stroke)?f:a.color?Object.assign({},s?{fill:{value:"transparent"}}:{},{[l]:{value:a.color}}):{}}function Lc(e,t){const{fill:n,stroke:i}=Mc(e);return Object.assign({},function(e,t){return Eo.reduce((n,i)=>(void 0!==e[i]&&"ignore"!==t[i]&&(n[i]={value:e[i]}),n),{})}(e.markDef,t),Ic(e,"fill",n),Ic(e,"stroke",i),Gc("opacity",e),Gc("fillOpacity",e),Gc("strokeOpacity",e),Gc("strokeWidth",e),Vc(e),Qc(e,"href"))}function Ic(e,t,n){const{config:i,mark:r}=e;if("hide"===i.invalidValues&&n&&!Ee(r)){const i=Wc(e,{invalid:!0,channels:_t});if(i)return{[t]:[{test:i,value:null},...y(n)]}}return n?{[t]:n}:{}}function qc(e,t){if(void 0!==t)return{[e]:{value:t}}}function Wc(e,{invalid:t=!1,channels:n}){const i=n.reduce((t,n)=>{const i=e.getScaleComponent(n);if(i){const r=i.get("type"),o=e.vgField(n,{expr:"datum"});o&&Xi(r)&&(t[o]=!0)}return t},{}),r=V(i);if(r.length>0){const e=t?"||":"&&";return r.map(e=>Dc(e,t)).join(` ${e} `)}}function Hc(e){if(e.config.invalidValues){const t=Wc(e,{channels:["x","y"]});if(t)return{defined:{signal:t}}}return{}}function Gc(e,t,n={}){const{markDef:i,encoding:r,config:o}=t,{vgChannel:a=e}=n;let{defaultRef:s,defaultValue:u}=n;void 0===s&&(u=u||(a===e?i[e]:se(i[e],i[a],Zo(e,i,o,{vgChannel:a}))),s=u?{value:u}:void 0);const c=r[e];return Yc(t,c,a,n=>_c({channel:e,channelDef:n,scaleName:t.scaleName(e),scale:t.getScaleComponent(e),stack:null,defaultRef:s}))}function Yc(e,t,n,i){const r=t&&t.condition,a=i(t);if(r){return{[n]:[...(o(r)?r:[r]).map(t=>{const n=i(t),r=function(e){return e.selection}(t)?Ac(e,t.selection):wc(e,t.test);return Object.assign({test:r},n)}),...void 0!==a?[a]:[]]}}return void 0!==a?{[n]:a}:{}}function Vc(e,t={}){const{encoding:n,markDef:i,config:r}=e,u=n.tooltip;return o(u)?{tooltip:Tc({tooltip:u},r,t)}:Yc(e,u,"tooltip",o=>{const u=zc(o,e.config,t.reactiveGeom?"datum.datum":"datum");if(u)return u;if(null===o)return;const c=se(i.tooltip,Zo("tooltip",i,r));return s(c)?{value:c}:a(c)?"encoding"===c.content?Tc(n,r,t):{signal:"datum"}:void 0})}function Qc(e,t="text"){const n=e.encoding[t];return Yc(e,n,t,t=>zc(t,e.config))}function Xc(e,t,n,i){const r=n.scaleName(t),o="x"===t?"width":"height";if(n.encoding.size||void 0!==n.markDef.size||i&&void 0!==i.value){if(n.markDef.orient){const a={[t+"c"]:Bc(e,r,{},{band:.5})};if(Mn(n.encoding.size))return Object.assign({},a,Gc("size",n,{vgChannel:o}));if(En(n.encoding.size))return Object.assign({},a,Gc("size",n,{vgChannel:o}));if(void 0!==n.markDef.size)return Object.assign({},a,{[o]:{value:n.markDef.size}});if(i&&void 0!==i.value)return Object.assign({},a,{[o]:i})}else Ht(Pt.cannotApplySizeToNonOrientedMark(n.markDef.type))}return{[t]:Bc(e,r,{binSuffix:"range"},{}),[o]:i||Nc(r)}}function Jc(e,t,n,i){const r="x"===e?"xc":"yc",o="x"===e?"width":"height";return Object.assign({},Kc(e,t,n,r),Gc("size",t,{defaultRef:i,vgChannel:o}))}function Zc({fieldDef:e,fieldDef2:t,channel:n,scaleName:i,mark:r,spacing:o=0,reverse:a}){const s={x:a?o:0,x2:a?0:o,y:a?0:o,y2:a?o:0},u=n===We?Ge:Ye;return Xn(e.bin)?{[u]:$c({channel:n,fieldDef:e,scaleName:i,mark:r,side:"start",offset:s[`${n}2`]}),[n]:$c({channel:n,fieldDef:e,scaleName:i,mark:r,side:"end",offset:s[n]})}:Jn(e.bin)&&wn(t)?{[u]:Bc(e,i,{},{offset:s[`${n}2`]}),[n]:Bc(t,i,{},{offset:s[n]})}:void Ht(Pt.channelRequiredForBinned(u))}function Kc(e,t,n,i){const{encoding:r,mark:o,markDef:a,config:s,stack:u}=t,c=r[e],l=r[e===We?Ge:Ye],f=t.scaleName(e),d=t.getScaleComponent(e),p=Oc(e,t.markDef);return{[i||e]:c||!r.latitude&&!r.longitude?Sc({channel:e,channelDef:c,channel2Def:l,scaleName:f,scale:d,stack:u,mark:o,offset:p,defaultRef:Pc({markDef:a,config:s,defaultRef:n,channel:e,scaleName:f,scale:d,mark:o,checkBarAreaWithoutZero:!l})}):{field:t.getName(e)}}}function el(e,t,n){const{encoding:i,mark:r,markDef:o,stack:a,config:s}=e,u="x2"===n?"x":"y",c=i[u],l=e.scaleName(u),f=e.getScaleComponent(u),d=Oc(n,e.markDef);return{[n]:c||!i.latitude&&!i.longitude?kc({channel:n,channelDef:c,channel2Def:i[n],scaleName:l,scale:f,stack:a,mark:r,offset:d,defaultRef:Pc({markDef:o,config:s,defaultRef:t,channel:n,scaleName:l,scale:f,mark:r,checkBarAreaWithoutZero:!i[n]})}):{field:e.getName(n)}}}function tl(e,t){return V(e).reduce((n,i)=>{const r=e[i];return Object.assign({},n,Yc(t,r,i,e=>({value:e.value})))},{})}function nl(e,t){if(Mf(t)||Rf(t))return"shared";if(Uf(t)||Pf(t))return R($t,e)?"independent":"shared";throw new Error("invalid model type for resolve")}function il(e,t){const n=e.scale[t],i=R($t,t)?"axis":"legend";return"independent"===n?("shared"===e[i][t]&&Ht(Pt.independentScaleMeansIndependentGuide(t)),"independent"):e[i][t]||"shared"}class rl{constructor(e={},t={}){this.explicit=e,this.implicit=t}clone(){return new rl(B(this.explicit),B(this.implicit))}combine(){return Object.assign({},this.explicit,this.implicit)}get(e){return se(this.explicit[e],this.implicit[e])}getWithExplicit(e){return void 0!==this.explicit[e]?{explicit:!0,value:this.explicit[e]}:void 0!==this.implicit[e]?{explicit:!1,value:this.implicit[e]}:{explicit:!1,value:void 0}}setWithExplicit(e,t){void 0!==t.value&&this.set(e,t.value,t.explicit)}set(e,t,n){return delete this[n?"implicit":"explicit"][e],this[n?"explicit":"implicit"][e]=t,this}copyKeyFromSplit(e,t){void 0!==t.explicit[e]?this.set(e,t.explicit[e],!0):void 0!==t.implicit[e]&&this.set(e,t.implicit[e],!1)}copyKeyFromObject(e,t){void 0!==t[e]&&this.set(e,t[e],!0)}copyAll(e){for(const t of V(e.combine())){const n=e.getWithExplicit(t);this.setWithExplicit(t,n)}}}function ol(e){return{explicit:!0,value:e}}function al(e){return{explicit:!1,value:e}}function sl(e){return(t,n,i,r)=>{const o=e(t.value,n.value);return o>0?t:o<0?n:ul(t,n,i,r)}}function ul(e,t,n,i){return e.explicit&&t.explicit&&Ht(Pt.mergeConflictingProperty(n,i,e.value,t.value)),e}function cl(e,t,n,i,r=ul){return void 0===e||void 0===e.value?t:e.explicit&&!t.explicit?e:t.explicit&&!e.explicit?t:_(e.value)===_(t.value)?e:r(e,t,n,i)}class ll extends rl{}function fl(e,t){const n=e.values;if(n)return Yn(t,n)}function dl(e){return"line"===e?"stroke":"circle"}function pl(e){const{legend:t}=e;return se(t.type,hl(e))}function hl({channel:e,timeUnit:t,scaleType:n,alwaysReturn:i}){if(gt(e)){if(R(["quarter","month","day"],t))return"symbol";if(Ji(n))return i?"gradient":void 0}return i?"symbol":void 0}function ml({legend:e,legendConfig:t,timeUnit:n,channel:i,scaleType:r}){const o=se(e.orient,t.orient,"right"),a=pl({legend:e,channel:i,timeUnit:n,scaleType:r,alwaysReturn:!0});return se(e.direction,t[a?"gradientDirection":"symbolDirection"],function(e,t){switch(e){case"top":case"bottom":return"horizontal";case"left":case"right":case"none":case void 0:return;default:return"gradient"===t?"horizontal":void 0}}(o,a))}function gl({legend:e,legendConfig:t,model:n,channel:i,scaleType:r}){const{gradientHorizontalMaxLength:o,gradientHorizontalMinLength:a,gradientVerticalMaxLength:s,gradientVerticalMinLength:u}=t;if("horizontal"===ml({legend:e,legendConfig:t,channel:i,scaleType:r})){const i=se(e.orient,t.orient);return"top"===i||"bottom"===i?yl(n,"width",a,o):a}return yl(n,"height",u,s)}function yl(e,t,n,i){return{signal:`clamp(${e.getSizeSignalRef(t).signal}, ${n}, ${i})`}}function bl(e){if(R(["quantile","threshold","log"],e))return"greedy"}function vl(e,t,n){const i=t.getScaleComponent(n).get("type");return se(e.get("type"),hl({channel:n,scaleType:i,alwaysReturn:!0}))}function xl(e){return wl(e,(e,t)=>Math.max(e,t.value))}function Al(e){return wl(e,(e,t)=>se(e,t.value))}function wl(e,t){return function(e){return!!e&&!!e.condition&&(o(e.condition)||En(e.condition))}(e)?(o(e.condition)?e.condition:[e.condition]).reduce(t,e.value):En(e)?e.value:void 0}var Cl=Object.freeze({symbols:function(e,t,n,i,r){if("symbol"!==vl(r,n,i))return;let a=Object.assign({},function(e,t,n){for(const i of n){const n=Zo(i,t.markDef,t.config);void 0!==n&&(e[i]={value:n})}return e}({},n,ke),Mc(n));switch(n.mark){case he:case xe:case ve:a.shape={value:"square"};break;case we:case Ce:a.shape={value:n.mark}}const{markDef:s,encoding:u,config:c}=n,l=s.filled,f=xl(u.opacity)||s.opacity;if(a.fill)if("fill"===i||l&&i===Ze)delete a.fill;else if(a.fill.field)r.get("symbolFillColor")?delete a.fill:(a.fill={value:c.legend.symbolBaseFillColor||"black"},a.fillOpacity={value:f||1});else if(o(a.fill)){const e=Al(u.fill||u.color)||s.fill||l&&s.color;e&&(a.fill={value:e})}if(a.stroke)if("stroke"===i||!l&&i===Ze)delete a.stroke;else if(a.stroke.field)delete a.stroke;else if(o(a.stroke)){const e=se(Al(u.stroke||u.color),s.stroke,l?s.color:void 0);e&&(a.stroke={value:e})}if(i!==tt){const e=Al(u.shape)||s.shape;e&&(a.shape={value:e})}return i!==it&&f&&(a.opacity={value:f}),a=Object.assign({},a,t),V(a).length>0?a:void 0},gradient:function(e,t,n,i,r){if("gradient"!==vl(r,n,i))return;let o={};const a=xl(n.encoding.opacity)||n.markDef.opacity;return a&&(o.opacity={value:a}),o=Object.assign({},o,t),V(o).length>0?o:void 0},labels:function(e,t,n,i){const r=n.legend(i),o=n.config;let a={};if(Hn(e)){const a=n.getScaleComponent(i).get("type")===Pi.UTC,s=oa("datum.value",e.timeUnit,r.format,o.legend.shortTimeLabels,o.timeFormat,a);t=Object.assign({},s?{text:{signal:s}}:{},t)}return a=Object.assign({},a,t),V(a).length>0?a:void 0}});function Fl(e){zf(e)?e.component.legends=function(e){const{encoding:t}=e;return[Ze,Ke,et,at,nt,tt,it,rt,ot].reduce((n,i)=>{const r=t[i];return!e.legend(i)||!e.getScaleComponent(i)||wn(r)&&i===tt&&r.type===bn||(n[i]=function(e,t){const n=e.fieldDef(t),i=e.legend(t),r=new ll({},function(e,t){const n=e.scaleName(Ze);if("color"===t)return e.markDef.filled?{fill:n}:{stroke:n};return{[t]:e.scaleName(t)}}(e,t));for(const o of zi){const a=Dl(o,i,t,e);if(void 0!==a){const t=El(a,o,i,n);(t||void 0===e.config.legend[o])&&r.set(o,a,t)}}const o=i.encoding||{},a=["labels","legend","title","symbols","gradient"].reduce((i,a)=>{const s=tl(o[a]||{},e),u=Cl[a]?Cl[a](n,s,e,t,r):s;return void 0!==u&&V(u).length>0&&(i[a]={update:u}),i},{});V(a).length>0&&r.set("encode",a,!!i.encoding);return r}(e,i)),n},{})}(e):e.component.legends=function(e){const{legends:t,resolve:n}=e.component;for(const i of e.children)Fl(i),V(i.component.legends).forEach(r=>{n.legend[r]=il(e.component.resolve,r),"shared"===n.legend[r]&&(t[r]=Sl(t[r],i.component.legends[r]),t[r]||(n.legend[r]="independent",delete t[r]))});return V(t).forEach(t=>{for(const i of e.children)i.component.legends[t]&&"shared"===n.legend[t]&&delete i.component.legends[t]}),t}(e)}function El(e,t,n,i){switch(t){case"values":return!!n.values;case"title":if("title"===t&&e===i.title)return!0}return e===n[t]}function Dl(e,t,n,i){const{encoding:r,mark:o}=i,a=Mn(r[n]),s=i.config.legend,{timeUnit:u}=a,c=i.getScaleComponent(n).get("type");switch(e){case"direction":return ml({legend:t,legendConfig:s,timeUnit:u,channel:n,scaleType:c});case"format":if(Hn(a))return;return ta(a,t.format,i.config);case"formatType":if(Hn(a))return;return t.formatType;case"gradientLength":return se(t.gradientLength,s.gradientLength,gl({model:i,legend:t,legendConfig:s,channel:n,scaleType:c}));case"labelOverlap":return se(t.labelOverlap,bl(c));case"symbolType":return se(t.symbolType,dl(o));case"title":return zn(a,i.config,{allowDisabling:!0})||void 0;case"type":return pl({legend:t,channel:n,timeUnit:u,scaleType:c,alwaysReturn:!1});case"values":return fl(t,a)}return t[e]}function Sl(e,t){if(!e)return t.clone();const n=e.getWithExplicit("orient"),i=t.getWithExplicit("orient");if(n.explicit&&i.explicit&&n.value!==i.value)return;let r=!1;for(const n of Ri){const i=cl(e.getWithExplicit(n),t.getWithExplicit(n),n,"legend",(e,t)=>{switch(n){case"symbolType":return kl(e,t);case"title":return ca(e,t);case"type":return r=!0,al("symbol")}return ul(e,t,n,"legend")});e.setWithExplicit(n,i)}return r&&(((e.implicit||{}).encode||{}).gradient&&ee(e.implicit,["encode","gradient"]),((e.explicit||{}).encode||{}).gradient&&ee(e.explicit,["encode","gradient"])),e}function kl(e,t){return"circle"===t.value?t:e}function Ol(e){const t=e.component.legends,n={};for(const i of V(t)){const r=e.getScaleComponent(i),o=_(r.domains);if(n[o])for(const e of n[o]){Sl(e,t[i])||n[o].push(t[i])}else n[o]=[t[i].clone()]}return M(Q(n)).map(e=>{const t=e.combine();if(t.encode&&t.encode.symbols){const e=t.encode.symbols.update;!e.fill||"transparent"===e.fill.value||e.stroke||t.stroke||(e.stroke={value:"transparent"}),t.fill&&delete e.fill}return t})}function $l(e){return Mf(e)||Uf(e)||Pf(e)?function(e){return e.children.reduce((e,t)=>e.concat(t.assembleProjections()),Bl(e))}(e):Bl(e)}function Bl(e){const t=e.component.projection;if(!t||t.merged)return[];const n=t.combine(),{name:i}=n,r=Ne(n,["name"]);if(t.data){const n={signal:`[${t.size.map(e=>e.signal).join(", ")}]`},o=t.data.reduce((t,n)=>{const i=wo(n)?n.signal:`data('${e.lookupDataSource(n)}')`;return R(t,i)||t.push(i),t},[]);if(o.length<=0)throw new Error("Projection's fit didn't find any data sources");return[Object.assign({name:i,size:n,fit:{signal:o.length>1?`[${o.join(", ")}]`:o[0]}},r)]}return[Object.assign({name:i},{translate:{signal:"[width / 2, height / 2]"}},r)]}const Nl=["type","clipAngle","clipExtent","center","rotate","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];class jl extends rl{constructor(e,t,n,i){super(Object.assign({},t),{name:e}),this.specifiedProjection=t,this.size=n,this.data=i,this.merged=!1}get isFit(){return!!this.data}}function _l(e){e.component.projection=zf(e)?function(e){if(e.hasProjection){const t=e.specifiedProjection,n=!(t&&(null!=t.scale||null!=t.translate)),i=n?[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]:void 0,r=n?function(e){const t=[];[[Qe,Ve],[Je,Xe]].forEach(n=>{(e.channelHasField(n[0])||e.channelHasField(n[1]))&&t.push({signal:e.getName(`geojson_${t.length}`)})}),e.channelHasField(tt)&&e.fieldDef(tt).type===bn&&t.push({signal:e.getName(`geojson_${t.length}`)});0===t.length&&t.push(e.requestDataName(Qr));return t}(e):void 0;return new jl(e.projectionName(!0),Object.assign({},e.config.projection||{},t||{}),i,r)}return}(e):function(e){if(0===e.children.length)return;let t;e.children.forEach(e=>_l(e));const n=U(e.children,e=>{const n=e.component.projection;if(n){if(t){const e=function(e,t){const n=U(Nl,n=>!e.explicit.hasOwnProperty(n)&&!t.explicit.hasOwnProperty(n)||!(!e.explicit.hasOwnProperty(n)||!t.explicit.hasOwnProperty(n)||_(e.get(n))!==_(t.get(n))));if(_(e.size)===_(t.size)){if(n)return e;if(_(e.explicit)===_({}))return t;if(_(t.explicit)===_({}))return e}return null}(t,n);return e&&(t=e),!!e}return t=n,!0}return!0});if(t&&n){const n=e.projectionName(!0),i=new jl(n,t.specifiedProjection,t.size,B(t.data));return e.children.forEach(e=>{const t=e.component.projection;t&&(t.isFit&&i.data.push(...e.component.projection.data),e.renameProjection(t.get("name"),n),t.merged=!0)}),i}return}(e)}class Tl extends la{constructor(e){let t;if(super(null),Hr(e=e||{name:"source"})||(t=e.format?Object.assign({},j(e.format,["parse"])):{}),qr(e))this._data={values:e.values};else if(Ir(e)){if(this._data={url:e.url},!t.type){let n=/(?:\.([^.]+))?$/.exec(e.url)[1];R(["json","csv","tsv","dsv","topojson"],n)||(n="json"),t.type=n}}else Yr(e)?this._data={values:[{type:"Sphere"}]}:(Wr(e)||Hr(e))&&(this._data={});this._generator=Hr(e),e.name&&(this._name=e.name),t&&V(t).length>0&&(this._data.format=t)}get data(){return this._data}hasName(){return!!this._name}get isGenerator(){return this._generator}get dataName(){return this._name}set dataName(e){this._name=e}set parent(e){throw new Error("Source nodes have to be roots.")}remove(){throw new Error("Source nodes are roots and cannot be removed.")}hash(){throw new Error("Cannot hash sources")}assemble(){return Object.assign({name:this._name},this._data,{transform:[]})}}function zl(e){for(const t of e){for(const e of t.children)if(e.parent!==t)return console.error("Dataflow graph is inconsistent.",t,e),!1;if(!zl(t.children))return!1}return!0}class Rl{constructor(){this._mutated=!1}setMutated(){this._mutated=!0}get mutatedFlag(){return this._mutated}}class Pl extends Rl{constructor(){super(),this._continue=!1}setContinue(){this._continue=!0}get continueFlag(){return this._continue}get flags(){return{continueFlag:this.continueFlag,mutatedFlag:this.mutatedFlag}}set flags({continueFlag:e,mutatedFlag:t}){e&&this.setContinue(),t&&this.setMutated()}reset(){}optimizeNextFromLeaves(e){if(e instanceof Tl)return!1;const t=e.parent,{continueFlag:n}=this.run(e);return n&&this.optimizeNextFromLeaves(t),this.mutatedFlag}}class Ul extends Rl{}function Ml(e,t,n,i){if(Cn(n)&&Xn(n.bin))e.add($n(n,{})),e.add($n(n,{binSuffix:"end"})),Vn(n,t)&&e.add($n(n,{binSuffix:"range"}));else if(function(e){switch(e){case Ve:case Xe:case Qe:case Je:return!0}return!1}(t)){const n=function(e){switch(e){case Ve:return"y";case Xe:return"y2";case Qe:return"x";case Je:return"x2"}}(t);e.add(i.getName(n))}else e.add($n(n));return e}class Ll extends la{constructor(e,t,n){super(e),this.dimensions=t,this.measures=n}clone(){return new Ll(null,new Set(this.dimensions),B(this.measures))}get groupBy(){return this.dimensions}static makeFromEncoding(e,t){let n=!1;t.forEachFieldDef(e=>{e.aggregate&&(n=!0)});const i={},r=new Set;return n?(t.forEachFieldDef((e,n)=>{const{aggregate:o,field:a}=e;if(o)if("count"===o)i["*"]=i["*"]||{},i["*"].count=new Set([$n(e,{forAs:!0})]);else{if(_e(o)||Te(o)){const e=_e(o)?"argmin":"argmax",t=o[e];i[t]=i[t]||{},i[t][e]=new Set([$n({op:e,field:t},{forAs:!0})])}else i[a]=i[a]||{},i[a][o]=new Set([$n(e,{forAs:!0})]);Tt(n)&&"unaggregated"===t.scaleDomain(n)&&(i[a]=i[a]||{},i[a].min=new Set([$n({field:a,aggregate:"min"},{forAs:!0})]),i[a].max=new Set([$n({field:a,aggregate:"max"},{forAs:!0})]))}else Ml(r,n,e,t)}),r.size+V(i).length===0?null:new Ll(e,r,i)):null}static makeFromTransform(e,t){const n=new Set,i={};for(const e of t.aggregate){const{op:t,field:n,as:r}=e;t&&("count"===t?(i["*"]=i["*"]||{},i["*"].count=new Set([r||$n(e,{forAs:!0})])):(i[n]=i[n]||{},i[n][t]=new Set([r||$n(e,{forAs:!0})])))}for(const e of t.groupby||[])n.add(e);return n.size+V(i).length===0?null:new Ll(e,n,i)}merge(e){return W(this.dimensions,e.dimensions)?(function(e,t){for(const n of V(t)){const i=t[n];for(const t of V(i))n in e?e[n][t]=new Set([...e[n][t]||[],...i[t]]):e[n]={[t]:i[t]}}}(this.measures,e.measures),!0):(Gt("different dimensions, cannot merge"),!1)}addDimensions(e){e.forEach(this.dimensions.add,this.dimensions)}dependentFields(){return new Set([...this.dimensions,...V(this.measures)])}producedFields(){const e=new Set;for(const t of V(this.measures))for(const n of V(this.measures[t])){const i=this.measures[t][n];0===i.size?e.add(`${n}_${t}`):i.forEach(e.add,e)}return e}hash(){return`Aggregate ${T({dimensions:this.dimensions,measures:this.measures})}`}assemble(){const e=[],t=[],n=[];for(const i of V(this.measures))for(const r of V(this.measures[i]))for(const o of this.measures[i][r])n.push(o),e.push(r),t.push("*"===i?null:re(i));return{type:"aggregate",groupby:[...this.dimensions],ops:e,fields:t,as:n}}}function Il(e,t,n){let i;i=function(e){return"as"in e}(e)?s(e.as)?[e.as,`${e.as}_end`]:[e.as[0],e.as[1]]:[$n(e,{forAs:!0}),$n(e,{binSuffix:"end",forAs:!0})];const r=qn(t,void 0)||{},o=function(e,t){return`${Qn(e)}_${t}`}(r,e.field),{signal:a,extentSignal:u}=function(e,t){return{signal:e.getName(`${t}_bins`),extentSignal:e.getName(`${t}_extent`)}}(n,o);return{key:o,binComponent:Object.assign({bin:r,field:e.field,as:[i]},a?{signal:a}:{},u?{extentSignal:u}:{})}}class ql extends la{constructor(e,t){super(e),this.bins=t}clone(){return new ql(null,B(this.bins))}static makeFromEncoding(e,t){const n=t.reduceFieldDef((e,n,i)=>{if(Cn(n)&&Xn(n.bin)){const{key:r,binComponent:o}=Il(n,n.bin,t);e[r]=Object.assign({},o,e[r],function(e,t,n,i){if(Vn(t,n)){const r=zf(e)&&(e.axis(n)||e.legend(n))||{},o=$n(t,{expr:"datum"}),a=$n(t,{expr:"datum",binSuffix:"end"});return{formulaAs:$n(t,{binSuffix:"range",forAs:!0}),formula:ra(o,a,r.format,i)}}return{}}(t,n,i,t.config))}return e},{});return 0===V(n).length?null:new ql(e,n)}static makeFromTransform(e,t,n){const{key:i,binComponent:r}=Il(t,t.bin,n);return new ql(e,{[i]:r})}merge(e,t){for(const n of V(e.bins))n in this.bins?(t(e.bins[n].signal,this.bins[n].signal),this.bins[n].as=q([...this.bins[n].as,...e.bins[n].as],T)):this.bins[n]=e.bins[n];for(const t of e.children)e.removeChild(t),t.parent=this;e.remove()}producedFields(){return new Set(M(M(Q(this.bins).map(e=>e.as))))}dependentFields(){return new Set(Q(this.bins).map(e=>e.field))}hash(){return`Bin ${T(this.bins)}`}assemble(){return M(Q(this.bins).map(e=>{const t=[],[n,...i]=e.as,r=Object.assign({type:"bin",field:e.field,as:n,signal:e.signal},e.bin);!e.bin.extent&&e.extentSignal&&(t.push({type:"extent",field:e.field,signal:e.extentSignal}),r.extent={signal:e.extentSignal}),t.push(r);for(const e of i)for(let i=0;i<2;i++)t.push({type:"formula",expr:$n({field:n[i]},{expr:"datum"}),as:e[i]});return e.formula&&t.push({type:"formula",expr:e.formula,as:e.formulaAs}),t}))}}class Wl extends la{constructor(e,t,n,i){super(e),this.model=t,this.name=n,this.data=i;for(const e of bt){const n=t.facet[e];if(n){const{bin:i,sort:r}=n;this[e]=Object.assign({name:t.getName(`${e}_domain`),fields:[$n(n),...Xn(i)?[$n(n,{binSuffix:"end"})]:[]]},Po(r)?{sortField:r}:o(r)?{sortIndexField:nu(n,e)}:{})}}this.childModel=t.child}hash(){let e="Facet";for(const t of bt)this[t]&&(e+=` ${t.charAt(0)}:${T(this[t])}`);return e}get fields(){const e=[];for(const t of bt)this[t]&&this[t].fields&&e.push(...this[t].fields);return e}getSource(){return this.name}getChildIndependentFieldsWithStep(){const e={};for(const t of["x","y"]){const n=this.childModel.component.scales[t];if(n&&!n.merged){const i=n.get("type"),r=n.get("range");if(Qi(i)&&Co(r)){const n=bf(vf(this.childModel,t));n?e[t]=n:Ht("Unknown field for ${channel}. Cannot calculate view size.")}}}return e}assembleRowColumnHeaderData(e,t,n){const i={row:"y",column:"x"}[e],r=[],o=[],a=[];n&&n[i]&&(t?(r.push(`distinct_${n[i]}`),o.push("max")):(r.push(n[i]),o.push("distinct")),a.push(`distinct_${n[i]}`));const{sortField:s,sortIndexField:u}=this[e];if(s){const{op:e=Ro,field:t}=s;r.push(t),o.push(e),a.push($n(s,{forAs:!0}))}else u&&(r.push(u),o.push("max"),a.push(u));return{name:this[e].name,source:t||this.data,transform:[Object.assign({type:"aggregate",groupby:this[e].fields},r.length?{fields:r,ops:o,as:a}:{})]}}assembleFacetHeaderData(e){const{columns:t}=this.model.layout,{layoutHeaders:n}=this.model.component,i=[],r={};for(const e of au){for(const t of su){const i=n[e]&&n[e][t]||[];for(const t of i)if(t.axes&&t.axes.length>0){r[e]=!0;break}}if(r[e]){const n=`length(data("${this.facet.name}"))`,r="row"===e?t?{signal:`ceil(${n} / ${t})`}:1:t?{signal:`min(${n}, ${t})`}:{signal:n};i.push({name:`${this.facet.name}_${e}`,transform:[{type:"sequence",start:0,stop:r}]})}}const{row:o,column:a}=r;return(o||a)&&i.unshift(this.assembleRowColumnHeaderData("facet",null,e)),i}assemble(){const e=[];let t=null;const n=this.getChildIndependentFieldsWithStep(),{column:i,row:r,facet:o}=this;if(i&&r&&(n.x||n.y)){t=`cross_${this.column.name}_${this.row.name}`;const i=[].concat(n.x||[],n.y||[]),r=i.map(()=>"distinct");e.push({name:t,source:this.data,transform:[{type:"aggregate",groupby:this.fields,fields:i,ops:r}]})}for(const i of[Ie,Le])this[i]&&e.push(this.assembleRowColumnHeaderData(i,t,n));if(o){const t=this.assembleFacetHeaderData(n);t&&e.push(...t)}return e}}class Hl extends la{constructor(e,t,n){super(e),this.model=t,this.filter=n,this.expr=wc(this.model,this.filter,this),this._dependentFields=eu(this.expr)}clone(){return new Hl(null,this.model,B(this.filter))}dependentFields(){return this._dependentFields}assemble(){return{type:"filter",expr:this.expr}}hash(){return`Filter ${this.expr}`}}function Gl(e){return"'"===e[0]&&"'"===e[e.length-1]||'"'===e[0]&&'"'===e[e.length-1]?e.slice(1,-1):e}class Yl extends la{clone(){return new Yl(null,B(this._parse))}constructor(e,t){super(e),this._parse=t}hash(){return`Parse ${T(this._parse)}`}static makeExplicit(e,t,n){let i={};const r=t.data;return!Hr(r)&&r&&r.format&&r.format.parse&&(i=r.format.parse),this.makeWithAncestors(e,i,{},n)}static makeImplicitFromFilterTransform(e,t,n){const i={};return function e(t,n){if(k(t))e(t.not,n);else if(S(t))for(const i of t.and)e(i,n);else if(D(t))for(const i of t.or)e(i,n);else n(t)}(t.filter,e=>{if(ro(e)){let t=null;Jr(e)?t=e.equal:no(e)?t=e.range[0]:io(e)&&(t=(e.oneOf||e.in)[0]),t&&(Vt(t)?i[e.field]="date":v(t)?i[e.field]="number":s(t)&&(i[e.field]="string")),e.timeUnit&&(i[e.field]="date")}}),0===V(i).length?null:this.makeWithAncestors(e,{},i,n)}static makeImplicitFromEncoding(e,t,n){const i={};function r(e){var t;Hn(e)?i[e.field]="date":function(e){return"quantitative"===e.type||Xn(e.bin)}(e)&&((t=e.aggregate)&&s(t)&&R(["min","max"],t))?i[e.field]="number":ae(e.field)>1?e.field in i||(i[e.field]="flatten"):Dn(e)&&Po(e.sort)&&ae(e.sort.field)>1&&(e.sort.field in i||(i[e.sort.field]="flatten"))}return(zf(t)||Rf(t))&&t.forEachFieldDef((e,n)=>{if(Cn(e))r(e);else{const i=Dt(n);if(i===n)throw new Error(`Non-secondary channel ${n} must have type in its field definition ${JSON.stringify(e)}`);{const n=t.fieldDef(i);r(Object.assign({},e,{type:n.type}))}}}),this.makeWithAncestors(e,{},i,n)}static makeWithAncestors(e,t,n,i){for(const e of V(n)){const t=i.getWithExplicit(e);void 0!==t.value&&(t.explicit||t.value===n[e]||"derived"===t.value||"flatten"===n[e]?delete n[e]:Ht(Pt.differentParse(e,n[e],t.value)))}for(const e of V(t)){const n=i.get(e);void 0!==n&&(n===t[e]?delete t[e]:Ht(Pt.differentParse(e,t[e],n)))}const r=new rl(t,n);i.copyAll(r);const o={};for(const e of V(r.combine())){const t=r.get(e);null!==t&&(o[e]=t)}return 0===V(o).length||i.parseNothing?null:new Yl(e,o)}get parse(){return this._parse}merge(e){this._parse=Object.assign({},this._parse,e.parse),e.remove()}assembleFormatParse(){const e={};for(const t of V(this._parse)){const n=this._parse[t];1===ae(t)&&(e[t]=n)}return e}producedFields(){return new Set(V(this._parse))}dependentFields(){return new Set(V(this._parse))}assembleTransforms(e=!1){return V(this._parse).filter(t=>!e||ae(t)>1).map(e=>{const t=function(e,t){const n=ne(e);if("number"===t)return`toNumber(${n})`;if("boolean"===t)return`toBoolean(${n})`;if("string"===t)return`toString(${n})`;if("date"===t)return`toDate(${n})`;if("flatten"===t)return n;if(0===t.indexOf("date:"))return`timeParse(${n},'${Gl(t.slice(5,t.length))}')`;if(0===t.indexOf("utc:"))return`utcParse(${n},'${Gl(t.slice(4,t.length))}')`;return Ht(Pt.unrecognizedParse(t)),null}(e,this._parse[e]);return t?{type:"formula",expr:t,as:oe(e)}:null}).filter(e=>null!==e)}}class Vl extends la{constructor(e,t){super(e),this.transform=t}clone(){return new Vl(null,B(this.transform))}addDimensions(e){this.transform.groupby=q(this.transform.groupby.concat(e),e=>e)}dependentFields(){const e=new Set;return this.transform.groupby.forEach(t=>e.add(t)),this.transform.joinaggregate.map(e=>e.field).filter(e=>void 0!==e).forEach(t=>e.add(t)),e}producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName))}getDefaultName(e){return e.as||$n(e)}hash(){return`JoinAggregateTransform ${T(this.transform)}`}assemble(){const e=[],t=[],n=[];for(const i of this.transform.joinaggregate)t.push(i.op),n.push(this.getDefaultName(i)),e.push(void 0===i.field?null:i.field);const i=this.transform.groupby;return Object.assign({type:"joinaggregate",as:n,ops:t,fields:e},void 0!==i?{groupby:i}:{})}}class Ql extends la{clone(){return new Ql(null,B(this._stack))}constructor(e,t){super(e),this._stack=t}static makeFromTransform(e,t){const{stack:n,groupby:i,as:r,offset:a="zero"}=t,u=[],c=[];if(void 0!==t.sort)for(const e of t.sort)u.push(e.field),c.push(se(e.order,"ascending"));const l={field:u,order:c};let f;return f=function(e){return o(e)&&e.every(e=>s(e))&&e.length>1}(r)?r:s(r)?[r,r+"_end"]:[t.stack+"_start",t.stack+"_end"],new Ql(e,{stackField:n,groupby:i,offset:a,sort:l,facetby:[],as:f})}static makeFromEncoding(e,t){const n=t.stack,{encoding:i}=t;if(!n)return null;let r;if(n.groupbyChannel){r=Mn(i[n.groupbyChannel])}const a=function(e){return e.stack.stackBy.reduce((e,t)=>{const n=$n(t.fieldDef);return n&&e.push(n),e},[])}(t),s=t.encoding.order;let u;return u=o(s)||wn(s)?aa(s):a.reduce((e,t)=>(e.field.push(t),e.order.push("descending"),e),{field:[],order:[]}),new Ql(e,{dimensionFieldDef:r,stackField:t.vgField(n.fieldChannel),facetby:[],stackby:a,sort:u,offset:n.offset,impute:n.impute,as:[t.vgField(n.fieldChannel,{suffix:"start",forAs:!0}),t.vgField(n.fieldChannel,{suffix:"end",forAs:!0})]})}get stack(){return this._stack}addDimensions(e){this._stack.facetby.push(...e)}dependentFields(){const e=new Set;e.add(this._stack.stackField),this.getGroupbyFields().forEach(e.add),this._stack.facetby.forEach(e.add);const t=this._stack.sort.field;return o(t)?t.forEach(e.add):e.add(t),e}producedFields(){return new Set(this._stack.as)}hash(){return`Stack ${T(this._stack)}`}getGroupbyFields(){const{dimensionFieldDef:e,impute:t,groupby:n}=this._stack;return e?e.bin?t?[$n(e,{binSuffix:"mid"})]:[$n(e,{}),$n(e,{binSuffix:"end"})]:[$n(e)]:n||[]}assemble(){const e=[],{facetby:t,dimensionFieldDef:n,stackField:i,stackby:r,sort:o,offset:a,impute:s,as:u}=this._stack;return s&&n&&(n.bin&&e.push({type:"formula",expr:"("+$n(n,{expr:"datum"})+"+"+$n(n,{expr:"datum",binSuffix:"end"})+")/2",as:$n(n,{binSuffix:"mid",forAs:!0})}),e.push({type:"impute",field:i,groupby:[...r,...t],key:$n(n,{binSuffix:"mid"}),method:"value",value:0})),e.push({type:"stack",groupby:[...this.getGroupbyFields(),...t],field:i,sort:o,as:u,offset:a}),e}}class Xl extends la{constructor(e,t){super(e),this.transform=t}clone(){return new Xl(null,B(this.transform))}addDimensions(e){this.transform.groupby=q(this.transform.groupby.concat(e),e=>e)}dependentFields(){const e=new Set;return this.transform.groupby.forEach(t=>e.add(t)),this.transform.sort.forEach(t=>e.add(t.field)),this.transform.window.map(e=>e.field).filter(e=>void 0!==e).forEach(t=>e.add(t)),e}producedFields(){return new Set(this.transform.window.map(this.getDefaultName))}getDefaultName(e){return e.as||$n(e)}hash(){return`WindowTransform ${T(this.transform)}`}assemble(){const e=[],t=[],n=[],i=[];for(const r of this.transform.window)t.push(r.op),n.push(this.getDefaultName(r)),i.push(void 0===r.param?null:r.param),e.push(void 0===r.field?null:r.field);const r=this.transform.frame,o=this.transform.groupby;if(r&&null===r[0]&&null===r[1]&&t.every(e=>ze(e)))return Object.assign({type:"joinaggregate",as:n,ops:t,fields:e},void 0!==o?{groupby:o}:{});const a=[],s=[];if(void 0!==this.transform.sort)for(const e of this.transform.sort)a.push(e.field),s.push(e.order||"ascending");const u={field:a,order:s},c=this.transform.ignorePeers;return Object.assign({type:"window",params:i,as:n,ops:t,fields:e,sort:u},void 0!==c?{ignorePeers:c}:{},void 0!==o?{groupby:o}:{},void 0!==r?{frame:r}:{})}}class Jl extends Pl{run(e){const t=e.parent;if(e instanceof Yl){if(t instanceof Tl)return this.flags;if(t.numChildren()>1)return this.setContinue(),this.flags;if(t instanceof Yl)this.setMutated(),t.merge(e);else{if(Y(t.producedFields(),e.dependentFields()))return this.setContinue(),this.flags;this.setMutated(),e.swapWithParent()}}return this.setContinue(),this.flags}}class Zl extends Ul{mergeNodes(e,t){const n=t.shift();for(const i of t)e.removeChild(i),i.parent=n,i.remove()}run(e){const t=e.children.map(e=>e.hash()),n={};for(let i=0;i1&&(this.setMutated(),this.mergeNodes(e,n[t]));for(const t of e.children)this.run(t);return this.mutatedFlag}}class Kl extends Pl{run(e){return e instanceof fa||e.numChildren()>0||e instanceof Wl?this.flags:(this.setMutated(),e.remove(),this.flags)}}class ef extends Pl{constructor(){super(...arguments),this.fields=new Set}run(e){if(this.setContinue(),e instanceof Uu){const t=e.producedFields();H(t,this.fields)?(this.setMutated(),e.remove()):this.fields=new Set([...this.fields,...t])}return this.flags}reset(){this.fields.clear()}}function tf(e){if(e instanceof Wl)if(1!==e.numChildren()||e.children[0]instanceof fa){const n=e.model.component.data.main;!function e(t){if(t instanceof fa&&t.type===Qr&&1===t.numChildren()){const n=t.children[0];n instanceof Wl||(n.swapWithParent(),e(t))}}(n);const i=(t=e,function e(n){if(!(n instanceof Wl)){const i=n.clone();if(i instanceof fa){const e=sf+i.getSource();i.setSource(e),t.model.component.data.outputNodes[e]=i}else(i instanceof Ll||i instanceof Ql||i instanceof Xl||i instanceof Vl)&&i.addDimensions(t.fields);return M(n.children.map(e)).forEach(e=>e.parent=i),[i]}return M(n.children.map(e))}),r=M(e.children.map(i));for(const e of r)e.parent=n}else{const t=e.children[0];(t instanceof Ll||t instanceof Ql||t instanceof Xl||t instanceof Vl)&&t.addDimensions(e.fields),t.swapWithParent(),tf(e)}else e.children.map(tf);var t}class nf extends Ul{run(e){e instanceof fa&&!e.isRequired()&&(this.setMutated(),e.remove());for(const t of e.children)this.run(t);return this.mutatedFlag}}class rf extends Pl{run(e){const t=e.parent,n=t.children.filter(e=>e instanceof Yl);if(n.length>1){const e={};for(const t of n){const n=t.parse;for(const t of V(n))void 0===e[t]?e[t]=n[t]:e[t]!==n[t]&&delete e[t]}if(0!==V(e).length){this.setMutated();const i=new Yl(t,e);for(const r of n){for(const t of V(e))delete r.parse[t];t.removeChild(r),r.parent=i,0===V(r.parse).length&&r.remove()}}}return this.setContinue(),this.flags}}class of extends Pl{run(e){const t=e.parent,n=t.children.filter(e=>e instanceof Ll),i={};for(const e of n){const t=T(V(e.groupBy).sort());t in i||(i[t]=[]),i[t].push(e)}for(const e of V(i)){const n=i[e];if(n.length>1){const e=n.pop();for(const i of n)e.merge(i)&&(t.removeChild(i),i.parent=e,i.remove(),this.setMutated())}}return this.setContinue(),this.flags}}class af extends Pl{constructor(e){super(),this.model=e}run(e){const t=e.parent,n=!(t instanceof Tl||t instanceof Hl||t instanceof Yl),i=[],r=[];for(const e of t.children)e instanceof ql&&(n&&!Y(t.producedFields(),e.dependentFields())?i.push(e):r.push(e));if(i.length>0){const e=i.pop();for(const t of i)e.merge(t,this.model.renameSignal.bind(this.model));this.setMutated(),t instanceof ql?t.merge(e,this.model.renameSignal.bind(this.model)):e.swapWithParent()}if(r.length>1){const e=r.pop();for(const t of r)e.merge(t,this.model.renameSignal.bind(this.model));this.setMutated()}return this.setContinue(),this.flags}}const sf="scale_",uf=5;function cf(e){const t=[];return e.forEach(function e(n){0===n.numChildren()?t.push(n):n.children.forEach(e)}),t}function lf(e){return e}function ff(e,t,n){return t.map(t=>{if(e instanceof Pl){const n=e.optimizeNextFromLeaves(t);return e.reset(),n}return e.run(t)}).some(lf)||n}function df(e,t){let n=e.sources,i=!1;return i=ff(new nf,n,i),n=n.filter(e=>e.numChildren()>0),i=ff(new Kl,cf(n),i),n=n.filter(e=>e.numChildren()>0),i=ff(new Jl,cf(n),i),i=ff(new af(t),cf(n),i),i=ff(new ef,cf(n),i),i=ff(new rf,cf(n),i),i=ff(new of,cf(n),i),i=ff(new Zl,n,i),e.sources=n,i}class pf{constructor(e){Object.defineProperty(this,"signal",{enumerable:!0,get:e})}static fromName(e,t){return new pf(()=>e(t))}}function hf(e){zf(e)?function(e){const t=e.specifiedScales,n=e.component.scales;V(n).forEach(i=>{const r=t[i],o=r?r.domain:void 0,a=function(e,t){const n=e.getScaleComponent(t).get("type"),i=function(e,t,n,i){if("unaggregated"===e){const{valid:e,reason:i}=yf(t,n);if(!e)return void Ht(i)}else if(void 0===e&&i.useUnaggregatedDomain){const{valid:e}=yf(t,n);if(e)return"unaggregated"}return e}(e.scaleDomain(t),e.fieldDef(t),n,e.config.scale);i!==e.scaleDomain(t)&&(e.specifiedScales[t]=Object.assign({},e.specifiedScales[t],{domain:i}));if("x"===t&&e.channelHasField("x2"))return e.channelHasField("x")?mf(n,i,e,"x").concat(mf(n,i,e,"x2")):mf(n,i,e,"x2");if("y"===t&&e.channelHasField("y2"))return e.channelHasField("y")?mf(n,i,e,"y").concat(mf(n,i,e,"y2")):mf(n,i,e,"y2");return mf(n,i,e,t)}(e,i),s=n[i];if(s.domains=a,er(o)&&s.set("domainRaw",{signal:Ku+T(o)},!0),e.component.data.isFaceted){let t=e;for(;!Rf(t)&&t.parent;)t=t.parent;const n=t.component.resolve.scale[i];if("shared"===n)for(const e of a)Fo(e)&&(e.data=sf+e.data.replace(sf,""))}})}(e):function(e){for(const t of e.children)hf(t);const t=e.component.scales;V(t).forEach(n=>{let i,r=null;for(const t of e.children){const e=t.component.scales[n];if(e){i=void 0===i?e.domains:i.concat(e.domains);const t=e.get("domainRaw");r&&t&&r.signal!==t.signal&&Ht("The same selection must be used to override scale domains in a layered view."),r=t}}t[n].domains=i,r&&t[n].set("domainRaw",r,!0)})}(e)}function mf(e,t,n,i){const r=n.fieldDef(i);if(t&&"unaggregated"!==t&&!er(t)){const{type:e,timeUnit:n}=r;return"temporal"===e||n?function(e,t,n){return e.map(e=>({signal:`{data: ${Gn(e,{timeUnit:n,type:t})}}`}))}(t,e,n):[t]}const o=n.stack;if(o&&i===o.fieldChannel){if("normalize"===o.offset)return[[0,1]];const e=n.requestDataName(Qr);return[{data:e,field:n.vgField(i,{suffix:"start"})},{data:e,field:n.vgField(i,{suffix:"end"})}]}const s=Tt(i)?function(e,t,n){if(!Qi(n))return;const i=e.fieldDef(t),r=i.sort;if(Uo(r))return{op:"min",field:nu(i,t),order:"ascending"};const o=null!==e.stack;if(Po(r))return gf(r,o);if(function(e){return!!e&&!!e.encoding}(r)){const{encoding:t,order:n}=r,{aggregate:i,field:a}=e.fieldDef(t),s={op:i,field:a,order:n};return gf(s,o)}if("descending"===r)return{op:"min",field:e.vgField(t),order:"descending"};if(R(["ascending",void 0],r))return!0;return}(n,i,e):void 0;if("unaggregated"===t){const e=n.requestDataName(Qr),{field:t}=r;return[{data:e,field:$n({field:t,aggregate:"min"})},{data:e,field:$n({field:t,aggregate:"max"})}]}if(Xn(r.bin)){if(Qi(e))return"bin-ordinal"===e?[]:[{data:J(s)?n.requestDataName(Qr):n.requestDataName(Xr),field:n.vgField(i,Vn(r,i)?{binSuffix:"range"}:{}),sort:!0!==s&&a(s)?s:{field:n.vgField(i,{}),op:"min"}}];if(Xn(r.bin)){const e=n.getName($n(r,{suffix:"bins"}));return[new pf(()=>{const t=n.getSignalName(e);return`[${t}.start, ${t}.stop]`})]}return[{data:n.requestDataName(Qr),field:n.vgField(i,{})}]}return s?[{data:J(s)?n.requestDataName(Qr):n.requestDataName(Xr),field:n.vgField(i),sort:s}]:[{data:n.requestDataName(Qr),field:n.vgField(i)}]}function gf(e,t){const{op:n,field:i,order:r}=e;return Object.assign({op:n||(t?"sum":Ro)},i?{field:re(i)}:{},r?{order:r}:{})}function yf(e,t){const{aggregate:n,type:i}=e;return n?s(n)&&!Me[n]?{valid:!1,reason:Pt.unaggregateDomainWithNonSharedDomainOp(n)}:"quantitative"===i&&"log"===t?{valid:!1,reason:Pt.unaggregatedDomainWithLogScale(e)}:{valid:!0}:{valid:!1,reason:Pt.unaggregateDomainHasNoEffectForRawField(e)}}function bf(e){if(Fo(e)&&s(e.field))return e.field;if(function(e){return!o(e)&&"fields"in e&&!("data"in e)}(e)){let t;for(const n of e.fields)if(Fo(n)&&s(n.field))if(t){if(t!==n.field)return Ht("Detected faceted independent scales that union domain of multiple fields from different data sources. We will use the first field. The result view size may be incorrect."),t}else t=n.field;return Ht("Detected faceted independent scales that union domain of identical fields from different source detected. We will assume that this is the same field from a different fork of the same data source. However, if this is not case, the result view size maybe incorrect."),t}if(function(e){return!o(e)&&"fields"in e&&"data"in e}(e)){Ht("Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.");const t=e.fields[0];return s(t)?t:void 0}}function vf(e,t){return function(e){const t=q(e.map(e=>Fo(e)?Ne(e,["sort"]):e),T),n=q(e.map(e=>{if(Fo(e)){const t=e.sort;return void 0===t||J(t)||("count"===t.op&&delete t.field,"ascending"===t.order&&delete t.order),t}}).filter(e=>void 0!==e),T);if(0===t.length)return;if(1===t.length){const t=e[0];if(Fo(t)&&n.length>0){let e=n[0];return n.length>1&&(Ht(Pt.MORE_THAN_ONE_SORT),e=!0),Object.assign({},t,{sort:e})}return t}const i=q(n.map(e=>J(e)?e:"count"===e.op?e:(Ht(Pt.domainSortDropped(e)),!0)),T);let r;1===i.length?r=i[0]:i.length>1&&(Ht(Pt.MORE_THAN_ONE_SORT),r=!0);const o=q(e.map(e=>Fo(e)?e.data:null),e=>e);if(1===o.length&&null!==o[0])return Object.assign({data:o[0],fields:t.map(e=>e.field)},r?{sort:r}:{});return Object.assign({fields:t},r?{sort:r}:{})}(e.component.scales[t].domains.map(t=>(Fo(t)&&(t.data=e.lookupDataSource(t.data)),t)))}function xf(e){return V(e.component.scales).reduce((t,n)=>{const i=e.component.scales[n];if(i.merged)return t;const r=i.combine();let{domainRaw:o}=r;const{name:a,type:s,domainRaw:c,range:l}=r,f=Ne(r,["name","type","domainRaw","range"]),d=function(e,t,n){if(("x"===n||"y"===n)&&Co(e))return{step:{signal:t+"_step"}};return e}(r.range,a,n);o&&function(e){return e.signal.indexOf(Ku)>=0}(o)&&(o=function(e,t){const n=JSON.parse(t.signal.replace(Ku,"")),i=Z(n.selection),r=n.encoding;let o=n.field,a=e.component.selection&&e.component.selection[i];if(!a){if(a=e.getSelectionComponent(i,n.selection),r||o){if(r&&!o){const e=a.project.items.filter(e=>e.channel===r);!e.length||e.length>1?(o=a.project.items[0].field,Ht((e.length?"Multiple ":"No ")+`matching ${u(r)} encoding found for selection ${u(n.selection)}. `+`Using "field": ${u(o)}.`)):o=e[0].field}}else o=a.project.items[0].field,a.project.items.length>1&&Ht('A "field" or "encoding" must be specified when using a selection as a scale domain. '+`Using "field": ${u(o)}.`);return{signal:ne(o,i)}}return Ht('Use "bind": "scales" to setup a binding for scales and selections within the same view.'),{signal:"null"}}(e,o));const p=vf(e,n);return t.push(Object.assign({name:a,type:s},p?{domain:p}:{},o?{domainRaw:o}:{},{range:d},f)),t},[])}class Af extends rl{constructor(e,t){super({},{name:e}),this.merged=!1,this.domains=[],this.setWithExplicit("type",t)}get domainDefinitelyIncludesZero(){if(!1!==this.get("zero"))return!0;const e=this.domains;return!!o(e)&&P(e,e=>o(e)&&2===e.length&&e[0]<=0&&e[1]>=0)}}const wf=["range","rangeStep","scheme"];function Cf(e){return"x"===e?"width":"y"===e?"height":void 0}function Ff(e){const t=e.component.scales;_t.forEach(n=>{const i=t[n];if(!i)return;const r=e.getScaleComponent(n),a=e.specifiedScales[n],s=e.fieldDef(n),u=Cf(n);let c=u?!!e.component.layoutSize.get(u):void 0;const l=r.get("type"),f=R(["point","band"],l)||!!a.rangeStep;u&&e.fit&&!c&&f&&(Ht(Pt.CANNOT_FIX_RANGE_STEP_WITH_FIT),c=!0);const d=function(e){const t=[];for(const n of $t){const i=Ef(e,n);void 0!==i&&t.push(i)}return t}(e),p=function(e,t,n,i,r,a,s,u,c,l,f){const d=c||null===r.rangeStep;for(const t of wf)if(void 0!==r[t]){const i=nr(n,t),o=ir(e,t);if(i)if(o)Ht(o);else switch(t){case"range":return ol(r[t]);case"scheme":return ol(Df(r[t]));case"rangeStep":{const n=r[t];if(null!==n){if(!c)return ol({step:n});Ht(Pt.rangeStepDropped(e))}}}else Ht(Pt.scalePropertyNotWorkWithScaleType(n,t,e))}return al(function(e,t,n,i,r,a,s,u,c,l,f){switch(e){case We:case He:if(R(["point","band"],n)&&!l)if(e===We&&"text"===s){if(r.scale.textXRangeStep)return{step:r.scale.textXRangeStep}}else if(r.scale.rangeStep)return{step:r.scale.rangeStep};return e===He&&Xi(n)?[pf.fromName(t,u),0]:[0,pf.fromName(t,u)];case nt:{const t=function(e,t,n){if(t)return 0;switch(e){case"bar":case"tick":return n.scale.minBandSize;case"line":case"trail":case"rule":return n.scale.minStrokeWidth;case"text":return n.scale.minFontSize;case"point":case"square":case"circle":return n.scale.minSize}throw new Error(Pt.incompatibleChannel("size",e))}(s,a,r),i=function(e,t,n){const i=n.scale;switch(e){case"bar":case"tick":{if(void 0!==n.scale.maxBandSize)return n.scale.maxBandSize;const e=kf(t,n.scale);return v(e)?e-1:new pf(()=>`${e.signal} - 1`)}case"line":case"trail":case"rule":return n.scale.maxStrokeWidth;case"text":return n.scale.maxFontSize;case"point":case"square":case"circle":{if(n.scale.maxSize)return n.scale.maxSize;const e=kf(t,i);return v(e)?Math.pow(Sf*e,2):new pf(()=>`pow(${Sf} * ${e.signal}, 2)`)}}throw new Error(Pt.incompatibleChannel("size",e))}(s,c,r);return Zi(n)?function(e,t,n){const i=()=>{const i=wo(t)?t.signal:t,r=`(${i} - ${e}) / (${n} - 1)`;return`sequence(${e}, ${t} + ${r}, ${r})`};return wo(t)?new pf(i):{signal:i()}}(t,i,function(e,t,n,i){switch(e){case"quantile":return t.scale.quantileCount;case"quantize":return t.scale.quantizeCount;case"threshold":return void 0!==n&&o(n)?n.length+1:(Ht(Pt.domainRequiredForThresholdScale(i)),3)}}(n,r,f,e)):[t,i]}case at:return[r.scale.minStrokeWidth,r.scale.maxStrokeWidth];case tt:return"symbol";case Ze:case Ke:case et:return"ordinal"===n?"nominal"===i?"category":"ordinal":"rect"===s||"geoshape"===s?"heatmap":"ramp";case it:case rt:case ot:return[r.scale.minOpacity,r.scale.maxOpacity]}throw new Error(`Scale range undefined for channel ${e}`)}(e,t,n,i,a,s,u,l,f,d,r.domain))}(n,e.getSignalName.bind(e),l,s.type,a,e.config,i.get("zero"),e.mark,c,e.getName(u),d);i.setWithExplicit("range",p)})}function Ef(e,t){const n=e.getScaleComponent(t);if(!n)return;const i=n.get("type"),r=e.fieldDef(t);if(Qi(i)){const e=n&&n.get("range");if(e&&Co(e)&&v(e.step))return e.step}else if(r&&r.bin&&Xn(r.bin)){const n=e.getName($n(r,{suffix:"bins"})),i=Cf(t),o=e.getName(i);return new pf(()=>{const t=e.getSignalName(n),i=`(${t}.stop - ${t}.start) / ${t}.step`;return`${e.getSignalName(o)} / (${i})`})}}function Df(e){return function(e){return e&&!!e.name}(e)?Object.assign({scheme:e.name},j(e,["name"])):{scheme:e}}const Sf=.95;function kf(e,t){if(e.length>0){let t=1/0;for(const n of e)wo(n)?t=void 0:void 0!==t&&n{return`min(${e.map(e=>wo(e)?e.signal:e).join(", ")})`})}return t.rangeStep?t.rangeStep:21}function Of(e,t){zf(e)?function(e,t){const n=e.component.scales;V(n).forEach(i=>{const r=e.specifiedScales[i],a=n[i],s=e.getScaleComponent(i),u=e.fieldDef(i),c=e.config,l=r[t],f=s.get("type"),d=nr(f,t),p=ir(i,t);if(void 0!==l&&(d?p&&Ht(p):Ht(Pt.scalePropertyNotWorkWithScaleType(f,t,i))),d&&void 0===p)if(void 0!==l)a.copyKeyFromObject(t,r);else{const n=function(e,t,n,i,r,a,s,u,c,l){const f=l.scale,{type:d,sort:p}=i;switch(e){case"bins":return function(e,t){const n=t.bin;if(Xn(n)){const n=e.getName($n(t,{suffix:"bins"}));return new pf(()=>e.getSignalName(n))}if(Jn(n)&&Zn(n)&&void 0!==n.step)return{step:n.step};return}(t,i);case"interpolate":return function(e,t){if(R([Ze,Ke,et],e)&&"nominal"!==t)return"hcl";return}(n,d);case"nice":return function(e,t,n){if(n.bin||R([Pi.TIME,Pi.UTC],e))return;return!!R([We,He],t)||void 0}(r,n,i);case"padding":return function(e,t,n,i,r,o){if(R([We,He],e)){if(Ji(t)){if(void 0!==n.continuousPadding)return n.continuousPadding;const{type:t,orient:a}=r;if("bar"===t&&!i.bin&&("vertical"===a&&"x"===e||"horizontal"===a&&"y"===e))return o.continuousBandSize}if(t===Pi.POINT)return n.pointPadding}return}(n,r,f,i,c,l.bar);case"paddingInner":return function(e,t,n,i){if(void 0!==e)return;if(R([We,He],t)){const{bandPaddingInner:e,barBandPaddingInner:t,rectBandPaddingInner:r}=i;return se(e,"bar"===n?t:r)}return}(a,n,c.type,f);case"paddingOuter":return function(e,t,n,i,r,o){if(void 0!==e)return;if(R([We,He],t)&&n===Pi.BAND){const{bandPaddingOuter:e,barBandPaddingOuter:t,rectBandPaddingOuter:n}=o;return se(e,"bar"===i?t:n,r/2)}return}(a,n,r,c.type,s,f);case"reverse":return function(e,t){if(Xi(e)&&"descending"===t)return!0;return}(r,p);case"zero":return function(e,t,n,i,r){if(n&&"unaggregated"!==n&&Xi(r)){if(o(n)){const e=n[0],t=n[n.length-1];if(e<=0&&t>=0)return!0}return!1}if("size"===e&&"quantitative"===t.type&&!Zi(r))return!0;if(!t.bin&&R([We,He],e)){const{orient:t,type:n}=i;return!R(["bar","area","line","trail"],n)||!("horizontal"===t&&"y"===e||"vertical"===t&&"x"===e)}return!1}(n,i,u,c,r)}return f[e]}(t,e,i,u,s.get("type"),s.get("padding"),s.get("paddingInner"),r.domain,e.markDef,c);void 0!==n&&a.set(t,n,!1)}})}(e,t):Bf(e,t)}function $f(e){zf(e)?Ff(e):Bf(e,"range")}function Bf(e,t){const n=e.component.scales;for(const n of e.children)"range"===t?$f(n):Of(n,t);V(n).forEach(i=>{let r;for(const n of e.children){const e=n.component.scales[i];if(e){r=cl(r,e.getWithExplicit(t),t,"scale",sl((e,n)=>{switch(t){case"range":return e.step&&n.step?e.step-n.step:0}return 0}))}}n[i].setWithExplicit(t,r)})}function Nf(e,t,n,i){const r=function(e,t,n){switch(t.type){case"nominal":case"ordinal":if(gt(e)||"discrete"===Rt(e))return"shape"===e&&"ordinal"===t.type&&Ht(Pt.discreteChannelCannotEncode(e,"ordinal")),"ordinal";if(R(["x","y"],e)){if(R(["rect","bar","rule"],n))return"band";if("bar"===n)return"band"}return"point";case"temporal":return gt(e)?"time":"discrete"===Rt(e)?(Ht(Pt.discreteChannelCannotEncode(e,"temporal")),"ordinal"):"time";case"quantitative":return gt(e)?Xn(t.bin)?"bin-ordinal":"linear":"discrete"===Rt(e)?(Ht(Pt.discreteChannelCannotEncode(e,"quantitative")),"ordinal"):"linear";case"geojson":return}throw new Error(Pt.invalidFieldType(t.type))}(t,n,i),{type:o}=e;return Tt(t)?void 0!==o?or(t,o)?rr(o,n.type)?o:(Ht(Pt.scaleTypeNotWorkWithFieldDef(o,r)),r):(Ht(Pt.scaleTypeNotWorkWithChannel(t,o,r)),r):r:null}function jf(e){zf(e)?e.component.scales=function(e){const{encoding:t,mark:n}=e;return _t.reduce((i,r)=>{let o,a;const s=t[r];if(wn(s)&&n===Fe&&r===tt&&s.type===bn)return i;if(wn(s)?(o=s,a=s.scale):An(s)&&(o=s.condition,a=s.condition.scale),o&&null!==a&&!1!==a){const t=Nf(a=a||{},r,o,n);i[r]=new Af(e.scaleName(r+"",!0),{value:t,explicit:a.type===t})}return i},{})}(e):e.component.scales=function(e){const t=e.component.scales={},n={},i=e.component.resolve;for(const t of e.children)jf(t),V(t.component.scales).forEach(r=>{if(i.scale[r]=i.scale[r]||nl(r,e),"shared"===i.scale[r]){const e=n[r],o=t.component.scales[r].getWithExplicit("type");e?Li(e.value,o.value)?n[r]=cl(e,o,"type","scale",_f):(i.scale[r]="independent",delete n[r]):n[r]=o}});return V(n).forEach(i=>{const r=e.scaleName(i,!0),o=n[i];t[i]=new Af(r,o);for(const t of e.children){const e=t.component.scales[i];e&&(t.renameScale(e.get("name"),r),e.merged=!0)}}),t}(e)}const _f=sl((e,t)=>qi(e)-qi(t));class Tf{constructor(){this.nameMap={}}rename(e,t){this.nameMap[e]=t}has(e){return void 0!==this.nameMap[e]}get(e){for(;this.nameMap[e]&&e!==this.nameMap[e];)e=this.nameMap[e];return e}}function zf(e){return e&&"unit"===e.type}function Rf(e){return e&&"facet"===e.type}function Pf(e){return e&&"repeat"===e.type}function Uf(e){return e&&"concat"===e.type}function Mf(e){return e&&"layer"===e.type}class Lf{constructor(e,t,n,i,r,a,u,c){this.type=t,this.parent=n,this.config=r,this.repeater=a,this.view=c,this.children=[],this.correctDataNames=e=>(e.from&&e.from.data&&(e.from.data=this.lookupDataSource(e.from.data)),e.from&&e.from.facet&&e.from.facet.data&&(e.from.facet.data=this.lookupDataSource(e.from.facet.data)),e),this.parent=n,this.config=r,this.repeater=a,this.name=e.name||i,this.title=s(e.title)?{text:e.title}:e.title,this.scaleNameMap=n?n.scaleNameMap:new Tf,this.projectionNameMap=n?n.projectionNameMap:new Tf,this.signalNameMap=n?n.signalNameMap:new Tf,this.data=e.data,this.description=e.description,this.transforms=(e.transform||[]).map(e=>uo(e)?{filter:O(e.filter,so)}:e),this.layout=$e(e)||Cr(e)?{}:function(e,t,n){const i=n[t],r={},{spacing:a,columns:s}=i;void 0!==a&&(r.spacing=a),void 0!==s&&(tn(e)&&!en(e.facet)||pr(e)&&o(e.repeat)||lr(e))&&(r.columns=s);for(const t of hr)if(void 0!==e[t])if("spacing"===t){const n=e[t];r[t]=v(n)?n:{row:n.row||a,column:n.column||a}}else r[t]=e[t];return r}(e,t,r),this.component={data:{sources:n?n.component.data.sources:[],outputNodes:n?n.component.data.outputNodes:{},outputNodeRefCounts:n?n.component.data.outputNodeRefCounts:{},isFaceted:tn(e)||n&&n.component.data.isFaceted&&!e.data},layoutSize:new rl,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:Object.assign({scale:{},axis:{},legend:{}},u?B(u):{}),selection:null,scales:null,projection:null,axes:{},legends:{}}}get width(){return this.getSizeSignalRef("width")}get height(){return this.getSizeSignalRef("height")}initSize(e){const{width:t,height:n}=e;t&&this.component.layoutSize.set("width",t,!0),n&&this.component.layoutSize.set("height",n,!0)}parse(){this.parseScale(),this.parseLayoutSize(),this.renameTopLevelLayoutSizeSignal(),this.parseSelections(),this.parseProjection(),this.parseData(),this.parseAxesAndHeaders(),this.parseLegends(),this.parseMarkGroup()}parseScale(){!function(e){jf(e),hf(e);for(const t of tr)Of(e,t);$f(e)}(this)}parseProjection(){_l(this)}renameTopLevelLayoutSizeSignal(){"width"!==this.getName("width")&&this.renameSignal(this.getName("width"),"width"),"height"!==this.getName("height")&&this.renameSignal(this.getName("height"),"height")}parseLegends(){Fl(this)}assembleGroupStyle(){if("unit"===this.type||"layer"===this.type)return this.view&&this.view.style||"cell"}assembleEncodeFromView(e){const t=Ne(e,["style"]),n={};for(const e in t)if(t.hasOwnProperty(e)){const i=t[e];void 0!==i&&(n[e]={value:i})}return n}assembleGroupEncodeEntry(e){let t=void 0;return this.view&&(t=this.assembleEncodeFromView(this.view)),e||"unit"!==this.type&&"layer"!==this.type?t:Object.assign({width:this.getSizeSignalRef("width"),height:this.getSizeSignalRef("height")},t||{})}assembleLayout(){if(!this.layout)return;const e=this.layout,{spacing:t}=e,n=Ne(e,["spacing"]),{component:i,config:r}=this,o=function(e,t){const n={};for(const i of bt){const r=e[i];if(r&&r.facetFieldDef){const{titleAnchor:e,titleOrient:o}=ou(["titleAnchor","titleOrient"],r.facetFieldDef,t,i),a=iu(i,o),s=gu(e,a);void 0!==s&&(n[a]=s)}}return V(n).length>0?n:void 0}(i.layoutHeaders,r);return Object.assign({padding:t},this.assembleDefaultLayout(),n,o?{titleBand:o}:{})}assembleDefaultLayout(){return{}}assembleHeaderMarks(){const{layoutHeaders:e}=this.component;let t=[];for(const n of bt)e[n].title&&t.push(uu(this,n));for(const e of au)t=t.concat(fu(this,e));return t}assembleAxes(){return function(e,t){const{x:n=[],y:i=[]}=e;return[...n.map(e=>Bo(e,"main",t)),...n.map(e=>Bo(e,"grid",t)),...i.map(e=>Bo(e,"main",t)),...i.map(e=>Bo(e,"grid",t))].filter(e=>e)}(this.component.axes,this.config)}assembleLegends(){return Ol(this)}assembleProjections(){return $l(this)}assembleTitle(){const e=this.title||{},{encoding:t}=e,n=Ne(e,["encoding"]),i=Object.assign({},mr(this.config.title).nonMark,n,t?{encode:{update:t}}:{});if(i.text)return R(["unit","layer"],this.type)?R(["middle",void 0],i.anchor)&&(i.frame=i.frame||"group"):i.anchor=i.anchor||"start",V(i).length>0?i:void 0}assembleGroup(e=[]){const t={};(e=e.concat(this.assembleSignals())).length>0&&(t.signals=e);const n=this.assembleLayout();n&&(t.layout=n),t.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());const i=!this.parent||Rf(this.parent)?function e(t){return Mf(t)||Uf(t)||Pf(t)?t.children.reduce((t,n)=>t.concat(e(n)),xf(t)):xf(t)}(this):[];i.length>0&&(t.scales=i);const r=this.assembleAxes();r.length>0&&(t.axes=r);const o=this.assembleLegends();return o.length>0&&(t.legends=o),t}hasDescendantWithFieldOnChannel(e){for(const t of this.children)if(zf(t)){if(t.channelHasField(e))return!0}else if(t.hasDescendantWithFieldOnChannel(e))return!0;return!1}getName(e){return Z((this.name?this.name+"_":"")+e)}requestDataName(e){const t=this.getName(e),n=this.component.data.outputNodeRefCounts;return n[t]=(n[t]||0)+1,t}getSizeSignalRef(e){if(Rf(this.parent)){const t="width"===e?"x":"y",n=this.component.scales[t];if(n&&!n.merged){const e=n.get("type"),i=n.get("range");if(Qi(e)&&Co(i)){const e=n.get("name"),i=bf(vf(this,t));if(i){return{signal:Au(e,n,$n({aggregate:"distinct",field:i},{expr:"datum"}))}}return Ht("Unknown field for ${channel}. Cannot calculate view size."),null}}}return{signal:this.signalNameMap.get(this.getName(e))}}lookupDataSource(e){const t=this.component.data.outputNodes[e];return t?t.getSource():e}getSignalName(e){return this.signalNameMap.get(e)}renameSignal(e,t){this.signalNameMap.rename(e,t)}renameScale(e,t){this.scaleNameMap.rename(e,t)}renameProjection(e,t){this.projectionNameMap.rename(e,t)}scaleName(e,t){return t?this.getName(e):Ct(e)&&Tt(e)&&this.component.scales[e]||this.scaleNameMap.has(this.getName(e))?this.scaleNameMap.get(this.getName(e)):void 0}projectionName(e){return e?this.getName("projection"):this.component.projection&&!this.component.projection.merged||this.projectionNameMap.has(this.getName("projection"))?this.projectionNameMap.get(this.getName("projection")):void 0}getScaleComponent(e){if(!this.component.scales)throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().");const t=this.component.scales[e];return t&&!t.merged?t:this.parent?this.parent.getScaleComponent(e):void 0}getSelectionComponent(e,t){let n=this.component.selection[e];if(!n&&this.parent&&(n=this.parent.getSelectionComponent(e,t)),!n)throw new Error(Pt.selectionNotFound(t));return n}}class If extends Lf{vgField(e,t={}){const n=this.fieldDef(e);if(n)return $n(n,t)}reduceFieldDef(e,t,n){return ai(this.getMapping(),(t,n,i)=>{const r=Un(n);return r?e(t,r,i):t},t,n)}forEachFieldDef(e,t){oi(this.getMapping(),(t,n)=>{const i=Un(t);i&&e(i,n)},t)}}class qf extends la{constructor(e,t){super(e),this.fieldDefs=t}clone(){return new qf(null,Object.assign({},this.fieldDefs))}static make(e,t){const{config:n,mark:i}=t;if("filter"!==n.invalidValues)return null;const r=t.reduceFieldDef((e,n,r)=>{const o=Tt(r)&&t.getScaleComponent(r);if(o){!Xi(o.get("type"))||n.aggregate||Ee(i)||(e[n.field]=n)}return e},{});return V(r).length?new qf(e,r):null}get filter(){return this.fieldDefs}assemble(){const e=V(this.filter).reduce((e,t)=>{const n=this.fieldDefs[t],i=$n(n,{expr:"datum"});return null!==n&&(e.push(`${i} !== null`),e.push(`!isNaN(${i})`)),e},[]);return e.length>0?{type:"filter",expr:e.join(" && ")}:null}}class Wf extends la{constructor(e,t){super(e),this.transform=t,this.transform=B(t);const{flatten:n,as:i=[]}=this.transform;this.transform.as=n.map((e,t)=>i[t]||e)}clone(){return new Wf(this.parent,B(this.transform))}producedFields(){return new Set(this.transform.as)}hash(){return`FlattenTransform ${T(this.transform)}`}assemble(){const{flatten:e,as:t}=this.transform;return{type:"flatten",fields:e,as:t}}}class Hf extends la{constructor(e,t){super(e),this.transform=t,this.transform=B(t);const n=this.transform.as||[void 0,void 0];this.transform.as=[n[0]||"key",n[1]||"value"]}clone(){return new Hf(null,B(this.transform))}producedFields(){return new Set(this.transform.as)}hash(){return`FoldTransform ${T(this.transform)}`}assemble(){const{fold:e,as:t}=this.transform;return{type:"fold",fields:e,as:t}}}class Gf extends la{constructor(e,t,n,i){super(e),this.fields=t,this.geojson=n,this.signal=i}clone(){return new Gf(null,B(this.fields),this.geojson,this.signal)}static parseAll(e,t){if(t.component.projection&&!t.component.projection.isFit)return e;let n=0;if([[Qe,Ve],[Je,Xe]].forEach(i=>{const r=i.map(e=>t.channelHasField(e)?t.fieldDef(e).field:En(t.encoding[e])?{expr:t.encoding[e].value+""}:void 0);(r[0]||r[1])&&(e=new Gf(e,r,null,t.getName(`geojson_${n++}`)))}),t.channelHasField(tt)){const i=t.fieldDef(tt);i.type===bn&&(e=new Gf(e,null,i.field,t.getName(`geojson_${n++}`)))}return e}assemble(){return Object.assign({type:"geojson"},this.fields?{fields:this.fields}:{},this.geojson?{geojson:this.geojson}:{},{signal:this.signal})}}class Yf extends la{constructor(e,t,n,i){super(e),this.projection=t,this.fields=n,this.as=i}clone(){return new Yf(null,this.projection,B(this.fields),B(this.as))}static parseAll(e,t){return t.projectionName()?([[Qe,Ve],[Je,Xe]].forEach(n=>{const i=n.map(e=>t.channelHasField(e)?t.fieldDef(e).field:En(t.encoding[e])?{expr:t.encoding[e].value+""}:void 0),r=n[0]===Je?"2":"";(i[0]||i[1])&&(e=new Yf(e,t.projectionName(),i,[t.getName("x"+r),t.getName("y"+r)]))}),e):e}assemble(){return{type:"geopoint",projection:this.projection,fields:this.fields,as:this.as}}}class Vf extends la{constructor(e,t){super(e),this.params=t}clone(){return new Vf(null,this.params)}assemble(){return Object.assign({type:"graticule"},!0===this.params?{}:this.params)}}class Qf extends la{clone(){return new Qf(null)}constructor(e){super(e)}producedFields(){return new Set([sr])}hash(){return"Identifier"}assemble(){return{type:"identifier",as:sr}}}function Xf(e,t){const{config:n,encoding:i,markDef:r}=e,o=r.orient,a=i.size,s="x"===t?"horizontal"===o:"vertical"===o,u="x"===t?"x2":"y2",c=i[t],l=i[u],f=e.scaleName(t),d=e.getScaleComponent(t),p=se(r.binSpacing,n.bar.binSpacing),h=d?d.get("reverse"):void 0;if(wn(c)&&Jn(c.bin))return Zc({fieldDef:c,fieldDef2:l,channel:t,mark:"bar",scaleName:f,spacing:p,reverse:h});if(s||l)return Object.assign({},Kc(t,e,"zeroOrMin"),el(e,"zeroOrMin",u));{const i="x"===t?"width":"height";if(wn(c)){const o=d.get("type");if(Xn(c.bin)&&!a&&!Qi(o))return Zc({fieldDef:c,channel:t,scaleName:f,mark:"bar",spacing:p,reverse:h});if(o===Pi.BAND)return Xc(c,t,e,Jf(r,i,f,d,n))}return Jc(t,e,Rc(e[i]),Jf(r,i,f,d,n))}}function Jf(e,t,n,i,r){const o=se(e[t],e.size,Zo("size",e,r,{vgChannel:t}));if(void 0!==o)return{value:o};if(i){const e=i.get("type");if("point"!==e&&"band"!==e)return{value:r.bar.continuousBandSize};if(void 0!==r.bar.discreteBandSize)return{value:r.bar.discreteBandSize};if(e!==Pi.POINT)return Nc(n);{const e=i.get("range");if(Co(e)&&v(e.step))return{value:e.step-1};Ht(Pt.BAR_WITH_POINT_SCALE_AND_RANGESTEP_NULL)}}return{value:se(r.bar.discreteBandSize,r.scale.rangeStep?r.scale.rangeStep-1:void 0,20)}}function Zf(e,t){const{config:n,width:i,height:r}=e;return Object.assign({},Lc(e,{size:"include",orient:"ignore"}),Kc("x",e,Rc(i)),Kc("y",e,Rc(r)),Gc("size",e),function(e,t,n){if(n)return{shape:{value:n}};return Gc("shape",e)}(e,0,t))}function Kf(e,t){const n="x"===t?"x2":"y2",i=e.encoding[t],r=e.encoding[n],o=e.getScaleComponent(t),a=o?o.get("type"):void 0,s=e.scaleName(t);if(wn(i)&&(Xn(i.bin)||Jn(i.bin)))return Zc({fieldDef:i,fieldDef2:r,channel:t,mark:"rect",scaleName:s,spacing:0,reverse:o.get("reverse")});if(wn(i)&&o&&Qi(a)){if(a===Pi.BAND)return Xc(i,t,e);throw new Error(Pt.scaleTypeNotWorkWithMark(ye,a))}return Object.assign({},Kc(t,e,"zeroOrMax"),el(e,"zeroOrMin",n))}function ed(e){const{config:t,markDef:n}=e,{orient:i}=n,r="horizontal"===i?"width":"height",o=e.getScaleComponent("horizontal"===i?"x":"y"),a=se(n[r],n.size,Zo("size",n,t,{vgChannel:r}),t.tick.bandSize);if(void 0!==a)return a;{const e=o?o.get("range"):void 0,n=e&&Co(e)?e.step:t.scale.rangeStep;if("number"!=typeof n)throw new Error("Function does not handle non-numeric rangeStep");return 3*n/4}}const td={area:{vgMark:"area",encodeEntry:e=>Object.assign({},Lc(e,{size:"ignore",orient:"include"}),Kc("x",e,"zeroOrMin"),Kc("y",e,"zeroOrMin"),el(e,"zeroOrMin","horizontal"===e.markDef.orient?"x2":"y2"),Hc(e))},bar:{vgMark:"rect",encodeEntry:e=>Object.assign({},Lc(e,{size:"ignore",orient:"ignore"}),Xf(e,"x"),Xf(e,"y"))},circle:{vgMark:"symbol",encodeEntry:e=>Zf(e,"circle")},geoshape:{vgMark:"shape",encodeEntry:e=>Object.assign({},Lc(e,{size:"ignore",orient:"ignore"})),postEncodingTransform:e=>{const{encoding:t}=e,n=t.shape;return[Object.assign({type:"geoshape",projection:e.projectionName()},n&&wn(n)&&n.type===bn?{field:$n(n,{expr:"datum"})}:{})]}},line:{vgMark:"line",encodeEntry:e=>{const{width:t,height:n}=e;return Object.assign({},Lc(e,{size:"ignore",orient:"ignore"}),Kc("x",e,Rc(t)),Kc("y",e,Rc(n)),Gc("size",e,{vgChannel:"strokeWidth"}),Hc(e))}},point:{vgMark:"symbol",encodeEntry:e=>Zf(e)},rect:{vgMark:"rect",encodeEntry:e=>Object.assign({},Lc(e,{size:"ignore",orient:"ignore"}),Kf(e,"x"),Kf(e,"y"))},rule:{vgMark:"rule",encodeEntry:e=>{const{markDef:t,width:n,height:i}=e,r=t.orient;return e.encoding.x||e.encoding.y||e.encoding.latitude||e.encoding.longitude?Object.assign({},Lc(e,{size:"ignore",orient:"ignore"}),Kc("x",e,"horizontal"===r?"zeroOrMin":Rc(n)),Kc("y",e,"vertical"===r?"zeroOrMin":Rc(i)),"vertical"!==r?el(e,"zeroOrMax","x2"):{},"horizontal"!==r?el(e,"zeroOrMax","y2"):{},Gc("size",e,{vgChannel:"strokeWidth"})):{}}},square:{vgMark:"symbol",encodeEntry:e=>Zf(e,"square")},text:{vgMark:"text",encodeEntry:e=>{const{config:t,encoding:n,width:i,height:r}=e;return Object.assign({},Lc(e,{size:"ignore",orient:"ignore"}),Kc("x",e,Rc(i)),Kc("y",e,Rc(r)),Qc(e),Gc("size",e,{vgChannel:"fontSize"}),qc("align",function(e,t,n){if(void 0===(e.align||Zo("align",e,n)))return"center";return}(e.markDef,0,t)),qc("baseline",function(e,t,n){if(void 0===(e.baseline||Zo("baseline",e,n)))return"middle";return}(e.markDef,0,t)))}},tick:{vgMark:"rect",encodeEntry:e=>{const{config:t,markDef:n,width:i,height:r}=e,o=n.orient,a="horizontal"===o?"width":"height",s="horizontal"===o?"height":"width";return Object.assign({},Lc(e,{size:"ignore",orient:"ignore"}),Kc("x",e,Rc(i),"xc"),Kc("y",e,Rc(r),"yc"),Gc("size",e,{defaultValue:ed(e),vgChannel:a}),{[s]:{value:se(n.thickness,t.tick.thickness)}})}},trail:{vgMark:"trail",encodeEntry:e=>{const{width:t,height:n}=e;return Object.assign({},Lc(e,{size:"include",orient:"ignore"}),Kc("x",e,Rc(t)),Kc("y",e,Rc(n)),Gc("size",e),Hc(e))}}};function nd(e){return R([me,pe,Ae],e.mark)?function(e){const t=od(e.mark,e.encoding),n=rd(e,{fromPrefix:t.length>0?id:""});return t.length>0?[{name:e.getName("pathgroup"),type:"group",from:{facet:{name:id+e.requestDataName(Qr),data:e.requestDataName(Qr),groupby:t}},encode:{update:{width:{field:{group:"width"}},height:{field:{group:"height"}}}},marks:n}]:n}(e):rd(e)}const id="faceted_path_";function rd(e,t={fromPrefix:""}){const n=e.mark,i=se(e.markDef.clip,function(e){const t=e.getScaleComponent("x"),n=e.getScaleComponent("y");return!!(t&&t.get("domainRaw")||n&&n.get("domainRaw"))||void 0}(e),function(e){const t=e.component.projection;return!(!t||t.isFit)||void 0}(e)),r=Jo(e.markDef),a=e.encoding.key,s=function(e){const{encoding:t,stack:n,mark:i,markDef:r,config:a}=e,s=t.order;if(!(!o(s)&&En(s)&&z(s.value)||!s&&z(r.order)||z(Zo("order",r,a)))){if((o(s)||wn(s))&&!n)return aa(s,{expr:"datum"});if(Ee(i)){const n=t["horizontal"===r.orient?"y":"x"];if(wn(n)){const t=n.sort;return{field:Po(t)?$n({aggregate:ti(e.encoding)?t.op:void 0,field:t.field},{expr:"datum"}):$n(n,{binSuffix:e.stack&&e.stack.impute?"mid":void 0,expr:"datum"}),order:"descending"}}}}}(e),u=td[n].postEncodingTransform?td[n].postEncodingTransform(e):null;return[Object.assign({name:e.getName("marks"),type:td[n].vgMark},i?{clip:!0}:{},r?{style:r}:{},a?{key:{field:a.field}}:{},s?{sort:s}:{},{from:{data:t.fromPrefix+e.requestDataName(Qr)},encode:{update:td[n].encodeEntry(e)}},u?{transform:u}:{})]}function od(e,t){return V(t).reduce((n,i)=>{switch(i){case"x":case"y":case"order":case"href":case"x2":case"y2":case"latitude":case"longitude":case"latitude2":case"longitude2":case"text":case"shape":case"tooltip":return n;case"detail":case"key":{const e=t[i];return(o(e)||wn(e))&&(o(e)?e:[e]).forEach(e=>{e.aggregate||n.push($n(e,{}))}),n}case"size":if("trail"===e)return n;case"color":case"fill":case"stroke":case"opacity":case"fillOpacity":case"strokeOpacity":case"strokeWidth":{const e=Mn(t[i]);return e&&!e.aggregate&&n.push($n(e,{})),n}default:throw new Error(`Bug: Channel ${i} unimplemented for line mark`)}},[])}class ad extends la{constructor(e,t){super(e),this.transform=t}clone(){return new ad(null,B(this.transform))}producedFields(){return new Set([this.transform.impute])}processSequence(e){const{start:t=0,stop:n,step:i}=e;return{signal:`sequence(${[t,n,...i?[i]:[]].join(",")})`}}static makeFromTransform(e,t){return new ad(e,t)}static makeFromEncoding(e,t){const n=t.encoding,i=n.x,r=n.y;if(wn(i)&&wn(r)){const o=i.impute?i:r.impute?r:void 0;if(void 0===o)return;const a=i.impute?r:r.impute?i:void 0,{method:s,value:u,frame:c,keyvals:l}=o.impute,f=od(t.mark,n);return new ad(e,Object.assign({impute:o.field,key:a.field},s?{method:s}:{},void 0!==u?{value:u}:{},c?{frame:c}:{},void 0!==l?{keyvals:l}:{},f.length?{groupby:f}:{}))}return null}hash(){return`Impute ${T(this.transform)}`}assemble(){const{impute:e,key:t,keyvals:n,method:i,groupby:r,value:o,frame:a=[null,null]}=this.transform,s=Object.assign({type:"impute",field:e,key:t},n?{keyvals:(u=n,u&&void 0!==u.start&&void 0!==u.stop?this.processSequence(n):n)}:{},{method:"value"},r?{groupby:r}:{},{value:null});var u;let c;if(i&&"value"!==i){c=[Object.assign({type:"window",as:[`imputed_${e}_value`],ops:[i],fields:[e],frame:a,ignorePeers:!1},r?{groupby:r}:{}),{type:"formula",expr:`datum.${e} === null ? datum.imputed_${e}_value : datum.${e}`,as:e}]}else{c=[{type:"formula",expr:`datum.${e} === null ? ${o} : datum.${e}`,as:e}]}return[s,...c]}}class sd extends rl{constructor(e={},t={},n=!1){super(e,t),this.explicit=e,this.implicit=t,this.parseNothing=n}clone(){const e=super.clone();return e.parseNothing=this.parseNothing,e}}class ud extends la{constructor(e,t,n){super(e),this.transform=t,this.secondary=n}clone(){return new ud(null,B(this.transform),this.secondary)}static make(e,t,n,i){const r=t.component.data.sources;let o=kd(n.from.data,r);o||(o=new Tl(n.from.data),r.push(o));const a=t.getName(`lookup_${i}`),s=new fa(o,a,"lookup",t.component.data.outputNodeRefCounts);return t.component.data.outputNodes[a]=s,new ud(e,n,s.getSource())}producedFields(){return new Set(this.transform.from.fields||(this.transform.as instanceof Array?this.transform.as:[this.transform.as]))}hash(){return`Lookup ${T({transform:this.transform,secondary:this.secondary})}`}assemble(){let e;if(this.transform.from.fields)e=Object.assign({values:this.transform.from.fields},this.transform.as?{as:this.transform.as instanceof Array?this.transform.as:[this.transform.as]}:{});else{let t=this.transform.as;s(t)||(Ht(Pt.NO_FIELDS_NEEDS_AS),t="_lookup"),e={as:[t]}}return Object.assign({type:"lookup",from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup]},e,this.transform.default?{default:this.transform.default}:{})}}class cd extends la{constructor(e,t){super(e),this.transform=t}clone(){return new cd(null,B(this.transform))}hash(){return`SampleTransform ${T(this.transform)}`}assemble(){return{type:"sample",size:this.transform.sample}}}class ld extends la{constructor(e,t){super(e),this.params=t}clone(){return new ld(null,this.params)}assemble(){return Object.assign({type:"sequence"},this.params)}}function fd(e){let t=0;return function n(i,r){i instanceof Tl&&!i.isGenerator&&!Ir(i.data)&&(e.push(r),r={name:null,source:r.name,transform:[]});if(i instanceof Yl&&(i.parent instanceof Tl&&!r.source?(r.format=Object.assign({},r.format||{},{parse:i.assembleFormatParse()}),r.transform.push(...i.assembleTransforms(!0))):r.transform.push(...i.assembleTransforms())),i instanceof Wl)return r.name||(r.name=`data_${t++}`),!r.source||r.transform.length>0?(e.push(r),i.data=r.name):i.data=r.source,void i.assemble().forEach(t=>e.push(t));(i instanceof Vf||i instanceof ld||i instanceof qf||i instanceof Hl||i instanceof tu||i instanceof Yf||i instanceof Gf||i instanceof Ll||i instanceof ud||i instanceof Xl||i instanceof Vl||i instanceof Hf||i instanceof Wf||i instanceof Qf||i instanceof cd)&&r.transform.push(i.assemble()),(i instanceof ql||i instanceof Uu||i instanceof ad||i instanceof Ql)&&(r.transform=r.transform.concat(i.assemble())),i instanceof fa&&(r.source&&0===r.transform.length?i.setSource(r.source):i.parent instanceof fa?i.setSource(r.name):(r.name||(r.name=`data_${t++}`),i.setSource(r.name),1===i.numChildren()&&(e.push(r),r={name:null,source:r.name,transform:[]})));switch(i.numChildren()){case 0:i instanceof fa&&(!r.source||r.transform.length>0)&&e.push(r);break;case 1:n(i.children[0],r);break;default:{r.name||(r.name=`data_${t++}`);let o=r.name;!r.source||r.transform.length>0?e.push(r):o=r.source,i.children.forEach(e=>{n(e,{name:null,source:o,transform:[]})});break}}}}function dd(e){return"top"===e||"left"===e?"header":"footer"}function pd(e,t){if(e.channelHasField(t)){const n=e.facet[t],i=ru("title",null,e.config,t);let r=zn(n,e.config,{allowDisabling:!0,includeDefault:void 0===i||!!i});e.child.component.layoutHeaders[t].title&&(r+=" / "+e.child.component.layoutHeaders[t].title,e.child.component.layoutHeaders[t].title=null);const o=R(["bottom","right"],ru("labelOrient",n,e.config,t))?"footer":"header";e.component.layoutHeaders[t]={title:r,facetFieldDef:n,[o]:"facet"===t?[]:[hd(e,t,!0)]}}}function hd(e,t,n){const i="row"===t?"height":"width";return{labels:n,sizeSignal:e.child.component.layoutSize.get(i)?e.child.getSizeSignalRef(i):void 0,axes:[]}}function md(e,t){const{child:n}=e;if(n.component.axes[t]){const{layoutHeaders:i,resolve:r}=e.component;if(r.axis[t]=il(r,t),"shared"===r.axis[t]){const r="x"===t?"column":"row",o=i[r];for(const i of n.component.axes[t]){const t=dd(i.get("orient"));o[t]=o[t]||[hd(e,r,!1)];const n=Bo(i,"main",e.config,{header:!0});o[t][0].axes.push(n),i.mainExtracted=!0}}}}function gd(e){vd(e);const t=e.component.layoutSize;t.setWithExplicit("width",xd(e,"width")),t.setWithExplicit("height",xd(e,"height"))}const yd=gd,bd={vconcat:"width",hconcat:"height"};function vd(e){for(const t of e.children)t.parseLayoutSize()}function xd(e,t){const n="width"===t?"x":"y",i=e.component.resolve;let r;for(const o of e.children){const e=o.component.layoutSize.getWithExplicit(t),a=i.scale[n];if("independent"===a&&"range-step"===e.value){r=void 0;break}if(r){if("independent"===a&&r.value!==e.value){r=void 0;break}r=cl(r,e,t,"")}else r=e}if(r){for(const n of e.children)e.renameSignal(n.getName(t),e.getName(t)),n.component.layoutSize.set(t,"merged",!1);return r}return{explicit:!1,value:void 0}}function Ad(e,t){const n="width"===t?"x":"y",i=e.config,r=e.getScaleComponent(n);if(r){const e=r.get("type"),n=r.get("range");return Qi(e)&&Co(n)?"range-step":i.view[t]}return e.hasProjection?i.view[t]:"width"===t&&"text"===e.mark?i.scale.textXRangeStep:i.scale.rangeStep||Ki.rangeStep}function wd(e,t){return function(e){return e&&!s(e)&&"repeat"in e}(e.field)?e.field.repeat in t?Object.assign({},e,{field:t[e.field.repeat]}):void Ht(Pt.noSuchRepeatedValue(e.field.repeat)):e}function Cd(e,t){if(void 0!==(e=wd(e,t))){if(null===e)return null;if(function(e){return Cn(e)&&!!e.sort}(e)&&Po(e.sort)){const n=wd(e.sort,t);e=Object.assign({},e,n?{sort:n}:{})}return e}}function Fd(e,t){if(!wn(e)){if(An(e)){const n=Cd(e.condition,t);if(n)return Object.assign({},e,{condition:n});return Ne(e,["condition"])}return e}{const n=Cd(e,t);if(n)return n;if(xn(e))return{condition:e.condition}}}function Ed(e,t){const n={};for(const i in e)if(e.hasOwnProperty(i)){const r=e[i];if(o(r))n[i]=r.map(e=>Fd(e,t)).filter(e=>e);else{const e=Fd(r,t);void 0!==e&&(n[i]=e)}}return n}function Dd(e,t,n){return $n(t,Object.assign({suffix:`by_${$n(e)}`},n||{}))}class Sd extends If{constructor(e,t,n,i,r){super(e,"facet",t,n,r,i,e.resolve),this.child=Id(e.spec,this,this.getName("child"),void 0,i,r,!1),this.children=[this.child];const o=function(e,t){return en(e)?Ed(e,t):Cd(e,t)}(e.facet,i);this.facet=this.initFacet(o)}initFacet(e){return en(e)?ai(e,(e,t,n)=>R([Le,Ie],n)?void 0===t.field?(Ht(Pt.emptyFieldDef(t,n)),e):(e[n]=Ln(t,n),e):(Ht(Pt.incompatibleChannel(n,"facet")),e),{}):{facet:Ln(e,"facet")}}channelHasField(e){return!!this.facet[e]}fieldDef(e){return this.facet[e]}parseData(){this.component.data=Od(this),this.child.parseData()}parseLayoutSize(){vd(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),function(e){for(const t of bt)pd(e,t);md(e,"x"),md(e,"y")}(this)}assembleSelectionTopLevelSignals(e){return this.child.assembleSelectionTopLevelSignals(e)}assembleSignals(){return this.child.assembleSignals(),[]}assembleSelectionData(e){return this.child.assembleSelectionData(e)}getHeaderLayoutMixins(){const e={};for(const t of bt)for(const n of su){const i=this.component.layoutHeaders[t],r=i[n],{facetFieldDef:o}=i;if(o){const n=ru("titleOrient",o,this.config,t);if(R(["right","bottom"],n)){const i=iu(t,n);e.titleAnchor=e.titleAnchor||{},e.titleAnchor[i]="end"}}if(r&&r[0]){const r="row"===t?"height":"width",o="header"===n?"headerBand":"footerBand";"facet"===t||this.child.component.layoutSize.get(r)||(e[o]=e[o]||{},e[o][t]=.5),i.title&&(e.offset=e.offset||{},e.offset["row"===t?"rowTitle":"columnTitle"]=10)}}return e}assembleDefaultLayout(){const{column:e,row:t}=this.facet,n=e?this.columnDistinctSignal():t?1:void 0;let i="all";return(t||"independent"!==this.component.resolve.scale.x)&&(e||"independent"!==this.component.resolve.scale.y)||(i="none"),Object.assign({},this.getHeaderLayoutMixins(),n?{columns:n}:{},{bounds:"full",align:i})}assembleLayoutSignals(){return this.child.assembleLayoutSignals()}columnDistinctSignal(){if(!(this.parent&&this.parent instanceof Sd)){return{signal:`length(data('${this.getName("column_domain")}'))`}}}assembleGroup(e){return this.parent&&this.parent instanceof Sd?Object.assign({},this.channelHasField("column")?{encode:{update:{columns:{field:$n(this.facet.column,{prefix:"distinct"})}}}}:{},super.assembleGroup(e)):super.assembleGroup(e)}getCardinalityAggregateForChild(){const e=[],t=[],n=[];if(this.child instanceof Sd){if(this.child.channelHasField("column")){const i=$n(this.child.facet.column);e.push(i),t.push("distinct"),n.push(`distinct_${i}`)}}else for(const i of["x","y"]){const r=this.child.component.scales[i];if(r&&!r.merged){const o=r.get("type"),a=r.get("range");if(Qi(o)&&Co(a)){const r=bf(vf(this.child,i));r?(e.push(r),t.push("distinct"),n.push(`distinct_${r}`)):Ht("Unknown field for ${channel}. Cannot calculate view size.")}}}return{fields:e,ops:t,as:n}}assembleFacet(){const{name:e,data:t}=this.component.data.facetRoot,{row:n,column:i}=this.facet,{fields:r,ops:a,as:s}=this.getCardinalityAggregateForChild(),u=[];for(const e of bt){const t=this.facet[e];if(t){u.push($n(t));const{bin:c,sort:l}=t;if(Xn(c)&&u.push($n(t,{binSuffix:"end"})),Po(l)){const{field:e,op:o=Ro}=l,u=Dd(t,l);n&&i?(r.push(u),a.push("max"),s.push(u)):(r.push(e),a.push(o),s.push(u))}else if(o(l)){const n=nu(t,e);r.push(n),a.push("max"),s.push(n)}}}const c=!!n&&!!i;return Object.assign({name:e,data:t,groupby:u},c||r.length?{aggregate:Object.assign({},c?{cross:c}:{},r.length?{fields:r,ops:a,as:s}:{})}:{})}facetSortFields(e){const{facet:t}=this,n=t[e];return n?Po(n.sort)?[Dd(n,n.sort,{expr:"datum"})]:o(n.sort)?[nu(n,e,{expr:"datum"})]:[$n(n,{expr:"datum"})]:[]}facetSortOrder(e){const{facet:t}=this,n=t[e];if(n){const{sort:e}=n;return[(Po(e)?e.order:!o(e)&&e)||"ascending"]}return[]}assembleLabelTitle(){const{facet:e,config:t}=this;if(e.facet)return pu(e.facet,"facet",t);const n={row:["top","bottom"],column:["left","right"]};for(const i of au)if(e[i]){const r=ru("labelOrient",e[i],t,i);if(R(n[i],r))return pu(e[i],i,t)}}assembleMarks(){const{child:e}=this,t=function(e){const t=[],n=fd(t);return e.children.forEach(t=>n(t,{source:e.name,name:null,transform:[]})),t}(this.component.data.facetRoot),n=e.assembleGroupEncodeEntry(!1),i=this.assembleLabelTitle()||e.assembleTitle(),r=e.assembleGroupStyle();return[Object.assign({name:this.getName("cell"),type:"group"},i?{title:i}:{},r?{style:r}:{},{from:{facet:this.assembleFacet()},sort:{field:M(bt.map(e=>this.facetSortFields(e))),order:M(bt.map(e=>this.facetSortOrder(e)))}},t.length>0?{data:t}:{},n?{encode:{update:n}}:{},e.assembleGroup(function(e,t){if(e.component.selection&&V(e.component.selection).length){const n=u(e.getName("cell"));t.unshift({name:"facet",value:{},on:[{events:wu("mousemove","scope"),update:`isTuple(facet) ? facet : group(${n}).datum`}]})}return t}(this,[])))]}getMapping(){return this.facet}}function kd(e,t){for(const n of t){const t=n.data;if((!e.name||!n.hasName()||e.name===n.dataName)&&!(e.format&&e.format.mesh&&t.format&&t.format.feature))if(qr(e)&&qr(t)){if($(e.values,t.values))return n}else if(Ir(e)&&Ir(t)){if(e.url===t.url)return n}else if(Wr(e)&&e.name===n.dataName)return n}return null}function Od(e){let t=function(e,t){if(e.data||!e.parent){const n=kd(e.data,t);if(n)return Hr(e.data)||(n.data.format=L({},e.data.format,n.data.format)),!n.hasName()&&e.data.name&&(n.dataName=e.data.name),n;{const n=new Tl(e.data);return t.push(n),n}}return e.parent.component.data.facetRoot?e.parent.component.data.facetRoot:e.parent.component.data.main}(e,e.component.data.sources);const{outputNodes:n,outputNodeRefCounts:i}=e.component.data,r=e.parent?e.parent.component.data.ancestorParse.clone():new sd,o=e.data;Hr(o)?(Gr(o)?t=new ld(t,o.sequence):Vr(o)&&(t=new Vf(t,o.graticule)),r.parseNothing=!0):o&&o.format&&null===o.format.parse&&(r.parseNothing=!0),t=Yl.makeExplicit(t,e,r)||t,!rc(e)||!zf(e)&&!Mf(e)||e.parent&&Mf(e.parent)||(t=new Qf(t));const a=e.parent&&Mf(e.parent);(zf(e)||Rf(e))&&a&&(t=ql.makeFromEncoding(t,e)||t),e.transforms.length>0&&(t=function(e,t,n){let i=0;for(const r of t.transforms){let o,a=void 0;if(mo(r))o=e=new tu(e,r),a="derived";else if(uo(r))o=e=Yl.makeImplicitFromFilterTransform(e,r,n)||e,e=new Hl(e,t,r.filter);else if(go(r))o=e=ql.makeFromTransform(e,r,t),a="number";else if(bo(r))o=e=Uu.makeFromTransform(e,r),a="date",void 0===n.getWithExplicit(r.field).value&&(e=new Yl(e,{[r.field]:a}),n.set(r.field,a,!1));else if(vo(r))o=e=Ll.makeFromTransform(e,r),a="number",rc(t)&&(e=new Qf(e));else if(co(r))o=e=ud.make(e,t,r,i++),a="derived";else if(fo(r))o=e=new Xl(e,r),a="number";else if(po(r))o=e=new Vl(e,r),a="number";else if(xo(r))o=e=Ql.makeFromTransform(e,r),a="derived";else if(Ao(r))o=e=new Hf(e,r),a="derived";else if(ho(r))o=e=new Wf(e,r),a="derived";else if(lo(r))e=new cd(e,r);else{if(!yo(r)){Ht(Pt.invalidTransformIgnored(r));continue}o=e=ad.makeFromTransform(e,r),a="derived"}if(o&&void 0!==a)for(const e of o.producedFields())n.set(e,a,!1)}return e}(t,e,r)),t=Yl.makeImplicitFromEncoding(t,e,r)||t,zf(e)&&(t=Gf.parseAll(t,e),t=Yf.parseAll(t,e)),(zf(e)||Rf(e))&&(a||(t=ql.makeFromEncoding(t,e)||t),t=Uu.makeFromEncoding(t,e)||t,t=tu.parseAllForSortIndex(t,e));const s=e.getName(Xr),u=new fa(t,s,Xr,i);if(n[s]=u,t=u,zf(e)){const n=Ll.makeFromEncoding(t,e);n&&(t=n,rc(e)&&(t=new Qf(t))),t=ad.makeFromEncoding(t,e)||t,t=Ql.makeFromEncoding(t,e)||t}zf(e)&&(t=qf.make(t,e)||t);const c=e.getName(Qr),l=new fa(t,c,Qr,i);n[c]=l,t=l;let f=null;if(Rf(e)){const i=e.getName("facet");t=function(e,t){const{row:n,column:i}=t;if(n&&i){let t=null;for(const r of[n,i])if(Po(r.sort)){const{field:n,op:i=Ro}=r.sort;e=t=new Vl(e,{joinaggregate:[{op:i,field:n,as:Dd(r,r.sort,{forAs:!0})}],groupby:[$n(r)]})}return t}return null}(t=tu.parseAllForSortIndex(t,e),e.facet)||t,f=new Wl(t,e,i,l.getSource()),n[i]=f,t=f}return Object.assign({},e.component.data,{outputNodes:n,outputNodeRefCounts:i,raw:u,main:l,facetRoot:f,ancestorParse:r})}class $d extends Lf{constructor(e,t,n,i,r,o,a){super(e,t,n,i,r,o,a)}parseData(){this.component.data=Od(this),this.children.forEach(e=>{e.parseData()})}parseSelections(){this.component.selection={};for(const e of this.children)e.parseSelections(),V(e.component.selection).forEach(t=>{this.component.selection[t]=e.component.selection[t]})}parseMarkGroup(){for(const e of this.children)e.parseMarkGroup()}parseAxesAndHeaders(){for(const e of this.children)e.parseAxesAndHeaders()}assembleSelectionTopLevelSignals(e){return this.children.reduce((e,t)=>t.assembleSelectionTopLevelSignals(e),e)}assembleSignals(){return this.children.forEach(e=>e.assembleSignals()),[]}assembleLayoutSignals(){return this.children.reduce((e,t)=>[...e,...t.assembleLayoutSignals()],bu(this))}assembleSelectionData(e){return this.children.reduce((e,t)=>t.assembleSelectionData(e),e)}assembleMarks(){return this.children.map(e=>{const t=e.assembleTitle(),n=e.assembleGroupStyle(),i=e.assembleGroupEncodeEntry(!1);return Object.assign({type:"group",name:e.getName("group")},t?{title:t}:{},n?{style:n}:{},i?{encode:{update:i}}:{},e.assembleGroup())})}}class Bd extends $d{constructor(e,t,n,i,r){super(e,"concat",t,n,r,i,e.resolve),e.resolve&&e.resolve.axis&&("shared"===e.resolve.axis.x||"shared"===e.resolve.axis.y)&&Ht(Pt.CONCAT_CANNOT_SHARE_AXIS),this.concatType=fr(e)?"vconcat":dr(e)?"hconcat":"concat",this.children=this.getChildren(e).map((e,t)=>Id(e,this,this.getName("concat_"+t),void 0,i,r,!1))}getChildren(e){return fr(e)?e.vconcat:dr(e)?e.hconcat:e.concat}parseLayoutSize(){!function(e){vd(e);const t=e.component.layoutSize,n=bd[e.concatType];n&&t.setWithExplicit(n,xd(e,n))}(this)}parseAxisGroup(){return null}assembleDefaultLayout(){return Object.assign({},"vconcat"===this.concatType?{columns:1}:{},{bounds:"full",align:"each"})}}class Nd extends rl{constructor(e={},t={},n=!1){super(),this.explicit=e,this.implicit=t,this.mainExtracted=n}clone(){return new Nd(B(this.explicit),B(this.implicit),this.mainExtracted)}hasAxisPart(e){return"axis"===e||("grid"===e||"title"===e?!!this.get(e):!(!1===(t=this.get(e))||null===t));var t}}const jd={bottom:"top",top:"bottom",left:"right",right:"left"};function _d(e,t){if(!e)return t.map(e=>e.clone());{if(e.length!==t.length)return;const n=e.length;for(let i=0;i{switch(n){case"title":return ca(e,t);case"gridScale":return{explicit:e.explicit,value:se(e.value,t.value)}}return ul(e,t,n,"axis")});e.setWithExplicit(n,i)}return e}function zd(e,t){const n="x"===t?"x2":"y2",i=e.fieldDef(t),r=e.fieldDef(n),o=i?i.title:void 0,a=r?r.title:void 0;return o&&a?ua(o,a):o||(a||(void 0!==o?o:void 0!==a?a:void 0))}function Rd(e,t){const n=t.axis(e),i=new Nd;$o.forEach(r=>{const o=function(e,t,n,i){const r=i.fieldDef(n),o=qo(i,t,n,r),a=se(t.orient,Vo(n));switch(e){case"scale":return i.scaleName(n);case"gridScale":return Io(i,n);case"format":if(Hn(r))return;return ta(r,t.format,i.config);case"formatType":if(Hn(r))return;return t.formatType;case"grid":if(Jn(i.fieldDef(n).bin))return!1;{const e=i.getScaleComponent(n).get("type");return se(t.grid,Lo(e,r))}case"labelAlign":return se(t.labelAlign,Ho(o,a));case"labelAngle":return o;case"labelBaseline":return se(t.labelBaseline,Wo(o,a));case"labelFlush":return se(t.labelFlush,Go(r,n));case"labelOverlap":{const e=i.getScaleComponent(n).get("type");return se(t.labelOverlap,Yo(r,e))}case"orient":return a;case"tickCount":{const e=i.getScaleComponent(n).get("type"),o="x"===n?"width":"y"===n?"height":void 0,a=o?i.getSizeSignalRef(o):void 0;return se(t.tickCount,Qo({fieldDef:r,scaleType:e,size:a}))}case"title":{const e="x"===n?"x2":"y2",o=i.fieldDef(e);return se(t.title,zd(i,n),sa([vn(r)],o?[vn(o)]:[]))}case"values":return Xo(t,0,r)}return s=e,Oo[s]?t[e]:void 0;var s}(r,n,e,t);if(void 0!==o){const a=function(e,t,n,i,r){switch(t){case"titleAngle":case"labelAngle":return e===de(n[t]);case"values":return!!n.values;case"encode":return!!n.encoding||!!n.labelAngle;case"title":if(e===zd(i,r))return!0}return e===n[t]}(o,r,n,t,e),s=Mo(r,t.config,e,i.get("orient"),t.getScaleComponent(e).get("type"));a||void 0===s?i.set(r,o,a):R(["grid","orient"],r)&&s&&i.set(r,s,!1)}});const r=n.encoding||{},o=Do.reduce((n,o)=>{if(!i.hasAxisPart(o))return n;const a=tl(r[o]||{},t),s="labels"===o?function(e,t,n){const i=e.fieldDef(t)||("x"===t?e.fieldDef("x2"):"y"===t?e.fieldDef("y2"):void 0),r=e.axis(t),o=e.config;let a={};if(Hn(i)){const n=e.getScaleComponent(t).get("type")===Pi.UTC,s=oa("datum.value",i.timeUnit,r.format,o.axis.shortTimeLabels,null,n);s&&(a.text={signal:s})}return a=Object.assign({},a,n),0===V(a).length?void 0:a}(t,e,a):a;return void 0!==s&&V(s).length>0&&(n[o]={update:s}),n},{});return V(o).length>0&&i.set("encode",o,!!n.encoding||void 0!==n.labelAngle),i}function Pd(e,t,n){const i=Se(e)?Object.assign({},e):{type:e},r=i.orient||Zo("orient",i,n);return i.orient=function(e,t,n){switch(e){case ge:case we:case Ce:case ve:case ye:return}const{x:i,y:r,x2:o,y2:a}=t;switch(e){case he:if(wn(i)&&Jn(i.bin))return"vertical";if(wn(r)&&Jn(r.bin))return"horizontal";if(a||o){if(n)return n;if(!o&&wn(i)&&i.type===hn&&!Xn(i.bin))return"horizontal";if(!a&&wn(r)&&r.type===hn&&!Xn(r.bin))return"vertical"}case be:if(o&&a)return;case pe:if(a)return wn(r)&&Jn(r.bin)?"horizontal":"vertical";if(o)return wn(i)&&Jn(i.bin)?"vertical":"horizontal";if(e===be){if(t.x&&!t.y)return"vertical";if(t.y&&!t.x)return"horizontal"}case me:case xe:{const i=wn(t.x)&&Bn(t.x),r=wn(t.y)&&Bn(t.y);if(i&&!r)return"tick"!==e?"horizontal":"vertical";if(!i&&r)return"tick"!==e?"vertical":"horizontal";if(i&&r){const i=t.x,r=t.y,o=i.type===gn,a=r.type===gn;return o&&!a?"tick"!==e?"vertical":"horizontal":!o&&a?"tick"!==e?"horizontal":"vertical":!i.aggregate&&r.aggregate?"tick"!==e?"vertical":"horizontal":i.aggregate&&!r.aggregate?"tick"!==e?"horizontal":"vertical":n||"vertical"}return n||void 0}}return"vertical"}(i.type,t,r),void 0!==r&&r!==i.orient&&Ht(Pt.orientOverridden(i.orient,r)),void 0===se(i.opacity,Zo("opacity",i,n))&&(i.opacity=function(e,t){if(R([ge,xe,we,Ce],e)&&!ti(t))return.7;return}(i.type,t)),void 0===i.filled&&(i.filled=function(e,t){const n=Zo("filled",e,t),i=e.type;return se(n,i!==ge&&i!==me&&i!==be)}(i,n)),void 0===(i.cursor||Zo("cursor",i,n))&&(i.cursor=function(e,t,n){if(t.href||e.href||Zo("href",e,n))return"pointer";return e.cursor}(i,t,n)),i}class Ud extends If{constructor(e,t,n,i={},r,o,a){super(e,"unit",t,n,o,r,void 0,e.view),this.fit=a,this.specifiedScales={},this.specifiedAxes={},this.specifiedLegends={},this.specifiedProjection={},this.selection={},this.children=[],this.initSize(Object.assign({},i,e.width?{width:e.width}:{},e.height?{height:e.height}:{}));const s=Se(e.mark)?e.mark.type:e.mark,u=this.encoding=ii(function(e,t){return Ed(e,t)}(e.encoding||{},r),s);this.markDef=Pd(e.mark,u,o),this.stack=kr(s,u,this.config.stack),this.specifiedScales=this.initScales(s,u),this.specifiedAxes=this.initAxes(u),this.specifiedLegends=this.initLegend(u),this.specifiedProjection=e.projection,this.selection=e.selection}get hasProjection(){const{encoding:e}=this,t=this.mark===Fe,n=e&&ht.some(t=>wn(e[t]));return t||n}scaleDomain(e){const t=this.specifiedScales[e];return t?t.domain:void 0}axis(e){return this.specifiedAxes[e]}legend(e){return this.specifiedLegends[e]}initScales(e,t){return _t.reduce((e,n)=>{let i,r;const o=t[n];return wn(o)?(i=o,r=o.scale):An(o)&&(i=o.condition,r=o.condition.scale),i&&(e[n]=r||{}),e},{})}initAxes(e){return[We,He].reduce((t,n)=>{const i=e[n];if(wn(i)||n===We&&wn(e.x2)||n===He&&wn(e.y2)){const e=wn(i)?i.axis:null;null!==e&&(t[n]=Object.assign({},e))}return t},{})}initLegend(e){return Nt.reduce((t,n)=>{const i=e[n];if(i){const e=wn(i)?i.legend:An(i)?i.condition.legend:null;null!==e&&!1!==e&&function(e){switch(e){case Ze:case Ke:case et:case nt:case tt:case it:return!0;case rt:case ot:case at:return!1}}(n)&&(t[n]=Object.assign({},e))}return t},{})}parseData(){this.component.data=Od(this)}parseLayoutSize(){!function(e){const t=e.component.layoutSize;if(!t.explicit.width){const n=Ad(e,"width");t.set("width",n,!1)}if(!t.explicit.height){const n=Ad(e,"height");t.set("height",n,!1)}}(this)}parseSelections(){this.component.selection=function(e,t){const n={},i=e.config.selection;t&&(t=B(t));for(let r in t){if(!t.hasOwnProperty(r))continue;const o=t[r],a=Ne(i[o.type],["fields","encodings"]);for(const e in a)"encodings"===e&&o.fields||"fields"===e&&o.encodings||("mark"===e&&(o[e]=Object.assign({},a[e],o[e])),void 0!==o[e]&&!0!==o[e]||(o[e]=a[e]||o[e]));const u=n[r=Z(r)]=Object.assign({},o,{name:r,events:s(o.on)?wu(o.on,"scope"):o.on});bc(u,t=>{t.parse&&t.parse(e,o,u)})}return n}(this,this.selection)}parseMarkGroup(){this.component.mark=nd(this)}parseAxesAndHeaders(){var e;this.component.axes=(e=this,$t.reduce((t,n)=>(e.component.scales[n]&&e.axis(n)&&(t[n]=[Rd(n,e)]),t),{}))}assembleSelectionTopLevelSignals(e){return function(e,t){let n=!1;nc(e,(i,r)=>{const o=i.name,a=u(o+Xu);t.filter(e=>e.name===o).length||t.push({name:i.name,update:`${ec}(${a}`+("global"===i.resolve?")":`, ${u(i.resolve)})`)}),n=!0,r.topLevelSignals&&(t=r.topLevelSignals(e,i,t)),bc(i,n=>{n.topLevelSignals&&(t=n.topLevelSignals(e,i,t))})}),n&&(t.filter(e=>"unit"===e.name).length||t.unshift({name:"unit",value:{},on:[{events:"mousemove",update:"isTuple(group()) ? group() : unit"}]}));return t}(this,e)}assembleSignals(){return[...No(this),...(e=this,t=[],nc(e,(n,i)=>{const r=n.name;let o=i.modifyExpr(e,n);t.push(...i.signals(e,n)),bc(n,i=>{i.signals&&(t=i.signals(e,n,t)),i.modifyExpr&&(o=i.modifyExpr(e,n,o))}),t.push({name:r+Zu,update:`modify(${u(n.name+Xu)}, ${o})`})}),t)];var e,t}assembleSelectionData(e){return function(e,t){return nc(e,e=>{t.filter(t=>t.name===e.name+Xu).length||t.push({name:e.name+Xu})}),t}(this,e)}assembleLayout(){return null}assembleLayoutSignals(){return bu(this)}assembleMarks(){let e=this.component.mark||[];return this.parent&&Mf(this.parent)||(e=xc(this,e)),e.map(this.correctDataNames)}getMapping(){return this.encoding}get mark(){return this.markDef.type}channelHasField(e){return ei(this.encoding,e)}fieldDef(e){return Mn(this.encoding[e])}}class Md extends Lf{constructor(e,t,n,i,r,o,a){super(e,"layer",t,n,o,r,e.resolve,e.view);const s=Object.assign({},i,e.width?{width:e.width}:{},e.height?{height:e.height}:{});this.initSize(s),this.children=e.layer.map((e,t)=>{if(Cr(e))return new Md(e,this,this.getName("layer_"+t),s,r,o,a);if($e(e))return new Ud(e,this,this.getName("layer_"+t),s,r,o,a);throw new Error(Pt.INVALID_SPEC)})}parseData(){this.component.data=Od(this);for(const e of this.children)e.parseData()}parseLayoutSize(){gd(this)}parseSelections(){this.component.selection={};for(const e of this.children)e.parseSelections(),V(e.component.selection).forEach(t=>{this.component.selection[t]=e.component.selection[t]})}parseMarkGroup(){for(const e of this.children)e.parseMarkGroup()}parseAxesAndHeaders(){!function(e){const{axes:t,resolve:n}=e.component,i={top:0,bottom:0,right:0,left:0};for(const i of e.children){i.parseAxesAndHeaders();for(const r of V(i.component.axes))n.axis[r]=il(e.component.resolve,r),"shared"===n.axis[r]&&(t[r]=_d(t[r],i.component.axes[r]),t[r]||(n.axis[r]="independent",delete t[r]))}for(const r of[We,He]){for(const o of e.children)if(o.component.axes[r]){if("independent"===n.axis[r]){t[r]=(t[r]||[]).concat(o.component.axes[r]);for(const e of o.component.axes[r]){const{value:t,explicit:n}=e.getWithExplicit("orient");if(i[t]>0&&!n){const n=jd[t];i[t]>i[n]&&e.set("orient",n,!1)}i[t]++}}delete o.component.axes[r]}if("independent"===n.axis[r]&&t[r]&&t[r].length>1)for(const e of t[r])e.get("grid")&&!e.explicit.grid&&(e.implicit.grid=!1)}}(this)}assembleSelectionTopLevelSignals(e){return this.children.reduce((e,t)=>t.assembleSelectionTopLevelSignals(e),e)}assembleSignals(){return this.children.reduce((e,t)=>e.concat(t.assembleSignals()),No(this))}assembleLayoutSignals(){return this.children.reduce((e,t)=>e.concat(t.assembleLayoutSignals()),bu(this))}assembleSelectionData(e){return this.children.reduce((e,t)=>t.assembleSelectionData(e),e)}assembleTitle(){let e=super.assembleTitle();if(e)return e;for(const t of this.children)if(e=t.assembleTitle())return e}assembleLayout(){return null}assembleMarks(){return function(e,t){for(const n of e.children)zf(n)&&(t=xc(n,t));return t}(this,M(this.children.map(e=>e.assembleMarks())))}assembleLegends(){return this.children.reduce((e,t)=>e.concat(t.assembleLegends()),Ol(this))}}class Ld extends $d{constructor(e,t,n,i,r){super(e,"repeat",t,n,r,i,e.resolve),e.resolve&&e.resolve.axis&&("shared"===e.resolve.axis.x||"shared"===e.resolve.axis.y)&&Ht(Pt.REPEAT_CANNOT_SHARE_AXIS),this.repeat=e.repeat,this.children=this._initChildren(e,this.repeat,i,r)}_initChildren(e,t,n,i){const r=[],a=!o(t)&&t.row||[n?n.row:null],s=!o(t)&&t.column||[n?n.column:null],u=o(t)&&t||[n?n.repeat:null];for(const t of u)for(const n of a)for(const o of s){const a=(t?`__repeat_repeat_${t}`:"")+(n?`__repeat_row_${n}`:"")+(o?`__repeat_column_${o}`:""),s={repeat:t,row:n,column:o};r.push(Id(e.spec,this,this.getName("child"+a),void 0,s,i,!1))}return r}parseLayoutSize(){yd(this)}assembleDefaultLayout(){const{repeat:e}=this,t=o(e)?void 0:e.column?e.column.length:1;return Object.assign({},t?{columns:t}:{},{bounds:"full",align:"all"})}}function Id(e,t,n,i,r,o,a){if(tn(e))return new Sd(e,t,n,r,o);if(Cr(e))return new Md(e,t,n,i,r,o,a);if($e(e))return new Ud(e,t,n,i,r,o,a);if(pr(e))return new Ld(e,t,n,r,o);if(function(e){return fr(e)||dr(e)||lr(e)}(e))return new Bd(e,t,n,r,o);throw new Error(Pt.INVALID_SPEC)}const qd=new class extends Fr{mapUnit(e,{config:t}){if(e.encoding){const{encoding:n,transform:i}=e,{bins:r,timeUnits:o,aggregate:a,groupby:s,encoding:u}=ni(n,t),c=[...i||[],...r,...o,...a.length?[{aggregate:a,groupby:s}]:[]];return Object.assign({},e,c.length>0?{transform:c}:{},{encoding:u})}return e}};const Wd=t;e.compile=function(e,t={}){t.logger&&qt(t.logger),t.fieldTitle&&Tn(t.fieldTitle);try{const n=yr(L({},t.config,e.config)),i=Rr(e,n),r=function(e,t,n=!0){const i=Object.assign({type:"pad"},Ur(t),Ur(e));return"fit"===i.type&&(n||(Ht(Pt.FIT_NON_SINGLE),i.type="pad")),i}(e.autosize,n.autosize,Cr(i)||$e(i)),o=Id(i,null,"",void 0,void 0,n,"fit"===r.type);return o.parse(),function(e,t){zl(e.sources);let n=0,i=0;for(let i=0;i{e.hasName()||(e.dataName=`source_${r++}`);const t=e.assemble();i(e,t)}),n.forEach(e=>{0===e.transform.length&&delete e.transform});let o=0;for(const[e,t]of n.entries())0!==(t.transform||[]).length||t.source||n.splice(o++,0,n.splice(e,1)[0]);for(const t of n)for(const n of t.transform||[])"lookup"===n.type&&(n.from=e.outputNodes[n.from].getSource());for(const e of n)e.name in t&&(e.values=t[e.name]);return n}(e.component.data,n)),a=e.assembleProjections(),s=e.assembleTitle(),u=e.assembleGroupStyle(),c=e.assembleGroupEncodeEntry(!0);let l=e.assembleLayoutSignals();return l=l.filter(e=>"width"!==e.name&&"height"!==e.name||void 0===e.value||(t[e.name]=+e.value,!1)),{spec:Object.assign({$schema:"https://vega.github.io/schema/vega/v5.json"},e.description?{description:e.description}:{},t,s?{title:s}:{},u?{style:u}:{},c?{encode:{update:c}}:{},{data:o},a.length>0?{projections:a}:{},e.assembleGroup([...l,...e.assembleSelectionTopLevelSignals([])]),r?{config:r}:{},i?{usermeta:i}:{})}}(o,function(e,t,n){return Object.assign({autosize:1===V(n).length&&n.type?n.type:n},Lr(t),Lr(e))}(e,n,r),e.datasets,e.usermeta)}finally{t.logger&&Wt(),t.fieldTitle&&Tn(jn)}},e.extractTransforms=function(e,t){return qd.map(e,{config:t})},e.normalize=Rr,e.version=Wd,Object.defineProperty(e,"__esModule",{value:!0})});