1?p-1:0),x=1;x0===P?O:`[${O}]`),A=S.map((O,P)=>S.slice(0,P+1).join(""));for(const O of A)p.add(O)}return p}function Oi(d,p){return void 0===d||void 0===p||Qi(an(d),an(p))}function Gt(d){return 0===We(d).length}Set.prototype.toJSON=function(){return`Set(${[...this].map(d=>Wn(d)).join(",")})`};const We=Object.keys,Dn=Object.values,Jt=Object.entries;function Hi(d){return!0===d||!1===d}function hn(d){const p=d.replace(/\W/g,"_");return(d.match(/^\d+/)?"_":"")+p}function io(d,p){return Qe(d)?`!(${io(d.not,p)})`:Be(d)?`(${d.and.map(_=>io(_,p)).join(") && (")})`:fe(d)?`(${d.or.map(_=>io(_,p)).join(") || (")})`:p(d)}function xn(d,p){if(0===p.length)return!0;const _=p.shift();return _ in d&&xn(d[_],p)&&delete d[_],Gt(d)}function Mo(d){return d.charAt(0).toUpperCase()+d.substr(1)}function Js(d){let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"datum";const _=re.splitAccessPath(d),x=[];for(let S=1;S<=_.length;S++){const A=`[${_.slice(0,S).map(re.stringValue).join("][")}]`;x.push(`${p}${A}`)}return x.join(" && ")}function Vo(d){return`${arguments.length>1&&void 0!==arguments[1]?arguments[1]:"datum"}[${re.stringValue(re.splitAccessPath(d).join("."))}]`}function Mi(d){return d.replace(/(\[|\]|\.|'|")/g,"\\$1")}function ci(d){return`${re.splitAccessPath(d).map(Mi).join("\\.")}`}function jo(d,p,_){return d.replace(new RegExp(p.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),_)}function Si(d){return`${re.splitAccessPath(d).join(".")}`}function ro(d){return d?re.splitAccessPath(d).length:0}function ui(){for(var d=arguments.length,p=new Array(d),_=0;_Q_(d[p])?hn(`_${p}_${Jt(d[p])}`):hn(`_${p}_${d[p]}`)).join("")}function sr(d){return!0===d||Lc(d)&&!d.binned}function oo(d){return"binned"===d||Lc(d)&&!0===d.binned}function Lc(d){return re.isObject(d)}function Q_(d){return d?.param}function iv(d){switch(d){case ea:case Xl:case He:case be:case Se:case Fe:case Ts:case _e:case nn:case gi:case ye:return 6;case Hh:return 4;default:return 10}}function Ea(d){return!!d?.expr}function _o(d){const p=We(d||{}),_={};for(const x of p)_[x]=Ha(d[x]);return _}function pl(d){const{anchor:p,frame:_,offset:x,orient:S,angle:A,limit:O,color:P,subtitleColor:B,subtitleFont:q,subtitleFontSize:G,subtitleFontStyle:ee,subtitleFontWeight:se,subtitleLineHeight:Ee,subtitlePadding:De,...Re}=d,Ye={...p?{anchor:p}:{},..._?{frame:_}:{},...x?{offset:x}:{},...S?{orient:S}:{},...void 0!==A?{angle:A}:{},...void 0!==O?{limit:O}:{}},bt={...B?{subtitleColor:B}:{},...q?{subtitleFont:q}:{},...G?{subtitleFontSize:G}:{},...ee?{subtitleFontStyle:ee}:{},...se?{subtitleFontWeight:se}:{},...Ee?{subtitleLineHeight:Ee}:{},...De?{subtitlePadding:De}:{}};return{titleMarkConfig:{...Re,...P?{fill:P}:{}},subtitleMarkConfig:Sn(d,["align","baseline","dx","dy","limit"]),nonMarkTitleProperties:Ye,subtitle:bt}}function ds(d){return re.isString(d)||re.isArray(d)&&re.isString(d[0])}function Je(d){return!!d?.signal}function ht(d){return!!d.step}function vu(d){return!re.isArray(d)&&"field"in d&&"data"in d}const gd=We({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}),OM={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},rv=["cornerRadius","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight"];function RM(d){const p=re.isArray(d.condition)?d.condition.map(NM):NM(d.condition);return{...Ha(d),condition:p}}function Ha(d){if(Ea(d)){const{expr:p,..._}=d;return{signal:p,..._}}return d}function NM(d){if(Ea(d)){const{expr:p,..._}=d;return{signal:p,..._}}return d}function Ar(d){if(Ea(d)){const{expr:p,..._}=d;return{signal:p,..._}}return Je(d)?d:void 0!==d?{value:d}:void 0}function Jl(d){return Je(d)?d.signal:re.stringValue(d)}function FM(d){return Je(d)?d.signal:re.stringValue(d.value)}function ec(d){return Je(d)?d.signal:null==d?null:re.stringValue(d)}function R2(d,p,_){for(const x of _){const S=xu(x,p.markDef,p.config);void 0!==S&&(d[x]=Ar(S))}return d}function F1(d){return[].concat(d.type,d.style??[])}function Ji(d,p,_){let x=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const{vgChannel:S,ignoreVgConfig:A}=x;return S&&void 0!==p[S]?p[S]:void 0!==p[d]?p[d]:!A||S&&S!==d?xu(d,p,_,x):void 0}function xu(d,p,_){let{vgChannel:x}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return ui(x?ey(d,p,_.style):void 0,ey(d,p,_.style),x?_[p.type][x]:void 0,_[p.type][d],x?_.mark[x]:_.mark[d])}function ey(d,p,_){return PM(d,F1(p),_)}function PM(d,p,_){let x;p=re.array(p);for(const S of p){const A=_[S];A&&void 0!==A[d]&&(x=A[d])}return x}function LM(d,p){return re.array(d).reduce((_,x)=>(_.field.push(pt(x,p)),_.order.push(x.sort??"ascending"),_),{field:[],order:[]})}function $M(d,p){const _=[...d];return p.forEach(x=>{for(const S of _)if(xr(S,x))return;_.push(x)}),_}function Rn(d,p){return xr(d,p)||!p?d:d?[...re.array(d),...re.array(p)].join(", "):p}function BM(d,p){const _=d.value,x=p.value;if(null==_||null===x)return{explicit:d.explicit,value:null};if((ds(_)||Je(_))&&(ds(x)||Je(x)))return{explicit:d.explicit,value:Rn(_,x)};if(ds(_)||Je(_))return{explicit:d.explicit,value:_};if(ds(x)||Je(x))return{explicit:d.explicit,value:x};if(!(ds(_)||Je(_)||ds(x)||Je(x)))return{explicit:d.explicit,value:$M(_,x)};throw new Error("It should never reach here")}function ln(d,p,_){return(p=function zM(d){var p=function Ft(d,p){if("object"!=typeof d||null===d)return d;var _=d[Symbol.toPrimitive];if(void 0!==_){var x=_.call(d,p||"default");if("object"!=typeof x)return x;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===p?String:Number)(d)}(d,"string");return"symbol"==typeof p?p:String(p)}(p))in d?Object.defineProperty(d,p,{value:_,enumerable:!0,configurable:!0,writable:!0}):d[p]=_,d}function fs(d,p,_){return function ks(d,p,_){if(p.set)p.set.call(d,_);else{if(!p.writable)throw new TypeError("attempted to set read only private field");p.value=_}}(d,Jn(d,p,"set"),_),_}function Jn(d,p,_){if(!p.has(d))throw new TypeError("attempted to "+_+" private field on non-instance");return p.get(d)}function ia(d,p,_){(function Nf(d,p){if(p.has(d))throw new TypeError("Cannot initialize the same private elements twice on an object")})(d,p),p.set(d,_)}function ov(d){return`Invalid specification ${Wn(d)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`}const VM='Autosize "fit" only works for single views and layered views.';function jm(d){return("width"==d?"Width":"Height")+' "container" only works for single views and layered views.'}function jM(d){return`${"width"==d?"Width":"Height"} "container" only works well with autosize "fit" or "fit-${"width"==d?"x":"y"}".`}function UM(d){return d?`Dropping "fit-${d}" because spec has discrete ${Mr(d)}.`:'Dropping "fit" because spec has discrete size.'}function Tr(d){return`Unknown field for ${d}. Cannot calculate view size.`}function mt(d){return`Cannot project a selection on encoding channel "${d}", which has no field.`}function _n(d,p){return`Cannot project a selection on encoding channel "${d}" as it uses an aggregate function ("${p}").`}function tc(d){return`Selection not supported for ${d} yet.`}const wu="The same selection must be used to override scale domains in a layered view.";function P1(d){return`The "columns" property cannot be used when "${d}" has nested row/column.`}function Wm(d,p,_){return`An ancestor parsed field "${d}" as ${_} but a child wants to parse the field as ${p}.`}function Eu(d){return`Ignoring an invalid transform: ${Wn(d)}.`}function L1(d){return`Config.customFormatTypes is not true, thus custom format type and format for channel ${d} are dropped.`}function Yh(d){return`${d}Offset dropped because ${d} is continuous`}function av(d){return`Invalid field type "${d}".`}function Gm(d,p){const{fill:_,stroke:x}=p;return`Dropping color ${d} as the plot also has ${_&&x?"fill and stroke":_?"fill":"stroke"}.`}function Nr(d,p){return`Dropping ${Wn(d)} from channel "${p}" since it does not contain any data field, datum, value, or signal.`}function bo(d,p,_){return`${d} dropped as it is incompatible with "${p}"${_?` when ${_}`:""}.`}function Is(d){return`${d}-encoding is dropped as ${d} is not a valid encoding channel.`}function $1(d){return`${d} encoding should be discrete (ordinal / nominal / binned).`}function zc(d){return`${d} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`}function ml(d,p){return`Using discrete channel "${d}" to encode "${p}" field can be misleading as it does not encode ${"ordinal"===p?"order":"magnitude"}.`}function WM(d){return`Using unaggregated domain with raw field has no effect (${Wn(d)}).`}function fv(d){return`Unaggregated domain not applicable for "${d}" since it produces values outside the origin domain of the source data.`}function qM(d){return`Unaggregated domain is currently unsupported for log scale (${Wn(d)}).`}function z1(d,p,_){return`${_}-scale's "${p}" is dropped as it does not work with ${d} scale.`}function GM(d){return`The step for "${d}" is dropped because the ${"width"===d?"x":"y"} is continuous.`}const P2="Domains that should be unioned has conflicting sort properties. Sort will be set to true.";function V1(d,p){return`Invalid ${d}: ${Wn(p)}.`}function ry(d){return`1D error band does not support ${d}.`}function eA(d){return`Channel ${d} is required for "binned" bin.`}const pv=re.logger(re.Warn);let Xm=pv;function nt(){Xm.warn(...arguments)}function _d(d){if(d&&re.isObject(d))for(const p of Pf)if(p in d)return!0;return!1}const gv=["january","february","march","april","may","june","july","august","september","october","november","december"],H1=gv.map(d=>d.substr(0,3)),B2=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],er=B2.map(d=>d.substr(0,3));function Ym(d,p){const _=[];if(p&&void 0!==d.day&&We(d).length>1&&(nt(function Kh(d){return`Dropping day from datetime ${Wn(d)} as day cannot be combined with other units.`}(d)),delete(d=st(d)).day),_.push(void 0!==d.year?d.year:2012),void 0!==d.month){const x=p?function sy(d){if(vr(d)&&(d=+d),re.isNumber(d))return d-1;{const p=d.toLowerCase(),_=gv.indexOf(p);if(-1!==_)return _;const x=p.substr(0,3),S=H1.indexOf(x);if(-1!==S)return S;throw new Error(V1("month",d))}}(d.month):d.month;_.push(x)}else if(void 0!==d.quarter){const x=p?function W1(d){if(vr(d)&&(d=+d),re.isNumber(d))return d>4&&nt(V1("quarter",d)),d-1;throw new Error(V1("quarter",d))}(d.quarter):d.quarter;_.push(re.isNumber(x)?3*x:`${x}*3`)}else _.push(0);if(void 0!==d.date)_.push(d.date);else if(void 0!==d.day){const x=p?function oa(d){if(vr(d)&&(d=+d),re.isNumber(d))return d%7;{const p=d.toLowerCase(),_=B2.indexOf(p);if(-1!==_)return _;const x=p.substr(0,3),S=er.indexOf(x);if(-1!==S)return S;throw new Error(V1("day",d))}}(d.day):d.day;_.push(re.isNumber(x)?x+1:`${x}+1`)}else _.push(1);for(const x of["hours","minutes","seconds","milliseconds"]){const S=d[x];_.push(typeof S>"u"?0:S)}return _}function gl(d){const _=Ym(d,!0).join(", ");return d.utc?`utc(${_})`:`datetime(${_})`}const nA={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},Pf=We(nA);function qo(d){return re.isObject(d)?d.binned:ay(d)}function ay(d){return d&&d.startsWith("binned")}function yv(d){return d.startsWith("utc")}const ly={"year-month":"%b %Y ","year-month-date":"%b %d, %Y "};function Kt(d){return Pf.filter(p=>Ti(d,p))}function Qh(d){const p=Kt(d);return p[p.length-1]}function Ti(d,p){const _=d.indexOf(p);return!(_<0||_>0&&"seconds"===p&&"i"===d.charAt(_-1)||d.length>_+3&&"day"===p&&"o"===d.charAt(_+3)||_>0&&"year"===p&&"f"===d.charAt(_-1))}function cy(d,p){let{end:_}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{end:!1};const x=Js(p),S=yv(d)?"utc":"";function A(B){return"quarter"===B?`(${S}quarter(${x})-1)`:`${S}${B}(${x})`}let O;const P={};for(const B of Pf)Ti(d,B)&&(P[B]=A(B),O=B);return _&&(P[O]+="+1"),function Zh(d){const _=Ym(d,!1).join(", ");return d.utc?`utc(${_})`:`datetime(${_})`}(P)}function Vc(d){if(d)return`timeUnitSpecifier(${Wn(Kt(d))}, ${Wn(ly)})`}function Fr(d){if(!d)return;let p;return re.isString(d)?p=ay(d)?{unit:d.substring(6),binned:!0}:{unit:d}:re.isObject(d)&&(p={...d,...d.unit?{unit:d.unit}:{}}),yv(p.unit)&&(p.utc=!0,p.unit=function iA(d){return d.substring(3)}(p.unit)),p}function Lf(d){let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:S=>S;const _=Fr(d),x=Qh(_.unit);if(x&&"day"!==x){const S={year:2001,month:1,date:1,hours:0,minutes:0,seconds:0,milliseconds:0},{step:A,part:O}=q1(x,_.step);return`${p(gl({...S,[O]:+S[O]+A}))} - ${p(gl(S))}`}}const bv={year:1,month:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1};function q1(d){let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;if(function vv(d){return!!bv[d]}(d))return{part:d,step:p};switch(d){case"day":case"dayofyear":return{part:"date",step:p};case"quarter":return{part:"month",step:3*p};case"week":return{part:"date",step:7*p}}}function G1(d){return!!d?.field&&void 0!==d.equal}function X1(d){return!!d?.field&&void 0!==d.lt}function Y1(d){return!!d?.field&&void 0!==d.lte}function ar(d){return!!d?.field&&void 0!==d.gt}function xv(d){return!!d?.field&&void 0!==d.gte}function qe(d){if(d?.field){if(re.isArray(d.range)&&2===d.range.length)return!0;if(Je(d.range))return!0}return!1}function bi(d){return!!d?.field&&(re.isArray(d.oneOf)||re.isArray(d.in))}function so(d){return bi(d)||G1(d)||qe(d)||X1(d)||ar(d)||Y1(d)||xv(d)}function Un(d,p){return Td(d,{timeUnit:p,wrapTime:!0})}function Zm(d){let p=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];const{field:_}=d,x=Fr(d.timeUnit),{unit:S,binned:A}=x||{},O=pt(d,{expr:"datum"}),P=S?`time(${A?O:cy(S,_)})`:O;if(G1(d))return`${P}===${Un(d.equal,S)}`;if(X1(d))return`${P}<${Un(d.lt,S)}`;if(ar(d))return`${P}>${Un(d.gt,S)}`;if(Y1(d))return`${P}<=${Un(d.lte,S)}`;if(xv(d))return`${P}>=${Un(d.gte,S)}`;if(bi(d))return`indexof([${function rA(d,p){return d.map(_=>Un(_,p))}(d.oneOf,S).join(",")}], ${P}) !== -1`;if(function hs(d){return!!d?.field&&void 0!==d.valid}(d))return ic(P,d.valid);if(qe(d)){const{range:B}=d,q=Je(B)?{signal:`${B.signal}[0]`}:B[0],G=Je(B)?{signal:`${B.signal}[1]`}:B[1];if(null!==q&&null!==G&&p)return"inrange("+P+", ["+Un(q,S)+", "+Un(G,S)+"])";const ee=[];return null!==q&&ee.push(`${P} >= ${Un(q,S)}`),null!==G&&ee.push(`${P} <= ${Un(G,S)}`),ee.length>0?ee.join(" && "):"true"}throw new Error(`Invalid field predicate: ${Wn(d)}`)}function ic(d){return arguments.length>1&&void 0!==arguments[1]&&!arguments[1]?`!isValid(${d}) || !isFinite(+${d})`:`isValid(${d}) && isFinite(+${d})`}function K1(d){return so(d)&&d.timeUnit?{...d,timeUnit:Fr(d.timeUnit)}:d}function V2(d){return"quantitative"===d||"temporal"===d}function Z1(d){return"ordinal"===d||"nominal"===d}const $f="quantitative",Os="ordinal",qa="temporal",wv="nominal",Sa="geojson";const Ga={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"},Ev={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 Cv(d,p){const _=Ev[d],x=Ev[p];return _===x||"ordinal-position"===_&&"time"===x||"ordinal-position"===x&&"time"===_}const Cu={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 jc(d){return Cu[d]}const rc=new Set(["linear","log","pow","sqrt","symlog"]),Q1=new Set([...rc,"time","utc"]);function uy(d){return rc.has(d)}const Jh=new Set(["quantile","quantize","threshold"]),J1=new Set([...Q1,...Jh,"sequential","identity"]),ep=new Set(["ordinal","bin-ordinal","point","band"]);function ko(d){return ep.has(d)}function Da(d){return J1.has(d)}function Go(d){return Q1.has(d)}function vd(d){return Jh.has(d)}function Xo(d){return d?.param}const{type:oA,domain:sA,range:Z$,rangeMax:aA,rangeMin:j2,scheme:eE,...Bf}={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},tE=We(Bf);function Qm(d,p){switch(p){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!["point","band","identity"].includes(d);case"bins":return!["point","band","identity","ordinal"].includes(d);case"round":return Go(d)||"band"===d||"point"===d;case"padding":case"rangeMin":case"rangeMax":return Go(d)||["point","band"].includes(d);case"paddingOuter":case"align":return["point","band"].includes(d);case"paddingInner":return"band"===d;case"domainMax":case"domainMid":case"domainMin":case"domainRaw":case"clamp":return Go(d);case"nice":return Go(d)||"quantize"===d||"threshold"===d;case"exponent":return"pow"===d;case"base":return"log"===d;case"constant":return"symlog"===d;case"zero":return Da(d)&&!St(["log","time","utc","threshold","quantile"],d)}}function fy(d,p){switch(p){case"interpolate":case"scheme":case"domainMid":return Wh(d)?void 0:function dv(d){return`Cannot use the scale property "${d}" with non-color channel.`}(p);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 Rs={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"},iE=Rs.arc,xd=Rs.area,_l=Rs.bar,ze=Rs.image,wd=Rs.line,np=Rs.point,lA=Rs.rect,Su=Rs.rule,Av=Rs.text,U2=Rs.tick,H2=Rs.trail,zf=Rs.circle,Vf=Rs.square,Jm=Rs.geoshape;function yl(d){return["line","area","trail"].includes(d)}function ip(d){return["rect","bar","image","arc"].includes(d)}const eg=new Set(We(Rs));function Du(d){return d.type}const q2=["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit","fill","fillOpacity"],G2=We({color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBandSize:1,timeUnitBandPosition:1}),rp=We({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 Au(d){return d&&null!=d.band}const oc={horizontal:["cornerRadiusTopRight","cornerRadiusBottomRight"],vertical:["cornerRadiusTopLeft","cornerRadiusTopRight"]},sE={binSpacing:1,continuousBandSize:5,minBandSize:.25,timeUnitBandPosition:.5},aE={binSpacing:0,continuousBandSize:5,minBandSize:.25,timeUnitBandPosition:.5};function tg(d){const{channel:p,channelDef:_,markDef:x,scale:S,config:A}=d,O=lE(d);return dt(_)&&!zm(_.aggregate)&&S&&Go(S.get("type"))?function jf(d){let{fieldDef:p,channel:_,markDef:x,ref:S,config:A}=d;return yl(x.type)?S:null===Ji("invalid",x,A)?[Y2(p,_),S]:S}({fieldDef:_,channel:p,markDef:x,ref:O,config:A}):O}function Y2(d,p){return{test:Uf(d,!0),..."y"===Fc(p)?{field:{group:"height"}}:{value:0}}}function Uf(d){let p=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return ic(re.isString(d)?d:pt(d,{expr:"datum"}),!p)}function Xa(d,p,_,x){const S={};if(p&&(S.scale=p),Sd(d)){const{datum:A}=d;_d(A)?S.signal=gl(A):Je(A)?S.signal=A.signal:Ea(A)?S.signal=A.expr:S.value=A}else S.field=pt(d,_);if(x){const{offset:A,band:O}=x;A&&(S.offset=A),O&&(S.band=O)}return S}function sc(d){let{scaleName:p,fieldOrDatumDef:_,fieldOrDatumDef2:x,offset:S,startSuffix:A,endSuffix:O="end",bandPosition:P=.5}=d;const B=!Je(P)&&01&&void 0!==arguments[1]?arguments[1]:{},_=d.field;const x=p.prefix;let S=p.suffix,A="";if(function xy(d){return"count"===d.aggregate}(d))_=cs("count");else{let O;if(!p.nofn)if(function Z2(d){return"op"in d}(d))O=d.op;else{const{bin:P,aggregate:B,timeUnit:q}=d;sr(P)?(O=Z_(P),S=(p.binSuffix??"")+(p.suffix??"")):B?Ua(B)?(A=`["${_}"]`,_=`argmax_${B.argmax}`):bu(B)?(A=`["${_}"]`,_=`argmin_${B.argmin}`):O=String(B):q&&!qo(q)&&(O=function z2(d){const{utc:p,..._}=Fr(d);return _.unit?(p?"utc":"")+We(_).map(x=>hn(`${"unit"===x?"":`_${x}_`}${_[x]}`)).join(""):(p?"utc":"")+"timeunit"+We(_).map(x=>hn(`_${x}_${_[x]}`)).join("")}(q),S=(!["range","mid"].includes(p.binSuffix)&&p.binSuffix||"")+(p.suffix??""))}O&&(_=_?`${O}_${_}`:O)}return S&&(_=`${_}_${S}`),x&&(_=`${x}_${_}`),p.forAs?Si(_):p.expr?Vo(_,p.expr)+A:ci(_)+A}function Fv(d){switch(d.type){case"nominal":case"ordinal":case"geojson":return!0;case"quantitative":return dt(d)&&!!d.bin;case"temporal":return!1}throw new Error(av(d.type))}const fA=(d,p)=>{switch(p.fieldTitle){case"plain":return d.field;case"functional":return function Md(d){const{aggregate:p,bin:_,timeUnit:x,field:S}=d;if(Ua(p))return`${S} for argmax(${p.argmax})`;if(bu(p))return`${S} for argmin(${p.argmin})`;const A=x&&!qo(x)?Fr(x):void 0,O=p||A?.unit||A?.maxbins&&"timeunit"||sr(_)&&"bin";return O?`${O.toUpperCase()}(${S})`:S}(d);default:return function Io(d,p){const{field:_,bin:x,timeUnit:S,aggregate:A}=d;if("count"===A)return p.countTitle;if(sr(x))return`${_} (binned)`;if(S&&!qo(S)){const O=Fr(S)?.unit;if(O)return`${_} (${Kt(O).join("-")})`}else if(A)return Ua(A)?`${_} for max ${A.argmax}`:bu(A)?`${_} for min ${A.argmin}`:`${Mo(A)} of ${_}`;return _}(d,p)}};let Pv=fA;function Gf(d){Pv=d}function cp(d,p,_){let{allowDisabling:x,includeDefault:S=!0}=_;const A=hA(d)?.title;if(!dt(d))return A??d.title;const O=d,P=S?lg(O,p):void 0;return x?ui(A,O.title,P):A??O.title??P}function hA(d){return Dd(d)&&d.axis?d.axis:ag(d)&&d.legend?d.legend:Zr(d)&&d.header?d.header:void 0}function lg(d,p){return Pv(d,p)}function Lv(d){if(dA(d)){const{format:p,formatType:_}=d;return{format:p,formatType:_}}{const p=hA(d)??{},{format:_,formatType:x}=p;return{format:_,formatType:x}}}function ku(d){return dt(d)?d:qf(d)?d.condition:void 0}function Oo(d){return Bn(d)?d:Nv(d)?d.condition:void 0}function mA(d,p,_){let x=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return re.isString(d)||re.isNumber(d)||re.isBoolean(d)?(nt(function $n(d,p,_){return`Channel ${d} is a ${p}. Converted to {value: ${Wn(_)}}.`}(p,re.isString(d)?"string":re.isNumber(d)?"number":"boolean",d)),{value:d}):Bn(d)?qc(d,p,_,x):Nv(d)?{...d,condition:qc(d.condition,p,_,x)}:d}function qc(d,p,_,x){if(dA(d)){const{format:S,formatType:A,...O}=d;if(Uc(A)&&!_.customFormatTypes)return nt(L1(p)),qc(O,p,_,x)}else{const S=Dd(d)?"axis":ag(d)?"legend":Zr(d)?"header":null;if(S&&d[S]){const{format:A,formatType:O,...P}=d[S];if(Uc(O)&&!_.customFormatTypes)return nt(L1(p)),qc({...d,[S]:P},p,_,x)}}return dt(d)?cg(d,p,x):function gE(d){let p=d.type;if(p)return d;const{datum:_}=d;return p=re.isNumber(_)?"quantitative":re.isString(_)?"nominal":_d(_)?"temporal":void 0,{...d,type:p}}(d)}function cg(d,p){let{compositeMark:_=!1}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{aggregate:x,timeUnit:S,bin:A,field:O}=d,P={...d};if(!_&&x&&!K_(x)&&!Ua(x)&&!bu(x)&&(nt(function $c(d){return`Invalid aggregation operator "${d}".`}(x)),delete P.aggregate),S&&(P.timeUnit=Fr(S)),O&&(P.field=`${O}`),sr(A)&&(P.bin=Ad(A,p)),oo(A)&&!Yr(p)&&nt(function $2(d){return`Channel ${d} should not be used with "binned" bin.`}(p)),Yo(P)){const{type:B}=P,q=function bd(d){if(d)switch(d=d.toLowerCase(),d){case"q":case $f:return"quantitative";case"t":case qa:return"temporal";case"o":case Os:return"ordinal";case"n":case wv:return"nominal";case Sa:return"geojson"}}(B);B!==q&&(P.type=q),"quantitative"!==B&&zm(x)&&(nt(function qm(d,p){return`Invalid field type "${d}" for aggregate: "${p}", using "quantitative" instead.`}(B,x)),P.type="quantitative")}else if(!SM(p)){const B=function pA(d,p){switch(p){case"latitude":case"longitude":return"quantitative";case"row":case"column":case"facet":case"shape":case"strokeDash":return"nominal";case"order":return"ordinal"}if(Cd(d)&&re.isArray(d.sort))return"ordinal";const{aggregate:_,bin:x,timeUnit:S}=d;if(S)return"temporal";if(x||_&&!Ua(_)&&!bu(_))return"quantitative";if(sp(d)&&d.scale?.type)switch(Ev[d.scale.type]){case"numeric":case"discretizing":return"quantitative";case"time":return"temporal"}return"nominal"}(P,p);P.type=B}if(Yo(P)){const{compatible:B,warning:q}=function Q2(d,p){const _=d.type;if("geojson"===_&&"shape"!==p)return{compatible:!1,warning:`Channel ${p} should not be used with a geojson data.`};switch(p){case ea:case Xl:case yu:return Fv(d)?Iu:{compatible:!1,warning:$1(p)};case Ri:case mo:case Yl:case Qn:case be:case Se:case Fe:case G0:case X0:case I1:case W_:case Gi:case O1:case lt:case As:case Ao:case go:return Iu;case Ho:case ae:case It:case wr:return _!==$f?{compatible:!1,warning:`Channel ${p} should be used with a quantitative field only, not ${d.type} field.`}:Iu;case _e:case nn:case gi:case Ts:case He:case Rc:case ta:case Wi:case Oc:return"nominal"!==_||d.sort?Iu:{compatible:!1,warning:`Channel ${p} should not be used with an unsorted discrete field.`};case ye:case Hh:return Fv(d)||function mE(d){return sp(d)&&vd(d.scale?.type)}(d)?Iu:{compatible:!1,warning:zc(p)};case Kl:return"nominal"!==d.type||"sort"in d?Iu:{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}}}(P,p)||{};!1===B&&nt(q)}if(Cd(P)&&re.isString(P.sort)){const{sort:B}=P;if(rg(B))return{...P,sort:{encoding:B}};const q=B.substr(1);if("-"===B.charAt(0)&&rg(q))return{...P,sort:{encoding:q,order:"descending"}}}if(Zr(P)){const{header:B}=P;if(B){const{orient:q,...G}=B;if(q)return{...P,header:{...G,labelOrient:B.labelOrient||q,titleOrient:B.titleOrient||q}}}}return P}function Ad(d,p){return re.isBoolean(d)?{maxbins:iv(p)}:"binned"===d?{binned:!0}:d.maxbins||d.step?d:{...d,maxbins:iv(p)}}const Iu={compatible:!0};function up(d){const{formatType:p}=Lv(d);return"time"===p||!p&&function _E(d){return d&&("temporal"===d.type||dt(d)&&!!d.timeUnit)}(d)}function Td(d,p){let{timeUnit:_,type:x,wrapTime:S,undefinedIfExprNotRequired:A}=p;const O=_&&Fr(_)?.unit;let B,P=O||"temporal"===x;return Ea(d)?B=d.expr:Je(d)?B=d.signal:_d(d)?(P=!0,B=gl(d)):(re.isString(d)||re.isNumber(d))&&P&&(B=`datetime(${Wn(d)})`,function _v(d){return!!nA[d]}(O)&&(re.isNumber(d)&&d<1e4||re.isString(d)&&isNaN(Date.parse(d)))&&(B=gl({[O]:d}))),B?S&&P?`time(${B})`:B:A?void 0:Wn(d)}function gA(d,p){const{type:_}=d;return p.map(x=>{const A=Td(x,{timeUnit:dt(d)&&!qo(d.timeUnit)?d.timeUnit:void 0,type:_,undefinedIfExprNotRequired:!0});return void 0!==A?{signal:A}:x})}function kd(d,p){return sr(d.bin)?pd(p)&&["ordinal","nominal"].includes(d.type):(console.warn("Only call this method for binned field defs."),!1)}const _A={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 Xf(d){return d?.condition}const yE=["domain","grid","labels","ticks","title"],$v={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"},Ou={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},Bv={...Ou,style:1,labelExpr:1,encoding:1};function wy(d){return!!Bv[d]}const zv=We({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 vl(d){return"mark"in d}class Id{constructor(p,_){this.name=p,this.run=_}hasMatchingType(p){return!!vl(p)&&function X2(d){return Du(d)?d.type:d}(p.mark)===this.name}}function xo(d,p){const _=d&&d[p];return!!_&&(re.isArray(_)?li(_,x=>!!x.field):dt(_)||qf(_))}function Yf(d,p){const _=d&&d[p];return!!_&&(re.isArray(_)?li(_,x=>!!x.field):dt(_)||Sd(_)||Nv(_))}function dp(d,p){if(Yr(p)){const _=d[p];if((dt(_)||Sd(_))&&(Z1(_.type)||dt(_)&&_.timeUnit))return Yf(d,To(p))}return!1}function vE(d){return li(Y0,p=>{if(xo(d,p)){const _=d[p];if(re.isArray(_))return li(_,x=>!!x.aggregate);{const x=ku(_);return x&&!!x.aggregate}}return!1})}function Vv(d,p){const _=[],x=[],S=[],A=[],O={};return Ey(d,(P,B)=>{if(dt(P)){const{field:q,aggregate:G,bin:ee,timeUnit:se,...Ee}=P;if(G||se||ee){const Re=hA(P)?.title;let Le=pt(P,{forAs:!0});const Ye={...Re?[]:{title:cp(P,p,{allowDisabling:!0})},...Ee,field:Le};if(G){let bt;if(Ua(G)?(bt="argmax",Le=pt({op:"argmax",field:G.argmax},{forAs:!0}),Ye.field=`${Le}.${q}`):bu(G)?(bt="argmin",Le=pt({op:"argmin",field:G.argmin},{forAs:!0}),Ye.field=`${Le}.${q}`):"boxplot"!==G&&"errorbar"!==G&&"errorband"!==G&&(bt=G),bt){const kn={op:bt,as:Le};q&&(kn.field=q),A.push(kn)}}else if(_.push(Le),Yo(P)&&sr(ee))x.push({bin:ee,field:q,as:Le}),_.push(pt(P,{binSuffix:"end"})),kd(P,B)&&_.push(pt(P,{binSuffix:"range"})),Yr(B)&&(O[`${B}2`]={field:`${Le}_end`}),Ye.bin="binned",SM(B)||(Ye.type=$f);else if(se&&!qo(se)){S.push({timeUnit:se,field:q,as:Le});const bt=Yo(P)&&P.type!==qa&&"time";bt&&(B===G0||B===W_?Ye.formatType=bt:function I2(d){return!!Z0[d]}(B)?Ye.legend={formatType:bt,...Ye.legend}:Yr(B)&&(Ye.axis={formatType:bt,...Ye.axis}))}O[B]=Ye}else _.push(q),O[B]=d[B]}else O[B]=d[B]}),{bins:x,timeUnits:S,aggregate:A,groupby:_,encoding:O}}function yA(d,p,_){const x=O2(p,_);if(!x)return!1;if("binned"===x){const S=d[p===Wi?Ri:mo];return!!(dt(S)&&dt(d[p])&&oo(S.bin))}return!0}function jv(d,p){const _={};for(const x of We(d)){const S=mA(d[x],x,p,{compositeMark:!0});_[x]=S}return _}function xE(d){const p=[];for(const _ of We(d))if(xo(d,_)){const S=re.array(d[_]);for(const A of S)dt(A)?p.push(A):qf(A)&&p.push(A.condition)}return p}function Ey(d,p,_){if(d)for(const x of We(d)){const S=d[x];if(re.isArray(S))for(const A of S)p.call(_,A,x);else p.call(_,S,x)}}function Od(d,p){return We(p).reduce((_,x)=>{switch(x){case Ri:case mo:case Gi:case go:case O1:case Wi:case Oc:case Yl:case Qn:case As:case Rc:case Ao:case ta:case It:case Ho:case wr:case ae:case G0:case ye:case lt:case W_:return _;case Kl:if("line"===d||"trail"===d)return _;case X0:case I1:{const S=p[x];if(re.isArray(S)||dt(S))for(const A of re.array(S))A.aggregate||_.push(pt(A,{}));return _}case He:if("trail"===d)return _;case be:case Se:case Fe:case _e:case nn:case gi:case Hh:case Ts:{const S=ku(p[x]);return S&&!S.aggregate&&_.push(pt(S,{})),_}}},[])}function Wv(d,p,_){let x=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];return"tooltip"in _?{tooltip:_.tooltip}:{tooltip:[...d.map(O=>{let{fieldPrefix:P,titlePrefix:B}=O;const q=x?` of ${Cy(p)}`:"";return{field:P+p.field,type:p.type,title:Je(B)?{signal:`${B}"${escape(q)}"`}:B+q}}),...Ci(xE(_).map(ap),kt)]}}function Cy(d){const{title:p,field:_}=d;return ui(p,_)}function Sy(d,p,_,x,S){const{scale:A,axis:O}=_;return P=>{let{partName:B,mark:q,positionPrefix:G,endPositionPrefix:ee,extraEncoding:se={}}=P;const Ee=Cy(_);return qv(d,B,S,{mark:q,encoding:{[p]:{field:`${G}_${_.field}`,type:_.type,...void 0!==Ee?{title:Ee}:{},...void 0!==A?{scale:A}:{},...void 0!==O?{axis:O}:{}},...re.isString(ee)?{[`${p}2`]:{field:`${ee}_${_.field}`}}:{},...x,...se}})}}function qv(d,p,_,x){const{clip:S,color:A,opacity:O}=d,P=d.type;return d[p]||void 0===d[p]&&_[p]?[{...x,mark:{..._[p],...S?{clip:S}:{},...A?{color:A}:{},...O?{opacity:O}:{},...Du(x.mark)?x.mark:{type:x.mark},style:`${P}-${String(p)}`,...re.isBoolean(d[p])?{}:d[p]}}]:[]}function bA(d,p,_){const{encoding:x}=d,S="vertical"===p?"y":"x",O=x[`${S}2`],P=x[`${S}Error`],B=x[`${S}Error2`];return{continuousAxisChannelDef:dg(x[S],_),continuousAxisChannelDef2:dg(O,_),continuousAxisChannelDefError:dg(P,_),continuousAxisChannelDefError2:dg(B,_),continuousAxis:S}}function dg(d,p){if(d?.aggregate){const{aggregate:_,...x}=d;return _!==p&&nt(function vo(d,p){return`Continuous axis should not have customized aggregation function ${d}; ${p} already agregates the axis.`}(_,p)),x}return d}function vA(d,p){const{mark:_,encoding:x}=d,{x:S,y:A}=x;if(Du(_)&&_.orient)return _.orient;if(Wc(S)){if(Wc(A)){const O=dt(S)&&S.aggregate,P=dt(A)&&A.aggregate;if(!O&&P===p)return"vertical";if(!P&&O===p)return"horizontal";if(O===p&&P===p)throw new Error("Both x and y cannot have aggregate");return up(A)&&!up(S)?"horizontal":"vertical"}return"horizontal"}if(Wc(A))return"vertical";throw new Error(`Need a valid continuous axis for ${p}s`)}const Dy="boxplot",wA=new Id(Dy,hr);function wE(d){return re.isNumber(d)?"tukey":d}function hr(d,p){let{config:_}=p;d={...d,encoding:jv(d.encoding,_)};const{mark:x,encoding:S,params:A,projection:O,...P}=d,B=Du(x)?x:{type:x};A&&nt(tc("boxplot"));const q=B.extent??_.boxplot.extent,G=Ji("size",B,_),ee=B.invalid,se=wE(q),{bins:Ee,timeUnits:De,transform:Re,continuousAxisChannelDef:Le,continuousAxis:Ye,groupby:bt,aggregate:kn,encodingWithoutContinuousAxis:dn,ticksOrient:vi,boxOrient:lr,customTooltipWithoutAggregatedField:ca}=function Ru(d,p,_){const x=vA(d,Dy),{continuousAxisChannelDef:S,continuousAxis:A}=bA(d,x,Dy),O=S.field,P=wE(p),B=[...My(O),{op:"median",field:O,as:`mid_box_${O}`},{op:"min",field:O,as:("min-max"===P?"lower_whisker_":"min_")+O},{op:"max",field:O,as:("min-max"===P?"upper_whisker_":"max_")+O}],q="min-max"===P||"tukey"===P?[]:[{calculate:`datum["upper_box_${O}"] - datum["lower_box_${O}"]`,as:`iqr_${O}`},{calculate:`min(datum["upper_box_${O}"] + datum["iqr_${O}"] * ${p}, datum["max_${O}"])`,as:`upper_whisker_${O}`},{calculate:`max(datum["lower_box_${O}"] - datum["iqr_${O}"] * ${p}, datum["min_${O}"])`,as:`lower_whisker_${O}`}],{[A]:G,...ee}=d.encoding,{customTooltipWithoutAggregatedField:se,filteredEncoding:Ee}=function Hv(d){const{tooltip:p,..._}=d;if(!p)return{filteredEncoding:_};let x,S;if(re.isArray(p)){for(const A of p)A.aggregate?(x||(x=[]),x.push(A)):(S||(S=[]),S.push(A));x&&(_.tooltip=x)}else p.aggregate?_.tooltip=p:S=p;return re.isArray(S)&&1===S.length&&(S=S[0]),{customTooltipWithoutAggregatedField:S,filteredEncoding:_}}(ee),{bins:De,timeUnits:Re,aggregate:Le,groupby:Ye,encoding:bt}=Vv(Ee,_),kn="vertical"===x?"horizontal":"vertical",dn=x;return{bins:De,timeUnits:Re,transform:[...De,...Re,{aggregate:[...Le,...B],groupby:Ye},...q],groupby:Ye,aggregate:Le,continuousAxisChannelDef:S,continuousAxis:A,encodingWithoutContinuousAxis:bt,ticksOrient:kn,boxOrient:dn,customTooltipWithoutAggregatedField:se}}(d,q,_),{color:ua,size:da,...Ml}=dn,fa=kR=>Sy(B,Ye,Le,kR,_.boxplot),em=fa(Ml),Rb=fa(dn),Nb=fa({...Ml,...da?{size:da}:{}}),Gu=Wv([{fieldPrefix:"min-max"===se?"upper_whisker_":"max_",titlePrefix:"Max"},{fieldPrefix:"upper_box_",titlePrefix:"Q3"},{fieldPrefix:"mid_box_",titlePrefix:"Median"},{fieldPrefix:"lower_box_",titlePrefix:"Q1"},{fieldPrefix:"min-max"===se?"lower_whisker_":"min_",titlePrefix:"Min"}],Le,dn),dw={type:"tick",color:"black",opacity:1,orient:vi,invalid:ee,aria:!1},tf="min-max"===se?Gu:Wv([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],Le,dn),tS=[...em({partName:"rule",mark:{type:"rule",invalid:ee,aria:!1},positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",extraEncoding:tf}),...em({partName:"rule",mark:{type:"rule",invalid:ee,aria:!1},positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",extraEncoding:tf}),...em({partName:"ticks",mark:dw,positionPrefix:"lower_whisker",extraEncoding:tf}),...em({partName:"ticks",mark:dw,positionPrefix:"upper_whisker",extraEncoding:tf})],ek=[..."tukey"!==se?tS:[],...Rb({partName:"box",mark:{type:"bar",...G?{size:G}:{},orient:lr,invalid:ee,ariaRoleDescription:"box"},positionPrefix:"lower_box",endPositionPrefix:"upper_box",extraEncoding:Gu}),...Nb({partName:"median",mark:{type:"tick",invalid:ee,...re.isObject(_.boxplot.median)&&_.boxplot.median.color?{color:_.boxplot.median.color}:{},...G?{size:G}:{},orient:vi,aria:!1},positionPrefix:"mid_box",extraEncoding:Gu})];if("min-max"===se)return{...P,transform:(P.transform??[]).concat(Re),layer:ek};const tk=`datum["lower_box_${Le.field}"]`,nk=`datum["upper_box_${Le.field}"]`,nS=`(${nk} - ${tk})`,tm=`${tk} - ${q} * ${nS}`,fw=`${nk} + ${q} * ${nS}`,Fb=`datum["${Le.field}"]`,iS={joinaggregate:My(Le.field),groupby:bt},n_={transform:[{filter:`(${tm} <= ${Fb}) && (${Fb} <= ${fw})`},{aggregate:[{op:"min",field:Le.field,as:`lower_whisker_${Le.field}`},{op:"max",field:Le.field,as:`upper_whisker_${Le.field}`},{op:"min",field:`lower_box_${Le.field}`,as:`lower_box_${Le.field}`},{op:"max",field:`upper_box_${Le.field}`,as:`upper_box_${Le.field}`},...kn],groupby:bt}],layer:tS},{tooltip:Pb,...AR}=Ml,{scale:ik,axis:TR}=Le,rk=Cy(Le),ok=yt(TR,["title"]),sk=qv(B,"outliers",_.boxplot,{transform:[{filter:`(${Fb} < ${tm}) || (${Fb} > ${fw})`}],mark:"point",encoding:{[Ye]:{field:Le.field,type:Le.type,...void 0!==rk?{title:rk}:{},...void 0!==ik?{scale:ik}:{},...Gt(ok)?{}:{axis:ok}},...AR,...ua?{color:ua}:{},...ca?{tooltip:ca}:{}}})[0];let nm;const ak=[...Ee,...De,iS];return sk?nm={transform:ak,layer:[sk,n_]}:(nm=n_,nm.transform.unshift(...ak)),{...P,layer:[nm,{transform:Re,layer:ek}]}}function My(d){return[{op:"q1",field:d,as:`lower_box_${d}`},{op:"q3",field:d,as:`upper_box_${d}`}]}const fg="errorbar",fp=new Id(fg,EA);function EA(d,p){let{config:_}=p;d={...d,encoding:jv(d.encoding,_)};const{transform:x,continuousAxisChannelDef:S,continuousAxis:A,encodingWithoutContinuousAxis:O,ticksOrient:P,markDef:B,outerSpec:q,tooltipEncoding:G}=hp(d,fg,_);delete O.size;const ee=Sy(B,A,S,O,_.errorbar),se=B.thickness,Ee=B.size,De={type:"tick",orient:P,aria:!1,...void 0!==se?{thickness:se}:{},...void 0!==Ee?{size:Ee}:{}},Re=[...ee({partName:"ticks",mark:De,positionPrefix:"lower",extraEncoding:G}),...ee({partName:"ticks",mark:De,positionPrefix:"upper",extraEncoding:G}),...ee({partName:"rule",mark:{type:"rule",ariaRoleDescription:"errorbar",...void 0!==se?{size:se}:{}},positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:G})];return{...q,transform:x,...Re.length>1?{layer:Re}:{...Re[0]}}}function CA(d,p){const{encoding:_}=d;if(function Ay(d){return(Bn(d.x)||Bn(d.y))&&!Bn(d.x2)&&!Bn(d.y2)&&!Bn(d.xError)&&!Bn(d.xError2)&&!Bn(d.yError)&&!Bn(d.yError2)}(_))return{orient:vA(d,p),inputType:"raw"};const x=function CE(d){return Bn(d.x2)||Bn(d.y2)}(_),S=function Rd(d){return Bn(d.xError)||Bn(d.xError2)||Bn(d.yError)||Bn(d.yError2)}(_),A=_.x,O=_.y;if(x){if(S)throw new Error(`${p} cannot be both type aggregated-upper-lower and aggregated-error`);const P=_.x2,B=_.y2;if(Bn(P)&&Bn(B))throw new Error(`${p} cannot have both x2 and y2`);if(Bn(P)){if(Wc(A))return{orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error(`Both x and x2 have to be quantitative in ${p}`)}if(Bn(B)){if(Wc(O))return{orient:"vertical",inputType:"aggregated-upper-lower"};throw new Error(`Both y and y2 have to be quantitative in ${p}`)}throw new Error("No ranged axis")}{const P=_.xError,q=_.yError,G=_.yError2;if(Bn(_.xError2)&&!Bn(P))throw new Error(`${p} cannot have xError2 without xError`);if(Bn(G)&&!Bn(q))throw new Error(`${p} cannot have yError2 without yError`);if(Bn(P)&&Bn(q))throw new Error(`${p} cannot have both xError and yError with both are quantiative`);if(Bn(P)){if(Wc(A))return{orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative")}if(Bn(q)){if(Wc(O))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 hp(d,p,_){const{mark:x,encoding:S,params:A,projection:O,...P}=d,B=Du(x)?x:{type:x};A&&nt(tc(p));const{orient:q,inputType:G}=CA(d,p),{continuousAxisChannelDef:ee,continuousAxisChannelDef2:se,continuousAxisChannelDefError:Ee,continuousAxisChannelDefError2:De,continuousAxis:Re}=bA(d,q,p),{errorBarSpecificAggregate:Le,postAggregateCalculates:Ye,tooltipSummary:bt,tooltipTitleWithFieldName:kn}=function SA(d,p,_,x,S,A,O,P){let B=[],q=[];const G=p.field;let ee,se=!1;if("raw"===A){const Ee=d.center?d.center:d.extent?"iqr"===d.extent?"median":"mean":P.errorbar.center,De=d.extent?d.extent:"mean"===Ee?"stderr":"iqr";if("median"===Ee!=("iqr"===De)&&nt(function JM(d,p,_){return`${d} is not usually used with ${p} for ${_}.`}(Ee,De,O)),"stderr"===De||"stdev"===De)B=[{op:De,field:G,as:`extent_${G}`},{op:Ee,field:G,as:`center_${G}`}],q=[{calculate:`datum["center_${G}"] + datum["extent_${G}"]`,as:`upper_${G}`},{calculate:`datum["center_${G}"] - datum["extent_${G}"]`,as:`lower_${G}`}],ee=[{fieldPrefix:"center_",titlePrefix:Mo(Ee)},{fieldPrefix:"upper_",titlePrefix:Gv(Ee,De,"+")},{fieldPrefix:"lower_",titlePrefix:Gv(Ee,De,"-")}],se=!0;else{let Re,Le,Ye;"ci"===De?(Re="mean",Le="ci0",Ye="ci1"):(Re="median",Le="q1",Ye="q3"),B=[{op:Le,field:G,as:`lower_${G}`},{op:Ye,field:G,as:`upper_${G}`},{op:Re,field:G,as:`center_${G}`}],ee=[{fieldPrefix:"upper_",titlePrefix:cp({field:G,aggregate:Ye,type:"quantitative"},P,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:cp({field:G,aggregate:Le,type:"quantitative"},P,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:cp({field:G,aggregate:Re,type:"quantitative"},P,{allowDisabling:!1})}]}}else{(d.center||d.extent)&&nt(function j1(d,p){return`${p?"extent ":""}${p&&d?"and ":""}${d?"center ":""}${p&&d?"are ":"is "}not needed when data are aggregated.`}(d.center,d.extent)),"aggregated-upper-lower"===A?(ee=[],q=[{calculate:`datum["${_.field}"]`,as:`upper_${G}`},{calculate:`datum["${G}"]`,as:`lower_${G}`}]):"aggregated-error"===A&&(ee=[{fieldPrefix:"",titlePrefix:G}],q=[{calculate:`datum["${G}"] + datum["${x.field}"]`,as:`upper_${G}`}],q.push(S?{calculate:`datum["${G}"] + datum["${S.field}"]`,as:`lower_${G}`}:{calculate:`datum["${G}"] - datum["${x.field}"]`,as:`lower_${G}`}));for(const Ee of q)ee.push({fieldPrefix:Ee.as.substring(0,6),titlePrefix:jo(jo(Ee.calculate,'datum["',""),'"]',"")})}return{postAggregateCalculates:q,errorBarSpecificAggregate:B,tooltipSummary:ee,tooltipTitleWithFieldName:se}}(B,ee,se,Ee,De,G,p,_),{[Re]:dn,["x"===Re?"x2":"y2"]:vi,["x"===Re?"xError":"yError"]:lr,["x"===Re?"xError2":"yError2"]:ca,...ua}=S,{bins:da,timeUnits:Ml,aggregate:fa,groupby:em,encoding:Rb}=Vv(ua,_),Nb=[...fa,...Le],Gu="raw"!==G?[]:em,dw=Wv(bt,ee,Rb,kn);return{transform:[...P.transform??[],...da,...Ml,...0===Nb.length?[]:[{aggregate:Nb,groupby:Gu}],...Ye],groupby:Gu,continuousAxisChannelDef:ee,continuousAxis:Re,encodingWithoutContinuousAxis:Rb,ticksOrient:"vertical"===q?"horizontal":"vertical",markDef:B,outerSpec:P,tooltipEncoding:dw}}function Gv(d,p,_){return`${Mo(d)} ${_} ${p}`}const ps="errorband",Ko=new Id(ps,Xv);function Xv(d,p){let{config:_}=p;d={...d,encoding:jv(d.encoding,_)};const{transform:x,continuousAxisChannelDef:S,continuousAxis:A,encodingWithoutContinuousAxis:O,markDef:P,outerSpec:B,tooltipEncoding:q}=hp(d,ps,_),G=P,ee=Sy(G,A,S,O,_.errorband),se=void 0!==d.encoding.x&&void 0!==d.encoding.y;let Ee={type:se?"area":"rect"},De={type:se?"line":"rule"};const Re={...G.interpolate?{interpolate:G.interpolate}:{},...G.tension&&G.interpolate?{tension:G.tension}:{}};return se?(Ee={...Ee,...Re,ariaRoleDescription:"errorband"},De={...De,...Re,aria:!1}):G.interpolate?nt(ry("interpolate")):G.tension&&nt(ry("tension")),{...B,transform:x,layer:[...ee({partName:"band",mark:Ee,positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:q}),...ee({partName:"borders",mark:De,positionPrefix:"lower",extraEncoding:q}),...ee({partName:"borders",mark:De,positionPrefix:"upper",extraEncoding:q})]}}const DA={};function Yv(d,p,_){const x=new Id(d,p);DA[d]={normalizer:x,parts:_}}Yv(Dy,hr,["box","median","outliers","rule","ticks"]),Yv(fg,EA,["ticks","rule"]),Yv(ps,Xv,["band","borders"]);const J2=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength","unselectedOpacity"],Ty={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"},pp={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"},xl=We(Ty),Kf=We(pp),hg=We({header:1,headerRow:1,headerColumn:1,headerFacet:1}),Nd=["size","shape","fill","stroke","strokeDash","strokeWidth","opacity"],Ya="_vgsid_",SE={point:{on:"click",fields:[Ya],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 DE(d){return"legend"===d||!!d?.legend}function Iy(d){return DE(d)&&re.isObject(d)}function AA(d){return!!d?.select}function pg(d){const p=[];for(const _ of d||[]){if(AA(_))continue;const{expr:x,bind:S,...A}=_;if(S&&x){const O={...A,bind:S,init:x};p.push(O)}else{const O={...A,...x?{update:x}:{},...S?{bind:S}:{}};p.push(O)}}return p}function ME(d){return"concat"in d}function mg(d){return"vconcat"in d}function Oy(d){return"hconcat"in d}function AE(d){let{step:p,offsetIsDiscrete:_}=d;return _?p.for??"offset":"position"}function Fd(d){return re.isObject(d)&&void 0!==d.step}function Ry(d){return d.view||d.width||d.height}const J$=We({align:1,bounds:1,center:1,columns:1,spacing:1});function Aa(d,p){return d[p]??d["width"===p?"continuousWidth":"continuousHeight"]}function pr(d,p){const _=lo(d,p);return Fd(_)?_.step:lc}function lo(d,p){return ui(d[p]??d["width"===p?"discreteWidth":"discreteHeight"],{step:d.step})}const lc=20,gg={background:"white",padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",view:{continuousWidth:200,continuousHeight:200,step:lc},mark:{color:"#4c78a8",invalid:"filter",timeUnitBandSize:1},arc:{},area:{},bar:sE,circle:{},geoshape:{},image:{},line:{},point:{},rect:aE,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:{pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,bandWithNestedOffsetPaddingInner:.2,bandWithNestedOffsetPaddingOuter:.2,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:9,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4,zero:!0},projection:{},legend:{gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:SE,style:{},title:{},facet:{spacing:20},concat:{spacing:20},normalizedNumberFormat:".0%"},Nu=["#4c78a8","#f58518","#e45756","#72b7b2","#54a24b","#eeca3b","#b279a2","#ff9da6","#9d755d","#bab0ac"],gp={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},Kv={blue:Nu[0],orange:Nu[1],red:Nu[2],teal:Nu[3],green:Nu[4],yellow:Nu[5],purple:Nu[6],pink:Nu[7],brown:Nu[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 Ly(d){const p=We(d||{}),_={};for(const x of p){const S=d[x];_[x]=Xf(S)?RM(S):Ha(S)}return _}const tR=[...rp,...zv,...hg,"background","padding","legend","lineBreak","scale","style","title","view"];function kE(){let d=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{color:p,font:_,fontSize:x,selection:S,...A}=d,O=re.mergeConfig({},st(gg),_?function Py(d){return{text:{font:d},style:{"guide-label":{font:d},"guide-title":{font:d},"group-title":{font:d},"group-subtitle":{font:d}}}}(_):{},p?function TE(){let d=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{signals:[{name:"color",value:re.isObject(d)?{...Kv,...d}:Kv}],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"}]}}}(p):{},x?function kA(d){return{signals:[{name:"fontSize",value:re.isObject(d)?{...gp,...d}:gp}],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"}}}}}(x):{},A||{});S&&re.writeConfig(O,"selection",S,!0);const P=yt(O,tR);for(const B of["background","lineBreak","padding"])O[B]&&(P[B]=Ha(O[B]));for(const B of rp)O[B]&&(P[B]=_o(O[B]));for(const B of zv)O[B]&&(P[B]=Ly(O[B]));for(const B of hg)O[B]&&(P[B]=_o(O[B]));return O.legend&&(P.legend=_o(O.legend)),O.scale&&(P.scale=_o(O.scale)),O.style&&(P.style=function Pd(d){const p=We(d),_={};for(const x of p)_[x]=Ly(d[x]);return _}(O.style)),O.title&&(P.title=_o(O.title)),O.view&&(P.view=_o(O.view)),P}const IE=new Set(["view",...eg]),OE=["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"],RE={view:["continuousWidth","continuousHeight","discreteWidth","discreteHeight","step"],area:["line","point"],bar:["binSpacing","continuousBandSize","discreteBandSize","minBandSize"],rect:["binSpacing","continuousBandSize","discreteBandSize","minBandSize"],line:["point"],tick:["bandSize","thickness"]};function IA(d){d=st(d);for(const p of OE)delete d[p];if(d.axis)for(const p in d.axis)Xf(d.axis[p])&&delete d.axis[p];if(d.legend)for(const p of J2)delete d.legend[p];if(d.mark){for(const p of G2)delete d.mark[p];d.mark.tooltip&&re.isObject(d.mark.tooltip)&&delete d.mark.tooltip}d.params&&(d.signals=(d.signals||[]).concat(pg(d.params)),delete d.params);for(const p of IE){for(const x of G2)delete d[p][x];const _=RE[p];if(_)for(const x of _)delete d[p][x];RA(d,p)}for(const p of function MA(){return We(DA)}())delete d[p];!function OA(d){const{titleMarkConfig:p,subtitleMarkConfig:_,subtitle:x}=pl(d.title);Gt(p)||(d.style["group-title"]={...d.style["group-title"],...p}),Gt(_)||(d.style["group-subtitle"]={...d.style["group-subtitle"],..._}),Gt(x)?delete d.title:d.title=x}(d);for(const p in d)re.isObject(d[p])&&Gt(d[p])&&delete d[p];return Gt(d)?void 0:d}function RA(d,p,_,x){"view"===p&&(_="cell");const A={...x?d[p][x]:d[p],...d.style[_??p]};Gt(A)||(d.style[_??p]=A),x||delete d[p]}function _p(d){return"layer"in d}class Fs{map(p,_){return _y(p)?this.mapFacet(p,_):function Zv(d){return"repeat"in d}(p)?this.mapRepeat(p,_):Oy(p)?this.mapHConcat(p,_):mg(p)?this.mapVConcat(p,_):ME(p)?this.mapConcat(p,_):this.mapLayerOrUnit(p,_)}mapLayerOrUnit(p,_){if(_p(p))return this.mapLayer(p,_);if(vl(p))return this.mapUnit(p,_);throw new Error(ov(p))}mapLayer(p,_){return{...p,layer:p.layer.map(x=>this.mapLayerOrUnit(x,_))}}mapHConcat(p,_){return{...p,hconcat:p.hconcat.map(x=>this.map(x,_))}}mapVConcat(p,_){return{...p,vconcat:p.vconcat.map(x=>this.map(x,_))}}mapConcat(p,_){const{concat:x,...S}=p;return{...S,concat:x.map(A=>this.map(A,_))}}mapFacet(p,_){return{...p,spec:this.map(p.spec,_)}}mapRepeat(p,_){return{...p,spec:this.map(p.spec,_)}}}const NE={zero:1,center:1,normalize:1};const Qv=new Set([iE,_l,xd,Su,np,zf,Vf,wd,Av,U2]),Ps=new Set([_l,xd,iE]);function Fu(d){return dt(d)&&"quantitative"===Qr(d)&&!d.bin}function _g(d,p,_){let{orient:x,type:S}=_;const A="x"===p?"y":"radius",O="x"===p&&["bar","area"].includes(S),P=d[p],B=d[A];if(dt(P)&&dt(B))if(Fu(P)&&Fu(B)){if(P.stack)return p;if(B.stack)return A;const q=dt(P)&&!!P.aggregate;if(q!==(dt(B)&&!!B.aggregate))return q?p:A;if(O){if("vertical"===x)return A;if("horizontal"===x)return p}}else{if(Fu(P))return p;if(Fu(B))return A}else{if(Fu(P))return O&&"vertical"===x?void 0:p;if(Fu(B))return O&&"horizontal"===x?void 0:A}}function LA(d,p){const _=Du(d)?d:{type:d},x=_.type;if(!Qv.has(x))return null;const S=_g(p,"x",_)||_g(p,"theta",_);if(!S)return null;const A=p[S],O=dt(A)?pt(A,{}):void 0,P=function PA(d){switch(d){case"x":return"y";case"y":return"x";case"theta":return"radius";case"radius":return"theta"}}(S),B=[],q=new Set;if(p[P]){const Re=p[P],Le=dt(Re)?pt(Re,{}):void 0;Le&&Le!==O&&(B.push(P),q.add(Le))}const G="x"===P?"xOffset":"yOffset",ee=p[G],se=dt(ee)?pt(ee,{}):void 0;se&&se!==O&&(B.push(G),q.add(se));const Ee=$m.reduce((Re,Le)=>{if("tooltip"!==Le&&xo(p,Le)){const Ye=p[Le];for(const bt of re.array(Ye)){const kn=ku(bt);if(kn.aggregate)continue;const dn=pt(kn,{});(!dn||!q.has(dn))&&Re.push({channel:Le,fieldDef:kn})}}return Re},[]);let De;return void 0!==A.stack?De=re.isBoolean(A.stack)?A.stack?"zero":null:A.stack:Ps.has(x)&&(De="zero"),!De||!function FA(d){return d in NE}(De)||vE(p)&&0===Ee.length?null:A?.scale?.type&&A?.scale?.type!==Ga.LINEAR?(A?.stack&&nt(function K$(d){return`Cannot stack non-linear scale (${d}).`}(A.scale.type)),null):Bn(p[Or(S)])?(void 0!==A.stack&&nt(function ZM(d){return`Cannot stack "${d}" if there is already "${d}2".`}(S)),null):(dt(A)&&A.aggregate&&!Vm.has(A.aggregate)&&nt(function QM(d){return`Stacking is applied even though the aggregate function is non-summative ("${d}").`}(A.aggregate)),{groupbyChannels:B,groupbyFields:q,fieldChannel:S,impute:null!==A.impute&&yl(x),stackBy:Ee,offset:De})}function FE(d,p,_){const x=_o(d),S=Ji("orient",x,_);if(x.orient=function Zf(d,p,_){switch(d){case np:case zf:case Vf:case Av:case lA:case ze:return}const{x,y:S,x2:A,y2:O}=p;switch(d){case _l:if(dt(x)&&(oo(x.bin)||dt(S)&&S.aggregate&&!x.aggregate))return"vertical";if(dt(S)&&(oo(S.bin)||dt(x)&&x.aggregate&&!S.aggregate))return"horizontal";if(O||A){if(_)return _;if(!A)return(dt(x)&&x.type===$f&&!sr(x.bin)||sg(x))&&dt(S)&&oo(S.bin)?"horizontal":"vertical";if(!O)return(dt(S)&&S.type===$f&&!sr(S.bin)||sg(S))&&dt(x)&&oo(x.bin)?"vertical":"horizontal"}case Su:if(A&&(!dt(x)||!oo(x.bin))&&O&&(!dt(S)||!oo(S.bin)))return;case xd:if(O)return dt(S)&&oo(S.bin)?"horizontal":"vertical";if(A)return dt(x)&&oo(x.bin)?"vertical":"horizontal";if(d===Su){if(x&&!S)return"vertical";if(S&&!x)return"horizontal"}case wd:case U2:{const P=pE(x),B=pE(S);if(_)return _;if(P&&!B)return"tick"!==d?"horizontal":"vertical";if(!P&&B)return"tick"!==d?"vertical":"horizontal";if(P&&B)return"vertical";{const q=Yo(x)&&x.type===qa,G=Yo(S)&&S.type===qa;if(q&&!G)return"vertical";if(!q&&G)return"horizontal"}return}}return"vertical"}(x.type,p,S),void 0!==S&&S!==x.orient&&nt(function HM(d,p){return`Specified orient "${d}" overridden with "${p}".`}(x.orient,S)),"bar"===x.type&&x.orient){const P=Ji("cornerRadiusEnd",x,_);if(void 0!==P){const B="horizontal"===x.orient&&p.x2||"vertical"===x.orient&&p.y2?["cornerRadius"]:oc[x.orient];for(const q of B)x[q]=P;void 0!==x.cornerRadiusEnd&&delete x.cornerRadiusEnd}}return void 0===Ji("opacity",x,_)&&(x.opacity=function Jv(d,p){if(St([np,U2,zf,Vf],d)&&!vE(p))return.7}(x.type,p)),void 0===Ji("cursor",x,_)&&(x.cursor=function tr(d,p,_){return p.href||d.href||Ji("href",d,_)?"pointer":d.cursor}(x,p,_)),x}function nR(d){const{point:p,line:_,...x}=d;return We(x).length>1?x:x.type}function $A(d){for(const p of["line","area","rule","trail"])d[p]&&(d={...d,[p]:yt(d[p],["point","line"])});return d}function $y(d){let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},_=arguments.length>2?arguments[2]:void 0;return"transparent"===d.point?{opacity:0}:d.point?re.isObject(d.point)?d.point:{}:void 0!==d.point?null:p.point||_.shape?re.isObject(p.point)?p.point:{}:void 0}function yp(d){let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return d.line?!0===d.line?{}:d.line:void 0!==d.line?null:p.line?!0===p.line?{}:p.line:void 0}class ex{constructor(){ln(this,"name","path-overlay")}hasMatchingType(p,_){if(vl(p)){const{mark:x,encoding:S}=p,A=Du(x)?x:{type:x};switch(A.type){case"line":case"rule":case"trail":return!!$y(A,_[A.type],S);case"area":return!!$y(A,_[A.type],S)||!!yp(A,_[A.type])}}return!1}run(p,_,x){const{config:S}=_,{params:A,projection:O,mark:P,name:B,encoding:q,...G}=p,ee=jv(q,S),se=Du(P)?P:{type:P},Ee=$y(se,S[se.type],ee),De="area"===se.type&&yp(se,S[se.type]),Re=[{name:B,...A?{params:A}:{},mark:nR({..."area"===se.type&&void 0===se.opacity&&void 0===se.fillOpacity?{opacity:.7}:{},...se}),encoding:yt(ee,["shape"])}],Le=LA(FE(se,ee,S),ee);let Ye=ee;if(Le){const{fieldChannel:bt,offset:kn}=Le;Ye={...ee,[bt]:{...ee[bt],...kn?{stack:kn}:{}}}}return Ye=yt(Ye,["y2","x2"]),De&&Re.push({...O?{projection:O}:{},mark:{type:"line",...Sn(se,["clip","interpolate","tension","tooltip"]),...De},encoding:Ye}),Ee&&Re.push({...O?{projection:O}:{},mark:{type:"point",opacity:1,filled:!0,...Sn(se,["clip","tooltip"]),...Ee},encoding:Ye}),x({...G,layer:Re},{..._,config:$A(S)})}}function By(d,p){return p?og(d)?zA(d,p):nx(d,p):d}function Ld(d,p){return p?zA(d,p):d}function tx(d,p,_){const x=p[d];return function K2(d){return d&&!re.isString(d)&&"repeat"in d}(x)?x.repeat in _?{...p,[d]:_[x.repeat]}:void nt(function ty(d){return`Unknown repeated value "${d}".`}(x.repeat)):p}function nx(d,p){if(void 0!==(d=tx("field",d,p))){if(null===d)return null;if(Cd(d)&&sa(d.sort)){const _=tx("field",d.sort,p);d={...d,..._?{sort:_}:{}}}return d}}function zy(d,p){if(dt(d))return nx(d,p);{const _=tx("datum",d,p);return _!==d&&!_.type&&(_.type="nominal"),_}}function BA(d,p){if(!Bn(d)){if(Nv(d)){const _=zy(d.condition,p);if(_)return{...d,condition:_};{const{condition:x,...S}=d;return S}}return d}{const _=zy(d,p);if(_)return _;if(hE(d))return{condition:d.condition}}}function zA(d,p){const _={};for(const x in d)if(re.hasOwnProperty(d,x)){const S=d[x];if(re.isArray(S))_[x]=S.map(A=>BA(A,p)).filter(A=>A);else{const A=BA(S,p);void 0!==A&&(_[x]=A)}}return _}class VA{constructor(){ln(this,"name","RuleForRangedLine")}hasMatchingType(p){if(vl(p)){const{encoding:_,mark:x}=p;if("line"===x||Du(x)&&"line"===x.type)for(const S of Tf){const O=_[Fc(S)];if(_[S]&&(dt(O)&&!oo(O.bin)||Sd(O)))return!0}}return!1}run(p,_,x){const{encoding:S,mark:A}=p;return nt(function B1(d,p){return`Line mark is for continuous lines and thus cannot be used with ${d&&p?"x2 and y2":d?"x2":"y2"}. We will use the rule mark (line segments) instead.`}(!!S.x2,!!S.y2)),x({...p,mark:re.isObject(A)?{...A,type:"rule"}:"rule"},_)}}function jA(d){let{parentEncoding:p,encoding:_={},layer:x}=d,S={};if(p){const A=new Set([...We(p),...We(_)]);for(const O of A){const P=_[O],B=p[O];if(Bn(P)){const q={...B,...P};S[O]=q}else Nv(P)?S[O]={...P,condition:{...B,...P.condition}}:P||null===P?S[O]=P:(x||Ma(B)||Je(B)||Bn(B)||re.isArray(B))&&(S[O]=B)}}else S=_;return!S||Gt(S)?void 0:S}function iR(d){const{parentProjection:p,projection:_}=d;return p&&_&&nt(function Ff(d){const{parentProjection:p,projection:_}=d;return`Layer's shared projection ${Wn(p)} is overridden by a child projection ${Wn(_)}.`}({parentProjection:p,projection:_})),_??p}function Vy(d){return"filter"in d}function bg(d){return"lookup"in d}function rR(d){return"pivot"in d}function LE(d){return"density"in d}function ox(d){return"quantile"in d}function bp(d){return"regression"in d}function $E(d){return"loess"in d}function HA(d){return"sample"in d}function oR(d){return"window"in d}function e3(d){return"joinaggregate"in d}function sx(d){return"flatten"in d}function sR(d){return"calculate"in d}function BE(d){return"bin"in d}function WA(d){return"impute"in d}function zE(d){return"timeUnit"in d}function VE(d){return"aggregate"in d}function qA(d){return"stack"in d}function ax(d){return"fold"in d}function vp(d){return"extent"in d&&!("density"in d)}function jy(d,p){const{transform:_,...x}=d;return _?{...x,transform:_.map(A=>{if(Vy(A))return{filter:Qf(A,p)};if(BE(A)&&Lc(A.bin))return{...A,bin:Ta(A.bin)};if(bg(A)){const{selection:O,...P}=A.from;return O?{...A,from:{param:O,...P}}:A}return A})}:d}function Ka(d,p){const _=st(d);if(dt(_)&&Lc(_.bin)&&(_.bin=Ta(_.bin)),sp(_)&&_.scale?.domain?.selection){const{selection:x,...S}=_.scale.domain;_.scale.domain={...S,...x?{param:x}:{}}}if(hE(_))if(re.isArray(_.condition))_.condition=_.condition.map(x=>{const{selection:S,param:A,test:O,...P}=x;return A?x:{...P,test:Qf(x,p)}});else{const{selection:x,param:S,test:A,...O}=Ka(_.condition,p);_.condition=S?_.condition:{...O,test:Qf(_.condition,p)}}return _}function Ta(d){const p=d.extent;if(p?.selection){const{selection:_,...x}=p;return{...d,extent:{...x,param:_}}}return d}function Qf(d,p){const _=x=>At(x,S=>{const O={param:S,empty:p.emptySelections[S]??!0};return p.selectionPredicates[S]??=[],p.selectionPredicates[S].push(O),O});return d.selection?_(d.selection):At(d.test||d.filter,x=>x.selection?_(x.selection):x)}class UE extends Fs{map(p,_){const x=_.selections??[];if(p.params&&!vl(p)){const S=[];for(const A of p.params)AA(A)?x.push(A):S.push(A);p.params=S}return _.selections=x,super.map(p,_)}mapUnit(p,_){const x=_.selections;if(!x||!x.length)return p;const S=(_.path??[]).concat(p.name),A=[];for(const O of x)if(O.views&&O.views.length)for(const P of O.views)(re.isString(P)&&(P===p.name||S.includes(P))||re.isArray(P)&&P.map(B=>S.indexOf(B)).every((B,q,G)=>-1!==B&&(0===q||B>G[q-1])))&&A.push(O);else A.push(O);return A.length&&(p.params=A),p}}for(const d of["mapFacet","mapRepeat","mapHConcat","mapVConcat","mapLayer"]){const p=UE.prototype[d];UE.prototype[d]=function(_,x){return p.call(this,_,XA(_,x))}}function XA(d,p){return d.name?{...p,path:(p.path??[]).concat(d.name)}:p}function YA(d,p){void 0===p&&(p=kE(d.config));const _=function $d(d){const _={config:arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}};return KA.map(t3.map(n3.map(d,_),_),_)}(d,p),{width:x,height:S}=d,A=function lx(d,p,_){let{width:x,height:S}=p;const A=vl(d)||_p(d),O={};A?"container"==x&&"container"==S?(O.type="fit",O.contains="padding"):"container"==x?(O.type="fit-x",O.contains="padding"):"container"==S&&(O.type="fit-y",O.contains="padding"):("container"==x&&(nt(jm("width")),x=void 0),"container"==S&&(nt(jm("height")),S=void 0));const P={type:"pad",...O,..._?Uy(_.autosize):{},...Uy(d.autosize)};if("fit"===P.type&&!A&&(nt(VM),P.type="pad"),"container"==x&&!("fit"==P.type||"fit-x"==P.type)&&nt(jM("width")),"container"==S&&!("fit"==P.type||"fit-y"==P.type)&&nt(jM("height")),!xr(P,{type:"pad"}))return P}(_,{width:x,height:S,autosize:d.autosize},p);return{..._,...A?{autosize:A}:{}}}const t3=new class ix extends Fs{constructor(){super(...arguments),ln(this,"nonFacetUnitNormalizers",[wA,fp,Ko,new ex,new VA])}map(p,_){if(vl(p)){const x=xo(p.encoding,ea),S=xo(p.encoding,Xl),A=xo(p.encoding,yu);if(x||S||A)return this.mapFacetedUnit(p,_)}return super.map(p,_)}mapUnit(p,_){const{parentEncoding:x,parentProjection:S}=_,A=Ld(p.encoding,_.repeater),O={...p,...p.name?{name:[_.repeaterPrefix,p.name].filter(B=>B).join("_")}:{},...A?{encoding:A}:{}};if(x||S)return this.mapUnitWithParentEncodingOrProjection(O,_);const P=this.mapLayerOrUnit.bind(this);for(const B of this.nonFacetUnitNormalizers)if(B.hasMatchingType(O,_.config))return B.run(O,_,P);return O}mapRepeat(p,_){return function NA(d){return!re.isArray(d.repeat)&&d.repeat.layer}(p)?this.mapLayerRepeat(p,_):this.mapNonLayerRepeat(p,_)}mapLayerRepeat(p,_){const{repeat:x,spec:S,...A}=p,{row:O,column:P,layer:B}=x,{repeater:q={},repeaterPrefix:G=""}=_;return O||P?this.mapRepeat({...p,repeat:{...O?{row:O}:{},...P?{column:P}:{}},spec:{repeat:{layer:B},spec:S}},_):{...A,layer:B.map(ee=>{const se={...q,layer:ee},Ee=`${(S.name?`${S.name}_`:"")+G}child__layer_${hn(ee)}`,De=this.mapLayerOrUnit(S,{..._,repeater:se,repeaterPrefix:Ee});return De.name=Ee,De})}}mapNonLayerRepeat(p,_){const{repeat:x,spec:S,data:A,...O}=p;!re.isArray(x)&&p.columns&&(p=yt(p,["columns"]),nt(P1("repeat")));const P=[],{repeater:B={},repeaterPrefix:q=""}=_,G=!re.isArray(x)&&x.row||[B?B.row:null],ee=!re.isArray(x)&&x.column||[B?B.column:null],se=re.isArray(x)&&x||[B?B.repeat:null];for(const De of se)for(const Re of G)for(const Le of ee){const Ye={repeat:De,row:Re,column:Le,layer:B.layer},bt=(S.name?`${S.name}_`:"")+q+"child__"+(re.isArray(x)?`${hn(De)}`:(x.row?`row_${hn(Re)}`:"")+(x.column?`column_${hn(Le)}`:"")),kn=this.map(S,{..._,repeater:Ye,repeaterPrefix:bt});kn.name=bt,P.push(yt(kn,["data"]))}const Ee=re.isArray(x)?p.columns:x.column?x.column.length:1;return{data:S.data??A,align:"all",...O,columns:Ee,concat:P}}mapFacet(p,_){const{facet:x}=p;return og(x)&&p.columns&&(p=yt(p,["columns"]),nt(P1("facet"))),super.mapFacet(p,_)}mapUnitWithParentEncodingOrProjection(p,_){const{encoding:x,projection:S}=p,{parentEncoding:A,parentProjection:O,config:P}=_,B=iR({parentProjection:O,projection:S}),q=jA({parentEncoding:A,encoding:Ld(x,_.repeater)});return this.mapUnit({...p,...B?{projection:B}:{},...q?{encoding:q}:{}},{config:P})}mapFacetedUnit(p,_){const{row:x,column:S,facet:A,...O}=p.encoding,{mark:P,width:B,projection:q,height:G,view:ee,params:se,encoding:Ee,...De}=p,{facetMapping:Re,layout:Le}=this.getFacetMappingAndLayout({row:x,column:S,facet:A},_),Ye=Ld(O,_.repeater);return this.mapFacet({...De,...Le,facet:Re,spec:{...B?{width:B}:{},...G?{height:G}:{},...ee?{view:ee}:{},...q?{projection:q}:{},mark:P,encoding:Ye,...se?{params:se}:{}}},_)}getFacetMappingAndLayout(p,_){const{row:x,column:S,facet:A}=p;if(x||S){A&&nt(function cv(d){return`Facet encoding dropped as ${d.join(" and ")} ${d.length>1?"are":"is"} also specified.`}([...x?[ea]:[],...S?[Xl]:[]]));const O={},P={};for(const B of[ea,Xl]){const q=p[B];if(q){const{align:G,center:ee,spacing:se,columns:Ee,...De}=q;O[B]=De;for(const Re of["align","center","spacing"])void 0!==q[Re]&&(P[Re]??={},P[Re][B]=q[Re])}}return{facetMapping:O,layout:P}}{const{align:O,center:P,spacing:B,columns:q,...G}=A;return{facetMapping:By(G,_.repeater),layout:{...O?{align:O}:{},...P?{center:P}:{},...B?{spacing:B}:{},...q?{columns:q}:{}}}}}mapLayer(p,_){let{parentEncoding:x,parentProjection:S,...A}=_;const{encoding:O,projection:P,...B}=p,q={...A,parentEncoding:jA({parentEncoding:x,encoding:O,layer:!0}),parentProjection:iR({parentProjection:S,projection:P})};return super.mapLayer({...B,...p.name?{name:[q.repeaterPrefix,p.name].filter(G=>G).join("_")}:{}},q)}},n3=new class jE extends Fs{map(p,_){return _.emptySelections??={},_.selectionPredicates??={},p=jy(p,_),super.map(p,_)}mapLayerOrUnit(p,_){if((p=jy(p,_)).encoding){const x={};for(const[S,A]of Jt(p.encoding))x[S]=Ka(A,_);p={...p,encoding:x}}return super.mapLayerOrUnit(p,_)}mapUnit(p,_){const{selection:x,...S}=p;return x?{...S,params:Jt(x).map(A=>{let[O,P]=A;const{init:B,bind:q,empty:G,...ee}=P;"single"===ee.type?(ee.type="point",ee.toggle=!1):"multi"===ee.type&&(ee.type="point"),_.emptySelections[O]="none"!==G;for(const se of Dn(_.selectionPredicates[O]??{}))se.empty="none"!==G;return{name:O,value:B,select:ee,bind:q}})}:p}},KA=new UE;function Uy(d){return re.isString(d)?{type:d}:d??{}}const i3=["background","padding"];function Hy(d,p){const _={};for(const x of i3)d&&void 0!==d[x]&&(_[x]=Ha(d[x]));return p&&(_.params=d.params),_}class Za{constructor(){let _=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.explicit=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},this.implicit=_}clone(){return new Za(st(this.explicit),st(this.implicit))}combine(){return{...this.explicit,...this.implicit}}get(p){return ui(this.explicit[p],this.implicit[p])}getWithExplicit(p){return void 0!==this.explicit[p]?{explicit:!0,value:this.explicit[p]}:void 0!==this.implicit[p]?{explicit:!1,value:this.implicit[p]}:{explicit:!1,value:void 0}}setWithExplicit(p,_){let{value:x,explicit:S}=_;void 0!==x&&this.set(p,x,S)}set(p,_,x){return delete this[x?"implicit":"explicit"][p],this[x?"explicit":"implicit"][p]=_,this}copyKeyFromSplit(p,_){let{explicit:x,implicit:S}=_;void 0!==x[p]?this.set(p,x[p],!0):void 0!==S[p]&&this.set(p,S[p],!1)}copyKeyFromObject(p,_){void 0!==_[p]&&this.set(p,_[p],!0)}copyAll(p){for(const _ of We(p.combine())){const x=p.getWithExplicit(_);this.setWithExplicit(_,x)}}}function Ls(d){return{explicit:!0,value:d}}function co(d){return{explicit:!1,value:d}}function zd(d){return(p,_,x,S)=>{const A=d(p.value,_.value);return A>0?p:A<0?_:Pu(p,_,x,S)}}function Pu(d,p,_,x){return d.explicit&&p.explicit&&nt(function XM(d,p,_,x){return`Conflicting ${p.toString()} property "${d.toString()}" (${Wn(_)} and ${Wn(x)}). Using ${Wn(_)}.`}(_,x,d.value,p.value)),d}function Qa(d,p,_,x){let S=arguments.length>4&&void 0!==arguments[4]?arguments[4]:Pu;return void 0===d||void 0===d.value?p:d.explicit&&!p.explicit?d:p.explicit&&!d.explicit?p:xr(d.value,p.value)?d:S(d,p,_,x)}class Gc extends Za{constructor(){let p=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},_=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},x=arguments.length>2&&void 0!==arguments[2]&&arguments[2];super(p,_),this.explicit=p,this.implicit=_,this.parseNothing=x}clone(){const p=super.clone();return p.parseNothing=this.parseNothing,p}}function ka(d){return"url"in d}function Wy(d){return"values"in d}function ZA(d){return"name"in d&&!ka(d)&&!Wy(d)&&!Jf(d)}function Jf(d){return d&&(QA(d)||Ja(d)||cc(d))}function QA(d){return"sequence"in d}function Ja(d){return"sphere"in d}function cc(d){return"graticule"in d}let Vr=function(d){return d[d.Raw=0]="Raw",d[d.Main=1]="Main",d[d.Row=2]="Row",d[d.Column=3]="Column",d[d.Lookup=4]="Lookup",d}({});function HE(d){const{signals:p,hasLegend:_,index:x,...S}=d;return S.field=ci(S.field),S}function eh(d){let p=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],_=arguments.length>2&&void 0!==arguments[2]?arguments[2]:re.identity;if(re.isArray(d)){const x=d.map(S=>eh(S,p,_));return p?`[${x.join(", ")}]`:x}return _d(d)?_(p?gl(d):function Wa(d){const p=Ym(d,!0);return d.utc?+new Date(Date.UTC(...p)):+new Date(...p)}(d)):p?_(Wn(d)):d}function lR(d,p){for(const _ of Dn(d.component.selection??{})){const x=_.name;let S=`${x}${Wd}, ${"global"===_.resolve?"true":`{unit: ${kp(d)}}`}`;for(const A of gx)A.defined(_)&&(A.signals&&(p=A.signals(d,_,p)),A.modifyExpr&&(S=A.modifyExpr(d,_,S)));p.push({name:x+dT,on:[{events:{signal:_.name+Wd},update:`modify(${re.stringValue(_.name+Hd)}, ${S})`}]})}return Lu(p)}function cR(d,p){if(d.component.selection&&We(d.component.selection).length){const _=re.stringValue(d.getName("cell"));p.unshift({name:"facet",value:{},on:[{events:re.parseSelector("pointermove","scope"),update:`isTuple(facet) ? facet : group(${_}).datum`}]})}return Lu(p)}function WE(d,p){for(const _ of Dn(d.component.selection??{}))for(const x of gx)x.defined(_)&&x.marks&&(p=x.marks(d,_,p));return p}function Lu(d){return d.map(p=>(p.on&&!p.on.length&&delete p.on,p))}class Tn{constructor(p,_){this.debugName=_,ln(this,"_children",[]),ln(this,"_parent",null),ln(this,"_hash",void 0),p&&(this.parent=p)}clone(){throw new Error("Cannot clone node")}get parent(){return this._parent}set parent(p){this._parent=p,p&&p.addChild(this)}get children(){return this._children}numChildren(){return this._children.length}addChild(p,_){this._children.includes(p)?nt("Attempt to add the same child twice."):void 0!==_?this._children.splice(_,0,p):this._children.push(p)}removeChild(p){const _=this._children.indexOf(p);return this._children.splice(_,1),_}remove(){let p=this._parent.removeChild(this);for(const _ of this._children)_._parent=this._parent,this._parent.addChild(_,p++)}insertAsParentOf(p){const _=p.parent;_.removeChild(this),this.parent=_,p.parent=this}swapWithParent(){const p=this._parent,_=p.parent;for(const S of this._children)S.parent=p;this._children=[],p.removeChild(this);const x=p.parent.removeChild(p);this._parent=_,_.addChild(this,x),p.parent=this}}class jr extends Tn{clone(){const p=new this.constructor;return p.debugName=`clone_${this.debugName}`,p._source=this._source,p._name=`clone_${this._name}`,p.type=this.type,p.refCounts=this.refCounts,p.refCounts[p._name]=0,p}constructor(p,_,x,S){super(p,_),this.type=x,this.refCounts=S,ln(this,"_source",void 0),ln(this,"_name",void 0),this._source=this._name=_,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 ${Ms()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(p){this._source=p}}function xp(d){return void 0!==d.as}function ux(d){return`${d}_end`}class el extends Tn{clone(){return new el(null,st(this.timeUnits))}constructor(p,_){super(p),this.timeUnits=_}static makeFromEncoding(p,_){const x=_.reduceFieldDef((S,A,O)=>{const{field:P,timeUnit:B}=A;if(B){let q;if(qo(B)){if(uo(_)){const{mark:G,markDef:ee,config:se}=_,Ee=Tu({fieldDef:A,markDef:ee,config:se});(ip(G)||Ee)&&(q={timeUnit:Fr(B),field:P})}}else q={as:pt(A,{forAs:!0}),field:P,timeUnit:B};if(uo(_)){const{mark:G,markDef:ee,config:se}=_,Ee=Tu({fieldDef:A,markDef:ee,config:se});ip(G)&&Yr(O)&&.5!==Ee&&(q.rectBandPosition=Ee)}q&&(S[kt(q)]=q)}return S},{});return Gt(x)?null:new el(p,x)}static makeFromTransform(p,_){const{timeUnit:x,...S}={..._},O={...S,timeUnit:Fr(x)};return new el(p,{[kt(O)]:O})}merge(p){this.timeUnits={...this.timeUnits};for(const _ in p.timeUnits)this.timeUnits[_]||(this.timeUnits[_]=p.timeUnits[_]);for(const _ of p.children)p.removeChild(_),_.parent=this;p.remove()}removeFormulas(p){const _={};for(const[x,S]of Jt(this.timeUnits)){const A=xp(S)?S.as:`${S.field}_end`;p.has(A)||(_[x]=S)}this.timeUnits=_}producedFields(){return new Set(Dn(this.timeUnits).map(p=>xp(p)?p.as:ux(p.field)))}dependentFields(){return new Set(Dn(this.timeUnits).map(p=>p.field))}hash(){return`TimeUnit ${kt(this.timeUnits)}`}assemble(){const p=[];for(const _ of Dn(this.timeUnits)){const{rectBandPosition:x}=_,S=Fr(_.timeUnit);if(xp(_)){const{field:A,as:O}=_,{unit:P,utc:B,...q}=S,G=[O,`${O}_end`];p.push({field:ci(A),type:"timeunit",...P?{units:Kt(P)}:{},...B?{timezone:"utc"}:{},...q,as:G}),p.push(...tT(G,x,S))}else if(_){const{field:A}=_,O=A.replaceAll("\\.","."),P=eT({timeUnit:S,field:O}),B=ux(O);p.push({type:"formula",expr:P,as:B}),p.push(...tT([O,B],x,S))}}return p}}const Xc="offsetted_rect_start",Vd="offsetted_rect_end";function eT(d){let{timeUnit:p,field:_,reverse:x}=d;const{unit:S,utc:A}=p,O=Qh(S),{part:P,step:B}=q1(O,p.step);return`${A?"utcOffset":"timeOffset"}('${P}', datum['${_}'], ${x?-B:B})`}function tT(d,p,_){let[x,S]=d;if(void 0!==p&&.5!==p){const A=`datum['${x}']`,O=`datum['${S}']`;return[{type:"formula",expr:wp([eT({timeUnit:_,field:x,reverse:!0}),A],p+.5),as:`${x}_${Xc}`},{type:"formula",expr:wp([A,O],p+.5),as:`${x}_${Vd}`}]}return[]}function wp(d,p){let[_,x]=d;return`${1-p} * ${_} + ${p} * ${x}`}const $s="_tuple_fields";class uR{constructor(){ln(this,"hasChannel",void 0),ln(this,"hasField",void 0),ln(this,"hasSelectionId",void 0),ln(this,"timeUnit",void 0),ln(this,"items",void 0);for(var p=arguments.length,_=new Array(p),x=0;x
!0,parse:(d,p,_)=>{const x=p.name,S=p.project??=new uR,A={},O={},P=new Set,B=(De,Re)=>{const Le="visual"===Re?De.channel:De.field;let Ye=hn(`${x}_${Le}`);for(let bt=1;P.has(Ye);bt++)Ye=hn(`${x}_${Le}_${bt}`);return P.add(Ye),{[Re]:Ye}},q=p.type,G=d.config.selection[q],ee=void 0!==_.value?re.array(_.value):null;let{fields:se,encodings:Ee}=re.isObject(_.select)?_.select:{};if(!se&&!Ee&&ee)for(const De of ee)if(re.isObject(De))for(const Re of We(De))Af(Re)?(Ee||(Ee=[])).push(Re):"interval"===q?(nt('Interval selections should be initialized using "x", "y", "longitude", or "latitude" keys.'),Ee=G.encodings):(se??=[]).push(Re);!se&&!Ee&&(Ee=G.encodings,"fields"in G&&(se=G.fields));for(const De of Ee??[]){const Re=d.fieldDef(De);if(Re){let Le=Re.field;if(Re.aggregate){nt(_n(De,Re.aggregate));continue}if(!Le){nt(mt(De));continue}if(Re.timeUnit&&!qo(Re.timeUnit)){Le=d.vgField(De);const Ye={timeUnit:Re.timeUnit,as:Le,field:Re.field};O[kt(Ye)]=Ye}if(!A[Le]){const bt={field:Le,channel:De,type:"interval"===q&&pd(De)&&Da(d.getScaleComponent(De).get("type"))?"R":Re.bin?"R-RE":"E",index:S.items.length};bt.signals={...B(bt,"data"),...B(bt,"visual")},S.items.push(A[Le]=bt),S.hasField[Le]=A[Le],S.hasSelectionId=S.hasSelectionId||Le===Ya,za(De)?(bt.geoChannel=De,bt.channel=Mn(De),S.hasChannel[bt.channel]=A[Le]):S.hasChannel[De]=A[Le]}}else nt(mt(De))}for(const De of se??[]){if(S.hasField[De])continue;const Re={type:"E",field:De,index:S.items.length};Re.signals={...B(Re,"data")},S.items.push(Re),S.hasField[De]=Re,S.hasSelectionId=S.hasSelectionId||De===Ya}ee&&(p.init=ee.map(De=>S.items.map(Re=>re.isObject(De)?void 0!==De[Re.geoChannel||Re.channel]?De[Re.geoChannel||Re.channel]:De[Re.field]:De))),Gt(O)||(S.timeUnit=new el(null,O))},signals:(d,p,_)=>{const x=p.name+$s;return _.filter(A=>A.name===x).length>0||p.project.hasSelectionId?_:_.concat({name:x,value:p.project.items.map(HE)})}},uc={defined:d=>"interval"===d.type&&"global"===d.resolve&&d.bind&&"scales"===d.bind,parse:(d,p)=>{const _=p.scales=[];for(const x of p.project.items){const S=x.channel;if(!pd(S))continue;const A=d.getScaleComponent(S),O=A?A.get("type"):void 0;A&&Da(O)?(A.set("selectionExtent",{param:p.name,field:x.field},!0),_.push(x)):nt("Scale bindings are currently only supported for scales with unbinned, continuous domains.")}},topLevelSignals:(d,p,_)=>{const x=p.scales.filter(O=>0===_.filter(P=>P.name===O.signals.data).length);if(!d.parent||XE(d)||0===x.length)return _;const S=_.filter(O=>O.name===p.name)[0];let A=S.update;if(A.indexOf(fR)>=0)S.update=`{${x.map(O=>`${re.stringValue(ci(O.field))}: ${O.signals.data}`).join(", ")}}`;else{for(const O of x){const P=`${re.stringValue(ci(O.field))}: ${O.signals.data}`;A.includes(P)||(A=`${A.substring(0,A.length-1)}, ${P}}`)}S.update=A}return _.concat(x.map(O=>({name:O.signals.data})))},signals:(d,p,_)=>{if(d.parent&&!XE(d))for(const x of p.scales){const S=_.filter(A=>A.name===x.signals.data)[0];S.push="outer",delete S.value,delete S.update}return _}};function dx(d,p){return`domain(${re.stringValue(d.scaleName(p))})`}function XE(d){return d.parent&&Hg(d.parent)&&!d.parent.parent}const Ep="_brush",qy="_scale_trigger",Cp="geo_interval_init_tick",Gy="_init",YE={defined:d=>"interval"===d.type,parse:(d,p,_)=>{if(d.hasProjection){const x={...re.isObject(_.select)?_.select:{}};x.fields=[Ya],x.encodings||(x.encodings=_.value?We(_.value):[Ho,It]),_.select={type:"interval",...x}}if(p.translate&&!uc.defined(p)){const x=`!event.item || event.item.mark.name !== ${re.stringValue(p.name+Ep)}`;for(const S of p.events){if(!S.between){nt(`${S} is not an ordered event stream for interval selections.`);continue}const A=re.array(S.between[0].filter??=[]);A.indexOf(x)<0&&A.push(x)}}},signals:(d,p,_)=>{const x=p.name,S=x+Wd,A=Dn(p.project.hasChannel).filter(P=>P.channel===Ri||P.channel===mo),O=p.init?p.init[0]:null;if(_.push(...A.reduce((P,B)=>P.concat(function ms(d,p,_,x){const S=!d.hasProjection,A=_.channel,O=_.signals.visual,P=re.stringValue(S?d.scaleName(A):d.projectionName()),B=se=>`scale(${P}, ${se})`,q=d.getSizeSignalRef(A===Ri?"width":"height").signal,G=`${A}(unit)`,ee=p.events.reduce((se,Ee)=>[...se,{events:Ee.between[0],update:`[${G}, ${G}]`},{events:Ee,update:`[${O}[0], clamp(${G}, 0, ${q})]`}],[]);if(S){const se=_.signals.data,Ee=uc.defined(p),De=d.getScaleComponent(A),Re=De?De.get("type"):void 0,Le=x?{init:eh(x,!0,B)}:{value:[]};return ee.push({events:{signal:p.name+qy},update:Da(Re)?`[${B(`${se}[0]`)}, ${B(`${se}[1]`)}]`:"[0, 0]"}),Ee?[{name:se,on:[]}]:[{name:O,...Le,on:ee},{name:se,...x?{init:eh(x)}:{},on:[{events:{signal:O},update:`${O}[0] === ${O}[1] ? null : invert(${P}, ${O})`}]}]}{const se=A===Ri?0:1,Ee=p.name+Gy;return[{name:O,...x?{init:`[${Ee}[0][${se}], ${Ee}[1][${se}]]`}:{value:[]},on:ee}]}}(d,p,B,O&&O[B.index])),[])),d.hasProjection){const P=re.stringValue(d.projectionName()),B=d.projectionName()+"_center",{x:q,y:G}=p.project.hasChannel,ee=q&&q.signals.visual,se=G&&G.signals.visual,Ee=q?O&&O[q.index]:`${B}[0]`,De=G?O&&O[G.index]:`${B}[1]`,Re=vi=>d.getSizeSignalRef(vi).signal,Le=`[[${ee?ee+"[0]":"0"}, ${se?se+"[0]":"0"}],[${ee?ee+"[1]":Re("width")}, ${se?se+"[1]":Re("height")}]]`;O&&(_.unshift({name:x+Gy,init:`[scale(${P}, [${q?Ee[0]:Ee}, ${G?De[0]:De}]), scale(${P}, [${q?Ee[1]:Ee}, ${G?De[1]:De}])]`}),(!q||!G)&&(_.find(lr=>lr.name===B)||_.unshift({name:B,update:`invert(${P}, [${Re("width")}/2, ${Re("height")}/2])`})));const kn=`vlSelectionTuples(intersect(${Le}, {markname: ${re.stringValue(d.getName("marks"))}}, unit.mark), {unit: ${kp(d)}})`,dn=A.map(vi=>vi.signals.visual);return _.concat({name:S,on:[{events:[...dn.length?[{signal:dn.join(" || ")}]:[],...O?[{signal:Cp}]:[]],update:kn}]})}{if(!uc.defined(p)){const q=x+qy,G=A.map(ee=>{const se=ee.channel,{data:Ee,visual:De}=ee.signals,Re=re.stringValue(d.scaleName(se)),Ye=Da(d.getScaleComponent(se).get("type"))?"+":"";return`(!isArray(${Ee}) || (${Ye}invert(${Re}, ${De})[0] === ${Ye}${Ee}[0] && ${Ye}invert(${Re}, ${De})[1] === ${Ye}${Ee}[1]))`});G.length&&_.push({name:q,value:{},on:[{events:A.map(ee=>({scale:d.scaleName(ee.channel)})),update:G.join(" && ")+` ? ${q} : {}`}]})}const P=A.map(q=>q.signals.data),B=`unit: ${kp(d)}, fields: ${x+$s}, values`;return _.concat({name:S,...O?{init:`{${B}: ${eh(O)}}`}:{},...P.length?{on:[{events:[{signal:P.join(" || ")}],update:`${P.join(" && ")} ? {${B}: [${P}]} : null`}]}:{}})}},topLevelSignals:(d,p,_)=>(uo(d)&&d.hasProjection&&p.init&&(_.filter(S=>S.name===Cp).length||_.unshift({name:Cp,value:null,on:[{events:"timer{1}",update:`${Cp} === null ? {} : ${Cp}`}]})),_),marks:(d,p,_)=>{const x=p.name,{x:S,y:A}=p.project.hasChannel,O=S?.signals.visual,P=A?.signals.visual,B=`data(${re.stringValue(p.name+Hd)})`;if(uc.defined(p)||!S&&!A)return _;const q={x:void 0!==S?{signal:`${O}[0]`}:{value:0},y:void 0!==A?{signal:`${P}[0]`}:{value:0},x2:void 0!==S?{signal:`${O}[1]`}:{field:{group:"width"}},y2:void 0!==A?{signal:`${P}[1]`}:{field:{group:"height"}}};if("global"===p.resolve)for(const Re of We(q))q[Re]=[{test:`${B}.length && ${B}[0].unit === ${kp(d)}`,...q[Re]},{value:0}];const{fill:G,fillOpacity:ee,cursor:se,...Ee}=p.mark,De=We(Ee).reduce((Re,Le)=>(Re[Le]=[{test:[void 0!==S&&`${O}[0] !== ${O}[1]`,void 0!==A&&`${P}[0] !== ${P}[1]`].filter(Ye=>Ye).join(" && "),value:Ee[Le]},{value:null}],Re),{});return[{name:`${x+Ep}_bg`,type:"rect",clip:!0,encode:{enter:{fill:{value:G},fillOpacity:{value:ee}},update:q}},..._,{name:x+Ep,type:"rect",clip:!0,encode:{enter:{...se?{cursor:{value:se}}:{},fill:{value:"transparent"}},update:{...q,...De}}}]}};const Ro={defined:d=>"point"===d.type,signals:(d,p,_)=>{const x=p.name,S=x+$s,A=p.project,O="(item().isVoronoi ? datum.datum : datum)",P=Dn(d.component.selection??{}).reduce((ee,se)=>"interval"===se.type?ee.concat(se.name+Ep):ee,[]).map(ee=>`indexof(item().mark.name, '${ee}') < 0`).join(" && "),B="datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0"+(P?` && ${P}`:"");let q=`unit: ${kp(d)}, `;q+=p.project.hasSelectionId?`${Ya}: ${O}[${re.stringValue(Ya)}]`:`fields: ${S}, values: [${A.items.map(se=>d.fieldDef(se.channel)?.bin?`[${O}[${re.stringValue(d.vgField(se.channel,{}))}], ${O}[${re.stringValue(d.vgField(se.channel,{binSuffix:"end"}))}]]`:`${O}[${re.stringValue(se.field)}]`).join(", ")}]`;const G=p.events;return _.concat([{name:x+Wd,on:G?[{events:G,update:`${B} ? {${q}} : null`,force:!0}]:[]}])}};function Sp(d,p,_,x){const S=hE(p)&&p.condition,A=x(p);return S?{[_]:[...re.array(S).map(B=>{const q=x(B);if(function yy(d){return d.param}(B)){const{param:G,empty:ee}=B;return{test:ib(d,{param:G,empty:ee}),...q}}return{test:aC(d,B.test),...q}}),...void 0!==A?[A]:[]]}:void 0!==A?{[_]:A}:{}}function KE(d){let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"text";return Sp(d,d.encoding[p],p,x=>jd(x,d.config))}function jd(d,p){let _=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"datum";if(d){if(Ma(d))return Ar(d.value);if(Bn(d)){const{format:x,formatType:S}=Lv(d);return Hc({fieldOrDatumDef:d,format:x,formatType:S,expr:_,config:p})}}}function Yy(d){let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{encoding:_,markDef:x,config:S,stack:A}=d,O=_.tooltip;if(re.isArray(O))return{tooltip:nT({tooltip:O},A,S,p)};{const P=p.reactiveGeom?"datum.datum":"datum";return Sp(d,O,"tooltip",B=>{const q=jd(B,S,P);if(q)return q;if(null===B)return;let G=Ji("tooltip",x,S);return!0===G&&(G={content:"encoding"}),re.isString(G)?{value:G}:re.isObject(G)?Je(G)?G:"encoding"===G.content?nT(_,A,S,p):{signal:P}:void 0})}}function ZE(d,p,_){let{reactiveGeom:x}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const S={..._,..._.tooltipFormat},A={},O=x?"datum.datum":"datum",P=[];function B(G,ee){const se=Fc(ee),Ee=Yo(G)?G:{...G,type:d[se].type},De=Ee.title||lg(Ee,S),Re=re.array(De).join(", ").replaceAll(/"/g,'\\"');let Le;if(Yr(ee)){const Ye="x"===ee?"x2":"y2",bt=ku(d[Ye]);if(oo(Ee.bin)&&bt){const kn=pt(Ee,{expr:O}),dn=pt(bt,{expr:O}),{format:vi,formatType:lr}=Lv(Ee);Le=ng(kn,dn,vi,lr,S),A[Ye]=!0}}if((Yr(ee)||ee===As||ee===Ao)&&p&&p.fieldChannel===ee&&"normalize"===p.offset){const{format:Ye,formatType:bt}=Lv(Ee);Le=Hc({fieldOrDatumDef:Ee,format:Ye,formatType:bt,expr:O,config:S,normalizeStack:!0}).signal}Le??=jd(Ee,S,O).signal,P.push({channel:ee,key:Re,value:Le})}Ey(d,(G,ee)=>{dt(G)?B(G,ee):qf(G)&&B(G.condition,ee)});const q={};for(const{channel:G,key:ee,value:se}of P)!A[G]&&!q[ee]&&(q[ee]=se);return q}function nT(d,p,_){let{reactiveGeom:x}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const S=ZE(d,p,_,{reactiveGeom:x}),A=Jt(S).map(O=>{let[P,B]=O;return`"${P}": ${B}`});return A.length>0?{signal:`{${A.join(", ")}}`}:void 0}function iT(d){const{markDef:p,config:_}=d,x=Ji("aria",p,_);return!1===x?{}:{...x?{aria:x}:{},...rT(d),...dc(d)}}function rT(d){const{mark:p,markDef:_,config:x}=d;if(!1===x.aria)return{};const S=Ji("ariaRoleDescription",_,x);return null!=S?{ariaRoleDescription:{value:S}}:p in OM?{}:{ariaRoleDescription:{value:p}}}function dc(d){const{encoding:p,markDef:_,config:x,stack:S}=d,A=p.description;if(A)return Sp(d,A,"description",B=>jd(B,d.config));const O=Ji("description",_,x);if(null!=O)return{description:Ar(O)};if(!1===x.aria)return{};const P=ZE(p,S,x);return Gt(P)?void 0:{description:{signal:Jt(P).map((B,q)=>{let[G,ee]=B;return`"${q>0?"; ":""}${G}: " + (${ee})`}).join(" + ")}}}function gs(d,p){let _=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{markDef:x,encoding:S,config:A}=p,{vgChannel:O}=_;let{defaultRef:P,defaultValue:B}=_;return void 0===P&&(B??=Ji(d,x,A,{vgChannel:O,ignoreVgConfig:!0}),void 0!==B&&(P=Ar(B))),Sp(p,S[d],O??d,G=>lE({channel:d,channelDef:G,markDef:x,config:A,scaleName:p.scaleName(d),scale:p.getScaleComponent(d),stack:null,defaultRef:P}))}function QE(d){let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{filled:void 0};const{markDef:_,encoding:x,config:S}=d,{type:A}=_,O=p.filled??Ji("filled",_,S),P=St(["bar","point","circle","square","geoshape"],A)?"transparent":void 0,B=Ji(!0===O?"color":void 0,_,S,{vgChannel:"fill"})??S.mark[!0===O&&"color"]??P,q=Ji(!1===O?"color":void 0,_,S,{vgChannel:"stroke"})??S.mark[!1===O&&"color"],G=O?"fill":"stroke",ee={...B?{fill:Ar(B)}:{},...q?{stroke:Ar(q)}:{}};return _.color&&(O?_.fill:_.stroke)&&nt(Gm("property",{fill:"fill"in _,stroke:"stroke"in _})),{...ee,...gs("color",d,{vgChannel:G,defaultValue:O?B:q}),...gs("fill",d,{defaultValue:x.fill?B:void 0}),...gs("stroke",d,{defaultValue:x.stroke?q:void 0})}}function Dp(d){const{encoding:p,mark:_}=d,x=p.order;return!yl(_)&&Ma(x)?Sp(d,x,"zindex",S=>Ar(S.value)):{}}function th(d){let{channel:p,markDef:_,encoding:x={},model:S,bandPosition:A}=d;const O=`${p}Offset`,P=_[O],B=x[O];if(("xOffset"===O||"yOffset"===O)&&B)return{offsetType:"encoding",offset:lE({channel:O,channelDef:B,markDef:_,config:S?.config,scaleName:S.scaleName(O),scale:S.getScaleComponent(O),stack:null,defaultRef:Ar(P),bandPosition:A})};const q=_[O];return q?{offsetType:"visual",offset:q}:{}}function Ia(d,p,_){let{defaultPos:x,vgChannel:S}=_;const{encoding:A,markDef:O,config:P,stack:B}=p,q=A[d],G=A[Or(d)],ee=p.scaleName(d),se=p.getScaleComponent(d),{offset:Ee,offsetType:De}=th({channel:d,markDef:O,encoding:A,model:p,bandPosition:.5}),Re=wl({model:p,defaultPos:x,channel:d,scaleName:ee,scale:se}),Le=!q&&Yr(d)&&(A.latitude||A.longitude)?{field:p.getName(d)}:function dR(d){const{channel:p,channelDef:_,scaleName:x,stack:S,offset:A,markDef:O}=d;if(Bn(_)&&S&&p===S.fieldChannel){if(dt(_)){let P=_.bandPosition;if(void 0===P&&"text"===O.type&&("radius"===p||"theta"===p)&&(P=.5),void 0!==P)return sc({scaleName:x,fieldOrDatumDef:_,startSuffix:"start",bandPosition:P,offset:A})}return Xa(_,x,{suffix:"end"},{offset:A})}return tg(d)}({channel:d,channelDef:q,channel2Def:G,markDef:O,config:P,scaleName:ee,scale:se,stack:B,offset:Ee,defaultRef:Re,bandPosition:"encoding"===De?0:void 0});return Le?{[S||d]:Le}:void 0}function wl(d){let{model:p,defaultPos:_,channel:x,scaleName:S,scale:A}=d;const{markDef:O,config:P}=p;return()=>{const B=Fc(x),q=xa(x),G=Ji(x,O,P,{vgChannel:q});if(void 0!==G)return Fi(x,G);switch(_){case"zeroOrMin":case"zeroOrMax":if(S){const ee=A.get("type");if(!St([Ga.LOG,Ga.TIME,Ga.UTC],ee)&&A.domainDefinitelyIncludesZero())return{scale:S,value:0}}if("zeroOrMin"===_)return"y"===B?{field:{group:"height"}}:{value:0};switch(B){case"radius":return{signal:`min(${p.width.signal},${p.height.signal})/2`};case"theta":return{signal:"2*PI"};case"x":return{field:{group:"width"}};case"y":return{value:0}}break;case"mid":return{...p[Mr(x)],mult:.5}}}}const Ky={left:"x",center:"xc",right:"x2"},JE={top:"y",middle:"yc",bottom:"y2"};function xg(d,p,_){let x=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"middle";if("radius"===d||"theta"===d)return xa(d);const S="x"===d?"align":"baseline",A=Ji(S,p,_);let O;return Je(A)?(nt(function uv(d){return`The ${d} for range marks cannot be an expression`}(S)),O=void 0):O=A,"x"===d?Ky[O||("top"===x?"left":"center")]:JE[O||x]}function $u(d,p,_){let{defaultPos:x,defaultPos2:S,range:A}=_;return A?Bs(d,p,{defaultPos:x,defaultPos2:S}):Ia(d,p,{defaultPos:x})}function Bs(d,p,_){let{defaultPos:x,defaultPos2:S}=_;const{markDef:A,config:O}=p,P=Or(d),B=Mr(d),q=function Zy(d,p,_){const{encoding:x,mark:S,markDef:A,stack:O,config:P}=d,B=Fc(_),q=Mr(_),G=xa(_),ee=x[B],se=d.scaleName(B),Ee=d.getScaleComponent(B),{offset:De}=th(_ in x||_ in A?{channel:_,markDef:A,encoding:x,model:d}:{channel:B,markDef:A,encoding:x,model:d});if(!ee&&("x2"===_||"y2"===_)&&(x.latitude||x.longitude)){const Le=Mr(_),Ye=d.markDef[Le];return null!=Ye?{[Le]:{value:Ye}}:{[G]:{field:d.getName(_)}}}const Re=function Qy(d){let{channel:p,channelDef:_,channel2Def:x,markDef:S,config:A,scaleName:O,scale:P,stack:B,offset:q,defaultRef:G}=d;return Bn(_)&&B&&p.charAt(0)===B.fieldChannel.charAt(0)?Xa(_,O,{suffix:"start"},{offset:q}):tg({channel:p,channelDef:x,scaleName:O,scale:P,stack:B,markDef:S,config:A,offset:q,defaultRef:G})}({channel:_,channelDef:ee,channel2Def:x[_],markDef:A,config:P,scaleName:se,scale:Ee,stack:O,offset:De,defaultRef:void 0});return void 0!==Re?{[G]:Re}:Mp(_,A)||Mp(_,{[_]:ey(_,A,P.style),[q]:ey(q,A,P.style)})||Mp(_,P[S])||Mp(_,P.mark)||{[G]:wl({model:d,defaultPos:p,channel:_,scaleName:se,scale:Ee})()}}(p,S,P);return{...Ia(d,p,{defaultPos:x,vgChannel:q[B]?xg(d,A,O):xa(d)}),...q}}function Mp(d,p){const _=Mr(d),x=xa(d);if(void 0!==p[x])return{[x]:Fi(d,p[x])};if(void 0!==p[d])return{[x]:Fi(d,p[d])};if(p[_]){const S=p[_];if(!Au(S))return{[_]:Fi(d,S)};nt(function Bc(d){return`Position range does not support relative band size for ${d}.`}(_))}}function El(d,p){const{config:_,encoding:x,markDef:S}=d,A=S.type,O=Or(p),P=Mr(p),B=x[p],q=x[O],G=d.getScaleComponent(p),ee=G?G.get("type"):void 0,se=S.orient,Ee=x[P]??x.size??Ji("size",S,_,{vgChannel:P}),De=na(p),Re="bar"===A&&("x"===p?"vertical"===se:"horizontal"===se);return!dt(B)||!(sr(B.bin)||oo(B.bin)||B.timeUnit&&!q)||Ee&&!Au(Ee)||x[De]||ko(ee)?(Bn(B)&&ko(ee)||Re)&&!q?function wg(d,p,_){const{markDef:x,encoding:S,config:A,stack:O}=_,P=x.orient,B=_.scaleName(p),q=_.getScaleComponent(p),G=Mr(p),ee=Or(p),se=na(p),Ee=_.scaleName(se),De=_.getScaleComponent(To(p)),Re="horizontal"===P&&"y"===p||"vertical"===P&&"x"===p;let Le;(S.size||x.size)&&(Re?Le=gs("size",_,{vgChannel:G,defaultRef:Ar(x.size)}):nt(function N2(d){return`Cannot apply size to non-oriented mark "${d}".`}(x.type)));const Ye=!!Le,bt=by({channel:p,fieldDef:d,markDef:x,config:A,scaleType:(q||De)?.get("type"),useVlSizeChannel:Re});Le=Le||{[G]:Ap(G,Ee||B,De||q,A,bt,!!d,x.type)};const dn=xg(p,x,A,"band"===(q||De)?.get("type")&&Au(bt)&&!Ye?"top":"middle"),vi="xc"===dn||"yc"===dn,{offset:lr,offsetType:ca}=th({channel:p,markDef:x,encoding:S,model:_,bandPosition:vi?.5:0}),ua=tg({channel:p,channelDef:d,markDef:x,config:A,scaleName:B,scale:q,stack:O,offset:lr,defaultRef:wl({model:_,defaultPos:"mid",channel:p,scaleName:B,scale:q}),bandPosition:vi?"encoding"===ca?0:.5:Je(bt)?{signal:`(1-${bt})/2`}:Au(bt)?(1-bt.band)/2:0});if(G)return{[dn]:ua,...Le};{const da=xa(ee),Ml=Le[G],fa=lr?{...Ml,offset:lr}:Ml;return{[dn]:ua,[da]:re.isArray(ua)?[ua[0],{...ua[1],offset:fa}]:{...ua,offset:fa}}}}(B,p,d):Bs(p,d,{defaultPos:"zeroOrMax",defaultPos2:"zeroOrMin"}):function Ud(d){let{fieldDef:p,fieldDef2:_,channel:x,model:S}=d;const{config:A,markDef:O,encoding:P}=S,B=S.getScaleComponent(x),q=S.scaleName(x),G=B?B.get("type"):void 0,ee=B.get("reverse"),se=by({channel:x,fieldDef:p,markDef:O,config:A,scaleType:G}),De=S.component.axes[x]?.[0]?.get("translate")??.5,Re=Yr(x)?Ji("binSpacing",O,A)??0:0,Le=Or(x),Ye=xa(x),bt=xa(Le),kn=xu("minBandSize",O,A),{offset:dn}=th({channel:x,markDef:O,encoding:P,model:S,bandPosition:0}),{offset:vi}=th({channel:Le,markDef:O,encoding:P,model:S,bandPosition:0}),lr=function ao(d){let{scaleName:p,fieldDef:_}=d;const x=pt(_,{expr:"datum"});return`abs(scale("${p}", ${pt(_,{expr:"datum",suffix:"end"})}) - scale("${p}", ${x}))`}({fieldDef:p,scaleName:q}),ca=Eg(x,Re,ee,De,dn,kn,lr),ua=Eg(Le,Re,ee,De,vi??dn,kn,lr),da=Je(se)?{signal:`(1-${se.signal})/2`}:Au(se)?(1-se.band)/2:.5,Ml=Tu({fieldDef:p,fieldDef2:_,markDef:O,config:A});if(sr(p.bin)||p.timeUnit){const fa=p.timeUnit&&.5!==Ml;return{[bt]:Yc({fieldDef:p,scaleName:q,bandPosition:da,offset:ua,useRectOffsetField:fa}),[Ye]:Yc({fieldDef:p,scaleName:q,bandPosition:Je(da)?{signal:`1-${da.signal}`}:1-da,offset:ca,useRectOffsetField:fa})}}if(oo(p.bin)){const fa=Xa(p,q,{},{offset:ua});if(dt(_))return{[bt]:fa,[Ye]:Xa(_,q,{},{offset:ca})};if(Lc(p.bin)&&p.bin.step)return{[bt]:fa,[Ye]:{signal:`scale("${q}", ${pt(p,{expr:"datum"})} + ${p.bin.step})`,offset:ca}}}nt(eA(Le))}({fieldDef:B,fieldDef2:q,channel:p,model:d})}function Ap(d,p,_,x,S,A,O){if(Au(S)){if(!_)return{mult:S.band,field:{group:d}};{const B=_.get("type");if("band"===B){let q=`bandwidth('${p}')`;1!==S.band&&(q=`${S.band} * ${q}`);const G=xu("minBandSize",{type:O},x);return{signal:G?`max(${ec(G)}, ${q})`:q}}1!==S.band&&(nt(function iy(d){return`Cannot use the relative band size with ${d} scale.`}(B)),S=void 0)}}else{if(Je(S))return S;if(S)return{value:S}}if(_){const B=_.get("range");if(ht(B)&&re.isNumber(B.step))return{value:B.step-2}}if(!A){const{bandPaddingInner:B,barBandPaddingInner:q,rectBandPaddingInner:G}=x.scale,ee=ui(B,"bar"===O?q:G);if(Je(ee))return{signal:`(1 - (${ee.signal})) * ${d}`};if(re.isNumber(ee))return{signal:`${1-ee} * ${d}`}}return{value:pr(x.view,d)-2}}function Eg(d,p,_,x,S,A,O){if(D2(d))return 0;const P="x"===d||"y2"===d,B=P?-p/2:p/2;if(Je(_)||Je(S)||Je(x)||A){const q=ec(_),G=ec(S),ee=ec(x),se=ec(A),De=A?`(${O} < ${se} ? ${P?"":"-"}0.5 * (${se} - (${O})) : ${B})`:B;return{signal:(ee?`${ee} + `:"")+(q?`(${q} ? -1 : 1) * `:"")+(G?`(${G} + ${De})`:De)}}return S=S||0,x+(_?-S-B:+S+B)}function Yc(d){let{fieldDef:p,scaleName:_,bandPosition:x,offset:S,useRectOffsetField:A}=d;return sc({scaleName:_,fieldOrDatumDef:p,bandPosition:x,offset:S,...A?{startSuffix:Xc,endSuffix:Vd}:{}})}const Cg=new Set(["aria","width","height"]);function _s(d,p){const{fill:_,stroke:x}="include"===p.color?QE(d):{};return{...oT(d.markDef,p),...fx(d,"fill",_),...fx(d,"stroke",x),...gs("opacity",d),...gs("fillOpacity",d),...gs("strokeOpacity",d),...gs("strokeWidth",d),...gs("strokeDash",d),...Dp(d),...Yy(d),...KE(d,"href"),...iT(d)}}function fx(d,p,_){const{config:x,mark:S,markDef:A}=d;if("hide"===Ji("invalid",A,x)&&_&&!yl(S)){const P=function sT(d,p){let{invalid:_=!1,channels:x}=p;const S=x.reduce((O,P)=>{const B=d.getScaleComponent(P);if(B){const q=B.get("type"),G=d.vgField(P,{expr:"datum"});G&&Da(q)&&(O[G]=!0)}return O},{}),A=We(S);if(A.length>0){const O=_?"||":"&&";return A.map(P=>Uf(P,_)).join(` ${O} `)}}(d,{invalid:!0,channels:ev});if(P)return{[p]:[{test:P,value:null},...re.array(_)]}}return _?{[p]:_}:{}}function oT(d,p){return gd.reduce((_,x)=>(!Cg.has(x)&&void 0!==d[x]&&"ignore"!==p[x]&&(_[x]=Ar(d[x])),_),{})}function Sg(d){const{config:p,markDef:_}=d;if(Ji("invalid",_,p)){const S=function eC(d,p){let{invalid:_=!1,channels:x}=p;const S=x.reduce((O,P)=>{const B=d.getScaleComponent(P);if(B){const q=B.get("type"),G=d.vgField(P,{expr:"datum",binSuffix:d.stack?.impute?"mid":void 0});G&&Da(q)&&(O[G]=!0)}return O},{}),A=We(S);if(A.length>0){const O=_?"||":"&&";return A.map(P=>Uf(P,_)).join(` ${O} `)}}(d,{channels:Ql});if(S)return{defined:{signal:S}}}return{}}function aT(d,p){if(void 0!==p)return{[d]:Ar(p)}}const tC="voronoi",Tp={defined:d=>"point"===d.type&&d.nearest,parse:(d,p)=>{if(p.events)for(const _ of p.events)_.markname=d.getName(tC)},marks:(d,p,_)=>{const{x,y:S}=p.project.hasChannel,A=d.mark;if(yl(A))return nt(function yo(d){return`The "nearest" transform is not supported for ${d} marks.`}(A)),_;const O={name:d.getName(tC),type:"path",interactive:!0,from:{data:d.getName("marks")},encode:{update:{fill:{value:"transparent"},strokeWidth:{value:.35},stroke:{value:"transparent"},isVoronoi:{value:!0},...Yy(d,{reactiveGeom:!0})}},transform:[{type:"voronoi",x:{expr:x||!S?"datum.datum.x || 0":"0"},y:{expr:S||!x?"datum.datum.y || 0":"0"},size:[d.getSizeSignalRef("width"),d.getSizeSignalRef("height")]}]};let P=0,B=!1;return _.forEach((q,G)=>{const ee=q.name??"";ee===d.component.mark[0].name?P=G:ee.indexOf(tC)>=0&&(B=!0)}),B||_.splice(P+1,0,O),_}},nC={defined:d=>"point"===d.type&&"global"===d.resolve&&d.bind&&"scales"!==d.bind&&!DE(d.bind),parse:(d,p,_)=>zn(p,_),topLevelSignals:(d,p,_)=>{const x=p.name,S=p.project,A=p.bind,O=p.init&&p.init[0],P=Tp.defined(p)?"(item().isVoronoi ? datum.datum : datum)":"datum";return S.items.forEach((B,q)=>{const G=hn(`${x}_${B.field}`);_.filter(se=>se.name===G).length||_.unshift({name:G,...O?{init:eh(O[q])}:{value:null},on:p.events?[{events:p.events,update:`datum && item().mark.marktype !== 'group' ? ${P}[${re.stringValue(B.field)}] : null`}]:[],bind:A[B.field]??A[B.channel]??A})}),_},signals:(d,p,_)=>{const x=p.name,S=p.project,A=_.filter(q=>q.name===x+Wd)[0],O=x+$s,P=S.items.map(q=>hn(`${x}_${q.field}`)),B=P.map(q=>`${q} !== null`).join(" && ");return P.length&&(A.update=`${B} ? {fields: ${O}, values: [${P.join(", ")}]} : null`),delete A.value,delete A.on,_}},Dg="_toggle",hx={defined:d=>"point"===d.type&&!!d.toggle,signals:(d,p,_)=>_.concat({name:p.name+Dg,value:!1,on:[{events:p.events,update:p.toggle}]}),modifyExpr:(d,p)=>{const _=p.name+Wd,x=p.name+Dg;return`${x} ? null : ${_}, `+("global"===p.resolve?`${x} ? null : true, `:`${x} ? null : {unit: ${kp(d)}}, `)+`${x} ? ${_} : null`}},lT={defined:d=>void 0!==d.clear&&!1!==d.clear,parse:(d,p)=>{p.clear&&(p.clear=re.isString(p.clear)?re.parseSelector(p.clear,"view"):p.clear)},topLevelSignals:(d,p,_)=>{if(nC.defined(p))for(const x of p.project.items){const S=_.findIndex(A=>A.name===hn(`${p.name}_${x.field}`));-1!==S&&_[S].on.push({events:p.clear,update:"null"})}return _},signals:(d,p,_)=>{function x(S,A){-1!==S&&_[S].on&&_[S].on.push({events:p.clear,update:A})}if("interval"===p.type)for(const S of p.project.items){const A=_.findIndex(O=>O.name===S.signals.visual);x(A,"[0, 0]"),-1===A&&x(_.findIndex(P=>P.name===S.signals.data),"null")}else{let S=_.findIndex(A=>A.name===p.name+Wd);x(S,"null"),hx.defined(p)&&(S=_.findIndex(A=>A.name===p.name+Dg),x(S,"false"))}return _}},cT={defined:d=>{const p="global"===d.resolve&&d.bind&&DE(d.bind),_=1===d.project.items.length&&d.project.items[0].field!==Ya;return p&&!_&&nt("Legend bindings are only supported for selections over an individual field or encoding channel."),p&&_},parse:(d,p,_)=>{const x=st(_);if(x.select=re.isString(x.select)?{type:x.select,toggle:p.toggle}:{...x.select,toggle:p.toggle},zn(p,x),re.isObject(_.select)&&(_.select.on||_.select.clear)){const O='event.item && indexof(event.item.mark.role, "legend") < 0';for(const P of p.events)P.filter=re.array(P.filter??[]),P.filter.includes(O)||P.filter.push(O)}const S=Iy(p.bind)?p.bind.legend:"click",A=re.isString(S)?re.parseSelector(S,"view"):re.array(S);p.bind={legend:{merge:A}}},topLevelSignals:(d,p,_)=>{const x=p.name,S=Iy(p.bind)&&p.bind.legend,A=O=>P=>{const B=st(P);return B.markname=O,B};for(const O of p.project.items){if(!O.hasLegend)continue;const P=`${hn(O.field)}_legend`,B=`${x}_${P}`;if(0===_.filter(G=>G.name===B).length){const G=S.merge.map(A(`${P}_symbols`)).concat(S.merge.map(A(`${P}_labels`))).concat(S.merge.map(A(`${P}_entries`)));_.unshift({name:B,...p.init?{}:{value:null},on:[{events:G,update:"isDefined(datum.value) ? datum.value : item().items[0].items[0].datum.value",force:!0},{events:S.merge,update:`!event.item || !datum ? null : ${B}`,force:!0}]})}}return _},signals:(d,p,_)=>{const x=p.name,S=p.project,A=_.find(se=>se.name===x+Wd),O=x+$s,P=S.items.filter(se=>se.hasLegend).map(se=>hn(`${x}_${hn(se.field)}_legend`)),q=`${P.map(se=>`${se} !== null`).join(" && ")} ? {fields: ${O}, values: [${P.join(", ")}]} : null`;p.events&&P.length>0?A.on.push({events:P.map(se=>({signal:se})),update:q}):P.length>0&&(A.update=q,delete A.value,delete A.on);const G=_.find(se=>se.name===x+Dg),ee=Iy(p.bind)&&p.bind.legend;return G&&(p.events?G.on.push({...G.on[0],events:ee}):G.on[0].events=ee),_}};const uT="_translate_anchor",Jy="_translate_delta",eb={defined:d=>"interval"===d.type&&d.translate,signals:(d,p,_)=>{const x=p.name,S=uc.defined(p),A=x+uT,{x:O,y:P}=p.project.hasChannel;let B=re.parseSelector(p.translate,"scope");return S||(B=B.map(q=>(q.between[0].markname=x+Ep,q))),_.push({name:A,value:{},on:[{events:B.map(q=>q.between[0]),update:"{x: x(unit), y: y(unit)"+(void 0!==O?`, extent_x: ${S?dx(d,Ri):`slice(${O.signals.visual})`}`:"")+(void 0!==P?`, extent_y: ${S?dx(d,mo):`slice(${P.signals.visual})`}`:"")+"}"}]},{name:x+Jy,value:{},on:[{events:B,update:`{x: ${A}.x - x(unit), y: ${A}.y - y(unit)}`}]}),void 0!==O&&px(d,p,O,"width",_),void 0!==P&&px(d,p,P,"height",_),_}};function px(d,p,_,x,S){const A=p.name,O=A+uT,P=A+Jy,B=_.channel,q=uc.defined(p),G=S.filter(vi=>vi.name===_.signals[q?"data":"visual"])[0],ee=d.getSizeSignalRef(x).signal,se=d.getScaleComponent(B),Ee=se&&se.get("type"),De=se&&se.get("reverse"),Le=`${O}.extent_${B}`,dn=`${q&&se?"log"===Ee?"panLog":"symlog"===Ee?"panSymlog":"pow"===Ee?"panPow":"panLinear":"panLinear"}(${Le}, ${q?B===Ri?De?"":"-":De?"-":"":""}${P}.${B} / ${q?`${ee}`:`span(${Le})`}${q?"pow"===Ee?`, ${se.get("exponent")??1}`:"symlog"===Ee?`, ${se.get("constant")??1}`:"":""})`;G.on.push({events:{signal:P},update:q?dn:`clampRange(${dn}, 0, ${ee})`})}const iC="_zoom_anchor",tb="_zoom_delta",nb={defined:d=>"interval"===d.type&&d.zoom,signals:(d,p,_)=>{const x=p.name,S=uc.defined(p),A=x+tb,{x:O,y:P}=p.project.hasChannel,B=re.stringValue(d.scaleName(Ri)),q=re.stringValue(d.scaleName(mo));let G=re.parseSelector(p.zoom,"scope");return S||(G=G.map(ee=>(ee.markname=x+Ep,ee))),_.push({name:x+iC,on:[{events:G,update:S?"{"+[B?`x: invert(${B}, x(unit))`:"",q?`y: invert(${q}, y(unit))`:""].filter(ee=>ee).join(", ")+"}":"{x: x(unit), y: y(unit)}"}]},{name:A,on:[{events:G,force:!0,update:"pow(1.001, event.deltaY * pow(16, event.deltaMode))"}]}),void 0!==O&&mx(d,p,O,"width",_),void 0!==P&&mx(d,p,P,"height",_),_}};function mx(d,p,_,x,S){const A=p.name,O=_.channel,P=uc.defined(p),B=S.filter(bt=>bt.name===_.signals[P?"data":"visual"])[0],q=d.getSizeSignalRef(x).signal,G=d.getScaleComponent(O),ee=G&&G.get("type"),se=P?dx(d,O):B.name,Ee=A+tb,Ye=`${P&&G?"log"===ee?"zoomLog":"symlog"===ee?"zoomSymlog":"pow"===ee?"zoomPow":"zoomLinear":"zoomLinear"}(${se}, ${A}${iC}.${O}, ${Ee}${P?"pow"===ee?`, ${G.get("exponent")??1}`:"symlog"===ee?`, ${G.get("constant")??1}`:"":""})`;B.on.push({events:{signal:Ee},update:P?Ye:`clampRange(${Ye}, 0, ${q})`})}const Hd="_store",Wd="_tuple",dT="_modify",fR="vlSelectionResolve",gx=[Ro,YE,GE,hx,nC,uc,cT,lT,eb,nb,Tp];function kp(d){let{escape:p}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{escape:!0},_=p?re.stringValue(d.name):d.name;const x=function Ag(d){let p=d.parent;for(;p&&!mc(p);)p=p.parent;return p}(d);if(x){const{facet:S}=x;for(const A of Zl)S[A]&&(_+=` + '__facet_${A}_' + (facet[${re.stringValue(x.vgField(A))}])`)}return _}function nh(d){return Dn(d.component.selection??{}).reduce((p,_)=>p||_.project.hasSelectionId,!1)}function zn(d,p){(re.isString(p.select)||!p.select.on)&&delete d.events,(re.isString(p.select)||!p.select.clear)&&delete d.clear,(re.isString(p.select)||!p.select.toggle)&&delete d.toggle}function rC(d){const p=[];return"Identifier"===d.type?[d.name]:"Literal"===d.type?[d.value]:("MemberExpression"===d.type&&(p.push(...rC(d.object)),p.push(...rC(d.property))),p)}function _x(d){return"MemberExpression"===d.object.type?_x(d.object):"datum"===d.object.name}function tl(d){const p=re.parseExpression(d),_=new Set;return p.visit(x=>{"MemberExpression"===x.type&&_x(x)&&_.add(rC(x).slice(1).join("."))}),_}class Cl extends Tn{clone(){return new Cl(null,this.model,st(this.filter))}constructor(p,_,x){super(p),this.model=_,this.filter=x,ln(this,"expr",void 0),ln(this,"_dependentFields",void 0),this.expr=aC(this.model,this.filter,this),this._dependentFields=tl(this.expr)}dependentFields(){return this._dependentFields}producedFields(){return new Set}assemble(){return{type:"filter",expr:this.expr}}hash(){return`Filter ${this.expr}`}}function ib(d,p,_){let x=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"datum";const S=re.isString(p)?p:p.param,A=hn(S),O=re.stringValue(A+Hd);let P;try{P=d.getSelectionComponent(A,S)}catch{return`!!${A}`}if(P.project.timeUnit){const se=_??d.component.data.raw,Ee=P.project.timeUnit.clone();se.parent?Ee.insertAsParentOf(se):se.parent=Ee}const G=`${P.project.hasSelectionId?"vlSelectionIdTest(":"vlSelectionTest("}${O}, ${x}${"global"===P.resolve?")":`, ${re.stringValue(P.resolve)})`}`,ee=`length(data(${O}))`;return!1===p.empty?`${ee} && ${G}`:`!${ee} || ${G}`}function sC(d,p,_){const x=hn(p),S=_.encoding;let O,A=_.field;try{O=d.getSelectionComponent(x,p)}catch{return x}if(S||A){if(S&&!A){const P=O.project.items.filter(B=>B.channel===S);!P.length||P.length>1?(A=O.project.items[0].field,nt((P.length?"Multiple ":"No ")+`matching ${re.stringValue(S)} encoding found for selection ${re.stringValue(_.param)}. Using "field": ${re.stringValue(A)}.`)):A=P[0].field}}else A=O.project.items[0].field,O.project.items.length>1&&nt(`A "field" or "encoding" must be specified when using a selection as a scale domain. Using "field": ${re.stringValue(A)}.`);return`${O.name}[${re.stringValue(ci(A))}]`}function aC(d,p,_){return io(p,x=>re.isString(x)?x:function Km(d){return d?.param}(x)?ib(d,x,_):Zm(x))}function Ip(d,p,_,x){d.encode??={},d.encode[p]??={},d.encode[p].update??={},d.encode[p].update[_]=x}function rb(d,p,_){let x=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{header:!1};const{disable:S,orient:A,scale:O,labelExpr:P,title:B,zindex:q,...G}=d.combine();if(!S){for(const ee in G){const se=$v[ee],Ee=G[ee];if(se&&se!==p&&"both"!==se)delete G[ee];else if(Xf(Ee)){const{condition:De,...Re}=Ee,Le=re.array(De),Ye=_A[ee];if(Ye){const{vgProp:bt,part:kn}=Ye;Ip(G,kn,bt,[...Le.map(vi=>{const{test:lr,...ca}=vi;return{test:aC(null,lr),...ca}}),Re]),delete G[ee]}else if(null===Ye){const bt={signal:Le.map(kn=>{const{test:dn,...vi}=kn;return`${aC(null,dn)} ? ${FM(vi)} : `}).join("")+FM(Re)};G[ee]=bt}}else if(Je(Ee)){const De=_A[ee];if(De){const{vgProp:Re,part:Le}=De;Ip(G,Le,Re,Ee),delete G[ee]}}St(["labelAlign","labelBaseline"],ee)&&null===G[ee]&&delete G[ee]}if("grid"===p){if(!G.grid)return;if(G.encode){const{grid:ee}=G.encode;G.encode={...ee?{grid:ee}:{}},Gt(G.encode)&&delete G.encode}return{scale:O,orient:A,...G,domain:!1,labels:!1,aria:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:ui(q,0)}}{if(!x.header&&d.mainExtracted)return;if(void 0!==P){let se=P;G.encode?.labels?.update&&Je(G.encode.labels.update.text)&&(se=jo(P,"datum.label",G.encode.labels.update.text.signal)),Ip(G,"labels","text",{signal:se})}if(null===G.labelAlign&&delete G.labelAlign,G.encode){for(const se of yE)d.hasAxisPart(se)||delete G.encode[se];Gt(G.encode)&&delete G.encode}const ee=function lC(d,p){if(d)return re.isArray(d)&&!ds(d)?d.map(_=>lg(_,p)).join(", "):d}(B,_);return{scale:O,orient:A,grid:!1,...ee?{title:ee}:{},...G,...!1===_.aria?{aria:!1}:{},zindex:ui(q,0)}}}}function Tg(d){const{axes:p}=d.component,_=[];for(const x of Ql)if(p[x])for(const S of p[x])if(!S.get("disable")&&!S.get("gridScale")){const A="x"===x?"height":"width",O=d.getSizeSignalRef(A).signal;A!==O&&_.push({name:A,update:O})}return _}function yx(d,p,_,x){return Object.assign.apply(null,[{},...d.map(S=>{if("axisOrient"===S){const A="x"===_?"bottom":"left",O=p["x"===_?"axisBottom":"axisLeft"]||{},P=p["x"===_?"axisTop":"axisRight"]||{},B=new Set([...We(O),...We(P)]),q={};for(const G of B.values())q[G]={signal:`${x.signal} === "${A}" ? ${ec(O[G])} : ${ec(P[G])}`};return q}return p[S]})])}function uC(d,p){const _=[{}];for(const x of d){let S=p[x]?.style;if(S){S=re.array(S);for(const A of S)_.push(p.style[A])}}return Object.assign.apply(null,_)}function bx(d,p,_){let x=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const S=PM(d,_,p);if(void 0!==S)return{configFrom:"style",configValue:S};for(const A of["vlOnlyAxisConfig","vgAxisConfig","axisConfigStyle"])if(void 0!==x[A]?.[d])return{configFrom:A,configValue:x[A][d]};return{}}const dC={scale:d=>{let{model:p,channel:_}=d;return p.scaleName(_)},format:d=>{let{format:p}=d;return p},formatType:d=>{let{formatType:p}=d;return p},grid:d=>{let{fieldOrDatumDef:p,axis:_,scaleType:x}=d;return _.grid??function pT(d,p){return!ko(d)&&dt(p)&&!sr(p?.bin)&&!oo(p?.bin)}(x,p)},gridScale:d=>{let{model:p,channel:_}=d;return function vx(d,p){const _="x"===p?"y":"x";if(d.getScaleComponent(_))return d.scaleName(_)}(p,_)},labelAlign:d=>{let{axis:p,labelAngle:_,orient:x,channel:S}=d;return p.labelAlign||fC(_,x,S)},labelAngle:d=>{let{labelAngle:p}=d;return p},labelBaseline:d=>{let{axis:p,labelAngle:_,orient:x,channel:S}=d;return p.labelBaseline||wx(_,x,S)},labelFlush:d=>{let{axis:p,fieldOrDatumDef:_,channel:x}=d;return p.labelFlush??function hC(d,p){if("x"===p&&St(["quantitative","temporal"],d))return!0}(_.type,x)},labelOverlap:d=>{let{axis:p,fieldOrDatumDef:_,scaleType:x}=d;return p.labelOverlap??function Ex(d,p,_,x){if(_&&!re.isObject(x)||"nominal"!==d&&"ordinal"!==d)return"log"!==p&&"symlog"!==p||"greedy"}(_.type,x,dt(_)&&!!_.timeUnit,dt(_)?_.sort:void 0)},orient:d=>{let{orient:p}=d;return p},tickCount:d=>{let{channel:p,model:_,axis:x,fieldOrDatumDef:S,scaleType:A}=d;const O="x"===p?"width":"y"===p?"height":void 0,P=O?_.getSizeSignalRef(O):void 0;return x.tickCount??function r3(d){let{fieldOrDatumDef:p,scaleType:_,size:x,values:S}=d;if(!S&&!ko(_)&&"log"!==_){if(dt(p)){if(sr(p.bin))return{signal:`ceil(${x.signal}/10)`};if(p.timeUnit&&St(["month","hours","day","quarter"],Fr(p.timeUnit)?.unit))return}return{signal:`ceil(${x.signal}/40)`}}}({fieldOrDatumDef:S,scaleType:A,size:P,values:x.values})},tickMinStep:function mC(d){let{format:p,fieldOrDatumDef:_}=d;if("d"===p)return 1;if(dt(_)){const{timeUnit:x}=_;if(x){const S=Lf(x);if(S)return{signal:S}}}},title:d=>{let{axis:p,model:_,channel:x}=d;if(void 0!==p.title)return p.title;const S=Op(_,x);if(void 0!==S)return S;const A=_.typedFieldDef(x),P=_.fieldDef("x"===x?"x2":"y2");return $M(A?[aa(A)]:[],dt(P)?[aa(P)]:[])},values:d=>{let{axis:p,fieldOrDatumDef:_}=d;return function mT(d,p){const _=d.values;return re.isArray(_)?gA(p,_):Je(_)?_:void 0}(p,_)},zindex:d=>{let{axis:p,fieldOrDatumDef:_,mark:x}=d;return p.zindex??function ih(d,p){return"rect"===d&&Fv(p)?1:0}(x,_)}};function ob(d){return`(((${d.signal} % 360) + 360) % 360)`}function wx(d,p,_,x){if(void 0!==d){if("x"===_){if(Je(d)){const S=ob(d);return{signal:`(45 < ${S} && ${S} < 135) || (225 < ${S} && ${S} < 315) ? "middle" :(${S} <= 45 || 315 <= ${S}) === ${Je(p)?`(${p.signal} === "top")`:"top"===p} ? "bottom" : "top"`}}return 45{if(sp(x)&&fE(x.sort)){const{field:A,timeUnit:O}=x,P=x.sort,B=P.map((q,G)=>`${Zm({field:A,timeUnit:O,equal:q})} ? ${G} : `).join("")+P.length;p=new Rp(p,{calculate:B,as:Np(x,S,{forAs:!0})})}}),p}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 ${kt(this.transform)}`}}function Np(d,p,_){return pt(d,{prefix:p,suffix:"sort_index",..._??{}})}function sb(d,p){return St(["top","bottom"],p)?"column":St(["left","right"],p)||"row"===d?"row":"column"}function kg(d,p,_,x){return ui((p||{})[d],("row"===x?_.headerRow:"column"===x?_.headerColumn:_.headerFacet)[d],_.header[d])}function Cx(d,p,_,x){const S={};for(const A of d){const O=kg(A,p||{},_,x);void 0!==O&&(S[A]=O)}return S}const gC=["row","column"],Sx=["header","footer"];function hR(d,p){const _=d.component.layoutHeaders[p].title,x=d.config?d.config:void 0,S=d.component.layoutHeaders[p].facetFieldDef?d.component.layoutHeaders[p].facetFieldDef:void 0,{titleAnchor:A,titleAngle:O,titleOrient:P}=Cx(["titleAnchor","titleAngle","titleOrient"],S.header,x,p),B=sb(p,P),q=$i(O);return{name:`${p}-title`,type:"group",role:`${B}-title`,title:{text:_,..."row"===p?{orient:"left"}:{},style:"guide-title",...yC(q,B),..._C(B,q,A),...Mx(x,S,p,xl,Ty)}}}function _C(d,p){switch(arguments.length>2&&void 0!==arguments[2]?arguments[2]:"middle"){case"start":return{align:"left"};case"end":return{align:"right"}}const x=fC(p,"row"===d?"left":"top","row"===d?"y":"x");return x?{align:x}:{}}function yC(d,p){const _=wx(d,"row"===p?"left":"top","row"===p?"y":"x",!0);return _?{baseline:_}:{}}function bC(d,p){const _=d.component.layoutHeaders[p],x=[];for(const S of Sx)if(_[S])for(const A of _[S]){const O=Dx(d,p,S,_,A);null!=O&&x.push(O)}return x}function gT(d,p){const{sort:_}=d;return sa(_)?{field:pt(_,{expr:"datum"}),order:_.order??"ascending"}:re.isArray(_)?{field:Np(d,p,{expr:"datum"}),order:"ascending"}:{field:pt(d,{expr:"datum"}),order:_??"ascending"}}function _T(d,p,_){const{format:x,formatType:S,labelAngle:A,labelAnchor:O,labelOrient:P,labelExpr:B}=Cx(["format","formatType","labelAngle","labelAnchor","labelOrient","labelExpr"],d.header,_,p),q=Hc({fieldOrDatumDef:d,format:x,formatType:S,expr:"parent",config:_}).signal,G=sb(p,P);return{text:{signal:B?jo(jo(B,"datum.label",q),"datum.value",pt(d,{expr:"parent"})):q},..."row"===p?{orient:"left"}:{},style:"guide-label",frame:"group",...yC(A,G),..._C(G,A,O),...Mx(_,d,p,Kf,pp)}}function Dx(d,p,_,x,S){if(S){let A=null;const{facetFieldDef:O}=x,P=d.config?d.config:void 0;if(O&&S.labels){const{labelOrient:ee}=Cx(["labelOrient"],O.header,P,p);("row"===p&&!St(["top","bottom"],ee)||"column"===p&&!St(["left","right"],ee))&&(A=_T(O,p,P))}const B=mc(d)&&!og(d.facet),q=S.axes,G=q?.length>0;if(A||G){const ee="row"===p?"height":"width";return{name:d.getName(`${p}_${_}`),type:"group",role:`${p}-${_}`,...x.facetFieldDef?{from:{data:d.getName(`${p}_domain`)},sort:gT(O,p)}:{},...G&&B?{from:{data:d.getName(`facet_domain_${p}`)}}:{},...A?{title:A}:{},...S.sizeSignal?{encode:{update:{[ee]:S.sizeSignal}}}:{},...G?{axes:q}:{}}}}return null}const nl={column:{start:0,end:1},row:{start:1,end:0}};function ab(d,p){return nl[p][d]}function Mx(d,p,_,x,S){const A={};for(const O of x){if(!S[O])continue;const P=kg(O,p?.header,d,_);void 0!==P&&(A[S[O]]=P)}return A}function cb(d){return[...ub(d,"width"),...ub(d,"height"),...ub(d,"childWidth"),...ub(d,"childHeight")]}function ub(d,p){const _="width"===p?"x":"y",x=d.component.layoutSize.get(p);if(!x||"merged"===x)return[];const S=d.getSizeSignalRef(p).signal;if("step"===x){const A=d.getScaleComponent(_);if(A){const O=A.get("type"),P=A.get("range");if(ko(O)&&ht(P)){const B=d.scaleName(_);return mc(d.parent)&&"independent"===d.parent.component.resolve.scale[_]?[Fp(B,P)]:[Fp(B,P),{name:S,update:vC(B,A,`domain('${B}').length`)}]}}throw new Error("layout size is step although width/height is not step.")}if("container"==x){const A=S.endsWith("width"),O=A?"containerSize()[0]":"containerSize()[1]",B=`isFinite(${O}) ? ${O} : ${Aa(d.config.view,A?"width":"height")}`;return[{name:S,init:B,on:[{update:B,events:"window:resize"}]}]}return[{name:S,value:x}]}function Fp(d,p){const _=`${d}_step`;return Je(p.step)?{name:_,update:p.step.signal}:{name:_,value:p.step}}function vC(d,p,_){const x=p.get("type"),S=p.get("padding"),A=ui(p.get("paddingOuter"),S);let O=p.get("paddingInner");return O="band"===x?void 0!==O?O:S:1,`bandspace(${_}, ${ec(O)}, ${ec(A)}) * ${d}_step`}function yT(d){return"childWidth"===d?"width":"childHeight"===d?"height":d}function Ax(d,p){return We(d).reduce((_,x)=>({..._,...Sp(p,d[x],x,A=>Ar(A.value))}),{})}function o3(d,p){if(mc(p))return"theta"===d?"independent":"shared";if(Hg(p))return"shared";if(Gx(p))return Yr(d)||"theta"===d||"radius"===d?"independent":"shared";throw new Error("invalid model type for resolve")}function Ig(d,p){const _=d.scale[p],x=Yr(p)?"axis":"legend";return"independent"===_?("shared"===d[x][p]&&nt(function X$(d){return`Setting the scale to be independent for "${d}" means we also have to set the guide (axis or legend) to be independent.`}(p)),"independent"):d[x][p]||"shared"}const xC=We({aria:1,clipHeight:1,columnPadding:1,columns:1,cornerRadius:1,description: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,symbolLimit: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,titleLineHeight:1,titleOpacity:1,titleOrient:1,titlePadding:1,type:1,values:1,zindex:1,disable:1,labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1});class Tx extends Za{}const db={symbols:function bT(d,p){let{fieldOrDatumDef:_,model:x,channel:S,legendCmpt:A,legendType:O}=p;if("symbol"!==O)return;const{markDef:P,encoding:B,config:q,mark:G}=x,ee=P.filled&&"trail"!==G;let se={...R2({},x,q2),...QE(x,{filled:ee})};const Ee=A.get("symbolOpacity")??q.legend.symbolOpacity,De=A.get("symbolFillColor")??q.legend.symbolFillColor,Re=A.get("symbolStrokeColor")??q.legend.symbolStrokeColor,Le=void 0===Ee?ue(B.opacity)??P.opacity:void 0;if(se.fill)if("fill"===S||ee&&S===be)delete se.fill;else if(se.fill.field)De?delete se.fill:(se.fill=Ar(q.legend.symbolBaseFillColor??"black"),se.fillOpacity=Ar(Le??1));else if(re.isArray(se.fill)){const Ye=Og(B.fill??B.color)??P.fill??(ee&&P.color);Ye&&(se.fill=Ar(Ye))}if(se.stroke)if("stroke"===S||!ee&&S===be)delete se.stroke;else if(se.stroke.field||Re)delete se.stroke;else if(re.isArray(se.stroke)){const Ye=ui(Og(B.stroke||B.color),P.stroke,ee?P.color:void 0);Ye&&(se.stroke={value:Ye})}if(S!==_e){const Ye=dt(_)&&EC(0,A,_);Ye?se.opacity=[{test:Ye,...Ar(Le??1)},Ar(q.legend.unselectedOpacity)]:Le&&(se.opacity=Ar(Le))}return se={...se,...d},Gt(se)?void 0:se},gradient:function Vn(d,p){let{model:_,legendType:x,legendCmpt:S}=p;if("gradient"!==x)return;const{config:A,markDef:O,encoding:P}=_;let B={};const G=void 0===(S.get("gradientOpacity")??A.legend.gradientOpacity)?ue(P.opacity)||O.opacity:void 0;return G&&(B.opacity=Ar(G)),B={...B,...d},Gt(B)?void 0:B},labels:function Ze(d,p){let{fieldOrDatumDef:_,model:x,channel:S,legendCmpt:A}=p;const O=x.legend(S)||{},P=x.config,B=dt(_)?EC(0,A,_):void 0,q=B?[{test:B,value:1},{value:P.legend.unselectedOpacity}]:void 0,{format:G,formatType:ee}=O;let se;Uc(ee)?se=Ns({fieldOrDatumDef:_,field:"datum.value",format:G,formatType:ee,config:P}):void 0===G&&void 0===ee&&P.customFormatTypes&&("quantitative"===_.type&&P.numberFormatType?se=Ns({fieldOrDatumDef:_,field:"datum.value",format:P.numberFormat,formatType:P.numberFormatType,config:P}):"temporal"===_.type&&P.timeFormatType&&dt(_)&&void 0===_.timeUnit&&(se=Ns({fieldOrDatumDef:_,field:"datum.value",format:P.timeFormat,formatType:P.timeFormatType,config:P})));const Ee={...q?{opacity:q}:{},...se?{text:se}:{},...d};return Gt(Ee)?void 0:Ee},entries:function fb(d,p){let{legendCmpt:_}=p;return _.get("selections")?.length?{...d,fill:{value:"transparent"}}:d}};function ue(d){return wC(d,(p,_)=>Math.max(p,_.value))}function Og(d){return wC(d,(p,_)=>ui(p,_.value))}function wC(d,p){return function bl(d){const p=d?.condition;return!!p&&(re.isArray(p)||Ma(p))}(d)?re.array(d.condition).reduce(p,d.value):Ma(d)?d.value:void 0}function EC(d,p,_){const x=p.get("selections");if(!x?.length)return;const S=re.stringValue(_.field);return x.map(A=>`(!length(data(${re.stringValue(hn(A)+Hd)})) || (${A}[${S}] && indexof(${A}[${S}], datum.value) >= 0))`).join(" || ")}const hb={direction:d=>{let{direction:p}=d;return p},format:d=>{let{fieldOrDatumDef:p,legend:_,config:x}=d;const{format:S,formatType:A}=_;return Hf(p,p.type,S,A,x,!1)},formatType:d=>{let{legend:p,fieldOrDatumDef:_,scaleType:x}=d;const{formatType:S}=p;return gy(S,_,x)},gradientLength:d=>{const{legend:p,legendConfig:_}=d;return p.gradientLength??_.gradientLength??function Ox(d){let{legendConfig:p,model:_,direction:x,orient:S,scaleType:A}=d;const{gradientHorizontalMaxLength:O,gradientHorizontalMinLength:P,gradientVerticalMaxLength:B,gradientVerticalMinLength:q}=p;if(Go(A))return"horizontal"===x?"top"===S||"bottom"===S?Rx(_,"width",P,O):P:Rx(_,"height",q,B)}(d)},labelOverlap:d=>{let{legend:p,legendConfig:_,scaleType:x}=d;return p.labelOverlap??_.labelOverlap??function Nx(d){if(St(["quantile","threshold","log","symlog"],d))return"greedy"}(x)},symbolType:d=>{let{legend:p,markDef:_,channel:x,encoding:S}=d;return p.symbolType??function kx(d,p,_,x){if("shape"!==p){const S=Og(_)??x;if(S)return S}switch(d){case"bar":case"rect":case"image":case"square":return"square";case"line":case"trail":case"rule":return"stroke";case"arc":case"point":case"circle":case"tick":case"geoshape":case"area":case"text":return"circle"}}(_.type,x,S.shape,_.shape)},title:d=>{let{fieldOrDatumDef:p,config:_}=d;return cp(p,_,{allowDisabling:!0})},type:d=>{let{legendType:p,scaleType:_,channel:x}=d;if(Wh(x)&&Go(_)){if("gradient"===p)return}else if("symbol"===p)return;return p},values:d=>{let{fieldOrDatumDef:p,legend:_}=d;return function Rg(d,p){const _=d.values;return re.isArray(_)?gA(p,_):Je(_)?_:void 0}(_,p)}};function Pp(d){const{legend:p}=d;return ui(p.type,function Ix(d){let{channel:p,timeUnit:_,scaleType:x}=d;if(Wh(p)){if(St(["quarter","month","day"],_))return"symbol";if(Go(x))return"gradient"}return"symbol"}(d))}function Ng(d){let{legendConfig:p,legendType:_,orient:x,legend:S}=d;return S.direction??p[_?"gradientDirection":"symbolDirection"]??function Lp(d,p){switch(d){case"top":case"bottom":return"horizontal";case"left":case"right":case"none":case void 0:return;default:return"gradient"===p?"horizontal":void 0}}(x,_)}function Rx(d,p,_,x){return{signal:`clamp(${d.getSizeSignalRef(p).signal}, ${_}, ${x})`}}function vT(d){const p=uo(d)?function CC(d){const{encoding:p}=d,_={};for(const x of[be,...Nd]){const S=Oo(p[x]);!S||!d.getScaleComponent(x)||x===ye&&dt(S)&&S.type===Sa||(_[x]=pR(d,x))}return _}(d):function mR(d){const{legends:p,resolve:_}=d.component;for(const x of d.children){vT(x);for(const S of We(x.component.legends))_.legend[S]=Ig(d.component.resolve,S),"shared"===_.legend[S]&&(p[S]=xT(p[S],x.component.legends[S]),p[S]||(_.legend[S]="independent",delete p[S]))}for(const x of We(p))for(const S of d.children)S.component.legends[x]&&"shared"===_.legend[x]&&delete S.component.legends[x];return p}(d);return d.component.legends=p,p}function SC(d,p,_,x){switch(p){case"disable":return void 0!==_;case"values":return!!_?.values;case"title":if("title"===p&&d===x?.title)return!0}return d===(_||{})[p]}function pR(d,p){let _=d.legend(p);const{markDef:x,encoding:S,config:A}=d,O=A.legend,P=new Tx({},function $p(d,p){const _=d.scaleName(p);if("trail"===d.mark){if("color"===p)return{stroke:_};if("size"===p)return{strokeWidth:_}}return"color"===p?d.markDef.filled?{fill:_}:{stroke:_}:{[p]:_}}(d,p));!function Mg(d,p,_){const x=d.fieldDef(p)?.field;for(const S of Dn(d.component.selection??{})){const A=S.project.hasField[x]??S.project.hasChannel[p];if(A&&cT.defined(S)){const O=_.get("selections")??[];O.push(S.name),_.set("selections",O,!1),A.hasLegend=!0}}}(d,p,P);const B=void 0!==_?!_:O.disable;if(P.set("disable",B,void 0!==_),B)return P;_=_||{};const q=d.getScaleComponent(p).get("type"),G=Oo(S[p]),ee=dt(G)?Fr(G.timeUnit)?.unit:void 0,se=_.orient||A.legend.orient||"right",Ee=Pp({legend:_,channel:p,timeUnit:ee,scaleType:q}),Re={legend:_,channel:p,model:d,markDef:x,encoding:S,fieldOrDatumDef:G,legendConfig:O,config:A,scaleType:q,orient:se,legendType:Ee,direction:Ng({legend:_,legendType:Ee,orient:se,legendConfig:O})};for(const dn of xC){if("gradient"===Ee&&dn.startsWith("symbol")||"symbol"===Ee&&dn.startsWith("gradient"))continue;const vi=dn in hb?hb[dn](Re):_[dn];if(void 0!==vi){const lr=SC(vi,dn,_,d.fieldDef(p));(lr||void 0===A.legend[dn])&&P.set(dn,vi,lr)}}const Le=_?.encoding??{},Ye=P.get("selections"),bt={},kn={fieldOrDatumDef:G,model:d,channel:p,legendCmpt:P,legendType:Ee};for(const dn of["labels","legend","title","symbols","gradient","entries"]){const vi=Ax(Le[dn]??{},d),lr=dn in db?db[dn](vi,kn):vi;void 0!==lr&&!Gt(lr)&&(bt[dn]={...Ye?.length&&dt(G)?{name:`${hn(G.field)}_legend_${dn}`}:{},...Ye?.length?{interactive:!!Ye}:{},update:lr})}return Gt(bt)||P.set("encode",bt,!!_?.encoding),P}function xT(d,p){if(!d)return p.clone();const _=d.getWithExplicit("orient"),x=p.getWithExplicit("orient");if(_.explicit&&x.explicit&&_.value!==x.value)return;let S=!1;for(const A of xC){const O=Qa(d.getWithExplicit(A),p.getWithExplicit(A),A,"legend",(P,B)=>{switch(A){case"symbolType":return DC(P,B);case"title":return BM(P,B);case"type":return S=!0,co("symbol")}return Pu(P,B,A,"legend")});d.setWithExplicit(A,O)}return S&&(d.implicit?.encode?.gradient&&xn(d.implicit,["encode","gradient"]),d.explicit?.encode?.gradient&&xn(d.explicit,["encode","gradient"])),d}function DC(d,p){return"circle"===p.value?p:d}function rh(d){const p=d.component.legends,_={};for(const S of We(p)){const O=Wn(d.getScaleComponent(S).get("domains"));if(_[O])for(const P of _[O])xT(P,p[S])||_[O].push(p[S]);else _[O]=[p[S].clone()]}return Dn(_).flat().map(S=>function qd(d,p){const{disable:_,labelExpr:x,selections:S,...A}=d.combine();if(!_){if(!1===p.aria&&null==A.aria&&(A.aria=!1),A.encode?.symbols){const O=A.encode.symbols.update;O.fill&&"transparent"!==O.fill.value&&!O.stroke&&!A.stroke&&(O.stroke={value:"transparent"});for(const P of Nd)A[P]&&delete O[P]}if(A.title||delete A.title,void 0!==x){let O=x;A.encode?.labels?.update&&Je(A.encode.labels.update.text)&&(O=jo(x,"datum.label",A.encode.labels.update.text.signal)),function wT(d,p,_,x){d.encode??={},d.encode[p]??={},d.encode[p].update??={},d.encode[p].update[_]=x}(A,"labels","text",{signal:O})}return A}}(S,d.config)).filter(S=>void 0!==S)}function pb(d){return Hg(d)||Gx(d)?function zs(d){return d.children.reduce((p,_)=>p.concat(_.assembleProjections()),mb(d))}(d):mb(d)}function mb(d){const p=d.component.projection;if(!p||p.merged)return[];const _=p.combine(),{name:x}=_;if(p.data){const S={signal:`[${p.size.map(O=>O.signal).join(", ")}]`},A=p.data.reduce((O,P)=>{const B=Je(P)?P.signal:`data('${d.lookupDataSource(P)}')`;return St(O,B)||O.push(B),O},[]);if(A.length<=0)throw new Error("Projection's fit didn't find any data sources");return[{name:x,size:S,fit:{signal:A.length>1?`[${A.join(", ")}]`:A[0]},..._}]}return[{name:x,translate:{signal:"[width / 2, height / 2]"},..._}]}const Bp=["type","clipAngle","clipExtent","center","rotate","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];class zp extends Za{constructor(p,_,x,S){super({..._},{name:p}),this.specifiedProjection=_,this.size=x,this.data=S,ln(this,"merged",!1)}get isFit(){return!!this.data}}function Sl(d){d.component.projection=uo(d)?function Vp(d){if(d.hasProjection){const p=_o(d.specifiedProjection),_=!(p&&(null!=p.scale||null!=p.translate)),x=_?[d.getSizeSignalRef("width"),d.getSizeSignalRef("height")]:void 0,S=_?function Fg(d){const p=[],{encoding:_}=d;for(const x of[[Ho,It],[ae,wr]])(Oo(_[x[0]])||Oo(_[x[1]]))&&p.push({signal:d.getName(`geojson_${p.length}`)});return d.channelHasField(ye)&&d.typedFieldDef(ye).type===Sa&&p.push({signal:d.getName(`geojson_${p.length}`)}),0===p.length&&p.push(d.requestDataName(Vr.Main)),p}(d):void 0,A=new zp(d.projectionName(!0),{..._o(d.config.projection)??{},...p??{}},x,S);return A.get("type")||A.set("type","equalEarth",!1),A}}(d):function Px(d){if(0===d.children.length)return;let p;for(const x of d.children)Sl(x);const _=Ot(d.children,x=>{const S=x.component.projection;if(S){if(p){const A=function Fx(d,p){const _=Ot(Bp,S=>!!(!re.hasOwnProperty(d.explicit,S)&&!re.hasOwnProperty(p.explicit,S)||re.hasOwnProperty(d.explicit,S)&&re.hasOwnProperty(p.explicit,S)&&xr(d.get(S),p.get(S))));if(xr(d.size,p.size)){if(_)return d;if(xr(d.explicit,{}))return p;if(xr(p.explicit,{}))return d}return null}(p,S);return A&&(p=A),!!A}return p=S,!0}return!0});if(p&&_){const x=d.projectionName(!0),S=new zp(x,p.specifiedProjection,p.size,st(p.data));for(const A of d.children){const O=A.component.projection;O&&(O.isFit&&S.data.push(...A.component.projection.data),A.renameProjection(O.get("name"),x),O.merged=!0)}return S}}(d)}function Lx(d,p,_,x){if(kd(p,_)){const S=uo(d)?d.axis(_)??d.legend(_)??{}:{},A=pt(p,{expr:"datum"}),O=pt(p,{expr:"datum",binSuffix:"end"});return{formulaAs:pt(p,{binSuffix:"range",forAs:!0}),formula:ng(A,O,S.format,S.formatType,x)}}return{}}function $x(d,p){return`${Z_(d)}_${p}`}function jp(d,p,_){const S=$x(Ad(_,void 0)??{},p);return d.getName(`${S}_bins`)}function Pg(d,p,_){let x,S;x=function Zo(d){return"as"in d}(d)?re.isString(d.as)?[d.as,`${d.as}_end`]:[d.as[0],d.as[1]]:[pt(d,{forAs:!0}),pt(d,{binSuffix:"end",forAs:!0})];const A={...Ad(p,void 0)},O=$x(A,d.field),{signal:P,extentSignal:B}=function ET(d,p){return{signal:d.getName(`${p}_bins`),extentSignal:d.getName(`${p}_extent`)}}(_,O);if(Q_(A.extent)){const G=A.extent;S=sC(_,G.param,G),delete A.extent}return{key:O,binComponent:{bin:A,field:d.field,as:[x],...P?{signal:P}:{},...B?{extentSignal:B}:{},...S?{span:S}:{}}}}class il extends Tn{clone(){return new il(null,st(this.bins))}constructor(p,_){super(p),this.bins=_}static makeFromEncoding(p,_){const x=_.reduceFieldDef((S,A,O)=>{if(Yo(A)&&sr(A.bin)){const{key:P,binComponent:B}=Pg(A,A.bin,_);S[P]={...B,...S[P],...Lx(_,A,O,_.config)}}return S},{});return Gt(x)?null:new il(p,x)}static makeFromTransform(p,_,x){const{key:S,binComponent:A}=Pg(_,_.bin,x);return new il(p,{[S]:A})}merge(p,_){for(const x of We(p.bins))x in this.bins?(_(p.bins[x].signal,this.bins[x].signal),this.bins[x].as=Ci([...this.bins[x].as,...p.bins[x].as],kt)):this.bins[x]=p.bins[x];for(const x of p.children)p.removeChild(x),x.parent=this;p.remove()}producedFields(){return new Set(Dn(this.bins).map(p=>p.as).flat(2))}dependentFields(){return new Set(Dn(this.bins).map(p=>p.field))}hash(){return`Bin ${kt(this.bins)}`}assemble(){return Dn(this.bins).flatMap(p=>{const _=[],[x,...S]=p.as,{extent:A,...O}=p.bin,P={type:"bin",field:ci(p.field),as:x,signal:p.signal,...Q_(A)?{extent:null}:{extent:A},...p.span?{span:{signal:`span(${p.span})`}}:{},...O};!A&&p.extentSignal&&(_.push({type:"extent",field:ci(p.field),signal:p.extentSignal}),P.extent={signal:p.extentSignal}),_.push(P);for(const B of S)for(let q=0;q<2;q++)_.push({type:"formula",expr:pt({field:x[q]},{expr:"datum"}),as:B[q]});return p.formula&&_.push({type:"formula",expr:p.formula,as:p.formulaAs}),_})}}function fc(d,p,_,x){const S=uo(x)?x.encoding[Or(p)]:void 0;if(Yo(_)&&uo(x)&&vy(_,S,x.markDef,x.config)){d.add(pt(_,{})),d.add(pt(_,{suffix:"end"}));const{mark:A,markDef:O,config:P}=x,B=Tu({fieldDef:_,markDef:O,config:P});ip(A)&&.5!==B&&Yr(p)&&(d.add(pt(_,{suffix:Xc})),d.add(pt(_,{suffix:Vd}))),_.bin&&kd(_,p)&&d.add(pt(_,{binSuffix:"range"}))}else if(za(p)){const A=Mn(p);d.add(x.getName(A))}else d.add(pt(_));return sp(_)&&function Er(d){return re.isObject(d)&&"field"in d}(_.scale?.range)&&d.add(_.scale.range.field),d}class No extends Tn{clone(){return new No(null,new Set(this.dimensions),st(this.measures))}constructor(p,_,x){super(p),this.dimensions=_,this.measures=x}get groupBy(){return this.dimensions}static makeFromEncoding(p,_){let x=!1;_.forEachFieldDef(O=>{O.aggregate&&(x=!0)});const S={},A=new Set;return x&&(_.forEachFieldDef((O,P)=>{const{aggregate:B,field:q}=O;if(B)if("count"===B)S["*"]??={},S["*"].count=new Set([pt(O,{forAs:!0})]);else{if(bu(B)||Ua(B)){const G=bu(B)?"argmin":"argmax",ee=B[G];S[ee]??={},S[ee][G]=new Set([pt({op:G,field:ee},{forAs:!0})])}else S[q]??={},S[q][B]=new Set([pt(O,{forAs:!0})]);pd(P)&&"unaggregated"===_.scaleDomain(P)&&(S[q]??={},S[q].min=new Set([pt({field:q,aggregate:"min"},{forAs:!0})]),S[q].max=new Set([pt({field:q,aggregate:"max"},{forAs:!0})]))}else fc(A,P,O,_)}),A.size+We(S).length!==0)?new No(p,A,S):null}static makeFromTransform(p,_){const x=new Set,S={};for(const A of _.aggregate){const{op:O,field:P,as:B}=A;O&&("count"===O?(S["*"]??={},S["*"].count=new Set([B||pt(A,{forAs:!0})])):(S[P]??={},S[P][O]=new Set([B||pt(A,{forAs:!0})])))}for(const A of _.groupby??[])x.add(A);return x.size+We(S).length===0?null:new No(p,x,S)}merge(p){return no(this.dimensions,p.dimensions)?(function MC(d,p){for(const _ of We(p)){const x=p[_];for(const S of We(x))_ in d?d[_][S]=new Set([...d[_][S]??[],...x[S]]):d[_]={[S]:x[S]}}}(this.measures,p.measures),!0):(function U1(){Xm.debug(...arguments)}("different dimensions, cannot merge"),!1)}addDimensions(p){p.forEach(this.dimensions.add,this.dimensions)}dependentFields(){return new Set([...this.dimensions,...We(this.measures)])}producedFields(){const p=new Set;for(const _ of We(this.measures))for(const x of We(this.measures[_])){const S=this.measures[_][x];0===S.size?p.add(`${x}_${_}`):S.forEach(p.add,p)}return p}hash(){return`Aggregate ${kt({dimensions:this.dimensions,measures:this.measures})}`}assemble(){const p=[],_=[],x=[];for(const A of We(this.measures))for(const O of We(this.measures[A]))for(const P of this.measures[A][O])x.push(P),p.push(O),_.push("*"===A?null:ci(A));return{type:"aggregate",groupby:[...this.dimensions].map(ci),ops:p,fields:_,as:x}}}class oh extends Tn{constructor(p,_,x,S){super(p),this.model=_,this.name=x,this.data=S,ln(this,"column",void 0),ln(this,"row",void 0),ln(this,"facet",void 0),ln(this,"childModel",void 0);for(const A of Zl){const O=_.facet[A];if(O){const{bin:P,sort:B}=O;this[A]={name:_.getName(`${A}_domain`),fields:[pt(O),...sr(P)?[pt(O,{binSuffix:"end"})]:[]],...sa(B)?{sortField:B}:re.isArray(B)?{sortIndexField:Np(O,A)}:{}}}}this.childModel=_.child}hash(){let p="Facet";for(const _ of Zl)this[_]&&(p+=` ${_.charAt(0)}:${kt(this[_])}`);return p}get fields(){const p=[];for(const _ of Zl)this[_]?.fields&&p.push(...this[_].fields);return p}dependentFields(){const p=new Set(this.fields);for(const _ of Zl)this[_]&&(this[_].sortField&&p.add(this[_].sortField.field),this[_].sortIndexField&&p.add(this[_].sortIndexField));return p}producedFields(){return new Set}getSource(){return this.name}getChildIndependentFieldsWithStep(){const p={};for(const _ of Ql){const x=this.childModel.component.scales[_];if(x&&!x.merged){const S=x.get("type"),A=x.get("range");if(ko(S)&&ht(A)){const P=NC(Wp(this.childModel,_));P?p[_]=P:nt(Tr(_))}}}return p}assembleRowColumnHeaderData(p,_,x){const S={row:"y",column:"x",facet:void 0}[p],A=[],O=[],P=[];S&&x&&x[S]&&(_?(A.push(`distinct_${x[S]}`),O.push("max")):(A.push(x[S]),O.push("distinct")),P.push(`distinct_${x[S]}`));const{sortField:B,sortIndexField:q}=this[p];if(B){const{op:G=ig,field:ee}=B;A.push(ee),O.push(G),P.push(pt(B,{forAs:!0}))}else q&&(A.push(q),O.push("max"),P.push(q));return{name:this[p].name,source:_??this.data,transform:[{type:"aggregate",groupby:this[p].fields,...A.length?{fields:A,ops:O,as:P}:{}}]}}assembleFacetHeaderData(p){const{columns:_}=this.model.layout,{layoutHeaders:x}=this.model.component,S=[],A={};for(const B of gC){for(const q of Sx){const G=(x[B]&&x[B][q])??[];for(const ee of G)if(ee.axes?.length>0){A[B]=!0;break}}if(A[B]){const q=`length(data("${this.facet.name}"))`;S.push({name:`${this.facet.name}_${B}`,transform:[{type:"sequence",start:0,stop:"row"===B?_?{signal:`ceil(${q} / ${_})`}:1:_?{signal:`min(${q}, ${_})`}:{signal:q}}]})}}const{row:O,column:P}=A;return(O||P)&&S.unshift(this.assembleRowColumnHeaderData("facet",null,p)),S}assemble(){const p=[];let _=null;const x=this.getChildIndependentFieldsWithStep(),{column:S,row:A,facet:O}=this;if(S&&A&&(x.x||x.y)){_=`cross_${this.column.name}_${this.row.name}`;const P=[].concat(x.x??[],x.y??[]),B=P.map(()=>"distinct");p.push({name:_,source:this.data,transform:[{type:"aggregate",groupby:this.fields,fields:P,ops:B}]})}for(const P of[Xl,ea])this[P]&&p.push(this.assembleRowColumnHeaderData(P,_,x));if(O){const P=this.assembleFacetHeaderData(x);P&&p.push(...P)}return p}}function Bx(d){return d.startsWith("'")&&d.endsWith("'")||d.startsWith('"')&&d.endsWith('"')?d.slice(1,-1):d}function ST(d){const p={};return ot(d.filter,_=>{if(so(_)){let x=null;G1(_)?x=Ha(_.equal):Y1(_)?x=Ha(_.lte):X1(_)?x=Ha(_.lt):ar(_)?x=Ha(_.gt):xv(_)?x=Ha(_.gte):qe(_)?x=_.range[0]:bi(_)&&(x=(_.oneOf??_.in)[0]),x&&(_d(x)?p[_.field]="date":re.isNumber(x)?p[_.field]="number":re.isString(x)&&(p[_.field]="string")),_.timeUnit&&(p[_.field]="date")}}),p}function DT(d){const p={};function _(x){up(x)?p[x.field]="date":"quantitative"===x.type&&function pe(d){return re.isString(d)&&St(["min","max"],d)}(x.aggregate)?p[x.field]="number":ro(x.field)>1?x.field in p||(p[x.field]="flatten"):sp(x)&&sa(x.sort)&&ro(x.sort.field)>1&&(x.sort.field in p||(p[x.sort.field]="flatten"))}if((uo(d)||mc(d))&&d.forEachFieldDef((x,S)=>{if(Yo(x))_(x);else{const A=Fc(S),O=d.fieldDef(A);_({...x,type:O.type})}}),uo(d)){const{mark:x,markDef:S,encoding:A}=d;if(yl(x)&&!d.encoding.order){const P=A["horizontal"===S.orient?"y":"x"];dt(P)&&"quantitative"===P.type&&!(P.field in p)&&(p[P.field]="number")}}return p}class ys extends Tn{clone(){return new ys(null,st(this._parse))}constructor(p,_){super(p),ln(this,"_parse",void 0),this._parse=_}hash(){return`Parse ${kt(this._parse)}`}static makeExplicit(p,_,x){let S={};const A=_.data;return!Jf(A)&&A?.format?.parse&&(S=A.format.parse),this.makeWithAncestors(p,S,{},x)}static makeWithAncestors(p,_,x,S){for(const P of We(x)){const B=S.getWithExplicit(P);void 0!==B.value&&(B.explicit||B.value===x[P]||"derived"===B.value||"flatten"===x[P]?delete x[P]:nt(Wm(P,x[P],B.value)))}for(const P of We(_)){const B=S.get(P);void 0!==B&&(B===_[P]?delete _[P]:nt(Wm(P,_[P],B)))}const A=new Za(_,x);S.copyAll(A);const O={};for(const P of We(A.combine())){const B=A.get(P);null!==B&&(O[P]=B)}return 0===We(O).length||S.parseNothing?null:new ys(p,O)}get parse(){return this._parse}merge(p){this._parse={...this._parse,...p.parse},p.remove()}assembleFormatParse(){const p={};for(const _ of We(this._parse)){const x=this._parse[_];1===ro(_)&&(p[_]=x)}return p}producedFields(){return new Set(We(this._parse))}dependentFields(){return new Set(We(this._parse))}assembleTransforms(){let p=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return We(this._parse).filter(_=>!p||ro(_)>1).map(_=>{const x=function CT(d,p){const _=Js(d);return"number"===p?`toNumber(${_})`:"boolean"===p?`toBoolean(${_})`:"string"===p?`toString(${_})`:"date"===p?`toDate(${_})`:"flatten"===p?_:p.startsWith("date:")?`timeParse(${_},'${Bx(p.slice(5,p.length))}')`:p.startsWith("utc:")?`utcParse(${_},'${Bx(p.slice(4,p.length))}')`:(nt(function Kr(d){return`Unrecognized parse "${d}".`}(p)),null)}(_,this._parse[_]);return x?{type:"formula",expr:x,as:Si(_)}:null}).filter(_=>null!==_)}}class sh extends Tn{clone(){return new sh(null)}constructor(p){super(p)}dependentFields(){return new Set}producedFields(){return new Set([Ya])}hash(){return"Identifier"}assemble(){return{type:"identifier",as:Ya}}}class Gd extends Tn{clone(){return new Gd(null,this.params)}constructor(p,_){super(p),this.params=_}dependentFields(){return new Set}producedFields(){}hash(){return`Graticule ${kt(this.params)}`}assemble(){return{type:"graticule",...!0===this.params?{}:this.params}}}class Up extends Tn{clone(){return new Up(null,this.params)}constructor(p,_){super(p),this.params=_}dependentFields(){return new Set}producedFields(){return new Set([this.params.as??"data"])}hash(){return`Hash ${kt(this.params)}`}assemble(){return{type:"sequence",...this.params}}}class Xd extends Tn{constructor(p){let _;if(super(null),ln(this,"_data",void 0),ln(this,"_name",void 0),ln(this,"_generator",void 0),p??={name:"source"},Jf(p)||(_=p.format?{...yt(p.format,["parse"])}:{}),Wy(p))this._data={values:p.values};else if(ka(p)){if(this._data={url:p.url},!_.type){let x=/(?:\.([^.]+))?$/.exec(p.url)[1];St(["json","csv","tsv","dsv","topojson"],x)||(x="json"),_.type=x}}else Ja(p)?this._data={values:[{type:"Sphere"}]}:(ZA(p)||Jf(p))&&(this._data={});this._generator=Jf(p),p.name&&(this._name=p.name),_&&!Gt(_)&&(this._data.format=_)}dependentFields(){return new Set}producedFields(){}get data(){return this._data}hasName(){return!!this._name}get isGenerator(){return this._generator}get dataName(){return this._name}set dataName(p){this._name=p}set parent(p){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{name:this._name,...this._data,transform:[]}}}function Lg(d){return d instanceof Xd||d instanceof Gd||d instanceof Up}var $g=new WeakMap;class Yn{constructor(){ia(this,$g,{writable:!0,value:void 0}),fs(this,$g,!1)}setModified(){fs(this,$g,!0)}get modifiedFlag(){return function Vt(d,p){return function Wo(d,p){return p.get?p.get.call(d):p.value}(d,Jn(d,p,"get"))}(this,$g)}}class ah extends Yn{getNodeDepths(p,_,x){x.set(p,_);for(const S of p.children)this.getNodeDepths(S,_+1,x);return x}optimize(p){const x=[...this.getNodeDepths(p,0,new Map).entries()].sort((S,A)=>A[1]-S[1]);for(const S of x)this.run(S[0]);return this.modifiedFlag}}class Kc extends Yn{optimize(p){this.run(p);for(const _ of p.children)this.optimize(_);return this.modifiedFlag}}class AC extends Kc{mergeNodes(p,_){const x=_.shift();for(const S of _)p.removeChild(S),S.parent=x,S.remove()}run(p){const _=p.children.map(S=>S.hash()),x={};for(let S=0;S<_.length;S++)void 0===x[_[S]]?x[_[S]]=[p.children[S]]:x[_[S]].push(p.children[S]);for(const S of We(x))x[S].length>1&&(this.setModified(),this.mergeNodes(p,x[S]))}}class gb extends Kc{constructor(p){super(),ln(this,"requiresSelectionId",void 0),this.requiresSelectionId=p&&nh(p)}run(p){p instanceof sh&&(this.requiresSelectionId&&(Lg(p.parent)||p.parent instanceof No||p.parent instanceof ys)||(this.setModified(),p.remove()))}}class TC extends Yn{optimize(p){return this.run(p,new Set),this.modifiedFlag}run(p,_){let x=new Set;p instanceof el&&(x=p.producedFields(),Qi(x,_)&&(this.setModified(),p.removeFormulas(_),0===p.producedFields.length&&p.remove()));for(const S of p.children)this.run(S,new Set([..._,...x]))}}class MT extends Kc{constructor(){super()}run(p){p instanceof jr&&!p.isRequired()&&(this.setModified(),p.remove())}}class AT extends ah{run(p){if(!(Lg(p)||p.numChildren()>1))for(const _ of p.children)if(_ instanceof ys)if(p instanceof ys)this.setModified(),p.merge(_);else{if(Oi(p.producedFields(),_.dependentFields()))continue;this.setModified(),_.swapWithParent()}}}class TT extends ah{run(p){const _=[...p.children],x=p.children.filter(S=>S instanceof ys);if(p.numChildren()>1&&x.length>=1){const S={},A=new Set;for(const O of x){const P=O.parse;for(const B of We(P))B in S?S[B]!==P[B]&&A.add(B):S[B]=P[B]}for(const O of A)delete S[O];if(!Gt(S)){this.setModified();const O=new ys(p,S);for(const P of _){if(P instanceof ys)for(const B of We(S))delete P.parse[B];p.removeChild(P),P.parent=O,P instanceof ys&&0===We(P.parse).length&&P.remove()}}}}}class kT extends ah{run(p){p instanceof jr||p.numChildren()>0||p instanceof oh||p instanceof Xd||(this.setModified(),p.remove())}}class IT extends ah{run(p){const _=p.children.filter(S=>S instanceof el),x=_.pop();for(const S of _)this.setModified(),x.merge(S)}}class Vx extends ah{run(p){const _=p.children.filter(S=>S instanceof No),x={};for(const S of _){const A=kt(S.groupBy);A in x||(x[A]=[]),x[A].push(S)}for(const S of We(x)){const A=x[S];if(A.length>1){const O=A.pop();for(const P of A)O.merge(P)&&(p.removeChild(P),P.parent=O,P.remove(),this.setModified())}}}}class _b extends ah{constructor(p){super(),this.model=p}run(p){const _=!(Lg(p)||p instanceof Cl||p instanceof ys||p instanceof sh),x=[],S=[];for(const A of p.children)A instanceof il&&(_&&!Oi(p.producedFields(),A.dependentFields())?x.push(A):S.push(A));if(x.length>0){const A=x.pop();for(const O of x)A.merge(O,this.model.renameSignal.bind(this.model));this.setModified(),p instanceof il?p.merge(A,this.model.renameSignal.bind(this.model)):A.swapWithParent()}if(S.length>1){const A=S.pop();for(const O of S)A.merge(O,this.model.renameSignal.bind(this.model));this.setModified()}}}class Bg extends ah{run(p){const _=[...p.children];if(!li(_,O=>O instanceof jr)||p.numChildren()<=1)return;const S=[];let A;for(const O of _)if(O instanceof jr){let P=O;for(;1===P.numChildren();){const[B]=P.children;if(!(B instanceof jr))break;P=B}S.push(...P.children),A?(p.removeChild(O),O.parent=A.parent,A.parent.removeChild(A),A.parent=P,this.setModified()):A=P}else S.push(O);if(S.length){this.setModified();for(const O of S)O.parent.removeChild(O),O.parent=A}}}class zu extends Tn{clone(){return new zu(null,st(this.transform))}constructor(p,_){super(p),this.transform=_}addDimensions(p){this.transform.groupby=Ci(this.transform.groupby.concat(p),_=>_)}dependentFields(){const p=new Set;return this.transform.groupby&&this.transform.groupby.forEach(p.add,p),this.transform.joinaggregate.map(_=>_.field).filter(_=>void 0!==_).forEach(p.add,p),p}producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName))}getDefaultName(p){return p.as??pt(p)}hash(){return`JoinAggregateTransform ${kt(this.transform)}`}assemble(){const p=[],_=[],x=[];for(const A of this.transform.joinaggregate)_.push(A.op),x.push(this.getDefaultName(A)),p.push(void 0===A.field?null:A.field);const S=this.transform.groupby;return{type:"joinaggregate",as:x,ops:_,fields:p,...void 0!==S?{groupby:S}:{}}}}class Yd extends Tn{clone(){return new Yd(null,st(this._stack))}constructor(p,_){super(p),ln(this,"_stack",void 0),this._stack=_}static makeFromTransform(p,_){const{stack:x,groupby:S,as:A,offset:O="zero"}=_,P=[],B=[];if(void 0!==_.sort)for(const ee of _.sort)P.push(ee.field),B.push(ui(ee.order,"ascending"));const q={field:P,order:B};let G;return G=function kC(d){return re.isArray(d)&&d.every(p=>re.isString(p))&&d.length>1}(A)?A:re.isString(A)?[A,`${A}_end`]:[`${_.stack}_start`,`${_.stack}_end`],new Yd(p,{dimensionFieldDefs:[],stackField:x,groupby:S,offset:O,sort:q,facetby:[],as:G})}static makeFromEncoding(p,_){const x=_.stack,{encoding:S}=_;if(!x)return null;const{groupbyChannels:A,fieldChannel:O,offset:P,impute:B}=x,q=A.map(Ee=>ku(S[Ee])).filter(Ee=>!!Ee),G=function Qo(d){return d.stack.stackBy.reduce((p,_)=>{const S=pt(_.fieldDef);return S&&p.push(S),p},[])}(_),ee=_.encoding.order;let se;if(re.isArray(ee)||dt(ee))se=LM(ee);else{const Ee=Rv(ee)?ee.sort:"y"===O?"descending":"ascending";se=G.reduce((De,Re)=>(De.field.push(Re),De.order.push(Ee),De),{field:[],order:[]})}return new Yd(p,{dimensionFieldDefs:q,stackField:_.vgField(O),facetby:[],stackby:G,sort:se,offset:P,impute:B,as:[_.vgField(O,{suffix:"start",forAs:!0}),_.vgField(O,{suffix:"end",forAs:!0})]})}get stack(){return this._stack}addDimensions(p){this._stack.facetby.push(...p)}dependentFields(){const p=new Set;return p.add(this._stack.stackField),this.getGroupbyFields().forEach(p.add,p),this._stack.facetby.forEach(p.add,p),this._stack.sort.field.forEach(p.add,p),p}producedFields(){return new Set(this._stack.as)}hash(){return`Stack ${kt(this._stack)}`}getGroupbyFields(){const{dimensionFieldDefs:p,impute:_,groupby:x}=this._stack;return p.length>0?p.map(S=>S.bin?_?[pt(S,{binSuffix:"mid"})]:[pt(S,{}),pt(S,{binSuffix:"end"})]:[pt(S)]).flat():x??[]}assemble(){const p=[],{facetby:_,dimensionFieldDefs:x,stackField:S,stackby:A,sort:O,offset:P,impute:B,as:q}=this._stack;if(B)for(const G of x){const{bandPosition:ee=.5,bin:se}=G;if(se){const Ee=pt(G,{expr:"datum"}),De=pt(G,{expr:"datum",binSuffix:"end"});p.push({type:"formula",expr:`${ee}*${Ee}+${1-ee}*${De}`,as:pt(G,{binSuffix:"mid",forAs:!0})})}p.push({type:"impute",field:S,groupby:[...A,..._],key:pt(G,{binSuffix:"mid"}),method:"value",value:0})}return p.push({type:"stack",groupby:[...this.getGroupbyFields(),..._],field:S,sort:O,as:q,offset:P}),p}}class zg extends Tn{clone(){return new zg(null,st(this.transform))}constructor(p,_){super(p),this.transform=_}addDimensions(p){this.transform.groupby=Ci(this.transform.groupby.concat(p),_=>_)}dependentFields(){const p=new Set;return(this.transform.groupby??[]).forEach(p.add,p),(this.transform.sort??[]).forEach(_=>p.add(_.field)),this.transform.window.map(_=>_.field).filter(_=>void 0!==_).forEach(p.add,p),p}producedFields(){return new Set(this.transform.window.map(this.getDefaultName))}getDefaultName(p){return p.as??pt(p)}hash(){return`WindowTransform ${kt(this.transform)}`}assemble(){const p=[],_=[],x=[],S=[];for(const ee of this.transform.window)_.push(ee.op),x.push(this.getDefaultName(ee)),S.push(void 0===ee.param?null:ee.param),p.push(void 0===ee.field?null:ee.field);const A=this.transform.frame,O=this.transform.groupby;if(A&&null===A[0]&&null===A[1]&&_.every(ee=>K_(ee)))return{type:"joinaggregate",as:x,ops:_,fields:p,...void 0!==O?{groupby:O}:{}};const P=[],B=[];if(void 0!==this.transform.sort)for(const ee of this.transform.sort)P.push(ee.field),B.push(ee.order??"ascending");const G=this.transform.ignorePeers;return{type:"window",params:S,as:x,ops:_,fields:p,sort:{field:P,order:B},...void 0!==G?{ignorePeers:G}:{},...void 0!==O?{groupby:O}:{},...void 0!==A?{frame:A}:{}}}}function IC(d){if(d instanceof oh)if(1!==d.numChildren()||d.children[0]instanceof jr){const p=d.model.component.data.main;OT(p);const _=function gR(d){return function p(_){if(!(_ instanceof oh)){const x=_.clone();if(x instanceof jr){const S=Hp+x.getSource();x.setSource(S),d.model.component.data.outputNodes[S]=x}else(x instanceof No||x instanceof Yd||x instanceof zg||x instanceof zu)&&x.addDimensions(d.fields);for(const S of _.children.flatMap(p))S.parent=x;return[x]}return _.children.flatMap(p)}}(d),x=d.children.map(_).flat();for(const S of x)S.parent=p}else{const p=d.children[0];(p instanceof No||p instanceof Yd||p instanceof zg||p instanceof zu)&&p.addDimensions(d.fields),p.swapWithParent(),IC(d)}else d.children.map(IC)}function OT(d){if(d instanceof jr&&d.type===Vr.Main&&1===d.numChildren()){const p=d.children[0];p instanceof oh||(p.swapWithParent(),OT(d))}}const Hp="scale_",Vg=5;function jg(d){for(const p of d){for(const _ of p.children)if(_.parent!==p)return!1;if(!jg(p.children))return!1}return!0}function Vu(d,p){let _=!1;for(const x of p)_=d.optimize(x)||_;return _}function RT(d,p,_){let x=d.sources,S=!1;return S=Vu(new MT,x)||S,S=Vu(new gb(p),x)||S,x=x.filter(A=>A.numChildren()>0),S=Vu(new kT,x)||S,x=x.filter(A=>A.numChildren()>0),_||(S=Vu(new AT,x)||S,S=Vu(new _b(p),x)||S,S=Vu(new TC,x)||S,S=Vu(new TT,x)||S,S=Vu(new Vx,x)||S,S=Vu(new IT,x)||S,S=Vu(new AC,x)||S,S=Vu(new Bg,x)||S),d.sources=x,S}class bs{constructor(p){ln(this,"signal",void 0),Object.defineProperty(this,"signal",{enumerable:!0,get:p})}static fromName(p,_){return new bs(()=>p(_))}}function NT(d){uo(d)?function OC(d){const p=d.component.scales;for(const _ of We(p)){const x=FT(d,_);if(p[_].setWithExplicit("domains",x),s3(d,_),d.component.data.isFaceted){let A=d;for(;!mc(A)&&A.parent;)A=A.parent;if("shared"===A.component.resolve.scale[_])for(const P of x.value)vu(P)&&(P.data=Hp+P.data.replace(Hp,""))}}}(d):function RC(d){for(const _ of d.children)NT(_);const p=d.component.scales;for(const _ of We(p)){let x,S=null;for(const A of d.children){const O=A.component.scales[_];if(O){x=void 0===x?O.getWithExplicit("domains"):Qa(x,O.getWithExplicit("domains"),"domains","scale",yb);const P=O.get("selectionExtent");S&&P&&S.param!==P.param&&nt(wu),S=P}}p[_].setWithExplicit("domains",x),S&&p[_].set("selectionExtent",S,!0)}}(d)}function FT(d,p){const _=d.getScaleComponent(p).get("type"),{encoding:x}=d,S=function Kd(d,p,_,x){if("unaggregated"===d){const{valid:S,reason:A}=PT(p,_);if(!S)return void nt(A)}else if(void 0===d&&x.useUnaggregatedDomain){const{valid:S}=PT(p,_);if(S)return"unaggregated"}return d}(d.scaleDomain(p),d.typedFieldDef(p),_,d.config.scale);return S!==d.scaleDomain(p)&&(d.specifiedScales[p]={...d.specifiedScales[p],domain:S}),"x"===p&&Oo(x.x2)?Oo(x.x)?Qa(ju(_,S,d,"x"),ju(_,S,d,"x2"),"domain","scale",yb):ju(_,S,d,"x2"):"y"===p&&Oo(x.y2)?Oo(x.y)?Qa(ju(_,S,d,"y"),ju(_,S,d,"y2"),"domain","scale",yb):ju(_,S,d,"y2"):ju(_,S,d,p)}function cn(d,p,_){const x=Fr(_)?.unit;return"temporal"===p||x?function jx(d,p,_){return d.map(x=>({signal:`{data: ${Td(x,{timeUnit:_,type:p})}}`}))}(d,p,x):[d]}function ju(d,p,_,x){const{encoding:S,markDef:A,mark:O,config:P,stack:B}=_,q=Oo(S[x]),{type:G}=q,ee=q.timeUnit;if(function tp(d){return d?.unionWith}(p)){const De=ju(d,void 0,_,x);return Ls([...cn(p.unionWith,G,ee),...De.value])}if(Je(p))return Ls([p]);if(p&&"unaggregated"!==p&&!Xo(p))return Ls(cn(p,G,ee));if(B&&x===B.fieldChannel){if("normalize"===B.offset)return co([[0,1]]);const De=_.requestDataName(Vr.Main);return co([{data:De,field:_.vgField(x,{suffix:"start"})},{data:De,field:_.vgField(x,{suffix:"end"})}])}const se=pd(x)&&dt(q)?function Bt(d,p,_){if(!ko(_))return;const x=d.fieldDef(p),S=x.sort;if(fE(S))return{op:"min",field:Np(x,p),order:"ascending"};const{stack:A}=d,O=A?new Set([...A.groupbyFields,...A.stackBy.map(P=>P.fieldDef.field)]):void 0;if(sa(S))return Ux(S,A&&!O.has(S.field));if(dE(S)){const{encoding:P,order:B}=S,q=d.fieldDef(P),{aggregate:G,field:ee}=q,se=A&&!O.has(ee);if(bu(G)||Ua(G))return Ux({field:pt(q),order:B},se);if(K_(G)||!G)return Ux({op:G,field:ee,order:B},se)}else{if("descending"===S)return{op:"min",field:d.vgField(p),order:"descending"};if(St(["ascending",void 0],S))return!0}}(_,x,d):void 0;if(Sd(q))return co(cn([q.datum],G,ee));const Ee=q;if("unaggregated"===p){const De=_.requestDataName(Vr.Main),{field:Re}=q;return co([{data:De,field:pt({field:Re,aggregate:"min"})},{data:De,field:pt({field:Re,aggregate:"max"})}])}if(sr(Ee.bin)){if(ko(d))return co("bin-ordinal"===d?[]:[{data:Hi(se)?_.requestDataName(Vr.Main):_.requestDataName(Vr.Raw),field:_.vgField(x,kd(Ee,x)?{binSuffix:"range"}:{}),sort:!0!==se&&re.isObject(se)?se:{field:_.vgField(x,{}),op:"min"}}]);{const{bin:De}=Ee;if(sr(De)){const Re=jp(_,Ee.field,De);return co([new bs(()=>{const Le=_.getSignalName(Re);return`[${Le}.start, ${Le}.stop]`})])}return co([{data:_.requestDataName(Vr.Main),field:_.vgField(x,{})}])}}if(Ee.timeUnit&&St(["time","utc"],d)){const De=S[Or(x)];if(vy(Ee,De,A,P)){const Re=_.requestDataName(Vr.Main),Le=Tu({fieldDef:Ee,fieldDef2:De,markDef:A,config:P}),Ye=ip(O)&&.5!==Le&&Yr(x);return co([{data:Re,field:_.vgField(x,Ye?{suffix:Xc}:{})},{data:Re,field:_.vgField(x,{suffix:Ye?Vd:"end"})}])}}return co(se?[{data:Hi(se)?_.requestDataName(Vr.Main):_.requestDataName(Vr.Raw),field:_.vgField(x),sort:se}]:[{data:_.requestDataName(Vr.Main),field:_.vgField(x)}])}function Ux(d,p){const{op:_,field:x,order:S}=d;return{op:_??(p?"sum":ig),...x?{field:ci(x)}:{},...S?{order:S}:{}}}function s3(d,p){const _=d.component.scales[p],x=d.specifiedScales[p].domain,S=d.fieldDef(p)?.bin,A=Xo(x)&&x,O=Lc(S)&&Q_(S.extent)&&S.extent;(A||O)&&_.set("selectionExtent",A??O,!0)}function PT(d,p){const{aggregate:_,type:x}=d;return _?re.isString(_)&&!Xe.has(_)?{valid:!1,reason:fv(_)}:"quantitative"===x&&"log"===p?{valid:!1,reason:qM(d)}:{valid:!0}:{valid:!1,reason:WM(d)}}function yb(d,p,_,x){return d.explicit&&p.explicit&&nt(function G$(d,p,_,x){return`Conflicting ${p.toString()} property "${d.toString()}" (${Wn(_)} and ${Wn(x)}). Using the union of the two domains.`}(_,x,d.value,p.value)),{explicit:d.explicit,value:[...d.value,...p.value]}}function LT(d){const p=Ci(d.map(O=>{if(vu(O)){const{sort:P,...B}=O;return B}return O}),kt),_=Ci(d.map(O=>{if(vu(O)){const P=O.sort;return void 0!==P&&!Hi(P)&&("op"in P&&"count"===P.op&&delete P.field,"ascending"===P.order&&delete P.order),P}}).filter(O=>void 0!==O),kt);if(0===p.length)return;if(1===p.length){const O=d[0];if(vu(O)&&_.length>0){let P=_[0];if(_.length>1){nt(P2);const B=_.filter(q=>re.isObject(q)&&"op"in q&&"min"!==q.op);P=!_.every(q=>re.isObject(q)&&"op"in q)||1!==B.length||B[0]}else re.isObject(P)&&"field"in P&&O.field===P.field&&(P=!P.order||{order:P.order});return{...O,sort:P}}return O}const x=Ci(_.map(O=>Hi(O)||!("op"in O)||re.isString(O.op)&&O.op in nv?O:(nt(function Y$(d){return`Dropping sort property ${Wn(d)} as unioned domains only support boolean or op "count", "min", and "max".`}(O)),!0)),kt);let S;1===x.length?S=x[0]:x.length>1&&(nt(P2),S=!0);const A=Ci(d.map(O=>vu(O)?O.data:null),O=>O);return 1===A.length&&null!==A[0]?{data:A[0],fields:p.map(P=>P.field),...S?{sort:S}:{}}:{fields:p,...S?{sort:S}:{}}}function NC(d){if(vu(d)&&re.isString(d.field))return d.field;if(function IM(d){return!re.isArray(d)&&"fields"in d&&!("data"in d)}(d)){let p;for(const _ of d.fields)if(vu(_)&&re.isString(_.field))if(p){if(p!==_.field)return nt("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."),p}else p=_.field;return nt("Detected faceted independent scales that union domain of the same fields from different source. We will assume that this is the same field from a different fork of the same data source. However, if this is not the case, the result view size may be incorrect."),p}if(function Ni(d){return!re.isArray(d)&&"fields"in d&&"data"in d}(d)){nt("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 p=d.fields[0];return re.isString(p)?p:void 0}}function Wp(d,p){return LT(d.component.scales[p].get("domains").map(S=>(vu(S)&&(S.data=d.lookupDataSource(S.data)),S)))}function FC(d){return Hg(d)||Gx(d)?d.children.reduce((p,_)=>p.concat(FC(_)),PC(d)):PC(d)}function PC(d){return We(d.component.scales).reduce((p,_)=>{const x=d.component.scales[_];if(x.merged)return p;const S=x.combine(),{name:A,type:O,selectionExtent:P,domains:B,range:q,reverse:G,...ee}=S,se=function LC(d,p,_,x){if(Yr(_)){if(ht(d))return{step:{signal:`${p}_step`}}}else if(re.isObject(d)&&vu(d))return{...d,data:x.lookupDataSource(d.data)};return d}(S.range,A,_,d),Ee=Wp(d,_),De=P?function qE(d,p,_,x){const S=sC(d,p.param,p);return{signal:Da(_.get("type"))&&re.isArray(x)&&x[0]>x[1]?`isValid(${S}) && reverse(${S})`:S}}(d,P,x,Ee):null;return p.push({name:A,type:O,...Ee?{domain:Ee}:{},...De?{domainRaw:De}:{},range:se,...void 0!==G?{reverse:G}:{},...ee}),p},[])}class $T extends Za{constructor(p,_){super({},{name:p}),ln(this,"merged",!1),this.setWithExplicit("type",_)}domainDefinitelyIncludesZero(){return!1!==this.get("zero")||li(this.get("domains"),p=>re.isArray(p)&&2===p.length&&re.isNumber(p[0])&&p[0]<=0&&re.isNumber(p[1])&&p[1]>=0)}}const yR=["range","scheme"];function Hx(d,p){const _=d.fieldDef(p);if(_?.bin){const{bin:x,field:S}=_,A=Mr(p),O=d.getName(A);if(re.isObject(x)&&x.binned&&void 0!==x.step)return new bs(()=>{const P=d.scaleName(p),B=`(domain("${P}")[1] - domain("${P}")[0]) / ${x.step}`;return`${d.getSignalName(O)} / (${B})`});if(sr(x)){const P=jp(d,S,x);return new bs(()=>{const B=d.getSignalName(P),q=`(${B}.stop - ${B}.start) / ${B}.step`;return`${d.getSignalName(O)} / (${q})`})}}}function BT(d,p){const _=p.specifiedScales[d],{size:x}=p,A=p.getScaleComponent(d).get("type");for(const ee of yR)if(void 0!==_[ee]){const se=Qm(A,ee),Ee=fy(d,ee);if(se)if(Ee)nt(Ee);else switch(ee){case"range":{const De=_.range;if(re.isArray(De)){if(Yr(d))return Ls(De.map(Re=>{if("width"===Re||"height"===Re){const Le=p.getName(Re),Ye=p.getSignalName.bind(p);return bs.fromName(Ye,Le)}return Re}))}else if(re.isObject(De))return Ls({data:p.requestDataName(Vr.Main),field:De.field,sort:{op:"min",field:p.vgField(d)}});return Ls(De)}case"scheme":return Ls(Wx(_[ee]))}else nt(z1(A,ee,d))}const O=d===Ri||"xOffset"===d?"width":"height",P=x[O];if(Fd(P))if(Yr(d))if(ko(A)){const ee=hc(P,p,d);if(ee)return Ls({step:ee})}else nt(GM(O));else if(us(d)&&"band"===p.getScaleComponent(d===Yl?"x":"y").get("type")){const De=qp(P,A);if(De)return Ls(De)}const{rangeMin:B,rangeMax:q}=_,G=function $C(d,p){const{size:_,config:x,mark:S,encoding:A}=p,{type:O}=Oo(A[d]),B=p.getScaleComponent(d).get("type"),{domain:q,domainMid:G}=p.specifiedScales[d];switch(d){case Ri:case mo:if(St(["point","band"],B)){const ee=qx(d,_,x.view);if(Fd(ee))return{step:hc(ee,p,d)}}return bb(d,p,B);case Yl:case Qn:return function zT(d,p,_){const x=d===Yl?"x":"y",S=p.getScaleComponent(x);if(!S)return bb(x,p,_,{center:!0});const A=S.get("type"),O=p.scaleName(x),{markDef:P,config:B}=p;if("band"===A){const q=qx(x,p.size,p.config.view);if(Fd(q)){const G=qp(q,_);if(G)return G}return[0,{signal:`bandwidth('${O}')`}]}{const q=p.encoding[x];if(dt(q)&&q.timeUnit){const G=Lf(q.timeUnit,De=>`scale('${O}', ${De})`),ee=p.config.scale.bandWithNestedOffsetPaddingInner,se=Tu({fieldDef:q,markDef:P,config:B})-.5,Ee=0!==se?` + ${se}`:"";return ee?[{signal:`${Je(ee)?`${ee.signal}/2`+Ee:`${ee/2+se}`} * (${G})`},{signal:`${Je(ee)?`(1 - ${ee.signal}/2)`+Ee:`${1-ee/2+se}`} * (${G})`}]:[0,{signal:G}]}return Fn(`Cannot use ${d} scale if ${x} scale is not discrete.`)}}(d,p,B);case He:{const se=vb(S,p.component.scales[d].get("zero"),x),Ee=function VT(d,p,_,x){const S={x:Hx(_,"x"),y:Hx(_,"y")};switch(d){case"bar":case"tick":{if(void 0!==x.scale.maxBandSize)return x.scale.maxBandSize;const A=Gp(p,S,x.view);return re.isNumber(A)?A-1:new bs(()=>`${A.signal} - 1`)}case"line":case"trail":case"rule":return x.scale.maxStrokeWidth;case"text":return x.scale.maxFontSize;case"point":case"square":case"circle":{if(x.scale.maxSize)return x.scale.maxSize;const A=Gp(p,S,x.view);return re.isNumber(A)?Math.pow(zC*A,2):new bs(()=>`pow(${zC} * ${A.signal}, 2)`)}}throw new Error(bo("size",d))}(S,_,p,x);return vd(B)?function bR(d,p,_){const x=()=>{const S=ec(p),A=ec(d),O=`(${S} - ${A}) / (${_} - 1)`;return`sequence(${A}, ${S} + ${O}, ${O})`};return Je(p)?new bs(x):{signal:x()}}(se,Ee,function BC(d,p,_,x){switch(d){case"quantile":return p.scale.quantileCount;case"quantize":return p.scale.quantizeCount;case"threshold":return void 0!==_&&re.isArray(_)?_.length+1:(nt(function tA(d){return`Domain for ${d} is required for threshold scale.`}(x)),3)}}(B,x,q,d)):[se,Ee]}case As:return[0,2*Math.PI];case lt:return[0,360];case Ao:return[0,new bs(()=>`min(${p.getSignalName("width")},${p.getSignalName("height")})/2`)];case Ts:return[x.scale.minStrokeWidth,x.scale.maxStrokeWidth];case Hh:return[[1,0],[4,2],[2,1],[1,1],[1,2,4,2]];case ye:return"symbol";case be:case Se:case Fe:return"ordinal"===B?"nominal"===O?"category":"ordinal":void 0!==G?"diverging":"rect"===S||"geoshape"===S?"heatmap":"ramp";case _e:case nn:case gi:return[x.scale.minOpacity,x.scale.maxOpacity]}}(d,p);return(void 0!==B||void 0!==q)&&Qm(A,"rangeMin")&&re.isArray(G)&&2===G.length?Ls([B??G[0],q??G[1]]):co(G)}function Wx(d){return function Dv(d){return!re.isString(d)&&!!d.name}(d)?{scheme:d.name,...yt(d,["name"])}:{scheme:d}}function bb(d,p,_){let{center:x}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const S=Mr(d),A=p.getName(S),O=p.getSignalName.bind(p);return d===mo&&Da(_)?x?[bs.fromName(P=>`${O(P)}/2`,A),bs.fromName(P=>`-${O(P)}/2`,A)]:[bs.fromName(O,A),0]:x?[bs.fromName(P=>`-${O(P)}/2`,A),bs.fromName(P=>`${O(P)}/2`,A)]:[0,bs.fromName(O,A)]}function hc(d,p,_){const{encoding:x}=p,S=p.getScaleComponent(_),A=To(_),O=x[A];if("offset"===AE({step:d,offsetIsDiscrete:Bn(O)&&Z1(O.type)})&&Yf(x,A)){const B=p.getScaleComponent(A);let G=`domain('${p.scaleName(A)}').length`;"band"===B.get("type")&&(G=`bandspace(${G}, ${B.get("paddingInner")??B.get("padding")??0}, ${B.get("paddingOuter")??B.get("padding")??0})`);const ee=S.get("paddingInner")??S.get("padding");return{signal:`${d.step} * ${G} / (1-${Jl(ee)})`}}return d.step}function qp(d,p){if("offset"===AE({step:d,offsetIsDiscrete:ko(p)}))return{step:d.step}}function qx(d,p,_){const x=d===Ri?"width":"height";return p[x]||lo(_,x)}function vb(d,p,_){if(p)return Je(p)?{signal:`${p.signal} ? 0 : ${vb(d,!1,_)}`}:0;switch(d){case"bar":case"tick":return _.scale.minBandSize;case"line":case"trail":case"rule":return _.scale.minStrokeWidth;case"text":return _.scale.minFontSize;case"point":case"square":case"circle":return _.scale.minSize}throw new Error(bo("size",d))}const zC=.95;function Gp(d,p,_){const x=Fd(d.width)?d.width.step:pr(_,"width"),S=Fd(d.height)?d.height.step:pr(_,"height");return p.x||p.y?new bs(()=>`min(${[p.x?p.x.signal:x,p.y?p.y.signal:S].join(", ")})`):Math.min(x,S)}function jT(d,p){uo(d)?function pc(d,p){const _=d.component.scales,{config:x,encoding:S,markDef:A,specifiedScales:O}=d;for(const P of We(_)){const B=O[P],q=_[P],G=d.getScaleComponent(P),ee=Oo(S[P]),se=B[p],Ee=G.get("type"),De=G.get("padding"),Re=G.get("paddingInner"),Le=Qm(Ee,p),Ye=fy(P,p);if(void 0!==se&&(Le?Ye&&nt(Ye):nt(z1(Ee,p,P))),Le&&void 0===Ye)if(void 0!==se){const bt=ee.timeUnit,kn=ee.type;switch(p){case"domainMax":case"domainMin":_d(B[p])||"temporal"===kn||bt?q.set(p,{signal:Td(B[p],{type:kn,timeUnit:bt})},!0):q.set(p,B[p],!0);break;default:q.copyKeyFromObject(p,B)}}else{const bt=p in UT?UT[p]({model:d,channel:P,fieldOrDatumDef:ee,scaleType:Ee,scalePadding:De,scalePaddingInner:Re,domain:B.domain,domainMin:B.domainMin,domainMax:B.domainMax,markDef:A,config:x,hasNestedOffsetScale:dp(S,P),hasSecondaryRangeChannel:!!S[Or(P)]}):x.scale[p];void 0!==bt&&q.set(p,bt,!1)}}}(d,p):Zc(d,p)}const UT={bins:d=>{let{model:p,fieldOrDatumDef:_}=d;return dt(_)?function Ug(d,p){const _=p.bin;if(sr(_)){const x=jp(d,p.field,_);return new bs(()=>d.getSignalName(x))}if(oo(_)&&Lc(_)&&void 0!==_.step)return{step:_.step}}(p,_):void 0},interpolate:d=>{let{channel:p,fieldOrDatumDef:_}=d;return function VC(d,p){if(St([be,Se,Fe],d)&&"nominal"!==p)return"hcl"}(p,_.type)},nice:d=>{let{scaleType:p,channel:_,domain:x,domainMin:S,domainMax:A,fieldOrDatumDef:O}=d;return function jC(d,p,_,x,S,A){if(!(ku(A)?.bin||re.isArray(_)||null!=S||null!=x||St([Ga.TIME,Ga.UTC],d)))return!!Yr(p)||void 0}(p,_,x,S,A,O)},padding:d=>{let{channel:p,scaleType:_,fieldOrDatumDef:x,markDef:S,config:A}=d;return function HT(d,p,_,x,S,A){if(Yr(d)){if(Go(p)){if(void 0!==_.continuousPadding)return _.continuousPadding;const{type:O,orient:P}=S;if("bar"===O&&(!dt(x)||!x.bin&&!x.timeUnit)&&("vertical"===P&&"x"===d||"horizontal"===P&&"y"===d))return A.continuousBandSize}if(p===Ga.POINT)return _.pointPadding}}(p,_,A.scale,x,S,A.bar)},paddingInner:d=>{let{scalePadding:p,channel:_,markDef:x,scaleType:S,config:A,hasNestedOffsetScale:O}=d;return function vR(d,p,_,x,S){let A=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(void 0===d){if(Yr(p)){const{bandPaddingInner:O,barBandPaddingInner:P,rectBandPaddingInner:B,bandWithNestedOffsetPaddingInner:q}=S;return A?q:ui(O,"bar"===_?P:B)}if(us(p)&&x===Ga.BAND)return S.offsetBandPaddingInner}}(p,_,x.type,S,A.scale,O)},paddingOuter:d=>{let{scalePadding:p,channel:_,scaleType:x,scalePaddingInner:S,config:A,hasNestedOffsetScale:O}=d;return function WT(d,p,_,x,S){let A=arguments.length>5&&void 0!==arguments[5]&&arguments[5];if(void 0===d)if(Yr(p)){const{bandPaddingOuter:O,bandWithNestedOffsetPaddingOuter:P}=S;if(A)return P;if(_===Ga.BAND)return ui(O,Je(x)?{signal:`${x.signal}/2`}:x/2)}else if(us(p)){if(_===Ga.POINT)return.5;if(_===Ga.BAND)return S.offsetBandPaddingOuter}}(p,_,x,S,A.scale,O)},reverse:d=>{let{fieldOrDatumDef:p,scaleType:_,channel:x,config:S}=d;return function wn(d,p,_,x){return"x"===_&&void 0!==x.xReverse?Da(d)&&"descending"===p?Je(x.xReverse)?{signal:`!${x.xReverse.signal}`}:!x.xReverse:x.xReverse:!(!Da(d)||"descending"!==p)||void 0}(_,dt(p)?p.sort:void 0,x,S.scale)},zero:d=>{let{channel:p,fieldOrDatumDef:_,domain:x,markDef:S,scaleType:A,config:O,hasSecondaryRangeChannel:P}=d;return function xR(d,p,_,x,S,A,O){if(_&&"unaggregated"!==_&&Da(S)){if(re.isArray(_)){const B=_[0],q=_[_.length-1];if(re.isNumber(B)&&B<=0&&re.isNumber(q)&&q>=0)return!0}return!1}if("size"===d&&"quantitative"===p.type&&!vd(S))return!0;if((!dt(p)||!p.bin)&&St([...Ql,...fi],d)){const{orient:B,type:q}=x;return(!St(["bar","area","line","trail"],q)||!("horizontal"===B&&"y"===d||"vertical"===B&&"x"===d))&&(!(!St(["bar","area"],q)||O)||A?.zero)}return!1}(p,_,x,S,A,O.scale,P)}};function ch(d){uo(d)?function lh(d){const p=d.component.scales;for(const _ of ev){const x=p[_];if(!x)continue;const S=BT(_,d);x.setWithExplicit("range",S)}}(d):Zc(d,"range")}function Zc(d,p){const _=d.component.scales;for(const x of d.children)"range"===p?ch(x):jT(x,p);for(const x of We(_)){let S;for(const A of d.children){const O=A.component.scales[x];O&&(S=Qa(S,O.getWithExplicit(p),p,"scale",zd((B,q)=>"range"===p&&B.step&&q.step?B.step-q.step:0)))}_[x].setWithExplicit(p,S)}}function xb(d,p,_,x){const A=function wb(d,p,_,x){switch(p.type){case"nominal":case"ordinal":if(Wh(d)||"discrete"===Gh(d))return"shape"===d&&"ordinal"===p.type&&nt(ml(d,"ordinal")),"ordinal";if(Yr(d)||us(d)){if(St(["rect","bar","image","rule"],_.type)||x)return"band"}else if("arc"===_.type&&d in Q0)return"band";return Au(_[Mr(d)])||Dd(p)&&p.axis?.tickBand?"band":"point";case"temporal":return Wh(d)?"time":"discrete"===Gh(d)?(nt(ml(d,"temporal")),"ordinal"):dt(p)&&p.timeUnit&&Fr(p.timeUnit).utc?"utc":"time";case"quantitative":return Wh(d)?dt(p)&&sr(p.bin)?"bin-ordinal":"linear":"discrete"===Gh(d)?(nt(ml(d,"quantitative")),"ordinal"):"linear";case"geojson":return}throw new Error(av(p.type))}(p,_,x,arguments.length>4&&void 0!==arguments[4]&&arguments[4]),{type:O}=d;return pd(p)?void 0!==O?function nE(d,p){let _=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!pd(d))return!1;switch(d){case Ri:case mo:case Yl:case Qn:case As:case Ao:return!(!Go(p)&&"band"!==p)||"point"===p&&!_;case He:case Ts:case _e:case nn:case gi:case lt:return Go(p)||vd(p)||St(["band","point","ordinal"],p);case be:case Se:case Fe:return"band"!==p;case Hh:case ye:return"ordinal"===p||vd(p)}}(p,O)?dt(_)&&!function Mv(d,p){return St([Os,wv],p)?void 0===d||ko(d):p===qa?St([Ga.TIME,Ga.UTC,void 0],d):p!==$f||uy(d)||vd(d)||void 0===d}(O,_.type)?(nt(function hv(d,p){return`FieldDef does not work with "${d}" scale. We are using "${p}" scale instead.`}(O,A)),A):O:(nt(function F2(d,p,_){return`Channel "${d}" does not work with "${p}" scale. We are using "${_}" scale instead.`}(p,O,A)),A):A:null}function UC(d){d.component.scales=uo(d)?function GT(d){const{encoding:p,mark:_,markDef:x}=d,S={};for(const A of ev){const O=Oo(p[A]);if(O&&_===Jm&&A===ye&&O.type===Sa)continue;let P=O&&O.scale;if(O&&null!==P&&!1!==P){P??={};const q=xb(P,A,O,x,dp(p,A));S[A]=new $T(d.scaleName(`${A}`,!0),{value:q,explicit:P.type===q})}}return S}(d):function wR(d){const p=d.component.scales={},_={},x=d.component.resolve;for(const S of d.children){UC(S);for(const A of We(S.component.scales))if(x.scale[A]??=o3(A,d),"shared"===x.scale[A]){const O=_[A],P=S.component.scales[A].getWithExplicit("type");O?Cv(O.value,P.value)?_[A]=Qa(O,P,"type","scale",HC):(x.scale[A]="independent",delete _[A]):_[A]=P}}for(const S of We(_)){const A=d.scaleName(S,!0);p[S]=new $T(A,_[S]);for(const P of d.children){const B=P.component.scales[S];B&&(P.renameScale(B.get("name"),A),B.merged=!0)}}return p}(d)}const HC=zd((d,p)=>jc(d)-jc(p));class Uu{constructor(){ln(this,"nameMap",void 0),this.nameMap={}}rename(p,_){this.nameMap[p]=_}has(p){return void 0!==this.nameMap[p]}get(p){for(;this.nameMap[p]&&p!==this.nameMap[p];)p=this.nameMap[p];return p}}function uo(d){return"unit"===d?.type}function mc(d){return"facet"===d?.type}function Gx(d){return"concat"===d?.type}function Hg(d){return"layer"===d?.type}class Hu{constructor(p,_,x,S,A,O,P){this.type=_,this.parent=x,this.config=A,ln(this,"name",void 0),ln(this,"size",void 0),ln(this,"title",void 0),ln(this,"description",void 0),ln(this,"data",void 0),ln(this,"transforms",void 0),ln(this,"layout",void 0),ln(this,"scaleNameMap",void 0),ln(this,"projectionNameMap",void 0),ln(this,"signalNameMap",void 0),ln(this,"component",void 0),ln(this,"view",void 0),ln(this,"children",void 0),ln(this,"correctDataNames",B=>(B.from?.data&&(B.from.data=this.lookupDataSource(B.from.data)),B.from?.facet?.data&&(B.from.facet.data=this.lookupDataSource(B.from.facet.data)),B)),this.parent=x,this.config=A,this.view=_o(P),this.name=p.name??S,this.title=ds(p.title)?{text:p.title}:p.title?_o(p.title):void 0,this.scaleNameMap=x?x.scaleNameMap:new Uu,this.projectionNameMap=x?x.projectionNameMap:new Uu,this.signalNameMap=x?x.signalNameMap:new Uu,this.data=p.data,this.description=p.description,this.transforms=function GA(d){return d.map(p=>Vy(p)?{filter:At(p.filter,K1)}:p)}(p.transform??[]),this.layout="layer"===_||"unit"===_?{}:function Ny(d,p,_){const x=_[p],S={},{spacing:A,columns:O}=x;void 0!==A&&(S.spacing=A),void 0!==O&&(_y(d)&&!og(d.facet)||ME(d))&&(S.columns=O),mg(d)&&(S.columns=1);for(const P of J$)if(void 0!==d[P])if("spacing"===P){const B=d[P];S[P]=re.isNumber(B)?B:{row:B.row??A,column:B.column??A}}else S[P]=d[P];return S}(p,_,A),this.component={data:{sources:x?x.component.data.sources:[],outputNodes:x?x.component.data.outputNodes:{},outputNodeRefCounts:x?x.component.data.outputNodeRefCounts:{},isFaceted:_y(p)||x?.component.data.isFaceted&&void 0===p.data},layoutSize:new Za,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:{scale:{},axis:{},legend:{},...O?st(O):{}},selection:null,scales:null,projection:null,axes:{},legends:{}}}get width(){return this.getSizeSignalRef("width")}get height(){return this.getSizeSignalRef("height")}parse(){this.parseScale(),this.parseLayoutSize(),this.renameTopLevelLayoutSizeSignal(),this.parseSelections(),this.parseProjection(),this.parseData(),this.parseAxesAndHeaders(),this.parseLegends(),this.parseMarkGroup()}parseScale(){!function qT(d){let{ignoreRange:p}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};UC(d),NT(d);for(const _ of tE)jT(d,_);p||ch(d)}(this)}parseProjection(){Sl(this)}renameTopLevelLayoutSizeSignal(){"width"!==this.getName("width")&&this.renameSignal(this.getName("width"),"width"),"height"!==this.getName("height")&&this.renameSignal(this.getName("height"),"height")}parseLegends(){vT(this)}assembleEncodeFromView(p){const{style:_,...x}=p,S={};for(const A of We(x)){const O=x[A];void 0!==O&&(S[A]=Ar(O))}return S}assembleGroupEncodeEntry(p){let _={};return this.view&&(_=this.assembleEncodeFromView(this.view)),p||(this.description&&(_.description=Ar(this.description)),"unit"!==this.type&&"layer"!==this.type)?Gt(_)?void 0:_:{width:this.getSizeSignalRef("width"),height:this.getSizeSignalRef("height"),..._??{}}}assembleLayout(){if(!this.layout)return;const{spacing:p,..._}=this.layout,{component:x,config:S}=this,A=function lb(d,p){const _={};for(const x of Zl){const S=d[x];if(S?.facetFieldDef){const{titleAnchor:A,titleOrient:O}=Cx(["titleAnchor","titleOrient"],S.facetFieldDef.header,p,x),P=sb(x,O),B=ab(A,P);void 0!==B&&(_[P]=B)}}return Gt(_)?void 0:_}(x.layoutHeaders,S);return{padding:p,...this.assembleDefaultLayout(),..._,...A?{titleBand:A}:{}}}assembleDefaultLayout(){return{}}assembleHeaderMarks(){const{layoutHeaders:p}=this.component;let _=[];for(const x of Zl)p[x].title&&_.push(hR(this,x));for(const x of gC)_=_.concat(bC(this,x));return _}assembleAxes(){return function hT(d,p){const{x:_=[],y:x=[]}=d;return[..._.map(S=>rb(S,"grid",p)),...x.map(S=>rb(S,"grid",p)),..._.map(S=>rb(S,"main",p)),...x.map(S=>rb(S,"main",p))].filter(S=>S)}(this.component.axes,this.config)}assembleLegends(){return rh(this)}assembleProjections(){return pb(this)}assembleTitle(){const{encoding:p,..._}=this.title??{},x={...pl(this.config.title).nonMarkTitleProperties,..._,...p?{encode:{update:p}}:{}};if(x.text)return St(["unit","layer"],this.type)?St(["middle",void 0],x.anchor)&&(x.frame??="group"):x.anchor??="start",Gt(x)?void 0:x}assembleGroup(){let p=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const _={};p=p.concat(this.assembleSignals()),p.length>0&&(_.signals=p);const x=this.assembleLayout();x&&(_.layout=x),_.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());const S=!this.parent||mc(this.parent)?FC(this):[];S.length>0&&(_.scales=S);const A=this.assembleAxes();A.length>0&&(_.axes=A);const O=this.assembleLegends();return O.length>0&&(_.legends=O),_}getName(p){return hn((this.name?`${this.name}_`:"")+p)}getDataName(p){return this.getName(Vr[p].toLowerCase())}requestDataName(p){const _=this.getDataName(p),x=this.component.data.outputNodeRefCounts;return x[_]=(x[_]||0)+1,_}getSizeSignalRef(p){if(mc(this.parent)){const x=If(yT(p)),S=this.component.scales[x];if(S&&!S.merged){const A=S.get("type"),O=S.get("range");if(ko(A)&&ht(O)){const P=S.get("name"),q=NC(Wp(this,x));return q?{signal:vC(P,S,pt({aggregate:"distinct",field:q},{expr:"datum"}))}:(nt(Tr(x)),null)}}}return{signal:this.signalNameMap.get(this.getName(p))}}lookupDataSource(p){const _=this.component.data.outputNodes[p];return _?_.getSource():p}getSignalName(p){return this.signalNameMap.get(p)}renameSignal(p,_){this.signalNameMap.rename(p,_)}renameScale(p,_){this.scaleNameMap.rename(p,_)}renameProjection(p,_){this.projectionNameMap.rename(p,_)}scaleName(p,_){return _?this.getName(p):hl(p)&&pd(p)&&this.component.scales[p]||this.scaleNameMap.has(this.getName(p))?this.scaleNameMap.get(this.getName(p)):void 0}projectionName(p){return p?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(p){if(!this.component.scales)throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().");const _=this.component.scales[p];return _&&!_.merged?_:this.parent?this.parent.getScaleComponent(p):void 0}getSelectionComponent(p,_){let x=this.component.selection[p];if(!x&&this.parent&&(x=this.parent.getSelectionComponent(p,_)),!x)throw new Error(function ra(d){return`Cannot find a selection named "${d}".`}(_));return x}hasAxisOrientSignalRef(){return this.component.axes.x?.some(p=>p.hasOrientSignalRef())||this.component.axes.y?.some(p=>p.hasOrientSignalRef())}}class Wg extends Hu{vgField(p){let _=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const x=this.fieldDef(p);if(x)return pt(x,_)}reduceFieldDef(p,_){return function Uv(d,p,_,x){return d?We(d).reduce((S,A)=>{const O=d[A];return re.isArray(O)?O.reduce((P,B)=>p.call(x,P,B,A),S):p.call(x,S,O,A)},_):_}(this.getMapping(),(x,S,A)=>{const O=ku(S);return O?p(x,O,A):x},_)}forEachFieldDef(p,_){Ey(this.getMapping(),(x,S)=>{const A=ku(x);A&&p(A,S)},_)}}class Vs extends Tn{clone(){return new Vs(null,st(this.transform))}constructor(p,_){super(p),this.transform=_,this.transform=st(_);const x=this.transform.as??[void 0,void 0];this.transform.as=[x[0]??"value",x[1]??"density"]}dependentFields(){return new Set([this.transform.density,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`DensityTransform ${kt(this.transform)}`}assemble(){const{density:p,..._}=this.transform,x={type:"kde",field:p,..._};return this.transform.groupby&&(x.resolve="shared"),x}}class Xp extends Tn{clone(){return new Xp(null,st(this.transform))}constructor(p,_){super(p),this.transform=_,this.transform=st(_)}dependentFields(){return new Set([this.transform.extent])}producedFields(){return new Set([])}hash(){return`ExtentTransform ${kt(this.transform)}`}assemble(){const{extent:p,param:_}=this.transform;return{type:"extent",field:p,signal:_}}}class Zd extends Tn{clone(){return new Zd(null,{...this.filter})}constructor(p,_){super(p),this.filter=_}static make(p,_){const{config:x,mark:S,markDef:A}=_;if("filter"!==Ji("invalid",A,x))return null;const P=_.reduceFieldDef((B,q,G)=>{const ee=pd(G)&&_.getScaleComponent(G);return ee&&Da(ee.get("type"))&&"count"!==q.aggregate&&!yl(S)&&(B[q.field]=q),B},{});return We(P).length?new Zd(p,P):null}dependentFields(){return new Set(We(this.filter))}producedFields(){return new Set}hash(){return`FilterInvalid ${kt(this.filter)}`}assemble(){const p=We(this.filter).reduce((_,x)=>{const S=this.filter[x],A=pt(S,{expr:"datum"});return null!==S&&("temporal"===S.type?_.push(`(isDate(${A}) || (isValid(${A}) && isFinite(+${A})))`):"quantitative"===S.type&&(_.push(`isValid(${A})`),_.push(`isFinite(+${A})`))),_},[]);return p.length>0?{type:"filter",expr:p.join(" && ")}:null}}class Yp extends Tn{clone(){return new Yp(this.parent,st(this.transform))}constructor(p,_){super(p),this.transform=_,this.transform=st(_);const{flatten:x,as:S=[]}=this.transform;this.transform.as=x.map((A,O)=>S[O]??A)}dependentFields(){return new Set(this.transform.flatten)}producedFields(){return new Set(this.transform.as)}hash(){return`FlattenTransform ${kt(this.transform)}`}assemble(){const{flatten:p,as:_}=this.transform;return{type:"flatten",fields:p,as:_}}}class Kp extends Tn{clone(){return new Kp(null,st(this.transform))}constructor(p,_){super(p),this.transform=_,this.transform=st(_);const x=this.transform.as??[void 0,void 0];this.transform.as=[x[0]??"key",x[1]??"value"]}dependentFields(){return new Set(this.transform.fold)}producedFields(){return new Set(this.transform.as)}hash(){return`FoldTransform ${kt(this.transform)}`}assemble(){const{fold:p,as:_}=this.transform;return{type:"fold",fields:p,as:_}}}class qg extends Tn{clone(){return new qg(null,st(this.fields),this.geojson,this.signal)}static parseAll(p,_){if(_.component.projection&&!_.component.projection.isFit)return p;let x=0;for(const S of[[Ho,It],[ae,wr]]){const A=S.map(O=>{const P=Oo(_.encoding[O]);return dt(P)?P.field:Sd(P)?{expr:`${P.datum}`}:Ma(P)?{expr:`${P.value}`}:void 0});(A[0]||A[1])&&(p=new qg(p,A,null,_.getName("geojson_"+x++)))}if(_.channelHasField(ye)){const S=_.typedFieldDef(ye);S.type===Sa&&(p=new qg(p,null,S.field,_.getName("geojson_"+x++)))}return p}constructor(p,_,x,S){super(p),this.fields=_,this.geojson=x,this.signal=S}dependentFields(){const p=(this.fields??[]).filter(re.isString);return new Set([...this.geojson?[this.geojson]:[],...p])}producedFields(){return new Set}hash(){return`GeoJSON ${this.geojson} ${this.signal} ${kt(this.fields)}`}assemble(){return[...this.geojson?[{type:"filter",expr:`isValid(datum["${this.geojson}"])`}]:[],{type:"geojson",...this.fields?{fields:this.fields}:{},...this.geojson?{geojson:this.geojson}:{},signal:this.signal}]}}class Eb extends Tn{clone(){return new Eb(null,this.projection,st(this.fields),st(this.as))}constructor(p,_,x,S){super(p),this.projection=_,this.fields=x,this.as=S}static parseAll(p,_){if(!_.projectionName())return p;for(const x of[[Ho,It],[ae,wr]]){const S=x.map(O=>{const P=Oo(_.encoding[O]);return dt(P)?P.field:Sd(P)?{expr:`${P.datum}`}:Ma(P)?{expr:`${P.value}`}:void 0}),A=x[0]===ae?"2":"";(S[0]||S[1])&&(p=new Eb(p,_.projectionName(),S,[_.getName(`x${A}`),_.getName(`y${A}`)]))}return p}dependentFields(){return new Set(this.fields.filter(re.isString))}producedFields(){return new Set(this.as)}hash(){return`Geopoint ${this.projection} ${kt(this.fields)} ${kt(this.as)}`}assemble(){return{type:"geopoint",projection:this.projection,fields:this.fields,as:this.as}}}class Gg extends Tn{clone(){return new Gg(null,st(this.transform))}constructor(p,_){super(p),this.transform=_}dependentFields(){return new Set([this.transform.impute,this.transform.key,...this.transform.groupby??[]])}producedFields(){return new Set([this.transform.impute])}processSequence(p){const{start:_=0,stop:x,step:S}=p;return{signal:`sequence(${[_,x,...S?[S]:[]].join(",")})`}}static makeFromTransform(p,_){return new Gg(p,_)}static makeFromEncoding(p,_){const x=_.encoding,S=x.x,A=x.y;if(dt(S)&&dt(A)){const O=S.impute?S:A.impute?A:void 0;if(void 0===O)return;const P=S.impute?A:A.impute?S:void 0,{method:B,value:q,frame:G,keyvals:ee}=O.impute,se=Od(_.mark,x);return new Gg(p,{impute:O.field,key:P.field,...B?{method:B}:{},...void 0!==q?{value:q}:{},...G?{frame:G}:{},...void 0!==ee?{keyvals:ee}:{},...se.length?{groupby:se}:{}})}return null}hash(){return`Impute ${kt(this.transform)}`}assemble(){const{impute:p,key:_,keyvals:x,method:S,groupby:A,value:O,frame:P=[null,null]}=this.transform,B={type:"impute",field:p,key:_,...x?{keyvals:(d=x,void 0!==d?.stop?this.processSequence(x):x)}:{},method:"value",...A?{groupby:A}:{},value:S&&"value"!==S?null:O};var d;return S&&"value"!==S?[B,{type:"window",as:[`imputed_${p}_value`],ops:[S],fields:[p],frame:P,ignorePeers:!1,...A?{groupby:A}:{}},{type:"formula",expr:`datum.${p} === null ? datum.imputed_${p}_value : datum.${p}`,as:p}]:[B]}}class Xx extends Tn{clone(){return new Xx(null,st(this.transform))}constructor(p,_){super(p),this.transform=_,this.transform=st(_);const x=this.transform.as??[void 0,void 0];this.transform.as=[x[0]??_.on,x[1]??_.loess]}dependentFields(){return new Set([this.transform.loess,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`LoessTransform ${kt(this.transform)}`}assemble(){const{loess:p,on:_,...x}=this.transform;return{type:"loess",x:_,y:p,...x}}}class Yx extends Tn{clone(){return new Yx(null,st(this.transform),this.secondary)}constructor(p,_,x){super(p),this.transform=_,this.secondary=x}static make(p,_,x,S){const A=_.component.data.sources,{from:O}=x;let P=null;if(function rx(d){return"data"in d}(O)){let B=tw(O.data,A);B||(B=new Xd(O.data),A.push(B));const q=_.getName(`lookup_${S}`);P=new jr(B,q,Vr.Lookup,_.component.data.outputNodeRefCounts),_.component.data.outputNodes[q]=P}else if(function UA(d){return"param"in d}(O)){const B=O.param;let q;x={as:B,...x};try{q=_.getSelectionComponent(hn(B),B)}catch{throw new Error(function kr(d){return`Lookups can only be performed on selection parameters. "${d}" is a variable parameter.`}(B))}if(P=q.materialized,!P)throw new Error(function Ca(d){return`Cannot define and lookup the "${d}" selection in the same view. Try moving the lookup into a second, layered view?`}(B))}return new Yx(p,x,P.getSource())}dependentFields(){return new Set([this.transform.lookup])}producedFields(){return new Set(this.transform.as?re.array(this.transform.as):this.transform.from.fields)}hash(){return`Lookup ${kt({transform:this.transform,secondary:this.secondary})}`}assemble(){let p;if(this.transform.from.fields)p={values:this.transform.from.fields,...this.transform.as?{as:re.array(this.transform.as)}:{}};else{let _=this.transform.as;re.isString(_)||(nt('If "from.fields" is not specified, "as" has to be a string that specifies the key to be used for the data from the secondary source.'),_="_lookup"),p={as:[_]}}return{type:"lookup",from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup],...p,...this.transform.default?{default:this.transform.default}:{}}}}class Kx extends Tn{clone(){return new Kx(null,st(this.transform))}constructor(p,_){super(p),this.transform=_,this.transform=st(_);const x=this.transform.as??[void 0,void 0];this.transform.as=[x[0]??"prob",x[1]??"value"]}dependentFields(){return new Set([this.transform.quantile,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`QuantileTransform ${kt(this.transform)}`}assemble(){const{quantile:p,..._}=this.transform;return{type:"quantile",field:p,..._}}}class Zx extends Tn{clone(){return new Zx(null,st(this.transform))}constructor(p,_){super(p),this.transform=_,this.transform=st(_);const x=this.transform.as??[void 0,void 0];this.transform.as=[x[0]??_.on,x[1]??_.regression]}dependentFields(){return new Set([this.transform.regression,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`RegressionTransform ${kt(this.transform)}`}assemble(){const{regression:p,on:_,...x}=this.transform;return{type:"regression",x:_,y:p,...x}}}class Qx extends Tn{clone(){return new Qx(null,st(this.transform))}constructor(p,_){super(p),this.transform=_}addDimensions(p){this.transform.groupby=Ci((this.transform.groupby??[]).concat(p),_=>_)}producedFields(){}dependentFields(){return new Set([this.transform.pivot,this.transform.value,...this.transform.groupby??[]])}hash(){return`PivotTransform ${kt(this.transform)}`}assemble(){const{pivot:p,value:_,groupby:x,limit:S,op:A}=this.transform;return{type:"pivot",field:p,value:_,...void 0!==S?{limit:S}:{},...void 0!==A?{op:A}:{},...void 0!==x?{groupby:x}:{}}}}class Xg extends Tn{clone(){return new Xg(null,st(this.transform))}constructor(p,_){super(p),this.transform=_}dependentFields(){return new Set}producedFields(){return new Set}hash(){return`SampleTransform ${kt(this.transform)}`}assemble(){return{type:"sample",size:this.transform.sample}}}function Yg(d){let p=0;return function _(x,S){if(x instanceof Xd&&!x.isGenerator&&!ka(x.data)&&(d.push(S),S={name:null,source:S.name,transform:[]}),x instanceof ys&&(x.parent instanceof Xd&&!S.source?(S.format={...S.format??{},parse:x.assembleFormatParse()},S.transform.push(...x.assembleTransforms(!0))):S.transform.push(...x.assembleTransforms())),x instanceof oh)return S.name||(S.name="data_"+p++),!S.source||S.transform.length>0?(d.push(S),x.data=S.name):x.data=S.source,void d.push(...x.assemble());switch((x instanceof Gd||x instanceof Up||x instanceof Zd||x instanceof Cl||x instanceof Rp||x instanceof Eb||x instanceof No||x instanceof Yx||x instanceof zg||x instanceof zu||x instanceof Kp||x instanceof Yp||x instanceof Vs||x instanceof Xx||x instanceof Kx||x instanceof Zx||x instanceof sh||x instanceof Xg||x instanceof Qx||x instanceof Xp)&&S.transform.push(x.assemble()),(x instanceof il||x instanceof el||x instanceof Gg||x instanceof Yd||x instanceof qg)&&S.transform.push(...x.assemble()),x instanceof jr&&(S.source&&0===S.transform.length?x.setSource(S.source):x.parent instanceof jr?x.setSource(S.name):(S.name||(S.name="data_"+p++),x.setSource(S.name),1===x.numChildren()&&(d.push(S),S={name:null,source:S.name,transform:[]}))),x.numChildren()){case 0:x instanceof jr&&(!S.source||S.transform.length>0)&&d.push(S);break;case 1:_(x.children[0],S);break;default:{S.name||(S.name="data_"+p++);let A=S.name;!S.source||S.transform.length>0?d.push(S):A=S.source;for(const O of x.children)_(O,{name:null,source:A,transform:[]});break}}}}function XT(d){return"top"===d||"left"===d||Je(d)?"header":"footer"}function YT(d,p){const{facet:_,config:x,child:S,component:A}=d;if(d.channelHasField(p)){const O=_[p],P=kg("title",null,x,p);let B=cp(O,x,{allowDisabling:!0,includeDefault:void 0===P||!!P});S.component.layoutHeaders[p].title&&(B=re.isArray(B)?B.join(", "):B,B+=` / ${S.component.layoutHeaders[p].title}`,S.component.layoutHeaders[p].title=null);const q=kg("labelOrient",O.header,x,p),G=null!==O.header&&ui(O.header?.labels,x.header.labels,!0),ee=St(["bottom","right"],q)?"footer":"header";A.layoutHeaders[p]={title:null!==O.header?B:null,facetFieldDef:O,[ee]:"facet"===p?[]:[KT(d,p,G)]}}}function KT(d,p,_){const x="row"===p?"height":"width";return{labels:_,sizeSignal:d.child.component.layoutSize.get(x)?d.child.getSizeSignalRef(x):void 0,axes:[]}}function Qd(d,p){const{child:_}=d;if(_.component.axes[p]){const{layoutHeaders:x,resolve:S}=d.component;if(S.axis[p]=Ig(S,p),"shared"===S.axis[p]){const A="x"===p?"column":"row",O=x[A];for(const P of _.component.axes[p]){const B=XT(P.get("orient"));O[B]??=[KT(d,A,!1)];const q=rb(P,"main",d.config,{header:!0});q&&O[B][0].axes.push(q),P.mainExtracted=!0}}}}function ew(d){for(const p of d.children)p.parseLayoutSize()}function Zp(d,p){const _=yT(p),x=If(_),S=d.component.resolve,A=d.component.layoutSize;let O;for(const P of d.children){const B=P.component.layoutSize.getWithExplicit(_),q=S.scale[x]??o3(x,d);if("independent"===q&&"step"===B.value){O=void 0;break}if(O){if("independent"===q&&O.value!==B.value){O=void 0;break}O=Qa(O,B,_,"")}else O=B}if(O){for(const P of d.children)d.renameSignal(P.getName(_),d.getName(p)),P.component.layoutSize.set(_,"merged",!1);A.setWithExplicit(p,O)}else A.setWithExplicit(p,{explicit:!1,value:void 0})}function SR(d,p){const x=d.config,S=d.getScaleComponent("width"===p?"x":"y");if(S){const A=S.get("type"),O=S.get("range");if(ko(A)){const P=lo(x.view,p);return ht(O)||Fd(P)?"step":P}return Aa(x.view,p)}if(d.hasProjection||"arc"===d.mark)return Aa(x.view,p);{const A=lo(x.view,p);return Fd(A)?A.step:A}}function qC(d,p,_){return pt(p,{suffix:`by_${pt(d)}`,..._??{}})}class Sb extends Wg{constructor(p,_,x,S){super(p,"facet",_,x,S,p.resolve),ln(this,"facet",void 0),ln(this,"child",void 0),ln(this,"children",void 0),this.child=Jr(p.spec,this,this.getName("child"),void 0,S),this.children=[this.child],this.facet=this.initFacet(p.facet)}initFacet(p){if(!og(p))return{facet:this.initFacetFieldDef(p,"facet")};const _=We(p),x={};for(const S of _){if(![ea,Xl].includes(S)){nt(bo(S,"facet"));break}const A=p[S];if(void 0===A.field){nt(Nr(A,S));break}x[S]=this.initFacetFieldDef(A,S)}return x}initFacetFieldDef(p,_){const x=cg(p,_);return x.header?x.header=_o(x.header):null===x.header&&(x.header=null),x}channelHasField(p){return!!this.facet[p]}fieldDef(p){return this.facet[p]}parseData(){this.component.data=gc(this),this.child.parseData()}parseLayoutSize(){ew(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),function Cb(d){for(const p of Zl)YT(d,p);Qd(d,"x"),Qd(d,"y")}(this)}assembleSelectionTopLevelSignals(p){return this.child.assembleSelectionTopLevelSignals(p)}assembleSignals(){return this.child.assembleSignals(),[]}assembleSelectionData(p){return this.child.assembleSelectionData(p)}getHeaderLayoutMixins(){const p={};for(const _ of Zl)for(const x of Sx){const S=this.component.layoutHeaders[_],A=S[x],{facetFieldDef:O}=S;if(O){const P=kg("titleOrient",O.header,this.config,_);if(["right","bottom"].includes(P)){const B=sb(_,P);p.titleAnchor??={},p.titleAnchor[B]="end"}}if(A?.[0]){const B="header"===x?"headerBand":"footerBand";"facet"!==_&&!this.child.component.layoutSize.get("row"===_?"height":"width")&&(p[B]??={},p[B][_]=.5),S.title&&(p.offset??={},p.offset["row"===_?"rowTitle":"columnTitle"]=10)}}return p}assembleDefaultLayout(){const{column:p,row:_}=this.facet,x=p?this.columnDistinctSignal():_?1:void 0;let S="all";return(!_&&"independent"===this.component.resolve.scale.x||!p&&"independent"===this.component.resolve.scale.y)&&(S="none"),{...this.getHeaderLayoutMixins(),...x?{columns:x}:{},bounds:"full",align:S}}assembleLayoutSignals(){return this.child.assembleLayoutSignals()}columnDistinctSignal(){if(!(this.parent&&this.parent instanceof Sb))return{signal:`length(data('${this.getName("column_domain")}'))`}}assembleGroupStyle(){}assembleGroup(p){return this.parent&&this.parent instanceof Sb?{...this.channelHasField("column")?{encode:{update:{columns:{field:pt(this.facet.column,{prefix:"distinct"})}}}}:{},...super.assembleGroup(p)}:super.assembleGroup(p)}getCardinalityAggregateForChild(){const p=[],_=[],x=[];if(this.child instanceof Sb){if(this.child.channelHasField("column")){const S=pt(this.child.facet.column);p.push(S),_.push("distinct"),x.push(`distinct_${S}`)}}else for(const S of Ql){const A=this.child.component.scales[S];if(A&&!A.merged){const O=A.get("type"),P=A.get("range");if(ko(O)&&ht(P)){const q=NC(Wp(this.child,S));q?(p.push(q),_.push("distinct"),x.push(`distinct_${q}`)):nt(Tr(S))}}}return{fields:p,ops:_,as:x}}assembleFacet(){const{name:p,data:_}=this.component.data.facetRoot,{row:x,column:S}=this.facet,{fields:A,ops:O,as:P}=this.getCardinalityAggregateForChild(),B=[];for(const G of Zl){const ee=this.facet[G];if(ee){B.push(pt(ee));const{bin:se,sort:Ee}=ee;if(sr(se)&&B.push(pt(ee,{binSuffix:"end"})),sa(Ee)){const{field:De,op:Re=ig}=Ee,Le=qC(ee,Ee);x&&S?(A.push(Le),O.push("max"),P.push(Le)):(A.push(De),O.push(Re),P.push(Le))}else if(re.isArray(Ee)){const De=Np(ee,G);A.push(De),O.push("max"),P.push(De)}}}const q=!!x&&!!S;return{name:p,data:_,groupby:B,...q||A.length>0?{aggregate:{...q?{cross:q}:{},...A.length?{fields:A,ops:O,as:P}:{}}}:{}}}facetSortFields(p){const{facet:_}=this,x=_[p];return x?sa(x.sort)?[qC(x,x.sort,{expr:"datum"})]:re.isArray(x.sort)?[Np(x,p,{expr:"datum"})]:[pt(x,{expr:"datum"})]:[]}facetSortOrder(p){const{facet:_}=this,x=_[p];if(x){const{sort:S}=x;return[(sa(S)?S.order:!re.isArray(S)&&S)||"ascending"]}return[]}assembleLabelTitle(){const{facet:p,config:_}=this;if(p.facet)return _T(p.facet,"facet",_);const x={row:["top","bottom"],column:["left","right"]};for(const S of gC)if(p[S]){const A=kg("labelOrient",p[S]?.header,_,S);if(x[S].includes(A))return _T(p[S],S,_)}}assembleMarks(){const{child:p}=this,x=function WC(d){const p=[],_=Yg(p);for(const x of d.children)_(x,{source:d.name,name:null,transform:[]});return p}(this.component.data.facetRoot),S=p.assembleGroupEncodeEntry(!1),A=this.assembleLabelTitle()||p.assembleTitle(),O=p.assembleGroupStyle();return[{name:this.getName("cell"),type:"group",...A?{title:A}:{},...O?{style:O}:{},from:{facet:this.assembleFacet()},sort:{field:Zl.map(B=>this.facetSortFields(B)).flat(),order:Zl.map(B=>this.facetSortOrder(B)).flat()},...x.length>0?{data:x}:{},...S?{encode:{update:S}}:{},...p.assembleGroup(cR(this,[]))}]}getMapping(){return this.facet}}function tw(d,p){for(const _ of p){const x=_.data;if(d.name&&_.hasName()&&d.name!==_.dataName)continue;const S=d.format?.mesh,A=x.format?.feature;if(S&&A)continue;const O=d.format?.feature;if((O||A)&&O!==A)continue;const P=x.format?.mesh;if(!S&&!P||S===P)if(Wy(d)&&Wy(x)){if(xr(d.values,x.values))return _}else if(ka(d)&&ka(x)){if(d.url===x.url)return _}else if(ZA(d)&&d.name===_.dataName)return _}return null}function gc(d){let p=function Db(d,p){if(d.data||!d.parent){if(null===d.data){const x=new Xd({values:[]});return p.push(x),x}const _=tw(d.data,p);if(_)return Jf(d.data)||(_.data.format=qi({},d.data.format,_.data.format)),!_.hasName()&&d.data.name&&(_.dataName=d.data.name),_;{const x=new Xd(d.data);return p.push(x),x}}return d.parent.component.data.facetRoot?d.parent.component.data.facetRoot:d.parent.component.data.main}(d,d.component.data.sources);const{outputNodes:_,outputNodeRefCounts:x}=d.component.data,S=d.data,O=S&&(Jf(S)||ka(S)||Wy(S))||!d.parent?new Gc:d.parent.component.data.ancestorParse.clone();Jf(S)?(QA(S)?p=new Up(p,S.sequence):cc(S)&&(p=new Gd(p,S.graticule)),O.parseNothing=!0):null===S?.format?.parse&&(O.parseNothing=!0),p=ys.makeExplicit(p,d,O)??p,p=new sh(p);const P=d.parent&&Hg(d.parent);(uo(d)||mc(d))&&P&&(p=il.makeFromEncoding(p,d)??p),d.transforms.length>0&&(p=function nw(d,p,_){let x=0;for(const S of p.transforms){let A,O;if(sR(S))O=d=new Rp(d,S),A="derived";else if(Vy(S)){const P=ST(S);O=d=ys.makeWithAncestors(d,{},P,_)??d,d=new Cl(d,p,S.filter)}else if(BE(S))O=d=il.makeFromTransform(d,S,p),A="number";else if(zE(S))A="date",void 0===_.getWithExplicit(S.field).value&&(d=new ys(d,{[S.field]:A}),_.set(S.field,A,!1)),O=d=el.makeFromTransform(d,S);else if(VE(S))O=d=No.makeFromTransform(d,S),A="number",nh(p)&&(d=new sh(d));else if(bg(S))O=d=Yx.make(d,p,S,x++),A="derived";else if(oR(S))O=d=new zg(d,S),A="number";else if(e3(S))O=d=new zu(d,S),A="number";else if(qA(S))O=d=Yd.makeFromTransform(d,S),A="derived";else if(ax(S))O=d=new Kp(d,S),A="derived";else if(vp(S))O=d=new Xp(d,S),A="derived";else if(sx(S))O=d=new Yp(d,S),A="derived";else if(rR(S))O=d=new Qx(d,S),A="derived";else if(HA(S))d=new Xg(d,S);else if(WA(S))O=d=Gg.makeFromTransform(d,S),A="derived";else if(LE(S))O=d=new Vs(d,S),A="derived";else if(ox(S))O=d=new Kx(d,S),A="derived";else if(bp(S))O=d=new Zx(d,S),A="derived";else{if(!$E(S)){nt(Eu(S));continue}O=d=new Xx(d,S),A="derived"}if(O&&void 0!==A)for(const P of O.producedFields()??[])_.set(P,A,!1)}return d}(p,d,O));const B=function zx(d){const p={};if(uo(d)&&d.component.selection)for(const _ of We(d.component.selection)){const x=d.component.selection[_];for(const S of x.project.items)!S.channel&&ro(S.field)>1&&(p[S.field]="flatten")}return p}(d),q=DT(d);p=ys.makeWithAncestors(p,{},{...B,...q},O)??p,uo(d)&&(p=qg.parseAll(p,d),p=Eb.parseAll(p,d)),(uo(d)||mc(d))&&(P||(p=il.makeFromEncoding(p,d)??p),p=el.makeFromEncoding(p,d)??p,p=Rp.parseAllForSortIndex(p,d));const G=d.getDataName(Vr.Raw),ee=new jr(p,G,Vr.Raw,x);if(_[G]=ee,p=ee,uo(d)){const Re=No.makeFromEncoding(p,d);Re&&(p=Re,nh(d)&&(p=new sh(p))),p=Gg.makeFromEncoding(p,d)??p,p=Yd.makeFromEncoding(p,d)??p}uo(d)&&(p=Zd.make(p,d)??p);const se=d.getDataName(Vr.Main),Ee=new jr(p,se,Vr.Main,x);_[se]=Ee,p=Ee,uo(d)&&function fT(d,p){for(const[_,x]of Jt(d.component.selection??{})){const S=d.getName(`lookup_${_}`);d.component.data.outputNodes[S]=x.materialized=new jr(new Cl(p,d,{param:_}),S,Vr.Lookup,d.component.data.outputNodeRefCounts)}}(d,Ee);let De=null;if(mc(d)){const Re=d.getName("facet");p=function GC(d,p){const{row:_,column:x}=p;if(_&&x){let S=null;for(const A of[_,x])if(sa(A.sort)){const{field:O,op:P=ig}=A.sort;d=S=new zu(d,{joinaggregate:[{op:P,field:O,as:qC(A,A.sort,{forAs:!0})}],groupby:[pt(A)]})}return S}return null}(p,d.facet)??p,De=new oh(p,d,Re,Ee.getSource()),_[Re]=De}return{...d.component.data,outputNodes:_,outputNodeRefCounts:x,raw:ee,main:Ee,facetRoot:De,ancestorParse:O}}class a3 extends Hu{constructor(p,_,x,S){super(p,"concat",_,x,S,p.resolve),ln(this,"children",void 0),("shared"===p.resolve?.axis?.x||"shared"===p.resolve?.axis?.y)&&nt("Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415)."),this.children=this.getChildren(p).map((A,O)=>Jr(A,this,this.getName(`concat_${O}`),void 0,S))}parseData(){this.component.data=gc(this);for(const p of this.children)p.parseData()}parseSelections(){this.component.selection={};for(const p of this.children){p.parseSelections();for(const _ of We(p.component.selection))this.component.selection[_]=p.component.selection[_]}}parseMarkGroup(){for(const p of this.children)p.parseMarkGroup()}parseAxesAndHeaders(){for(const p of this.children)p.parseAxesAndHeaders()}getChildren(p){return mg(p)?p.vconcat:Oy(p)?p.hconcat:p.concat}parseLayoutSize(){!function ER(d){ew(d);const _=void 0===d.layout.columns?"height":"childHeight";Zp(d,1===d.layout.columns?"width":"childWidth"),Zp(d,_)}(this)}parseAxisGroup(){return null}assembleSelectionTopLevelSignals(p){return this.children.reduce((_,x)=>x.assembleSelectionTopLevelSignals(_),p)}assembleSignals(){return this.children.forEach(p=>p.assembleSignals()),[]}assembleLayoutSignals(){const p=cb(this);for(const _ of this.children)p.push(..._.assembleLayoutSignals());return p}assembleSelectionData(p){return this.children.reduce((_,x)=>x.assembleSelectionData(_),p)}assembleMarks(){return this.children.map(p=>{const _=p.assembleTitle(),x=p.assembleGroupStyle(),S=p.assembleGroupEncodeEntry(!1);return{type:"group",name:p.getName("group"),..._?{title:_}:{},...x?{style:x}:{},...S?{encode:{update:S}}:{},...p.assembleGroup()}})}assembleGroupStyle(){}assembleDefaultLayout(){const p=this.layout.columns;return{...null!=p?{columns:p}:{},bounds:"full",align:"each"}}}const MR={disable:1,gridScale:1,scale:1,...Ou,labelExpr:1,encode:1},Mb=We(MR);class iw extends Za{constructor(){let p=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},_=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},x=arguments.length>2&&void 0!==arguments[2]&&arguments[2];super(),this.explicit=p,this.implicit=_,this.mainExtracted=x}clone(){return new iw(st(this.explicit),st(this.implicit),this.mainExtracted)}hasAxisPart(p){return"axis"===p||("grid"===p||"title"===p?!!this.get(p):!function DR(d){return!1===d||null===d}(this.get(p)))}hasOrientSignalRef(){return Je(this.explicit.orient)}}const ow={bottom:"top",top:"bottom",left:"right",right:"left"};function XC(d,p){if(!d)return p.map(_=>_.clone());{if(d.length!==p.length)return;const _=d.length;for(let x=0;x<_;x++){const S=d[x],A=p[x];if(!!S!=!!A)return;if(S&&A){const O=S.getWithExplicit("orient"),P=A.getWithExplicit("orient");if(O.explicit&&P.explicit&&O.value!==P.value)return;d[x]=QT(S,A)}}}return d}function QT(d,p){for(const _ of Mb){const x=Qa(d.getWithExplicit(_),p.getWithExplicit(_),_,"axis",(S,A)=>{switch(_){case"title":return BM(S,A);case"gridScale":return{explicit:S.explicit,value:ui(S.value,A.value)}}return Pu(S,A,_,"axis")});d.setWithExplicit(_,x)}return d}function Wu(d,p,_,x,S){if("disable"===p)return void 0!==_;switch(_=_||{},p){case"titleAngle":case"labelAngle":return d===(Je(_.labelAngle)?_.labelAngle:$i(_.labelAngle));case"values":return!!_.values;case"encode":return!!_.encoding||!!_.labelAngle;case"title":if(d===Op(x,S))return!0}return d===_[p]}const Dl=new Set(["grid","translate","format","formatType","orient","labelExpr","tickCount","position","tickMinStep"]);function JT(d,p){let _=p.axis(d);const x=new iw,S=Oo(p.encoding[d]),{mark:A,config:O}=p,P=_?.orient||O["x"===d?"axisX":"axisY"]?.orient||O.axis?.orient||function pC(d){return"x"===d?"bottom":"left"}(d),B=p.getScaleComponent(d).get("type"),q=function cC(d,p,_,x){const S="band"===p?["axisDiscrete","axisBand"]:"point"===p?["axisDiscrete","axisPoint"]:uy(p)?["axisQuantitative"]:"time"===p||"utc"===p?["axisTemporal"]:[],A="x"===d?"axisX":"axisY",O=Je(_)?"axisOrient":`axis${Mo(_)}`,P=[...S,...S.map(q=>A+q.substr(4))],B=["axis",O,A];return{vlOnlyAxisConfig:yx(P,x,d,_),vgAxisConfig:yx(B,x,d,_),axisConfigStyle:uC([...B,...P],x)}}(d,B,P,p.config),G=void 0!==_?!_:bx("disable",O.style,_?.style,q).configValue;if(x.set("disable",G,void 0!==_),G)return x;_=_||{};const ee=function xx(d,p,_,x,S){const A=p?.labelAngle;if(void 0!==A)return Je(A)?A:$i(A);{const{configValue:O}=bx("labelAngle",x,p?.style,S);return void 0!==O?$i(O):_!==Ri||!St([wv,Os],d.type)||dt(d)&&d.timeUnit?void 0:270}}(S,_,d,O.style,q),se=gy(_.formatType,S,B),Ee=Hf(S,S.type,_.format,_.formatType,O,!0),De={fieldOrDatumDef:S,axis:_,channel:d,model:p,scaleType:B,orient:P,labelAngle:ee,format:Ee,formatType:se,mark:A,config:O};for(const Ye of Mb){const bt=Ye in dC?dC[Ye](De):wy(Ye)?_[Ye]:void 0,kn=void 0!==bt,dn=Wu(bt,Ye,_,p,d);if(kn&&dn)x.set(Ye,bt,dn);else{const{configValue:vi,configFrom:lr}=wy(Ye)&&"values"!==Ye?bx(Ye,O.style,_.style,q):{},ca=void 0!==vi;kn&&!ca?x.set(Ye,bt,dn):("vgAxisConfig"!==lr||Dl.has(Ye)&&ca||Xf(vi)||Je(vi))&&x.set(Ye,vi,!1)}}const Re=_.encoding??{},Le=yE.reduce((Ye,bt)=>{if(!x.hasAxisPart(bt))return Ye;const kn=Ax(Re[bt]??{},p),dn="labels"===bt?function rw(d,p,_){const{encoding:x,config:S}=d,A=Oo(x[p])??Oo(x[Or(p)]),O=d.axis(p)||{},{format:P,formatType:B}=O;if(Uc(B))return{text:Ns({fieldOrDatumDef:A,field:"datum.value",format:P,formatType:B,config:S}),..._};if(void 0===P&&void 0===B&&S.customFormatTypes){if("quantitative"===Qr(A)){if(Dd(A)&&"normalize"===A.stack&&S.normalizedNumberFormatType)return{text:Ns({fieldOrDatumDef:A,field:"datum.value",format:S.normalizedNumberFormat,formatType:S.normalizedNumberFormatType,config:S}),..._};if(S.numberFormatType)return{text:Ns({fieldOrDatumDef:A,field:"datum.value",format:S.numberFormat,formatType:S.numberFormatType,config:S}),..._}}if("temporal"===Qr(A)&&S.timeFormatType&&dt(A)&&!A.timeUnit)return{text:Ns({fieldOrDatumDef:A,field:"datum.value",format:S.timeFormat,formatType:S.timeFormatType,config:S}),..._}}return _}(p,d,kn):kn;return void 0!==dn&&!Gt(dn)&&(Ye[bt]={update:dn}),Ye},{});return Gt(Le)||x.set("encode",Le,!!_.encoding||void 0!==_.labelAngle),x}function Jp(d,p){const{config:_}=d;return{..._s(d,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...Ia("x",d,{defaultPos:"mid"}),...Ia("y",d,{defaultPos:"mid"}),...gs("size",d),...gs("angle",d),...Jd(d,0,p)}}function Jd(d,p,_){return _?{shape:{value:_}}:gs("shape",d)}function QC(d,p,_){if(void 0===Ji("align",d,_))return"center"}function kb(d,p,_){if(void 0===Ji("baseline",d,_))return"middle"}function Qg(d){const{config:p,markDef:_}=d,{orient:x}=_,S="horizontal"===x?"width":"height",A=d.getScaleComponent("horizontal"===x?"x":"y"),O=Ji("size",_,p,{vgChannel:S})??p.tick.bandSize;if(void 0!==O)return O;{const P=A?A.get("range"):void 0;return P&&ht(P)&&re.isNumber(P.step)?3*P.step/4:3*pr(p.view,S)/4}}const Ur={arc:{vgMark:"arc",encodeEntry:d=>({..._s(d,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...Ia("x",d,{defaultPos:"mid"}),...Ia("y",d,{defaultPos:"mid"}),...El(d,"radius"),...El(d,"theta")})},area:{vgMark:"area",encodeEntry:d=>({..._s(d,{align:"ignore",baseline:"ignore",color:"include",orient:"include",size:"ignore",theta:"ignore"}),...$u("x",d,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:"horizontal"===d.markDef.orient}),...$u("y",d,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:"vertical"===d.markDef.orient}),...Sg(d)})},bar:{vgMark:"rect",encodeEntry:d=>({..._s(d,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...El(d,"x"),...El(d,"y")})},circle:{vgMark:"symbol",encodeEntry:d=>Jp(d,"circle")},geoshape:{vgMark:"shape",encodeEntry:d=>({..._s(d,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"})}),postEncodingTransform:d=>{const{encoding:p}=d,_=p.shape;return[{type:"geoshape",projection:d.projectionName(),..._&&dt(_)&&_.type===Sa?{field:pt(_,{expr:"datum"})}:{}}]}},image:{vgMark:"image",encodeEntry:d=>({..._s(d,{align:"ignore",baseline:"ignore",color:"ignore",orient:"ignore",size:"ignore",theta:"ignore"}),...El(d,"x"),...El(d,"y"),...KE(d,"url")})},line:{vgMark:"line",encodeEntry:d=>({..._s(d,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...Ia("x",d,{defaultPos:"mid"}),...Ia("y",d,{defaultPos:"mid"}),...gs("size",d,{vgChannel:"strokeWidth"}),...Sg(d)})},point:{vgMark:"symbol",encodeEntry:d=>Jp(d)},rect:{vgMark:"rect",encodeEntry:d=>({..._s(d,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...El(d,"x"),...El(d,"y")})},rule:{vgMark:"rule",encodeEntry:d=>{const{markDef:p}=d,_=p.orient;return d.encoding.x||d.encoding.y||d.encoding.latitude||d.encoding.longitude?{..._s(d,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...$u("x",d,{defaultPos:"horizontal"===_?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:"vertical"!==_}),...$u("y",d,{defaultPos:"vertical"===_?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:"horizontal"!==_}),...gs("size",d,{vgChannel:"strokeWidth"})}:{}}},square:{vgMark:"symbol",encodeEntry:d=>Jp(d,"square")},text:{vgMark:"text",encodeEntry:d=>{const{config:p,encoding:_}=d;return{..._s(d,{align:"include",baseline:"include",color:"include",size:"ignore",orient:"ignore",theta:"include"}),...Ia("x",d,{defaultPos:"mid"}),...Ia("y",d,{defaultPos:"mid"}),...KE(d),...gs("size",d,{vgChannel:"fontSize"}),...gs("angle",d),...aT("align",QC(d.markDef,0,p)),...aT("baseline",kb(d.markDef,0,p)),...Ia("radius",d,{defaultPos:null}),...Ia("theta",d,{defaultPos:null})}}},tick:{vgMark:"rect",encodeEntry:d=>{const{config:p,markDef:_}=d,x=_.orient,S="horizontal"===x?"width":"height",A="horizontal"===x?"height":"width";return{..._s(d,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Ia("x",d,{defaultPos:"mid",vgChannel:"xc"}),...Ia("y",d,{defaultPos:"mid",vgChannel:"yc"}),...gs("size",d,{defaultValue:Qg(d),vgChannel:S}),[A]:Ar(Ji("thickness",_,p))}}},trail:{vgMark:"trail",encodeEntry:d=>({..._s(d,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...Ia("x",d,{defaultPos:"mid"}),...Ia("y",d,{defaultPos:"mid"}),...gs("size",d),...Sg(d)})}};function hh(d){if(St([wd,xd,H2],d.mark)){const p=Od(d.mark,d.encoding);if(p.length>0)return function rl(d,p){return[{name:d.getName("pathgroup"),type:"group",from:{facet:{name:_c+d.requestDataName(Vr.Main),data:d.requestDataName(Vr.Main),groupby:p}},encode:{update:{width:{field:{group:"width"}},height:{field:{group:"height"}}}},marks:Ib(d,{fromPrefix:_c})}]}(d,p)}else if(d.mark===_l){const p=rv.some(_=>Ji(_,d.markDef,d.config));if(d.stack&&!d.fieldDef("size")&&p)return function en(d){const[p]=Ib(d,{fromPrefix:cw}),_=d.scaleName(d.stack.fieldChannel),x=function(){return d.vgField(d.stack.fieldChannel,arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})},S=(q,G)=>`${q}(${[x({prefix:"min",suffix:"start",expr:G}),x({prefix:"max",suffix:"start",expr:G}),x({prefix:"min",suffix:"end",expr:G}),x({prefix:"max",suffix:"end",expr:G})].map(se=>`scale('${_}',${se})`).join(",")})`;let A,O;"x"===d.stack.fieldChannel?(A={...Sn(p.encode.update,["y","yc","y2","height",...rv]),x:{signal:S("min","datum")},x2:{signal:S("max","datum")},clip:{value:!0}},O={x:{field:{group:"x"},mult:-1},height:{field:{group:"height"}}},p.encode.update={...yt(p.encode.update,["y","yc","y2"]),height:{field:{group:"height"}}}):(A={...Sn(p.encode.update,["x","xc","x2","width"]),y:{signal:S("min","datum")},y2:{signal:S("max","datum")},clip:{value:!0}},O={y:{field:{group:"y"},mult:-1},width:{field:{group:"width"}}},p.encode.update={...yt(p.encode.update,["x","xc","x2"]),width:{field:{group:"width"}}});for(const q of rv){const G=xu(q,d.markDef,d.config);p.encode.update[q]?(A[q]=p.encode.update[q],delete p.encode.update[q]):G&&(A[q]=Ar(G)),G&&(p.encode.update[q]={value:0})}const P=[];if(d.stack.groupbyChannels?.length>0)for(const q of d.stack.groupbyChannels){const G=d.fieldDef(q),ee=pt(G);ee&&P.push(ee),(G?.bin||G?.timeUnit)&&P.push(pt(G,{binSuffix:"end"}))}return A=["stroke","strokeWidth","strokeJoin","strokeCap","strokeDash","strokeDashOffset","strokeMiterLimit","strokeOpacity"].reduce((q,G)=>{if(p.encode.update[G])return{...q,[G]:p.encode.update[G]};{const ee=xu(G,d.markDef,d.config);return void 0!==ee?{...q,[G]:Ar(ee)}:q}},A),A.stroke&&(A.strokeForeground={value:!0},A.strokeOffset={value:0}),[{type:"group",from:{facet:{data:d.requestDataName(Vr.Main),name:cw+d.requestDataName(Vr.Main),groupby:P,aggregate:{fields:[x({suffix:"start"}),x({suffix:"start"}),x({suffix:"end"}),x({suffix:"end"})],ops:["min","max","min","max"]}}},encode:{update:A},marks:[{type:"group",encode:{update:O},marks:[p]}]}]}(d)}return Ib(d)}const _c="faceted_path_";const cw="stack_group_";function Ib(d){let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{fromPrefix:""};const{mark:_,markDef:x,encoding:S,config:A}=d,O=ui(x.clip,function Jg(d){const p=d.getScaleComponent("x"),_=d.getScaleComponent("y");return!(!p?.get("selectionExtent")&&!_?.get("selectionExtent"))||void 0}(d),function e_(d){const p=d.component.projection;return!(!p||p.isFit)||void 0}(d)),P=F1(x),B=S.key,q=function JC(d){const{encoding:p,stack:_,mark:x,markDef:S,config:A}=d,O=p.order;if(!(!re.isArray(O)&&Ma(O)&&$t(O.value)||!O&&$t(Ji("order",S,A)))){if((re.isArray(O)||dt(O))&&!_)return LM(O,{expr:"datum"});if(yl(x)){const P="horizontal"===S.orient?"y":"x",B=p[P];if(dt(B)){const q=B.sort;return re.isArray(q)?{field:pt(B,{prefix:P,suffix:"sort_index",expr:"datum"})}:sa(q)?{field:pt({aggregate:vE(d.encoding)?q.op:void 0,field:q.field},{expr:"datum"})}:dE(q)?{field:pt(d.fieldDef(q.encoding),{expr:"datum"}),order:q.order}:null===q?void 0:{field:pt(B,{binSuffix:d.stack?.impute?"mid":void 0,expr:"datum"})}}return}}}(d),G=function Xi(d){if(!d.component.selection)return null;const p=We(d.component.selection).length;let _=p,x=d.parent;for(;x&&0===_;)_=We(x.component.selection).length,x=x.parent;return _?{interactive:p>0||"geoshape"===d.mark||!!d.encoding.tooltip}:null}(d),ee=Ji("aria",x,A),se=Ur[_].postEncodingTransform?Ur[_].postEncodingTransform(d):null;return[{name:d.getName("marks"),type:Ur[_].vgMark,...O?{clip:!0}:{},...P?{style:P}:{},...B?{key:B.field}:{},...q?{sort:q}:{},...G||{},...!1===ee?{aria:ee}:{},from:{data:p.fromPrefix+d.requestDataName(Vr.Main)},encode:{update:Ur[_].encodeEntry(d)},...se?{transform:se}:{}}]}class uw extends Wg{constructor(p,_,x){let S=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},A=arguments.length>4?arguments[4]:void 0;super(p,"unit",_,x,A,void 0,Ry(p)?p.view:void 0),ln(this,"markDef",void 0),ln(this,"encoding",void 0),ln(this,"specifiedScales",{}),ln(this,"stack",void 0),ln(this,"specifiedAxes",{}),ln(this,"specifiedLegends",{}),ln(this,"specifiedProjection",{}),ln(this,"selection",[]),ln(this,"children",[]);const O=Du(p.mark)?{...p.mark}:{type:p.mark},P=O.type;void 0===O.filled&&(O.filled=function PE(d,p,_){let{graticule:x}=_;if(x)return!1;const S=xu("filled",d,p),A=d.type;return ui(S,A!==np&&A!==wd&&A!==Su)}(O,A,{graticule:p.data&&cc(p.data)}));const B=this.encoding=function ug(d,p,_,x){const S={};for(const A of We(d))hl(A)||nt(Is(A));for(let A of wa){if(!d[A])continue;const O=d[A];if(us(A)){const P=ja(A),B=S[P];if(dt(B)&&V2(B.type)&&dt(O)&&!B.timeUnit){nt(Yh(P));continue}}if("angle"===A&&"arc"===p&&!d.theta&&(nt("Arc marks uses theta channel rather than angle, replacing angle with theta."),A=As),yA(d,A,p))if(A===He&&"line"===p&&ku(d[A])?.aggregate)nt("Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.");else if(A===be&&(_?"fill"in d:"stroke"in d))nt(Gm("encoding",{fill:"fill"in d,stroke:"stroke"in d}));else if(A===X0||A===Kl&&!re.isArray(O)&&!Ma(O)||A===W_&&re.isArray(O)){if(O){if(A===Kl){const P=d[A];if(Rv(P)){S[A]=P;continue}}S[A]=re.array(O).reduce((P,B)=>(dt(B)?P.push(cg(B,A)):nt(Nr(B,A)),P),[])}}else{if(A===W_&&null===O)S[A]=null;else if(!(dt(O)||Sd(O)||Ma(O)||hE(O)||Je(O))){nt(Nr(O,A));continue}S[A]=mA(O,A,x)}else nt(bo(A,p))}return S}(p.encoding||{},P,O.filled,A);this.markDef=FE(O,B,A),this.size=function Kg(d){let{encoding:p,size:_}=d;for(const x of Ql){const S=Mr(x);Fd(_[S])&&Wc(p[x])&&(delete _[S],nt(GM(S)))}return _}({encoding:B,size:Ry(p)?{...S,...p.width?{width:p.width}:{},...p.height?{height:p.height}:{}}:S}),this.stack=LA(this.markDef,B),this.specifiedScales=this.initScales(P,B),this.specifiedAxes=this.initAxes(B),this.specifiedLegends=this.initLegends(B),this.specifiedProjection=p.projection,this.selection=(p.params??[]).filter(q=>AA(q))}get hasProjection(){const{encoding:p}=this,_=this.mark===Jm,x=p&&CM.some(S=>Bn(p[S]));return _||x}scaleDomain(p){const _=this.specifiedScales[p];return _?_.domain:void 0}axis(p){return this.specifiedAxes[p]}legend(p){return this.specifiedLegends[p]}initScales(p,_){return ev.reduce((x,S)=>{const A=Oo(_[S]);return A&&(x[S]=this.initScale(A.scale??{})),x},{})}initScale(p){const{domain:_,range:x}=p,S=_o(p);return re.isArray(_)&&(S.domain=_.map(Ha)),re.isArray(x)&&(S.range=x.map(Ha)),S}initAxes(p){return Ql.reduce((_,x)=>{const S=p[x];if(Bn(S)||x===Ri&&Bn(p.x2)||x===mo&&Bn(p.y2)){const A=Bn(S)?S.axis:void 0;_[x]=A&&this.initAxis({...A})}return _},{})}initAxis(p){const _=We(p),x={};for(const S of _){const A=p[S];x[S]=Xf(A)?RM(A):Ha(A)}return x}initLegends(p){return N1.reduce((_,x)=>{const S=Oo(p[x]);if(S&&function Of(d){switch(d){case be:case Se:case Fe:case He:case ye:case _e:case Ts:case Hh:return!0;case nn:case gi:case lt:return!1}}(x)){const A=S.legend;_[x]=A&&_o(A)}return _},{})}parseData(){this.component.data=gc(this)}parseLayoutSize(){!function CR(d){const{size:p,component:_}=d;for(const x of Ql){const S=Mr(x);if(p[S]){const A=p[S];_.layoutSize.set(S,Fd(A)?"step":A,!0)}else{const A=SR(d,S);_.layoutSize.set(S,A,!1)}}}(this)}parseSelections(){this.component.selection=function oC(d,p){const _={},x=d.config.selection;if(!p||!p.length)return _;for(const S of p){const A=hn(S.name),O=S.select,P=re.isString(O)?O:O.type,B=re.isObject(O)?st(O):{type:P},q=x[P];for(const se in q)"fields"===se||"encodings"===se||("mark"===se&&(B[se]={...q[se],...B[se]}),(void 0===B[se]||!0===B[se])&&(B[se]=st(q[se]??B[se])));const G=_[A]={...B,name:A,type:P,init:S.value,bind:S.bind,events:re.isString(B.on)?re.parseSelector(B.on,"scope"):re.array(st(B.on))},ee=st(S);for(const se of gx)se.defined(G)&&se.parse&&se.parse(d,G,ee)}return _}(this,this.selection)}parseMarkGroup(){this.component.mark=hh(this)}parseAxesAndHeaders(){this.component.axes=function Fo(d){return Ql.reduce((p,_)=>(d.component.scales[_]&&(p[_]=[JT(_,d)]),p),{})}(this)}assembleSelectionTopLevelSignals(p){return function JA(d,p){let _=!1;for(const x of Dn(d.component.selection??{})){const S=x.name,A=re.stringValue(S+Hd);if(0===p.filter(P=>P.name===S).length){const B="point"===x.type?", true, true)":")";p.push({name:x.name,update:`${fR}(${A}, ${re.stringValue("global"===x.resolve?"union":x.resolve)}${B}`})}_=!0;for(const P of gx)P.defined(x)&&P.topLevelSignals&&(p=P.topLevelSignals(d,x,p))}return _&&0===p.filter(S=>"unit"===S.name).length&&p.unshift({name:"unit",value:{},on:[{events:"pointermove",update:"isTuple(group()) ? group() : unit"}]}),Lu(p)}(this,p)}assembleSignals(){return[...Tg(this),...lR(this,[])]}assembleSelectionData(p){return function vg(d,p){const _=[...p],x=kp(d,{escape:!1});for(const S of Dn(d.component.selection??{})){const A={name:S.name+Hd};if(S.project.hasSelectionId&&(A.transform=[{type:"collect",sort:{field:Ya}}]),S.init){const P=S.project.items.map(HE);A.values=S.init.map(S.project.hasSelectionId?B=>({unit:x,[Ya]:eh(B,!1)[0]}):B=>({unit:x,fields:P,values:eh(B,!1)}))}_.filter(P=>P.name===S.name+Hd).length||_.push(A)}return _}(this,p)}assembleLayout(){return null}assembleLayoutSignals(){return cb(this)}assembleMarks(){let p=this.component.mark??[];return(!this.parent||!Hg(this.parent))&&(p=WE(this,p)),p.map(this.correctDataNames)}assembleGroupStyle(){const{style:p}=this.view||{};return void 0!==p?p:this.encoding.x||this.encoding.y?"cell":"view"}getMapping(){return this.encoding}get mark(){return this.markDef.type}channelHasField(p){return xo(this.encoding,p)}fieldDef(p){return ku(this.encoding[p])}typedFieldDef(p){const _=this.fieldDef(p);return Yo(_)?_:null}}class eS extends Hu{constructor(p,_,x,S,A){super(p,"layer",_,x,A,p.resolve,p.view),ln(this,"children",void 0);const O={...S,...p.width?{width:p.width}:{},...p.height?{height:p.height}:{}};this.children=p.layer.map((P,B)=>{if(_p(P))return new eS(P,this,this.getName(`layer_${B}`),O,A);if(vl(P))return new uw(P,this,this.getName(`layer_${B}`),O,A);throw new Error(ov(P))})}parseData(){this.component.data=gc(this);for(const p of this.children)p.parseData()}parseLayoutSize(){!function ZT(d){ew(d),Zp(d,"width"),Zp(d,"height")}(this)}parseSelections(){this.component.selection={};for(const p of this.children){p.parseSelections();for(const _ of We(p.component.selection))this.component.selection[_]=p.component.selection[_]}}parseMarkGroup(){for(const p of this.children)p.parseMarkGroup()}parseAxesAndHeaders(){!function Ab(d){const{axes:p,resolve:_}=d.component,x={top:0,bottom:0,right:0,left:0};for(const S of d.children){S.parseAxesAndHeaders();for(const A of We(S.component.axes))_.axis[A]=Ig(d.component.resolve,A),"shared"===_.axis[A]&&(p[A]=XC(p[A],S.component.axes[A]),p[A]||(_.axis[A]="independent",delete p[A]))}for(const S of Ql){for(const A of d.children)if(A.component.axes[S]){if("independent"===_.axis[S]){p[S]=(p[S]??[]).concat(A.component.axes[S]);for(const O of A.component.axes[S]){const{value:P,explicit:B}=O.getWithExplicit("orient");if(!Je(P)){if(x[P]>0&&!B){const q=ow[P];x[P]>x[q]&&O.set("orient",q,!1)}x[P]++}}}delete A.component.axes[S]}if("independent"===_.axis[S]&&p[S]&&p[S].length>1)for(const[A,O]of(p[S]||[]).entries())A>0&&O.get("grid")&&!O.explicit.grid&&(O.implicit.grid=!1)}}(this)}assembleSelectionTopLevelSignals(p){return this.children.reduce((_,x)=>x.assembleSelectionTopLevelSignals(_),p)}assembleSignals(){return this.children.reduce((p,_)=>p.concat(_.assembleSignals()),Tg(this))}assembleLayoutSignals(){return this.children.reduce((p,_)=>p.concat(_.assembleLayoutSignals()),cb(this))}assembleSelectionData(p){return this.children.reduce((_,x)=>x.assembleSelectionData(_),p)}assembleGroupStyle(){const p=new Set;for(const x of this.children)for(const S of re.array(x.assembleGroupStyle()))p.add(S);const _=Array.from(p);return _.length>1?_:1===_.length?_[0]:void 0}assembleTitle(){let p=super.assembleTitle();if(p)return p;for(const _ of this.children)if(p=_.assembleTitle(),p)return p}assembleLayout(){return null}assembleMarks(){return function cx(d,p){for(const _ of d.children)uo(_)&&(p=WE(_,p));return p}(this,this.children.flatMap(p=>p.assembleMarks()))}assembleLegends(){return this.children.reduce((p,_)=>p.concat(_.assembleLegends()),rh(this))}}function Jr(d,p,_,x,S){if(_y(d))return new Sb(d,p,_,S);if(_p(d))return new eS(d,p,_,x,S);if(vl(d))return new uw(d,p,_,x,S);if(function TA(d){return mg(d)||Oy(d)||ME(d)}(d))return new a3(d,p,_,S);throw new Error(ov(d))}function t_(d,p,_,x){const S=x.component.layoutSize.get("width"),A=x.component.layoutSize.get("height");if(void 0===p?(p={type:"pad"},x.hasAxisOrientSignalRef()&&(p.resize=!0)):re.isString(p)&&(p={type:p}),S&&A&&function Bd(d){return"fit"===d||"fit-x"===d||"fit-y"===d}(p.type))if("step"===S&&"step"===A)nt(UM()),p.type="pad";else if("step"===S||"step"===A){const O="step"===S?"width":"height";nt(UM(If(O))),p.type=function aR(d){return d?`fit-${If(d)}`:"fit"}("width"===O?"height":"width")}return{...1===We(p).length&&p.type?"pad"===p.type?{}:{autosize:p.type}:{autosize:p},...Hy(_,!1),...Hy(d,!0)}}function ef(d,p){let _=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},x=arguments.length>3?arguments[3]:void 0;const S=d.config?IA(d.config):void 0,A=[].concat(d.assembleSelectionData([]),function Jx(d,p){const _=[],x=Yg(_);let S=0;for(const O of d.sources){O.hasName()||(O.dataName="source_"+S++);const P=O.assemble();x(O,P)}for(const O of _)0===O.transform.length&&delete O.transform;let A=0;for(const[O,P]of _.entries())0===(P.transform??[]).length&&!P.source&&_.splice(A++,0,_.splice(O,1)[0]);for(const O of _)for(const P of O.transform??[])"lookup"===P.type&&(P.from=d.outputNodes[P.from].getSource());for(const O of _)O.name in p&&(O.values=p[O.name]);return _}(d.component.data,_)),O=d.assembleProjections(),P=d.assembleTitle(),B=d.assembleGroupStyle(),q=d.assembleGroupEncodeEntry(!0);let G=d.assembleLayoutSignals();G=G.filter(Ee=>"width"!==Ee.name&&"height"!==Ee.name||void 0===Ee.value||(p[Ee.name]=+Ee.value,!1));const{params:ee,...se}=p;return{$schema:"https://vega.github.io/schema/vega/v5.json",...d.description?{description:d.description}:{},...se,...P?{title:P}:{},...B?{style:B}:{},...q?{encode:{update:q}}:{},data:A,...O.length>0?{projections:O}:{},...d.assembleGroup([...G,...d.assembleSelectionTopLevelSignals([]),...pg(ee)]),...S?{config:S}:{},...x?{usermeta:x}:{}}}Ct.accessPathDepth=ro,Ct.accessPathWithDatum=Js,Ct.compile=function ph(d){let p=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};p.logger&&function oy(d){return Xm=d,Xm}(p.logger),p.fieldTitle&&Gf(p.fieldTitle);try{const _=kE(re.mergeConfig(p.config,d.config)),x=YA(d,_),S=Jr(x,null,"",void 0,_);return S.parse(),function _R(d,p){jg(d.sources);let _=0,x=0;for(let S=0;S{"use strict";function Ct(ae,be,Se){return ae.fields=be||[],ae.fname=Se,ae}function re(ae){return null==ae?null:ae.fname}function Ii(ae){return null==ae?null:ae.fields}function sn(ae){return 1===ae.length?yi(ae[0]):Zn(ae)}tn.d(Ds,{$G:()=>Ho,$m:()=>Ri,BB:()=>Rc,Ds:()=>Vo,Dw:()=>St,EP:()=>Rt,FP:()=>wr,HD:()=>Wn,He:()=>At,Hq:()=>Li,IX:()=>Gt,J_:()=>$i,Jy:()=>ea,Kj:()=>xr,Kn:()=>ti,N3:()=>Oi,Oj:()=>Ii,QA:()=>Ot,Rg:()=>It,TS:()=>mo,TW:()=>vr,We:()=>ci,XW:()=>ls,Xr:()=>va,ZE:()=>Ct,ZU:()=>As,Zw:()=>qi,_k:()=>oi,a9:()=>Js,ay:()=>Ci,bM:()=>si,bV:()=>Qi,cG:()=>zo,dH:()=>fr,dI:()=>jo,el:()=>re,fE:()=>fe,fj:()=>ot,hj:()=>po,iL:()=>Be,id:()=>On,j2:()=>hn,jj:()=>dr,jn:()=>Uo,k:()=>Gr,kI:()=>Zi,kJ:()=>ei,kX:()=>N,kg:()=>Xr,l$:()=>We,l7:()=>Mi,m8:()=>Qn,mJ:()=>li,mK:()=>no,mS:()=>an,mf:()=>Dn,nr:()=>ro,qu:()=>Hi,rx:()=>Wi,sw:()=>Ao,t7:()=>Xl,u5:()=>cs,uU:()=>Br,vU:()=>Xt,vk:()=>Oc,yP:()=>Yl,yR:()=>Ut,yb:()=>ai,yl:()=>Ms});const yi=ae=>function(be){return be[ae]},Zn=ae=>{const be=ae.length;return function(Se){for(let Fe=0;Felt&&gi(),ye=lt=_e+1):"]"===nn&&(ye||Xt("Access path missing open bracket: "+ae),ye>0&&gi(),ye=0,lt=_e+1):_e>lt?gi():lt=_e+1}return ye&&Xt("Access path missing closing bracket: "+ae),Fe&&Xt("Access path missing closing quote: "+ae),_e>lt&&(_e++,gi()),be}function Rt(ae,be,Se){const Fe=oi(ae);return ae=1===Fe.length?Fe[0]:ae,Ct((Se&&Se.get||sn)(Fe),[ae],be||ae)}const On=Rt("id"),Ut=Ct(ae=>ae,[],"identity"),si=Ct(()=>0,[],"zero"),N=Ct(()=>1,[],"one"),ai=Ct(()=>!0,[],"true"),Gr=Ct(()=>!1,[],"false");function Yt(ae,be,Se){const Fe=[be].concat([].slice.call(Se));console[ae].apply(console,Fe)}const Li=0,dr=1,Br=2,Zi=3,zo=4;function Xr(ae,be){let Se=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Yt,Fe=ae||Li;return{level(ye){return arguments.length?(Fe=+ye,this):Fe},error(){return Fe>=dr&&Se(be||"error","ERROR",arguments),this},warn(){return Fe>=Br&&Se(be||"warn","WARN",arguments),this},info(){return Fe>=Zi&&Se(be||"log","INFO",arguments),this},debug(){return Fe>=zo&&Se(be||"log","DEBUG",arguments),this}}}var ei=Array.isArray;function ti(ae){return ae===Object(ae)}const he=ae=>"__proto__"!==ae;function fe(){for(var ae=arguments.length,be=new Array(ae),Se=0;Se{for(const He in ye)"signals"===He?Fe.signals=Qe(Fe.signals,ye.signals):Be(Fe,He,ye[He],"legend"===He?{layout:1}:"style"===He||null);return Fe},{})}function Be(ae,be,Se,Fe){if(!he(be))return;let ye,He;if(ti(Se)&&!ei(Se))for(ye in He=ti(ae[be])?ae[be]:ae[be]={},Se)Fe&&(!0===Fe||Fe[ye])?Be(He,ye,Se[ye]):he(ye)&&(He[ye]=Se[ye]);else ae[be]=Se}function Qe(ae,be){if(null==ae)return be;const Se={},Fe=[];function ye(He){Se[He.name]||(Se[He.name]=1,Fe.push(He))}return be.forEach(ye),ae.forEach(ye),Fe}function ot(ae){return ae[ae.length-1]}function At(ae){return null==ae||""===ae?null:+ae}const st=ae=>be=>ae*Math.exp(be),Fn=ae=>be=>Math.log(ae*be),Sn=ae=>be=>Math.sign(be)*Math.log1p(Math.abs(be/ae)),yt=ae=>be=>Math.sign(be)*Math.expm1(Math.abs(be))*ae,kt=ae=>be=>be<0?-Math.pow(-be,ae):Math.pow(be,ae);function $t(ae,be,Se,Fe){const ye=Se(ae[0]),He=Se(ot(ae)),lt=(He-ye)*be;return[Fe(ye-lt),Fe(He-lt)]}function St(ae,be){return $t(ae,be,At,Ut)}function li(ae,be){var Se=Math.sign(ae[0]);return $t(ae,be,Fn(Se),st(Se))}function Ot(ae,be,Se){return $t(ae,be,kt(Se),kt(1/Se))}function qi(ae,be,Se){return $t(ae,be,Sn(Se),yt(Se))}function zr(ae,be,Se,Fe,ye){const He=Fe(ae[0]),lt=Fe(ot(ae)),_e=null!=be?Fe(be):(He+lt)/2;return[ye(_e+(He-_e)*Se),ye(_e+(lt-_e)*Se)]}function Ci(ae,be,Se){return zr(ae,be,Se,At,Ut)}function fr(ae,be,Se){const Fe=Math.sign(ae[0]);return zr(ae,be,Se,Fn(Fe),st(Fe))}function no(ae,be,Se,Fe){return zr(ae,be,Se,kt(Fe),kt(1/Fe))}function Qi(ae,be,Se,Fe){return zr(ae,be,Se,Sn(Fe),yt(Fe))}function an(ae){return 1+~~(new Date(ae).getMonth()/3)}function Oi(ae){return 1+~~(new Date(ae).getUTCMonth()/3)}function Gt(ae){return null!=ae?ei(ae)?ae:[ae]:[]}function We(ae,be,Se){let He,Fe=ae[0],ye=ae[1];return ye=Se-be?[be,Se]:[Fe=Math.min(Math.max(Fe,be),Se-He),Fe+He]}function Dn(ae){return"function"==typeof ae}const Jt="descending";function Hi(ae,be,Se){Se=Se||{},be=Gt(be)||[];const Fe=[],ye=[],He={},lt=Se.comparator||io;return Gt(ae).forEach((_e,nn)=>{null!=_e&&(Fe.push(be[nn]===Jt?-1:1),ye.push(_e=Dn(_e)?_e:Rt(_e,null,Se)),(Ii(_e)||[]).forEach(gi=>He[gi]=1))}),0===ye.length?null:Ct(lt(ye,Fe),Object.keys(He))}const hn=(ae,be)=>(aebe||null==be)&&null!=ae?1:(be=be instanceof Date?+be:be,(ae=ae instanceof Date?+ae:ae)!==ae&&be==be?-1:be!=be&&ae==ae?1:0),io=(ae,be)=>1===ae.length?xn(ae[0],be[0]):Mo(ae,be,ae.length),xn=(ae,be)=>function(Se,Fe){return hn(ae(Se),ae(Fe))*be},Mo=(ae,be,Se)=>(be.push(0),function(Fe,ye){let He,lt=0,_e=-1;for(;0===lt&&++_eae}function Vo(ae,be){let Se;return Fe=>{Se&&clearTimeout(Se),Se=setTimeout(()=>(be(Fe),Se=null),ae)}}function Mi(ae){for(let be,Se,Fe=1,ye=arguments.length;Felt&&(lt=ye))}else{for(ye=be(ae[Se]);Selt&&(lt=ye))}return[He,lt]}function jo(ae,be){const Se=ae.length;let ye,He,lt,_e,nn,Fe=-1;if(null==be){for(;++Fe=He){ye=lt=He;break}if(Fe===Se)return[-1,-1];for(_e=nn=Fe;++FeHe&&(ye=He,_e=Fe),lt=He){ye=lt=He;break}if(Fe===Se)return[-1,-1];for(_e=nn=Fe;++FeHe&&(ye=He,_e=Fe),ltFe(He)?be[He]:void 0,set(He,lt){return Fe(He)||(++ye.size,be[He]===ui&&--ye.empty),be[He]=lt,this},delete(He){return Fe(He)&&(--ye.size,++ye.empty,be[He]=ui),this},clear(){ye.size=ye.empty=0,ye.object=be={}},test(He){return arguments.length?(Se=He,ye):Se},clean(){const He={};let lt=0;for(const _e in be){const nn=be[_e];nn!==ui&&(!Se||!Se(nn))&&(He[_e]=nn,++lt)}ye.size=lt,ye.empty=0,ye.object=be=He}};return ae&&Object.keys(ae).forEach(He=>{ye.set(He,ae[He])}),ye}function Ms(ae,be,Se,Fe,ye,He){if(!Se&&0!==Se)return He;const lt=+Se;let gi,_e=ae[0],nn=ot(ae);nn<_e&&(gi=_e,_e=nn,nn=gi),gi=Math.abs(be-_e);const Ts=Math.abs(nn-be);return giHe&&(lt=ye,ye=He,He=lt),Fe=void 0===Fe||Fe,((Se=void 0===Se||Se)?ye<=ae:ye_e.replace(/\\(.)/g,"$1")):Gt(ae));const Fe=ae&&ae.length,ye=Se&&Se.get||sn,He=_e=>ye(be?[_e]:oi(_e));let lt;if(Fe)if(1===Fe){const _e=He(ae[0]);lt=function(nn){return""+_e(nn)}}else{const _e=ae.map(He);lt=function(nn){let gi=""+_e[0](nn),Ts=0;for(;++Ts{be={},Se={},Fe=0},He=(lt,_e)=>(++Fe>ae&&(Se=be,be={},Fe=1),be[lt]=_e);return ye(),{clear:ye,has:lt=>ro(be,lt)||ro(Se,lt),get:lt=>ro(be,lt)?be[lt]:ro(Se,lt)?He(lt,Se[lt]):void 0,set:(lt,_e)=>ro(be,lt)?be[lt]=_e:He(lt,_e)}}function mo(ae,be,Se,Fe){const ye=be.length,He=Se.length;if(!He)return be;if(!ye)return Se;const lt=Fe||new be.constructor(ye+He);let _e=0,nn=0,gi=0;for(;_e0?Se[nn++]:be[_e++];for(;_e=0;)Se+=ae;return Se}function Oc(ae,be,Se,Fe){const ye=Se||" ",He=ae+"",lt=be-He.length;return lt<=0?He:"left"===Fe?Wi(ye,lt)+He:"center"===Fe?Wi(ye,~~(lt/2))+He+Wi(ye,Math.ceil(lt/2)):He+Wi(ye,lt)}function Yl(ae){return ae&&ot(ae)-ae[0]||0}function Qn(ae){return ei(ae)?"["+ae.map(Qn)+"]":ti(ae)||Wn(ae)?JSON.stringify(ae).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):ae}function Ao(ae){return null==ae||""===ae?null:!(!ae||"false"===ae||"0"===ae||!ae)}const ta=ae=>po(ae)||$i(ae)?ae:Date.parse(ae);function As(ae,be){return be=be||ta,null==ae||""===ae?null:be(ae)}function Rc(ae){return null==ae||""===ae?null:ae+""}function It(ae){const be={},Se=ae.length;for(let Fe=0;Fe{"use strict";tn.r(Ds),tn.d(Ds,{Bounds:()=>Fo,CanvasHandler:()=>sm,CanvasRenderer:()=>lS,DATE:()=>ja,DAY:()=>wa,DAYOFYEAR:()=>fd,Dataflow:()=>xd,Debug:()=>N.cG,Error:()=>N.jj,EventStream:()=>so,Gradient:()=>qp,GroupItem:()=>Ab,HOURS:()=>Pc,Handler:()=>rm,HybridHandler:()=>QR,HybridRenderer:()=>wk,Info:()=>N.kI,Item:()=>ow,MILLISECONDS:()=>hd,MINUTES:()=>Rr,MONTH:()=>na,Marks:()=>eu,MultiPulse:()=>Xo,None:()=>N.Hq,Operator:()=>ar,Parameters:()=>vv,Pulse:()=>Go,QUARTER:()=>Mr,RenderType:()=>l_,Renderer:()=>bc,ResourceLoader:()=>XC,SECONDS:()=>rn,SVGHandler:()=>LR,SVGRenderer:()=>xw,SVGStringRenderer:()=>V3,Scenegraph:()=>b3,TIME_UNITS:()=>M2,Transform:()=>ze,View:()=>hj,WEEK:()=>To,Warn:()=>N.uU,YEAR:()=>Or,accessor:()=>N.ZE,accessorFields:()=>N.Oj,accessorName:()=>N.el,array:()=>N.IX,ascending:()=>N.j2,bandwidthNRD:()=>rp,bin:()=>Au,bootstrapCI:()=>sE,boundClip:()=>H3,boundContext:()=>kb,boundItem:()=>OR,boundMark:()=>s_,boundStroke:()=>Dl,changeset:()=>Lf,clampRange:()=>N.l$,codegenExpression:()=>gV,compare:()=>N.qu,constant:()=>N.a9,cumulativeLogNormal:()=>Hc,cumulativeNormal:()=>sc,cumulativeUniform:()=>Wf,dayofyear:()=>k2,debounce:()=>N.Ds,defaultLocale:()=>XM,definition:()=>np,densityLogNormal:()=>kv,densityNormal:()=>Xa,densityUniform:()=>op,domChild:()=>js,domClear:()=>mr,domCreate:()=>a_,domFind:()=>pk,dotbin:()=>aE,error:()=>N.vU,expressionFunction:()=>xs,extend:()=>N.l7,extent:()=>N.We,extentIndex:()=>N.dI,falsy:()=>N.k,fastmap:()=>N.Xr,field:()=>N.EP,flush:()=>N.yl,font:()=>im,fontFamily:()=>gh,fontSize:()=>hi,format:()=>Ym,formatLocale:()=>iy,formats:()=>gl,hasOwnProperty:()=>N.nr,id:()=>N.id,identity:()=>N.yR,inferType:()=>U1,inferTypes:()=>_d,ingest:()=>Ti,inherits:()=>N.XW,inrange:()=>N.u5,interpolate:()=>kC,interpolateColors:()=>_b,interpolateRange:()=>Vx,intersect:()=>tN,intersectBoxLine:()=>Jg,intersectPath:()=>cw,intersectPoint:()=>en,intersectRule:()=>Ib,isArray:()=>N.kJ,isBoolean:()=>N.jn,isDate:()=>N.J_,isFunction:()=>N.mf,isIterable:()=>N.TW,isNumber:()=>N.hj,isObject:()=>N.Kn,isRegExp:()=>N.Kj,isString:()=>N.HD,isTuple:()=>ly,key:()=>N.Jy,lerp:()=>N.t7,lineHeight:()=>Qc,loader:()=>Pf,locale:()=>GM,logger:()=>N.kg,lruCache:()=>N.$m,markup:()=>GR,merge:()=>N.TS,mergeConfig:()=>N.fE,multiLineOffset:()=>r_,one:()=>N.kX,pad:()=>N.vk,panLinear:()=>N.Dw,panLog:()=>N.mJ,panPow:()=>N.QA,panSymlog:()=>N.Zw,parse:()=>cd,parseExpression:()=>gD,parseSelector:()=>yj,path:()=>ex,pathCurves:()=>qx,pathEqual:()=>pS,pathParse:()=>Gp,pathRectangle:()=>Vs,pathRender:()=>xb,pathSymbols:()=>GT,pathTrail:()=>Xp,peek:()=>N.fj,point:()=>mk,projection:()=>dF,quantileLogNormal:()=>Ed,quantileNormal:()=>ao,quantileUniform:()=>cE,quantiles:()=>py,quantizeInterpolator:()=>Bg,quarter:()=>N.mS,quartiles:()=>rE,random:()=>oc,randomInteger:()=>tg,randomKDE:()=>Uc,randomLCG:()=>X2,randomLogNormal:()=>Ns,randomMixture:()=>Hf,randomNormal:()=>Fi,randomUniform:()=>uE,read:()=>Wa,regressionConstant:()=>ng,regressionExp:()=>fE,regressionLinear:()=>dE,regressionLoess:()=>Tu,regressionLog:()=>sa,regressionPoly:()=>_y,regressionPow:()=>og,regressionQuad:()=>Zr,renderModule:()=>hS,repeat:()=>N.rx,resetDefaultLocale:()=>G$,resetSVGClipId:()=>iw,resetSVGDefIds:()=>q3,responseType:()=>Zh,runtimeContext:()=>v9,sampleCurve:()=>qf,sampleLogNormal:()=>Tv,sampleNormal:()=>my,sampleUniform:()=>gy,scale:()=>Yn,sceneEqual:()=>iN,sceneFromJSON:()=>hk,scenePickVisit:()=>_,sceneToJSON:()=>y3,sceneVisit:()=>p,sceneZOrder:()=>d,scheme:()=>Vg,serializeXML:()=>Ae,setHybridRendererOptions:()=>h8,setRandom:()=>oE,span:()=>N.yP,splitAccessPath:()=>N._k,stringValue:()=>N.m8,textMetrics:()=>yc,timeBin:()=>Q_,timeFloor:()=>$e,timeFormatLocale:()=>hv,timeInterval:()=>Of,timeOffset:()=>pd,timeSequence:()=>X_,timeUnitSpecifier:()=>q$,timeUnits:()=>T2,toBoolean:()=>N.sw,toDate:()=>N.ZU,toNumber:()=>N.He,toSet:()=>N.Rg,toString:()=>N.BB,transform:()=>lA,transforms:()=>wd,truncate:()=>N.$G,truthy:()=>N.yb,tupleid:()=>Kt,typeParsers:()=>oy,utcFloor:()=>J0,utcInterval:()=>Bm,utcOffset:()=>O2,utcSequence:()=>tv,utcdayofyear:()=>Yr,utcquarter:()=>N.N3,utcweek:()=>Q0,version:()=>E1,visitArray:()=>N.FP,week:()=>DM,writeConfig:()=>N.iL,zero:()=>N.bM,zoomLinear:()=>N.ay,zoomLog:()=>N.dH,zoomPow:()=>N.mK,zoomSymlog:()=>N.bV});var Ct={};tn.r(Ct),tn.d(Ct,{aggregate:()=>Md,bin:()=>Pv,collect:()=>lp,compare:()=>cp,countpattern:()=>lg,cross:()=>pA,density:()=>Ad,dotbin:()=>kd,expression:()=>Xf,extent:()=>$v,facet:()=>Bv,field:()=>wy,filter:()=>zv,flatten:()=>vl,fold:()=>Id,formula:()=>xo,generate:()=>Yf,impute:()=>Vv,joinaggregate:()=>xE,kde:()=>Ey,key:()=>Uv,load:()=>Hv,lookup:()=>Sy,multiextent:()=>qv,multivalues:()=>dg,params:()=>Dy,pivot:()=>xA,prefacet:()=>My,project:()=>Ru,proxy:()=>EE,quantile:()=>fp,relay:()=>CA,sample:()=>Ay,sequence:()=>CE,sieve:()=>Rd,subflow:()=>Ou,timeunit:()=>hp,tupleindex:()=>Gv,values:()=>ps,window:()=>Ty});var re={};tn.r(re),tn.d(re,{interpolate:()=>wl,interpolateArray:()=>nT,interpolateBasis:()=>XE,interpolateBasisClosed:()=>Ep,interpolateCubehelix:()=>pR,interpolateCubehelixLong:()=>mR,interpolateDate:()=>rT,interpolateDiscrete:()=>pC,interpolateHcl:()=>hb,interpolateHclLong:()=>Rg,interpolateHsl:()=>gT,interpolateHslLong:()=>_T,interpolateHue:()=>r3,interpolateLab:()=>wC,interpolateNumber:()=>dc,interpolateNumberArray:()=>Yy,interpolateObject:()=>gs,interpolateRgb:()=>Ro,interpolateRgbBasis:()=>KE,interpolateRgbBasisClosed:()=>jd,interpolateRound:()=>Ky,interpolateString:()=>dR,interpolateTransformCss:()=>kg,interpolateTransformSvg:()=>Cx,interpolateZoom:()=>yC,piecewise:()=>lC,quantize:()=>xT});var Ii={};tn.r(Ii),tn.d(Ii,{bound:()=>aN,identifier:()=>cN,mark:()=>iB,overlap:()=>dN,render:()=>cB,viewlayout:()=>yN});var sn={};tn.r(sn),tn.d(sn,{axisticks:()=>vN,datajoin:()=>vB,encode:()=>xB,legendentries:()=>wB,linkpath:()=>Ok,pie:()=>vs,scale:()=>lm,sortitems:()=>MN,stack:()=>Fk});var yi={};tn.r(yi),tn.d(yi,{contour:()=>dI,geojson:()=>yF,geopath:()=>bF,geopoint:()=>vF,geoshape:()=>pI,graticule:()=>Jb,heatmap:()=>__,isocontour:()=>gF,kde2d:()=>Az,projection:()=>Oz});var Zn={};tn.r(Zn),tn.d(Zn,{force:()=>mm});var Xt={};tn.r(Xt),tn.d(Xt,{nest:()=>GF,pack:()=>zS,partition:()=>YF,stratify:()=>KF,tree:()=>NI,treelinks:()=>ZF,treemap:()=>l5});var oi={};tn.r(oi),tn.d(oi,{label:()=>JF});var Rt={};tn.r(Rt),tn.d(Rt,{loess:()=>eP,regression:()=>GS});var On={};tn.r(On),tn.d(On,{voronoi:()=>OP});var Ut={};tn.r(Ut),tn.d(Ut,{wordcloud:()=>FP});var si={};tn.r(si),tn.d(si,{crossfilter:()=>XI,resolvefilter:()=>YI});var N=tn(537),ai=tn(861),Gr={},Yt={},Li=34,dr=10,Br=13;function Zi(i){return new Function("d","return {"+i.map(function(o,a){return JSON.stringify(o)+": d["+a+'] || ""'}).join(",")+"}")}function Xr(i){var o=Object.create(null),a=[];return i.forEach(function(l){for(var u in l)u in o||a.push(o[u]=u)}),a}function ei(i,o){var a=i+"",l=a.length;return l=I?z=!0:(Z=C.charCodeAt(k++))===dr?V=!0:Z===Br&&(V=!0,C.charCodeAt(k)===dr&&++k),C.slice(H+1,Y-1).replace(/""/g,'"')}for(;k9999?"+"+ei(i,6):ei(i,4)}(i.getUTCFullYear())+"-"+ei(i.getUTCMonth()+1,2)+"-"+ei(i.getUTCDate(),2)+(u?"T"+ei(o,2)+":"+ei(a,2)+":"+ei(l,2)+"."+ei(u,3)+"Z":l?"T"+ei(o,2)+":"+ei(a,2)+":"+ei(l,2)+"Z":a||o?"T"+ei(o,2)+":"+ei(a,2)+"Z":"")}(C):o.test(C+="")?'"'+C.replace(/"/g,'""')+'"':C}return{parse:function l(C,D){var T,I,k=u(C,function(F,L){if(T)return T(F,L-1);I=F,T=D?function zo(i,o){var a=Zi(i);return function(l,u){return o(a(l),u,i)}}(F,D):Zi(F)});return k.columns=I||[],k},parseRows:u,format:function m(C,D){return null==D&&(D=Xr(C)),[D.map(w).join(i)].concat(f(C,D)).join("\n")},formatBody:function g(C,D){return null==D&&(D=Xr(C)),f(C,D).join("\n")},formatRows:function b(C){return C.map(v).join("\n")},formatRow:v,formatValue:w}}function Qe(i){return i}function At(i,o){return"string"==typeof o&&(o=i.objects[o]),"GeometryCollection"===o.type?{type:"FeatureCollection",features:o.geometries.map(function(a){return st(i,a)})}:st(i,o)}function st(i,o){var a=o.id,l=o.bbox,u=null==o.properties?{}:o.properties,f=Fn(i,o);return null==a&&null==l?{type:"Feature",properties:u,geometry:f}:null==l?{type:"Feature",id:a,properties:u,geometry:f}:{type:"Feature",id:a,bbox:l,properties:u,geometry:f}}function Fn(i,o){var a=function ot(i){if(null==i)return Qe;var o,a,l=i.scale[0],u=i.scale[1],f=i.translate[0],m=i.translate[1];return function(g,b){b||(o=a=0);var v=2,w=g.length,C=new Array(w);for(C[0]=(o+=g[0])*l+f,C[1]=(a+=g[1])*u+m;v1)l=function $t(i,o,a){var f,l=[],u=[];function m(C){var D=C<0?~C:C;(u[D]||(u[D]=[])).push({i:C,g:f})}function g(C){C.forEach(m)}function b(C){C.forEach(g)}return function w(C){switch(f=C,C.type){case"GeometryCollection":C.geometries.forEach(w);break;case"LineString":g(C.arcs);break;case"MultiLineString":case"Polygon":b(C.arcs);break;case"MultiPolygon":!function v(C){C.forEach(b)}(C.arcs)}}(o),u.forEach(null==a?function(C){l.push(C[0].i)}:function(C){a(C[0].g,C[C.length-1].g)&&l.push(C[0].i)}),l}(0,o,a);else for(u=0,l=new Array(f=i.arcs.length);u=St?10:f>=li?5:f>=Ot?2:1;let g,b,v;return u<0?(v=Math.pow(10,-u)/m,g=Math.round(i*v),b=Math.round(o*v),g/vo&&--b,v=-v):(v=Math.pow(10,u)*m,g=Math.round(i/v),b=Math.round(o/v),g*vo&&--b),b0))return[];if((i=+i)==(o=+o))return[i];const l=o=u))return[];const g=f-u+1,b=new Array(g);if(l)if(m<0)for(let v=0;v=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Qi(i){if(!(o=no.exec(i)))throw new Error("invalid format: "+i);var o;return new an({fill:o[1],align:o[2],sign:o[3],symbol:o[4],zero:o[5],width:o[6],comma:o[7],precision:o[8]&&o[8].slice(1),trim:o[9],type:o[10]})}function an(i){this.fill=void 0===i.fill?" ":i.fill+"",this.align=void 0===i.align?">":i.align+"",this.sign=void 0===i.sign?"-":i.sign+"",this.symbol=void 0===i.symbol?"":i.symbol+"",this.zero=!!i.zero,this.width=void 0===i.width?void 0:+i.width,this.comma=!!i.comma,this.precision=void 0===i.precision?void 0:+i.precision,this.trim=!!i.trim,this.type=void 0===i.type?"":i.type+""}function Gt(i,o){if((a=(i=o?i.toExponential(o-1):i.toExponential()).indexOf("e"))<0)return null;var a,l=i.slice(0,a);return[l.length>1?l[0]+l.slice(2):l,+i.slice(a+1)]}function We(i){return(i=Gt(Math.abs(i)))?i[1]:NaN}function Dn(i,o){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(We(o)/3)))-We(Math.abs(i)))}function Jt(i,o){return i=Math.abs(i),o=Math.abs(o)-i,Math.max(0,We(o)-We(i))+1}function Hi(i){return Math.max(0,-We(Math.abs(i)))}function Vo(i,o){var a=Gt(i,o);if(!a)return i+"";var l=a[0],u=a[1];return u<0?"0."+new Array(-u).join("0")+l:l.length>u+1?l.slice(0,u+1)+"."+l.slice(u+1):l+new Array(u-l.length+2).join("0")}Qi.prototype=an.prototype,an.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};const Mi={"%":(i,o)=>(100*i).toFixed(o),b:i=>Math.round(i).toString(2),c:i=>i+"",d:function Oi(i){return Math.abs(i=Math.round(i))>=1e21?i.toLocaleString("en").replace(/,/g,""):i.toString(10)},e:(i,o)=>i.toExponential(o),f:(i,o)=>i.toFixed(o),g:(i,o)=>i.toPrecision(o),o:i=>Math.round(i).toString(8),p:(i,o)=>Vo(100*i,o),r:Vo,s:function Js(i,o){var a=Gt(i,o);if(!a)return i+"";var l=a[0],u=a[1],f=u-(Mo=3*Math.max(-8,Math.min(8,Math.floor(u/3))))+1,m=l.length;return f===m?l:f>m?l+new Array(f-m+1).join("0"):f>0?l.slice(0,f)+"."+l.slice(f):"0."+new Array(1-f).join("0")+Gt(i,Math.max(0,o+f-1))[0]},X:i=>Math.round(i).toString(16).toUpperCase(),x:i=>Math.round(i).toString(16)};function ci(i){return i}var ui,va,Ms,jo=Array.prototype.map,Si=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"];function ro(i){var o=void 0===i.grouping||void 0===i.thousands?ci:function hn(i,o){return function(a,l){for(var u=a.length,f=[],m=0,g=i[0],b=0;u>0&&g>0&&(b+g+1>l&&(g=Math.max(1,l-b)),f.push(a.substring(u-=g,u+g)),!((b+=g+1)>l));)g=i[m=(m+1)%i.length];return f.reverse().join(o)}}(jo.call(i.grouping,Number),i.thousands+""),a=void 0===i.currency?"":i.currency[0]+"",l=void 0===i.currency?"":i.currency[1]+"",u=void 0===i.decimal?".":i.decimal+"",f=void 0===i.numerals?ci:function io(i){return function(o){return o.replace(/[0-9]/g,function(a){return i[+a]})}}(jo.call(i.numerals,String)),m=void 0===i.percent?"%":i.percent+"",g=void 0===i.minus?"\u2212":i.minus+"",b=void 0===i.nan?"NaN":i.nan+"";function v(C){var D=(C=Qi(C)).fill,T=C.align,I=C.sign,k=C.symbol,F=C.zero,L=C.width,z=C.comma,V=C.precision,U=C.trim,W=C.type;"n"===W?(z=!0,W="g"):Mi[W]||(void 0===V&&(V=12),U=!0,W="g"),(F||"0"===D&&"="===T)&&(F=!0,D="0",T="=");var Y="$"===k?a:"#"===k&&/[boxX]/.test(W)?"0"+W.toLowerCase():"",H="$"===k?l:/[%p]/.test(W)?m:"",Z=Mi[W],te=/[defgprs%]/.test(W);function ce(le){var Q,J,oe,ve=Y,xe=H;if("c"===W)xe=Z(le)+xe,le="";else{var we=(le=+le)<0||1/le<0;if(le=isNaN(le)?b:Z(Math.abs(le),V),U&&(le=function xn(i){e:for(var u,o=i.length,a=1,l=-1;a0&&(l=0)}return l>0?i.slice(0,l)+i.slice(u+1):i}(le)),we&&0==+le&&"+"!==I&&(we=!1),ve=(we?"("===I?I:g:"-"===I||"("===I?"":I)+ve,xe=("s"===W?Si[8+Mo/3]:"")+xe+(we&&"("===I?")":""),te)for(Q=-1,J=le.length;++Q(oe=le.charCodeAt(Q))||oe>57){xe=(46===oe?u+le.slice(Q+1):le.slice(Q))+xe,le=le.slice(0,Q);break}}z&&!F&&(le=o(le,1/0));var ne=ve.length+le.length+xe.length,ge=ne>1)+ve+le+xe+ge.slice(ne);break;default:le=ge+ve+le+xe}return f(le)}return V=void 0===V?6:/[gprs]/.test(W)?Math.max(1,Math.min(21,V)):Math.max(0,Math.min(20,V)),ce.toString=function(){return C+""},ce}return{format:v,formatPrefix:function w(C,D){var T=v(((C=Qi(C)).type="f",C)),I=3*Math.max(-8,Math.min(8,Math.floor(We(D)/3))),k=Math.pow(10,-I),F=Si[8+I/3];return function(L){return T(k*L)+F}}}}!function ls(i){ui=ro(i),va=ui.format,Ms=ui.formatPrefix}({thousands:",",grouping:[3],currency:["$",""]});const cs=new Date,Uo=new Date;function $i(i,o,a,l){function u(f){return i(f=0===arguments.length?new Date:new Date(+f)),f}return u.floor=f=>(i(f=new Date(+f)),f),u.ceil=f=>(i(f=new Date(f-1)),o(f,1),i(f),f),u.round=f=>{const m=u(f),g=u.ceil(f);return f-m(o(f=new Date(+f),null==m?1:Math.floor(m)),f),u.range=(f,m,g)=>{const b=[];if(f=u.ceil(f),g=null==g?1:Math.floor(g),!(f0))return b;let v;do{b.push(v=new Date(+f)),o(f,g),i(f)}while(v$i(m=>{if(m>=m)for(;i(m),!f(m);)m.setTime(m-1)},(m,g)=>{if(m>=m)if(g<0)for(;++g<=0;)for(;o(m,-1),!f(m););else for(;--g>=0;)for(;o(m,1),!f(m););}),a&&(u.count=(f,m)=>(cs.setTime(+f),Uo.setTime(+m),i(cs),i(Uo),Math.floor(a(cs,Uo))),u.every=f=>(f=Math.floor(f),isFinite(f)&&f>0?f>1?u.filter(l?m=>l(m)%f==0:m=>u.count(0,m)%f==0):u:null)),u}const vr=1e3,po=6e4,xr=60*po,Wn=24*xr,ea=7*Wn,Xl=30*Wn,yu=365*Wn,Ri=$i(i=>i.setHours(0,0,0,0),(i,o)=>i.setDate(i.getDate()+o),(i,o)=>(o-i-(o.getTimezoneOffset()-i.getTimezoneOffset())*po)/Wn,i=>i.getDate()-1),Wi=$i(i=>{i.setUTCHours(0,0,0,0)},(i,o)=>{i.setUTCDate(i.getUTCDate()+o)},(i,o)=>(o-i)/Wn,i=>i.getUTCDate()-1),Yl=$i(i=>{i.setUTCHours(0,0,0,0)},(i,o)=>{i.setUTCDate(i.getUTCDate()+o)},(i,o)=>(o-i)/Wn,i=>Math.floor(i/Wn));function Ao(i){return $i(o=>{o.setDate(o.getDate()-(o.getDay()+7-i)%7),o.setHours(0,0,0,0)},(o,a)=>{o.setDate(o.getDate()+7*a)},(o,a)=>(a-o-(a.getTimezoneOffset()-o.getTimezoneOffset())*po)/ea)}const ta=Ao(0),As=Ao(1),Ho=(Ao(2),Ao(3),Ao(4));function nn(i){return $i(o=>{o.setUTCDate(o.getUTCDate()-(o.getUTCDay()+7-i)%7),o.setUTCHours(0,0,0,0)},(o,a)=>{o.setUTCDate(o.getUTCDate()+7*a)},(o,a)=>(a-o)/ea)}Ao(5),Ao(6);const gi=nn(0),Ts=nn(1),Kl=(nn(2),nn(3),nn(4)),di=(nn(5),nn(6),$i(i=>{i.setMonth(0,1),i.setHours(0,0,0,0)},(i,o)=>{i.setFullYear(i.getFullYear()+o)},(i,o)=>o.getFullYear()-i.getFullYear(),i=>i.getFullYear()));di.every=i=>isFinite(i=Math.floor(i))&&i>0?$i(o=>{o.setFullYear(Math.floor(o.getFullYear()/i)*i),o.setMonth(0,1),o.setHours(0,0,0,0)},(o,a)=>{o.setFullYear(o.getFullYear()+a*i)}):null;const za=$i(i=>{i.setUTCMonth(0,1),i.setUTCHours(0,0,0,0)},(i,o)=>{i.setUTCFullYear(i.getUTCFullYear()+o)},(i,o)=>o.getUTCFullYear()-i.getUTCFullYear(),i=>i.getUTCFullYear());za.every=i=>isFinite(i=Math.floor(i))&&i>0?$i(o=>{o.setUTCFullYear(Math.floor(o.getUTCFullYear()/i)*i),o.setUTCMonth(0,1),o.setUTCHours(0,0,0,0)},(o,a)=>{o.setUTCFullYear(o.getUTCFullYear()+a*i)}):null;const Nc=$i(i=>{i.setDate(1),i.setHours(0,0,0,0)},(i,o)=>{i.setMonth(i.getMonth()+o)},(i,o)=>o.getMonth()-i.getMonth()+12*(o.getFullYear()-i.getFullYear()),i=>i.getMonth()),Mf=$i(i=>{i.setUTCDate(1),i.setUTCHours(0,0,0,0)},(i,o)=>{i.setUTCMonth(i.getUTCMonth()+o)},(i,o)=>o.getUTCMonth()-i.getUTCMonth()+12*(o.getUTCFullYear()-i.getUTCFullYear()),i=>i.getUTCMonth()),Va=$i(i=>{i.setTime(i-i.getMilliseconds()-i.getSeconds()*vr-i.getMinutes()*po)},(i,o)=>{i.setTime(+i+o*xr)},(i,o)=>(o-i)/xr,i=>i.getHours()),K0=$i(i=>{i.setUTCMinutes(0,0,0)},(i,o)=>{i.setTime(+i+o*xr)},(i,o)=>(o-i)/xr,i=>i.getUTCHours()),Bi=$i(i=>{i.setTime(i-i.getMilliseconds()-i.getSeconds()*vr)},(i,o)=>{i.setTime(+i+o*po)},(i,o)=>(o-i)/po,i=>i.getMinutes()),R1=$i(i=>{i.setUTCSeconds(0,0)},(i,o)=>{i.setTime(+i+o*po)},(i,o)=>(o-i)/po,i=>i.getUTCMinutes()),qh=$i(i=>{i.setTime(i-i.getMilliseconds())},(i,o)=>{i.setTime(+i+o*vr)},(i,o)=>(o-i)/vr,i=>i.getUTCSeconds()),Af=$i(()=>{},(i,o)=>{i.setTime(+i+o)},(i,o)=>o-i);function Tf(i,o){return null==i||null==o?NaN:io?1:i>=o?0:NaN}function SM(i,o){return null==i||null==o?NaN:oi?1:o>=i?0:NaN}function Fc(i){let o,a,l;function u(g,b,v=0,w=g.length){if(v>>1;a(g[C],b)<0?v=C+1:w=C}while(vTf(i(g),b),l=(g,b)=>i(g)-b):(o=i===Tf||i===SM?i:xa,a=i,l=i),{left:u,center:function m(g,b,v=0,w=g.length){const C=u(g,b,v,w-1);return C>v&&l(g[C-1],b)>-l(g[C],b)?C-1:C},right:function f(g,b,v=0,w=g.length){if(v>>1;a(g[C],b)<=0?v=C+1:w=C}while(v(i=Math.floor(i),isFinite(i)&&i>0?i>1?$i(o=>{o.setTime(Math.floor(o/i)*i)},(o,a)=>{o.setTime(+o+a*i)},(o,a)=>(a-o)/i):Af:null);const Or="year",Mr="quarter",na="month",To="week",ja="date",wa="day",fd="dayofyear",Pc="hours",Rr="minutes",rn="seconds",hd="milliseconds",M2=[Or,Mr,na,To,ja,wa,fd,Pc,Rr,rn,hd],A2=M2.reduce((i,o,a)=>(i[o]=1+a,i),{});function T2(i){const o=(0,N.IX)(i).slice(),a={};return o.length||(0,N.vU)("Missing time unit."),o.forEach(u=>{(0,N.nr)(A2,u)?a[u]=1:(0,N.vU)(`Invalid time unit: ${u}.`)}),(a[To]||a[wa]?1:0)+(a[Mr]||a[na]||a[ja]?1:0)+(a[fd]?1:0)>1&&(0,N.vU)(`Incompatible time units: ${i}`),o.sort((u,f)=>A2[u]-A2[f]),o}const Ue={[Or]:"%Y ",[Mr]:"Q%q ",[na]:"%b ",[ja]:"%d ",[To]:"W%U ",[wa]:"%a ",[fd]:"%j ",[Pc]:"%H:00",[Rr]:"00:%M",[rn]:":%S",[hd]:".%L",[`${Or}-${na}`]:"%Y-%m ",[`${Or}-${na}-${ja}`]:"%Y-%m-%d ",[`${Pc}-${Rr}`]:"%H:%M"};function q$(i,o){const a=(0,N.l7)({},Ue,o),l=T2(i),u=l.length;let g,b,f="",m=0;for(m=0;mm;--g)if(b=l.slice(m,g).join("-"),null!=a[b]){f+=a[b],m=g;break}return f.trim()}const Tt=new Date;function q_(i){return Tt.setFullYear(i),Tt.setMonth(0),Tt.setDate(1),Tt.setHours(0,0,0,0),Tt}function k2(i){return Z0(new Date(i))}function DM(i){return $m(new Date(i))}function Z0(i){return Ri.count(q_(i.getFullYear())-1,i)}function $m(i){return ta.count(q_(i.getFullYear())-1,i)}function kf(i){return q_(i).getDay()}function Ql(i,o,a,l,u,f,m){if(0<=i&&i<100){const g=new Date(-1,o,a,l,u,f,m);return g.setFullYear(i),g}return new Date(i,o,a,l,u,f,m)}function Yr(i){return fi(new Date(i))}function Q0(i){return If(new Date(i))}function fi(i){const o=Date.UTC(i.getUTCFullYear(),0,1);return Wi.count(o-1,i)}function If(i){const o=Date.UTC(i.getUTCFullYear(),0,1);return gi.count(o-1,i)}function G_(i){return Tt.setTime(Date.UTC(i,0,1)),Tt.getUTCDay()}function us(i,o,a,l,u,f,m){if(0<=i&&i<100){const g=new Date(Date.UTC(-1,o,a,l,u,f,m));return g.setUTCFullYear(a.y),g}return new Date(Date.UTC(i,o,a,l,u,f,m))}function MM(i,o,a,l,u){const f=o||1,m=(0,N.fj)(i),g=(L,z,V)=>function jU(i,o,a,l){const u=a<=1?i:l?(f,m)=>l+a*Math.floor((i(f,m)-l)/a):(f,m)=>a*Math.floor(i(f,m)/a);return o?(f,m)=>o(u(f,m),m):u}(a[V=V||L],l[V],L===m&&f,z),b=new Date,v=(0,N.Rg)(i),w=v[Or]?g(Or):(0,N.a9)(2012),C=v[na]?g(na):v[Mr]?g(Mr):N.bM,D=v[To]&&v[wa]?g(wa,1,To+wa):v[To]?g(To,1):v[wa]?g(wa,1):v[ja]?g(ja,1):v[fd]?g(fd,1):N.kX,T=v[Pc]?g(Pc):N.bM,I=v[Rr]?g(Rr):N.bM,k=v[rn]?g(rn):N.bM,F=v[hd]?g(hd):N.bM;return function(L){b.setTime(+L);const z=w(b);return u(z,C(b),D(b,z),T(b),I(b),k(b),F(b))}}function Ai(i,o,a){return o+7*i-(a+6)%7}const UU={[Or]:i=>i.getFullYear(),[Mr]:i=>Math.floor(i.getMonth()/3),[na]:i=>i.getMonth(),[ja]:i=>i.getDate(),[Pc]:i=>i.getHours(),[Rr]:i=>i.getMinutes(),[rn]:i=>i.getSeconds(),[hd]:i=>i.getMilliseconds(),[fd]:i=>Z0(i),[To]:i=>$m(i),[To+wa]:(i,o)=>Ai($m(i),i.getDay(),kf(o)),[wa]:(i,o)=>Ai(1,i.getDay(),kf(o))},HU={[Mr]:i=>3*i,[To]:(i,o)=>Ai(i,0,kf(o))};function $e(i,o){return MM(i,o||1,UU,HU,Ql)}const AM={[Or]:i=>i.getUTCFullYear(),[Mr]:i=>Math.floor(i.getUTCMonth()/3),[na]:i=>i.getUTCMonth(),[ja]:i=>i.getUTCDate(),[Pc]:i=>i.getUTCHours(),[Rr]:i=>i.getUTCMinutes(),[rn]:i=>i.getUTCSeconds(),[hd]:i=>i.getUTCMilliseconds(),[fd]:i=>fi(i),[To]:i=>If(i),[wa]:(i,o)=>Ai(1,i.getUTCDay(),G_(o)),[To+wa]:(i,o)=>Ai(If(i),i.getUTCDay(),G_(o))},TM={[Mr]:i=>3*i,[To]:(i,o)=>Ai(i,0,G_(o))};function J0(i,o){return MM(i,o||1,AM,TM,us)}const N1={[Or]:di,[Mr]:Nc.every(3),[na]:Nc,[To]:ta,[ja]:Ri,[wa]:Ri,[fd]:Ri,[Pc]:Va,[Rr]:Bi,[rn]:qh,[hd]:Af},I2={[Or]:za,[Mr]:Mf.every(3),[na]:Mf,[To]:gi,[ja]:Wi,[wa]:Wi,[fd]:Wi,[Pc]:K0,[Rr]:R1,[rn]:qh,[hd]:Af};function Of(i){return N1[i]}function Bm(i){return I2[i]}function ev(i,o,a){return i?i.offset(o,a):void 0}function pd(i,o,a){return ev(Of(i),o,a)}function O2(i,o,a){return ev(Bm(i),o,a)}function kM(i,o,a,l){return i?i.range(o,a,l):void 0}function X_(i,o,a,l){return kM(Of(i),o,a,l)}function tv(i,o,a,l){return kM(Bm(i),o,a,l)}const Gh=6e4,Y_=60*Gh,nv=24*Y_,Ua=30*nv,K_=365*nv,md=[Or,na,ja,Pc,Rr,rn,hd],zm=md.slice(0,-1),pe=zm.slice(0,-1),Vm=pe.slice(0,-1),Xe=Vm.slice(0,-1),sr=[Or,na],oo=[Or],Lc=[[zm,1,1e3],[zm,5,5e3],[zm,15,15e3],[zm,30,3e4],[pe,1,Gh],[pe,5,5*Gh],[pe,15,15*Gh],[pe,30,30*Gh],[Vm,1,Y_],[Vm,3,3*Y_],[Vm,6,6*Y_],[Vm,12,12*Y_],[Xe,1,nv],[[Or,To],1,6048e5],[sr,1,Ua],[sr,3,3*Ua],[oo,1,K_]];function Q_(i){const o=i.extent,a=i.maxbins||40,l=Math.abs((0,N.yP)(o))/a;let f,m,u=Fc(g=>g[2]).right(Lc,l);return u===Lc.length?(f=oo,m=fr(o[0]/K_,o[1]/K_,a)):u?(u=Lc[l/Lc[u-1][2]=12)]},q:function Pe(je){return 1+~~(je.getMonth()/3)},Q:$c,s:Gm,S:ia,u:ov,U:VM,V:jM,w:UM,W:Tr,x:null,X:null,y:mt,Y:yo,Z:ra,"%":qm},U={a:function Ie(je){return m[je.getUTCDay()]},A:function Ne(je){return f[je.getUTCDay()]},b:function Ve(je){return b[je.getUTCMonth()]},B:function ft(je){return g[je.getUTCMonth()]},c:null,d:nc,e:nc,f:jn,g:sv,G:$n,H:Um,I:kr,j:Ca,L:wu,m:ty,M:P1,p:function Ke(je){return u[+(je.getUTCHours()>=12)]},q:function Dt(je){return 1+~~(je.getUTCMonth()/3)},Q:$c,s:Gm,S:Hm,u:Kr,U:Wm,V:Eu,w:ny,W:L1,x:null,X:null,y:Ff,Y:Yh,Z:av,"%":qm},W={a:function ce(je,tt,it){var Oe=T.exec(tt.slice(it));return Oe?(je.w=I.get(Oe[0].toLowerCase()),it+Oe[0].length):-1},A:function le(je,tt,it){var Oe=C.exec(tt.slice(it));return Oe?(je.w=D.get(Oe[0].toLowerCase()),it+Oe[0].length):-1},b:function ve(je,tt,it){var Oe=L.exec(tt.slice(it));return Oe?(je.m=z.get(Oe[0].toLowerCase()),it+Oe[0].length):-1},B:function xe(je,tt,it){var Oe=k.exec(tt.slice(it));return Oe?(je.m=F.get(Oe[0].toLowerCase()),it+Oe[0].length):-1},c:function Q(je,tt,it){return Z(je,o,tt,it)},d:F1,e:F1,f:$M,g:Jl,G:Ar,H:xu,I:xu,j:Ji,L:LM,m:R2,M:ey,p:function te(je,tt,it){var Oe=v.exec(tt.slice(it));return Oe?(je.p=w.get(Oe[0].toLowerCase()),it+Oe[0].length):-1},q:ec,Q:BM,s:ln,S:PM,u:rv,U:RM,V:Ha,w:OM,W:NM,x:function J(je,tt,it){return Z(je,a,tt,it)},X:function oe(je,tt,it){return Z(je,l,tt,it)},y:Jl,Y:Ar,Z:FM,"%":Rn};function Y(je,tt){return function(it){var un,xt,ur,Oe=[],_t=-1,qt=0,Ln=je.length;for(it instanceof Date||(it=new Date(+it));++_t53)return null;"w"in Oe||(Oe.w=1),"Z"in Oe?(Ln=(qt=Ea(_o(Oe.y,0,1))).getUTCDay(),qt=Ln>4||0===Ln?Ts.ceil(qt):Ts(qt),qt=Wi.offset(qt,7*(Oe.V-1)),Oe.y=qt.getUTCFullYear(),Oe.m=qt.getUTCMonth(),Oe.d=qt.getUTCDate()+(Oe.w+6)%7):(Ln=(qt=iv(_o(Oe.y,0,1))).getDay(),qt=Ln>4||0===Ln?As.ceil(qt):As(qt),qt=Ri.offset(qt,7*(Oe.V-1)),Oe.y=qt.getFullYear(),Oe.m=qt.getMonth(),Oe.d=qt.getDate()+(Oe.w+6)%7)}else("W"in Oe||"U"in Oe)&&("w"in Oe||(Oe.w="u"in Oe?Oe.u%7:"W"in Oe?1:0),Ln="Z"in Oe?Ea(_o(Oe.y,0,1)).getUTCDay():iv(_o(Oe.y,0,1)).getDay(),Oe.m=0,Oe.d="W"in Oe?(Oe.w+6)%7+7*Oe.W-(Ln+5)%7:Oe.w+7*Oe.U-(Ln+6)%7);return"Z"in Oe?(Oe.H+=Oe.Z/100|0,Oe.M+=Oe.Z%100,Ea(Oe)):iv(Oe)}}function Z(je,tt,it,Oe){for(var un,xt,_t=0,qt=tt.length,Ln=it.length;_t=Ln)return-1;if(37===(un=tt.charCodeAt(_t++))){if(un=tt.charAt(_t++),!(xt=W[un in ds?tt.charAt(_t++):un])||(Oe=xt(je,it,Oe))<0)return-1}else if(un!=it.charCodeAt(Oe++))return-1}return Oe}return V.x=Y(a,V),V.X=Y(l,V),V.c=Y(o,V),U.x=Y(a,U),U.X=Y(l,U),U.c=Y(o,U),{format:function(je){var tt=Y(je+="",V);return tt.toString=function(){return je},tt},parse:function(je){var tt=H(je+="",!1);return tt.toString=function(){return je},tt},utcFormat:function(je){var tt=Y(je+="",U);return tt.toString=function(){return je},tt},utcParse:function(je){var tt=H(je+="",!0);return tt.toString=function(){return je},tt}}}var Bc,Nr,lv,bo,Is,ds={"-":"",_:" ",0:"0"},Je=/^\s*\d+/,ht=/^%/,IM=/[\\^$*+?|[\]().{}]/g;function Ni(i,o,a){var l=i<0?"-":"",u=(l?-i:i)+"",f=u.length;return l+(f[o.toLowerCase(),a]))}function OM(i,o,a){var l=Je.exec(o.slice(a,a+1));return l?(i.w=+l[0],a+l[0].length):-1}function rv(i,o,a){var l=Je.exec(o.slice(a,a+1));return l?(i.u=+l[0],a+l[0].length):-1}function RM(i,o,a){var l=Je.exec(o.slice(a,a+2));return l?(i.U=+l[0],a+l[0].length):-1}function Ha(i,o,a){var l=Je.exec(o.slice(a,a+2));return l?(i.V=+l[0],a+l[0].length):-1}function NM(i,o,a){var l=Je.exec(o.slice(a,a+2));return l?(i.W=+l[0],a+l[0].length):-1}function Ar(i,o,a){var l=Je.exec(o.slice(a,a+4));return l?(i.y=+l[0],a+l[0].length):-1}function Jl(i,o,a){var l=Je.exec(o.slice(a,a+2));return l?(i.y=+l[0]+(+l[0]>68?1900:2e3),a+l[0].length):-1}function FM(i,o,a){var l=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(o.slice(a,a+6));return l?(i.Z=l[1]?0:-(l[2]+(l[3]||"00")),a+l[0].length):-1}function ec(i,o,a){var l=Je.exec(o.slice(a,a+1));return l?(i.q=3*l[0]-3,a+l[0].length):-1}function R2(i,o,a){var l=Je.exec(o.slice(a,a+2));return l?(i.m=l[0]-1,a+l[0].length):-1}function F1(i,o,a){var l=Je.exec(o.slice(a,a+2));return l?(i.d=+l[0],a+l[0].length):-1}function Ji(i,o,a){var l=Je.exec(o.slice(a,a+3));return l?(i.m=0,i.d=+l[0],a+l[0].length):-1}function xu(i,o,a){var l=Je.exec(o.slice(a,a+2));return l?(i.H=+l[0],a+l[0].length):-1}function ey(i,o,a){var l=Je.exec(o.slice(a,a+2));return l?(i.M=+l[0],a+l[0].length):-1}function PM(i,o,a){var l=Je.exec(o.slice(a,a+2));return l?(i.S=+l[0],a+l[0].length):-1}function LM(i,o,a){var l=Je.exec(o.slice(a,a+3));return l?(i.L=+l[0],a+l[0].length):-1}function $M(i,o,a){var l=Je.exec(o.slice(a,a+6));return l?(i.L=Math.floor(l[0]/1e3),a+l[0].length):-1}function Rn(i,o,a){var l=ht.exec(o.slice(a,a+1));return l?a+l[0].length:-1}function BM(i,o,a){var l=Je.exec(o.slice(a));return l?(i.Q=+l[0],a+l[0].length):-1}function ln(i,o,a){var l=Je.exec(o.slice(a));return l?(i.s=+l[0],a+l[0].length):-1}function Ft(i,o){return Ni(i.getDate(),o,2)}function zM(i,o){return Ni(i.getHours(),o,2)}function Vt(i,o){return Ni(i.getHours()%12||12,o,2)}function fs(i,o){return Ni(1+Ri.count(di(i),i),o,3)}function Jn(i,o){return Ni(i.getMilliseconds(),o,3)}function Wo(i,o){return Jn(i,o)+"000"}function ks(i,o){return Ni(i.getMonth()+1,o,2)}function Nf(i,o){return Ni(i.getMinutes(),o,2)}function ia(i,o){return Ni(i.getSeconds(),o,2)}function ov(i){var o=i.getDay();return 0===o?7:o}function VM(i,o){return Ni(ta.count(di(i)-1,i),o,2)}function jm(i){var o=i.getDay();return o>=4||0===o?Ho(i):Ho.ceil(i)}function jM(i,o){return i=jm(i),Ni(Ho.count(di(i),i)+(4===di(i).getDay()),o,2)}function UM(i){return i.getDay()}function Tr(i,o){return Ni(As.count(di(i)-1,i),o,2)}function mt(i,o){return Ni(i.getFullYear()%100,o,2)}function _n(i,o){return Ni((i=jm(i)).getFullYear()%100,o,2)}function yo(i,o){return Ni(i.getFullYear()%1e4,o,4)}function tc(i,o){var a=i.getDay();return Ni((i=a>=4||0===a?Ho(i):Ho.ceil(i)).getFullYear()%1e4,o,4)}function ra(i){var o=i.getTimezoneOffset();return(o>0?"-":(o*=-1,"+"))+Ni(o/60|0,"0",2)+Ni(o%60,"0",2)}function nc(i,o){return Ni(i.getUTCDate(),o,2)}function Um(i,o){return Ni(i.getUTCHours(),o,2)}function kr(i,o){return Ni(i.getUTCHours()%12||12,o,2)}function Ca(i,o){return Ni(1+Wi.count(za(i),i),o,3)}function wu(i,o){return Ni(i.getUTCMilliseconds(),o,3)}function jn(i,o){return wu(i,o)+"000"}function ty(i,o){return Ni(i.getUTCMonth()+1,o,2)}function P1(i,o){return Ni(i.getUTCMinutes(),o,2)}function Hm(i,o){return Ni(i.getUTCSeconds(),o,2)}function Kr(i){var o=i.getUTCDay();return 0===o?7:o}function Wm(i,o){return Ni(gi.count(za(i)-1,i),o,2)}function Xh(i){var o=i.getUTCDay();return o>=4||0===o?Kl(i):Kl.ceil(i)}function Eu(i,o){return i=Xh(i),Ni(Kl.count(za(i),i)+(4===za(i).getUTCDay()),o,2)}function ny(i){return i.getUTCDay()}function L1(i,o){return Ni(Ts.count(za(i)-1,i),o,2)}function Ff(i,o){return Ni(i.getUTCFullYear()%100,o,2)}function sv(i,o){return Ni((i=Xh(i)).getUTCFullYear()%100,o,2)}function Yh(i,o){return Ni(i.getUTCFullYear()%1e4,o,4)}function $n(i,o){var a=i.getUTCDay();return Ni((i=a>=4||0===a?Kl(i):Kl.ceil(i)).getUTCFullYear()%1e4,o,4)}function av(){return"+0000"}function qm(){return"%"}function $c(i){return+i}function Gm(i){return Math.floor(+i/1e3)}function zc(i){const o={};return a=>o[a]||(o[a]=i(a))}function uv(i){const o=zc(i.format),a=i.formatPrefix;return{format:o,formatPrefix:a,formatFloat(l){const u=Qi(l||",");if(null==u.precision){switch(u.precision=12,u.type){case"%":u.precision-=2;break;case"e":u.precision-=1}return function cv(i,o){return a=>{const l=i(a),u=l.indexOf(o);if(u<0)return l;let f=function ml(i,o){let l,a=i.lastIndexOf("e");if(a>0)return a;for(a=i.length;--a>o;)if(l=i.charCodeAt(a),l>=48&&l<=57)return a+1}(l,u);const m=fu;)if("0"!==l[f]){++f;break}return l.slice(0,f)+m}}(o(u),o(".1f")(1)[1])}return o(u)},formatSpan(l,u,f,m){m=Qi(m??",f");const g=fr(l,u,f),b=Math.max(Math.abs(l),Math.abs(u));let v;if(null==m.precision)switch(m.type){case"s":return isNaN(v=Dn(g,b))||(m.precision=v),a(m,b);case"":case"e":case"g":case"p":case"r":isNaN(v=Jt(g,b))||(m.precision=v-("e"===m.type));break;case"f":case"%":isNaN(v=Hi(g))||(m.precision=v-2*("%"===m.type))}return o(m)}}}let B1,qM;function HM(){return B1=uv({format:va,formatPrefix:Ms})}function dv(i){return uv(ro(i))}function iy(i){return arguments.length?B1=dv(i):B1}function WM(i,o,a){(0,N.Kn)(a=a||{})||(0,N.vU)(`Invalid time multi-format specifier: ${a}`);const l=o(rn),u=o(Rr),f=o(Pc),m=o(ja),g=o(To),b=o(na),v=o(Mr),w=o(Or),C=i(a[hd]||".%L"),D=i(a[rn]||":%S"),T=i(a[Rr]||"%I:%M"),I=i(a[Pc]||"%I %p"),k=i(a[ja]||a[wa]||"%a %d"),F=i(a[To]||"%b %d"),L=i(a[na]||"%B"),z=i(a[Mr]||"%B"),V=i(a[Or]||"%Y");return U=>(l(U)(0,N.HD)(l)?o(l):WM(o,Of,l),utcFormat:l=>(0,N.HD)(l)?a(l):WM(a,Bm,l),timeParse:zc(i.parse),utcParse:zc(i.utcParse)}}function N2(){return qM=fv({format:Nr,parse:lv,utcFormat:bo,utcParse:Is})}function F2(i){return fv(pl(i))}function hv(i){return arguments.length?qM=F2(i):qM}!function $1(i){Bc=pl(i),Nr=Bc.format,lv=Bc.parse,bo=Bc.utcFormat,Is=Bc.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}),HM(),N2();const z1=(i,o)=>(0,N.l7)({},i,o);function GM(i,o){const a=i?dv(i):iy(),l=o?F2(o):hv();return z1(a,l)}function XM(i,o){const a=arguments.length;return a&&2!==a&&(0,N.vU)("defaultLocale expects either zero or two arguments."),a?z1(iy(i),hv(o)):z1(iy(),hv())}function G$(){return HM(),N2(),XM()}const X$=/^(data:|([A-Za-z]+:)?\/\/)/,Y$=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp|file|data):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i,P2=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,L2="file://";function KM(i,o){return ZM.apply(this,arguments)}function ZM(){return(ZM=(0,ai.Z)(function*(i,o){const a=yield this.sanitize(i,o),l=a.href;return a.localFile?this.file(l):this.http(l,o)})).apply(this,arguments)}function K$(i,o){return QM.apply(this,arguments)}function QM(){return(QM=(0,ai.Z)(function*(i,o){o=(0,N.l7)({},this.options,o);const a=this.fileAccess,l={href:null};let u,f,m;const g=Y$.test(i.replace(P2,""));(null==i||"string"!=typeof i||!g)&&(0,N.vU)("Sanitize failure, invalid URI: "+(0,N.m8)(i));const b=X$.test(i);return(m=o.baseURL)&&!b&&(!i.startsWith("/")&&!m.endsWith("/")&&(i="/"+i),i=m+i),f=(u=i.startsWith(L2))||"file"===o.mode||"http"!==o.mode&&!b&&a,u?i=i.slice(L2.length):i.startsWith("//")&&("file"===o.defaultProtocol?(i=i.slice(2),f=!0):i=(o.defaultProtocol||"http")+":"+i),Object.defineProperty(l,"localFile",{value:!!f}),l.href=i,o.target&&(l.target=o.target+""),o.rel&&(l.rel=o.rel+""),"image"===o.context&&o.crossOrigin&&(l.crossOrigin=o.crossOrigin+""),l})).apply(this,arguments)}function V1(i){return i?o=>new Promise((a,l)=>{i.readFile(o,(u,f)=>{u?l(u):a(f)})}):Kh}function Kh(){return j1.apply(this,arguments)}function j1(){return(j1=(0,ai.Z)(function*(){(0,N.vU)("No file system access.")})).apply(this,arguments)}function JM(i){return i?function(){var o=(0,ai.Z)(function*(a,l){const u=(0,N.l7)({},this.options.http,l),f=l&&l.response,m=yield i(a,u);return m.ok?(0,N.mf)(m[f])?m[f]():m.text():(0,N.vU)(m.status+""+m.statusText)});return function(a,l){return o.apply(this,arguments)}}():vo}function vo(){return ry.apply(this,arguments)}function ry(){return(ry=(0,ai.Z)(function*(){(0,N.vU)("No HTTP fetch method available.")})).apply(this,arguments)}const eA=i=>null!=i&&i==i,pv=i=>!(Number.isNaN(+i)||i instanceof Date),oy={boolean:N.sw,integer:N.He,number:N.He,date:N.ZU,string:N.BB,unknown:N.yR},mv=[i=>"true"===i||"false"===i||!0===i||!1===i,i=>pv(i)&&Number.isInteger(+i),pv,i=>!Number.isNaN(Date.parse(i))],nt=["boolean","integer","number","date"];function U1(i,o){if(!i||!i.length)return"unknown";const a=i.length,l=mv.length,u=mv.map((f,m)=>m+1);for(let g,b,f=0,m=0;f0===f?m:f,0)-1]}function _d(i,o){return o.reduce((a,l)=>(a[l]=U1(i,l),a),{})}function gv(i){const o=function(a,l){const u={delimiter:i};return H1(a,l?(0,N.l7)(l,u):u)};return o.responseType="text",o}function H1(i,o){return o.header&&(i=o.header.map(N.m8).join(o.delimiter)+"\n"+i),fe(o.delimiter).parse(i+"")}function er(i,o){const a=o&&o.property?(0,N.EP)(o.property):N.yR;return(0,N.Kn)(i)&&!function B2(i){return!("function"!=typeof Buffer||!(0,N.mf)(Buffer.isBuffer))&&Buffer.isBuffer(i)}(i)?function W1(i,o){return!(0,N.kJ)(i)&&(0,N.TW)(i)&&(i=[...i]),o&&o.copy?JSON.parse(JSON.stringify(i)):i}(a(i),o):a(JSON.parse(i))}H1.responseType="text",er.responseType="json";const sy={interior:(i,o)=>i!==o,exterior:(i,o)=>i===o};function oa(i,o){let a,l,u,f;return i=er(i,o),o&&o.feature?(a=At,u=o.feature):o&&o.mesh?(a=yt,u=o.mesh,f=sy[o.filter]):(0,N.vU)("Missing TopoJSON feature or mesh parameter."),l=(l=i.objects[u])?a(i,l,f):(0,N.vU)("Invalid TopoJSON object: "+u),l&&l.features||[l]}oa.responseType="json";const Ym={dsv:H1,csv:gv(","),tsv:gv("\t"),json:er,topojson:oa};function gl(i,o){return arguments.length>1?(Ym[i]=o,this):(0,N.nr)(Ym,i)?Ym[i]:null}function Zh(i){const o=gl(i);return o&&o.responseType||"text"}function Wa(i,o,a,l){const u=gl((o=o||{}).type||"json");return u||(0,N.vU)("Unknown data format type: "+o.type),i=u(i,o),o.parse&&function nA(i,o,a,l){if(!i.length)return;const u=hv();a=a||u.timeParse,l=l||u.utcParse;let m,g,b,v,w,C,f=i.columns||Object.keys(i[0]);"auto"===o&&(o=_d(i,f)),f=Object.keys(o);const D=f.map(T=>{const I=o[T];let k,F;if(I&&(I.startsWith("date:")||I.startsWith("utc:")))return k=I.split(/:(.+)?/,2),F=k[1],("'"===F[0]&&"'"===F[F.length-1]||'"'===F[0]&&'"'===F[F.length-1])&&(F=F.slice(1,-1)),("utc"===k[0]?l:a)(F);if(!oy[I])throw Error("Illegal format pattern: "+T+":"+I);return oy[I]});for(b=0,w=i.length,C=f.length;b({options:a||{},sanitize:K$,load:KM,fileAccess:!!o,file:V1(o),http:JM(i)})}(typeof fetch<"u"&&fetch,null);function _v(i){const o=i||N.yR,a=[],l={};return a.add=u=>{const f=o(u);return l[f]||(l[f]=1,a.push(u)),a},a.remove=u=>{const f=o(u);if(l[f]){l[f]=0;const m=a.indexOf(u);m>=0&&a.splice(m,1)}return a},a}function qo(i,o){return ay.apply(this,arguments)}function ay(){return(ay=(0,ai.Z)(function*(i,o){try{yield o(i)}catch(a){i.error(a)}})).apply(this,arguments)}const yv=Symbol("vega_id");let iA=1;function ly(i){return!(!i||!Kt(i))}function Kt(i){return i[yv]}function Qh(i,o){return i[yv]=o,i}function Ti(i){const o=i===Object(i)?i:{data:i};return Kt(o)?o:Qh(o,iA++)}function cy(i){return Vc(i,Ti({}))}function Vc(i,o){for(const a in i)o[a]=i[a];return o}function An(i,o){return Qh(o,Kt(i))}function Fr(i,o){return i?o?(a,l)=>i(a,l)||Kt(o(a))-Kt(o(l)):(a,l)=>i(a,l)||Kt(a)-Kt(l):null}function z2(i){return i&&i.constructor===Lf}function Lf(){const i=[],o=[],a=[],l=[],u=[];let f=null,m=!1;return{constructor:Lf,insert(g){const b=(0,N.IX)(g),v=b.length;for(let w=0;w{I(z)&&(v[Kt(z)]=-1)});for(C=0,D=i.length;C0&&(L(k,I,T.value),g.modifies(I));for(C=0,D=u.length;C{I(z)&&v[Kt(z)]>0&&L(z,T.field,T.value)}),g.modifies(T.field);if(m)g.mod=o.length||l.length?b.filter(z=>v[Kt(z)]>0):b.slice();else for(F in w)g.mod.push(w[F]);return(f||null==f&&(o.length||l.length))&&g.clean(!0),g}}}const bv="_:mod:_";function vv(){Object.defineProperty(this,bv,{writable:!0,value:{}})}vv.prototype={set(i,o,a,l){const u=this,f=u[i],m=u[bv];return null!=o&&o>=0?(f[o]!==a||l)&&(f[o]=a,m[o+":"+i]=-1,m[i]=-1):(f!==a||l)&&(u[i]=a,m[i]=(0,N.kJ)(a)?1+a.length:-1),u},modified(i,o){const a=this[bv];if(!arguments.length){for(const l in a)if(a[l])return!0;return!1}if((0,N.kJ)(i)){for(let l=0;l=0?o+1{T instanceof ar?(T!==this&&(o&&T.targets().add(this),f.push(T)),u.push({op:T,name:C,index:D})):l.set(C,D,T)};for(m in i)if(g=i[m],"pulse"===m)(0,N.IX)(g).forEach(C=>{C instanceof ar?C!==this&&(C.targets().add(this),f.push(C)):(0,N.vU)("Pulse parameters must be operator instances.")}),this.source=g;else if((0,N.kJ)(g))for(l.set(m,-1,Array(b=g.length)),v=0;vo=l);return a.requests=0,a.done=()=>{0==--a.requests&&(i._pending=null,o(i))},i._pending=a}(l);u.requests+=1;const f=yield l.request(o,a);return l.pulse(i,l.changeset().remove(N.yb).insert(f.data||[])),u.done(),f})).apply(this,arguments)}so.prototype={_filter:N.yb,_apply:N.yR,targets(){return this._targets||(this._targets=_v(N.id))},consume(i){return arguments.length?(this._consume=!!i,this):!!this._consume},receive(i){if(this._filter(i)){const o=this.value=this._apply(i),a=this._targets,l=a?a.length:0;for(let u=0;u{const a=Date.now();return a-o>i?(o=a,1):0})},debounce(i){const o=Un();return this.targets().add(Un(null,null,(0,N.Ds)(i,a=>{const l=a.dataflow;o.receive(a),l&&l.run&&l.run()}))),o},between(i,o){let a=!1;return i.targets().add(Un(null,null,()=>a=!0)),o.targets().add(Un(null,null,()=>a=!1)),this.filter(()=>a)},detach(){this._filter=N.yb,this._targets=null}};const Os={skip:!0};function wv(i,o,a,l,u,f){const m=(0,N.l7)({},f,Os);let g,b;(0,N.mf)(a)||(a=(0,N.a9)(a)),void 0===l?g=v=>i.touch(a(v)):(0,N.mf)(l)?(b=new ar(null,l,u,!1),g=v=>{b.evaluate(v);const w=a(v),C=b.value;z2(C)?i.pulse(w,C,f):i.update(w,C,m)}):g=v=>i.update(a(v),l,m),o.apply(g)}function Sa(i,o,a,l,u,f){if(void 0===l)o.targets().add(a);else{const m=f||{},g=new ar(null,function bd(i,o){return o=(0,N.mf)(o)?o:(0,N.a9)(o),i?function(a,l){const u=o(a,l);return i.skip()||(i.skip(u!==this.value).value=u),u}:o}(a,l),u,!1);g.modified(m.force),g.rank=o.rank,o.targets().add(g),a&&(g.skip(!0),g.value=a.value,g.targets().add(a),i.connect(a,[g]))}}const Cv={};function Go(i,o,a){this.dataflow=i,this.stamp=o??-1,this.add=[],this.rem=[],this.mod=[],this.fields=null,this.encode=a||null}function vd(i,o){const a=[];return(0,N.FP)(i,o,l=>a.push(l)),a}function Sv(i,o){const a={};return i.visit(o,l=>{a[Kt(l)]=1}),l=>a[Kt(l)]?null:l}function Dv(i,o){return i?(a,l)=>i(a,l)&&o(a,l):o}function Xo(i,o,a,l){const u=this;let f=0;this.dataflow=i,this.stamp=o,this.fields=null,this.encode=l||null,this.pulses=a;for(const m of a)if(m.stamp===o){if(m.fields){const g=u.fields||(u.fields={});for(const b in m.fields)g[b]=1}m.changed(u.ADD)&&(f|=u.ADD),m.changed(u.REM)&&(f|=u.REM),m.changed(u.MOD)&&(f|=u.MOD)}this.changes=f}function Er(){return(Er=(0,ai.Z)(function*(i,o,a){const l=this,u=[];if(l._pulse)return aA(l);if(l._pending&&(yield l._pending),o&&(yield qo(l,o)),!l._touched.length)return l.debug("Dataflow invoked, but nothing to do."),l;const f=++l._clock;l._pulse=new Go(l,f,i),l._touched.forEach(w=>l._enqueue(w,!0)),l._touched=_v(N.id);let g,b,v,m=0;try{for(;l._heap.size()>0;)g=l._heap.pop(),g.rank===g.qrank?(b=g.run(l._getPulse(g,i)),b.then?b=yield b:b.async&&(u.push(b.async),b=Cv),b!==Cv&&g._targets&&g._targets.forEach(w=>l._enqueue(w)),++m):l._enqueue(g,!0)}catch(w){l._heap.clear(),v=w}if(l._input={},l._pulse=null,l.debug(`Pulse ${f}: ${m} operators`),v&&(l._postrun=[],l.error(v)),l._postrun.length){const w=l._postrun.sort((C,D)=>D.priority-C.priority);l._postrun=[];for(let C=0;Cl.runAsync(null,()=>{w.forEach(C=>{try{C(l)}catch(D){l.error(D)}})})),l})).apply(this,arguments)}function oA(){return(oA=(0,ai.Z)(function*(i,o,a){for(;this._running;)yield this._running;const l=()=>this._running=null;return(this._running=this.evaluate(i,o,a)).then(l,l),this._running})).apply(this,arguments)}function aA(i){return i.error("Dataflow already running. Use runAsync() to chain invocations."),i}Go.prototype={StopPropagation:Cv,ADD:1,REM:2,MOD:4,ADD_REM:3,ADD_MOD:5,ALL:7,REFLOW:8,SOURCE:16,NO_SOURCE:32,NO_FIELDS:64,fork(i){return new Go(this.dataflow).init(this,i)},clone(){const i=this.fork(7);return i.add=i.add.slice(),i.rem=i.rem.slice(),i.mod=i.mod.slice(),i.source&&(i.source=i.source.slice()),i.materialize(23)},addAll(){let i=this;return!i.source||i.add===i.rem||!i.rem.length&&i.source.length===i.add.length||(i=new Go(this.dataflow).init(this),i.add=i.source,i.rem=[]),i},init(i,o){const a=this;return a.stamp=i.stamp,a.encode=i.encode,i.fields&&!(64&o)&&(a.fields=i.fields),1&o?(a.addF=i.addF,a.add=i.add):(a.addF=null,a.add=[]),2&o?(a.remF=i.remF,a.rem=i.rem):(a.remF=null,a.rem=[]),4&o?(a.modF=i.modF,a.mod=i.mod):(a.modF=null,a.mod=[]),32&o?(a.srcF=null,a.source=null):(a.srcF=i.srcF,a.source=i.source,i.cleans&&(a.cleans=i.cleans)),a},runAfter(i){this.dataflow.runAfter(i)},changed(i){const o=i||7;return 1&o&&this.add.length||2&o&&this.rem.length||4&o&&this.mod.length},reflow(i){if(i)return this.fork(7).reflow();const o=this.add.length,a=this.source&&this.source.length;return a&&a!==o&&(this.mod=this.source,o&&this.filter(4,Sv(this,1))),this},clean(i){return arguments.length?(this.cleans=!!i,this):this.cleans},modifies(i){const o=this.fields||(this.fields={});return(0,N.kJ)(i)?i.forEach(a=>o[a]=!0):o[i]=!0,this},modified(i,o){const a=this.fields;return!(!o&&!this.mod.length||!a)&&(arguments.length?(0,N.kJ)(i)?i.some(l=>a[l]):a[i]:!!a)},filter(i,o){const a=this;return 1&i&&(a.addF=Dv(a.addF,o)),2&i&&(a.remF=Dv(a.remF,o)),4&i&&(a.modF=Dv(a.modF,o)),16&i&&(a.srcF=Dv(a.srcF,o)),a},materialize(i){const o=this;return 1&(i=i||7)&&o.addF&&(o.add=vd(o.add,o.addF),o.addF=null),2&i&&o.remF&&(o.rem=vd(o.rem,o.remF),o.remF=null),4&i&&o.modF&&(o.mod=vd(o.mod,o.modF),o.modF=null),16&i&&o.srcF&&(o.source=o.source.filter(o.srcF),o.srcF=null),o},visit(i,o){const a=this,l=o;if(16&i)return(0,N.FP)(a.source,a.srcF,l),a;1&i&&(0,N.FP)(a.add,a.addF,l),2&i&&(0,N.FP)(a.rem,a.remF,l),4&i&&(0,N.FP)(a.mod,a.modF,l);const u=a.source;if(8&i&&u){const f=a.add.length+a.mod.length;f===u.length||(0,N.FP)(u,f?Sv(a,5):a.srcF,l)}return a}},(0,N.XW)(Xo,Go,{fork(i){const o=new Go(this.dataflow).init(this,i&this.NO_FIELDS);return void 0!==i&&(i&o.ADD&&this.visit(o.ADD,a=>o.add.push(a)),i&o.REM&&this.visit(o.REM,a=>o.rem.push(a)),i&o.MOD&&this.visit(o.MOD,a=>o.mod.push(a))),o},changed(i){return this.changes&i},modified(i){const o=this,a=o.fields;return a&&o.changes&o.MOD?(0,N.kJ)(i)?i.some(l=>a[l]):a[i]:0},filter(){(0,N.vU)("MultiPulse does not support filtering.")},materialize(){(0,N.vU)("MultiPulse does not support materialization.")},visit(i,o){const a=this,l=a.pulses,u=l.length;let f=0;if(i&a.SOURCE)for(;fo&&(f=a-1>>1,u=i[f],l(m,u)<0);)i[a]=u,a=f;return i[a]=m}function xd(){this.logger((0,N.kg)()),this.logLevel(N.jj),this._clock=0,this._rank=0,this._locale=XM();try{this._loader=Pf()}catch{}this._touched=_v(N.id),this._input={},this._pulse=null,this._heap=function nE(i){let o=[];return{clear:()=>o=[],size:()=>o.length,peek:()=>o[0],push:a=>(o.push(a),Rs(o,0,o.length-1,i)),pop:()=>{const a=o.pop();let l;return o.length?(l=o[0],o[0]=a,function iE(i,o,a){const l=o,u=i.length,f=i[o];let g,m=1+(o<<1);for(;m=0&&(m=g),i[o]=i[m],m=1+((o=m)<<1);i[o]=f,Rs(i,l,o,a)}(o,0,i)):l=a,l}}}((i,o)=>i.qrank-o.qrank),this._postrun=[]}function _l(i){return function(){return this._log[i].apply(this,arguments)}}function ze(i,o){ar.call(this,i,null,o)}xd.prototype={stamp(){return this._clock},loader(i){return arguments.length?(this._loader=i,this):this._loader},locale(i){return arguments.length?(this._locale=i,this):this._locale},logger(i){return arguments.length?(this._log=i,this):this._log},error:_l("error"),warn:_l("warn"),info:_l("info"),debug:_l("debug"),logLevel:_l("level"),cleanThreshold:1e4,add:function qe(i,o,a,l){let f,u=1;return i instanceof ar?f=i:i&&i.prototype instanceof ar?f=new i:(0,N.mf)(i)?f=new ar(null,i):(u=0,f=new ar(i,o)),this.rank(f),u&&(l=a,a=o),a&&this.connect(f,f.parameters(a,l)),this.touch(f),f},connect:function bi(i,o){const a=i.rank,l=o.length;for(let u=0;u=0;)o.push(a=l[u]),a===i&&(0,N.vU)("Cycle detected in dataflow graph.")},pulse:function Mv(i,o,a){this.touch(i,a||tE);const l=new Go(this,this._clock+(this._pulse?0:1)),u=i.pulse&&i.pulse.source||[];return l.target=i,this._input[i.id]=o.pulse(l,u),this},touch:function Qm(i,o){const a=o||tE;return this._pulse?this._enqueue(i):this._touched.add(i),a.skip&&i.skip(!0),this},update:function fy(i,o,a){const l=a||tE;return(i.set(o)||l.force)&&this.touch(i,l),this},changeset:Lf,ingest:function ic(i,o,a){return o=this.parse(o,a),this.pulse(i,this.changeset().insert(o))},parse:function Zm(i,o){const a=this.locale();return Wa(i,o,a.timeParse,a.utcParse)},preload:function V2(i,o,a){return Z1.apply(this,arguments)},request:function K1(i,o){return yd.apply(this,arguments)},events:function rA(i,o,a,l){const u=this,f=Un(a,l),m=function(v){v.dataflow=u;try{f.receive(v)}catch(w){u.error(w)}finally{u.run()}};let g;g="string"==typeof i&&typeof document<"u"?document.querySelectorAll(i):(0,N.IX)(i);const b=g.length;for(let v=0;vu.pulse),o):this._input[i.id]||function Bf(i,o){return o&&o.stamp===i.stamp?o:(i=i.fork(),o&&o!==Cv&&(i.source=o.source),i)}(this._pulse,a&&a.pulse)}},(0,N.XW)(ze,ar,{run(i){if(i.stampthis.pulse=a):o!==i.StopPropagation&&(this.pulse=o),o},evaluate(i){const o=this.marshall(i.stamp),a=this.transform(o,i);return o.clear(),a},transform(){}});const wd={};function np(i){const o=lA(i);return o&&o.Definition||null}function lA(i){return i=i&&i.toLowerCase(),(0,N.nr)(wd,i)?wd[i]:null}function Su(i,o){let a;if(void 0===o)for(const l of i)null!=l&&(a=l)&&(a=l);else{let l=-1;for(let u of i)null!=(u=o(u,++l,i))&&(a=u)&&(a=u)}return a}function Av(i,o){let a;if(void 0===o)for(const l of i)null!=l&&(a>l||void 0===a&&l>=l)&&(a=l);else{let l=-1;for(let u of i)null!=(u=o(u,++l,i))&&(a>u||void 0===a&&u>=u)&&(a=u)}return a}function zf(i,o){return(null==i||!(i>=i))-(null==o||!(o>=o))||(io?1:0)}function Vf(i,o,a=0,l=1/0,u){if(o=Math.floor(o),a=Math.floor(Math.max(0,a)),l=Math.floor(Math.min(i.length-1,l)),!(a<=o&&o<=l))return i;for(u=void 0===u?zf:function H2(i=Tf){if(i===Tf)return zf;if("function"!=typeof i)throw new TypeError("compare is not a function");return(o,a)=>{const l=i(o,a);return l||0===l?l:(0===i(a,a))-(0===i(o,o))}}(u);l>a;){if(l-a>600){const b=l-a+1,v=o-a+1,w=Math.log(b),C=.5*Math.exp(2*w/3),D=.5*Math.sqrt(w*C*(b-C)/b)*(v-b/2<0?-1:1);Vf(i,o,Math.max(a,Math.floor(o-v*C/b+D)),Math.min(l,Math.floor(o+(b-v)*C/b+D)),u)}const f=i[o];let m=a,g=l;for(Jm(i,a,o),u(i[l],f)>0&&Jm(i,a,l);m0;)--g}0===u(i[a],f)?Jm(i,a,g):(++g,Jm(i,g,l)),g<=o&&(a=g+1),o<=g&&(l=g-1)}return i}function Jm(i,o,a){const l=i[o];i[o]=i[a],i[a]=l}function yl(i){return null===i?NaN:+i}function eg(i,o,a){if(i=Float64Array.from(function*ip(i,o){if(void 0===o)for(let a of i)null!=a&&(a=+a)>=a&&(yield a);else{let a=-1;for(let l of i)null!=(l=o(l,++a,i))&&(l=+l)>=l&&(yield l)}}(i,a)),(l=i.length)&&!isNaN(o=+o)){if(o<=0||l<2)return Av(i);if(o>=1)return Su(i);var l,u=(l-1)*o,f=Math.floor(u),m=Su(Vf(i,f).subarray(0,f+1));return m+(Av(i.subarray(f+1))-m)*(u-f)}}function Du(i,o,a=yl){if((l=i.length)&&!isNaN(o=+o)){if(o<=0||l<2)return+a(i[0],0,i);if(o>=1)return+a(i[l-1],l-1,i);var l,u=(l-1)*o,f=Math.floor(u),m=+a(i[f],f,i);return m+(+a(i[f+1],f+1,i)-m)*(u-f)}}function Mu(i,o){return eg(i,.5,o)}function*hy(i,o){if(null==o)for(let a of i)null!=a&&""!==a&&(a=+a)>=a&&(yield a);else{let a=-1;for(let l of i)l=o(l,++a,i),null!=l&&""!==l&&(l=+l)>=l&&(yield l)}}function py(i,o,a){const l=Float64Array.from(hy(i,a));return l.sort(Tf),o.map(u=>Du(l,u))}function rE(i,o){return py(i,[.25,.5,.75],o)}function rp(i,o){const a=i.length,l=function q2(i,o){const a=function cA(i,o){let l,a=0,u=0,f=0;if(void 0===o)for(let m of i)null!=m&&(m=+m)>=m&&(l=m-u,u+=l/++a,f+=l*(m-u));else{let m=-1;for(let g of i)null!=(g=o(g,++m,i))&&(g=+g)>=g&&(l=g-u,u+=l/++a,f+=l*(g-u))}if(a>1)return f/(a-1)}(i,o);return a&&Math.sqrt(a)}(i,o),u=rE(i,o);return 1.06*(Math.min(l,(u[2]-u[0])/1.34)||l||Math.abs(u[0])||1)*Math.pow(a,-.2)}function Au(i){const o=i.maxbins||20,a=i.base||10,l=Math.log(a),u=i.divide||[5,2];let g,b,v,w,C,D,f=i.extent[0],m=i.extent[1];const T=i.span||m-f||Math.abs(f)||1;if(i.step)g=i.step;else if(i.steps){for(w=T/o,C=0,D=i.steps.length;Co;)g*=a;for(C=0,D=u.length;C=v&&T/w<=o&&(g=w)}w=Math.log(g);const k=Math.pow(a,-(w>=0?0:1+~~(-w/l))-1);return(i.nice||void 0===i.nice)&&(w=Math.floor(f/g+k)*g,f=fD);const u=i.length,f=new Float64Array(u);let C,m=0,g=1,b=l(i[0]),v=b,w=b+o;for(;g=w){for(v=(b+v)/2;m>1);mu;)i[m--]=i[l]}l=u,u=f}return i}(f,o+o/4):f}function X2(i){return function(){return(i=(1103515245*i+12345)%2147483647)/2147483647}}function tg(i,o){let a,l,u;null==o&&(o=i,i=0);const f={min(m){return arguments.length?(a=m||0,u=l-a,f):a},max(m){return arguments.length?(l=m||0,u=l-a,f):l},sample:()=>a+Math.floor(u*oc()),pdf:m=>m===Math.floor(m)&&m>=a&&m=l?1:(g-a+1)/u},icdf:m=>m>=0&&m<=1?a-1+Math.floor(m*u):NaN};return f.min(i).max(o)}const jf=Math.sqrt(2*Math.PI),Y2=Math.SQRT2;let Uf=NaN;function my(i,o){i=i||0,o=o??1;let u,f,a=0,l=0;if(Uf==Uf)a=Uf,Uf=NaN;else{do{a=2*oc()-1,l=2*oc()-1,u=a*a+l*l}while(0===u||u>1);f=Math.sqrt(-2*Math.log(u)/u),a*=f,Uf=l*f}return i+a*o}function Xa(i,o,a){const l=(i-(o||0))/(a=a??1);return Math.exp(-.5*l*l)/(a*jf)}function sc(i,o,a){const l=(i-(o=o||0))/(a=a??1),u=Math.abs(l);let f;if(u>37)f=0;else{const m=Math.exp(-u*u/2);let g;u<7.07106781186547?(g=.0352624965998911*u+.700383064443688,g=g*u+6.37396220353165,g=g*u+33.912866078383,g=g*u+112.079291497871,g=g*u+221.213596169931,g=g*u+220.206867912376,f=m*g,g=.0883883476483184*u+1.75566716318264,g=g*u+16.064177579207,g=g*u+86.7807322029461,g=g*u+296.564248779674,g=g*u+637.333633378831,g=g*u+793.826512519948,g=g*u+440.413735824752,f/=g):(g=u+.65,g=u+4/g,g=u+3/g,g=u+2/g,g=u+1/g,f=m/g/2.506628274631)}return l>0?1-f:f}function ao(i,o,a){return i<0||i>1?NaN:(o||0)+(a??1)*Y2*function lE(i){let a,o=-Math.log((1-i)*(1+i));return o<6.25?(o-=3.125,a=-364441206401782e-35,a=a*o-16850591381820166e-35,a=128584807152564e-32+a*o,a=11157877678025181e-33+a*o,a=a*o-1333171662854621e-31,a=20972767875968562e-33+a*o,a=6637638134358324e-30+a*o,a=a*o-4054566272975207e-29,a=a*o-8151934197605472e-29,a=26335093153082323e-28+a*o,a=a*o-12975133253453532e-27,a=a*o-5415412054294628e-26,a=1.0512122733215323e-9+a*o,a=a*o-4.112633980346984e-9,a=a*o-2.9070369957882005e-8,a=4.2347877827932404e-7+a*o,a=a*o-13654692000834679e-22,a=a*o-13882523362786469e-21,a=.00018673420803405714+a*o,a=a*o-.000740702534166267,a=a*o-.006033670871430149,a=.24015818242558962+a*o,a=1.6536545626831027+a*o):o<16?(o=Math.sqrt(o)-3.25,a=2.2137376921775787e-9,a=9.075656193888539e-8+a*o,a=a*o-2.7517406297064545e-7,a=1.8239629214389228e-8+a*o,a=15027403968909828e-22+a*o,a=a*o-4013867526981546e-21,a=29234449089955446e-22+a*o,a=12475304481671779e-21+a*o,a=a*o-47318229009055734e-21,a=6828485145957318e-20+a*o,a=24031110387097894e-21+a*o,a=a*o-.0003550375203628475,a=.0009532893797373805+a*o,a=a*o-.0016882755560235047,a=.002491442096107851+a*o,a=a*o-.003751208507569241,a=.005370914553590064+a*o,a=1.0052589676941592+a*o,a=3.0838856104922208+a*o):Number.isFinite(o)?(o=Math.sqrt(o)-5,a=-27109920616438573e-27,a=a*o-2.555641816996525e-10,a=1.5076572693500548e-9+a*o,a=a*o-3.789465440126737e-9,a=7.61570120807834e-9+a*o,a=a*o-1.496002662714924e-8,a=2.914795345090108e-8+a*o,a=a*o-6.771199775845234e-8,a=2.2900482228026655e-7+a*o,a=a*o-9.9298272942317e-7,a=4526062597223154e-21+a*o,a=a*o-1968177810553167e-20,a=7599527703001776e-20+a*o,a=a*o-.00021503011930044477,a=a*o-.00013871931833623122,a=1.0103004648645344+a*o,a=4.849906401408584+a*o):a=1/0,a*i}(2*i-1)}function Fi(i,o){let a,l;const u={mean(f){return arguments.length?(a=f||0,u):a},stdev(f){return arguments.length?(l=f??1,u):l},sample:()=>my(a,l),pdf:f=>Xa(f,a,l),cdf:f=>sc(f,a,l),icdf:f=>ao(f,a,l)};return u.mean(i).stdev(o)}function Uc(i,o){const a=Fi();let l=0;const u={data(f){return arguments.length?(i=f,l=f?f.length:0,u.bandwidth(o)):i},bandwidth(f){return arguments.length?(!(o=f)&&i&&(o=rp(i)),u):o},sample:()=>i[~~(oc()*l)]+o*a.sample(),pdf(f){let m=0,g=0;for(;gTv(a,l),pdf:f=>kv(f,a,l),cdf:f=>Hc(f,a,l),icdf:f=>Ed(f,a,l)};return u.mean(i).stdev(o)}function Hf(i,o){let l,a=0;const f={weights(m){return arguments.length?(l=function u(m){const g=[];let v,b=0;for(v=0;v=o&&i<=a?1/(a-o):0}function Wf(i,o,a){return null==a&&(a=o??1,o=0),ia?1:(i-o)/(a-o)}function cE(i,o,a){return null==a&&(a=o??1,o=0),i>=0&&i<=1?o+i*(a-o):NaN}function uE(i,o){let a,l;const u={min(f){return arguments.length?(a=f||0,u):a},max(f){return arguments.length?(l=f??1,u):l},sample:()=>gy(a,l),pdf:f=>op(f,a,l),cdf:f=>Wf(f,a,l),icdf:f=>cE(f,a,l)};return null==o&&(o=i??1,i=0),u.min(i).max(o)}function ng(i,o,a){let l=0,u=0;for(const f of i){const m=a(f);null==o(f)||null==m||isNaN(m)||(l+=(m-l)/++u)}return{coef:[l],predict:()=>l,rSquared:0}}function Iv(i,o,a,l){const u=l-i*i,f=Math.abs(u)<1e-24?0:(a-i*o)/u;return[o-f*i,f]}function ig(i,o,a,l){i=i.filter(T=>{let I=o(T),k=a(T);return null!=I&&(I=+I)>=I&&null!=k&&(k=+k)>=k}),l&&i.sort((T,I)=>o(T)-o(I));const u=i.length,f=new Float64Array(u),m=new Float64Array(u);let w,C,D,g=0,b=0,v=0;for(D of i)f[g]=w=+o(D),m[g]=C=+a(D),++g,b+=(w-b)/g,v+=(C-v)/g;for(g=0;g=f&&null!=m&&(m=+m)>=m&&l(f,m,++u)}function rg(i,o,a,l,u){let f=0,m=0;return Ov(i,o,a,(g,b)=>{const v=b-u(g),w=b-l;f+=v*v,m+=w*w}),1-f/m}function dE(i,o,a){let l=0,u=0,f=0,m=0,g=0;Ov(i,o,a,(w,C)=>{++g,l+=(w-l)/g,u+=(C-u)/g,f+=(w*C-f)/g,m+=(w*w-m)/g});const b=Iv(l,u,f,m),v=w=>b[0]+b[1]*w;return{coef:b,predict:v,rSquared:rg(i,o,a,u,v)}}function sa(i,o,a){let l=0,u=0,f=0,m=0,g=0;Ov(i,o,a,(w,C)=>{++g,w=Math.log(w),l+=(w-l)/g,u+=(C-u)/g,f+=(w*C-f)/g,m+=(w*w-m)/g});const b=Iv(l,u,f,m),v=w=>b[0]+b[1]*Math.log(w);return{coef:b,predict:v,rSquared:rg(i,o,a,u,v)}}function fE(i,o,a){const[l,u,f,m]=ig(i,o,a);let D,T,I,g=0,b=0,v=0,w=0,C=0;Ov(i,o,a,(z,V)=>{D=l[C++],T=Math.log(V),I=D*V,g+=(V*T-g)/C,b+=(I-b)/C,v+=(I*T-v)/C,w+=(D*I-w)/C});const[k,F]=Iv(b/m,g/m,v/m,w/m),L=z=>Math.exp(k+F*(z-f));return{coef:[Math.exp(k-F*f),F],predict:L,rSquared:rg(i,o,a,m,L)}}function og(i,o,a){let l=0,u=0,f=0,m=0,g=0,b=0;Ov(i,o,a,(C,D)=>{const T=Math.log(C),I=Math.log(D);++b,l+=(T-l)/b,u+=(I-u)/b,f+=(T*I-f)/b,m+=(T*T-m)/b,g+=(D-g)/b});const v=Iv(l,u,f,m),w=C=>v[0]*Math.pow(C,v[1]);return v[0]=Math.exp(v[0]),{coef:v,predict:w,rSquared:rg(i,o,a,g,w)}}function Zr(i,o,a){const[l,u,f,m]=ig(i,o,a),g=l.length;let T,I,k,F,b=0,v=0,w=0,C=0,D=0;for(T=0;TV*(H-=f)*H+U*H+W+m;return{coef:[W-U*f+V*f*f+m,U-2*V*f,V],predict:Y,rSquared:rg(i,o,a,m,Y)}}function _y(i,o,a,l){if(0===l)return ng(i,o,a);if(1===l)return dE(i,o,a);if(2===l)return Zr(i,o,a);const[u,f,m,g]=ig(i,o,a),b=u.length,v=[],w=[],C=l+1;let D,T,I,k,F;for(D=0;DMath.abs(i[l][m])&&(m=u);for(f=l;f=l;f--)i[f][u]-=i[f][l]*i[l][u]/i[l][l]}for(u=o-1;u>=0;--u){for(g=0,f=u+1;f{let U=g+L[0]+L[1]*(V-=m)+L[2]*V*V;for(D=3;D=0;--f)for(g=o[f],b=1,u[f]+=g,m=1;m<=f;++m)b*=(f+1-m)/m,u[f-m]+=g*Math.pow(a,m)*b;return u[0]+=l,u}const aa=2,Cd=1e-12;function Tu(i,o,a,l){const[u,f,m,g]=ig(i,o,a,!0),b=u.length,v=Math.max(2,~~(l*b)),w=new Float64Array(b),C=new Float64Array(b),D=new Float64Array(b).fill(1);for(let T=-1;++T<=aa;){const I=[0,v-1];for(let F=0;Fu[V]-L?z:V]-L||1);for(let xe=z;xe<=V;++xe){const Q=u[xe],J=f[xe],oe=by(Math.abs(L-Q)*ce)*D[xe],we=Q*oe;W+=oe,Y+=we,H+=J*oe,Z+=J*we,te+=Q*we}const[le,ve]=Iv(Y/W,H/W,Z/W,te/W);w[F]=le+ve*L,C[F]=Math.abs(f[F]-w[F]),vy(u,F+1,I)}if(T===aa)break;const k=Mu(C);if(Math.abs(k)=1?Cd:(z=1-L*L)*z}return function Rv(i,o,a,l){const u=i.length,f=[];let v,m=0,g=0,b=[];for(;m=i.length))for(;o>u&&i[f]-l<=l-i[u];)a[0]=++u,a[1]=f,++f}const hE=.5*Math.PI/180;function qf(i,o,a,l){a=a||25,l=Math.max(a,l||200);const u=k=>[k,i(k)],f=o[0],m=o[1],g=m-f,b=g/l,v=[u(f)],w=[];if(a===l){for(let k=1;k0;)w.push(u(f+k/a*g));let C=v[0],D=w[w.length-1];const T=1/g,I=function Nv(i,o){let a=i,l=i;const u=o.length;for(let f=0;fl&&(l=m)}return 1/(l-a)}(C[1],w);for(;D;){const k=u((C[0]+D[0])/2);k[0]-C[0]>=b&&bl(C,k,D,T,I)>hE?w.push(k):(C=D,v.push(D),w.pop()),D=w[w.length-1]}return v}function bl(i,o,a,l,u){const f=Math.atan2(u*(a[1]-i[1]),l*(a[0]-i[0])),m=Math.atan2(u*(o[1]-i[1]),l*(o[0]-i[0]));return Math.abs(f-m)}function Qr(i,o,a){i=+i,o=+o,a=(u=arguments.length)<2?(o=i,i=0,1):u<3?1:+a;for(var l=-1,u=0|Math.max(0,Math.ceil((o-i)/a)),f=new Array(u);++l{const a=i.length;let l=1,u=String(i[0](o));for(;l{},Bn={init:sg,add:sg,rem:sg,idx:0},Yo={values:{init:i=>i.cell.store=!0,value:i=>i.cell.data.values(),idx:-1},count:{value:i=>i.cell.num},__count__:{value:i=>i.missing+i.valid},missing:{value:i=>i.missing},valid:{value:i=>i.valid},sum:{init:i=>i.sum=0,value:i=>i.valid?i.sum:void 0,add:(i,o)=>i.sum+=+o,rem:(i,o)=>i.sum-=o},product:{init:i=>i.product=1,value:i=>i.valid?i.product:void 0,add:(i,o)=>i.product*=o,rem:(i,o)=>i.product/=o},mean:{init:i=>i.mean=0,value:i=>i.valid?i.mean:void 0,add:(i,o)=>(i.mean_d=o-i.mean,i.mean+=i.mean_d/i.valid),rem:(i,o)=>(i.mean_d=o-i.mean,i.mean-=i.valid?i.mean_d/i.valid:i.mean)},average:{value:i=>i.valid?i.mean:void 0,req:["mean"],idx:1},variance:{init:i=>i.dev=0,value:i=>i.valid>1?i.dev/(i.valid-1):void 0,add:(i,o)=>i.dev+=i.mean_d*(o-i.mean),rem:(i,o)=>i.dev-=i.mean_d*(o-i.mean),req:["mean"],idx:1},variancep:{value:i=>i.valid>1?i.dev/i.valid:void 0,req:["variance"],idx:2},stdev:{value:i=>i.valid>1?Math.sqrt(i.dev/(i.valid-1)):void 0,req:["variance"],idx:2},stdevp:{value:i=>i.valid>1?Math.sqrt(i.dev/i.valid):void 0,req:["variance"],idx:2},stderr:{value:i=>i.valid>1?Math.sqrt(i.dev/(i.valid*(i.valid-1))):void 0,req:["variance"],idx:2},distinct:{value:i=>i.cell.data.distinct(i.get),req:["values"],idx:3},ci0:{value:i=>i.cell.data.ci0(i.get),req:["values"],idx:3},ci1:{value:i=>i.cell.data.ci1(i.get),req:["values"],idx:3},median:{value:i=>i.cell.data.q2(i.get),req:["values"],idx:3},q1:{value:i=>i.cell.data.q1(i.get),req:["values"],idx:3},q3:{value:i=>i.cell.data.q3(i.get),req:["values"],idx:3},min:{init:i=>i.min=void 0,value:i=>i.min=Number.isNaN(i.min)?i.cell.data.min(i.get):i.min,add:(i,o)=>{(o{o<=i.min&&(i.min=NaN)},req:["values"],idx:4},max:{init:i=>i.max=void 0,value:i=>i.max=Number.isNaN(i.max)?i.cell.data.max(i.get):i.max,add:(i,o)=>{(o>i.max||void 0===i.max)&&(i.max=o)},rem:(i,o)=>{o>=i.max&&(i.max=NaN)},req:["values"],idx:4},argmin:{init:i=>i.argmin=void 0,value:i=>i.argmin||i.cell.data.argmin(i.get),add:(i,o,a)=>{o{o<=i.min&&(i.argmin=void 0)},req:["min","values"],idx:3},argmax:{init:i=>i.argmax=void 0,value:i=>i.argmax||i.cell.data.argmax(i.get),add:(i,o,a)=>{o>i.max&&(i.argmax=a)},rem:(i,o)=>{o>=i.max&&(i.argmax=void 0)},req:["max","values"],idx:3},exponential:{init:(i,o)=>{i.exp=0,i.exp_r=o},value:i=>i.valid?i.exp*(1-i.exp_r)/(1-i.exp_r**i.valid):void 0,add:(i,o)=>i.exp=i.exp_r*i.exp+o,rem:(i,o)=>i.exp=(i.exp-o/i.exp_r**(i.valid-1))/i.exp_r},exponentialb:{value:i=>i.valid?i.exp*(1-i.exp_r):void 0,req:["exponential"],idx:1}},Ma=Object.keys(Yo).filter(i=>"__count__"!==i);function Dd(i,o,a){return Yo[i](a,o)}function ag(i,o){return i.idx-o.idx}function ap(){this.valid=0,this.missing=0,this._ops.forEach(i=>null==i.aggregate_param?i.init(this):i.init(this,i.aggregate_param))}function Z2(i,o){null!=i&&""!==i?i==i&&(++this.valid,this._ops.forEach(a=>a.add(this,i,o))):++this.missing}function pt(i,o){null!=i&&""!==i?i==i&&(--this.valid,this._ops.forEach(a=>a.rem(this,i,o))):--this.missing}function Fv(i){return this._out.forEach(o=>i[o.out]=o.value(this)),i}function mE(i,o){const a=o||N.yR,l=function dA(i){const o={};i.forEach(l=>o[l.name]=l);const a=l=>{l.req&&l.req.forEach(u=>{o[u]||a(o[u]=Yo[u]())})};return i.forEach(a),Object.values(o).sort(ag)}(i),u=i.slice().sort(ag);function f(m){this._ops=l,this._out=u,this.cell=m,this.init()}return f.prototype.init=ap,f.prototype.add=Z2,f.prototype.rem=pt,f.prototype.set=Fv,f.prototype.get=a,f.fields=i.map(m=>m.out),f}function xy(i){this._key=i?(0,N.EP)(i):Kt,this.reset()}[...Ma,"__count__"].forEach(i=>{Yo[i]=function sp(i,o){return(a,l)=>(0,N.l7)({name:i,aggregate_param:l,out:a||i},Bn,o)}(i,Yo[i])});const Io=xy.prototype;function Md(i){ze.call(this,null,i),this._adds=[],this._mods=[],this._alen=0,this._mlen=0,this._drop=!0,this._cross=!1,this._dims=[],this._dnames=[],this._measures=[],this._countOnly=!1,this._counts=null,this._prev=null,this._inputs=null,this._outputs=null}function Pv(i){ze.call(this,null,i)}function Gf(i,o,a){const l=i;let u=o||[],f=a||[],m={},g=0;return{add:b=>f.push(b),remove:b=>m[l(b)]=++g,size:()=>u.length,data:(b,v)=>(g&&(u=u.filter(w=>!m[l(w)]),m={},g=0),v&&b&&u.sort(b),f.length&&(u=b?(0,N.TS)(b,u,f.sort(b)):u.concat(f),f=[]),u)}}function lp(i){ze.call(this,[],i)}function cp(i){ar.call(this,null,hA,i)}function hA(i){return this.value&&!i.modified()?this.value:(0,N.qu)(i.fields,i.orders)}function lg(i){ze.call(this,null,i)}function pA(i){ze.call(this,null,i)}Io.reset=function(){this._add=[],this._rem=[],this._ext=null,this._get=null,this._q=null},Io.add=function(i){this._add.push(i)},Io.rem=function(i){this._rem.push(i)},Io.values=function(){if(this._get=null,0===this._rem.length)return this._add;const i=this._add,o=this._rem,a=this._key,l=i.length,u=o.length,f=Array(l-u),m={};let g,b,v;for(g=0;g=0;)f=i(o[l])+"",(0,N.nr)(a,f)||(a[f]=1,++u);return u},Io.extent=function(i){if(this._get!==i||!this._ext){const o=this.values(),a=(0,N.dI)(o,i);this._ext=[o[a[0]],o[a[1]]],this._get=i}return this._ext},Io.argmin=function(i){return this.extent(i)[0]||{}},Io.argmax=function(i){return this.extent(i)[1]||{}},Io.min=function(i){const o=this.extent(i)[0];return null!=o?i(o):void 0},Io.max=function(i){const o=this.extent(i)[1];return null!=o?i(o):void 0},Io.quartile=function(i){return(this._get!==i||!this._q)&&(this._q=rE(this.values(),i),this._get=i),this._q},Io.q1=function(i){return this.quartile(i)[0]},Io.q2=function(i){return this.quartile(i)[1]},Io.q3=function(i){return this.quartile(i)[2]},Io.ci=function(i){return(this._get!==i||!this._ci)&&(this._ci=sE(this.values(),1e3,.05,i),this._get=i),this._ci},Io.ci0=function(i){return this.ci(i)[0]},Io.ci1=function(i){return this.ci(i)[1]},Md.Definition={type:"Aggregate",metadata:{generates:!0,changes:!0},params:[{name:"groupby",type:"field",array:!0},{name:"ops",type:"enum",array:!0,values:Ma},{name:"aggregate_params",type:"number",null:!0,array:!0},{name:"fields",type:"field",null:!0,array:!0},{name:"as",type:"string",null:!0,array:!0},{name:"drop",type:"boolean",default:!0},{name:"cross",type:"boolean",default:!1},{name:"key",type:"field"}]},(0,N.XW)(Md,ze,{transform(i,o){const a=this,l=o.fork(o.NO_SOURCE|o.NO_FIELDS),u=i.modified();return a.stamp=l.stamp,a.value&&(u||o.modified(a._inputs,!0))?(a._prev=a.value,a.value=u?a.init(i):Object.create(null),o.visit(o.SOURCE,f=>a.add(f))):(a.value=a.value||a.init(i),o.visit(o.REM,f=>a.rem(f)),o.visit(o.ADD,f=>a.add(f))),l.modifies(a._outputs),a._drop=!1!==i.drop,i.cross&&a._dims.length>1&&(a._drop=!1,a.cross()),o.clean()&&a._drop&&l.clean(!0).runAfter(()=>this.clean()),a.changes(l)},cross(){const i=this,o=i.value,a=i._dnames,l=a.map(()=>({})),u=a.length;function f(g){let b,v,w,C;for(b in g)for(w=g[b].tuple,v=0;v{const V=(0,N.el)(z);return u(z),a.push(V),V}),this.cellkey=i.key?i.key:Wc(this._dims),this._countOnly=!0,this._counts=[],this._measures=[];const f=i.fields||[null],m=i.ops||["count"],g=i.aggregate_params||[null],b=i.as||[],v=f.length,w={};let C,D,T,I,k,F,L;for(v!==m.length&&(0,N.vU)("Unmatched number of fields and aggregate ops."),L=0;LmE(z,z.field)),Object.create(null)},cellkey:Wc(),cell(i,o){let a=this.value[i];return a?0===a.num&&this._drop&&a.stamp{const C=l(w);w[g]=C,w[b]=null==C?null:u+f*(1+(C-u)/f)}:w=>w[g]=l(w)),o.modifies(a?m:g)},_bins(i){if(this.value&&!i.modified())return this.value;const o=i.field,a=Au(i),l=a.step;let m,g,u=a.start,f=u+Math.ceil((a.stop-u)/l)*l;null!=(m=i.anchor)&&(g=m-(u+l*Math.floor((m-u)/l)),u+=g,f+=g);const b=function(v){let w=(0,N.He)(o(v));return null==w?null:wf?1/0:(w=Math.max(u,Math.min(w,f-l)),u+l*Math.floor(1e-14+(w-u)/l))};return b.start=u,b.stop=a.stop,b.step=l,this.value=(0,N.ZE)(b,(0,N.Oj)(o),i.name||"bin_"+(0,N.el)(o))}}),lp.Definition={type:"Collect",metadata:{source:!0},params:[{name:"sort",type:"compare"}]},(0,N.XW)(lp,ze,{transform(i,o){const a=o.fork(o.ALL),l=Gf(Kt,this.value,a.materialize(a.ADD).add),u=i.sort,f=o.changed()||u&&(i.modified("sort")||o.modified(u.fields));return a.visit(a.REM,l.remove),this.modified(f),this.value=a.source=l.data(Fr(u),f),o.source&&o.source.root&&(this.value.root=o.source.root),a}}),(0,N.XW)(cp,ar),lg.Definition={type:"CountPattern",metadata:{generates:!0,changes:!0},params:[{name:"field",type:"field",required:!0},{name:"case",type:"enum",values:["upper","lower","mixed"],default:"mixed"},{name:"pattern",type:"string",default:'[\\w"]+'},{name:"stopwords",type:"string",default:""},{name:"as",type:"string",array:!0,length:2,default:["text","count"]}]},(0,N.XW)(lg,ze,{transform(i,o){const a=C=>D=>{for(var I,T=function Lv(i,o,a){switch(o){case"upper":i=i.toUpperCase();break;case"lower":i=i.toLowerCase()}return i.match(a)}(g(D),i.case,f)||[],k=0,F=T.length;ku[C]=1+(u[C]||0)),w=a(C=>u[C]-=1);return l?o.visit(o.SOURCE,v):(o.visit(o.ADD,v),o.visit(o.REM,w)),this._finish(o,b)},_parameterCheck(i,o){let a=!1;return(i.modified("stopwords")||!this._stop)&&(this._stop=new RegExp("^"+(i.stopwords||"")+"$","i"),a=!0),(i.modified("pattern")||!this._match)&&(this._match=new RegExp(i.pattern||"[\\w']+","g"),a=!0),(i.modified("field")||o.modified(i.field.fields))&&(a=!0),a&&(this._counts={}),a},_finish(i,o){const a=this._counts,l=this._tuples||(this._tuples={}),u=o[0],f=o[1],m=i.fork(i.NO_SOURCE|i.NO_FIELDS);let g,b,v;for(g in a)b=l[g],v=a[g]||0,!b&&v?(l[g]=b=Ti({}),b[u]=g,b[f]=v,m.add.push(b)):0===v?(b&&m.rem.push(b),a[g]=null,l[g]=null):b[f]!==v&&(b[f]=v,m.mod.push(b));return m.modifies(o)}}),pA.Definition={type:"Cross",metadata:{generates:!0},params:[{name:"filter",type:"expr"},{name:"as",type:"string",array:!0,length:2,default:["a","b"]}]},(0,N.XW)(pA,ze,{transform(i,o){const a=o.fork(o.NO_SOURCE),l=i.as||["a","b"],u=l[0],f=l[1],m=!this.value||o.changed(o.ADD_REM)||i.modified("as")||i.modified("filter");let g=this.value;return m?(g&&(a.rem=g),g=o.materialize(o.SOURCE).source,a.add=this.value=function ku(i,o,a,l){for(var b,v,u=[],f={},m=i.length,g=0;gcg(f,o))):typeof l[u]===qc&&l[u](i[u]);return l}function Ad(i){ze.call(this,null,i)}const Iu=[{key:{function:"normal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"lognormal"},params:[{name:"mean",type:"number",default:0},{name:"stdev",type:"number",default:1}]},{key:{function:"uniform"},params:[{name:"min",type:"number",default:0},{name:"max",type:"number",default:1}]},{key:{function:"kde"},params:[{name:"field",type:"field",required:!0},{name:"from",type:"data"},{name:"bandwidth",type:"number",default:0}]}];function _E(i,o){return i?i.map((a,l)=>o[l]||(0,N.el)(a)):null}function Td(i,o,a){const l=[],u=C=>C(b);let f,m,g,b,v,w;if(null==o)l.push(i.map(a));else for(f={},m=0,g=i.length;mo(a,i),(0,N.Oj)(o),(0,N.el)(o))}function $v(i){ze.call(this,[void 0,void 0],i)}function Ou(i,o){ar.call(this,i),this.parent=o,this.count=0}function Bv(i){ze.call(this,{},i),this._keys=(0,N.Xr)();const o=this._targets=[];o.active=0,o.forEach=a=>{for(let l=0,u=o.active;l(0,N.EP)(o)):(0,N.EP)(i.name,i.as)}function zv(i){ze.call(this,(0,N.Xr)(),i)}function vl(i){ze.call(this,[],i)}function Id(i){ze.call(this,[],i)}function xo(i){ze.call(this,null,i)}function Yf(i){ze.call(this,[],i)}Ad.Definition={type:"Density",metadata:{generates:!0},params:[{name:"extent",type:"number",array:!0,length:2},{name:"steps",type:"number"},{name:"minsteps",type:"number",default:25},{name:"maxsteps",type:"number",default:200},{name:"method",type:"string",default:"pdf",values:["pdf","cdf"]},{name:"distribution",type:"param",params:Iu.concat({key:{function:"mixture"},params:[{name:"distributions",type:"param",array:!0,params:Iu},{name:"weights",type:"number",array:!0}]})},{name:"as",type:"string",array:!0,default:["value","density"]}]},(0,N.XW)(Ad,ze,{transform(i,o){const a=o.fork(o.NO_SOURCE|o.NO_FIELDS);if(!this.value||o.changed()||i.modified()){const l=cg(i.distribution,function up(i){return()=>i.materialize(i.SOURCE).source}(o)),u=i.steps||i.minsteps||25,f=i.steps||i.maxsteps||200;let m=i.method||"pdf";"pdf"!==m&&"cdf"!==m&&(0,N.vU)("Invalid density method: "+m),!i.extent&&!l.data&&(0,N.vU)("Missing density extent parameter."),m=l[m];const g=i.as||["value","density"],v=qf(m,i.extent||(0,N.We)(l.data()),u,f).map(w=>{const C={};return C[g[0]]=w[0],C[g[1]]=w[1],Ti(C)});this.value&&(a.rem=this.value),this.value=a.add=a.source=v}return a}}),kd.Definition={type:"DotBin",metadata:{modifies:!0},params:[{name:"field",type:"field",required:!0},{name:"groupby",type:"field",array:!0},{name:"step",type:"number"},{name:"smooth",type:"boolean",default:!1},{name:"as",type:"string",default:"bin"}]},(0,N.XW)(kd,ze,{transform(i,o){if(this.value&&!i.modified()&&!o.changed())return o;const a=o.materialize(o.SOURCE).source,l=Td(o.source,i.groupby,N.yR),u=i.smooth||!1,f=i.field,m=i.step||((i,o)=>(0,N.yP)((0,N.We)(i,o))/30)(a,f),g=Fr((I,k)=>f(I)-f(k)),b=i.as||"bin",v=l.length;let T,w=1/0,C=-1/0,D=0;for(;DC&&(C=k),I[++T][b]=k}return this.value={start:w,stop:C,step:m},o.reflow(!0).modifies(b)}}),(0,N.XW)(Xf,ar),$v.Definition={type:"Extent",metadata:{},params:[{name:"field",type:"field",required:!0}]},(0,N.XW)($v,ze,{transform(i,o){const a=this.value,l=i.field,u=o.changed()||o.modified(l.fields)||i.modified("field");let f=a[0],m=a[1];if((u||null==f)&&(f=1/0,m=-1/0),o.visit(u?o.SOURCE:o.ADD,g=>{const b=(0,N.He)(l(g));null!=b&&(bm&&(m=b))}),!Number.isFinite(f)||!Number.isFinite(m)){let g=(0,N.el)(l);g&&(g=` for field "${g}"`),o.dataflow.warn(`Infinite extent${g}: [${f}, ${m}]`),f=m=void 0}this.value=[f,m]}}),(0,N.XW)(Ou,ar,{connect(i){return this.detachSubflow=i.detachSubflow,this.targets().add(i),i.source=this},add(i){this.count+=1,this.value.add.push(i)},rem(i){this.count-=1,this.value.rem.push(i)},mod(i){this.value.mod.push(i)},init(i){this.value.init(i,i.NO_SOURCE)},evaluate(){return this.value}}),(0,N.XW)(Bv,ze,{activate(i){this._targets[this._targets.active++]=i},subflow(i,o,a,l){const u=this.value;let m,g,f=(0,N.nr)(u,i)&&u[i];return f?f.value.stampl&&l.count>0);this.initTargets(a)}},initTargets(i){const o=this._targets,a=o.length,l=i?i.length:0;let u=0;for(;uthis.subflow(b,u,o);return this._group=i.group||{},this.initTargets(),o.visit(o.REM,b=>{const v=Kt(b),w=f.get(v);void 0!==w&&(f.delete(v),g(w).rem(b))}),o.visit(o.ADD,b=>{const v=l(b);f.set(Kt(b),v),g(v).add(b)}),m||o.modified(l.fields)?o.visit(o.MOD,b=>{const v=Kt(b),w=f.get(v),C=l(b);w===C?g(C).mod(b):(f.set(v,C),g(w).rem(b),g(C).add(b))}):o.changed(o.MOD)&&o.visit(o.MOD,b=>{g(f.get(Kt(b))).mod(b)}),m&&o.visit(o.REFLOW,b=>{const v=Kt(b),w=f.get(v),C=l(b);w!==C&&(f.set(v,C),g(w).rem(b),g(C).add(b))}),o.clean()?a.runAfter(()=>{this.clean(),f.clean()}):f.empty>a.cleanThreshold&&a.runAfter(f.clean),o}}),(0,N.XW)(wy,ar),zv.Definition={type:"Filter",metadata:{changes:!0},params:[{name:"expr",type:"expr",required:!0}]},(0,N.XW)(zv,ze,{transform(i,o){const a=o.dataflow,l=this.value,u=o.fork(),f=u.add,m=u.rem,g=u.mod,b=i.expr;let v=!0;function w(C){const D=Kt(C),T=b(C,i),I=l.get(D);T&&I?(l.delete(D),f.push(C)):T||I?v&&T&&!I&&g.push(C):(l.set(D,1),m.push(C))}return o.visit(o.REM,C=>{const D=Kt(C);l.has(D)?l.delete(D):m.push(C)}),o.visit(o.ADD,C=>{b(C,i)?f.push(C):l.set(Kt(C),1)}),o.visit(o.MOD,w),i.modified()&&(v=!1,o.visit(o.REFLOW,w)),l.empty>a.cleanThreshold&&a.runAfter(l.clean),u}}),vl.Definition={type:"Flatten",metadata:{generates:!0},params:[{name:"fields",type:"field",array:!0,required:!0},{name:"index",type:"string"},{name:"as",type:"string",array:!0}]},(0,N.XW)(vl,ze,{transform(i,o){const a=o.fork(o.NO_SOURCE),l=i.fields,u=_E(l,i.as||[]),f=i.index||null,m=u.length;return a.rem=this.value,o.visit(o.SOURCE,g=>{const b=l.map(I=>I(g)),v=b.reduce((I,k)=>Math.max(I,k.length),0);let C,D,T,w=0;for(;w{for(let C,w=0;wm[l]=a(m,i))}}),(0,N.XW)(Yf,ze,{transform(i,o){const a=o.fork(o.ALL),l=i.generator;let m,g,b,u=this.value,f=i.size-u.length;if(f>0){for(m=[];--f>=0;)m.push(b=Ti(l(i))),u.push(b);a.add=a.add.length?a.materialize(a.ADD).add.concat(m):m}else g=u.slice(0,-f),a.rem=a.rem.length?a.materialize(a.REM).rem.concat(g):g,u=u.slice(-f);return a.source=this.value=u,a}});const dp={value:"value",median:Mu,mean:function dt(i,o){let a=0,l=0;if(void 0===o)for(let u of i)null!=u&&(u=+u)>=u&&(++a,l+=u);else{let u=-1;for(let f of i)null!=(f=o(f,++u,i))&&(f=+f)>=f&&(++a,l+=f)}if(a)return l/a},min:Av,max:Su},vE=[];function Vv(i){ze.call(this,[],i)}function xE(i){Md.call(this,i)}function Ey(i){ze.call(this,null,i)}function Uv(i){ar.call(this,null,Od,i)}function Od(i){return this.value&&!i.modified()?this.value:(0,N.Jy)(i.fields,i.flat)}function Hv(i){ze.call(this,[],i),this._pending=null}function Cy(i,o,a){a.forEach(Ti);const l=o.fork(o.NO_FIELDS&o.NO_SOURCE);return l.rem=i.value,i.value=l.source=l.add=a,i._pending=null,l.rem.length&&l.clean(!0),l}function Sy(i){ze.call(this,{},i)}function qv(i){ar.call(this,null,bA,i)}function bA(i){if(this.value&&!i.modified())return this.value;const o=i.extents,a=o.length;let f,m,l=1/0,u=-1/0;for(f=0;fu&&(u=m[1]);return[l,u]}function dg(i){ar.call(this,null,vA,i)}function vA(i){return this.value&&!i.modified()?this.value:i.values.reduce((o,a)=>o.concat(a),[])}function Dy(i){ze.call(this,null,i)}function xA(i){Md.call(this,i)}function My(i){Bv.call(this,i)}function Ru(i){ze.call(this,null,i)}function EE(i){ze.call(this,null,i)}function fp(i){ze.call(this,null,i)}function CA(i){ze.call(this,null,i)}function Ay(i){ze.call(this,[],i),this.count=0}function CE(i){ze.call(this,null,i)}function Rd(i){ze.call(this,null,i),this.modified(!0)}function hp(i){ze.call(this,null,i)}Vv.Definition={type:"Impute",metadata:{changes:!0},params:[{name:"field",type:"field",required:!0},{name:"key",type:"field",required:!0},{name:"keyvals",array:!0},{name:"groupby",type:"field",array:!0},{name:"method",type:"enum",default:"value",values:["value","mean","median","max","min"]},{name:"value",default:0}]},(0,N.XW)(Vv,ze,{transform(i,o){var D,T,I,k,F,L,z,V,U,W,a=o.fork(o.ALL),l=function yA(i){var a,o=i.method||dp.value;if(null!=dp[o])return o===dp.value?(a=void 0!==i.value?i.value:0,()=>a):dp[o];(0,N.vU)("Unrecognized imputation method: "+o)}(i),u=function ug(i){const o=i.field;return a=>a?o(a):NaN}(i),f=(0,N.el)(i.field),m=(0,N.el)(i.key),g=(i.groupby||[]).map(N.el),b=function jv(i,o,a,l){var v,w,C,D,T,I,k,F,u=L=>L(F),f=[],m=l?l.slice():[],g={},b={};for(m.forEach((L,z)=>g[L]=z+1),D=0,k=i.length;Da.add(f))):(u=a.value=a.value||this.init(i),o.visit(o.REM,f=>a.rem(f)),o.visit(o.ADD,f=>a.add(f))),a.changes(),o.visit(o.SOURCE,f=>{(0,N.l7)(f,u[a.cellkey(f)].tuple)}),o.reflow(l).modifies(this._outputs)},changes(){const i=this._adds,o=this._mods;let a,l;for(a=0,l=this._alen;a{const I=Uc(T,m)[g],k=i.counts?T.length:1;qf(I,w||(0,N.We)(T),C,D).forEach(L=>{const z={};for(let V=0;V