import{b0 as e,g as t,cQ as n,K as r,ec as i,ed as o,ee as a,ef as s,ar as c,d6 as l,dq as u,dX as d,D as f,H as p,eg as h,eh as g,ei as m,ej as y,ek as v,el as b,em as x,bq as E,en as T,eo as S,cU as N,G as w,a7 as C,W as A,ep as O,d0 as k,eq as M,aj as I,a6 as U,er as F,at as D,as as _,R as j,ai as P,aq as R}from"./index-FKnJJang.js";import{i as $,c as B,N as L,a as W}from"./VegaLite-sOKbiepp.js";import"./time-BB5za7E_.js";import"./timer-CK-RIWfW.js";import"./linear-spCykGIY.js";import"./init-DLRA0X12.js";import"./range-CtcPcB_L.js";import"./zoom-COrs4lFh.js";import"./ordinal-DDUp3AbE.js";import"./colors-bszWmPJw.js";import"./arc-lt4NHaVr.js";import"./step-CNn2V7Th.js";import"./index-D4qOZ_cs.js";
/**
 * @license lucide-react v0.428.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const q=e("ChartColumnBig",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["rect",{x:"15",y:"5",width:"4",height:"12",rx:"1",key:"q8uenq"}],["rect",{x:"7",y:"8",width:"4",height:"9",rx:"1",key:"sr5ea"}]]),H=e("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]),G=e("ListOrdered",[["line",{x1:"10",x2:"21",y1:"6",y2:"6",key:"76qw6h"}],["line",{x1:"10",x2:"21",y1:"12",y2:"12",key:"16nom4"}],["line",{x1:"10",x2:"21",y1:"18",y2:"18",key:"u3jurt"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);
/**
 * @license lucide-react v0.428.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */
