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