blockcharts 0.0.0-stage → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +289 -2
  3. package/package.json +87 -4
  4. package/release/bc.d.ts +764 -0
  5. package/release/blocks/guide.axis.js +3 -0
  6. package/release/blocks/guide.grid.js +3 -0
  7. package/release/blocks/guide.kpi.js +3 -0
  8. package/release/blocks/guide.legend.js +3 -0
  9. package/release/blocks/interaction.animate.js +3 -0
  10. package/release/blocks/interaction.brush.js +3 -0
  11. package/release/blocks/interaction.crosshair.js +3 -0
  12. package/release/blocks/interaction.legend-filter.js +3 -0
  13. package/release/blocks/interaction.tooltip.js +3 -0
  14. package/release/blocks/interaction.zoom-controls.js +3 -0
  15. package/release/blocks/interaction.zoom.js +3 -0
  16. package/release/blocks/lib.columns.js +3 -0
  17. package/release/blocks/lib.curve.js +3 -0
  18. package/release/blocks/lib.pointer.js +3 -0
  19. package/release/blocks/lib.stats.js +3 -0
  20. package/release/blocks/lib.ticks.js +3 -0
  21. package/release/blocks/lib.view.js +3 -0
  22. package/release/blocks/mark.arc.js +3 -0
  23. package/release/blocks/mark.area.js +3 -0
  24. package/release/blocks/mark.boxplot.js +3 -0
  25. package/release/blocks/mark.candlestick.js +3 -0
  26. package/release/blocks/mark.line.js +3 -0
  27. package/release/blocks/mark.point.js +3 -0
  28. package/release/blocks/mark.polygon.js +3 -0
  29. package/release/blocks/mark.rect.js +3 -0
  30. package/release/blocks/mark.rule.js +3 -0
  31. package/release/blocks/mark.sankey.js +3 -0
  32. package/release/blocks/mark.text.js +3 -0
  33. package/release/blocks/mark.violin.js +3 -0
  34. package/release/blocks/renderer.canvas.js +3 -0
  35. package/release/blocks/renderer.svg.js +3 -0
  36. package/release/blocks/scale.band.js +3 -0
  37. package/release/blocks/scale.color.js +3 -0
  38. package/release/blocks/scale.linear.js +3 -0
  39. package/release/blocks/scale.log.js +3 -0
  40. package/release/blocks/scale.sequential.js +3 -0
  41. package/release/blocks/scale.size.js +3 -0
  42. package/release/blocks/scale.time.js +3 -0
  43. package/release/blocks/transform.aggregate.js +3 -0
  44. package/release/blocks/transform.bin.js +3 -0
  45. package/release/blocks/transform.calculate.js +3 -0
  46. package/release/blocks/transform.calendar.js +3 -0
  47. package/release/blocks/transform.contour.js +3 -0
  48. package/release/blocks/transform.decimate.js +3 -0
  49. package/release/blocks/transform.density.js +3 -0
  50. package/release/blocks/transform.filter.js +3 -0
  51. package/release/blocks/transform.fold.js +3 -0
  52. package/release/blocks/transform.funnel.js +3 -0
  53. package/release/blocks/transform.hexbin.js +3 -0
  54. package/release/blocks/transform.highlight.js +3 -0
  55. package/release/blocks/transform.marimekko.js +3 -0
  56. package/release/blocks/transform.quartiles.js +3 -0
  57. package/release/blocks/transform.sankey.js +3 -0
  58. package/release/blocks/transform.sort.js +3 -0
  59. package/release/blocks/transform.stack.js +3 -0
  60. package/release/blocks/transform.treemap.js +3 -0
  61. package/release/blocks/transform.waterfall.js +3 -0
  62. package/release/blocks/transform.window.js +3 -0
  63. package/release/core.js +5 -0
  64. package/release/kits/basic.d.mts +3 -0
  65. package/release/kits/basic.d.ts +3 -0
  66. package/release/kits/basic.js +64 -0
  67. package/release/kits/basic.mjs +64 -0
  68. package/release/kits/composition.d.mts +3 -0
  69. package/release/kits/composition.d.ts +3 -0
  70. package/release/kits/composition.js +106 -0
  71. package/release/kits/composition.mjs +106 -0
  72. package/release/kits/dashboard.d.mts +3 -0
  73. package/release/kits/dashboard.d.ts +3 -0
  74. package/release/kits/dashboard.js +100 -0
  75. package/release/kits/dashboard.mjs +100 -0
  76. package/release/kits/full.d.mts +3 -0
  77. package/release/kits/full.d.ts +3 -0
  78. package/release/kits/full.js +181 -0
  79. package/release/kits/full.mjs +181 -0
  80. package/release/kits/timeseries.d.mts +3 -0
  81. package/release/kits/timeseries.d.ts +3 -0
  82. package/release/kits/timeseries.js +94 -0
  83. package/release/kits/timeseries.mjs +94 -0
  84. package/release/loader.js +3 -0
  85. package/release/manifest.json +1038 -0
@@ -0,0 +1,181 @@
1
+ /*! blockcharts 0.0.2 kit "full": lib.columns, lib.curve, lib.pointer, lib.stats, lib.ticks, lib.view, scale.band, scale.color, scale.linear, scale.log, scale.sequential, scale.size, scale.time, transform.aggregate, transform.bin, transform.calculate, transform.calendar, transform.contour, transform.decimate, transform.density, transform.filter, transform.fold, transform.funnel, transform.hexbin, transform.highlight, transform.marimekko, transform.quartiles, transform.sankey, transform.sort, transform.stack, transform.treemap, transform.waterfall, transform.window, mark.arc, mark.area, mark.boxplot, mark.candlestick, mark.line, mark.point, mark.polygon, mark.rect, mark.rule, mark.sankey, mark.text, mark.violin, guide.axis, guide.grid, guide.kpi, guide.legend, interaction.animate, interaction.brush, interaction.crosshair, interaction.legend-filter, interaction.tooltip, interaction.zoom, interaction.zoom-controls, renderer.canvas, renderer.svg | MIT License */
2
+ "use strict";(function(){const ve="0.0.2",Ee=globalThis,ue=Ee.BC;if(ue&&typeof ue.define=="function"&&typeof ue.version=="string"){ue.version!==ve&&console.warn(`blockcharts core ${ve} ignored: ${ue.version} is already loaded`);return}const St=["lib","scale","transform","mark","guide","interaction","renderer"],pe=["top","right","bottom","left"],xt={top:16,right:16,bottom:16,left:16},He=24,F=new Map,ce=new Map,se=new Map,he=new Map,Ke=new Map,je=64*1024*1024;function Ct(t){if(!t||St.indexOf(t.role)<0||typeof t.type!="string"||!t.type)throw new Error("BC.define: a block needs a valid role and type");const e=`${t.role}.${t.type}`;{const r=["position","color","size"],c=["number","date","category"];if(t.role==="scale"&&!(r.indexOf(t.output)>=0&&c.indexOf(t.input)>=0))throw new Error(`BC.define: ${e} must declare its output ("position", "color" or "size") and its input ("number", "date" or "category")`);if(t.role==="mark")for(const a of Object.keys(t.channels||{})){const y=t.channels[a].accepts;if(y&&!(r.indexOf(y.output)>=0&&(y.input===void 0||Array.isArray(y.input)&&y.input.every(m=>c.indexOf(m)>=0))))throw new Error(`BC.define: channel "${a}" of ${e} accepts { output: "position", "color" or "size", input: a list of "number", "date", "category" }`)}}const o=F.get(e);if(o){o.version!==t.version&&console.warn(`BC.define: ${e} v${t.version} ignored, v${o.version} is already registered`);return}F.set(e,t)}function Ze(t){if(t instanceof Float64Array)return t;for(let o=0;o<t.length;o++){const r=t[o];if(typeof r!="number"&&r!=null)return t}const e=new Float64Array(t.length);for(let o=0;o<t.length;o++){const r=t[o];e[o]=typeof r=="number"?r:NaN}return e}function Se(t){const e={};let o=0;const r=c=>{if(c==="__proto__")throw new Error('BC.data: a column cannot be named "__proto__"; rename it');return c};if(Array.isArray(t)){const c=new Set;t.forEach((a,y)=>{if(!a||typeof a!="object"||Array.isArray(a))throw new Error(`BC.data: row ${y} is not an object`);for(const m of Object.keys(a))c.add(r(m))});for(const a of c)e[a]=Ze(t.map(y=>y[a]));o=t.length}else if(t&&typeof t=="object"&&t.columns&&typeof t.columns=="object"){const c=t.columns,a=Object.keys(c).map(r);for(const y of a)if(!Array.isArray(c[y])&&!(c[y]instanceof Float64Array))throw new Error(`BC.data: column "${y}" is not an array`);o=a.length?c[a[0]].length:0;for(const y of a){if(c[y].length!==o)throw new Error(`BC.data: column "${y}" has ${c[y].length} values, expected ${o}`);e[y]=Ze(c[y])}}else throw new Error("BC.data: a dataset is an array of rows or { columns }");return{length:o,columns:e}}const xe=t=>!!t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.encoding=="string",Ge=function(e){const o=e.replace(/\s+/g,"");if(o.length%4===1||!/^[A-Za-z0-9+/]*={0,2}$/.test(o))throw new Error("the data is not valid base64");if(typeof atob!="function")throw new Error("this environment has no atob(), cannot decode base64");const r=atob(o),c=new Uint8Array(r.length);for(let a=0;a<r.length;a++)c[a]=r.charCodeAt(a);return c},Xe=async function(e,o){const r=globalThis.DecompressionStream;if(typeof r!="function"||typeof Blob!="function")throw new Error('this browser cannot decompress gzip data (no DecompressionStream); store the dataset as plain rows or "base64"');const c=new Blob([e]).stream().pipeThrough(new r("gzip")).getReader(),a=[];let y=0;for(;;){let w;try{w=await c.read()}catch{throw new Error("the data is not valid gzip")}const{done:N,value:z}=w;if(N)break;if(y+=z.length,y>o)throw await c.cancel(),new Error(`the decoded data is larger than ${je/1024/1024} MB, refusing to unpack it`);a.push(z)}const m=new Uint8Array(y);let $=0;for(const w of a)m.set(w,$),$+=w.length;return m},Ye={float32:{size:4,ctor:Float32Array,get:"getFloat32"},float64:{size:8,ctor:Float64Array,get:"getFloat64"},int8:{size:1,ctor:Int8Array,get:"getInt8"},int16:{size:2,ctor:Int16Array,get:"getInt16"},int32:{size:4,ctor:Int32Array,get:"getInt32"},uint8:{size:1,ctor:Uint8Array,get:"getUint8"},uint16:{size:2,ctor:Uint16Array,get:"getUint16"},uint32:{size:4,ctor:Uint32Array,get:"getUint32"}},Dt=new Uint8Array(new Uint16Array([1]).buffer)[0]===1,Qe=t=>!!t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof Float64Array)&&typeof t.dtype=="string",et=t=>{const e=t&&typeof t=="object"&&!Array.isArray(t)?t.columns:void 0;return!!e&&typeof e=="object"&&Object.keys(e).some(o=>Qe(e[o]))},Mt=async function(e,o,r){const c=Ye[o.dtype];if(!c)throw new Error(`column "${e}": unknown dtype "${o.dtype}" (use ${Object.keys(Ye).join(", ")})`);if(o.encoding!=="base64"&&o.encoding!=="gzip+base64")throw new Error(`column "${e}": unknown encoding "${o.encoding}" (use "base64" or "gzip+base64")`);if(typeof o.data!="string")throw new Error(`column "${e}": a binary column needs a "data" string`);let a;try{a=Ge(o.data),o.encoding==="gzip+base64"&&(a=await Xe(a,r.left))}catch($){throw new Error(`column "${e}": ${$ instanceof Error?$.message:String($)}`)}if(a.length%c.size!==0)throw new Error(`column "${e}": ${a.length} bytes is not a whole number of ${o.dtype} values`);const y=a.length/c.size;if(r.left-=y*8,r.left<0)throw new Error(`the decoded data is larger than ${je/1024/1024} MB, refusing to unpack it`);const m=new Float64Array(y);if(Dt){const $=a.byteOffset%c.size===0?a.buffer:a.slice().buffer,w=a.byteOffset%c.size===0?a.byteOffset:0;m.set(new c.ctor($,w,y))}else{const $=new DataView(a.buffer,a.byteOffset,a.length);for(let w=0;w<y;w++)m[w]=$[c.get](w*c.size,!0)}return m},tt=async function(e,o){if(!et(e))return e;const r=e.columns,c=Object.create(null);for(const a of Object.keys(r))c[a]=Qe(r[a])?await Mt(a,r[a],o):r[a];return{columns:c}},zt=async function(e){const o={left:je};if(!xe(e))return Se(await tt(e,o));if(typeof e.data!="string")throw new Error('an encoded dataset needs a "data" string');if(e.encoding!=="base64"&&e.encoding!=="gzip+base64")throw new Error(`unknown encoding "${e.encoding}" (use "base64" or "gzip+base64")`);let r=Ge(e.data);e.encoding==="gzip+base64"&&(r=await Xe(r,o.left)),o.left-=r.length;let c;try{c=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(r))}catch(a){throw new Error("the decoded data is not UTF-8 JSON: "+(a instanceof Error?a.message:String(a)))}if(xe(c))throw new Error("an encoded dataset cannot contain another encoded dataset");return Se(await tt(c,o))};function nt(t,e){if(xe(e)||et(e)){he.delete(t);const r=zt(e).then(c=>{se.get(t)===r&&ce.set(t,c)},c=>{if(se.get(t)!==r)return;const a=c instanceof Error?c.message:String(c);he.set(t,a),console.error(`[blockcharts] dataset "${t}": ${a}`)}).then(()=>{se.get(t)===r&&se.delete(t)});se.set(t,r);return}const o=Se(e);se.delete(t),he.delete(t),ce.set(t,o)}function Nt(){return Promise.all(Array.from(se.values())).then(()=>{})}function ie(t,e,o){const r=t[e];if(r===void 0)return o&&o.default!==void 0?{value:o.default}:null;const c=o&&o.unscaled?void 0:o&&o.sharesScale||e;if(typeof r=="string")return{field:r,scale:c};if(r&&typeof r=="object"){const a=r;if(typeof a.field=="string")return{field:a.field,scale:typeof a.scale=="string"?a.scale:c};if(a.value!==void 0){const y=typeof a.scale=="string"?a.scale:c==="x"||c==="y"?c:void 0;return y!==void 0?{value:a.value,scale:y}:{value:a.value}}}}function be(t,e){return e.range!==void 0?e.range:t==="x"?"width":t==="y"?"height":void 0}function Ce(t,e,o){const r=be(t,e);return r==="width"?[o.x,o.x+o.w]:r==="height"?[o.y+o.h,o.y]:Array.isArray(r)?r:[]}function rt(t){const e=t&&typeof t=="object"?t.data:void 0;return typeof e!="string"?"data must be the name of a dataset":se.has(e)?`dataset "${e}" is still being decoded (await BC.ready())`:he.has(e)?`dataset "${e}" could not be loaded: ${he.get(e)}`:ce.has(e)?null:`dataset "${e}" is not in the data lake`}const Ft=function(e){const o=[],r=(c,a)=>{const y=a&&a.type;if(typeof y=="string"){const m=`${c}.${y}`;o.indexOf(m)<0&&o.push(m)}};if(!e)return o;if(Array.isArray(e.transforms)&&e.transforms.forEach(c=>r("transform",c)),e.scales)for(const c of Object.keys(e.scales))r("scale",e.scales[c]);return Array.isArray(e.marks)&&e.marks.forEach(c=>r("mark",c)),Array.isArray(e.guides)&&e.guides.forEach(c=>r("guide",c)),Array.isArray(e.interaction)&&e.interaction.forEach(c=>r("interaction",c)),r("renderer",{type:e.renderer||"svg"}),o},ot=["id","data","transforms","size","padding","title","alt","scales","guides","marks","interaction","view","responsive","renderer","locale"],st=function(e){const o=[],r=(i,f)=>o.push({level:"error",path:i,message:f}),c=(i,f)=>o.push({level:"warn",path:i,message:f});if(!e||typeof e!="object")return r("","the spec must be an object"),o;const a=(i,f)=>i.output===f.output&&(!f.input||f.input.indexOf(i.input)>=0),y=(i,f)=>{const g=(p,I)=>{let U=Array.from({length:I.length+1},(S,R)=>R);for(let S=1;S<=p.length;S++){const R=[S];for(let x=1;x<=I.length;x++)R[x]=Math.min(U[x]+1,R[x-1]+1,U[x-1]+(p[S-1]===I[x-1]?0:1));U=R}return U[I.length]};let k,j=3;for(const p of f){const I=p.toLowerCase()===i.toLowerCase()?0:g(i,p);I<j&&([k,j]=[p,I])}return k},m=(i,f)=>{const g=y(i,f);return g?`; did you mean "${g}"?`:""};for(const i of Object.keys(e))ot.indexOf(i)<0&&c(i,`unknown key "${i}"${m(i,ot)}`);for(const i of["transforms","guides","interaction"])e[i]!==void 0&&!Array.isArray(e[i])&&r(i,`${i} must be a list: [{ "type": ... }]`);if(e.scales!==void 0&&(!e.scales||typeof e.scales!="object"||Array.isArray(e.scales))&&r("scales",'scales must map names to scales: { "x": { "type": "band" } }'),e.padding!==void 0)if(typeof e.padding=="number")(!isFinite(e.padding)||e.padding<0)&&r("padding","padding must be a number of px, 0 or more, or one per side");else if(!e.padding||typeof e.padding!="object"||Array.isArray(e.padding))r("padding",'padding must be { "top": 8, "right": 8, "bottom": 30, "left": 40 } in px, or one number for every side');else for(const i of Object.keys(e.padding)){const f=e.padding[i];pe.indexOf(i)<0?c(`padding.${i}`,`unknown side "${i}"${m(i,pe)}`):(typeof f!="number"||!isFinite(f)||f<0)&&r(`padding.${i}`,`padding.${i} must be a number of px, 0 or more`)}if(e.title!==void 0&&typeof e.title!="string"&&r("title","title must be text"),e.alt!==void 0&&typeof e.alt!="string"&&r("alt","alt must be text: what the chart shows, in a sentence"),e.id!==void 0&&typeof e.id!="string"&&r("id","id must be text"),e.responsive!==void 0&&typeof e.responsive!="boolean"&&r("responsive","responsive must be true or false"),e.renderer!==void 0&&typeof e.renderer!="string"&&r("renderer",'renderer must be the name of one: "svg", "canvas"'),e.locale!==void 0){let i=!1;try{i=typeof e.locale=="string"&&Intl.getCanonicalLocales(e.locale).length===1}catch{i=!1}i||r("locale",`locale ${JSON.stringify(e.locale)} is not a language tag like "en-US", "de" or "ja"`)}const $=(i,f,g)=>{try{Pe(g)}catch(k){r(i,`${f}: ${k.message}`)}},w=i=>typeof i=="string"&&/^\s*(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch)\([-+\w.%,\s/]*\)|[a-z]+|var\(\s*--[\w-]+\s*(?:,\s*(?:#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})|(?:rgba?|hsla?)\([-+\w.%,\s/]*\)|[a-z]+)\s*)?\))\s*$/i.test(i),N=i=>`${{position:"places",color:"colors",size:"sizes"}[i.output]} ${i.input?i.input.map(f=>({number:"numbers",date:"dates",category:"categories"})[f]).join(" or "):"values"}`,z=typeof e.data=="string"&&!se.has(e.data)?ce.get(e.data):void 0,M=rt(e);M&&r("data",M);const _=[z?{...z.columns}:void 0];if(Array.isArray(e.transforms))for(const i of e.transforms){let f=_[_.length-1];const g=i&&typeof i.type=="string"?F.get(`transform.${i.type}`):void 0;if(f)if(g&&g.role==="transform"&&g.outputs)try{const k=g.outputs(i);f=g.replacesColumns?{}:{...f};for(const j of k)f[j]=!0}catch{f=void 0}else f=void 0;_.push(f)}const ee=_[_.length-1],G=(i,f,g)=>{i&&!Object.prototype.hasOwnProperty.call(i,g)&&r(f,`unknown field "${g}" in dataset "${e.data}"`)},te=(i,f)=>G(ee,i,f),L=Object.assign(Object.create(null),e.scales);e.size!==void 0&&!(Array.isArray(e.size)&&e.size.length===2&&e.size[0]>0&&e.size[1]>0)&&r("size","size must be [width, height] with positive numbers");const H=new Map,O=(i,f,g)=>{const k=f&&f.type;if(typeof k!="string"||!k){r(`${g}.type`,`${i} needs a "type"`);return}const j=`${i}.${k}`;H.has(j)||H.set(j,g);const p=F.get(j);return p||r(`${g}.type`,`block "${j}" is not loaded`),p},T=(i,f,g,k,j=te)=>{const p=`${g.role}.${g.type}`,I=g.params||{},U=g.role==="mark"?g.channels:{};for(const S of Object.keys(f)){if(S==="type"||k.indexOf(S)>=0||Object.prototype.hasOwnProperty.call(U,S))continue;const R=Object.prototype.hasOwnProperty.call(I,S)?I[S]:void 0;if(!R){c(`${i}.${S}`,`unknown parameter "${S}" for ${p}${m(S,Object.keys(I).concat(Object.keys(U)))}`);continue}const x=f[S];if(x===void 0)continue;const B=X=>r(`${i}.${S}`,`${S} of ${p} must be ${X}`);switch(R.kind){case"string":typeof x!="string"&&B("a string");break;case"number":typeof x!="number"&&B("a number");break;case"boolean":typeof x!="boolean"&&B("a boolean");break;case"list":Array.isArray(x)||B("a list");break;case"color":w(x)||B('a color: "#4e79a7", "rgb(78 121 167)", "steelblue" or "var(--bc-c0)"');break;case"enum":(typeof x!="string"||!R.values||R.values.indexOf(x)<0)&&B(`one of: ${(R.values||[]).join(", ")}`);break;case"field":typeof x!="string"?B("a field name"):j(`${i}.${S}`,x);break;case"scale":(typeof x!="string"||!L[x])&&B("the name of a declared scale");break;case"format":$(`${i}.${S}`,`${S} of ${p}`,x);break;case"formats":if(!x||typeof x!="object"||Array.isArray(x))B('an object of field names and formats: { "revenue": "currency" }');else for(const X of Object.keys(x))j(`${i}.${S}.${X}`,X),$(`${i}.${S}.${X}`,`the format of "${X}"`,x[X]);break;case"fields":!Array.isArray(x)||x.some(X=>typeof X!="string")?B("a list of field names"):x.forEach((X,_e)=>j(`${i}.${S}[${_e}]`,X));break}}for(const S of Object.keys(I))I[S].required&&I[S].default===void 0&&f[S]===void 0&&r(`${i}.${S}`,`${p} requires "${S}"`)},Z=Array.isArray(e.guides)&&e.guides.length>0;Array.isArray(e.marks)?!e.marks.length&&!Z&&r("marks","at least one mark is required (or a guide, such as a KPI)"):r("marks","marks must be a list (an empty one is fine when the chart has a guide, such as a KPI)");const E=(i,f)=>{const g=f.map(k=>i==="date"?we(k):typeof k=="number"?k:NaN);return f.length===2&&g.every(k=>isFinite(k))&&g[0]!==g[1]},A=i=>i==="date"?'dates ("2024-03-01" or ms)':"numbers";if(e.view!==void 0)if(!e.view||typeof e.view!="object")r("view","view must map scale names to domains");else for(const i of Object.keys(e.view)){const f=e.view[i],g=L[i]&&F.get(`scale.${L[i].type}`);L[i]?Array.isArray(f)?g&&g.input==="category"?f.length||r(`view.${i}`,"a view of categories lists at least one of them"):g&&!E(g.input,f)&&r(`view.${i}`,`a view of "${i}" is [from, to]: two different ${A(g.input)}, not ${JSON.stringify(f)}`):r(`view.${i}`,"a view is a list (the visible domain)"):r(`view.${i}`,`scale "${i}" is not declared in scales`)}Array.isArray(e.transforms)&&e.transforms.forEach((i,f)=>{const g=O("transform",i,`transforms[${f}]`);g&&T(`transforms[${f}]`,i,g,[],(k,j)=>G(_[f],k,j))});for(const i of Object.keys(L)){const f=L[i],g=`scales.${i}`,k=O("scale",f,g);if(!k)continue;T(g,f,k,["field","domain","range"]),typeof f.field=="string"&&te(`${g}.field`,f.field);const j=k;f.domain!==void 0&&!Array.isArray(f.domain)?r(`${g}.domain`,"domain must be a list: [min, max], or the categories in order"):Array.isArray(f.domain)&&j.input!=="category"&&!E(j.input,f.domain)&&r(`${g}.domain`,`the domain of scale "${i}" is [from, to]: two different ${A(j.input)}, not ${JSON.stringify(f.domain)}`+(j.output==="color"&&f.domain.length===3?'; a diverging scale is three colors in "range" and a domain even around the middle, such as [-10, 10]':"")),f.range!==void 0&&f.range!=="width"&&f.range!=="height"&&!Array.isArray(f.range)?r(`${g}.range`,'range must be "width", "height" or a list'):Array.isArray(f.range)&&k.output==="color"&&f.range.forEach((p,I)=>{w(p)||r(`${g}.range[${I}]`,`${JSON.stringify(p)} is not a color: "#4e79a7", "rgb(78 121 167)", "steelblue" or "var(--bc-c0)"`)})}const K=new Set;Array.isArray(e.marks)&&e.marks.forEach((i,f)=>{const g=`marks[${f}]`,k=O("mark",i,g);if(!k||k.role!=="mark")return;const j=`mark.${k.type}`;T(g,i,k,[]);for(const p of Object.keys(k.channels)){const I=k.channels[p],U=ie(i,p,I);if(U===null){I.required&&r(`${g}.${p}`,`${j} requires channel "${p}"`);continue}if(U===void 0){r(`${g}.${p}`,`channel "${p}" must be a field name, { field, scale } or { value }`);continue}if(U.field!==void 0&&te(`${g}.${p}`,U.field),I.unscaled)U.scale!==void 0&&r(`${g}.${p}`,`channel "${p}" of ${j} is read as it is and does not use a scale`);else if(U.scale!==void 0){const S=L[U.scale],R=S&&F.get(`scale.${S.type}`);if(!S)r(`${g}.${p}`,`scale "${U.scale}" is not declared in scales`);else if(R&&I.accepts&&!a(R,I.accepts)){const x=[];F.forEach((B,X)=>{B.role==="scale"&&a(B,I.accepts)&&x.push(X.slice(6))}),r(`${g}.${p}`,`channel "${p}" of ${j} needs a scale that ${N(I.accepts)}${x.length?` (${x.sort().join(", ")})`:""}; "${S.type}" ${N({output:R.output,input:[R.input]})}`)}else R&&R.output==="position"&&be(U.scale,S)===void 0&&(K.has(U.scale)||(K.add(U.scale),r(`scales.${U.scale}`,`scale "${U.scale}" places values but has no range, so nothing it places is drawn: give it "range": "width" or "height" (only x and y have one by default)`)))}}}),Array.isArray(e.guides)&&e.guides.forEach((i,f)=>{const g=`guides[${f}]`,k=O("guide",i,g);if(!k)return;T(g,i,k,["scale","position"]),i.scale!==void 0&&(typeof i.scale!="string"||!L[i.scale])&&r(`${g}.scale`,`scale "${String(i.scale)}" is not declared in scales`);const j=k.params&&k.params.position,p=j&&j.kind==="enum"&&j.values?j.values:pe;i.position!==void 0&&p.indexOf(i.position)<0&&r(`${g}.position`,`position must be one of: ${p.join(", ")}`)}),Array.isArray(e.interaction)&&e.interaction.forEach((i,f)=>{const g=O("interaction",i,`interaction[${f}]`);g&&T(`interaction[${f}]`,i,g,[])}),O("renderer",{type:e.renderer||"svg"},"renderer");const Q=new Set,W=(i,f)=>{if(Q.has(i))return;Q.add(i);const g=F.get(i);if(!(!g||!g.requires))for(const k of g.requires)F.has(k)?W(k,f):r(f,`${i} requires ${k}, which is not loaded`)};return H.forEach((i,f)=>W(f,i)),o},ge=["#3a6fe4","#16a39d","#f29b38","#e0527a","#8a6be8","#5d718f","#2e9e62","#ea7b4f","#8c6d46","#a3ad3a","#1f7a9c","#b0479a"];function ye(t){const e=(t%ge.length+ge.length)%ge.length;return`var(--bc-c${e}, ${ge[e]})`}const at=t=>t>=4352&&t<=4607||t>=11904&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65072&&t<=65135||t>=65280&&t<=65376||t>=55360&&t<=55423;function Tt(t){for(let e=0;e<t.length;e++)if(at(t.charCodeAt(e)))return!0;return!1}function it(t,e=11){let o=0;for(let r=0;r<t.length;r++)o+=at(t.charCodeAt(r))?1:.6;return{w:o*e,h:e*1.2}}function De(t,e=11,o){let r=0;for(const a of t)a===" "||"iIl|!.,:;'".indexOf(a)>=0?r+=.28:"fjrt()[]-".indexOf(a)>=0?r+=.4:a==="M"||a==="W"||a==="m"||a==="w"||a==="%"||a==="@"?r+=.95:a>="0"&&a<="9"?r+=.6:a>="a"&&a<="z"?r+=.54:a>="A"&&a<="Z"?r+=.7:a.charCodeAt(0)<11904?r+=.62:r+=1;const c=o==="bold"||typeof o=="number"&&o>=700?1.08:typeof o=="number"&&o>=600?1.04:1;return r*e*c}const Me=new Map,ze=new Map,ct=new Set,Bt=4e3;let fe;function ft(){const t=typeof document=="object"&&document?document:null,e=t&&t.fonts;return e&&typeof e.check=="function"&&typeof e.load=="function"?e:null}function It(){if(fe!==void 0)return fe;fe=null;try{if(ft()){const t=document.createElement("canvas").getContext("2d");t&&typeof t.measureText=="function"&&(fe=t)}}catch{fe=null}return fe}function Pt(t,e){const o=It(),r=ft();let c="";try{c=o&&typeof getComputedStyle=="function"?String(getComputedStyle(t).fontFamily||""):""}catch{c=""}if(!o||!r||!c)return null;const a=(m,$)=>{o.font=m;const w=o.measureText($),N=w.width;if(typeof N!="number"||!isFinite(N)||N<0)return null;const z=typeof w.actualBoundingBoxLeft=="number"&&isFinite(w.actualBoundingBoxLeft)?w.actualBoundingBoxLeft:0,M=typeof w.actualBoundingBoxRight=="number"&&isFinite(w.actualBoundingBoxRight)?w.actualBoundingBoxRight-N:0;return[N,Math.max(0,z,M)]},y=(m,$,w)=>{if(typeof m!="string"||typeof $!="number"||!($>0)||!isFinite($))return null;const N=w==="bold"?700:typeof w=="number"&&w>=1&&w<=1e3?Math.round(w):400,z=`${N} ${c}`,M=`${N} ${$}px ${c}`;let _=Me.get(z);if(!_&&(_={widths:new Map,figures:new Map},Me.set(z,_),!ct.has(z))){let O=!0;try{O=r.check(M)}catch{O=!0}if(!O){ct.add(z);const T=()=>{ze.delete(z),Me.delete(z)};ze.set(z,Promise.resolve(r.load(M)).then(T,T))}}const ee=ze.get(z);ee&&e(ee);const G=$+" "+m,te=_.widths.get(G);if(te!==void 0)return te;let L=_.figures.get($);if(L===void 0){L="0";let O=-1;for(const T of"0123456789"){const Z=a(M,T);Z&&Z[0]>O&&([L,O]=[T,Z[0]])}_.figures.set($,L)}const H=a(M,/[0-9]/.test(m)?m.replace(/[0-9]/g,L):m);return H?(_.widths.size>=Bt&&_.widths.delete(_.widths.keys().next().value),_.widths.set(G,H),H):null};return{width(m,$=11,w){const N=y(m,$,w);return N?N[0]:De(m,$,w)},inked(m,$=11){const w=y(m,$,void 0);return w?w[0]+2*w[1]:De(m,$)}}}function _t(t,e){const o=[],r=typeof t.alt=="string"&&t.alt.trim()?t.alt:t.title;for(const c of[typeof r=="string"?r.trim():"",...e])c&&o.indexOf(c)<0&&o.push(c);return o.join(". ")}function Ne(t,e){return{x:e.left,y:e.top,w:Math.max(1,t.w-e.left-e.right),h:Math.max(1,t.h-e.top-e.bottom)}}function Ut(t,e){return t.length===e.length&&t.every((o,r)=>o.length===e[r].length&&o.every((c,a)=>c===e[r][a]||c instanceof Date&&e[r][a]instanceof Date&&c.getTime()===e[r][a].getTime()))}function Fe(t,e){for(let o=0;o<e.length;o++)t.push(e[o])}function qt(t){typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>t()):setTimeout(t,0)}function Lt(t,e,o,r,c){const a=typeof e.locale=="string"&&e.locale?e.locale:void 0,y=()=>{Ie=a};y();const m=[],$=(n,s)=>{const l=s instanceof Error?s.message:String(s);m.some(d=>d.path===n&&d.message===l)||m.push({level:"error",path:n,message:l})},w=(n,s)=>{m.some(l=>l.path===n&&l.message===s)||m.push({level:"warn",path:n,message:s})};let N=!1;o.push(()=>{N=!0});let z=0,M=!1;const _=()=>{z||(M=typeof getComputedStyle=="function"&&getComputedStyle(t).position==="static",M&&(t.style.position="relative")),z++;let n=!1;return()=>{n||(n=!0,z--,z<=0&&(z=0,M&&(t.style.position="")))}},ee=[],G=e.transforms||[],te=n=>{const s=F.get(`transform.${n.type}`).viewDependent;return typeof s=="function"?s(n):!!s},L=G.findIndex(te),H=L<0?G.length:L,O=(n,s)=>{s&&(s.level==="error"?$:w)(n,s.message)},T=(n,s)=>typeof s=="string"&&Object.prototype.hasOwnProperty.call(n.columns,s)?n.columns[s]:void 0,Z=new Set,E=(n,s)=>{if(Z.has(n))return;Z.add(n);const l=G[n],d=F.get(`transform.${l.type}`).params||{};for(const u of Object.keys(d)){const h=d[u].reads,b=l[u];h&&typeof b=="string"&&O(`transforms[${n}].${u}`,Be(`transform.${l.type}`,b,T(s,b),h))}};let A=ce.get(e.data);G.slice(0,H).forEach((n,s)=>{const l=F.get(`transform.${n.type}`),d=m.length;E(s,A);try{A=l.apply(A,n)}catch(u){const h=m.slice(d).find(b=>b.level==="error");throw h?Object.assign(new Error(h.message),{path:h.path}):Object.assign(new Error(u instanceof Error?u.message:String(u)),{path:`transforms[${s}]`})}if(!A)throw new Error(`transforms[${s}] returned no table`)});const K=A,Q=G.slice(H);let W=0;for(const n of Q){const s=F.get(`transform.${n.type}`);if(s.viewDependent===!0)break;A=s.apply(A,n),W++}const i={w:e.size?e.size[0]:640,h:e.size?e.size[1]:400},f=e.padding,g=typeof f=="number"?{top:f,right:f,bottom:f,left:f}:{...xt,...f||{}};e.title&&(g.top+=He);let k=Ne(i,g);const j=e.scales||{},p=Object.create(null),I=new Map,U=new Map,S=new Map,R=new Map,x=n=>F.get(`mark.${n.type}`),B=Object.create(null),X=()=>{for(const n of Object.keys(p))p[n].setDomain(B[n]||null),B[n]&&(B[n]=p[n].domain());I.clear(),U.clear(),S.clear(),R.clear()},_e=n=>{const s=x(n),l=d=>s.channels[d]?ie(n,d,s.channels[d]):null;return{scale(d){const u=l(d),h=u&&u.scale!==void 0&&Object.prototype.hasOwnProperty.call(j,u.scale)?j[u.scale]:void 0,b=h?F.get(`scale.${h.type}`):void 0;return h&&b?{input:b.input,even:b.even===!0}:void 0},column(d){const u=l(d);return u&&u.field!==void 0?T(A,u.field):void 0}}},bt=(n={})=>{for(const s of Object.keys(j))en(s,Object.prototype.hasOwnProperty.call(n,s)?n[s]:[])},en=(n,s)=>{const l=j[n],d=F.get(`scale.${l.type}`),u=s.length?[s]:[],h=`scale "${n}"`;e.marks.forEach((v,D)=>{const C=x(v);for(const P of Object.keys(C.channels)){const V=ie(v,P,C.channels[P]);if(!(!V||V.scale!==n))if(V.field!==void 0){u.push(A.columns[V.field]),O(`marks[${D}].${P}`,Be(h,V.field,T(A,V.field),d.input));const J=C.reach?C.reach(v,P,_e(v)):null;J&&J.length&&u.push(J)}else d.fieldsOnly||u.push([V.value])}}),typeof l.field=="string"&&(u.push(A.columns[l.field]),O(`scales.${n}.field`,Be(h,l.field,T(A,l.field),d.input)));let b;try{b=d.create(l,{name:n,sources:u,range:Ce(n,l,k),color:ye})}catch(v){throw Object.assign(new Error(v instanceof Error?v.message:String(v)),{path:`scales.${n}`})}p[n]=Object.defineProperties(b,{output:{value:d.output},input:{value:d.input}})};bt();const Ue=e.view||{};for(const n of Object.keys(Ue))B[n]=Ue[n];for(const n of Object.keys(r||{}))p[n]&&!Object.prototype.hasOwnProperty.call(Ue,n)&&(B[n]=r[n]);for(const n of Object.keys(c||{})){const s=c[n];p[n]&&(s?B[n]=s:delete B[n])}X(),e.marks.forEach((n,s)=>{const l=x(n);for(const d of Object.keys(l.channels)){const u=ie(n,d,l.channels[d]),h=u&&u.field===void 0&&u.scale!==void 0?p[u.scale]:void 0,b=h?be(u.scale,j[u.scale]):void 0;if(!u||!h||b!=="width"&&b!=="height")continue;const v=h(u.value),[D,C]=h.range();v>=Math.min(D,C)-.5&&v<=Math.max(D,C)+.5||w(`marks[${s}].${d}`,`the constant ${String(u.value)} is outside scale "${u.scale}", so it is not drawn where you meant`)}});const wt=12,qe=new WeakMap,tn=(n,s,l)=>{const d=qe.get(n);if(d&&d.scale===s)return d.dir;if(n instanceof Float64Array&&s.invert&&l>=2){let D=!0,C=!0;for(let q=1;q<l&&(D||C);q++){const Y=n[q],ne=n[q-1];Y!==Y||ne!==ne?(D=!1,C=!1):(Y<ne&&(D=!1),Y>ne&&(C=!1))}const P=s(n[0]),V=s(n[l-1]);let J=0;if(isFinite(P)&&isFinite(V)&&P!==V){const q=V>P?1:-1;J=D?q:C?-q:0}return qe.set(n,{scale:s,dir:J}),J}let u=!0,h=!0,b=0;for(let D=0;D<l&&(u||h);D++){const C=s(n[D]);if(typeof C!="number"||C!==C){u=!1,h=!1;break}D>0&&(C<b&&(u=!1),C>b&&(h=!1)),b=C}const v=l<2?0:u?1:h?-1:0;return qe.set(n,{scale:s,dir:v}),v},ke=(n,s)=>{let l=0,d=n;for(;l<d;){const u=l+d>>1;s(u)?d=u:l=u+1}return l},nn=n=>{const s=A.length;let l=0,d=s;if(!Object.keys(B).length)return{from:l,to:d};const u=x(n);for(const h of Object.keys(u.channels)){const b=ie(n,h,u.channels[h]);if(!b||b.field===void 0||b.scale===void 0||!B[b.scale])continue;const v=p[b.scale],D=A.columns[b.field],C=v.range();if(!D||typeof C[0]!="number"||typeof C[1]!="number")continue;const P=tn(D,v,s);if(!P)continue;const V=Math.min(C[0],C[1])-wt,J=Math.max(C[0],C[1])+wt,q=oe=>v(D[oe]),Y=P===1?ke(s,oe=>q(oe)>=V):ke(s,oe=>q(oe)<=J),ne=P===1?ke(s,oe=>q(oe)>J):ke(s,oe=>q(oe)<V);l=Math.max(l,Y-1,0),d=Math.min(d,ne+1,s)}return d<l&&(d=l),{from:l,to:d}};let Le=[];const Re=new Set,Ae=Pt(t,n=>Re.add(n)),re={spec:e,format:(n,s)=>Pe(n,s,a),get table(){return A},baseTable:K,size:i,get plot(){return k},scales:p,measure:Ae?(n,s)=>{const l=it(n,s),d=Ae.inked(n,s);return d>l.w?{w:d,h:l.h}:l}:it,textWidth:Ae?Ae.width:De,wide:Tt,alongX:(e.interaction||[]).some(n=>{const s=F.get(`interaction.${n.type}`);return!!(s&&s.alongX)}),toggled(n){return(e.interaction||[]).some(s=>{const l=F.get(`interaction.${s.type}`);return!!(l&&l.toggles&&l.toggles(s,re)===n)})},say(n){typeof n=="string"&&n.trim()&&Le.push(n.trim())},orientation(n){const s=j[n]&&be(n,j[n]);return s==="width"?"horizontal":s==="height"?"vertical":null},ticks(n,s){const l=p[n];if(!l||!l.ticks)return[];const d=re.orientation(n);let u=s!==void 0?s:Math.max(2,Math.round(d==="vertical"?k.h/40:d==="horizontal"?k.w/80:6));if(s===void 0&&l.input==="category"&&d)for(const v of e.guides||[]){const D=v.scale===n?F.get(`guide.${v.type}`):void 0;D&&D.fits&&(u=Math.max(u,Math.min(l.domain().length,D.fits(v,re,d==="horizontal"?k.w:k.h))))}const h=`${n}:${u}`;let b=U.get(h);return b||U.set(h,b=l.ticks(u)),b},edgeTaken(n){const s={left:0,right:0};for(const l of e.interaction||[]){const d=F.get(`interaction.${l.type}`),u=d&&d.corner?d.corner(l,re):null;u&&u.edge===n&&(s[u.side]=Math.max(s[u.side],u.width))}return s},rows(n){let s=S.get(n);return s||S.set(n,s=nn(n)),s},series(n,s){const l=R.get(n);if(l&&l.xs===s)return l.out;const d=n.color!==void 0?re.channel(n,"color"):null,u=typeof n.group=="string"?n.group:d&&d.field,h=u?A.columns[u]:void 0,{from:b,to:v}=re.rows(n),D=new Map;for(let P=b;P<v;P++){const V=h?h[P]:0,J=D.get(V);J?J.push(P):D.set(V,[P])}const C=[];return D.forEach((P,V)=>{let J=!0;for(let q=1;q<P.length;q++)if(s[P[q]]<s[P[q-1]]){J=!1;break}J||P.sort((q,Y)=>s[q]!==s[q]?s[Y]!==s[Y]?0:1:s[Y]!==s[Y]?-1:s[q]-s[Y]),C.push({key:V,rows:P})}),R.set(n,{xs:s,out:C}),C},color:ye,channel(n,s){let l=I.get(n);if(l||I.set(n,l={}),l[s])return l[s];const d=x(n).channels[s],u=ie(n,s,d);let h;if(u)if(u.field===void 0){const b=u.scale!==void 0?p[u.scale]:void 0,v=new Array(A.length).fill(u.value),D=b?new Array(A.length).fill(b(u.value)):v;h={raw:v,mapped:D,scale:b,half:b&&b.bandwidth!==void 0?b.bandwidth/2:0}}else{const b=A.columns[u.field],v=u.scale!==void 0?p[u.scale]:void 0;if(!v)h={field:u.field,raw:b,mapped:b,half:0};else{const D=A.length,{from:C,to:P}=re.rows(n),J=typeof(P>C?v(b[C]):0)=="number"?new Float64Array(D).fill(NaN):new Array(D);for(let q=C;q<P;q++)J[q]=v(b[q]);h={field:u.field,scale:v,raw:b,mapped:J,half:v.bandwidth!==void 0?v.bandwidth/2:0}}}else{if(d&&d.required)throw new Error(`mark.${n.type}: channel "${s}" is required`);h={raw:[],mapped:[],half:0}}return l[s]=h}},$t=e.guides||[],Ve=[],kt=()=>{k=Ne(i,g);for(const d of Object.keys(p))p[d].setRange(Ce(d,j[d],k));U.clear();const n={top:0,right:0,bottom:0,left:0},s={top:0,right:0,bottom:0,left:0};Ve.length=0,$t.forEach((d,u)=>{Ve.push({...n});try{const h=F.get(`guide.${d.type}`),b=h.measure?h.measure(d,re):{};for(const v of pe)n[v]+=b[v]||0,b.overhang&&(s[v]=Math.max(s[v],b.overhang[v]||0))}catch(h){$(`guides[${u}]`,h)}});const l=d=>Math.max(g[d]+n[d],s[d]);k=Ne(i,{top:l("top"),right:l("right"),bottom:l("bottom"),left:l("left")}),l("top")+l("bottom")>i.h&&w("size",`padding and guides need ${l("top")+l("bottom")} px of height and the chart has ${i.h}, so its bottom is cut off`);for(const d of Object.keys(p))p[d].setRange(Ce(d,j[d],k));I.clear(),U.clear(),S.clear(),R.clear()};if(kt(),W){const n=()=>Object.keys(p).map(s=>p[s].baseDomain());for(let s=0;s<4;s++){for(const h of Object.keys(p))p[h].setDomain(null);let l=K;const d=Object.create(null);for(let h=0;h<W;h++){const b=H+h,v=F.get(`transform.${Q[h].type}`).apply(l,Q[h],{plot:k,scales:p,warn:D=>w(`transforms[${b}]`,D),fitting:!0,reach:(D,C)=>{typeof D=="string"&&Array.isArray(C)&&(d[D]=d[D]||[]).push(...C)}});if(!v)throw Object.assign(new Error("returned no table"),{path:`transforms[${b}]`});l=v}const u=n();if(A=l,bt(d),X(),Ut(u,n()))break;kt()}}let me;function At(){if(y(),Le=[],Q.length){let d=K;Q.forEach((u,h)=>{try{E(H+h,d);const b=F.get(`transform.${u.type}`).apply(d,u,{plot:k,scales:p,warn:v=>w(`transforms[${H+h}]`,v)});if(!b)throw new Error("returned no table");d=b}catch(b){$(`transforms[${H+h}]`,b)}}),A=d}I.clear(),U.clear(),S.clear(),R.clear();const n={grid:[],marks:[],axes:[],overlay:[]};e.marks.forEach((d,u)=>{try{const h=x(d);Fe(n.marks,h.render(d,re,u)),h.labels&&Fe(n.axes,h.labels(d,re,u))}catch(h){$(`marks[${u}]`,h)}}),$t.forEach((d,u)=>{try{const h=F.get(`guide.${d.type}`).render(d,re,Ve[u]);for(const b of Object.keys(h))Fe(n[b],h[b]||[])}catch(h){$(`guides[${u}]`,h)}}),e.title&&n.axes.push({type:"text",x:g.left,y:He-6,text:e.title,size:14,weight:600,style:{fill:"var(--bc-text, #444)"}});const s=Object.keys(B).length>0;me={size:i,plot:k,layers:["grid","marks","axes","overlay"].map(d=>({name:d,prims:n[d],clip:d==="marks"&&s?{...k}:void 0}))};const l=_t(e,Le);l&&(me.label=l),mt()}At();const le=F.get(`renderer.${e.renderer||"svg"}`).render(me,t);let We=!1;const Ot=(n,s)=>{if(!p[n]){console.warn(`[blockcharts] setView: unknown scale "${n}"`);return}s?B[n]=s:delete B[n],!We&&(We=!0,qt(()=>{if(We=!1,!N)try{X(),At(),le.update(me)}catch(l){$("view",l),console.error(l)}}))},vt=()=>{const n={};for(const s of Object.keys(p))n[s]=B[s]?B[s].slice():p[s].baseDomain();return n},rn=(n,s)=>{const l=j[n],d=j[s],u=B[s];if(!l||!d||!p[s]||!u)return null;const h=p[s].range(),b=typeof h[0]=="number"&&typeof h[1]=="number",v=b?Math.min(h[0],h[1]):0,D=b?Math.max(h[0],h[1]):0,C=F.get(`scale.${d.type}`).create({...d,domain:p[s].baseDomain()},{name:s,sources:[],range:p[s].range(),color:ye});C.setDomain(u);const P=Y=>{const ne=C(Y);return typeof ne=="number"?!b||ne>=v&&ne<=D:!!ne},V=[];let J=0;for(const Y of e.marks){const ne=x(Y),oe=de=>ie(Y,de,ne.channels[de]),Et=[],Je=[];for(const de of Object.keys(ne.channels)){const ae=oe(de);!ae||ae.field===void 0||(ae.scale===s?Et.push(A.columns[ae.field]):ae.scale===n&&Je.push(A.columns[ae.field]))}if(Je.length)for(const de of Je){const ae=[];for(let Oe=0;Oe<A.length;Oe++){let jt=!0;for(const an of Et)if(!P(an[Oe])){jt=!1;break}jt&&ae.push(de[Oe])}J+=ae.length,V.push(ae)}}return J?F.get(`scale.${l.type}`).create(l,{name:n,sources:V,range:p[n].range(),color:ye}).baseDomain():null},on=n=>{const s=n.target,l=s&&s.closest?s.closest("[data-bc-mark]"):null;return l?{mark:Number(l.getAttribute("data-bc-mark")),row:Number(l.getAttribute("data-bc-row"))}:null},sn=Object.create(re,{host:{value:t},dataAt:{value:n=>{if(le.dataAt)return le.dataAt(n);let s=n.target;for(;s&&s!==le.root.parentNode;){const l={};let d=!1;const u=s.attributes;for(let h=0;u&&h<u.length;h++)u[h].name.indexOf("data-")===0&&(l[u[h].name.slice(5)]=u[h].value,d=!0);if(d)return l;s=s.parentNode}return null}},root:{value:le.root},list:{get:()=>me},hit:{value:on},cleanup:{value:n=>{o.push(n)}},setView:{value:Ot},getView:{value:vt},fit:{value:rn},claimPosition:{value:_},claimDrag:{value:n=>ee.push(n)},dragClaimed:{value:n=>ee.some(s=>s(n))}});return(e.interaction||[]).forEach((n,s)=>{try{F.get(`interaction.${n.type}`).attach(n,sn)}catch(l){$(`interaction[${s}]`,l)}}),{rendered:le,diagnostics:m,setView:Ot,getView:vt,viewState:()=>{const n={};for(const s of Object.keys(B))n[s]=B[s].slice();return n},get fontsDue(){return Re.size?Promise.all(Array.from(Re)):null}}}function Rt(t,e){const o=document.createElement("div");o.setAttribute("class","bc-error"),o.setAttribute("style","font:12px/1.5 monospace;color:#b00020;border:1px solid #b00020;padding:8px;white-space:pre-wrap"),o.textContent=`blockcharts:
3
+ `+e.map(r=>`${r.level} ${r.path||"(spec)"}: ${r.message}`).join(`
4
+ `),t.appendChild(o)}function ln(t){if(!t||typeof t!="object")return[{level:"error",path:"",message:"the spec must be an object"}];const e=rt(t);return e?[{level:"error",path:"data",message:e}]:[]}const Vt=200,Wt=100;function lt(t){const e=(o,r)=>Array.isArray(r)&&r.every(c=>{if(!c||typeof c!="object"||typeof c.type!="string")return!1;const a=F.get(`${o}.${c.type}`),y=a&&a.role===o?a.narrow:void 0;try{return typeof y=="function"?y(c)===!0:y===!0}catch{return!1}});return e("mark",t.marks)&&(t.guides===void 0||e("guide",t.guides))}function dt(t,e){let o=e,r=null,c=[],a=null,y=[],m=0,$=!1,w=null,N={},z;const M=new Promise(E=>{z=E}),_=()=>a?c.concat(a.diagnostics):c;function ee(){for(const E of y)try{E()}catch(A){console.error(A)}y=[],a&&a.rendered.destroy(),a=null,t.textContent=""}function G(){const E=document.createElement("div");E.setAttribute("class","bc-loading"),E.setAttribute("style","font:12px system-ui,sans-serif;color:#777;padding:8px"),E.textContent="Loading data\u2026",t.appendChild(E)}function te(E){ee();const A=o&&typeof o.data=="string"?se.get(o.data):void 0;if(A){G(),A.then(()=>{!$&&E===m&&te(E)});return}c=st(o);const K=w,Q=N;if(w=null,N={},!c.some(i=>i.level==="error"))try{r=H(o);const i=r===null?o:{...o,size:[r,Array.isArray(o.size)?o.size[1]:400]};a=Lt(t,i,y,K||void 0,Q);const f=a.fontsDue;f&&f.then(()=>{$||E!==m||(w=a?a.viewState():w,L())})}catch(i){mt();const f=i&&typeof i.path=="string"?i.path:"";c.push({level:"error",path:f,message:i instanceof Error?i.message:String(i)})}const W=_();if(W.length){for(const i of W)(i.level==="error"?console.error:console.warn)(`[blockcharts] ${i.path||"(spec)"}: ${i.message}`);c.some(i=>i.level==="error")&&Rt(t,W)}z()}const L=()=>te(++m),H=E=>{if(!E||typeof E!="object"||E.responsive===!1)return null;const A=t.clientWidth,K=Array.isArray(E.size)&&typeof E.size[0]=="number"?E.size[0]:640;if(typeof A!="number"||!isFinite(A)||A<=0)return null;const Q=lt(E)?Wt:Vt,W=Math.max(Math.round(A),Math.min(K,Q));return Math.abs(W-K)<1?null:W},O=globalThis;let T=null,Z=!1;if(typeof O.ResizeObserver=="function"){const E=new O.ResizeObserver(()=>{if(Z||$)return;Z=!0,(typeof requestAnimationFrame=="function"?requestAnimationFrame:K=>setTimeout(K,16))(()=>{Z=!1,!($||H(o)===r)&&(w=a?a.viewState():w,L())})});E.observe(t),T=E}return L(),{host:t,get spec(){return o},get diagnostics(){return _()},ready:M,update(E,A){if($)return;const K=a?a.viewState():w||{},Q={};if(!(A&&A.resetView)){const W=o&&o.scales||{},i=E&&E.scales||{};for(const f of Object.keys(K))W[f]&&i[f]&&W[f].type===i[f].type&&(Q[f]=K[f])}for(const W of Object.keys(N)){const i=o&&o.scales||{},f=E&&E.scales||{};(A&&A.resetView||!i[W]||!f[W]||i[W].type!==f[W].type)&&delete N[W]}o=E,w=Q,L()},setView(E,A){if(!$){if(a)return a.setView(E,A);if(!(o&&o.scales&&Object.prototype.hasOwnProperty.call(o.scales,E))){console.warn(`[blockcharts] setView: unknown scale "${E}"`);return}N[E]=A}},getView(){if(a)return a.getView();const E={...o&&o.view||{}};for(const A of Object.keys(w||{}))Object.prototype.hasOwnProperty.call(E,A)||(E[A]=w[A]);for(const A of Object.keys(N)){const K=N[A];K?E[A]=K:delete E[A]}return E},destroy(){$=!0,T&&T.disconnect(),m++,ee(),z()}}}const ut=new WeakMap,ht=new WeakSet;function Te(t){const e=t||document,o=e.ownerDocument||e,r=[];return e.querySelectorAll("script#bc-data").forEach(c=>{try{const a=JSON.parse(c.textContent||"{}");for(const y of Object.keys(a))nt(y,a[y])}catch(a){console.error("[blockcharts] #bc-data:",a)}}),e.querySelectorAll("script[data-bc-chart]").forEach(c=>{if(ut.has(c))return;let a;try{a=JSON.parse(c.textContent||"")}catch($){console.error("[blockcharts] chart spec is not valid JSON:",$);return}const y=a&&typeof a=="object"&&typeof a.id=="string"&&a.id?a.id:null;let m=y?o.getElementById(y):null;m&&ht.has(m)?(console.error(`[blockcharts] chart id "${y}" is used by another chart on the page; this one is drawn where its spec is`),m=null):m&&/^script$/i.test(m.tagName||"")&&(m=null),m||(m=o.createElement("div"),y&&!o.getElementById(y)&&(m.id=y),m.className="bc-chart",c.parentNode&&c.parentNode.insertBefore(m,c.nextSibling));try{const $=dt(m,a);ht.add(m),ut.set(c,$),r.push($)}catch($){console.error("[blockcharts] chart could not be mounted:",$)}}),r}const Jt=864e13,Ht=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}:\d{2}(?::\d{2}(?:[.,]\d+)?)?)\s*(Z|[+-]\d{2}(?::?\d{2})?)?$/i,Kt=/^(?:\d{4}|[+-]\d{6})(?:-\d{2}(?:-\d{2})?)?$/;function we(t){if(typeof t=="number")return Math.abs(t)<=Jt?t:NaN;if(typeof t=="string"){const e=t.trim(),o=Ht.exec(e);if(!o)return Kt.test(e)?Date.parse(e):NaN;const r=o[3]===void 0?"Z":o[3].length===3?o[3]+":00":o[3].length===5?o[3].slice(0,3)+":"+o[3].slice(3):o[3];return Date.parse(`${o[1]}T${o[2].replace(",",".")}${r.toUpperCase()}`)}if(t&&typeof t.getTime=="function"){const e=t.getTime();return typeof e=="number"?e:NaN}return NaN}const Zt=/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/;function Be(t,e,o,r){if(!o||typeof o!="object"||ArrayBuffer.isView(o)||r!=="number"&&r!=="date")return null;let c=0,a=0;const y=[],m=[];for(let z=0;z<o.length;z++){const M=o[z];if(!(M==null||M===""||typeof M=="number"&&isNaN(M)))if(c++,r==="number"?typeof M=="number"&&isFinite(M):isFinite(we(M)))a++;else{const _=typeof M=="string"&&Zt.test(M.trim())?m:y;_.length<3&&_.indexOf(M)<0&&_.push(M)}}if(a===c)return null;const $=r==="number"?"numbers":"dates",w=y.concat(m).slice(0,3).map(z=>{const M=JSON.stringify(z)||String(z);return M.length>28?M.slice(0,27)+"\u2026":M}).join(", "),N=r==="number"?'A number is written as a number: 1750.5, not "1750.5", "1,750.50", "1750,5" or "$1,750"':'A date is ISO text ("2024-03-15", "2024-03-15T09:30") or epoch milliseconds';return a?{level:"warn",path:"",message:`${t} reads ${$} from "${e}", and ${c-a} of its ${c} values ${c-a===1?`is not a ${$.slice(0,-1)}, so it is`:`are not ${$}, so they are`} left out: ${w}. ${N}; where there is no value, null`}:{level:"error",path:"",message:`${t} reads ${$} from "${e}", and it has none: its values are like ${w}, so nothing of it is drawn. ${N}; where there is no value, null`}}const Gt="en-US",gt=["era","year","month","day","weekday","hour","minute","second","dayPeriod","fractionalSecondDigits","timeZoneName","dateStyle","timeStyle","hour12","hourCycle"],$e={percent:{kind:"number",style:"percent",maximumFractionDigits:1},compact:{kind:"number",notation:"compact",maximumFractionDigits:1},integer:{kind:"number",maximumFractionDigits:0},year:{kind:"date",year:"numeric"},quarter:{kind:"date",year:"numeric"},month:{kind:"date",month:"short",year:"numeric"},day:{kind:"date",month:"short",day:"numeric"},date:{kind:"date",dateStyle:"medium"},datetime:{kind:"date",dateStyle:"medium",timeStyle:"short"}},yt=new Map;let Ie;const mt=()=>{Ie=void 0},Xt=["style","currency","currencyDisplay","currencySign","unit","unitDisplay","notation","compactDisplay","signDisplay","useGrouping","minimumIntegerDigits","minimumFractionDigits","maximumFractionDigits","minimumSignificantDigits","maximumSignificantDigits","roundingMode","roundingIncrement","roundingPriority","trailingZeroDisplay","numberingSystem"],Yt={ko:(t,e)=>`${e}\uB144 ${t}\uBD84\uAE30`,zh:(t,e)=>`${e}\u5E74\u7B2C${t}\u5B63\u5EA6`,ja:(t,e)=>`${e}\u5E74\u7B2C${t}\u56DB\u534A\u671F`};function Pe(t,e,o){let r;if(typeof t=="string"){if(!Object.prototype.hasOwnProperty.call($e,t))throw new Error(`unknown format "${t}" (presets: ${Object.keys($e).join(", ")}; or an object of Intl options)`);r=$e[t]}else if(t&&typeof t=="object"&&!Array.isArray(t))r=t;else throw new Error("a format is a preset name or an object of Intl options");const c=r===$e.quarter,a=typeof r.locale=="string"&&r.locale||o||Ie||Gt,y=(e||"")+"|"+a+"|"+(c?"quarter":JSON.stringify(r)),m=yt.get(y);if(m)return m;const{locale:$,kind:w,prefix:N,suffix:z,...M}=r;if($!==void 0&&typeof $!="string")throw new Error('format "locale" must be a string like "en-US"');for(const[O,T]of[["prefix",N],["suffix",z]])if(T!==void 0&&typeof T!="string")throw new Error(`format "${O}" must be a string`);if(w!==void 0&&w!=="number"&&w!=="date")throw new Error('format "kind" must be "number" or "date"');for(const O of Object.keys(M))if(Xt.indexOf(O)<0&&gt.indexOf(O)<0&&O!=="timeZone"&&O!=="calendar"&&O!=="era"&&O!=="dayPeriod")throw new Error(`format option "${O}" is not known (a preset is written as the format itself, "quarter", and the language comes from "locale" or the chart)`);const _=(e||w||(Object.keys(M).some(O=>gt.indexOf(O)>=0)?"date":"number"))==="date";let ee,G;try{_?G=new Intl.DateTimeFormat(a,{timeZone:"UTC",...M}):ee=new Intl.NumberFormat(a,M)}catch(O){throw new Error(`invalid format ${JSON.stringify(t)}: ${O instanceof Error?O.message:String(O)}`)}const te=Yt[a.split("-")[0].toLowerCase()],L=O=>{if(!c)return G.format(O);const T=new Date(O),Z=Math.floor(T.getUTCMonth()/3)+1;return te?te(Z,T.getUTCFullYear()):"Q"+Z+" "+G.format(O)},H=O=>{if(O==null||typeof O=="number"&&isNaN(O))return"";let T;if(ee)T=typeof O=="number"&&isFinite(O)?ee.format(O):String(O);else{const Z=we(O);T=isFinite(Z)?L(Z):String(O)}return(N||"")+T+(z||"")};return yt.set(y,H),H}const Qt={version:ve,define:Ct,has:t=>F.has(t),get:t=>F.get(t),blocks:()=>Array.from(F.keys()),color:ye,palette:Object.freeze(ge.slice()),data:nt,ready:Nt,defineFn:(t,e)=>{if(typeof e!="function")throw new Error("BC.defineFn: "+t+" is not a function");Ke.set(t,e)},getFn:t=>Ke.get(t),formatter:(t,e)=>Pe(t,e),time:we,needs:Ft,validate:st,narrow:t=>!!t&&typeof t=="object"&&lt(t),table:t=>ce.get(t),chart:dt,mount:Te};Ee.BC=Qt;const pt=Ee.BC_CONFIG;typeof document<"u"&&!(pt&&pt.autoMount===!1)&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>Te()):setTimeout(()=>Te(),0))})();
5
+
6
+
7
+ "use strict";(function(i){function r(c,f,l,h,m){const o=e=>{throw new Error(c+": "+e)},a=e=>Object.prototype.hasOwnProperty.call(f.columns,e);for(const[e,n]of l)n!==void 0&&(typeof n!="string"||!a(n))&&o(`unknown field "${String(n)}" in "${e}"`);const t=new Map;for(const[e,n]of h)n==="__proto__"&&o(`a column cannot be named "__proto__": give "${e}" another name`),t.has(n)&&o(`"${t.get(n)}" and "${e}" both name the new column "${n}"`),t.set(n,e),a(n)&&m.indexOf(n)<0&&o(`"${n}" is already a column of the data: give the new one another name with "${e}"`)}const s={role:"lib",type:"columns",version:2,exports:{check:r}};i.define(s)})(globalThis.BC);
8
+
9
+
10
+ "use strict";(function(u){const e=n=>Math.round(n*100)/100;function k(n,f){const c=n.length,r=[];for(let o=0;o<c-1;o++){const h=n[o+1]-n[o];r.push(h?(f[o+1]-f[o])/h:0)}const s=new Array(c);s[0]=r[0]||0,s[c-1]=r[c-2]||0;for(let o=1;o<c-1;o++)s[o]=r[o-1]*r[o]<=0?0:(r[o-1]+r[o])/2;for(let o=0;o<c-1;o++){if(!r[o]){s[o]=0,s[o+1]=0;continue}const h=s[o]/r[o],i=s[o+1]/r[o],t=h*h+i*i;if(t>9){const l=3/Math.sqrt(t);s[o]=l*h*r[o],s[o+1]=l*i*r[o]}}return s}function d(n,f,c,r){const s=n.length;let o="";if(c==="step"){if(r)for(let t=s-1;t>0;t--)o+="V"+e(f[t-1])+"H"+e(n[t-1]);else for(let t=1;t<s;t++)o+="H"+e(n[t])+"V"+e(f[t]);return o}if(!(c===!0||c==="smooth")||s<3){if(r)for(let t=s-2;t>=0;t--)o+="L"+e(n[t])+" "+e(f[t]);else for(let t=1;t<s;t++)o+="L"+e(n[t])+" "+e(f[t]);return o}const i=k(n,f);if(r)for(let t=s-1;t>0;t--){const l=(n[t]-n[t-1])/3;o+="C"+e(n[t]-l)+" "+e(f[t]-i[t]*l)+" "+e(n[t-1]+l)+" "+e(f[t-1]+i[t-1]*l)+" "+e(n[t-1])+" "+e(f[t-1])}else for(let t=0;t<s-1;t++){const l=(n[t+1]-n[t])/3;o+="C"+e(n[t]+l)+" "+e(f[t]+i[t]*l)+" "+e(n[t+1]-l)+" "+e(f[t+1]-i[t+1]*l)+" "+e(n[t+1])+" "+e(f[t+1])}return o}const g={role:"lib",type:"curve",version:2,exports:{through:d}};u.define(g)})(globalThis.BC);
11
+
12
+
13
+ "use strict";(function(h){function w(n,r){const e=n.root.getBoundingClientRect();return{x:(r.clientX-e.left)*n.size.w/e.width,y:(r.clientY-e.top)*n.size.h/e.height}}function y(n,r,e=0){const i=n.plot;return r.x>=i.x-e&&r.x<=i.x+i.w+e&&r.y>=i.y-e&&r.y<=i.y+i.h+e}function x(n){typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>n()):setTimeout(n,0)}function b(n,r,e,i){const o=n.root,a=n.host,u=a.ownerDocument||document;let s=null,d=!1,v=!1;const l=t=>t.pointerType==="touch",p=t=>{if(t.buttons&&!l(t))return s=null,e();s=t,!d&&(d=!0,x(()=>{if(d=!1,v||!s)return;const f=s;s=null;try{r(f)}catch{e()}}))},L=t=>{(!i||l(t))&&p(t)},c=()=>{s=null,e()},m=t=>{l(t)||c()},E=t=>{const f=t.target;l(t)&&f&&typeof a.contains=="function"&&!a.contains(f)&&c()};o.addEventListener("pointermove",p),o.addEventListener("pointerdown",L),o.addEventListener("pointerleave",m),o.addEventListener("pointercancel",c),o.addEventListener("wheel",c),typeof u.addEventListener=="function"&&u.addEventListener("pointerdown",E,!0),n.cleanup(()=>{v=!0,o.removeEventListener("pointermove",p),o.removeEventListener("pointerdown",L),o.removeEventListener("pointerleave",m),o.removeEventListener("pointercancel",c),o.removeEventListener("wheel",c),typeof u.removeEventListener=="function"&&u.removeEventListener("pointerdown",E,!0)})}const g={role:"lib",type:"pointer",version:2,exports:{toLogical:w,inPlot:y,follow:b}};h.define(g)})(globalThis.BC);
14
+
15
+
16
+ "use strict";(function(f){function u(n){const i=n.length;if(i<2)return 0;let e=0;for(let t=0;t<i;t++)e+=n[t];e/=i;let s=0;for(let t=0;t<i;t++)s+=(n[t]-e)*(n[t]-e);const l=Math.sqrt(s/(i-1)),c=t=>{const a=t*(i-1),o=Math.floor(a);return n[o]+(n[Math.min(i-1,o+1)]-n[o])*(a-o)},r=c(.75)-c(.25);return r>0?Math.min(l,r/1.34):l}const h={role:"lib",type:"stats",version:1,exports:{spread:u}};f.define(h)})(globalThis.BC);
17
+
18
+
19
+ "use strict";(function(M){function h(s,e){const a=s/Math.max(1,e),o=Math.pow(10,Math.floor(Math.log10(a))),t=a/o;return(t<1.5?1:t<3?2:t<7?5:10)*o}const f=1e3;function u(s,e,a){const o=Math.min(s,e),t=Math.max(s,e),i=[];if(!(isFinite(o)&&isFinite(t)&&t-o>1e-12*Math.max(Math.abs(o),Math.abs(t))))return i;const n=h(t-o,a);if(!(n>0&&isFinite(n)))return i;const r=Math.min(100,Math.max(0,-Math.floor(Math.log10(n)))),p=Math.ceil(o/n-1e-9),x=Math.floor(t/n+1e-9);for(let c=p;c<=x&&i.length<f;c++){const l=+(c*n).toFixed(r);i.push({value:l,label:l.toFixed(r)})}return i}const m={role:"lib",type:"ticks",version:2,exports:{niceStep:h,roundTicks:u}};M.define(m)})(globalThis.BC);
20
+
21
+
22
+ "use strict";(function(F){function b(t){const s=t.baseDomain(),n=t(s[0]),i=t(s[1])-n;return!t.invert||!(isFinite(n)&&isFinite(i)&&i!==0)?null:{to:o=>(t(o)-n)/i,from:o=>o===0?s[0]:o===1?s[1]:t.invert(n+o*i),full:[0,1]}}function w(t,s){const n=b(t.scales[s]),i=t.getView()[s];return n?[n.to(i[0]),n.to(i[1])]:[0,1]}function l(t,s,n,i){const o=b(t.scales[s]);if(!o)return;const{from:u,full:c}=o,[f,e]=c;if(i-n>=(e-f)*(1-1e-9)){t.setView(s,null);return}n<f&&(i+=f-n,n=f),i>e&&(n-=i-e,i=e),t.setView(s,[u(n),u(i)])}function M(t,s,n,i,o){const u=b(t.scales[s]);if(!u)return;const[c,f]=u.full,[e,r]=w(t,s),p=Math.min(f-c,Math.max((f-c)/i,(r-e)*n));if(o===void 0||!(r>e)){const g=o===void 0?(e+r)/2:o;return l(t,s,g-p/2,g+p/2)}const V=p/(r-e);l(t,s,o-(o-e)*V,o+(r-o)*V)}const m={role:"lib",type:"view",version:2,exports:{current:w,show:l,zoom:M}};F.define(m)})(globalThis.BC);
23
+
24
+
25
+ "use strict";(function(y){function M(t){const i=new Set,r=[];for(const u of t)for(let a=0;a<u.length;a++){const e=u[a];e==null||typeof e=="number"&&isNaN(e)||i.has(e)||(i.add(e),r.push(e))}return r}const w={role:"scale",type:"band",version:5,output:"position",input:"category",merge:"union",fieldsOnly:!0,params:{paddingInner:{kind:"number",default:.2},paddingOuter:{kind:"number",default:.1}},create(t,i){const r=typeof t.paddingInner=="number"?t.paddingInner:.2,u=typeof t.paddingOuter=="number"?t.paddingOuter:.1,a=t.domain?t.domain.slice():M(i.sources);let e=a,g=new Map,l=Number(i.range[0]),d=Number(i.range[1]),c=0,f=0;const b=()=>{g=new Map,e.forEach((n,o)=>g.set(n,o))},m=()=>{c=Math.abs(d-l)/Math.max(1,e.length-r+2*u),f=c*(1-r)},h=n=>Math.min(l,d)+u*c+n*c;b(),m();const p=(n=>{const o=g.get(n);return o===void 0?NaN:h(o)});return Object.defineProperties(p,{bandwidth:{get:()=>f},domain:{value:()=>e.slice()},baseDomain:{value:()=>a.slice()},setDomain:{value:n=>{e=n?n.slice():a,b(),m()}},range:{value:()=>[l,d]},setRange:{value:n=>{l=n[0],d=n[1],m()}},ticks:{value:(n=10)=>{const o=Math.max(1,Math.ceil(e.length/Math.max(1,n))),v=[];for(let s=0;s<e.length;s+=o)v.push({value:e[s],pos:h(s)+f/2,label:String(e[s])});return v}}}),p}};y.define(w)})(globalThis.BC);
26
+
27
+
28
+ "use strict";(function(f){function g(o){const s=new Set,t=[];for(const r of o)for(let a=0;a<r.length;a++){const n=r[a];n==null||typeof n=="number"&&isNaN(n)||s.has(n)||(s.add(n),t.push(n))}return t}const d={role:"scale",type:"color",version:4,output:"color",input:"category",merge:"union",create(o,s){const t=o.domain?o.domain.slice():g(s.sources);let r=t,a=null;const n=Array.isArray(o.range)&&o.range.length?o.range.map(String):null,i=e=>n?n[e%n.length]:s.color(e),u=new Map;t.forEach((e,l)=>u.set(e,l));const c=(e=>{const l=u.get(e);return l===void 0?"var(--bc-axis, #999)":a&&!a.has(e)?"":i(l)});return Object.defineProperties(c,{domain:{value:()=>r.slice()},baseDomain:{value:()=>t.slice()},setDomain:{value:e=>{r=e?e.slice():t,a=e?new Set(r):null}},range:{value:()=>t.map((e,l)=>i(l))},setRange:{value:()=>{}}}),c}};f.define(d)})(globalThis.BC);
29
+
30
+
31
+ "use strict";(function(m){const b=()=>m.get("lib.ticks").exports,c=(i,o)=>b().niceStep(i,o),g=(i,o,e)=>b().roundTicks(i,o,e);function h(i){let o=1/0,e=-1/0;for(const t of i)for(let r=0;r<t.length;r++){const a=t[r];typeof a!="number"||!isFinite(a)||(a<o&&(o=a),a>e&&(e=a))}return o<=e?[o,e]:[0,1]}const N={role:"scale",type:"linear",version:9,output:"position",input:"number",merge:"extent",even:!0,requires:["lib.ticks"],params:{nice:{kind:"boolean",default:!0},zero:{kind:"boolean",default:!1},padding:{kind:"number",default:0}},create(i,o){let e,t;if(i.domain!==void 0&&i.domain!==null){const n=s=>typeof s=="number"?s:typeof s=="string"&&s.trim()?Number(s):NaN,u=Array.isArray(i.domain)&&i.domain.length===2?i.domain:[];if(e=n(u[0]),t=n(u[1]),!isFinite(e)||!isFinite(t)||e===t)throw new Error(`scale.linear: the domain must be two different numbers, not ${JSON.stringify(i.domain)}`)}else{if([e,t]=h(o.sources),i.zero&&(e=Math.min(e,0),t=Math.max(t,0)),t-e<=1e-12*Math.max(Math.abs(e),Math.abs(t))&&(e-=1,t+=1),typeof i.padding=="number"&&i.padding>0){const n=(t-e)*i.padding;e=i.zero&&e===0?0:e-n,t=i.zero&&t===0?0:t+n}if(i.nice!==!1){const n=c(t-e,6);e=Math.floor(e/n+1e-9)*n,t=Math.ceil(t/n-1e-9)*n}}let r=e,a=t,l=Number(o.range[0]),f=Number(o.range[1]);const d=(n=>l+(n-r)/(a-r)*(f-l));return Object.defineProperties(d,{domain:{value:()=>[r,a]},baseDomain:{value:()=>[e,t]},setDomain:{value:n=>{r=n?n[0]:e,a=n?n[1]:t}},range:{value:()=>[l,f]},setRange:{value:n=>{l=n[0],f=n[1]}},invert:{value:n=>r+(n-l)/(f-l)*(a-r)},ticks:{value:(n=6)=>g(r,a,n).map(u=>({...u,pos:d(u.value)}))}}),d}};m.define(N)})(globalThis.BC);
32
+
33
+
34
+ "use strict";(function(w){const s=Math.log10;function E(i){throw new Error("scale.log: "+i)}function x(i){let r=1/0,t=-1/0;for(const n of i)for(let a=0;a<n.length;a++){const o=n[a];typeof o!="number"||!(o>0)||o===1/0||(o<r&&(r=o),o>t&&(t=o))}return r<=t?[r,t]:null}const y=i=>i>=1?w.formatter({notation:"compact",maximumSignificantDigits:3})(i):String(+i.toPrecision(3)),C=2,v=(i,r)=>{const t=Math.pow(10,Math.floor(s(i)+1e-9)),n=i/t,a=[1,2,5,10];return t*(r?a.find(o=>o>=n-1e-9):a.slice().reverse().find(o=>o<=n+1e-9))},D={role:"scale",type:"log",version:6,output:"position",input:"number",merge:"extent",params:{nice:{kind:"boolean",default:!0}},create(i,r){let t,n;if(i.domain!==void 0&&i.domain!==null){const e=Array.isArray(i.domain)&&i.domain.length===2?i.domain:[NaN,NaN];t=Number(e[0]),n=Number(e[1]),t>0&&n>0&&isFinite(t)&&isFinite(n)&&t!==n||E(`the domain must be two different positive numbers, not ${JSON.stringify(i.domain)}`)}else{[t,n]=x(r.sources)||[1,10];const c=l=>l>0&&isFinite(l);if(t===n&&(c(t/10)&&(t/=10),c(n*10)&&(n*=10)),i.nice!==!1){const l=s(n)-s(t)<C,m=l?v(t,!1):Math.pow(10,Math.floor(s(t)+1e-9)),d=l?v(n,!0):Math.pow(10,Math.ceil(s(n)-1e-9));c(m)&&(t=m),c(d)&&(n=d)}}let a=t,o=n,u=Number(r.range[0]),g=Number(r.range[1]);const p=(e=>e>0?u+(s(e)-s(a))/(s(o)-s(a))*(g-u):NaN);return Object.defineProperties(p,{domain:{value:()=>[a,o]},baseDomain:{value:()=>[t,n]},setDomain:{value:e=>{a=e&&e[0]>0&&isFinite(e[0])?e[0]:t,o=e&&e[1]>0&&isFinite(e[1])?e[1]:n}},range:{value:()=>[u,g]},setRange:{value:e=>{u=e[0],g=e[1]}},invert:{value:e=>Math.pow(10,s(a)+(e-u)/(g-u)*(s(o)-s(a)))},ticks:{value:(e=6)=>{const c=Math.min(a,o),l=Math.max(a,o),m=Math.floor(s(c)+1e-9),d=Math.ceil(s(l)-1e-9),b=Math.max(1,d-m),M=Math.max(1,e),F=b*3<=M?[1,2,5]:b*2<=M?[1,3]:[1],I=F.length===1?Math.max(1,Math.ceil(b/M)):1,N=[];for(let f=m;f<=d;f++)if(!((f-m)%I))for(const O of F){const h=+(O*Math.pow(10,f)).toPrecision(12);!isFinite(h)||h<c*(1-1e-9)||h>l*(1+1e-9)||N.push({value:h,pos:p(h),label:y(h)})}return N.length<2?[c,l].map(f=>({value:f,pos:p(f),label:y(f)})):N}}}),p}};w.define(D)})(globalThis.BC);
35
+
36
+
37
+ "use strict";(function(h){const x=["#440154","#3b528b","#21908d","#5dc863","#fde725"];function y(n){const a=typeof n=="string"?/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(n.trim()):null;if(!a)throw new Error(`scale.sequential: range colors must be #rgb or #rrggbb, got ${JSON.stringify(n)} (mixing needs real numbers, so CSS variables and names cannot be used)`);let t=a[1];return t.length===3&&(t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2]),[parseInt(t.slice(0,2),16),parseInt(t.slice(2,4),16),parseInt(t.slice(4,6),16)]}const u=n=>{const a=Math.max(0,Math.min(255,Math.round(n)));return(a<16?"0":"")+a.toString(16)},N=()=>h.get("lib.ticks").exports,w=(n,a,t)=>N().roundTicks(n,a,t),M={role:"scale",type:"sequential",version:7,output:"color",input:"number",merge:"extent",requires:["lib.ticks"],params:{exponent:{kind:"number",default:1}},create(n,a){const t=(Array.isArray(n.range)&&n.range.length?n.range:x).map(y);if(t.length<2)throw new Error("scale.sequential: range needs at least two colors");let i,o;if(n.domain!==void 0&&n.domain!==null){const e=Array.isArray(n.domain)&&n.domain.length===2?n.domain:[NaN,NaN];if(i=Number(e[0]),o=Number(e[1]),!isFinite(i)||!isFinite(o)||i===o)throw new Error(`scale.sequential: domain must be two different numbers, [min, max], not ${JSON.stringify(n.domain)}; a diverging scale is three colors in "range" and a domain even around the middle, such as [-10, 10]`)}else{i=1/0,o=-1/0;for(const e of a.sources)for(let s=0;s<e.length;s++){const r=e[s];typeof r!="number"||!isFinite(r)||(r<i&&(i=r),r>o&&(o=r))}i>o&&(i=0,o=1),i===o&&(i-=.5,o+=.5)}let l=i,m=o;const d=typeof n.exponent=="number"&&n.exponent>0&&isFinite(n.exponent)?n.exponent:1,f=e=>d===1?e:e<0?-Math.pow(-e,d):Math.pow(e,d),v=e=>{const s=Math.max(0,Math.min(1,e))*(t.length-1),r=Math.min(t.length-2,Math.floor(s)),g=s-r,c=t[r],b=t[r+1];return"#"+u(c[0]+(b[0]-c[0])*g)+u(c[1]+(b[1]-c[1])*g)+u(c[2]+(b[2]-c[2])*g)},p=(e=>typeof e=="number"&&isFinite(e)?v((f(e)-f(l))/(f(m)-f(l))):"");return Object.defineProperties(p,{domain:{value:()=>[l,m]},baseDomain:{value:()=>[i,o]},setDomain:{value:e=>{l=e?e[0]:i,m=e?e[1]:o}},range:{value:()=>t.map(e=>"#"+u(e[0])+u(e[1])+u(e[2]))},setRange:{value:()=>{}},ticks:{value:(e=5)=>w(l,m,e).map(s=>({...s,pos:(s.value-l)/(m-l)}))}}),p}};h.define(M)})(globalThis.BC);
38
+
39
+
40
+ "use strict";(function(c){const d=[2,24],g=()=>c.get("lib.ticks").exports,y=(n,f,a)=>g().roundTicks(n,f,a),N={role:"scale",type:"size",version:6,output:"size",input:"number",merge:"extent",requires:["lib.ticks"],params:{zero:{kind:"boolean",default:!0}},create(n,f){const a=Array.isArray(n.range)&&n.range.length===2?n.range.map(Number):d;if(!a.every(e=>isFinite(e)&&e>=0)||a[0]>a[1])throw new Error(`scale.size: range must be [smallest, largest] radius in px, got ${JSON.stringify(n.range)}`);let s=a[0],u=a[1],i,r;if(n.domain!==void 0&&n.domain!==null){const e=Array.isArray(n.domain)&&n.domain.length===2?n.domain:[NaN,NaN];if(i=Number(e[0]),r=Number(e[1]),!isFinite(i)||!isFinite(r)||i>=r||i<0)throw new Error(`scale.size: domain must be [min, max] with 0 <= min < max, not ${JSON.stringify(n.domain)}`)}else{i=1/0,r=-1/0;for(const e of f.sources)for(let t=0;t<e.length;t++){const o=e[t];typeof o!="number"||!isFinite(o)||o<0||(o<i&&(i=o),o>r&&(r=o))}i>r&&(i=0,r=1),n.zero!==!1&&(i=0),i===r&&(i=i>0?0:i,r=r>0?r*2:1)}let l=i,m=r;const b=(e=>{if(typeof e!="number"||!isFinite(e)||e<0)return NaN;const t=Math.max(0,Math.min(1,(e-l)/(m-l)));return Math.sqrt(s*s+t*(u*u-s*s))});return Object.defineProperties(b,{domain:{value:()=>[l,m]},baseDomain:{value:()=>[i,r]},setDomain:{value:e=>{l=e?Number(e[0]):i,m=e?Number(e[1]):r}},range:{value:()=>[s,u]},setRange:{value:e=>{Array.isArray(e)&&e.length===2&&e.every(t=>typeof t=="number"&&isFinite(t))&&(s=e[0],u=e[1])}},ticks:{value:(e=3)=>y(l,m,e).filter(t=>t.value>0).slice(0,50).map(t=>({...t,pos:b(t.value)}))}}),b}};c.define(N)})(globalThis.BC);
41
+
42
+
43
+ "use strict";(function(g){const D=[1,2,5,10,20,50,100,200,500,1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5],T=[1,3,6],F=4*864e5,S=864e13,p=1e3,b=n=>(n<10?"0":"")+n;function M(n){return typeof n=="number"?Math.abs(n)<=S?n:NaN:g.time(n)}function w(n,a){const t=n/315576e5/Math.max(1,a),e=Math.pow(10,Math.floor(Math.log10(Math.max(t,1)))),i=t/e;return Math.max(1,(i<1.5?1:i<3?2:i<7?5:10)*e)}function C(n,a){const t=new Date(n);if(a>=864e5)return g.formatter({month:"short",day:"numeric"},"date")(n);const e=`${b(t.getUTCHours())}:${b(t.getUTCMinutes())}`;if(a<1e3){const i=t.getUTCMilliseconds();return`${e}:${b(t.getUTCSeconds())}.${i<10?"00":i<100?"0":""}${i}`}return a<6e4?`${e}:${b(t.getUTCSeconds())}`:e}function y(n,a,t){const e=Date.UTC(n,a,t);if(n<0||n>99||!isFinite(e))return e;const i=new Date(e);return i.setUTCFullYear(n),i.getTime()}function N(n,a,t){const e=[];if(!isFinite(n)||!isFinite(a))return e;const i=Math.min(n,a),f=Math.max(n,a),s=f-i,u=D.find(r=>s/r<=t);if(u!==void 0){const r=u===6048e5?F:0;for(let c=Math.ceil((i-r)/u)*u+r;c<=f&&e.length<p;c+=u)e.push({t:c,label:C(c,u)});return e}const d=T.find(r=>s/(r*26298e5)<=t);if(d!==void 0){const r=new Date(i);let c=Math.ceil((r.getUTCFullYear()*12+r.getUTCMonth())/d)*d;for(;e.length<p;c+=d){const l=y(Math.floor(c/12),c%12,1);if(!isFinite(l)||l>f)break;l<i||e.push({t:l,label:g.formatter({month:"short",year:"numeric"},"date")(l)})}return e}const o=w(s,t);for(let r=Math.ceil(new Date(i).getUTCFullYear()/o)*o;e.length<p;r+=o){const c=y(r,0,1);if(!isFinite(c)||c>f)break;c<i||e.push({t:c,label:String(r)})}return e}function U(n,a){const t=a-n,e=10;let i;const f=D.find(s=>t/s<=e);if(f!==void 0){const s=f===6048e5?F:0;i=[Math.floor((n-s)/f)*f+s,Math.ceil((a-s)/f)*f+s]}else{const s=T.find(l=>t/(l*26298e5)<=e),u=s!==void 0?s:w(t,e)*12,d=l=>y(Math.floor(l/12),(l%12+12)%12,1),o=l=>{const h=new Date(l);return h.getUTCFullYear()*12+h.getUTCMonth()},r=Math.floor(o(n)/u)*u;let c=Math.floor(o(a)/u)*u;d(c)<a&&(c+=u),i=[d(r),d(c)]}return i.every(s=>isFinite(s)&&Math.abs(s)<=S)&&i[0]<i[1]?i:[n,a]}function k(n,a,t){let e=N(n,a,t);for(let i=t*2;e.length<2&&i<=t*16;i*=2){const f=N(n,a,i);f.length>e.length&&(e=f)}return e}const v={role:"scale",type:"time",version:10,output:"position",input:"date",merge:"extent",even:!0,params:{padding:{kind:"number",default:0},nice:{kind:"boolean",default:!1}},create(n,a){let t,e;if(n.domain!==void 0&&n.domain!==null){const o=Array.isArray(n.domain)&&n.domain.length===2?n.domain:[NaN,NaN];if(t=M(o[0]),e=M(o[1]),!isFinite(t)||!isFinite(e)||t===e)throw new Error(`scale.time: domain must be two different dates (ISO strings such as "2024-01-01", or epoch milliseconds), got ${JSON.stringify(n.domain)}`)}else{t=1/0,e=-1/0;let o=0,r=0,c=0;for(const l of a.sources)for(let h=0;h<l.length;h++){const m=M(l[h]);if(!isFinite(m)){typeof l[h]=="number"&&isFinite(l[h])&&o++;continue}typeof l[h]=="number"&&m>=1e3&&m<=2999&&m===Math.floor(m)?r++:c++,m<t&&(t=m),m>e&&(e=m)}if(r&&!c)throw new Error(`scale.time: the numbers look like years (${t} to ${e}), and a time scale reads a number as milliseconds since 1970, so all of them fall in its first three seconds. Give the years as text ("2019" is 1 January) or as dates ("2019-01-01"); from a CSV, "types": { "year": "string" } keeps the column text. Or draw them on a linear scale`);if(t>e){if(o)throw new Error("scale.time: the numbers are outside the range of dates; a time scale reads epoch milliseconds (from nanoseconds divide by 1e6, from seconds multiply by 1000)");t=0,e=864e5}if(t===e&&(t-=864e5/2,e+=864e5/2),typeof n.padding=="number"&&n.padding>0){const l=(e-t)*n.padding;t-=l,e+=l}n.nice===!0&&([t,e]=U(t,e))}let i=t,f=e,s=Number(a.range[0]),u=Number(a.range[1]);const d=(o=>s+(M(o)-i)/(f-i)*(u-s));return Object.defineProperties(d,{domain:{value:()=>[i,f]},baseDomain:{value:()=>[t,e]},setDomain:{value:o=>{i=o?M(o[0]):t,f=o?M(o[1]):e}},range:{value:()=>[s,u]},setRange:{value:o=>{s=o[0],u=o[1]}},invert:{value:o=>i+(o-s)/(u-s)*(f-i)},ticks:{value:(o=6)=>k(i,f,Math.max(1,o)).map(r=>({value:r.t,pos:d(r.t),label:r.label}))}}),d}};g.define(v)})(globalThis.BC);
44
+
45
+
46
+ "use strict";(function(N){const w=["count","sum","mean","min","max","median","distinct"],O=["year","quarter","month","week","day","hour"],D=["sum","mean","min","max","median","distinct"],A=["sum","mean","min","max","median"],d=(o,s=2)=>{let i=String(o);for(;i.length<s;)i="0"+i;return i};function m(o){throw new Error("transform.aggregate: "+o)}function k(o){const s=o.groupby===void 0?[]:o.groupby;return Array.isArray(s)||m('"groupby" must be a list of field names'),s.map((i,r)=>{if(typeof i=="string")return{field:i,as:i};const e=i;(!e||typeof e!="object"||typeof e.field!="string")&&m(`groupby[${r}] must be a field name or { field, unit }`),e.unit!==void 0&&(typeof e.unit!="string"||O.indexOf(e.unit)<0)&&m(`groupby[${r}].unit must be one of: ${O.join(", ")}`);const n=e.unit;return{field:e.field,unit:n,as:typeof e.as=="string"&&e.as?e.as:e.field}})}function x(o){const s=o.measures===void 0?[{op:"count"}]:o.measures;return(!Array.isArray(s)||!s.length)&&m('"measures" must be a non-empty list like [{ "op": "sum", "field": "revenue" }]'),s.map((i,r)=>{const e=i;(!e||typeof e!="object"||typeof e.op!="string"||w.indexOf(e.op)<0)&&m(`measures[${r}].op must be one of: ${w.join(", ")}`);const n=e.op;D.indexOf(n)>=0&&typeof e.field!="string"&&m(`measures[${r}]: "${n}" needs a "field"`),e.field!==void 0&&typeof e.field!="string"&&m(`measures[${r}].field must be a field name`);const u=e.field;return{op:n,field:u,as:typeof e.as=="string"&&e.as?e.as:u?`${n}_${u}`:n}})}function T(o){const s=[...k(o).map(r=>r.as),...x(o).map(r=>r.as)],i=s.find((r,e)=>s.indexOf(r)!==e);return i!==void 0&&m(`two output columns are called "${i}"; give one of them another "as"`),s}function S(o,s){const i=N.time(o);if(!isFinite(i))return null;const r=new Date(i),e=r.getUTCFullYear(),n=r.getUTCMonth();switch(s){case"year":return`${d(e,4)}-01-01`;case"quarter":return`${d(e,4)}-${d(Math.floor(n/3)*3+1)}-01`;case"month":return`${d(e,4)}-${d(n+1)}-01`;case"week":{const u=(r.getUTCDay()+6)%7,c=new Date(Date.UTC(e,n,r.getUTCDate()-u));return`${d(c.getUTCFullYear(),4)}-${d(c.getUTCMonth()+1)}-${d(c.getUTCDate())}`}case"day":return`${d(e,4)}-${d(n+1)}-${d(r.getUTCDate())}`;default:return`${d(e,4)}-${d(n+1)}-${d(r.getUTCDate())}T${d(r.getUTCHours())}:00:00Z`}}const U=o=>typeof o=="number"&&isFinite(o);function j(o,s,i){if(o==="count"){if(!i)return s.length;let n=0;for(const u of s)i[u]!=null&&!(typeof i[u]=="number"&&isNaN(i[u]))&&n++;return n}const r=i;if(o==="distinct"){const n=new Set;for(const u of s)r[u]!=null&&!(typeof r[u]=="number"&&isNaN(r[u]))&&n.add(r[u]);return n.size}const e=[];for(const n of s)U(r[n])&&e.push(r[n]);if(!e.length)return NaN;switch(o){case"sum":return e.reduce((n,u)=>n+u,0);case"mean":return e.reduce((n,u)=>n+u,0)/e.length;case"min":return e.reduce((n,u)=>u<n?u:n);case"max":return e.reduce((n,u)=>u>n?u:n);default:{e.sort((u,c)=>u-c);const n=e.length>>1;return e.length%2?e[n]:(e[n-1]+e[n])/2}}}const F={role:"transform",type:"aggregate",version:3,replacesColumns:!0,params:{groupby:{kind:"list"},measures:{kind:"list",default:[{op:"count"}]},sort:{kind:"string"},order:{kind:"enum",values:["asc","desc"],default:"asc"},limit:{kind:"number"}},outputs:o=>T(o),apply(o,s){const i=k(s),r=x(s),e=T(s);i.forEach((t,f)=>{Object.prototype.hasOwnProperty.call(o.columns,t.field)||m(`unknown field "${t.field}" in "groupby[${f}]"`)}),r.forEach((t,f)=>{t.field&&!Object.prototype.hasOwnProperty.call(o.columns,t.field)&&m(`unknown field "${t.field}" in "measures[${f}].field"`)}),r.forEach((t,f)=>{if(!t.field||A.indexOf(t.op)<0)return;const g=o.columns[t.field];let a;for(let y=0;y<o.length;y++){const l=g[y];if(U(l))return;a===void 0&&l!=null&&l!==""&&typeof l!="number"&&(a=l)}a!==void 0&&m(`measures[${f}]: "${t.op}" needs numbers, and "${t.field}" has none: its values are like ${JSON.stringify(a)}. A number is written as a number: 1750.5, not "1750.5", "1,750.50" or "$1,750"`)}),s.sort!==void 0&&(typeof s.sort!="string"||e.indexOf(s.sort)<0)&&m(`"sort" must be one of the output columns: ${e.join(", ")}`),s.limit!==void 0&&!(typeof s.limit=="number"&&s.limit>=0&&isFinite(s.limit))&&m('"limit" must be a number of at least 0');const n=new Map,u=i.map(t=>o.columns[t.field]);for(let t=0;t<o.length;t++){const f=[];let g=!1;for(let l=0;l<i.length;l++){let p=u[l][t];if(i[l].unit){if(p=S(p,i[l].unit),p===null){g=!0;break}}else typeof p=="number"&&isNaN(p)&&(p=null);f.push(p)}if(g)continue;const a=f.map(l=>typeof l+":"+String(l)).join("\u241F"),y=n.get(a);y?y.rows.push(t):n.set(a,{values:f,rows:[t]})}!i.length&&!n.size&&n.set("",{values:[],rows:[]});let c=Array.from(n.values());const v=c.map(t=>r.map(f=>j(f.op,t.rows,f.field?o.columns[f.field]:void 0)));let h=c.map((t,f)=>f);const C=typeof s.sort=="string"?s.sort:i.some(t=>t.unit)?i.find(t=>t.unit).as:void 0;if(C!==void 0){const t=e.indexOf(C),f=a=>t<i.length?c[a].values[t]:v[a][t-i.length],g=s.order==="desc"?-1:1;h.sort((a,y)=>{const l=f(a),p=f(y),b=l==null||typeof l=="number"&&isNaN(l),E=p==null||typeof p=="number"&&isNaN(p);return b||E?b===E?a-y:b?1:-1:(l<p?-1:l>p?1:0)*g||a-y})}typeof s.limit=="number"&&(h=h.slice(0,Math.floor(s.limit))),c=h.map(t=>c[t]);const M=h.map(t=>v[t]),$={};return i.forEach((t,f)=>{const g=c.map(a=>a.values[f]);$[t.as]=g.every(a=>a===null||typeof a=="number")?Float64Array.from(g.map(a=>a===null?NaN:a)):g}),r.forEach((t,f)=>{$[t.as]=Float64Array.from(M.map(g=>g[f]))}),{length:c.length,columns:$}}};N.define(F)})(globalThis.BC);
47
+
48
+
49
+ "use strict";(function(M){const C=()=>M.get("lib.ticks").exports,O=(o,t)=>C().niceStep(o,t);function p(o){const t=o.as;if(t===void 0)return["bin0","bin1","count"];if(Array.isArray(t)&&t.length===3&&t.every(i=>typeof i=="string"&&i)&&new Set(t).size===3)return[t[0],t[1],t[2]];throw new Error('transform.bin: "as" must be three different column names, e.g. ["bin0", "bin1", "count"]')}const P={role:"transform",type:"bin",version:7,requires:["lib.ticks"],replacesColumns:!0,params:{field:{kind:"field",reads:"number",required:!0},bins:{kind:"number",default:10},width:{kind:"number"},log:{kind:"boolean",default:!1},extent:{kind:"list"},group:{kind:"field"},as:{kind:"list"}},outputs(o){const[t,i,a]=p(o);return typeof o.group=="string"?[t,i,a,o.group]:[t,i,a]},labels(o){const[t,i,a]=p(o);return{[t]:"From",[i]:"To",[a]:"Count"}},apply(o,t){const i=t.field,a=Object.prototype.hasOwnProperty.call(o.columns,i)?o.columns[i]:void 0;if(!a)throw new Error(`transform.bin: unknown field "${i}" in "field"`);const u=typeof t.group=="string"?t.group:void 0,l=u?o.columns[u]:void 0;if(u&&!l)throw new Error(`transform.bin: unknown field "${u}" in "group"`);const[k,F,x]=p(t),w=t.log===!0,g=n=>w?n>0?Math.log10(n):NaN:n,T=n=>w?Math.pow(10,n):n;let c=1/0,h=-1/0,N=!1,E=!1;for(let n=0;n<o.length;n++){const e=a[n];if(typeof e!="number"){e!=null&&(E=!0);continue}const r=g(e);isFinite(r)&&(N=!0,r<c&&(c=r),r>h&&(h=r))}if(Array.isArray(t.extent)){const[n,e]=t.extent.map(Number);if(!isFinite(n)||!isFinite(e)||n>=e)throw new Error('transform.bin: "extent" must be [min, max] with min < max');if(w&&n<=0)throw new Error('transform.bin: with "log" the "extent" must be positive');c=g(n),h=g(e)}else if(!N){if(E)throw new Error(`transform.bin: field "${i}" has no numeric values`);if(w&&Array.prototype.some.call(a,n=>typeof n=="number"&&isFinite(n)))throw new Error(`transform.bin: field "${i}" has no positive values, and "log" needs them`);return{length:0,columns:{[k]:new Float64Array(0),[F]:new Float64Array(0),[x]:new Float64Array(0),...u?{[u]:[]}:{}}}}c===h&&(c-=.5,h+=.5);let s;if(t.width!==void 0){if(s=Number(t.width),!isFinite(s)||s<=0)throw new Error('transform.bin: "width" must be a positive number')}else{const n=t.bins===void 0?10:Number(t.bins);if(!isFinite(n)||n<1)throw new Error('transform.bin: "bins" must be a number of at least 1');s=O(h-c,n)}const v=Array.isArray(t.extent),d=v?c:Math.floor(c/s+1e-9)*s,m=Math.max(1,Math.ceil((h-d)/s-1e-9));if(m>5e3)throw new Error(`transform.bin: ${m} bins is too many (at most 5000); use a larger width`);const j=v?h:d+m*s,f=[],A=new Map;if(l)for(let n=0;n<o.length;n++)A.has(l[n])||(A.set(l[n],f.length),f.push(l[n]));else f.push(void 0);const I=new Float64Array(m*f.length);for(let n=0;n<o.length;n++){const e=a[n];if(typeof e!="number")continue;const r=g(e);if(!isFinite(r)||r<d||r>j+1e-9*s)continue;let y=Math.floor((r-d)/s+1e-9);y>=m&&(y=m-1),!(y<0)&&I[y*f.length+(l?A.get(l[n]):0)]++}const b=m*f.length,S=new Float64Array(b),$=new Float64Array(b),B=new Float64Array(b),X=new Array(l?b:0),z=Math.floor(Math.log10(s)),_=n=>{const e=d+n*s,r=Math.floor(Math.log10(Math.max(Math.abs(e),s)))-z+4;return+T(e).toPrecision(Math.min(17,Math.max(12,r)))};for(let n=0;n<m;n++)for(let e=0;e<f.length;e++){const r=n*f.length+e;S[r]=_(n),$[r]=_(n+1),B[r]=I[r],l&&(X[r]=f[e])}const q={[k]:S,[F]:$,[x]:B};return u&&(q[u]=X),{length:b,columns:q}}};M.define(P)})(globalThis.BC);
50
+
51
+
52
+ "use strict";(function(y){const a=["+","-","*","/"];function t(e){throw new Error("transform.calculate: "+e)}function d(e){return(typeof e.as!="string"||!e.as)&&t('"as" must name the new column'),e.as}const m=e=>typeof e=="number"&&isFinite(e)?e:NaN,g={role:"transform",type:"calculate",version:3,params:{a:{kind:"field",reads:"number",required:!0},op:{kind:"enum",values:a,required:!0},b:{kind:"field",reads:"number"},value:{kind:"number"},as:{kind:"string",required:!0}},outputs:e=>[d(e)],apply(e,n){const o=d(n),f=i=>typeof i=="string"&&Object.prototype.hasOwnProperty.call(e.columns,i);(typeof n.a!="string"||!n.a)&&t('"a" must be the name of a numeric field'),f(n.a)||t(`unknown field "${n.a}" in "a"`),(typeof n.op!="string"||a.indexOf(n.op)<0)&&t(`"op" must be one of: ${a.join(" ")}`),n.b===void 0==(n.value===void 0)&&t('give either "b" (a field) or "value" (a number), not both or neither'),n.b!==void 0&&!f(n.b)&&t(`unknown field "${n.b}" in "b"`),n.value!==void 0&&!(typeof n.value=="number"&&isFinite(n.value))&&t('"value" must be a finite number'),f(o)&&o!==n.a&&o!==n.b&&t(`"${o}" is already a column: name the new one differently`);const c=e.columns[n.a],s=n.b!==void 0?e.columns[n.b]:void 0,v=n.value,l=n.op,b=new Float64Array(e.length);for(let i=0;i<e.length;i++){const u=m(c[i]),r=s?m(s[i]):v,h=l==="+"?u+r:l==="-"?u-r:l==="*"?u*r:u/r;b[i]=isFinite(h)?h:NaN}return{length:e.length,columns:{...e.columns,[o]:b}}}};y.define(g)})(globalThis.BC);
53
+
54
+
55
+ "use strict";(function(w){function f(t){throw new Error("transform.calendar: "+t)}function u(t){const e=Array.isArray(t.as)?t.as:[],o=(s,l)=>typeof e[s]=="string"?e[s]:l;return{week:o(0,"week"),weekEnd:o(1,"weekEnd"),day:o(2,"day")}}const y=t=>new Date(t).toISOString().slice(0,10),m={role:"transform",type:"calendar",version:3,params:{field:{kind:"field",reads:"date",required:!0},weekStart:{kind:"enum",values:["monday","sunday"],default:"monday"},as:{kind:"list"}},outputs(t){const e=u(t);return[e.week,e.weekEnd,e.day]},apply(t,e){const o=u(e),s=n=>Object.prototype.hasOwnProperty.call(t.columns,n);(typeof e.field!="string"||!s(e.field))&&f(`unknown field "${String(e.field)}" in "field"`),e.weekStart!==void 0&&e.weekStart!=="monday"&&e.weekStart!=="sunday"&&f('"weekStart" must be "monday" or "sunday"');for(const n of[o.week,o.weekEnd,o.day])s(n)&&f(`"${n}" is already a column of the data: give the new one another name with "as"`);new Set([o.week,o.weekEnd,o.day]).size<3&&f('"as" must name three different columns');const l=e.weekStart==="sunday"?0:1,c=t.columns[e.field],k=w.formatter({weekday:"short"},"date"),r=[];for(let n=0;n<t.length;n++){const a=w.time(c[n]);if(typeof a!="number"||!isFinite(a))continue;const d=Math.floor(a/864e5)*864e5,h=((d/864e5+4-l)%7+7)%7;r.push({row:n,day:d,into:h})}if(r.length)for(let n=0;n<7;n++)r.some(a=>a.into===n)||r.push({row:-1,day:(n+l+3)*864e5,into:n});r.sort((n,a)=>n.into-a.into||n.day-a.day||n.row-a.row);const i={};for(const n of Object.keys(t.columns)){const a=t.columns[n];i[n]=r.map(d=>d.row<0?null:a[d.row])}return i[o.week]=r.map(n=>n.row<0?null:y(n.day-n.into*864e5)),i[o.weekEnd]=r.map(n=>n.row<0?null:y(n.day+(7-n.into)*864e5)),i[o.day]=r.map(n=>k(n.day)),{length:r.length,columns:i}}};w.define(m)})(globalThis.BC);
56
+
57
+
58
+ "use strict";(function(V){const J=(a,e,u,d)=>V.get("lib.columns").exports.check("transform.contour",a,e,u,d);function L(a){throw new Error("transform.contour: "+a)}const K=a=>V.get("lib.stats").exports.spread(a);function $(a){const e=Float64Array.from(a).sort(),u=K(e);return u>0?u*Math.pow(e.length,-1/6):Math.abs(e[0])*.05||1}function N(a){const e=Math.max(1,Math.ceil(4*a)),u=new Float64Array(2*e+1);let d=0;for(let n=-e;n<=e;n++)d+=u[n+e]=Math.exp(-(n*n)/(2*a*a));for(let n=0;n<u.length;n++)u[n]/=d;return u}function P(a,e,u,d,n){const b=new Float64Array(a.length),k=(d.length-1)/2;for(let y=0;y<u;y++)for(let o=0;o<e;o++){let l=0;for(let s=Math.max(-k,-o);s<=Math.min(k,e-1-o);s++)l+=a[y*e+o+s]*d[s+k];b[y*e+o]=l}const w=new Float64Array(a.length),g=(n.length-1)/2;for(let y=0;y<u;y++)for(let o=0;o<e;o++){let l=0;for(let s=Math.max(-g,-y);s<=Math.min(g,u-1-y);s++)l+=b[(y+s)*e+o]*n[s+g];w[y*e+o]=l}return w}function Q(a,e,u,d){const n=(o,l)=>o<0||l<0||o>=e||l>=u?0:a[l*e+o],b=e+2,k=(o,l)=>(l+1)*b+(o+1),w=o=>{const l=o>>1,s=l%b-1,f=Math.floor(l/b)-1,M=o&1,m=n(s,f),E=M?n(s,f+1):n(s+1,f),h=E===m?.5:(d-m)/(E-m);return M?[s,f+h]:[s+h,f]},g=new Map;for(let o=-1;o<u;o++)for(let l=-1;l<e;l++){const s=[n(l,o),n(l+1,o),n(l+1,o+1),n(l,o+1)],f=s.map(h=>h>=d);if(f[0]===f[1]&&f[1]===f[2]&&f[2]===f[3])continue;const M=[2*k(l,o),2*k(l+1,o)+1,2*k(l,o+1),2*k(l,o)+1],m=[];for(let h=0;h<4;h++)f[h]!==f[(h+1)%4]&&m.push({edge:M[h],out:f[h]});const E=m.length===4&&(s[0]+s[1]+s[2]+s[3])/4<d?3:1;m.forEach((h,v)=>{h.out&&g.set(h.edge,m[(v+E)%m.length].edge)})}const y=[];for(const o of g.keys()){if(!g.has(o))continue;const l=[];let s=o;for(;g.has(s);){l.push(w(s));const f=g.get(s);g.delete(s),s=f}l.length>2&&y.push(l)}return y}const U={role:"transform",type:"contour",version:2,requires:["lib.columns","lib.stats"],replacesColumns:!0,params:{x:{kind:"field",reads:"number",required:!0},y:{kind:"field",reads:"number",required:!0},shares:{kind:"list"},levels:{kind:"number",default:6},bandwidth:{kind:"list"},extent:{kind:"list"},grid:{kind:"number",default:80}},outputs(a){const e=["level","share","density","ring"];for(const u of[a.x,a.y])typeof u=="string"&&e.push(u);return e},apply(a,e){const u=e.x,d=e.y;J(a,[["x",u],["y",d]],[["x",u],["y",d],["level","level"],["share","share"],["density","density"],["ring","ring"]],Object.keys(a.columns));const n=e.grid===void 0?80:e.grid;typeof n=="number"&&Math.floor(n)===n&&n>=8&&n<=400||L('"grid" must be a whole number from 8 to 400');const b=e.levels===void 0?6:e.levels;typeof b=="number"&&Math.floor(b)===b&&b>=1&&b<=50||L('"levels" must be a whole number from 1 to 50');let k;if(e.shares!==void 0){const t=e.shares;(!Array.isArray(t)||!t.length||t.length>50||!t.every(r=>typeof r=="number"&&r>0&&r<1))&&L('"shares" must be a list of up to 50 numbers above 0 and below 1, like [0.25, 0.5, 0.75]'),k=t.slice()}let w=[null,null];if(e.bandwidth!==void 0){const t=e.bandwidth;(!Array.isArray(t)||t.length!==2||!t.every(r=>r===null||typeof r=="number"&&r>0&&isFinite(r)))&&L('"bandwidth" must be [along x, along y]: two positive numbers, or null to keep one to the rule'),w=t}let g=[[null,null],[null,null]];if(e.extent!==void 0){const t=e.extent,r=i=>i===null||Array.isArray(i)&&i.length===2&&i.every(c=>c===null||typeof c=="number"&&isFinite(c))&&!(typeof i[0]=="number"&&typeof i[1]=="number"&&i[0]>=i[1]);(!Array.isArray(t)||t.length!==2||!t.every(r))&&L('"extent" must be [[x low, x high], [y low, y high]], each end a number or null, the low below the high, like [[0, null], [0, null]]'),g=t.map(i=>i||[null,null])}const y=t=>typeof t=="number"?t:t instanceof Date?t.getTime():NaN,o=a.columns[u],l=a.columns[d],s=[],f=[];for(let t=0;t<a.length;t++){const r=y(o[t]),i=y(l[t]);isFinite(r)&&isFinite(i)&&(s.push(r),f.push(i))}const M={level:[],share:[],density:[],ring:[],[u]:[],[d]:[]},m=s.length;if(!m)return{length:0,columns:M};const E=s.map((t,r)=>r).sort((t,r)=>s[t]-s[r]||f[t]-f[r]),h=Float64Array.from(E,t=>s[t]),v=Float64Array.from(E,t=>f[t]),X=w[0]??$(h),j=w[1]??$(v);let D=1/0,G=-1/0,R=1/0,q=-1/0;for(let t=0;t<m;t++)D=Math.min(D,h[t]),G=Math.max(G,h[t]),R=Math.min(R,v[t]),q=Math.max(q,v[t]);const I=g[0][0]??D-3*X,F=g[1][0]??R-3*j,C=g[0][1]??G+3*X,W=g[1][1]??q+3*j;C>I&&W>F||L('"extent" leaves no room for the points');const _=(C-I)/(n-1),S=(W-F)/(n-1),z=(t,r)=>{const i=(t-I)/_,c=(r-F)/S;if(!(i>=0&&c>=0&&i<=n-1&&c<=n-1))return null;const x=Math.min(n-2,Math.floor(i)),A=Math.min(n-2,Math.floor(c));return{i:x,j:A,u:i-x,v:c-A}};let p=new Float64Array(n*n);for(let t=0;t<m;t++){const r=z(h[t],v[t]);if(!r)continue;const{i,j:c,u:x,v:A}=r;p[c*n+i]+=(1-x)*(1-A),p[c*n+i+1]+=x*(1-A),p[(c+1)*n+i]+=(1-x)*A,p[(c+1)*n+i+1]+=x*A}p=P(p,n,n,N(X/_),N(j/S));const Y=1/(m*_*S);for(let t=0;t<p.length;t++)p[t]*=Y;const O=new Float64Array(m);for(let t=0;t<m;t++){const r=z(h[t],v[t]);if(!r)continue;const{i,j:c,u:x,v:A}=r;O[t]=p[c*n+i]*(1-x)*(1-A)+p[c*n+i+1]*x*(1-A)+p[(c+1)*n+i]*(1-x)*A+p[(c+1)*n+i+1]*x*A}const Z=Array.from(O).sort((t,r)=>r-t);let T=0;for(let t=0;t<p.length;t++)T=Math.max(T,p[t]);const B=k?k.map(t=>Z[Math.max(0,Math.ceil(t*m)-1)]):Array.from({length:b},(t,r)=>T*(r+1)/(b+1)),tt=Array.from(new Set(B.filter(t=>t>0))).sort((t,r)=>t-r);let H=0;return tt.forEach((t,r)=>{let i=0;for(let c=0;c<m;c++)O[c]>=t&&i++;for(const c of Q(p,n,n,t)){for(const[x,A]of c)M.level.push(r+1),M.share.push(i/m),M.density.push(t),M.ring.push(H),M[u].push(I+Math.min(n-1,Math.max(0,x))*_),M[d].push(F+Math.min(n-1,Math.max(0,A))*S);H++}}),{length:M.level.length,columns:M}}};V.define(U)})(globalThis.BC);
59
+
60
+
61
+ "use strict";(function(j){const B=new WeakMap,C=new WeakMap;function q(n,e,o){const i=B.get(n);if(i&&i.length&&(e||i[0].rows.length===o))return i;const s=new Map;if(e)for(let r=0;r<o;r++){const f=s.get(e[r]);f?f.push(r):s.set(e[r],[r])}else{const r=new Int32Array(o);for(let a=0;a<o;a++)r[a]=a;const f=[{key:void 0,rows:r}];return B.set(n,f),f}const m=[];return s.forEach((r,f)=>m.push({key:f,rows:Int32Array.from(r)})),B.set(n,m),m}function D(n,e,o){const i=C.get(n);if(i&&i.scale===o)return i.dir;const s=n.length;if(e instanceof Float64Array&&o.invert&&s>=2){let u=!0,c=!0;for(let d=1;d<s&&(u||c);d++){const g=e[n[d]],w=e[n[d-1]];g!==g||w!==w?(u=!1,c=!1):(g<w&&(u=!1),g>w&&(c=!1))}const b=o(e[n[0]]),l=o(e[n[s-1]]);let $=0;if(isFinite(b)&&isFinite(l)&&b!==l){const d=l>b?1:-1;$=u?d:c?-d:0}return C.set(n,{scale:o,dir:$}),$}let m=!0,r=!0,f=0;for(let u=0;u<s&&(m||r);u++){const c=o(e[n[u]]);if(typeof c!="number"||c!==c){m=!1,r=!1;break}u>0&&(c<f&&(m=!1),c>f&&(r=!1)),f=c}const a=s<2?0:m?1:r?-1:0;return C.set(n,{scale:o,dir:a}),a}const F=(n,e)=>{let o=0,i=n;for(;o<i;){const s=o+i>>1;e(s)?i=s:o=s+1}return o},Y={role:"transform",type:"decimate",version:4,viewDependent:!0,params:{x:{kind:"field",required:!0},y:{kind:"field",required:!0},scale:{kind:"scale",default:"x"},group:{kind:"field"},buckets:{kind:"number"},threshold:{kind:"number",default:4}},outputs:()=>[],apply(n,e,o){const i=p=>Object.prototype.hasOwnProperty.call(n.columns,p)?n.columns[p]:void 0,s=e.x,m=e.y,r=i(s),f=i(m);if(!r)throw new Error(`transform.decimate: unknown field "${s}" in "x"`);if(!f)throw new Error(`transform.decimate: unknown field "${m}" in "y"`);const a=typeof e.group=="string"?e.group:void 0,u=a?i(a):void 0;if(a&&!u)throw new Error(`transform.decimate: unknown field "${a}" in "group"`);if(!o)return n;const c=typeof e.scale=="string"?e.scale:"x",b=o.scales[c];if(!b)throw new Error(`transform.decimate: there is no scale named "${c}"`);const l=b.range();if(typeof l[0]!="number"||typeof l[1]!="number")return n;if(e.buckets!==void 0&&!(typeof e.buckets=="number"&&e.buckets>=1&&e.buckets<=2e4))throw new Error('transform.decimate: "buckets" must be a number from 1 to 20000');const $=typeof e.threshold=="number"&&e.threshold>0?e.threshold:4,d=Math.min(l[0],l[1])-12,g=Math.max(l[0],l[1])+12,w=Math.max(1,Math.floor(typeof e.buckets=="number"?e.buckets:Math.abs(l[1]-l[0]))),J=(g-d)/w,x=[];let S=!1;for(const p of q(u||r,u,n.length)){const k=p.rows,h=k.length,M=D(k,r,b);if(!M){for(let t=0;t<h;t++)x.push(k[t]);if(h>$*w){const t=p.key===void 0?"the rows":`series ${JSON.stringify(p.key)}`;o.warn(`${t} are not sorted by "${s}" (or have a missing "${s}"), so decimate left ${h} rows as they are; sort the data by "${s}" first`)}continue}const E=t=>b(r[k[t]]),P=M===1?F(h,t=>E(t)>=d):F(h,t=>E(t)<=g),z=M===1?F(h,t=>E(t)>g):F(h,t=>E(t)<d),v=Math.max(0,P-1),I=Math.min(h,z+1);if((v>0||I<h)&&(S=!0),I-v<=$*w){for(let t=v;t<I;t++)x.push(k[t]);continue}S=!0;let N=-1,_=0,T=0,U=0,G=0,K=0,R=0;const W=()=>{if(N<0)return;const t=[_,U,G,T].sort((A,H)=>A-H);let y=-1;for(const A of t)A!==y&&x.push(k[A]),y=A;N=-1};for(let t=v;t<I;t++){const y=f[k[t]];if(typeof y!="number"||y!==y){W(),x.push(k[t]);continue}const A=Math.max(0,Math.min(w-1,Math.floor((E(t)-d)/J)));if(A!==N){W(),N=A,_=T=U=G=t,K=R=y;continue}T=t,y<K&&(K=y,U=t),y>R&&(R=y,G=t)}W()}if(!S)return n;const O=x.length,X={};for(const p of Object.keys(n.columns)){const k=n.columns[p],h=k instanceof Float64Array?new Float64Array(O):new Array(O);for(let M=0;M<O;M++)h[M]=k[x[M]];X[p]=h}return{length:O,columns:X}}};j.define(Y)})(globalThis.BC);
62
+
63
+
64
+ "use strict";(function(x){const X=Math.sqrt(2*Math.PI);function s(e){throw new Error("transform.density: "+e)}function A(e){const t=e.as;return t===void 0?["value","density"]:Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"&&t[0]&&t[1]&&t[0]!==t[1]?[t[0],t[1]]:s('"as" must be two different column names: [value, density]')}const _=e=>x.get("lib.stats").exports.spread(e);function D(e){const t=_(e);return t>0?.9*t*Math.pow(e.length,-.2):Math.abs(e[0])*.05||1}const N={role:"transform",type:"density",version:4,requires:["lib.stats"],replacesColumns:!0,params:{field:{kind:"field",reads:"number",required:!0},group:{kind:"field"},bandwidth:{kind:"number"},steps:{kind:"number",default:80},extent:{kind:"list"},counts:{kind:"boolean",default:!1},as:{kind:"list"}},outputs(e){const[t,c]=A(e);return typeof e.group=="string"?[e.group,t,c,"count"]:[t,c,"count"]},apply(e,t){(typeof t.field!="string"||!t.field)&&s('"field" must be the name of a numeric field');const c=Object.prototype.hasOwnProperty.call(e.columns,t.field)?e.columns[t.field]:void 0;c||s(`unknown field "${t.field}" in "field"`);const u=typeof t.group=="string"?t.group:void 0,g=u&&Object.prototype.hasOwnProperty.call(e.columns,u)?e.columns[u]:void 0;u&&!g&&s(`unknown field "${u}" in "group"`);const[P,v]=A(t);for(const[n,o]of[[P,"as[0]"],[v,"as[1]"]])n==="count"&&s(`"count" is the column of the number of samples: give "${o}" another name`),n===u&&s(`"${n}" is the group: give "${o}" another name`);const f=t.steps===void 0?80:t.steps;typeof f=="number"&&Math.floor(f)===f&&f>=2&&f<=1e3||s('"steps" must be a whole number from 2 to 1000');const a=t.bandwidth;a!==void 0&&!(typeof a=="number"&&isFinite(a)&&a>0)&&s('"bandwidth" must be a positive number');let b=-1/0,w=1/0;if(t.extent!==void 0){const n=t.extent,o=i=>i===null||typeof i=="number"&&isFinite(i);(!Array.isArray(n)||n.length!==2||!o(n[0])||!o(n[1]))&&s('"extent" must be [low, high]: two numbers, or null for an end the data decides'),typeof n[0]=="number"&&(b=n[0]),typeof n[1]=="number"&&(w=n[1]),b<w||s('"extent" must run from low to high')}const T=new Map,h=[],k=[];for(let n=0;n<e.length;n++){const o=g?g[n]:void 0,i=o==null||typeof o=="number"&&isNaN(o)?null:o;let r=T.get(i);r===void 0&&(r=h.length,T.set(i,r),h.push(o),k.push([]));const l=c[n];typeof l=="number"&&isFinite(l)&&k[r].push(l)}const E=[],S=[],F=[],O=[];for(let n=0;n<h.length;n++){const o=k[n].sort((m,d)=>m-d),i=o.length;if(!i)continue;const r=typeof a=="number"?a:D(o),l=Math.max(b,o[0]-3*r),I=Math.min(w,o[i-1]+3*r);if(!(I>l))continue;const V=(t.counts===!0?i:1)/(i*r*X);let p=0,y=0;const j=6*r;for(let m=0;m<f;m++){const d=l+(I-l)*m/(f-1);for(;p<i&&o[p]<d-j;)p++;for(;y<i&&o[y]<=d+j;)y++;let q=0;for(let M=p;M<y;M++){const C=(d-o[M])/r;q+=Math.exp(-.5*C*C)}E.push(h[n]),S.push(d),F.push(q*V),O.push(i)}}const $={[P]:Float64Array.from(S),[v]:Float64Array.from(F),count:Float64Array.from(O)};return u&&($[u]=E),{length:S.length,columns:$}}};x.define(N)})(globalThis.BC);
65
+
66
+
67
+ "use strict";(function(p){const l=["==","!=","<","<=",">",">=","in","notIn","valid"],y=/^\d{4}-\d{2}(-\d{2})?([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\d{2})?)?$/;function r(t){throw new Error("transform.filter: "+t)}const f=t=>t==null||t===""||typeof t=="number"&&isNaN(t)||t instanceof Date&&isNaN(t.getTime());function d(t){if(f(t))return null;if(typeof t=="number")return{kind:"number",at:t};if(t instanceof Date)return{kind:"date",at:t.getTime()};if(typeof t=="string"&&y.test(t)){const e=p.time(t.length===7?t+"-01":t);if(isFinite(e))return{kind:"date",at:e}}return typeof t=="string"?{kind:"text",at:t}:null}function s(t){const e=d(t);return e?e.kind+":"+e.at:typeof t+":"+String(t)}function h(t){const e=t.op===void 0?"==":t.op;if((typeof e!="string"||l.indexOf(e)<0)&&r(`"op" must be one of: ${l.join(", ")}`),e==="valid")return t.value!==void 0&&r('"valid" keeps the rows that have a value: it takes no "value"'),i=>!f(i);if(e==="in"||e==="notIn"){Array.isArray(t.value)||r(`"${e}" needs "value": a list of values`);const i=new Set(t.value.map(s));return e==="in"?n=>!f(n)&&i.has(s(n)):n=>!f(n)&&!i.has(s(n))}const o=t.value;if(typeof o!="number"&&typeof o!="string"&&typeof o!="boolean"&&r(`"${e}" needs "value": a number, a string or a date`),typeof o=="number"&&!isFinite(o)&&r('"value" must be a finite number'),o===""&&r('"value" is empty: to keep the rows that have a value, use "op": "valid"'),e==="=="||e==="!="){const i=s(o);return e==="=="?n=>!f(n)&&s(n)===i:n=>!f(n)&&s(n)!==i}typeof o=="boolean"&&r(`"${e}" compares numbers, dates or text, not true / false`);const a=d(o),u=e==="<"?i=>i<a.at:e==="<="?i=>i<=a.at:e===">"?i=>i>a.at:i=>i>=a.at;return i=>{const n=d(i);return n!==null&&n.kind===a.kind&&u(n.at)}}const g={role:"transform",type:"filter",version:3,params:{field:{kind:"field",required:!0},op:{kind:"enum",values:l,default:"=="},value:{kind:"any"}},outputs:()=>[],apply(t,e){(typeof e.field!="string"||!e.field)&&r('"field" must be the name of a field'),Object.prototype.hasOwnProperty.call(t.columns,e.field)||r(`unknown field "${e.field}" in "field"`);const o=h(e),a=t.columns[e.field],u=[];for(let n=0;n<t.length;n++)o(a[n])&&u.push(n);const i={};for(const n of Object.keys(t.columns)){const m=t.columns[n];i[n]=ArrayBuffer.isView(m)?Float64Array.from(u,c=>m[c]):u.map(c=>m[c])}return{length:u.length,columns:i}}};p.define(g)})(globalThis.BC);
68
+
69
+
70
+ "use strict";(function(A){function r(e){throw new Error("transform.fold: "+e)}const y=e=>ArrayBuffer.isView(e);function d(e){for(const s of["key","value"])e[s]!==void 0&&(typeof e[s]!="string"||!e[s])&&r(`"${s}" must be a column name`);const t=e.key||"key",o=e.value||"value";return t===o&&r(`"key" and "value" are both "${t}": give them different names`),{key:t,value:o}}const O={role:"transform",type:"fold",version:3,params:{fields:{kind:"fields",required:!0},key:{kind:"string",default:"key"},value:{kind:"string",default:"value"}},outputs:e=>{const{key:t,value:o}=d(e);return[t,o]},apply(e,t){const o=t.fields;(!Array.isArray(o)||!o.length)&&r('"fields" must be a list of the columns to fold');const{key:s,value:m}=d(t),k={};for(const n of o)(typeof n!="string"||!n)&&r('"fields" must be a list of column names'),Object.prototype.hasOwnProperty.call(e.columns,n)||r(`unknown field "${n}" in "fields"`),k[n]&&r(`"${n}" is listed twice in "fields"`),k[n]=!0;for(const n of[s,m])Object.prototype.hasOwnProperty.call(e.columns,n)&&r(`"${n}" is already a column: name the new one differently`);const a=o.length,l=e.length*a,h=o.map(n=>e.columns[n]),v=h.every(y)?new Float64Array(l):new Array(l),w=new Array(l);for(let n=0,i=0;n<e.length;n++)for(let f=0;f<a;f++,i++)w[i]=o[f],v[i]=h[f][n];const u={};for(const n of Object.keys(e.columns)){const i=e.columns[n],f=y(i)?new Float64Array(l):new Array(l);for(let c=0,g=0;c<e.length;c++){const j=i[c];for(let p=0;p<a;p++,g++)f[g]=j}u[n]=f}return u[s]=w,u[m]=v,{length:l,columns:u}}};A.define(O)})(globalThis.BC);
71
+
72
+
73
+ "use strict";(function(d){const p=(t,e,n,l)=>d.get("lib.columns").exports.check("transform.funnel",t,e,n,l);function f(t){const e=String(t.field),n=Array.isArray(t.as)?t.as:[];return{from:typeof n[0]=="string"?n[0]:e+"0",to:typeof n[1]=="string"?n[1]:e+"1",rate:typeof t.rateAs=="string"?t.rateAs:"rate",step:typeof t.stepAs=="string"?t.stepAs:"stepRate"}}const A={role:"transform",type:"funnel",version:5,requires:["lib.columns"],params:{field:{kind:"field",reads:"number",required:!0},as:{kind:"list"},rateAs:{kind:"string",default:"rate"},stepAs:{kind:"string",default:"stepRate"}},outputs(t){const e=f(t);return[e.from,e.to,e.rate,e.step]},labels(t){const e=f(t);return{[e.from]:"From",[e.to]:"To",[e.rate]:"Of the first stage",[e.step]:"Of the stage before"}},apply(t,e){const n=f(e);p(t,[["field",e.field]],[["as[0]",n.from],["as[1]",n.to],["rateAs",n.rate],["stepAs",n.step]],[e.field]);const l=t.columns[String(e.field)]||[],u=new Float64Array(t.length),g=new Float64Array(t.length),m=new Float64Array(t.length),c=new Float64Array(t.length);let i=NaN,a=NaN;for(let r=0;r<t.length;r++){const s=l[r];if(typeof s!="number"||!isFinite(s)||s<0){u[r]=g[r]=m[r]=c[r]=NaN;continue}u[r]=-s/2,g[r]=s/2,isFinite(i)||(i=s),m[r]=i>0?s/i:NaN,c[r]=isFinite(a)&&a>0?s/a:NaN,a=s}const o={...t.columns};return o[n.from]=u,o[n.to]=g,o[n.rate]=m,o[n.step]=c,{length:t.length,columns:o}}};d.define(A)})(globalThis.BC);
74
+
75
+
76
+ "use strict";(function(Y){const Z=(i,c,f,o)=>Y.get("lib.columns").exports.check("transform.hexbin",i,c,f,o),v=Math.sqrt(3),nn=200,N=1.6,w=new WeakMap,B=i=>typeof i.aspect=="number"&&i.aspect>0&&isFinite(i.aspect)?i.aspect:void 0;function E(i){const c=Array.isArray(i.as)?i.as:[],f=(o,b)=>typeof c[o]=="string"?c[o]:b;return{x0:f(0,"x0"),x1:f(1,"x1"),y0:f(2,"y0"),y1:f(3,"y1"),count:typeof i.countAs=="string"?i.countAs:"count"}}const tn={role:"transform",type:"hexbin",version:3,requires:["lib.columns"],replacesColumns:!0,viewDependent:i=>B(i)===void 0,params:{x:{kind:"field",reads:"number",required:!0},y:{kind:"field",reads:"number",required:!0},bins:{kind:"number",default:20},aspect:{kind:"number"},xScale:{kind:"scale",default:"x"},yScale:{kind:"scale",default:"y"},as:{kind:"list"},countAs:{kind:"string",default:"count"}},outputs(i){const c=E(i),f=[c.x0,c.x1,c.y0,c.y1,c.count];for(const o of[i.x,i.y])typeof o=="string"&&f.push(o);return f},apply(i,c,f){const o=E(c),b=c.x,k=c.y;Z(i,[["x",b],["y",k]],[["as[0]",o.x0],["as[1]",o.x1],["as[2]",o.y0],["as[3]",o.y1],["countAs",o.count],["x",b],["y",k]],Object.keys(i.columns));const q=typeof c.bins=="number"&&c.bins>=1?Math.min(nn,Math.round(c.bins)):20,G=i.columns[b],P=i.columns[k],x=s=>typeof s=="number"?s:s instanceof Date?s.getTime():NaN;let g=1/0,I=-1/0,p=1/0,S=-1/0;for(let s=0;s<i.length;s++){const r=x(G[s]),e=x(P[s]);!isFinite(r)||!isFinite(e)||(r<g&&(g=r),r>I&&(I=r),e<p&&(p=e),e>S&&(S=e))}const sn={[o.x0]:[],[o.x1]:[],[o.y0]:[],[o.y1]:[],[o.count]:[],[b]:[],[k]:[]};if(!(I>=g))return{length:0,columns:sn};I===g&&(g-=.5,I+=.5),S===p&&(p-=.5,S+=.5);const O=I-g,T=S-p,C=(s,r=q)=>{const e=s/r,a=e/v,n=a*1.5,t=new Map;for(let u=0;u<i.length;u++){const d=x(G[u]),W=x(P[u]);if(!isFinite(d)||!isFinite(W))continue;const rn=(d-g)/O*s/e,X=(W-p)/T/n;let M=Math.round(X);const $=rn-(M&1)/2;let j=Math.round($);const U=X-M;if(Math.abs(U)*3>1){const H=$-j,J=j+($<j?-1:1)/2,K=M+(X<M?-1:1),L=$-J,V=X-K;3*H*H+2.25*U*U>3*L*L+2.25*V*V&&(j=J+(M&1?1:-1)/2,M=K)}const _=j+","+M,z=t.get(_);z?z.n++:t.set(_,{i:j,j:M,n:1})}let l=1/0,h=-1/0,m=1/0,y=-1/0;for(const u of t.values()){const d=(u.i+(u.j&1)/2)*e;l=Math.min(l,d),h=Math.max(h,d),m=Math.min(m,u.j*n),y=Math.max(y,u.j*n)}return{a:s,dx:e,r:a,dy:n,counts:t,ratio:(h-l+e)/(y-m+2*a)}},Q=(s,r=!1)=>{const e=l=>r?q*Math.sqrt(l/N):q,a=l=>Math.abs(Math.log(l.ratio/s));let n=C(s,e(s)),t=n;for(let l=0,h=s;l<8&&Math.abs(n.ratio/s-1)>1e-9;l++)h*=s/t.ratio,t=C(h,e(h)),a(t)<a(n)&&(n=t);return n},A=typeof c.xScale=="string"?c.xScale:"x",F=typeof c.yScale=="string"?c.yScale:"y",on=s=>{const r=a=>{const n=s.scales[a];if(!n)return NaN;const t=n.domain(),l=n.range();return Math.abs((x(l[1])-x(l[0]))/(x(t[t.length-1])-x(t[0])))},e=O*r(A)/(T*r(F));if(e>0&&isFinite(e))return C(e,q*Math.sqrt(e/N));s.warn(`transform.hexbin: the scales "${A}" and "${F}" cannot be followed (one is missing or has no extent), so the hexagons are binned for a plot ${N} times as wide as tall`)},D=({a:s,dx:r,r:e,dy:a,counts:n})=>{const t={[o.x0]:[],[o.x1]:[],[o.y0]:[],[o.y1]:[],[o.count]:[],[b]:[],[k]:[]},l=Array.from(n.values()).sort((y,u)=>y.j-u.j||y.i-u.i),h=r/2*O/s,m=e*T;for(const y of l){const u=g+(y.i+(y.j&1)/2)*r/s*O,d=p+y.j*a*T;t[o.x0].push(u-h),t[o.x1].push(u+h),t[o.y0].push(d-m),t[o.y1].push(d+m),t[o.count].push(y.n),t[b].push(u),t[k].push(d)}return{length:l.length,columns:t}},en=s=>{const r=Q(s,!0),e=D(r),a=e.columns,n=[1/0,-1/0,1/0,-1/0];for(let t=0;t<e.length;t++)n[0]=Math.min(n[0],a[o.x0][t]),n[1]=Math.max(n[1],a[o.x1][t]),n[2]=Math.min(n[2],a[o.y0][t]),n[3]=Math.max(n[3],a[o.y1][t]);if(r.ratio>s){const t=(n[3]-n[2])*(r.ratio/s-1)/2;n[2]-=t,n[3]+=t}else{const t=(n[1]-n[0])*(s/r.ratio-1)/2;n[0]-=t,n[1]+=t}return{table:e,room:n}},R=B(c);if(R===void 0&&f){const s=a=>{const n=f.scales[a],t=n?n.range():[];return Math.abs(x(t[1])-x(t[0]))},r=s(A)/s(F);if(r>0&&isFinite(r)){let a=w.get(c);(!a||a.table!==i||a.aspect!==r)&&w.set(c,a={table:i,aspect:r,out:en(r)});const{room:n}=a.out;if(f.fitting)return f.reach&&(f.reach(A,[n[0],n[1]]),f.reach(F,[n[2],n[3]])),a.out.table;const t=(l,h,m)=>{const y=f.scales[l].domain(),u=Math.abs(m-h)*1e-9;return Math.abs(x(y[0])-h)<=u&&Math.abs(x(y[y.length-1])-m)<=u};if(t(A,n[0],n[1])&&t(F,n[2],n[3]))return a.out.table}const e=on(f);if(e)return D(e)}return D(Q(R??N))}};Y.define(tn)})(globalThis.BC);
77
+
78
+
79
+ "use strict";(function(y){const l=["max","min","first","last"];function o(n){throw new Error("transform.highlight: "+n)}const u=n=>typeof n.as=="string"&&n.as?n.as:"highlight",h=(n,i)=>typeof n=="string"&&n?n:i,w={role:"transform",type:"highlight",version:2,params:{field:{kind:"field",required:!0},pick:{kind:"enum",values:l},value:{kind:"any"},as:{kind:"string",default:"highlight"},yes:{kind:"string",default:"yes"},no:{kind:"string",default:"no"}},outputs:n=>[u(n)],apply(n,i){const s=u(i),g=t=>typeof t=="string"&&Object.prototype.hasOwnProperty.call(n.columns,t);(typeof i.field!="string"||!i.field)&&o('"field" must be the name of a field'),g(i.field)||o(`unknown field "${i.field}" in "field"`),i.pick===void 0==(i.value===void 0)&&o('give either "pick" or "value", not both or neither'),i.pick!==void 0&&l.indexOf(i.pick)<0&&o(`"pick" must be one of: ${l.join(" ")}`),g(s)&&o(`"${s}" is already a column: name the new one with "as"`);const f=n.columns[i.field],m=t=>typeof f[t]=="number"&&isFinite(f[t]);let r;if(i.pick===void 0)r=t=>f[t]===i.value;else{let t=NaN,a=-1,k=-1;for(let e=0;e<n.length;e++){if(!m(e))continue;const d=f[e];a<0&&(a=e),k=e,(t!==t||(i.pick==="max"?d>t:d<t))&&(t=d)}r=i.pick==="first"?e=>e===a:i.pick==="last"?e=>e===k:e=>m(e)&&f[e]===t}const v=h(i.yes,"yes"),p=h(i.no,"no"),c=new Array(n.length);for(let t=0;t<n.length;t++)c[t]=r(t)?v:p;return{length:n.length,columns:{...n.columns,[s]:c}}}};y.define(w)})(globalThis.BC);
80
+
81
+
82
+ "use strict";(function(b){function m(n){throw new Error("transform.marimekko: "+n)}function w(n){const e=Array.isArray(n.as)?n.as:[],r=(f,u)=>typeof e[f]=="string"?e[f]:u;return{x0:r(0,"x0"),x1:r(1,"x1"),y0:r(2,"y0"),y1:r(3,"y1"),share:typeof n.shareAs=="string"?n.shareAs:"share",label:typeof n.labelAs=="string"?n.labelAs:"label"}}const M={role:"transform",type:"marimekko",version:3,params:{field:{kind:"field",reads:"number",required:!0},category:{kind:"field",required:!0},gap:{kind:"number",default:.003},as:{kind:"list"},shareAs:{kind:"string",default:"share"},labelAs:{kind:"string",default:"label"}},outputs(n){const e=w(n);return[e.x0,e.x1,e.y0,e.y1,e.share,e.label]},apply(n,e){const r=w(e),f=t=>Object.prototype.hasOwnProperty.call(n.columns,t);for(const t of["field","category"]){const o=e[t];(typeof o!="string"||!f(o))&&m(`unknown field "${String(o)}" in "${t}"`)}const u=[r.x0,r.x1,r.y0,r.y1,r.share,r.label];new Set(u).size<u.length&&m("the new columns must have different names");for(const t of u)f(t)&&m(`"${t}" is already a column of the data: give the new one another name`);const h=n.columns[e.field],S=n.columns[e.category],y=new Map;let p=0;for(let t=0;t<n.length;t++){const o=h[t],s=S[t];if(typeof o!="number"||!isFinite(o)||o<=0||s===null||s===void 0||s==="")continue;y.has(s)||y.set(s,{rows:[],sum:0});const c=y.get(s);c.rows.push(t),c.sum+=o,p+=o}const A=new Float64Array(n.length).fill(NaN),x=new Float64Array(n.length).fill(NaN),k=new Float64Array(n.length).fill(NaN),N=new Float64Array(n.length).fill(NaN),F=new Float64Array(n.length).fill(NaN),v=new Array(n.length).fill(null),$=(typeof e.gap=="number"&&e.gap>=0?Math.min(.05,e.gap):.003)/2;let d=0;y.forEach((t,o)=>{const s=t.sum/p,c=Math.min($,s/4);let g=1;for(const a of t.rows){const i=h[a]/t.sum;A[a]=d+c,x[a]=d+s-c,N[a]=g,k[a]=g-i,F[a]=i,g-=i}v[t.rows.reduce((a,i)=>h[i]>h[a]?i:a)]=String(o),d+=s});const l={...n.columns};return l[r.x0]=A,l[r.x1]=x,l[r.y0]=k,l[r.y1]=N,l[r.share]=F,l[r.label]=v,{length:n.length,columns:l}}};b.define(M)})(globalThis.BC);
83
+
84
+
85
+ "use strict";(function(x){function y(e,s){const f=e.length;if(f===1)return e[0];const c=s*(f-1),t=Math.floor(c),h=Math.ceil(c);return t===h?e[t]:e[t]+(e[h]-e[t])*(c-t)}const N=["low","q1","median","q3","high","value","count"],H={role:"transform",type:"quartiles",version:5,replacesColumns:!0,params:{field:{kind:"field",reads:"number",required:!0},group:{kind:"field"},outliers:{kind:"boolean",default:!0}},outputs(e){const s=typeof e.group=="string"?e.group:void 0;return s?[s,...N]:N.slice()},labels:()=>({low:"Low",q1:"Q1",median:"Median",q3:"Q3",high:"High",value:"Outlier",count:"Samples"}),apply(e,s){const f=s.field,c=e.columns[f];if(!c)throw new Error(`transform.quartiles: unknown field "${f}" in "field"`);const t=typeof s.group=="string"?s.group:void 0,h=t?e.columns[t]:void 0;if(t&&!h)throw new Error(`transform.quartiles: unknown field "${t}" in "group"`);const S=s.outliers!==!1,d=[],A=new Map,w=[];let v=!1,k=!1;for(let n=0;n<e.length;n++){const o=h?h[n]:void 0;let r=A.get(o);r===void 0&&(r=d.length,A.set(o,r),d.push(o),w.push([]));const u=c[n];typeof u=="number"&&isFinite(u)?(w[r].push(u),v=!0):u!=null&&(k=!0)}const T=()=>{const n={low:new Float64Array(0),q1:new Float64Array(0),median:new Float64Array(0),q3:new Float64Array(0),high:new Float64Array(0),value:new Float64Array(0),count:new Float64Array(0)};return t&&(n[t]=[]),{length:0,columns:n}};if(!v){if(k)throw new Error(`transform.quartiles: field "${f}" has no numeric values`);return T()}const b=[],F=[],C=[],M=[],I=[],O=[],Q=[],E=[],L=(n,o,r,u,g,l,i,m)=>{b.push(n),F.push(o),C.push(r),M.push(u),I.push(g),O.push(l),Q.push(i),E.push(m)};for(let n=0;n<d.length;n++){const o=w[n].slice().sort((p,q)=>p-q);if(!o.length)continue;const r=y(o,.25),u=y(o,.5),g=y(o,.75);let l=o[0],i=o[o.length-1];const m=[];if(S){const p=g-r,q=r-1.5*p,B=g+1.5*p;l=1/0,i=-1/0;for(const a of o)a<q||a>B?m.push(a):(a<l&&(l=a),a>i&&(i=a));l===1/0&&(l=r,i=g)}L(d[n],l,r,u,g,i,NaN,o.length);for(const p of m)L(d[n],NaN,NaN,NaN,NaN,NaN,p,NaN)}const $={low:Float64Array.from(F),q1:Float64Array.from(C),median:Float64Array.from(M),q3:Float64Array.from(I),high:Float64Array.from(O),value:Float64Array.from(Q),count:Float64Array.from(E)};return t&&($[t]=b),{length:F.length,columns:$,sparse:!0}}};x.define(H)})(globalThis.BC);
86
+
87
+
88
+ "use strict";(function(S){const R=(o,r,n,i)=>S.get("lib.columns").exports.check("transform.sankey",o,r,n,i),E=["x0","x1","y0","y1","thickness","waypoints"];function x(o){throw new Error("transform.sankey: "+o)}function N(o){if(o.as===void 0)return E;const r=o.as;return(!Array.isArray(r)||r.length!==5&&r.length!==6||!r.every(n=>typeof n=="string"&&n))&&x('"as" must be six column names: [x0, x1, y0, y1, thickness, waypoints] (five keep "waypoints")'),r.length===6?r:r.concat(E[5])}const G=o=>o!=null&&o!=="";function b(o){const r=new Map(o.map(e=>[e,e.ins.length])),n=o.filter(e=>!e.ins.length);let i=0;for(;i<n.length;){const e=n[i++];for(const a of e.outs){a.to.layer=Math.max(a.to.layer,e.layer+1);const h=r.get(a.to)-1;r.set(a.to,h),h||n.push(a.to)}}if(i<o.length){const e=o.filter(a=>r.get(a)>0).map(a=>`"${a.name}"`);x(`the flows go round in a loop through ${e.slice(0,6).join(", ")}; a Sankey needs them to run one way`)}const l=o.reduce((e,a)=>Math.max(e,a.layer),0);for(const e of o)e.outs.length||(e.layer=l);return l}function C(o,r){for(const n of o){if(n.to.layer-n.from.layer<2)continue;const i=e=>e.splice(e.indexOf(n),1);i(n.from.outs),i(n.to.ins),n.parts=[];let l=n.from;for(let e=n.from.layer+1;e<=n.to.layer;e++){let a=n.to;e<n.to.layer&&(a={name:"",layer:e,value:0,y:0,h:0,ins:[],outs:[]},r.push(a));const h={row:n.row,from:l,to:a,value:n.value,thick:0,top0:0,top1:0};l.outs.push(h),a.ins.push(h),n.parts.push(h),l=a}}}function P(o,r,n){let i=0,l=0;for(const e of o)i+=n.get(r(e))*e.value,l+=e.value;return l?i/l:NaN}function $(o){const r=new Map,n=l=>l.forEach((e,a)=>r.set(e,a/Math.max(1,l.length-1))),i=(l,e)=>{const a=new Map(l.map(f=>[f,e(f)])),h=new Map(l.map((f,m)=>[f,m])),y=f=>{const m=a.get(f);return isNaN(m)?r.get(f):m};l.sort((f,m)=>y(f)-y(m)||h.get(f)-h.get(m)),n(l)};o.forEach(n);for(let l=0;l<8;l++){const e=l%2===0,a=e?o.slice(1):o.slice(0,-1).reverse();for(const h of a)i(h,y=>e?P(y.ins,f=>f.from,r):P(y.outs,f=>f.to,r))}}const D={role:"transform",type:"sankey",version:3,requires:["lib.columns"],params:{source:{kind:"field",required:!0},target:{kind:"field",required:!0},value:{kind:"field",reads:"number",required:!0},nodeGap:{kind:"number",default:.03},as:{kind:"list"}},outputs:o=>N(o),apply(o,r){const n=N(r),[i,l,e]=[r.source,r.target,r.value];R(o,[["source",i],["target",l],["value",e]],n.map((t,s)=>[`as[${s}]`,t]),[]);const a=r.nodeGap===void 0?.03:r.nodeGap;typeof a=="number"&&a>=0&&a<1||x('"nodeGap" must be a share of the height, from 0 to below 1');const h=o.columns[i],y=o.columns[l],f=o.columns[e],m=new Map,q=t=>{let s=m.get(t);return s||m.set(t,s={name:t,layer:0,value:0,y:0,h:0,ins:[],outs:[]}),s},w=[];for(let t=0;t<o.length;t++){const s=f[t];if(typeof s!="number"||!isFinite(s)||s<=0||!G(h[t])||!G(y[t]))continue;const c=q(String(h[t])),u=q(String(y[t]));if(c===u)continue;const p={row:t,from:c,to:u,value:s,thick:0,top0:0,top1:0};w.push(p),c.outs.push(p),u.ins.push(p)}const v=Array.from(m.values()).filter(t=>t.ins.length||t.outs.length),M={};for(const t of n)M[t]=new Array(o.length).fill(t===n[5]?null:NaN);const O={length:o.length,columns:{...o.columns,...M}};if(!w.length)return O;const g=b(v);C(w,v);const k=Array.from({length:g+1},()=>[]);for(const t of v)t.value=Math.max(t.ins.reduce((s,c)=>s+c.value,0),t.outs.reduce((s,c)=>s+c.value,0)),k[t.layer].push(t);$(k);const _=k.reduce((t,s)=>Math.max(t,s.length),1),A=Math.min(a,.5/Math.max(1,_-1));let d=1/0;for(const t of k){const s=t.reduce((c,u)=>c+u.value,0);d=Math.min(d,(1-A*(t.length-1))/s)}for(const t of k){let c=(1-(t.reduce((u,p)=>u+p.value*d,0)+A*(t.length-1)))/2;for(const u of t)u.y=c,u.h=u.value*d,c+=u.h+A}for(const t of w)for(const s of t.parts||[t])s.thick=t.value*d;for(const t of v){let s=t.y;for(const c of t.outs.slice().sort((u,p)=>u.to.y-p.to.y||u.row-p.row))c.top0=s,s+=c.thick;s=t.y;for(const c of t.ins.slice().sort((u,p)=>u.from.y-p.from.y||u.row-p.row))c.top1=s,s+=c.thick}const[j,F,I,L,T,W]=n.map(t=>M[t]);for(const t of w){const s=t.parts||[t];j[t.row]=g?t.from.layer/g:0,F[t.row]=g?t.to.layer/g:0,I[t.row]=s[0].top0,L[t.row]=s[s.length-1].top1,T[t.row]=t.value*d,W[t.row]=s.slice(0,-1).flatMap(c=>[c.to.layer/g,c.to.y])}return O}};S.define(D)})(globalThis.BC);
89
+
90
+
91
+ "use strict";(function(h){function f(o){throw new Error("transform.sort: "+o)}const g=o=>o==null||typeof o=="number"&&isNaN(o);function p(o){if(g(o))return null;if(typeof o=="number"||typeof o=="string")return o;if(o&&typeof o.getTime=="function"){const n=o.getTime();return isFinite(n)?n:null}return String(o)}const w={role:"transform",type:"sort",version:2,params:{field:{kind:"field",required:!0},order:{kind:"enum",values:["asc","desc"],default:"asc"},limit:{kind:"number"},group:{kind:"field"}},outputs:()=>[],apply(o,n){(typeof n.field!="string"||!n.field)&&f('"field" must be the name of a field');const c=r=>Object.prototype.hasOwnProperty.call(o.columns,r);c(n.field)||f(`unknown field "${n.field}" in "field"`),n.group!==void 0&&(typeof n.group!="string"||!c(n.group))&&f(`unknown field "${n.group}" in "group"`),n.order!==void 0&&n.order!=="asc"&&n.order!=="desc"&&f('"order" must be "asc" or "desc"'),n.limit!==void 0&&!(typeof n.limit=="number"&&n.limit>=0&&Math.floor(n.limit)===n.limit)&&f('"limit" must be a whole number of rows, at least 0');const k=n.order==="desc"?-1:1,b=o.columns[n.field],s=typeof n.group=="string"?o.columns[n.group]:void 0,a=Array.from({length:o.length},(r,e)=>p(b[e])),d=new Map;for(let r=0;r<o.length;r++){const e=s?g(s[r])?null:s[r]:0,t=d.get(e);t?t.push(r):d.set(e,[r])}const l=[];d.forEach(r=>{r.sort((t,m)=>{const i=a[t],u=a[m];return i===null||u===null?i===u?t-m:i===null?1:-1:typeof i!=typeof u?typeof i=="number"?-1:1:(i<u?-1:i>u?1:0)*k||t-m});const e=typeof n.limit=="number"?r.slice(0,n.limit):r;for(const t of e)l.push(t)});const y={};for(const r of Object.keys(o.columns)){const e=o.columns[r];y[r]=ArrayBuffer.isView(e)?Float64Array.from(l,t=>e[t]):l.map(t=>e[t])}return{length:l.length,columns:y}}};h.define(w)})(globalThis.BC);
92
+
93
+
94
+ "use strict";(function(b){function g(t){const e=typeof t.field=="string"?t.field:"value",s=t.as;if(s===void 0)return[e+"0",e+"1"];if(Array.isArray(s)&&s.length===2&&typeof s[0]=="string"&&typeof s[1]=="string"&&s[0]!==s[1])return[s[0],s[1]];throw new Error('transform.stack: "as" must be two different column names, e.g. ["y0", "y1"]')}const N={role:"transform",type:"stack",version:5,viewDependent:t=>typeof t.follows=="string",params:{field:{kind:"field",reads:"number",required:!0},by:{kind:"field",required:!0},group:{kind:"field"},as:{kind:"list"},normalize:{kind:"boolean",default:!1},center:{kind:"boolean",default:!1},follows:{kind:"scale"}},outputs:t=>g(t),apply(t,e,s){const w=e.field,y=e.by,h=Object.prototype.hasOwnProperty.call(t.columns,w)?t.columns[w]:void 0,m=Object.prototype.hasOwnProperty.call(t.columns,y)?t.columns[y]:void 0;if(!h)throw new Error(`transform.stack: unknown field "${w}" in "field"`);if(!m)throw new Error(`transform.stack: unknown field "${y}" in "by"`);const i=typeof e.group=="string"&&Object.prototype.hasOwnProperty.call(t.columns,e.group)?t.columns[e.group]:void 0;if(typeof e.group=="string"&&!i)throw new Error(`transform.stack: unknown field "${e.group}" in "group"`);const[k,O]=g(e);for(const o of[k,O])if(Object.prototype.hasOwnProperty.call(t.columns,o))throw new Error(`transform.stack: "${o}" is already a column of the data: give the new one another name with "as"`);const d=t.length;if(typeof e.follows=="string"&&!i)throw new Error('transform.stack: "follows" needs "group"');const E=s&&typeof e.follows=="string"?s.scales[e.follows]:void 0,v=E?new Set(E.domain()):null,c=new Map;if(i)for(let o=0;o<d;o++)c.has(i[o])||c.set(i[o],c.size);const p=new Map;for(let o=0;o<d;o++){const f=p.get(m[o]);f?f.push(o):p.set(m[o],[o])}const l=new Float64Array(d),a=new Float64Array(d);return p.forEach(o=>{i&&o.sort((n,r)=>c.get(i[n])-c.get(i[r])||n-r);let f=0,u=0;for(const n of o){const r=h[n];typeof r!="number"||!isFinite(r)||v&&!v.has(i[n])?(l[n]=NaN,a[n]=NaN):r>=0?(l[n]=f,f+=r,a[n]=f):(l[n]=u,u+=r,a[n]=u)}if(e.normalize===!0){const n=f-u;if(n>0){for(const r of o)l[r]/=n,a[r]/=n;f/=n,u/=n}}if(e.center===!0){const n=(f+u)/2;for(const r of o)l[r]-=n,a[r]-=n}}),{length:d,columns:{...t.columns,[k]:l,[O]:a}}}};b.define(N)})(globalThis.BC);
95
+
96
+
97
+ "use strict";(function(v){function z(n){throw new Error("transform.treemap: "+n)}const H=(n,t,l,e)=>v.get("lib.columns").exports.check("transform.treemap",n,t,l,e),J=1.6,M=n=>typeof n.aspect=="number"&&n.aspect>0&&isFinite(n.aspect)?n.aspect:void 0,A=new WeakMap;function N(n){const t=Array.isArray(n.as)?n.as:[],l=(e,o)=>typeof t[e]=="string"?t[e]:o;return{x0:l(0,"x0"),x1:l(1,"x1"),y0:l(2,"y0"),y1:l(3,"y1"),label:typeof n.labelAs=="string"?n.labelAs:"label"}}function F(n,t){let l=0,e=0,o=1/0;for(const u of n)l+=u,u>e&&(e=u),u<o&&(o=u);const i=t*t,f=l*l;return Math.max(i*e/f,f/(i*o))}function E(n,t,l){let e=n.slice(),o={...t};for(;e.length;){const i=Math.min(o.w,o.h);if(i<=0)break;const f=[e[0]];let u=1;for(;u<e.length&&F(f.concat(e[u]).map(s=>s.v),i)<=F(f.map(s=>s.v),i);)f.push(e[u]),u++;e=e.slice(u);const x=f.reduce((s,c)=>s+c.v,0);if(o.w>=o.h){const s=e.length?x/o.h:o.w;let c=o.y;for(const d of f){const h=s>0?d.v/s:0;l.set(d.i,{x:o.x,y:c,w:s,h}),c+=h}o={x:o.x+s,y:o.y,w:o.w-s,h:o.h}}else{const s=e.length?x/o.w:o.h;let c=o.x;for(const d of f){const h=s>0?d.v/s:0;l.set(d.i,{x:c,y:o.y,w:h,h:s}),c+=h}o={x:o.x,y:o.y+s,w:o.w,h:o.h-s}}}}function S(n,t){const l=n.reduce((o,i)=>o+i.v,0),e=l>0?t.w*t.h/l:0;return n.map(o=>({i:o.i,v:o.v*e})).sort((o,i)=>i.v-o.v||o.i-i.i)}const K={role:"transform",type:"treemap",version:6,requires:["lib.columns"],viewDependent:n=>M(n)===void 0,params:{field:{kind:"field",reads:"number",required:!0},group:{kind:"field"},subgroup:{kind:"field"},name:{kind:"field"},aspect:{kind:"number"},padding:{kind:"number",default:.004},labelMin:{kind:"number",default:0},as:{kind:"list"},labelAs:{kind:"string",default:"label"}},outputs(n){const t=N(n);return[t.x0,t.x1,t.y0,t.y1,t.label]},apply(n,t,l){const e=N(t);H(n,[["field",t.field],["group",t.group],["subgroup",t.subgroup],["name",t.name]],[["as[0]",e.x0],["as[1]",e.x1],["as[2]",e.y0],["as[3]",e.y1],["labelAs",e.label]],[t.name]);const o=n.columns[String(t.field)]||[],i=typeof t.group=="string"?n.columns[t.group]:void 0,f=typeof t.subgroup=="string"?n.columns[t.subgroup]:void 0;f&&!i&&z('"subgroup" divides the blocks of "group", so it needs "group"');const u=typeof t.name=="string"?n.columns[t.name]:void 0,x=M(t),s=l?l.plot.w/l.plot.h:NaN,c=x===void 0&&s>0&&isFinite(s),d=x??(c?s:J),h=c?A.get(t):void 0;if(h&&h.table===n&&h.aspect===d)return h.out;const L=typeof t.padding=="number"&&t.padding>=0?Math.min(.1,t.padding):.004,P=typeof t.labelMin=="number"?t.labelMin:0,q=[];let k=0;for(let a=0;a<n.length;a++){const r=o[a];typeof r=="number"&&isFinite(r)&&r>0&&(q.push({i:a,v:r}),k+=r)}const Q={x:0,y:0,w:d,h:1},G=new Map,O=(a,r,w)=>{if(!w.length)return E(S(a,r),r,G);const m=new Map;for(const g of a){const y=w[0][g.i];m.has(y)||m.set(y,[]),m.get(y).push(g)}const b=Array.from(m.values()).map((g,y)=>({i:y,v:g.reduce((R,V)=>R+V.v,0),part:g})),j=new Map;E(S(b,r),r,j),b.forEach(g=>{const y=j.get(g.i);y&&O(g.part,y,w.slice(1))})};O(q,Q,i?f?[i,f]:[i]:[]);const B=new Float64Array(n.length).fill(NaN),C=new Float64Array(n.length).fill(NaN),D=new Float64Array(n.length).fill(NaN),I=new Float64Array(n.length).fill(NaN),T=new Array(n.length).fill(null),U=L/2;G.forEach((a,r)=>{const w=Math.min(U,a.w/2),m=Math.min(U,a.h/2);B[r]=(a.x+w)/d,C[r]=(a.x+a.w-w)/d,I[r]=1-(a.y+m),D[r]=1-(a.y+a.h-m);const b=o[r];u&&k>0&&b/k>=P&&u[r]!=null&&(T[r]=String(u[r]))});const p={...n.columns};p[e.x0]=B,p[e.x1]=C,p[e.y0]=D,p[e.y1]=I,p[e.label]=T;const W={length:n.length,columns:p};return c&&A.set(t,{table:n,aspect:d,out:W}),W}};v.define(K)})(globalThis.BC);
98
+
99
+
100
+ "use strict";(function(g){const y=(t,n,r,m)=>g.get("lib.columns").exports.check("transform.waterfall",t,n,r,m);function f(t){const n=String(t.field),r=Array.isArray(t.as)?t.as:[];return{start:typeof r[0]=="string"?r[0]:n+"0",end:typeof r[1]=="string"?r[1]:n+"1",kind:typeof t.kindAs=="string"?t.kindAs:"step",amount:typeof t.amountAs=="string"?t.amountAs:"amount",top:typeof t.topAs=="string"?t.topAs:"top"}}const c=t=>t===!0||t===1||t==="true"||t==="yes"||t==="total",h={role:"transform",type:"waterfall",version:5,requires:["lib.columns"],params:{field:{kind:"field",reads:"number",required:!0},total:{kind:"field"},start:{kind:"number",default:0},as:{kind:"list"},kindAs:{kind:"string",default:"step"},amountAs:{kind:"string",default:"amount"},topAs:{kind:"string",default:"top"}},outputs(t){const n=f(t);return[n.start,n.end,n.kind,n.amount,n.top]},labels(t){const n=f(t);return{[n.start]:"From",[n.end]:"Running total",[n.kind]:"Step",[n.amount]:"Amount",[n.top]:"Top"}},apply(t,n){const r=f(n);y(t,[["field",n.field],["total",n.total]],[["as[0]",r.start],["as[1]",r.end],["kindAs",r.kind],["amountAs",r.amount],["topAs",r.top]],[n.field]);const m=t.columns[String(n.field)]||[],A=typeof n.total=="string"?t.columns[n.total]:void 0,i=new Float64Array(t.length),e=new Float64Array(t.length),u=new Array(t.length),d=new Float64Array(t.length);let a=typeof n.start=="number"&&isFinite(n.start)?n.start:0;for(let o=0;o<t.length;o++){if(A&&c(A[o])){i[o]=0,e[o]=a,u[o]="total",d[o]=a;continue}const l=m[o];if(typeof l!="number"||!isFinite(l)){i[o]=NaN,e[o]=NaN,u[o]=null,d[o]=NaN;continue}i[o]=a,a+=l,e[o]=a,u[o]=l<0?"decrease":"increase",d[o]=l}const s={...t.columns};s[r.start]=i,s[r.end]=e,s[r.kind]=u,s[r.amount]=d;const k=new Float64Array(t.length);for(let o=0;o<t.length;o++)k[o]=Math.max(i[o],e[o]);return s[r.top]=k,{length:t.length,columns:s}}};g.define(h)})(globalThis.BC);
101
+
102
+
103
+ "use strict";(function(M){const F=["cumsum","sum","mean","min","max","diff","pctChange","total","share","rank"],C=["sum","mean","min","max"];function u(n){throw new Error("transform.window: "+n)}function $(n){return(typeof n.op!="string"||F.indexOf(n.op)<0)&&u(`"op" must be one of: ${F.join(", ")}`),n.op}function x(n){return(typeof n.field!="string"||!n.field)&&u('"field" must be the name of a numeric field'),n.as!==void 0&&(typeof n.as!="string"||!n.as)&&u('"as" must be a column name'),typeof n.as=="string"?n.as:`${$(n)}_${n.field}`}const P=n=>typeof n=="number"&&isFinite(n),j=n=>n==null||typeof n=="number"&&isNaN(n);function q(n){if(j(n))return null;if(typeof n=="number"||typeof n=="string")return n;if(n&&typeof n.getTime=="function"){const e=n.getTime();return isFinite(e)?e:null}return String(n)}function A(n,e,l,z){const N=n.length,m=new Array(N);let c=0,p=0;const a=[];let w=0,h=0,b=0;const O=e==="min"?(f,g)=>f<=g:(f,g)=>f>=g;for(let f=0;f<N;f++){const g=l(f),y=z(f);for(;h<=y;h++){const r=n[h];if(isFinite(r)){for(c+=r,p++;a.length>w&&O(r,n[a[a.length-1]]);)a.pop();a.push(h)}}for(;b<g;b++){const r=n[b];isFinite(r)&&(c-=r,p--,a.length>w&&a[w]===b&&w++)}p?e==="sum"?m[f]=c:e==="mean"?m[f]=c/p:m[f]=n[a[w]]:m[f]=NaN}return m}const E={role:"transform",type:"window",version:5,params:{field:{kind:"field",reads:"number",required:!0},op:{kind:"enum",values:F,required:!0},order:{kind:"enum",values:["desc","asc"],default:"desc"},size:{kind:"number"},align:{kind:"enum",values:["trailing","center"],default:"trailing"},partial:{kind:"boolean",default:!1},sort:{kind:"field"},group:{kind:"field"},as:{kind:"string"}},outputs:n=>[x(n)],apply(n,e){const l=$(e),z=x(e),N=Object.prototype.hasOwnProperty.call(n.columns,e.field)?n.columns[e.field]:void 0;N||u(`unknown field "${e.field}" in "field"`);const m=typeof e.sort=="string"&&Object.prototype.hasOwnProperty.call(n.columns,e.sort)?n.columns[e.sort]:void 0;e.sort!==void 0&&!m&&u(`unknown field "${e.sort}" in "sort"`);const c=typeof e.group=="string"&&Object.prototype.hasOwnProperty.call(n.columns,e.group)?n.columns[e.group]:void 0;e.group!==void 0&&!c&&u(`unknown field "${e.group}" in "group"`),Object.prototype.hasOwnProperty.call(n.columns,z)&&u(`"${z}" is already a column of the data: give the new one another name with "as"`);const p=C.indexOf(l)>=0;p?typeof e.size=="number"&&e.size>=1&&Math.floor(e.size)===e.size||u(`"${l}" needs "size": a whole number of rows, at least 1`):e.size!==void 0&&u(`"size" applies to sum, mean, min and max, not to "${l}"`),e.align!==void 0&&e.align!=="trailing"&&e.align!=="center"&&u('"align" must be "trailing" or "center"'),e.order!==void 0&&(l!=="rank"&&u(`"order" applies to rank, not to "${l}"`),e.order!=="asc"&&e.order!=="desc"&&u('"order" must be "desc" (1 = the largest) or "asc" (1 = the smallest)'));const a=p?e.size:1,w=e.partial===!0,h=e.align==="center"?Math.floor(a/2):a-1,b=a-1-h,O=n.length,f=new Float64Array(O).fill(NaN),g=new Map,y=m?new Array(O):null;for(let r=0;r<O;r++){if(y&&(y[r]=q(m[r]),y[r]===null))continue;const s=c?j(c[r])?null:c[r]:0,d=g.get(s);d?d.push(r):g.set(s,[r])}return g.forEach(r=>{y&&r.sort((i,o)=>{const t=y[i],k=y[o];return typeof t!=typeof k?typeof t=="number"?-1:1:t<k?-1:t>k?1:i-o});const s=r.map(i=>P(N[i])?N[i]:NaN),d=r.length;if(l==="rank"){const i=[];for(let t=0;t<d;t++)isFinite(s[t])&&i.push(t);const o=e.order==="asc"?1:-1;i.sort((t,k)=>o*(s[t]-s[k])||t-k);for(let t=0;t<i.length;t++){const k=t>0&&s[i[t]]===s[i[t-1]];f[r[i[t]]]=k?f[r[i[t-1]]]:t+1}}else if(l==="total"||l==="share"){let i=0,o=!1;for(let t=0;t<d;t++)isFinite(s[t])&&(i+=s[t],o=!0);for(let t=0;t<d;t++)l==="total"?f[r[t]]=o?i:NaN:isFinite(s[t])&&i!==0&&(f[r[t]]=s[t]/i)}else if(l==="cumsum"){let i=0;for(let o=0;o<d;o++)isFinite(s[o])&&(i+=s[o],f[r[o]]=i)}else if(l==="diff"||l==="pctChange")for(let i=1;i<d;i++){const o=s[i-1],t=s[i]-o;f[r[i]]=l==="diff"?t:o?t/Math.abs(o):NaN}else{const i=A(s,l,o=>Math.max(0,o-h),o=>Math.min(d-1,o+b));for(let o=0;o<d;o++)isFinite(s[o])&&(!w&&(o-h<0||o+b>d-1)||(f[r[o]]=i[o]))}}),{length:O,columns:{...n.columns,[z]:f}}}};M.define(E)})(globalThis.BC);
104
+
105
+
106
+ "use strict";(function(A){const $=Math.PI*2,N="var(--bc-text, #444)",_="var(--bc-kpi, var(--bc-text, #111))",D="var(--bc-grid, #edf0f4)",S=26,U=.03,M=t=>Math.round(t*100)/100,P=(t,e,l)=>Math.max(e,Math.min(l,t)),R=Math.PI/180,x=t=>typeof t=="number"&&isFinite(t)?t:void 0;function q(t){const e=x(t.startAngle)!==void 0?t.startAngle:0,l=x(t.endAngle)!==void 0?t.endAngle:e+360;if(!(l>e)||l-e>360)throw new Error(`mark.arc: endAngle ${l} has to be after startAngle ${e} and at most 360 degrees on (-90 to 90 is a half circle)`);return[e*R-Math.PI/2,l*R-Math.PI/2]}function G(t,e,l){const o=[],s=[],a=(r,n)=>{o.push(r*Math.cos(n)),s.push(r*Math.sin(n))};a(1,t),a(1,e),a(l,t),a(l,e);for(let r=Math.ceil(t/(Math.PI/2));r*(Math.PI/2)<=e;r++)a(1,r*(Math.PI/2));return{x0:Math.min(...o),x1:Math.max(...o),y0:Math.min(...s),y1:Math.max(...s)}}function I(t,e){const l=e.channel(t,"value").raw,o=t.color!==void 0?e.channel(t,"color").mapped:null,{from:s,to:a}=e.rows(t),r=[];let n=0;for(let d=s;d<a;d++){const f=l[d];typeof f!="number"||!isFinite(f)||f<=0||o&&!o[d]||(r.push(d),n+=f)}if(!r.length&&!((x(t.total)||0)>0))return null;t.sort==="desc"?r.sort((d,f)=>l[f]-l[d]||d-f):t.sort==="asc"&&r.sort((d,f)=>l[d]-l[f]||d-f);const h=t.label==="percent"||t.label==="value",{x:u,y:c,w:i,h:y}=e.plot,m=typeof t.innerRadius=="number"?P(t.innerRadius,0,.95):0,[g,v]=q(t),b=G(g,v,m),L=h?S:4,w=Math.max(1,Math.min((i-2*L)/(b.x1-b.x0),(y-2*L)/(b.y1-b.y0))),k=x(t.total);if(t.total!==void 0&&!(k!==void 0&&k>0))throw new Error(`mark.arc: total has to be a positive number (the maximum of a gauge), not ${JSON.stringify(t.total)}`);const T=k!==void 0?k:n,K=v-g;let p=g;const O=[];for(const d of r){if(p>=v)break;const f=l[d],Z=f/T,z={row:d,a0:p,a1:Math.min(v,p+Z*K),frac:Z,value:f};p=z.a1,O.push(z)}return{cx:u+i/2-w*(b.x0+b.x1)/2,cy:c+y/2-w*(b.y0+b.y1)/2,R:w,r0:w*m,slices:O,start:g,end:v,sum:n,whole:T}}function E(t,e,l){const{cx:o,cy:s,R:a,r0:r}=t,n=(c,i)=>`${M(o+c*Math.cos(i))} ${M(s+c*Math.sin(i))}`;if(l-e>=$-1e-6){let c=`M${n(a,e)}A${a} ${a} 0 1 1 ${n(a,e+Math.PI)}A${a} ${a} 0 1 1 ${n(a,e)}Z`;return r>0&&(c+=`M${n(r,e)}A${r} ${r} 0 1 0 ${n(r,e+Math.PI)}A${r} ${r} 0 1 0 ${n(r,e)}Z`),c}const h=l-e>Math.PI?1:0,u=`M${n(a,e)}A${a} ${a} 0 ${h} 1 ${n(a,l)}`;return r>0?`${u}L${n(r,l)}A${r} ${r} 0 ${h} 0 ${n(r,e)}Z`:`${u}L${M(o)} ${M(s)}Z`}function F(t,e,l,o,s){return t.color!==void 0?e.channel(t,"color").mapped[o]||"":typeof t.fill=="string"?t.fill:e.color(l+s)}const J={role:"mark",type:"arc",version:7,enter:"pop",params:{innerRadius:{kind:"number",default:0},startAngle:{kind:"number",default:0},endAngle:{kind:"number"},total:{kind:"number"},center:{kind:"enum",values:["none","value","percent"],default:"none"},padAngle:{kind:"number",default:1},sort:{kind:"enum",values:["none","desc","asc"],default:"none"},label:{kind:"enum",values:["none","percent","value"],default:"none"},labelFormat:{kind:"format"},fill:{kind:"color"},opacity:{kind:"number",default:1}},channels:{value:{required:!0,unscaled:!0},color:{accepts:{output:"color"}}},render(t,e,l){const o=I(t,e);if(!o)return[];const s=(typeof t.padAngle=="number"?Math.max(0,t.padAngle):1)*Math.PI/180,a=typeof t.opacity=="number"?t.opacity:void 0,r=[];if(x(t.total)!==void 0&&r.push({type:"path",d:E(o,o.start,o.end),style:{fill:D},cls:"bc-arc-track"}),o.slices.forEach((n,h)=>{const u=F(t,e,l,n.row,h),c=o.slices.length>1?Math.min(s,(n.a1-n.a0)*.5):0;if(r.push({type:"path",d:E(o,n.a0+c/2,n.a1-c/2),style:{fill:u,opacity:a},ref:{mark:l,row:n.row}}),(t.label==="percent"||t.label==="value")&&n.frac>=U){const i=(n.a0+n.a1)/2,y=o.cx+(o.R+10)*Math.cos(i),m=o.cy+(o.R+10)*Math.sin(i),g=t.labelFormat!==void 0?A.formatter(t.labelFormat)(t.label==="percent"?n.frac:n.value):t.label==="percent"?`${Math.round(n.frac*100)}%`:String(Number.isInteger(n.value)?n.value:+n.value.toPrecision(6));r.push({type:"text",x:M(y),y:M(m),text:g,size:11,anchor:Math.cos(i)>.2?"start":Math.cos(i)<-.2?"end":"middle",baseline:"middle",style:{fill:N}})}}),t.center==="value"||t.center==="percent"){const n=t.center==="percent"?o.sum/o.whole:o.sum,h=t.labelFormat!==void 0?A.formatter(t.labelFormat)(n):t.center==="percent"?`${Math.round(n*100)}%`:A.formatter("compact")(n),u=o.r0>0?o.r0:o.R*.6;let c=P(u*.45,10,44);const i=e.measure(h,c).w;i>u*1.6&&(c=Math.max(10,c*u*1.6/i));const m=Math.PI/2+Math.ceil((o.start-Math.PI/2)/$)*$<=o.end;r.push({type:"text",x:M(o.cx),y:M(m?o.cy:o.cy-4),text:h,size:M(c),weight:650,anchor:"middle",baseline:m?"middle":"auto",style:{fill:_},cls:"bc-arc-center"})}return r},pick(t,e,l,o,s){const a=I(t,e);if(!a)return null;const r=o-a.cx,n=s-a.cy,h=Math.hypot(r,n);if(h>a.R||h<a.r0)return null;let u=Math.atan2(n,r)-a.start;u=(u%$+$)%$;const c=a.start+u;for(const i of a.slices)if(c>=i.a0&&c<i.a1){const y=(i.a0+i.a1)/2,m=(a.R+a.r0)/2;return{row:i.row,x:a.cx+m*Math.cos(y),y:a.cy+m*Math.sin(y),dist:0}}return null},color(t,e,l,o){const s=I(t,e),a=s?s.slices.findIndex(r=>r.row===o):-1;return a<0?"":F(t,e,l,o,a)}};A.define(J)})(globalThis.BC);
107
+
108
+
109
+ "use strict";(function(B){const v=t=>Math.round(t*100)/100,O=(t,e,l,o)=>B.get("lib.curve").exports.through(t,e,l,o);function C(t,e){const l=t(e);return isFinite(l)?l:t(Math.min(...t.domain()))}const W=new WeakMap,A=new WeakMap;function N(t,e){const l=e.channel(t,"y"),o=e.channel(t,"y2"),a=typeof t.baseline=="number"?t.baseline:0,n=o.raw.length?NaN:t.toBottom===!0?e.plot.y+e.plot.h:l.scale?C(l.scale,a):NaN,r=e.channel(t,"x");let u=r.half?W.get(r):r.mapped;return u||W.set(r,u=Array.from(r.mapped,p=>p+r.half)),{xs:u,top:l.mapped,bottom:p=>o.raw.length?o.mapped[p]:n}}function L(t,e,l,o,a){return typeof t.fill=="string"?t.fill:t.color!==void 0?e.channel(t,"color").mapped[o[0]]||"":e.color(l+a)}const E={role:"mark",type:"area",version:16,requires:["lib.curve"],series:!0,enter:"wipe",narrow:!0,params:{baseline:{kind:"number",default:0},group:{kind:"field"},fill:{kind:"color"},opacity:{kind:"number",default:.85},toBottom:{kind:"boolean",default:!1},fade:{kind:"boolean",default:!1},curve:{kind:"enum",values:["linear","smooth","step"],default:"linear"}},channels:{x:{required:!0,accepts:{output:"position"}},y:{required:!0,accepts:{output:"position",input:["number","date"]}},y2:{accepts:{output:"position",input:["number","date"]},sharesScale:"y"},color:{accepts:{output:"color",input:["category"]}}},render(t,e,l){const{xs:o,top:a,bottom:n}=N(t,e),r=t.fade===!0,u=typeof t.opacity=="number"?t.opacity:r?.45:.85,p=t.curve==="smooth"||t.curve==="step"?t.curve:"linear",w=[];return e.series(t,o).forEach(({rows:y},s)=>{const d=L(t,e,l,y,s);if(!d)return;let m="",i=[];const f=()=>{if(i.length){const c=i.map(b=>o[b]),M=i.map(b=>a[b]),g=i.map(b=>n(b)),k=i.length-1;m+="M"+v(c[0])+" "+v(M[0])+O(c,M,p,!1),m+="L"+v(c[k])+" "+v(g[k])+O(c,g,p,!0),m+="Z"}i=[]};for(const c of y)isFinite(o[c])&&isFinite(a[c])&&isFinite(n(c))?i.push(c):f();f(),m&&w.push({type:"path",d:m,style:r?{fill:d,fillOpacity:u,fade:!0}:{fill:d,fillOpacity:u,stroke:d,strokeWidth:1,strokeLinejoin:"round"}})}),w},pick(t,e,l,o,a){const{xs:n,top:r,bottom:u}=N(t,e),p=t.color!==void 0?e.channel(t,"color"):null;let w=null;for(const{rows:y}of e.series(t,n)){if(p&&!p.mapped[y[0]])continue;let s=A.get(y);if(s||A.set(y,s=y.filter(h=>isFinite(n[h])&&isFinite(r[h])&&isFinite(u(h)))),!s.length||o<n[s[0]]||o>n[s[s.length-1]])continue;let d=0,m=s.length-1;for(;d<m;){const h=d+m+1>>1;n[s[h]]<=o?d=h:m=h-1}const i=s[d],f=s[Math.min(d+1,s.length-1)],c=n[f]-n[i],M=c>0?Math.min(1,Math.max(0,(o-n[i])/c)):0,g=o<n[f]?i:f,k=t.curve==="step",b=k?r[g]:r[i]+(r[f]-r[i])*M,T=k?u(g):u(i)+(u(f)-u(i))*M;if(a<Math.min(b,T)-1||a>Math.max(b,T)+1)continue;const j=h=>n[h]>=e.plot.x-.5&&n[h]<=e.plot.x+e.plot.w+.5,q=k?g:Math.abs(o-n[i])<=Math.abs(o-n[f])?i:f,F=j(q)?q:q===i?f:i;j(F)&&(w={row:F,x:n[F],y:r[F],dist:0})}return w},color(t,e,l,o){const a=e.series(t,N(t,e).xs);for(let n=0;n<a.length;n++)if(a[n].rows.includes(o))return L(t,e,l,a[n].rows,n);return""}};B.define(E)})(globalThis.BC);
110
+
111
+
112
+ "use strict";(function(T){function L(t,n,c){const i=t.color!==void 0?n.channel(t,"color").mapped:null,m=typeof t.fill=="string"&&t.fill||n.color(c);return r=>i?i[r]||"":m}const v="var(--bc-text, #333)",B={role:"mark",type:"boxplot",version:5,params:{width:{kind:"number",default:.6},fill:{kind:"color"},fillOpacity:{kind:"number",default:.85},strokeWidth:{kind:"number",default:1.5},opacity:{kind:"number",default:1}},channels:{x:{required:!0,accepts:{output:"position"}},low:{required:!0,accepts:{output:"position",input:["number","date"]},sharesScale:"y"},q1:{required:!0,accepts:{output:"position",input:["number","date"]},sharesScale:"y"},median:{required:!0,accepts:{output:"position",input:["number","date"]},sharesScale:"y"},q3:{required:!0,accepts:{output:"position",input:["number","date"]},sharesScale:"y"},high:{required:!0,accepts:{output:"position",input:["number","date"]},sharesScale:"y"},color:{accepts:{output:"color"}}},render(t,n,c){const i=n.channel(t,"x"),m=n.channel(t,"low"),r=n.channel(t,"q1"),W=n.channel(t,"median"),O=n.channel(t,"q3"),S=n.channel(t,"high"),H=L(t,n,c),b=i.scale&&i.scale.bandwidth!==void 0?i.scale.bandwidth:0,a=typeof t.width=="number"&&t.width>0?t.width:.6,s=b?a<=1?b*a:Math.min(a,b):a>1?a:16,$=b/2,Q=typeof t.fillOpacity=="number"?t.fillOpacity:.85,M=typeof t.strokeWidth=="number"?t.strokeWidth:1.5,F=typeof t.opacity=="number"?t.opacity:void 0,{from:y,to:e}=n.rows(t),l=[];for(let o=y;o<e;o++){const u=m.mapped[o],d=r.mapped[o],w=W.mapped[o],h=O.mapped[o],p=S.mapped[o];if(!isFinite(u)||!isFinite(d)||!isFinite(w)||!isFinite(h)||!isFinite(p))continue;const x=i.mapped[o];if(!isFinite(x))continue;const k=H(o);if(!k)continue;const q=x+$,f=q-s/2,g=q+s/2,C=Math.min(d,h),Y=Math.abs(d-h);l.push({type:"path",ref:{mark:c,row:o},d:`M${q} ${u}L${q} ${p}M${f} ${u}L${g} ${u}M${f} ${p}L${g} ${p}`,style:{stroke:k,strokeWidth:M,opacity:F}}),l.push({type:"rect",x:f,y:C,w:s,h:Y,style:{fill:k,fillOpacity:Q,stroke:k,strokeWidth:M,opacity:F},ref:{mark:c,row:o}}),l.push({type:"path",d:`M${f} ${w}L${g} ${w}`,style:{stroke:v,strokeWidth:M+.5,opacity:F}})}return l},pick(t,n,c,i,m){const r=n.channel(t,"x"),W=n.channel(t,"low"),O=n.channel(t,"q1"),S=n.channel(t,"q3"),H=n.channel(t,"high"),b=L(t,n,c),a=r.scale&&r.scale.bandwidth!==void 0?r.scale.bandwidth:0,s=typeof t.width=="number"&&t.width>0?t.width:.6,$=a?s<=1?a*s:Math.min(s,a):s>1?s:16,Q=a/2,{from:M,to:F}=n.rows(t),y=4;for(let e=F-1;e>=M;e--){if(!b(e))continue;const l=W.mapped[e],o=O.mapped[e],u=S.mapped[e],d=H.mapped[e],w=r.mapped[e];if(!isFinite(l)||!isFinite(o)||!isFinite(u)||!isFinite(d)||!isFinite(w))continue;const h=w+Q,p=h-$/2,x=h+$/2,k=Math.min(l,d)-y,q=Math.max(l,d)+y;if(i>=p-y&&i<=x+y&&m>=k&&m<=q){const f=Math.min(o,u),g=Math.abs(o-u);return{row:e,x:h,y:f,dist:0,box:{x:p,y:f,w:$,h:g}}}}return null},color(t,n,c,i){return L(t,n,c)(i)}};T.define(B)})(globalThis.BC);
113
+
114
+
115
+ "use strict";(function(x){const w="var(--bc-good, #12a150)",y="var(--bc-bad, #e5484d)";function k(t){const e=t.slice().sort((i,o)=>i-o);let s=1/0;for(let i=1;i<e.length;i++){const o=e[i]-e[i-1];o>1e-6&&o<s&&(s=o)}return s===1/0?0:s}function m(t,e){const s=e.channel(t,"x"),i=e.channel(t,"open"),o=e.channel(t,"high"),a=e.channel(t,"low"),d=e.channel(t,"close"),c=s.scale&&s.scale.bandwidth!==void 0?s.scale.bandwidth:0,{from:n,to:u}=e.rows(t),h=[];for(let r=n;r<u;r++){const l={row:r,x:s.mapped[r]+c/2,open:i.mapped[r],high:o.mapped[r],low:a.mapped[r],close:d.mapped[r]};![i,o,a,d].every(M=>typeof M.raw[r]=="number")||![l.x,l.open,l.high,l.low,l.close].every(isFinite)||h.push({...l,up:l.close<=l.open})}const p=c||k(h.map(r=>r.x))||e.plot.w*.1,f=typeof t.width=="number"&&t.width>0?Math.min(1,t.width):.7;return{candles:h,width:Math.max(1,p*f),step:p}}function b(t,e){return e.up?typeof t.up=="string"?t.up:w:typeof t.down=="string"?t.down:y}const g={role:"mark",type:"candlestick",version:4,params:{width:{kind:"number",default:.7},up:{kind:"color",default:w},down:{kind:"color",default:y},strokeWidth:{kind:"number",default:1},opacity:{kind:"number",default:1}},channels:{x:{required:!0,accepts:{output:"position"}},open:{required:!0,accepts:{output:"position",input:["number"]},sharesScale:"y"},high:{required:!0,accepts:{output:"position",input:["number"]},sharesScale:"y"},low:{required:!0,accepts:{output:"position",input:["number"]},sharesScale:"y"},close:{required:!0,accepts:{output:"position",input:["number"]},sharesScale:"y"}},render(t,e,s){const{candles:i,width:o}=m(t,e),a=typeof t.opacity=="number"?t.opacity:void 0,d=typeof t.strokeWidth=="number"&&t.strokeWidth>0?t.strokeWidth:1,c=[];for(const n of i){const u=b(t,n);c.push({type:"path",d:`M${n.x} ${n.high}L${n.x} ${n.low}`,style:{stroke:u,strokeWidth:d,opacity:a}}),c.push({type:"rect",x:n.x-o/2,y:Math.min(n.open,n.close),w:o,h:Math.max(1,Math.abs(n.open-n.close)),style:{fill:u,opacity:a},ref:{mark:s,row:n.row}})}return c},pick(t,e,s,i){const{candles:o,width:a,step:d}=m(t,e),c=Math.max(a/2,Math.min(d/2,12));let n=null,u=1/0;for(const f of o){const r=Math.abs(f.x-i);r<=c&&r<u&&(n=f,u=r)}if(!n)return null;const h=Math.min(n.open,n.close),p=Math.max(1,Math.abs(n.open-n.close));return{row:n.row,x:n.x,y:h,dist:u,box:{x:n.x-a/2,y:h,w:a,h:p}}},color(t,e,s,i){const o=m(t,e).candles.find(a=>a.row===i);return o?b(t,o):""}};x.define(g)})(globalThis.BC);
116
+
117
+
118
+ "use strict";(function(S){const C=n=>Math.round(n*100)/100;function L(n,e){const l=e.channel(n,"x");if(!l.half)return l.mapped;let o=F.get(l);return o||F.set(l,o=Array.from(l.mapped,t=>t+l.half)),o}const F=new WeakMap,W=new WeakMap;function _(n,e,l,o,t){return typeof n.stroke=="string"?n.stroke:n.color!==void 0?e.channel(n,"color").mapped[o[0]]||"":e.color(l+t)}function I(n,e,l){const o=n.label==="name"||n.label==="value"||n.label==="both"?n.label:"none";if(o==="none")return[];const t=L(n,e),r=e.channel(n,"y"),s=r.mapped,M=n.color!==void 0?e.channel(n,"color"):null,E=typeof n.group=="string"||!!(M&&M.field),A=o==="value"||o==="both"?n.format!==void 0?S.formatter(n.format):i=>String(typeof i=="number"?+i.toPrecision(6):i):null,{x:b,y:c,w:a,h:m}=e.plot,v=i=>t[i]<=b+a+.5&&s[i]>=c-.5&&s[i]<=c+m+.5,f=[];return e.series(n,t).forEach(({key:i,rows:h},g)=>{const k=_(n,e,l,h,g);if(!k)return;let d=-1;for(const w of h)isFinite(t[w])&&isFinite(s[w])&&v(w)&&(d=w);if(d<0)return;const y=E?String(i):typeof n.name=="string"?n.name:r.field||"",p=A?A(r.raw[d]):"",u=o==="name"?y:o==="value"?p:y&&p?`${y} ${p}`:y||p;u&&f.push({x:t[d],y:s[d],text:u,color:k,owner:l})}),f}function q(n,e,l){n.sort((t,r)=>t.y-r.y);for(let t=1;t<n.length;t++)n[t].y=Math.max(n[t].y,n[t-1].y+14);const o=n.length?n[n.length-1].y-l:0;if(o>0)for(const t of n)t.y-=o;for(let t=0;t<n.length;t++)n[t].y=Math.max(n[t].y,e+t*14)}const G=(n,e,l,o)=>S.get("lib.curve").exports.through(n,e,l,o),O={role:"mark",type:"line",version:23,requires:["lib.curve"],series:!0,enter:"wipe",narrow:n=>n.label!=="name"&&n.label!=="value"&&n.label!=="both",params:{group:{kind:"field"},stroke:{kind:"color"},strokeWidth:{kind:"number",default:2},dash:{kind:"list"},opacity:{kind:"number",default:1},curve:{kind:"enum",values:["linear","smooth","step"],default:"linear"},label:{kind:"enum",values:["none","name","value","both"],default:"none"},format:{kind:"format"},name:{kind:"string"}},channels:{x:{required:!0,accepts:{output:"position"}},y:{required:!0,accepts:{output:"position",input:["number","date"]}},color:{accepts:{output:"color",input:["category"]}}},render(n,e,l){const o=L(n,e),t=e.channel(n,"y").mapped,r=n.color!==void 0?e.channel(n,"color"):null,s=typeof n.group=="string"||!!(r&&r.field),M=typeof n.strokeWidth=="number"?n.strokeWidth:2,E=Array.isArray(n.dash)?n.dash:void 0,A=typeof n.opacity=="number"?n.opacity:void 0,b=n.curve==="smooth"||n.curve==="step"?n.curve:"linear",c=[];return e.series(n,o).forEach(({key:a,rows:m},v)=>{let f="",i=[],h=[];const g=()=>{i.length&&(f+="M"+C(i[0])+" "+C(h[0])+G(i,h,b,!1)),i=[],h=[]};for(const d of m){const y=o[d],p=t[d];if(!isFinite(y)||!isFinite(p)){g();continue}i.push(y),h.push(p)}if(g(),!f)return;const k=_(n,e,l,m,v);k&&c.push({type:"path",d:f,title:s?String(a):void 0,style:{fill:"none",stroke:k,strokeWidth:M,strokeDash:E,opacity:A,strokeLinejoin:"round",strokeLinecap:"round"}})}),c},labels(n,e,l){if(!I(n,e,l).length)return[];const o=[];return e.spec.marks.forEach((t,r)=>{t.type==="line"&&o.push(...I(t,e,r))}),q(o,e.plot.y,e.plot.y+e.plot.h),o.filter(t=>t.owner===l).map(t=>({type:"text",x:t.x+8,y:t.y,text:t.text,size:11,weight:600,anchor:"start",baseline:"middle",style:{fill:t.color},cls:"bc-line-label"}))},pick(n,e,l,o,t){const r=L(n,e),s=e.channel(n,"y").mapped,M=n.color!==void 0?e.channel(n,"color"):null,E=e.alongX?1/0:14,A=c=>r[c]>=e.plot.x-.5&&r[c]<=e.plot.x+e.plot.w+.5;let b=null;for(const{rows:c}of e.series(n,r)){if(M&&!M.mapped[c[0]])continue;let a=W.get(c);if(a||W.set(c,a=c.filter(u=>isFinite(r[u])&&isFinite(s[u]))),!a.length||o<r[a[0]]-14||o>r[a[a.length-1]]+14)continue;let m=0,v=a.length-1;for(;m<v;){const u=m+v+1>>1;r[a[u]]<=o?m=u:v=u-1}const f=a[m],i=a[Math.min(m+1,a.length-1)];let h,g;if(n.curve==="step"){const u=(R,B)=>t>=Math.min(s[R],s[B])&&t<=Math.max(s[R],s[B])?Math.abs(o-r[B]):1/0,w=Math.abs(t-(o<r[i]?s[f]:s[i])),H=u(a[Math.max(0,m-1)],f),P=u(f,i);h=Math.min(w,H,P),g=P>h&&(o<r[i]||H===h)}else{const u=r[i]-r[f],w=u>0?Math.min(1,Math.max(0,(o-r[f])/u)):0;h=Math.abs(t-(s[f]+(s[i]-s[f])*w)),g=Math.abs(o-r[f])<=Math.abs(o-r[i])}if(h>E||b&&h>=b.dist)continue;A(g?f:i)||(g=!g);const k=g?f:i;if(!A(k))continue;b={row:k,x:r[k],y:s[k],dist:h};let d=g?m:Math.min(m+1,a.length-1),y=d;const p=u=>r[a[u]]===r[k]&&s[a[u]]===s[k];for(;d>0&&p(d-1);)d--;for(;y<a.length-1&&p(y+1);)y++;y>d&&(b.rows=a.slice(d,y+1))}return b},color(n,e,l,o){const t=e.series(n,L(n,e));for(let r=0;r<t.length;r++)if(t[r].rows.includes(o))return _(n,e,l,t[r].rows,r);return""}};S.define(O)})(globalThis.BC);
119
+
120
+
121
+ "use strict";(function(L){function E(t,o){if(t.size!==void 0){const r=o.channel(t,"size").mapped;return c=>r[c]}const a=typeof t.r=="number"?t.r:3;return()=>a}function W(t,o,a){const r=t.color!==void 0?o.channel(t,"color").mapped:null,c=typeof t.fill=="string"?t.fill:o.color(a);return i=>r?r[i]||"":c}function A(t,o,a){const{from:r,to:c}=o.rows(t),i=[];for(let h=r;h<c;h++)i.push(h);if(t.size!==void 0){const h=m=>{const f=a(m);return isFinite(f)?f:-1};i.sort((m,f)=>h(f)-h(m)||m-f)}return i}const T=new WeakMap;function D(t,o,a){if(t.swarm!==!0)return null;const r=o.channel(t,"x"),c=o.channel(t,"y"),i=!!(r.scale&&r.scale.bandwidth!==void 0),h=!!(c.scale&&c.scale.bandwidth!==void 0);if(i===h)throw new Error("mark.point: swarm spreads the points of a category across its band, so one of x and y needs a band scale and the other a value");const m=T.get(i?c:r);if(m)return m;const f=i?r.mapped:c.mapped,g=(i?r:c).scale.bandwidth/2,l=i?c.mapped:r.mapped,s=typeof t.swarmGap=="number"&&t.swarmGap>=0?t.swarmGap:1,p=typeof t.swarmShrink=="number"&&t.swarmShrink>=0?Math.min(t.swarmShrink,.9):.5,d=new Float64Array(l.length),u=[],b=new Map,{from:x,to:v}=o.rows(t);for(let n=x;n<v;n++){if(!isFinite(f[n])||!isFinite(l[n])||!isFinite(a(n)))continue;const w=b.get(f[n]);w?w.push(n):(b.set(f[n],[n]),u.push(b.get(f[n])))}for(const n of u)n.sort((w,k)=>l[w]-l[k]||w-k);const y=(n,w)=>{const k=s*n;for(const S of u){let B=0;for(const M of S)B=Math.max(B,a(M)*n);const C=[];let I=0,P=0;for(const M of S){const O=a(M)*n,H=Math.max(0,g-O);for(;I<C.length&&l[C[I]]<l[M]-O-B-k;)I++;const J=C.slice(I),K=X=>J.every(z=>{const Y=O+a(z)*n+k,q=l[M]-l[z],G=X-d[z];return q*q+G*G>=Y*Y-1e-6});let $=0;if(!K(0)){$=1/0;for(const X of J){const z=O+a(X)*n+k,Y=l[M]-l[X];if(Math.abs(Y)>=z)continue;const q=Math.sqrt(z*z-Y*Y);for(const G of[d[X]+q,d[X]-q])Math.abs(G)<=H&&Math.abs(G)<Math.abs($)&&K(G)&&($=G)}}if(isFinite($))d[M]=$,C.push(M);else{if(w)return!1;d[M]=H*(P++*.618034%1*2-1)}}}return!0};let e=1;if(p>0&&!y(1,!0)){let n=1-p;if(y(n,!0)){let w=1;for(let k=0;k<8;k++){const S=(n+w)/2;y(S,!0)?n=S:w=S}}e=n}y(e,!1);const F={across:i?"x":"y",shift:d,k:e};return T.set(i?c:r,F),F}const N={role:"mark",type:"point",version:16,narrow:!0,params:{r:{kind:"number",default:3},fill:{kind:"color"},opacity:{kind:"number",default:1},stroke:{kind:"string"},swarm:{kind:"boolean",default:!1},swarmGap:{kind:"number",default:1},swarmShrink:{kind:"number",default:.5}},channels:{x:{required:!0,accepts:{output:"position"}},y:{required:!0,accepts:{output:"position"}},color:{accepts:{output:"color"}},size:{accepts:{output:"size"}}},render(t,o,a){const r=o.channel(t,"x"),c=o.channel(t,"y"),i=r.half,h=c.half,m=E(t,o),f=typeof t.opacity=="number"?t.opacity:void 0,g=typeof t.stroke=="string"?t.stroke:void 0,l=W(t,o,a),s=D(t,o,m),p=f===void 0||f>=1?new Set:null,d=[];for(const u of A(t,o,m)){const b=r.mapped[u]+(s&&s.across==="x"?s.shift[u]:0),x=c.mapped[u]+(s&&s.across==="y"?s.shift[u]:0),v=m(u)*(s?s.k:1);if(!isFinite(b)||!isFinite(x)||!isFinite(v))continue;const y=l(u);if(y){if(p){const e=`${b},${x},${v},${y}`;if(p.has(e))continue;p.add(e)}d.push({type:"circle",cx:b+i,cy:x+h,r:v,style:g?{fill:y,opacity:f,stroke:g,strokeWidth:1}:{fill:y,opacity:f},ref:{mark:a,row:u}})}}return d},pick(t,o,a,r,c){const i=o.channel(t,"x"),h=o.channel(t,"y"),m=i.half,f=h.half,g=E(t,o),l=W(t,o,a),s=D(t,o,g);let p=-1,d=1/0,u=0,b=0;for(const e of A(t,o,g)){const F=i.mapped[e]+m+(s&&s.across==="x"?s.shift[e]:0),n=h.mapped[e]+f+(s&&s.across==="y"?s.shift[e]:0),w=g(e)*(s?s.k:1);if(!isFinite(F)||!isFinite(n)||!isFinite(w)||!l(e))continue;const k=Math.max(0,Math.hypot(F-r,n-c)-w);k<=d&&(d=k,p=e,u=F,b=n)}if(p<0||d>6)return null;const x=g(p),v=l(p),y=[];for(const e of A(t,o,g)){const F=i.mapped[e]+m+(s&&s.across==="x"?s.shift[e]:0),n=h.mapped[e]+f+(s&&s.across==="y"?s.shift[e]:0);F===u&&n===b&&g(e)===x&&l(e)===v&&y.push(e)}return y.length>1?{row:p,x:u,y:b,dist:d,rows:y}:{row:p,x:u,y:b,dist:d}},color(t,o,a,r){return W(t,o,a)(r)}};L.define(N)})(globalThis.BC);
122
+
123
+
124
+ "use strict";(function(b){const h=n=>Math.round(n*100)/100;function y(n,t,l){const s=t.channel(n,"x").mapped,e=t.channel(n,"y").mapped,o=n.color!==void 0?t.channel(n,"color").mapped:null,r=typeof n.group=="string"?t.table.columns[n.group]:void 0,i=typeof n.ring=="string"?t.table.columns[n.ring]:void 0,d=typeof n.fill=="string"?n.fill:t.color(l),{from:c,to:a}=t.rows(n),g=new Map;for(let u=c;u<a;u++){const k=r?r[u]:null;let f=g.get(k);f||g.set(k,f={row:u,rings:[],ringKey:{}});const p=i?i[u]:null;(p!==f.ringKey||!f.rings.length)&&(f.rings.push([]),f.ringKey=p),isFinite(s[u])&&isFinite(e[u])&&f.rings[f.rings.length-1].push([s[u],e[u]])}const m=[];return g.forEach((u,k)=>{const f=o?o[u.row]:d;if(!f)return;const p=u.rings.filter(j=>j.length>2);p.length&&m.push({row:u.row,rings:p,color:f,key:k})}),m}function w(n,t,l){let s=0;for(const e of n)for(let o=0,r=e.length-1;o<e.length;r=o++){const[i,d]=e[r],[c,a]=e[o],g=(c-i)*(l-d)-(t-i)*(a-d);d<=l?a>l&&g>0&&s++:a<=l&&g<0&&s--}return s}const W={role:"mark",type:"polygon",version:4,params:{group:{kind:"field"},ring:{kind:"field"},filled:{kind:"boolean",default:!0},fill:{kind:"color"},opacity:{kind:"number",default:1},stroke:{kind:"color"},strokeWidth:{kind:"number",default:1}},channels:{x:{required:!0,accepts:{output:"position",input:["number","date"]}},y:{required:!0,accepts:{output:"position",input:["number","date"]}},color:{accepts:{output:"color"}}},render(n,t,l){const s=n.filled!==!1,e=typeof n.opacity=="number"?n.opacity:void 0,o=typeof n.strokeWidth=="number"?n.strokeWidth:1,r=typeof n.stroke=="string"?n.stroke:void 0;return y(n,t,l).map(i=>({type:"path",d:i.rings.map(d=>"M"+d.map(([c,a])=>`${h(c)} ${h(a)}`).join("L")+"Z").join(""),style:s?{fill:i.color,fillOpacity:e,stroke:r,strokeWidth:r?o:void 0,strokeLinejoin:"round"}:{fill:"none",stroke:i.color,strokeWidth:o,strokeLinejoin:"round"},ref:{mark:l,row:i.row}}))},pick(n,t,l,s,e){const o=y(n,t,l);for(let r=o.length-1;r>=0;r--)if(w(o[r].rings,s,e)!==0)return{row:o[r].row,x:s,y:e,dist:0};return null},color(n,t,l,s){const e=typeof n.group=="string"?t.table.columns[n.group]:void 0,o=e?e[s]:null,r=y(n,t,l).find(i=>i.key===o||i.key!==i.key&&o!==o);return r?r.color:""}};b.define(W)})(globalThis.BC);
125
+
126
+
127
+ "use strict";(function(M){function x(t,n,r,e){if(n.dodge===void 0)return null;const i=t.channel(n,"dodge").raw,o=new Map;for(let c=r;c<e;c++){const d=i[c];d==null||o.has(d)||o.set(d,o.size)}if(o.size<=1)return null;const a=typeof n.dodgePadding=="number"?Math.max(0,Math.min(.9,n.dodgePadding)):.1;return{col:i,order:o,padding:a}}function k(t,n,r){const e=t.color!==void 0?n.channel(t,"color").mapped:null,i=typeof t.fill=="string"?t.fill:n.color(r);return o=>e?e[o]||"":i}function L(t,n){const r=t(n);return isFinite(r)?r:t(Math.min(...t.domain()))}const $=.8,S=.1;function v(t,n,r){const e=r==="x"?"y":"x",i=t.channel(n,r),o=t.channel(n,e);return!i.scale||!o.scale||i.scale.bandwidth!==void 0||o.scale.bandwidth!==void 0||t.channel(n,r+"2").raw.length?!1:r==="y"?i.scale.input==="date"&&o.scale.input!=="date":!!t.channel(n,"y2").raw.length||o.scale.input!=="date"||i.scale.input==="date"}function A(t){const n=t.filter(e=>isFinite(e)).sort((e,i)=>e-i);let r=1/0;for(let e=1;e<n.length;e++)n[e]>n[e-1]&&n[e]-n[e-1]<r&&(r=n[e]-n[e-1]);return{lo:n[0],hi:n[n.length-1],step:r===1/0?0:r}}function F(t,n,r){const e=[];for(let o=n;o<r;o++)isFinite(t[o])&&e.push(t[o]);e.sort((o,a)=>o-a);let i=1/0;for(let o=1;o<e.length;o++)e[o]-e[o-1]>1e-6&&e[o]-e[o-1]<i&&(i=e[o]-e[o-1]);return i===1/0?0:i}function w(t,n,r,e,i){const o=typeof n.thickness=="number"&&n.thickness>0?Math.min(1,n.thickness):1,a=t.channel(n,r),c=t.channel(n,r+"2"),d=a.scale?a.scale.bandwidth:void 0;if(v(t,n,r)){const{from:h,to:m}=t.rows(n),y=typeof n.thickness=="number"&&n.thickness>0?Math.min(1,n.thickness):$,l=Math.max(1,(F(a.mapped,h,m)||t.plot.w*S)*y);return s=>isFinite(a.mapped[s])?[a.mapped[s]-l/2,l]:null}const b=!c.raw.length&&d===void 0&&a.scale?L(a.scale,e):NaN;return h=>{const m=a.mapped[h];let y,l;if(d!==void 0)if(i){const s=i.order.get(i.col[h]);if(s===void 0)return null;const u=d/i.order.size,f=u*i.padding;y=m+s*u+f/2,l=u-f}else y=m+d*(1-o)/2,l=d*o;else c.raw.length?(y=Math.min(m,c.mapped[h]),l=Math.abs(c.mapped[h]-m)):(y=Math.min(m,b),l=Math.abs(m-b));return isFinite(y)&&isFinite(l)?[y,l]:null}}const g=t=>Math.round(t*100)/100;function z(t,n){const[r,e]=t,[i,o]=n,a=g(r+e/2),c=g(r),d=g(r+e),b=g(i+o/4),h=g(i+3*o/4);return`M${a} ${g(i)}L${d} ${b}L${d} ${h}L${a} ${g(i+o)}L${c} ${h}L${c} ${b}Z`}const N={role:"mark",type:"rect",version:17,enter:"grow",narrow:!0,params:{baseline:{kind:"number",default:0},fill:{kind:"color"},opacity:{kind:"number",default:1},radius:{kind:"number",default:0},shape:{kind:"enum",values:["rect","hexagon"],default:"rect"},thickness:{kind:"number",default:1},dodgePadding:{kind:"number",default:.1}},channels:{x:{required:!0,accepts:{output:"position"}},y:{required:!0,accepts:{output:"position"}},x2:{accepts:{output:"position",input:["number","date"]},sharesScale:"x"},y2:{accepts:{output:"position",input:["number","date"]},sharesScale:"y"},color:{accepts:{output:"color"}},dodge:{unscaled:!0}},render(t,n,r){const e=typeof t.baseline=="number"?t.baseline:0,i=typeof t.opacity=="number"?t.opacity:void 0,o=typeof t.radius=="number"&&t.radius>0?t.radius:void 0,a=t.shape==="hexagon",{from:c,to:d}=n.rows(t),b=x(n,t,c,d),h=w(n,t,"x",e,b),m=w(n,t,"y",e,b),y=k(t,n,r),l=[];for(let s=c;s<d;s++){const u=h(s),f=m(s);if(!u||!f)continue;const p=y(s);p&&(a?l.push({type:"path",d:z(u,f),style:{fill:p,opacity:i},ref:{mark:r,row:s}}):l.push({type:"rect",x:u[0],y:f[0],w:u[1],h:f[1],r:o,style:{fill:p,opacity:i},ref:{mark:r,row:s}}))}return l},reach(t,n,r){if(n!=="x"&&n!=="y")return null;const e=n==="x"?"y":"x",i=r.scale(n),o=r.scale(e),a=r.column(n);if(!i||!o||!a||!i.even||o.input==="category"||t[n+"2"]!==void 0||!(n==="y"?i.input==="date"&&o.input!=="date":t.y2!==void 0||o.input!=="date"||i.input==="date"))return null;const d=Array.from(a,s=>i.input==="date"?M.time(s):typeof s=="number"?s:NaN),{lo:b,hi:h,step:m}=A(d);if(!m)return null;const y=typeof t.thickness=="number"&&t.thickness>0?Math.min(1,t.thickness):$,l=m*y/2;return[b-l,h+l]},pick(t,n,r,e,i){const o=typeof t.baseline=="number"?t.baseline:0,{from:a,to:c}=n.rows(t),d=x(n,t,a,c),b=w(n,t,"x",o,d),h=w(n,t,"y",o,d),m=k(t,n,r),y=t.shape==="hexagon",l=2;for(let s=c-1;s>=a;s--){if(!m(s))continue;const u=b(s),f=h(s);if(!(!u||!f)){if(y){const p=Math.abs(e-(u[0]+u[1]/2))/(u[1]/2),O=Math.abs(i-(f[0]+f[1]/2))/(f[1]/2);if(p<=1&&O<=1-p/2)return{row:s,x:u[0]+u[1]/2,y:f[0]+f[1]/2,dist:0};continue}if(e>=u[0]-l&&e<=u[0]+u[1]+l&&i>=f[0]-l&&i<=f[0]+f[1]+l)return{row:s,x:u[0]+u[1]/2,y:f[0],dist:0,box:{x:u[0],y:f[0],w:u[1],h:f[1]}}}}return null},color(t,n,r,e){return k(t,n,r)(e)}};M.define(N)})(globalThis.BC);
128
+
129
+
130
+ "use strict";(function(j){const m=t=>Math.round(t*100)/100;function B(t,o){const s=i=>t[i]===void 0?null:o.channel(t,i),r=s("x"),u=s("y"),h=s("x2"),c=s("y2"),y=typeof t.thickness=="number"&&t.thickness>0?Math.min(1,t.thickness):.7,{x:e,y:n,w:d,h:a}=o.plot,f=(i,k,x,w,g,M)=>{if(!i)return[g,M];const l=i.mapped[w];if(!isFinite(l))return null;const p=i.scale?i.scale.bandwidth:void 0;if(p!==void 0){if(x)return[l+p/2,l+p/2];const b=p*(1-y)/2;return[l+b,l+p-b]}if(k){const b=k.mapped[w];return isFinite(b)?[l,b]:null}return[l,l]};return i=>{const k=f(r,h,!!c||!u,i,e,e+d),x=f(u,c,!!h||!r,i,n+a,n);return!k||!x||k[0]===k[1]&&x[0]===x[1]?null:[k[0],x[0],k[1],x[1]]}}function v(t,o){const s=t.color!==void 0?o.channel(t,"color").mapped:null,r=typeof t.stroke=="string"?t.stroke:"var(--bc-text, #444)";return u=>s?s[u]||"":r}function W(t,o){if(t.x===void 0&&t.y===void 0)return[];const s=B(t,o),r=v(t,o),u=new Map,h=[],{from:c,to:y}=o.rows(t);for(let e=c;e<y;e++){const n=s(e);if(!n)continue;const d=r(e);if(!d)continue;const a=n.map(m).join(",")+"|"+d,f=u.get(a);if(f){f.rows.push(e);continue}const i={s:n,c:d,row:e,rows:[e]};u.set(a,i),h.push(i)}return h}const C=5,F=8;function O(t,o){return["x","y","x2","y2","color"].some(s=>t[s]!==void 0&&!!o.channel(t,s).field)}function S(t,o){const[s,r,u,h]=t,c=u-s,y=h-r;let e=0,n=1;const d=[[-c,s-o.x],[c,o.x+o.w-s],[-y,r-o.y],[y,o.y+o.h-r]];for(const[a,f]of d){if(a===0){if(f<0)return null;continue}const i=f/a;if(a<0?e=Math.max(e,i):n=Math.min(n,i),e>n)return null}return[s+e*c,r+e*y,s+n*c,r+n*y]}const _={role:"mark",type:"rule",version:12,narrow:t=>typeof t.label!="string"||t.label==="",params:{stroke:{kind:"color"},strokeWidth:{kind:"number",default:2},dash:{kind:"list"},opacity:{kind:"number",default:1},thickness:{kind:"number",default:.7},label:{kind:"string"}},channels:{x:{accepts:{output:"position"}},y:{accepts:{output:"position"}},x2:{accepts:{output:"position",input:["number","date"]},sharesScale:"x"},y2:{accepts:{output:"position",input:["number","date"]},sharesScale:"y"},color:{accepts:{output:"color",input:["category"]}}},render(t,o,s){const r=typeof t.strokeWidth=="number"?t.strokeWidth:2,u=Array.isArray(t.dash)?t.dash:void 0,h=typeof t.opacity=="number"?t.opacity:void 0;return W(t,o).map(({s:c,c:y,row:e})=>({type:"path",d:`M${m(c[0])} ${m(c[1])}L${m(c[2])} ${m(c[3])}`,style:{fill:"none",stroke:y,strokeWidth:r,strokeDash:u,opacity:h,strokeLinecap:"butt"},ref:{mark:s,row:e}}))},labels(t,o){const s=typeof t.label=="string"?t.label:"";if(!s)return[];const{x:r,y:u,w:h,h:c}=o.plot,y=(n,d)=>n>=r-.5&&n<=r+h+.5&&d>=u-.5&&d<=u+c+.5,e=[];for(const{s:n,c:d}of W(t,o)){const a={fill:d,stroke:"var(--bc-tooltip-bg, #fff)",strokeWidth:3,strokeLinejoin:"round",paintOrder:"stroke"},f=Math.abs(n[2]-n[0])>=Math.abs(n[3]-n[1]),i=f?n[0]>=n[2]?0:2:n[1]<=n[3]?0:2;y(n[i],n[i+1])&&e.push(f?{type:"text",x:n[i],y:n[i+1]-5,text:s,size:11,weight:600,anchor:"end",baseline:"auto",style:a}:{type:"text",x:n[0]+5,y:n[i+1],text:s,size:11,weight:600,anchor:"start",baseline:"hanging",style:a})}return e},pick(t,o,s,r,u){if(!O(t,o))return null;const h=typeof t.strokeWidth=="number"&&t.strokeWidth>0?t.strokeWidth:2,c=o.plot,y={x:c.x-.5,y:c.y-.5,w:c.w+1,h:c.h+1};let e=null,n=1/0;for(const M of W(t,o)){const l=S(M.s,y);if(!l)continue;const p=l[2]-l[0],b=l[3]-l[1],A=p*p+b*b,$=A?Math.min(1,Math.max(0,((r-l[0])*p+(u-l[1])*b)/A)):0,z=l[0]+$*p,D=l[1]+$*b,L=Math.max(0,Math.hypot(r-z,u-D)-h/2);L<=n&&(n=L,e={line:M,s:l,x:z,y:D})}if(!e||n>C)return null;const{line:d,s:a}=e,f=Math.max(F,h+4),i=Math.min(a[0],a[2]),k=Math.min(a[1],a[3]),x={w:Math.abs(a[2]-a[0]),h:Math.abs(a[3]-a[1])},w=x.h<.5?{x:i,y:a[1]-f/2,w:x.w,h:f}:x.w<.5?{x:a[0]-f/2,y:k,w:f,h:x.h}:null,g=w?{row:d.row,x:w.x+w.w/2,y:w.y,dist:n,box:w}:{row:d.row,x:e.x,y:e.y,dist:n};return d.rows.length>1&&(g.rows=d.rows),g},color(t,o,s,r){return v(t,o)(r)}};j.define(_)})(globalThis.BC);
131
+
132
+
133
+ "use strict";(function(Y){const J="var(--bc-text, #444)",j=["x0","x1","y0","y1","thickness","waypoints"],b=n=>Math.round(n*100)/100,q=n=>n!=null&&n!=="",F=(n,e)=>typeof n.nodeWidth=="number"&&n.nodeWidth>0?Math.min(n.nodeWidth,e.plot.w/4):12;function V(n,e){const a=n.layout;if(a!==void 0&&!(Array.isArray(a)&&(a.length===5||a.length===6)&&a.every(i=>typeof i=="string"&&i)))throw new Error('mark.sankey: "layout" must be six column names: [x0, x1, y0, y1, thickness, waypoints] (five keep "waypoints")');const l=a===void 0?j:a.concat(a.length===5?[j[5]]:[]),c=l.map(i=>e.table.columns[i]),r=l.slice(0,5).find((i,t)=>!c[t]);if(r!==void 0)throw new Error(`mark.sankey: there is no column "${r}" with the layout of the flows: put a sankey transform before it`);const[m,u,h,o,d,w]=c,k=e.channel(n,"source").raw,x=e.channel(n,"target").raw,p=e.channel(n,"value").raw,{x:g,y:f,w:M,h:v}=e.plot,T=F(n,e),{from:$,to:P}=e.rows(n),B=new Map,H=[],O=i=>typeof i=="number"&&isFinite(i)?i:NaN;for(let i=$;i<P;i++){const t=p[i],[s,y,A,E,L]=[O(m[i]),O(u[i]),O(h[i]),O(o[i]),O(d[i])];if(typeof t!="number"||!(t>0)||!q(k[i])||!q(x[i])||!(isFinite(s)&&isFinite(y)&&isFinite(A)&&isFinite(E)&&L>=0))continue;const G=(_,tt)=>{let W=B.get(_);return W||(W={name:_,order:B.size,value:0,x:g+tt*(M-T),y:0,h:0,color:"",ins:[],outs:[],top:1/0,inH:0,outH:0,inV:0,outV:0},B.set(_,W)),W},I=G(String(k[i]),s),N=G(String(x[i]),y);if(I===N)continue;const S=w?w[i]:null,X=[];if(Array.isArray(S)&&S.length%2===0&&S.every(_=>typeof _=="number"&&isFinite(_)))for(let _=0;_<S.length;_+=2)X.push({x:g+S[_]*(M-T),y:f+(S[_+1]+L/2)*v});const Z={row:i,from:I,to:N,value:t,thick:L*v,y0:f+(A+L/2)*v,y1:f+(E+L/2)*v,via:X};H.push(Z),I.outs.push(Z),N.ins.push(Z),I.top=Math.min(I.top,A),N.top=Math.min(N.top,E),I.outH+=L,N.inH+=L,I.outV+=t,N.inV+=t}if(!H.length)return null;const D=Array.from(B.values());for(const i of D)i.y=f+i.top*v,i.h=Math.max(i.inH,i.outH)*v,i.value=Math.max(i.inV,i.outV),i.color=e.color(i.order);return{nodes:D,links:H}}function U(n,e){const a=[];let l=n.from.x+e,c=n.y0;for(const r of n.via)a.push({xa:l,ya:c,xb:r.x,yb:r.y}),l=r.x+e,c=r.y;return a.push({xa:l,ya:c,xb:n.to.x,yb:n.y1}),a}function z(n,e){const a=n.thick/2,l=U(n,e),c=(u,h,o,d)=>{const w=b((u+o)/2);return`C${w} ${b(h)} ${w} ${b(d)} ${b(o)} ${b(d)}`};let r=`M${b(l[0].xa)} ${b(l[0].ya-a)}`;l.forEach((u,h)=>{h&&(r+=`L${b(u.xa)} ${b(u.ya-a)}`),r+=c(u.xa,u.ya-a,u.xb,u.yb-a)});const m=l[l.length-1];r+=`L${b(m.xb)} ${b(m.yb+a)}`;for(let u=l.length-1;u>=0;u--){const h=l[u];u<l.length-1&&(r+=`L${b(h.xb)} ${b(h.yb+a)}`),r+=c(h.xb,h.yb+a,h.xa,h.ya+a)}return r+"Z"}function K(n,e,a){const l=U(n,e);for(let c=0;c<l.length;c++){const{xa:r,ya:m,xb:u,yb:h}=l[c];if(c&&a<r)return m;if(a<r||a>u)continue;const o=(r+u)/2,d=g=>{const f=1-g;return f*f*f*r+3*f*g*(f+g)*o+g*g*g*u};let w=0,k=1;for(let g=0;g<20;g++){const f=(w+k)/2;d(f)<a?w=f:k=f}const x=(w+k)/2,p=1-x;return(p*p*p+3*p*p*x)*m+(3*p*x*x+x*x*x)*h}return NaN}function C(n,e,a,l,c){const r=o=>n.measure(o,12).w,m=[[e]],u=e.split(/\s+/).filter(Boolean);let h=null;for(let o=1;o<u.length;o++){const d=[u.slice(0,o).join(" "),u.slice(o).join(" ")];(!h||Math.max(...d.map(r))<Math.max(...h.map(r)))&&(h=d)}h&&m.push(h);for(const o of m){const d=o[o.length-1],w=a===null?[o]:[o.slice(0,-1).concat(`${d} ${a}`),o.concat(a)];for(const k of w)if(k.length<=c&&k.every(x=>r(x)<=l))return k}return null}function Q(n,e,a){const l=r=>n.measure(r,12).w<=a;if(l(e))return e;const c=Array.from(e);for(let r=c.length-1;r>0;r--){const m=c.slice(0,r).join("").trimEnd()+"\u2026";if(l(m))return m}return""}const R={role:"mark",type:"sankey",version:7,params:{nodeWidth:{kind:"number",default:12},format:{kind:"format"},linkOpacity:{kind:"number",default:.35},nodeLabels:{kind:"list"},layout:{kind:"list"},labelMin:{kind:"number",default:11}},channels:{source:{required:!0,unscaled:!0},target:{required:!0,unscaled:!0},value:{required:!0,unscaled:!0}},render(n,e,a){const l=V(n,e);if(!l)return[];const c=F(n,e),r=typeof n.linkOpacity=="number"?n.linkOpacity:.35,m=typeof n.labelMin=="number"?n.labelMin:11,u=n.format!==void 0?e.format(n.format):null,h=[];for(const t of l.links.slice().sort((s,y)=>y.thick-s.thick||s.row-y.row))h.push({type:"path",d:z(t,c),style:{fill:t.from.color,opacity:r},ref:{mark:a,row:t.row}});const o=e.plot.x+e.plot.w,d=Array.from(new Set(l.nodes.map(t=>t.x))).sort((t,s)=>t-s),w=(d.length>1?d[1]-d[0]:e.plot.w)-c-12,k=t=>t.x+c>=o-.5&&l.nodes.some(s=>s.x<t.x),x=t=>u?u(t.value):null,p=t=>Math.max(1,Math.floor(t.h/15)),g=l.nodes.filter(t=>t.h>=m),f=new Map(g.map(t=>[t,w])),M=new Map,v=()=>{const t=g.every(s=>C(e,s.name,x(s),f.get(s),p(s))!==null);for(const s of g){const y=f.get(s);M.set(s,C(e,s.name,t?x(s):null,y,p(s))||[Q(e,s.name,y)].filter(Boolean))}};v();const T=d[d.length-2],$=new Map,P=t=>M.get(t).length*15,B=t=>t.y+t.h/2+($.get(t)||0),H=(t,s)=>Math.max(0,(t.h-P(t))/2)*s-($.get(t)||0),O=t=>({w:M.get(t).reduce((s,y)=>Math.max(s,e.measure(y,12).w),0),top:B(t)-P(t)/2,bottom:B(t)+P(t)/2}),D=t=>{for(const s of g.filter(y=>y.x===T&&!k(y)))for(const y of g.filter(k)){const A=O(s),E=O(y),L=Math.min(A.bottom,E.bottom)-Math.max(A.top,E.top);L>0&&A.w+E.w+6>w&&t(s,y,L)}};D((t,s,y)=>{const[A,E]=B(t)<=B(s)?[t,s]:[s,t],L=y+2,G=-H(A,-1),I=H(E,1);if(G+I<L)return;const N=Math.min(G,Math.max(L/2,L-I));$.set(A,($.get(A)||0)-N),$.set(E,($.get(E)||0)+(L-N))});let i=!1;D((t,s)=>{f.set(t,(w-6)/2),f.set(s,(w-6)/2),$.delete(t),$.delete(s),i=!0}),i&&v();for(const t of l.nodes){h.push({type:"rect",x:b(t.x),y:b(t.y),w:c,h:b(Math.max(1,t.h)),style:{fill:t.color}});const s=M.get(t);if(!s)continue;const y=k(t);s.forEach((A,E)=>h.push({type:"text",x:b(y?t.x-6:t.x+c+6),y:b(B(t)+(E-(s.length-1)/2)*15),text:A,size:12,anchor:y?"end":"start",baseline:"middle",style:{fill:J}}))}return h},pick(n,e,a,l,c){const r=V(n,e);if(!r)return null;const m=F(n,e);for(const o of r.nodes){if(l<o.x||l>o.x+m||c<o.y||c>o.y+Math.max(1,o.h))continue;const d=Array.isArray(n.nodeLabels)?n.nodeLabels:[],w=(f,M)=>typeof d[f]=="string"?d[f]:M,k=n.format!==void 0?e.format(n.format):f=>String(+f.toPrecision(6)),x=f=>f.reduce((M,v)=>M+v.value,0),p=[];return o.ins.length&&p.push([w(0,"In"),k(x(o.ins))]),o.outs.length&&p.push([w(1,"Out"),k(x(o.outs))]),{row:(o.outs[0]||o.ins[0]).row,x:o.x+m/2,y:o.y+o.h/2,dist:0,box:{x:o.x,y:o.y,w:m,h:Math.max(1,o.h)},card:{title:o.name,color:o.color,lines:p},flows:o.ins.concat(o.outs).map(f=>({d:z(f,m),fill:f.from.color}))}}let u=null,h=0;for(const o of r.links){const d=K(o,m,l);isNaN(d)||Math.abs(c-d)<=Math.max(o.thick,2)/2&&(!u||o.thick<u.thick)&&(u=o,h=d)}return u?{row:u.row,x:l,y:h,dist:0}:null},color(n,e,a,l){const c=V(n,e),r=c?c.links.find(m=>m.row===l):void 0;return r?r.from.color:""}};Y.define(R)})(globalThis.BC);
134
+
135
+
136
+ "use strict";(function(H){const sn="var(--bc-text, #444)",dn="#111",un="#fff";function fn(n){const l=cn(n),u=typeof n=="string"?/^var\(--bc-c(\d+),/.exec(n):null;return l&&u?`var(--bc-on-c${u[1]}, ${l})`:l}function cn(n){const l=typeof n=="string"?/#([0-9a-f]{6}|[0-9a-f]{3})\b/i.exec(n):null;if(!l)return null;let u=l[1];u.length===3&&(u=u[0]+u[0]+u[1]+u[1]+u[2]+u[2]);const d=D=>{const A=parseInt(u.slice(D,D+2),16)/255;return A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4)},y=.2126*d(0)+.7152*d(2)+.0722*d(4);return(y+.05)/(.0056+.05)>=1.05/(y+.05)?dn:un}function mn(n,l){return n==null?"":typeof n=="number"?isFinite(n)?l!==void 0?n.toFixed(l):Number.isInteger(n)?String(n):String(+n.toPrecision(6)):"":String(n)}const C=4,hn={role:"mark",type:"text",version:14,params:{size:{kind:"number",default:11},weight:{kind:"any"},anchor:{kind:"enum",values:["start","middle","end"],default:"middle"},baseline:{kind:"enum",values:["auto","middle","hanging"],default:"middle"},dx:{kind:"number",default:0},dy:{kind:"number",default:0},rotate:{kind:"number",default:0},decimals:{kind:"number"},format:{kind:"format"},fill:{kind:"color"},negative:{kind:"enum",values:["same","flip"],default:"same"},collide:{kind:"enum",values:["show","hide"],default:"show"},minSize:{kind:"number",default:8}},channels:{x:{required:!0,accepts:{output:"position"}},y:{required:!0,accepts:{output:"position"}},x2:{accepts:{output:"position",input:["number","date"]},sharesScale:"x"},y2:{accepts:{output:"position",input:["number","date"]},sharesScale:"y"},text:{required:!0,unscaled:!0},sign:{unscaled:!0},color:{accepts:{output:"color"}},on:{accepts:{output:"color"},sharesScale:"color"}},render(n,l,u){const d=l.channel(n,"x"),y=l.channel(n,"y"),D=l.channel(n,"text").raw,A=n.sign!==void 0?l.channel(n,"sign").raw:null,W=n.color!==void 0?l.channel(n,"color").mapped:null,G=n.on!==void 0?l.channel(n,"on").mapped:null,j=n.format!==void 0?H.formatter(n.format):null,E=d.half,J=y.half,f=typeof n.size=="number"?n.size:11,c=n.anchor==="start"||n.anchor==="end"?n.anchor:"middle",k=n.baseline==="auto"||n.baseline==="hanging"?n.baseline:"middle",R=typeof n.dx=="number"?n.dx:0,T=typeof n.dy=="number"?n.dy:0,I=typeof n.rotate=="number"&&n.rotate!==0?n.rotate:void 0,yn=typeof n.decimals=="number"&&n.decimals>=0?Math.min(20,Math.floor(n.decimals)):void 0,Q=typeof n.weight=="number"||typeof n.weight=="string"?n.weight:void 0,V=typeof n.fill=="string"?n.fill:sn,O=typeof n.minSize=="number"&&n.minSize>0?Math.min(n.minSize,f):Math.min(8,f),g=n.x2!==void 0?l.channel(n,"x2").mapped:null,b=n.y2!==void 0?l.channel(n,"y2").mapped:null,P=(t,e)=>l.textWidth(t,e,Q);let z=0,$=1/0,U=1/0;if(E&&!g&&c==="middle"&&I===void 0&&d.scale){const t=d.scale.domain();z=t.length>1?Math.abs(d.scale(t[1])-d.scale(t[0])):l.plot.w,isFinite(z)&&z>0&&($=z-C,U=b?$:Math.max($,2*(z-E)-C))}const bn=(t,e,s)=>{let m=U,o=1/0;if(g&&I===void 0&&isFinite(g[t])){const a=Math.min(d.mapped[t],g[t]),i=Math.max(d.mapped[t],g[t]),r=Math.abs(R);m=c==="start"?i-e-r:c==="end"?e-a-r:2*Math.min(e-a,i-e)-2*r,m>=0||(m=0)}if(b&&I===void 0&&isFinite(b[t])){const a=Math.min(y.mapped[t],b[t]),i=Math.max(y.mapped[t],b[t]),r=Math.abs(T);o=k==="hanging"?i-s-r:k==="auto"?s-a-r:2*Math.min(s-a,i-s)-2*r,o>=0||(o=0)}return[m,o]},Z=n.negative==="flip",F=Z&&!!y.half&&!d.half,Y=Z?A||(F?d:y).raw:null,xn=n.collide==="hide"&&I===void 0,nn=[],v=(t,e,s,m,o,a=c)=>{const i=P(t,o),r=a==="start"?e:a==="end"?e-i:e-i/2,x=m==="hanging"?s:m==="auto"?s-o:s-o/2;return{x0:r,x1:r+i,y0:x,y1:x+o}},tn=t=>!nn.some(e=>t.x0<e.x1&&e.x0<t.x1&&t.y0<e.y1&&e.y0<t.y1),K=t=>t==="auto"?"hanging":t==="hanging"?"auto":t,{from:gn,to:pn}=l.rows(n);let _=[];const L=[],en=new Set,N=l.plot;for(let t=gn;t<pn;t++){const e=j?j(D[t]):mn(D[t],yn),s=G?G[t]?fn(G[t])||V:"":W?W[t]:V;if(!e||!s)continue;const m=g&&!E&&c==="middle"&&I===void 0&&isFinite(g[t]),o=b&&!J&&k==="middle"&&I===void 0&&isFinite(b[t]),a=m?(d.mapped[t]+g[t])/2:d.mapped[t]+E,i=o?(y.mapped[t]+b[t])/2:y.mapped[t]+J;let r=Y!==null&&typeof Y[t]=="number"&&Y[t]<0;if(r){const M=F?v(e,a-R,i,k,f,c==="start"?"end":c==="end"?"start":c):v(e,a,i-T,K(k),f);(F?M.x0<N.x-.5||M.x1>N.x+N.w+.5:M.y0<N.y-.5||M.y1>N.y+N.h+.5)&&(r=!1)}const x=r&&F?c==="start"?"end":c==="end"?"start":c:c,p=r&&F?-R:R;let h=r&&!F?K(k):k,X=r&&!F?-T:T;const q=a+p;let S=i+X;if(!isFinite(q)||!isFinite(S))continue;const on=`${q},${S},${x},${h},${s}|${e}`;if(en.has(on))continue;en.add(on);let w=f;const[an,ln]=bn(t,q,S);if(an<1/0||ln<1/0){if(w=Math.min(f,f*an/P(e,f),ln),!(w>=O))continue;w=Math.floor(w*2)/2}if(xn){let M=v(e,q,S,h,w);if(!tn(M)){const B=S-2*X,rn=v(e,q,B,K(h),w);if(h==="middle"||!tn(rn))continue;S=B,h=K(h),X=-X,M=rn}nn.push(M)}L.push(U>$?Math.floor(Math.min(f,f*$/P(e,f))*2)/2:w),_.push({type:"text",x:q,y:S,text:e,size:w,weight:Q,anchor:x,baseline:h,rotate:I,style:{fill:s},ref:{mark:u,row:t}})}if($<1/0&&!b){const t=_;let e=f;for(const o of t)e=Math.min(e,o.size);const s=t.map((o,a)=>a).sort((o,a)=>t[o].x-t[a].x),m=o=>{for(let a=0;a<s.length;a++){const i=t[s[a]],r=v(i.text,i.x,i.y,i.baseline,o);for(let x=a+1;x<s.length;x++){const p=t[s[x]];if(p.x-i.x>=2*z)break;if(p.x-i.x<z/2)continue;const h=v(p.text,p.x,p.y,p.baseline,o);if(r.x1+C>h.x0&&r.y0<h.y1&&h.y0<r.y1)return!0}}return!1};for(;e>=O&&m(e);)e-=.5;if(e<O){const o=t.filter((a,i)=>L[i]>=O);e=f,t.forEach((a,i)=>L[i]>=O&&(e=Math.min(e,L[i]))),_=o}for(const o of _)o.size=e}return _}};H.define(hn)})(globalThis.BC);
137
+
138
+
139
+ "use strict";(function(L){const z=t=>Math.round(t*100)/100,C="var(--bc-tooltip-bg, #fff)";function F(t,n,i){const r=n.channel(t,"x"),a=n.channel(t,"y"),o=!!(r.scale&&r.scale.bandwidth!==void 0);if(!o&&!(a.scale&&a.scale.bandwidth!==void 0))throw new Error("mark.violin: put the categories on a band scale, x for violins standing up or y for ridges lying down");const u=o?r:a,c=o?a:r,h=n.channel(t,"density").raw,e=t.color!==void 0?n.channel(t,"color").mapped:null,f=u.scale.bandwidth,p=t.side!=="one",w=typeof t.extent=="number"&&t.extent>0?t.extent:p?.9:1.6,m=typeof t.fill=="string"?t.fill:"",{from:j,to:v}=n.rows(t),y=c.mapped.length,d=new Float64Array(y),k=new Map;for(let s=j;s<v;s++){const l=u.mapped[s],b=h[s];if(d[s]=c.mapped[s],!isFinite(l)||!isFinite(d[s])||typeof b!="number"||!isFinite(b)||b<0||e&&!e[s])continue;const M=k.get(l);M?M.push(s):k.set(l,[s])}let W=0;k.forEach(s=>s.forEach(l=>W=Math.max(W,h[l])));const q=[];return[...k.keys()].sort((s,l)=>s-l).forEach(s=>{const l=k.get(s).sort((g,x)=>d[g]-d[x]||g-x),b=t.normalize==="each"?l.reduce((g,x)=>Math.max(g,h[x]),0):W,M=(p?f/2:f)*w,A=new Float64Array(y);for(const g of l)A[g]=b>0?h[g]/b*M:0;q.push({rows:l,at:p?s+f/2:o?s:s+f,w:A,color:e?e[l[0]]:m||n.color(i)})}),{upright:o,v:d,both:p,shapes:q}}function E(t,n,i,r){const a=t.both?n.at+r*n.w[i]:t.upright?n.at+(r>0?n.w[i]:0):n.at-(r>0?n.w[i]:0);return t.upright?[a,t.v[i]]:[t.v[i],a]}function B(t,n){const i=(o,u)=>u.map(c=>E(t,n,c,o).map(z).join(" ")),r=i(1,n.rows),a=i(-1,n.rows.slice().reverse());return"M"+r.join("L")+"L"+a.join("L")+"Z"}const D={role:"mark",type:"violin",version:4,params:{side:{kind:"enum",values:["both","one"],default:"both"},extent:{kind:"number"},normalize:{kind:"enum",values:["all","each"],default:"all"},fill:{kind:"color"},opacity:{kind:"number",default:.85},stroke:{kind:"string"},strokeWidth:{kind:"number",default:1.5}},channels:{x:{required:!0,accepts:{output:"position"}},y:{required:!0,accepts:{output:"position"}},density:{required:!0,unscaled:!0},color:{accepts:{output:"color"}}},render(t,n,i){const r=F(t,n,i),a=typeof t.opacity=="number"?t.opacity:.85,o=typeof t.stroke=="string"?t.stroke:r.both?void 0:C,u=typeof t.strokeWidth=="number"?t.strokeWidth:1.5;return r.shapes.filter(c=>c.rows.length>1).map(c=>({type:"path",d:B(r,c),style:{fill:c.color,fillOpacity:a,stroke:o,strokeWidth:o?u:void 0},ref:{mark:i,row:c.rows[0]}}))},pick(t,n,i,r,a){const o=F(t,n,i),u=o.upright?a:r,c=o.upright?r:a;for(let h=o.shapes.length-1;h>=0;h--){const e=o.shapes[h];if(e.rows.length<2)continue;const f=o.v[e.rows[0]],p=o.v[e.rows[e.rows.length-1]];if(u<Math.min(f,p)||u>Math.max(f,p))continue;let w=e.rows[0];for(const d of e.rows)Math.abs(o.v[d]-u)<Math.abs(o.v[w]-u)&&(w=d);const m=e.w[w]+3;if(!(o.both?Math.abs(c-e.at)<=m:o.upright?c>=e.at-3&&c<=e.at+m:c<=e.at+3&&c>=e.at-m))continue;const[v,y]=E(o,e,w,1);return{row:w,x:o.both&&o.upright?e.at:v,y:o.both?o.upright?y:e.at:y,dist:0}}return null},color(t,n,i,r){const a=F(t,n,i).shapes.find(o=>o.rows.length>1&&o.rows.includes(r));return a?a.color:""}};L.define(D)})(globalThis.BC);
140
+
141
+
142
+ "use strict";(function(E){const ot="var(--bc-axis, #888)",S="var(--bc-text, #444)",z="var(--bc-label, var(--bc-text, #444))",I=t=>t.ticks===!0?9:8,K=(t,e)=>t.line==="on"?!0:t.line==="off"?!1:e==="top"||e==="bottom";function L(t,e){return t.position?t.position:t.scale&&e.orientation(t.scale)==="vertical"?"left":"bottom"}const F=new WeakMap,A=.71,st=14,V=19,G=20,_=6,it=.85,lt=/^\s*-?\d[\d.,:\/-]*(T[\d:.]+Z?)?\s*$/;function P(t,e){let i=0,o=0;for(const n of e.spec.guides||[])if(n!==t)if(n.type==="axis"){const s=n.scale?L(n,e):"top",a=(s==="left"||s==="right")&&nt.measure(n,e)[s]||0;s==="left"?i+=a:s==="right"&&(o+=a)}else{const s=E.get(`guide.${n.type}`),a=s&&s.measure?s.measure(n,e):{};i+=a.left||0,o+=a.right||0}return{x:e.plot.x+i,w:e.plot.w-i-o}}function rt(t,e,i){const o=t.scale?e.scales[t.scale]:void 0;if(!o||o.input!=="category"||i==="left"||i==="right"||e.orientation(t.scale)!=="horizontal")return 0;const n=o.domain(),s=P(t,e).w;return n.length<2||s/n.length<st||n.every(a=>typeof a=="number"||a instanceof Date||lt.test(String(a)))||X(t,e,s)>=n.length?0:s/n.length<V?90:45}const at=/[、。,.・:;?!)」』】〕》〉ーゝゞ々ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮヵヶ]/,ft=/[(「『【〔《〈]/,H=/\d/;function q(t,e){const i=[];for(let o=1;o<t.length;o++){const n=t[o-1],s=t[o];!e.wide(n)||at.test(s)||ft.test(n)||H.test(s)&&!(o>=2&&H.test(t[o-2]))||i.push(o)}return i}function B(t,e,i){const o=Array.from(t),n=(r,u)=>i.measure(o.slice(r,u).join(""),11).w;let s=-1,a=1/0;for(const r of q(o,i)){const u=n(0,r);if(u>e)break;const m=Math.max(u,n(r,o.length));m<a&&(a=m,s=r)}if(s<0){const r=q(o,i);if(!r.length)return[t];s=r[0]}return[o.slice(0,s).join(""),o.slice(s).join("")]}function X(t,e,i){const o=t.scale,n=e.orientation(o)==="horizontal";let s=0;for(const a of e.scales[o].domain()){const r=String(a);if(!n){s=Math.max(s,e.measure(r,11).h);continue}const u=e.measure(r,11).w,m=r.split(/\s+/).filter(Boolean),l=m.length===1&&e.wide(r)?Math.max(...B(r,1/0,e).map(f=>e.measure(f,11).w)):m.reduce((f,h)=>Math.max(f,e.measure(h,11).w),0);s=Math.max(s,Math.min(u,Math.max(l,u/2)))}return Math.floor(i/(n?s*.9+4:s+3))}const D=t=>t.length>G?t.slice(0,G-1)+"\u2026":t;function R(t,e){return ut(mt(t,e),t,e)}function ut(t,e,i){if(i.scales[e.scale].input==="category"||i.orientation(e.scale)!=="horizontal")return t;const o=Q(e),n=t.filter((u,m)=>m===0||u.label!==t[m-1].label);if(n.length<2)return n;let s=1/0;for(let u=1;u<n.length;u++)s=Math.min(s,Math.abs(n[u].pos-n[u-1].pos));const a=n.reduce((u,m)=>Math.max(u,i.measure(m.label,11).w),0),r=s>0?Math.ceil((a+_)/s):1;return r>1?n.filter((u,m)=>o(m,n.length,r)):n}const Q=t=>(e,i,o)=>(t.anchor==="end"?i-1-e:e)%o===0;function ht(t,e){if(t.format===void 0||e.orientation(t.scale)!=="horizontal")return 0;const i=E.formatter(t.format),o=e.scales[t.scale].domain(),n=o.reduce((s,a)=>Math.max(s,e.measure(i(a),11).w),0);return Math.min(o.length,Math.floor(e.plot.w/(n+_)))}function ct(t,e){const i=t.scale,o=e.scales[i],n=typeof t.count=="number"&&t.count>=1?Math.round(t.count):void 0;if(o.input!=="category")return n===void 0?e.ticks(i):e.ticks(i,n);const s=Math.max(e.ticks(i).length,ht(t,e)),a=n===void 0?s:Math.min(n,s);if(t.anchor!=="end")return e.ticks(i,a);const r=e.ticks(i,o.domain().length),u=Math.max(1,Math.ceil(r.length/Math.max(1,a))),m=Q(t);return r.filter((l,f)=>m(f,r.length,u))}function mt(t,e){const i=e.scales[t.scale],o=F.has(t)?e.ticks(t.scale,i.domain().length):ct(t,e);if(t.format===void 0||i.output!=="position")return o;const{input:n}=i,s=E.formatter(t.format,n==="date"?"date":n==="category"?void 0:"number");return o.map(a=>({value:a.value,pos:a.pos,label:s(a.value)}))}const U=(t,e)=>F.has(t)?R(t,e).map(i=>({...i,label:D(i.label)})):R(t,e),x=t=>typeof t.title=="string"?t.title:"",N=11*1.25,dt=.3;function Z(t,e,i){if(i.measure(t,11).w<=e)return t;const o=Array.from(t);let n=0,s=o.length;for(;n<s;){const a=n+s+1>>1;i.measure(o.slice(0,a).join("")+"\u2026",11).w<=e?n=a:s=a-1}return o.slice(0,n).join("").trimEnd()+"\u2026"}function gt(t,e,i){const o=t.split(/\s+/).filter(Boolean);if(o.length<2){if(!i.wide(t))return null;const a=Array.from(t);let r=0;for(;r<a.length-1&&i.measure(a.slice(0,r+1).join(""),11).w<=e;)r++;return r?[a.slice(0,r).join(""),a.slice(r).join("")]:null}if(i.measure(o[0],11).w>e)return null;let n=o[0],s=1;for(;s<o.length-1&&i.measure(n+" "+o[s],11).w<=e;)n+=" "+o[s++];return[n,o.slice(s).join(" ")]}function wt(t,e){const i=e.scales[t.scale],o=i.input==="category"?i.domain().length:0,n=Math.max(44,e.size.w*dt),s=o>0&&e.plot.h/o>=2*N+2;return a=>{if(e.measure(a,11).w<=n)return[a];const r=s?gt(a,n,e):null;return r?[r[0],Z(r[1],n,e)]:[Z(a,n,e)]}}function j(t,e,i){if(t.scale&&(i==="left"||i==="right"))return wt(t,e);const o=t.scale?e.scales[t.scale]:void 0,n=o&&o.input==="category"?o.domain().length:0;if(!n)return a=>[a];const s=e.plot.w/n-6;return a=>J(a,s,e)}function J(t,e,i){if(i.measure(t,11).w<=e)return[t];const o=t.split(/\s+/).filter(Boolean);if(o.length<2)return i.wide(t)?B(t,e,i):[t];let n=o[0],s=1;for(;s<o.length-1&&i.measure(n+" "+o[s],11).w<=e;)n+=" "+o[s++];return[n,o.slice(s).join(" ")]}const Y=new WeakMap;function W(t,e){const{text:i,from:o,to:n}=t;if(i===void 0&&o===void 0&&n===void 0)return null;if(typeof i!="string"||typeof o!="string"||typeof n!="string")throw new Error('an axis that names spans needs all three of "text", "from" and "to"');const s=L(t,e);if(s==="left"||s==="right")throw new Error('"text", "from" and "to" name spans along a horizontal axis (top or bottom)');return{text:i,from:o,to:n}}function Tt(t,e,i){const o=W(t,e),n=e.table.columns,s=n[o.text],a=n[o.from],r=n[o.to],u=e.scales[t.scale];if(!s||!a||!r||!u)return[];const m=t.format!==void 0?E.formatter(t.format):null,l=e.plot,f=g=>i.x+(g-l.x)*i.w/l.w,h=[],c=new Set;for(let g=0;g<e.table.length;g++){const T=s[g];if(T==null||T==="")continue;const O=m?m(T):String(T),d=u(a[g]),b=u(r[g]);if(!O||typeof d!="number"||typeof b!="number"||!isFinite(d)||!isFinite(b))continue;const k=(d+b)/2;if(k<l.x-.5||k>l.x+l.w+.5)continue;const y=`${d},${b}|${O}`;if(c.has(y))continue;c.add(y);const p=f(Math.min(d,b)),w=f(Math.max(d,b));h.push({label:O,lo:p,hi:w,mid:(p+w)/2})}return h.sort((g,T)=>g.mid-T.mid)}function bt(t,e,i,o){const n=t.map(l=>{const f=J(l.label,l.hi-l.lo-_,e),h=f.reduce((g,T)=>Math.max(g,e.textWidth(T,11)),0),c=f.reduce((g,T)=>Math.max(g,e.measure(T,11).w),h);return{...l,lines:f,w:h,room:c,x:l.mid}}),s=n.length;if(!s)return{named:n,ok:!0};const a=[0];for(let l=1;l<s;l++)a.push(a[l-1]+(n[l-1].w+n[l].w)/2+_);const r=[];for(let l=0;l<s;l++){let f={first:l,last:l,sum:n[l].mid-a[l]};for(;r.length;){const h=r[r.length-1];if(h.sum/(h.last-h.first+1)<f.sum/(f.last-f.first+1))break;r.pop(),f={first:h.first,last:f.last,sum:h.sum+f.sum}}r.push(f)}for(const l of r)for(let f=l.first;f<=l.last;f++)n[f].x=l.sum/(l.last-l.first+1)+a[f];const u=l=>a[l]-a[l-1];n[s-1].x=Math.min(n[s-1].x,o-n[s-1].room/2);for(let l=s-2;l>=0;l--)n[l].x=Math.min(n[l].x,n[l+1].x-u(l+1));n[0].x=Math.max(n[0].x,i+n[0].room/2);for(let l=1;l<s;l++)n[l].x=Math.max(n[l].x,n[l-1].x+u(l));const m=n[s-1].x+n[s-1].room/2<=o+.5&&n.every(l=>Math.abs(l.x-l.mid)<=l.w/2);return{named:n,ok:m}}const Mt=2;function tt(t,e,i){const o=i?P(t,e):{x:e.plot.x,w:e.plot.w},n=Tt(t,e,o).filter(r=>r.hi-r.lo>=Mt),s=i?void 0:Y.get(t),a=[];for(const r of n){const u=a[a.length-1];if(u&&r.mid-u.mid<V){r.hi-r.lo>u.hi-u.lo&&(a[a.length-1]=r);continue}a.push(r)}if(!s){const r=m=>bt(m,e,0,e.size.w);let u=r(n);if(!u.ok){const m=n.map((c,g)=>g).sort((c,g)=>n[c].hi-n[c].lo-(n[g].hi-n[g].lo)),l=c=>{const g=new Set(m.slice(0,c));return n.filter((T,O)=>!g.has(O))};let f=1,h=n.length;for(;f<h;){const c=f+h>>1;r(l(c)).ok?h=c:f=c+1}u=r(l(f))}if(s===0||u.named.length>=a.length)return{angle:0,named:u.named}}return{angle:45,named:a.map(r=>({...r,label:D(r.label),lines:[D(r.label)],w:0,room:0,x:r.mid}))}}function et(t,e,i,o,n){const s=o===90?0:A,a=o===90?1:A;let r=0,u=0,m=0;for(const f of n){const h=e.textWidth(f.label,11),c=(h+11)*s;r=Math.max(r,h*a),i==="bottom"?u=Math.max(u,e.plot.x-(f.pos-c)):m=Math.max(m,f.pos+c-(e.plot.x+e.plot.w))}const l={overhang:{top:0,right:m,bottom:0,left:u}};return l[i]=I(t)+r+11*A+4+(x(t)?20.4:0),l}const nt={role:"guide",type:"axis",version:20,params:{scale:{kind:"scale",required:!0},position:{kind:"enum",values:["top","right","bottom","left"]},title:{kind:"string"},format:{kind:"format"},line:{kind:"enum",values:["auto","on","off"],default:"auto"},ticks:{kind:"boolean",default:!1},count:{kind:"number"},anchor:{kind:"enum",values:["start","end"],default:"start"},text:{kind:"field"},from:{kind:"field"},to:{kind:"field"}},fits:X,measure(t,e){if(!t.scale)return{};const i=L(t,e),o=i==="left"||i==="right";if(W(t,e)){const{angle:l,named:f}=tt(t,e,!0);if(Y.set(t,l),l)return et(t,e,i,l,f.map(d=>({pos:d.x,label:d.label})));const h=P(t,e);let c=0,g=0,T=0;for(const d of f)c=Math.max(c,d.lines.length>1?d.lines.length*N:e.measure(d.label,11).h),g=Math.max(g,h.x-(d.x-d.room/2)),T=Math.max(T,d.x+d.room/2-(h.x+h.w));const O={overhang:{top:0,right:T,bottom:0,left:g}};return O[i]=I(t)+c+4+(x(t)?20.4:0),O}const n=rt(t,e,i);if(n?F.set(t,n):F.delete(t),n)return et(t,e,i,n,U(t,e));let s=0;const a={top:0,right:0,bottom:0,left:0},r=e.plot,u=j(t,e,i);for(const l of R(t,e)){const f=u(l.label),h=f.reduce((c,g)=>{const T=e.measure(g,11);return{w:Math.max(c.w,T.w),h:c.h}},{w:0,h:f.length>1?f.length*N:e.measure(l.label,11).h});if(s=Math.max(s,o?h.w:h.h),o){const c=l.pos-(f.length-1)/2*N;a.top=Math.max(a.top,r.y-(l.pos-h.h/2),r.y-(c-it*11)),a.bottom=Math.max(a.bottom,l.pos+h.h/2-(r.y+r.h))}else a.left=Math.max(a.left,r.x-(l.pos-h.w/2)),a.right=Math.max(a.right,l.pos+h.w/2-(r.x+r.w))}const m={overhang:a};return m[i]=I(t)+s+4+(x(t)?20.4:0),m},render(t,e,i){if(!t.scale)return{};const o=L(t,e),{x:n,y:s,w:a,h:r}=e.plot,u=W(t,e),m=u?[]:U(t,e),l=[],f=x(t);let h,c=0;const g=I(t),T=t.ticks===!0;if(o==="left"||o==="right"){const d=o==="left"?-1:1,b=o==="left"?n-i.left:n+a+i.right;h=K(t,o)?`M${b} ${s}V${s+r}`:"";const k=j(t,e,o);for(const w of m){T&&(h+=`M${b} ${w.pos}H${b+d*5}`);const M=k(w.label),v=M.length===1&&M[0]===w.label?void 0:w.label;M.forEach(($,C)=>{c=Math.max(c,e.measure($,11).w),l.push({type:"text",x:b+d*g,y:w.pos+(C-(M.length-1)/2)*N,text:$,size:11,anchor:d<0?"end":"start",baseline:"middle",style:{fill:z},cls:"bc-axis-label",title:v})})}const y=b+d*(g+c+4+20.4/2);if(!!f&&Array.from(f).every(w=>e.wide(w))&&f.length*12*1.1<=r){const w=Array.from(f);w.forEach((M,v)=>{l.push({type:"text",x:y,y:s+r/2+(v-(w.length-1)/2)*12*1.1,text:M,size:12,weight:600,anchor:"middle",baseline:"middle",style:{fill:S},cls:"bc-axis-title"})})}else f&&l.push({type:"text",x:y,y:s+r/2,text:f,size:12,weight:600,anchor:"middle",baseline:"middle",rotate:d<0?-90:90,style:{fill:S},cls:"bc-axis-title"})}else{const d=o==="top"?-1:1,b=o==="top"?s-i.top:s+r+i.bottom;h=K(t,o)?`M${n} ${b}H${n+a}`:"";const k=(p,w,M)=>{c=Math.max(c,e.textWidth(w,11)*(M===90?1:A)+11*A),l.push({type:"text",x:p,y:b+d*g,text:w,size:11,anchor:d<0?"start":"end",baseline:"middle",rotate:-M,style:{fill:z},cls:"bc-axis-label"})},y=(p,w,M)=>{c=Math.max(c,M.length>1?M.length*N:e.measure(w,11).h),(d<0?M.slice().reverse():M).forEach(($,C)=>{l.push({type:"text",x:p,y:b+d*(g+C*N),text:$,size:11,anchor:"middle",baseline:d<0?"auto":"hanging",style:{fill:z},cls:"bc-axis-label"})})};if(u){const{angle:p,named:w}=tt(t,e,!1);for(const M of w)T&&(h+=`M${M.mid} ${b}V${b+d*5}`),p?k(M.mid,M.label,p):y(M.x,M.label,M.lines)}else{const p=j(t,e,o);for(const w of m)T&&(h+=`M${w.pos} ${b}V${b+d*5}`),F.has(t)?k(w.pos,w.label,F.get(t)):y(w.pos,w.label,p(w.label))}if(f){const p=b+d*(g+c+4+2);l.push({type:"text",x:n+a/2,y:p,text:f,size:12,weight:600,anchor:"middle",baseline:d<0?"auto":"hanging",style:{fill:S},cls:"bc-axis-title"})}}return{axes:[...h?[{type:"path",d:h,cls:"bc-axis",style:{fill:"none",stroke:ot,strokeWidth:1}}]:[],...l]}}};E.define(nt)})(globalThis.BC);
143
+
144
+
145
+ "use strict";(function(u){const c={role:"guide",type:"grid",version:3,narrow:!0,params:{scale:{kind:"scale",required:!0},count:{kind:"number"}},render(e,n){const t=e.scale;if(!t)return{};const a=n.orientation(t)==="vertical",{x:o,y:i,w:l,h:f}=n.plot;let r="";const s=typeof e.count=="number"&&e.count>=1?Math.round(e.count):void 0;for(const d of s===void 0?n.ticks(t):n.ticks(t,s))r+=a?`M${o} ${d.pos}H${o+l}`:`M${d.pos} ${i}V${i+f}`;return r?{grid:[{type:"path",d:r,cls:"bc-grid",style:{fill:"none",stroke:"var(--bc-grid, #e6e6e6)",strokeWidth:1}}]}:{}}};u.define(c)})(globalThis.BC);
146
+
147
+
148
+ "use strict";(function(m){const v="var(--bc-label, var(--bc-text, #666))",$="var(--bc-kpi, var(--bc-text, #111))",x="var(--bc-good, #12a150)",W="var(--bc-bad, #e5484d)",F="var(--bc-label, #888)",_=["last","first","sum","mean","min","max","count"];function p(t){const o=[];if(!t)return o;for(let n=0;n<t.length;n++){const e=t[n];typeof e=="number"&&isFinite(e)&&o.push(e)}return o}function I(t,o){if(o==="count")return t.length;if(!t.length)return NaN;switch(o){case"first":return t[0];case"sum":return t.reduce((n,e)=>n+e,0);case"mean":return t.reduce((n,e)=>n+e,0)/t.length;case"min":return t.reduce((n,e)=>e<n?e:n);case"max":return t.reduce((n,e)=>e>n?e:n);default:return t[t.length-1]}}const h=(t,o)=>t.baseTable.columns[o]||t.table.columns[o];function U(t,o){const n=typeof t.aggregate=="string"&&_.indexOf(t.aggregate)>=0?t.aggregate:"last",e=p(h(o,t.field)),a=I(e,n);let i=NaN;if(typeof t.against=="string")i=I(p(h(o,t.against)),n);else{const r=t.compare==="first"||t.compare==="none"||t.compare==="previous"?t.compare:n==="last"?"previous":"none";r==="previous"&&e.length>1?i=e[e.length-2]:r==="first"&&e.length>1&&(i=e[0])}return{value:a,base:i}}const V=t=>typeof t.note=="string"?t.note:"";function N(t,o,n,e,a,i){const r=t.textWidth(o,n,e);return r<=a?n:Math.max(Math.min(i,n),Math.floor(n*a/r*2)/2)}function L(t,o,n,e,a){if(t.textWidth(o,n,e)<=a)return o;const i=Array.from(o);let r=0,l=i.length;for(;r<l;){const s=r+l+1>>1;t.textWidth(i.slice(0,s).join("")+"\u2026",n,e)<=a?r=s:l=s-1}return r?i.slice(0,r).join("").trimEnd()+"\u2026":""}function M(t,o){const n=Math.max(1,o.size.w-o.plot.x-2),e=typeof t.size=="number"&&t.size>0&&isFinite(t.size)?t.size:30,a=B(t,o),i=typeof t.label=="string"?t.label:"",r=i&&a?`${i}: ${a}`:i||a,l=N(o,r,12,500,n,10),s=L(o,r,l,500,n),{value:u,base:c}=U(t,o),w=t.format!==void 0?m.formatter(t.format):d=>m.formatter("compact")(d),b=isFinite(u)?w(u):"\u2013",A=N(o,b,e,650,n,8);let f="",G="",O=F;if(isFinite(u)&&isFinite(c)){const d=u-c,k=d>0,z=d===0,J=t.better==="down"?!k:k;O=z?F:J?x:W;const D=t.deltaFormat!==void 0?m.formatter(t.deltaFormat):null,P=E=>k&&!/^[+]/.test(E)?"+"+E:E;let y;if(t.delta==="absolute")y=P((D||w)(d*(typeof t.deltaScale=="number"&&isFinite(t.deltaScale)?t.deltaScale:1)));else{const E=D||m.formatter({style:"percent",maximumFractionDigits:1});y=c!==0?P(E(d/Math.abs(c))):""}f=`${z?"\u25A0":k?"\u25B2":"\u25BC"} ${y}`.trim(),G=y}const g=V(t),T=f&&g?6:0,Z=(d=>(f?o.textWidth(f,d,600):0)+(g?o.textWidth(g,d,400):0))(12),S=T+Z<=n?12:Math.max(10,Math.floor(12*Math.max(0,n-T)/Z*2)/2);f&&(f=L(o,f,S,600,n));const X=g?L(o,g,S,400,n-(f?o.textWidth(f,S,600)+T:0)):"",q=f||g?18:0,R=(r?18:0)+A+q+10,H=[r,b,[G,g].filter(Boolean).join(" ")];return{labelled:!!r,label:s,labelSize:l,value:b,valueSize:A,change:f,changeColor:O,note:X,lineSize:S,height:R,spoken:H}}function B(t,o){if(typeof t.rowField!="string")return"";const n=h(o,t.rowField),e=h(o,t.field);if(!n||!e)return"";const a=typeof t.aggregate=="string"?t.aggregate:"last";let i=-1;for(let l=0;l<e.length;l++){const s=e[l];if(typeof s!="number"||!isFinite(s))continue;const u=i<0?NaN:e[i];if((i<0||a==="last"||a==="max"&&s>u||a==="min"&&s<u)&&(i=l),a==="first")break}const r=i<0?null:n[i];return r==null||r!==r?"":t.rowFormat!==void 0?m.formatter(t.rowFormat)(n[i]):String(n[i])}const j={role:"guide",type:"kpi",version:10,narrow:!0,params:{field:{kind:"field",required:!0},label:{kind:"string"},aggregate:{kind:"enum",values:_,default:"last"},compare:{kind:"enum",values:["previous","first","none"]},against:{kind:"field"},delta:{kind:"enum",values:["percent","absolute"],default:"percent"},deltaFormat:{kind:"format"},deltaScale:{kind:"number",default:1},better:{kind:"enum",values:["up","down"],default:"up"},format:{kind:"format"},note:{kind:"string"},rowField:{kind:"field"},rowFormat:{kind:"format"},size:{kind:"number",default:30}},measure(t,o){const n=typeof t.aggregate=="string"?t.aggregate:"last";if((t.compare==="previous"||t.compare==="first")&&n!=="last"&&typeof t.against!="string")throw new Error(`guide.kpi: compare "${t.compare}" compares one row with another, so it needs aggregate "last" (not "${n}"); to compare a ${n} with something, give "against" a field`);if(typeof t.rowField=="string"&&["last","first","min","max"].indexOf(n)<0)throw new Error(`guide.kpi: rowField names one row, and aggregate "${n}" comes from many; use last, first, min or max`);return{top:M(t,o).height}},render(t,o,n){if(typeof t.field!="string"||!h(o,t.field))return{};const e=M(t,o),a=o.plot.x;let i=o.plot.y-n.top-e.height;const r=[],l=(u,c,w,b,A,f)=>r.push({type:"text",x:c,y:i,text:u,size:w,weight:b,baseline:"hanging",style:{fill:A},cls:f});e.label&&l(e.label,a,e.labelSize,500,v,"bc-kpi-label"),e.labelled&&(i+=18),l(e.value,a,e.valueSize,650,$,"bc-kpi-value"),i+=e.valueSize+6;let s=a;e.change&&(l(e.change,a,e.lineSize,600,e.changeColor,"bc-kpi-delta"),s=a+o.textWidth(e.change,e.lineSize,600)+6),e.note&&l(e.note,s,e.lineSize,400,v,"bc-kpi-note");for(const u of e.spoken)o.say(u);return{axes:r}}};m.define(j)})(globalThis.BC);
149
+
150
+
151
+ "use strict";(function(j){const M="var(--bc-text, #444)",z=t=>t.output==="color"&&t.input==="category";function Y(t,e){const n=t.scale?e.scales[t.scale]:void 0;if(!n||!(n.output==="color"||n.output==="size"&&n.input==="number"))throw new Error("guide.legend needs a scale of colors, or of sizes for numbers");return n}function x(t,e,n){return C(t,e,3).filter(o=>isFinite(o.pos)&&o.pos>0).map(o=>({label:o.label,r:o.pos,w:E(o.label,n),drawn:n.textWidth(o.label,11)}))}const tt="var(--bc-label, var(--bc-text, #888))",N=t=>2*t.r+6+t.w,et=t=>2*t.r+6+t.drawn,p=(t,e)=>{const n=q(t,e);return Math.max(1,t.size.w-Math.max(8,n.left)-Math.max(8,n.right))},q=(t,e)=>e==="top"||e==="bottom"?t.edgeTaken(e):{left:0,right:0},W=(t,e,n,s)=>{const o=q(t,e);return Math.max(Math.max(8,o.left),Math.min(n,t.size.w-Math.max(8,o.right)-s))};function K(t,e){const n=[];let s=0;for(const o of t){const r=n[n.length-1];!r||r.items.length&&s+O+N(o)>e?(n.push({items:[o],h:Math.max(2*o.r,16)+4}),s=N(o)):(r.items.push(o),r.h=Math.max(r.h,Math.max(2*o.r,16)+4),s+=O+N(o))}return n}const E=(t,e)=>Math.max(e.measure(t,11).w,e.textWidth(t,11));function F(t,e,n=1/0){const s=new Set(t.domain()),o=t.range();return t.baseDomain().map((r,i)=>{const l=String(r),h=U(l,n-10-6,e);return{label:h,full:l,color:o[i],w:E(h,e),drawn:e.textWidth(h,11),hidden:!s.has(r),index:i}})}function U(t,e,n){if(!(e<1/0)||E(t,n)<=e)return t;const s=Array.from(t);let o=0,r=s.length;for(;o<r;){const i=o+r+1>>1;E(s.slice(0,i).join("")+"\u2026",n)<=e?o=i:r=i-1}return s.slice(0,o).join("").trimEnd()+"\u2026"}function C(t,e,n=4){const s=t.ticks?t.ticks(n):[];if(e.format===void 0)return s;const o=j.formatter(e.format,"number");return s.map(r=>({value:r.value,pos:r.pos,label:o(r.value)}))}const R=t=>typeof t.title=="string"&&t.title?t.title:"",H=t=>R(t)?16:0,nt=(t,e)=>R(t)?e.measure(R(t),11).w:0,ot=.2;function st(t,e){if(!z(t))return"right";const n=p(e,"top");return I(F(t,e,n),n).length<=2?"top":"right"}function k(t,e,n){const s=nt(t,n),o=H(t);if(e.output==="size"){const i=x(e,t,n),l=i.reduce((h,b)=>Math.max(h,b.r),0);return{w:Math.max(2*l+6+i.reduce((h,b)=>Math.max(h,b.w),0),s)+16,h:4+o+i.reduce((h,b)=>h+Math.max(2*b.r,16)+4,0)}}if(!z(e)){const i=C(e,t).reduce((l,h)=>Math.max(l,n.measure(h.label,11).w),0);return{w:Math.max(18+i,s)+16,h:0}}const r=F(e,n);return{w:Math.max(16+r.reduce((i,l)=>Math.max(i,l.w),0),s)+16,h:4+o+r.length*16+4}}function X(t,e,n){const s=t.position==="auto"?st(e,n):t.position||"right";if(!B(s))return s;const o=k(t,e,n);return o.w<=n.size.w*ot&&o.h<=n.size.h?s:"top"}const B=t=>t==="left"||t==="right",Z=(t,e,n)=>Math.max(e,Math.min(n,t)),O=14,J=t=>16+t.w,it=t=>16+t.drawn;function I(t,e){const n=[];let s=[],o=0;for(const r of t){const i=J(r);s.length&&o+O+i>e&&(n.push(s),s=[],o=0),o+=(s.length?O:0)+i,s.push(r)}return s.length&&n.push(s),n}function rt(t,e){return t?Z(e.plot.h*.6,80,200):Z(e.plot.w*.4,100,240)}const lt={role:"guide",type:"legend",version:16,shownOnce:!0,params:{scale:{kind:"scale",required:!0},position:{kind:"enum",values:["top","right","bottom","left","auto"],default:"right"},title:{kind:"string"},format:{kind:"format"}},measure(t,e){const n=Y(t,e),s=X(t,n,e),o=B(s),r=H(t),i={};if(n.output==="size"){const b=x(n,t,e);return i[s]=b.length?o?k(t,n,e).w:K(b,p(e,s)).reduce((T,w)=>T+w.h,0)+8+r:0,i}if(!z(n))return i[s]=o?k(t,n,e).w:12+e.measure("0",11).h+16+r,i;const l=p(e,s),h=F(n,e,o?1/0:l);return i[s]=h.length?o?k(t,n,e).w:I(h,l).length*16+8+r:0,i},render(t,e,n){const s=Y(t,e),o=X(t,s,e),r=B(o),{x:i,y:l,w:h,h:b}=e.plot,T=[],w=H(t),v=r?R(t):U(R(t),p(e,o),e),y=v?e.measure(v,11).w:0,S=(u,d)=>{w&&T.push({type:"text",x:u,y:d+16/2,text:v,size:11,weight:600,baseline:"middle",style:{fill:M},cls:"bc-legend-title"})};if(s.output==="size"){const u=x(s,t,e),d=u.reduce((m,f)=>Math.max(m,f.r),0),a=(m,f,A,c)=>{T.push({type:"circle",cx:m,cy:f,r:A.r,style:{fill:"none",stroke:tt,strokeWidth:1},cls:"bc-legend-size"}),T.push({type:"text",x:c,y:f,text:A.label,size:11,baseline:"middle",style:{fill:M}})};if(r){const m=Math.max(2*d+6+u.reduce((c,g)=>Math.max(c,g.w),0),y)+16,f=(o==="right"?i+h+n.right:i-n.left-m)+8;S(f,l+4);let A=l+4+w;for(const c of u){const g=Math.max(2*c.r,16)+4;a(f+d,A+g/2,c,f+2*d+6),A+=g}}else{const m=K(u,p(e,o));let f=o==="top"?l-n.top-(m.reduce((A,c)=>A+c.h,0)+8+w):l+b+n.bottom+8/2;S(W(e,o,i,y),f),f+=w;for(const A of m){let c=W(e,o,i,A.items.reduce((g,D,G)=>g+(G?O:0)+N(D),0));for(const g of A.items)a(c+g.r,f+A.h/2,g,c+2*g.r+6),c+=et(g)+O;f+=A.h}}return{axes:T}}if(!z(s)){const[u,d]=s.domain(),a=rt(r,e),m=C(s,t),f=m.reduce((P,L)=>Math.max(P,e.measure(L.label,11).w),0),A=Math.max(18+f,y)+16,c=o==="right"?i+h+n.right+8:i-n.left-A+8,g=o==="top"?l-n.top-(12+e.measure("0",11).h+16+w)+8:l+b+n.bottom+8,D=g+w,G=l+4+w+(w?11/2:0);r?S(c,l+4):S(W(e,o,i,y),g);const V=a/48*1.05;for(let P=0;P<48;P++){const L=r?d-(P+.5)/48*(d-u):u+(P+.5)/48*(d-u),$=s(L);T.push(r?{type:"rect",x:c,y:G+P*a/48,w:12,h:V,style:{fill:$},cls:"bc-legend-bar"}:{type:"rect",x:i+P*a/48,y:D,w:V,h:12,style:{fill:$},cls:"bc-legend-bar"})}for(const P of m)T.push(r?{type:"text",x:c+12+6,y:G+(1-P.pos)*a,text:P.label,size:11,baseline:"middle",style:{fill:M}}:{type:"text",x:i+P.pos*a,y:D+12+3,text:P.label,size:11,anchor:"middle",baseline:"hanging",style:{fill:M}});return{axes:T}}const _=F(s,e,r?1/0:p(e,o)),at=e.toggled(String(t.scale)),Q=(u,d,a)=>{T.push({type:"g",cls:"bc-legend-item",data:{"bc-legend-scale":String(t.scale),"bc-legend-index":String(a.index)},pressed:at?!a.hidden:void 0,style:a.hidden?{opacity:.4}:void 0,title:a.label!==a.full?a.full:void 0,children:[{type:"rect",x:u,y:d+6/2,w:10,h:10,r:10/2,style:{fill:a.color},cls:"bc-legend-swatch"},{type:"text",x:u+10+6,y:d+16/2,text:a.label,size:11,baseline:"middle",style:{fill:M}}]})};if(r){const u=Math.max(16+_.reduce((a,m)=>Math.max(a,m.w),0),y)+16,d=o==="right"?i+h+n.right:i-n.left-u;S(d+8,l+4),_.forEach((a,m)=>Q(d+8,l+4+w+m*16,a))}else{const u=I(_,p(e,o)),d=o==="top"?l-n.top-(u.length*16+8+w):l+b+n.bottom+8/2,a=d+w;S(W(e,o,i,y),d),u.forEach((m,f)=>{let A=W(e,o,i,m.reduce((c,g,D)=>c+(D?O:0)+J(g),0));for(const c of m)Q(A,a+f*16,c),A+=it(c)+O})}return{axes:T}}};j.define(lt)})(globalThis.BC);
152
+
153
+
154
+ "use strict";(function(l){const d=typeof WeakMap=="function"?new WeakMap:null,m=()=>typeof performance=="object"&&performance&&typeof performance.now=="function"?performance.now():Date.now();function y(t){const e=l.get(`mark.${t.type}`);return e&&e.enter}function b(t){const e=t.marks.map(y);return e.indexOf("pop")>=0?"pop":e.indexOf("grow")>=0&&e.indexOf("wipe")<0?"grow":e.indexOf("wipe")>=0?"wipe":"fade"}function g(t){const e=t.spec.marks.find(r=>y(r)==="grow");let a=!1;if(e)try{const r=t.channel(e,"y");a=!!(r.scale&&r.scale.bandwidth!==void 0)}catch{a=!1}const n=t.plot,i=a?t.scales.x:t.scales.y,o=i&&i.input==="number"?i(0):NaN;return a?{horizontal:a,at:isFinite(o)&&o>=n.x&&o<=n.x+n.w?o:n.x}:{horizontal:a,at:isFinite(o)&&o>=n.y&&o<=n.y+n.h?o:n.y+n.h}}const k={role:"interaction",type:"animate",version:4,params:{effect:{kind:"enum",values:["auto","grow","wipe","pop","fade"],default:"auto"},duration:{kind:"number",default:700},delay:{kind:"number",default:0}},attach(t,e){const a=e.root;let n=0;const i=d?d.get(e.host):void 0;i!==void 0?n=Math.max(0,m()-i):d&&d.set(e.host,m());const o=e.host.ownerDocument&&e.host.ownerDocument.defaultView||(typeof window<"u"?window:void 0);if(o&&typeof o.matchMedia=="function"&&o.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const r=typeof t.duration=="number"&&t.duration>=0?Math.min(1e4,t.duration):700,w=typeof t.delay=="number"&&t.delay>=0?Math.min(1e4,t.delay):0,M={duration:r,delay:w,easing:"cubic-bezier(.2,.7,.2,1)",fill:"backwards"};if(i!==void 0&&n>=w+r)return;const p=t.effect==="grow"||t.effect==="wipe"||t.effect==="pop"||t.effect==="fade"?t.effect:b(e.spec),s=typeof a.querySelector=="function"?a.querySelector('[data-bc-layer="marks"]'):null,h=s||a;if(typeof h.animate!="function")return;const f=e.plot;let u;if(!s||p==="fade")u=[{opacity:0},{opacity:1}];else if(p==="wipe"){const c=e.size.w-(f.x+f.w);u=[{clipPath:`inset(0 ${e.size.w-f.x}px 0 0)`},{clipPath:`inset(0 ${Math.max(0,c-4)}px 0 0)`,offset:.999},{clipPath:"none"}]}else if(p==="pop")s.style.transformBox="view-box",s.style.transformOrigin=`${f.x+f.w/2}px ${f.y+f.h/2}px`,u=[{transform:"scale(0.6) rotate(-30deg)",opacity:0},{transform:"none",opacity:1}];else{const c=g(e);s.style.transformBox="view-box",s.style.transformOrigin=c.horizontal?`${c.at}px 0px`:`0px ${c.at}px`,u=[{transform:c.horizontal?"scaleX(0)":"scaleY(0)"},{transform:"none"}]}const x=h.animate(u,M);n>0&&(x.currentTime=n),e.cleanup(()=>{try{x.cancel()}catch{}})}};l.define(k)})(globalThis.BC);
155
+
156
+
157
+ "use strict";(function(k){const E=()=>k.get("lib.pointer").exports,j="bc-brush",I={role:"interaction",type:"brush",version:5,requires:["lib.pointer"],params:{scales:{kind:"list",default:["x"]},modifier:{kind:"enum",values:["shift","alt","ctrl","none"],default:"shift"},fit:{kind:"list"},minSize:{kind:"number",default:6}},attach(s,e){const a=(Array.isArray(s.scales)?s.scales.filter(t=>typeof t=="string"):["x"]).filter(t=>{const n=e.scales[t],o=!!n&&e.orientation(t)!==null&&(!!n.invert||n.bandwidth!==void 0);return o||console.warn(`[blockcharts] interaction.brush: scale "${t}" is not a positional scale that can be selected on, ignored`),o});if(!a.length)return;const L=(Array.isArray(s.fit)?s.fit:[]).filter(t=>{const n=typeof t=="string"&&!!e.scales[t]&&a.indexOf(t)<0;return!n&&typeof t=="string"&&console.warn(`[blockcharts] interaction.brush: cannot fit scale "${t}"`),n}),h=s.modifier==="alt"||s.modifier==="ctrl"||s.modifier==="none"?s.modifier:"shift",z=typeof s.minSize=="number"&&s.minSize>=0?s.minSize:6,r=e.root,y=e.host,p=y.ownerDocument||document,g=a.some(t=>e.orientation(t)==="horizontal"),w=a.some(t=>e.orientation(t)==="vertical");let u=null;const m=t=>E().toLogical(e,t),M=t=>E().inPlot(e,t),C=t=>{const n=e.plot;return{x:Math.max(n.x,Math.min(n.x+n.w,t.x)),y:Math.max(n.y,Math.min(n.y+n.h,t.y))}},S=t=>h==="none"||(h==="shift"?t.shiftKey:h==="alt"?t.altKey:t.ctrlKey||t.metaKey);e.claimDrag(S);let i=null;const v=t=>{const n=e.plot;return{x0:g?Math.min(t.x0,t.x1):n.x,x1:g?Math.max(t.x0,t.x1):n.x+n.w,y0:w?Math.min(t.y0,t.y1):n.y,y1:w?Math.max(t.y0,t.y1):n.y+n.h}},A=()=>{if(!i)return;const t=v(i),n=r.getBoundingClientRect(),o=y.getBoundingClientRect(),c=n.width/e.size.w;Object.assign(i.box.style,{left:n.left-o.left+t.x0*c+"px",top:n.top-o.top+t.y0*c+"px",width:(t.x1-t.x0)*c+"px",height:(t.y1-t.y0)*c+"px"})},b=()=>{i&&(i.box.parentNode&&i.box.parentNode.removeChild(i.box),i=null,p.removeEventListener("keydown",D),u&&(u(),u=null))},T=t=>{if(!(g&&t.x1-t.x0<z)&&!(w&&t.y1-t.y0<z)){for(const n of a){const o=e.scales[n],c=e.orientation(n)==="horizontal"?t.x0:t.y0,q=e.orientation(n)==="horizontal"?t.x1:t.y1;if(o.invert){const x=Number(o.invert(c)),f=Number(o.invert(q)),d=Math.min(x,f),l=Math.max(x,f),[B,R]=o.baseDomain(),$=R<B?[l,d]:[d,l];e.setView(n,l-d>=Math.abs(R-B)*(1-1e-9)?null:$)}else{const x=o.bandwidth,f=o.domain().filter(d=>{const l=o(d);return isFinite(l)&&l+x>=c&&l<=q});if(!f.length)continue;e.setView(n,f.length===o.baseDomain().length?null:f)}}for(const n of L)e.setView(n,e.fit(n,a[0]))}},D=t=>{t.key==="Escape"&&b()},P=t=>{if(t.button!==0||!S(t))return;const n=m(t);if(!M(n))return;const o=p.createElement("div");o.setAttribute("class",j),Object.assign(o.style,{position:"absolute",pointerEvents:"none",boxSizing:"border-box",zIndex:"5",background:"var(--bc-brush-fill, rgba(78,121,167,.22))",border:"1px solid var(--bc-brush-line, rgba(78,121,167,.9))"}),u=e.claimPosition(),y.appendChild(o),i={x0:n.x,y0:n.y,x1:n.x,y1:n.y,box:o},r.setPointerCapture&&r.setPointerCapture(t.pointerId),p.addEventListener("keydown",D),A(),t.preventDefault()},V=t=>{if(!i)return;const n=C(m(t));i.x1=n.x,i.y1=n.y,A()},K=t=>{if(!i)return;const n=C(m(t));i.x1=n.x,i.y1=n.y;const o=v(i);b(),T(o)},N=()=>b(),O=t=>{if(M(m(t))){for(const n of a)e.setView(n,null);for(const n of L)e.setView(n,e.fit(n,a[0]))}};r.addEventListener("pointerdown",P),r.addEventListener("pointermove",V),r.addEventListener("pointerup",K),r.addEventListener("pointercancel",N),r.addEventListener("dblclick",O),e.cleanup(()=>{b(),r.removeEventListener("pointerdown",P),r.removeEventListener("pointermove",V),r.removeEventListener("pointerup",K),r.removeEventListener("pointercancel",N),r.removeEventListener("dblclick",O)})}};k.define(I)})(globalThis.BC);
158
+
159
+
160
+ "use strict";(function(u){const g=()=>u.get("lib.pointer").exports,z=(r,t,f,b)=>u.get("lib.pointer").exports.follow(r,t,f,b);function E(r){const t=u.get(`mark.${r.type}`);return!!(t&&t.series)}const L={role:"interaction",type:"crosshair",version:6,requires:["lib.pointer"],alongX:!0,params:{snap:{kind:"enum",values:["lines","all","off"],default:"lines"},horizontal:{kind:"boolean",default:!1}},attach(r,t){const f=t.host,b=t.root,O=f.ownerDocument||document,T=t.claimPosition(),m=r.snap==="all"||r.snap==="off"?r.snap:"lines",w=(e,s)=>{const o=O.createElement("div");return o.setAttribute("class",e),Object.assign(o.style,s?{position:"absolute",display:"none",pointerEvents:"none",width:"0",marginLeft:"-0.5px",borderLeft:"1px dashed var(--bc-crosshair, var(--bc-axis, #999))"}:{position:"absolute",display:"none",pointerEvents:"none",height:"0",marginTop:"-0.5px",borderTop:"1px dashed var(--bc-crosshair, var(--bc-axis, #999))"}),f.appendChild(o),o},y=w("bc-crosshair",!0),d=r.horizontal===!0?w("bc-crosshair-h",!1):null,x=()=>{y.style.display="none",d&&(d.style.display="none")},C=(e,s)=>{let o=null;for(const n of t.spec.marks){if(m==="lines"&&!E(n))continue;let p,a=null,l=0;try{const i=t.channel(n,"x");if(!i.scale)continue;p=i.mapped,l=i.half;const c=t.channel(n,"y");c.scale&&(a=c.mapped)}catch{continue}const{from:h,to:F}=t.rows(n),{x:k,w:N}=t.plot;for(let i=h;i<F;i++){const c=p[i]+l;if(!isFinite(c)||c<k-.5||c>k+N+.5)continue;const j=Math.abs(c-e);(!o||j<o.d)&&(o={x:c,y:a&&isFinite(a[i])?a[i]:s,d:j})}}return o};z(t,e=>{const s=b.getBoundingClientRect(),o=f.getBoundingClientRect();if(!s.width)return x();const n=s.width/t.size.w,{x:p,y:a}=g().toLogical(t,e),l=t.plot;if(!g().inPlot(t,{x:p,y:a}))return x();const h=m==="off"?{x:p,y:a}:C(p,a);if(!h)return x();Object.assign(y.style,{left:s.left-o.left+h.x*n+"px",top:s.top-o.top+l.y*n+"px",height:l.h*n+"px",display:"block"}),d&&Object.assign(d.style,{top:s.top-o.top+h.y*n+"px",left:s.left-o.left+l.x*n+"px",width:l.w*n+"px",display:"block"})},x,!0),t.cleanup(()=>{for(const e of[y,d])e&&e.parentNode&&e.parentNode.removeChild(e);T()})}};u.define(L)})(globalThis.BC);
161
+
162
+
163
+ "use strict";(function(x){const O="bc-legend-scale",K="bc-legend-index",S="bc-legend-filter",A=s=>s.output==="color"&&s.input==="category",E=(s,o,a)=>{const l=(o.guides||[]).find(m=>typeof m.scale=="string"&&!!a[m.scale]&&A(a[m.scale])),d=typeof s.scale=="string"?s.scale:l?l.scale:void 0;return d&&a[d]&&A(a[d])?d:void 0},T=s=>s.key==="Enter"||s.key===" "||s.key==="Spacebar",I={role:"interaction",type:"legend-filter",version:6,outerLegend:!0,params:{scale:{kind:"scale"},legend:{kind:"string"},fit:{kind:"list"}},toggles:(s,o)=>typeof s.legend=="string"?void 0:E(s,o.spec,o.scales),attach(s,o){const a=typeof s.legend=="string"?s.legend:null,l=E(s,o.spec,o.scales),d=l?o.scales[l]:void 0;if(!l||!d){console.warn('[blockcharts] interaction.legend-filter: needs a categorical color scale (set "scale", or add a legend guide for one); ignored');return}const m=(Array.isArray(s.fit)?s.fit:[]).filter(t=>{const e=typeof t=="string"&&!!o.scales[t]&&t!==l;return!e&&typeof t=="string"&&console.warn(`[blockcharts] interaction.legend-filter: cannot fit scale "${t}"`),e}),i=o.root,c=d.baseDomain(),V=o.host.ownerDocument||document,f=a?V.getElementById(a):null;if(a&&!f)return;const k=()=>o.getView()[l],h=t=>{o.setView(l,t.length===0||t.length===c.length?null:t);for(const e of m)o.setView(e,o.fit(e,l));if(f){const e=t.length?t:c;f.querySelectorAll("[data-bc-legend-index]").forEach(n=>{const r=e.indexOf(c[Number(n.getAttribute("data-bc-legend-index"))])>=0;n.setAttribute("aria-pressed",r?"true":"false")})}},p=t=>{if(f){const r=t.target?.closest?.("[data-bc-legend-index]"),u=r?Number(r.getAttribute("data-bc-legend-index")):NaN;return Number.isInteger(u)&&u>=0&&u<c.length?{value:c[u]}:null}const e=o.dataAt(t);if(!e||e[O]!==l)return null;const n=Number(e[K]);return Number.isInteger(n)&&n>=0&&n<c.length?{value:c[n]}:null};let g=null;const v=t=>{if(t.detail>1)return;const e=p(t);if(!e)return;const n=k();g={shown:n.slice(),at:Date.now()},h(c.filter(r=>r===e.value?n.indexOf(r)<0:n.indexOf(r)>=0))},L=t=>{const e=p(t);if(!e)return;t.preventDefault();const n=g&&Date.now()-g.at<700?g.shown:k();g=null,h(n.length===1&&n[0]===e.value?c.slice():[e.value])},C=t=>{const e=t;if(!T(e)||e.altKey||e.ctrlKey||e.metaKey)return;const n=p(t);if(!n||(t.preventDefault(),e.repeat))return;const r=k();g=null,e.shiftKey?h(r.length===1&&r[0]===n.value?c.slice():[n.value]):h(c.filter(u=>u===n.value?r.indexOf(u)<0:r.indexOf(u)>=0))},b=f||i;b.addEventListener("click",v),b.addEventListener("dblclick",L),b.addEventListener("keydown",C);let y=null;const N=t=>{const e=i.style,n=!!p(t);n&&y===null?(y=e.cursor,e.cursor="pointer"):!n&&y!==null&&(e.cursor=y,y=null)},D=!f&&typeof i.getContext=="function";D&&i.addEventListener("pointermove",N);const w=i.getAttribute("class");i.setAttribute("class",((w||"")+" "+S).trim()),o.cleanup(()=>{b.removeEventListener("click",v),b.removeEventListener("dblclick",L),b.removeEventListener("keydown",C),D&&i.removeEventListener("pointermove",N),w===null?i.removeAttribute?i.removeAttribute("class"):i.setAttribute("class",""):i.setAttribute("class",w)})}};x.define(I)})(globalThis.BC);
164
+
165
+
166
+ "use strict";(function(M){const ht=i=>i==null||i===""||typeof i=="number"&&isNaN(i),bt=/\d|[a-z][A-Z]|_/;function gt(i){if(i==null)return"\u2013";if(typeof i=="number")return isNaN(i)?"\u2013":Number.isInteger(i)?String(i):String(+i.toPrecision(6));const o=String(i);return o.length>80?o.slice(0,79)+"\u2026":o}const Y=()=>M.get("lib.pointer").exports,yt=(i,o,S,H)=>M.get("lib.pointer").exports.follow(i,o,S,H),mt={role:"interaction",type:"tooltip",version:23,requires:["lib.pointer"],params:{fields:{kind:"fields"},formats:{kind:"formats"},labels:{kind:"any"},content:{kind:"any"},heading:{kind:"field"},marker:{kind:"enum",values:["auto","dot","box","none"],default:"auto"}},attach(i,o){const S=o.host,H=o.root,u=S.ownerDocument||document,_={};if(i.formats&&typeof i.formats=="object"&&!Array.isArray(i.formats)){const t=i.formats;for(const n of Object.keys(t))try{_[n]=o.format(t[n])}catch(r){console.warn(`[blockcharts] interaction.tooltip: format of "${n}" ignored: ${r instanceof Error?r.message:String(r)}`)}}else i.formats!==void 0&&console.warn('[blockcharts] interaction.tooltip: "formats" must be an object of field name to format; ignored');const v=o.format("date"),I={};for(const t of Array.isArray(o.spec.transforms)?o.spec.transforms:[]){const n=t&&M.get(`transform.${t.type}`);if(!(!n||typeof n.labels!="function"))try{Object.assign(I,n.labels(t))}catch{}}if(i.labels&&typeof i.labels=="object"&&!Array.isArray(i.labels)){const t=i.labels;for(const n of Object.keys(t))o.table.columns[n]?typeof t[n]!="string"?console.warn(`[blockcharts] interaction.tooltip: label of "${n}" must be text; ignored`):I[n]=t[n]:console.warn(`[blockcharts] interaction.tooltip: label of "${n}" ignored: no such field`)}else i.labels!==void 0&&console.warn('[blockcharts] interaction.tooltip: "labels" must be an object of field name to text; ignored');const G=Array.isArray(i.fields)?i.fields.filter(t=>typeof t=="string"):null,xt=o.claimPosition(),a=u.createElement("div");a.setAttribute("class","bc-tooltip"),a.setAttribute("role","tooltip"),Object.assign(a.style,{position:"absolute",display:"none",pointerEvents:"none",zIndex:"10",boxSizing:"border-box",whiteSpace:"normal",overflowWrap:"anywhere",fontSize:"12px",lineHeight:"1.45",fontVariantNumeric:"tabular-nums",padding:"8px 11px",borderRadius:"10px",background:"var(--bc-tooltip-bg, #fff)",color:"var(--bc-text, #333)",border:"1px solid var(--bc-tooltip-border, rgba(127,127,127,.22))",boxShadow:"var(--bc-tooltip-shadow, 0 10px 28px rgba(15,23,42,.14), 0 2px 6px rgba(15,23,42,.08))"});const b=u.createElement("div");b.setAttribute("class","bc-tooltip-dot"),Object.assign(b.style,{position:"absolute",display:"none",pointerEvents:"none",width:"12px",height:"12px",marginLeft:"-6px",marginTop:"-6px",boxSizing:"border-box",borderRadius:"50%",border:"2.5px solid var(--bc-tooltip-bg, #fff)",background:"var(--bc-text, #333)",boxShadow:"0 1px 4px rgba(15,23,42,.3)"});const j=u.createElement("div");j.setAttribute("class","bc-tooltip-highlight"),Object.assign(j.style,{position:"absolute",display:"none",pointerEvents:"none",boxSizing:"border-box",borderRadius:"3px",background:"var(--bc-tooltip-highlight-fill, rgba(127,127,127,.14))",outline:"1.5px solid var(--bc-tooltip-highlight-line, rgba(127,127,127,.45))",outlineOffset:"-1.5px"});const m=u.createElementNS("http://www.w3.org/2000/svg","svg");m.setAttribute("class","bc-tooltip-flows"),Object.assign(m.style,{position:"absolute",display:"none",pointerEvents:"none"}),S.appendChild(m),S.appendChild(b),S.appendChild(j),S.appendChild(a);const V=i.marker==="dot"||i.marker==="box"||i.marker==="none"?i.marker:"auto";let tt=!1,et=!1;const wt=()=>{const t=i.content;if(typeof t=="function")return t;if(typeof t!="string")return;const n=M.getFn(t);return!n&&!tt&&(tt=!0,console.warn(`[blockcharts] interaction.tooltip: no function "${t}" is registered (BC.defineFn); showing the default content`)),n},kt=t=>!!t&&typeof t=="object"&&typeof t.nodeType=="number",nt=t=>{if(!(t==null||t===!1)){if(typeof t=="string"||typeof t=="number"){if(t==="")return;const n=u.createElement("div");n.textContent=String(t),a.appendChild(n)}else if(Array.isArray(t))t.forEach(nt);else if(kt(t))a.appendChild(t);else if(typeof t.html=="string"){const n=u.createElement("div");n.innerHTML=t.html,a.appendChild(n)}}},X=()=>{a.style.display="none",b.style.display="none",j.style.display="none",m.style.display="none"},N=(t,n)=>{const r=o.table.columns[t][n];return _[t]?_[t](r)||"\u2013":gt(r)};function ot(t){if(typeof i.heading=="string"&&o.table.columns[i.heading])return i.heading;for(const n of["category","date"])for(const r of["x","y"])try{const e=o.channel(t,r);if(e.field&&e.scale&&e.scale.input===n&&o.table.columns[e.field])return e.field}catch{}return null}function st(t,n){for(const[r,e]of[["x","x2"],["y","y2"]])try{const s=o.channel(t,r),d=o.channel(t,e);if(!s.field||!d.field||s.field===d.field||!s.scale||s.scale!==d.scale||s.scale.input==="category"||!o.table.columns[s.field]||!o.table.columns[d.field]||n.indexOf(s.field)<0||n.indexOf(d.field)<0)continue;return{from:s.field,to:d.field,date:s.scale.input==="date"}}catch{}return null}const q=t=>M.get(`mark.${t.type}`);function Z(t,n,r){const e=q(t);if(!e||typeof e.color!="function")return"";try{const s=e.color(t,o,n,r);return typeof s=="string"?s:""}catch{return""}}function L(t,n){const r=[];for(const e of Object.keys(n.channels))try{const s=o.channel(t,e);s.field&&r.push(s.field)}catch{}return typeof t.group=="string"&&r.push(t.group),r}function Et(t,n,r,e,s){const d=Z(t,r,e);if(s===null||L(t,n).includes(s))return d;const p=o.spec.marks;for(let c=p.length-1;c>=0;c--){const x=q(p[c]);if(c===r||!x||!L(p[c],x).includes(s))continue;const h=Z(p[c],c,e);if(h)return h}return d}function it(t,n){const r=new Set;for(const e of Object.keys(n.channels))try{const s=o.channel(t,e);s.field&&s.scale&&s.scale.input==="date"&&r.add(s.field)}catch{}return(e,s)=>!_[e]&&r.has(e)&&v(o.table.columns[e][s])||N(e,s)}function At(t,n,r,e,s){const d=[],p=[],c=new Set(s),x=it(t,n),h=w=>{const $=o.table.columns[w];if(!$||c.has(w)||(c.add(w),ht($[r])))return;const k=x(w,r);e.some(T=>x(w,T)!==k)||(d.push([I[w]||w,k]),p.push(w))};return(G||L(t,n)).forEach(h),{lines:d,fields:p}}function Ot(t){const n=Y().toLogical(o,t);if(!Y().inPlot(o,n,12))return X();let r=null;if(o.spec.marks.forEach((f,l)=>{const g=M.get(`mark.${f.type}`);if(!g||!g.pick)return;let y=null;try{y=g.pick(f,o,l,n.x,n.y)}catch{return}y&&isFinite(y.dist)&&(!r||y.dist<=r.pick.dist)&&(r={pick:y,mark:f,def:g,index:l})}),!r)return X();const{pick:e,mark:s,def:d,index:p}=r,c=e.card,x=e.rows&&e.rows.length>1?e.rows:[e.row],h=c?null:ot(s),w=typeof i.heading=="string"&&!!o.table.columns[i.heading],$=c||w?null:st(s,G||L(s,d)),k=$&&(!h||h===$.from||h===$.to)?$:null,T=c?N:it(s,d),E=k&&x.every(f=>T(k.from,f)===T(k.from,e.row)&&T(k.to,f)===T(k.to,e.row))?k:null,O=!k&&h&&x.every(f=>N(h,f)===N(h,e.row))?h:null,rt=c?{lines:c.lines,fields:[]}:At(s,d,e.row,x,E?[E.from,E.to]:[]),J=rt.lines,lt=O?I[O]||O:null;let z;const at=c?void 0:wt();if(at){const f={};for(const l of Object.keys(o.table.columns))f[l]=o.table.columns[l][e.row];try{z=at({row:e.row,values:f,rows:x,lines:J,mark:s,markIndex:p,x:e.x,y:e.y,table:o.table})}catch(l){et||(et=!0,console.error("[blockcharts] interaction.tooltip: the content function threw, showing the default content:",l)),z=void 0}}if(z===null||z===!1)return X();a.textContent="";const Ct=Z(s,p,e.row),ct=rt.fields.find((f,l)=>J[l][0]!==lt),ft=c?c.color||"":Et(s,d,p,e.row,G&&ct!==void 0?ct:null);if(z===void 0){if(O||c||E){const l=u.createElement("div");if(l.setAttribute("class","bc-tooltip-heading"),O?l.setAttribute("data-bc-field",O):E&&l.setAttribute("data-bc-field",`${E.from} ${E.to}`),Object.assign(l.style,{display:"flex",alignItems:"center",gap:"7px",fontWeight:"600",marginBottom:"4px"}),ft){const F=u.createElement("span");F.setAttribute("class","bc-tooltip-swatch"),Object.assign(F.style,{width:"8px",height:"8px",borderRadius:"50%",background:ft,boxShadow:"inset 0 0 0 1px var(--bc-tooltip-highlight-line, rgba(127,127,127,.45))",flex:"none"}),l.appendChild(F)}const g=u.createElement("span"),y=o.table.columns[O],D=(()=>{for(const F of["x","y"])try{const W=o.channel(s,F);if(W.field===O&&W.scale&&W.scale.input==="date")return!0}catch{}return!1})(),U=O;if(c)g.textContent=c.title;else if(E){const F=[T(E.from,e.row),T(E.to,e.row)];g.textContent=F.join(F.some(W=>W.indexOf(" ")>=0)?" \u2013 ":"\u2013")}else g.textContent=!_[U]&&D&&v(y[e.row])||N(U,e.row);l.appendChild(g),a.appendChild(l)}const f=u.createElement("div");f.setAttribute("class","bc-tooltip-lines"),Object.assign(f.style,{display:"grid",gridTemplateColumns:"auto auto",columnGap:"16px",rowGap:"1px"});for(const[l,g]of J){if(l===lt)continue;const y=u.createElement("span");y.textContent=l,y.style.opacity="0.68";const D=u.createElement("span");D.textContent=g,Object.assign(D.style,{textAlign:"right",fontWeight:"600"}),f.appendChild(y),f.appendChild(D)}f.children.length&&a.appendChild(f)}else nt(z);if(!(a.childNodes?a.childNodes.length>0:a.children.length>0))return X();const C=H.getBoundingClientRect(),A=S.getBoundingClientRect(),R=C.width/o.size.w,P=C.left-A.left+e.x*R,B=C.top-A.top+e.y*R;m.textContent="";for(const f of e.flows||[]){const l=u.createElementNS("http://www.w3.org/2000/svg","path");l.setAttribute("d",f.d),l.setAttribute("fill",f.fill),l.setAttribute("fill-opacity","0.5"),m.appendChild(l)}e.flows&&e.flows.length?(m.setAttribute("viewBox",`0 0 ${o.size.w} ${o.size.h}`),Object.assign(m.style,{left:C.left-A.left+"px",top:C.top-A.top+"px",width:C.width+"px",height:C.height+"px",display:"block"})):m.style.display="none",(V==="box"||V==="auto"&&!!e.box)&&e.box?(Object.assign(j.style,{left:C.left-A.left+e.box.x*R+"px",top:C.top-A.top+e.box.y*R+"px",width:Math.max(0,e.box.w*R)+"px",height:Math.max(0,e.box.h*R)+"px",display:"block"}),b.style.display="none"):V!=="none"?(b.style.left=P+"px",b.style.top=B+"px",b.style.background=Ct||"var(--bc-text, #333)",b.style.display="block",j.style.display="none"):(b.style.display="none",j.style.display="none");const K=u.defaultView||globalThis,Q=Math.max(0,-A.left),dt=typeof K.innerWidth=="number"&&K.innerWidth>0?Math.min(A.width,K.innerWidth-A.left):A.width;a.style.display="block",a.style.maxWidth=Math.max(120,dt-Q)+"px",a.style.left=Q+"px";const pt=a.offsetWidth||0,ut=a.offsetHeight||0,St=P+12+pt>dt?P-12-pt:P+12,jt=B-12-ut>=0?B-12-ut:B+12;a.style.left=Math.max(Q,St)+"px",a.style.top=Math.max(0,jt)+"px"}if(i.content===void 0&&o.table){const t=[];for(const n of o.spec.marks){const r=q(n);if(!r||!r.pick)continue;const e=G||L(n,r),s=ot(n),d=typeof i.heading=="string"?null:st(n,e);for(const p of e)p===s||d&&(p===d.from||p===d.to)||!I[p]&&bt.test(p)&&o.table.columns[p]&&t.indexOf(p)<0&&t.push(p)}t.length&&console.warn(`[blockcharts] interaction.tooltip: the card shows ${t.map(n=>`"${n}"`).join(", ")} under ${t.length>1?"their own names; give them names":"its own name; give it a name"} a reader knows in "labels"`)}yt(o,Ot,X),o.cleanup(()=>{for(const t of[a,b,j,m])t.parentNode&&t.parentNode.removeChild(t);xt()})}};M.define(mt)})(globalThis.BC);
167
+
168
+
169
+ "use strict";(function(p){const h=()=>p.get("lib.pointer").exports,y=()=>p.get("lib.view").exports,A={role:"interaction",type:"zoom",version:7,requires:["lib.pointer","lib.view"],params:{scales:{kind:"list",default:["x"]},wheel:{kind:"enum",values:["ctrl","always","off"],default:"ctrl"},fit:{kind:"list"},pan:{kind:"boolean",default:!0},maxZoom:{kind:"number",default:50}},attach(r,e){const a=(Array.isArray(r.scales)?r.scales.filter(t=>typeof t=="string"):["x"]).filter(t=>{const o=!!e.scales[t]&&!!e.scales[t].invert&&e.orientation(t)!==null;return o||console.warn(`[blockcharts] interaction.zoom: scale "${t}" is not a continuous positional scale, ignored`),o});if(!a.length)return;const q=(Array.isArray(r.fit)?r.fit:[]).filter(t=>{const o=typeof t=="string"&&!!e.scales[t]&&a.indexOf(t)<0;return!o&&typeof t=="string"&&console.warn(`[blockcharts] interaction.zoom: cannot fit scale "${t}"`),o}),w=()=>{for(const t of q)e.setView(t,e.fit(t,a[0]))},L=r.wheel==="always"||r.wheel==="off"?r.wheel:"ctrl",C=r.pan!==!1,D=typeof r.maxZoom=="number"&&r.maxZoom>1?r.maxZoom:50,n=e.root,f=t=>h().toLogical(e,t),b=t=>h().inPlot(e,t),M=(t,o)=>e.orientation(t)==="horizontal"?o.x:o.y,k=t=>y().current(e,t),E=t=>{if(L==="off"||L==="ctrl"&&!(t.ctrlKey||t.metaKey))return;const o=f(t);if(!b(o))return;t.preventDefault();const s=t.deltaMode===1?t.deltaY*16:t.deltaY,i=Math.exp(s*.002);for(const c of a){const[u,g]=k(c),[x,m]=e.scales[c].range();y().zoom(e,c,i,D,u+(M(c,o)-x)/(m-x)*(g-u))}w()};let l=null;const z=t=>{if(t.button!==0||e.dragClaimed(t))return;const o=f(t);if(!b(o))return;const s={};for(const i of a)s[i]=k(i);l={x:o.x,y:o.y,start:s},n.setPointerCapture&&n.setPointerCapture(t.pointerId),n.style.cursor="grabbing"},P=t=>{if(!l)return;const o=f(t);for(const s of a){const[i,c]=l.start[s],[u,g]=e.scales[s].range(),m=-(e.orientation(s)==="horizontal"?o.x-l.x:o.y-l.y)/(g-u)*(c-i);y().show(e,s,i+m,c+m)}w()},d=()=>{l=null,n.style.cursor="grab"},Z=t=>{if(b(f(t))){for(const o of a)e.setView(o,null);w()}};n.addEventListener("wheel",E,{passive:!1}),n.addEventListener("dblclick",Z),C&&(n.addEventListener("pointerdown",z),n.addEventListener("pointermove",P),n.addEventListener("pointerup",d),n.addEventListener("pointercancel",d),n.style.cursor="grab"),e.cleanup(()=>{n.removeEventListener("wheel",E),n.removeEventListener("dblclick",Z),n.removeEventListener("pointerdown",z),n.removeEventListener("pointermove",P),n.removeEventListener("pointerup",d),n.removeEventListener("pointercancel",d),n.style.cursor=""})}};p.define(A)})(globalThis.BC);
170
+
171
+
172
+ "use strict";(function(u){const k=()=>u.get("lib.view").exports,w={role:"interaction",type:"zoom-controls",version:6,requires:["lib.view"],params:{scales:{kind:"list",default:["x"]},fit:{kind:"list"},step:{kind:"number",default:.5},maxZoom:{kind:"number",default:50},titles:{kind:"any"},corner:{kind:"enum",values:["top-right","top-left","bottom-right","bottom-left"],default:"top-right"}},corner(o,e){const[b,r]=(typeof o.corner=="string"?o.corner:"top-right").split("-"),f=(Array.isArray(o.scales)?o.scales:["x"]).some(a=>typeof a=="string"&&!!e.scales[a]&&!!e.scales[a].invert);return{edge:b,side:r,width:f?120:64}},attach(o,e){const r=(Array.isArray(o.scales)?o.scales.filter(t=>typeof t=="string"):["x"]).filter(t=>{const n=e.scales[t],c=!!n&&e.orientation(t)!==null&&(!!n.invert||n.bandwidth!==void 0);return c||console.warn(`[blockcharts] interaction.zoom-controls: scale "${t}" is not a positional scale, ignored`),c});if(!r.length)return;const l=r.filter(t=>!!e.scales[t].invert),f=(Array.isArray(o.fit)?o.fit:[]).filter(t=>{const n=typeof t=="string"&&!!e.scales[t]&&r.indexOf(t)<0;return!n&&typeof t=="string"&&console.warn(`[blockcharts] interaction.zoom-controls: cannot fit scale "${t}"`),n}),a=()=>{for(const t of f)e.setView(t,e.fit(t,r[0]))},p=typeof o.step=="number"&&o.step>0&&o.step<1?o.step:.5,A=typeof o.maxZoom=="number"&&o.maxZoom>1?o.maxZoom:50,z=o.corner==="top-left"||o.corner==="bottom-right"||o.corner==="bottom-left"?o.corner:"top-right",[v,E]=z.split("-"),T=()=>{for(const t of r)e.setView(t,null);a()},g=t=>{for(const n of l)k().zoom(e,n,t,A);a()},h=e.host,x=h.ownerDocument||document,i=x.createElement("div");i.setAttribute("class","bc-zoom-controls"),Object.assign(i.style,{position:"absolute",[v]:"8px",[E]:"8px",zIndex:"6",display:"flex",gap:"4px",font:"12px/1 system-ui, sans-serif"});const d=(t,n,c)=>{const s=x.createElement("button");return s.type="button",s.textContent=t,s.setAttribute("aria-label",n),s.title=n,Object.assign(s.style,{minWidth:"22px",height:"22px",padding:"0 6px",lineHeight:"20px",textAlign:"center",border:"1px solid var(--bc-axis, #ccc)",borderRadius:"4px",cursor:"pointer",whiteSpace:"nowrap",background:"var(--bc-tooltip-bg, #fff)",color:"var(--bc-text, #333)"}),s.addEventListener("click",D=>{D.preventDefault(),c()}),i.appendChild(s),s},y=o.titles&&typeof o.titles=="object"?o.titles:{},m=(t,n)=>typeof y[t]=="string"?y[t]:n;d("100%",m("reset","Reset zoom to the full range"),T),l.length&&(d("\u2212",m("out","Zoom out"),()=>g(1/p)),d("+",m("in","Zoom in"),()=>g(p)));const Z=e.claimPosition();h.appendChild(i),e.cleanup(()=>{i.parentNode&&i.parentNode.removeChild(i),Z()})}};u.define(w)})(globalThis.BC);
173
+
174
+
175
+ "use strict";(function(W){const S='system-ui, -apple-system, "Segoe UI", sans-serif',z=Math.PI*2,C={role:"renderer",type:"canvas",version:4,render(v,d){const b=d.ownerDocument||document,a=b.createElement("canvas");a.setAttribute("role","img"),a.setAttribute("style","display:block;width:100%;height:auto");const O=a.getContext("2d");if(!O)throw new Error("renderer.canvas: this environment has no 2D canvas context");const t=O;let h=v,k=new Map,A=S,u=null,L=!1;const $=e=>{t.fillStyle="#010203",t.fillStyle=e;const n=t.fillStyle;return t.fillStyle="#040506",t.fillStyle=e,n===t.fillStyle},R=e=>u&&typeof u.getPropertyValue=="function"?u.getPropertyValue(e).trim():"",T=e=>{const n=k.get(e);if(n!==void 0)return n;let r=e.trim();for(let o=0;o<8;o++){const s=/^var\(\s*(--[^\s,)]+)\s*(?:,([\s\S]*))?\)$/.exec(r);if(!s)break;r=R(s[1])||(s[2]!==void 0?s[2].trim():"")}let i=null;return r&&r!=="none"&&(r.toLowerCase()==="currentcolor"&&(r=u&&u.color||"#000"),$(r)&&(i=r)),k.set(e,i),i},_=e=>{t.fillStyle=e;const n=String(t.fillStyle),r=/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(n);if(r)return`rgba(${parseInt(r[1],16)}, ${parseInt(r[2],16)}, ${parseInt(r[3],16)}, 0)`;const i=/^rgba?\(([^,]+),([^,]+),([^,)]+)/.exec(n);return i?`rgba(${i[1].trim()}, ${i[2].trim()}, ${i[3].trim()}, 0)`:"rgba(0, 0, 0, 0)"},j=e=>{const n=h.plot,r=t.createLinearGradient(0,n.y,0,n.y+n.h);return r.addColorStop(0,e),r.addColorStop(1,_(e)),r},F=e=>`${e.weight===void 0?"normal":String(e.weight)} ${e.size===void 0?12:e.size}px ${A}`,D=e=>{t.font=F(e),t.textAlign=e.anchor==="middle"?"center":e.anchor==="end"?"right":"left",t.textBaseline=e.baseline==="middle"?"middle":e.baseline==="hanging"?"hanging":"alphabetic"},U=(e,n,r,i,o)=>{const s=Math.max(0,Math.min(o,r/2,i/2));if(t.beginPath(),typeof t.roundRect=="function"){t.roundRect(e,n,r,i,s);return}t.moveTo(e+s,n),t.arcTo(e+r,n,e+r,n+i,s),t.arcTo(e+r,n+i,e,n+i,s),t.arcTo(e,n+i,e,n,s),t.arcTo(e,n,e+r,n,s),t.closePath()},E=(e,n,r)=>{const i=e.style||{},o={fill:i.fill!==void 0?i.fill:r.fill,stroke:i.stroke!==void 0?i.stroke:r.stroke,strokeWidth:i.strokeWidth!==void 0?i.strokeWidth:r.strokeWidth,strokeDash:i.strokeDash!==void 0?i.strokeDash:r.strokeDash,fillOpacity:i.fillOpacity!==void 0?i.fillOpacity:r.fillOpacity,strokeLinejoin:i.strokeLinejoin!==void 0?i.strokeLinejoin:r.strokeLinejoin,strokeLinecap:i.strokeLinecap!==void 0?i.strokeLinecap:r.strokeLinecap,paintOrder:i.paintOrder!==void 0?i.paintOrder:r.paintOrder},s=n*(i.opacity===void 0?1:i.opacity);if(e.type==="g"){t.save(),e.translate&&t.translate(e.translate[0],e.translate[1]),e.clip&&(t.beginPath(),t.rect(e.clip.x,e.clip.y,e.clip.w,e.clip.h),t.clip());for(const f of e.children)E(f,s,o);t.restore();return}const l=o.fill===void 0?"#000":T(o.fill),c=o.stroke===void 0?null:T(o.stroke);t.lineWidth=o.strokeWidth===void 0?1:o.strokeWidth,t.setLineDash(o.strokeDash||[]),t.lineJoin=o.strokeLinejoin||"miter",t.lineCap=o.strokeLinecap||"butt";const w=o.paintOrder==="stroke",M=f=>{const B=()=>{l&&(t.globalAlpha=s*(o.fillOpacity===void 0?1:o.fillOpacity),t.fillStyle=i.fade?j(l):l,f?t.fill(f):t.fill())},I=()=>{c&&(t.globalAlpha=s,t.strokeStyle=c,f?t.stroke(f):t.stroke())};w&&I(),B(),w||I()};switch(e.type){case"path":M(new Path2D(e.d));break;case"rect":e.r?U(e.x,e.y,e.w,e.h,e.r):(t.beginPath(),t.rect(e.x,e.y,e.w,e.h)),M();break;case"circle":t.beginPath(),t.arc(e.cx,e.cy,e.r,0,z),M();break;case"text":D(e),t.save(),t.translate(e.x,e.y),e.rotate&&t.rotate(e.rotate*Math.PI/180);for(const f of w?["stroke","fill"]:["fill","stroke"])f==="fill"&&l?(t.globalAlpha=s*(o.fillOpacity===void 0?1:o.fillOpacity),t.fillStyle=l,t.fillText(e.text,0,0)):f==="stroke"&&c&&(t.globalAlpha=s,t.strokeStyle=c,t.strokeText(e.text,0,0));t.restore();break}t.globalAlpha=1},x=e=>{if(L)return;h=e,e.label?a.setAttribute("aria-label",e.label):a.removeAttribute("aria-label"),k=new Map,u=typeof getComputedStyle=="function"?getComputedStyle(d):null,A=u&&u.fontFamily||S;const n=d.clientWidth||e.size.w,r=Math.min(3,Math.max(1,globalThis.devicePixelRatio||1)),i=Math.max(1,Math.min(16384,Math.round(n*r))),o=i/e.size.w,s=Math.max(1,Math.min(16384,Math.round(e.size.h*o)));a.width=i,a.height=s,t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,i,s),t.setTransform(o,0,0,o,0,0);for(const l of e.layers){t.save(),l.clip&&(t.beginPath(),t.rect(l.clip.x,l.clip.y,l.clip.w,l.clip.h),t.clip());for(const c of l.prims)E(c,1,{});t.restore()}},P=e=>{switch(e.type){case"rect":return[e.x,e.y,e.x+e.w,e.y+e.h];case"circle":return[e.cx-e.r,e.cy-e.r,e.cx+e.r,e.cy+e.r];case"text":{D(e);const n=t.measureText(e.text).width,r=e.size===void 0?12:e.size,i=e.anchor==="middle"?e.x-n/2:e.anchor==="end"?e.x-n:e.x,o=e.baseline==="middle"?e.y-r/2:e.baseline==="hanging"?e.y:e.y-r;return[i,o,i+n,o+r]}case"g":{let n=null;for(const i of e.children){const o=P(i);o&&(n=n?[Math.min(n[0],o[0]),Math.min(n[1],o[1]),Math.max(n[2],o[2]),Math.max(n[3],o[3])]:o)}const r=e.translate||[0,0];return n?[n[0]+r[0],n[1]+r[1],n[2]+r[0],n[3]+r[1]]:null}default:return null}},p=(e,n,r)=>{if(e.type==="g"){const o=e.translate||[0,0];for(let s=e.children.length-1;s>=0;s--){const l=p(e.children[s],n-o[0],r-o[1]);if(l)return l}}if(!e.data)return null;const i=P(e);return i&&n>=i[0]&&n<=i[2]&&r>=i[1]&&r<=i[3]?Object.assign({},e.data):null},X=e=>{const n=a.getBoundingClientRect();if(!n.width||!n.height)return null;const r=(e.clientX-n.left)*h.size.w/n.width,i=(e.clientY-n.top)*h.size.h/n.height;for(let o=h.layers.length-1;o>=0;o--){const s=h.layers[o].prims;for(let l=s.length-1;l>=0;l--){const c=p(s[l],r,i);if(c)return c}}return null},g=[],m=()=>x(h),y=globalThis;if(typeof y.ResizeObserver=="function"){let e=d.clientWidth;const n=new y.ResizeObserver(()=>{d.clientWidth!==e&&(e=d.clientWidth,m())});n.observe(d),g.push(()=>n.disconnect())}if(typeof y.matchMedia=="function"){const e=y.matchMedia("(prefers-color-scheme: dark)");e&&typeof e.addEventListener=="function"&&(e.addEventListener("change",m),g.push(()=>e.removeEventListener("change",m)))}if(typeof y.MutationObserver=="function"&&b.documentElement){const e=new y.MutationObserver(m);e.observe(b.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),g.push(()=>e.disconnect())}return x(v),d.appendChild(a),{root:a,update:x,dataAt:X,destroy(){L=!0;for(const e of g)e();a.parentNode&&a.parentNode.removeChild(a)}}}};W.define(C)})(globalThis.BC);
176
+
177
+
178
+ "use strict";(function(k){const x="http://www.w3.org/2000/svg";let w=0,m=0;function s(e){return document.createElementNS(x,e)}function r(e,i,t){t!==void 0&&e.setAttribute(i,String(t))}function C(e,i,t){const n=e+"|"+i,l=t.fades.get(n);if(l)return l;const o=`bc-fade-${++m}`,a=s("linearGradient");a.setAttribute("id",o),a.setAttribute("gradientUnits","userSpaceOnUse"),a.setAttribute("x1","0"),a.setAttribute("x2","0"),r(a,"y1",t.plot.y),r(a,"y2",t.plot.y+t.plot.h);for(const[b,c]of[[0,i],[1,0]]){const f=s("stop");f.setAttribute("offset",String(b)),f.setAttribute("style",`stop-color:${e.replace(/[;{}<>]/g,"")};stop-opacity:${c}`),a.appendChild(f)}t.defs.appendChild(a);const u=`url(#${o})`;return t.fades.set(n,u),u}function $(e,i,t){i&&(i.fill!==void 0&&i.fade&&i.fill!=="none"?e.setAttribute("fill",C(i.fill,i.fillOpacity===void 0?1:i.fillOpacity,t)):i.fill!==void 0&&e.setAttribute("fill",i.fill),i.stroke!==void 0&&e.setAttribute("stroke",i.stroke),r(e,"stroke-width",i.strokeWidth),i.strokeDash&&e.setAttribute("stroke-dasharray",i.strokeDash.join(" ")),r(e,"opacity",i.opacity),i.fade||r(e,"fill-opacity",i.fillOpacity),i.strokeLinejoin&&e.setAttribute("stroke-linejoin",i.strokeLinejoin),i.strokeLinecap&&e.setAttribute("stroke-linecap",i.strokeLinecap),i.paintOrder&&e.setAttribute("paint-order",i.paintOrder))}function y(e,i,t){const n=`bc-clip-${++w}`,l=s("clipPath");l.setAttribute("id",n);const o=s("rect");r(o,"x",i.x),r(o,"y",i.y),r(o,"width",i.w),r(o,"height",i.h),l.appendChild(o),t.appendChild(l),e.setAttribute("clip-path",`url(#${n})`)}function g(e,i){let t;switch(e.type){case"path":t=s("path"),t.setAttribute("d",e.d);break;case"rect":t=s("rect"),r(t,"x",e.x),r(t,"y",e.y),r(t,"width",e.w),r(t,"height",e.h),r(t,"rx",e.r);break;case"circle":t=s("circle"),r(t,"cx",e.cx),r(t,"cy",e.cy),r(t,"r",e.r);break;case"text":t=s("text"),r(t,"x",e.x),r(t,"y",e.y),r(t,"font-size",e.size),e.weight!==void 0&&t.setAttribute("font-weight",String(e.weight)),e.anchor&&t.setAttribute("text-anchor",e.anchor),e.baseline&&t.setAttribute("dominant-baseline",e.baseline),e.rotate&&t.setAttribute("transform",`rotate(${e.rotate} ${e.x} ${e.y})`),t.textContent=e.text;break;case"g":t=s("g"),e.translate&&t.setAttribute("transform",`translate(${e.translate[0]} ${e.translate[1]})`),e.clip&&y(t,e.clip,i.defs);for(const n of e.children)t.appendChild(g(n,i));break}if($(t,e.style,i),e.cls&&t.setAttribute("class",e.cls),e.data)for(const n of Object.keys(e.data))t.setAttribute("data-"+n,e.data[n]);if(e.ref&&(t.setAttribute("data-bc-mark",String(e.ref.mark)),t.setAttribute("data-bc-row",String(e.ref.row))),e.pressed!==void 0&&(t.setAttribute("tabindex","0"),t.setAttribute("role","button"),t.setAttribute("aria-pressed",e.pressed?"true":"false"),i.controls.push(t)),e.title){const n=s("title");n.textContent=e.title,t.appendChild(n)}return t}const S={role:"renderer",type:"svg",version:6,render(e,i){const t=s("svg");t.setAttribute("width","100%"),t.setAttribute("role","img"),t.setAttribute("style","display:block;height:auto");let n=[];const l=o=>{const a=t.ownerDocument||(typeof document>"u"?null:document),u=a&&a.activeElement?n.indexOf(a.activeElement):-1;t.textContent="",t.setAttribute("viewBox",`0 0 ${o.size.w} ${o.size.h}`);const b=s("defs");t.appendChild(b);const c={defs:b,plot:o.plot,fades:new Map,controls:[]},f=[];for(const d of o.layers){const h=s("g");h.setAttribute("data-bc-layer",d.name),d.clip&&y(h,d.clip,b);for(const v of d.prims){const O=c.controls.length,p=g(v,c);c.controls.length===O&&f.push(p),h.appendChild(p)}t.appendChild(h)}if(n=c.controls,t.setAttribute("role",n.length?"group":"img"),n.length)for(const d of f)d.setAttribute("aria-hidden","true");o.label?t.setAttribute("aria-label",o.label):t.removeAttribute("aria-label");const A=u>=0?n[u]:void 0;A&&typeof A.focus=="function"&&A.focus({preventScroll:!0})};return l(e),i.appendChild(t),{root:t,update:l,destroy(){t.parentNode&&t.parentNode.removeChild(t)}}}};k.define(S)})(globalThis.BC);
179
+
180
+
181
+ if (typeof module === 'object' && module && typeof module.exports === 'object') module.exports = globalThis.BC;