import{hasOwnProperty as on,isNumber as G,isString as F,writeConfig as yf,splitAccessPath as an,stringValue as T,isObject as L,isBoolean as Ln,isArray as $,array as H,logger as bf,Warn as xf,isFunction as Sf,mergeConfig as Go,identity as wf}from"/-/vega-util@v1.17.2-LUfkDhormMyfWqy3Ts6U/dist=es2020,mode=imports,min/optimized/vega-util.js";import vf from"/-/clone@v2.1.2-inH2VLNzDGiYU9HUWyZM/dist=es2020,mode=imports,min/optimized/clone.js";import $f from"/-/fast-deep-equal@v3.1.3-ysejKs1WDEDPxUJhgGoP/dist=es2020,mode=imports,min/optimized/fast-deep-equal.js";import _r from"/-/fast-json-stable-stringify@v2.1.0-HLgsuOtxPikt0pw16nth/dist=es2020,mode=imports,min/optimized/fast-json-stable-stringify.js";import{isObject as kr,writeConfig as Ef,isArray as Vo,isString as mi}from"/-/vega@v5.30.0-fYDVG3pUN16BiGmbVNdw/dist=es2020,mode=imports,min/optimized/vega.js";import{parseSelector as cn}from"/-/vega-event-selector@v3.0.1-UgiEAWJA4WQL4DTKnV4R/dist=es2020,mode=imports,min/optimized/vega-event-selector.js";import{parseExpression as _f}from"/-/vega-expression@v5.1.1-K4clrYr2THuj5KncykTn/dist=es2020,mode=imports,min/optimized/vega-expression.js";const kf="vega-lite",Cf='Dominik Moritz, Kanit "Ham" Wongsuphasawat, Arvind Satyanarayan, Jeffrey Heer',Nf="5.8.0",Ff=["Kanit Wongsuphasawat (http://kanitw.yellowpigz.com)","Dominik Moritz (https://www.domoritz.de)","Arvind Satyanarayan (https://arvindsatya.com)","Jeffrey Heer (https://jheer.org)"],Tf="https://vega.github.io/vega-lite/",Af="Vega-Lite is a concise high-level language for interactive visualization.",Of=["vega","chart","visualization"],Pf="build/vega-lite.js",zf="build/vega-lite.min.js",Rf="build/vega-lite.min.js",If="build/src/index",Lf="build/src/index.d.ts",Mf={vl2pdf:"./bin/vl2pdf",vl2png:"./bin/vl2png",vl2svg:"./bin/vl2svg",vl2vg:"./bin/vl2vg"},Df=["bin","build","src","vega-lite*","tsconfig.json"],jf={changelog:"conventional-changelog -p angular -r 2",prebuild:"yarn clean:build",build:"yarn build:only","build:only":"tsc -p tsconfig.build.json && rollup -c","prebuild:examples":"yarn build:only","build:examples":"yarn data && TZ=America/Los_Angeles scripts/build-examples.sh","prebuild:examples-full":"yarn build:only","build:examples-full":"TZ=America/Los_Angeles scripts/build-examples.sh 1","build:example":"TZ=America/Los_Angeles scripts/build-example.sh","build:toc":"yarn build:jekyll && scripts/generate-toc","build:site":"rollup -c site/rollup.config.mjs","build:jekyll":"pushd site && bundle exec jekyll build -q && popd","build:versions":"scripts/update-version.sh",clean:"yarn clean:build && del-cli 'site/data/*' 'examples/compiled/*.png' && find site/examples ! -name 'index.md' ! -name 'data' -type f -delete","clean:build":"del-cli 'build/*' !build/vega-lite-schema.json",data:"rsync -r node_modules/vega-datasets/data/* site/data",schema:"mkdir -p build && ts-json-schema-generator -f tsconfig.json -p src/index.ts -t TopLevelSpec --no-type-check --no-ref-encode > build/vega-lite-schema.json && yarn renameschema && cp build/vega-lite-schema.json site/_data/",renameschema:"scripts/rename-schema.sh",presite:"yarn data && yarn schema && yarn build:site && yarn build:versions && scripts/create-example-pages.sh",site:"yarn site:only","site:only":"pushd site && bundle exec jekyll serve -I -l && popd",prettierbase:"prettier '**/*.{md,css,yml}'",format:"eslint . --fix && yarn prettierbase --write",lint:"eslint . && yarn prettierbase --check",jest:"NODE_OPTIONS=--experimental-vm-modules npx jest",test:"yarn jest test/ && yarn lint && yarn schema && yarn jest examples/ && yarn test:runtime","test:cover":"yarn jest --collectCoverage test/","test:inspect":"node --inspect-brk --experimental-vm-modules ./node_modules/.bin/jest --runInBand test","test:runtime":"NODE_OPTIONS=--experimental-vm-modules TZ=America/Los_Angeles npx jest test-runtime/ --config test-runtime/jest-config.json","test:runtime:generate":"yarn build:only && del-cli test-runtime/resources && VL_GENERATE_TESTS=true yarn test:runtime",watch:"tsc -p tsconfig.build.json -w","watch:site":"yarn build:site -w","watch:test":"yarn jest --watch test/","watch:test:runtime":"NODE_OPTIONS=--experimental-vm-modules TZ=America/Los_Angeles npx jest --watch test-runtime/ --config test-runtime/jest-config.json",release:"release-it"},Uf={type:"git",url:"https://github.com/vega/vega-lite.git"},Wf="BSD-3-Clause",Bf={url:"https://github.com/vega/vega-lite/issues"},Hf={"@babel/core":"^7.21.4","@babel/preset-env":"^7.21.4","@babel/preset-typescript":"^7.21.4","@release-it/conventional-changelog":"^5.1.1","@rollup/plugin-alias":"^5.0.0","@rollup/plugin-babel":"^6.0.3","@rollup/plugin-commonjs":"^24.1.0","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-terser":"^0.4.1","@types/chai":"^4.3.4","@types/d3":"^7.4.0","@types/jest":"^27.4.1","@types/pako":"^2.0.0","@typescript-eslint/eslint-plugin":"^5.59.1","@typescript-eslint/parser":"^5.59.1","ajv-formats":"^2.1.1",ajv:"^8.12.0",chai:"^4.3.7",cheerio:"^1.0.0-rc.12","conventional-changelog-cli":"^2.2.2",d3:"^7.8.4","del-cli":"^5.0.0","eslint-config-prettier":"^8.8.0","eslint-plugin-jest":"^27.2.1","eslint-plugin-prettier":"^4.2.1",eslint:"^8.39.0","highlight.js":"^11.7.0","jest-dev-server":"^6.1.1",jest:"^27.5.1",mkdirp:"^3.0.1",pako:"^2.1.0",prettier:"^2.8.8",puppeteer:"^15.0.0","release-it":"^15.10.1","rollup-plugin-bundle-size":"^1.0.3","rollup-plugin-sourcemaps":"^0.6.3",rollup:"^3.21.0",serve:"^14.2.0",terser:"^5.17.1","ts-jest":"^29.1.0","ts-json-schema-generator":"^1.2.0",typescript:"~4.9.5","vega-cli":"^5.25.0","vega-datasets":"^2.7.0","vega-embed":"^6.22.1","vega-tooltip":"^0.32.0","yaml-front-matter":"^4.1.1"},qf={"@types/clone":"~2.1.1",clone:"~2.1.2","fast-deep-equal":"~3.1.3","fast-json-stable-stringify":"~2.1.0","json-stringify-pretty-compact":"~3.0.0",tslib:"~2.5.0","vega-event-selector":"~3.0.1","vega-expression":"~5.1.0","vega-util":"~1.17.2",yargs:"~17.7.1"},Gf={vega:"^5.24.0"},Vf={node:">=16"};var Xf={name:kf,author:Cf,version:Nf,collaborators:Ff,homepage:Tf,description:Af,keywords:Of,main:Pf,unpkg:zf,jsdelivr:Rf,module:If,types:Lf,bin:Mf,files:Df,scripts:jf,repository:Uf,license:Wf,bugs:Bf,devDependencies:Hf,dependencies:qf,peerDependencies:Gf,engines:Vf};function Cr(e){return!!e.or}function Nr(e){return!!e.and}function Fr(e){return!!e.not}function hi(e,t){if(Fr(e))hi(e.not,t);else if(Nr(e))for(const n of e.and)hi(n,t);else if(Cr(e))for(const n of e.or)hi(n,t);else t(e)}function un(e,t){return Fr(e)?{not:un(e.not,t)}:Nr(e)?{and:e.and.map(n=>un(n,t))}:Cr(e)?{or:e.or.map(n=>un(n,t))}:t(e)}const Ie=$f,C=vf;function Xo(e){throw new Error(e)}function ln(e,t){const n={};for(const i of t)on(e,i)&&(n[i]=e[i]);return n}function ue(e,t){const n={...e};for(const i of t)delete n[i];return n}Set.prototype.toJSON=function(){return`Set(${[...this].map(e=>_r(e)).join(",")})`};const M=_r;function O(e){if(G(e))return e;const t=F(e)?e:_r(e);if(t.length<250)return t;let n=0;for(let i=0;ia===0?o:`[${o}]`),s=r.map((o,a)=>r.slice(0,a+1).join(""));for(const o of s)t.add(o)}return t}function zr(e,t){return e===void 0||t===void 0?!0:Or(Pr(e),Pr(t))}function R(e){return b(e).length===0}const b=Object.keys,ee=Object.values,mt=Object.entries;function Mn(e){return e===!0||e===!1}function W(e){const t=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+t}function Dn(e,t){return Fr(e)?`!(${Dn(e.not,t)})`:Nr(e)?`(${e.and.map(n=>Dn(n,t)).join(") && (")})`:Cr(e)?`(${e.or.map(n=>Dn(n,t)).join(") || (")})`:t(e)}function yi(e,t){if(t.length===0)return!0;const n=t.shift();return n in e&&yi(e[n],t)&&delete e[n],R(e)}function jn(e){return e.charAt(0).toUpperCase()+e.substr(1)}function Rr(e,t="datum"){const n=an(e),i=[];for(let r=1;r<=n.length;r++){const s=`[${n.slice(0,r).map(T).join("][")}]`;i.push(`${t}${s}`)}return i.join(" && ")}function Qo(e,t="datum"){return`${t}[${T(an(e).join("."))}]`}function Qf(e){return e.replace(/(\[|\]|\.|'|")/g,"\\$1")}function xe(e){return`${an(e).map(Qf).join("\\.")}`}function zt(e,t,n){return e.replace(new RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),n)}function Ir(e){return`${an(e).join(".")}`}function fn(e){return e?an(e).length:0}function V(...e){for(const t of e)if(t!==void 0)return t;return}let Zo=42;function Jo(e){const t=++Zo;return e?String(e)+t:t}function Zf(){Zo=42}function ea(e){return ta(e)?e:`__${e}`}function ta(e){return e.startsWith("__")}function Un(e){return e===void 0?void 0:(e%360+360)%360}function bi(e){return G(e)?!0:!isNaN(e)&&!isNaN(parseFloat(e))}const Ze="row",Je="column",xi="facet",B="x",K="y",Ee="x2",Me="y2",ht="xOffset",dn="yOffset",_e="radius",et="radius2",Se="theta",tt="theta2",ke="latitude",Ce="longitude",Ne="latitude2",we="longitude2",le="color",De="fill",je="stroke",fe="shape",nt="size",Rt="angle",it="opacity",yt="fillOpacity",bt="strokeOpacity",xt="strokeWidth",St="strokeDash",Wn="text",Bn="order",Hn="detail",Si="key",It="tooltip",wi="href",vi="url",$i="description",Jf={x:1,y:1,x2:1,y2:1},na={theta:1,theta2:1,radius:1,radius2:1};function ia(e){return e in na}const Lr={longitude:1,longitude2:1,latitude:1,latitude2:1};function ra(e){switch(e){case ke:return"y";case Ne:return"y2";case Ce:return"x";case we:return"x2"}}function sa(e){return e in Lr}const ed=b(Lr),Mr={...Jf,...na,...Lr,xOffset:1,yOffset:1,color:1,fill:1,stroke:1,opacity:1,fillOpacity:1,strokeOpacity:1,strokeWidth:1,strokeDash:1,size:1,angle:1,shape:1,order:1,text:1,detail:1,key:1,tooltip:1,href:1,url:1,description:1};function pn(e){return e===le||e===De||e===je}const oa={row:1,column:1,facet:1},ve=b(oa),Dr={...Mr,...oa},td=b(Dr),{order:kS,detail:CS,tooltip:NS,...nd}=Dr,{row:FS,column:TS,facet:AS,...id}=nd;function rd(e){return!!id[e]}function aa(e){return!!Dr[e]}const sd=[Ee,Me,Ne,we,tt,et];function ca(e){const t=Lt(e);return t!==e}function Lt(e){switch(e){case Ee:return B;case Me:return K;case Ne:return ke;case we:return Ce;case tt:return Se;case et:return _e}return e}function wt(e){if(ia(e))switch(e){case Se:return"startAngle";case tt:return"endAngle";case _e:return"outerRadius";case et:return"innerRadius"}return e}function Ue(e){switch(e){case B:return Ee;case K:return Me;case ke:return Ne;case Ce:return we;case Se:return tt;case _e:return et}return}function de(e){switch(e){case B:case Ee:return"width";case K:case Me:return"height"}return}function od(e){switch(e){case B:return"xOffset";case K:return"yOffset";case Ee:return"x2Offset";case Me:return"y2Offset";case Se:return"thetaOffset";case _e:return"radiusOffset";case tt:return"theta2Offset";case et:return"radius2Offset"}return}function ua(e){switch(e){case B:return"xOffset";case K:return"yOffset"}return}function la(e){switch(e){case"xOffset":return"x";case"yOffset":return"y"}}const ad=b(Mr),{x:OS,y:PS,x2:zS,y2:RS,xOffset:IS,yOffset:LS,latitude:MS,longitude:DS,latitude2:jS,longitude2:US,theta:WS,theta2:BS,radius:HS,radius2:qS,...jr}=Mr,cd=b(jr),Ur={x:1,y:1},We=b(Ur);function Q(e){return e in Ur}const Wr={theta:1,radius:1},ud=b(Wr);function Ei(e){return e==="width"?B:K}const fa={xOffset:1,yOffset:1};function gn(e){return e in fa}const{text:GS,tooltip:VS,href:XS,url:YS,description:KS,detail:QS,key:ZS,order:JS,...da}=jr,ld=b(da);function fd(e){return!!jr[e]}function dd(e){switch(e){case le:case De:case je:case nt:case fe:case it:case xt:case St:return!0;case yt:case bt:case Rt:return!1}}const pa={...Ur,...Wr,...fa,...da},_i=b(pa);function rt(e){return!!pa[e]}function pd(e,t){return md(e)[t]}const ga={arc:"always",area:"always",bar:"always",circle:"always",geoshape:"always",image:"always",line:"always",rule:"always",point:"always",rect:"always",square:"always",trail:"always",text:"always",tick:"always"},{geoshape:ew,...gd}=ga;function md(e){switch(e){case le:case De:case je:case $i:case Hn:case Si:case It:case wi:case Bn:case it:case yt:case bt:case xt:case xi:case Ze:case Je:return ga;case B:case K:case ht:case dn:case ke:case Ce:return gd;case Ee:case Me:case Ne:case we:return{area:"always",bar:"always",image:"always",rect:"always",rule:"always",circle:"binned",point:"binned",square:"binned",tick:"binned",line:"binned",trail:"binned"};case nt:return{point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",text:"always",line:"always",trail:"always"};case St:return{line:"always",point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",geoshape:"always"};case fe:return{point:"always",geoshape:"always"};case Wn:return{text:"always"};case Rt:return{point:"always",square:"always",text:"always"};case vi:return{image:"always"};case Se:return{text:"always",arc:"always"};case _e:return{text:"always",arc:"always"};case tt:case et:return{arc:"always"}}}function Br(e){switch(e){case B:case K:case Se:case _e:case ht:case dn:case nt:case Rt:case xt:case it:case yt:case bt:case Ee:case Me:case tt:case et:return;case xi:case Ze:case Je:case fe:case St:case Wn:case It:case wi:case vi:case $i:return"discrete";case le:case De:case je:return"flexible";case ke:case Ce:case Ne:case we:case Hn:case Si:case Bn:return}}const hd={argmax:1,argmin:1,average:1,count:1,distinct:1,product:1,max:1,mean:1,median:1,min:1,missing:1,q1:1,q3:1,ci0:1,ci1:1,stderr:1,stdev:1,stdevp:1,sum:1,valid:1,values:1,variance:1,variancep:1},yd={count:1,min:1,max:1};function st(e){return!!e&&!!e.argmin}function vt(e){return!!e&&!!e.argmax}function Hr(e){return F(e)&&!!hd[e]}const bd=new Set(["count","valid","missing","distinct"]);function ma(e){return F(e)&&bd.has(e)}function xd(e){return F(e)&&A(["min","max"],e)}const Sd=new Set(["count","sum","distinct","valid","missing"]),wd=new Set(["mean","average","median","q1","q3","min","max"]);function ha(e){return Ln(e)&&(e=qi(e,void 0)),"bin"+b(e).map(t=>ki(e[t])?W(`_${t}_${mt(e[t])}`):W(`_${t}_${e[t]}`)).join("")}function D(e){return e===!0||Mt(e)&&!e.binned}function te(e){return e==="binned"||Mt(e)&&e.binned===!0}function Mt(e){return L(e)}function ki(e){return e?.param}function ya(e){switch(e){case Ze:case Je:case nt:case le:case De:case je:case xt:case it:case yt:case bt:case fe:return 6;case St:return 4;default:return 10}}function qn(e){return!!e?.expr}function pe(e){const t=b(e||{}),n={};for(const i of t)n[i]=he(e[i]);return n}function ba(e){const{anchor:t,frame:n,offset:i,orient:r,angle:s,limit:o,color:a,subtitleColor:c,subtitleFont:u,subtitleFontSize:l,subtitleFontStyle:f,subtitleFontWeight:d,subtitleLineHeight:p,subtitlePadding:g,...m}=e,h={...m,...a?{fill:a}:{}},y={...t?{anchor:t}:{},...n?{frame:n}:{},...i?{offset:i}:{},...r?{orient:r}:{},...s!==void 0?{angle:s}:{},...o!==void 0?{limit:o}:{}},v={...c?{subtitleColor:c}:{},...u?{subtitleFont:u}:{},...l?{subtitleFontSize:l}:{},...f?{subtitleFontStyle:f}:{},...d?{subtitleFontWeight:d}:{},...p?{subtitleLineHeight:p}:{},...g?{subtitlePadding:g}:{}},_=ln(e,["align","baseline","dx","dy","limit"]);return{titleMarkConfig:h,subtitleMarkConfig:_,nonMarkTitleProperties:y,subtitle:v}}function $t(e){return F(e)||$(e)&&F(e[0])}function E(e){return!!e?.signal}function Et(e){return!!e.step}function vd(e){return $(e)?!1:"fields"in e&&!("data"in e)}function $d(e){return $(e)?!1:"fields"in e&&"data"in e}function ot(e){return $(e)?!1:"field"in e&&"data"in e}const Ed={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},_d=b(Ed),kd={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},qr=["cornerRadius","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight"];function xa(e){const t=$(e.condition)?e.condition.map(Sa):Sa(e.condition);return{...he(e),condition:t}}function he(e){if(qn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return e}function Sa(e){if(qn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return e}function U(e){if(qn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return E(e)?e:e!==void 0?{value:e}:void 0}function Cd(e){return E(e)?e.signal:T(e)}function wa(e){return E(e)?e.signal:T(e.value)}function at(e){return E(e)?e.signal:e==null?null:T(e)}function Nd(e,t,n){for(const i of n){const r=Dt(i,t.markDef,t.config);r!==void 0&&(e[i]=U(r))}return e}function va(e){return[].concat(e.type,e.style??[])}function z(e,t,n,i={}){const{vgChannel:r,ignoreVgConfig:s}=i;return r&&t[r]!==void 0?t[r]:t[e]!==void 0?t[e]:s&&(!r||r===e)?void 0:Dt(e,t,n,i)}function Dt(e,t,n,{vgChannel:i}={}){return V(i?Ci(e,t,n.style):void 0,Ci(e,t,n.style),i?n[t.type][i]:void 0,n[t.type][e],i?n.mark[i]:n.mark[e])}function Ci(e,t,n){return $a(e,va(t),n)}function $a(e,t,n){t=H(t);let i;for(const r of t){const s=n[r];s&&s[e]!==void 0&&(i=s[e])}return i}function Ea(e,t){return H(e).reduce((n,i)=>(n.field.push(w(i,t)),n.order.push(i.sort??"ascending"),n),{field:[],order:[]})}function _a(e,t){const n=[...e];return t.forEach(i=>{for(const r of n)if(Ie(r,i))return;n.push(i)}),n}function ka(e,t){return Ie(e,t)||!t?e:e?[...H(e),...H(t)].join(", "):t}function Ca(e,t){const n=e.value,i=t.value;if(n==null||i===null)return{explicit:e.explicit,value:null};if(($t(n)||E(n))&&($t(i)||E(i)))return{explicit:e.explicit,value:ka(n,i)};if($t(n)||E(n))return{explicit:e.explicit,value:n};if($t(i)||E(i))return{explicit:e.explicit,value:i};if(!$t(n)&&!E(n)&&!$t(i)&&!E(i))return{explicit:e.explicit,value:_a(n,i)};throw new Error("It should never reach here")}function Gr(e){return`Invalid specification ${M(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`}const Fd='Autosize "fit" only works for single views and layered views.';function Na(e){const t=e=="width"?"Width":"Height";return`${t} "container" only works for single views and layered views.`}function Fa(e){const t=e=="width"?"Width":"Height",n=e=="width"?"x":"y";return`${t} "container" only works well with autosize "fit" or "fit-${n}".`}function Ta(e){return e?`Dropping "fit-${e}" because spec has discrete ${de(e)}.`:'Dropping "fit" because spec has discrete size.'}function Vr(e){return`Unknown field for ${e}. Cannot calculate view size.`}function Aa(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`}function Td(e,t){return`Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${t}").`}function Ad(e){return`The "nearest" transform is not supported for ${e} marks.`}function Oa(e){return`Selection not supported for ${e} yet.`}function Od(e){return`Cannot find a selection named "${e}".`}const Pd="Scale bindings are currently only supported for scales with unbinned, continuous domains.",zd="Legend bindings are only supported for selections over an individual field or encoding channel.";function Rd(e){return`Lookups can only be performed on selection parameters. "${e}" is a variable parameter.`}function Id(e){return`Cannot define and lookup the "${e}" selection in the same view. Try moving the lookup into a second, layered view?`}const Ld="The same selection must be used to override scale domains in a layered view.",Md='Interval selections should be initialized using "x", "y", "longitude", or "latitude" keys.';function Dd(e){return`Unknown repeated value "${e}".`}function Pa(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`}const jd="Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415).";function Ud(e){return`Unrecognized parse "${e}".`}function za(e,t,n){return`An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.`}const Wd="Attempt to add the same child twice.";function Bd(e){return`Ignoring an invalid transform: ${M(e)}.`}const Hd='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.';function Ra(e){return`Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.`}function qd(e){const{parentProjection:t,projection:n}=e;return`Layer's shared projection ${M(t)} is overridden by a child projection ${M(n)}.`}const Gd="Arc marks uses theta channel rather than angle, replacing angle with theta.";function Vd(e){return`${e}Offset dropped because ${e} is continuous`}function Xd(e){return`There is no ${e} encoding. Replacing ${e}Offset encoding as ${e}.`}function Yd(e,t,n){return`Channel ${e} is a ${t}. Converted to {value: ${M(n)}}.`}function Ia(e){return`Invalid field type "${e}".`}function Kd(e,t){return`Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.`}function Qd(e){return`Invalid aggregation operator "${e}".`}function La(e,t){const{fill:n,stroke:i}=t;return`Dropping color ${e} as the plot also has ${n&&i?"fill and stroke":n?"fill":"stroke"}.`}function Zd(e){return`Position range does not support relative band size for ${e}.`}function Xr(e,t){return`Dropping ${M(e)} from channel "${t}" since it does not contain any data field, datum, value, or signal.`}const Jd="Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.";function Ni(e,t,n){return`${e} dropped as it is incompatible with "${t}"${n?` when ${n}`:""}.`}function ep(e){return`${e} encoding has no scale, so specified scale is ignored.`}function tp(e){return`${e}-encoding is dropped as ${e} is not a valid encoding channel.`}function np(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`}function ip(e){return`${e} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`}function rp(e){return`Facet encoding dropped as ${e.join(" and ")} ${e.length>1?"are":"is"} also specified.`}function Yr(e,t){return`Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${t==="ordinal"?"order":"magnitude"}.`}function sp(e){return`The ${e} for range marks cannot be an expression`}function op(e,t){const n=e&&t?"x2 and y2":e?"x2":"y2";return`Line mark is for continuous lines and thus cannot be used with ${n}. We will use the rule mark (line segments) instead.`}function ap(e,t){return`Specified orient "${e}" overridden with "${t}".`}function cp(e){return`Cannot use the scale property "${e}" with non-color channel.`}function up(e){return`Cannot use the relative band size with ${e} scale.`}function lp(e){return`Using unaggregated domain with raw field has no effect (${M(e)}).`}function fp(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`}function dp(e){return`Unaggregated domain is currently unsupported for log scale (${M(e)}).`}function pp(e){return`Cannot apply size to non-oriented mark "${e}".`}function gp(e,t,n){return`Channel "${e}" does not work with "${t}" scale. We are using "${n}" scale instead.`}function mp(e,t){return`FieldDef does not work with "${e}" scale. We are using "${t}" scale instead.`}function Ma(e,t,n){return`${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`}function Da(e){return`The step for "${e}" is dropped because the ${e==="width"?"x":"y"} is continuous.`}function hp(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${M(n)} and ${M(i)}). Using ${M(n)}.`}function yp(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${M(n)} and ${M(i)}). Using the union of the two domains.`}function bp(e){return`Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.`}function xp(e){return`Dropping sort property ${M(e)} as unioned domains only support boolean or op "count", "min", and "max".`}const ja="Domains that should be unioned has conflicting sort properties. Sort will be set to true.",Sp="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.",wp="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.",vp="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.";function $p(e){return`Cannot stack "${e}" if there is already "${e}2".`}function Ep(e){return`Cannot stack non-linear scale (${e}).`}function _p(e){return`Stacking is applied even though the aggregate function is non-summative ("${e}").`}function Fi(e,t){return`Invalid ${e}: ${M(t)}.`}function kp(e){return`Dropping day from datetime ${M(e)} as day cannot be combined with other units.`}function Cp(e,t){return`${t?"extent ":""}${t&&e?"and ":""}${e?"center ":""}${t&&e?"are ":"is "}not needed when data are aggregated.`}function Np(e,t,n){return`${e} is not usually used with ${t} for ${n}.`}function Fp(e,t){return`Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.`}function Ua(e){return`1D error band does not support ${e}.`}function Wa(e){return`Channel ${e} is required for "binned" bin.`}function Tp(e){return`Channel ${e} should not be used with "binned" bin.`}function Ap(e){return`Domain for ${e} is required for threshold scale.`}var tw=function(e,t,n,i,r){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(e,n):r?r.value=n:t.set(e,n),n},nw=function(e,t,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(e):i?i.value:t.get(e)};const Ba=bf(xf);let mn=Ba;function Op(e){return mn=e,mn}function Pp(){return mn=Ba,mn}function x(...e){mn.warn(...e)}function zp(...e){mn.debug(...e)}function jt(e){if(e&&L(e)){for(const t of Qr)if(t in e)return!0}return!1}const Ha=["january","february","march","april","may","june","july","august","september","october","november","december"],Rp=Ha.map(e=>e.substr(0,3)),qa=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Ip=qa.map(e=>e.substr(0,3));function Lp(e){if(bi(e)&&(e=+e),G(e))return e>4&&x(Fi("quarter",e)),e-1;throw new Error(Fi("quarter",e))}function Mp(e){if(bi(e)&&(e=+e),G(e))return e-1;{const t=e.toLowerCase(),n=Ha.indexOf(t);if(n!==-1)return n;const i=t.substr(0,3),r=Rp.indexOf(i);if(r!==-1)return r;throw new Error(Fi("month",e))}}function Dp(e){if(bi(e)&&(e=+e),G(e))return e%7;{const t=e.toLowerCase(),n=qa.indexOf(t);if(n!==-1)return n;const i=t.substr(0,3),r=Ip.indexOf(i);if(r!==-1)return r;throw new Error(Fi("day",e))}}function Kr(e,t){const n=[];if(t&&e.day!==void 0&&(b(e).length>1&&(x(kp(e)),e=C(e),delete e.day)),e.year!==void 0?n.push(e.year):n.push(2012),e.month!==void 0){const i=t?Mp(e.month):e.month;n.push(i)}else if(e.quarter!==void 0){const i=t?Lp(e.quarter):e.quarter;n.push(G(i)?i*3:`${i}*3`)}else n.push(0);if(e.date!==void 0)n.push(e.date);else if(e.day!==void 0){const i=t?Dp(e.day):e.day;n.push(G(i)?i+1:`${i}+1`)}else n.push(1);for(const i of["hours","minutes","seconds","milliseconds"]){const r=e[i];n.push(typeof r=="undefined"?0:r)}return n}function Ut(e){const t=Kr(e,!0),n=t.join(", ");return e.utc?`utc(${n})`:`datetime(${n})`}function jp(e){const t=Kr(e,!1),n=t.join(", ");return e.utc?`utc(${n})`:`datetime(${n})`}function Up(e){const t=Kr(e,!0);return e.utc?+new Date(Date.UTC(...t)):+new Date(...t)}const Ga={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},Qr=b(Ga);function Wp(e){return!!Ga[e]}function Zr(e){return e.startsWith("utc")}function Bp(e){return e.substr(3)}const Hp={"year-month":"%b %Y ","year-month-date":"%b %d, %Y "};function Ti(e){return Qr.filter(t=>Va(e,t))}function qp(e){const t=Ti(e);return t[t.length-1]}function Va(e,t){const n=e.indexOf(t);return n<0||(n>0&&t==="seconds"&&e.charAt(n-1)==="i"||e.length>n+3&&t==="day"&&e.charAt(n+3)==="o")?!1:!(n>0&&t==="year"&&e.charAt(n-1)==="f")}function Gp(e,t,{end:n}={end:!1}){const i=Rr(t),r=Zr(e)?"utc":"";function s(c){return c==="quarter"?`(${r}quarter(${i})-1)`:`${r}${c}(${i})`}let o;const a={};for(const c of Qr)Va(e,c)&&(a[c]=s(c),o=c);return n&&(a[o]+="+1"),jp(a)}function Xa(e){if(!e)return;const t=Ti(e);return`timeUnitSpecifier(${M(t)}, ${M(Hp)})`}function Vp(e,t,n){if(!e)return;const i=Xa(e),r=n||Zr(e);return`${r?"utc":"time"}Format(${t}, ${i})`}function ne(e){if(!e)return;let t;return F(e)?t={unit:e}:L(e)&&(t={...e,...e.unit?{unit:e.unit}:{}}),Zr(t.unit)&&(t.utc=!0,t.unit=Bp(t.unit)),t}function Xp(e){const{utc:t,...n}=ne(e);return n.unit?(t?"utc":"")+b(n).map(i=>W(`${i==="unit"?"":`_${i}_`}${n[i]}`)).join(""):(t?"utc":"")+"timeunit"+b(n).map(i=>W(`_${i}_${n[i]}`)).join("")}function Yp(e){return e?.param}function Jr(e){return!!e?.field&&e.equal!==void 0}function es(e){return!!e?.field&&e.lt!==void 0}function ts(e){return!!e?.field&&e.lte!==void 0}function ns(e){return!!e?.field&&e.gt!==void 0}function is(e){return!!e?.field&&e.gte!==void 0}function rs(e){if(e?.field){if($(e.range)&&e.range.length===2)return!0;if(E(e.range))return!0}return!1}function ss(e){return!!e?.field&&($(e.oneOf)||$(e.in))}function Kp(e){return!!e?.field&&e.valid!==void 0}function Ya(e){return ss(e)||Jr(e)||rs(e)||es(e)||ns(e)||ts(e)||is(e)}function Be(e,t){return Gi(e,{timeUnit:t,wrapTime:!0})}function Qp(e,t){return e.map(n=>Be(n,t))}function Ka(e,t=!0){const{field:n}=e,i=ne(e.timeUnit)?.unit,r=i?`time(${Gp(i,n)})`:w(e,{expr:"datum"});if(Jr(e))return`${r}===${Be(e.equal,i)}`;if(es(e)){const s=e.lt;return`${r}<${Be(s,i)}`}else if(ns(e)){const s=e.gt;return`${r}>${Be(s,i)}`}else if(ts(e)){const s=e.lte;return`${r}<=${Be(s,i)}`}else if(is(e)){const s=e.gte;return`${r}>=${Be(s,i)}`}else{if(ss(e))return`indexof([${Qp(e.oneOf,i).join(",")}], ${r}) !== -1`;if(Kp(e))return os(r,e.valid);if(rs(e)){const{range:s}=e,o=E(s)?{signal:`${s.signal}[0]`}:s[0],a=E(s)?{signal:`${s.signal}[1]`}:s[1];if(o!==null&&a!==null&&t)return"inrange("+r+", ["+Be(o,i)+", "+Be(a,i)+"])";const c=[];return o!==null&&c.push(`${r} >= ${Be(o,i)}`),a!==null&&c.push(`${r} <= ${Be(a,i)}`),c.length>0?c.join(" && "):"true"}}throw new Error(`Invalid field predicate: ${M(e)}`)}function os(e,t=!0){return t?`isValid(${e}) && isFinite(+${e})`:`!isValid(${e}) || !isFinite(+${e})`}function Zp(e){return Ya(e)&&e.timeUnit?{...e,timeUnit:ne(e.timeUnit)?.unit}:e}const Gn={quantitative:"quantitative",ordinal:"ordinal",temporal:"temporal",nominal:"nominal",geojson:"geojson"};function Jp(e){return e==="quantitative"||e==="temporal"}function Qa(e){return e==="ordinal"||e==="nominal"}const Wt=Gn.quantitative,as=Gn.ordinal,hn=Gn.temporal,cs=Gn.nominal,yn=Gn.geojson;function eg(e){if(e){e=e.toLowerCase();switch(e){case"q":case Wt:return"quantitative";case"t":case hn:return"temporal";case"o":case as:return"ordinal";case"n":case cs:return"nominal";case yn:return"geojson"}}return}const ge={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"},us={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 tg(e,t){const n=us[e],i=us[t];return n===i||n==="ordinal-position"&&i==="time"||i==="ordinal-position"&&n==="time"}const ng={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 Za(e){return ng[e]}const Ja=new Set(["linear","log","pow","sqrt","symlog"]),ec=new Set([...Ja,"time","utc"]);function tc(e){return Ja.has(e)}const nc=new Set(["quantile","quantize","threshold"]),ig=new Set([...ec,...nc,"sequential","identity"]),rg=new Set(["ordinal","bin-ordinal","point","band"]);function Z(e){return rg.has(e)}function ye(e){return ig.has(e)}function Fe(e){return ec.has(e)}function bn(e){return nc.has(e)}const sg={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};function og(e){return!F(e)&&!!e.name}function ic(e){return e?.param}function ag(e){return e?.unionWith}function cg(e){return kr(e)&&"field"in e}const ug={type:1,domain:1,domainMax:1,domainMin:1,domainMid: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},{type:iw,domain:rw,range:sw,rangeMax:ow,rangeMin:aw,scheme:cw,...lg}=ug,fg=b(lg);function ls(e,t){switch(t){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!["point","band","identity"].includes(e);case"bins":return!["point","band","identity","ordinal"].includes(e);case"round":return Fe(e)||e==="band"||e==="point";case"padding":case"rangeMin":case"rangeMax":return Fe(e)||["point","band"].includes(e);case"paddingOuter":case"align":return["point","band"].includes(e);case"paddingInner":return e==="band";case"domainMax":case"domainMid":case"domainMin":case"clamp":return Fe(e);case"nice":return Fe(e)||e==="quantize"||e==="threshold";case"exponent":return e==="pow";case"base":return e==="log";case"constant":return e==="symlog";case"zero":return ye(e)&&!A(["log","time","utc","threshold","quantile"],e)}}function rc(e,t){switch(t){case"interpolate":case"scheme":case"domainMid":return pn(e)?void 0:cp(t);case"align":case"type":case"bins":case"domain":case"domainMax":case"domainMin":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}}function dg(e,t){return A([as,cs],t)?e===void 0||Z(e):t===hn?A([ge.TIME,ge.UTC,void 0],e):t===Wt?tc(e)||bn(e)||e===void 0:!0}function pg(e,t,n=!1){if(!rt(e))return!1;switch(e){case B:case K:case ht:case dn:case Se:case _e:return Fe(t)||t==="band"?!0:t==="point"?!n:!1;case nt:case xt:case it:case yt:case bt:case Rt:return Fe(t)||bn(t)||A(["band","point","ordinal"],t);case le:case De:case je:return t!=="band";case St:case fe:return t==="ordinal"||bn(t)}}const oe={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"},sc=oe.arc,Ai=oe.area,Oi=oe.bar,gg=oe.image,Pi=oe.line,zi=oe.point,mg=oe.rect,Ri=oe.rule,oc=oe.text,fs=oe.tick,hg=oe.trail,ds=oe.circle,ps=oe.square,ac=oe.geoshape;function _t(e){return["line","area","trail"].includes(e)}function cc(e){return["rect","bar","image","arc"].includes(e)}const yg=new Set(b(oe));function He(e){return e.type}const bg=["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit"],xg=["fill","fillOpacity"],Sg=[...bg,...xg],wg={color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBandSize:1,timeUnitBandPosition:1},uc=b(wg),vg={area:["line","point"],bar:["binSpacing","continuousBandSize","discreteBandSize"],rect:["binSpacing","continuousBandSize","discreteBandSize"],line:["point"],tick:["bandSize","thickness"]},$g={color:"#4c78a8",invalid:"filter",timeUnitBandSize:1},Eg={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},lc=b(Eg);function Bt(e){return e&&e.band!=null}const _g={horizontal:["cornerRadiusTopRight","cornerRadiusBottomRight"],vertical:["cornerRadiusTopLeft","cornerRadiusTopRight"]},fc=5,kg={binSpacing:1,continuousBandSize:fc,timeUnitBandPosition:.5},Cg={binSpacing:0,continuousBandSize:fc,timeUnitBandPosition:.5},Ng={thickness:1};function Fg(e){return He(e)?e.type:e}function gs(e){const{channel:t,channelDef:n,markDef:i,scale:r,config:s}=e,o=hs(e);return S(n)&&!ma(n.aggregate)&&r&&Fe(r.get("type"))?Tg({fieldDef:n,channel:t,markDef:i,ref:o,config:s}):o}function Tg({fieldDef:e,channel:t,markDef:n,ref:i,config:r}){if(_t(n.type))return i;const s=z("invalid",n,r);return s===null?[Ag(e,t),i]:i}function Ag(e,t){const n=ms(e,!0),i=Lt(t),r=i==="y"?{field:{group:"height"}}:{value:0};return{test:n,...r}}function ms(e,t=!0){return os(F(e)?e:w(e,{expr:"datum"}),!t)}function Og(e){const{datum:t}=e;return jt(t)?Ut(t):`${M(t)}`}function Ht(e,t,n,i){const r={};if(t&&(r.scale=t),Ge(e)){const{datum:s}=e;jt(s)?r.signal=Ut(s):E(s)?r.signal=s.signal:qn(s)?r.signal=s.expr:r.value=s}else r.field=w(e,n);if(i){const{offset:s,band:o}=i;s&&(r.offset=s),o&&(r.band=o)}return r}function Ii({scaleName:e,fieldOrDatumDef:t,fieldOrDatumDef2:n,offset:i,startSuffix:r,bandPosition:s=.5}){const o=0{switch(t.fieldTitle){case"plain":return e.field;case"functional":return qg(e);default:return Hg(e,t)}};let Fc=Nc;function Tc(e){Fc=e}function Gg(){Tc(Nc)}function wn(e,t,{allowDisabling:n,includeDefault:i=!0}){const r=ws(e)?.title;if(!S(e))return r??e.title;const s=e,o=i?vs(s,t):void 0;return n?V(r,s.title,o):r??s.title??o}function ws(e){return Sn(e)&&e.axis?e.axis:kc(e)&&e.legend?e.legend:xs(e)&&e.header?e.header:void 0}function vs(e,t){return Fc(e,t)}function Bi(e){if(Cc(e)){const{format:t,formatType:n}=e;return{format:t,formatType:n}}else{const t=ws(e)??{},{format:n,formatType:i}=t;return{format:n,formatType:i}}}function Vg(e,t){switch(t){case"latitude":case"longitude":return"quantitative";case"row":case"column":case"facet":case"shape":case"strokeDash":return"nominal";case"order":return"ordinal"}if(Ss(e)&&$(e.sort))return"ordinal";const{aggregate:n,bin:i,timeUnit:r}=e;if(r)return"temporal";if(i||n&&!vt(n)&&!st(n))return"quantitative";if(Gt(e)&&e.scale?.type)switch(us[e.scale.type]){case"numeric":case"discretizing":return"quantitative";case"time":return"temporal"}return"nominal"}function Ve(e){return S(e)?e:ji(e)?e.condition:void 0}function X(e){return N(e)?e:Kn(e)?e.condition:void 0}function Ac(e,t,n,i={}){if(F(e)||G(e)||Ln(e)){const r=F(e)?"string":G(e)?"number":"boolean";return x(Yd(t,r,e)),{value:e}}return N(e)?Hi(e,t,n,i):Kn(e)?{...e,condition:Hi(e.condition,t,n,i)}:e}function Hi(e,t,n,i){if(Cc(e)){const{format:r,formatType:s,...o}=e;if(qt(s)&&!n.customFormatTypes)return x(Ra(t)),Hi(o,t,n,i)}else{const r=Sn(e)?"axis":kc(e)?"legend":xs(e)?"header":null;if(r&&e[r]){const{format:s,formatType:o,...a}=e[r];if(qt(o)&&!n.customFormatTypes)return x(Ra(t)),Hi({...e,[r]:a},t,n,i)}}return S(e)?$s(e,t,i):Xg(e)}function Xg(e){let t=e.type;if(t)return e;const{datum:n}=e;return t=G(n)?"quantitative":F(n)?"nominal":jt(n)?"temporal":void 0,{...e,type:t}}function $s(e,t,{compositeMark:n=!1}={}){const{aggregate:i,timeUnit:r,bin:s,field:o}=e,a={...e};if(!n&&i&&!Hr(i)&&!vt(i)&&!st(i)&&(x(Qd(i)),delete a.aggregate),r&&(a.timeUnit=ne(r)),o&&(a.field=`${o}`),D(s)&&(a.bin=qi(s,t)),te(s)&&!Q(t)&&x(Tp(t)),ae(a)){const{type:c}=a,u=eg(c);c!==u&&(a.type=u),c!=="quantitative"&&(ma(i)&&(x(Kd(c,i)),a.type="quantitative"))}else if(!ca(t)){const c=Vg(a,t);a.type=c}if(ae(a)){const{compatible:c,warning:u}=Yg(a,t)||{};c===!1&&x(u)}if(Ss(a)&&F(a.sort)){const{sort:c}=a;if(bc(c))return{...a,sort:{encoding:c}};const u=c.substr(1);if(c.charAt(0)==="-"&&bc(u))return{...a,sort:{encoding:u,order:"descending"}}}if(xs(a)){const{header:c}=a;if(c){const{orient:u,...l}=c;if(u)return{...a,header:{...l,labelOrient:c.labelOrient||u,titleOrient:c.titleOrient||u}}}}return a}function qi(e,t){return Ln(e)?{maxbins:ya(t)}:e==="binned"?{binned:!0}:!e.maxbins&&!e.step?{...e,maxbins:ya(t)}:e}const vn={compatible:!0};function Yg(e,t){const n=e.type;if(n==="geojson"&&t!=="shape")return{compatible:!1,warning:`Channel ${t} should not be used with a geojson data.`};switch(t){case Ze:case Je:case xi:return Wi(e)?vn:{compatible:!1,warning:np(t)};case B:case K:case ht:case dn:case le:case De:case je:case Wn:case Hn:case Si:case It:case wi:case vi:case Rt:case Se:case _e:case $i:return vn;case Ce:case we:case ke:case Ne:return n!==Wt?{compatible:!1,warning:`Channel ${t} should be used with a quantitative field only, not ${e.type} field.`}:vn;case it:case yt:case bt:case xt:case nt:case tt:case et:case Ee:case Me:return n==="nominal"&&!e.sort?{compatible:!1,warning:`Channel ${t} should not be used with an unsorted discrete field.`}:vn;case fe:case St:return!Wi(e)&&!Wg(e)?{compatible:!1,warning:ip(t)}:vn;case Bn:return e.type==="nominal"&&!("sort"in e)?{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}:vn}}function $n(e){const{formatType:t}=Bi(e);return t==="time"||!t&&Kg(e)}function Kg(e){return e&&(e.type==="temporal"||S(e)&&!!e.timeUnit)}function Gi(e,{timeUnit:t,type:n,wrapTime:i,undefinedIfExprNotRequired:r}){const s=t&&ne(t)?.unit;let o=s||n==="temporal",a;return qn(e)?a=e.expr:E(e)?a=e.signal:jt(e)?(o=!0,a=Ut(e)):(F(e)||G(e))&&(o&&(a=`datetime(${M(e)})`,Wp(s)&&((G(e)&&e<1e4||F(e)&&isNaN(Date.parse(e)))&&(a=Ut({[s]:e}))))),a?i&&o?`time(${a})`:a:r?void 0:M(e)}function Oc(e,t){const{type:n}=e;return t.map(i=>{const r=Gi(i,{timeUnit:S(e)?e.timeUnit:void 0,type:n,undefinedIfExprNotRequired:!0});return r!==void 0?{signal:r}:i})}function Qn(e,t){return D(e.bin)?rt(t)&&["ordinal","nominal"].includes(e.type):(console.warn("Only call this method for binned field defs."),!1)}const Pc={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 Zn(e){return e?.condition}const zc=["domain","grid","labels","ticks","title"],Qg={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"},Rc={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},Zg={...Rc,style:1,labelExpr:1,encoding:1};function Ic(e){return!!Zg[e]}const Jg={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},Lc=b(Jg);function ct(e){return"mark"in e}class Vi{constructor(t,n){this.name=t,this.run=n}hasMatchingType(t){return ct(t)?Fg(t.mark)===this.name:!1}}function Vt(e,t){const n=e&&e[t];return n?$(n)?Pt(n,i=>!!i.field):S(n)||ji(n):!1}function Mc(e,t){const n=e&&e[t];return n?$(n)?Pt(n,i=>!!i.field):S(n)||Ge(n)||Kn(n):!1}function Es(e,t){if(Q(t)){const n=e[t];if((S(n)||Ge(n))&&Qa(n.type)){const i=ua(t);return Mc(e,i)}}return!1}function _s(e){return Pt(td,t=>{if(Vt(e,t)){const n=e[t];if($(n))return Pt(n,i=>!!i.aggregate);{const i=Ve(n);return i&&!!i.aggregate}}return!1})}function Dc(e,t){const n=[],i=[],r=[],s=[],o={};return ks(e,(a,c)=>{if(S(a)){const{field:u,aggregate:l,bin:f,timeUnit:d,...p}=a;if(l||d||f){const g=ws(a),m=g?.title;let h=w(a,{forAs:!0});const y={...m?[]:{title:wn(a,t,{allowDisabling:!0})},...p,field:h};if(l){let v;if(vt(l)?(v="argmax",h=w({op:"argmax",field:l.argmax},{forAs:!0}),y.field=`${h}.${u}`):st(l)?(v="argmin",h=w({op:"argmin",field:l.argmin},{forAs:!0}),y.field=`${h}.${u}`):l!=="boxplot"&&l!=="errorbar"&&l!=="errorband"&&(v=l),v){const _={op:v,as:h};u&&(_.field=u),s.push(_)}}else if(n.push(h),ae(a)&&D(f)){if(i.push({bin:f,field:u,as:h}),n.push(w(a,{binSuffix:"end"})),Qn(a,c)&&n.push(w(a,{binSuffix:"range"})),Q(c)){const v={field:`${h}_end`};o[`${c}2`]=v}y.bin="binned",ca(c)||(y.type=Wt)}else if(d){r.push({timeUnit:d,field:u,as:h});const v=ae(a)&&a.type!==hn&&"time";v&&(c===Wn||c===It?y.formatType=v:fd(c)?y.legend={formatType:v,...y.legend}:Q(c)&&(y.axis={formatType:v,...y.axis}))}o[c]=y}else n.push(u),o[c]=e[c]}else o[c]=e[c]}),{bins:i,timeUnits:r,aggregate:s,groupby:n,encoding:o}}function em(e,t,n){const i=pd(t,n);if(i){if(i==="binned"){const r=e[t===Ee?B:K];return!!(S(r)&&S(e[t])&&te(r.bin))}}else return!1;return!0}function tm(e,t,n,i){const r={};for(const s of b(e))aa(s)||x(tp(s));for(let s of ad){if(!e[s])continue;const o=e[s];if(gn(s)){const a=la(s),c=r[a];if(S(c)){if(Jp(c.type)&&S(o)){x(Vd(a));continue}}else s=a,x(Xd(a))}if(s==="angle"&&t==="arc"&&!e.theta&&(x(Gd),s=Se),!em(e,s,t)){x(Ni(s,t));continue}if(s===nt&&t==="line"){const a=Ve(e[s]);if(a?.aggregate){x(Jd);continue}}if(s===le&&(n?"fill"in e:"stroke"in e)){x(La("encoding",{fill:"fill"in e,stroke:"stroke"in e}));continue}if(s===Hn||s===Bn&&!$(o)&&!Ae(o)||s===It&&$(o))o&&(r[s]=H(o).reduce((a,c)=>(S(c)?a.push($s(c,s)):x(Xr(c,s)),a),[]));else{if(s===It&&o===null)r[s]=null;else if(!S(o)&&!Ge(o)&&!Ae(o)&&!Di(o)&&!E(o)){x(Xr(o,s));continue}r[s]=Ac(o,s,i)}}return r}function Xi(e,t){const n={};for(const i of b(e)){const r=Ac(e[i],i,t,{compositeMark:!0});n[i]=r}return n}function nm(e){const t=[];for(const n of b(e))if(Vt(e,n)){const i=e[n],r=H(i);for(const s of r)S(s)?t.push(s):ji(s)&&t.push(s.condition)}return t}function ks(e,t,n){if(!e)return;for(const i of b(e)){const r=e[i];if($(r))for(const s of r)t.call(n,s,i);else t.call(n,r,i)}}function im(e,t,n,i){return e?b(e).reduce((r,s)=>{const o=e[s];return $(o)?o.reduce((a,c)=>t.call(i,a,c,s),r):t.call(i,r,o,s)},n):n}function jc(e,t){return b(t).reduce((n,i)=>{switch(i){case B:case K:case wi:case $i:case vi:case Ee:case Me:case ht:case dn:case Se:case tt:case _e:case et:case ke:case Ce:case Ne:case we:case Wn:case fe:case Rt:case It:return n;case Bn:if(e==="line"||e==="trail")return n;case Hn:case Si:{const r=t[i];if($(r)||S(r))for(const s of H(r))s.aggregate||n.push(w(s,{}));return n}case nt:if(e==="trail")return n;case le:case De:case je:case it:case yt:case bt:case St:case xt:{const r=Ve(t[i]);return r&&!r.aggregate&&n.push(w(r,{})),n}}},[])}function rm(e){const{tooltip:t,...n}=e;if(!t)return{filteredEncoding:n};let i,r;if($(t)){for(const s of t)s.aggregate?(i||(i=[]),i.push(s)):(r||(r=[]),r.push(s));i&&(n.tooltip=i)}else t.aggregate?n.tooltip=t:r=t;return $(r)&&r.length===1&&(r=r[0]),{customTooltipWithoutAggregatedField:r,filteredEncoding:n}}function Cs(e,t,n,i=!0){if("tooltip"in n)return{tooltip:n.tooltip};const r=e.map(({fieldPrefix:o,titlePrefix:a})=>{const c=i?` of ${Ns(t)}`:"";return{field:o+t.field,type:t.type,title:E(a)?{signal:`${a}"${escape(c)}"`}:a+c}}),s=nm(n).map(jg);return{tooltip:[...r,...Le(s,O)]}}function Ns(e){const{title:t,field:n}=e;return V(t,n)}function Fs(e,t,n,i,r){const{scale:s,axis:o}=n;return({partName:a,mark:c,positionPrefix:u,endPositionPrefix:l=void 0,extraEncoding:f={}})=>{const d=Ns(n);return Uc(e,a,r,{mark:c,encoding:{[t]:{field:`${u}_${n.field}`,type:n.type,...d!==void 0?{title:d}:{},...s!==void 0?{scale:s}:{},...o!==void 0?{axis:o}:{}},...F(l)?{[`${t}2`]:{field:`${l}_${n.field}`}}:{},...i,...f}})}}function Uc(e,t,n,i){const{clip:r,color:s,opacity:o}=e,a=e.type;return e[t]||e[t]===void 0&&n[t]?[{...i,mark:{...n[t],...r?{clip:r}:{},...s?{color:s}:{},...o?{opacity:o}:{},...He(i.mark)?i.mark:{type:i.mark},style:`${a}-${String(t)}`,...Ln(e[t])?{}:e[t]}}]:[]}function Wc(e,t,n){const{encoding:i}=e,r=t==="vertical"?"y":"x",s=i[r],o=i[`${r}2`],a=i[`${r}Error`],c=i[`${r}Error2`];return{continuousAxisChannelDef:Yi(s,n),continuousAxisChannelDef2:Yi(o,n),continuousAxisChannelDefError:Yi(a,n),continuousAxisChannelDefError2:Yi(c,n),continuousAxis:r}}function Yi(e,t){if(e?.aggregate){const{aggregate:n,...i}=e;return n!==t&&x(Fp(n,t)),i}else return e}function Bc(e,t){const{mark:n,encoding:i}=e,{x:r,y:s}=i;if(He(n)&&n.orient)return n.orient;if(kt(r)){if(kt(s)){const o=S(r)&&r.aggregate,a=S(s)&&s.aggregate;if(!o&&a===t)return"vertical";if(!a&&o===t)return"horizontal";if(o===t&&a===t)throw new Error("Both x and y cannot have aggregate");return $n(s)&&!$n(r)?"horizontal":"vertical"}return"horizontal"}else{if(kt(s))return"vertical";throw new Error(`Need a valid continuous axis for ${t}s`)}}const Ki="boxplot",sm=["box","median","outliers","rule","ticks"],om=new Vi(Ki,qc);function Hc(e){return G(e)?"tukey":e}function qc(e,{config:t}){e={...e,encoding:Xi(e.encoding,t)};const{mark:n,encoding:i,params:r,projection:s,...o}=e,a=He(n)?n:{type:n};r&&x(Oa("boxplot"));const c=a.extent??t.boxplot.extent,u=z("size",a,t),l=a.invalid,f=Hc(c),{bins:d,timeUnits:p,transform:g,continuousAxisChannelDef:m,continuousAxis:h,groupby:y,aggregate:v,encodingWithoutContinuousAxis:_,ticksOrient:k,boxOrient:P,customTooltipWithoutAggregatedField:Y}=am(e,c,t),{color:se,size:tn,...pt}=_,gt=hf=>Fs(a,h,m,hf,t.boxplot),nn=gt(pt),Er=gt(_),di=gt({...pt,...tn?{size:tn}:{}}),rn=Cs([{fieldPrefix:f==="min-max"?"upper_whisker_":"max_",titlePrefix:"Max"},{fieldPrefix:"upper_box_",titlePrefix:"Q3"},{fieldPrefix:"mid_box_",titlePrefix:"Median"},{fieldPrefix:"lower_box_",titlePrefix:"Q1"},{fieldPrefix:f==="min-max"?"lower_whisker_":"min_",titlePrefix:"Min"}],m,_),In={type:"tick",color:"black",opacity:1,orient:k,invalid:l,aria:!1},sn=f==="min-max"?rn:Cs([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],m,_),Po=[...nn({partName:"rule",mark:{type:"rule",invalid:l,aria:!1},positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",extraEncoding:sn}),...nn({partName:"rule",mark:{type:"rule",invalid:l,aria:!1},positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",extraEncoding:sn}),...nn({partName:"ticks",mark:In,positionPrefix:"lower_whisker",extraEncoding:sn}),...nn({partName:"ticks",mark:In,positionPrefix:"upper_whisker",extraEncoding:sn})],zo=[...f!=="tukey"?Po:[],...Er({partName:"box",mark:{type:"bar",...u?{size:u}:{},orient:P,invalid:l,ariaRoleDescription:"box"},positionPrefix:"lower_box",endPositionPrefix:"upper_box",extraEncoding:rn}),...di({partName:"median",mark:{type:"tick",invalid:l,...L(t.boxplot.median)&&t.boxplot.median.color?{color:t.boxplot.median.color}:{},...u?{size:u}:{},orient:k,aria:!1},positionPrefix:"mid_box",extraEncoding:rn})];if(f==="min-max")return{...o,transform:(o.transform??[]).concat(g),layer:zo};const Ro=`datum["lower_box_${m.field}"]`,Io=`datum["upper_box_${m.field}"]`,Lo=`(${Io} - ${Ro})`,Mo=`${Ro} - ${c} * ${Lo}`,Do=`${Io} + ${c} * ${Lo}`,pi=`datum["${m.field}"]`,pf={joinaggregate:Gc(m.field),groupby:y},jo={transform:[{filter:`(${Mo} <= ${pi}) && (${pi} <= ${Do})`},{aggregate:[{op:"min",field:m.field,as:`lower_whisker_${m.field}`},{op:"max",field:m.field,as:`upper_whisker_${m.field}`},{op:"min",field:`lower_box_${m.field}`,as:`lower_box_${m.field}`},{op:"max",field:`upper_box_${m.field}`,as:`upper_box_${m.field}`},...v],groupby:y}],layer:Po},{tooltip:bS,...gf}=pt,{scale:Uo,axis:mf}=m,Wo=Ns(m),Bo=ue(mf,["title"]),Ho=Uc(a,"outliers",t.boxplot,{transform:[{filter:`(${pi} < ${Mo}) || (${pi} > ${Do})`}],mark:"point",encoding:{[h]:{field:m.field,type:m.type,...Wo!==void 0?{title:Wo}:{},...Uo!==void 0?{scale:Uo}:{},...R(Bo)?{}:{axis:Bo}},...gf,...se?{color:se}:{},...Y?{tooltip:Y}:{}}})[0];let gi;const qo=[...d,...p,pf];return Ho?gi={transform:qo,layer:[Ho,jo]}:(gi=jo,gi.transform.unshift(...qo)),{...o,layer:[gi,{transform:g,layer:zo}]}}function Gc(e){return[{op:"q1",field:e,as:`lower_box_${e}`},{op:"q3",field:e,as:`upper_box_${e}`}]}function am(e,t,n){const i=Bc(e,Ki),{continuousAxisChannelDef:r,continuousAxis:s}=Wc(e,i,Ki),o=r.field,a=Hc(t),c=[...Gc(o),{op:"median",field:o,as:`mid_box_${o}`},{op:"min",field:o,as:(a==="min-max"?"lower_whisker_":"min_")+o},{op:"max",field:o,as:(a==="min-max"?"upper_whisker_":"max_")+o}],u=a==="min-max"||a==="tukey"?[]:[{calculate:`datum["upper_box_${o}"] - datum["lower_box_${o}"]`,as:`iqr_${o}`},{calculate:`min(datum["upper_box_${o}"] + datum["iqr_${o}"] * ${t}, datum["max_${o}"])`,as:`upper_whisker_${o}`},{calculate:`max(datum["lower_box_${o}"] - datum["iqr_${o}"] * ${t}, datum["min_${o}"])`,as:`lower_whisker_${o}`}],{[s]:l,...f}=e.encoding,{customTooltipWithoutAggregatedField:d,filteredEncoding:p}=rm(f),{bins:g,timeUnits:m,aggregate:h,groupby:y,encoding:v}=Dc(p,n),_=i==="vertical"?"horizontal":"vertical",k=i,P=[...g,...m,{aggregate:[...h,...c],groupby:y},...u];return{bins:g,timeUnits:m,transform:P,groupby:y,aggregate:h,continuousAxisChannelDef:r,continuousAxis:s,encodingWithoutContinuousAxis:v,ticksOrient:_,boxOrient:k,customTooltipWithoutAggregatedField:d}}const Ts="errorbar",cm=["ticks","rule"],um=new Vi(Ts,Vc);function Vc(e,{config:t}){e={...e,encoding:Xi(e.encoding,t)};const{transform:n,continuousAxisChannelDef:i,continuousAxis:r,encodingWithoutContinuousAxis:s,ticksOrient:o,markDef:a,outerSpec:c,tooltipEncoding:u}=Xc(e,Ts,t);delete s.size;const l=Fs(a,r,i,s,t.errorbar),f=a.thickness,d=a.size,p={type:"tick",orient:o,aria:!1,...f!==void 0?{thickness:f}:{},...d!==void 0?{size:d}:{}},g=[...l({partName:"ticks",mark:p,positionPrefix:"lower",extraEncoding:u}),...l({partName:"ticks",mark:p,positionPrefix:"upper",extraEncoding:u}),...l({partName:"rule",mark:{type:"rule",ariaRoleDescription:"errorbar",...f!==void 0?{size:f}:{}},positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:u})];return{...c,transform:n,...g.length>1?{layer:g}:{...g[0]}}}function lm(e,t){const{encoding:n}=e;if(fm(n))return{orient:Bc(e,t),inputType:"raw"};const i=dm(n),r=pm(n),s=n.x,o=n.y;if(i){if(r)throw new Error(`${t} cannot be both type aggregated-upper-lower and aggregated-error`);const a=n.x2,c=n.y2;if(N(a)&&N(c))throw new Error(`${t} cannot have both x2 and y2`);if(N(a)){if(kt(s))return{orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error(`Both x and x2 have to be quantitative in ${t}`)}else if(N(c)){if(kt(o))return{orient:"vertical",inputType:"aggregated-upper-lower"};throw new Error(`Both y and y2 have to be quantitative in ${t}`)}throw new Error("No ranged axis")}else{const a=n.xError,c=n.xError2,u=n.yError,l=n.yError2;if(N(c)&&!N(a))throw new Error(`${t} cannot have xError2 without xError`);if(N(l)&&!N(u))throw new Error(`${t} cannot have yError2 without yError`);if(N(a)&&N(u))throw new Error(`${t} cannot have both xError and yError with both are quantiative`);if(N(a)){if(kt(s))return{orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative")}else if(N(u)){if(kt(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 fm(e){return(N(e.x)||N(e.y))&&!N(e.x2)&&!N(e.y2)&&!N(e.xError)&&!N(e.xError2)&&!N(e.yError)&&!N(e.yError2)}function dm(e){return N(e.x2)||N(e.y2)}function pm(e){return N(e.xError)||N(e.xError2)||N(e.yError)||N(e.yError2)}function Xc(e,t,n){const{mark:i,encoding:r,params:s,projection:o,...a}=e,c=He(i)?i:{type:i};s&&x(Oa(t));const{orient:u,inputType:l}=lm(e,t),{continuousAxisChannelDef:f,continuousAxisChannelDef2:d,continuousAxisChannelDefError:p,continuousAxisChannelDefError2:g,continuousAxis:m}=Wc(e,u,t),{errorBarSpecificAggregate:h,postAggregateCalculates:y,tooltipSummary:v,tooltipTitleWithFieldName:_}=gm(c,f,d,p,g,l,t,n),{[m]:k,[m==="x"?"x2":"y2"]:P,[m==="x"?"xError":"yError"]:Y,[m==="x"?"xError2":"yError2"]:se,...tn}=r,{bins:pt,timeUnits:gt,aggregate:nn,groupby:Er,encoding:di}=Dc(tn,n),rn=[...nn,...h],In=l!=="raw"?[]:Er,sn=Cs(v,f,di,_);return{transform:[...a.transform??[],...pt,...gt,...rn.length===0?[]:[{aggregate:rn,groupby:In}],...y],groupby:In,continuousAxisChannelDef:f,continuousAxis:m,encodingWithoutContinuousAxis:di,ticksOrient:u==="vertical"?"horizontal":"vertical",markDef:c,outerSpec:a,tooltipEncoding:sn}}function gm(e,t,n,i,r,s,o,a){let c=[],u=[];const l=t.field;let f,d=!1;if(s==="raw"){const p=e.center?e.center:e.extent?e.extent==="iqr"?"median":"mean":a.errorbar.center,g=e.extent?e.extent:p==="mean"?"stderr":"iqr";if(p==="median"!==(g==="iqr")&&x(Np(p,g,o)),g==="stderr"||g==="stdev")c=[{op:g,field:l,as:`extent_${l}`},{op:p,field:l,as:`center_${l}`}],u=[{calculate:`datum["center_${l}"] + datum["extent_${l}"]`,as:`upper_${l}`},{calculate:`datum["center_${l}"] - datum["extent_${l}"]`,as:`lower_${l}`}],f=[{fieldPrefix:"center_",titlePrefix:jn(p)},{fieldPrefix:"upper_",titlePrefix:Yc(p,g,"+")},{fieldPrefix:"lower_",titlePrefix:Yc(p,g,"-")}],d=!0;else{let m,h,y;g==="ci"?(m="mean",h="ci0",y="ci1"):(m="median",h="q1",y="q3"),c=[{op:h,field:l,as:`lower_${l}`},{op:y,field:l,as:`upper_${l}`},{op:m,field:l,as:`center_${l}`}],f=[{fieldPrefix:"upper_",titlePrefix:wn({field:l,aggregate:y,type:"quantitative"},a,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:wn({field:l,aggregate:h,type:"quantitative"},a,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:wn({field:l,aggregate:m,type:"quantitative"},a,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&x(Cp(e.center,e.extent)),s==="aggregated-upper-lower"?(f=[],u=[{calculate:`datum["${n.field}"]`,as:`upper_${l}`},{calculate:`datum["${l}"]`,as:`lower_${l}`}]):s==="aggregated-error"&&(f=[{fieldPrefix:"",titlePrefix:l}],u=[{calculate:`datum["${l}"] + datum["${i.field}"]`,as:`upper_${l}`}],r?u.push({calculate:`datum["${l}"] + datum["${r.field}"]`,as:`lower_${l}`}):u.push({calculate:`datum["${l}"] - datum["${i.field}"]`,as:`lower_${l}`}));for(const p of u)f.push({fieldPrefix:p.as.substring(0,6),titlePrefix:zt(zt(p.calculate,'datum["',""),'"]',"")})}return{postAggregateCalculates:u,errorBarSpecificAggregate:c,tooltipSummary:f,tooltipTitleWithFieldName:d}}function Yc(e,t,n){return`${jn(e)} ${n} ${t}`}const As="errorband",mm=["band","borders"],hm=new Vi(As,Kc);function Kc(e,{config:t}){e={...e,encoding:Xi(e.encoding,t)};const{transform:n,continuousAxisChannelDef:i,continuousAxis:r,encodingWithoutContinuousAxis:s,markDef:o,outerSpec:a,tooltipEncoding:c}=Xc(e,As,t),u=o,l=Fs(u,r,i,s,t.errorband),f=e.encoding.x!==void 0&&e.encoding.y!==void 0;let d={type:f?"area":"rect"},p={type:f?"line":"rule"};const g={...u.interpolate?{interpolate:u.interpolate}:{},...u.tension&&u.interpolate?{tension:u.tension}:{}};return f?(d={...d,...g,ariaRoleDescription:"errorband"},p={...p,...g,aria:!1}):u.interpolate?x(Ua("interpolate")):u.tension&&x(Ua("tension")),{...a,transform:n,layer:[...l({partName:"band",mark:d,positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:c}),...l({partName:"borders",mark:p,positionPrefix:"lower",extraEncoding:c}),...l({partName:"borders",mark:p,positionPrefix:"upper",extraEncoding:c})]}}const Qc={};function Os(e,t,n){const i=new Vi(e,t);Qc[e]={normalizer:i,parts:n}}function ym(){return b(Qc)}Os(Ki,qc,sm),Os(Ts,Vc,cm),Os(As,Kc,mm);const bm=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength","unselectedOpacity"],Zc={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"},Jc={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"},xm=b(Zc),Sm=b(Jc),wm={header:1,headerRow:1,headerColumn:1,headerFacet:1},eu=b(wm),tu=["size","shape","fill","stroke","strokeDash","strokeWidth","opacity"],vm={gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},$m={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},Oe="_vgsid_",Em={point:{on:"click",fields:[Oe],toggle:"event.shiftKey",resolve:"global",clear:"dblclick"},interval:{on:"[mousedown, window:mouseup] > window:mousemove!",encodings:["x","y"],translate:"[mousedown, window:mouseup] > window:mousemove!",zoom:"wheel!",mark:{fill:"#333",fillOpacity:.125,stroke:"white"},resolve:"global",clear:"dblclick"}};function Ps(e){return e==="legend"||!!e?.legend}function zs(e){return Ps(e)&&L(e)}function Rs(e){return!!e?.select}function nu(e){const t=[];for(const n of e||[]){if(Rs(n))continue;const{expr:i,bind:r,...s}=n;if(r&&i){const o={...s,bind:r,init:i};t.push(o)}else{const o={...s,...i?{update:i}:{},...r?{bind:r}:{}};t.push(o)}}return t}function _m(e){return Qi(e)||Ls(e)||Is(e)}function Is(e){return"concat"in e}function Qi(e){return"vconcat"in e}function Ls(e){return"hconcat"in e}function iu({step:e,offsetIsDiscrete:t}){return t?e.for??"offset":"position"}function Xe(e){return L(e)&&e.step!==void 0}function ru(e){return e.view||e.width||e.height}const su=20,km={align:1,bounds:1,center:1,columns:1,spacing:1},Cm=b(km);function Nm(e,t,n){const i=n[t],r={},{spacing:s,columns:o}=i;s!==void 0&&(r.spacing=s),o!==void 0&&((Mi(e)&&!Yn(e.facet)||Is(e))&&(r.columns=o)),Qi(e)&&(r.columns=1);for(const a of Cm)if(e[a]!==void 0)if(a==="spacing"){const c=e[a];r[a]=G(c)?c:{row:c.row??s,column:c.column??s}}else r[a]=e[a];return r}function Ms(e,t){return e[t]??e[t==="width"?"continuousWidth":"continuousHeight"]}function Zi(e,t){const n=Ji(e,t);return Xe(n)?n.step:ou}function Ji(e,t){const n=e[t]??e[t==="width"?"discreteWidth":"discreteHeight"];return V(n,{step:e.step})}const ou=20,Fm={continuousWidth:200,continuousHeight:200,step:ou},Tm={background:"white",padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",view:Fm,mark:$g,arc:{},area:{},bar:kg,circle:{},geoshape:{},image:{},line:{},point:{},rect:Cg,rule:{color:"black"},square:{},text:{color:"black"},tick:Ng,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:sg,projection:{},legend:vm,header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:Em,style:{},title:{},facet:{spacing:su},concat:{spacing:su},normalizedNumberFormat:".0%"},ut=["#4c78a8","#f58518","#e45756","#72b7b2","#54a24b","#eeca3b","#b279a2","#ff9da6","#9d755d","#bab0ac"],au={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},cu={blue:ut[0],orange:ut[1],red:ut[2],teal:ut[3],green:ut[4],yellow:ut[5],purple:ut[6],pink:ut[7],brown:ut[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 Am(e={}){return{signals:[{name:"color",value:L(e)?{...cu,...e}:cu}],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"}]}}}function Om(e){return{signals:[{name:"fontSize",value:L(e)?{...au,...e}:au}],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"}}}}}function Pm(e){return{text:{font:e},style:{"guide-label":{font:e},"guide-title":{font:e},"group-title":{font:e},"group-subtitle":{font:e}}}}function uu(e){const t=b(e||{}),n={};for(const i of t){const r=e[i];n[i]=Zn(r)?xa(r):he(r)}return n}function zm(e){const t=b(e),n={};for(const i of t)n[i]=uu(e[i]);return n}const Rm=[...lc,...Lc,...eu,"background","padding","legend","lineBreak","scale","style","title","view"];function lu(e={}){const{color:t,font:n,fontSize:i,selection:r,...s}=e,o=Go({},C(Tm),n?Pm(n):{},t?Am(t):{},i?Om(i):{},s||{});r&&Ef(o,"selection",r,!0);const a=ue(o,Rm);for(const c of["background","lineBreak","padding"])o[c]&&(a[c]=he(o[c]));for(const c of lc)o[c]&&(a[c]=pe(o[c]));for(const c of Lc)o[c]&&(a[c]=uu(o[c]));for(const c of eu)o[c]&&(a[c]=pe(o[c]));return o.legend&&(a.legend=pe(o.legend)),o.scale&&(a.scale=pe(o.scale)),o.style&&(a.style=zm(o.style)),o.title&&(a.title=pe(o.title)),o.view&&(a.view=pe(o.view)),a}const Im=new Set(["view",...yg]),Lm=["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"],Mm={view:["continuousWidth","continuousHeight","discreteWidth","discreteHeight","step"],...vg};function Dm(e){e=C(e);for(const t of Lm)delete e[t];if(e.axis)for(const t in e.axis)Zn(e.axis[t])&&delete e.axis[t];if(e.legend)for(const t of bm)delete e.legend[t];if(e.mark){for(const t of uc)delete e.mark[t];e.mark.tooltip&&L(e.mark.tooltip)&&delete e.mark.tooltip}e.params&&(e.signals=(e.signals||[]).concat(nu(e.params)),delete e.params);for(const t of Im){for(const i of uc)delete e[t][i];const n=Mm[t];if(n)for(const i of n)delete e[t][i];Um(e,t)}for(const t of ym())delete e[t];jm(e);for(const t in e)L(e[t])&&R(e[t])&&delete e[t];return R(e)?void 0:e}function jm(e){const{titleMarkConfig:t,subtitleMarkConfig:n,subtitle:i}=ba(e.title);R(t)||(e.style["group-title"]={...e.style["group-title"],...t}),R(n)||(e.style["group-subtitle"]={...e.style["group-subtitle"],...n}),R(i)?delete e.title:e.title=i}function Um(e,t,n,i){const r=i?e[t][i]:e[t];t==="view"&&(n="cell");const s={...r,...e.style[n??t]};R(s)||(e.style[n??t]=s),i||delete e[t]}function er(e){return"layer"in e}function Wm(e){return"repeat"in e}function Bm(e){return!$(e.repeat)&&e.repeat.layer}class Ds{map(t,n){return Mi(t)?this.mapFacet(t,n):Wm(t)?this.mapRepeat(t,n):Ls(t)?this.mapHConcat(t,n):Qi(t)?this.mapVConcat(t,n):Is(t)?this.mapConcat(t,n):this.mapLayerOrUnit(t,n)}mapLayerOrUnit(t,n){if(er(t))return this.mapLayer(t,n);if(ct(t))return this.mapUnit(t,n);throw new Error(Gr(t))}mapLayer(t,n){return{...t,layer:t.layer.map(i=>this.mapLayerOrUnit(i,n))}}mapHConcat(t,n){return{...t,hconcat:t.hconcat.map(i=>this.map(i,n))}}mapVConcat(t,n){return{...t,vconcat:t.vconcat.map(i=>this.map(i,n))}}mapConcat(t,n){const{concat:i,...r}=t;return{...r,concat:i.map(s=>this.map(s,n))}}mapFacet(t,n){return{...t,spec:this.map(t.spec,n)}}mapRepeat(t,n){return{...t,spec:this.map(t.spec,n)}}}const Hm={zero:1,center:1,normalize:1};function qm(e){return e in Hm}const Gm=new Set([sc,Oi,Ai,Ri,zi,ds,ps,Pi,oc,fs]),Vm=new Set([Oi,Ai,sc]);function En(e){return S(e)&&xn(e)==="quantitative"&&!e.bin}function fu(e,t,{orient:n,type:i}){const r=t==="x"?"y":"radius",s=t==="x",o=e[t],a=e[r];if(S(o)&&S(a))if(En(o)&&En(a)){if(o.stack)return t;if(a.stack)return r;const c=S(o)&&!!o.aggregate,u=S(a)&&!!a.aggregate;if(c!==u)return c?t:r;if(s&&i==="bar"){if(n==="vertical")return r;if(n==="horizontal")return t}}else{if(En(o))return t;if(En(a))return r}else{if(En(o))return t;if(En(a))return r}return}function Xm(e){switch(e){case"x":return"y";case"y":return"x";case"theta":return"radius";case"radius":return"theta"}}function du(e,t){const n=He(e)?e:{type:e},i=n.type;if(!Gm.has(i))return null;const r=fu(t,"x",n)||fu(t,"theta",n);if(!r)return null;const s=t[r],o=S(s)?w(s,{}):void 0,a=Xm(r),c=[],u=new Set;if(t[a]){const d=t[a],p=S(d)?w(d,{}):void 0;p&&p!==o&&(c.push(a),u.add(p));const g=a==="x"?"xOffset":"yOffset",m=t[g],h=S(m)?w(m,{}):void 0;h&&h!==o&&(c.push(g),u.add(h))}const l=cd.reduce((d,p)=>{if(p!=="tooltip"&&Vt(t,p)){const g=t[p];for(const m of H(g)){const h=Ve(m);if(h.aggregate)continue;const y=w(h,{});(!y||!u.has(y))&&d.push({channel:p,fieldDef:h})}}return d},[]);let f;return s.stack!==void 0?Ln(s.stack)?f=s.stack?"zero":null:f=s.stack:Vm.has(i)&&(f="zero"),!f||!qm(f)||_s(t)&&l.length===0?null:s?.scale?.type&&s?.scale?.type!==ge.LINEAR?(s?.stack&&x(Ep(s.scale.type)),null):N(t[Ue(r)])?(s.stack!==void 0&&x($p(r)),null):(S(s)&&s.aggregate&&!Sd.has(s.aggregate)&&x(_p(s.aggregate)),{groupbyChannels:c,groupbyFields:u,fieldChannel:r,impute:s.impute===null?!1:_t(i),stackBy:l,offset:f})}function Ym(e){const{point:t,line:n,...i}=e;return b(i).length>1?i:i.type}function Km(e){for(const t of["line","area","rule","trail"])e[t]&&(e={...e,[t]:ue(e[t],["point","line"])});return e}function js(e,t={},n){return e.point==="transparent"?{opacity:0}:e.point?L(e.point)?e.point:{}:e.point!==void 0?null:t.point||n.shape?L(t.point)?t.point:{}:void 0}function pu(e,t={}){return e.line?e.line===!0?{}:e.line:e.line!==void 0?null:t.line?t.line===!0?{}:t.line:void 0}class Qm{constructor(){this.name="path-overlay"}hasMatchingType(t,n){if(ct(t)){const{mark:i,encoding:r}=t,s=He(i)?i:{type:i};switch(s.type){case"line":case"rule":case"trail":return!!js(s,n[s.type],r);case"area":return!!js(s,n[s.type],r)||!!pu(s,n[s.type])}}return!1}run(t,n,i){const{config:r}=n,{params:s,projection:o,mark:a,name:c,encoding:u,...l}=t,f=Xi(u,r),d=He(a)?a:{type:a},p=js(d,r[d.type],f),g=d.type==="area"&&pu(d,r[d.type]),m=[{name:c,...s?{params:s}:{},mark:Ym({...d.type==="area"&&d.opacity===void 0&&d.fillOpacity===void 0?{opacity:.7}:{},...d}),encoding:ue(f,["shape"])}],h=du(d,f);let y=f;if(h){const{fieldChannel:v,offset:_}=h;y={...f,[v]:{...f[v],..._?{stack:_}:{}}}}return y=ue(y,["y2","x2"]),g&&m.push({...o?{projection:o}:{},mark:{type:"line",...ln(d,["clip","interpolate","tension","tooltip"]),...g},encoding:y}),p&&m.push({...o?{projection:o}:{},mark:{type:"point",opacity:1,filled:!0,...ln(d,["clip","tooltip"]),...p},encoding:y}),i({...l,layer:m},{...n,config:Km(r)})}}function Zm(e,t){return t?Yn(e)?yu(e,t):gu(e,t):e}function Us(e,t){return t?yu(e,t):e}function Ws(e,t,n){const i=t[e];if(Mg(i)){if(i.repeat in n)return{...t,[e]:n[i.repeat]};x(Dd(i.repeat));return}return t}function gu(e,t){if(e=Ws("field",e,t),e===void 0)return;if(e===null)return null;if(Ss(e)&&qe(e.sort)){const n=Ws("field",e.sort,t);e={...e,...n?{sort:n}:{}}}return e}function mu(e,t){if(S(e))return gu(e,t);{const n=Ws("datum",e,t);return n!==e&&!n.type&&(n.type="nominal"),n}}function hu(e,t){if(N(e)){const n=mu(e,t);if(n)return n;if(Di(e))return{condition:e.condition}}else{if(Kn(e)){const n=mu(e.condition,t);if(n)return{...e,condition:n};{const{condition:i,...r}=e;return r}}return e}return}function yu(e,t){const n={};for(const i in e)if(on(e,i)){const r=e[i];if($(r))n[i]=r.map(s=>hu(s,t)).filter(s=>s);else{const s=hu(r,t);s!==void 0&&(n[i]=s)}}return n}class Jm{constructor(){this.name="RuleForRangedLine"}hasMatchingType(t){if(ct(t)){const{encoding:n,mark:i}=t;if(i==="line"||He(i)&&i.type==="line")for(const r of sd){const s=Lt(r),o=n[s];if(n[r]&&(S(o)&&!te(o.bin)||Ge(o)))return!0}}return!1}run(t,n,i){const{encoding:r,mark:s}=t;return x(op(!!r.x2,!!r.y2)),i({...t,mark:L(s)?{...s,type:"rule"}:"rule"},n)}}class eh extends Ds{constructor(){super(...arguments);this.nonFacetUnitNormalizers=[om,um,hm,new Qm,new Jm]}map(t,n){if(ct(t)){const i=Vt(t.encoding,Ze),r=Vt(t.encoding,Je),s=Vt(t.encoding,xi);if(i||r||s)return this.mapFacetedUnit(t,n)}return super.map(t,n)}mapUnit(t,n){const{parentEncoding:i,parentProjection:r}=n,s=Us(t.encoding,n.repeater),o={...t,...t.name?{name:[n.repeaterPrefix,t.name].filter(c=>c).join("_")}:{},...s?{encoding:s}:{}};if(i||r)return this.mapUnitWithParentEncodingOrProjection(o,n);const a=this.mapLayerOrUnit.bind(this);for(const c of this.nonFacetUnitNormalizers)if(c.hasMatchingType(o,n.config))return c.run(o,n,a);return o}mapRepeat(t,n){return Bm(t)?this.mapLayerRepeat(t,n):this.mapNonLayerRepeat(t,n)}mapLayerRepeat(t,n){const{repeat:i,spec:r,...s}=t,{row:o,column:a,layer:c}=i,{repeater:u={},repeaterPrefix:l=""}=n;return o||a?this.mapRepeat({...t,repeat:{...o?{row:o}:{},...a?{column:a}:{}},spec:{repeat:{layer:c},spec:r}},n):{...s,layer:c.map(f=>{const d={...u,layer:f},p=`${(r.name?`${r.name}_`:"")+l}child__layer_${W(f)}`,g=this.mapLayerOrUnit(r,{...n,repeater:d,repeaterPrefix:p});return g.name=p,g})}}mapNonLayerRepeat(t,n){const{repeat:i,spec:r,data:s,...o}=t;!$(i)&&t.columns&&(t=ue(t,["columns"]),x(Pa("repeat")));const a=[],{repeater:c={},repeaterPrefix:u=""}=n,l=!$(i)&&i.row||[c?c.row:null],f=!$(i)&&i.column||[c?c.column:null],d=$(i)&&i||[c?c.repeat:null];for(const g of d)for(const m of l)for(const h of f){const y={repeat:g,row:m,column:h,layer:c.layer},v=(r.name?`${r.name}_`:"")+u+"child__"+($(i)?`${W(g)}`:(i.row?`row_${W(m)}`:"")+(i.column?`column_${W(h)}`:"")),_=this.map(r,{...n,repeater:y,repeaterPrefix:v});_.name=v,a.push(ue(_,["data"]))}const p=$(i)?t.columns:i.column?i.column.length:1;return{data:r.data??s,align:"all",...o,columns:p,concat:a}}mapFacet(t,n){const{facet:i}=t;return Yn(i)&&t.columns&&(t=ue(t,["columns"]),x(Pa("facet"))),super.mapFacet(t,n)}mapUnitWithParentEncodingOrProjection(t,n){const{encoding:i,projection:r}=t,{parentEncoding:s,parentProjection:o,config:a}=n,c=xu({parentProjection:o,projection:r}),u=bu({parentEncoding:s,encoding:Us(i,n.repeater)});return this.mapUnit({...t,...c?{projection:c}:{},...u?{encoding:u}:{}},{config:a})}mapFacetedUnit(t,n){const{row:i,column:r,facet:s,...o}=t.encoding,{mark:a,width:c,projection:u,height:l,view:f,params:d,encoding:p,...g}=t,{facetMapping:m,layout:h}=this.getFacetMappingAndLayout({row:i,column:r,facet:s},n),y=Us(o,n.repeater);return this.mapFacet({...g,...h,facet:m,spec:{...c?{width:c}:{},...l?{height:l}:{},...f?{view:f}:{},...u?{projection:u}:{},mark:a,encoding:y,...d?{params:d}:{}}},n)}getFacetMappingAndLayout(t,n){const{row:i,column:r,facet:s}=t;if(i||r){s&&x(rp([...i?[Ze]:[],...r?[Je]:[]]));const o={},a={};for(const c of[Ze,Je]){const u=t[c];if(u){const{align:l,center:f,spacing:d,columns:p,...g}=u;o[c]=g;for(const m of["align","center","spacing"])u[m]!==void 0&&(a[m]??(a[m]={}),a[m][c]=u[m])}}return{facetMapping:o,layout:a}}else{const{align:o,center:a,spacing:c,columns:u,...l}=s;return{facetMapping:Zm(l,n.repeater),layout:{...o?{align:o}:{},...a?{center:a}:{},...c?{spacing:c}:{},...u?{columns:u}:{}}}}}mapLayer(t,{parentEncoding:n,parentProjection:i,...r}){const{encoding:s,projection:o,...a}=t,c={...r,parentEncoding:bu({parentEncoding:n,encoding:s,layer:!0}),parentProjection:xu({parentProjection:i,projection:o})};return super.mapLayer({...a,...t.name?{name:[c.repeaterPrefix,t.name].filter(u=>u).join("_")}:{}},c)}}function bu({parentEncoding:e,encoding:t={},layer:n}){let i={};if(e){const r=new Set([...b(e),...b(t)]);for(const s of r){const o=t[s],a=e[s];if(N(o)){const c={...a,...o};i[s]=c}else Kn(o)?i[s]={...o,condition:{...a,...o.condition}}:o||o===null?i[s]=o:(n||Ae(a)||E(a)||N(a)||$(a))&&(i[s]=a)}}else i=t;return!i||R(i)?void 0:i}function xu(e){const{parentProjection:t,projection:n}=e;return t&&n&&x(qd({parentProjection:t,projection:n})),n??t}function Bs(e){return"filter"in e}function th(e){return e?.stop!==void 0}function Su(e){return"lookup"in e}function nh(e){return"data"in e}function ih(e){return"param"in e}function rh(e){return"pivot"in e}function sh(e){return"density"in e}function oh(e){return"quantile"in e}function ah(e){return"regression"in e}function ch(e){return"loess"in e}function uh(e){return"sample"in e}function lh(e){return"window"in e}function fh(e){return"joinaggregate"in e}function dh(e){return"flatten"in e}function ph(e){return"calculate"in e}function wu(e){return"bin"in e}function gh(e){return"impute"in e}function mh(e){return"timeUnit"in e}function hh(e){return"aggregate"in e}function yh(e){return"stack"in e}function bh(e){return"fold"in e}function xh(e){return e.map(t=>Bs(t)?{filter:un(t.filter,Zp)}:t)}class Sh extends Ds{map(t,n){return n.emptySelections??(n.emptySelections={}),n.selectionPredicates??(n.selectionPredicates={}),t=vu(t,n),super.map(t,n)}mapLayerOrUnit(t,n){if(t=vu(t,n),t.encoding){const i={};for(const[r,s]of mt(t.encoding))i[r]=$u(s,n);t={...t,encoding:i}}return super.mapLayerOrUnit(t,n)}mapUnit(t,n){const{selection:i,...r}=t;return i?{...r,params:mt(i).map(([s,o])=>{const{init:a,bind:c,empty:u,...l}=o;l.type==="single"?(l.type="point",l.toggle=!1):l.type==="multi"&&(l.type="point"),n.emptySelections[s]=u!=="none";for(const f of ee(n.selectionPredicates[s]??{}))f.empty=u!=="none";return{name:s,value:a,select:l,bind:c}})}:t}}function vu(e,t){const{transform:n,...i}=e;if(n){const r=n.map(s=>{if(Bs(s))return{filter:Hs(s,t)};if(wu(s)&&Mt(s.bin))return{...s,bin:Eu(s.bin)};if(Su(s)){const{selection:o,...a}=s.from;return o?{...s,from:{param:o,...a}}:s}return s});return{...i,transform:r}}return e}function $u(e,t){const n=C(e);if(S(n)&&Mt(n.bin)&&(n.bin=Eu(n.bin)),Gt(n)&&n.scale?.domain?.selection){const{selection:i,...r}=n.scale.domain;n.scale.domain={...r,...i?{param:i}:{}}}if(Di(n))if(Vo(n.condition))n.condition=n.condition.map(i=>{const{selection:r,param:s,test:o,...a}=i;return s?i:{...a,test:Hs(i,t)}});else{const{selection:i,param:r,test:s,...o}=$u(n.condition,t);n.condition=r?n.condition:{...o,test:Hs(n.condition,t)}}return n}function Eu(e){const t=e.extent;if(t?.selection){const{selection:n,...i}=t;return{...e,extent:{...i,param:n}}}return e}function Hs(e,t){const n=i=>un(i,r=>{var s;const o=t.emptySelections[r]??!0,a={param:r,empty:o};return(s=t.selectionPredicates)[r]??(s[r]=[]),t.selectionPredicates[r].push(a),a});return e.selection?n(e.selection):un(e.test||e.filter,i=>i.selection?n(i.selection):i)}class qs extends Ds{map(t,n){const i=n.selections??[];if(t.params&&!ct(t)){const r=[];for(const s of t.params)Rs(s)?i.push(s):r.push(s);t.params=r}return n.selections=i,super.map(t,n)}mapUnit(t,n){const i=n.selections;if(!i||!i.length)return t;const r=(n.path??[]).concat(t.name),s=[];for(const o of i)if(!o.views||!o.views.length)s.push(o);else for(const a of o.views)(mi(a)&&(a===t.name||r.includes(a))||Vo(a)&&a.map(c=>r.indexOf(c)).every((c,u,l)=>c!==-1&&(u===0||c>l[u-1])))&&s.push(o);return s.length&&(t.params=s),t}}for(const e of["mapFacet","mapRepeat","mapHConcat","mapVConcat","mapLayer"]){const t=qs.prototype[e];qs.prototype[e]=function(n,i){return t.call(this,n,wh(n,i))}}function wh(e,t){return e.name?{...t,path:(t.path??[]).concat(e.name)}:t}function _u(e,t){t===void 0&&(t=lu(e.config));const n=_h(e,t),{width:i,height:r}=e,s=kh(n,{width:i,height:r,autosize:e.autosize},t);return{...n,...s?{autosize:s}:{}}}const vh=new eh,$h=new Sh,Eh=new qs;function _h(e,t={}){const n={config:t};return Eh.map(vh.map($h.map(e,n),n),n)}function ku(e){return F(e)?{type:e}:e??{}}function kh(e,t,n){let{width:i,height:r}=t;const s=ct(e)||er(e),o={};s?i=="container"&&r=="container"?(o.type="fit",o.contains="padding"):i=="container"?(o.type="fit-x",o.contains="padding"):r=="container"&&(o.type="fit-y",o.contains="padding"):(i=="container"&&(x(Na("width")),i=void 0),r=="container"&&(x(Na("height")),r=void 0));const a={type:"pad",...o,...n?ku(n.autosize):{},...ku(e.autosize)};return a.type==="fit"&&!s&&(x(Fd),a.type="pad"),i=="container"&&!(a.type=="fit"||a.type=="fit-x")&&x(Fa("width")),r=="container"&&!(a.type=="fit"||a.type=="fit-y")&&x(Fa("height")),Ie(a,{type:"pad"})?void 0:a}function Ch(e){return e==="fit"||e==="fit-x"||e==="fit-y"}function Nh(e){return e?`fit-${Ei(e)}`:"fit"}const Fh=["background","padding"];function Cu(e,t){const n={};for(const i of Fh)e&&e[i]!==void 0&&(n[i]=he(e[i]));return t&&(n.params=e.params),n}class lt{constructor(t={},n={}){this.explicit=t,this.implicit=n}clone(){return new lt(C(this.explicit),C(this.implicit))}combine(){return{...this.explicit,...this.implicit}}get(t){return V(this.explicit[t],this.implicit[t])}getWithExplicit(t){return this.explicit[t]!==void 0?{explicit:!0,value:this.explicit[t]}:this.implicit[t]!==void 0?{explicit:!1,value:this.implicit[t]}:{explicit:!1,value:void 0}}setWithExplicit(t,{value:n,explicit:i}){n!==void 0&&this.set(t,n,i)}set(t,n,i){return delete this[i?"implicit":"explicit"][t],this[i?"explicit":"implicit"][t]=n,this}copyKeyFromSplit(t,{explicit:n,implicit:i}){n[t]!==void 0?this.set(t,n[t],!0):i[t]!==void 0&&this.set(t,i[t],!1)}copyKeyFromObject(t,n){n[t]!==void 0&&this.set(t,n[t],!0)}copyAll(t){for(const n of b(t.combine())){const i=t.getWithExplicit(n);this.setWithExplicit(n,i)}}}function Ye(e){return{explicit:!0,value:e}}function be(e){return{explicit:!1,value:e}}function Nu(e){return(t,n,i,r)=>{const s=e(t.value,n.value);return s>0?t:s<0?n:tr(t,n,i,r)}}function tr(e,t,n,i){return e.explicit&&t.explicit&&x(hp(n,i,e.value,t.value)),e}function Ct(e,t,n,i,r=tr){return e===void 0||e.value===void 0?t:e.explicit&&!t.explicit?e:t.explicit&&!e.explicit?t:Ie(e.value,t.value)?e:r(e,t,n,i)}class Th extends lt{constructor(t={},n={},i=!1){super(t,n);this.explicit=t,this.implicit=n,this.parseNothing=i}clone(){const t=super.clone();return t.parseNothing=this.parseNothing,t}}function _n(e){return"url"in e}function Jn(e){return"values"in e}function Fu(e){return"name"in e&&!_n(e)&&!Jn(e)&&!Nt(e)}function Nt(e){return e&&(Tu(e)||Au(e)||Gs(e))}function Tu(e){return"sequence"in e}function Au(e){return"sphere"in e}function Gs(e){return"graticule"in e}var j;(function(e){e[e.Raw=0]="Raw",e[e.Main=1]="Main",e[e.Row=2]="Row",e[e.Column=3]="Column",e[e.Lookup=4]="Lookup"})(j||(j={}));function Ou(e){const{signals:t,hasLegend:n,index:i,...r}=e;return r.field=xe(r.field),r}function Xt(e,t=!0,n=wf){if($(e)){const i=e.map(r=>Xt(r,t,n));return t?`[${i.join(", ")}]`:i}else if(jt(e))return n(t?Ut(e):Up(e));return t?n(M(e)):e}function Ah(e,t){for(const n of ee(e.component.selection??{})){const i=n.name;let r=`${i}${Tt}, ${n.resolve==="global"?"true":`{unit: ${Kt(e)}}`}`;for(const s of or){if(!s.defined(n))continue;s.signals&&(t=s.signals(e,n,t)),s.modifyExpr&&(r=s.modifyExpr(e,n,r))}t.push({name:i+uy,on:[{events:{signal:n.name+Tt},update:`modify(${T(n.name+Yt)}, ${r})`}]})}return Vs(t)}function Oh(e,t){if(e.component.selection&&b(e.component.selection).length){const n=T(e.getName("cell"));t.unshift({name:"facet",value:{},on:[{events:cn("mousemove","scope"),update:`isTuple(facet) ? facet : group(${n}).datum`}]})}return Vs(t)}function Ph(e,t){let n=!1;for(const i of ee(e.component.selection??{})){const r=i.name,s=T(r+Yt),o=t.filter(a=>a.name===r);if(o.length===0){const a=i.resolve==="global"?"union":i.resolve,c=i.type==="point"?", true, true)":")";t.push({name:i.name,update:`${tl}(${s}, ${T(a)}${c}`})}n=!0;for(const a of or)a.defined(i)&&a.topLevelSignals&&(t=a.topLevelSignals(e,i,t))}if(n){const i=t.filter(r=>r.name==="unit");i.length===0&&t.unshift({name:"unit",value:{},on:[{events:"mousemove",update:"isTuple(group()) ? group() : unit"}]})}return Vs(t)}function zh(e,t){const n=[...t],i=Kt(e,{escape:!1});for(const r of ee(e.component.selection??{})){const s={name:r.name+Yt};if(r.project.hasSelectionId&&(s.transform=[{type:"collect",sort:{field:Oe}}]),r.init){const a=r.project.items.map(Ou);s.values=r.project.hasSelectionId?r.init.map(c=>({unit:i,[Oe]:Xt(c,!1)[0]})):r.init.map(c=>({unit:i,fields:a,values:Xt(c,!1)}))}const o=n.filter(a=>a.name===r.name+Yt);o.length||n.push(s)}return n}function Pu(e,t){for(const n of ee(e.component.selection??{}))for(const i of or)i.defined(n)&&i.marks&&(t=i.marks(e,n,t));return t}function Rh(e,t){for(const n of e.children)q(n)&&(t=Pu(n,t));return t}function Ih(e,t,n,i){const r=ol(e,t.param,t);return{signal:ye(n.get("type"))&&$(i)&&i[0]>i[1]?`isValid(${r}) && reverse(${r})`:r}}function Vs(e){return e.map(t=>(t.on&&!t.on.length&&delete t.on,t))}class I{constructor(t,n){this.debugName=n,this._children=[],this._parent=null,t&&(this.parent=t)}clone(){throw new Error("Cannot clone node")}get parent(){return this._parent}set parent(t){this._parent=t,t&&t.addChild(this)}get children(){return this._children}numChildren(){return this._children.length}addChild(t,n){if(this._children.includes(t)){x(Wd);return}n!==void 0?this._children.splice(n,0,t):this._children.push(t)}removeChild(t){const n=this._children.indexOf(t);return this._children.splice(n,1),n}remove(){let t=this._parent.removeChild(this);for(const n of this._children)n._parent=this._parent,this._parent.addChild(n,t++)}insertAsParentOf(t){const n=t.parent;n.removeChild(this),this.parent=n,t.parent=this}swapWithParent(){const t=this._parent,n=t.parent;for(const r of this._children)r.parent=t;this._children=[],t.removeChild(this);const i=t.parent.removeChild(t);this._parent=n,n.addChild(this,i),t.parent=this}}class ce extends I{clone(){const t=new this.constructor;return t.debugName=`clone_${this.debugName}`,t._source=this._source,t._name=`clone_${this._name}`,t.type=this.type,t.refCounts=this.refCounts,t.refCounts[t._name]=0,t}constructor(t,n,i,r){super(t,n);this.type=i,this.refCounts=r,this._source=this._name=n,this.refCounts&&!(this._name in this.refCounts)&&(this.refCounts[this._name]=0)}dependentFields(){return new Set}producedFields(){return new Set}hash(){return this._hash===void 0&&(this._hash=`Output ${Jo()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(t){this._source=t}}class Ke extends I{clone(){return new Ke(null,C(this.formula))}constructor(t,n){super(t);this.formula=n}static makeFromEncoding(t,n){const i=n.reduceFieldDef((r,s)=>{const{field:o,timeUnit:a}=s;if(a){const c=w(s,{forAs:!0});r[O({as:c,field:o,timeUnit:a})]={as:c,field:o,timeUnit:a}}return r},{});return R(i)?null:new Ke(t,i)}static makeFromTransform(t,n){const{timeUnit:i,...r}={...n},s=ne(i),o={...r,timeUnit:s};return new Ke(t,{[O(o)]:o})}merge(t){this.formula={...this.formula};for(const n in t.formula)this.formula[n]||(this.formula[n]=t.formula[n]);for(const n of t.children)t.removeChild(n),n.parent=this;t.remove()}removeFormulas(t){const n={};for(const[i,r]of mt(this.formula))t.has(r.as)||(n[i]=r);this.formula=n}producedFields(){return new Set(ee(this.formula).map(t=>t.as))}dependentFields(){return new Set(ee(this.formula).map(t=>t.field))}hash(){return`TimeUnit ${O(this.formula)}`}assemble(){const t=[];for(const n of ee(this.formula)){const{field:i,as:r,timeUnit:s}=n,{unit:o,utc:a,...c}=ne(s);t.push({field:xe(i),type:"timeunit",...o?{units:Ti(o)}:{},...a?{timezone:"utc"}:{},...c,as:[r,`${r}_end`]})}return t}}const ei="_tuple_fields";class Lh{constructor(...t){this.items=t,this.hasChannel={},this.hasField={},this.hasSelectionId=!1}}const Mh={defined:()=>!0,parse:(e,t,n)=>{const i=t.name,r=t.project??(t.project=new Lh),s={},o={},a=new Set,c=(g,m)=>{const h=m==="visual"?g.channel:g.field;let y=W(`${i}_${h}`);for(let v=1;a.has(y);v++)y=W(`${i}_${h}_${v}`);return a.add(y),{[m]:y}},u=t.type,l=e.config.selection[u],f=n.value!==void 0?H(n.value):null;let{fields:d,encodings:p}=L(n.select)?n.select:{};if(!d&&!p&&f)for(const g of f){if(!L(g))continue;for(const m of b(g))rd(m)?(p||(p=[])).push(m):u==="interval"?(x(Md),p=l.encodings):(d??(d=[])).push(m)}!d&&!p&&(p=l.encodings,"fields"in l&&(d=l.fields));for(const g of p??[]){const m=e.fieldDef(g);if(m){let h=m.field;if(m.aggregate){x(Td(g,m.aggregate));continue}else if(!h){x(Aa(g));continue}if(m.timeUnit){h=e.vgField(g);const y={timeUnit:m.timeUnit,as:h,field:m.field};o[O(y)]=y}if(!s[h]){const y=u==="interval"&&rt(g)&&ye(e.getScaleComponent(g).get("type"))?"R":m.bin?"R-RE":"E",v={field:h,channel:g,type:y,index:r.items.length};v.signals={...c(v,"data"),...c(v,"visual")},r.items.push(s[h]=v),r.hasField[h]=s[h],r.hasSelectionId=r.hasSelectionId||h===Oe,sa(g)?(v.geoChannel=g,v.channel=ra(g),r.hasChannel[v.channel]=s[h]):r.hasChannel[g]=s[h]}}else x(Aa(g))}for(const g of d??[]){if(r.hasField[g])continue;const m={type:"E",field:g,index:r.items.length};m.signals={...c(m,"data")},r.items.push(m),r.hasField[g]=m,r.hasSelectionId=r.hasSelectionId||g===Oe}f&&(t.init=f.map(g=>r.items.map(m=>L(g)?g[m.geoChannel||m.channel]!==void 0?g[m.geoChannel||m.channel]:g[m.field]:g))),R(o)||(r.timeUnit=new Ke(null,o))},signals:(e,t,n)=>{const i=t.name+ei,r=n.filter(s=>s.name===i);return r.length>0||t.project.hasSelectionId?n:n.concat({name:i,value:t.project.items.map(Ou)})}},ft={defined:e=>e.type==="interval"&&e.resolve==="global"&&e.bind&&e.bind==="scales",parse:(e,t)=>{const n=t.scales=[];for(const i of t.project.items){const r=i.channel;if(!rt(r))continue;const s=e.getScaleComponent(r),o=s?s.get("type"):void 0;if(!s||!ye(o)){x(Pd);continue}s.set("selectionExtent",{param:t.name,field:i.field},!0),n.push(i)}},topLevelSignals:(e,t,n)=>{const i=t.scales.filter(o=>n.filter(a=>a.name===o.signals.data).length===0);if(!e.parent||Ys(e)||i.length===0)return n;const r=n.filter(o=>o.name===t.name)[0];let s=r.update;if(s.indexOf(tl)>=0)r.update=`{${i.map(o=>`${T(xe(o.field))}: ${o.signals.data}`).join(", ")}}`;else{for(const o of i){const a=`${T(xe(o.field))}: ${o.signals.data}`;s.includes(a)||(s=`${s.substring(0,s.length-1)}, ${a}}`)}r.update=s}return n.concat(i.map(o=>({name:o.signals.data})))},signals:(e,t,n)=>{if(e.parent&&!Ys(e))for(const i of t.scales){const r=n.filter(s=>s.name===i.signals.data)[0];r.push="outer",delete r.value,delete r.update}return n}};function Xs(e,t){const n=T(e.scaleName(t));return`domain(${n})`}function Ys(e){return e.parent&&zn(e.parent)&&(!e.parent.parent??Ys(e.parent.parent))}const kn="_brush",zu="_scale_trigger",ti="geo_interval_init_tick",Ru="_init",Dh="_center",jh={defined:e=>e.type==="interval",parse:(e,t,n)=>{var i;if(e.hasProjection){const r={...kr(n.select)?n.select:{}};r.fields=[Oe],r.encodings||(r.encodings=n.value?b(n.value):[Ce,ke]),n.select={type:"interval",...r}}if(t.translate&&!ft.defined(t)){const r=`!event.item || event.item.mark.name !== ${T(t.name+kn)}`;for(const s of t.events){if(!s.between){x(`${s} is not an ordered event stream for interval selections.`);continue}const o=H((i=s.between[0]).filter??(i.filter=[]));o.indexOf(r)<0&&o.push(r)}}},signals:(e,t,n)=>{const i=t.name,r=i+Tt,s=ee(t.project.hasChannel).filter(a=>a.channel===B||a.channel===K),o=t.init?t.init[0]:null;if(n.push(...s.reduce((a,c)=>a.concat(Uh(e,t,c,o&&o[c.index])),[])),e.hasProjection){const a=T(e.projectionName()),c=e.projectionName()+Dh,{x:u,y:l}=t.project.hasChannel,f=u&&u.signals.visual,d=l&&l.signals.visual,p=u?o&&o[u.index]:`${c}[0]`,g=l?o&&o[l.index]:`${c}[1]`,m=P=>e.getSizeSignalRef(P).signal,h=`[[${f?f+"[0]":"0"}, ${d?d+"[0]":"0"}],[${f?f+"[1]":m("width")}, ${d?d+"[1]":m("height")}]]`;if(o&&(n.unshift({name:i+Ru,init:`[scale(${a}, [${u?p[0]:p}, ${l?g[0]:g}]), scale(${a}, [${u?p[1]:p}, ${l?g[1]:g}])]`}),!u||!l)){const P=n.find(Y=>Y.name===c);P||n.unshift({name:c,update:`invert(${a}, [${m("width")}/2, ${m("height")}/2])`})}const y=`intersect(${h}, {markname: ${T(e.getName("marks"))}}, unit.mark)`,v=`{unit: ${Kt(e)}}`,_=`vlSelectionTuples(${y}, ${v})`,k=s.map(P=>P.signals.visual);return n.concat({name:r,on:[{events:[...k.length?[{signal:k.join(" || ")}]:[],...o?[{signal:ti}]:[]],update:_}]})}else{if(!ft.defined(t)){const u=i+zu,l=s.map(f=>{const d=f.channel,{data:p,visual:g}=f.signals,m=T(e.scaleName(d)),h=e.getScaleComponent(d).get("type"),y=ye(h)?"+":"";return`(!isArray(${p}) || (${y}invert(${m}, ${g})[0] === ${y}${p}[0] && ${y}invert(${m}, ${g})[1] === ${y}${p}[1]))`});l.length&&n.push({name:u,value:{},on:[{events:s.map(f=>({scale:e.scaleName(f.channel)})),update:l.join(" && ")+` ? ${u} : {}`}]})}const a=s.map(u=>u.signals.data),c=`unit: ${Kt(e)}, fields: ${i+ei}, values`;return n.concat({name:r,...o?{init:`{${c}: ${Xt(o)}}`}:{},...a.length?{on:[{events:[{signal:a.join(" || ")}],update:`${a.join(" && ")} ? {${c}: [${a}]} : null`}]}:{}})}},topLevelSignals:(e,t,n)=>{if(q(e)&&e.hasProjection&&t.init){const i=n.filter(r=>r.name===ti);i.length||n.unshift({name:ti,value:null,on:[{events:"timer{1}",update:`${ti} === null ? {} : ${ti}`}]})}return n},marks:(e,t,n)=>{const i=t.name,{x:r,y:s}=t.project.hasChannel,o=r?.signals.visual,a=s?.signals.visual,c=`data(${T(t.name+Yt)})`;if(ft.defined(t)||!r&&!s)return n;const u={x:r!==void 0?{signal:`${o}[0]`}:{value:0},y:s!==void 0?{signal:`${a}[0]`}:{value:0},x2:r!==void 0?{signal:`${o}[1]`}:{field:{group:"width"}},y2:s!==void 0?{signal:`${a}[1]`}:{field:{group:"height"}}};if(t.resolve==="global")for(const m of b(u))u[m]=[{test:`${c}.length && ${c}[0].unit === ${Kt(e)}`,...u[m]},{value:0}];const{fill:l,fillOpacity:f,cursor:d,...p}=t.mark,g=b(p).reduce((m,h)=>(m[h]=[{test:[r!==void 0&&`${o}[0] !== ${o}[1]`,s!==void 0&&`${a}[0] !== ${a}[1]`].filter(y=>y).join(" && "),value:p[h]},{value:null}],m),{});return[{name:`${i+kn}_bg`,type:"rect",clip:!0,encode:{enter:{fill:{value:l},fillOpacity:{value:f}},update:u}},...n,{name:i+kn,type:"rect",clip:!0,encode:{enter:{...d?{cursor:{value:d}}:{},fill:{value:"transparent"}},update:{...u,...g}}}]}};function Uh(e,t,n,i){const r=!e.hasProjection,s=n.channel,o=n.signals.visual,a=T(r?e.scaleName(s):e.projectionName()),c=d=>`scale(${a}, ${d})`,u=e.getSizeSignalRef(s===B?"width":"height").signal,l=`${s}(unit)`,f=t.events.reduce((d,p)=>[...d,{events:p.between[0],update:`[${l}, ${l}]`},{events:p,update:`[${o}[0], clamp(${l}, 0, ${u})]`}],[]);if(r){const d=n.signals.data,p=ft.defined(t),g=e.getScaleComponent(s),m=g?g.get("type"):void 0,h=i?{init:Xt(i,!0,c)}:{value:[]};return f.push({events:{signal:t.name+zu},update:ye(m)?`[${c(`${d}[0]`)}, ${c(`${d}[1]`)}]`:"[0, 0]"}),p?[{name:d,on:[]}]:[{name:o,...h,on:f},{name:d,...i?{init:Xt(i)}:{},on:[{events:{signal:o},update:`${o}[0] === ${o}[1] ? null : invert(${a}, ${o})`}]}]}else{const d=s===B?0:1,p=t.name+Ru,g=i?{init:`[${p}[0][${d}], ${p}[1][${d}]]`}:{value:[]};return[{name:o,...g,on:f}]}}const Wh={defined:e=>e.type==="point",signals:(e,t,n)=>{const i=t.name,r=i+ei,s=t.project,o="(item().isVoronoi ? datum.datum : datum)",a=ee(e.component.selection??{}).reduce((f,d)=>d.type==="interval"?f.concat(d.name+kn):f,[]).map(f=>`indexof(item().mark.name, '${f}') < 0`).join(" && "),c=`datum && item().mark.marktype !== 'group' && indexof(item().mark.role, 'legend') < 0${a?` && ${a}`:""}`;let u=`unit: ${Kt(e)}, `;if(t.project.hasSelectionId)u+=`${Oe}: ${o}[${T(Oe)}]`;else{const f=s.items.map(d=>{const p=e.fieldDef(d.channel);return p?.bin?`[${o}[${T(e.vgField(d.channel,{}))}], ${o}[${T(e.vgField(d.channel,{binSuffix:"end"}))}]]`:`${o}[${T(d.field)}]`}).join(", ");u+=`fields: ${r}, values: [${f}]`}const l=t.events;return n.concat([{name:i+Tt,on:l?[{events:l,update:`${c} ? {${u}} : null`,force:!0}]:[]}])}};function Cn(e,t,n,i){const r=Di(t)&&t.condition,s=i(t);if(r){const o=H(r),a=o.map(c=>{const u=i(c);if(Lg(c)){const{param:l,empty:f}=c,d=sl(e,{param:l,empty:f});return{test:d,...u}}else{const l=ar(e,c.test);return{test:l,...u}}});return{[n]:[...a,...s!==void 0?[s]:[]]}}else return s!==void 0?{[n]:s}:{}}function Ks(e,t="text"){const n=e.encoding[t];return Cn(e,n,t,i=>nr(i,e.config))}function nr(e,t,n="datum"){if(e){if(Ae(e))return U(e.value);if(N(e)){const{format:i,formatType:r}=Bi(e);return ys({fieldOrDatumDef:e,format:i,formatType:r,expr:n,config:t})}}return}function Iu(e,t={}){const{encoding:n,markDef:i,config:r,stack:s}=e,o=n.tooltip;if($(o))return{tooltip:Mu({tooltip:o},s,r,t)};{const a=t.reactiveGeom?"datum.datum":"datum";return Cn(e,o,"tooltip",c=>{const u=nr(c,r,a);if(u)return u;if(c===null)return;let l=z("tooltip",i,r);return l===!0&&(l={content:"encoding"}),F(l)?{value:l}:L(l)?E(l)?l:l.content==="encoding"?Mu(n,s,r,t):{signal:a}:void 0})}}function Lu(e,t,n,{reactiveGeom:i}={}){const r={},s=i?"datum.datum":"datum",o=[];function a(u,l){const f=Lt(l),d=ae(u)?u:{...u,type:e[f].type},p=d.title||vs(d,n),g=H(p).join(", ");let m;if(Q(l)){const h=l==="x"?"x2":"y2",y=Ve(e[h]);if(te(d.bin)&&y){const v=w(d,{expr:s}),_=w(y,{expr:s}),{format:k,formatType:P}=Bi(d);m=Xn(v,_,k,P,n),r[h]=!0}}if((Q(l)||l===Se||l===_e)&&t&&t.fieldChannel===l&&t.offset==="normalize"){const{format:h,formatType:y}=Bi(d);m=ys({fieldOrDatumDef:d,format:h,formatType:y,expr:s,config:n,normalizeStack:!0}).signal}m??(m=nr(d,n,s).signal),o.push({channel:l,key:g,value:m})}ks(e,(u,l)=>{S(u)?a(u,l):ji(u)&&a(u.condition,l)});const c={};for(const{channel:u,key:l,value:f}of o)!r[u]&&!c[l]&&(c[l]=f);return c}function Mu(e,t,n,{reactiveGeom:i}={}){const r=Lu(e,t,n,{reactiveGeom:i}),s=mt(r).map(([o,a])=>`"${o}": ${a}`);return s.length>0?{signal:`{${s.join(", ")}}`}:void 0}function Bh(e){const{markDef:t,config:n}=e,i=z("aria",t,n);return i===!1?{}:{...i?{aria:i}:{},...Hh(e),...qh(e)}}function Hh(e){const{mark:t,markDef:n,config:i}=e;if(i.aria===!1)return{};const r=z("ariaRoleDescription",n,i);return r!=null?{ariaRoleDescription:{value:r}}:t in kd?{}:{ariaRoleDescription:{value:t}}}function qh(e){const{encoding:t,markDef:n,config:i,stack:r}=e,s=t.description;if(s)return Cn(e,s,"description",c=>nr(c,e.config));const o=z("description",n,i);if(o!=null)return{description:U(o)};if(i.aria===!1)return{};const a=Lu(t,r,i);return R(a)?void 0:{description:{signal:mt(a).map(([c,u],l)=>`"${l>0?"; ":""}${c}: " + (${u})`).join(" + ")}}}function J(e,t,n={}){const{markDef:i,encoding:r,config:s}=t,{vgChannel:o}=n;let{defaultRef:a,defaultValue:c}=n;a===void 0&&(c??(c=z(e,i,s,{vgChannel:o,ignoreVgConfig:!0})),c!==void 0&&(a=U(c)));const u=r[e];return Cn(t,u,o??e,l=>hs({channel:e,channelDef:l,markDef:i,config:s,scaleName:t.scaleName(e),scale:t.getScaleComponent(e),stack:null,defaultRef:a}))}function Du(e,t={filled:void 0}){const{markDef:n,encoding:i,config:r}=e,{type:s}=n,o=t.filled??z("filled",n,r),a=A(["bar","point","circle","square","geoshape"],s)?"transparent":void 0,c=z(o===!0?"color":void 0,n,r,{vgChannel:"fill"})??r.mark[o===!0&&"color"]??a,u=z(o===!1?"color":void 0,n,r,{vgChannel:"stroke"})??r.mark[o===!1&&"color"],l=o?"fill":"stroke",f={...c?{fill:U(c)}:{},...u?{stroke:U(u)}:{}};return n.color&&(o?n.fill:n.stroke)&&x(La("property",{fill:"fill"in n,stroke:"stroke"in n})),{...f,...J("color",e,{vgChannel:l,defaultValue:o?c:u}),...J("fill",e,{defaultValue:i.fill?c:void 0}),...J("stroke",e,{defaultValue:i.stroke?u:void 0})}}function Gh(e){const{encoding:t,mark:n}=e,i=t.order;return!_t(n)&&Ae(i)?Cn(e,i,"zindex",r=>U(r.value)):{}}function ni({channel:e,markDef:t,encoding:n={},model:i,bandPosition:r}){const s=`${e}Offset`,o=t[s],a=n[s];if((s==="xOffset"||s==="yOffset")&&a){const u=hs({channel:s,channelDef:a,markDef:t,config:i?.config,scaleName:i.scaleName(s),scale:i.getScaleComponent(s),stack:null,defaultRef:U(o),bandPosition:r});return{offsetType:"encoding",offset:u}}const c=t[s];return c?{offsetType:"visual",offset:c}:{}}function ie(e,t,{defaultPos:n,vgChannel:i}){const{encoding:r,markDef:s,config:o,stack:a}=t,c=r[e],u=r[Ue(e)],l=t.scaleName(e),f=t.getScaleComponent(e),{offset:d,offsetType:p}=ni({channel:e,markDef:s,encoding:r,model:t,bandPosition:.5}),g=Qs({model:t,defaultPos:n,channel:e,scaleName:l,scale:f}),m=!c&&Q(e)&&(r.latitude||r.longitude)?{field:t.getName(e)}:Vh({channel:e,channelDef:c,channel2Def:u,markDef:s,config:o,scaleName:l,scale:f,stack:a,offset:d,defaultRef:g,bandPosition:p==="encoding"?0:void 0});return m?{[i||e]:m}:void 0}function Vh(e){const{channel:t,channelDef:n,scaleName:i,stack:r,offset:s,markDef:o}=e;if(N(n)&&r&&t===r.fieldChannel){if(S(n)){let a=n.bandPosition;if(a===void 0&&o.type==="text"&&(t==="radius"||t==="theta")&&(a=.5),a!==void 0)return Ii({scaleName:i,fieldOrDatumDef:n,startSuffix:"start",bandPosition:a,offset:s})}return Ht(n,i,{suffix:"end"},{offset:s})}return gs(e)}function Qs({model:e,defaultPos:t,channel:n,scaleName:i,scale:r}){const{markDef:s,config:o}=e;return()=>{const a=Lt(n),c=wt(n),u=z(n,s,o,{vgChannel:c});if(u!==void 0)return Vn(n,u);switch(t){case"zeroOrMin":case"zeroOrMax":if(i){const l=r.get("type");if(!A([ge.LOG,ge.TIME,ge.UTC],l)){if(r.domainDefinitelyIncludesZero())return{scale:i,value:0}}}if(t==="zeroOrMin")return a==="y"?{field:{group:"height"}}:{value:0};switch(a){case"radius":return{signal:`min(${e.width.signal},${e.height.signal})/2`};case"theta":return{signal:"2*PI"};case"x":return{field:{group:"width"}};case"y":return{value:0}}break;case"mid":{const l=e[de(n)];return{...l,mult:.5}}}return}}const Xh={left:"x",center:"xc",right:"x2"},Yh={top:"y",middle:"yc",bottom:"y2"};function ju(e,t,n,i="middle"){if(e==="radius"||e==="theta")return wt(e);const r=e==="x"?"align":"baseline",s=z(r,t,n);let o;return E(s)?(x(sp(r)),o=void 0):o=s,e==="x"?Xh[o||(i==="top"?"left":"center")]:Yh[o||i]}function ir(e,t,{defaultPos:n,defaultPos2:i,range:r}){return r?Uu(e,t,{defaultPos:n,defaultPos2:i}):ie(e,t,{defaultPos:n})}function Uu(e,t,{defaultPos:n,defaultPos2:i}){const{markDef:r,config:s}=t,o=Ue(e),a=de(e),c=Kh(t,i,o),u=c[a]?ju(e,r,s):wt(e);return{...ie(e,t,{defaultPos:n,vgChannel:u}),...c}}function Kh(e,t,n){const{encoding:i,mark:r,markDef:s,stack:o,config:a}=e,c=Lt(n),u=de(n),l=wt(n),f=i[c],d=e.scaleName(c),p=e.getScaleComponent(c),{offset:g}=n in i||n in s?ni({channel:n,markDef:s,encoding:i,model:e}):ni({channel:c,markDef:s,encoding:i,model:e});if(!f&&(n==="x2"||n==="y2")&&(i.latitude||i.longitude)){const h=de(n),y=e.markDef[h];return y!=null?{[h]:{value:y}}:{[l]:{field:e.getName(n)}}}const m=Qh({channel:n,channelDef:f,channel2Def:i[n],markDef:s,config:a,scaleName:d,scale:p,stack:o,offset:g,defaultRef:void 0});return m!==void 0?{[l]:m}:rr(n,s)||rr(n,{[n]:Ci(n,s,a.style),[u]:Ci(u,s,a.style)})||rr(n,a[r])||rr(n,a.mark)||{[l]:Qs({model:e,defaultPos:t,channel:n,scaleName:d,scale:p})()}}function Qh({channel:e,channelDef:t,channel2Def:n,markDef:i,config:r,scaleName:s,scale:o,stack:a,offset:c,defaultRef:u}){return N(t)&&a&&e.charAt(0)===a.fieldChannel.charAt(0)?Ht(t,s,{suffix:"start"},{offset:c}):gs({channel:e,channelDef:n,scaleName:s,scale:o,stack:a,markDef:i,config:r,offset:c,defaultRef:u})}function rr(e,t){const n=de(e),i=wt(e);if(t[i]!==void 0)return{[i]:Vn(e,t[i])};if(t[e]!==void 0)return{[i]:Vn(e,t[e])};if(t[n]){const r=t[n];if(Bt(r))x(Zd(n));else return{[n]:Vn(e,r)}}return}function Ft(e,t){const{config:n,encoding:i,markDef:r}=e,s=r.type,o=Ue(t),a=de(t),c=i[t],u=i[o],l=e.getScaleComponent(t),f=l?l.get("type"):void 0,d=r.orient,p=i[a]??i.size??z("size",r,n,{vgChannel:a}),g=s==="bar"&&(t==="x"?d==="vertical":d==="horizontal");return S(c)&&(D(c.bin)||te(c.bin)||c.timeUnit&&!u)&&!(p&&!Bt(p))&&!Z(f)?ey({fieldDef:c,fieldDef2:u,channel:t,model:e}):(N(c)&&Z(f)||g)&&!u?Jh(c,t,e):Uu(t,e,{defaultPos:"zeroOrMax",defaultPos2:"zeroOrMin"})}function Zh(e,t,n,i,r){if(Bt(r))if(n){const o=n.get("type");if(o==="band"){let a=`bandwidth('${t}')`;return r.band!==1&&(a=`${r.band} * ${a}`),{signal:`max(0.25, ${a})`}}else r.band!==1&&(x(up(o)),r=void 0)}else return{mult:r.band,field:{group:e}};else{if(E(r))return r;if(r)return{value:r}}if(n){const o=n.get("range");if(Et(o)&&G(o.step))return{value:o.step-2}}const s=Zi(i.view,e);return{value:s-2}}function Jh(e,t,n){const{markDef:i,encoding:r,config:s,stack:o}=n,a=i.orient,c=n.scaleName(t),u=n.getScaleComponent(t),l=de(t),f=Ue(t),d=od(t),p=n.scaleName(d),g=a==="horizontal"&&t==="y"||a==="vertical"&&t==="x";let m;(r.size||i.size)&&(g?m=J("size",n,{vgChannel:l,defaultRef:U(i.size)}):x(pp(i.type)));const h=!!m,y=$c({channel:t,fieldDef:e,markDef:i,config:s,scaleType:u?.get("type"),useVlSizeChannel:g});m=m||{[l]:Zh(l,p||c,u,s,y)};const v=u?.get("type")==="band"&&Bt(y)&&!h?"top":"middle",_=ju(t,i,s,v),k=_==="xc"||_==="yc",{offset:P,offsetType:Y}=ni({channel:t,markDef:i,encoding:r,model:n,bandPosition:k?.5:0}),se=gs({channel:t,channelDef:e,markDef:i,config:s,scaleName:c,scale:u,stack:o,offset:P,defaultRef:Qs({model:n,defaultPos:"mid",channel:t,scaleName:c,scale:u}),bandPosition:k?Y==="encoding"?0:.5:E(y)?{signal:`(1-${y})/2`}:Bt(y)?(1-y.band)/2:0});if(l)return{[_]:se,...m};{const tn=wt(f),pt=m[l],gt=P?{...pt,offset:P}:pt;return{[_]:se,[tn]:$(se)?[se[0],{...se[1],offset:gt}]:{...se,offset:gt}}}}function ii(e,t,n,i,r){if(ia(e))return 0;const s=e==="x"||e==="y2"?-t/2:t/2;if(E(n)||E(r)||E(i)){const o=at(n),a=at(r),c=at(i),u=c?`${c} + `:"",l=o?`(${o} ? -1 : 1) * `:"",f=a?`(${a} + ${s})`:s;return{signal:u+l+f}}else return r=r||0,i+(n?-r-s:+r+s)}function ey({fieldDef:e,fieldDef2:t,channel:n,model:i}){const{config:r,markDef:s,encoding:o}=i,a=i.getScaleComponent(n),c=i.scaleName(n),u=a?a.get("type"):void 0,l=a.get("reverse"),f=$c({channel:n,fieldDef:e,markDef:s,config:r,scaleType:u}),d=i.component.axes[n]?.[0],p=d?.get("translate")??.5,g=Q(n)?z("binSpacing",s,r)??0:0,m=Ue(n),h=wt(n),y=wt(m),{offset:v}=ni({channel:n,markDef:s,encoding:o,model:i,bandPosition:0}),_=E(f)?{signal:`(1-${f.signal})/2`}:Bt(f)?(1-f.band)/2:.5;if(D(e.bin)||e.timeUnit)return{[y]:Wu({fieldDef:e,scaleName:c,bandPosition:_,offset:ii(m,g,l,p,v)}),[h]:Wu({fieldDef:e,scaleName:c,bandPosition:E(_)?{signal:`1-${_.signal}`}:1-_,offset:ii(n,g,l,p,v)})};if(te(e.bin)){const k=Ht(e,c,{},{offset:ii(m,g,l,p,v)});if(S(t))return{[y]:k,[h]:Ht(t,c,{},{offset:ii(n,g,l,p,v)})};if(Mt(e.bin)&&e.bin.step)return{[y]:k,[h]:{signal:`scale("${c}", ${w(e,{expr:"datum"})} + ${e.bin.step})`,offset:ii(n,g,l,p,v)}}}x(Wa(m));return}function Wu({fieldDef:e,scaleName:t,bandPosition:n,offset:i}){return Ii({scaleName:t,fieldOrDatumDef:e,bandPosition:n,offset:i})}const ty=new Set(["aria","width","height"]);function $e(e,t){const{fill:n=void 0,stroke:i=void 0}=t.color==="include"?Du(e):{};return{...ny(e.markDef,t),...Bu(e,"fill",n),...Bu(e,"stroke",i),...J("opacity",e),...J("fillOpacity",e),...J("strokeOpacity",e),...J("strokeWidth",e),...J("strokeDash",e),...Gh(e),...Iu(e),...Ks(e,"href"),...Bh(e)}}function Bu(e,t,n){const{config:i,mark:r,markDef:s}=e,o=z("invalid",s,i);if(o==="hide"&&n&&!_t(r)){const a=iy(e,{invalid:!0,channels:_i});if(a)return{[t]:[{test:a,value:null},...H(n)]}}return n?{[t]:n}:{}}function ny(e,t){return _d.reduce((n,i)=>(!ty.has(i)&&e[i]!==void 0&&t[i]!=="ignore"&&(n[i]=U(e[i])),n),{})}function iy(e,{invalid:t=!1,channels:n}){const i=n.reduce((s,o)=>{const a=e.getScaleComponent(o);if(a){const c=a.get("type"),u=e.vgField(o,{expr:"datum"});u&&ye(c)&&(s[u]=!0)}return s},{}),r=b(i);if(r.length>0){const s=t?"||":"&&";return r.map(o=>ms(o,t)).join(` ${s} `)}return}function Zs(e){const{config:t,markDef:n}=e,i=z("invalid",n,t);if(i){const r=ry(e,{channels:We});if(r)return{defined:{signal:r}}}return{}}function ry(e,{invalid:t=!1,channels:n}){const i=n.reduce((s,o)=>{const a=e.getScaleComponent(o);if(a){const c=a.get("type"),u=e.vgField(o,{expr:"datum",binSuffix:e.stack?.impute?"mid":void 0});u&&ye(c)&&(s[u]=!0)}return s},{}),r=b(i);if(r.length>0){const s=t?"||":"&&";return r.map(o=>ms(o,t)).join(` ${s} `)}return}function Hu(e,t){return t!==void 0?{[e]:U(t)}:void 0}const Js="voronoi",qu={defined:e=>e.type==="point"&&e.nearest,parse:(e,t)=>{if(t.events)for(const n of t.events)n.markname=e.getName(Js)},marks:(e,t,n)=>{const{x:i,y:r}=t.project.hasChannel,s=e.mark;if(_t(s))return x(Ad(s)),n;const o={name:e.getName(Js),type:"path",interactive:!0,from:{data:e.getName("marks")},encode:{update:{fill:{value:"transparent"},strokeWidth:{value:.35},stroke:{value:"transparent"},isVoronoi:{value:!0},...Iu(e,{reactiveGeom:!0})}},transform:[{type:"voronoi",x:{expr:i||!r?"datum.datum.x || 0":"0"},y:{expr:r||!i?"datum.datum.y || 0":"0"},size:[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]}]};let a=0,c=!1;return n.forEach((u,l)=>{const f=u.name??"";f===e.component.mark[0].name?a=l:f.indexOf(Js)>=0&&(c=!0)}),c||n.splice(a+1,0,o),n}},Gu={defined:e=>e.type==="point"&&e.resolve==="global"&&e.bind&&e.bind!=="scales"&&!Ps(e.bind),parse:(e,t,n)=>nl(t,n),topLevelSignals:(e,t,n)=>{const i=t.name,r=t.project,s=t.bind,o=t.init&&t.init[0],a=qu.defined(t)?"(item().isVoronoi ? datum.datum : datum)":"datum";return r.items.forEach((c,u)=>{const l=W(`${i}_${c.field}`),f=n.filter(d=>d.name===l);f.length||n.unshift({name:l,...o?{init:Xt(o[u])}:{value:null},on:t.events?[{events:t.events,update:`datum && item().mark.marktype !== 'group' ? ${a}[${T(c.field)}] : null`}]:[],bind:s[c.field]??s[c.channel]??s})}),n},signals:(e,t,n)=>{const i=t.name,r=t.project,s=n.filter(u=>u.name===i+Tt)[0],o=i+ei,a=r.items.map(u=>W(`${i}_${u.field}`)),c=a.map(u=>`${u} !== null`).join(" && ");return a.length&&(s.update=`${c} ? {fields: ${o}, values: [${a.join(", ")}]} : null`),delete s.value,delete s.on,n}},sr="_toggle",Vu={defined:e=>e.type==="point"&&!!e.toggle,signals:(e,t,n)=>n.concat({name:t.name+sr,value:!1,on:[{events:t.events,update:t.toggle}]}),modifyExpr:(e,t)=>{const n=t.name+Tt,i=t.name+sr;return`${i} ? null : ${n}, `+(t.resolve==="global"?`${i} ? null : true, `:`${i} ? null : {unit: ${Kt(e)}}, `)+`${i} ? ${n} : null`}},sy={defined:e=>e.clear!==void 0&&e.clear!==!1,parse:(e,t)=>{t.clear&&(t.clear=F(t.clear)?cn(t.clear,"view"):t.clear)},topLevelSignals:(e,t,n)=>{if(Gu.defined(t))for(const i of t.project.items){const r=n.findIndex(s=>s.name===W(`${t.name}_${i.field}`));r!==-1&&n[r].on.push({events:t.clear,update:"null"})}return n},signals:(e,t,n)=>{function i(r,s){r!==-1&&n[r].on&&n[r].on.push({events:t.clear,update:s})}if(t.type==="interval")for(const r of t.project.items){const s=n.findIndex(o=>o.name===r.signals.visual);if(i(s,"[0, 0]"),s===-1){const o=n.findIndex(a=>a.name===r.signals.data);i(o,"null")}}else{let r=n.findIndex(s=>s.name===t.name+Tt);i(r,"null"),Vu.defined(t)&&(r=n.findIndex(s=>s.name===t.name+sr),i(r,"false"))}return n}},Xu={defined:e=>{const t=e.resolve==="global"&&e.bind&&Ps(e.bind),n=e.project.items.length===1&&e.project.items[0].field!==Oe;return t&&!n&&x(zd),t&&n},parse:(e,t,n)=>{const i=C(n);if(i.select=F(i.select)?{type:i.select,toggle:t.toggle}:{...i.select,toggle:t.toggle},nl(t,i),kr(n.select)&&(n.select.on||n.select.clear)){const o='event.item && indexof(event.item.mark.role, "legend") < 0';for(const a of t.events)a.filter=H(a.filter??[]),a.filter.includes(o)||a.filter.push(o)}const r=zs(t.bind)?t.bind.legend:"click",s=F(r)?cn(r,"view"):H(r);t.bind={legend:{merge:s}}},topLevelSignals:(e,t,n)=>{const i=t.name,r=zs(t.bind)&&t.bind.legend,s=o=>a=>{const c=C(a);return c.markname=o,c};for(const o of t.project.items){if(!o.hasLegend)continue;const a=`${W(o.field)}_legend`,c=`${i}_${a}`,u=n.filter(l=>l.name===c);if(u.length===0){const l=r.merge.map(s(`${a}_symbols`)).concat(r.merge.map(s(`${a}_labels`))).concat(r.merge.map(s(`${a}_entries`)));n.unshift({name:c,...t.init?{}:{value:null},on:[{events:l,update:"datum.value || item().items[0].items[0].datum.value",force:!0},{events:r.merge,update:`!event.item || !datum ? null : ${c}`,force:!0}]})}}return n},signals:(e,t,n)=>{const i=t.name,r=t.project,s=n.find(d=>d.name===i+Tt),o=i+ei,a=r.items.filter(d=>d.hasLegend).map(d=>W(`${i}_${W(d.field)}_legend`)),c=a.map(d=>`${d} !== null`).join(" && "),u=`${c} ? {fields: ${o}, values: [${a.join(", ")}]} : null`;t.events&&a.length>0?s.on.push({events:a.map(d=>({signal:d})),update:u}):a.length>0&&(s.update=u,delete s.value,delete s.on);const l=n.find(d=>d.name===i+sr),f=zs(t.bind)&&t.bind.legend;return l&&(t.events?l.on.push({...l.on[0],events:f}):l.on[0].events=f),n}};function oy(e,t,n){const i=e.fieldDef(t)?.field;for(const r of ee(e.component.selection??{})){const s=r.project.hasField[i]??r.project.hasChannel[t];if(s&&Xu.defined(r)){const o=n.get("selections")??[];o.push(r.name),n.set("selections",o,!1),s.hasLegend=!0}}}const Yu="_translate_anchor",Ku="_translate_delta",ay={defined:e=>e.type==="interval"&&e.translate,signals:(e,t,n)=>{const i=t.name,r=ft.defined(t),s=i+Yu,{x:o,y:a}=t.project.hasChannel;let c=cn(t.translate,"scope");return r||(c=c.map(u=>(u.between[0].markname=i+kn,u))),n.push({name:s,value:{},on:[{events:c.map(u=>u.between[0]),update:"{x: x(unit), y: y(unit)"+(o!==void 0?`, extent_x: ${r?Xs(e,B):`slice(${o.signals.visual})`}`:"")+(a!==void 0?`, extent_y: ${r?Xs(e,K):`slice(${a.signals.visual})`}`:"")+"}"}]},{name:i+Ku,value:{},on:[{events:c,update:`{x: ${s}.x - x(unit), y: ${s}.y - y(unit)}`}]}),o!==void 0&&Qu(e,t,o,"width",n),a!==void 0&&Qu(e,t,a,"height",n),n}};function Qu(e,t,n,i,r){const s=t.name,o=s+Yu,a=s+Ku,c=n.channel,u=ft.defined(t),l=r.filter(P=>P.name===n.signals[u?"data":"visual"])[0],f=e.getSizeSignalRef(i).signal,d=e.getScaleComponent(c),p=d&&d.get("type"),g=d&&d.get("reverse"),m=u?c===B?g?"":"-":g?"-":"":"",h=`${o}.extent_${c}`,y=`${m}${a}.${c} / ${u?`${f}`:`span(${h})`}`,v=!u||!d?"panLinear":p==="log"?"panLog":p==="symlog"?"panSymlog":p==="pow"?"panPow":"panLinear",_=u?p==="pow"?`, ${d.get("exponent")??1}`:p==="symlog"?`, ${d.get("constant")??1}`:"":"",k=`${v}(${h}, ${y}${_})`;l.on.push({events:{signal:a},update:u?k:`clampRange(${k}, 0, ${f})`})}const Zu="_zoom_anchor",Ju="_zoom_delta",cy={defined:e=>e.type==="interval"&&e.zoom,signals:(e,t,n)=>{const i=t.name,r=ft.defined(t),s=i+Ju,{x:o,y:a}=t.project.hasChannel,c=T(e.scaleName(B)),u=T(e.scaleName(K));let l=cn(t.zoom,"scope");return r||(l=l.map(f=>(f.markname=i+kn,f))),n.push({name:i+Zu,on:[{events:l,update:r?"{"+[c?`x: invert(${c}, x(unit))`:"",u?`y: invert(${u}, y(unit))`:""].filter(f=>f).join(", ")+"}":"{x: x(unit), y: y(unit)}"}]},{name:s,on:[{events:l,force:!0,update:"pow(1.001, event.deltaY * pow(16, event.deltaMode))"}]}),o!==void 0&&el(e,t,o,"width",n),a!==void 0&&el(e,t,a,"height",n),n}};function el(e,t,n,i,r){const s=t.name,o=n.channel,a=ft.defined(t),c=r.filter(v=>v.name===n.signals[a?"data":"visual"])[0],u=e.getSizeSignalRef(i).signal,l=e.getScaleComponent(o),f=l&&l.get("type"),d=a?Xs(e,o):c.name,p=s+Ju,g=`${s}${Zu}.${o}`,m=!a||!l?"zoomLinear":f==="log"?"zoomLog":f==="symlog"?"zoomSymlog":f==="pow"?"zoomPow":"zoomLinear",h=a?f==="pow"?`, ${l.get("exponent")??1}`:f==="symlog"?`, ${l.get("constant")??1}`:"":"",y=`${m}(${d}, ${g}, ${p}${h})`;c.on.push({events:{signal:p},update:a?y:`clampRange(${y}, 0, ${u})`})}const Yt="_store",Tt="_tuple",uy="_modify",tl="vlSelectionResolve",or=[Wh,jh,Mh,Vu,Gu,ft,Xu,sy,ay,cy,qu];function ly(e){let t=e.parent;for(;t&&!Re(t);)t=t.parent;return t}function Kt(e,{escape:t}={escape:!0}){let n=t?T(e.name):e.name;const i=ly(e);if(i){const{facet:r}=i;for(const s of ve)r[s]&&(n+=` + '__facet_${s}_' + (facet[${T(i.vgField(s))}])`)}return n}function eo(e){return ee(e.component.selection??{}).reduce((t,n)=>t||n.project.hasSelectionId,!1)}function nl(e,t){(mi(t.select)||!t.select.on)&&delete e.events,(mi(t.select)||!t.select.clear)&&delete e.clear,(mi(t.select)||!t.select.toggle)&&delete e.toggle}function to(e){const t=[];return e.type==="Identifier"?[e.name]:e.type==="Literal"?[e.value]:(e.type==="MemberExpression"&&(t.push(...to(e.object)),t.push(...to(e.property))),t)}function il(e){return e.object.type==="MemberExpression"?il(e.object):e.object.name==="datum"}function rl(e){const t=_f(e),n=new Set;return t.visit(i=>{i.type==="MemberExpression"&&il(i)&&n.add(to(i).slice(1).join("."))}),n}class Nn extends I{clone(){return new Nn(null,this.model,C(this.filter))}constructor(t,n,i){super(t);this.model=n,this.filter=i,this.expr=ar(this.model,this.filter,this),this._dependentFields=rl(this.expr)}dependentFields(){return this._dependentFields}producedFields(){return new Set}assemble(){return{type:"filter",expr:this.expr}}hash(){return`Filter ${this.expr}`}}function fy(e,t){const n={},i=e.config.selection;if(!t||!t.length)return n;for(const r of t){const s=W(r.name),o=r.select,a=F(o)?o:o.type,c=L(o)?C(o):{type:a},u=i[a];for(const d in u){if(d==="fields"||d==="encodings")continue;d==="mark"&&(c[d]={...u[d],...c[d]}),(c[d]===void 0||c[d]===!0)&&(c[d]=C(u[d]??c[d]))}const l=n[s]={...c,name:s,type:a,init:r.value,bind:r.bind,events:F(c.on)?cn(c.on,"scope"):H(C(c.on))},f=C(r);for(const d of or)d.defined(l)&&d.parse&&d.parse(e,l,f)}return n}function sl(e,t,n,i="datum"){const r=F(t)?t:t.param,s=W(r),o=T(s+Yt);let a;try{a=e.getSelectionComponent(s,r)}catch(d){return`!!${s}`}if(a.project.timeUnit){const d=n??e.component.data.raw,p=a.project.timeUnit.clone();d.parent?p.insertAsParentOf(d):d.parent=p}const c=a.project.hasSelectionId?"vlSelectionIdTest(":"vlSelectionTest(",u=a.resolve==="global"?")":`, ${T(a.resolve)})`,l=`${c}${o}, ${i}${u}`,f=`length(data(${o}))`;return t.empty===!1?`${f} && ${l}`:`!${f} || ${l}`}function ol(e,t,n){const i=W(t),r=n.encoding;let s=n.field,o;try{o=e.getSelectionComponent(i,t)}catch(a){return i}if(!r&&!s)s=o.project.items[0].field,o.project.items.length>1&&x(`A "field" or "encoding" must be specified when using a selection as a scale domain. Using "field": ${T(s)}.`);else if(r&&!s){const a=o.project.items.filter(c=>c.channel===r);!a.length||a.length>1?(s=o.project.items[0].field,x((a.length?"Multiple ":"No ")+`matching ${T(r)} encoding found for selection ${T(n.param)}. Using "field": ${T(s)}.`)):s=a[0].field}return`${o.name}[${T(xe(s))}]`}function dy(e,t){for(const[n,i]of mt(e.component.selection??{})){const r=e.getName(`lookup_${n}`);e.component.data.outputNodes[r]=i.materialized=new ce(new Nn(t,e,{param:n}),r,j.Lookup,e.component.data.outputNodeRefCounts)}}function ar(e,t,n){return Dn(t,i=>F(i)?i:Yp(i)?sl(e,i,n):Ka(i))}function py(e,t){return e?$(e)&&!$t(e)?e.map(n=>vs(n,t)).join(", "):e:void 0}function no(e,t,n,i){var r,s;e.encode??(e.encode={}),(r=e.encode)[t]??(r[t]={}),(s=e.encode[t]).update??(s.update={}),e.encode[t].update[n]=i}function ri(e,t,n,i={header:!1}){const{disable:r,orient:s,scale:o,labelExpr:a,title:c,zindex:u,...l}=e.combine();if(r)return;for(const f in l){const d=Qg[f],p=l[f];if(d&&d!==t&&d!=="both")delete l[f];else if(Zn(p)){const{condition:g,...m}=p,h=H(g),y=Pc[f];if(y){const{vgProp:v,part:_}=y,k=[...h.map(P=>{const{test:Y,...se}=P;return{test:ar(null,Y),...se}}),m];no(l,_,v,k),delete l[f]}else if(y===null){const v={signal:h.map(_=>{const{test:k,...P}=_;return`${ar(null,k)} ? ${wa(P)} : `}).join("")+wa(m)};l[f]=v}}else if(E(p)){const g=Pc[f];if(g){const{vgProp:m,part:h}=g;no(l,h,m,p),delete l[f]}}A(["labelAlign","labelBaseline"],f)&&l[f]===null&&delete l[f]}if(t==="grid"){if(!l.grid)return;if(l.encode){const{grid:f}=l.encode;l.encode={...f?{grid:f}:{}},R(l.encode)&&delete l.encode}return{scale:o,orient:s,...l,domain:!1,labels:!1,aria:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:V(u,0)}}else{if(!i.header&&e.mainExtracted)return;if(a!==void 0){let d=a;l.encode?.labels?.update&&E(l.encode.labels.update.text)&&(d=zt(a,"datum.label",l.encode.labels.update.text.signal)),no(l,"labels","text",{signal:d})}if(l.labelAlign===null&&delete l.labelAlign,l.encode){for(const d of zc)e.hasAxisPart(d)||delete l.encode[d];R(l.encode)&&delete l.encode}const f=py(c,n);return{scale:o,orient:s,grid:!1,...f?{title:f}:{},...l,...n.aria===!1?{aria:!1}:{},zindex:V(u,0)}}}function al(e){const{axes:t}=e.component,n=[];for(const i of We)if(t[i]){for(const r of t[i])if(!r.get("disable")&&!r.get("gridScale")){const s=i==="x"?"height":"width",o=e.getSizeSignalRef(s).signal;s!==o&&n.push({name:s,update:o})}}return n}function gy(e,t){const{x:n=[],y:i=[]}=e;return[...n.map(r=>ri(r,"grid",t)),...i.map(r=>ri(r,"grid",t)),...n.map(r=>ri(r,"main",t)),...i.map(r=>ri(r,"main",t))].filter(r=>r)}function cl(e,t,n,i){return Object.assign.apply(null,[{},...e.map(r=>{if(r==="axisOrient"){const s=n==="x"?"bottom":"left",o=t[n==="x"?"axisBottom":"axisLeft"]||{},a=t[n==="x"?"axisTop":"axisRight"]||{},c=new Set([...b(o),...b(a)]),u={};for(const l of c.values())u[l]={signal:`${i.signal} === "${s}" ? ${at(o[l])} : ${at(a[l])}`};return u}return t[r]})])}function my(e,t,n,i){const r=t==="band"?["axisDiscrete","axisBand"]:t==="point"?["axisDiscrete","axisPoint"]:tc(t)?["axisQuantitative"]:t==="time"||t==="utc"?["axisTemporal"]:[],s=e==="x"?"axisX":"axisY",o=E(n)?"axisOrient":`axis${jn(n)}`,a=[...r,...r.map(u=>s+u.substr(4))],c=["axis",o,s];return{vlOnlyAxisConfig:cl(a,i,e,n),vgAxisConfig:cl(c,i,e,n),axisConfigStyle:hy([...c,...a],i)}}function hy(e,t){const n=[{}];for(const i of e){let r=t[i]?.style;if(r){r=H(r);for(const s of r)n.push(t.style[s])}}return Object.assign.apply(null,n)}function io(e,t,n,i={}){const r=$a(e,n,t);if(r!==void 0)return{configFrom:"style",configValue:r};for(const s of["vlOnlyAxisConfig","vgAxisConfig","axisConfigStyle"])if(i[s]?.[e]!==void 0)return{configFrom:s,configValue:i[s][e]};return{}}const ul={scale:({model:e,channel:t})=>e.scaleName(t),format:({format:e})=>e,formatType:({formatType:e})=>e,grid:({fieldOrDatumDef:e,axis:t,scaleType:n})=>t.grid??yy(n,e),gridScale:({model:e,channel:t})=>by(e,t),labelAlign:({axis:e,labelAngle:t,orient:n,channel:i})=>e.labelAlign||fl(t,n,i),labelAngle:({labelAngle:e})=>e,labelBaseline:({axis:e,labelAngle:t,orient:n,channel:i})=>e.labelBaseline||ll(t,n,i),labelFlush:({axis:e,fieldOrDatumDef:t,channel:n})=>e.labelFlush??Sy(t.type,n),labelOverlap:({axis:e,fieldOrDatumDef:t,scaleType:n})=>e.labelOverlap??wy(t.type,n,S(t)&&!!t.timeUnit,S(t)?t.sort:void 0),orient:({orient:e})=>e,tickCount:({channel:e,model:t,axis:n,fieldOrDatumDef:i,scaleType:r})=>{const s=e==="x"?"width":e==="y"?"height":void 0,o=s?t.getSizeSignalRef(s):void 0;return n.tickCount??$y({fieldOrDatumDef:i,scaleType:r,size:o,values:n.values})},tickMinStep:Ey,title:({axis:e,model:t,channel:n})=>{if(e.title!==void 0)return e.title;const i=dl(t,n);if(i!==void 0)return i;const r=t.typedFieldDef(n),s=n==="x"?"x2":"y2",o=t.fieldDef(s);return _a(r?[wc(r)]:[],S(o)?[wc(o)]:[])},values:({axis:e,fieldOrDatumDef:t})=>_y(e,t),zindex:({axis:e,fieldOrDatumDef:t,mark:n})=>e.zindex??ky(n,t)};function yy(e,t){return!Z(e)&&S(t)&&!D(t?.bin)&&!te(t?.bin)}function by(e,t){const n=t==="x"?"y":"x";return e.getScaleComponent(n)?e.scaleName(n):void 0}function xy(e,t,n,i,r){const s=t?.labelAngle;if(s!==void 0)return E(s)?s:Un(s);{const{configValue:o}=io("labelAngle",i,t?.style,r);return o!==void 0?Un(o):n===B&&A([cs,as],e.type)&&!(S(e)&&e.timeUnit)?270:void 0}}function ro(e){return`(((${e.signal} % 360) + 360) % 360)`}function ll(e,t,n,i){if(e!==void 0)if(n==="x"){if(E(e)){const r=ro(e),s=E(t)?`(${t.signal} === "top")`:t==="top";return{signal:`(45 < ${r} && ${r} < 135) || (225 < ${r} && ${r} < 315) ? "middle" :(${r} <= 45 || 315 <= ${r}) === ${s} ? "bottom" : "top"`}}if(45{if(!Gt(i))return;if(Sc(i.sort)){const{field:s,timeUnit:o}=i,a=i.sort,c=a.map((u,l)=>`${Ka({field:s,timeUnit:o,equal:u})} ? ${l} : `).join("")+a.length;t=new Fn(t,{calculate:c,as:Tn(i,r,{forAs:!0})})}}),t}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 ${O(this.transform)}`}}function Tn(e,t,n){return w(e,{prefix:t,suffix:"sort_index",...n??{}})}function cr(e,t){return A(["top","bottom"],t)?"column":A(["left","right"],t)||e==="row"?"row":"column"}function An(e,t,n,i){const r=i==="row"?n.headerRow:i==="column"?n.headerColumn:n.headerFacet;return V((t||{})[e],r[e],n.header[e])}function ur(e,t,n,i){const r={};for(const s of e){const o=An(s,t||{},n,i);o!==void 0&&(r[s]=o)}return r}const so=["row","column"],oo=["header","footer"];function Cy(e,t){const n=e.component.layoutHeaders[t].title,i=e.config?e.config:void 0,r=e.component.layoutHeaders[t].facetFieldDef?e.component.layoutHeaders[t].facetFieldDef:void 0,{titleAnchor:s,titleAngle:o,titleOrient:a}=ur(["titleAnchor","titleAngle","titleOrient"],r.header,i,t),c=cr(t,a),u=Un(o);return{name:`${t}-title`,type:"group",role:`${c}-title`,title:{text:n,...t==="row"?{orient:"left"}:{},style:"guide-title",...gl(u,c),...pl(c,u,s),...ml(i,r,t,xm,Zc)}}}function pl(e,t,n="middle"){switch(n){case"start":return{align:"left"};case"end":return{align:"right"}}const i=fl(t,e==="row"?"left":"top",e==="row"?"y":"x");return i?{align:i}:{}}function gl(e,t){const n=ll(e,t==="row"?"left":"top",t==="row"?"y":"x",!0);return n?{baseline:n}:{}}function Ny(e,t){const n=e.component.layoutHeaders[t],i=[];for(const r of oo)if(n[r])for(const s of n[r]){const o=Ty(e,t,r,n,s);o!=null&&i.push(o)}return i}function Fy(e,t){const{sort:n}=e;return qe(n)?{field:w(n,{expr:"datum"}),order:n.order??"ascending"}:$(n)?{field:Tn(e,t,{expr:"datum"}),order:"ascending"}:{field:w(e,{expr:"datum"}),order:n??"ascending"}}function ao(e,t,n){const{format:i,formatType:r,labelAngle:s,labelAnchor:o,labelOrient:a,labelExpr:c}=ur(["format","formatType","labelAngle","labelAnchor","labelOrient","labelExpr"],e.header,n,t),u=ys({fieldOrDatumDef:e,format:i,formatType:r,expr:"parent",config:n}).signal,l=cr(t,a);return{text:{signal:c?zt(zt(c,"datum.label",u),"datum.value",w(e,{expr:"parent"})):u},...t==="row"?{orient:"left"}:{},style:"guide-label",frame:"group",...gl(s,l),...pl(l,s,o),...ml(n,e,t,Sm,Jc)}}function Ty(e,t,n,i,r){if(r){let s=null;const{facetFieldDef:o}=i,a=e.config?e.config:void 0;if(o&&r.labels){const{labelOrient:f}=ur(["labelOrient"],o.header,a,t);(t==="row"&&!A(["top","bottom"],f)||t==="column"&&!A(["left","right"],f))&&(s=ao(o,t,a))}const c=Re(e)&&!Yn(e.facet),u=r.axes,l=u?.length>0;if(s||l){const f=t==="row"?"height":"width";return{name:e.getName(`${t}_${n}`),type:"group",role:`${t}-${n}`,...i.facetFieldDef?{from:{data:e.getName(`${t}_domain`)},sort:Fy(o,t)}:{},...l&&c?{from:{data:e.getName(`facet_domain_${t}`)}}:{},...s?{title:s}:{},...r.sizeSignal?{encode:{update:{[f]:r.sizeSignal}}}:{},...l?{axes:u}:{}}}}return null}const Ay={column:{start:0,end:1},row:{start:1,end:0}};function Oy(e,t){return Ay[t][e]}function Py(e,t){const n={};for(const i of ve){const r=e[i];if(r?.facetFieldDef){const{titleAnchor:s,titleOrient:o}=ur(["titleAnchor","titleOrient"],r.facetFieldDef.header,t,i),a=cr(i,o),c=Oy(s,a);c!==void 0&&(n[a]=c)}}return R(n)?void 0:n}function ml(e,t,n,i,r){const s={};for(const o of i){if(!r[o])continue;const a=An(o,t?.header,e,n);a!==void 0&&(s[r[o]]=a)}return s}function co(e){return[...lr(e,"width"),...lr(e,"height"),...lr(e,"childWidth"),...lr(e,"childHeight")]}function lr(e,t){const n=t==="width"?"x":"y",i=e.component.layoutSize.get(t);if(!i||i==="merged")return[];const r=e.getSizeSignalRef(t).signal;if(i==="step"){const s=e.getScaleComponent(n);if(s){const o=s.get("type"),a=s.get("range");if(Z(o)&&Et(a)){const c=e.scaleName(n);if(Re(e.parent)){const u=e.parent.component.resolve;if(u.scale[n]==="independent")return[hl(c,a)]}return[hl(c,a),{name:r,update:yl(c,s,`domain('${c}').length`)}]}}throw new Error("layout size is step although width/height is not step.")}else if(i=="container"){const s=r.endsWith("width"),o=s?"containerSize()[0]":"containerSize()[1]",a=Ms(e.config.view,s?"width":"height"),c=`isFinite(${o}) ? ${o} : ${a}`;return[{name:r,init:c,on:[{update:c,events:"window:resize"}]}]}else return[{name:r,value:i}]}function hl(e,t){const n=`${e}_step`;return E(t.step)?{name:n,update:t.step.signal}:{name:n,value:t.step}}function yl(e,t,n){const i=t.get("type"),r=t.get("padding"),s=V(t.get("paddingOuter"),r);let o=t.get("paddingInner");return o=i==="band"?o!==void 0?o:r:1,`bandspace(${n}, ${at(o)}, ${at(s)}) * ${e}_step`}function bl(e){return e==="childWidth"?"width":e==="childHeight"?"height":e}function xl(e,t){return b(e).reduce((n,i)=>{const r=e[i];return{...n,...Cn(t,r,i,s=>U(s.value))}},{})}function Sl(e,t){if(Re(t))return e==="theta"?"independent":"shared";if(zn(t))return"shared";if(Eo(t))return Q(e)||e==="theta"||e==="radius"?"independent":"shared";throw new Error("invalid model type for resolve")}function uo(e,t){const n=e.scale[t],i=Q(t)?"axis":"legend";return n==="independent"?(e[i][t]==="shared"&&x(bp(t)),"independent"):e[i][t]||"shared"}const zy={...$m,disable:1,labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1},wl=b(zy);class Ry extends lt{}const vl={symbols:Iy,gradient:Ly,labels:My,entries:Dy};function Iy(e,{fieldOrDatumDef:t,model:n,channel:i,legendCmpt:r,legendType:s}){if(s!=="symbol")return;const{markDef:o,encoding:a,config:c,mark:u}=n,l=o.filled&&u!=="trail";let f={...Nd({},n,Sg),...Du(n,{filled:l})};const d=r.get("symbolOpacity")??c.legend.symbolOpacity,p=r.get("symbolFillColor")??c.legend.symbolFillColor,g=r.get("symbolStrokeColor")??c.legend.symbolStrokeColor,m=d===void 0?$l(a.opacity)??o.opacity:void 0;if(f.fill){if(i==="fill"||l&&i===le)delete f.fill;else if(f.fill.field)p?delete f.fill:(f.fill=U(c.legend.symbolBaseFillColor??"black"),f.fillOpacity=U(m??1));else if($(f.fill)){const h=lo(a.fill??a.color)??o.fill??(l&&o.color);h&&(f.fill=U(h))}}if(f.stroke){if(i==="stroke"||!l&&i===le)delete f.stroke;else if(f.stroke.field||g)delete f.stroke;else if($(f.stroke)){const h=V(lo(a.stroke||a.color),o.stroke,l?o.color:void 0);h&&(f.stroke={value:h})}}if(i!==it){const h=S(t)&&_l(n,r,t);h?f.opacity=[{test:h,...U(m??1)},U(c.legend.unselectedOpacity)]:m&&(f.opacity=U(m))}return f={...f,...e},R(f)?void 0:f}function Ly(e,{model:t,legendType:n,legendCmpt:i}){if(n!=="gradient")return;const{config:r,markDef:s,encoding:o}=t;let a={};const c=i.get("gradientOpacity")??r.legend.gradientOpacity,u=c===void 0?$l(o.opacity)||s.opacity:void 0;return u&&(a.opacity=U(u)),a={...a,...e},R(a)?void 0:a}function My(e,{fieldOrDatumDef:t,model:n,channel:i,legendCmpt:r}){const s=n.legend(i)||{},o=n.config,a=S(t)?_l(n,r,t):void 0,c=a?[{test:a,value:1},{value:o.legend.unselectedOpacity}]:void 0,{format:u,formatType:l}=s;let f;qt(l)?f=Te({fieldOrDatumDef:t,field:"datum.value",format:u,formatType:l,config:o}):u===void 0&&l===void 0&&o.customFormatTypes&&(t.type==="quantitative"&&o.numberFormatType?f=Te({fieldOrDatumDef:t,field:"datum.value",format:o.numberFormat,formatType:o.numberFormatType,config:o}):t.type==="temporal"&&o.timeFormatType&&S(t)&&t.timeUnit===void 0&&(f=Te({fieldOrDatumDef:t,field:"datum.value",format:o.timeFormat,formatType:o.timeFormatType,config:o})));const d={...c?{opacity:c}:{},...f?{text:f}:{},...e};return R(d)?void 0:d}function Dy(e,{legendCmpt:t}){const n=t.get("selections");return n?.length?{...e,fill:{value:"transparent"}}:e}function $l(e){return El(e,(t,n)=>Math.max(t,n.value))}function lo(e){return El(e,(t,n)=>V(t,n.value))}function El(e,t){return Dg(e)?H(e.condition).reduce(t,e.value):Ae(e)?e.value:void 0}function _l(e,t,n){const i=t.get("selections");if(!i?.length)return;const r=T(n.field);return i.map(s=>{const o=T(W(s)+Yt);return`(!length(data(${o})) || (${s}[${r}] && indexof(${s}[${r}], datum.value) >= 0))`}).join(" || ")}const kl={direction:({direction:e})=>e,format:({fieldOrDatumDef:e,legend:t,config:n})=>{const{format:i,formatType:r}=t;return gc(e,e.type,i,r,n,!1)},formatType:({legend:e,fieldOrDatumDef:t,scaleType:n})=>{const{formatType:i}=e;return mc(i,t,n)},gradientLength:e=>{const{legend:t,legendConfig:n}=e;return t.gradientLength??n.gradientLength??Gy(e)},labelOverlap:({legend:e,legendConfig:t,scaleType:n})=>e.labelOverlap??t.labelOverlap??Vy(n),symbolType:({legend:e,markDef:t,channel:n,encoding:i})=>e.symbolType??Uy(t.type,n,i.shape,t.shape),title:({fieldOrDatumDef:e,config:t})=>wn(e,t,{allowDisabling:!0}),type:({legendType:e,scaleType:t,channel:n})=>{if(pn(n)&&Fe(t)){if(e==="gradient")return}else if(e==="symbol")return;return e},values:({fieldOrDatumDef:e,legend:t})=>jy(t,e)};function jy(e,t){const n=e.values;return $(n)?Oc(t,n):E(n)?n:void 0}function Uy(e,t,n,i){if(t!=="shape"){const r=lo(n)??i;if(r)return r}switch(e){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"}}function Wy(e){const{legend:t}=e;return V(t.type,By(e))}function By({channel:e,timeUnit:t,scaleType:n}){if(pn(e)){if(A(["quarter","month","day"],t))return"symbol";if(Fe(n))return"gradient"}return"symbol"}function Hy({legendConfig:e,legendType:t,orient:n,legend:i}){return i.direction??e[t?"gradientDirection":"symbolDirection"]??qy(n,t)}function qy(e,t){switch(e){case"top":case"bottom":return"horizontal";case"left":case"right":case"none":case void 0:return;default:return t==="gradient"?"horizontal":void 0}}function Gy({legendConfig:e,model:t,direction:n,orient:i,scaleType:r}){const{gradientHorizontalMaxLength:s,gradientHorizontalMinLength:o,gradientVerticalMaxLength:a,gradientVerticalMinLength:c}=e;return Fe(r)?n==="horizontal"?i==="top"||i==="bottom"?Cl(t,"width",o,s):o:Cl(t,"height",c,a):void 0}function Cl(e,t,n,i){const r=e.getSizeSignalRef(t).signal;return{signal:`clamp(${r}, ${n}, ${i})`}}function Vy(e){return A(["quantile","threshold","log","symlog"],e)?"greedy":void 0}function Nl(e){const t=q(e)?Xy(e):Zy(e);return e.component.legends=t,t}function Xy(e){const{encoding:t}=e,n={};for(const i of[le,...tu]){const r=X(t[i]);if(!r||!e.getScaleComponent(i))continue;if(i===fe&&S(r)&&r.type===yn)continue;n[i]=Qy(e,i)}return n}function Yy(e,t){const n=e.scaleName(t);if(e.mark==="trail"){if(t==="color")return{stroke:n};if(t==="size")return{strokeWidth:n}}return t==="color"?e.markDef.filled?{fill:n}:{stroke:n}:{[t]:n}}function Ky(e,t,n,i){switch(t){case"disable":return n!==void 0;case"values":return!!n?.values;case"title":if(t==="title"&&e===i?.title)return!0}return e===(n||{})[t]}function Qy(e,t){let n=e.legend(t);const{markDef:i,encoding:r,config:s}=e,o=s.legend,a=new Ry({},Yy(e,t));oy(e,t,a);const c=n!==void 0?!n:o.disable;if(a.set("disable",c,n!==void 0),c)return a;n=n||{};const u=e.getScaleComponent(t).get("type"),l=X(r[t]),f=S(l)?ne(l.timeUnit)?.unit:void 0,d=n.orient||s.legend.orient||"right",p=Wy({legend:n,channel:t,timeUnit:f,scaleType:u}),g=Hy({legend:n,legendType:p,orient:d,legendConfig:o}),m={legend:n,channel:t,model:e,markDef:i,encoding:r,fieldOrDatumDef:l,legendConfig:o,config:s,scaleType:u,orient:d,legendType:p,direction:g};for(const k of wl){if(p==="gradient"&&k.startsWith("symbol")||p==="symbol"&&k.startsWith("gradient"))continue;const P=k in kl?kl[k](m):n[k];if(P!==void 0){const Y=Ky(P,k,n,e.fieldDef(t));(Y||s.legend[k]===void 0)&&a.set(k,P,Y)}}const h=n?.encoding??{},y=a.get("selections"),v={},_={fieldOrDatumDef:l,model:e,channel:t,legendCmpt:a,legendType:p};for(const k of["labels","legend","title","symbols","gradient","entries"]){const P=xl(h[k]??{},e),Y=k in vl?vl[k](P,_):P;Y!==void 0&&!R(Y)&&(v[k]={...y?.length&&S(l)?{name:`${W(l.field)}_legend_${k}`}:{},...y?.length?{interactive:!!y}:{},update:Y})}return R(v)||a.set("encode",v,!!n?.encoding),a}function Zy(e){const{legends:t,resolve:n}=e.component;for(const i of e.children){Nl(i);for(const r of b(i.component.legends))n.legend[r]=uo(e.component.resolve,r),n.legend[r]==="shared"&&(t[r]=Fl(t[r],i.component.legends[r]),t[r]||(n.legend[r]="independent",delete t[r]))}for(const i of b(t))for(const r of e.children){if(!r.component.legends[i])continue;n.legend[i]==="shared"&&delete r.component.legends[i]}return t}function Fl(e,t){if(!e)return t.clone();const n=e.getWithExplicit("orient"),i=t.getWithExplicit("orient");if(n.explicit&&i.explicit&&n.value!==i.value)return;let r=!1;for(const s of wl){const o=Ct(e.getWithExplicit(s),t.getWithExplicit(s),s,"legend",(a,c)=>{switch(s){case"symbolType":return Jy(a,c);case"title":return Ca(a,c);case"type":return r=!0,be("symbol")}return tr(a,c,s,"legend")});e.setWithExplicit(s,o)}return r&&(e.implicit?.encode?.gradient&&yi(e.implicit,["encode","gradient"]),e.explicit?.encode?.gradient&&yi(e.explicit,["encode","gradient"])),e}function Jy(e,t){return t.value==="circle"?t:e}function eb(e,t,n,i){var r,s;e.encode??(e.encode={}),(r=e.encode)[t]??(r[t]={}),(s=e.encode[t]).update??(s.update={}),e.encode[t].update[n]=i}function Tl(e){const t=e.component.legends,n={};for(const r of b(t)){const s=e.getScaleComponent(r),o=M(s.get("domains"));if(n[o])for(const a of n[o]){const c=Fl(a,t[r]);c||n[o].push(t[r])}else n[o]=[t[r].clone()]}const i=ee(n).flat().map(r=>tb(r,e.config)).filter(r=>r!==void 0);return i}function tb(e,t){const{disable:n,labelExpr:i,selections:r,...s}=e.combine();if(n)return;if(t.aria===!1&&s.aria==null&&(s.aria=!1),s.encode?.symbols){const o=s.encode.symbols.update;o.fill&&o.fill.value!=="transparent"&&!o.stroke&&!s.stroke&&(o.stroke={value:"transparent"});for(const a of tu)s[a]&&delete o[a]}if(s.title||delete s.title,i!==void 0){let o=i;s.encode?.labels?.update&&E(s.encode.labels.update.text)&&(o=zt(i,"datum.label",s.encode.labels.update.text.signal)),eb(s,"labels","text",{signal:o})}return s}function nb(e){return zn(e)||Eo(e)?ib(e):Al(e)}function ib(e){return e.children.reduce((t,n)=>t.concat(n.assembleProjections()),Al(e))}function Al(e){const t=e.component.projection;if(!t||t.merged)return[];const n=t.combine(),{name:i}=n;if(t.data){const r={signal:`[${t.size.map(o=>o.signal).join(", ")}]`},s=t.data.reduce((o,a)=>{const c=E(a)?a.signal:`data('${e.lookupDataSource(a)}')`;return A(o,c)||o.push(c),o},[]);if(s.length<=0)throw new Error("Projection's fit didn't find any data sources");return[{name:i,size:r,fit:{signal:s.length>1?`[${s.join(", ")}]`:s[0]},...n}]}else return[{name:i,translate:{signal:"[width / 2, height / 2]"},...n}]}const rb=["type","clipAngle","clipExtent","center","rotate","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];class Ol extends lt{constructor(t,n,i,r){super({...n},{name:t});this.specifiedProjection=n,this.size=i,this.data=r,this.merged=!1}get isFit(){return!!this.data}}function Pl(e){e.component.projection=q(e)?sb(e):cb(e)}function sb(e){if(e.hasProjection){const t=pe(e.specifiedProjection),n=!(t&&(t.scale!=null||t.translate!=null)),i=n?[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]:void 0,r=n?ob(e):void 0,s=new Ol(e.projectionName(!0),{...pe(e.config.projection)??{},...t??{}},i,r);return s.get("type")||s.set("type","equalEarth",!1),s}return}function ob(e){const t=[],{encoding:n}=e;for(const i of[[Ce,ke],[we,Ne]])(X(n[i[0]])||X(n[i[1]]))&&t.push({signal:e.getName(`geojson_${t.length}`)});return e.channelHasField(fe)&&e.typedFieldDef(fe).type===yn&&t.push({signal:e.getName(`geojson_${t.length}`)}),t.length===0&&t.push(e.requestDataName(j.Main)),t}function ab(e,t){const n=Ar(rb,r=>!on(e.explicit,r)&&!on(t.explicit,r)?!0:!!(on(e.explicit,r)&&on(t.explicit,r)&&Ie(e.get(r),t.get(r)))),i=Ie(e.size,t.size);if(i){if(n)return e;if(Ie(e.explicit,{}))return t;if(Ie(t.explicit,{}))return e}return null}function cb(e){if(e.children.length===0)return;let t;for(const i of e.children)Pl(i);const n=Ar(e.children,i=>{const r=i.component.projection;if(r)if(t){const s=ab(t,r);return s&&(t=s),!!s}else return t=r,!0;else return!0});if(t&&n){const i=e.projectionName(!0),r=new Ol(i,t.specifiedProjection,t.size,C(t.data));for(const s of e.children){const o=s.component.projection;o&&(o.isFit&&r.data.push(...s.component.projection.data),s.renameProjection(o.get("name"),i),o.merged=!0)}return r}return}function ub(e,t,n,i){if(Qn(t,n)){const r=q(e)?e.axis(n)??e.legend(n)??{}:{},s=w(t,{expr:"datum"}),o=w(t,{expr:"datum",binSuffix:"end"});return{formulaAs:w(t,{binSuffix:"range",forAs:!0}),formula:Xn(s,o,r.format,r.formatType,i)}}return{}}function zl(e,t){return`${ha(e)}_${t}`}function lb(e,t){return{signal:e.getName(`${t}_bins`),extentSignal:e.getName(`${t}_extent`)}}function fo(e,t,n){const i=qi(n,void 0)??{},r=zl(i,t);return e.getName(`${r}_bins`)}function fb(e){return"as"in e}function Rl(e,t,n){let i,r;fb(e)?i=F(e.as)?[e.as,`${e.as}_end`]:[e.as[0],e.as[1]]:i=[w(e,{forAs:!0}),w(e,{binSuffix:"end",forAs:!0})];const s={...qi(t,void 0)},o=zl(s,e.field),{signal:a,extentSignal:c}=lb(n,o);if(ki(s.extent)){const l=s.extent;r=ol(n,l.param,l),delete s.extent}const u={bin:s,field:e.field,as:[i],...a?{signal:a}:{},...c?{extentSignal:c}:{},...r?{span:r}:{}};return{key:o,binComponent:u}}class Qe extends I{clone(){return new Qe(null,C(this.bins))}constructor(t,n){super(t);this.bins=n}static makeFromEncoding(t,n){const i=n.reduceFieldDef((r,s,o)=>{if(ae(s)&&D(s.bin)){const{key:a,binComponent:c}=Rl(s,s.bin,n);r[a]={...c,...r[a],...ub(n,s,o,n.config)}}return r},{});return R(i)?null:new Qe(t,i)}static makeFromTransform(t,n,i){const{key:r,binComponent:s}=Rl(n,n.bin,i);return new Qe(t,{[r]:s})}merge(t,n){for(const i of b(t.bins))i in this.bins?(n(t.bins[i].signal,this.bins[i].signal),this.bins[i].as=Le([...this.bins[i].as,...t.bins[i].as],O)):this.bins[i]=t.bins[i];for(const i of t.children)t.removeChild(i),i.parent=this;t.remove()}producedFields(){return new Set(ee(this.bins).map(t=>t.as).flat(2))}dependentFields(){return new Set(ee(this.bins).map(t=>t.field))}hash(){return`Bin ${O(this.bins)}`}assemble(){return ee(this.bins).flatMap(t=>{const n=[],[i,...r]=t.as,{extent:s,...o}=t.bin,a={type:"bin",field:xe(t.field),as:i,signal:t.signal,...ki(s)?{extent:null}:{extent:s},...t.span?{span:{signal:`span(${t.span})`}}:{},...o};!s&&t.extentSignal&&(n.push({type:"extent",field:xe(t.field),signal:t.extentSignal}),a.extent={signal:t.extentSignal}),n.push(a);for(const c of r)for(let u=0;u<2;u++)n.push({type:"formula",expr:w({field:i[u]},{expr:"datum"}),as:c[u]});return t.formula&&n.push({type:"formula",expr:t.formula,as:t.formulaAs}),n})}}function db(e,t,n,i){const r=q(i)?i.encoding[Ue(t)]:void 0;if(ae(n)&&q(i)&&Ec(n,r,i.markDef,i.config))e.add(w(n,{})),e.add(w(n,{suffix:"end"})),n.bin&&Qn(n,t)&&e.add(w(n,{binSuffix:"range"}));else if(sa(t)){const s=ra(t);e.add(i.getName(s))}else e.add(w(n));return Gt(n)&&cg(n.scale?.range)&&e.add(n.scale.range.field),e}function pb(e,t){for(const n of b(t)){const i=t[n];for(const r of b(i))n in e?e[n][r]=new Set([...e[n][r]??[],...i[r]]):e[n]={[r]:i[r]}}}class Pe extends I{clone(){return new Pe(null,new Set(this.dimensions),C(this.measures))}constructor(t,n,i){super(t);this.dimensions=n,this.measures=i}get groupBy(){return this.dimensions}static makeFromEncoding(t,n){let i=!1;n.forEachFieldDef(o=>{o.aggregate&&(i=!0)});const r={},s=new Set;return i?(n.forEachFieldDef((o,a)=>{const{aggregate:c,field:u}=o;if(c)if(c==="count")r["*"]??(r["*"]={}),r["*"].count=new Set([w(o,{forAs:!0})]);else{if(st(c)||vt(c)){const l=st(c)?"argmin":"argmax",f=c[l];r[f]??(r[f]={}),r[f][l]=new Set([w({op:l,field:f},{forAs:!0})])}else r[u]??(r[u]={}),r[u][c]=new Set([w(o,{forAs:!0})]);rt(a)&&n.scaleDomain(a)==="unaggregated"&&(r[u]??(r[u]={}),r[u].min=new Set([w({field:u,aggregate:"min"},{forAs:!0})]),r[u].max=new Set([w({field:u,aggregate:"max"},{forAs:!0})]))}else db(s,a,o,n)}),s.size+b(r).length===0?null:new Pe(t,s,r)):null}static makeFromTransform(t,n){const i=new Set,r={};for(const s of n.aggregate){const{op:o,field:a,as:c}=s;o&&(o==="count"?(r["*"]??(r["*"]={}),r["*"].count=new Set([c||w(s,{forAs:!0})])):(r[a]??(r[a]={}),r[a][o]=new Set([c||w(s,{forAs:!0})])))}for(const s of n.groupby??[])i.add(s);return i.size+b(r).length===0?null:new Pe(t,i,r)}merge(t){return Ko(this.dimensions,t.dimensions)?(pb(this.measures,t.measures),!0):(zp("different dimensions, cannot merge"),!1)}addDimensions(t){t.forEach(this.dimensions.add,this.dimensions)}dependentFields(){return new Set([...this.dimensions,...b(this.measures)])}producedFields(){const t=new Set;for(const n of b(this.measures))for(const i of b(this.measures[n])){const r=this.measures[n][i];r.size===0?t.add(`${i}_${n}`):r.forEach(t.add,t)}return t}hash(){return`Aggregate ${O({dimensions:this.dimensions,measures:this.measures})}`}assemble(){const t=[],n=[],i=[];for(const s of b(this.measures))for(const o of b(this.measures[s]))for(const a of this.measures[s][o])i.push(a),t.push(o),n.push(s==="*"?null:xe(s));const r={type:"aggregate",groupby:[...this.dimensions].map(xe),ops:t,fields:n,as:i};return r}}class On extends I{constructor(t,n,i,r){super(t);this.model=n,this.name=i,this.data=r;for(const s of ve){const o=n.facet[s];if(o){const{bin:a,sort:c}=o;this[s]={name:n.getName(`${s}_domain`),fields:[w(o),...D(a)?[w(o,{binSuffix:"end"})]:[]],...qe(c)?{sortField:c}:$(c)?{sortIndexField:Tn(o,s)}:{}}}}this.childModel=n.child}hash(){let t="Facet";for(const n of ve)this[n]&&(t+=` ${n.charAt(0)}:${O(this[n])}`);return t}get fields(){const t=[];for(const n of ve)this[n]?.fields&&t.push(...this[n].fields);return t}dependentFields(){const t=new Set(this.fields);for(const n of ve)this[n]&&(this[n].sortField&&t.add(this[n].sortField.field),this[n].sortIndexField&&t.add(this[n].sortIndexField));return t}producedFields(){return new Set}getSource(){return this.name}getChildIndependentFieldsWithStep(){const t={};for(const n of We){const i=this.childModel.component.scales[n];if(i&&!i.merged){const r=i.get("type"),s=i.get("range");if(Z(r)&&Et(s)){const o=dr(this.childModel,n),a=vo(o);a?t[n]=a:x(Vr(n))}}}return t}assembleRowColumnHeaderData(t,n,i){const r={row:"y",column:"x",facet:void 0}[t],s=[],o=[],a=[];r&&i&&i[r]&&(n?(s.push(`distinct_${i[r]}`),o.push("max")):(s.push(i[r]),o.push("distinct")),a.push(`distinct_${i[r]}`));const{sortField:c,sortIndexField:u}=this[t];if(c){const{op:l=Li,field:f}=c;s.push(f),o.push(l),a.push(w(c,{forAs:!0}))}else u&&(s.push(u),o.push("max"),a.push(u));return{name:this[t].name,source:n??this.data,transform:[{type:"aggregate",groupby:this[t].fields,...s.length?{fields:s,ops:o,as:a}:{}}]}}assembleFacetHeaderData(t){const{columns:n}=this.model.layout,{layoutHeaders:i}=this.model.component,r=[],s={};for(const c of so){for(const u of oo){const l=(i[c]&&i[c][u])??[];for(const f of l)if(f.axes?.length>0){s[c]=!0;break}}if(s[c]){const u=`length(data("${this.facet.name}"))`,l=c==="row"?n?{signal:`ceil(${u} / ${n})`}:1:n?{signal:`min(${u}, ${n})`}:{signal:u};r.push({name:`${this.facet.name}_${c}`,transform:[{type:"sequence",start:0,stop:l}]})}}const{row:o,column:a}=s;return(o||a)&&r.unshift(this.assembleRowColumnHeaderData("facet",null,t)),r}assemble(){const t=[];let n=null;const i=this.getChildIndependentFieldsWithStep(),{column:r,row:s,facet:o}=this;if(r&&s&&(i.x||i.y)){n=`cross_${this.column.name}_${this.row.name}`;const a=[].concat(i.x??[],i.y??[]),c=a.map(()=>"distinct");t.push({name:n,source:this.data,transform:[{type:"aggregate",groupby:this.fields,fields:a,ops:c}]})}for(const a of[Je,Ze])this[a]&&t.push(this.assembleRowColumnHeaderData(a,n,i));if(o){const a=this.assembleFacetHeaderData(i);a&&t.push(...a)}return t}}function Il(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function gb(e,t){const n=Rr(e);if(t==="number")return`toNumber(${n})`;if(t==="boolean")return`toBoolean(${n})`;if(t==="string")return`toString(${n})`;if(t==="date")return`toDate(${n})`;if(t==="flatten")return n;if(t.startsWith("date:")){const i=Il(t.slice(5,t.length));return`timeParse(${n},'${i}')`}else if(t.startsWith("utc:")){const i=Il(t.slice(4,t.length));return`utcParse(${n},'${i}')`}else return x(Ud(t)),null}function mb(e){const t={};return hi(e.filter,n=>{if(Ya(n)){let i=null;Jr(n)?i=he(n.equal):ts(n)?i=he(n.lte):es(n)?i=he(n.lt):ns(n)?i=he(n.gt):is(n)?i=he(n.gte):rs(n)?i=n.range[0]:ss(n)&&(i=(n.oneOf??n.in)[0]),i&&(jt(i)?t[n.field]="date":G(i)?t[n.field]="number":F(i)&&(t[n.field]="string")),n.timeUnit&&(t[n.field]="date")}}),t}function hb(e){const t={};function n(i){$n(i)?t[i.field]="date":i.type==="quantitative"&&xd(i.aggregate)?t[i.field]="number":fn(i.field)>1?i.field in t||(t[i.field]="flatten"):Gt(i)&&qe(i.sort)&&fn(i.sort.field)>1&&(i.sort.field in t||(t[i.sort.field]="flatten"))}if((q(e)||Re(e))&&e.forEachFieldDef((i,r)=>{if(ae(i))n(i);else{const s=Lt(r),o=e.fieldDef(s);n({...i,type:o.type})}}),q(e)){const{mark:i,markDef:r,encoding:s}=e;if(_t(i)&&!e.encoding.order){const o=r.orient==="horizontal"?"y":"x",a=s[o];S(a)&&a.type==="quantitative"&&!(a.field in t)&&(t[a.field]="number")}}return t}function yb(e){const t={};if(q(e)&&e.component.selection)for(const n of b(e.component.selection)){const i=e.component.selection[n];for(const r of i.project.items)!r.channel&&fn(r.field)>1&&(t[r.field]="flatten")}return t}class re extends I{clone(){return new re(null,C(this._parse))}constructor(t,n){super(t);this._parse=n}hash(){return`Parse ${O(this._parse)}`}static makeExplicit(t,n,i){let r={};const s=n.data;return!Nt(s)&&s?.format?.parse&&(r=s.format.parse),this.makeWithAncestors(t,r,{},i)}static makeWithAncestors(t,n,i,r){for(const a of b(i)){const c=r.getWithExplicit(a);c.value!==void 0&&(c.explicit||c.value===i[a]||c.value==="derived"||i[a]==="flatten"?delete i[a]:x(za(a,i[a],c.value)))}for(const a of b(n)){const c=r.get(a);c!==void 0&&(c===n[a]?delete n[a]:x(za(a,n[a],c)))}const s=new lt(n,i);r.copyAll(s);const o={};for(const a of b(s.combine())){const c=s.get(a);c!==null&&(o[a]=c)}return b(o).length===0||r.parseNothing?null:new re(t,o)}get parse(){return this._parse}merge(t){this._parse={...this._parse,...t.parse},t.remove()}assembleFormatParse(){const t={};for(const n of b(this._parse)){const i=this._parse[n];fn(n)===1&&(t[n]=i)}return t}producedFields(){return new Set(b(this._parse))}dependentFields(){return new Set(b(this._parse))}assembleTransforms(t=!1){return b(this._parse).filter(n=>t?fn(n)>1:!0).map(n=>{const i=gb(n,this._parse[n]);if(!i)return null;const r={type:"formula",expr:i,as:Ir(n)};return r}).filter(n=>n!==null)}}class At extends I{clone(){return new At(null)}constructor(t){super(t)}dependentFields(){return new Set}producedFields(){return new Set([Oe])}hash(){return"Identifier"}assemble(){return{type:"identifier",as:Oe}}}class si extends I{clone(){return new si(null,this.params)}constructor(t,n){super(t);this.params=n}dependentFields(){return new Set}producedFields(){return}hash(){return`Graticule ${O(this.params)}`}assemble(){return{type:"graticule",...this.params===!0?{}:this.params}}}class oi extends I{clone(){return new oi(null,this.params)}constructor(t,n){super(t);this.params=n}dependentFields(){return new Set}producedFields(){return new Set([this.params.as??"data"])}hash(){return`Hash ${O(this.params)}`}assemble(){return{type:"sequence",...this.params}}}class Qt extends I{constructor(t){super(null);t??(t={name:"source"});let n;if(Nt(t)||(n=t.format?{...ue(t.format,["parse"])}:{}),Jn(t))this._data={values:t.values};else if(_n(t)){if(this._data={url:t.url},!n.type){let i=/(?:\.([^.]+))?$/.exec(t.url)[1];A(["json","csv","tsv","dsv","topojson"],i)||(i="json"),n.type=i}}else Au(t)?this._data={values:[{type:"Sphere"}]}:(Fu(t)||Nt(t))&&(this._data={});this._generator=Nt(t),t.name&&(this._name=t.name),n&&!R(n)&&(this._data.format=n)}dependentFields(){return new Set}producedFields(){return}get data(){return this._data}hasName(){return!!this._name}get isGenerator(){return this._generator}get dataName(){return this._name}set dataName(t){this._name=t}set parent(t){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:[]}}}var Ll=function(e,t,n,i,r){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(e,n):r?r.value=n:t.set(e,n),n},bb=function(e,t,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(e):i?i.value:t.get(e)},ai;function po(e){return e instanceof Qt||e instanceof si||e instanceof oi}class go{constructor(){ai.set(this,void 0),Ll(this,ai,!1,"f")}setModified(){Ll(this,ai,!0,"f")}get modifiedFlag(){return bb(this,ai,"f")}}ai=new WeakMap;class Zt extends go{getNodeDepths(t,n,i){i.set(t,n);for(const r of t.children)this.getNodeDepths(r,n+1,i);return i}optimize(t){const n=this.getNodeDepths(t,0,new Map),i=[...n.entries()].sort((r,s)=>s[1]-r[1]);for(const r of i)this.run(r[0]);return this.modifiedFlag}}class mo extends go{optimize(t){this.run(t);for(const n of t.children)this.optimize(n);return this.modifiedFlag}}class xb extends mo{mergeNodes(t,n){const i=n.shift();for(const r of n)t.removeChild(r),r.parent=i,r.remove()}run(t){const n=t.children.map(r=>r.hash()),i={};for(let r=0;r1&&(this.setModified(),this.mergeNodes(t,i[r]))}}class Sb extends mo{constructor(t){super();this.requiresSelectionId=t&&eo(t)}run(t){t instanceof At&&(this.requiresSelectionId&&(po(t.parent)||t.parent instanceof Pe||t.parent instanceof re)||(this.setModified(),t.remove()))}}class wb extends go{optimize(t){return this.run(t,new Set),this.modifiedFlag}run(t,n){let i=new Set;t instanceof Ke&&(i=t.producedFields(),Or(i,n)&&(this.setModified(),t.removeFormulas(n),t.producedFields.length===0&&t.remove()));for(const r of t.children)this.run(r,new Set([...n,...i]))}}class vb extends mo{constructor(){super()}run(t){t instanceof ce&&!t.isRequired()&&(this.setModified(),t.remove())}}class $b extends Zt{run(t){if(po(t))return;if(t.numChildren()>1)return;for(const n of t.children)if(n instanceof re)if(t instanceof re)this.setModified(),t.merge(n);else{if(zr(t.producedFields(),n.dependentFields()))continue;this.setModified(),n.swapWithParent()}return}}class Eb extends Zt{run(t){const n=[...t.children],i=t.children.filter(r=>r instanceof re);if(t.numChildren()>1&&i.length>=1){const r={},s=new Set;for(const o of i){const a=o.parse;for(const c of b(a))c in r?r[c]!==a[c]&&s.add(c):r[c]=a[c]}for(const o of s)delete r[o];if(!R(r)){this.setModified();const o=new re(t,r);for(const a of n){if(a instanceof re)for(const c of b(r))delete a.parse[c];t.removeChild(a),a.parent=o,a instanceof re&&b(a.parse).length===0&&a.remove()}}}}}class _b extends Zt{run(t){t instanceof ce||t.numChildren()>0||t instanceof On||(t instanceof Qt||(this.setModified(),t.remove()))}}class kb extends Zt{run(t){const n=t.children.filter(r=>r instanceof Ke),i=n.pop();for(const r of n)this.setModified(),i.merge(r)}}class Cb extends Zt{run(t){const n=t.children.filter(r=>r instanceof Pe),i={};for(const r of n){const s=O(r.groupBy);s in i||(i[s]=[]),i[s].push(r)}for(const r of b(i)){const s=i[r];if(s.length>1){const o=s.pop();for(const a of s)o.merge(a)&&(t.removeChild(a),a.parent=o,a.remove(),this.setModified())}}}}class Nb extends Zt{constructor(t){super();this.model=t}run(t){const n=!(po(t)||t instanceof Nn||t instanceof re||t instanceof At),i=[],r=[];for(const s of t.children)s instanceof Qe&&(n&&!zr(t.producedFields(),s.dependentFields())?i.push(s):r.push(s));if(i.length>0){const s=i.pop();for(const o of i)s.merge(o,this.model.renameSignal.bind(this.model));this.setModified(),t instanceof Qe?t.merge(s,this.model.renameSignal.bind(this.model)):s.swapWithParent()}if(r.length>1){const s=r.pop();for(const o of r)s.merge(o,this.model.renameSignal.bind(this.model));this.setModified()}}}class Fb extends Zt{run(t){const n=[...t.children],i=Pt(n,o=>o instanceof ce);if(!i||t.numChildren()<=1)return;const r=[];let s;for(const o of n)if(o instanceof ce){let a=o;for(;a.numChildren()===1;){const[c]=a.children;if(c instanceof ce)a=c;else break}r.push(...a.children),s?(t.removeChild(o),o.parent=s.parent,s.parent.removeChild(s),s.parent=a,this.setModified()):s=a}else r.push(o);if(r.length){this.setModified();for(const o of r)o.parent.removeChild(o),o.parent=s}}}class Jt extends I{clone(){return new Jt(null,C(this.transform))}constructor(t,n){super(t);this.transform=n}addDimensions(t){this.transform.groupby=Le(this.transform.groupby.concat(t),n=>n)}dependentFields(){const t=new Set;return this.transform.groupby&&this.transform.groupby.forEach(t.add,t),this.transform.joinaggregate.map(n=>n.field).filter(n=>n!==void 0).forEach(t.add,t),t}producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName))}getDefaultName(t){return t.as??w(t)}hash(){return`JoinAggregateTransform ${O(this.transform)}`}assemble(){const t=[],n=[],i=[];for(const s of this.transform.joinaggregate)n.push(s.op),i.push(this.getDefaultName(s)),t.push(s.field===void 0?null:s.field);const r=this.transform.groupby;return{type:"joinaggregate",as:i,ops:n,fields:t,...r!==void 0?{groupby:r}:{}}}}function Tb(e){return e.stack.stackBy.reduce((t,n)=>{const i=n.fieldDef,r=w(i);return r&&t.push(r),t},[])}function Ab(e){return $(e)&&e.every(t=>F(t))&&e.length>1}class dt extends I{clone(){return new dt(null,C(this._stack))}constructor(t,n){super(t);this._stack=n}static makeFromTransform(t,n){const{stack:i,groupby:r,as:s,offset:o="zero"}=n,a=[],c=[];if(n.sort!==void 0)for(const f of n.sort)a.push(f.field),c.push(V(f.order,"ascending"));const u={field:a,order:c};let l;return Ab(s)?l=s:F(s)?l=[s,`${s}_end`]:l=[`${n.stack}_start`,`${n.stack}_end`],new dt(t,{dimensionFieldDefs:[],stackField:i,groupby:r,offset:o,sort:u,facetby:[],as:l})}static makeFromEncoding(t,n){const i=n.stack,{encoding:r}=n;if(!i)return null;const{groupbyChannels:s,fieldChannel:o,offset:a,impute:c}=i,u=s.map(p=>{const g=r[p];return Ve(g)}).filter(p=>!!p),l=Tb(n),f=n.encoding.order;let d;return $(f)||S(f)?d=Ea(f):d=l.reduce((p,g)=>(p.field.push(g),p.order.push(o==="y"?"descending":"ascending"),p),{field:[],order:[]}),new dt(t,{dimensionFieldDefs:u,stackField:n.vgField(o),facetby:[],stackby:l,sort:d,offset:a,impute:c,as:[n.vgField(o,{suffix:"start",forAs:!0}),n.vgField(o,{suffix:"end",forAs:!0})]})}get stack(){return this._stack}addDimensions(t){this._stack.facetby.push(...t)}dependentFields(){const t=new Set;return t.add(this._stack.stackField),this.getGroupbyFields().forEach(t.add,t),this._stack.facetby.forEach(t.add,t),this._stack.sort.field.forEach(t.add,t),t}producedFields(){return new Set(this._stack.as)}hash(){return`Stack ${O(this._stack)}`}getGroupbyFields(){const{dimensionFieldDefs:t,impute:n,groupby:i}=this._stack;return t.length>0?t.map(r=>r.bin?n?[w(r,{binSuffix:"mid"})]:[w(r,{}),w(r,{binSuffix:"end"})]:[w(r)]).flat():i??[]}assemble(){const t=[],{facetby:n,dimensionFieldDefs:i,stackField:r,stackby:s,sort:o,offset:a,impute:c,as:u}=this._stack;if(c)for(const l of i){const{bandPosition:f=.5,bin:d}=l;if(d){const p=w(l,{expr:"datum"}),g=w(l,{expr:"datum",binSuffix:"end"});t.push({type:"formula",expr:`${f}*${p}+${1-f}*${g}`,as:w(l,{binSuffix:"mid",forAs:!0})})}t.push({type:"impute",field:r,groupby:[...s,...n],key:w(l,{binSuffix:"mid"}),method:"value",value:0})}return t.push({type:"stack",groupby:[...this.getGroupbyFields(),...n],field:r,sort:o,as:u,offset:a}),t}}class Pn extends I{clone(){return new Pn(null,C(this.transform))}constructor(t,n){super(t);this.transform=n}addDimensions(t){this.transform.groupby=Le(this.transform.groupby.concat(t),n=>n)}dependentFields(){const t=new Set;return(this.transform.groupby??[]).forEach(t.add,t),(this.transform.sort??[]).forEach(n=>t.add(n.field)),this.transform.window.map(n=>n.field).filter(n=>n!==void 0).forEach(t.add,t),t}producedFields(){return new Set(this.transform.window.map(this.getDefaultName))}getDefaultName(t){return t.as??w(t)}hash(){return`WindowTransform ${O(this.transform)}`}assemble(){const t=[],n=[],i=[],r=[];for(const f of this.transform.window)n.push(f.op),i.push(this.getDefaultName(f)),r.push(f.param===void 0?null:f.param),t.push(f.field===void 0?null:f.field);const s=this.transform.frame,o=this.transform.groupby;if(s&&s[0]===null&&s[1]===null&&n.every(f=>Hr(f)))return{type:"joinaggregate",as:i,ops:n,fields:t,...o!==void 0?{groupby:o}:{}};const a=[],c=[];if(this.transform.sort!==void 0)for(const f of this.transform.sort)a.push(f.field),c.push(f.order??"ascending");const u={field:a,order:c},l=this.transform.ignorePeers;return{type:"window",params:r,as:i,ops:n,fields:t,sort:u,...l!==void 0?{ignorePeers:l}:{},...o!==void 0?{groupby:o}:{},...s!==void 0?{frame:s}:{}}}}function Ob(e){function t(n){if(!(n instanceof On)){const i=n.clone();if(i instanceof ce){const r=yo+i.getSource();i.setSource(r),e.model.component.data.outputNodes[r]=i}else(i instanceof Pe||i instanceof dt||i instanceof Pn||i instanceof Jt)&&i.addDimensions(e.fields);for(const r of n.children.flatMap(t))r.parent=i;return[i]}return n.children.flatMap(t)}return t}function ho(e){if(e instanceof On)if(e.numChildren()===1&&!(e.children[0]instanceof ce)){const t=e.children[0];(t instanceof Pe||t instanceof dt||t instanceof Pn||t instanceof Jt)&&t.addDimensions(e.fields),t.swapWithParent(),ho(e)}else{const t=e.model.component.data.main;Ml(t);const n=Ob(e),i=e.children.map(n).flat();for(const r of i)r.parent=t}else e.children.map(ho)}function Ml(e){if(e instanceof ce&&e.type===j.Main&&e.numChildren()===1){const t=e.children[0];t instanceof On||(t.swapWithParent(),Ml(e))}}const yo="scale_",fr=5;function bo(e){for(const t of e){for(const n of t.children)if(n.parent!==t)return!1;if(!bo(t.children))return!1}return!0}function ze(e,t){let n=!1;for(const i of t)n=e.optimize(i)||n;return n}function Dl(e,t,n){let i=e.sources,r=!1;return r=ze(new vb,i)||r,r=ze(new Sb(t),i)||r,i=i.filter(s=>s.numChildren()>0),r=ze(new _b,i)||r,i=i.filter(s=>s.numChildren()>0),n||(r=ze(new $b,i)||r,r=ze(new Nb(t),i)||r,r=ze(new wb,i)||r,r=ze(new Eb,i)||r,r=ze(new Cb,i)||r,r=ze(new kb,i)||r,r=ze(new xb,i)||r,r=ze(new Fb,i)||r),e.sources=i,r}function Pb(e,t){bo(e.sources);let n=0,i=0;for(let r=0;rt(n))}}function jl(e){q(e)?zb(e):Rb(e)}function zb(e){const t=e.component.scales;for(const n of b(t)){const i=Lb(e,n),r=t[n];if(r.setWithExplicit("domains",i),Db(e,n),e.component.data.isFaceted){let s=e;for(;!Re(s)&&s.parent;)s=s.parent;const o=s.component.resolve.scale[n];if(o==="shared")for(const a of i.value)ot(a)&&(a.data=yo+a.data.replace(yo,""))}}}function Rb(e){for(const n of e.children)jl(n);const t=e.component.scales;for(const n of b(t)){let i,r=null;for(const s of e.children){const o=s.component.scales[n];if(o){i===void 0?i=o.getWithExplicit("domains"):i=Ct(i,o.getWithExplicit("domains"),"domains","scale",wo);const a=o.get("selectionExtent");r&&a&&r.param!==a.param&&x(Ld),r=a}}t[n].setWithExplicit("domains",i),r&&t[n].set("selectionExtent",r,!0)}}function Ib(e,t,n,i){if(e==="unaggregated"){const{valid:r,reason:s}=Ul(t,n);if(!r){x(s);return}}else if(e===void 0&&i.useUnaggregatedDomain){const{valid:r}=Ul(t,n);if(r)return"unaggregated"}return e}function Lb(e,t){const n=e.getScaleComponent(t).get("type"),{encoding:i}=e,r=Ib(e.scaleDomain(t),e.typedFieldDef(t),n,e.config.scale);return r!==e.scaleDomain(t)&&(e.specifiedScales[t]={...e.specifiedScales[t],domain:r}),t==="x"&&X(i.x2)?X(i.x)?Ct(Ot(n,r,e,"x"),Ot(n,r,e,"x2"),"domain","scale",wo):Ot(n,r,e,"x2"):t==="y"&&X(i.y2)?X(i.y)?Ct(Ot(n,r,e,"y"),Ot(n,r,e,"y2"),"domain","scale",wo):Ot(n,r,e,"y2"):Ot(n,r,e,t)}function Mb(e,t,n){return e.map(i=>{const r=Gi(i,{timeUnit:n,type:t});return{signal:`{data: ${r}}`}})}function xo(e,t,n){const i=ne(n)?.unit;return t==="temporal"||i?Mb(e,t,i):[e]}function Ot(e,t,n,i){const{encoding:r}=n,s=X(r[i]),{type:o}=s,a=s.timeUnit;if(ag(t)){const f=Ot(e,void 0,n,i),d=xo(t.unionWith,o,a);return Ye([...d,...f.value])}else{if(E(t))return Ye([t]);if(t&&t!=="unaggregated"&&!ic(t))return Ye(xo(t,o,a))}const c=n.stack;if(c&&i===c.fieldChannel){if(c.offset==="normalize")return be([[0,1]]);const f=n.requestDataName(j.Main);return be([{data:f,field:n.vgField(i,{suffix:"start"})},{data:f,field:n.vgField(i,{suffix:"end"})}])}const u=rt(i)&&S(s)?jb(n,i,e):void 0;if(Ge(s)){const f=xo([s.datum],o,a);return be(f)}const l=s;if(t==="unaggregated"){const f=n.requestDataName(j.Main),{field:d}=s;return be([{data:f,field:w({field:d,aggregate:"min"})},{data:f,field:w({field:d,aggregate:"max"})}])}else if(D(l.bin)){if(Z(e))return e==="bin-ordinal"?be([]):be([{data:Mn(u)?n.requestDataName(j.Main):n.requestDataName(j.Raw),field:n.vgField(i,Qn(l,i)?{binSuffix:"range"}:{}),sort:u===!0||!L(u)?{field:n.vgField(i,{}),op:"min"}:u}]);{const{bin:f}=l;if(D(f)){const d=fo(n,l.field,f);return be([new me(()=>{const p=n.getSignalName(d);return`[${p}.start, ${p}.stop]`})])}else return be([{data:n.requestDataName(j.Main),field:n.vgField(i,{})}])}}else if(l.timeUnit&&A(["time","utc"],e)&&Ec(l,q(n)?n.encoding[Ue(i)]:void 0,n.markDef,n.config)){const f=n.requestDataName(j.Main);return be([{data:f,field:n.vgField(i)},{data:f,field:n.vgField(i,{suffix:"end"})}])}else return be(u?[{data:Mn(u)?n.requestDataName(j.Main):n.requestDataName(j.Raw),field:n.vgField(i),sort:u}]:[{data:n.requestDataName(j.Main),field:n.vgField(i)}])}function So(e,t){const{op:n,field:i,order:r}=e;return{op:n??(t?"sum":Li),...i?{field:xe(i)}:{},...r?{order:r}:{}}}function Db(e,t){const n=e.component.scales[t],i=e.specifiedScales[t].domain,r=e.fieldDef(t)?.bin,s=ic(i)&&i,o=Mt(r)&&ki(r.extent)&&r.extent;(s||o)&&n.set("selectionExtent",s??o,!0)}function jb(e,t,n){if(!Z(n))return;const i=e.fieldDef(t),r=i.sort;if(Sc(r))return{op:"min",field:Tn(i,t),order:"ascending"};const{stack:s}=e,o=s?new Set([...s.groupbyFields,...s.stackBy.map(a=>a.fieldDef.field)]):void 0;if(qe(r)){const a=s&&!o.has(r.field);return So(r,a)}else if(xc(r)){const{encoding:a,order:c}=r,u=e.fieldDef(a),{aggregate:l,field:f}=u,d=s&&!o.has(f);if(st(l)||vt(l))return So({field:w(u),order:c},d);if(Hr(l)||!l)return So({op:l,field:f,order:c},d)}else{if(r==="descending")return{op:"min",field:e.vgField(t),order:"descending"};if(A(["ascending",void 0],r))return!0}return}function Ul(e,t){const{aggregate:n,type:i}=e;return n?F(n)&&!wd.has(n)?{valid:!1,reason:fp(n)}:i==="quantitative"&&t==="log"?{valid:!1,reason:dp(e)}:{valid:!0}:{valid:!1,reason:lp(e)}}function wo(e,t,n,i){return e.explicit&&t.explicit&&x(yp(n,i,e.value,t.value)),{explicit:e.explicit,value:[...e.value,...t.value]}}function Ub(e){const t=Le(e.map(o=>{if(ot(o)){const{sort:a,...c}=o;return c}return o}),O),n=Le(e.map(o=>{if(ot(o)){const a=o.sort;return a!==void 0&&!Mn(a)&&("op"in a&&a.op==="count"&&delete a.field,a.order==="ascending"&&delete a.order),a}return}).filter(o=>o!==void 0),O);if(t.length===0)return;if(t.length===1){const o=e[0];if(ot(o)&&n.length>0){let a=n[0];if(n.length>1){x(ja);const c=n.filter(u=>L(u)&&"op"in u&&u.op!=="min");n.every(u=>L(u)&&"op"in u)&&c.length===1?a=c[0]:a=!0}else if(L(a)&&"field"in a){const c=a.field;o.field===c&&(a=a.order?{order:a.order}:!0)}return{...o,sort:a}}return o}const i=Le(n.map(o=>Mn(o)||!("op"in o)||F(o.op)&&o.op in yd?o:(x(xp(o)),!0)),O);let r;i.length===1?r=i[0]:i.length>1&&(x(ja),r=!0);const s=Le(e.map(o=>ot(o)?o.data:null),o=>o);if(s.length===1&&s[0]!==null){const o={data:s[0],fields:t.map(a=>a.field),...r?{sort:r}:{}};return o}return{fields:t,...r?{sort:r}:{}}}function vo(e){if(ot(e)&&F(e.field))return e.field;if(vd(e)){let t;for(const n of e.fields)if(ot(n)&&F(n.field)){if(!t)t=n.field;else if(t!==n.field)return x(Sp),t}return x(wp),t}else if($d(e)){x(vp);const t=e.fields[0];return F(t)?t:void 0}return}function dr(e,t){const n=e.component.scales[t],i=n.get("domains").map(r=>(ot(r)&&(r.data=e.lookupDataSource(r.data)),r));return Ub(i)}function Wl(e){return zn(e)||Eo(e)?e.children.reduce((t,n)=>t.concat(Wl(n)),Bl(e)):Bl(e)}function Bl(e){return b(e.component.scales).reduce((t,n)=>{const i=e.component.scales[n];if(i.merged)return t;const r=i.combine(),{name:s,type:o,selectionExtent:a,domains:c,range:u,reverse:l,...f}=r,d=Wb(r.range,s,n,e),p=dr(e,n),g=a?Ih(e,a,i,p):null;return t.push({name:s,type:o,...p?{domain:p}:{},...g?{domainRaw:g}:{},range:d,...l!==void 0?{reverse:l}:{},...f}),t},[])}function Wb(e,t,n,i){if(Q(n)){if(Et(e))return{step:{signal:`${t}_step`}}}else if(L(e)&&ot(e))return{...e,data:i.lookupDataSource(e.data)};return e}class Hl extends lt{constructor(t,n){super({},{name:t});this.merged=!1,this.setWithExplicit("type",n)}domainDefinitelyIncludesZero(){return this.get("zero")!==!1?!0:Pt(this.get("domains"),t=>$(t)&&t.length===2&&t[0]<=0&&t[1]>=0)}}const Bb=["range","scheme"];function Hb(e){const t=e.component.scales;for(const n of _i){const i=t[n];if(!i)continue;const r=qb(n,e);i.setWithExplicit("range",r)}}function ql(e,t){const n=e.fieldDef(t);if(n?.bin){const{bin:i,field:r}=n,s=de(t),o=e.getName(s);if(L(i)&&i.binned&&i.step!==void 0)return new me(()=>{const a=e.scaleName(t),c=`(domain("${a}")[1] - domain("${a}")[0]) / ${i.step}`;return`${e.getSignalName(o)} / (${c})`});if(D(i)){const a=fo(e,r,i);return new me(()=>{const c=e.getSignalName(a),u=`(${c}.stop - ${c}.start) / ${c}.step`;return`${e.getSignalName(o)} / (${u})`})}}return}function qb(e,t){const n=t.specifiedScales[e],{size:i}=t,r=t.getScaleComponent(e),s=r.get("type");for(const f of Bb)if(n[f]!==void 0){const d=ls(s,f),p=rc(e,f);if(!d)x(Ma(s,f,e));else if(p)x(p);else switch(f){case"range":{const g=n.range;if($(g)){if(Q(e))return Ye(g.map(m=>{if(m==="width"||m==="height"){const h=t.getName(m),y=t.getSignalName.bind(t);return me.fromName(y,h)}return m}))}else if(L(g))return Ye({data:t.requestDataName(j.Main),field:g.field,sort:{op:"min",field:t.vgField(e)}});return Ye(g)}case"scheme":return Ye(Gb(n[f]))}}const o=e===B||e==="xOffset"?"width":"height",a=i[o];if(Xe(a)){if(Q(e))if(Z(s)){const f=Gl(a,t,e);if(f)return Ye({step:f})}else x(Da(o));else if(gn(e)){const f=e===ht?"x":"y",d=t.getScaleComponent(f),p=d.get("type");if(p==="band"){const g=Vl(a,s);if(g)return Ye(g)}}}const{rangeMin:c,rangeMax:u}=n,l=Vb(e,t);return(c!==void 0||u!==void 0)&&ls(s,"rangeMin")&&$(l)&&l.length===2?Ye([c??l[0],u??l[1]]):be(l)}function Gb(e){return og(e)?{scheme:e.name,...ue(e,["name"])}:{scheme:e}}function Vb(e,t){const{size:n,config:i,mark:r,encoding:s}=t,o=t.getSignalName.bind(t),{type:a}=X(s[e]),c=t.getScaleComponent(e),u=c.get("type"),{domain:l,domainMid:f}=t.specifiedScales[e];switch(e){case B:case K:{if(A(["point","band"],u)){const g=Xl(e,n,i.view);if(Xe(g)){const m=Gl(g,t,e);return{step:m}}}const d=de(e),p=t.getName(d);return e===K&&ye(u)?[me.fromName(o,p),0]:[0,me.fromName(o,p)]}case ht:case dn:return Xb(e,t,u);case nt:{const d=t.component.scales[e].get("zero"),p=Yl(r,d,i),g=Qb(r,n,t,i);return bn(u)?Kb(p,g,Yb(u,i,l,e)):[p,g]}case Se:return[0,Math.PI*2];case Rt:return[0,360];case _e:return[0,new me(()=>{const d=t.getSignalName("width"),p=t.getSignalName("height");return`min(${d},${p})/2`})];case xt:return[i.scale.minStrokeWidth,i.scale.maxStrokeWidth];case St:return[[1,0],[4,2],[2,1],[1,1],[1,2,4,2]];case fe:return"symbol";case le:case De:case je:return u==="ordinal"?a==="nominal"?"category":"ordinal":f!==void 0?"diverging":r==="rect"||r==="geoshape"?"heatmap":"ramp";case it:case yt:case bt:return[i.scale.minOpacity,i.scale.maxOpacity]}}function Gl(e,t,n){const{encoding:i}=t,r=t.getScaleComponent(n),s=ua(n),o=i[s],a=iu({step:e,offsetIsDiscrete:N(o)&&Qa(o.type)});if(a==="offset"&&Mc(i,s)){const c=t.getScaleComponent(s),u=t.scaleName(s);let l=`domain('${u}').length`;if(c.get("type")==="band"){const d=c.get("paddingInner")??c.get("padding")??0,p=c.get("paddingOuter")??c.get("padding")??0;l=`bandspace(${l}, ${d}, ${p})`}const f=r.get("paddingInner")??r.get("padding");return{signal:`${e.step} * ${l} / (1-${Cd(f)})`}}else return e.step}function Vl(e,t){const n=iu({step:e,offsetIsDiscrete:Z(t)});return n==="offset"?{step:e.step}:void 0}function Xb(e,t,n){const i=e===ht?"x":"y",r=t.getScaleComponent(i),s=r.get("type"),o=t.scaleName(i);if(s==="band"){const a=Xl(i,t.size,t.config.view);if(Xe(a)){const c=Vl(a,n);if(c)return c}return[0,{signal:`bandwidth('${o}')`}]}else return Xo(`Cannot use ${e} scale if ${i} scale is not discrete.`)}function Xl(e,t,n){const i=e===B?"width":"height",r=t[i];return r||Ji(n,i)}function Yb(e,t,n,i){switch(e){case"quantile":return t.scale.quantileCount;case"quantize":return t.scale.quantizeCount;case"threshold":return n!==void 0&&$(n)?n.length+1:(x(Ap(i)),3)}}function Kb(e,t,n){const i=()=>{const r=at(t),s=at(e),o=`(${r} - ${s}) / (${n} - 1)`;return`sequence(${s}, ${r} + ${o}, ${o})`};return E(t)?new me(i):{signal:i()}}function Yl(e,t,n){if(t)return E(t)?{signal:`${t.signal} ? 0 : ${Yl(e,!1,n)}`}:0;switch(e){case"bar":case"tick":return n.scale.minBandSize;case"line":case"trail":case"rule":return n.scale.minStrokeWidth;case"text":return n.scale.minFontSize;case"point":case"square":case"circle":return n.scale.minSize}throw new Error(Ni("size",e))}const Kl=.95;function Qb(e,t,n,i){const r={x:ql(n,"x"),y:ql(n,"y")};switch(e){case"bar":case"tick":{if(i.scale.maxBandSize!==void 0)return i.scale.maxBandSize;const s=Ql(t,r,i.view);return G(s)?s-1:new me(()=>`${s.signal} - 1`)}case"line":case"trail":case"rule":return i.scale.maxStrokeWidth;case"text":return i.scale.maxFontSize;case"point":case"square":case"circle":{if(i.scale.maxSize)return i.scale.maxSize;const s=Ql(t,r,i.view);return G(s)?Math.pow(Kl*s,2):new me(()=>`pow(${Kl} * ${s.signal}, 2)`)}}throw new Error(Ni("size",e))}function Ql(e,t,n){const i=Xe(e.width)?e.width.step:Zi(n,"width"),r=Xe(e.height)?e.height.step:Zi(n,"height");return t.x||t.y?new me(()=>{const s=[t.x?t.x.signal:i,t.y?t.y.signal:r];return`min(${s.join(", ")})`}):Math.min(i,r)}function Zl(e,t){q(e)?Zb(e,t):tf(e,t)}function Zb(e,t){const n=e.component.scales,{config:i,encoding:r,markDef:s,specifiedScales:o}=e;for(const a of b(n)){const c=o[a],u=n[a],l=e.getScaleComponent(a),f=X(r[a]),d=c[t],p=l.get("type"),g=l.get("padding"),m=l.get("paddingInner"),h=ls(p,t),y=rc(a,t);if(d!==void 0&&(h?y&&x(y):x(Ma(p,t,a))),h&&y===void 0)if(d!==void 0){const v=f.timeUnit,_=f.type;switch(t){case"domainMax":case"domainMin":jt(c[t])||_==="temporal"||v?u.set(t,{signal:Gi(c[t],{type:_,timeUnit:v})},!0):u.set(t,c[t],!0);break;default:u.copyKeyFromObject(t,c)}}else{const v=t in Jl?Jl[t]({model:e,channel:a,fieldOrDatumDef:f,scaleType:p,scalePadding:g,scalePaddingInner:m,domain:c.domain,domainMin:c.domainMin,domainMax:c.domainMax,markDef:s,config:i,hasNestedOffsetScale:Es(r,a),hasSecondaryRangeChannel:!!r[Ue(a)]}):i.scale[t];v!==void 0&&u.set(t,v,!1)}}}const Jl={bins:({model:e,fieldOrDatumDef:t})=>S(t)?Jb(e,t):void 0,interpolate:({channel:e,fieldOrDatumDef:t})=>ex(e,t.type),nice:({scaleType:e,channel:t,domain:n,domainMin:i,domainMax:r,fieldOrDatumDef:s})=>tx(e,t,n,i,r,s),padding:({channel:e,scaleType:t,fieldOrDatumDef:n,markDef:i,config:r})=>nx(e,t,r.scale,n,i,r.bar),paddingInner:({scalePadding:e,channel:t,markDef:n,scaleType:i,config:r,hasNestedOffsetScale:s})=>ix(e,t,n.type,i,r.scale,s),paddingOuter:({scalePadding:e,channel:t,scaleType:n,scalePaddingInner:i,config:r,hasNestedOffsetScale:s})=>rx(e,t,n,i,r.scale,s),reverse:({fieldOrDatumDef:e,scaleType:t,channel:n,config:i})=>{const r=S(e)?e.sort:void 0;return sx(t,r,n,i.scale)},zero:({channel:e,fieldOrDatumDef:t,domain:n,markDef:i,scaleType:r,config:s,hasSecondaryRangeChannel:o})=>ox(e,t,n,i,r,s.scale,o)};function ef(e){q(e)?Hb(e):tf(e,"range")}function tf(e,t){const n=e.component.scales;for(const i of e.children)t==="range"?ef(i):Zl(i,t);for(const i of b(n)){let r;for(const s of e.children){const o=s.component.scales[i];if(o){const a=o.getWithExplicit(t);r=Ct(r,a,t,"scale",Nu((c,u)=>{switch(t){case"range":return c.step&&u.step?c.step-u.step:0}return 0}))}}n[i].setWithExplicit(t,r)}}function Jb(e,t){const n=t.bin;if(D(n)){const i=fo(e,t.field,n);return new me(()=>e.getSignalName(i))}else if(te(n)&&Mt(n)&&n.step!==void 0)return{step:n.step};return}function ex(e,t){return A([le,De,je],e)&&t!=="nominal"?"hcl":void 0}function tx(e,t,n,i,r,s){return Ve(s)?.bin||$(n)||r!=null||i!=null||A([ge.TIME,ge.UTC],e)?void 0:Q(t)?!0:void 0}function nx(e,t,n,i,r,s){if(Q(e)){if(Fe(t)){if(n.continuousPadding!==void 0)return n.continuousPadding;const{type:o,orient:a}=r;if(o==="bar"&&!(S(i)&&(i.bin||i.timeUnit))&&(a==="vertical"&&e==="x"||a==="horizontal"&&e==="y"))return s.continuousBandSize}if(t===ge.POINT)return n.pointPadding}return}function ix(e,t,n,i,r,s=!1){if(e!==void 0)return;if(Q(t)){const{bandPaddingInner:o,barBandPaddingInner:a,rectBandPaddingInner:c,bandWithNestedOffsetPaddingInner:u}=r;return s?u:V(o,n==="bar"?a:c)}else if(gn(t)&&i===ge.BAND)return r.offsetBandPaddingInner;return}function rx(e,t,n,i,r,s=!1){if(e!==void 0)return;if(Q(t)){const{bandPaddingOuter:o,bandWithNestedOffsetPaddingOuter:a}=r;if(s)return a;if(n===ge.BAND)return V(o,E(i)?{signal:`${i.signal}/2`}:i/2)}else if(gn(t)){if(n===ge.POINT)return .5;if(n===ge.BAND)return r.offsetBandPaddingOuter}return}function sx(e,t,n,i){return n==="x"&&i.xReverse!==void 0?ye(e)&&t==="descending"?E(i.xReverse)?{signal:`!${i.xReverse.signal}`}:!i.xReverse:i.xReverse:ye(e)&&t==="descending"?!0:void 0}function ox(e,t,n,i,r,s,o){const a=!!n&&n!=="unaggregated";if(a&&ye(r)){if($(n)){const c=n[0],u=n[n.length-1];if(c<=0&&u>=0)return!0}return!1}if(e==="size"&&t.type==="quantitative"&&!bn(r))return!0;if(!(S(t)&&t.bin)&&A([...We,...ud],e)){const{orient:c,type:u}=i;return A(["bar","area","line","trail"],u)&&(c==="horizontal"&&e==="y"||c==="vertical"&&e==="x")?!1:A(["bar","area"],u)&&!o?!0:s?.zero}return!1}function ax(e,t,n,i,r=!1){const s=cx(t,n,i,r),{type:o}=e;return rt(t)?o!==void 0?pg(t,o)?S(n)&&!dg(o,n.type)?(x(mp(o,s)),s):o:(x(gp(t,o,s)),s):s:null}function cx(e,t,n,i){switch(t.type){case"nominal":case"ordinal":{if(pn(e)||Br(e)==="discrete")return e==="shape"&&t.type==="ordinal"&&x(Yr(e,"ordinal")),"ordinal";if(Q(e)||gn(e)){if(A(["rect","bar","image","rule"],n.type))return"band";if(i)return"band"}else if(n.type==="arc"&&e in Wr)return"band";const r=n[de(e)];return Bt(r)||Sn(t)&&t.axis?.tickBand?"band":"point"}case"temporal":return pn(e)?"time":Br(e)==="discrete"?(x(Yr(e,"temporal")),"ordinal"):S(t)&&t.timeUnit&&ne(t.timeUnit).utc?"utc":"time";case"quantitative":return pn(e)?S(t)&&D(t.bin)?"bin-ordinal":"linear":Br(e)==="discrete"?(x(Yr(e,"quantitative")),"ordinal"):"linear";case"geojson":return}throw new Error(Ia(t.type))}function ux(e,{ignoreRange:t}={}){nf(e),jl(e);for(const n of fg)Zl(e,n);t||ef(e)}function nf(e){q(e)?e.component.scales=lx(e):e.component.scales=dx(e)}function lx(e){const{encoding:t,mark:n,markDef:i}=e,r={};for(const s of _i){const o=X(t[s]);if(o&&n===ac&&s===fe&&o.type===yn)continue;let a=o&&o.scale;if(gn(s)){const c=la(s);if(!Es(t,c)){a&&x(ep(s));continue}}if(o&&a!==null&&a!==!1){a??(a={});const c=Es(t,s),u=ax(a,s,o,i,c);r[s]=new Hl(e.scaleName(`${s}`,!0),{value:u,explicit:a.type===u})}}return r}const fx=Nu((e,t)=>Za(e)-Za(t));function dx(e){var t;const n=e.component.scales={},i={},r=e.component.resolve;for(const s of e.children){nf(s);for(const o of b(s.component.scales))if((t=r.scale)[o]??(t[o]=Sl(o,e)),r.scale[o]==="shared"){const a=i[o],c=s.component.scales[o].getWithExplicit("type");a?tg(a.value,c.value)?i[o]=Ct(a,c,"type","scale",fx):(r.scale[o]="independent",delete i[o]):i[o]=c}}for(const s of b(i)){const o=e.scaleName(s,!0),a=i[s];n[s]=new Hl(o,a);for(const c of e.children){const u=c.component.scales[s];u&&(c.renameScale(u.get("name"),o),u.merged=!0)}}return n}class $o{constructor(){this.nameMap={}}rename(t,n){this.nameMap[t]=n}has(t){return this.nameMap[t]!==void 0}get(t){for(;this.nameMap[t]&&t!==this.nameMap[t];)t=this.nameMap[t];return t}}function q(e){return e?.type==="unit"}function Re(e){return e?.type==="facet"}function Eo(e){return e?.type==="concat"}function zn(e){return e?.type==="layer"}class _o{constructor(t,n,i,r,s,o,a){this.type=n,this.parent=i,this.config=s,this.correctDataNames=c=>(c.from?.data&&(c.from.data=this.lookupDataSource(c.from.data)),c.from?.facet?.data&&(c.from.facet.data=this.lookupDataSource(c.from.facet.data)),c),this.parent=i,this.config=s,this.view=pe(a),this.name=t.name??r,this.title=$t(t.title)?{text:t.title}:t.title?pe(t.title):void 0,this.scaleNameMap=i?i.scaleNameMap:new $o,this.projectionNameMap=i?i.projectionNameMap:new $o,this.signalNameMap=i?i.signalNameMap:new $o,this.data=t.data,this.description=t.description,this.transforms=xh(t.transform??[]),this.layout=n==="layer"||n==="unit"?{}:Nm(t,n,s),this.component={data:{sources:i?i.component.data.sources:[],outputNodes:i?i.component.data.outputNodes:{},outputNodeRefCounts:i?i.component.data.outputNodeRefCounts:{},isFaceted:Mi(t)||i?.component.data.isFaceted&&t.data===void 0},layoutSize:new lt,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:{scale:{},axis:{},legend:{},...o?C(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(){ux(this)}parseProjection(){Pl(this)}renameTopLevelLayoutSizeSignal(){this.getName("width")!=="width"&&this.renameSignal(this.getName("width"),"width"),this.getName("height")!=="height"&&this.renameSignal(this.getName("height"),"height")}parseLegends(){Nl(this)}assembleEncodeFromView(t){const{style:n,...i}=t,r={};for(const s of b(i)){const o=i[s];o!==void 0&&(r[s]=U(o))}return r}assembleGroupEncodeEntry(t){let n={};return this.view&&(n=this.assembleEncodeFromView(this.view)),!t&&(this.description&&(n.description=U(this.description)),this.type==="unit"||this.type==="layer")?{width:this.getSizeSignalRef("width"),height:this.getSizeSignalRef("height"),...n??{}}:R(n)?void 0:n}assembleLayout(){if(!this.layout)return;const{spacing:t,...n}=this.layout,{component:i,config:r}=this,s=Py(i.layoutHeaders,r);return{padding:t,...this.assembleDefaultLayout(),...n,...s?{titleBand:s}:{}}}assembleDefaultLayout(){return{}}assembleHeaderMarks(){const{layoutHeaders:t}=this.component;let n=[];for(const i of ve)t[i].title&&n.push(Cy(this,i));for(const i of so)n=n.concat(Ny(this,i));return n}assembleAxes(){return gy(this.component.axes,this.config)}assembleLegends(){return Tl(this)}assembleProjections(){return nb(this)}assembleTitle(){const{encoding:t,...n}=this.title??{},i={...ba(this.config.title).nonMarkTitleProperties,...n,...t?{encode:{update:t}}:{}};return i.text?(A(["unit","layer"],this.type)?A(["middle",void 0],i.anchor)&&(i.frame??(i.frame="group")):i.anchor??(i.anchor="start"),R(i)?void 0:i):void 0}assembleGroup(t=[]){const n={};t=t.concat(this.assembleSignals()),t.length>0&&(n.signals=t);const i=this.assembleLayout();i&&(n.layout=i),n.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());const r=!this.parent||Re(this.parent)?Wl(this):[];r.length>0&&(n.scales=r);const s=this.assembleAxes();s.length>0&&(n.axes=s);const o=this.assembleLegends();return o.length>0&&(n.legends=o),n}getName(t){return W((this.name?`${this.name}_`:"")+t)}getDataName(t){return this.getName(j[t].toLowerCase())}requestDataName(t){const n=this.getDataName(t),i=this.component.data.outputNodeRefCounts;return i[n]=(i[n]||0)+1,n}getSizeSignalRef(t){if(Re(this.parent)){const n=bl(t),i=Ei(n),r=this.component.scales[i];if(r&&!r.merged){const s=r.get("type"),o=r.get("range");if(Z(s)&&Et(o)){const a=r.get("name"),c=dr(this,i),u=vo(c);if(u){const l=w({aggregate:"distinct",field:u},{expr:"datum"});return{signal:yl(a,r,l)}}else return x(Vr(i)),null}}}return{signal:this.signalNameMap.get(this.getName(t))}}lookupDataSource(t){const n=this.component.data.outputNodes[t];return n?n.getSource():t}getSignalName(t){return this.signalNameMap.get(t)}renameSignal(t,n){this.signalNameMap.rename(t,n)}renameScale(t,n){this.scaleNameMap.rename(t,n)}renameProjection(t,n){this.projectionNameMap.rename(t,n)}scaleName(t,n){return n?this.getName(t):aa(t)&&rt(t)&&this.component.scales[t]||this.scaleNameMap.has(this.getName(t))?this.scaleNameMap.get(this.getName(t)):void 0}projectionName(t){return t?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(t){if(!this.component.scales)throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().");const n=this.component.scales[t];return n&&!n.merged?n:this.parent?this.parent.getScaleComponent(t):void 0}getSelectionComponent(t,n){let i=this.component.selection[t];if(!i&&this.parent&&(i=this.parent.getSelectionComponent(t,n)),!i)throw new Error(Od(n));return i}hasAxisOrientSignalRef(){return this.component.axes.x?.some(t=>t.hasOrientSignalRef())||this.component.axes.y?.some(t=>t.hasOrientSignalRef())}}class rf extends _o{vgField(t,n={}){const i=this.fieldDef(t);return i?w(i,n):void 0}reduceFieldDef(t,n){return im(this.getMapping(),(i,r,s)=>{const o=Ve(r);return o?t(i,o,s):i},n)}forEachFieldDef(t,n){ks(this.getMapping(),(i,r)=>{const s=Ve(i);s&&t(s,r)},n)}}class pr extends I{clone(){return new pr(null,C(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=C(n);const i=this.transform.as??[void 0,void 0];this.transform.as=[i[0]??"value",i[1]??"density"],n.groupby&&n.minsteps==null&&n.maxsteps==null&&n.steps==null&&(this.transform.steps=200)}dependentFields(){return new Set([this.transform.density,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`DensityTransform ${O(this.transform)}`}assemble(){const{density:t,...n}=this.transform,i={type:"kde",field:t,...n};return i}}class ci extends I{clone(){return new ci(null,{...this.filter})}constructor(t,n){super(t);this.filter=n}static make(t,n){const{config:i,mark:r,markDef:s}=n,o=z("invalid",s,i);if(o!=="filter")return null;const a=n.reduceFieldDef((c,u,l)=>{const f=rt(l)&&n.getScaleComponent(l);if(f){const d=f.get("type");ye(d)&&u.aggregate!=="count"&&!_t(r)&&(c[u.field]=u)}return c},{});return b(a).length?new ci(t,a):null}dependentFields(){return new Set(b(this.filter))}producedFields(){return new Set}hash(){return`FilterInvalid ${O(this.filter)}`}assemble(){const t=b(this.filter).reduce((n,i)=>{const r=this.filter[i],s=w(r,{expr:"datum"});return r!==null&&(r.type==="temporal"?n.push(`(isDate(${s}) || (isValid(${s}) && isFinite(+${s})))`):r.type==="quantitative"&&(n.push(`isValid(${s})`),n.push(`isFinite(+${s})`))),n},[]);return t.length>0?{type:"filter",expr:t.join(" && ")}:null}}class gr extends I{clone(){return new gr(this.parent,C(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=C(n);const{flatten:i,as:r=[]}=this.transform;this.transform.as=i.map((s,o)=>r[o]??s)}dependentFields(){return new Set(this.transform.flatten)}producedFields(){return new Set(this.transform.as)}hash(){return`FlattenTransform ${O(this.transform)}`}assemble(){const{flatten:t,as:n}=this.transform,i={type:"flatten",fields:t,as:n};return i}}class mr extends I{clone(){return new mr(null,C(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=C(n);const i=this.transform.as??[void 0,void 0];this.transform.as=[i[0]??"key",i[1]??"value"]}dependentFields(){return new Set(this.transform.fold)}producedFields(){return new Set(this.transform.as)}hash(){return`FoldTransform ${O(this.transform)}`}assemble(){const{fold:t,as:n}=this.transform,i={type:"fold",fields:t,as:n};return i}}class Rn extends I{clone(){return new Rn(null,C(this.fields),this.geojson,this.signal)}static parseAll(t,n){if(n.component.projection&&!n.component.projection.isFit)return t;let i=0;for(const r of[[Ce,ke],[we,Ne]]){const s=r.map(o=>{const a=X(n.encoding[o]);return S(a)?a.field:Ge(a)?{expr:`${a.datum}`}:Ae(a)?{expr:`${a.value}`}:void 0});(s[0]||s[1])&&(t=new Rn(t,s,null,n.getName(`geojson_${i++}`)))}if(n.channelHasField(fe)){const r=n.typedFieldDef(fe);r.type===yn&&(t=new Rn(t,null,r.field,n.getName(`geojson_${i++}`)))}return t}constructor(t,n,i,r){super(t);this.fields=n,this.geojson=i,this.signal=r}dependentFields(){const t=(this.fields??[]).filter(F);return new Set([...this.geojson?[this.geojson]:[],...t])}producedFields(){return new Set}hash(){return`GeoJSON ${this.geojson} ${this.signal} ${O(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 ui extends I{clone(){return new ui(null,this.projection,C(this.fields),C(this.as))}constructor(t,n,i,r){super(t);this.projection=n,this.fields=i,this.as=r}static parseAll(t,n){if(!n.projectionName())return t;for(const i of[[Ce,ke],[we,Ne]]){const r=i.map(o=>{const a=X(n.encoding[o]);return S(a)?a.field:Ge(a)?{expr:`${a.datum}`}:Ae(a)?{expr:`${a.value}`}:void 0}),s=i[0]===we?"2":"";(r[0]||r[1])&&(t=new ui(t,n.projectionName(),r,[n.getName(`x${s}`),n.getName(`y${s}`)]))}return t}dependentFields(){return new Set(this.fields.filter(F))}producedFields(){return new Set(this.as)}hash(){return`Geopoint ${this.projection} ${O(this.fields)} ${O(this.as)}`}assemble(){return{type:"geopoint",projection:this.projection,fields:this.fields,as:this.as}}}class en extends I{clone(){return new en(null,C(this.transform))}constructor(t,n){super(t);this.transform=n}dependentFields(){return new Set([this.transform.impute,this.transform.key,...this.transform.groupby??[]])}producedFields(){return new Set([this.transform.impute])}processSequence(t){const{start:n=0,stop:i,step:r}=t,s=[n,i,...r?[r]:[]].join(",");return{signal:`sequence(${s})`}}static makeFromTransform(t,n){return new en(t,n)}static makeFromEncoding(t,n){const i=n.encoding,r=i.x,s=i.y;if(S(r)&&S(s)){const o=r.impute?r:s.impute?s:void 0;if(o===void 0)return;const a=r.impute?s:s.impute?r:void 0,{method:c,value:u,frame:l,keyvals:f}=o.impute,d=jc(n.mark,i);return new en(t,{impute:o.field,key:a.field,...c?{method:c}:{},...u!==void 0?{value:u}:{},...l?{frame:l}:{},...f!==void 0?{keyvals:f}:{},...d.length?{groupby:d}:{}})}return null}hash(){return`Impute ${O(this.transform)}`}assemble(){const{impute:t,key:n,keyvals:i,method:r,groupby:s,value:o,frame:a=[null,null]}=this.transform,c={type:"impute",field:t,key:n,...i?{keyvals:th(i)?this.processSequence(i):i}:{},method:"value",...s?{groupby:s}:{},value:!r||r==="value"?o:null};if(r&&r!=="value"){const u={type:"window",as:[`imputed_${t}_value`],ops:[r],fields:[t],frame:a,ignorePeers:!1,...s?{groupby:s}:{}},l={type:"formula",expr:`datum.${t} === null ? datum.imputed_${t}_value : datum.${t}`,as:t};return[c,u,l]}else return[c]}}class hr extends I{clone(){return new hr(null,C(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=C(n);const i=this.transform.as??[void 0,void 0];this.transform.as=[i[0]??n.on,i[1]??n.loess]}dependentFields(){return new Set([this.transform.loess,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`LoessTransform ${O(this.transform)}`}assemble(){const{loess:t,on:n,...i}=this.transform,r={type:"loess",x:n,y:t,...i};return r}}class li extends I{clone(){return new li(null,C(this.transform),this.secondary)}constructor(t,n,i){super(t);this.transform=n,this.secondary=i}static make(t,n,i,r){const s=n.component.data.sources,{from:o}=i;let a=null;if(nh(o)){let c=cf(o.data,s);c||(c=new Qt(o.data),s.push(c));const u=n.getName(`lookup_${r}`);a=new ce(c,u,j.Lookup,n.component.data.outputNodeRefCounts),n.component.data.outputNodes[u]=a}else if(ih(o)){const c=o.param;i={as:c,...i};let u;try{u=n.getSelectionComponent(W(c),c)}catch(l){throw new Error(Rd(c))}if(a=u.materialized,!a)throw new Error(Id(c))}return new li(t,i,a.getSource())}dependentFields(){return new Set([this.transform.lookup])}producedFields(){return new Set(this.transform.as?H(this.transform.as):this.transform.from.fields)}hash(){return`Lookup ${O({transform:this.transform,secondary:this.secondary})}`}assemble(){let t;if(this.transform.from.fields)t={values:this.transform.from.fields,...this.transform.as?{as:H(this.transform.as)}:{}};else{let n=this.transform.as;F(n)||(x(Hd),n="_lookup"),t={as:[n]}}return{type:"lookup",from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup],...t,...this.transform.default?{default:this.transform.default}:{}}}}class yr extends I{clone(){return new yr(null,C(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=C(n);const i=this.transform.as??[void 0,void 0];this.transform.as=[i[0]??"prob",i[1]??"value"]}dependentFields(){return new Set([this.transform.quantile,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`QuantileTransform ${O(this.transform)}`}assemble(){const{quantile:t,...n}=this.transform,i={type:"quantile",field:t,...n};return i}}class br extends I{clone(){return new br(null,C(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=C(n);const i=this.transform.as??[void 0,void 0];this.transform.as=[i[0]??n.on,i[1]??n.regression]}dependentFields(){return new Set([this.transform.regression,this.transform.on,...this.transform.groupby??[]])}producedFields(){return new Set(this.transform.as)}hash(){return`RegressionTransform ${O(this.transform)}`}assemble(){const{regression:t,on:n,...i}=this.transform,r={type:"regression",x:n,y:t,...i};return r}}class xr extends I{clone(){return new xr(null,C(this.transform))}constructor(t,n){super(t);this.transform=n}addDimensions(t){this.transform.groupby=Le((this.transform.groupby??[]).concat(t),n=>n)}producedFields(){return}dependentFields(){return new Set([this.transform.pivot,this.transform.value,...this.transform.groupby??[]])}hash(){return`PivotTransform ${O(this.transform)}`}assemble(){const{pivot:t,value:n,groupby:i,limit:r,op:s}=this.transform;return{type:"pivot",field:t,value:n,...r!==void 0?{limit:r}:{},...s!==void 0?{op:s}:{},...i!==void 0?{groupby:i}:{}}}}class Sr extends I{clone(){return new Sr(null,C(this.transform))}constructor(t,n){super(t);this.transform=n}dependentFields(){return new Set}producedFields(){return new Set}hash(){return`SampleTransform ${O(this.transform)}`}assemble(){return{type:"sample",size:this.transform.sample}}}function sf(e){let t=0;function n(i,r){if(i instanceof Qt&&(!i.isGenerator&&!_n(i.data))){e.push(r);const s={name:null,source:r.name,transform:[]};r=s}if(i instanceof re&&(i.parent instanceof Qt&&!r.source?(r.format={...r.format??{},parse:i.assembleFormatParse()},r.transform.push(...i.assembleTransforms(!0))):r.transform.push(...i.assembleTransforms())),i instanceof On){r.name||(r.name=`data_${t++}`),!r.source||r.transform.length>0?(e.push(r),i.data=r.name):i.data=r.source,e.push(...i.assemble());return}if((i instanceof si||i instanceof oi||i instanceof ci||i instanceof Nn||i instanceof Fn||i instanceof ui||i instanceof Pe||i instanceof li||i instanceof Pn||i instanceof Jt||i instanceof mr||i instanceof gr||i instanceof pr||i instanceof hr||i instanceof yr||i instanceof br||i instanceof At||i instanceof Sr||i instanceof xr)&&r.transform.push(i.assemble()),(i instanceof Qe||i instanceof Ke||i instanceof en||i instanceof dt||i instanceof Rn)&&r.transform.push(...i.assemble()),i instanceof ce){if(r.source&&r.transform.length===0)i.setSource(r.source);else if(i.parent instanceof ce)i.setSource(r.name);else if(r.name||(r.name=`data_${t++}`),i.setSource(r.name),i.numChildren()===1){e.push(r);const s={name:null,source:r.name,transform:[]};r=s}}switch(i.numChildren()){case 0:i instanceof ce&&(!r.source||r.transform.length>0)&&e.push(r);break;case 1:n(i.children[0],r);break;default:{r.name||(r.name=`data_${t++}`);let s=r.name;!r.source||r.transform.length>0?e.push(r):s=r.source;for(const o of i.children){const a={name:null,source:s,transform:[]};n(o,a)}break}}}return n}function px(e){const t=[],n=sf(t);for(const i of e.children)n(i,{source:e.name,name:null,transform:[]});return t}function gx(e,t){const n=[],i=sf(n);let r=0;for(const o of e.sources){o.hasName()||(o.dataName=`source_${r++}`);const a=o.assemble();i(o,a)}for(const o of n)o.transform.length===0&&delete o.transform;let s=0;for(const[o,a]of n.entries())(a.transform??[]).length===0&&!a.source&&n.splice(s++,0,n.splice(o,1)[0]);for(const o of n)for(const a of o.transform??[])a.type==="lookup"&&(a.from=e.outputNodes[a.from].getSource());for(const o of n)o.name in t&&(o.values=t[o.name]);return n}function mx(e){return e==="top"||e==="left"||E(e)?"header":"footer"}function hx(e){for(const t of ve)yx(e,t);af(e,"x"),af(e,"y")}function yx(e,t){const{facet:n,config:i,child:r,component:s}=e;if(e.channelHasField(t)){const o=n[t],a=An("title",null,i,t);let c=wn(o,i,{allowDisabling:!0,includeDefault:a===void 0||!!a});r.component.layoutHeaders[t].title&&(c=$(c)?c.join(", "):c,c+=` / ${r.component.layoutHeaders[t].title}`,r.component.layoutHeaders[t].title=null);const u=An("labelOrient",o.header,i,t),l=o.header!==null?V(o.header?.labels,i.header.labels,!0):!1,f=A(["bottom","right"],u)?"footer":"header";s.layoutHeaders[t]={title:o.header!==null?c:null,facetFieldDef:o,[f]:t==="facet"?[]:[of(e,t,l)]}}}function of(e,t,n){const i=t==="row"?"height":"width";return{labels:n,sizeSignal:e.child.component.layoutSize.get(i)?e.child.getSizeSignalRef(i):void 0,axes:[]}}function af(e,t){const{child:n}=e;if(n.component.axes[t]){const{layoutHeaders:i,resolve:r}=e.component;if(r.axis[t]=uo(r,t),r.axis[t]==="shared"){const s=t==="x"?"column":"row",o=i[s];for(const a of n.component.axes[t]){const c=mx(a.get("orient"));o[c]??(o[c]=[of(e,s,!1)]);const u=ri(a,"main",e.config,{header:!0});u&&o[c][0].axes.push(u),a.mainExtracted=!0}}}}function bx(e){ko(e),wr(e,"width"),wr(e,"height")}function xx(e){ko(e);const t=e.layout.columns===1?"width":"childWidth",n=e.layout.columns===void 0?"height":"childHeight";wr(e,t),wr(e,n)}function ko(e){for(const t of e.children)t.parseLayoutSize()}function wr(e,t){const n=bl(t),i=Ei(n),r=e.component.resolve,s=e.component.layoutSize;let o;for(const a of e.children){const c=a.component.layoutSize.getWithExplicit(n),u=r.scale[i]??Sl(i,e);if(u==="independent"&&c.value==="step"){o=void 0;break}if(o){if(u==="independent"&&o.value!==c.value){o=void 0;break}o=Ct(o,c,n,"")}else o=c}if(o){for(const a of e.children)e.renameSignal(a.getName(n),e.getName(t)),a.component.layoutSize.set(n,"merged",!1);s.setWithExplicit(t,o)}else s.setWithExplicit(t,{explicit:!1,value:void 0})}function Sx(e){const{size:t,component:n}=e;for(const i of We){const r=de(i);if(t[r]){const s=t[r];n.layoutSize.set(r,Xe(s)?"step":s,!0)}else{const s=wx(e,r);n.layoutSize.set(r,s,!1)}}}function wx(e,t){const n=t==="width"?"x":"y",i=e.config,r=e.getScaleComponent(n);if(r){const s=r.get("type"),o=r.get("range");if(Z(s)){const a=Ji(i.view,t);return Et(o)||Xe(a)?"step":a}else return Ms(i.view,t)}else{if(e.hasProjection||e.mark==="arc")return Ms(i.view,t);{const s=Ji(i.view,t);return Xe(s)?s.step:s}}}function Co(e,t,n){return w(t,{suffix:`by_${w(e)}`,...n??{}})}class fi extends rf{constructor(t,n,i,r){super(t,"facet",n,i,r,t.resolve);this.child=Oo(t.spec,this,this.getName("child"),void 0,r),this.children=[this.child],this.facet=this.initFacet(t.facet)}initFacet(t){if(!Yn(t))return{facet:this.initFacetFieldDef(t,"facet")};const n=b(t),i={};for(const r of n){if(![Ze,Je].includes(r)){x(Ni(r,"facet"));break}const s=t[r];if(s.field===void 0){x(Xr(s,r));break}i[r]=this.initFacetFieldDef(s,r)}return i}initFacetFieldDef(t,n){const i=$s(t,n);return i.header?i.header=pe(i.header):i.header===null&&(i.header=null),i}channelHasField(t){return!!this.facet[t]}fieldDef(t){return this.facet[t]}parseData(){this.component.data=vr(this),this.child.parseData()}parseLayoutSize(){ko(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),hx(this)}assembleSelectionTopLevelSignals(t){return this.child.assembleSelectionTopLevelSignals(t)}assembleSignals(){return this.child.assembleSignals(),[]}assembleSelectionData(t){return this.child.assembleSelectionData(t)}getHeaderLayoutMixins(){const t={};for(const n of ve)for(const i of oo){const r=this.component.layoutHeaders[n],s=r[i],{facetFieldDef:o}=r;if(o){const a=An("titleOrient",o.header,this.config,n);if(["right","bottom"].includes(a)){const c=cr(n,a);t.titleAnchor??(t.titleAnchor={}),t.titleAnchor[c]="end"}}if(s?.[0]){const a=n==="row"?"height":"width",c=i==="header"?"headerBand":"footerBand";n!=="facet"&&!this.child.component.layoutSize.get(a)&&(t[c]??(t[c]={}),t[c][n]=.5),r.title&&(t.offset??(t.offset={}),t.offset[n==="row"?"rowTitle":"columnTitle"]=10)}}return t}assembleDefaultLayout(){const{column:t,row:n}=this.facet,i=t?this.columnDistinctSignal():n?1:void 0;let r="all";return(!n&&this.component.resolve.scale.x==="independent"||!t&&this.component.resolve.scale.y==="independent")&&(r="none"),{...this.getHeaderLayoutMixins(),...i?{columns:i}:{},bounds:"full",align:r}}assembleLayoutSignals(){return this.child.assembleLayoutSignals()}columnDistinctSignal(){if(this.parent&&this.parent instanceof fi)return;{const t=this.getName("column_domain");return{signal:`length(data('${t}'))`}}}assembleGroupStyle(){return}assembleGroup(t){return this.parent&&this.parent instanceof fi?{...this.channelHasField("column")?{encode:{update:{columns:{field:w(this.facet.column,{prefix:"distinct"})}}}}:{},...super.assembleGroup(t)}:super.assembleGroup(t)}getCardinalityAggregateForChild(){const t=[],n=[],i=[];if(this.child instanceof fi){if(this.child.channelHasField("column")){const r=w(this.child.facet.column);t.push(r),n.push("distinct"),i.push(`distinct_${r}`)}}else for(const r of We){const s=this.child.component.scales[r];if(s&&!s.merged){const o=s.get("type"),a=s.get("range");if(Z(o)&&Et(a)){const c=dr(this.child,r),u=vo(c);u?(t.push(u),n.push("distinct"),i.push(`distinct_${u}`)):x(Vr(r))}}}return{fields:t,ops:n,as:i}}assembleFacet(){const{name:t,data:n}=this.component.data.facetRoot,{row:i,column:r}=this.facet,{fields:s,ops:o,as:a}=this.getCardinalityAggregateForChild(),c=[];for(const l of ve){const f=this.facet[l];if(f){c.push(w(f));const{bin:d,sort:p}=f;if(D(d)&&c.push(w(f,{binSuffix:"end"})),qe(p)){const{field:g,op:m=Li}=p,h=Co(f,p);i&&r?(s.push(h),o.push("max"),a.push(h)):(s.push(g),o.push(m),a.push(h))}else if($(p)){const g=Tn(f,l);s.push(g),o.push("max"),a.push(g)}}}const u=!!i&&!!r;return{name:t,data:n,groupby:c,...u||s.length>0?{aggregate:{...u?{cross:u}:{},...s.length?{fields:s,ops:o,as:a}:{}}}:{}}}facetSortFields(t){const{facet:n}=this,i=n[t];return i?qe(i.sort)?[Co(i,i.sort,{expr:"datum"})]:$(i.sort)?[Tn(i,t,{expr:"datum"})]:[w(i,{expr:"datum"})]:[]}facetSortOrder(t){const{facet:n}=this,i=n[t];if(i){const{sort:r}=i,s=(qe(r)?r.order:!$(r)&&r)||"ascending";return[s]}return[]}assembleLabelTitle(){const{facet:t,config:n}=this;if(t.facet)return ao(t.facet,"facet",n);const i={row:["top","bottom"],column:["left","right"]};for(const r of so)if(t[r]){const s=An("labelOrient",t[r]?.header,n,r);if(i[r].includes(s))return ao(t[r],r,n)}return}assembleMarks(){const{child:t}=this,n=this.component.data.facetRoot,i=px(n),r=t.assembleGroupEncodeEntry(!1),s=this.assembleLabelTitle()||t.assembleTitle(),o=t.assembleGroupStyle(),a={name:this.getName("cell"),type:"group",...s?{title:s}:{},...o?{style:o}:{},from:{facet:this.assembleFacet()},sort:{field:ve.map(c=>this.facetSortFields(c)).flat(),order:ve.map(c=>this.facetSortOrder(c)).flat()},...i.length>0?{data:i}:{},...r?{encode:{update:r}}:{},...t.assembleGroup(Oh(this,[]))};return[a]}getMapping(){return this.facet}}function vx(e,t){const{row:n,column:i}=t;if(n&&i){let r=null;for(const s of[n,i])if(qe(s.sort)){const{field:o,op:a=Li}=s.sort;e=r=new Jt(e,{joinaggregate:[{op:a,field:o,as:Co(s,s.sort,{forAs:!0})}],groupby:[w(s)]})}return r}return null}function cf(e,t){for(const n of t){const i=n.data;if(e.name&&n.hasName()&&e.name!==n.dataName)continue;const r=e.format?.mesh,s=i.format?.feature;if(r&&s)continue;const o=e.format?.feature;if((o||s)&&o!==s)continue;const a=i.format?.mesh;if((r||a)&&r!==a)continue;if(Jn(e)&&Jn(i)){if(Ie(e.values,i.values))return n}else if(_n(e)&&_n(i)){if(e.url===i.url)return n}else if(Fu(e)&&e.name===n.dataName)return n}return null}function $x(e,t){if(e.data||!e.parent){if(e.data===null){const i=new Qt({values:[]});return t.push(i),i}const n=cf(e.data,t);if(n)return Nt(e.data)||(n.data.format=Yo({},e.data.format,n.data.format)),!n.hasName()&&e.data.name&&(n.dataName=e.data.name),n;{const i=new Qt(e.data);return t.push(i),i}}else return e.parent.component.data.facetRoot?e.parent.component.data.facetRoot:e.parent.component.data.main}function Ex(e,t,n){let i=0;for(const r of t.transforms){let s,o;if(ph(r))o=e=new Fn(e,r),s="derived";else if(Bs(r)){const a=mb(r);o=e=re.makeWithAncestors(e,{},a,n)??e,e=new Nn(e,t,r.filter)}else if(wu(r))o=e=Qe.makeFromTransform(e,r,t),s="number";else if(mh(r)){s="date";const a=n.getWithExplicit(r.field);a.value===void 0&&(e=new re(e,{[r.field]:s}),n.set(r.field,s,!1)),o=e=Ke.makeFromTransform(e,r)}else if(hh(r))o=e=Pe.makeFromTransform(e,r),s="number",eo(t)&&(e=new At(e));else if(Su(r))o=e=li.make(e,t,r,i++),s="derived";else if(lh(r))o=e=new Pn(e,r),s="number";else if(fh(r))o=e=new Jt(e,r),s="number";else if(yh(r))o=e=dt.makeFromTransform(e,r),s="derived";else if(bh(r))o=e=new mr(e,r),s="derived";else if(dh(r))o=e=new gr(e,r),s="derived";else if(rh(r))o=e=new xr(e,r),s="derived";else if(uh(r))e=new Sr(e,r);else if(gh(r))o=e=en.makeFromTransform(e,r),s="derived";else if(sh(r))o=e=new pr(e,r),s="derived";else if(oh(r))o=e=new yr(e,r),s="derived";else if(ah(r))o=e=new br(e,r),s="derived";else if(ch(r))o=e=new hr(e,r),s="derived";else{x(Bd(r));continue}if(o&&s!==void 0)for(const a of o.producedFields()??[])n.set(a,s,!1)}return e}function vr(e){let t=$x(e,e.component.data.sources);const{outputNodes:n,outputNodeRefCounts:i}=e.component.data,r=e.data,s=r&&(Nt(r)||_n(r)||Jn(r)),o=!s&&e.parent?e.parent.component.data.ancestorParse.clone():new Th;Nt(r)?(Tu(r)?t=new oi(t,r.sequence):Gs(r)&&(t=new si(t,r.graticule)),o.parseNothing=!0):r?.format?.parse===null&&(o.parseNothing=!0),t=re.makeExplicit(t,e,o)??t,t=new At(t);const a=e.parent&&zn(e.parent);(q(e)||Re(e))&&(a&&(t=Qe.makeFromEncoding(t,e)??t)),e.transforms.length>0&&(t=Ex(t,e,o));const c=yb(e),u=hb(e);t=re.makeWithAncestors(t,{},{...c,...u},o)??t,q(e)&&(t=Rn.parseAll(t,e),t=ui.parseAll(t,e)),(q(e)||Re(e))&&(a||(t=Qe.makeFromEncoding(t,e)??t),t=Ke.makeFromEncoding(t,e)??t,t=Fn.parseAllForSortIndex(t,e));const l=e.getDataName(j.Raw),f=new ce(t,l,j.Raw,i);if(n[l]=f,t=f,q(e)){const m=Pe.makeFromEncoding(t,e);m&&(t=m,eo(e)&&(t=new At(t))),t=en.makeFromEncoding(t,e)??t,t=dt.makeFromEncoding(t,e)??t}q(e)&&(t=ci.make(t,e)??t);const d=e.getDataName(j.Main),p=new ce(t,d,j.Main,i);n[d]=p,t=p,q(e)&&dy(e,p);let g=null;if(Re(e)){const m=e.getName("facet");t=vx(t,e.facet)??t,g=new On(t,e,m,p.getSource()),n[m]=g}return{...e.component.data,outputNodes:n,outputNodeRefCounts:i,raw:f,main:p,facetRoot:g,ancestorParse:o}}class _x extends _o{constructor(t,n,i,r){super(t,"concat",n,i,r,t.resolve);(t.resolve?.axis?.x==="shared"||t.resolve?.axis?.y==="shared")&&x(jd),this.children=this.getChildren(t).map((s,o)=>Oo(s,this,this.getName(`concat_${o}`),void 0,r))}parseData(){this.component.data=vr(this);for(const t of this.children)t.parseData()}parseSelections(){this.component.selection={};for(const t of this.children){t.parseSelections();for(const n of b(t.component.selection))this.component.selection[n]=t.component.selection[n]}}parseMarkGroup(){for(const t of this.children)t.parseMarkGroup()}parseAxesAndHeaders(){for(const t of this.children)t.parseAxesAndHeaders()}getChildren(t){return Qi(t)?t.vconcat:Ls(t)?t.hconcat:t.concat}parseLayoutSize(){xx(this)}parseAxisGroup(){return null}assembleSelectionTopLevelSignals(t){return this.children.reduce((n,i)=>i.assembleSelectionTopLevelSignals(n),t)}assembleSignals(){return this.children.forEach(t=>t.assembleSignals()),[]}assembleLayoutSignals(){const t=co(this);for(const n of this.children)t.push(...n.assembleLayoutSignals());return t}assembleSelectionData(t){return this.children.reduce((n,i)=>i.assembleSelectionData(n),t)}assembleMarks(){return this.children.map(t=>{const n=t.assembleTitle(),i=t.assembleGroupStyle(),r=t.assembleGroupEncodeEntry(!1);return{type:"group",name:t.getName("group"),...n?{title:n}:{},...i?{style:i}:{},...r?{encode:{update:r}}:{},...t.assembleGroup()}})}assembleGroupStyle(){return}assembleDefaultLayout(){const t=this.layout.columns;return{...t!=null?{columns:t}:{},bounds:"full",align:"each"}}}function kx(e){return e===!1||e===null}const Cx={disable:1,gridScale:1,scale:1,...Rc,labelExpr:1,encode:1},uf=b(Cx);class No extends lt{constructor(t={},n={},i=!1){super();this.explicit=t,this.implicit=n,this.mainExtracted=i}clone(){return new No(C(this.explicit),C(this.implicit),this.mainExtracted)}hasAxisPart(t){return t==="axis"?!0:t==="grid"||t==="title"?!!this.get(t):!kx(this.get(t))}hasOrientSignalRef(){return E(this.explicit.orient)}}function Nx(e,t,n){const{encoding:i,config:r}=e,s=X(i[t])??X(i[Ue(t)]),o=e.axis(t)||{},{format:a,formatType:c}=o;if(qt(c))return{text:Te({fieldOrDatumDef:s,field:"datum.value",format:a,formatType:c,config:r}),...n};if(a===void 0&&c===void 0&&r.customFormatTypes){if(xn(s)==="quantitative"){if(Sn(s)&&s.stack==="normalize"&&r.normalizedNumberFormatType)return{text:Te({fieldOrDatumDef:s,field:"datum.value",format:r.normalizedNumberFormat,formatType:r.normalizedNumberFormatType,config:r}),...n};if(r.numberFormatType)return{text:Te({fieldOrDatumDef:s,field:"datum.value",format:r.numberFormat,formatType:r.numberFormatType,config:r}),...n}}if(xn(s)==="temporal"&&r.timeFormatType&&S(s)&&!s.timeUnit)return{text:Te({fieldOrDatumDef:s,field:"datum.value",format:r.timeFormat,formatType:r.timeFormatType,config:r}),...n}}return n}function Fx(e){return We.reduce((t,n)=>(e.component.scales[n]&&(t[n]=[Ix(n,e)]),t),{})}const Tx={bottom:"top",top:"bottom",left:"right",right:"left"};function Ax(e){const{axes:t,resolve:n}=e.component,i={top:0,bottom:0,right:0,left:0};for(const r of e.children){r.parseAxesAndHeaders();for(const s of b(r.component.axes))n.axis[s]=uo(e.component.resolve,s),n.axis[s]==="shared"&&(t[s]=Ox(t[s],r.component.axes[s]),t[s]||(n.axis[s]="independent",delete t[s]))}for(const r of We){for(const s of e.children){if(!s.component.axes[r])continue;if(n.axis[r]==="independent"){t[r]=(t[r]??[]).concat(s.component.axes[r]);for(const o of s.component.axes[r]){const{value:a,explicit:c}=o.getWithExplicit("orient");if(E(a))continue;if(i[a]>0&&!c){const u=Tx[a];i[a]>i[u]&&o.set("orient",u,!1)}i[a]++}}delete s.component.axes[r]}if(n.axis[r]==="independent"&&t[r]&&t[r].length>1)for(const s of t[r])!!s.get("grid")&&!s.explicit.grid&&(s.implicit.grid=!1)}}function Ox(e,t){if(e){if(e.length!==t.length)return;const n=e.length;for(let i=0;in.clone());return e}function Px(e,t){for(const n of uf){const i=Ct(e.getWithExplicit(n),t.getWithExplicit(n),n,"axis",(r,s)=>{switch(n){case"title":return Ca(r,s);case"gridScale":return{explicit:r.explicit,value:V(r.value,s.value)}}return tr(r,s,n,"axis")});e.setWithExplicit(n,i)}return e}function zx(e,t,n,i,r){if(t==="disable")return n!==void 0;n=n||{};switch(t){case"titleAngle":case"labelAngle":return e===(E(n.labelAngle)?n.labelAngle:Un(n.labelAngle));case"values":return!!n.values;case"encode":return!!n.encoding||!!n.labelAngle;case"title":if(e===dl(i,r))return!0}return e===n[t]}const Rx=new Set(["grid","translate","format","formatType","orient","labelExpr","tickCount","position","tickMinStep"]);function Ix(e,t){let n=t.axis(e);const i=new No,r=X(t.encoding[e]),{mark:s,config:o}=t,a=n?.orient||o[e==="x"?"axisX":"axisY"]?.orient||o.axis?.orient||vy(e),c=t.getScaleComponent(e).get("type"),u=my(e,c,a,t.config),l=n!==void 0?!n:io("disable",o.style,n?.style,u).configValue;if(i.set("disable",l,n!==void 0),l)return i;n=n||{};const f=xy(r,n,e,o.style,u),d=mc(n.formatType,r,c),p=gc(r,r.type,n.format,n.formatType,o,!0),g={fieldOrDatumDef:r,axis:n,channel:e,model:t,scaleType:c,orient:a,labelAngle:f,format:p,formatType:d,mark:s,config:o};for(const y of uf){const v=y in ul?ul[y](g):Ic(y)?n[y]:void 0,_=v!==void 0,k=zx(v,y,n,t,e);if(_&&k)i.set(y,v,k);else{const{configValue:P=void 0,configFrom:Y=void 0}=Ic(y)&&y!=="values"?io(y,o.style,n.style,u):{},se=P!==void 0;_&&!se?i.set(y,v,k):(!(Y==="vgAxisConfig")||Rx.has(y)&&se||Zn(P)||E(P))&&i.set(y,P,!1)}}const m=n.encoding??{},h=zc.reduce((y,v)=>{if(!i.hasAxisPart(v))return y;const _=xl(m[v]??{},t),k=v==="labels"?Nx(t,e,_):_;return k!==void 0&&!R(k)&&(y[v]={update:k}),y},{});return R(h)||i.set("encode",h,!!n.encoding||n.labelAngle!==void 0),i}function Lx({encoding:e,size:t}){for(const n of We){const i=de(n);Xe(t[i])&&(kt(e[n])&&(delete t[i],x(Da(i))))}return t}function Mx(e,t,n){const i=pe(e),r=z("orient",i,n);if(i.orient=Wx(i.type,t,r),r!==void 0&&r!==i.orient&&x(ap(i.orient,r)),i.type==="bar"&&i.orient){const a=z("cornerRadiusEnd",i,n);if(a!==void 0){const c=i.orient==="horizontal"&&t.x2||i.orient==="vertical"&&t.y2?["cornerRadius"]:_g[i.orient];for(const u of c)i[u]=a;i.cornerRadiusEnd!==void 0&&delete i.cornerRadiusEnd}}const s=z("opacity",i,n);s===void 0&&(i.opacity=jx(i.type,t));const o=z("cursor",i,n);return o===void 0&&(i.cursor=Dx(i,t,n)),i}function Dx(e,t,n){return t.href||e.href||z("href",e,n)?"pointer":e.cursor}function jx(e,t){return A([zi,fs,ds,ps],e)&&!_s(t)?.7:void 0}function Ux(e,t,{graticule:n}){if(n)return!1;const i=Dt("filled",e,t),r=e.type;return V(i,r!==zi&&r!==Pi&&r!==Ri)}function Wx(e,t,n){switch(e){case zi:case ds:case ps:case oc:case mg:case gg:return}const{x:i,y:r,x2:s,y2:o}=t;switch(e){case Oi:if(S(i)&&(te(i.bin)||S(r)&&r.aggregate&&!i.aggregate))return"vertical";if(S(r)&&(te(r.bin)||S(i)&&i.aggregate&&!r.aggregate))return"horizontal";if(o||s){if(n)return n;if(!s)return(S(i)&&i.type===Wt&&!D(i.bin)||Ui(i))&&(S(r)&&te(r.bin))?"horizontal":"vertical";if(!o)return(S(r)&&r.type===Wt&&!D(r.bin)||Ui(r))&&(S(i)&&te(i.bin))?"vertical":"horizontal"}case Ri:if(s&&!(S(i)&&te(i.bin))&&o&&!(S(r)&&te(r.bin)))return;case Ai:if(o)return S(r)&&te(r.bin)?"horizontal":"vertical";if(s)return S(i)&&te(i.bin)?"vertical":"horizontal";if(e===Ri){if(i&&!r)return"vertical";if(r&&!i)return"horizontal"}case Pi:case fs:{const a=_c(i),c=_c(r);if(n)return n;if(a&&!c)return e!=="tick"?"horizontal":"vertical";if(!a&&c)return e!=="tick"?"vertical":"horizontal";if(a&&c)return"vertical";{const u=ae(i)&&i.type===hn,l=ae(r)&&r.type===hn;if(u&&!l)return"vertical";if(!u&&l)return"horizontal"}return}}return"vertical"}const Bx={vgMark:"arc",encodeEntry:e=>({...$e(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...ie("x",e,{defaultPos:"mid"}),...ie("y",e,{defaultPos:"mid"}),...Ft(e,"radius"),...Ft(e,"theta")})},Hx={vgMark:"area",encodeEntry:e=>({...$e(e,{align:"ignore",baseline:"ignore",color:"include",orient:"include",size:"ignore",theta:"ignore"}),...ir("x",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:e.markDef.orient==="horizontal"}),...ir("y",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:e.markDef.orient==="vertical"}),...Zs(e)})},qx={vgMark:"rect",encodeEntry:e=>({...$e(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Ft(e,"x"),...Ft(e,"y")})},Gx={vgMark:"shape",encodeEntry:e=>({...$e(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"})}),postEncodingTransform:e=>{const{encoding:t}=e,n=t.shape,i={type:"geoshape",projection:e.projectionName(),...n&&S(n)&&n.type===yn?{field:w(n,{expr:"datum"})}:{}};return[i]}},Vx={vgMark:"image",encodeEntry:e=>({...$e(e,{align:"ignore",baseline:"ignore",color:"ignore",orient:"ignore",size:"ignore",theta:"ignore"}),...Ft(e,"x"),...Ft(e,"y"),...Ks(e,"url")})},Xx={vgMark:"line",encodeEntry:e=>({...$e(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...ie("x",e,{defaultPos:"mid"}),...ie("y",e,{defaultPos:"mid"}),...J("size",e,{vgChannel:"strokeWidth"}),...Zs(e)})},Yx={vgMark:"trail",encodeEntry:e=>({...$e(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...ie("x",e,{defaultPos:"mid"}),...ie("y",e,{defaultPos:"mid"}),...J("size",e),...Zs(e)})};function Fo(e,t){const{config:n}=e;return{...$e(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...ie("x",e,{defaultPos:"mid"}),...ie("y",e,{defaultPos:"mid"}),...J("size",e),...J("angle",e),...Kx(e,n,t)}}function Kx(e,t,n){return n?{shape:{value:n}}:J("shape",e)}const Qx={vgMark:"symbol",encodeEntry:e=>Fo(e)},Zx={vgMark:"symbol",encodeEntry:e=>Fo(e,"circle")},Jx={vgMark:"symbol",encodeEntry:e=>Fo(e,"square")},eS={vgMark:"rect",encodeEntry:e=>({...$e(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Ft(e,"x"),...Ft(e,"y")})},tS={vgMark:"rule",encodeEntry:e=>{const{markDef:t}=e,n=t.orient;return!e.encoding.x&&!e.encoding.y&&!e.encoding.latitude&&!e.encoding.longitude?{}:{...$e(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...ir("x",e,{defaultPos:n==="horizontal"?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:n!=="vertical"}),...ir("y",e,{defaultPos:n==="vertical"?"zeroOrMax":"mid",defaultPos2:"zeroOrMin",range:n!=="horizontal"}),...J("size",e,{vgChannel:"strokeWidth"})}}},nS={vgMark:"text",encodeEntry:e=>{const{config:t,encoding:n}=e;return{...$e(e,{align:"include",baseline:"include",color:"include",size:"ignore",orient:"ignore",theta:"include"}),...ie("x",e,{defaultPos:"mid"}),...ie("y",e,{defaultPos:"mid"}),...Ks(e),...J("size",e,{vgChannel:"fontSize"}),...J("angle",e),...Hu("align",iS(e.markDef,n,t)),...Hu("baseline",rS(e.markDef,n,t)),...ie("radius",e,{defaultPos:null}),...ie("theta",e,{defaultPos:null})}}};function iS(e,t,n){const i=z("align",e,n);return i===void 0?"center":void 0}function rS(e,t,n){const i=z("baseline",e,n);return i===void 0?"middle":void 0}const sS={vgMark:"rect",encodeEntry:e=>{const{config:t,markDef:n}=e,i=n.orient,r=i==="horizontal"?"width":"height",s=i==="horizontal"?"height":"width";return{...$e(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...ie("x",e,{defaultPos:"mid",vgChannel:"xc"}),...ie("y",e,{defaultPos:"mid",vgChannel:"yc"}),...J("size",e,{defaultValue:oS(e),vgChannel:r}),[s]:U(z("thickness",n,t))}}};function oS(e){const{config:t,markDef:n}=e,{orient:i}=n,r=i==="horizontal"?"width":"height",s=e.getScaleComponent(i==="horizontal"?"x":"y"),o=z("size",n,t,{vgChannel:r})??t.tick.bandSize;if(o!==void 0)return o;{const a=s?s.get("range"):void 0;if(a&&Et(a)&&G(a.step))return a.step*3/4;const c=Zi(t.view,r);return c*3/4}}const $r={arc:Bx,area:Hx,bar:qx,circle:Zx,geoshape:Gx,image:Vx,line:Xx,point:Qx,rect:eS,rule:tS,square:Jx,text:nS,tick:sS,trail:Yx};function aS(e){if(A([Pi,Ai,hg],e.mark)){const t=jc(e.mark,e.encoding);if(t.length>0)return cS(e,t)}else if(e.mark===Oi){const t=qr.some(n=>z(n,e.markDef,e.config));if(e.stack&&!e.fieldDef("size")&&t)return uS(e)}return To(e)}const lf="faceted_path_";function cS(e,t){return[{name:e.getName("pathgroup"),type:"group",from:{facet:{name:lf+e.requestDataName(j.Main),data:e.requestDataName(j.Main),groupby:t}},encode:{update:{width:{field:{group:"width"}},height:{field:{group:"height"}}}},marks:To(e,{fromPrefix:lf})}]}const ff="stack_group_";function uS(e){const[t]=To(e,{fromPrefix:ff}),n=e.scaleName(e.stack.fieldChannel),i=(u={})=>e.vgField(e.stack.fieldChannel,u),r=(u,l)=>{const f=[i({prefix:"min",suffix:"start",expr:l}),i({prefix:"max",suffix:"start",expr:l}),i({prefix:"min",suffix:"end",expr:l}),i({prefix:"max",suffix:"end",expr:l})];return`${u}(${f.map(d=>`scale('${n}',${d})`).join(",")})`};let s,o;e.stack.fieldChannel==="x"?(s={...ln(t.encode.update,["y","yc","y2","height",...qr]),x:{signal:r("min","datum")},x2:{signal:r("max","datum")},clip:{value:!0}},o={x:{field:{group:"x"},mult:-1},height:{field:{group:"height"}}},t.encode.update={...ue(t.encode.update,["y","yc","y2"]),height:{field:{group:"height"}}}):(s={...ln(t.encode.update,["x","xc","x2","width"]),y:{signal:r("min","datum")},y2:{signal:r("max","datum")},clip:{value:!0}},o={y:{field:{group:"y"},mult:-1},width:{field:{group:"width"}}},t.encode.update={...ue(t.encode.update,["x","xc","x2"]),width:{field:{group:"width"}}});for(const u of qr){const l=Dt(u,e.markDef,e.config);t.encode.update[u]?(s[u]=t.encode.update[u],delete t.encode.update[u]):l&&(s[u]=U(l)),l&&(t.encode.update[u]={value:0})}const a=[];if(e.stack.groupbyChannels?.length>0)for(const u of e.stack.groupbyChannels){const l=e.fieldDef(u),f=w(l);f&&a.push(f),(l?.bin||l?.timeUnit)&&a.push(w(l,{binSuffix:"end"}))}const c=["stroke","strokeWidth","strokeJoin","strokeCap","strokeDash","strokeDashOffset","strokeMiterLimit","strokeOpacity"];return s=c.reduce((u,l)=>{if(t.encode.update[l])return{...u,[l]:t.encode.update[l]};{const f=Dt(l,e.markDef,e.config);return f!==void 0?{...u,[l]:U(f)}:u}},s),s.stroke&&(s.strokeForeground={value:!0},s.strokeOffset={value:0}),[{type:"group",from:{facet:{data:e.requestDataName(j.Main),name:ff+e.requestDataName(j.Main),groupby:a,aggregate:{fields:[i({suffix:"start"}),i({suffix:"start"}),i({suffix:"end"}),i({suffix:"end"})],ops:["min","max","min","max"]}}},encode:{update:s},marks:[{type:"group",encode:{update:o},marks:[t]}]}]}function lS(e){const{encoding:t,stack:n,mark:i,markDef:r,config:s}=e,o=t.order;if(!$(o)&&Ae(o)&&Tr(o.value)||!o&&Tr(z("order",r,s)))return;if(($(o)||S(o))&&!n)return Ea(o,{expr:"datum"});if(_t(i)){const a=r.orient==="horizontal"?"y":"x",c=t[a];if(S(c)){const u=c.sort;if($(u))return{field:w(c,{prefix:a,suffix:"sort_index",expr:"datum"})};if(qe(u))return{field:w({aggregate:_s(e.encoding)?u.op:void 0,field:u.field},{expr:"datum"})};if(xc(u)){const l=e.fieldDef(u.encoding);return{field:w(l,{expr:"datum"}),order:u.order}}else return u===null?void 0:{field:w(c,{binSuffix:e.stack?.impute?"mid":void 0,expr:"datum"})}}return}return}function To(e,t={fromPrefix:""}){const{mark:n,markDef:i,encoding:r,config:s}=e,o=V(i.clip,fS(e),dS(e)),a=va(i),c=r.key,u=lS(e),l=pS(e),f=z("aria",i,s),d=$r[n].postEncodingTransform?$r[n].postEncodingTransform(e):null;return[{name:e.getName("marks"),type:$r[n].vgMark,...o?{clip:!0}:{},...a?{style:a}:{},...c?{key:c.field}:{},...u?{sort:u}:{},...l||{},...f===!1?{aria:f}:{},from:{data:t.fromPrefix+e.requestDataName(j.Main)},encode:{update:$r[n].encodeEntry(e)},...d?{transform:d}:{}}]}function fS(e){const t=e.getScaleComponent("x"),n=e.getScaleComponent("y");return t?.get("selectionExtent")||n?.get("selectionExtent")?!0:void 0}function dS(e){const t=e.component.projection;return t&&!t.isFit?!0:void 0}function pS(e){if(!e.component.selection)return null;const t=b(e.component.selection).length;let n=t,i=e.parent;for(;i&&n===0;)n=b(i.component.selection).length,i=i.parent;return n?{interactive:t>0||e.mark==="geoshape"||!!e.encoding.tooltip}:null}class df extends rf{constructor(t,n,i,r={},s){super(t,"unit",n,i,s,void 0,ru(t)?t.view:void 0);this.specifiedScales={},this.specifiedAxes={},this.specifiedLegends={},this.specifiedProjection={},this.selection=[],this.children=[];const o=He(t.mark)?{...t.mark}:{type:t.mark},a=o.type;o.filled===void 0&&(o.filled=Ux(o,s,{graticule:t.data&&Gs(t.data)}));const c=this.encoding=tm(t.encoding||{},a,o.filled,s);this.markDef=Mx(o,c,s),this.size=Lx({encoding:c,size:ru(t)?{...r,...t.width?{width:t.width}:{},...t.height?{height:t.height}:{}}:r}),this.stack=du(this.markDef,c),this.specifiedScales=this.initScales(a,c),this.specifiedAxes=this.initAxes(c),this.specifiedLegends=this.initLegends(c),this.specifiedProjection=t.projection,this.selection=(t.params??[]).filter(u=>Rs(u))}get hasProjection(){const{encoding:t}=this,n=this.mark===ac,i=t&&ed.some(r=>N(t[r]));return n||i}scaleDomain(t){const n=this.specifiedScales[t];return n?n.domain:void 0}axis(t){return this.specifiedAxes[t]}legend(t){return this.specifiedLegends[t]}initScales(t,n){return _i.reduce((i,r)=>{const s=X(n[r]);return s&&(i[r]=this.initScale(s.scale??{})),i},{})}initScale(t){const{domain:n,range:i}=t,r=pe(t);return $(n)&&(r.domain=n.map(he)),$(i)&&(r.range=i.map(he)),r}initAxes(t){return We.reduce((n,i)=>{const r=t[i];if(N(r)||i===B&&N(t.x2)||i===K&&N(t.y2)){const s=N(r)?r.axis:void 0;n[i]=s&&this.initAxis({...s})}return n},{})}initAxis(t){const n=b(t),i={};for(const r of n){const s=t[r];i[r]=Zn(s)?xa(s):he(s)}return i}initLegends(t){return ld.reduce((n,i)=>{const r=X(t[i]);if(r&&dd(i)){const s=r.legend;n[i]=s&&pe(s)}return n},{})}parseData(){this.component.data=vr(this)}parseLayoutSize(){Sx(this)}parseSelections(){this.component.selection=fy(this,this.selection)}parseMarkGroup(){this.component.mark=aS(this)}parseAxesAndHeaders(){this.component.axes=Fx(this)}assembleSelectionTopLevelSignals(t){return Ph(this,t)}assembleSignals(){return[...al(this),...Ah(this,[])]}assembleSelectionData(t){return zh(this,t)}assembleLayout(){return null}assembleLayoutSignals(){return co(this)}assembleMarks(){let t=this.component.mark??[];return(!this.parent||!zn(this.parent))&&(t=Pu(this,t)),t.map(this.correctDataNames)}assembleGroupStyle(){const{style:t}=this.view||{};return t!==void 0?t:this.encoding.x||this.encoding.y?"cell":"view"}getMapping(){return this.encoding}get mark(){return this.markDef.type}channelHasField(t){return Vt(this.encoding,t)}fieldDef(t){const n=this.encoding[t];return Ve(n)}typedFieldDef(t){const n=this.fieldDef(t);return ae(n)?n:null}}class Ao extends _o{constructor(t,n,i,r,s){super(t,"layer",n,i,s,t.resolve,t.view);const o={...r,...t.width?{width:t.width}:{},...t.height?{height:t.height}:{}};this.children=t.layer.map((a,c)=>{if(er(a))return new Ao(a,this,this.getName(`layer_${c}`),o,s);if(ct(a))return new df(a,this,this.getName(`layer_${c}`),o,s);throw new Error(Gr(a))})}parseData(){this.component.data=vr(this);for(const t of this.children)t.parseData()}parseLayoutSize(){bx(this)}parseSelections(){this.component.selection={};for(const t of this.children){t.parseSelections();for(const n of b(t.component.selection))this.component.selection[n]=t.component.selection[n]}}parseMarkGroup(){for(const t of this.children)t.parseMarkGroup()}parseAxesAndHeaders(){Ax(this)}assembleSelectionTopLevelSignals(t){return this.children.reduce((n,i)=>i.assembleSelectionTopLevelSignals(n),t)}assembleSignals(){return this.children.reduce((t,n)=>t.concat(n.assembleSignals()),al(this))}assembleLayoutSignals(){return this.children.reduce((t,n)=>t.concat(n.assembleLayoutSignals()),co(this))}assembleSelectionData(t){return this.children.reduce((n,i)=>i.assembleSelectionData(n),t)}assembleGroupStyle(){const t=new Set;for(const i of this.children)for(const r of H(i.assembleGroupStyle()))t.add(r);const n=Array.from(t);return n.length>1?n:n.length===1?n[0]:void 0}assembleTitle(){let t=super.assembleTitle();if(t)return t;for(const n of this.children)if(t=n.assembleTitle(),t)return t;return}assembleLayout(){return null}assembleMarks(){return Rh(this,this.children.flatMap(t=>t.assembleMarks()))}assembleLegends(){return this.children.reduce((t,n)=>t.concat(n.assembleLegends()),Tl(this))}}function Oo(e,t,n,i,r){if(Mi(e))return new fi(e,t,n,r);if(er(e))return new Ao(e,t,n,i,r);if(ct(e))return new df(e,t,n,i,r);if(_m(e))return new _x(e,t,n,r);throw new Error(Gr(e))}function gS(e,t={}){t.logger&&Op(t.logger),t.fieldTitle&&Tc(t.fieldTitle);try{const n=lu(Go(t.config,e.config)),i=_u(e,n),r=Oo(i,null,"",void 0,n);r.parse(),Pb(r.component.data,r);const s=hS(r,mS(e,i.autosize,n,r),e.datasets,e.usermeta);return{spec:s,normalized:i}}finally{t.logger&&Pp(),t.fieldTitle&&Gg()}}function mS(e,t,n,i){const r=i.component.layoutSize.get("width"),s=i.component.layoutSize.get("height");if(t===void 0?(t={type:"pad"},i.hasAxisOrientSignalRef()&&(t.resize=!0)):F(t)&&(t={type:t}),r&&s&&Ch(t.type)){if(r==="step"&&s==="step")x(Ta()),t.type="pad";else if(r==="step"||s==="step"){const o=r==="step"?"width":"height";x(Ta(Ei(o)));const a=o==="width"?"height":"width";t.type=Nh(a)}}return{...b(t).length===1&&t.type?t.type==="pad"?{}:{autosize:t.type}:{autosize:t},...Cu(n,!1),...Cu(e,!0)}}function hS(e,t,n={},i){const r=e.config?Dm(e.config):void 0,s=[].concat(e.assembleSelectionData([]),gx(e.component.data,n)),o=e.assembleProjections(),a=e.assembleTitle(),c=e.assembleGroupStyle(),u=e.assembleGroupEncodeEntry(!0);let l=e.assembleLayoutSignals();l=l.filter(p=>(p.name==="width"||p.name==="height")&&p.value!==void 0?(t[p.name]=+p.value,!1):!0);const{params:f,...d}=t;return{$schema:"https://vega.github.io/schema/vega/v5.json",...e.description?{description:e.description}:{},...d,...a?{title:a}:{},...c?{style:c}:{},...u?{encode:{update:u}}:{},data:s,...o.length>0?{projections:o}:{},...e.assembleGroup([...l,...e.assembleSelectionTopLevelSignals([]),...nu(f)]),...r?{config:r}:{},...i?{usermeta:i}:{}}}const yS=Xf.version;export{fn as accessPathDepth,Rr as accessPathWithDatum,gS as compile,A as contains,Ie as deepEqual,yi as deleteNestedProperty,C as duplicate,mt as entries,Ar as every,zr as fieldIntersection,Qo as flatAccessWithDatum,V as getFirstDefined,Or as hasIntersection,O as hash,ea as internalField,Mn as isBoolean,R as isEmpty,Kf as isEqual,ta as isInternalField,Tr as isNullOrFalse,bi as isNumeric,b as keys,Dn as logicalExpr,Yo as mergeDeep,Xo as never,_u as normalize,Un as normalizeAngle,ue as omit,ln as pick,Pr as prefixGenerator,Ir as removePathFromField,zt as replaceAll,xe as replacePathInField,Zf as resetIdCounter,Ko as setEqual,Pt as some,M as stringify,jn as titleCase,Le as unique,Jo as uniqueId,ee as vals,W as varName,yS as version};export default null;