OCA reporting engine fork for dev and update.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

15 lines
246 KiB

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).vegaLite={})}(this,(function(e){"use strict";var t="4.0.2";function n(e,t,n){return e.fields=t||[],e.fname=n,e}function i(e){throw Error(e)}function r(e){var t,n,r,o=[],s=null,a=0,u=e.length,c="";function l(){o.push(c+e.substring(t,n)),c="",t=n+1}for(e+="",t=n=0;n<u;++n)if("\\"===(r=e[n]))c+=e.substring(t,n),t=++n;else if(r===s)l(),s=null,a=-1;else{if(s)continue;t===a&&'"'===r?(t=n+1,s=r):t===a&&"'"===r?(t=n+1,s=r):"."!==r||a?"["===r?(n>t&&l(),a=t=n+1):"]"===r&&(a||i("Access path missing open bracket: "+e),a>0&&l(),a=0,t=n+1):n>t?l():t=n+1}return a&&i("Access path missing closing bracket: "+e),s&&i("Access path missing closing quote: "+e),n>t&&(n++,l()),o}var o=Array.isArray;function s(e){return e===Object(e)}function a(e){return"string"==typeof e}function u(e){return o(e)?"["+e.map(u)+"]":s(e)||a(e)?JSON.stringify(e).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):e}var c=[],l=(function(e,t){var i=r(e),o="return _["+i.map(u).join("][")+"];";n(Function("_",o),[e=1===i.length?i[0]:e],t||e)}("id"),n((function(e){return e}),c,"identity"));n((function(){return 0}),c,"zero"),n((function(){return 1}),c,"one"),n((function(){return!0}),c,"true"),n((function(){return!1}),c,"false");function d(e,t,n){var i=[t].concat([].slice.call(n));console[e].apply(console,i)}var f=0,p=1,g=2,h=3,m=4;function b(...e){return e.reduce((e,t)=>{for(var n in t)if("signals"===n)e.signals=y(e.signals,t.signals);else{var i="legend"===n?{layout:1}:"style"===n||null;v(e,n,t[n],i)}return e},{})}function v(e,t,n,i){var r,a;if(s(n)&&!o(n))for(r in a=s(e[t])?e[t]:e[t]={},n)i&&(!0===i||i[r])?v(a,r,n[r]):a[r]=n[r];else e[t]=n}function y(e,t){if(null==e)return t;const n={},i=[];function r(e){n[e.name]||(n[e.name]=1,i.push(e))}return t.forEach(r),e.forEach(r),i}function x(e){return null!=e?o(e)?e:[e]:[]}const A=Object.prototype.hasOwnProperty;function O(e,t){return A.call(e,t)}function w(e){return"boolean"==typeof e}function F(e){return"number"==typeof e}function C(e){for(var t={},n=0,i=e.length;n<i;++n)t[e[n]]=!0;return t}Array.prototype.flat||Object.defineProperty(Array.prototype,"flat",{configurable:!0,value:function e(){var t=isNaN(arguments[0])?1:Number(arguments[0]);return t?Array.prototype.reduce.call(this,(function(n,i){return Array.isArray(i)?n.push.apply(n,e.call(i,t-1)):n.push(i),n}),[]):Array.prototype.slice.call(this)},writable:!0}),Array.prototype.flatMap||Object.defineProperty(Array.prototype,"flatMap",{configurable:!0,value:function(e){return Array.prototype.map.apply(this,arguments).flat()},writable:!0});var j=function(e,t){return e(t={exports:{}},t.exports),t.exports}((function(e){var t=function(){function e(e,t){return null!=t&&e instanceof t}var t,n,i;try{t=Map}catch(e){t=function(){}}try{n=Set}catch(e){n=function(){}}try{i=Promise}catch(e){i=function(){}}function r(o,a,u,c,l){"object"==typeof a&&(u=a.depth,c=a.prototype,l=a.includeNonEnumerable,a=a.circular);var d=[],f=[],p="undefined"!=typeof Buffer;return void 0===a&&(a=!0),void 0===u&&(u=1/0),function o(u,g){if(null===u)return null;if(0===g)return u;var h,m;if("object"!=typeof u)return u;if(e(u,t))h=new t;else if(e(u,n))h=new n;else if(e(u,i))h=new i((function(e,t){u.then((function(t){e(o(t,g-1))}),(function(e){t(o(e,g-1))}))}));else if(r.__isArray(u))h=[];else if(r.__isRegExp(u))h=new RegExp(u.source,s(u)),u.lastIndex&&(h.lastIndex=u.lastIndex);else if(r.__isDate(u))h=new Date(u.getTime());else{if(p&&Buffer.isBuffer(u))return h=Buffer.allocUnsafe?Buffer.allocUnsafe(u.length):new Buffer(u.length),u.copy(h),h;e(u,Error)?h=Object.create(u):void 0===c?(m=Object.getPrototypeOf(u),h=Object.create(m)):(h=Object.create(c),m=c)}if(a){var b=d.indexOf(u);if(-1!=b)return f[b];d.push(u),f.push(h)}for(var v in e(u,t)&&u.forEach((function(e,t){var n=o(t,g-1),i=o(e,g-1);h.set(n,i)})),e(u,n)&&u.forEach((function(e){var t=o(e,g-1);h.add(t)})),u){var y;m&&(y=Object.getOwnPropertyDescriptor(m,v)),y&&null==y.set||(h[v]=o(u[v],g-1))}if(Object.getOwnPropertySymbols){var x=Object.getOwnPropertySymbols(u);for(v=0;v<x.length;v++){var A=x[v];(!(w=Object.getOwnPropertyDescriptor(u,A))||w.enumerable||l)&&(h[A]=o(u[A],g-1),w.enumerable||Object.defineProperty(h,A,{enumerable:!1}))}}if(l){var O=Object.getOwnPropertyNames(u);for(v=0;v<O.length;v++){var w,F=O[v];(w=Object.getOwnPropertyDescriptor(u,F))&&w.enumerable||(h[F]=o(u[F],g-1),Object.defineProperty(h,F,{enumerable:!1}))}}return h}(o,u)}function o(e){return Object.prototype.toString.call(e)}function s(e){var t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),t}return r.clonePrototype=function(e){if(null===e)return null;var t=function(){};return t.prototype=e,new t},r.__objToStr=o,r.__isDate=function(e){return"object"==typeof e&&"[object Date]"===o(e)},r.__isArray=function(e){return"object"==typeof e&&"[object Array]"===o(e)},r.__isRegExp=function(e){return"object"==typeof e&&"[object RegExp]"===o(e)},r.__getRegExpFlags=s,r}();e.exports&&(e.exports=t)})),D=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n,i="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&(n=t.cmp,function(e){return function(t,i){var r={key:t,value:e[t]},o={key:i,value:e[i]};return n(r,o)}}),o=[];return function e(t){if(t&&t.toJSON&&"function"==typeof t.toJSON&&(t=t.toJSON()),void 0!==t){if("number"==typeof t)return isFinite(t)?""+t:"null";if("object"!=typeof t)return JSON.stringify(t);var n,s;if(Array.isArray(t)){for(s="[",n=0;n<t.length;n++)n&&(s+=","),s+=e(t[n])||"null";return s+"]"}if(null===t)return"null";if(-1!==o.indexOf(t)){if(i)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var a=o.push(t)-1,u=Object.keys(t).sort(r&&r(t));for(s="",n=0;n<u.length;n++){var c=u[n],l=e(t[c]);l&&(s&&(s+=","),s+=JSON.stringify(c)+":"+l)}return o.splice(a,1),"{"+s+"}"}}(e)};function E(e){return!!e.or}function S(e){return!!e.and}function k(e){return!!e.not}function $(e,t){return k(e)?{not:$(e.not,t)}:S(e)?{and:e.and.map(e=>$(e,t))}:E(e)?{or:e.or.map(e=>$(e,t))}:t(e)}const B=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var i,r,o;if(Array.isArray(t)){if((i=t.length)!=n.length)return!1;for(r=i;0!=r--;)if(!e(t[r],n[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((i=(o=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(r=i;0!=r--;)if(!Object.prototype.hasOwnProperty.call(n,o[r]))return!1;for(r=i;0!=r--;){var s=o[r];if(!e(t[s],n[s]))return!1}return!0}return t!=t&&n!=n},N=j;function _(e,t){const n={};for(const i of t)O(e,i)&&(n[i]=e[i]);return n}function z(e,t){const n=Object.assign({},e);for(const e of t)delete n[e];return n}Set.prototype.toJSON=function(){return`Set(${[...this].map(e=>D(e)).join(",")})`};const T=D;function P(e){if(F(e))return e;const t=a(e)?e:D(e);if(t.length<250)return t;let n=0;for(let e=0;e<t.length;e++){n=(n<<5)-n+t.charCodeAt(e),n&=n}return n}function M(e){return!1===e||null===e}function U(e,t){return e.indexOf(t)>-1}function R(e,t){let n=0;for(const[i,r]of e.entries())if(t(r,i,n++))return!0;return!1}function L(e,t){let n=0;for(const[i,r]of e.entries())if(!t(r,i,n++))return!1;return!0}function W(e,t){for(const n of Object.keys(t))v(e,n,t[n],!0)}function q(e,t){const n=[],i={};let r;for(const o of e)r=t(o),r in i||(i[r]=1,n.push(o));return n}function I(e,t){for(const n of e)if(t.has(n))return!0;return!1}function H(e){const t=new Set;for(const n of e){const e=r(n).map((e,t)=>0===t?e:`[${e}]`);e.map((t,n)=>e.slice(0,n+1).join("")).forEach(e=>t.add(e))}return t}function G(e,t){return void 0===e||void 0===t||I(H(e),H(t))}const Y=Object.keys;function V(e){const t=[];for(const n in e)O(e,n)&&t.push(e[n]);return t}function J(e){return!0===e||!1===e}function Q(e){const t=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+t}function X(e,t){return k(e)?"!("+X(e.not,t)+")":S(e)?"("+e.and.map(e=>X(e,t)).join(") && (")+")":E(e)?"("+e.or.map(e=>X(e,t)).join(") || (")+")":t(e)}function Z(e,t){if(0===t.length)return!0;const n=t.shift();return Z(e[n],t)&&delete e[n],0===Y(e).length}function K(e){return e.charAt(0).toUpperCase()+e.substr(1)}function ee(e,t="datum"){const n=r(e),i=[];for(let e=1;e<=n.length;e++){const r=`[${n.slice(0,e).map(u).join("][")}]`;i.push(`${t}${r}`)}return i.join(" && ")}function te(e){return`${r(e).map(e=>ne(e,".","\\.")).join("\\.")}`}function ne(e,t,n){return e.replace(new RegExp(t.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&"),"g"),n)}function ie(e){return`${r(e).join(".")}`}function re(e){return e?r(e).length:0}function oe(...e){for(const t of e)if(void 0!==t)return t}let se=42;function ae(e){return(e%360+360)%360}const ue="area",ce="bar",le="image",de="line",fe="point",pe="rect",ge="rule",he="text",me="tick",be="trail",ve="circle",ye="square",xe="geoshape";function Ae(e){return U(["line","area","trail"],e)}function Oe(e){return U(["rect","bar","image"],e)}const we=Y({area:1,bar:1,image:1,line:1,point:1,text:1,tick:1,trail:1,rect:1,geoshape:1,rule:1,circle:1,square:1});function Fe(e){return e.type}C(we);const Ce=["stroke","strokeWidth","strokeDash","strokeDashOffset","strokeOpacity","strokeJoin","strokeMiterLimit","fill","fillOpacity"],je=["filled","color","tooltip","invalid","timeUnitBandPosition","timeUnitBand"],De={binSpacing:1,continuousBandSize:5,timeUnitBandPosition:.5},Ee={binSpacing:0,continuousBandSize:5,timeUnitBandPosition:.5};function Se(e){return!!e.mark}class ke{constructor(e,t){this.name=e,this.run=t}hasMatchingType(e){return!!Se(e)&&(Fe(t=e.mark)?t.type:t)===this.name;var t}}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function $e(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}const Be={argmax:1,argmin:1,average:1,count:1,distinct:1,max:1,mean:1,median:1,min:1,missing:1,q1:1,q3:1,ci0:1,ci1:1,stderr:1,stdev:1,stdevp:1,sum:1,valid:1,values:1,variance:1,variancep:1},Ne={count:1,min:1,max:1};function _e(e){return!!e&&!!e.argmin}function ze(e){return!!e&&!!e.argmax}function Te(e){return a(e)&&!!Be[e]}const Pe=["count","valid","missing","distinct"];function Me(e){return a(e)&&U(Pe,e)}const Ue=["count","sum","distinct","valid","missing"],Re=C(["mean","average","median","q1","q3","min","max"]),Le="row",We="column",qe="facet",Ie="x",He="y",Ge="x2",Ye="y2",Ve="latitude",Je="longitude",Qe="latitude2",Xe="longitude2",Ze="color",Ke="fill",et="stroke",tt="shape",nt="size",it="opacity",rt="fillOpacity",ot="strokeOpacity",st="strokeWidth",at="text",ut="order",ct="detail",lt="key",dt="tooltip",ft="href",pt="url";const gt={longitude:1,longitude2:1,latitude:1,latitude2:1};const ht=Y(gt),mt=Object.assign(Object.assign(Object.assign({},{x:1,y:1,x2:1,y2:1}),gt),{color:1,fill:1,stroke:1,opacity:1,fillOpacity:1,strokeOpacity:1,strokeWidth:1,size:1,shape:1,order:1,text:1,detail:1,key:1,tooltip:1,href:1,url:1});function bt(e){return"color"===e||"fill"===e||"stroke"===e}const vt={row:1,column:1,facet:1},yt=Y(vt),xt=Object.assign(Object.assign({},mt),vt),At=Y(xt),Ot=$e(xt,["order","detail","tooltip"]),wt=$e(Ot,["row","column","facet"]);function Ft(e){return!!wt[e]}function Ct(e){return!!xt[e]}const jt=["x2","y2","latitude2","longitude2"];function Dt(e){return Et(e)!==e}function Et(e){switch(e){case"x2":return"x";case"y2":return"y";case"latitude2":return"latitude";case"longitude2":return"longitude"}return e}function St(e){switch(e){case"x":return"x2";case"y":return"y2";case"latitude":return"latitude2";case"longitude":return"longitude2"}}const kt=$e(mt,["x","y","x2","y2","latitude","longitude","latitude2","longitude2"]),$t=Y(kt),Bt={x:1,y:1},Nt=Y(Bt);function _t(e){return"x"===e?"width":"height"}function zt(e){return"width"===e?"x":"y"}const Tt=$e(kt,["text","tooltip","href","url","detail","key","order"]),Pt=Y(Tt);const Mt=Object.assign(Object.assign({},Bt),Tt),Ut=Y(Mt);function Rt(e){return!!Mt[e]}function Lt(e,t){return function(e){switch(e){case Ze:case Ke:case et:case ct:case lt:case dt:case ft:case ut:case it:case rt:case ot:case st:case qe:case Le:case We:return Wt;case Ie:case He:case Ve:case Je:return qt;case Ge:case Ye:case Qe:case Xe:return{area:"always",bar:"always",image:"always",rect:"always",rule:"always",circle:"binned",point:"binned",square:"binned",tick:"binned",line:"binned",trail:"binned"};case nt:return{point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",text:"always",line:"always",trail:"always"};case tt:return{point:"always",geoshape:"always"};case at:return{text:"always"};case pt:return{image:"always"}}}(e)[t]}const Wt={area:"always",bar:"always",circle:"always",geoshape:"always",image:"always",line:"always",rule:"always",point:"always",rect:"always",square:"always",trail:"always",text:"always",tick:"always"},qt=$e(Wt,["geoshape"]);function It(e){switch(e){case Ie:case He:case nt:case st:case it:case rt:case ot:case Ge:case Ye:return;case qe:case Le:case We:case tt:case at:case dt:case ft:case pt:return"discrete";case Ze:case Ke:case et:return"flexible";case Ve:case Je:case Qe:case Xe:case ct:case lt:case ut:return}}const Ht=Object.freeze({__proto__:null,invalidSpec:function(e){return`Invalid specification ${JSON.stringify(e)}. Make sure the specification includes at least one of the following properties: "mark", "layer", "facet", "hconcat", "vconcat", "concat", or "repeat".`},FIT_NON_SINGLE:'Autosize "fit" only works for single views and layered views.',containerSizeNonSingle:function(e){return`${"width"==e?"Width":"Height"} "container" only works for single views and layered views.`},containerSizeNotCompatibleWithAutosize:function(e){return`${"width"==e?"Width":"Height"} "container" only works well with autosize "fit" or "fit-x".`},droppingFit:function(e){return e?`Dropping "fit-${e}" because spec has discrete ${_t(e)}.`:'Dropping "fit" because spec has discrete size.'},cannotProjectOnChannelWithoutField:function(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`},cannotProjectAggregate:function(e,t){return`Cannot project a selection on encoding channel "${e}" as it uses an aggregate function ("${t}").`},nearestNotSupportForContinuous:function(e){return`The "nearest" transform is not supported for ${e} marks.`},selectionNotSupported:function(e){return`Selection not supported for ${e} yet.`},selectionNotFound:function(e){return`Cannot find a selection named "${e}".`},SCALE_BINDINGS_CONTINUOUS:"Scale bindings are currently only supported for scales with unbinned, continuous domains.",LEGEND_BINDINGS_PROJECT_LENGTH:"Legend bindings are only supported for selections over an individual field or encoding channel.",noSameUnitLookup:function(e){return`Cannot define and lookup the "${e}" selection in the same view. `+"Try moving the lookup into a second, layered view?"},noSuchRepeatedValue:function(e){return`Unknown repeated value "${e}".`},columnsNotSupportByRowCol:function(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`},CONCAT_CANNOT_SHARE_AXIS:"Axes cannot be shared in concatenated views yet (https://github.com/vega/vega-lite/issues/2415).",REPEAT_CANNOT_SHARE_AXIS:"Axes cannot be shared in repeated views yet (https://github.com/vega/vega-lite/issues/2415).",unrecognizedParse:function(e){return`Unrecognized parse "${e}".`},differentParse:function(e,t,n){return`An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.`},invalidTransformIgnored:function(e){return`Ignoring an invalid transform: ${T(e)}.`},NO_FIELDS_NEEDS_AS:'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.',encodingOverridden:function(e){return`Layer's shared ${e.join(",")} channel ${1===e.length?"is":"are"} overriden.`},projectionOverridden:function(e){const{parentProjection:t,projection:n}=e;return`Layer's shared projection ${T(t)} is overridden by a child projection ${T(n)}.`},primitiveChannelDef:function(e,t,n){return`Channel ${e} is a ${t}. Converted to {value: ${T(n)}}.`},invalidFieldType:function(e){return`Invalid field type "${e}".`},nonZeroScaleUsedWithLengthMark:function(e,t,n){return`A ${n.scaleType?`${n.scaleType} scale`:n.zeroFalse?"scale with zero=false":"scale with custom domain that excludes zero"} is used to encode ${e}'s ${t}. This can be misleading as the ${"x"===t?"width":"height"} of the ${e} can be arbitrary based on the scale domain. You may want to use point mark instead.`},invalidFieldTypeForCountAggregate:function(e,t){return`Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.`},invalidAggregate:function(e){return`Invalid aggregation operator "${e}".`},missingFieldType:function(e,t){return`Missing type for channel "${e}", using "${t}" instead.`},droppingColor:function(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"}.`},emptyFieldDef:function(e,t){return`Dropping ${T(e)} from channel "${t}" since it does not contain data field or value.`},latLongDeprecated:function(e,t,n){return`${e}-encoding with type ${t} is deprecated. Replacing with ${n}-encoding.`},LINE_WITH_VARYING_SIZE:"Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.",incompatibleChannel:function(e,t,n){return`${e} dropped as it is incompatible with "${t}"${n?` when ${n}`:""}.`},invalidEncodingChannel:function(e){return`${e}-encoding is dropped as ${e} is not a valid encoding channel.`},facetChannelShouldBeDiscrete:function(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`},facetChannelDropped:function(e){return`Facet encoding dropped as ${e.join(" and ")} ${e.length>1?"are":"is"} also specified.`},discreteChannelCannotEncode:function(e,t){return`Using discrete channel "${e}" to encode "${t}" field can be misleading as it does not encode ${"ordinal"===t?"order":"magnitude"}.`},lineWithRange:function(e,t){return`Line mark is for continuous lines and thus cannot be used with ${e&&t?"x2 and y2":e?"x2":"y2"}. We will use the rule mark (line segments) instead.`},orientOverridden:function(e,t){return`Specified orient "${e}" overridden with "${t}".`},CANNOT_UNION_CUSTOM_DOMAIN_WITH_FIELD_DOMAIN:"Custom domain scale cannot be unioned with default field-based domain.",RANGE_STEP_DEPRECATED:'Scale\'s "rangeStep" is deprecated and will be removed in Vega-Lite 5.0. Please use "width"/"height": {"step": ...} instead. See https://vega.github.io/vega-lite/docs/size.html.',cannotUseScalePropertyWithNonColor:function(e){return`Cannot use the scale property "${e}" with non-color channel.`},unaggregateDomainHasNoEffectForRawField:function(e){return`Using unaggregated domain with raw field has no effect (${T(e)}).`},unaggregateDomainWithNonSharedDomainOp:function(e){return`Unaggregated domain not applicable for "${e}" since it produces values outside the origin domain of the source data.`},unaggregatedDomainWithLogScale:function(e){return`Unaggregated domain is currently unsupported for log scale (${T(e)}).`},cannotApplySizeToNonOrientedMark:function(e){return`Cannot apply size to non-oriented mark "${e}".`},scaleTypeNotWorkWithChannel:function(e,t,n){return`Channel "${e}" does not work with "${t}" scale. We are using "${n}" scale instead.`},scaleTypeNotWorkWithFieldDef:function(e,t){return`FieldDef does not work with "${e}" scale. We are using "${t}" scale instead.`},scalePropertyNotWorkWithScaleType:function(e,t,n){return`${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`},scaleTypeNotWorkWithMark:function(e,t){return`Scale type "${t}" does not work with mark "${e}".`},stepDropped:function(e){return`The step for "${e}" is dropped because the ${"width"===e?"x":"y"} is continuous.`},mergeConflictingProperty:function(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${T(n)} and ${T(i)}). Using ${T(n)}.`},mergeConflictingDomainProperty:function(e,t,n,i){return`Conflicting ${t.toString()} property "${e.toString()}" (${T(n)} and ${T(i)}). Using the union of the two domains.`},independentScaleMeansIndependentGuide:function(e){return`Setting the scale to be independent for "${e}" means we also have to set the guide (axis or legend) to be independent.`},domainSortDropped:function(e){return`Dropping sort property ${T(e)} as unioned domains only support boolean or op "count", "min", and "max".`},UNABLE_TO_MERGE_DOMAINS:"Unable to merge domains.",MORE_THAN_ONE_SORT:"Domains that should be unioned has conflicting sort properties. Sort will be set to true.",INVALID_CHANNEL_FOR_AXIS:"Invalid channel for axis.",cannotStackRangedMark:function(e){return`Cannot stack "${e}" if there is already "${e}2".`},cannotStackNonLinearScale:function(e){return`Cannot stack non-linear scale (${e}).`},stackNonSummativeAggregate:function(e){return`Stacking is applied even though the aggregate function is non-summative ("${e}").`},invalidTimeUnit:function(e,t){return`Invalid ${e}: ${T(t)}.`},dayReplacedWithDate:function(e){return`Time unit "${e}" is not supported. We are replacing it with ${ne(e,"day","date")}.`},droppedDay:function(e){return`Dropping day from datetime ${T(e)} as day cannot be combined with other units.`},errorBarCenterAndExtentAreNotNeeded:function(e,t){return`${t?"extent ":""}${t&&e?"and ":""}${e?"center ":""}${t&&e?"are ":"is "}not needed when data are aggregated.`},errorBarCenterIsUsedWithWrongExtent:function(e,t,n){return`${e} is not usually used with ${t} for ${n}.`},errorBarContinuousAxisHasCustomizedAggregate:function(e,t){return`Continuous axis should not have customized aggregation function ${e}; ${t} already agregates the axis.`},errorBarCenterIsNotNeeded:function(e,t){return`Center is not needed to be specified in ${t} when extent is ${e}.`},errorBand1DNotSupport:function(e){return`1D error band does not support ${e}.`},channelRequiredForBinned:function(e){return`Channel ${e} is required for "binned" bin.`},domainRequiredForThresholdScale:function(e){return`Domain for ${e} is required for threshold scale.`}}),Gt=(Vt=g||f,{level:function(e){return arguments.length?(Vt=+e,this):Vt},error:function(){return Vt>=p&&d(Yt||"error","ERROR",arguments),this},warn:function(){return Vt>=g&&d(Yt||"warn","WARN",arguments),this},info:function(){return Vt>=h&&d(Yt||"log","INFO",arguments),this},debug:function(){return Vt>=m&&d(Yt||"log","DEBUG",arguments),this}});var Yt,Vt;let Jt=Gt;function Qt(...e){Jt.warn(...e)}const Xt=2006;function Zt(e){return!!(e&&(e.year||e.quarter||e.month||e.date||e.day||e.hours||e.minutes||e.seconds||e.milliseconds))}const Kt=["january","february","march","april","may","june","july","august","september","october","november","december"],en=Kt.map(e=>e.substr(0,3)),tn=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],nn=tn.map(e=>e.substr(0,3));function rn(e,t=!1,n=!1){const i=[];if(t&&void 0!==e.day&&Y(e).length>1&&(Qt(Ht.droppedDay(e)),delete(e=N(e)).day),void 0!==e.year?i.push(e.year):void 0!==e.day?i.push(Xt):i.push(0),void 0!==e.month){const n=t?function(e){if(F(e))return(e-1).toString();{const t=e.toLowerCase(),n=Kt.indexOf(t);if(-1!==n)return n+"";const i=t.substr(0,3),r=en.indexOf(i);if(-1!==r)return r+"";throw new Error(Ht.invalidTimeUnit("month",e))}}(e.month):e.month;i.push(n)}else if(void 0!==e.quarter){const n=t?function(e){if(F(e))return e>4&&Qt(Ht.invalidTimeUnit("quarter",e)),(e-1).toString();throw new Error(Ht.invalidTimeUnit("quarter",e))}(e.quarter):e.quarter;i.push(n+"*3")}else i.push(0);if(void 0!==e.date)i.push(e.date);else if(void 0!==e.day){const n=t?function(e){if(F(e))return e%7+"";{const t=e.toLowerCase(),n=tn.indexOf(t);if(-1!==n)return n+"";const i=t.substr(0,3),r=nn.indexOf(i);if(-1!==r)return r+"";throw new Error(Ht.invalidTimeUnit("day",e))}}(e.day):e.day;i.push(n+"+1")}else i.push(1);for(const t of["hours","minutes","seconds","milliseconds"]){const n=e[t];i.push(void 0===n?0:n)}const r=i.join(", ");return n?e.utc?new Function(`return +new Date(Date.UTC(${r}))`)():new Function(`return +new Date(${r})`)():e.utc?`utc(${r})`:`datetime(${r})`}var on;!function(e){e.YEAR="year",e.MONTH="month",e.DAY="day",e.DATE="date",e.HOURS="hours",e.MINUTES="minutes",e.SECONDS="seconds",e.MILLISECONDS="milliseconds",e.YEARMONTH="yearmonth",e.YEARMONTHDATE="yearmonthdate",e.YEARMONTHDATEHOURS="yearmonthdatehours",e.YEARMONTHDATEHOURSMINUTES="yearmonthdatehoursminutes",e.YEARMONTHDATEHOURSMINUTESSECONDS="yearmonthdatehoursminutesseconds",e.MONTHDATE="monthdate",e.MONTHDATEHOURS="monthdatehours",e.HOURSMINUTES="hoursminutes",e.HOURSMINUTESSECONDS="hoursminutesseconds",e.MINUTESSECONDS="minutesseconds",e.SECONDSMILLISECONDS="secondsmilliseconds",e.QUARTER="quarter",e.YEARQUARTER="yearquarter",e.QUARTERMONTH="quartermonth",e.YEARQUARTERMONTH="yearquartermonth",e.UTCYEAR="utcyear",e.UTCMONTH="utcmonth",e.UTCDAY="utcday",e.UTCDATE="utcdate",e.UTCHOURS="utchours",e.UTCMINUTES="utcminutes",e.UTCSECONDS="utcseconds",e.UTCMILLISECONDS="utcmilliseconds",e.UTCYEARMONTH="utcyearmonth",e.UTCYEARMONTHDATE="utcyearmonthdate",e.UTCYEARMONTHDATEHOURS="utcyearmonthdatehours",e.UTCYEARMONTHDATEHOURSMINUTES="utcyearmonthdatehoursminutes",e.UTCYEARMONTHDATEHOURSMINUTESSECONDS="utcyearmonthdatehoursminutesseconds",e.UTCMONTHDATE="utcmonthdate",e.UTCMONTHDATEHOURS="utcmonthdatehours",e.UTCHOURSMINUTES="utchoursminutes",e.UTCHOURSMINUTESSECONDS="utchoursminutesseconds",e.UTCMINUTESSECONDS="utcminutesseconds",e.UTCSECONDSMILLISECONDS="utcsecondsmilliseconds",e.UTCQUARTER="utcquarter",e.UTCYEARQUARTER="utcyearquarter",e.UTCQUARTERMONTH="utcquartermonth",e.UTCYEARQUARTERMONTH="utcyearquartermonth"}(on||(on={}));const sn={year:1,quarter:1,month:1,day:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},an=Y(sn);const un={utcyear:1,utcquarter:1,utcmonth:1,utcday:1,utcdate:1,utchours:1,utcminutes:1,utcseconds:1,utcmilliseconds:1};const cn={utcyearquarter:1,utcyearquartermonth:1,utcyearmonth:1,utcyearmonthdate:1,utcyearmonthdatehours:1,utcyearmonthdatehoursminutes:1,utcyearmonthdatehoursminutesseconds:1,utcquartermonth:1,utcmonthdate:1,utcmonthdatehours:1,utchoursminutes:1,utchoursminutesseconds:1,utcminutesseconds:1,utcsecondsmilliseconds:1},ln=Object.assign(Object.assign({},un),cn);Object.assign(Object.assign(Object.assign(Object.assign({},sn),un),{yearquarter:1,yearquartermonth:1,yearmonth:1,yearmonthdate:1,yearmonthdatehours:1,yearmonthdatehoursminutes:1,yearmonthdatehoursminutesseconds:1,quartermonth:1,monthdate:1,monthdatehours:1,hoursminutes:1,hoursminutesseconds:1,minutesseconds:1,secondsmilliseconds:1}),cn);const dn={"year-month":"%b %Y ","year-month-date":"%b %d, %Y "};function fn(e){return an.reduce((t,n)=>pn(e,n)?[...t,n]:t,[])}function pn(e,t){const n=e.indexOf(t);return n>-1&&(t!==on.SECONDS||0===n||"i"!==e.charAt(n-1))}function gn(e,t,{end:n}={end:!1}){const i=ee(t),r=ln[e]?"utc":"";let o;const s=an.reduce((t,n)=>(pn(e,n)&&(t[n]=function(e){return e===on.QUARTER?`(${r}quarter(${i})-1)`:`${r}${e}(${i})`}(n),o=n),t),{});return n&&(s[o]+="+1"),rn(s)}function hn(e,t,n){if(!e)return;const i=function(e){if(!e)return;const t=fn(e);return`timeUnitSpecifier(${D(t)}, ${D(dn)})`}(e);return n?`utcFormat(${t}, ${i})`:`timeFormat(${t}, ${i})`}function mn(e){return"day"!==e&&e.indexOf("day")>=0?(Qt(Ht.dayReplacedWithDate(e)),ne(e,"day","date")):e}function bn(e){return e&&!!e.field&&void 0!==e.equal}function vn(e){return e&&!!e.field&&void 0!==e.lt}function yn(e){return e&&!!e.field&&void 0!==e.lte}function xn(e){return e&&!!e.field&&void 0!==e.gt}function An(e){return e&&!!e.field&&void 0!==e.gte}function On(e){return!!(e&&e.field&&o(e.range)&&2===e.range.length)}function wn(e){return e&&!!e.field&&(o(e.oneOf)||o(e.in))}function Fn(e){return wn(e)||bn(e)||On(e)||vn(e)||xn(e)||yn(e)||An(e)}function Cn(e,t){return or(e,{timeUnit:t,time:!0})}function jn(e,t=!0){const{field:n,timeUnit:i}=e,r=i?"time("+gn(i,n)+")":Wi(e,{expr:"datum"});if(bn(e))return r+"==="+Cn(e.equal,i);if(vn(e)){return`${r}<${Cn(e.lt,i)}`}if(xn(e)){return`${r}>${Cn(e.gt,i)}`}if(yn(e)){return`${r}<=${Cn(e.lte,i)}`}if(An(e)){return`${r}>=${Cn(e.gte,i)}`}if(wn(e))return`indexof([${function(e,t){return e.map(e=>Cn(e,t))}(e.oneOf,i).join(",")}], ${r}) !== -1`;if(function(e){return e&&!!e.field&&void 0!==e.valid}(e))return Dn(r,e.valid);if(On(e)){const n=e.range[0],o=e.range[1];if(null!==n&&null!==o&&t)return"inrange("+r+", ["+Cn(n,i)+", "+Cn(o,i)+"])";const s=[];return null!==n&&s.push(`${r} >= ${Cn(n,i)}`),null!==o&&s.push(`${r} <= ${Cn(o,i)}`),s.length>0?s.join(" && "):"true"}throw new Error(`Invalid field predicate: ${JSON.stringify(e)}`)}function Dn(e,t=!0){return t?`isValid(${e}) && isFinite(+${e})`:`!isValid(${e}) || !isFinite(+${e})`}function En(e){return Fn(e)&&e.timeUnit?Object.assign(Object.assign({},e),{timeUnit:mn(e.timeUnit)}):e}const Sn={quantitative:1,ordinal:1,temporal:1,nominal:1,geojson:1},kn="quantitative",$n="ordinal",Bn="temporal",Nn="nominal",_n="geojson";var zn;!function(e){e.LINEAR="linear",e.LOG="log",e.POW="pow",e.SQRT="sqrt",e.SYMLOG="symlog",e.TIME="time",e.UTC="utc",e.QUANTILE="quantile",e.QUANTIZE="quantize",e.THRESHOLD="threshold",e.BIN_ORDINAL="bin-ordinal",e.ORDINAL="ordinal",e.POINT="point",e.BAND="band"}(zn||(zn={}));const Tn={linear:"numeric",log:"numeric",pow:"numeric",sqrt:"numeric",symlog:"numeric",time:"time",utc:"time",ordinal:"ordinal","bin-ordinal":"bin-ordinal",point:"ordinal-position",band:"ordinal-position",quantile:"discretizing",quantize:"discretizing",threshold:"discretizing"},Pn=Y(Tn);function Mn(e,t){const n=Tn[e],i=Tn[t];return n===i||"ordinal-position"===n&&"time"===i||"ordinal-position"===i&&"time"===n}const Un={linear:0,log:1,pow:1,sqrt:1,symlog:1,time:0,utc:0,point:10,band:11,ordinal:0,"bin-ordinal":0,quantile:0,quantize:0,threshold:0};function Rn(e){return Un[e]}const Ln=["linear","log","pow","sqrt","symlog","time","utc"],Wn=C(Ln),qn=C(["quantile","quantize","threshold"]),In=C(Ln.concat(["quantile","quantize","threshold"])),Hn=C(["ordinal","bin-ordinal","point","band"]);function Gn(e){return e in Hn}function Yn(e){return e in In}function Vn(e){return e in Wn}function Jn(e){return e in qn}function Qn(e){var t;return null===(t=e)||void 0===t?void 0:t.selection}const Xn=$e({type:1,domain:1,align:1,range: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","domain","range","scheme"]),Zn=Y(Xn);!function(){var e;const t={};for(const n of At)for(const i of Y(Sn))for(const r of Pn){const o=ii(n,i);ni(n,r)&&ti(r,i)&&(t[o]=null!=(e=t[o])?e:[],t[o].push(r))}}();function Kn(e,t){switch(t){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!U(["point","band","identity"],e);case"bins":return!U(["point","band","identity","ordinal"],e);case"round":return Vn(e)||"band"===e||"point"===e;case"padding":return Vn(e)||U(["point","band"],e);case"paddingOuter":case"align":return U(["point","band"],e);case"paddingInner":return"band"===e;case"clamp":return Vn(e);case"nice":return Vn(e)||"quantize"===e||"threshold"===e;case"exponent":return"pow"===e;case"base":return"log"===e;case"constant":return"symlog"===e;case"zero":return Yn(e)&&!U(["log","time","utc","threshold","quantile"],e)}}function ei(e,t){switch(t){case"interpolate":case"scheme":return bt(e)?void 0:Ht.cannotUseScalePropertyWithNonColor(e);case"align":case"type":case"bins":case"domain":case"range":case"base":case"exponent":case"constant":case"nice":case"padding":case"paddingInner":case"paddingOuter":case"reverse":case"round":case"clamp":case"zero":return}}function ti(e,t){return U([$n,Nn],t)?void 0===e||Gn(e):t===Bn?U([zn.TIME,zn.UTC,void 0],e):t!==kn||U([zn.LOG,zn.POW,zn.SQRT,zn.SYMLOG,zn.QUANTILE,zn.QUANTIZE,zn.THRESHOLD,zn.LINEAR,void 0],e)}function ni(e,t){switch(e){case Ie:case He:return Vn(t)||U(["band","point"],t);case nt:case st:case it:case rt:case ot:return Vn(t)||Jn(t)||U(["band","point"],t);case Ze:case Ke:case et:return"band"!==t;case tt:return"ordinal"===t}return!1}function ii(e,t){return e+"_"+t}function ri(e){const{anchor:t,frame:n,offset:i,orient:r,color:o}=e,s=$e(e,["anchor","frame","offset","orient","color"]);return{mark:Object.assign(Object.assign({},s),o?{fill:o}:{}),nonMark:Object.assign(Object.assign(Object.assign(Object.assign({},t?{anchor:t}:{}),n?{frame:n}:{}),i?{offset:i}:{}),r?{orient:r}:{})}}function oi(e){return a(e)||o(e)&&a(e[0])}const si=" – ";function ai(e){var t;return[].concat(e.type,null!=(t=e.style)?t:[])}function ui(e,t,n){return oe(t[e],ci(e,t,n))}function ci(e,t,n,{vgChannel:i}={}){return oe(i?li(e,t,n.style):void 0,li(e,t,n.style),i?n[t.type][i]:void 0,n[t.type][e],i?n.mark[i]:n.mark[e])}function li(e,t,n){const i=ai(t);let r;for(const t of i){const i=n[t],o=e;i&&void 0!==i[o]&&(r=i[o])}return r}function di(e,t,n,i){if(rr(e)){const r=Ui(e)&&e.scale&&e.scale.type===zn.UTC;return{signal:mi(Wi(e,{expr:n}),e.timeUnit,t,i.timeFormat,r,!0)}}{const r=fi(e,t,i);if(cr(e.bin)){return{signal:hi(Wi(e,{expr:n}),Wi(e,{expr:n,binSuffix:"end"}),r,i)}}return"quantitative"===e.type||r?{signal:`${pi(Wi(e,{expr:n,binSuffix:"range"}),r)}`}:{signal:`''+${Wi(e,{expr:n})}`}}}function fi(e,t,n){return t||(e.type===kn?n.numberFormat:void 0)}function pi(e,t){return`format(${e}, "${t||""}")`}function gi(e,t,n){return pi(e,null!=t?t:n.numberFormat)}function hi(e,t,n,i){return`${Dn(e,!1)} ? "null" : ${gi(e,n,i)} + "${si}" + ${gi(t,n,i)}`}function mi(e,t,n,i,r,o=!1){return!t||n?(n=null!=n?n:i)||o?`${r?"utc":"time"}Format(${e}, '${n}')`:void 0:hn(t,e,r)}function bi(e,t){return x(e).reduce((e,n)=>{var i;return e.field.push(Wi(n,t)),e.order.push(null!=(i=n.sort)?i:"ascending"),e},{field:[],order:[]})}function vi(e,t){const n=[...e];return t.forEach(e=>{for(const t of n)if(B(t,e))return;n.push(e)}),n}function yi(e,t){return B(e,t)||!t?e:e?[...x(e),...x(t)].join(", "):t}function xi(e,t){const n=e.value,i=t.value;if(null==n||null===i)return{explicit:e.explicit,value:null};if(oi(n)&&oi(i))return{explicit:e.explicit,value:yi(n,i)};if(!oi(n)&&!oi(i))return{explicit:e.explicit,value:vi(n,i)};throw new Error("It should never reach here")}const Ai="mean",Oi={x:1,y:1,color:1,fill:1,stroke:1,strokeWidth:1,size:1,shape:1,fillOpacity:1,strokeOpacity:1,opacity:1,text:1};function wi(e){return!!Oi[e]}function Fi(e){return!!e&&!!e.encoding}function Ci(e){return!(!e||"count"!==e.op&&!e.field)}function ji(e){return!!e&&o(e)}function Di(e){return!!e.row||!!e.column}function Ei(e){return void 0!==e.facet}function Si(e){const{field:t,timeUnit:n,bin:i,aggregate:r}=e;return Object.assign(Object.assign(Object.assign(Object.assign({},n?{timeUnit:n}:{}),i?{bin:i}:{}),r?{aggregate:r}:{}),{field:t})}function ki(e){return Ti(e)&&!!e.sort}function $i(e,t,n,i,r,{isMidPoint:o}={}){const{timeUnit:s,bin:a}=t;if(U(["x","y"],e)){if(Ri(t)&&void 0!==t.band)return t.band;if(s&&!n)return o?ci("timeUnitBandPosition",i,r):Oe(i.type)?ci("timeUnitBand",i,r):0;if(cr(a))return Oe(i.type)&&!o?1:.5}}function Bi(e,t,n,i,r){return!!(cr(t.bin)||t.timeUnit&&Ti(t)&&"temporal"===t.type)&&!!$i(e,t,n,i,r)}function Ni(e){return!!e&&!!e.condition}function _i(e){return!!e&&!!e.condition&&!o(e.condition)&&zi(e.condition)}function zi(e){return!(!e||!e.field&&"count"!==e.aggregate)}function Ti(e){return!!e&&(!!e.field&&!!e.type||"count"===e.aggregate)}function Pi(e){return zi(e)&&a(e.field)}function Mi(e){return e&&"value"in e&&void 0!==e.value}function Ui(e){return!(!e||!e.scale&&!e.sort)}function Ri(e){return!(!e||!e.axis&&!e.stack&&!e.impute&&void 0===e.band)}function Li(e){return!!e&&!!e.format}function Wi(e,t={}){var n,i,o;let s=e.field;const a=t.prefix;let c=t.suffix,l="";if(function(e){return"count"===e.aggregate}(e))s=function(e){return function(e){return 0===e.indexOf("__")}(e)?e:`__${e}`}("count");else{let r;if(!t.nofn)if(function(e){return!!e.op}(e))r=e.op;else{const{bin:a,aggregate:u,timeUnit:d}=e;cr(a)?(r=ur(a),c=(null!=(n=t.binSuffix)?n:"")+(null!=(i=t.suffix)?i:"")):u?ze(u)?(l=`.${s}`,s=`argmax_${u.argmax}`):_e(u)?(l=`.${s}`,s=`argmin_${u.argmin}`):r=String(u):d&&(r=String(d),c=(!U(["range","mid"],t.binSuffix)&&t.binSuffix||"")+(null!=(o=t.suffix)?o:""))}r&&(s=s?`${r}_${s}`:r)}return c&&(s=`${s}_${c}`),a&&(s=`${a}_${s}`),t.forAs?s:t.expr?function(e,t="datum"){return`${t}[${u(r(e).join("."))}]`}(s,t.expr)+l:te(s)+l}function qi(e){switch(e.type){case"nominal":case"ordinal":case"geojson":return!0;case"quantitative":return!!e.bin;case"temporal":return!1}throw new Error(Ht.invalidFieldType(e.type))}function Ii(e){return!qi(e)}const Hi=(e,t)=>{switch(t.fieldTitle){case"plain":return e.field;case"functional":return function(e){const{aggregate:t,bin:n,timeUnit:i,field:r}=e;if(ze(t))return`${r} for argmax(${t.argmax})`;if(_e(t))return`${r} for argmin(${t.argmin})`;const o=t||i||cr(n)&&"bin";return o?o.toUpperCase()+"("+r+")":r}(e);default:return function(e,t){const{field:n,bin:i,timeUnit:r,aggregate:o}=e;if("count"===o)return t.countTitle;if(cr(i))return`${n} (binned)`;if(r){return`${n} (${fn(r).join("-")})`}return o?ze(o)?`${n} for max ${o.argmax}`:_e(o)?`${n} for min ${o.argmin}`:`${K(o)} of ${n}`:n}(e,t)}};let Gi=Hi;function Yi(e){Gi=e}function Vi(e,t,{allowDisabling:n,includeDefault:i=!0}){var r,o;const s=(null!=(r=Ji(e))?r:{}).title,a=i?Qi(e,t):void 0;return n?oe(s,e.title,a):null!=(o=null!=s?s:e.title)?o:a}function Ji(e){return Ri(e)&&e.axis?e.axis:(t=e)&&t.legend&&e.legend?e.legend:function(e){return!!e&&!!e.header}(e)&&e.header?e.header:void 0;var t}function Qi(e,t){return Gi(e,t)}function Xi(e){var t;if(Li(e)&&e.format)return e.format;return(null!=(t=Ji(e))?t:{}).format}function Zi(e){return zi(e)?e:_i(e)?e.condition:void 0}function Ki(e){return zi(e)?e:_i(e)?e.condition:void 0}function er(e,t){if(a(e)||F(e)||w(e)){const n=a(e)?"string":F(e)?"number":"boolean";return Qt(Ht.primitiveChannelDef(t,n,e)),{value:e}}return zi(e)?tr(e,t):_i(e)?Object.assign(Object.assign({},e),{condition:tr(e.condition,t)}):e}function tr(e,t){const{aggregate:n,timeUnit:i,bin:r,field:o}=e,s=Object.assign({},e);if(!n||Te(n)||ze(n)||_e(n)||(Qt(Ht.invalidAggregate(n)),delete s.aggregate),i&&(s.timeUnit=mn(i)),o&&(s.field=`${o}`),cr(r)&&(s.bin=nr(r,t)),lr(r)&&!U(Nt,t)&&Qt(`Channel ${t} should not be used with "binned" bin`),Ti(s)){const{type:e}=s,t=function(e){if(e)switch(e=e.toLowerCase()){case"q":case kn:return"quantitative";case"t":case Bn:return"temporal";case"o":case $n:return"ordinal";case"n":case Nn:return"nominal";case _n:return"geojson"}}(e);e!==t&&(s.type=t),"quantitative"!==e&&Me(n)&&(Qt(Ht.invalidFieldTypeForCountAggregate(e,n)),s.type="quantitative")}else if(!Dt(t)){const e=function(e,t){if(e.timeUnit)return"temporal";if(cr(e.bin))return"quantitative";switch(It(t)){case"continuous":return"quantitative";case"discrete":case"flexible":return"nominal";default:return"quantitative"}}(s,t);Qt(Ht.missingFieldType(t,e)),s.type=e}if(Ti(s)){const{compatible:e,warning:n}=function(e,t){const n=e.type;if("geojson"===n&&"shape"!==t)return{compatible:!1,warning:`Channel ${t} should not be used with a geojson data.`};switch(t){case"row":case"column":case"facet":return Ii(e)?{compatible:!1,warning:Ht.facetChannelShouldBeDiscrete(t)}:ir;case"x":case"y":case"color":case"fill":case"stroke":case"text":case"detail":case"key":case"tooltip":case"href":case"url":return ir;case"longitude":case"longitude2":case"latitude":case"latitude2":return n!==kn?{compatible:!1,warning:`Channel ${t} should be used with a quantitative field only, not ${e.type} field.`}:ir;case"opacity":case"fillOpacity":case"strokeOpacity":case"strokeWidth":case"size":case"x2":case"y2":return"nominal"!==n||e.sort?ir:{compatible:!1,warning:`Channel ${t} should not be used with an unsorted discrete field.`};case"shape":return U(["ordinal","nominal","geojson"],e.type)?ir:{compatible:!1,warning:"Shape channel should be used with only either discrete or geojson data."};case"order":return"nominal"!==e.type||"sort"in e?ir:{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}}throw new Error("channelCompatability not implemented for channel "+t)}(s,t);e||Qt(n)}if(ki(s)&&a(s.sort)){const{sort:e}=s;if(wi(e))return Object.assign(Object.assign({},s),{sort:{encoding:e}});const t=e.substr(1);if("-"===e.charAt(0)&&wi(t))return Object.assign(Object.assign({},s),{sort:{encoding:t,order:"descending"}})}return s}function nr(e,t){return w(e)?{maxbins:pr(t)}:"binned"===e?{binned:!0}:e.maxbins||e.step?e:Object.assign(Object.assign({},e),{maxbins:pr(t)})}const ir={compatible:!0};function rr(e){const t=Ji(e),n=t&&t.formatType||Li(e)&&e.formatType;return"time"===n||!n&&function(e){return"temporal"===e.type||!!e.timeUnit}(e)}function or(e,{timeUnit:t,type:n,time:i,undefinedIfExprNotRequired:r}){let o;var s;return Zt(e)?o=rn(e,!0):(a(e)||F(e))&&(t||"temporal"===n)&&(o=function(e){return!!sn[e]}(t)?rn({[t]:e},!0):function(e){return!!un[e]}(t)?or(e,{timeUnit:(s=t,s.substr(3))}):`datetime(${JSON.stringify(e)})`),o?i?`time(${o})`:o:r?void 0:JSON.stringify(e)}function sr(e,t){const{timeUnit:n,type:i}=e;return t.map(e=>{const t=or(e,{timeUnit:n,type:i,undefinedIfExprNotRequired:!0});return void 0!==t?{signal:t}:e})}function ar(e,t){return cr(e.bin)?Rt(t)&&U(["ordinal","nominal"],e.type):(console.warn("Only use this method with binned field defs"),!1)}function ur(e){return w(e)&&(e=nr(e,void 0)),"bin"+Y(e).map(t=>fr(e[t])?Q(`_${t}_${Object.entries(e[t])}`):Q(`_${t}_${e[t]}`)).join("")}function cr(e){return!0===e||dr(e)&&!e.binned}function lr(e){return"binned"===e||dr(e)&&!0===e.binned}function dr(e){return s(e)}function fr(e){var t;return null===(t=e)||void 0===t?void 0:t.selection}function pr(e){switch(e){case Le:case We:case nt:case Ze:case Ke:case et:case st:case it:case rt:case ot:case tt:return 6;default:return 10}}function gr(e,t){const n=e&&e[t];return!!n&&(o(n)?R(n,e=>!!e.field):zi(n)||_i(n))}function hr(e){return R(At,t=>{if(gr(e,t)){const n=e[t];if(o(n))return R(n,e=>!!e.aggregate);{const e=Zi(n);return e&&!!e.aggregate}}return!1})}function mr(e,t){const n=[],i=[],r=[],o=[],s={};return yr(e,(a,u)=>{if(zi(a)){const{field:c,aggregate:l,timeUnit:d,bin:f}=a,p=$e(a,["field","aggregate","timeUnit","bin"]);if(l||d||f){const e=Ji(a),g=e&&e.title;let h=Wi(a,{forAs:!0});const m=Object.assign(Object.assign(Object.assign({},g?[]:{title:Vi(a,t,{allowDisabling:!0})}),p),{field:h}),b="x"===u||"y"===u;if(l){let e;if(ze(l)?(e="argmax",h=Wi({op:"argmax",field:l.argmax},{forAs:!0}),m.field=`${h}.${c}`):_e(l)?(e="argmin",h=Wi({op:"argmin",field:l.argmin},{forAs:!0}),m.field=`${h}.${c}`):"boxplot"!==l&&"errorbar"!==l&&"errorband"!==l&&(e=l),e){const t={op:e,as:h};c&&(t.field=c),o.push(t)}}else if(n.push(h),Ti(a)&&cr(f)){if(i.push({bin:f,field:c,as:h}),n.push(Wi(a,{binSuffix:"end"})),ar(a,u)&&n.push(Wi(a,{binSuffix:"range"})),b){const e={field:h+"_end"};s[u+"2"]=e}m.bin="binned",Dt(u)||(m.type="quantitative")}else if(d){r.push({timeUnit:d,field:c,as:h});const e=Ti(a)&&a.type!==Bn&&"time";e&&("text"===u||"tooltip"===u?m.formatType=e:!function(e){return!!kt[e]}(u)?b&&(m.axis=Object.assign({formatType:e},m.axis)):m.legend=Object.assign({formatType:e},m.legend))}s[u]=m}else n.push(c),s[u]=e[u]}else s[u]=e[u]}),{bins:i,timeUnits:r,aggregate:o,groupby:n,encoding:s}}function br(e,t){const n=t.type;return Y(e).reduce((i,r)=>{var s;if(!Ct(r))return Qt(Ht.invalidEncodingChannel(r)),i;if(!function(e,t,n){const i=Lt(t,n);if(!i)return!1;if("binned"===i){const n=e["x2"===t?"x":"y"];return!!(zi(n)&&zi(e[t])&&lr(n.bin))}return!0}(e,r,n))return Qt(Ht.incompatibleChannel(r,n)),i;if("size"===r&&"line"===n){if(null===(s=Ki(e[r]))||void 0===s?void 0:s.aggregate)return Qt(Ht.LINE_WITH_VARYING_SIZE),i}if("color"===r&&(t.filled?"fill"in e:"stroke"in e))return Qt(Ht.droppingColor("encoding",{fill:"fill"in e,stroke:"stroke"in e})),i;const a=e[r];if("detail"===r||"order"===r&&!o(a)&&!Mi(a)||"tooltip"===r&&o(a))a&&(i[r]=(o(a)?a:[a]).reduce((e,t)=>(zi(t)?e.push(tr(t,r)):Qt(Ht.emptyFieldDef(t,r)),e),[]));else{if("tooltip"===r&&null===a)i[r]=null;else if(!zi(a)&&!Mi(a)&&!Ni(a))return Qt(Ht.emptyFieldDef(a,r)),i;i[r]=er(a,r)}return i},{})}function vr(e){const t=[];for(const n of Y(e))if(gr(e,n)){const i=e[n],r=o(i)?i:[i];for(const e of r)zi(e)?t.push(e):_i(e)&&t.push(e.condition)}return t}function yr(e,t,n){if(e)for(const i of Y(e)){const r=e[i];o(r)?r.forEach(e=>{t.call(n,e,i)}):t.call(n,r,i)}}function xr(e,t,n,i){return e?Y(e).reduce((n,r)=>{const s=e[r];return o(s)?s.reduce((e,n)=>t.call(i,e,n,r),n):t.call(i,n,s,r)},n):n}function Ar(e,t){return Y(t).reduce((n,i)=>{switch(i){case"x":case"y":case"href":case"url":case"x2":case"y2":case"latitude":case"longitude":case"latitude2":case"longitude2":case"text":case"shape":case"tooltip":return n;case"order":if("line"===e||"trail"===e)return n;case"detail":case"key":{const e=t[i];return(o(e)||zi(e))&&(o(e)?e:[e]).forEach(e=>{e.aggregate||n.push(Wi(e,{}))}),n}case"size":if("trail"===e)return n;case"color":case"fill":case"stroke":case"opacity":case"fillOpacity":case"strokeOpacity":case"strokeWidth":{const e=Ki(t[i]);return e&&!e.aggregate&&n.push(Wi(e,{})),n}}},[])}function Or(e,t,n,i=!0){if("tooltip"in n)return{tooltip:n.tooltip};return{tooltip:[...e.map(({fieldPrefix:e,titlePrefix:n})=>({field:e+t.field,type:t.type,title:n+(i?" of "+t.field:"")})),...vr(n)]}}function wr(e){const{axis:t,title:n,field:i}=e;return t&&void 0!==t.title?void 0:oe(n,i)}function Fr(e,t,n,i,r){const{scale:o,axis:s}=n;return({partName:u,mark:c,positionPrefix:l,endPositionPrefix:d,extraEncoding:f={}})=>{const p=wr(n);return Cr(e,u,r,{mark:c,encoding:Object.assign(Object.assign(Object.assign({[t]:Object.assign(Object.assign(Object.assign({field:l+"_"+n.field,type:n.type},void 0!==p?{title:p}:{}),void 0!==o?{scale:o}:{}),void 0!==s?{axis:s}:{})},a(d)?{[t+"2"]:{field:d+"_"+n.field,type:n.type}}:{}),i),f)})}}function Cr(e,t,n,i){const{clip:r,color:o,opacity:s}=e,a=e.type;return e[t]||void 0===e[t]&&n[t]?[Object.assign(Object.assign({},i),{mark:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},n[t]),r?{clip:r}:{}),o?{color:o}:{}),s?{opacity:s}:{}),Fe(i.mark)?i.mark:{type:i.mark}),{style:`${a}-${t}`}),w(e[t])?{}:e[t])})]:[]}function jr(e,t,n){const{encoding:i}=e,r="vertical"===t?"y":"x",o=i[r],s=i[r+"2"],a=i[r+"Error"],u=i[r+"Error2"];return{continuousAxisChannelDef:Dr(o,n),continuousAxisChannelDef2:Dr(s,n),continuousAxisChannelDefError:Dr(a,n),continuousAxisChannelDefError2:Dr(u,n),continuousAxis:r}}function Dr(e,t){if(e&&e.aggregate){const{aggregate:n}=e,i=$e(e,["aggregate"]);return n!==t&&Qt(Ht.errorBarContinuousAxisHasCustomizedAggregate(n,t)),i}return e}function Er(e,t){const{mark:n,encoding:i}=e;if(zi(i.x)&&Ii(i.x)){if(zi(i.y)&&Ii(i.y)){if(void 0===i.x.aggregate&&i.y.aggregate===t)return"vertical";if(void 0===i.y.aggregate&&i.x.aggregate===t)return"horizontal";if(i.x.aggregate===t&&i.y.aggregate===t)throw new Error("Both x and y cannot have aggregate");return Fe(n)&&n.orient?n.orient:"vertical"}return"horizontal"}if(zi(i.y)&&Ii(i.y))return"vertical";throw new Error("Need a valid continuous axis for "+t+"s")}const Sr="boxplot",kr=Y({box:1,median:1,outliers:1,rule:1,ticks:1}),$r=new ke(Sr,Nr);function Br(e){return F(e)?"tukey":e}function Nr(e,{config:t}){var n,i;const{mark:r,encoding:a,selection:u,projection:c}=e,l=$e(e,["mark","encoding","selection","projection"]),d=Fe(r)?r:{type:r};u&&Qt(Ht.selectionNotSupported("boxplot"));const f=null!=(n=d.extent)?n:t.boxplot.extent,p=oe(d.size,t.boxplot.size),g=Br(f),{transform:h,continuousAxisChannelDef:m,continuousAxis:b,groupby:v,aggregate:y,encodingWithoutContinuousAxis:x,ticksOrient:A,boxOrient:O,customTooltipWithoutAggregatedField:w}=function(e,t,n){const i=Er(e,Sr),{continuousAxisChannelDef:r,continuousAxis:s}=jr(e,i,Sr),a=r.field,u=Br(t),c=[..._r(a),{op:"median",field:a,as:"mid_box_"+a},{op:"min",field:a,as:("min-max"===u?"lower_whisker_":"min_")+a},{op:"max",field:a,as:("min-max"===u?"upper_whisker_":"max_")+a}],l="min-max"===u||"tukey"===u?[]:[{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}],d=e.encoding,f=s,p=(d[f],$e(d,["symbol"==typeof f?f:f+""])),{customTooltipWithoutAggregatedField:g,filteredEncoding:h}=function(e){const{tooltip:t}=e,n=$e(e,["tooltip"]);if(!t)return{filteredEncoding:e};let i,r;return o(t)?(t.forEach(e=>{e.aggregate?(i||(i=[]),i.push(e)):(r||(r=[]),r.push(e))}),i&&(n.tooltip=i)):t.aggregate?n.tooltip=t:r=t,o(r)&&1===r.length&&(r=r[0]),{customTooltipWithoutAggregatedField:r,filteredEncoding:n}}(p),{bins:m,timeUnits:b,aggregate:v,groupby:y,encoding:x}=mr(h,n),A="vertical"===i?"horizontal":"vertical",O=i;return{transform:[...m,...b,{aggregate:[...v,...c],groupby:y},...l],groupby:y,aggregate:v,continuousAxisChannelDef:r,continuousAxis:s,encodingWithoutContinuousAxis:x,ticksOrient:A,boxOrient:O,customTooltipWithoutAggregatedField:g}}(e,f,t),{color:F,size:C}=x,j=$e(x,["color","size"]),D=e=>Fr(d,b,m,e,t.boxplot),E=D(j),S=D(x),k=D(Object.assign(Object.assign({},j),C?{size:C}:{})),$=Or([{fieldPrefix:"min-max"===g?"upper_whisker_":"max_",titlePrefix:"Max"},{fieldPrefix:"upper_box_",titlePrefix:"Q3"},{fieldPrefix:"mid_box_",titlePrefix:"Median"},{fieldPrefix:"lower_box_",titlePrefix:"Q1"},{fieldPrefix:"min-max"===g?"lower_whisker_":"min_",titlePrefix:"Min"}],m,x),B={type:"tick",color:"black",opacity:1,orient:A,invalid:null},N="min-max"===g?$:Or([{fieldPrefix:"upper_whisker_",titlePrefix:"Upper Whisker"},{fieldPrefix:"lower_whisker_",titlePrefix:"Lower Whisker"}],m,x),_=[...E({partName:"rule",mark:{type:"rule",invalid:null},positionPrefix:"lower_whisker",endPositionPrefix:"lower_box",extraEncoding:N}),...E({partName:"rule",mark:{type:"rule",invalid:null},positionPrefix:"upper_box",endPositionPrefix:"upper_whisker",extraEncoding:N}),...E({partName:"ticks",mark:B,positionPrefix:"lower_whisker",extraEncoding:N}),...E({partName:"ticks",mark:B,positionPrefix:"upper_whisker",extraEncoding:N})],z=[..."tukey"!==g?_:[],...S({partName:"box",mark:Object.assign(Object.assign({type:"bar"},p?{size:p}:{}),{orient:O,invalid:null}),positionPrefix:"lower_box",endPositionPrefix:"upper_box",extraEncoding:$}),...k({partName:"median",mark:Object.assign(Object.assign(Object.assign({type:"tick",invalid:null},s(t.boxplot.median)&&t.boxplot.median.color?{color:t.boxplot.median.color}:{}),p?{size:p}:{}),{orient:A}),positionPrefix:"mid_box",extraEncoding:$})];let T;if("min-max"!==g){const e=`datum["lower_box_${m.field}"]`,n=`datum["upper_box_${m.field}"]`,i=`(${n} - ${e})`,r=`${e} - ${f} * ${i}`,o=`${n} + ${f} * ${i}`,s=`datum["${m.field}"]`,a={joinaggregate:_r(m.field),groupby:v};let u=void 0;"tukey"===g&&(u={transform:[{filter:`(${r} <= ${s}) && (${s} <= ${o})`},{aggregate:[{op:"min",field:m.field,as:"lower_whisker_"+m.field},{op:"max",field:m.field,as:"upper_whisker_"+m.field},{op:"min",field:"lower_box_"+m.field,as:"lower_box_"+m.field},{op:"max",field:"upper_box_"+m.field,as:"upper_box_"+m.field},...y],groupby:v}],layer:_});const c=$e(j,["tooltip"]),{scale:l,axis:p}=m,h=wr(m),x=Cr(d,"outliers",t.boxplot,{transform:[{filter:`(${s} < ${r}) || (${s} > ${o})`}],mark:"point",encoding:Object.assign(Object.assign({[b]:Object.assign(Object.assign(Object.assign({field:m.field,type:m.type},void 0!==h?{title:h}:{}),void 0!==l?{scale:l}:{}),void 0!==p?{axis:p}:{})},c),w?{tooltip:w}:{})})[0];x&&u?T={transform:[a],layer:[x,u]}:x?(T=x,T.transform.unshift(a)):u&&(T=u,T.transform.unshift(a))}return T?Object.assign(Object.assign({},l),{layer:[T,{transform:h,layer:z}]}):Object.assign(Object.assign({},l),{transform:(i=l.transform,null!=i?i:[]).concat(h),layer:z})}function _r(e){return[{op:"q1",field:e,as:"lower_box_"+e},{op:"q3",field:e,as:"upper_box_"+e}]}const zr="errorbar",Tr=Y({ticks:1,rule:1}),Pr=new ke(zr,Mr);function Mr(e,{config:t}){const{transform:n,continuousAxisChannelDef:i,continuousAxis:r,encodingWithoutContinuousAxis:o,ticksOrient:s,markDef:a,outerSpec:u,tooltipEncoding:c}=Rr(e,zr,t),l=Fr(a,r,i,o,t.errorbar),d={type:"tick",orient:s};return Object.assign(Object.assign({},u),{transform:n,layer:[...l({partName:"ticks",mark:d,positionPrefix:"lower",extraEncoding:c}),...l({partName:"ticks",mark:d,positionPrefix:"upper",extraEncoding:c}),...l({partName:"rule",mark:"rule",positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:c})]})}function Ur(e,t){const{encoding:n}=e;if(function(e){return(zi(e.x)||zi(e.y))&&!zi(e.x2)&&!zi(e.y2)&&!zi(e.xError)&&!zi(e.xError2)&&!zi(e.yError)&&!zi(e.yError2)}(n))return{orient:Er(e,t),inputType:"raw"};const i=function(e){return zi(e.x2)||zi(e.y2)}(n),r=function(e){return zi(e.xError)||zi(e.xError2)||zi(e.yError)||zi(e.yError2)}(n),o=n.x,s=n.y;if(i){if(r)throw new Error(t+" cannot be both type aggregated-upper-lower and aggregated-error");const e=n.x2,i=n.y2;if(zi(e)&&zi(i))throw new Error(t+" cannot have both x2 and y2");if(zi(e)){if(zi(o)&&Ii(o))return{orient:"horizontal",inputType:"aggregated-upper-lower"};throw new Error("Both x and x2 have to be quantitative in "+t)}if(zi(i)){if(zi(s)&&Ii(s))return{orient:"vertical",inputType:"aggregated-upper-lower"};throw new Error("Both y and y2 have to be quantitative in "+t)}throw new Error("No ranged axis")}{const e=n.xError,i=n.xError2,r=n.yError,a=n.yError2;if(zi(i)&&!zi(e))throw new Error(t+" cannot have xError2 without xError");if(zi(a)&&!zi(r))throw new Error(t+" cannot have yError2 without yError");if(zi(e)&&zi(r))throw new Error(t+" cannot have both xError and yError with both are quantiative");if(zi(e)){if(zi(o)&&Ii(o))return{orient:"horizontal",inputType:"aggregated-error"};throw new Error("All x, xError, and xError2 (if exist) have to be quantitative")}if(zi(r)){if(zi(s)&&Ii(s))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 Rr(e,t,n){var i;const{mark:r,encoding:o,selection:s,projection:a}=e,u=$e(e,["mark","encoding","selection","projection"]),c=Fe(r)?r:{type:r};s&&Qt(Ht.selectionNotSupported(t));const{orient:l,inputType:d}=Ur(e,t),{continuousAxisChannelDef:f,continuousAxisChannelDef2:p,continuousAxisChannelDefError:g,continuousAxisChannelDefError2:h,continuousAxis:m}=jr(e,l,t),{errorBarSpecificAggregate:b,postAggregateCalculates:v,tooltipSummary:y,tooltipTitleWithFieldName:x}=function(e,t,n,i,r,o,s,a){let u=[],c=[];const l=t.field;let d,f=!1;if("raw"===o){const t=e.center?e.center:e.extent?"iqr"===e.extent?"median":"mean":a.errorbar.center,n=e.extent?e.extent:"mean"===t?"stderr":"iqr";if("median"===t!=("iqr"===n)&&Qt(Ht.errorBarCenterIsUsedWithWrongExtent(t,n,s)),"stderr"===n||"stdev"===n)u=[{op:n,field:l,as:"extent_"+l},{op:t,field:l,as:"center_"+l}],c=[{calculate:`datum["center_${l}"] + datum["extent_${l}"]`,as:"upper_"+l},{calculate:`datum["center_${l}"] - datum["extent_${l}"]`,as:"lower_"+l}],d=[{fieldPrefix:"center_",titlePrefix:K(t)},{fieldPrefix:"upper_",titlePrefix:Lr(t,n,"+")},{fieldPrefix:"lower_",titlePrefix:Lr(t,n,"-")}],f=!0;else{let t,i,r;e.center&&e.extent&&Qt(Ht.errorBarCenterIsNotNeeded(e.extent,s)),"ci"===n?(t="mean",i="ci0",r="ci1"):(t="median",i="q1",r="q3"),u=[{op:i,field:l,as:"lower_"+l},{op:r,field:l,as:"upper_"+l},{op:t,field:l,as:"center_"+l}],d=[{fieldPrefix:"upper_",titlePrefix:Vi({field:l,aggregate:r,type:"quantitative"},a,{allowDisabling:!1})},{fieldPrefix:"lower_",titlePrefix:Vi({field:l,aggregate:i,type:"quantitative"},a,{allowDisabling:!1})},{fieldPrefix:"center_",titlePrefix:Vi({field:l,aggregate:t,type:"quantitative"},a,{allowDisabling:!1})}]}}else{(e.center||e.extent)&&Qt(Ht.errorBarCenterAndExtentAreNotNeeded(e.center,e.extent)),"aggregated-upper-lower"===o?(d=[],c=[{calculate:`datum["${n.field}"]`,as:"upper_"+l},{calculate:`datum["${l}"]`,as:"lower_"+l}]):"aggregated-error"===o&&(d=[{fieldPrefix:"",titlePrefix:l}],c=[{calculate:`datum["${l}"] + datum["${i.field}"]`,as:"upper_"+l}],r?c.push({calculate:`datum["${l}"] + datum["${r.field}"]`,as:"lower_"+l}):c.push({calculate:`datum["${l}"] - datum["${i.field}"]`,as:"lower_"+l}));for(const e of c)d.push({fieldPrefix:e.as.substring(0,6),titlePrefix:ne(ne(e.calculate,'datum["',""),'"]',"")})}return{postAggregateCalculates:c,errorBarSpecificAggregate:u,tooltipSummary:d,tooltipTitleWithFieldName:f}}(c,f,p,g,h,d,t,n),A=m,O=(o[A],"x"===m?"x2":"y2"),w=(o[O],"x"===m?"xError":"yError"),F=(o[w],"x"===m?"xError2":"yError2"),C=(o[F],$e(o,["symbol"==typeof A?A:A+"","symbol"==typeof O?O:O+"","symbol"==typeof w?w:w+"","symbol"==typeof F?F:F+""])),{bins:j,timeUnits:D,aggregate:E,groupby:S,encoding:k}=mr(C,n),$=[...E,...b],B="raw"!==d?[]:S,N=Or(y,f,k,x);return{transform:[...(i=u.transform,null!=i?i:[]),...j,...D,...0===$.length?[]:[{aggregate:$,groupby:B}],...v],groupby:B,continuousAxisChannelDef:f,continuousAxis:m,encodingWithoutContinuousAxis:k,ticksOrient:"vertical"===l?"horizontal":"vertical",markDef:c,outerSpec:u,tooltipEncoding:N}}function Lr(e,t,n){return K(e)+" "+n+" "+t}const Wr="errorband",qr=Y({band:1,borders:1}),Ir=new ke(Wr,Hr);function Hr(e,{config:t}){const{transform:n,continuousAxisChannelDef:i,continuousAxis:r,encodingWithoutContinuousAxis:o,markDef:s,outerSpec:a,tooltipEncoding:u}=Rr(e,Wr,t),c=s,l=Fr(c,r,i,o,t.errorband),d=void 0!==e.encoding.x&&void 0!==e.encoding.y;let f={type:d?"area":"rect"},p={type:d?"line":"rule"};const g=Object.assign(Object.assign({},c.interpolate?{interpolate:c.interpolate}:{}),c.tension&&c.interpolate?{interpolate:c.tension}:{});return d?(f=Object.assign(Object.assign({},f),g),p=Object.assign(Object.assign({},p),g)):c.interpolate?Qt(Ht.errorBand1DNotSupport("interpolate")):c.tension&&Qt(Ht.errorBand1DNotSupport("tension")),Object.assign(Object.assign({},a),{transform:n,layer:[...l({partName:"band",mark:f,positionPrefix:"lower",endPositionPrefix:"upper",extraEncoding:u}),...l({partName:"borders",mark:p,positionPrefix:"lower",extraEncoding:u}),...l({partName:"borders",mark:p,positionPrefix:"upper",extraEncoding:u})]})}const Gr={};function Yr(e,t,n){const i=new ke(e,t);Gr[e]={normalizer:i,parts:n}}Yr(Sr,Nr,kr),Yr(zr,Mr,Tr),Yr(Wr,Hr,qr);const Vr=["gradientHorizontalMaxLength","gradientHorizontalMinLength","gradientVerticalMaxLength","gradientVerticalMinLength","unselectedOpacity"],Jr="_vgsid_",Qr={single:{on:"click",fields:[Jr],resolve:"global",empty:"all",clear:"dblclick"},multi:{on:"click",fields:[Jr],toggle:"event.shiftKey",resolve:"global",empty:"all",clear:"dblclick"},interval:{on:"[mousedown, window:mouseup] > window:mousemove!",encodings:["x","y"],translate:"[mousedown, window:mouseup] > window:mousemove!",zoom:"wheel!",mark:{fill:"#333",fillOpacity:.125,stroke:"white"},resolve:"global",clear:"dblclick"}};function Xr(e){return!(!e||"legend"!==e&&!e.legend)}function Zr(e){return Xr(e)&&s(e)}function Kr(e){return void 0!==e.concat}function eo(e){return void 0!==e.vconcat}function to(e){return void 0!==e.hconcat}function no(e){return void 0!==e.repeat}function io(e){return s(e)&&void 0!==e.step}const ro=Y({align:1,bounds:1,center:1,columns:1,spacing:1});function oo(e,t){var n;return null!=(n=e[t])?n:e["width"===t?"continuousWidth":"continuousHeight"]}function so(e,t){const n=ao(e,t);return io(n)?n.step:uo}function ao(e,t){var n;return oe(null!=(n=e[t])?n:e["width"===t?"discreteWidth":"discreteHeight"],{step:e.step})}const uo=20,co={background:"white",padding:5,timeFormat:"%b %d, %Y",countTitle:"Count of Records",view:{continuousWidth:200,continuousHeight:200,step:uo},mark:{color:"#4c78a8",invalid:"filter",timeUnitBand:1},area:{},bar:De,circle:{},geoshape:{},image:{},line:{},point:{},rect:Ee,rule:{color:"black"},square:{},text:{color:"black"},tick:{thickness:1},trail:{},boxplot:{size:14,extent:1.5,box:{},median:{color:"white"},outliers:{},rule:{},ticks:null},errorbar:{center:"mean",rule:!0,ticks:!1},errorband:{band:{opacity:.3},borders:!1},scale:{pointPadding:.5,barBandPaddingInner:.1,rectBandPaddingInner:0,minBandSize:2,minFontSize:8,maxFontSize:40,minOpacity:.3,maxOpacity:.8,minSize:9,minStrokeWidth:1,maxStrokeWidth:4,quantileCount:4,quantizeCount:4},projection:{},axis:{},axisX:{},axisY:{},axisLeft:{},axisRight:{},axisTop:{},axisBottom:{},axisBand:{},legend:{gradientHorizontalMaxLength:200,gradientHorizontalMinLength:100,gradientVerticalMaxLength:200,gradientVerticalMinLength:64,unselectedOpacity:.35},header:{titlePadding:10,labelPadding:10},headerColumn:{},headerRow:{},headerFacet:{},selection:Qr,style:{},title:{},facet:{spacing:20},repeat:{spacing:20},concat:{spacing:20}};function lo(e){return b({},co,e)}const fo=["view",...we],po=["background","padding","facet","concat","repeat","numberFormat","timeFormat","countTitle","header","scale","selection","overlay"],go=Object.assign({view:["continuousWidth","continuousHeight","discreteWidth","discreteHeight","step"]},{area:["line","point"],bar:["binSpacing","continuousBandSize","discreteBandSize"],rect:["binSpacing","continuousBandSize","discreteBandSize"],line:["point"],tick:["bandSize","thickness"]});function ho(e){e=N(e);for(const t of po)delete e[t];if(e.legend)for(const t of Vr)delete e.legend[t];if(e.mark)for(const t of je)delete e.mark[t];for(const t of fo){for(const n of je)delete e[t][n];const n=go[t];if(n)for(const i of n)delete e[t][i];mo(e,t)}for(const t of Y(Gr))delete e[t];mo(e,"title","group-title");for(const t in e)s(e[t])&&0===Y(e[t]).length&&delete e[t];return Y(e).length>0?e:void 0}function mo(e,t,n,i){const r="title"===t?ri(e.title).mark:i?e[t][i]:e[t];"view"===t&&(n="cell");const o=Object.assign(Object.assign({},r),e.style[t]);Y(o).length>0&&(e.style[null!=n?n:t]=o),i||delete e[t]}function bo(e){return void 0!==e.layer}class vo{map(e,t){return Ei(e)?this.mapFacet(e,t):no(e)?this.mapRepeat(e,t):to(e)?this.mapHConcat(e,t):eo(e)?this.mapVConcat(e,t):Kr(e)?this.mapConcat(e,t):this.mapLayerOrUnit(e,t)}mapLayerOrUnit(e,t){if(bo(e))return this.mapLayer(e,t);if(Se(e))return this.mapUnit(e,t);throw new Error(Ht.invalidSpec(e))}mapLayer(e,t){return Object.assign(Object.assign({},e),{layer:e.layer.map(e=>this.mapLayerOrUnit(e,t))})}mapHConcat(e,t){return Object.assign(Object.assign({},e),{hconcat:e.hconcat.map(e=>this.map(e,t))})}mapVConcat(e,t){return Object.assign(Object.assign({},e),{vconcat:e.vconcat.map(e=>this.map(e,t))})}mapConcat(e,t){const{concat:n}=e,i=$e(e,["concat"]);return Object.assign(Object.assign({},i),{concat:n.map(e=>this.map(e,t))})}mapFacet(e,t){return Object.assign(Object.assign({},e),{spec:this.map(e.spec,t)})}mapRepeat(e,t){return Object.assign(Object.assign({},e),{spec:this.map(e.spec,t)})}}const yo={zero:1,center:1,normalize:1};const xo=[ce,ue,ge,fe,ve,ye,de,he,me],Ao=[ce,ue];function Oo(e,t,n={}){const i=Fe(e)?e.type:e;if(!U(xo,i))return null;const r=function(e){const t=e.x,n=e.y;if(zi(t)&&zi(n))if("quantitative"===t.type&&"quantitative"===n.type){if(t.stack)return"x";if(n.stack)return"y";if(!!t.aggregate!=!!n.aggregate)return t.aggregate?"x":"y"}else{if("quantitative"===t.type)return"x";if("quantitative"===n.type)return"y"}else{if(zi(t)&&"quantitative"===t.type)return"x";if(zi(n)&&"quantitative"===n.type)return"y"}}(t);if(!r)return null;const s=t[r],a=Pi(s)?Wi(s,{}):void 0,u="x"===r?"y":"x",c=t[u],l=Pi(c)?Wi(c,{}):void 0,d=$t.reduce((e,n)=>{if("tooltip"!==n&&gr(t,n)){const i=t[n];(o(i)?i:[i]).forEach(t=>{const i=Ki(t);if(i.aggregate)return;const r=Pi(i)?Wi(i,{}):void 0;(!r||r!==l&&r!==a)&&e.push({channel:n,fieldDef:i})})}return e},[]);let f;if(void 0!==s.stack?f=w(s.stack)?s.stack?"zero":null:s.stack:d.length>0&&U(Ao,i)&&(f="zero"),!f||!yo[f])return null;if(hr(t)&&0===d.length)return null;if(s.scale&&s.scale.type&&s.scale.type!==zn.LINEAR){if(n.disallowNonLinearStack)return null;Qt(Ht.cannotStackNonLinearScale(s.scale.type))}return gr(t,r===Ie?Ge:Ye)?(void 0!==s.stack&&Qt(Ht.cannotStackRangedMark(r)),null):(s.aggregate&&!U(Ue,s.aggregate)&&Qt(Ht.stackNonSummativeAggregate(s.aggregate)),{groupbyChannel:c?u:void 0,fieldChannel:r,impute:null!==s.impute&&Ae(i),stackBy:d,offset:f})}function wo(e){const t=$e(e,["point","line"]);return Y(t).length>1?t:t.type}function Fo(e){for(const t of["line","area","rule","trail"])e[t]&&(e=Object.assign(Object.assign({},e),{[t]:z(e[t],["point","line"])}));return e}function Co(e,t={},n){return"transparent"===e.point?{opacity:0}:e.point?s(e.point)?e.point:{}:void 0!==e.point?null:t.point||n.shape?s(t.point)?t.point:{}:void 0}function jo(e,t={}){return e.line?!0===e.line?{}:e.line:void 0!==e.line?null:t.line?!0===t.line?{}:t.line:void 0}class Do{constructor(){this.name="path-overlay"}hasMatchingType(e,t){if(Se(e)){const{mark:n,encoding:i}=e,r=Fe(n)?n:{type:n};switch(r.type){case"line":case"rule":case"trail":return!!Co(r,t[r.type],i);case"area":return!!Co(r,t[r.type],i)||!!jo(r,t[r.type])}}return!1}run(e,t,n){const{config:i}=t,{selection:r,projection:o,encoding:s,mark:a}=e,u=$e(e,["selection","projection","encoding","mark"]),c=Fe(a)?a:{type:a},l=Co(c,i[c.type],s),d="area"===c.type&&jo(c,i[c.type]),f=[Object.assign(Object.assign({},r?{selection:r}:{}),{mark:wo(Object.assign(Object.assign({},c),"area"===c.type?{opacity:.7}:{})),encoding:z(s,["shape"])})],p=Oo(c,s);let g=s;if(p){const{fieldChannel:e,offset:t}=p;g=Object.assign(Object.assign({},s),{[e]:Object.assign(Object.assign({},s[e]),t?{stack:t}:{})})}return d&&f.push(Object.assign(Object.assign({},o?{projection:o}:{}),{mark:Object.assign(Object.assign({type:"line"},_(c,["clip","interpolate","tension","tooltip"])),d),encoding:g})),l&&f.push(Object.assign(Object.assign({},o?{projection:o}:{}),{mark:Object.assign(Object.assign({type:"point",opacity:1,filled:!0},_(c,["clip","tooltip"])),l),encoding:g})),n(Object.assign(Object.assign({},u),{layer:f}),Object.assign(Object.assign({},t),{config:Fo(i)}))}}class Eo{constructor(){this.name="RangeStep"}hasMatchingType(e){var t,n;if(Se(e)&&e.encoding)for(const i of Nt){const r=e.encoding[i];if(r&&zi(r)&&(null===(n=null===(t=r)||void 0===t?void 0:t.scale)||void 0===n?void 0:n.rangeStep))return!0}return!1}run(e){var t,n;const i={};let r=Object.assign({},e.encoding);for(const e of Nt){const o=_t(e),s=r[e];if(s&&zi(s)&&(null===(n=null===(t=s)||void 0===t?void 0:t.scale)||void 0===n?void 0:n.rangeStep)){const{scale:t}=s,n=$e(s,["scale"]),a=$e(t,["rangeStep"]);i[o]={step:t.rangeStep},Qt(Ht.RANGE_STEP_DEPRECATED),r=Object.assign(Object.assign({},r),{[e]:Object.assign(Object.assign({},n),Y(a).length>0?{scale:a}:{})})}}return Object.assign(Object.assign(Object.assign({},i),e),{encoding:r})}}class So{constructor(){this.name="RuleForRangedLine"}hasMatchingType(e){if(Se(e)){const{encoding:t,mark:n}=e;if("line"===n)for(const e of jt){const n=t[Et(e)];if(t[e]&&zi(n)&&!lr(n.bin))return!0}}return!1}run(e,t,n){const{encoding:i}=e;return Qt(Ht.lineWithRange(!!i.x2,!!i.y2)),n(Object.assign(Object.assign({},e),{mark:"rule"}),t)}}function ko(e){const{parentEncoding:t,encoding:n}=e;if(t&&n){const e=Y(t).reduce((e,t)=>(n[t]&&e.push(t),e),[]);e.length>0&&Qt(Ht.encodingOverridden(e))}const i=Object.assign(Object.assign({},null!=t?t:{}),null!=n?n:{});return Y(i).length>0?i:void 0}function $o(e){const{parentProjection:t,projection:n}=e;return t&&n&&Qt(Ht.projectionOverridden({parentProjection:t,projection:n})),null!=n?n:t}function Bo(e,t){void 0===t&&(t=lo(e.config));const n=function(e,t={}){return No.map(e,{config:t})}(e,t),{width:i,height:r}=e,o=function(e,t,n){let{width:i,height:r}=t;const o=Se(e)||bo(e),s={};o?"container"==i&&"container"==r?(s.type="fit",s.contains="padding"):"container"==i?(s.type="fit-x",s.contains="padding"):"container"==r&&(s.type="fit-y",s.contains="padding"):("container"==i&&(Qt(Ht.containerSizeNonSingle("width")),i=void 0),"container"==r&&(Qt(Ht.containerSizeNonSingle("height")),r=void 0));const a=Object.assign(Object.assign(Object.assign({type:"pad"},s),n?_o(n.autosize):{}),_o(e.autosize));"fit"!==a.type||o||(Qt(Ht.FIT_NON_SINGLE),a.type="pad");"container"==i&&"fit"!=a.type&&"fit-x"!=a.type&&Qt(Ht.containerSizeNotCompatibleWithAutosize("width"));"container"==r&&"fit"!=a.type&&"fit-y"!=a.type&&Qt(Ht.containerSizeNotCompatibleWithAutosize("height"));if(B(a,{type:"pad"}))return;return a}(n,{width:i,height:r,autosize:e.autosize},t);return Object.assign(Object.assign({},n),o?{autosize:o}:{})}const No=new class extends vo{constructor(){super(...arguments),this.nonFacetUnitNormalizers=[$r,Pr,Ir,new Do,new So,new Eo]}map(e,t){if(Se(e)){const n=gr(e.encoding,Le),i=gr(e.encoding,We),r=gr(e.encoding,qe);if(n||i||r)return this.mapFacetedUnit(e,t)}return super.map(e,t)}mapUnit(e,t){const{parentEncoding:n,parentProjection:i}=t;if(n||i)return this.mapUnitWithParentEncodingOrProjection(e,t);const r=this.mapLayerOrUnit.bind(this);for(const n of this.nonFacetUnitNormalizers)if(n.hasMatchingType(e,t.config))return n.run(e,t,r);return e}mapRepeat(e,t){const{repeat:n}=e;return!o(n)&&e.columns&&(e=z(e,["columns"]),Qt(Ht.columnsNotSupportByRowCol("repeat"))),Object.assign(Object.assign({},e),{spec:this.map(e.spec,t)})}mapFacet(e,t){const{facet:n}=e;return Di(n)&&e.columns&&(e=z(e,["columns"]),Qt(Ht.columnsNotSupportByRowCol("facet"))),super.mapFacet(e,t)}mapUnitWithParentEncodingOrProjection(e,t){const{encoding:n,projection:i}=e,{parentEncoding:r,parentProjection:o,config:s}=t,a=$o({parentProjection:o,projection:i}),u=ko({parentEncoding:r,encoding:n});return this.mapUnit(Object.assign(Object.assign(Object.assign({},e),a?{projection:a}:{}),u?{encoding:u}:{}),{config:s})}mapFacetedUnit(e,t){const n=e.encoding,{row:i,column:r,facet:o}=n,s=$e(n,["row","column","facet"]),{mark:a,width:u,projection:c,height:l,selection:d,encoding:f}=e,p=$e(e,["mark","width","projection","height","selection","encoding"]),{facetMapping:g,layout:h}=this.getFacetMappingAndLayout({row:i,column:r,facet:o});return this.mapFacet(Object.assign(Object.assign(Object.assign({},p),h),{facet:g,spec:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},c?{projection:c}:{}),{mark:a}),u?{width:u}:{}),l?{height:l}:{}),{encoding:s}),d?{selection:d}:{})}),t)}getFacetMappingAndLayout(e){var t;const{row:n,column:i,facet:r}=e;if(n||i){r&&Qt(Ht.facetChannelDropped([...n?[Le]:[],...i?[We]:[]]));const o={},s={};for(const n of[Le,We]){const i=e[n];if(i){const e=$e(i,["align","center","spacing","columns"]);o[n]=e;for(const e of["align","center","spacing"])void 0!==i[e]&&(s[e]=null!=(t=s[e])?t:{},s[e][n]=i[e])}}return{facetMapping:o,layout:s}}{const{align:e,center:t,spacing:n,columns:i}=r;return{facetMapping:$e(r,["align","center","spacing","columns"]),layout:Object.assign(Object.assign(Object.assign(Object.assign({},e?{align:e}:{}),t?{center:t}:{}),n?{spacing:n}:{}),i?{columns:i}:{})}}}mapLayer(e,t){var{parentEncoding:n,parentProjection:i}=t,r=$e(t,["parentEncoding","parentProjection"]);const{encoding:o,projection:s}=e,a=$e(e,["encoding","projection"]),u=Object.assign(Object.assign({},r),{parentEncoding:ko({parentEncoding:n,encoding:o}),parentProjection:$o({parentProjection:i,projection:s})});return super.mapLayer(a,u)}};function _o(e){return a(e)?{type:e}:null!=e?e:{}}const zo=["background","padding"];function To(e){return zo.reduce((t,n)=>(e&&void 0!==e[n]&&(t[n]=e[n]),t),{})}function Po(e){return!!e.url}function Mo(e){return!!e.values}function Uo(e){return!(!e.name||Po(e)||Mo(e)||Ro(e))}function Ro(e){return e&&(Lo(e)||Wo(e)||qo(e))}function Lo(e){return!!e.sequence}function Wo(e){return!!e.sphere}function qo(e){return!!e.graticule}const Io="main",Ho="raw";function Go(e){return void 0!==e.filter}function Yo(e){return void 0!==e.lookup}function Vo(e){return void 0!==e.pivot}function Jo(e){return void 0!==e.density}function Qo(e){return void 0!==e.quantile}function Xo(e){return void 0!==e.regression}function Zo(e){return void 0!==e.loess}function Ko(e){return void 0!==e.sample}function es(e){return void 0!==e.window}function ts(e){return void 0!==e.joinaggregate}function ns(e){return void 0!==e.flatten}function is(e){return void 0!==e.calculate}function rs(e){return!!e.bin}function os(e){return void 0!==e.impute}function ss(e){return void 0!==e.timeUnit}function as(e){return void 0!==e.aggregate}function us(e){return void 0!==e.stack}function cs(e){return void 0!==e.fold}function ls(e){return!!e.signal}function ds(e){return!!e.step}function fs(e){return!o(e)&&("field"in e&&"data"in e)}const ps=Y({opacity:1,fill:1,fillOpacity:1,stroke:1,strokeCap:1,strokeWidth:1,strokeOpacity:1,strokeDash:1,strokeDashOffset:1,strokeJoin:1,strokeMiterLimit: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,x:1,y:1,x2:1,y2:1,width:1,height:1,aspect:1}),gs=["cornerRadius","cornerRadiusTopLeft","cornerRadiusTopRight","cornerRadiusBottomLeft","cornerRadiusBottomRight"],hs={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"},gridColor:{part:"grid",vgProp:"stroke"},gridDash:{part:"grid",vgProp:"strokeDash"},gridDashOffset:{part:"grid",vgProp:"strokeDash"},gridOpacity:{part:"grid",vgProp:"opacity"},gridWidth:{part:"grid",vgProp:"strokeWidth"},tickColor:{part:"ticks",vgProp:"stroke"},tickDash:{part:"ticks",vgProp:"strokeDash"},tickDashOffset:{part:"ticks",vgProp:"strokeDash"},tickOpacity:{part:"ticks",vgProp:"opacity"},tickWidth:{part:"ticks",vgProp:"strokeWidth"}};const ms=["domain","grid","labels","ticks","title"],bs={grid:"grid",gridColor:"grid",gridDash:"grid",gridOpacity:"grid",gridScale:"grid",gridWidth:"grid",orient:"main",bandPosition:"both",domain:"main",domainColor:"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",labelFontWeight:"main",labelLimit:"main",labelOpacity:"main",labelOverlap:"main",labelPadding:"main",labels:"main",maxExtent:"main",minExtent:"main",offset:"main",position:"main",tickColor:"main",tickExtra:"main",tickOffset:"both",tickOpacity:"main",tickRound:"main",ticks:"main",tickSize:"main",title:"main",titleAlign:"main",titleAngle:"main",titleBaseline:"main",titleColor:"main",titleFont:"main",titleFontSize:"main",titleFontWeight:"main",titleLimit:"main",titleLineHeight:"main",titleOpacity:"main",titlePadding:"main",titleX:"main",titleY:"main",tickWidth:"both",tickCount:"both",values:"both",scale:"both",zindex:"both"},vs={orient:1,bandPosition:1,domain:1,domainColor:1,domainDash:1,domainDashOffset:1,domainOpacity:1,domainWidth:1,format:1,formatType:1,grid: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,labelOpacity:1,labelOverlap:1,labelPadding:1,labels:1,labelSeparation:1,maxExtent:1,minExtent:1,offset:1,position:1,tickBand: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,values:1,translate:1,zindex:1},ys=Object.assign(Object.assign({},vs),{labelExpr:1,encoding:1});function xs(e,t,n){return As=t||ws,Os=n||Ns,zs(e.trim()).map(Ts)}var As,Os,ws="view",Fs="[",Cs="]",js="{",Ds="}",Es=":",Ss=",",ks="@",$s=">",Bs=/[[\]{}]/,Ns={"*":1,arc:1,area:1,group:1,image:1,line:1,path:1,rect:1,rule:1,shape:1,symbol:1,text:1,trail:1};function _s(e,t,n,i,r){for(var o,s=0,a=e.length;t<a;++t){if(o=e[t],!s&&o===n)return t;r&&r.indexOf(o)>=0?--s:i&&i.indexOf(o)>=0&&++s}return t}function zs(e){for(var t=[],n=0,i=e.length,r=0;r<i;)r=_s(e,r,Ss,Fs+js,Cs+Ds),t.push(e.substring(n,r).trim()),n=++r;if(0===t.length)throw"Empty event selector: "+e;return t}function Ts(e){return"["===e[0]?function(e){var t,n,i=e.length,r=1;if((r=_s(e,r,Cs,Fs,Cs))===i)throw"Empty between selector: "+e;if(2!==(t=zs(e.substring(1,r))).length)throw"Between selector must have two elements: "+e;if((e=e.slice(r+1).trim())[0]!==$s)throw"Expected '>' after between selector: "+e;if(t=t.map(Ts),(n=Ts(e.slice(1).trim())).between)return{between:t,stream:n};n.between=t;return n}(e):function(e){var t,n,i={source:As},r=[],o=[0,0],s=0,a=0,u=e.length,c=0;if(e[u-1]===Ds){if(!((c=e.lastIndexOf(js))>=0))throw"Unmatched right brace: "+e;try{o=function(e){var t=e.split(Ss);if(!e.length||t.length>2)throw e;return t.map((function(t){var n=+t;if(n!=n)throw e;return n}))}(e.substring(c+1,u-1))}catch(t){throw"Invalid throttle specification: "+e}e=e.slice(0,c).trim(),u=e.length,c=0}if(!u)throw e;e[0]===ks&&(s=++c);(t=_s(e,c,Es))<u&&(r.push(e.substring(a,t).trim()),a=c=++t);if((c=_s(e,c,Fs))===u)r.push(e.substring(a,u).trim());else if(r.push(e.substring(a,c).trim()),n=[],(a=++c)===u)throw"Unmatched left bracket: "+e;for(;c<u;){if((c=_s(e,c,Cs))===u)throw"Unmatched left bracket: "+e;if(n.push(e.substring(a,c).trim()),c<u-1&&e[++c]!==Fs)throw"Expected left bracket: "+e;a=++c}if(!(u=r.length)||Bs.test(r[u-1]))throw"Invalid event selector: "+e;u>1?(i.type=r[1],s?i.markname=r[0].slice(1):!function(e){return Os[e]}(r[0])?i.source=r[0]:i.marktype=r[0]):i.type=r[0];"!"===i.type.slice(-1)&&(i.consume=!0,i.type=i.type.slice(0,-1));null!=n&&(i.filter=n);o[0]&&(i.throttle=o[0]);o[1]&&(i.debounce=o[1]);return i}(e)}function Ps(e,t,n,i){const r=t&&t.condition,o=i(t);if(r){return{[n]:[...x(r).map(t=>{const n=i(t),r=function(e){return e.selection}(t)?Gc(e,t.selection):Vc(e,t.test);return Object.assign({test:r},n)}),...void 0!==o?[o]:[]]}}return void 0!==o?{[n]:o}:{}}function Ms(e){const{channel:t,channelDef:n,markDef:i,scale:r}=e,o=Is(e);return zi(n)&&!Me(n.aggregate)&&r&&Vn(r.get("type"))&&!1===r.get("zero")?Us({fieldDef:n,channel:t,markDef:i,ref:o}):o}function Us({fieldDef:e,channel:t,markDef:n,ref:i}){return Ae(n.type)?i:[Rs(e,t),i]}function Rs(e,t){const n=Ls(e,!0),i="x"===Et(t)?{value:0}:{field:{group:"height"}};return Object.assign({test:n},i)}function Ls(e,t=!0){return Dn(a(e)?e:Wi(e,{expr:"datum"}),!t)}function Ws(e,t,n,i){const r=Object.assign(Object.assign({},t?{scale:t}:{}),{field:Wi(e,n)});if(i){const{offset:e,band:t}=i;return Object.assign(Object.assign(Object.assign({},r),e?{offset:e}:{}),t?{band:t}:{})}return r}function qs({scaleName:e,fieldDef:t,fieldDef2:n,offset:i,startSuffix:r,band:o=.5}){const s=0<o&&o<1?"datum":void 0,a=Wi(t,{expr:s,suffix:r}),u=void 0!==n?Wi(n,{expr:s}):Wi(t,{suffix:"end",expr:s});if(0===o)return Object.assign({scale:e,field:a},i?{offset:i}:{});if(1===o)return Object.assign({scale:e,field:u},i?{offset:i}:{});{const t=`${o} * ${a} + ${1-o} * ${u}`;return Object.assign({signal:`scale("${e}", ${t})`},i?{offset:i}:{})}}function Is({channel:e,channelDef:t,channel2Def:n,markDef:i,config:r,scaleName:o,scale:s,stack:a,offset:u,defaultRef:c}){if(t){if(zi(t)){if(Ti(t)){const s=$i(e,t,n,i,r,{isMidPoint:!0});if(cr(t.bin)||s&&t.timeUnit)return U([Ie,He],e)&&U([kn,Bn],t.type)?a&&a.impute?Ws(t,o,{binSuffix:"mid"},{offset:u}):qs({scaleName:o,fieldDef:t,band:s,offset:u}):Ws(t,o,ar(t,e)?{binSuffix:"range"}:{},{offset:u});if(lr(t.bin)){if(zi(n))return qs({scaleName:o,fieldDef:t,fieldDef2:n,band:s,offset:u});{const t=e===Ie?Ge:Ye;Qt(Ht.channelRequiredForBinned(t))}}}if(s){const e=s.get("type");if(Gn(e)){if("band"===e){return Ws(t,o,{binSuffix:"range"},{band:oe(Ri(t)?t.band:void 0,.5),offset:u})}return Ws(t,o,{binSuffix:"range"},{offset:u})}}return Ws(t,o,{},{offset:u})}if(Mi(t)){const n=t.value,i=u?{offset:u}:{};return Object.assign(Object.assign({},Hs(e,n)),i)}}const l=function(e){return"function"==typeof e}(c)?Object.assign(Object.assign({},c()),u?{offset:u}:{}):c;return l?Object.assign(Object.assign({},l),u?{offset:u}:{}):l}function Hs(e,t){return U(["x","x2"],e)&&"width"===t?{field:{group:"width"}}:U(["y","y2"],e)&&"height"===t?{field:{group:"height"}}:{value:t}}function Gs(e,t,n={}){const{markDef:i,encoding:r,config:o}=t,{vgChannel:s=e}=n;let{defaultRef:a,defaultValue:u}=n;void 0===a&&(u=null!=u?u:s===e?i[e]:oe(i[e],i[s],ci(e,i,o,{vgChannel:s})),a=u?{value:u}:void 0);const c=r[e];return Ps(t,c,s,n=>Is({channel:e,channelDef:n,markDef:i,config:o,scaleName:t.scaleName(e),scale:t.getScaleComponent(e),stack:null,defaultRef:a}))}function Ys(e){const{markDef:t,encoding:n,config:i}=e,{filled:r,type:o}=t,s={fill:ci("fill",t,i),stroke:ci("stroke",t,i),color:ci("color",t,i)},a=U(["bar","point","circle","square","geoshape"],o)?"transparent":void 0,u=oe(t.fill,!0===r?t.color:void 0,s.fill,!0===r?s.color:void 0,a),c=oe(t.stroke,!1===r?t.color:void 0,s.stroke,!1===r?s.color:void 0),l=r?"fill":"stroke",d=Object.assign(Object.assign({},u?{fill:{value:u}}:{}),c?{stroke:{value:c}}:{});return t.color&&(r?t.fill:t.stroke)&&Qt(Ht.droppingColor("property",{fill:"fill"in t,stroke:"stroke"in t})),Object.assign(Object.assign(Object.assign(Object.assign({},d),Gs("color",e,{vgChannel:l,defaultValue:r?u:c})),Gs("fill",e,{defaultValue:n.fill?u:void 0})),Gs("stroke",e,{defaultValue:n.stroke?c:void 0}))}function Vs(e,t="text"){const n=e.encoding[t];return Ps(e,n,t,t=>Js(t,e.config))}function Js(e,t,n="datum"){if(e){if(Mi(e))return{value:e.value};if(Ti(e))return di(e,Xi(e),n,t)}}function Qs(e,t={}){const{encoding:n,markDef:i,config:r}=e,u=n.tooltip;return o(u)?{tooltip:Xs({tooltip:u},r,t)}:Ps(e,u,"tooltip",o=>{const u=Js(o,e.config,t.reactiveGeom?"datum.datum":"datum");if(u)return u;if(null===o)return;let c=oe(i.tooltip,ci("tooltip",i,r));return!0===c&&(c={content:"encoding"}),a(c)?{value:c}:s(c)?"encoding"===c.content?Xs(n,r,t):{signal:"datum"}:void 0})}function Xs(e,t,{reactiveGeom:n}={}){const i=[],r={},o={},s=n?"datum.datum":"datum",a=[];function c(n,i){const r=Et(i),u=Ti(n)?n:Object.assign(Object.assign({},n),{type:e[r].type}),c=x(Vi(u,t,{allowDisabling:!1})).join(", ");let l=Js(u,t,s).signal;if("x"===i||"y"===i){const n="x"===i?"x2":"y2",r=Zi(e[n]);if(lr(u.bin)&&r){l=hi(Wi(u,{expr:s}),Wi(r,{expr:s}),Xi(u),t),o[n]=!0}}a.push({channel:i,key:c,value:l})}yr(e,(e,t)=>{zi(e)?c(e,t):_i(e)&&c(e.condition,t)});for(const{channel:e,key:t,value:n}of a)o[e]||r[t]||(i.push(`${u(t)}: ${n}`),r[t]=!0);return i.length>0?{signal:`{${i.join(", ")}}`}:void 0}function Zs(e,t){const n=t[e+"Offset"];if(n)return n}function Ks(e,t,{defaultPos:n,vgChannel:i}){const{encoding:r,mark:o,markDef:s,config:a,stack:u}=t,c=r[e],l=r[e===Ie?Ge:Ye],d=t.scaleName(e),f=t.getScaleComponent(e),p=Zs(e,t.markDef),g=ea({model:t,markDef:s,config:a,defaultPos:n,channel:e,scaleName:d,scale:f,mark:o,checkBarAreaWithoutZero:!l});return{[null!=i?i:e]:c||!r.latitude&&!r.longitude?function(e){const{channel:t,channelDef:n,scaleName:i,stack:r,offset:o}=e;if(zi(n)&&r&&t===r.fieldChannel)return Ri(n)&&void 0!==n.band?qs({scaleName:i,fieldDef:n,startSuffix:"start",band:n.band,offset:0}):Ws(n,i,{suffix:"end"},{offset:o});return Ms(e)}({channel:e,channelDef:c,channel2Def:l,markDef:s,config:a,scaleName:d,scale:f,stack:u,offset:p,defaultRef:g}):{field:t.getName(e)}}}function ea({model:e,markDef:t,config:n,defaultPos:i,channel:r,scaleName:o,scale:s,mark:a,checkBarAreaWithoutZero:u}){return()=>{const c=Et(r),l=oe(t[r],ci(r,t,n));if(void 0!==l)return Hs(r,l);if("zeroOrMin"===i||"zeroOrMax"===i){if(o){const e=s.get("type");if(U([zn.LOG,zn.TIME,zn.UTC],e))!u||"bar"!==a&&"area"!==a||Qt(Ht.nonZeroScaleUsedWithLengthMark(a,c,{scaleType:e}));else{if(s.domainDefinitelyIncludesZero())return{scale:o,value:0};!u||"bar"!==a&&"area"!==a||Qt(Ht.nonZeroScaleUsedWithLengthMark(a,c,{zeroFalse:!1===s.explicit.zero}))}}return"zeroOrMin"===i?"x"===c?{value:0}:{field:{group:"height"}}:"x"===c?{field:{group:"width"}}:{value:0}}{const t=e["x"===c?"width":"height"];return Object.assign(Object.assign({},t),{mult:.5})}}}const ta={left:"x",center:"xc",right:"x2"},na={top:"y",middle:"yc",bottom:"y2"};function ia(e,t,n){const i="x"===e?"align":"baseline",r=oe(t[i],ci(i,t,n));return"x"===e?ta[null!=r?r:"center"]:na[null!=r?r:"middle"]}function ra(e,t,{defaultPos:n,defaultPos2:i,range:r}){return r?oa(e,t,{defaultPos:n,defaultPos2:i}):Ks(e,t,{defaultPos:n})}function oa(e,t,{defaultPos:n,defaultPos2:i}){const{markDef:r,config:o}=t,s="x"===e?"width":"height",a=function(e,t,n){const{encoding:i,mark:r,markDef:o,stack:s,config:a}=e,u="x2"===n?"x":"y",c="x2"===n?"width":"height",l=i[u],d=e.scaleName(u),f=e.getScaleComponent(u),p=Zs(n,e.markDef);if(!l&&(i.latitude||i.longitude))return{[n]:{field:e.getName(n)}};const g=function({channel:e,channelDef:t,channel2Def:n,markDef:i,config:r,scaleName:o,scale:s,stack:a,offset:u,defaultRef:c}){if(zi(t)&&a&&e.charAt(0)===a.fieldChannel.charAt(0))return Ws(t,o,{suffix:"start"},{offset:u});return Ms({channel:e,channelDef:n,scaleName:o,scale:s,stack:a,markDef:i,config:r,offset:u,defaultRef:c})}({channel:n,channelDef:l,channel2Def:i[n],markDef:o,config:a,scaleName:d,scale:f,stack:s,offset:p,defaultRef:void 0});if(void 0!==g)return{[n]:g};const h=ea({model:e,markDef:o,config:a,defaultPos:t,channel:n,scaleName:d,scale:f,mark:r,checkBarAreaWithoutZero:!i[n]})();return oe(sa(n,o),sa(n,{[n]:li(n,o,a.style),[c]:li(c,o,a.style)}),sa(n,a[r]),sa(n,a.mark),{[n]:h})}(t,i,"x"===e?"x2":"y2"),u=a[s]?ia(e,r,o):e;return Object.assign(Object.assign({},Ks(e,t,{defaultPos:n,vgChannel:u})),a)}function sa(e,t){const n="x2"===e?"width":"height";return t[e]?{[e]:Hs(e,t[e])}:t[n]?{[n]:{value:t[n]}}:void 0}function aa(e,t,n){var i,r,o,s;const{config:a,encoding:u,markDef:c}=e,l="x"===t?"x2":"y2",d="x"===t?"width":"height",f=u[t],p=u[l],g=e.getScaleComponent(t),h=g?g.get("type"):void 0,m=e.scaleName(t),b=c.orient,v=null!=(s=null!=(o=null!=(r=null!=(i=u[d])?i:u.size)?r:c[d])?o:c.size)?s:ci("size",c,a,{vgChannel:d}),y="x"===t?"vertical"===b:"horizontal"===b;if(zi(f)&&(cr(f.bin)||lr(f.bin)||f.timeUnit&&!p)&&!v&&!Gn(h)){return function({fieldDef:e,fieldDef2:t,channel:n,band:i,scaleName:r,markDef:o,spacing:s=0,reverse:a}){const u={x:a?s:0,x2:a?0:s,y:a?0:s,y2:a?s:0},c=n===Ie?Ge:Ye;return cr(e.bin)||e.timeUnit?{[c]:la({channel:n,fieldDef:e,scaleName:r,markDef:o,band:(1-i)/2,offset:u[`${n}2`]}),[n]:la({channel:n,fieldDef:e,scaleName:r,markDef:o,band:1-(1-i)/2,offset:u[n]})}:lr(e.bin)&&zi(t)?{[c]:Ws(e,r,{},{offset:u[`${n}2`]}),[n]:Ws(t,r,{},{offset:u[n]})}:void Qt(Ht.channelRequiredForBinned(c))}({fieldDef:f,fieldDef2:p,channel:t,markDef:c,scaleName:m,band:$i(t,f,void 0,c,a),spacing:oe(c.binSpacing,a[n].binSpacing),reverse:g.get("reverse")})}if((zi(f)&&Gn(h)||y)&&!p){if(zi(f)&&h===zn.BAND){return function(e,t,n,i){var r;const o=n.scaleName(t),s="x"===t?"width":"height",{markDef:a,encoding:u,config:c}=n,l={[ia(t,a,c)]:Ws(e,o,{},{band:.5})};if(u.size||null!==a.size&&void 0!==a.size){if(a.orient){if(Ki(u.size)||Mi(u.size))return Object.assign(Object.assign({},l),Gs("size",n,{vgChannel:s}));if(void 0!==a.size)return Object.assign(Object.assign({},l),{[s]:{value:a.size}})}else Qt(Ht.cannotApplySizeToNonOrientedMark(a.type))}if(void 0!==(null===(r=i)||void 0===r?void 0:r.value))return Object.assign(Object.assign({},l),{[s]:i});const{band:d=1}=e;return{[t]:Ws(e,o,{binSuffix:"range"},{band:(1-d)/2}),[s]:null!=i?i:ca(o,d)}}(f,t,e,ua(n,c,d,m,g,a,Ri(f)?f.band:void 0))}return function(e,t,n){const i="x"===e?"xc":"yc",r="x"===e?"width":"height";return Object.assign(Object.assign({},Ks(e,t,{defaultPos:"mid",vgChannel:i})),Gs("size",t,{defaultRef:n,vgChannel:r}))}(t,e,ua(n,c,d,m,g,a))}return oa(t,e,{defaultPos:"zeroOrMax",defaultPos2:"zeroOrMin"})}function ua(e,t,n,i,r,o,s){const a=oe(t[n],t.size,ci("size",t,o,{vgChannel:n}));if(void 0!==a)return{value:a};if(r){const t=r.get("type");if("point"===t||"band"===t){if(void 0!==o[e].discreteBandSize)return{value:o[e].discreteBandSize};if(t===zn.POINT){const e=r.get("range");return ds(e)&&F(e.step)?{value:e.step-2}:{value:uo-2}}return ca(i,s)}return{value:o[e].continuousBandSize}}const u=so(o.view,n);return{value:oe(o[e].discreteBandSize,u-2)}}function ca(e,t=!0){return{scale:e,band:t}}function la({channel:e,fieldDef:t,scaleName:n,markDef:i,band:r,offset:o}){return Us({fieldDef:t,channel:e,markDef:i,ref:qs({scaleName:n,fieldDef:t,band:r,offset:o})})}function da(e,t){const{fill:n,stroke:i}="include"===t.color?Ys(e):{};return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},function(e,t){return ps.reduce((n,i)=>(void 0!==e[i]&&"ignore"!==t[i]&&(n[i]={value:e[i]}),n),{})}(e.markDef,t)),fa(e,"fill",n)),fa(e,"stroke",i)),Gs("opacity",e)),Gs("fillOpacity",e)),Gs("strokeOpacity",e)),Gs("strokeWidth",e)),Qs(e)),Vs(e,"href"))}function fa(e,t,n){const{config:i,mark:r,markDef:o}=e;if("hide"===ui("invalid",o,i)&&n&&!Ae(r)){const i=function(e,{invalid:t=!1,channels:n}){const i=n.reduce((t,n)=>{const i=e.getScaleComponent(n);if(i){const r=i.get("type"),o=e.vgField(n,{expr:"datum"});o&&Yn(r)&&(t[o]=!0)}return t},{}),r=Y(i);if(r.length>0){const e=t?"||":"&&";return r.map(e=>Ls(e,t)).join(` ${e} `)}return}(e,{invalid:!0,channels:Ut});if(i)return{[t]:[{test:i,value:null},...x(n)]}}return n?{[t]:n}:{}}function pa(e){const{config:t,markDef:n}=e;if(ui("invalid",n,t)){const t=function(e,{invalid:t=!1,channels:n}){const i=n.reduce((t,n)=>{const i=e.getScaleComponent(n);if(i){const r=i.get("type"),o=e.vgField(n,{expr:"datum"});o&&Yn(r)&&(t[o]=!0)}return t},{}),r=Y(i);if(r.length>0){const e=t?"||":"&&";return r.map(e=>Ls(e,t)).join(` ${e} `)}return}(e,{channels:["x","y"]});if(t)return{defined:{signal:t}}}return{}}function ga(e,t){if(void 0!==t)return{[e]:{value:t}}}const ha={has:e=>"interval"!==e.type&&e.nearest,parse:(e,t)=>{if(t.events)for(const n of t.events)n.markname=e.getName("voronoi")},marks:(e,t,n)=>{const{x:i,y:r}=t.project.hasChannel,o=e.mark;if(Ae(o))return Qt(Ht.nearestNotSupportForContinuous(o)),n;const s={name:e.getName("voronoi"),type:"path",interactive:!0,from:{data:e.getName("marks")},encode:{update:Object.assign({fill:{value:"transparent"},strokeWidth:{value:.35},stroke:{value:"transparent"},isVoronoi:{value:!0}},Qs(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,u=!1;return n.forEach((t,n)=>{var i;const r=null!=(i=t.name)?i:"";r===e.component.mark[0].name?a=n:r.indexOf("voronoi")>=0&&(u=!0)}),u||n.splice(a+1,0,s),n}};class ma{constructor(e,t){this.debugName=t,this._children=[],this._parent=null,e&&(this.parent=e)}clone(){throw new Error("Cannot clone node")}get parent(){return this._parent}set parent(e){this._parent=e,e&&e.addChild(this)}get children(){return this._children}numChildren(){return this._children.length}addChild(e,t){this._children.indexOf(e)>-1?console.warn("Attempt to add the same child twice."):void 0!==t?this._children.splice(t,0,e):this._children.push(e)}removeChild(e){const t=this._children.indexOf(e);return this._children.splice(t,1),t}remove(){let e=this._parent.removeChild(this);for(const t of this._children)t._parent=this._parent,this._parent.addChild(t,e++)}insertAsParentOf(e){const t=e.parent;t.removeChild(this),this.parent=t,e.parent=this}swapWithParent(){const e=this._parent,t=e.parent;for(const t of this._children)t.parent=e;this._children=[],e.removeChild(this),e.parent.removeChild(e),this.parent=t,e.parent=this}}class ba extends ma{constructor(e,t,n,i){super(e,t),this.type=n,this.refCounts=i,this._source=this._name=t,!this.refCounts||this._name in this.refCounts||(this.refCounts[this._name]=0)}clone(){const e=new this.constructor;return e.debugName="clone_"+this.debugName,e._source=this._source,e._name="clone_"+this._name,e.type=this.type,e.refCounts=this.refCounts,e.refCounts[e._name]=0,e}dependentFields(){return new Set}producedFields(){return new Set}hash(){return void 0===this._hash&&(this._hash=`Output ${function(e){const t=++se;return e?String(e)+t:t}()}`),this._hash}getSource(){return this.refCounts[this._name]++,this._source}isRequired(){return!!this.refCounts[this._name]}setSource(e){this._source=e}}class va extends ma{constructor(e,t){super(e),this.formula=t}clone(){return new va(null,N(this.formula))}static makeFromEncoding(e,t){const n=t.reduceFieldDef((e,n,i)=>{const{timeUnit:r,field:o}=n,s=vf(t)?t.encoding[St(i)]:void 0,a=vf(t)&&Bi(i,n,s,t.markDef,t.config);if(r){const t=Wi(n,{forAs:!0});e[P({as:t,timeUnit:r,field:o})]=Object.assign({as:t,timeUnit:r,field:o},a?{band:!0}:{})}return e},{});return 0===Y(n).length?null:new va(e,n)}static makeFromTransform(e,t){const n=Object.assign({},t);return new va(e,{[P(n)]:n})}merge(e){this.formula=Object.assign({},this.formula);for(const t in e.formula)this.formula[t]&&!e.formula[t].band||(this.formula[t]=e.formula[t]);for(const t of e.children)e.removeChild(t),t.parent=this;e.remove()}producedFields(){return new Set(V(this.formula).map(e=>e.as))}dependentFields(){return new Set(V(this.formula).map(e=>e.field))}hash(){return`TimeUnit ${P(this.formula)}`}assemble(){const e=[];for(const t of V(this.formula)){const{timeUnit:n,field:i,as:r}=t;e.push({field:i,type:"timeunit",units:fn(n),as:[r,`${r}_end`]})}return e}}const ya="_tuple_fields";class xa{constructor(...e){this.items=e,this.hasChannel={},this.hasField={}}}const Aa={has:e=>"single"===e.type&&"global"===e.resolve&&e.bind&&"scales"!==e.bind&&!Xr(e.bind),parse:(e,t,n,i)=>{i.on||delete t.events,i.clear||delete t.clear},topLevelSignals:(e,t,n)=>{const i=t.name,r=t.project,o=t.bind,s=t.init&&t.init[0],a=ha.has(t)?"(item().isVoronoi ? datum.datum : datum)":"datum";return r.items.forEach((e,r)=>{var c,l;const d=Q(`${i}_${e.field}`);n.filter(e=>e.name===d).length||n.unshift(Object.assign(Object.assign({name:d},s?{init:Ma(s[r])}:{value:null}),{on:t.events?[{events:t.events,update:`datum && item().mark.marktype !== 'group' ? ${a}[${u(e.field)}] : null`}]:[],bind:(c=o[e.field],l=null!=c?c:o[e.channel],null!=l?l:o)}))}),n},signals:(e,t,n)=>{const i=t.name,r=t.project,o=n.filter(e=>e.name===i+Ja)[0],s=i+ya,a=r.items.map(e=>Q(`${i}_${e.field}`)),u=a.map(e=>`${e} !== null`).join(" && ");return a.length&&(o.update=`${u} ? {fields: ${s}, values: [${a.join(", ")}]} : null`),delete o.value,delete o.on,n}},Oa={has:e=>"multi"===e.type&&!!e.toggle,signals:(e,t,n)=>n.concat({name:t.name+"_toggle",value:!1,on:[{events:t.events,update:t.toggle}]}),modifyExpr:(e,t)=>{const n=t.name+Ja,i=t.name+"_toggle";return`${i} ? null : ${n}, `+("global"===t.resolve?`${i} ? null : true, `:`${i} ? null : {unit: ${eu(e)}}, `)+`${i} ? ${n} : null`}},wa={has:e=>void 0!==e.clear&&!1!==e.clear,parse:(e,t,n)=>{n.clear&&(t.clear=a(n.clear)?xs(n.clear,"scope"):n.clear)},topLevelSignals:(e,t,n)=>(Aa.has(t)&&t.project.items.forEach(e=>{const i=n.findIndex(n=>n.name===Q(`${t.name}_${e.field}`));-1!==i&&n[i].on.push({events:t.clear,update:"null"})}),n),signals:(e,t,n)=>{function i(e,i){-1!==e&&n[e].on&&n[e].on.push({events:t.clear,update:i})}if("interval"===t.type)t.project.items.forEach(e=>{const t=n.findIndex(t=>t.name===e.signals.visual);if(i(t,"[0, 0]"),-1===t){i(n.findIndex(t=>t.name===e.signals.data),"null")}});else{let e=n.findIndex(e=>e.name===t.name+Ja);i(e,"null"),Oa.has(t)&&(e=n.findIndex(e=>e.name===t.name+"_toggle"),i(e,"false"))}return n}},Fa={has:e=>"interval"===e.type&&"global"===e.resolve&&e.bind&&"scales"===e.bind,parse:(e,t)=>{const n=t.scales=[];for(const i of t.project.items){const r=i.channel;if(!Rt(r))continue;const o=e.getScaleComponent(r),s=o?o.get("type"):void 0;if(!o||!Yn(s)){Qt(Ht.SCALE_BINDINGS_CONTINUOUS);continue}const a={selection:t.name,field:i.field};if(o.set("selectionExtent",a,!0),n.push(i),e.repeater&&e.repeater.row===e.repeater.column){e.getScaleComponent(r===Ie?He:Ie).set("selectionExtent",a,!0)}}},topLevelSignals:(e,t,n)=>{const i=t.scales.filter(e=>0===n.filter(t=>t.name===e.signals.data).length);if(!e.parent||ja(e)||0===i.length)return n;const r=n.filter(e=>e.name===t.name)[0];let o=r.update;if(o.indexOf(Xa)>=0)r.update=`{${i.map(e=>`${u(e.field)}: ${e.signals.data}`).join(", ")}}`;else{for(const e of i){const t=`${u(e.field)}: ${e.signals.data}`;o.indexOf(t)<0&&(o=`${o.substring(0,o.length-1)}, ${t}}`)}r.update=o}return n.concat(i.map(e=>({name:e.signals.data})))},signals:(e,t,n)=>{if(e.parent&&!ja(e))for(const e of t.scales){const t=n.filter(t=>t.name===e.signals.data)[0];t.push="outer",delete t.value,delete t.update}return n}};function Ca(e,t){return`domain(${u(e.scaleName(t))})`}function ja(e){var t;return e.parent&&Of(e.parent)&&(null!=(t=!e.parent.parent)?t:ja(e.parent.parent))}const Da={has:e=>{const t="global"===e.resolve&&e.bind&&Xr(e.bind),n=1===e.project.items.length&&e.project.items[0].field!==Jr;return t&&!n&&Qt(Ht.LEGEND_BINDINGS_PROJECT_LENGTH),t&&n},parse:(e,t,n,i)=>{var r;if(i.on||delete t.events,i.clear||delete t.clear,i.on||i.clear){const e='event.item && indexof(event.item.mark.role, "legend") < 0';for(const n of t.events)n.filter=x(null!=(r=n.filter)?r:[]),n.filter.indexOf(e)<0&&n.filter.push(e)}const o=Zr(t.bind)?t.bind.legend:"click",s=a(o)?xs(o,"view"):x(o);t.bind={legend:{merge:s}}},topLevelSignals:(e,t,n)=>{const i=t.name,r=Zr(t.bind)&&t.bind.legend,o=e=>t=>{const n=N(t);return n.markname=e,n};for(const e of t.project.items){if(!e.hasLegend)continue;const s=`${e.field}_legend`,a=`${i}_${s}`;if(0===n.filter(e=>e.name===a).length){const e=r.merge.map(o(`${s}_symbols`)).concat(r.merge.map(o(`${s}_labels`))).concat(r.merge.map(o(`${s}_entries`)));n.unshift(Object.assign(Object.assign({name:a},t.init?{}:{value:null}),{on:[{events:e,update:"datum.value || item().items[0].items[0].datum.value",force:!0},{events:r.merge,update:`!event.item || !datum ? null : ${a}`,force:!0}]}))}}return n},signals:(e,t,n)=>{const i=t.name,r=t.project,o=n.find(e=>e.name===i+Ja),s=i+ya,a=r.items.filter(e=>e.hasLegend).map(e=>Q(`${i}_${e.field}_legend`)),u=`${a.map(e=>`${e} !== null`).join(" && ")} ? {fields: ${s}, values: [${a.join(", ")}]} : null`;t.events&&a.length>0?o.on.push({events:a.map(e=>({signal:e})),update:u}):a.length>0&&(o.update=u,delete o.value,delete o.on);const c=n.find(e=>e.name===i+"_toggle"),l=Zr(t.bind)&&t.bind.legend;return c&&(t.events?c.on.push(Object.assign(Object.assign({},c.on[0]),{events:l})):c.on[0].events=l),n}};const Ea="_translate_anchor",Sa="_translate_delta",ka={has:e=>"interval"===e.type&&e.translate,signals:(e,t,n)=>{const i=t.name,r=Fa.has(t),o=i+Ea,{x:s,y:a}=t.project.hasChannel;let u=xs(t.translate,"scope");return r||(u=u.map(e=>(e.between[0].markname=i+La,e))),n.push({name:o,value:{},on:[{events:u.map(e=>e.between[0]),update:"{x: x(unit), y: y(unit)"+(void 0!==s?", extent_x: "+(r?Ca(e,Ie):`slice(${s.signals.visual})`):"")+(void 0!==a?", extent_y: "+(r?Ca(e,He):`slice(${a.signals.visual})`):"")+"}"}]},{name:i+Sa,value:{},on:[{events:u,update:`{x: ${o}.x - x(unit), y: ${o}.y - y(unit)}`}]}),void 0!==s&&$a(e,t,s,"width",n),void 0!==a&&$a(e,t,a,"height",n),n}};function $a(e,t,n,i,r){var o;const s=t.name,a=s+Ea,u=s+Sa,c=n.channel,l=Fa.has(t),d=r.filter(e=>e.name===n.signals[l?"data":"visual"])[0],f=e.getSizeSignalRef(i).signal,p=e.getScaleComponent(c),g=p.get("type"),h=`${a}.extent_${c}`,m=`${l?"log"===g?"panLog":"pow"===g?"panPow":"panLinear":"panLinear"}(${h}, ${`${l&&c===Ie?"-":""}${u}.${c} / `+(l?`${f}`:`span(${h})`)}`+(l&&"pow"===g?`, ${o=p.get("exponent"),null!=o?o:1}`:"")+")";d.on.push({events:{signal:u},update:l?m:`clampRange(${m}, 0, ${f})`})}const Ba="_zoom_anchor",Na="_zoom_delta",_a={has:e=>"interval"===e.type&&e.zoom,signals:(e,t,n)=>{const i=t.name,r=Fa.has(t),o=i+Na,{x:s,y:a}=t.project.hasChannel,c=u(e.scaleName(Ie)),l=u(e.scaleName(He));let d=xs(t.zoom,"scope");return r||(d=d.map(e=>(e.markname=i+La,e))),n.push({name:i+Ba,on:[{events:d,update:r?"{"+[c?`x: invert(${c}, x(unit))`:"",l?`y: invert(${l}, y(unit))`:""].filter(e=>!!e).join(", ")+"}":"{x: x(unit), y: y(unit)}"}]},{name:o,on:[{events:d,force:!0,update:"pow(1.001, event.deltaY * pow(16, event.deltaMode))"}]}),void 0!==s&&za(e,t,s,"width",n),void 0!==a&&za(e,t,a,"height",n),n}};function za(e,t,n,i,r){var o;const s=t.name,a=n.channel,u=Fa.has(t),c=r.filter(e=>e.name===n.signals[u?"data":"visual"])[0],l=e.getSizeSignalRef(i).signal,d=e.getScaleComponent(a),f=d.get("type"),p=u?Ca(e,a):c.name,g=s+Na,h=`${u?"log"===f?"zoomLog":"pow"===f?"zoomPow":"zoomLinear":"zoomLinear"}(${p}, ${`${s}${Ba}.${a}`}, ${g}`+(u&&"pow"===f?`, ${o=d.get("exponent"),null!=o?o:1}`:"")+")";c.on.push({events:{signal:g},update:u?h:`clampRange(${h}, 0, ${l})`})}const Ta=[{has:()=>!0,parse:(e,t,n)=>{var i,r,s;const a=t.name,u=null!=(i=t.project)?i:t.project=new xa,c={},l={},d=new Set,f=(e,t)=>{const n="visual"===t?e.channel:e.field;let i=Q(`${a}_${n}`);for(let e=1;d.has(i);e++)i=Q(`${a}_${n}_${e}`);return d.add(i),{[t]:i}};if(!n.fields&&!n.encodings){const t=e.config.selection[n.type];if(n.init)for(const e of x(n.init))for(const i of Y(e))Ft(i)?(n.encodings||(n.encodings=[])).push(i):"interval"===n.type?(Qt('Interval selections should be initialized using "x" and/or "y" keys.'),n.encodings=t.encodings):(n.fields||(n.fields=[])).push(i);else n.encodings=t.encodings,n.fields=t.fields}for(const e of null!=(r=n.fields)?r:[]){const t={type:"E",field:e};t.signals=Object.assign({},f(t,"data")),u.items.push(t),u.hasField[e]=t}for(const i of null!=(s=n.encodings)?s:[]){const n=e.fieldDef(i);if(n){let r=n.field;if(n.aggregate){Qt(Ht.cannotProjectAggregate(i,n.aggregate));continue}if(!r){Qt(Ht.cannotProjectOnChannelWithoutField(i));continue}if(n.timeUnit){r=e.vgField(i);const t={as:r,field:n.field,timeUnit:n.timeUnit};l[P(t)]=t}if(!c[r]){let o="E";if("interval"===t.type){Yn(e.getScaleComponent(i).get("type"))&&(o="R")}else n.bin&&(o="R-RE");const s={field:r,channel:i,type:o};s.signals=Object.assign(Object.assign({},f(s,"data")),f(s,"visual")),u.items.push(c[r]=s),u.hasField[r]=u.hasChannel[i]=c[r]}}else Qt(Ht.cannotProjectOnChannelWithoutField(i))}if(n.init){const e=e=>u.items.map(t=>void 0!==e[t.channel]?e[t.channel]:e[t.field]);if("interval"===n.type)t.init=e(n.init);else{const i=o(n.init)?n.init:[n.init];t.init=i.map(e)}}Y(l).length>0&&(u.timeUnit=new va(null,l))},signals:(e,t,n)=>{const i=t.name+ya;return n.filter(e=>e.name===i).length>0?n:n.concat({name:i,value:t.project.items.map(e=>{const t=$e(e,["signals","hasLegend"]),n=N(t);return n.field=te(n.field),n})})}},Oa,Fa,Da,ka,_a,Aa,ha,wa];function Pa(e,t){for(const n of Ta)n.has(e)&&t(n)}function Ma(e,t=!0,n=l){if(o(e)){const i=e.map(e=>Ma(e,t,n));return t?`[${i.join(", ")}]`:i}return Zt(e)?n(rn(e,!1,!t)):t?n(JSON.stringify(e)):e}function Ua(e,t){return Ka(e,(n,i)=>{t=i.marks?i.marks(e,n,t):t,Pa(n,i=>{i.marks&&(t=i.marks(e,n,t))})}),t}function Ra(e){return e.map(e=>(e.on&&!e.on.length&&delete e.on,e))}const La="_brush",Wa="_scale_trigger",qa={signals:(e,t)=>{const n=t.name,i=n+ya,r=Fa.has(t),o=[],s=[],a=[];if(t.translate&&!r){const e=`!event.item || event.item.mark.name !== ${u(n+La)}`;Ia(t,(t,n)=>{var i;const r=x(null!=(i=n.between[0].filter)?i:n.between[0].filter=[]);return r.indexOf(e)<0&&r.push(e),t})}t.project.items.forEach((n,i)=>{const r=n.channel;if(r!==Ie&&r!==He)return void Qt("Interval selections only support x and y encoding channels.");const c=t.init?t.init[i]:null,l=function(e,t,n,i){const r=n.channel,o=n.signals.visual,s=n.signals.data,a=Fa.has(t),c=u(e.scaleName(r)),l=e.getScaleComponent(r),d=l?l.get("type"):void 0,f=e=>`scale(${c}, ${e})`,p=e.getSizeSignalRef(r===Ie?"width":"height").signal,g=`${r}(unit)`,h=Ia(t,(e,t)=>[...e,{events:t.between[0],update:`[${g}, ${g}]`},{events:t,update:`[${o}[0], clamp(${g}, 0, ${p})]`}]);return h.push({events:{signal:t.name+Wa},update:Yn(d)?`[${f(`${s}[0]`)}, ${f(`${s}[1]`)}]`:"[0, 0]"}),a?[{name:s,on:[]}]:[Object.assign(Object.assign({name:o},i?{init:Ma(i,!0,f)}:{value:[]}),{on:h}),Object.assign(Object.assign({name:s},i?{init:Ma(i)}:{}),{on:[{events:{signal:o},update:`${o}[0] === ${o}[1] ? null : invert(${c}, ${o})`}]})]}(e,t,n,c),d=n.signals.data,f=n.signals.visual,p=u(e.scaleName(r)),g=Yn(e.getScaleComponent(r).get("type"))?"+":"";o.push(...l),s.push(d),a.push({scaleName:e.scaleName(r),expr:`(!isArray(${d}) || `+`(${g}invert(${p}, ${f})[0] === ${g}${d}[0] && `+`${g}invert(${p}, ${f})[1] === ${g}${d}[1]))`})}),r||o.push({name:n+Wa,value:{},on:[{events:a.map(e=>({scale:e.scaleName})),update:a.map(e=>e.expr).join(" && ")+` ? ${n+Wa} : {}`}]});const c=t.init,l=`unit: ${eu(e)}, fields: ${i}, values`;return o.concat(Object.assign(Object.assign({name:n+Ja},c?{init:`{${l}: ${Ma(c)}}`}:{}),{on:[{events:[{signal:s.join(" || ")}],update:s.join(" && ")+` ? {${l}: [${s}]} : null`}]}))},modifyExpr:(e,t)=>{return t.name+Ja+", "+("global"===t.resolve?"true":`{unit: ${eu(e)}}`)},marks:(e,t,n)=>{const i=t.name,{x:r,y:o}=t.project.hasChannel,s=r&&r.signals.visual,a=o&&o.signals.visual,c=`data(${u(t.name+Va)})`;if(Fa.has(t))return n;const l={x:void 0!==r?{signal:`${s}[0]`}:{value:0},y:void 0!==o?{signal:`${a}[0]`}:{value:0},x2:void 0!==r?{signal:`${s}[1]`}:{field:{group:"width"}},y2:void 0!==o?{signal:`${a}[1]`}:{field:{group:"height"}}};if("global"===t.resolve)for(const t of Y(l))l[t]=[Object.assign({test:`${c}.length && ${c}[0].unit === ${eu(e)}`},l[t]),{value:0}];const d=t.mark,{fill:f,fillOpacity:p}=d,g=$e(d,["fill","fillOpacity"]),h=Y(g).reduce((e,t)=>(e[t]=[{test:[void 0!==r&&`${s}[0] !== ${s}[1]`,void 0!==o&&`${a}[0] !== ${a}[1]`].filter(e=>e).join(" && "),value:g[t]},{value:null}],e),{});return[{name:i+La+"_bg",type:"rect",clip:!0,encode:{enter:{fill:{value:f},fillOpacity:{value:p}},update:l}},...n,{name:i+La,type:"rect",clip:!0,encode:{enter:{fill:{value:"transparent"}},update:Object.assign(Object.assign({},l),h)}}]}};function Ia(e,t){return e.events.reduce((e,n)=>n.between?t(e,n):(Qt(`${n} is not an ordered event stream for interval selections.`),e),[])}function Ha(e,t){const n=t.name,i=n+ya,r=t.project,o="(item().isVoronoi ? datum.datum : datum)",s=r.items.map(t=>{const n=e.fieldDef(t.channel);return n&&n.bin?`[${o}[${u(e.vgField(t.channel,{}))}], `+`${o}[${u(e.vgField(t.channel,{binSuffix:"end"}))}]]`:`${o}[${u(t.field)}]`}).join(", "),a=`unit: ${eu(e)}, fields: ${i}, values`,c=t.events;return[{name:n+Ja,on:c?[{events:c,update:`datum && item().mark.marktype !== 'group' ? {${a}: [${s}]} : null`,force:!0}]:[]}]}const Ga={signals:Ha,modifyExpr:(e,t)=>{return t.name+Ja+", "+("global"===t.resolve?"null":`{unit: ${eu(e)}}`)}},Ya={signals:Ha,modifyExpr:(e,t)=>{return t.name+Ja+", "+("global"===t.resolve?"true":`{unit: ${eu(e)}}`)}},Va="_store",Ja="_tuple",Qa="_modify",Xa="vlSelectionResolve",Za={single:Ya,multi:Ga,interval:qa};function Ka(e,t){const n=e.component.selection;if(n)for(const e in n)if(O(n,e)){const i=n[e];if(!0===t(i,Za[i.type]))break}}function eu(e,{escape:t}={escape:!0}){let n=t?u(e.name):e.name;const i=function(e){let t=e.parent;for(;t&&!yf(t);)t=t.parent;return t}(e);if(i){const{facet:e}=i;for(const t of yt)e[t]&&(n+=` + '__facet_${t}_' + (facet[${u(i.vgField(t))}])`)}return n}function tu(e){let t=!1;return Ka(e,e=>{t=t||e.project.items.some(e=>e.field===Jr)}),t}var nu,iu,ru,ou,su,au="RawCode",uu="Literal",cu="Property",lu="Identifier",du="ArrayExpression",fu="BinaryExpression",pu="CallExpression",gu="ConditionalExpression",hu="LogicalExpression",mu="MemberExpression",bu="ObjectExpression",vu="UnaryExpression";function yu(e){this.type=e}yu.prototype.visit=function(e){var t,n,i;if(e(this))return 1;for(n=0,i=(t=function(e){switch(e.type){case du:return e.elements;case fu:case hu:return[e.left,e.right];case pu:var t=e.arguments.slice();return t.unshift(e.callee),t;case gu:return[e.test,e.consequent,e.alternate];case mu:return[e.object,e.property];case bu:return e.properties;case cu:return[e.key,e.value];case vu:return[e.argument];case lu:case uu:case au:default:return[]}}(this)).length;n<i;++n)if(t[n].visit(e))return 1};var xu=1,Au=2,Ou=3,wu=4,Fu=5,Cu=6,ju=7,Du=8;(nu={})[xu]="Boolean",nu[Au]="<end>",nu[Ou]="Identifier",nu[wu]="Keyword",nu[Fu]="Null",nu[Cu]="Numeric",nu[ju]="Punctuator",nu[Du]="String",nu[9]="RegularExpression";var Eu="ArrayExpression",Su="BinaryExpression",ku="CallExpression",$u="ConditionalExpression",Bu="Identifier",Nu="Literal",_u="LogicalExpression",zu="MemberExpression",Tu="ObjectExpression",Pu="Property",Mu="UnaryExpression",Uu="Unexpected token %0",Ru="Unexpected number",Lu="Unexpected string",Wu="Unexpected identifier",qu="Unexpected reserved word",Iu="Unexpected end of input",Hu="Invalid regular expression",Gu="Invalid regular expression: missing /",Yu="Octal literals are not allowed in strict mode.",Vu="Duplicate data property in object literal not allowed in strict mode",Ju="ILLEGAL",Qu="Disabled.",Xu=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0620-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0800-\\u0815\\u081A\\u0824\\u0828\\u0840-\\u0858\\u08A0-\\u08B2\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971-\\u0980\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0CF1\\u0CF2\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D\\u0D4E\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC-\\u0EDF\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8C\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1A20-\\u1A54\\u1AA7\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1BBA-\\u1BE5\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1CE9-\\u1CEC\\u1CEE-\\u1CF1\\u1CF5\\u1CF6\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u209C\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CEE\\u2CF2\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA66E\\uA67F-\\uA69D\\uA6A0-\\uA6EF\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA8F2-\\uA8F7\\uA8FB\\uA90A-\\uA925\\uA930-\\uA946\\uA960-\\uA97C\\uA984-\\uA9B2\\uA9CF\\uA9E0-\\uA9E4\\uA9E6-\\uA9EF\\uA9FA-\\uA9FE\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAA60-\\uAA76\\uAA7A\\uAA7E-\\uAAAF\\uAAB1\\uAAB5\\uAAB6\\uAAB9-\\uAABD\\uAAC0\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEA\\uAAF2-\\uAAF4\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABE2\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),Zu=new RegExp("[\\xAA\\xB5\\xBA\\xC0-\\xD6\\xD8-\\xF6\\xF8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0300-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u037F\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u0483-\\u0487\\u048A-\\u052F\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0610-\\u061A\\u0620-\\u0669\\u066E-\\u06D3\\u06D5-\\u06DC\\u06DF-\\u06E8\\u06EA-\\u06FC\\u06FF\\u0710-\\u074A\\u074D-\\u07B1\\u07C0-\\u07F5\\u07FA\\u0800-\\u082D\\u0840-\\u085B\\u08A0-\\u08B2\\u08E4-\\u0963\\u0966-\\u096F\\u0971-\\u0983\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC-\\u09C4\\u09C7\\u09C8\\u09CB-\\u09CE\\u09D7\\u09DC\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09F1\\u0A01-\\u0A03\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A3C\\u0A3E-\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A59-\\u0A5C\\u0A5E\\u0A66-\\u0A75\\u0A81-\\u0A83\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABC-\\u0AC5\\u0AC7-\\u0AC9\\u0ACB-\\u0ACD\\u0AD0\\u0AE0-\\u0AE3\\u0AE6-\\u0AEF\\u0B01-\\u0B03\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3C-\\u0B44\\u0B47\\u0B48\\u0B4B-\\u0B4D\\u0B56\\u0B57\\u0B5C\\u0B5D\\u0B5F-\\u0B63\\u0B66-\\u0B6F\\u0B71\\u0B82\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BBE-\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCD\\u0BD0\\u0BD7\\u0BE6-\\u0BEF\\u0C00-\\u0C03\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C39\\u0C3D-\\u0C44\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C58\\u0C59\\u0C60-\\u0C63\\u0C66-\\u0C6F\\u0C81-\\u0C83\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBC-\\u0CC4\\u0CC6-\\u0CC8\\u0CCA-\\u0CCD\\u0CD5\\u0CD6\\u0CDE\\u0CE0-\\u0CE3\\u0CE6-\\u0CEF\\u0CF1\\u0CF2\\u0D01-\\u0D03\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D3A\\u0D3D-\\u0D44\\u0D46-\\u0D48\\u0D4A-\\u0D4E\\u0D57\\u0D60-\\u0D63\\u0D66-\\u0D6F\\u0D7A-\\u0D7F\\u0D82\\u0D83\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0DCA\\u0DCF-\\u0DD4\\u0DD6\\u0DD8-\\u0DDF\\u0DE6-\\u0DEF\\u0DF2\\u0DF3\\u0E01-\\u0E3A\\u0E40-\\u0E4E\\u0E50-\\u0E59\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB9\\u0EBB-\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EC8-\\u0ECD\\u0ED0-\\u0ED9\\u0EDC-\\u0EDF\\u0F00\\u0F18\\u0F19\\u0F20-\\u0F29\\u0F35\\u0F37\\u0F39\\u0F3E-\\u0F47\\u0F49-\\u0F6C\\u0F71-\\u0F84\\u0F86-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u1000-\\u1049\\u1050-\\u109D\\u10A0-\\u10C5\\u10C7\\u10CD\\u10D0-\\u10FA\\u10FC-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u135D-\\u135F\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u167F\\u1681-\\u169A\\u16A0-\\u16EA\\u16EE-\\u16F8\\u1700-\\u170C\\u170E-\\u1714\\u1720-\\u1734\\u1740-\\u1753\\u1760-\\u176C\\u176E-\\u1770\\u1772\\u1773\\u1780-\\u17D3\\u17D7\\u17DC\\u17DD\\u17E0-\\u17E9\\u180B-\\u180D\\u1810-\\u1819\\u1820-\\u1877\\u1880-\\u18AA\\u18B0-\\u18F5\\u1900-\\u191E\\u1920-\\u192B\\u1930-\\u193B\\u1946-\\u196D\\u1970-\\u1974\\u1980-\\u19AB\\u19B0-\\u19C9\\u19D0-\\u19D9\\u1A00-\\u1A1B\\u1A20-\\u1A5E\\u1A60-\\u1A7C\\u1A7F-\\u1A89\\u1A90-\\u1A99\\u1AA7\\u1AB0-\\u1ABD\\u1B00-\\u1B4B\\u1B50-\\u1B59\\u1B6B-\\u1B73\\u1B80-\\u1BF3\\u1C00-\\u1C37\\u1C40-\\u1C49\\u1C4D-\\u1C7D\\u1CD0-\\u1CD2\\u1CD4-\\u1CF6\\u1CF8\\u1CF9\\u1D00-\\u1DF5\\u1DFC-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u200C\\u200D\\u203F\\u2040\\u2054\\u2071\\u207F\\u2090-\\u209C\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2160-\\u2188\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2CE4\\u2CEB-\\u2CF3\\u2D00-\\u2D25\\u2D27\\u2D2D\\u2D30-\\u2D67\\u2D6F\\u2D7F-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2DE0-\\u2DFF\\u2E2F\\u3005-\\u3007\\u3021-\\u302F\\u3031-\\u3035\\u3038-\\u303C\\u3041-\\u3096\\u3099\\u309A\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31BA\\u31F0-\\u31FF\\u3400-\\u4DB5\\u4E00-\\u9FCC\\uA000-\\uA48C\\uA4D0-\\uA4FD\\uA500-\\uA60C\\uA610-\\uA62B\\uA640-\\uA66F\\uA674-\\uA67D\\uA67F-\\uA69D\\uA69F-\\uA6F1\\uA717-\\uA71F\\uA722-\\uA788\\uA78B-\\uA78E\\uA790-\\uA7AD\\uA7B0\\uA7B1\\uA7F7-\\uA827\\uA840-\\uA873\\uA880-\\uA8C4\\uA8D0-\\uA8D9\\uA8E0-\\uA8F7\\uA8FB\\uA900-\\uA92D\\uA930-\\uA953\\uA960-\\uA97C\\uA980-\\uA9C0\\uA9CF-\\uA9D9\\uA9E0-\\uA9FE\\uAA00-\\uAA36\\uAA40-\\uAA4D\\uAA50-\\uAA59\\uAA60-\\uAA76\\uAA7A-\\uAAC2\\uAADB-\\uAADD\\uAAE0-\\uAAEF\\uAAF2-\\uAAF6\\uAB01-\\uAB06\\uAB09-\\uAB0E\\uAB11-\\uAB16\\uAB20-\\uAB26\\uAB28-\\uAB2E\\uAB30-\\uAB5A\\uAB5C-\\uAB5F\\uAB64\\uAB65\\uABC0-\\uABEA\\uABEC\\uABED\\uABF0-\\uABF9\\uAC00-\\uD7A3\\uD7B0-\\uD7C6\\uD7CB-\\uD7FB\\uF900-\\uFA6D\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE00-\\uFE0F\\uFE20-\\uFE2D\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF10-\\uFF19\\uFF21-\\uFF3A\\uFF3F\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]");function Ku(e,t){if(!e)throw new Error("ASSERT: "+t)}function ec(e){return e>=48&&e<=57}function tc(e){return"0123456789abcdefABCDEF".indexOf(e)>=0}function nc(e){return"01234567".indexOf(e)>=0}function ic(e){return 32===e||9===e||11===e||12===e||160===e||e>=5760&&[5760,6158,8192,8193,8194,8195,8196,8197,8198,8199,8200,8201,8202,8239,8287,12288,65279].indexOf(e)>=0}function rc(e){return 10===e||13===e||8232===e||8233===e}function oc(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||92===e||e>=128&&Xu.test(String.fromCharCode(e))}function sc(e){return 36===e||95===e||e>=65&&e<=90||e>=97&&e<=122||e>=48&&e<=57||92===e||e>=128&&Zu.test(String.fromCharCode(e))}var ac={if:1,in:1,do:1,var:1,for:1,new:1,try:1,let:1,this:1,else:1,case:1,void:1,with:1,enum:1,while:1,break:1,catch:1,throw:1,const:1,yield:1,class:1,super:1,return:1,typeof:1,delete:1,switch:1,export:1,import:1,public:1,static:1,default:1,finally:1,extends:1,package:1,private:1,function:1,continue:1,debugger:1,interface:1,protected:1,instanceof:1,implements:1};function uc(){for(var e;ru<ou&&(ic(e=iu.charCodeAt(ru))||rc(e));)++ru}function cc(e){var t,n,i,r=0;for(n="u"===e?4:2,t=0;t<n;++t)ru<ou&&tc(iu[ru])?(i=iu[ru++],r=16*r+"0123456789abcdef".indexOf(i.toLowerCase())):Cc({},Uu,Ju);return String.fromCharCode(r)}function lc(){var e,t,n,i;for(t=0,"}"===(e=iu[ru])&&Cc({},Uu,Ju);ru<ou&&tc(e=iu[ru++]);)t=16*t+"0123456789abcdef".indexOf(e.toLowerCase());return(t>1114111||"}"!==e)&&Cc({},Uu,Ju),t<=65535?String.fromCharCode(t):(n=55296+(t-65536>>10),i=56320+(t-65536&1023),String.fromCharCode(n,i))}function dc(){var e,t;for(e=iu.charCodeAt(ru++),t=String.fromCharCode(e),92===e&&(117!==iu.charCodeAt(ru)&&Cc({},Uu,Ju),++ru,(e=cc("u"))&&"\\"!==e&&oc(e.charCodeAt(0))||Cc({},Uu,Ju),t=e);ru<ou&&sc(e=iu.charCodeAt(ru));)++ru,t+=String.fromCharCode(e),92===e&&(t=t.substr(0,t.length-1),117!==iu.charCodeAt(ru)&&Cc({},Uu,Ju),++ru,(e=cc("u"))&&"\\"!==e&&sc(e.charCodeAt(0))||Cc({},Uu,Ju),t+=e);return t}function fc(){var e,t;return e=ru,{type:1===(t=92===iu.charCodeAt(ru)?dc():function(){var e,t;for(e=ru++;ru<ou;){if(92===(t=iu.charCodeAt(ru)))return ru=e,dc();if(!sc(t))break;++ru}return iu.slice(e,ru)}()).length?Ou:ac.hasOwnProperty(t)?wu:"null"===t?Fu:"true"===t||"false"===t?xu:Ou,value:t,start:e,end:ru}}function pc(){var e,t,n,i,r=ru,o=iu.charCodeAt(ru),s=iu[ru];switch(o){case 46:case 40:case 41:case 59:case 44:case 123:case 125:case 91:case 93:case 58:case 63:case 126:return++ru,{type:ju,value:String.fromCharCode(o),start:r,end:ru};default:if(61===(e=iu.charCodeAt(ru+1)))switch(o){case 43:case 45:case 47:case 60:case 62:case 94:case 124:case 37:case 38:case 42:return ru+=2,{type:ju,value:String.fromCharCode(o)+String.fromCharCode(e),start:r,end:ru};case 33:case 61:return ru+=2,61===iu.charCodeAt(ru)&&++ru,{type:ju,value:iu.slice(r,ru),start:r,end:ru}}}return">>>="===(i=iu.substr(ru,4))?{type:ju,value:i,start:r,end:ru+=4}:">>>"===(n=i.substr(0,3))||"<<="===n||">>="===n?{type:ju,value:n,start:r,end:ru+=3}:s===(t=n.substr(0,2))[1]&&"+-<>&|".indexOf(s)>=0||"=>"===t?{type:ju,value:t,start:r,end:ru+=2}:"<>=!+-*%&|^/".indexOf(s)>=0?(++ru,{type:ju,value:s,start:r,end:ru}):void Cc({},Uu,Ju)}function gc(){var e,t,n;if(Ku(ec((n=iu[ru]).charCodeAt(0))||"."===n,"Numeric literal must start with a decimal digit or a decimal point"),t=ru,e="","."!==n){if(e=iu[ru++],n=iu[ru],"0"===e){if("x"===n||"X"===n)return++ru,function(e){for(var t="";ru<ou&&tc(iu[ru]);)t+=iu[ru++];return 0===t.length&&Cc({},Uu,Ju),oc(iu.charCodeAt(ru))&&Cc({},Uu,Ju),{type:Cu,value:parseInt("0x"+t,16),start:e,end:ru}}(t);if(nc(n))return function(e){for(var t="0"+iu[ru++];ru<ou&&nc(iu[ru]);)t+=iu[ru++];return(oc(iu.charCodeAt(ru))||ec(iu.charCodeAt(ru)))&&Cc({},Uu,Ju),{type:Cu,value:parseInt(t,8),octal:!0,start:e,end:ru}}(t);n&&ec(n.charCodeAt(0))&&Cc({},Uu,Ju)}for(;ec(iu.charCodeAt(ru));)e+=iu[ru++];n=iu[ru]}if("."===n){for(e+=iu[ru++];ec(iu.charCodeAt(ru));)e+=iu[ru++];n=iu[ru]}if("e"===n||"E"===n)if(e+=iu[ru++],"+"!==(n=iu[ru])&&"-"!==n||(e+=iu[ru++]),ec(iu.charCodeAt(ru)))for(;ec(iu.charCodeAt(ru));)e+=iu[ru++];else Cc({},Uu,Ju);return oc(iu.charCodeAt(ru))&&Cc({},Uu,Ju),{type:Cu,value:parseFloat(e),start:t,end:ru}}function hc(){var e,t,n,i;return su=null,uc(),e=ru,t=function(){var e,t,n,i;for(Ku("/"===(e=iu[ru]),"Regular expression literal must start with a slash"),t=iu[ru++],n=!1,i=!1;ru<ou;)if(t+=e=iu[ru++],"\\"===e)rc((e=iu[ru++]).charCodeAt(0))&&Cc({},Gu),t+=e;else if(rc(e.charCodeAt(0)))Cc({},Gu);else if(n)"]"===e&&(n=!1);else{if("/"===e){i=!0;break}"["===e&&(n=!0)}return i||Cc({},Gu),{value:t.substr(1,t.length-2),literal:t}}(),n=function(){var e,t,n;for(t="",n="";ru<ou&&sc((e=iu[ru]).charCodeAt(0));)++ru,"\\"===e&&ru<ou?Cc({},Uu,Ju):(n+=e,t+=e);return n.search(/[^gimuy]/g)>=0&&Cc({},Hu,n),{value:n,literal:t}}(),i=function(e,t){var n=e;t.indexOf("u")>=0&&(n=n.replace(/\\u\{([0-9a-fA-F]+)\}/g,(function(e,t){if(parseInt(t,16)<=1114111)return"x";Cc({},Hu)})).replace(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,"x"));try{new RegExp(n)}catch(e){Cc({},Hu)}try{return new RegExp(e,t)}catch(e){return null}}(t.value,n.value),{literal:t.literal+n.literal,value:i,regex:{pattern:t.value,flags:n.value},start:e,end:ru}}function mc(){var e;return uc(),ru>=ou?{type:Au,start:ru,end:ru}:oc(e=iu.charCodeAt(ru))?fc():40===e||41===e||59===e?pc():39===e||34===e?function(){var e,t,n,i,r="",o=!1;for(Ku("'"===(e=iu[ru])||'"'===e,"String literal must starts with a quote"),t=ru,++ru;ru<ou;){if((n=iu[ru++])===e){e="";break}if("\\"===n)if((n=iu[ru++])&&rc(n.charCodeAt(0)))"\r"===n&&"\n"===iu[ru]&&++ru;else switch(n){case"u":case"x":"{"===iu[ru]?(++ru,r+=lc()):r+=cc(n);break;case"n":r+="\n";break;case"r":r+="\r";break;case"t":r+="\t";break;case"b":r+="\b";break;case"f":r+="\f";break;case"v":r+="\v";break;default:nc(n)?(0!==(i="01234567".indexOf(n))&&(o=!0),ru<ou&&nc(iu[ru])&&(o=!0,i=8*i+"01234567".indexOf(iu[ru++]),"0123".indexOf(n)>=0&&ru<ou&&nc(iu[ru])&&(i=8*i+"01234567".indexOf(iu[ru++]))),r+=String.fromCharCode(i)):r+=n}else{if(rc(n.charCodeAt(0)))break;r+=n}}return""!==e&&Cc({},Uu,Ju),{type:Du,value:r,octal:o,start:t,end:ru}}():46===e?ec(iu.charCodeAt(ru+1))?gc():pc():ec(e)?gc():pc()}function bc(){var e;return ru=(e=su).end,su=mc(),ru=e.end,e}function vc(){var e;e=ru,su=mc(),ru=e}function yc(e,t,n){var i=new yu("||"===e||"&&"===e?_u:Su);return i.operator=e,i.left=t,i.right=n,i}function xc(e,t){var n=new yu(ku);return n.callee=e,n.arguments=t,n}function Ac(e){var t=new yu(Bu);return t.name=e,t}function Oc(e){var t=new yu(Nu);return t.value=e.value,t.raw=iu.slice(e.start,e.end),e.regex&&("//"===t.raw&&(t.raw="/(?:)/"),t.regex=e.regex),t}function wc(e,t,n){var i=new yu(zu);return i.computed="["===e,i.object=t,i.property=n,i.computed||(n.member=!0),i}function Fc(e,t,n){var i=new yu(Pu);return i.key=t,i.value=n,i.kind=e,i}function Cc(e,t){var n,i=Array.prototype.slice.call(arguments,2),r=t.replace(/%(\d)/g,(function(e,t){return Ku(t<i.length,"Message reference must be in range"),i[t]}));throw(n=new Error(r)).index=ru,n.description=r,n}function jc(e){e.type===Au&&Cc(e,Iu),e.type===Cu&&Cc(e,Ru),e.type===Du&&Cc(e,Lu),e.type===Ou&&Cc(e,Wu),e.type===wu&&Cc(e,qu),Cc(e,Uu,e.value)}function Dc(e){var t=bc();t.type===ju&&t.value===e||jc(t)}function Ec(e){return su.type===ju&&su.value===e}function Sc(e){return su.type===wu&&su.value===e}function kc(){var e=[];for(ru=su.start,Dc("[");!Ec("]");)Ec(",")?(bc(),e.push(null)):(e.push(Wc()),Ec("]")||Dc(","));return bc(),function(e){var t=new yu(Eu);return t.elements=e,t}(e)}function $c(){var e;return ru=su.start,(e=bc()).type===Du||e.type===Cu?(e.octal&&Cc(e,Yu),Oc(e)):Ac(e.value)}function Bc(){var e,t,n;return ru=su.start,(e=su).type===Ou?(n=$c(),Dc(":"),Fc("init",n,Wc())):e.type!==Au&&e.type!==ju?(t=$c(),Dc(":"),Fc("init",t,Wc())):void jc(e)}function Nc(){var e,t,n=[],i={},r=String;for(ru=su.start,Dc("{");!Ec("}");)t="$"+((e=Bc()).key.type===Bu?e.key.name:r(e.key.value)),Object.prototype.hasOwnProperty.call(i,t)?Cc({},Vu):i[t]=!0,n.push(e),Ec("}")||Dc(",");return Dc("}"),function(e){var t=new yu(Tu);return t.properties=e,t}(n)}var _c={if:1,this:1};function zc(){var e,t,n;if(Ec("("))return function(){var e;return Dc("("),e=qc(),Dc(")"),e}();if(Ec("["))return kc();if(Ec("{"))return Nc();if(e=su.type,ru=su.start,e===Ou||_c[su.value])n=Ac(bc().value);else if(e===Du||e===Cu)su.octal&&Cc(su,Yu),n=Oc(bc());else{if(e===wu)throw new Error(Qu);e===xu?((t=bc()).value="true"===t.value,n=Oc(t)):e===Fu?((t=bc()).value=null,n=Oc(t)):Ec("/")||Ec("/=")?(n=Oc(hc()),vc()):jc(bc())}return n}function Tc(){var e=[];if(Dc("("),!Ec(")"))for(;ru<ou&&(e.push(Wc()),!Ec(")"));)Dc(",");return Dc(")"),e}function Pc(){var e;return ru=su.start,function(e){return e.type===Ou||e.type===wu||e.type===xu||e.type===Fu}(e=bc())||jc(e),Ac(e.value)}function Mc(){var e;return Dc("["),e=qc(),Dc("]"),e}function Uc(){var e=function(){var e;for(e=zc();;)if(Ec("."))Dc("."),e=wc(".",e,Pc());else if(Ec("("))e=xc(e,Tc());else{if(!Ec("["))break;e=wc("[",e,Mc())}return e}();if(su.type===ju&&(Ec("++")||Ec("--")))throw new Error(Qu);return e}function Rc(){var e,t,n,i,r;if(su.type!==ju&&su.type!==wu)t=Uc();else{if(Ec("++")||Ec("--"))throw new Error(Qu);if(Ec("+")||Ec("-")||Ec("~")||Ec("!"))e=bc(),t=Rc(),n=e.value,i=t,(r=new yu(Mu)).operator=n,r.argument=i,r.prefix=!0,t=r;else{if(Sc("delete")||Sc("void")||Sc("typeof"))throw new Error(Qu);t=Uc()}}return t}function Lc(e){var t=0;if(e.type!==ju&&e.type!==wu)return 0;switch(e.value){case"||":t=1;break;case"&&":t=2;break;case"|":t=3;break;case"^":t=4;break;case"&":t=5;break;case"==":case"!=":case"===":case"!==":t=6;break;case"<":case">":case"<=":case">=":case"instanceof":case"in":t=7;break;case"<<":case">>":case">>>":t=8;break;case"+":case"-":t=9;break;case"*":case"/":case"%":t=11}return t}function Wc(){var e,t;return e=function(){var e,t,n,i,r,o,s,a,u,c;if(e=su,u=Rc(),0===(r=Lc(i=su)))return u;for(i.prec=r,bc(),t=[e,su],o=[u,i,s=Rc()];(r=Lc(su))>0;){for(;o.length>2&&r<=o[o.length-2].prec;)s=o.pop(),a=o.pop().value,u=o.pop(),t.pop(),n=yc(a,u,s),o.push(n);(i=bc()).prec=r,o.push(i),t.push(su),n=Rc(),o.push(n)}for(n=o[c=o.length-1],t.pop();c>1;)t.pop(),n=yc(o[c-1].value,o[c-2],n),c-=2;return n}(),Ec("?")&&(bc(),t=Wc(),Dc(":"),e=function(e,t,n){var i=new yu($u);return i.test=e,i.consequent=t,i.alternate=n,i}(e,t,Wc())),e}function qc(){var e=Wc();if(Ec(","))throw new Error(Qu);return e}function Ic(e){const t=function(e){ru=0,ou=(iu=e).length,su=null,vc();var t=qc();if(su.type!==Au)throw new Error("Unexpect token after expression.");return t}(e),n=new Set;return t.visit(e=>{"MemberExpression"===e.type&&function e(t){return"MemberExpression"===t.object.type?e(t.object):"datum"===t.object.name}(e)&&n.add(function e(t){const n=[];return"Identifier"===t.type?[t.name]:"Literal"===t.type?[t.value]:("MemberExpression"===t.type&&(n.push(...e(t.object)),n.push(...e(t.property))),n)}(e).slice(1).join("."))}),n}class Hc extends ma{constructor(e,t,n){super(e),this.model=t,this.filter=n,this.expr=Vc(this.model,this.filter,this),this._dependentFields=Ic(this.expr)}clone(){return new Hc(null,this.model,N(this.filter))}dependentFields(){return this._dependentFields}producedFields(){return new Set}assemble(){return{type:"filter",expr:this.expr}}hash(){return`Filter ${this.expr}`}}function Gc(e,t,n,i="datum"){const r=[];const o=X(t,(function(t){const o=Q(t),s=e.getSelectionComponent(o,t),a=u(o+Va);if(s.project.timeUnit){const t=null!=n?n:e.component.data.raw,i=s.project.timeUnit.clone();t.parent?i.insertAsParentOf(t):t.parent=i}return"none"!==s.empty&&r.push(a),`vlSelectionTest(${a}, ${i}`+("global"===s.resolve?")":`, ${u(s.resolve)})`)}));return(r.length?"!("+r.map(e=>`length(data(${e}))`).join(" || ")+") || ":"")+`(${o})`}function Yc(e,t){const n=t.encoding;let i=t.field;if(n||i){if(n&&!i){const r=e.project.items.filter(e=>e.channel===n);!r.length||r.length>1?(i=e.project.items[0].field,Qt((r.length?"Multiple ":"No ")+`matching ${u(n)} encoding found for selection ${u(t.selection)}. `+`Using "field": ${u(i)}.`)):i=r[0].field}}else i=e.project.items[0].field,e.project.items.length>1&&Qt('A "field" or "encoding" must be specified when using a selection as a scale domain. '+`Using "field": ${u(i)}.`);return`${e.name}[${u(i)}]`}function Vc(e,t,n){return X(t,t=>a(t)?t:function(e){var t;return null===(t=e)||void 0===t?void 0:t.selection}(t)?Gc(e,t.selection,n):jn(t))}function Jc(e,t,n,i){var r,o,s;e.encode=null!=(r=e.encode)?r:{},e.encode[t]=null!=(o=e.encode[t])?o:{},e.encode[t].update=null!=(s=e.encode[t].update)?s:{},e.encode[t].update[n]=i}function Qc(e,t,n,i={header:!1}){var r,s;const a=e.combine(),{orient:u,scale:c,labelExpr:l,title:d,zindex:f}=a,p=$e(a,["orient","scale","labelExpr","title","zindex"]);if(Y(p).forEach(e=>{const n=bs[e],i=p[e];if(n&&n!==t&&"both"!==n)delete p[e];else if(function(e){return e.condition}(i)){const{vgProp:t,part:n}=hs[e],{condition:r,value:s}=i,a=[...(o(r)?r:[r]).map(e=>{const{value:t,test:n}=e;return{test:Vc(null,n),value:t}}),{value:s}];Jc(p,n,t,a),delete p[e]}}),"grid"===t){if(!p.grid)return;if(p.encode){const{grid:e}=p.encode;p.encode=Object.assign({},e?{grid:e}:{}),0===Y(p.encode).length&&delete p.encode}return Object.assign(Object.assign({scale:c,orient:u},p),{domain:!1,labels:!1,maxExtent:0,minExtent:0,ticks:!1,zindex:oe(f,0)})}{if(!i.header&&e.mainExtracted)return;if(void 0!==l){let e=l;(null===(s=null===(r=p.encode)||void 0===r?void 0:r.labels)||void 0===s?void 0:s.update)&&ls(p.encode.labels.update.text)&&(e=ne(l,"datum.label",p.encode.labels.update.text.signal)),Jc(p,"labels","text",{signal:e})}if(p.encode){for(const t of ms)e.hasAxisPart(t)||delete p.encode[t];0===Y(p.encode).length&&delete p.encode}const t=function(e,t){if(e)return oi(e)?e:e.map(e=>Qi(e,t)).join(", ")}(d,n);return Object.assign(Object.assign(Object.assign({scale:c,orient:u,grid:!1},t?{title:t}:{}),p),{zindex:oe(f,0)})}}function Xc(e){const{axes:t}=e.component;for(const n of Nt)if(t[n])for(const i of t[n])if(!i.get("gridScale")){const t="x"===n?"height":"width";return[{name:t,update:e.getSizeSignalRef(t).signal}]}return[]}const Zc={titleAlign:"align",titleAnchor:"anchor",titleAngle:"angle",titleBaseline:"baseline",titleColor:"color",titleFont:"font",titleFontSize:"fontSize",titleFontStyle:"fontStyle",titleFontWeight:"fontWeight",titleLimit:"limit",titleLineHeight:"lineHeight",titleOrient:"orient",titlePadding:"offset"},Kc={labelAlign:"align",labelAnchor:"anchor",labelAngle:"angle",labelColor:"color",labelFont:"font",labelFontSize:"fontSize",labelFontStyle:"fontStyle",labelLimit:"limit",labelOrient:"orient",labelPadding:"offset"},el=Y(Zc),tl=Y(Kc);function nl(e,t,n,i,r){var o;const s=[..."band"===r?["axisBand"]:[],"x"===n?"axisX":"axisY",...i?["axis"+i.substr(0,1).toUpperCase()+i.substr(1)]:[],"axis"];for(const n of s)if(void 0!==(null===(o=t[n])||void 0===o?void 0:o[e]))return t[n][e]}function il(e,t){if(void 0!==e)return e=ae(e),"top"===t||"bottom"===t?e<=45||315<=e?"top"===t?"bottom":"top":135<=e&&e<=225?"top"===t?"top":"bottom":"middle":e<=45||315<=e||135<=e&&e<=225?"middle":45<=e&&e<=135?"left"===t?"top":"bottom":"left"===t?"bottom":"top"}function rl(e,t){if(void 0!==e)return e=ae(e),"top"===t||"bottom"===t?e%180==0?"center":0<e&&e<180?"top"===t?"right":"left":"top"===t?"left":"right":(e+90)%180==0?"center":90<=e&&e<270?"left"===t?"left":"right":"left"===t?"right":"left"}function ol(e){switch(e){case Ie:return"bottom";case He:return"left"}throw new Error(Ht.INVALID_CHANNEL_FOR_AXIS)}class sl extends ma{constructor(e,t){super(e),this.transform=t,this._dependentFields=Ic(this.transform.calculate)}clone(){return new sl(null,N(this.transform))}static parseAllForSortIndex(e,t){return t.forEachFieldDef((t,n)=>{if(Ui(t)&&ji(t.sort)){const{field:i,timeUnit:r}=t,o=t.sort,s=o.map((e,t)=>`${jn({field:i,timeUnit:r,equal:e})} ? ${t} : `).join("")+o.length;e=new sl(e,{calculate:s,as:al(t,n,{forAs:!0})})}}),e}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 ${P(this.transform)}`}}function al(e,t,n){return Wi(e,Object.assign({prefix:t,suffix:"sort_index"},null!=n?n:{}))}function ul(e,t){return U(["top","bottom"],t)?"column":U(["left","right"],t)?"row":"row"===e?"row":"column"}function cl(e,t,n,i){const r="row"===i?n.headerRow:"column"===i?n.headerColumn:n.headerFacet;return oe(t&&t.header?t.header[e]:void 0,r[e],n.header[e])}function ll(e,t,n,i){const r={};for(const o of e){const e=cl(o,t,n,i);void 0!==e&&(r[o]=e)}return r}const dl=["row","column"],fl=["header","footer"];function pl(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:o,titleAngle:s,titleOrient:a}=ll(["titleAnchor","titleAngle","titleOrient"],r,i,t),u=ul(t,a);return{name:`${t}-title`,type:"group",role:`${u}-title`,title:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({text:n},"row"===t?{orient:"left"}:{}),{style:"guide-title"}),hl(s,u)),gl(u,s,o)),Ol(i,r,t,el,Zc))}}function gl(e,t,n="middle"){switch(n){case"start":return{align:"left"};case"end":return{align:"right"}}const i=rl(t,"row"===e?"left":"top");return i?{align:i}:{}}function hl(e,t){const n=il(e,"row"===t?"left":"top");return n?{baseline:n}:{}}function ml(e,t){const n=e.component.layoutHeaders[t],i=[];for(const r of fl)if(n[r])for(const o of n[r])i.push(yl(e,t,r,n,o));return i}function bl(e,t){var n;const{sort:i}=e;return Ci(i)?{field:Wi(i,{expr:"datum"}),order:(n=i.order,null!=n?n:"ascending")}:o(i)?{field:al(e,t,{expr:"datum"}),order:"ascending"}:{field:Wi(e,{expr:"datum"}),order:null!=i?i:"ascending"}}function vl(e,t,n){const{format:i,labelAngle:r,labelAnchor:o,labelOrient:s,labelExpr:a}=ll(["format","labelAngle","labelAnchor","labelOrient","labelExpr"],e,n,t),u=di(e,i,"parent",n).signal,c=ul(t,s);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({text:{signal:a?ne(ne(a,"datum.label",u),"datum.value",Wi(e,{expr:"parent"})):u}},"row"===t?{orient:"left"}:{}),{style:"guide-label",frame:"group"}),hl(r,c)),gl(c,r,o)),Ol(n,e,t,tl,Kc))}function yl(e,t,n,i,r){var o;if(r){let s=null;const{facetFieldDef:a}=i,u=e.config?e.config:void 0;if(a&&r.labels){const{labelOrient:e}=ll(["labelOrient"],a,u,t);("row"===t&&!U(["top","bottom"],e)||"column"===t&&!U(["left","right"],e))&&(s=vl(a,t,u))}const c=yf(e)&&!Di(e.facet),l=r.axes,d=(null===(o=l)||void 0===o?void 0:o.length)>0;if(s||d){const o="row"===t?"height":"width";return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({name:e.getName(`${t}_${n}`),type:"group",role:`${t}-${n}`},i.facetFieldDef?{from:{data:e.getName(t+"_domain")},sort:bl(a,t)}:{}),d&&c?{from:{data:e.getName(`facet_domain_${t}`)}}:{}),s?{title:s}:{}),r.sizeSignal?{encode:{update:{[o]:r.sizeSignal}}}:{}),d?{axes:l}:{})}}return null}const xl={column:{start:0,end:1},row:{start:1,end:0}};function Al(e,t){return xl[t][e]}function Ol(e,t,n,i,r){const o={};for(const s of i){if(!r[s])continue;const i=cl(s,t,e,n);void 0!==i&&(o[r[s]]=i)}return o}function wl(e){return[...Fl(e,"width"),...Fl(e,"height")]}function Fl(e,t){const n="width"===t?"x":"y",i=e.component.layoutSize.get(t);if(!i||"merged"===i)return[];const r=e.getSizeSignalRef(t).signal;if("step"===i){const t=e.getScaleComponent(n);if(t){const i=t.get("type"),o=t.get("range");if(Gn(i)&&ds(o)){const i=e.scaleName(n);if(yf(e.parent)){if("independent"===e.parent.component.resolve.scale[n])return[Cl(i,o)]}return[Cl(i,o),{name:r,update:jl(i,t,`domain('${i}').length`)}]}}throw new Error("layout size is step although width/height is not step.")}if("container"==i){const t=r.endsWith("width"),n=t?"containerSize()[0]":"containerSize()[1]",i=`isFinite(${n}) ? ${n} : ${oo(e.config.view,t?"width":"height")}`;return[{name:r,init:i,on:[{update:i,events:"window:resize"}]}]}return[{name:r,value:i}]}function Cl(e,t){return{name:e+"_step",value:t.step}}function jl(e,t,n){const i=t.get("type"),r=t.get("padding"),o=oe(t.get("paddingOuter"),r);let s=t.get("paddingInner");return s="band"===i?void 0!==s?s:r:1,`bandspace(${n}, ${s}, ${o}) * ${e}_step`}function Dl(e,t){return Y(e).reduce((n,i)=>{const r=e[i];return Object.assign(Object.assign({},n),Ps(t,r,i,e=>({value:e.value})))},{})}function El(e,t){if(Of(t)||yf(t))return"shared";if(Af(t)||xf(t))return U(Nt,e)?"independent":"shared";throw new Error("invalid model type for resolve")}function Sl(e,t){const n=e.scale[t],i=U(Nt,t)?"axis":"legend";return"independent"===n?("shared"===e[i][t]&&Qt(Ht.independentScaleMeansIndependentGuide(t)),"independent"):e[i][t]||"shared"}class kl{constructor(e={},t={}){this.explicit=e,this.implicit=t}clone(){return new kl(N(this.explicit),N(this.implicit))}combine(){return Object.assign(Object.assign({},this.explicit),this.implicit)}get(e){return oe(this.explicit[e],this.implicit[e])}getWithExplicit(e){return void 0!==this.explicit[e]?{explicit:!0,value:this.explicit[e]}:void 0!==this.implicit[e]?{explicit:!1,value:this.implicit[e]}:{explicit:!1,value:void 0}}setWithExplicit(e,t){void 0!==t.value&&this.set(e,t.value,t.explicit)}set(e,t,n){return delete this[n?"implicit":"explicit"][e],this[n?"explicit":"implicit"][e]=t,this}copyKeyFromSplit(e,t){void 0!==t.explicit[e]?this.set(e,t.explicit[e],!0):void 0!==t.implicit[e]&&this.set(e,t.implicit[e],!1)}copyKeyFromObject(e,t){void 0!==t[e]&&this.set(e,t[e],!0)}copyAll(e){for(const t of Y(e.combine())){const n=e.getWithExplicit(t);this.setWithExplicit(t,n)}}}function $l(e){return{explicit:!0,value:e}}function Bl(e){return{explicit:!1,value:e}}function Nl(e){return(t,n,i,r)=>{const o=e(t.value,n.value);return o>0?t:o<0?n:_l(t,n,i,r)}}function _l(e,t,n,i){return e.explicit&&t.explicit&&Qt(Ht.mergeConflictingProperty(n,i,e.value,t.value)),e}function zl(e,t,n,i,r=_l){return void 0===e||void 0===e.value?t:e.explicit&&!t.explicit?e:t.explicit&&!e.explicit?t:B(e.value,t.value)?e:r(e,t,n,i)}const Tl=Object.assign(Object.assign({},{clipHeight:1,columnPadding:1,columns:1,cornerRadius: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}),{labelExpr:1,selections:1,opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,strokeDash:1,encode:1}),Pl=Y(Tl);class Ml extends kl{}function Ul(e){const{legend:t}=e;return oe(t.type,Rl(e))}function Rl({channel:e,timeUnit:t,scaleType:n,alwaysReturn:i}){if(bt(e)){if(U(["quarter","month","day"],t))return"symbol";if(Vn(n))return i?"gradient":void 0}return i?"symbol":void 0}function Ll({legend:e,legendConfig:t,timeUnit:n,channel:i,scaleType:r}){const o=oe(e.orient,t.orient,"right"),s=Ul({legend:e,channel:i,timeUnit:n,scaleType:r,alwaysReturn:!0});return oe(e.direction,t[s?"gradientDirection":"symbolDirection"],function(e,t){switch(e){case"top":case"bottom":return"horizontal";case"left":case"right":case"none":case void 0:return;default:return"gradient"===t?"horizontal":void 0}}(o,s))}function Wl(e,t,n,i){return{signal:`clamp(${e.getSizeSignalRef(t).signal}, ${n}, ${i})`}}function ql(e,t,n){const i=t.getScaleComponent(n).get("type");return oe(e.get("type"),Rl({channel:n,scaleType:i,alwaysReturn:!0}))}function Il(e){return Gl(e,(e,t)=>Math.max(e,t.value))}function Hl(e){return Gl(e,(e,t)=>oe(e,t.value))}function Gl(e,t){return function(e){return!!e&&!!e.condition&&(o(e.condition)||Mi(e.condition))}(e)?(o(e.condition)?e.condition:[e.condition]).reduce(t,e.value):Mi(e)?e.value:void 0}function Yl(e,t,n){var i;const r=t.get("selections");if(!(null===(i=r)||void 0===i?void 0:i.length))return;const o=u(n.field);return r.map(e=>{return`(!length(data(${u(Q(e)+Va)})) || (${e}[${o}] && indexof(${e}[${o}], datum.value) >= 0))`}).join(" || ")}var Vl=Object.freeze({__proto__:null,symbols:function(e,t,n,i,r){var s,a,u,c,l;if("symbol"!==ql(r,n,i))return;let d=Object.assign(Object.assign({},function(e,t,n){for(const i of n){const n=ci(i,t.markDef,t.config);void 0!==n&&(e[i]={value:n})}return e}({},n,Ce)),Ys(n));const{markDef:f,encoding:p,config:g}=n,h=f.filled,m=null!=(s=Il(p.opacity))?s:f.opacity,b=Yl(n,r,e);if(d.fill)if("fill"===i||h&&i===Ze)delete d.fill;else if(d.fill.field)r.get("symbolFillColor")?delete d.fill:(d.fill={value:(a=g.legend.symbolBaseFillColor,null!=a?a:"black")},d.fillOpacity={value:null!=m?m:1});else if(o(d.fill)){const e=null!=(l=null!=(c=Hl(null!=(u=p.fill)?u:p.color))?c:f.fill)?l:h&&f.color;e&&(d.fill={value:e})}if(d.stroke)if("stroke"===i||!h&&i===Ze)delete d.stroke;else if(d.stroke.field)delete d.stroke;else if(o(d.stroke)){const e=oe(Hl(p.stroke||p.color),f.stroke,h?f.color:void 0);e&&(d.stroke={value:e})}return i!==it&&(b?d.opacity=[{test:b,value:null!=m?m:1},{value:g.legend.unselectedOpacity}]:m&&(d.opacity={value:m})),d=Object.assign(Object.assign({},d),t),Y(d).length>0?d:void 0},gradient:function(e,t,n,i,r){if("gradient"!==ql(r,n,i))return;let o={};const s=Il(n.encoding.opacity)||n.markDef.opacity;return s&&(o.opacity={value:s}),o=Object.assign(Object.assign({},o),t),Y(o).length>0?o:void 0},labels:function(e,t,n,i,r){const o=n.legend(i),s=n.config,a=Yl(n,r,e);let u={};if(rr(e)){const r=n.getScaleComponent(i).get("type")===zn.UTC,a=mi("datum.value",e.timeUnit,o.format,s.timeFormat,r);t=Object.assign(Object.assign({},a?{text:{signal:a}}:{}),t)}return a&&(t.opacity=[{test:a,value:1},{value:s.legend.unselectedOpacity}]),u=Object.assign(Object.assign({},u),t),Y(u).length>0?u:void 0},entries:function(e,t,n,i,r){var o;return(null===(o=r.get("selections"))||void 0===o?void 0:o.length)?{fill:{value:"transparent"}}:void 0},getFirstConditionValue:Hl});function Jl(e){vf(e)?e.component.legends=function(e){const{encoding:t}=e;return[Ze,Ke,et,st,nt,tt,it,rt,ot].reduce((n,i)=>{const r=t[i];return!e.legend(i)||!e.getScaleComponent(i)||zi(r)&&i===tt&&r.type===_n||(n[i]=function(e,t){var n;const i=e.fieldDef(t),r=e.legend(t),o=new Ml({},function(e,t){const n=e.scaleName(Ze);if("color"===t)return e.markDef.filled?{fill:n}:{stroke:n};return{[t]:e.scaleName(t)}}(e,t));!function(e,t,n){const i=e.fieldDef(t).field;Ka(e,e=>{var r,o;const s=null!=(r=e.project.hasField[i])?r:e.project.hasChannel[t];if(s&&Da.has(e)){const t=null!=(o=n.get("selections"))?o:[];t.push(e.name),n.set("selections",t,!1),s.hasLegend=!0}})}(e,t,o);for(const n of Pl){const s=Xl(n,r,t,e);if(void 0!==s){const t=Ql(s,n,r,i);(t||void 0===e.config.legend[n])&&o.set(n,s,t)}}const s=null!==(n=r.encoding)&&void 0!==n?n:{},a=o.get("selections"),u=["labels","legend","title","symbols","gradient","entries"].reduce((n,r)=>{var u,c,l;const d=Dl(null!=(u=s[r])?u:{},e),f=Vl[r]?Vl[r](i,d,e,t,o):d;return void 0!==f&&Y(f).length>0&&(n[r]=Object.assign(Object.assign(Object.assign({},(null===(c=a)||void 0===c?void 0:c.length)?{name:`${i.field}_legend_${r}`}:{}),(null===(l=a)||void 0===l?void 0:l.length)?{interactive:!!a}:{}),{update:f})),n},{});Y(u).length>0&&o.set("encode",u,!!r.encoding);return o}(e,i)),n},{})}(e):e.component.legends=function(e){const{legends:t,resolve:n}=e.component;for(const i of e.children)Jl(i),Y(i.component.legends).forEach(r=>{n.legend[r]=Sl(e.component.resolve,r),"shared"===n.legend[r]&&(t[r]=Zl(t[r],i.component.legends[r]),t[r]||(n.legend[r]="independent",delete t[r]))});return Y(t).forEach(t=>{for(const i of e.children)i.component.legends[t]&&"shared"===n.legend[t]&&delete i.component.legends[t]}),t}(e)}function Ql(e,t,n,i){switch(t){case"values":return!!n.values;case"title":if("title"===t&&e===i.title)return!0}return e===n[t]}function Xl(e,t,n,i){const{encoding:r,mark:o}=i,s=Ki(r[n]),a=i.config.legend,{timeUnit:u}=s,c=i.getScaleComponent(n).get("type");switch(e){case"direction":return Ll({legend:t,legendConfig:a,timeUnit:u,channel:n,scaleType:c});case"format":if(rr(s))return;return fi(s,t.format,i.config);case"formatType":if(rr(s))return;return t.formatType;case"gradientLength":return oe(t.gradientLength,a.gradientLength,function({legend:e,legendConfig:t,model:n,channel:i,scaleType:r}){const{gradientHorizontalMaxLength:o,gradientHorizontalMinLength:s,gradientVerticalMaxLength:a,gradientVerticalMinLength:u}=t;if("horizontal"===Ll({legend:e,legendConfig:t,channel:i,scaleType:r})){const i=oe(e.orient,t.orient);return"top"===i||"bottom"===i?Wl(n,"width",s,o):s}return Wl(n,"height",u,a)}({model:i,legend:t,legendConfig:a,channel:n,scaleType:c}));case"labelOverlap":return oe(t.labelOverlap,function(e){if(U(["quantile","threshold","log"],e))return"greedy"}(c));case"symbolType":return oe(t.symbolType,function(e,t,n,i){var r;if("shape"!==t){const e=null!=(r=Hl(n))?r:i;if(e)return e}switch(e){case"bar":case"rect":case"image":case"square":return"square";case"line":case"trail":case"rule":return"stroke";case"point":case"circle":case"tick":case"geoshape":case"area":case"text":return"circle"}}(o,n,r.shape,i.markDef.shape));case"title":return Vi(s,i.config,{allowDisabling:!0})||void 0;case"type":return Ul({legend:t,channel:n,timeUnit:u,scaleType:c,alwaysReturn:!1});case"values":return function(e,t){const n=e.values;if(n)return sr(t,n)}(t,s)}return t[e]}function Zl(e,t){var n,i,r,o,s,a;if(!e)return t.clone();const u=e.getWithExplicit("orient"),c=t.getWithExplicit("orient");if(u.explicit&&c.explicit&&u.value!==c.value)return;let l=!1;for(const n of Pl){const i=zl(e.getWithExplicit(n),t.getWithExplicit(n),n,"legend",(e,t)=>{switch(n){case"symbolType":return Kl(e,t);case"title":return xi(e,t);case"type":return l=!0,Bl("symbol")}return _l(e,t,n,"legend")});e.setWithExplicit(n,i)}return l&&((null==(r=null===(i=null===(n=e.implicit)||void 0===n?void 0:n.encode)||void 0===i?void 0:i.gradient)||r)&&Z(e.implicit,["encode","gradient"]),(null==(a=null===(s=null===(o=e.explicit)||void 0===o?void 0:o.encode)||void 0===s?void 0:s.gradient)||a)&&Z(e.explicit,["encode","gradient"])),e}function Kl(e,t){return"circle"===t.value?t:e}function ed(e){const t=e.component.legends,n={};for(const i of Y(t)){const r=e.getScaleComponent(i),o=T(r.get("domains"));if(n[o])for(const e of n[o]){Zl(e,t[i])||n[o].push(t[i])}else n[o]=[t[i].clone()]}return V(n).flat().map(e=>{var t,n,i,r;const o=e.combine(),{labelExpr:s,selections:a}=o,u=$e(o,["labelExpr","selections"]);if(null===(t=u.encode)||void 0===t?void 0:t.symbols){const e=u.encode.symbols.update;!e.fill||"transparent"===e.fill.value||e.stroke||u.stroke||(e.stroke={value:"transparent"}),u.fill&&delete e.fill}if(void 0!==s){let e=s;(null===(r=null===(i=null===(n=u.encode)||void 0===n?void 0:n.labels)||void 0===i?void 0:i.update)||void 0===r?void 0:r.text)&&ls(u.encode.labels.update.text)&&(e=ne(s,"datum.label",u.encode.labels.update.text.signal)),function(e,t,n,i){var r,o,s;e.encode=null!=(r=e.encode)?r:{},e.encode[t]=null!=(o=e.encode[t])?o:{},e.encode[t].update=null!=(s=e.encode[t].update)?s:{},e.encode[t].update[n]=i}(u,"labels","text",{signal:e})}return u})}function td(e){return Of(e)||Af(e)||xf(e)?function(e){return e.children.reduce((e,t)=>e.concat(t.assembleProjections()),nd(e))}(e):nd(e)}function nd(e){const t=e.component.projection;if(!t||t.merged)return[];const n=t.combine(),{name:i}=n,r=$e(n,["name"]);if(t.data){const n={signal:`[${t.size.map(e=>e.signal).join(", ")}]`},o=t.data.reduce((t,n)=>{const i=ls(n)?n.signal:`data('${e.lookupDataSource(n)}')`;return U(t,i)||t.push(i),t},[]);if(o.length<=0)throw new Error("Projection's fit didn't find any data sources");return[Object.assign({name:i,size:n,fit:{signal:o.length>1?`[${o.join(", ")}]`:o[0]}},r)]}return[Object.assign(Object.assign({name:i},{translate:{signal:"[width / 2, height / 2]"}}),r)]}const id=["type","clipAngle","clipExtent","center","rotate","precision","reflectX","reflectY","coefficient","distance","fraction","lobes","parallel","radius","ratio","spacing","tilt"];class rd extends kl{constructor(e,t,n,i){super(Object.assign({},t),{name:e}),this.specifiedProjection=t,this.size=n,this.data=i,this.merged=!1}get isFit(){return!!this.data}}function od(e){e.component.projection=vf(e)?function(e){var t;if(e.hasProjection){const n=e.specifiedProjection,i=!(n&&(null!=n.scale||null!=n.translate)),r=i?[e.getSizeSignalRef("width"),e.getSizeSignalRef("height")]:void 0,o=i?function(e){const t=[];for(const n of[[Je,Ve],[Xe,Qe]])(e.channelHasField(n[0])||e.channelHasField(n[1]))&&t.push({signal:e.getName(`geojson_${t.length}`)});e.channelHasField(tt)&&e.fieldDef(tt).type===_n&&t.push({signal:e.getName(`geojson_${t.length}`)});0===t.length&&t.push(e.requestDataName(Io));return t}(e):void 0;return new rd(e.projectionName(!0),Object.assign(Object.assign({},null!=(t=e.config.projection)?t:{}),null!=n?n:{}),r,o)}return}(e):function(e){if(0===e.children.length)return;let t;e.children.forEach(e=>od(e));const n=L(e.children,e=>{const n=e.component.projection;if(n){if(t){const e=function(e,t){const n=L(id,n=>!O(e.explicit,n)&&!O(t.explicit,n)||!(!O(e.explicit,n)||!O(t.explicit,n)||T(e.get(n))!==T(t.get(n))));if(T(e.size)===T(t.size)){if(n)return e;if(T(e.explicit)===T({}))return t;if(T(t.explicit)===T({}))return e}return null}(t,n);return e&&(t=e),!!e}return t=n,!0}return!0});if(t&&n){const n=e.projectionName(!0),i=new rd(n,t.specifiedProjection,t.size,N(t.data));return e.children.forEach(e=>{const t=e.component.projection;t&&(t.isFit&&i.data.push(...e.component.projection.data),e.renameProjection(t.get("name"),n),t.merged=!0)}),i}return}(e)}function sd(e,t){return`${ur(e)}_${t}`}function ad(e,t,n){var i;const r=sd(null!=(i=nr(n,void 0))?i:{},t);return e.getName(`${r}_bins`)}function ud(e,t,n){let i,r;i=function(e){return"as"in e}(e)?a(e.as)?[e.as,`${e.as}_end`]:[e.as[0],e.as[1]]:[Wi(e,{forAs:!0}),Wi(e,{binSuffix:"end",forAs:!0})];const o=Object.assign({},nr(t,void 0)),s=sd(o,e.field),{signal:u,extentSignal:c}=function(e,t){return{signal:e.getName(`${t}_bins`),extentSignal:e.getName(`${t}_extent`)}}(n,s);if(fr(o.extent)){const e=o.extent,t=e.selection;r=Yc(n.getSelectionComponent(Q(t),t),e),delete o.extent}return{key:s,binComponent:Object.assign(Object.assign(Object.assign({bin:o,field:e.field,as:[i]},u?{signal:u}:{}),c?{extentSignal:c}:{}),r?{span:r}:{})}}class cd extends ma{constructor(e,t){super(e),this.bins=t}clone(){return new cd(null,N(this.bins))}static makeFromEncoding(e,t){const n=t.reduceFieldDef((e,n,i)=>{if(Ti(n)&&cr(n.bin)){const{key:r,binComponent:o}=ud(n,n.bin,t);e[r]=Object.assign(Object.assign(Object.assign({},o),e[r]),function(e,t,n,i){var r,o;if(ar(t,n)){const s=vf(e)?null!=(o=null!=(r=e.axis(n))?r:e.legend(n))?o:{}:{},a=Wi(t,{expr:"datum"}),u=Wi(t,{expr:"datum",binSuffix:"end"});return{formulaAs:Wi(t,{binSuffix:"range",forAs:!0}),formula:hi(a,u,s.format,i)}}return{}}(t,n,i,t.config))}return e},{});return 0===Y(n).length?null:new cd(e,n)}static makeFromTransform(e,t,n){const{key:i,binComponent:r}=ud(t,t.bin,n);return new cd(e,{[i]:r})}merge(e,t){for(const n of Y(e.bins))n in this.bins?(t(e.bins[n].signal,this.bins[n].signal),this.bins[n].as=q([...this.bins[n].as,...e.bins[n].as],P)):this.bins[n]=e.bins[n];for(const t of e.children)e.removeChild(t),t.parent=this;e.remove()}producedFields(){return new Set(V(this.bins).map(e=>e.as).flat(2))}dependentFields(){return new Set(V(this.bins).map(e=>e.field))}hash(){return`Bin ${P(this.bins)}`}assemble(){return V(this.bins).flatMap(e=>{const t=[],[n,...i]=e.as,r=e.bin,{extent:o}=r,s=$e(r,["extent"]),a=Object.assign(Object.assign(Object.assign({type:"bin",field:te(e.field),as:n,signal:e.signal},fr(o)?{extent:null}:{extent:o}),e.span?{span:{signal:`span(${e.span})`}}:{}),s);!o&&e.extentSignal&&(t.push({type:"extent",field:te(e.field),signal:e.extentSignal}),a.extent={signal:e.extentSignal}),t.push(a);for(const e of i)for(let i=0;i<2;i++)t.push({type:"formula",expr:Wi({field:n[i]},{expr:"datum"}),as:e[i]});return e.formula&&t.push({type:"formula",expr:e.formula,as:e.formulaAs}),t})}}class ld extends ma{constructor(e){let t;if(super(null),Ro(e=null!=e?e:{name:"source"})||(t=e.format?Object.assign({},z(e.format,["parse"])):{}),Mo(e))this._data={values:e.values};else if(Po(e)){if(this._data={url:e.url},!t.type){let n=/(?:\.([^.]+))?$/.exec(e.url)[1];U(["json","csv","tsv","dsv","topojson"],n)||(n="json"),t.type=n}}else Wo(e)?this._data={values:[{type:"Sphere"}]}:(Uo(e)||Ro(e))&&(this._data={});this._generator=Ro(e),e.name&&(this._name=e.name),t&&Y(t).length>0&&(this._data.format=t)}dependentFields(){return new Set}producedFields(){}get data(){return this._data}hasName(){return!!this._name}get isGenerator(){return this._generator}get dataName(){return this._name}set dataName(e){this._name=e}set parent(e){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 Object.assign(Object.assign({name:this._name},this._data),{transform:[]})}}function dd(e){for(const t of e){for(const e of t.children)if(e.parent!==t)return console.error("Dataflow graph is inconsistent.",t,e),!1;if(!dd(t.children))return!1}return!0}class fd extends ma{constructor(e,t){super(e),this.params=t}clone(){return new fd(null,this.params)}dependentFields(){return new Set}producedFields(){}hash(){return`Graticule ${P(this.params)}`}assemble(){return Object.assign({type:"graticule"},!0===this.params?{}:this.params)}}class pd extends ma{constructor(e,t){super(e),this.params=t}clone(){return new pd(null,this.params)}dependentFields(){return new Set}producedFields(){var e;return new Set([(e=this.params.as,null!=e?e:"data")])}hash(){return`Hash ${P(this.params)}`}assemble(){return Object.assign({type:"sequence"},this.params)}}function gd(e){return e instanceof ld||e instanceof fd||e instanceof pd}class hd{constructor(){this._mutated=!1}setMutated(){this._mutated=!0}get mutatedFlag(){return this._mutated}}class md extends hd{constructor(){super(),this._continue=!1}setContinue(){this._continue=!0}get continueFlag(){return this._continue}get flags(){return{continueFlag:this.continueFlag,mutatedFlag:this.mutatedFlag}}set flags({continueFlag:e,mutatedFlag:t}){e&&this.setContinue(),t&&this.setMutated()}reset(){}optimizeNextFromLeaves(e){if(gd(e))return!1;const t=e.parent,{continueFlag:n}=this.run(e);return n&&this.optimizeNextFromLeaves(t),this.mutatedFlag}}class bd extends hd{}function vd(e,t,n,i){const r=vf(i)?i.encoding[St(t)]:void 0;if(Ti(n)&&vf(i)&&Bi(t,n,r,i.markDef,i.config))e.add(Wi(n,{})),e.add(Wi(n,{suffix:"end"})),ar(n,t)&&e.add(Wi(n,{binSuffix:"range"}));else if(t in gt){const n=function(e){switch(e){case Ve:return"y";case Qe:return"y2";case Je:return"x";case Xe:return"x2"}}(t);e.add(i.getName(n))}else e.add(Wi(n));return e}class yd extends ma{constructor(e,t,n){super(e),this.dimensions=t,this.measures=n}clone(){return new yd(null,new Set(this.dimensions),N(this.measures))}get groupBy(){return this.dimensions}static makeFromEncoding(e,t){let n=!1;t.forEachFieldDef(e=>{e.aggregate&&(n=!0)});const i={},r=new Set;return n?(t.forEachFieldDef((e,n)=>{var o,s,a,u;const{aggregate:c,field:l}=e;if(c)if("count"===c)i["*"]=null!=(o=i["*"])?o:{},i["*"].count=new Set([Wi(e,{forAs:!0})]);else{if(_e(c)||ze(c)){const e=_e(c)?"argmin":"argmax",t=c[e];i[t]=null!=(s=i[t])?s:{},i[t][e]=new Set([Wi({op:e,field:t},{forAs:!0})])}else i[l]=null!=(a=i[l])?a:{},i[l][c]=new Set([Wi(e,{forAs:!0})]);Rt(n)&&"unaggregated"===t.scaleDomain(n)&&(i[l]=null!=(u=i[l])?u:{},i[l].min=new Set([Wi({field:l,aggregate:"min"},{forAs:!0})]),i[l].max=new Set([Wi({field:l,aggregate:"max"},{forAs:!0})]))}else vd(r,n,e,t)}),r.size+Y(i).length===0?null:new yd(e,r,i)):null}static makeFromTransform(e,t){var n,i,r;const o=new Set,s={};for(const e of t.aggregate){const{op:t,field:r,as:o}=e;t&&("count"===t?(s["*"]=null!=(n=s["*"])?n:{},s["*"].count=new Set([o||Wi(e,{forAs:!0})])):(s[r]=null!=(i=s[r])?i:{},s[r][t]=new Set([o||Wi(e,{forAs:!0})])))}for(const e of null!=(r=t.groupby)?r:[])o.add(e);return o.size+Y(s).length===0?null:new yd(e,o,s)}merge(e){return function(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}(this.dimensions,e.dimensions)?(function(e,t){var n;for(const i of Y(t)){const r=t[i];for(const t of Y(r))i in e?e[i][t]=new Set([...(n=e[i][t],null!=n?n:[]),...r[t]]):e[i]={[t]:r[t]}}}(this.measures,e.measures),!0):(function(...e){Jt.debug(...e)}("different dimensions, cannot merge"),!1)}addDimensions(e){e.forEach(this.dimensions.add,this.dimensions)}dependentFields(){return new Set([...this.dimensions,...Y(this.measures)])}producedFields(){const e=new Set;for(const t of Y(this.measures))for(const n of Y(this.measures[t])){const i=this.measures[t][n];0===i.size?e.add(`${n}_${t}`):i.forEach(e.add,e)}return e}hash(){return`Aggregate ${P({dimensions:this.dimensions,measures:this.measures})}`}assemble(){const e=[],t=[],n=[];for(const i of Y(this.measures))for(const r of Y(this.measures[i]))for(const o of this.measures[i][r])n.push(o),e.push(r),t.push("*"===i?null:te(i));return{type:"aggregate",groupby:[...this.dimensions],ops:e,fields:t,as:n}}}class xd extends ma{constructor(e,t,n,i){super(e),this.model=t,this.name=n,this.data=i;for(const e of yt){const n=t.facet[e];if(n){const{bin:i,sort:r}=n;this[e]=Object.assign({name:t.getName(`${e}_domain`),fields:[Wi(n),...cr(i)?[Wi(n,{binSuffix:"end"})]:[]]},Ci(r)?{sortField:r}:o(r)?{sortIndexField:al(n,e)}:{})}}this.childModel=t.child}hash(){let e="Facet";for(const t of yt)this[t]&&(e+=` ${t.charAt(0)}:${P(this[t])}`);return e}get fields(){var e;const t=[];for(const n of yt)(null===(e=this[n])||void 0===e?void 0:e.fields)&&t.push(...this[n].fields);return t}dependentFields(){const e=new Set(this.fields);for(const t of yt)this[t]&&(this[t].sortField&&e.add(this[t].sortField.field),this[t].sortIndexField&&e.add(this[t].sortIndexField));return e}producedFields(){return new Set}getSource(){return this.name}getChildIndependentFieldsWithStep(){const e={};for(const t of["x","y"]){const n=this.childModel.component.scales[t];if(n&&!n.merged){const i=n.get("type"),r=n.get("range");if(Gn(i)&&ds(r)){const n=Kd(ef(this.childModel,t));n?e[t]=n:Qt(`Unknown field for ${t}. Cannot calculate view size.`)}}}return e}assembleRowColumnHeaderData(e,t,n){const i={row:"y",column:"x"}[e],r=[],o=[],s=[];n&&n[i]&&(t?(r.push(`distinct_${n[i]}`),o.push("max")):(r.push(n[i]),o.push("distinct")),s.push(`distinct_${n[i]}`));const{sortField:a,sortIndexField:u}=this[e];if(a){const{op:e=Ai,field:t}=a;r.push(t),o.push(e),s.push(Wi(a,{forAs:!0}))}else u&&(r.push(u),o.push("max"),s.push(u));return{name:this[e].name,source:null!=t?t:this.data,transform:[Object.assign({type:"aggregate",groupby:this[e].fields},r.length?{fields:r,ops:o,as:s}:{})]}}assembleFacetHeaderData(e){var t,n;const{columns:i}=this.model.layout,{layoutHeaders:r}=this.model.component,o=[],s={};for(const e of dl){for(const i of fl){const o=null!=(t=r[e]&&r[e][i])?t:[];for(const t of o)if((null===(n=t.axes)||void 0===n?void 0:n.length)>0){s[e]=!0;break}}if(s[e]){const t=`length(data("${this.facet.name}"))`,n="row"===e?i?{signal:`ceil(${t} / ${i})`}:1:i?{signal:`min(${t}, ${i})`}:{signal:t};o.push({name:`${this.facet.name}_${e}`,transform:[{type:"sequence",start:0,stop:n}]})}}const{row:a,column:u}=s;return(a||u)&&o.unshift(this.assembleRowColumnHeaderData("facet",null,e)),o}assemble(){var e,t;const n=[];let i=null;const r=this.getChildIndependentFieldsWithStep(),{column:o,row:s,facet:a}=this;if(o&&s&&(r.x||r.y)){i=`cross_${this.column.name}_${this.row.name}`;const o=[].concat(null!=(e=r.x)?e:[],null!=(t=r.y)?t:[]),s=o.map(()=>"distinct");n.push({name:i,source:this.data,transform:[{type:"aggregate",groupby:this.fields,fields:o,ops:s}]})}for(const e of[We,Le])this[e]&&n.push(this.assembleRowColumnHeaderData(e,i,r));if(a){const e=this.assembleFacetHeaderData(r);e&&n.push(...e)}return n}}function Ad(e){return"'"===e[0]&&"'"===e[e.length-1]||'"'===e[0]&&'"'===e[e.length-1]?e.slice(1,-1):e}function Od(e){const t={};return function e(t,n){if(k(t))e(t.not,n);else if(S(t))for(const i of t.and)e(i,n);else if(E(t))for(const i of t.or)e(i,n);else n(t)}(e.filter,e=>{var n;if(Fn(e)){let i=null;bn(e)?i=e.equal:On(e)?i=e.range[0]:wn(e)&&(i=(n=e.oneOf,null!=n?n:e.in)[0]),i&&(Zt(i)?t[e.field]="date":F(i)?t[e.field]="number":a(i)&&(t[e.field]="string")),e.timeUnit&&(t[e.field]="date")}}),t}function wd(e){const t={};function n(e){var n;rr(e)?t[e.field]="date":"quantitative"===e.type&&(a(n=e.aggregate)&&U(["min","max"],n))?t[e.field]="number":re(e.field)>1?e.field in t||(t[e.field]="flatten"):Ui(e)&&Ci(e.sort)&&re(e.sort.field)>1&&(e.sort.field in t||(t[e.sort.field]="flatten"))}if((vf(e)||yf(e))&&e.forEachFieldDef((t,i)=>{if(Ti(t))n(t);else{const r=Et(i),o=e.fieldDef(r);n(Object.assign(Object.assign({},t),{type:o.type}))}}),vf(e)){const{mark:n,markDef:i,encoding:r}=e;if(Ae(n)&&!e.encoding.order){const e=r["horizontal"===i.orient?"y":"x"];!zi(e)||"quantitative"!==e.type||e.field in t||(t[e.field]="number")}}return t}class Fd extends ma{constructor(e,t){super(e),this._parse=t}clone(){return new Fd(null,N(this._parse))}hash(){return`Parse ${P(this._parse)}`}static makeExplicit(e,t,n){let i={};const r=t.data;return!Ro(r)&&r&&r.format&&r.format.parse&&(i=r.format.parse),this.makeWithAncestors(e,i,{},n)}static makeWithAncestors(e,t,n,i){for(const e of Y(n)){const t=i.getWithExplicit(e);void 0!==t.value&&(t.explicit||t.value===n[e]||"derived"===t.value||"flatten"===n[e]?delete n[e]:Qt(Ht.differentParse(e,n[e],t.value)))}for(const e of Y(t)){const n=i.get(e);void 0!==n&&(n===t[e]?delete t[e]:Qt(Ht.differentParse(e,t[e],n)))}const r=new kl(t,n);i.copyAll(r);const o={};for(const e of Y(r.combine())){const t=r.get(e);null!==t&&(o[e]=t)}return 0===Y(o).length||i.parseNothing?null:new Fd(e,o)}get parse(){return this._parse}merge(e){this._parse=Object.assign(Object.assign({},this._parse),e.parse),e.remove()}assembleFormatParse(){const e={};for(const t of Y(this._parse)){const n=this._parse[t];1===re(t)&&(e[t]=n)}return e}producedFields(){return new Set(Y(this._parse))}dependentFields(){return new Set(Y(this._parse))}assembleTransforms(e=!1){return Y(this._parse).filter(t=>!e||re(t)>1).map(e=>{const t=function(e,t){const n=ee(e);if("number"===t)return`toNumber(${n})`;if("boolean"===t)return`toBoolean(${n})`;if("string"===t)return`toString(${n})`;if("date"===t)return`toDate(${n})`;if("flatten"===t)return n;if(0===t.indexOf("date:")){return`timeParse(${n},'${Ad(t.slice(5,t.length))}')`}if(0===t.indexOf("utc:")){return`utcParse(${n},'${Ad(t.slice(4,t.length))}')`}return Qt(Ht.unrecognizedParse(t)),null}(e,this._parse[e]);return t?{type:"formula",expr:t,as:ie(e)}:null}).filter(e=>null!==e)}}class Cd extends ma{constructor(e,t){super(e),this.transform=t}clone(){return new Cd(null,N(this.transform))}addDimensions(e){this.transform.groupby=q(this.transform.groupby.concat(e),e=>e)}dependentFields(){const e=new Set;return this.transform.groupby&&this.transform.groupby.forEach(t=>e.add(t)),this.transform.joinaggregate.map(e=>e.field).filter(e=>void 0!==e).forEach(t=>e.add(t)),e}producedFields(){return new Set(this.transform.joinaggregate.map(this.getDefaultName))}getDefaultName(e){var t;return null!=(t=e.as)?t:Wi(e)}hash(){return`JoinAggregateTransform ${P(this.transform)}`}assemble(){const e=[],t=[],n=[];for(const i of this.transform.joinaggregate)t.push(i.op),n.push(this.getDefaultName(i)),e.push(void 0===i.field?null:i.field);const i=this.transform.groupby;return Object.assign({type:"joinaggregate",as:n,ops:t,fields:e},void 0!==i?{groupby:i}:{})}}class jd extends ma{constructor(e,t){super(e),this._stack=t}clone(){return new jd(null,N(this._stack))}static makeFromTransform(e,t){const{stack:n,groupby:i,as:r,offset:s="zero"}=t,u=[],c=[];if(void 0!==t.sort)for(const e of t.sort)u.push(e.field),c.push(oe(e.order,"ascending"));const l={field:u,order:c};let d;return d=function(e){return o(e)&&e.every(e=>a(e))&&e.length>1}(r)?r:a(r)?[r,r+"_end"]:[t.stack+"_start",t.stack+"_end"],new jd(e,{stackField:n,groupby:i,offset:s,sort:l,facetby:[],as:d})}static makeFromEncoding(e,t){const n=t.stack,{encoding:i}=t;if(!n)return null;let r;if(n.groupbyChannel){r=Ki(i[n.groupbyChannel])}const s=function(e){return e.stack.stackBy.reduce((e,t)=>{const n=Wi(t.fieldDef);return n&&e.push(n),e},[])}(t),a=t.encoding.order;let u;return u=o(a)||zi(a)?bi(a):s.reduce((e,t)=>(e.field.push(t),e.order.push("descending"),e),{field:[],order:[]}),new jd(e,{dimensionFieldDef:r,stackField:t.vgField(n.fieldChannel),facetby:[],stackby:s,sort:u,offset:n.offset,impute:n.impute,as:[t.vgField(n.fieldChannel,{suffix:"start",forAs:!0}),t.vgField(n.fieldChannel,{suffix:"end",forAs:!0})]})}get stack(){return this._stack}addDimensions(e){this._stack.facetby.push(...e)}dependentFields(){const e=new Set;return e.add(this._stack.stackField),this.getGroupbyFields().forEach(t=>e.add(t)),this._stack.facetby.forEach(t=>e.add(t)),this._stack.sort.field.forEach(t=>e.add(t)),e}producedFields(){return new Set(this._stack.as)}hash(){return`Stack ${P(this._stack)}`}getGroupbyFields(){const{dimensionFieldDef:e,impute:t,groupby:n}=this._stack;return e?e.bin?t?[Wi(e,{binSuffix:"mid"})]:[Wi(e,{}),Wi(e,{binSuffix:"end"})]:[Wi(e)]:null!=n?n:[]}assemble(){const e=[],{facetby:t,dimensionFieldDef:n,stackField:i,stackby:r,sort:o,offset:s,impute:a,as:u}=this._stack;if(a&&n){const{band:o=.5,bin:s}=n;s&&e.push({type:"formula",expr:`${o}*`+Wi(n,{expr:"datum"})+`+${1-o}*`+Wi(n,{expr:"datum",binSuffix:"end"}),as:Wi(n,{binSuffix:"mid",forAs:!0})}),e.push({type:"impute",field:i,groupby:[...r,...t],key:Wi(n,{binSuffix:"mid"}),method:"value",value:0})}return e.push({type:"stack",groupby:[...this.getGroupbyFields(),...t],field:i,sort:o,as:u,offset:s}),e}}class Dd extends ma{constructor(e,t){super(e),this.transform=t}clone(){return new Dd(null,N(this.transform))}addDimensions(e){this.transform.groupby=q(this.transform.groupby.concat(e),e=>e)}dependentFields(){var e,t;const n=new Set;return(e=this.transform.groupby,null!=e?e:[]).forEach(e=>n.add(e)),(t=this.transform.sort,null!=t?t:[]).forEach(e=>n.add(e.field)),this.transform.window.map(e=>e.field).filter(e=>void 0!==e).forEach(e=>n.add(e)),n}producedFields(){return new Set(this.transform.window.map(this.getDefaultName))}getDefaultName(e){var t;return null!=(t=e.as)?t:Wi(e)}hash(){return`WindowTransform ${P(this.transform)}`}assemble(){var e;const t=[],n=[],i=[],r=[];for(const e of this.transform.window)n.push(e.op),i.push(this.getDefaultName(e)),r.push(void 0===e.param?null:e.param),t.push(void 0===e.field?null:e.field);const o=this.transform.frame,s=this.transform.groupby;if(o&&null===o[0]&&null===o[1]&&n.every(e=>Te(e)))return Object.assign({type:"joinaggregate",as:i,ops:n,fields:t},void 0!==s?{groupby:s}:{});const a=[],u=[];if(void 0!==this.transform.sort)for(const t of this.transform.sort)a.push(t.field),u.push(null!=(e=t.order)?e:"ascending");const c={field:a,order:u},l=this.transform.ignorePeers;return Object.assign(Object.assign(Object.assign({type:"window",params:r,as:i,ops:n,fields:t,sort:c},void 0!==l?{ignorePeers:l}:{}),void 0!==s?{groupby:s}:{}),void 0!==o?{frame:o}:{})}}class Ed extends ma{clone(){return new Ed(null)}constructor(e){super(e)}dependentFields(){return new Set}producedFields(){return new Set([Jr])}hash(){return"Identifier"}assemble(){return{type:"identifier",as:Jr}}}class Sd extends md{run(e){const t=e.parent;if(e instanceof Fd){if(gd(t))return this.flags;if(t.numChildren()>1)return this.setContinue(),this.flags;if(t instanceof Fd)this.setMutated(),t.merge(e);else{if(G(t.producedFields(),e.dependentFields()))return this.setContinue(),this.flags;this.setMutated(),e.swapWithParent()}}return this.setContinue(),this.flags}}class kd extends bd{mergeNodes(e,t){const n=t.shift();for(const i of t)e.removeChild(i),i.parent=n,i.remove()}run(e){const t=e.children.map(e=>e.hash()),n={};for(let i=0;i<t.length;i++)void 0===n[t[i]]?n[t[i]]=[e.children[i]]:n[t[i]].push(e.children[i]);for(const t of Y(n))n[t].length>1&&(this.setMutated(),this.mergeNodes(e,n[t]));for(const t of e.children)this.run(t);return this.mutatedFlag}}class $d extends md{run(e){return e instanceof ba||e.numChildren()>0||e instanceof xd?this.flags:(this.setMutated(),e.remove(),this.flags)}}class Bd extends md{constructor(){super(...arguments),this.fields=new Set,this.prev=null}run(e){if(this.setContinue(),e instanceof va){const t=e.producedFields();I(t,this.fields)?(this.setMutated(),this.prev.remove()):this.fields=new Set([...this.fields,...t]),this.prev=e}return this.flags}reset(){this.fields.clear()}}class Nd extends md{run(e){this.setContinue();const t=e.parent.children.filter(e=>e instanceof va),n=t.pop();for(const e of t)this.setMutated(),n.merge(e);return this.flags}}function _d(e){if(e instanceof xd)if(1!==e.numChildren()||e.children[0]instanceof ba){const n=e.model.component.data.main;!function e(t){if(t instanceof ba&&t.type===Io&&1===t.numChildren()){const n=t.children[0];n instanceof xd||(n.swapWithParent(),e(t))}}(n);const i=(t=e,function e(n){if(!(n instanceof xd)){const i=n.clone();if(i instanceof ba){const e=Ld+i.getSource();i.setSource(e),t.model.component.data.outputNodes[e]=i}else(i instanceof yd||i instanceof jd||i instanceof Dd||i instanceof Cd)&&i.addDimensions(t.fields);return n.children.flatMap(e).forEach(e=>e.parent=i),[i]}return n.children.flatMap(e)}),r=e.children.map(i).flat();for(const e of r)e.parent=n}else{const t=e.children[0];(t instanceof yd||t instanceof jd||t instanceof Dd||t instanceof Cd)&&t.addDimensions(e.fields),t.swapWithParent(),_d(e)}else e.children.map(_d);var t}class zd extends bd{constructor(){super()}run(e){e instanceof ba&&!e.isRequired()&&(this.setMutated(),e.remove());for(const t of e.children)this.run(t);return this.mutatedFlag}}class Td extends bd{constructor(e){super(),this.requiresSelectionId=e&&tu(e)}run(e){e instanceof Ed&&(this.requiresSelectionId&&(gd(e.parent)||e.parent instanceof yd||e.parent instanceof Fd)||(this.setMutated(),e.remove()));for(const t of e.children)this.run(t);return this.mutatedFlag}}class Pd extends md{run(e){const t=e.parent,n=[...t.children],i=t.children.filter(e=>e instanceof Fd);if(t.numChildren()>1&&i.length>=1){const e={},r=new Set;for(const t of i){const n=t.parse;for(const t of Y(n))t in e?e[t]!==n[t]&&r.add(t):e[t]=n[t]}for(const t of r)delete e[t];if(0!==Y(e).length){this.setMutated();const i=new Fd(t,e);for(const r of n){if(r instanceof Fd)for(const t of Y(e))delete r.parse[t];t.removeChild(r),r.parent=i,r instanceof Fd&&0===Y(r.parse).length&&r.remove()}}}return this.setContinue(),this.flags}}class Md extends md{run(e){const t=e.parent,n=t.children.filter(e=>e instanceof yd),i={};for(const e of n){const t=P(e.groupBy);t in i||(i[t]=[]),i[t].push(e)}for(const e of Y(i)){const n=i[e];if(n.length>1){const e=n.pop();for(const i of n)e.merge(i)&&(t.removeChild(i),i.parent=e,i.remove(),this.setMutated())}}return this.setContinue(),this.flags}}class Ud extends md{constructor(e){super(),this.model=e}run(e){const t=e.parent,n=!(gd(t)||t instanceof Hc||t instanceof Fd||t instanceof Ed),i=[],r=[];for(const e of t.children)e instanceof cd&&(n&&!G(t.producedFields(),e.dependentFields())?i.push(e):r.push(e));if(i.length>0){const e=i.pop();for(const t of i)e.merge(t,this.model.renameSignal.bind(this.model));this.setMutated(),t instanceof cd?t.merge(e,this.model.renameSignal.bind(this.model)):e.swapWithParent()}if(r.length>1){const e=r.pop();for(const t of r)e.merge(t,this.model.renameSignal.bind(this.model));this.setMutated()}return this.setContinue(),this.flags}}class Rd extends md{run(e){const t=e.parent,n=[...t.children];if(!R(n,e=>e instanceof ba)||t.numChildren()<=1)return this.setContinue(),this.flags;const i=[];let r;for(const e of n)if(e instanceof ba){let n=e;for(;1===n.numChildren();){const e=n.children[0];if(!(e instanceof ba))break;n=e}i.push(...n.children),r?(t.removeChild(e),e.parent=r.parent,r.parent.removeChild(r),r.parent=n,this.setMutated()):r=n}else i.push(e);if(i.length){this.setMutated();for(const e of i)e.parent.removeChild(e),e.parent=r}return this.setContinue(),this.flags}}const Ld="scale_",Wd=5;function qd(e){const t=[];return e.forEach((function e(n){0===n.numChildren()?t.push(n):n.children.forEach(e)})),t}function Id(e){return e}function Hd(e,t){return t.map(t=>{if(e instanceof md){const n=e.optimizeNextFromLeaves(t);return e.reset(),n}return e.run(t)}).some(Id)}function Gd(e,t){let n=e.sources;const i=new Set;return i.add(Hd(new zd,n)),i.add(Hd(new Td(t),n)),n=n.filter(e=>e.numChildren()>0),i.add(Hd(new $d,qd(n))),n=n.filter(e=>e.numChildren()>0),i.add(Hd(new Sd,qd(n))),i.add(Hd(new Ud(t),qd(n))),i.add(Hd(new Bd,qd(n))),i.add(Hd(new Pd,qd(n))),i.add(Hd(new Md,qd(n))),i.add(Hd(new Nd,qd(n))),i.add(Hd(new kd,n)),i.add(Hd(new Rd,qd(n))),e.sources=n,i.has(!0)}class Yd{constructor(e){Object.defineProperty(this,"signal",{enumerable:!0,get:e})}static fromName(e,t){return new Yd(()=>e(t))}}function Vd(e){vf(e)?function(e){const t=e.component.scales;Y(t).forEach(n=>{const i=function(e,t){const n=e.getScaleComponent(t).get("type"),i=function(e,t,n,i){if("unaggregated"===e){const{valid:e,reason:i}=Xd(t,n);if(!e)return void Qt(i)}else if(void 0===e&&i.useUnaggregatedDomain){const{valid:e}=Xd(t,n);if(e)return"unaggregated"}return e}(e.scaleDomain(t),e.fieldDef(t),n,e.config.scale);i!==e.scaleDomain(t)&&(e.specifiedScales[t]=Object.assign(Object.assign({},e.specifiedScales[t]),{domain:i}));if("x"===t&&e.channelHasField("x2"))return e.channelHasField("x")?zl(Jd(n,i,e,"x"),Jd(n,i,e,"x2"),"domain","scale",Zd):Jd(n,i,e,"x2");if("y"===t&&e.channelHasField("y2"))return e.channelHasField("y")?zl(Jd(n,i,e,"y"),Jd(n,i,e,"y2"),"domain","scale",Zd):Jd(n,i,e,"y2");return Jd(n,i,e,t)}(e,n);if(t[n].setWithExplicit("domains",i),function(e,t){const n=e.component.scales[t],i=e.specifiedScales[t].domain,r=e.fieldDef(t).bin,o=Qn(i)&&i,s=dr(r)&&fr(r.extent)&&r.extent;(o||s)&&n.set("selectionExtent",null!=o?o:s,!0)}(e,n),e.component.data.isFaceted){let t=e;for(;!yf(t)&&t.parent;)t=t.parent;if("shared"===t.component.resolve.scale[n])for(const e of i.value)fs(e)&&(e.data=Ld+e.data.replace(Ld,""))}})}(e):function(e){for(const t of e.children)Vd(t);const t=e.component.scales;Y(t).forEach(n=>{let i,r=null;for(const t of e.children){const e=t.component.scales[n];if(e){i=void 0===i?e.getWithExplicit("domains"):zl(i,e.getWithExplicit("domains"),"domains","scale",Zd);const t=e.get("selectionExtent");r&&t&&r.selection!==t.selection&&Qt("The same selection must be used to override scale domains in a layered view."),r=t}}t[n].setWithExplicit("domains",i),r&&t[n].set("selectionExtent",r,!0)})}(e)}function Jd(e,t,n,i){const r=n.fieldDef(i);if(t&&"unaggregated"!==t&&!Qn(t)){const{type:e,timeUnit:n}=r;return $l("temporal"===e||n?function(e,t,n){return e.map(e=>{return{signal:`{data: ${or(e,{timeUnit:n,type:t})}}`}})}(t,e,n):[t])}const o=n.stack;if(o&&i===o.fieldChannel){if("normalize"===o.offset)return Bl([[0,1]]);const e=n.requestDataName(Io);return Bl([{data:e,field:n.vgField(i,{suffix:"start"})},{data:e,field:n.vgField(i,{suffix:"end"})}])}const a=Rt(i)?function(e,t,n){if(!Gn(n))return;const i=e.fieldDef(t),r=i.sort;if(ji(r))return{op:"min",field:al(i,t),order:"ascending"};const o=null!==e.stack;if(Ci(r))return Qd(r,o);if(Fi(r)){const{encoding:t,order:n}=r,i=e.fieldDef(t),{aggregate:s,field:a}=i;if(_e(s)||ze(s))return Qd({field:Wi(i),order:n},o);if(Te(s)||!s)return Qd({op:s,field:a,order:n},o)}else{if("descending"===r)return{op:"min",field:e.vgField(t),order:"descending"};if(U(["ascending",void 0],r))return!0}return}(n,i,e):void 0;if("unaggregated"===t){const e=n.requestDataName(Io),{field:t}=r;return Bl([{data:e,field:Wi({field:t,aggregate:"min"})},{data:e,field:Wi({field:t,aggregate:"max"})}])}if(cr(r.bin)){if(Gn(e))return Bl("bin-ordinal"===e?[]:[{data:J(a)?n.requestDataName(Io):n.requestDataName(Ho),field:n.vgField(i,ar(r,i)?{binSuffix:"range"}:{}),sort:!0!==a&&s(a)?a:{field:n.vgField(i,{}),op:"min"}}]);{const{bin:e}=r;if(cr(e)){const t=ad(n,r.field,e);return Bl([new Yd(()=>{const e=n.getSignalName(t);return`[${e}.start, ${e}.stop]`})])}return Bl([{data:n.requestDataName(Io),field:n.vgField(i,{})}])}}if(r.timeUnit&&U(["time","utc"],e)&&Bi(i,r,vf(n)?n.encoding[St(i)]:void 0,n.markDef,n.config)){const e=n.requestDataName(Io);return Bl([{data:e,field:n.vgField(i)},{data:e,field:n.vgField(i,{suffix:"end"})}])}return Bl(a?[{data:J(a)?n.requestDataName(Io):n.requestDataName(Ho),field:n.vgField(i),sort:a}]:[{data:n.requestDataName(Io),field:n.vgField(i)}])}function Qd(e,t){const{op:n,field:i,order:r}=e;return Object.assign(Object.assign({op:null!=n?n:t?"sum":Ai},i?{field:te(i)}:{}),r?{order:r}:{})}function Xd(e,t){const{aggregate:n,type:i}=e;return n?a(n)&&!Re[n]?{valid:!1,reason:Ht.unaggregateDomainWithNonSharedDomainOp(n)}:"quantitative"===i&&"log"===t?{valid:!1,reason:Ht.unaggregatedDomainWithLogScale(e)}:{valid:!0}:{valid:!1,reason:Ht.unaggregateDomainHasNoEffectForRawField(e)}}function Zd(e,t,n,i){return e.explicit&&t.explicit&&Qt(Ht.mergeConflictingDomainProperty(n,i,e.value,t.value)),{explicit:e.explicit,value:[...e.value,...t.value]}}function Kd(e){if(fs(e)&&a(e.field))return e.field;if(function(e){return!o(e)&&("fields"in e&&!("data"in e))}(e)){let t;for(const n of e.fields)if(fs(n)&&a(n.field))if(t){if(t!==n.field)return Qt("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."),t}else t=n.field;return Qt("Detected faceted independent scales that union domain of identical fields from different source detected. We will assume that this is the same field from a different fork of the same data source. However, if this is not case, the result view size maybe incorrect."),t}if(function(e){return!o(e)&&("fields"in e&&"data"in e)}(e)){Qt("Detected faceted independent scales that union domain of multiple fields from the same data source. We will use the first field. The result view size may be incorrect.");const t=e.fields[0];return a(t)?t:void 0}}function ef(e,t){return function(e){const t=q(e.map(e=>{if(fs(e)){return $e(e,["sort"])}return e}),P),n=q(e.map(e=>{if(fs(e)){const t=e.sort;return void 0===t||J(t)||("op"in t&&"count"===t.op&&delete t.field,"ascending"===t.order&&delete t.order),t}}).filter(e=>void 0!==e),P);if(0===t.length)return;if(1===t.length){const t=e[0];if(fs(t)&&n.length>0){let e=n[0];return n.length>1&&(Qt(Ht.MORE_THAN_ONE_SORT),e=!0),Object.assign(Object.assign({},t),{sort:e})}return t}const i=q(n.map(e=>J(e)||!("op"in e)||e.op in Ne?e:(Qt(Ht.domainSortDropped(e)),!0)),P);let r;1===i.length?r=i[0]:i.length>1&&(Qt(Ht.MORE_THAN_ONE_SORT),r=!0);const o=q(e.map(e=>fs(e)?e.data:null),e=>e);if(1===o.length&&null!==o[0]){return Object.assign({data:o[0],fields:t.map(e=>e.field)},r?{sort:r}:{})}return Object.assign({fields:t},r?{sort:r}:{})}(e.component.scales[t].get("domains").map(t=>(fs(t)&&(t.data=e.lookupDataSource(t.data)),t)))}function tf(e){return Y(e.component.scales).reduce((t,n)=>{const i=e.component.scales[n];if(i.merged)return t;const r=i.combine(),{name:o,type:s,selectionExtent:a,domains:u,range:c}=r,l=$e(r,["name","type","selectionExtent","domains","range"]),d=function(e,t,n){if(("x"===n||"y"===n)&&ds(e))return{step:{signal:t+"_step"}};return e}(r.range,o,n);let f;a&&(f=function(e,t){const n=t.selection;return{signal:Yc(e.getSelectionComponent(n,Q(n)),t)}}(e,a));const p=ef(e,n);return t.push(Object.assign(Object.assign(Object.assign(Object.assign({name:o,type:s},p?{domain:p}:{}),f?{domainRaw:f}:{}),{range:d}),l)),t},[])}class nf extends kl{constructor(e,t){super({},{name:e}),this.merged=!1,this.setWithExplicit("type",t)}domainDefinitelyIncludesZero(){return!1!==this.get("zero")||R(this.get("domains"),e=>o(e)&&2===e.length&&e[0]<=0&&e[1]>=0)}}const rf=["range","scheme"];function of(e){return"x"===e?"width":"y"===e?"height":void 0}function sf(e){const t=e.component.scales;Ut.forEach(n=>{const i=t[n];if(!i)return;const r=function(e,t){const n=t.specifiedScales[e],{size:i}=t,r=t.getScaleComponent(e).get("type");for(const t of rf)if(void 0!==n[t]){const i=Kn(r,t),o=ei(e,t);if(i)if(o)Qt(o);else switch(t){case"range":return $l(n[t]);case"scheme":return $l(uf(n[t]))}else Qt(Ht.scalePropertyNotWorkWithScaleType(r,t,e))}if(e===Ie||e===He){const t=e===Ie?"width":"height",n=i[t];if(io(n)){if(Gn(r))return $l({step:n.step});Qt(Ht.stepDropped(t))}}return Bl(function(e,t){const{size:n,config:i,mark:r}=t,s=t.getSignalName.bind(t),{type:a}=t.fieldDef(e),u=t.getScaleComponent(e).get("type"),{domain:c}=t.specifiedScales[e];switch(e){case Ie:case He:{if(U(["point","band"],u))if(e!==Ie||n.width){if(e===He&&!n.height){const e=ao(i.view,"height");if(io(e))return e}}else{const e=ao(i.view,"width");if(io(e))return e}const r=of(e),o=t.getName(r);return e===He&&Yn(u)?[Yd.fromName(s,o),0]:[0,Yd.fromName(s,o)]}case nt:{const s=t.component.scales[e].get("zero"),a=function(e,t,n){if(t)return 0;switch(e){case"bar":case"tick":return n.scale.minBandSize;case"line":case"trail":case"rule":return n.scale.minStrokeWidth;case"text":return n.scale.minFontSize;case"point":case"square":case"circle":return n.scale.minSize}throw new Error(Ht.incompatibleChannel("size",e))}(r,s,i),l=function(e,t,n,i){const r={x:af(n,"x"),y:af(n,"y")};switch(e){case"bar":case"tick":{if(void 0!==i.scale.maxBandSize)return i.scale.maxBandSize;const e=lf(t,r,i.view);return F(e)?e-1:new Yd(()=>`${e.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 e=lf(t,r,i.view);return F(e)?Math.pow(cf*e,2):new Yd(()=>`pow(${cf} * ${e.signal}, 2)`)}}throw new Error(Ht.incompatibleChannel("size",e))}(r,n,t,i);return Jn(u)?function(e,t,n){const i=()=>{const i=`(${ls(t)?t.signal:t} - ${e}) / (${n} - 1)`;return`sequence(${e}, ${t} + ${i}, ${i})`};return ls(t)?new Yd(i):{signal:i()}}(a,l,function(e,t,n,i){switch(e){case"quantile":return t.scale.quantileCount;case"quantize":return t.scale.quantizeCount;case"threshold":return void 0!==n&&o(n)?n.length+1:(Qt(Ht.domainRequiredForThresholdScale(i)),3)}}(u,i,c,e)):[a,l]}case st:return[i.scale.minStrokeWidth,i.scale.maxStrokeWidth];case tt:return"symbol";case Ze:case Ke:case et:return"ordinal"===u?"nominal"===a?"category":"ordinal":"rect"===r||"geoshape"===r?"heatmap":"ramp";case it:case rt:case ot:return[i.scale.minOpacity,i.scale.maxOpacity]}throw new Error(`Scale range undefined for channel ${e}`)}(e,t))}(n,e);i.setWithExplicit("range",r)})}function af(e,t){const n=e.fieldDef(t);if(n&&n.bin&&cr(n.bin)){const i=ad(e,n.field,n.bin),r=of(t),o=e.getName(r);return new Yd(()=>{const t=e.getSignalName(i),n=`(${t}.stop - ${t}.start) / ${t}.step`;return`${e.getSignalName(o)} / (${n})`})}}function uf(e){return function(e){return!a(e)&&!!e.name}(e)?Object.assign({scheme:e.name},z(e,["name"])):{scheme:e}}const cf=.95;function lf(e,t,n){const i=io(e.width)?e.width.step:so(n,"width"),r=io(e.height)?e.height.step:so(n,"height");return t.x||t.y?new Yd(()=>{return`min(${[t.x?t.x.signal:i,t.y?t.y.signal:r].join(", ")})`}):Math.min(i,r)}function df(e,t){vf(e)?function(e,t){const n=e.component.scales;Y(n).forEach(i=>{const r=e.specifiedScales[i],s=n[i],a=e.getScaleComponent(i),u=e.fieldDef(i),c=e.config,l=r[t],d=a.get("type"),f=Kn(d,t),p=ei(i,t);if(void 0!==l&&(f?p&&Qt(p):Qt(Ht.scalePropertyNotWorkWithScaleType(d,t,i))),f&&void 0===p)if(void 0!==l)s.copyKeyFromObject(t,r);else{const n=function(e,t,n,i,r,s,a,u,c,l){const d=l.scale,{type:f,sort:p}=i;switch(e){case"bins":return function(e,t){const n=t.bin;if(cr(n)){const i=ad(e,t.field,n);return new Yd(()=>e.getSignalName(i))}if(lr(n)&&dr(n)&&void 0!==n.step)return{step:n.step};return}(t,i);case"interpolate":return function(e,t){if(U([Ze,Ke,et],e)&&"nominal"!==t)return"hcl";return}(n,f);case"nice":return function(e,t,n){if(n.bin||U([zn.TIME,zn.UTC],e))return;return!!U([Ie,He],t)||void 0}(r,n,i);case"padding":return function(e,t,n,i,r,o){if(U([Ie,He],e)){if(Vn(t)){if(void 0!==n.continuousPadding)return n.continuousPadding;const{type:t,orient:s}=r;if("bar"===t&&!i.bin&&!i.timeUnit&&("vertical"===s&&"x"===e||"horizontal"===s&&"y"===e))return o.continuousBandSize}if(t===zn.POINT)return n.pointPadding}return}(n,r,d,i,c,l.bar);case"paddingInner":return function(e,t,n,i){if(void 0!==e)return;if(U([Ie,He],t)){const{bandPaddingInner:e,barBandPaddingInner:t,rectBandPaddingInner:r}=i;return oe(e,"bar"===n?t:r)}return}(s,n,c.type,d);case"paddingOuter":return function(e,t,n,i,r,o){if(void 0!==e)return;if(U([Ie,He],t)&&n===zn.BAND){const{bandPaddingOuter:e}=o;return oe(e,r/2)}return}(s,n,r,c.type,a,d);case"reverse":return function(e,t){if(Yn(e)&&"descending"===t)return!0;return}(r,p);case"zero":return function(e,t,n,i,r){if(n&&"unaggregated"!==n&&Yn(r)){if(o(n)){const e=n[0],t=n[n.length-1];if(e<=0&&t>=0)return!0}return!1}if("size"===e&&"quantitative"===t.type&&!Jn(r))return!0;if(!t.bin&&U([Ie,He],e)){const{orient:t,type:n}=i;return!U(["bar","area","line","trail"],n)||!("horizontal"===t&&"y"===e||"vertical"===t&&"x"===e)}return!1}(n,i,u,c,r)}return d[e]}(t,e,i,u,a.get("type"),a.get("padding"),a.get("paddingInner"),r.domain,e.markDef,c);void 0!==n&&s.set(t,n,!1)}})}(e,t):pf(e,t)}function ff(e){vf(e)?sf(e):pf(e,"range")}function pf(e,t){const n=e.component.scales;for(const n of e.children)"range"===t?ff(n):df(n,t);Y(n).forEach(i=>{let r;for(const n of e.children){const e=n.component.scales[i];if(e){r=zl(r,e.getWithExplicit(t),t,"scale",Nl((e,n)=>{switch(t){case"range":return e.step&&n.step?e.step-n.step:0}return 0}))}}n[i].setWithExplicit(t,r)})}function gf(e,t,n,i){const r=function(e,t,n){switch(t.type){case"nominal":case"ordinal":return bt(e)||"discrete"===It(e)?("shape"===e&&"ordinal"===t.type&&Qt(Ht.discreteChannelCannotEncode(e,"ordinal")),"ordinal"):U(["x","y"],e)&&U(["rect","bar","image","rule"],n)?"band":"point";case"temporal":return bt(e)?"time":"discrete"===It(e)?(Qt(Ht.discreteChannelCannotEncode(e,"temporal")),"ordinal"):"time";case"quantitative":return bt(e)?cr(t.bin)?"bin-ordinal":"linear":"discrete"===It(e)?(Qt(Ht.discreteChannelCannotEncode(e,"quantitative")),"ordinal"):"linear";case"geojson":return}throw new Error(Ht.invalidFieldType(t.type))}(t,n,i),{type:o}=e;return Rt(t)?void 0!==o?ni(t,o)?ti(o,n.type)?o:(Qt(Ht.scaleTypeNotWorkWithFieldDef(o,r)),r):(Qt(Ht.scaleTypeNotWorkWithChannel(t,o,r)),r):r:null}function hf(e){vf(e)?e.component.scales=function(e){const{encoding:t,mark:n}=e;return Ut.reduce((i,r)=>{let o,s;const a=t[r];if(zi(a)&&n===xe&&r===tt&&a.type===_n)return i;if(zi(a)?(o=a,s=a.scale):_i(a)&&(o=a.condition,s=a.condition.scale),o&&null!==s&&!1!==s){s=null!=s?s:{};const t=gf(s,r,o,n);i[r]=new nf(e.scaleName(r+"",!0),{value:t,explicit:s.type===t})}return i},{})}(e):e.component.scales=function(e){const t=e.component.scales={},n={},i=e.component.resolve;for(const t of e.children)hf(t),Y(t.component.scales).forEach(r=>{var o;if(i.scale[r]=null!=(o=i.scale[r])?o:El(r,e),"shared"===i.scale[r]){const e=n[r],o=t.component.scales[r].getWithExplicit("type");e?Mn(e.value,o.value)?n[r]=zl(e,o,"type","scale",mf):(i.scale[r]="independent",delete n[r]):n[r]=o}});for(const i of Y(n)){const r=e.scaleName(i,!0),o=n[i];t[i]=new nf(r,o);for(const t of e.children){const e=t.component.scales[i];e&&(t.renameScale(e.get("name"),r),e.merged=!0)}}return t}(e)}const mf=Nl((e,t)=>Rn(e)-Rn(t));class bf{constructor(){this.nameMap={}}rename(e,t){this.nameMap[e]=t}has(e){return void 0!==this.nameMap[e]}get(e){for(;this.nameMap[e]&&e!==this.nameMap[e];)e=this.nameMap[e];return e}}function vf(e){var t;return"unit"===(null===(t=e)||void 0===t?void 0:t.type)}function yf(e){var t;return"facet"===(null===(t=e)||void 0===t?void 0:t.type)}function xf(e){var t;return"repeat"===(null===(t=e)||void 0===t?void 0:t.type)}function Af(e){var t;return"concat"===(null===(t=e)||void 0===t?void 0:t.type)}function Of(e){var t;return"layer"===(null===(t=e)||void 0===t?void 0:t.type)}class wf{constructor(e,t,n,i,r,s,a,u){var c,l;this.type=t,this.parent=n,this.config=r,this.repeater=s,this.view=u,this.children=[],this.correctDataNames=e=>(e.from&&e.from.data&&(e.from.data=this.lookupDataSource(e.from.data)),e.from&&e.from.facet&&e.from.facet.data&&(e.from.facet.data=this.lookupDataSource(e.from.facet.data)),e),this.parent=n,this.config=r,this.repeater=s,this.name=null!=(c=e.name)?c:i,this.title=oi(e.title)?{text:e.title}:e.title,this.scaleNameMap=n?n.scaleNameMap:new bf,this.projectionNameMap=n?n.projectionNameMap:new bf,this.signalNameMap=n?n.signalNameMap:new bf,this.data=e.data,this.description=e.description,this.transforms=(l=e.transform,(null!=l?l:[]).map(e=>Go(e)?{filter:$(e.filter,En)}:e)),this.layout=Se(e)||bo(e)?{}:function(e,t,n){var i,r;const s=n[t],a={},{spacing:u,columns:c}=s;void 0!==u&&(a.spacing=u),void 0!==c&&(Ei(e)&&!Di(e.facet)||no(e)&&o(e.repeat)||Kr(e))&&(a.columns=c);for(const t of ro)if(void 0!==e[t])if("spacing"===t){const n=e[t];a[t]=F(n)?n:{row:(i=n.row,null!=i?i:u),column:(r=n.column,null!=r?r:u)}}else a[t]=e[t];return a}(e,t,r),this.component={data:{sources:n?n.component.data.sources:[],outputNodes:n?n.component.data.outputNodes:{},outputNodeRefCounts:n?n.component.data.outputNodeRefCounts:{},isFaceted:Ei(e)||n&&n.component.data.isFaceted&&void 0===e.data},layoutSize:new kl,layoutHeaders:{row:{},column:{},facet:{}},mark:null,resolve:Object.assign({scale:{},axis:{},legend:{}},a?N(a):{}),selection:null,scales:null,projection:null,axes:{},legends:{}}}get width(){return this.getSizeSignalRef("width")}get height(){return this.getSizeSignalRef("height")}parse(){this.parseScale(),this.parseLayoutSize(),this.renameTopLevelLayoutSizeSignal(),this.parseSelections(),this.parseProjection(),this.parseData(),this.parseAxesAndHeaders(),this.parseLegends(),this.parseMarkGroup()}parseScale(){!function(e,{ignoreRange:t}={}){hf(e),Vd(e);for(const t of Zn)df(e,t);t||ff(e)}(this)}parseProjection(){od(this)}renameTopLevelLayoutSizeSignal(){"width"!==this.getName("width")&&this.renameSignal(this.getName("width"),"width"),"height"!==this.getName("height")&&this.renameSignal(this.getName("height"),"height")}parseLegends(){Jl(this)}assembleGroupStyle(){var e,t;if("unit"===this.type||"layer"===this.type)return null!=(t=null===(e=this.view)||void 0===e?void 0:e.style)?t:"cell"}assembleEncodeFromView(e){const t=$e(e,["style"]),n={};for(const e in t)if(O(t,e)){const i=t[e];void 0!==i&&(n[e]={value:i})}return n}assembleGroupEncodeEntry(e){let t=void 0;return this.view&&(t=this.assembleEncodeFromView(this.view)),e||"unit"!==this.type&&"layer"!==this.type?t:Object.assign({width:this.getSizeSignalRef("width"),height:this.getSizeSignalRef("height")},null!=t?t:{})}assembleLayout(){if(!this.layout)return;const e=this.layout,{spacing:t}=e,n=$e(e,["spacing"]),{component:i,config:r}=this,o=function(e,t){var n;const i={};for(const r of yt){const o=e[r];if(null===(n=o)||void 0===n?void 0:n.facetFieldDef){const{titleAnchor:e,titleOrient:n}=ll(["titleAnchor","titleOrient"],o.facetFieldDef,t,r),s=ul(r,n),a=Al(e,s);void 0!==a&&(i[s]=a)}}return Y(i).length>0?i:void 0}(i.layoutHeaders,r);return Object.assign(Object.assign(Object.assign({padding:t},this.assembleDefaultLayout()),n),o?{titleBand:o}:{})}assembleDefaultLayout(){return{}}assembleHeaderMarks(){const{layoutHeaders:e}=this.component;let t=[];for(const n of yt)e[n].title&&t.push(pl(this,n));for(const e of dl)t=t.concat(ml(this,e));return t}assembleAxes(){return function(e,t){const{x:n=[],y:i=[]}=e;return[...n.map(e=>Qc(e,"grid",t)),...i.map(e=>Qc(e,"grid",t)),...n.map(e=>Qc(e,"main",t)),...i.map(e=>Qc(e,"main",t))].filter(e=>e)}(this.component.axes,this.config)}assembleLegends(){return ed(this)}assembleProjections(){return td(this)}assembleTitle(){var e,t,n;const i=null!=(e=this.title)?e:{},{encoding:r}=i,o=$e(i,["encoding"]),s=Object.assign(Object.assign(Object.assign({},ri(this.config.title).nonMark),o),r?{encode:{update:r}}:{});if(s.text)return U(["unit","layer"],this.type)?U(["middle",void 0],s.anchor)&&(s.frame=null!=(t=s.frame)?t:"group"):s.anchor=null!=(n=s.anchor)?n:"start",Y(s).length>0?s:void 0}assembleGroup(e=[]){const t={};(e=e.concat(this.assembleSignals())).length>0&&(t.signals=e);const n=this.assembleLayout();n&&(t.layout=n),t.marks=[].concat(this.assembleHeaderMarks(),this.assembleMarks());const i=!this.parent||yf(this.parent)?function e(t){return Of(t)||Af(t)||xf(t)?t.children.reduce((t,n)=>t.concat(e(n)),tf(t)):tf(t)}(this):[];i.length>0&&(t.scales=i);const r=this.assembleAxes();r.length>0&&(t.axes=r);const o=this.assembleLegends();return o.length>0&&(t.legends=o),t}hasDescendantWithFieldOnChannel(e){for(const t of this.children)if(vf(t)){if(t.channelHasField(e))return!0}else if(t.hasDescendantWithFieldOnChannel(e))return!0;return!1}getName(e){return Q((this.name?this.name+"_":"")+e)}requestDataName(e){var t;const n=this.getName(e),i=this.component.data.outputNodeRefCounts;return i[n]=(null!=(t=i[n])?t:0)+1,n}getSizeSignalRef(e){if(yf(this.parent)){const t=zt(e),n=this.component.scales[t];if(n&&!n.merged){const e=n.get("type"),i=n.get("range");if(Gn(e)&&ds(i)){const e=n.get("name"),i=Kd(ef(this,t));if(i){return{signal:jl(e,n,Wi({aggregate:"distinct",field:i},{expr:"datum"}))}}return Qt(`Unknown field for ${t}. Cannot calculate view size.`),null}}}return{signal:this.signalNameMap.get(this.getName(e))}}lookupDataSource(e){const t=this.component.data.outputNodes[e];return t?t.getSource():e}getSignalName(e){return this.signalNameMap.get(e)}renameSignal(e,t){this.signalNameMap.rename(e,t)}renameScale(e,t){this.scaleNameMap.rename(e,t)}renameProjection(e,t){this.projectionNameMap.rename(e,t)}scaleName(e,t){return t?this.getName(e):Ct(e)&&Rt(e)&&this.component.scales[e]||this.scaleNameMap.has(this.getName(e))?this.scaleNameMap.get(this.getName(e)):void 0}projectionName(e){return e?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(e){if(!this.component.scales)throw new Error("getScaleComponent cannot be called before parseScale(). Make sure you have called parseScale or use parseUnitModelWithScale().");const t=this.component.scales[e];return t&&!t.merged?t:this.parent?this.parent.getScaleComponent(e):void 0}getSelectionComponent(e,t){let n=this.component.selection[e];if(!n&&this.parent&&(n=this.parent.getSelectionComponent(e,t)),!n)throw new Error(Ht.selectionNotFound(t));return n}}class Ff extends wf{vgField(e,t={}){const n=this.fieldDef(e);if(n)return Wi(n,t)}reduceFieldDef(e,t){return xr(this.getMapping(),(t,n,i)=>{const r=Zi(n);return r?e(t,r,i):t},t)}forEachFieldDef(e,t){yr(this.getMapping(),(t,n)=>{const i=Zi(t);i&&e(i,n)},t)}}class Cf extends ma{constructor(e,t){var n,i,r;super(e),this.transform=t,this.transform=N(t);const o=null!=(n=this.transform.as)?n:[void 0,void 0];this.transform.as=[(i=o[0],null!=i?i:"value"),(r=o[1],null!=r?r:"density")]}clone(){return new Cf(null,N(this.transform))}dependentFields(){var e;return new Set([this.transform.density,...(e=this.transform.groupby,null!=e?e:[])])}producedFields(){return new Set(this.transform.as)}hash(){return`DensityTransform ${P(this.transform)}`}assemble(){const e=this.transform,{density:t}=e,n=$e(e,["density"]);return Object.assign({type:"kde",field:t},n)}}class jf extends ma{constructor(e,t){super(e),this.filter=t}clone(){return new jf(null,Object.assign({},this.filter))}static make(e,t){const{config:n,mark:i,markDef:r}=t;if("filter"!==ui("invalid",r,n))return null;const o=t.reduceFieldDef((e,n,r)=>{const o=Rt(r)&&t.getScaleComponent(r);if(o){!Yn(o.get("type"))||n.aggregate||Ae(i)||(e[n.field]=n)}return e},{});return Y(o).length?new jf(e,o):null}dependentFields(){return new Set(Y(this.filter))}producedFields(){return new Set}hash(){return`FilterInvalid ${P(this.filter)}`}assemble(){const e=Y(this.filter).reduce((e,t)=>{const n=this.filter[t],i=Wi(n,{expr:"datum"});return null!==n&&("temporal"===n.type?e.push(`(isDate(${i}) || (isValid(${i}) && isFinite(+${i})))`):"quantitative"===n.type&&(e.push(`isValid(${i})`),e.push(`isFinite(+${i})`))),e},[]);return e.length>0?{type:"filter",expr:e.join(" && ")}:null}}class Df extends ma{constructor(e,t){super(e),this.transform=t,this.transform=N(t);const{flatten:n,as:i=[]}=this.transform;this.transform.as=n.map((e,t)=>{var n;return null!=(n=i[t])?n:e})}clone(){return new Df(this.parent,N(this.transform))}dependentFields(){return new Set(this.transform.flatten)}producedFields(){return new Set(this.transform.as)}hash(){return`FlattenTransform ${P(this.transform)}`}assemble(){const{flatten:e,as:t}=this.transform;return{type:"flatten",fields:e,as:t}}}class Ef extends ma{constructor(e,t){var n,i,r;super(e),this.transform=t,this.transform=N(t);const o=null!=(n=this.transform.as)?n:[void 0,void 0];this.transform.as=[(i=o[0],null!=i?i:"key"),(r=o[1],null!=r?r:"value")]}clone(){return new Ef(null,N(this.transform))}dependentFields(){return new Set(this.transform.fold)}producedFields(){return new Set(this.transform.as)}hash(){return`FoldTransform ${P(this.transform)}`}assemble(){const{fold:e,as:t}=this.transform;return{type:"fold",fields:e,as:t}}}class Sf extends ma{constructor(e,t,n,i){super(e),this.fields=t,this.geojson=n,this.signal=i}clone(){return new Sf(null,N(this.fields),this.geojson,this.signal)}static parseAll(e,t){if(t.component.projection&&!t.component.projection.isFit)return e;let n=0;for(const i of[[Je,Ve],[Xe,Qe]]){const r=i.map(e=>t.channelHasField(e)?t.fieldDef(e).field:Mi(t.encoding[e])?{expr:t.encoding[e].value+""}:void 0);(r[0]||r[1])&&(e=new Sf(e,r,null,t.getName(`geojson_${n++}`)))}if(t.channelHasField(tt)){const i=t.fieldDef(tt);i.type===_n&&(e=new Sf(e,null,i.field,t.getName(`geojson_${n++}`)))}return e}dependentFields(){var e;const t=(e=this.fields,null!=e?e:[]).filter(a);return new Set([...this.geojson?[this.geojson]:[],...t])}producedFields(){return new Set}hash(){return`GeoJSON ${this.geojson} ${this.signal} ${P(this.fields)}`}assemble(){return Object.assign(Object.assign(Object.assign({type:"geojson"},this.fields?{fields:this.fields}:{}),this.geojson?{geojson:this.geojson}:{}),{signal:this.signal})}}class kf extends ma{constructor(e,t,n,i){super(e),this.projection=t,this.fields=n,this.as=i}clone(){return new kf(null,this.projection,N(this.fields),N(this.as))}static parseAll(e,t){if(!t.projectionName())return e;for(const n of[[Je,Ve],[Xe,Qe]]){const i=n.map(e=>t.channelHasField(e)?t.fieldDef(e).field:Mi(t.encoding[e])?{expr:t.encoding[e].value+""}:void 0),r=n[0]===Xe?"2":"";(i[0]||i[1])&&(e=new kf(e,t.projectionName(),i,[t.getName("x"+r),t.getName("y"+r)]))}return e}dependentFields(){return new Set(this.fields.filter(a))}producedFields(){return new Set(this.as)}hash(){return`Geopoint ${this.projection} ${P(this.fields)} ${P(this.as)}`}assemble(){return{type:"geopoint",projection:this.projection,fields:this.fields,as:this.as}}}class $f extends ma{constructor(e,t){super(e),this.transform=t}clone(){return new $f(null,N(this.transform))}dependentFields(){var e;return new Set([this.transform.impute,this.transform.key,...(e=this.transform.groupby,null!=e?e:[])])}producedFields(){return new Set([this.transform.impute])}processSequence(e){const{start:t=0,stop:n,step:i}=e;return{signal:`sequence(${[t,n,...i?[i]:[]].join(",")})`}}static makeFromTransform(e,t){return new $f(e,t)}static makeFromEncoding(e,t){const n=t.encoding,i=n.x,r=n.y;if(zi(i)&&zi(r)){const o=i.impute?i:r.impute?r:void 0;if(void 0===o)return;const s=i.impute?r:r.impute?i:void 0,{method:a,value:u,frame:c,keyvals:l}=o.impute,d=Ar(t.mark,n);return new $f(e,Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({impute:o.field,key:s.field},a?{method:a}:{}),void 0!==u?{value:u}:{}),c?{frame:c}:{}),void 0!==l?{keyvals:l}:{}),d.length?{groupby:d}:{}))}return null}hash(){return`Impute ${P(this.transform)}`}assemble(){const{impute:e,key:t,keyvals:n,method:i,groupby:r,value:o,frame:s=[null,null]}=this.transform,a=Object.assign(Object.assign(Object.assign(Object.assign({type:"impute",field:e,key:t},n?{keyvals:(u=n,void 0!==(null===(c=u)||void 0===c?void 0:c.stop)?this.processSequence(n):n)}:{}),{method:"value"}),r?{groupby:r}:{}),{value:null});var u,c;let l;if(i&&"value"!==i){l=[Object.assign({type:"window",as:[`imputed_${e}_value`],ops:[i],fields:[e],frame:s,ignorePeers:!1},r?{groupby:r}:{}),{type:"formula",expr:`datum.${e} === null ? datum.imputed_${e}_value : datum.${e}`,as:e}]}else{l=[{type:"formula",expr:`datum.${e} === null ? ${o} : datum.${e}`,as:e}]}return[a,...l]}}class Bf extends kl{constructor(e={},t={},n=!1){super(e,t),this.explicit=e,this.implicit=t,this.parseNothing=n}clone(){const e=super.clone();return e.parseNothing=this.parseNothing,e}}class Nf extends ma{constructor(e,t){var n,i,r;super(e),this.transform=t,this.transform=N(t);const o=null!=(n=this.transform.as)?n:[void 0,void 0];this.transform.as=[(i=o[0],null!=i?i:t.on),(r=o[1],null!=r?r:t.loess)]}clone(){return new Nf(null,N(this.transform))}dependentFields(){var e;return new Set([this.transform.loess,this.transform.on,...(e=this.transform.groupby,null!=e?e:[])])}producedFields(){return new Set(this.transform.as)}hash(){return`LoessTransform ${P(this.transform)}`}assemble(){const e=this.transform,{loess:t,on:n}=e,i=$e(e,["loess","on"]);return Object.assign({type:"loess",x:n,y:t},i)}}class _f extends ma{constructor(e,t,n){super(e),this.transform=t,this.secondary=n}clone(){return new _f(null,N(this.transform),this.secondary)}static make(e,t,n,i){var r;const o=t.component.data.sources,{from:s}=n;let a=null;if(function(e){return void 0!==e.data}(s)){let e=np(s.data,o);e||(e=new ld(s.data),o.push(e));const n=t.getName(`lookup_${i}`);a=new ba(e,n,"lookup",t.component.data.outputNodeRefCounts),t.component.data.outputNodes[n]=a}else if(function(e){return void 0!==e.selection}(s)){const e=s.selection;if(n.as=null!=(r=n.as)?r:e,a=t.getSelectionComponent(Q(e),e).materialized,!a)throw new Error(Ht.noSameUnitLookup(e))}return new _f(e,n,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 ${P({transform:this.transform,secondary:this.secondary})}`}assemble(){let e;if(this.transform.from.fields)e=Object.assign({values:this.transform.from.fields},this.transform.as?{as:x(this.transform.as)}:{});else{let t=this.transform.as;a(t)||(Qt(Ht.NO_FIELDS_NEEDS_AS),t="_lookup"),e={as:[t]}}return Object.assign(Object.assign({type:"lookup",from:this.secondary,key:this.transform.from.key,fields:[this.transform.lookup]},e),this.transform.default?{default:this.transform.default}:{})}}class zf extends ma{constructor(e,t){var n,i,r;super(e),this.transform=t,this.transform=N(t);const o=null!=(n=this.transform.as)?n:[void 0,void 0];this.transform.as=[(i=o[0],null!=i?i:"prob"),(r=o[1],null!=r?r:"value")]}clone(){return new zf(null,N(this.transform))}dependentFields(){var e;return new Set([this.transform.quantile,...(e=this.transform.groupby,null!=e?e:[])])}producedFields(){return new Set(this.transform.as)}hash(){return`QuantileTransform ${P(this.transform)}`}assemble(){const e=this.transform,{quantile:t}=e,n=$e(e,["quantile"]);return Object.assign({type:"quantile",field:t},n)}}class Tf extends ma{constructor(e,t){var n,i,r;super(e),this.transform=t,this.transform=N(t);const o=null!=(n=this.transform.as)?n:[void 0,void 0];this.transform.as=[(i=o[0],null!=i?i:t.on),(r=o[1],null!=r?r:t.regression)]}clone(){return new Tf(null,N(this.transform))}dependentFields(){var e;return new Set([this.transform.regression,this.transform.on,...(e=this.transform.groupby,null!=e?e:[])])}producedFields(){return new Set(this.transform.as)}hash(){return`RegressionTransform ${P(this.transform)}`}assemble(){const e=this.transform,{regression:t,on:n}=e,i=$e(e,["regression","on"]);return Object.assign({type:"regression",x:n,y:t},i)}}class Pf extends ma{constructor(e,t){super(e),this.transform=t}clone(){return new Pf(null,N(this.transform))}addDimensions(e){var t;this.transform.groupby=q((t=this.transform.groupby,null!=t?t:[]).concat(e),e=>e)}producedFields(){}dependentFields(){var e;return new Set([this.transform.pivot,this.transform.value,...(e=this.transform.groupby,null!=e?e:[])])}hash(){return`PivotTransform ${P(this.transform)}`}assemble(){const{pivot:e,value:t,groupby:n,limit:i,op:r}=this.transform;return Object.assign(Object.assign(Object.assign({type:"pivot",field:e,value:t},void 0!==i?{limit:i}:{}),void 0!==r?{op:r}:{}),void 0!==n?{groupby:n}:{})}}class Mf extends ma{constructor(e,t){super(e),this.transform=t}clone(){return new Mf(null,N(this.transform))}dependentFields(){return new Set}producedFields(){return new Set}hash(){return`SampleTransform ${P(this.transform)}`}assemble(){return{type:"sample",size:this.transform.sample}}}function Uf(e){let t=0;return function n(i,r){var o;if(i instanceof ld&&!i.isGenerator&&!Po(i.data)){e.push(r),r={name:null,source:r.name,transform:[]}}if(i instanceof Fd&&(i.parent instanceof ld&&!r.source?(r.format=Object.assign(Object.assign({},null!=(o=r.format)?o:{}),{parse:i.assembleFormatParse()}),r.transform.push(...i.assembleTransforms(!0))):r.transform.push(...i.assembleTransforms())),i instanceof xd)return r.name||(r.name=`data_${t++}`),!r.source||r.transform.length>0?(e.push(r),i.data=r.name):i.data=r.source,void i.assemble().forEach(t=>e.push(t));if((i instanceof fd||i instanceof pd||i instanceof jf||i instanceof Hc||i instanceof sl||i instanceof kf||i instanceof Sf||i instanceof yd||i instanceof _f||i instanceof Dd||i instanceof Cd||i instanceof Ef||i instanceof Df||i instanceof Cf||i instanceof Nf||i instanceof zf||i instanceof Tf||i instanceof Ed||i instanceof Mf||i instanceof Pf)&&r.transform.push(i.assemble()),(i instanceof cd||i instanceof va||i instanceof $f||i instanceof jd)&&r.transform.push(...i.assemble()),i instanceof ba)if(r.source&&0===r.transform.length)i.setSource(r.source);else if(i.parent instanceof ba)i.setSource(r.name);else if(r.name||(r.name=`data_${t++}`),i.setSource(r.name),1===i.numChildren()){e.push(r),r={name:null,source:r.name,transform:[]}}switch(i.numChildren()){case 0:i instanceof ba&&(!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 o=r.name;!r.source||r.transform.length>0?e.push(r):o=r.source,i.children.forEach(e=>{n(e,{name:null,source:o,transform:[]})});break}}}}function Rf(e){return"top"===e||"left"===e?"header":"footer"}function Lf(e,t){var n;if(e.channelHasField(t)){const i=e.facet[t],r=cl("title",null,e.config,t);let s=Vi(i,e.config,{allowDisabling:!0,includeDefault:void 0===r||!!r});e.child.component.layoutHeaders[t].title&&(s=o(s)?s.join(", "):s,s+=" / "+e.child.component.layoutHeaders[t].title,e.child.component.layoutHeaders[t].title=null);const a=cl("labelOrient",i,e.config,t),u=oe((null!=(n=i.header)?n:{}).labels,!0),c=U(["bottom","right"],a)?"footer":"header";e.component.layoutHeaders[t]={title:s,facetFieldDef:i,[c]:"facet"===t?[]:[Wf(e,t,u)]}}}function Wf(e,t,n){const i="row"===t?"height":"width";return{labels:n,sizeSignal:e.child.component.layoutSize.get(i)?e.child.getSizeSignalRef(i):void 0,axes:[]}}function qf(e,t){var n;const{child:i}=e;if(i.component.axes[t]){const{layoutHeaders:r,resolve:o}=e.component;if(o.axis[t]=Sl(o,t),"shared"===o.axis[t]){const o="x"===t?"column":"row",s=r[o];for(const r of i.component.axes[t]){const t=Rf(r.get("orient"));s[t]=null!=(n=s[t])?n:[Wf(e,o,!1)];const i=Qc(r,"main",e.config,{header:!0});s[t][0].axes.push(i),r.mainExtracted=!0}}}}function If(e){Yf(e);const t=e.component.layoutSize;t.setWithExplicit("width",Vf(e,"width")),t.setWithExplicit("height",Vf(e,"height"))}const Hf=If,Gf={vconcat:"width",hconcat:"height"};function Yf(e){for(const t of e.children)t.parseLayoutSize()}function Vf(e,t){const n="width"===t?"x":"y",i=e.component.resolve;let r;for(const o of e.children){const e=o.component.layoutSize.getWithExplicit(t),s=i.scale[n];if("independent"===s&&"step"===e.value){r=void 0;break}if(r){if("independent"===s&&r.value!==e.value){r=void 0;break}r=zl(r,e,t,"")}else r=e}if(r){for(const n of e.children)e.renameSignal(n.getName(t),e.getName(t)),n.component.layoutSize.set(t,"merged",!1);return r}return{explicit:!1,value:void 0}}function Jf(e,t){const n="width"===t?"x":"y",i=e.config,r=e.getScaleComponent(n);if(r){const e=r.get("type"),n=r.get("range");if(Gn(e)){const e=ao(i.view,t);return ds(n)||io(e)?"step":e}return oo(i.view,t)}if(e.hasProjection)return oo(i.view,t);{const e=ao(i.view,t);return io(e)?e.step:e}}function Qf(e,t){return function(e){return e&&!a(e)&&"repeat"in e}(e.field)?e.field.repeat in t?Object.assign(Object.assign({},e),{field:t[e.field.repeat]}):void Qt(Ht.noSuchRepeatedValue(e.field.repeat)):e}function Xf(e,t){if(void 0!==(e=Qf(e,t))){if(null===e)return null;if(ki(e)&&Ci(e.sort)){const n=Qf(e.sort,t);e=Object.assign(Object.assign({},e),n?{sort:n}:{})}return e}}function Zf(e,t){if(!zi(e)){if(_i(e)){const n=Xf(e.condition,t);if(n)return Object.assign(Object.assign({},e),{condition:n});return $e(e,["condition"])}return e}{const n=Xf(e,t);if(n)return n;if(Ni(e))return{condition:e.condition}}}function Kf(e,t){const n={};for(const i in e)if(O(e,i)){const r=e[i];if(o(r))n[i]=r.map(e=>Zf(e,t)).filter(e=>e);else{const e=Zf(r,t);void 0!==e&&(n[i]=e)}}return n}function ep(e,t,n){return Wi(t,Object.assign({suffix:`by_${Wi(e)}`},null!=n?n:{}))}class tp extends Ff{constructor(e,t,n,i,r){super(e,"facet",t,n,r,i,e.resolve),this.child=jp(e.spec,this,this.getName("child"),void 0,i,r),this.children=[this.child];const o=function(e,t){return Di(e)?Kf(e,t):Xf(e,t)}(e.facet,i);this.facet=this.initFacet(o)}initFacet(e){return Di(e)?xr(e,(e,t,n)=>U([Le,We],n)?void 0===t.field?(Qt(Ht.emptyFieldDef(t,n)),e):(e[n]=er(t,n),e):(Qt(Ht.incompatibleChannel(n,"facet")),e),{}):{facet:er(e,"facet")}}channelHasField(e){return!!this.facet[e]}fieldDef(e){return this.facet[e]}parseData(){this.component.data=rp(this),this.child.parseData()}parseLayoutSize(){Yf(this)}parseSelections(){this.child.parseSelections(),this.component.selection=this.child.component.selection}parseMarkGroup(){this.child.parseMarkGroup()}parseAxesAndHeaders(){this.child.parseAxesAndHeaders(),function(e){for(const t of yt)Lf(e,t);qf(e,"x"),qf(e,"y")}(this)}assembleSelectionTopLevelSignals(e){return this.child.assembleSelectionTopLevelSignals(e)}assembleSignals(){return this.child.assembleSignals(),[]}assembleSelectionData(e){return this.child.assembleSelectionData(e)}getHeaderLayoutMixins(){var e,t,n,i;const r={};for(const o of yt)for(const s of fl){const a=this.component.layoutHeaders[o],u=a[s],{facetFieldDef:c}=a;if(c){const t=cl("titleOrient",c,this.config,o);if(U(["right","bottom"],t)){const n=ul(o,t);r.titleAnchor=null!=(e=r.titleAnchor)?e:{},r.titleAnchor[n]="end"}}if(null===(t=u)||void 0===t?void 0:t[0]){const e="row"===o?"height":"width",t="header"===s?"headerBand":"footerBand";"facet"===o||this.child.component.layoutSize.get(e)||(r[t]=null!=(n=r[t])?n:{},r[t][o]=.5),a.title&&(r.offset=null!=(i=r.offset)?i:{},r.offset["row"===o?"rowTitle":"columnTitle"]=10)}}return r}assembleDefaultLayout(){const{column:e,row:t}=this.facet,n=e?this.columnDistinctSignal():t?1:void 0;let i="all";return(t||"independent"!==this.component.resolve.scale.x)&&(e||"independent"!==this.component.resolve.scale.y)||(i="none"),Object.assign(Object.assign(Object.assign({},this.getHeaderLayoutMixins()),n?{columns:n}:{}),{bounds:"full",align:i})}assembleLayoutSignals(){return this.child.assembleLayoutSignals()}columnDistinctSignal(){if(!(this.parent&&this.parent instanceof tp)){return{signal:`length(data('${this.getName("column_domain")}'))`}}}assembleGroup(e){return this.parent&&this.parent instanceof tp?Object.assign(Object.assign({},this.channelHasField("column")?{encode:{update:{columns:{field:Wi(this.facet.column,{prefix:"distinct"})}}}}:{}),super.assembleGroup(e)):super.assembleGroup(e)}getCardinalityAggregateForChild(){const e=[],t=[],n=[];if(this.child instanceof tp){if(this.child.channelHasField("column")){const i=Wi(this.child.facet.column);e.push(i),t.push("distinct"),n.push(`distinct_${i}`)}}else for(const i of["x","y"]){const r=this.child.component.scales[i];if(r&&!r.merged){const o=r.get("type"),s=r.get("range");if(Gn(o)&&ds(s)){const r=Kd(ef(this.child,i));r?(e.push(r),t.push("distinct"),n.push(`distinct_${r}`)):Qt(`Unknown field for ${i}. Cannot calculate view size.`)}}}return{fields:e,ops:t,as:n}}assembleFacet(){const{name:e,data:t}=this.component.data.facetRoot,{row:n,column:i}=this.facet,{fields:r,ops:s,as:a}=this.getCardinalityAggregateForChild(),u=[];for(const e of yt){const t=this.facet[e];if(t){u.push(Wi(t));const{bin:c,sort:l}=t;if(cr(c)&&u.push(Wi(t,{binSuffix:"end"})),Ci(l)){const{field:e,op:o=Ai}=l,u=ep(t,l);n&&i?(r.push(u),s.push("max"),a.push(u)):(r.push(e),s.push(o),a.push(u))}else if(o(l)){const n=al(t,e);r.push(n),s.push("max"),a.push(n)}}}const c=!!n&&!!i;return Object.assign({name:e,data:t,groupby:u},c||r.length>0?{aggregate:Object.assign(Object.assign({},c?{cross:c}:{}),r.length?{fields:r,ops:s,as:a}:{})}:{})}facetSortFields(e){const{facet:t}=this,n=t[e];return n?Ci(n.sort)?[ep(n,n.sort,{expr:"datum"})]:o(n.sort)?[al(n,e,{expr:"datum"})]:[Wi(n,{expr:"datum"})]:[]}facetSortOrder(e){const{facet:t}=this,n=t[e];if(n){const{sort:e}=n;return[(Ci(e)?e.order:!o(e)&&e)||"ascending"]}return[]}assembleLabelTitle(){const{facet:e,config:t}=this;if(e.facet)return vl(e.facet,"facet",t);const n={row:["top","bottom"],column:["left","right"]};for(const i of dl)if(e[i]){const r=cl("labelOrient",e[i],t,i);if(U(n[i],r))return vl(e[i],i,t)}}assembleMarks(){const{child:e}=this,t=function(e){const t=[],n=Uf(t);return e.children.forEach(t=>n(t,{source:e.name,name:null,transform:[]})),t}(this.component.data.facetRoot),n=e.assembleGroupEncodeEntry(!1),i=this.assembleLabelTitle()||e.assembleTitle(),r=e.assembleGroupStyle();return[Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({name:this.getName("cell"),type:"group"},i?{title:i}:{}),r?{style:r}:{}),{from:{facet:this.assembleFacet()},sort:{field:yt.map(e=>this.facetSortFields(e)).flat(),order:yt.map(e=>this.facetSortOrder(e)).flat()}}),t.length>0?{data:t}:{}),n?{encode:{update:n}}:{}),e.assembleGroup(function(e,t){if(e.component.selection&&Y(e.component.selection).length){const n=u(e.getName("cell"));t.unshift({name:"facet",value:{},on:[{events:xs("mousemove","scope"),update:`isTuple(facet) ? facet : group(${n}).datum`}]})}return Ra(t)}(this,[])))]}getMapping(){return this.facet}}function np(e,t){var n,i,r,o,s,a,u,c,l,d;for(const f of t){const t=f.data;if((!e.name||!f.hasName()||e.name===f.dataName)&&!((null===(n=e.format)||void 0===n?void 0:n.mesh)&&(null===(i=t.format)||void 0===i?void 0:i.feature)||((null===(r=e.format)||void 0===r?void 0:r.feature)||(null===(o=t.format)||void 0===o?void 0:o.feature))&&(null===(s=e.format)||void 0===s?void 0:s.feature)!==(null===(a=t.format)||void 0===a?void 0:a.feature)||((null===(u=e.format)||void 0===u?void 0:u.mesh)||(null===(c=t.format)||void 0===c?void 0:c.mesh))&&(null===(l=e.format)||void 0===l?void 0:l.mesh)!==(null===(d=t.format)||void 0===d?void 0:d.mesh)))if(Mo(e)&&Mo(t)){if(B(e.values,t.values))return f}else if(Po(e)&&Po(t)){if(e.url===t.url)return f}else if(Uo(e)&&e.name===f.dataName)return f}return null}function ip(e,t){if(e.data||!e.parent){if(null===e.data){const e=new ld([]);return t.push(e),e}const n=np(e.data,t);if(n)return Ro(e.data)||(n.data.format=function(e,...t){for(const n of t)W(e,null!=n?n:{});return e}({},e.data.format,n.data.format)),!n.hasName()&&e.data.name&&(n.dataName=e.data.name),n;{const n=new ld(e.data);return t.push(n),n}}return e.parent.component.data.facetRoot?e.parent.component.data.facetRoot:e.parent.component.data.main}function rp(e){var t,n,i,r,o,s,a,u,c,l,d;let f=ip(e,e.component.data.sources);const{outputNodes:p,outputNodeRefCounts:g}=e.component.data,h=e.parent?e.parent.component.data.ancestorParse.clone():new Bf,m=e.data;Ro(m)?(Lo(m)?f=new pd(f,m.sequence):qo(m)&&(f=new fd(f,m.graticule)),h.parseNothing=!0):null===(null===(n=null===(t=m)||void 0===t?void 0:t.format)||void 0===n?void 0:n.parse)&&(h.parseNothing=!0),f=null!=(i=Fd.makeExplicit(f,e,h))?i:f,f=new Ed(f);const b=e.parent&&Of(e.parent);(vf(e)||yf(e))&&b&&(f=null!=(r=cd.makeFromEncoding(f,e))?r:f),e.transforms.length>0&&(f=function(e,t,n){var i,r;let o=0;for(const s of t.transforms){let a,u=void 0;if(is(s))a=e=new sl(e,s),u="derived";else if(Go(s)){const r=Od(s);a=e=null!=(i=Fd.makeWithAncestors(e,{},r,n))?i:e,e=new Hc(e,t,s.filter)}else if(rs(s))a=e=cd.makeFromTransform(e,s,t),u="number";else if(ss(s)){u="date",void 0===n.getWithExplicit(s.field).value&&(e=new Fd(e,{[s.field]:u}),n.set(s.field,u,!1)),a=e=va.makeFromTransform(e,s)}else if(as(s))a=e=yd.makeFromTransform(e,s),u="number",tu(t)&&(e=new Ed(e));else if(Yo(s))a=e=_f.make(e,t,s,o++),u="derived";else if(es(s))a=e=new Dd(e,s),u="number";else if(ts(s))a=e=new Cd(e,s),u="number";else if(us(s))a=e=jd.makeFromTransform(e,s),u="derived";else if(cs(s))a=e=new Ef(e,s),u="derived";else if(ns(s))a=e=new Df(e,s),u="derived";else if(Vo(s))a=e=new Pf(e,s),u="derived";else if(Ko(s))e=new Mf(e,s);else if(os(s))a=e=$f.makeFromTransform(e,s),u="derived";else if(Jo(s))a=e=new Cf(e,s),u="derived";else if(Qo(s))a=e=new zf(e,s),u="derived";else if(Xo(s))a=e=new Tf(e,s),u="derived";else{if(!Zo(s)){Qt(Ht.invalidTransformIgnored(s));continue}a=e=new Nf(e,s),u="derived"}if(a&&void 0!==u)for(const e of null!=(r=a.producedFields())?r:[])n.set(e,u,!1)}return e}(f,e,h));const v=function(e){const t={};if(vf(e)&&e.component.selection)for(const n of Y(e.component.selection)){const i=e.component.selection[n];for(const e of i.project.items)!e.channel&&re(e.field)>1&&(t[e.field]="flatten")}return t}(e),y=wd(e);f=null!=(o=Fd.makeWithAncestors(f,{},Object.assign(Object.assign({},v),y),h))?o:f,vf(e)&&(f=Sf.parseAll(f,e),f=kf.parseAll(f,e)),(vf(e)||yf(e))&&(b||(f=null!=(s=cd.makeFromEncoding(f,e))?s:f),f=null!=(a=va.makeFromEncoding(f,e))?a:f,f=sl.parseAllForSortIndex(f,e));const x=e.getName(Ho),A=new ba(f,x,Ho,g);if(p[x]=A,f=A,vf(e)){const t=yd.makeFromEncoding(f,e);t&&(f=t,tu(e)&&(f=new Ed(f))),f=null!=(u=$f.makeFromEncoding(f,e))?u:f,f=null!=(c=jd.makeFromEncoding(f,e))?c:f}vf(e)&&(f=null!=(l=jf.make(f,e))?l:f);const O=e.getName(Io),w=new ba(f,O,Io,g);p[O]=w,f=w,vf(e)&&function(e,t){Ka(e,n=>{const i=n.name,r=e.getName(`lookup_${i}`);e.component.data.outputNodes[r]=n.materialized=new ba(new Hc(t,e,{selection:i}),r,"lookup",e.component.data.outputNodeRefCounts)})}(e,w);let F=null;if(yf(e)){const t=e.getName("facet");f=sl.parseAllForSortIndex(f,e),f=null!=(d=function(e,t){const{row:n,column:i}=t;if(n&&i){let t=null;for(const r of[n,i])if(Ci(r.sort)){const{field:n,op:i=Ai}=r.sort;e=t=new Cd(e,{joinaggregate:[{op:i,field:n,as:ep(r,r.sort,{forAs:!0})}],groupby:[Wi(r)]})}return t}return null}(f,e.facet))?d:f,F=new xd(f,e,t,w.getSource()),p[t]=F,f=F}return Object.assign(Object.assign({},e.component.data),{outputNodes:p,outputNodeRefCounts:g,raw:A,main:w,facetRoot:F,ancestorParse:h})}class op extends wf{constructor(e,t,n,i,r,o,s){super(e,t,n,i,r,o,s)}parseData(){this.component.data=rp(this),this.children.forEach(e=>{e.parseData()})}parseSelections(){this.component.selection={};for(const e of this.children)e.parseSelections(),Y(e.component.selection).forEach(t=>{this.component.selection[t]=e.component.selection[t]})}parseMarkGroup(){for(const e of this.children)e.parseMarkGroup()}parseAxesAndHeaders(){for(const e of this.children)e.parseAxesAndHeaders()}assembleSelectionTopLevelSignals(e){return this.children.reduce((e,t)=>t.assembleSelectionTopLevelSignals(e),e)}assembleSignals(){return this.children.forEach(e=>e.assembleSignals()),[]}assembleLayoutSignals(){return this.children.reduce((e,t)=>[...e,...t.assembleLayoutSignals()],wl(this))}assembleSelectionData(e){return this.children.reduce((e,t)=>t.assembleSelectionData(e),e)}assembleMarks(){return this.children.map(e=>{const t=e.assembleTitle(),n=e.assembleGroupStyle(),i=e.assembleGroupEncodeEntry(!1);return Object.assign(Object.assign(Object.assign(Object.assign({type:"group",name:e.getName("group")},t?{title:t}:{}),n?{style:n}:{}),i?{encode:{update:i}}:{}),e.assembleGroup())})}}class sp extends op{constructor(e,t,n,i,r){var o,s,a,u;super(e,"concat",t,n,r,i,e.resolve),"shared"!==(null===(s=null===(o=e.resolve)||void 0===o?void 0:o.axis)||void 0===s?void 0:s.x)&&"shared"!==(null===(u=null===(a=e.resolve)||void 0===a?void 0:a.axis)||void 0===u?void 0:u.y)||Qt(Ht.CONCAT_CANNOT_SHARE_AXIS),this.concatType=eo(e)?"vconcat":to(e)?"hconcat":"concat",this.children=this.getChildren(e).map((e,t)=>jp(e,this,this.getName("concat_"+t),void 0,i,r))}getChildren(e){return eo(e)?e.vconcat:to(e)?e.hconcat:e.concat}parseLayoutSize(){!function(e){Yf(e);const t=e.component.layoutSize,n=Gf[e.concatType];n&&t.setWithExplicit(n,Vf(e,n))}(this)}parseAxisGroup(){return null}assembleDefaultLayout(){return Object.assign(Object.assign({},"vconcat"===this.concatType?{columns:1}:{}),{bounds:"full",align:"each"})}}const ap=Object.assign(Object.assign({gridScale:1,scale:1},vs),{labelExpr:1,encode:1}),up=Y(ap);class cp extends kl{constructor(e={},t={},n=!1){super(),this.explicit=e,this.implicit=t,this.mainExtracted=n}clone(){return new cp(N(this.explicit),N(this.implicit),this.mainExtracted)}hasAxisPart(e){return"axis"===e||("grid"===e||"title"===e?!!this.get(e):!(!1===(t=this.get(e))||null===t));var t}}const lp={bottom:"top",top:"bottom",left:"right",right:"left"};function dp(e,t){if(!e)return t.map(e=>e.clone());{if(e.length!==t.length)return;const n=e.length;for(let i=0;i<n;i++){const n=e[i],r=t[i];if(!!n!=!!r)return;if(n&&r){const t=n.getWithExplicit("orient"),o=r.getWithExplicit("orient");if(t.explicit&&o.explicit&&t.value!==o.value)return;e[i]=fp(n,r)}}}return e}function fp(e,t){for(const n of up){const i=zl(e.getWithExplicit(n),t.getWithExplicit(n),n,"axis",(e,t)=>{switch(n){case"title":return xi(e,t);case"gridScale":return{explicit:e.explicit,value:oe(e.value,t.value)}}return _l(e,t,n,"axis")});e.setWithExplicit(n,i)}return e}function pp(e,t){const n="x"===t?"x2":"y2",i=e.fieldDef(t),r=e.fieldDef(n),o=i?i.title:void 0,s=r?r.title:void 0;return o&&s?yi(o,s):o||(s||(void 0!==o?o:void 0!==s?s:void 0))}function gp(e,t){var n;const i=t.axis(e),r=new cp;up.forEach(n=>{const o=function(e,t,n,i){const r=i.fieldDef(n),o=function(e,t,n,i){if(void 0!==t.labelAngle)return ae(t.labelAngle);{const t=nl("labelAngle",e.config,n,ol(n),e.getScaleComponent(n).get("type"));return void 0!==t?ae(t):n===Ie&&U([Nn,$n],i.type)?270:void 0}}(i,t,n,r),s=oe(t.orient,ol(n)),{mark:a,config:u}=i;switch(e){case"scale":return i.scaleName(n);case"gridScale":return function(e,t){const n="x"===t?"y":"x";if(e.getScaleComponent(n))return e.scaleName(n)}(i,n);case"format":if(rr(r))return;return fi(r,t.format,u);case"formatType":if(rr(r))return;return t.formatType;case"grid":if(lr(i.fieldDef(n).bin))return!1;{const e=i.getScaleComponent(n).get("type");return oe(t.grid,function(e,t){return!Gn(e)&&!cr(t.bin)}(e,r))}case"labelAlign":return oe(t.labelAlign,rl(o,s));case"labelAngle":return o;case"labelBaseline":return oe(t.labelBaseline,il(o,s));case"labelFlush":return oe(t.labelFlush,function(e,t){if("x"===t&&U(["quantitative","temporal"],e.type))return!0}(r,n));case"labelOverlap":{const e=i.getScaleComponent(n).get("type");return oe(t.labelOverlap,function(e,t){if("nominal"!==e.type)return"log"!==t||"greedy"}(r,e))}case"orient":return s;case"tickCount":{const e=i.getScaleComponent(n).get("type"),o="x"===n?"width":"y"===n?"height":void 0,s=o?i.getSizeSignalRef(o):void 0;return oe(t.tickCount,function({fieldDef:e,scaleType:t,size:n}){if(!Gn(t)&&"log"!==t&&!U(["month","hours","day","quarter"],e.timeUnit))return cr(e.bin)?{signal:`ceil(${n.signal}/10)`}:{signal:`ceil(${n.signal}/40)`}}({fieldDef:r,scaleType:e,size:s}))}case"title":{const e="x"===n?"x2":"y2",o=i.fieldDef(e);return oe(t.title,pp(i,n),vi([Si(r)],o?[Si(o)]:[]))}case"values":return function(e,t,n){const i=e.values;if(i)return sr(n,i)}(t,0,r);case"zindex":return oe(t.zindex,function(e,t){return"rect"===e&&qi(t)?1:0}(a,r))}return c=e,ys[c]?t[e]:void 0;var c}(n,i,e,t);if(void 0!==o){const s=function(e,t,n,i,r){switch(t){case"titleAngle":case"labelAngle":return e===ae(n[t]);case"values":return!!n.values;case"encode":return!!n.encoding||!!n.labelAngle;case"title":if(e===pp(i,r))return!0}return e===n[t]}(o,n,i,t,e),a=nl(n,t.config,e,r.get("orient"),t.getScaleComponent(e).get("type"));s||void 0===a?r.set(n,o,s):U(["grid","orient"],n)&&a&&r.set(n,a,!1)}});const o=null!=(n=i.encoding)?n:{},s=ms.reduce((n,i)=>{var s;if(!r.hasAxisPart(i))return n;const a=Dl(null!=(s=o[i])?s:{},t),u="labels"===i?function(e,t,n){var i;const r=null!=(i=e.fieldDef(t))?i:"x"===t?e.fieldDef("x2"):"y"===t?e.fieldDef("y2"):void 0,o=e.axis(t);let s={};if(rr(r)){const n=e.getScaleComponent(t).get("type")===zn.UTC,i=mi("datum.value",r.timeUnit,o.format,null,n);i&&(s.text={signal:i})}return s=Object.assign(Object.assign({},s),n),0===Y(s).length?void 0:s}(t,e,a):a;return void 0!==u&&Y(u).length>0&&(n[i]={update:u}),n},{});return Y(s).length>0&&r.set("encode",s,!!i.encoding||void 0!==i.labelAngle),r}function hp(e,t,n,{graticule:i}){var r,o;const s=Fe(e)?Object.assign({},e):{type:e},a=null!=(r=s.orient)?r:ci("orient",s,n);return s.orient=function(e,t,n){switch(e){case fe:case ve:case ye:case he:case pe:case le:return}const{x:i,y:r,x2:o,y2:s}=t;switch(e){case ce:if(zi(i)&&(lr(i.bin)||zi(r)&&r.aggregate&&!i.aggregate))return"vertical";if(zi(r)&&(lr(r.bin)||zi(i)&&i.aggregate&&!r.aggregate))return"horizontal";if(s||o){if(n)return n;if(!o&&zi(i)&&i.type===kn&&!cr(i.bin))return"horizontal";if(!s&&zi(r)&&r.type===kn&&!cr(r.bin))return"vertical"}case ge:if(o&&s)return;case ue:if(s)return zi(r)&&lr(r.bin)?"horizontal":"vertical";if(o)return zi(i)&&lr(i.bin)?"vertical":"horizontal";if(e===ge){if(i&&!r)return"vertical";if(r&&!i)return"horizontal"}case de:case me:{const t=zi(i)&&Ii(i),o=zi(r)&&Ii(r);if(t&&!o)return"tick"!==e?"horizontal":"vertical";if(!t&&o)return"tick"!==e?"vertical":"horizontal";if(t&&o){const t=i,o=r,s=t.type===Bn,a=o.type===Bn;return s&&!a?"tick"!==e?"vertical":"horizontal":!s&&a?"tick"!==e?"horizontal":"vertical":!t.aggregate&&o.aggregate?"tick"!==e?"vertical":"horizontal":t.aggregate&&!o.aggregate?"tick"!==e?"horizontal":"vertical":n||"vertical"}return n||void 0}}return"vertical"}(s.type,t,a),void 0!==a&&a!==s.orient&&Qt(Ht.orientOverridden(s.orient,a)),void 0===oe(s.opacity,ci("opacity",s,n))&&(s.opacity=function(e,t){if(U([fe,me,ve,ye],e)&&!hr(t))return.7;return}(s.type,t)),void 0===s.filled&&(s.filled=!i&&function(e,t){const n=ci("filled",e,t),i=e.type;return oe(n,i!==fe&&i!==de&&i!==ge)}(s,n)),void 0===(null!=(o=s.cursor)?o:ci("cursor",s,n))&&(s.cursor=function(e,t,n){if(t.href||e.href||ci("href",e,n))return"pointer";return e.cursor}(s,t,n)),s}function mp(e,t){const{config:n}=e;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},da(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore"})),Ks("x",e,{defaultPos:"mid"})),Ks("y",e,{defaultPos:"mid"})),Gs("size",e)),function(e,t,n){if(n)return{shape:{value:n}};return Gs("shape",e)}(e,0,t))}function bp(e){const{config:t,markDef:n}=e,{orient:i}=n,r="horizontal"===i?"width":"height",o=e.getScaleComponent("horizontal"===i?"x":"y"),s=oe(n[r],n.size,ci("size",n,t,{vgChannel:r}),t.tick.bandSize);if(void 0!==s)return s;{const e=o?o.get("range"):void 0;return e&&ds(e)&&F(e.step)?3*e.step/4:3*so(t.view,r)/4}}const vp={area:{vgMark:"area",encodeEntry:e=>Object.assign(Object.assign(Object.assign(Object.assign({},da(e,{align:"ignore",baseline:"ignore",color:"include",orient:"include",size:"ignore"})),ra("x",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:"horizontal"===e.markDef.orient})),ra("y",e,{defaultPos:"zeroOrMin",defaultPos2:"zeroOrMin",range:"vertical"===e.markDef.orient})),pa(e))},bar:{vgMark:"rect",encodeEntry:e=>Object.assign(Object.assign(Object.assign({},da(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore"})),aa(e,"x","bar")),aa(e,"y","bar"))},circle:{vgMark:"symbol",encodeEntry:e=>mp(e,"circle")},geoshape:{vgMark:"shape",encodeEntry:e=>Object.assign({},da(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore"})),postEncodingTransform:e=>{const{encoding:t}=e,n=t.shape;return[Object.assign({type:"geoshape",projection:e.projectionName()},n&&zi(n)&&n.type===_n?{field:Wi(n,{expr:"datum"})}:{})]}},image:{vgMark:"image",encodeEntry:e=>Object.assign(Object.assign(Object.assign(Object.assign({},da(e,{align:"ignore",baseline:"ignore",color:"ignore",orient:"ignore",size:"ignore"})),aa(e,"x","image")),aa(e,"y","image")),Vs(e,"url"))},line:{vgMark:"line",encodeEntry:e=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},da(e,{align:"ignore",baseline:"ignore",color:"include",size:"ignore",orient:"ignore"})),Ks("x",e,{defaultPos:"mid"})),Ks("y",e,{defaultPos:"mid"})),Gs("size",e,{vgChannel:"strokeWidth"})),pa(e))},point:{vgMark:"symbol",encodeEntry:e=>mp(e)},rect:{vgMark:"rect",encodeEntry:e=>Object.assign(Object.assign(Object.assign({},da(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore"})),aa(e,"x","rect")),aa(e,"y","rect"))},rule:{vgMark:"rule",encodeEntry:e=>{const{markDef:t}=e,n=t.orient;return e.encoding.x||e.encoding.y||e.encoding.latitude||e.encoding.longitude?Object.assign(Object.assign(Object.assign(Object.assign({},da(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore"})),ra("x",e,{defaultPos:"horizontal"===n?"zeroOrMin":"mid",defaultPos2:"zeroOrMax",range:"vertical"!==n})),ra("y",e,{defaultPos:"vertical"===n?"zeroOrMin":"mid",defaultPos2:"zeroOrMax",range:"horizontal"!==n})),Gs("size",e,{vgChannel:"strokeWidth"})):{}}},square:{vgMark:"symbol",encodeEntry:e=>mp(e,"square")},text:{vgMark:"text",encodeEntry:e=>{const{config:t,encoding:n}=e;return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},da(e,{align:"include",baseline:"include",color:"include",size:"ignore",orient:"ignore"})),Ks("x",e,{defaultPos:"mid"})),Ks("y",e,{defaultPos:"mid"})),Vs(e)),Gs("size",e,{vgChannel:"fontSize"})),ga("align",function(e,t,n){var i;if(void 0===(null!==(i=e.align)&&void 0!==i?i:ci("align",e,n)))return"center";return}(e.markDef,0,t))),ga("baseline",function(e,t,n){var i;if(void 0===(null!==(i=e.baseline)&&void 0!==i?i:ci("baseline",e,n)))return"middle";return}(e.markDef,0,t)))}},tick:{vgMark:"rect",encodeEntry:e=>{const{config:t,markDef:n}=e,i=n.orient,r="horizontal"===i?"width":"height",o="horizontal"===i?"height":"width";return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},da(e,{align:"ignore",baseline:"ignore",color:"include",orient:"ignore",size:"ignore"})),Ks("x",e,{defaultPos:"mid",vgChannel:"xc"})),Ks("y",e,{defaultPos:"mid",vgChannel:"yc"})),Gs("size",e,{defaultValue:bp(e),vgChannel:r})),{[o]:{value:oe(n.thickness,t.tick.thickness)}})}},trail:{vgMark:"trail",encodeEntry:e=>Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},da(e,{align:"ignore",baseline:"ignore",color:"include",size:"include",orient:"ignore"})),Ks("x",e,{defaultPos:"mid"})),Ks("y",e,{defaultPos:"mid"})),Gs("size",e)),pa(e))}};function yp(e){return U([de,ue,be],e.mark)?function(e){const t=Ar(e.mark,e.encoding),n=Op(e,{fromPrefix:t.length>0?xp:""});return t.length>0?[{name:e.getName("pathgroup"),type:"group",from:{facet:{name:xp+e.requestDataName(Io),data:e.requestDataName(Io),groupby:t}},encode:{update:{width:{field:{group:"width"}},height:{field:{group:"height"}}}},marks:n}]:n}(e):U([ce],e.mark)?function(e){var t;const n=gs.some(t=>e.markDef[t]||ci(t,e.markDef,e.config));if(e.stack&&!e.fieldDef("size")&&n){const[n]=Op(e,{fromPrefix:Ap}),i=e.scaleName(e.stack.fieldChannel),r=(t={})=>e.vgField(e.stack.fieldChannel,t),o=(e,t)=>{return`${e}(${[r({prefix:"min",suffix:"start",expr:t}),r({prefix:"max",suffix:"start",expr:t}),r({prefix:"min",suffix:"end",expr:t}),r({prefix:"max",suffix:"end",expr:t})].map(e=>`scale('${i}',${e})`).join(",")})`};let s,a;"x"===e.stack.fieldChannel?(s=Object.assign(Object.assign({},_(n.encode.update,["y","yc","y2","height",...gs])),{x:{signal:o("min","datum")},x2:{signal:o("max","datum")},clip:{value:!0}}),a={x:{field:{group:"x"},mult:-1},height:{field:{group:"height"}}},n.encode.update=Object.assign(Object.assign({},z(n.encode.update,["y","yc","y2"])),{height:{field:{group:"height"}}})):(s=Object.assign(Object.assign({},_(n.encode.update,["x","xc","x2","width"])),{y:{signal:o("min","datum")},y2:{signal:o("max","datum")},clip:{value:!0}}),a={y:{field:{group:"y"},mult:-1},width:{field:{group:"width"}}},n.encode.update=Object.assign(Object.assign({},z(n.encode.update,["x","xc","x2"])),{width:{field:{group:"width"}}}));for(const t of gs){const i=ci(t,e.markDef,e.config);n.encode.update[t]?(s[t]=n.encode.update[t],delete n.encode.update[t]):i&&(s[t]={value:i}),i&&(n.encode.update[t]={value:0})}const u=e.vgField(e.stack.groupbyChannel)?[e.vgField(e.stack.groupbyChannel)]:[];return(null===(t=e.fieldDef(e.stack.groupbyChannel))||void 0===t?void 0:t.bin)&&u.push(e.vgField(e.stack.groupbyChannel,{binSuffix:"end"})),s=["stroke","strokeWidth","strokeJoin","strokeCap","strokeDash","strokeDashOffset","strokeMiterLimit","strokeOpacity"].reduce((t,i)=>{if(n.encode.update[i])return Object.assign(Object.assign({},t),{[i]:n.encode.update[i]});{const n=ci(i,e.markDef,e.config);return void 0!==n?Object.assign(Object.assign({},t),{[i]:{value:n}}):t}},s),s.stroke&&(s.strokeForeground={value:!0},s.strokeOffset={value:0}),[{type:"group",from:{facet:{data:e.requestDataName(Io),name:Ap+e.requestDataName(Io),groupby:u,aggregate:{fields:[r({suffix:"start"}),r({suffix:"start"}),r({suffix:"end"}),r({suffix:"end"})],ops:["min","max","min","max"]}}},encode:{update:s},marks:[{type:"group",encode:{update:a},marks:[n]}]}]}return Op(e)}(e):Op(e)}const xp="faceted_path_";const Ap="stack_group_";function Op(e,t={fromPrefix:""}){const n=e.mark,i=oe(e.markDef.clip,function(e){const t=e.getScaleComponent("x"),n=e.getScaleComponent("y");return!!(t&&t.get("selectionExtent")||n&&n.get("selectionExtent"))||void 0}(e),function(e){const t=e.component.projection;return!(!t||t.isFit)||void 0}(e)),r=ai(e.markDef),s=e.encoding.key,a=function(e){const{encoding:t,stack:n,mark:i,markDef:r,config:s}=e,a=t.order;if(!(!o(a)&&Mi(a)&&M(a.value)||!a&&M(r.order)||M(ci("order",r,s)))){if((o(a)||zi(a))&&!n)return bi(a,{expr:"datum"});if(Ae(i)){const n="horizontal"===r.orient?"y":"x",i=t[n];if(zi(i)){const t=i.sort;if(o(t))return{field:Wi(i,{prefix:n,suffix:"sort_index",expr:"datum"})};if(Ci(t))return{field:Wi({aggregate:hr(e.encoding)?t.op:void 0,field:t.field},{expr:"datum"})};if(Fi(t)){return{field:Wi(e.fieldDef(t.encoding),{expr:"datum"}),order:t.order}}return{field:Wi(i,{binSuffix:e.stack&&e.stack.impute?"mid":void 0,expr:"datum"})}}}else;}}(e),u=function(e){if(!e.component.selection)return null;const t=Y(e.component.selection).length;let n=t,i=e.parent;for(;i&&0===n;)n=Y(i.component.selection).length,i=i.parent;return n?{interactive:t>0}:null}(e),c=vp[n].postEncodingTransform?vp[n].postEncodingTransform(e):null;return[Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({name:e.getName("marks"),type:vp[n].vgMark},i?{clip:!0}:{}),r?{style:r}:{}),s?{key:s.field}:{}),a?{sort:a}:{}),u||{}),{from:{data:t.fromPrefix+e.requestDataName(Io)},encode:{update:vp[n].encodeEntry(e)}}),c?{transform:c}:{})]}class wp extends Ff{constructor(e,t,n,i={},r,o){var s;super(e,"unit",t,n,o,r,void 0,e.view),this.specifiedScales={},this.specifiedAxes={},this.specifiedLegends={},this.specifiedProjection={},this.selection={},this.children=[];const a=Fe(e.mark)?e.mark.type:e.mark,u=function(e,t){return Kf(e,t)}(null!=(s=e.encoding)?s:{},r);this.markDef=hp(e.mark,u,o,{graticule:e.data&&qo(e.data)});const c=this.encoding=br(u,this.markDef);this.size=function({encoding:e,size:t}){for(const n of Nt){const i=_t(n),r=Zi(e[n]);io(t[i])&&r&&Ii(r)&&(delete t[i],Qt(Ht.stepDropped(i)))}return t}({encoding:c,size:Object.assign(Object.assign(Object.assign({},i),e.width?{width:e.width}:{}),e.height?{height:e.height}:{})}),this.stack=Oo(a,c),this.specifiedScales=this.initScales(a,c),this.specifiedAxes=this.initAxes(c),this.specifiedLegends=this.initLegend(c),this.specifiedProjection=e.projection,this.selection=e.selection}get hasProjection(){const{encoding:e}=this,t=this.mark===xe,n=e&&ht.some(t=>zi(e[t]));return t||n}scaleDomain(e){const t=this.specifiedScales[e];return t?t.domain:void 0}axis(e){return this.specifiedAxes[e]}legend(e){return this.specifiedLegends[e]}initScales(e,t){return Ut.reduce((e,n)=>{let i,r;const o=t[n];return zi(o)?(i=o,r=o.scale):_i(o)&&(i=o.condition,r=o.condition.scale),i&&(e[n]=null!=r?r:{}),e},{})}initAxes(e){return[Ie,He].reduce((t,n)=>{const i=e[n];if(zi(i)||n===Ie&&zi(e.x2)||n===He&&zi(e.y2)){const e=zi(i)?i.axis:null;null!==e&&(t[n]=Object.assign({},e))}return t},{})}initLegend(e){return Pt.reduce((t,n)=>{const i=e[n];if(i){const e=zi(i)?i.legend:_i(i)?i.condition.legend:null;null!==e&&!1!==e&&function(e){switch(e){case Ze:case Ke:case et:case nt:case tt:case it:case st:return!0;case rt:case ot:return!1}}(n)&&(t[n]=Object.assign({},e))}return t},{})}parseData(){this.component.data=rp(this)}parseLayoutSize(){!function(e){const{size:t,component:n}=e;for(const i of Nt){const r=_t(i);if(t[r]){const e=t[r];n.layoutSize.set(r,io(e)?"step":e,!0)}else{const t=Jf(e,r);n.layoutSize.set(r,t,!1)}}}(this)}parseSelections(){this.component.selection=function(e,t){var n;const i={},r=e.config.selection;for(const o in t){if(!O(t,o))continue;const s=N(t[o]),u=$e(r[s.type],["fields","encodings"]);for(const e in u)"encodings"===e&&s.fields||"fields"===e&&s.encodings||("mark"===e&&(s[e]=Object.assign(Object.assign({},u[e]),s[e])),void 0!==s[e]&&!0!==s[e]||(s[e]=null!=(n=u[e])?n:s[e]));const c=Q(o),l=i[c]=Object.assign(Object.assign({},s),{name:c,events:a(s.on)?xs(s.on,"scope"):N(s.on)});Pa(l,n=>{n.has(l)&&n.parse&&n.parse(e,l,s,t[o])})}return i}(this,this.selection)}parseMarkGroup(){this.component.mark=yp(this)}parseAxesAndHeaders(){var e;this.component.axes=(e=this,Nt.reduce((t,n)=>(e.component.scales[n]&&e.axis(n)&&(t[n]=[gp(n,e)]),t),{}))}assembleSelectionTopLevelSignals(e){return function(e,t){let n=!1;if(Ka(e,(i,r)=>{const o=i.name,s=u(o+Va);if(0===t.filter(e=>e.name===o).length){const e="global"===i.resolve?"union":i.resolve,n="multi"===i.type?", true)":")";t.push({name:i.name,update:`${Xa}(${s}, ${u(e)}${n}`})}n=!0,r.topLevelSignals&&(t=r.topLevelSignals(e,i,t)),Pa(i,n=>{n.topLevelSignals&&(t=n.topLevelSignals(e,i,t))})}),n){0===t.filter(e=>"unit"===e.name).length&&t.unshift({name:"unit",value:{},on:[{events:"mousemove",update:"isTuple(group()) ? group() : unit"}]})}return Ra(t)}(this,e)}assembleSignals(){return[...Xc(this),...(e=this,t=[],Ka(e,(n,i)=>{const r=n.name;let o=i.modifyExpr(e,n);t.push(...i.signals(e,n)),Pa(n,i=>{i.signals&&(t=i.signals(e,n,t)),i.modifyExpr&&(o=i.modifyExpr(e,n,o))}),t.push({name:r+Qa,on:[{events:{signal:n.name+Ja},update:`modify(${u(n.name+Va)}, ${o})`}]})}),Ra(t))];var e,t}assembleSelectionData(e){return function(e,t){const n=[...t];return Ka(e,t=>{const i={name:t.name+Va};if(t.init){const n=t.project.items.map(e=>{return $e(e,["signals"])}),r=t.init.map(e=>Ma(e,!1));i.values="interval"===t.type?[{unit:eu(e,{escape:!1}),fields:n,values:r}]:r.map(t=>({unit:eu(e,{escape:!1}),fields:n,values:t}))}n.filter(e=>e.name===t.name+Va).length||n.push(i)}),n}(this,e)}assembleLayout(){return null}assembleLayoutSignals(){return wl(this)}assembleMarks(){var e;let t=null!=(e=this.component.mark)?e:[];return this.parent&&Of(this.parent)||(t=Ua(this,t)),t.map(this.correctDataNames)}getMapping(){return this.encoding}get mark(){return this.markDef.type}channelHasField(e){return gr(this.encoding,e)}fieldDef(e){return Ki(this.encoding[e])}}class Fp extends wf{constructor(e,t,n,i,r,o){super(e,"layer",t,n,o,r,e.resolve,e.view);const s=Object.assign(Object.assign(Object.assign({},i),e.width?{width:e.width}:{}),e.height?{height:e.height}:{});this.children=e.layer.map((e,t)=>{if(bo(e))return new Fp(e,this,this.getName("layer_"+t),s,r,o);if(Se(e))return new wp(e,this,this.getName("layer_"+t),s,r,o);throw new Error(Ht.invalidSpec(e))})}parseData(){this.component.data=rp(this);for(const e of this.children)e.parseData()}parseLayoutSize(){If(this)}parseSelections(){this.component.selection={};for(const e of this.children)e.parseSelections(),Y(e.component.selection).forEach(t=>{this.component.selection[t]=e.component.selection[t]})}parseMarkGroup(){for(const e of this.children)e.parseMarkGroup()}parseAxesAndHeaders(){!function(e){var t;const{axes:n,resolve:i}=e.component,r={top:0,bottom:0,right:0,left:0};for(const t of e.children){t.parseAxesAndHeaders();for(const r of Y(t.component.axes))i.axis[r]=Sl(e.component.resolve,r),"shared"===i.axis[r]&&(n[r]=dp(n[r],t.component.axes[r]),n[r]||(i.axis[r]="independent",delete n[r]))}for(const o of[Ie,He]){for(const s of e.children)if(s.component.axes[o]){if("independent"===i.axis[o]){n[o]=(t=n[o],null!=t?t:[]).concat(s.component.axes[o]);for(const e of s.component.axes[o]){const{value:t,explicit:n}=e.getWithExplicit("orient");if(r[t]>0&&!n){const n=lp[t];r[t]>r[n]&&e.set("orient",n,!1)}r[t]++}}delete s.component.axes[o]}if("independent"===i.axis[o]&&n[o]&&n[o].length>1)for(const e of n[o])e.get("grid")&&!e.explicit.grid&&(e.implicit.grid=!1)}}(this)}assembleSelectionTopLevelSignals(e){return this.children.reduce((e,t)=>t.assembleSelectionTopLevelSignals(e),e)}assembleSignals(){return this.children.reduce((e,t)=>e.concat(t.assembleSignals()),Xc(this))}assembleLayoutSignals(){return this.children.reduce((e,t)=>e.concat(t.assembleLayoutSignals()),wl(this))}assembleSelectionData(e){return this.children.reduce((e,t)=>t.assembleSelectionData(e),e)}assembleTitle(){let e=super.assembleTitle();if(e)return e;for(const t of this.children)if(e=t.assembleTitle(),e)return e}assembleLayout(){return null}assembleMarks(){return function(e,t){for(const n of e.children)vf(n)&&(t=Ua(n,t));return t}(this,this.children.flatMap(e=>e.assembleMarks()))}assembleLegends(){return this.children.reduce((e,t)=>e.concat(t.assembleLegends()),ed(this))}}class Cp extends op{constructor(e,t,n,i,r){super(e,"repeat",t,n,r,i,e.resolve),e.resolve&&e.resolve.axis&&("shared"===e.resolve.axis.x||"shared"===e.resolve.axis.y)&&Qt(Ht.REPEAT_CANNOT_SHARE_AXIS),this.repeat=e.repeat,this.children=this._initChildren(e,this.repeat,i,r)}_initChildren(e,t,n,i){const r=[],s=!o(t)&&t.row||[n?n.row:null],a=!o(t)&&t.column||[n?n.column:null],u=o(t)&&t||[n?n.repeat:null];for(const t of u)for(const n of s)for(const o of a){const s=(t?`__repeat_repeat_${t}`:"")+(n?`__repeat_row_${n}`:"")+(o?`__repeat_column_${o}`:""),a={repeat:t,row:n,column:o};r.push(jp(e.spec,this,this.getName("child"+s),void 0,a,i))}return r}parseLayoutSize(){Hf(this)}assembleDefaultLayout(){const{repeat:e}=this,t=o(e)?void 0:e.column?e.column.length:1;return Object.assign(Object.assign({},t?{columns:t}:{}),{bounds:"full",align:"all"})}}function jp(e,t,n,i,r,o){if(Ei(e))return new tp(e,t,n,r,o);if(bo(e))return new Fp(e,t,n,i,r,o);if(Se(e))return new wp(e,t,n,i,r,o);if(no(e))return new Cp(e,t,n,r,o);if(function(e){return eo(e)||to(e)||Kr(e)}(e))return new sp(e,t,n,r,o);throw new Error(Ht.invalidSpec(e))}const Dp=new class extends vo{mapUnit(e,{config:t}){if(e.encoding){const{encoding:n,transform:i}=e,{bins:r,timeUnits:o,aggregate:s,groupby:a,encoding:u}=mr(n,t),c=[...i||[],...r,...o,...0===s.length?[]:[{aggregate:s,groupby:a}]];return Object.assign(Object.assign(Object.assign({},e),c.length>0?{transform:c}:{}),{encoding:u})}return e}};const Ep=t;e.compile=function(e,t={}){var n;t.logger&&(n=t.logger,Jt=n),t.fieldTitle&&Yi(t.fieldTitle);try{const n=lo(b({},t.config,e.config)),i=Bo(e,n),r=jp(i,null,"",void 0,void 0,n);return r.parse(),function(e,t){dd(e.sources);let n=0,i=0;for(let i=0;i<Wd&&Gd(e,t);i++)n++;e.sources.map(_d);for(let n=0;n<Wd&&Gd(e,t);n++)i++;dd(e.sources),Math.max(n,i)===Wd&&Qt(`Maximum optimization runs(${Wd}) reached.`)}(r.component.data,r),{spec:function(e,t,n={},i){const r=e.config?ho(e.config):void 0,o=[].concat(e.assembleSelectionData([]),function(e,t){var n,i;const r=[],o=Uf(r);let s=0;e.sources.forEach(e=>{e.hasName()||(e.dataName=`source_${s++}`);const t=e.assemble();o(e,t)}),r.forEach(e=>{0===e.transform.length&&delete e.transform});let a=0;for(const[e,t]of r.entries())0!==(n=t.transform,null!=n?n:[]).length||t.source||r.splice(a++,0,r.splice(e,1)[0]);for(const t of r)for(const n of null!=(i=t.transform)?i:[])"lookup"===n.type&&(n.from=e.outputNodes[n.from].getSource());for(const e of r)e.name in t&&(e.values=t[e.name]);return r}(e.component.data,n)),s=e.assembleProjections(),a=e.assembleTitle(),u=e.assembleGroupStyle(),c=e.assembleGroupEncodeEntry(!0);let l=e.assembleLayoutSignals();return l=l.filter(e=>"width"!==e.name&&"height"!==e.name||void 0===e.value||(t[e.name]=+e.value,!1)),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({$schema:"https://vega.github.io/schema/vega/v5.json"},e.description?{description:e.description}:{}),t),a?{title:a}:{}),u?{style:u}:{}),c?{encode:{update:c}}:{}),{data:o}),s.length>0?{projections:s}:{}),e.assembleGroup([...l,...e.assembleSelectionTopLevelSignals([])])),r?{config:r}:{}),i?{usermeta:i}:{})}(r,function(e,t,n,i){const r=i.component.layoutSize.get("width"),o=i.component.layoutSize.get("height");void 0===t?t={type:"pad"}:a(t)&&(t={type:t});if(r&&o&&(s=t.type,"fit"===s||"fit-x"===s||"fit-y"===s))if("step"===r&&"step"===o)Qt(Ht.droppingFit()),t.type="pad";else if("step"===r||"step"===o){const e="step"===r?"width":"height";Qt(Ht.droppingFit(zt(e)));const n="width"===e?"height":"width";t.type=function(e){return e?`fit-${zt(e)}`:"fit"}(n)}var s;return Object.assign(Object.assign(Object.assign({},1===Y(t).length&&t.type?"pad"===t.type?{}:{autosize:t.type}:{autosize:t}),To(n)),To(e))}(e,i.autosize,n,r),e.datasets,e.usermeta),normalized:i}}finally{t.logger&&(Jt=Gt),t.fieldTitle&&Yi(Hi)}},e.extractTransforms=function(e,t){return Dp.map(e,{config:t})},e.normalize=Bo,e.version=Ep,Object.defineProperty(e,"__esModule",{value:!0})}));