!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vega")):"function"==typeof define&&define.amd?define(["exports","vega"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).vegaLite={},e.vega)}(this,(function(e,t){"use strict";var n="5.23.0";function i(e){return J(e,"or")}function r(e){return J(e,"and")}function o(e){return J(e,"not")}function a(e,t){if(o(e))a(e.not,t);else if(r(e))for(const n of e.and)a(n,t);else if(i(e))for(const n of e.or)a(n,t);else t(e)}function s(e,t){return o(e)?{not:s(e.not,t)}:r(e)?{and:e.and.map((e=>s(e,t)))}:i(e)?{or:e.or.map((e=>s(e,t)))}:t(e)}const l=structuredClone;function c(e){throw new Error(e)}function u(e,n){const i={};for(const r of n)t.hasOwnProperty(e,r)&&(i[r]=e[r]);return i}function f(e,t){const n={...e};for(const e of t)delete n[e];return n}function d(e){if(t.isNumber(e))return e;const n=t.isString(e)?e:Q(e);if(n.length<250)return n;let i=0;for(let e=0;e1?t-1:0),i=1;i0===t?e:`[${e}]`)),r=e.map(((t,n)=>e.slice(0,n+1).join("")));for(const e of r)n.add(e)}return n}function k(e,t){return void 0===e||void 0===t||$(w(e),w(t))}function S(e){return 0===D(e).length}Set.prototype.toJSON=function(){return`Set(${[...this].map((e=>Q(e))).join(",")})`};const D=Object.keys,F=Object.values,O=Object.entries;function z(e){return!0===e||!1===e}function C(e){const t=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+t}function _(e,t){return o(e)?`!(${_(e.not,t)})`:r(e)?`(${e.and.map((e=>_(e,t))).join(") && (")})`:i(e)?`(${e.or.map((e=>_(e,t))).join(") || (")})`:t(e)}function P(e,t){if(0===t.length)return!0;const n=t.shift();return n in e&&P(e[n],t)&&delete e[n],S(e)}function N(e){return e.charAt(0).toUpperCase()+e.substr(1)}function A(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"datum";const i=t.splitAccessPath(e),r=[];for(let e=1;e<=i.length;e++){const o=`[${i.slice(0,e).map(t.stringValue).join("][")}]`;r.push(`${n}${o}`)}return r.join(" && ")}function T(e){return`${arguments.length>1&&void 0!==arguments[1]?arguments[1]:"datum"}[${t.stringValue(t.splitAccessPath(e).join("."))}]`}function j(e){return`datum['${e.replaceAll("'","\\'")}']`}function E(e){return e.replace(/(\[|\]|\.|'|")/g,"\\$1")}function M(e){return`${t.splitAccessPath(e).map(E).join("\\.")}`}function R(e,t,n){return e.replace(new RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),n)}function L(e){return`${t.splitAccessPath(e).join(".")}`}function q(e){return e?t.splitAccessPath(e).length:0}function U(){for(var e=arguments.length,t=new Array(e),n=0;nvoid 0!==e))}let W=42;function I(e){const t=++W;return e?String(e)+t:t}function B(e){return V(e)?e:`__${e}`}function V(e){return e.startsWith("__")}function H(e){if(void 0!==e)return(e%360+360)%360}function G(e){return!!t.isNumber(e)||!isNaN(e)&&!isNaN(parseFloat(e))}const Y=Object.getPrototypeOf(structuredClone({}));function X(e,t){if(e===t)return!0;if(e&&t&&"object"==typeof e&&"object"==typeof t){if(e.constructor.name!==t.constructor.name)return!1;let n,i;if(Array.isArray(e)){if(n=e.length,n!=t.length)return!1;for(i=n;0!=i--;)if(!X(e[i],t[i]))return!1;return!0}if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const n of e.entries())if(!t.has(n[0]))return!1;for(const n of e.entries())if(!X(n[1],t.get(n[0])))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e.entries())if(!t.has(n[0]))return!1;return!0}if(ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)){if(n=e.length,n!=t.length)return!1;for(i=n;0!=i--;)if(e[i]!==t[i])return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf&&e.valueOf!==Y.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString&&e.toString!==Y.toString)return e.toString()===t.toString();const r=Object.keys(e);if(n=r.length,n!==Object.keys(t).length)return!1;for(i=n;0!=i--;)if(!Object.prototype.hasOwnProperty.call(t,r[i]))return!1;for(i=n;0!=i--;){const n=r[i];if(!X(e[n],t[n]))return!1}return!0}return e!=e&&t!=t}function Q(e){const t=[];return function e(n){if(n&&n.toJSON&&"function"==typeof n.toJSON&&(n=n.toJSON()),void 0===n)return;if("number"==typeof n)return isFinite(n)?""+n:"null";if("object"!=typeof n)return JSON.stringify(n);let i,r;if(Array.isArray(n)){for(r="[",i=0;ihn(e[t])?C(`_${t}_${O(e[t])}`):C(`_${t}_${e[t]}`))).join("")}function mn(e){return!0===e||gn(e)&&!e.binned}function pn(e){return"binned"===e||gn(e)&&!0===e.binned}function gn(e){return t.isObject(e)}function hn(e){return J(e,"param")}function yn(e){switch(e){case K:case Z:case xe:case he:case ye:case ve:case De:case we:case ke:case Se:case be:return 6;case Fe:return 4;default:return 10}}function vn(e){return J(e,"expr")}function bn(e){let{level:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{level:0};const n=D(e||{}),i={};for(const r of n)i[r]=0===t?Cn(e[r]):bn(e[r],{level:t-1});return i}function xn(e){const{anchor:t,frame:n,offset:i,orient:r,angle:o,limit:a,color:s,subtitleColor:l,subtitleFont:c,subtitleFontSize:f,subtitleFontStyle:d,subtitleFontWeight:m,subtitleLineHeight:p,subtitlePadding:g,...h}=e,y={...t?{anchor:t}:{},...n?{frame:n}:{},...i?{offset:i}:{},...r?{orient:r}:{},...void 0!==o?{angle:o}:{},...void 0!==a?{limit:a}:{}},v={...l?{subtitleColor:l}:{},...c?{subtitleFont:c}:{},...f?{subtitleFontSize:f}:{},...d?{subtitleFontStyle:d}:{},...m?{subtitleFontWeight:m}:{},...p?{subtitleLineHeight:p}:{},...g?{subtitlePadding:g}:{}};return{titleMarkConfig:{...h,...s?{fill:s}:{}},subtitleMarkConfig:u(e,["align","baseline","dx","dy","limit"]),nonMarkTitleProperties:y,subtitle:v}}function $n(e){return t.isString(e)||t.isArray(e)&&t.isString(e[0])}function wn(e){return J(e,"signal")}function kn(e){return J(e,"step")}function Sn(e){return!t.isArray(e)&&(J(e,"field")&&J(e,"data"))}const Dn=D({aria:1,description:1,ariaRole:1,ariaRoleDescription:1,blend:1,opacity:1,fill:1,fillOpacity:1,stroke:1,strokeCap:1,strokeWidth:1,strokeOpacity:1,strokeDash:1,strokeDashOffset:1,strokeJoin:1,strokeOffset:1,strokeMiterLimit:1,startAngle:1,endAngle:1,padAngle:1,innerRadius:1,outerRadius: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,lineBreak:1,lineHeight:1,cursor:1,href:1,tooltip:1,cornerRadius:1,cornerRadiusTopLeft:1,cornerRadiusTopRight:1,cornerRadiusBottomLeft:1,cornerRadiusBottomRight:1,aspect:1,width:1,height:1,url:1,smooth:1}),Fn={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},On=["cornerRadius","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight"];function zn(e){const n=t.isArray(e.condition)?e.condition.map(_n):_n(e.condition);return{...Cn(e),condition:n}}function Cn(e){if(vn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return e}function _n(e){if(vn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return e}function Pn(e){if(vn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return wn(e)?e:void 0!==e?{value:e}:void 0}function Nn(e){return wn(e)?e.signal:t.stringValue(e.value)}function An(e){return wn(e)?e.signal:null==e?null:t.stringValue(e)}function Tn(e,t,n){for(const i of n){const n=Mn(i,t.markDef,t.config);void 0!==n&&(e[i]=Pn(n))}return e}function jn(e){return[].concat(e.type,e.style??[])}function En(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const{vgChannel:r,ignoreVgConfig:o}=i;return r&&J(t,r)?t[r]:void 0!==t[e]?t[e]:!o||r&&r!==e?Mn(e,t,n,i):void 0}function Mn(e,t,n){let{vgChannel:i}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const r=Rn(e,t,n.style);return U(i?r:void 0,r,i?n[t.type][i]:void 0,n[t.type][e],i?n.mark[i]:n.mark[e])}function Rn(e,t,n){return Ln(e,jn(t),n)}function Ln(e,n,i){let r;n=t.array(n);for(const t of n){const n=i[t];J(n,e)&&(r=n[e])}return r}function qn(e,n){return t.array(e).reduce(((e,t)=>(e.field.push(ma(t,n)),e.order.push(t.sort??"ascending"),e)),{field:[],order:[]})}function Un(e,t){const n=[...e];return t.forEach((e=>{for(const t of n)if(X(t,e))return;n.push(e)})),n}function Wn(e,n){return X(e,n)||!n?e:e?[...t.array(e),...t.array(n)].join(", "):n}function In(e,t){const n=e.value,i=t.value;if(null==n||null===i)return{explicit:e.explicit,value:null};if(($n(n)||wn(n))&&($n(i)||wn(i)))return{explicit:e.explicit,value:Wn(n,i)};if($n(n)||wn(n))return{explicit:e.explicit,value:n};if($n(i)||wn(i))return{explicit:e.explicit,value:i};if(!($n(n)||wn(n)||$n(i)||wn(i)))return{explicit:e.explicit,value:Un(n,i)};throw new Error("It should never reach here")}function Bn(e){return`Invalid specification ${Q(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`}const Vn='Autosize "fit" only works for single views and layered views.';function Hn(e){return`${"width"==e?"Width":"Height"} "container" only works for single views and layered views.`}function Gn(e){return`${"width"==e?"Width":"Height"} "container" only works well with autosize "fit" or "fit-${"width"==e?"x":"y"}".`}function Yn(e){return e?`Dropping "fit-${e}" because spec has discrete ${st(e)}.`:'Dropping "fit" because spec has discrete size.'}function Xn(e){return`Unknown field for ${e}. Cannot calculate view size.`}function Qn(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`}function Jn(e,t){return`Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${t}").`}function Kn(e){return`Selection not supported for ${e} yet.`}const Zn="The same selection must be used to override scale domains in a layered view.";function ei(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`}const ti="Animation involving facet, layer, or concat is currently unsupported.";function ni(e,t,n){return`An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.`}function ii(e){return`Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.`}function ri(e){return`${e}Offset dropped because ${e} is continuous`}function oi(e){return`Invalid field type "${e}".`}function ai(e,t){const{fill:n,stroke:i}=t;return`Dropping color ${e} as the plot also has ${n&&i?"fill and stroke":n?"fill":"stroke"}.`}function si(e,t){return`Dropping ${Q(e)} from channel "${t}" since it does not contain any data field, datum, value, or signal.`}function li(e,t,n){return`${e} dropped as it is incompatible with "${t}".`}function ci(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`}function ui(e){return`${e} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`}function fi(e,t){return`Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${"ordinal"===t?"order":"magnitude"}.`}function di(e){return`Using unaggregated domain with raw field has no effect (${Q(e)}).`}function mi(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`}function pi(e){return`Unaggregated domain is currently unsupported for log scale (${Q(e)}).`}function gi(e,t,n){return`${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`}function hi(e){return`The step for "${e}" is dropped because the ${"width"===e?"x":"y"} is continuous.`}const yi="Domains that should be unioned has conflicting sort properties. Sort will be set to true.";function vi(e,t){return`Invalid ${e}: ${Q(t)}.`}function bi(e){return`1D error band does not support ${e}.`}function xi(e){return`Channel ${e} is required for "binned" bin.`}const $i=t.logger(t.Warn);let wi=$i;function ki(){wi.error(...arguments)}function Si(){wi.warn(...arguments)}function Di(e){if(e&&t.isObject(e))for(const t of Ai)if(J(e,t))return!0;return!1}const Fi=["january","february","march","april","may","june","july","august","september","october","november","december"],Oi=Fi.map((e=>e.substr(0,3))),zi=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Ci=zi.map((e=>e.substr(0,3)));function _i(e,n){const i=[];if(n&&void 0!==e.day&&D(e).length>1&&(Si(function(e){return`Dropping day from datetime ${Q(e)} as day cannot be combined with other units.`}(e)),delete(e=l(e)).day),void 0!==e.year?i.push(e.year):i.push(2012),void 0!==e.month){const r=n?function(e){if(G(e)&&(e=+e),t.isNumber(e))return e-1;{const t=e.toLowerCase(),n=Fi.indexOf(t);if(-1!==n)return n;const i=t.substr(0,3),r=Oi.indexOf(i);if(-1!==r)return r;throw new Error(vi("month",e))}}(e.month):e.month;i.push(r)}else if(void 0!==e.quarter){const r=n?function(e){if(G(e)&&(e=+e),t.isNumber(e))return e>4&&Si(vi("quarter",e)),e-1;throw new Error(vi("quarter",e))}(e.quarter):e.quarter;i.push(t.isNumber(r)?3*r:`${r}*3`)}else i.push(0);if(void 0!==e.date)i.push(e.date);else if(void 0!==e.day){const r=n?function(e){if(G(e)&&(e=+e),t.isNumber(e))return e%7;{const t=e.toLowerCase(),n=zi.indexOf(t);if(-1!==n)return n;const i=t.substr(0,3),r=Ci.indexOf(i);if(-1!==r)return r;throw new Error(vi("day",e))}}(e.day):e.day;i.push(t.isNumber(r)?r+1:`${r}+1`)}else i.push(1);for(const t of["hours","minutes","seconds","milliseconds"]){const n=e[t];i.push(void 0===n?0:n)}return i}function Pi(e){const t=_i(e,!0).join(", ");return e.utc?`utc(${t})`:`datetime(${t})`}const Ni={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},Ai=D(Ni);function Ti(e){return t.isObject(e)?e.binned:ji(e)}function ji(e){return e&&e.startsWith("binned")}function Ei(e){return e.startsWith("utc")}const Mi={"year-month":"%b %Y ","year-month-date":"%b %d, %Y "};function Ri(e){return Ai.filter((t=>qi(e,t)))}function Li(e){const t=Ri(e);return t[t.length-1]}function qi(e,t){const n=e.indexOf(t);return!(n<0)&&(!(n>0&&"seconds"===t&&"i"===e.charAt(n-1))&&(!(e.length>n+3&&"day"===t&&"o"===e.charAt(n+3))&&!(n>0&&"year"===t&&"f"===e.charAt(n-1))))}function Ui(e,t){let{end:n}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{end:!1};const i=A(t),r=Ei(e)?"utc":"";let o;const a={};for(const t of Ai)qi(e,t)&&(a[t]="quarter"===(s=t)?`(${r}quarter(${i})-1)`:`${r}${s}(${i})`,o=t);var s;return n&&(a[o]+="+1"),function(e){const t=_i(e,!1).join(", ");return e.utc?`utc(${t})`:`datetime(${t})`}(a)}function Wi(e){if(!e)return;return`timeUnitSpecifier(${Q(Ri(e))}, ${Q(Mi)})`}function Ii(e){if(!e)return;let n;return t.isString(e)?n=ji(e)?{unit:e.substring(6),binned:!0}:{unit:e}:t.isObject(e)&&(n={...e,...e.unit?{unit:e.unit}:{}}),Ei(n.unit)&&(n.utc=!0,n.unit=n.unit.substring(3)),n}function Bi(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e=>e;const n=Ii(e),i=Li(n.unit);if(i&&"day"!==i){const e={year:2001,month:1,date:1,hours:0,minutes:0,seconds:0,milliseconds:0},{step:r,part:o}=Hi(i,n.step);return`${t(Pi({...e,[o]:+e[o]+r}))} - ${t(Pi(e))}`}}const Vi={year:1,month:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1};function Hi(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(function(e){return t.hasOwnProperty(Vi,e)}(e))return{part:e,step:n};switch(e){case"day":case"dayofyear":return{part:"date",step:n};case"quarter":return{part:"month",step:3*n};case"week":return{part:"date",step:7*n}}}function Gi(e){return!!e?.field&&void 0!==e.equal}function Yi(e){return!!e?.field&&void 0!==e.lt}function Xi(e){return!!e?.field&&void 0!==e.lte}function Qi(e){return!!e?.field&&void 0!==e.gt}function Ji(e){return!!e?.field&&void 0!==e.gte}function Ki(e){if(e?.field){if(t.isArray(e.range)&&2===e.range.length)return!0;if(wn(e.range))return!0}return!1}function Zi(e){return!!e?.field&&(t.isArray(e.oneOf)||t.isArray(e.in))}function er(e){return Zi(e)||Gi(e)||Ki(e)||Yi(e)||Qi(e)||Xi(e)||Ji(e)}function tr(e,t){return _a(e,{timeUnit:t,wrapTime:!0})}function nr(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const{field:n}=e,i=Ii(e.timeUnit),{unit:r,binned:o}=i||{},a=ma(e,{expr:"datum"}),s=r?`time(${o?a:Ui(r,n)})`:a;if(Gi(e))return`${s}===${tr(e.equal,r)}`;if(Yi(e)){return`${s}<${tr(e.lt,r)}`}if(Qi(e)){return`${s}>${tr(e.gt,r)}`}if(Xi(e)){return`${s}<=${tr(e.lte,r)}`}if(Ji(e)){return`${s}>=${tr(e.gte,r)}`}if(Zi(e))return`indexof([${function(e,t){return e.map((e=>tr(e,t)))}(e.oneOf,r).join(",")}], ${s}) !== -1`;if(function(e){return!!e?.field&&void 0!==e.valid}(e))return ir(s,e.valid);if(Ki(e)){const{range:n}=bn(e),i=wn(n)?{signal:`${n.signal}[0]`}:n[0],o=wn(n)?{signal:`${n.signal}[1]`}:n[1];if(null!==i&&null!==o&&t)return"inrange("+s+", ["+tr(i,r)+", "+tr(o,r)+"])";const a=[];return null!==i&&a.push(`${s} >= ${tr(i,r)}`),null!==o&&a.push(`${s} <= ${tr(o,r)}`),a.length>0?a.join(" && "):"true"}throw new Error(`Invalid field predicate: ${Q(e)}`)}function ir(e){return!(arguments.length>1&&void 0!==arguments[1])||arguments[1]?`isValid(${e}) && isFinite(+${e})`:`!isValid(${e}) || !isFinite(+${e})`}function rr(e){return er(e)&&e.timeUnit?{...e,timeUnit:Ii(e.timeUnit)}:e}function or(e){return"quantitative"===e||"temporal"===e}function ar(e){return"ordinal"===e||"nominal"===e}const sr="quantitative",lr="ordinal",cr="temporal",ur="nominal",fr="geojson";const dr={LINEAR:"linear",LOG:"log",POW:"pow",SQRT:"sqrt",SYMLOG:"symlog",IDENTITY:"identity",SEQUENTIAL:"sequential",TIME:"time",UTC:"utc",QUANTILE:"quantile",QUANTIZE:"quantize",THRESHOLD:"threshold",BIN_ORDINAL:"bin-ordinal",ORDINAL:"ordinal",POINT:"point",BAND:"band"},mr={linear:"numeric",log:"numeric",pow:"numeric",sqrt:"numeric",symlog:"numeric",identity:"numeric",sequential:"numeric",time:"time",utc:"time",ordinal:"ordinal","bin-ordinal":"bin-ordinal",point:"ordinal-position",band:"ordinal-position",quantile:"discretizing",quantize:"discretizing",threshold:"discretizing"};function pr(e,t){const n=mr[e],i=mr[t];return n===i||"ordinal-position"===n&&"time"===i||"ordinal-position"===i&&"time"===n}const gr={linear:0,log:1,pow:1,sqrt:1,symlog:1,identity:1,sequential:1,time:0,utc:0,point:10,band:11,ordinal:0,"bin-ordinal":0,quantile:0,quantize:0,threshold:0};function hr(e){return gr[e]}const yr=new Set(["linear","log","pow","sqrt","symlog"]),vr=new Set([...yr,"time","utc"]);function br(e){return yr.has(e)}const xr=new Set(["quantile","quantize","threshold"]),$r=new Set([...vr,...xr,"sequential","identity"]),wr=new Set(["ordinal","bin-ordinal","point","band"]);function kr(e){return wr.has(e)}function Sr(e){return $r.has(e)}function Dr(e){return vr.has(e)}function Fr(e){return xr.has(e)}function Or(e){return J(e,"param")}const{type:zr,domain:Cr,range:_r,rangeMax:Pr,rangeMin:Nr,scheme:Ar,...Tr}={type:1,domain:1,domainMax:1,domainMin:1,domainMid:1,domainRaw:1,align:1,range:1,rangeMax:1,rangeMin: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},jr=D(Tr);function Er(e,t){switch(t){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!["point","band","identity"].includes(e);case"bins":return!["point","band","identity","ordinal"].includes(e);case"round":return Dr(e)||"band"===e||"point"===e;case"padding":case"rangeMin":case"rangeMax":return Dr(e)||["point","band"].includes(e);case"paddingOuter":case"align":return["point","band"].includes(e);case"paddingInner":return"band"===e;case"domainMax":case"domainMid":case"domainMin":case"domainRaw":case"clamp":return Dr(e);case"nice":return Dr(e)||"quantize"===e||"threshold"===e;case"exponent":return"pow"===e;case"base":return"log"===e;case"constant":return"symlog"===e;case"zero":return Sr(e)&&!p(["log","time","utc","threshold","quantile"],e)}}function Mr(e,t){switch(t){case"interpolate":case"scheme":case"domainMid":return We(e)?void 0:`Cannot use the scale property "${t}" with non-color channel.`;case"align":case"type":case"bins":case"domain":case"domainMax":case"domainMin":case"domainRaw":case"range":case"base":case"exponent":case"constant":case"nice":case"padding":case"paddingInner":case"paddingOuter":case"rangeMax":case"rangeMin":case"reverse":case"round":case"clamp":case"zero":return}}const Rr={arc:"arc",area:"area",bar:"bar",image:"image",line:"line",point:"point",rect:"rect",rule:"rule",text:"text",tick:"tick",trail:"trail",circle:"circle",square:"square",geoshape:"geoshape"},Lr=Rr.arc,qr=Rr.area,Ur=Rr.bar,Wr=Rr.image,Ir=Rr.line,Br=Rr.point,Vr=Rr.rect,Hr=Rr.rule,Gr=Rr.text,Yr=Rr.tick,Xr=Rr.trail,Qr=Rr.circle,Jr=Rr.square,Kr=Rr.geoshape;function Zr(e){return["line","area","trail"].includes(e)}function eo(e){return["rect","bar","image","arc","tick"].includes(e)}const to=new Set(D(Rr));function no(e){return J(e,"type")}const io=["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit","fill","fillOpacity"],ro=D({color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBandSize:1,timeUnitBandPosition:1}),oo=["binSpacing","continuousBandSize","discreteBandSize","minBandSize"],ao={area:["line","point"],bar:oo,rect:oo,line:["point"],tick:["bandSize","thickness",...oo]},so=D({mark:1,arc:1,area:1,bar:1,circle:1,image:1,line:1,point:1,rect:1,rule:1,square:1,text:1,tick:1,trail:1,geoshape:1});function lo(e){return J(e,"band")}const co={horizontal:["cornerRadiusTopRight","cornerRadiusBottomRight"],vertical:["cornerRadiusTopLeft","cornerRadiusTopRight"]},uo={binSpacing:0,continuousBandSize:5,minBandSize:.25,timeUnitBandPosition:.5},fo={...uo,binSpacing:1},mo={...uo,thickness:1};function po(e,t){let{isPath:n}=t;return void 0===e||"break-paths-show-path-domains"===e?n?"break-paths-show-domains":"filter":null===e?"show":e}function go(e){let{markDef:t,config:n,scaleChannel:i,scaleType:r,isCountAggregate:o}=e;if(!r||!Sr(r)||o)return"always-valid";const a=po(En("invalid",t,n),{isPath:Zr(t.type)}),s=n.scale?.invalid?.[i];return void 0!==s?"show":a}function ho(e){let{scaleName:t,scale:n,mode:i}=e;const r=`domain('${t}')`;if(!n||!t)return;const o=`${r}[0]`,a=`peek(${r})`,s=n.domainHasZero();if("definitely"===s)return{scale:t,value:0};if("maybe"===s){return{signal:`scale('${t}', inrange(0, ${r}) ? 0 : ${"zeroOrMin"===i?o:a})`}}return{signal:`scale('${t}', ${"zeroOrMin"===i?o:a})`}}function yo(e){let{scaleChannel:t,channelDef:n,scale:i,scaleName:r,markDef:o,config:a}=e;const s=i?.get("type"),l=wa(n),c=go({scaleChannel:t,markDef:o,config:a,scaleType:s,isCountAggregate:cn(l?.aggregate)});if(l&&"show"===c){const e=a.scale.invalid?.[t]??"zero-or-min";return{test:ir(ma(l,{expr:"datum"}),!1),...vo(e,i,r)}}}function vo(e,n,i){if(r=e,t.isObject(r)&&"value"in r){const{value:t}=e;return wn(t)?{signal:t.signal}:{value:t}}var r;return ho({scale:n,scaleName:i,mode:"zeroOrMin"})}function bo(e){const{channel:t,channelDef:n,markDef:i,scale:r,scaleName:o,config:a}=e,s=rt(t),l=wo(e),c=yo({scaleChannel:s,channelDef:n,scale:r,scaleName:o,markDef:i,config:a});return void 0!==c?[c,l]:l}function xo(e,t,n,i){const r={};if(t&&(r.scale=t),ta(e)){const{datum:t}=e;Di(t)?r.signal=Pi(t):wn(t)?r.signal=t.signal:vn(t)?r.signal=t.expr:r.value=t}else r.field=ma(e,n);if(i){const{offset:e,band:t}=i;e&&(r.offset=e),t&&(r.band=t)}return r}function $o(e){let{scaleName:t,fieldOrDatumDef:n,fieldOrDatumDef2:i,offset:r,startSuffix:o,endSuffix:a="end",bandPosition:s=.5}=e;const l=!wn(s)&&01&&void 0!==arguments[1]?arguments[1]:{},n=e.field;const i=t.prefix;let r=t.suffix,o="";if(function(e){return"count"===e.aggregate}(e))n=B("count");else{let i;if(!t.nofn)if(function(e){return J(e,"op")}(e))i=e.op;else{const{bin:a,aggregate:s,timeUnit:l}=e;mn(a)?(i=dn(a),r=(t.binSuffix??"")+(t.suffix??"")):s?an(s)?(o=`["${n}"]`,n=`argmax_${s.argmax}`):on(s)?(o=`["${n}"]`,n=`argmin_${s.argmin}`):i=String(s):l&&!Ti(l)&&(i=function(e){const{utc:t,...n}=Ii(e);return n.unit?(t?"utc":"")+D(n).map((e=>C(`${"unit"===e?"":`_${e}_`}${n[e]}`))).join(""):(t?"utc":"")+"timeunit"+D(n).map((e=>C(`_${e}_${n[e]}`))).join("")}(l),r=(!["range","mid"].includes(t.binSuffix)&&t.binSuffix||"")+(t.suffix??""))}i&&(n=n?`${i}_${n}`:i)}return r&&(n=`${n}_${r}`),i&&(n=`${i}_${n}`),t.forAs?L(n):t.expr?T(n,t.expr)+o:M(n)+o}function pa(e){switch(e.type){case"nominal":case"ordinal":case"geojson":return!0;case"quantitative":return Zo(e)&&!!e.bin;case"temporal":return!1}throw new Error(oi(e.type))}const ga=(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(an(t))return`${r} for argmax(${t.argmax})`;if(on(t))return`${r} for argmin(${t.argmin})`;const o=i&&!Ti(i)?Ii(i):void 0,a=t||o?.unit||o?.maxbins&&"timeunit"||mn(n)&&"bin";return a?`${a.toUpperCase()}(${r})`:r}(e);default:return function(e,t){const{field:n,bin:i,timeUnit:r,aggregate:o}=e;if("count"===o)return t.countTitle;if(mn(i))return`${n} (binned)`;if(r&&!Ti(r)){const e=Ii(r)?.unit;if(e)return`${n} (${Ri(e).join("-")})`}else if(o)return an(o)?`${n} for max ${o.argmax}`:on(o)?`${n} for min ${o.argmin}`:`${N(o)} of ${n}`;return n}(e,t)}};let ha=ga;function ya(e){ha=e}function va(e,t,n){let{allowDisabling:i,includeDefault:r=!0}=n;const o=ba(e)?.title;if(!Zo(e))return o??e.title;const a=e,s=r?xa(a,t):void 0;return i?U(o,a.title,s):o??a.title??s}function ba(e){return ca(e)&&e.axis?e.axis:ua(e)&&e.legend?e.legend:Wo(e)&&e.header?e.header:void 0}function xa(e,t){return ha(e,t)}function $a(e){if(fa(e)){const{format:t,formatType:n}=e;return{format:t,formatType:n}}{const t=ba(e)??{},{format:n,formatType:i}=t;return{format:n,formatType:i}}}function wa(e){return Zo(e)?e:Jo(e)?e.condition:void 0}function ka(e){return oa(e)?e:Ko(e)?e.condition:void 0}function Sa(e,n,i){let r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(t.isString(e)||t.isNumber(e)||t.isBoolean(e)){return Si(function(e,t,n){return`Channel ${e} is a ${t}. Converted to {value: ${Q(n)}}.`}(n,t.isString(e)?"string":t.isNumber(e)?"number":"boolean",e)),{value:e}}return oa(e)?Da(e,n,i,r):Ko(e)?{...e,condition:Da(e.condition,n,i,r)}:e}function Da(e,n,i,r){if(fa(e)){const{format:t,formatType:o,...a}=e;if(So(o)&&!i.customFormatTypes)return Si(ii(n)),Da(a,n,i,r)}else{const t=ca(e)?"axis":ua(e)?"legend":Wo(e)?"header":null;if(t&&e[t]){const{format:o,formatType:a,...s}=e[t];if(So(a)&&!i.customFormatTypes)return Si(ii(n)),Da({...e,[t]:s},n,i,r)}}return Zo(e)?Fa(e,n,r):function(e){let n=e.type;if(n)return e;const{datum:i}=e;return n=t.isNumber(i)?"quantitative":t.isString(i)?"nominal":Di(i)?"temporal":void 0,{...e,type:n}}(e)}function Fa(e,n){let{compositeMark:i=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{aggregate:r,timeUnit:o,bin:a,field:s}=e,l={...e};if(i||!r||sn(r)||an(r)||on(r)||(Si(function(e){return`Invalid aggregation operator "${e}".`}(r)),delete l.aggregate),o&&(l.timeUnit=Ii(o)),s&&(l.field=`${s}`),mn(a)&&(l.bin=Oa(a,n)),pn(a)&&!_t(n)&&Si(function(e){return`Channel ${e} should not be used with "binned" bin.`}(n)),aa(l)){const{type:e}=l,t=function(e){if(e)switch(e=e.toLowerCase()){case"q":case sr:return"quantitative";case"t":case cr:return"temporal";case"o":case lr:return"ordinal";case"n":case ur:return"nominal";case fr:return"geojson"}}(e);e!==t&&(l.type=t),"quantitative"!==e&&cn(r)&&(Si(function(e,t){return`Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.`}(e,r)),l.type="quantitative")}else if(!it(n)){const e=function(e,n){switch(n){case"latitude":case"longitude":return"quantitative";case"row":case"column":case"facet":case"shape":case"strokeDash":return"nominal";case"order":return"ordinal"}if(Vo(e)&&t.isArray(e.sort))return"ordinal";const{aggregate:i,bin:r,timeUnit:o}=e;if(o)return"temporal";if(r||i&&!an(i)&&!on(i))return"quantitative";if(la(e)&&e.scale?.type)switch(mr[e.scale.type]){case"numeric":case"discretizing":return"quantitative";case"time":return"temporal"}return"nominal"}(l,n);l.type=e}if(aa(l)){const{compatible:e,warning:t}=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 K:case Z:case ee:return pa(e)?za:{compatible:!1,warning:ci(t)};case te:case ne:case oe:case ae:case he:case ye:case ve:case Oe:case Ce:case _e:case Pe:case Ne:case Ae:case $e:case ce:case se:case Te:return za;case de:case pe:case fe:case me:return n!==sr?{compatible:!1,warning:`Channel ${t} should be used with a quantitative field only, not ${e.type} field.`}:za;case we:case ke:case Se:case De:case xe:case ue:case le:case ie:case re:case ge:return"nominal"!==n||e.sort?za:{compatible:!1,warning:`Channel ${t} should not be used with an unsorted discrete field.`};case be:case Fe:return pa(e)||la(i=e)&&Fr(i.scale?.type)?za:{compatible:!1,warning:ui(t)};case ze:return"nominal"!==e.type||"sort"in e?za:{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}}var i}(l,n)||{};!1===e&&Si(t)}if(Vo(l)&&t.isString(l.sort)){const{sort:e}=l;if(Ro(e))return{...l,sort:{encoding:e}};const t=e.substring(1);if("-"===e.charAt(0)&&Ro(t))return{...l,sort:{encoding:t,order:"descending"}}}if(Wo(l)){const{header:e}=l;if(e){const{orient:t,...n}=e;if(t)return{...l,header:{...n,labelOrient:e.labelOrient||t,titleOrient:e.titleOrient||t}}}}return l}function Oa(e,n){return t.isBoolean(e)?{maxbins:yn(n)}:"binned"===e?{binned:!0}:e.maxbins||e.step?e:{...e,maxbins:yn(n)}}const za={compatible:!0};function Ca(e){const{formatType:t}=$a(e);return"time"===t||!t&&((n=e)&&("temporal"===n.type||Zo(n)&&!!n.timeUnit));var n}function _a(e,n){let{timeUnit:i,type:r,wrapTime:o,undefinedIfExprNotRequired:a}=n;const s=i&&Ii(i)?.unit;let l,c=s||"temporal"===r;return vn(e)?l=e.expr:wn(e)?l=e.signal:Di(e)?(c=!0,l=Pi(e)):(t.isString(e)||t.isNumber(e))&&c&&(l=`datetime(${Q(e)})`,function(e){return t.hasOwnProperty(Ni,e)}(s)&&(t.isNumber(e)&&e<1e4||t.isString(e)&&isNaN(Date.parse(e)))&&(l=Pi({[s]:e}))),l?o&&c?`time(${l})`:l:a?void 0:Q(e)}function Pa(e,t){const{type:n}=e;return t.map((t=>{const i=_a(t,{timeUnit:Zo(e)&&!Ti(e.timeUnit)?e.timeUnit:void 0,type:n,undefinedIfExprNotRequired:!0});return void 0!==i?{signal:i}:t}))}function Na(e,t){return mn(e.bin)?Qt(t)&&["ordinal","nominal"].includes(e.type):(console.warn("Only call this method for binned field defs."),!1)}const Aa={labelAlign:{part:"labels",vgProp:"align"},labelBaseline:{part:"labels",vgProp:"baseline"},labelColor:{part:"labels",vgProp:"fill"},labelFont:{part:"labels",vgProp:"font"},labelFontSize:{part:"labels",vgProp:"fontSize"},labelFontStyle:{part:"labels",vgProp:"fontStyle"},labelFontWeight:{part:"labels",vgProp:"fontWeight"},labelOpacity:{part:"labels",vgProp:"opacity"},labelOffset:null,labelPadding:null,gridColor:{part:"grid",vgProp:"stroke"},gridDash:{part:"grid",vgProp:"strokeDash"},gridDashOffset:{part:"grid",vgProp:"strokeDashOffset"},gridOpacity:{part:"grid",vgProp:"opacity"},gridWidth:{part:"grid",vgProp:"strokeWidth"},tickColor:{part:"ticks",vgProp:"stroke"},tickDash:{part:"ticks",vgProp:"strokeDash"},tickDashOffset:{part:"ticks",vgProp:"strokeDashOffset"},tickOpacity:{part:"ticks",vgProp:"opacity"},tickSize:null,tickWidth:{part:"ticks",vgProp:"strokeWidth"}};function Ta(e){return e?.condition}const ja=["domain","grid","labels","ticks","title"],Ea={grid:"grid",gridCap:"grid",gridColor:"grid",gridDash:"grid",gridDashOffset:"grid",gridOpacity:"grid",gridScale:"grid",gridWidth:"grid",orient:"main",bandPosition:"both",aria:"main",description:"main",domain:"main",domainCap:"main",domainColor:"main",domainDash:"main",domainDashOffset:"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",labelFontStyle:"main",labelFontWeight:"main",labelLimit:"main",labelLineHeight:"main",labelOffset:"main",labelOpacity:"main",labelOverlap:"main",labelPadding:"main",labels:"main",labelSeparation:"main",maxExtent:"main",minExtent:"main",offset:"both",position:"main",tickCap:"main",tickColor:"main",tickDash:"main",tickDashOffset:"main",tickMinStep:"both",tickOffset:"both",tickOpacity:"main",tickRound:"both",ticks:"main",tickSize:"main",tickWidth:"both",title:"main",titleAlign:"main",titleAnchor:"main",titleAngle:"main",titleBaseline:"main",titleColor:"main",titleFont:"main",titleFontSize:"main",titleFontStyle:"main",titleFontWeight:"main",titleLimit:"main",titleLineHeight:"main",titleOpacity:"main",titlePadding:"main",titleX:"main",titleY:"main",encode:"both",scale:"both",tickBand:"both",tickCount:"both",tickExtra:"both",translate:"both",values:"both",zindex:"both"},Ma={orient:1,aria:1,bandPosition:1,description:1,domain:1,domainCap:1,domainColor:1,domainDash:1,domainDashOffset:1,domainOpacity:1,domainWidth:1,format:1,formatType:1,grid:1,gridCap: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,labelLineHeight:1,labelOffset:1,labelOpacity:1,labelOverlap:1,labelPadding:1,labels:1,labelSeparation:1,maxExtent:1,minExtent:1,offset:1,position:1,tickBand:1,tickCap: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,titleLineHeight:1,titleOpacity:1,titlePadding:1,titleX:1,titleY:1,translate:1,values:1,zindex:1},Ra={...Ma,style:1,labelExpr:1,encoding:1};function La(e){return t.hasOwnProperty(Ra,e)}const qa=D({axis:1,axisBand:1,axisBottom:1,axisDiscrete:1,axisLeft:1,axisPoint:1,axisQuantitative:1,axisRight:1,axisTemporal:1,axisTop:1,axisX:1,axisXBand:1,axisXDiscrete:1,axisXPoint:1,axisXQuantitative:1,axisXTemporal:1,axisY:1,axisYBand:1,axisYDiscrete:1,axisYPoint:1,axisYQuantitative:1,axisYTemporal:1});function Ua(e){return J(e,"mark")}class Wa{constructor(e,t){this.name=e,this.run=t}hasMatchingType(e){return!!Ua(e)&&(no(t=e.mark)?t.type:t)===this.name;var t}}function Ia(e,n){const i=e&&e[n];return!!i&&(t.isArray(i)?g(i,(e=>!!e.field)):Zo(i)||Jo(i))}function Ba(e,n){const i=e&&e[n];return!!i&&(t.isArray(i)?g(i,(e=>!!e.field)):Zo(i)||ta(i)||Ko(i))}function Va(e,t){if(_t(t)){const n=e[t];if((Zo(n)||ta(n))&&(ar(n.type)||Zo(n)&&n.timeUnit)){return Ba(e,ct(t))}}return!1}function Ha(e){return g(He,(n=>{if(Ia(e,n)){const i=e[n];if(t.isArray(i))return g(i,(e=>!!e.aggregate));{const e=wa(i);return e&&!!e.aggregate}}return!1}))}function Ga(e,n){const i=[],r=[],o=[],a=[],s={};return Qa(e,((l,c)=>{if(Zo(l)){const{field:u,aggregate:f,bin:d,timeUnit:m,...p}=l;if(f||m||d){const e=ba(l),g=e?.title;let h=ma(l,{forAs:!0});const y={...g?[]:{title:va(l,n,{allowDisabling:!0})},...p,field:h};if(f){let e;if(an(f)?(e="argmax",h=ma({op:"argmax",field:f.argmax},{forAs:!0}),y.field=`${h}.${u}`):on(f)?(e="argmin",h=ma({op:"argmin",field:f.argmin},{forAs:!0}),y.field=`${h}.${u}`):"boxplot"!==f&&"errorbar"!==f&&"errorband"!==f&&(e=f),e){const t={op:e,as:h};u&&(t.field=u),a.push(t)}}else if(i.push(h),aa(l)&&mn(d)){if(r.push({bin:d,field:u,as:h}),i.push(ma(l,{binSuffix:"end"})),Na(l,c)&&i.push(ma(l,{binSuffix:"range"})),_t(c)){const e={field:`${h}_end`};s[`${c}2`]=e}y.bin="binned",it(c)||(y.type=sr)}else if(m&&!Ti(m)){o.push({timeUnit:m,field:u,as:h});const e=aa(l)&&l.type!==cr&&"time";e&&(c===Oe||c===Pe?y.formatType=e:!function(e){return t.hasOwnProperty(Ft,e)}(c)?_t(c)&&(y.axis={formatType:e,...y.axis}):y.legend={formatType:e,...y.legend})}s[c]=y}else i.push(u),s[c]=e[c]}else s[c]=e[c]})),{bins:r,timeUnits:o,aggregate:a,groupby:i,encoding:s}}function Ya(e,t,n){const i=Jt(t,n);if(!i)return!1;if("binned"===i){const n=e[t===ie?te:ne];return!!(Zo(n)&&Zo(e[t])&&pn(n.bin))}return!0}function Xa(e,t){const n={};for(const i of D(e)){const r=Sa(e[i],i,t,{compositeMark:!0});n[i]=r}return n}function Qa(e,n,i){if(e)for(const r of D(e)){const o=e[r];if(t.isArray(o))for(const e of o)n.call(i,e,r);else n.call(i,o,r)}}function Ja(e,n){return D(n).reduce(((i,r)=>{switch(r){case te:case ne:case Ne:case Te:case Ae:case ie:case re:case oe:case ae:case ce:case ue:case se:case le:case ge:case fe:case de:case me:case pe:case Oe:case be:case $e:case Pe:return i;case ze:if("line"===e||"trail"===e)return i;case Ce:case _e:{const e=n[r];if(t.isArray(e)||Zo(e))for(const n of t.array(e))n.aggregate||i.push(ma(n,{}));return i}case xe:if("trail"===e)return i;case he:case ye:case ve:case we:case ke:case Se:case Fe:case De:{const e=wa(n[r]);return e&&!e.aggregate&&i.push(ma(e,{})),i}}}),[])}function Ka(e,n,i){let r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];if("tooltip"in i)return{tooltip:i.tooltip};return{tooltip:[...e.map((e=>{let{fieldPrefix:t,titlePrefix:i}=e;const o=r?` of ${Za(n)}`:"";return{field:t+n.field,type:n.type,title:wn(i)?{signal:`${i}"${escape(o)}"`}:i+o}})),...b(function(e){const n=[];for(const i of D(e))if(Ia(e,i)){const r=e[i],o=t.array(r);for(const e of o)Zo(e)?n.push(e):Jo(e)&&n.push(e.condition)}return n}(i).map(da),d)]}}function Za(e){const{title:t,field:n}=e;return U(t,n)}function es(e,n,i,r,o){const{scale:a,axis:s}=i;return l=>{let{partName:c,mark:u,positionPrefix:f,endPositionPrefix:d,extraEncoding:m={}}=l;const p=Za(i);return ts(e,c,o,{mark:u,encoding:{[n]:{field:`${f}_${i.field}`,type:i.type,...void 0!==p?{title:p}:{},...void 0!==a?{scale:a}:{},...void 0!==s?{axis:s}:{}},...t.isString(d)?{[`${n}2`]:{field:`${d}_${i.field}`}}:{},...r,...m}})}}function ts(e,n,i,r){const{clip:o,color:a,opacity:s}=e,l=e.type;return e[n]||void 0===e[n]&&i[n]?[{...r,mark:{...i[n],...o?{clip:o}:{},...a?{color:a}:{},...s?{opacity:s}:{},...no(r.mark)?r.mark:{type:r.mark},style:`${l}-${String(n)}`,...t.isBoolean(e[n])?{}:e[n]}}]:[]}function ns(e,t,n){const{encoding:i}=e,r="vertical"===t?"y":"x",o=i[r],a=i[`${r}2`],s=i[`${r}Error`],l=i[`${r}Error2`];return{continuousAxisChannelDef:is(o,n),continuousAxisChannelDef2:is(a,n),continuousAxisChannelDefError:is(s,n),continuousAxisChannelDefError2:is(l,n),continuousAxis:r}}function is(e,t){if(e?.aggregate){const{aggregate:n,...i}=e;return n!==t&&Si(function(e,t){return`Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.`}(n,t)),i}return e}function rs(e,t){const{mark:n,encoding:i}=e,{x:r,y:o}=i;if(no(n)&&n.orient)return n.orient;if(na(r)){if(na(o)){const e=Zo(r)&&r.aggregate,n=Zo(o)&&o.aggregate;if(e||n!==t){if(n||e!==t){if(e===t&&n===t)throw new Error("Both x and y cannot have aggregate");return Ca(o)&&!Ca(r)?"horizontal":"vertical"}return"horizontal"}return"vertical"}return"horizontal"}if(na(o))return"vertical";throw new Error(`Need a valid continuous axis for ${t}s`)}const os="boxplot",as=new Wa(os,ls);function ss(e){return t.isNumber(e)?"tukey":e}function ls(e,n){let{config:i}=n;e={...e,encoding:Xa(e.encoding,i)};const{mark:r,encoding:o,params:a,projection:s,...l}=e,c=no(r)?r:{type:r};a&&Si(Kn("boxplot"));const u=c.extent??i.boxplot.extent,d=En("size",c,i),m=c.invalid,p=ss(u),{bins:g,timeUnits:h,transform:y,continuousAxisChannelDef:v,continuousAxis:b,groupby:x,aggregate:$,encodingWithoutContinuousAxis:w,ticksOrient:k,boxOrient:D,customTooltipWithoutAggregatedField:F}=function(e,n,i){const r=rs(e,os),{continuousAxisChannelDef:o,continuousAxis:a}=ns(e,r,os),s=o.field,l=L(s),c=ss(n),u=[...cs(s),{op:"median",field:s,as:`mid_box_${l}`},{op:"min",field:s,as:("min-max"===c?"lower_whisker_":"min_")+l},{op:"max",field:s,as:("min-max"===c?"upper_whisker_":"max_")+l}],f="min-max"===c||"tukey"===c?[]:[{calculate:`${j(`upper_box_${l}`)} - ${j(`lower_box_${l}`)}`,as:`iqr_${l}`},{calculate:`min(${j(`upper_box_${l}`)} + ${j(`iqr_${l}`)} * ${n}, ${j(`max_${l}`)})`,as:`upper_whisker_${l}`},{calculate:`max(${j(`lower_box_${l}`)} - ${j(`iqr_${l}`)} * ${n}, ${j(`min_${l}`)})`,as:`lower_whisker_${l}`}],{[a]:d,...m}=e.encoding,{customTooltipWithoutAggregatedField:p,filteredEncoding:g}=function(e){const{tooltip:n,...i}=e;if(!n)return{filteredEncoding:i};let r,o;if(t.isArray(n)){for(const e of n)e.aggregate?(r||(r=[]),r.push(e)):(o||(o=[]),o.push(e));r&&(i.tooltip=r)}else n.aggregate?i.tooltip=n:o=n;return t.isArray(o)&&1===o.length&&(o=o[0]),{customTooltipWithoutAggregatedField:o,filteredEncoding:i}}(m),{bins:h,timeUnits:y,aggregate:v,groupby:b,encoding:x}=Ga(g,i),$="vertical"===r?"horizontal":"vertical",w=r,k=[...h,...y,{aggregate:[...v,...u],groupby:b},...f];return{bins:h,timeUnits:y,transform:k,groupby:b,aggregate:v,continuousAxisChannelDef:o,continuousAxis:a,encodingWithoutContinuousAxis:x,ticksOrient:$,boxOrient:w,customTooltipWithoutAggregatedField:p}}(e,u,i),O=L(v.field),{color:z,size:C,..._}=w,P=e=>es(c,b,v,e,i.boxplot),N=P(_),A=P(w),T=(t.isObject(i.boxplot.box)?i.boxplot.box.color:i.mark.color)||"#4c78a8",E=P({..._,...C?{size:C}:{},color:{condition:{test:`${j(`lower_box_${v.field}`)} >= ${j(`upper_box_${v.field}`)}`,...z||{value:T}}}}),M=Ka([{fieldPrefix:"min-max"===p?"upper_whisker_":"max_",titlePrefix:"Max"},{fieldPrefix:"upper_box_",titlePrefix:"Q3"},{fieldPrefix:"mid_box_",titlePrefix:"Median"},{fieldPrefix:"lower_box_",titlePrefix:"Q1"},{fieldPrefix:"min-max"===p?"lower_whisker_":"min_",titlePrefix:"Min"}],v,w),R={type:"tick",color:"black",opacity:1,orient:k,invalid:m,aria:!1},q="min-max"===p?M:Ka([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],v,w),U=[...N({partName:"rule",mark:{type:"rule",invalid:m,aria:!1},positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",extraEncoding:q}),...N({partName:"rule",mark:{type:"rule",invalid:m,aria:!1},positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",extraEncoding:q}),...N({partName:"ticks",mark:R,positionPrefix:"lower_whisker",extraEncoding:q}),...N({partName:"ticks",mark:R,positionPrefix:"upper_whisker",extraEncoding:q})],W=[..."tukey"!==p?U:[],...A({partName:"box",mark:{type:"bar",...d?{size:d}:{},orient:D,invalid:m,ariaRoleDescription:"box"},positionPrefix:"lower_box",endPositionPrefix:"upper_box",extraEncoding:M}),...E({partName:"median",mark:{type:"tick",invalid:m,...t.isObject(i.boxplot.median)&&i.boxplot.median.color?{color:i.boxplot.median.color}:{},...d?{size:d}:{},orient:k,aria:!1},positionPrefix:"mid_box",extraEncoding:M})];if("min-max"===p)return{...l,transform:(l.transform??[]).concat(y),layer:W};const I=j(`lower_box_${v.field}`),B=j(`upper_box_${v.field}`),V=`(${B} - ${I})`,H=`${I} - ${u} * ${V}`,G=`${B} + ${u} * ${V}`,Y=j(v.field),X={joinaggregate:cs(v.field),groupby:x},Q={transform:[{filter:`(${H} <= ${Y}) && (${Y} <= ${G})`},{aggregate:[{op:"min",field:v.field,as:`lower_whisker_${O}`},{op:"max",field:v.field,as:`upper_whisker_${O}`},{op:"min",field:`lower_box_${v.field}`,as:`lower_box_${O}`},{op:"max",field:`upper_box_${v.field}`,as:`upper_box_${O}`},...$],groupby:x}],layer:U},{tooltip:J,...K}=_,{scale:Z,axis:ee}=v,te=Za(v),ne=f(ee,["title"]),ie=ts(c,"outliers",i.boxplot,{transform:[{filter:`(${Y} < ${H}) || (${Y} > ${G})`}],mark:"point",encoding:{[b]:{field:v.field,type:v.type,...void 0!==te?{title:te}:{},...void 0!==Z?{scale:Z}:{},...S(ne)?{}:{axis:ne}},...K,...z?{color:z}:{},...F?{tooltip:F}:{}}})[0];let re;const oe=[...g,...h,X];return ie?re={transform:oe,layer:[ie,Q]}:(re=Q,re.transform.unshift(...oe)),{...l,layer:[re,{transform:y,layer:W}]}}function cs(e){const t=L(e);return[{op:"q1",field:e,as:`lower_box_${t}`},{op:"q3",field:e,as:`upper_box_${t}`}]}const us="errorbar",fs=new Wa(us,ds);function ds(e,t){let{config:n}=t;e={...e,encoding:Xa(e.encoding,n)};const{transform:i,continuousAxisChannelDef:r,continuousAxis:o,encodingWithoutContinuousAxis:a,ticksOrient:s,markDef:l,outerSpec:c,tooltipEncoding:u}=ps(e,us,n);delete a.size;const f=es(l,o,r,a,n.errorbar),d=l.thickness,m=l.size,p={type:"tick",orient:s,aria:!1,...void 0!==d?{thickness:d}:{},...void 0!==m?{size:m}:{}},g=[...f({partName:"ticks",mark:p,positionPrefix:"lower",extraEncoding:u}),...f({partName:"ticks",mark:p,positionPrefix:"upper",extraEncoding:u}),...f({partName:"rule",mark:{type:"rule",ariaRoleDescription:"errorbar",...void 0!==d?{size:d}:{}},positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:u})];return{...c,transform:i,...g.length>1?{layer:g}:{...g[0]}}}function ms(e,t){const{encoding:n}=e;if(function(e){return(oa(e.x)||oa(e.y))&&!oa(e.x2)&&!oa(e.y2)&&!oa(e.xError)&&!oa(e.xError2)&&!oa(e.yError)&&!oa(e.yError2)}(n))return{orient:rs(e,t),inputType:"raw"};const i=function(e){return oa(e.x2)||oa(e.y2)}(n),r=function(e){return oa(e.xError)||oa(e.xError2)||oa(e.yError)||oa(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(oa(e)&&oa(i))throw new Error(`${t} cannot have both x2 and y2`);if(oa(e)){if(na(o))return{orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error(`Both x and x2 have to be quantitative in ${t}`)}if(oa(i)){if(na(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(oa(i)&&!oa(e))throw new Error(`${t} cannot have xError2 without xError`);if(oa(s)&&!oa(r))throw new Error(`${t} cannot have yError2 without yError`);if(oa(e)&&oa(r))throw new Error(`${t} cannot have both xError and yError with both are quantiative`);if(oa(e)){if(na(o))return{orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative")}if(oa(r)){if(na(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 ps(e,t,n){const{mark:i,encoding:r,params:o,projection:a,...s}=e,l=no(i)?i:{type:i};o&&Si(Kn(t));const{orient:c,inputType:u}=ms(e,t),{continuousAxisChannelDef:f,continuousAxisChannelDef2:d,continuousAxisChannelDefError:m,continuousAxisChannelDefError2:p,continuousAxis:g}=ns(e,c,t),{errorBarSpecificAggregate:h,postAggregateCalculates:y,tooltipSummary:v,tooltipTitleWithFieldName:b}=function(e,t,n,i,r,o,a,s){let l=[],c=[];const u=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)&&Si(function(e,t,n){return`${e} is not usually used with ${t} for ${n}.`}(t,n,a)),"stderr"===n||"stdev"===n)l=[{op:n,field:u,as:`extent_${u}`},{op:t,field:u,as:`center_${u}`}],c=[{calculate:`${j(`center_${u}`)} + ${j(`extent_${u}`)}`,as:`upper_${u}`},{calculate:`${j(`center_${u}`)} - ${j(`extent_${u}`)}`,as:`lower_${u}`}],f=[{fieldPrefix:"center_",titlePrefix:N(t)},{fieldPrefix:"upper_",titlePrefix:gs(t,n,"+")},{fieldPrefix:"lower_",titlePrefix:gs(t,n,"-")}],d=!0;else{let e,t,i;"ci"===n?(e="mean",t="ci0",i="ci1"):(e="median",t="q1",i="q3"),l=[{op:t,field:u,as:`lower_${u}`},{op:i,field:u,as:`upper_${u}`},{op:e,field:u,as:`center_${u}`}],f=[{fieldPrefix:"upper_",titlePrefix:va({field:u,aggregate:i,type:"quantitative"},s,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:va({field:u,aggregate:t,type:"quantitative"},s,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:va({field:u,aggregate:e,type:"quantitative"},s,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&Si((m=e.center,`${(p=e.extent)?"extent ":""}${p&&m?"and ":""}${m?"center ":""}${p&&m?"are ":"is "}not needed when data are aggregated.`)),"aggregated-upper-lower"===o?(f=[],c=[{calculate:j(n.field),as:`upper_${u}`},{calculate:j(u),as:`lower_${u}`}]):"aggregated-error"===o&&(f=[{fieldPrefix:"",titlePrefix:u}],c=[{calculate:`${j(u)} + ${j(i.field)}`,as:`upper_${u}`}],r?c.push({calculate:`${j(u)} + ${j(r.field)}`,as:`lower_${u}`}):c.push({calculate:`${j(u)} - ${j(i.field)}`,as:`lower_${u}`}));for(const e of c)f.push({fieldPrefix:e.as.substring(0,6),titlePrefix:R(R(e.calculate,"datum['",""),"']","")})}var m,p;return{postAggregateCalculates:c,errorBarSpecificAggregate:l,tooltipSummary:f,tooltipTitleWithFieldName:d}}(l,f,d,m,p,u,t,n),{[g]:x,["x"===g?"x2":"y2"]:$,["x"===g?"xError":"yError"]:w,["x"===g?"xError2":"yError2"]:k,...S}=r,{bins:D,timeUnits:F,aggregate:O,groupby:z,encoding:C}=Ga(S,n),_=[...O,...h],P="raw"!==u?[]:z,A=Ka(v,f,C,b);return{transform:[...s.transform??[],...D,...F,...0===_.length?[]:[{aggregate:_,groupby:P}],...y],groupby:P,continuousAxisChannelDef:f,continuousAxis:g,encodingWithoutContinuousAxis:C,ticksOrient:"vertical"===c?"horizontal":"vertical",markDef:l,outerSpec:s,tooltipEncoding:A}}function gs(e,t,n){return`${N(e)} ${n} ${t}`}const hs="errorband",ys=new Wa(hs,vs);function vs(e,t){let{config:n}=t;e={...e,encoding:Xa(e.encoding,n)};const{transform:i,continuousAxisChannelDef:r,continuousAxis:o,encodingWithoutContinuousAxis:a,markDef:s,outerSpec:l,tooltipEncoding:c}=ps(e,hs,n),u=s,f=es(u,o,r,a,n.errorband),d=void 0!==e.encoding.x&&void 0!==e.encoding.y;let m={type:d?"area":"rect"},p={type:d?"line":"rule"};const g={...u.interpolate?{interpolate:u.interpolate}:{},...u.tension&&u.interpolate?{tension:u.tension}:{}};return d?(m={...m,...g,ariaRoleDescription:"errorband"},p={...p,...g,aria:!1}):u.interpolate?Si(bi("interpolate")):u.tension&&Si(bi("tension")),{...l,transform:i,layer:[...f({partName:"band",mark:m,positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:c}),...f({partName:"borders",mark:p,positionPrefix:"lower",extraEncoding:c}),...f({partName:"borders",mark:p,positionPrefix:"upper",extraEncoding:c})]}}const bs={};function xs(e,t,n){const i=new Wa(e,t);bs[e]={normalizer:i,parts:n}}xs(os,ls,["box","median","outliers","rule","ticks"]),xs(us,ds,["ticks","rule"]),xs(hs,vs,["band","borders"]);const $s=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength","unselectedOpacity"],ws={titleAlign:"align",titleAnchor:"anchor",titleAngle:"angle",titleBaseline:"baseline",titleColor:"color",titleFont:"font",titleFontSize:"fontSize",titleFontStyle:"fontStyle",titleFontWeight:"fontWeight",titleLimit:"limit",titleLineHeight:"lineHeight",titleOrient:"orient",titlePadding:"offset"},ks={labelAlign:"align",labelAnchor:"anchor",labelAngle:"angle",labelBaseline:"baseline",labelColor:"color",labelFont:"font",labelFontSize:"fontSize",labelFontStyle:"fontStyle",labelFontWeight:"fontWeight",labelLimit:"limit",labelLineHeight:"lineHeight",labelOrient:"orient",labelPadding:"offset"},Ss=D(ws),Ds=D(ks),Fs=D({header:1,headerRow:1,headerColumn:1,headerFacet:1}),Os=["size","shape","fill","stroke","strokeDash","strokeWidth","opacity"],zs="_vgsid_",Cs={point:{on:"click",fields:[zs],toggle:"event.shiftKey",resolve:"global",clear:"dblclick"},interval:{on:"[pointerdown, window:pointerup] > window:pointermove!",encodings:["x","y"],translate:"[pointerdown, window:pointerup] > window:pointermove!",zoom:"wheel!",mark:{fill:"#333",fillOpacity:.125,stroke:"white"},resolve:"global",clear:"dblclick"}};function _s(e){return"legend"===e||!!e?.legend}function Ps(e){return _s(e)&&t.isObject(e)}function Ns(e){return!!e?.select}function As(e){const t=[];for(const n of e||[]){if(Ns(n))continue;const{expr:e,bind:i,...r}=n;if(i&&e){const n={...r,bind:i,init:e};t.push(n)}else{const n={...r,...e?{update:e}:{},...i?{bind:i}:{}};t.push(n)}}return t}function Ts(e){return J(e,"concat")}function js(e){return J(e,"vconcat")}function Es(e){return J(e,"hconcat")}function Ms(e){let{step:t,offsetIsDiscrete:n}=e;return n?t.for??"offset":"position"}function Rs(e){return J(e,"step")}function Ls(e){return J(e,"view")||J(e,"width")||J(e,"height")}const qs=D({align:1,bounds:1,center:1,columns:1,spacing:1});function Us(e,t){return e[t]??e["width"===t?"continuousWidth":"continuousHeight"]}function Ws(e,t){const n=Is(e,t);return Rs(n)?n.step:Bs}function Is(e,t){return U(e[t]??e["width"===t?"discreteWidth":"discreteHeight"],{step:e.step})}const Bs=20,Vs={background:"white",padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",view:{continuousWidth:200,continuousHeight:200,step:Bs},mark:{color:"#4c78a8",invalid:"break-paths-show-path-domains",timeUnitBandSize:1},arc:{},area:{},bar:fo,circle:{},geoshape:{},image:{},line:{},point:{},rect:uo,rule:{color:"black"},square:{},text:{color:"black"},tick:mo,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:{pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,tickBandPaddingInner:.25,bandWithNestedOffsetPaddingInner:.2,bandWithNestedOffsetPaddingOuter:.2,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:4,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4,zero:!0,framesPerSecond:2,animationDuration:5},projection:{},legend:{gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:Cs,style:{},title:{},facet:{spacing:20},concat:{spacing:20},normalizedNumberFormat:".0%"},Hs=["#4c78a8","#f58518","#e45756","#72b7b2","#54a24b","#eeca3b","#b279a2","#ff9da6","#9d755d","#bab0ac"],Gs={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},Ys={blue:Hs[0],orange:Hs[1],red:Hs[2],teal:Hs[3],green:Hs[4],yellow:Hs[5],purple:Hs[6],pink:Hs[7],brown:Hs[8],gray0:"#000",gray1:"#111",gray2:"#222",gray3:"#333",gray4:"#444",gray5:"#555",gray6:"#666",gray7:"#777",gray8:"#888",gray9:"#999",gray10:"#aaa",gray11:"#bbb",gray12:"#ccc",gray13:"#ddd",gray14:"#eee",gray15:"#fff"};function Xs(e){const t=D(e||{}),n={};for(const i of t){const t=e[i];n[i]=Ta(t)?zn(t):Cn(t)}return n}const Qs=[...so,...qa,...Fs,"background","padding","legend","lineBreak","scale","style","title","view"];function Js(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{color:n,font:i,fontSize:r,selection:o,...a}=e,s=t.mergeConfig({},l(Vs),i?function(e){return{text:{font:e},style:{"guide-label":{font:e},"guide-title":{font:e},"group-title":{font:e},"group-subtitle":{font:e}}}}(i):{},n?function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{signals:[{name:"color",value:t.isObject(e)?{...Ys,...e}:Ys}],mark:{color:{signal:"color.blue"}},rule:{color:{signal:"color.gray0"}},text:{color:{signal:"color.gray0"}},style:{"guide-label":{fill:{signal:"color.gray0"}},"guide-title":{fill:{signal:"color.gray0"}},"group-title":{fill:{signal:"color.gray0"}},"group-subtitle":{fill:{signal:"color.gray0"}},cell:{stroke:{signal:"color.gray8"}}},axis:{domainColor:{signal:"color.gray13"},gridColor:{signal:"color.gray8"},tickColor:{signal:"color.gray13"}},range:{category:[{signal:"color.blue"},{signal:"color.orange"},{signal:"color.red"},{signal:"color.teal"},{signal:"color.green"},{signal:"color.yellow"},{signal:"color.purple"},{signal:"color.pink"},{signal:"color.brown"},{signal:"color.grey8"}]}}}(n):{},r?function(e){return{signals:[{name:"fontSize",value:t.isObject(e)?{...Gs,...e}:Gs}],text:{fontSize:{signal:"fontSize.text"}},style:{"guide-label":{fontSize:{signal:"fontSize.guideLabel"}},"guide-title":{fontSize:{signal:"fontSize.guideTitle"}},"group-title":{fontSize:{signal:"fontSize.groupTitle"}},"group-subtitle":{fontSize:{signal:"fontSize.groupSubtitle"}}}}}(r):{},a||{});o&&t.writeConfig(s,"selection",o,!0);const c=f(s,Qs);for(const e of["background","lineBreak","padding"])s[e]&&(c[e]=Cn(s[e]));for(const e of so)s[e]&&(c[e]=bn(s[e]));for(const e of qa)s[e]&&(c[e]=Xs(s[e]));for(const e of Fs)s[e]&&(c[e]=bn(s[e]));if(s.legend&&(c.legend=bn(s.legend)),s.scale){const{invalid:e,...t}=s.scale,n=bn(e,{level:1});c.scale={...bn(t),...D(n).length>0?{invalid:n}:{}}}return s.style&&(c.style=function(e){const t=D(e),n={};for(const i of t)n[i]=Xs(e[i]);return n}(s.style)),s.title&&(c.title=bn(s.title)),s.view&&(c.view=bn(s.view)),c}const Ks=new Set(["view",...to]),Zs=["color","fontSize","background","padding","facet","concat","numberFormat","numberFormatType","normalizedNumberFormat","normalizedNumberFormatType","timeFormat","countTitle","header","axisQuantitative","axisTemporal","axisDiscrete","axisPoint","axisXBand","axisXPoint","axisXDiscrete","axisXQuantitative","axisXTemporal","axisYBand","axisYPoint","axisYDiscrete","axisYQuantitative","axisYTemporal","scale","selection","overlay"],el={view:["continuousWidth","continuousHeight","discreteWidth","discreteHeight","step"],...ao};function tl(e){e=l(e);for(const t of Zs)delete e[t];if(e.axis)for(const t in e.axis)Ta(e.axis[t])&&delete e.axis[t];if(e.legend)for(const t of $s)delete e.legend[t];if(e.mark){for(const t of ro)delete e.mark[t];e.mark.tooltip&&t.isObject(e.mark.tooltip)&&delete e.mark.tooltip}e.params&&(e.signals=(e.signals||[]).concat(As(e.params)),delete e.params);for(const t of Ks){for(const n of ro)delete e[t][n];const n=el[t];if(n)for(const i of n)delete e[t][i];nl(e,t)}for(const t of D(bs))delete e[t];!function(e){const{titleMarkConfig:t,subtitleMarkConfig:n,subtitle:i}=xn(e.title);S(t)||(e.style["group-title"]={...e.style["group-title"],...t});S(n)||(e.style["group-subtitle"]={...e.style["group-subtitle"],...n});S(i)?delete e.title:e.title=i}(e);for(const n in e)t.isObject(e[n])&&S(e[n])&&delete e[n];return S(e)?void 0:e}function nl(e,t,n,i){"view"===t&&(n="cell");const r={...e[t],...e.style[n??t]};S(r)||(e.style[n??t]=r),delete e[t]}function il(e){return J(e,"layer")}class rl{map(e,t){return Io(e)?this.mapFacet(e,t):function(e){return J(e,"repeat")}(e)?this.mapRepeat(e,t):Es(e)?this.mapHConcat(e,t):js(e)?this.mapVConcat(e,t):Ts(e)?this.mapConcat(e,t):this.mapLayerOrUnit(e,t)}mapLayerOrUnit(e,t){if(il(e))return this.mapLayer(e,t);if(Ua(e))return this.mapUnit(e,t);throw new Error(Bn(e))}mapLayer(e,t){return{...e,layer:e.layer.map((e=>this.mapLayerOrUnit(e,t)))}}mapHConcat(e,t){return{...e,hconcat:e.hconcat.map((e=>this.map(e,t)))}}mapVConcat(e,t){return{...e,vconcat:e.vconcat.map((e=>this.map(e,t)))}}mapConcat(e,t){const{concat:n,...i}=e;return{...i,concat:n.map((e=>this.map(e,t)))}}mapFacet(e,t){return{...e,spec:this.map(e.spec,t)}}mapRepeat(e,t){return{...e,spec:this.map(e.spec,t)}}}const ol={zero:1,center:1,normalize:1};const al=new Set([Lr,Ur,qr,Hr,Br,Qr,Jr,Ir,Gr,Yr]),sl=new Set([Ur,qr,Lr]);function ll(e){return Zo(e)&&"quantitative"===ea(e)&&!e.bin}function cl(e,t,n){let{orient:i,type:r}=n;const o="x"===t?"y":"radius",a="x"===t&&["bar","area"].includes(r),s=e[t],l=e[o];if(Zo(s)&&Zo(l))if(ll(s)&&ll(l)){if(s.stack)return t;if(l.stack)return o;const e=Zo(s)&&!!s.aggregate;if(e!==(Zo(l)&&!!l.aggregate))return e?t:o;if(a){if("vertical"===i)return o;if("horizontal"===i)return t}}else{if(ll(s))return t;if(ll(l))return o}else{if(ll(s)){if(a&&"vertical"===i)return;return t}if(ll(l)){if(a&&"horizontal"===i)return;return o}}}function ul(e,n){const i=no(e)?e:{type:e},r=i.type;if(!al.has(r))return null;const o=cl(n,"x",i)||cl(n,"theta",i);if(!o)return null;const a=n[o],s=Zo(a)?ma(a,{}):void 0,l=function(e){switch(e){case"x":return"y";case"y":return"x";case"theta":return"radius";case"radius":return"theta"}}(o),c=[],u=new Set;if(n[l]){const e=n[l],t=Zo(e)?ma(e,{}):void 0;t&&t!==s&&(c.push(l),u.add(t))}const f="x"===l?"xOffset":"yOffset",d=n[f],m=Zo(d)?ma(d,{}):void 0;m&&m!==s&&(c.push(f),u.add(m));const p=Ot.reduce(((e,i)=>{if("tooltip"!==i&&Ia(n,i)){const r=n[i];for(const n of t.array(r)){const t=wa(n);if(t.aggregate)continue;const r=ma(t,{});r&&u.has(r)||e.push({channel:i,fieldDef:t})}}return e}),[]);let g;return void 0!==a.stack?g=t.isBoolean(a.stack)?a.stack?"zero":null:a.stack:sl.has(r)&&(g="zero"),g&&(h=g,t.hasOwnProperty(ol,h))?Ha(n)&&0===p.length?null:(a?.scale?.type&&a?.scale?.type!==dr.LINEAR&&a?.stack&&Si(function(e){return`Stack is applied to a non-linear scale (${e}).`}(a.scale.type)),oa(n[at(o)])?(void 0!==a.stack&&Si(`Cannot stack "${y=o}" if there is already "${y}2".`),null):(Zo(a)&&a.aggregate&&!un.has(a.aggregate)&&Si(`Stacking is applied even though the aggregate function is non-summative ("${a.aggregate}").`),{groupbyChannels:c,groupbyFields:u,fieldChannel:o,impute:null!==a.impute&&Zr(r),stackBy:p,offset:g})):null;var h,y}function fl(e,t,n){const i=bn(e),r=En("orient",i,n);if(i.orient=function(e,t,n){switch(e){case Br:case Qr:case Jr:case Gr:case Vr:case Wr:return}const{x:i,y:r,x2:o,y2:a}=t;switch(e){case Ur:if(Zo(i)&&(pn(i.bin)||Zo(r)&&r.aggregate&&!i.aggregate))return"vertical";if(Zo(r)&&(pn(r.bin)||Zo(i)&&i.aggregate&&!r.aggregate))return"horizontal";if(a||o){if(n)return n;if(!o)return(Zo(i)&&i.type===sr&&!mn(i.bin)||ra(i))&&Zo(r)&&pn(r.bin)?"horizontal":"vertical";if(!a)return(Zo(r)&&r.type===sr&&!mn(r.bin)||ra(r))&&Zo(i)&&pn(i.bin)?"vertical":"horizontal"}case Hr:if(o&&(!Zo(i)||!pn(i.bin))&&a&&(!Zo(r)||!pn(r.bin)))return;case qr:if(a)return Zo(r)&&pn(r.bin)?"horizontal":"vertical";if(o)return Zo(i)&&pn(i.bin)?"vertical":"horizontal";if(e===Hr){if(i&&!r)return"vertical";if(r&&!i)return"horizontal"}case Ir:case Yr:{const t=ia(i),o=ia(r);if(n)return n;if(t&&!o)return"tick"!==e?"horizontal":"vertical";if(!t&&o)return"tick"!==e?"vertical":"horizontal";if(t&&o)return"vertical";{const e=aa(i)&&i.type===cr,t=aa(r)&&r.type===cr;if(e&&!t)return"vertical";if(!e&&t)return"horizontal"}return}}return"vertical"}(i.type,t,r),void 0!==r&&r!==i.orient&&Si(`Specified orient "${i.orient}" overridden with "${r}".`),"bar"===i.type&&i.orient){const e=En("cornerRadiusEnd",i,n);if(void 0!==e){const n="horizontal"===i.orient&&t.x2||"vertical"===i.orient&&t.y2?["cornerRadius"]:co[i.orient];for(const t of n)i[t]=e;void 0!==i.cornerRadiusEnd&&delete i.cornerRadiusEnd}}const o=En("opacity",i,n),a=En("fillOpacity",i,n);void 0===o&&void 0===a&&(i.opacity=function(e,t){if(p([Br,Yr,Qr,Jr],e)&&!Ha(t))return.7;return}(i.type,t));return void 0===En("cursor",i,n)&&(i.cursor=function(e,t,n){if(t.href||e.href||En("href",e,n))return"pointer";return e.cursor}(i,t,n)),i}function dl(e){const{point:t,line:n,...i}=e;return D(i).length>1?i:i.type}function ml(e){for(const t of["line","area","rule","trail"])e[t]&&(e={...e,[t]:f(e[t],["point","line"])});return e}function pl(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2?arguments[2]:void 0;return"transparent"===e.point?{opacity:0}:e.point?t.isObject(e.point)?e.point:{}:void 0!==e.point?null:n.point||i.shape?t.isObject(n.point)?n.point:{}:void 0}function gl(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.line?!0===e.line?{}:e.line:void 0!==e.line?null:t.line?!0===t.line?{}:t.line:void 0}class hl{name="path-overlay";hasMatchingType(e,t){if(Ua(e)){const{mark:n,encoding:i}=e,r=no(n)?n:{type:n};switch(r.type){case"line":case"rule":case"trail":return!!pl(r,t[r.type],i);case"area":return!!pl(r,t[r.type],i)||!!gl(r,t[r.type])}}return!1}run(e,t,n){const{config:i}=t,{params:r,projection:o,mark:a,name:s,encoding:l,...c}=e,d=Xa(l,i),m=no(a)?a:{type:a},p=pl(m,i[m.type],d),g="area"===m.type&&gl(m,i[m.type]),h=[{name:s,...r?{params:r}:{},mark:dl({..."area"===m.type&&void 0===m.opacity&&void 0===m.fillOpacity?{opacity:.7}:{},...m}),encoding:f(d,["shape"])}],y=ul(fl(m,d,i),d);let v=d;if(y){const{fieldChannel:e,offset:t}=y;v={...d,[e]:{...d[e],...t?{stack:t}:{}}}}return v=f(v,["y2","x2"]),g&&h.push({...o?{projection:o}:{},mark:{type:"line",...u(m,["clip","interpolate","tension","tooltip"]),...g},encoding:v}),p&&h.push({...o?{projection:o}:{},mark:{type:"point",opacity:1,filled:!0,...u(m,["clip","tooltip"]),...p},encoding:v}),n({...c,layer:h},{...t,config:ml(i)})}}function yl(e,t){return t?Uo(e)?kl(e,t):xl(e,t):e}function vl(e,t){return t?kl(e,t):e}function bl(e,n,i){const r=n[e];return o=r,!t.isString(o)&&J(o,"repeat")?r.repeat in i?{...n,[e]:i[r.repeat]}:void Si(function(e){return`Unknown repeated value "${e}".`}(r.repeat)):n;var o}function xl(e,t){if(void 0!==(e=bl("field",e,t))){if(null===e)return null;if(Vo(e)&&Lo(e.sort)){const n=bl("field",e.sort,t);e={...e,...n?{sort:n}:{}}}return e}}function $l(e,t){if(Zo(e))return xl(e,t);{const n=bl("datum",e,t);return n===e||n.type||(n.type="nominal"),n}}function wl(e,t){if(!oa(e)){if(Ko(e)){const n=$l(e.condition,t);if(n)return{...e,condition:n};{const{condition:t,...n}=e;return n}}return e}{const n=$l(e,t);if(n)return n;if(Qo(e))return{condition:e.condition}}}function kl(e,n){const i={};for(const r in e)if(J(e,r)){const o=e[r];if(t.isArray(o))i[r]=o.map((e=>wl(e,n))).filter((e=>e));else{const e=wl(o,n);void 0!==e&&(i[r]=e)}}return i}class Sl{name="RuleForRangedLine";hasMatchingType(e){if(Ua(e)){const{encoding:t,mark:n}=e;if("line"===n||no(n)&&"line"===n.type)for(const e of nt){const n=t[rt(e)];if(t[e]&&(Zo(n)&&!pn(n.bin)||ta(n)))return!0}}return!1}run(e,n,i){const{encoding:r,mark:o}=e;var a,s;return Si((a=!!r.x2,s=!!r.y2,`Line mark is for continuous lines and thus cannot be used with ${a&&s?"x2 and y2":a?"x2":"y2"}. We will use the rule mark (line segments) instead.`)),i({...e,mark:t.isObject(o)?{...o,type:"rule"}:"rule"},n)}}function Dl(e){let{parentEncoding:n,encoding:i={},layer:r}=e,o={};if(n){const e=new Set([...D(n),...D(i)]);for(const a of e){const e=i[a],s=n[a];if(oa(e)){const t={...s,...e};o[a]=t}else Ko(e)?o[a]={...e,condition:{...s,...e.condition}}:e||null===e?o[a]=e:(r||sa(s)||wn(s)||oa(s)||t.isArray(s))&&(o[a]=s)}}else o=i;return!o||S(o)?void 0:o}function Fl(e){const{parentProjection:t,projection:n}=e;return t&&n&&Si(function(e){const{parentProjection:t,projection:n}=e;return`Layer's shared projection ${Q(t)} is overridden by a child projection ${Q(n)}.`}({parentProjection:t,projection:n})),n??t}function Ol(e){return J(e,"filter")}function zl(e){return J(e,"lookup")}function Cl(e){return J(e,"pivot")}function _l(e){return J(e,"density")}function Pl(e){return J(e,"quantile")}function Nl(e){return J(e,"regression")}function Al(e){return J(e,"loess")}function Tl(e){return J(e,"sample")}function jl(e){return J(e,"window")}function El(e){return J(e,"joinaggregate")}function Ml(e){return J(e,"flatten")}function Rl(e){return J(e,"calculate")}function Ll(e){return J(e,"bin")}function ql(e){return J(e,"impute")}function Ul(e){return J(e,"timeUnit")}function Wl(e){return J(e,"aggregate")}function Il(e){return J(e,"stack")}function Bl(e){return J(e,"fold")}function Vl(e){return J(e,"extent")&&!J(e,"density")&&!J(e,"regression")}function Hl(e,t){const{transform:n,...i}=e;if(n){return{...i,transform:n.map((e=>{if(Ol(e))return{filter:Xl(e,t)};if(Ll(e)&&gn(e.bin))return{...e,bin:Yl(e.bin)};if(zl(e)){const{selection:t,...n}=e.from;return t?{...e,from:{param:t,...n}}:e}return e}))}}return e}function Gl(e,n){const i=l(e);if(Zo(i)&&gn(i.bin)&&(i.bin=Yl(i.bin)),la(i)&&i.scale?.domain?.selection){const{selection:e,...t}=i.scale.domain;i.scale.domain={...t,...e?{param:e}:{}}}if(Qo(i))if(t.isArray(i.condition))i.condition=i.condition.map((e=>{const{selection:t,param:i,test:r,...o}=e;return i?e:{...o,test:Xl(e,n)}}));else{const{selection:e,param:t,test:r,...o}=Gl(i.condition,n);i.condition=t?i.condition:{...o,test:Xl(i.condition,n)}}return i}function Yl(e){const t=e.extent;if(t?.selection){const{selection:n,...i}=t;return{...e,extent:{...i,param:n}}}return e}function Xl(e,t){const n=e=>s(e,(e=>{const n={param:e,empty:t.emptySelections[e]??!0};return t.selectionPredicates[e]??=[],t.selectionPredicates[e].push(n),n}));return e.selection?n(e.selection):s(e.test||e.filter,(e=>e.selection?n(e.selection):e))}class Ql extends rl{map(e,t){const n=t.selections??[];if(e.params&&!Ua(e)){const t=[];for(const i of e.params)Ns(i)?n.push(i):t.push(i);e.params=t}return t.selections=n,super.map(e,t)}mapUnit(e,n){const i=n.selections;if(!i||!i.length)return e;const r=(n.path??[]).concat(e.name),o=[];for(const n of i)if(n.views&&n.views.length)for(const i of n.views)(t.isString(i)&&(i===e.name||r.includes(i))||t.isArray(i)&&i.map((e=>r.indexOf(e))).every(((e,t,n)=>-1!==e&&(0===t||e>n[t-1]))))&&o.push(n);else o.push(n);return o.length&&(e.params=o),e}}for(const e of["mapFacet","mapRepeat","mapHConcat","mapVConcat","mapLayer"]){const t=Ql.prototype[e];Ql.prototype[e]=function(e,n){return t.call(this,e,Jl(e,n))}}function Jl(e,t){return e.name?{...t,path:(t.path??[]).concat(e.name)}:t}function Kl(e,t){void 0===t&&(t=Js(e.config));const n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={config:t};return tc.map(Zl.map(ec.map(e,n),n),n)}(e,t),{width:i,height:r}=e,o=function(e,t,n){let{width:i,height:r}=t;const o=Ua(e)||il(e),a={};o?"container"==i&&"container"==r?(a.type="fit",a.contains="padding"):"container"==i?(a.type="fit-x",a.contains="padding"):"container"==r&&(a.type="fit-y",a.contains="padding"):("container"==i&&(Si(Hn("width")),i=void 0),"container"==r&&(Si(Hn("height")),r=void 0));const s={type:"pad",...a,...n?nc(n.autosize):{},...nc(e.autosize)};"fit"!==s.type||o||(Si(Vn),s.type="pad");"container"==i&&"fit"!=s.type&&"fit-x"!=s.type&&Si(Gn("width"));"container"==r&&"fit"!=s.type&&"fit-y"!=s.type&&Si(Gn("height"));if(X(s,{type:"pad"}))return;return s}(n,{width:i,height:r,autosize:e.autosize},t);return{...n,...o?{autosize:o}:{}}}const Zl=new class extends rl{nonFacetUnitNormalizers=(()=>[as,fs,ys,new hl,new Sl])();map(e,t){if(Ua(e)){const n=Ia(e.encoding,K),i=Ia(e.encoding,Z),r=Ia(e.encoding,ee);if(n||i||r)return this.mapFacetedUnit(e,t)}return super.map(e,t)}mapUnit(e,t){const{parentEncoding:n,parentProjection:i}=t,r=vl(e.encoding,t.repeater),o={...e,...e.name?{name:[t.repeaterPrefix,e.name].filter((e=>e)).join("_")}:{},...r?{encoding:r}:{}};if(n||i)return this.mapUnitWithParentEncodingOrProjection(o,t);const a=this.mapLayerOrUnit.bind(this);for(const e of this.nonFacetUnitNormalizers)if(e.hasMatchingType(o,t.config))return e.run(o,t,a);return o}mapRepeat(e,n){return function(e){return!t.isArray(e.repeat)&&J(e.repeat,"layer")}(e)?this.mapLayerRepeat(e,n):this.mapNonLayerRepeat(e,n)}mapLayerRepeat(e,t){const{repeat:n,spec:i,...r}=e,{row:o,column:a,layer:s}=n,{repeater:l={},repeaterPrefix:c=""}=t;return o||a?this.mapRepeat({...e,repeat:{...o?{row:o}:{},...a?{column:a}:{}},spec:{repeat:{layer:s},spec:i}},t):{...r,layer:s.map((e=>{const n={...l,layer:e},r=`${(i.name?`${i.name}_`:"")+c}child__layer_${C(e)}`,o=this.mapLayerOrUnit(i,{...t,repeater:n,repeaterPrefix:r});return o.name=r,o}))}}mapNonLayerRepeat(e,n){const{repeat:i,spec:r,data:o,...a}=e;!t.isArray(i)&&e.columns&&(e=f(e,["columns"]),Si(ei("repeat")));const s=[],{repeater:l={},repeaterPrefix:c=""}=n,u=!t.isArray(i)&&i.row||[l?l.row:null],d=!t.isArray(i)&&i.column||[l?l.column:null],m=t.isArray(i)&&i||[l?l.repeat:null];for(const e of m)for(const o of u)for(const a of d){const u={repeat:e,row:o,column:a,layer:l.layer},d=(r.name?`${r.name}_`:"")+c+"child__"+(t.isArray(i)?`${C(e)}`:(i.row?`row_${C(o)}`:"")+(i.column?`column_${C(a)}`:"")),m=this.map(r,{...n,repeater:u,repeaterPrefix:d});m.name=d,s.push(f(m,["data"]))}const p=t.isArray(i)?e.columns:i.column?i.column.length:1;return{data:r.data??o,align:"all",...a,columns:p,concat:s}}mapFacet(e,t){const{facet:n}=e;return Uo(n)&&e.columns&&(e=f(e,["columns"]),Si(ei("facet"))),super.mapFacet(e,t)}mapUnitWithParentEncodingOrProjection(e,t){const{encoding:n,projection:i}=e,{parentEncoding:r,parentProjection:o,config:a}=t,s=Fl({parentProjection:o,projection:i}),l=Dl({parentEncoding:r,encoding:vl(n,t.repeater)});return this.mapUnit({...e,...s?{projection:s}:{},...l?{encoding:l}:{}},{config:a})}mapFacetedUnit(e,t){const{row:n,column:i,facet:r,...o}=e.encoding,{mark:a,width:s,projection:l,height:c,view:u,params:f,encoding:d,...m}=e,{facetMapping:p,layout:g}=this.getFacetMappingAndLayout({row:n,column:i,facet:r},t),h=vl(o,t.repeater);return this.mapFacet({...m,...g,facet:p,spec:{...s?{width:s}:{},...c?{height:c}:{},...u?{view:u}:{},...l?{projection:l}:{},mark:a,encoding:h,...f?{params:f}:{}}},t)}getFacetMappingAndLayout(e,t){const{row:n,column:i,facet:r}=e;if(n||i){r&&Si(`Facet encoding dropped as ${(o=[...n?[K]:[],...i?[Z]:[]]).join(" and ")} ${o.length>1?"are":"is"} also specified.`);const t={},a={};for(const n of[K,Z]){const i=e[n];if(i){const{align:e,center:r,spacing:o,columns:s,...l}=i;t[n]=l;for(const e of["align","center","spacing"])void 0!==i[e]&&(a[e]??={},a[e][n]=i[e])}}return{facetMapping:t,layout:a}}{const{align:e,center:n,spacing:i,columns:o,...a}=r;return{facetMapping:yl(a,t.repeater),layout:{...e?{align:e}:{},...n?{center:n}:{},...i?{spacing:i}:{},...o?{columns:o}:{}}}}var o}mapLayer(e,t){let{parentEncoding:n,parentProjection:i,...r}=t;const{encoding:o,projection:a,...s}=e,l={...r,parentEncoding:Dl({parentEncoding:n,encoding:o,layer:!0}),parentProjection:Fl({parentProjection:i,projection:a})};return super.mapLayer({...s,...e.name?{name:[l.repeaterPrefix,e.name].filter((e=>e)).join("_")}:{}},l)}},ec=new class extends rl{map(e,t){return t.emptySelections??={},t.selectionPredicates??={},e=Hl(e,t),super.map(e,t)}mapLayerOrUnit(e,t){if((e=Hl(e,t)).encoding){const n={};for(const[i,r]of O(e.encoding))n[i]=Gl(r,t);e={...e,encoding:n}}return super.mapLayerOrUnit(e,t)}mapUnit(e,t){const{selection:n,...i}=e;return n?{...i,params:O(n).map((e=>{let[n,i]=e;const{init:r,bind:o,empty:a,...s}=i;"single"===s.type?(s.type="point",s.toggle=!1):"multi"===s.type&&(s.type="point"),t.emptySelections[n]="none"!==a;for(const e of F(t.selectionPredicates[n]??{}))e.empty="none"!==a;return{name:n,value:r,select:s,bind:o}}))}:e}},tc=new Ql;function nc(e){return t.isString(e)?{type:e}:e??{}}const ic=["background","padding"];function rc(e,t){const n={};for(const t of ic)e&&void 0!==e[t]&&(n[t]=Cn(e[t]));return t&&(n.params=e.params),n}class oc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.explicit=e,this.implicit=t}clone(){return new oc(l(this.explicit),l(this.implicit))}combine(){return{...this.explicit,...this.implicit}}get(e){return U(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){let{value:n,explicit:i}=t;void 0!==n&&this.set(e,n,i)}set(e,t,n){return delete this[n?"implicit":"explicit"][e],this[n?"explicit":"implicit"][e]=t,this}copyKeyFromSplit(e,t){let{explicit:n,implicit:i}=t;void 0!==n[e]?this.set(e,n[e],!0):void 0!==i[e]&&this.set(e,i[e],!1)}copyKeyFromObject(e,t){void 0!==t[e]&&this.set(e,t[e],!0)}copyAll(e){for(const t of D(e.combine())){const n=e.getWithExplicit(t);this.setWithExplicit(t,n)}}}function ac(e){return{explicit:!0,value:e}}function sc(e){return{explicit:!1,value:e}}function lc(e){return(t,n,i,r)=>{const o=e(t.value,n.value);return o>0?t:o<0?n:cc(t,n,i,r)}}function cc(e,t,n,i){return e.explicit&&t.explicit&&Si(function(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${Q(n)} and ${Q(i)}). Using ${Q(n)}.`}(n,i,e.value,t.value)),e}function uc(e,t,n,i){let r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:cc;return void 0===e||void 0===e.value?t:e.explicit&&!t.explicit?e:t.explicit&&!e.explicit?t:X(e.value,t.value)?e:r(e,t,n,i)}class fc extends oc{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];super(e,t),this.explicit=e,this.implicit=t,this.parseNothing=n}clone(){const e=super.clone();return e.parseNothing=this.parseNothing,e}}function dc(e){return J(e,"url")}function mc(e){return J(e,"values")}function pc(e){return J(e,"name")&&!dc(e)&&!mc(e)&&!gc(e)}function gc(e){return e&&(hc(e)||yc(e)||vc(e))}function hc(e){return J(e,"sequence")}function yc(e){return J(e,"sphere")}function vc(e){return J(e,"graticule")}let bc=function(e){return e[e.Raw=0]="Raw",e[e.Main=1]="Main",e[e.Row=2]="Row",e[e.Column=3]="Column",e[e.Lookup=4]="Lookup",e[e.PreFilterInvalid=5]="PreFilterInvalid",e[e.PostFilterInvalid=6]="PostFilterInvalid",e}({});function xc(e){let{invalid:t,isPath:n}=e;switch(po(t,{isPath:n})){case"filter":return{marks:"exclude-invalid-values",scales:"exclude-invalid-values"};case"break-paths-show-domains":return{marks:n?"include-invalid-values":"exclude-invalid-values",scales:"include-invalid-values"};case"break-paths-filter-domains":return{marks:n?"include-invalid-values":"exclude-invalid-values",scales:"exclude-invalid-values"};case"show":return{marks:"include-invalid-values",scales:"include-invalid-values"}}}class $c{_children=[];_parent=null;constructor(e,t){this.debugName=t,e&&(this.parent=e)}clone(){throw new Error("Cannot clone node")}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.includes(e)?Si("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);const n=e.parent.removeChild(e);this._parent=t,t.addChild(this,n),e.parent=this}}class wc extends $c{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}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)}dependentFields(){return new Set}producedFields(){return new Set}hash(){return void 0===this._hash&&(this._hash=`Output ${I()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(e){this._source=e}}function kc(e){return void 0!==e.as}function Sc(e){return`${e}_end`}class Dc extends $c{clone(){return new Dc(null,l(this.timeUnits))}constructor(e,t){super(e),this.timeUnits=t}static makeFromEncoding(e,t){const n=t.reduceFieldDef(((e,n,i)=>{const{field:r,timeUnit:o}=n;if(o){let a;if(Ti(o)){if(qm(t)){const{mark:e,markDef:i,config:s}=t,l=Ho({fieldDef:n,markDef:i,config:s});(eo(e)||l)&&(a={timeUnit:Ii(o),field:r})}}else a={as:ma(n,{forAs:!0}),field:r,timeUnit:o};if(qm(t)){const{mark:e,markDef:r,config:o}=t,s=Ho({fieldDef:n,markDef:r,config:o});eo(e)&&_t(i)&&.5!==s&&(a.rectBandPosition=s)}a&&(e[d(a)]=a)}return e}),{});return S(n)?null:new Dc(e,n)}static makeFromTransform(e,t){const{timeUnit:n,...i}={...t},r={...i,timeUnit:Ii(n)};return new Dc(e,{[d(r)]:r})}merge(e){this.timeUnits={...this.timeUnits};for(const t in e.timeUnits)this.timeUnits[t]||(this.timeUnits[t]=e.timeUnits[t]);for(const t of e.children)e.removeChild(t),t.parent=this;e.remove()}removeFormulas(e){const t={};for(const[n,i]of O(this.timeUnits)){const r=kc(i)?i.as:`${i.field}_end`;e.has(r)||(t[n]=i)}this.timeUnits=t}producedFields(){return new Set(F(this.timeUnits).map((e=>kc(e)?e.as:Sc(e.field))))}dependentFields(){return new Set(F(this.timeUnits).map((e=>e.field)))}hash(){return`TimeUnit ${d(this.timeUnits)}`}assemble(){const e=[];for(const t of F(this.timeUnits)){const{rectBandPosition:n}=t,i=Ii(t.timeUnit);if(kc(t)){const{field:r,as:o}=t,{unit:a,utc:s,...l}=i,c=[o,`${o}_end`];e.push({field:M(r),type:"timeunit",...a?{units:Ri(a)}:{},...s?{timezone:"utc"}:{},...l,as:c}),e.push(...Cc(c,n,i))}else if(t){const{field:r}=t,o=r.replaceAll("\\.","."),a=zc({timeUnit:i,field:o}),s=Sc(o);e.push({type:"formula",expr:a,as:s}),e.push(...Cc([o,s],n,i))}}return e}}const Fc="offsetted_rect_start",Oc="offsetted_rect_end";function zc(e){let{timeUnit:t,field:n,reverse:i}=e;const{unit:r,utc:o}=t,a=Li(r),{part:s,step:l}=Hi(a,t.step);return`${o?"utcOffset":"timeOffset"}('${s}', ${j(n)}, ${i?-l:l})`}function Cc(e,t,n){let[i,r]=e;if(void 0!==t&&.5!==t){const e=j(i),o=j(r);return[{type:"formula",expr:_c([zc({timeUnit:n,field:i,reverse:!0}),e],t+.5),as:`${i}_${Fc}`},{type:"formula",expr:_c([e,o],t+.5),as:`${i}_${Oc}`}]}return[]}function _c(e,t){let[n,i]=e;return`${1-t} * ${n} + ${t} * ${i}`}const Pc="_tuple_fields";class Nc{constructor(){for(var e=arguments.length,t=new Array(e),n=0;n!0,parse:(e,n,i)=>{const r=n.name,o=n.project??=new Nc,a={},s={},l=new Set,c=(e,t)=>{const n="visual"===t?e.channel:e.field;let i=C(`${r}_${n}`);for(let e=1;l.has(i);e++)i=C(`${r}_${n}_${e}`);return l.add(i),{[t]:i}},u=n.type,f=e.config.selection[u],m=void 0!==i.value?t.array(i.value):null;let{fields:p,encodings:g}=t.isObject(i.select)?i.select:{};if(!p&&!g&&m)for(const e of m)if(t.isObject(e))for(const n of D(e))h=n,t.hasOwnProperty(et,h)?(g||(g=[])).push(n):"interval"===u?(Si('Interval selections should be initialized using "x", "y", "longitude", or "latitude" keys.'),g=f.encodings):(p??=[]).push(n);var h;p||g||(g=f.encodings,"fields"in f&&(p=f.fields));for(const t of g??[]){const n=e.fieldDef(t);if(n){let i=n.field;if(n.aggregate){Si(Jn(t,n.aggregate));continue}if(!i){Si(Qn(t));continue}if(n.timeUnit&&!Ti(n.timeUnit)){i=e.vgField(t);const r={timeUnit:n.timeUnit,as:i,field:n.field};s[d(r)]=r}if(!a[i]){const r={field:i,channel:t,type:"interval"===u&&Qt(t)&&Sr(e.getScaleComponent(t).get("type"))?"R":n.bin?"R-RE":"E",index:o.items.length};r.signals={...c(r,"data"),...c(r,"visual")},o.items.push(a[i]=r),o.hasField[i]=a[i],o.hasSelectionId=o.hasSelectionId||i===zs,Le(t)?(r.geoChannel=t,r.channel=Re(t),o.hasChannel[r.channel]=a[i]):o.hasChannel[t]=a[i]}}else Si(Qn(t))}for(const e of p??[]){if(o.hasField[e])continue;const t={type:"E",field:e,index:o.items.length};t.signals={...c(t,"data")},o.items.push(t),o.hasField[e]=t,o.hasSelectionId=o.hasSelectionId||e===zs}m&&(n.init=m.map((e=>o.items.map((n=>t.isObject(e)?void 0!==e[n.geoChannel||n.channel]?e[n.geoChannel||n.channel]:e[n.field]:e))))),S(s)||(o.timeUnit=new Dc(null,s))},signals:(e,t,n)=>{const i=t.name+Pc;return n.filter((e=>e.name===i)).length>0||t.project.hasSelectionId?n:n.concat({name:i,value:t.project.items.map(Bc)})}},Tc="_curr",jc="anim_value",Ec="anim_clock",Mc="eased_anim_clock",Rc="min_extent",Lc="max_range_extent",qc="last_tick_at",Uc="is_playing",Wc=1/60*1e3,Ic={defined:e=>"point"===e.type,topLevelSignals:(e,t,n)=>(af(t)&&(n=n.concat([{name:Ec,init:"0",on:[{events:{type:"timer",throttle:Wc},update:`${Uc} ? (${Ec} + (now() - ${qc}) > ${Lc} ? 0 : ${Ec} + (now() - ${qc})) : ${Ec}`}]},{name:qc,init:"now()",on:[{events:[{signal:Ec},{signal:Uc}],update:"now()"}]},{name:Uc,init:"true"}])),n),signals:(e,n,i)=>{const r=n.name,o=r+Pc,a=n.project,s="(item().isVoronoi ? datum.datum : datum)",l=F(e.component.selection??{}).reduce(((e,t)=>"interval"===t.type?e.concat(t.name+Zc):e),[]).map((e=>`indexof(item().mark.name, '${e}') < 0`)).join(" && "),c="datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0"+(l?` && ${l}`:"");let u=`unit: ${nf(e)}, `;if(n.project.hasSelectionId)u+=`${zs}: ${s}[${t.stringValue(zs)}]`;else if(af(n))u+=`fields: ${o}, values: [${jc} ? ${jc} : ${Rc}]`;else{u+=`fields: ${o}, values: [${a.items.map((n=>{const i=e.fieldDef(n.channel);return i?.bin?`[${s}[${t.stringValue(e.vgField(n.channel,{}))}], ${s}[${t.stringValue(e.vgField(n.channel,{binSuffix:"end"}))}]]`:`${s}[${t.stringValue(n.field)}]`})).join(", ")}]`}if(af(n))return i.concat((f=n.name,d=e.scaleName(ge),[{name:Mc,update:Ec},{name:`${f}_domain`,init:`domain('${d}')`},{name:Rc,init:`extent(${f}_domain)[0]`},{name:Lc,init:`extent(range('${d}'))[1]`},{name:jc,update:`invert('${d}', ${Mc})`}]),[{name:r+Ku,on:[{events:[{signal:Mc},{signal:jc}],update:`{${u}}`,force:!0}]}]);{const e=n.events;return i.concat([{name:r+Ku,on:e?[{events:e,update:`${c} ? {${u}} : null`,force:!0}]:[]}])}var f,d}};function Bc(e){const{signals:t,hasLegend:n,index:i,...r}=e;return r.field=M(r.field),r}function Vc(e){let n=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t.identity;if(t.isArray(e)){const t=e.map((e=>Vc(e,n,i)));return n?`[${t.join(", ")}]`:t}return Di(e)?i(n?Pi(e):function(e){const t=_i(e,!0);return e.utc?+new Date(Date.UTC(...t)):+new Date(...t)}(e)):n?i(Q(e)):e}function Hc(e,n){for(const i of F(e.component.selection??{})){const r=i.name;let o=`${r}${Ku}, ${"global"===i.resolve?"true":`{unit: ${nf(e)}}`}`;for(const t of tf)t.defined(i)&&(t.signals&&(n=t.signals(e,i,n)),t.modifyExpr&&(o=t.modifyExpr(e,i,o)));n.push({name:r+Zu,on:[{events:{signal:i.name+Ku},update:`modify(${t.stringValue(i.name+Ju)}, ${o})`}]})}return Xc(n)}function Gc(e,n){if(e.