marimo-learn / _site /functional_programming /assets /ConnectedDataExplorerComponent-D39SA74B.js
Haleshot's picture
Update course materials and assets across various sections, including functional programming, optimization, probability, and Python. Enhance HTML content and ensure consistency in asset management.
565ea71 unverified
raw
history blame
133 kB
import{aD as e,q as t,d5 as n,P as r,ez as i,eA as o,eB as a,eC as s,at as c,dp as l,dH as u,eD as d,G as f,M as p,eE as h,eF as g,eG as m,eH as y,eI as v,eJ as b,eK as x,be as E,eL as T,db as S,eM as N,J as w,ad as C,$ as A,eN as O,dj as k,eO as M,ao as I,ac as U,ax as F,az as D,eP as _,an as j,ap as P,R}from"./index-BiV-b1K2.js";import{U as $,e as B,V as L}from"./compile-C9-2F0s7.js";import{a as W}from"./VegaLite-x3FR6zXd.js";import"./time-IYxE9Zrl.js";import"./step-xJWGRC3d.js";import"./linear-Ba7S-mDj.js";import"./init-DLRA0X12.js";import"./range-CtcPcB_L.js";import"./ordinal-BcaZTuz9.js";import"./colors-bszWmPJw.js";import"./arc-B5qYPUYs.js";import"./index-DbEIEgDe.js";
/**
* @license lucide-react v0.474.0 - ISC
*
* This source code is licensed under the ISC license.
* See the LICENSE file in the root directory of this source tree.
*/const H=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"}]]),q=e("ListFilter",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M7 12h10",key:"b7w52i"}],["path",{d:"M10 18h4",key:"1ulq68"}]]),G=e("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]]);
/*! *****************************************************************************
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,V,K,J,X={exports:{}};Y||(Y=1,Q=X,V=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}(),Q.exports&&(Q.exports=V));var Z=J?K:(J=1,K=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 ee=t(Z);function te(e,t,n){return e.fields=t||[],e.fname=n,e}function ne(e){throw Error(e)}function re(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||ne("Access path missing open bracket: "+e),a>0&&l(),a=0,t=n+1):n>t?l():t=n+1}return a&&ne("Access path missing closing bracket: "+e),o&&ne("Access path missing closing quote: "+e),n>t&&(n++,l()),i}const ie=Array.isArray;function oe(e){return e===Object(e)}function ae(e){return"string"==typeof e}function se(e){return ie(e)?"["+e.map(se)+"]":oe(e)||ae(e)?JSON.stringify(e).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):e}var ce,le,ue,de=[];function fe(e,t,n){var r=[t].concat([].slice.call(n));console[e](...r)}le=re(ce="id"),ue="return _["+le.map(se).join("][")+"];",te(Function("_",ue),[ce=1===le.length?le[0]:ce],ce),te((function(e){return e}),de,"identity"),te((function(){return 0}),de,"zero"),te((function(){return 1}),de,"one"),te((function(){return!0}),de,"true"),te((function(){return!1}),de,"false");function pe(e){return"boolean"==typeof e}function he(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=>ee(e))).join(",")})`};const ge=ee;function me(e,t){return e.indexOf(t)>-1}const ye=Object.keys;const ve="row",be="column",xe="facet",Ee="x",Te="y",Se="x2",Ne="y2",we="latitude",Ce="longitude",Ae="latitude2",Oe="longitude2",ke="color",Me="fill",Ie="stroke",Ue="shape",Fe="size",De="opacity",_e="fillOpacity",je="strokeOpacity",Pe="strokeWidth",Re="text",$e="order",Be="detail",Le="key",We="tooltip",He="href",qe=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 Ge(e){return"color"===e||"fill"===e||"stroke"===e}const ze=Object.assign({},qe,{row:1,column:1,facet:1}),Ye=ye(ze),{order:Qe,detail:Ve}=ze;z(ze,["order","detail"]);const{order:Ke,detail:Je,row:Xe,column:Ze,facet:et}=ze;z(ze,["order","detail","row","column","facet"]);const{x:tt,y:nt,x2:rt,y2:it,latitude:ot,longitude:at,latitude2:st,longitude2:ct}=qe,lt=z(qe,["x","y","x2","y2","latitude","longitude","latitude2","longitude2"]),ut=ye(lt),{text:dt,tooltip:ft,href:pt,detail:ht,key:gt,order:mt}=lt,yt=z(lt,["text","tooltip","href","detail","key","order"]),vt=Object.assign({},{x:1,y:1},yt);function bt(e,t){return function(e){switch(e){case ke:case Me:case Ie:case Be:case Le:case We:case He:case $e:case De:case _e:case je:case Pe:case xe:case ve:case be:return xt;case Ee:case Te:case we:case Ce:return Tt;case Se:case Ne:case Ae:case Oe:return{rule:"always",bar:"always",rect:"always",area:"always",circle:"binned",point:"binned",square:"binned",tick:"binned",line:"binned",trail:"binned"};case Fe:return{point:"always",tick:"always",rule:"always",circle:"always",square:"always",bar:"always",text:"always",line:"always",trail:"always"};case Ue:return{point:"always",geoshape:"always"};case Re:return{text:"always"}}}(e)[t]}const xt={area:"always",bar:"always",circle:"always",geoshape:"always",line:"always",rule:"always",point:"always",rect:"always",square:"always",trail:"always",text:"always",tick:"always"},{geoshape:Et}=xt,Tt=z(xt,["geoshape"]);function St(e){switch(e){case Ee:case Te:case Fe:case Pe:case De:case _e:case je:case Se:case Ne:return;case xe:case ve:case be:case Ue:case Re:case We:case He:return"discrete";case ke:case Me:case Ie:return"flexible";case we:case Ce:case Ae:case Oe:case Be:case Le:case $e:return}throw new Error("rangeType not implemented for "+e)}const Nt={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},wt=Object.assign({},Nt,{encoding:1});Object.assign({gridScale:1,scale:1},Nt,{encode:1});const Ct=ye(wt),At={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({},At,{opacity:1,shape:1,stroke:1,fill:1,size:1,strokeWidth:1,encode:1});const Ot=ye(At);const kt=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 ${ge(e)} as unioned domains only support boolean or op 'count'.`},droppedDay:function(e){return`Dropping day from datetime ${ge(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 ${ge(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}: ${ge(t)}`},invalidTransformIgnored:function(e){return`Ignoring an invalid transform: ${ge(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()}" (${ge(n)} and ${ge(r)}). Using the union of the two domains.`},mergeConflictingProperty:function(e,t,n,r){return`Conflicting ${t.toString()} property "${e.toString()}" (${ge(n)} and ${ge(r)}). Using ${ge(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: ${ge(n)}}.`},projectionOverridden:function(e){const{parentProjection:t,projection:n}=e;return`Layer's shared projection ${ge(t)} is overridden by a child projection ${ge(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 (${ge(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 (${ge(e)}).`},unrecognizedParse:function(e){return`Unrecognized parse "${e}".`}},Symbol.toStringTag,{value:"Module"})),Mt=kt;var It;let Ut=(It=2||0,{level:function(e){return arguments.length?(It=+e,this):It},error:function(){return It>=1&&fe("error","ERROR",arguments),this},warn:function(){return It>=2&&fe("warn","WARN",arguments),this},info:function(){return It>=3&&fe("log","INFO",arguments),this},debug:function(){return It>=4&&fe("log","DEBUG",arguments),this}});function Ft(...e){Ut.warn.apply(Ut,arguments)}const Dt={quantitative:1,ordinal:1,temporal:1,nominal:1,geojson:1},_t="quantitative",jt="ordinal",Pt="temporal",Rt="nominal";var $t,Bt;(Bt=$t||($t={})).LINEAR="linear",Bt.LOG="log",Bt.POW="pow",Bt.SQRT="sqrt",Bt.SYMLOG="symlog",Bt.TIME="time",Bt.UTC="utc",Bt.QUANTILE="quantile",Bt.QUANTIZE="quantize",Bt.THRESHOLD="threshold",Bt.BIN_ORDINAL="bin-ordinal",Bt.ORDINAL="ordinal",Bt.POINT="point",Bt.BAND="band";const Lt=ye({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"}),Wt=["linear","log","pow","sqrt","symlog","time","utc"],Ht=he(Wt),qt=he(["quantile","quantize","threshold"]),Gt=he(Wt.concat(["quantile","quantize","threshold"])),zt=he(["ordinal","bin-ordinal","point","band"]);function Yt(e){return e in zt}function Qt(e){return e in Ht}const Vt={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},Kt=ye(Vt),{type:Jt,domain:Xt,range:Zt,rangeStep:en,scheme:tn}=Vt;function nn(e,t){switch(t){case"type":case"domain":case"reverse":case"range":return!0;case"scheme":case"interpolate":return!me(["point","band","identity"],e);case"bins":return!me(["point","band","identity","ordinal"],e);case"round":return Qt(e)||"band"===e||"point"===e;case"padding":return Qt(e)||me(["point","band"],e);case"paddingOuter":case"rangeStep":case"align":return me(["point","band"],e);case"paddingInner":return"band"===e;case"clamp":return Qt(e);case"nice":return Qt(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 Gt&&!me(["log","time","utc","threshold","quantile"],e)}}function rn(e,t){switch(t){case"interpolate":case"scheme":return Ge(e)?void 0:Mt.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 on(e,t){return me([jt,Rt],t)?void 0===e||Yt(e):t===Pt?me([$t.TIME,$t.UTC,void 0],e):t!==_t||me([$t.LOG,$t.POW,$t.SQRT,$t.SYMLOG,$t.QUANTILE,$t.QUANTIZE,$t.THRESHOLD,$t.LINEAR,void 0],e)}function an(e,t){switch(e){case Ee:case Te:return Qt(t)||me(["band","point"],t);case Fe:case Pe:case De:case _e:case je:return Qt(t)||t in qt||me(["band","point"],t);case ke:case Me:case Ie:return"band"!==t;case Ue:return"ordinal"===t}return!1}function sn(e,t){return e+"_"+t}z(Vt,["type","domain","range","rangeStep","scheme"]),function(){const e={};for(const t of Ye)for(const n of ye(Dt))for(const r of Lt){const i=sn(t,n);an(t,r)&&on(r,n)&&(e[i]=e[i]||[],e[i].push(r))}}();var cn,ln={exports:{}};function un(){return cn||(cn=1,function(){var e=ln.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])/}()),ln.exports}var dn=un();function fn(e,t){return-1!==e.indexOf(t)}function pn(e,t){for(let n=0;n<e.length;n++)if(!t(e[n],n))return!1;return!0}function hn(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 gn(e,t){let n,r=0;for(n in e)if(t(e[n],n,r++))return!0;return!1}function mn(e){return!!e.parent}const yn={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},vn=(bn=yn,Object.keys(bn));var bn;const xn={bin:1,scale:1,sort:1,axis:1,legend:1};function En(e){return xn[e]}const Tn=["maxbins","divide","extent","base","step","steps","minstep"].map((e=>({parent:"bin",child:e}))),Sn=["field","op","order"].map((e=>({parent:"sort",child:e}))),Nn=Kt.map((e=>({parent:"scale",child:e}))),wn=Ct.map((e=>({parent:"axis",child:e}))),Cn=Ot.map((e=>({parent:"legend",child:e}))),An=[].concat(Tn,Sn,Nn,wn,Cn),On=["width","height","background","padding","title"];function kn(e){return mn(e)?e.parent+"."+e.child:e}const Mn=An.reduce(((e,t)=>(e[t.parent]=e[t.parent]||[],e[t.parent][t.child]=t,e)),{});function In(e,t){return(Mn[e]||{})[t]}function Un(e){return function(e){return e in yn}(e)||mn(e)}const Fn=[].concat(vn,An),Dn=["type","field","bin","timeUnit","aggregate","autoCount","channel","mark","stack","scale","sort","axis","legend"].concat(Tn,Nn,wn,Cn,Sn);var _n,jn;(jn=_n||(_n={})).MARK="mark",jn.TRANSFORM="transform",jn.STACK="stack",jn.FORMAT="format",jn.CHANNEL="channel",jn.AGGREGATE="aggregate",jn.AUTOCOUNT="autoCount",jn.BIN="bin",jn.HAS_FN="hasFn",jn.TIMEUNIT="timeUnit",jn.FIELD="field",jn.TYPE="type",jn.SORT="sort",jn.SCALE="scale",jn.AXIS="axis",jn.LEGEND="legend",jn.WIDTH="width",jn.HEIGHT="height",jn.BACKGROUND="background",jn.PADDING="padding",jn.TITLE="title";const Pn="area",Rn="bar",$n="line",Bn="point",Ln="rect",Wn="rule",Hn="text",qn="tick",Gn="circle",zn="square";function Yn(e){return me(["line","area","trail"],e)}he(ye({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 Qn,Vn;["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].map((e=>e.substr(0,3))),(Vn=Qn||(Qn={})).YEAR="year",Vn.MONTH="month",Vn.DAY="day",Vn.DATE="date",Vn.HOURS="hours",Vn.MINUTES="minutes",Vn.SECONDS="seconds",Vn.MILLISECONDS="milliseconds",Vn.YEARMONTH="yearmonth",Vn.YEARMONTHDATE="yearmonthdate",Vn.YEARMONTHDATEHOURS="yearmonthdatehours",Vn.YEARMONTHDATEHOURSMINUTES="yearmonthdatehoursminutes",Vn.YEARMONTHDATEHOURSMINUTESSECONDS="yearmonthdatehoursminutesseconds",Vn.MONTHDATE="monthdate",Vn.MONTHDATEHOURS="monthdatehours",Vn.HOURSMINUTES="hoursminutes",Vn.HOURSMINUTESSECONDS="hoursminutesseconds",Vn.MINUTESSECONDS="minutesseconds",Vn.SECONDSMILLISECONDS="secondsmilliseconds",Vn.QUARTER="quarter",Vn.YEARQUARTER="yearquarter",Vn.QUARTERMONTH="quartermonth",Vn.YEARQUARTERMONTH="yearquartermonth",Vn.UTCYEAR="utcyear",Vn.UTCMONTH="utcmonth",Vn.UTCDAY="utcday",Vn.UTCDATE="utcdate",Vn.UTCHOURS="utchours",Vn.UTCMINUTES="utcminutes",Vn.UTCSECONDS="utcseconds",Vn.UTCMILLISECONDS="utcmilliseconds",Vn.UTCYEARMONTH="utcyearmonth",Vn.UTCYEARMONTHDATE="utcyearmonthdate",Vn.UTCYEARMONTHDATEHOURS="utcyearmonthdatehours",Vn.UTCYEARMONTHDATEHOURSMINUTES="utcyearmonthdatehoursminutes",Vn.UTCYEARMONTHDATEHOURSMINUTESSECONDS="utcyearmonthdatehoursminutesseconds",Vn.UTCMONTHDATE="utcmonthdate",Vn.UTCMONTHDATEHOURS="utcmonthdatehours",Vn.UTCHOURSMINUTES="utchoursminutes",Vn.UTCHOURSMINUTESSECONDS="utchoursminutesseconds",Vn.UTCMINUTESSECONDS="utcminutesseconds",Vn.UTCSECONDSMILLISECONDS="utcsecondsmilliseconds",Vn.UTCQUARTER="utcquarter",Vn.UTCYEARQUARTER="utcyearquarter",Vn.UTCQUARTERMONTH="utcquartermonth",Vn.UTCYEARQUARTERMONTH="utcyearquartermonth";const Kn={year:1,quarter:1,month:1,day:1,date:1,hours:1,minutes:1,seconds:1,milliseconds:1},Jn=ye(Kn);const Xn={utcyear:1,utcquarter:1,utcmonth:1,utcday:1,utcdate:1,utchours:1,utcminutes:1,utcseconds:1,utcmilliseconds:1};const Zn={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},er=Object.assign({},Xn,Zn);const tr=Object.assign({},Kn,Xn,{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},Zn);const nr={year:"setFullYear",month:"setMonth",date:"setDate",hours:"setHours",minutes:"setMinutes",seconds:"setSeconds",milliseconds:"setMilliseconds",quarter:null,day:null};function rr(e,t){const n=!!er[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 Jn)if(or(e,i))switch(i){case Qn.DAY:throw new Error("Cannot convert to TimeUnits containing 'day'");case Qn.QUARTER:{const{getDateMethod:e,setDateMethod:i}=ir("month",n);r[i](3*Math.floor(t[e]()/3));break}default:{const{getDateMethod:e,setDateMethod:o}=ir(i,n);r[o](t[e]())}}return r}function ir(e,t){const n=nr[e];return{setDateMethod:t?"setUTC"+n.substr(3):n,getDateMethod:"get"+(t?"UTC":"")+n.substr(3)}}function or(e,t){const n=e.indexOf(t);return n>-1&&(t!==Qn.SECONDS||0===n||"i"!==e.charAt(n-1))}const ar="?";function sr(e){return cr(e)||function(e){return!(void 0===e||null==e||!e.enum&&!e.name||dn.isArray(e))}(e)}function cr(e){return e===ar}function lr(e,t,n){return dn.extend({},{name:t,enum:n},e===ar?{}:e)}function ur(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 dr={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:ur(Kt),axisProps:ur(Ct),legendProps:ur(Ot)};function fr(e){if(mn(e))return dr[e.parent]+"-"+dr[e.parent+"Props"][e.child];if(dr[e])return dr[e];throw new Error("Default name undefined for "+e)}const pr=[!1,!0],hr={type:[void 0,$t.LOG],domain:[void 0],base:[void 0],exponent:[1,2],constant:[void 0],bins:[void 0],clamp:pr,nice:pr,reverse:pr,round:pr,zero:pr,padding:[void 0],paddingInner:[void 0],paddingOuter:[void 0],interpolate:[void 0],range:[void 0],rangeStep:[17,21],scheme:[void 0]},gr={zindex:[1,0],offset:[void 0],orient:[void 0],values:[void 0],bandPosition:[void 0],encoding:[void 0],domain:pr,domainColor:[void 0],domainDash:[void 0],domainDashOffset:[void 0],domainOpacity:[void 0],domainWidth:[void 0],formatType:[void 0],grid:pr,gridColor:[void 0],gridDash:[void 0],gridDashOffset:[void 0],gridOpacity:[void 0],gridWidth:[void 0],format:[void 0],labels:pr,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:pr,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]},mr={mark:[Bn,Rn,$n,Pn,Ln,qn,Hn],channel:[Ee,Te,ve,be,Fe,ke],aggregate:[void 0,"mean"],autoCount:pr,bin:pr,hasFn:pr,timeUnit:[void 0,Qn.YEAR,Qn.MONTH,Qn.MINUTES,Qn.SECONDS],field:[void 0],type:[Rt,jt,_t,Pt],sort:["ascending","descending"],stack:["zero","normalize","center",null],value:[void 0],format:[void 0],title:[void 0],scale:[!0],axis:pr,legend:pr,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:hr,axisProps:gr,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 yr(e,t,n){if("field"===e||mn(e)&&"sort"===e.parent&&"field"===e.child)return t.fieldNames();let r;if(r=mn(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 vr={verbose:!1,defaultSpecConfig:{line:{point:!0},scale:{useUnaggregatedDomain:!0}},propertyPrecedence:Dn.map(kn),enum:mr,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:Ee,preferredTemporalAxis:Ee,preferredOrdinalAxis:Te,preferredNominalAxis:Te,preferredFacet:ve,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},br={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 xr=["count","sum","distinct","valid","missing"];function Er(e){return pe(e)&&(e=function(e,t){return pe(e)?{maxbins:Sr(t)}:"binned"===e?{binned:!0}:e.maxbins||e.step?e:Object.assign({},e,{maxbins:Sr(t)})}(e,void 0)),"bin"+ye(e).map((t=>function(e){const t=e.replace(/\W/g,"_");return(e.match(/^\d+/)?"_":"")+t}(`_${t}_${e[t]}`))).join("")}function Tr(e){return!0===e||function(e){return oe(e)}(e)&&!e.binned}function Sr(e){switch(e){case ve:case be:case Fe:case ke:case Me:case Ie:case Pe:case De:case _e:case je:case Ue:return 6;default:return 10}}function Nr(e){return!!e&&!!e.condition&&!ie(e.condition)&&wr(e.condition)}function wr(e){return!(!e||!e.field&&"count"!==e.aggregate)}function Cr(e){return wr(e)&&ae(e.field)}function Ar(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;Tr(s)?(r=Er(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}[${se(re(e).join("."))}]`}(n,t.expr)+o:function(e){return`${re(e).map((e=>e.replace(".","\\."))).join("\\.")}`}(n)+o}function Or(e){switch(e.type){case"nominal":case"ordinal":case"geojson":return!0;case"quantitative":return!!e.bin;case"temporal":return!1}throw new Error(Mt.invalidFieldType(e.type))}he(["mean","average","median","q1","q3","min","max"]);const kr={compatible:!0};function Mr(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!Or(e)}(e)?{compatible:!1,warning:Mt.facetChannelShouldBeDiscrete(t)}:kr;case"x":case"y":case"color":case"fill":case"stroke":case"text":case"detail":case"key":case"tooltip":case"href":return kr;case"longitude":case"longitude2":case"latitude":case"latitude2":return n!==_t?{compatible:!1,warning:`Channel ${t} should be used with a quantitative field only, not ${e.type} field.`}:kr;case"opacity":case"fillOpacity":case"strokeOpacity":case"strokeWidth":case"size":case"x2":case"y2":return"nominal"!==n||e.sort?kr:{compatible:!1,warning:`Channel ${t} should not be used with an unsorted discrete field.`};case"shape":return me(["ordinal","nominal","geojson"],e.type)?kr:{compatible:!1,warning:"Shape channel should be used with only either discrete or geojson data."};case"order":return"nominal"!==e.type||"sort"in e?kr:{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 Ir(e,t,n,r){const i=function(e,t,n){switch(t.type){case"nominal":case"ordinal":return Ge(e)||"discrete"===St(e)?("shape"===e&&"ordinal"===t.type&&Ft(Mt.discreteChannelCannotEncode(e,"ordinal")),"ordinal"):me(["x","y"],e)&&me(["rect","bar","rule"],n)?"band":"point";case"temporal":return Ge(e)?"time":"discrete"===St(e)?(Ft(Mt.discreteChannelCannotEncode(e,"temporal")),"ordinal"):"time";case"quantitative":return Ge(e)?Tr(t.bin)?"bin-ordinal":"linear":"discrete"===St(e)?(Ft(Mt.discreteChannelCannotEncode(e,"quantitative")),"ordinal"):"linear";case"geojson":return}throw new Error(Mt.invalidFieldType(t.type))}(t,n,r),{type:o}=e;return function(e){return!!vt[e]}(t)?void 0!==o?an(t,o)?on(o,n.type)?o:(Ft(Mt.scaleTypeNotWorkWithFieldDef(o,i)),i):(Ft(Mt.scaleTypeNotWorkWithChannel(t,o,i)),i):i:null}var Ur,Fr;function Dr(e){return e===jt||e===Rt||e===Ur.KEY}(Fr=Ur||(Ur={})).QUANTITATIVE=_t,Fr.ORDINAL=jt,Fr.TEMPORAL=Pt,Fr.NOMINAL=Rt,Fr.KEY="key";class _r{constructor(e=null){this.index=e?Object.assign({},e):{}}has(e){return kn(e)in this.index}get(e){return this.index[kn(e)]}set(e,t){return this.index[kn(e)]=t,this}setByKey(e,t){this.index[e]=t}map(e){const t=new _r;for(const n in this.index)t.index[n]=e(this.index[n]);return t}size(){return dn.keys(this.index).length}duplicate(){return new _r(this.index)}}function jr(e,t){const n=e&&e[t];return!!n&&(ie(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)):wr(n)||Nr(n))}const Pr={zero:1,center:1,normalize:1};const Rr=[Rn,Pn,Wn,Bn,Gn,zn,$n,Hn,qn],$r=[Rn,Pn];function Br(e,t,n,r={}){const i=function(e){return e.type}(e)?e.type:e;if(!me(Rr,i))return null;const o=function(e){const t=e.x,n=e.y;if(wr(t)&&wr(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(wr(t)&&"quantitative"===t.type)return"x";if(wr(n)&&"quantitative"===n.type)return"y"}}(t);if(!o)return null;const a=t[o],s=Cr(a)?Ar(a,{}):void 0,c="x"===o?"y":"x",l=t[c],u=Cr(l)?Ar(l,{}):void 0,d=ut.reduce(((e,n)=>{if("tooltip"!==n&&jr(t,n)){const r=t[n];(ie(r)?r:[r]).forEach((t=>{const r=function(e){return wr(e)?e:Nr(e)?e.condition:void 0}(t);if(r.aggregate)return;const i=Cr(r)?Ar(r,{}):void 0;(!i||i!==u&&i!==s)&&e.push({channel:n,fieldDef:r})}))}return e}),[]);let f;if(void 0!==a.stack?f=pe(a.stack)?a.stack?"zero":null:a.stack:d.length>0&&(f=me($r,i)?function(...e){for(const t of e)if(void 0!==t)return t}(n,"zero"):n),!f||!Pr[f])return null;if(a.scale&&a.scale.type&&a.scale.type!==$t.LINEAR){if(r.disallowNonLinearStack)return null;Ft(Mt.cannotStackNonLinearScale(a.scale.type))}return jr(t,o===Ee?Se:Ne)?(void 0!==a.stack&&Ft(Mt.cannotStackRangedMark(o)),null):(a.aggregate&&!me(xr,a.aggregate)&&Ft(Mt.stackNonSummativeAggregate(a.aggregate)),{groupbyChannel:l?c:void 0,fieldChannel:o,impute:Yn(i),stackBy:d,offset:f})}function Lr(e){if(!function(e){if(sr(e.mark))return!1;const t=[_n.STACK,_n.CHANNEL,_n.MARK,_n.FIELD,_n.AGGREGATE,_n.AUTOCOUNT,_n.SCALE,In("scale","type"),_n.TYPE],n=dn.toMap((i=Fn,o=t,i.filter((function(e){return!fn(o,e)})))),r=e.encodings.filter((e=>!ri(e)));var i,o;for(const a of r)if(Wr(a,{exclude:n}))return!1;return!0}(e))return null;const t=ai(e.encodings,{schema:null,wildcardMode:"null"});return Br(e.mark,t,void 0,{disallowNonLinearStack:!0})}function Wr(e,t={}){if(!dn.isObject(e))return!1;for(const n in e)if(e.hasOwnProperty(n)){if(sr(e[n])&&(!t.exclude||!t.exclude[n])||Wr(e[n],t))return!0}return!1}function Hr(e){return e.map((e=>{return t=e,e=>void 0!==t[e]?t[e]:e;var t}))}function qr(e,t){return sr(e)?!cr(e)&&e.enum?ar+JSON.stringify(e.enum):ar:t?t(e):e}function Gr(e,t){return t?t(e):e}const zr=new _r,Yr=[].concat(Dn,Sn,[_n.TRANSFORM,_n.STACK],On).reduce(((e,t)=>e.set(t,!0)),new _r),Qr={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 Vr(e,t=Yr,n=zr){const r=[];let i;if(t.get(_n.MARK)&&r.push(qr(e.mark,n.get(_n.MARK))),e.transform&&e.transform.length>0&&r.push("transform:"+JSON.stringify(e.transform)),t.get(_n.STACK)&&(i=Lr(e)),e.encodings){const o=e.encodings.reduce(((e,r)=>{if(!ri(r)){let o;o=i&&r.channel===i.fieldChannel?Kr(Object.assign({},r,{stack:i.offset}),t,n):Kr(r,t,n),o&&e.push(o)}return e}),[]).sort().join("|");o&&r.push(o)}for(let o of On){const n=o.toString();if(t.get(o)&&e[n]){const t=e[n];r.push(`${n}=${JSON.stringify(t)}`)}}return r.join("|")}function Kr(e,t=Yr,n=zr){const r=[];if(t.get(_n.CHANNEL)&&r.push(qr(e.channel,n.get(_n.CHANNEL))),ti(e)){const i=Jr(e,t,n);i&&r.push(i)}else ei(e)?r.push(e.value):ni(e)&&r.push("autocount()");return r.join(":")}function Jr(e,t=Yr,n=zr){if(t.get(_n.AGGREGATE)&&ri(e))return"-";const r=function(e,t,n){if(t.get(_n.AGGREGATE)&&e.aggregate&&!sr(e.aggregate))return Gr(e.aggregate,n.get(_n.AGGREGATE));if(t.get(_n.AGGREGATE)&&ii(e))return Gr("count",n.get(_n.AGGREGATE));if(t.get(_n.TIMEUNIT)&&e.timeUnit&&!sr(e.timeUnit))return Gr(e.timeUnit,n.get(_n.TIMEUNIT));if(t.get(_n.BIN)&&e.bin&&!sr(e.bin))return"bin";{let n=null;for(const r of[_n.AGGREGATE,_n.AUTOCOUNT,_n.TIMEUNIT,_n.BIN]){const i=e[r];t.get(r)&&e[r]&&sr(i)&&(n=n||{},n[r]=cr(i)?i:i.enum)}return n&&e.hasFn&&(n.hasFn=!0),n}}(e,t,n),i=function(e,t,n){const r=[];if(!dn.isBoolean(e.bin)&&!cr(e.bin)){const i=e.bin;for(const e in i){const o=In("bin",e);o&&t.get(o)&&void 0!==i[e]&&r.push({key:e,value:qr(i[e],n.get(o))})}r.sort(((e,t)=>e.key.localeCompare(t.key)))}for(const i of[_n.SCALE,_n.SORT,_n.STACK,_n.AXIS,_n.LEGEND])if((sr(e.channel)||Qr[i][e.channel])&&t.get(i)&&void 0!==e[i]){const o=e[i];if(dn.isBoolean(o)||null===o)r.push({key:i+"",value:o||!1});else if(dn.isString(o))r.push({key:i+"",value:Gr(JSON.stringify(o),n.get(i))});else{let e=[];for(const r in o){const a=In(i,r);a&&t.get(a)&&void 0!==o[r]&&e.push({key:r,value:qr(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(ti(e)){if(o=t.get("field")?qr(e.field,n.get("field")):"...",t.get(_n.TYPE))if(sr(e.type))o+=","+qr(e.type,n.get(_n.TYPE));else{o+=","+qr(((e.type||_t)+"").substr(0,1),n.get(_n.TYPE))}o+=i.map((e=>{let t=e.value instanceof Array?"["+e.value+"]":e.value;return","+e.key+"="+t})).join("")}else ni(e)&&(o="*,q");if(!o)return null;if(r){return(dn.isString(r)?r:ar+(dn.keys(r).length>0?JSON.stringify(r):""))+"("+o+")"}return o}function Xr(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 Zr;function ei(e){return null!=e&&void 0!==e.value}function ti(e){return null!=e&&(e.field||"count"===e.aggregate)}function ni(e){return null!=e&&"autoCount"in e}function ri(e){return ni(e)&&!1===e.autoCount}function ii(e){return ni(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 _t:return"quantitative";case"t":case Pt:return"temporal";case"o":case jt:return"ordinal";case"n":case Rt: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))}En(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)dn.isArray(o[e])?r[e]={enum:o[e]}:r[e]=o[e];return Object.assign({},r,t(Xr(e.substring(i+2,e.length-1),",",2)))}{let n=e.substring(0,e.indexOf("(")),r=Xr(e.substring(n.length+1,e.length-1),",",2);if(ae(i=n)&&br[i])return Object.assign({aggregate:n},t(r));if(tr[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(Xr(n,",",2));return Object.assign({channel:e},i)},e.rawFieldDef=t,e.getClosingIndex=n,e.fn=r}(Zr||(Zr={}));const oi=[_n.AGGREGATE,_n.BIN,_n.TIMEUNIT,_n.FIELD,_n.TYPE,_n.SCALE,_n.SORT,_n.AXIS,_n.LEGEND,_n.STACK,_n.FORMAT];function ai(e,t){const{wildcardMode:n="skip"}=t;let r={};for(const i of e){if(ri(i))continue;const{channel:e}=i;if(sr(e))throw new Error("Cannot convert wildcard channel to a fixed channel");const n=ei(i)?si(i):ci(i,t);if(null!==n)r[e]=n;else if("null"===t.wildcardMode)return null}return r}function si(e){const{value:t}=e;return sr(t)?null:{value:t}}function ci(e,t={}){const{props:n=oi,schema:r,wildcardMode:i="skip"}=t;if(ti(e)){const t={};for(const o of n){let n=e[o];if(sr(n)){if("skip"===i)continue;return null}if(void 0!==n){if(!(!Qr[o]||Qr[o][e.channel]))continue;if(En(o)&&dn.isObject(n)){n=Object.assign({},n);for(const e in n)if(sr(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===_n.SCALE&&r&&e.type===jt){const n=e.scale,{ordinalDomain:i}=r.fieldSchema(e.field);null!==n&&i&&(t[_n.SCALE]=Object.assign({domain:i},dn.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 li(e){return ti(e)?!ui(e)&&"temporal"!==e.type:ni(e)}function ui(e){if(ti(e)){const t=ci(e,{props:["bin","timeUnit","type"]});return Or(t)||!!t.timeUnit}return!1}function di(e){const t=!0===e.scale||e.scale===ar?{}:e.scale||{},{type:n,channel:r,timeUnit:i,bin:o}=e;if(sr(t.type)||sr(n)||sr(r)||sr(o))return;if(t.type)return t.type;if("temporal"===n&&sr(i))return;if("quantitative"===n&&sr(o))return;const a={type:n===Ur.KEY?"nominal":n,bin:o};return Ir({type:t.type},r,a,void 0)}var fi={exports:{}},pi=new Date,hi=new Date;function gi(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 gi((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 pi.setTime(+t),hi.setTime(+r),e(pi),e(hi),Math.floor(n(pi,hi))},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 mi=gi((function(){}),(function(e,t){e.setTime(+e+t)}),(function(e,t){return t-e}));mi.every=function(e){return e=Math.floor(e),isFinite(e)&&e>0?e>1?gi((function(t){t.setTime(Math.floor(t/e)*e)}),(function(t,n){t.setTime(+t+n*e)}),(function(t,n){return(n-t)/e})):mi:null};const yi=gi((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()})),vi=gi((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()})),bi=gi((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()})),xi=gi((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 Ei(e){return gi((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 Ti=Ei(0),Si=Ei(1),Ni=Ei(2),wi=Ei(3),Ci=Ei(4),Ai=Ei(5),Oi=Ei(6);const ki=gi((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()})),Mi=gi((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()})),Ii=gi((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()})),Ui=gi((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()})),Fi=gi((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()})),Di=gi((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 _i(e){return gi((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 ji=_i(0),Pi=_i(1),Ri=_i(2),$i=_i(3),Bi=_i(4),Li=_i(5),Wi=_i(6);const Hi=gi((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()})),qi=gi((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 Gi=mi.range,zi=yi.range,Yi=vi.range,Qi=bi.range,Vi=xi.range,Ki=Ti.range,Ji=Si.range,Xi=Ni.range,Zi=wi.range,eo=Ci.range,to=Ai.range,no=Oi.range,ro=Ti.range,io=ki.range,oo=Mi.range,ao=mi,so=Gi,co=Ii.range,lo=Ui.range,uo=Fi.range,fo=Di.range,po=ji.range,ho=Pi.range,go=Ri.range,mo=$i.range,yo=Bi.range,vo=Li.range,bo=Wi.range,xo=ji.range,Eo=Hi.range,To=qi.range;const So=n(Object.freeze(Object.defineProperty({__proto__:null,day:xi,days:Vi,friday:Ai,fridays:to,hour:bi,hours:Qi,interval:gi,millisecond:mi,milliseconds:Gi,minute:vi,minutes:Yi,monday:Si,mondays:Ji,month:ki,months:io,saturday:Oi,saturdays:no,second:yi,seconds:zi,sunday:Ti,sundays:Ki,thursday:Ci,thursdays:eo,tuesday:Ni,tuesdays:Xi,utcDay:Di,utcDays:fo,utcFriday:Li,utcFridays:vo,utcHour:Fi,utcHours:uo,utcMillisecond:ao,utcMilliseconds:so,utcMinute:Ui,utcMinutes:lo,utcMonday:Pi,utcMondays:ho,utcMonth:Hi,utcMonths:Eo,utcSaturday:Wi,utcSaturdays:bo,utcSecond:Ii,utcSeconds:co,utcSunday:ji,utcSundays:po,utcThursday:Bi,utcThursdays:yo,utcTuesday:Ri,utcTuesdays:go,utcWednesday:$i,utcWednesdays:mo,utcWeek:ji,utcWeeks:xo,utcYear:qi,utcYears:To,wednesday:wi,wednesdays:Zi,week:Ti,weeks:ro,year:Mi,years:oo},Symbol.toStringTag,{value:"Module"})));var No,wo,Co;function Ao(){if(No)return fi.exports;No=1;var e=So,t=new Date,n=new Date(0,0,1).setFullYear(0),r=new Date(Date.UTC(0,0,1)).setUTCFullYear(0);function i(e){return t.setTime(+e),t}function o(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 a(e,t,n,r,i,a){return o(e,(function(e){return t.offset(n,e)}),(function(e){return t.count(n,e)}),r,i,a)}var s=[a("second",e.second,n),a("minute",e.minute,n),a("hour",e.hour,n),a("day",e.day,n,[1,7]),a("month",e.month,n,[1,3,6]),a("year",e.year,n),o("seconds",(function(e){return new Date(1970,0,1,0,0,e)}),(function(e){return i(e).getSeconds()}),null,0,59),o("minutes",(function(e){return new Date(1970,0,1,0,e)}),(function(e){return i(e).getMinutes()}),null,0,59),o("hours",(function(e){return new Date(1970,0,1,e)}),(function(e){return i(e).getHours()}),null,0,23),o("weekdays",(function(e){return new Date(1970,0,4+e)}),(function(e){return i(e).getDay()}),[1],0,6),o("dates",(function(e){return new Date(1970,0,e)}),(function(e){return i(e).getDate()}),[1],1,31),o("months",(function(e){return new Date(1970,e%12,1)}),(function(e){return i(e).getMonth()}),[1],0,11)],c=[a("second",e.utcSecond,r),a("minute",e.utcMinute,r),a("hour",e.utcHour,r),a("day",e.utcDay,r,[1,7]),a("month",e.utcMonth,r,[1,3,6]),a("year",e.utcYear,r),o("seconds",(function(e){return new Date(Date.UTC(1970,0,1,0,0,e))}),(function(e){return i(e).getUTCSeconds()}),null,0,59),o("minutes",(function(e){return new Date(Date.UTC(1970,0,1,0,e))}),(function(e){return i(e).getUTCMinutes()}),null,0,59),o("hours",(function(e){return new Date(Date.UTC(1970,0,1,e))}),(function(e){return i(e).getUTCHours()}),null,0,23),o("weekdays",(function(e){return new Date(Date.UTC(1970,0,4+e))}),(function(e){return i(e).getUTCDay()}),[1],0,6),o("dates",(function(e){return new Date(Date.UTC(1970,0,e))}),(function(e){return i(e).getUTCDate()}),[1],1,31),o("months",(function(e){return new Date(Date.UTC(1970,e%12,1))}),(function(e){return i(e).getUTCMonth()}),[1],0,11)],l=[[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 u(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=l[0];for(i=1,o=l.length;i<o;++i)if(t>(s=l[i])[0]){if((a=t/s[0])>r)return e[l[i-1][1]];if(a>=n)return e[s[1]]}return e[l[o-1][1]]}(e,t,n,r)},r}return fi.exports=u(s),fi.exports.utc=u(c),fi.exports}var Oo=function(){if(Co)return wo;Co=1;var e=un(),t=Ao();function n(t){if(!t)throw Error("Missing binning options.");var n,o,a,s,c,l,u,d=t.maxbins||15,f=t.base||10,p=Math.log(f),h=t.div||[5,2],g=t.min,m=t.max,y=m-g;if(t.step)n=t.step;else if(t.steps)n=t.steps[Math.min(t.steps.length-1,function(t,n,r,i){for(;r<i;){var o=r+i>>>1;e.cmp(t[o],n)<0?r=o+1:i=o}return r}(t.steps,y/d,0,t.steps.length))];else{for(o=Math.ceil(Math.log(d)/p),a=t.minstep||0,n=Math.max(a,Math.pow(f,Math.round(Math.log(y)/p)-o));Math.ceil(y/n)>d;)n*=f;for(l=0;l<h.length;++l)(c=n/h[l])>=a&&y/c<=d&&(n=c)}return s=(c=Math.log(n))>=0?0:1+~~(-c/p),u=Math.pow(f,-s-1),{start:g=Math.min(g,Math.floor(g/n+u)*n),stop:m=Math.ceil(m/n)*n,step:n,unit:{precision:s},value:r,index:i}}function r(e){return this.step*Math.floor(e/this.step+1e-15)}function i(e){return Math.floor((e-this.start)/this.step+1e-15)}function o(e){return this.unit.date(r.call(this,e))}function a(e){return i.call(this,this.unit.unit(e))}return n.date=function(e){if(!e)throw Error("Missing date binning options.");var r=e.utc?t.utc:t,i=e.min,s=e.max,c=e.maxbins||20,l=e.minbins||4,u=+s-+i,d=e.unit?r[e.unit]:r.find(u,l,c),f=n({min:null!=d.min?d.min:d.unit(i),max:null!=d.max?d.max:d.unit(s),maxbins:c,minstep:d.minstep,steps:d.step});return f.unit=d,f.index=a,e.raw||(f.value=o),f},wo=n}();const ko=t(Oo);var Mo,Io;function Uo(){if(Io)return Mo;Io=1;var e=un(),t="__types__",n={boolean:e.boolean,integer:e.number,number:e.number,date:e.date,string:function(e){return null==e||""===e?null:e+""}},r={boolean:function(t){return"true"===t||"false"===t||e.isBoolean(t)},integer:function(e){return r.number(e)&&(e=+e)==~~e},number:function(t){return!isNaN(+t)&&!e.isDate(t)},date:function(e){return!isNaN(Date.parse(e))}};function i(t){return e.keys(t)}function o(e){return"["+e+"]"}function a(n,r){var i,o,a;if(n=e.array(n),r=e.$(r),n[t]&&(i=r(n[t]),e.isString(i)))return i;for(o=0,a=n.length;!e.isValid(i)&&o<a;++o)i=r?r(n[o]):n[o];return e.isDate(i)?"date":e.isNumber(i)?"number":e.isBoolean(i)?"boolean":e.isString(i)?"string":null}function s(t,n){var i,o,a;t=e.array(t),n=e.$(n);var s=["boolean","integer","number","date"];for(i=0;i<t.length;++i){for(a=n?n(t[i]):t[i],o=0;o<s.length;++o)e.isValid(a)&&!r[s[o]](a)&&(s.splice(o,1),o-=1);if(0===s.length)return"string"}return s[0]}return a.annotation=function(e,n){if(!n)return e&&e[t]||null;e[t]=n},a.all=function(t,n){if(t.length){var r=n?e.identity:(n=i(t[0]),o);return n.reduce((function(e,n){return e[n]=a(t,r(n)),e}),{})}},a.infer=s,a.inferAll=function(t,n){var r=n?e.identity:(n=i(t[0]),o);return n.reduce((function(e,n){return e[n]=s(t,r(n)),e}),{})},a.parsers=n,Mo=a}var Fo,Do,_o=Uo(),jo={exports:{}},Po={exports:{}};var Ro=(Do||(Do=1,function(e){var t=un(),n=Uo(),r=(Fo||(Fo=1,function(e){var t=un(),n=e.exports;n.repeat=function(e,t){var n,r=Array(t);for(n=0;n<t;++n)r[n]=e;return r},n.zeros=function(e){return n.repeat(0,e)},n.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},n.random={},n.random.uniform=function(e,t){void 0===t&&(t=void 0===e?1:e,e=0);var r=t-e,i=function(){return e+r*Math.random()};return i.samples=function(e){return n.zeros(e).map(i)},i.pdf=function(n){return n>=e&&n<=t?1/r:0},i.cdf=function(n){return n<e?0:n>t?1:(n-e)/r},i.icdf=function(t){return t>=0&&t<=1?e+t*r:NaN},i},n.random.integer=function(e,t){void 0===t&&(t=e,e=0);var r=t-e,i=function(){return e+Math.floor(r*Math.random())};return i.samples=function(e){return n.zeros(e).map(i)},i.pdf=function(n){return n===Math.floor(n)&&n>=e&&n<t?1/r:0},i.cdf=function(n){var i=Math.floor(n);return i<e?0:i>=t?1:(i-e+1)/r},i.icdf=function(t){return t>=0&&t<=1?e-1+Math.floor(t*r):NaN},i},n.random.normal=function(e,t){var r;e=e||0,t=t||1;var i=function(){var n,i,o=0,a=0;if(void 0!==r)return o=r,r=void 0,o;do{n=(o=2*Math.random()-1)*o+(a=2*Math.random()-1)*a}while(0===n||n>1);return i=Math.sqrt(-2*Math.log(n)/n),r=e+a*i*t,e+o*i*t};return i.samples=function(e){return n.zeros(e).map(i)},i.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},i.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},i.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},i},n.random.bootstrap=function(e,r){var i=e.filter(t.isValid),o=i.length,a=r?n.random.normal(0,r):null,s=function(){return i[~~(Math.random()*o)]+(a?a():0)};return s.samples=function(e){return n.zeros(e).map(s)},s}}(Po)),Po.exports),i=e.exports;function o(e,t,n){var o=e&&e.nullh||0,a=r.random.normal(0,1),s=i.mean(t,n),c=i.stdev(t,n)/Math.sqrt(i.count.valid(t,n));if(0===c)return s-o==0?1:0;var l=(s-o)/c;return 2*a.cdf(-Math.abs(l))}function a(e,n,r,o){var a,s=o?n.map(t.$(r)):n,c=o?n.map(t.$(o)):r,l=i.count(s),u=i.count(c),d=Array();if(l!==u)throw Error("Array lengths must match.");for(a=0;a<l;++a)t.isValid(s[a])&&t.isValid(c[a])&&d.push(s[a]-c[a]);return i.z.test(d,e&&e.nullh||0)}function s(e,n,o,a){var s=a?n.map(t.$(o)):n,c=a?n.map(t.$(a)):o,l=i.count.valid(s),u=i.count.valid(c),d=r.random.normal(0,1),f=i.mean(s)-i.mean(c)-(e&&e.nullh||0),p=Math.sqrt(i.variance(s)/l+i.variance(c)/u);if(0===p)return 0===f?1:0;var h=f/p;return 2*d.cdf(-Math.abs(h))}i.unique=function(e,n,r){n=t.$(n),r=r||[];var i,o,a,s={};for(o=0,a=e.length;o<a;++o)(i=n?n(e[o]):e[o])in s||(s[i]=1,r.push(i));return r},i.count=function(e){return e&&e.length||0},i.count.valid=function(e,n){n=t.$(n);var r,i,o,a=0;for(i=0,o=e.length;i<o;++i)r=n?n(e[i]):e[i],t.isValid(r)&&(a+=1);return a},i.count.missing=function(e,n){n=t.$(n);var r,i,o=0;for(r=0,i=e.length;r<i;++r)null==(n?n(e[r]):e[r])&&(o+=1);return o},i.count.distinct=function(e,n){n=t.$(n);var r,i,o,a={},s=0;for(i=0,o=e.length;i<o;++i)(r=n?n(e[i]):e[i])in a||(a[r]=1,s+=1);return s},i.count.map=function(e,n){n=t.$(n);var r,i,o,a={};for(i=0,o=e.length;i<o;++i)a[r=n?n(e[i]):e[i]]=r in a?a[r]+1:1;return a},i.median=function(e,n){return n&&(e=e.map(t.$(n))),e=e.filter(t.isValid).sort(t.cmp),i.quantile(e,.5)},i.quartile=function(e,n){n&&(e=e.map(t.$(n))),e=e.filter(t.isValid).sort(t.cmp);var r=i.quantile;return[r(e,.25),r(e,.5),r(e,.75)]},i.quantile=function(e,n,r){void 0===r&&(r=n,n=t.identity),n=t.$(n);var i=(e.length-1)*r+1,o=Math.floor(i),a=+n(e[o-1]),s=i-o;return s?a+s*(n(e[o])-a):a},i.sum=function(e,n){n=t.$(n);for(var r,i=0,o=0,a=e.length;o<a;++o)r=n?n(e[o]):e[o],t.isValid(r)&&(i+=r);return i},i.mean=function(e,n){n=t.$(n);var r,i,o,a,s=0;for(r=0,o=0,i=e.length;r<i;++r)a=n?n(e[r]):e[r],t.isValid(a)&&(s+=(a-s)/++o);return s},i.mean.geometric=function(e,n){n=t.$(n);var r,i,o,a,s=1;for(a=0,r=0,i=e.length;a<i;++a)if(o=n?n(e[a]):e[a],t.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},i.mean.harmonic=function(e,n){n=t.$(n);var r,i,o,a,s=0;for(a=0,r=0,i=e.length;a<i;++a)o=n?n(e[a]):e[a],t.isValid(o)&&(s+=1/o,++r);return r/s},i.variance=function(e,n){if(n=t.$(n),!t.isArray(e)||e.length<2)return 0;var r,i,o,a,s=0,c=0;for(i=0,o=0;i<e.length;++i)a=n?n(e[i]):e[i],t.isValid(a)&&(c+=(r=a-s)*(a-(s+=r/++o)));return c/=o-1},i.stdev=function(e,t){return Math.sqrt(i.variance(e,t))},i.modeskew=function(e,t){var n=i.mean(e,t),r=i.median(e,t),o=i.stdev(e,t);return 0===o?0:(n-r)/o},i.min=function(e,t){return i.extent(e,t)[0]},i.max=function(e,t){return i.extent(e,t)[1]},i.extent=function(e,n){n=t.$(n);var r,i,o,a,s=e.length;for(a=0;a<s;++a)if(o=n?n(e[a]):e[a],t.isValid(o)){r=i=o;break}for(;a<s;++a)o=n?n(e[a]):e[a],t.isValid(o)&&(o<r&&(r=o),o>i&&(i=o));return[r,i]},i.extent.index=function(e,n){n=t.$(n);var r,i,o,a,s=-1,c=-1,l=e.length;for(a=0;a<l;++a)if(o=n?n(e[a]):e[a],t.isValid(o)){r=i=o,s=c=a;break}for(;a<l;++a)o=n?n(e[a]):e[a],t.isValid(o)&&(o<r&&(r=o,s=a),o>i&&(i=o,c=a));return[s,c]},i.dot=function(e,n,r){var i,o,a=0;if(r)for(n=t.$(n),r=t.$(r),i=0;i<e.length;++i)(o=n(e[i])*r(e[i]))==o&&(a+=o);else{if(e.length!==n.length)throw Error("Array lengths must match.");for(i=0;i<e.length;++i)(o=e[i]*n[i])==o&&(a+=o)}return a},i.dist=function(e,n,r,i){var o,a,s=t.isFunction(r)||t.isString(r),c=e,l=s?e:n,u=s?i:r,d=2===u||null==u,f=e.length,p=0;for(s&&(n=t.$(n),r=t.$(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)},i.cohensd=function(e,n,r){var o=r?e.map(t.$(n)):e,a=r?e.map(t.$(r)):n,s=i.mean(o),c=i.mean(a),l=i.count.valid(o),u=i.count.valid(a);if(l+u-2<=0)return 0;var d=i.variance(o),f=i.variance(a),p=Math.sqrt(((l-1)*d+(u-1)*f)/(l+u-2));return 0===p?0:(s-c)/p},i.covariance=function(e,n,r){var o,a,s,c,l,u=r?e.map(t.$(n)):e,d=r?e.map(t.$(r)):n,f=u.length,p=i.mean(u),h=i.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=t.isValid(a),s=d[o],l=t.isValid(s),c&&l)g+=(a-p)*(s-h),++m;else if(c||l)throw Error("Valid values must align.");return g/(m-1)},i.rank=function(e,n){n=t.$(n)||t.identity;var r,i,o,a=e.map((function(e,t){return{idx:t,val:n(e)}})).sort(t.comparator("val")),s=e.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},i.cor=function(e,n,r){var o=r;r=o?e.map(t.$(r)):n,n=o?e.map(t.$(n)):e;var a=i.dot(n,r),s=i.mean(n),c=i.mean(r),l=i.stdev(n),u=i.stdev(r),d=e.length;return(a-d*s*c)/((d-1)*l*u)},i.cor.rank=function(e,t,n){var r,o,a,s=n?i.rank(e,t):i.rank(e),c=n?i.rank(e,n):i.rank(t),l=e.length;for(r=0,o=0;r<l;++r)o+=(a=s[r]-c[r])*a;return 1-6*o/(l*(l*l-1))},i.cor.dist=function(e,n,r){var o,a,s,c,l=r?e.map(t.$(n)):e,u=r?e.map(t.$(r)):n,d=i.dist.mat(l),f=i.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))},i.linearRegression=function(e,n,r){var o,a,s=r?e.map(t.$(n)):e,c=r?e.map(t.$(r)):n,l=s.length,u=i.covariance(s,c),d=i.stdev(s),f=i.stdev(c),p=u/(d*d),h=i.mean(c)-p*i.mean(s),g={slope:p,intercept:h,R:u/(d*f),rss:0};for(a=0;a<l;++a)t.isValid(s[a])&&t.isValid(c[a])&&(o=p*s[a]+h-c[a],g.rss+=o*o);return g},i.bootstrap={},i.bootstrap.ci=function(e,n,o,a,s){var c,l,u,d,f,p,h;for(t.isFunction(n)||t.isString(n)?(c=e.map(t.$(n)),l=o,u=a,d=s):(c=e,l=n,u=o,d=a),l=l?+l:1e3,u=u||.05,f=r.random.bootstrap(c,d),h=0,p=Array(l);h<l;++h)p[h]=i.mean(f.samples(c.length));return p.sort(t.numcmp),[i.quantile(p,u/2),i.quantile(p,1-u/2)]},i.z={},i.z.ci=function(e,n,o){var a=e,s=n;(t.isFunction(n)||t.isString(n))&&(a=e.map(t.$(n)),s=o);var c=.05===(s=s||.05)?1.96:r.random.normal(0,1).icdf(1-s/2),l=i.mean(a),u=i.stdev(a)/Math.sqrt(i.count.valid(a));return[l-c*u,l+c*u]},i.z.test=function(e,n,r,i){return t.isFunction(r)||t.isString(r)?(i&&i.paired?a:s)(i,e,n,r):t.isArray(n)?(r&&r.paired?a:s)(r,e,n):t.isFunction(n)||t.isString(n)?o(r,e,n):o(n,e)},i.dist.mat=function(e){var t,n,i,o=e.length,a=o*o,s=Array(a),c=r.zeros(o),l=0;for(n=0;n<o;++n)for(s[n*o+n]=0,i=n+1;i<o;++i)s[n*o+i]=t=Math.abs(e[n]-e[i]),s[i*o+n]=t,c[n]+=t,c[i]+=t;for(n=0;n<o;++n)l+=c[n],c[n]/=o;for(l/=a,n=0;n<o;++n)for(i=n;i<o;++i)s[n*o+i]+=l-c[n]-c[i],s[i*o+n]=s[n*o+i];return s},i.entropy=function(e,n){n=t.$(n);var r,i,o=0,a=0,s=e.length;for(r=0;r<s;++r)o+=n?n(e[r]):e[r];if(0===o)return 0;for(r=0;r<s;++r)(i=(n?n(e[r]):e[r])/o)&&(a+=i*Math.log(i));return-a/Math.LN2},i.mutual=function(e,n,r,i){var o,a,s,c=i?e.map(t.$(n)):e,l=i?e.map(t.$(r)):n,u=i?e.map(t.$(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]},i.mutual.info=function(e,t,n,r){return i.mutual(e,t,n,r)[0]},i.mutual.dist=function(e,t,n,r){return i.mutual(e,t,n,r)[1]},i.profile=function(e,r){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<e.length;++s)v[c=r?r(e[s]):e[s]]=c in v?v[c]+1:(p+=1,1),null==c?++f:t.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(t.cmp),{type:n(e,r),unique:v,count:e.length,valid:d,missing:f,distinct:p,min:h,max:g,mean:u,stdev:a,median:c=i.quantile(y,.5),q1:i.quantile(y,.25),q3:i.quantile(y,.75),modeskew:0===a?0:(u-c)/a}},i.summary=function(e,n){var r=(n=n||t.keys(e[0])).map((function(n){var r=i.profile(e,t.$(n));return r.field=n,r}));return r.__summary__=!0,r}}(jo)),jo.exports);const $o=ko;const Bo={nominal:0,key:1,ordinal:2,temporal:3,quantitative:4};class Lo{constructor(e){this._tableSchema=e,e.fields.sort((function(e,t){return Bo[e.vlType]<Bo[t.vlType]?-1:Bo[e.vlType]>Bo[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=dn.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||ni(e)&&e.autoCount)return 1;if(e.bin){let t;t="boolean"==typeof e.bin?{maxbins:Sr(e.channel)}:"?"===e.bin?{enum:[!0,!1]}:e.bin;const n=t.maxbins;return r.binStats[n]||(r.binStats[n]=Wo(n,r.stats)),r.binStats[n].distinct}if(e.timeUnit){if(t)switch(e.timeUnit){case Qn.SECONDS:case Qn.MINUTES:return 60;case Qn.HOURS:return 24;case Qn.DAY:return 7;case Qn.DATE:return 31;case Qn.MONTH:return 12;case Qn.QUARTER:return 4;case Qn.MILLISECONDS:return 1e3}let i=e.timeUnit,o=r.timeStats;return o&&o[i]||(o=Object.assign({},o,{[i]:Ho(e.timeUnit,r.stats)})),n?o[i].distinct-qo(o[i].unique,["Invalid Date",null]):o[i].distinct}return r?n?r.stats.distinct-qo(r.stats.unique,[NaN,null]):r.stats.distinct:null}timeUnitHasVariation(e){if(!e.timeUnit)return;if(e.timeUnit===Qn.DAY){const t=dn.extend({},e,{timeUnit:Qn.DATE});if(this.cardinality(t,!1,!0)<=1)return!1}let t=e.timeUnit;for(let n of Jn)if(or(t,n)){const t=dn.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=dn.keys(t.stats.unique);return t.vlType===_t?[+t.stats.min,+t.stats.max]:t.type===Go.DATETIME?[t.stats.min,t.stats.max]:t.type===Go.INTEGER||t.type===Go.NUMBER?(n=n.map((e=>+e)),n.sort(dn.cmp)):t.vlType===jt&&t.ordinalDomain?t.ordinalDomain:n.map((e=>"null"===e?null:e)).sort(dn.cmp)}stats(e){const t=this._fieldSchemaIndex[e.field];return t?t.stats:null}}function Wo(e,t){const n=$o({min:t.min,max:t.max,maxbins:e}),r=dn.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 Ho(e,t){const n=dn.extend({},t);let r={};return dn.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===Qn.DAY?o.getDay():rr(e,o)).toString(),r[i]=(r[i]||0)+t.unique[n]})),n.unique=r,n.distinct=dn.keys(r).length,n}function qo(e,t){return t.reduce((function(t,n){return e[n]?t+1:t}),0)}var Go,zo;(zo=Go||(Go={}))[zo.STRING="string"]="STRING",zo[zo.NUMBER="number"]="NUMBER",zo[zo.INTEGER="integer"]="INTEGER",zo[zo.BOOLEAN="boolean"]="BOOLEAN",zo[zo.DATETIME="datetime"]="DATETIME";class Yo{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 Qo extends Yo{constructor(e){super(e)}hasAllRequiredPropertiesSpecific(e){return pn(this.constraint.properties,(t=>{if(mn(t)){let n=t.parent,r=t.child;return!e[n]||!sr(e[n][r])}return!e[t]||!sr(e[t])}))}satisfy(e,t,n,r){return!this.constraint.allowWildcardForProperties&&!this.hasAllRequiredPropertiesSpecific(e)||this.constraint.satisfy(e,t,n,r)}}const Vo=[{name:"aggregateOpSupportedByType",description:"Aggregate function should be supported by data type.",properties:[_n.TYPE,_n.AGGREGATE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!e.aggregate||!Dr(e.type)},{name:"asteriskFieldWithCountOnly",description:'Field="*" should be disallowed except aggregate="count"',properties:[_n.FIELD,_n.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:[_n.BIN,_n.FIELD,_n.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>{if(e.bin&&e.type===_t){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:[_n.TYPE,_n.BIN],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!e.bin||e.type===_t},{name:"channelFieldCompatible",description:"encoding channel's range type be compatible with channel type.",properties:[_n.CHANNEL,_n.TYPE,_n.BIN,_n.TIMEUNIT],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>{const i=Object.assign({field:"f"},ci(e,{schema:t,props:["bin","timeUnit","type"]})),{compatible:o}=Mr(i,e.channel);if(o)return!0;return!("row"!==e.channel&&"column"!==e.channel||(a=i.timeUnit,!Kn[a]&&!function(e){return!!Xn[e]}(i.timeUnit)));var a}},{name:"hasFn",description:"A field with as hasFn flag should have one of aggregate, timeUnit, or bin.",properties:[_n.AGGREGATE,_n.BIN,_n.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:[_n.SCALE,In("scale","zero"),_n.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:[_n.AGGREGATE,_n.AUTOCOUNT,_n.TIMEUNIT,_n.BIN],allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n,r)=>{if(ti(e)){return(!sr(e.aggregate)&&e.aggregate?1:0)+(!sr(e.bin)&&e.bin?1:0)+(!sr(e.timeUnit)&&e.timeUnit?1:0)<=1}return!0}},{name:"timeUnitAppliedForTemporal",description:"Time unit should be applied to temporal field only.",properties:[_n.TYPE,_n.TIMEUNIT],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!e.timeUnit||e.type===Pt},{name:"timeUnitShouldHaveVariation",description:"A particular time unit should be applied only if they produce unique values.",properties:[_n.TIMEUNIT,_n.TYPE],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n,r)=>!e.timeUnit||e.type!==Pt||(!n.has("timeUnit")&&!r.constraintManuallySpecifiedValue||t.timeUnitHasVariation(e))},{name:"scalePropertiesSupportedByScaleType",description:"Scale properties must be supported by correct scale type",properties:[].concat(Nn,[_n.SCALE,_n.TYPE]),allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n,r)=>{if(e.scale){const t=e.scale,n=di(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(!nn("point",t)&&!nn("band",t))return!1}else if(!nn(n,t))return!1}}return!0}},{name:"scalePropertiesSupportedByChannel",description:"Not all scale properties are supported by all encoding channels",properties:[].concat(Nn,[_n.SCALE,_n.CHANNEL]),allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n,r)=>{if(e){let t=e.channel,n=e.scale;if(t&&!sr(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===rn(t,e)))return!1}}}return!0}},{name:"typeMatchesPrimitiveType",description:"Data type should be supported by field's primitive type.",properties:[_n.FIELD,_n.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 Go.BOOLEAN:case Go.STRING:return o!==_t&&o!==Pt;case Go.NUMBER:case Go.INTEGER:return o!==Pt;case Go.DATETIME:return o===Pt;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:[_n.FIELD,_n.TYPE],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n,r)=>!(n.has("field")||n.has("type")||r.constraintManuallySpecifiedValue)||("*"===e.field?e.type===_t:t.vlType(e.field)===e.type)},{name:"maxCardinalityForCategoricalColor",description:"Categorical channel should not have too high cardinality",properties:[_n.CHANNEL,_n.FIELD],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n,r)=>e.channel!==ke||e.type!==Rt&&e.type!==Ur.KEY||t.cardinality(e)<=r.maxCardinalityForCategoricalColor},{name:"maxCardinalityForFacet",description:"Row/column channel should not have too high cardinality",properties:[_n.CHANNEL,_n.FIELD,_n.BIN,_n.TIMEUNIT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n,r)=>e.channel!==ve&&e.channel!==be||t.cardinality(e)<=r.maxCardinalityForFacet},{name:"maxCardinalityForShape",description:"Shape channel should not have too high cardinality",properties:[_n.CHANNEL,_n.FIELD,_n.BIN,_n.TIMEUNIT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n,r)=>e.channel!==Ue||t.cardinality(e)<=r.maxCardinalityForShape},{name:"dataTypeAndFunctionMatchScaleType",description:"Scale type must match data type",properties:[_n.TYPE,_n.SCALE,In("scale","type"),_n.TIMEUNIT,_n.BIN],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>{if(e.scale){const t=e.type,n=di(e);if(Dr(t))return void 0===n||Yt(n);if(t===Pt)return e.timeUnit?fn([$t.TIME,$t.UTC,void 0],n)||Yt(n):fn([$t.TIME,$t.UTC,void 0],n);if(t===_t)return e.bin?fn([$t.LINEAR,void 0],n):fn([$t.LOG,$t.POW,$t.SQRT,$t.QUANTILE,$t.QUANTIZE,$t.LINEAR,void 0],n)}return!0}},{name:"stackIsOnlyUsedWithXY",description:"stack should only be allowed for x and y channels",properties:[_n.STACK,_n.CHANNEL],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!e.stack||(e.channel===Ee||e.channel===Te)}].map((e=>new Qo(e)));Vo.reduce(((e,t)=>(e[t.name()]=t,e)),{});const Ko=Vo.reduce(((e,t)=>{for(const n of t.properties())e.set(n,e.get(n)||[]),e.get(n).push(t);return e}),new _r),Jo=[{name:"doesNotSupportConstantValue",description:"row, column, x, y, order, and detail should not work with constant values.",properties:[_n.TYPE,_n.AGGREGATE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n,r)=>!fn(["row","column","x","y","detail","order"],e.channel)}].map((e=>new Qo(e)));Jo.reduce(((e,t)=>(e[t.name()]=t,e)),{});const Xo=Jo.reduce(((e,t)=>{for(const n of t.properties())e.set(n,e.get(n)||[]),e.get(n).push(t);return e}),new _r);const Zo=ut.reduce(((e,t)=>(e[t]=!0,e)),{});class ea extends Yo{constructor(e){super(e)}hasAllRequiredPropertiesSpecific(e){return pn(this.constraint.properties,(t=>{if(t===_n.MARK)return!sr(e.getMark());if(mn(t)){let n=t.parent,r=t.child;return pn(e.getEncodings(),(e=>!e[n]||!sr(e[n][r])))}if(!Un(t))throw new Error("UNIMPLEMENTED");return pn(e.getEncodings(),(e=>!e[t]||!sr(e[t])))}))}satisfy(e,t,n){return!this.constraint.allowWildcardForProperties&&!this.hasAllRequiredPropertiesSpecific(e)||this.constraint.satisfy(e,t,n)}}const ta=[{name:"noRepeatedChannel",description:"Each encoding channel should only be used once.",properties:[_n.CHANNEL],allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n)=>{let r={};return pn(e.getEncodings(),(e=>!!sr(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:[_n.MARK,_n.SCALE,In("scale","zero"),_n.CHANNEL,_n.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>{const r=e.getMark(),i=e.getEncodings();if(r===Rn)for(let o of i)if(ti(o)&&(o.channel===Ee||o.channel===Te)&&o.type===_t&&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:[_n.BIN,_n.TIMEUNIT,_n.TYPE,_n.AUTOCOUNT],allowWildcardForProperties:!0,strict:!1,satisfy:(e,t,n)=>{if(gn(e.getEncodings(),(e=>ii(e))))return pn(e.getEncodings(),(e=>{if(ei(e))return!0;if(ni(e))return!0;switch(e.type){case _t:return!!e.bin;case Pt:return!!e.timeUnit;case jt:case Ur.KEY:case Rt:return!0}throw new Error("Unsupported Type")}));if(pn(e.wildcardIndex.encodingIndicesByProperty.get("autoCount")||[],(t=>{let n=e.getEncodingQueryByIndex(t);return ni(n)&&!sr(n.autoCount)})))return gn(e.getEncodings(),(e=>(ti(e)||ni(e))&&e.type===_t?!ri(e)&&(ti(e)&&(!e.bin||sr(e.bin))):!(!ti(e)||e.type!==Pt)&&(!e.timeUnit||sr(e.timeUnit))));return!0}},{name:"channelPermittedByMarkType",description:"Each encoding channel should be supported by the mark type",properties:[_n.CHANNEL,_n.MARK],allowWildcardForProperties:!0,strict:!0,satisfy:(e,t,n)=>{const r=e.getMark();return!!sr(r)||pn(e.getEncodings(),(e=>!!sr(e.channel)||!!bt(e.channel,r)))}},{name:"hasAllRequiredChannelsForMark",description:"All required channels for the specified mark should be specified",properties:[_n.CHANNEL,_n.MARK],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>{const r=e.getMark();switch(r){case Pn:case $n:return e.channelUsed(Ee)&&e.channelUsed(Te);case Hn:return e.channelUsed(Re);case Rn:case Gn:case zn:case qn:case Wn:case Ln:return e.channelUsed(Ee)||e.channelUsed(Te);case Bn:return!e.wildcardIndex.hasProperty(_n.CHANNEL)||e.channelUsed(Ee)||e.channelUsed(Te)}throw new Error("hasAllRequiredChannelsForMark not implemented for mark"+JSON.stringify(r))}},{name:"omitAggregate",description:"Omit aggregate plots.",properties:[_n.AGGREGATE,_n.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:[_n.CHANNEL,_n.AGGREGATE,_n.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)=>{ei(n)||ri(n)||ti(n)&&!n.aggregate&&(r=!0,fn([ve,be],n.channel)?e.wildcardIndex.hasEncodingProperty(o,_n.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:[_n.AGGREGATE,_n.AUTOCOUNT,_n.BIN,_n.TIMEUNIT,_n.TYPE],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>!e.isAggregate()||gn(e.getEncodings(),(e=>!!(ui(e)||ti(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:[_n.MARK,_n.AGGREGATE,_n.AUTOCOUNT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>!fn([Rn,$n,Pn],e.getMark())||e.isAggregate()},{name:"omitBarTickWithSize",description:"Do not map field to size channel with bar and tick mark",properties:[_n.CHANNEL,_n.MARK],allowWildcardForProperties:!0,strict:!1,satisfy:(e,t,n)=>{const r=e.getMark();if(fn([qn,Rn],r)&&e.channelEncodingField(Fe)){if(n.constraintManuallySpecifiedValue)return!1;{const t=e.specQuery.encodings;for(let n=0;n<t.length;n++){if(t[n].channel===Fe)return!e.wildcardIndex.hasEncodingProperty(n,_n.CHANNEL)}}}return!0}},{name:"omitBarAreaForLogScale",description:"Do not use bar and area mark for x and y's log scale",properties:[_n.MARK,_n.CHANNEL,_n.SCALE,In("scale","type"),_n.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>{const r=e.getMark(),i=e.getEncodings();if(r===Pn||r===Rn)for(let o of i)if(ti(o)&&(o.channel===Ee||o.channel===Te)&&o.scale){if(di(o)===$t.LOG)return!1}return!0}},{name:"omitMultipleNonPositionalChannels",description:"Unless manually specified, do not use multiple non-positional encoding channel to avoid over-encoding.",properties:[_n.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(ei(t)||ri(t))continue;const s=t.channel;if(!sr(s)&&Zo[s+""]&&(i+=1,e.wildcardIndex.hasEncodingProperty(a,_n.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:[_n.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(ei(t)||ri(t))continue;const n=t.channel;n===Ee?a=!0:n===Te?s=!0:sr(n)||(i=!0,e.wildcardIndex.hasEncodingProperty(c,_n.CHANNEL)&&(o=!0))}return!(o||n.constraintManuallySpecifiedValue&&i)||a&&s}},{name:"omitRaw",description:"Omit raw plots.",properties:[_n.AGGREGATE,_n.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:[_n.AGGREGATE,_n.AUTOCOUNT,_n.TIMEUNIT,_n.BIN,_n.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(!ei(i)&&!ri(i)){if(ti(i)&&i.type===Pt&&!i.timeUnit&&(e.wildcardIndex.hasEncodingProperty(r,_n.TIMEUNIT)||n.constraintManuallySpecifiedValue))return!1;if(i.type===_t&&ti(i)&&!i.bin&&!i.aggregate){if(e.wildcardIndex.hasEncodingProperty(r,_n.BIN)||e.wildcardIndex.hasEncodingProperty(r,_n.AGGREGATE)||e.wildcardIndex.hasEncodingProperty(r,_n.AUTOCOUNT))return!1;if(n.constraintManuallySpecifiedValue)return!1}}}}return!0}},{name:"omitRawDetail",description:"Do not use detail channel with raw plot.",properties:[_n.CHANNEL,_n.AGGREGATE,_n.AUTOCOUNT],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>!!e.isAggregate()||pn(e.specQuery.encodings,((t,r)=>!(!ei(t)&&!ri(t))||(t.channel!==Be||!e.wildcardIndex.hasEncodingProperty(r,_n.CHANNEL)&&!n.constraintManuallySpecifiedValue)))},{name:"omitRepeatedField",description:"Each field should be mapped to only one channel",properties:[_n.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(ei(t)||ni(t))continue;let s;if(t.field&&!sr(t.field)&&(s=t.field),ni(t)&&!sr(t.autoCount)&&(s="count_*"),s){if(e.wildcardIndex.hasEncodingProperty(a,_n.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:[_n.CHANNEL],allowWildcardForProperties:!0,strict:!1,satisfy:(e,t,n)=>{const r=e.getEncodings();return 1!==r.length||r[0].channel!==Te}},{name:"hasAppropriateGraphicTypeForMark",description:"Has appropriate graphic type for mark",properties:[_n.CHANNEL,_n.MARK,_n.TYPE,_n.TIMEUNIT,_n.BIN,_n.AGGREGATE,_n.AUTOCOUNT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>{const r=e.getMark();switch(r){case Pn:case $n:if(e.isAggregate()){const t=e.getEncodingQueryByChannel(Ee),n=e.getEncodingQueryByChannel(Te),r=li(t),i=li(n);return t&&n&&r!==i&&!(ti(t)&&!r&&fn(["nominal","key"],t.type))&&!(ti(n)&&!i&&fn(["nominal","key"],n.type))}return!0;case Hn:return!0;case Rn:case qn:if(e.channelEncodingField(Fe))return!1;{const t=e.getEncodingQueryByChannel(Ee),n=e.getEncodingQueryByChannel(Te);return li(t)!==li(n)}case Ln:const t=e.getEncodingQueryByChannel(Ee),n=e.getEncodingQueryByChannel(Te),r=ui(t),i=ui(n),o=e.getEncodingQueryByChannel(ke),a=li(o),s=!!ti(o)&&o.type===jt;return(r&&i||r&&!e.channelUsed(Te)||i&&!e.channelUsed(Ee))&&(!o||o&&(a||s));case Gn:case Bn:case zn:case Wn: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:[_n.STACK,_n.FIELD,_n.CHANNEL,_n.MARK,_n.AGGREGATE,_n.AUTOCOUNT,_n.SCALE,In("scale","type"),_n.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>{if(!e.wildcardIndex.hasProperty(_n.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:[_n.CHANNEL,_n.MARK,_n.AGGREGATE,_n.AUTOCOUNT,_n.SCALE,In("scale","type"),_n.TYPE],allowWildcardForProperties:!1,strict:!0,satisfy:(e,t,n)=>{const r=e.getVlStack();if(null!=r){const t=e.getEncodingQueryByChannel(r.fieldChannel);if(!fn(xr,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:[_n.CHANNEL,_n.TYPE,_n.TIMEUNIT,_n.BIN,_n.AGGREGATE,_n.AUTOCOUNT],allowWildcardForProperties:!1,strict:!1,satisfy:(e,t,n)=>{if(n.autoAddCount){const t=e.getEncodingQueryByChannel("x"),n=e.getEncodingQueryByChannel("y");if((!ti(t)||ui(t))&&(!ti(n)||ui(n)))return!!e.isAggregate()&&pn(e.getEncodings(),(e=>{let t=e.channel;return!(t!==Ee&&t!==Te&&t!==ve&&t!==be&&ti(e)&&!e.aggregate)}))}return!0}}].map((e=>new ea(e)));ta.reduce(((e,t)=>(e[t.name()]=t,e)),{});const na=ta.reduce(((e,t)=>{for(const n of t.properties())e.set(n,e.get(n)||[]),e.get(n).push(t);return e}),new _r);function ra(e,t,n,r,i){const o=na.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 ia=new _r;function oa(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);ei(d)||ri(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=Ko.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=Xo.get(e)||[];for(const l of c)if((l.strict()||o[l.name()])&&ei(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;ra(e,u,o,n,r)||s(c+1)})),o.resetEncodingProperty(l,e,u))}(0),i}}function aa(e,t,n){return t=t||new _r,n=n||new _r,e.forEach((e=>{var r;r=e,dn.isObject(r)&&r.property?(t.setByKey(e.property,!0),n.setByKey(e.property,e.replace)):t.setByKey(e,!0)})),{include:t,replaceIndex:n,replacer:Hr(n)}}ia.set("mark",((e,t,n)=>(r,i)=>(i.getMark().enum.forEach((o=>{i.setMark(o);ra("mark",e.mark,i,t,n)||r.push(i.duplicate())})),i.resetMark(),r))),vn.forEach((e=>{ia.set(e,oa(e))})),An.forEach((e=>{ia.set(e,oa(e))}));const sa=[_n.FIELD,_n.TYPE,_n.AGGREGATE,_n.BIN,_n.TIMEUNIT,_n.STACK],ca=sa.concat([{property:_n.CHANNEL,replace:{x:"xy",y:"xy",color:"style",size:"style",shape:"style",opacity:"style",row:"facet",column:"facet"}}]);let la={};function ua(e,t){la[e]=t}const da=aa([_n.FIELD]);ua("field",(e=>Vr(e,da.include,da.replacer)));const fa=aa(sa);ua("fieldTransform",(e=>Vr(e,fa.include,fa.replacer)));const pa=aa(ca);ua("encoding",(e=>Vr(e,pa.include,pa.replacer))),ua("spec",(e=>JSON.stringify(e)));class ha{constructor(){this._mark=void 0,this._encodings={},this._encodingIndicesByProperty=new _r}setEncodingProperty(e,t,n){const r=this._encodings;(r[e]=r[e]||new _r).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(Un(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 ga{constructor(e,t,n,r,i){this._rankingScore={},this._spec=e,this._channelFieldCount=e.encodings.reduce(((e,t)=>(sr(t.channel)||ni(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 ha;if(sr(e.mark)){const t=fr(_n.MARK);e.mark=lr(e.mark,t,n.enum.mark),r.setMark(e.mark)}if(e.encodings.forEach(((e,i)=>{ni(e)&&(console.warn("A field with autoCount should not be included as autoCount meant to be an internal object."),e.type=_t),ti(e)&&void 0===e.type&&(e.type=ar),vn.forEach((o=>{if(sr(e[o])){const a=fr(o)+i,s=yr(o,t,n),c=e[o]=lr(e[o],a,s);r.setEncodingProperty(i,o,c)}})),An.forEach((o=>{const a=e[o.parent];if(a){const e=o.child;if(sr(a[e])){const s=fr(o)+i,c=yr(o,t,n),l=a[e]=lr(a[e],s,c);r.setEncodingProperty(i,o,l)}}}))})),n.autoAddCount){const i={name:fr(_n.CHANNEL)+e.encodings.length,enum:yr(_n.CHANNEL,t,n)},o={name:fr(_n.AUTOCOUNT)+e.encodings.length,enum:[!1,!0]},a={channel:i,autoCount:o,type:_t};e.encodings.push(a);const s=e.encodings.length-1;r.setEncodingProperty(s,_n.CHANNEL,i),r.setEncodingProperty(s,_n.AUTOCOUNT,o)}return new ga(e,r,t,n,{})}get wildcardIndex(){return this._wildcardIndex}get schema(){return this._schema}get specQuery(){return this._spec}duplicate(){return new ga(dn.duplicate(this._spec),this._wildcardIndex,this._schema,this._opt,dn.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 mn(t)?n[t.parent][t.child]:n[t]}setEncodingProperty(e,t,n,r){const i=this._spec.encodings[e];t===_n.CHANNEL&&i.channel&&!sr(i.channel)&&this._channelFieldCount[i.channel]--,mn(t)?i[t.parent][t.child]=n:En(t)&&!0===n?i[t]=dn.extend({},i[t],{enum:void 0,name:void 0}):i[t]=n,this._assignedWildcardIndex[r.name]=n,t===_n.CHANNEL&&(this._channelFieldCount[n]=(this._channelFieldCount[n]||0)+1)}resetEncodingProperty(e,t,n){const r=this._spec.encodings[e];t===_n.CHANNEL&&this._channelFieldCount[r.channel]--,mn(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 ti(this.getEncodingQueryByChannel(e))}getEncodings(){return this._spec.encodings.filter((e=>!ri(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 gn(this._spec.encodings,(e=>ti(e)&&!sr(e.aggregate)&&!!e.aggregate||ii(e)))}getVlStack(){return Lr(this._spec)}getStackOffset(){return function(e){for(const t of e.encodings)if(void 0!==t[_n.STACK]&&!sr(t[_n.STACK]))return t[_n.STACK]}(this._spec)}getStackChannel(){return function(e){for(const t of e.encodings)if(void 0!==t[_n.STACK]&&!sr(t.channel))return t.channel;return null}(this._spec)}toShorthand(e){if(e){if(dn.isString(e))return function(e,t){return la[t](e)}(this.specQuery,e);const t=aa(e);return Vr(this._spec,t.include,t.replacer)}return Vr(this._spec)}toSpec(e){if(sr(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=ai(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=dn.extend({},this._opt.defaultSpecConfig,this._spec.config)),t)}getRankingScore(e){return this._rankingScore[e]}setRankingScore(e,t){this._rankingScore[e]=t}}function ma(e){return void 0!==e.items}function ya(e){let t=e.items[0];for(;t&&ma(t);)t=t.items[0];return t}class va{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 ba,xa;(xa=ba||(ba={}))[xa.Q=_t]="Q",xa[xa.BIN_Q="bin_"+_t]="BIN_Q",xa[xa.T=Pt]="T",xa[xa.TIMEUNIT_T="timeUnit_time"]="TIMEUNIT_T",xa[xa.TIMEUNIT_O="timeUnit_"+jt]="TIMEUNIT_O",xa[xa.O=jt]="O",xa[xa.N=Rt]="N",xa[xa.K=Ur.KEY]="K",xa[xa.NONE="-"]="NONE";const Ea=ba.Q,Ta=ba.BIN_Q,Sa=ba.T,Na=ba.TIMEUNIT_T,wa=ba.TIMEUNIT_O,Ca=ba.O,Aa=ba.N,Oa=ba.K,ka=ba.NONE;function Ma(e){if(e.bin)return ba.BIN_Q;if(e.timeUnit){return Yt(di(e))?ba.TIMEUNIT_O:ba.TIMEUNIT_T}return e.type}const Ia=-10;function Ua(e,t,n,r){return e+"_"+t+"_"+n+"_"+r}const Fa=[new class extends va{constructor(){super("Axis")}initScore(e={}){e=Object.assign({},vr,e);let t={};return[{feature:Ta,opt:"preferredBinAxis"},{feature:Sa,opt:"preferredTemporalAxis"},{feature:Na,opt:"preferredTemporalAxis"},{feature:wa,opt:"preferredTemporalAxis"},{feature:Ca,opt:"preferredOrdinalAxis"},{feature:Aa,opt:"preferredNominalAxis"}].forEach((n=>{e[n.opt]===Ee?t[n.feature+"_"+Te]=-.01:e[n.opt]===Te&&(t[n.feature+"_"+Ee]=-.01)})),t}featurize(e,t){return e+"_"+t}getScore(e,t,n){return e.getEncodings().reduce(((e,t)=>{if(ti(t)||ni(t)){const n=Ma(t),r=this.featurize(n,t.channel),i=this.getFeatureScore(r);i&&e.push(i)}return e}),[])}},new class extends va{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(ni(t)||ti(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 va{constructor(){super("Facet")}initScore(e){let t={};return(e=Object.assign({},vr,e)).preferredFacet===ve?t[be]=-.01:e.preferredFacet===be&&(t[ve]=-.01),t}getScore(e,t,n){return e.getEncodings().reduce(((e,t)=>{if(ti(t)||ni(t)){const n=this.getFeatureScore(t.channel);n&&e.push(n)}return e}),[])}},new class extends va{constructor(){super("Mark")}initScore(){return function(){const e=[Ea,Sa],t=[Ta,wa,Ca,Aa,Oa].concat([ka]);let n={};e.forEach((t=>{e.forEach((e=>{hn({point:0,text:-.2,tick:-.5,rect:-1,bar:-2,line:-2,area:-2,rule:-2.5},((r,i)=>{const o=Ua(t,e,!0,i);n[o]=r}));hn({point:0,text:-.2,tick:-.5,bar:-2,line:-2,area:-2,rule:-2.5},((r,i)=>{const o=Ua(t,e,!1,i);n[o]=r}))}))})),e.forEach((e=>{t.forEach((t=>{hn({tick:0,point:-.2,text:-.5,bar:-2,line:-2,area:-2,rule:-2.5},((r,i)=>{const o=Ua(e,t,!0,i);n[o]=r;const a=Ua(t,e,!0,i);n[a]=r}))})),[Na].forEach((t=>{hn({point:0,text:-.5,tick:-1,bar:-2,line:-2,area:-2,rule:-2.5},((r,i)=>{const o=Ua(e,t,!0,i);n[o]=r;const a=Ua(t,e,!0,i);n[a]=r}))})),[ka,Aa,Ca,Oa].forEach((t=>{hn({bar:0,point:-.2,tick:-.25,text:-.3,line:-2,area:-2,rule:-2.5},((r,i)=>{const o=Ua(e,t,!1,i);n[o]=r;const a=Ua(t,e,!1,i);n[a]=r}))})),[Ta].forEach((t=>{hn({bar:0,point:-.2,tick:-.25,text:-.3,line:-.5,area:-.5,rule:-2.5},((r,i)=>{const o=Ua(e,t,!1,i);n[o]=r;const a=Ua(t,e,!1,i);n[a]=r}))})),[Na,wa].forEach((t=>{hn({line:0,area:-.1,bar:-.2,point:-.3,tick:-.35,text:-.4,rule:-2.5},((r,i)=>{const o=Ua(e,t,!1,i);n[o]=r;const a=Ua(t,e,!1,i);n[a]=r}))}))})),[Na].forEach((e=>{[Na].forEach((t=>{const r={point:0,rect:-.1,text:-.5,tick:-1,bar:-2,line:-2,area:-2,rule:-2.5};hn(r,((r,i)=>{const o=Ua(e,t,!0,i);n[o]=r})),hn(r,((r,i)=>{const o=Ua(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};hn(r,((r,i)=>{const o=Ua(e,t,!0,i);n[o]=r})),hn(r,((r,i)=>{const o=Ua(t,e,!0,i);n[o]=r})),hn(r,((r,i)=>{const o=Ua(e,t,!1,i);n[o]=r})),hn(r,((r,i)=>{const o=Ua(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};hn(t,((t,i)=>{const o=Ua(r,e,!0,i);n[o]=t})),hn(t,((t,i)=>{const o=Ua(r,e,!1,i);n[o]=t}))}return n}()}getScore(e,t,n){let r=e.getMark();r!==Gn&&r!==zn||(r=Bn);const i=e.getEncodingQueryByChannel(Ee),o=i?Ma(i):ka,a=e.getEncodingQueryByChannel(Te),s=o+"_"+(a?Ma(a):ka)+"_"+!e.isAggregate()+"_"+r,c=this.getFeatureScore(s);return c?[c]:(console.error("feature score missing for",s),[])}},new class extends va{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(ti(t)||ni(t)){const n=r+"_"+t.channel,i=this.getFeatureScore(n);i&&e.push(i)}return e}),[])}},new class extends va{constructor(){super("TypeChannel")}initScore(){let e={};const t={x:0,y:0,size:-.575,color:-.725,text:-2,opacity:-3,shape:Ia,row:Ia,column:Ia,detail:-20};[Ea,Sa,Na].forEach((n=>{dn.keys(t).forEach((r=>{e[this.featurize(n,r)]=t[r]}))}));const n=dn.extend({},t,{row:-.75,column:-.75,shape:-3.1,text:-3.2,detail:-4});[Ta,wa,Ca].forEach((t=>{dn.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 dn.keys(r).forEach((t=>{e[this.featurize(Aa,t)]=r[t],e[this.featurize(Oa,t)]=fn(["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(ti(t)||ni(t)){const n=Jr(t);(e[n]=e[n]||[]).push(t)}return e}),{}),i=[];return hn(r,(e=>{const t=e.reduce(((e,t)=>{if(ti(t)||ni(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 Da="aggregationQuality";let _a={};function ja(e,t){_a[e]=t}function Pa(e,t,n,r){return t.nest&&r!==t.nest.length?(e.items.forEach((e=>{Pa(e,t,n,r+1)})),t.nest[r].orderGroupBy&&e.items.sort(function(e,t,n){return(r,i)=>{const o=ya(r),a=ya(i);return Ra(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)=>Ra(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 Ra(e,t,n,r,i){for(let o of e){let e=$a(n,o,r,i).score-$a(t,o,r,i).score;if(0!==e)return e}return 0}function $a(e,t,n,r){if(void 0!==e.getRankingScore(t))return e.getRankingScore(t);const i=(0,_a[t])(e,n,r);return e.setRankingScore(t,i),i}function Ba(e,t,n){let r={};return e=e.map((function(e){return n.smallRangeStepForHighCardinalityOrFacet&&(e=function(e,t,n,r){[ve,Te,be,Ee].forEach((t=>{n[t]=e.getEncodingQueryByChannel(t)}));const i=n[Te];if(void 0!==i&&ti(i)&&(n[ve]||t.cardinality(i)>r.smallRangeStepForHighCardinalityOrFacet.maxCardinality)){void 0===i.scale&&(i.scale={});const e=di(i);i.scale&&(void 0===e||Yt(e))&&(i.scale.rangeStep||(i.scale.rangeStep=12))}const o=n[Ee];if(ti(o)&&(n[be]||t.cardinality(o)>r.smallRangeStepForHighCardinalityOrFacet.maxCardinality)){void 0===o.scale&&(o.scale={});const e=di(o);o.scale&&(void 0===e||Yt(e))&&(o.scale.rangeStep||(o.scale.rangeStep=12))}return e}(e,t,r,n)),n.nominalColorScaleForHighCardinality&&(e=function(e,t,n,r){n[ke]=e.getEncodingQueryByChannel(ke);const i=n[ke];ti(i)&&void 0!==i&&(i.type===Rt||i.type===Ur.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([be,Ee,Te].forEach((t=>{n[t]=e.getEncodingQueryByChannel(t)})),void 0===n[be]){const e=n[Ee],i=n[Te];ti(e)&&ti(i)&&void 0!==i&&i.field&&Yt(di(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 La(e,t,n=vr){const r=ga.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 ia.get(e)}(r),a=e(i,t,n);o=o.reduce(a,[])}})),!n.stylize||null===n.nominalColorScaleForHighCardinality&&null===n.smallRangeStepForHighCardinalityOrFacet&&null===n.xAxisOnTopForHighYCardinalityWithoutColumn?o:Ba(o,t,n)}function Wa(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 _r),o.push(e>0?o[e-1].duplicate():new _r);const n=t[e].groupBy;if(dn.isArray(n)){let t=aa(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=dn.isArray(c)?Vr(e.specQuery,i[n],a[n]):la[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}}(La((e=Object.assign({},function(e){if(e.groupBy){let t={groupBy:e.groupBy};e.orderBy&&(t.orderGroupBy=e.orderBy);let n={spec:dn.duplicate(e.spec),nest:[t]};return e.chooseBy&&(n.chooseBy=e.chooseBy),e.config&&(n.config=e.config),n}return dn.duplicate(e)}(e),{config:Object.assign({},vr,n,e.config)})).spec,t,e.config),e.nest);return{query:e,result:Pa(r,e,t,0)}}ja("effectiveness",(function(e,t,n){const r=Fa.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}})),ja(Da,(function(e,t,n){const r=function(e){const t=e.getEncodings();if(e.isAggregate()){if(gn(t,(e=>ti(e)&&(e.type===_t&&!e.bin&&!e.aggregate||e.type===Pt&&!e.timeUnit))))return{type:Da,score:.1,feature:"Aggregate with raw continuous"};if(gn(t,(e=>ti(e)&&ui(e)))){let e=gn(t,(e=>ti(e)&&"count"===e.aggregate||ii(e))),n=gn(t,(e=>ti(e)&&!!e.bin));return e?{type:Da,score:.8,feature:"Aggregate with count"}:n?{type:Da,score:.7,feature:"Aggregate with bin but without count"}:{type:Da,score:.9,feature:"Aggregate without count and without bin"}}return{type:Da,score:.3,feature:"Aggregate without dimension"}}return gn(t,(e=>ti(e)&&!ui(e)))?{type:Da,score:1,feature:"Raw with measure"}:{type:Da,score:.2,feature:"Raw without measure"}}(e);return{score:r.score,features:[r]}})),ja("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(!ti(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 Ha={[Go.BOOLEAN]:r.jsx(s,{className:"h-5 w-5 inline-flex opacity-60"}),[Go.DATETIME]:r.jsx(a,{className:"h-5 w-5 inline-flex opacity-60"}),[Go.NUMBER]:r.jsx(o,{className:"h-5 w-5 inline-flex opacity-60"}),[Go.STRING]:r.jsx(i,{className:"h-5 w-5 inline-flex opacity-60"}),[Go.INTEGER]:r.jsx(G,{className:"h-5 w-5 inline-flex opacity-60"})};function qa(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 Ga=qa({type:"addCategoricalField",limit:4,additionalFieldQuery:{channel:ar,field:ar,type:"nominal"}}),za=qa({type:"addQuantitativeField",limit:4,additionalFieldQuery:{channel:ar,bin:ar,aggregate:ar,field:ar,type:"quantitative"}}),Ya=qa({type:"addTemporalField",limit:2,additionalFieldQuery:{channel:ar,hasFn:!0,timeUnit:ar,field:ar,type:"temporal"}});function Qa(e){return e?"bin"===e?{bin:!0}:$(e)?{aggregate:e}:function(e){if(!e)return!1;return Ka.includes(e)||Ja.includes(e)}(e)?{timeUnit:e}:{}:{}}const Va=["bin","min","max","mean","median","sum"],Ka=["year","month","date","day","hours","minutes","seconds","milliseconds"],Ja=["yearmonth","yearmonthdate","monthdate"];function Xa(e){const t={};for(const n in e)void 0!==e[n]&&(t[n]=e[n]);return t}function Za(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(sr(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"),Xa({field:i,fn:p,type:f,sort:u,scale:o,axis:s,legend:a,description:d})}function es(e){return 0===e.encodings.length}function ts(e){let t=!1,n=!1,r=!1;for(const i of e.encodings)ei(i)||(ni(i)?sr(i.autoCount)&&(n=!0):(sr(i.field)&&(t=!0),(sr(i.aggregate)||sr(i.bin)||sr(i.timeUnit))&&(n=!0),sr(i.channel)&&(r=!0)));return{hasAnyWildcard:r||t||n,hasWildcardField:t,hasWildcardFn:n,hasWildcardChannel:r}}function ns(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,...Qa(n),...r}}(t,e)))),config:e.config};var t}const rs={name:"source"};function is(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=as(za,e,t)),(r||i||o)&&(n.addCategoricalField=as(Ga,e,t)),r&&(n.addTemporalField=as(Ya,e,t)),n}function os(e,t){if(es(e.spec))return{plots:[],query:e,limit:1};return{plots:[ss(Wa(e,t).result,rs)[0]],query:e,limit:1}}function as(e,t,n){const r=e.createQuery(t);return{plots:ss(Wa(r,n).result,rs),query:r,limit:e.limit}}function ss(e,t){return e.items.map((e=>ma(e)?cs(t,ya(e)):cs(t,e)))}function cs(e,t){return{fieldInfos:t.getEncodings().filter(ti).map((e=>({fieldDef:Za(e),channel:e.channel}))),spec:t.toSpec(e)}}const ls={type:"histograms",limit:12,createQuery:e=>({spec:{data:e.spec.data,mark:ar,transform:e.spec.transform,encodings:[{channel:ar,bin:ar,timeUnit:ar,field:ar,type:ar},{channel:ar,aggregate:"count",field:"*",type:"quantitative"}]},groupBy:"fieldTransform",orderBy:["fieldOrder","aggregationQuality","effectiveness"],chooseBy:["aggregationQuality","effectiveness"],config:{autoAddCount:!1}})};const{valueAtom:us,useActions:ds}=u((function(){return{mark:ar,encoding:{},config:{},schema:null}}),{setSchema:(e,t)=>({...e,schema:t}),setMark:(e,t)=>({...e,mark:t}),setEncoding:(e,t)=>{const n=Xa({...e.encoding,...t});return{...e,encoding:n}},set:(e,t)=>{const{schema:n,...r}=t;return{...e,...r}}});function fs(){return ds()}const ps=d((e=>{const t=e(us);if(!t.schema)return{};const n=function(e){const{spec:t,autoAddCount:n}=e,r=ns(t),{hasAnyWildcard:i,hasWildcardFn:o,hasWildcardField:a}=ts(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 es(n.spec)?{main:os(n,t.schema),histograms:as(ls,n,t.schema)}:function(e){return!ts(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:os(n,t.schema),...is(n,t.schema)}:{main:os(n,t.schema)}})),hs=[ar,"area","bar","circle","geoshape","line","point","rect","rule","square","text","tick","trail"],gs=["x","y","row","column"],ms=["color","size","shape"],ys=e=>{const t=f.c(26),{schema:n,mark:i}=e,o=p(us),a=fs(),s=o.encoding.x&&o.encoding.y;let c;t[0]!==a||t[1]!==s||t[2]!==n||t[3]!==o.encoding?(c=e=>{const t=("row"===e||"column"===e)&&!s;return r.jsx(vs,{schema:n,label:e,disabled:t,fieldDefinition:o.encoding[e],onChange:t=>a.setEncoding({[e]:t})},e)},t[0]=a,t[1]=s,t[2]=n,t[3]=o.encoding,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"}),hs.map(Es)]})}),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=gs.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=ms.map(l),t[20]=l,t[21]=O):O=t[21],t[22]!==A||t[23]!==O||t[24]!==w?(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]=A,t[23]=O,t[24]=w,t[25]=k):k=t[25],k},vs=e=>{const t=f.c(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:[Ha[Go.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:[Ha[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:[Ha[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:[Ha[Go.NUMBER],r.jsx("span",{className:"flex-1",children:"Count"})]})},"*"),t[22]=M):M=t[22],t[23]!==O||t[24]!==A?(I=r.jsx(m,{children:r.jsxs(y,{children:[A,O,k,M]})}),t[23]=O,t[24]=A,t[25]=I):I=t[25],t[26]!==a||t[27]!==g||t[28]!==I||t[29]!==S||t[30]!==C?(U=r.jsxs(b,{value:g,disabled:a,onValueChange:S,children:[C,I]}),t[26]=a,t[27]=g,t[28]=I,t[29]=S,t[30]=C,t[31]=U):U=t[31],t[32]!==o||t[33]!==s?(F=o&&r.jsx(xs,{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]!==_||t[41]!==v?(j=r.jsxs(r.Fragment,{children:[v,_]}),t[40]=_,t[41]=v,t[42]=j):j=t[42],j},bs="__",xs=e=>{const t=f.c(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===Ur.QUANTITATIVE){let e;t[1]===Symbol.for("react.memo_cache_sentinel")?(e=[["",Va]],t[1]=e):e=t[1],a=e}if(n.type===Ur.TEMPORAL){let e;t[2]===Symbol.for("react.memo_cache_sentinel")?(e=[["Single",Ka],["Multi",Ja]],t[2]=e):e=t[2],a=e}if(a.length>0){let e,o,s,c,l,u;return t[3]!==n||t[4]!==i?(e=e=>{i({...n,fn:e===bs?void 0:e})},t[3]=n,t[4]=i,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(N,{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:bs,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(Ss)]}),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 Es(e){return r.jsx(x,{value:e,children:e===ar?"auto":e},e)}function Ts(e){return r.jsx(x,{value:e??bs,children:S(e)},e)}function Ss(e){const[t,n]=e;return r.jsxs(y,{children:[t&&r.jsx(v,{children:t}),n.map(Ts)]},t)}const Ns=e=>{const t=f.c(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(H,{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:[Ha[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(As),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:[Ha[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]!==k||t[23]!==F||t[24]!==O?(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]=k,t[23]=F,t[24]=O,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:ws.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:Cs(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},ws=["distinct","min","max","mean","median","q1","q3","stdev"];function Cs(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)}function As(e){return!e}const Os=e=>{const t=f.c(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(us,(()=>{const t=o.get(us),{schema:n,...r}=t;e.setValue(r)})),n=e.value;return n&&Object.keys(n).length>0&&o.set(us,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(Is,{...e})}),t[3]=e,t[4]=s):s=t[4],s},ks={export:{svg:!0,png:!0},source:!1,compiled:!1,editor:!1},Ms={left:20,right:20,top:20,bottom:20},Is=e=>{var t,n,i,o,a,s,c,l,u,d,h,g,m,y;const v=f.c(43),{data:b}=e,x=fs();let E,T;v[0]!==x||v[1]!==b?(E=async()=>{if(!b)return{};const e=await j(b,{type:"csv",parse:"auto"},{replacePeriod:!0}),t=function(e,t={},n={fields:[]}){t=dn.extend({},vr,t);let r=Ro.summary(e),i=_o.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]?Go.DATETIME:i[a];let c,l=n.distinct;if(s===Go.NUMBER)c=_t;else if(s===Go.INTEGER)c=l<t.numberNominalLimit&&l/n.count<t.numberNominalProportion?Rt:_t;else if(s===Go.DATETIME){c=Pt,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=Rt;c===Rt&&l/n.count>t.minPercentUniqueForKey&&n.count>t.minCardinalityForKey&&(c=Ur.KEY);let u={name:a,originalIndex:r,vlType:c,type:s,stats:n,timeStats:{},binStats:{}};const d=o[u.name];return u=dn.extend(u,d),u}));for(let c of a)if(c.vlType===_t)for(let e of t.enum.binProps.maxbins)c.binStats[e]=Wo(e,c.stats);else if(c.vlType===Pt)for(let e of t.enum.timeUnit)void 0!==e&&(c.timeStats[e]=Ho(e,c.stats));const s=Object.assign({},n,{fields:a});return new Lo(s)}(e);return x.setSchema(t),{chartData:e,schema:t}},v[0]=x,v[1]=b,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(us),O=p(ps),{theme:k}=U();if(w){let e;return v[5]!==w?(e=r.jsx(P,{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:R}=S;if(N||!R){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,H,G,z,Y;if(v[9]!==x||v[10]!==M||v[11]!==(null==(i=O.addCategoricalField)?void 0:i.plots)||v[12]!==(null==(o=O.addQuantitativeField)?void 0:o.plots)||v[13]!==(null==(a=O.addTemporalField)?void 0:a.plots)||v[14]!==(null==(s=O.histograms)?void 0:s.plots)||v[15]!==$||v[16]!==C||v[17]!==R||v[18]!==k){const e=new Set(null==$?void 0:$.fieldInfos.map(_s));let t;v[23]!==M||v[24]!==$||v[25]!==R||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:Ms,actions:ks,spec:Ds($.spec),theme:"dark"===k?"dark":void 0})}):r.jsx(Ns,{schema:R}),v[23]=M,v[24]=$,v[25]=R,v[26]=k,v[27]=t):t=v[27];const n=t;let i,o;H="flex flex-col gap-2",v[28]!==C||v[29]!==R?(i=r.jsx(ys,{mark:C,schema:R}),v[28]=C,v[29]=R,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=Us,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(Fs,{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(_,{variant:e.has(t.fieldDef.field)?"secondary":"defaultOutline",children:n},n)}))}),actions:r.jsx(F,{content:"Make main plot",children:r.jsx(A,{"data-testid":"marimo-plugin-data-explorer-make-main-plot",variant:"text",size:"icon",onClick:()=>{const e=D.fromEntries(t.fieldInfos.map(js));x.setEncoding(e)},children:r.jsx(q,{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]=x,v[10]=M,v[11]=null==(h=O.addCategoricalField)?void 0:h.plots,v[12]=null==(g=O.addQuantitativeField)?void 0:g.plots,v[13]=null==(m=O.addTemporalField)?void 0:m.plots,v[14]=null==(y=O.histograms)?void 0:y.plots,v[15]=$,v[16]=C,v[17]=R,v[18]=k,v[19]=B,v[20]=L,v[21]=H,v[22]=G}else B=v[19],L=v[20],H=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]!==H||v[40]!==G||v[41]!==z?(Y=r.jsxs("div",{className:H,children:[G,z]}),v[39]=H,v[40]=G,v[41]=z,v[42]=Y):Y=v[42],Y},Us=e=>{const t=f.c(2),{children:n}=e;if(0===R.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},Fs=e=>{const t=f.c(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]!==o||t[3]!==a?(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]=o,t[3]=a,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 Ds(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 _s(e){return e.fieldDef.field}function js(e){return[e.channel,e.fieldDef]}export{Is as DataExplorerComponent,Os as default};