import{hasOwnProperty as an,isNumber as V,isString as N,writeConfig as Ff,splitAccessPath as cn,stringValue as A,isObject as L,isBoolean as jn,isArray as v,array as q,logger as Nf,Warn as Tf,isFunction as Af,mergeConfig as Ko,identity as Of}from"/-/vega-util@v1.17.2-LUfkDhormMyfWqy3Ts6U/dist=es2020,mode=imports,min/optimized/vega-util.js";import Pf from"/-/clone@v2.1.2-inH2VLNzDGiYU9HUWyZM/dist=es2020,mode=imports,min/optimized/clone.js";import zf from"/-/fast-deep-equal@v3.1.3-ysejKs1WDEDPxUJhgGoP/dist=es2020,mode=imports,min/optimized/fast-deep-equal.js";import kr from"/-/fast-json-stable-stringify@v2.1.0-HLgsuOtxPikt0pw16nth/dist=es2020,mode=imports,min/optimized/fast-json-stable-stringify.js";import{isObject as Cr,writeConfig as Rf,isArray as Qo,isString as mi}from"/-/vega@v5.30.0-fYDVG3pUN16BiGmbVNdw/dist=es2020,mode=imports,min/optimized/vega.js";import{parseSelector as un}from"/-/vega-event-selector@v3.0.1-UgiEAWJA4WQL4DTKnV4R/dist=es2020,mode=imports,min/optimized/vega-event-selector.js";import{parseExpression as If}from"/-/vega-expression@v5.1.1-K4clrYr2THuj5KncykTn/dist=es2020,mode=imports,min/optimized/vega-expression.js";const Lf="vega-lite",Mf='Dominik Moritz, Kanit "Ham" Wongsuphasawat, Arvind Satyanarayan, Jeffrey Heer',Df="5.14.1",jf=["Kanit Wongsuphasawat (http://kanitw.yellowpigz.com)","Dominik Moritz (https://www.domoritz.de)","Arvind Satyanarayan (https://arvindsatya.com)","Jeffrey Heer (https://jheer.org)"],Uf="https://vega.github.io/vega-lite/",Bf="Vega-Lite is a concise high-level language for interactive visualization.",Wf=["vega","chart","visualization"],Hf="build/vega-lite.js",qf="build/vega-lite.min.js",Gf="build/vega-lite.min.js",Vf="build/src/index",Xf="build/src/index.d.ts",Yf={vl2pdf:"./bin/vl2pdf",vl2png:"./bin/vl2png",vl2svg:"./bin/vl2svg",vl2vg:"./bin/vl2vg"},Kf=["bin","build","src","vega-lite*","tsconfig.json"],Qf={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"},Zf={type:"git",url:"https://github.com/vega/vega-lite.git"},Jf="BSD-3-Clause",ed={url:"https://github.com/vega/vega-lite/issues"},td={"@babel/core":"^7.21.8","@babel/plugin-proposal-class-properties":"^7.18.6","@babel/preset-env":"^7.21.5","@babel/preset-typescript":"^7.21.5","@release-it/conventional-changelog":"^7.0.0","@rollup/plugin-alias":"^5.0.0","@rollup/plugin-babel":"^6.0.3","@rollup/plugin-commonjs":"^25.0.0","@rollup/plugin-json":"^6.0.0","@rollup/plugin-node-resolve":"^15.0.2","@rollup/plugin-terser":"^0.4.1","@types/chai":"^4.3.5","@types/d3":"^7.4.0","@types/jest":"^27.4.1","@types/pako":"^2.0.0","@typescript-eslint/eslint-plugin":"^5.59.5","@typescript-eslint/parser":"^5.59.5",ajv:"^8.12.0","ajv-formats":"^2.1.1",chai:"^4.3.7",cheerio:"^1.0.0-rc.12","conventional-changelog-cli":"^3.0.0",d3:"^7.8.4","del-cli":"^5.0.0",eslint:"^8.40.0","eslint-config-prettier":"^8.8.0","eslint-plugin-jest":"^27.2.1","eslint-plugin-prettier":"^4.2.1","highlight.js":"^11.8.0",jest:"^27.5.1","jest-dev-server":"^6.1.1",mkdirp:"^3.0.1",pako:"^2.1.0",prettier:"^2.8.8",puppeteer:"^15.0.0","release-it":"^16.1.2",rollup:"^3.21.6","rollup-plugin-bundle-size":"^1.0.3","rollup-plugin-sourcemaps":"^0.6.3",serve:"^14.2.0",terser:"^5.17.3","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"},nd={"@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.2"},id={vega:"^5.24.0"},rd={node:">=16"};var sd={name:Lf,author:Mf,version:Df,collaborators:jf,homepage:Uf,description:Bf,keywords:Wf,main:Hf,unpkg:qf,jsdelivr:Gf,module:Vf,types:Xf,bin:Yf,files:Kf,scripts:Qf,repository:Zf,license:Jf,bugs:ed,devDependencies:td,dependencies:nd,peerDependencies:id,engines:rd};function Fr(e){return!!e.or}function Nr(e){return!!e.and}function Tr(e){return!!e.not}function hi(e,t){if(Tr(e))hi(e.not,t);else if(Nr(e))for(const n of e.and)hi(n,t);else if(Fr(e))for(const n of e.or)hi(n,t);else t(e)}function ln(e,t){return Tr(e)?{not:ln(e.not,t)}:Nr(e)?{and:e.and.map(n=>ln(n,t))}:Fr(e)?{or:e.or.map(n=>ln(n,t))}:t(e)}const De=zf,k=Pf;function Zo(e){throw new Error(e)}function fn(e,t){const n={};for(const i of t)an(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=>kr(e)).join(",")})`};const D=kr;function O(e){if(V(e))return e;const t=N(e)?e:kr(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 Rr(e,t){return e===void 0||t===void 0?!0:Pr(zr(e),zr(t))}function I(e){return b(e).length===0}const b=Object.keys,te=Object.values,bt=Object.entries;function Un(e){return e===!0||e===!1}function W(e){const t=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+t}function Bn(e,t){return Tr(e)?`!(${Bn(e.not,t)})`:Nr(e)?`(${e.and.map(n=>Bn(n,t)).join(") && (")})`:Fr(e)?`(${e.or.map(n=>Bn(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],I(e)}function Wn(e){return e.charAt(0).toUpperCase()+e.substr(1)}function Ir(e,t="datum"){const n=cn(e),i=[];for(let r=1;r<=n.length;r++){const s=`[${n.slice(0,r).map(A).join("][")}]`;i.push(`${t}${s}`)}return i.join(" && ")}function ta(e,t="datum"){return`${t}[${A(cn(e).join("."))}]`}function cd(e){return e.replace(/(\[|\]|\.|'|")/g,"\\$1")}function Se(e){return`${cn(e).map(cd).join("\\.")}`}function Lt(e,t,n){return e.replace(new RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),n)}function Lr(e){return`${cn(e).join(".")}`}function dn(e){return e?cn(e).length:0}function X(...e){for(const t of e)if(t!==void 0)return t;return}let na=42;function ia(e){const t=++na;return e?String(e)+t:t}function ud(){na=42}function ra(e){return sa(e)?e:`__${e}`}function sa(e){return e.startsWith("__")}function Hn(e){return e===void 0?void 0:(e%360+360)%360}function bi(e){return V(e)?!0:!isNaN(e)&&!isNaN(parseFloat(e))}const nt="row",it="column",xi="facet",H="x",K="y",_e="x2",Ue="y2",xt="xOffset",pn="yOffset",ke="radius",rt="radius2",we="theta",st="theta2",Ce="latitude",Fe="longitude",Ne="latitude2",$e="longitude2",le="color",Be="fill",We="stroke",fe="shape",ot="size",Mt="angle",at="opacity",St="fillOpacity",wt="strokeOpacity",$t="strokeWidth",vt="strokeDash",qn="text",gn="order",Gn="detail",Si="key",Dt="tooltip",wi="href",$i="url",vi="description",ld={x:1,y:1,x2:1,y2:1},oa={theta:1,theta2:1,radius:1,radius2:1};function aa(e){return e in oa}const Mr={longitude:1,longitude2:1,latitude:1,latitude2:1};function ca(e){switch(e){case Ce:return"y";case Ne:return"y2";case Fe:return"x";case $e:return"x2"}}function ua(e){return e in Mr}const fd=b(Mr),Dr={...ld,...oa,...Mr,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 mn(e){return e===le||e===Be||e===We}const la={row:1,column:1,facet:1},ve=b(la),jr={...Dr,...la},dd=b(jr),{order:MS,detail:DS,tooltip:jS,...pd}=jr,{row:US,column:BS,facet:WS,...gd}=pd;function md(e){return!!gd[e]}function fa(e){return!!jr[e]}const hd=[_e,Ue,Ne,$e,st,rt];function da(e){const t=jt(e);return t!==e}function jt(e){switch(e){case _e:return H;case Ue:return K;case Ne:return Ce;case $e:return Fe;case st:return we;case rt:return ke}return e}function Et(e){if(aa(e))switch(e){case we:return"startAngle";case st:return"endAngle";case ke:return"outerRadius";case rt:return"innerRadius"}return e}function He(e){switch(e){case H:return _e;case K:return Ue;case Ce:return Ne;case Fe:return $e;case we:return st;case ke:return rt}return}function de(e){switch(e){case H:case _e:return"width";case K:case Ue:return"height"}return}function pa(e){switch(e){case H:return"xOffset";case K:return"yOffset";case _e:return"x2Offset";case Ue:return"y2Offset";case we:return"thetaOffset";case ke:return"radiusOffset";case st:return"theta2Offset";case rt:return"radius2Offset"}return}function Ur(e){switch(e){case H:return"xOffset";case K:return"yOffset"}return}function ga(e){switch(e){case"xOffset":return"x";case"yOffset":return"y"}}const yd=b(Dr),{x:HS,y:qS,x2:GS,y2:VS,xOffset:XS,yOffset:YS,latitude:KS,longitude:QS,latitude2:ZS,longitude2:JS,theta:ew,theta2:tw,radius:nw,radius2:iw,...Br}=Dr,bd=b(Br),Wr={x:1,y:1},qe=b(Wr);function Q(e){return e in Wr}const Hr={theta:1,radius:1},xd=b(Hr);function Ei(e){return e==="width"?H:K}const ma={xOffset:1,yOffset:1};function hn(e){return e in ma}const{text:rw,tooltip:sw,href:ow,url:aw,description:cw,detail:uw,key:lw,order:fw,...ha}=Br,Sd=b(ha);function wd(e){return!!Br[e]}function $d(e){switch(e){case le:case Be:case We:case ot:case fe:case at:case $t:case vt:return!0;case St:case wt:case Mt:return!1}}const ya={...Wr,...Hr,...ma,...ha},_i=b(ya);function ct(e){return!!ya[e]}function vd(e,t){return _d(e)[t]}const ba={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:dw,...Ed}=ba;function _d(e){switch(e){case le:case Be:case We:case vi:case Gn:case Si:case Dt:case wi:case gn:case at:case St:case wt:case $t:case xi:case nt:case it:return ba;case H:case K:case xt:case pn:case Ce:case Fe:return Ed;case _e:case Ue:case Ne:case $e:return{area:"always",bar:"always",image:"always",rect:"always",rule:"always",circle:"binned",point:"binned",square:"binned",tick:"binned",line:"binned",trail:"binned"};case ot:return{point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",text:"always",line:"always",trail:"always"};case vt: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 qn:return{text:"always"};case Mt:return{point:"always",square:"always",text:"always"};case $i:return{image:"always"};case we:return{text:"always",arc:"always"};case ke:return{text:"always",arc:"always"};case st:case rt:return{arc:"always"}}}function qr(e){switch(e){case H:case K:case we:case ke:case xt:case pn:case ot:case Mt:case $t:case at:case St:case wt:case _e:case Ue:case st:case rt:return;case xi:case nt:case it:case fe:case vt:case qn:case Dt:case wi:case $i:case vi:return"discrete";case le:case Be:case We:return"flexible";case Ce:case Fe:case Ne:case $e:case Gn:case Si:case gn:return}}const kd={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},Cd={count:1,min:1,max:1};function ut(e){return!!e&&!!e.argmin}function _t(e){return!!e&&!!e.argmax}function Gr(e){return N(e)&&!!kd[e]}const Fd=new Set(["count","valid","missing","distinct"]);function xa(e){return N(e)&&Fd.has(e)}function Nd(e){return N(e)&&P(["min","max"],e)}const Td=new Set(["count","sum","distinct","valid","missing"]),Ad=new Set(["mean","average","median","q1","q3","min","max"]);function Sa(e){return jn(e)&&(e=qi(e,void 0)),"bin"+b(e).map(t=>ki(e[t])?W(`_${t}_${bt(e[t])}`):W(`_${t}_${e[t]}`)).join("")}function j(e){return e===!0||Ut(e)&&!e.binned}function ne(e){return e==="binned"||Ut(e)&&e.binned===!0}function Ut(e){return L(e)}function ki(e){return e?.param}function wa(e){switch(e){case nt:case it:case ot:case le:case Be:case We:case $t:case at:case St:case wt:case fe:return 6;case vt:return 4;default:return 10}}function Vn(e){return!!e?.expr}function pe(e){const t=b(e||{}),n={};for(const i of t)n[i]=ye(e[i]);return n}function $a(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}:{}},$={...c?{subtitleColor:c}:{},...u?{subtitleFont:u}:{},...l?{subtitleFontSize:l}:{},...f?{subtitleFontStyle:f}:{},...d?{subtitleFontWeight:d}:{},...p?{subtitleLineHeight:p}:{},...g?{subtitlePadding:g}:{}},C=fn(e,["align","baseline","dx","dy","limit"]);return{titleMarkConfig:h,subtitleMarkConfig:C,nonMarkTitleProperties:y,subtitle:$}}function kt(e){return N(e)||v(e)&&N(e[0])}function E(e){return!!e?.signal}function Ct(e){return!!e.step}function Od(e){return v(e)?!1:"fields"in e&&!("data"in e)}function Pd(e){return v(e)?!1:"fields"in e&&"data"in e}function lt(e){return v(e)?!1:"field"in e&&"data"in e}const zd={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},Rd=b(zd),Id={arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1},Vr=["cornerRadius","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight"];function va(e){const t=v(e.condition)?e.condition.map(Ea):Ea(e.condition);return{...ye(e),condition:t}}function ye(e){if(Vn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return e}function Ea(e){if(Vn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return e}function B(e){if(Vn(e)){const{expr:t,...n}=e;return{signal:t,...n}}return E(e)?e:e!==void 0?{value:e}:void 0}function Ld(e){return E(e)?e.signal:A(e)}function _a(e){return E(e)?e.signal:A(e.value)}function Te(e){return E(e)?e.signal:e==null?null:A(e)}function Md(e,t,n){for(const i of n){const r=ft(i,t.markDef,t.config);r!==void 0&&(e[i]=B(r))}return e}function ka(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:ft(e,t,n,i)}function ft(e,t,n,{vgChannel:i}={}){return X(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 Ca(e,ka(t),n)}function Ca(e,t,n){t=q(t);let i;for(const r of t){const s=n[r];s&&s[e]!==void 0&&(i=s[e])}return i}function Fa(e,t){return q(e).reduce((n,i)=>(n.field.push(w(i,t)),n.order.push(i.sort??"ascending"),n),{field:[],order:[]})}function Na(e,t){const n=[...e];return t.forEach(i=>{for(const r of n)if(De(r,i))return;n.push(i)}),n}function Ta(e,t){return De(e,t)||!t?e:e?[...q(e),...q(t)].join(", "):t}function Aa(e,t){const n=e.value,i=t.value;if(n==null||i===null)return{explicit:e.explicit,value:null};if((kt(n)||E(n))&&(kt(i)||E(i)))return{explicit:e.explicit,value:Ta(n,i)};if(kt(n)||E(n))return{explicit:e.explicit,value:n};if(kt(i)||E(i))return{explicit:e.explicit,value:i};if(!kt(n)&&!E(n)&&!kt(i)&&!E(i))return{explicit:e.explicit,value:Na(n,i)};throw new Error("It should never reach here")}function Xr(e){return`Invalid specification ${D(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`}const Dd='Autosize "fit" only works for single views and layered views.';function Oa(e){const t=e=="width"?"Width":"Height";return`${t} "container" only works for single views and layered views.`}function Pa(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 za(e){return e?`Dropping "fit-${e}" because spec has discrete ${de(e)}.`:'Dropping "fit" because spec has discrete size.'}function Yr(e){return`Unknown field for ${e}. Cannot calculate view size.`}function Ra(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`}function jd(e,t){return`Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${t}").`}function Ud(e){return`The "nearest" transform is not supported for ${e} marks.`}function Ia(e){return`Selection not supported for ${e} yet.`}function Bd(e){return`Cannot find a selection named "${e}".`}const Wd="Scale bindings are currently only supported for scales with unbinned, continuous domains.",Hd="Legend bindings are only supported for selections over an individual field or encoding channel.";function qd(e){return`Lookups can only be performed on selection parameters. "${e}" is a variable parameter.`}function Gd(e){return`Cannot define and lookup the "${e}" selection in the same view. Try moving the lookup into a second, layered view?`}const Vd="The same selection must be used to override scale domains in a layered view.",Xd='Interval selections should be initialized using "x", "y", "longitude", or "latitude" keys.';function Yd(e){return`Unknown repeated value "${e}".`}function La(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`}const Kd="Axes cannot be shared in concatenated or repeated views yet (https://github.com/vega/vega-lite/issues/2415).";function Qd(e){return`Unrecognized parse "${e}".`}function Ma(e,t,n){return`An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.`}const Zd="Attempt to add the same child twice.";function Jd(e){return`Ignoring an invalid transform: ${D(e)}.`}const ep='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 Da(e){return`Config.customFormatTypes is not true, thus custom format type and format for channel ${e} are dropped.`}function tp(e){const{parentProjection:t,projection:n}=e;return`Layer's shared projection ${D(t)} is overridden by a child projection ${D(n)}.`}const np="Arc marks uses theta channel rather than angle, replacing angle with theta.";function ip(e){return`${e}Offset dropped because ${e} is continuous`}function rp(e){return`There is no ${e} encoding. Replacing ${e}Offset encoding as ${e}.`}function sp(e,t,n){return`Channel ${e} is a ${t}. Converted to {value: ${D(n)}}.`}function ja(e){return`Invalid field type "${e}".`}function op(e,t){return`Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.`}function ap(e){return`Invalid aggregation operator "${e}".`}function Ua(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 cp(e){return`Position range does not support relative band size for ${e}.`}function Kr(e,t){return`Dropping ${D(e)} from channel "${t}" since it does not contain any data field, datum, value, or signal.`}const up="Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.";function Fi(e,t,n){return`${e} dropped as it is incompatible with "${t}"${n?` when ${n}`:""}.`}function lp(e){return`${e} encoding has no scale, so specified scale is ignored.`}function fp(e){return`${e}-encoding is dropped as ${e} is not a valid encoding channel.`}function dp(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`}function pp(e){return`${e} encoding should be discrete (ordinal / nominal / binned) or use a discretizing scale (e.g. threshold).`}function gp(e){return`Facet encoding dropped as ${e.join(" and ")} ${e.length>1?"are":"is"} also specified.`}function Qr(e,t){return`Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${t==="ordinal"?"order":"magnitude"}.`}function mp(e){return`The ${e} for range marks cannot be an expression`}function hp(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 yp(e,t){return`Specified orient "${e}" overridden with "${t}".`}function bp(e){return`Cannot use the scale property "${e}" with non-color channel.`}function xp(e){return`Cannot use the relative band size with ${e} scale.`}function Sp(e){return`Using unaggregated domain with raw field has no effect (${D(e)}).`}function wp(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`}function $p(e){return`Unaggregated domain is currently unsupported for log scale (${D(e)}).`}function vp(e){return`Cannot apply size to non-oriented mark "${e}".`}function Ep(e,t,n){return`Channel "${e}" does not work with "${t}" scale. We are using "${n}" scale instead.`}function _p(e,t){return`FieldDef does not work with "${e}" scale. We are using "${t}" scale instead.`}function Ba(e,t,n){return`${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`}function Wa(e){return`The step for "${e}" is dropped because the ${e==="width"?"x":"y"} is continuous.`}function kp(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${D(n)} and ${D(i)}). Using ${D(n)}.`}function Cp(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${D(n)} and ${D(i)}). Using the union of the two domains.`}function Fp(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 Np(e){return`Dropping sort property ${D(e)} as unioned domains only support boolean or op "count", "min", and "max".`}const Ha="Domains that should be unioned has conflicting sort properties. Sort will be set to true.",Tp="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.",Ap="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.",Op="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 Pp(e){return`Cannot stack "${e}" if there is already "${e}2".`}function zp(e){return`Cannot stack non-linear scale (${e}).`}function Rp(e){return`Stacking is applied even though the aggregate function is non-summative ("${e}").`}function Ni(e,t){return`Invalid ${e}: ${D(t)}.`}function Ip(e){return`Dropping day from datetime ${D(e)} as day cannot be combined with other units.`}function Lp(e,t){return`${t?"extent ":""}${t&&e?"and ":""}${e?"center ":""}${t&&e?"are ":"is "}not needed when data are aggregated.`}function Mp(e,t,n){return`${e} is not usually used with ${t} for ${n}.`}function Dp(e,t){return`Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.`}function qa(e){return`1D error band does not support ${e}.`}function Ga(e){return`Channel ${e} is required for "binned" bin.`}function jp(e){return`Channel ${e} should not be used with "binned" bin.`}function Up(e){return`Domain for ${e} is required for threshold scale.`}var pw=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},gw=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 Va=Nf(Tf);let yn=Va;function Bp(e){return yn=e,yn}function Wp(){return yn=Va,yn}function x(...e){yn.warn(...e)}function Hp(...e){yn.debug(...e)}function Bt(e){if(e&&L(e)){for(const t of Jr)if(t in e)return!0}return!1}const Xa=["january","february","march","april","may","june","july","august","september","october","november","december"],qp=Xa.map(e=>e.substr(0,3)),Ya=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Gp=Ya.map(e=>e.substr(0,3));function Vp(e){if(bi(e)&&(e=+e),V(e))return e>4&&x(Ni("quarter",e)),e-1;throw new Error(Ni("quarter",e))}function Xp(e){if(bi(e)&&(e=+e),V(e))return e-1;{const t=e.toLowerCase(),n=Xa.indexOf(t);if(n!==-1)return n;const i=t.substr(0,3),r=qp.indexOf(i);if(r!==-1)return r;throw new Error(Ni("month",e))}}function Yp(e){if(bi(e)&&(e=+e),V(e))return e%7;{const t=e.toLowerCase(),n=Ya.indexOf(t);if(n!==-1)return n;const i=t.substr(0,3),r=Gp.indexOf(i);if(r!==-1)return r;throw new Error(Ni("day",e))}}function Zr(e,t){const n=[];if(t&&e.day!==void 0&&(b(e).length>1&&(x(Ip(e)),e=k(e),delete e.day)),e.year!==void 0?n.push(e.year):n.push(2012),e.month!==void 0){const i=t?Xp(e.month):e.month;n.push(i)}else if(e.quarter!==void 0){const i=t?Vp(e.quarter):e.quarter;n.push(V(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?Yp(e.day):e.day;n.push(V(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 Wt(e){const t=Zr(e,!0),n=t.join(", ");return e.utc?`utc(${n})`:`datetime(${n})`}function Kp(e){const t=Zr(e,!1),n=t.join(", ");return e.utc?`utc(${n})`:`datetime(${n})`}function Qp(e){const t=Zr(e,!0);return e.utc?+new Date(Date.UTC(...t)):+new Date(...t)}const Ka={year:1,quarter:1,month:1,week:1,day:1,dayofyear:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},Jr=b(Ka);function Zp(e){return!!Ka[e]}function Ht(e){return L(e)?e.binned:Qa(e)}function Qa(e){return e&&e.startsWith("binned")}function es(e){return e.startsWith("utc")}function Jp(e){return e.substring(3)}const eg={"year-month":"%b %Y ","year-month-date":"%b %d, %Y "};function Ti(e){return Jr.filter(t=>Ja(e,t))}function Za(e){const t=Ti(e);return t[t.length-1]}function Ja(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 tg(e,t,{end:n}={end:!1}){const i=Ir(t),r=es(e)?"utc":"";function s(c){return c==="quarter"?`(${r}quarter(${i})-1)`:`${r}${c}(${i})`}let o;const a={};for(const c of Jr)Ja(e,c)&&(a[c]=s(c),o=c);return n&&(a[o]+="+1"),Kp(a)}function ec(e){if(!e)return;const t=Ti(e);return`timeUnitSpecifier(${D(t)}, ${D(eg)})`}function ng(e,t,n){if(!e)return;const i=ec(e),r=n||es(e);return`${r?"utc":"time"}Format(${t}, ${i})`}function Z(e){if(!e)return;let t;return N(e)?Qa(e)?t={unit:e.substring(6),binned:!0}:t={unit:e}:L(e)&&(t={...e,...e.unit?{unit:e.unit}:{}}),es(t.unit)&&(t.utc=!0,t.unit=Jp(t.unit)),t}function ig(e){const{utc:t,...n}=Z(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 tc(e,t=n=>n){const n=Z(e),i=Za(n.unit);if(i&&i!=="day"){const r={year:2001,month:1,date:1,hours:0,minutes:0,seconds:0,milliseconds:0},{step:s,part:o}=nc(i,n.step),a={...r,[o]:+r[o]+s};return`${t(Wt(a))} - ${t(Wt(r))}`}return}const rg={year:1,month:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1};function sg(e){return!!rg[e]}function nc(e,t=1){if(sg(e))return{part:e,step:t};switch(e){case"day":case"dayofyear":return{part:"date",step:t};case"quarter":return{part:"month",step:t*3};case"week":return{part:"date",step:t*7}}}function og(e){return e?.param}function ts(e){return!!e?.field&&e.equal!==void 0}function ns(e){return!!e?.field&&e.lt!==void 0}function is(e){return!!e?.field&&e.lte!==void 0}function rs(e){return!!e?.field&&e.gt!==void 0}function ss(e){return!!e?.field&&e.gte!==void 0}function os(e){if(e?.field){if(v(e.range)&&e.range.length===2)return!0;if(E(e.range))return!0}return!1}function as(e){return!!e?.field&&(v(e.oneOf)||v(e.in))}function ag(e){return!!e?.field&&e.valid!==void 0}function ic(e){return as(e)||ts(e)||os(e)||ns(e)||rs(e)||is(e)||ss(e)}function Ge(e,t){return Gi(e,{timeUnit:t,wrapTime:!0})}function cg(e,t){return e.map(n=>Ge(n,t))}function rc(e,t=!0){const{field:n}=e,i=Z(e.timeUnit),{unit:r,binned:s}=i||{},o=w(e,{expr:"datum"}),a=r?`time(${s?o:tg(r,n)})`:o;if(ts(e))return`${a}===${Ge(e.equal,r)}`;if(ns(e)){const c=e.lt;return`${a}<${Ge(c,r)}`}else if(rs(e)){const c=e.gt;return`${a}>${Ge(c,r)}`}else if(is(e)){const c=e.lte;return`${a}<=${Ge(c,r)}`}else if(ss(e)){const c=e.gte;return`${a}>=${Ge(c,r)}`}else{if(as(e))return`indexof([${cg(e.oneOf,r).join(",")}], ${a}) !== -1`;if(ag(e))return cs(a,e.valid);if(os(e)){const{range:c}=e,u=E(c)?{signal:`${c.signal}[0]`}:c[0],l=E(c)?{signal:`${c.signal}[1]`}:c[1];if(u!==null&&l!==null&&t)return"inrange("+a+", ["+Ge(u,r)+", "+Ge(l,r)+"])";const f=[];return u!==null&&f.push(`${a} >= ${Ge(u,r)}`),l!==null&&f.push(`${a} <= ${Ge(l,r)}`),f.length>0?f.join(" && "):"true"}}throw new Error(`Invalid field predicate: ${D(e)}`)}function cs(e,t=!0){return t?`isValid(${e}) && isFinite(+${e})`:`!isValid(${e}) || !isFinite(+${e})`}function ug(e){return ic(e)&&e.timeUnit?{...e,timeUnit:Z(e.timeUnit)}:e}const Xn={quantitative:"quantitative",ordinal:"ordinal",temporal:"temporal",nominal:"nominal",geojson:"geojson"};function lg(e){return e==="quantitative"||e==="temporal"}function sc(e){return e==="ordinal"||e==="nominal"}const qt=Xn.quantitative,us=Xn.ordinal,bn=Xn.temporal,ls=Xn.nominal,xn=Xn.geojson;function fg(e){if(e){e=e.toLowerCase();switch(e){case"q":case qt:return"quantitative";case"t":case bn:return"temporal";case"o":case us:return"ordinal";case"n":case ls:return"nominal";case xn: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"},fs={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 dg(e,t){const n=fs[e],i=fs[t];return n===i||n==="ordinal-position"&&i==="time"||i==="ordinal-position"&&n==="time"}const pg={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 oc(e){return pg[e]}const ac=new Set(["linear","log","pow","sqrt","symlog"]),cc=new Set([...ac,"time","utc"]);function uc(e){return ac.has(e)}const lc=new Set(["quantile","quantize","threshold"]),gg=new Set([...cc,...lc,"sequential","identity"]),mg=new Set(["ordinal","bin-ordinal","point","band"]);function J(e){return mg.has(e)}function be(e){return gg.has(e)}function Ae(e){return cc.has(e)}function Sn(e){return lc.has(e)}const hg={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 yg(e){return!N(e)&&!!e.name}function fc(e){return e?.param}function bg(e){return e?.unionWith}function xg(e){return Cr(e)&&"field"in e}const Sg={type:1,domain:1,domainMax:1,domainMin:1,domainMid:1,domainRaw:1,align:1,range:1,rangeMax:1,rangeMin:1,scheme:1,bins:1,reverse:1,round:1,clamp:1,nice:1,base:1,exponent:1,constant:1,interpolate:1,zero:1,padding:1,paddingInner:1,paddingOuter:1},{type:mw,domain:hw,range:yw,rangeMax:bw,rangeMin:xw,scheme:Sw,...wg}=Sg,$g=b(wg);function ds(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 Ae(e)||e==="band"||e==="point";case"padding":case"rangeMin":case"rangeMax":return Ae(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"domainRaw":case"clamp":return Ae(e);case"nice":return Ae(e)||e==="quantize"||e==="threshold";case"exponent":return e==="pow";case"base":return e==="log";case"constant":return e==="symlog";case"zero":return be(e)&&!P(["log","time","utc","threshold","quantile"],e)}}function dc(e,t){switch(t){case"interpolate":case"scheme":case"domainMid":return mn(e)?void 0:bp(t);case"align":case"type":case"bins":case"domain":case"domainMax":case"domainMin":case"domainRaw":case"range":case"base":case"exponent":case"constant":case"nice":case"padding":case"paddingInner":case"paddingOuter":case"rangeMax":case"rangeMin":case"reverse":case"round":case"clamp":case"zero":return}}function vg(e,t){return P([us,ls],t)?e===void 0||J(e):t===bn?P([ge.TIME,ge.UTC,void 0],e):t===qt?uc(e)||Sn(e)||e===void 0:!0}function Eg(e,t,n=!1){if(!ct(e))return!1;switch(e){case H:case K:case xt:case pn:case we:case ke:return Ae(t)||t==="band"?!0:t==="point"?!n:!1;case ot:case $t:case at:case St:case wt:case Mt:return Ae(t)||Sn(t)||P(["band","point","ordinal"],t);case le:case Be:case We:return t!=="band";case vt:case fe:return t==="ordinal"||Sn(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"},pc=oe.arc,Ai=oe.area,Oi=oe.bar,_g=oe.image,Pi=oe.line,zi=oe.point,kg=oe.rect,Ri=oe.rule,gc=oe.text,ps=oe.tick,Cg=oe.trail,gs=oe.circle,ms=oe.square,mc=oe.geoshape;function Ft(e){return["line","area","trail"].includes(e)}function hs(e){return["rect","bar","image","arc"].includes(e)}const Fg=new Set(b(oe));function Ve(e){return e.type}const Ng=["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit"],Tg=["fill","fillOpacity"],Ag=[...Ng,...Tg],Og={color:1,filled:1,invalid:1,order:1,radius2:1,theta2:1,timeUnitBandSize:1,timeUnitBandPosition:1},hc=b(Og),Pg={area:["line","point"],bar:["binSpacing","continuousBandSize","discreteBandSize","minBandSize"],rect:["binSpacing","continuousBandSize","discreteBandSize","minBandSize"],line:["point"],tick:["bandSize","thickness"]},zg={color:"#4c78a8",invalid:"filter",timeUnitBandSize:1},Rg={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},yc=b(Rg);function Gt(e){return e&&e.band!=null}const Ig={horizontal:["cornerRadiusTopRight","cornerRadiusBottomRight"],vertical:["cornerRadiusTopLeft","cornerRadiusTopRight"]},bc=5,Lg={binSpacing:1,continuousBandSize:bc,minBandSize:.25,timeUnitBandPosition:.5},Mg={binSpacing:0,continuousBandSize:bc,minBandSize:.25,timeUnitBandPosition:.5},Dg={thickness:1};function jg(e){return Ve(e)?e.type:e}function ys(e){const{channel:t,channelDef:n,markDef:i,scale:r,config:s}=e,o=xs(e);return S(n)&&!xa(n.aggregate)&&r&&Ae(r.get("type"))?Ug({fieldDef:n,channel:t,markDef:i,ref:o,config:s}):o}function Ug({fieldDef:e,channel:t,markDef:n,ref:i,config:r}){if(Ft(n.type))return i;const s=z("invalid",n,r);return s===null?[Bg(e,t),i]:i}function Bg(e,t){const n=bs(e,!0),i=jt(t),r=i==="y"?{field:{group:"height"}}:{value:0};return{test:n,...r}}function bs(e,t=!0){return cs(N(e)?e:w(e,{expr:"datum"}),!t)}function Wg(e){const{datum:t}=e;return Bt(t)?Wt(t):`${D(t)}`}function Vt(e,t,n,i){const r={};if(t&&(r.scale=t),Ye(e)){const{datum:s}=e;Bt(s)?r.signal=Wt(s):E(s)?r.signal=s.signal:Vn(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 im(e);default:return nm(e,t)}};let Lc=Ic;function Mc(e){Lc=e}function rm(){Mc(Ic)}function vn(e,t,{allowDisabling:n,includeDefault:i=!0}){const r=Es(e)?.title;if(!S(e))return r??e.title;const s=e,o=i?_s(s,t):void 0;return n?X(r,s.title,o):r??s.title??o}function Es(e){return $n(e)&&e.axis?e.axis:zc(e)&&e.legend?e.legend:$s(e)&&e.header?e.header:void 0}function _s(e,t){return Lc(e,t)}function Wi(e){if(Rc(e)){const{format:t,formatType:n}=e;return{format:t,formatType:n}}else{const t=Es(e)??{},{format:n,formatType:i}=t;return{format:n,formatType:i}}}function sm(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(vs(e)&&v(e.sort))return"ordinal";const{aggregate:n,bin:i,timeUnit:r}=e;if(r)return"temporal";if(i||n&&!_t(n)&&!ut(n))return"quantitative";if(Yt(e)&&e.scale?.type)switch(fs[e.scale.type]){case"numeric":case"discretizing":return"quantitative";case"time":return"temporal"}return"nominal"}function Ke(e){return S(e)?e:ji(e)?e.condition:void 0}function Y(e){return F(e)?e:Zn(e)?e.condition:void 0}function Dc(e,t,n,i={}){if(N(e)||V(e)||jn(e)){const r=N(e)?"string":V(e)?"number":"boolean";return x(sp(t,r,e)),{value:e}}return F(e)?Hi(e,t,n,i):Zn(e)?{...e,condition:Hi(e.condition,t,n,i)}:e}function Hi(e,t,n,i){if(Rc(e)){const{format:r,formatType:s,...o}=e;if(Xt(s)&&!n.customFormatTypes)return x(Da(t)),Hi(o,t,n,i)}else{const r=$n(e)?"axis":zc(e)?"legend":$s(e)?"header":null;if(r&&e[r]){const{format:s,formatType:o,...a}=e[r];if(Xt(o)&&!n.customFormatTypes)return x(Da(t)),Hi({...e,[r]:a},t,n,i)}}return S(e)?ks(e,t,i):om(e)}function om(e){let t=e.type;if(t)return e;const{datum:n}=e;return t=V(n)?"quantitative":N(n)?"nominal":Bt(n)?"temporal":void 0,{...e,type:t}}function ks(e,t,{compositeMark:n=!1}={}){const{aggregate:i,timeUnit:r,bin:s,field:o}=e,a={...e};if(!n&&i&&!Gr(i)&&!_t(i)&&!ut(i)&&(x(ap(i)),delete a.aggregate),r&&(a.timeUnit=Z(r)),o&&(a.field=`${o}`),j(s)&&(a.bin=qi(s,t)),ne(s)&&!Q(t)&&x(jp(t)),ae(a)){const{type:c}=a,u=fg(c);c!==u&&(a.type=u),c!=="quantitative"&&(xa(i)&&(x(op(c,i)),a.type="quantitative"))}else if(!da(t)){const c=sm(a,t);a.type=c}if(ae(a)){const{compatible:c,warning:u}=am(a,t)||{};c===!1&&x(u)}if(vs(a)&&N(a.sort)){const{sort:c}=a;if(_c(c))return{...a,sort:{encoding:c}};const u=c.substr(1);if(c.charAt(0)==="-"&&_c(u))return{...a,sort:{encoding:u,order:"descending"}}}if($s(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 jn(e)?{maxbins:wa(t)}:e==="binned"?{binned:!0}:!e.maxbins&&!e.step?{...e,maxbins:wa(t)}:e}const En={compatible:!0};function am(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 nt:case it:case xi:return Bi(e)?En:{compatible:!1,warning:dp(t)};case H:case K:case xt:case pn:case le:case Be:case We:case qn:case Gn:case Si:case Dt:case wi:case $i:case Mt:case we:case ke:case vi:return En;case Fe:case $e:case Ce:case Ne:return n!==qt?{compatible:!1,warning:`Channel ${t} should be used with a quantitative field only, not ${e.type} field.`}:En;case at:case St:case wt:case $t:case ot:case st:case rt:case _e:case Ue:return n==="nominal"&&!e.sort?{compatible:!1,warning:`Channel ${t} should not be used with an unsorted discrete field.`}:En;case fe:case vt:return!Bi(e)&&!em(e)?{compatible:!1,warning:pp(t)}:En;case gn:return e.type==="nominal"&&!("sort"in e)?{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}:En}}function _n(e){const{formatType:t}=Wi(e);return t==="time"||!t&&cm(e)}function cm(e){return e&&(e.type==="temporal"||S(e)&&!!e.timeUnit)}function Gi(e,{timeUnit:t,type:n,wrapTime:i,undefinedIfExprNotRequired:r}){const s=t&&Z(t)?.unit;let o=s||n==="temporal",a;return Vn(e)?a=e.expr:E(e)?a=e.signal:Bt(e)?(o=!0,a=Wt(e)):(N(e)||V(e))&&(o&&(a=`datetime(${D(e)})`,Zp(s)&&((V(e)&&e<1e4||N(e)&&isNaN(Date.parse(e)))&&(a=Wt({[s]:e}))))),a?i&&o?`time(${a})`:a:r?void 0:D(e)}function jc(e,t){const{type:n}=e;return t.map(i=>{const r=S(e)&&!Ht(e.timeUnit)?e.timeUnit:void 0,s=Gi(i,{timeUnit:r,type:n,undefinedIfExprNotRequired:!0});return s!==void 0?{signal:s}:i})}function Jn(e,t){return j(e.bin)?ct(t)&&["ordinal","nominal"].includes(e.type):(console.warn("Only call this method for binned field defs."),!1)}const Uc={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 ei(e){return e?.condition}const Bc=["domain","grid","labels","ticks","title"],um={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"},Wc={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},lm={...Wc,style:1,labelExpr:1,encoding:1};function Hc(e){return!!lm[e]}const fm={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},qc=b(fm);function dt(e){return"mark"in e}class Vi{constructor(t,n){this.name=t,this.run=n}hasMatchingType(t){return dt(t)?jg(t.mark)===this.name:!1}}function Kt(e,t){const n=e&&e[t];return n?v(n)?It(n,i=>!!i.field):S(n)||ji(n):!1}function Gc(e,t){const n=e&&e[t];return n?v(n)?It(n,i=>!!i.field):S(n)||Ye(n)||Zn(n):!1}function Cs(e,t){if(Q(t)){const n=e[t];if((S(n)||Ye(n))&&(sc(n.type)||S(n)&&n.timeUnit)){const i=Ur(t);return Gc(e,i)}}return!1}function Fs(e){return It(dd,t=>{if(Kt(e,t)){const n=e[t];if(v(n))return It(n,i=>!!i.aggregate);{const i=Ke(n);return i&&!!i.aggregate}}return!1})}function Vc(e,t){const n=[],i=[],r=[],s=[],o={};return Ns(e,(a,c)=>{if(S(a)){const{field:u,aggregate:l,bin:f,timeUnit:d,...p}=a;if(l||d||f){const g=Es(a),m=g?.title;let h=w(a,{forAs:!0});const y={...m?[]:{title:vn(a,t,{allowDisabling:!0})},...p,field:h};if(l){let $;if(_t(l)?($="argmax",h=w({op:"argmax",field:l.argmax},{forAs:!0}),y.field=`${h}.${u}`):ut(l)?($="argmin",h=w({op:"argmin",field:l.argmin},{forAs:!0}),y.field=`${h}.${u}`):l!=="boxplot"&&l!=="errorbar"&&l!=="errorband"&&($=l),$){const C={op:$,as:h};u&&(C.field=u),s.push(C)}}else if(n.push(h),ae(a)&&j(f)){if(i.push({bin:f,field:u,as:h}),n.push(w(a,{binSuffix:"end"})),Jn(a,c)&&n.push(w(a,{binSuffix:"range"})),Q(c)){const $={field:`${h}_end`};o[`${c}2`]=$}y.bin="binned",da(c)||(y.type=qt)}else if(d&&!Ht(d)){r.push({timeUnit:d,field:u,as:h});const $=ae(a)&&a.type!==bn&&"time";$&&(c===qn||c===Dt?y.formatType=$:wd(c)?y.legend={formatType:$,...y.legend}:Q(c)&&(y.axis={formatType:$,...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 dm(e,t,n){const i=vd(t,n);if(i){if(i==="binned"){const r=e[t===_e?H:K];return!!(S(r)&&S(e[t])&&ne(r.bin))}}else return!1;return!0}function pm(e,t,n,i){const r={};for(const s of b(e))fa(s)||x(fp(s));for(let s of yd){if(!e[s])continue;const o=e[s];if(hn(s)){const a=ga(s),c=r[a];if(S(c)){if(lg(c.type)&&(S(o)&&!c.timeUnit)){x(ip(a));continue}}else s=a,x(rp(a))}if(s==="angle"&&t==="arc"&&!e.theta&&(x(np),s=we),!dm(e,s,t)){x(Fi(s,t));continue}if(s===ot&&t==="line"){const a=Ke(e[s]);if(a?.aggregate){x(up);continue}}if(s===le&&(n?"fill"in e:"stroke"in e)){x(Ua("encoding",{fill:"fill"in e,stroke:"stroke"in e}));continue}if(s===Gn||s===gn&&!v(o)&&!Pe(o)||s===Dt&&v(o)){if(o){if(s===gn){const a=e[s];if(Oc(a)){r[s]=a;continue}}r[s]=q(o).reduce((a,c)=>(S(c)?a.push(ks(c,s)):x(Kr(c,s)),a),[])}}else{if(s===Dt&&o===null)r[s]=null;else if(!S(o)&&!Ye(o)&&!Pe(o)&&!Di(o)&&!E(o)){x(Kr(o,s));continue}r[s]=Dc(o,s,i)}}return r}function Xi(e,t){const n={};for(const i of b(e)){const r=Dc(e[i],i,t,{compositeMark:!0});n[i]=r}return n}function gm(e){const t=[];for(const n of b(e))if(Kt(e,n)){const i=e[n],r=q(i);for(const s of r)S(s)?t.push(s):ji(s)&&t.push(s.condition)}return t}function Ns(e,t,n){if(!e)return;for(const i of b(e)){const r=e[i];if(v(r))for(const s of r)t.call(n,s,i);else t.call(n,r,i)}}function mm(e,t,n,i){return e?b(e).reduce((r,s)=>{const o=e[s];return v(o)?o.reduce((a,c)=>t.call(i,a,c,s),r):t.call(i,r,o,s)},n):n}function Xc(e,t){return b(t).reduce((n,i)=>{switch(i){case H:case K:case wi:case vi:case $i:case _e:case Ue:case xt:case pn:case we:case st:case ke:case rt:case Ce:case Fe:case Ne:case $e:case qn:case fe:case Mt:case Dt:return n;case gn:if(e==="line"||e==="trail")return n;case Gn:case Si:{const r=t[i];if(v(r)||S(r))for(const s of q(r))s.aggregate||n.push(w(s,{}));return n}case ot:if(e==="trail")return n;case le:case Be:case We:case at:case St:case wt:case vt:case $t:{const r=Ke(t[i]);return r&&!r.aggregate&&n.push(w(r,{})),n}}},[])}function hm(e){const{tooltip:t,...n}=e;if(!t)return{filteredEncoding:n};let i,r;if(v(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 v(r)&&r.length===1&&(r=r[0]),{customTooltipWithoutAggregatedField:r,filteredEncoding:n}}function Ts(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 ${As(t)}`:"";return{field:o+t.field,type:t.type,title:E(a)?{signal:`${a}"${escape(c)}"`}:a+c}}),s=gm(n).map(Zg);return{tooltip:[...r,...je(s,O)]}}function As(e){const{title:t,field:n}=e;return X(t,n)}function Os(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=As(n);return Yc(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}:{}},...N(l)?{[`${t}2`]:{field:`${l}_${n.field}`}}:{},...i,...f}})}}function Yc(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}:{},...Ve(i.mark)?i.mark:{type:i.mark},style:`${a}-${String(t)}`,...jn(e[t])?{}:e[t]}}]:[]}function Kc(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(Dp(n,t)),i}else return e}function Qc(e,t){const{mark:n,encoding:i}=e,{x:r,y:s}=i;if(Ve(n)&&n.orient)return n.orient;if(Nt(r)){if(Nt(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(Nt(s))return"vertical";throw new Error(`Need a valid continuous axis for ${t}s`)}}const Ki="boxplot",ym=["box","median","outliers","rule","ticks"],bm=new Vi(Ki,Jc);function Zc(e){return V(e)?"tukey":e}function Jc(e,{config:t}){e={...e,encoding:Xi(e.encoding,t)};const{mark:n,encoding:i,params:r,projection:s,...o}=e,a=Ve(n)?n:{type:n};r&&x(Ia("boxplot"));const c=a.extent??t.boxplot.extent,u=z("size",a,t),l=a.invalid,f=Zc(c),{bins:d,timeUnits:p,transform:g,continuousAxisChannelDef:m,continuousAxis:h,groupby:y,aggregate:$,encodingWithoutContinuousAxis:C,ticksOrient:_,boxOrient:T,customTooltipWithoutAggregatedField:M}=xm(e,c,t),{color:he,size:ie,...Me}=C,yt=Cf=>Os(a,h,m,Cf,t.boxplot),tt=yt(Me),_r=yt(C),di=yt({...Me,...ie?{size:ie}:{}}),sn=Ts([{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,C),Dn={type:"tick",color:"black",opacity:1,orient:_,invalid:l,aria:!1},on=f==="min-max"?sn:Ts([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],m,C),Lo=[...tt({partName:"rule",mark:{type:"rule",invalid:l,aria:!1},positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",extraEncoding:on}),...tt({partName:"rule",mark:{type:"rule",invalid:l,aria:!1},positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",extraEncoding:on}),...tt({partName:"ticks",mark:Dn,positionPrefix:"lower_whisker",extraEncoding:on}),...tt({partName:"ticks",mark:Dn,positionPrefix:"upper_whisker",extraEncoding:on})],Mo=[...f!=="tukey"?Lo:[],..._r({partName:"box",mark:{type:"bar",...u?{size:u}:{},orient:T,invalid:l,ariaRoleDescription:"box"},positionPrefix:"lower_box",endPositionPrefix:"upper_box",extraEncoding:sn}),...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:_,aria:!1},positionPrefix:"mid_box",extraEncoding:sn})];if(f==="min-max")return{...o,transform:(o.transform??[]).concat(g),layer:Mo};const Do=`datum["lower_box_${m.field}"]`,jo=`datum["upper_box_${m.field}"]`,Uo=`(${jo} - ${Do})`,Bo=`${Do} - ${c} * ${Uo}`,Wo=`${jo} + ${c} * ${Uo}`,pi=`datum["${m.field}"]`,Ef={joinaggregate:eu(m.field),groupby:y},Ho={transform:[{filter:`(${Bo} <= ${pi}) && (${pi} <= ${Wo})`},{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}`},...$],groupby:y}],layer:Lo},{tooltip:TS,..._f}=Me,{scale:qo,axis:kf}=m,Go=As(m),Vo=ue(kf,["title"]),Xo=Yc(a,"outliers",t.boxplot,{transform:[{filter:`(${pi} < ${Bo}) || (${pi} > ${Wo})`}],mark:"point",encoding:{[h]:{field:m.field,type:m.type,...Go!==void 0?{title:Go}:{},...qo!==void 0?{scale:qo}:{},...I(Vo)?{}:{axis:Vo}},..._f,...he?{color:he}:{},...M?{tooltip:M}:{}}})[0];let gi;const Yo=[...d,...p,Ef];return Xo?gi={transform:Yo,layer:[Xo,Ho]}:(gi=Ho,gi.transform.unshift(...Yo)),{...o,layer:[gi,{transform:g,layer:Mo}]}}function eu(e){return[{op:"q1",field:e,as:`lower_box_${e}`},{op:"q3",field:e,as:`upper_box_${e}`}]}function xm(e,t,n){const i=Qc(e,Ki),{continuousAxisChannelDef:r,continuousAxis:s}=Kc(e,i,Ki),o=r.field,a=Zc(t),c=[...eu(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}=hm(f),{bins:g,timeUnits:m,aggregate:h,groupby:y,encoding:$}=Vc(p,n),C=i==="vertical"?"horizontal":"vertical",_=i,T=[...g,...m,{aggregate:[...h,...c],groupby:y},...u];return{bins:g,timeUnits:m,transform:T,groupby:y,aggregate:h,continuousAxisChannelDef:r,continuousAxis:s,encodingWithoutContinuousAxis:$,ticksOrient:C,boxOrient:_,customTooltipWithoutAggregatedField:d}}const Ps="errorbar",Sm=["ticks","rule"],wm=new Vi(Ps,tu);function tu(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}=nu(e,Ps,t);delete s.size;const l=Os(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 $m(e,t){const{encoding:n}=e;if(vm(n))return{orient:Qc(e,t),inputType:"raw"};const i=Em(n),r=_m(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(F(a)&&F(c))throw new Error(`${t} cannot have both x2 and y2`);if(F(a)){if(Nt(s))return{orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error(`Both x and x2 have to be quantitative in ${t}`)}else if(F(c)){if(Nt(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(F(c)&&!F(a))throw new Error(`${t} cannot have xError2 without xError`);if(F(l)&&!F(u))throw new Error(`${t} cannot have yError2 without yError`);if(F(a)&&F(u))throw new Error(`${t} cannot have both xError and yError with both are quantiative`);if(F(a)){if(Nt(s))return{orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative")}else if(F(u)){if(Nt(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 vm(e){return(F(e.x)||F(e.y))&&!F(e.x2)&&!F(e.y2)&&!F(e.xError)&&!F(e.xError2)&&!F(e.yError)&&!F(e.yError2)}function Em(e){return F(e.x2)||F(e.y2)}function _m(e){return F(e.xError)||F(e.xError2)||F(e.yError)||F(e.yError2)}function nu(e,t,n){const{mark:i,encoding:r,params:s,projection:o,...a}=e,c=Ve(i)?i:{type:i};s&&x(Ia(t));const{orient:u,inputType:l}=$m(e,t),{continuousAxisChannelDef:f,continuousAxisChannelDef2:d,continuousAxisChannelDefError:p,continuousAxisChannelDefError2:g,continuousAxis:m}=Kc(e,u,t),{errorBarSpecificAggregate:h,postAggregateCalculates:y,tooltipSummary:$,tooltipTitleWithFieldName:C}=km(c,f,d,p,g,l,t,n),{[m]:_,[m==="x"?"x2":"y2"]:T,[m==="x"?"xError":"yError"]:M,[m==="x"?"xError2":"yError2"]:he,...ie}=r,{bins:Me,timeUnits:yt,aggregate:tt,groupby:_r,encoding:di}=Vc(ie,n),sn=[...tt,...h],Dn=l!=="raw"?[]:_r,on=Ts($,f,di,C);return{transform:[...a.transform??[],...Me,...yt,...sn.length===0?[]:[{aggregate:sn,groupby:Dn}],...y],groupby:Dn,continuousAxisChannelDef:f,continuousAxis:m,encodingWithoutContinuousAxis:di,ticksOrient:u==="vertical"?"horizontal":"vertical",markDef:c,outerSpec:a,tooltipEncoding:on}}function km(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(Mp(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:Wn(p)},{fieldPrefix:"upper_",titlePrefix:iu(p,g,"+")},{fieldPrefix:"lower_",titlePrefix:iu(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:vn({field:l,aggregate:y,type:"quantitative"},a,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:vn({field:l,aggregate:h,type:"quantitative"},a,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:vn({field:l,aggregate:m,type:"quantitative"},a,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&x(Lp(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:Lt(Lt(p.calculate,'datum["',""),'"]',"")})}return{postAggregateCalculates:u,errorBarSpecificAggregate:c,tooltipSummary:f,tooltipTitleWithFieldName:d}}function iu(e,t,n){return`${Wn(e)} ${n} ${t}`}const zs="errorband",Cm=["band","borders"],Fm=new Vi(zs,ru);function ru(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}=nu(e,zs,t),u=o,l=Os(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(qa("interpolate")):u.tension&&x(qa("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 su={};function Rs(e,t,n){const i=new Vi(e,t);su[e]={normalizer:i,parts:n}}function Nm(){return b(su)}Rs(Ki,Jc,ym),Rs(Ps,tu,Sm),Rs(zs,ru,Cm);const Tm=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength","unselectedOpacity"],ou={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"},au={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"},Am=b(ou),Om=b(au),Pm={header:1,headerRow:1,headerColumn:1,headerFacet:1},cu=b(Pm),uu=["size","shape","fill","stroke","strokeDash","strokeWidth","opacity"],zm={gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},Rm={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},ze="_vgsid_",Im={point:{on:"click",fields:[ze],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 Is(e){return e==="legend"||!!e?.legend}function Ls(e){return Is(e)&&L(e)}function Ms(e){return!!e?.select}function lu(e){const t=[];for(const n of e||[]){if(Ms(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 Lm(e){return Qi(e)||js(e)||Ds(e)}function Ds(e){return"concat"in e}function Qi(e){return"vconcat"in e}function js(e){return"hconcat"in e}function fu({step:e,offsetIsDiscrete:t}){return t?e.for??"offset":"position"}function Qe(e){return L(e)&&e.step!==void 0}function du(e){return e.view||e.width||e.height}const pu=20,Mm={align:1,bounds:1,center:1,columns:1,spacing:1},Dm=b(Mm);function jm(e,t,n){const i=n[t],r={},{spacing:s,columns:o}=i;s!==void 0&&(r.spacing=s),o!==void 0&&((Mi(e)&&!Qn(e.facet)||Ds(e))&&(r.columns=o)),Qi(e)&&(r.columns=1);for(const a of Dm)if(e[a]!==void 0)if(a==="spacing"){const c=e[a];r[a]=V(c)?c:{row:c.row??s,column:c.column??s}}else r[a]=e[a];return r}function Us(e,t){return e[t]??e[t==="width"?"continuousWidth":"continuousHeight"]}function Zi(e,t){const n=Ji(e,t);return Qe(n)?n.step:gu}function Ji(e,t){const n=e[t]??e[t==="width"?"discreteWidth":"discreteHeight"];return X(n,{step:e.step})}const gu=20,Um={continuousWidth:200,continuousHeight:200,step:gu},Bm={background:"white",padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",view:Um,mark:zg,arc:{},area:{},bar:Lg,circle:{},geoshape:{},image:{},line:{},point:{},rect:Mg,rule:{color:"black"},square:{},text:{color:"black"},tick:Dg,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:hg,projection:{},legend:zm,header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:Im,style:{},title:{},facet:{spacing:pu},concat:{spacing:pu},normalizedNumberFormat:".0%"},pt=["#4c78a8","#f58518","#e45756","#72b7b2","#54a24b","#eeca3b","#b279a2","#ff9da6","#9d755d","#bab0ac"],mu={text:11,guideLabel:10,guideTitle:11,groupTitle:13,groupSubtitle:12},hu={blue:pt[0],orange:pt[1],red:pt[2],teal:pt[3],green:pt[4],yellow:pt[5],purple:pt[6],pink:pt[7],brown:pt[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 Wm(e={}){return{signals:[{name:"color",value:L(e)?{...hu,...e}:hu}],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 Hm(e){return{signals:[{name:"fontSize",value:L(e)?{...mu,...e}:mu}],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 qm(e){return{text:{font:e},style:{"guide-label":{font:e},"guide-title":{font:e},"group-title":{font:e},"group-subtitle":{font:e}}}}function yu(e){const t=b(e||{}),n={};for(const i of t){const r=e[i];n[i]=ei(r)?va(r):ye(r)}return n}function Gm(e){const t=b(e),n={};for(const i of t)n[i]=yu(e[i]);return n}const Vm=[...yc,...qc,...cu,"background","padding","legend","lineBreak","scale","style","title","view"];function bu(e={}){const{color:t,font:n,fontSize:i,selection:r,...s}=e,o=Ko({},k(Bm),n?qm(n):{},t?Wm(t):{},i?Hm(i):{},s||{});r&&Rf(o,"selection",r,!0);const a=ue(o,Vm);for(const c of["background","lineBreak","padding"])o[c]&&(a[c]=ye(o[c]));for(const c of yc)o[c]&&(a[c]=pe(o[c]));for(const c of qc)o[c]&&(a[c]=yu(o[c]));for(const c of cu)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=Gm(o.style)),o.title&&(a.title=pe(o.title)),o.view&&(a.view=pe(o.view)),a}const Xm=new Set(["view",...Fg]),Ym=["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"],Km={view:["continuousWidth","continuousHeight","discreteWidth","discreteHeight","step"],...Pg};function Qm(e){e=k(e);for(const t of Ym)delete e[t];if(e.axis)for(const t in e.axis)ei(e.axis[t])&&delete e.axis[t];if(e.legend)for(const t of Tm)delete e.legend[t];if(e.mark){for(const t of hc)delete e.mark[t];e.mark.tooltip&&L(e.mark.tooltip)&&delete e.mark.tooltip}e.params&&(e.signals=(e.signals||[]).concat(lu(e.params)),delete e.params);for(const t of Xm){for(const i of hc)delete e[t][i];const n=Km[t];if(n)for(const i of n)delete e[t][i];Jm(e,t)}for(const t of Nm())delete e[t];Zm(e);for(const t in e)L(e[t])&&I(e[t])&&delete e[t];return I(e)?void 0:e}function Zm(e){const{titleMarkConfig:t,subtitleMarkConfig:n,subtitle:i}=$a(e.title);I(t)||(e.style["group-title"]={...e.style["group-title"],...t}),I(n)||(e.style["group-subtitle"]={...e.style["group-subtitle"],...n}),I(i)?delete e.title:e.title=i}function Jm(e,t,n,i){const r=i?e[t][i]:e[t];t==="view"&&(n="cell");const s={...r,...e.style[n??t]};I(s)||(e.style[n??t]=s),i||delete e[t]}function er(e){return"layer"in e}function eh(e){return"repeat"in e}function th(e){return!v(e.repeat)&&e.repeat.layer}class Bs{map(t,n){return Mi(t)?this.mapFacet(t,n):eh(t)?this.mapRepeat(t,n):js(t)?this.mapHConcat(t,n):Qi(t)?this.mapVConcat(t,n):Ds(t)?this.mapConcat(t,n):this.mapLayerOrUnit(t,n)}mapLayerOrUnit(t,n){if(er(t))return this.mapLayer(t,n);if(dt(t))return this.mapUnit(t,n);throw new Error(Xr(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 nh={zero:1,center:1,normalize:1};function ih(e){return e in nh}const rh=new Set([pc,Oi,Ai,Ri,zi,gs,ms,Pi,gc,ps]),sh=new Set([Oi,Ai,pc]);function kn(e){return S(e)&&wn(e)==="quantitative"&&!e.bin}function xu(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(kn(o)&&kn(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&&["bar","area"].includes(i)){if(n==="vertical")return r;if(n==="horizontal")return t}}else{if(kn(o))return t;if(kn(a))return r}else{if(kn(o))return t;if(kn(a))return r}return}function oh(e){switch(e){case"x":return"y";case"y":return"x";case"theta":return"radius";case"radius":return"theta"}}function Su(e,t){const n=Ve(e)?e:{type:e},i=n.type;if(!rh.has(i))return null;const r=xu(t,"x",n)||xu(t,"theta",n);if(!r)return null;const s=t[r],o=S(s)?w(s,{}):void 0,a=oh(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=bd.reduce((d,p)=>{if(p!=="tooltip"&&Kt(t,p)){const g=t[p];for(const m of q(g)){const h=Ke(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?jn(s.stack)?f=s.stack?"zero":null:f=s.stack:sh.has(i)&&(f="zero"),!f||!ih(f)||Fs(t)&&l.length===0?null:s?.scale?.type&&s?.scale?.type!==ge.LINEAR?(s?.stack&&x(zp(s.scale.type)),null):F(t[He(r)])?(s.stack!==void 0&&x(Pp(r)),null):(S(s)&&s.aggregate&&!Td.has(s.aggregate)&&x(Rp(s.aggregate)),{groupbyChannels:c,groupbyFields:u,fieldChannel:r,impute:s.impute===null?!1:Ft(i),stackBy:l,offset:f})}function wu(e,t,n){const i=pe(e),r=z("orient",i,n);if(i.orient=lh(i.type,t,r),r!==void 0&&r!==i.orient&&x(yp(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"]:Ig[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=ch(i.type,t));const o=z("cursor",i,n);return o===void 0&&(i.cursor=ah(i,t,n)),i}function ah(e,t,n){return t.href||e.href||z("href",e,n)?"pointer":e.cursor}function ch(e,t){return P([zi,ps,gs,ms],e)&&!Fs(t)?.7:void 0}function uh(e,t,{graticule:n}){if(n)return!1;const i=ft("filled",e,t),r=e.type;return X(i,r!==zi&&r!==Pi&&r!==Ri)}function lh(e,t,n){switch(e){case zi:case gs:case ms:case gc:case kg:case _g:return}const{x:i,y:r,x2:s,y2:o}=t;switch(e){case Oi:if(S(i)&&(ne(i.bin)||S(r)&&r.aggregate&&!i.aggregate))return"vertical";if(S(r)&&(ne(r.bin)||S(i)&&i.aggregate&&!r.aggregate))return"horizontal";if(o||s){if(n)return n;if(!s)return(S(i)&&i.type===qt&&!j(i.bin)||Ui(i))&&(S(r)&&ne(r.bin))?"horizontal":"vertical";if(!o)return(S(r)&&r.type===qt&&!j(r.bin)||Ui(r))&&(S(i)&&ne(i.bin))?"vertical":"horizontal"}case Ri:if(s&&!(S(i)&&ne(i.bin))&&o&&!(S(r)&&ne(r.bin)))return;case Ai:if(o)return S(r)&&ne(r.bin)?"horizontal":"vertical";if(s)return S(i)&&ne(i.bin)?"vertical":"horizontal";if(e===Ri){if(i&&!r)return"vertical";if(r&&!i)return"horizontal"}case Pi:case ps:{const a=Pc(i),c=Pc(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===bn,l=ae(r)&&r.type===bn;if(u&&!l)return"vertical";if(!u&&l)return"horizontal"}return}}return"vertical"}function fh(e){const{point:t,line:n,...i}=e;return b(i).length>1?i:i.type}function dh(e){for(const t of["line","area","rule","trail"])e[t]&&(e={...e,[t]:ue(e[t],["point","line"])});return e}function Ws(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 $u(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 ph{constructor(){this.name="path-overlay"}hasMatchingType(t,n){if(dt(t)){const{mark:i,encoding:r}=t,s=Ve(i)?i:{type:i};switch(s.type){case"line":case"rule":case"trail":return!!Ws(s,n[s.type],r);case"area":return!!Ws(s,n[s.type],r)||!!$u(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=Ve(a)?a:{type:a},p=Ws(d,r[d.type],f),g=d.type==="area"&&$u(d,r[d.type]),m=[{name:c,...s?{params:s}:{},mark:fh({...d.type==="area"&&d.opacity===void 0&&d.fillOpacity===void 0?{opacity:.7}:{},...d}),encoding:ue(f,["shape"])}],h=Su(wu(d,f,r),f);let y=f;if(h){const{fieldChannel:$,offset:C}=h;y={...f,[$]:{...f[$],...C?{stack:C}:{}}}}return y=ue(y,["y2","x2"]),g&&m.push({...o?{projection:o}:{},mark:{type:"line",...fn(d,["clip","interpolate","tension","tooltip"]),...g},encoding:y}),p&&m.push({...o?{projection:o}:{},mark:{type:"point",opacity:1,filled:!0,...fn(d,["clip","tooltip"]),...p},encoding:y}),i({...l,layer:m},{...n,config:dh(r)})}}function gh(e,t){return t?Qn(e)?ku(e,t):vu(e,t):e}function Hs(e,t){return t?ku(e,t):e}function qs(e,t,n){const i=t[e];if(Kg(i)){if(i.repeat in n)return{...t,[e]:n[i.repeat]};x(Yd(i.repeat));return}return t}function vu(e,t){if(e=qs("field",e,t),e===void 0)return;if(e===null)return null;if(vs(e)&&Xe(e.sort)){const n=qs("field",e.sort,t);e={...e,...n?{sort:n}:{}}}return e}function Eu(e,t){if(S(e))return vu(e,t);{const n=qs("datum",e,t);return n!==e&&!n.type&&(n.type="nominal"),n}}function _u(e,t){if(F(e)){const n=Eu(e,t);if(n)return n;if(Di(e))return{condition:e.condition}}else{if(Zn(e)){const n=Eu(e.condition,t);if(n)return{...e,condition:n};{const{condition:i,...r}=e;return r}}return e}return}function ku(e,t){const n={};for(const i in e)if(an(e,i)){const r=e[i];if(v(r))n[i]=r.map(s=>_u(s,t)).filter(s=>s);else{const s=_u(r,t);s!==void 0&&(n[i]=s)}}return n}class mh{constructor(){this.name="RuleForRangedLine"}hasMatchingType(t){if(dt(t)){const{encoding:n,mark:i}=t;if(i==="line"||Ve(i)&&i.type==="line")for(const r of hd){const s=jt(r),o=n[s];if(n[r]&&(S(o)&&!ne(o.bin)||Ye(o)))return!0}}return!1}run(t,n,i){const{encoding:r,mark:s}=t;return x(hp(!!r.x2,!!r.y2)),i({...t,mark:L(s)?{...s,type:"rule"}:"rule"},n)}}class hh extends Bs{constructor(){super(...arguments);this.nonFacetUnitNormalizers=[bm,wm,Fm,new ph,new mh]}map(t,n){if(dt(t)){const i=Kt(t.encoding,nt),r=Kt(t.encoding,it),s=Kt(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=Hs(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 th(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;!v(i)&&t.columns&&(t=ue(t,["columns"]),x(La("repeat")));const a=[],{repeater:c={},repeaterPrefix:u=""}=n,l=!v(i)&&i.row||[c?c.row:null],f=!v(i)&&i.column||[c?c.column:null],d=v(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},$=(r.name?`${r.name}_`:"")+u+"child__"+(v(i)?`${W(g)}`:(i.row?`row_${W(m)}`:"")+(i.column?`column_${W(h)}`:"")),C=this.map(r,{...n,repeater:y,repeaterPrefix:$});C.name=$,a.push(ue(C,["data"]))}const p=v(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 Qn(i)&&t.columns&&(t=ue(t,["columns"]),x(La("facet"))),super.mapFacet(t,n)}mapUnitWithParentEncodingOrProjection(t,n){const{encoding:i,projection:r}=t,{parentEncoding:s,parentProjection:o,config:a}=n,c=Fu({parentProjection:o,projection:r}),u=Cu({parentEncoding:s,encoding:Hs(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=Hs(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(gp([...i?[nt]:[],...r?[it]:[]]));const o={},a={};for(const c of[nt,it]){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:gh(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:Cu({parentEncoding:n,encoding:s,layer:!0}),parentProjection:Fu({parentProjection:i,projection:o})};return super.mapLayer({...a,...t.name?{name:[c.repeaterPrefix,t.name].filter(u=>u).join("_")}:{}},c)}}function Cu({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(F(o)){const c={...a,...o};i[s]=c}else Zn(o)?i[s]={...o,condition:{...a,...o.condition}}:o||o===null?i[s]=o:(n||Pe(a)||E(a)||F(a)||v(a))&&(i[s]=a)}}else i=t;return!i||I(i)?void 0:i}function Fu(e){const{parentProjection:t,projection:n}=e;return t&&n&&x(tp({parentProjection:t,projection:n})),n??t}function Gs(e){return"filter"in e}function yh(e){return e?.stop!==void 0}function Nu(e){return"lookup"in e}function bh(e){return"data"in e}function xh(e){return"param"in e}function Sh(e){return"pivot"in e}function wh(e){return"density"in e}function $h(e){return"quantile"in e}function vh(e){return"regression"in e}function Eh(e){return"loess"in e}function _h(e){return"sample"in e}function kh(e){return"window"in e}function Ch(e){return"joinaggregate"in e}function Fh(e){return"flatten"in e}function Nh(e){return"calculate"in e}function Tu(e){return"bin"in e}function Th(e){return"impute"in e}function Ah(e){return"timeUnit"in e}function Oh(e){return"aggregate"in e}function Ph(e){return"stack"in e}function zh(e){return"fold"in e}function Rh(e){return"extent"in e&&!("density"in e)}function Ih(e){return e.map(t=>Gs(t)?{filter:ln(t.filter,ug)}:t)}class Lh extends Bs{map(t,n){return n.emptySelections??(n.emptySelections={}),n.selectionPredicates??(n.selectionPredicates={}),t=Au(t,n),super.map(t,n)}mapLayerOrUnit(t,n){if(t=Au(t,n),t.encoding){const i={};for(const[r,s]of bt(t.encoding))i[r]=Ou(s,n);t={...t,encoding:i}}return super.mapLayerOrUnit(t,n)}mapUnit(t,n){const{selection:i,...r}=t;return i?{...r,params:bt(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 te(n.selectionPredicates[s]??{}))f.empty=u!=="none";return{name:s,value:a,select:l,bind:c}})}:t}}function Au(e,t){const{transform:n,...i}=e;if(n){const r=n.map(s=>{if(Gs(s))return{filter:Vs(s,t)};if(Tu(s)&&Ut(s.bin))return{...s,bin:Pu(s.bin)};if(Nu(s)){const{selection:o,...a}=s.from;return o?{...s,from:{param:o,...a}}:s}return s});return{...i,transform:r}}return e}function Ou(e,t){const n=k(e);if(S(n)&&Ut(n.bin)&&(n.bin=Pu(n.bin)),Yt(n)&&n.scale?.domain?.selection){const{selection:i,...r}=n.scale.domain;n.scale.domain={...r,...i?{param:i}:{}}}if(Di(n))if(Qo(n.condition))n.condition=n.condition.map(i=>{const{selection:r,param:s,test:o,...a}=i;return s?i:{...a,test:Vs(i,t)}});else{const{selection:i,param:r,test:s,...o}=Ou(n.condition,t);n.condition=r?n.condition:{...o,test:Vs(n.condition,t)}}return n}function Pu(e){const t=e.extent;if(t?.selection){const{selection:n,...i}=t;return{...e,extent:{...i,param:n}}}return e}function Vs(e,t){const n=i=>ln(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):ln(e.test||e.filter,i=>i.selection?n(i.selection):i)}class Xs extends Bs{map(t,n){const i=n.selections??[];if(t.params&&!dt(t)){const r=[];for(const s of t.params)Ms(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))||Qo(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=Xs.prototype[e];Xs.prototype[e]=function(n,i){return t.call(this,n,Mh(n,i))}}function Mh(e,t){return e.name?{...t,path:(t.path??[]).concat(e.name)}:t}function zu(e,t){t===void 0&&(t=bu(e.config));const n=Bh(e,t),{width:i,height:r}=e,s=Wh(n,{width:i,height:r,autosize:e.autosize},t);return{...n,...s?{autosize:s}:{}}}const Dh=new hh,jh=new Lh,Uh=new Xs;function Bh(e,t={}){const n={config:t};return Uh.map(Dh.map(jh.map(e,n),n),n)}function Ru(e){return N(e)?{type:e}:e??{}}function Wh(e,t,n){let{width:i,height:r}=t;const s=dt(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(Oa("width")),i=void 0),r=="container"&&(x(Oa("height")),r=void 0));const a={type:"pad",...o,...n?Ru(n.autosize):{},...Ru(e.autosize)};return a.type==="fit"&&!s&&(x(Dd),a.type="pad"),i=="container"&&!(a.type=="fit"||a.type=="fit-x")&&x(Pa("width")),r=="container"&&!(a.type=="fit"||a.type=="fit-y")&&x(Pa("height")),De(a,{type:"pad"})?void 0:a}function Hh(e){return e==="fit"||e==="fit-x"||e==="fit-y"}function qh(e){return e?`fit-${Ei(e)}`:"fit"}const Gh=["background","padding"];function Iu(e,t){const n={};for(const i of Gh)e&&e[i]!==void 0&&(n[i]=ye(e[i]));return t&&(n.params=e.params),n}class gt{constructor(t={},n={}){this.explicit=t,this.implicit=n}clone(){return new gt(k(this.explicit),k(this.implicit))}combine(){return{...this.explicit,...this.implicit}}get(t){return X(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 Ze(e){return{explicit:!0,value:e}}function xe(e){return{explicit:!1,value:e}}function Lu(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(kp(n,i,e.value,t.value)),e}function Tt(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:De(e.value,t.value)?e:r(e,t,n,i)}class Vh extends gt{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 Cn(e){return"url"in e}function ti(e){return"values"in e}function Mu(e){return"name"in e&&!Cn(e)&&!ti(e)&&!At(e)}function At(e){return e&&(Du(e)||ju(e)||Ys(e))}function Du(e){return"sequence"in e}function ju(e){return"sphere"in e}function Ys(e){return"graticule"in e}var U;(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"})(U||(U={}));function Uu(e){const{signals:t,hasLegend:n,index:i,...r}=e;return r.field=Se(r.field),r}function Qt(e,t=!0,n=Of){if(v(e)){const i=e.map(r=>Qt(r,t,n));return t?`[${i.join(", ")}]`:i}else if(Bt(e))return n(t?Wt(e):Qp(e));return t?n(D(e)):e}function Xh(e,t){for(const n of te(e.component.selection??{})){const i=n.name;let r=`${i}${Pt}, ${n.resolve==="global"?"true":`{unit: ${Jt(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+ky,on:[{events:{signal:n.name+Pt},update:`modify(${A(n.name+Zt)}, ${r})`}]})}return Ks(t)}function Yh(e,t){if(e.component.selection&&b(e.component.selection).length){const n=A(e.getName("cell"));t.unshift({name:"facet",value:{},on:[{events:un("mousemove","scope"),update:`isTuple(facet) ? facet : group(${n}).datum`}]})}return Ks(t)}function Kh(e,t){let n=!1;for(const i of te(e.component.selection??{})){const r=i.name,s=A(r+Zt),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:`${dl}(${s}, ${A(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 Ks(t)}function Qh(e,t){const n=[...t],i=Jt(e,{escape:!1});for(const r of te(e.component.selection??{})){const s={name:r.name+Zt};if(r.project.hasSelectionId&&(s.transform=[{type:"collect",sort:{field:ze}}]),r.init){const a=r.project.items.map(Uu);s.values=r.project.hasSelectionId?r.init.map(c=>({unit:i,[ze]:Qt(c,!1)[0]})):r.init.map(c=>({unit:i,fields:a,values:Qt(c,!1)}))}const o=n.filter(a=>a.name===r.name+Zt);o.length||n.push(s)}return n}function Bu(e,t){for(const n of te(e.component.selection??{}))for(const i of or)i.defined(n)&&i.marks&&(t=i.marks(e,n,t));return t}function Zh(e,t){for(const n of e.children)G(n)&&(t=Bu(n,t));return t}function Jh(e,t,n,i){const r=yl(e,t.param,t);return{signal:be(n.get("type"))&&v(i)&&i[0]>i[1]?`isValid(${r}) && reverse(${r})`:r}}function Ks(e){return e.map(t=>(t.on&&!t.on.length&&delete t.on,t))}class R{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(Zd);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 R{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 ${ia()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(t){this._source=t}}function Qs(e){return e.as!==void 0}function Wu(e){return`${e}_end`}class Je extends R{clone(){return new Je(null,k(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){let c;if(Ht(a)){if(G(n)){const{mark:u}=n;(hs(u)||!!s.bandPosition)&&(c={timeUnit:Z(a),field:o})}}else c={as:w(s,{forAs:!0}),field:o,timeUnit:a};c&&(r[O(c)]=c)}return r},{});return I(i)?null:new Je(t,i)}static makeFromTransform(t,n){const{timeUnit:i,...r}={...n},s=Z(i),o={...r,timeUnit:s};return new Je(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 bt(this.formula)){const s=Qs(r)?r.as:`${r.field}_end`;t.has(s)||(n[i]=r)}this.formula=n}producedFields(){return new Set(te(this.formula).map(t=>Qs(t)?t.as:Wu(t.field)))}dependentFields(){return new Set(te(this.formula).map(t=>t.field))}hash(){return`TimeUnit ${O(this.formula)}`}assemble(){const t=[];for(const n of te(this.formula))if(Qs(n)){const{field:i,as:r,timeUnit:s}=n,{unit:o,utc:a,...c}=Z(s);t.push({field:Se(i),type:"timeunit",...o?{units:Ti(o)}:{},...a?{timezone:"utc"}:{},...c,as:[r,`${r}_end`]})}else if(n){const{field:i,timeUnit:r}=n,s=Za(r?.unit),{part:o,step:a}=nc(s,r.step);t.push({type:"formula",expr:`timeOffset('${o}', datum['${i}'], ${a})`,as:Wu(i)})}return t}}const ni="_tuple_fields";class ey{constructor(...t){this.items=t,this.hasChannel={},this.hasField={},this.hasSelectionId=!1}}const ty={defined:()=>!0,parse:(e,t,n)=>{const i=t.name,r=t.project??(t.project=new ey),s={},o={},a=new Set,c=(g,m)=>{const h=m==="visual"?g.channel:g.field;let y=W(`${i}_${h}`);for(let $=1;a.has(y);$++)y=W(`${i}_${h}_${$}`);return a.add(y),{[m]:y}},u=t.type,l=e.config.selection[u],f=n.value!==void 0?q(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))md(m)?(p||(p=[])).push(m):u==="interval"?(x(Xd),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(jd(g,m.aggregate));continue}else if(!h){x(Ra(g));continue}if(m.timeUnit&&!Ht(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"&&ct(g)&&be(e.getScaleComponent(g).get("type"))?"R":m.bin?"R-RE":"E",$={field:h,channel:g,type:y,index:r.items.length};$.signals={...c($,"data"),...c($,"visual")},r.items.push(s[h]=$),r.hasField[h]=s[h],r.hasSelectionId=r.hasSelectionId||h===ze,ua(g)?($.geoChannel=g,$.channel=ca(g),r.hasChannel[$.channel]=s[h]):r.hasChannel[g]=s[h]}}else x(Ra(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===ze}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))),I(o)||(r.timeUnit=new Je(null,o))},signals:(e,t,n)=>{const i=t.name+ni,r=n.filter(s=>s.name===i);return r.length>0||t.project.hasSelectionId?n:n.concat({name:i,value:t.project.items.map(Uu)})}},mt={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(!ct(r))continue;const s=e.getScaleComponent(r),o=s?s.get("type"):void 0;if(!s||!be(o)){x(Wd);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||Js(e)||i.length===0)return n;const r=n.filter(o=>o.name===t.name)[0];let s=r.update;if(s.indexOf(dl)>=0)r.update=`{${i.map(o=>`${A(Se(o.field))}: ${o.signals.data}`).join(", ")}}`;else{for(const o of i){const a=`${A(Se(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&&!Js(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 Zs(e,t){const n=A(e.scaleName(t));return`domain(${n})`}function Js(e){return e.parent&&Ln(e.parent)&&(!e.parent.parent??Js(e.parent.parent))}const Fn="_brush",Hu="_scale_trigger",ii="geo_interval_init_tick",qu="_init",ny="_center",iy={defined:e=>e.type==="interval",parse:(e,t,n)=>{var i;if(e.hasProjection){const r={...Cr(n.select)?n.select:{}};r.fields=[ze],r.encodings||(r.encodings=n.value?b(n.value):[Fe,Ce]),n.select={type:"interval",...r}}if(t.translate&&!mt.defined(t)){const r=`!event.item || event.item.mark.name !== ${A(t.name+Fn)}`;for(const s of t.events){if(!s.between){x(`${s} is not an ordered event stream for interval selections.`);continue}const o=q((i=s.between[0]).filter??(i.filter=[]));o.indexOf(r)<0&&o.push(r)}}},signals:(e,t,n)=>{const i=t.name,r=i+Pt,s=te(t.project.hasChannel).filter(a=>a.channel===H||a.channel===K),o=t.init?t.init[0]:null;if(n.push(...s.reduce((a,c)=>a.concat(ry(e,t,c,o&&o[c.index])),[])),e.hasProjection){const a=A(e.projectionName()),c=e.projectionName()+ny,{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=T=>e.getSizeSignalRef(T).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+qu,init:`[scale(${a}, [${u?p[0]:p}, ${l?g[0]:g}]), scale(${a}, [${u?p[1]:p}, ${l?g[1]:g}])]`}),!u||!l)){const T=n.find(M=>M.name===c);T||n.unshift({name:c,update:`invert(${a}, [${m("width")}/2, ${m("height")}/2])`})}const y=`intersect(${h}, {markname: ${A(e.getName("marks"))}}, unit.mark)`,$=`{unit: ${Jt(e)}}`,C=`vlSelectionTuples(${y}, ${$})`,_=s.map(T=>T.signals.visual);return n.concat({name:r,on:[{events:[..._.length?[{signal:_.join(" || ")}]:[],...o?[{signal:ii}]:[]],update:C}]})}else{if(!mt.defined(t)){const u=i+Hu,l=s.map(f=>{const d=f.channel,{data:p,visual:g}=f.signals,m=A(e.scaleName(d)),h=e.getScaleComponent(d).get("type"),y=be(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: ${Jt(e)}, fields: ${i+ni}, values`;return n.concat({name:r,...o?{init:`{${c}: ${Qt(o)}}`}:{},...a.length?{on:[{events:[{signal:a.join(" || ")}],update:`${a.join(" && ")} ? {${c}: [${a}]} : null`}]}:{}})}},topLevelSignals:(e,t,n)=>{if(G(e)&&e.hasProjection&&t.init){const i=n.filter(r=>r.name===ii);i.length||n.unshift({name:ii,value:null,on:[{events:"timer{1}",update:`${ii} === null ? {} : ${ii}`}]})}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(${A(t.name+Zt)})`;if(mt.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 === ${Jt(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+Fn}_bg`,type:"rect",clip:!0,encode:{enter:{fill:{value:l},fillOpacity:{value:f}},update:u}},...n,{name:i+Fn,type:"rect",clip:!0,encode:{enter:{...d?{cursor:{value:d}}:{},fill:{value:"transparent"}},update:{...u,...g}}}]}};function ry(e,t,n,i){const r=!e.hasProjection,s=n.channel,o=n.signals.visual,a=A(r?e.scaleName(s):e.projectionName()),c=d=>`scale(${a}, ${d})`,u=e.getSizeSignalRef(s===H?"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=mt.defined(t),g=e.getScaleComponent(s),m=g?g.get("type"):void 0,h=i?{init:Qt(i,!0,c)}:{value:[]};return f.push({events:{signal:t.name+Hu},update:be(m)?`[${c(`${d}[0]`)}, ${c(`${d}[1]`)}]`:"[0, 0]"}),p?[{name:d,on:[]}]:[{name:o,...h,on:f},{name:d,...i?{init:Qt(i)}:{},on:[{events:{signal:o},update:`${o}[0] === ${o}[1] ? null : invert(${a}, ${o})`}]}]}else{const d=s===H?0:1,p=t.name+qu,g=i?{init:`[${p}[0][${d}], ${p}[1][${d}]]`}:{value:[]};return[{name:o,...g,on:f}]}}const sy={defined:e=>e.type==="point",signals:(e,t,n)=>{const i=t.name,r=i+ni,s=t.project,o="(item().isVoronoi ? datum.datum : datum)",a=te(e.component.selection??{}).reduce((f,d)=>d.type==="interval"?f.concat(d.name+Fn):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: ${Jt(e)}, `;if(t.project.hasSelectionId)u+=`${ze}: ${o}[${A(ze)}]`;else{const f=s.items.map(d=>{const p=e.fieldDef(d.channel);return p?.bin?`[${o}[${A(e.vgField(d.channel,{}))}], ${o}[${A(e.vgField(d.channel,{binSuffix:"end"}))}]]`:`${o}[${A(d.field)}]`}).join(", ");u+=`fields: ${r}, values: [${f}]`}const l=t.events;return n.concat([{name:i+Pt,on:l?[{events:l,update:`${c} ? {${u}} : null`,force:!0}]:[]}])}};function Nn(e,t,n,i){const r=Di(t)&&t.condition,s=i(t);if(r){const o=q(r),a=o.map(c=>{const u=i(c);if(Yg(c)){const{param:l,empty:f}=c,d=hl(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 eo(e,t="text"){const n=e.encoding[t];return Nn(e,n,t,i=>nr(i,e.config))}function nr(e,t,n="datum"){if(e){if(Pe(e))return B(e.value);if(F(e)){const{format:i,formatType:r}=Wi(e);return Ss({fieldOrDatumDef:e,format:i,formatType:r,expr:n,config:t})}}return}function Gu(e,t={}){const{encoding:n,markDef:i,config:r,stack:s}=e,o=n.tooltip;if(v(o))return{tooltip:Xu({tooltip:o},s,r,t)};{const a=t.reactiveGeom?"datum.datum":"datum";return Nn(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"}),N(l)?{value:l}:L(l)?E(l)?l:l.content==="encoding"?Xu(n,s,r,t):{signal:a}:void 0})}}function Vu(e,t,n,{reactiveGeom:i}={}){const r={...n,...n.tooltipFormat},s={},o=i?"datum.datum":"datum",a=[];function c(l,f){const d=jt(f),p=ae(l)?l:{...l,type:e[d].type},g=p.title||_s(p,r),m=q(g).join(", ").replaceAll(/"/g,'\\"');let h;if(Q(f)){const y=f==="x"?"x2":"y2",$=Ke(e[y]);if(ne(p.bin)&&$){const C=w(p,{expr:o}),_=w($,{expr:o}),{format:T,formatType:M}=Wi(p);h=Kn(C,_,T,M,r),s[y]=!0}}if((Q(f)||f===we||f===ke)&&t&&t.fieldChannel===f&&t.offset==="normalize"){const{format:y,formatType:$}=Wi(p);h=Ss({fieldOrDatumDef:p,format:y,formatType:$,expr:o,config:r,normalizeStack:!0}).signal}h??(h=nr(p,r,o).signal),a.push({channel:f,key:m,value:h})}Ns(e,(l,f)=>{S(l)?c(l,f):ji(l)&&c(l.condition,f)});const u={};for(const{channel:l,key:f,value:d}of a)!s[l]&&!u[f]&&(u[f]=d);return u}function Xu(e,t,n,{reactiveGeom:i}={}){const r=Vu(e,t,n,{reactiveGeom:i}),s=bt(r).map(([o,a])=>`"${o}": ${a}`);return s.length>0?{signal:`{${s.join(", ")}}`}:void 0}function oy(e){const{markDef:t,config:n}=e,i=z("aria",t,n);return i===!1?{}:{...i?{aria:i}:{},...ay(e),...cy(e)}}function ay(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 Id?{}:{ariaRoleDescription:{value:t}}}function cy(e){const{encoding:t,markDef:n,config:i,stack:r}=e,s=t.description;if(s)return Nn(e,s,"description",c=>nr(c,e.config));const o=z("description",n,i);if(o!=null)return{description:B(o)};if(i.aria===!1)return{};const a=Vu(t,r,i);return I(a)?void 0:{description:{signal:bt(a).map(([c,u],l)=>`"${l>0?"; ":""}${c}: " + (${u})`).join(" + ")}}}function ee(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=B(c)));const u=r[e];return Nn(t,u,o??e,l=>xs({channel:e,channelDef:l,markDef:i,config:s,scaleName:t.scaleName(e),scale:t.getScaleComponent(e),stack:null,defaultRef:a}))}function Yu(e,t={filled:void 0}){const{markDef:n,encoding:i,config:r}=e,{type:s}=n,o=t.filled??z("filled",n,r),a=P(["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:B(c)}:{},...u?{stroke:B(u)}:{}};return n.color&&(o?n.fill:n.stroke)&&x(Ua("property",{fill:"fill"in n,stroke:"stroke"in n})),{...f,...ee("color",e,{vgChannel:l,defaultValue:o?c:u}),...ee("fill",e,{defaultValue:i.fill?c:void 0}),...ee("stroke",e,{defaultValue:i.stroke?u:void 0})}}function uy(e){const{encoding:t,mark:n}=e,i=t.order;return!Ft(n)&&Pe(i)?Nn(e,i,"zindex",r=>B(r.value)):{}}function Tn({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=xs({channel:s,channelDef:a,markDef:t,config:i?.config,scaleName:i.scaleName(s),scale:i.getScaleComponent(s),stack:null,defaultRef:B(o),bandPosition:r});return{offsetType:"encoding",offset:u}}const c=t[s];return c?{offsetType:"visual",offset:c}:{}}function re(e,t,{defaultPos:n,vgChannel:i}){const{encoding:r,markDef:s,config:o,stack:a}=t,c=r[e],u=r[He(e)],l=t.scaleName(e),f=t.getScaleComponent(e),{offset:d,offsetType:p}=Tn({channel:e,markDef:s,encoding:r,model:t,bandPosition:.5}),g=to({model:t,defaultPos:n,channel:e,scaleName:l,scale:f}),m=!c&&Q(e)&&(r.latitude||r.longitude)?{field:t.getName(e)}:ly({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 ly(e){const{channel:t,channelDef:n,scaleName:i,stack:r,offset:s,markDef:o}=e;if(F(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 Vt(n,i,{suffix:"end"},{offset:s})}return ys(e)}function to({model:e,defaultPos:t,channel:n,scaleName:i,scale:r}){const{markDef:s,config:o}=e;return()=>{const a=jt(n),c=Et(n),u=z(n,s,o,{vgChannel:c});if(u!==void 0)return Yn(n,u);switch(t){case"zeroOrMin":case"zeroOrMax":if(i){const l=r.get("type");if(!P([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 fy={left:"x",center:"xc",right:"x2"},dy={top:"y",middle:"yc",bottom:"y2"};function Ku(e,t,n,i="middle"){if(e==="radius"||e==="theta")return Et(e);const r=e==="x"?"align":"baseline",s=z(r,t,n);let o;return E(s)?(x(mp(r)),o=void 0):o=s,e==="x"?fy[o||(i==="top"?"left":"center")]:dy[o||i]}function ir(e,t,{defaultPos:n,defaultPos2:i,range:r}){return r?Qu(e,t,{defaultPos:n,defaultPos2:i}):re(e,t,{defaultPos:n})}function Qu(e,t,{defaultPos:n,defaultPos2:i}){const{markDef:r,config:s}=t,o=He(e),a=de(e),c=py(t,i,o),u=c[a]?Ku(e,r,s):Et(e);return{...re(e,t,{defaultPos:n,vgChannel:u}),...c}}function py(e,t,n){const{encoding:i,mark:r,markDef:s,stack:o,config:a}=e,c=jt(n),u=de(n),l=Et(n),f=i[c],d=e.scaleName(c),p=e.getScaleComponent(c),{offset:g}=n in i||n in s?Tn({channel:n,markDef:s,encoding:i,model:e}):Tn({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=gy({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]:to({model:e,defaultPos:t,channel:n,scaleName:d,scale:p})()}}function gy({channel:e,channelDef:t,channel2Def:n,markDef:i,config:r,scaleName:s,scale:o,stack:a,offset:c,defaultRef:u}){return F(t)&&a&&e.charAt(0)===a.fieldChannel.charAt(0)?Vt(t,s,{suffix:"start"},{offset:c}):ys({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=Et(e);if(t[i]!==void 0)return{[i]:Yn(e,t[i])};if(t[e]!==void 0)return{[i]:Yn(e,t[e])};if(t[n]){const r=t[n];if(Gt(r))x(cp(n));else return{[n]:Yn(e,r)}}return}function Ot(e,t){const{config:n,encoding:i,markDef:r}=e,s=r.type,o=He(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=pa(t),m=s==="bar"&&(t==="x"?d==="vertical":d==="horizontal");return S(c)&&(j(c.bin)||ne(c.bin)||c.timeUnit&&!u)&&!(p&&!Gt(p))&&!i[g]&&!J(f)?yy({fieldDef:c,fieldDef2:u,channel:t,model:e}):(F(c)&&J(f)||m)&&!u?hy(c,t,e):Qu(t,e,{defaultPos:"zeroOrMax",defaultPos2:"zeroOrMin"})}function my(e,t,n,i,r,s,o){if(Gt(r))if(n){const c=n.get("type");if(c==="band"){let u=`bandwidth('${t}')`;r.band!==1&&(u=`${r.band} * ${u}`);const l=ft("minBandSize",{type:o},i);return{signal:l?`max(${Te(l)}, ${u})`:u}}else r.band!==1&&(x(xp(c)),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 c=n.get("range");if(Ct(c)&&V(c.step))return{value:c.step-2}}if(!s){const{bandPaddingInner:c,barBandPaddingInner:u,rectBandPaddingInner:l}=i.scale,f=X(c,o==="bar"?u:l);if(E(f))return{signal:`(1 - (${f.signal})) * ${e}`};if(V(f))return{signal:`${1-f} * ${e}`}}const a=Zi(i.view,e);return{value:a-2}}function hy(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=He(t),d=pa(t),p=n.scaleName(d),g=n.getScaleComponent(Ur(t)),m=a==="horizontal"&&t==="y"||a==="vertical"&&t==="x";let h;(r.size||i.size)&&(m?h=ee("size",n,{vgChannel:l,defaultRef:B(i.size)}):x(vp(i.type)));const y=!!h,$=Tc({channel:t,fieldDef:e,markDef:i,config:s,scaleType:u?.get("type"),useVlSizeChannel:m});h=h||{[l]:my(l,p||c,g||u,s,$,!!e,i.type)};const C=u?.get("type")==="band"&&Gt($)&&!y?"top":"middle",_=Ku(t,i,s,C),T=_==="xc"||_==="yc",{offset:M,offsetType:he}=Tn({channel:t,markDef:i,encoding:r,model:n,bandPosition:T?.5:0}),ie=ys({channel:t,channelDef:e,markDef:i,config:s,scaleName:c,scale:u,stack:o,offset:M,defaultRef:to({model:n,defaultPos:"mid",channel:t,scaleName:c,scale:u}),bandPosition:T?he==="encoding"?0:.5:E($)?{signal:`(1-${$})/2`}:Gt($)?(1-$.band)/2:0});if(l)return{[_]:ie,...h};{const Me=Et(f),yt=h[l],tt=M?{...yt,offset:M}:yt;return{[_]:ie,[Me]:v(ie)?[ie[0],{...ie[1],offset:tt}]:{...ie,offset:tt}}}}function Zu(e,t,n,i,r,s,o){if(aa(e))return 0;const a=e==="x"||e==="y2",c=a?-t/2:t/2;if(E(n)||E(r)||E(i)||s){const u=Te(n),l=Te(r),f=Te(i),d=Te(s),p=a?"":"-",g=s?`(${o} < ${d} ? ${p}0.5 * (${d} - (${o})) : ${c})`:c,m=f?`${f} + `:"",h=u?`(${u} ? -1 : 1) * `:"",y=l?`(${l} + ${g})`:g;return{signal:m+h+y}}else return r=r||0,i+(n?-r-c:+r+c)}function yy({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=Tc({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=He(n),h=Et(n),y=Et(m),$=ft("minBandSize",s,r),{offset:C}=Tn({channel:n,markDef:s,encoding:o,model:i,bandPosition:0}),{offset:_}=Tn({channel:m,markDef:s,encoding:o,model:i,bandPosition:0}),T=Hg({fieldDef:e,scaleName:c}),M=Zu(n,g,l,p,C,$,T),he=Zu(m,g,l,p,_??C,$,T),ie=E(f)?{signal:`(1-${f.signal})/2`}:Gt(f)?(1-f.band)/2:.5;if(j(e.bin)||e.timeUnit)return{[y]:Ju({fieldDef:e,scaleName:c,bandPosition:ie,offset:he}),[h]:Ju({fieldDef:e,scaleName:c,bandPosition:E(ie)?{signal:`1-${ie.signal}`}:1-ie,offset:M})};if(ne(e.bin)){const Me=Vt(e,c,{},{offset:he});if(S(t))return{[y]:Me,[h]:Vt(t,c,{},{offset:M})};if(Ut(e.bin)&&e.bin.step)return{[y]:Me,[h]:{signal:`scale("${c}", ${w(e,{expr:"datum"})} + ${e.bin.step})`,offset:M}}}x(Ga(m));return}function Ju({fieldDef:e,scaleName:t,bandPosition:n,offset:i}){return Ii({scaleName:t,fieldOrDatumDef:e,bandPosition:n,offset:i})}const by=new Set(["aria","width","height"]);function Ee(e,t){const{fill:n=void 0,stroke:i=void 0}=t.color==="include"?Yu(e):{};return{...xy(e.markDef,t),...el(e,"fill",n),...el(e,"stroke",i),...ee("opacity",e),...ee("fillOpacity",e),...ee("strokeOpacity",e),...ee("strokeWidth",e),...ee("strokeDash",e),...uy(e),...Gu(e),...eo(e,"href"),...oy(e)}}function el(e,t,n){const{config:i,mark:r,markDef:s}=e,o=z("invalid",s,i);if(o==="hide"&&n&&!Ft(r)){const a=Sy(e,{invalid:!0,channels:_i});if(a)return{[t]:[{test:a,value:null},...q(n)]}}return n?{[t]:n}:{}}function xy(e,t){return Rd.reduce((n,i)=>(!by.has(i)&&e[i]!==void 0&&t[i]!=="ignore"&&(n[i]=B(e[i])),n),{})}function Sy(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&&be(c)&&(s[u]=!0)}return s},{}),r=b(i);if(r.length>0){const s=t?"||":"&&";return r.map(o=>bs(o,t)).join(` ${s} `)}return}function no(e){const{config:t,markDef:n}=e,i=z("invalid",n,t);if(i){const r=wy(e,{channels:qe});if(r)return{defined:{signal:r}}}return{}}function wy(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&&be(c)&&(s[u]=!0)}return s},{}),r=b(i);if(r.length>0){const s=t?"||":"&&";return r.map(o=>bs(o,t)).join(` ${s} `)}return}function tl(e,t){return t!==void 0?{[e]:B(t)}:void 0}const io="voronoi",nl={defined:e=>e.type==="point"&&e.nearest,parse:(e,t)=>{if(t.events)for(const n of t.events)n.markname=e.getName(io)},marks:(e,t,n)=>{const{x:i,y:r}=t.project.hasChannel,s=e.mark;if(Ft(s))return x(Ud(s)),n;const o={name:e.getName(io),type:"path",interactive:!0,from:{data:e.getName("marks")},encode:{update:{fill:{value:"transparent"},strokeWidth:{value:.35},stroke:{value:"transparent"},isVoronoi:{value:!0},...Gu(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(io)>=0&&(c=!0)}),c||n.splice(a+1,0,o),n}},il={defined:e=>e.type==="point"&&e.resolve==="global"&&e.bind&&e.bind!=="scales"&&!Is(e.bind),parse:(e,t,n)=>pl(t,n),topLevelSignals:(e,t,n)=>{const i=t.name,r=t.project,s=t.bind,o=t.init&&t.init[0],a=nl.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:Qt(o[u])}:{value:null},on:t.events?[{events:t.events,update:`datum && item().mark.marktype !== 'group' ? ${a}[${A(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+Pt)[0],o=i+ni,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",rl={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+Pt,i=t.name+sr;return`${i} ? null : ${n}, `+(t.resolve==="global"?`${i} ? null : true, `:`${i} ? null : {unit: ${Jt(e)}}, `)+`${i} ? ${n} : null`}},$y={defined:e=>e.clear!==void 0&&e.clear!==!1,parse:(e,t)=>{t.clear&&(t.clear=N(t.clear)?un(t.clear,"view"):t.clear)},topLevelSignals:(e,t,n)=>{if(il.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+Pt);i(r,"null"),rl.defined(t)&&(r=n.findIndex(s=>s.name===t.name+sr),i(r,"false"))}return n}},sl={defined:e=>{const t=e.resolve==="global"&&e.bind&&Is(e.bind),n=e.project.items.length===1&&e.project.items[0].field!==ze;return t&&!n&&x(Hd),t&&n},parse:(e,t,n)=>{const i=k(n);if(i.select=N(i.select)?{type:i.select,toggle:t.toggle}:{...i.select,toggle:t.toggle},pl(t,i),Cr(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=q(a.filter??[]),a.filter.includes(o)||a.filter.push(o)}const r=Ls(t.bind)?t.bind.legend:"click",s=N(r)?un(r,"view"):q(r);t.bind={legend:{merge:s}}},topLevelSignals:(e,t,n)=>{const i=t.name,r=Ls(t.bind)&&t.bind.legend,s=o=>a=>{const c=k(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:"isDefined(datum.value) ? 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+Pt),o=i+ni,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=Ls(t.bind)&&t.bind.legend;return l&&(t.events?l.on.push({...l.on[0],events:f}):l.on[0].events=f),n}};function vy(e,t,n){const i=e.fieldDef(t)?.field;for(const r of te(e.component.selection??{})){const s=r.project.hasField[i]??r.project.hasChannel[t];if(s&&sl.defined(r)){const o=n.get("selections")??[];o.push(r.name),n.set("selections",o,!1),s.hasLegend=!0}}}const ol="_translate_anchor",al="_translate_delta",Ey={defined:e=>e.type==="interval"&&e.translate,signals:(e,t,n)=>{const i=t.name,r=mt.defined(t),s=i+ol,{x:o,y:a}=t.project.hasChannel;let c=un(t.translate,"scope");return r||(c=c.map(u=>(u.between[0].markname=i+Fn,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?Zs(e,H):`slice(${o.signals.visual})`}`:"")+(a!==void 0?`, extent_y: ${r?Zs(e,K):`slice(${a.signals.visual})`}`:"")+"}"}]},{name:i+al,value:{},on:[{events:c,update:`{x: ${s}.x - x(unit), y: ${s}.y - y(unit)}`}]}),o!==void 0&&cl(e,t,o,"width",n),a!==void 0&&cl(e,t,a,"height",n),n}};function cl(e,t,n,i,r){const s=t.name,o=s+ol,a=s+al,c=n.channel,u=mt.defined(t),l=r.filter(T=>T.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===H?g?"":"-":g?"-":"":"",h=`${o}.extent_${c}`,y=`${m}${a}.${c} / ${u?`${f}`:`span(${h})`}`,$=!u||!d?"panLinear":p==="log"?"panLog":p==="symlog"?"panSymlog":p==="pow"?"panPow":"panLinear",C=u?p==="pow"?`, ${d.get("exponent")??1}`:p==="symlog"?`, ${d.get("constant")??1}`:"":"",_=`${$}(${h}, ${y}${C})`;l.on.push({events:{signal:a},update:u?_:`clampRange(${_}, 0, ${f})`})}const ul="_zoom_anchor",ll="_zoom_delta",_y={defined:e=>e.type==="interval"&&e.zoom,signals:(e,t,n)=>{const i=t.name,r=mt.defined(t),s=i+ll,{x:o,y:a}=t.project.hasChannel,c=A(e.scaleName(H)),u=A(e.scaleName(K));let l=un(t.zoom,"scope");return r||(l=l.map(f=>(f.markname=i+Fn,f))),n.push({name:i+ul,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&&fl(e,t,o,"width",n),a!==void 0&&fl(e,t,a,"height",n),n}};function fl(e,t,n,i,r){const s=t.name,o=n.channel,a=mt.defined(t),c=r.filter($=>$.name===n.signals[a?"data":"visual"])[0],u=e.getSizeSignalRef(i).signal,l=e.getScaleComponent(o),f=l&&l.get("type"),d=a?Zs(e,o):c.name,p=s+ll,g=`${s}${ul}.${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 Zt="_store",Pt="_tuple",ky="_modify",dl="vlSelectionResolve",or=[sy,iy,ty,rl,il,mt,sl,$y,Ey,_y,nl];function Cy(e){let t=e.parent;for(;t&&!Le(t);)t=t.parent;return t}function Jt(e,{escape:t}={escape:!0}){let n=t?A(e.name):e.name;const i=Cy(e);if(i){const{facet:r}=i;for(const s of ve)r[s]&&(n+=` + '__facet_${s}_' + (facet[${A(i.vgField(s))}])`)}return n}function ro(e){return te(e.component.selection??{}).reduce((t,n)=>t||n.project.hasSelectionId,!1)}function pl(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 so(e){const t=[];return e.type==="Identifier"?[e.name]:e.type==="Literal"?[e.value]:(e.type==="MemberExpression"&&(t.push(...so(e.object)),t.push(...so(e.property))),t)}function gl(e){return e.object.type==="MemberExpression"?gl(e.object):e.object.name==="datum"}function ml(e){const t=If(e),n=new Set;return t.visit(i=>{i.type==="MemberExpression"&&gl(i)&&n.add(so(i).slice(1).join("."))}),n}class An extends R{clone(){return new An(null,this.model,k(this.filter))}constructor(t,n,i){super(t);this.model=n,this.filter=i,this.expr=ar(this.model,this.filter,this),this._dependentFields=ml(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=N(o)?o:o.type,c=L(o)?k(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]=k(u[d]??c[d]))}const l=n[s]={...c,name:s,type:a,init:r.value,bind:r.bind,events:N(c.on)?un(c.on,"scope"):q(k(c.on))},f=k(r);for(const d of or)d.defined(l)&&d.parse&&d.parse(e,l,f)}return n}function hl(e,t,n,i="datum"){const r=N(t)?t:t.param,s=W(r),o=A(s+Zt);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"?")":`, ${A(a.resolve)})`,l=`${c}${o}, ${i}${u}`,f=`length(data(${o}))`;return t.empty===!1?`${f} && ${l}`:`!${f} || ${l}`}function yl(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": ${A(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 ${A(r)} encoding found for selection ${A(n.param)}. Using "field": ${A(s)}.`)):s=a[0].field}return`${o.name}[${A(Se(s))}]`}function Ny(e,t){for(const[n,i]of bt(e.component.selection??{})){const r=e.getName(`lookup_${n}`);e.component.data.outputNodes[r]=i.materialized=new ce(new An(t,e,{param:n}),r,U.Lookup,e.component.data.outputNodeRefCounts)}}function ar(e,t,n){return Bn(t,i=>N(i)?i:og(i)?hl(e,i,n):rc(i))}function Ty(e,t){return e?v(e)&&!kt(e)?e.map(n=>_s(n,t)).join(", "):e:void 0}function oo(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=um[f],p=l[f];if(d&&d!==t&&d!=="both")delete l[f];else if(ei(p)){const{condition:g,...m}=p,h=q(g),y=Uc[f];if(y){const{vgProp:$,part:C}=y,_=[...h.map(T=>{const{test:M,...he}=T;return{test:ar(null,M),...he}}),m];oo(l,C,$,_),delete l[f]}else if(y===null){const $={signal:h.map(C=>{const{test:_,...T}=C;return`${ar(null,_)} ? ${_a(T)} : `}).join("")+_a(m)};l[f]=$}}else if(E(p)){const g=Uc[f];if(g){const{vgProp:m,part:h}=g;oo(l,h,m,p),delete l[f]}}P(["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}:{}},I(l.encode)&&delete l.encode}return{scale:o,orient:s,...l,domain:!1,labels:!1,aria:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:X(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=Lt(a,"datum.label",l.encode.labels.update.text.signal)),oo(l,"labels","text",{signal:d})}if(l.labelAlign===null&&delete l.labelAlign,l.encode){for(const d of Bc)e.hasAxisPart(d)||delete l.encode[d];I(l.encode)&&delete l.encode}const f=Ty(c,n);return{scale:o,orient:s,grid:!1,...f?{title:f}:{},...l,...n.aria===!1?{aria:!1}:{},zindex:X(u,0)}}}function bl(e){const{axes:t}=e.component,n=[];for(const i of qe)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 Ay(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 xl(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}" ? ${Te(o[l])} : ${Te(a[l])}`};return u}return t[r]})])}function Oy(e,t,n,i){const r=t==="band"?["axisDiscrete","axisBand"]:t==="point"?["axisDiscrete","axisPoint"]:uc(t)?["axisQuantitative"]:t==="time"||t==="utc"?["axisTemporal"]:[],s=e==="x"?"axisX":"axisY",o=E(n)?"axisOrient":`axis${Wn(n)}`,a=[...r,...r.map(u=>s+u.substr(4))],c=["axis",o,s];return{vlOnlyAxisConfig:xl(a,i,e,n),vgAxisConfig:xl(c,i,e,n),axisConfigStyle:Py([...c,...a],i)}}function Py(e,t){const n=[{}];for(const i of e){let r=t[i]?.style;if(r){r=q(r);for(const s of r)n.push(t.style[s])}}return Object.assign.apply(null,n)}function ao(e,t,n,i={}){const r=Ca(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 Sl={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??zy(n,e),gridScale:({model:e,channel:t})=>Ry(e,t),labelAlign:({axis:e,labelAngle:t,orient:n,channel:i})=>e.labelAlign||$l(t,n,i),labelAngle:({labelAngle:e})=>e,labelBaseline:({axis:e,labelAngle:t,orient:n,channel:i})=>e.labelBaseline||wl(t,n,i),labelFlush:({axis:e,fieldOrDatumDef:t,channel:n})=>e.labelFlush??Ly(t.type,n),labelOverlap:({axis:e,fieldOrDatumDef:t,scaleType:n})=>e.labelOverlap??My(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??jy({fieldOrDatumDef:i,scaleType:r,size:o,values:n.values})},tickMinStep:Uy,title:({axis:e,model:t,channel:n})=>{if(e.title!==void 0)return e.title;const i=vl(t,n);if(i!==void 0)return i;const r=t.typedFieldDef(n),s=n==="x"?"x2":"y2",o=t.fieldDef(s);return Na(r?[Fc(r)]:[],S(o)?[Fc(o)]:[])},values:({axis:e,fieldOrDatumDef:t})=>By(e,t),zindex:({axis:e,fieldOrDatumDef:t,mark:n})=>e.zindex??Wy(n,t)};function zy(e,t){return!J(e)&&S(t)&&!j(t?.bin)&&!ne(t?.bin)}function Ry(e,t){const n=t==="x"?"y":"x";return e.getScaleComponent(n)?e.scaleName(n):void 0}function Iy(e,t,n,i,r){const s=t?.labelAngle;if(s!==void 0)return E(s)?s:Hn(s);{const{configValue:o}=ao("labelAngle",i,t?.style,r);return o!==void 0?Hn(o):n===H&&P([ls,us],e.type)&&!(S(e)&&e.timeUnit)?270:void 0}}function co(e){return`(((${e.signal} % 360) + 360) % 360)`}function wl(e,t,n,i){if(e!==void 0)if(n==="x"){if(E(e)){const r=co(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(!Yt(i))return;if(Cc(i.sort)){const{field:s,timeUnit:o}=i,a=i.sort,c=a.map((u,l)=>`${rc({field:s,timeUnit:o,equal:u})} ? ${l} : `).join("")+a.length;t=new On(t,{calculate:c,as:Pn(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 Pn(e,t,n){return w(e,{prefix:t,suffix:"sort_index",...n??{}})}function cr(e,t){return P(["top","bottom"],t)?"column":P(["left","right"],t)||e==="row"?"row":"column"}function zn(e,t,n,i){const r=i==="row"?n.headerRow:i==="column"?n.headerColumn:n.headerFacet;return X((t||{})[e],r[e],n.header[e])}function ur(e,t,n,i){const r={};for(const s of e){const o=zn(s,t||{},n,i);o!==void 0&&(r[s]=o)}return r}const uo=["row","column"],lo=["header","footer"];function Hy(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=Hn(o);return{name:`${t}-title`,type:"group",role:`${c}-title`,title:{text:n,...t==="row"?{orient:"left"}:{},style:"guide-title",..._l(u,c),...El(c,u,s),...kl(i,r,t,Am,ou)}}}function El(e,t,n="middle"){switch(n){case"start":return{align:"left"};case"end":return{align:"right"}}const i=$l(t,e==="row"?"left":"top",e==="row"?"y":"x");return i?{align:i}:{}}function _l(e,t){const n=wl(e,t==="row"?"left":"top",t==="row"?"y":"x",!0);return n?{baseline:n}:{}}function qy(e,t){const n=e.component.layoutHeaders[t],i=[];for(const r of lo)if(n[r])for(const s of n[r]){const o=Vy(e,t,r,n,s);o!=null&&i.push(o)}return i}function Gy(e,t){const{sort:n}=e;return Xe(n)?{field:w(n,{expr:"datum"}),order:n.order??"ascending"}:v(n)?{field:Pn(e,t,{expr:"datum"}),order:"ascending"}:{field:w(e,{expr:"datum"}),order:n??"ascending"}}function fo(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=Ss({fieldOrDatumDef:e,format:i,formatType:r,expr:"parent",config:n}).signal,l=cr(t,a);return{text:{signal:c?Lt(Lt(c,"datum.label",u),"datum.value",w(e,{expr:"parent"})):u},...t==="row"?{orient:"left"}:{},style:"guide-label",frame:"group",..._l(s,l),...El(l,s,o),...kl(n,e,t,Om,au)}}function Vy(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"&&!P(["top","bottom"],f)||t==="column"&&!P(["left","right"],f))&&(s=fo(o,t,a))}const c=Le(e)&&!Qn(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:Gy(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 Xy={column:{start:0,end:1},row:{start:1,end:0}};function Yy(e,t){return Xy[t][e]}function Ky(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=Yy(s,a);c!==void 0&&(n[a]=c)}}return I(n)?void 0:n}function kl(e,t,n,i,r){const s={};for(const o of i){if(!r[o])continue;const a=zn(o,t?.header,e,n);a!==void 0&&(s[r[o]]=a)}return s}function po(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(J(o)&&Ct(a)){const c=e.scaleName(n);if(Le(e.parent)){const u=e.parent.component.resolve;if(u.scale[n]==="independent")return[Cl(c,a)]}return[Cl(c,a),{name:r,update:Fl(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=Us(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 Cl(e,t){const n=`${e}_step`;return E(t.step)?{name:n,update:t.step.signal}:{name:n,value:t.step}}function Fl(e,t,n){const i=t.get("type"),r=t.get("padding"),s=X(t.get("paddingOuter"),r);let o=t.get("paddingInner");return o=i==="band"?o!==void 0?o:r:1,`bandspace(${n}, ${Te(o)}, ${Te(s)}) * ${e}_step`}function Nl(e){return e==="childWidth"?"width":e==="childHeight"?"height":e}function Tl(e,t){return b(e).reduce((n,i)=>{const r=e[i];return{...n,...Nn(t,r,i,s=>B(s.value))}},{})}function Al(e,t){if(Le(t))return e==="theta"?"independent":"shared";if(Ln(t))return"shared";if(Fo(t))return Q(e)||e==="theta"||e==="radius"?"independent":"shared";throw new Error("invalid model type for resolve")}function go(e,t){const n=e.scale[t],i=Q(t)?"axis":"legend";return n==="independent"?(e[i][t]==="shared"&&x(Fp(t)),"independent"):e[i][t]||"shared"}const Qy={...Rm,disable:1,labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1},Ol=b(Qy);class Zy extends gt{}const Pl={symbols:Jy,gradient:eb,labels:tb,entries:nb};function Jy(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={...Md({},n,Ag),...Yu(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?zl(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=B(c.legend.symbolBaseFillColor??"black"),f.fillOpacity=B(m??1));else if(v(f.fill)){const h=mo(a.fill??a.color)??o.fill??(l&&o.color);h&&(f.fill=B(h))}}if(f.stroke){if(i==="stroke"||!l&&i===le)delete f.stroke;else if(f.stroke.field||g)delete f.stroke;else if(v(f.stroke)){const h=X(mo(a.stroke||a.color),o.stroke,l?o.color:void 0);h&&(f.stroke={value:h})}}if(i!==at){const h=S(t)&&Il(n,r,t);h?f.opacity=[{test:h,...B(m??1)},B(c.legend.unselectedOpacity)]:m&&(f.opacity=B(m))}return f={...f,...e},I(f)?void 0:f}function eb(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?zl(o.opacity)||s.opacity:void 0;return u&&(a.opacity=B(u)),a={...a,...e},I(a)?void 0:a}function tb(e,{fieldOrDatumDef:t,model:n,channel:i,legendCmpt:r}){const s=n.legend(i)||{},o=n.config,a=S(t)?Il(n,r,t):void 0,c=a?[{test:a,value:1},{value:o.legend.unselectedOpacity}]:void 0,{format:u,formatType:l}=s;let f;Xt(l)?f=Oe({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=Oe({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=Oe({fieldOrDatumDef:t,field:"datum.value",format:o.timeFormat,formatType:o.timeFormatType,config:o})));const d={...c?{opacity:c}:{},...f?{text:f}:{},...e};return I(d)?void 0:d}function nb(e,{legendCmpt:t}){const n=t.get("selections");return n?.length?{...e,fill:{value:"transparent"}}:e}function zl(e){return Rl(e,(t,n)=>Math.max(t,n.value))}function mo(e){return Rl(e,(t,n)=>X(t,n.value))}function Rl(e,t){return Qg(e)?q(e.condition).reduce(t,e.value):Pe(e)?e.value:void 0}function Il(e,t,n){const i=t.get("selections");if(!i?.length)return;const r=A(n.field);return i.map(s=>{const o=A(W(s)+Zt);return`(!length(data(${o})) || (${s}[${r}] && indexof(${s}[${r}], datum.value) >= 0))`}).join(" || ")}const Ll={direction:({direction:e})=>e,format:({fieldOrDatumDef:e,legend:t,config:n})=>{const{format:i,formatType:r}=t;return wc(e,e.type,i,r,n,!1)},formatType:({legend:e,fieldOrDatumDef:t,scaleType:n})=>{const{formatType:i}=e;return $c(i,t,n)},gradientLength:e=>{const{legend:t,legendConfig:n}=e;return t.gradientLength??n.gradientLength??ub(e)},labelOverlap:({legend:e,legendConfig:t,scaleType:n})=>e.labelOverlap??t.labelOverlap??lb(n),symbolType:({legend:e,markDef:t,channel:n,encoding:i})=>e.symbolType??rb(t.type,n,i.shape,t.shape),title:({fieldOrDatumDef:e,config:t})=>vn(e,t,{allowDisabling:!0}),type:({legendType:e,scaleType:t,channel:n})=>{if(mn(n)&&Ae(t)){if(e==="gradient")return}else if(e==="symbol")return;return e},values:({fieldOrDatumDef:e,legend:t})=>ib(t,e)};function ib(e,t){const n=e.values;return v(n)?jc(t,n):E(n)?n:void 0}function rb(e,t,n,i){if(t!=="shape"){const r=mo(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 sb(e){const{legend:t}=e;return X(t.type,ob(e))}function ob({channel:e,timeUnit:t,scaleType:n}){if(mn(e)){if(P(["quarter","month","day"],t))return"symbol";if(Ae(n))return"gradient"}return"symbol"}function ab({legendConfig:e,legendType:t,orient:n,legend:i}){return i.direction??e[t?"gradientDirection":"symbolDirection"]??cb(n,t)}function cb(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 ub({legendConfig:e,model:t,direction:n,orient:i,scaleType:r}){const{gradientHorizontalMaxLength:s,gradientHorizontalMinLength:o,gradientVerticalMaxLength:a,gradientVerticalMinLength:c}=e;return Ae(r)?n==="horizontal"?i==="top"||i==="bottom"?Ml(t,"width",o,s):o:Ml(t,"height",c,a):void 0}function Ml(e,t,n,i){const r=e.getSizeSignalRef(t).signal;return{signal:`clamp(${r}, ${n}, ${i})`}}function lb(e){return P(["quantile","threshold","log","symlog"],e)?"greedy":void 0}function Dl(e){const t=G(e)?fb(e):mb(e);return e.component.legends=t,t}function fb(e){const{encoding:t}=e,n={};for(const i of[le,...uu]){const r=Y(t[i]);if(!r||!e.getScaleComponent(i))continue;if(i===fe&&S(r)&&r.type===xn)continue;n[i]=gb(e,i)}return n}function db(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 pb(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 gb(e,t){let n=e.legend(t);const{markDef:i,encoding:r,config:s}=e,o=s.legend,a=new Zy({},db(e,t));vy(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=Y(r[t]),f=S(l)?Z(l.timeUnit)?.unit:void 0,d=n.orient||s.legend.orient||"right",p=sb({legend:n,channel:t,timeUnit:f,scaleType:u}),g=ab({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 _ of Ol){if(p==="gradient"&&_.startsWith("symbol")||p==="symbol"&&_.startsWith("gradient"))continue;const T=_ in Ll?Ll[_](m):n[_];if(T!==void 0){const M=pb(T,_,n,e.fieldDef(t));(M||s.legend[_]===void 0)&&a.set(_,T,M)}}const h=n?.encoding??{},y=a.get("selections"),$={},C={fieldOrDatumDef:l,model:e,channel:t,legendCmpt:a,legendType:p};for(const _ of["labels","legend","title","symbols","gradient","entries"]){const T=Tl(h[_]??{},e),M=_ in Pl?Pl[_](T,C):T;M!==void 0&&!I(M)&&($[_]={...y?.length&&S(l)?{name:`${W(l.field)}_legend_${_}`}:{},...y?.length?{interactive:!!y}:{},update:M})}return I($)||a.set("encode",$,!!n?.encoding),a}function mb(e){const{legends:t,resolve:n}=e.component;for(const i of e.children){Dl(i);for(const r of b(i.component.legends))n.legend[r]=go(e.component.resolve,r),n.legend[r]==="shared"&&(t[r]=jl(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 jl(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 Ol){const o=Tt(e.getWithExplicit(s),t.getWithExplicit(s),s,"legend",(a,c)=>{switch(s){case"symbolType":return hb(a,c);case"title":return Aa(a,c);case"type":return r=!0,xe("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 hb(e,t){return t.value==="circle"?t:e}function yb(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 Ul(e){const t=e.component.legends,n={};for(const r of b(t)){const s=e.getScaleComponent(r),o=D(s.get("domains"));if(n[o])for(const a of n[o]){const c=jl(a,t[r]);c||n[o].push(t[r])}else n[o]=[t[r].clone()]}const i=te(n).flat().map(r=>bb(r,e.config)).filter(r=>r!==void 0);return i}function bb(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 uu)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=Lt(i,"datum.label",s.encode.labels.update.text.signal)),yb(s,"labels","text",{signal:o})}return s}function xb(e){return Ln(e)||Fo(e)?Sb(e):Bl(e)}function Sb(e){return e.children.reduce((t,n)=>t.concat(n.assembleProjections()),Bl(e))}function Bl(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 P(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 wb=["type","clipAngle","clipExtent","center","rotate","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];class Wl extends gt{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 Hl(e){e.component.projection=G(e)?$b(e):_b(e)}function $b(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?vb(e):void 0,s=new Wl(e.projectionName(!0),{...pe(e.config.projection)??{},...t??{}},i,r);return s.get("type")||s.set("type","equalEarth",!1),s}return}function vb(e){const t=[],{encoding:n}=e;for(const i of[[Fe,Ce],[$e,Ne]])(Y(n[i[0]])||Y(n[i[1]]))&&t.push({signal:e.getName(`geojson_${t.length}`)});return e.channelHasField(fe)&&e.typedFieldDef(fe).type===xn&&t.push({signal:e.getName(`geojson_${t.length}`)}),t.length===0&&t.push(e.requestDataName(U.Main)),t}function Eb(e,t){const n=Or(wb,r=>!an(e.explicit,r)&&!an(t.explicit,r)?!0:!!(an(e.explicit,r)&&an(t.explicit,r)&&De(e.get(r),t.get(r)))),i=De(e.size,t.size);if(i){if(n)return e;if(De(e.explicit,{}))return t;if(De(t.explicit,{}))return e}return null}function _b(e){if(e.children.length===0)return;let t;for(const i of e.children)Hl(i);const n=Or(e.children,i=>{const r=i.component.projection;if(r)if(t){const s=Eb(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 Wl(i,t.specifiedProjection,t.size,k(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 kb(e,t,n,i){if(Jn(t,n)){const r=G(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:Kn(s,o,r.format,r.formatType,i)}}return{}}function ql(e,t){return`${Sa(e)}_${t}`}function Cb(e,t){return{signal:e.getName(`${t}_bins`),extentSignal:e.getName(`${t}_extent`)}}function ho(e,t,n){const i=qi(n,void 0)??{},r=ql(i,t);return e.getName(`${r}_bins`)}function Fb(e){return"as"in e}function Gl(e,t,n){let i,r;Fb(e)?i=N(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=ql(s,e.field),{signal:a,extentSignal:c}=Cb(n,o);if(ki(s.extent)){const l=s.extent;r=yl(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 et extends R{clone(){return new et(null,k(this.bins))}constructor(t,n){super(t);this.bins=n}static makeFromEncoding(t,n){const i=n.reduceFieldDef((r,s,o)=>{if(ae(s)&&j(s.bin)){const{key:a,binComponent:c}=Gl(s,s.bin,n);r[a]={...c,...r[a],...kb(n,s,o,n.config)}}return r},{});return I(i)?null:new et(t,i)}static makeFromTransform(t,n,i){const{key:r,binComponent:s}=Gl(n,n.bin,i);return new et(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=je([...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(te(this.bins).map(t=>t.as).flat(2))}dependentFields(){return new Set(te(this.bins).map(t=>t.field))}hash(){return`Bin ${O(this.bins)}`}assemble(){return te(this.bins).flatMap(t=>{const n=[],[i,...r]=t.as,{extent:s,...o}=t.bin,a={type:"bin",field:Se(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:Se(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 Nb(e,t,n,i){const r=G(i)?i.encoding[He(t)]:void 0;if(ae(n)&&G(i)&&Ac(n,r,i.markDef,i.config))e.add(w(n,{})),e.add(w(n,{suffix:"end"})),n.bin&&Jn(n,t)&&e.add(w(n,{binSuffix:"range"}));else if(ua(t)){const s=ca(t);e.add(i.getName(s))}else e.add(w(n));return Yt(n)&&xg(n.scale?.range)&&e.add(n.scale.range.field),e}function Tb(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 Re extends R{clone(){return new Re(null,new Set(this.dimensions),k(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(ut(c)||_t(c)){const l=ut(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})]);ct(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 Nb(s,a,o,n)}),s.size+b(r).length===0?null:new Re(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 Re(t,i,r)}merge(t){return ea(this.dimensions,t.dimensions)?(Tb(this.measures,t.measures),!0):(Hp("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:Se(s));const r={type:"aggregate",groupby:[...this.dimensions].map(Se),ops:t,fields:n,as:i};return r}}class Rn extends R{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),...j(a)?[w(o,{binSuffix:"end"})]:[]],...Xe(c)?{sortField:c}:v(c)?{sortIndexField:Pn(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 qe){const i=this.childModel.component.scales[n];if(i&&!i.merged){const r=i.get("type"),s=i.get("range");if(J(r)&&Ct(s)){const o=dr(this.childModel,n),a=ko(o);a?t[n]=a:x(Yr(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 uo){for(const u of lo){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[it,nt])this[a]&&t.push(this.assembleRowColumnHeaderData(a,n,i));if(o){const a=this.assembleFacetHeaderData(i);a&&t.push(...a)}return t}}function Vl(e){return e.startsWith("'")&&e.endsWith("'")||e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1):e}function Ab(e,t){const n=Ir(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=Vl(t.slice(5,t.length));return`timeParse(${n},'${i}')`}else if(t.startsWith("utc:")){const i=Vl(t.slice(4,t.length));return`utcParse(${n},'${i}')`}else return x(Qd(t)),null}function Ob(e){const t={};return hi(e.filter,n=>{if(ic(n)){let i=null;ts(n)?i=ye(n.equal):is(n)?i=ye(n.lte):ns(n)?i=ye(n.lt):rs(n)?i=ye(n.gt):ss(n)?i=ye(n.gte):os(n)?i=n.range[0]:as(n)&&(i=(n.oneOf??n.in)[0]),i&&(Bt(i)?t[n.field]="date":V(i)?t[n.field]="number":N(i)&&(t[n.field]="string")),n.timeUnit&&(t[n.field]="date")}}),t}function Pb(e){const t={};function n(i){_n(i)?t[i.field]="date":i.type==="quantitative"&&Nd(i.aggregate)?t[i.field]="number":dn(i.field)>1?i.field in t||(t[i.field]="flatten"):Yt(i)&&Xe(i.sort)&&dn(i.sort.field)>1&&(i.sort.field in t||(t[i.sort.field]="flatten"))}if((G(e)||Le(e))&&e.forEachFieldDef((i,r)=>{if(ae(i))n(i);else{const s=jt(r),o=e.fieldDef(s);n({...i,type:o.type})}}),G(e)){const{mark:i,markDef:r,encoding:s}=e;if(Ft(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 zb(e){const t={};if(G(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&&dn(r.field)>1&&(t[r.field]="flatten")}return t}class se extends R{clone(){return new se(null,k(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!At(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(Ma(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(Ma(a,n[a],c)))}const s=new gt(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 se(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];dn(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?dn(n)>1:!0).map(n=>{const i=Ab(n,this._parse[n]);if(!i)return null;const r={type:"formula",expr:i,as:Lr(n)};return r}).filter(n=>n!==null)}}class zt extends R{clone(){return new zt(null)}constructor(t){super(t)}dependentFields(){return new Set}producedFields(){return new Set([ze])}hash(){return"Identifier"}assemble(){return{type:"identifier",as:ze}}}class si extends R{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 R{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 en extends R{constructor(t){super(null);t??(t={name:"source"});let n;if(At(t)||(n=t.format?{...ue(t.format,["parse"])}:{}),ti(t))this._data={values:t.values};else if(Cn(t)){if(this._data={url:t.url},!n.type){let i=/(?:\.([^.]+))?$/.exec(t.url)[1];P(["json","csv","tsv","dsv","topojson"],i)||(i="json"),n.type=i}}else ju(t)?this._data={values:[{type:"Sphere"}]}:(Mu(t)||At(t))&&(this._data={});this._generator=At(t),t.name&&(this._name=t.name),n&&!I(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 Xl=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},Rb=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 yo(e){return e instanceof en||e instanceof si||e instanceof oi}class bo{constructor(){ai.set(this,void 0),Xl(this,ai,!1,"f")}setModified(){Xl(this,ai,!0,"f")}get modifiedFlag(){return Rb(this,ai,"f")}}ai=new WeakMap;class tn extends bo{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 xo extends bo{optimize(t){this.run(t);for(const n of t.children)this.optimize(n);return this.modifiedFlag}}class Ib extends xo{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 Lb extends xo{constructor(t){super();this.requiresSelectionId=t&&ro(t)}run(t){t instanceof zt&&(this.requiresSelectionId&&(yo(t.parent)||t.parent instanceof Re||t.parent instanceof se)||(this.setModified(),t.remove()))}}class Mb extends bo{optimize(t){return this.run(t,new Set),this.modifiedFlag}run(t,n){let i=new Set;t instanceof Je&&(i=t.producedFields(),Pr(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 Db extends xo{constructor(){super()}run(t){t instanceof ce&&!t.isRequired()&&(this.setModified(),t.remove())}}class jb extends tn{run(t){if(yo(t))return;if(t.numChildren()>1)return;for(const n of t.children)if(n instanceof se)if(t instanceof se)this.setModified(),t.merge(n);else{if(Rr(t.producedFields(),n.dependentFields()))continue;this.setModified(),n.swapWithParent()}return}}class Ub extends tn{run(t){const n=[...t.children],i=t.children.filter(r=>r instanceof se);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(!I(r)){this.setModified();const o=new se(t,r);for(const a of n){if(a instanceof se)for(const c of b(r))delete a.parse[c];t.removeChild(a),a.parent=o,a instanceof se&&b(a.parse).length===0&&a.remove()}}}}}class Bb extends tn{run(t){t instanceof ce||t.numChildren()>0||t instanceof Rn||(t instanceof en||(this.setModified(),t.remove()))}}class Wb extends tn{run(t){const n=t.children.filter(r=>r instanceof Je),i=n.pop();for(const r of n)this.setModified(),i.merge(r)}}class Hb extends tn{run(t){const n=t.children.filter(r=>r instanceof Re),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 qb extends tn{constructor(t){super();this.model=t}run(t){const n=!(yo(t)||t instanceof An||t instanceof se||t instanceof zt),i=[],r=[];for(const s of t.children)s instanceof et&&(n&&!Rr(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 et?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 Gb extends tn{run(t){const n=[...t.children],i=It(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 nn extends R{clone(){return new nn(null,k(this.transform))}constructor(t,n){super(t);this.transform=n}addDimensions(t){this.transform.groupby=je(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 Vb(e){return e.stack.stackBy.reduce((t,n)=>{const i=n.fieldDef,r=w(i);return r&&t.push(r),t},[])}function Xb(e){return v(e)&&e.every(t=>N(t))&&e.length>1}class ht extends R{clone(){return new ht(null,k(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(X(f.order,"ascending"));const u={field:a,order:c};let l;return Xb(s)?l=s:N(s)?l=[s,`${s}_end`]:l=[`${n.stack}_start`,`${n.stack}_end`],new ht(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 Ke(g)}).filter(p=>!!p),l=Vb(n),f=n.encoding.order;let d;if(v(f)||S(f))d=Fa(f);else{const p=Oc(f)?f.sort:o==="y"?"descending":"ascending";d=l.reduce((g,m)=>(g.field.push(m),g.order.push(p),g),{field:[],order:[]})}return new ht(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 In extends R{clone(){return new In(null,k(this.transform))}constructor(t,n){super(t);this.transform=n}addDimensions(t){this.transform.groupby=je(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=>Gr(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 Yb(e){function t(n){if(!(n instanceof Rn)){const i=n.clone();if(i instanceof ce){const r=wo+i.getSource();i.setSource(r),e.model.component.data.outputNodes[r]=i}else(i instanceof Re||i instanceof ht||i instanceof In||i instanceof nn)&&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 So(e){if(e instanceof Rn)if(e.numChildren()===1&&!(e.children[0]instanceof ce)){const t=e.children[0];(t instanceof Re||t instanceof ht||t instanceof In||t instanceof nn)&&t.addDimensions(e.fields),t.swapWithParent(),So(e)}else{const t=e.model.component.data.main;Yl(t);const n=Yb(e),i=e.children.map(n).flat();for(const r of i)r.parent=t}else e.children.map(So)}function Yl(e){if(e instanceof ce&&e.type===U.Main&&e.numChildren()===1){const t=e.children[0];t instanceof Rn||(t.swapWithParent(),Yl(e))}}const wo="scale_",fr=5;function $o(e){for(const t of e){for(const n of t.children)if(n.parent!==t)return!1;if(!$o(t.children))return!1}return!0}function Ie(e,t){let n=!1;for(const i of t)n=e.optimize(i)||n;return n}function Kl(e,t,n){let i=e.sources,r=!1;return r=Ie(new Db,i)||r,r=Ie(new Lb(t),i)||r,i=i.filter(s=>s.numChildren()>0),r=Ie(new Bb,i)||r,i=i.filter(s=>s.numChildren()>0),n||(r=Ie(new jb,i)||r,r=Ie(new qb(t),i)||r,r=Ie(new Mb,i)||r,r=Ie(new Ub,i)||r,r=Ie(new Hb,i)||r,r=Ie(new Wb,i)||r,r=Ie(new Ib,i)||r,r=Ie(new Gb,i)||r),e.sources=i,r}function Kb(e,t){$o(e.sources);let n=0,i=0;for(let r=0;rt(n))}}function Ql(e){G(e)?Qb(e):Zb(e)}function Qb(e){const t=e.component.scales;for(const n of b(t)){const i=ex(e,n),r=t[n];if(r.setWithExplicit("domains",i),nx(e,n),e.component.data.isFaceted){let s=e;for(;!Le(s)&&s.parent;)s=s.parent;const o=s.component.resolve.scale[n];if(o==="shared")for(const a of i.value)lt(a)&&(a.data=wo+a.data.replace(wo,""))}}}function Zb(e){for(const n of e.children)Ql(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=Tt(i,o.getWithExplicit("domains"),"domains","scale",_o);const a=o.get("selectionExtent");r&&a&&r.param!==a.param&&x(Vd),r=a}}t[n].setWithExplicit("domains",i),r&&t[n].set("selectionExtent",r,!0)}}function Jb(e,t,n,i){if(e==="unaggregated"){const{valid:r,reason:s}=Zl(t,n);if(!r){x(s);return}}else if(e===void 0&&i.useUnaggregatedDomain){const{valid:r}=Zl(t,n);if(r)return"unaggregated"}return e}function ex(e,t){const n=e.getScaleComponent(t).get("type"),{encoding:i}=e,r=Jb(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"&&Y(i.x2)?Y(i.x)?Tt(Rt(n,r,e,"x"),Rt(n,r,e,"x2"),"domain","scale",_o):Rt(n,r,e,"x2"):t==="y"&&Y(i.y2)?Y(i.y)?Tt(Rt(n,r,e,"y"),Rt(n,r,e,"y2"),"domain","scale",_o):Rt(n,r,e,"y2"):Rt(n,r,e,t)}function tx(e,t,n){return e.map(i=>{const r=Gi(i,{timeUnit:n,type:t});return{signal:`{data: ${r}}`}})}function vo(e,t,n){const i=Z(n)?.unit;return t==="temporal"||i?tx(e,t,i):[e]}function Rt(e,t,n,i){const{encoding:r}=n,s=Y(r[i]),{type:o}=s,a=s.timeUnit;if(bg(t)){const f=Rt(e,void 0,n,i),d=vo(t.unionWith,o,a);return Ze([...d,...f.value])}else{if(E(t))return Ze([t]);if(t&&t!=="unaggregated"&&!fc(t))return Ze(vo(t,o,a))}const c=n.stack;if(c&&i===c.fieldChannel){if(c.offset==="normalize")return xe([[0,1]]);const f=n.requestDataName(U.Main);return xe([{data:f,field:n.vgField(i,{suffix:"start"})},{data:f,field:n.vgField(i,{suffix:"end"})}])}const u=ct(i)&&S(s)?ix(n,i,e):void 0;if(Ye(s)){const f=vo([s.datum],o,a);return xe(f)}const l=s;if(t==="unaggregated"){const f=n.requestDataName(U.Main),{field:d}=s;return xe([{data:f,field:w({field:d,aggregate:"min"})},{data:f,field:w({field:d,aggregate:"max"})}])}else if(j(l.bin)){if(J(e))return e==="bin-ordinal"?xe([]):xe([{data:Un(u)?n.requestDataName(U.Main):n.requestDataName(U.Raw),field:n.vgField(i,Jn(l,i)?{binSuffix:"range"}:{}),sort:u===!0||!L(u)?{field:n.vgField(i,{}),op:"min"}:u}]);{const{bin:f}=l;if(j(f)){const d=ho(n,l.field,f);return xe([new me(()=>{const p=n.getSignalName(d);return`[${p}.start, ${p}.stop]`})])}else return xe([{data:n.requestDataName(U.Main),field:n.vgField(i,{})}])}}else if(l.timeUnit&&P(["time","utc"],e)&&Ac(l,G(n)?n.encoding[He(i)]:void 0,n.markDef,n.config)){const f=n.requestDataName(U.Main);return xe([{data:f,field:n.vgField(i)},{data:f,field:n.vgField(i,{suffix:"end"})}])}else return xe(u?[{data:Un(u)?n.requestDataName(U.Main):n.requestDataName(U.Raw),field:n.vgField(i),sort:u}]:[{data:n.requestDataName(U.Main),field:n.vgField(i)}])}function Eo(e,t){const{op:n,field:i,order:r}=e;return{op:n??(t?"sum":Li),...i?{field:Se(i)}:{},...r?{order:r}:{}}}function nx(e,t){const n=e.component.scales[t],i=e.specifiedScales[t].domain,r=e.fieldDef(t)?.bin,s=fc(i)&&i,o=Ut(r)&&ki(r.extent)&&r.extent;(s||o)&&n.set("selectionExtent",s??o,!0)}function ix(e,t,n){if(!J(n))return;const i=e.fieldDef(t),r=i.sort;if(Cc(r))return{op:"min",field:Pn(i,t),order:"ascending"};const{stack:s}=e,o=s?new Set([...s.groupbyFields,...s.stackBy.map(a=>a.fieldDef.field)]):void 0;if(Xe(r)){const a=s&&!o.has(r.field);return Eo(r,a)}else if(kc(r)){const{encoding:a,order:c}=r,u=e.fieldDef(a),{aggregate:l,field:f}=u,d=s&&!o.has(f);if(ut(l)||_t(l))return Eo({field:w(u),order:c},d);if(Gr(l)||!l)return Eo({op:l,field:f,order:c},d)}else{if(r==="descending")return{op:"min",field:e.vgField(t),order:"descending"};if(P(["ascending",void 0],r))return!0}return}function Zl(e,t){const{aggregate:n,type:i}=e;return n?N(n)&&!Ad.has(n)?{valid:!1,reason:wp(n)}:i==="quantitative"&&t==="log"?{valid:!1,reason:$p(e)}:{valid:!0}:{valid:!1,reason:Sp(e)}}function _o(e,t,n,i){return e.explicit&&t.explicit&&x(Cp(n,i,e.value,t.value)),{explicit:e.explicit,value:[...e.value,...t.value]}}function rx(e){const t=je(e.map(o=>{if(lt(o)){const{sort:a,...c}=o;return c}return o}),O),n=je(e.map(o=>{if(lt(o)){const a=o.sort;return a!==void 0&&!Un(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(lt(o)&&n.length>0){let a=n[0];if(n.length>1){x(Ha);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=je(n.map(o=>Un(o)||!("op"in o)||N(o.op)&&o.op in Cd?o:(x(Np(o)),!0)),O);let r;i.length===1?r=i[0]:i.length>1&&(x(Ha),r=!0);const s=je(e.map(o=>lt(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 ko(e){if(lt(e)&&N(e.field))return e.field;if(Od(e)){let t;for(const n of e.fields)if(lt(n)&&N(n.field)){if(!t)t=n.field;else if(t!==n.field)return x(Tp),t}return x(Ap),t}else if(Pd(e)){x(Op);const t=e.fields[0];return N(t)?t:void 0}return}function dr(e,t){const n=e.component.scales[t],i=n.get("domains").map(r=>(lt(r)&&(r.data=e.lookupDataSource(r.data)),r));return rx(i)}function Jl(e){return Ln(e)||Fo(e)?e.children.reduce((t,n)=>t.concat(Jl(n)),ef(e)):ef(e)}function ef(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=sx(r.range,s,n,e),p=dr(e,n),g=a?Jh(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 sx(e,t,n,i){if(Q(n)){if(Ct(e))return{step:{signal:`${t}_step`}}}else if(L(e)&<(e))return{...e,data:i.lookupDataSource(e.data)};return e}class tf extends gt{constructor(t,n){super({},{name:t});this.merged=!1,this.setWithExplicit("type",n)}domainDefinitelyIncludesZero(){return this.get("zero")!==!1?!0:It(this.get("domains"),t=>v(t)&&t.length===2&&t[0]<=0&&t[1]>=0)}}const ox=["range","scheme"];function ax(e){const t=e.component.scales;for(const n of _i){const i=t[n];if(!i)continue;const r=cx(n,e);i.setWithExplicit("range",r)}}function nf(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(j(i)){const a=ho(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 cx(e,t){const n=t.specifiedScales[e],{size:i}=t,r=t.getScaleComponent(e),s=r.get("type");for(const f of ox)if(n[f]!==void 0){const d=ds(s,f),p=dc(e,f);if(!d)x(Ba(s,f,e));else if(p)x(p);else switch(f){case"range":{const g=n.range;if(v(g)){if(Q(e))return Ze(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 Ze({data:t.requestDataName(U.Main),field:g.field,sort:{op:"min",field:t.vgField(e)}});return Ze(g)}case"scheme":return Ze(ux(n[f]))}}const o=e===H||e==="xOffset"?"width":"height",a=i[o];if(Qe(a)){if(Q(e))if(J(s)){const f=rf(a,t,e);if(f)return Ze({step:f})}else x(Wa(o));else if(hn(e)){const f=e===xt?"x":"y",d=t.getScaleComponent(f),p=d.get("type");if(p==="band"){const g=sf(a,s);if(g)return Ze(g)}}}const{rangeMin:c,rangeMax:u}=n,l=lx(e,t);return(c!==void 0||u!==void 0)&&ds(s,"rangeMin")&&v(l)&&l.length===2?Ze([c??l[0],u??l[1]]):xe(l)}function ux(e){return yg(e)?{scheme:e.name,...ue(e,["name"])}:{scheme:e}}function lx(e,t){const{size:n,config:i,mark:r,encoding:s}=t,o=t.getSignalName.bind(t),{type:a}=Y(s[e]),c=t.getScaleComponent(e),u=c.get("type"),{domain:l,domainMid:f}=t.specifiedScales[e];switch(e){case H:case K:{if(P(["point","band"],u)){const g=of(e,n,i.view);if(Qe(g)){const m=rf(g,t,e);return{step:m}}}const d=de(e),p=t.getName(d);return e===K&&be(u)?[me.fromName(o,p),0]:[0,me.fromName(o,p)]}case xt:case pn:return fx(e,t,u);case ot:{const d=t.component.scales[e].get("zero"),p=af(r,d,i),g=gx(r,n,t,i);return Sn(u)?px(p,g,dx(u,i,l,e)):[p,g]}case we:return[0,Math.PI*2];case Mt:return[0,360];case ke:return[0,new me(()=>{const d=t.getSignalName("width"),p=t.getSignalName("height");return`min(${d},${p})/2`})];case $t:return[i.scale.minStrokeWidth,i.scale.maxStrokeWidth];case vt:return[[1,0],[4,2],[2,1],[1,1],[1,2,4,2]];case fe:return"symbol";case le:case Be:case We:return u==="ordinal"?a==="nominal"?"category":"ordinal":f!==void 0?"diverging":r==="rect"||r==="geoshape"?"heatmap":"ramp";case at:case St:case wt:return[i.scale.minOpacity,i.scale.maxOpacity]}}function rf(e,t,n){const{encoding:i}=t,r=t.getScaleComponent(n),s=Ur(n),o=i[s],a=fu({step:e,offsetIsDiscrete:F(o)&&sc(o.type)});if(a==="offset"&&Gc(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-${Ld(f)})`}}else return e.step}function sf(e,t){const n=fu({step:e,offsetIsDiscrete:J(t)});return n==="offset"?{step:e.step}:void 0}function fx(e,t,n){const i=e===xt?"x":"y",r=t.getScaleComponent(i),s=r.get("type"),o=t.scaleName(i);if(s==="band"){const a=of(i,t.size,t.config.view);if(Qe(a)){const c=sf(a,n);if(c)return c}return[0,{signal:`bandwidth('${o}')`}]}else{const a=t.encoding[i];if(S(a)&&a.timeUnit){const c=tc(a.timeUnit,l=>`scale('${o}', ${l})`),u=t.config.scale.bandWithNestedOffsetPaddingInner;if(u){const l=E(u)?`${u.signal}/2`:`${u/2}`,f=E(u)?`(1 - ${u.signal}/2)`:`${1-u/2}`;return[{signal:`${l} * (${c})`},{signal:`${f} * (${c})`}]}return[0,{signal:c}]}return Zo(`Cannot use ${e} scale if ${i} scale is not discrete.`)}}function of(e,t,n){const i=e===H?"width":"height",r=t[i];return r||Ji(n,i)}function dx(e,t,n,i){switch(e){case"quantile":return t.scale.quantileCount;case"quantize":return t.scale.quantizeCount;case"threshold":return n!==void 0&&v(n)?n.length+1:(x(Up(i)),3)}}function px(e,t,n){const i=()=>{const r=Te(t),s=Te(e),o=`(${r} - ${s}) / (${n} - 1)`;return`sequence(${s}, ${r} + ${o}, ${o})`};return E(t)?new me(i):{signal:i()}}function af(e,t,n){if(t)return E(t)?{signal:`${t.signal} ? 0 : ${af(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(Fi("size",e))}const cf=.95;function gx(e,t,n,i){const r={x:nf(n,"x"),y:nf(n,"y")};switch(e){case"bar":case"tick":{if(i.scale.maxBandSize!==void 0)return i.scale.maxBandSize;const s=uf(t,r,i.view);return V(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=uf(t,r,i.view);return V(s)?Math.pow(cf*s,2):new me(()=>`pow(${cf} * ${s.signal}, 2)`)}}throw new Error(Fi("size",e))}function uf(e,t,n){const i=Qe(e.width)?e.width.step:Zi(n,"width"),r=Qe(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 lf(e,t){G(e)?mx(e,t):pf(e,t)}function mx(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=Y(r[a]),d=c[t],p=l.get("type"),g=l.get("padding"),m=l.get("paddingInner"),h=ds(p,t),y=dc(a,t);if(d!==void 0&&(h?y&&x(y):x(Ba(p,t,a))),h&&y===void 0)if(d!==void 0){const $=f.timeUnit,C=f.type;switch(t){case"domainMax":case"domainMin":Bt(c[t])||C==="temporal"||$?u.set(t,{signal:Gi(c[t],{type:C,timeUnit:$})},!0):u.set(t,c[t],!0);break;default:u.copyKeyFromObject(t,c)}}else{const $=t in ff?ff[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:Cs(r,a),hasSecondaryRangeChannel:!!r[He(a)]}):i.scale[t];$!==void 0&&u.set(t,$,!1)}}}const ff={bins:({model:e,fieldOrDatumDef:t})=>S(t)?hx(e,t):void 0,interpolate:({channel:e,fieldOrDatumDef:t})=>yx(e,t.type),nice:({scaleType:e,channel:t,domain:n,domainMin:i,domainMax:r,fieldOrDatumDef:s})=>bx(e,t,n,i,r,s),padding:({channel:e,scaleType:t,fieldOrDatumDef:n,markDef:i,config:r})=>xx(e,t,r.scale,n,i,r.bar),paddingInner:({scalePadding:e,channel:t,markDef:n,scaleType:i,config:r,hasNestedOffsetScale:s})=>Sx(e,t,n.type,i,r.scale,s),paddingOuter:({scalePadding:e,channel:t,scaleType:n,scalePaddingInner:i,config:r,hasNestedOffsetScale:s})=>wx(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 $x(t,r,n,i.scale)},zero:({channel:e,fieldOrDatumDef:t,domain:n,markDef:i,scaleType:r,config:s,hasSecondaryRangeChannel:o})=>vx(e,t,n,i,r,s.scale,o)};function df(e){G(e)?ax(e):pf(e,"range")}function pf(e,t){const n=e.component.scales;for(const i of e.children)t==="range"?df(i):lf(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=Tt(r,a,t,"scale",Lu((c,u)=>{switch(t){case"range":return c.step&&u.step?c.step-u.step:0}return 0}))}}n[i].setWithExplicit(t,r)}}function hx(e,t){const n=t.bin;if(j(n)){const i=ho(e,t.field,n);return new me(()=>e.getSignalName(i))}else if(ne(n)&&Ut(n)&&n.step!==void 0)return{step:n.step};return}function yx(e,t){return P([le,Be,We],e)&&t!=="nominal"?"hcl":void 0}function bx(e,t,n,i,r,s){return Ke(s)?.bin||v(n)||r!=null||i!=null||P([ge.TIME,ge.UTC],e)?void 0:Q(t)?!0:void 0}function xx(e,t,n,i,r,s){if(Q(e)){if(Ae(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 Sx(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:X(o,n==="bar"?a:c)}else if(hn(t)&&i===ge.BAND)return r.offsetBandPaddingInner;return}function wx(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 X(o,E(i)?{signal:`${i.signal}/2`}:i/2)}else if(hn(t)){if(n===ge.POINT)return .5;if(n===ge.BAND)return r.offsetBandPaddingOuter}return}function $x(e,t,n,i){return n==="x"&&i.xReverse!==void 0?be(e)&&t==="descending"?E(i.xReverse)?{signal:`!${i.xReverse.signal}`}:!i.xReverse:i.xReverse:be(e)&&t==="descending"?!0:void 0}function vx(e,t,n,i,r,s,o){const a=!!n&&n!=="unaggregated";if(a&&be(r)){if(v(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"&&!Sn(r))return!0;if(!(S(t)&&t.bin)&&P([...qe,...xd],e)){const{orient:c,type:u}=i;return P(["bar","area","line","trail"],u)&&(c==="horizontal"&&e==="y"||c==="vertical"&&e==="x")?!1:P(["bar","area"],u)&&!o?!0:s?.zero}return!1}function Ex(e,t,n,i,r=!1){const s=_x(t,n,i,r),{type:o}=e;return ct(t)?o!==void 0?Eg(t,o)?S(n)&&!vg(o,n.type)?(x(_p(o,s)),s):o:(x(Ep(t,o,s)),s):s:null}function _x(e,t,n,i){switch(t.type){case"nominal":case"ordinal":{if(mn(e)||qr(e)==="discrete")return e==="shape"&&t.type==="ordinal"&&x(Qr(e,"ordinal")),"ordinal";if(Q(e)||hn(e)){if(P(["rect","bar","image","rule"],n.type))return"band";if(i)return"band"}else if(n.type==="arc"&&e in Hr)return"band";const r=n[de(e)];return Gt(r)||$n(t)&&t.axis?.tickBand?"band":"point"}case"temporal":return mn(e)?"time":qr(e)==="discrete"?(x(Qr(e,"temporal")),"ordinal"):S(t)&&t.timeUnit&&Z(t.timeUnit).utc?"utc":"time";case"quantitative":return mn(e)?S(t)&&j(t.bin)?"bin-ordinal":"linear":qr(e)==="discrete"?(x(Qr(e,"quantitative")),"ordinal"):"linear";case"geojson":return}throw new Error(ja(t.type))}function kx(e,{ignoreRange:t}={}){gf(e),Ql(e);for(const n of $g)lf(e,n);t||df(e)}function gf(e){G(e)?e.component.scales=Cx(e):e.component.scales=Nx(e)}function Cx(e){const{encoding:t,mark:n,markDef:i}=e,r={};for(const s of _i){const o=Y(t[s]);if(o&&n===mc&&s===fe&&o.type===xn)continue;let a=o&&o.scale;if(hn(s)){const c=ga(s);if(!Cs(t,c)){a&&x(lp(s));continue}}if(o&&a!==null&&a!==!1){a??(a={});const c=Cs(t,s),u=Ex(a,s,o,i,c);r[s]=new tf(e.scaleName(`${s}`,!0),{value:u,explicit:a.type===u})}}return r}const Fx=Lu((e,t)=>oc(e)-oc(t));function Nx(e){var t;const n=e.component.scales={},i={},r=e.component.resolve;for(const s of e.children){gf(s);for(const o of b(s.component.scales))if((t=r.scale)[o]??(t[o]=Al(o,e)),r.scale[o]==="shared"){const a=i[o],c=s.component.scales[o].getWithExplicit("type");a?dg(a.value,c.value)?i[o]=Tt(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 tf(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 Co{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 G(e){return e?.type==="unit"}function Le(e){return e?.type==="facet"}function Fo(e){return e?.type==="concat"}function Ln(e){return e?.type==="layer"}class No{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=kt(t.title)?{text:t.title}:t.title?pe(t.title):void 0,this.scaleNameMap=i?i.scaleNameMap:new Co,this.projectionNameMap=i?i.projectionNameMap:new Co,this.signalNameMap=i?i.signalNameMap:new Co,this.data=t.data,this.description=t.description,this.transforms=Ih(t.transform??[]),this.layout=n==="layer"||n==="unit"?{}:jm(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 gt,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:{scale:{},axis:{},legend:{},...o?k(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(){kx(this)}parseProjection(){Hl(this)}renameTopLevelLayoutSizeSignal(){this.getName("width")!=="width"&&this.renameSignal(this.getName("width"),"width"),this.getName("height")!=="height"&&this.renameSignal(this.getName("height"),"height")}parseLegends(){Dl(this)}assembleEncodeFromView(t){const{style:n,...i}=t,r={};for(const s of b(i)){const o=i[s];o!==void 0&&(r[s]=B(o))}return r}assembleGroupEncodeEntry(t){let n={};return this.view&&(n=this.assembleEncodeFromView(this.view)),!t&&(this.description&&(n.description=B(this.description)),this.type==="unit"||this.type==="layer")?{width:this.getSizeSignalRef("width"),height:this.getSizeSignalRef("height"),...n??{}}:I(n)?void 0:n}assembleLayout(){if(!this.layout)return;const{spacing:t,...n}=this.layout,{component:i,config:r}=this,s=Ky(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(Hy(this,i));for(const i of uo)n=n.concat(qy(this,i));return n}assembleAxes(){return Ay(this.component.axes,this.config)}assembleLegends(){return Ul(this)}assembleProjections(){return xb(this)}assembleTitle(){const{encoding:t,...n}=this.title??{},i={...$a(this.config.title).nonMarkTitleProperties,...n,...t?{encode:{update:t}}:{}};return i.text?(P(["unit","layer"],this.type)?P(["middle",void 0],i.anchor)&&(i.frame??(i.frame="group")):i.anchor??(i.anchor="start"),I(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||Le(this.parent)?Jl(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(U[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(Le(this.parent)){const n=Nl(t),i=Ei(n),r=this.component.scales[i];if(r&&!r.merged){const s=r.get("type"),o=r.get("range");if(J(s)&&Ct(o)){const a=r.get("name"),c=dr(this,i),u=ko(c);if(u){const l=w({aggregate:"distinct",field:u},{expr:"datum"});return{signal:Fl(a,r,l)}}else return x(Yr(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):fa(t)&&ct(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(Bd(n));return i}hasAxisOrientSignalRef(){return this.component.axes.x?.some(t=>t.hasOrientSignalRef())||this.component.axes.y?.some(t=>t.hasOrientSignalRef())}}class mf extends No{vgField(t,n={}){const i=this.fieldDef(t);return i?w(i,n):void 0}reduceFieldDef(t,n){return mm(this.getMapping(),(i,r,s)=>{const o=Ke(r);return o?t(i,o,s):i},n)}forEachFieldDef(t,n){Ns(this.getMapping(),(i,r)=>{const s=Ke(i);s&&t(s,r)},n)}}class pr extends R{clone(){return new pr(null,k(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=k(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 gr extends R{clone(){return new gr(null,k(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=k(n)}dependentFields(){return new Set([this.transform.extent])}producedFields(){return new Set([])}hash(){return`ExtentTransform ${O(this.transform)}`}assemble(){const{extent:t,param:n}=this.transform,i={type:"extent",field:t,signal:n};return i}}class ci extends R{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=ct(l)&&n.getScaleComponent(l);if(f){const d=f.get("type");be(d)&&u.aggregate!=="count"&&!Ft(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 mr extends R{clone(){return new mr(this.parent,k(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=k(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 hr extends R{clone(){return new hr(null,k(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=k(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 Mn extends R{clone(){return new Mn(null,k(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[[Fe,Ce],[$e,Ne]]){const s=r.map(o=>{const a=Y(n.encoding[o]);return S(a)?a.field:Ye(a)?{expr:`${a.datum}`}:Pe(a)?{expr:`${a.value}`}:void 0});(s[0]||s[1])&&(t=new Mn(t,s,null,n.getName(`geojson_${i++}`)))}if(n.channelHasField(fe)){const r=n.typedFieldDef(fe);r.type===xn&&(t=new Mn(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(N);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 R{clone(){return new ui(null,this.projection,k(this.fields),k(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[[Fe,Ce],[$e,Ne]]){const r=i.map(o=>{const a=Y(n.encoding[o]);return S(a)?a.field:Ye(a)?{expr:`${a.datum}`}:Pe(a)?{expr:`${a.value}`}:void 0}),s=i[0]===$e?"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(N))}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 rn extends R{clone(){return new rn(null,k(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 rn(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=Xc(n.mark,i);return new rn(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:yh(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 yr extends R{clone(){return new yr(null,k(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=k(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 R{clone(){return new li(null,k(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(bh(o)){let c=xf(o.data,s);c||(c=new en(o.data),s.push(c));const u=n.getName(`lookup_${r}`);a=new ce(c,u,U.Lookup,n.component.data.outputNodeRefCounts),n.component.data.outputNodes[u]=a}else if(xh(o)){const c=o.param;i={as:c,...i};let u;try{u=n.getSelectionComponent(W(c),c)}catch(l){throw new Error(qd(c))}if(a=u.materialized,!a)throw new Error(Gd(c))}return new li(t,i,a.getSource())}dependentFields(){return new Set([this.transform.lookup])}producedFields(){return new Set(this.transform.as?q(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:q(this.transform.as)}:{}};else{let n=this.transform.as;N(n)||(x(ep),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 br extends R{clone(){return new br(null,k(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=k(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 xr extends R{clone(){return new xr(null,k(this.transform))}constructor(t,n){super(t);this.transform=n,this.transform=k(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 Sr extends R{clone(){return new Sr(null,k(this.transform))}constructor(t,n){super(t);this.transform=n}addDimensions(t){this.transform.groupby=je((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 wr extends R{clone(){return new wr(null,k(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 hf(e){let t=0;function n(i,r){if(i instanceof en&&(!i.isGenerator&&!Cn(i.data))){e.push(r);const s={name:null,source:r.name,transform:[]};r=s}if(i instanceof se&&(i.parent instanceof en&&!r.source?(r.format={...r.format??{},parse:i.assembleFormatParse()},r.transform.push(...i.assembleTransforms(!0))):r.transform.push(...i.assembleTransforms())),i instanceof Rn){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 An||i instanceof On||i instanceof ui||i instanceof Re||i instanceof li||i instanceof In||i instanceof nn||i instanceof hr||i instanceof mr||i instanceof pr||i instanceof yr||i instanceof br||i instanceof xr||i instanceof zt||i instanceof wr||i instanceof Sr||i instanceof gr)&&r.transform.push(i.assemble()),(i instanceof et||i instanceof Je||i instanceof rn||i instanceof ht||i instanceof Mn)&&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 Tx(e){const t=[],n=hf(t);for(const i of e.children)n(i,{source:e.name,name:null,transform:[]});return t}function Ax(e,t){const n=[],i=hf(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 Ox(e){return e==="top"||e==="left"||E(e)?"header":"footer"}function Px(e){for(const t of ve)zx(e,t);bf(e,"x"),bf(e,"y")}function zx(e,t){const{facet:n,config:i,child:r,component:s}=e;if(e.channelHasField(t)){const o=n[t],a=zn("title",null,i,t);let c=vn(o,i,{allowDisabling:!0,includeDefault:a===void 0||!!a});r.component.layoutHeaders[t].title&&(c=v(c)?c.join(", "):c,c+=` / ${r.component.layoutHeaders[t].title}`,r.component.layoutHeaders[t].title=null);const u=zn("labelOrient",o.header,i,t),l=o.header!==null?X(o.header?.labels,i.header.labels,!0):!1,f=P(["bottom","right"],u)?"footer":"header";s.layoutHeaders[t]={title:o.header!==null?c:null,facetFieldDef:o,[f]:t==="facet"?[]:[yf(e,t,l)]}}}function yf(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 bf(e,t){const{child:n}=e;if(n.component.axes[t]){const{layoutHeaders:i,resolve:r}=e.component;if(r.axis[t]=go(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=Ox(a.get("orient"));o[c]??(o[c]=[yf(e,s,!1)]);const u=ri(a,"main",e.config,{header:!0});u&&o[c][0].axes.push(u),a.mainExtracted=!0}}}}function Rx(e){To(e),$r(e,"width"),$r(e,"height")}function Ix(e){To(e);const t=e.layout.columns===1?"width":"childWidth",n=e.layout.columns===void 0?"height":"childHeight";$r(e,t),$r(e,n)}function To(e){for(const t of e.children)t.parseLayoutSize()}function $r(e,t){const n=Nl(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]??Al(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=Tt(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 Lx(e){const{size:t,component:n}=e;for(const i of qe){const r=de(i);if(t[r]){const s=t[r];n.layoutSize.set(r,Qe(s)?"step":s,!0)}else{const s=Mx(e,r);n.layoutSize.set(r,s,!1)}}}function Mx(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(J(s)){const a=Ji(i.view,t);return Ct(o)||Qe(a)?"step":a}else return Us(i.view,t)}else{if(e.hasProjection||e.mark==="arc")return Us(i.view,t);{const s=Ji(i.view,t);return Qe(s)?s.step:s}}}function Ao(e,t,n){return w(t,{suffix:`by_${w(e)}`,...n??{}})}class fi extends mf{constructor(t,n,i,r){super(t,"facet",n,i,r,t.resolve);this.child=Io(t.spec,this,this.getName("child"),void 0,r),this.children=[this.child],this.facet=this.initFacet(t.facet)}initFacet(t){if(!Qn(t))return{facet:this.initFacetFieldDef(t,"facet")};const n=b(t),i={};for(const r of n){if(![nt,it].includes(r)){x(Fi(r,"facet"));break}const s=t[r];if(s.field===void 0){x(Kr(s,r));break}i[r]=this.initFacetFieldDef(s,r)}return i}initFacetFieldDef(t,n){const i=ks(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(){To(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),Px(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 lo){const r=this.component.layoutHeaders[n],s=r[i],{facetFieldDef:o}=r;if(o){const a=zn("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 qe){const s=this.child.component.scales[r];if(s&&!s.merged){const o=s.get("type"),a=s.get("range");if(J(o)&&Ct(a)){const c=dr(this.child,r),u=ko(c);u?(t.push(u),n.push("distinct"),i.push(`distinct_${u}`)):x(Yr(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(j(d)&&c.push(w(f,{binSuffix:"end"})),Xe(p)){const{field:g,op:m=Li}=p,h=Ao(f,p);i&&r?(s.push(h),o.push("max"),a.push(h)):(s.push(g),o.push(m),a.push(h))}else if(v(p)){const g=Pn(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?Xe(i.sort)?[Ao(i,i.sort,{expr:"datum"})]:v(i.sort)?[Pn(i,t,{expr:"datum"})]:[w(i,{expr:"datum"})]:[]}facetSortOrder(t){const{facet:n}=this,i=n[t];if(i){const{sort:r}=i,s=(Xe(r)?r.order:!v(r)&&r)||"ascending";return[s]}return[]}assembleLabelTitle(){const{facet:t,config:n}=this;if(t.facet)return fo(t.facet,"facet",n);const i={row:["top","bottom"],column:["left","right"]};for(const r of uo)if(t[r]){const s=zn("labelOrient",t[r]?.header,n,r);if(i[r].includes(s))return fo(t[r],r,n)}return}assembleMarks(){const{child:t}=this,n=this.component.data.facetRoot,i=Tx(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(Yh(this,[]))};return[a]}getMapping(){return this.facet}}function Dx(e,t){const{row:n,column:i}=t;if(n&&i){let r=null;for(const s of[n,i])if(Xe(s.sort)){const{field:o,op:a=Li}=s.sort;e=r=new nn(e,{joinaggregate:[{op:a,field:o,as:Ao(s,s.sort,{forAs:!0})}],groupby:[w(s)]})}return r}return null}function xf(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(ti(e)&&ti(i)){if(De(e.values,i.values))return n}else if(Cn(e)&&Cn(i)){if(e.url===i.url)return n}else if(Mu(e)&&e.name===n.dataName)return n}return null}function jx(e,t){if(e.data||!e.parent){if(e.data===null){const i=new en({values:[]});return t.push(i),i}const n=xf(e.data,t);if(n)return At(e.data)||(n.data.format=Jo({},e.data.format,n.data.format)),!n.hasName()&&e.data.name&&(n.dataName=e.data.name),n;{const i=new en(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 Ux(e,t,n){let i=0;for(const r of t.transforms){let s,o;if(Nh(r))o=e=new On(e,r),s="derived";else if(Gs(r)){const a=Ob(r);o=e=se.makeWithAncestors(e,{},a,n)??e,e=new An(e,t,r.filter)}else if(Tu(r))o=e=et.makeFromTransform(e,r,t),s="number";else if(Ah(r)){s="date";const a=n.getWithExplicit(r.field);a.value===void 0&&(e=new se(e,{[r.field]:s}),n.set(r.field,s,!1)),o=e=Je.makeFromTransform(e,r)}else if(Oh(r))o=e=Re.makeFromTransform(e,r),s="number",ro(t)&&(e=new zt(e));else if(Nu(r))o=e=li.make(e,t,r,i++),s="derived";else if(kh(r))o=e=new In(e,r),s="number";else if(Ch(r))o=e=new nn(e,r),s="number";else if(Ph(r))o=e=ht.makeFromTransform(e,r),s="derived";else if(zh(r))o=e=new hr(e,r),s="derived";else if(Rh(r))o=e=new gr(e,r),s="derived";else if(Fh(r))o=e=new mr(e,r),s="derived";else if(Sh(r))o=e=new Sr(e,r),s="derived";else if(_h(r))e=new wr(e,r);else if(Th(r))o=e=rn.makeFromTransform(e,r),s="derived";else if(wh(r))o=e=new pr(e,r),s="derived";else if($h(r))o=e=new br(e,r),s="derived";else if(vh(r))o=e=new xr(e,r),s="derived";else if(Eh(r))o=e=new yr(e,r),s="derived";else{x(Jd(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=jx(e,e.component.data.sources);const{outputNodes:n,outputNodeRefCounts:i}=e.component.data,r=e.data,s=r&&(At(r)||Cn(r)||ti(r)),o=!s&&e.parent?e.parent.component.data.ancestorParse.clone():new Vh;At(r)?(Du(r)?t=new oi(t,r.sequence):Ys(r)&&(t=new si(t,r.graticule)),o.parseNothing=!0):r?.format?.parse===null&&(o.parseNothing=!0),t=se.makeExplicit(t,e,o)??t,t=new zt(t);const a=e.parent&&Ln(e.parent);(G(e)||Le(e))&&(a&&(t=et.makeFromEncoding(t,e)??t)),e.transforms.length>0&&(t=Ux(t,e,o));const c=zb(e),u=Pb(e);t=se.makeWithAncestors(t,{},{...c,...u},o)??t,G(e)&&(t=Mn.parseAll(t,e),t=ui.parseAll(t,e)),(G(e)||Le(e))&&(a||(t=et.makeFromEncoding(t,e)??t),t=Je.makeFromEncoding(t,e)??t,t=On.parseAllForSortIndex(t,e));const l=e.getDataName(U.Raw),f=new ce(t,l,U.Raw,i);if(n[l]=f,t=f,G(e)){const m=Re.makeFromEncoding(t,e);m&&(t=m,ro(e)&&(t=new zt(t))),t=rn.makeFromEncoding(t,e)??t,t=ht.makeFromEncoding(t,e)??t}G(e)&&(t=ci.make(t,e)??t);const d=e.getDataName(U.Main),p=new ce(t,d,U.Main,i);n[d]=p,t=p,G(e)&&Ny(e,p);let g=null;if(Le(e)){const m=e.getName("facet");t=Dx(t,e.facet)??t,g=new Rn(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 Bx extends No{constructor(t,n,i,r){super(t,"concat",n,i,r,t.resolve);(t.resolve?.axis?.x==="shared"||t.resolve?.axis?.y==="shared")&&x(Kd),this.children=this.getChildren(t).map((s,o)=>Io(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:js(t)?t.hconcat:t.concat}parseLayoutSize(){Ix(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=po(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 Wx(e){return e===!1||e===null}const Hx={disable:1,gridScale:1,scale:1,...Wc,labelExpr:1,encode:1},Sf=b(Hx);class Oo extends gt{constructor(t={},n={},i=!1){super();this.explicit=t,this.implicit=n,this.mainExtracted=i}clone(){return new Oo(k(this.explicit),k(this.implicit),this.mainExtracted)}hasAxisPart(t){return t==="axis"?!0:t==="grid"||t==="title"?!!this.get(t):!Wx(this.get(t))}hasOrientSignalRef(){return E(this.explicit.orient)}}function qx(e,t,n){const{encoding:i,config:r}=e,s=Y(i[t])??Y(i[He(t)]),o=e.axis(t)||{},{format:a,formatType:c}=o;if(Xt(c))return{text:Oe({fieldOrDatumDef:s,field:"datum.value",format:a,formatType:c,config:r}),...n};if(a===void 0&&c===void 0&&r.customFormatTypes){if(wn(s)==="quantitative"){if($n(s)&&s.stack==="normalize"&&r.normalizedNumberFormatType)return{text:Oe({fieldOrDatumDef:s,field:"datum.value",format:r.normalizedNumberFormat,formatType:r.normalizedNumberFormatType,config:r}),...n};if(r.numberFormatType)return{text:Oe({fieldOrDatumDef:s,field:"datum.value",format:r.numberFormat,formatType:r.numberFormatType,config:r}),...n}}if(wn(s)==="temporal"&&r.timeFormatType&&S(s)&&!s.timeUnit)return{text:Oe({fieldOrDatumDef:s,field:"datum.value",format:r.timeFormat,formatType:r.timeFormatType,config:r}),...n}}return n}function Gx(e){return qe.reduce((t,n)=>(e.component.scales[n]&&(t[n]=[Jx(n,e)]),t),{})}const Vx={bottom:"top",top:"bottom",left:"right",right:"left"};function Xx(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]=go(e.component.resolve,s),n.axis[s]==="shared"&&(t[s]=Yx(t[s],r.component.axes[s]),t[s]||(n.axis[s]="independent",delete t[s]))}for(const r of qe){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=Vx[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,o]of(t[r]||[]).entries())s>0&&!!o.get("grid")&&!o.explicit.grid&&(o.implicit.grid=!1)}}function Yx(e,t){if(e){if(e.length!==t.length)return;const n=e.length;for(let i=0;in.clone());return e}function Kx(e,t){for(const n of Sf){const i=Tt(e.getWithExplicit(n),t.getWithExplicit(n),n,"axis",(r,s)=>{switch(n){case"title":return Aa(r,s);case"gridScale":return{explicit:r.explicit,value:X(r.value,s.value)}}return tr(r,s,n,"axis")});e.setWithExplicit(n,i)}return e}function Qx(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:Hn(n.labelAngle));case"values":return!!n.values;case"encode":return!!n.encoding||!!n.labelAngle;case"title":if(e===vl(i,r))return!0}return e===n[t]}const Zx=new Set(["grid","translate","format","formatType","orient","labelExpr","tickCount","position","tickMinStep"]);function Jx(e,t){let n=t.axis(e);const i=new Oo,r=Y(t.encoding[e]),{mark:s,config:o}=t,a=n?.orient||o[e==="x"?"axisX":"axisY"]?.orient||o.axis?.orient||Dy(e),c=t.getScaleComponent(e).get("type"),u=Oy(e,c,a,t.config),l=n!==void 0?!n:ao("disable",o.style,n?.style,u).configValue;if(i.set("disable",l,n!==void 0),l)return i;n=n||{};const f=Iy(r,n,e,o.style,u),d=$c(n.formatType,r,c),p=wc(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 Sf){const $=y in Sl?Sl[y](g):Hc(y)?n[y]:void 0,C=$!==void 0,_=Qx($,y,n,t,e);if(C&&_)i.set(y,$,_);else{const{configValue:T=void 0,configFrom:M=void 0}=Hc(y)&&y!=="values"?ao(y,o.style,n.style,u):{},he=T!==void 0;C&&!he?i.set(y,$,_):(!(M==="vgAxisConfig")||Zx.has(y)&&he||ei(T)||E(T))&&i.set(y,T,!1)}}const m=n.encoding??{},h=Bc.reduce((y,$)=>{if(!i.hasAxisPart($))return y;const C=Tl(m[$]??{},t),_=$==="labels"?qx(t,e,C):C;return _!==void 0&&!I(_)&&(y[$]={update:_}),y},{});return I(h)||i.set("encode",h,!!n.encoding||n.labelAngle!==void 0),i}function eS({encoding:e,size:t}){for(const n of qe){const i=de(n);Qe(t[i])&&(Nt(e[n])&&(delete t[i],x(Wa(i))))}return t}const tS={vgMark:"arc",encodeEntry:e=>({...Ee(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...re("x",e,{defaultPos:"mid"}),...re("y",e,{defaultPos:"mid"}),...Ot(e,"radius"),...Ot(e,"theta")})},nS={vgMark:"area",encodeEntry:e=>({...Ee(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"}),...no(e)})},iS={vgMark:"rect",encodeEntry:e=>({...Ee(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Ot(e,"x"),...Ot(e,"y")})},rS={vgMark:"shape",encodeEntry:e=>({...Ee(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===xn?{field:w(n,{expr:"datum"})}:{}};return[i]}},sS={vgMark:"image",encodeEntry:e=>({...Ee(e,{align:"ignore",baseline:"ignore",color:"ignore",orient:"ignore",size:"ignore",theta:"ignore"}),...Ot(e,"x"),...Ot(e,"y"),...eo(e,"url")})},oS={vgMark:"line",encodeEntry:e=>({...Ee(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore",theta:"ignore"}),...re("x",e,{defaultPos:"mid"}),...re("y",e,{defaultPos:"mid"}),...ee("size",e,{vgChannel:"strokeWidth"}),...no(e)})},aS={vgMark:"trail",encodeEntry:e=>({...Ee(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...re("x",e,{defaultPos:"mid"}),...re("y",e,{defaultPos:"mid"}),...ee("size",e),...no(e)})};function Po(e,t){const{config:n}=e;return{...Ee(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore",theta:"ignore"}),...re("x",e,{defaultPos:"mid"}),...re("y",e,{defaultPos:"mid"}),...ee("size",e),...ee("angle",e),...cS(e,n,t)}}function cS(e,t,n){return n?{shape:{value:n}}:ee("shape",e)}const uS={vgMark:"symbol",encodeEntry:e=>Po(e)},lS={vgMark:"symbol",encodeEntry:e=>Po(e,"circle")},fS={vgMark:"symbol",encodeEntry:e=>Po(e,"square")},dS={vgMark:"rect",encodeEntry:e=>({...Ee(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...Ot(e,"x"),...Ot(e,"y")})},pS={vgMark:"rule",encodeEntry:e=>{const{markDef:t}=e,n=t.orient;return!e.encoding.x&&!e.encoding.y&&!e.encoding.latitude&&!e.encoding.longitude?{}:{...Ee(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"}),...ee("size",e,{vgChannel:"strokeWidth"})}}},gS={vgMark:"text",encodeEntry:e=>{const{config:t,encoding:n}=e;return{...Ee(e,{align:"include",baseline:"include",color:"include",size:"ignore",orient:"ignore",theta:"include"}),...re("x",e,{defaultPos:"mid"}),...re("y",e,{defaultPos:"mid"}),...eo(e),...ee("size",e,{vgChannel:"fontSize"}),...ee("angle",e),...tl("align",mS(e.markDef,n,t)),...tl("baseline",hS(e.markDef,n,t)),...re("radius",e,{defaultPos:null}),...re("theta",e,{defaultPos:null})}}};function mS(e,t,n){const i=z("align",e,n);return i===void 0?"center":void 0}function hS(e,t,n){const i=z("baseline",e,n);return i===void 0?"middle":void 0}const yS={vgMark:"rect",encodeEntry:e=>{const{config:t,markDef:n}=e,i=n.orient,r=i==="horizontal"?"width":"height",s=i==="horizontal"?"height":"width";return{...Ee(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore",theta:"ignore"}),...re("x",e,{defaultPos:"mid",vgChannel:"xc"}),...re("y",e,{defaultPos:"mid",vgChannel:"yc"}),...ee("size",e,{defaultValue:bS(e),vgChannel:r}),[s]:B(z("thickness",n,t))}}};function bS(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&&Ct(a)&&V(a.step))return a.step*3/4;const c=Zi(t.view,r);return c*3/4}}const Er={arc:tS,area:nS,bar:iS,circle:lS,geoshape:rS,image:sS,line:oS,point:uS,rect:dS,rule:pS,square:fS,text:gS,tick:yS,trail:aS};function xS(e){if(P([Pi,Ai,Cg],e.mark)){const t=Xc(e.mark,e.encoding);if(t.length>0)return SS(e,t)}else if(e.mark===Oi){const t=Vr.some(n=>z(n,e.markDef,e.config));if(e.stack&&!e.fieldDef("size")&&t)return wS(e)}return zo(e)}const wf="faceted_path_";function SS(e,t){return[{name:e.getName("pathgroup"),type:"group",from:{facet:{name:wf+e.requestDataName(U.Main),data:e.requestDataName(U.Main),groupby:t}},encode:{update:{width:{field:{group:"width"}},height:{field:{group:"height"}}}},marks:zo(e,{fromPrefix:wf})}]}const $f="stack_group_";function wS(e){const[t]=zo(e,{fromPrefix:$f}),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={...fn(t.encode.update,["y","yc","y2","height",...Vr]),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={...fn(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 Vr){const l=ft(u,e.markDef,e.config);t.encode.update[u]?(s[u]=t.encode.update[u],delete t.encode.update[u]):l&&(s[u]=B(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=ft(l,e.markDef,e.config);return f!==void 0?{...u,[l]:B(f)}:u}},s),s.stroke&&(s.strokeForeground={value:!0},s.strokeOffset={value:0}),[{type:"group",from:{facet:{data:e.requestDataName(U.Main),name:$f+e.requestDataName(U.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 $S(e){const{encoding:t,stack:n,mark:i,markDef:r,config:s}=e,o=t.order;if(!v(o)&&Pe(o)&&Ar(o.value)||!o&&Ar(z("order",r,s)))return;if((v(o)||S(o))&&!n)return Fa(o,{expr:"datum"});if(Ft(i)){const a=r.orient==="horizontal"?"y":"x",c=t[a];if(S(c)){const u=c.sort;if(v(u))return{field:w(c,{prefix:a,suffix:"sort_index",expr:"datum"})};if(Xe(u))return{field:w({aggregate:Fs(e.encoding)?u.op:void 0,field:u.field},{expr:"datum"})};if(kc(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 zo(e,t={fromPrefix:""}){const{mark:n,markDef:i,encoding:r,config:s}=e,o=X(i.clip,vS(e),ES(e)),a=ka(i),c=r.key,u=$S(e),l=_S(e),f=z("aria",i,s),d=Er[n].postEncodingTransform?Er[n].postEncodingTransform(e):null;return[{name:e.getName("marks"),type:Er[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(U.Main)},encode:{update:Er[n].encodeEntry(e)},...d?{transform:d}:{}}]}function vS(e){const t=e.getScaleComponent("x"),n=e.getScaleComponent("y");return t?.get("selectionExtent")||n?.get("selectionExtent")?!0:void 0}function ES(e){const t=e.component.projection;return t&&!t.isFit?!0:void 0}function _S(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 vf extends mf{constructor(t,n,i,r={},s){super(t,"unit",n,i,s,void 0,du(t)?t.view:void 0);this.specifiedScales={},this.specifiedAxes={},this.specifiedLegends={},this.specifiedProjection={},this.selection=[],this.children=[];const o=Ve(t.mark)?{...t.mark}:{type:t.mark},a=o.type;o.filled===void 0&&(o.filled=uh(o,s,{graticule:t.data&&Ys(t.data)}));const c=this.encoding=pm(t.encoding||{},a,o.filled,s);this.markDef=wu(o,c,s),this.size=eS({encoding:c,size:du(t)?{...r,...t.width?{width:t.width}:{},...t.height?{height:t.height}:{}}:r}),this.stack=Su(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=>Ms(u))}get hasProjection(){const{encoding:t}=this,n=this.mark===mc,i=t&&fd.some(r=>F(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=Y(n[r]);return s&&(i[r]=this.initScale(s.scale??{})),i},{})}initScale(t){const{domain:n,range:i}=t,r=pe(t);return v(n)&&(r.domain=n.map(ye)),v(i)&&(r.range=i.map(ye)),r}initAxes(t){return qe.reduce((n,i)=>{const r=t[i];if(F(r)||i===H&&F(t.x2)||i===K&&F(t.y2)){const s=F(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]=ei(s)?va(s):ye(s)}return i}initLegends(t){return Sd.reduce((n,i)=>{const r=Y(t[i]);if(r&&$d(i)){const s=r.legend;n[i]=s&&pe(s)}return n},{})}parseData(){this.component.data=vr(this)}parseLayoutSize(){Lx(this)}parseSelections(){this.component.selection=Fy(this,this.selection)}parseMarkGroup(){this.component.mark=xS(this)}parseAxesAndHeaders(){this.component.axes=Gx(this)}assembleSelectionTopLevelSignals(t){return Kh(this,t)}assembleSignals(){return[...bl(this),...Xh(this,[])]}assembleSelectionData(t){return Qh(this,t)}assembleLayout(){return null}assembleLayoutSignals(){return po(this)}assembleMarks(){let t=this.component.mark??[];return(!this.parent||!Ln(this.parent))&&(t=Bu(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 Kt(this.encoding,t)}fieldDef(t){const n=this.encoding[t];return Ke(n)}typedFieldDef(t){const n=this.fieldDef(t);return ae(n)?n:null}}class Ro extends No{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 Ro(a,this,this.getName(`layer_${c}`),o,s);if(dt(a))return new vf(a,this,this.getName(`layer_${c}`),o,s);throw new Error(Xr(a))})}parseData(){this.component.data=vr(this);for(const t of this.children)t.parseData()}parseLayoutSize(){Rx(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(){Xx(this)}assembleSelectionTopLevelSignals(t){return this.children.reduce((n,i)=>i.assembleSelectionTopLevelSignals(n),t)}assembleSignals(){return this.children.reduce((t,n)=>t.concat(n.assembleSignals()),bl(this))}assembleLayoutSignals(){return this.children.reduce((t,n)=>t.concat(n.assembleLayoutSignals()),po(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 q(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 Zh(this,this.children.flatMap(t=>t.assembleMarks()))}assembleLegends(){return this.children.reduce((t,n)=>t.concat(n.assembleLegends()),Ul(this))}}function Io(e,t,n,i,r){if(Mi(e))return new fi(e,t,n,r);if(er(e))return new Ro(e,t,n,i,r);if(dt(e))return new vf(e,t,n,i,r);if(Lm(e))return new Bx(e,t,n,r);throw new Error(Xr(e))}function kS(e,t={}){t.logger&&Bp(t.logger),t.fieldTitle&&Mc(t.fieldTitle);try{const n=bu(Ko(t.config,e.config)),i=zu(e,n),r=Io(i,null,"",void 0,n);r.parse(),Kb(r.component.data,r);const s=FS(r,CS(e,i.autosize,n,r),e.datasets,e.usermeta);return{spec:s,normalized:i}}finally{t.logger&&Wp(),t.fieldTitle&&rm()}}function CS(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)):N(t)&&(t={type:t}),r&&s&&Hh(t.type)){if(r==="step"&&s==="step")x(za()),t.type="pad";else if(r==="step"||s==="step"){const o=r==="step"?"width":"height";x(za(Ei(o)));const a=o==="width"?"height":"width";t.type=qh(a)}}return{...b(t).length===1&&t.type?t.type==="pad"?{}:{autosize:t.type}:{autosize:t},...Iu(n,!1),...Iu(e,!0)}}function FS(e,t,n={},i){const r=e.config?Qm(e.config):void 0,s=[].concat(e.assembleSelectionData([]),Ax(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([]),...lu(f)]),...r?{config:r}:{},...i?{usermeta:i}:{}}}const NS=sd.version;export{dn as accessPathDepth,Ir as accessPathWithDatum,kS as compile,P as contains,De as deepEqual,yi as deleteNestedProperty,k as duplicate,bt as entries,Or as every,Rr as fieldIntersection,ta as flatAccessWithDatum,X as getFirstDefined,Pr as hasIntersection,O as hash,ra as internalField,Un as isBoolean,I as isEmpty,ad as isEqual,sa as isInternalField,Ar as isNullOrFalse,bi as isNumeric,b as keys,Bn as logicalExpr,Jo as mergeDeep,Zo as never,zu as normalize,Hn as normalizeAngle,ue as omit,fn as pick,zr as prefixGenerator,Lr as removePathFromField,Lt as replaceAll,Se as replacePathInField,ud as resetIdCounter,ea as setEqual,It as some,D as stringify,Wn as titleCase,je as unique,ia as uniqueId,te as vals,W as varName,NS as version};export default null;