/** * Bundled by jsDelivr using Rollup v2.79.1 and Terser v5.19.2. * Original file: /npm/@observablehq/plot@0.6.16/src/index.js * * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files */ import{ascending as t,descending as n,timeSecond as e,timeMinute as r,timeHour as o,timeDay as i,timeMonday as a,timeTuesday as l,timeWednesday as s,timeThursday as c,timeFriday as u,timeSaturday as f,timeSunday as h,timeWeek as d,timeMonth as p,timeYear as y,utcSecond as m,utcMinute as g,utcHour as v,unixDay as x,utcMonday as w,utcTuesday as b,utcWednesday as k,utcThursday as $,utcFriday as M,utcSaturday as A,utcSunday as L,utcWeek as E,utcMonth as z,utcYear as O,bisector as S,max as N,pairs as C,timeFormat as T,utcFormat as R,range as I,quantile as W,symbolAsterisk as j,symbolCircle as B,symbolCross as F,symbolDiamond as D,symbolDiamond2 as q,symbolPlus as _,symbolSquare as P,symbolSquare2 as V,symbolStar as H,symbolTimes as U,symbolTriangle as Y,symbolTriangle2 as X,symbolWye as G,randomLcg as Z,group as J,sort as K,rollup as Q,sum as tt,InternSet as nt,mode as et,variance as rt,median as ot,mean as at,maxIndex as lt,minIndex as st,min as ct,deviation as ut,rollups as ft,quantize as ht,schemeAccent as dt,schemeCategory10 as pt,schemeDark2 as yt,schemeObservable10 as mt,schemePaired as gt,schemePastel1 as vt,schemePastel2 as xt,schemeSet1 as wt,schemeSet2 as bt,schemeSet3 as kt,schemeTableau10 as $t,interpolateBrBG as Mt,schemeBrBG as At,interpolatePRGn as Lt,schemePRGn as Et,interpolatePiYG as zt,schemePiYG as Ot,interpolatePuOr as St,schemePuOr as Nt,interpolateRdBu as Ct,schemeRdBu as Tt,interpolateRdGy as Rt,schemeRdGy as It,interpolateRdYlBu as Wt,schemeRdYlBu as jt,interpolateRdYlGn as Bt,schemeRdYlGn as Ft,interpolateSpectral as Dt,schemeSpectral as qt,interpolateBlues as _t,schemeBlues as Pt,interpolateGreens as Vt,schemeGreens as Ht,interpolateGreys as Ut,schemeGreys as Yt,interpolateOranges as Xt,schemeOranges as Gt,interpolatePurples as Zt,schemePurples as Jt,interpolateReds as Kt,schemeReds as Qt,interpolateTurbo as tn,interpolateViridis as nn,interpolateMagma as en,interpolateInferno as rn,interpolatePlasma as on,interpolateCividis as an,interpolateCubehelixDefault as ln,interpolateWarm as sn,interpolateCool as cn,interpolateBuGn as un,schemeBuGn as fn,interpolateBuPu as hn,schemeBuPu as dn,interpolateGnBu as pn,schemeGnBu as yn,interpolateOrRd as mn,schemeOrRd as gn,interpolatePuBu as vn,schemePuBu as xn,interpolatePuBuGn as wn,schemePuBuGn as bn,interpolatePuRd as kn,schemePuRd as $n,interpolateRdPu as Mn,schemeRdPu as An,interpolateYlGn as Ln,schemeYlGn as En,interpolateYlGnBu as zn,schemeYlGnBu as On,interpolateYlOrBr as Sn,schemeYlOrBr as Nn,interpolateYlOrRd as Cn,schemeYlOrRd as Tn,interpolateRainbow as Rn,interpolateSinebow as In,scaleLinear as Wn,scalePow as jn,scaleLog as Bn,scaleSymlog as Fn,scaleQuantile as Dn,extent as qn,ticks as _n,interpolateNumber as Pn,reverse as Vn,scaleThreshold as Hn,scaleIdentity as Un,piecewise as Yn,interpolateRgb as Xn,interpolateRound as Gn,interpolateHsl as Zn,interpolateHcl as Jn,interpolateLab as Kn,scaleDiverging as Qn,scaleDivergingPow as te,scaleDivergingLog as ne,scaleDivergingSymlog as ee,scaleTime as re,scaleUtc as oe,scaleImplicit as ie,scaleOrdinal as ae,scalePoint as le,scaleBand as se,symbolsStroke as ce,symbolsFill as ue,cross as fe,InternMap as he,geoTransform as de,geoPath as pe,geoClipRectangle as ye,geoStream as me,geoTransverseMercator as ge,geoStereographic as ve,geoOrthographic as xe,geoMercator as we,geoGnomonic as be,geoEquirectangular as ke,geoEqualEarth as $e,geoAzimuthalEquidistant as Me,geoAzimuthalEqualArea as Ae,geoAlbersUsa as Le,geoConicEquidistant as Ee,geoConicEqualArea as ze,geoConicConformal as Oe,geoAlbers as Se,select as Ne,creator as Ce,namespaces as Te,pointer as Re,format as Ie,axisBottom as We,pathRound as je,rgb as Be,cumsum as Fe,groupSort as De,greatest as qe,curveLinear as _e,curveBasis as Pe,curveBasisClosed as Ve,curveBasisOpen as He,curveBundle as Ue,curveBumpX as Ye,curveBumpY as Xe,curveCardinal as Ge,curveCardinalClosed as Ze,curveCardinalOpen as Je,curveCatmullRom as Ke,curveCatmullRomClosed as Qe,curveCatmullRomOpen as tr,curveLinearClosed as nr,curveMonotoneX as er,curveMonotoneY as rr,curveNatural as or,curveStep as ir,curveStepAfter as ar,curveStepBefore as lr,thresholdSturges as sr,thresholdScott as cr,thresholdFreedmanDiaconis as ur,utcTickInterval as fr,tickIncrement as hr,bisect as dr,area as pr,line as yr,rank as mr,count as gr,blurImage as vr,Delaunay as xr,blur2 as wr,contours as br,nice as kr,contourDensity as $r,geoCentroid as Mr,geoGraticule10 as Ar,stratify as Lr,tree as Er,cluster as zr,least as Or}from"../../d3@7.9.0/7055d4c5.js";import{parse as Sr,format as Nr}from"../../isoformat@0.2.1/c68fbd73.js";import Cr from"../../interval-tree-1d@1.0.4/a62ae5ce.js";function Tr(t){return null!=t&&!Number.isNaN(t)}function Rr(n,e){return+Tr(e)-+Tr(n)||t(n,e)}function Ir(t,e){return+Tr(e)-+Tr(t)||n(t,e)}function Wr(t){return null!=t&&""!=`${t}`}function jr(t){return isFinite(t)?t:NaN}function Br(t){return t>0&&isFinite(t)?t:NaN}function Fr(t){return t<0&&isFinite(t)?t:NaN}function Dr(t){if(null==t)return;const e=t[0],r=t[t.length-1];return n(e,r)}const qr=1e3,_r=6e4,Pr=36e5,Vr=864e5,Hr=7*Vr,Ur=30*Vr,Yr=365*Vr,Xr=[["millisecond",1],["2 milliseconds",2],["5 milliseconds",5],["10 milliseconds",10],["20 milliseconds",20],["50 milliseconds",50],["100 milliseconds",100],["200 milliseconds",200],["500 milliseconds",500],["second",qr],["5 seconds",5e3],["15 seconds",15e3],["30 seconds",3e4],["minute",_r],["5 minutes",3e5],["15 minutes",9e5],["30 minutes",18e5],["hour",Pr],["3 hours",108e5],["6 hours",216e5],["12 hours",432e5],["day",Vr],["2 days",2*Vr],["week",Hr],["2 weeks",2*Hr],["month",Ur],["3 months",3*Ur],["6 months",6*Ur],["year",Yr],["2 years",2*Yr],["5 years",5*Yr],["10 years",10*Yr],["20 years",20*Yr],["50 years",50*Yr],["100 years",100*Yr]],Gr=new Map([["second",qr],["minute",_r],["hour",Pr],["day",Vr],["monday",Hr],["tuesday",Hr],["wednesday",Hr],["thursday",Hr],["friday",Hr],["saturday",Hr],["sunday",Hr],["week",Hr],["month",Ur],["year",Yr]]),Zr=new Map([["second",e],["minute",r],["hour",o],["day",i],["monday",a],["tuesday",l],["wednesday",s],["thursday",c],["friday",u],["saturday",f],["sunday",h],["week",d],["month",p],["year",y]]),Jr=new Map([["second",m],["minute",g],["hour",v],["day",x],["monday",w],["tuesday",b],["wednesday",k],["thursday",$],["friday",M],["saturday",A],["sunday",L],["week",E],["month",z],["year",O]]),Kr=Symbol("intervalDuration"),Qr=Symbol("intervalType");for(const[t,n]of Zr)n[Kr]=Gr.get(t),n[Qr]="time";for(const[t,n]of Jr)n[Kr]=Gr.get(t),n[Qr]="utc";const to=[["year",O,"utc"],["month",z,"utc"],["day",x,"utc",6*Ur],["hour",v,"utc",3*Vr],["minute",g,"utc",216e5],["second",m,"utc",18e5]],no=[["year",y,"time"],["month",p,"time"],["day",i,"time",6*Ur],["hour",o,"time",3*Vr],["minute",r,"time",216e5],["second",e,"time",18e5]],eo=[to[0],no[0],to[1],no[1],to[2],no[2],...to.slice(3)];function ro(t){let n=`${t}`.toLowerCase();n.endsWith("s")&&(n=n.slice(0,-1));let e=1;const r=/^(?:(\d+)\s+)/.exec(n);switch(r&&(n=n.slice(r[0].length),e=+r[1]),n){case"quarter":n="month",e*=3;break;case"half":n="month",e*=6}let o=Jr.get(n);if(!o)throw new Error(`unknown interval: ${t}`);if(e>1&&!o.every)throw new Error(`non-periodic interval: ${n}`);return[n,e]}function oo(t){return ao(ro(t),"time")}function io(t){return ao(ro(t),"utc")}function ao([t,n],e){let r=("time"===e?Zr:Jr).get(t);return n>1&&(r=r.every(n),r[Kr]=Gr.get(t)*n,r[Qr]=e),r}function lo(t,n){if(!(n>1))return;const e=t[Kr];if(!Xr.some((([,t])=>t===e)))return;if(e%Vr==0&&VrMath.log(t))).center(Xr,Math.log(e*n))];return("time"===t[Qr]?oo:io)(r)}function so(t,n,e){const r="time"===n?T:R;if(null==e)return r("year"===t?"%Y":"month"===t?"%Y-%m":"day"===t?"%Y-%m-%d":"hour"===t||"minute"===t?"%Y-%m-%dT%H:%M":"second"===t?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M:%S.%L");const o=function(t){return"left"===t||"right"===t?(t,n)=>`\n${t}\n${n}`:"top"===t?(t,n)=>`${n}\n${t}`:(t,n)=>`${t}\n${n}`}(e);switch(t){case"millisecond":return uo(r(".%L"),r(":%M:%S"),o);case"second":return uo(r(":%S"),r("%-I:%M"),o);case"minute":return uo(r("%-I:%M"),r("%p"),o);case"hour":return uo(r("%-I %p"),r("%b %-d"),o);case"day":return uo(r("%-d"),r("%b"),o);case"month":return uo(r("%b"),r("%Y"),o);case"year":return r("%Y")}throw new Error("unable to format time ticks")}function co(t,n,e){const r=N(C(n,((t,n)=>Math.abs(n-t))));if(r<1e3)return so("millisecond","utc",e);for(const[o,i,a,l]of function(t){return"time"===t?no:"utc"===t?to:eo}(t)){if(r>l)break;if("hour"===o&&!r)break;if(n.every((t=>i.floor(t)>=t)))return so(o,a,e)}}function uo(t,n,e){return(r,o,i)=>{const a=t(r,o),l=n(r,o),s=o-Dr(i);return o!==s&&void 0!==i[s]&&l===n(i[s],s)?a:e(a,l)}}const fo=Object.getPrototypeOf(Uint8Array),ho=Object.prototype.toString;function po(t){return t instanceof Array||t instanceof fo}function yo(t){return t instanceof fo&&!function(t){return t instanceof BigInt64Array||t instanceof BigUint64Array}(t)}function mo(t){return t?.prototype instanceof fo&&!function(t){return t===BigInt64Array||t===BigUint64Array}(t)}const go=Symbol("reindex");function vo(t,n,e){const r=typeof n;return"string"===r?Bi(t)?bo(t.getChild(n),e):xo(t,$o(n),e):"function"===r?xo(t,n,e):"number"===r||n instanceof Date||"boolean"===r?Ho(t,To(n),e):"function"==typeof n?.transform?wo(n.transform(t),e):function(t,n){return null!=t&&n?ii(t,n):t}(wo(n,e),t?.[go])}function xo(t,n,e){return Ho(t,mo(e)?(t,e)=>Wo(n(t,e)):n,e)}function wo(t,n){return void 0===n?Vo(t):Fi(t)?bo(t,n):t instanceof n?t:n.from(t,mo(n)&&!yo(t)?Wo:void 0)}function bo(t,n){return null==t?t:void 0!==n&&n!==Array||!function(t){return t&&(8===t.typeId||10===t.typeId)&&1===t.unit}(t.type)?wo(t.toArray(),n):jo(t.toArray())}const ko=[null],$o=t=>n=>{const e=n[t];return void 0===e&&"Feature"===n.type?n.properties?.[t]:e},Mo={transform:oi},Ao={transform:t=>t},Lo=()=>1,Eo=()=>!0,zo=t=>null==t?t:`${t}`,Oo=t=>null==t?t:+t,So=t=>t?t[0]:void 0,No=t=>t?t[1]:void 0,Co=t=>t?t[2]:void 0,To=t=>()=>t;function Ro(t){const n=+`${t}`.slice(1)/100;return(t,e)=>W(t,n,e)}function Io(t){return yo(t)?t:Ho(t,Wo,Float64Array)}function Wo(t){return null==t?NaN:Number(t)}function jo(t){return Ho(t,Bo)}function Bo(t){return t instanceof Date&&!isNaN(t)?t:"string"==typeof t?Sr(t):null==t||isNaN(t=Number(t))?void 0:new Date(t)}function Fo(t,n){return void 0===t&&(t=n),null===t?[void 0,"none"]:Si(t)?[void 0,t]:[t,void 0]}function Do(t,n){return void 0===t&&(t=n),null===t||"number"==typeof t?[void 0,t]:[t,void 0]}function qo(t,n,e){if(null!=t)return _o(t,n,e)}function _o(t,n,e){const r=`${t}`.toLowerCase();if(!e.includes(r))throw new Error(`invalid ${n}: ${t}`);return r}function Po(t){return Bi(t)?t:Vo(t)}function Vo(t){if(null==t||po(t))return t;if(Fi(t))return bo(t);switch(t.type){case"FeatureCollection":return t.features;case"GeometryCollection":return t.geometries;case"Feature":case"LineString":case"MultiLineString":case"MultiPoint":case"MultiPolygon":case"Point":case"Polygon":case"Sphere":return[t]}return Array.from(t)}function Ho(t,n,e=Array){return null==t?t:t instanceof e?t.map(n):e.from(t,n)}function Uo(t,n=Array){return t instanceof n?t.slice():n.from(t)}function Yo({x:t,x1:n,x2:e}){return void 0!==t||void 0!==n||void 0!==e}function Xo({y:t,y1:n,y2:e}){return void 0!==t||void 0!==n||void 0!==e}function Go(t){return Yo(t)||Xo(t)||void 0!==t.interval}function Zo(t){return t?.toString===ho}function Jo(t){return Zo(t)&&(void 0!==t.type||void 0!==t.domain)}function Ko(t){return Zo(t)&&"function"!=typeof t.transform}function Qo(t){return Ko(t)&&void 0===t.value&&void 0===t.channel}function ti(t,n,e,r=Ao){return void 0===n&&void 0===e?(n=0,e=void 0===t?r:t):void 0===n?n=void 0===t?0:t:void 0===e&&(e=void 0===t?0:t),[n,e]}function ni(t,n){return void 0===t&&void 0===n?[So,No]:[t,n]}function ei({z:t,fill:n,stroke:e}={}){return void 0===t&&([t]=Fo(n)),void 0===t&&([t]=Fo(e)),t}function ri(t){return po(t)?t.length:t?.numRows}function oi(t){const n=ri(t),e=new Uint32Array(n);for(let t=0;tt[n]),t.constructor):Ho(n,(n=>t.at(n)))}function ai(t){return 1===t.length?(n,e)=>t(ii(e,n)):t}function li(t,n,e){return t.subarray?t.subarray(n,e):t.slice(n,e)}function si(t){return null!==t&&"object"==typeof t?t.valueOf():t}function ci(t,n){if(void 0!==n[t])return n[t];switch(t){case"x1":case"x2":t="x";break;case"y1":case"y2":t="y"}return n[t]}function ui(t){let n;return[{transform:()=>n,label:hi(t)},t=>n=t]}function fi(t){return null==t?[t]:ui(t)}function hi(t,n){return"string"==typeof t?t:t&&void 0!==t.label?t.label:n}function di(t,n){return{transform(e){const r=t.transform(e),o=n.transform(e);return Mi(r)||Mi(o)?Ho(r,((t,n)=>new Date((+r[n]+ +o[n])/2))):Ho(r,((t,n)=>(+r[n]+ +o[n])/2),Float64Array)},label:t.label}}function pi(t,n){const e=yi(n?.interval,n?.type);return e?Ho(t,e):t}function yi(t,n){const e=mi(t,n);return e&&(t=>Tr(t)?e.floor(t):t)}function mi(t,n){if(null!=t){if("number"==typeof t)return gi(t);if("string"==typeof t)return("time"===n?oo:io)(t);if("function"!=typeof t.floor)throw new Error("invalid interval; missing floor method");if("function"!=typeof t.offset)throw new Error("invalid interval; missing offset method");return t}}function gi(t){0<(t=+t)&&t<1&&Number.isInteger(1/t)&&(t=-1/t);const n=Math.abs(t);return t<0?{floor:t=>Math.floor(t*n)/n,offset:(t,e=1)=>(t*n+Math.floor(e))/n,range:(t,e)=>I(Math.ceil(t*n),e*n).map((t=>t/n))}:{floor:t=>Math.floor(t/n)*n,offset:(t,e=1)=>t+n*Math.floor(e),range:(t,e)=>I(Math.ceil(t/n),e/n).map((t=>t*n))}}function vi(t,n){if((t=mi(t,n))&&"function"!=typeof t.range)throw new Error("invalid interval: missing range method");return t}function xi(t){return"function"==typeof t?.range}function wi(t){return void 0===t||Ko(t)?t:{value:t}}function bi(t){return t&&"function"==typeof t[Symbol.iterator]}function ki(t){for(const n of t)if(null!=n)return"object"!=typeof n||n instanceof Date}function $i(t){for(const n of t){if(null==n)continue;const t=typeof n;return"string"===t||"boolean"===t}}function Mi(t){for(const n of t)if(null!=n)return n instanceof Date}function Ai(t){for(const n of t)if(null!=n)return"string"==typeof n&&isNaN(n)&&Sr(n)}function Li(t){for(const n of t)if(null!=n){if("string"!=typeof n)return!1;if(n.trim())return!isNaN(n)}}function Ei(t){for(const n of t)if(null!=n)return"number"==typeof n}function zi(t,n){let e;for(const r of t)if(null!=r){if(!n(r))return!1;e=!0}return e}const Oi=new Set("none,currentcolor,transparent,aliceblue,antiquewhite,aqua,aquamarine,azure,beige,bisque,black,blanchedalmond,blue,blueviolet,brown,burlywood,cadetblue,chartreuse,chocolate,coral,cornflowerblue,cornsilk,crimson,cyan,darkblue,darkcyan,darkgoldenrod,darkgray,darkgreen,darkgrey,darkkhaki,darkmagenta,darkolivegreen,darkorange,darkorchid,darkred,darksalmon,darkseagreen,darkslateblue,darkslategray,darkslategrey,darkturquoise,darkviolet,deeppink,deepskyblue,dimgray,dimgrey,dodgerblue,firebrick,floralwhite,forestgreen,fuchsia,gainsboro,ghostwhite,gold,goldenrod,gray,green,greenyellow,grey,honeydew,hotpink,indianred,indigo,ivory,khaki,lavender,lavenderblush,lawngreen,lemonchiffon,lightblue,lightcoral,lightcyan,lightgoldenrodyellow,lightgray,lightgreen,lightgrey,lightpink,lightsalmon,lightseagreen,lightskyblue,lightslategray,lightslategrey,lightsteelblue,lightyellow,lime,limegreen,linen,magenta,maroon,mediumaquamarine,mediumblue,mediumorchid,mediumpurple,mediumseagreen,mediumslateblue,mediumspringgreen,mediumturquoise,mediumvioletred,midnightblue,mintcream,mistyrose,moccasin,navajowhite,navy,oldlace,olive,olivedrab,orange,orangered,orchid,palegoldenrod,palegreen,paleturquoise,palevioletred,papayawhip,peachpuff,peru,pink,plum,powderblue,purple,rebeccapurple,red,rosybrown,royalblue,saddlebrown,salmon,sandybrown,seagreen,seashell,sienna,silver,skyblue,slateblue,slategray,slategrey,snow,springgreen,steelblue,tan,teal,thistle,tomato,turquoise,violet,wheat,white,whitesmoke,yellow".split(","));function Si(t){return"string"==typeof t&&(t=t.toLowerCase().trim(),/^#[0-9a-f]{3,8}$/.test(t)||/^(?:url|var|rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\(.*\)$/.test(t)||Oi.has(t))}function Ni(t){return"number"==typeof t&&(0<=t&&t<=1||isNaN(t))}function Ci(t){return null==t||Ti(t)}function Ti(t){return/^\s*none\s*$/i.test(t)}function Ri(t,n){return qo(t,n,["middle","top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"])}function Ii(t="middle"){return Ri(t,"frameAnchor")}function Wi(t){return bi(t)?function(t){console.warn("named iterables are deprecated; please use an object instead");const n=new Set;return Object.fromEntries(Array.from(t,(t=>{const{name:e}=t;if(null==e)throw new Error("missing name");const r=`${e}`;if("__proto__"===r)throw new Error(`illegal name: ${r}`);if(n.has(r))throw new Error(`duplicate name: ${r}`);return n.add(r),[e,t]})))}(t):t}function ji(t){return!0===t?t="frame":!1===t?t=null:null!=t&&(t=_o(t,"clip",["frame","sphere"])),t}function Bi(t){return t&&"function"==typeof t.getChild&&"function"==typeof t.toArray&&t.schema&&Array.isArray(t.schema.fields)}function Fi(t){return t&&"function"==typeof t.toArray&&t.type}const Di=Symbol("position"),qi=Symbol("color"),_i=Symbol("radius"),Pi=Symbol("length"),Vi=Symbol("opacity"),Hi=Symbol("symbol"),Ui=Symbol("projection"),Yi=new Map([["x",Di],["y",Di],["fx",Di],["fy",Di],["r",_i],["color",qi],["opacity",Vi],["symbol",Hi],["length",Pi],["projection",Ui]]);const Xi=Math.sqrt(3),Gi=2/Xi,Zi=new Map([["asterisk",j],["circle",B],["cross",F],["diamond",D],["diamond2",q],["hexagon",{draw(t,n){const e=Math.sqrt(n/Math.PI),r=e*Gi,o=r/2;t.moveTo(0,r),t.lineTo(e,o),t.lineTo(e,-o),t.lineTo(0,-r),t.lineTo(-e,-o),t.lineTo(-e,o),t.closePath()}}],["plus",_],["square",P],["square2",V],["star",H],["times",U],["triangle",Y],["triangle2",X],["wye",G]]);function Ji(t){return t&&"function"==typeof t.draw}function Ki(t){return!!Ji(t)||"string"==typeof t&&Zi.has(t.toLowerCase())}function Qi(t){if(null==t||Ji(t))return t;const n=Zi.get(`${t}`.toLowerCase());if(n)return n;throw new Error(`invalid symbol: ${t}`)}function ta({filter:t,sort:n,reverse:e,transform:r,initializer:o,...i}={},a){if(void 0===r&&(null!=t&&(r=aa(t)),null==n||Qo(n)||(r=ea(r,fa(n))),e&&(r=ea(r,sa))),null!=a&&null!=o)throw new Error("transforms cannot be applied after initializers");return{...i,...(null===n||Qo(n))&&{sort:n},transform:ea(r,a)}}function na({filter:t,sort:n,reverse:e,initializer:r,...o}={},i){return void 0===r&&(null!=t&&(r=aa(t)),null==n||Qo(n)||(r=ra(r,fa(n))),e&&(r=ra(r,sa))),{...o,...(null===n||Qo(n))&&{sort:n},initializer:ra(r,i)}}function ea(t,n){return null==t?null===n?void 0:n:null==n?null===t?void 0:t:function(e,r,o){return({data:e,facets:r}=t.call(this,e,r,o)),n.call(this,Po(e),r,o)}}function ra(t,n){return null==t?null===n?void 0:n:null==n?null===t?void 0:t:function(e,r,o,...i){let a,l,s,c,u,f;return({data:l=e,facets:s=r,channels:a}=t.call(this,e,r,o,...i)),({data:u=l,facets:f=s,channels:c}=n.call(this,l,s,{...o,...a},...i)),{data:u,facets:f,channels:{...a,...c}}}}function oa(t,n){return(null!=t.initializer?na:ta)(t,n)}function ia(t,n){return oa(n,aa(t))}function aa(t){return(n,e)=>{const r=vo(n,t);return{data:n,facets:e.map((t=>t.filter((t=>r[t]))))}}}function la({sort:t,...n}={}){return{...oa(n,sa),sort:Qo(t)?t:null}}function sa(t,n){return{data:t,facets:n.map((t=>t.slice().reverse()))}}function ca({seed:t,sort:n,...e}={}){return{...oa(e,da(null==t?Math.random:Z(t))),sort:Qo(n)?n:null}}function ua(t,{sort:n,...e}={}){return{...(Ko(t)&&void 0!==t.channel?na:oa)(e,fa(t)),sort:Qo(n)?n:null}}function fa(t){return("function"==typeof t&&1!==t.length?ha:da)(t)}function ha(t){return(n,e)=>{const r=po(n)?(e,r)=>t(n[e],n[r]):(e,r)=>t(n.get(e),n.get(r));return{data:n,facets:e.map((t=>t.slice().sort(r)))}}}function da(t){let n,e;({channel:n,value:t,order:e}={...wi(t)});const r=n?.startsWith("-");if(r&&(n=n.slice(1)),void 0===e&&(e=r?Ir:Rr),"function"!=typeof e)switch(`${e}`.toLowerCase()){case"ascending":e=Rr;break;case"descending":e=Ir;break;default:throw new Error(`invalid order: ${e}`)}return(r,o,i)=>{let a;if(void 0===n)a=vo(r,t);else{if(void 0===i)throw new Error("channel sort requires an initializer");if(a=i[n],!a)return{};a=a.value}const l=(t,n)=>e(a[t],a[n]);return{data:r,facets:o.map((t=>t.slice().sort(l)))}}}function pa(t,n){return va(null,null,t,n)}function ya(t={y:"count"},n={}){const{x:e=Ao}=n;if(null==e)throw new Error("missing channel: x");return va(e,null,t,n)}function ma(t={x:"count"},n={}){const{y:e=Ao}=n;if(null==e)throw new Error("missing channel: y");return va(null,e,t,n)}function ga(t={fill:"count"},n={}){let{x:e,y:r}=n;if([e,r]=ni(e,r),null==e)throw new Error("missing channel: x");if(null==r)throw new Error("missing channel: y");return va(e,r,t,n)}function va(t,n,{data:e=Ia,filter:r,sort:o,reverse:i,...a}={},l={}){a=La(a,l),e=Oa(e,Ao),o=null==o?void 0:Ea("sort",o,l),r=null==r?void 0:za("filter",r,l);const[s,c]=fi(t),[u,f]=fi(n),{z:h,fill:d,stroke:p,x1:y,x2:m,y1:g,y2:v,...x}=l,[w,b]=fi(h),[k]=Fo(d),[$]=Fo(p),[M,A]=fi(k),[L,E]=fi($);return{..."z"in l&&{z:w||h},..."fill"in l&&{fill:M||d},..."stroke"in l&&{stroke:L||p},...ta(x,((l,s,u)=>{const d=pi(vo(l,t),u?.x),p=pi(vo(l,n),u?.y),y=vo(l,h),m=vo(l,k),g=vo(l,$),v=Na(a,{z:y,fill:m,stroke:g}),x=[],w=[],M=d&&c([]),L=p&&f([]),z=y&&b([]),O=m&&A([]),S=g&&E([]);let N=0;for(const t of a)t.initialize(l);o&&o.initialize(l),r&&r.initialize(l);for(const t of s){const n=[];for(const n of a)n.scope("facet",t);o&&o.scope("facet",t),r&&r.scope("facet",t);for(const[i,s]of $a(t,v))for(const[t,c]of $a(s,p))for(const[s,u]of $a(c,d)){const c={data:l};if(d&&(c.x=s),p&&(c.y=t),v&&(c.z=i),!r||r.reduce(u,c)){n.push(N++),w.push(e.reduceIndex(u,l,c)),d&&M.push(s),p&&L.push(t),y&&z.push(v===y?i:y[u[0]]),m&&O.push(v===m?i:m[u[0]]),g&&S.push(v===g?i:g[u[0]]);for(const t of a)t.reduce(u,c);o&&o.reduce(u,c)}}x.push(n)}return Ca(x,o,i),{data:w,facets:x}})),...!xa(a,"x")&&(s?{x:s}:{x1:y,x2:m}),...!xa(a,"y")&&(u?{y:u}:{y1:g,y2:v}),...Object.fromEntries(a.map((({name:t,output:n})=>[t,n])))}}function xa(t,...n){for(const{name:e}of t)if(n.includes(e))return!0;return!1}function wa(t,n,e=ba){const r=Object.entries(t);return null!=n.title&&void 0===t.title&&r.push(["title",ja]),null!=n.href&&void 0===t.href&&r.push(["href",Wa]),r.filter((([,t])=>void 0!==t)).map((([t,r])=>null===r?function(t){return{name:t,initialize(){},scope(){},reduce(){}}}(t):e(t,r,n)))}function ba(t,n,e,r=ka){let o;Zo(n)&&"reduce"in n&&(o=n.scale,n=n.reduce);const i=r(t,n,e),[a,l]=ui(i.label);let s;return{name:t,output:void 0===o?a:{value:a,scale:o},initialize(t){i.initialize(t),s=l([])},scope(t,n){i.scope(t,n)},reduce(t,n){s.push(i.reduce(t,n))}}}function ka(t,n,e,r=Ma){const o=ci(t,e),i=r(n,o);let a,l;return{label:hi(i===Fa?null:o,i.label),initialize(t){a=void 0===o?t:vo(t,o),"data"===i.scope&&(l=i.reduceIndex(oi(t),a))},scope(t,n){i.scope===t&&(l=i.reduceIndex(n,a))},reduce:(t,n)=>null==i.scope?i.reduceIndex(t,a,n):i.reduceIndex(t,a,l,n)}}function $a(t,n){return n?J(t,(t=>n[t])):[[,t]]}function Ma(t,n,e=Aa){if(null==t)return e(t);if("function"==typeof t.reduceIndex)return t;if("function"==typeof t.reduce&&Zo(t))return function(t){return console.warn("deprecated reduce interface; implement reduceIndex instead."),{...t,reduceIndex:t.reduce.bind(t)}}(t);if("function"==typeof t)return r=t,{reduceIndex:(t,n,e)=>r(ii(n,t),e)};var r;if(/^p\d{2}$/i.test(t))return Ta(Ro(t));switch(`${t}`.toLowerCase()){case"first":return Wa;case"last":return Ba;case"identity":return Ia;case"count":return Fa;case"distinct":return Da;case"sum":return null==n?Fa:qa;case"proportion":return _a(n,"data");case"proportion-facet":return _a(n,"facet");case"deviation":return Ta(ut);case"min":return Ta(ct);case"min-index":return Ta(st);case"max":return Ta(N);case"max-index":return Ta(lt);case"mean":return Ra(at);case"median":return Ra(ot);case"variance":return Ta(rt);case"mode":return Ta(et)}return e(t)}function Aa(t){throw new Error(`invalid reduce: ${t}`)}function La(t,n){return wa(t,n,Ea)}function Ea(t,n,e){return ba(t,n,e,za)}function za(t,n,e){return ka(t,n,e,Oa)}function Oa(t,n){return Ma(t,n,Sa)}function Sa(t){switch(`${t}`.toLowerCase()){case"x":return Pa;case"y":return Va;case"z":return Ha}throw new Error(`invalid group reduce: ${t}`)}function Na(t,n){for(const e in n){const r=n[e];if(void 0!==r&&!t.some((t=>t.name===e)))return r}}function Ca(t,n,e){if(n){const e=n.output.transform(),r=(t,n)=>Rr(e[t],e[n]);t.forEach((t=>t.sort(r)))}e&&t.forEach((t=>t.reverse()))}function Ta(t){return{reduceIndex:(n,e)=>t(n,(t=>e[t]))}}function Ra(t){return{reduceIndex(n,e){const r=t(n,(t=>e[t]));return Mi(e)?new Date(r):r}}}const Ia={reduceIndex:(t,n)=>ii(n,t)},Wa={reduceIndex:(t,n)=>n[t[0]]},ja={reduceIndex(t,n){const e=K(Q(t,(t=>t.length),(t=>n[t])),No),r=e.slice(-5).reverse();if(r.length`${t} (${n.toLocaleString("en-US")})`)).join("\n")}},Ba={reduceIndex:(t,n)=>n[t[t.length-1]]},Fa={label:"Frequency",reduceIndex:t=>t.length},Da={label:"Distinct",reduceIndex(t,n){const e=new nt;for(const r of t)e.add(n[r]);return e.size}},qa=Ta(tt);function _a(t,n){return null==t?{scope:n,label:"Frequency",reduceIndex:(t,n,e=1)=>t.length/e}:{scope:n,reduceIndex:(t,n,e=1)=>tt(t,(t=>n[t]))/e}}const Pa={reduceIndex:(t,n,{x:e})=>e},Va={reduceIndex:(t,n,{y:e})=>e},Ha={reduceIndex:(t,n,{z:e})=>e};function Ua(t){if("function"!=typeof t)throw new Error(`invalid test function: ${t}`);return{reduceIndex:(n,e,{data:r})=>e[n.find(po(r)?n=>t(r[n],n,r):n=>t(r.get(n),n,r))]}}function Ya(t,{scale:n,type:e,value:r,filter:o,hint:i,label:a=hi(r)},l){return void 0===i&&"function"==typeof r?.transform&&(i=r.hint),Za(l,{scale:n,type:e,value:vo(t,r),label:a,filter:o,hint:i})}function Xa(t,n){return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,Ya(n,e,t)])))}function Ga(t,n){const e=Object.fromEntries(Object.entries(t).map((([t,{scale:e,value:r}])=>{const o=null==e?null:n[e];return[t,null==o?r:Ho(r,o)]})));return e.channels=t,e}function Za(t,n){const{scale:e,value:r}=n;if(!0===e||"auto"===e)switch(t){case"fill":case"stroke":case"color":n.scale=!0!==e&&zi(r,Si)?null:"color",n.defaultScale="color";break;case"fillOpacity":case"strokeOpacity":case"opacity":n.scale=!0!==e&&zi(r,Ni)?null:"opacity",n.defaultScale="opacity";break;case"symbol":!0!==e&&zi(r,Ki)?(n.scale=null,n.value=Ho(r,Qi)):n.scale="symbol",n.defaultScale="symbol";break;default:n.scale=Yi.has(t)?t:null}else if(!1===e)n.scale=null;else if(null!=e&&!Yi.has(e))throw new Error(`unknown scale: ${e}`);return n}function Ja(t,n){for(const e in t){const r=t[e];if(r.scale===n)return r}}function Ka(t,n){const e=t.original;if(e===t)return n;const r=n.value,o=n.value=[];for(let n=0;nMath.abs(t-r[n])),Float64Array)}function tl(t,n,e){let r=t[n];if(r||void 0===e||(r=t[e]),r)return r.value;throw new Error(`missing channel: ${n}`)}function nl(t){if(null==t||"function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"ascending":return el;case"descending":return rl}throw new Error(`invalid order: ${t}`)}function el([t,n],[e,r]){return Rr(n,r)||Rr(t,e)}function rl([t,n],[e,r]){return Ir(n,r)||Rr(t,e)}function ol(t,n){let e=t[n];if(e){for(;e.source;)e=e.source;return null===e.source?null:e}}const il=new Map([["accent",dt],["category10",pt],["dark2",yt],["observable10",mt],["paired",gt],["pastel1",vt],["pastel2",xt],["set1",wt],["set2",bt],["set3",kt],["tableau10",$t]]);const al=new Map([...il,["brbg",sl(At,Mt)],["prgn",sl(Et,Lt)],["piyg",sl(Ot,zt)],["puor",sl(Nt,St)],["rdbu",sl(Tt,Ct)],["rdgy",sl(It,Rt)],["rdylbu",sl(jt,Wt)],["rdylgn",sl(Ft,Bt)],["spectral",sl(qt,Dt)],["burd",cl(Tt,Ct)],["buylrd",cl(jt,Wt)],["blues",ll(Pt,_t)],["greens",ll(Ht,Vt)],["greys",ll(Yt,Ut)],["oranges",ll(Gt,Xt)],["purples",ll(Jt,Zt)],["reds",ll(Qt,Kt)],["turbo",ul(tn)],["viridis",ul(nn)],["magma",ul(en)],["inferno",ul(rn)],["plasma",ul(on)],["cividis",ul(an)],["cubehelix",ul(ln)],["warm",ul(sn)],["cool",ul(cn)],["bugn",ll(fn,un)],["bupu",ll(dn,hn)],["gnbu",ll(yn,pn)],["orrd",ll(gn,mn)],["pubu",ll(xn,vn)],["pubugn",ll(bn,wn)],["purd",ll($n,kn)],["rdpu",ll(An,Mn)],["ylgn",ll(En,Ln)],["ylgnbu",ll(On,zn)],["ylorbr",ll(Nn,Sn)],["ylorrd",ll(Tn,Cn)],["rainbow",fl(Rn)],["sinebow",fl(In)]]);function ll(t,n){return({length:e})=>1===e?[t[3][1]]:2===e?[t[3][1],t[3][2]]:(e=Math.max(3,Math.floor(e)))>9?ht(n,e):t[e]}function sl(t,n){return({length:e})=>2===e?[t[3][0],t[3][2]]:(e=Math.max(3,Math.floor(e)))>11?ht(n,e):t[e]}function cl(t,n){return({length:e})=>2===e?[t[3][2],t[3][0]]:(e=Math.max(3,Math.floor(e)))>11?ht((t=>n(1-t)),e):t[e].slice().reverse()}function ul(t){return({length:n})=>ht(t,Math.max(2,Math.floor(n)))}function fl(t){return({length:n})=>ht(t,Math.floor(n)+1).slice(0,-1)}function hl(t){const n=`${t}`.toLowerCase();if(!al.has(n))throw new Error(`unknown ordinal scheme: ${n}`);return al.get(n)}function dl(t,n){const e=hl(t),r="function"==typeof e?e({length:n}):e;return r.length!==n?r.slice(0,n):r}const pl=new Map([["brbg",Mt],["prgn",Lt],["piyg",zt],["puor",St],["rdbu",Ct],["rdgy",Rt],["rdylbu",Wt],["rdylgn",Bt],["spectral",Dt],["burd",t=>Ct(1-t)],["buylrd",t=>Wt(1-t)],["blues",_t],["greens",Vt],["greys",Ut],["purples",Zt],["reds",Kt],["oranges",Xt],["turbo",tn],["viridis",nn],["magma",en],["inferno",rn],["plasma",on],["cividis",an],["cubehelix",ln],["warm",sn],["cool",cn],["bugn",un],["bupu",hn],["gnbu",pn],["orrd",mn],["pubugn",wn],["pubu",vn],["purd",kn],["rdpu",Mn],["ylgnbu",zn],["ylgn",Ln],["ylorbr",Sn],["ylorrd",Cn],["rainbow",Rn],["sinebow",In]]);function yl(t){const n=`${t}`.toLowerCase();if(!pl.has(n))throw new Error(`unknown quantitative scheme: ${n}`);return pl.get(n)}const ml=new Set(["brbg","prgn","piyg","puor","rdbu","rdgy","rdylbu","rdylgn","spectral","burd","buylrd"]);const gl=t=>n=>t(1-n),vl=[0,1],xl=new Map([["number",Pn],["rgb",Xn],["hsl",Zn],["hcl",Jn],["lab",Kn]]);function wl(t){const n=`${t}`.toLowerCase();if(!xl.has(n))throw new Error(`unknown interpolator: ${n}`);return xl.get(n)}function bl(t,n,e,{type:r,nice:o,clamp:i,zero:a,domain:l=Al(t,e),unknown:s,round:c,scheme:u,interval:f,range:h=(Yi.get(t)===_i?El(e,l):Yi.get(t)===Pi?zl(e,l):Yi.get(t)===Vi?vl:void 0),interpolate:d=(Yi.get(t)===qi?null==u&&void 0!==h?Xn:yl(void 0!==u?u:"cyclical"===r?"rainbow":"turbo"):c?Gn:Pn),reverse:p}){if(f=vi(f,r),"cyclical"!==r&&"sequential"!==r||(r="linear"),"function"!=typeof d&&(d=wl(d)),p=!!p,void 0!==h){if((l=Vo(l)).length!==(h=Vo(h)).length){if(1===d.length)throw new Error("invalid piecewise interpolator");d=Yn(d,h),h=void 0}}if(1===d.length?(p&&(d=gl(d),p=!1),void 0===h&&2===(h=Float64Array.from(l,((t,n)=>n/(l.length-1)))).length&&(h=vl),n.interpolate((h===vl?To:Nl)(d))):n.interpolate(d),a){const[t,n]=qn(l);if(t>0||n<0){(Dr(l=Uo(l))||1)===Math.sign(t)?l[0]=0:l[l.length-1]=0}}return p&&(l=Vn(l)),n.domain(l).unknown(s),o&&(n.nice(function(t,n){return!0===t?void 0:"number"==typeof t?t:function(t,n){if((t=vi(t,n))&&"function"!=typeof t.ceil)throw new Error("invalid interval: missing ceil method");return t}(t,n)}(o,r)),l=n.domain()),void 0!==h&&n.range(h),i&&n.clamp(i),{type:r,domain:l,range:h,scale:n,interpolate:d,interval:f}}function kl(t,n,{exponent:e=1,...r}){return bl(t,jn().exponent(e),n,{...r,type:"pow"})}function $l(t,e,{domain:r=[0],unknown:o,scheme:i="rdylbu",interpolate:a,range:l=(void 0!==a?ht(a,r.length+1):Yi.get(t)===qi?dl(i,r.length+1):void 0),reverse:s}){const c=Dr(r=Vo(r));if(!isNaN(c)&&!function(t,e){for(let r=1,o=t.length,i=t[0];rvoid 0===t?t:ct(t,n))),N(t,(({value:t})=>void 0===t?t:N(t,n)))]:[0,1]}function Al(t,n){const e=Yi.get(t);return(e===_i||e===Vi||e===Pi?Ll:Ml)(n)}function Ll(t){return[0,t.length?N(t,(({value:t})=>void 0===t?t:N(t,jr))):1]}function El(t,n){const e=t.find((({radius:t})=>void 0!==t));if(void 0!==e)return[0,e.radius];const r=W(t,.5,(({value:t})=>void 0===t?NaN:W(t,.25,Br))),o=n.map((t=>3*Math.sqrt(t/r))),i=30/N(o);return i<1?o.map((t=>t*i)):o}function zl(t,n){const e=ot(t,(({value:t})=>void 0===t?NaN:ot(t,Math.abs))),r=n.map((t=>12*t/e)),o=60/N(r);return o<1?r.map((t=>t*o)):r}function Ol(t){for(const{value:n}of t)if(void 0!==n)for(let e of n){if(e>0)return Ml(t,Br);if(e<0)return Ml(t,Fr)}return[1,10]}function Sl(t){const n=[];for(const{value:e}of t)if(void 0!==e)for(const t of e)n.push(t);return n}function Nl(t){return(n,e)=>r=>t(n+r*(e-n))}let Cl,Tl=0;function Rl(t){t!==Cl&&(Cl=t,console.warn(t),++Tl)}function Il(t,e,r,o,{type:i,nice:a,clamp:l,domain:s=Ml(o),unknown:c,pivot:u=0,scheme:f,range:h,symmetric:d=!0,interpolate:p=(Yi.get(t)===qi?null==f&&void 0!==h?Xn:yl(void 0!==f?f:"rdbu"):Pn),reverse:y}){u=+u,s=Vo(s);let[m,g]=s;if(s.length>2&&Rl(`Warning: the diverging ${t} scale domain contains extra elements.`),n(m,g)<0&&([m,g]=[g,m],y=!y),m=Math.min(m,u),g=Math.max(g,u),"function"!=typeof p&&(p=wl(p)),void 0!==h&&(p=1===p.length?Nl(p)(...h):Yn(p,h)),y&&(p=gl(p)),d){const t=r.apply(u),n=t-r.apply(m),e=r.apply(g)-t;ne&&(g=r.invert(t+n))}return e.domain([m,u,g]).unknown(c).interpolator(p),l&&e.clamp(l),a&&e.nice(a),{type:i,domain:[m,g],pivot:u,interpolate:p,scale:e}}function Wl(t,n,{exponent:e=1,...r}){return Il(t,te().exponent(e=+e),function(t){return.5===t?Dl:{apply:n=>Math.sign(n)*Math.pow(Math.abs(n),t),invert:n=>Math.sign(n)*Math.pow(Math.abs(n),1/t)}}(e),n,{...r,type:"diverging-pow"})}function jl(t,n,{constant:e=1,...r}){return Il(t,ee().constant(e=+e),function(t){return{apply:n=>Math.sign(n)*Math.log1p(Math.abs(n/t)),invert:n=>Math.sign(n)*Math.expm1(Math.abs(n))*t}}(e),n,r)}const Bl={apply:t=>t,invert:t=>t},Fl={apply:Math.log,invert:Math.exp},Dl={apply:t=>Math.sign(t)*Math.sqrt(Math.abs(t)),invert:t=>Math.sign(t)*(t*t)};function ql(t,n,e,r){return bl(t,n,e,r)}const _l=Symbol("ordinal");function Pl(t,n,e,{type:r,interval:o,domain:i,range:a,reverse:l,hint:s}){return o=vi(o,r),void 0===i&&(i=Ul(e,o,t)),"categorical"!==r&&r!==_l||(r="ordinal"),l&&(i=Vn(i)),i=n.domain(i).domain(),void 0!==a&&("function"==typeof a&&(a=a(i)),n.range(a)),{type:r,domain:i,range:a,scale:n,hint:s,interval:o}}function Vl(t,n,{type:e,interval:r,domain:o,range:i,scheme:a,unknown:l,...s}){let c;if(r=vi(r,e),void 0===o&&(o=Ul(n,r,t)),Yi.get(t)===Hi)c=function(t){return{fill:Yl(t,"fill"),stroke:Yl(t,"stroke")}}(n),i=void 0===i?function(t){return Ci(t.fill)?ce:ue}(c):Ho(i,Qi);else if(Yi.get(t)===qi&&(void 0!==i||"ordinal"!==e&&e!==_l||(i=function(t,n="greys"){const e=new Set,[r,o]=dl(n,2);for(const n of t)if(null!=n)if(!0===n)e.add(o);else{if(!1!==n)return;e.add(r)}return[...e]}(o,a),void 0!==i&&(a=void 0)),void 0===a&&void 0===i&&(a="ordinal"===e?"turbo":"observable10"),void 0!==a))if(void 0!==i){const t=yl(a),n=i[0],e=i[1]-i[0];i=({length:r})=>ht((r=>t(n+e*r)),r)}else i=hl(a);if(l===ie)throw new Error(`implicit unknown on ${t} scale is not supported`);return Pl(t,ae().unknown(l),n,{...s,type:e,domain:o,range:i,hint:c})}function Hl(t,n,e,r){let{round:o}=e;return void 0!==o&&t.round(o=!!o),(t=Pl(r,t,n,e)).round=o,t}function Ul(t,n,e){const r=new nt;for(const{value:n,domain:e}of t){if(void 0!==e)return e();if(void 0!==n)for(const t of n)r.add(t)}if(void 0!==n){const[t,e]=qn(r).map(n.floor,n);return n.range(t,n.offset(e))}if(r.size>1e4&&Yi.get(e)===Di)throw new Error(`implicit ordinal domain of ${e} scale has more than 10,000 values`);return K(r,Rr)}function Yl(t,n){let e;for(const{hint:r}of t){const t=r?.[n];if(void 0!==t)if(void 0===e)e=t;else if(e!==t)return}return e}function Xl(t,{label:n,inset:e=0,insetTop:r=e,insetRight:o=e,insetBottom:i=e,insetLeft:a=e,round:l,nice:s,clamp:c,zero:u,align:f,padding:h,projection:d,facet:{label:p=n}={},...y}={}){const m={};for(const[e,g]of t){const t=y[e],v=is(e,g,{round:Yi.get(e)===Di?l:void 0,nice:s,clamp:c,zero:u,align:f,padding:h,projection:d,...t});if(v){let{label:l=("fx"===e||"fy"===e?p:n),percent:s,transform:c,inset:u,insetTop:f=(void 0!==u?u:"y"===e?r:0),insetRight:h=(void 0!==u?u:"x"===e?o:0),insetBottom:d=(void 0!==u?u:"y"===e?i:0),insetLeft:y=(void 0!==u?u:"x"===e?a:0)}=t||{};if(null==c)c=void 0;else if("function"!=typeof c)throw new Error("invalid scale transform; not a function");v.percent=!!s,v.label=void 0===l?Zl(g,v):l,v.transform=c,"x"===e||"fx"===e?(v.insetLeft=+y,v.insetRight=+h):"y"!==e&&"fy"!==e||(v.insetTop=+f,v.insetBottom=+d),m[e]=v}}return m}function Gl(t){const n={},e={scales:n};for(const[r,o]of Object.entries(t)){const{scale:t,type:i,interval:a,label:l}=o;n[r]=ms(o),e[r]=t,t.type=i,null!=a&&(t.interval=a),null!=l&&(t.label=l)}return e}function Zl(t=[],n){let e;for(const{label:n}of t)if(void 0!==n)if(void 0===e)e=n;else if(e!==n)return;if(void 0!==e)return!us(n)&&n.percent&&(e=`${e} (%)`),{inferred:!0,toString:()=>e}}function Jl(t){return Math.sign(Dr(t.domain()))*Math.sign(Dr(t.range()))}function Kl(t){const{marginTop:n,marginRight:e,marginBottom:r,marginLeft:o,width:i,height:a,facet:{marginTop:l,marginRight:s,marginBottom:c,marginLeft:u}}=t;return{marginTop:Math.max(n,l),marginRight:Math.max(e,s),marginBottom:Math.max(r,c),marginLeft:Math.max(o,u),width:i,height:a}}function Ql({fx:t,fy:n},e){const{marginTop:r,marginRight:o,marginBottom:i,marginLeft:a,width:l,height:s}=Kl(e);return{marginTop:r,marginRight:o,marginBottom:i,marginLeft:a,width:t?t.scale.bandwidth()+a+o:l,height:n?n.scale.bandwidth()+r+i:s,facet:{width:l,height:s}}}function ts(t,n){if(void 0===t.range){const{insetLeft:e,insetRight:r}=t,{width:o,marginLeft:i=0,marginRight:a=0}=n,l=i+e,s=o-a-r;t.range=[l,Math.max(l,s)],us(t)||(t.range=rs(t)),t.scale.range(t.range)}es(t)}function ns(t,n){if(void 0===t.range){const{insetTop:e,insetBottom:r}=t,{height:o,marginTop:i=0,marginBottom:a=0}=n,l=i+e,s=o-a-r;t.range=[Math.max(l,s),l],us(t)?t.range.reverse():t.range=rs(t),t.scale.range(t.range)}es(t)}function es(t){void 0===t.round&&function({type:t}){return"point"===t||"band"===t}(t)&&function({scale:t}){const n=t.domain().length,[e,r]=t.range(),o=t.paddingInner?t.paddingInner():1,i=t.paddingOuter?t.paddingOuter():t.padding(),a=n-o,l=Math.abs(r-e)/Math.max(1,a+2*i);return(l-Math.floor(l))*a}(t)<=30&&t.scale.round(!0)}function rs(t){const n=t.scale.domain().length+fs(t);if(!(n>2))return t.range;const[e,r]=t.range;return Array.from({length:n},((t,o)=>e+o/(n-1)*(r-e)))}function os(t,n,e){return is(t,void 0===e?void 0:[{hint:e}],{...n})}function is(t,n=[],e={}){const r=function(t,n,{type:e,domain:r,range:o,scheme:i,pivot:a,projection:l}){if(e=ls(e),"fx"===t||"fy"===t)return"band";"x"!==t&&"y"!==t||null==l||(e=ss);for(const t of n){const n=ls(t.type);if(void 0!==n)if(void 0===e)e=n;else if(e!==n)throw new Error(`scale incompatible with channel: ${e} !== ${n}`)}if(e===ss)return;if(void 0!==e)return e;if(void 0===r&&!n.some((({value:t})=>void 0!==t)))return;const s=Yi.get(t);if(s===_i)return"sqrt";if(s===Vi||s===Pi)return"linear";if(s===Hi)return"ordinal";if((r||o||[]).length>2)return cs(s);if(void 0!==r){if($i(r))return cs(s);if(Mi(r))return"utc"}else{const t=n.map((({value:t})=>t)).filter((t=>void 0!==t));if(t.some($i))return cs(s);if(t.some(Mi))return"utc"}if(s===qi){if(null!=a||function(t){return null!=t&&ml.has(`${t}`.toLowerCase())}(i))return"diverging";if(function(t){return null!=t&&il.has(`${t}`.toLowerCase())}(i))return"categorical"}return"linear"}(t,n,e);if(void 0===e.type&&void 0===e.domain&&void 0===e.range&&null==e.interval&&"fx"!==t&&"fy"!==t&&us({type:r})){const e=n.map((({value:t})=>t)).filter((t=>void 0!==t));e.some(Mi)?Rl(`Warning: some data associated with the ${t} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${as(r)}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can specify the interval of the ${t} scale (e.g., d3.utcDay), or you can suppress this warning by setting the type of the ${t} scale to "${as(r)}".`):e.some(Ai)?Rl(`Warning: some data associated with the ${t} scale are strings that appear to be dates (e.g., YYYY-MM-DD). If these strings represent dates, you should parse them to Date objects. Dates are typically associated with a "utc" or "time" scale rather than a "${as(r)}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${t} scale to "${as(r)}".`):e.some(Li)&&Rl(`Warning: some data associated with the ${t} scale are strings that appear to be numbers. If these strings represent numbers, you should parse or coerce them to numbers. Numbers are typically associated with a "linear" scale rather than a "${as(r)}" scale. If you want to treat this data as ordinal, you can specify the interval of the ${t} scale (e.g., 1 for integers), or you can suppress this warning by setting the type of the ${t} scale to "${as(r)}".`)}switch(e.type=r,r){case"diverging":case"diverging-sqrt":case"diverging-pow":case"diverging-log":case"diverging-symlog":case"cyclical":case"sequential":case"linear":case"sqrt":case"threshold":case"quantile":case"pow":case"log":case"symlog":e=ds(n,e,Io);break;case"identity":switch(Yi.get(t)){case Di:e=ds(n,e,Io);break;case Hi:e=ds(n,e,ps)}break;case"utc":case"time":e=ds(n,e,jo)}switch(r){case"diverging":return function(t,n,e){return Il(t,Qn(),Bl,n,e)}(t,n,e);case"diverging-sqrt":return function(t,n,e){return Wl(t,n,{...e,exponent:.5})}(t,n,e);case"diverging-pow":return Wl(t,n,e);case"diverging-log":return function(t,n,{base:e=10,pivot:r=1,domain:o=Ml(n,r<0?Fr:Br),...i}){return Il(t,ne().base(e=+e),Fl,n,{domain:o,pivot:r,...i})}(t,n,e);case"diverging-symlog":return jl(t,n,e);case"categorical":case"ordinal":case _l:return Vl(t,n,e);case"cyclical":case"sequential":case"linear":return function(t,n,e){return bl(t,Wn(),n,e)}(t,n,e);case"sqrt":return function(t,n,e){return kl(t,n,{...e,exponent:.5})}(t,n,e);case"threshold":return $l(t,0,e);case"quantile":return function(t,n,{range:e,quantiles:r=(void 0===e?5:(e=[...e]).length),n:o=r,scheme:i="rdylbu",domain:a=Sl(n),unknown:l,interpolate:s,reverse:c}){return void 0===e&&(e=void 0!==s?ht(s,o):Yi.get(t)===qi?dl(i,o):void 0),a.length>0&&(a=Dn(a,void 0===e?{length:o}:e).quantiles()),$l(t,0,{domain:a,range:e,reverse:c,unknown:l})}(t,n,e);case"quantize":return function(t,n,{range:e,n:r=(void 0===e?5:(e=[...e]).length),scheme:o="rdylbu",domain:i=Al(t,n),unknown:a,interpolate:l,reverse:s}){const[c,u]=qn(i);let f;return void 0===e?(f=_n(c,u,r),f[0]<=c&&f.splice(0,1),f[f.length-1]>=u&&f.pop(),r=f.length+1,e=void 0!==l?ht(l,r):Yi.get(t)===qi?dl(o,r):void 0):(f=ht(Pn(c,u),r+1).slice(1,-1),c instanceof Date&&(f=f.map((t=>new Date(t))))),Dr(Vo(i))<0&&f.reverse(),$l(t,0,{domain:f,range:e,reverse:s,unknown:a})}(t,n,e);case"pow":return kl(t,n,e);case"log":return function(t,n,{base:e=10,domain:r=Ol(n),...o}){return bl(t,Bn().base(e),n,{...o,domain:r})}(t,n,e);case"symlog":return function(t,n,{constant:e=1,...r}){return bl(t,Fn().constant(e),n,r)}(t,n,e);case"utc":return function(t,n,e){return ql(t,oe(),n,e)}(t,n,e);case"time":return function(t,n,e){return ql(t,re(),n,e)}(t,n,e);case"point":return function(t,n,{align:e=.5,padding:r=.5,...o}){return Hl(le().align(e).padding(r),n,o,t)}(t,n,e);case"band":return function(t,n,{align:e=.5,padding:r=.1,paddingInner:o=r,paddingOuter:i=("fx"===t||"fy"===t?0:r),...a}){return Hl(se().align(e).paddingInner(o).paddingOuter(i),n,a,t)}(t,n,e);case"identity":return function(t){return{type:"identity",scale:(n=Yi.get(t),n===Di||n===_i||n===Pi||n===Vi?Un():t=>t)};var n}(t);case void 0:return;default:throw new Error(`unknown scale type: ${r}`)}}function as(t){return"symbol"==typeof t?t.description:t}function ls(t){return"string"==typeof t?`${t}`.toLowerCase():t}const ss={toString:()=>"projection"};function cs(t){switch(t){case Di:return"point";case qi:return _l;default:return"ordinal"}}function us({type:t}){return"ordinal"===t||"point"===t||"band"===t||t===_l}function fs({type:t}){return"threshold"===t}function hs(t){if(void 0===t)return!0;const n=t.domain(),e=t(n[0]);for(let r=1,o=n.length;rt,invert:t=>t};const c=t.unknown?t.unknown():void 0;return{type:n,domain:Uo(e),...void 0!==r&&{range:Uo(r)},...void 0!==a&&{transform:a},...l&&{percent:l},...void 0!==c&&{unknown:c},...void 0!==i&&{interval:i},...void 0!==o&&{interpolate:o},...t.clamp&&{clamp:t.clamp()},...void 0!==s&&{pivot:s,symmetric:!1},...t.base&&{base:t.base()},...t.exponent&&{exponent:t.exponent()},...t.constant&&{constant:t.constant()},...t.align&&{align:t.align(),round:t.round()},...t.padding&&(t.paddingInner?{paddingInner:t.paddingInner(),paddingOuter:t.paddingOuter()}:{padding:t.padding()}),...t.bandwidth&&{bandwidth:t.bandwidth(),step:t.step()},apply:n=>t(n),...t.invert&&{invert:n=>t.invert(n)}}}function gs(t,{fx:n,fy:e}){const r=oi(t),o=n?.value,i=e?.value;return n&&e?Q(r,(t=>(t.fx=o[t[0]],t.fy=i[t[0]],t)),(t=>o[t]),(t=>i[t])):n?Q(r,(t=>(t.fx=o[t[0]],t)),(t=>o[t])):Q(r,(t=>(t.fy=i[t[0]],t)),(t=>i[t]))}function vs(t){const n=[],e=new Uint32Array(tt(t,(t=>t.length)));for(const r of t){let o=0;for(const n of t)r!==n&&(e.set(n,o),o+=n.length);n.push(e.slice(0,o))}return n}const xs=new Map([["top",Ms],["right",Es],["bottom",As],["left",Ls],["top-left",zs(Ms,Ls)],["top-right",zs(Ms,Es)],["bottom-left",zs(As,Ls)],["bottom-right",zs(As,Es)],["top-empty",function(t,{y:n},{x:e,y:r,empty:o}){if(o)return!1;if(!n)return;const i=ks(n,r);if(i>0)return $s(t,e,n[i-1])}],["right-empty",function(t,{x:n},{x:e,y:r,empty:o}){if(o)return!1;if(!n)return;const i=ks(n,e);if(i0)return $s(t,n[i-1],r)}],["empty",function(t,n,{empty:e}){return e}]]);const ws=new WeakMap;function bs(t){let n=ws.get(t);return n||ws.set(t,n=new he(Ho(t,((t,n)=>[t,n])))),n}function ks(t,n){return bs(t).get(n)}function $s(t,n,e){return function(t,n,e){return n=si(n),e=si(e),t.find((t=>Object.is(si(t.x),n)&&Object.is(si(t.y),e)))}(t,n,e)?.empty}function Ms(t,{y:n},{y:e}){return!n||0===ks(n,e)}function As(t,{y:n},{y:e}){return!n||ks(n,e)===n.length-1}function Ls(t,{x:n},{x:e}){return!n||0===ks(n,e)}function Es(t,{x:n},{x:e}){return!n||ks(n,e)===n.length-1}function zs(t,n){return function(){return t.apply(null,arguments)&&n.apply(null,arguments)}}function Os(t,{channels:{fx:n,fy:e},groups:r}){return n&&e?t.map((({x:t,y:n})=>r.get(t)?.get(n)??[])):n?t.map((({x:t})=>r.get(t)??[])):t.map((({y:t})=>r.get(t)??[]))}const Ss=Math.PI,Ns=2*Ss,Cs=.618;function Ts({projection:t,inset:n=0,insetTop:e=n,insetRight:r=n,insetBottom:o=n,insetLeft:i=n}={},a){if(null==t)return;if("function"==typeof t.stream)return t;let l,s,c="frame";if(Zo(t)){let n;if(({type:t,domain:s,inset:n,insetTop:e=(void 0!==n?n:e),insetRight:r=(void 0!==n?n:r),insetBottom:o=(void 0!==n?n:o),insetLeft:i=(void 0!==n?n:i),clip:c=c,...l}=t),null==t)return}"function"!=typeof t&&({type:t}=Rs(t));const{width:u,height:f,marginLeft:h,marginRight:d,marginTop:p,marginBottom:y}=a,m=u-h-d-i-r,g=f-p-y-e-o;if(t=t?.({width:m,height:g,clip:c,...l}),null==t)return;c=function(t,n,e,r,o){if(!1===t||null==t||"number"==typeof t)return t=>t;!0===t&&(t="frame");if("frame"===`${t}`.toLowerCase())return ye(n,e,r,o);throw new Error(`unknown projection clip type: ${t}`)}(c,h,p,u-d,f-y);let v,x=h+i,w=p+e;if(null!=s){const[[n,e],[r,o]]=pe(t).bounds(s),i=Math.min(m/(r-n),g/(o-e));i>0?(x-=(i*(n+r)-m)/2,w-=(i*(e+o)-g)/2,v=de({point(t,n){this.stream.point(t*i+x,n*i+w)}})):Rl("Warning: the projection could not be fit to the specified domain; using the default scale.")}return v??=0===x&&0===w?js():de({point(t,n){this.stream.point(t+x,n+w)}}),{stream:n=>t.stream(v.stream(c(n)))}}function Rs(t){switch(`${t}`.toLowerCase()){case"albers-usa":return Is(Le,.7463,.4673);case"albers":return Ws(Se,.7463,.4673);case"azimuthal-equal-area":return Is(Ae,4,4);case"azimuthal-equidistant":return Is(Me,Ns,Ns);case"conic-conformal":return Ws(Oe,Ns,Ns);case"conic-equal-area":return Ws(ze,6.1702,2.9781);case"conic-equidistant":return Ws(Ee,7.312,3.6282);case"equal-earth":return Is($e,5.4133,2.6347);case"equirectangular":return Is(ke,Ns,Ss);case"gnomonic":return Is(be,3.4641,3.4641);case"identity":return{type:js};case"reflect-y":return{type:Bs};case"mercator":return Is(we,Ns,Ns);case"orthographic":return Is(xe,2,2);case"stereographic":return Is(ve,2,2);case"transverse-mercator":return Is(ge,Ns,Ns);default:throw new Error(`unknown projection type: ${t}`)}}function Is(t,n,e){return{type:({width:r,height:o,rotate:i,precision:a=.15,clip:l})=>{const s=t();return null!=a&&s.precision?.(a),null!=i&&s.rotate?.(i),"number"==typeof l&&s.clipAngle?.(l),null!=r&&(s.scale(Math.min(r/n,o/e)),s.translate([r/2,o/2])),s},aspectRatio:e/n}}function Ws(t,n,e){const{type:r,aspectRatio:o}=Is(t,n,e);return{type:t=>{const{parallels:n,domain:e,width:o,height:i}=t,a=r(t);return null!=n&&(a.parallels(n),void 0===e&&null!=o&&a.fitSize([o,i],{type:"Sphere"})),a},aspectRatio:o}}const js=To({stream:t=>t}),Bs=To(de({point(t,n){this.stream.point(t,-n)}}));function Fs(t,n,e,r){const o=e[t],i=e[n],a=o.length,l=e[t]=new Float64Array(a).fill(NaN),s=e[n]=new Float64Array(a).fill(NaN);let c;const u=r.stream({point(t,n){l[c]=t,s[c]=n}});for(c=0;c(Object.is(e,r)||(e=r,n=t(r)),n)}function Xs(t){let n,e;return(...r)=>((e?.length!==r.length||e.some(((t,n)=>!Object.is(t,r[n]))))&&(e=r,n=t(...r)),n)}const Gs=Us((t=>new Intl.NumberFormat(t))),Zs=Us(((t,n)=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...n&&{month:n}}))),Js=Us(((t,n)=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...n&&{weekday:n}})));function Ks(t="en-US"){const n=Gs(t);return t=>null==t||isNaN(t)?void 0:n.format(t)}function Qs(t="en-US",n="short"){const e=Zs(t,n);return t=>null==t||isNaN(t=+new Date(Date.UTC(2e3,+t)))?void 0:e.format(t)}function tc(t="en-US",n="short"){const e=Js(t,n);return t=>null==t||isNaN(t=+new Date(Date.UTC(2001,0,+t)))?void 0:e.format(t)}function nc(t){return Nr(t,"Invalid Date")}const ec=function(t="en-US"){const n=Ks(t);return t=>(t instanceof Date?nc:"number"==typeof t?n:zo)(t)}(),rc=("undefined"!=typeof window?window.devicePixelRatio>1:"undefined"==typeof it)?0:.5;let oc=0,ic=0;function ac(){return"plot-clip-"+ ++oc}function lc(t,{title:n,href:e,ariaLabel:r,ariaDescription:o,ariaHidden:i,target:a,fill:l,fillOpacity:s,stroke:c,strokeWidth:u,strokeOpacity:f,strokeLinejoin:h,strokeLinecap:d,strokeMiterlimit:p,strokeDasharray:y,strokeDashoffset:m,opacity:g,mixBlendMode:v,imageFilter:x,paintOrder:w,pointerEvents:b,shapeRendering:k,channels:$},{ariaLabel:M,fill:A="currentColor",fillOpacity:L,stroke:E="none",strokeOpacity:z,strokeWidth:O,strokeLinecap:S,strokeLinejoin:N,strokeMiterlimit:C,paintOrder:T}){null===A&&(l=null,s=null),null===E&&(c=null,f=null),Ci(A)?Ci(E)||Ci(l)&&!$?.fill||(E="none"):!Ci(E)||Ci(c)&&!$?.stroke||(A="none");const[R,I]=Fo(l,A),[W,j]=Do(s,L),[B,F]=Fo(c,E),[D,q]=Do(f,z),[_,P]=Do(g);Ti(F)||(void 0===u&&(u=O),void 0===d&&(d=S),void 0===h&&(h=N),void 0!==p||/^\s*round\s*$/i.test(h)||(p=C),Ti(I)||void 0!==w||(w=T));const[V,H]=Do(u);return null!==A&&(t.fill=kc(I,"currentColor"),t.fillOpacity=$c(j,1)),null!==E&&(t.stroke=kc(F,"none"),t.strokeWidth=$c(H,1),t.strokeOpacity=$c(q,1),t.strokeLinejoin=kc(h,"miter"),t.strokeLinecap=kc(d,"butt"),t.strokeMiterlimit=$c(p,4),t.strokeDasharray=kc(y,"none"),t.strokeDashoffset=kc(m,"0")),t.target=zo(a),t.ariaLabel=zo(M),t.ariaDescription=zo(o),t.ariaHidden=zo(i),t.opacity=$c(P,1),t.mixBlendMode=kc(v,"normal"),t.imageFilter=kc(x,"none"),t.paintOrder=kc(w,"normal"),t.pointerEvents=kc(b,"auto"),t.shapeRendering=kc(k,"auto"),{title:{value:n,optional:!0,filter:null},href:{value:e,optional:!0,filter:null},ariaLabel:{value:r,optional:!0,filter:null},fill:{value:R,scale:"auto",optional:!0},fillOpacity:{value:W,scale:"auto",optional:!0},stroke:{value:B,scale:"auto",optional:!0},strokeOpacity:{value:D,scale:"auto",optional:!0},strokeWidth:{value:V,optional:!0},opacity:{value:_,scale:"auto",optional:!0}}}function sc(t,n){n&&t.text((t=>ec(n[t])))}function cc(t,n){n&&t.text((([t])=>ec(n[t])))}function uc(t,{target:n,tip:e},{ariaLabel:r,title:o,fill:i,fillOpacity:a,stroke:l,strokeOpacity:s,strokeWidth:c,opacity:u,href:f}){r&&wc(t,"aria-label",(t=>r[t])),i&&wc(t,"fill",(t=>i[t])),a&&wc(t,"fill-opacity",(t=>a[t])),l&&wc(t,"stroke",(t=>l[t])),s&&wc(t,"stroke-opacity",(t=>s[t])),c&&wc(t,"stroke-width",(t=>c[t])),u&&wc(t,"opacity",(t=>u[t])),f&&xc(t,(t=>f[t]),n),e||function(t,n){n&&t.filter((t=>Wr(n[t]))).append("title").call(sc,n)}(t,o)}function fc(t,{target:n,tip:e},{ariaLabel:r,title:o,fill:i,fillOpacity:a,stroke:l,strokeOpacity:s,strokeWidth:c,opacity:u,href:f}){r&&wc(t,"aria-label",(([t])=>r[t])),i&&wc(t,"fill",(([t])=>i[t])),a&&wc(t,"fill-opacity",(([t])=>a[t])),l&&wc(t,"stroke",(([t])=>l[t])),s&&wc(t,"stroke-opacity",(([t])=>s[t])),c&&wc(t,"stroke-width",(([t])=>c[t])),u&&wc(t,"opacity",(([t])=>u[t])),f&&xc(t,(([t])=>f[t]),n),e||function(t,n){n&&t.filter((([t])=>Wr(n[t]))).append("title").call(cc,n)}(t,o)}function hc(t,n,e){const r=J(t,(t=>n[t]));return void 0===e&&r.size>1+t.length>>1&&Rl("Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null."),r.values()}function*dc(t,n,e,r){const{z:o}=e,{z:i}=r,a=function({ariaLabel:t,title:n,fill:e,fillOpacity:r,stroke:o,strokeOpacity:i,strokeWidth:a,opacity:l,href:s},{tip:c}){return[t,c?void 0:n,e,r,o,i,a,l,s].filter((t=>void 0!==t))}(r,e),l=[...n,...a];for(const n of i?hc(t,i,o):[t]){let t,e;t:for(const r of n){for(const t of l)if(!Tr(t[r])){e&&e.push(-1);continue t}if(void 0!==t){e.push(r);for(let n=0;nsi(t[r]))),e=[r];continue t}}}else e&&(yield e),t=a.map((t=>si(t[r]))),e=[r]}e&&(yield e)}}function pc(t){const n=new WeakMap;return(e,r)=>{let o=n.get(e);if(!o){const i=ac();Ne(e.ownerSVGElement).append("clipPath").attr("id",i).call(t,e,r),n.set(e,o=`url(#${i})`)}return o}}const yc=pc(((t,n,e)=>{const{width:r,height:o,marginLeft:i,marginRight:a,marginTop:l,marginBottom:s}=e;t.append("rect").attr("x",i).attr("y",l).attr("width",r-a-i).attr("height",o-l-s)})),mc=pc(((t,n)=>{const{projection:e}=n;if(!e)throw new Error('the "sphere" clip option requires a projection');t.append("path").attr("d",pe(e)({type:"Sphere"}))}));function gc(t,n,e,r){!function(t,n,e,r){let o;const{clip:i=r.clip}=n;switch(i){case"frame":t=Vs("svg:g",r).each((function(){this.appendChild(t.node()),t.node=()=>this})),o=yc(r,e);break;case"sphere":o=mc(r)}wc(t,"aria-label",n.ariaLabel),wc(t,"aria-description",n.ariaDescription),wc(t,"aria-hidden",n.ariaHidden),wc(t,"clip-path",o)}(t,n,e,r),wc(t,"class",n.className),wc(t,"fill",n.fill),wc(t,"fill-opacity",n.fillOpacity),wc(t,"stroke",n.stroke),wc(t,"stroke-width",n.strokeWidth),wc(t,"stroke-opacity",n.strokeOpacity),wc(t,"stroke-linejoin",n.strokeLinejoin),wc(t,"stroke-linecap",n.strokeLinecap),wc(t,"stroke-miterlimit",n.strokeMiterlimit),wc(t,"stroke-dasharray",n.strokeDasharray),wc(t,"stroke-dashoffset",n.strokeDashoffset),wc(t,"shape-rendering",n.shapeRendering),wc(t,"filter",n.imageFilter),wc(t,"paint-order",n.paintOrder);const{pointerEvents:o=(!1===r.pointerSticky?"none":void 0)}=n;wc(t,"pointer-events",o)}function vc(t,n){!function(t,n,e){null!=e&&t.style(n,e)}(t,"mix-blend-mode",n.mixBlendMode),wc(t,"opacity",n.opacity)}function xc(t,n,e){t.each((function(t){const r=n(t);if(null!=r){const t=this.ownerDocument.createElementNS(Te.svg,"a");t.setAttribute("fill","inherit"),t.setAttributeNS(Te.xlink,"href",r),null!=e&&t.setAttribute("target",e),this.parentNode.insertBefore(t,this).appendChild(this)}}))}function wc(t,n,e){null!=e&&t.attr(n,e)}function bc(t,n,{x:e,y:r},o=rc,i=rc){o+=n.dx,i+=n.dy,e?.bandwidth&&(o+=e.bandwidth()/2),r?.bandwidth&&(i+=r.bandwidth()/2),(o||i)&&t.attr("transform",`translate(${o},${i})`)}function kc(t,n){if((t=zo(t))!==n)return t}function $c(t,n){if((t=Oo(t))!==n)return t}const Mc=/^-?([_a-z]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*$/i;function Ac(t){if(void 0===t)return"plot-d6a7b5";if(t=`${t}`,!Mc.test(t))throw new Error(`invalid class name: ${t}`);return t}function Lc(t,n){if("string"==typeof n)t.property("style",n);else if(null!=n)for(const e of t)Object.assign(e.style,n)}function Ec({frameAnchor:t},{width:n,height:e,marginTop:r,marginRight:o,marginBottom:i,marginLeft:a}){return[/left$/.test(t)?a:/right$/.test(t)?n-o:(a+n-o)/2,/^top/.test(t)?r:/^bottom/.test(t)?e-i:(r+e-i)/2]}class zc{constructor(t,n={},e={},r){const{facet:o="auto",facetAnchor:i,fx:a,fy:l,sort:s,dx:c=0,dy:u=0,margin:f=0,marginTop:h=f,marginRight:d=f,marginBottom:p=f,marginLeft:y=f,className:m,clip:g=r?.clip,channels:v,tip:x,render:w}=e;if(this.data=t,this.sort=Qo(s)?s:null,this.initializer=na(e).initializer,this.transform=this.initializer?e.transform:ta(e).transform,null===o||!1===o?this.facet=null:(this.facet=_o(!0===o?"include":o,"facet",["auto","include","exclude","super"]),this.fx=t===ko&&"string"==typeof a?[a]:a,this.fy=t===ko&&"string"==typeof l?[l]:l),this.facetAnchor=function(t){if(null==t)return null;const n=xs.get(`${t}`.toLowerCase());if(n)return n;throw new Error(`invalid facet anchor: ${t}`)}(i),n=Wi(n),void 0!==v&&(n={...Nc(v),...n}),void 0!==r&&(n={...lc(this,e,r),...n}),this.channels=Object.fromEntries(Object.entries(n).map((([n,e])=>{if(Ko(e.value)){const{value:t,label:n=e.label,scale:r=e.scale}=e.value;e={...e,label:n,scale:r,value:t}}if(t===ko&&"string"==typeof e.value){const{value:t}=e;e={...e,value:[t]}}return[n,e]})).filter((([t,{value:n,optional:e}])=>{if(null!=n)return!0;if(e)return!1;throw new Error(`missing channel value: ${t}`)}))),this.dx=+c,this.dy=+u,this.marginTop=+h,this.marginRight=+d,this.marginBottom=+p,this.marginLeft=+y,this.clip=ji(g),this.tip=function(t){return!0===t?"xy":!1===t||null==t?null:"string"==typeof t?_o(t,"tip",["x","y","xy"]):t}(x),this.className=m?Ac(m):null,"super"===this.facet){if(a||l)throw new Error("super-faceting cannot use fx or fy");for(const t in this.channels){const{scale:e}=n[t];if("x"===e||"y"===e)throw new Error("super-faceting cannot use x or y")}}null!=w&&(this.render=Sc(w,this.render))}initialize(t,n,e){let r=Po(this.data);void 0===t&&null!=r&&(t=[oi(r)]);const o=t;null!=this.transform&&(({facets:t,data:r}=this.transform(r,t,e)),r=Po(r)),void 0!==t&&(t.original=o);const i=Xa(this.channels,r);return null!=this.sort&&function(t,n,e,r,o){const{order:i,reverse:a,reduce:l=!0,limit:s}=o;for(const c in o){if(!Yi.has(c))continue;let{value:u,order:f=i,reverse:h=a,reduce:d=l,limit:p=s}=wi(o[c]);const y=u?.startsWith("-");if(y&&(u=u.slice(1)),f=void 0===f?y!==("width"===u||"height"===u)?rl:el:nl(f),null==d||!1===d)continue;const m="fx"===c||"fy"===c?Ka(n,r[c]):Ja(e,c);if(!m)throw new Error(`missing channel for scale: ${c}`);const g=m.value,[v=0,x=1/0]=bi(p)?p:p<0?[p]:[0,p];if(null==u)m.domain=()=>{let t=Array.from(new nt(g));return h&&(t=t.reverse()),0===v&&x===1/0||(t=t.slice(v,x)),t};else{const n="data"===u?t:"height"===u?Qa(e,"y1","y2"):"width"===u?Qa(e,"x1","x2"):tl(e,u,"y"===u?"y2":"x"===u?"x2":void 0),r=Ma(!0===d?"max":d,n);m.domain=()=>{let t=ft(oi(g),(t=>r.reduceIndex(t,n)),(t=>g[t]));return f&&t.sort(f),h&&t.reverse(),0===v&&x===1/0||(t=t.slice(v,x)),t.map(So)}}}}(r,t,i,n,this.sort),{data:r,facets:t,channels:i}}filter(t,n,e){for(const r in n){const{filter:o=Tr}=n[r];if(null!==o){const n=e[r];t=t.filter((t=>o(n[t])))}}return t}project(t,n,e){for(const r in t)if("x"===t[r].scale&&/^x|x$/.test(r)){const o=r.replace(/^x|x$/,"y");o in t&&"y"===t[o].scale&&Fs(r,o,n,e.projection)}}scale(t,n,e){const r=Ga(t,n);return e.projection&&this.project(t,r,e),r}}function Oc(...t){return t.plot=zc.prototype.plot,t}function Sc(t,n){if(null==t)return null===n?void 0:n;if(null==n)return null===t?void 0:t;if("function"!=typeof t)throw new TypeError(`invalid render transform: ${t}`);if("function"!=typeof n)throw new TypeError(`invalid render transform: ${n}`);return function(e,r,o,i,a,l){return t.call(this,e,r,o,i,a,((t,e,r,o,i)=>n.call(this,t,e,r,o,i,l)))}}function Nc(t){return Object.fromEntries(Object.entries(Wi(t)).map((([t,n])=>(void 0===(n="string"==typeof n?{value:n,label:t}:wi(n)).filter&&null==n.scale&&(n={...n,filter:null}),[t,n]))))}function Cc(t,n){return!0===t?.tip?{...t,tip:n}:Zo(t?.tip)&&void 0===t.tip.pointer?{...t,tip:{...t.tip,pointer:n}}:t}function Tc({x:t,y:n,fy:e,fx:r},{projection:o,aspectRatio:i},{width:a,marginTopDefault:l,marginRightDefault:s,marginBottomDefault:c,marginLeftDefault:u}){const f=e&&e.scale.domain().length||1,h=function(t){if("function"==typeof t?.stream)return Cs;if(Zo(t)){let n,e;if(({domain:n,type:t,...e}=t),null!=n&&null!=t){const r="string"==typeof t?Rs(t).type:t,[[o,i],[a,l]]=pe(r({...e,width:100,height:100})).bounds(n),s=(l-i)/(a-o);return s&&isFinite(s)?s<.2?.2:s>5?5:s:Cs}}if(null!=t){if("function"!=typeof t){const{aspectRatio:n}=Rs(t);if(n)return n}return Cs}}(o);if(h){const t=(1.1*f-.1)/(1.1*(r?r.scale.domain().length:1)-.1)*h,n=Math.max(.1,Math.min(10,t));return Math.round((a-u-s)*n+l+c)}const d=n?us(n)?n.scale.domain().length||1:Math.max(7,17/f):1;if(null!=i){if(i=+i,!(isFinite(i)&&i>0))throw new Error(`invalid aspectRatio: ${i}`);const o=Rc("y",n)/(Rc("x",t)*i),f=r?r.scale.bandwidth():1,h=e?e.scale.bandwidth():1;return(o*(f*(a-u-s)-t.insetLeft-t.insetRight)+n.insetTop+n.insetBottom)/h+l+c}return!(!n&&!e)*Math.max(1,Math.min(60,d*f))*20+30*!!r+60}function Rc(t,n){if(!n)throw new Error(`aspectRatio requires ${t} scale`);const{type:e,domain:r}=n;let o;switch(e){case"linear":case"utc":case"time":o=Number;break;case"pow":{const t=n.scale.exponent();o=n=>Math.pow(n,t);break}case"log":o=Math.log;break;case"point":case"band":return r.length;default:throw new Error(`unsupported ${t} scale for aspectRatio: ${e}`)}const[i,a]=qn(r);return Math.abs(o(a)-o(i))}const Ic=new WeakMap;function Wc(t,n,{x:e,y:r,px:o,py:i,maxRadius:a=40,channels:l,render:s,...c}={}){return a=+a,null!=o&&(e??=null,l={...l,px:{value:o,scale:"x"}}),null!=i&&(r??=null,l={...l,py:{value:i,scale:"y"}}),{x:e,y:r,channels:l,...c,render:Sc((function(e,r,o,i,l,s){const c=(l={...l,pointerSticky:!1}).ownerSVGElement,{data:u}=l.getMarkState(this);let f=Ic.get(c);f||Ic.set(c,f={sticky:!1,roots:[],renders:[]});let h=f.renders.push(C)-1;const{x:d,y:p,fx:y,fy:m}=r;let g=y?y(e.fx)-i.marginLeft:0,v=m?m(e.fy)-i.marginTop:0;d?.bandwidth&&(g+=d.bandwidth()/2),p?.bandwidth&&(v+=p.bandwidth()/2);const x=null!=e.fi;let w;if(x){let t=f.facetStates;t||(f.facetStates=t=new Map),w=t.get(this),w||t.set(this,w=new Map)}const[b,k]=Ec(this,i),{px:$,py:M}=o,A=$?t=>$[t]:Dc(o,b),L=M?t=>M[t]:qc(o,k);let E,z,O,S;function N(t,n){if(x){if(S&&(S=cancelAnimationFrame(S)),null!=t)return w.set(e.fi,n),void(S=requestAnimationFrame((()=>{S=null;for(const[r,o]of w)if(o1)){const t=null==E?null:po(u)?u[E]:u.get(E);l.dispatchValue(t)}return a}function T(r){if(f.sticky||"mouse"===r.pointerType&&1===r.buttons)return;let[o,l]=Re(r);o-=g,l-=v;const s=oi.width-i.marginRight?1:t,c=li.height-i.marginBottom?1:n;let u=null,h=a*a;for(const t of e){const n=s*(A(t)-o),e=c*(L(t)-l),r=n*n+e*e;r<=h&&(u=t,h=r)}if(null!=u&&(1!==t||1!==n)){const t=A(u)-o,n=L(u)-l;h=t*t+n*n}N(u,h)}return c.addEventListener("pointerenter",T),c.addEventListener("pointermove",T),c.addEventListener("pointerdown",(function(t){"mouse"===t.pointerType&&null!=E&&(f.sticky&&f.roots.some((n=>n?.contains(t.target)))||(f.sticky?(f.sticky=!1,f.renders.forEach((t=>t(null)))):(f.sticky=!0,C(E)),t.stopImmediatePropagation()))})),c.addEventListener("pointerleave",(function(t){"mouse"===t.pointerType&&(f.sticky||N(null))})),C(null)}),s)}}function jc(t){return Wc(1,1,t)}function Bc(t){return Wc(1,.01,t)}function Fc(t){return Wc(.01,1,t)}function Dc({x1:t,x2:n,x:e=t},r){return t&&n?e=>(t[e]+n[e])/2:e?t=>e[t]:()=>r}function qc({y1:t,y2:n,y:e=t},r){return t&&n?e=>(t[e]+n[e])/2:e?t=>e[t]:()=>r}function _c(t){return us(t)&&void 0===t.interval?void 0:"tabular-nums"}const Pc=Math.PI/180;function Vc(t,{marker:n,markerStart:e=n,markerMid:r=n,markerEnd:o=n}={}){t.markerStart=Hc(e),t.markerMid=Hc(r),t.markerEnd=Hc(o)}function Hc(t){if(null==t||!1===t)return null;if(!0===t)return Xc;if("function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"none":return null;case"arrow":return Uc("auto");case"arrow-reverse":return Uc("auto-start-reverse");case"dot":return Yc;case"circle":case"circle-fill":return Xc;case"circle-stroke":return Gc;case"tick":return Zc("auto");case"tick-x":return Zc(90);case"tick-y":return Zc(0)}throw new Error(`invalid marker: ${t}`)}function Uc(t){return(n,e)=>Vs("svg:marker",e).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("orient",t).attr("fill","none").attr("stroke",n).attr("stroke-width",1.5).attr("stroke-linecap","round").attr("stroke-linejoin","round").call((t=>t.append("path").attr("d","M-1.5,-3l3,3l-3,3"))).node()}function Yc(t,n){return Vs("svg:marker",n).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill",t).attr("stroke","none").call((t=>t.append("circle").attr("r",2.5))).node()}function Xc(t,n){return Vs("svg:marker",n).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill",t).attr("stroke","var(--plot-background)").attr("stroke-width",1.5).call((t=>t.append("circle").attr("r",3))).node()}function Gc(t,n){return Vs("svg:marker",n).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill","var(--plot-background)").attr("stroke",t).attr("stroke-width",1.5).call((t=>t.append("circle").attr("r",3))).node()}function Zc(t){return(n,e)=>Vs("svg:marker",e).attr("viewBox","-3 -3 6 6").attr("markerWidth",6).attr("markerHeight",6).attr("orient",t).attr("stroke",n).call((t=>t.append("path").attr("d","M0,-3v6"))).node()}let Jc=0;function Kc(t,n,{stroke:e},r){return eu(t,n,e&&(t=>e[t]),null,r)}function Qc(t,n,{stroke:e,z:r},o){return eu(t,n,e&&(([t])=>e[t]),r,o)}const tu=1,nu=2;function eu(t,{markerStart:n,markerMid:e,markerEnd:r,stroke:o},i=(()=>o),a,l){if(!n&&!e&&!r)return;const s=new Map,c=a&&function(t,n){const e=new Uint8Array(n.length),r=t.data().filter((t=>t.length>1)),o=r.length;for(let t=0,i=Hs;t1){const t=o[0];i!==(i=si(n[t]))&&(e[t]|=tu)}}for(let t=o-1,i=Hs;t>=0;--t){const o=r[t];if(o.length>1){const t=o[0];i!==(i=si(n[t]))&&(e[t]|=nu)}}return([t])=>e[t]}(t,a);function u(t,n,e){return function(r){if(e&&!e(r))return;const o=i(r);let a=s.get(n);a||s.set(n,a=new Map);let c=a.get(o);if(!c){const t=this.parentNode.insertBefore(n(o,l),this),e="plot-marker-"+ ++Jc;t.setAttribute("id",e),a.set(o,c=`url(#${e})`)}this.setAttribute(t,c)}}n&&t.each(u("marker-start",n,c&&(t=>c(t)&tu))),e&&c&&t.each(u("marker-start",e,(t=>!(c(t)&tu)))),e&&t.each(u("marker-mid",e)),r&&t.each(u("marker-end",r,c&&(t=>c(t)&nu)))}function ru({inset:t,insetLeft:n,insetRight:e,...r}={}){return[n,e]=iu(t,n,e),{inset:t,insetLeft:n,insetRight:e,...r}}function ou({inset:t,insetTop:n,insetBottom:e,...r}={}){return[n,e]=iu(t,n,e),{inset:t,insetTop:n,insetBottom:e,...r}}function iu(t,n,e){return void 0===t&&void 0===n&&void 0===e?rc?[1,0]:[.5,.5]:[n,e]}function au(t,{interval:n}){return(t={...wi(t)}).interval=mi(void 0===t.interval?n:t.interval),t}function lu(t,n,e,r){const{[t]:o,[`${t}1`]:i,[`${t}2`]:a}=e,{value:l,interval:s}=au(o,e);if(null==l||null==s&&!r)return e;const c=hi(o);if(null==s){let n;const o={transform:t=>n||(n=vo(t,l)),label:c};return{...e,[t]:void 0,[`${t}1`]:void 0===i?o:i,[`${t}2`]:void 0!==a||i===a&&r?a:o}}let u,f;function h(t){return void 0!==f&&t===u?f:f=Ho(vo(u=t,l),(t=>s.floor(t)))}return n({...e,[t]:void 0,[`${t}1`]:void 0===i?{transform:h,label:c}:i,[`${t}2`]:void 0===a?{transform:t=>h(t).map((t=>s.offset(t))),label:c}:a})}function su(t,n,e){const{[t]:r}=e,{value:o,interval:i}=au(r,e);return null==o||null==i?e:n({...e,[t]:{label:hi(r),transform:t=>{const n=Ho(vo(t,o),(t=>i.floor(t))),e=n.map((t=>i.offset(t)));return n.map(Mi(n)?(t,n)=>null==t||isNaN(t=+t)||null==(n=e[n])||isNaN(n=+n)?void 0:new Date((t+n)/2):(t,n)=>null==t||null==(n=e[n])?NaN:(+t+ +n)/2)}}})}function cu(t={}){return lu("x",ru,t,!0)}function uu(t={}){return lu("y",ou,t,!0)}function fu(t={}){return lu("x",ru,t)}function hu(t={}){return lu("y",ou,t)}function du(t={}){return su("x",ru,t)}function pu(t={}){return su("y",ou,t)}const yu={ariaLabel:"rule",fill:null,stroke:"currentColor"};class mu extends zc{constructor(t,n={}){const{x:e,y1:r,y2:o,inset:i=0,insetTop:a=i,insetBottom:l=i}=n;super(t,{x:{value:e,scale:"x",optional:!0},y1:{value:r,scale:"y",optional:!0},y2:{value:o,scale:"y",optional:!0}},Cc(n,"x"),yu),this.insetTop=Oo(a),this.insetBottom=Oo(l),Vc(this,n)}render(t,n,e,r,o){const{x:i,y:a}=n,{x:l,y1:s,y2:c}=e,{width:u,height:f,marginTop:h,marginRight:d,marginLeft:p,marginBottom:y}=r,{insetTop:m,insetBottom:g}=this;return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,{x:l&&i},rc,0).call((n=>n.selectAll().data(t).enter().append("line").call(vc,this).attr("x1",l?t=>l[t]:(p+u-d)/2).attr("x2",l?t=>l[t]:(p+u-d)/2).attr("y1",s&&!hs(a)?t=>s[t]+m:h+m).attr("y2",c&&!hs(a)?a.bandwidth?t=>c[t]+a.bandwidth()-g:t=>c[t]-g:f-y-g).call(uc,this,e).call(Kc,this,e,o))).node()}}class gu extends zc{constructor(t,n={}){const{x1:e,x2:r,y:o,inset:i=0,insetRight:a=i,insetLeft:l=i}=n;super(t,{y:{value:o,scale:"y",optional:!0},x1:{value:e,scale:"x",optional:!0},x2:{value:r,scale:"x",optional:!0}},Cc(n,"y"),yu),this.insetRight=Oo(a),this.insetLeft=Oo(l),Vc(this,n)}render(t,n,e,r,o){const{x:i,y:a}=n,{y:l,x1:s,x2:c}=e,{width:u,height:f,marginTop:h,marginRight:d,marginLeft:p,marginBottom:y}=r,{insetLeft:m,insetRight:g}=this;return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,{y:l&&a},0,rc).call((n=>n.selectAll().data(t).enter().append("line").call(vc,this).attr("x1",s&&!hs(i)?t=>s[t]+m:p+m).attr("x2",c&&!hs(i)?i.bandwidth?t=>c[t]+i.bandwidth()-g:t=>c[t]-g:u-d-g).attr("y1",l?t=>l[t]:(h+f-y)/2).attr("y2",l?t=>l[t]:(h+f-y)/2).call(uc,this,e).call(Kc,this,e,o))).node()}}function vu(t,n){let{x:e=Ao,y:r,y1:o,y2:i,...a}=hu(n);return[o,i]=wu(r,o,i),new mu(t,{...a,x:e,y1:o,y2:i})}function xu(t,n){let{y:e=Ao,x:r,x1:o,x2:i,...a}=fu(n);return[o,i]=wu(r,o,i),new gu(t,{...a,y:e,x1:o,x2:i})}function wu(t,n,e){if(null==t){if(void 0===n){if(void 0!==e)return[0,e]}else if(void 0===e)return[0,n]}else{if(void 0===n)return void 0===e?[0,t]:[t,e];if(void 0===e)return[t,n]}return[n,e]}function bu(t,...n){let e=n.length;for(let r=0,o=!0;r{let o=t[0];for(let i=0;ivo(t,k,Float64Array),label:hi(k)}),optional:!0},text:{value:o,filter:Wr,optional:!0}},n,ku),this.rotate=x,this.textAnchor=kc(a,"middle"),this.lineAnchor=_o(l,"lineAnchor",["top","middle","bottom"]),this.lineHeight=+s,this.lineWidth=+c,this.textOverflow=Au(u),this.monospace=!!f,this.fontFamily=zo(h),this.fontSize=b,this.fontStyle=zo(p),this.fontVariant=zo(y),this.fontWeight=zo(m),this.frameAnchor=Ii(i),!(this.lineWidth>=0))throw new Error(`invalid lineWidth: ${c}`);this.splitLines=Wu(this),this.clipLine=ju(this)}render(t,n,e,r,o){const{x:i,y:a}=n,{x:l,y:s,rotate:c,text:u,title:f,fontSize:h}=e,{rotate:d}=this,[p,y]=Ec(this,r);return Vs("svg:g",o).call(gc,this,r,o).call(Su,this,u,r).call(bc,this,{x:l&&i,y:s&&a}).call((n=>n.selectAll().data(t).enter().append("text").call(vc,this).call(Lu,this,u,f).attr("transform",bu`translate(${l?t=>l[t]:p},${s?t=>s[t]:y})${c?t=>` rotate(${c[t]})`:d?` rotate(${d})`:""}`).call(wc,"font-size",h&&(t=>h[t])).call(uc,this,e))).node()}}function Au(t){return null==t?null:_o(t,"textOverflow",["clip","ellipsis","clip-start","clip-end","ellipsis-start","ellipsis-middle","ellipsis-end"]).replace(/^(clip|ellipsis)$/,"$1-end")}function Lu(t,n,e,r){if(!e)return;const{lineAnchor:o,lineHeight:i,textOverflow:a,splitLines:l,clipLine:s}=n;t.each((function(t){const n=l(ec(e[t])??"").map(s),c=n.length,u="top"===o?.71:"bottom"===o?1-c:(164-100*c)/200;if(c>1){let t=0;for(let e=0;eo&&e(t,o,l)>n&&(r.push(t.slice(o,i)+(t[i-1]===$u?"-":"")),o=a),s?(r.push(t.slice(o,l)),o=void 0):i=l;return r}const Tu={a:56,b:63,c:57,d:63,e:58,f:37,g:62,h:60,i:26,j:26,k:55,l:26,m:88,n:60,o:60,p:62,q:62,r:39,s:54,t:38,u:60,v:55,w:79,x:54,y:55,z:55,A:69,B:67,C:73,D:74,E:61,F:58,G:76,H:75,I:28,J:55,K:67,L:58,M:89,N:75,O:78,P:65,Q:78,R:67,S:65,T:65,U:75,V:69,W:98,X:69,Y:67,Z:67,0:64,1:48,2:62,3:64,4:66,5:63,6:65,7:58,8:65,9:65," ":29,"!":32,'"':49,"'":31,"(":39,")":39,",":31,"-":48,".":31,"/":32,":":31,";":31,"?":52,"‘":31,"’":31,"“":47,"”":47,"…":82};function Ru(t,n=0,e=t.length){let r=0;for(let o=n;ot.split(/\r\n?|\n/g);const r=t?Iu:Ru,o=100*n;return t=>Cu(t,o,r)}function ju({monospace:t,lineWidth:n,textOverflow:e}){if(null==e||n==1/0)return t=>t;const r=t?Iu:Ru,o=100*n;switch(e){case"clip-start":return t=>qu(t,o,r,"");case"clip-end":return t=>Du(t,o,r,"");case"ellipsis-start":return t=>qu(t,o,r,Bu);case"ellipsis-middle":return t=>function(t,n,e,r){t=t.trim();const o=e(t);if(o<=n)return t;const i=e(r)/2,[a,l]=Fu(t,n/2,e,i),[s]=Fu(t,o-n/2-l+i,e,-i);return s<0?r:t.slice(0,a).trimEnd()+r+t.slice(Vu(t,s)).trimStart()}(t,o,r,Bu);case"ellipsis-end":return t=>Du(t,o,r,Bu)}}const Bu="…";function Fu(t,n,e,r){const o=[];let i=0;for(let a=0,l=0,s=t.length;an){for(i+=r;i>n&&a>0;)l=a,a=o.pop(),i-=e(t,a,l);return[a,n-i]}i+=s,o.push(a)}return[-1,0]}function Du(t,n,e,r){t=t.trim();const o=e(r),[i]=Fu(t,n,e,o);return i<0?t:t.slice(0,i).trimEnd()+r}function qu(t,n,e,r){const o=e(t=t.trim());if(o<=n)return t;const i=e(r),[a]=Fu(t,o-n+i,e,-i);return a<0?r:r+t.slice(Vu(t,a)).trimStart()}const _u=/[\p{Combining_Mark}\p{Emoji_Modifier}]+/uy,Pu=/\p{Extended_Pictographic}/uy;function Vu(t,n){return n+=function(t,n){const e=t.charCodeAt(n);if(e>=55296&&e<56320){const e=t.charCodeAt(n+1);return e>=56320&&e<57344}return!1}(t,n)?2:1,function(t,n){return!Hu(t,n)&&(_u.lastIndex=n,_u.test(t))}(t,n)&&(n=_u.lastIndex),function(t,n){return 8205===t.charCodeAt(n)}(t,n)?Vu(t,n+1):n}function Hu(t,n){return t.charCodeAt(n)<128}function Uu(t,n){return!Hu(t,n)&&(Pu.lastIndex=n,Pu.test(t))}const Yu={ariaLabel:"vector",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"},Xu=3.5,Gu=5*Xu,Zu={draw(t,n,e){const r=n*e/Gu;t.moveTo(0,0),t.lineTo(0,-n),t.moveTo(-r,r-n),t.lineTo(0,-n),t.lineTo(r,r-n)}},Ju={draw(t,n,e){t.moveTo(-e,0),t.lineTo(0,-n),t.lineTo(e,0)}},Ku=new Map([["arrow",Zu],["spike",Ju]]);class Qu extends zc{constructor(t,n={}){const{x:e,y:r,r:o=Xu,length:i,rotate:a,shape:l=Zu,anchor:s="middle",frameAnchor:c}=n,[u,f]=Do(i,12),[h,d]=Do(a,0);super(t,{x:{value:e,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},length:{value:u,scale:"length",optional:!0},rotate:{value:h,optional:!0}},n,Yu),this.r=+o,this.length=f,this.rotate=d,this.shape=function(t){if(function(t){return t&&"function"==typeof t.draw}(t))return t;const n=Ku.get(`${t}`.toLowerCase());if(n)return n;throw new Error(`invalid shape: ${t}`)}(l),this.anchor=_o(s,"anchor",["start","middle","end"]),this.frameAnchor=Ii(c)}render(t,n,e,r,o){const{x:i,y:a}=n,{x:l,y:s,length:c,rotate:u}=e,{length:f,rotate:h,anchor:d,shape:p,r:y}=this,[m,g]=Ec(this,r);return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,{x:l&&i,y:s&&a}).call((n=>n.selectAll().data(t).enter().append("path").call(vc,this).attr("transform",bu`translate(${l?t=>l[t]:m},${s?t=>s[t]:g})${u?t=>` rotate(${u[t]})`:h?` rotate(${h})`:""}${"start"===d?"":"end"===d?c?t=>` translate(0,${c[t]})`:` translate(0,${f})`:c?t=>` translate(0,${c[t]/2})`:` translate(0,${f/2})`}`).attr("d",c?t=>{const n=je();return p.draw(n,c[t],y),n}:(()=>{const t=je();return p.draw(t,f,y),t})()).call(uc,this,e))).node()}}function tf(t,n={}){let{x:e,y:r,...o}=n;return void 0===n.frameAnchor&&([e,r]=ni(e,r)),new Qu(t,{...o,x:e,y:r})}function nf(t,n={}){const{x:e=Ao,...r}=n;return new Qu(t,{...r,x:e})}function ef(t,n={}){const{y:e=Ao,...r}=n;return new Qu(t,{...r,y:e})}function rf(t,n={}){const{shape:e=Ju,stroke:r=Yu.stroke,strokeWidth:o=1,fill:i=r,fillOpacity:a=.3,anchor:l="start",...s}=n;return tf(t,{...s,shape:e,stroke:r,strokeWidth:o,fill:i,fillOpacity:a,anchor:l})}function of(t,n){return arguments.length<2&&!bi(t)&&(n=t,t=null),void 0===n&&(n={}),[t,n]}function af({anchor:t}={},n){return void 0===t?n[0]:_o(t,"anchor",n)}function lf(t){return af(t,["left","right"])}function sf(t){return af(t,["right","left"])}function cf(t){return af(t,["bottom","top"])}function uf(t){return af(t,["top","bottom"])}function ff(){const[t,n]=of(...arguments);return yf("y",lf(n),t,n)}function hf(){const[t,n]=of(...arguments);return yf("fy",sf(n),t,n)}function df(){const[t,n]=of(...arguments);return mf("x",cf(n),t,n)}function pf(){const[t,n]=of(...arguments);return mf("fx",uf(n),t,n)}function yf(t,n,e,{color:r="currentColor",opacity:o=1,stroke:i=r,strokeOpacity:a=o,strokeWidth:l=1,fill:s=r,fillOpacity:c=o,textAnchor:u,textStroke:f,textStrokeOpacity:h,textStrokeWidth:d,tickSize:p=("y"===t?6:0),tickPadding:y,tickRotate:m,x:g,margin:v,marginTop:x=(void 0===v?20:v),marginRight:w=(void 0===v?"right"===n?40:0:v),marginBottom:b=(void 0===v?20:v),marginLeft:k=(void 0===v?"left"===n?40:0:v),label:$,labelAnchor:M,labelArrow:A,labelOffset:L,...E}){return p=Oo(p),y=Oo(y),m=Oo(m),void 0!==M&&(M=_o(M,"labelAnchor",["center","top","bottom"])),A=If(A),Oc(p&&!Ci(i)?function(t,n,e,{strokeWidth:r=1,strokeLinecap:o=null,strokeLinejoin:i=null,facetAnchor:a=n+("y"===t?"-empty":""),frameAnchor:l=n,tickSize:s,inset:c=0,insetLeft:u=c,insetRight:f=c,dx:h=0,y:d=("y"===t?void 0:null),...p}){return Af(ef,t,e,{ariaLabel:`${t}-axis tick`,ariaHidden:!0},{strokeWidth:r,strokeLinecap:o,strokeLinejoin:i,facetAnchor:a,frameAnchor:l,y:d,...p,dx:"left"===n?+h-rc+ +u:+h+rc-f,anchor:"start",length:s,shape:"left"===n?Nf:Cf})}(t,n,e,{stroke:i,strokeOpacity:a,strokeWidth:l,tickSize:p,tickPadding:y,tickRotate:m,x:g,...E}):null,Ci(s)?null:function(t,n,e,{facetAnchor:r=n+("y"===t?"-empty":""),frameAnchor:o=n,tickSize:i,tickRotate:a=0,tickPadding:l=Math.max(3,9-i)+(Math.abs(a)>60?4*Math.cos(a*Pc):0),text:s,textAnchor:c=(Math.abs(a)>60?"middle":"left"===n?"end":"start"),lineAnchor:u=(a>60?"top":a<-60?"bottom":"middle"),fontVariant:f,inset:h=0,insetLeft:d=h,insetRight:p=h,dx:y=0,y:m=("y"===t?void 0:null),...g}){return Af(Ou,t,e,{ariaLabel:`${t}-axis tick label`},{facetAnchor:r,frameAnchor:o,text:s,textAnchor:c,lineAnchor:u,fontVariant:f,rotate:a,y:m,...g,dx:"left"===n?+y-i-l+ +d:+y+ +i+ +l-p},(function(t,e,r,o,i){void 0===f&&(this.fontVariant=Tf(t)),void 0===s&&(i.text=Lf(t,e,r,o,n))}))}(t,n,e,{fill:s,fillOpacity:c,stroke:f,strokeOpacity:h,strokeWidth:d,textAnchor:u,tickSize:p,tickPadding:y,tickRotate:m,x:g,marginTop:x,marginRight:w,marginBottom:b,marginLeft:k,...E}),Ci(s)||null===$?null:Eu([],Mf({fill:s,fillOpacity:c,...E},(function(e,r,o,i,a){const l=i[t],{marginTop:s,marginRight:c,marginBottom:u,marginLeft:f}="y"===t&&a.inset||a,h=M??(l.bandwidth?"center":"top"),d=L??("right"===n?c:f)-3;return"center"===h?(this.textAnchor=void 0,this.lineAnchor="right"===n?"bottom":"top",this.frameAnchor=n,this.rotate=-90):(this.textAnchor="right"===n?"end":"start",this.lineAnchor=h,this.frameAnchor=`${h}-${n}`,this.rotate=0),this.dy="top"===h?3-s:"bottom"===h?u-3:0,this.dx="right"===n?d:-d,this.ariaLabel=`${t}-axis label`,{facets:[[0]],channels:{text:{value:[Rf(t,l,{anchor:n,label:$,labelAnchor:h,labelArrow:A})]}}}}))))}function mf(t,n,e,{color:r="currentColor",opacity:o=1,stroke:i=r,strokeOpacity:a=o,strokeWidth:l=1,fill:s=r,fillOpacity:c=o,textAnchor:u,textStroke:f,textStrokeOpacity:h,textStrokeWidth:d,tickSize:p=("x"===t?6:0),tickPadding:y,tickRotate:m,y:g,margin:v,marginTop:x=(void 0===v?"top"===n?30:0:v),marginRight:w=(void 0===v?20:v),marginBottom:b=(void 0===v?"bottom"===n?30:0:v),marginLeft:k=(void 0===v?20:v),label:$,labelAnchor:M,labelArrow:A,labelOffset:L,...E}){return p=Oo(p),y=Oo(y),m=Oo(m),void 0!==M&&(M=_o(M,"labelAnchor",["center","left","right"])),A=If(A),Oc(p&&!Ci(i)?function(t,n,e,{strokeWidth:r=1,strokeLinecap:o=null,strokeLinejoin:i=null,facetAnchor:a=n+("x"===t?"-empty":""),frameAnchor:l=n,tickSize:s,inset:c=0,insetTop:u=c,insetBottom:f=c,dy:h=0,x:d=("x"===t?void 0:null),...p}){return Af(nf,t,e,{ariaLabel:`${t}-axis tick`,ariaHidden:!0},{strokeWidth:r,strokeLinejoin:i,strokeLinecap:o,facetAnchor:a,frameAnchor:l,x:d,...p,dy:"bottom"===n?+h-rc-f:+h+rc+ +u,anchor:"start",length:s,shape:"bottom"===n?Of:Sf})}(t,n,e,{stroke:i,strokeOpacity:a,strokeWidth:l,tickSize:p,tickPadding:y,tickRotate:m,y:g,...E}):null,Ci(s)?null:function(t,n,e,{facetAnchor:r=n+("x"===t?"-empty":""),frameAnchor:o=n,tickSize:i,tickRotate:a=0,tickPadding:l=Math.max(3,9-i)+(Math.abs(a)>=10?4*Math.cos(a*Pc):0),text:s,textAnchor:c=(Math.abs(a)>=10?a<0^"bottom"===n?"start":"end":"middle"),lineAnchor:u=(Math.abs(a)>=10?"middle":"bottom"===n?"top":"bottom"),fontVariant:f,inset:h=0,insetTop:d=h,insetBottom:p=h,dy:y=0,x:m=("x"===t?void 0:null),...g}){return Af(zu,t,e,{ariaLabel:`${t}-axis tick label`},{facetAnchor:r,frameAnchor:o,text:void 0===s?null:s,textAnchor:c,lineAnchor:u,fontVariant:f,rotate:a,x:m,...g,dy:"bottom"===n?+y+ +i+ +l-p:+y-i-l+ +d},(function(t,e,r,o,i){void 0===f&&(this.fontVariant=Tf(t)),void 0===s&&(i.text=Lf(t,e,r,o,n))}))}(t,n,e,{fill:s,fillOpacity:c,stroke:f,strokeOpacity:h,strokeWidth:d,textAnchor:u,tickSize:p,tickPadding:y,tickRotate:m,y:g,marginTop:x,marginRight:w,marginBottom:b,marginLeft:k,...E}),Ci(s)||null===$?null:Eu([],Mf({fill:s,fillOpacity:c,...E},(function(e,r,o,i,a){const l=i[t],{marginTop:s,marginRight:c,marginBottom:u,marginLeft:f}="x"===t&&a.inset||a,h=M??(l.bandwidth?"center":"right"),d=L??("top"===n?s:u)-3;return"center"===h?(this.frameAnchor=n,this.textAnchor=void 0):(this.frameAnchor=`${n}-${h}`,this.textAnchor="right"===h?"end":"start"),this.lineAnchor=n,this.dy="top"===n?-d:d,this.dx="right"===h?c-3:"left"===h?3-f:0,this.ariaLabel=`${t}-axis label`,{facets:[[0]],channels:{text:{value:[Rf(t,l,{anchor:n,label:$,labelAnchor:h,labelArrow:A})]}}}}))))}function gf(){const[t,n]=of(...arguments);return bf("y",lf(n),t,n)}function vf(){const[t,n]=of(...arguments);return bf("fy",sf(n),t,n)}function xf(){const[t,n]=of(...arguments);return kf("x",cf(n),t,n)}function wf(){const[t,n]=of(...arguments);return kf("fx",uf(n),t,n)}function bf(t,n,e,{y:r=("y"===t?void 0:null),x:o=null,x1:i=("left"===n?o:null),x2:a=("right"===n?o:null),...l}){return Af(xu,t,e,{ariaLabel:`${t}-grid`,ariaHidden:!0},{y:r,x1:i,x2:a,...$f(l)})}function kf(t,n,e,{x:r=("x"===t?void 0:null),y:o=null,y1:i=("top"===n?o:null),y2:a=("bottom"===n?o:null),...l}){return Af(vu,t,e,{ariaLabel:`${t}-grid`,ariaHidden:!0},{x:r,y1:i,y2:a,...$f(l)})}function $f({color:t="currentColor",opacity:n=.1,stroke:e=t,strokeOpacity:r=n,strokeWidth:o=1,...i}){return{stroke:e,strokeOpacity:r,strokeWidth:o,...i}}function Mf({fill:t,fillOpacity:n,fontFamily:e,fontSize:r,fontStyle:o,fontVariant:i,fontWeight:a,monospace:l,pointerEvents:s,shapeRendering:c,clip:u=!1},f){return[,t]=Fo(t),[,n]=Do(n),{facet:"super",x:null,y:null,fill:t,fillOpacity:n,fontFamily:e,fontSize:r,fontStyle:o,fontVariant:i,fontWeight:a,monospace:l,pointerEvents:s,shapeRendering:c,clip:u,initializer:f}}function Af(t,n,e,r,o,i){let a;const l=na(o).initializer,s=t(e,na({...o,initializer:function(t,e,r,l,s,c){const u=null==t&&("fx"===n||"fy"===n),{[n]:f}=l;if(!f)throw new Error(`missing scale: ${n}`);const h=f.domain();let{interval:d,ticks:p,tickFormat:y,tickSpacing:m=("x"===n?80:35)}=o;if("string"==typeof p&&Wf(f)&&(d=p,p=void 0),void 0===p&&(p=vi(d,f.type)??function(t,n){const[e,r]=qn(t.range());return(r-e)/n}(f,m)),null==t){if(bi(p))t=Vo(p);else if(xi(p))t=zf(p,...qn(h));else if(f.interval){let n=f.interval;if(f.ticks){const[e,r]=qn(h);n=lo(n,(r-e)/n[Kr]/p)??n,t=zf(n,e,r)}else{n=lo(n,(t=h).length/p)??n,n!==f.interval&&(t=zf(n,...qn(t)))}if(n===f.interval){const n=Math.round(t.length/p);n>1&&(t=t.filter(((t,e)=>e%n==0)))}}else t=f.ticks?f.ticks(p):h;if(!f.ticks&&t.length&&t!==h){const e=new nt(h);(t=t.filter((t=>e.has(t)))).length||Rl(`Warning: the ${n}-axis ticks appear to not align with the scale domain, resulting in no ticks. Try different ticks?`)}"y"===n||"x"===n?e=[oi(t)]:a[n]={scale:n,value:Ao}}i?.call(this,f,t,p,y,a);const g=Object.fromEntries(Object.entries(a).map((([n,e])=>[n,{...e,value:vo(t,e.value)}])));return u&&(e=c.filterFacets(t,g)),{data:t,facets:e,channels:g}}},l));return null==e?(a=s.channels,s.channels={}):a={},void 0!==r&&Object.assign(s,r),void 0===s.clip&&(s.clip=!1),s}function Lf(t,n,e,r,o){return{value:Ef(t,n,e,r,o)}}function Ef(t,n,e,r,o){return"function"!=typeof r||"log"===t.type&&t.tickFormat?void 0===r&&n&&Mi(n)?co(t.type,n,o)??ec:t.tickFormat?t.tickFormat("number"==typeof e?e:null,r):void 0===r?ec:"string"==typeof r?(Mi(t.domain())?R:Ie)(r):To(r):r}function zf(t,n,e){return t.range(n,t.offset(t.floor(e)))}const Of={draw(t,n){t.moveTo(0,0),t.lineTo(0,n)}},Sf={draw(t,n){t.moveTo(0,0),t.lineTo(0,-n)}},Nf={draw(t,n){t.moveTo(0,0),t.lineTo(-n,0)}},Cf={draw(t,n){t.moveTo(0,0),t.lineTo(n,0)}};function Tf(t){return t.bandwidth&&!t.interval?void 0:"tabular-nums"}function Rf(t,n,{anchor:e,label:r=n.label,labelAnchor:o,labelArrow:i}={}){if(!(null==r||r.inferred&&Wf(n)&&/^(date|time|year)$/i.test(r))){if(r=String(r),"auto"===i&&(i=(!n.bandwidth||n.interval)&&!/[↑↓→←]/.test(r)),!i)return r;if(!0===i){const e=Jl(n);e&&(i=/x$/.test(t)||"center"===o?/x$/.test(t)===e<0?"left":"right":e<0?"up":"down")}switch(i){case"left":return`← ${r}`;case"right":return`${r} →`;case"up":return"right"===e?`${r} ↑`:`↑ ${r}`;case"down":return"right"===e?`${r} ↓`:`↓ ${r}`}return r}}function If(t="auto"){return!Ci(t)&&("boolean"==typeof t?t:_o(t,"labelArrow",["auto","up","right","down","left"]))}function Wf(t){return Mi(t.domain())}function jf(t,n){if(null==n)return n;const e=t(n);if(!e)throw new Error(`scale not found: ${n}`);return e}function Bf(t,n={},e){let{columns:r,tickFormat:o,fontVariant:i=_c(t),swatchSize:a=15,swatchWidth:l=a,swatchHeight:s=a,marginLeft:c=0,className:u,style:f,width:h}=n;const d=Ps(n);u=Ac(u),o=Ef(t.scale,t.domain,void 0,o);const p=Vs("div",d).attr("class",`${u}-swatches ${u}-swatches-${null!=r?"columns":"wrap"}`);let y;return null!=r?(y=`:where(.${u}-swatches-columns .${u}-swatch) {\n display: flex;\n align-items: center;\n break-inside: avoid;\n padding-bottom: 1px;\n}\n:where(.${u}-swatches-columns .${u}-swatch::before) {\n flex-shrink: 0;\n}\n:where(.${u}-swatches-columns .${u}-swatch-label) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}`,p.style("columns",r).selectAll().data(t.domain).enter().append("div").attr("class",`${u}-swatch`).call(e,t,l,s).call((t=>t.append("div").attr("class",`${u}-swatch-label`).attr("title",o).text(o)))):(y=`:where(.${u}-swatches-wrap) {\n display: flex;\n align-items: center;\n min-height: 33px;\n flex-wrap: wrap;\n}\n:where(.${u}-swatches-wrap .${u}-swatch) {\n display: inline-flex;\n align-items: center;\n margin-right: 1em;\n}`,p.selectAll().data(t.domain).enter().append("span").attr("class",`${u}-swatch`).call(e,t,l,s).append((function(){return this.ownerDocument.createTextNode(o.apply(this,arguments))}))),p.call((t=>t.insert("style","*").text(`:where(.${u}-swatches) {\n font-family: system-ui, sans-serif;\n font-size: 10px;\n margin-bottom: 0.5em;\n}\n:where(.${u}-swatch > svg) {\n margin-right: 0.5em;\n overflow: visible;\n}\n${y}`))).style("margin-left",c?+c+"px":null).style("width",void 0===h?null:+h+"px").style("font-variant",kc(i,"normal")).call(Lc,f).node()}const Ff=new Map([["symbol",function(t,{fill:n=(void 0!==t.hint?.fill?t.hint.fill:"none"),fillOpacity:e=1,stroke:r=(void 0!==t.hint?.stroke?t.hint.stroke:Ci(n)?"currentColor":"none"),strokeOpacity:o=1,strokeWidth:i=1.5,r:a=4.5,...l}={},s){const[c,u]=Fo(n),[f,h]=Fo(r),d=jf(s,c),p=jf(s,f),y=a*a*Math.PI;return e=Do(e)[1],o=Do(o)[1],i=Do(i)[1],Bf(t,l,((n,r,a,l)=>n.append("svg").attr("viewBox","-8 -8 16 16").attr("width",a).attr("height",l).attr("fill","color"===c?t=>d.scale(t):u).attr("fill-opacity",e).attr("stroke","color"===f?t=>p.scale(t):h).attr("stroke-opacity",o).attr("stroke-width",i).append("path").attr("d",(n=>{const e=je();return t.scale(n).draw(e,y),e}))))}],["color",_f],["opacity",function({type:t,interpolate:n,...e},{legend:r=!0,color:o=Be(0,0,0),...i}){if(!n)throw new Error(`${t} opacity scales are not supported`);!0===r&&(r="ramp");if("ramp"!==`${r}`.toLowerCase())throw new Error(`${r} opacity legends are not supported`);return _f({type:t,...e,interpolate:Pf(o)},{legend:r,...i})}]]);function Df(t={}){for(const[n,e]of Ff){const r=t[n];if(Jo(r)){const o=Ps(t);let i;if("symbol"===n){const{fill:n,stroke:e=(void 0===n&&Jo(t.color)?"color":void 0)}=t;i={fill:n,stroke:e}}return e(os(n,r,i),qf(o,r,t),(n=>Jo(t[n])?os(n,t[n]):null))}}throw new Error("unknown legend type; no scale found")}function qf({className:t,...n},{label:e,ticks:r,tickFormat:o}={},i){return function(t={},...n){let e=t;for(const r of n)for(const n in r)if(void 0===e[n]){const o=r[n];e===t?e={...e,[n]:o}:e[n]=o}return e}(i,{className:t,...n},{label:e,ticks:r,tickFormat:o})}function _f(t,{legend:n=!0,...e}){if(!0===n&&(n="ordinal"===t.type?"swatches":"ramp"),void 0!==t.domain)switch(`${n}`.toLowerCase()){case"swatches":return function(t,{opacity:n,...e}={}){if(!us(t)&&!fs(t))throw new Error(`swatches legend requires ordinal or threshold color scale (not ${t.type})`);return Bf(t,e,((t,e,r,o)=>t.append("svg").attr("width",r).attr("height",o).attr("fill",e.scale).attr("fill-opacity",Do(n)[1]).append("rect").attr("width","100%").attr("height","100%")))}(t,e);case"ramp":return function(t,n){let{label:e=t.label,tickSize:r=6,width:o=240,height:i=44+r,marginTop:a=18,marginRight:l=0,marginBottom:s=16+r,marginLeft:c=0,style:u,ticks:f=(o-c-l)/64,tickFormat:h,fontVariant:d=_c(t),round:p=!0,opacity:y,className:m}=n;const g=Ps(n);m=Ac(m),y=Do(y)[1],null===h&&(h=()=>null);const v=Vs("svg",g).attr("class",`${m}-ramp`).attr("font-family","system-ui, sans-serif").attr("font-size",10).attr("width",o).attr("height",i).attr("viewBox",`0 0 ${o} ${i}`).call((t=>t.append("style").text(`:where(.${m}-ramp) {\n display: block;\n height: auto;\n height: intrinsic;\n max-width: 100%;\n overflow: visible;\n}\n:where(.${m}-ramp text) {\n white-space: pre;\n}`))).call(Lc,u);let x,w=t=>t.selectAll(".tick line").attr("y1",a+s-i);const b=p?(t,n)=>t.rangeRound(n):(t,n)=>t.range(n),{type:k,domain:$,range:M,interpolate:A,scale:L,pivot:E}=t;if(A){const t=void 0===M?A:Yn(1===A.length?Nl(A):A,M);x=b(L.copy(),ht(Pn(c,o-l),Math.min($.length+(void 0!==E),void 0===M?1/0:M.length)));const n=256,e=g.document.createElement("canvas");e.width=n,e.height=1;const r=e.getContext("2d");for(let e=0,o=n-1;et:"string"==typeof h?Ie(h):h;x=b(Wn().domain([-1,M.length-1]),[c,o-l]),v.append("g").attr("fill-opacity",y).selectAll().data(M).enter().append("rect").attr("x",((t,n)=>x(n-1))).attr("y",a).attr("width",((t,n)=>x(n)-x(n-1))).attr("height",i-a-s).attr("fill",(t=>t)),f=Ho(t,((t,n)=>n)),h=e=>n(t[e],e)}else x=b(se().domain($),[c,o-l]),v.append("g").attr("fill-opacity",y).selectAll().data($).enter().append("rect").attr("x",x).attr("y",a).attr("width",Math.max(0,x.bandwidth()-1)).attr("height",i-a-s).attr("fill",L),w=()=>{};return v.append("g").attr("transform",`translate(0,${i-s})`).call(We(x).ticks(Array.isArray(f)?null:f,"string"==typeof h?h:void 0).tickFormat("function"==typeof h?h:void 0).tickSize(r).tickValues(Array.isArray(f)?f:null)).attr("font-size",null).attr("font-family",null).attr("font-variant",kc(d,"normal")).call(w).call((t=>t.select(".domain").remove())),void 0!==e&&v.append("text").attr("x",c).attr("y",a-6).attr("fill","currentColor").attr("font-weight","bold").text(e),v.node()}(t,e);default:throw new Error(`unknown legend type: ${n}`)}}function Pf(t){const{r:n,g:e,b:r}=Be(t)||Be(0,0,0);return t=>`rgba(${n},${e},${r},${t})`}function Vf(t={}){return Yo(t)?t:{...t,x:Ao}}function Hf(t={}){return Xo(t)?t:{...t,y:Ao}}function Uf(t,n){if(1===n.length)return{data:t,facets:n};const e=ri(t),r=new Uint8Array(e);let o=0;for(const t of n)for(const n of t)r[n]&&++o,r[n]=1;if(0===o)return{data:t,facets:n};const i=(t=Uo(t))[go]=new Uint32Array(e+o);n=n.map((t=>Uo(t,Uint32Array)));let a=e;r.fill(0);for(const e of n)for(let n=0,o=e.length;n(n,e)=>t(r[n],r[e])}(r);case"z":return function(t){return(n,e,r,o)=>(n,e)=>t(o[n],o[e])}(r);case"sum":return function(t){return dh(t,((t,n,e,r)=>De(oi(t),(t=>tt(t,(t=>e[t]))),(t=>r[t]))))}(r);case"appearance":return function(t){return dh(t,((t,n,e,r)=>De(oi(t),(t=>n[qe(t,(t=>e[t]))]),(t=>r[t]))))}(r);case"inside-out":return uh(r)}return fh($o(t))}if("function"==typeof t)return(1===t.length?fh:hh)(t);if(po(t))return r=t,dh(Rr,(()=>r));var r;throw new Error(`invalid order: ${t}`)}(i,o,r),[ta(l,((r,l,c)=>{({data:r,facets:l}=Uf(r,l));const f=null==t?void 0:u(pi(vo(r,t),c?.[e])),d=vo(r,n,Float64Array),y=vo(r,s),m=i&&i(r,f,d,y),g=ri(r),v=h(new Float64Array(g)),x=p(new Float64Array(g)),w=[];for(const t of l){const n=f?Array.from(J(t,(t=>f[t])).values()):[t];if(m)for(const t of n)t.sort(m);for(const t of n){let n=0,e=0;a&&t.reverse();for(const r of t){const t=d[r];t<0?n=x[r]=(v[r]=n)+t:t>0?e=x[r]=(v[r]=e)+t:x[r]=v[r]=e}}w.push(n)}return o&&o(w,v,x,y),{data:r,facets:l}})),c,f,d]}function oh(t,n){let e=0,r=0;for(const o of t){const t=n[o];tr&&(r=t)}return[e,r]}function ih(t,n,e){for(const r of t)for(const t of r){const[r,o]=oh(t,e);for(const i of t){const t=1/(o-r||1);n[i]=t*(n[i]-r),e[i]=t*(e[i]-r)}}}function ah(t,n,e){for(const r of t){for(const t of r){const[r,o]=oh(t,e);for(const i of t){const t=(o+r)/2;n[i]-=t,e[i]-=t}}sh(r,n,e)}ch(t,n,e)}function lh(t,n,e,r){for(const o of t){const t=new he;let i=0;for(const a of o){let o=-1;const l=a.map((t=>Math.abs(e[t]-n[t]))),s=a.map((i=>{o=r?r[i]:++o;const a=e[i]-n[i],l=t.has(o)?a-t.get(o):0;return t.set(o,a),l})),c=[0,...Fe(s)];for(const t of a)n[t]+=i,e[t]+=i;const u=tt(l);u&&(i-=tt(l,((t,n)=>(s[n]/2+c[n])*t))/u)}sh(o,n,e)}ch(t,n,e)}function sh(t,n,e){const r=ct(t,(t=>ct(t,(t=>n[t]))));for(const o of t)for(const t of o)n[t]-=r,e[t]-=r}function ch(t,n,e){const r=t.length;if(1===r)return;const o=t.map((t=>t.flat())),i=o.map((t=>(ct(t,(t=>n[t]))+N(t,(t=>e[t])))/2)),a=ct(i);for(let t=0;t{const o=oi(t),i=De(o,(t=>n[qe(t,(t=>e[t]))]),(t=>r[t])),a=Q(o,(t=>tt(t,(t=>e[t]))),(t=>r[t])),l=[],s=[];let c=0;for(const t of i)c<0?(c+=a.get(t),l.push(t)):(c-=a.get(t),s.push(t));return s.reverse().concat(l)}))}function fh(t){return n=>{const e=vo(n,t);return(t,n)=>Rr(e[t],e[n])}}function hh(t){return n=>po(n)?(e,r)=>t(n[e],n[r]):(e,r)=>t(n.get(e),n.get(r))}function dh(t,n){return(e,r,o,i)=>{if(!i)throw new Error("missing channel: z");const a=new he(n(e,r,o,i).map(((t,n)=>[t,n])));return(n,e)=>t(a.get(i[n]),a.get(i[e]))}}const ph={ariaLabel:"rect"};class yh extends zc{constructor(t,n={}){const{x1:e,y1:r,x2:o,y2:i}=n;super(t,{x1:{value:e,scale:"x",type:null!=e&&null==o?"band":void 0,optional:!0},y1:{value:r,scale:"y",type:null!=r&&null==i?"band":void 0,optional:!0},x2:{value:o,scale:"x",optional:!0},y2:{value:i,scale:"y",optional:!0}},n,ph),mh(this,n),gh(this,n)}render(t,n,e,r,o){const{x:i,y:a}=n;let{x1:l,y1:s,x2:c,y2:u}=e;const{marginTop:f,marginRight:h,marginBottom:d,marginLeft:p,width:y,height:m}=r,{projection:g}=o,{insetTop:v,insetRight:x,insetBottom:w,insetLeft:b}=this,{rx:k,ry:$,rx1y1:M,rx1y2:A,rx2y1:L,rx2y2:E}=this;(l||c)&&!g&&hs(i)&&(l=c=null),(s||u)&&!g&&hs(a)&&(s=u=null);const z=i?.bandwidth?i.bandwidth():0,O=a?.bandwidth?a.bandwidth():0;return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,{},0,0).call((n=>n.selectAll().data(t).enter().call(M||A||L||E?t=>t.append("path").call(vc,this).call(vh,l&&c?t=>l[t]+(c[t]l[t]+b:p+b,s&&u?t=>s[t]+(u[t]s[t]+v:f+v,l&&c?t=>c[t]-(c[t]l[t]+z-x:y-h-x,s&&u?t=>u[t]-(u[t]s[t]+O-w:m-d-w,this).call(uc,this,e):t=>t.append("rect").call(vc,this).attr("x",l?c?t=>Math.min(l[t],c[t])+b:t=>l[t]+b:p+b).attr("y",s?u?t=>Math.min(s[t],u[t])+v:t=>s[t]+v:f+v).attr("width",l?c?t=>Math.max(0,Math.abs(c[t]-l[t])+z-b-x):z-b-x:y-h-p-x-b).attr("height",s?u?t=>Math.max(0,Math.abs(s[t]-u[t])+O-v-w):O-v-w:m-f-d-v-w).call(wc,"rx",k).call(wc,"ry",$).call(uc,this,e)))).node()}}function mh(t,{inset:n=0,insetTop:e=n,insetRight:r=n,insetBottom:o=n,insetLeft:i=n}={}){t.insetTop=Oo(e),t.insetRight=Oo(r),t.insetBottom=Oo(o),t.insetLeft=Oo(i)}function gh(t,{r:n,rx:e,ry:r,rx1:o=n,ry1:i=n,rx2:a=n,ry2:l=n,rx1y1:s=(void 0!==o?+o:void 0!==i?+i:0),rx1y2:c=(void 0!==o?+o:void 0!==l?+l:0),rx2y1:u=(void 0!==a?+a:void 0!==i?+i:0),rx2y2:f=(void 0!==a?+a:void 0!==l?+l:0)}={}){s||c||u||f?(t.rx1y1=s,t.rx1y2=c,t.rx2y1=u,t.rx2y2=f):(t.rx=kc(e,"auto"),t.ry=kc(r,"auto"))}function vh(t,n,e,r,o,i){const{rx1y1:a,rx1y2:l,rx2y1:s,rx2y2:c}=i;"function"!=typeof n&&(n=To(n)),"function"!=typeof e&&(e=To(e)),"function"!=typeof r&&(r=To(r)),"function"!=typeof o&&(o=To(o));const u=Math.max(Math.abs(a+s),Math.abs(l+c)),f=Math.max(Math.abs(a+l),Math.abs(s+c));t.attr("d",(t=>{const i=n(t),h=e(t),d=r(t),p=o(t),y=i>d,m=h>p,g=y?d:i,v=y?i:d,x=m?p:h,w=m?h:p,b=Math.min(1,(v-g)/u,(w-x)/f),k=b*(y?m?c:s:m?l:a),$=b*(y?m?l:a:m?c:s),M=b*(y?m?a:l:m?s:c),A=b*(y?m?s:c:m?a:l);return`M${g},${x+wh(k,A)}A${k},${k} 0 0 ${k<0?0:1} ${g+xh(k,A)},${x}H${v-xh($,M)}A${$},${$} 0 0 ${$<0?0:1} ${v},${x+wh($,M)}V${w-wh(M,$)}A${M},${M} 0 0 ${M<0?0:1} ${v-xh(M,$)},${w}H${g+xh(A,k)}A${A},${A} 0 0 ${A<0?0:1} ${g},${w-wh(A,k)}Z`}))}function xh(t,n){return n<0?t:Math.abs(t)}function wh(t,n){return n<0?Math.abs(t):t}function bh(t,n){return new yh(t,cu(uu(n)))}function kh(t,n={}){return Go(n)||(n={...n,y:Mo,x2:Ao,interval:1}),new yh(t,Qf(uu(Vf(n))))}function $h(t,n={}){return Go(n)||(n={...n,x:Mo,y2:Ao,interval:1}),new yh(t,th(cu(Hf(n))))}const Mh={ariaLabel:"frame",fill:"none",stroke:"currentColor",clip:!1},Ah={ariaLabel:"frame",fill:null,stroke:"currentColor",strokeLinecap:"square",clip:!1};class Lh extends zc{constructor(t={}){const{anchor:n=null}=t;super(ko,void 0,t,null==n?Mh:Ah),this.anchor=qo(n,"anchor",["top","right","bottom","left"]),mh(this,t),n||gh(this,t)}render(t,n,e,r,o){const{marginTop:i,marginRight:a,marginBottom:l,marginLeft:s,width:c,height:u}=r,{anchor:f,insetTop:h,insetRight:d,insetBottom:p,insetLeft:y}=this,{rx:m,ry:g,rx1y1:v,rx1y2:x,rx2y1:w,rx2y2:b}=this,k=s+y,$=c-a-d,M=i+h,A=u-l-p;return Vs(f?"svg:line":v||x||w||b?"svg:path":"svg:rect",o).datum(0).call(gc,this,r,o).call(vc,this).call(uc,this,e).call(bc,this,{}).call("left"===f?t=>t.attr("x1",k).attr("x2",k).attr("y1",M).attr("y2",A):"right"===f?t=>t.attr("x1",$).attr("x2",$).attr("y1",M).attr("y2",A):"top"===f?t=>t.attr("x1",k).attr("x2",$).attr("y1",M).attr("y2",M):"bottom"===f?t=>t.attr("x1",k).attr("x2",$).attr("y1",A).attr("y2",A):v||x||w||b?t=>t.call(vh,k,M,$,A,this):t=>t.attr("x",k).attr("y",M).attr("width",$-k).attr("height",A-M).attr("rx",m).attr("ry",g)).node()}}function Eh(t){return new Lh(t)}const zh={ariaLabel:"tip",fill:"var(--plot-background)",stroke:"currentColor"},Oh=new Set(["geometry","href","src","ariaLabel","scales"]);class Sh extends zc{constructor(t,n={}){n.tip&&(n={...n,tip:!1}),void 0===n.title&&bi(t)&&ki(t)&&(n={...n,title:Ao});const{x:e,y:r,x1:o,x2:i,y1:a,y2:l,anchor:s,preferredAnchor:c="bottom",monospace:u,fontFamily:f=(u?"ui-monospace, monospace":void 0),fontSize:h,fontStyle:d,fontVariant:p,fontWeight:y,lineHeight:m=1,lineWidth:g=20,frameAnchor:v,format:x,textAnchor:w="start",textOverflow:b,textPadding:k=8,title:$,pointerSize:M=12,pathFilter:A="drop-shadow(0 3px 4px rgba(0,0,0,0.2))"}=n;super(t,{x:{value:null!=o&&null!=i?null:e,scale:"x",optional:!0},y:{value:null!=a&&null!=l?null:r,scale:"y",optional:!0},x1:{value:o,scale:"x",optional:null==i},y1:{value:a,scale:"y",optional:null==l},x2:{value:i,scale:"x",optional:null==o},y2:{value:l,scale:"y",optional:null==a},title:{value:$,optional:!0}},n,zh),this.anchor=Ri(s,"anchor"),this.preferredAnchor=Ri(c,"preferredAnchor"),this.frameAnchor=Ii(v),this.textAnchor=kc(w,"middle"),this.textPadding=+k,this.pointerSize=+M,this.pathFilter=zo(A),this.lineHeight=+m,this.lineWidth=+g,this.textOverflow=Au(b),this.monospace=!!u,this.fontFamily=zo(f),this.fontSize=Oo(h),this.fontStyle=zo(d),this.fontVariant=zo(p),this.fontWeight=zo(y);for(const t in zh)t in this.channels&&(this[t]=zh[t]);this.splitLines=Wu(this),this.clipLine=ju(this),this.format="string"==typeof x||"function"==typeof x?{title:x}:{...x}}render(t,n,e,r,o){const i=this,{x:a,y:l,fx:s,fy:c}=n,{ownerSVGElement:u,document:f}=o,{anchor:h,monospace:d,lineHeight:p,lineWidth:y}=this,{textPadding:m,pointerSize:g,pathFilter:v}=this,{marginTop:x,marginLeft:w}=r,{x1:b,y1:k,x2:$,y2:M,x:A=b??$,y:L=k??M}=e,E=s?s(t.fx)-w:0,z=c?c(t.fy)-x:0,[O,S]=Ec(this,r),N=Dc(e,O),C=qc(e,S),T=d?Iu:Ru,R=T(Bu);let I,W;"title"in e?(I=Ch.call(this,{title:e.channels.title},n),W=Rh):(I=Ch.call(this,e.channels,n),W=Ih);const j=Vs("svg:g",o).call(gc,this,r,o).call(Su,this).call(bc,this,{x:A&&a,y:L&&l}).call((r=>r.selectAll().data(t).enter().append("g").attr("transform",(t=>`translate(${Math.round(N(t))},${Math.round(C(t))})`)).call(vc,this).call((t=>t.append("path").attr("filter",v))).call((r=>r.append("text").each((function(r){const o=Ne(this);this.setAttribute("fill","currentColor"),this.setAttribute("fill-opacity",1),this.setAttribute("stroke","none");const a=W.call(i,r,t,I,n,e);if("string"==typeof a)for(const t of i.splitLines(a))B(o,{value:i.clipLine(t)});else{const t=new Set;for(const n of a){const{label:e=""}=n;e&&t.has(e)||(t.add(e),B(o,n))}}}))))));function B(t,{label:n,value:e,color:r,opacity:o}){n??="",e??="";const i=null!=r||null!=o;let a,l=100*y;const[s]=Fu(n,l,T,R);if(s>=0)n=n.slice(0,s).trimEnd()+Bu,a=e.trim(),e="";else{(n||!e&&!i)&&(e=" "+e);const[t]=Fu(e,l-T(n),T,R);t>=0&&(a=e.trim(),e=e.slice(0,t).trimEnd()+Bu)}const c=t.append("tspan").attr("x",0).attr("dy",`${p}em`).text("​");n&&c.append("tspan").attr("font-weight","bold").text(n),e&&c.append((()=>f.createTextNode(e))),i&&c.append("tspan").text(" ■").attr("fill",r).attr("fill-opacity",o).style("user-select","none"),a&&c.append("title").text(a)}function F(){const{width:t,height:n}=r.facet??r;j.selectChildren().each((function(e){let{x:r,width:o,height:a}=this.getBBox();o=Math.round(o),a=Math.round(a);let l=h;if(void 0===l){const r=N(e)+E,s=C(e)+z,c=r+o+g+2*m0,f=s+a+g+2*m0;l=c&&u?f&&h?i.preferredAnchor:h?"bottom":"top":f&&h?c?"left":"right":(c||u)&&(f||h)?`${h?"bottom":"top"}-${c?"left":"right"}`:i.preferredAnchor}const s=this.firstChild,c=this.lastChild;if(s.setAttribute("d",function(t,n,e,r,o){const i=r+2*e,a=o+2*e;switch(t){case"middle":return`M${-i/2},${-a/2}h${i}v${a}h${-i}z`;case"top-left":return`M0,0l${n},${n}h${i-n}v${a}h${-i}z`;case"top":return`M0,0l${n/2},${n/2}h${(i-n)/2}v${a}h${-i}v${-a}h${(i-n)/2}z`;case"top-right":return`M0,0l${-n},${n}h${n-i}v${a}h${i}z`;case"right":return`M0,0l${-n/2},${-n/2}v${n/2-a/2}h${-i}v${a}h${i}v${n/2-a/2}z`;case"bottom-left":return`M0,0l${n},${-n}h${i-n}v${-a}h${-i}z`;case"bottom":return`M0,0l${n/2},${-n/2}h${(i-n)/2}v${-a}h${-i}v${a}h${(i-n)/2}z`;case"bottom-right":return`M0,0l${-n},${-n}h${n-i}v${-a}h${i}z`;case"left":return`M0,0l${n/2},${-n/2}v${n/2-a/2}h${i}v${a}h${-i}v${n/2-a/2}z`}}(l,g,m,o,a)),r)for(const t of c.childNodes)t.setAttribute("x",-r);c.setAttribute("y",+function(t,n,e){return/^top(?:-|$)/.test(t)?.94-e:-.29-n*e}(l,c.childNodes.length,p).toFixed(6)+"em"),c.setAttribute("transform",`translate(${function(t,n,e,r,o){switch(t){case"middle":return[-r/2,o/2];case"top-left":return[e,n+e];case"top":return[-r/2,n/2+e];case"top-right":return[-r-e,n+e];case"right":return[-n/2-r-e,o/2];case"bottom-left":return[e,-n-e];case"bottom":return[-r/2,-n/2-e];case"bottom-right":return[-r-e,-n-e];case"left":return[e+n/2,o/2]}}(l,g,m,o,a)})`)})),j.attr("visibility",null)}return t.length&&(j.attr("visibility","hidden"),u.isConnected?Promise.resolve().then(F):"undefined"!=typeof requestAnimationFrame&&requestAnimationFrame(F)),j.node()}}function Nh(t,{x:n,y:e,...r}={}){return void 0===r.frameAnchor&&([n,e]=ni(n,e)),new Sh(t,{...r,x:n,y:e})}function Ch(t,n){const e={};let r=this.format;r=Th(r,t,"x"),r=Th(r,t,"y"),this.format=r;for(const n in r){const o=r[n];if(null!==o&&!1!==o)if("fx"===n||"fy"===n)e[n]=!0;else{const r=ol(t,n);r&&(e[n]=r)}}for(const n in t){if(n in e||n in r||Oh.has(n))continue;if(("x"===n||"y"===n)&&t.geometry)continue;const o=ol(t,n);if(o){if(null==o.scale&&"color"===o.defaultScale)continue;e[n]=o}}this.facet&&(n.fx&&!("fx"in r)&&(e.fx=!0),n.fy&&!("fy"in r)&&(e.fy=!0));for(const t in e){const r=this.format[t];if("string"==typeof r){const o=e[t]?.value??n[t]?.domain()??[];this.format[t]=(Mi(o)?R:Ie)(r)}else if(void 0===r||!0===r){const e=n[t];this.format[t]=e?.bandwidth?Ef(e,e.domain()):ec}}return e}function Th(t,n,e){if(!(e in t))return t;const r=`${e}1`,o=`${e}2`;if(!(!(r in t)&&r in n||!(o in t)&&o in n))return t;const i=Object.entries(t),a=t[e];return i.splice(i.findIndex((([t])=>t===e))+1,0,[r,a],[o,a]),Object.fromEntries(i)}function Rh(t,n,{title:e}){return this.format.title(e.value[t],t)}function*Ih(t,n,e,r,o){for(const i in e){if("fx"===i||"fy"===i){yield{label:Bh(r,e,i),value:this.format[i](n[i],t)};continue}if("x1"===i&&"x2"in e)continue;if("y1"===i&&"y2"in e)continue;const a=e[i];if("x2"===i&&"x1"in e)yield{label:jh(r,e,"x"),value:Wh(this.format.x2,e.x1,a,t)};else if("y2"===i&&"y1"in e)yield{label:jh(r,e,"y"),value:Wh(this.format.y2,e.y1,a,t)};else{const n=a.value[t],l=a.scale;if(!Tr(n)&&null==l)continue;yield{label:Bh(r,e,i),value:this.format[i](n,t),color:"color"===l?o[i][t]:null,opacity:"opacity"===l?o[i][t]:null}}}}function Wh(t,n,e,r){return e.hint?.length?`${t(e.value[r]-n.value[r],r)}`:`${t(n.value[r],r)}–${t(e.value[r],r)}`}function jh(t,n,e){const r=Bh(t,n,`${e}1`,e),o=Bh(t,n,`${e}2`,e);return r===o?r:`${r}–${o}`}function Bh(t,n,e,r=e){const o=n[e],i=t[o?.scale??e];return String(i?.label??o?.label??r)}function Fh(t={}){const{facet:n,style:e,title:r,subtitle:o,caption:i,ariaLabel:a,ariaDescription:l}=t,s=Ac(t.className),c=void 0===t.marks?[]:qh(t.marks);c.push(...function(t){const n=[];for(const e of t){let t=e.tip;if(t){!0===t?t={}:"string"==typeof t&&(t={pointer:t});let{pointer:r,preferredAnchor:o}=t;r=/^x$/i.test(r)?Bc:/^y$/i.test(r)?Fc:jc,t=r(Zh(e,t)),t.title=null,void 0===o&&(t.preferredAnchor=r===Fc?"left":"bottom");const i=Nh(e.data,t);i.facet=e.facet,i.facetAnchor=e.facetAnchor,n.push(i)}}return n}(c));const u=function(t,n){if(null==t)return;const{x:e,y:r}=t;if(null==e&&null==r)return;const o=Po(t.data);if(null==o)throw new Error("missing facet data");const i={};null!=e&&(i.fx=Ya(o,{value:e,scale:"fx"}));null!=r&&(i.fy=Ya(o,{value:r,scale:"fy"}));Vh(i,n);const a=gs(o,i);return{channels:i,groups:a,data:t.data}}(n,t),f=new Map;for(const n of c){const e=Gh(n,u,t);e&&f.set(n,e)}const h=new Map;u&&Yh(h,[u],t),Yh(h,f,t);const d=qh(function(t,n,e){let{projection:r,x:o={},y:i={},fx:a={},fy:l={},axis:s,grid:c,facet:u={},facet:{axis:f=s,grid:h}=u,x:{axis:d=s,grid:p=(null===d?null:c)}=o,y:{axis:y=s,grid:m=(null===y?null:c)}=i,fx:{axis:g=f,grid:v=(null===g?null:h)}=a,fy:{axis:x=f,grid:w=(null===x?null:h)}=l}=e;(r||!Jo(o)&&!nd("x",t))&&(d=p=null);(r||!Jo(i)&&!nd("y",t))&&(y=m=null);n.has("fx")||(g=v=null);n.has("fy")||(x=w=null);void 0===d&&(d=!td(t,"x"));void 0===y&&(y=!td(t,"y"));void 0===g&&(g=!td(t,"fx"));void 0===x&&(x=!td(t,"fy"));!0===d&&(d="bottom");!0===y&&(y="left");!0===g&&(g="top"===d||null===d?"bottom":"top");!0===x&&(x="right"===y||null===y?"left":"right");const b=[];return Kh(b,w,vf,l),Jh(b,x,hf,"right","left",u,l),Kh(b,v,wf,a),Jh(b,g,pf,"top","bottom",u,a),Kh(b,m,gf,i),Jh(b,y,ff,"left","right",e,i),Kh(b,p,xf,o),Jh(b,d,df,"bottom","top",e,o),b}(c,h,t));for(const n of d){const e=Gh(n,u,t);e&&f.set(n,e)}c.unshift(...d);let p=function(t,n){const{fx:e,fy:r}=Xl(t,n),o=e?.scale.domain(),i=r?.scale.domain();return o&&i?fe(o,i).map((([t,n],e)=>({x:t,y:n,i:e}))):o?o.map(((t,n)=>({x:t,i:n}))):i?i.map(((t,n)=>({y:t,i:n}))):void 0}(h,t);if(void 0!==p){const t=u?Os(p,u):void 0;for(const n of c){if(null===n.facet||"super"===n.facet)continue;const e=f.get(n);void 0!==e&&(e.facetsIndex=null!=n.fx||null!=n.fy?Os(p,e):t)}const n=new Set;for(const{facetsIndex:t}of f.values())t?.forEach(((t,e)=>{t?.length>0&&n.add(e)}));p.forEach(0t.empty=!n.has(e):t=>t.empty=!1);for(const t of c)if("exclude"===t.facet){const n=f.get(t);void 0!==n&&(n.facetsIndex=vs(n.facetsIndex))}}for(const n of Yi.keys())Jo(t[n])&&"fx"!==n&&"fy"!==n&&h.set(n,[]);const y=new Map;for(const n of c){if(y.has(n))throw new Error("duplicate mark; each mark must be unique");const{facetsIndex:e,channels:r}=f.get(n)??{},{data:o,facets:i,channels:a}=n.initialize(e,r,t);Vh(a,t),y.set(n,{data:o,facets:i,channels:a})}const m=Xl(Yh(h,y,t),t),g=function(t,n,e={}){let r=.5-rc,o=.5+rc,i=.5+rc,a=.5-rc;for(const{marginTop:t,marginRight:e,marginBottom:l,marginLeft:s}of n)t>r&&(r=t),e>o&&(o=e),l>i&&(i=l),s>a&&(a=s);let{margin:l,marginTop:s=(void 0!==l?l:r),marginRight:c=(void 0!==l?l:o),marginBottom:u=(void 0!==l?l:i),marginLeft:f=(void 0!==l?l:a)}=e;s=+s,c=+c,u=+u,f=+f;let{width:h=640,height:d=Tc(t,e,{width:h,marginTopDefault:r,marginRightDefault:o,marginBottomDefault:i,marginLeftDefault:a})+Math.max(0,s-r+u-i)}=e;h=+h,d=+d;const p={width:h,height:d,marginTop:s,marginRight:c,marginBottom:u,marginLeft:f};if(t.fx||t.fy){let{margin:t,marginTop:n=(void 0!==t?t:s),marginRight:r=(void 0!==t?t:c),marginBottom:o=(void 0!==t?t:u),marginLeft:i=(void 0!==t?t:f)}=e.facet??{};n=+n,r=+r,o=+o,i=+i,p.facet={marginTop:n,marginRight:r,marginBottom:o,marginLeft:i}}return p}(m,c,t);!function(t,n){const{x:e,y:r,fx:o,fy:i}=t,a=o||i?Kl(n):n;o&&ts(o,a),i&&ns(i,a);const l=o||i?Ql(t,n):n;e&&ts(e,l),r&&ns(r,l)}(m,g);const v=Gl(m),{fx:x,fy:w}=v,b=x||w?Ql(m,g):g,k=x||w?function({fx:t,fy:n},e){const{marginTop:r,marginRight:o,marginBottom:i,marginLeft:a,width:l,height:s}=Kl(e),c=t&&ed(t),u=n&&ed(n);return{marginTop:n?u[0]:r,marginRight:t?l-c[1]:o,marginBottom:n?s-u[1]:i,marginLeft:t?c[0]:a,inset:{marginTop:e.marginTop,marginRight:e.marginRight,marginBottom:e.marginBottom,marginLeft:e.marginLeft},width:l,height:s}}(v,g):g,$=Ps(t),M=$.document,A=Ce("svg").call(M.documentElement);let L=A;$.ownerSVGElement=A,$.className=s,$.projection=Ts(t,b),$.filterFacets=(t,n)=>Os(p,{channels:n,groups:gs(t,n)}),$.getMarkState=t=>{const n=y.get(t),e=f.get(t);return{...n,channels:{...n.channels,...e?.channels}}},$.dispatchValue=t=>{L.value!==t&&(L.value=t,L.dispatchEvent(new Event("input",{bubbles:!0})))};const E=new Set;for(const[n,e]of y)if(null!=n.initializer){const r="super"===n.facet?k:b,o=n.initializer(e.data,e.facets,e.channels,v,r,$);if(void 0!==o.data&&(e.data=o.data),void 0!==o.facets&&(e.facets=o.facets),void 0!==o.channels){const{fx:r,fy:i,...a}=o.channels;Uh(a),Object.assign(e.channels,a);for(const n of Object.values(a)){const{scale:e}=n;null!=e&&((z=Yi.get(e))!==Di&&z!==Ui)&&(Hh(n,t),E.add(e))}null==r&&null==i||f.set(n,!0)}}var z;if(E.size){const n=new Map;Yh(n,y,t,(t=>E.has(t))),Yh(h,y,t,(t=>E.has(t)));const e=function(t,n){for(const e in t){const r=t[e],o=n[e];void 0===r.label&&o&&(r.label=o.label)}return t}(Xl(n,t),m),{scales:r,...o}=Gl(e);Object.assign(m,e),Object.assign(v,o),Object.assign(v.scales,r)}let O,S;void 0!==p&&(O={x:x?.domain(),y:w?.domain()},p=function(t,{x:n,y:e}){return n&&=bs(n),e&&=bs(e),t.filter(n&&e?t=>n.has(t.x)&&e.has(t.y):n?t=>n.has(t.x):t=>e.has(t.y)).sort(n&&e?(t,r)=>n.get(t.x)-n.get(r.x)||e.get(t.y)-e.get(r.y):n?(t,e)=>n.get(t.x)-n.get(e.x):(t,n)=>e.get(t.y)-e.get(n.y))}(p,O),S=function(t,n,{marginTop:e,marginLeft:r}){return t&&n?({x:o,y:i})=>`translate(${t(o)-r},${n(i)-e})`:t?({x:n})=>`translate(${t(n)-r},0)`:({y:t})=>`translate(0,${n(t)-e})`}(x,w,g));for(const[t,n]of y)n.values=t.scale(n.channels,v,$);const{width:N,height:C}=g;Ne(A).attr("class",s).attr("fill","currentColor").attr("font-family","system-ui, sans-serif").attr("font-size",10).attr("text-anchor","middle").attr("width",N).attr("height",C).attr("viewBox",`0 0 ${N} ${C}`).attr("aria-label",a).attr("aria-description",l).call((t=>t.append("style").text(`:where(.${s}) {\n --plot-background: white;\n display: block;\n height: auto;\n height: intrinsic;\n max-width: 100%;\n}\n:where(.${s} text),\n:where(.${s} tspan) {\n white-space: pre;\n}`))).call(Lc,e);for(const t of c){const{channels:n,values:e,facets:r}=y.get(t);if(void 0===p||"super"===t.facet){let o=null;if(r&&(o=r[0],o=t.filter(o,n,e),0===o.length))continue;const i=t.render(o,v,e,k,$);if(null==i)continue;A.appendChild(i)}else{let o;for(const i of p){if(!(t.facetAnchor?.(p,O,i)??!i.empty))continue;let a=null;if(r){const o=f.has(t);if(a=r[o?i.i:0],a=t.filter(a,n,e),0===a.length)continue;o||a!==r[0]||(a=li(a)),a.fx=i.x,a.fy=i.y,a.fi=i.i}const l=t.render(a,v,e,b,$);if(null!=l){(o??=Ne(A).append("g")).append((()=>l)).datum(i);for(const t of["aria-label","aria-description","aria-hidden","transform"])l.hasAttribute(t)&&(o.attr(t,l.getAttribute(t)),l.removeAttribute(t))}}o?.selectChildren().attr("transform",S)}}const T=function(t,n,e){const r=[];for(const[o,i]of Ff){const a=e[o];if(a?.legend&&o in t){const e=i(t[o],qf(n,t[o],a),(n=>t[n]));null!=e&&r.push(e)}}return r}(m,$,t),{figure:R=null!=r||null!=o||null!=i||T.length>0}=t;R&&(L=M.createElement("figure"),L.className=`${s}-figure`,L.style.maxWidth="initial",null!=r&&L.append(Dh(M,r,"h2")),null!=o&&L.append(Dh(M,o,"h3")),L.append(...T,A),null!=i&&L.append(function(t,n){const e=t.createElement("figcaption");return e.append(n),e}(M,i)),"value"in A&&(L.value=A.value,delete A.value)),L.scale=function(t){return n=>{if(!Yi.has(n=`${n}`))throw new Error(`unknown scale: ${n}`);return t[n]}}(v.scales),L.legend=function(t,n,e={}){return(r,o)=>{if(!Ff.has(r))throw new Error(`unknown legend type: ${r}`);if(r in t)return Ff.get(r)(t[r],qf(n,e[r],o),(n=>t[n]))}}(m,$,t);const I=function(){const t=Tl;return Tl=0,Cl=void 0,t}();return I>0&&Ne(A).append("text").attr("x",N).attr("y",20).attr("dy","-1em").attr("text-anchor","end").attr("font-family","initial").text("⚠️").append("title").text(`${I.toLocaleString("en-US")} warning${1===I?"":"s"}. Please check the console.`),L}function Dh(t,n,e){if(n.ownerDocument)return n;const r=t.createElement(e);return r.append(n),r}function qh(t){return t.flat(1/0).filter((t=>null!=t)).map(_h)}function _h(t){return"function"==typeof t.render?t:new Ph(t)}class Ph extends zc{constructor(t){if("function"!=typeof t)throw new TypeError("invalid mark; missing render function");super(),this.render=t}render(){}}function Vh(t,n){for(const e in t)Hh(t[e],n);return t}function Hh(t,n){const{scale:e,transform:r=!0}=t;if(null==e||!r)return;const{type:o,percent:i,interval:a,transform:l=(i?t=>null==t?NaN:100*t:yi(a,o))}=n[e]??{};null!=l&&(t.value=Ho(t.value,l),t.transform=!1)}function Uh(t){for(const n in t)Za(n,t[n])}function Yh(t,n,e,r=Eo){for(const{channels:o}of n.values())for(const n in o){const i=o[n],{scale:a}=i;if(null!=a&&r(a))if("projection"===a){if(!Ds(e)){const n=void 0===e.x?.domain,r=void 0===e.y?.domain;if(n||r){const[e,o]=_s(i);n&&Xh(t,"x",e),r&&Xh(t,"y",o)}}}else Xh(t,a,i)}return t}function Xh(t,n,e){const r=t.get(n);void 0!==r?r.push(e):t.set(n,[e])}function Gh(t,n,e){if(null===t.facet||"super"===t.facet)return;const{fx:r,fy:o}=t;if(null!=r||null!=o){const n=Po(t.data??r??o);if(void 0===n)throw new Error(`missing facet data in ${t.ariaLabel}`);if(null===n)return;const i={};return null!=r&&(i.fx=Ya(n,{value:r,scale:"fx"})),null!=o&&(i.fy=Ya(n,{value:o,scale:"fy"})),Vh(i,e),{channels:i,groups:gs(n,i)}}if(void 0===n)return;const{channels:i,groups:a,data:l}=n;if("auto"!==t.facet||t.data===l)return{channels:i,groups:a};l.length>0&&(a.size>1||1===a.size&&i.fx&&i.fy&&[...a][0][1].size>1)&&ri(Po(t.data))===ri(l)&&Rl(`Warning: the ${t.ariaLabel} mark appears to use faceted data, but isn’t faceted. The mark data has the same length as the facet data and the mark facet option is "auto", but the mark data and facet data are distinct. If this mark should be faceted, set the mark facet option to true; otherwise, suppress this warning by setting the mark facet option to false.`)}function Zh(t,n={}){return na({...n,x:null,y:null},((n,e,r,o,i,a)=>a.getMarkState(t)))}function Jh(t,n,e,r,o,i,a){if(!n)return;const l=/^\s*both\s*$/i.test(n);a=function(t,n,{line:e=n.line,ticks:r,tickSize:o,tickSpacing:i,tickPadding:a,tickFormat:l,tickRotate:s,fontVariant:c,ariaLabel:u,ariaDescription:f,label:h=n.label,labelAnchor:d,labelArrow:p=n.labelArrow,labelOffset:y}){return{anchor:t,line:e,ticks:r,tickSize:o,tickSpacing:i,tickPadding:a,tickFormat:l,tickRotate:s,fontVariant:c,ariaLabel:u,ariaDescription:f,label:h,labelAnchor:d,labelArrow:p,labelOffset:y}}(l?r:n,i,a);const{line:s}=a;e!==ff&&e!==df||!s||Ti(s)||t.push(Eh(function(t){const{anchor:n,line:e}=t;return{anchor:n,facetAnchor:n+"-empty",stroke:!0===e?void 0:e}}(a))),t.push(e(a)),l&&t.push(e({...a,anchor:o,label:null}))}function Kh(t,n,e,r){n&&!Ti(n)&&t.push(e(function(t,{stroke:n=(Si(t)?t:void 0),ticks:e=(Qh(t)?t:void 0),tickSpacing:r,ariaLabel:o,ariaDescription:i}){return{stroke:n,ticks:e,tickSpacing:r,ariaLabel:o,ariaDescription:i}}(n,r)))}function Qh(t){switch(typeof t){case"number":return!0;case"string":return!Si(t)}return bi(t)||"function"==typeof t?.range}function td(t,n){const e=`${n}-axis `;return t.some((t=>t.ariaLabel?.startsWith(e)))}function nd(t,n){for(const e of n)for(const n in e.channels){const{scale:r}=e.channels[n];if(r===t||"projection"===r)return!0}return!1}function ed(t){const n=t.domain();if(0===n.length)return[0,t.bandwidth()];let e=t(n[0]),r=t(n[n.length-1]);return r{const u=pi(vo(e,v),c?.[x]),h=vo(e,M),p=vo(e,B),m=vo(e,F),w=Na(s,{z:h,fill:p,stroke:m}),k=[],$=[],A=u&&b([]),L=h&&j([]),E=p&&q([]),z=m&&P([]),O=t&&f([]),S=t&&d([]),N=n&&y([]),C=n&&g([]),T=function(t,n,e){const r=t?.(e),o=n?.(e);return r&&o?function*(t){const n=r.bin(t);for(const[t,[i,a]]of r.entries()){const r=o.bin(n[t]);for(const[t,[n,l]]of o.entries())yield[r[t],{data:e,x1:i,y1:n,x2:a,y2:l}]}}:r?function*(t){const n=r.bin(t);for(const[t,[o,i]]of r.entries())yield[n[t],{data:e,x1:o,x2:i}]}:function*(t){const n=o.bin(t);for(const[t,[r,i]]of o.entries())yield[n[t],{data:e,y1:r,y2:i}]}}(t,n,e);let R=0;for(const t of s)t.initialize(e);a&&a.initialize(e),i&&i.initialize(e);for(const t of r){const n=[];for(const n of s)n.scope("facet",t);a&&a.scope("facet",t),i&&i.scope("facet",t);for(const[r,l]of $a(t,w))for(const[t,c]of $a(l,u))for(const[l,f]of T(c))if(w&&(f.z=r),!i||i.reduce(l,f)){n.push(R++),$.push(o.reduceIndex(l,e,f)),u&&A.push(t),h&&L.push(w===h?r:h[(l.length>0?l:c)[0]]),p&&E.push(w===p?r:p[(l.length>0?l:c)[0]]),m&&z.push(w===m?r:m[(l.length>0?l:c)[0]]),O&&(O.push(f.x1),S.push(f.x2)),N&&(N.push(f.y1),C.push(f.y2));for(const t of s)t.reduce(l,f);a&&a.reduce(l,f)}k.push(n)}return Ca(k,a,l),{data:$,facets:k}})),...!xa(s,"x")&&(u?{x1:u,x2:h,x:di(u,h)}:{x:k,x1:E,x2:z}),...!xa(s,"y")&&(p?{y1:p,y2:m,y:di(p,m)}:{y:$,y1:O,y2:S}),...w&&{[x]:w},...Object.fromEntries(s.map((({name:t,output:n})=>[t,n])))}}function pd({cumulative:t,domain:n,thresholds:e,interval:r,...o},i){return[o,{cumulative:t,domain:n,thresholds:e,interval:r,...i}]}function yd(t,{cumulative:n,domain:e,thresholds:r,interval:o},i){return void 0===(t={...wi(t)}).domain&&(t.domain=e),void 0===t.cumulative&&(t.cumulative=n),void 0===t.thresholds&&(t.thresholds=r),void 0===t.interval&&(t.interval=o),void 0===t.value&&(t.value=i),t.thresholds=gd(t.thresholds,t.interval),t}function md(t){if(null==t)return;const{value:n,cumulative:e,domain:r=qn,thresholds:o}=t,i=t=>{let i,a=vo(t,n);if(Mi(a)||(function(t){return xi(t)&&"function"==typeof t?.floor&&t.floor()instanceof Date}(l=o)||bi(l)&&Mi(l))){a=Ho(a,Bo,Float64Array);let[t,n]="function"==typeof r?r(a):r,e="function"!=typeof o||xi(o)?o:o(a,t,n);"number"==typeof e&&(e=fr(t,n,e)),xi(e)&&(r===qn&&(t=e.floor(t),n=e.offset(e.floor(n))),e=e.range(t,e.offset(n))),i=e}else{a=Io(a);let[t,n]="function"==typeof r?r(a):r,e="function"!=typeof o||xi(o)?o:o(a,t,n);if("number"==typeof e)if(r===qn){let r=hr(t,n,e);if(isFinite(r))if(r>0){let o=Math.round(t/r),i=Math.round(n/r);o*r<=t||--o,i*r>n||++i;let a=i-o+1;e=new Float64Array(a);for(let t=0;tn||++i;let a=i-o+1;e=new Float64Array(a);for(let t=0;t0?Md:$d)(s,i,a),s};return i.label=hi(n),i}function gd(t,n,e=kd){if(void 0===t)return void 0===n?e:vi(n);if("string"==typeof t){switch(t.toLowerCase()){case"freedman-diaconis":return ur;case"scott":return cr;case"sturges":return sr;case"auto":return kd}return io(t)}return t}function vd(t,n,e){return ba(t,n,e,xd)}function xd(t,n,e){return ka(t,n,e,wd)}function wd(t,n){return Ma(t,n,bd)}function bd(t){switch(`${t}`.toLowerCase()){case"x":return Ed;case"x1":return Od;case"x2":return Sd;case"y":return zd;case"y1":return Nd;case"y2":return Cd;case"z":return Ha}throw new Error(`invalid bin reduce: ${t}`)}function kd(t,n,e){return Math.min(200,cr(t,n,e))}function $d(t,n,e){return n=Io(n),r=>{const o=t.map((()=>[]));for(const t of r)o[dr(n,e[t])-1]?.push(t);return o}}function Md(t,n,e){const r=$d(t,n,e);return t=>{const n=r(t);for(let t=1,e=n.length;t{const n=r(t);for(let t=n.length-2;t>=0;--t){const e=n[t+1],r=n[t];for(const t of e)r.push(t)}return n}}function Ld(t,n){const e=(+t+ +n)/2;return t instanceof Date?new Date(e):e}const Ed={reduceIndex:(t,n,{x1:e,x2:r})=>Ld(e,r)},zd={reduceIndex:(t,n,{y1:e,y2:r})=>Ld(e,r)},Od={reduceIndex:(t,n,{x1:e})=>e},Sd={reduceIndex:(t,n,{x2:e})=>e},Nd={reduceIndex:(t,n,{y1:e})=>e},Cd={reduceIndex:(t,n,{y2:e})=>e},Td={ariaLabel:"area",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class Rd extends zc{constructor(t,n={}){const{x1:e,y1:r,x2:o,y2:i,z:a,curve:l,tension:s}=n;super(t,{x1:{value:e,scale:"x"},y1:{value:r,scale:"y"},x2:{value:o,scale:"x",optional:!0},y2:{value:i,scale:"y",optional:!0},z:{value:ei(n),optional:!0}},n,Td),this.z=a,this.curve=od(l,s)}filter(t){return t}render(t,n,e,r,o){const{x1:i,y1:a,x2:l=i,y2:s=a}=e;return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,n,0,0).call((n=>n.selectAll().data(dc(t,[i,a,l,s],this,e)).enter().append("path").call(vc,this).call(fc,this,e).attr("d",pr().curve(this.curve).defined((t=>t>=0)).x0((t=>i[t])).y0((t=>a[t])).x1((t=>l[t])).y1((t=>s[t]))))).node()}}function Id(t,n){return void 0===n?jd(t,{x:So,y:No}):new Rd(t,n)}function Wd(t,n){const{y:e=Mo,...r}=hd(n);return new Rd(t,Qf(Vf({...r,y1:e,y2:void 0})))}function jd(t,n){const{x:e=Mo,...r}=fd(n);return new Rd(t,th(Hf({...r,x1:e,x2:void 0})))}const Bd={ariaLabel:"link",fill:"none",stroke:"currentColor",strokeMiterlimit:1};class Fd extends zc{constructor(t,n={}){const{x1:e,y1:r,x2:o,y2:i,curve:a,tension:l}=n;super(t,{x1:{value:e,scale:"x"},y1:{value:r,scale:"y"},x2:{value:o,scale:"x",optional:!0},y2:{value:i,scale:"y",optional:!0}},n,Bd),this.curve=id(a,l),Vc(this,n)}project(t,n,e){this.curve!==ad&&super.project(t,n,e)}render(t,n,e,r,o){const{x1:i,y1:a,x2:l=i,y2:s=a}=e,{curve:c}=this;return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,n).call((n=>n.selectAll().data(t).enter().append("path").call(vc,this).attr("d",c===ad&&o.projection?function(t,n,e,r,o){const i=pe(t);return n=Io(n),e=Io(e),r=Io(r),o=Io(o),t=>i({type:"LineString",coordinates:[[n[t],e[t]],[r[t],o[t]]]})}(o.projection,i,a,l,s):t=>{const n=je(),e=c(n);return e.lineStart(),e.point(i[t],a[t]),e.point(l[t],s[t]),e.lineEnd(),n}).call(uc,this,e).call(Kc,this,e,o))).node()}}function Dd(t,{x:n,x1:e,x2:r,y:o,y1:i,y2:a,...l}={}){return[e,r]=qd(n,e,r),[i,a]=qd(o,i,a),new Fd(t,{...l,x1:e,x2:r,y1:i,y2:a})}function qd(t,n,e){if(void 0===t){if(void 0===n){if(void 0!==e)return[e]}else if(void 0===e)return[n]}else{if(void 0===n)return void 0===e?[t]:[t,e];if(void 0===e)return[t,n]}return[n,e]}const _d={ariaLabel:"arrow",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:1,strokeWidth:1.5};class Pd extends zc{constructor(e,r={}){const{x1:o,y1:i,x2:a,y2:l,bend:s=0,headAngle:c=60,headLength:u=8,inset:f=0,insetStart:h=f,insetEnd:d=f,sweep:p}=r;super(e,{x1:{value:o,scale:"x"},y1:{value:i,scale:"y"},x2:{value:a,scale:"x",optional:!0},y2:{value:l,scale:"y",optional:!0}},r,_d),this.bend=!0===s?22.5:Math.max(-90,Math.min(90,s)),this.headAngle=+c,this.headLength=+u,this.insetStart=+h,this.insetEnd=+d,this.sweep=function(e=1){if("number"==typeof e)return To(Math.sign(e));if("function"==typeof e)return(t,n,r,o)=>Math.sign(e(t,n,r,o));switch(_o(e,"sweep",["+x","-x","+y","-y"])){case"+x":return(n,e,r)=>t(n,r);case"-x":return(t,e,r)=>n(t,r);case"+y":return(n,e,r,o)=>t(e,o);case"-y":return(t,e,r,o)=>n(e,o)}}(p)}render(t,n,e,r,o){const{x1:i,y1:a,x2:l=i,y2:s=a,SW:c}=e,{strokeWidth:u,bend:f,headAngle:h,headLength:d,insetStart:p,insetEnd:y}=this,m=c?t=>c[t]:To(void 0===u?1:u),g=h*Pc/2,v=d/1.5;return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,n).call((n=>n.selectAll().data(t).enter().append("path").call(vc,this).attr("d",(t=>{let n=i[t],e=a[t],r=l[t],o=s[t];const c=Math.hypot(r-n,o-e);if(c<=p+y)return null;let u=Math.atan2(o-e,r-n);const h=Math.min(v*m(t),c/3),d=this.sweep(n,e,r,o)*f*Pc,x=Math.hypot(c/Math.tan(d),c)/2;if(p||y)if(x<1e5){const t=Math.sign(d),[i,a]=function([t,n],[e,r],o,i){const a=e-t,l=r-n,s=Math.hypot(a,l),c=i*Math.sqrt(o*o-s*s/4)/s;return[(t+e)/2-l*c,(n+r)/2+a*c]}([n,e],[r,o],x,t);if(p&&([n,e]=Vd([i,a,x],[n,e,p],-t*Math.sign(p))),y){const[n,e]=Vd([i,a,x],[r,o,y],t*Math.sign(y));u+=Math.atan2(e-a,n-i)-Math.atan2(o-a,r-i),r=n,o=e}}else{const t=r-n,i=o-e,a=Math.hypot(t,i);p&&(n+=t/a*p,e+=i/a*p),y&&(r-=t/a*y,o-=i/a*y)}const w=u+d,b=w+g,k=w-g,$=r-h*Math.cos(b),M=o-h*Math.sin(b),A=r-h*Math.cos(k),L=o-h*Math.sin(k);return`M${n},${e}${x<1e5?`A${x},${x} 0,0,${d>0?1:0} `:"L"}${r},${o}${h?`M${$},${M}L${r},${o}L${A},${L}`:""}`})).call(uc,this,e))).node()}}function Vd([t,n,e],[r,o,i],a){const l=r-t,s=o-n,c=Math.hypot(l,s),u=(l*l+s*s-i*i+e*e)/(2*c),f=a*Math.sqrt(e*e-u*u);return[t+(l*u+s*f)/c,n+(s*u-l*f)/c]}function Hd(t,{x:n,x1:e,x2:r,y:o,y1:i,y2:a,...l}={}){return[e,r]=qd(n,e,r),[i,a]=qd(o,i,a),new Pd(t,{...l,x1:e,x2:r,y1:i,y2:a})}const Ud={ariaLabel:"bar"};class Yd extends zc{constructor(t,n,e={},r=Ud){super(t,n,e,r),mh(this,e),gh(this,e)}render(t,n,e,r,o){const{rx:i,ry:a,rx1y1:l,rx1y2:s,rx2y1:c,rx2y2:u}=this,f=this._x(n,e,r),h=this._y(n,e,r),d=this._width(n,e,r),p=this._height(n,e,r);return Vs("svg:g",o).call(gc,this,r,o).call(this._transform,this,n).call((n=>n.selectAll().data(t).enter().call(l||s||c||u?t=>t.append("path").call(vc,this).call(vh,f,h,Xd(f,d),Xd(h,p),this).call(uc,this,e):t=>t.append("rect").call(vc,this).attr("x",f).attr("width",d).attr("y",h).attr("height",p).call(wc,"rx",i).call(wc,"ry",a).call(uc,this,e)))).node()}_x(t,{x:n},{marginLeft:e}){const{insetLeft:r}=this;return n?t=>n[t]+r:e+r}_y(t,{y:n},{marginTop:e}){const{insetTop:r}=this;return n?t=>n[t]+r:e+r}_width({x:t},{x:n},{marginRight:e,marginLeft:r,width:o}){const{insetLeft:i,insetRight:a}=this,l=n&&t?t.bandwidth():o-e-r;return Math.max(0,l-i-a)}_height({y:t},{y:n},{marginTop:e,marginBottom:r,height:o}){const{insetTop:i,insetBottom:a}=this,l=n&&t?t.bandwidth():o-e-r;return Math.max(0,l-i-a)}}function Xd(t,n){return"function"==typeof t&&"function"==typeof n?e=>t(e)+n(e):"function"==typeof t?e=>t(e)+n:"function"==typeof n?e=>t+n(e):t+n}class Gd extends Yd{constructor(t,n={},e){const{x1:r,x2:o,y:i}=n;super(t,{x1:{value:r,scale:"x"},x2:{value:o,scale:"x"},y:{value:i,scale:"y",type:"band",optional:!0}},n,e)}_transform(t,n,{x:e}){t.call(bc,n,{x:e},0,0)}_x({x:t},{x1:n,x2:e},{marginLeft:r}){const{insetLeft:o}=this;return hs(t)?r+o:t=>Math.min(n[t],e[t])+o}_width({x:t},{x1:n,x2:e},{marginRight:r,marginLeft:o,width:i}){const{insetLeft:a,insetRight:l}=this;return hs(t)?i-r-o-a-l:t=>Math.max(0,Math.abs(e[t]-n[t])-a-l)}}class Zd extends Yd{constructor(t,n={},e){const{x:r,y1:o,y2:i}=n;super(t,{y1:{value:o,scale:"y"},y2:{value:i,scale:"y"},x:{value:r,scale:"x",type:"band",optional:!0}},n,e)}_transform(t,n,{y:e}){t.call(bc,n,{y:e},0,0)}_y({y:t},{y1:n,y2:e},{marginTop:r}){const{insetTop:o}=this;return hs(t)?r+o:t=>Math.min(n[t],e[t])+o}_height({y:t},{y1:n,y2:e},{marginTop:r,marginBottom:o,height:i}){const{insetTop:a,insetBottom:l}=this;return hs(t)?i-r-o-a-l:t=>Math.max(0,Math.abs(e[t]-n[t])-a-l)}}function Jd(t,n={}){return Go(n)||(n={...n,y:Mo,x2:Ao}),new Gd(t,Qf(fu(Vf(n))))}function Kd(t,n={}){return Go(n)||(n={...n,x:Mo,y2:Ao}),new Zd(t,th(hu(Hf(n))))}const Qd={ariaLabel:"cell"};class tp extends Yd{constructor(t,{x:n,y:e,...r}={}){super(t,{x:{value:n,scale:"x",type:"band",optional:!0},y:{value:e,scale:"y",type:"band",optional:!0}},r,Qd)}_transform(t,n){t.call(bc,n,{},0,0)}}function np(t,{x:n,y:e,...r}={}){return[n,e]=ni(n,e),new tp(t,{...r,x:n,y:e})}function ep(t,{x:n=Mo,fill:e,stroke:r,...o}={}){return void 0===e&&void 0===Fo(r)[0]&&(e=Ao),new tp(t,{...o,x:n,fill:e,stroke:r})}function rp(t,{y:n=Mo,fill:e,stroke:r,...o}={}){return void 0===e&&void 0===Fo(r)[0]&&(e=Ao),new tp(t,{...o,y:n,fill:e,stroke:r})}const op={ariaLabel:"dot",fill:"none",stroke:"currentColor",strokeWidth:1.5};function ip(t){return void 0===t.sort&&void 0===t.reverse?ua({channel:"-r"},t):t}class ap extends zc{constructor(t,n={}){const{x:e,y:r,r:o,rotate:i,symbol:a=B,frameAnchor:l}=n,[s,c]=Do(i,0),[u,f]=function(t){if(null==t||Ji(t))return[void 0,t];if("string"==typeof t){const n=Zi.get(`${t}`.toLowerCase());if(n)return[void 0,n]}return[t,void 0]}(a),[h,d]=Do(o,null==u?3:4.5);super(t,{x:{value:e,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},r:{value:h,scale:"r",filter:Br,optional:!0},rotate:{value:s,optional:!0},symbol:{value:u,scale:"auto",optional:!0}},ip(n),op),this.r=d,this.rotate=c,this.symbol=f,this.frameAnchor=Ii(l);const{channels:p}=this,{symbol:y}=p;if(y){const{fill:t,stroke:n}=p;y.hint={fill:t?t.value===y.value?"color":"currentColor":this.fill??"currentColor",stroke:n?n.value===y.value?"color":"currentColor":this.stroke??"none"}}}render(t,n,e,r,o){const{x:i,y:a}=n,{x:l,y:s,r:c,rotate:u,symbol:f}=e,{r:h,rotate:d,symbol:p}=this,[y,m]=Ec(this,r),g=p===B,v=c?void 0:h*h*Math.PI;return Fr(h)&&(t=[]),Vs("svg:g",o).call(gc,this,r,o).call(bc,this,{x:l&&i,y:s&&a}).call((n=>n.selectAll().data(t).enter().append(g?"circle":"path").call(vc,this).call(g?t=>{t.attr("cx",l?t=>l[t]:y).attr("cy",s?t=>s[t]:m).attr("r",c?t=>c[t]:h)}:t=>{t.attr("transform",bu`translate(${l?t=>l[t]:y},${s?t=>s[t]:m})${u?t=>` rotate(${u[t]})`:d?` rotate(${d})`:""}`).attr("d",c&&f?t=>{const n=je();return f[t].draw(n,c[t]*c[t]*Math.PI),n}:c?t=>{const n=je();return p.draw(n,c[t]*c[t]*Math.PI),n}:f?t=>{const n=je();return f[t].draw(n,v),n}:(()=>{const t=je();return p.draw(t,v),t})())}).call(uc,this,e))).node()}}function lp(t,{x:n,y:e,...r}={}){return void 0===r.frameAnchor&&([n,e]=ni(n,e)),new ap(t,{...r,x:n,y:e})}function sp(t,{x:n=Ao,...e}={}){return new ap(t,pu({...e,x:n}))}function cp(t,{y:n=Ao,...e}={}){return new ap(t,du({...e,y:n}))}function up(t,n){return lp(t,{...n,symbol:"circle"})}function fp(t,n){return lp(t,{...n,symbol:"hexagon"})}const hp={ariaLabel:"line",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class dp extends zc{constructor(t,n={}){const{x:e,y:r,z:o,curve:i,tension:a}=n;super(t,{x:{value:e,scale:"x"},y:{value:r,scale:"y"},z:{value:ei(n),optional:!0}},n,hp),this.z=o,this.curve=id(i,a),Vc(this,n)}filter(t){return t}project(t,n,e){this.curve!==ad&&super.project(t,n,e)}render(t,n,e,r,o){const{x:i,y:a}=e,{curve:l}=this;return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,n).call((n=>n.selectAll().data(dc(t,[i,a],this,e)).enter().append("path").call(vc,this).call(fc,this,e).call(Qc,this,e,o).attr("d",l===ad&&o.projection?function(t,n,e){const r=pe(t);return n=Io(n),e=Io(e),t=>{let o=[];const i=[o];for(const r of t)-1===r?(o=[],i.push(o)):o.push([n[r],e[r]]);return r({type:"MultiLineString",coordinates:i})}}(o.projection,i,a):yr().curve(l).defined((t=>t>=0)).x((t=>i[t])).y((t=>a[t]))))).node()}}function pp(t,{x:n,y:e,...r}={}){return[n,e]=ni(n,e),new dp(t,{...r,x:n,y:e})}function yp(t,{x:n=Ao,y:e=Mo,...r}={}){return new dp(t,hd({...r,x:n,y:e}))}function mp(t,{x:n=Mo,y:e=Ao,...r}={}){return new dp(t,fd({...r,x:n,y:e}))}function gp(t,n){n=function({x:t,y:n,color:e,size:r,fx:o,fy:i,mark:a}={}){Ko(t)||(t=bp(t));Ko(n)||(n=bp(n));Ko(e)||(e=Si(e)?{color:e}:bp(e));Ko(r)||(r=bp(r));Ko(o)&&({value:o}=bp(o));Ko(i)&&({value:i}=bp(i));null!=a&&(a=`${a}`.toLowerCase());return{x:t,y:n,color:e,size:r,fx:o,fy:i,mark:a}}(n);const{x:e,y:r,color:o,size:i}=n,a=wp(t,e),l=wp(t,r),s=wp(t,o),c=wp(t,i);let u,f,h,{fx:d,fy:p,x:{value:y,reduce:m,zero:g,...v},y:{value:x,reduce:w,zero:b,...k},color:{value:$,color:M,reduce:A},size:{value:L,reduce:E},mark:z}=n;if(void 0===m&&(m=null==w&&null==y&&null==L&&null!=x?"count":null),void 0===w&&(w=null==m&&null==x&&null==L&&null!=y?"count":null),void 0!==E||null!=L||null!=A||null!=m||null!=w||null!=y&&!$i(a)||null!=x&&!$i(l)||(E="count"),void 0===g&&(g=!!kp(m)||void 0),void 0===b&&(b=!!kp(w)||void 0),null==y&&null==x)throw new Error("must specify x or y");if(null!=m&&null==x)throw new Error("reducing x requires y");if(null!=w&&null==y)throw new Error("reducing y requires x");switch(void 0===z&&(z=null!=L||null!=E?"dot":kp(m)||kp(w)||null!=A?"bar":null!=y&&null!=x?$i(a)||$i(l)||null==m&&null==w&&!xp(a)&&!xp(l)?"dot":"line":null!=y||null!=x?"rule":null),z){case"dot":h=lp,f="stroke";break;case"line":h=a&&l||null!=m||null!=w?b||null!=w||a&&xp(a)?mp:g||null!=m||l&&xp(l)?yp:pp:a?yp:mp,f="stroke",Mp(s)&&(u=null);break;case"area":h=!b&&null==w&&(g||null!=m||l&&xp(l))?Wd:jd,f="fill",Mp(s)&&(u=null);break;case"rule":h=a?vu:xu,f="stroke";break;case"bar":h=null!=m?$i(l)?$p(m)&&a&&$i(a)?np:Jd:kh:null!=w?$i(a)?$p(w)&&l&&$i(l)?np:Kd:$h:null!=A||null!=E?a&&$i(a)&&l&&$i(l)?np:a&&$i(a)?Kd:l&&$i(l)?Jd:bh:!a||!Ei(a)||l&&Ei(l)?!l||!Ei(l)||a&&Ei(a)?np:Kd:Jd,f="fill";break;default:throw new Error(`invalid mark: ${z}`)}let O,S={fx:d,fy:p,x:a??void 0,y:l??void 0,[f]:s??M,z:u,r:c??void 0,tip:!0},N={[f]:A??void 0,r:E??void 0};if(null!=m&&null!=w)throw new Error("cannot reduce both x and y");return null!=w?(N.y=w,O=$i(a)?ya:ld):null!=m?(N.x=m,O=$i(l)?ma:sd):null==A&&null==E||(a&&l?O=$i(a)&&$i(l)?ga:$i(a)?sd:$i(l)?ld:cd:a?O=$i(a)?ya:ld:l&&(O=$i(l)?ma:sd)),O!==cd&&O!==ld||(S.x={value:a,...v}),O!==cd&&O!==sd||(S.y={value:l,...k}),void 0===g&&(g=a&&!(O===cd||O===ld)&&(h===Jd||h===Wd||h===kh||h===xu)),void 0===b&&(b=l&&!(O===cd||O===sd)&&(h===Kd||h===jd||h===$h||h===vu)),{fx:d??null,fy:p??null,x:{value:y??null,reduce:m??null,zero:!!g,...v},y:{value:x??null,reduce:w??null,zero:!!b,...k},color:{value:$??null,reduce:A??null,...void 0!==M&&{color:M}},size:{value:L??null,reduce:E??null},mark:z,markImpl:Lp[h],markOptions:S,transformImpl:Lp[O],transformOptions:N,colorMode:f}}function vp(t,n){const e=gp(t,n),{fx:r,fy:o,x:{zero:i},y:{zero:a},markOptions:l,transformOptions:s,colorMode:c}=e,u=Ap[e.markImpl],f=Ap[e.transformImpl],h=null!=r||null!=o?Eh({strokeOpacity:.1}):null,d=[i?vu([0]):null,a?xu([0]):null],p=u(t,f?f(s,l):l);return"stroke"===c?Oc(h,d,p):Oc(h,p,d)}function xp(n){let e,r;for(const o of n){if(null==o)continue;if(void 0===e){e=o;continue}const n=Math.sign(t(e,o));if(n){if(void 0!==r&&n!==r)return!1;e=o,r=n}}return!0}function wp(t,n){const e=vo(t,n.value);return e&&(e.label=hi(n.value)),e}function bp(t){return function(t){if(null==t)return!1;if("function"==typeof t.reduceIndex)return!0;if("function"==typeof t.reduce&&Zo(t))return!0;if(/^p\d{2}$/i.test(t))return!0;switch(`${t}`.toLowerCase()){case"first":case"last":case"count":case"distinct":case"sum":case"proportion":case"proportion-facet":case"deviation":case"min":case"min-index":case"max":case"max-index":case"mean":case"median":case"variance":case"mode":return!0}return!1}(t)?{reduce:t}:{value:t}}function kp(t){return/^(?:distinct|count|sum|proportion)$/i.test(t)}function $p(t){return/^(?:first|last|mode)$/i.test(t)}function Mp(t){return!!t&&new nt(t).size>t.length>>1}const Ap={dot:lp,line:pp,lineX:yp,lineY:mp,areaX:Wd,areaY:jd,ruleX:vu,ruleY:xu,barX:Jd,barY:Kd,rect:bh,rectX:kh,rectY:$h,cell:np,bin:cd,binX:ld,binY:sd,group:ga,groupX:ya,groupY:ma},Lp=Object.fromEntries(Object.entries(Ap).map((([t,n])=>[n,t])));function Ep(t,n={}){let{x:e,x1:r,x2:o}=n;void 0===e&&void 0===r&&void 0===o&&(n={...n,x:e=Ao});const i={};return null!=e&&(i.x=t),null!=r&&(i.x1=t),null!=o&&(i.x2=t),Op(i,n)}function zp(t,n={}){let{y:e,y1:r,y2:o}=n;void 0===e&&void 0===r&&void 0===o&&(n={...n,y:e=Ao});const i={};return null!=e&&(i.y=t),null!=r&&(i.y1=t),null!=o&&(i.y2=t),Op(i,n)}function Op(t={},n={}){const e=ei(n),r=Object.entries(t).map((([t,e])=>{const r=ci(t,n);if(null==r)throw new Error(`missing channel: ${t}`);const[o,i]=ui(r);return{key:t,input:r,output:o,setOutput:i,map:Sp(e)}}));return{...ta(n,((t,n)=>{const o=vo(t,e),i=r.map((({input:n})=>vo(t,n))),a=r.map((({setOutput:n})=>n(new Array(t.length))));for(const t of n)for(const n of o?J(t,(t=>o[t])).values():[t])r.forEach((({map:t},e)=>t.mapIndex(n,i[e],a[e])));return{data:t,facets:n}})),...Object.fromEntries(r.map((({key:t,output:n})=>[t,n])))}}function Sp(t){if(null==t)throw new Error("missing map");if("function"==typeof t.mapIndex)return t;if("function"==typeof t.map&&Zo(t))return function(t){return console.warn("deprecated map interface; implement mapIndex instead."),{mapIndex:t.map.bind(t)}}(t);if("function"==typeof t)return Np(ai(t));switch(`${t}`.toLowerCase()){case"cumsum":return Cp;case"rank":return Np(((t,n)=>mr(t,(t=>n[t]))));case"quantile":return Np(((t,n)=>function(t,n){const e=gr(t,n)-1;return mr(t,n).map((t=>t/e))}(t,(t=>n[t]))))}throw new Error(`invalid map: ${t}`)}function Np(t){return{mapIndex(n,e,r){const o=t(n,e);if(o.length!==n.length)throw new Error("map function returned a mismatched length");for(let t=0,e=n.length;t0))throw new Error(`invalid k: ${n}`);return function(t="mean"){if("string"==typeof t){if(/^p\d{2}$/i.test(t))return Wp(Ro(t));switch(t.toLowerCase()){case"deviation":return Wp(ut);case"max":return jp(((t,n)=>N(t,(t=>n[t]))));case"mean":return Fp;case"median":return Wp(ot);case"min":return jp(((t,n)=>ct(t,(t=>n[t]))));case"mode":return jp(((t,n)=>et(t,(t=>n[t]))));case"sum":return Bp;case"variance":return Wp(rt);case"difference":return Vp;case"ratio":return Hp;case"first":return Up;case"last":return Yp}}if("function"!=typeof t)throw new Error(`invalid reduce: ${t}`);return jp(ai(t))}(e)(n,function(t="middle",n){switch(`${t}`.toLowerCase()){case"middle":return n-1>>1;case"start":return 0;case"end":return n-1}throw new Error(`invalid anchor: ${t}`)}(o,n),i)}function Wp(t){return(n,e,r)=>r?{mapIndex(r,o,i){const a=t=>null==o[t]?NaN:+o[t];let l=0;for(let t=0;tnull==o[t]?NaN:+o[t];for(let o=-e;o<0;++o)i[r[o+e]]=t(li(r,0,o+n),a);for(let o=0,l=r.length-e;or?{mapIndex(r,o,i){let a=0;for(let t=0;t=e;--o){const e=t[n[o]];if(Tr(e))return e}}function _p(t,n,e,r){for(let o=e+r;e=e;--o){let e=t[n[o]];if(null!==e&&!isNaN(e=+e))return e}}function Vp(t,n,e){return e?{mapIndex(e,r,o){for(let i=0,a=e.length-t;iat(t)+n*(ut(t)||0),strict:e,anchor:r})}const Kp={ariaLabel:"tick",fill:null,stroke:"currentColor"};class Qp extends zc{constructor(t,n,e){super(t,n,e,Kp),Vc(this,e)}render(t,n,e,r,o){return Vs("svg:g",o).call(gc,this,r,o).call(this._transform,this,n).call((i=>i.selectAll().data(t).enter().append("line").call(vc,this).attr("x1",this._x1(n,e,r)).attr("x2",this._x2(n,e,r)).attr("y1",this._y1(n,e,r)).attr("y2",this._y2(n,e,r)).call(uc,this,e).call(Kc,this,e,o))).node()}}class ty extends Qp{constructor(t,n={}){const{x:e,y:r,inset:o=0,insetTop:i=o,insetBottom:a=o}=n;super(t,{x:{value:e,scale:"x"},y:{value:r,scale:"y",type:"band",optional:!0}},n),this.insetTop=Oo(i),this.insetBottom=Oo(a)}_transform(t,n,{x:e}){t.call(bc,n,{x:e},rc,0)}_x1(t,{x:n}){return t=>n[t]}_x2(t,{x:n}){return t=>n[t]}_y1({y:t},{y:n},{marginTop:e}){const{insetTop:r}=this;return n&&t?t=>n[t]+r:e+r}_y2({y:t},{y:n},{height:e,marginBottom:r}){const{insetBottom:o}=this;return n&&t?e=>n[e]+t.bandwidth()-o:e-r-o}}class ny extends Qp{constructor(t,n={}){const{x:e,y:r,inset:o=0,insetRight:i=o,insetLeft:a=o}=n;super(t,{y:{value:r,scale:"y"},x:{value:e,scale:"x",type:"band",optional:!0}},n),this.insetRight=Oo(i),this.insetLeft=Oo(a)}_transform(t,n,{y:e}){t.call(bc,n,{y:e},0,rc)}_x1({x:t},{x:n},{marginLeft:e}){const{insetLeft:r}=this;return n&&t?t=>n[t]+r:e+r}_x2({x:t},{x:n},{width:e,marginRight:r}){const{insetRight:o}=this;return n&&t?e=>n[e]+t.bandwidth()-o:e-r-o}_y1(t,{y:n}){return t=>n[t]}_y2(t,{y:n}){return t=>n[t]}}function ey(t,{x:n=Ao,...e}={}){return new ty(t,{...e,x:n})}function ry(t,{y:n=Ao,...e}={}){return new ny(t,{...e,y:n})}function oy(t,{x:n=Ao,y:e=null,r:r,fill:o="#ccc",fillOpacity:i,stroke:a="currentColor",strokeOpacity:l,strokeWidth:s=2,sort:c,...u}={}){const f=null!=e?ma:pa;return Oc(xu(t,f({x1:ly,x2:sy},{x:n,y:e,stroke:a,strokeOpacity:l,...u})),Jd(t,f({x1:"p25",x2:"p75"},{x:n,y:e,fill:o,fillOpacity:i,...u})),ey(t,f({x:"p50"},{x:n,y:e,stroke:a,strokeOpacity:l,strokeWidth:s,sort:c,...u})),lp(t,Op({x:ay},{x:n,y:e,z:e,r:r,stroke:a,strokeOpacity:l,...u})))}function iy(t,{y:n=Ao,x:e=null,r:r,fill:o="#ccc",fillOpacity:i,stroke:a="currentColor",strokeOpacity:l,strokeWidth:s=2,sort:c,...u}={}){const f=null!=e?ya:pa;return Oc(vu(t,f({y1:ly,y2:sy},{x:e,y:n,stroke:a,strokeOpacity:l,...u})),Kd(t,f({y1:"p25",y2:"p75"},{x:e,y:n,fill:o,fillOpacity:i,...u})),ry(t,f({y:"p50"},{x:e,y:n,stroke:a,strokeOpacity:l,strokeWidth:s,sort:c,...u})),lp(t,Op({y:ay},{x:e,y:n,z:e,r:r,stroke:a,strokeOpacity:l,...u})))}function ay(t){const n=ly(t),e=sy(t);return t.map((t=>te?t:NaN))}function ly(t){const n=2.5*cy(t)-1.5*uy(t);return ct(t,(t=>t>=n?t:NaN))}function sy(t){const n=2.5*uy(t)-1.5*cy(t);return N(t,(t=>t<=n?t:NaN))}function cy(t){return W(t,.25)}function uy(t){return W(t,.75)}const fy={ariaLabel:"raster",stroke:null,pixelSize:1};function hy(t,n){const e=+t;if(isNaN(e))throw new Error(`invalid ${n}: ${t}`);return e}function dy(t,n){const e=Math.floor(t);if(isNaN(e))throw new Error(`invalid ${n}: ${t}`);return e}class py extends zc{constructor(t,n,e={},r){let{width:o,height:i,x:a,y:l,x1:s=(null==a?0:void 0),y1:c=(null==l?0:void 0),x2:u=(null==a?o:void 0),y2:f=(null==l?i:void 0),pixelSize:h=r.pixelSize,blur:d=0,interpolate:p}=e;if(null!=o&&(o=dy(o,"width")),null!=i&&(i=dy(i,"height")),null!=s&&(s=hy(s,"x1")),null!=c&&(c=hy(c,"y1")),null!=u&&(u=hy(u,"x2")),null!=f&&(f=hy(f,"y2")),null==a&&(null==s||null==u))throw new Error("missing x");if(null==l&&(null==c||null==f))throw new Error("missing y");null!=t&&null!=o&&null!=i&&(void 0===a&&null!=s&&null!=u&&(a=function(t,n,e){return{transform(r){const o=r.length,i=new Float64Array(o),a=(n-t)/e,l=t+a/2;for(let t=0;tt),{x:a,y:l}=e,{document:s}=o,[c,u,f,h]=vy(e,r,o),d=f-c,p=h-u,{pixelSize:y,width:m=Math.round(Math.abs(d)/y),height:g=Math.round(Math.abs(p)/y)}=this,v=m*g;let{fill:x,fillOpacity:w}=e,b=0;if(this.interpolate){const n=m/d,e=g/p,r=Ho(a,(t=>(t-c)*n),Float64Array),o=Ho(l,(t=>(t-u)*e),Float64Array);x&&(x=this.interpolate(t,m,g,r,o,x)),w&&(w=this.interpolate(t,m,g,r,o,w))}else null==this.data&&t&&(b=t.fi*v);const k=s.createElement("canvas");k.width=m,k.height=g;const $=k.getContext("2d"),M=$.createImageData(m,g),A=M.data;let{r:L,g:E,b:z}=Be(this.fill)??{r:0,g:0,b:0},O=255*(this.fillOpacity??1);for(let t=0;t0&&vr(M,this.blur),$.putImageData(M,0,0),Vs("svg:g",o).call(gc,this,r,o).call(bc,this,n).call((t=>t.append("image").attr("transform",`translate(${c},${u}) scale(${Math.sign(f-c)},${Math.sign(h-u)})`).attr("width",Math.abs(d)).attr("height",Math.abs(p)).attr("preserveAspectRatio","none").call(wc,"image-rendering",this.imageRendering).call(vc,this).attr("xlink:href",k.toDataURL()))).node()}}function my(t,n,e){arguments.length<3&&(e=n,n=null);let{x:r,y:o,[t]:i,...a}=e;return void 0===r&&void 0===o&&function(t){if(!bi(t))return!1;for(const n of t)if(null!=n)return"object"==typeof n&&"0"in n&&"1"in n}(n)&&(r=So,o=No,void 0===i&&(i=Co)),[n,{...a,x:r,y:o,[t]:i}]}function gy(){const[t,n]=my("fill",...arguments);return new yy(t,null==t||void 0!==n.fill||void 0!==n.fillOpacity?n:{...n,fill:Ao})}function vy({x1:t,y1:n,x2:e,y2:r},o,{projection:i}){const{width:a,height:l,marginTop:s,marginRight:c,marginBottom:u,marginLeft:f}=o;return[t&&null==i?t[0]:f,n&&null==i?n[0]:s,e&&null==i?e[0]:a-c,r&&null==i?r[0]:l-u]}function xy({x1:t,y1:n,x2:e,y2:r},o,i,a){const l={};return t&&(l.x1=t),n&&(l.y1=n),e&&(l.x2=e),r&&(l.y2=r),vy(Ga(l,o),i,a)}function wy(t,n={}){const{[t]:e}=n;if("function"!=typeof e)throw new Error(`invalid ${t}: not a function`);return na({...n,[t]:void 0},(function(r,o,i,a,l,s){const{x:c,y:u}=a;if(!c)throw new Error("missing scale: x");if(!u)throw new Error("missing scale: y");const[f,h,d,p]=xy(i,a,l,s),y=d-f,m=p-h,{pixelSize:g}=this,{width:v=Math.round(Math.abs(y)/g),height:x=Math.round(Math.abs(m)/g)}=n,w=new Array(v*x*(o?o.length:1)),b=y/v,k=m/x;let $=0;for(const t of o??[void 0])for(let n=.5;n=n||o[l]<0||o[l]>=e||(a[Math.floor(o[l])*n+Math.floor(r[l])]=i[l]);return a}function ky({random:t=Z(42)}={}){return(n,e,r,o,i,a)=>{const{points:l,triangles:s,hull:c}=xr.from(n,(t=>o[t]),(t=>i[t])),u=new a.constructor(e*r).fill(NaN),f=new Uint8Array(e*r),h=function(t,n){return Ei(t)||Mi(t)?Ey:function(t){return(n,e,r,o,i,a,l,s)=>{const c=t(l,s);return c=e||n<0||n>=r)continue;const o=t+.5,i=n+.5,a=Math.sign($),l=(g-v)*(o-y)+(i-v)*(y-p);if(l*a<0)continue;const s=(v-m)*(o-y)+(i-v)*(d-y);if(s*a<0)continue;const c=$-(l+s);if(c*a<0)continue;const x=t+e*n;u[x]=h(M,l/$,A,s/$,L,c/$,t,n),f[x]=1}}return function(t,n,e,r,o,i,a,l,s,c){e=Float64Array.from(l,(t=>e[s[t]])),r=Float64Array.from(l,(t=>r[s[t]])),o=Array.from(l,(t=>o[s[t]]));const u=e.length,f=Array.from({length:u},((t,n)=>function(t,n,e){const r=n.length,o=n.at(t-2),i=e.at(t-2),a=n.at(t-1),l=e.at(t-1),s=n[t],c=e[t],u=n.at(t+1-r),f=e.at(t+1-r),h=a-s,d=l-c,p=o-a,y=i-l,m=s-u,g=c-f,v=Math.hypot(h,d),x=Math.hypot(p,y),w=Math.hypot(m,g);return(t,n)=>{const e=t-a,r=n-l,o=t-s,i=n-c;return My(e,r,o,i)>-1e-6&&My(e,r,h,d)*x-My(e,r,p,y)*v>-1e-6&&My(o,i,m,g)*v-My(o,i,h,d)*w<=0}}(n,e,r)));let h=0;for(let l=0;l0&&c>0?s/(s+c):+(s>c)}function My(t,n,e,r){return t*r-e*n}function Ay(t,n,e,r,o,i){const a=new i.constructor(n*e),l=xr.from(t,(t=>r[t]),(t=>o[t]));let s,c;for(let r=.5,o=0;r{const c=new s.constructor(o*i),u=xr.from(r,(t=>a[t]),(t=>l[t]));let f,h,d;for(let p=.5,y=0;pn&&vt.map((t=>t.value)),label:hi(e)};for(const n in o)"value"===r[n]&&(r[n]=t)}if(null==t){if(null==e)throw new Error("missing contour value");r=wy("value",{value:e,...r}),e=null}else{let{interpolate:t}=r;void 0===e&&(e=Ao),void 0===t&&(r.interpolate="nearest")}super(t,{value:{value:e,optional:!0}},function({thresholds:t,interval:n,...e}){return t=gd(t,n,sr),na(e,(function(n,e,r,o,i,a){const[l,s,c,u]=xy(r,o,i,a),f=c-l,h=u-s,{pixelSize:d,width:p=Math.round(Math.abs(f)/d),height:y=Math.round(Math.abs(h)/d)}=this,m=p/f,g=y/h,v=r.value.value,x=[];if(this.interpolate){const{x:t,y:n}=qs(r,o,a),i=Ho(t,(t=>(t-l)*m),Float64Array),c=Ho(n,(t=>(t-s)*g),Float64Array),u=[r.x,r.y,r.value],f=[i,c,v];for(const t of e){const n=this.filter(t,u,f);x.push(this.interpolate(n,p,y,i,c,v))}}else if(e){const t=p*y,n=e.length;for(let e=0;e0)for(const t of x)wr({data:t,width:p,height:y},this.blur);const w=function(t,n,e,r){if("function"==typeof t?.range)return t.range(t.floor(e),r);"function"==typeof t&&(t=t(n,e,r));if("number"!=typeof t)return Vo(t);const o=_n(...kr(e,r,t),t);for(;o[o.length-1]>=r;)o.pop();for(;o[1]ct(t,Ny))),N(t,(t=>N(t,Ny)))]}(x));if(null===w)throw new Error(`unsupported thresholds: ${t}`);const{contour:b}=br().size([p,y]).smooth(this.smooth),k=[],$=[];for(const t of x)$.push(I(k.length,k.push(...Ho(w,(n=>b(t,n))))));for(const{coordinates:t}of k)for(const n of t)for(const t of n)for(const n of t)n[0]=n[0]/m+l,n[1]=n[1]/g+s;return{data:k,facets:$,channels:Xa(this.contourChannels,k)}}))}(r),zy);const i={geometry:{value:Ao}};for(const t in this.channels){const n=this.channels[t],{scale:e}=n;"x"!==e&&"y"!==e&&"value"!==t&&(i[t]=n,delete this.channels[t])}this.contourChannels=i,this.smooth=!!n}filter(t,{x:n,y:e,value:r,...o},i){return super.filter(t,o,i)}render(t,n,e,r,o){const{geometry:i}=e,a=pe();return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,n).call((n=>{n.selectAll().data(t).enter().append("path").call(vc,this).attr("d",(t=>a(i[t]))).call(uc,this,e)})).node()}}function Sy(){return new Oy(...my("value",...arguments))}function Ny(t){return isFinite(t)?t:NaN}function Cy(t,n){return Iy(jc,t,n)}function Ty(t,n={}){return Iy(Bc,t,n)}function Ry(t,n={}){return Iy(Fc,t,n)}function Iy(t,n,e={}){const{x:r,y:o,maxRadius:i}=e,a=t({px:r,py:o,maxRadius:i}),l=[];null!=r&&l.push(vu(n,By("x",{...a,inset:-6},e))),null!=o&&l.push(xu(n,By("y",{...a,inset:-6},e))),null!=r&&l.push(Eu(n,Fy("x",{...a,dy:9,frameAnchor:"bottom",lineAnchor:"top"},e))),null!=o&&l.push(Eu(n,Fy("y",{...a,dx:-9,frameAnchor:"left",textAnchor:"end"},e)));for(const t of l)t.ariaLabel=`crosshair ${t.ariaLabel}`;return Oc(...l)}function Wy(t,{channels:n,...e},{facet:r,facetAnchor:o,fx:i,fy:a,[t]:l,channels:s,transform:c,initializer:u}){return{...e,facet:r,facetAnchor:o,fx:i,fy:a,[t]:l,channels:{...n,...s},transform:c,initializer:jy(t,u)}}function jy(t,n){return null==n?n:function(e,r,{x:o,y:i,px:a,py:l,...s},...c){const{channels:{x:u,y:f,...h}={},...d}=n.call(this,e,r,{...s,x:a,y:l},...c);return{channels:{...h,...u&&{px:u,..."x"===t&&{x:u}},...f&&{py:f,..."y"===t&&{y:f}}},...d}}}function By(t,n,e){const{color:r="currentColor",opacity:o=.2,ruleStroke:i=r,ruleStrokeOpacity:a=o,ruleStrokeWidth:l}=e;return{...Wy(t,n,e),stroke:i,strokeOpacity:a,strokeWidth:l}}function Fy(t,n,e){const{color:r="currentColor",textFill:o=r,textFillOpacity:i,textStroke:a="var(--plot-background)",textStrokeOpacity:l,textStrokeWidth:s=5}=e;return{...Wy(t,n,Dy(t,e)),fill:o,fillOpacity:i,stroke:a,strokeOpacity:l,strokeWidth:s}}function Dy(t,n){return na(n,((n,e,r)=>({channels:{text:{value:ol(r,t)?.value}}})))}const qy={ariaLabel:"delaunay link",fill:"none",stroke:"currentColor",strokeMiterlimit:1},_y={ariaLabel:"delaunay mesh",fill:null,stroke:"currentColor",strokeOpacity:.2},Py={ariaLabel:"hull",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:1},Vy={ariaLabel:"voronoi",fill:"none",stroke:"currentColor",strokeMiterlimit:1},Hy={ariaLabel:"voronoi mesh",fill:null,stroke:"currentColor",strokeOpacity:.2};class Uy extends zc{constructor(t,n={}){const{x:e,y:r,z:o,curve:i,tension:a}=n;super(t,{x:{value:e,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},z:{value:o,optional:!0}},n,qy),this.curve=od(i,a),Vc(this,n)}render(t,n,e,r,o){const{x:i,y:a}=n,{x:l,y:s,z:c}=e,{curve:u}=this,[f,h]=Ec(this,r),d=l?t=>l[t]:To(f),p=s?t=>s[t]:To(h),y=this;function m(t){let n=-1;const r=[],i={};for(const t in e)i[t]=[];const a=[],l=[],s=[],c=[];function f(o,u){o=t[o],u=t[u],r.push(++n),a[n]=d(o),s[n]=p(o),l[n]=d(u),c[n]=p(u);for(const t in e)i[t].push(e[t][u])}const{halfedges:h,hull:m,triangles:g}=xr.from(t,d,p);for(let t=0;tt&&f(g[t],g[n])}for(let t=0;t{const n=je(),e=u(n);return e.lineStart(),e.point(a[t],s[t]),e.point(l[t],c[t]),e.lineEnd(),n})).call(uc,y,i).call(Kc,y,i,o)}return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,{x:l&&i,y:s&&a}).call(c?n=>n.selectAll().data(J(t,(t=>c[t])).values()).enter().append("g").each(m):n=>n.datum(t).each(m)).node()}}class Yy extends zc{constructor(t,n={},e,r=(({z:t})=>t)){const{x:o,y:i}=n;super(t,{x:{value:o,scale:"x",optional:!0},y:{value:i,scale:"y",optional:!0},z:{value:r(n),optional:!0}},n,e)}render(t,n,e,r,o){const{x:i,y:a}=n,{x:l,y:s,z:c}=e,[u,f]=Ec(this,r),h=l?t=>l[t]:To(u),d=s?t=>s[t]:To(f),p=this;function y(t){const n=xr.from(t,h,d);Ne(this).append("path").datum(t[0]).call(vc,p).attr("d",p._render(n,r)).call(uc,p,e)}return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,{x:l&&i,y:s&&a}).call(c?n=>n.selectAll().data(J(t,(t=>c[t])).values()).enter().append("g").each(y):n=>n.datum(t).each(y)).node()}}class Xy extends Yy{constructor(t,n={}){super(t,n,_y),this.fill="none"}_render(t){return t.render()}}class Gy extends Yy{constructor(t,n={}){super(t,n,Py,ei)}_render(t){return t.renderHull()}}class Zy extends zc{constructor(t,n={}){const{x:e,y:r,z:o}=n;super(t,{x:{value:e,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},z:{value:o,optional:!0}},na(n,(function(t,n,e,r,o,i){let{x:a,y:l,z:s}=e;({x:a,y:l}=qs(e,r,i)),s=s?.value;const c=new Array((a??l).length).fill(null),[u,f]=Ec(this,o),h=a?t=>a[t]:To(u),d=l?t=>l[t]:To(f);for(let t of n){a&&(t=t.filter((t=>Tr(h(t))))),l&&(t=t.filter((t=>Tr(d(t)))));for(const[,n]of $a(t,s)){const t=Ky(xr.from(n,h,d),o);for(let e=0,r=n.length;e{n.selectAll().data(t).enter().append("path").call(vc,this).attr("d",(t=>c[t])).call(uc,this,e)})).node()}}class Jy extends Yy{constructor(t,n){super(t,n,Hy),this.fill="none"}_render(t,n){return Ky(t,n).render()}}function Ky(t,n){const{width:e,height:r,marginTop:o,marginRight:i,marginBottom:a,marginLeft:l}=n;return t.voronoi([l,o,e-i,r-a])}function Qy(t,n,{x:e,y:r,...o}={}){return[e,r]=ni(e,r),new t(n,{...o,x:e,y:r})}function tm(t,n){return Qy(Uy,t,n)}function nm(t,n){return Qy(Xy,t,n)}function em(t,n){return Qy(Gy,t,n)}function rm(t,{x:n,y:e,initializer:r,...o}={}){return Qy(Zy,t,{...ta({...o,x:n,y:e},Uf),initializer:r})}function om(t,n){return Qy(Jy,t,n)}const im={ariaLabel:"density",fill:"none",stroke:"currentColor",strokeMiterlimit:1};class am extends zc{constructor(t,{x:n,y:e,z:r,weight:o,fill:i,stroke:a,...l}={}){const s=cm(i)&&(i="currentColor",!0),c=cm(a)&&(a="currentColor",!0);super(t,{x:{value:n,scale:"x",optional:!0},y:{value:e,scale:"y",optional:!0},z:{value:ei({z:r,fill:i,stroke:a}),optional:!0},weight:{value:o,optional:!0}},function(t,n,e){const r=100;let{bandwidth:o,thresholds:i}=t;return o=void 0===o?20:+o,i=void 0===i?20:"function"==typeof i?.[Symbol.iterator]?Io(i):+i,na(t,(function(t,a,l,s,c,u){const f=l.weight?Io(l.weight.value):null,h=l.z?.value,{z:d}=this,[p,y]=Ec(this,c),{width:m,height:g}=c,{x:v,y:x}=qs(l,s,u),w=Object.fromEntries(Object.entries(l).filter((([t])=>!sm.has(t))).map((([t,n])=>[t,{...n,value:[]}]))),b=n&&[],k=e&&[],$=$r().x(v?t=>v[t]:p).y(x?t=>x[t]:y).weight(f?t=>f[t]:1).size([m,g]).bandwidth(o),M=[];for(const t of a){const n=[];M.push(n);for(const e of h?hc(t,h,d):[t]){const t=$.contours(e);n.push([e,t])}}let A=i;if(!(A instanceof fo)){let t=0;for(const n of M)for(const[,e]of n){const n=e.max;n>t&&(t=n)}A=Float64Array.from({length:i-1},((n,e)=>t*r*(e+1)/i))}const L=[],E=[];for(const t of M){const n=[];L.push(n);for(const[e,o]of t)for(const t of A){n.push(E.length),E.push(o(t/r)),b&&b.push(t),k&&k.push(t);for(const t in w)w[t].value.push(l[t].value[e[0]])}}return b&&b.push(0),k&&k.push(0),{data:t,facets:L,channels:{...w,...b&&{fill:{value:b,scale:"color"}},...k&&{stroke:{value:k,scale:"color"}},contours:{value:E}}}}))}({...l,fill:i,stroke:a},s,c),im),s&&(this.fill=void 0),c&&(this.stroke=void 0),this.z=r}filter(t){return t}render(t,n,e,r,o){const{contours:i}=e,a=pe();return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,{}).call((n=>n.selectAll().data(t).enter().append("path").call(vc,this).call(uc,this,e).attr("d",(t=>a(i[t]))))).node()}}function lm(t,{x:n,y:e,...r}={}){return[n,e]=ni(n,e),new am(t,{...r,x:n,y:e})}const sm=new Set(["x","y","z","weight"]);function cm(t){return/^density$/i.test(t)}function um(t,n){return hm("x",t,n)}function fm(t,n){return hm("y",t,n)}function hm(t,n,{x1:e,x2:r,y1:o,y2:i,x:a=(void 0===e&&void 0===r?"y"===t?Mo:Ao:void 0),y:l=(void 0===o&&void 0===i?"x"===t?Mo:Ao:void 0),fill:s,positiveFill:c="#3ca951",negativeFill:u="#4269d0",fillOpacity:f=1,positiveFillOpacity:h=f,negativeFillOpacity:d=f,stroke:p,strokeOpacity:y,z:m=Fo(p)[0],clip:g,tip:v,render:x,...w}={}){return[e,r]=dm(a,e,r),[o,i]=dm(l,o,i),e===r&&o===i&&("y"===t?o=pm(0):e=pm(0)),({tip:v}=Cc({tip:v},"y"===t?"x":"y")),Oc(Ci(c)?null:Object.assign(Id(n,{x1:e,x2:r,y1:o,y2:i,z:m,fill:c,fillOpacity:h,render:Sc(x,ym(t,!0)),clip:g,...w}),{ariaLabel:"positive difference"}),Ci(u)?null:Object.assign(Id(n,{x1:e,x2:r,y1:o,y2:i,z:m,fill:u,fillOpacity:d,render:Sc(x,ym(t,!1)),clip:g,...w}),{ariaLabel:"negative difference"}),pp(n,{x:r,y:i,z:m,stroke:p,strokeOpacity:y,tip:v,clip:!0,...w}))}function dm(t,n,e){return void 0===n&&void 0===e?n=e=pm(t):void 0===n?(e=pm(e),n=void 0===t?e:pm(t)):void 0===e?(n=pm(n),e=void 0===t?n:pm(t)):(n=pm(n),e=pm(e)),[n,e]}function pm(t){let n;const{value:e,label:r=hi(e)}=wi(t);return{transform:t=>n||(n=vo(t,e)),label:r}}function ym(t,n){const e="x"===t?"y":"x",r=`${e}1`,o=`${e}2`,i=`${t}1`,a=`${t}2`;return(e,l,s,c,u,f)=>{const{[r]:h,[o]:d}=s,p=new Float32Array(h.length),y=new Float32Array(d.length),m=c["y"===t?"height":"width"];(n===Jl(l[t])<0?p:y).fill(m);const g=f(e,l,{...s,[o]:h,[a]:y},c,u),v=f(e,l,{...s,[r]:d,[i]:p},c,u),x=g.querySelector("g")??g,w=v.querySelector("g")??v;for(let t=0;x.firstChild;t+=2){const n=ac(),e=Vs("svg:clipPath",u).attr("id",n).node();e.appendChild(x.firstChild),w.childNodes[t].setAttribute("clip-path",`url(#${n})`),w.insertBefore(e,w.childNodes[t])}return v}}function mm({geometry:t=Ao,...n}={}){const e=Us((n=>vo(n,t)));return na({...n,x:null,y:null,geometry:{transform:e}},((t,n,r,o,i,{projection:a})=>{const l=e(t),s=l.length,c=new Float64Array(s),u=new Float64Array(s),f=pe(a);for(let t=0;tvo(n,t))),r=Us((t=>vo(e(t),Mr)));return{...n,x:{transform:t=>Float64Array.from(r(t),(([t])=>t))},y:{transform:t=>Float64Array.from(r(t),(([,t])=>t))},geometry:{transform:e}}}const vm={ariaLabel:"geo",fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class xm extends zc{constructor(t,n={}){const[e,r]=Do(n.r,3);super(t,{x:{value:n.tip?n.x:null,scale:"x",optional:!0},y:{value:n.tip?n.y:null,scale:"y",optional:!0},r:{value:e,scale:"r",filter:Br,optional:!0},geometry:{value:n.geometry,scale:"projection"}},ip(n),vm),this.r=r}render(t,n,e,r,o){const{geometry:i,r:a}=e,l=pe(o.projection??function({x:t,y:n}){if(t||n)return t??=t=>t,n??=t=>t,de({point(e,r){this.stream.point(t(e),n(r))}})}(n)),{r:s}=this;return Fr(s)?t=[]:void 0!==s&&l.pointRadius(s),Vs("svg:g",o).call(gc,this,r,o).call(bc,this,n).call((n=>{n.selectAll().data(t).enter().append("path").call(vc,this).attr("d",a?t=>l.pointRadius(a[t])(i[t]):t=>l(i[t])).call(uc,this,e)})).node()}}function wm(t,n={}){return n.tip&&void 0===n.x&&void 0===n.y?n=mm(n):void 0===n.geometry&&(n={...n,geometry:Ao}),new xm(t,n)}function bm({strokeWidth:t=1.5,...n}={}){return wm({type:"Sphere"},{strokeWidth:t,...n})}function km({strokeOpacity:t=.1,...n}={}){return wm(Ar(),{strokeOpacity:t,...n})}const $m=.5,Mm=0;function Am(t={fill:"count"},{binWidth:n,...e}={}){const{z:r}=e;return n=void 0===n?20:Oo(n),xa(t=La(t,e),"fill")&&(e.channels={...e.channels,fill:{value:[]}}),void 0===e.symbol&&(e.symbol="hexagon"),void 0!==e.r||xa(t,"r")||(e.r=n/2),na(e,((e,o,i,a,l,s)=>{let{x:c,y:u,z:f,fill:h,stroke:d,symbol:p}=i;if(void 0===c)throw new Error("missing channel: x");if(void 0===u)throw new Error("missing channel: y");({x:c,y:u}=qs(i,a,s)),f=f?f.value:vo(e,r),h=h?.value,d=d?.value,p=p?.value;const y=Na(t,{z:f,fill:h,stroke:d,symbol:p}),m=f&&[],g=h&&[],v=d&&[],x=p&&[],w=[],b=[],k=[];let $=-1;for(const n of t)n.initialize(e);for(const r of o){const o=[];for(const n of t)n.scope("facet",r);for(const[i,a]of $a(r,y))for(const{index:r,extent:l}of Lm(e,a,c,u,n)){o.push(++$),b.push(l.x),k.push(l.y),f&&m.push(y===f?i:f[r[0]]),h&&g.push(y===h?i:h[r[0]]),d&&v.push(y===d?i:d[r[0]]),p&&x.push(y===p?i:p[r[0]]);for(const n of t)n.reduce(r,l)}w.push(o)}const M=i.x.scale,A=i.y.scale;return{data:e,facets:w,channels:{x:{value:b,source:a[M]?{value:Ho(b,a[M].invert),scale:M}:null},y:{value:k,source:a[A]?{value:Ho(k,a[A].invert),scale:A}:null},...f&&{z:{value:m}},...h&&{fill:{value:g,scale:"auto"}},...d&&{stroke:{value:v,scale:"auto"}},...p&&{symbol:{value:x,scale:"auto"}},...Object.fromEntries(t.map((({name:t,output:e})=>[t,{scale:"auto",label:e.label,radius:"r"===t?n/2:void 0,value:e.transform()}])))}}}))}function Lm(t,n,e,r,o){const i=o*(1.5/Xi),a=new Map;for(const l of n){let n=e[l],s=r[l];if(isNaN(n)||isNaN(s))continue;let c=Math.round(s=(s-Mm)/i),u=Math.round(n=(n-$m)/o-(1&c)/2),f=s-c;if(3*Math.abs(f)>1){let t=n-u,e=u+(no*o+i*i&&(u=e+(1&c?1:-1)/2,c=r)}const h=`${u},${c}`;let d=a.get(h);void 0===d&&(d={index:[],extent:{data:t,x:(u+(1&c)/2)*o+$m,y:c*i+Mm}},a.set(h,d)),d.index.push(l)}return a.values()}const Em={ariaLabel:"hexgrid",fill:"none",stroke:"currentColor",strokeOpacity:.1};function zm(t){return new Om(t)}class Om extends zc{constructor({binWidth:t=20,clip:n=!0,...e}={}){super(ko,void 0,{clip:n,...e},Em),this.binWidth=Oo(t)}render(t,n,e,r,o){const{binWidth:i}=this,{marginTop:a,marginRight:l,marginBottom:s,marginLeft:c,width:u,height:f}=r,h=c-$m,d=u-l-$m,p=a-Mm,y=f-s-Mm,m=i/2,g=m*Gi,v=g/2,x=2*m,w=1.5*g,b=Math.floor(h/x),k=Math.ceil(d/x),$=Math.floor((p+v)/w),M=Math.ceil((y-v)/w)+1,A=`m0,${Sm(-g)}l${Sm(m)},${Sm(v)}v${Sm(g)}l${Sm(-m)},${Sm(v)}`;let L=A;for(let t=$;tt.append("path").call(vc,this).call(uc,this,e).attr("d",L))).node()}}function Sm(t){return Math.round(1e3*t)/1e3}const Nm={ariaLabel:"image",fill:null,stroke:null};class Cm extends zc{constructor(t,n={}){let{x:e,y:r,r:o,width:i,height:a,rotate:l,src:s,preserveAspectRatio:c,crossOrigin:u,frameAnchor:f,imageRendering:h}=n;null==o&&(o=void 0),void 0===o&&void 0===i&&void 0===a?i=a=16:void 0===i&&void 0!==a?i=a:void 0===a&&void 0!==i&&(a=i);const[d,p]="string"==typeof(y=s)&&(function(t){return/^\.*\//.test(t)}(y)||function(t){return/^(blob|data|file|http|https):/i.test(t)}(y))?[void 0,y]:[y,void 0];var y;const[m,g]=Do(o),[v,x]=Do(i,void 0!==g?2*g:void 0),[w,b]=Do(a,void 0!==g?2*g:void 0),[k,$]=Do(l,0);super(t,{x:{value:e,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},r:{value:m,scale:"r",filter:Br,optional:!0},width:{value:v,filter:Br,optional:!0},height:{value:w,filter:Br,optional:!0},rotate:{value:k,optional:!0},src:{value:d,optional:!0}},ip(n),Nm),this.src=p,this.width=x,this.rotate=$,this.height=b,this.r=g,this.preserveAspectRatio=kc(c,"xMidYMid"),this.crossOrigin=zo(u),this.frameAnchor=Ii(f),this.imageRendering=kc(h,"auto")}render(t,n,e,r,o){const{x:i,y:a}=n,{x:l,y:s,width:c,height:u,r:f,rotate:h,src:d}=e,{r:p,width:y,height:m,rotate:g}=this,[v,x]=Ec(this,r);return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,{x:l&&i,y:s&&a}).call((n=>n.selectAll().data(t).enter().append("image").call(vc,this).attr("x",Tm(l,c,f,v,y,p)).attr("y",Tm(s,u,f,x,m,p)).attr("width",c?t=>c[t]:void 0!==y?y:f?t=>2*f[t]:2*p).attr("height",u?t=>u[t]:void 0!==m?m:f?t=>2*f[t]:2*p).attr("transform",h?t=>`rotate(${h[t]})`:g?`rotate(${g})`:null).attr("transform-origin",h||g?bu`${l?t=>l[t]:v}px ${s?t=>s[t]:x}px`:null).call(wc,"href",d?t=>d[t]:this.src).call(wc,"preserveAspectRatio",this.preserveAspectRatio).call(wc,"crossorigin",this.crossOrigin).call(wc,"image-rendering",this.imageRendering).call(wc,"clip-path",f?t=>`circle(${f[t]}px)`:void 0!==p?`circle(${p}px)`:null).call(uc,this,e))).node()}}function Tm(t,n,e,r,o,i){return n&&t?e=>t[e]-n[e]/2:n?t=>r-n[t]/2:t&&void 0!==o?n=>t[n]-o/2:void 0!==o?r-o/2:e&&t?n=>t[n]-e[n]:e?t=>r-e[t]:t?n=>t[n]-i:r-i}function Rm(t,{x:n,y:e,...r}={}){return void 0===r.frameAnchor&&([n,e]=ni(n,e)),new Cm(t,{...r,x:n,y:e})}function Im(t,n,e){var r=0===t||1===t?0:Math.exp(jm(n+e)-jm(n)-jm(e)+n*Math.log(t)+e*Math.log(1-t));return!(t<0||t>1)&&(t<(n+1)/(n+e+2)?r*Wm(t,n,e)/n:1-r*Wm(1-t,e,n)/e)}function Wm(t,n,e){var r,o,i,a,l=1e-30,s=1,c=n+e,u=n+1,f=n-1,h=1,d=1-c*t/u;for(Math.abs(d)=1)return 1;for(n>=1&&e>=1?(i=t<.5?t:1-t,s=(2.30753+.27061*(a=Math.sqrt(-2*Math.log(i))))/(1+a*(.99229+.04481*a))-a,t<.5&&(s=-s),c=(s*s-3)/6,u=2/(1/(2*n-1)+1/(2*e-1)),f=s*Math.sqrt(c+u)/u-(1/(2*e-1)-1/(2*n-1))*(c+5/6-2/(3*u)),s=n/(n+e*Math.exp(2*f))):(r=Math.log(n/(n+e)),o=Math.log(e/(n+e)),s=t<(a=Math.exp(n*r)/n)/(f=a+(l=Math.exp(e*o)/e))?Math.pow(n*f*t,1/n):1-Math.pow(e*f*(1-t),1/e)),h=-jm(n)-jm(e)+jm(n+e);y<10;y++){if(0===s||1===s)return s;if((s-=a=(l=(Im(s,n,e)-t)/(a=Math.exp(d*Math.log(s)+p*Math.log(1-s)+h)))/(1-.5*Math.min(1,l*(d/s-p/(1-s)))))<=0&&(s=.5*(s+a)),s>=1&&(s=.5*(s+a+1)),Math.abs(a)<1e-8*s&&y>0)break}return s}(2*Math.min(t,1-t),.5*n,.5);return e=Math.sqrt(n*(1-e)/e),t>.5?e:-e}const Fm={ariaLabel:"linear-regression",fill:"currentColor",fillOpacity:.1,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class Dm extends zc{constructor(t,n={}){const{x:e,y:r,z:o,ci:i=.95,precision:a=4}=n;if(super(t,{x:{value:e,scale:"x"},y:{value:r,scale:"y"},z:{value:ei(n),optional:!0}},n,Fm),this.z=o,this.ci=+i,this.precision=+a,!(0<=this.ci&&this.ci<1))throw new Error(`invalid ci; not in [0, 1): ${i}`);if(!(this.precision>0))throw new Error(`invalid precision: ${a}`)}render(t,n,e,r,o){const{x:i,y:a,z:l}=e,{ci:s}=this;return Vs("svg:g",o).call(gc,this,r,o).call(bc,this,n).call((n=>n.selectAll().data(l?hc(t,l,this.z):[t]).enter().call((t=>t.append("path").attr("fill","none").call(vc,this).call(fc,this,{...e,fill:null,fillOpacity:null}).attr("d",(t=>this._renderLine(t,i,a))).call(s&&!Ti(this.fill)?t=>t.select(qm).attr("stroke","none").call(vc,this).call(fc,this,{...e,stroke:null,strokeOpacity:null,strokeWidth:null}).attr("d",(t=>this._renderBand(t,i,a))):()=>{}))))).node()}}function qm(){return this.parentNode.insertBefore(this.ownerDocument.createElementNS(Te.svg,"path"),this)}class _m extends Dm{constructor(t,n){super(t,n)}_renderBand(t,n,e){const{ci:r,precision:o}=this,[i,a]=qn(t,(t=>e[t])),l=Um(t,e,n),s=Ym(t,e,n,(1-r)/2,l);return pr().y((t=>t)).x0((t=>s(t,-1))).x1((t=>s(t,1)))(I(i,a-o/2,o).concat(a))}_renderLine(t,n,e){const[r,o]=qn(t,(t=>e[t])),i=Um(t,e,n);return`M${i(r)},${r}L${i(o)},${o}`}}class Pm extends Dm{constructor(t,n){super(t,n)}_renderBand(t,n,e){const{ci:r,precision:o}=this,[i,a]=qn(t,(t=>n[t])),l=Um(t,n,e),s=Ym(t,n,e,(1-r)/2,l);return pr().x((t=>t)).y0((t=>s(t,-1))).y1((t=>s(t,1)))(I(i,a-o/2,o).concat(a))}_renderLine(t,n,e){const[r,o]=qn(t,(t=>n[t])),i=Um(t,n,e);return`M${r},${i(r)}L${o},${i(o)}`}}function Vm(t,{y:n=Mo,x:e=Ao,stroke:r,fill:o=(Ci(r)?"currentColor":r),...i}={}){return new _m(t,hd({...i,x:e,y:n,fill:o,stroke:r}))}function Hm(t,{x:n=Mo,y:e=Ao,stroke:r,fill:o=(Ci(r)?"currentColor":r),...i}={}){return new Pm(t,fd({...i,x:n,y:e,fill:o,stroke:r}))}function Um(t,n,e){let r=0,o=0,i=0,a=0;for(const l of t){const t=n[l],s=e[l];r+=t,o+=s,i+=t*s,a+=t*t}const l=t.length,s=(l*i-r*o)/(l*a-r*r),c=(o-s*r)/l;return t=>s*t+c}function Ym(t,n,e,r,o){const i=tt(t,(t=>n[t]))/t.length;let a=0,l=0;for(const r of t)a+=(n[r]-i)**2,l+=(e[r]-o(n[r]))**2;const s=Math.sqrt(l/(t.length-2)),c=Bm(r,t.length-2);return(n,e)=>{const r=o(n),l=s*Math.sqrt(1/t.length+(n-i)**2/a);return r+e*c*l}}function Xm({path:t=Ao,delimiter:n,frameAnchor:e,treeLayout:r=Er,treeSort:o,treeSeparation:i,treeAnchor:a,treeFilter:l,...s}={}){a=Zm(a),o=Qm(o),null!=l&&(l=ig(l)),void 0===e&&(e=a.frameAnchor);const c=ng(n),u=vg(s,ig),[f,h]=ui(),[d,p]=ui();return{x:f,y:d,frameAnchor:e,...ta(s,((n,e)=>{const s=c(vo(n,t)),f=h([]),d=p([]);let y=-1;const m=[],g=[],v=Lr().path((t=>s[t])),x=po(n)?t=>t.data=n[t.data]:t=>t.data=n.get(t.data),w=r();w.nodeSize&&w.nodeSize([1,1]),w.separation&&void 0!==i&&w.separation(i??Lo);for(const t of u)t[gg]=t[yg]([]);for(const t of e){const n=[],e=v(t.filter((t=>null!=s[t]))).each(x);null!=o&&e.sort(o),w(e);for(const t of e.descendants())if(null==l||l(t)){n.push(++y),m[y]=t.data,a.position(t,y,f,d);for(const n of u)n[gg][y]=n[mg](t)}g.push(n)}return{data:m,facets:g}})),...Object.fromEntries(u)}}function Gm({path:t=Ao,delimiter:n,curve:e="bump-x",stroke:r="#555",strokeWidth:o=1.5,strokeOpacity:i=.5,treeLayout:a=Er,treeSort:l,treeSeparation:s,treeAnchor:c,treeFilter:u,...f}={}){c=Zm(c),l=Qm(l),null!=u&&(u=ag(u)),f={curve:e,stroke:r,strokeWidth:o,strokeOpacity:i,...f};const h=ng(n),d=vg(f,ag),[p,y]=ui(),[m,g]=ui(),[v,x]=ui(),[w,b]=ui();return{x1:p,x2:m,y1:v,y2:w,...ta(f,((n,e)=>{const r=h(vo(n,t)),o=y([]),i=g([]),f=x([]),p=b([]);let m=-1;const v=[],w=[],k=Lr().path((t=>r[t])),$=a();$.nodeSize&&$.nodeSize([1,1]),$.separation&&void 0!==s&&$.separation(s??Lo);for(const t of d)t[gg]=t[yg]([]);for(const t of e){const e=[],a=k(t.filter((t=>null!=r[t]))).each((t=>t.data=n[t.data]));null!=l&&a.sort(l),$(a);for(const{source:t,target:n}of a.links())if(null==u||u(n,t)){e.push(++m),v[m]=n.data,c.position(t,m,o,f),c.position(n,m,i,p);for(const e of d)e[gg][m]=e[mg](n,t)}w.push(e)}return{data:v,facets:w}})),...Object.fromEntries(d)}}function Zm(t="left"){switch(`${t}`.trim().toLowerCase()){case"left":return Jm;case"right":return Km}throw new Error(`invalid tree anchor: ${t}`)}const Jm={frameAnchor:"left",dx:6,position({x:t,y:n},e,r,o){r[e]=n,o[e]=-t}},Km={frameAnchor:"right",dx:-6,position({x:t,y:n},e,r,o){r[e]=-n,o[e]=-t}};function Qm(t){return null==t||"function"==typeof t?t:`${t}`.trim().toLowerCase().startsWith("node:")?tg(ig(t)):tg(function(t){return n=>n.data?.[t]}(t))}function tg(t){return(n,e)=>Rr(t(n),t(e))}function ng(t="/"){if("/"===(t=`${t}`))return t=>t;if(1!==t.length)throw new Error("delimiter must be exactly one character");const n=t.charCodeAt(0);return t=>t.map((t=>function(t,n){if(n===eg)throw new Error("delimiter cannot be backslash");let e=!1;for(let r=0,o=t.length;r0&&!pg(t,n););return function(t){let n=!1;for(let e=0,r=t.length;enull==e?void 0:t(e)}function pg(t,n){if("/"===t[n]){let e=0;for(;n>0&&"\\"===t[--n];)++e;if(0==(1&e))return!0}return!1}const yg=2,mg=3,gg=4;function vg(t,n){const e=[];for(const r in t){const o=t[r],i=n(o);void 0!==i&&e.push([r,...ui(o),i])}return e}function xg(t,{fill:n,stroke:e,strokeWidth:r,strokeOpacity:o,strokeLinejoin:i,strokeLinecap:a,strokeMiterlimit:l,strokeDasharray:s,strokeDashoffset:c,marker:u,markerStart:f=u,markerEnd:h=u,dot:d=Ci(f)&&Ci(h),text:p="node:name",textStroke:y="var(--plot-background)",title:m="node:path",dx:g,dy:v,textAnchor:x,treeLayout:w=Er,textLayout:b=(w===Er||w===zr?"mirrored":"normal"),tip:k,...$}={}){if(void 0===g&&(g=Zm($.treeAnchor).dx),void 0!==x)throw new Error("textAnchor is not a configurable tree option");function M(e){return Eu(t,Xm({treeLayout:w,text:p,fill:void 0===n?"currentColor":n,stroke:y,dx:g,dy:v,title:m,...e,...$}))}return b=_o(b,"textLayout",["mirrored","normal"]),Oc(Dd(t,Gm({treeLayout:w,markerStart:f,markerEnd:h,stroke:void 0!==e?e:void 0===n?"node:internal":n,strokeWidth:r,strokeOpacity:o,strokeLinejoin:i,strokeLinecap:a,strokeMiterlimit:l,strokeDasharray:s,strokeDashoffset:c,...$})),d?lp(t,Xm({treeLayout:w,fill:void 0===n?"node:internal":n,title:m,tip:k,...$})):null,null!=p?"mirrored"===b?[M({textAnchor:"start",treeFilter:"node:external"}),M({textAnchor:"end",treeFilter:"node:internal",dx:-g})]:M():null)}function wg(t,n){return xg(t,{...n,treeLayout:zr})}const bg={ariaLabel:"waffle"};class kg extends Gd{constructor(t,{unit:n=1,gap:e=1,round:r,render:o,multiple:i,...a}={}){super(t,{...a,render:Sc(o,Mg("x"))},bg),this.unit=Math.max(0,n),this.gap=+e,this.round=Lg(r),this.multiple=Eg(i)}}class $g extends Zd{constructor(t,{unit:n=1,gap:e=1,round:r,render:o,multiple:i,...a}={}){super(t,{...a,render:Sc(o,Mg("y"))},bg),this.unit=Math.max(0,n),this.gap=+e,this.round=Lg(r),this.multiple=Eg(i)}}function Mg(t){return function(n,e,r,o,i){const{unit:a,gap:l,rx:s,ry:c,round:u}=this,{document:f}=i,h=r.channels[`${t}1`].value,d=r.channels[`${t}2`].value,p=this["y"===t?"_width":"_height"](e,r,o),y=this["y"===t?"_x":"_y"](e,r,o),m=a*function({domain:t,range:n}){return zg(n)/zg(t)}(e.scales[t]),{multiple:g=Math.max(1,Math.floor(Math.sqrt(p/m)))}=this,v=Math.min(p/g,m*g),x=m*g,w="y"===t?([t,n])=>[t*v,-n*x]:([t,n])=>[n*x,t*v],b=(p-g*v)/2,k="function"==typeof y?t=>y(t)+b:y+b,$=e[t](0),M="plot-pattern-"+ ++ic,A=f.createElementNS(Te.svg,"pattern");A.setAttribute("width","y"===t?v:x),A.setAttribute("height","y"===t?x:v),A.setAttribute("patternUnits","userSpaceOnUse");const L=A.appendChild(f.createElementNS(Te.svg,"rect"));return L.setAttribute("x",l/2),L.setAttribute("y",l/2),L.setAttribute("width",("y"===t?v:x)-l),L.setAttribute("height",("y"===t?x:v)-l),null!=s&&L.setAttribute("rx",s),null!=c&&L.setAttribute("ry",c),Vs("svg:g",i).call(gc,this,o,i).call(this._transform,this,e).call((t=>t.selectAll().data(n).enter().append((()=>A.cloneNode(!0))).attr("id",(t=>`${M}-${t}`)).select("rect").call(vc,this).call(uc,this,r))).call((e=>e.selectAll().data(n).enter().append("path").attr("transform","y"===t?bu`translate(${k},${$})`:bu`translate(${$},${k})`).attr("d",(t=>`M${Ag(u(h[t]/a),u(d[t]/a),g).map(w).join("L")}Z`)).attr("fill",(t=>`url(#${M}-${t})`)).attr("stroke",null==this.stroke?null:t=>`url(#${M}-${t})`))).node()}}function Ag(t,n,e){if(t<0||n<0){const r=Math.ceil(-Math.min(t,n)/e);return Ag(t+r*e,n+r*e,e).map((([t,n])=>[t,n-r]))}return ne-1?[]:[[Math.ceil(t%e),Math.floor(t/e)],[e,Math.floor(t/e)]],[e,Math.floor(n/e)],[Math.ceil(n%e),Math.floor(n/e)],[Math.ceil(n%e),Math.floor(n/e)+n%1],[Math.floor(n%e),Math.floor(n/e)+n%1],...n%e<1?[]:[[Math.floor(n%e),Math.ceil(n/e)],[0,Math.ceil(n/e)]]]}function Lg(t){if(void 0===t||!1===t)return Number;if(!0===t)return Math.round;if("function"!=typeof t)throw new Error(`invalid round: ${t}`);return t}function Eg(t){return void 0===t?void 0:Math.max(1,Math.floor(t))}function zg(t){const[n,e]=qn(t);return e-n}function Og(t,n={}){return Go(n)||(n={...n,y:Mo,x2:Ao}),new kg(t,Qf(fu(Vf(n))))}function Sg(t,n={}){return Go(n)||(n={...n,x:Mo,y2:Ao}),new $g(t,th(hu(Hf(n))))}const Ng=({marginLeft:t})=>[1,t],Cg=({width:t,marginRight:n})=>[-1,t-n],Tg=({width:t,marginLeft:n,marginRight:e})=>[0,(n+t-e)/2],Rg=({marginTop:t})=>[1,t],Ig=({height:t,marginBottom:n})=>[-1,t-n],Wg=({height:t,marginTop:n,marginBottom:e})=>[0,(n+t-e)/2];function jg(t){return"string"==typeof t?{anchor:t}:t}function Bg(t={},n={}){1===arguments.length&&([t,n]=Dg(t));let{anchor:e="left",padding:r=1,r:o=n.r}=jg(t);switch(`${e}`.toLowerCase()){case"left":e=Ng;break;case"right":e=Cg;break;case"middle":e=Tg;break;default:throw new Error(`unknown dodge anchor: ${e}`)}return qg("x","y",e,Oo(r),o,n)}function Fg(t={},n={}){1===arguments.length&&([t,n]=Dg(t));let{anchor:e="bottom",padding:r=1,r:o=n.r}=jg(t);switch(`${e}`.toLowerCase()){case"top":e=Rg;break;case"bottom":e=Ig;break;case"middle":e=Wg;break;default:throw new Error(`unknown dodge anchor: ${e}`)}return qg("y","x",e,Oo(r),o,n)}function Dg(t){const{anchor:n,padding:e,...r}=t,{r:o}=r;return[{anchor:n,padding:e,r:o},r]}function qg(t,n,e,r,o,i){if(null!=o&&"number"!=typeof o){let{channels:t,sort:n,reverse:e}=i;t=Wi(t),void 0===t?.r&&(i={...i,channels:{...t,r:{value:o,scale:"r"}}}),void 0===n&&void 0===e&&(i.sort={channel:"-r"})}return na(i,(function(i,a,l,s,c,u){let{[n]:f,r:h}=l;if(!l[n])throw new Error(`missing channel: ${n}`);({[n]:f}=qs(l,s,u));const d=h?void 0:void 0!==o?Oo(o):void 0!==this.r?this.r:3;h&&(h=vo(h.value,s[h.scale]||Ao,Float64Array));let[p,y]=e(c);const m=p?Pg:_g,g=new Float64Array(f.length),v=h?t=>h[t]:()=>d;for(let t of a){const n=Cr();t=t.filter(h?t=>jr(f[t])&&Br(h[t]):t=>jr(f[t]));const e=new Float64Array(2*t.length+2);for(const o of t){const t=v(o),i=p?t+r:0,a=f[o]-t,l=f[o]+t;let s=2;n.queryInterval(a-r,l+r,(([,,t])=>{const n=g[t]-i,a=f[o]-f[t],l=r+(h?h[o]+h[t]:2*d),c=Math.sqrt(l*l-a*a);e[s++]=n-c,e[s++]=n+c}));let c=e.slice(0,s);p&&(c=c.filter((t=>t>=0)));t:for(const t of c.sort(m)){for(let n=0;nt(n,(t=>e[t]))))}const Gg={mapIndex(t,n,e){const[r,o]=qn(t,(t=>n[t])),i=o-r;for(const o of t)e[o]=null===n[o]?NaN:(n[o]-r)/i}},Zg=Yg(((t,n)=>{for(let e=0;e{for(let e=t.length-1;e>=0;--e){const r=n[t[e]];if(Tr(r))return r}})),Kg={mapIndex(t,n,e){const r=at(t,(t=>n[t])),o=ut(t,(t=>n[t]));for(const i of t)e[i]=null===n[i]?NaN:o?(n[i]-r)/o:0}},Qg=Xg(N),tv=Xg(at),nv=Xg(ot),ev=Xg(ct),rv=Xg(tt);function ov(t,n){return av("x",t,n)}function iv(t,n){return av("y",t,n)}function av(t,n,e={}){let r,o=1;if("number"==typeof n)o=n,r=(t,n)=>+t+n;else{if("string"==typeof n){const t=n.startsWith("-")?-1:1;[n,o]=ro(n.replace(/^[+-]/,"")),o*=t}n=mi(n),r=(t,e)=>n.offset(t,e)}const i=`${t}2`,a=Op({[`${t}1`]:t=>t.map((t=>r(t,o))),[i]:t=>t},e),l=a[i].transform;return a[i].transform=()=>{const t=l(),[n,e]=qn(t);return t.domain=o<0?[n,r(e,o)]:[r(n,o),e],t},a}function lv(t,n={}){if("string"==typeof t)switch(t.toLowerCase()){case"first":return cv(n);case"last":return uv(n)}if("function"==typeof t)return xv(null,t,n);let e,r;for(e in t){if(void 0!==r)throw new Error("ambiguous selector; multiple inputs");r=sv(t[e])}if(void 0===r)throw new Error(`invalid selector: ${t}`);return xv(e,r,n)}function sv(t){if("function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"min":return gv;case"max":return vv}throw new Error(`unknown selector: ${t}`)}function cv(t){return xv(null,yv,t)}function uv(t){return xv(null,mv,t)}function fv(t){return xv("x",gv,t)}function hv(t){return xv("y",gv,t)}function dv(t){return xv("x",vv,t)}function pv(t){return xv("y",vv,t)}function*yv(t){yield t[0]}function*mv(t){yield t[t.length-1]}function*gv(t,n){yield Or(t,(t=>n[t]))}function*vv(t,n){yield qe(t,(t=>n[t]))}function xv(t,n,e){if(null!=t){if(null==e[t])throw new Error(`missing channel: ${t}`);t=e[t]}const r=ei(e);return ta(e,((e,o)=>{const i=vo(e,r),a=vo(e,t),l=[];for(const t of o){const e=[];for(const r of i?J(t,(t=>i[t])).values():[t])for(const t of n(r,a))e.push(t);l.push(e)}return{data:e,facets:l}}))}zc.prototype.plot=function({marks:t=[],...n}={}){return Fh({...n,marks:[...t,this]})};export{Rd as Area,Pd as Arrow,Gd as BarX,Zd as BarY,tp as Cell,Oy as Contour,am as Density,ap as Dot,Lh as Frame,xm as Geo,Om as Hexgrid,Cm as Image,dp as Line,Fd as Link,zc as Mark,yy as Raster,yh as Rect,mu as RuleX,gu as RuleY,Mu as Text,ty as TickX,ny as TickY,Sh as Tip,Qu as Vector,kg as WaffleX,$g as WaffleY,Id as area,Wd as areaX,jd as areaY,Hd as arrow,vp as auto,gp as autoSpec,pf as axisFx,hf as axisFy,df as axisX,ff as axisY,Jd as barX,Kd as barY,cd as bin,ld as binX,sd as binY,Jp as bollinger,Gp as bollingerX,Zp as bollingerY,oy as boxX,iy as boxY,np as cell,ep as cellX,rp as cellY,mm as centroid,up as circle,wg as cluster,ui as column,Sy as contour,Cy as crosshair,Ty as crosshairX,Ry as crosshairY,tm as delaunayLink,nm as delaunayMesh,lm as density,um as differenceX,fm as differenceY,Bg as dodgeX,Fg as dodgeY,lp as dot,sp as dotX,cp as dotY,ia as filter,Ua as find,nc as formatIsoDate,Qs as formatMonth,Ks as formatNumber,tc as formatWeekday,Eh as frame,wm as geo,gm as geoCentroid,km as graticule,wf as gridFx,vf as gridFy,xf as gridX,gf as gridY,ga as group,ya as groupX,ma as groupY,pa as groupZ,fp as hexagon,Am as hexbin,zm as hexgrid,em as hull,Ao as identity,Rm as image,Mo as indexOf,na as initializer,Ay as interpolateNearest,by as interpolateNone,ky as interpolatorBarycentric,Ly as interpolatorRandomWalk,Df as legend,pp as line,yp as lineX,mp as lineY,Vm as linearRegressionX,Hm as linearRegressionY,Dd as link,Op as map,Ep as mapX,zp as mapY,Oc as marks,Ug as normalize,Vg as normalizeX,Hg as normalizeY,gi as numberInterval,Fh as plot,jc as pointer,Bc as pointerX,Fc as pointerY,gy as raster,bh as rect,kh as rectX,$h as rectY,la as reverse,vu as ruleX,xu as ruleY,ys as scale,lv as select,cv as selectFirst,uv as selectLast,dv as selectMaxX,pv as selectMaxY,fv as selectMinX,hv as selectMinY,ov as shiftX,iv as shiftY,ca as shuffle,ua as sort,bm as sphere,rf as spike,Yf as stackX,Xf as stackX1,Gf as stackX2,Zf as stackY,Jf as stackY1,Kf as stackY2,Eu as text,zu as textX,Ou as textY,ey as tickX,ry as tickY,oo as timeInterval,Nh as tip,ta as transform,xg as tree,Gm as treeLink,Xm as treeNode,io as utcInterval,vo as valueof,tf as vector,nf as vectorX,ef as vectorY,rm as voronoi,om as voronoiMesh,Og as waffleX,Sg as waffleY,Ip as window,Tp as windowX,Rp as windowY};export default null;