/*! *****************************************************************************
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 z(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}var Y,Q;Y={exports:{}},Q=function(){function e(e,t){return null!=t&&e instanceof t}var t,n,r;try{t=Map}catch(s){t=function(){}}try{n=Set}catch(s){n=function(){}}try{r=Promise}catch(s){r=function(){}}function i(o,s,c,l,u){"object"==typeof s&&(c=s.depth,l=s.prototype,u=s.includeNonEnumerable,s=s.circular);var d=[],f=[],p="undefined"!=typeof Buffer;return void 0===s&&(s=!0),void 0===c&&(c=1/0),function o(c,h){if(null===c)return null;if(0===h)return c;var g,m;if("object"!=typeof c)return c;if(e(c,t))g=new t;else if(e(c,n))g=new n;else if(e(c,r))g=new r((function(e,t){c.then((function(t){e(o(t,h-1))}),(function(e){t(o(e,h-1))}))}));else if(i.__isArray(c))g=[];else if(i.__isRegExp(c))g=new RegExp(c.source,a(c)),c.lastIndex&&(g.lastIndex=c.lastIndex);else if(i.__isDate(c))g=new Date(c.getTime());else{if(p&&Buffer.isBuffer(c))return g=Buffer.allocUnsafe?Buffer.allocUnsafe(c.length):new Buffer(c.length),c.copy(g),g;e(c,Error)?g=Object.create(c):void 0===l?(m=Object.getPrototypeOf(c),g=Object.create(m)):(g=Object.create(l),m=l)}if(s){var y=d.indexOf(c);if(-1!=y)return f[y];d.push(c),f.push(g)}for(var v in e(c,t)&&c.forEach((function(e,t){var n=o(t,h-1),r=o(e,h-1);g.set(n,r)})),e(c,n)&&c.forEach((function(e){var t=o(e,h-1);g.add(t)})),c){var b;m&&(b=Object.getOwnPropertyDescriptor(m,v)),b&&null==b.set||(g[v]=o(c[v],h-1))}if(Object.getOwnPropertySymbols){var x=Object.getOwnPropertySymbols(c);for(v=0;v<x.length;v++){var E=x[v];(!(S=Object.getOwnPropertyDescriptor(c,E))||S.enumerable||u)&&(g[E]=o(c[E],h-1),S.enumerable||Object.defineProperty(g,E,{enumerable:!1}))}}if(u){var T=Object.getOwnPropertyNames(c);for(v=0;v<T.length;v++){var S,N=T[v];(S=Object.getOwnPropertyDescriptor(c,N))&&S.enumerable||(g[N]=o(c[N],h-1),Object.defineProperty(g,N,{enumerable:!1}))}}return g}(o,c)}function o(e){return Object.prototype.toString.call(e)}function a(e){var t="";return e.global&&(t+="g"),e.ignoreCase&&(t+="i"),e.multiline&&(t+="m"),t}return i.clonePrototype=function(e){if(null===e)return null;var t=function(){};return t.prototype=e,new t},i.__objToStr=o,i.__isDate=function(e){return"object"==typeof e&&"[object Date]"===o(e)},i.__isArray=function(e){return"object"==typeof e&&"[object Array]"===o(e)},i.__isRegExp=function(e){return"object"==typeof e&&"[object RegExp]"===o(e)},i.__getRegExpFlags=a,i}(),Y.exports&&(Y.exports=Q);var V=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var n="boolean"==typeof t.cycles&&t.cycles,r=t.cmp&&function(e){return function(t){return function(n,r){var i={key:n,value:t[n]},o={key:r,value:t[r]};return e(i,o)}}}(t.cmp),i=[];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 o,a;if(Array.isArray(t)){for(a="[",o=0;o<t.length;o++)o&&(a+=","),a+=e(t[o])||"null";return a+"]"}if(null===t)return"null";if(-1!==i.indexOf(t)){if(n)return JSON.stringify("__cycle__");throw new TypeError("Converting circular structure to JSON")}var s=i.push(t)-1,c=Object.keys(t).sort(r&&r(t));for(a="",o=0;o<c.length;o++){var l=c[o],u=e(t[l]);u&&(a&&(a+=","),a+=JSON.stringify(l)+":"+u)}return i.splice(s,1),"{"+a+"}"}}(e)};const K=t(V);function J(e,t,n){return e.fields=t||[],e.fname=n,e}function X(e){throw Error(e)}function Z(e){var t,n,r,i=[],o=null,a=0,s=e.length,c="";function l(){i.push(c+e.substring(t,n)),c="",t=n+1}for(e+="",t=n=0;n<s;++n)if("\\"===(r=e[n]))c+=e.substring(t,n),t=++n;else if(r===o)l(),o=null,a=-1;else{if(o)continue;t===a&&'"'===r||t===a&&"'"===r?(t=n+1,o=r):"."!==r||a?"["===r?(n>t&&l(),a=t=n+1):"]"===r&&(a||X("Access path missing open bracket: "+e),a>0&&l(),a=0,t=n+1):n>t?l():t=n+1}return a&&X("Access path missing closing bracket: "+e),o&&X("Access path missing closing quote: "+e),n>t&&(n++,l()),i}const ee=Array.isArray;function te(e){return e===Object(e)}function ne(e){return"string"==typeof e}function re(e){return ee(e)?"["+e.map(re)+"]":te(e)||ne(e)?JSON.stringify(e).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):e}var ie,oe,ae,se=[];function ce(e,t,n){var r=[t].concat([].slice.call(n));console[e](...r)}oe=Z(ie="id"),ae="return _["+oe.map(re).join("][")+"];",J(Function("_",ae),[ie=1===oe.length?oe[0]:ie],ie),J((function(e){return e}),se,"identity"),J((function(){return 0}),se,"zero"),J((function(){return 1}),se,"one"),J((function(){return!0}),se,"true"),J((function(){return!1}),se,"false");function le(e){return"boolean"==typeof e}function ue(e){for(var t={},n=0,r=e.length;n<r;++n)t[e[n]]=!0;return t}Set.prototype.toJSON=function(){return`Set(${[...this].map((e=>K(e))).join(",")})`};const de=K;function fe(e,t){return e.indexOf(t)>-1}const pe=Object.keys;const he="row",ge="column",me="facet",ye="x",ve="y",be="x2",xe="y2",Ee="latitude",Te="longitude",Se="latitude2",Ne="longitude2",we="color",Ce="fill",Ae="stroke",Oe="shape",ke="size",Me="opacity",Ie="fillOpacity",Ue="strokeOpacity",Fe="strokeWidth",De="text",_e="order",je="detail",Pe="key",Re="tooltip",$e="href",Be=Object.assign({},{x:1,y:1,x2:1,y2:1},{longitude:1,longitude2:1,latitude:1,latitude2:1},{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});function Le(e){return"color"===e||"fill"===e||"stroke"===e}const We=Object.assign({},Be,{row:1,column:1,facet:1}),qe=pe(We);z(We,["order","detail"]),z(We,["order","detail","row","column","facet"]);const He=z(Be,["x","y","x2","y2","latitude","longitude","latitude2","longitude2"]),Ge=pe(He),ze=z(He,["text","tooltip","href","detail","key","order"]),Ye=Object.assign({},{x:1,y:1},ze);function Qe(e,t){return function(e){switch(e){case we:case Ce:case Ae:case je:case Pe:case Re:case $e:case _e:case Me:case Ie:case Ue:case Fe:case me:case he:case ge:return Ve;case ye:case ve:case Ee:case Te:return Ke;case be:case xe:case Se:case Ne:return{rule:"always",bar:"always",rect:"always",area:"always",circle:"binned",point:"binned",square:"binned",tick:"binned",line:"binned",trail:"binned"};case ke:return{point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",text:"always",line:"always",trail:"always"};case Oe:return{point:"always",geoshape:"always"};case De:return{text:"always"}}}(e)[t]}const Ve={area:"always",bar:"always",circle:"always",geoshape:"always",line:"always",rule:"always",point:"always",rect:"always",square:"always",trail:"always",text:"always",tick:"always"},Ke=z(Ve,["geoshape"]);function Je(e){switch(e){case ye:case ve:case ke:case Fe:case Me:case Ie:case Ue:case be:case xe:return;case me:case he:case ge:case Oe:case De:case Re:case $e:return"discrete";case we:case Ce:case Ae:return"flexible";case Ee:case Te:case Se:case Ne:case je:case Pe:case _e:return}throw new Error("rangeType not implemented for "+e)}const Xe={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,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,titleOpacity:1,titlePadding:1,titleX:1,titleY:1,values:1,zindex:1},Ze=Object.assign({},Xe,{encoding:1});Object.assign({gridScale:1,scale:1},Xe,{encode:1});const et=pe(Ze),tt={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,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,titleOpacity:1,titleOrient:1,titlePadding:1,type:1,values:1,zindex:1};Object.assign({},tt,{opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,encode:1});const nt=pe(tt);const rt=Object.freeze(Object.defineProperty({__proto__:null,BAR_WITH_POINT_SCALE_AND_RANGESTEP_NULL:"Bar mark should not be used with point scale when rangeStep is null. Please use band scale instead.",CANNOT_FIX_RANGE_STEP_WITH_FIT:'Cannot use a fixed value of "rangeStep" when "autosize" is "fit".',CANNOT_UNION_CUSTOM_DOMAIN_WITH_FIELD_DOMAIN:"custom domain scale cannot be unioned with default field-based domain",CONCAT_CANNOT_SHARE_AXIS:"Axes cannot be shared in concatenated views yet (https://github.com/vega/vega-lite/issues/2415).",FIT_NON_SINGLE:'Autosize "fit" only works for single views and layered views.',INVALID_CHANNEL_FOR_AXIS:"Invalid channel for axis.",INVALID_SPEC:"Invalid spec",LINE_WITH_VARYING_SIZE:"Line marks cannot encode size with a non-groupby field. You may want to use trail marks instead.",MORE_THAN_ONE_SORT:"Domains that should be unioned has conflicting sort properties. Sort will be set to true.",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.',NO_INIT_SCALE_BINDINGS:"Selections bound to scales cannot be separately initialized.",REPEAT_CANNOT_SHARE_AXIS:"Axes cannot be shared in repeated views yet (https://github.com/vega/vega-lite/issues/2415).",SCALE_BINDINGS_CONTINUOUS:"Scale bindings are currently only supported for scales with unbinned, continuous domains.",UNABLE_TO_MERGE_DOMAINS:"Unable to merge domains",cannotApplySizeToNonOrientedMark:function(e){return`Cannot apply size to non-oriented mark "${e}".`},cannotProjectOnChannelWithoutField:function(e){return`Cannot project a selection on encoding channel "${e}", which has no field.`},cannotStackNonLinearScale:function(e){return`Cannot stack non-linear scale (${e})`},cannotStackRangedMark:function(e){return`Cannot stack "${e}" if there is already "${e}2"`},cannotUseScalePropertyWithNonColor:function(e){return`Cannot use the scale property "${e}" with non-color channel.`},channelRequiredForBinned:function(e){return`Channel ${e} is required for "binned" bin`},columnsNotSupportByRowCol:function(e){return`The "columns" property cannot be used when "${e}" has nested row/column.`},dayReplacedWithDate:function(e){return`Time unit "${e}" is not supported. We are replacing it with ${e.replace("day","date")}.`},differentParse:function(e,t,n){return`An ancestor parsed field "${e}" as ${n} but a child wants to parse the field as ${t}.`},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"}.`},domainRequiredForThresholdScale:function(e){return`Domain for ${e} is required for threshold scale`},domainSortDropped:function(e){return`Dropping sort property ${de(e)} as unioned domains only support boolean or op 'count'.`},droppedDay:function(e){return`Dropping day from datetime ${de(e)} as day cannot be combined with other units.`},droppingColor:function(e,t){const{fill:n,stroke:r}=t;return`Dropping color ${e} as the plot also has `+(n&&r?"fill and stroke":n?"fill":"stroke")},emptyFieldDef:function(e,t){return`Dropping ${de(e)} from channel "${t}" since it does not contain data field or value.`},encodingOverridden:function(e){return`Layer's shared ${e.join(",")} channel ${1===e.length?"is":"are"} overriden`},errorBand1DNotSupport:function(e){return`1D error band does not support ${e}`},errorBarCenterAndExtentAreNotNeeded:function(e,t){return`${t?"extent ":""}${t&&e?"and ":""}${e?"center ":""}${t&&e?"are ":"is "}not needed when data are aggregated.`},errorBarCenterIsNotNeeded:function(e,t){return`Center is not needed to be specified in ${t} when extent is ${e}.`},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.`},facetChannelDropped:function(e){return`Facet encoding dropped as ${e.join(" and ")} ${e.length>1?"are":"is"} also specified.`},facetChannelShouldBeDiscrete:function(e){return`${e} encoding should be discrete (ordinal / nominal / binned).`},incompatibleChannel:function(e,t,n){return`${e} dropped as it is incompatible with "${t}"${n?` when ${n}`:""}.`},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.`},invalidAggregate:function(e){return`Invalid aggregation operator "${e}"`},invalidEncodingChannel:function(e){return`${e}-encoding is dropped as ${e} is not a valid encoding channel.`},invalidFieldType:function(e){return`Invalid field type "${e}"`},invalidFieldTypeForCountAggregate:function(e,t){return`Invalid field type "${e}" for aggregate: "${t}", using "quantitative" instead.`},invalidTimeUnit:function(e,t){return`Invalid ${e}: ${de(t)}`},invalidTransformIgnored:function(e){return`Ignoring an invalid transform: ${de(e)}.`},latLongDeprecated:function(e,t,n){return`${e}-encoding with type ${t} is deprecated. Replacing with ${n}-encoding.`},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.`},mergeConflictingDomainProperty:function(e,t,n,r){return`Conflicting ${t.toString()} property "${e.toString()}" (${de(n)} and ${de(r)}).  Using the union of the two domains.`},mergeConflictingProperty:function(e,t,n,r){return`Conflicting ${t.toString()} property "${e.toString()}" (${de(n)} and ${de(r)}).  Using ${de(n)}.`},missingFieldType:function(e,t){return`Missing type for channel "${e}", using "${t}" instead.`},nearestNotSupportForContinuous:function(e){return`The "nearest" transform is not supported for ${e} marks.`},noSuchRepeatedValue:function(e){return`Unknown repeated value "${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.`},orientOverridden:function(e,t){return`Specified orient "${e}" overridden with "${t}"`},primitiveChannelDef:function(e,t,n){return`Channel ${e} is a ${t}. Converted to {value: ${de(n)}}.`},projectionOverridden:function(e){const{parentProjection:t,projection:n}=e;return`Layer's shared projection ${de(t)} is overridden by a child projection ${de(n)}.`},rangeStepDropped:function(e){return`rangeStep for "${e}" is dropped as top-level ${"x"===e?"width":"height"} is provided.`},scalePropertyNotWorkWithScaleType:function(e,t,n){return`${n}-scale's "${t}" is dropped as it does not work with ${e} scale.`},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.`},scaleTypeNotWorkWithMark:function(e,t){return`Scale type "${t}" does not work with mark "${e}".`},selectionNotFound:function(e){return`Cannot find a selection named "${e}"`},selectionNotSupported:function(e){return`Selection not supported for ${e} yet`},stackNonSummativeAggregate:function(e){return`Stacking is applied even though the aggregate function is non-summative ("${e}")`},unaggregateDomainHasNoEffectForRawField:function(e){return`Using unaggregated domain with raw field has no effect (${de(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 (${de(e)}).`},unrecognizedParse:function(e){return`Unrecognized parse "${e}".`}},Symbol.toStringTag,{value:"Module"})),it=rt;var ot;let at=(ot=2,{level:function(e){return arguments.length?(ot=+e,this):ot},error:function(){return ot>=1&&ce("error","ERROR",arguments),this},warn:function(){return ot>=2&&ce("warn","WARN",arguments),this},info:function(){return ot>=3&&ce("log","INFO",arguments),this},debug:function(){return ot>=4&&ce("log","DEBUG",arguments),this}});function st(...e){at.warn.apply(at,arguments)}const ct={quantitative:1,ordinal:1,temporal:1,nominal:1,geojson:1},lt="quantitative",ut="ordinal",dt="temporal",ft="nominal";var pt,ht;(ht=pt||(pt={})).LINEAR="linear",ht.LOG="log",ht.POW="pow",ht.SQRT="sqrt",ht.SYMLOG="symlog",ht.TIME="time",ht.UTC="utc",ht.QUANTILE="quantile",ht.QUANTIZE="quantize",ht.THRESHOLD="threshold",ht.BIN_ORDINAL="bin-ordinal",ht.ORDINAL="ordinal",ht.POINT="point",ht.BAND="band";const gt=pe({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"}),mt=["linear","log","pow","sqrt","symlog","time","utc"],yt=ue(mt),vt=ue(["quantile","quantize","threshold"]),bt=ue(mt.concat(["quantile","quantize","threshold"])),xt=ue(["ordinal","bin-ordinal","point","band"]);function Et(e){return e in xt}function Tt(e){return e in yt}const St={type:1,domain:1,align:1,range:1,rangeStep: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},Nt=pe(St);function wt(e,t){switch(t){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!fe(["point","band","identity"],e);case"bins":return!fe(["point","band","identity","ordinal"],e);case"round":return Tt(e)||"band"===e||"point"===e;case"padding":return Tt(e)||fe(["point","band"],e);case"paddingOuter":case"rangeStep":case"align":return fe(["point","band"],e);case"paddingInner":return"band"===e;case"clamp":return Tt(e);case"nice":return Tt(e)||"quantize"===e||"threshold"===e;case"exponent":return"pow"===e;case"base":return"log"===e;case"constant":return"symlog"===e;case"zero":return e in bt&&!fe(["log","time","utc","threshold","quantile"],e)}}function Ct(e,t){switch(t){case"interpolate":case"scheme":return Le(e)?void 0:it.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"rangeStep":case"reverse":case"round":case"clamp":case"zero":return}}function At(e,t){return fe([ut,ft],t)?void 0===e||Et(e):t===dt?fe([pt.TIME,pt.UTC,void 0],e):t!==lt||fe([pt.LOG,pt.POW,pt.SQRT,pt.SYMLOG,pt.QUANTILE,pt.QUANTIZE,pt.THRESHOLD,pt.LINEAR,void 0],e)}function Ot(e,t){switch(e){case ye:case ve:return Tt(t)||fe(["band","point"],t);case ke:case Fe:case Me:case Ie:case Ue:return Tt(t)||t in vt||fe(["band","point"],t);case we:case Ce:case Ae:return"band"!==t;case Oe:return"ordinal"===t}return!1}function kt(e,t){return e+"_"+t}z(St,["type","domain","range","rangeStep","scheme"]),function(){const e={};for(const t of qe)for(const n of pe(ct))for(const r of gt){const i=kt(t,n);Ot(t,r)&&At(r,n)&&(e[i]=e[i]||[],e[i].push(r))}}();var Mt={exports:{}};!function(){var e=Mt.exports,t="__name__";e.namedfunc=function(e,n){return n[t]=e,n},e.name=function(e){return null==e?null:e[t]},e.identity=function(e){return e},e.true=e.namedfunc("true",(function(){return!0})),e.false=e.namedfunc("false",(function(){return!1})),e.duplicate=function(e){return JSON.parse(JSON.stringify(e))},e.equal=function(e,t){return JSON.stringify(e)===JSON.stringify(t)},e.extend=function(e){for(var t,n,r=1,i=arguments.length;r<i;++r)for(n in t=arguments[r])e[n]=t[n];return e},e.length=function(e){return null!=e&&null!=e.length?e.length:null},e.keys=function(e){var t,n=[];for(t in e)n.push(t);return n},e.vals=function(e){var t,n=[];for(t in e)n.push(e[t]);return n},e.toMap=function(t,n){return(n=e.$(n))?t.reduce((function(e,t){return e[n(t)]=1,e}),{}):t.reduce((function(e,t){return e[t]=1,e}),{})},e.keystr=function(e){var t=e.length;if(!t)return"";for(var n=String(e[0]),r=1;r<t;++r)n+="|"+String(e[r]);return n};var n=Object.prototype.toString;e.isObject=function(e){return e===Object(e)},e.isFunction=function(e){return"[object Function]"===n.call(e)},e.isString=function(e){return"string"==typeof value||"[object String]"===n.call(e)},e.isArray=Array.isArray||function(e){return"[object Array]"===n.call(e)},e.isNumber=function(e){return"number"==typeof e||"[object Number]"===n.call(e)},e.isBoolean=function(e){return!0===e||!1===e||"[object Boolean]"==n.call(e)},e.isDate=function(e){return"[object Date]"===n.call(e)},e.isValid=function(e){return null!=e&&e==e},e.isBuffer="function"==typeof Buffer&&Buffer.isBuffer||e.false,e.number=function(e){return null==e||""===e?null:+e},e.boolean=function(e){return null==e||""===e?null:"false"!==e&&!!e},e.date=function(e,t){var n=t||Date;return null==e||""===e?null:n.parse(e)},e.array=function(t){return null!=t?e.isArray(t)?t:[t]:[]},e.str=function(t){return e.isArray(t)?"["+t.map(e.str)+"]":e.isObject(t)||e.isString(t)?JSON.stringify(t).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):t};var r=/\[(.*?)\]|[^.\[]+/g;function i(e,t){var n,r="";for(n=0;n<e;++n)r+=t;return r}function o(e,t,n){var r=0,i=e.split(a);return(e=n?(i=i.reverse()).filter((function(e){return(r+=e.length)<=t})).reverse():i.filter((function(e){return(r+=e.length)<=t}))).length?e.join("").trim():i[0].slice(0,t)}e.field=function(e){return String(e).match(r).map((function(e){return"["!==e[0]?e:"'"!==e[1]&&'"'!==e[1]?e.slice(1,-1):e.slice(2,-2).replace(/\\(["'])/g,"$1")}))},e.accessor=function(t){return null==t||e.isFunction(t)?t:e.namedfunc(t,Function("x","return x["+e.field(t).map(e.str).join("][")+"];"))},e.$=e.accessor,e.mutator=function(t){var n;return e.isString(t)&&(n=e.field(t)).length>1?function(e,t){for(var r=0;r<n.length-1;++r)e=e[n[r]];e[n[r]]=t}:function(e,n){e[t]=n}},e.$func=function(t,n){return function(r){r=e.$(r)||e.identity;var i=t+(e.name(r)?"_"+e.name(r):"");return e.namedfunc(i,(function(e){return n(r(e))}))}},e.$valid=e.$func("valid",e.isValid),e.$length=e.$func("length",e.length),e.$in=function(t,n){t=e.$(t);var r=e.isArray(n)?e.toMap(n):n;return function(e){return!!r[t(e)]}},e.comparator=function(t){var n=[];return void 0===t&&(t=[]),t=e.array(t).map((function(t){var r=1;return"-"===t[0]?(r=-1,t=t.slice(1)):"+"===t[0]&&(r=1,t=t.slice(1)),n.push(r),e.accessor(t)})),function(r,i){var o,a,s,c;for(o=0,a=t.length;o<a;++o)if(s=t[o],c=e.cmp(s(r),s(i)))return c*n[o];return 0}},e.cmp=function(e,t){return(e<t||null==e)&&null!=t?-1:(e>t||null==t)&&null!=e?1:(t=t instanceof Date?+t:t,(e=e instanceof Date?+e:e)!==e&&t==t?-1:t!=t&&e==e?1:0)},e.numcmp=function(e,t){return e-t},e.stablesort=function(e,t,n){var r=e.reduce((function(e,t,r){return e[n(t)]=r,e}),{});return e.sort((function(e,i){var o=t(e),a=t(i);return o<a?-1:o>a?1:r[n(e)]-r[n(i)]})),e},e.permute=function(e){for(var t,n,r=e.length;r;)n=Math.floor(Math.random()*r--),t=e[r],e[r]=e[n],e[n]=t},e.pad=function(e,t,n,r){r=r||" ";var o=t-e.length;if(o<=0)return e;switch(n){case"left":return i(o,r)+e;case"middle":case"center":return i(Math.floor(o/2),r)+e+i(Math.ceil(o/2),r);default:return e+i(o,r)}},e.truncate=function(e,t,n,r,i){var a=e.length;if(a<=t)return e;i=void 0!==i?String(i):"…";var s=Math.max(0,t-i.length);switch(n){case"left":return i+(r?o(e,s,1):e.slice(a-s));case"middle":case"center":var c=Math.ceil(s/2),l=Math.floor(s/2);return(r?o(e,c):e.slice(0,c))+i+(r?o(e,l,1):e.slice(a-l));default:return(r?o(e,s):e.slice(0,s))+i}};var a=/([\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u2028\u2029\u3000\uFEFF])/}();var It=Mt.exports;function Ut(e,t){return-1!==e.indexOf(t)}function Ft(e,t){for(let n=0;n<e.length;n++)if(!t(e[n],n))return!1;return!0}function Dt(e,t,n){if(e.forEach)e.forEach.call(n,t);else for(let r in e)t.call(n,e[r],r,e)}function _t(e,t){let n,r=0;for(n in e)if(t(e[n],n,r++))return!0;return!1}function jt(e){return!!e.parent}const Pt={channel:1,aggregate:1,autoCount:1,bin:1,timeUnit:1,hasFn:1,sort:1,stack:1,field:1,type:1,format:1,scale:1,axis:1,legend:1,value:1},Rt=($t=Pt,Object.keys($t));var $t;const Bt={bin:1,scale:1,sort:1,axis:1,legend:1};function Lt(e){return Bt[e]}const Wt=["maxbins","divide","extent","base","step","steps","minstep"].map((e=>({parent:"bin",child:e}))),qt=["field","op","order"].map((e=>({parent:"sort",child:e}))),Ht=Nt.map((e=>({parent:"scale",child:e}))),Gt=et.map((e=>({parent:"axis",child:e}))),zt=nt.map((e=>({parent:"legend",child:e}))),Yt=[].concat(Wt,qt,Ht,Gt,zt),Qt=["width","height","background","padding","title"];function Vt(e){return jt(e)?e.parent+"."+e.child:e}const Kt=Yt.reduce(((e,t)=>(e[t.parent]=e[t.parent]||[],e[t.parent][t.child]=t,e)),{});function Jt(e,t){return(Kt[e]||{})[t]}function Xt(e){return function(e){return e in Pt}(e)||jt(e)}const Zt=[].concat(Rt,Yt),en=["type","field","bin","timeUnit","aggregate","autoCount","channel","mark","stack","scale","sort","axis","legend"].concat(Wt,Ht,Gt,zt,qt);var tn,nn;(nn=tn||(tn={})).MARK="mark",nn.TRANSFORM="transform",nn.STACK="stack",nn.FORMAT="format",nn.CHANNEL="channel",nn.AGGREGATE="aggregate",nn.AUTOCOUNT="autoCount",nn.BIN="bin",nn.HAS_FN="hasFn",nn.TIMEUNIT="timeUnit",nn.FIELD="field",nn.TYPE="type",nn.SORT="sort",nn.SCALE="scale",nn.AXIS="axis",nn.LEGEND="legend",nn.WIDTH="width",nn.HEIGHT="height",nn.BACKGROUND="background",nn.PADDING="padding",nn.TITLE="title";const rn="area",on="bar",an="line",sn="point",cn="rect",ln="rule",un="text",dn="tick",fn="circle",pn="square";function hn(e){return fe(["line","area","trail"],e)}ue(pe({area:1,bar:1,line:1,point:1,text:1,tick:1,trail:1,rect:1,geoshape:1,rule:1,circle:1,square:1}));["january","february","march","april","may","june","july","august","september","october","november","december"].map((e=>e.substr(0,3)));var gn,mn;["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].map((e=>e.substr(0,3))),(mn=gn||(gn={})).YEAR="year",mn.MONTH="month",mn.DAY="day",mn.DATE="date",mn.HOURS="hours",mn.MINUTES="minutes",mn.SECONDS="seconds",mn.MILLISECONDS="milliseconds",mn.YEARMONTH="yearmonth",mn.YEARMONTHDATE="yearmonthdate",mn.YEARMONTHDATEHOURS="yearmonthdatehours",mn.YEARMONTHDATEHOURSMINUTES="yearmonthdatehoursminutes",mn.YEARMONTHDATEHOURSMINUTESSECONDS="yearmonthdatehoursminutesseconds",mn.MONTHDATE="monthdate",mn.MONTHDATEHOURS="monthdatehours",mn.HOURSMINUTES="hoursminutes",mn.HOURSMINUTESSECONDS="hoursminutesseconds",mn.MINUTESSECONDS="minutesseconds",mn.SECONDSMILLISECONDS="secondsmilliseconds",mn.QUARTER="quarter",mn.YEARQUARTER="yearquarter",mn.QUARTERMONTH="quartermonth",mn.YEARQUARTERMONTH="yearquartermonth",mn.UTCYEAR="utcyear",mn.UTCMONTH="utcmonth",mn.UTCDAY="utcday",mn.UTCDATE="utcdate",mn.UTCHOURS="utchours",mn.UTCMINUTES="utcminutes",mn.UTCSECONDS="utcseconds",mn.UTCMILLISECONDS="utcmilliseconds",mn.UTCYEARMONTH="utcyearmonth",mn.UTCYEARMONTHDATE="utcyearmonthdate",mn.UTCYEARMONTHDATEHOURS="utcyearmonthdatehours",mn.UTCYEARMONTHDATEHOURSMINUTES="utcyearmonthdatehoursminutes",mn.UTCYEARMONTHDATEHOURSMINUTESSECONDS="utcyearmonthdatehoursminutesseconds",mn.UTCMONTHDATE="utcmonthdate",mn.UTCMONTHDATEHOURS="utcmonthdatehours",mn.UTCHOURSMINUTES="utchoursminutes",mn.UTCHOURSMINUTESSECONDS="utchoursminutesseconds",mn.UTCMINUTESSECONDS="utcminutesseconds",mn.UTCSECONDSMILLISECONDS="utcsecondsmilliseconds",mn.UTCQUARTER="utcquarter",mn.UTCYEARQUARTER="utcyearquarter",mn.UTCQUARTERMONTH="utcquartermonth",mn.UTCYEARQUARTERMONTH="utcyearquartermonth";const yn={year:1,quarter:1,month:1,day:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},vn=pe(yn);const bn={utcyear:1,utcquarter:1,utcmonth:1,utcday:1,utcdate:1,utchours:1,utcminutes:1,utcseconds:1,utcmilliseconds:1};const xn={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},En=Object.assign({},bn,xn);const Tn=Object.assign({},yn,bn,{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},xn);const Sn={year:"setFullYear",month:"setMonth",date:"setDate",hours:"setHours",minutes:"setMinutes",seconds:"setSeconds",milliseconds:"setMilliseconds",quarter:null,day:null};function Nn(e,t){const n=!!En[e];const r=n?new Date(Date.UTC(1972,0,1,0,0,0,0)):new Date(1972,0,1,0,0,0,0);for(const i of vn)if(Cn(e,i))switch(i){case gn.DAY:throw new Error("Cannot convert to TimeUnits containing 'day'");case gn.QUARTER:{const{getDateMethod:e,setDateMethod:i}=wn("month",n);r[i](3*Math.floor(t[e]()/3));break}default:{const{getDateMethod:e,setDateMethod:o}=wn(i,n);r[o](t[e]())}}return r}function wn(e,t){const n=Sn[e];return{setDateMethod:t?"setUTC"+n.substr(3):n,getDateMethod:"get"+(t?"UTC":"")+n.substr(3)}}function Cn(e,t){const n=e.indexOf(t);return n>-1&&(t!==gn.SECONDS||0===n||"i"!==e.charAt(n-1))}const An="?";function On(e){return kn(e)||function(e){return!(void 0===e||null==e||!e.enum&&!e.name||It.isArray(e))}(e)}function kn(e){return e===An}function Mn(e,t,n){return It.extend({},{name:t,enum:n},e===An?{}:e)}function In(e){let t={},n={};for(const r of e){const e=[0];for(let t=0;t<r.length;t++)r.charAt(t).toUpperCase()===r.charAt(t)&&e.push(t);let i=e.map((e=>r.charAt(e))).join("").toLowerCase();if(n[i])if(e[e.length-1]===r.length-1||(i=e.concat([r.length-1]).map((e=>r.charAt(e))).join("").toLowerCase(),n[i]))for(let o=1;!t[r];o++){let e=i+"_"+o;if(!n[e]){t[r]=e,n[e]=!0;break}}else t[r]=i,n[i]=!0;else t[r]=i,n[i]=!0}return t}const Un={mark:"m",channel:"c",aggregate:"a",autoCount:"#",hasFn:"h",bin:"b",sort:"so",stack:"st",scale:"s",format:"f",axis:"ax",legend:"l",value:"v",timeUnit:"tu",field:"f",type:"t",binProps:{maxbins:"mb",min:"mi",max:"ma",base:"b",step:"s",steps:"ss",minstep:"ms",divide:"d"},sortProps:{field:"f",op:"o",order:"or"},scaleProps:In(Nt),axisProps:In(et),legendProps:In(nt)};function Fn(e){if(jt(e))return Un[e.parent]+"-"+Un[e.parent+"Props"][e.child];if(Un[e])return Un[e];throw new Error("Default name undefined for "+e)}const Dn=[!1,!0],_n={type:[void 0,pt.LOG],domain:[void 0],base:[void 0],exponent:[1,2],constant:[void 0],bins:[void 0],clamp:Dn,nice:Dn,reverse:Dn,round:Dn,zero:Dn,padding:[void 0],paddingInner:[void 0],paddingOuter:[void 0],interpolate:[void 0],range:[void 0],rangeStep:[17,21],scheme:[void 0]},jn={zindex:[1,0],offset:[void 0],orient:[void 0],values:[void 0],bandPosition:[void 0],encoding:[void 0],domain:Dn,domainColor:[void 0],domainDash:[void 0],domainDashOffset:[void 0],domainOpacity:[void 0],domainWidth:[void 0],formatType:[void 0],grid:Dn,gridColor:[void 0],gridDash:[void 0],gridDashOffset:[void 0],gridOpacity:[void 0],gridWidth:[void 0],format:[void 0],labels:Dn,labelAlign:[void 0],labelAngle:[void 0],labelBaseline:[void 0],labelColor:[void 0],labelFlushOffset:[void 0],labelFont:[void 0],labelFontSize:[void 0],labelFontStyle:[void 0],labelFontWeight:[void 0],labelLimit:[void 0],labelOpacity:[void 0],labelSeparation:[void 0],labelOverlap:[void 0],labelPadding:[void 0],labelBound:[void 0],labelFlush:[void 0],maxExtent:[void 0],minExtent:[void 0],position:[void 0],ticks:Dn,tickColor:[void 0],tickCount:[void 0],tickDash:[void 0],tickExtra:[void 0],tickDashOffset:[void 0],tickMinStep:[void 0],tickOffset:[void 0],tickOpacity:[void 0],tickRound:[void 0],tickSize:[void 0],tickWidth:[void 0],title:[void 0],titleAlign:[void 0],titleAnchor:[void 0],titleAngle:[void 0],titleBaseline:[void 0],titleColor:[void 0],titleFont:[void 0],titleFontSize:[void 0],titleFontStyle:[void 0],titleFontWeight:[void 0],titleLimit:[void 0],titleOpacity:[void 0],titlePadding:[void 0],titleX:[void 0],titleY:[void 0]},Pn={mark:[sn,on,an,rn,cn,dn,un],channel:[ye,ve,he,ge,ke,we],aggregate:[void 0,"mean"],autoCount:Dn,bin:Dn,hasFn:Dn,timeUnit:[void 0,gn.YEAR,gn.MONTH,gn.MINUTES,gn.SECONDS],field:[void 0],type:[ft,ut,lt,dt],sort:["ascending","descending"],stack:["zero","normalize","center",null],value:[void 0],format:[void 0],title:[void 0],scale:[!0],axis:Dn,legend:Dn,binProps:{maxbins:[5,10,20],extent:[void 0],base:[10],step:[void 0],steps:[void 0],minstep:[void 0],divide:[[5,2]],binned:[!1],anchor:[void 0],nice:[!0]},sortProps:{field:[void 0],op:["min","mean"],order:["ascending","descending"]},scaleProps:_n,axisProps:jn,legendProps:{orient:["left","right"],format:[void 0],type:[void 0],values:[void 0],zindex:[void 0],clipHeight:[void 0],columnPadding:[void 0],columns:[void 0],cornerRadius:[void 0],direction:[void 0],encoding:[void 0],fillColor:[void 0],formatType:[void 0],gridAlign:[void 0],offset:[void 0],padding:[void 0],rowPadding:[void 0],strokeColor:[void 0],labelAlign:[void 0],labelBaseline:[void 0],labelColor:[void 0],labelFont:[void 0],labelFontSize:[void 0],labelFontStyle:[void 0],labelFontWeight:[void 0],labelLimit:[void 0],labelOffset:[void 0],labelOpacity:[void 0],labelOverlap:[void 0],labelPadding:[void 0],labelSeparation:[void 0],legendX:[void 0],legendY:[void 0],gradientLength:[void 0],gradientOpacity:[void 0],gradientStrokeColor:[void 0],gradientStrokeWidth:[void 0],gradientThickness:[void 0],symbolDash:[void 0],symbolDashOffset:[void 0],symbolFillColor:[void 0],symbolOffset:[void 0],symbolOpacity:[void 0],symbolSize:[void 0],symbolStrokeColor:[void 0],symbolStrokeWidth:[void 0],symbolType:[void 0],tickCount:[void 0],tickMinStep:[void 0],title:[void 0],titleAnchor:[void 0],titleAlign:[void 0],titleBaseline:[void 0],titleColor:[void 0],titleFont:[void 0],titleFontSize:[void 0],titleFontStyle:[void 0],titleFontWeight:[void 0],titleLimit:[void 0],titleOpacity:[void 0],titleOrient:[void 0],titlePadding:[void 0]}};function Rn(e,t,n){if("field"===e||jt(e)&&"sort"===e.parent&&"field"===e.child)return t.fieldNames();let r;if(r=jt(e)?n.enum[e.parent+"Props"][e.child]:n.enum[e],void 0!==r)return r;throw new Error("No default enumValues for "+JSON.stringify(e))}const $n={verbose:!1,defaultSpecConfig:{line:{point:!0},scale:{useUnaggregatedDomain:!0}},propertyPrecedence:en.map(Vt),enum:Pn,numberNominalProportion:.05,numberNominalLimit:40,constraintManuallySpecifiedValue:!1,autoAddCount:!1,hasAppropriateGraphicTypeForMark:!0,omitAggregate:!1,omitAggregatePlotWithDimensionOnlyOnFacet:!0,omitAggregatePlotWithoutDimension:!1,omitBarLineAreaWithOcclusion:!0,omitBarTickWithSize:!0,omitMultipleNonPositionalChannels:!0,omitRaw:!1,omitRawContinuousFieldForAggregatePlot:!0,omitRepeatedField:!0,omitNonPositionalOrFacetOverPositionalChannels:!0,omitTableWithOcclusionIfAutoAddCount:!0,omitVerticalDotPlot:!1,omitInvalidStackSpec:!0,omitNonSumStack:!0,preferredBinAxis:ye,preferredTemporalAxis:ye,preferredOrdinalAxis:ve,preferredNominalAxis:ve,preferredFacet:he,minCardinalityForBin:15,maxCardinalityForCategoricalColor:20,maxCardinalityForFacet:20,maxCardinalityForShape:6,timeUnitShouldHaveVariation:!0,typeMatchesSchemaType:!0,stylize:!0,smallRangeStepForHighCardinalityOrFacet:{maxCardinality:10,rangeStep:12},nominalColorScaleForHighCardinality:{maxCardinality:10,palette:"category20"},xAxisOnTopForHighYCardinalityWithoutColumn:{maxCardinality:30},maxGoodCardinalityForFacet:5,maxGoodCardinalityForColor:7,minPercentUniqueForKey:.8,minCardinalityForKey:50},Bn={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};const Ln=["count","sum","distinct","valid","missing"];function Wn(e){return le(e)&&(e=function(e,t){return le(e)?{maxbins:Hn(t)}:"binned"===e?{binned:!0}:e.maxbins||e.step?e:Object.assign({},e,{maxbins:Hn(t)})}(e,void 0)),"bin"+pe(e).map((t=>function(e){const t=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+t}(`_${t}_${e[t]}`))).join("")}function qn(e){return!0===e||function(e){return te(e)}(e)&&!e.binned}function Hn(e){switch(e){case he:case ge:case ke:case we:case Ce:case Ae:case Fe:case Me:case Ie:case Ue:case Oe:return 6;default:return 10}}function Gn(e){return!!e&&!!e.condition&&!ee(e.condition)&&zn(e.condition)}function zn(e){return!(!e||!e.field&&"count"!==e.aggregate)}function Yn(e){return zn(e)&&ne(e.field)}function Qn(e,t={}){let n=e.field;const r=t.prefix;let i=t.suffix,o="";if(function(e){return"count"===e.aggregate}(e))n=function(e){return 0===e.indexOf("__")}(s="count")?s:`__${s}`;else{let r;if(!t.nofn)if(function(e){return!!e.op}(e))r=e.op;else{const{bin:s,aggregate:c,timeUnit:l}=e;qn(s)?(r=Wn(s),i=(t.binSuffix||"")+(t.suffix||"")):c?(a=c)&&a.argmax?(o=`.${n}`,n=`argmax_${c.argmax}`):!function(e){return!!e&&!!e.argmin}(c)?r=String(c):(o=`.${n}`,n=`argmin_${c.argmin}`):l&&(r=String(l))}r&&(n=n?`${r}_${n}`:r)}var a,s;return i&&(n=`${n}_${i}`),r&&(n=`${r}_${n}`),t.forAs?n:t.expr?function(e,t="datum"){return`${t}[${re(Z(e).join("."))}]`}(n,t.expr)+o:function(e){return`${Z(e).map((e=>e.replace(".","\\."))).join("\\.")}`}(n)+o}function Vn(e){switch(e.type){case"nominal":case"ordinal":case"geojson":return!0;case"quantitative":return!!e.bin;case"temporal":return!1}throw new Error(it.invalidFieldType(e.type))}ue(["mean","average","median","q1","q3","min","max"]);const Kn={compatible:!0};function Jn(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 function(e){return!Vn(e)}(e)?{compatible:!1,warning:it.facetChannelShouldBeDiscrete(t)}:Kn;case"x":case"y":case"color":case"fill":case"stroke":case"text":case"detail":case"key":case"tooltip":case"href":return Kn;case"longitude":case"longitude2":case"latitude":case"latitude2":return n!==lt?{compatible:!1,warning:`Channel ${t} should be used with a quantitative field only, not ${e.type} field.`}:Kn;case"opacity":case"fillOpacity":case"strokeOpacity":case"strokeWidth":case"size":case"x2":case"y2":return"nominal"!==n||e.sort?Kn:{compatible:!1,warning:`Channel ${t} should not be used with an unsorted discrete field.`};case"shape":return fe(["ordinal","nominal","geojson"],e.type)?Kn:{compatible:!1,warning:"Shape channel should be used with only either discrete or geojson data."};case"order":return"nominal"!==e.type||"sort"in e?Kn:{compatible:!1,warning:"Channel order is inappropriate for nominal field, which has no inherent order."}}throw new Error("channelCompatability not implemented for channel "+t)}function Xn(e,t,n,r){const i=function(e,t,n){switch(t.type){case"nominal":case"ordinal":return Le(e)||"discrete"===Je(e)?("shape"===e&&"ordinal"===t.type&&st(it.discreteChannelCannotEncode(e,"ordinal")),"ordinal"):fe(["x","y"],e)&&fe(["rect","bar","rule"],n)?"band":"point";case"temporal":return Le(e)?"time":"discrete"===Je(e)?(st(it.discreteChannelCannotEncode(e,"temporal")),"ordinal"):"time";case"quantitative":return Le(e)?qn(t.bin)?"bin-ordinal":"linear":"discrete"===Je(e)?(st(it.discreteChannelCannotEncode(e,"quantitative")),"ordinal"):"linear";case"geojson":return}throw new Error(it.invalidFieldType(t.type))}(t,n,r),{type:o}=e;return function(e){return!!Ye[e]}(t)?void 0!==o?Ot(t,o)?At(o,n.type)?o:(st(it.scaleTypeNotWorkWithFieldDef(o,i)),i):(st(it.scaleTypeNotWorkWithChannel(t,o,i)),i):i:null}var Zn,er;function tr(e){return e===ut||e===ft||e===Zn.KEY}(er=Zn||(Zn={})).QUANTITATIVE=lt,er.ORDINAL=ut,er.TEMPORAL=dt,er.NOMINAL=ft,er.KEY="key";class nr{constructor(e=null){this.index=e?Object.assign({},e):{}}has(e){return Vt(e)in this.index}get(e){return this.index[Vt(e)]}set(e,t){return this.index[Vt(e)]=t,this}setByKey(e,t){this.index[e]=t}map(e){const t=new nr;for(const n in this.index)t.index[n]=e(this.index[n]);return t}size(){return It.keys(this.index).length}duplicate(){return new nr(this.index)}}function rr(e,t){const n=e&&e[t];return!!n&&(ee(n)?function(e,t){let n=0;for(const[r,i]of e.entries())if(t(i,r,n++))return!0;return!1}(n,(e=>!!e.field)):zn(n)||Gn(n))}const ir={zero:1,center:1,normalize:1};const or=[on,rn,ln,sn,fn,pn,an,un,dn],ar=[on,rn];function sr(e,t,n,r={}){const i=function(e){return e.type}(e)?e.type:e;if(!fe(or,i))return null;const o=function(e){const t=e.x,n=e.y;if(zn(t)&&zn(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(zn(t)&&"quantitative"===t.type)return"x";if(zn(n)&&"quantitative"===n.type)return"y"}}(t);if(!o)return null;const a=t[o],s=Yn(a)?Qn(a,{}):void 0,c="x"===o?"y":"x",l=t[c],u=Yn(l)?Qn(l,{}):void 0,d=Ge.reduce(((e,n)=>{if("tooltip"!==n&&rr(t,n)){const r=t[n];(ee(r)?r:[r]).forEach((t=>{const r=function(e){return zn(e)?e:Gn(e)?e.condition:void 0}(t);if(r.aggregate)return;const i=Yn(r)?Qn(r,{}):void 0;(!i||i!==u&&i!==s)&&e.push({channel:n,fieldDef:r})}))}return e}),[]);let f;if(void 0!==a.stack?f=le(a.stack)?a.stack?"zero":null:a.stack:d.length>0&&(f=fe(ar,i)?function(...e){for(const t of e)if(void 0!==t)return t}(n,"zero"):n),!f||!ir[f])return null;if(a.scale&&a.scale.type&&a.scale.type!==pt.LINEAR){if(r.disallowNonLinearStack)return null;st(it.cannotStackNonLinearScale(a.scale.type))}return rr(t,o===ye?be:xe)?(void 0!==a.stack&&st(it.cannotStackRangedMark(o)),null):(a.aggregate&&!fe(Ln,a.aggregate)&&st(it.stackNonSummativeAggregate(a.aggregate)),{groupbyChannel:l?c:void 0,fieldChannel:o,impute:hn(i),stackBy:d,offset:f})}function cr(e){if(!function(e){if(On(e.mark))return!1;const t=[tn.STACK,tn.CHANNEL,tn.MARK,tn.FIELD,tn.AGGREGATE,tn.AUTOCOUNT,tn.SCALE,Jt("scale","type"),tn.TYPE],n=It.toMap((i=Zt,o=t,i.filter((function(e){return!Ut(o,e)})))),r=e.encodings.filter((e=>!Nr(e)));var i,o;for(const a of r)if(lr(a,{exclude:n}))return!1;return!0}(e))return null;const t=Ar(e.encodings,{schema:null,wildcardMode:"null"});return sr(e.mark,t,void 0,{disallowNonLinearStack:!0})}function lr(e,t={}){if(!It.isObject(e))return!1;for(const n in e)if(e.hasOwnProperty(n)){if(On(e[n])&&(!t.exclude||!t.exclude[n])||lr(e[n],t))return!0}return!1}function ur(e){return e.map((e=>{return t=e,e=>void 0!==t[e]?t[e]:e;var t}))}function dr(e,t){return On(e)?!kn(e)&&e.enum?An+JSON.stringify(e.enum):An:t?t(e):e}function fr(e,t){return t?t(e):e}const pr=new nr,hr=[].concat(en,qt,[tn.TRANSFORM,tn.STACK],Qt).reduce(((e,t)=>e.set(t,!0)),new nr),gr={axis:{x:!0,y:!0,row:!0,column:!0},legend:{color:!0,opacity:!0,size:!0,shape:!0},scale:{x:!0,y:!0,color:!0,opacity:!0,row:!0,column:!0,size:!0,shape:!0},sort:{x:!0,y:!0,path:!0,order:!0},stack:{x:!0,y:!0}};function mr(e,t=hr,n=pr){const r=[];let i;if(t.get(tn.MARK)&&r.push(dr(e.mark,n.get(tn.MARK))),e.transform&&e.transform.length>0&&r.push("transform:"+JSON.stringify(e.transform)),t.get(tn.STACK)&&(i=cr(e)),e.encodings){const o=e.encodings.reduce(((e,r)=>{if(!Nr(r)){let o;o=i&&r.channel===i.fieldChannel?yr(Object.assign({},r,{stack:i.offset}),t,n):yr(r,t,n),o&&e.push(o)}return e}),[]).sort().join("|");o&&r.push(o)}for(let o of Qt){const n=o.toString();if(t.get(o)&&e[n]){const t=e[n];r.push(`${n}=${JSON.stringify(t)}`)}}return r.join("|")}function yr(e,t=hr,n=pr){const r=[];if(t.get(tn.CHANNEL)&&r.push(dr(e.channel,n.get(tn.CHANNEL))),Tr(e)){const i=vr(e,t,n);i&&r.push(i)}else Er(e)?r.push(e.value):Sr(e)&&r.push("autocount()");return r.join(":")}function vr(e,t=hr,n=pr){if(t.get(tn.AGGREGATE)&&Nr(e))return"-";const r=function(e,t,n){if(t.get(tn.AGGREGATE)&&e.aggregate&&!On(e.aggregate))return fr(e.aggregate,n.get(tn.AGGREGATE));if(t.get(tn.AGGREGATE)&&wr(e))return fr("count",n.get(tn.AGGREGATE));if(t.get(tn.TIMEUNIT)&&e.timeUnit&&!On(e.timeUnit))return fr(e.timeUnit,n.get(tn.TIMEUNIT));if(t.get(tn.BIN)&&e.bin&&!On(e.bin))return"bin";{let n=null;for(const r of[tn.AGGREGATE,tn.AUTOCOUNT,tn.TIMEUNIT,tn.BIN]){const i=e[r];t.get(r)&&e[r]&&On(i)&&(n=n||{},n[r]=kn(i)?i:i.enum)}return n&&e.hasFn&&(n.hasFn=!0),n}}(e,t,n),i=function(e,t,n){const r=[];if(!It.isBoolean(e.bin)&&!kn(e.bin)){const i=e.bin;for(const e in i){const o=Jt("bin",e);o&&t.get(o)&&void 0!==i[e]&&r.push({key:e,value:dr(i[e],n.get(o))})}r.sort(((e,t)=>e.key.localeCompare(t.key)))}for(const i of[tn.SCALE,tn.SORT,tn.STACK,tn.AXIS,tn.LEGEND])if((On(e.channel)||gr[i][e.channel])&&t.get(i)&&void 0!==e[i]){const o=e[i];if(It.isBoolean(o)||null===o)r.push({key:i+"",value:o||!1});else if(It.isString(o))r.push({key:i+"",value:fr(JSON.stringify(o),n.get(i))});else{let e=[];for(const r in o){const a=Jt(i,r);a&&t.get(a)&&void 0!==o[r]&&e.push({key:r,value:dr(o[r],n.get(a))})}if(e.length>0){const t=e.sort(((e,t)=>e.key.localeCompare(t.key))).reduce(((e,t)=>(e[t.key]=t.value,e)),{});r.push({key:i+"",value:JSON.stringify(t)})}}}return r}(e,t,n);let o;if(Tr(e)){if(o=t.get("field")?dr(e.field,n.get("field")):"...",t.get(tn.TYPE))if(On(e.type))o+=","+dr(e.type,n.get(tn.TYPE));else{o+=","+dr(((e.type||lt)+"").substr(0,1),n.get(tn.TYPE))}o+=i.map((e=>{let t=e.value instanceof Array?"["+e.value+"]":e.value;return","+e.key+"="+t})).join("")}else Sr(e)&&(o="*,q");if(!o)return null;if(r){return(It.isString(r)?r:An+(It.keys(r).length>0?JSON.stringify(r):""))+"("+o+")"}return o}function br(e,t,n){let r=[],i=0;for(let o=0;o<n;o++){let n=e.indexOf(t,i);if(-1===n)break;r.push(e.substring(i,n)),i=n+1}if(r.push(e.substr(i)),r.length!==n+1)for(;r.length!==n+1;)r.push("");return r}var xr;function Er(e){return null!=e&&void 0!==e.value}function Tr(e){return null!=e&&(e.field||"count"===e.aggregate)}function Sr(e){return null!=e&&"autoCount"in e}function Nr(e){return Sr(e)&&!1===e.autoCount}function wr(e){return Sr(e)&&!0===e.autoCount}!function(e){function t(e){const t={};t.field=e[0],t.type=function(e){if(e)switch(e=e.toLowerCase()){case"q":case lt:return"quantitative";case"t":case dt:return"temporal";case"o":case ut:return"ordinal";case"n":case ft:return"nominal";case"geojson":return"geojson"}}(e[1].toUpperCase())||"?";let r=e[2],i=0,o=0;for(;o<r.length;){let e,a=r.indexOf("=",o);if(-1===a)break;{let s=r.substring(o,a);if("{"===r[o+s.length+1]){let t=o+s.length+1;i=n(t,r,"}");const a=r.substring(t,i+1);e=JSON.parse(a),o=i+2}else if("["===r[o+s.length+1]){let t=o+s.length+1,i=n(t,r,"]");const a=r.substring(t,i+1);e=JSON.parse(a),o=i+2}else{let t=o,n=r.indexOf(",",o+s.length);-1===n&&(n=r.length),o=n+1,e=JSON.parse(r.substring(t+s.length+1,n))}Lt(s)?t[s]=e:(t.bin=t.bin||{},t.bin[s]=e)}}return t}function n(e,t,n){for(let r=e;r<t.length;r++)if(t[r]===n)return r}function r(e){const r={};if("?"===e[0]){let i=n(1,e,"}"),o=JSON.parse(e.substring(1,i+1));for(let e in o)It.isArray(o[e])?r[e]={enum:o[e]}:r[e]=o[e];return Object.assign({},r,t(br(e.substring(i+2,e.length-1),",",2)))}{let n=e.substring(0,e.indexOf("(")),r=br(e.substring(n.length+1,e.length-1),",",2);if(ne(i=n)&&Bn[i])return Object.assign({aggregate:n},t(r));if(Tn[n])return Object.assign({timeUnit:n},t(r));if("bin"===n)return Object.assign({bin:{}},t(r))}var i}e.encoding=function(e,n){let i=-1!==n.indexOf("(")?r(n):t(br(n,",",2));return Object.assign({channel:e},i)},e.rawFieldDef=t,e.getClosingIndex=n,e.fn=r}(xr||(xr={}));const Cr=[tn.AGGREGATE,tn.BIN,tn.TIMEUNIT,tn.FIELD,tn.TYPE,tn.SCALE,tn.SORT,tn.AXIS,tn.LEGEND,tn.STACK,tn.FORMAT];function Ar(e,t){let n={};for(const r of e){if(Nr(r))continue;const{channel:e}=r;if(On(e))throw new Error("Cannot convert wildcard channel to a fixed channel");const i=Er(r)?Or(r):kr(r,t);if(null!==i)n[e]=i;else if("null"===t.wildcardMode)return null}return n}function Or(e){const{value:t}=e;return On(t)?null:{value:t}}function kr(e,t={}){const{props:n=Cr,schema:r,wildcardMode:i="skip"}=t;if(Tr(e)){const t={};for(const o of n){let n=e[o];if(On(n)){if("skip"===i)continue;return null}if(void 0!==n){if(!(!gr[o]||gr[o][e.channel]))continue;if(Lt(o)&&It.isObject(n)){n=Object.assign({},n);for(const e in n)if(On(n[e])){if("null"===i)return null;delete n[e]}}if("bin"===o&&!1===n)continue;"type"===o&&"key"===n?t.type="nominal":t[o]=n}if(o===tn.SCALE&&r&&e.type===ut){const n=e.scale,{ordinalDomain:i}=r.fieldSchema(e.field);null!==n&&i&&(t[tn.SCALE]=Object.assign({domain:i},It.isObject(n)?n:{}))}}return t}if(!1===e.autoCount)throw new Error("Cannot convert {autoCount: false} into a field def");return{aggregate:"count",field:"*",type:"quantitative"}}function Mr(e){return Tr(e)?!Ir(e)&&"temporal"!==e.type:Sr(e)}function Ir(e){if(Tr(e)){const t=kr(e,{props:["bin","timeUnit","type"]});return Vn(t)||!!t.timeUnit}return!1}function Ur(e){const t=!0===e.scale||e.scale===An?{}:e.scale||{},{type:n,channel:r,timeUnit:i,bin:o}=e;if(On(t.type)||On(n)||On(r)||On(o))return;if(t.type)return t.type;if("temporal"===n&&On(i))return;if("quantitative"===n&&On(o))return;const a={type:n===Zn.KEY?"nominal":n,timeUnit:i,bin:o};return Xn({type:t.type},r,a,void 0)}var Fr={exports:{}},Dr=new Date,_r=new Date;function jr(e,t,n,r){function i(t){return e(t=new Date(+t)),t}return i.floor=i,i.round=function(n){var r=new Date(+n),i=new Date(n-1);return e(r),e(i),t(i,1),n-r<i-n?r:i},i.ceil=function(n){return e(n=new Date(n-1)),t(n,1),n},i.offset=function(e,n){return t(e=new Date(+e),null==n?1:Math.floor(n)),e},i.range=function(n,r,i){var o=[];if(n=new Date(n-1),r=new Date(+r),i=null==i?1:Math.floor(i),!(n<r&&i>0))return o;for(t(n,1),e(n),n<r&&o.push(new Date(+n));t(n,i),e(n),n<r;)o.push(new Date(+n));return o},i.filter=function(n){return jr((function(t){for(;e(t),!n(t);)t.setTime(t-1)}),(function(e,r){for(;--r>=0;)for(;t(e,1),!n(e););}))},n&&(i.count=function(t,r){return Dr.setTime(+t),_r.setTime(+r),e(Dr),e(_r),Math.floor(n(Dr,_r))},i.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?i.filter(r?function(t){return r(t)%e==0}:function(t){return i.count(0,t)%e==0}):i:null}),i}var Pr=jr((function(){}),(function(e,t){e.setTime(+e+t)}),(function(e,t){return t-e}));Pr.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?jr((function(t){t.setTime(Math.floor(t/e)*e)}),(function(t,n){t.setTime(+t+n*e)}),(function(t,n){return(n-t)/e})):Pr:null};const Rr=jr((function(e){e.setMilliseconds(0)}),(function(e,t){e.setTime(+e+1e3*t)}),(function(e,t){return(t-e)/1e3}),(function(e){return e.getSeconds()})),$r=jr((function(e){e.setSeconds(0,0)}),(function(e,t){e.setTime(+e+6e4*t)}),(function(e,t){return(t-e)/6e4}),(function(e){return e.getMinutes()})),Br=jr((function(e){e.setMinutes(0,0,0)}),(function(e,t){e.setTime(+e+36e5*t)}),(function(e,t){return(t-e)/36e5}),(function(e){return e.getHours()})),Lr=jr((function(e){e.setHours(0,0,0,0)}),(function(e,t){e.setDate(e.getDate()+t)}),(function(e,t){return(t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/864e5}),(function(e){return e.getDate()-1}));function Wr(e){return jr((function(t){t.setHours(0,0,0,0),t.setDate(t.getDate()-(t.getDay()+7-e)%7)}),(function(e,t){e.setDate(e.getDate()+7*t)}),(function(e,t){return(t-e-6e4*(t.getTimezoneOffset()-e.getTimezoneOffset()))/6048e5}))}var qr=Wr(0),Hr=Wr(1),Gr=Wr(2),zr=Wr(3),Yr=Wr(4),Qr=Wr(5),Vr=Wr(6);const Kr=jr((function(e){e.setHours(0,0,0,0),e.setDate(1)}),(function(e,t){e.setMonth(e.getMonth()+t)}),(function(e,t){return t.getMonth()-e.getMonth()+12*(t.getFullYear()-e.getFullYear())}),(function(e){return e.getMonth()})),Jr=jr((function(e){e.setHours(0,0,0,0),e.setMonth(0,1)}),(function(e,t){e.setFullYear(e.getFullYear()+t)}),(function(e,t){return t.getFullYear()-e.getFullYear()}),(function(e){return e.getFullYear()})),Xr=jr((function(e){e.setUTCMilliseconds(0)}),(function(e,t){e.setTime(+e+1e3*t)}),(function(e,t){return(t-e)/1e3}),(function(e){return e.getUTCSeconds()})),Zr=jr((function(e){e.setUTCSeconds(0,0)}),(function(e,t){e.setTime(+e+6e4*t)}),(function(e,t){return(t-e)/6e4}),(function(e){return e.getUTCMinutes()})),ei=jr((function(e){e.setUTCMinutes(0,0,0)}),(function(e,t){e.setTime(+e+36e5*t)}),(function(e,t){return(t-e)/36e5}),(function(e){return e.getUTCHours()})),ti=jr((function(e){e.setUTCHours(0,0,0,0)}),(function(e,t){e.setUTCDate(e.getUTCDate()+t)}),(function(e,t){return(t-e)/864e5}),(function(e){return e.getUTCDate()-1}));function ni(e){return jr((function(t){t.setUTCHours(0,0,0,0),t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7)}),(function(e,t){e.setUTCDate(e.getUTCDate()+7*t)}),(function(e,t){return(t-e)/6048e5}))}var ri=ni(0),ii=ni(1),oi=ni(2),ai=ni(3),si=ni(4),ci=ni(5),li=ni(6);const ui=jr((function(e){e.setUTCHours(0,0,0,0),e.setUTCDate(1)}),(function(e,t){e.setUTCMonth(e.getUTCMonth()+t)}),(function(e,t){return t.getUTCMonth()-e.getUTCMonth()+12*(t.getUTCFullYear()-e.getUTCFullYear())}),(function(e){return e.getUTCMonth()})),di=jr((function(e){e.setUTCHours(0,0,0,0),e.setUTCMonth(0,1)}),(function(e,t){e.setUTCFullYear(e.getUTCFullYear()+t)}),(function(e,t){return t.getUTCFullYear()-e.getUTCFullYear()}),(function(e){return e.getUTCFullYear()}));var fi=Pr.range,pi=Rr.range,hi=$r.range,gi=Br.range,mi=Lr.range,yi=qr.range,vi=Hr.range,bi=Gr.range,xi=zr.range,Ei=Yr.range,Ti=Qr.range,Si=Vr.range,Ni=qr.range,wi=Kr.range,Ci=Jr.range,Ai=Pr,Oi=fi,ki=Xr.range,Mi=Zr.range,Ii=ei.range,Ui=ti.range,Fi=ri.range,Di=ii.range,_i=oi.range,ji=ai.range,Pi=si.range,Ri=ci.range,$i=li.range,Bi=ri.range,Li=ui.range,Wi=di.range;var qi=n(Object.freeze(Object.defineProperty({__proto__:null,day:Lr,days:mi,friday:Qr,fridays:Ti,hour:Br,hours:gi,interval:jr,millisecond:Pr,milliseconds:fi,minute:$r,minutes:hi,monday:Hr,mondays:vi,month:Kr,months:wi,saturday:Vr,saturdays:Si,second:Rr,seconds:pi,sunday:qr,sundays:yi,thursday:Yr,thursdays:Ei,tuesday:Gr,tuesdays:bi,utcDay:ti,utcDays:Ui,utcFriday:ci,utcFridays:Ri,utcHour:ei,utcHours:Ii,utcMillisecond:Ai,utcMilliseconds:Oi,utcMinute:Zr,utcMinutes:Mi,utcMonday:ii,utcMondays:Di,utcMonth:ui,utcMonths:Li,utcSaturday:li,utcSaturdays:$i,utcSecond:Xr,utcSeconds:ki,utcSunday:ri,utcSundays:Fi,utcThursday:si,utcThursdays:Pi,utcTuesday:oi,utcTuesdays:_i,utcWednesday:ai,utcWednesdays:ji,utcWeek:ri,utcWeeks:Bi,utcYear:di,utcYears:Wi,wednesday:zr,wednesdays:xi,week:qr,weeks:Ni,year:Jr,years:Ci},Symbol.toStringTag,{value:"Module"}))),Hi=new Date,Gi=new Date(0,0,1).setFullYear(0),zi=new Date(Date.UTC(0,0,1)).setUTCFullYear(0);function Yi(e){return Hi.setTime(+e),Hi}function Qi(e,t,n,r,i,o){var a={type:e,date:t,unit:n};return r?a.step=r:a.minstep=1,null!=i&&(a.min=i),null!=o&&(a.max=o),a}function Vi(e,t,n,r,i,o){return Qi(e,(function(e){return t.offset(n,e)}),(function(e){return t.count(n,e)}),r,i,o)}var Ki=[Vi("second",qi.second,Gi),Vi("minute",qi.minute,Gi),Vi("hour",qi.hour,Gi),Vi("day",qi.day,Gi,[1,7]),Vi("month",qi.month,Gi,[1,3,6]),Vi("year",qi.year,Gi),Qi("seconds",(function(e){return new Date(1970,0,1,0,0,e)}),(function(e){return Yi(e).getSeconds()}),null,0,59),Qi("minutes",(function(e){return new Date(1970,0,1,0,e)}),(function(e){return Yi(e).getMinutes()}),null,0,59),Qi("hours",(function(e){return new Date(1970,0,1,e)}),(function(e){return Yi(e).getHours()}),null,0,23),Qi("weekdays",(function(e){return new Date(1970,0,4+e)}),(function(e){return Yi(e).getDay()}),[1],0,6),Qi("dates",(function(e){return new Date(1970,0,e)}),(function(e){return Yi(e).getDate()}),[1],1,31),Qi("months",(function(e){return new Date(1970,e%12,1)}),(function(e){return Yi(e).getMonth()}),[1],0,11)],Ji=[Vi("second",qi.utcSecond,zi),Vi("minute",qi.utcMinute,zi),Vi("hour",qi.utcHour,zi),Vi("day",qi.utcDay,zi,[1,7]),Vi("month",qi.utcMonth,zi,[1,3,6]),Vi("year",qi.utcYear,zi),Qi("seconds",(function(e){return new Date(Date.UTC(1970,0,1,0,0,e))}),(function(e){return Yi(e).getUTCSeconds()}),null,0,59),Qi("minutes",(function(e){return new Date(Date.UTC(1970,0,1,0,e))}),(function(e){return Yi(e).getUTCMinutes()}),null,0,59),Qi("hours",(function(e){return new Date(Date.UTC(1970,0,1,e))}),(function(e){return Yi(e).getUTCHours()}),null,0,23),Qi("weekdays",(function(e){return new Date(Date.UTC(1970,0,4+e))}),(function(e){return Yi(e).getUTCDay()}),[1],0,6),Qi("dates",(function(e){return new Date(Date.UTC(1970,0,e))}),(function(e){return Yi(e).getUTCDate()}),[1],1,31),Qi("months",(function(e){return new Date(Date.UTC(1970,e%12,1))}),(function(e){return Yi(e).getUTCMonth()}),[1],0,11)],Xi=[[31536e6,5],[7776e6,4],[2592e6,4],[12096e5,3],[6048e5,3],[1728e5,3],[864e5,3],[432e5,2],[216e5,2],[108e5,2],[36e5,2],[18e5,1],[9e5,1],[3e5,1],[6e4,1],[3e4,0],[15e3,0],[5e3,0],[1e3,0]];function Zi(e){var t,n,r={};for(t=0,n=e.length;t<n;++t)r[e[t].type]=e[t];return r.find=function(t,n,r){return function(e,t,n,r){var i,o,a,s=Xi[0];for(i=1,o=Xi.length;i<o;++i)if(t>(s=Xi[i])[0]){if((a=t/s[0])>r)return e[Xi[i-1][1]];if(a>=n)return e[s[1]]}return e[Xi[o-1][1]]}(e,t,n,r)},r}Fr.exports=Zi(Ki),Fr.exports.utc=Zi(Ji);var eo=Fr.exports,to=It,no=eo;function ro(e){if(!e)throw Error("Missing binning options.");var t,n,r,i,o,a,s,c=e.maxbins||15,l=e.base||10,u=Math.log(l),d=e.div||[5,2],f=e.min,p=e.max,h=p-f;if(e.step)t=e.step;else if(e.steps)t=e.steps[Math.min(e.steps.length-1,function(e,t,n,r){for(;n<r;){var i=n+r>>>1;to.cmp(e[i],t)<0?n=i+1:r=i}return n}(e.steps,h/c,0,e.steps.length))];else{for(n=Math.ceil(Math.log(c)/u),r=e.minstep||0,t=Math.max(r,Math.pow(l,Math.round(Math.log(h)/u)-n));Math.ceil(h/t)>c;)t*=l;for(a=0;a<d.length;++a)(o=t/d[a])>=r&&h/o<=c&&(t=o)}return i=(o=Math.log(t))>=0?0:1+~~(-o/u),s=Math.pow(l,-i-1),{start:f=Math.min(f,Math.floor(f/t+s)*t),stop:p=Math.ceil(p/t)*t,step:t,unit:{precision:i},value:io,index:oo}}function io(e){return this.step*Math.floor(e/this.step+1e-15)}function oo(e){return Math.floor((e-this.start)/this.step+1e-15)}function ao(e){return this.unit.date(io.call(this,e))}function so(e){return oo.call(this,this.unit.unit(e))}ro.date=function(e){if(!e)throw Error("Missing date binning options.");var t=e.utc?no.utc:no,n=e.min,r=e.max,i=e.maxbins||20,o=e.minbins||4,a=+r-+n,s=e.unit?t[e.unit]:t.find(a,o,i),c=ro({min:null!=s.min?s.min:s.unit(n),max:null!=s.max?s.max:s.unit(r),maxbins:i,minstep:s.minstep,steps:s.step});return c.unit=s,c.index=so,e.raw||(c.value=ao),c};const co=t(ro);var lo=It,uo="__types__",fo={boolean:lo.boolean,integer:lo.number,number:lo.number,date:lo.date,string:function(e){return null==e||""===e?null:e+""}},po={boolean:function(e){return"true"===e||"false"===e||lo.isBoolean(e)},integer:function(e){return po.number(e)&&(e=+e)==~~e},number:function(e){return!isNaN(+e)&&!lo.isDate(e)},date:function(e){return!isNaN(Date.parse(e))}};function ho(e){return lo.keys(e)}function go(e){return"["+e+"]"}function mo(e,t){var n,r,i;if(e=lo.array(e),t=lo.$(t),e[uo]&&(n=t(e[uo]),lo.isString(n)))return n;for(r=0,i=e.length;!lo.isValid(n)&&r<i;++r)n=t?t(e[r]):e[r];return lo.isDate(n)?"date":lo.isNumber(n)?"number":lo.isBoolean(n)?"boolean":lo.isString(n)?"string":null}function yo(e,t){var n,r,i;e=lo.array(e),t=lo.$(t);var o=["boolean","integer","number","date"];for(n=0;n<e.length;++n){for(i=t?t(e[n]):e[n],r=0;r<o.length;++r)lo.isValid(i)&&!po[o[r]](i)&&(o.splice(r,1),r-=1);if(0===o.length)return"string"}return o[0]}mo.annotation=function(e,t){if(!t)return e&&e[uo]||null;e[uo]=t},mo.all=function(e,t){if(e.length){var n=t?lo.identity:(t=ho(e[0]),go);return t.reduce((function(t,r){return t[r]=mo(e,n(r)),t}),{})}},mo.infer=yo,mo.inferAll=function(e,t){var n=t?lo.identity:(t=ho(e[0]),go);return t.reduce((function(t,r){return t[r]=yo(e,n(r)),t}),{})},mo.parsers=fo;var vo,bo,xo=mo,Eo={exports:{}},To={exports:{}};vo=It,(bo=To.exports).repeat=function(e,t){var n,r=Array(t);for(n=0;n<t;++n)r[n]=e;return r},bo.zeros=function(e){return bo.repeat(0,e)},bo.range=function(e,t,n){if(arguments.length<3&&(n=1,arguments.length<2&&(t=e,e=0)),(t-e)/n==1/0)throw new Error("Infinite range");var r,i=[],o=-1;if(n<0)for(;(r=e+n*++o)>t;)i.push(r);else for(;(r=e+n*++o)<t;)i.push(r);return i},bo.random={},bo.random.uniform=function(e,t){void 0===t&&(t=void 0===e?1:e,e=0);var n=t-e,r=function(){return e+n*Math.random()};return r.samples=function(e){return bo.zeros(e).map(r)},r.pdf=function(r){return r>=e&&r<=t?1/n:0},r.cdf=function(r){return r<e?0:r>t?1:(r-e)/n},r.icdf=function(t){return t>=0&&t<=1?e+t*n:NaN},r},bo.random.integer=function(e,t){void 0===t&&(t=e,e=0);var n=t-e,r=function(){return e+Math.floor(n*Math.random())};return r.samples=function(e){return bo.zeros(e).map(r)},r.pdf=function(r){return r===Math.floor(r)&&r>=e&&r<t?1/n:0},r.cdf=function(r){var i=Math.floor(r);return i<e?0:i>=t?1:(i-e+1)/n},r.icdf=function(t){return t>=0&&t<=1?e-1+Math.floor(t*n):NaN},r},bo.random.normal=function(e,t){var n;e=e||0,t=t||1;var r=function(){var r,i,o=0,a=0;if(void 0!==n)return o=n,n=void 0,o;do{r=(o=2*Math.random()-1)*o+(a=2*Math.random()-1)*a}while(0===r||r>1);return i=Math.sqrt(-2*Math.log(r)/r),n=e+a*i*t,e+o*i*t};return r.samples=function(e){return bo.zeros(e).map(r)},r.pdf=function(n){var r=Math.exp(Math.pow(n-e,2)/(-2*Math.pow(t,2)));return 1/(t*Math.sqrt(2*Math.PI))*r},r.cdf=function(n){var r,i=(n-e)/t,o=Math.abs(i);if(o>37)r=0;else{var a=Math.exp(-o*o/2);o<7.07106781186547?(r=a*((((((.0352624965998911*o+.700383064443688)*o+6.37396220353165)*o+33.912866078383)*o+112.079291497871)*o+221.213596169931)*o+220.206867912376),r/=((((((.0883883476483184*o+1.75566716318264)*o+16.064177579207)*o+86.7807322029461)*o+296.564248779674)*o+637.333633378831)*o+793.826512519948)*o+440.413735824752):r=a/(o+1/(o+2/(o+3/(o+4/(o+.65)))))/2.506628274631}return i>0?1-r:r},r.icdf=function(n){if(n<=0||n>=1)return NaN;var r=2*n-1,i=8*(Math.PI-3)/(3*Math.PI*(4-Math.PI)),o=2/(Math.PI*i)+Math.log(1-Math.pow(r,2))/2,a=Math.log(1-r*r)/i,s=(r>0?1:-1)*Math.sqrt(Math.sqrt(o*o-a)-o);return e+t*Math.SQRT2*s},r},bo.random.bootstrap=function(e,t){var n=e.filter(vo.isValid),r=n.length,i=t?bo.random.normal(0,t):null,o=function(){return n[~~(Math.random()*r)]+(i?i():0)};return o.samples=function(e){return bo.zeros(e).map(o)},o};var So=To.exports;!function(){var e=It,t=xo,n=So,r=Eo.exports;function i(e,t,i){var o=e&&e.nullh||0,a=n.random.normal(0,1),s=r.mean(t,i),c=r.stdev(t,i)/Math.sqrt(r.count.valid(t,i));if(0===c)return s-o==0?1:0;var l=(s-o)/c;return 2*a.cdf(-Math.abs(l))}function o(t,n,i,o){var a,s=o?n.map(e.$(i)):n,c=o?n.map(e.$(o)):i,l=r.count(s),u=r.count(c),d=Array();if(l!==u)throw Error("Array lengths must match.");for(a=0;a<l;++a)e.isValid(s[a])&&e.isValid(c[a])&&d.push(s[a]-c[a]);return r.z.test(d,t&&t.nullh||0)}function a(t,i,o,a){var s=a?i.map(e.$(o)):i,c=a?i.map(e.$(a)):o,l=r.count.valid(s),u=r.count.valid(c),d=n.random.normal(0,1),f=r.mean(s)-r.mean(c)-(t&&t.nullh||0),p=Math.sqrt(r.variance(s)/l+r.variance(c)/u);if(0===p)return 0===f?1:0;var h=f/p;return 2*d.cdf(-Math.abs(h))}r.unique=function(t,n,r){n=e.$(n),r=r||[];var i,o,a,s={};for(o=0,a=t.length;o<a;++o)(i=n?n(t[o]):t[o])in s||(s[i]=1,r.push(i));return r},r.count=function(e){return e&&e.length||0},r.count.valid=function(t,n){n=e.$(n);var r,i,o,a=0;for(i=0,o=t.length;i<o;++i)r=n?n(t[i]):t[i],e.isValid(r)&&(a+=1);return a},r.count.missing=function(t,n){n=e.$(n);var r,i,o=0;for(r=0,i=t.length;r<i;++r)null==(n?n(t[r]):t[r])&&(o+=1);return o},r.count.distinct=function(t,n){n=e.$(n);var r,i,o,a={},s=0;for(i=0,o=t.length;i<o;++i)(r=n?n(t[i]):t[i])in a||(a[r]=1,s+=1);return s},r.count.map=function(t,n){n=e.$(n);var r,i,o,a={};for(i=0,o=t.length;i<o;++i)a[r=n?n(t[i]):t[i]]=r in a?a[r]+1:1;return a},r.median=function(t,n){return n&&(t=t.map(e.$(n))),t=t.filter(e.isValid).sort(e.cmp),r.quantile(t,.5)},r.quartile=function(t,n){n&&(t=t.map(e.$(n))),t=t.filter(e.isValid).sort(e.cmp);var i=r.quantile;return[i(t,.25),i(t,.5),i(t,.75)]},r.quantile=function(t,n,r){void 0===r&&(r=n,n=e.identity),n=e.$(n);var i=(t.length-1)*r+1,o=Math.floor(i),a=+n(t[o-1]),s=i-o;return s?a+s*(n(t[o])-a):a},r.sum=function(t,n){n=e.$(n);for(var r,i=0,o=0,a=t.length;o<a;++o)r=n?n(t[o]):t[o],e.isValid(r)&&(i+=r);return i},r.mean=function(t,n){n=e.$(n);var r,i,o,a,s=0;for(r=0,o=0,i=t.length;r<i;++r)a=n?n(t[r]):t[r],e.isValid(a)&&(s+=(a-s)/++o);return s},r.mean.geometric=function(t,n){n=e.$(n);var r,i,o,a,s=1;for(a=0,r=0,i=t.length;a<i;++a)if(o=n?n(t[a]):t[a],e.isValid(o)){if(o<=0)throw Error("Geometric mean only defined for positive values.");s*=o,++r}return s=r>0?Math.pow(s,1/r):0},r.mean.harmonic=function(t,n){n=e.$(n);var r,i,o,a,s=0;for(a=0,r=0,i=t.length;a<i;++a)o=n?n(t[a]):t[a],e.isValid(o)&&(s+=1/o,++r);return r/s},r.variance=function(t,n){if(n=e.$(n),!e.isArray(t)||t.length<2)return 0;var r,i,o,a,s=0,c=0;for(i=0,o=0;i<t.length;++i)a=n?n(t[i]):t[i],e.isValid(a)&&(c+=(r=a-s)*(a-(s+=r/++o)));return c/=o-1},r.stdev=function(e,t){return Math.sqrt(r.variance(e,t))},r.modeskew=function(e,t){var n=r.mean(e,t),i=r.median(e,t),o=r.stdev(e,t);return 0===o?0:(n-i)/o},r.min=function(e,t){return r.extent(e,t)[0]},r.max=function(e,t){return r.extent(e,t)[1]},r.extent=function(t,n){n=e.$(n);var r,i,o,a,s=t.length;for(a=0;a<s;++a)if(o=n?n(t[a]):t[a],e.isValid(o)){r=i=o;break}for(;a<s;++a)o=n?n(t[a]):t[a],e.isValid(o)&&(o<r&&(r=o),o>i&&(i=o));return[r,i]},r.extent.index=function(t,n){n=e.$(n);var r,i,o,a,s=-1,c=-1,l=t.length;for(a=0;a<l;++a)if(o=n?n(t[a]):t[a],e.isValid(o)){r=i=o,s=c=a;break}for(;a<l;++a)o=n?n(t[a]):t[a],e.isValid(o)&&(o<r&&(r=o,s=a),o>i&&(i=o,c=a));return[s,c]},r.dot=function(t,n,r){var i,o,a=0;if(r)for(n=e.$(n),r=e.$(r),i=0;i<t.length;++i)(o=n(t[i])*r(t[i]))==o&&(a+=o);else{if(t.length!==n.length)throw Error("Array lengths must match.");for(i=0;i<t.length;++i)(o=t[i]*n[i])==o&&(a+=o)}return a},r.dist=function(t,n,r,i){var o,a,s=e.isFunction(r)||e.isString(r),c=t,l=s?t:n,u=s?i:r,d=2===u||null==u,f=t.length,p=0;for(s&&(n=e.$(n),r=e.$(r)),a=0;a<f;++a)o=s?n(c[a])-r(l[a]):c[a]-l[a],p+=d?o*o:Math.pow(Math.abs(o),u);return d?Math.sqrt(p):Math.pow(p,1/u)},r.cohensd=function(t,n,i){var o=i?t.map(e.$(n)):t,a=i?t.map(e.$(i)):n,s=r.mean(o),c=r.mean(a),l=r.count.valid(o),u=r.count.valid(a);if(l+u-2<=0)return 0;var d=r.variance(o),f=r.variance(a),p=Math.sqrt(((l-1)*d+(u-1)*f)/(l+u-2));return 0===p?0:(s-c)/p},r.covariance=function(t,n,i){var o,a,s,c,l,u=i?t.map(e.$(n)):t,d=i?t.map(e.$(i)):n,f=u.length,p=r.mean(u),h=r.mean(d),g=0,m=0;if(f!==d.length)throw Error("Input lengths must match.");for(o=0;o<f;++o)if(a=u[o],c=e.isValid(a),s=d[o],l=e.isValid(s),c&&l)g+=(a-p)*(s-h),++m;else if(c||l)throw Error("Valid values must align.");return g/(m-1)},r.rank=function(t,n){n=e.$(n)||e.identity;var r,i,o,a=t.map((function(e,t){return{idx:t,val:n(e)}})).sort(e.comparator("val")),s=t.length,c=Array(s),l=-1,u={};for(r=0;r<s;++r){if(i=a[r].val,l<0&&u===i)l=r-1;else if(l>-1&&u!==i){for(o=1+(r-1+l)/2;l<r;++l)c[a[l].idx]=o;l=-1}c[a[r].idx]=r+1,u=i}if(l>-1)for(o=1+(s-1+l)/2;l<s;++l)c[a[l].idx]=o;return c},r.cor=function(t,n,i){var o=i;i=o?t.map(e.$(i)):n,n=o?t.map(e.$(n)):t;var a=r.dot(n,i),s=r.mean(n),c=r.mean(i),l=r.stdev(n),u=r.stdev(i),d=t.length;return(a-d*s*c)/((d-1)*l*u)},r.cor.rank=function(e,t,n){var i,o,a,s=n?r.rank(e,t):r.rank(e),c=n?r.rank(e,n):r.rank(t),l=e.length;for(i=0,o=0;i<l;++i)o+=(a=s[i]-c[i])*a;return 1-6*o/(l*(l*l-1))},r.cor.dist=function(t,n,i){var o,a,s,c,l=i?t.map(e.$(n)):t,u=i?t.map(e.$(i)):n,d=r.dist.mat(l),f=r.dist.mat(u),p=d.length;for(o=0,a=0,s=0,c=0;o<p;++o)a+=d[o]*d[o],s+=f[o]*f[o],c+=d[o]*f[o];return Math.sqrt(c/Math.sqrt(a*s))},r.linearRegression=function(t,n,i){var o,a,s=i?t.map(e.$(n)):t,c=i?t.map(e.$(i)):n,l=s.length,u=r.covariance(s,c),d=r.stdev(s),f=r.stdev(c),p=u/(d*d),h=r.mean(c)-p*r.mean(s),g={slope:p,intercept:h,R:u/(d*f),rss:0};for(a=0;a<l;++a)e.isValid(s[a])&&e.isValid(c[a])&&(o=p*s[a]+h-c[a],g.rss+=o*o);return g},r.bootstrap={},r.bootstrap.ci=function(t,i,o,a,s){var c,l,u,d,f,p,h;for(e.isFunction(i)||e.isString(i)?(c=t.map(e.$(i)),l=o,u=a,d=s):(c=t,l=i,u=o,d=a),l=l?+l:1e3,u=u||.05,f=n.random.bootstrap(c,d),h=0,p=Array(l);h<l;++h)p[h]=r.mean(f.samples(c.length));return p.sort(e.numcmp),[r.quantile(p,u/2),r.quantile(p,1-u/2)]},r.z={},r.z.ci=function(t,i,o){var a=t,s=i;(e.isFunction(i)||e.isString(i))&&(a=t.map(e.$(i)),s=o);var c=.05===(s=s||.05)?1.96:n.random.normal(0,1).icdf(1-s/2),l=r.mean(a),u=r.stdev(a)/Math.sqrt(r.count.valid(a));return[l-c*u,l+c*u]},r.z.test=function(t,n,r,s){return e.isFunction(r)||e.isString(r)?(s&&s.paired?o:a)(s,t,n,r):e.isArray(n)?(r&&r.paired?o:a)(r,t,n):e.isFunction(n)||e.isString(n)?i(r,t,n):i(n,t)},r.dist.mat=function(e){var t,r,i,o=e.length,a=o*o,s=Array(a),c=n.zeros(o),l=0;for(r=0;r<o;++r)for(s[r*o+r]=0,i=r+1;i<o;++i)s[r*o+i]=t=Math.abs(e[r]-e[i]),s[i*o+r]=t,c[r]+=t,c[i]+=t;for(r=0;r<o;++r)l+=c[r],c[r]/=o;for(l/=a,r=0;r<o;++r)for(i=r;i<o;++i)s[r*o+i]+=l-c[r]-c[i],s[i*o+r]=s[r*o+i];return s},r.entropy=function(t,n){n=e.$(n);var r,i,o=0,a=0,s=t.length;for(r=0;r<s;++r)o+=n?n(t[r]):t[r];if(0===o)return 0;for(r=0;r<s;++r)(i=(n?n(t[r]):t[r])/o)&&(a+=i*Math.log(i));return-a/Math.LN2},r.mutual=function(t,n,r,i){var o,a,s,c=i?t.map(e.$(n)):t,l=i?t.map(e.$(r)):n,u=i?t.map(e.$(i)):r,d={},f={},p=u.length,h=0,g=0,m=0;for(s=0;s<p;++s)d[c[s]]=0,f[l[s]]=0;for(s=0;s<p;++s)d[c[s]]+=u[s],f[l[s]]+=u[s],h+=u[s];for(a=1/(h*Math.LN2),s=0;s<p;++s)0!==u[s]&&(o=h*u[s]/(d[c[s]]*f[l[s]]),g+=u[s]*a*Math.log(o),m+=u[s]*a*Math.log(u[s]/h));return[g,1+g/m]},r.mutual.info=function(e,t,n,i){return r.mutual(e,t,n,i)[0]},r.mutual.dist=function(e,t,n,i){return r.mutual(e,t,n,i)[1]},r.profile=function(n,i){var o,a,s,c,l,u=0,d=0,f=0,p=0,h=null,g=null,m=0,y=[],v={};for(s=0;s<n.length;++s)v[c=i?i(n[s]):n[s]]=c in v?v[c]+1:(p+=1,1),null==c?++f:e.isValid(c)&&(l="string"==typeof c?c.length:c,(null===h||l<h)&&(h=l),(null===g||l>g)&&(g=l),m+=(o=l-u)*(l-(u+=o/++d)),y.push(l));return m/=d-1,a=Math.sqrt(m),y.sort(e.cmp),{type:t(n,i),unique:v,count:n.length,valid:d,missing:f,distinct:p,min:h,max:g,mean:u,stdev:a,median:c=r.quantile(y,.5),q1:r.quantile(y,.25),q3:r.quantile(y,.75),modeskew:0===a?0:(u-c)/a}},r.summary=function(t,n){var i=(n=n||e.keys(t[0])).map((function(n){var i=r.profile(t,e.$(n));return i.field=n,i}));return i.__summary__=!0,i}}();var No=Eo.exports;const wo=co;const Co={nominal:0,key:1,ordinal:2,temporal:3,quantitative:4};class Ao{constructor(e){this._tableSchema=e,e.fields.sort((function(e,t){return Co[e.vlType]<Co[t.vlType]?-1:Co[e.vlType]>Co[t.vlType]?1:e.name.localeCompare(t.name)})),e.fields.forEach(((e,t)=>e.index=t)),this._fieldSchemaIndex=e.fields.reduce(((e,t)=>(e[t.name]=t,e)),{})}fieldNames(){return this._tableSchema.fields.map((e=>e.name))}get fieldSchemas(){return this._tableSchema.fields}fieldSchema(e){return this._fieldSchemaIndex[e]}tableSchema(){const e=It.duplicate(this._tableSchema);return e.fields.sort(((e,t)=>e.originalIndex-t.originalIndex)),e}primitiveType(e){return this._fieldSchemaIndex[e]?this._fieldSchemaIndex[e].type:null}vlType(e){return this._fieldSchemaIndex[e]?this._fieldSchemaIndex[e].vlType:null}cardinality(e,t=!0,n=!1){const r=this._fieldSchemaIndex[e.field];if(e.aggregate||Sr(e)&&e.autoCount)return 1;if(e.bin){let t;t="boolean"==typeof e.bin?{maxbins:Hn(e.channel)}:"?"===e.bin?{enum:[!0,!1]}:e.bin;const n=t.maxbins;return r.binStats[n]||(r.binStats[n]=Oo(n,r.stats)),r.binStats[n].distinct}if(e.timeUnit){if(t)switch(e.timeUnit){case gn.SECONDS:case gn.MINUTES:return 60;case gn.HOURS:return 24;case gn.DAY:return 7;case gn.DATE:return 31;case gn.MONTH:return 12;case gn.QUARTER:return 4;case gn.MILLISECONDS:return 1e3}let i=e.timeUnit,o=r.timeStats;return o&&o[i]||(o=Object.assign({},o,{[i]:ko(e.timeUnit,r.stats)})),n?o[i].distinct-Mo(o[i].unique,["Invalid Date",null]):o[i].distinct}return r?n?r.stats.distinct-Mo(r.stats.unique,[NaN,null]):r.stats.distinct:null}timeUnitHasVariation(e){if(!e.timeUnit)return;if(e.timeUnit===gn.DAY){const t=It.extend({},e,{timeUnit:gn.DATE});if(this.cardinality(t,!1,!0)<=1)return!1}let t=e.timeUnit;for(let n of vn)if(Cn(t,n)){const t=It.extend({},e,{timeUnit:n});if(this.cardinality(t,!1,!0)<=1)return!1}return!0}domain(e){const t=this._fieldSchemaIndex[e.field];let n=It.keys(t.stats.unique);return t.vlType===lt?[+t.stats.min,+t.stats.max]:t.type===Io.DATETIME?[t.stats.min,t.stats.max]:t.type===Io.INTEGER||t.type===Io.NUMBER?(n=n.map((e=>+e)),n.sort(It.cmp)):t.vlType===ut&&t.ordinalDomain?t.ordinalDomain:n.map((e=>"null"===e?null:e)).sort(It.cmp)}stats(e){const t=this._fieldSchemaIndex[e.field];return t?t.stats:null}}function Oo(e,t){const n=wo({min:t.min,max:t.max,maxbins:e}),r=It.extend({},t);return r.unique=function(e,t){const n={};for(let r in t){let i;i=null===r?null:isNaN(Number(r))?NaN:e.value(Number(r)),n[i]=(n[i]||0)+t[r]}return n}(n,t.unique),r.distinct=(n.stop-n.start)/n.step,r.min=n.start,r.max=n.stop,r}function ko(e,t){const n=It.extend({},t);let r={};return It.keys(t.unique).forEach((function(n){let i,o="null"===n?null:new Date(n);i=null===o?null:isNaN(o.getTime())?"Invalid Date":(e===gn.DAY?o.getDay():Nn(e,o)).toString(),r[i]=(r[i]||0)+t.unique[n]})),n.unique=r,n.distinct=It.keys(r).length,n}function Mo(e,t){return t.reduce((function(t,n){return e[n]?t+1:t}),0)}var Io,Uo;(Uo=Io||(Io={}))[Uo.STRING="string"]="STRING",Uo[Uo.NUMBER="number"]="NUMBER",Uo[Uo.INTEGER="integer"]="INTEGER",Uo[Uo.BOOLEAN="boolean"]="BOOLEAN",Uo[Uo.DATETIME="datetime"]="DATETIME";class Fo{constructor(e){this.constraint=e}name(){return this.constraint.name}description(){return this.constraint.description}properties(){return this.constraint.properties}strict(){return this.constraint.strict}}class Do extends Fo{constructor(e){super(e)}hasAllRequiredPropertiesSpecific(e){return Ft(this.constraint.properties,(t=>{if(jt(t)){let n=t.parent,r=t.child;return!e[n]||!On(e[n][r])}return!e[t]||!On(e[t])}))}satisfy(e,t,n,r){return!this.constraint.allowWildcardForProperties&&!this.hasAllRequiredPropertiesSpecific(e)||this.constraint.satisfy(e,t,n,r)}}const _o=[{name:"aggregateOpSupportedByType",description:"Aggregate function should be supported by data type.",properties:[tn.TYPE,tn.AGGREGATE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!e.aggregate||!tr(e.type)},{name:"asteriskFieldWithCountOnly",description:'Field="*" should be disallowed except aggregate="count"',properties:[tn.FIELD,tn.AGGREGATE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>"*"===e.field==("count"===e.aggregate)},{name:"minCardinalityForBin",description:"binned quantitative field should not have too low cardinality",properties:[tn.BIN,tn.FIELD,tn.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>{if(e.bin&&e.type===lt){let n={channel:e.channel,field:e.field,type:e.type};return t.cardinality(n)>=r.minCardinalityForBin}return!0}},{name:"binAppliedForQuantitative",description:"bin should be applied to quantitative field only.",properties:[tn.TYPE,tn.BIN],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!e.bin||e.type===lt},{name:"channelFieldCompatible",description:"encoding channel's range type be compatible with channel type.",properties:[tn.CHANNEL,tn.TYPE,tn.BIN,tn.TIMEUNIT],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>{const i=Object.assign({field:"f"},kr(e,{schema:t,props:["bin","timeUnit","type"]})),{compatible:o}=Jn(i,e.channel);if(o)return!0;return!("row"!==e.channel&&"column"!==e.channel||(a=i.timeUnit,!yn[a]&&!function(e){return!!bn[e]}(i.timeUnit)));var a}},{name:"hasFn",description:"A field with as hasFn flag should have one of aggregate, timeUnit, or bin.",properties:[tn.AGGREGATE,tn.BIN,tn.TIMEUNIT],allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n,r)=>!e.hasFn||(!!e.aggregate||!!e.bin||!!e.timeUnit)},{name:"omitScaleZeroWithBinnedField",description:"Do not use scale zero with binned field",properties:[tn.SCALE,Jt("scale","zero"),tn.BIN],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!e.bin||!e.scale||!0!==e.scale.zero},{name:"onlyOneTypeOfFunction",description:"Only of of aggregate, autoCount, timeUnit, or bin should be applied at the same time.",properties:[tn.AGGREGATE,tn.AUTOCOUNT,tn.TIMEUNIT,tn.BIN],allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n,r)=>{if(Tr(e)){return(!On(e.aggregate)&&e.aggregate?1:0)+(!On(e.bin)&&e.bin?1:0)+(!On(e.timeUnit)&&e.timeUnit?1:0)<=1}return!0}},{name:"timeUnitAppliedForTemporal",description:"Time unit should be applied to temporal field only.",properties:[tn.TYPE,tn.TIMEUNIT],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!e.timeUnit||e.type===dt},{name:"timeUnitShouldHaveVariation",description:"A particular time unit should be applied only if they produce unique values.",properties:[tn.TIMEUNIT,tn.TYPE],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n,r)=>!e.timeUnit||e.type!==dt||(!n.has("timeUnit")&&!r.constraintManuallySpecifiedValue||t.timeUnitHasVariation(e))},{name:"scalePropertiesSupportedByScaleType",description:"Scale properties must be supported by correct scale type",properties:[].concat(Ht,[tn.SCALE,tn.TYPE]),allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n,r)=>{if(e.scale){const t=e.scale,n=Ur(e);if(null==n)return!0;for(let e in t){if("type"===e||"name"===e||"enum"===e)continue;const t=e;if("point"===n){if(!wt("point",t)&&!wt("band",t))return!1}else if(!wt(n,t))return!1}}return!0}},{name:"scalePropertiesSupportedByChannel",description:"Not all scale properties are supported by all encoding channels",properties:[].concat(Ht,[tn.SCALE,tn.CHANNEL]),allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n,r)=>{if(e){let t=e.channel,n=e.scale;if(t&&!On(t)&&n){if("row"===t||"column"===t)return!1;for(let e in n){if(!n.hasOwnProperty(e))continue;if("type"===e||"name"===e||"enum"===e)continue;if(!(void 0===Ct(t,e)))return!1}}}return!0}},{name:"typeMatchesPrimitiveType",description:"Data type should be supported by field's primitive type.",properties:[tn.FIELD,tn.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>{if("*"===e.field)return!0;const i=t.primitiveType(e.field),o=e.type;if(!n.has("field")&&!n.has("type")&&!r.constraintManuallySpecifiedValue)return!0;switch(i){case Io.BOOLEAN:case Io.STRING:return o!==lt&&o!==dt;case Io.NUMBER:case Io.INTEGER:return o!==dt;case Io.DATETIME:return o===dt;case null:return!1}throw new Error("Not implemented")}},{name:"typeMatchesSchemaType",description:"Enumerated data type of a field should match the field's type in the schema.",properties:[tn.FIELD,tn.TYPE],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n,r)=>!(n.has("field")||n.has("type")||r.constraintManuallySpecifiedValue)||("*"===e.field?e.type===lt:t.vlType(e.field)===e.type)},{name:"maxCardinalityForCategoricalColor",description:"Categorical channel should not have too high cardinality",properties:[tn.CHANNEL,tn.FIELD],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n,r)=>e.channel!==we||e.type!==ft&&e.type!==Zn.KEY||t.cardinality(e)<=r.maxCardinalityForCategoricalColor},{name:"maxCardinalityForFacet",description:"Row/column channel should not have too high cardinality",properties:[tn.CHANNEL,tn.FIELD,tn.BIN,tn.TIMEUNIT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n,r)=>e.channel!==he&&e.channel!==ge||t.cardinality(e)<=r.maxCardinalityForFacet},{name:"maxCardinalityForShape",description:"Shape channel should not have too high cardinality",properties:[tn.CHANNEL,tn.FIELD,tn.BIN,tn.TIMEUNIT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n,r)=>e.channel!==Oe||t.cardinality(e)<=r.maxCardinalityForShape},{name:"dataTypeAndFunctionMatchScaleType",description:"Scale type must match data type",properties:[tn.TYPE,tn.SCALE,Jt("scale","type"),tn.TIMEUNIT,tn.BIN],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>{if(e.scale){const t=e.type,n=Ur(e);if(tr(t))return void 0===n||Et(n);if(t===dt)return e.timeUnit?Ut([pt.TIME,pt.UTC,void 0],n)||Et(n):Ut([pt.TIME,pt.UTC,void 0],n);if(t===lt)return e.bin?Ut([pt.LINEAR,void 0],n):Ut([pt.LOG,pt.POW,pt.SQRT,pt.QUANTILE,pt.QUANTIZE,pt.LINEAR,void 0],n)}return!0}},{name:"stackIsOnlyUsedWithXY",description:"stack should only be allowed for x and y channels",properties:[tn.STACK,tn.CHANNEL],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!e.stack||(e.channel===ye||e.channel===ve)}].map((e=>new Do(e)));_o.reduce(((e,t)=>(e[t.name()]=t,e)),{});const jo=_o.reduce(((e,t)=>{for(const n of t.properties())e.set(n,e.get(n)||[]),e.get(n).push(t);return e}),new nr),Po=[{name:"doesNotSupportConstantValue",description:"row, column, x, y, order, and detail should not work with constant values.",properties:[tn.TYPE,tn.AGGREGATE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!Ut(["row","column","x","y","detail","order"],e.channel)}].map((e=>new Do(e)));Po.reduce(((e,t)=>(e[t.name()]=t,e)),{});const Ro=Po.reduce(((e,t)=>{for(const n of t.properties())e.set(n,e.get(n)||[]),e.get(n).push(t);return e}),new nr);const $o=Ge.reduce(((e,t)=>(e[t]=!0,e)),{});class Bo extends Fo{constructor(e){super(e)}hasAllRequiredPropertiesSpecific(e){return Ft(this.constraint.properties,(t=>{if(t===tn.MARK)return!On(e.getMark());if(jt(t)){let n=t.parent,r=t.child;return Ft(e.getEncodings(),(e=>!e[n]||!On(e[n][r])))}if(!Xt(t))throw new Error("UNIMPLEMENTED");return Ft(e.getEncodings(),(e=>!e[t]||!On(e[t])))}))}satisfy(e,t,n){return!this.constraint.allowWildcardForProperties&&!this.hasAllRequiredPropertiesSpecific(e)||this.constraint.satisfy(e,t,n)}}const Lo=[{name:"noRepeatedChannel",description:"Each encoding channel should only be used once.",properties:[tn.CHANNEL],allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n)=>{let r={};return Ft(e.getEncodings(),(e=>!!On(e.channel)||!r[e.channel]&&(r[e.channel]=!0,!0)))}},{name:"alwaysIncludeZeroInScaleWithBarMark",description:"Do not recommend bar mark if scale does not start at zero",properties:[tn.MARK,tn.SCALE,Jt("scale","zero"),tn.CHANNEL,tn.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>{const r=e.getMark(),i=e.getEncodings();if(r===on)for(let o of i)if(Tr(o)&&(o.channel===ye||o.channel===ve)&&o.type===lt&&o.scale&&!1===o.scale.zero)return!1;return!0}},{name:"autoAddCount",description:"Automatically adding count only for plots with only ordinal, binned quantitative, or temporal with timeunit fields.",properties:[tn.BIN,tn.TIMEUNIT,tn.TYPE,tn.AUTOCOUNT],allowWildcardForProperties:!0,strict:!1,satisfy:(e,t,n)=>{if(_t(e.getEncodings(),(e=>wr(e))))return Ft(e.getEncodings(),(e=>{if(Er(e))return!0;if(Sr(e))return!0;switch(e.type){case lt:return!!e.bin;case dt:return!!e.timeUnit;case ut:case Zn.KEY:case ft:return!0}throw new Error("Unsupported Type")}));if(Ft(e.wildcardIndex.encodingIndicesByProperty.get("autoCount")||[],(t=>{let n=e.getEncodingQueryByIndex(t);return Sr(n)&&!On(n.autoCount)})))return _t(e.getEncodings(),(e=>(Tr(e)||Sr(e))&&e.type===lt?!Nr(e)&&(Tr(e)&&(!e.bin||On(e.bin))):!(!Tr(e)||e.type!==dt)&&(!e.timeUnit||On(e.timeUnit))));return!0}},{name:"channelPermittedByMarkType",description:"Each encoding channel should be supported by the mark type",properties:[tn.CHANNEL,tn.MARK],allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n)=>{const r=e.getMark();return!!On(r)||Ft(e.getEncodings(),(e=>!!On(e.channel)||!!Qe(e.channel,r)))}},{name:"hasAllRequiredChannelsForMark",description:"All required channels for the specified mark should be specified",properties:[tn.CHANNEL,tn.MARK],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>{const r=e.getMark();switch(r){case rn:case an:return e.channelUsed(ye)&&e.channelUsed(ve);case un:return e.channelUsed(De);case on:case fn:case pn:case dn:case ln:case cn:return e.channelUsed(ye)||e.channelUsed(ve);case sn:return!e.wildcardIndex.hasProperty(tn.CHANNEL)||e.channelUsed(ye)||e.channelUsed(ve)}throw new Error("hasAllRequiredChannelsForMark not implemented for mark"+JSON.stringify(r))}},{name:"omitAggregate",description:"Omit aggregate plots.",properties:[tn.AGGREGATE,tn.AUTOCOUNT],allowWildcardForProperties:!0,strict:!1,satisfy:(e,t,n)=>!e.isAggregate()},{name:"omitAggregatePlotWithDimensionOnlyOnFacet",description:"Omit aggregate plots with dimensions only on facets as that leads to inefficient use of space.",properties:[tn.CHANNEL,tn.AGGREGATE,tn.AUTOCOUNT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>{if(e.isAggregate()){let t=!1,r=!1,i=!1;if(e.specQuery.encodings.forEach(((n,o)=>{Er(n)||Nr(n)||Tr(n)&&!n.aggregate&&(r=!0,Ut([he,ge],n.channel)?e.wildcardIndex.hasEncodingProperty(o,tn.CHANNEL)&&(i=!0):t=!0)})),r&&!t&&(i||n.constraintManuallySpecifiedValue))return!1}return!0}},{name:"omitAggregatePlotWithoutDimension",description:"Aggregate plots without dimension should be omitted",properties:[tn.AGGREGATE,tn.AUTOCOUNT,tn.BIN,tn.TIMEUNIT,tn.TYPE],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>!e.isAggregate()||_t(e.getEncodings(),(e=>!!(Ir(e)||Tr(e)&&"temporal"===e.type)))},{name:"omitBarLineAreaWithOcclusion",description:"Don't use bar, line or area to visualize raw plot as they often lead to occlusion.",properties:[tn.MARK,tn.AGGREGATE,tn.AUTOCOUNT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>!Ut([on,an,rn],e.getMark())||e.isAggregate()},{name:"omitBarTickWithSize",description:"Do not map field to size channel with bar and tick mark",properties:[tn.CHANNEL,tn.MARK],allowWildcardForProperties:!0,strict:!1,satisfy:(e,t,n)=>{const r=e.getMark();if(Ut([dn,on],r)&&e.channelEncodingField(ke)){if(n.constraintManuallySpecifiedValue)return!1;{const t=e.specQuery.encodings;for(let n=0;n<t.length;n++){if(t[n].channel===ke)return!e.wildcardIndex.hasEncodingProperty(n,tn.CHANNEL)}}}return!0}},{name:"omitBarAreaForLogScale",description:"Do not use bar and area mark for x and y's log scale",properties:[tn.MARK,tn.CHANNEL,tn.SCALE,Jt("scale","type"),tn.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>{const r=e.getMark(),i=e.getEncodings();if(r===rn||r===on)for(let o of i)if(Tr(o)&&(o.channel===ye||o.channel===ve)&&o.scale){if(Ur(o)===pt.LOG)return!1}return!0}},{name:"omitMultipleNonPositionalChannels",description:"Unless manually specified, do not use multiple non-positional encoding channel to avoid over-encoding.",properties:[tn.CHANNEL],allowWildcardForProperties:!0,strict:!1,satisfy:(e,t,n)=>{const r=e.specQuery.encodings;let i=0,o=!1;for(let a=0;a<r.length;a++){const t=r[a];if(Er(t)||Nr(t))continue;const s=t.channel;if(!On(s)&&$o[s+""]&&(i+=1,e.wildcardIndex.hasEncodingProperty(a,tn.CHANNEL)&&(o=!0),i>1&&(o||n.constraintManuallySpecifiedValue)))return!1}return!0}},{name:"omitNonPositionalOrFacetOverPositionalChannels",description:"Do not use non-positional channels unless all positional channels are used",properties:[tn.CHANNEL],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>{const r=e.specQuery.encodings;let i=!1,o=!1,a=!1,s=!1;for(let c=0;c<r.length;c++){const t=r[c];if(Er(t)||Nr(t))continue;const n=t.channel;n===ye?a=!0:n===ve?s=!0:On(n)||(i=!0,e.wildcardIndex.hasEncodingProperty(c,tn.CHANNEL)&&(o=!0))}return!(o||n.constraintManuallySpecifiedValue&&i)||a&&s}},{name:"omitRaw",description:"Omit raw plots.",properties:[tn.AGGREGATE,tn.AUTOCOUNT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>!!e.isAggregate()},{name:"omitRawContinuousFieldForAggregatePlot",description:"Aggregate plot should not use raw continuous field as group by values. (Quantitative should be binned. Temporal should have time unit.)",properties:[tn.AGGREGATE,tn.AUTOCOUNT,tn.TIMEUNIT,tn.BIN,tn.TYPE],allowWildcardForProperties:!0,strict:!1,satisfy:(e,t,n)=>{if(e.isAggregate()){const t=e.specQuery.encodings;for(let r=0;r<t.length;r++){const i=t[r];if(!Er(i)&&!Nr(i)){if(Tr(i)&&i.type===dt&&!i.timeUnit&&(e.wildcardIndex.hasEncodingProperty(r,tn.TIMEUNIT)||n.constraintManuallySpecifiedValue))return!1;if(i.type===lt&&Tr(i)&&!i.bin&&!i.aggregate){if(e.wildcardIndex.hasEncodingProperty(r,tn.BIN)||e.wildcardIndex.hasEncodingProperty(r,tn.AGGREGATE)||e.wildcardIndex.hasEncodingProperty(r,tn.AUTOCOUNT))return!1;if(n.constraintManuallySpecifiedValue)return!1}}}}return!0}},{name:"omitRawDetail",description:"Do not use detail channel with raw plot.",properties:[tn.CHANNEL,tn.AGGREGATE,tn.AUTOCOUNT],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>!!e.isAggregate()||Ft(e.specQuery.encodings,((t,r)=>!(!Er(t)&&!Nr(t))||(t.channel!==je||!e.wildcardIndex.hasEncodingProperty(r,tn.CHANNEL)&&!n.constraintManuallySpecifiedValue)))},{name:"omitRepeatedField",description:"Each field should be mapped to only one channel",properties:[tn.FIELD],allowWildcardForProperties:!0,strict:!1,satisfy:(e,t,n)=>{let r={},i={};const o=e.specQuery.encodings;for(let a=0;a<o.length;a++){const t=o[a];if(Er(t)||Sr(t))continue;let s;if(t.field&&!On(t.field)&&(s=t.field),Sr(t)&&!On(t.autoCount)&&(s="count_*"),s){if(e.wildcardIndex.hasEncodingProperty(a,tn.FIELD)&&(i[s]=!0),r[s]&&(i[s]||n.constraintManuallySpecifiedValue))return!1;r[s]=!0}}return!0}},{name:"omitVerticalDotPlot",description:"Do not output vertical dot plot.",properties:[tn.CHANNEL],allowWildcardForProperties:!0,strict:!1,satisfy:(e,t,n)=>{const r=e.getEncodings();return 1!==r.length||r[0].channel!==ve}},{name:"hasAppropriateGraphicTypeForMark",description:"Has appropriate graphic type for mark",properties:[tn.CHANNEL,tn.MARK,tn.TYPE,tn.TIMEUNIT,tn.BIN,tn.AGGREGATE,tn.AUTOCOUNT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>{const r=e.getMark();switch(r){case rn:case an:if(e.isAggregate()){const t=e.getEncodingQueryByChannel(ye),n=e.getEncodingQueryByChannel(ve),r=Mr(t),i=Mr(n);return t&&n&&r!==i&&!(Tr(t)&&!r&&Ut(["nominal","key"],t.type))&&!(Tr(n)&&!i&&Ut(["nominal","key"],n.type))}return!0;case un:return!0;case on:case dn:if(e.channelEncodingField(ke))return!1;{const t=e.getEncodingQueryByChannel(ye),n=e.getEncodingQueryByChannel(ve);return Mr(t)!==Mr(n)}case cn:const t=e.getEncodingQueryByChannel(ye),n=e.getEncodingQueryByChannel(ve),r=Ir(t),i=Ir(n),o=e.getEncodingQueryByChannel(we),a=Mr(o),s=!!Tr(o)&&o.type===ut;return(r&&i||r&&!e.channelUsed(ve)||i&&!e.channelUsed(ye))&&(!o||o&&(a||s));case fn:case sn:case pn:case ln:return!0}throw new Error("hasAllRequiredChannelsForMark not implemented for mark"+r)}},{name:"omitInvalidStackSpec",description:"If stack is specified, must follow Vega-Lite stack rules",properties:[tn.STACK,tn.FIELD,tn.CHANNEL,tn.MARK,tn.AGGREGATE,tn.AUTOCOUNT,tn.SCALE,Jt("scale","type"),tn.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>{if(!e.wildcardIndex.hasProperty(tn.STACK))return!0;const r=e.getVlStack();return(null!==r||null===e.getStackOffset())&&r.fieldChannel===e.getStackChannel()}},{name:"omitNonSumStack",description:"Stack specifications that use non-summative aggregates should be omitted (even implicit ones)",properties:[tn.CHANNEL,tn.MARK,tn.AGGREGATE,tn.AUTOCOUNT,tn.SCALE,Jt("scale","type"),tn.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>{const r=e.getVlStack();if(null!=r){const t=e.getEncodingQueryByChannel(r.fieldChannel);if(!Ut(Ln,t.aggregate))return!1}return!0}},{name:"omitTableWithOcclusionIfAutoAddCount",description:"Plots without aggregation or autocount where x and y are both discrete should be omitted if autoAddCount is enabled as they often lead to occlusion",properties:[tn.CHANNEL,tn.TYPE,tn.TIMEUNIT,tn.BIN,tn.AGGREGATE,tn.AUTOCOUNT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>{if(n.autoAddCount){const t=e.getEncodingQueryByChannel("x"),n=e.getEncodingQueryByChannel("y");if((!Tr(t)||Ir(t))&&(!Tr(n)||Ir(n)))return!!e.isAggregate()&&Ft(e.getEncodings(),(e=>{let t=e.channel;return!(t!==ye&&t!==ve&&t!==he&&t!==ge&&Tr(e)&&!e.aggregate)}))}return!0}}].map((e=>new Bo(e)));Lo.reduce(((e,t)=>(e[t.name()]=t,e)),{});const Wo=Lo.reduce(((e,t)=>{for(const n of t.properties())e.set(n,e.get(n)||[]),e.get(n).push(t);return e}),new nr);function qo(e,t,n,r,i){const o=Wo.get(e)||[];for(const a of o)if(a.strict()||i[a.name()]){if(!a.satisfy(n,r,i)){let e="(spec) "+a.name();return i.verbose&&console.log(e+" failed with "+n.toShorthand()+" for "+t.name),e}}return null}const Ho=new nr;function Go(e){return(t,n,r)=>(i,o)=>{const a=t.encodingIndicesByProperty.get(e);return function s(c){if(c===a.length)return void i.push(o.duplicate());const l=a[c],u=t.encodings[l].get(e),d=o.getEncodingQueryByIndex(l),f=o.getEncodingProperty(l,e);Er(d)||Nr(d)||!f?s(c+1):(u.enum.forEach((t=>{null===t&&(t=void 0),o.setEncodingProperty(l,e,t,u);const i=function(e,t,n,r,i,o){const a=jo.get(e)||[],s=r.getEncodingQueryByIndex(n);for(const l of a)if((l.strict()||o[l.name()])&&!l.satisfy(s,i,r.wildcardIndex.encodings[n],o)){let e="(enc) "+l.name();return o.verbose&&console.log(e+" failed with "+r.toShorthand()+" for "+t.name),e}const c=Ro.get(e)||[];for(const l of c)if((l.strict()||o[l.name()])&&Er(s)&&!l.satisfy(s,i,r.wildcardIndex.encodings[n],o)){let e="(enc) "+l.name();return o.verbose&&console.log(e+" failed with "+r.toShorthand()+" for "+t.name),e}return null}(e,u,l,o,n,r);if(i)return;qo(e,u,o,n,r)||s(c+1)})),o.resetEncodingProperty(l,e,u))}(0),i}}function zo(e,t,n){return t=t||new nr,n=n||new nr,e.forEach((e=>{var r;r=e,It.isObject(r)&&r.property?(t.setByKey(e.property,!0),n.setByKey(e.property,e.replace)):t.setByKey(e,!0)})),{include:t,replaceIndex:n,replacer:ur(n)}}Ho.set("mark",((e,t,n)=>(r,i)=>(i.getMark().enum.forEach((o=>{i.setMark(o);qo("mark",e.mark,i,t,n)||r.push(i.duplicate())})),i.resetMark(),r))),Rt.forEach((e=>{Ho.set(e,Go(e))})),Yt.forEach((e=>{Ho.set(e,Go(e))}));const Yo=[tn.FIELD,tn.TYPE,tn.AGGREGATE,tn.BIN,tn.TIMEUNIT,tn.STACK],Qo=Yo.concat([{property:tn.CHANNEL,replace:{x:"xy",y:"xy",color:"style",size:"style",shape:"style",opacity:"style",row:"facet",column:"facet"}}]);let Vo={};function Ko(e,t){Vo[e]=t}const Jo=zo([tn.FIELD]);Ko("field",(e=>mr(e,Jo.include,Jo.replacer)));const Xo=zo(Yo);Ko("fieldTransform",(e=>mr(e,Xo.include,Xo.replacer)));const Zo=zo(Qo);Ko("encoding",(e=>mr(e,Zo.include,Zo.replacer))),Ko("spec",(e=>JSON.stringify(e)));class ea{constructor(){this._mark=void 0,this._encodings={},this._encodingIndicesByProperty=new nr}setEncodingProperty(e,t,n){const r=this._encodings;(r[e]=r[e]||new nr).set(t,n);const i=this._encodingIndicesByProperty;return i.set(t,i.get(t)||[]),i.get(t).push(e),this}hasEncodingProperty(e,t){return!!this._encodings[e]&&this._encodings[e].has(t)}hasProperty(e){if(Xt(e))return this.encodingIndicesByProperty.has(e);if("mark"===e)return!!this.mark;throw new Error("Unimplemented for property "+e)}isEmpty(){return!this.mark&&0===this.encodingIndicesByProperty.size()}setMark(e){return this._mark=e,this}get mark(){return this._mark}get encodings(){return this._encodings}get encodingIndicesByProperty(){return this._encodingIndicesByProperty}}class ta{constructor(e,t,n,r,i){this._rankingScore={},this._spec=e,this._channelFieldCount=e.encodings.reduce(((e,t)=>(On(t.channel)||Sr(t)&&!1===t.autoCount||(e[t.channel+""]=1),e)),{}),this._wildcardIndex=t,this._assignedWildcardIndex=i,this._opt=r,this._schema=n}static build(e,t,n){let r=new ea;if(On(e.mark)){const t=Fn(tn.MARK);e.mark=Mn(e.mark,t,n.enum.mark),r.setMark(e.mark)}if(e.encodings.forEach(((e,i)=>{Sr(e)&&(console.warn("A field with autoCount should not be included as autoCount meant to be an internal object."),e.type=lt),Tr(e)&&void 0===e.type&&(e.type=An),Rt.forEach((o=>{if(On(e[o])){const a=Fn(o)+i,s=Rn(o,t,n),c=e[o]=Mn(e[o],a,s);r.setEncodingProperty(i,o,c)}})),Yt.forEach((o=>{const a=e[o.parent];if(a){const e=o.child;if(On(a[e])){const s=Fn(o)+i,c=Rn(o,t,n),l=a[e]=Mn(a[e],s,c);r.setEncodingProperty(i,o,l)}}}))})),n.autoAddCount){const i={name:Fn(tn.CHANNEL)+e.encodings.length,enum:Rn(tn.CHANNEL,t,n)},o={name:Fn(tn.AUTOCOUNT)+e.encodings.length,enum:[!1,!0]},a={channel:i,autoCount:o,type:lt};e.encodings.push(a);const s=e.encodings.length-1;r.setEncodingProperty(s,tn.CHANNEL,i),r.setEncodingProperty(s,tn.AUTOCOUNT,o)}return new ta(e,r,t,n,{})}get wildcardIndex(){return this._wildcardIndex}get schema(){return this._schema}get specQuery(){return this._spec}duplicate(){return new ta(It.duplicate(this._spec),this._wildcardIndex,this._schema,this._opt,It.duplicate(this._assignedWildcardIndex))}setMark(e){const t=this._wildcardIndex.mark.name;this._assignedWildcardIndex[t]=this._spec.mark=e}resetMark(){const e=this._spec.mark=this._wildcardIndex.mark;delete this._assignedWildcardIndex[e.name]}getMark(){return this._spec.mark}getEncodingProperty(e,t){const n=this._spec.encodings[e];return jt(t)?n[t.parent][t.child]:n[t]}setEncodingProperty(e,t,n,r){const i=this._spec.encodings[e];t===tn.CHANNEL&&i.channel&&!On(i.channel)&&this._channelFieldCount[i.channel]--,jt(t)?i[t.parent][t.child]=n:Lt(t)&&!0===n?i[t]=It.extend({},i[t],{enum:void 0,name:void 0}):i[t]=n,this._assignedWildcardIndex[r.name]=n,t===tn.CHANNEL&&(this._channelFieldCount[n]=(this._channelFieldCount[n]||0)+1)}resetEncodingProperty(e,t,n){const r=this._spec.encodings[e];t===tn.CHANNEL&&this._channelFieldCount[r.channel]--,jt(t)?r[t.parent][t.child]=n:r[t]=n,delete this._assignedWildcardIndex[n.name]}channelUsed(e){return this._channelFieldCount[e]>0}channelEncodingField(e){return Tr(this.getEncodingQueryByChannel(e))}getEncodings(){return this._spec.encodings.filter((e=>!Nr(e)))}getEncodingQueryByChannel(e){for(let t of this._spec.encodings)if(t.channel===e)return t}getEncodingQueryByIndex(e){return this._spec.encodings[e]}isAggregate(){return _t(this._spec.encodings,(e=>Tr(e)&&!On(e.aggregate)&&!!e.aggregate||wr(e)))}getVlStack(){return cr(this._spec)}getStackOffset(){return function(e){for(const t of e.encodings)if(void 0!==t[tn.STACK]&&!On(t[tn.STACK]))return t[tn.STACK]}(this._spec)}getStackChannel(){return function(e){for(const t of e.encodings)if(void 0!==t[tn.STACK]&&!On(t.channel))return t.channel;return null}(this._spec)}toShorthand(e){if(e){if(It.isString(e))return function(e,t){return Vo[t](e)}(this.specQuery,e);const t=zo(e);return mr(this._spec,t.include,t.replacer)}return mr(this._spec)}toSpec(e){if(On(this._spec.mark))return null;let t={};return(e=e||this._spec.data)&&(t.data=e),this._spec.transform&&(t.transform=this._spec.transform),t.mark=this._spec.mark,t.encoding=Ar(this.specQuery.encodings,{schema:this._schema,wildcardMode:"null"}),this._spec.width&&(t.width=this._spec.width),this._spec.height&&(t.height=this._spec.height),this._spec.background&&(t.background=this._spec.background),this._spec.padding&&(t.padding=this._spec.padding),this._spec.title&&(t.title=this._spec.title),null===t.encoding?null:((this._spec.config||this._opt.defaultSpecConfig)&&(t.config=It.extend({},this._opt.defaultSpecConfig,this._spec.config)),t)}getRankingScore(e){return this._rankingScore[e]}setRankingScore(e,t){this._rankingScore[e]=t}}function na(e){return void 0!==e.items}function ra(e){let t=e.items[0];for(;t&&na(t);)t=t.items[0];return t}class ia{constructor(e){this.type=e,this.scoreIndex=this.initScore()}getFeatureScore(e){const t=this.type,n=this.scoreIndex[e];if(void 0!==n)return{type:t,feature:e,score:n}}}var oa,aa;(aa=oa||(oa={}))[aa.Q=lt]="Q",aa[aa.BIN_Q="bin_"+lt]="BIN_Q",aa[aa.T=dt]="T",aa[aa.TIMEUNIT_T="timeUnit_time"]="TIMEUNIT_T",aa[aa.TIMEUNIT_O="timeUnit_"+ut]="TIMEUNIT_O",aa[aa.O=ut]="O",aa[aa.N=ft]="N",aa[aa.K=Zn.KEY]="K",aa[aa.NONE="-"]="NONE";const sa=oa.Q,ca=oa.BIN_Q,la=oa.T,ua=oa.TIMEUNIT_T,da=oa.TIMEUNIT_O,fa=oa.O,pa=oa.N,ha=oa.K,ga=oa.NONE;function ma(e){if(e.bin)return oa.BIN_Q;if(e.timeUnit){return Et(Ur(e))?oa.TIMEUNIT_O:oa.TIMEUNIT_T}return e.type}const ya=-10;function va(e,t,n,r){return e+"_"+t+"_"+n+"_"+r}const ba=[new class extends ia{constructor(){super("Axis")}initScore(e={}){e=Object.assign({},$n,e);let t={};return[{feature:ca,opt:"preferredBinAxis"},{feature:la,opt:"preferredTemporalAxis"},{feature:ua,opt:"preferredTemporalAxis"},{feature:da,opt:"preferredTemporalAxis"},{feature:fa,opt:"preferredOrdinalAxis"},{feature:pa,opt:"preferredNominalAxis"}].forEach((n=>{e[n.opt]===ye?t[n.feature+"_"+ve]=-.01:e[n.opt]===ve&&(t[n.feature+"_"+ye]=-.01)})),t}featurize(e,t){return e+"_"+t}getScore(e,t,n){return e.getEncodings().reduce(((e,t)=>{if(Tr(t)||Sr(t)){const n=ma(t),r=this.featurize(n,t.channel),i=this.getFeatureScore(r);i&&e.push(i)}return e}),[])}},new class extends ia{constructor(){super("Dimension")}initScore(){return{row:-2,column:-2,color:0,opacity:0,size:0,shape:0}}getScore(e,t,n){return e.isAggregate()&&e.getEncodings().reduce(((e,t)=>{if(Sr(t)||Tr(t)&&!t.aggregate){const n=this.getFeatureScore(t.channel+"");if(n&&n.score>e.score)return n}return e}),{type:"Dimension",feature:"No Dimension",score:-5}),[]}},new class extends ia{constructor(){super("Facet")}initScore(e){let t={};return(e=Object.assign({},$n,e)).preferredFacet===he?t[ge]=-.01:e.preferredFacet===ge&&(t[he]=-.01),t}getScore(e,t,n){return e.getEncodings().reduce(((e,t)=>{if(Tr(t)||Sr(t)){const n=this.getFeatureScore(t.channel);n&&e.push(n)}return e}),[])}},new class extends ia{constructor(){super("Mark")}initScore(){return function(){const e=[sa,la],t=[ca,da,fa,pa,ha].concat([ga]);let n={};e.forEach((t=>{e.forEach((e=>{Dt({point:0,text:-.2,tick:-.5,rect:-1,bar:-2,line:-2,area:-2,rule:-2.5},((r,i)=>{const o=va(t,e,!0,i);n[o]=r}));Dt({point:0,text:-.2,tick:-.5,bar:-2,line:-2,area:-2,rule:-2.5},((r,i)=>{const o=va(t,e,!1,i);n[o]=r}))}))})),e.forEach((e=>{t.forEach((t=>{Dt({tick:0,point:-.2,text:-.5,bar:-2,line:-2,area:-2,rule:-2.5},((r,i)=>{const o=va(e,t,!0,i);n[o]=r;const a=va(t,e,!0,i);n[a]=r}))})),[ua].forEach((t=>{Dt({point:0,text:-.5,tick:-1,bar:-2,line:-2,area:-2,rule:-2.5},((r,i)=>{const o=va(e,t,!0,i);n[o]=r;const a=va(t,e,!0,i);n[a]=r}))})),[ga,pa,fa,ha].forEach((t=>{Dt({bar:0,point:-.2,tick:-.25,text:-.3,line:-2,area:-2,rule:-2.5},((r,i)=>{const o=va(e,t,!1,i);n[o]=r;const a=va(t,e,!1,i);n[a]=r}))})),[ca].forEach((t=>{Dt({bar:0,point:-.2,tick:-.25,text:-.3,line:-.5,area:-.5,rule:-2.5},((r,i)=>{const o=va(e,t,!1,i);n[o]=r;const a=va(t,e,!1,i);n[a]=r}))})),[ua,da].forEach((t=>{Dt({line:0,area:-.1,bar:-.2,point:-.3,tick:-.35,text:-.4,rule:-2.5},((r,i)=>{const o=va(e,t,!1,i);n[o]=r;const a=va(t,e,!1,i);n[a]=r}))}))})),[ua].forEach((e=>{[ua].forEach((t=>{const r={point:0,rect:-.1,text:-.5,tick:-1,bar:-2,line:-2,area:-2,rule:-2.5};Dt(r,((r,i)=>{const o=va(e,t,!0,i);n[o]=r})),Dt(r,((r,i)=>{const o=va(e,t,!1,i);n[o]=r}))})),t.forEach((t=>{const r={tick:0,point:-.2,text:-.5,rect:-1,bar:-2,line:-2,area:-2,rule:-2.5};Dt(r,((r,i)=>{const o=va(e,t,!0,i);n[o]=r})),Dt(r,((r,i)=>{const o=va(t,e,!0,i);n[o]=r})),Dt(r,((r,i)=>{const o=va(e,t,!1,i);n[o]=r})),Dt(r,((r,i)=>{const o=va(t,e,!1,i);n[o]=r}))}))}));for(const r of t)for(const e of t){const t={point:0,rect:0,text:-.1,tick:-1,bar:-2,line:-2,area:-2,rule:-2.5};Dt(t,((t,i)=>{const o=va(r,e,!0,i);n[o]=t})),Dt(t,((t,i)=>{const o=va(r,e,!1,i);n[o]=t}))}return n}()}getScore(e,t,n){let r=e.getMark();r!==fn&&r!==pn||(r=sn);const i=e.getEncodingQueryByChannel(ye),o=i?ma(i):ga,a=e.getEncodingQueryByChannel(ve),s=o+"_"+(a?ma(a):ga)+"_"+!e.isAggregate()+"_"+r,c=this.getFeatureScore(s);return c?[c]:(console.error("feature score missing for",s),[])}},new class extends ia{constructor(){super("SizeChannel")}initScore(){return{bar_size:-2,tick_size:-2}}getScore(e,t,n){const r=e.getMark();return e.getEncodings().reduce(((e,t)=>{if(Tr(t)||Sr(t)){const n=r+"_"+t.channel,i=this.getFeatureScore(n);i&&e.push(i)}return e}),[])}},new class extends ia{constructor(){super("TypeChannel")}initScore(){let e={};const t={x:0,y:0,size:-.575,color:-.725,text:-2,opacity:-3,shape:ya,row:ya,column:ya,detail:-20};[sa,la,ua].forEach((n=>{It.keys(t).forEach((r=>{e[this.featurize(n,r)]=t[r]}))}));const n=It.extend({},t,{row:-.75,column:-.75,shape:-3.1,text:-3.2,detail:-4});[ca,da,fa].forEach((t=>{It.keys(n).forEach((r=>{e[this.featurize(t,r)]=n[r]}))}));const r={x:0,y:0,color:-.6,shape:-.65,row:-.7,column:-.7,text:-.8,detail:-2,size:-3,opacity:-3.1};return It.keys(r).forEach((t=>{e[this.featurize(pa,t)]=r[t],e[this.featurize(ha,t)]=Ut(["x","y","detail"],t)?-1:r[t]-2})),e}featurize(e,t){return e+"_"+t}getScore(e,t,n){const r=e.getEncodings().reduce(((e,t)=>{if(Tr(t)||Sr(t)){const n=vr(t);(e[n]=e[n]||[]).push(t)}return e}),{}),i=[];return Dt(r,(e=>{const t=e.reduce(((e,t)=>{if(Tr(t)||Sr(t)){const n=ma(t),r=this.featurize(n,t.channel),i=this.getFeatureScore(r);if(null===e||i.score>e.score)return i}return e}),null);i.push(t)})),i}}];const xa="aggregationQuality";let Ea={};function Ta(e,t){Ea[e]=t}function Sa(e,t,n,r){return t.nest&&r!==t.nest.length?(e.items.forEach((e=>{Sa(e,t,n,r+1)})),t.nest[r].orderGroupBy&&e.items.sort(function(e,t,n){return(r,i)=>{const o=ra(r),a=ra(i);return Na(e instanceof Array?e:[e],o,a,t,n)}}(t.nest[r].orderGroupBy,n,t.config))):(t.orderBy||t.chooseBy)&&(e.items.sort(function(e,t,n){return(r,i)=>Na(e instanceof Array?e:[e],r,i,t,n)}(t.orderBy||t.chooseBy,n,t.config)),t.chooseBy&&e.items.length>0&&e.items.splice(1)),e}function Na(e,t,n,r,i){for(let o of e){let e=wa(n,o,r,i).score-wa(t,o,r,i).score;if(0!==e)return e}return 0}function wa(e,t,n,r){if(void 0!==e.getRankingScore(t))return e.getRankingScore(t);const i=(0,Ea[t])(e,n,r);return e.setRankingScore(t,i),i}function Ca(e,t,n){let r={};return e=e.map((function(e){return n.smallRangeStepForHighCardinalityOrFacet&&(e=function(e,t,n,r){[he,ve,ge,ye].forEach((t=>{n[t]=e.getEncodingQueryByChannel(t)}));const i=n[ve];if(void 0!==i&&Tr(i)&&(n[he]||t.cardinality(i)>r.smallRangeStepForHighCardinalityOrFacet.maxCardinality)){void 0===i.scale&&(i.scale={});const e=Ur(i);i.scale&&(void 0===e||Et(e))&&(i.scale.rangeStep||(i.scale.rangeStep=12))}const o=n[ye];if(Tr(o)&&(n[ge]||t.cardinality(o)>r.smallRangeStepForHighCardinalityOrFacet.maxCardinality)){void 0===o.scale&&(o.scale={});const e=Ur(o);o.scale&&(void 0===e||Et(e))&&(o.scale.rangeStep||(o.scale.rangeStep=12))}return e}(e,t,r,n)),n.nominalColorScaleForHighCardinality&&(e=function(e,t,n,r){n[we]=e.getEncodingQueryByChannel(we);const i=n[we];Tr(i)&&void 0!==i&&(i.type===ft||i.type===Zn.KEY)&&t.cardinality(i)>r.nominalColorScaleForHighCardinality.maxCardinality&&(void 0===i.scale&&(i.scale={}),i.scale&&(i.scale.range||(i.scale.scheme=r.nominalColorScaleForHighCardinality.palette)));return e}(e,t,r,n)),n.xAxisOnTopForHighYCardinalityWithoutColumn&&(e=function(e,t,n,r){if([ge,ye,ve].forEach((t=>{n[t]=e.getEncodingQueryByChannel(t)})),void 0===n[ge]){const e=n[ye],i=n[ve];Tr(e)&&Tr(i)&&void 0!==i&&i.field&&Et(Ur(i))&&void 0!==e&&t.cardinality(i)>r.xAxisOnTopForHighYCardinalityWithoutColumn.maxCardinality&&(void 0===e.axis&&(e.axis={}),e.axis&&!e.axis.orient&&(e.axis.orient="top"))}return e}(e,t,r,n)),e})),e}function Aa(e,t,n=$n){const r=ta.build(e,t,n),i=r.wildcardIndex;let o=[r];return n.propertyPrecedence.forEach((e=>{const r=function(e){const t=e.split(".");if(1===t.length)return e;if(2===t.length)return{parent:t[0],child:t[1]};throw"Invalid property key with "+t.length+" dots: "+e}(e);if(i.hasProperty(r)){const e=function(e){return Ho.get(e)}(r),a=e(i,t,n);o=o.reduce(a,[])}})),!n.stylize||null===n.nominalColorScaleForHighCardinality&&null===n.smallRangeStepForHighCardinalityOrFacet&&null===n.xAxisOnTopForHighYCardinalityWithoutColumn?o:Ca(o,t,n)}function Oa(e,t,n){const r=function(e,t){if(t){const n={name:"",path:"",items:[]};let r={},i=[],o=[],a=[];for(let e=0;e<t.length;e++){i.push(e>0?i[e-1].duplicate():new nr),o.push(e>0?o[e-1].duplicate():new nr);const n=t[e].groupBy;if(It.isArray(n)){let t=zo(n,i[e],o[e]);a.push(t.replacer)}}return e.forEach((e=>{let o="",s=n;for(let n=0;n<t.length;n++){const c=s.groupBy=t[n].groupBy;s.orderGroupBy=t[n].orderGroupBy;const l=It.isArray(c)?mr(e.specQuery,i[n],a[n]):Vo[c](e.specQuery);o+="/"+l,r[o]||(r[o]={name:l,path:o,items:[]},s.items.push(r[o])),s=r[o]}s.items.push(e)})),n}return{name:"",path:"",items:e}}(Aa((e=Object.assign({},function(e){if(e.groupBy){let t={groupBy:e.groupBy};e.orderBy&&(t.orderGroupBy=e.orderBy);let n={spec:It.duplicate(e.spec),nest:[t]};return e.chooseBy&&(n.chooseBy=e.chooseBy),e.config&&(n.config=e.config),n}return It.duplicate(e)}(e),{config:Object.assign({},$n,n,e.config)})).spec,t,e.config),e.nest);return{query:e,result:Sa(r,e,t,0)}}Ta("effectiveness",(function(e,t,n){const r=ba.reduce(((r,i)=>{const o=i.getScore(e,t,n);return r.concat(o)}),[]);return{score:r.reduce(((e,t)=>e+t.score),0),features:r}})),Ta(xa,(function(e,t,n){const r=function(e){const t=e.getEncodings();if(e.isAggregate()){if(_t(t,(e=>Tr(e)&&(e.type===lt&&!e.bin&&!e.aggregate||e.type===dt&&!e.timeUnit))))return{type:xa,score:.1,feature:"Aggregate with raw continuous"};if(_t(t,(e=>Tr(e)&&Ir(e)))){let e=_t(t,(e=>Tr(e)&&"count"===e.aggregate||wr(e))),n=_t(t,(e=>Tr(e)&&!!e.bin));return e?{type:xa,score:.8,feature:"Aggregate with count"}:n?{type:xa,score:.7,feature:"Aggregate with bin but without count"}:{type:xa,score:.9,feature:"Aggregate without count and without bin"}}return{type:xa,score:.3,feature:"Aggregate without dimension"}}return _t(t,(e=>Tr(e)&&!Ir(e)))?{type:xa,score:1,feature:"Raw with measure"}:{type:xa,score:.2,feature:"Raw without measure"}}(e);return{score:r.score,features:[r]}})),Ta("fieldOrder",(function(e,t,n){const r=e.wildcardIndex.encodingIndicesByProperty.get("field");if(!r)return{score:0,features:[]};const i=e.specQuery.encodings,o=t.fieldSchemas.length,a=[];let s=0,c=1;for(let l=r.length-1;l>=0;l--){const n=r[l],u=i[n];let d;if(!Tr(u))continue;d=u.field;const f=e.wildcardIndex.encodings[n].get("field"),p=t.fieldSchema(d).index,h=-p*c;s+=h,a.push({score:h,type:"fieldOrder",feature:`field ${f.name} is ${d} (#${p} in the schema)`}),c*=o}return{score:s,features:a}}));const ka={[Io.BOOLEAN]:r.jsx(i,{className:"h-5 w-5 inline-flex opacity-60"}),[Io.DATETIME]:r.jsx(o,{className:"h-5 w-5 inline-flex opacity-60"}),[Io.NUMBER]:r.jsx(a,{className:"h-5 w-5 inline-flex opacity-60"}),[Io.STRING]:r.jsx(s,{className:"h-5 w-5 inline-flex opacity-60"}),[Io.INTEGER]:r.jsx(G,{className:"h-5 w-5 inline-flex opacity-60"})};function Ma(e){const{type:t,limit:n,additionalFieldQuery:r}=e;return{type:t,limit:n,createQuery:e=>({spec:{...e.spec,encodings:[...e.spec.encodings,r]},groupBy:"field",orderBy:["fieldOrder","aggregationQuality","effectiveness"],chooseBy:["aggregationQuality","effectiveness"],config:{autoAddCount:!0}})}}const Ia=Ma({type:"addCategoricalField",limit:4,additionalFieldQuery:{channel:An,field:An,type:"nominal"}}),Ua=Ma({type:"addQuantitativeField",limit:4,additionalFieldQuery:{channel:An,bin:An,aggregate:An,field:An,type:"quantitative"}}),Fa=Ma({type:"addTemporalField",limit:2,additionalFieldQuery:{channel:An,hasFn:!0,timeUnit:An,field:An,type:"temporal"}});function Da(e){return e?"bin"===e?{bin:!0}:$(e)?{aggregate:e}:function(e){if(!e)return!1;return ja.includes(e)||Pa.includes(e)}(e)?{timeUnit:e}:{}:{}}const _a=["bin","min","max","mean","median","sum"],ja=["year","month","date","day","hours","minutes","seconds","milliseconds"],Pa=["yearmonth","yearmonthdate","monthdate"];function Ra(e){const t={};for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}function $a(e){const{aggregate:t,bin:n,timeUnit:r,field:i,scale:o,legend:a,axis:s,sort:u,description:d}=e;let{type:f}=e;if(On(f))throw new Error("Wildcard not support");"ordinal"===f&&(c.warn("Ordinal type is not supported. Using nominal type instead."),f="nominal");const p=function(e){const{aggregate:t,bin:n,timeUnit:r}=e;return n?"bin":t?t.toString():r?r.toString():void 0}({aggregate:t,bin:n,timeUnit:r});return l(void 0!==i,"Field is required for fieldQ"),Ra({field:i,fn:p,type:f,sort:u,scale:o,axis:s,legend:a,description:d})}function Ba(e){return 0===e.encodings.length}function La(e){let t=!1,n=!1,r=!1;for(const i of e.encodings)Er(i)||(Sr(i)?On(i.autoCount)&&(n=!0):(On(i.field)&&(t=!0),(On(i.aggregate)||On(i.bin)||On(i.timeUnit))&&(n=!0),On(i.channel)&&(r=!0)));return{hasAnyWildcard:r||t||n,hasWildcardField:t,hasWildcardFn:n,hasWildcardChannel:r}}function Wa(e){return{mark:e.mark,encodings:(t=e.encoding,Object.entries(t).map((([e,t])=>function(e,t){const{fn:n,...r}=e;return{channel:t,...Da(n),...r}}(t,e)))),config:e.config};var t}const qa={name:"source"};function Ha(e,t){const n={},{hasOpenPosition:r,hasStyleChannel:i,hasOpenFacet:o}=function(e){let t=!1,n=!1,r=!1;return e.encodings.forEach((e=>{"x"===e.channel||"y"===e.channel?t=!0:"row"===e.channel||"column"===e.channel?r=!0:"string"==typeof e.channel&&B(L,e.channel)&&(n=!0)})),{hasOpenPosition:t,hasStyleChannel:n,hasOpenFacet:r}}(e.spec);return(r||i)&&(n.addQuantitativeField=za(Ua,e,t)),(r||i||o)&&(n.addCategoricalField=za(Ia,e,t)),r&&(n.addTemporalField=za(Fa,e,t)),n}function Ga(e,t){if(Ba(e.spec))return{plots:[],query:e,limit:1};return{plots:[Ya(Oa(e,t).result,qa)[0]],query:e,limit:1}}function za(e,t,n){const r=e.createQuery(t);return{plots:Ya(Oa(r,n).result,qa),query:r,limit:e.limit}}function Ya(e,t){return e.items.map((e=>na(e)?Qa(t,ra(e)):Qa(t,e)))}function Qa(e,t){return{fieldInfos:t.getEncodings().filter(Tr).map((e=>({fieldDef:$a(e),channel:e.channel}))),spec:t.toSpec(e)}}const Va={type:"histograms",limit:12,createQuery:e=>({spec:{data:e.spec.data,mark:An,transform:e.spec.transform,encodings:[{channel:An,bin:An,timeUnit:An,field:An,type:An},{channel:An,aggregate:"count",field:"*",type:"quantitative"}]},groupBy:"fieldTransform",orderBy:["fieldOrder","aggregationQuality","effectiveness"],chooseBy:["aggregationQuality","effectiveness"],config:{autoAddCount:!1}})};const{valueAtom:Ka,useActions:Ja}=u((function(){return{mark:An,encoding:{},config:{},schema:null}}),{setSchema:(e,t)=>({...e,schema:t}),setMark:(e,t)=>({...e,mark:t}),setEncoding:(e,t)=>{const n=Ra({...e.encoding,...t});return{...e,encoding:n}},set:(e,t)=>{const{schema:n,...r}=t;return{...e,...r}}});function Xa(){return Ja()}const Za=d((e=>{const t=e(Ka);if(!t.schema)return{};const n=function(e){const{spec:t,autoAddCount:n}=e,r=Wa(t),{hasAnyWildcard:i,hasWildcardFn:o,hasWildcardField:a}=La(r),s=function(e){const{hasWildcardFn:t,hasWildcardField:n}=e;return t?"fieldTransform":n?"field":"encoding"}({hasWildcardFn:o,hasWildcardField:a});return{spec:r,groupBy:s,orderBy:["fieldOrder","aggregationQuality","effectiveness"],chooseBy:["aggregationQuality","effectiveness"],config:i?{autoAddCount:n}:void 0}}({spec:t,autoAddCount:!0});return Ba(n.spec)?{main:Ga(n,t.schema),histograms:za(Va,n,t.schema)}:function(e){return!La(e).hasAnyWildcard}(n.spec)&&!function(e){const t=new Set(e.encodings.map((e=>e.channel))),n=["x","y","color"].every((e=>t.has(e))),r=["row","column"].some((e=>t.has(e)));return n&&r}(n.spec)?{main:Ga(n,t.schema),...Ha(n,t.schema)}:{main:Ga(n,t.schema)}})),es=[An,"area","bar","circle","geoshape","line","point","rect","rule","square","text","tick","trail"],ts=["x","y","row","column"],ns=["color","size","shape"],rs=e=>{const t=f(26),{schema:n,mark:i}=e,o=p(Ka),a=Xa(),s=o.encoding.x&&o.encoding.y;let c;t[0]!==s||t[1]!==n||t[2]!==o.encoding||t[3]!==a?(c=e=>{const t=("row"===e||"column"===e)&&!s;return r.jsx(is,{schema:n,label:e,disabled:t,fieldDefinition:o.encoding[e],onChange:t=>a.setEncoding({[e]:t})},e)},t[0]=s,t[1]=n,t[2]=o.encoding,t[3]=a,t[4]=c):c=t[4];const l=c;let u,d,x,E,T;t[5]!==i?(u=i.toString(),t[5]=i,t[6]=u):u=t[6],t[7]!==a?(d=e=>a.setMark(e),t[7]=a,t[8]=d):d=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(x=r.jsx(h,{children:r.jsx(g,{placeholder:"Mark"})}),t[9]=x):x=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(E=r.jsx(m,{children:r.jsxs(y,{children:[r.jsx(v,{children:"Mark"}),es.map(ss)]})}),t[10]=E):E=t[10],t[11]!==u||t[12]!==d?(T=r.jsxs(b,{"data-testid":"marimo-plugin-data-explorer-mark-select",value:u,onValueChange:d,children:[x,E]}),t[11]=u,t[12]=d,t[13]=T):T=t[13];const S=T;let N,w,C,A,O,k;return t[14]===Symbol.for("react.memo_cache_sentinel")?(N=r.jsx("span",{className:"col-span-2 flex items-center justify-between w-full",children:r.jsx("div",{className:"text-sm font-semibold",children:"Encodings"})}),t[14]=N):N=t[14],t[15]!==l?(w=ts.map(l),t[15]=l,t[16]=w):w=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(C=r.jsx("div",{children:"Mark"}),t[17]=C):C=t[17],t[18]!==S?(A=r.jsxs("span",{className:"col-span-2 text-sm font-semibold w-full border-t border-divider flex items-center justify-between pt-2 pr-[30px]",children:[C,S]}),t[18]=S,t[19]=A):A=t[19],t[20]!==l?(O=ns.map(l),t[20]=l,t[21]=O):O=t[21],t[22]!==w||t[23]!==A||t[24]!==O?(k=r.jsxs("div",{className:"grid gap-x-2 gap-y-4 justify-items-start py-3 pl-4 pr-2 bg-[var(--slate-1)] border rounded items-center grid-template-columns-[repeat(2,_minmax(0,_min-content))] self-start",children:[N,w,A,O]}),t[22]=w,t[23]=A,t[24]=O,t[25]=k):k=t[25],k},is=e=>{const t=f(43),{label:n,schema:i,fieldDefinition:o,disabled:a,onChange:s}=e;let c;t[0]!==o||t[1]!==i?(c=()=>{if(!o)return"--";if("*"===o.field)return r.jsxs("span",{className:"flex gap-2 flex-1",children:[ka[Io.NUMBER],r.jsx("span",{className:"text-left flex-1",children:"Count"})]});const e=o.field.toString();return r.jsxs("span",{className:"flex gap-2 flex-1",children:[ka[i.primitiveType(e)],r.jsx("span",{className:"text-left flex-1",children:o.fn?`${o.fn}(${o.field})`:e})]})},t[0]=o,t[1]=i,t[2]=c):c=t[2];const l=c;let u;t[3]!==s?(u=()=>{s(void 0)},t[3]=s,t[4]=u):u=t[4];const d=u;let p;t[5]!==(null==o?void 0:o.field)?(p=(null==o?void 0:o.field.toString())??"",t[5]=null==o?void 0:o.field,t[6]=p):p=t[6];const g=p;let v,S;t[7]!==n?(v=r.jsx(E,{className:"text-[var(--slate-11)] font-semibold",children:n}),t[7]=n,t[8]=v):v=t[8],t[9]!==s||t[10]!==i?(S=e=>{s("*"===e?{field:"*",fn:"count",type:"quantitative"}:{field:e,type:i.vlType(e)})},t[9]=s,t[10]=i,t[11]=S):S=t[11];const N=g?d:void 0;let w,C,A,O,k,M,I,U,F,D,_,j;return t[12]!==l?(w=l(),t[12]=l,t[13]=w):w=t[13],t[14]!==N||t[15]!==w?(C=r.jsx(h,{className:"min-w-[140px] lg:min-w-[210px] h-full",onClear:N,children:w}),t[14]=N,t[15]=w,t[16]=C):C=t[16],t[17]!==i?(A=i.fieldNames().map((e=>r.jsx(x,{value:e.toString(),children:r.jsxs("span",{className:"flex items-center gap-2 flex-1",children:[ka[i.primitiveType(e)],r.jsx("span",{className:"flex-1",children:e}),r.jsxs("span",{className:"text-muted-foreground text-xs font-semibold",children:["(",i.vlType(e),")"]})]})},e))),t[17]=i,t[18]=A):A=t[18],t[19]!==i?(O=0===i.fieldNames().length&&r.jsx(x,{disabled:!0,value:"--",children:"No columns"}),t[19]=i,t[20]=O):O=t[20],t[21]===Symbol.for("react.memo_cache_sentinel")?(k=r.jsx(T,{}),t[21]=k):k=t[21],t[22]===Symbol.for("react.memo_cache_sentinel")?(M=r.jsx(x,{value:"*",children:r.jsxs("span",{className:"flex items-center gap-1 flex-1",children:[ka[Io.NUMBER],r.jsx("span",{className:"flex-1",children:"Count"})]})},"*"),t[22]=M):M=t[22],t[23]!==A||t[24]!==O?(I=r.jsx(m,{children:r.jsxs(y,{children:[A,O,k,M]})}),t[23]=A,t[24]=O,t[25]=I):I=t[25],t[26]!==g||t[27]!==a||t[28]!==S||t[29]!==C||t[30]!==I?(U=r.jsxs(b,{value:g,disabled:a,onValueChange:S,children:[C,I]}),t[26]=g,t[27]=a,t[28]=S,t[29]=C,t[30]=I,t[31]=U):U=t[31],t[32]!==o||t[33]!==s?(F=o&&r.jsx(as,{field:o,onChange:s}),t[32]=o,t[33]=s,t[34]=F):F=t[34],t[35]!==F?(D=r.jsx("div",{className:"w-[26px]",children:F}),t[35]=F,t[36]=D):D=t[36],t[37]!==U||t[38]!==D?(_=r.jsxs("div",{className:"flex flex-row gap-1 h-[26px]",children:[U,D]}),t[37]=U,t[38]=D,t[39]=_):_=t[39],t[40]!==v||t[41]!==_?(j=r.jsxs(r.Fragment,{children:[v,_]}),t[40]=v,t[41]=_,t[42]=j):j=t[42],j},os="__",as=e=>{const t=f(15),{field:n,onChange:i}=e;if("*"===n.field)return null;let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],t[0]=o):o=t[0];let a=o;if(n.type===Zn.QUANTITATIVE){let e;t[1]===Symbol.for("react.memo_cache_sentinel")?(e=[["",_a]],t[1]=e):e=t[1],a=e}if(n.type===Zn.TEMPORAL){let e;t[2]===Symbol.for("react.memo_cache_sentinel")?(e=[["Single",ja],["Multi",Pa]],t[2]=e):e=t[2],a=e}if(a.length>0){let e,o,s,c,l,u;return t[3]!==i||t[4]!==n?(e=e=>{i({...n,fn:e===os?void 0:e})},t[3]=i,t[4]=n,t[5]=e):e=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(o=r.jsx(h,{className:"h-full px-1",hideChevron:!0,variant:"ghost",children:r.jsx(S,{size:14,strokeWidth:1.5})}),t[6]=o):o=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(s=r.jsx(y,{children:r.jsx(x,{value:os,children:"None"})}),c=r.jsx(T,{}),t[7]=s,t[8]=c):(s=t[7],c=t[8]),t[9]!==a?(l=r.jsxs(m,{children:[s,c,a.map(ls)]}),t[9]=a,t[10]=l):l=t[10],t[11]!==n.fn||t[12]!==e||t[13]!==l?(u=r.jsxs(b,{"data-testid":"marimo-plugin-data-explorer-field-options",value:n.fn,onValueChange:e,children:[o,l]}),t[11]=n.fn,t[12]=e,t[13]=l,t[14]=u):u=t[14],u}return null};function ss(e){return r.jsx(x,{value:e,children:e===An?"auto":e},e)}function cs(e){return r.jsx(x,{value:e??os,children:N(e)},e)}function ls(e){const[t,n]=e;return r.jsxs(y,{children:[t&&r.jsx(v,{children:t}),n.map(cs)]},t)}const us=e=>{const t=f(26),{schema:n}=e,[i,o]=w.useState(),[a,s]=w.useState();let c;if(t[0]!==n||t[1]!==i||t[2]!==a){const e=n.fieldNames(),l=i?n.stats({field:i,channel:"x"}):void 0;let u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=r.jsx(q,{className:"text-muted-foreground",width:40,height:40,strokeWidth:1.5}),t[4]=u):u=t[4];const d=u,f=a?e:e.slice(0,12),p=e.length>12,v=e.length>0?e.length:"No";let E,T;t[5]!==v?(E=r.jsxs("span",{className:"text-muted-foreground font-semibold",children:[v," fields"]}),t[5]=v,t[6]=E):E=t[6],t[7]!==n||t[8]!==i?(T=e=>{const t=n.cardinality({channel:"x",field:e});return r.jsxs("span",{className:C("hover:bg-muted self-start px-2 py-2 rounded flex flex-row gap-1 items-center cursor-pointer lg:justify-center text-sm truncate flex-shrink-0 overflow-hidden",i===e&&"bg-muted"),onClick:()=>{o(i!==e?e:void 0)},children:[ka[n.primitiveType(e)],e,t>1&&r.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",t,")"]})]},e)},t[7]=n,t[8]=i,t[9]=T):T=t[9];const S=f.map(T);let N,w;t[10]!==p||t[11]!==a?(N=p&&r.jsx(A,{"data-testid":"marimo-plugin-data-explorer-show-more-columns",variant:"link",size:"sm",className:"self-center col-span-3 -mt-1",onClick:()=>s((e=>!e)),children:a?"Show less":"Show more"}),t[10]=p,t[11]=a,t[12]=N):N=t[12],t[13]!==S||t[14]!==N?(w=r.jsxs("div",{className:"hidden lg:grid grid-cols-2 xl:grid-cols-3 gap-2 p-2 bg-[var(--slate-1)] border rounded lg:items-center items-start w-fit grid-flow-dense max-h-[300px] overflow-auto",children:[S,N]}),t[13]=S,t[14]=N,t[15]=w):w=t[15];const O=i||"",k=0===e.length;let M,I,U,F,D;t[16]===Symbol.for("react.memo_cache_sentinel")?(M=e=>{o(e)},t[16]=M):M=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(I=r.jsx(h,{className:"min-w-[210px] h-full",children:r.jsx(g,{placeholder:"Select a column"})}),t[17]=I):I=t[17],t[18]!==n?(U=n.fieldNames().map((e=>r.jsx(x,{value:e.toString(),children:r.jsxs("span",{className:"flex items-center gap-2 flex-1",children:[ka[n.primitiveType(e)],r.jsx("span",{className:"flex-1",children:e}),r.jsxs("span",{className:"text-muted-foreground text-xs font-semibold",children:["(",n.vlType(e),")"]})]})},e))),t[18]=n,t[19]=U):U=t[19],t[20]!==U?(F=r.jsx(m,{children:r.jsx(y,{children:U})}),t[20]=U,t[21]=F):F=t[21],t[22]!==O||t[23]!==k||t[24]!==F?(D=r.jsx("div",{className:"lg:hidden",children:r.jsxs(b,{"data-testid":"marimo-plugin-data-explorer-column-select",value:O,disabled:k,onValueChange:M,children:[I,F]})}),t[22]=O,t[23]=k,t[24]=F,t[25]=D):D=t[25],c=r.jsxs("div",{className:"flex flex-col justify-center items-center h-full flex-1 gap-2",children:[d,E,w,D,i&&r.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-2 p-2 text-sm",children:ds.map((e=>r.jsxs("div",{className:"flex flex-row gap-2 min-w-[100px]",children:[r.jsx("span",{className:"font-semibold",children:e}),r.jsx("span",{children:fs(null==l?void 0:l[e])})]},e)))})]}),t[0]=n,t[1]=i,t[2]=a,t[3]=c}else c=t[3];return c},ds=["distinct","min","max","mean","median","q1","q3","stdev"];function fs(e){return"number"==typeof e?new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e):"string"==typeof e?e:"object"==typeof e&&e instanceof Date?new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric"}).format(e):String(e)}const ps=e=>{const t=f(5);let n,i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=O(),t[0]=i):i=t[0],n=i;const o=n;let a,s;return t[1]!==e?(a=()=>{const t=o.sub(Ka,(()=>{const t=o.get(Ka),{schema:n,...r}=t;e.setValue(r)})),n=e.value;return n&&Object.keys(n).length>0&&o.set(Ka,n),t},t[1]=e,t[2]=a):a=t[2],k(a),t[3]!==e?(s=r.jsx(M,{store:o,children:r.jsx(ms,{...e})}),t[3]=e,t[4]=s):s=t[4],s},hs={export:{svg:!0,png:!0},source:!1,compiled:!1,editor:!1},gs={left:20,right:20,top:20,bottom:20},ms=e=>{var t,n,i,o,a,s,c,l,u,d,h,g,m,y;const v=f(43),{data:b}=e,x=Xa();let E,T;v[0]!==b||v[1]!==x?(E=async()=>{if(!b)return{};const e=await P(b,{type:"csv",parse:"auto"},{replacePeriod:!0}),t=function(e,t={},n={fields:[]}){t=It.extend({},$n,t);let r=No.summary(e),i=xo.inferAll(e),o=n.fields.reduce(((e,t)=>(e[t.name]=t,e)),{}),a=r.map((function(n,r){const a=n.field,s="date"===i[a]?Io.DATETIME:i[a];let c,l=n.distinct;if(s===Io.NUMBER)c=lt;else if(s===Io.INTEGER)c=l<t.numberNominalLimit&&l/n.count<t.numberNominalProportion?ft:lt;else if(s===Io.DATETIME){c=dt,n.min=new Date(e[0][a]),n.max=new Date(e[0][a]);for(const t of e){const e=new Date(t[a]).getTime();e<n.min.getTime()&&(n.min=new Date(e)),e>n.max.getTime()&&(n.max=new Date(e))}}else c=ft;c===ft&&l/n.count>t.minPercentUniqueForKey&&n.count>t.minCardinalityForKey&&(c=Zn.KEY);let u={name:a,originalIndex:r,vlType:c,type:s,stats:n,timeStats:{},binStats:{}};const d=o[u.name];return u=It.extend(u,d),u}));for(let c of a)if(c.vlType===lt)for(let e of t.enum.binProps.maxbins)c.binStats[e]=Oo(e,c.stats);else if(c.vlType===dt)for(let e of t.enum.timeUnit)void 0!==e&&(c.timeStats[e]=ko(e,c.stats));const s=Object.assign({},n,{fields:a});return new Ao(s)}(e);return x.setSchema(t),{chartData:e,schema:t}},v[0]=b,v[1]=x,v[2]=E):E=v[2],v[3]!==b?(T=[b],v[3]=b,v[4]=T):T=v[4];const{data:S,loading:N,error:w}=I(E,T),{mark:C}=p(Ka),O=p(Za),{theme:k}=U();if(w){let e;return v[5]!==w?(e=r.jsx(R,{error:w}),v[5]=w,v[6]=e):e=v[6],e}if(!S){let e;return v[7]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{}),v[7]=e):e=v[7],e}const{chartData:M,schema:j}=S;if(N||!j){let e;return v[8]===Symbol.for("react.memo_cache_sentinel")?(e=r.jsx("div",{}),v[8]=e):e=v[8],e}const $=null==(n=null==(t=O.main)?void 0:t.plots)?void 0:n[0];let B,L,q,G,z,Y;if(v[9]!==$||v[10]!==j||v[11]!==M||v[12]!==k||v[13]!==C||v[14]!==(null==(i=O.histograms)?void 0:i.plots)||v[15]!==(null==(o=O.addCategoricalField)?void 0:o.plots)||v[16]!==(null==(a=O.addQuantitativeField)?void 0:a.plots)||v[17]!==(null==(s=O.addTemporalField)?void 0:s.plots)||v[18]!==x){const e=new Set(null==$?void 0:$.fieldInfos.map(xs));let t;v[23]!==$||v[24]!==j||v[25]!==M||v[26]!==k?(t=()=>$?r.jsx("div",{className:"flex overflow-y-auto justify-center items-center flex-1 w-[90%]",children:r.jsx(W,{data:{source:M},padding:gs,actions:hs,spec:bs($.spec),theme:"dark"===k?"dark":void 0})}):r.jsx(us,{schema:j}),v[23]=$,v[24]=j,v[25]=M,v[26]=k,v[27]=t):t=v[27];const n=t;let i,o;q="flex flex-col gap-2",v[28]!==C||v[29]!==j?(i=r.jsx(rs,{mark:C,schema:j}),v[28]=C,v[29]=j,v[30]=i):i=v[30],v[31]!==n?(o=n(),v[31]=n,v[32]=o):o=v[32],v[33]!==i||v[34]!==o?(G=r.jsxs("div",{className:"flex items-center gap-2",children:[i,o]}),v[33]=i,v[34]=o,v[35]=G):G=v[35],B=ys,L=[null==(c=O.histograms)?void 0:c.plots,null==(l=O.addCategoricalField)?void 0:l.plots,null==(u=O.addQuantitativeField)?void 0:u.plots,null==(d=O.addTemporalField)?void 0:d.plots].filter(Boolean).flat().map(((t,n)=>r.jsx(vs,{title:r.jsx("div",{className:"flex flex-row gap-1",children:t.fieldInfos.map((t=>{const n="*"===t.fieldDef.field?"Count":t.fieldDef.fn?`${t.fieldDef.fn}(${t.fieldDef.field})`:t.fieldDef.field.toString();return r.jsx(F,{variant:e.has(t.fieldDef.field)?"secondary":"defaultOutline",children:n},n)}))}),actions:r.jsx(D,{content:"Make main plot",children:r.jsx(A,{"data-testid":"marimo-plugin-data-explorer-make-main-plot",variant:"text",size:"icon",onClick:()=>{const e=_.fromEntries(t.fieldInfos.map((e=>[e.channel,e.fieldDef])));x.setEncoding(e)},children:r.jsx(H,{className:"w-4 h-4"})})}),children:r.jsx(W,{data:{source:M},actions:!1,spec:t.spec,theme:"dark"===k?"dark":void 0},n)},n))),v[9]=$,v[10]=j,v[11]=M,v[12]=k,v[13]=C,v[14]=null==(h=O.histograms)?void 0:h.plots,v[15]=null==(g=O.addCategoricalField)?void 0:g.plots,v[16]=null==(m=O.addQuantitativeField)?void 0:m.plots,v[17]=null==(y=O.addTemporalField)?void 0:y.plots,v[18]=x,v[19]=B,v[20]=L,v[21]=q,v[22]=G}else B=v[19],L=v[20],q=v[21],G=v[22];return v[36]!==B||v[37]!==L?(z=r.jsx(B,{children:L}),v[36]=B,v[37]=L,v[38]=z):z=v[38],v[39]!==q||v[40]!==G||v[41]!==z?(Y=r.jsxs("div",{className:q,children:[G,z]}),v[39]=q,v[40]=G,v[41]=z,v[42]=Y):Y=v[42],Y},ys=e=>{const t=f(2),{children:n}=e;if(0===j.Children.count(n))return null;let i;return t[0]!==n?(i=r.jsx("div",{className:"flex flex-row overflow-x-auto overflow-y-hidden gap-4 snap-x pb-4",children:n}),t[0]=n,t[1]=i):i=t[1],i},vs=e=>{const t=f(10),{title:n,children:i,actions:o}=e;let a,s,c,l;return t[0]!==n?(a=r.jsx("div",{className:"text-sm font-medium",children:n}),t[0]=n,t[1]=a):a=t[1],t[2]!==a||t[3]!==o?(s=r.jsxs("div",{className:"flex flex-row justify-between items-center bg-[var(--slate-3)] py-0.5 px-2",children:[a,o]}),t[2]=a,t[3]=o,t[4]=s):s=t[4],t[5]!==i?(c=r.jsx("div",{className:"px-6 pt-2 max-h-[280px] overflow-y-auto",children:i}),t[5]=i,t[6]=c):c=t[6],t[7]!==s||t[8]!==c?(l=r.jsxs("div",{className:"flex-shrink-0 bg-card shadow-md border overflow-hidden rounded snap-start",children:[s,c]}),t[7]=s,t[8]=c,t[9]=l):l=t[9],l};function bs(e){var t,n;return Boolean((null==(t=e.encoding)?void 0:t.row)||(null==(n=e.encoding)?void 0:n.column))||(e.width="container"),e}function xs(e){return e.fieldDef.field}export{ms as DataExplorerComponent,ps as default};
