diff --git "a/libs/plot.umd.min.js" "b/libs/plot.umd.min.js" new file mode 100644--- /dev/null +++ "b/libs/plot.umd.min.js" @@ -0,0 +1,2 @@ +// @observablehq/plot v0.6.11 Copyright 2020-2023 Observable, Inc. +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("d3@7.8.5/dist/d3.min.js")):"function"==typeof define&&define.amd?define(["exports","d3@7.8.5/dist/d3.min.js"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Plot=t.Plot||{},t.d3)}(this,(function(t,e){"use strict";function n(t){return null!=t&&!Number.isNaN(t)}function r(t,r){return+n(r)-+n(t)||e.ascending(t,r)}function o(t,r){return+n(r)-+n(t)||e.descending(t,r)}function i(t){return null!=t&&""!=`${t}`}function a(t){return isFinite(t)?t:NaN}function l(t){return t>0&&isFinite(t)?t:NaN}function s(t){return t<0&&isFinite(t)?t:NaN}function c(t,e){if(t instanceof Date||(t=new Date(+t)),isNaN(t))return"function"==typeof e?e(t):e;const n=t.getUTCHours(),r=t.getUTCMinutes(),o=t.getUTCSeconds(),i=t.getUTCMilliseconds();return`${a=t.getUTCFullYear(),a<0?`-${u(-a,6)}`:a>9999?`+${u(a,6)}`:u(a,4)}-${u(t.getUTCMonth()+1,2)}-${u(t.getUTCDate(),2)}${n||r||o||i?`T${u(n,2)}:${u(r,2)}${o||i?`:${u(o,2)}${i?`.${u(i,3)}`:""}`:""}Z`:""}`;var a}function u(t,e){return`${t}`.padStart(e,"0")}const f=/^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;function h(t,e){return f.test(t+="")?new Date(t):"function"==typeof e?e(t):e}const d=1e3,p=6e4,m=36e5,y=864e5,g=7*y,v=30*y,x=365*y,w=[["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",d],["5 seconds",5e3],["15 seconds",15e3],["30 seconds",3e4],["minute",p],["5 minutes",3e5],["15 minutes",9e5],["30 minutes",18e5],["hour",m],["3 hours",108e5],["6 hours",216e5],["12 hours",432e5],["day",y],["2 days",2*y],["week",g],["2 weeks",2*g],["month",v],["3 months",3*v],["6 months",6*v],["year",x],["2 years",2*x],["5 years",5*x],["10 years",10*x],["20 years",20*x],["50 years",50*x],["100 years",100*x]],b=new Map([["second",d],["minute",p],["hour",m],["day",y],["monday",g],["tuesday",g],["wednesday",g],["thursday",g],["friday",g],["saturday",g],["sunday",g],["week",g],["month",v],["year",x]]),k=new Map([["second",e.timeSecond],["minute",e.timeMinute],["hour",e.timeHour],["day",e.timeDay],["monday",e.timeMonday],["tuesday",e.timeTuesday],["wednesday",e.timeWednesday],["thursday",e.timeThursday],["friday",e.timeFriday],["saturday",e.timeSaturday],["sunday",e.timeSunday],["week",e.timeWeek],["month",e.timeMonth],["year",e.timeYear]]),$=new Map([["second",e.utcSecond],["minute",e.utcMinute],["hour",e.utcHour],["day",e.unixDay],["monday",e.utcMonday],["tuesday",e.utcTuesday],["wednesday",e.utcWednesday],["thursday",e.utcThursday],["friday",e.utcFriday],["saturday",e.utcSaturday],["sunday",e.utcSunday],["week",e.utcWeek],["month",e.utcMonth],["year",e.utcYear]]),M=Symbol("intervalDuration"),L=Symbol("intervalType");for(const[t,e]of k)e[M]=b.get(t),e[L]="time";for(const[t,e]of $)e[M]=b.get(t),e[L]="utc";const A=[["year",e.utcYear,"utc"],["year",e.timeYear,"time"],["month",e.utcMonth,"utc"],["month",e.timeMonth,"time"],["day",e.unixDay,"utc",6*v],["day",e.timeDay,"time",6*v],["hour",e.utcHour,"utc",3*y],["minute",e.utcMinute,"utc",216e5],["second",e.utcSecond,"utc",18e5]];function S(t,e,n){let r=`${t}`.toLowerCase();r.endsWith("s")&&(r=r.slice(0,-1));let o=1;const i=/^(?:(\d+)\s+)/.exec(r);switch(i&&(r=r.slice(i[0].length),o=+i[1]),r){case"quarter":r="month",o*=3;break;case"half":r="month",o*=6}let a=e.get(r);if(!a)throw new Error(`unknown interval: ${t}`);if(o>1){if(!a.every)throw new Error(`non-periodic interval: ${r}`);a=a.every(o),a[M]=b.get(r)*o,a[L]=n}return a}function z(t){return S(t,k,"time")}function E(t){return S(t,$,"utc")}function O(t,n){if(!(n>1))return;const r=t[M];if(!w.some((([,t])=>t===r)))return;if(r%y==0&&yMath.log(t))).center(w,Math.log(r*n))];return("time"===t[L]?z:E)(o)}function R(t,n,r){const o="time"===n?e.timeFormat:e.utcFormat;if(null==r)return o("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 i=function(t){return"left"===t||"right"===t?(t,e)=>`\n${t}\n${e}`:"top"===t?(t,e)=>`${e}\n${t}`:(t,e)=>`${t}\n${e}`}(r);switch(t){case"millisecond":return C(o(".%L"),o(":%M:%S"),i);case"second":return C(o(":%S"),o("%-I:%M"),i);case"minute":return C(o("%-I:%M"),o("%p"),i);case"hour":return C(o("%-I %p"),o("%b %-d"),i);case"day":return C(o("%-d"),o("%b"),i);case"month":return C(o("%b"),o("%Y"),i);case"year":return o("%Y")}throw new Error("unable to format time ticks")}function C(t,e,n){return(r,o,i)=>{const a=t(r,o),l=e(r,o),s=o-Qt(i);return o!==s&&void 0!==i[s]&&l===e(i[s],s)?a:n(a,l)}}const T=Object.getPrototypeOf(Uint8Array),B=Object.prototype.toString,N=Symbol("reindex");function I(t,e,n){const r=typeof e;return"string"===r?P(t,q(e),n):"function"===r?P(t,e,n):"number"===r||e instanceof Date||"boolean"===r?st(t,Z(e),n):"function"==typeof e?.transform?W(e.transform(t),n):function(t,e){return e?bt(t,e):t}(W(e,n),t?.[N])}function P(t,e,n){return st(t,n?.prototype instanceof T?function(t){return(e,n)=>K(t(e,n))}(e):e,n)}function W(t,e){return void 0===e?lt(t):t instanceof e?t:e.prototype instanceof T&&!(t instanceof T)?e.from(t,K):e.from(t)}const j=[null],q=t=>e=>e[t],D={transform:wt},F={transform:t=>t},Y=()=>1,_=()=>!0,G=t=>null==t?t:`${t}`,X=t=>null==t?t:+t,U=t=>t?t[0]:void 0,V=t=>t?t[1]:void 0,H=t=>t?t[2]:void 0,Z=t=>()=>t;function Q(t){const n=+`${t}`.slice(1)/100;return(t,r)=>e.quantile(t,n,r)}function J(t){return t instanceof T?t:st(t,K,Float64Array)}function K(t){return null==t?NaN:Number(t)}function tt(t){return st(t,et)}function et(t){return t instanceof Date&&!isNaN(t)?t:"string"==typeof t?h(t):null==t||isNaN(t=+t)?void 0:new Date(t)}function nt(t,e){return void 0===t&&(t=e),null===t?[void 0,"none"]:Gt(t)?[void 0,t]:[t,void 0]}function rt(t,e){return void 0===t&&(t=e),null===t||"number"==typeof t?[void 0,t]:[t,void 0]}function ot(t,e,n){if(null!=t)return at(t,e,n)}function at(t,e,n){const r=`${t}`.toLowerCase();if(!n.includes(r))throw new Error(`invalid ${e}: ${t}`);return r}function lt(t){return null==t||t instanceof Array||t instanceof T?t:Array.from(t)}function st(t,e,n=Array){return null==t?t:t instanceof n?t.map(e):n.from(t,e)}function ct(t,e=Array){return t instanceof e?t.slice():e.from(t)}function ut({x:t,x1:e,x2:n}){return void 0!==t||void 0!==e||void 0!==n}function ft({y:t,y1:e,y2:n}){return void 0!==t||void 0!==e||void 0!==n}function ht(t){return ut(t)||ft(t)||void 0!==t.interval}function dt(t){return t?.toString===B}function pt(t){return dt(t)&&(void 0!==t.type||void 0!==t.domain)}function mt(t){return dt(t)&&"function"!=typeof t.transform}function yt(t){return mt(t)&&void 0===t.value&&void 0===t.channel}function gt(t,e,n,r=F){return void 0===e&&void 0===n?(e=0,n=void 0===t?r:t):void 0===e?e=void 0===t?0:t:void 0===n&&(n=void 0===t?0:t),[e,n]}function vt(t,e){return void 0===t&&void 0===e?[U,V]:[t,e]}function xt({z:t,fill:e,stroke:n}={}){return void 0===t&&([t]=nt(e)),void 0===t&&([t]=nt(n)),t}function wt(t){const e=t.length,n=new Uint32Array(e);for(let t=0;tt[e]),t.constructor)}function kt(t){return 1===t.length?(e,n)=>t(bt(n,e)):t}function $t(t,e,n){return t.subarray?t.subarray(e,n):t.slice(e,n)}function Mt(t){return null!==t&&"object"==typeof t?t.valueOf():t}function Lt(t,e){if(void 0!==e[t])return e[t];switch(t){case"x1":case"x2":t="x";break;case"y1":case"y2":t="y"}return e[t]}function At(t){let e;return[{transform:()=>e,label:zt(t)},t=>e=t]}function St(t){return null==t?[t]:At(t)}function zt(t,e){return"string"==typeof t?t:t&&void 0!==t.label?t.label:e}function Et(t,e){return{transform(n){const r=t.transform(n),o=e.transform(n);return jt(r)||jt(o)?st(r,((t,e)=>new Date((+r[e]+ +o[e])/2))):st(r,((t,e)=>(+r[e]+ +o[e])/2),Float64Array)},label:t.label}}function Ot(t,e){const n=Rt(e?.interval,e?.type);return n?st(t,n):t}function Rt(t,e){const r=Ct(t,e);return r&&(t=>n(t)?r.floor(t):t)}function Ct(t,n){if(null!=t){if("number"==typeof t){0Math.floor(t*n)/n,offset:t=>(t*n+1)/n,range:(t,r)=>e.range(Math.ceil(t*n),r*n).map((t=>t/n))}:{floor:t=>Math.floor(t/n)*n,offset:t=>t+n,range:(t,r)=>e.range(Math.ceil(t/n),r/n).map((t=>t*n))}}if("string"==typeof t)return("time"===n?z:E)(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 Tt(t,e){if((t=Ct(t,e))&&"function"!=typeof t.range)throw new Error("invalid interval: missing range method");return t}function Bt(t){return"function"==typeof t?.range}function Nt(t){return void 0===t||mt(t)?t:{value:t}}function It(t){return t&&"function"==typeof t[Symbol.iterator]}function Pt(t){for(const e of t)if(null!=e)return"object"!=typeof e||e instanceof Date}function Wt(t){for(const e of t){if(null==e)continue;const t=typeof e;return"string"===t||"boolean"===t}}function jt(t){for(const e of t)if(null!=e)return e instanceof Date}function qt(t){for(const e of t)if(null!=e)return"string"==typeof e&&isNaN(e)&&h(e)}function Dt(t){for(const e of t)if(null!=e){if("string"!=typeof e)return!1;if(e.trim())return!isNaN(e)}}function Ft(t){for(const e of t)if(null!=e)return"number"==typeof e}function Yt(t,e){let n;for(const r of t)if(null!=r){if(!e(r))return!1;n=!0}return n}const _t=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 Gt(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)||_t.has(t))}function Xt(t){return"number"==typeof t&&(0<=t&&t<=1||isNaN(t))}function Ut(t){return null==t||Vt(t)}function Vt(t){return/^\s*none\s*$/i.test(t)}function Ht(t,e){return ot(t,e,["middle","top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"])}function Zt(t="middle"){return Ht(t,"frameAnchor")}function Qt(t){if(null==t)return;const n=t[0],r=t[t.length-1];return e.descending(n,r)}function Jt(t){return It(t)?function(t){console.warn("named iterables are deprecated; please use an object instead");const e=new Set;return Object.fromEntries(Array.from(t,(t=>{const{name:n}=t;if(null==n)throw new Error("missing name");const r=`${n}`;if("__proto__"===r)throw new Error(`illegal name: ${r}`);if(e.has(r))throw new Error(`duplicate name: ${r}`);return e.add(r),[n,t]})))}(t):t}const Kt=Symbol("position"),te=Symbol("color"),ee=Symbol("radius"),ne=Symbol("length"),re=Symbol("opacity"),oe=Symbol("symbol"),ie=Symbol("projection"),ae=new Map([["x",Kt],["y",Kt],["fx",Kt],["fy",Kt],["r",ee],["color",te],["opacity",re],["symbol",oe],["length",ne],["projection",ie]]);const le=Math.sqrt(3),se=2/le,ce={draw(t,e){const n=Math.sqrt(e/Math.PI),r=n*se,o=r/2;t.moveTo(0,r),t.lineTo(n,o),t.lineTo(n,-o),t.lineTo(0,-r),t.lineTo(-n,-o),t.lineTo(-n,o),t.closePath()}},ue=new Map([["asterisk",e.symbolAsterisk],["circle",e.symbolCircle],["cross",e.symbolCross],["diamond",e.symbolDiamond],["diamond2",e.symbolDiamond2],["hexagon",ce],["plus",e.symbolPlus],["square",e.symbolSquare],["square2",e.symbolSquare2],["star",e.symbolStar],["times",e.symbolTimes],["triangle",e.symbolTriangle],["triangle2",e.symbolTriangle2],["wye",e.symbolWye]]);function fe(t){return t&&"function"==typeof t.draw}function he(t){return!!fe(t)||"string"==typeof t&&ue.has(t.toLowerCase())}function de(t){if(null==t||fe(t))return t;const e=ue.get(`${t}`.toLowerCase());if(e)return e;throw new Error(`invalid symbol: ${t}`)}function pe({filter:t,sort:e,reverse:n,transform:r,initializer:o,...i}={},a){if(void 0===r&&(null!=t&&(r=xe(t)),null==e||yt(e)||(r=ye(r,ke(e))),n&&(r=ye(r,we))),null!=a&&null!=o)throw new Error("transforms cannot be applied after initializers");return{...i,...(null===e||yt(e))&&{sort:e},transform:ye(r,a)}}function me({filter:t,sort:e,reverse:n,initializer:r,...o}={},i){return void 0===r&&(null!=t&&(r=xe(t)),null==e||yt(e)||(r=ge(r,ke(e))),n&&(r=ge(r,we))),{...o,...(null===e||yt(e))&&{sort:e},initializer:ge(r,i)}}function ye(t,e){return null==t?null===e?void 0:e:null==e?null===t?void 0:t:function(n,r,o){return({data:n,facets:r}=t.call(this,n,r,o)),e.call(this,lt(n),r,o)}}function ge(t,e){return null==t?null===e?void 0:e:null==e?null===t?void 0:t:function(n,r,o,...i){let a,l,s,c,u,f;return({data:l=n,facets:s=r,channels:a}=t.call(this,n,r,o,...i)),({data:u=l,facets:f=s,channels:c}=e.call(this,l,s,{...o,...a},...i)),{data:u,facets:f,channels:{...a,...c}}}}function ve(t,e){return(null!=t.initializer?me:pe)(t,e)}function xe(t){return(e,n)=>{const r=I(e,t);return{data:e,facets:n.map((t=>t.filter((t=>r[t]))))}}}function we(t,e){return{data:t,facets:e.map((t=>t.slice().reverse()))}}function be(t,{sort:e,...n}={}){return{...(mt(t)&&void 0!==t.channel?me:ve)(n,ke(t)),sort:yt(e)?e:null}}function ke(t){return("function"==typeof t&&1!==t.length?$e:Me)(t)}function $e(t){return(e,n)=>{const r=(n,r)=>t(e[n],e[r]);return{data:e,facets:n.map((t=>t.slice().sort(r)))}}}function Me(t){let e,n;({channel:e,value:t,order:n}={...Nt(t)});const i=e?.startsWith("-");if(i&&(e=e.slice(1)),void 0===n&&(n=i?o:r),"function"!=typeof n)switch(`${n}`.toLowerCase()){case"ascending":n=r;break;case"descending":n=o;break;default:throw new Error(`invalid order: ${n}`)}return(r,o,i)=>{let a;if(void 0===e)a=I(r,t);else{if(void 0===i)throw new Error("channel sort requires an initializer");if(a=i[e],!a)return{};a=a.value}const l=(t,e)=>n(a[t],a[e]);return{data:r,facets:o.map((t=>t.slice().sort(l)))}}}function Le(t,e){return Ee(null,null,t,e)}function Ae(t={y:"count"},e={}){const{x:n=F}=e;if(null==n)throw new Error("missing channel: x");return Ee(n,null,t,e)}function Se(t={x:"count"},e={}){const{y:n=F}=e;if(null==n)throw new Error("missing channel: y");return Ee(null,n,t,e)}function ze(t={fill:"count"},e={}){let{x:n,y:r}=e;if([n,r]=vt(n,r),null==n)throw new Error("missing channel: x");if(null==r)throw new Error("missing channel: y");return Ee(n,r,t,e)}function Ee(t,e,{data:n=De,filter:r,sort:o,reverse:i,...a}={},l={}){a=Re(a,l),n=Ne(n,F),o=null==o?void 0:Ce("sort",o,l),r=null==r?void 0:Te("filter",r,l);const[s,c]=St(t),[u,f]=St(e),{z:h,fill:d,stroke:p,x1:m,x2:y,y1:g,y2:v,...x}=l,[w,b]=St(h),[k]=nt(d),[$]=nt(p),[M,L]=St(k),[A,S]=St($);return{..."z"in l&&{z:w||h},..."fill"in l&&{fill:M||d},..."stroke"in l&&{stroke:A||p},...pe(x,((l,s,u)=>{const d=Ot(I(l,t),u?.x),p=Ot(I(l,e),u?.y),m=I(l,h),y=I(l,k),g=I(l,$),v=Pe(a,{z:m,fill:y,stroke:g}),x=[],w=[],M=d&&c([]),A=p&&f([]),z=m&&b([]),E=y&&L([]),O=g&&S([]);let R=0;for(const t of a)t.initialize(l);o&&o.initialize(l),r&&r.initialize(l);for(const t of s){const e=[];for(const e of a)e.scope("facet",t);o&&o.scope("facet",t),r&&r.scope("facet",t);for(const[i,s]of Be(t,v))for(const[t,c]of Be(s,p))for(const[s,u]of Be(c,d))if(!r||r.reduce(u)){e.push(R++),w.push(n.reduceIndex(u,l)),d&&M.push(s),p&&A.push(t),m&&z.push(v===m?i:m[u[0]]),y&&E.push(v===y?i:y[u[0]]),g&&O.push(v===g?i:g[u[0]]);for(const t of a)t.reduce(u);o&&o.reduce(u)}x.push(e)}return We(x,o,i),{data:w,facets:x}})),...!Oe(a,"x")&&(s?{x:s}:{x1:m,x2:y}),...!Oe(a,"y")&&(u?{y:u}:{y1:g,y2:v}),...Object.fromEntries(a.map((({name:t,output:e})=>[t,e])))}}function Oe(t,...e){for(const{name:n}of t)if(e.includes(n))return!0;return!1}function Re(t,e,n=Ce){const r=Object.entries(t);return null!=e.title&&void 0===t.title&&r.push(["title",Ye]),null!=e.href&&void 0===t.href&&r.push(["href",Fe]),r.filter((([,t])=>void 0!==t)).map((([t,r])=>null===r?function(t){return{name:t,initialize(){},scope(){},reduce(){}}}(t):n(t,r,e)))}function Ce(t,e,n,r=Te){let o;dt(e)&&"reduce"in e&&(o=e.scale,e=e.reduce);const i=r(t,e,n),[a,l]=At(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,e){i.scope(t,e)},reduce(t,e){s.push(i.reduce(t,e))}}}function Te(t,e,n,r=Ne){const o=Lt(t,n),i=r(e,o);let a,l;return{label:zt(i===Ge?null:o,i.label),initialize(t){a=void 0===o?t:I(t,o),"data"===i.scope&&(l=i.reduceIndex(wt(t),a))},scope(t,e){i.scope===t&&(l=i.reduceIndex(e,a))},reduce:(t,e)=>null==i.scope?i.reduceIndex(t,a,e):i.reduceIndex(t,a,l,e)}}function Be(t,n){return n?e.sort(e.group(t,(t=>n[t])),U):[[,t]]}function Ne(t,n,r=Ie){if(null==t)return r(t);if("function"==typeof t.reduceIndex)return t;if("function"==typeof t.reduce&&dt(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 o=t,{reduceIndex:(t,e,n)=>o(bt(e,t),n)};var o;if(/^p\d{2}$/i.test(t))return je(Q(t));switch(`${t}`.toLowerCase()){case"first":return Fe;case"last":return _e;case"identity":return De;case"count":return Ge;case"distinct":return Xe;case"sum":return null==n?Ge:Ue;case"proportion":return Ve(n,"data");case"proportion-facet":return Ve(n,"facet");case"deviation":return je(e.deviation);case"min":return je(e.min);case"min-index":return je(e.minIndex);case"max":return je(e.max);case"max-index":return je(e.maxIndex);case"mean":return qe(e.mean);case"median":return qe(e.median);case"variance":return je(e.variance);case"mode":return je(e.mode)}return r(t)}function Ie(t){throw new Error(`invalid reduce: ${t}`)}function Pe(t,e){for(const n in e){const r=e[n];if(void 0!==r&&!t.some((t=>t.name===n)))return r}}function We(t,e,n){if(e){const n=e.output.transform(),o=(t,e)=>r(n[t],n[e]);t.forEach((t=>t.sort(o)))}n&&t.forEach((t=>t.reverse()))}function je(t){return{reduceIndex:(e,n)=>t(e,(t=>n[t]))}}function qe(t){return{reduceIndex(e,n){const r=t(e,(t=>n[t]));return jt(n)?new Date(r):r}}}const De={reduceIndex:(t,e)=>bt(e,t)},Fe={reduceIndex:(t,e)=>e[t[0]]},Ye={reduceIndex(t,n){const r=e.sort(e.rollup(t,(t=>t.length),(t=>n[t])),V),o=r.slice(-5).reverse();if(o.length`${t} (${e.toLocaleString("en-US")})`)).join("\n")}},_e={reduceIndex:(t,e)=>e[t[t.length-1]]},Ge={label:"Frequency",reduceIndex:t=>t.length},Xe={label:"Distinct",reduceIndex(t,n){const r=new e.InternSet;for(const e of t)r.add(n[e]);return r.size}},Ue=je(e.sum);function Ve(t,n){return null==t?{scope:n,label:"Frequency",reduceIndex:(t,e,n=1)=>t.length/n}:{scope:n,reduceIndex:(t,n,r=1)=>e.sum(t,(t=>n[t]))/r}}function He(t,{scale:e,type:n,value:r,filter:o,hint:i,label:a=zt(r)},l){return void 0===i&&"function"==typeof r?.transform&&(i=r.hint),Je(l,{scale:e,type:n,value:I(t,r),label:a,filter:o,hint:i})}function Ze(t,e){return Object.fromEntries(Object.entries(t).map((([t,n])=>[t,He(e,n,t)])))}function Qe(t,e){const n=Object.fromEntries(Object.entries(t).map((([t,{scale:n,value:r}])=>{const o=null==n?null:e[n];return[t,null==o?r:st(r,o)]})));return n.channels=t,n}function Je(t,e){const{scale:n,value:r}=e;if(!0===n||"auto"===n)switch(t){case"fill":case"stroke":case"color":e.scale=!0!==n&&Yt(r,Gt)?null:"color";break;case"fillOpacity":case"strokeOpacity":case"opacity":e.scale=!0!==n&&Yt(r,Xt)?null:"opacity";break;case"symbol":!0!==n&&Yt(r,he)?(e.scale=null,e.value=st(r,de)):e.scale="symbol";break;default:e.scale=ae.has(t)?t:null}else if(!1===n)e.scale=null;else if(null!=n&&!ae.has(n))throw new Error(`unknown scale: ${n}`);return e}function Ke(t,e){for(const n in t){const r=t[n];if(r.scale===e)return r}}function tn(t,e){const n=t.original;if(n===t)return e;const r=e.value,o=e.value=[];for(let e=0;eMath.abs(t-r[e])),Float64Array)}function nn(t,e,n){let r=t[e];if(r||void 0===n||(r=t[n]),r)return r.value;throw new Error(`missing channel: ${e}`)}function rn(t){if(null==t||"function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"ascending":return on;case"descending":return an}throw new Error(`invalid order: ${t}`)}function on([t,e],[n,o]){return r(e,o)||r(t,n)}function an([t,e],[n,i]){return o(e,i)||r(t,n)}function ln(t,e){let n=t[e];if(n){for(;n.source;)n=n.source;return null===n.source?null:n}}function sn(t){let e,n;return(...r)=>((n?.length!==r.length||n.some(((t,e)=>t!==r[e])))&&(n=r,e=t(...r)),e)}const cn=sn((t=>new Intl.NumberFormat(t))),un=sn(((t,e)=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...e&&{month:e}}))),fn=sn(((t,e)=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...e&&{weekday:e}})));function hn(t){return c(t,"Invalid Date")}const dn=function(t="en-US"){const e=function(t="en-US"){const e=cn(t);return t=>null==t||isNaN(t)?void 0:e.format(t)}(t);return t=>(t instanceof Date?hn:"number"==typeof t?e:G)(t)}();let pn,mn=0;function yn(t){t!==pn&&(pn=t,console.warn(t),++mn)}const gn=("undefined"!=typeof window?window.devicePixelRatio>1:"undefined"==typeof it)?0:.5;let vn=0;function xn(){return"plot-clip-"+ ++vn}function wn(t,{title:e,href:n,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:m,strokeDashoffset:y,opacity:g,mixBlendMode:v,imageFilter:x,paintOrder:w,pointerEvents:b,shapeRendering:k,channels:$},{ariaLabel:M,fill:L="currentColor",fillOpacity:A,stroke:S="none",strokeOpacity:z,strokeWidth:E,strokeLinecap:O,strokeLinejoin:R,strokeMiterlimit:C,paintOrder:T}){null===L&&(l=null,s=null),null===S&&(c=null,f=null),Ut(L)?Ut(S)||Ut(l)&&!$?.fill||(S="none"):!Ut(S)||Ut(c)&&!$?.stroke||(L="none");const[B,N]=nt(l,L),[I,P]=rt(s,A),[W,j]=nt(c,S),[q,D]=rt(f,z),[F,Y]=rt(g);Vt(j)||(void 0===u&&(u=E),void 0===d&&(d=O),void 0===h&&(h=R),void 0!==p||/^\s*round\s*$/i.test(h)||(p=C),Vt(N)||void 0!==w||(w=T));const[_,X]=rt(u);return null!==L&&(t.fill=Tn(N,"currentColor"),t.fillOpacity=Bn(P,1)),null!==S&&(t.stroke=Tn(j,"none"),t.strokeWidth=Bn(X,1),t.strokeOpacity=Bn(D,1),t.strokeLinejoin=Tn(h,"miter"),t.strokeLinecap=Tn(d,"butt"),t.strokeMiterlimit=Bn(p,4),t.strokeDasharray=Tn(m,"none"),t.strokeDashoffset=Tn(y,"0")),t.target=G(a),t.ariaLabel=G(M),t.ariaDescription=G(o),t.ariaHidden=G(i),t.opacity=Bn(Y,1),t.mixBlendMode=Tn(v,"normal"),t.imageFilter=Tn(x,"none"),t.paintOrder=Tn(w,"normal"),t.pointerEvents=Tn(b,"auto"),t.shapeRendering=Tn(k,"auto"),{title:{value:e,optional:!0,filter:null},href:{value:n,optional:!0,filter:null},ariaLabel:{value:r,optional:!0,filter:null},fill:{value:B,scale:"auto",optional:!0},fillOpacity:{value:I,scale:"auto",optional:!0},stroke:{value:W,scale:"auto",optional:!0},strokeOpacity:{value:q,scale:"auto",optional:!0},strokeWidth:{value:_,optional:!0},opacity:{value:F,scale:"auto",optional:!0}}}function bn(t,e){e&&t.text((t=>dn(e[t])))}function kn(t,e){e&&t.text((([t])=>dn(e[t])))}function $n(t,{target:e,tip:n},{ariaLabel:r,title:o,fill:a,fillOpacity:l,stroke:s,strokeOpacity:c,strokeWidth:u,opacity:f,href:h}){r&&Rn(t,"aria-label",(t=>r[t])),a&&Rn(t,"fill",(t=>a[t])),l&&Rn(t,"fill-opacity",(t=>l[t])),s&&Rn(t,"stroke",(t=>s[t])),c&&Rn(t,"stroke-opacity",(t=>c[t])),u&&Rn(t,"stroke-width",(t=>u[t])),f&&Rn(t,"opacity",(t=>f[t])),h&&On(t,(t=>h[t]),e),n||function(t,e){e&&t.filter((t=>i(e[t]))).append("title").call(bn,e)}(t,o)}function Mn(t,{target:e,tip:n},{ariaLabel:r,title:o,fill:a,fillOpacity:l,stroke:s,strokeOpacity:c,strokeWidth:u,opacity:f,href:h}){r&&Rn(t,"aria-label",(([t])=>r[t])),a&&Rn(t,"fill",(([t])=>a[t])),l&&Rn(t,"fill-opacity",(([t])=>l[t])),s&&Rn(t,"stroke",(([t])=>s[t])),c&&Rn(t,"stroke-opacity",(([t])=>c[t])),u&&Rn(t,"stroke-width",(([t])=>u[t])),f&&Rn(t,"opacity",(([t])=>f[t])),h&&On(t,(([t])=>h[t]),e),n||function(t,e){e&&t.filter((([t])=>i(e[t]))).append("title").call(kn,e)}(t,o)}function Ln(t,n,r){const o=e.group(t,(t=>n[t]));return void 0===r&&o.size>1+t.length>>1&&yn("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."),o.values()}function*An(t,e,r,o){const{z:i}=r,{z:a}=o,l=function({ariaLabel:t,title:e,fill:n,fillOpacity:r,stroke:o,strokeOpacity:i,strokeWidth:a,opacity:l,href:s},{tip:c}){return[t,c?void 0:e,n,r,o,i,a,l,s].filter((t=>void 0!==t))}(o,r),s=[...e,...l];for(const e of a?Ln(t,a,i):[t]){let t,r;t:for(const o of e){for(const t of s)if(!n(t[o])){r&&r.push(-1);continue t}if(void 0!==t){r.push(o);for(let e=0;eMt(t[o]))),r=[o];continue t}}}else r&&(yield r),t=l.map((t=>Mt(t[o]))),r=[o]}r&&(yield r)}}function Sn(t){return!0===t?t="frame":!1===t?t=null:null!=t&&(t=at(t,"clip",["frame","sphere"])),t}function zn(t,n,r,o){!function(t,n,r,o){let i;const{clip:a=o.clip}=n;switch(a){case"frame":{const{width:e,height:n,marginLeft:a,marginRight:l,marginTop:s,marginBottom:c}=r,u=xn();i=`url(#${u})`,t=qn("svg:g",o).call((t=>t.append("svg:clipPath").attr("id",u).append("rect").attr("x",a).attr("y",s).attr("width",e-l-a).attr("height",n-s-c))).each((function(){this.appendChild(t.node()),t.node=()=>this}));break}case"sphere":{const{projection:n}=o;if(!n)throw new Error('the "sphere" clip option requires a projection');const r=xn();i=`url(#${r})`,t.append("clipPath").attr("id",r).append("path").attr("d",e.geoPath(n)({type:"Sphere"}));break}}Rn(t,"aria-label",n.ariaLabel),Rn(t,"aria-description",n.ariaDescription),Rn(t,"aria-hidden",n.ariaHidden),Rn(t,"clip-path",i)}(t,n,r,o),Rn(t,"fill",n.fill),Rn(t,"fill-opacity",n.fillOpacity),Rn(t,"stroke",n.stroke),Rn(t,"stroke-width",n.strokeWidth),Rn(t,"stroke-opacity",n.strokeOpacity),Rn(t,"stroke-linejoin",n.strokeLinejoin),Rn(t,"stroke-linecap",n.strokeLinecap),Rn(t,"stroke-miterlimit",n.strokeMiterlimit),Rn(t,"stroke-dasharray",n.strokeDasharray),Rn(t,"stroke-dashoffset",n.strokeDashoffset),Rn(t,"shape-rendering",n.shapeRendering),Rn(t,"filter",n.imageFilter),Rn(t,"paint-order",n.paintOrder);const{pointerEvents:i=(!1===o.pointerSticky?"none":void 0)}=n;Rn(t,"pointer-events",i)}function En(t,e){!function(t,e,n){null!=n&&t.style(e,n)}(t,"mix-blend-mode",e.mixBlendMode),Rn(t,"opacity",e.opacity)}function On(t,n,r){t.each((function(t){const o=n(t);if(null!=o){const t=this.ownerDocument.createElementNS(e.namespaces.svg,"a");t.setAttribute("fill","inherit"),t.setAttributeNS(e.namespaces.xlink,"href",o),null!=r&&t.setAttribute("target",r),this.parentNode.insertBefore(t,this).appendChild(this)}}))}function Rn(t,e,n){null!=n&&t.attr(e,n)}function Cn(t,e,{x:n,y:r},o=gn,i=gn){o+=e.dx,i+=e.dy,n?.bandwidth&&(o+=n.bandwidth()/2),r?.bandwidth&&(i+=r.bandwidth()/2),(o||i)&&t.attr("transform",`translate(${o},${i})`)}function Tn(t,e){if((t=G(t))!==e)return t}function Bn(t,e){if((t=X(t))!==e)return t}const Nn=/^-?([_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 In(t){if(void 0===t)return"plot-d6a7b5";if(t=`${t}`,!Nn.test(t))throw new Error(`invalid class name: ${t}`);return t}function Pn(t,e){if("string"==typeof e)t.property("style",e);else if(null!=e)for(const n of t)Object.assign(n.style,e)}function Wn({frameAnchor:t},{width:e,height:n,marginTop:r,marginRight:o,marginBottom:i,marginLeft:a}){return[/left$/.test(t)?a:/right$/.test(t)?e-o:(a+e-o)/2,/^top/.test(t)?r:/^bottom/.test(t)?n-i:(r+n-i)/2]}function jn(t={}){const{document:e=("undefined"!=typeof window?window.document:void 0),clip:n}=t;return{document:e,clip:Sn(n)}}function qn(t,{document:n}){return e.select(e.creator(t).call(n.documentElement))}const Dn=Math.PI,Fn=2*Dn,Yn=.618;function _n({projection:t,inset:n=0,insetTop:r=n,insetRight:o=n,insetBottom:i=n,insetLeft:a=n}={},l){if(null==t)return;if("function"==typeof t.stream)return t;let s,c,u="frame";if(dt(t)){let e;if(({type:t,domain:c,inset:e,insetTop:r=(void 0!==e?e:r),insetRight:o=(void 0!==e?e:o),insetBottom:i=(void 0!==e?e:i),insetLeft:a=(void 0!==e?e:a),clip:u=u,...s}=t),null==t)return}"function"!=typeof t&&({type:t}=Gn(t));const{width:f,height:h,marginLeft:d,marginRight:p,marginTop:m,marginBottom:y}=l,g=f-d-p-a-o,v=h-m-y-r-i;if(t=t?.({width:g,height:v,clip:u,...s}),null==t)return;u=function(t,n,r,o,i){if(!1===t||null==t||"number"==typeof t)return t=>t;!0===t&&(t="frame");if("frame"===`${t}`.toLowerCase())return e.geoClipRectangle(n,r,o,i);throw new Error(`unknown projection clip type: ${t}`)}(u,d,m,f-p,h-y);let x,w=d+a,b=m+r;if(null!=c){const[[n,r],[o,i]]=e.geoPath(t).bounds(c),a=Math.min(g/(o-n),v/(i-r));a>0?(w-=(a*(n+o)-g)/2,b-=(a*(r+i)-v)/2,x=e.geoTransform({point(t,e){this.stream.point(t*a+w,e*a+b)}})):yn("Warning: the projection could not be fit to the specified domain; using the default scale.")}return x??=0===w&&0===b?Vn():e.geoTransform({point(t,e){this.stream.point(t+w,e+b)}}),{stream:e=>t.stream(x.stream(u(e)))}}function Gn(t){switch(`${t}`.toLowerCase()){case"albers-usa":return Xn(e.geoAlbersUsa,.7463,.4673);case"albers":return Un(e.geoAlbers,.7463,.4673);case"azimuthal-equal-area":return Xn(e.geoAzimuthalEqualArea,4,4);case"azimuthal-equidistant":return Xn(e.geoAzimuthalEquidistant,Fn,Fn);case"conic-conformal":return Un(e.geoConicConformal,Fn,Fn);case"conic-equal-area":return Un(e.geoConicEqualArea,6.1702,2.9781);case"conic-equidistant":return Un(e.geoConicEquidistant,7.312,3.6282);case"equal-earth":return Xn(e.geoEqualEarth,5.4133,2.6347);case"equirectangular":return Xn(e.geoEquirectangular,Fn,Dn);case"gnomonic":return Xn(e.geoGnomonic,3.4641,3.4641);case"identity":return{type:Vn};case"reflect-y":return{type:Hn};case"mercator":return Xn(e.geoMercator,Fn,Fn);case"orthographic":return Xn(e.geoOrthographic,2,2);case"stereographic":return Xn(e.geoStereographic,2,2);case"transverse-mercator":return Xn(e.geoTransverseMercator,Fn,Fn);default:throw new Error(`unknown projection type: ${t}`)}}function Xn(t,e,n){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),s.scale(Math.min(r/e,o/n)),s.translate([r/2,o/2]),s},aspectRatio:n/e}}function Un(t,e,n){const{type:r,aspectRatio:o}=Xn(t,e,n);return{type:t=>{const{parallels:e,domain:n,width:o,height:i}=t,a=r(t);return null!=e&&(a.parallels(e),void 0===n&&a.fitSize([o,i],{type:"Sphere"})),a},aspectRatio:o}}const Vn=Z({stream:t=>t}),Hn=Z(e.geoTransform({point(t,e){this.stream.point(t,-e)}}));function Zn(t,e,n,r){const o=n[t],i=n[e],a=o.length,l=n[t]=new Float64Array(a).fill(NaN),s=n[e]=new Float64Array(a).fill(NaN);let c;const u=r.stream({point(t,e){l[c]=t,s[c]=e}});for(c=0;c1===r?[t[3][1]]:2===r?[t[3][1],t[3][2]]:(r=Math.max(3,Math.floor(r)))>9?e.quantize(n,r):t[r]}function rr(t,n){return({length:r})=>2===r?[t[3][0],t[3][2]]:(r=Math.max(3,Math.floor(r)))>11?e.quantize(n,r):t[r]}function or(t,n){return({length:r})=>2===r?[t[3][2],t[3][0]]:(r=Math.max(3,Math.floor(r)))>11?e.quantize((t=>n(1-t)),r):t[r].slice().reverse()}function ir(t){return({length:n})=>e.quantize(t,Math.max(2,Math.floor(n)))}function ar(t){return({length:n})=>e.quantize(t,Math.floor(n)+1).slice(0,-1)}function lr(t){const e=`${t}`.toLowerCase();if(!er.has(e))throw new Error(`unknown ordinal scheme: ${e}`);return er.get(e)}function sr(t,e){const n=lr(t),r="function"==typeof n?n({length:e}):n;return r.length!==e?r.slice(0,e):r}const cr=new Map([["brbg",e.interpolateBrBG],["prgn",e.interpolatePRGn],["piyg",e.interpolatePiYG],["puor",e.interpolatePuOr],["rdbu",e.interpolateRdBu],["rdgy",e.interpolateRdGy],["rdylbu",e.interpolateRdYlBu],["rdylgn",e.interpolateRdYlGn],["spectral",e.interpolateSpectral],["burd",t=>e.interpolateRdBu(1-t)],["buylrd",t=>e.interpolateRdYlBu(1-t)],["blues",e.interpolateBlues],["greens",e.interpolateGreens],["greys",e.interpolateGreys],["purples",e.interpolatePurples],["reds",e.interpolateReds],["oranges",e.interpolateOranges],["turbo",e.interpolateTurbo],["viridis",e.interpolateViridis],["magma",e.interpolateMagma],["inferno",e.interpolateInferno],["plasma",e.interpolatePlasma],["cividis",e.interpolateCividis],["cubehelix",e.interpolateCubehelixDefault],["warm",e.interpolateWarm],["cool",e.interpolateCool],["bugn",e.interpolateBuGn],["bupu",e.interpolateBuPu],["gnbu",e.interpolateGnBu],["orrd",e.interpolateOrRd],["pubugn",e.interpolatePuBuGn],["pubu",e.interpolatePuBu],["purd",e.interpolatePuRd],["rdpu",e.interpolateRdPu],["ylgnbu",e.interpolateYlGnBu],["ylgn",e.interpolateYlGn],["ylorbr",e.interpolateYlOrBr],["ylorrd",e.interpolateYlOrRd],["rainbow",e.interpolateRainbow],["sinebow",e.interpolateSinebow]]);function ur(t){const e=`${t}`.toLowerCase();if(!cr.has(e))throw new Error(`unknown quantitative scheme: ${e}`);return cr.get(e)}const fr=new Set(["brbg","prgn","piyg","puor","rdbu","rdgy","rdylbu","rdylgn","spectral","burd","buylrd"]);const hr=t=>e=>t(1-e),dr=[0,1],pr=new Map([["number",e.interpolateNumber],["rgb",e.interpolateRgb],["hsl",e.interpolateHsl],["hcl",e.interpolateHcl],["lab",e.interpolateLab]]);function mr(t){const e=`${t}`.toLowerCase();if(!pr.has(e))throw new Error(`unknown interpolator: ${e}`);return pr.get(e)}function yr(t,n,r,{type:o,nice:i,clamp:a,zero:l,domain:s=wr(t,r),unknown:c,round:u,scheme:f,interval:h,range:d=(ae.get(t)===ee?kr(r,s):ae.get(t)===ne?$r(r,s):ae.get(t)===re?dr:void 0),interpolate:p=(ae.get(t)===te?null==f&&void 0!==d?e.interpolateRgb:ur(void 0!==f?f:"cyclical"===o?"rainbow":"turbo"):u?e.interpolateRound:e.interpolateNumber),reverse:m}){if(h=Tt(h,o),"cyclical"!==o&&"sequential"!==o||(o="linear"),"function"!=typeof p&&(p=mr(p)),m=!!m,void 0!==d){if((s=lt(s)).length!==(d=lt(d)).length){if(1===p.length)throw new Error("invalid piecewise interpolator");p=e.piecewise(p,d),d=void 0}}if(1===p.length?(m&&(p=hr(p),m=!1),void 0===d&&2===(d=Float64Array.from(s,((t,e)=>e/(s.length-1)))).length&&(d=dr),n.interpolate((d===dr?Z:Ar)(p))):n.interpolate(p),l){const[t,n]=e.extent(s);(t>0||n<0)&&(Qt(s=ct(s))!==Math.sign(t)?s[s.length-1]=0:s[0]=0)}return m&&(s=e.reverse(s)),n.domain(s).unknown(c),i&&(n.nice(function(t,e){return!0===t?void 0:"number"==typeof t?t:function(t,e){if((t=Tt(t,e))&&"function"!=typeof t.ceil)throw new Error("invalid interval: missing ceil method");return t}(t,e)}(i,o)),s=n.domain()),void 0!==d&&n.range(d),a&&n.clamp(a),{type:o,domain:s,range:d,scale:n,interpolate:p,interval:h}}function gr(t,n,{exponent:r=1,...o}){return yr(t,e.scalePow().exponent(r),n,{...o,type:"pow"})}function vr(t,n,{domain:r=[0],unknown:o,scheme:i="rdylbu",interpolate:a,range:l=(void 0!==a?e.quantize(a,r.length+1):ae.get(t)===te?sr(i,r.length+1):void 0),reverse:s}){const c=Qt(r=lt(r));if(!isNaN(c)&&!function(t,n){for(let r=1,o=t.length,i=t[0];rvoid 0===t?t:e.min(t,n))),e.max(t,(({value:t})=>void 0===t?t:e.max(t,n)))]:[0,1]}function wr(t,e){const n=ae.get(t);return(n===ee||n===re||n===ne?br:xr)(e)}function br(t){return[0,t.length?e.max(t,(({value:t})=>void 0===t?t:e.max(t,a))):1]}function kr(t,n){const r=t.find((({radius:t})=>void 0!==t));if(void 0!==r)return[0,r.radius];const o=e.quantile(t,.5,(({value:t})=>void 0===t?NaN:e.quantile(t,.25,l))),i=n.map((t=>3*Math.sqrt(t/o))),a=30/e.max(i);return a<1?i.map((t=>t*a)):i}function $r(t,n){const r=e.median(t,(({value:t})=>void 0===t?NaN:e.median(t,Math.abs))),o=n.map((t=>12*t/r)),i=60/e.max(o);return i<1?o.map((t=>t*i)):o}function Mr(t){for(const{value:e}of t)if(void 0!==e)for(let n of e){if(n>0)return xr(t,l);if(n<0)return xr(t,s)}return[1,10]}function Lr(t){const e=[];for(const{value:n}of t)if(void 0!==n)for(const t of n)e.push(t);return e}function Ar(t){return(e,n)=>r=>t(e+r*(n-e))}function Sr(t,n,r,o,{type:i,nice:a,clamp:l,domain:s=xr(o),unknown:c,pivot:u=0,scheme:f,range:h,symmetric:d=!0,interpolate:p=(ae.get(t)===te?null==f&&void 0!==h?e.interpolateRgb:ur(void 0!==f?f:"rdbu"):e.interpolateNumber),reverse:m}){u=+u,s=lt(s);let[y,g]=s;if(s.length>2&&yn(`Warning: the diverging ${t} scale domain contains extra elements.`),e.descending(y,g)<0&&([y,g]=[g,y],m=!m),y=Math.min(y,u),g=Math.max(g,u),"function"!=typeof p&&(p=mr(p)),void 0!==h&&(p=1===p.length?Ar(p)(...h):e.piecewise(p,h)),m&&(p=hr(p)),d){const t=r.apply(u),e=t-r.apply(y),n=r.apply(g)-t;en&&(g=r.invert(t+e))}return n.domain([y,u,g]).unknown(c).interpolator(p),l&&n.clamp(l),a&&n.nice(a),{type:i,domain:[y,g],pivot:u,interpolate:p,scale:n}}function zr(t,n,{exponent:r=1,...o}){return Sr(t,e.scaleDivergingPow().exponent(r=+r),function(t){return.5===t?Cr:{apply:e=>Math.sign(e)*Math.pow(Math.abs(e),t),invert:e=>Math.sign(e)*Math.pow(Math.abs(e),1/t)}}(r),n,{...o,type:"diverging-pow"})}function Er(t,n,{constant:r=1,...o}){return Sr(t,e.scaleDivergingSymlog().constant(r=+r),function(t){return{apply:e=>Math.sign(e)*Math.log1p(Math.abs(e/t)),invert:e=>Math.sign(e)*Math.expm1(Math.abs(e))*t}}(r),n,o)}const Or={apply:t=>t,invert:t=>t},Rr={apply:Math.log,invert:Math.exp},Cr={apply:t=>Math.sign(t)*Math.sqrt(Math.abs(t)),invert:t=>Math.sign(t)*(t*t)};function Tr(t,e,n,r){return yr(t,e,n,r)}const Br=Symbol("ordinal");function Nr(t,n,r,{type:o,interval:i,domain:a,range:l,reverse:s,hint:c}){return i=Tt(i,o),void 0===a&&(a=Wr(r,i,t)),"categorical"!==o&&o!==Br||(o="ordinal"),s&&(a=e.reverse(a)),a=n.domain(a).domain(),void 0!==l&&("function"==typeof l&&(l=l(a)),n.range(l)),{type:o,domain:a,range:l,scale:n,hint:c,interval:i}}function Ir(t,n,{type:r,interval:o,domain:i,range:a,scheme:l,unknown:s,...c}){let u;if(o=Tt(o,r),void 0===i&&(i=Wr(n,o,t)),ae.get(t)===oe)u=function(t){return{fill:jr(t,"fill"),stroke:jr(t,"stroke")}}(n),a=void 0===a?function(t){return Ut(t.fill)?e.symbolsStroke:e.symbolsFill}(u):st(a,de);else if(ae.get(t)===te&&(void 0!==a||"ordinal"!==r&&r!==Br||(a=function(t,e="greys"){const n=new Set,[r,o]=sr(e,2);for(const e of t)if(null!=e)if(!0===e)n.add(o);else{if(!1!==e)return;n.add(r)}return[...n]}(i,l),void 0!==a&&(l=void 0)),void 0===l&&void 0===a&&(l="ordinal"===r?"turbo":"tableau10"),void 0!==l))if(void 0!==a){const t=ur(l),n=a[0],r=a[1]-a[0];a=({length:o})=>e.quantize((e=>t(n+r*e)),o)}else a=lr(l);if(s===e.scaleImplicit)throw new Error(`implicit unknown on ${t} scale is not supported`);return Nr(t,e.scaleOrdinal().unknown(s),n,{...c,type:r,domain:i,range:a,hint:u})}function Pr(t,e,n,r){let{round:o}=n;return void 0!==o&&t.round(o=!!o),(t=Nr(r,t,e,n)).round=o,t}function Wr(t,n,o){const i=new e.InternSet;for(const{value:e,domain:n}of t){if(void 0!==n)return n();if(void 0!==e)for(const t of e)i.add(t)}if(void 0!==n){const[t,r]=e.extent(i).map(n.floor,n);return n.range(t,n.offset(r))}if(i.size>1e4&&ae.get(o)===Kt)throw new Error(`implicit ordinal domain of ${o} scale has more than 10,000 values`);return e.sort(i,r)}function jr(t,e){let n;for(const{hint:r}of t){const t=r?.[e];if(void 0!==t)if(void 0===n)n=t;else if(n!==t)return}return n}function qr(t,{label:e,inset:n=0,insetTop:r=n,insetRight:o=n,insetBottom:i=n,insetLeft:a=n,round:l,nice:s,clamp:c,zero:u,align:f,padding:h,projection:d,facet:{label:p=e}={},...m}={}){const y={};for(const[n,g]of t){const t=m[n],v=Zr(n,g,{round:ae.get(n)===Kt?l:void 0,nice:s,clamp:c,zero:u,align:f,padding:h,projection:d,...t});if(v){let{label:l=("fx"===n||"fy"===n?p:e),percent:s,transform:c,inset:u,insetTop:f=(void 0!==u?u:"y"===n?r:0),insetRight:h=(void 0!==u?u:"x"===n?o:0),insetBottom:d=(void 0!==u?u:"y"===n?i:0),insetLeft:m=(void 0!==u?u:"x"===n?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?Fr(g,v):l,v.transform=c,"x"===n||"fx"===n?(v.insetLeft=+m,v.insetRight=+h):"y"!==n&&"fy"!==n||(v.insetTop=+f,v.insetBottom=+d),y[n]=v}}return y}function Dr(t){const e={},n={scales:e};for(const[r,o]of Object.entries(t)){const{scale:t,type:i,interval:a,label:l}=o;e[r]=io(o),n[r]=t,t.type=i,null!=a&&(t.interval=a),null!=l&&(t.label=l)}return n}function Fr(t=[],e){let n;for(const{label:e}of t)if(void 0!==e)if(void 0===n)n=e;else if(n!==e)return;if(void 0!==n)return!to(e)&&e.percent&&(n=`${n} (%)`),{inferred:!0,toString:()=>n}}function Yr(t){const{marginTop:e,marginRight:n,marginBottom:r,marginLeft:o,width:i,height:a,facet:{marginTop:l,marginRight:s,marginBottom:c,marginLeft:u}}=t;return{marginTop:Math.max(e,l),marginRight:Math.max(n,s),marginBottom:Math.max(r,c),marginLeft:Math.max(o,u),width:i,height:a}}function _r({fx:t,fy:e},n){const{marginTop:r,marginRight:o,marginBottom:i,marginLeft:a,width:l,height:s}=Yr(n);return{marginTop:r,marginRight:o,marginBottom:i,marginLeft:a,width:t?t.scale.bandwidth()+a+o:l,height:e?e.scale.bandwidth()+r+i:s,facet:{width:l,height:s}}}function Gr(t,e){if(void 0===t.range){const{insetLeft:n,insetRight:r}=t,{width:o,marginLeft:i=0,marginRight:a=0}=e,l=i+n,s=o-a-r;t.range=[l,Math.max(l,s)],to(t)||(t.range=Vr(t)),t.scale.range(t.range)}Ur(t)}function Xr(t,e){if(void 0===t.range){const{insetTop:n,insetBottom:r}=t,{height:o,marginTop:i=0,marginBottom:a=0}=e,l=i+n,s=o-a-r;t.range=[Math.max(l,s),l],to(t)?t.range.reverse():t.range=Vr(t),t.scale.range(t.range)}Ur(t)}function Ur(t){void 0===t.round&&function({type:t}){return"point"===t||"band"===t}(t)&&function({scale:t}){const e=t.domain().length,[n,r]=t.range(),o=t.paddingInner?t.paddingInner():1,i=t.paddingOuter?t.paddingOuter():t.padding(),a=e-o,l=Math.abs(r-n)/Math.max(1,a+2*i);return(l-Math.floor(l))*a}(t)<=30&&t.scale.round(!0)}function Vr(t){const e=t.scale.domain().length+eo(t);if(!(e>2))return t.range;const[n,r]=t.range;return Array.from({length:e},((t,o)=>n+o/(e-1)*(r-n)))}function Hr(t,e,n){return Zr(t,void 0===n?void 0:[{hint:n}],{...e})}function Zr(t,n=[],r={}){const o=function(t,e,{type:n,domain:r,range:o,scheme:i,pivot:a,projection:l}){if("fx"===t||"fy"===t)return"band";"x"!==t&&"y"!==t||null==l||(n=Jr);for(const{type:t}of e)if(void 0!==t)if(void 0===n)n=t;else if(n!==t)throw new Error(`scale incompatible with channel: ${n} !== ${t}`);if(n===Jr)return;if(void 0!==n)return n;if(void 0===r&&!e.some((({value:t})=>void 0!==t)))return;const s=ae.get(t);if(s===ee)return"sqrt";if(s===re||s===ne)return"linear";if(s===oe)return"ordinal";if((r||o||[]).length>2)return Kr(s);if(void 0!==r){if(Wt(r))return Kr(s);if(jt(r))return"utc"}else{const t=e.map((({value:t})=>t)).filter((t=>void 0!==t));if(t.some(Wt))return Kr(s);if(t.some(jt))return"utc"}if(s===te){if(null!=a||function(t){return null!=t&&fr.has(`${t}`.toLowerCase())}(i))return"diverging";if(function(t){return null!=t&&tr.has(`${t}`.toLowerCase())}(i))return"categorical"}return"linear"}(t,n,r);if(void 0===r.type&&void 0===r.domain&&void 0===r.range&&null==r.interval&&"fx"!==t&&"fy"!==t&&to({type:o})){const e=n.map((({value:t})=>t)).filter((t=>void 0!==t));e.some(jt)?yn(`Warning: some data associated with the ${t} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${Qr(o)}" 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 "${Qr(o)}".`):e.some(qt)?yn(`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 "${Qr(o)}" 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 "${Qr(o)}".`):e.some(Dt)&&yn(`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 "${Qr(o)}" 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 "${Qr(o)}".`)}switch(r.type=o,o){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":r=ro(n,r,J);break;case"identity":switch(ae.get(t)){case Kt:r=ro(n,r,J);break;case oe:r=ro(n,r,oo)}break;case"utc":case"time":r=ro(n,r,tt)}switch(o){case"diverging":return function(t,n,r){return Sr(t,e.scaleDiverging(),Or,n,r)}(t,n,r);case"diverging-sqrt":return function(t,e,n){return zr(t,e,{...n,exponent:.5})}(t,n,r);case"diverging-pow":return zr(t,n,r);case"diverging-log":return function(t,n,{base:r=10,pivot:o=1,domain:i=xr(n,o<0?s:l),...a}){return Sr(t,e.scaleDivergingLog().base(r=+r),Rr,n,{domain:i,pivot:o,...a})}(t,n,r);case"diverging-symlog":return Er(t,n,r);case"categorical":case"ordinal":case Br:return Ir(t,n,r);case"cyclical":case"sequential":case"linear":return function(t,n,r){return yr(t,e.scaleLinear(),n,r)}(t,n,r);case"sqrt":return function(t,e,n){return gr(t,e,{...n,exponent:.5})}(t,n,r);case"threshold":return vr(t,0,r);case"quantile":return function(t,n,{range:r,quantiles:o=(void 0===r?5:(r=[...r]).length),n:i=o,scheme:a="rdylbu",domain:l=Lr(n),unknown:s,interpolate:c,reverse:u}){return void 0===r&&(r=void 0!==c?e.quantize(c,i):ae.get(t)===te?sr(a,i):void 0),l.length>0&&(l=e.scaleQuantile(l,void 0===r?{length:i}:r).quantiles()),vr(t,0,{domain:l,range:r,reverse:u,unknown:s})}(t,n,r);case"quantize":return function(t,n,{range:r,n:o=(void 0===r?5:(r=[...r]).length),scheme:i="rdylbu",domain:a=wr(t,n),unknown:l,interpolate:s,reverse:c}){const[u,f]=e.extent(a);let h;return void 0===r?(h=e.ticks(u,f,o),h[0]<=u&&h.splice(0,1),h[h.length-1]>=f&&h.pop(),o=h.length+1,r=void 0!==s?e.quantize(s,o):ae.get(t)===te?sr(i,o):void 0):(h=e.quantize(e.interpolateNumber(u,f),o+1).slice(1,-1),u instanceof Date&&(h=h.map((t=>new Date(t))))),Qt(lt(a))<0&&h.reverse(),vr(t,0,{domain:h,range:r,reverse:c,unknown:l})}(t,n,r);case"pow":return gr(t,n,r);case"log":return function(t,n,{base:r=10,domain:o=Mr(n),...i}){return yr(t,e.scaleLog().base(r),n,{...i,domain:o})}(t,n,r);case"symlog":return function(t,n,{constant:r=1,...o}){return yr(t,e.scaleSymlog().constant(r),n,o)}(t,n,r);case"utc":return function(t,n,r){return Tr(t,e.scaleUtc(),n,r)}(t,n,r);case"time":return function(t,n,r){return Tr(t,e.scaleTime(),n,r)}(t,n,r);case"point":return function(t,n,{align:r=.5,padding:o=.5,...i}){return Pr(e.scalePoint().align(r).padding(o),n,i,t)}(t,n,r);case"band":return function(t,n,{align:r=.5,padding:o=.1,paddingInner:i=o,paddingOuter:a=("fx"===t||"fy"===t?0:o),...l}){return Pr(e.scaleBand().align(r).paddingInner(i).paddingOuter(a),n,l,t)}(t,n,r);case"identity":return function(t){return{type:"identity",scale:(n=ae.get(t),n===Kt||n===ee||n===ne||n===re?e.scaleIdentity():t=>t)};var n}(t);case void 0:return;default:throw new Error(`unknown scale type: ${o}`)}}function Qr(t){return"symbol"==typeof t?t.description:t}const Jr={toString:()=>"projection"};function Kr(t){switch(t){case Kt:return"point";case te:return Br;default:return"ordinal"}}function to({type:t}){return"ordinal"===t||"point"===t||"band"===t||t===Br}function eo({type:t}){return"threshold"===t}function no(t){if(void 0===t)return!0;const e=t.domain(),n=t(e[0]);for(let r=1,o=e.length;rt,invert:t=>t};const c=t.unknown?t.unknown():void 0;return{type:e,domain:ct(n),...void 0!==r&&{range:ct(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:e=>t(e),...t.invert&&{invert:e=>t.invert(e)}}}function ao({x:t,y:e,fy:n,fx:r},{projection:o,aspectRatio:i},{width:a,marginTopDefault:l,marginRightDefault:s,marginBottomDefault:c,marginLeftDefault:u}){const f=n?n.scale.domain().length:1,h=function(t){if("function"==typeof t?.stream)return Yn;if(dt(t)&&(t=t.type),null!=t){if("function"!=typeof t){const{aspectRatio:e}=Gn(t);if(e)return e}return Yn}}(o);if(h){const t=(1.1*f-.1)/(1.1*(r?r.scale.domain().length:1)-.1)*h,e=Math.max(.1,Math.min(10,t));return Math.round((a-u-s)*e+l+c)}const d=e?to(e)?e.scale.domain().length:Math.max(7,17/f):1;if(null!=i){if(i=+i,!(isFinite(i)&&i>0))throw new Error(`invalid aspectRatio: ${i}`);const o=lo("y",e)/(lo("x",t)*i),f=r?r.scale.bandwidth():1,h=n?n.scale.bandwidth():1;return(o*(f*(a-u-s)-t.insetLeft-t.insetRight)+e.insetTop+e.insetBottom)/h+l+c}return!(!e&&!n)*Math.max(1,Math.min(60,d*f))*20+30*!!r+60}function lo(t,n){if(!n)throw new Error(`aspectRatio requires ${t} scale`);const{type:r,domain:o}=n;let i;switch(r){case"linear":case"utc":case"time":i=Number;break;case"pow":{const t=n.scale.exponent();i=e=>Math.pow(e,t);break}case"log":i=Math.log;break;case"point":case"band":return o.length;default:throw new Error(`unsupported ${t} scale for aspectRatio: ${r}`)}const[a,l]=e.extent(o);return Math.abs(i(l)-i(a))}function so(t,{fx:n,fy:r}){const o=wt(t),i=n?.value,a=r?.value;return n&&r?e.rollup(o,(t=>(t.fx=i[t[0]],t.fy=a[t[0]],t)),(t=>i[t]),(t=>a[t])):n?e.rollup(o,(t=>(t.fx=i[t[0]],t)),(t=>i[t])):e.rollup(o,(t=>(t.fy=a[t[0]],t)),(t=>a[t]))}function co(t){const n=[],r=new Uint32Array(e.sum(t,(t=>t.length)));for(const e of t){let o=0;for(const n of t)e!==n&&(r.set(n,o),o+=n.length);n.push(r.slice(0,o))}return n}const uo=new Map([["top",yo],["right",xo],["bottom",go],["left",vo],["top-left",wo(yo,vo)],["top-right",wo(yo,xo)],["bottom-left",wo(go,vo)],["bottom-right",wo(go,xo)],["top-empty",function(t,{y:e},{x:n,y:r,empty:o}){if(o)return!1;if(!e)return;const i=po(e,r);if(i>0)return mo(t,n,e[i-1])}],["right-empty",function(t,{x:e},{x:n,y:r,empty:o}){if(o)return!1;if(!e)return;const i=po(e,n);if(i0)return mo(t,e[i-1],r)}],["empty",function(t,e,{empty:n}){return n}]]);const fo=new WeakMap;function ho(t){let n=fo.get(t);return n||fo.set(t,n=new e.InternMap(st(t,((t,e)=>[t,e])))),n}function po(t,e){return ho(t).get(e)}function mo(t,e,n){return function(t,e,n){return e=Mt(e),n=Mt(n),t.find((t=>Object.is(Mt(t.x),e)&&Object.is(Mt(t.y),n)))}(t,e,n)?.empty}function yo(t,{y:e},{y:n}){return!e||0===po(e,n)}function go(t,{y:e},{y:n}){return!e||po(e,n)===e.length-1}function vo(t,{x:e},{x:n}){return!e||0===po(e,n)}function xo(t,{x:e},{x:n}){return!e||po(e,n)===e.length-1}function wo(t,e){return function(){return t.apply(null,arguments)&&e.apply(null,arguments)}}function bo(t,{channels:{fx:e,fy:n},groups:r}){return e&&n?t.map((({x:t,y:e})=>r.get(t)?.get(e)??[])):e?t.map((({x:t})=>r.get(t)??[])):t.map((({y:t})=>r.get(t)??[]))}class ko{constructor(t,e={},n={},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:m=f,clip:y=r?.clip,channels:g,tip:v,render:x}=n;if(this.data=t,this.sort=yt(s)?s:null,this.initializer=me(n).initializer,this.transform=this.initializer?n.transform:pe(n).transform,null===o||!1===o?this.facet=null:(this.facet=at(!0===o?"include":o,"facet",["auto","include","exclude","super"]),this.fx=t===j&&"string"==typeof a?[a]:a,this.fy=t===j&&"string"==typeof l?[l]:l),this.facetAnchor=function(t){if(null==t)return null;const e=uo.get(`${t}`.toLowerCase());if(e)return e;throw new Error(`invalid facet anchor: ${t}`)}(i),e=Jt(e),void 0!==g&&(e={...Lo(g),...e}),void 0!==r&&(e={...wn(this,n,r),...e}),this.channels=Object.fromEntries(Object.entries(e).map((([e,n])=>{if(mt(n.value)){const{value:t,label:e=n.label,scale:r=n.scale}=n.value;n={...n,label:e,scale:r,value:t}}if(t===j&&"string"==typeof n.value){const{value:t}=n;n={...n,value:[t]}}return[e,n]})).filter((([t,{value:e,optional:n}])=>{if(null!=e)return!0;if(n)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=+m,this.clip=Sn(y),this.tip=function(t){return!0===t?"xy":!1===t||null==t?null:"string"==typeof t?at(t,"tip",["x","y","xy"]):t}(v),"super"===this.facet){if(a||l)throw new Error("super-faceting cannot use fx or fy");for(const t in this.channels){const{scale:n}=e[t];if("x"===n||"y"===n)throw new Error("super-faceting cannot use x or y")}}null!=x&&(this.render=Mo(x,this.render))}initialize(t,n,r){let o=lt(this.data);void 0===t&&null!=o&&(t=[wt(o)]);const i=t;null!=this.transform&&(({facets:t,data:o}=this.transform(o,t,r)),o=lt(o)),void 0!==t&&(t.original=i);const a=Ze(this.channels,o);return null!=this.sort&&function(t,n,r,o,i){const{order:a,reverse:l,reduce:s=!0,limit:c}=i;for(const u in i){if(!ae.has(u))continue;let{value:f,order:h=a,reverse:d=l,reduce:p=s,limit:m=c}=Nt(i[u]);const y=f?.startsWith("-");if(y&&(f=f.slice(1)),h=void 0===h?y!==("width"===f||"height"===f)?an:on:rn(h),null==p||!1===p)continue;const g="fx"===u||"fy"===u?tn(n,o[u]):Ke(r,u);if(!g)throw new Error(`missing channel for scale: ${u}`);const v=g.value,[x=0,w=1/0]=It(m)?m:m<0?[m]:[0,m];if(null==f)g.domain=()=>{let t=Array.from(new e.InternSet(v));return d&&(t=t.reverse()),0===x&&w===1/0||(t=t.slice(x,w)),t};else{const n="data"===f?t:"height"===f?en(r,"y1","y2"):"width"===f?en(r,"x1","x2"):nn(r,f,"y"===f?"y2":"x"===f?"x2":void 0),o=Ne(!0===p?"max":p,n);g.domain=()=>{let t=e.rollups(wt(v),(t=>o.reduceIndex(t,n)),(t=>v[t]));return h&&t.sort(h),d&&t.reverse(),0===x&&w===1/0||(t=t.slice(x,w)),t.map(U)}}}}(o,t,a,n,this.sort),{data:o,facets:t,channels:a}}filter(t,e,r){for(const o in e){const{filter:i=n}=e[o];if(null!==i){const e=r[o];t=t.filter((t=>i(e[t])))}}return t}project(t,e,n){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&&Zn(r,o,e,n.projection)}}scale(t,e,n){const r=Qe(t,e);return n.projection&&this.project(t,r,n),r}}function $o(...t){return t.plot=ko.prototype.plot,t}function Mo(t,e){if(null==t)return null===e?void 0:e;if(null==e)return null===t?void 0:t;if("function"!=typeof t)throw new TypeError(`invalid render transform: ${t}`);if("function"!=typeof e)throw new TypeError(`invalid render transform: ${e}`);return function(n,r,o,i,a,l){return t.call(this,n,r,o,i,a,((t,n,r,o,i)=>e.call(this,t,n,r,o,i,l)))}}function Lo(t){return Object.fromEntries(Object.entries(Jt(t)).map((([t,e])=>(void 0===(e="string"==typeof e?{value:e,label:t}:Nt(e)).filter&&null==e.scale&&(e={...e,filter:null}),[t,e]))))}function Ao(t,e){return!0===t?.tip?{...t,tip:e}:dt(t?.tip)&&void 0===t.tip.pointer?{...t,tip:{...t.tip,pointer:e}}:t}const So=new WeakMap;function zo(t,n,{x:r,y:o,px:i,py:a,maxRadius:l=40,channels:s,render:c,...u}={}){return l=+l,null!=i&&(r??=null,s={...s,px:{value:i,scale:"x"}}),null!=a&&(o??=null,s={...s,py:{value:a,scale:"y"}}),{x:r,y:o,channels:s,...u,render:Mo((function(r,o,i,a,s,c){const u=(s={...s,pointerSticky:!1}).ownerSVGElement,{data:f}=s.getMarkState(this);let h=So.get(u);h||So.set(u,h={sticky:!1,roots:[],renders:[]});let d=h.renders.push(T)-1;const{x:p,y:m,fx:y,fy:g}=o;let v=y?y(r.fx)-a.marginLeft:0,x=g?g(r.fy)-a.marginTop:0;p?.bandwidth&&(v+=p.bandwidth()/2),m?.bandwidth&&(x+=m.bandwidth()/2);const w=null!=r.fi;let b;if(w){let t=h.facetStates;t||(h.facetStates=t=new Map),b=t.get(this),b||t.set(this,b=new Map)}const[k,$]=Wn(this,a),{px:M,py:L}=i,A=M?t=>M[t]:Co(i,k),S=L?t=>L[t]:To(i,$);let z,E,O,R;function C(t,e){if(w){if(R&&(R=cancelAnimationFrame(R)),null!=t)return b.set(r.fi,e),void(R=requestAnimationFrame((()=>{R=null;for(const[n,o]of b)if(o1||s.dispatchValue(null==z?null:f[z]),n}function B(o){if(h.sticky||"mouse"===o.pointerType&&1===o.buttons)return;let[i,s]=e.pointer(o);i-=v,s-=x;const c=ia.width-a.marginRight?1:t,u=sa.height-a.marginBottom?1:n;let f=null,d=l*l;for(const t of r){const e=c*(A(t)-i),n=u*(S(t)-s),r=e*e+n*n;r<=d&&(f=t,d=r)}if(null!=f&&(1!==t||1!==n)){const t=A(f)-i,e=S(f)-s;d=t*t+e*e}C(f,d)}return u.addEventListener("pointerenter",B),u.addEventListener("pointermove",B),u.addEventListener("pointerdown",(function(t){"mouse"===t.pointerType&&null!=z&&(h.sticky&&h.roots.some((e=>e?.contains(t.target)))||(h.sticky?(h.sticky=!1,h.renders.forEach((t=>t(null)))):(h.sticky=!0,T(z)),t.stopImmediatePropagation()))})),u.addEventListener("pointerleave",(function(t){"mouse"===t.pointerType&&(h.sticky||C(null))})),T(null)}),c)}}function Eo(t){return zo(1,1,t)}function Oo(t){return zo(1,.01,t)}function Ro(t){return zo(.01,1,t)}function Co({x1:t,x2:e,x:n=t},r){return t&&e?n=>(t[n]+e[n])/2:n?t=>n[t]:()=>r}function To({y1:t,y2:e,y:n=t},r){return t&&e?n=>(t[n]+e[n])/2:n?t=>n[t]:()=>r}function Bo(t){return to(t)&&void 0===t.interval?void 0:"tabular-nums"}const No=Math.PI/180;function Io(t,{marker:e,markerStart:n=e,markerMid:r=e,markerEnd:o=e}={}){t.markerStart=Po(n),t.markerMid=Po(r),t.markerEnd=Po(o)}function Po(t){if(null==t||!1===t)return null;if(!0===t)return qo;if("function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"none":return null;case"arrow":return Wo("auto");case"arrow-reverse":return Wo("auto-start-reverse");case"dot":return jo;case"circle":case"circle-fill":return qo;case"circle-stroke":return Do}throw new Error(`invalid marker: ${t}`)}function Wo(t){return(e,n)=>qn("svg:marker",n).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("orient",t).attr("fill","none").attr("stroke",e).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 jo(t,e){return qn("svg:marker",e).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 qo(t,e){return qn("svg:marker",e).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill",t).attr("stroke","white").attr("stroke-width",1.5).call((t=>t.append("circle").attr("r",3))).node()}function Do(t,e){return qn("svg:marker",e).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill","white").attr("stroke",t).attr("stroke-width",1.5).call((t=>t.append("circle").attr("r",3))).node()}let Fo=0;function Yo(t,e,{stroke:n},r){return Go(t,e,n&&(t=>n[t]),r)}function _o(t,e,{stroke:n},r){return Go(t,e,n&&(([t])=>n[t]),r)}function Go(t,{markerStart:e,markerMid:n,markerEnd:r,stroke:o},i=(()=>o),a){const l=new Map;function s(t){return function(e){const n=i(e);let r=l.get(t);r||l.set(t,r=new Map);let o=r.get(n);if(!o){const e=this.parentNode.insertBefore(t(n,a),this),i="plot-marker-"+ ++Fo;e.setAttribute("id",i),r.set(n,o=`url(#${i})`)}return o}}e&&t.attr("marker-start",s(e)),n&&t.attr("marker-mid",s(n)),r&&t.attr("marker-end",s(r))}function Xo({inset:t,insetLeft:e,insetRight:n,...r}={}){return[e,n]=Vo(t,e,n),{inset:t,insetLeft:e,insetRight:n,...r}}function Uo({inset:t,insetTop:e,insetBottom:n,...r}={}){return[e,n]=Vo(t,e,n),{inset:t,insetTop:e,insetBottom:n,...r}}function Vo(t,e,n){return void 0===t&&void 0===e&&void 0===n?gn?[1,0]:[.5,.5]:[e,n]}function Ho(t,{interval:e}){return(t={...Nt(t)}).interval=Ct(void 0===t.interval?e:t.interval),t}function Zo(t,e,n,r){const{[t]:o,[`${t}1`]:i,[`${t}2`]:a}=n,{value:l,interval:s}=Ho(o,n);if(null==l||null==s&&!r)return n;const c=zt(o);if(null==s){let e;const r={transform:t=>e||(e=I(t,l)),label:c};return{...n,[t]:void 0,[`${t}1`]:void 0===i?r:i,[`${t}2`]:void 0===a?r:a}}let u,f;function h(t){return void 0!==f&&t===u?f:f=st(I(u=t,l),(t=>s.floor(t)))}return e({...n,[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 Qo(t,e,n){const{[t]:r}=n,{value:o,interval:i}=Ho(r,n);return null==o||null==i?n:e({...n,[t]:{label:zt(r),transform:t=>{const e=st(I(t,o),(t=>i.floor(t))),n=e.map((t=>i.offset(t)));return e.map(jt(e)?(t,e)=>null==t||isNaN(t=+t)||null==(e=n[e])||isNaN(e=+e)?void 0:new Date((t+e)/2):(t,e)=>null==t||null==(e=n[e])?NaN:(+t+ +e)/2)}}})}function Jo(t={}){return Zo("x",Xo,t,!0)}function Ko(t={}){return Zo("y",Uo,t,!0)}function ti(t={}){return Zo("x",Xo,t)}function ei(t={}){return Zo("y",Uo,t)}function ni(t={}){return Qo("x",Xo,t)}function ri(t={}){return Qo("y",Uo,t)}const oi={ariaLabel:"rule",fill:null,stroke:"currentColor"};class ii extends ko{constructor(t,e={}){const{x:n,y1:r,y2:o,inset:i=0,insetTop:a=i,insetBottom:l=i}=e;super(t,{x:{value:n,scale:"x",optional:!0},y1:{value:r,scale:"y",optional:!0},y2:{value:o,scale:"y",optional:!0}},Ao(e,"x"),oi),this.insetTop=X(a),this.insetBottom=X(l),Io(this,e)}render(t,e,n,r,o){const{x:i,y:a}=e,{x:l,y1:s,y2:c}=n,{width:u,height:f,marginTop:h,marginRight:d,marginLeft:p,marginBottom:m}=r,{insetTop:y,insetBottom:g}=this;return qn("svg:g",o).call(zn,this,r,o).call(Cn,this,{x:l&&i},gn,0).call((e=>e.selectAll().data(t).enter().append("line").call(En,this).attr("x1",l?t=>l[t]:(p+u-d)/2).attr("x2",l?t=>l[t]:(p+u-d)/2).attr("y1",s&&!no(a)?t=>s[t]+y:h+y).attr("y2",c&&!no(a)?a.bandwidth?t=>c[t]+a.bandwidth()-g:t=>c[t]-g:f-m-g).call($n,this,n).call(Yo,this,n,o))).node()}}class ai extends ko{constructor(t,e={}){const{x1:n,x2:r,y:o,inset:i=0,insetRight:a=i,insetLeft:l=i}=e;super(t,{y:{value:o,scale:"y",optional:!0},x1:{value:n,scale:"x",optional:!0},x2:{value:r,scale:"x",optional:!0}},Ao(e,"y"),oi),this.insetRight=X(a),this.insetLeft=X(l),Io(this,e)}render(t,e,n,r,o){const{x:i,y:a}=e,{y:l,x1:s,x2:c}=n,{width:u,height:f,marginTop:h,marginRight:d,marginLeft:p,marginBottom:m}=r,{insetLeft:y,insetRight:g}=this;return qn("svg:g",o).call(zn,this,r,o).call(Cn,this,{y:l&&a},0,gn).call((e=>e.selectAll().data(t).enter().append("line").call(En,this).attr("x1",s&&!no(i)?t=>s[t]+y:p+y).attr("x2",c&&!no(i)?i.bandwidth?t=>c[t]+i.bandwidth()-g:t=>c[t]-g:u-d-g).attr("y1",l?t=>l[t]:(h+f-m)/2).attr("y2",l?t=>l[t]:(h+f-m)/2).call($n,this,n).call(Yo,this,n,o))).node()}}function li(t,e){let{x:n=F,y:r,y1:o,y2:i,...a}=ei(e);return[o,i]=ci(r,o,i),new ii(t,{...a,x:n,y1:o,y2:i})}function si(t,e){let{y:n=F,x:r,x1:o,x2:i,...a}=ti(e);return[o,i]=ci(r,o,i),new ai(t,{...a,y:n,x1:o,x2:i})}function ci(t,e,n){if(null==t){if(void 0===e){if(void 0!==n)return[0,n]}else if(void 0===n)return[0,e]}else{if(void 0===e)return void 0===n?[0,t]:[t,n];if(void 0===n)return[t,e]}return[e,n]}function ui(t,...e){let n=e.length;for(let r=0,o=!0;r{let o=t[0];for(let i=0;iI(t,$,Float64Array),label:zt($)}),optional:!0},text:{value:o,filter:i,optional:!0}},e,fi),this.rotate=w,this.textAnchor=Tn(l,"middle"),this.lineAnchor=at(s,"lineAnchor",["top","middle","bottom"]),this.lineHeight=+c,this.lineWidth=+u,this.textOverflow=pi(f),this.monospace=!!h,this.fontFamily=G(d),this.fontSize=k,this.fontStyle=G(m),this.fontVariant=G(y),this.fontWeight=G(g),this.frameAnchor=Zt(a),!(this.lineWidth>=0))throw new Error(`invalid lineWidth: ${u}`);this.splitLines=Li(this),this.clipLine=Ai(this)}render(t,e,n,r,o){const{x:i,y:a}=e,{x:l,y:s,rotate:c,text:u,title:f,fontSize:h}=n,{rotate:d}=this,[p,m]=Wn(this,r);return qn("svg:g",o).call(zn,this,r,o).call(xi,this,u,r).call(Cn,this,{x:l&&i,y:s&&a}).call((e=>e.selectAll().data(t).enter().append("text").call(En,this).call(mi,this,u,f).attr("transform",ui`translate(${l?t=>l[t]:p},${s?t=>s[t]:m})${c?t=>` rotate(${c[t]})`:d?` rotate(${d})`:""}`).call(Rn,"font-size",h&&(t=>h[t])).call($n,this,n))).node()}}function pi(t){return null==t?null:at(t,"textOverflow",["clip","ellipsis","clip-start","clip-end","ellipsis-start","ellipsis-middle","ellipsis-end"]).replace(/^(clip|ellipsis)$/,"$1-end")}function mi(t,n,r,o){if(!r)return;const{lineAnchor:i,lineHeight:a,textOverflow:l,splitLines:s,clipLine:c}=n;t.each((function(t){const n=s(dn(r[t])??"").map(c),u=n.length,f="top"===i?.71:"bottom"===i?1-u:(164-100*u)/200;if(u>1){let t=0;for(let r=0;ro&&n(t,o,l)>e&&(r.push(t.slice(o,i)+(t[i-1]===hi?"-":"")),o=a),s?(r.push(t.slice(o,l)),o=void 0):i=l;return r}const ki={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 $i(t,e=0,n=t.length){let r=0;for(let o=e;ot.split(/\r\n?|\n/g);const r=t?Mi:$i,o=100*e;return t=>bi(t,o,r)}function Ai({monospace:t,lineWidth:e,textOverflow:n}){if(null==n||e==1/0)return t=>t;const r=t?Mi:$i,o=100*e;switch(n){case"clip-start":return t=>Oi(t,o,r,"");case"clip-end":return t=>Ei(t,o,r,"");case"ellipsis-start":return t=>Oi(t,o,r,Si);case"ellipsis-middle":return t=>function(t,e,n,r){t=t.trim();const o=n(t);if(o<=e)return t;const i=n(r)/2,[a,l]=zi(t,e/2,n,i),[s]=zi(t,o-e/2-l+i,n,-i);return s<0?r:t.slice(0,a).trimEnd()+r+t.slice(Ti(t,s)).trimStart()}(t,o,r,Si);case"ellipsis-end":return t=>Ei(t,o,r,Si)}}const Si="…";function zi(t,e,n,r){const o=[];let i=0;for(let a=0,l=0,s=t.length;ae){for(i+=r;i>e&&a>0;)l=a,a=o.pop(),i-=n(t,a,l);return[a,e-i]}i+=s,o.push(a)}return[-1,0]}function Ei(t,e,n,r){t=t.trim();const o=n(r),[i]=zi(t,e,n,o);return i<0?t:t.slice(0,i).trimEnd()+r}function Oi(t,e,n,r){const o=n(t=t.trim());if(o<=e)return t;const i=n(r),[a]=zi(t,o-e+i,n,-i);return a<0?r:r+t.slice(Ti(t,a)).trimStart()}const Ri=/[\p{Combining_Mark}\p{Emoji_Modifier}]+/uy,Ci=/\p{Extended_Pictographic}/uy;function Ti(t,e){return e+=function(t,e){const n=t.charCodeAt(e);if(n>=55296&&n<56320){const n=t.charCodeAt(e+1);return n>=56320&&n<57344}return!1}(t,e)?2:1,function(t,e){return!Bi(t,e)&&(Ri.lastIndex=e,Ri.test(t))}(t,e)&&(e=Ri.lastIndex),function(t,e){return 8205===t.charCodeAt(e)}(t,e)?Ti(t,e+1):e}function Bi(t,e){return t.charCodeAt(e)<128}function Ni(t,e){return!Bi(t,e)&&(Ci.lastIndex=e,Ci.test(t))}const Ii={ariaLabel:"vector",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"},Pi=3.5,Wi=5*Pi,ji={draw(t,e,n){const r=e*n/Wi;t.moveTo(0,0),t.lineTo(0,-e),t.moveTo(-r,r-e),t.lineTo(0,-e),t.lineTo(r,r-e)}},qi={draw(t,e,n){t.moveTo(-n,0),t.lineTo(0,-e),t.lineTo(n,0)}},Di=new Map([["arrow",ji],["spike",qi]]);class Fi extends ko{constructor(t,e={}){const{x:n,y:r,r:o=Pi,length:i,rotate:a,shape:l=ji,anchor:s="middle",frameAnchor:c}=e,[u,f]=rt(i,12),[h,d]=rt(a,0);super(t,{x:{value:n,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},length:{value:u,scale:"length",optional:!0},rotate:{value:h,optional:!0}},e,Ii),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 e=Di.get(`${t}`.toLowerCase());if(e)return e;throw new Error(`invalid shape: ${t}`)}(l),this.anchor=at(s,"anchor",["start","middle","end"]),this.frameAnchor=Zt(c)}render(t,n,r,o,i){const{x:a,y:l}=n,{x:s,y:c,length:u,rotate:f}=r,{length:h,rotate:d,anchor:p,shape:m,r:y}=this,[g,v]=Wn(this,o);return qn("svg:g",i).call(zn,this,o,i).call(Cn,this,{x:s&&a,y:c&&l}).call((n=>n.selectAll().data(t).enter().append("path").call(En,this).attr("transform",ui`translate(${s?t=>s[t]:g},${c?t=>c[t]:v})${f?t=>` rotate(${f[t]})`:d?` rotate(${d})`:""}${"start"===p?"":"end"===p?u?t=>` translate(0,${u[t]})`:` translate(0,${h})`:u?t=>` translate(0,${u[t]/2})`:` translate(0,${h/2})`}`).attr("d",u?t=>{const n=e.pathRound();return m.draw(n,u[t],y),n}:(()=>{const t=e.pathRound();return m.draw(t,h,y),t})()).call($n,this,r))).node()}}function Yi(t,e={}){let{x:n,y:r,...o}=e;return void 0===e.frameAnchor&&([n,r]=vt(n,r)),new Fi(t,{...o,x:n,y:r})}function _i(t,e={}){const{x:n=F,...r}=e;return new Fi(t,{...r,x:n})}function Gi(t,e={}){const{y:n=F,...r}=e;return new Fi(t,{...r,y:n})}function Xi(t,e){return arguments.length<2&&!It(t)&&(e=t,t=null),void 0===e&&(e={}),[t,e]}function Ui({anchor:t}={},e){return void 0===t?e[0]:at(t,"anchor",e)}function Vi(t){return Ui(t,["left","right"])}function Hi(t){return Ui(t,["right","left"])}function Zi(t){return Ui(t,["bottom","top"])}function Qi(t){return Ui(t,["top","bottom"])}function Ji(){const[t,e]=Xi(...arguments);return na("y",Vi(e),t,e)}function Ki(){const[t,e]=Xi(...arguments);return na("fy",Hi(e),t,e)}function ta(){const[t,e]=Xi(...arguments);return ra("x",Zi(e),t,e)}function ea(){const[t,e]=Xi(...arguments);return ra("fx",Qi(e),t,e)}function na(t,e,n,{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:m,tickRotate:y,x:g,margin:v,marginTop:x=(void 0===v?20:v),marginRight:w=(void 0===v?"right"===e?40:0:v),marginBottom:b=(void 0===v?20:v),marginLeft:k=(void 0===v?"left"===e?40:0:v),label:$,labelAnchor:M,labelArrow:L,labelOffset:A,...S}){return p=X(p),m=X(m),y=X(y),void 0!==M&&(M=at(M,"labelAnchor",["center","top","bottom"])),L=ka(L),$o(p&&!Ut(i)?function(t,e,n,{strokeWidth:r=1,strokeLinecap:o=null,strokeLinejoin:i=null,facetAnchor:a=e+("y"===t?"-empty":""),frameAnchor:l=e,tickSize:s,inset:c=0,insetLeft:u=c,insetRight:f=c,dx:h=0,y:d=("y"===t?void 0:null),...p}){return ha(Gi,t,e,`${t}-axis tick`,n,{strokeWidth:r,strokeLinecap:o,strokeLinejoin:i,facetAnchor:a,frameAnchor:l,y:d,...p,dx:"left"===e?+h-gn+ +u:+h+gn-f,anchor:"start",length:s,shape:"left"===e?va:xa})}(t,e,n,{stroke:i,strokeOpacity:a,strokeWidth:l,tickSize:p,tickPadding:m,tickRotate:y,x:g,...S}):null,Ut(s)?null:function(t,e,n,{facetAnchor:r=e+("y"===t?"-empty":""),frameAnchor:o=e,tickSize:i,tickRotate:a=0,tickPadding:l=Math.max(3,9-i)+(Math.abs(a)>60?4*Math.cos(a*No):0),text:s,textAnchor:c=(Math.abs(a)>60?"middle":"left"===e?"end":"start"),lineAnchor:u=(a>60?"top":a<-60?"bottom":"middle"),fontVariant:f,inset:h=0,insetLeft:d=h,insetRight:p=h,dx:m=0,y:y=("y"===t?void 0:null),...g}){return ha(vi,t,e,`${t}-axis tick label`,n,{facetAnchor:r,frameAnchor:o,text:s,textAnchor:c,lineAnchor:u,fontVariant:f,rotate:a,y:y,...g,dx:"left"===e?+m-i-l+ +d:+m+ +i+ +l-p},(function(t,n,r,o,i){void 0===f&&(this.fontVariant=wa(t)),void 0===s&&(i.text=da(t,n,r,o,e))}))}(t,e,n,{fill:s,fillOpacity:c,stroke:f,strokeOpacity:h,strokeWidth:d,textAnchor:u,tickSize:p,tickPadding:m,tickRotate:y,x:g,marginTop:x,marginRight:w,marginBottom:b,marginLeft:k,...S}),Ut(s)||null===$?null:yi([],fa({fill:s,fillOpacity:c,...S},(function(n,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=A??("right"===e?c:f)-3;return"center"===h?(this.textAnchor=void 0,this.lineAnchor="right"===e?"bottom":"top",this.frameAnchor=e,this.rotate=-90):(this.textAnchor="right"===e?"end":"start",this.lineAnchor=h,this.frameAnchor=`${h}-${e}`,this.rotate=0),this.dy="top"===h?3-s:"bottom"===h?u-3:0,this.dx="right"===e?d:-d,this.ariaLabel=`${t}-axis label`,{facets:[[0]],channels:{text:{value:[ba(t,l,{anchor:e,label:$,labelAnchor:h,labelArrow:L})]}}}}))))}function ra(t,e,n,{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:m,tickRotate:y,y:g,margin:v,marginTop:x=(void 0===v?"top"===e?30:0:v),marginRight:w=(void 0===v?20:v),marginBottom:b=(void 0===v?"bottom"===e?30:0:v),marginLeft:k=(void 0===v?20:v),label:$,labelAnchor:M,labelArrow:L,labelOffset:A,...S}){return p=X(p),m=X(m),y=X(y),void 0!==M&&(M=at(M,"labelAnchor",["center","left","right"])),L=ka(L),$o(p&&!Ut(i)?function(t,e,n,{strokeWidth:r=1,strokeLinecap:o=null,strokeLinejoin:i=null,facetAnchor:a=e+("x"===t?"-empty":""),frameAnchor:l=e,tickSize:s,inset:c=0,insetTop:u=c,insetBottom:f=c,dy:h=0,x:d=("x"===t?void 0:null),...p}){return ha(_i,t,e,`${t}-axis tick`,n,{strokeWidth:r,strokeLinejoin:i,strokeLinecap:o,facetAnchor:a,frameAnchor:l,x:d,...p,dy:"bottom"===e?+h-gn-f:+h+gn+ +u,anchor:"start",length:s,shape:"bottom"===e?ya:ga})}(t,e,n,{stroke:i,strokeOpacity:a,strokeWidth:l,tickSize:p,tickPadding:m,tickRotate:y,y:g,...S}):null,Ut(s)?null:function(t,e,n,{facetAnchor:r=e+("x"===t?"-empty":""),frameAnchor:o=e,tickSize:i,tickRotate:a=0,tickPadding:l=Math.max(3,9-i)+(Math.abs(a)>=10?4*Math.cos(a*No):0),text:s,textAnchor:c=(Math.abs(a)>=10?a<0^"bottom"===e?"start":"end":"middle"),lineAnchor:u=(Math.abs(a)>=10?"middle":"bottom"===e?"top":"bottom"),fontVariant:f,inset:h=0,insetTop:d=h,insetBottom:p=h,dy:m=0,x:y=("x"===t?void 0:null),...g}){return ha(gi,t,e,`${t}-axis tick label`,n,{facetAnchor:r,frameAnchor:o,text:void 0===s?null:s,textAnchor:c,lineAnchor:u,fontVariant:f,rotate:a,x:y,...g,dy:"bottom"===e?+m+ +i+ +l-p:+m-i-l+ +d},(function(t,n,r,o,i){void 0===f&&(this.fontVariant=wa(t)),void 0===s&&(i.text=da(t,n,r,o,e))}))}(t,e,n,{fill:s,fillOpacity:c,stroke:f,strokeOpacity:h,strokeWidth:d,textAnchor:u,tickSize:p,tickPadding:m,tickRotate:y,y:g,marginTop:x,marginRight:w,marginBottom:b,marginLeft:k,...S}),Ut(s)||null===$?null:yi([],fa({fill:s,fillOpacity:c,...S},(function(n,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=A??("top"===e?s:u)-3;return"center"===h?(this.frameAnchor=e,this.textAnchor=void 0):(this.frameAnchor=`${e}-${h}`,this.textAnchor="right"===h?"end":"start"),this.lineAnchor=e,this.dy="top"===e?-d:d,this.dx="right"===h?c-3:"left"===h?3-f:0,this.ariaLabel=`${t}-axis label`,{facets:[[0]],channels:{text:{value:[ba(t,l,{anchor:e,label:$,labelAnchor:h,labelArrow:L})]}}}}))))}function oa(){const[t,e]=Xi(...arguments);return sa("y",Vi(e),t,e)}function ia(){const[t,e]=Xi(...arguments);return sa("fy",Hi(e),t,e)}function aa(){const[t,e]=Xi(...arguments);return ca("x",Zi(e),t,e)}function la(){const[t,e]=Xi(...arguments);return ca("fx",Qi(e),t,e)}function sa(t,e,n,{y:r=("y"===t?void 0:null),x:o=null,x1:i=("left"===e?o:null),x2:a=("right"===e?o:null),...l}){return ha(si,t,e,`${t}-grid`,n,{y:r,x1:i,x2:a,...ua(l)})}function ca(t,e,n,{x:r=("x"===t?void 0:null),y:o=null,y1:i=("top"===e?o:null),y2:a=("bottom"===e?o:null),...l}){return ha(li,t,e,`${t}-grid`,n,{x:r,y1:i,y2:a,...ua(l)})}function ua({color:t="currentColor",opacity:e=.1,stroke:n=t,strokeOpacity:r=e,strokeWidth:o=1,...i}){return{stroke:n,strokeOpacity:r,strokeWidth:o,...i}}function fa({fill:t,fillOpacity:e,fontFamily:n,fontSize:r,fontStyle:o,fontVariant:i,fontWeight:a,monospace:l,pointerEvents:s,shapeRendering:c,clip:u=!1},f){return[,t]=nt(t),[,e]=rt(e),{facet:"super",x:null,y:null,fill:t,fillOpacity:e,fontFamily:n,fontSize:r,fontStyle:o,fontVariant:i,fontWeight:a,monospace:l,pointerEvents:s,shapeRendering:c,clip:u,initializer:f}}function ha(t,n,r,o,i,a,l){let s;const c=me(a).initializer,u=t(i,me({...a,initializer:function(t,r,o,i,c,u){const f=null==t&&("fx"===n||"fy"===n),{[n]:h}=i;if(!h)throw new Error(`missing scale: ${n}`);const d=h.domain();let{interval:p,ticks:m,tickFormat:y,tickSpacing:g=("x"===n?80:35)}=a;if("string"==typeof m&&$a(h)&&(p=m,m=void 0),void 0===m&&(m=Tt(p,h.type)??function(t,n){const[r,o]=e.extent(t.range());return(o-r)/n}(h,g)),null==t){if(It(m))t=lt(m);else if(Bt(m))t=ma(m,...e.extent(d));else if(h.interval){let n=h.interval;if(h.ticks){const[r,o]=e.extent(d);n=O(n,(o-r)/n[M]/m)??n,t=ma(n,r,o)}else{n=O(n,(t=d).length/m)??n,n!==h.interval&&(t=ma(n,...e.extent(t)))}if(n===h.interval){const e=Math.round(t.length/m);e>1&&(t=t.filter(((t,n)=>n%e==0)))}}else t=h.ticks?h.ticks(m):d;if(!h.ticks&&t.length&&t!==d){const r=new e.InternSet(d);(t=t.filter((t=>r.has(t)))).length||yn(`Warning: the ${n}-axis ticks appear to not align with the scale domain, resulting in no ticks. Try different ticks?`)}"y"===n||"x"===n?r=[wt(t)]:s[n]={scale:n,value:F}}l?.call(this,h,t,m,y,s);const v=Object.fromEntries(Object.entries(s).map((([e,n])=>[e,{...n,value:I(t,n.value)}])));return f&&(r=u.filterFacets(t,v)),{data:t,facets:r,channels:v}}},c));return null==i?(s=u.channels,u.channels={}):s={},u.ariaLabel=o,void 0===u.clip&&(u.clip=!1),u}function da(t,e,n,r,o){return{value:pa(t,e,n,r,o)}}function pa(t,n,r,o,i){return"function"==typeof o?o:void 0===o&&n&&jt(n)?function(t,n){const r=e.max(e.pairs(t,((t,e)=>Math.abs(e-t))));if(r<1e3)return R("millisecond","utc",n);for(const[e,o,i,a]of A){if(r>a)break;if("hour"===e&&!r)break;if(t.every((t=>o.floor(t)>=t)))return R(e,i,n)}}(n,i)??dn:t.tickFormat?t.tickFormat("number"==typeof r?r:null,o):void 0===o?dn:"string"==typeof o?(jt(t.domain())?e.utcFormat:e.format)(o):Z(o)}function ma(t,e,n){return t.range(e,t.offset(t.floor(n)))}const ya={draw(t,e){t.moveTo(0,0),t.lineTo(0,e)}},ga={draw(t,e){t.moveTo(0,0),t.lineTo(0,-e)}},va={draw(t,e){t.moveTo(0,0),t.lineTo(-e,0)}},xa={draw(t,e){t.moveTo(0,0),t.lineTo(e,0)}};function wa(t){return t.bandwidth&&!t.interval?void 0:"tabular-nums"}function ba(t,e,{anchor:n,label:r=e.label,labelAnchor:o,labelArrow:i}={}){if(!(null==r||r.inferred&&$a(e)&&/^(date|time|year)$/i.test(r))){if(r=String(r),"auto"===i&&(i=(!e.bandwidth||e.interval)&&!/[↑↓→←]/.test(r)),!i)return r;if(!0===i){const n=function(t){return Math.sign(Qt(t.domain()))*Math.sign(Qt(t.range()))}(e);n&&(i=/x$/.test(t)||"center"===o?/x$/.test(t)===n<0?"left":"right":n<0?"up":"down")}switch(i){case"left":return`← ${r}`;case"right":return`${r} →`;case"up":return"right"===n?`${r} ↑`:`↑ ${r}`;case"down":return"right"===n?`${r} ↓`:`↓ ${r}`}return r}}function ka(t="auto"){return!Ut(t)&&("boolean"==typeof t?t:at(t,"labelArrow",["auto","up","right","down","left"]))}function $a(t){return jt(t.domain())}function Ma(t,e){if(null==e)return e;const n=t(e);if(!n)throw new Error(`scale not found: ${e}`);return n}function La(t,e={},n){let{columns:r,tickFormat:o,fontVariant:i=Bo(t),swatchSize:a=15,swatchWidth:l=a,swatchHeight:s=a,marginLeft:c=0,className:u,style:f,width:h}=e;const d=jn(e);u=In(u),o=pa(t.scale,t.domain,void 0,o);const p=qn("div",d).attr("class",`${u}-swatches ${u}-swatches-${null!=r?"columns":"wrap"}`);let m;return null!=r?(m=`.${u}-swatches-columns .${u}-swatch {\n display: flex;\n align-items: center;\n break-inside: avoid;\n padding-bottom: 1px;\n}\n.${u}-swatches-columns .${u}-swatch::before {\n flex-shrink: 0;\n}\n.${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(n,t,l,s).call((t=>t.append("div").attr("class",`${u}-swatch-label`).attr("title",o).text(o)))):(m=`.${u}-swatches-wrap {\n display: flex;\n align-items: center;\n min-height: 33px;\n flex-wrap: wrap;\n}\n.${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(n,t,l,s).append((function(){return this.ownerDocument.createTextNode(o.apply(this,arguments))}))),p.call((t=>t.insert("style","*").text(`.${u}-swatches {\n font-family: system-ui, sans-serif;\n font-size: 10px;\n margin-bottom: 0.5em;\n}\n.${u}-swatch > svg {\n margin-right: 0.5em;\n overflow: visible;\n}\n${m}`))).style("margin-left",c?+c+"px":null).style("width",void 0===h?null:+h+"px").style("font-variant",Tn(i,"normal")).call(Pn,f).node()}const Aa=new Map([["symbol",function(t,{fill:n=(void 0!==t.hint?.fill?t.hint.fill:"none"),fillOpacity:r=1,stroke:o=(void 0!==t.hint?.stroke?t.hint.stroke:Ut(n)?"currentColor":"none"),strokeOpacity:i=1,strokeWidth:a=1.5,r:l=4.5,...s}={},c){const[u,f]=nt(n),[h,d]=nt(o),p=Ma(c,u),m=Ma(c,h),y=l*l*Math.PI;return r=rt(r)[1],i=rt(i)[1],a=rt(a)[1],La(t,s,((n,o,l,s)=>n.append("svg").attr("viewBox","-8 -8 16 16").attr("width",l).attr("height",s).attr("fill","color"===u?t=>p.scale(t):f).attr("fill-opacity",r).attr("stroke","color"===h?t=>m.scale(t):d).attr("stroke-opacity",i).attr("stroke-width",a).append("path").attr("d",(n=>{const r=e.pathRound();return t.scale(n).draw(r,y),r}))))}],["color",za],["opacity",function({type:t,interpolate:n,...r},{legend:o=!0,color:i=e.rgb(0,0,0),...a}){if(!n)throw new Error(`${t} opacity scales are not supported`);!0===o&&(o="ramp");if("ramp"!==`${o}`.toLowerCase())throw new Error(`${o} opacity legends are not supported`);return za({type:t,...r,interpolate:Ea(i)},{legend:o,...a})}]]);function Sa({className:t,...e},{label:n,ticks:r,tickFormat:o}={},i){return function(t={},...e){let n=t;for(const r of e)for(const e in r)if(void 0===n[e]){const o=r[e];n===t?n={...n,[e]:o}:n[e]=o}return n}(i,{className:t,...e},{label:n,ticks:r,tickFormat:o})}function za(t,{legend:n=!0,...r}){if(!0===n&&(n="ordinal"===t.type?"swatches":"ramp"),void 0!==t.domain)switch(`${n}`.toLowerCase()){case"swatches":return function(t,{opacity:e,...n}={}){if(!to(t)&&!eo(t))throw new Error(`swatches legend requires ordinal or threshold color scale (not ${t.type})`);return La(t,n,((t,n,r,o)=>t.append("svg").attr("width",r).attr("height",o).attr("fill",n.scale).attr("fill-opacity",rt(e)[1]).append("rect").attr("width","100%").attr("height","100%")))}(t,r);case"ramp":return function(t,n){let{label:r=t.label,tickSize:o=6,width:i=240,height:a=44+o,marginTop:l=18,marginRight:s=0,marginBottom:c=16+o,marginLeft:u=0,style:f,ticks:h=(i-u-s)/64,tickFormat:d,fontVariant:p=Bo(t),round:m=!0,opacity:y,className:g}=n;const v=jn(n);g=In(g),y=rt(y)[1],null===d&&(d=()=>null);const x=qn("svg",v).attr("class",`${g}-ramp`).attr("font-family","system-ui, sans-serif").attr("font-size",10).attr("width",i).attr("height",a).attr("viewBox",`0 0 ${i} ${a}`).call((t=>t.append("style").text(`.${g}-ramp {\n display: block;\n background: white;\n height: auto;\n height: intrinsic;\n max-width: 100%;\n overflow: visible;\n}\n.${g}-ramp text {\n white-space: pre;\n}`))).call(Pn,f);let w,b=t=>t.selectAll(".tick line").attr("y1",l+c-a);const k=m?(t,e)=>t.rangeRound(e):(t,e)=>t.range(e),{type:$,domain:M,range:L,interpolate:A,scale:S,pivot:z}=t;if(A){const t=void 0===L?A:e.piecewise(1===A.length?Ar(A):A,L);w=k(S.copy(),e.quantize(e.interpolateNumber(u,i-s),Math.min(M.length+(void 0!==z),void 0===L?1/0:L.length)));const n=256,r=v.document.createElement("canvas");r.width=n,r.height=1;const o=r.getContext("2d");for(let e=0,r=n-1;et:"string"==typeof d?e.format(d):d;w=k(e.scaleLinear().domain([-1,L.length-1]),[u,i-s]),x.append("g").attr("fill-opacity",y).selectAll().data(L).enter().append("rect").attr("x",((t,e)=>w(e-1))).attr("y",l).attr("width",((t,e)=>w(e)-w(e-1))).attr("height",a-l-c).attr("fill",(t=>t)),h=st(t,((t,e)=>e)),d=e=>n(t[e],e)}else w=k(e.scaleBand().domain(M),[u,i-s]),x.append("g").attr("fill-opacity",y).selectAll().data(M).enter().append("rect").attr("x",w).attr("y",l).attr("width",Math.max(0,w.bandwidth()-1)).attr("height",a-l-c).attr("fill",S),b=()=>{};return x.append("g").attr("transform",`translate(0,${a-c})`).call(e.axisBottom(w).ticks(Array.isArray(h)?null:h,"string"==typeof d?d:void 0).tickFormat("function"==typeof d?d:void 0).tickSize(o).tickValues(Array.isArray(h)?h:null)).attr("font-size",null).attr("font-family",null).attr("font-variant",Tn(p,"normal")).call(b).call((t=>t.select(".domain").remove())),void 0!==r&&x.append("text").attr("x",u).attr("y",l-6).attr("fill","currentColor").attr("font-weight","bold").text(r),x.node()}(t,r);default:throw new Error(`unknown legend type: ${n}`)}}function Ea(t){const{r:n,g:r,b:o}=e.rgb(t)||e.rgb(0,0,0);return t=>`rgba(${n},${r},${o},${t})`}const Oa={ariaLabel:"frame",fill:"none",stroke:"currentColor",clip:!1},Ra={ariaLabel:"frame",fill:null,stroke:"currentColor",strokeLinecap:"square",clip:!1};class Ca extends ko{constructor(t={}){const{anchor:e=null,inset:n=0,insetTop:r=n,insetRight:o=n,insetBottom:i=n,insetLeft:a=n,rx:l,ry:s}=t;super(j,void 0,t,null==e?Oa:Ra),this.anchor=ot(e,"anchor",["top","right","bottom","left"]),this.insetTop=X(r),this.insetRight=X(o),this.insetBottom=X(i),this.insetLeft=X(a),this.rx=X(l),this.ry=X(s)}render(t,e,n,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:m,rx:y,ry:g}=this,v=s+m,x=c-a-d,w=i+h,b=u-l-p;return qn(f?"svg:line":"svg:rect",o).datum(0).call(zn,this,r,o).call(En,this).call($n,this,n).call(Cn,this,{}).call("left"===f?t=>t.attr("x1",v).attr("x2",v).attr("y1",w).attr("y2",b):"right"===f?t=>t.attr("x1",x).attr("x2",x).attr("y1",w).attr("y2",b):"top"===f?t=>t.attr("x1",v).attr("x2",x).attr("y1",w).attr("y2",w):"bottom"===f?t=>t.attr("x1",v).attr("x2",x).attr("y1",b).attr("y2",b):t=>t.attr("x",v).attr("y",w).attr("width",x-v).attr("height",b-w).attr("rx",y).attr("ry",g)).node()}}function Ta(t){return new Ca(t)}const Ba={ariaLabel:"tip",fill:"white",stroke:"currentColor"},Na=new Set(["geometry","href","src","ariaLabel","scales"]);class Ia extends ko{constructor(t,e={}){e.tip&&(e={...e,tip:!1}),void 0===e.title&&It(t)&&Pt(t)&&(e={...e,title:F});const{x:n,y:r,x1:o,x2:i,y1:a,y2:l,anchor:s,monospace:c,fontFamily:u=(c?"ui-monospace, monospace":void 0),fontSize:f,fontStyle:h,fontVariant:d,fontWeight:p,lineHeight:m=1,lineWidth:y=20,frameAnchor:g,format:v,textAnchor:x="start",textOverflow:w,textPadding:b=8,title:k,pointerSize:$=12,pathFilter:M="drop-shadow(0 3px 4px rgba(0,0,0,0.2))"}=e;super(t,{x:{value:null!=o&&null!=i?null:n,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:k,optional:!0}},e,Ba),this.anchor=Ht(s,"anchor"),this.previousAnchor=this.anchor??"top-left",this.frameAnchor=Zt(g),this.textAnchor=Tn(x,"middle"),this.textPadding=+b,this.pointerSize=+$,this.pathFilter=G(M),this.lineHeight=+m,this.lineWidth=+y,this.textOverflow=pi(w),this.monospace=!!c,this.fontFamily=G(u),this.fontSize=X(f),this.fontStyle=G(h),this.fontVariant=G(d),this.fontWeight=G(p);for(const t in Ba)t in this.channels&&(this[t]=Ba[t]);this.splitLines=Li(this),this.clipLine=Ai(this),this.format={...v}}render(t,n,r,o,i){const a=this,{x:l,y:s,fx:c,fy:u}=n,{ownerSVGElement:f,document:h}=i,{anchor:d,monospace:p,lineHeight:m,lineWidth:y}=this,{textPadding:g,pointerSize:v,pathFilter:x}=this,{marginTop:w,marginLeft:b}=o,{x1:k,y1:$,x2:M,y2:L,x:A=k??M,y:S=$??L}=r,z=c?c(t.fx)-b:0,E=u?u(t.fy)-w:0,[O,R]=Wn(this,o),C=Co(r,O),T=To(r,R),B=p?Mi:$i,N=B(Si);let I,P;"title"in r?(I=r.channels,P=qa):(I=Wa.call(this,r,n),P=Da);const W=qn("svg:g",i).call(zn,this,o,i).call(xi,this).call(Cn,this,{x:A&&l,y:S&&s}).call((o=>o.selectAll().data(t).enter().append("g").attr("transform",(t=>`translate(${Math.round(C(t))},${Math.round(T(t))})`)).call(En,this).call((t=>t.append("path").attr("filter",x))).call((o=>o.append("text").each((function(o){const i=e.select(this);this.setAttribute("fill","currentColor"),this.setAttribute("fill-opacity",1),this.setAttribute("stroke","none");const l=P.call(a,o,t,I,n,r);if("string"==typeof l)for(const t of a.splitLines(l))j(i,{value:a.clipLine(t)});else{const t=new Set;for(const e of l){const{label:n=""}=e;n&&t.has(n)||(t.add(n),j(i,e))}}}))))));function j(t,{label:e,value:n,color:r,opacity:o}){e??="",n??="";const i=null!=r||null!=o;let a,l=100*y;const[s]=zi(e,l,B,N);if(s>=0)e=e.slice(0,s).trimEnd()+Si,a=n.trim(),n="";else{(e||!n&&!i)&&(n=" "+n);const[t]=zi(n,l-B(e),B,N);t>=0&&(a=(n=n.slice(0,t).trimEnd()+Si).trim())}const c=t.append("tspan").attr("x",0).attr("dy",`${m}em`).text("​");e&&c.append("tspan").attr("font-weight","bold").text(e),n&&c.append((()=>h.createTextNode(n))),i&&c.append("tspan").text(" ■").attr("fill",r).attr("fill-opacity",o).style("user-select","none"),a&&c.append("title").text(a)}function q(){const{width:t,height:e}=o.facet??o;W.selectChildren().each((function(n){let{x:r,width:o,height:i}=this.getBBox();o=Math.round(o),i=Math.round(i);let l=d;if(void 0===l){l=a.previousAnchor;const r=C(n)+z,s=T(n)+E,c=r+o+2*g0,f=s+i+v+2*g+70,d=(/-left$/.test(l)?c||!u:c&&!u)?"left":"right",p=(/^top-/.test(l)?f||!h:f&&!h)?"top":"bottom";l=a.previousAnchor=`${p}-${d}`}const s=this.firstChild,c=this.lastChild;if(s.setAttribute("d",function(t,e,n,r,o){const i=r+2*n,a=o+2*n;switch(t){case"middle":return`M${-i/2},${-a/2}h${i}v${a}h${-i}z`;case"top-left":return`M0,0l${e},${e}h${i-e}v${a}h${-i}z`;case"top":return`M0,0l${e/2},${e/2}h${(i-e)/2}v${a}h${-i}v${-a}h${(i-e)/2}z`;case"top-right":return`M0,0l${-e},${e}h${e-i}v${a}h${i}z`;case"right":return`M0,0l${-e/2},${-e/2}v${e/2-a/2}h${-i}v${a}h${i}v${e/2-a/2}z`;case"bottom-left":return`M0,0l${e},${-e}h${i-e}v${-a}h${-i}z`;case"bottom":return`M0,0l${e/2},${-e/2}h${(i-e)/2}v${-a}h${-i}v${a}h${(i-e)/2}z`;case"bottom-right":return`M0,0l${-e},${-e}h${e-i}v${-a}h${i}z`;case"left":return`M0,0l${e/2},${-e/2}v${e/2-a/2}h${i}v${a}h${-i}v${e/2-a/2}z`}}(l,v,g,o,i)),r)for(const t of c.childNodes)t.setAttribute("x",-r);c.setAttribute("y",+function(t,e,n){return/^top(?:-|$)/.test(t)?.94-n:-.29-e*n}(l,c.childNodes.length,m).toFixed(6)+"em"),c.setAttribute("transform",`translate(${function(t,e,n,r,o){switch(t){case"middle":return[-r/2,o/2];case"top-left":return[n,e+n];case"top":return[-r/2,e/2+n];case"top-right":return[-r-n,e+n];case"right":return[-e/2-r-n,o/2];case"bottom-left":return[n,-e-n];case"bottom":return[-r/2,-e/2-n];case"bottom-right":return[-r-n,-e-n];case"left":return[n+e/2,o/2]}}(l,v,g,o,i)})`)})),W.attr("visibility",null)}return t.length&&(W.attr("visibility","hidden"),f.isConnected?Promise.resolve().then(q):"undefined"!=typeof requestAnimationFrame&&requestAnimationFrame(q)),W.node()}}function Pa(t,{x:e,y:n,...r}={}){return void 0===r.frameAnchor&&([e,n]=vt(e,n)),new Ia(t,{...r,x:e,y:n})}function Wa({channels:t},n){const r={};let o=this.format;o=ja(o,t,"x"),o=ja(o,t,"y"),this.format=o;for(const e in o){const n=o[e];if(null!==n&&!1!==n)if("fx"===e||"fy"===e)r[e]=!0;else{const n=ln(t,e);n&&(r[e]=n)}}for(const e in t){if(e in r||e in o||Na.has(e))continue;const n=ln(t,e);n&&(r[e]=n)}this.facet&&(n.fx&&!("fx"in o)&&(r.fx=!0),n.fy&&!("fy"in o)&&(r.fy=!0));for(const t in r){const o=this.format[t];if("string"==typeof o){const i=r[t]?.value??n[t]?.domain()??[];this.format[t]=(jt(i)?e.utcFormat:e.format)(o)}else if(void 0===o||!0===o){const e=n[t];this.format[t]=e?.bandwidth?pa(e,e.domain()):dn}}return r}function ja(t,e,n){if(!(n in t))return t;const r=`${n}1`,o=`${n}2`;if(!(!(r in t)&&r in e||!(o in t)&&o in e))return t;const i=Object.entries(t),a=t[n];return i.splice(i.findIndex((([t])=>t===n))+1,0,[r,a],[o,a]),Object.fromEntries(i)}function qa(t,e,{title:n}){return dn(n.value[t],t)}function*Da(t,e,r,o,i){for(const a in r){if("fx"===a||"fy"===a){yield{label:_a(o,r,a),value:this.format[a](e[a],t)};continue}if("x1"===a&&"x2"in r)continue;if("y1"===a&&"y2"in r)continue;const l=r[a];if("x2"===a&&"x1"in r)yield{label:Ya(o,r,"x"),value:Fa(this.format.x2,r.x1,l,t)};else if("y2"===a&&"y1"in r)yield{label:Ya(o,r,"y"),value:Fa(this.format.y2,r.y1,l,t)};else{const e=l.value[t],s=l.scale;if(!n(e)&&null==s)continue;yield{label:_a(o,r,a),value:this.format[a](e,t),color:"color"===s?i[a][t]:null,opacity:"opacity"===s?i[a][t]:null}}}}function Fa(t,e,n,r){return n.hint?.length?`${t(n.value[r]-e.value[r],r)}`:`${t(e.value[r],r)}–${t(n.value[r],r)}`}function Ya(t,e,n){const r=_a(t,e,`${n}1`,n),o=_a(t,e,`${n}2`,n);return r===o?r:`${r}–${o}`}function _a(t,e,n,r=n){const o=e[n],i=t[o?.scale??n];return String(i?.label??o?.label??r)}function Ga(t={}){const{facet:n,style:r,title:o,subtitle:i,caption:a,ariaLabel:l,ariaDescription:s}=t,c=In(t.className),u=void 0===t.marks?[]:Ua(t.marks);u.push(...function(t){const e=[];for(const n of t){let t=n.tip;if(t){!0===t?t={}:"string"==typeof t&&(t={pointer:t});let{pointer:r}=t;r=/^x$/i.test(r)?Oo:/^y$/i.test(r)?Ro:Eo,t=r(nl(n,t)),t.title=null;const o=Pa(n.data,t);o.facet=n.facet,o.facetAnchor=n.facetAnchor,e.push(o)}}return e}(u));const f=function(t,e){if(null==t)return;const{x:n,y:r}=t;if(null==n&&null==r)return;const o=lt(t.data);if(null==o)throw new Error("missing facet data");const i={};null!=n&&(i.fx=He(o,{value:n,scale:"fx"}));null!=r&&(i.fy=He(o,{value:r,scale:"fy"}));Za(i,e);const a=so(o,i);return{channels:i,groups:a,data:t.data}}(n,t),h=new Map;for(const e of u){const n=el(e,f,t);n&&h.set(e,n)}const d=new Map;f&&Ka(d,[f],t),Ka(d,h,t);const p=Ua(function(t,e,n){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:m=s,grid:y=(null===m?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}=n;(r||!pt(o)&&!ll("x",t))&&(d=p=null);(r||!pt(i)&&!ll("y",t))&&(m=y=null);e.has("fx")||(g=v=null);e.has("fy")||(x=w=null);void 0===d&&(d=!al(t,"x"));void 0===m&&(m=!al(t,"y"));void 0===g&&(g=!al(t,"fx"));void 0===x&&(x=!al(t,"fy"));!0===d&&(d="bottom");!0===m&&(m="left");!0===g&&(g="top"===d||null===d?"bottom":"top");!0===x&&(x="right"===m||null===m?"left":"right");const b=[];return ol(b,w,ia,l),rl(b,x,Ki,"right","left",u,l),ol(b,v,la,a),rl(b,g,ea,"top","bottom",u,a),ol(b,y,oa,i),rl(b,m,Ji,"left","right",n,i),ol(b,p,aa,o),rl(b,d,ta,"bottom","top",n,o),b}(u,d,t));for(const e of p){const n=el(e,f,t);n&&h.set(e,n)}u.unshift(...p);let m=function(t,n){const{fx:r,fy:o}=qr(t,n),i=r?.scale.domain(),a=o?.scale.domain();return i&&a?e.cross(i,a).map((([t,e],n)=>({x:t,y:e,i:n}))):i?i.map(((t,e)=>({x:t,i:e}))):a?a.map(((t,e)=>({y:t,i:e}))):void 0}(d,t);if(void 0!==m){const t=f?bo(m,f):void 0;for(const e of u){if(null===e.facet||"super"===e.facet)continue;const n=h.get(e);void 0!==n&&(n.facetsIndex=null!=e.fx||null!=e.fy?bo(m,n):t)}const e=new Set;for(const{facetsIndex:t}of h.values())t?.forEach(((t,n)=>{t?.length>0&&e.add(n)}));m.forEach(0t.empty=!e.has(n):t=>t.empty=!1);for(const t of u)if("exclude"===t.facet){const e=h.get(t);void 0!==e&&(e.facetsIndex=co(e.facetsIndex))}}for(const e of ae.keys())pt(t[e])&&"fx"!==e&&"fy"!==e&&d.set(e,[]);const y=new Map;for(const e of u){if(y.has(e))throw new Error("duplicate mark; each mark must be unique");const{facetsIndex:n,channels:r}=h.get(e)??{},{data:o,facets:i,channels:a}=e.initialize(n,r,t);Za(a,t),y.set(e,{data:o,facets:i,channels:a})}const g=qr(Ka(d,y,t),t),v=function(t,e,n={}){let r=.5-gn,o=.5+gn,i=.5+gn,a=.5-gn;for(const{marginTop:t,marginRight:n,marginBottom:l,marginLeft:s}of e)t>r&&(r=t),n>o&&(o=n),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)}=n;s=+s,c=+c,u=+u,f=+f;let{width:h=640,height:d=ao(t,n,{width:h,marginTopDefault:r,marginRightDefault:o,marginBottomDefault:i,marginLeftDefault:a})+Math.max(0,s-r+u-i)}=n;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:e=(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)}=n.facet??{};e=+e,r=+r,o=+o,i=+i,p.facet={marginTop:e,marginRight:r,marginBottom:o,marginLeft:i}}return p}(g,u,t);!function(t,e){const{x:n,y:r,fx:o,fy:i}=t,a=o||i?Yr(e):e;o&&Gr(o,a),i&&Xr(i,a);const l=o||i?_r(t,e):e;n&&Gr(n,l),r&&Xr(r,l)}(g,v);const x=Dr(g),{fx:w,fy:b}=x,k=w||b?_r(g,v):v,$=w||b?function({fx:t,fy:e},n){const{marginTop:r,marginRight:o,marginBottom:i,marginLeft:a,width:l,height:s}=Yr(n),c=t&&sl(t),u=e&&sl(e);return{marginTop:e?u[0]:r,marginRight:t?l-c[1]:o,marginBottom:e?s-u[1]:i,marginLeft:t?c[0]:a,inset:{marginTop:n.marginTop,marginRight:n.marginRight,marginBottom:n.marginBottom,marginLeft:n.marginLeft},width:l,height:s}}(x,v):v,M=jn(t),L=M.document,A=e.creator("svg").call(L.documentElement);let S=A;M.ownerSVGElement=A,M.className=c,M.projection=_n(t,k),M.filterFacets=(t,e)=>bo(m,{channels:e,groups:so(t,e)}),M.getMarkState=t=>{const e=y.get(t),n=h.get(t);return{...e,channels:{...e.channels,...n?.channels}}},M.dispatchValue=t=>{S.value!==t&&(S.value=t,S.dispatchEvent(new Event("input",{bubbles:!0})))};const z=new Set;for(const[e,n]of y)if(null!=e.initializer){const r="super"===e.facet?$:k,o=e.initializer(n.data,n.facets,n.channels,x,r,M);if(void 0!==o.data&&(n.data=o.data),void 0!==o.facets&&(n.facets=o.facets),void 0!==o.channels){const{fx:r,fy:i,...a}=o.channels;Ja(a),Object.assign(n.channels,a);for(const e of Object.values(a)){const{scale:n}=e;null!=n&&((E=ae.get(n))!==Kt&&E!==ie)&&(Qa(e,t),z.add(n))}null==r&&null==i||h.set(e,!0)}}var E;if(z.size){const e=new Map;Ka(e,y,t,(t=>z.has(t))),Ka(d,y,t,(t=>z.has(t)));const n=function(t,e){for(const n in t){const r=t[n],o=e[n];void 0===r.label&&o&&(r.label=o.label)}return t}(qr(e,t),g),{scales:r,...o}=Dr(n);Object.assign(g,n),Object.assign(x,o),Object.assign(x.scales,r)}let O,R;void 0!==m&&(O={x:w?.domain(),y:b?.domain()},m=function(t,{x:e,y:n}){return e&&=ho(e),n&&=ho(n),t.filter(e&&n?t=>e.has(t.x)&&n.has(t.y):e?t=>e.has(t.x):t=>n.has(t.y)).sort(e&&n?(t,r)=>e.get(t.x)-e.get(r.x)||n.get(t.y)-n.get(r.y):e?(t,n)=>e.get(t.x)-e.get(n.x):(t,e)=>n.get(t.y)-n.get(e.y))}(m,O),R=function(t,e,{marginTop:n,marginLeft:r}){return t&&e?({x:o,y:i})=>`translate(${t(o)-r},${e(i)-n})`:t?({x:e})=>`translate(${t(e)-r},0)`:({y:t})=>`translate(0,${e(t)-n})`}(w,b,v));for(const[t,e]of y)e.values=t.scale(e.channels,x,M);const{width:C,height:T}=v;e.select(A).attr("class",c).attr("fill","currentColor").attr("font-family","system-ui, sans-serif").attr("font-size",10).attr("text-anchor","middle").attr("width",C).attr("height",T).attr("viewBox",`0 0 ${C} ${T}`).attr("aria-label",l).attr("aria-description",s).call((t=>t.append("style").text(`.${c} {\n display: block;\n background: white;\n height: auto;\n height: intrinsic;\n max-width: 100%;\n}\n.${c} text,\n.${c} tspan {\n white-space: pre;\n}`))).call(Pn,r);for(const t of u){const{channels:n,values:r,facets:o}=y.get(t);if(void 0===m||"super"===t.facet){let e=null;if(o&&(e=o[0],e=t.filter(e,n,r),0===e.length))continue;const i=t.render(e,x,r,$,M);if(null==i)continue;A.appendChild(i)}else{let i;for(const a of m){if(!(t.facetAnchor?.(m,O,a)??!a.empty))continue;let l=null;if(o){const e=h.has(t);if(l=o[e?a.i:0],l=t.filter(l,n,r),0===l.length)continue;e||l!==o[0]||(l=$t(l)),l.fx=a.x,l.fy=a.y,l.fi=a.i}const s=t.render(l,x,r,k,M);if(null!=s){(i??=e.select(A).append("g")).append((()=>s)).datum(a);for(const t of["aria-label","aria-description","aria-hidden","transform"])s.hasAttribute(t)&&(i.attr(t,s.getAttribute(t)),s.removeAttribute(t))}}i?.selectChildren().attr("transform",R)}}const B=function(t,e,n){const r=[];for(const[o,i]of Aa){const a=n[o];if(a?.legend&&o in t){const n=i(t[o],Sa(e,t[o],a),(e=>t[e]));null!=n&&r.push(n)}}return r}(g,M,t),{figure:N=null!=o||null!=i||null!=a||B.length>0}=t;N&&(S=L.createElement("figure"),S.className=`${c}-figure`,S.style.maxWidth="initial",null!=o&&S.append(Xa(L,o,"h2")),null!=i&&S.append(Xa(L,i,"h3")),S.append(...B,A),null!=a&&S.append(function(t,e){const n=t.createElement("figcaption");return n.append(e),n}(L,a))),S.scale=function(t){return e=>{if(!ae.has(e=`${e}`))throw new Error(`unknown scale: ${e}`);return t[e]}}(x.scales),S.legend=function(t,e,n={}){return(r,o)=>{if(!Aa.has(r))throw new Error(`unknown legend type: ${r}`);if(r in t)return Aa.get(r)(t[r],Sa(e,n[r],o),(e=>t[e]))}}(g,M,t);const I=function(){const t=mn;return mn=0,pn=void 0,t}();return I>0&&e.select(A).append("text").attr("x",C).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.`),S}function Xa(t,e,n){if(e.ownerDocument)return e;const r=t.createElement(n);return r.append(e),r}function Ua(t){return t.flat(1/0).filter((t=>null!=t)).map(Va)}function Va(t){return"function"==typeof t.render?t:new Ha(t)}ko.prototype.plot=function({marks:t=[],...e}={}){return Ga({...e,marks:[...t,this]})};class Ha extends ko{constructor(t){if("function"!=typeof t)throw new TypeError("invalid mark; missing render function");super(),this.render=t}render(){}}function Za(t,e){for(const n in t)Qa(t[n],e);return t}function Qa(t,e){const{scale:n,transform:r=!0}=t;if(null==n||!r)return;const{type:o,percent:i,interval:a,transform:l=(i?t=>100*t:Rt(a,o))}=e[n]??{};null!=l&&(t.value=st(t.value,l),t.transform=!1)}function Ja(t){for(const e in t)Je(e,t[e])}function Ka(t,e,n,r=_){for(const{channels:o}of e.values())for(const e in o){const i=o[e],{scale:a}=i;if(null!=a&&r(a))if("projection"===a){if(!Qn(n)){const e=void 0===n.x?.domain,r=void 0===n.y?.domain;if(e||r){const[n,o]=Kn(i);e&&tl(t,"x",n),r&&tl(t,"y",o)}}}else tl(t,a,i)}return t}function tl(t,e,n){const r=t.get(e);void 0!==r?r.push(n):t.set(e,[n])}function el(t,e,n){if(null===t.facet||"super"===t.facet)return;const{fx:r,fy:o}=t;if(null!=r||null!=o){const e=lt(t.data??r??o);if(void 0===e)throw new Error(`missing facet data in ${t.ariaLabel}`);if(null===e)return;const i={};return null!=r&&(i.fx=He(e,{value:r,scale:"fx"})),null!=o&&(i.fy=He(e,{value:o,scale:"fy"})),Za(i,n),{channels:i,groups:so(e,i)}}if(void 0===e)return;const{channels:i,groups:a,data:l}=e;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)&<(t.data)?.length===l.length&&yn(`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 nl(t,e={}){return me({...e,x:null,y:null},((e,n,r,o,i,a)=>a.getMarkState(t)))}function rl(t,e,n,r,o,i,a){if(!e)return;const l=/^\s*both\s*$/i.test(e);a=function(t,e,{line:n=e.line,ticks:r,tickSize:o,tickSpacing:i,tickPadding:a,tickFormat:l,tickRotate:s,fontVariant:c,ariaLabel:u,ariaDescription:f,label:h=e.label,labelAnchor:d,labelArrow:p=e.labelArrow,labelOffset:m}){return{anchor:t,line:n,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:m}}(l?r:e,i,a);const{line:s}=a;n!==Ji&&n!==ta||!s||Vt(s)||t.push(Ta(function(t){const{anchor:e,line:n}=t;return{anchor:e,facetAnchor:e+"-empty",stroke:!0===n?void 0:n}}(a))),t.push(n(a)),l&&t.push(n({...a,anchor:o,label:null}))}function ol(t,e,n,r){e&&!Vt(e)&&t.push(n(function(t,{stroke:e=(Gt(t)?t:void 0),ticks:n=(il(t)?t:void 0),tickSpacing:r,ariaLabel:o,ariaDescription:i}){return{stroke:e,ticks:n,tickSpacing:r,ariaLabel:o,ariaDescription:i}}(e,r)))}function il(t){switch(typeof t){case"number":return!0;case"string":return!Gt(t)}return It(t)||"function"==typeof t?.range}function al(t,e){const n=`${e}-axis `;return t.some((t=>t.ariaLabel?.startsWith(n)))}function ll(t,e){for(const n of e)for(const e in n.channels){const{scale:r}=n.channels[e];if(r===t||"projection"===r)return!0}return!1}function sl(t){const e=t.domain();let n=t(e[0]),r=t(e[e.length-1]);return r{const u=Ot(I(n,v),c?.[x]),h=I(n,M),p=I(n,j),y=I(n,q),w=Pe(s,{z:h,fill:p,stroke:y}),k=[],$=[],L=u&&b([]),A=h&&W([]),S=p&&Y([]),z=y&&G([]),E=t&&f([]),O=t&&d([]),R=e&&m([]),C=e&&g([]),T=(B=t?.(n),N=e?.(n),B&&N?function*(t){const e=B.bin(t);for(const[t,[n,r]]of B.entries()){const o=N.bin(e[t]);for(const[t,[e,i]]of N.entries())yield[o[t],{x1:n,y1:e,x2:r,y2:i}]}}:B?function*(t){const e=B.bin(t);for(const[t,[n,r]]of B.entries())yield[e[t],{x1:n,x2:r}]}:function*(t){const e=N.bin(t);for(const[t,[n,r]]of N.entries())yield[e[t],{y1:n,y2:r}]});var B,N;let P=0;for(const t of s)t.initialize(n);a&&a.initialize(n),i&&i.initialize(n);for(const t of r){const e=[];for(const e of s)e.scope("facet",t);a&&a.scope("facet",t),i&&i.scope("facet",t);for(const[r,l]of Be(t,w))for(const[t,c]of Be(l,u))for(const[l,f]of T(c))if(!i||i.reduce(l,f)){e.push(P++),$.push(o.reduceIndex(l,n,f)),u&&L.push(t),h&&A.push(w===h?r:h[(l.length>0?l:c)[0]]),p&&S.push(w===p?r:p[(l.length>0?l:c)[0]]),y&&z.push(w===y?r:y[(l.length>0?l:c)[0]]),E&&(E.push(f.x1),O.push(f.x2)),R&&(R.push(f.y1),C.push(f.y2));for(const t of s)t.reduce(l,f);a&&a.reduce(l)}k.push(e)}return We(k,a,l),{data:$,facets:k}})),...!Oe(s,"x")&&(u?{x1:u,x2:h,x:Et(u,h)}:{x:k,x1:S,x2:z}),...!Oe(s,"y")&&(p?{y1:p,y2:y,y:Et(p,y)}:{y:$,y1:E,y2:O}),...w&&{[x]:w},...Object.fromEntries(s.map((({name:t,output:e})=>[t,e])))}}function wl({cumulative:t,domain:e,thresholds:n,interval:r,...o},i){return[o,{cumulative:t,domain:e,thresholds:n,interval:r,...i}]}function bl(t,{cumulative:e,domain:n,thresholds:r,interval:o},i){return void 0===(t={...Nt(t)}).domain&&(t.domain=n),void 0===t.cumulative&&(t.cumulative=e),void 0===t.thresholds&&(t.thresholds=r),void 0===t.interval&&(t.interval=o),void 0===t.value&&(t.value=i),t.thresholds=$l(t.thresholds,t.interval),t}function kl(t){if(null==t)return;const{value:n,cumulative:r,domain:o=e.extent,thresholds:i}=t,a=t=>{let a,l=I(t,n);if(jt(l)||(function(t){return Bt(t)&&"function"==typeof t?.floor&&t.floor()instanceof Date}(s=i)||It(s)&&jt(s))){l=st(l,et,Float64Array);let[t,n]="function"==typeof o?o(l):o,r="function"!=typeof i||Bt(i)?i:i(l,t,n);"number"==typeof r&&(r=e.utcTickInterval(t,n,r)),Bt(r)&&(o===e.extent&&(t=r.floor(t),n=r.offset(r.floor(n))),r=r.range(t,r.offset(n))),a=r}else{l=J(l);let[t,n]="function"==typeof o?o(l):o,r="function"!=typeof i||Bt(i)?i:i(l,t,n);if("number"==typeof r)if(o===e.extent){let o=e.tickIncrement(t,n,r);if(isFinite(o))if(o>0){let e=Math.round(t/o),i=Math.round(n/o);e*o<=t||--e,i*o>n||++i;let a=i-e+1;r=new Float64Array(a);for(let t=0;tn||++i;let a=i-e+1;r=new Float64Array(a);for(let t=0;t0?Ol:El)(c,a,l),c};return a.label=zt(n),a}function $l(t,n,r=zl){if(void 0===t)return void 0===n?r:Tt(n);if("string"==typeof t){switch(t.toLowerCase()){case"freedman-diaconis":return e.thresholdFreedmanDiaconis;case"scott":return e.thresholdScott;case"sturges":return e.thresholdSturges;case"auto":return zl}return E(t)}return t}function Ml(t,e,n){return Ce(t,e,n,Ll)}function Ll(t,e,n){return Te(t,e,n,Al)}function Al(t,e){return Ne(t,e,Sl)}function Sl(t){switch(`${t}`.toLowerCase()){case"x":return Tl;case"x1":return Nl;case"x2":return Il;case"y":return Bl;case"y1":return Pl;case"y2":return Wl}throw new Error(`invalid bin reduce: ${t}`)}function zl(t,n,r){return Math.min(200,e.thresholdScott(t,n,r))}function El(t,n,r){return n=J(n),o=>{const i=t.map((()=>[]));for(const t of o)i[e.bisect(n,r[t])-1]?.push(t);return i}}function Ol(t,e,n){const r=El(t,e,n);return t=>{const e=r(t);for(let t=1,n=e.length;t{const e=r(t);for(let t=e.length-2;t>=0;--t){const n=e[t+1],r=e[t];for(const t of n)r.push(t)}return e}}function Cl(t,e){const n=(+t+ +e)/2;return t instanceof Date?new Date(n):n}const Tl={reduceIndex:(t,e,{x1:n,x2:r})=>Cl(n,r)},Bl={reduceIndex:(t,e,{y1:n,y2:r})=>Cl(n,r)},Nl={reduceIndex:(t,e,{x1:n})=>n},Il={reduceIndex:(t,e,{x2:n})=>n},Pl={reduceIndex:(t,e,{y1:n})=>n},Wl={reduceIndex:(t,e,{y2:n})=>n};function jl(t={}){return ut(t)?t:{...t,x:F}}function ql(t={}){return ft(t)?t:{...t,y:F}}function Dl(t={},e={}){1===arguments.length&&([t,e]=Gl(t));const{y1:n,y:r=n,x:o,...i}=e,[a,l,s,c]=Ul(r,o,"y","x",t,i);return{...a,y1:n,y:l,x1:s,x2:c,x:Et(s,c)}}function Fl(t={},e={}){1===arguments.length&&([t,e]=Gl(t));const{x1:n,x:r=n,y:o,...i}=e,[a,l,s,c]=Ul(r,o,"x","y",t,i);return{...a,x1:n,x:l,y1:s,y2:c,y:Et(s,c)}}function Yl({x:t,x1:e,x2:n,...r}={}){return r=Ao(r,"y"),void 0===e&&void 0===n?Dl({x:t,...r}):([e,n]=gt(t,e,n),{...r,x1:e,x2:n})}function _l({y:t,y1:e,y2:n,...r}={}){return r=Ao(r,"x"),void 0===e&&void 0===n?Fl({y:t,...r}):([e,n]=gt(t,e,n),{...r,y1:e,y2:n})}function Gl(t){const{offset:e,order:n,reverse:r,...o}=t;return[{offset:e,order:n,reverse:r},o]}const Xl={length:!0};function Ul(t,n=Y,i,a,{offset:l,order:s,reverse:c},u){if(null===n)throw new Error(`stack requires ${a}`);const f=xt(u),[h,d]=St(t),[p,m]=At(n),[y,g]=At(n);return p.hint=y.hint=Xl,l=function(t){if(null==t)return;if("function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"expand":case"normalize":return Hl;case"center":case"silhouette":return Zl;case"wiggle":return Ql}throw new Error(`unknown offset: ${t}`)}(l),s=function(t,n,i){if(void 0===t&&n===Ql)return ts(r);if(null==t)return;if("string"==typeof t){const n=t.startsWith("-"),a=n?o:r;switch((n?t.slice(1):t).toLowerCase()){case"value":case i:return function(t){return(e,n,r)=>(e,n)=>t(r[e],r[n])}(a);case"z":return function(t){return(e,n,r,o)=>(e,n)=>t(o[e],o[n])}(a);case"sum":return function(t){return rs(t,((t,n,r,o)=>e.groupSort(wt(t),(t=>e.sum(t,(t=>r[t]))),(t=>o[t]))))}(a);case"appearance":return function(t){return rs(t,((t,n,r,o)=>e.groupSort(wt(t),(t=>n[e.greatest(t,(t=>r[t]))]),(t=>o[t]))))}(a);case"inside-out":return ts(a)}return es(q(t))}if("function"==typeof t)return(1===t.length?es:ns)(t);if(Array.isArray(t))return a=t,rs(r,(()=>a));var a;throw new Error(`invalid order: ${t}`)}(s,l,a),[pe(u,((r,o,a)=>{({data:r,facets:o}=function(t,e){if(1===e.length)return{data:t,facets:e};const n=t.length,r=new Uint8Array(n);let o=0;for(const t of e)for(const e of t)r[e]&&++o,r[e]=1;if(0===o)return{data:t,facets:e};const i=(t=ct(t))[N]=new Uint32Array(n+o);e=e.map((t=>ct(t,Uint32Array)));let a=n;r.fill(0);for(const n of e)for(let e=0,o=n.length;eu[t])).values()):[t];if(y)for(const t of n)t.sort(y);for(const t of n){let e=0,n=0;c&&t.reverse();for(const r of t){const t=h[r];t<0?e=w[r]=(x[r]=e)+t:t>0?n=w[r]=(x[r]=n)+t:w[r]=x[r]=n}}b.push(n)}return l&&l(b,x,w,p),{data:r,facets:o}})),h,p,y]}function Vl(t,e){let n=0,r=0;for(const o of t){const t=e[o];tr&&(r=t)}return[n,r]}function Hl(t,e,n){for(const r of t)for(const t of r){const[r,o]=Vl(t,n);for(const i of t){const t=1/(o-r||1);e[i]=t*(e[i]-r),n[i]=t*(n[i]-r)}}}function Zl(t,e,n){for(const r of t){for(const t of r){const[r,o]=Vl(t,n);for(const i of t){const t=(o+r)/2;e[i]-=t,n[i]-=t}}Jl(r,e,n)}Kl(t,e,n)}function Ql(t,n,r,o){for(const i of t){const t=new e.InternMap;let a=0;for(const l of i){let i=-1;const s=l.map((t=>Math.abs(r[t]-n[t]))),c=l.map((e=>{i=o?o[e]:++i;const a=r[e]-n[e],l=t.has(i)?a-t.get(i):0;return t.set(i,a),l})),u=[0,...e.cumsum(c)];for(const t of l)n[t]+=a,r[t]+=a;const f=e.sum(s);f&&(a-=e.sum(s,((t,e)=>(c[e]/2+u[e])*t))/f)}Jl(i,n,r)}Kl(t,n,r)}function Jl(t,n,r){const o=e.min(t,(t=>e.min(t,(t=>n[t]))));for(const e of t)for(const t of e)n[t]-=o,r[t]-=o}function Kl(t,n,r){const o=t.length;if(1===o)return;const i=t.map((t=>t.flat())),a=i.map((t=>(e.min(t,(t=>n[t]))+e.max(t,(t=>r[t])))/2)),l=e.min(a);for(let t=0;t{const i=wt(t),a=e.groupSort(i,(t=>n[e.greatest(t,(t=>r[t]))]),(t=>o[t])),l=e.rollup(i,(t=>e.sum(t,(t=>r[t]))),(t=>o[t])),s=[],c=[];let u=0;for(const t of a)u<0?(u+=l.get(t),s.push(t)):(u-=l.get(t),c.push(t));return c.reverse().concat(s)}))}function es(t){return e=>{const n=I(e,t);return(t,e)=>r(n[t],n[e])}}function ns(t){return e=>(n,r)=>t(e[n],e[r])}function rs(t,n){return(r,o,i,a)=>{if(!a)throw new Error("missing channel: z");const l=new e.InternMap(n(r,o,i,a).map(((t,e)=>[t,e])));return(e,n)=>t(l.get(a[e]),l.get(a[n]))}}const os={ariaLabel:"area",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class is extends ko{constructor(t,e={}){const{x1:n,y1:r,x2:o,y2:i,z:a,curve:l,tension:s}=e;super(t,{x1:{value:n,scale:"x"},y1:{value:r,scale:"y"},x2:{value:o,scale:"x",optional:!0},y2:{value:i,scale:"y",optional:!0},z:{value:xt(e),optional:!0}},e,os),this.z=a,this.curve=ul(l,s)}filter(t){return t}render(t,n,r,o,i){const{x1:a,y1:l,x2:s=a,y2:c=l}=r;return qn("svg:g",i).call(zn,this,o,i).call(Cn,this,n,0,0).call((n=>n.selectAll().data(An(t,[a,l,s,c],this,r)).enter().append("path").call(En,this).call(Mn,this,r).attr("d",e.area().curve(this.curve).defined((t=>t>=0)).x0((t=>a[t])).y0((t=>l[t])).x1((t=>s[t])).y1((t=>c[t]))))).node()}}function as(t,e){const{y:n=D,...r}=vl(e);return new is(t,Yl(jl({...r,y1:n,y2:void 0})))}function ls(t,e){const{x:n=D,...r}=gl(e);return new is(t,_l(ql({...r,x1:n,x2:void 0})))}const ss={ariaLabel:"link",fill:"none",stroke:"currentColor",strokeMiterlimit:1};class cs extends ko{constructor(t,e={}){const{x1:n,y1:r,x2:o,y2:i,curve:a,tension:l}=e;super(t,{x1:{value:n,scale:"x"},y1:{value:r,scale:"y"},x2:{value:o,scale:"x",optional:!0},y2:{value:i,scale:"y",optional:!0}},e,ss),this.curve=fl(a,l),Io(this,e)}project(t,e,n){this.curve!==hl&&super.project(t,e,n)}render(t,n,r,o,i){const{x1:a,y1:l,x2:s=a,y2:c=l}=r,{curve:u}=this;return qn("svg:g",i).call(zn,this,o,i).call(Cn,this,n).call((n=>n.selectAll().data(t).enter().append("path").call(En,this).attr("d",u===hl&&i.projection?function(t,n,r,o,i){const a=e.geoPath(t);return n=J(n),r=J(r),o=J(o),i=J(i),t=>a({type:"LineString",coordinates:[[n[t],r[t]],[o[t],i[t]]]})}(i.projection,a,l,s,c):t=>{const n=e.pathRound(),r=u(n);return r.lineStart(),r.point(a[t],l[t]),r.point(s[t],c[t]),r.lineEnd(),n}).call($n,this,r).call(Yo,this,r,i))).node()}}function us(t,{x:e,x1:n,x2:r,y:o,y1:i,y2:a,...l}={}){return[n,r]=fs(e,n,r),[i,a]=fs(o,i,a),new cs(t,{...l,x1:n,x2:r,y1:i,y2:a})}function fs(t,e,n){if(void 0===t){if(void 0===e){if(void 0!==n)return[n]}else if(void 0===n)return[e]}else{if(void 0===e)return void 0===n?[t]:[t,n];if(void 0===n)return[t,e]}return[e,n]}const hs={ariaLabel:"arrow",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:1,strokeWidth:1.5};class ds extends ko{constructor(t,n={}){const{x1:r,y1:o,x2:i,y2:a,bend:l=0,headAngle:s=60,headLength:c=8,inset:u=0,insetStart:f=u,insetEnd:h=u,sweep:d}=n;super(t,{x1:{value:r,scale:"x"},y1:{value:o,scale:"y"},x2:{value:i,scale:"x",optional:!0},y2:{value:a,scale:"y",optional:!0}},n,hs),this.bend=!0===l?22.5:Math.max(-90,Math.min(90,l)),this.headAngle=+s,this.headLength=+c,this.insetStart=+f,this.insetEnd=+h,this.sweep=function(t=1){if("number"==typeof t)return Z(Math.sign(t));if("function"==typeof t)return(e,n,r,o)=>Math.sign(t(e,n,r,o));switch(at(t,"sweep",["+x","-x","+y","-y"])){case"+x":return(t,n,r)=>e.ascending(t,r);case"-x":return(t,n,r)=>e.descending(t,r);case"+y":return(t,n,r,o)=>e.ascending(n,o);case"-y":return(t,n,r,o)=>e.descending(n,o)}}(d)}render(t,e,n,r,o){const{x1:i,y1:a,x2:l=i,y2:s=a,SW:c}=n,{strokeWidth:u,bend:f,headAngle:h,headLength:d,insetStart:p,insetEnd:m}=this,y=c?t=>c[t]:Z(void 0===u?1:u),g=h*No/2,v=d/1.5;return qn("svg:g",o).call(zn,this,r,o).call(Cn,this,e).call((e=>e.selectAll().data(t).enter().append("path").call(En,this).attr("d",(t=>{let e=i[t],n=a[t],r=l[t],o=s[t];const c=Math.hypot(r-e,o-n);if(c<=p+m)return null;let u=Math.atan2(o-n,r-e);const h=Math.min(v*y(t),c/3),d=this.sweep(e,n,r,o)*f*No,x=Math.hypot(c/Math.tan(d),c)/2;if(p||m)if(x<1e5){const t=Math.sign(d),[i,a]=function([t,e],[n,r],o,i){const a=n-t,l=r-e,s=Math.hypot(a,l),c=i*Math.sqrt(o*o-s*s/4)/s;return[(t+n)/2-l*c,(e+r)/2+a*c]}([e,n],[r,o],x,t);if(p&&([e,n]=ps([i,a,x],[e,n,p],-t*Math.sign(p))),m){const[e,n]=ps([i,a,x],[r,o,m],t*Math.sign(m));u+=Math.atan2(n-a,e-i)-Math.atan2(o-a,r-i),r=e,o=n}}else{const t=r-e,i=o-n,a=Math.hypot(t,i);p&&(e+=t/a*p,n+=i/a*p),m&&(r-=t/a*m,o-=i/a*m)}const w=u+d,b=w+g,k=w-g,$=r-h*Math.cos(b),M=o-h*Math.sin(b),L=r-h*Math.cos(k),A=o-h*Math.sin(k);return`M${e},${n}${x<1e5?`A${x},${x} 0,0,${d>0?1:0} `:"L"}${r},${o}${h?`M${$},${M}L${r},${o}L${L},${A}`:""}`})).call($n,this,n))).node()}}function ps([t,e,n],[r,o,i],a){const l=r-t,s=o-e,c=Math.hypot(l,s),u=(l*l+s*s-i*i+n*n)/(2*c),f=a*Math.sqrt(n*n-u*u);return[t+(l*u+s*f)/c,e+(s*u-l*f)/c]}class ms extends ko{constructor(t,e,n={},r){super(t,e,n,r);const{inset:o=0,insetTop:i=o,insetRight:a=o,insetBottom:l=o,insetLeft:s=o,rx:c,ry:u}=n;this.insetTop=X(i),this.insetRight=X(a),this.insetBottom=X(l),this.insetLeft=X(s),this.rx=Tn(c,"auto"),this.ry=Tn(u,"auto")}render(t,e,n,r,o){const{rx:i,ry:a}=this;return qn("svg:g",o).call(zn,this,r,o).call(this._transform,this,e).call((o=>o.selectAll().data(t).enter().append("rect").call(En,this).attr("x",this._x(e,n,r)).attr("width",this._width(e,n,r)).attr("y",this._y(e,n,r)).attr("height",this._height(e,n,r)).call(Rn,"rx",i).call(Rn,"ry",a).call($n,this,n))).node()}_x(t,{x:e},{marginLeft:n}){const{insetLeft:r}=this;return e?t=>e[t]+r:n+r}_y(t,{y:e},{marginTop:n}){const{insetTop:r}=this;return e?t=>e[t]+r:n+r}_width({x:t},{x:e},{marginRight:n,marginLeft:r,width:o}){const{insetLeft:i,insetRight:a}=this,l=e&&t?t.bandwidth():o-n-r;return Math.max(0,l-i-a)}_height({y:t},{y:e},{marginTop:n,marginBottom:r,height:o}){const{insetTop:i,insetBottom:a}=this,l=e&&t?t.bandwidth():o-n-r;return Math.max(0,l-i-a)}}const ys={ariaLabel:"bar"};class gs extends ms{constructor(t,e={}){const{x1:n,x2:r,y:o}=e;super(t,{x1:{value:n,scale:"x"},x2:{value:r,scale:"x"},y:{value:o,scale:"y",type:"band",optional:!0}},e,ys)}_transform(t,e,{x:n}){t.call(Cn,e,{x:n},0,0)}_x({x:t},{x1:e,x2:n},{marginLeft:r}){const{insetLeft:o}=this;return no(t)?r+o:t=>Math.min(e[t],n[t])+o}_width({x:t},{x1:e,x2:n},{marginRight:r,marginLeft:o,width:i}){const{insetLeft:a,insetRight:l}=this;return no(t)?i-r-o-a-l:t=>Math.max(0,Math.abs(n[t]-e[t])-a-l)}}class vs extends ms{constructor(t,e={}){const{x:n,y1:r,y2:o}=e;super(t,{y1:{value:r,scale:"y"},y2:{value:o,scale:"y"},x:{value:n,scale:"x",type:"band",optional:!0}},e,ys)}_transform(t,e,{y:n}){t.call(Cn,e,{y:n},0,0)}_y({y:t},{y1:e,y2:n},{marginTop:r}){const{insetTop:o}=this;return no(t)?r+o:t=>Math.min(e[t],n[t])+o}_height({y:t},{y1:e,y2:n},{marginTop:r,marginBottom:o,height:i}){const{insetTop:a,insetBottom:l}=this;return no(t)?i-r-o-a-l:t=>Math.max(0,Math.abs(n[t]-e[t])-a-l)}}function xs(t,e={}){return ht(e)||(e={...e,y:D,x2:F}),new gs(t,Yl(ti(jl(e))))}function ws(t,e={}){return ht(e)||(e={...e,x:D,y2:F}),new vs(t,_l(ei(ql(e))))}const bs={ariaLabel:"cell"};class ks extends ms{constructor(t,{x:e,y:n,...r}={}){super(t,{x:{value:e,scale:"x",type:"band",optional:!0},y:{value:n,scale:"y",type:"band",optional:!0}},r,bs)}_transform(t,e){t.call(Cn,e,{},0,0)}}function $s(t,{x:e,y:n,...r}={}){return[e,n]=vt(e,n),new ks(t,{...r,x:e,y:n})}const Ms={ariaLabel:"dot",fill:"none",stroke:"currentColor",strokeWidth:1.5};function Ls(t){return void 0===t.sort&&void 0===t.reverse?be({channel:"-r"},t):t}class As extends ko{constructor(t,n={}){const{x:r,y:o,r:i,rotate:a,symbol:s=e.symbolCircle,frameAnchor:c}=n,[u,f]=rt(a,0),[h,d]=function(t){if(null==t||fe(t))return[void 0,t];if("string"==typeof t){const e=ue.get(`${t}`.toLowerCase());if(e)return[void 0,e]}return[t,void 0]}(s),[p,m]=rt(i,null==h?3:4.5);super(t,{x:{value:r,scale:"x",optional:!0},y:{value:o,scale:"y",optional:!0},r:{value:p,scale:"r",filter:l,optional:!0},rotate:{value:u,optional:!0},symbol:{value:h,scale:"auto",optional:!0}},Ls(n),Ms),this.r=m,this.rotate=f,this.symbol=d,this.frameAnchor=Zt(c);const{channels:y}=this,{symbol:g}=y;if(g){const{fill:t,stroke:e}=y;g.hint={fill:t?t.value===g.value?"color":"currentColor":this.fill??"currentColor",stroke:e?e.value===g.value?"color":"currentColor":this.stroke??"none"}}}render(t,n,r,o,i){const{x:a,y:l}=n,{x:c,y:u,r:f,rotate:h,symbol:d}=r,{r:p,rotate:m,symbol:y}=this,[g,v]=Wn(this,o),x=y===e.symbolCircle,w=f?void 0:p*p*Math.PI;return s(p)&&(t=[]),qn("svg:g",i).call(zn,this,o,i).call(Cn,this,{x:c&&a,y:u&&l}).call((n=>n.selectAll().data(t).enter().append(x?"circle":"path").call(En,this).call(x?t=>{t.attr("cx",c?t=>c[t]:g).attr("cy",u?t=>u[t]:v).attr("r",f?t=>f[t]:p)}:t=>{t.attr("transform",ui`translate(${c?t=>c[t]:g},${u?t=>u[t]:v})${h?t=>` rotate(${h[t]})`:m?` rotate(${m})`:""}`).attr("d",f&&d?t=>{const n=e.pathRound();return d[t].draw(n,f[t]*f[t]*Math.PI),n}:f?t=>{const n=e.pathRound();return y.draw(n,f[t]*f[t]*Math.PI),n}:d?t=>{const n=e.pathRound();return d[t].draw(n,w),n}:(()=>{const t=e.pathRound();return y.draw(t,w),t})())}).call($n,this,r))).node()}}function Ss(t,{x:e,y:n,...r}={}){return void 0===r.frameAnchor&&([e,n]=vt(e,n)),new As(t,{...r,x:e,y:n})}const zs={ariaLabel:"line",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class Es extends ko{constructor(t,e={}){const{x:n,y:r,z:o,curve:i,tension:a}=e;super(t,{x:{value:n,scale:"x"},y:{value:r,scale:"y"},z:{value:xt(e),optional:!0}},e,zs),this.z=o,this.curve=fl(i,a),Io(this,e)}filter(t){return t}project(t,e,n){this.curve!==hl&&super.project(t,e,n)}render(t,n,r,o,i){const{x:a,y:l}=r,{curve:s}=this;return qn("svg:g",i).call(zn,this,o,i).call(Cn,this,n).call((n=>n.selectAll().data(An(t,[a,l],this,r)).enter().append("path").call(En,this).call(Mn,this,r).call(_o,this,r,i).attr("d",s===hl&&i.projection?function(t,n,r){const o=e.geoPath(t);return n=J(n),r=J(r),t=>{let e=[];const i=[e];for(const o of t)-1===o?(e=[],i.push(e)):e.push([n[o],r[o]]);return o({type:"MultiLineString",coordinates:i})}}(i.projection,a,l):e.line().curve(s).defined((t=>t>=0)).x((t=>a[t])).y((t=>l[t]))))).node()}}function Os(t,{x:e,y:n,...r}={}){return[e,n]=vt(e,n),new Es(t,{...r,x:e,y:n})}function Rs(t,{x:e=F,y:n=D,...r}={}){return new Es(t,vl({...r,x:e,y:n}))}function Cs(t,{x:e=D,y:n=F,...r}={}){return new Es(t,gl({...r,x:e,y:n}))}const Ts={ariaLabel:"rect"};class Bs extends ko{constructor(t,e={}){const{x1:n,y1:r,x2:o,y2:i,inset:a=0,insetTop:l=a,insetRight:s=a,insetBottom:c=a,insetLeft:u=a,rx:f,ry:h}=e;super(t,{x1:{value:n,scale:"x",optional:!0},y1:{value:r,scale:"y",optional:!0},x2:{value:o,scale:"x",optional:!0},y2:{value:i,scale:"y",optional:!0}},e,Ts),this.insetTop=X(l),this.insetRight=X(s),this.insetBottom=X(c),this.insetLeft=X(u),this.rx=Tn(f,"auto"),this.ry=Tn(h,"auto")}render(t,e,n,r,o){const{x:i,y:a}=e,{x1:l,y1:s,x2:c,y2:u}=n,{marginTop:f,marginRight:h,marginBottom:d,marginLeft:p,width:m,height:y}=r,{projection:g}=o,{insetTop:v,insetRight:x,insetBottom:w,insetLeft:b,rx:k,ry:$}=this;return qn("svg:g",o).call(zn,this,r,o).call(Cn,this,{x:l&&c&&i,y:s&&u&&a},0,0).call((e=>e.selectAll().data(t).enter().append("rect").call(En,this).attr("x",l&&c&&(g||!no(i))?t=>Math.min(l[t],c[t])+b:p+b).attr("y",s&&u&&(g||!no(a))?t=>Math.min(s[t],u[t])+v:f+v).attr("width",l&&c&&(g||!no(i))?t=>Math.max(0,Math.abs(c[t]-l[t])-b-x):m-h-p-x-b).attr("height",s&&u&&(g||!no(a))?t=>Math.max(0,Math.abs(s[t]-u[t])-v-w):y-f-d-v-w).call(Rn,"rx",k).call(Rn,"ry",$).call($n,this,n))).node()}}function Ns(t,e){return new Bs(t,Jo(Ko(e)))}function Is(t,e={}){return ht(e)||(e={...e,y:D,x2:F,interval:1}),new Bs(t,Yl(Ko(jl(e))))}function Ps(t,e={}){return ht(e)||(e={...e,x:D,y2:F,interval:1}),new Bs(t,_l(Jo(ql(e))))}function Ws(t,e){e=function({x:t,y:e,color:n,size:r,fx:o,fy:i,mark:a}={}){mt(t)||(t=Ds(t));mt(e)||(e=Ds(e));mt(n)||(n=Gt(n)?{color:n}:Ds(n));mt(r)||(r=Ds(r));mt(o)&&({value:o}=Ds(o));mt(i)&&({value:i}=Ds(i));null!=a&&(a=`${a}`.toLowerCase());return{x:t,y:e,color:n,size:r,fx:o,fy:i,mark:a}}(e);const{x:n,y:r,color:o,size:i}=e,a=qs(t,n),l=qs(t,r),s=qs(t,o),c=qs(t,i);let u,f,h,{fx:d,fy:p,x:{value:m,reduce:y,zero:g,...v},y:{value:x,reduce:w,zero:b,...k},color:{value:$,color:M,reduce:L},size:{value:A,reduce:S},mark:z}=e;if(void 0===y&&(y=null==w&&null==m&&null==A&&null!=x?"count":null),void 0===w&&(w=null==y&&null==x&&null==A&&null!=m?"count":null),void 0!==S||null!=A||null!=L||null!=y||null!=w||null!=m&&!Wt(a)||null!=x&&!Wt(l)||(S="count"),void 0===g&&(g=!!Fs(y)||void 0),void 0===b&&(b=!!Fs(w)||void 0),null==m&&null==x)throw new Error("must specify x or y");if(null!=y&&null==x)throw new Error("reducing x requires y");if(null!=w&&null==m)throw new Error("reducing y requires x");switch(void 0===z&&(z=null!=A||null!=S?"dot":Fs(y)||Fs(w)||null!=L?"bar":null!=m&&null!=x?Wt(a)||Wt(l)||null==y&&null==w&&!js(a)&&!js(l)?"dot":"line":null!=m||null!=x?"rule":null),z){case"dot":h=Ss,f="stroke";break;case"line":h=a&&l||null!=y||null!=w?b||null!=w||a&&js(a)?Cs:g||null!=y||l&&js(l)?Rs:Os:a?Rs:Cs,f="stroke",_s(s)&&(u=null);break;case"area":h=!b&&null==w&&(g||null!=y||l&&js(l))?as:ls,f="fill",_s(s)&&(u=null);break;case"rule":h=a?li:si,f="stroke";break;case"bar":h=null!=y?Wt(l)?Ys(y)&&a&&Wt(a)?$s:xs:Is:null!=w?Wt(a)?Ys(w)&&l&&Wt(l)?$s:ws:Ps:null!=L||null!=S?a&&Wt(a)&&l&&Wt(l)?$s:a&&Wt(a)?ws:l&&Wt(l)?xs:Ns:!a||!Ft(a)||l&&Ft(l)?!l||!Ft(l)||a&&Ft(a)?$s:ws:xs,f="fill";break;default:throw new Error(`invalid mark: ${z}`)}let E,O={fx:d,fy:p,x:a??void 0,y:l??void 0,[f]:s??M,z:u,r:c??void 0,tip:!0},R={[f]:L??void 0,r:S??void 0};if(null!=y&&null!=w)throw new Error("cannot reduce both x and y");return null!=w?(R.y=w,E=Wt(a)?Ae:dl):null!=y?(R.x=y,E=Wt(l)?Se:pl):null==L&&null==S||(a&&l?E=Wt(a)&&Wt(l)?ze:Wt(a)?pl:Wt(l)?dl:ml:a?E=Wt(a)?Ae:dl:l&&(E=Wt(l)?Se:pl)),E!==ml&&E!==dl||(O.x={value:a,...v}),E!==ml&&E!==pl||(O.y={value:l,...k}),void 0===g&&(g=a&&!(E===ml||E===dl)&&(h===xs||h===as||h===Is||h===si)),void 0===b&&(b=l&&!(E===ml||E===pl)&&(h===ws||h===ls||h===Ps||h===li)),{fx:d??null,fy:p??null,x:{value:m??null,reduce:y??null,zero:!!g,...v},y:{value:x??null,reduce:w??null,zero:!!b,...k},color:{value:$??null,reduce:L??null,...void 0!==M&&{color:M}},size:{value:A??null,reduce:S??null},mark:z,markImpl:Xs[h],markOptions:O,transformImpl:Xs[E],transformOptions:R,colorMode:f}}function js(t){let n,r;for(const o of t){if(null==o)continue;if(void 0===n){n=o;continue}const t=Math.sign(e.ascending(n,o));if(t){if(void 0!==r&&t!==r)return!1;n=o,r=t}}return!0}function qs(t,e){const n=I(t,e.value);return n&&(n.label=zt(e.value)),n}function Ds(t){return function(t){if(null==t)return!1;if("function"==typeof t.reduceIndex)return!0;if("function"==typeof t.reduce&&dt(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 Fs(t){return/^(?:distinct|count|sum|proportion)$/i.test(t)}function Ys(t){return/^(?:first|last|mode)$/i.test(t)}function _s(t){return!!t&&new e.InternSet(t).size>t.length>>1}const Gs={dot:Ss,line:Os,lineX:Rs,lineY:Cs,areaX:as,areaY:ls,ruleX:li,ruleY:si,barX:xs,barY:ws,rect:Ns,rectX:Is,rectY:Ps,cell:$s,bin:ml,binX:dl,binY:pl,group:ze,groupX:Ae,groupY:Se},Xs=Object.fromEntries(Object.entries(Gs).map((([t,e])=>[e,t])));function Us(t,e={}){let{x:n,x1:r,x2:o}=e;void 0===n&&void 0===r&&void 0===o&&(e={...e,x:n=F});const i={};return null!=n&&(i.x=t),null!=r&&(i.x1=t),null!=o&&(i.x2=t),Hs(i,e)}function Vs(t,e={}){let{y:n,y1:r,y2:o}=e;void 0===n&&void 0===r&&void 0===o&&(e={...e,y:n=F});const i={};return null!=n&&(i.y=t),null!=r&&(i.y1=t),null!=o&&(i.y2=t),Hs(i,e)}function Hs(t={},n={}){const r=xt(n),o=Object.entries(t).map((([t,e])=>{const r=Lt(t,n);if(null==r)throw new Error(`missing channel: ${t}`);const[o,i]=At(r);return{key:t,input:r,output:o,setOutput:i,map:Zs(e)}}));return{...pe(n,((t,n)=>{const i=I(t,r),a=o.map((({input:e})=>I(t,e))),l=o.map((({setOutput:e})=>e(new Array(t.length))));for(const t of n)for(const n of i?e.group(t,(t=>i[t])).values():[t])o.forEach((({map:t},e)=>t.mapIndex(n,a[e],l[e])));return{data:t,facets:n}})),...Object.fromEntries(o.map((({key:t,output:e})=>[t,e])))}}function Zs(t){if(null==t)throw new Error("missing map");if("function"==typeof t.mapIndex)return t;if("function"==typeof t.map&&dt(t))return function(t){return console.warn("deprecated map interface; implement mapIndex instead."),{mapIndex:t.map.bind(t)}}(t);if("function"==typeof t)return Qs(kt(t));switch(`${t}`.toLowerCase()){case"cumsum":return Js;case"rank":return Qs(((t,n)=>e.rank(t,(t=>n[t]))));case"quantile":return Qs(((t,n)=>function(t,n){const r=e.count(t,n)-1;return e.rank(t,n).map((t=>t/r))}(t,(t=>n[t]))))}throw new Error(`invalid map: ${t}`)}function Qs(t){return{mapIndex(e,n,r){const o=t(e,n);if(o.length!==e.length)throw new Error("map function returned a mismatched length");for(let t=0,n=e.length;t0))throw new Error(`invalid k: ${n}`);return function(t="mean"){if("string"==typeof t){if(/^p\d{2}$/i.test(t))return tc(Q(t));switch(t.toLowerCase()){case"deviation":return tc(e.deviation);case"max":return ec(((t,n)=>e.max(t,(t=>n[t]))));case"mean":return rc;case"median":return tc(e.median);case"min":return ec(((t,n)=>e.min(t,(t=>n[t]))));case"mode":return ec(((t,n)=>e.mode(t,(t=>n[t]))));case"sum":return nc;case"variance":return tc(e.variance);case"difference":return sc;case"ratio":return cc;case"first":return uc;case"last":return fc}}if("function"!=typeof t)throw new Error(`invalid reduce: ${t}`);return ec(kt(t))}(r)(n,function(t="middle",e){switch(`${t}`.toLowerCase()){case"middle":return e-1>>1;case"start":return 0;case"end":return e-1}throw new Error(`invalid anchor: ${t}`)}(i,n),a)}function tc(t){return(e,n,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=-n;o<0;++o)i[r[o+n]]=t($t(r,0,o+e),a);for(let o=0,l=r.length-n;oo?{mapIndex(o,i,a){let l=0;for(let t=0;t=r;--i){const r=t[e[i]];if(n(r))return r}}function ac(t,e,n,r){for(let o=n+r;n=n;--o){let n=t[e[o]];if(null!==n&&!isNaN(n=+n))return n}}function sc(t,e,n){return n?{mapIndex(n,r,o){for(let i=0,a=n.length-t;ie.mean(t)+n*(e.deviation(t)||0),strict:r,anchor:o})}const pc={ariaLabel:"tick",fill:null,stroke:"currentColor"};class mc extends ko{constructor(t,e,n){super(t,e,n,pc),Io(this,n)}render(t,e,n,r,o){return qn("svg:g",o).call(zn,this,r,o).call(this._transform,this,e).call((i=>i.selectAll().data(t).enter().append("line").call(En,this).attr("x1",this._x1(e,n,r)).attr("x2",this._x2(e,n,r)).attr("y1",this._y1(e,n,r)).attr("y2",this._y2(e,n,r)).call($n,this,n).call(Yo,this,n,o))).node()}}class yc extends mc{constructor(t,e={}){const{x:n,y:r,inset:o=0,insetTop:i=o,insetBottom:a=o}=e;super(t,{x:{value:n,scale:"x"},y:{value:r,scale:"y",type:"band",optional:!0}},e),this.insetTop=X(i),this.insetBottom=X(a)}_transform(t,e,{x:n}){t.call(Cn,e,{x:n},gn,0)}_x1(t,{x:e}){return t=>e[t]}_x2(t,{x:e}){return t=>e[t]}_y1({y:t},{y:e},{marginTop:n}){const{insetTop:r}=this;return e&&t?t=>e[t]+r:n+r}_y2({y:t},{y:e},{height:n,marginBottom:r}){const{insetBottom:o}=this;return e&&t?n=>e[n]+t.bandwidth()-o:n-r-o}}class gc extends mc{constructor(t,e={}){const{x:n,y:r,inset:o=0,insetRight:i=o,insetLeft:a=o}=e;super(t,{y:{value:r,scale:"y"},x:{value:n,scale:"x",type:"band",optional:!0}},e),this.insetRight=X(i),this.insetLeft=X(a)}_transform(t,e,{y:n}){t.call(Cn,e,{y:n},0,gn)}_x1({x:t},{x:e},{marginLeft:n}){const{insetLeft:r}=this;return e&&t?t=>e[t]+r:n+r}_x2({x:t},{x:e},{width:n,marginRight:r}){const{insetRight:o}=this;return e&&t?n=>e[n]+t.bandwidth()-o:n-r-o}_y1(t,{y:e}){return t=>e[t]}_y2(t,{y:e}){return t=>e[t]}}function vc(t,{x:e=F,...n}={}){return new yc(t,{...n,x:e})}function xc(t,{y:e=F,...n}={}){return new gc(t,{...n,y:e})}function wc(t){const e=bc(t),n=kc(t);return t.map((t=>tn?t:NaN))}function bc(t){const n=2.5*$c(t)-1.5*Mc(t);return e.min(t,(t=>t>=n?t:NaN))}function kc(t){const n=2.5*Mc(t)-1.5*$c(t);return e.max(t,(t=>t<=n?t:NaN))}function $c(t){return e.quantile(t,.25)}function Mc(t){return e.quantile(t,.75)}const Lc={ariaLabel:"raster",stroke:null,pixelSize:1};function Ac(t,e){const n=+t;if(isNaN(n))throw new Error(`invalid ${e}: ${t}`);return n}function Sc(t,e){const n=Math.floor(t);if(isNaN(n))throw new Error(`invalid ${e}: ${t}`);return n}class zc extends ko{constructor(t,e,n={},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}=n;if(null!=o&&(o=Sc(o,"width")),null!=i&&(i=Sc(i,"height")),null!=s&&(s=Ac(s,"x1")),null!=c&&(c=Ac(c,"y1")),null!=u&&(u=Ac(u,"x2")),null!=f&&(f=Ac(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,e,n){return{transform(r){const o=r.length,i=new Float64Array(o),a=(e-t)/n,l=t+a/2;for(let t=0;tt),{x:l,y:s}=r,{document:c}=i,[u,f,h,d]=Rc(r,o,i),p=h-u,m=d-f,{pixelSize:y,width:g=Math.round(Math.abs(p)/y),height:v=Math.round(Math.abs(m)/y)}=this,x=g*v;let{fill:w,fillOpacity:b}=r,k=0;if(this.interpolate){const e=g/p,n=v/m,r=st(l,(t=>(t-u)*e),Float64Array),o=st(s,(t=>(t-f)*n),Float64Array);w&&(w=this.interpolate(t,g,v,r,o,w)),b&&(b=this.interpolate(t,g,v,r,o,b))}else null==this.data&&t&&(k=t.fi*x);const $=c.createElement("canvas");$.width=g,$.height=v;const M=$.getContext("2d"),L=M.createImageData(g,v),A=L.data;let{r:S,g:z,b:E}=e.rgb(this.fill)??{r:0,g:0,b:0},O=255*(this.fillOpacity??1);for(let t=0;t0&&e.blurImage(L,this.blur),M.putImageData(L,0,0),qn("svg:g",i).call(zn,this,o,i).call(Cn,this,n).call((t=>t.append("image").attr("transform",`translate(${u},${f}) scale(${Math.sign(h-u)},${Math.sign(d-f)})`).attr("width",Math.abs(p)).attr("height",Math.abs(m)).attr("preserveAspectRatio","none").call(Rn,"image-rendering",this.imageRendering).call(En,this).attr("xlink:href",$.toDataURL()))).node()}}function Oc(t,e,n){arguments.length<3&&(n=e,e=null);let{x:r,y:o,[t]:i,...a}=n;return void 0===r&&void 0===o&&function(t){if(!It(t))return!1;for(const e of t)if(null!=e)return"object"==typeof e&&"0"in e&&"1"in e}(e)&&(r=U,o=V,void 0===i&&(i=H)),[e,{...a,x:r,y:o,[t]:i}]}function Rc({x1:t,y1:e,x2:n,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,e&&null==i?e[0]:s,n&&null==i?n[0]:a-c,r&&null==i?r[0]:l-u]}function Cc({x1:t,y1:e,x2:n,y2:r},o,i,a){const l={};return t&&(l.x1=t),e&&(l.y1=e),n&&(l.x2=n),r&&(l.y2=r),Rc(Qe(l,o),i,a)}function Tc(t,e={}){const{[t]:n}=e;if("function"!=typeof n)throw new Error(`invalid ${t}: not a function`);return me({...e,[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]=Cc(i,a,l,s),m=d-f,y=p-h,{pixelSize:g}=this,{width:v=Math.round(Math.abs(m)/g),height:x=Math.round(Math.abs(y)/g)}=e,w=new Array(v*x*(o?o.length:1)),b=m/v,k=y/x;let $=0;for(const t of o??[void 0])for(let e=.5;e=e||o[l]<0||o[l]>=n||(a[Math.floor(o[l])*e+Math.floor(r[l])]=i[l]);return a}function Nc({random:t=e.randomLcg(42)}={}){return(n,r,o,i,a,l)=>{const{points:s,triangles:c,hull:u}=e.Delaunay.from(n,(t=>i[t]),(t=>a[t])),f=new l.constructor(r*o).fill(NaN),h=new Uint8Array(r*o),d=function(t,e){return Ft(t)||jt(t)?qc:function(t){return(e,n,r,o,i,a,l,s)=>{const c=t(l,s);return c=r||e<0||e>=o)continue;const n=t+.5,i=e+.5,a=((g-v)*(n-m)+(i-v)*(m-p))/$;if(a<0)continue;const l=((v-y)*(n-m)+(i-v)*(u-m))/$;if(l<0)continue;const s=1-a-l;if(s<0)continue;const c=t+r*e;f[c]=d(M,a,L,l,A,s,t,e),h[c]=1}}return function(t,e,n,r,o,i,a,l,s,c){n=Float64Array.from(l,(t=>n[s[t]])),r=Float64Array.from(l,(t=>r[s[t]])),o=Array.from(l,(t=>o[s[t]]));const u=n.length,f=Array.from({length:u},((t,e)=>function(t,e,n){const r=e.length,o=e.at(t-2),i=n.at(t-2),a=e.at(t-1),l=n.at(t-1),s=e[t],c=n[t],u=e.at(t+1-r),f=n.at(t+1-r),h=a-s,d=l-c,p=o-a,m=i-l,y=s-u,g=c-f,v=Math.hypot(h,d),x=Math.hypot(p,m),w=Math.hypot(y,g);return(t,e)=>{const n=t-a,r=e-l,o=t-s,i=e-c;return Pc(n,r,o,i)>-1e-6&&Pc(n,r,h,d)*x-Pc(n,r,p,m)*v>-1e-6&&Pc(o,i,y,g)*v-Pc(o,i,h,d)*w<=0}}(e,n,r)));let h=0;for(let l=0;l0&&c>0?s/(s+c):+(s>c)}function Pc(t,e,n,r){return t*r-n*e}function Wc(t,n,r,o,i,a){const l=new a.constructor(n*r),s=e.Delaunay.from(t,(t=>o[t]),(t=>i[t]));let c,u;for(let e=.5,o=0;e{const u=new c.constructor(i*a),f=e.Delaunay.from(o,(t=>l[t]),(t=>s[t]));let h,d,p;for(let e=.5,m=0;en&&vt.map((t=>t.value)),label:zt(r)};for(const e in i)"value"===o[e]&&(o[e]=t)}if(null==t){if(null==r)throw new Error("missing contour value");o=Tc("value",{value:r,...o}),r=null}else{let{interpolate:t}=o;void 0===r&&(r=F),void 0===t&&(o.interpolate="nearest")}super(t,{value:{value:r,optional:!0}},function({thresholds:t,interval:n,...r}){return t=$l(t,n,e.thresholdSturges),me(r,(function(n,r,o,i,a,l){const[s,c,u,f]=Cc(o,i,a,l),h=u-s,d=f-c,{pixelSize:p,width:m=Math.round(Math.abs(h)/p),height:y=Math.round(Math.abs(d)/p)}=this,g=m/h,v=y/d,x=o.value.value,w=[];if(this.interpolate){const{x:t,y:e}=Jn(o,i,l),n=st(t,(t=>(t-s)*g),Float64Array),a=st(e,(t=>(t-c)*v),Float64Array),u=[o.x,o.y,o.value],f=[n,a,x];for(const t of r){const e=this.filter(t,u,f);w.push(this.interpolate(e,m,y,n,a,x))}}else if(r){const t=m*y,e=r.length;for(let n=0;n0)for(const t of w)e.blur2({data:t,width:m,height:y},this.blur);const b=function(t,n,r,o){if("function"==typeof t?.range)return t.range(t.floor(r),o);"function"==typeof t&&(t=t(n,r,o));if("number"!=typeof t)return lt(t);const i=e.ticks(...e.nice(r,o,t),t);for(;i[i.length-1]>=o;)i.pop();for(;i[1]e.min(t,Yc))),e.max(t,(t=>e.max(t,Yc)))]}(w));if(null===b)throw new Error(`unsupported thresholds: ${t}`);const{contour:k}=e.contours().size([m,y]).smooth(this.smooth),$=[],M=[];for(const t of w)M.push(e.range($.length,$.push(...st(b,(e=>k(t,e))))));for(const{coordinates:t}of $)for(const e of t)for(const t of e)for(const e of t)e[0]=e[0]/g+s,e[1]=e[1]/v+c;return{data:$,facets:M,channels:Ze(this.contourChannels,$)}}))}(o),Dc);const a={geometry:{value:F}};for(const t in this.channels){const e=this.channels[t],{scale:n}=e;"x"!==n&&"y"!==n&&"value"!==t&&(a[t]=e,delete this.channels[t])}this.contourChannels=a,this.smooth=!!n}filter(t,{x:e,y:n,value:r,...o},i){return super.filter(t,o,i)}render(t,n,r,o,i){const{geometry:a}=r,l=e.geoPath();return qn("svg:g",i).call(zn,this,o,i).call(Cn,this,n).call((e=>{e.selectAll().data(t).enter().append("path").call(En,this).attr("d",(t=>l(a[t]))).call($n,this,r)})).node()}}function Yc(t){return isFinite(t)?t:NaN}function _c(t,e,n={}){const{x:r,y:o,maxRadius:i}=n,a=t({px:r,py:o,maxRadius:i}),l=[];null!=r&&l.push(li(e,Uc("x",{...a,inset:-6},n))),null!=o&&l.push(si(e,Uc("y",{...a,inset:-6},n))),null!=r&&l.push(yi(e,Vc("x",{...a,dy:9,frameAnchor:"bottom",lineAnchor:"top"},n))),null!=o&&l.push(yi(e,Vc("y",{...a,dx:-9,frameAnchor:"left",textAnchor:"end"},n)));for(const t of l)t.ariaLabel=`crosshair ${t.ariaLabel}`;return $o(...l)}function Gc(t,{channels:e,...n},{facet:r,facetAnchor:o,fx:i,fy:a,[t]:l,channels:s,transform:c,initializer:u}){return{...n,facet:r,facetAnchor:o,fx:i,fy:a,[t]:l,channels:{...e,...s},transform:c,initializer:Xc(t,u)}}function Xc(t,e){return null==e?e:function(n,r,{x:o,y:i,px:a,py:l,...s},...c){const{channels:{x:u,y:f,...h}={},...d}=e.call(this,n,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 Uc(t,e,n){const{color:r="currentColor",opacity:o=.2,ruleStroke:i=r,ruleStrokeOpacity:a=o,ruleStrokeWidth:l}=n;return{...Gc(t,e,n),stroke:i,strokeOpacity:a,strokeWidth:l}}function Vc(t,e,n){const{color:r="currentColor",textFill:o=r,textFillOpacity:i,textStroke:a="white",textStrokeOpacity:l,textStrokeWidth:s=5}=n;return{...Gc(t,e,Hc(t,n)),fill:o,fillOpacity:i,stroke:a,strokeOpacity:l,strokeWidth:s}}function Hc(t,e){return me(e,((e,n,r)=>({channels:{text:{value:ln(r,t)?.value}}})))}const Zc={ariaLabel:"delaunay link",fill:"none",stroke:"currentColor",strokeMiterlimit:1},Qc={ariaLabel:"delaunay mesh",fill:null,stroke:"currentColor",strokeOpacity:.2},Jc={ariaLabel:"hull",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:1},Kc={ariaLabel:"voronoi",fill:"none",stroke:"currentColor",strokeMiterlimit:1},tu={ariaLabel:"voronoi mesh",fill:null,stroke:"currentColor",strokeOpacity:.2};class eu extends ko{constructor(t,e={}){const{x:n,y:r,z:o,curve:i,tension:a}=e;super(t,{x:{value:n,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},z:{value:o,optional:!0}},e,Zc),this.curve=ul(i,a),Io(this,e)}render(t,n,r,o,i){const{x:a,y:l}=n,{x:s,y:c,z:u}=r,{curve:f}=this,[h,d]=Wn(this,o),p=s?t=>s[t]:Z(h),m=c?t=>c[t]:Z(d),y=this;function g(t){let n=-1;const o=[],a={};for(const t in r)a[t]=[];const l=[],s=[],c=[],u=[];function h(e,i){e=t[e],i=t[i],o.push(++n),l[n]=p(e),c[n]=m(e),s[n]=p(i),u[n]=m(i);for(const t in r)a[t].push(r[t][i])}const{halfedges:d,hull:g,triangles:v}=e.Delaunay.from(t,p,m);for(let t=0;tt&&h(v[t],v[e])}for(let t=0;t{const n=e.pathRound(),r=f(n);return r.lineStart(),r.point(l[t],c[t]),r.point(s[t],u[t]),r.lineEnd(),n})).call($n,y,a).call(Yo,y,a,i)}return qn("svg:g",i).call(zn,this,o,i).call(Cn,this,{x:s&&a,y:c&&l}).call(u?n=>n.selectAll().data(e.group(t,(t=>u[t])).values()).enter().append("g").each(g):e=>e.datum(t).each(g)).node()}}class nu extends ko{constructor(t,e={},n,r=(({z:t})=>t)){const{x:o,y:i}=e;super(t,{x:{value:o,scale:"x",optional:!0},y:{value:i,scale:"y",optional:!0},z:{value:r(e),optional:!0}},e,n)}render(t,n,r,o,i){const{x:a,y:l}=n,{x:s,y:c,z:u}=r,[f,h]=Wn(this,o),d=s?t=>s[t]:Z(f),p=c?t=>c[t]:Z(h),m=this;function y(t){const n=e.Delaunay.from(t,d,p);e.select(this).append("path").datum(t[0]).call(En,m).attr("d",m._render(n,o)).call($n,m,r)}return qn("svg:g",i).call(zn,this,o,i).call(Cn,this,{x:s&&a,y:c&&l}).call(u?n=>n.selectAll().data(e.group(t,(t=>u[t])).values()).enter().append("g").each(y):e=>e.datum(t).each(y)).node()}}class ru extends nu{constructor(t,e={}){super(t,e,Qc),this.fill="none"}_render(t){return t.render()}}class ou extends nu{constructor(t,e={}){super(t,e,Jc,xt)}_render(t){return t.renderHull()}}class iu extends ko{constructor(t,e={}){const{x:n,y:r,z:o}=e;super(t,{x:{value:n,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},z:{value:o,optional:!0}},e,Kc)}render(t,n,r,o,i){const{x:a,y:l}=n,{x:s,y:c,z:u}=r,[f,h]=Wn(this,o),d=s?t=>s[t]:Z(f),p=c?t=>c[t]:Z(h),m=this;function y(t){const n=lu(e.Delaunay.from(t,d,p),o);e.select(this).selectAll().data(t).enter().append("path").call(En,m).attr("d",((t,e)=>n.renderCell(e))).call($n,m,r)}return qn("svg:g",i).call(zn,this,o,i).call(Cn,this,{x:s&&a,y:c&&l}).call(u?n=>n.selectAll().data(e.group(t,(t=>u[t])).values()).enter().append("g").each(y):e=>e.datum(t).each(y)).node()}}class au extends nu{constructor(t,e){super(t,e,tu),this.fill="none"}_render(t,e){return lu(t,e).render()}}function lu(t,e){const{width:n,height:r,marginTop:o,marginRight:i,marginBottom:a,marginLeft:l}=e;return t.voronoi([l,o,n-i,r-a])}function su(t,e,{x:n,y:r,...o}={}){return[n,r]=vt(n,r),new t(e,{...o,x:n,y:r})}const cu={ariaLabel:"density",fill:"none",stroke:"currentColor",strokeMiterlimit:1};class uu extends ko{constructor(t,{x:n,y:r,z:o,weight:i,fill:a,stroke:l,...s}={}){const c=hu(a)&&(a="currentColor",!0),u=hu(l)&&(l="currentColor",!0);super(t,{x:{value:n,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},z:{value:xt({z:o,fill:a,stroke:l}),optional:!0},weight:{value:i,optional:!0}},function(t,n,r){const o=100;let{bandwidth:i,thresholds:a}=t;return i=void 0===i?20:+i,a=void 0===a?20:"function"==typeof a?.[Symbol.iterator]?J(a):+a,me(t,(function(t,l,s,c,u,f){const h=s.weight?J(s.weight.value):null,d=s.z?.value,{z:p}=this,[m,y]=Wn(this,u),{width:g,height:v}=u,{x:x,y:w}=Jn(s,c,f),b=Object.fromEntries(Object.entries(s).filter((([t])=>!fu.has(t))).map((([t,e])=>[t,{...e,value:[]}]))),k=n&&[],$=r&&[],M=e.contourDensity().x(x?t=>x[t]:m).y(w?t=>w[t]:y).weight(h?t=>h[t]:1).size([g,v]).bandwidth(i),L=[];for(const t of l){const e=[];L.push(e);for(const n of d?Ln(t,d,p):[t]){const t=M.contours(n);e.push([n,t])}}let A=a;if(!(A instanceof T)){let t=0;for(const e of L)for(const[,n]of e){const e=n.max;e>t&&(t=e)}A=Float64Array.from({length:a-1},((e,n)=>t*o*(n+1)/a))}const S=[],z=[];for(const t of L){const e=[];S.push(e);for(const[n,r]of t)for(const t of A){e.push(z.length),z.push(r(t/o)),k&&k.push(t),$&&$.push(t);for(const t in b)b[t].value.push(s[t].value[n[0]])}}return k&&k.push(0),$&&$.push(0),{data:t,facets:S,channels:{...b,...k&&{fill:{value:k,scale:"color"}},...$&&{stroke:{value:$,scale:"color"}},contours:{value:z}}}}))}({...s,fill:a,stroke:l},c,u),cu),c&&(this.fill=void 0),u&&(this.stroke=void 0),this.z=o}filter(t){return t}render(t,n,r,o,i){const{contours:a}=r,l=e.geoPath();return qn("svg:g",i).call(zn,this,o,i).call(Cn,this,{}).call((e=>e.selectAll().data(t).enter().append("path").call(En,this).call($n,this,r).attr("d",(t=>l(a[t]))))).node()}}const fu=new Set(["x","y","z","weight"]);function hu(t){return/^density$/i.test(t)}const du={ariaLabel:"geo",fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class pu extends ko{constructor(t,e={}){const[n,r]=rt(e.r,3);super(t,{geometry:{value:e.geometry,scale:"projection"},r:{value:n,scale:"r",filter:l,optional:!0}},Ls(e),du),this.r=r}render(t,n,r,o,i){const{geometry:a,r:l}=r,c=e.geoPath(i.projection??function({x:t,y:n}){if(t||n)return t??=t=>t,n??=t=>t,e.geoTransform({point(e,r){this.stream.point(t(e),n(r))}})}(n)),{r:u}=this;return s(u)?t=[]:void 0!==u&&c.pointRadius(u),qn("svg:g",i).call(zn,this,o,i).call(Cn,this,n).call((e=>{e.selectAll().data(t).enter().append("path").call(En,this).attr("d",l?t=>c.pointRadius(l[t])(a[t]):t=>c(a[t])).call($n,this,r)})).node()}}function mu(t,{geometry:e=F,...n}={}){switch(t?.type){case"FeatureCollection":t=t.features;break;case"GeometryCollection":t=t.geometries;break;case"Feature":case"LineString":case"MultiLineString":case"MultiPoint":case"MultiPolygon":case"Point":case"Polygon":case"Sphere":t=[t]}return new pu(t,{geometry:e,...n})}const yu=.5,gu=0;function vu(t,e,n,r){const o=r*(1.5/le),i=new Map;for(const a of t){let t=e[a],l=n[a];if(isNaN(t)||isNaN(l))continue;let s=Math.round(l=(l-gu)/o),c=Math.round(t=(t-yu)/r-(1&s)/2),u=l-s;if(3*Math.abs(u)>1){let e=t-c,n=c+(to*o+i*i&&(c=n+(1&s?1:-1)/2,s=r)}const f=`${c},${s}`;let h=i.get(f);void 0===h&&(i.set(f,h=[]),h.x=(c+(1&s)/2)*r+yu,h.y=s*o+gu),h.push(a)}return i.values()}const xu={ariaLabel:"hexgrid",fill:"none",stroke:"currentColor",strokeOpacity:.1};class wu extends ko{constructor({binWidth:t=20,clip:e=!0,...n}={}){super(j,void 0,{clip:e,...n},xu),this.binWidth=X(t)}render(t,e,n,r,o){const{binWidth:i}=this,{marginTop:a,marginRight:l,marginBottom:s,marginLeft:c,width:u,height:f}=r,h=c-yu,d=u-l-yu,p=a-gu,m=f-s-gu,y=i/2,g=y*se,v=g/2,x=2*y,w=1.5*g,b=Math.floor(h/x),k=Math.ceil(d/x),$=Math.floor((p+v)/w),M=Math.ceil((m-v)/w)+1,L=`m0,${bu(-g)}l${bu(y)},${bu(v)}v${bu(g)}l${bu(-y)},${bu(v)}`;let A=L;for(let t=$;tt.append("path").call(En,this).call($n,this,n).attr("d",A))).node()}}function bu(t){return Math.round(1e3*t)/1e3}const ku={ariaLabel:"image",fill:null,stroke:null};class $u extends ko{constructor(t,e={}){let{x:n,y:r,r:o,width:i,height:a,rotate:s,src:c,preserveAspectRatio:u,crossOrigin:f,frameAnchor:h,imageRendering:d}=e;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[p,m]="string"==typeof(y=c)&&(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[g,v]=rt(o),[x,w]=rt(i,void 0!==v?2*v:void 0),[b,k]=rt(a,void 0!==v?2*v:void 0),[$,M]=rt(s,0);super(t,{x:{value:n,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},r:{value:g,scale:"r",filter:l,optional:!0},width:{value:x,filter:l,optional:!0},height:{value:b,filter:l,optional:!0},rotate:{value:$,optional:!0},src:{value:p,optional:!0}},Ls(e),ku),this.src=m,this.width=w,this.rotate=M,this.height=k,this.r=v,this.preserveAspectRatio=Tn(u,"xMidYMid"),this.crossOrigin=G(f),this.frameAnchor=Zt(h),this.imageRendering=Tn(d,"auto")}render(t,e,n,r,o){const{x:i,y:a}=e,{x:l,y:s,width:c,height:u,r:f,rotate:h,src:d}=n,{r:p,width:m,height:y,rotate:g}=this,[v,x]=Wn(this,r);return qn("svg:g",o).call(zn,this,r,o).call(Cn,this,{x:l&&i,y:s&&a}).call((e=>e.selectAll().data(t).enter().append("image").call(En,this).attr("x",Mu(l,c,f,v,m,p)).attr("y",Mu(s,u,f,x,y,p)).attr("width",c?t=>c[t]:void 0!==m?m:f?t=>2*f[t]:2*p).attr("height",u?t=>u[t]:void 0!==y?y:f?t=>2*f[t]:2*p).attr("transform",h?t=>`rotate(${h[t]})`:g?`rotate(${g})`:null).attr("transform-origin",h||g?ui`${l?t=>l[t]:v}px ${s?t=>s[t]:x}px`:null).call(Rn,"href",d?t=>d[t]:this.src).call(Rn,"preserveAspectRatio",this.preserveAspectRatio).call(Rn,"crossorigin",this.crossOrigin).call(Rn,"image-rendering",this.imageRendering).call(Rn,"clip-path",f?t=>`circle(${f[t]}px)`:void 0!==p?`circle(${p}px)`:null).call($n,this,n))).node()}}function Mu(t,e,n,r,o,i){return e&&t?n=>t[n]-e[n]/2:e?t=>r-e[t]/2:t&&void 0!==o?e=>t[e]-o/2:void 0!==o?r-o/2:n&&t?e=>t[e]-n[e]:n?t=>r-n[t]:t?e=>t[e]-i:r-i}function Lu(t,e,n){var r=0===t||1===t?0:Math.exp(Su(e+n)-Su(e)-Su(n)+e*Math.log(t)+n*Math.log(1-t));return!(t<0||t>1)&&(t<(e+1)/(e+n+2)?r*Au(t,e,n)/e:1-r*Au(1-t,n,e)/n)}function Au(t,e,n){var r,o,i,a,l=1e-30,s=1,c=e+n,u=e+1,f=e-1,h=1,d=1-c*t/u;for(Math.abs(d)=1)return 1;for(e>=1&&n>=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*e-1)+1/(2*n-1)),f=s*Math.sqrt(c+u)/u-(1/(2*n-1)-1/(2*e-1))*(c+5/6-2/(3*u)),s=e/(e+n*Math.exp(2*f))):(r=Math.log(e/(e+n)),o=Math.log(n/(e+n)),s=t<(a=Math.exp(e*r)/e)/(f=a+(l=Math.exp(n*o)/n))?Math.pow(e*f*t,1/e):1-Math.pow(n*f*(1-t),1/n)),h=-Su(e)-Su(n)+Su(e+n);m<10;m++){if(0===s||1===s)return s;if((s-=a=(l=(Lu(s,e,n)-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&&m>0)break}return s}(2*Math.min(t,1-t),.5*e,.5);return n=Math.sqrt(e*(1-n)/n),t>.5?n:-n}const Eu={ariaLabel:"linear-regression",fill:"currentColor",fillOpacity:.1,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class Ou extends ko{constructor(t,e={}){const{x:n,y:r,z:o,ci:i=.95,precision:a=4}=e;if(super(t,{x:{value:n,scale:"x"},y:{value:r,scale:"y"},z:{value:xt(e),optional:!0}},e,Eu),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,e,n,r,o){const{x:i,y:a,z:l}=n,{ci:s}=this;return qn("svg:g",o).call(zn,this,r,o).call(Cn,this,e).call((e=>e.selectAll().data(l?Ln(t,l,this.z):[t]).enter().call((t=>t.append("path").attr("fill","none").call(En,this).call(Mn,this,{...n,fill:null,fillOpacity:null}).attr("d",(t=>this._renderLine(t,i,a))).call(s&&!Vt(this.fill)?t=>t.select(Ru).attr("stroke","none").call(En,this).call(Mn,this,{...n,stroke:null,strokeOpacity:null,strokeWidth:null}).attr("d",(t=>this._renderBand(t,i,a))):()=>{}))))).node()}}function Ru(){return this.parentNode.insertBefore(this.ownerDocument.createElementNS(e.namespaces.svg,"path"),this)}class Cu extends Ou{constructor(t,e){super(t,e)}_renderBand(t,n,r){const{ci:o,precision:i}=this,[a,l]=e.extent(t,(t=>r[t])),s=Bu(t,r,n),c=Nu(t,r,n,(1-o)/2,s);return e.area().y((t=>t)).x0((t=>c(t,-1))).x1((t=>c(t,1)))(e.range(a,l-i/2,i).concat(l))}_renderLine(t,n,r){const[o,i]=e.extent(t,(t=>r[t])),a=Bu(t,r,n);return`M${a(o)},${o}L${a(i)},${i}`}}class Tu extends Ou{constructor(t,e){super(t,e)}_renderBand(t,n,r){const{ci:o,precision:i}=this,[a,l]=e.extent(t,(t=>n[t])),s=Bu(t,n,r),c=Nu(t,n,r,(1-o)/2,s);return e.area().x((t=>t)).y0((t=>c(t,-1))).y1((t=>c(t,1)))(e.range(a,l-i/2,i).concat(l))}_renderLine(t,n,r){const[o,i]=e.extent(t,(t=>n[t])),a=Bu(t,n,r);return`M${o},${a(o)}L${i},${a(i)}`}}function Bu(t,e,n){let r=0,o=0,i=0,a=0;for(const l of t){const t=e[l],s=n[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 Nu(t,n,r,o,i){const a=e.sum(t,(t=>n[t]))/t.length;let l=0,s=0;for(const e of t)l+=(n[e]-a)**2,s+=(r[e]-i(n[e]))**2;const c=Math.sqrt(s/(t.length-2)),u=zu(o,t.length-2);return(e,n)=>{const r=i(e),o=c*Math.sqrt(1/t.length+(e-a)**2/l);return r+n*u*o}}function Iu({path:t=F,delimiter:n,frameAnchor:r,treeLayout:o=e.tree,treeSort:i,treeSeparation:a,treeAnchor:l,treeFilter:s,...c}={}){l=Wu(l),i=Du(i),null!=s&&(s=Uu(s)),void 0===r&&(r=l.frameAnchor);const u=Yu(n),f=lf(c,Uu),[h,d]=At(),[p,m]=At();return{x:h,y:p,frameAnchor:r,...pe(c,((n,r)=>{const c=u(I(n,t)),h=d([]),p=m([]);let y=-1;const g=[],v=[],x=e.stratify().path((t=>c[t])),w=o();w.nodeSize&&w.nodeSize([1,1]),w.separation&&void 0!==a&&w.separation(a??Y);for(const t of f)t[af]=t[rf]([]);for(const t of r){const e=[],r=x(t.filter((t=>null!=c[t]))).each((t=>t.data=n[t.data]));null!=i&&r.sort(i),w(r);for(const t of r.descendants())if(null==s||s(t)){e.push(++y),g[y]=t.data,l.position(t,y,h,p);for(const e of f)e[af][y]=e[of](t)}v.push(e)}return{data:g,facets:v}})),...Object.fromEntries(f)}}function Pu({path:t=F,delimiter:n,curve:r="bump-x",stroke:o="#555",strokeWidth:i=1.5,strokeOpacity:a=.5,treeLayout:l=e.tree,treeSort:s,treeSeparation:c,treeAnchor:u,treeFilter:f,...h}={}){u=Wu(u),s=Du(s),null!=f&&(f=Vu(f)),h={curve:r,stroke:o,strokeWidth:i,strokeOpacity:a,...h};const d=Yu(n),p=lf(h,Vu),[m,y]=At(),[g,v]=At(),[x,w]=At(),[b,k]=At();return{x1:m,x2:g,y1:x,y2:b,...pe(h,((n,r)=>{const o=d(I(n,t)),i=y([]),a=v([]),h=w([]),m=k([]);let g=-1;const x=[],b=[],$=e.stratify().path((t=>o[t])),M=l();M.nodeSize&&M.nodeSize([1,1]),M.separation&&void 0!==c&&M.separation(c??Y);for(const t of p)t[af]=t[rf]([]);for(const t of r){const e=[],r=$(t.filter((t=>null!=o[t]))).each((t=>t.data=n[t.data]));null!=s&&r.sort(s),M(r);for(const{source:t,target:n}of r.links())if(null==f||f(n,t)){e.push(++g),x[g]=n.data,u.position(t,g,i,h),u.position(n,g,a,m);for(const e of p)e[af][g]=e[of](n,t)}b.push(e)}return{data:x,facets:b}})),...Object.fromEntries(p)}}function Wu(t="left"){switch(`${t}`.trim().toLowerCase()){case"left":return ju;case"right":return qu}throw new Error(`invalid tree anchor: ${t}`)}const ju={frameAnchor:"left",dx:6,position({x:t,y:e},n,r,o){r[n]=e,o[n]=-t}},qu={frameAnchor:"right",dx:-6,position({x:t,y:e},n,r,o){r[n]=-e,o[n]=-t}};function Du(t){return null==t||"function"==typeof t?t:`${t}`.trim().toLowerCase().startsWith("node:")?Fu(Uu(t)):Fu(function(t){return e=>e.data?.[t]}(t))}function Fu(t){return(e,n)=>r(t(e),t(n))}function Yu(t="/"){if("/"===(t=`${t}`))return t=>t;if(1!==t.length)throw new Error("delimiter must be exactly one character");const e=t.charCodeAt(0);return t=>t.map((t=>function(t,e){if(e===_u)throw new Error("delimiter cannot be backslash");let n=!1;for(let r=0,o=t.length;r0&&!nf(t,e););return function(t){let e=!1;for(let n=0,r=t.length;nnull==n?void 0:t(n)}function nf(t,e){if("/"===t[e]){let n=0;for(;e>0&&"\\"===t[--e];)++n;if(0==(1&n))return!0}return!1}const rf=2,of=3,af=4;function lf(t,e){const n=[];for(const r in t){const o=t[r],i=e(o);void 0!==i&&n.push([r,...At(o),i])}return n}function sf(t,{fill:n,stroke:r,strokeWidth:o,strokeOpacity:i,strokeLinejoin:a,strokeLinecap:l,strokeMiterlimit:s,strokeDasharray:c,strokeDashoffset:u,marker:f,markerStart:h=f,markerEnd:d=f,dot:p=Ut(h)&&Ut(d),text:m="node:name",textStroke:y="white",title:g="node:path",dx:v,dy:x,textAnchor:w,treeLayout:b=e.tree,textLayout:k=(b===e.tree||b===e.cluster?"mirrored":"normal"),tip:$,...M}={}){if(void 0===v&&(v=Wu(M.treeAnchor).dx),void 0!==w)throw new Error("textAnchor is not a configurable tree option");function L(e){return yi(t,Iu({treeLayout:b,text:m,fill:void 0===n?"currentColor":n,stroke:y,dx:v,dy:x,title:g,...e,...M}))}return k=at(k,"textLayout",["mirrored","normal"]),$o(us(t,Pu({treeLayout:b,markerStart:h,markerEnd:d,stroke:void 0!==r?r:void 0===n?"node:internal":n,strokeWidth:o,strokeOpacity:i,strokeLinejoin:a,strokeLinecap:l,strokeMiterlimit:s,strokeDasharray:c,strokeDashoffset:u,...M})),p?Ss(t,Iu({treeLayout:b,fill:void 0===n?"node:internal":n,title:g,tip:$,...M})):null,null!=m?"mirrored"===k?[L({textAnchor:"start",treeFilter:"node:external"}),L({textAnchor:"end",treeFilter:"node:internal",dx:-v})]:L():null)}function cf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function uf(t,e,n,r,o){for(var i=o+1;r<=o;){var a=r+o>>>1,l=t[a];(void 0!==n?n(l,e):l-e)>=0?(i=a,o=a-1):r=a+1}return i}function ff(t,e,n,r,o){for(var i=o+1;r<=o;){var a=r+o>>>1,l=t[a];(void 0!==n?n(l,e):l-e)>0?(i=a,o=a-1):r=a+1}return i}function hf(t,e,n,r,o){for(var i=r-1;r<=o;){var a=r+o>>>1,l=t[a];(void 0!==n?n(l,e):l-e)<0?(i=a,r=a+1):o=a-1}return i}function df(t,e,n,r,o){for(var i=r-1;r<=o;){var a=r+o>>>1,l=t[a];(void 0!==n?n(l,e):l-e)<=0?(i=a,r=a+1):o=a-1}return i}function pf(t,e,n,r,o){for(;r<=o;){var i=r+o>>>1,a=t[i],l=void 0!==n?n(a,e):a-e;if(0===l)return i;l<=0?r=i+1:o=i-1}return-1}function mf(t,e,n,r,o,i){return"function"==typeof n?i(t,e,n,void 0===r?0:0|r,void 0===o?t.length-1:0|o):i(t,e,void 0,void 0===n?0:0|n,void 0===r?t.length-1:0|r)}var yf={ge:function(t,e,n,r,o){return mf(t,e,n,r,o,uf)},gt:function(t,e,n,r,o){return mf(t,e,n,r,o,ff)},lt:function(t,e,n,r,o){return mf(t,e,n,r,o,hf)},le:function(t,e,n,r,o){return mf(t,e,n,r,o,df)},eq:function(t,e,n,r,o){return mf(t,e,n,r,o,pf)}},gf=function(t){if(!t||0===t.length)return new Rf(null);return new Rf(Of(t))};function vf(t,e,n,r,o){this.mid=t,this.left=e,this.right=n,this.leftPoints=r,this.rightPoints=o,this.count=(e?e.count:0)+(n?n.count:0)+r.length}var xf=vf.prototype;function wf(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function bf(t,e){var n=Of(e);t.mid=n.mid,t.left=n.left,t.right=n.right,t.leftPoints=n.leftPoints,t.rightPoints=n.rightPoints,t.count=n.count}function kf(t,e){var n=t.intervals([]);n.push(e),bf(t,n)}function $f(t,e){var n=t.intervals([]),r=n.indexOf(e);return r<0?0:(n.splice(r,1),bf(t,n),1)}function Mf(t,e,n){for(var r=0;r=0&&t[r][1]>=e;--r){var o=n(t[r]);if(o)return o}}function Af(t,e){for(var n=0;n>1],o=[],i=[],a=[];for(n=0;n3*(e+1)?kf(this,t):this.left.insert(t):this.left=Of([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?kf(this,t):this.right.insert(t):this.right=Of([t]);else{var n=yf.ge(this.leftPoints,t,zf),r=yf.ge(this.rightPoints,t,Ef);this.leftPoints.splice(n,0,t),this.rightPoints.splice(r,0,t)}},xf.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1)?$f(this,t):2===(i=this.left.remove(t))?(this.left=null,this.count-=1,1):(1===i&&(this.count-=1),i):0;if(t[0]>this.mid)return this.right?4*(this.left?this.left.count:0)>3*(e-1)?$f(this,t):2===(i=this.right.remove(t))?(this.right=null,this.count-=1,1):(1===i&&(this.count-=1),i):0;if(1===this.count)return this.leftPoints[0]===t?2:0;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var n=this,r=this.left;r.right;)n=r,r=r.right;if(n===this)r.right=this.right;else{var o=this.left,i=this.right;n.count-=r.count,n.right=r.left,r.left=o,r.right=i}wf(this,r),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?wf(this,this.left):wf(this,this.right);return 1}for(o=yf.ge(this.leftPoints,t,zf);othis.mid){var n;if(this.right)if(n=this.right.queryPoint(t,e))return n;return Lf(this.rightPoints,t,e)}return Af(this.leftPoints,e)},xf.queryInterval=function(t,e,n){var r;if(tthis.mid&&this.right&&(r=this.right.queryInterval(t,e,n)))return r;return ethis.mid?Lf(this.rightPoints,t,n):Af(this.leftPoints,n)};var Cf=Rf.prototype;Cf.insert=function(t){this.root?this.root.insert(t):this.root=new vf(t[0],null,null,[t],[t])},Cf.remove=function(t){if(this.root){var e=this.root.remove(t);return 2===e&&(this.root=null),0!==e}return!1},Cf.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},Cf.queryInterval=function(t,e,n){if(t<=e&&this.root)return this.root.queryInterval(t,e,n)},Object.defineProperty(Cf,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(Cf,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}});var Tf=cf(gf);const Bf=({marginLeft:t})=>[1,t],Nf=({width:t,marginRight:e})=>[-1,t-e],If=({width:t,marginLeft:e,marginRight:n})=>[0,(e+t-n)/2],Pf=({marginTop:t})=>[1,t],Wf=({height:t,marginBottom:e})=>[-1,t-e],jf=({height:t,marginTop:e,marginBottom:n})=>[0,(e+t-n)/2];function qf(t){return"string"==typeof t?{anchor:t}:t}function Df(t){const{anchor:e,padding:n,...r}=t,{r:o}=r;return[{anchor:e,padding:n,r:o},r]}function Ff(t,e,n,r,o,i){if(null!=o&&"number"!=typeof o){let{channels:t,sort:e,reverse:n}=i;t=Jt(t),void 0===t?.r&&(i={...i,channels:{...t,r:{value:o,scale:"r"}}}),void 0===e&&void 0===n&&(i.sort={channel:"-r"})}return me(i,(function(i,s,c,u,f,h){let{[e]:d,r:p}=c;if(!c[e])throw new Error(`missing channel: ${e}`);({[e]:d}=Jn(c,u,h));const m=p?void 0:void 0!==o?X(o):void 0!==this.r?this.r:3;p&&(p=I(p.value,u[p.scale]||F,Float64Array));let[y,g]=n(f);const v=y?_f:Yf,x=new Float64Array(d.length),w=p?t=>p[t]:()=>m;for(let t of s){const e=Tf();t=t.filter(p?t=>a(d[t])&&l(p[t]):t=>a(d[t]));const n=new Float64Array(2*t.length+2);for(const o of t){const t=w(o),i=y?t+r:0,a=d[o]-t,l=d[o]+t;let s=2;e.queryInterval(a-r,l+r,(([,,t])=>{const e=x[t]-i,a=d[o]-d[t],l=r+(p?p[o]+p[t]:2*m),c=Math.sqrt(l*l-a*a);n[s++]=e-c,n[s++]=e+c}));let c=n.slice(0,s);y&&(c=c.filter((t=>t>=0)));t:for(const t of c.sort(v)){for(let e=0;et(e,(t=>n[t]))))}const Vf={mapIndex(t,n,r){const[o,i]=e.extent(t,(t=>n[t])),a=i-o;for(const e of t)r[e]=null===n[e]?NaN:(n[e]-o)/a}},Hf=Xf(((t,e)=>{for(let r=0;r{for(let r=t.length-1;r>=0;--r){const o=e[t[r]];if(n(o))return o}})),Qf={mapIndex(t,n,r){const o=e.mean(t,(t=>n[t])),i=e.deviation(t,(t=>n[t]));for(const e of t)r[e]=null===n[e]?NaN:i?(n[e]-o)/i:0}},Jf=Uf(e.max),Kf=Uf(e.mean),th=Uf(e.median),eh=Uf(e.min),nh=Uf(e.sum);function rh(t){if("function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"min":return sh;case"max":return ch}throw new Error(`unknown selector: ${t}`)}function oh(t){return uh(null,ah,t)}function ih(t){return uh(null,lh,t)}function*ah(t){yield t[0]}function*lh(t){yield t[t.length-1]}function*sh(t,n){yield e.least(t,(t=>n[t]))}function*ch(t,n){yield e.greatest(t,(t=>n[t]))}function uh(t,n,r){if(null!=t){if(null==r[t])throw new Error(`missing channel: ${t}`);t=r[t]}const o=xt(r);return pe(r,((r,i)=>{const a=I(r,o),l=I(r,t),s=[];for(const t of i){const r=[];for(const o of a?e.group(t,(t=>a[t])).values():[t])for(const t of n(o,l))r.push(t);s.push(r)}return{data:r,facets:s}}))}t.Area=is,t.Arrow=ds,t.BarX=gs,t.BarY=vs,t.Cell=ks,t.Contour=Fc,t.Density=uu,t.Dot=As,t.Frame=Ca,t.Geo=pu,t.Hexgrid=wu,t.Image=$u,t.Line=Es,t.Link=cs,t.Mark=ko,t.Raster=Ec,t.Rect=Bs,t.RuleX=ii,t.RuleY=ai,t.Text=di,t.TickX=yc,t.TickY=gc,t.Tip=Ia,t.Vector=Fi,t.area=function(t,e){return void 0===e?ls(t,{x:U,y:V}):new is(t,e)},t.areaX=as,t.areaY=ls,t.arrow=function(t,{x:e,x1:n,x2:r,y:o,y1:i,y2:a,...l}={}){return[n,r]=fs(e,n,r),[i,a]=fs(o,i,a),new ds(t,{...l,x1:n,x2:r,y1:i,y2:a})},t.auto=function(t,e){const n=Ws(t,e),{fx:r,fy:o,x:{zero:i},y:{zero:a},markOptions:l,transformOptions:s,colorMode:c}=n,u=Gs[n.markImpl],f=Gs[n.transformImpl],h=null!=r||null!=o?Ta({strokeOpacity:.1}):null,d=[i?li([0]):null,a?si([0]):null],p=u(t,f?f(s,l):l);return"stroke"===c?$o(h,d,p):$o(h,p,d)},t.autoSpec=Ws,t.axisFx=ea,t.axisFy=Ki,t.axisX=ta,t.axisY=Ji,t.barX=xs,t.barY=ws,t.bin=ml,t.binX=dl,t.binY=pl,t.bollinger=dc,t.bollingerX=function(t,{x:e=F,y:n,k:r=hc.k,color:o=hc.color,opacity:i=hc.opacity,fill:a=o,fillOpacity:l=i,stroke:s=o,strokeOpacity:c,strokeWidth:u,...f}={}){return $o(Ut(a)?null:as(t,Hs({x1:dc({k:-r,...f}),x2:dc({k:r,...f})},{x1:e,x2:e,y:n,fill:a,fillOpacity:l,...f})),Ut(s)?null:Rs(t,Hs({x:dc(f)},{x:e,y:n,stroke:s,strokeOpacity:c,strokeWidth:u,...f})))},t.bollingerY=function(t,{x:e,y:n=F,k:r=hc.k,color:o=hc.color,opacity:i=hc.opacity,fill:a=o,fillOpacity:l=i,stroke:s=o,strokeOpacity:c,strokeWidth:u,...f}={}){return $o(Ut(a)?null:ls(t,Hs({y1:dc({k:-r,...f}),y2:dc({k:r,...f})},{x:e,y1:n,y2:n,fill:a,fillOpacity:l,...f})),Ut(s)?null:Cs(t,Hs({y:dc(f)},{x:e,y:n,stroke:s,strokeOpacity:c,strokeWidth:u,...f})))},t.boxX=function(t,{x:e=F,y:n=null,fill:r="#ccc",fillOpacity:o,stroke:i="currentColor",strokeOpacity:a,strokeWidth:l=2,sort:s,...c}={}){const u=null!=n?Se:Le;return $o(si(t,u({x1:bc,x2:kc},{x:e,y:n,stroke:i,strokeOpacity:a,...c})),xs(t,u({x1:"p25",x2:"p75"},{x:e,y:n,fill:r,fillOpacity:o,...c})),vc(t,u({x:"p50"},{x:e,y:n,stroke:i,strokeOpacity:a,strokeWidth:l,sort:s,...c})),Ss(t,Hs({x:wc},{x:e,y:n,z:n,stroke:i,strokeOpacity:a,...c})))},t.boxY=function(t,{y:e=F,x:n=null,fill:r="#ccc",fillOpacity:o,stroke:i="currentColor",strokeOpacity:a,strokeWidth:l=2,sort:s,...c}={}){const u=null!=n?Ae:Le;return $o(li(t,u({y1:bc,y2:kc},{x:n,y:e,stroke:i,strokeOpacity:a,...c})),ws(t,u({y1:"p25",y2:"p75"},{x:n,y:e,fill:r,fillOpacity:o,...c})),xc(t,u({y:"p50"},{x:n,y:e,stroke:i,strokeOpacity:a,strokeWidth:l,sort:s,...c})),Ss(t,Hs({y:wc},{x:n,y:e,z:n,stroke:i,strokeOpacity:a,...c})))},t.cell=$s,t.cellX=function(t,{x:e=D,fill:n,stroke:r,...o}={}){return void 0===n&&void 0===nt(r)[0]&&(n=F),new ks(t,{...o,x:e,fill:n,stroke:r})},t.cellY=function(t,{y:e=D,fill:n,stroke:r,...o}={}){return void 0===n&&void 0===nt(r)[0]&&(n=F),new ks(t,{...o,y:e,fill:n,stroke:r})},t.centroid=function({geometry:t=F,...n}={}){return me({...n,x:null,y:null},((n,r,o,i,a,{projection:l})=>{const s=I(n,t),c=s.length,u=new Float64Array(c),f=new Float64Array(c),h=e.geoPath(l);for(let t=0;tnull==t||isNaN(t=+new Date(Date.UTC(2e3,+t)))?void 0:n.format(t)},t.formatWeekday=function(t="en-US",e="short"){const n=fn(t,e);return t=>null==t||isNaN(t=+new Date(Date.UTC(2001,0,+t)))?void 0:n.format(t)},t.frame=Ta,t.geo=mu,t.geoCentroid=function({geometry:t=F,...n}={}){let r;return{...n,x:{transform:n=>Float64Array.from(r=I(I(n,t),e.geoCentroid),(([t])=>t))},y:{transform:()=>Float64Array.from(r,(([,t])=>t))}}},t.graticule=function({strokeOpacity:t=.1,...n}={}){return mu(e.geoGraticule10(),{strokeOpacity:t,...n})},t.gridFx=la,t.gridFy=ia,t.gridX=aa,t.gridY=oa,t.group=ze,t.groupX=Ae,t.groupY=Se,t.groupZ=Le,t.hexagon=function(t,e){return Ss(t,{...e,symbol:"hexagon"})},t.hexbin=function(t={fill:"count"},{binWidth:e,...n}={}){const{z:r}=n;return e=void 0===e?20:X(e),Oe(t=Re(t,n),"fill")&&(n.channels={...n.channels,fill:{value:[]}}),void 0===n.symbol&&(n.symbol="hexagon"),void 0!==n.r||Oe(t,"r")||(n.r=e/2),me(n,((n,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}=Jn(i,a,s)),f=f?f.value:I(n,r),h=h?.value,d=d?.value,p=p?.value;const m=Pe(t,{z:f,fill:h,stroke:d,symbol:p}),y=f&&[],g=h&&[],v=d&&[],x=p&&[],w=[],b=[],k=[];let $=-1;for(const e of t)e.initialize(n);for(const n of o){const r=[];for(const e of t)e.scope("facet",n);for(const[o,i]of Be(n,m))for(const n of vu(i,c,u,e)){r.push(++$),b.push(n.x),k.push(n.y),f&&y.push(m===f?o:f[n[0]]),h&&g.push(m===h?o:h[n[0]]),d&&v.push(m===d?o:d[n[0]]),p&&x.push(m===p?o:p[n[0]]);for(const e of t)e.reduce(n)}w.push(r)}const M=i.x.scale,L=i.y.scale;return{data:n,facets:w,channels:{x:{value:b,source:a[M]?{value:st(b,a[M].invert),scale:M}:null},y:{value:k,source:a[L]?{value:st(k,a[L].invert),scale:L}:null},...f&&{z:{value:y}},...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:n})=>[t,{scale:"auto",label:n.label,radius:"r"===t?e/2:void 0,value:n.transform()}])))}}}))},t.hexgrid=function(t){return new wu(t)},t.hull=function(t,e){return su(ou,t,e)},t.identity=F,t.image=function(t,{x:e,y:n,...r}={}){return void 0===r.frameAnchor&&([e,n]=vt(e,n)),new $u(t,{...r,x:e,y:n})},t.indexOf=D,t.initializer=me,t.interpolateNearest=Wc,t.interpolateNone=Bc,t.interpolatorBarycentric=Nc,t.interpolatorRandomWalk=jc,t.legend=function(t={}){for(const[e,n]of Aa){const r=t[e];if(pt(r)){const o=jn(t);let i;if("symbol"===e){const{fill:e,stroke:n=(void 0===e&&pt(t.color)?"color":void 0)}=t;i={fill:e,stroke:n}}return n(Hr(e,r,i),Sa(o,r,t),(e=>pt(t[e])?Hr(e,t[e]):null))}}throw new Error("unknown legend type; no scale found")},t.line=Os,t.lineX=Rs,t.lineY=Cs,t.linearRegressionX=function(t,{y:e=D,x:n=F,stroke:r,fill:o=(Ut(r)?"currentColor":r),...i}={}){return new Cu(t,vl({...i,x:n,y:e,fill:o,stroke:r}))},t.linearRegressionY=function(t,{x:e=D,y:n=F,stroke:r,fill:o=(Ut(r)?"currentColor":r),...i}={}){return new Tu(t,gl({...i,x:e,y:n,fill:o,stroke:r}))},t.link=us,t.map=Hs,t.mapX=Us,t.mapY=Vs,t.marks=$o,t.normalize=Gf,t.normalizeX=function(t,e){return 1===arguments.length&&({basis:t,...e}=t),Us(Gf(t),e)},t.normalizeY=function(t,e){return 1===arguments.length&&({basis:t,...e}=t),Vs(Gf(t),e)},t.plot=Ga,t.pointer=Eo,t.pointerX=Oo,t.pointerY=Ro,t.raster=function(){const[t,e]=Oc("fill",...arguments);return new Ec(t,null==t||void 0!==e.fill||void 0!==e.fillOpacity?e:{...e,fill:F})},t.rect=Ns,t.rectX=Is,t.rectY=Ps,t.reverse=function({sort:t,...e}={}){return{...ve(e,we),sort:yt(t)?t:null}},t.ruleX=li,t.ruleY=si,t.scale=function(t={}){let e;for(const n in t)if(ae.has(n)&&pt(t[n])){if(void 0!==e)throw new Error("ambiguous scale definition; multiple scales found");e=io(Hr(n,t[n]))}if(void 0===e)throw new Error("invalid scale definition; no scale found");return e},t.select=function(t,e={}){if("string"==typeof t)switch(t.toLowerCase()){case"first":return oh(e);case"last":return ih(e)}if("function"==typeof t)return uh(null,t,e);let n,r;for(n in t){if(void 0!==r)throw new Error("ambiguous selector; multiple inputs");r=rh(t[n])}if(void 0===r)throw new Error(`invalid selector: ${t}`);return uh(n,r,e)},t.selectFirst=oh,t.selectLast=ih,t.selectMaxX=function(t){return uh("x",ch,t)},t.selectMaxY=function(t){return uh("y",ch,t)},t.selectMinX=function(t){return uh("x",sh,t)},t.selectMinY=function(t){return uh("y",sh,t)},t.shuffle=function({seed:t,sort:n,...r}={}){return{...ve(r,Me(null==t?Math.random:e.randomLcg(t))),sort:yt(n)?n:null}},t.sort=be,t.sphere=function({strokeWidth:t=1.5,...e}={}){return mu({type:"Sphere"},{strokeWidth:t,...e})},t.spike=function(t,e={}){const{shape:n=qi,stroke:r=Ii.stroke,strokeWidth:o=1,fill:i=r,fillOpacity:a=.3,anchor:l="start",...s}=e;return Yi(t,{...s,shape:n,stroke:r,strokeWidth:o,fill:i,fillOpacity:a,anchor:l})},t.stackX=Dl,t.stackX1=function(t={},e={}){1===arguments.length&&([t,e]=Gl(t));const{y1:n,y:r=n,x:o}=e,[i,a,l]=Ul(r,o,"y","x",t,e);return{...i,y1:n,y:a,x:l}},t.stackX2=function(t={},e={}){1===arguments.length&&([t,e]=Gl(t));const{y1:n,y:r=n,x:o}=e,[i,a,,l]=Ul(r,o,"y","x",t,e);return{...i,y1:n,y:a,x:l}},t.stackY=Fl,t.stackY1=function(t={},e={}){1===arguments.length&&([t,e]=Gl(t));const{x1:n,x:r=n,y:o}=e,[i,a,l]=Ul(r,o,"x","y",t,e);return{...i,x1:n,x:a,y:l}},t.stackY2=function(t={},e={}){1===arguments.length&&([t,e]=Gl(t));const{x1:n,x:r=n,y:o}=e,[i,a,,l]=Ul(r,o,"x","y",t,e);return{...i,x1:n,x:a,y:l}},t.text=yi,t.textX=gi,t.textY=vi,t.tickX=vc,t.tickY=xc,t.tip=Pa,t.transform=pe,t.tree=sf,t.treeLink=Pu,t.treeNode=Iu,t.valueof=I,t.vector=Yi,t.vectorX=_i,t.vectorY=Gi,t.version="0.6.11",t.voronoi=function(t,e){return su(iu,t,e)},t.voronoiMesh=function(t,e){return su(au,t,e)},t.window=Ks,t.windowX=function(t={},e){return 1===arguments.length&&(e=t),Us(Ks(t),e)},t.windowY=function(t={},e){return 1===arguments.length&&(e=t),Vs(Ks(t),e)}}));