python-plotto 0.5.0__tar.gz → 0.5.2__tar.gz
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.
- {python_plotto-0.5.0/python_plotto.egg-info → python_plotto-0.5.2}/PKG-INFO +1 -1
- {python_plotto-0.5.0 → python_plotto-0.5.2}/plotto/__init__.py +1 -1
- python_plotto-0.5.2/plotto/_assets/plotto.js +35 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/plotto/_assets/theme.json +9 -6
- {python_plotto-0.5.0 → python_plotto-0.5.2/python_plotto.egg-info}/PKG-INFO +1 -1
- python_plotto-0.5.0/plotto/_assets/plotto.js +0 -35
- {python_plotto-0.5.0 → python_plotto-0.5.2}/LICENSE +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/README.md +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/plotto/_assets/grammar.json +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/plotto/assets.py +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/plotto/data.py +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/plotto/output.py +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/plotto/plot.py +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/pyproject.toml +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/python_plotto.egg-info/SOURCES.txt +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/python_plotto.egg-info/dependency_links.txt +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/python_plotto.egg-info/requires.txt +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/python_plotto.egg-info/top_level.txt +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/setup.cfg +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/tests/test_builder.py +0 -0
- {python_plotto-0.5.0 → python_plotto-0.5.2}/tests/test_output.py +0 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var H={options:{size:"number",alpha:"number",dash:["solid","dashed","dotted","dashdot"],jitter:"number",summary:["mean","median","min","max","sum"],slope:"number",intercept:"number",position:["stack","dodge","overlay"],bins:"number",density:"boolean",method:["lm","loess"],span:"number",band:"boolean"},layers:{line:{channels:["x","y","color","group","tooltip"],options:["size","alpha","dash","summary"],requires:["x","y"]},path:{channels:["x","y","color","group","tooltip"],options:["size","alpha","dash"],requires:["x","y"]},step:{channels:["x","y","color","group","tooltip"],options:["size","alpha","dash"],requires:["x","y"]},point:{channels:["x","y","color","tooltip"],options:["size","alpha","jitter","summary"],requires:["x","y"]},bar:{channels:["x","y","color","tooltip"],options:["alpha","position"],requires:["x","y"]},hist:{channels:["x","color"],options:["alpha","bins","density","position"],requires:["x"]},density:{channels:["x","color"],options:["size","alpha","dash"],requires:["x"]},area:{channels:["x","y","color","group"],options:["alpha","position"],requires:["x","y"]},ribbon:{channels:["x","ymin","ymax","color","group"],options:["alpha"],requires:["x","ymin","ymax"]},smooth:{channels:["x","y","color"],options:["size","alpha","dash","method","span","band"],requires:["x","y"]},hline:{channels:["y","color"],options:["size","alpha","dash"],requires:["y"],inherit:!1},vline:{channels:["x","color"],options:["size","alpha","dash"],requires:["x"],inherit:!1},abline:{channels:["color"],options:["slope","intercept","size","alpha","dash"],requires:[],inherit:!1},segment:{channels:["x","y","xend","yend","color"],options:["size","alpha","dash"],requires:["x","y","xend","yend"]},rect:{channels:["xmin","xmax","ymin","ymax","color","tooltip"],options:["alpha"],requires:["xmin","xmax","ymin","ymax"]},band:{channels:["xmin","xmax","ymin","ymax","color"],options:["alpha"],requires:[],inherit:!1},tile:{channels:["x","y","color","tooltip"],options:["alpha"],requires:["x","y","color"]},text:{channels:["x","y","label","color"],options:["size","alpha"],requires:["x","y","label"]},errorbar:{channels:["x","ymin","ymax","color"],options:["size","alpha"],requires:["x","ymin","ymax"]},box:{channels:["x","y","color"],options:["alpha"],requires:["x","y"]}},scales:{x:["type","limits","format"],y:["type","limits","format"],color:["values","palette","scheme","limits","mid","clamp"]},scaleTypes:["linear","log","time","category"],facet:["free","ncol"],grid:["free"],free:["x","y","both"],labels:["title","subtitle","x","y","color","caption"],theme:["format","width","height","size","legend","aspect"],legend:["right","bottom","none"],info:["position"],infoPosition:["right","bottom"]};var I={styles:{pastel:{font:"Helvetica, Arial, 'Liberation Sans', sans-serif",metrics:"arial",background:"#FFFEFB",ink:"#3A3631",muted:"#7A736A",grid:"#ECE8E1",gridMinor:"#F6F3EE",tick:"#D6D0C6",strip:"#F4F0E9",accent:"#3E8A99",palette:"pastel",scheme:"ai",colors:{blue:"#7AA6DA",orange:"#EF977F",green:"#7DB89A",purple:"#A79BD6",pink:"#E48FAE",yellow:"#DDB459",teal:"#63B7C1",red:"#CF7468",brown:"#BB9C84",gray:"#97A1AD"},weight:1.25},wota:{font:"'M PLUS 1p', sans-serif",metrics:"mplus",ink:"#333333",muted:"#666666",grid:"#D9D9D9",gridMinor:"#EFEFEF",tick:"#BBBBBB",strip:"#EEF1FA",accent:"#5C6BC0",palette:"wota",scheme:"sakura",colors:{pink:"#E4007F",blue:"#5C6BC0",teal:"#00A3A3",orange:"#F5A623",purple:"#8E44AD",gray:"#7F7F7F",green:"#3BA55C",red:"#D7263D",yellow:"#F2C14E",brown:"#8D6E63"},weight:1,background:"#FFFFFF"},paper:{ink:"#000000",muted:"#333333",grid:"#E6E6E6",gridMinor:"#F5F5F5",tick:"#8C8C8C",strip:"#EBEBEB",accent:"#0072B2",palette:["blue","orange","green","pink","yellow","teal","red","brown","purple","gray"],scheme:"viridis",colors:{blue:"#0072B2",orange:"#E69F00",green:"#009E73",pink:"#CC79A7",yellow:"#F0E442",teal:"#56B4E9",red:"#D55E00",brown:"#8C6D31",purple:"#6A3D9A",gray:"#7F7F7F"},weight:1,background:"#FFFFFF"},dark:{background:"#16181D",ink:"#E8EAED",muted:"#A6ABB3",grid:"#2E323A",gridMinor:"#22252B",tick:"#4F5560",strip:"#252933",accent:"#8AB4F8",palette:["blue","orange","green","purple","pink","yellow","teal","red","brown","gray"],scheme:"yuhi",colors:{blue:"#8AB4F8",orange:"#FBA94C",green:"#81C995",purple:"#C58AF9",pink:"#FF8BCB",yellow:"#FDD663",teal:"#78D9D3",red:"#F28B82",brown:"#C8A27A",gray:"#9AA0A6"},weight:1.15}},palettes:{pastel:["#7AA6DA","#EF977F","#7DB89A","#A79BD6","#E48FAE","#DDB459","#63B7C1","#CF7468","#BB9C84","#97A1AD"],wota:["#E4007F","#5C6BC0","#00A3A3","#F5A623","#8E44AD","#7F7F7F","#3BA55C","#D7263D","#F2C14E","#8D6E63"],sakura:["#E16B8C","#5DAC81","#8B81C3","#FFB11B","#7DB9DE","#F596AA","#B9887D","#91AD70"],aizome:["#0F2540","#51A8DD","#66BAB7","#656765","#0D5661","#A5DEE4","#7B90D2"],momiji:["#CB4042","#FFB11B","#6C6A2D","#6D2E5B","#ED784A","#734338","#C99833"],tableau:["#4E79A7","#F28E2B","#E15759","#76B7B2","#59A14F","#EDC948","#B07AA1","#FF9DA7","#9C755F","#BAB0AC"]},schemes:{ai:["#F4F8F8","#A5DEE4","#33A6B8","#0D5661","#0F2540"],sakura:["#FEF4F4","#FEDFE1","#F596AA","#D05A6E","#8E354A","#4A1D30"],matcha:["#F8F6E3","#D7E3B5","#91AD70","#5DAC81","#1B813E","#0B3B2A"],yuhi:["#FFF3D6","#FFB11B","#ED784A","#CB4042","#6D2E5B","#26113A"],sumi:["#FCFAF2","#BDC0BA","#828282","#434343","#1C1C1C"],aiaka:["#0F2540","#33A6B8","#A5DEE4","#F7F6F0","#F4A7A0","#CB4042","#5C1A1B"]},formats:{screen:{width:900,height:500,size:12,line:1.5,point:2.5,reflow:!0},report:{width:640,height:400,size:10,line:1.2,point:2,reflow:!1},slide:{width:691,height:403,size:13,shrink:.8,line:1.6,point:2.7,pad:.3,flat:.55,legend:"bottom",reflow:!1}}};var Be=H.layers,Pe=[...new Set(Object.values(Be).flatMap(t=>t.channels))];function Oe(t,e={}){let n=[Te(t,"plot()")];for(let[r,o]of Object.entries(e))Pe.includes(r)||nt("plot()","channel",r,Pe),ae(n[0],o,"plot()");return new le({data:n,mapping:e,layers:[],facet:null,scales:{},labels:{},info:null,theme:{style:"pastel"}})}var le=class t{#e;constructor(e){this.#e=e}#n(e){return new t({...this.#e,...e})}#t(e,n={}){let r=Be[e],o=`${e}()`,{data:s,...i}=n,l=this.#e.data,a=0;s!==void 0&&(l=[...l,Te(s,o)],a=l.length-1);let c=l[a].columns,u={type:e,mapping:{},set:{}};a&&(u.data=a);for(let[p,h]of Object.entries(i))r.channels.includes(p)&&typeof h=="string"&&h in c?u.mapping[p]=h:r.channels.includes(p)||r.options.includes(p)?u.set[p]=Zn(p,h,o,c):nt(o,"option",p,["data",...r.channels,...r.options]);return this.#n({data:l,layers:[...this.#e.layers,u]})}line(e){return this.#t("line",e)}step(e){return this.#t("step",e)}bar(e){return this.#t("bar",e)}hist(e){return this.#t("hist",e)}density(e){return this.#t("density",e)}area(e){return this.#t("area",e)}ribbon(e){return this.#t("ribbon",e)}smooth(e){return this.#t("smooth",e)}path(e){return this.#t("path",e)}point(e){return this.#t("point",e)}hline(e){return this.#t("hline",e)}vline(e){return this.#t("vline",e)}abline(e){return this.#t("abline",e)}segment(e){return this.#t("segment",e)}rect(e){return this.#t("rect",e)}band(e){return this.#t("band",e)}tile(e){return this.#t("tile",e)}text(e){return this.#t("text",e)}errorbar(e){return this.#t("errorbar",e)}box(e){return this.#t("box",e)}facet(e,n={}){return ae(this.#e.data[0],e,"facet()"),St(n,H.facet,"facet()"),$e(n.free,"facet()"),this.#n({facet:{wrap:e,free:n.free??null,ncol:n.ncol??null}})}grid({rows:e=null,cols:n=null,...r}={}){if(e===null&&n===null)throw new Error("grid(): set rows, cols or both");for(let o of[e,n])o!==null&&ae(this.#e.data[0],o,"grid()");return St(r,H.grid,"grid()"),$e(r.free,"grid()"),this.#n({facet:{rows:e,cols:n,free:r.free??null}})}x(e){return this.#o("x",e)}y(e){return this.#o("y",e)}color(e){return this.#o("color",e)}#o(e,n={}){let r=`${e}()`;if(St(n,H.scales[e],r),n.type!==void 0&&!H.scaleTypes.includes(n.type)&&nt(r,"type",n.type,H.scaleTypes),n.palette!==void 0&&!Array.isArray(n.palette)&&!(n.palette in I.palettes)&&nt(r,"palette",n.palette,Object.keys(I.palettes)),n.mid!==void 0&&typeof n.mid!="number")throw new Error(`${r}: mid must be a number`);let o={...n};if(o.limits){if(!Array.isArray(o.limits))throw new Error(`${r}: limits must be a list, for example [0, 10] or [0, null]`);o.limits=o.limits.map(s=>s==null?null:_t(s))}return this.#n({scales:{...this.#e.scales,[e]:o}})}labels(e={}){return St(e,H.labels,"labels()"),this.#n({labels:{...this.#e.labels,...e}})}info(e,n={}){St(n,H.info,"info()");let{position:r}=n;if(r!==void 0&&!H.infoPosition.includes(r)&&nt("info()","position",r,H.infoPosition),e==null)return this.#n({info:null});let o=Array.isArray(e)?e:typeof e=="object"?Object.entries(e):null;if(!o)throw new Error("info(): entries must be an object or a list of [key, value] pairs");return this.#n({info:{entries:o.map(s=>Jn(s)),...r?{position:r}:{}}})}theme(e="pastel",n={}){if(St(n,H.theme,"theme()"),e in I.styles||nt("theme()","style",e,Object.keys(I.styles)),n.format!==void 0&&!(n.format in I.formats)&&nt("theme()","format",n.format,Object.keys(I.formats)),n.legend!==void 0&&!H.legend.includes(n.legend)&&nt("theme()","legend",n.legend,H.legend),n.aspect!=null&&!(typeof n.aspect=="number"&&n.aspect>0))throw new Error("theme(): aspect must be a positive number (panel height / width), for example 1 for square panels");return this.#n({theme:{style:e,...n}})}spec(){let e=this.#e,n=e.data.map(()=>new Set);for(let o of Object.values(e.mapping))n.forEach((s,i)=>o in e.data[i].columns&&s.add(o));for(let o of e.layers)for(let s of Object.values(o.mapping))n[o.data??0].add(s);for(let o of[e.facet?.wrap,e.facet?.rows,e.facet?.cols])o&&n.forEach((s,i)=>o in e.data[i].columns&&s.add(o));return{version:1,data:e.data.map((o,s)=>({columns:Object.fromEntries([...n[s]].map(i=>[i,o.columns[i]]))})),mapping:e.mapping,layers:e.layers,facet:e.facet,scales:e.scales,labels:e.labels,...e.info?{info:e.info}:{},theme:e.theme}}};function Te(t,e){if(!Array.isArray(t))throw new Error(`${e}: data must be an array of row objects`);let n=[...new Set(t.flatMap(Object.keys))],r={};for(let o of n){let s=t.map(c=>c[o]??null),i=s.find(c=>c!==null&&!Number.isNaN(c)),l=i instanceof Date?"time":typeof i=="number"?"number":"string",a=s.map(c=>c===null||Number.isNaN(c)?null:l==="string"?String(c):_t(c));r[o]={type:l,values:a}}return{columns:r}}function _t(t){return t instanceof Date?t.getTime()-t.getTimezoneOffset()*6e4:typeof t=="number"&&!Number.isInteger(t)?Number(t.toPrecision(6)):t}function Zn(t,e,n,r){let o=H.options[t];if(t==="tooltip"||t==="group")throw new Error(`${n}: ${t} must be a column. Columns: ${Object.keys(r).join(", ")}`);if(Array.isArray(o)&&!o.includes(e)&&nt(n,t,e,o),o==="number"&&typeof e!="number")throw new Error(`${n}: ${t} must be a number`);if(o==="boolean"&&typeof e!="boolean")throw new Error(`${n}: ${t} must be true or false`);if(t==="color"||t==="label")return e;if(typeof e=="string"&&!o)throw new Error(`${n}: "${e}" is not a column. Columns: ${Object.keys(r).join(", ")}`);return _t(e)}function Jn(t){if(!Array.isArray(t)||t.length!==2||typeof t[0]!="string")throw new Error("info(): each entry must be a [key, value] pair with a string key");let[e,n]=t;if(n==null||typeof n=="number"&&Number.isNaN(n))return[e,null];if(!["string","number","boolean"].includes(typeof n))throw new Error(`info(): the value of "${e}" must be a string, a number, a boolean or null. Format other values as a string`);return[e,_t(n)]}function ae(t,e,n){if(!(e in t.columns))throw new Error(`${n}: "${e}" is not a column. Columns: ${Object.keys(t.columns).join(", ")}`)}function St(t,e,n){for(let r of Object.keys(t))e.includes(r)||nt(n,"option",r,e)}function $e(t,e){t!=null&&!H.free.includes(t)&&nt(e,"free",t,H.free)}function nt(t,e,n,r){throw new Error(`${t}: unknown ${e} "${n}". Valid: ${r.join(", ")}`)}import*as et from"https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6.17/+esm";import*as wt from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";import*as T from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";import*as U from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var Qn=Object.keys(I.styles),to=Object.keys(I.formats),eo=Object.keys(I.palettes),no=Object.keys(I.schemes),Ne=["ink","muted","grid","tick","strip","accent","background"];function je({style:t="pastel",format:e="screen",legend:n,...r}={}){if(!I.styles[t])throw new Error(`theme(): unknown style "${t}". Valid: ${Qn.join(", ")}`);if(!I.formats[e])throw new Error(`theme(): unknown format "${e}". Valid: ${to.join(", ")}`);let o=I.styles.pastel,s=I.styles[t],i=I.formats[e],l=r.width!=null;for(let c of Object.keys(r))r[c]==null&&delete r[c];let a={...o,...s,colors:{...o.colors,...s.colors},...i,legend:n??i.legend??"right",...r,style:t,format:e};return a.reflow=i.reflow&&!l,a.line=i.line*(s.weight??o.weight??1),a.point=i.point*Math.sqrt(s.weight??o.weight??1),r.width!=null&&r.height==null&&(a.height=Math.round(r.width*i.height/i.width)),a.fixedHeight=r.height!=null,a.fitHeight=i.reflow&&!a.fixedHeight,a.fixedFormat=!i.reflow,a.pad=i.pad??.9,a.palette=ce(a,a.palette),a}function ce(t,e){let n=Array.isArray(e)?e:I.palettes[e];if(!n)throw new Error(`color(): unknown palette "${e}". Valid: ${eo.join(", ")}`);return n.map(r=>Ct(t,r)??r)}function He(t,e){let n=o=>U.piecewise(U.interpolateLab,o.map(s=>Ct(t,s)??s));if(Array.isArray(e))return n(e);if(I.schemes[e])return n(I.schemes[e]);let r=typeof e=="string"&&U[`interpolate${e[0].toUpperCase()}${e.slice(1)}`];if(!r)throw new Error(`color(): unknown scheme "${e}". plotto schemes: ${no.join(", ")}; or a d3 scheme such as viridis, magma, blues`);return r}function Ct(t,e){if(typeof e=="string")return t.colors[e]?t.colors[e]:Ne.includes(e)?t[e]:U.color(e)?e:void 0}function Ie(t){return[...Object.keys(t.colors),...Ne]}function ue(t){let e=o=>{let s=[o.r,o.g,o.b].map(i=>(i/=255,i<=.03928?i/12.92:((i+.055)/1.055)**2.4));return .2126*s[0]+.7152*s[1]+.0722*s[2]},n=U.rgb(t);if(e(n)>.42)return{bg:n.formatHex(),fg:"#1F2328"};let r=U.hcl(n);for(let o=0;o<20&&1.05/(e(U.rgb(r))+.05)<4;o++)r=U.hcl(r.h,r.c,r.l-4);return{bg:U.rgb(r).formatHex(),fg:"#FFFFFF"}}function Re(t){return ue(t).fg}function qe(t){let e=t.size;return{base:e,tick:e-1,title:Math.round(e*1.35),subtitle:e,strip:e-1,legend:e-1,axisTitle:e,hover:Math.max(11,e-1)}}var Rt={x:["x","xmin","xmax","xend"],y:["y","ymin","ymax","yend"]},We=.05,pe=864e5;function de(t,e){let n=t.scales[e]?.type;if(n)return n;for(let r of t.layers)for(let o of Rt[e]){let s=r.channels[o]?.column;if(!s)continue;let i=t.tables[r.table].columns[s].type;return i==="time"?"time":i==="string"?"category":"linear"}return"linear"}function Xe(t,e,n,r){let o=e.channels[n];if(!o)return;if("value"in o)return r.map(()=>o.value);let s=t.tables[e.table].columns[o.column].values;return r.map(i=>s[i])}function _e(t,e,n,r){let o=[];for(let i of r)for(let l of i.views)for(let a of Rt[e]){let c=l.cols[a];if(c)for(let u of c)u!=null&&(n==="category"||Number.isFinite(u))&&o.push(u)}if(n==="category")return oo(t,e,o);let s=T.extent(o.filter(i=>n!=="log"||i>0));return s[0]===void 0?n==="log"?[1,10]:[0,1]:Ge(s,n)}function oo(t,e,n){let r=t.layers.map(s=>s.channels[e]?.column&&t.tables[s.table].columns[s.channels[e].column].levels).find(Boolean),o=new Set(n.map(String));return r?r.filter(s=>o.has(s)):[...o].sort(Gt)}function Gt(t,e){return String(t).localeCompare(String(e),void 0,{numeric:!0})}function Ge([t,e],n){if(n==="log"){let[o,s]=Ge([Math.log10(t),Math.log10(e)],"linear");return[10**o,10**s]}let r=e>t?(e-t)*We:n==="time"?36e5:Math.abs(t)*We||1;return[t-r,e+r]}function vt(t,e,n,r){if(t==="category")return{major:e,minor:[],format:String};let[o,s]=e;if(t==="time"){let l=T.scaleUtc().domain([new Date(o),new Date(s)]).ticks(n),a=r??ro(l,s-o);return{major:l,minor:Ye(l,e,c=>+c).map(c=>new Date(c)),format:T.utcFormat(a)}}if(t==="log"){let l=T.range(Math.ceil(Math.log10(o)),Math.floor(Math.log10(s))+1).map(u=>10**u),a=l.length>=2?l:T.scaleLog().domain(e).ticks(n).filter(u=>[1,2,5].includes(Math.round(u/10**Math.floor(Math.log10(u)+1e-9)))),c=l.flatMap(u=>T.range(2,10).map(p=>u/10*p)).filter(u=>u>o&&u<s);return{major:a,minor:c,format:T.format(r??"~g")}}let i=T.ticks(o,s,n);return{major:i,minor:Ye(i,e,Number),format:r?T.format(r):T.tickFormat(o,s,n)}}function Ye(t,[e,n],r){if(t.length<2)return[];let o=r(t[1])-r(t[0]);return[r(t[0])-o/2,...t.map(i=>r(i)+o/2)].filter(i=>i>e&&i<n)}function ro(t,e){let n=t.length>=2?t[1]-t[0]:e;return n>=28*pe?"%Y-%m":n>=pe?"%m-%d":n>=6e4?e>pe?"%m-%d %H:%M":"%H:%M":"%H:%M:%S"}var so=T.format(",.4~r"),Ve={number:t=>t==null?"\u2013":Math.abs(t)>=1e15||t!==0&&Math.abs(t)<1e-4?T.format(".3~e")(t):so(t),time:T.utcFormat("%m-%d %H:%M"),string:t=>t==null?"\u2013":String(t)};function Ue(t){let e=t.theme,n=t.scales.color??{},r=t.layers.filter(x=>x.channels.color?.column);if(!r.length)return{kind:"none"};let o=r[0].channels.color.column,s=r.find(x=>x.channels.color.column!==o);if(s)throw new Error(`plotto: color maps "${o}" and "${s.channels.color.column}". Map color to one column only`);let i=r.map(x=>t.tables[x.table].columns[o]),l=i[0].type,a=i.flatMap(x=>x.values).filter(x=>x!==null),c=x=>Ct(e,x)??x;if(l==="string"){let x=i.find(E=>E.levels)?.levels,v=new Set(a),m=n.limits??(x?x.filter(E=>v.has(E)):[...v].sort(Gt)),f=n.palette?ce(e,n.palette):e.palette,k=n.values,M=Array.isArray(k)?(E,L)=>c(k[L%k.length]):k?(E,L)=>c(k[E]??f[L%f.length]):(E,L)=>f[L%f.length],F=new Map(m.map((E,L)=>[E,M(E,L)]));return{kind:"ordinal",column:o,domain:m,apply:E=>F.get(E)??e.muted}}let[u,p]=io(n.limits,T.extent(a)),h=He(e,n.values??n.scheme??e.scheme),d=n.mid,g=x=>d===void 0?(x-u)/(p-u||1):x<d?.5*((x-u)/(d-u||1)):.5+.5*((x-d)/(p-d||1)),y=x=>x>=u&&x<=p,w=x=>x===null?e.muted:n.clamp||y(x)?h(Math.max(0,Math.min(1,g(x)))):e.muted;return{kind:"continuous",column:o,domain:[u,p],type:l,interpolate:h,apply:w,ramp:x=>w(u+x*(p-u))}}function io(t,e){return t?[t[0]??e[0],t[1]??e[1]]:e}function Ke(t){let e=t.facet;if(!e)return{kind:"none",nrow:1,ncol:1,panels:[fe(t,0,0,{},{})]};if(e.kind==="wrap"){let s=he(t,e.by),i=e.ncol??lo(s.length),l=s.map((a,c)=>fe(t,Math.floor(c/i),c%i,{[e.by]:a},{top:a}));return{kind:"wrap",nrow:Math.ceil(s.length/i),ncol:i,panels:l}}let n=e.rows?he(t,e.rows):[null],r=e.cols?he(t,e.cols):[null],o=[];return n.forEach((s,i)=>r.forEach((l,a)=>{let c={};e.rows&&(c[e.rows]=s),e.cols&&(c[e.cols]=l),o.push(fe(t,i,a,c,{top:i===0?l:null,right:a===r.length-1?s:null}))})),{kind:"grid",nrow:n.length,ncol:r.length,panels:o}}function lo(t){return t<=3?t:t<=6?Math.ceil(t/2):t<=12?Math.ceil(t/3):Math.ceil(Math.sqrt(t))}function he(t,e){let n=t.tables[0].columns[e];return n.levels?n.levels.filter(r=>n.values.includes(r)):[...new Set(n.values.filter(r=>r!==null).map(String))].sort(Gt)}function fe(t,e,n,r,o){let s=t.layers.map(i=>{let l=t.tables[i.table];if(!Object.values(i.channels).some(u=>u.column))return[0];let a=Object.entries(r).filter(([u])=>u in l.columns),c=Array.from({length:l.n},(u,p)=>p);return a.length?c.filter(u=>a.every(([p,h])=>String(l.columns[p].values[u])===h)):c});return{row:e,col:n,strips:o,rows:s}}import*as at from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var ao="http://www.w3.org/2000/svg";function O(t,e,n={}){let r=t.createElementNS(ao,e);for(let[o,s]of Object.entries(n))s!=null&&r.setAttribute(o,String(s));return r}function K(t,e,n,r="text"){let o=O(t,r,n);return o.textContent=e,o}var Ze={arial:{regular:[.278,.278,.355,.556,.556,.889,.667,.191,.333,.333,.389,.584,.278,.333,.278,.278,.556,.556,.556,.556,.556,.556,.556,.556,.556,.556,.278,.278,.584,.584,.584,.556,1.015,.667,.667,.722,.722,.667,.611,.778,.722,.278,.5,.667,.556,.833,.722,.778,.667,.778,.722,.667,.611,.722,.667,.944,.667,.667,.611,.278,.278,.278,.469,.556,.333,.556,.556,.5,.556,.556,.278,.556,.556,.222,.222,.5,.222,.833,.556,.556,.556,.556,.333,.5,.278,.556,.5,.722,.5,.5,.5,.334,.26,.334,.584],bold:[.278,.333,.474,.556,.556,.889,.722,.238,.333,.333,.389,.584,.278,.333,.278,.278,.556,.556,.556,.556,.556,.556,.556,.556,.556,.556,.333,.333,.584,.584,.584,.611,.975,.722,.722,.722,.722,.667,.611,.778,.722,.278,.556,.722,.611,.833,.722,.778,.667,.778,.722,.667,.611,.722,.667,.944,.667,.667,.611,.333,.278,.333,.584,.556,.333,.556,.611,.556,.611,.556,.333,.611,.611,.278,.278,.556,.278,.889,.611,.611,.611,.611,.389,.556,.333,.611,.556,.778,.556,.556,.5,.389,.28,.389,.584]},mplus:{regular:[.29,.363,.4,.678,.605,.847,.712,.237,.385,.385,.527,.733,.304,.457,.283,.507,.62,.62,.62,.62,.62,.62,.62,.62,.62,.62,.363,.384,.667,.753,.667,.611,.823,.693,.598,.695,.682,.587,.572,.745,.71,.317,.527,.633,.585,.857,.713,.793,.6,.785,.62,.573,.653,.683,.693,.953,.65,.67,.637,.47,.507,.47,.653,.583,.278,.548,.578,.522,.578,.552,.522,.573,.573,.307,.347,.562,.307,.805,.568,.57,.573,.573,.453,.497,.512,.558,.557,.81,.553,.557,.547,.513,.343,.513,.69],bold:[.304,.425,.478,.692,.625,.901,.753,.291,.426,.426,.536,.735,.351,.471,.338,.546,.64,.64,.64,.64,.64,.64,.64,.64,.64,.64,.418,.431,.681,.755,.681,.628,.818,.715,.62,.703,.696,.601,.586,.756,.735,.351,.558,.678,.6,.878,.735,.798,.628,.798,.651,.608,.668,.705,.715,.971,.678,.698,.651,.501,.546,.501,.695,.609,.336,.576,.606,.54,.606,.57,.543,.601,.605,.335,.378,.603,.335,.843,.6,.585,.601,.601,.485,.525,.533,.59,.581,.831,.585,.585,.568,.535,.381,.535,.705]}};var co=11904;function ht(t,e,n=!1,r="arial"){let o=Ze[r][n?"bold":"regular"],s=0;for(let i of String(t)){let l=i.codePointAt(0);l>=32&&l<127?s+=o[l-32]:s+=l>=co?1:.6}return s*e}function ft(t,e,n,r,o){if(t=String(t),ht(t,e,r,o)<=n)return t;let s=[...t];for(;s.length>1&&ht(s.join("")+"\u2026",e,r,o)>n;)s.pop();return s.join("")+"\u2026"}function bt(t,e,n,r,o,s=2){let i=String(t).split(/\s+/),l=[],a="";for(let u of i){let p=a?`${a} ${u}`:u;a&&ht(p,e,r,o)>n?(l.push(a),a=u):a=p}if(l.push(a),l.length<=s)return l;let c=l.slice(0,s);return c[s-1]=ft(l.slice(s-1).join(" "),e,n,r,o),c}var uo=3,po=.45,ho={right:.3,bottom:.9},fo={right:.6,bottom:.3},mo=3;function Je(t,e,{W:n,H:r,narrow:o,place:s=t.info?.position}){if(!t.info)return null;let i=o?"bottom":s;return xo(t,e,t.info.entries,i,n,r*fo[i])}function xo(t,e,n,r,o,s){let i=t.theme.metrics,l=e.legend,a=Math.round(l*.8),c=l*1.35,u=l,p=l*2,h=n.map(([m,f])=>({key:String(m),value:f===null?"\u2013":String(f)})),d=m=>ht(m,l,!1,i),g=(m,f)=>{let k=Math.min(at.max(m,C=>d(C.key))??0,f*po),M=Math.max(l*3,f-k-u),F=0,E=m.map(C=>{let $=bt(C.value,l,M,!1,i,uo),R={key:ft(C.key,l,k,!1,i),full:C.key,lines:$,y:F};return F+=$.length*c,R}),L=at.max(E,C=>at.max(C.lines,d))??0;return{rows:E,keyW:k,width:k+u+L,height:F}},y=o*ho[r]-2*a,w=m=>{let f;if(r==="bottom"){let M=E=>{let L=Math.ceil(m.length/E);return at.range(E).map(C=>g(m.slice(C*L,(C+1)*L),1/0))};f=at.range(Math.min(mo,m.length),1,-1).map(M).find(E=>at.sum(E,L=>L.width)+p*(E.length-1)<=y)??[g(m,y)]}else f=[g(m,y)];let k=a;for(let M of f)M.x=k,k+=M.width+p;return{columns:f,width:k-p+a,height:(at.max(f,M=>M.height)??0)+2*a}},b=h.length,x=w(h);for(;x.height>s&&b>1;)b--,x=w([...h.slice(0,b),{key:`+${h.length-b} more`,value:""}]);let v=x.columns.flatMap(m=>m.rows).filter(m=>m.key!==m.full).length;return{position:r,size:l,pad:a,lineH:c,keyGap:u,cut:h.length-b+v,...x}}function Qe(t,e,n,{x:r,y:o}){let s=O(t,"g",{class:"pt-info",transform:`translate(${r},${o})`,"font-size":e.size});s.append(O(t,"rect",{width:e.width,height:e.height,fill:n.strip}));let i=e.lineH*.75;for(let l of e.columns)for(let a of l.rows){let c=e.pad+a.y+i,u=K(t,a.key,{x:l.x,y:c,fill:n.muted,"text-anchor":"start"});a.key!==a.full&&u.append(K(t,a.full,{},"title")),s.append(u),a.lines.forEach((p,h)=>s.append(K(t,p,{x:l.x+l.keyW+e.keyGap,y:c+h*e.lineH,fill:n.ink,"text-anchor":"start"})))}return s}import*as S from"https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6.17/+esm";import*as G from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";import*as D from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var Vt=80;function qt(t,e,n){let r=new Map;for(let o=0;o<n;o++){let s=e.map(l=>t[l]?.[o]??null),i=JSON.stringify(s);r.has(i)||r.set(i,{key:s,idx:[]}),r.get(i).idx.push(o)}return[...r.values()]}function tn(t,e,n){let r={mean:D.mean,median:D.median,min:D.min,max:D.max,sum:D.sum}[n],o={x:[],y:[],color:[],group:[]};for(let{key:s,idx:i}of qt(t,["x","color","group"],e))s[0]!==null&&(o.x.push(s[0]),o.y.push(r(i,l=>t.y[l])),o.color.push(s[1]),o.group.push(s[2]));return o}function en(t,e,n,r){let o=l=>t.color?r.indexOf(t.color[l]):0,s=t.color?r.filter(l=>t.color.includes(l)):[null],i={...t,ymin:new Array(e),ymax:new Array(e),value:t.y.slice(),slot:new Array(e),slots:new Array(e)};for(let{idx:l}of qt(t,n==="dodge"?["x","color"]:["x"],e)){l.sort((u,p)=>o(u)-o(p));let a=0,c=0;l.forEach((u,p)=>{let h=t.y[u]??0;if(n!=="overlay"){let d=h>=0?a:c;[i.ymin[u],i.ymax[u]]=[d,d+h],h>=0?a+=h:c+=h}else[i.ymin[u],i.ymax[u]]=[0,h];i.slot[u]=n==="dodge"&&t.color?s.indexOf(t.color[u]):0,i.slots[u]=n==="dodge"?s.length:1})}return i.y=i.ymax,i}function nn(t,e){let n=[...new Set(t.x.filter(l=>l!==null))].sort((l,a)=>l-a),o=(D.min(D.pairs(n),([l,a])=>a-l)??1)*.9,s=[],i=[];for(let l=0;l<e;l++){let a=o/t.slots[l];s.push(t.x[l]-o/2+t.slot[l]*a),i.push(t.x[l]-o/2+(t.slot[l]+1)*a)}return{...t,xmin:s,xmax:i}}function on(t,e){let n=t.filter(i=>i!==null&&Number.isFinite(i)),[r,o]=D.extent(n);if(r===void 0)return[0,1];if(r===o)return[r-.5,o+.5];let s=D.ticks(...D.nice(r,o,e),e);return s[0]>r&&s.unshift(s[0]-(s[1]-s[0])),s.at(-1)<o&&s.push(s.at(-1)+(s[1]-s[0])),s}function rn(t,e,n,r){let o={x:[],xmin:[],xmax:[],y:[],color:[]},s=D.bin().domain([n[0],n.at(-1)]).thresholds(n.slice(1,-1));for(let{key:i,idx:l}of qt(t,["color"],e)){let a=l.map(c=>t.x[c]).filter(c=>c!==null&&Number.isFinite(c));for(let c of s(a)){let u=c.length;o.x.push((c.x0+c.x1)/2),o.xmin.push(c.x0),o.xmax.push(c.x1),o.y.push(r?u/(a.length*(c.x1-c.x0)||1):u),o.color.push(i[0])}}return o}function Ut(t){let e=t.filter(a=>a!==null&&Number.isFinite(a)).sort(D.ascending),[n,r,o]=[.25,.5,.75].map(a=>D.quantile(e,a)),s=o-n,i=D.min(e.filter(a=>a>=n-1.5*s)),l=D.max(e.filter(a=>a<=o+1.5*s));return{n:e.length,q1:n,median:r,q3:o,low:i,high:l,outliers:e.filter(a=>a<i||a>l)}}function sn(t,e){let n={x:[],y:[],color:[],group:[]};for(let{key:r,idx:o}of qt(t,["color"],e)){let s=o.map(p=>t.x[p]).filter(p=>p!==null&&Number.isFinite(p));if(s.length<2)continue;let i=D.deviation(s),l=D.quantile(s,.75)-D.quantile(s,.25),a=.9*Math.min(i,l/1.34||i)*s.length**-.2||1,[c,u]=D.extent(s);for(let p of D.range(Vt).map(h=>c-3*a+(u-c+6*a)*h/(Vt-1))){let h=D.sum(s,d=>Math.exp(-.5*((p-d)/a)**2))/(s.length*a*Math.sqrt(2*Math.PI));n.x.push(p),n.y.push(h),n.color.push(r[0]),n.group.push(r[0])}}return n}function ln(t,e,{method:n="lm",span:r=.75,band:o=!0}){let s={x:[],y:[],ymin:[],ymax:[],color:[],group:[]};for(let{key:i,idx:l}of qt(t,["color"],e)){let a=l.map(d=>[t.x[d],t.y[d]]).filter(([d,g])=>d!==null&&g!==null&&Number.isFinite(d)&&Number.isFinite(g));if(a.length<3)continue;a.sort((d,g)=>d[0]-g[0]);let[c,u]=[a[0][0],a.at(-1)[0]],p=D.range(Vt).map(d=>c+(u-c)*d/(Vt-1));(n==="loess"?go(a,p,r):yo(a,p)).forEach(({x:d,y:g,se:y})=>{let w=bo(a.length-2);s.x.push(d),s.y.push(g),s.ymin.push(o&&y!==void 0?g-w*y:null),s.ymax.push(o&&y!==void 0?g+w*y:null),s.color.push(i[0]),s.group.push(i[0])})}return s}function yo(t,e){let n=t.length,r=D.mean(t,c=>c[0]),o=D.mean(t,c=>c[1]),s=D.sum(t,c=>(c[0]-r)**2)||1,i=D.sum(t,c=>(c[0]-r)*(c[1]-o))/s,l=o-i*r,a=Math.sqrt(D.sum(t,c=>(c[1]-l-i*c[0])**2)/Math.max(1,n-2));return e.map(c=>({x:c,y:l+i*c,se:a*Math.sqrt(1/n+(c-r)**2/s)}))}function go(t,e,n){let r=Math.max(3,Math.ceil(n*t.length));return e.map(o=>{let s=t.map(([y,w])=>[Math.abs(y-o),y,w]).sort((y,w)=>y[0]-w[0]).slice(0,r),i=s.at(-1)[0]||1,[l,a,c,u,p]=[0,0,0,0,0];for(let[y,w,b]of s){let x=(1-(y/i)**3)**3;l+=x,a+=x*w,c+=x*b,u+=x*w*w,p+=x*w*b}let h=l*u-a*a,d=Math.abs(h)<1e-12?0:(l*p-a*c)/h,g=(c-d*a)/l;return{x:o,y:g+d*o}})}function bo(t){let e=[12.71,4.3,3.18,2.78,2.57,2.45,2.36,2.31,2.26,2.23,2.2,2.18,2.16,2.14,2.13,2.12,2.11,2.1,2.09,2.09];return t<1?NaN:t<=e.length?e[t-1]:t<=30?2.05:t<=60?2:1.96}var wo={solid:void 0,dashed:"6,4",dotted:"1.5,3",dashdot:"6,3,1.5,3"},P="frame",ct=(t,e)=>({stroke:t.colors(e),strokeWidth:t.options.size??t.theme.line,strokeOpacity:t.options.alpha??1,strokeDasharray:wo[t.options.dash],strokeLinejoin:"round",strokeLinecap:"round"}),mt=(t,e,n=1)=>({fill:t.colors(e),fillOpacity:t.options.alpha??n}),tt=t=>t.theme.palette[0],ko=t=>e=>[S.line(e.index,{x:e.v("x"),y:e.v("y"),z:e.groups(),curve:t,...ct(e,tt(e)),clip:P})],an={line:t=>[S.line(t.index,{x:t.v("x"),y:t.v("y"),z:t.groups(),sort:{channel:"x"},...ct(t,tt(t)),clip:P})],path:ko("linear"),step:t=>[S.line(t.index,{x:t.v("x"),y:t.v("y"),z:t.groups(),sort:{channel:"x"},curve:"step-after",...ct(t,tt(t)),clip:P})],point:t=>{let e={x:vo(t),y:t.v("y"),r:t.options.size??t.theme.point,...mt(t,tt(t)),clip:P};return t.options.jitter&&t.kind.x==="category"&&(e.render=Mo(t.options.jitter)),[S.dot(t.index,e)]},bar:t=>{let e={...mt(t,tt(t),me(t,1)),clip:P};if(t.kind.x!=="category")return[S.rect(t.index,{x1:t.v("xmin"),x2:t.v("xmax"),y1:t.v("ymin"),y2:t.v("ymax"),...e})];let n=t.v("slots")[0]??1;if(n===1)return[S.barY(t.index,{x:t.v("x"),y1:t.v("ymin"),y2:t.v("ymax"),...e})];let r=t.bandwidth.x/n,o=(s,i)=>Array.isArray(s)?i.map(l=>s[l]):s;return G.range(n).map(s=>{let i=t.index.filter(a=>t.v("slot")[a]===s),l={x:o(t.v("x"),i),y1:o(t.v("ymin"),i),y2:o(t.v("ymax"),i),fill:o(e.fill,i)};return S.barY(G.range(i.length),{...e,...l,insetLeft:s*r+.5,insetRight:(n-1-s)*r+.5})})},hist:t=>[S.rect(t.index,{x1:t.v("xmin"),x2:t.v("xmax"),y1:t.v("ymin"),y2:t.v("ymax"),insetLeft:.5,insetRight:.5,...mt(t,tt(t),me(t)),clip:P})],density:t=>[S.areaY(t.index,{x:t.v("x"),y:t.v("y"),z:t.groups(),fill:t.colors(tt(t)),fillOpacity:.15,clip:P}),S.line(t.index,{x:t.v("x"),y:t.v("y"),z:t.groups(),...ct(t,tt(t)),clip:P})],area:t=>[S.areaY(t.index,{x:t.v("x"),y1:t.v("ymin"),y2:t.v("ymax"),z:t.groups(),...mt(t,tt(t),me(t,.8)),clip:P})],ribbon:t=>[S.areaY(t.index,{x:t.v("x"),y1:t.v("ymin"),y2:t.v("ymax"),z:t.groups(),...mt(t,tt(t),.2),clip:P})],smooth:t=>{let e=[];return t.v("ymin").some(n=>n!==null)&&e.push(S.areaY(t.index,{x:t.v("x"),y1:t.v("ymin"),y2:t.v("ymax"),z:t.groups(),fill:t.colors(t.theme.muted),fillOpacity:.15,clip:P})),e.push(S.line(t.index,{x:t.v("x"),y:t.v("y"),z:t.groups(),...ct(t,t.theme.accent),clip:P})),e},hline:t=>[S.ruleY(t.index,{y:t.v("y"),...ct(t,t.theme.muted),strokeWidth:t.options.size??1,clip:P})],vline:t=>[S.ruleX(t.index,{x:t.v("x"),...ct(t,t.theme.muted),strokeWidth:t.options.size??1,clip:P})],abline:t=>{let[e,n]=t.domain.x.map(Number),{slope:r=1,intercept:o=0}=t.options;return[S.line([0,1],{x:[e,n],y:[o+r*e,o+r*n],...ct(t,t.theme.muted),strokeWidth:t.options.size??1,clip:P})]},segment:t=>[S.link(t.index,{x1:t.v("x"),y1:t.v("y"),x2:t.v("xend"),y2:t.v("yend"),...ct(t,t.theme.ink),clip:P})],rect:t=>[S.rect(t.index,{x1:t.v("xmin"),x2:t.v("xmax"),y1:t.v("ymin"),y2:t.v("ymax"),...mt(t,tt(t)),clip:P})],band:t=>{let e=(r,o,s)=>t.v(r)??t.index.map(()=>t.domain[o][s]),n={x1:e("xmin","x",0),x2:e("xmax","x",1),y1:e("ymin","y",0),y2:e("ymax","y",1)};return[S.rect(t.index,{...n,...mt(t,t.theme.muted,.12),clip:P})]},tile:t=>{let e=mt(t,tt(t)),[n,r]=[t.kind.x==="category",t.kind.y==="category"];if(n&&r)return[S.cell(t.index,{x:t.v("x"),y:t.v("y"),...e,inset:.5,clip:P})];let[o,s]=n?[]:Kt(t.v("x")),[i,l]=r?[]:Kt(t.v("y"));return n?[S.barY(t.index,{x:t.v("x"),y1:i,y2:l,...e,clip:P})]:r?[S.barX(t.index,{y:t.v("y"),x1:o,x2:s,...e,insetTop:.5,insetBottom:.5,clip:P})]:[S.rect(t.index,{x1:o,x2:s,y1:i,y2:l,...e,clip:P})]},text:t=>[S.text(t.index,{x:t.v("x"),y:t.v("y"),text:t.v("label"),fontSize:t.options.size??t.fonts.tick,...mt(t,t.theme.ink),clip:P})],errorbar:t=>{let e={...ct(t,t.theme.ink),strokeWidth:t.options.size??1.2},n=S.ruleX(t.index,{x:t.v("x"),y1:t.v("ymin"),y2:t.v("ymax"),...e,clip:P});if(t.kind.x==="category"){let i=t.bandwidth.x*.35,l=a=>S.tickY(t.index,{x:t.v("x"),y:t.v(a),...e,insetLeft:i,insetRight:i,clip:P});return[n,l("ymin"),l("ymax")]}let[r,o]=Kt(t.v("x"),.25),s=i=>S.link(t.index,{x1:r,x2:o,y1:t.v(i),y2:t.v(i),...e,clip:P});return[n,s("ymin"),s("ymax")]},box:t=>{let[e,n,r]=[t.v("x"),t.v("y"),t.colors(t.theme.muted)],o=[];for(let[a,c]of G.group(t.index,u=>e[u])){let u=Ut(c.map(p=>n[p]));u.n&&o.push({key:a,color:Array.isArray(r)?r[c[0]]:r,...u})}let s=o.flatMap(a=>a.outliers.map(c=>({key:a.key,v:c,color:a.color}))),i=a=>({insetLeft:t.bandwidth.x*a,insetRight:t.bandwidth.x*a}),l={x:"key",stroke:"color",strokeWidth:1.25,clip:P};return[S.ruleX(o,{...l,y1:"q3",y2:"high"}),S.ruleX(o,{...l,y1:"low",y2:"q1"}),S.tickY(o,{...l,y:"high",...i(.38)}),S.tickY(o,{...l,y:"low",...i(.38)}),S.barY(o,{...l,y1:"q1",y2:"q3",fill:"color",fillOpacity:t.options.alpha??.3,...i(.22)}),S.tickY(o,{x:"key",y:"median",stroke:t.theme.ink,strokeWidth:2.25,...i(.22),clip:P}),S.dot(s,{x:"key",y:"v",fill:"color",r:t.theme.point,clip:P})]}};function me(t,e=.9){return t.options.position==="overlay"?.45:e}function Kt(t,e=.5){let n=t.map(Number),r=[...new Set(n)].sort((i,l)=>i-l),o=G.min(G.pairs(r),([i,l])=>l-i)??1,s=t[0]instanceof Date?i=>new Date(i):i=>i;return[n.map(i=>s(i-o*e)),n.map(i=>s(i+o*e))]}function vo(t){let e=t.v("x");if(!t.options.jitter||t.kind.x==="category")return e;let n=G.randomUniform.source(G.randomLcg(42))(-1,1),[r]=Kt(e,t.options.jitter);return e.map((o,s)=>+o+(+o-+r[s])*n()).map(o=>e[0]instanceof Date?new Date(o):o)}function Mo(t){return(e,n,r,o,s,i)=>{let l=G.randomUniform.source(G.randomLcg(42))(-1,1),a=n.scales.x?.bandwidth??20,c=Float64Array.from(r.x,u=>u+l()*a*t*.5);return i(e,n,{...r,x:c},o,s)}}import*as Lt from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var Dt=18,zt=6,ut={thick:12,long:150,slices:48},Eo=3,Ao=1.25,Fo=["line","path","step","density","smooth","hline","vline","abline","segment","errorbar"],So=["bar","hist","area","ribbon","rect","tile","box"];function cn(t,e,n,{horizontal:r,maxWidth:o,maxHeight:s}){if(e.kind==="none"||t.theme.legend==="none")return null;let i=t.theme.metrics,l=(f,k,M)=>ht(f,k,M,i),a=t.labels.color===null?null:t.labels.color??e.column,c=a?n.legend*1.8:0,u=a?l(a,n.legend+1,!0):0;if(e.kind==="continuous"){let f=vt(e.type==="time"?"time":"linear",e.domain,4),k=f.major.map(f.format),M=Lt.max(k,C=>l(C,n.legend))??0,F=Math.min(ut.long,r?o:s-c-4),[E,L]=r?[F,ut.thick+n.legend*1.6]:[ut.thick+zt+M,F];return{kind:"ramp",title:a,titleH:c,color:e,long:F,ticks:f.major,labels:k,width:Math.max(u,E),height:c+L,horizontal:r}}let p=t.layers.filter(f=>f.channels.color?.column),h=p.some(f=>So.includes(f.type))?"square":p.some(f=>Fo.includes(f.type))?"line":"point",d=Math.round(n.legend*1.75),g=n.legend*Ao,y=r?Math.max(80,o-Dt-zt):Math.max(110,Math.min(200,o*.2)),w=e.domain.map(f=>{let k=r?[ft(f,n.legend,y,!1,i)]:bt(f,n.legend,y,!1,i,Eo),M=Dt+zt+(Lt.max(k,F=>l(F,n.legend))??0);return{value:f,label:k.join(" "),lines:k,color:e.apply(f),w:M,h:d+(k.length-1)*g}});if(!r){let f=[[]],k=c;for(let E of w)k+E.h>s&&f.at(-1).length&&(f.push([]),k=c),f.at(-1).push(Object.assign(E,{y:k})),k+=E.h;let M=0;for(let E of f){for(let L of E)L.x=M;M+=(Lt.max(E,L=>L.w)??0)+n.legend}let F=Lt.max(f,E=>E.at(-1).y+E.at(-1).h)??c;return{kind:"swatches",title:a,titleH:c,key:h,rowH:d,lineH:g,items:w,width:Math.max(u,M-n.legend),height:F,horizontal:r}}let b=a?u+n.legend:0,x=b,v=0;for(let f of w)x>b&&x+f.w>o&&([x,v]=[b,v+d]),Object.assign(f,{x,y:v}),x+=f.w+n.legend*1.5;let m=Lt.max(w,f=>f.x+f.w)??u;return{kind:"swatches",title:a,titleH:0,inline:!0,key:h,rowH:d,lineH:g,items:w,width:m,height:v+d,horizontal:r}}function un(t,e,n,r,o=new Set){let s=O(t,"g",{class:"pt-legend","font-size":r.legend}),i=e.inline?{y:e.rowH/2,dy:"0.35em"}:{y:r.legend};return e.title&&s.append(K(t,e.title,{...i,"font-weight":"bold","font-size":r.legend+1,fill:n.ink})),e.kind==="ramp"?Lo(t,s,e,n,r):e.items.forEach((l,a)=>s.append(Co(t,e,l,a,n,o.has(l.value)))),s}function Co(t,e,n,r,o,s){let i=e.rowH/2,l=O(t,"g",{class:"pt-key","data-index":r,transform:`translate(${n.x},${n.y})`,opacity:s?.35:1}),a=O(t,"rect",{width:n.w,height:n.h,fill:"transparent"}),c=e.key==="line"?O(t,"line",{x1:1,x2:Dt-1,y1:i,y2:i,stroke:n.color,"stroke-width":Math.max(2.5,o.line+1)}):e.key==="point"?O(t,"circle",{cx:Dt/2,cy:i,r:Math.max(3.5,o.point+1),fill:n.color}):O(t,"rect",{x:3,y:i-6,width:12,height:12,fill:n.color}),u=O(t,"text",{x:Dt+zt,y:i,dy:"0.35em",fill:o.muted,"text-decoration":s?"line-through":null});return n.lines.forEach((p,h)=>u.append(h?K(t,p,{x:Dt+zt,dy:e.lineH},"tspan"):t.createTextNode(p))),n.lines.at(-1).endsWith("\u2026")&&u.append(K(t,n.value,{},"title")),l.append(a,c,u),l}function Lo(t,e,n,r,o){let{color:s,horizontal:i,long:l}=n,[a,c]=s.domain.map(Number),u=h=>(Number(h)-a)/(c-a||1),p=n.titleH;for(let h=0;h<ut.slices;h++){let d=h/ut.slices,g=l/ut.slices+.5,y=s.ramp(i?d:1-d),w=i?{x:d*l,y:p,width:g,height:ut.thick}:{x:0,y:p+d*l,width:ut.thick,height:g};e.append(O(t,"rect",{...w,fill:y}))}n.ticks.forEach((h,d)=>{let g=u(h)*l,y=i?{x:g,y:p+ut.thick+o.legend*1.2,"text-anchor":"middle"}:{x:ut.thick+zt,y:p+l-g,dy:"0.35em"};e.append(K(t,n.labels[d],{...y,fill:r.muted}))})}import*as N from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var xt={size:4,padding:3},pn=40,Do=3,xe=1.15,zo=.22;function dn({ns:t,grid:e,kind:n,home:r,legend:o,info:s,fonts:i,W:l,H:a}){let c=t.theme,u=c.metrics,p=(A,j,X)=>ht(A,j,X,u),h=i.base,d=Math.round(h*c.pad),g=Math.round(h*.8),{title:y,subtitle:w,caption:b,x,y:v}=t.labels,m=A=>s?.position===A?s:null,f=x?i.axisTitle*1.7:0,k=v?i.axisTitle*1.7:0,M=N.max(e.panels,(A,j)=>{let X=vt(n.y,r[j].y,5,t.scales.y?.format);return N.max(X.major,it=>p(X.format(it),i.tick))}),F=k+(M??0)+xt.size+xt.padding+3,E=l-2*d-(c.fixedFormat?F:Math.min(180,l*zo)),L=(A,j,X)=>{let it=A?E/p(A,j,X):1;return it<1&&it>=(c.shrink??1)?Math.floor(j*it*10)/10:j},C=L(y,i.title,!0),$=L(w,i.subtitle,!1),R=y?bt(y,C,E,!0,u):[],V=w?bt(w,$,E,!1,u):[],Z=R.length*C*1.25+V.length*$*1.4,z=d+Z+(Z?h*.7:0),B=b?i.tick*1.8:0,st=Math.max(o&&!o.horizontal?o.width:0,m("right")?.width??0),Qt=st?st+h*1.5:0,kt=o?.horizontal?o.height+h*.8:0,In=m("bottom")?m("bottom").height+g:0,J={x:d+k,y:z,w:l-2*d-k-Qt,h:a-z-d-f-kt-B-In},Bt=e.kind==="none"?0:Math.round(i.strip*2),Ot=e.kind==="wrap"?Bt:0,Wt=e.kind==="grid"&&t.facet.cols?Bt+2:0,ve=e.kind==="grid"&&t.facet.rows?Bt+2:0,Me=t.facet?.free??{x:!1,y:!1},Rn=e.panels.length,Ee=A=>Me.y||A.col===0,Tt=(A,j)=>Me.x||(e.kind==="wrap"?j+e.ncol>=Rn:A.row===e.nrow-1),q=J.w/e.ncol,W=J.h/e.nrow,pt,dt,Nt,te,gt,Mt;for(let A=0;A<2;A++){te={x:Math.max(2,q/(n.x==="time"?110:75)),y:Math.max(3,W/45)},pt=Array(e.ncol).fill(0),dt=Array(e.nrow).fill(0),gt=!1,Mt=new Map,Nt=0;let j=0;e.panels.forEach((Y,_)=>{if(Ee(Y)){let Q=vt(n.y,r[_].y,te.y,t.scales.y?.format),Ft=N.max(Q.major,lt=>p(Q.format(lt),i.tick))??0;if(pt[Y.col]=Math.max(pt[Y.col],Math.ceil(Ft+xt.size+xt.padding+3)),Y.row===0&&!Ot&&!Wt&&n.y!=="category"){let[lt,Ht]=r[_].y,It=(n.y==="log"?N.scaleLog():N.scaleLinear()).domain([lt,Ht]).range([W,0]),Xt=N.max(Q.major.filter(ze=>+ze>=+lt&&+ze<=+Ht));Xt!==void 0&&(Nt=Math.max(Nt,Math.ceil(i.tick*.6-It(Xt))))}}if(n.x==="category"&&Tt(Y,_)){let Q=r[_].x,Ft=q/(Q.length+.2)*.95;for(let lt of Q){let Ht=p(lt,i.tick);if(j=Math.max(j,Ht),Ht<=Ft)continue;let It=bt(lt,i.tick,Ft,!1,u,Do);It.at(-1).endsWith("\u2026")||N.max(It,Xt=>p(Xt,i.tick))>Ft?gt=!0:Mt.set(String(lt),It)}}});let X=Math.min(j,Math.max(W*.6,i.tick*10));gt&&(Mt.clear(),e.panels.forEach((Y,_)=>{if(!(n.x!=="category"||!Tt(Y,_)))for(let Q of r[_].x)p(Q,i.tick)>X&&Mt.set(String(Q),[ft(Q,i.tick,X,!1,u)])}));let it=gt?1:N.max(Mt.values(),Y=>Y.length)??1,Yt=gt?X*Math.sin(pn*Math.PI/180)+i.tick:i.tick*(1.2+xe*(it-1));gt&&e.panels.forEach((Y,_)=>{if(Y.col!==0||!Tt(Y,_))return;let Q=q/(r[_].x.length+.2),lt=Math.min(p(r[_].x[0],i.tick),X)*Math.cos(pn*Math.PI/180)+i.tick*.5;pt[0]=Math.max(pt[0],Math.ceil(lt-.6*Q))}),e.panels.forEach((Y,_)=>{Tt(Y,_)&&(dt[Y.row]=Math.max(dt[Y.row],Math.ceil(Yt+xt.size+xt.padding+3)))}),q=(J.w-N.sum(pt)-g*(e.ncol-1)-ve)/e.ncol,W=(J.h-Nt-N.sum(dt)-e.nrow*Ot-Wt-g*(e.nrow-1))/e.nrow}q=Math.max(20,q),W=Math.max(20,W);let ee={w:q,h:W};c.aspect?W>q*c.aspect?W=q*c.aspect:q=W/c.aspect:c.flat&&e.panels.length===1&&(W=Math.min(W,q*c.flat));let qn=(ee.h-W)*e.nrow/2,Ae=(ee.w-q)*e.ncol/2,Wn=N.cumsum([J.x+Ae,...pt.slice(0,-1).map(A=>A+q+g)]),Yn=N.cumsum([J.y+Nt+Wt+qn,...dt.slice(0,-1).map(A=>Ot+W+A+g)]),jt=e.panels.map((A,j)=>({x:Wn[A.col],y:Yn[A.row]+Ot,w:pt[A.col]+q,h:W+dt[A.row],ml:pt[A.col],mb:dt[A.row],innerW:q,innerH:W,count:te,rotateX:gt,wrapX:Mt,showX:Tt(A,j),showY:Ee(A)})),Xn=A=>[A.strips.top!=null&&[A.strips.top,q],A.strips.right!=null&&[A.strips.right,W]].filter(Boolean),_n=Math.max(c.shrink??1,Math.min(1,N.min(e.panels.flatMap(Xn),([A,j])=>(j-8)/p(A,i.strip,!0))??1)),ne=Math.round(i.strip*_n*10)/10,oe=[];e.panels.forEach((A,j)=>{let X=jt[j],it=X.x+X.ml,Yt=(Y,_)=>ft(Y,ne,_-8,!0,u);A.strips.top!=null&&oe.push({x:it,y:X.y-Ot-Wt,w:q,h:Bt,text:Yt(A.strips.top,q),full:A.strips.top,size:ne}),A.strips.right!=null&&oe.push({x:it+q+2,y:X.y,w:Bt,h:W,text:Yt(A.strips.right,W),full:A.strips.right,vertical:!0,size:ne})});let re=jt[0],Fe=jt.find((A,j)=>e.panels[j].col===e.ncol-1)??re,Et=re.x+re.ml,se=Fe.x+Fe.w,Se=N.max(jt,A=>A.y+A.h),At=[],ie=d;for(let A of R)At.push({text:A,attrs:{x:Et,y:ie+=C*1.05,"font-size":C,"font-weight":"bold",fill:c.ink,"text-anchor":"start"}}),ie+=C*.2;for(let A of V)At.push({text:A,attrs:{x:Et,y:ie+=$*1.3,"font-size":$,fill:c.muted,"text-anchor":"start"}});if(x&&At.push({text:x,attrs:{x:(Et+se)/2,y:Se+i.axisTitle*1.35,"text-anchor":"middle","font-size":i.axisTitle,fill:c.muted}}),v){let A=J.y+(J.h-N.sum(dt))/2;At.push({text:v,attrs:{transform:`translate(${d+Ae+i.axisTitle*.85},${A}) rotate(-90)`,"text-anchor":"middle","font-size":i.axisTitle,fill:c.muted}})}b&&At.push({text:ft(b,i.tick,l-2*d,!1,u),attrs:{x:Et,y:a-d-(kt||0)+i.tick*.2,"font-size":i.tick,fill:c.muted,"text-anchor":"start"}});let Ce=se+ve+h*1.5,Le=Ce<l-d-st-1?Ce:l-d-st,Gn=s?s.position==="right"?{x:Le,y:J.y}:{x:Math.max(d,Math.min(Et,l-d-s.width)),y:Se+f+g/2}:null,De=m("right")?s.height+h:0,Vn=o?o.horizontal?{x:Math.max(d,(Et+se-o.width)/2),y:a-d-o.height}:{x:Le,y:J.y+De+Math.max(0,(J.h-N.sum(dt)-De-o.height)/2)}:null;return{panels:jt,strips:oe,texts:At,legend:Vn,info:Gn,area:J,room:ee,rotateX:gt}}function hn(t,e={}){if(typeof t?.spec=="function"&&(t=t.spec()),t?.version!==1)throw new Error("plotto: unknown spec version");let n=je({...t.theme,...e});n.legendSet=(e.legend??t.theme?.legend)!=null;let r=t.data.map(Po),o=t.layers.map(a=>$o(a,t.mapping??{},r,n));if(!o.length)throw new Error("plotto: the plot has no layers. Add one, for example .line() or .point()");let s=Bo(t.facet),i={...Oo(o),...t.labels},l=t.info?.entries?.length?{entries:t.info.entries,position:t.info.position??"right",set:!!t.info.position}:null;return{tables:r,layers:o,facet:s,scales:t.scales??{},labels:i,info:l,theme:n}}function Po({columns:t}){let e=Object.keys(t),n=e.length?t[e[0]].values.length:1;return{columns:t,n}}function $o(t,e,n,r){let o=H.layers[t.type];if(!o)throw new Error(`plotto: unknown layer type "${t.type}". Valid: ${Object.keys(H.layers).join(", ")}`);let s=t.data??0,i=n[s].columns,l={};for(let u of o.channels)t.mapping?.[u]!==void 0?l[u]={column:t.mapping[u]}:t.set?.[u]!==void 0?l[u]={value:t.set[u]}:o.inherit!==!1&&e[u]in i&&(l[u]={column:e[u]});let a=o.requires.filter(u=>!l[u]);if(a.length)throw new Error(`${t.type}(): set ${a.join(" and ")}, as a column name or a value`);if(l.color&&"value"in l.color){let u=Ct(r,l.color.value);if(!u)throw new Error(`${t.type}(): "${l.color.value}" is not a column or a color. Theme colors: ${Ie(r).join(", ")}`);l.color={value:u}}let c={};for(let u of o.options)t.set?.[u]!==void 0&&(c[u]=t.set[u]);return{type:t.type,table:s,channels:l,options:c}}function Bo(t){if(!t)return null;let e={x:["x","both"].includes(t.free),y:["y","both"].includes(t.free)};return t.wrap?{kind:"wrap",by:t.wrap,ncol:t.ncol??null,free:e}:{kind:"grid",rows:t.rows??null,cols:t.cols??null,free:e}}function Oo(t){let e=o=>{for(let s of t)for(let i of o)if(s.channels[i]?.column)return s.channels[i].column},n=t.find(o=>o.type==="hist"||o.type==="density"),r=e(["y","ymin","yend"])??(n?n.type==="density"||n.options.density?"density":"count":void 0);return{x:e(["x","xmin","xend"]),y:r,color:e(["color"])}}function fn(t){return t.layers.map(e=>e.type!=="hist"||!e.channels.x.column?null:on(t.tables[e.table].columns[e.channels.x.column].values,e.options.bins??30))}function ye(t,e,n,r){let{ns:o,kind:s,colorLevels:i,edges:l}=t;if(r.size&&e.channels.color?.column){let w=o.tables[e.table].columns[e.channels.color.column].values;n=n.filter(b=>!r.has(w[b]))}let a={};for(let w of Object.keys(e.channels))a[w]=Xe(o,e,w,n);let c=n.length,u=e.options,p=(w,b,x)=>en(w,b,x,i),h=w=>w.x?.length??0,d=a,g=n;if(u.summary&&(e.type==="line"||e.type==="point"))d=tn(a,c,u.summary);else if(e.type==="bar")d=p(a,c,u.position??"stack"),s.x!=="category"&&(d=nn(d,c));else if(e.type==="area")d=p(a,c,u.position??"stack");else if(e.type==="hist"){let w=rn(a,c,l[o.layers.indexOf(e)],u.density);d=p(w,h(w),u.position??"stack")}else e.type==="density"?d=sn(a,c):e.type==="smooth"&&(d=ln(a,c,u));d!==a&&(g=null);let y={cols:d,n:d===a?c:h(d),rows:g};return y.hover=To(o,e,y),y}function To(t,e,{cols:n,rows:r}){let o=t.labels.x||e.channels.x?.column||"x",s=t.labels.y||e.channels.y?.column||"y",i=(c,u,p,h)=>({label:c,axis:u,values:p,values2:h}),l=i(o,"x",n.x),a=e.channels.tooltip?.column&&r?[i(e.channels.tooltip.column,null,n.tooltip)]:[];switch(e.type){case"line":case"path":case"step":case"point":return{hx:n.x,hy:n.y,fields:[l,i(s,"y",n.y),...a]};case"bar":case"area":return{hx:n.x,hy:n.ymax,fields:[l,i(s,"y",n.value),...a]};case"hist":return{hx:n.x,hy:n.ymax,fields:[i(o,"x",n.xmin,n.xmax),i(e.options.density?"density":"count",null,n.value)]};case"density":return{hx:n.x,hy:n.y,fields:[l,i("density",null,n.y)]};case"smooth":{let c=n.ymin.some(u=>u!==null)?[i("95% CI","y",n.ymin,n.ymax)]:[];return{hx:n.x,hy:n.y,fields:[l,i(s,"y",n.y),...c]}}case"ribbon":return{hx:n.x,hy:n.ymax,fields:[l,i(s,"y",n.ymin,n.ymax)]};case"errorbar":return{hx:n.x,hy:n.ymax,fields:[l,i(s,"y",n.ymin,n.ymax)]};case"tile":{let c=e.channels.color?.column?[i(t.labels.color??"value",null,n.color)]:[];return{hx:n.x,hy:n.y,fields:[l,i(s,"y",n.y),...c,...a],tile:!0}}case"box":return{hx:n.x,hy:n.y,fields:[l,i(s,"y",n.y)]};default:return null}}var mn=560,xn=240,No=1.2,jo=.05,Ho=.2,Io=.3;function Zt(t,{document:e=globalThis.document,width:n,domains:r,hidden:o=new Set}={}){let s=hn(t),i=s.theme,l=Math.round(n??i.width),c=n&&i.reflow&&!i.fixedHeight?Math.max(xn,Math.round(l*i.height/i.width)):i.height;i.legend==="right"&&l<mn&&(i.legend="bottom");let u=Ke(s),p={x:de(s,"x"),y:de(s,"y")},h=Ue(s),d={ns:s,kind:p,colorLevels:h.domain??[],edges:fn(s)};for(let M of u.panels)M.views=s.layers.map((F,E)=>ye(d,F,M.rows[E],new Set));let g=Wo(s,u,p),y=(M,F,E)=>{let L=qe(i),C={...L,legend:Math.round(L.legend*E*10)/10},$=Je(s,C,{W:l,H:M,narrow:l<mn,place:F.info}),R=$?.position==="right"?$.height+C.base:0,V=cn(s,h,C,{horizontal:F.legend==="bottom",maxWidth:l*.9,maxHeight:M*.8-R}),Z=dn({ns:s,grid:u,kind:p,home:g,legend:V,info:$,fonts:C,W:l,H:M}),z=V?.items??[],B=z.filter(kt=>kt.lines.at(-1).endsWith("\u2026")).length+(z.some(kt=>!V.horizontal&&kt.x>0)?1:0)+($?.cut??0),st=Z.panels[0],Qt=F.legend===i.legend&&F.info===s.info?.position;return{fonts:C,info:$,legend:V,layout:Z,k:E,cut:B,usual:Qt,area:Math.min(st.innerW,st.innerH/Io)*st.innerH}},w=M=>{let F=!i.fitHeight,E=F&&!i.legendSet&&i.legend!=="none"?["right","bottom"]:[i.legend],L=F&&s.info&&!s.info.set?["right","bottom"]:[s.info?.position],C=[];for(let z=1;z>=(i.shrink??1)-1e-9;z-=jo)C.push(z);let $=E.flatMap(z=>L.flatMap(B=>C.map(st=>y(M,{legend:z,info:B},st)))),R=wt.min($,z=>z.cut),V=$.filter(z=>z.cut===R),Z=wt.max(V,z=>z.area);return V.filter(z=>z.area>=Z*(1-Ho)).sort((z,B)=>B.k-z.k||B.usual-z.usual||B.area-z.area)[0]},{fonts:b,info:x,legend:v,layout:m}=w(c);if(i.aspect&&i.fitHeight){let M=c+u.nrow*(m.room.w*i.aspect-m.room.h);c=Math.round(Math.min(c*No,Math.max(xn,M))),{fonts:b,info:x,legend:v,layout:m}=w(c)}let f=O(e,"svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:c,viewBox:`0 0 ${l} ${c}`,"font-family":i.font,"font-size":b.base,style:`color:${i.ink}`});f.append(O(e,"rect",{width:l,height:c,fill:i.background}));for(let M of m.texts)f.append(K(e,M.text,M.attrs));x&&f.append(Qe(e,x,i,m.info));for(let M of m.strips)f.append(Xo(e,M,i));let k={spec:t,ns:s,doc:e,svg:f,theme:i,fonts:b,grid:u,kind:p,color:h,ctx:d,legend:v,info:x,layout:m,home:g,W:l,H:c};return k.domains=r??g,k.hidden=o,k.panelLayer=f.appendChild(O(e,"g",{class:"pt-panels"})),v&&(k.legendG=f.appendChild(wn(k))),yt(k),k}function bn(t,e){return Zt(t,e).svg.outerHTML}function yt(t){let{ns:e,grid:n,ctx:r,hidden:o}=t;if(o.size||t.filtered){for(let s of n.panels)s.views=e.layers.map((i,l)=>ye(r,i,s.rows[l],o));t.filtered=o.size>0}t.panelLayer.replaceChildren(),t.panels=n.panels.map((s,i)=>Ro(t,s,i)),t.legendG&&t.legendG.replaceWith(t.legendG=wn(t))}function wn(t){let e=un(t.doc,t.legend,t.theme,t.fonts,t.hidden);return e.setAttribute("transform",`translate(${t.layout.legend.x},${t.layout.legend.y})`),e}function Ro(t,e,n){let{ns:r,doc:o,theme:s,fonts:i,kind:l,color:a}=t,c=t.layout.panels[n],u={x:yn(l.x,t.domains[n].x),y:yn(l.y,t.domains[n].y)},p={x:l.x==="category"?c.innerW/(u.x.length+.2)*.8:0},h=r.layers.map((f,k)=>{let M=e.views[k],F=qo({view:M,layer:f,kind:l,color:a,theme:s,fonts:i,domain:u,bandwidth:p});return{layer:f,view:M,c:F,marks:M.n?an[f.type](F):[]}}),d=f=>{let k=vt(l[f],t.domains[n][f],c.count[f],r.scales[f]?.format),M=F=>l[f]==="category"||+F>=+u[f][0]&&+F<=+u[f][1];return{major:k.major.filter(M),minor:k.minor,format:k.format}},g=d("x"),y=d("y"),w=f=>({stroke:f?s.gridMinor:s.grid,strokeOpacity:1,strokeWidth:f?.6:.9}),b={tickSize:xt.size,tickPadding:xt.padding,fontSize:i.tick,stroke:s.tick,fill:s.muted,label:null},x=[];if(l.x!=="category"&&x.push(et.gridX(g.minor,w(!0)),et.gridX(g.major,w(!1))),l.y!=="category"&&x.push(et.gridY(y.minor,w(!0)),et.gridY(y.major,w(!1))),x.push(...h.flatMap(f=>f.marks)),c.showX){let f=c.rotateX?{tickRotate:-40,textAnchor:"end"}:{},k=F=>c.wrapX.get(String(F))?.join(`
|
|
2
|
+
`)??g.format(F),M=c.wrapX.size?{tickFormat:k,lineHeight:xe}:{tickFormat:g.format};x.push(et.axisX(g.major,{...b,...f,anchor:"bottom",...M}))}c.showY&&x.push(et.axisY(y.major,{...b,anchor:"left",tickFormat:y.format}));let v=et.plot({document:o,width:c.w,height:c.h,marginLeft:c.ml,marginRight:0,marginTop:0,marginBottom:c.mb,x:gn(l.x,u.x),y:gn(l.y,u.y),color:{type:"identity"},marks:x}),m=O(o,"g",{class:"pt-panel","data-panel":n,transform:`translate(${c.x},${c.y})`,fill:"currentColor","text-anchor":"middle"});for(let f of[...v.childNodes])f.nodeName.toLowerCase()!=="style"&&m.append(f);return t.panelLayer.append(m),{g:m,plot:v,box:c,layers:h}}function qo({view:t,layer:e,kind:n,color:r,theme:o,fonts:s,domain:i,bandwidth:l}){let a=h=>Rt.x.includes(h)?"x":Rt.y.includes(h)?"y":null,c={},u=h=>{if(h in c)return c[h];let d=t.cols[h];return d&&n[a(h)]==="time"&&(d=d.map(g=>g===null?null:new Date(g))),c[h]=d},p=e.channels.color;return{index:wt.range(t.n),v:u,options:e.options,colors:h=>p?"value"in p?p.value:u("color").map(r.apply):h,groups:()=>u("group")??(p?.column?u("color"):void 0),kind:n,theme:o,fonts:s,domain:i,bandwidth:l}}function yn(t,e){return t==="time"?e.map(n=>new Date(n)):e}function gn(t,e){return{type:{linear:"linear",log:"log",time:"utc",category:"band"}[t],domain:e,axis:null,...t==="category"?{padding:.2,round:!1}:{}}}function Wo(t,e,n){let r=t.facet?.free??{x:!1,y:!1},o=(i,l,a)=>r[i]?e.kind==="grid"?i==="x"?`c${l.col}`:`r${l.row}`:`p${a}`:"all",s=e.panels.map(()=>({}));for(let i of["x","y"]){let l=wt.group(e.panels.map((a,c)=>[a,c]),([a,c])=>o(i,a,c));for(let a of l.values()){let c=Yo(t,i,n[i],a.map(([u])=>u));for(let[,u]of a)s[u][i]=c}}return s}function Yo(t,e,n,r){let o=t.scales[e]?.limits;if(o&&(n==="category"||o.every(i=>i!==null)))return o;let s=_e(t,e,n,r);return o?[o[0]??s[0],o[1]??s[1]]:s}function Xo(t,e,n){let r=O(t,"g",{class:"pt-strip"});r.append(O(t,"rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:n.strip}));let o=e.vertical?{transform:`translate(${e.x+e.w/2},${e.y+e.h/2}) rotate(90)`,dy:"0.35em"}:{x:e.x+e.w/2,y:e.y+e.h/2,dy:"0.35em"},s=K(t,e.text,{...o,"text-anchor":"middle","font-weight":"bold","font-size":e.size,fill:n.ink});return e.text!==String(e.full)&&s.append(K(t,e.full,{},"title")),r.append(s),r}async function ge(t,e,n=2){let r=Mn(t,e?n*e.width/t.viewBox.baseVal.width:n),o={"image/png":r.then(_o)};if(e){let s=i=>`<img src="${i.toDataURL("image/png")}" width="${e.width}" height="${e.height}">`;o["text/html"]=r.then(i=>new Blob([s(i)],{type:"text/html"}))}try{return await navigator.clipboard.write([new ClipboardItem(o)]),"Copied"}catch{return be((await r).toDataURL("image/png"),"plot.png"),"Downloaded"}}async function kn(t){be((await Mn(t)).toDataURL("image/png"),"plot.png")}function vn(t){be(En(t),"plot.svg")}async function Mn(t,e=2){let n=new Image;n.src=En(t),await n.decode();let{width:r,height:o}=t.viewBox.baseVal,s=document.createElement("canvas");return s.width=Math.round(r*e),s.height=Math.round(o*e),s.getContext("2d").drawImage(n,0,0,s.width,s.height),s}function En(t){let e=t.cloneNode(!0);e.querySelector(".pt-overlay")?.remove();let{width:n,height:r}=t.viewBox.baseVal;e.setAttribute("width",n),e.setAttribute("height",r);let o=new TextEncoder().encode(new XMLSerializer().serializeToString(e)),s="";for(let i of o)s+=String.fromCharCode(i);return`data:image/svg+xml;base64,${btoa(s)}`}var _o=t=>new Promise(e=>t.toBlob(e,"image/png"));function be(t,e){let n=document.createElement("a");n.href=t,n.download=e,n.click()}import*as rt from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var Sn=40,Go=10,Vo=6,Cn=4,Uo=6,Ko=["line","step","area","density","smooth","ribbon"],Zo=["bar","hist","tile","box"],Jo=["point","path","errorbar"];function Ln(t,e,n,r,o){let s=t.panels[e],i=s.plot.scale("x"),l=s.plot.scale("y"),u={state:t,sx:i,sy:l,px:y=>i.apply(y)+(i.bandwidth??0)/2,py:y=>l.apply(y)+(l.bandwidth??0)/2},p=or(u,s,n);if(p)return{...p,panel:e};let h=tr(u,s,n,r,o?.panel===e?o:null);if(h&&h.d<=Go)return{...An(u,h),panel:e};let d=er(u,s,n,r,o?.panel===e?o:null);if(d)return{...d,panel:e};let g=rr(u,s,n,r);return g?{...g,panel:e}:h?{...An(u,h),panel:e}:null}function $t(t,e,n,r,o){let s=e.channels.color;return s?"value"in s?s.value:t.color.apply(n.cols.color[o]):e.type==="smooth"?t.theme.accent:t.theme.palette[0]}function ot(t,e,n){return n==null||Number.isNaN(n)?"\u2013":e&&t.kind[e]==="time"?Qo(t,e)(n):e&&t.kind[e]==="category"?String(n):typeof n=="number"?Ve.number(n):String(n)}function Qo(t,e){if(t.timeFormats??={},t.timeFormats[e])return t.timeFormats[e];let n=t.grid.panels.flatMap(s=>s.views.flatMap(i=>i.cols[e]??[])).filter(s=>s!==null),r=s=>n.every(i=>s(new Date(i))),o=r(s=>s.getUTCDate()===1&&s.getUTCHours()===0&&s.getUTCMinutes()===0)?"%Y-%m":r(s=>s.getUTCHours()===0&&s.getUTCMinutes()===0)?"%Y-%m-%d":r(s=>s.getUTCSeconds()===0)?"%m-%d %H:%M":"%m-%d %H:%M:%S";return t.timeFormats[e]=rt.utcFormat(o)}function Pt(t,e,n){return e.values2?`${ot(t,e.axis,e.values[n])} \u2013 ${ot(t,e.axis,e.values2[n])}`:ot(t,e.axis,e.values[n])}function tr({px:t,py:e},n,r,o,s){let i=null,l=null;for(let{layer:a,view:c,c:u}of n.layers){if(!Jo.includes(a.type)||!c.hover||!c.n)continue;let{hx:p,hy:h}=c.hover;for(let d=0;d<c.n;d++){if(p[d]===null||h[d]===null)continue;let g=Math.hypot(t(p[d])-r,e(h[d])-o);if(g>Sn)continue;let y={layer:a,view:c,c:u,k:d,d:g,x:t(p[d]),y:e(h[d])};(!i||g<i.d)&&(i=y),s?.layer===a&&s.k===d&&(l=y)}}return l&&i&&i.d>l.d-Cn?l:i}function An({state:t},{layer:e,view:n,c:r,k:o,x:s,y:i,d:l}){let a=$t(t,e,n,r,o),c=e.channels.color?.column?ot(t,null,n.cols.color[o]):null,u=n.hover.fields.map(p=>({label:p.label,value:Pt(t,p,o)})).filter(p=>p.value!==c);return{layer:e,k:o,d:l,color:a,header:c,rows:u,marks:[{x:s,y:i,color:a}],anchor:{x:s,y:i}}}function er({state:t,px:e,py:n},r,o,s,i){let l=[];for(let{layer:m,view:f,c:k}of r.layers){if(!Ko.includes(m.type)||!f.hover||!f.n)continue;let{hx:M,hy:F}=f.hover,E=k.groups()??[],L=new Map;for(let C=0;C<f.n;C++){if(M[C]===null||F[C]===null)continue;let $=Math.abs(e(M[C])-o),R=E[C]??"";$<=Sn&&(!L.has(R)||$<L.get(R).dx)&&L.set(R,{layer:m,view:f,c:k,k:C,dx:$,series:R})}l.push(...L.values())}if(!l.length)return null;let a=rt.least(l,m=>m.dx),c=e(a.view.hover.hx[a.k]),u=l.filter(m=>Math.abs(e(m.view.hover.hx[m.k])-c)<=Vo);for(let m of u)m.y=n(m.view.hover.hy[m.k]);let p=rt.least(u,m=>Math.abs(m.y-s)),h=i?.series!==void 0&&u.find(m=>m.layer===i.layer&&m.series===i.series);h&&Math.abs(h.y-s)<Math.abs(p.y-s)+Cn&&(p=h);let d=m=>m.layer.channels.color?.column?ot(t,null,m.view.cols.color[m.k]):m.series!==""?String(m.series):m.view.hover.fields[1]?.label??m.layer.type,g=m=>$t(t,m.layer,m.view,m.c,m.k),y=a.view.hover.fields[0],w=ot(t,"x",a.view.hover.hx[a.k]),b={crosshair:c,anchor:{x:c,y:s},layer:p.layer,series:p.series};if(u.length===1||u.length>Uo){let m=[{label:y?.label??"x",value:w},{label:p.view.hover.fields[1]?.label??"y",value:Fn(t,p.layer,p.view,p.k)}],f=u.length-1;return{...b,color:g(p),header:d(p),rows:m,note:f?`${f} other series at this x`:null,marks:[{x:c,y:p.y,color:g(p)}]}}let x=nr(t);u.sort((m,f)=>x(m)-x(f)||m.y-f.y);let v=u.map(m=>({swatch:g(m),label:d(m),value:Fn(t,m.layer,m.view,m.k),strong:m===p}));return{...b,color:t.theme.ink,header:y?`${y.label} ${w}`:w,rows:v,marks:u.map(m=>({x:c,y:m.y,color:g(m)}))}}function nr(t){let{color:e}=t;return n=>{let r=n.layer.channels.color?.column?n.view.cols.color[n.k]:null;return r===null?t.ns.layers.indexOf(n.layer):e.kind==="ordinal"?e.domain.indexOf(r):typeof r=="number"?r:0}}function Fn(t,e,n,r){let o=n.hover.fields;return e.type==="smooth"&&o[2]?`${Pt(t,o[1],r)} (${Pt(t,o[2],r)})`:Pt(t,o[1],r)}function or(t,e,n){for(let{layer:r,view:o,c:s}of e.layers)if(r.type==="box"&&o.n)return ir(t,r,o,s,n);return null}function rr(t,e,n,r){let{state:o,sx:s,sy:i}=t;for(let{layer:l,view:a,c}of e.layers){if(!Zo.includes(l.type)||l.type==="box"||!a.n)continue;let u=l.type==="tile",p=null;for(let y=0;y<a.n;y++){let[w,b]=lr(l,a,y,s),x=Math.abs((w+b)/2-n);if(u?n<w-we(s,b-w)||n>b+we(s,b-w):x>b-w)continue;let[v,m]=ar(l,a,y,i),[f,k]=[Math.min(v,m),Math.max(v,m)],M=u?we(i,k-f):0,F=r>=f-M&&r<=k+M;if(u&&!F)continue;let E=Math.round(x)*1e6+(F?0:1e5+f);(!p||E<p.score)&&(p={k:y,score:E,rect:{x:w,y:f,width:b-w,height:k-f}})}if(!p)continue;let{k:h,rect:d}=p,g=$t(o,l,a,c,h);if(u){let y=o.ns.labels.color??l.channels.color?.column??"value",w=l.channels.color?.column?ot(o,null,a.cols.color[h]):null,b=a.hover.fields.filter(x=>x.label!==y).map(x=>({label:x.label,value:Pt(o,x,h)}));return{color:g,header:w!==null?`${y} ${w}`:null,rows:b,marks:[{rect:d,color:o.theme.ink}],anchor:{x:d.x+d.width,y:r}}}return sr(o,l,a,c,h,d)}return null}function we(t,e){return t.bandwidth!==void 0?(t.step-t.bandwidth)/2||e*.125:.5}function sr(t,e,n,r,o,s){let i=e.type==="hist"?h=>n.cols.xmin[h]===n.cols.xmin[o]:h=>String(n.cols.x[h])===String(n.cols.x[o]),l=rt.range(n.n).filter(i),a=!!e.channels.color?.column,c=l.sort((h,d)=>a&&t.color.kind==="ordinal"?t.color.domain.indexOf(n.cols.color[h])-t.color.domain.indexOf(n.cols.color[d]):n.cols.ymax[d]-n.cols.ymax[h]).map(h=>({swatch:$t(t,e,n,r,h),label:a?ot(t,null,n.cols.color[h]):n.hover.fields[1].label,value:ot(t,null,n.cols.value[h]),strong:h===o&&l.length>1}));(e.options.position??"stack")==="stack"&&l.length>1&&c.push({label:"total",value:ot(t,null,rt.sum(l,h=>n.cols.value[h])),strong:!1,total:!0});let p=n.hover.fields[0];return{color:$t(t,e,n,r,o),header:`${p.label} ${Pt(t,p,o)}`,rows:c,marks:[{rect:s,color:t.theme.ink}],anchor:{x:s.x+s.width,y:s.y}}}function ir({state:t,sx:e},n,r,o,s){if(e.bandwidth===void 0)return null;let i=rt.range(r.n).find(v=>{let m=e.apply(r.cols.x[v]);return s>=m&&s<=m+e.bandwidth});if(i===void 0)return null;let l=String(r.cols.x[i]),{n:a,q1:c,median:u,q3:p,low:h,high:d,outliers:g}=Ut(rt.range(r.n).filter(v=>String(r.cols.x[v])===l).map(v=>r.cols.y[v])),y=v=>ot(t,"y",v),w=[{label:"max (whisker)",value:y(d)},{label:"q3",value:y(p)},{label:"median",value:y(u),strong:!0},{label:"q1",value:y(c)},{label:"min (whisker)",value:y(h)},{label:"n",value:String(a)}];g.length&&w.push({label:"outliers",value:String(g.length)});let b=e.apply(r.cols.x[i]);return{color:n.channels.color?.column?$t(t,n,r,o,i):t.theme.ink,header:`${r.hover.fields[0].label} ${l}`,rows:w,marks:[],anchor:{x:b+e.bandwidth,y:null}}}function lr(t,e,n,r){if(e.cols.xmin&&t.type!=="tile")return[r.apply(e.cols.xmin[n]),r.apply(e.cols.xmax[n])];if(r.bandwidth!==void 0){let i=e.cols.slots?.[n]??1,l=r.bandwidth/i,a=r.apply(e.cols.x[n])+(e.cols.slot?.[n]??0)*l;return[a,a+l]}let o=Dn(e.cols.x,r),s=r.apply(e.cols.x[n]);return[s-o,s+o]}function ar(t,e,n,r){if(t.type==="tile"){if(r.bandwidth!==void 0)return[r.apply(e.cols.y[n]),r.apply(e.cols.y[n])+r.bandwidth];let o=Dn(e.cols.y,r),s=r.apply(e.cols.y[n]);return[s-o,s+o]}return[r.apply(e.cols.ymin[n]),r.apply(e.cols.ymax[n])]}function Dn(t,e){let n=[...new Set(t.map(Number))].sort((o,s)=>o-s),r=1/0;for(let o=1;o<n.length;o++)r=Math.min(r,n[o]-n[o-1]);return Number.isFinite(r)?Math.abs(e.apply(n[0]+r)-e.apply(n[0]))/2:6}var cr={zoom:'<path d="M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5"/><rect x="9" y="9" width="6" height="6"/>',pan:'<path d="M12 3v18M3 12h18M12 3l-2.5 2.5M12 3l2.5 2.5M12 21l-2.5-2.5M12 21l2.5-2.5M3 12l2.5-2.5M3 12l2.5 2.5M21 12l-2.5-2.5M21 12l-2.5 2.5"/>',zoomIn:'<path d="M12 5v14M5 12h14"/>',zoomOut:'<path d="M5 12h14"/>',home:'<path d="M4 11l8-7 8 7M6 9.5V20h12V9.5"/>',copy:'<rect x="8.5" y="8.5" width="11" height="11"/><path d="M15.5 8.5V4.5h-11v11h4"/>',slide:'<rect x="3.5" y="4.5" width="17" height="11"/><path d="M12 15.5v4M8 19.5h8M7 12.5l3-3 2.5 2 4.5-4"/>',download:'<path d="M12 4v11M7.5 10.5L12 15l4.5-4.5M5 19.5h14"/>',check:'<path d="M5 12.5l4.5 4.5L19 7.5"/>'},ur=`
|
|
3
|
+
.pt-root{position:relative;--pt-size:24px}
|
|
4
|
+
.pt-root svg{display:block;user-select:none;-webkit-user-select:none}
|
|
5
|
+
.pt-root .pt-key{cursor:pointer}
|
|
6
|
+
.pt-root:focus{outline:none}
|
|
7
|
+
.pt-bar{position:absolute;top:6px;right:6px;display:flex;align-items:stretch;z-index:3;background:var(--pt-bg);
|
|
8
|
+
border:1px solid var(--pt-line);opacity:0;transition:opacity .12s ease}
|
|
9
|
+
.pt-root:hover .pt-bar,.pt-root:focus-within .pt-bar,.pt-bar.pt-open{opacity:1}
|
|
10
|
+
@media (hover:none){.pt-bar{opacity:1}}
|
|
11
|
+
.pt-btn{all:unset;box-sizing:border-box;display:grid;place-items:center;width:var(--pt-size);height:var(--pt-size);
|
|
12
|
+
color:var(--pt-muted);cursor:pointer}
|
|
13
|
+
.pt-btn svg{width:58%;height:58%;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:square;stroke-linejoin:miter}
|
|
14
|
+
.pt-btn:hover{color:var(--pt-ink);background:var(--pt-soft)}
|
|
15
|
+
.pt-btn:focus-visible{outline:2px solid var(--pt-accent);outline-offset:-2px}
|
|
16
|
+
.pt-btn.pt-on{color:var(--pt-on-accent);background:var(--pt-accent)}
|
|
17
|
+
.pt-sep{width:1px;background:var(--pt-line)}
|
|
18
|
+
.pt-menu{position:absolute;top:100%;right:-1px;display:none;flex-direction:column;min-width:72px;margin-top:-1px;
|
|
19
|
+
background:var(--pt-bg);border:1px solid var(--pt-line)}
|
|
20
|
+
.pt-menu.pt-open{display:flex}
|
|
21
|
+
.pt-menu button{all:unset;padding:5px 12px;font:600 11px/1.4 system-ui,sans-serif;letter-spacing:.04em;color:var(--pt-ink);cursor:pointer}
|
|
22
|
+
.pt-menu button:hover{color:var(--pt-on-accent);background:var(--pt-accent)}
|
|
23
|
+
.pt-tip{position:absolute;display:none;pointer-events:none;z-index:4;min-width:110px;max-width:280px;background:var(--pt-bg);
|
|
24
|
+
color:var(--pt-ink);border:1px solid var(--pt-c);line-height:1.3;font-variant-numeric:tabular-nums}
|
|
25
|
+
.pt-tip.pt-pinned{border-width:2px;box-shadow:3px 3px 0 color-mix(in srgb,var(--pt-c) 35%,transparent)}
|
|
26
|
+
.pt-tip .pt-head{padding:3px 7px;background:var(--pt-c);color:var(--pt-on-c);font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
27
|
+
.pt-tip .pt-rows{display:grid;grid-template-columns:auto minmax(0,1fr) auto;column-gap:7px;row-gap:0;padding:4px 7px 5px}
|
|
28
|
+
.pt-tip .pt-sw{width:8px;height:8px;align-self:center}
|
|
29
|
+
.pt-tip .pt-k{color:var(--pt-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
30
|
+
.pt-tip .pt-v{text-align:right;white-space:nowrap}
|
|
31
|
+
.pt-tip .pt-b{color:var(--pt-ink);font-weight:700}
|
|
32
|
+
.pt-tip .pt-t{border-top:1px solid var(--pt-line);padding-top:2px;margin-top:1px}
|
|
33
|
+
.pt-tip .pt-more{grid-column:1/-1;color:var(--pt-muted);font-size:.9em}
|
|
34
|
+
.pt-error{padding:8px 10px;border-left:3px solid #d93025;background:#fdecea;color:#5f2120;font:12px/1.4 ui-monospace,monospace;white-space:pre-wrap}
|
|
35
|
+
`;function Pn(t){if(t.getElementById("plotto-style"))return;let e=t.createElement("style");e.id="plotto-style",e.textContent=ur,t.head.append(e)}function $n(t,e){let n={bg:e.background,ink:e.ink,muted:e.muted,line:e.grid,soft:e.strip,accent:e.accent,"on-accent":Re(e.accent)};for(let[r,o]of Object.entries(n))t.style.setProperty(`--pt-${r}`,o)}function Bn(t,e){let n=t.createElement("div");n.className="pt-bar";let r={},o=null;e.forEach((i,l)=>{l&&n.append(Object.assign(t.createElement("div"),{className:"pt-sep"}));for(let a of i){let c=t.createElement("button");c.className="pt-btn",c.type="button",c.title=a.title,c.setAttribute("aria-label",a.title),c.innerHTML=zn(a.name),c.addEventListener("pointerdown",u=>u.stopPropagation()),c.addEventListener("click",u=>(u.stopPropagation(),a.menu?s():a.action(c))),n.append(c),r[a.name]=c,a.menu&&(o=pr(t,n,a.menu))}});function s(){let i=!o.classList.contains("pt-open");o.classList.toggle("pt-open",i),n.classList.toggle("pt-open",i)}return o&&t.addEventListener("click",()=>o.classList.contains("pt-open")&&s()),{el:n,button:i=>r[i],setSize:i=>n.parentElement?.style.setProperty("--pt-size",`${Math.round(Math.min(30,Math.max(22,i/34)))}px`),flash(i,l){let a=r[i],[c,u]=[a.innerHTML,a.title];a.innerHTML=zn("check"),a.title=l,a.classList.add("pt-on"),setTimeout(()=>(a.innerHTML=c,a.title=u,a.classList.remove("pt-on")),1100)}}}function pr(t,e,n){let r=t.createElement("div");r.className="pt-menu";for(let[o,s]of n){let i=t.createElement("button");i.type="button",i.textContent=o,i.addEventListener("click",l=>(l.stopPropagation(),r.classList.remove("pt-open"),e.classList.remove("pt-open"),s())),r.append(i)}return e.append(r),r}function zn(t){return`<svg viewBox="0 0 24 24" aria-hidden="true">${cr[t]}</svg>`}var Jt=5,ke=320,On=.75,dr=300,hr=4;function fr(t,e){let n=typeof t?.spec=="function"?t.spec():t,r={...n.theme,format:"slide",width:null,height:null,size:null},o=e.domains===e.home?void 0:e.domains;return Zt({...n,theme:r},{document:e.doc,domains:o,hidden:e.hidden})}function mr(t,e){let n=fr(t,e);return ge(n.svg,{width:n.W,height:n.H},hr)}function Nn(t,e,{interactive:n=!1,width:r}={}){let o=e.ownerDocument;Pn(o);let s=o.createElement("div");s.className="pt-root";let i=Object.assign(o.createElement("div"),{className:"pt-tip"}),l={state:null,mode:"zoom"},a=null,c=d=>{let g=l.state&&{domains:l.state.domains===l.state.home?void 0:l.state.domains,hidden:l.state.hidden},y=Zt(t,{document:o,width:d,...g}),w=l.state?.svg;y.overlay=y.svg.appendChild(O(o,"g",{class:"pt-overlay","pointer-events":"none"})),y.theme.reflow||(y.svg.setAttribute("width","100%"),y.svg.removeAttribute("height"),s.style.maxWidth=`${y.W}px`),w?w.replaceWith(y.svg):s.prepend(y.svg),l.state=y,$n(s,y.theme),p.setSize(y.theme.reflow?y.W:Math.min(y.W,e.clientWidth||y.W))},u=[[{name:"copy",title:"Copy as PNG",action:d=>ge(l.state.svg).then(g=>p.flash("copy",g))},{name:"slide",title:"Copy for a slide",action:()=>mr(t,l.state).then(d=>p.flash("slide",d))},{name:"download",title:"Download",menu:[["PNG",()=>kn(l.state.svg)],["SVG",()=>vn(l.state.svg)]]}]];n&&u.unshift([{name:"zoom",title:"Zoom: drag a box",action:()=>h("zoom")},{name:"pan",title:"Pan: drag the view",action:()=>h("pan")}],[{name:"zoomIn",title:"Zoom in",action:()=>Tn(l,On)},{name:"zoomOut",title:"Zoom out",action:()=>Tn(l,1/On)},{name:"home",title:"Reset view (double-click)",action:()=>jn(l)}]);let p=Bn(o,u);s.append(p.el,i);let h=d=>{l.mode=d,p.button("zoom").classList.toggle("pt-on",d==="zoom"),p.button("pan").classList.toggle("pt-on",d==="pan"),s.style.cursor=d==="pan"?"grab":""};try{let d=r??(e.clientWidth?Math.max(ke,e.clientWidth):void 0);c(d),e.replaceChildren(s)}catch(d){let g=Object.assign(o.createElement("div"),{className:"pt-error",textContent:`plotto: ${d.message}`});throw e.prepend(g),d}if(n&&(h("zoom"),xr(l,s,i)),l.state.theme.reflow&&r===void 0&&typeof ResizeObserver<"u"){let d;a=new ResizeObserver(()=>{clearTimeout(d),d=setTimeout(()=>{let g=Math.max(ke,Math.round(e.clientWidth));g&&g!==l.state.W&&c(g)},100)}),a.observe(e)}return l.redraw=()=>yt(l.state),l.resize=d=>c(Math.max(ke,d)),l.destroy=()=>a?.disconnect(),l}function xr(t,e,n){let r=null,o=null,s=()=>t.state.svg,i=b=>{let x=s().getBoundingClientRect(),v=t.state.W/x.width;return[(b.clientX-x.left)*v,(b.clientY-x.top)*v,v]},l=(b,x)=>t.state.layout.panels.findIndex(v=>b>=v.x+v.ml&&b<=v.x+v.ml+v.innerW&&x>=v.y&&x<=v.y+v.innerH),a=!1;e.addEventListener("pointerdown",b=>{if(b.button!==0||!s().contains(b.target))return;let[x,v]=i(b),m=l(x,v);m<0||(b.preventDefault(),e.focus({preventScroll:!0}),r={i:m,x,y:v,domains:t.state.domains,moving:!1,id:b.pointerId})}),e.addEventListener("pointermove",b=>{let[x,v,m]=i(b);if(r&&!r.moving&&Math.hypot(x-r.x,v-r.y)>=Jt&&(r.moving=!0,e.setPointerCapture(r.id),u(),w(),t.mode==="pan"&&(e.style.cursor="grabbing")),!r?.moving){!a&&!o&&(o=requestAnimationFrame(()=>(o=null,y(x,v,m))));return}if(t.mode==="pan")return wr(t,r,x,v);let f=t.state.layout.panels[r.i],k=z=>Math.max(f.x+f.ml,Math.min(f.x+f.ml+f.innerW,z)),M=z=>Math.max(f.y,Math.min(f.y+f.innerH,z)),[F,E]=[r.x,k(x)].sort((z,B)=>z-B),[L,C]=[r.y,M(v)].sort((z,B)=>z-B),$=C-L<Jt||t.state.kind.y==="category",R=E-F<Jt||t.state.kind.x==="category";if($&&R)return t.state.overlay.replaceChildren();let V={x:R?f.x+f.ml:F,y:$?f.y:L,width:R?f.innerW:E-F,height:$?f.innerH:C-L},Z=t.state.theme.accent;t.state.overlay.replaceChildren(O(t.state.doc,"rect",{...V,fill:Z,"fill-opacity":.1,stroke:Z,"stroke-opacity":.7,"stroke-width":1})),r.box={x0:F,x1:E,y0:L,y1:C}}),e.addEventListener("pointerup",b=>{if(r?.moving&&t.mode==="zoom"&&r.box)br(t,r.i,r.box);else if(r&&!r.moving){let[x,v,m]=i(b);a?(u(),y(x,v,m)):(y(x,v,m),n.style.display==="block"&&c())}t.mode==="pan"&&(e.style.cursor="grab"),a||t.state.overlay.replaceChildren(),r=null}),e.addEventListener("pointerleave",()=>!r&&!a&&w()),e.addEventListener("keydown",b=>b.key==="Escape"&&(u(),w())),e.tabIndex=-1,t.clearHover=()=>(u(),w());function c(){a=!0,n.classList.add("pt-pinned")}function u(){a=!1,n.classList.remove("pt-pinned")}let p=b=>t.state.doc.elementFromPoint(b.clientX,b.clientY),h=b=>p(b)?.closest?.(".pt-key");e.addEventListener("dblclick",b=>{let[x,v]=i(b);l(x,v)<0||(u(),w(),jn(t))});let d={value:void 0,time:0,before:null};e.addEventListener("click",b=>{let x=h(b);if(!x)return;let v=t.state.legend.items[Number(x.dataset.index)].value;t.clearHover();let m=performance.now();if(v===d.value&&m-d.time<dr)return t.state.hidden=d.before,d={value:void 0,time:0,before:null},gr(t,v);d={value:v,time:m,before:t.state.hidden};let f=new Set(t.state.hidden);f.has(v)?f.delete(v):f.add(v),t.state.hidden=f,yt(t.state)});let g=null;function y(b,x,v){let m=t.state,f=l(b,x),k=f<0?null:m.layout.panels[f],M=k?Ln(m,f,b-k.x,x-k.y,g):null;if(g=M,!M)return w();let F=m.doc,E=[];if(M.crosshair!==void 0){let B=k.x+M.crosshair;E.push(O(F,"line",{x1:B,x2:B,y1:k.y,y2:k.y+k.innerH,stroke:m.theme.muted,"stroke-opacity":.55,"stroke-width":1}))}for(let B of M.marks)B.rect?E.push(O(F,"rect",{x:k.x+B.rect.x,y:k.y+B.rect.y,width:B.rect.width,height:B.rect.height,fill:"none",stroke:B.color,"stroke-width":1.5})):E.push(O(F,"circle",{cx:k.x+B.x,cy:k.y+B.y,r:m.theme.point+1.5,fill:B.color,stroke:m.theme.background,"stroke-width":1.5}));m.overlay.replaceChildren(...E);let L=ue(M.color);n.style.setProperty("--pt-c",L.bg),n.style.setProperty("--pt-on-c",L.fg),n.style.font=`${m.fonts.hover}px ${m.theme.font}`,n.replaceChildren(...yr(F,M)),n.style.display="block";let C=(k.x+M.anchor.x)/v,$=x/v,R=e.clientWidth,V=e.clientHeight,Z=C+16+n.offsetWidth>R?C-16-n.offsetWidth:C+16,z=Math.min(Math.max(0,$-18),Math.max(0,V-n.offsetHeight));n.style.left=`${Math.max(0,Z)}px`,n.style.top=`${z}px`}function w(){n.style.display="none",r||t.state.overlay.replaceChildren()}}function yr(t,e){let n=(s,i,l)=>Object.assign(t.createElement(s),{className:i,textContent:l??""}),r=[];e.header&&r.push(n("div","pt-head",e.header));let o=n("div","pt-rows");for(let s of e.rows){let i=n("span","pt-sw");s.swatch&&(i.style.background=s.swatch);let l=[i,n("span","pt-k",s.label),n("span","pt-v",s.value)];s.strong&&l.forEach(a=>a.classList.add("pt-b")),s.total&&l.forEach(a=>a.classList.add("pt-t")),o.append(...l)}return e.note&&o.append(n("span","pt-more",e.note)),r.push(o),r}function jn(t){t.clearHover?.(),t.state.domains=t.state.home,yt(t.state)}function gr(t,e){let n=t.state.legend.items.map(o=>o.value),r=t.state.hidden.size===n.length-1&&!t.state.hidden.has(e);t.state.hidden=r?new Set:new Set(n.filter(o=>o!==e)),yt(t.state)}function br(t,e,{x0:n,x1:r,y0:o,y1:s}){let i=t.state,l=i.layout.panels[e],a=i.panels[e].plot,c=i.domains.map(p=>({...p})),u=(p,h,d)=>{if(i.kind[p]==="category"||d-h<Jt)return;let g=a.scale(p),y=p==="x"?l.x:l.y,w=[g.invert(h-y),g.invert(d-y)].map(Number).sort((b,x)=>b-x);Hn(i,p,e).forEach(b=>c[b][p]=w)};u("x",n,r),u("y",o,s),i.domains=c,yt(i)}function Tn(t,e){t.clearHover?.();let n=t.state;n.domains=n.domains.map(r=>{let o={...r};for(let s of["x","y"]){let i=n.kind[s];if(i==="category")continue;let l=i==="log"?Math.log10:h=>h,a=i==="log"?h=>10**h:h=>h,[c,u]=r[s].map(h=>l(+h)),p=(c+u)/2;o[s]=[a(p-(u-c)/2*e),a(p+(u-c)/2*e)]}return o}),yt(n)}function wr(t,e,n,r){let o=t.state,s=o.layout.panels[e.i],i=o.panels[e.i].plot,l=e.domains.map(a=>({...a}));for(let[a,c,u,p]of[["x",e.x,n,s.x],["y",e.y,r,s.y]]){if(o.kind[a]==="category")continue;let h=i.scale(a),d=o.kind[a]==="log",g=b=>d?Math.log10(b):b,y=g(+h.invert(c-p))-g(+h.invert(u-p)),w=e.domains[e.i][a].map(b=>d?10**(g(b)+y):+b+y);Hn(o,a,e.i).forEach(b=>l[b][a]=w)}o.domains=l,o.frame||(o.frame=requestAnimationFrame(()=>(o.frame=null,yt(o))))}function Hn(t,e,n){let r=t.ns.facet?.free?.[e],o=t.grid.panels[n];return t.grid.panels.flatMap((s,i)=>r?t.grid.kind!=="grid"?i===n?[i]:[]:(e==="x"?s.col===o.col:s.row===o.row)?[i]:[]:[i])}globalThis.plotto={plot:Oe,draw:Nn,toSVG:bn};
|
|
@@ -139,12 +139,15 @@
|
|
|
139
139
|
"reflow": false
|
|
140
140
|
},
|
|
141
141
|
"slide": {
|
|
142
|
-
"width":
|
|
143
|
-
"height":
|
|
144
|
-
"size":
|
|
145
|
-
"shrink": 0.
|
|
146
|
-
"line":
|
|
147
|
-
"point":
|
|
142
|
+
"width": 691,
|
|
143
|
+
"height": 403,
|
|
144
|
+
"size": 13,
|
|
145
|
+
"shrink": 0.8,
|
|
146
|
+
"line": 1.6,
|
|
147
|
+
"point": 2.7,
|
|
148
|
+
"pad": 0.3,
|
|
149
|
+
"flat": 0.55,
|
|
150
|
+
"legend": "bottom",
|
|
148
151
|
"reflow": false
|
|
149
152
|
}
|
|
150
153
|
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
var j={options:{size:"number",alpha:"number",dash:["solid","dashed","dotted","dashdot"],jitter:"number",summary:["mean","median","min","max","sum"],slope:"number",intercept:"number",position:["stack","dodge","overlay"],bins:"number",density:"boolean",method:["lm","loess"],span:"number",band:"boolean"},layers:{line:{channels:["x","y","color","group","tooltip"],options:["size","alpha","dash","summary"],requires:["x","y"]},path:{channels:["x","y","color","group","tooltip"],options:["size","alpha","dash"],requires:["x","y"]},step:{channels:["x","y","color","group","tooltip"],options:["size","alpha","dash"],requires:["x","y"]},point:{channels:["x","y","color","tooltip"],options:["size","alpha","jitter","summary"],requires:["x","y"]},bar:{channels:["x","y","color","tooltip"],options:["alpha","position"],requires:["x","y"]},hist:{channels:["x","color"],options:["alpha","bins","density","position"],requires:["x"]},density:{channels:["x","color"],options:["size","alpha","dash"],requires:["x"]},area:{channels:["x","y","color","group"],options:["alpha","position"],requires:["x","y"]},ribbon:{channels:["x","ymin","ymax","color","group"],options:["alpha"],requires:["x","ymin","ymax"]},smooth:{channels:["x","y","color"],options:["size","alpha","dash","method","span","band"],requires:["x","y"]},hline:{channels:["y","color"],options:["size","alpha","dash"],requires:["y"],inherit:!1},vline:{channels:["x","color"],options:["size","alpha","dash"],requires:["x"],inherit:!1},abline:{channels:["color"],options:["slope","intercept","size","alpha","dash"],requires:[],inherit:!1},segment:{channels:["x","y","xend","yend","color"],options:["size","alpha","dash"],requires:["x","y","xend","yend"]},rect:{channels:["xmin","xmax","ymin","ymax","color","tooltip"],options:["alpha"],requires:["xmin","xmax","ymin","ymax"]},band:{channels:["xmin","xmax","ymin","ymax","color"],options:["alpha"],requires:[],inherit:!1},tile:{channels:["x","y","color","tooltip"],options:["alpha"],requires:["x","y","color"]},text:{channels:["x","y","label","color"],options:["size","alpha"],requires:["x","y","label"]},errorbar:{channels:["x","ymin","ymax","color"],options:["size","alpha"],requires:["x","ymin","ymax"]},box:{channels:["x","y","color"],options:["alpha"],requires:["x","y"]}},scales:{x:["type","limits","format"],y:["type","limits","format"],color:["values","palette","scheme","limits","mid","clamp"]},scaleTypes:["linear","log","time","category"],facet:["free","ncol"],grid:["free"],free:["x","y","both"],labels:["title","subtitle","x","y","color","caption"],theme:["format","width","height","size","legend","aspect"],legend:["right","bottom","none"],info:["position"],infoPosition:["right","bottom"]};var H={styles:{pastel:{font:"Helvetica, Arial, 'Liberation Sans', sans-serif",metrics:"arial",background:"#FFFEFB",ink:"#3A3631",muted:"#7A736A",grid:"#ECE8E1",gridMinor:"#F6F3EE",tick:"#D6D0C6",strip:"#F4F0E9",accent:"#3E8A99",palette:"pastel",scheme:"ai",colors:{blue:"#7AA6DA",orange:"#EF977F",green:"#7DB89A",purple:"#A79BD6",pink:"#E48FAE",yellow:"#DDB459",teal:"#63B7C1",red:"#CF7468",brown:"#BB9C84",gray:"#97A1AD"},weight:1.25},wota:{font:"'M PLUS 1p', sans-serif",metrics:"mplus",ink:"#333333",muted:"#666666",grid:"#D9D9D9",gridMinor:"#EFEFEF",tick:"#BBBBBB",strip:"#EEF1FA",accent:"#5C6BC0",palette:"wota",scheme:"sakura",colors:{pink:"#E4007F",blue:"#5C6BC0",teal:"#00A3A3",orange:"#F5A623",purple:"#8E44AD",gray:"#7F7F7F",green:"#3BA55C",red:"#D7263D",yellow:"#F2C14E",brown:"#8D6E63"},weight:1,background:"#FFFFFF"},paper:{ink:"#000000",muted:"#333333",grid:"#E6E6E6",gridMinor:"#F5F5F5",tick:"#8C8C8C",strip:"#EBEBEB",accent:"#0072B2",palette:["blue","orange","green","pink","yellow","teal","red","brown","purple","gray"],scheme:"viridis",colors:{blue:"#0072B2",orange:"#E69F00",green:"#009E73",pink:"#CC79A7",yellow:"#F0E442",teal:"#56B4E9",red:"#D55E00",brown:"#8C6D31",purple:"#6A3D9A",gray:"#7F7F7F"},weight:1,background:"#FFFFFF"},dark:{background:"#16181D",ink:"#E8EAED",muted:"#A6ABB3",grid:"#2E323A",gridMinor:"#22252B",tick:"#4F5560",strip:"#252933",accent:"#8AB4F8",palette:["blue","orange","green","purple","pink","yellow","teal","red","brown","gray"],scheme:"yuhi",colors:{blue:"#8AB4F8",orange:"#FBA94C",green:"#81C995",purple:"#C58AF9",pink:"#FF8BCB",yellow:"#FDD663",teal:"#78D9D3",red:"#F28B82",brown:"#C8A27A",gray:"#9AA0A6"},weight:1.15}},palettes:{pastel:["#7AA6DA","#EF977F","#7DB89A","#A79BD6","#E48FAE","#DDB459","#63B7C1","#CF7468","#BB9C84","#97A1AD"],wota:["#E4007F","#5C6BC0","#00A3A3","#F5A623","#8E44AD","#7F7F7F","#3BA55C","#D7263D","#F2C14E","#8D6E63"],sakura:["#E16B8C","#5DAC81","#8B81C3","#FFB11B","#7DB9DE","#F596AA","#B9887D","#91AD70"],aizome:["#0F2540","#51A8DD","#66BAB7","#656765","#0D5661","#A5DEE4","#7B90D2"],momiji:["#CB4042","#FFB11B","#6C6A2D","#6D2E5B","#ED784A","#734338","#C99833"],tableau:["#4E79A7","#F28E2B","#E15759","#76B7B2","#59A14F","#EDC948","#B07AA1","#FF9DA7","#9C755F","#BAB0AC"]},schemes:{ai:["#F4F8F8","#A5DEE4","#33A6B8","#0D5661","#0F2540"],sakura:["#FEF4F4","#FEDFE1","#F596AA","#D05A6E","#8E354A","#4A1D30"],matcha:["#F8F6E3","#D7E3B5","#91AD70","#5DAC81","#1B813E","#0B3B2A"],yuhi:["#FFF3D6","#FFB11B","#ED784A","#CB4042","#6D2E5B","#26113A"],sumi:["#FCFAF2","#BDC0BA","#828282","#434343","#1C1C1C"],aiaka:["#0F2540","#33A6B8","#A5DEE4","#F7F6F0","#F4A7A0","#CB4042","#5C1A1B"]},formats:{screen:{width:900,height:500,size:12,line:1.5,point:2.5,reflow:!0},report:{width:640,height:400,size:10,line:1.2,point:2,reflow:!1},slide:{width:960,height:600,size:22,shrink:.7,line:2.5,point:4,reflow:!1}}};var Pe=j.layers,De=[...new Set(Object.values(Pe).flatMap(t=>t.channels))];function $e(t,e={}){let n=[Be(t,"plot()")];for(let[r,o]of Object.entries(e))De.includes(r)||nt("plot()","channel",r,De),ie(n[0],o,"plot()");return new se({data:n,mapping:e,layers:[],facet:null,scales:{},labels:{},info:null,theme:{style:"pastel"}})}var se=class t{#e;constructor(e){this.#e=e}#n(e){return new t({...this.#e,...e})}#t(e,n={}){let r=Pe[e],o=`${e}()`,{data:s,...i}=n,l=this.#e.data,a=0;s!==void 0&&(l=[...l,Be(s,o)],a=l.length-1);let c=l[a].columns,u={type:e,mapping:{},set:{}};a&&(u.data=a);for(let[p,f]of Object.entries(i))r.channels.includes(p)&&typeof f=="string"&&f in c?u.mapping[p]=f:r.channels.includes(p)||r.options.includes(p)?u.set[p]=Vn(p,f,o,c):nt(o,"option",p,["data",...r.channels,...r.options]);return this.#n({data:l,layers:[...this.#e.layers,u]})}line(e){return this.#t("line",e)}step(e){return this.#t("step",e)}bar(e){return this.#t("bar",e)}hist(e){return this.#t("hist",e)}density(e){return this.#t("density",e)}area(e){return this.#t("area",e)}ribbon(e){return this.#t("ribbon",e)}smooth(e){return this.#t("smooth",e)}path(e){return this.#t("path",e)}point(e){return this.#t("point",e)}hline(e){return this.#t("hline",e)}vline(e){return this.#t("vline",e)}abline(e){return this.#t("abline",e)}segment(e){return this.#t("segment",e)}rect(e){return this.#t("rect",e)}band(e){return this.#t("band",e)}tile(e){return this.#t("tile",e)}text(e){return this.#t("text",e)}errorbar(e){return this.#t("errorbar",e)}box(e){return this.#t("box",e)}facet(e,n={}){return ie(this.#e.data[0],e,"facet()"),St(n,j.facet,"facet()"),ze(n.free,"facet()"),this.#n({facet:{wrap:e,free:n.free??null,ncol:n.ncol??null}})}grid({rows:e=null,cols:n=null,...r}={}){if(e===null&&n===null)throw new Error("grid(): set rows, cols or both");for(let o of[e,n])o!==null&&ie(this.#e.data[0],o,"grid()");return St(r,j.grid,"grid()"),ze(r.free,"grid()"),this.#n({facet:{rows:e,cols:n,free:r.free??null}})}x(e){return this.#o("x",e)}y(e){return this.#o("y",e)}color(e){return this.#o("color",e)}#o(e,n={}){let r=`${e}()`;if(St(n,j.scales[e],r),n.type!==void 0&&!j.scaleTypes.includes(n.type)&&nt(r,"type",n.type,j.scaleTypes),n.palette!==void 0&&!Array.isArray(n.palette)&&!(n.palette in H.palettes)&&nt(r,"palette",n.palette,Object.keys(H.palettes)),n.mid!==void 0&&typeof n.mid!="number")throw new Error(`${r}: mid must be a number`);let o={...n};if(o.limits){if(!Array.isArray(o.limits))throw new Error(`${r}: limits must be a list, for example [0, 10] or [0, null]`);o.limits=o.limits.map(s=>s==null?null:Xt(s))}return this.#n({scales:{...this.#e.scales,[e]:o}})}labels(e={}){return St(e,j.labels,"labels()"),this.#n({labels:{...this.#e.labels,...e}})}info(e,n={}){St(n,j.info,"info()");let{position:r}=n;if(r!==void 0&&!j.infoPosition.includes(r)&&nt("info()","position",r,j.infoPosition),e==null)return this.#n({info:null});let o=Array.isArray(e)?e:typeof e=="object"?Object.entries(e):null;if(!o)throw new Error("info(): entries must be an object or a list of [key, value] pairs");return this.#n({info:{entries:o.map(s=>Un(s)),...r?{position:r}:{}}})}theme(e="pastel",n={}){if(St(n,j.theme,"theme()"),e in H.styles||nt("theme()","style",e,Object.keys(H.styles)),n.format!==void 0&&!(n.format in H.formats)&&nt("theme()","format",n.format,Object.keys(H.formats)),n.legend!==void 0&&!j.legend.includes(n.legend)&&nt("theme()","legend",n.legend,j.legend),n.aspect!=null&&!(typeof n.aspect=="number"&&n.aspect>0))throw new Error("theme(): aspect must be a positive number (panel height / width), for example 1 for square panels");return this.#n({theme:{style:e,...n}})}spec(){let e=this.#e,n=e.data.map(()=>new Set);for(let o of Object.values(e.mapping))n.forEach((s,i)=>o in e.data[i].columns&&s.add(o));for(let o of e.layers)for(let s of Object.values(o.mapping))n[o.data??0].add(s);for(let o of[e.facet?.wrap,e.facet?.rows,e.facet?.cols])o&&n.forEach((s,i)=>o in e.data[i].columns&&s.add(o));return{version:1,data:e.data.map((o,s)=>({columns:Object.fromEntries([...n[s]].map(i=>[i,o.columns[i]]))})),mapping:e.mapping,layers:e.layers,facet:e.facet,scales:e.scales,labels:e.labels,...e.info?{info:e.info}:{},theme:e.theme}}};function Be(t,e){if(!Array.isArray(t))throw new Error(`${e}: data must be an array of row objects`);let n=[...new Set(t.flatMap(Object.keys))],r={};for(let o of n){let s=t.map(c=>c[o]??null),i=s.find(c=>c!==null&&!Number.isNaN(c)),l=i instanceof Date?"time":typeof i=="number"?"number":"string",a=s.map(c=>c===null||Number.isNaN(c)?null:l==="string"?String(c):Xt(c));r[o]={type:l,values:a}}return{columns:r}}function Xt(t){return t instanceof Date?t.getTime()-t.getTimezoneOffset()*6e4:typeof t=="number"&&!Number.isInteger(t)?Number(t.toPrecision(6)):t}function Vn(t,e,n,r){let o=j.options[t];if(t==="tooltip"||t==="group")throw new Error(`${n}: ${t} must be a column. Columns: ${Object.keys(r).join(", ")}`);if(Array.isArray(o)&&!o.includes(e)&&nt(n,t,e,o),o==="number"&&typeof e!="number")throw new Error(`${n}: ${t} must be a number`);if(o==="boolean"&&typeof e!="boolean")throw new Error(`${n}: ${t} must be true or false`);if(t==="color"||t==="label")return e;if(typeof e=="string"&&!o)throw new Error(`${n}: "${e}" is not a column. Columns: ${Object.keys(r).join(", ")}`);return Xt(e)}function Un(t){if(!Array.isArray(t)||t.length!==2||typeof t[0]!="string")throw new Error("info(): each entry must be a [key, value] pair with a string key");let[e,n]=t;if(n==null||typeof n=="number"&&Number.isNaN(n))return[e,null];if(!["string","number","boolean"].includes(typeof n))throw new Error(`info(): the value of "${e}" must be a string, a number, a boolean or null. Format other values as a string`);return[e,Xt(n)]}function ie(t,e,n){if(!(e in t.columns))throw new Error(`${n}: "${e}" is not a column. Columns: ${Object.keys(t.columns).join(", ")}`)}function St(t,e,n){for(let r of Object.keys(t))e.includes(r)||nt(n,"option",r,e)}function ze(t,e){t!=null&&!j.free.includes(t)&&nt(e,"free",t,j.free)}function nt(t,e,n,r){throw new Error(`${t}: unknown ${e} "${n}". Valid: ${r.join(", ")}`)}import*as et from"https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6.17/+esm";import*as bt from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";import*as T from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";import*as K from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var Kn=Object.keys(H.styles),Zn=Object.keys(H.formats),Jn=Object.keys(H.palettes),Qn=Object.keys(H.schemes),Oe=["ink","muted","grid","tick","strip","accent","background"];function Te({style:t="pastel",format:e="screen",legend:n="right",...r}={}){if(!H.styles[t])throw new Error(`theme(): unknown style "${t}". Valid: ${Kn.join(", ")}`);if(!H.formats[e])throw new Error(`theme(): unknown format "${e}". Valid: ${Zn.join(", ")}`);let o=H.styles.pastel,s=H.styles[t],i=H.formats[e],l=r.width!=null;for(let c of Object.keys(r))r[c]==null&&delete r[c];let a={...o,...s,colors:{...o.colors,...s.colors},...i,legend:n,...r,style:t,format:e};return a.reflow=i.reflow&&!l,a.line=i.line*(s.weight??o.weight??1),a.point=i.point*Math.sqrt(s.weight??o.weight??1),r.width!=null&&r.height==null&&(a.height=Math.round(r.width*i.height/i.width)),a.fixedHeight=r.height!=null,a.fitHeight=i.reflow&&!a.fixedHeight,a.fixedFormat=!i.reflow,a.palette=le(a,a.palette),a}function le(t,e){let n=Array.isArray(e)?e:H.palettes[e];if(!n)throw new Error(`color(): unknown palette "${e}". Valid: ${Jn.join(", ")}`);return n.map(r=>Ct(t,r)??r)}function Ne(t,e){let n=o=>K.piecewise(K.interpolateLab,o.map(s=>Ct(t,s)??s));if(Array.isArray(e))return n(e);if(H.schemes[e])return n(H.schemes[e]);let r=typeof e=="string"&&K[`interpolate${e[0].toUpperCase()}${e.slice(1)}`];if(!r)throw new Error(`color(): unknown scheme "${e}". plotto schemes: ${Qn.join(", ")}; or a d3 scheme such as viridis, magma, blues`);return r}function Ct(t,e){if(typeof e=="string")return t.colors[e]?t.colors[e]:Oe.includes(e)?t[e]:K.color(e)?e:void 0}function je(t){return[...Object.keys(t.colors),...Oe]}function ae(t){let e=o=>{let s=[o.r,o.g,o.b].map(i=>(i/=255,i<=.03928?i/12.92:((i+.055)/1.055)**2.4));return .2126*s[0]+.7152*s[1]+.0722*s[2]},n=K.rgb(t);if(e(n)>.42)return{bg:n.formatHex(),fg:"#1F2328"};let r=K.hcl(n);for(let o=0;o<20&&1.05/(e(K.rgb(r))+.05)<4;o++)r=K.hcl(r.h,r.c,r.l-4);return{bg:K.rgb(r).formatHex(),fg:"#FFFFFF"}}function He(t){return ae(t).fg}function Ie(t){let e=t.size;return{base:e,tick:e-1,title:Math.round(e*1.35),subtitle:e,strip:e-1,legend:e-1,axisTitle:e,hover:Math.max(11,e-1)}}var It={x:["x","xmin","xmax","xend"],y:["y","ymin","ymax","yend"]},Re=.05,ce=864e5;function ue(t,e){let n=t.scales[e]?.type;if(n)return n;for(let r of t.layers)for(let o of It[e]){let s=r.channels[o]?.column;if(!s)continue;let i=t.tables[r.table].columns[s].type;return i==="time"?"time":i==="string"?"category":"linear"}return"linear"}function We(t,e,n,r){let o=e.channels[n];if(!o)return;if("value"in o)return r.map(()=>o.value);let s=t.tables[e.table].columns[o.column].values;return r.map(i=>s[i])}function Ye(t,e,n,r){let o=[];for(let i of r)for(let l of i.views)for(let a of It[e]){let c=l.cols[a];if(c)for(let u of c)u!=null&&(n==="category"||Number.isFinite(u))&&o.push(u)}if(n==="category")return to(t,e,o);let s=T.extent(o.filter(i=>n!=="log"||i>0));return s[0]===void 0?n==="log"?[1,10]:[0,1]:Xe(s,n)}function to(t,e,n){let r=t.layers.map(s=>s.channels[e]?.column&&t.tables[s.table].columns[s.channels[e].column].levels).find(Boolean),o=new Set(n.map(String));return r?r.filter(s=>o.has(s)):[...o].sort(_t)}function _t(t,e){return String(t).localeCompare(String(e),void 0,{numeric:!0})}function Xe([t,e],n){if(n==="log"){let[o,s]=Xe([Math.log10(t),Math.log10(e)],"linear");return[10**o,10**s]}let r=e>t?(e-t)*Re:n==="time"?36e5:Math.abs(t)*Re||1;return[t-r,e+r]}function wt(t,e,n,r){if(t==="category")return{major:e,minor:[],format:String};let[o,s]=e;if(t==="time"){let l=T.scaleUtc().domain([new Date(o),new Date(s)]).ticks(n),a=r??eo(l,s-o);return{major:l,minor:qe(l,e,c=>+c).map(c=>new Date(c)),format:T.utcFormat(a)}}if(t==="log"){let l=T.range(Math.ceil(Math.log10(o)),Math.floor(Math.log10(s))+1).map(u=>10**u),a=l.length>=2?l:T.scaleLog().domain(e).ticks(n).filter(u=>[1,2,5].includes(Math.round(u/10**Math.floor(Math.log10(u)+1e-9)))),c=l.flatMap(u=>T.range(2,10).map(p=>u/10*p)).filter(u=>u>o&&u<s);return{major:a,minor:c,format:T.format(r??"~g")}}let i=T.ticks(o,s,n);return{major:i,minor:qe(i,e,Number),format:r?T.format(r):T.tickFormat(o,s,n)}}function qe(t,[e,n],r){if(t.length<2)return[];let o=r(t[1])-r(t[0]);return[r(t[0])-o/2,...t.map(i=>r(i)+o/2)].filter(i=>i>e&&i<n)}function eo(t,e){let n=t.length>=2?t[1]-t[0]:e;return n>=28*ce?"%Y-%m":n>=ce?"%m-%d":n>=6e4?e>ce?"%m-%d %H:%M":"%H:%M":"%H:%M:%S"}var no=T.format(",.4~r"),_e={number:t=>t==null?"\u2013":Math.abs(t)>=1e15||t!==0&&Math.abs(t)<1e-4?T.format(".3~e")(t):no(t),time:T.utcFormat("%m-%d %H:%M"),string:t=>t==null?"\u2013":String(t)};function Ge(t){let e=t.theme,n=t.scales.color??{},r=t.layers.filter(x=>x.channels.color?.column);if(!r.length)return{kind:"none"};let o=r[0].channels.color.column,s=r.find(x=>x.channels.color.column!==o);if(s)throw new Error(`plotto: color maps "${o}" and "${s.channels.color.column}". Map color to one column only`);let i=r.map(x=>t.tables[x.table].columns[o]),l=i[0].type,a=i.flatMap(x=>x.values).filter(x=>x!==null),c=x=>Ct(e,x)??x;if(l==="string"){let x=i.find(A=>A.levels)?.levels,k=new Set(a),h=n.limits??(x?x.filter(A=>k.has(A)):[...k].sort(_t)),m=n.palette?le(e,n.palette):e.palette,v=n.values,M=Array.isArray(v)?(A,D)=>c(v[D%v.length]):v?(A,D)=>c(v[A]??m[D%m.length]):(A,D)=>m[D%m.length],E=new Map(h.map((A,D)=>[A,M(A,D)]));return{kind:"ordinal",column:o,domain:h,apply:A=>E.get(A)??e.muted}}let[u,p]=oo(n.limits,T.extent(a)),f=Ne(e,n.values??n.scheme??e.scheme),d=n.mid,g=x=>d===void 0?(x-u)/(p-u||1):x<d?.5*((x-u)/(d-u||1)):.5+.5*((x-d)/(p-d||1)),y=x=>x>=u&&x<=p,w=x=>x===null?e.muted:n.clamp||y(x)?f(Math.max(0,Math.min(1,g(x)))):e.muted;return{kind:"continuous",column:o,domain:[u,p],type:l,interpolate:f,apply:w,ramp:x=>w(u+x*(p-u))}}function oo(t,e){return t?[t[0]??e[0],t[1]??e[1]]:e}function Ve(t){let e=t.facet;if(!e)return{kind:"none",nrow:1,ncol:1,panels:[de(t,0,0,{},{})]};if(e.kind==="wrap"){let s=pe(t,e.by),i=e.ncol??ro(s.length),l=s.map((a,c)=>de(t,Math.floor(c/i),c%i,{[e.by]:a},{top:a}));return{kind:"wrap",nrow:Math.ceil(s.length/i),ncol:i,panels:l}}let n=e.rows?pe(t,e.rows):[null],r=e.cols?pe(t,e.cols):[null],o=[];return n.forEach((s,i)=>r.forEach((l,a)=>{let c={};e.rows&&(c[e.rows]=s),e.cols&&(c[e.cols]=l),o.push(de(t,i,a,c,{top:i===0?l:null,right:a===r.length-1?s:null}))})),{kind:"grid",nrow:n.length,ncol:r.length,panels:o}}function ro(t){return t<=3?t:t<=6?Math.ceil(t/2):t<=12?Math.ceil(t/3):Math.ceil(Math.sqrt(t))}function pe(t,e){let n=t.tables[0].columns[e];return n.levels?n.levels.filter(r=>n.values.includes(r)):[...new Set(n.values.filter(r=>r!==null).map(String))].sort(_t)}function de(t,e,n,r,o){let s=t.layers.map(i=>{let l=t.tables[i.table];if(!Object.values(i.channels).some(u=>u.column))return[0];let a=Object.entries(r).filter(([u])=>u in l.columns),c=Array.from({length:l.n},(u,p)=>p);return a.length?c.filter(u=>a.every(([p,f])=>String(l.columns[p].values[u])===f)):c});return{row:e,col:n,strips:o,rows:s}}import*as it from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var so="http://www.w3.org/2000/svg";function B(t,e,n={}){let r=t.createElementNS(so,e);for(let[o,s]of Object.entries(n))s!=null&&r.setAttribute(o,String(s));return r}function J(t,e,n,r="text"){let o=B(t,r,n);return o.textContent=e,o}var Ue={arial:{regular:[.278,.278,.355,.556,.556,.889,.667,.191,.333,.333,.389,.584,.278,.333,.278,.278,.556,.556,.556,.556,.556,.556,.556,.556,.556,.556,.278,.278,.584,.584,.584,.556,1.015,.667,.667,.722,.722,.667,.611,.778,.722,.278,.5,.667,.556,.833,.722,.778,.667,.778,.722,.667,.611,.722,.667,.944,.667,.667,.611,.278,.278,.278,.469,.556,.333,.556,.556,.5,.556,.556,.278,.556,.556,.222,.222,.5,.222,.833,.556,.556,.556,.556,.333,.5,.278,.556,.5,.722,.5,.5,.5,.334,.26,.334,.584],bold:[.278,.333,.474,.556,.556,.889,.722,.238,.333,.333,.389,.584,.278,.333,.278,.278,.556,.556,.556,.556,.556,.556,.556,.556,.556,.556,.333,.333,.584,.584,.584,.611,.975,.722,.722,.722,.722,.667,.611,.778,.722,.278,.556,.722,.611,.833,.722,.778,.667,.778,.722,.667,.611,.722,.667,.944,.667,.667,.611,.333,.278,.333,.584,.556,.333,.556,.611,.556,.611,.556,.333,.611,.611,.278,.278,.556,.278,.889,.611,.611,.611,.611,.389,.556,.333,.611,.556,.778,.556,.556,.5,.389,.28,.389,.584]},mplus:{regular:[.29,.363,.4,.678,.605,.847,.712,.237,.385,.385,.527,.733,.304,.457,.283,.507,.62,.62,.62,.62,.62,.62,.62,.62,.62,.62,.363,.384,.667,.753,.667,.611,.823,.693,.598,.695,.682,.587,.572,.745,.71,.317,.527,.633,.585,.857,.713,.793,.6,.785,.62,.573,.653,.683,.693,.953,.65,.67,.637,.47,.507,.47,.653,.583,.278,.548,.578,.522,.578,.552,.522,.573,.573,.307,.347,.562,.307,.805,.568,.57,.573,.573,.453,.497,.512,.558,.557,.81,.553,.557,.547,.513,.343,.513,.69],bold:[.304,.425,.478,.692,.625,.901,.753,.291,.426,.426,.536,.735,.351,.471,.338,.546,.64,.64,.64,.64,.64,.64,.64,.64,.64,.64,.418,.431,.681,.755,.681,.628,.818,.715,.62,.703,.696,.601,.586,.756,.735,.351,.558,.678,.6,.878,.735,.798,.628,.798,.651,.608,.668,.705,.715,.971,.678,.698,.651,.501,.546,.501,.695,.609,.336,.576,.606,.54,.606,.57,.543,.601,.605,.335,.378,.603,.335,.843,.6,.585,.601,.601,.485,.525,.533,.59,.581,.831,.585,.585,.568,.535,.381,.535,.705]}};var io=11904;function dt(t,e,n=!1,r="arial"){let o=Ue[r][n?"bold":"regular"],s=0;for(let i of String(t)){let l=i.codePointAt(0);l>=32&&l<127?s+=o[l-32]:s+=l>=io?1:.6}return s*e}function ht(t,e,n,r,o){if(t=String(t),dt(t,e,r,o)<=n)return t;let s=[...t];for(;s.length>1&&dt(s.join("")+"\u2026",e,r,o)>n;)s.pop();return s.join("")+"\u2026"}function gt(t,e,n,r,o,s=2){let i=String(t).split(/\s+/),l=[],a="";for(let u of i){let p=a?`${a} ${u}`:u;a&&dt(p,e,r,o)>n?(l.push(a),a=u):a=p}if(l.push(a),l.length<=s)return l;let c=l.slice(0,s);return c[s-1]=ht(l.slice(s-1).join(" "),e,n,r,o),c}var lo=3,ao=.45,co={right:.3,bottom:.9},uo={right:.6,bottom:.3},po=3;function Ke(t,e,{W:n,H:r,narrow:o,place:s=t.info?.position}){if(!t.info)return null;let i=o?"bottom":s;return ho(t,e,t.info.entries,i,n,r*uo[i])}function ho(t,e,n,r,o,s){let i=t.theme.metrics,l=e.legend,a=Math.round(l*.8),c=l*1.35,u=l,p=l*2,f=n.map(([h,m])=>({key:String(h),value:m===null?"\u2013":String(m)})),d=h=>dt(h,l,!1,i),g=(h,m)=>{let v=Math.min(it.max(h,L=>d(L.key))??0,m*ao),M=Math.max(l*3,m-v-u),E=0,A=h.map(L=>{let O=gt(L.value,l,M,!1,i,lo),I={key:ht(L.key,l,v,!1,i),full:L.key,lines:O,y:E};return E+=O.length*c,I}),D=it.max(A,L=>it.max(L.lines,d))??0;return{rows:A,keyW:v,width:v+u+D,height:E}},y=o*co[r]-2*a,w=h=>{let m;if(r==="bottom"){let M=A=>{let D=Math.ceil(h.length/A);return it.range(A).map(L=>g(h.slice(L*D,(L+1)*D),1/0))};m=it.range(Math.min(po,h.length),1,-1).map(M).find(A=>it.sum(A,D=>D.width)+p*(A.length-1)<=y)??[g(h,y)]}else m=[g(h,y)];let v=a;for(let M of m)M.x=v,v+=M.width+p;return{columns:m,width:v-p+a,height:(it.max(m,M=>M.height)??0)+2*a}},b=f.length,x=w(f);for(;x.height>s&&b>1;)b--,x=w([...f.slice(0,b),{key:`+${f.length-b} more`,value:""}]);let k=x.columns.flatMap(h=>h.rows).filter(h=>h.key!==h.full).length;return{position:r,size:l,pad:a,lineH:c,keyGap:u,cut:f.length-b+k,...x}}function Ze(t,e,n,{x:r,y:o}){let s=B(t,"g",{class:"pt-info",transform:`translate(${r},${o})`,"font-size":e.size});s.append(B(t,"rect",{width:e.width,height:e.height,fill:n.strip}));let i=e.lineH*.75;for(let l of e.columns)for(let a of l.rows){let c=e.pad+a.y+i,u=J(t,a.key,{x:l.x,y:c,fill:n.muted,"text-anchor":"start"});a.key!==a.full&&u.append(J(t,a.full,{},"title")),s.append(u),a.lines.forEach((p,f)=>s.append(J(t,p,{x:l.x+l.keyW+e.keyGap,y:c+f*e.lineH,fill:n.ink,"text-anchor":"start"})))}return s}import*as S from"https://cdn.jsdelivr.net/npm/@observablehq/plot@0.6.17/+esm";import*as _ from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";import*as C from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var Gt=80;function Rt(t,e,n){let r=new Map;for(let o=0;o<n;o++){let s=e.map(l=>t[l]?.[o]??null),i=JSON.stringify(s);r.has(i)||r.set(i,{key:s,idx:[]}),r.get(i).idx.push(o)}return[...r.values()]}function Je(t,e,n){let r={mean:C.mean,median:C.median,min:C.min,max:C.max,sum:C.sum}[n],o={x:[],y:[],color:[],group:[]};for(let{key:s,idx:i}of Rt(t,["x","color","group"],e))s[0]!==null&&(o.x.push(s[0]),o.y.push(r(i,l=>t.y[l])),o.color.push(s[1]),o.group.push(s[2]));return o}function Qe(t,e,n,r){let o=l=>t.color?r.indexOf(t.color[l]):0,s=t.color?r.filter(l=>t.color.includes(l)):[null],i={...t,ymin:new Array(e),ymax:new Array(e),value:t.y.slice(),slot:new Array(e),slots:new Array(e)};for(let{idx:l}of Rt(t,n==="dodge"?["x","color"]:["x"],e)){l.sort((u,p)=>o(u)-o(p));let a=0,c=0;l.forEach((u,p)=>{let f=t.y[u]??0;if(n!=="overlay"){let d=f>=0?a:c;[i.ymin[u],i.ymax[u]]=[d,d+f],f>=0?a+=f:c+=f}else[i.ymin[u],i.ymax[u]]=[0,f];i.slot[u]=n==="dodge"&&t.color?s.indexOf(t.color[u]):0,i.slots[u]=n==="dodge"?s.length:1})}return i.y=i.ymax,i}function tn(t,e){let n=[...new Set(t.x.filter(l=>l!==null))].sort((l,a)=>l-a),o=(C.min(C.pairs(n),([l,a])=>a-l)??1)*.9,s=[],i=[];for(let l=0;l<e;l++){let a=o/t.slots[l];s.push(t.x[l]-o/2+t.slot[l]*a),i.push(t.x[l]-o/2+(t.slot[l]+1)*a)}return{...t,xmin:s,xmax:i}}function en(t,e){let n=t.filter(i=>i!==null&&Number.isFinite(i)),[r,o]=C.extent(n);if(r===void 0)return[0,1];if(r===o)return[r-.5,o+.5];let s=C.ticks(...C.nice(r,o,e),e);return s[0]>r&&s.unshift(s[0]-(s[1]-s[0])),s.at(-1)<o&&s.push(s.at(-1)+(s[1]-s[0])),s}function nn(t,e,n,r){let o={x:[],xmin:[],xmax:[],y:[],color:[]},s=C.bin().domain([n[0],n.at(-1)]).thresholds(n.slice(1,-1));for(let{key:i,idx:l}of Rt(t,["color"],e)){let a=l.map(c=>t.x[c]).filter(c=>c!==null&&Number.isFinite(c));for(let c of s(a)){let u=c.length;o.x.push((c.x0+c.x1)/2),o.xmin.push(c.x0),o.xmax.push(c.x1),o.y.push(r?u/(a.length*(c.x1-c.x0)||1):u),o.color.push(i[0])}}return o}function Vt(t){let e=t.filter(a=>a!==null&&Number.isFinite(a)).sort(C.ascending),[n,r,o]=[.25,.5,.75].map(a=>C.quantile(e,a)),s=o-n,i=C.min(e.filter(a=>a>=n-1.5*s)),l=C.max(e.filter(a=>a<=o+1.5*s));return{n:e.length,q1:n,median:r,q3:o,low:i,high:l,outliers:e.filter(a=>a<i||a>l)}}function on(t,e){let n={x:[],y:[],color:[],group:[]};for(let{key:r,idx:o}of Rt(t,["color"],e)){let s=o.map(p=>t.x[p]).filter(p=>p!==null&&Number.isFinite(p));if(s.length<2)continue;let i=C.deviation(s),l=C.quantile(s,.75)-C.quantile(s,.25),a=.9*Math.min(i,l/1.34||i)*s.length**-.2||1,[c,u]=C.extent(s);for(let p of C.range(Gt).map(f=>c-3*a+(u-c+6*a)*f/(Gt-1))){let f=C.sum(s,d=>Math.exp(-.5*((p-d)/a)**2))/(s.length*a*Math.sqrt(2*Math.PI));n.x.push(p),n.y.push(f),n.color.push(r[0]),n.group.push(r[0])}}return n}function rn(t,e,{method:n="lm",span:r=.75,band:o=!0}){let s={x:[],y:[],ymin:[],ymax:[],color:[],group:[]};for(let{key:i,idx:l}of Rt(t,["color"],e)){let a=l.map(d=>[t.x[d],t.y[d]]).filter(([d,g])=>d!==null&&g!==null&&Number.isFinite(d)&&Number.isFinite(g));if(a.length<3)continue;a.sort((d,g)=>d[0]-g[0]);let[c,u]=[a[0][0],a.at(-1)[0]],p=C.range(Gt).map(d=>c+(u-c)*d/(Gt-1));(n==="loess"?mo(a,p,r):fo(a,p)).forEach(({x:d,y:g,se:y})=>{let w=xo(a.length-2);s.x.push(d),s.y.push(g),s.ymin.push(o&&y!==void 0?g-w*y:null),s.ymax.push(o&&y!==void 0?g+w*y:null),s.color.push(i[0]),s.group.push(i[0])})}return s}function fo(t,e){let n=t.length,r=C.mean(t,c=>c[0]),o=C.mean(t,c=>c[1]),s=C.sum(t,c=>(c[0]-r)**2)||1,i=C.sum(t,c=>(c[0]-r)*(c[1]-o))/s,l=o-i*r,a=Math.sqrt(C.sum(t,c=>(c[1]-l-i*c[0])**2)/Math.max(1,n-2));return e.map(c=>({x:c,y:l+i*c,se:a*Math.sqrt(1/n+(c-r)**2/s)}))}function mo(t,e,n){let r=Math.max(3,Math.ceil(n*t.length));return e.map(o=>{let s=t.map(([y,w])=>[Math.abs(y-o),y,w]).sort((y,w)=>y[0]-w[0]).slice(0,r),i=s.at(-1)[0]||1,[l,a,c,u,p]=[0,0,0,0,0];for(let[y,w,b]of s){let x=(1-(y/i)**3)**3;l+=x,a+=x*w,c+=x*b,u+=x*w*w,p+=x*w*b}let f=l*u-a*a,d=Math.abs(f)<1e-12?0:(l*p-a*c)/f,g=(c-d*a)/l;return{x:o,y:g+d*o}})}function xo(t){let e=[12.71,4.3,3.18,2.78,2.57,2.45,2.36,2.31,2.26,2.23,2.2,2.18,2.16,2.14,2.13,2.12,2.11,2.1,2.09,2.09];return t<1?NaN:t<=e.length?e[t-1]:t<=30?2.05:t<=60?2:1.96}var yo={solid:void 0,dashed:"6,4",dotted:"1.5,3",dashdot:"6,3,1.5,3"},P="frame",lt=(t,e)=>({stroke:t.colors(e),strokeWidth:t.options.size??t.theme.line,strokeOpacity:t.options.alpha??1,strokeDasharray:yo[t.options.dash],strokeLinejoin:"round",strokeLinecap:"round"}),ft=(t,e,n=1)=>({fill:t.colors(e),fillOpacity:t.options.alpha??n}),tt=t=>t.theme.palette[0],go=t=>e=>[S.line(e.index,{x:e.v("x"),y:e.v("y"),z:e.groups(),curve:t,...lt(e,tt(e)),clip:P})],sn={line:t=>[S.line(t.index,{x:t.v("x"),y:t.v("y"),z:t.groups(),sort:{channel:"x"},...lt(t,tt(t)),clip:P})],path:go("linear"),step:t=>[S.line(t.index,{x:t.v("x"),y:t.v("y"),z:t.groups(),sort:{channel:"x"},curve:"step-after",...lt(t,tt(t)),clip:P})],point:t=>{let e={x:bo(t),y:t.v("y"),r:t.options.size??t.theme.point,...ft(t,tt(t)),clip:P};return t.options.jitter&&t.kind.x==="category"&&(e.render=wo(t.options.jitter)),[S.dot(t.index,e)]},bar:t=>{let e={...ft(t,tt(t),he(t,1)),clip:P};if(t.kind.x!=="category")return[S.rect(t.index,{x1:t.v("xmin"),x2:t.v("xmax"),y1:t.v("ymin"),y2:t.v("ymax"),...e})];let n=t.v("slots")[0]??1;if(n===1)return[S.barY(t.index,{x:t.v("x"),y1:t.v("ymin"),y2:t.v("ymax"),...e})];let r=t.bandwidth.x/n,o=(s,i)=>Array.isArray(s)?i.map(l=>s[l]):s;return _.range(n).map(s=>{let i=t.index.filter(a=>t.v("slot")[a]===s),l={x:o(t.v("x"),i),y1:o(t.v("ymin"),i),y2:o(t.v("ymax"),i),fill:o(e.fill,i)};return S.barY(_.range(i.length),{...e,...l,insetLeft:s*r+.5,insetRight:(n-1-s)*r+.5})})},hist:t=>[S.rect(t.index,{x1:t.v("xmin"),x2:t.v("xmax"),y1:t.v("ymin"),y2:t.v("ymax"),insetLeft:.5,insetRight:.5,...ft(t,tt(t),he(t)),clip:P})],density:t=>[S.areaY(t.index,{x:t.v("x"),y:t.v("y"),z:t.groups(),fill:t.colors(tt(t)),fillOpacity:.15,clip:P}),S.line(t.index,{x:t.v("x"),y:t.v("y"),z:t.groups(),...lt(t,tt(t)),clip:P})],area:t=>[S.areaY(t.index,{x:t.v("x"),y1:t.v("ymin"),y2:t.v("ymax"),z:t.groups(),...ft(t,tt(t),he(t,.8)),clip:P})],ribbon:t=>[S.areaY(t.index,{x:t.v("x"),y1:t.v("ymin"),y2:t.v("ymax"),z:t.groups(),...ft(t,tt(t),.2),clip:P})],smooth:t=>{let e=[];return t.v("ymin").some(n=>n!==null)&&e.push(S.areaY(t.index,{x:t.v("x"),y1:t.v("ymin"),y2:t.v("ymax"),z:t.groups(),fill:t.colors(t.theme.muted),fillOpacity:.15,clip:P})),e.push(S.line(t.index,{x:t.v("x"),y:t.v("y"),z:t.groups(),...lt(t,t.theme.accent),clip:P})),e},hline:t=>[S.ruleY(t.index,{y:t.v("y"),...lt(t,t.theme.muted),strokeWidth:t.options.size??1,clip:P})],vline:t=>[S.ruleX(t.index,{x:t.v("x"),...lt(t,t.theme.muted),strokeWidth:t.options.size??1,clip:P})],abline:t=>{let[e,n]=t.domain.x.map(Number),{slope:r=1,intercept:o=0}=t.options;return[S.line([0,1],{x:[e,n],y:[o+r*e,o+r*n],...lt(t,t.theme.muted),strokeWidth:t.options.size??1,clip:P})]},segment:t=>[S.link(t.index,{x1:t.v("x"),y1:t.v("y"),x2:t.v("xend"),y2:t.v("yend"),...lt(t,t.theme.ink),clip:P})],rect:t=>[S.rect(t.index,{x1:t.v("xmin"),x2:t.v("xmax"),y1:t.v("ymin"),y2:t.v("ymax"),...ft(t,tt(t)),clip:P})],band:t=>{let e=(r,o,s)=>t.v(r)??t.index.map(()=>t.domain[o][s]),n={x1:e("xmin","x",0),x2:e("xmax","x",1),y1:e("ymin","y",0),y2:e("ymax","y",1)};return[S.rect(t.index,{...n,...ft(t,t.theme.muted,.12),clip:P})]},tile:t=>{let e=ft(t,tt(t)),[n,r]=[t.kind.x==="category",t.kind.y==="category"];if(n&&r)return[S.cell(t.index,{x:t.v("x"),y:t.v("y"),...e,inset:.5,clip:P})];let[o,s]=n?[]:Ut(t.v("x")),[i,l]=r?[]:Ut(t.v("y"));return n?[S.barY(t.index,{x:t.v("x"),y1:i,y2:l,...e,clip:P})]:r?[S.barX(t.index,{y:t.v("y"),x1:o,x2:s,...e,insetTop:.5,insetBottom:.5,clip:P})]:[S.rect(t.index,{x1:o,x2:s,y1:i,y2:l,...e,clip:P})]},text:t=>[S.text(t.index,{x:t.v("x"),y:t.v("y"),text:t.v("label"),fontSize:t.options.size??t.fonts.tick,...ft(t,t.theme.ink),clip:P})],errorbar:t=>{let e={...lt(t,t.theme.ink),strokeWidth:t.options.size??1.2},n=S.ruleX(t.index,{x:t.v("x"),y1:t.v("ymin"),y2:t.v("ymax"),...e,clip:P});if(t.kind.x==="category"){let i=t.bandwidth.x*.35,l=a=>S.tickY(t.index,{x:t.v("x"),y:t.v(a),...e,insetLeft:i,insetRight:i,clip:P});return[n,l("ymin"),l("ymax")]}let[r,o]=Ut(t.v("x"),.25),s=i=>S.link(t.index,{x1:r,x2:o,y1:t.v(i),y2:t.v(i),...e,clip:P});return[n,s("ymin"),s("ymax")]},box:t=>{let[e,n,r]=[t.v("x"),t.v("y"),t.colors(t.theme.muted)],o=[];for(let[a,c]of _.group(t.index,u=>e[u])){let u=Vt(c.map(p=>n[p]));u.n&&o.push({key:a,color:Array.isArray(r)?r[c[0]]:r,...u})}let s=o.flatMap(a=>a.outliers.map(c=>({key:a.key,v:c,color:a.color}))),i=a=>({insetLeft:t.bandwidth.x*a,insetRight:t.bandwidth.x*a}),l={x:"key",stroke:"color",strokeWidth:1.25,clip:P};return[S.ruleX(o,{...l,y1:"q3",y2:"high"}),S.ruleX(o,{...l,y1:"low",y2:"q1"}),S.tickY(o,{...l,y:"high",...i(.38)}),S.tickY(o,{...l,y:"low",...i(.38)}),S.barY(o,{...l,y1:"q1",y2:"q3",fill:"color",fillOpacity:t.options.alpha??.3,...i(.22)}),S.tickY(o,{x:"key",y:"median",stroke:t.theme.ink,strokeWidth:2.25,...i(.22),clip:P}),S.dot(s,{x:"key",y:"v",fill:"color",r:t.theme.point,clip:P})]}};function he(t,e=.9){return t.options.position==="overlay"?.45:e}function Ut(t,e=.5){let n=t.map(Number),r=[...new Set(n)].sort((i,l)=>i-l),o=_.min(_.pairs(r),([i,l])=>l-i)??1,s=t[0]instanceof Date?i=>new Date(i):i=>i;return[n.map(i=>s(i-o*e)),n.map(i=>s(i+o*e))]}function bo(t){let e=t.v("x");if(!t.options.jitter||t.kind.x==="category")return e;let n=_.randomUniform.source(_.randomLcg(42))(-1,1),[r]=Ut(e,t.options.jitter);return e.map((o,s)=>+o+(+o-+r[s])*n()).map(o=>e[0]instanceof Date?new Date(o):o)}function wo(t){return(e,n,r,o,s,i)=>{let l=_.randomUniform.source(_.randomLcg(42))(-1,1),a=n.scales.x?.bandwidth??20,c=Float64Array.from(r.x,u=>u+l()*a*t*.5);return i(e,n,{...r,x:c},o,s)}}import*as Lt from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var Dt=18,zt=6,at={thick:12,long:150,slices:48},ko=3,vo=1.25,Mo=["line","path","step","density","smooth","hline","vline","abline","segment","errorbar"],Eo=["bar","hist","area","ribbon","rect","tile","box"];function ln(t,e,n,{horizontal:r,maxWidth:o,maxHeight:s}){if(e.kind==="none"||t.theme.legend==="none")return null;let i=t.theme.metrics,l=(h,m,v)=>dt(h,m,v,i),a=t.labels.color===null?null:t.labels.color??e.column,c=a?n.legend*1.8:0,u=a?l(a,n.legend+1,!0):0;if(e.kind==="continuous"){let h=wt(e.type==="time"?"time":"linear",e.domain,4),m=h.major.map(h.format),v=Lt.max(m,D=>l(D,n.legend))??0,M=Math.min(at.long,r?o:s-c-4),[E,A]=r?[M,at.thick+n.legend*1.6]:[at.thick+zt+v,M];return{kind:"ramp",title:a,titleH:c,color:e,long:M,ticks:h.major,labels:m,width:Math.max(u,E),height:c+A,horizontal:r}}let p=t.layers.filter(h=>h.channels.color?.column),f=p.some(h=>Eo.includes(h.type))?"square":p.some(h=>Mo.includes(h.type))?"line":"point",d=Math.round(n.legend*1.75),g=n.legend*vo,y=r?Math.max(80,o-Dt-zt):Math.max(110,Math.min(200,o*.2)),w=e.domain.map(h=>{let m=r?[ht(h,n.legend,y,!1,i)]:gt(h,n.legend,y,!1,i,ko),v=Dt+zt+(Lt.max(m,M=>l(M,n.legend))??0);return{value:h,label:m.join(" "),lines:m,color:e.apply(h),w:v,h:d+(m.length-1)*g}});if(!r){let h=[[]],m=c;for(let E of w)m+E.h>s&&h.at(-1).length&&(h.push([]),m=c),h.at(-1).push(Object.assign(E,{y:m})),m+=E.h;let v=0;for(let E of h){for(let A of E)A.x=v;v+=(Lt.max(E,A=>A.w)??0)+n.legend}let M=Lt.max(h,E=>E.at(-1).y+E.at(-1).h)??c;return{kind:"swatches",title:a,titleH:c,key:f,rowH:d,lineH:g,items:w,width:Math.max(u,v-n.legend),height:M,horizontal:r}}let b=0,x=c;for(let h of w)b>0&&b+h.w>o&&([b,x]=[0,x+d]),Object.assign(h,{x:b,y:x}),b+=h.w+n.legend*1.5;let k=Math.max(u,Lt.max(w,h=>h.x+h.w)??0);return{kind:"swatches",title:a,titleH:c,key:f,rowH:d,lineH:g,items:w,width:k,height:x+d,horizontal:r}}function an(t,e,n,r,o=new Set){let s=B(t,"g",{class:"pt-legend","font-size":r.legend});return e.title&&s.append(J(t,e.title,{y:r.legend,"font-weight":"bold","font-size":r.legend+1,fill:n.ink})),e.kind==="ramp"?Fo(t,s,e,n,r):e.items.forEach((i,l)=>s.append(Ao(t,e,i,l,n,o.has(i.value)))),s}function Ao(t,e,n,r,o,s){let i=e.rowH/2,l=B(t,"g",{class:"pt-key","data-index":r,transform:`translate(${n.x},${n.y})`,opacity:s?.35:1}),a=B(t,"rect",{width:n.w,height:n.h,fill:"transparent"}),c=e.key==="line"?B(t,"line",{x1:1,x2:Dt-1,y1:i,y2:i,stroke:n.color,"stroke-width":Math.max(2.5,o.line+1)}):e.key==="point"?B(t,"circle",{cx:Dt/2,cy:i,r:Math.max(3.5,o.point+1),fill:n.color}):B(t,"rect",{x:3,y:i-6,width:12,height:12,fill:n.color}),u=B(t,"text",{x:Dt+zt,y:i,dy:"0.35em",fill:o.muted,"text-decoration":s?"line-through":null});return n.lines.forEach((p,f)=>u.append(f?J(t,p,{x:Dt+zt,dy:e.lineH},"tspan"):t.createTextNode(p))),n.lines.at(-1).endsWith("\u2026")&&u.append(J(t,n.value,{},"title")),l.append(a,c,u),l}function Fo(t,e,n,r,o){let{color:s,horizontal:i,long:l}=n,[a,c]=s.domain.map(Number),u=f=>(Number(f)-a)/(c-a||1),p=n.titleH;for(let f=0;f<at.slices;f++){let d=f/at.slices,g=l/at.slices+.5,y=s.ramp(i?d:1-d),w=i?{x:d*l,y:p,width:g,height:at.thick}:{x:0,y:p+d*l,width:at.thick,height:g};e.append(B(t,"rect",{...w,fill:y}))}n.ticks.forEach((f,d)=>{let g=u(f)*l,y=i?{x:g,y:p+at.thick+o.legend*1.2,"text-anchor":"middle"}:{x:at.thick+zt,y:p+l-g,dy:"0.35em"};e.append(J(t,n.labels[d],{...y,fill:r.muted}))})}import*as N from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var mt={size:4,padding:3},cn=40,So=3,fe=1.15,Co=.22;function un({ns:t,grid:e,kind:n,home:r,legend:o,info:s,fonts:i,W:l,H:a}){let c=t.theme,u=c.metrics,p=(F,Y,U)=>dt(F,Y,U,u),f=i.base,d=Math.round(f*.9),g=Math.round(f*.8),{title:y,subtitle:w,caption:b,x,y:k}=t.labels,h=F=>s?.position===F?s:null,m=x?i.axisTitle*1.7:0,v=k?i.axisTitle*1.7:0,M=N.max(e.panels,(F,Y)=>{let U=wt(n.y,r[Y].y,5,t.scales.y?.format);return N.max(U.major,At=>p(U.format(At),i.tick))}),E=v+(M??0)+mt.size+mt.padding+3,A=l-2*d-(c.fixedFormat?E:Math.min(180,l*Co)),D=y?gt(y,i.title,A,!0,u):[],L=w?gt(w,i.subtitle,A,!1,u):[],O=D.length*i.title*1.25+L.length*i.subtitle*1.4,I=d+O+(O?f*.7:0),Z=b?i.tick*1.8:0,G=Math.max(o&&!o.horizontal?o.width:0,h("right")?.width??0),z=G?G+f*1.5:0,$=o?.horizontal?o.height+f*.8:0,kt=h("bottom")?h("bottom").height+g:0,V={x:d+v,y:I,w:l-2*d-v-z,h:a-I-d-m-$-Z-kt},ct=e.kind==="none"?0:Math.round(i.strip*2),Bt=e.kind==="wrap"?ct:0,qt=e.kind==="grid"&&t.facet.cols?ct+2:0,we=e.kind==="grid"&&t.facet.rows?ct+2:0,ke=t.facet?.free??{x:!1,y:!1},jn=e.panels.length,ve=F=>ke.y||F.col===0,Ot=(F,Y)=>ke.x||(e.kind==="wrap"?Y+e.ncol>=jn:F.row===e.nrow-1),R=V.w/e.ncol,W=V.h/e.nrow,ut,pt,Tt,Jt,yt,vt;for(let F=0;F<2;F++){Jt={x:Math.max(2,R/(n.x==="time"?110:75)),y:Math.max(2,W/45)},ut=Array(e.ncol).fill(0),pt=Array(e.nrow).fill(0),yt=!1,vt=new Map,Tt=0;let Y=0;e.panels.forEach((q,X)=>{if(ve(q)){let Q=wt(n.y,r[X].y,Jt.y,t.scales.y?.format),Ft=N.max(Q.major,st=>p(Q.format(st),i.tick))??0;if(ut[q.col]=Math.max(ut[q.col],Math.ceil(Ft+mt.size+mt.padding+3)),q.row===0&&!Bt&&!qt&&n.y!=="category"){let[st,jt]=r[X].y,Ht=(n.y==="log"?N.scaleLog():N.scaleLinear()).domain([st,jt]).range([W,0]),Yt=N.max(Q.major.filter(Le=>+Le>=+st&&+Le<=+jt));Yt!==void 0&&(Tt=Math.max(Tt,Math.ceil(i.tick*.6-Ht(Yt))))}}if(n.x==="category"&&Ot(q,X)){let Q=r[X].x,Ft=R/(Q.length+.2)*.95;for(let st of Q){let jt=p(st,i.tick);if(Y=Math.max(Y,jt),jt<=Ft)continue;let Ht=gt(st,i.tick,Ft,!1,u,So);Ht.at(-1).endsWith("\u2026")||N.max(Ht,Yt=>p(Yt,i.tick))>Ft?yt=!0:vt.set(String(st),Ht)}}});let U=Math.min(Y,Math.max(W*.6,i.tick*10));yt&&(vt.clear(),e.panels.forEach((q,X)=>{if(!(n.x!=="category"||!Ot(q,X)))for(let Q of r[X].x)p(Q,i.tick)>U&&vt.set(String(Q),[ht(Q,i.tick,U,!1,u)])}));let At=yt?1:N.max(vt.values(),q=>q.length)??1,Wt=yt?U*Math.sin(cn*Math.PI/180)+i.tick:i.tick*(1.2+fe*(At-1));yt&&e.panels.forEach((q,X)=>{if(q.col!==0||!Ot(q,X))return;let Q=R/(r[X].x.length+.2),st=Math.min(p(r[X].x[0],i.tick),U)*Math.cos(cn*Math.PI/180)+i.tick*.5;ut[0]=Math.max(ut[0],Math.ceil(st-.6*Q))}),e.panels.forEach((q,X)=>{Ot(q,X)&&(pt[q.row]=Math.max(pt[q.row],Math.ceil(Wt+mt.size+mt.padding+3)))}),R=(V.w-N.sum(ut)-g*(e.ncol-1)-we)/e.ncol,W=(V.h-Tt-N.sum(pt)-e.nrow*Bt-qt-g*(e.nrow-1))/e.nrow}R=Math.max(20,R),W=Math.max(20,W);let Qt={w:R,h:W};c.aspect&&(W>R*c.aspect?W=R*c.aspect:R=W/c.aspect);let Hn=(Qt.h-W)*e.nrow/2,Me=(Qt.w-R)*e.ncol/2,In=N.cumsum([V.x+Me,...ut.slice(0,-1).map(F=>F+R+g)]),Rn=N.cumsum([V.y+Tt+qt+Hn,...pt.slice(0,-1).map(F=>Bt+W+F+g)]),Nt=e.panels.map((F,Y)=>({x:In[F.col],y:Rn[F.row]+Bt,w:ut[F.col]+R,h:W+pt[F.row],ml:ut[F.col],mb:pt[F.row],innerW:R,innerH:W,count:Jt,rotateX:yt,wrapX:vt,showX:Ot(F,Y),showY:ve(F)})),qn=F=>[F.strips.top!=null&&[F.strips.top,R],F.strips.right!=null&&[F.strips.right,W]].filter(Boolean),Wn=Math.max(c.shrink??1,Math.min(1,N.min(e.panels.flatMap(qn),([F,Y])=>(Y-8)/p(F,i.strip,!0))??1)),te=Math.round(i.strip*Wn*10)/10,ee=[];e.panels.forEach((F,Y)=>{let U=Nt[Y],At=U.x+U.ml,Wt=(q,X)=>ht(q,te,X-8,!0,u);F.strips.top!=null&&ee.push({x:At,y:U.y-Bt-qt,w:R,h:ct,text:Wt(F.strips.top,R),full:F.strips.top,size:te}),F.strips.right!=null&&ee.push({x:At+R+2,y:U.y,w:ct,h:W,text:Wt(F.strips.right,W),full:F.strips.right,vertical:!0,size:te})});let ne=Nt[0],Ee=Nt.find((F,Y)=>e.panels[Y].col===e.ncol-1)??ne,Mt=ne.x+ne.ml,oe=Ee.x+Ee.w,Ae=N.max(Nt,F=>F.y+F.h),Et=[],re=d;for(let F of D)Et.push({text:F,attrs:{x:Mt,y:re+=i.title*1.05,"font-size":i.title,"font-weight":"bold",fill:c.ink,"text-anchor":"start"}}),re+=i.title*.2;for(let F of L)Et.push({text:F,attrs:{x:Mt,y:re+=i.subtitle*1.3,"font-size":i.subtitle,fill:c.muted,"text-anchor":"start"}});if(x&&Et.push({text:x,attrs:{x:(Mt+oe)/2,y:Ae+i.axisTitle*1.35,"text-anchor":"middle","font-size":i.axisTitle,fill:c.muted}}),k){let F=V.y+(V.h-N.sum(pt))/2;Et.push({text:k,attrs:{transform:`translate(${d+Me+i.axisTitle*.85},${F}) rotate(-90)`,"text-anchor":"middle","font-size":i.axisTitle,fill:c.muted}})}b&&Et.push({text:ht(b,i.tick,l-2*d,!1,u),attrs:{x:Mt,y:a-d-($||0)+i.tick*.2,"font-size":i.tick,fill:c.muted,"text-anchor":"start"}});let Fe=oe+we+f*1.5,Se=Fe<l-d-G-1?Fe:l-d-G,Yn=s?s.position==="right"?{x:Se,y:V.y}:{x:Math.max(d,Math.min(Mt,l-d-s.width)),y:Ae+m+g/2}:null,Ce=h("right")?s.height+f:0,Xn=o?o.horizontal?{x:Math.max(d,(Mt+oe-o.width)/2),y:a-d-o.height}:{x:Se,y:V.y+Ce+Math.max(0,(V.h-N.sum(pt)-Ce-o.height)/2)}:null;return{panels:Nt,strips:ee,texts:Et,legend:Xn,info:Yn,area:V,room:Qt,rotateX:yt}}function pn(t,e={}){if(typeof t?.spec=="function"&&(t=t.spec()),t?.version!==1)throw new Error("plotto: unknown spec version");let n=Te({...t.theme,...e});n.legendSet=(e.legend??t.theme?.legend)!=null;let r=t.data.map(Lo),o=t.layers.map(a=>Do(a,t.mapping??{},r,n));if(!o.length)throw new Error("plotto: the plot has no layers. Add one, for example .line() or .point()");let s=zo(t.facet),i={...Po(o),...t.labels},l=t.info?.entries?.length?{entries:t.info.entries,position:t.info.position??"right",set:!!t.info.position}:null;return{tables:r,layers:o,facet:s,scales:t.scales??{},labels:i,info:l,theme:n}}function Lo({columns:t}){let e=Object.keys(t),n=e.length?t[e[0]].values.length:1;return{columns:t,n}}function Do(t,e,n,r){let o=j.layers[t.type];if(!o)throw new Error(`plotto: unknown layer type "${t.type}". Valid: ${Object.keys(j.layers).join(", ")}`);let s=t.data??0,i=n[s].columns,l={};for(let u of o.channels)t.mapping?.[u]!==void 0?l[u]={column:t.mapping[u]}:t.set?.[u]!==void 0?l[u]={value:t.set[u]}:o.inherit!==!1&&e[u]in i&&(l[u]={column:e[u]});let a=o.requires.filter(u=>!l[u]);if(a.length)throw new Error(`${t.type}(): set ${a.join(" and ")}, as a column name or a value`);if(l.color&&"value"in l.color){let u=Ct(r,l.color.value);if(!u)throw new Error(`${t.type}(): "${l.color.value}" is not a column or a color. Theme colors: ${je(r).join(", ")}`);l.color={value:u}}let c={};for(let u of o.options)t.set?.[u]!==void 0&&(c[u]=t.set[u]);return{type:t.type,table:s,channels:l,options:c}}function zo(t){if(!t)return null;let e={x:["x","both"].includes(t.free),y:["y","both"].includes(t.free)};return t.wrap?{kind:"wrap",by:t.wrap,ncol:t.ncol??null,free:e}:{kind:"grid",rows:t.rows??null,cols:t.cols??null,free:e}}function Po(t){let e=o=>{for(let s of t)for(let i of o)if(s.channels[i]?.column)return s.channels[i].column},n=t.find(o=>o.type==="hist"||o.type==="density"),r=e(["y","ymin","yend"])??(n?n.type==="density"||n.options.density?"density":"count":void 0);return{x:e(["x","xmin","xend"]),y:r,color:e(["color"])}}function dn(t){return t.layers.map(e=>e.type!=="hist"||!e.channels.x.column?null:en(t.tables[e.table].columns[e.channels.x.column].values,e.options.bins??30))}function me(t,e,n,r){let{ns:o,kind:s,colorLevels:i,edges:l}=t;if(r.size&&e.channels.color?.column){let w=o.tables[e.table].columns[e.channels.color.column].values;n=n.filter(b=>!r.has(w[b]))}let a={};for(let w of Object.keys(e.channels))a[w]=We(o,e,w,n);let c=n.length,u=e.options,p=(w,b,x)=>Qe(w,b,x,i),f=w=>w.x?.length??0,d=a,g=n;if(u.summary&&(e.type==="line"||e.type==="point"))d=Je(a,c,u.summary);else if(e.type==="bar")d=p(a,c,u.position??"stack"),s.x!=="category"&&(d=tn(d,c));else if(e.type==="area")d=p(a,c,u.position??"stack");else if(e.type==="hist"){let w=nn(a,c,l[o.layers.indexOf(e)],u.density);d=p(w,f(w),u.position??"stack")}else e.type==="density"?d=on(a,c):e.type==="smooth"&&(d=rn(a,c,u));d!==a&&(g=null);let y={cols:d,n:d===a?c:f(d),rows:g};return y.hover=$o(o,e,y),y}function $o(t,e,{cols:n,rows:r}){let o=t.labels.x||e.channels.x?.column||"x",s=t.labels.y||e.channels.y?.column||"y",i=(c,u,p,f)=>({label:c,axis:u,values:p,values2:f}),l=i(o,"x",n.x),a=e.channels.tooltip?.column&&r?[i(e.channels.tooltip.column,null,n.tooltip)]:[];switch(e.type){case"line":case"path":case"step":case"point":return{hx:n.x,hy:n.y,fields:[l,i(s,"y",n.y),...a]};case"bar":case"area":return{hx:n.x,hy:n.ymax,fields:[l,i(s,"y",n.value),...a]};case"hist":return{hx:n.x,hy:n.ymax,fields:[i(o,"x",n.xmin,n.xmax),i(e.options.density?"density":"count",null,n.value)]};case"density":return{hx:n.x,hy:n.y,fields:[l,i("density",null,n.y)]};case"smooth":{let c=n.ymin.some(u=>u!==null)?[i("95% CI","y",n.ymin,n.ymax)]:[];return{hx:n.x,hy:n.y,fields:[l,i(s,"y",n.y),...c]}}case"ribbon":return{hx:n.x,hy:n.ymax,fields:[l,i(s,"y",n.ymin,n.ymax)]};case"errorbar":return{hx:n.x,hy:n.ymax,fields:[l,i(s,"y",n.ymin,n.ymax)]};case"tile":{let c=e.channels.color?.column?[i(t.labels.color??"value",null,n.color)]:[];return{hx:n.x,hy:n.y,fields:[l,i(s,"y",n.y),...c,...a],tile:!0}}case"box":return{hx:n.x,hy:n.y,fields:[l,i(s,"y",n.y)]};default:return null}}var hn=560,fn=240,Bo=1.2,Oo=.05,To=.1;function Kt(t,{document:e=globalThis.document,width:n,domains:r,hidden:o=new Set}={}){let s=pn(t),i=s.theme,l=Math.round(n??i.width),c=n&&i.reflow&&!i.fixedHeight?Math.max(fn,Math.round(l*i.height/i.width)):i.height;i.legend==="right"&&l<hn&&(i.legend="bottom");let u=Ve(s),p={x:ue(s,"x"),y:ue(s,"y")},f=Ge(s),d={ns:s,kind:p,colorLevels:f.domain??[],edges:dn(s)};for(let M of u.panels)M.views=s.layers.map((E,A)=>me(d,E,M.rows[A],new Set));let g=Ho(s,u,p),y=(M,E,A)=>{let D=Ie(i),L={...D,legend:Math.round(D.legend*A*10)/10},O=Ke(s,L,{W:l,H:M,narrow:l<hn,place:E.info}),I=O?.position==="right"?O.height+L.base:0,Z=ln(s,f,L,{horizontal:E.legend==="bottom",maxWidth:l*.9,maxHeight:M*.8-I}),G=un({ns:s,grid:u,kind:p,home:g,legend:Z,info:O,fonts:L,W:l,H:M}),z=Z?.items??[],$=z.filter(ct=>ct.lines.at(-1).endsWith("\u2026")).length+(z.some(ct=>!Z.horizontal&&ct.x>0)?1:0)+(O?.cut??0),kt=G.panels[0],V=E.legend===i.legend&&E.info===s.info?.position;return{fonts:L,info:O,legend:Z,layout:G,k:A,cut:$,usual:V,area:kt.innerW*kt.innerH}},w=M=>{let E=!i.fitHeight,A=E&&!i.legendSet&&i.legend==="right"?["right","bottom"]:[i.legend],D=E&&s.info&&!s.info.set?["right","bottom"]:[s.info?.position],L=[];for(let z=1;z>=(i.shrink??1)-1e-9;z-=Oo)L.push(z);let O=A.flatMap(z=>D.flatMap($=>L.map(kt=>y(M,{legend:z,info:$},kt)))),I=bt.min(O,z=>z.cut),Z=O.filter(z=>z.cut===I),G=bt.max(Z,z=>z.area);return Z.filter(z=>z.area>=G*(1-To)).sort((z,$)=>$.k-z.k||$.usual-z.usual||$.area-z.area)[0]},{fonts:b,info:x,legend:k,layout:h}=w(c);if(i.aspect&&i.fitHeight){let M=c+u.nrow*(h.room.w*i.aspect-h.room.h);c=Math.round(Math.min(c*Bo,Math.max(fn,M))),{fonts:b,info:x,legend:k,layout:h}=w(c)}let m=B(e,"svg",{xmlns:"http://www.w3.org/2000/svg",width:l,height:c,viewBox:`0 0 ${l} ${c}`,"font-family":i.font,"font-size":b.base,style:`color:${i.ink}`});m.append(B(e,"rect",{width:l,height:c,fill:i.background}));for(let M of h.texts)m.append(J(e,M.text,M.attrs));x&&m.append(Ze(e,x,i,h.info));for(let M of h.strips)m.append(Ro(e,M,i));let v={spec:t,ns:s,doc:e,svg:m,theme:i,fonts:b,grid:u,kind:p,color:f,ctx:d,legend:k,info:x,layout:h,home:g,W:l,H:c};return v.domains=r??g,v.hidden=o,v.panelLayer=m.appendChild(B(e,"g",{class:"pt-panels"})),k&&(v.legendG=m.appendChild(gn(v))),xt(v),v}function yn(t,e){return Kt(t,e).svg.outerHTML}function xt(t){let{ns:e,grid:n,ctx:r,hidden:o}=t;if(o.size||t.filtered){for(let s of n.panels)s.views=e.layers.map((i,l)=>me(r,i,s.rows[l],o));t.filtered=o.size>0}t.panelLayer.replaceChildren(),t.panels=n.panels.map((s,i)=>No(t,s,i)),t.legendG&&t.legendG.replaceWith(t.legendG=gn(t))}function gn(t){let e=an(t.doc,t.legend,t.theme,t.fonts,t.hidden);return e.setAttribute("transform",`translate(${t.layout.legend.x},${t.layout.legend.y})`),e}function No(t,e,n){let{ns:r,doc:o,theme:s,fonts:i,kind:l,color:a}=t,c=t.layout.panels[n],u={x:mn(l.x,t.domains[n].x),y:mn(l.y,t.domains[n].y)},p={x:l.x==="category"?c.innerW/(u.x.length+.2)*.8:0},f=r.layers.map((m,v)=>{let M=e.views[v],E=jo({view:M,layer:m,kind:l,color:a,theme:s,fonts:i,domain:u,bandwidth:p});return{layer:m,view:M,c:E,marks:M.n?sn[m.type](E):[]}}),d=m=>{let v=wt(l[m],t.domains[n][m],c.count[m],r.scales[m]?.format),M=E=>l[m]==="category"||+E>=+u[m][0]&&+E<=+u[m][1];return{major:v.major.filter(M),minor:v.minor,format:v.format}},g=d("x"),y=d("y"),w=m=>({stroke:m?s.gridMinor:s.grid,strokeOpacity:1,strokeWidth:m?.6:.9}),b={tickSize:mt.size,tickPadding:mt.padding,fontSize:i.tick,stroke:s.tick,fill:s.muted,label:null},x=[];if(l.x!=="category"&&x.push(et.gridX(g.minor,w(!0)),et.gridX(g.major,w(!1))),l.y!=="category"&&x.push(et.gridY(y.minor,w(!0)),et.gridY(y.major,w(!1))),x.push(...f.flatMap(m=>m.marks)),c.showX){let m=c.rotateX?{tickRotate:-40,textAnchor:"end"}:{},v=E=>c.wrapX.get(String(E))?.join(`
|
|
2
|
-
`)??g.format(E),M=c.wrapX.size?{tickFormat:v,lineHeight:fe}:{tickFormat:g.format};x.push(et.axisX(g.major,{...b,...m,anchor:"bottom",...M}))}c.showY&&x.push(et.axisY(y.major,{...b,anchor:"left",tickFormat:y.format}));let k=et.plot({document:o,width:c.w,height:c.h,marginLeft:c.ml,marginRight:0,marginTop:0,marginBottom:c.mb,x:xn(l.x,u.x),y:xn(l.y,u.y),color:{type:"identity"},marks:x}),h=B(o,"g",{class:"pt-panel","data-panel":n,transform:`translate(${c.x},${c.y})`,fill:"currentColor","text-anchor":"middle"});for(let m of[...k.childNodes])m.nodeName.toLowerCase()!=="style"&&h.append(m);return t.panelLayer.append(h),{g:h,plot:k,box:c,layers:f}}function jo({view:t,layer:e,kind:n,color:r,theme:o,fonts:s,domain:i,bandwidth:l}){let a=f=>It.x.includes(f)?"x":It.y.includes(f)?"y":null,c={},u=f=>{if(f in c)return c[f];let d=t.cols[f];return d&&n[a(f)]==="time"&&(d=d.map(g=>g===null?null:new Date(g))),c[f]=d},p=e.channels.color;return{index:bt.range(t.n),v:u,options:e.options,colors:f=>p?"value"in p?p.value:u("color").map(r.apply):f,groups:()=>u("group")??(p?.column?u("color"):void 0),kind:n,theme:o,fonts:s,domain:i,bandwidth:l}}function mn(t,e){return t==="time"?e.map(n=>new Date(n)):e}function xn(t,e){return{type:{linear:"linear",log:"log",time:"utc",category:"band"}[t],domain:e,axis:null,...t==="category"?{padding:.2,round:!1}:{}}}function Ho(t,e,n){let r=t.facet?.free??{x:!1,y:!1},o=(i,l,a)=>r[i]?e.kind==="grid"?i==="x"?`c${l.col}`:`r${l.row}`:`p${a}`:"all",s=e.panels.map(()=>({}));for(let i of["x","y"]){let l=bt.group(e.panels.map((a,c)=>[a,c]),([a,c])=>o(i,a,c));for(let a of l.values()){let c=Io(t,i,n[i],a.map(([u])=>u));for(let[,u]of a)s[u][i]=c}}return s}function Io(t,e,n,r){let o=t.scales[e]?.limits;if(o&&(n==="category"||o.every(i=>i!==null)))return o;let s=Ye(t,e,n,r);return o?[o[0]??s[0],o[1]??s[1]]:s}function Ro(t,e,n){let r=B(t,"g",{class:"pt-strip"});r.append(B(t,"rect",{x:e.x,y:e.y,width:e.w,height:e.h,fill:n.strip}));let o=e.vertical?{transform:`translate(${e.x+e.w/2},${e.y+e.h/2}) rotate(90)`,dy:"0.35em"}:{x:e.x+e.w/2,y:e.y+e.h/2,dy:"0.35em"},s=J(t,e.text,{...o,"text-anchor":"middle","font-weight":"bold","font-size":e.size,fill:n.ink});return e.text!==String(e.full)&&s.append(J(t,e.full,{},"title")),r.append(s),r}async function xe(t,e,n=2){let r=kn(t,e?n*e.width/t.viewBox.baseVal.width:n),o={"image/png":r.then(qo)};if(e){let s=i=>`<img src="${i.toDataURL("image/png")}" width="${e.width}" height="${e.height}">`;o["text/html"]=r.then(i=>new Blob([s(i)],{type:"text/html"}))}try{return await navigator.clipboard.write([new ClipboardItem(o)]),"Copied"}catch{return ye((await r).toDataURL("image/png"),"plot.png"),"Downloaded"}}async function bn(t){ye((await kn(t)).toDataURL("image/png"),"plot.png")}function wn(t){ye(vn(t),"plot.svg")}async function kn(t,e=2){let n=new Image;n.src=vn(t),await n.decode();let{width:r,height:o}=t.viewBox.baseVal,s=document.createElement("canvas");return s.width=Math.round(r*e),s.height=Math.round(o*e),s.getContext("2d").drawImage(n,0,0,s.width,s.height),s}function vn(t){let e=t.cloneNode(!0);e.querySelector(".pt-overlay")?.remove();let{width:n,height:r}=t.viewBox.baseVal;e.setAttribute("width",n),e.setAttribute("height",r);let o=new TextEncoder().encode(new XMLSerializer().serializeToString(e)),s="";for(let i of o)s+=String.fromCharCode(i);return`data:image/svg+xml;base64,${btoa(s)}`}var qo=t=>new Promise(e=>t.toBlob(e,"image/png"));function ye(t,e){let n=document.createElement("a");n.href=t,n.download=e,n.click()}import*as rt from"https://cdn.jsdelivr.net/npm/d3@7.9.0/+esm";var An=40,Wo=10,Yo=6,Fn=4,Xo=6,_o=["line","step","area","density","smooth","ribbon"],Go=["bar","hist","tile","box"],Vo=["point","path","errorbar"];function Sn(t,e,n,r,o){let s=t.panels[e],i=s.plot.scale("x"),l=s.plot.scale("y"),u={state:t,sx:i,sy:l,px:y=>i.apply(y)+(i.bandwidth??0)/2,py:y=>l.apply(y)+(l.bandwidth??0)/2},p=Qo(u,s,n);if(p)return{...p,panel:e};let f=Ko(u,s,n,r,o?.panel===e?o:null);if(f&&f.d<=Wo)return{...Mn(u,f),panel:e};let d=Zo(u,s,n,r,o?.panel===e?o:null);if(d)return{...d,panel:e};let g=tr(u,s,n,r);return g?{...g,panel:e}:f?{...Mn(u,f),panel:e}:null}function $t(t,e,n,r,o){let s=e.channels.color;return s?"value"in s?s.value:t.color.apply(n.cols.color[o]):e.type==="smooth"?t.theme.accent:t.theme.palette[0]}function ot(t,e,n){return n==null||Number.isNaN(n)?"\u2013":e&&t.kind[e]==="time"?Uo(t,e)(n):e&&t.kind[e]==="category"?String(n):typeof n=="number"?_e.number(n):String(n)}function Uo(t,e){if(t.timeFormats??={},t.timeFormats[e])return t.timeFormats[e];let n=t.grid.panels.flatMap(s=>s.views.flatMap(i=>i.cols[e]??[])).filter(s=>s!==null),r=s=>n.every(i=>s(new Date(i))),o=r(s=>s.getUTCDate()===1&&s.getUTCHours()===0&&s.getUTCMinutes()===0)?"%Y-%m":r(s=>s.getUTCHours()===0&&s.getUTCMinutes()===0)?"%Y-%m-%d":r(s=>s.getUTCSeconds()===0)?"%m-%d %H:%M":"%m-%d %H:%M:%S";return t.timeFormats[e]=rt.utcFormat(o)}function Pt(t,e,n){return e.values2?`${ot(t,e.axis,e.values[n])} \u2013 ${ot(t,e.axis,e.values2[n])}`:ot(t,e.axis,e.values[n])}function Ko({px:t,py:e},n,r,o,s){let i=null,l=null;for(let{layer:a,view:c,c:u}of n.layers){if(!Vo.includes(a.type)||!c.hover||!c.n)continue;let{hx:p,hy:f}=c.hover;for(let d=0;d<c.n;d++){if(p[d]===null||f[d]===null)continue;let g=Math.hypot(t(p[d])-r,e(f[d])-o);if(g>An)continue;let y={layer:a,view:c,c:u,k:d,d:g,x:t(p[d]),y:e(f[d])};(!i||g<i.d)&&(i=y),s?.layer===a&&s.k===d&&(l=y)}}return l&&i&&i.d>l.d-Fn?l:i}function Mn({state:t},{layer:e,view:n,c:r,k:o,x:s,y:i,d:l}){let a=$t(t,e,n,r,o),c=e.channels.color?.column?ot(t,null,n.cols.color[o]):null,u=n.hover.fields.map(p=>({label:p.label,value:Pt(t,p,o)})).filter(p=>p.value!==c);return{layer:e,k:o,d:l,color:a,header:c,rows:u,marks:[{x:s,y:i,color:a}],anchor:{x:s,y:i}}}function Zo({state:t,px:e,py:n},r,o,s,i){let l=[];for(let{layer:h,view:m,c:v}of r.layers){if(!_o.includes(h.type)||!m.hover||!m.n)continue;let{hx:M,hy:E}=m.hover,A=v.groups()??[],D=new Map;for(let L=0;L<m.n;L++){if(M[L]===null||E[L]===null)continue;let O=Math.abs(e(M[L])-o),I=A[L]??"";O<=An&&(!D.has(I)||O<D.get(I).dx)&&D.set(I,{layer:h,view:m,c:v,k:L,dx:O,series:I})}l.push(...D.values())}if(!l.length)return null;let a=rt.least(l,h=>h.dx),c=e(a.view.hover.hx[a.k]),u=l.filter(h=>Math.abs(e(h.view.hover.hx[h.k])-c)<=Yo);for(let h of u)h.y=n(h.view.hover.hy[h.k]);let p=rt.least(u,h=>Math.abs(h.y-s)),f=i?.series!==void 0&&u.find(h=>h.layer===i.layer&&h.series===i.series);f&&Math.abs(f.y-s)<Math.abs(p.y-s)+Fn&&(p=f);let d=h=>h.layer.channels.color?.column?ot(t,null,h.view.cols.color[h.k]):h.series!==""?String(h.series):h.view.hover.fields[1]?.label??h.layer.type,g=h=>$t(t,h.layer,h.view,h.c,h.k),y=a.view.hover.fields[0],w=ot(t,"x",a.view.hover.hx[a.k]),b={crosshair:c,anchor:{x:c,y:s},layer:p.layer,series:p.series};if(u.length===1||u.length>Xo){let h=[{label:y?.label??"x",value:w},{label:p.view.hover.fields[1]?.label??"y",value:En(t,p.layer,p.view,p.k)}],m=u.length-1;return{...b,color:g(p),header:d(p),rows:h,note:m?`${m} other series at this x`:null,marks:[{x:c,y:p.y,color:g(p)}]}}let x=Jo(t);u.sort((h,m)=>x(h)-x(m)||h.y-m.y);let k=u.map(h=>({swatch:g(h),label:d(h),value:En(t,h.layer,h.view,h.k),strong:h===p}));return{...b,color:t.theme.ink,header:y?`${y.label} ${w}`:w,rows:k,marks:u.map(h=>({x:c,y:h.y,color:g(h)}))}}function Jo(t){let{color:e}=t;return n=>{let r=n.layer.channels.color?.column?n.view.cols.color[n.k]:null;return r===null?t.ns.layers.indexOf(n.layer):e.kind==="ordinal"?e.domain.indexOf(r):typeof r=="number"?r:0}}function En(t,e,n,r){let o=n.hover.fields;return e.type==="smooth"&&o[2]?`${Pt(t,o[1],r)} (${Pt(t,o[2],r)})`:Pt(t,o[1],r)}function Qo(t,e,n){for(let{layer:r,view:o,c:s}of e.layers)if(r.type==="box"&&o.n)return nr(t,r,o,s,n);return null}function tr(t,e,n,r){let{state:o,sx:s,sy:i}=t;for(let{layer:l,view:a,c}of e.layers){if(!Go.includes(l.type)||l.type==="box"||!a.n)continue;let u=l.type==="tile",p=null;for(let y=0;y<a.n;y++){let[w,b]=or(l,a,y,s),x=Math.abs((w+b)/2-n);if(u?n<w-ge(s,b-w)||n>b+ge(s,b-w):x>b-w)continue;let[k,h]=rr(l,a,y,i),[m,v]=[Math.min(k,h),Math.max(k,h)],M=u?ge(i,v-m):0,E=r>=m-M&&r<=v+M;if(u&&!E)continue;let A=Math.round(x)*1e6+(E?0:1e5+m);(!p||A<p.score)&&(p={k:y,score:A,rect:{x:w,y:m,width:b-w,height:v-m}})}if(!p)continue;let{k:f,rect:d}=p,g=$t(o,l,a,c,f);if(u){let y=o.ns.labels.color??l.channels.color?.column??"value",w=l.channels.color?.column?ot(o,null,a.cols.color[f]):null,b=a.hover.fields.filter(x=>x.label!==y).map(x=>({label:x.label,value:Pt(o,x,f)}));return{color:g,header:w!==null?`${y} ${w}`:null,rows:b,marks:[{rect:d,color:o.theme.ink}],anchor:{x:d.x+d.width,y:r}}}return er(o,l,a,c,f,d)}return null}function ge(t,e){return t.bandwidth!==void 0?(t.step-t.bandwidth)/2||e*.125:.5}function er(t,e,n,r,o,s){let i=e.type==="hist"?f=>n.cols.xmin[f]===n.cols.xmin[o]:f=>String(n.cols.x[f])===String(n.cols.x[o]),l=rt.range(n.n).filter(i),a=!!e.channels.color?.column,c=l.sort((f,d)=>a&&t.color.kind==="ordinal"?t.color.domain.indexOf(n.cols.color[f])-t.color.domain.indexOf(n.cols.color[d]):n.cols.ymax[d]-n.cols.ymax[f]).map(f=>({swatch:$t(t,e,n,r,f),label:a?ot(t,null,n.cols.color[f]):n.hover.fields[1].label,value:ot(t,null,n.cols.value[f]),strong:f===o&&l.length>1}));(e.options.position??"stack")==="stack"&&l.length>1&&c.push({label:"total",value:ot(t,null,rt.sum(l,f=>n.cols.value[f])),strong:!1,total:!0});let p=n.hover.fields[0];return{color:$t(t,e,n,r,o),header:`${p.label} ${Pt(t,p,o)}`,rows:c,marks:[{rect:s,color:t.theme.ink}],anchor:{x:s.x+s.width,y:s.y}}}function nr({state:t,sx:e},n,r,o,s){if(e.bandwidth===void 0)return null;let i=rt.range(r.n).find(k=>{let h=e.apply(r.cols.x[k]);return s>=h&&s<=h+e.bandwidth});if(i===void 0)return null;let l=String(r.cols.x[i]),{n:a,q1:c,median:u,q3:p,low:f,high:d,outliers:g}=Vt(rt.range(r.n).filter(k=>String(r.cols.x[k])===l).map(k=>r.cols.y[k])),y=k=>ot(t,"y",k),w=[{label:"max (whisker)",value:y(d)},{label:"q3",value:y(p)},{label:"median",value:y(u),strong:!0},{label:"q1",value:y(c)},{label:"min (whisker)",value:y(f)},{label:"n",value:String(a)}];g.length&&w.push({label:"outliers",value:String(g.length)});let b=e.apply(r.cols.x[i]);return{color:n.channels.color?.column?$t(t,n,r,o,i):t.theme.ink,header:`${r.hover.fields[0].label} ${l}`,rows:w,marks:[],anchor:{x:b+e.bandwidth,y:null}}}function or(t,e,n,r){if(e.cols.xmin&&t.type!=="tile")return[r.apply(e.cols.xmin[n]),r.apply(e.cols.xmax[n])];if(r.bandwidth!==void 0){let i=e.cols.slots?.[n]??1,l=r.bandwidth/i,a=r.apply(e.cols.x[n])+(e.cols.slot?.[n]??0)*l;return[a,a+l]}let o=Cn(e.cols.x,r),s=r.apply(e.cols.x[n]);return[s-o,s+o]}function rr(t,e,n,r){if(t.type==="tile"){if(r.bandwidth!==void 0)return[r.apply(e.cols.y[n]),r.apply(e.cols.y[n])+r.bandwidth];let o=Cn(e.cols.y,r),s=r.apply(e.cols.y[n]);return[s-o,s+o]}return[r.apply(e.cols.ymin[n]),r.apply(e.cols.ymax[n])]}function Cn(t,e){let n=[...new Set(t.map(Number))].sort((o,s)=>o-s),r=1/0;for(let o=1;o<n.length;o++)r=Math.min(r,n[o]-n[o-1]);return Number.isFinite(r)?Math.abs(e.apply(n[0]+r)-e.apply(n[0]))/2:6}var sr={zoom:'<path d="M4 9V4h5M15 4h5v5M20 15v5h-5M9 20H4v-5"/><rect x="9" y="9" width="6" height="6"/>',pan:'<path d="M12 3v18M3 12h18M12 3l-2.5 2.5M12 3l2.5 2.5M12 21l-2.5-2.5M12 21l2.5-2.5M3 12l2.5-2.5M3 12l2.5 2.5M21 12l-2.5-2.5M21 12l-2.5 2.5"/>',zoomIn:'<path d="M12 5v14M5 12h14"/>',zoomOut:'<path d="M5 12h14"/>',home:'<path d="M4 11l8-7 8 7M6 9.5V20h12V9.5"/>',copy:'<rect x="8.5" y="8.5" width="11" height="11"/><path d="M15.5 8.5V4.5h-11v11h4"/>',slide:'<rect x="3.5" y="4.5" width="17" height="11"/><path d="M12 15.5v4M8 19.5h8M7 12.5l3-3 2.5 2 4.5-4"/>',download:'<path d="M12 4v11M7.5 10.5L12 15l4.5-4.5M5 19.5h14"/>',check:'<path d="M5 12.5l4.5 4.5L19 7.5"/>'},ir=`
|
|
3
|
-
.pt-root{position:relative;--pt-size:24px}
|
|
4
|
-
.pt-root svg{display:block;user-select:none;-webkit-user-select:none}
|
|
5
|
-
.pt-root .pt-key{cursor:pointer}
|
|
6
|
-
.pt-root:focus{outline:none}
|
|
7
|
-
.pt-bar{position:absolute;top:6px;right:6px;display:flex;align-items:stretch;z-index:3;background:var(--pt-bg);
|
|
8
|
-
border:1px solid var(--pt-line);opacity:0;transition:opacity .12s ease}
|
|
9
|
-
.pt-root:hover .pt-bar,.pt-root:focus-within .pt-bar,.pt-bar.pt-open{opacity:1}
|
|
10
|
-
@media (hover:none){.pt-bar{opacity:1}}
|
|
11
|
-
.pt-btn{all:unset;box-sizing:border-box;display:grid;place-items:center;width:var(--pt-size);height:var(--pt-size);
|
|
12
|
-
color:var(--pt-muted);cursor:pointer}
|
|
13
|
-
.pt-btn svg{width:58%;height:58%;fill:none;stroke:currentColor;stroke-width:1.75;stroke-linecap:square;stroke-linejoin:miter}
|
|
14
|
-
.pt-btn:hover{color:var(--pt-ink);background:var(--pt-soft)}
|
|
15
|
-
.pt-btn:focus-visible{outline:2px solid var(--pt-accent);outline-offset:-2px}
|
|
16
|
-
.pt-btn.pt-on{color:var(--pt-on-accent);background:var(--pt-accent)}
|
|
17
|
-
.pt-sep{width:1px;background:var(--pt-line)}
|
|
18
|
-
.pt-menu{position:absolute;top:100%;right:-1px;display:none;flex-direction:column;min-width:72px;margin-top:-1px;
|
|
19
|
-
background:var(--pt-bg);border:1px solid var(--pt-line)}
|
|
20
|
-
.pt-menu.pt-open{display:flex}
|
|
21
|
-
.pt-menu button{all:unset;padding:5px 12px;font:600 11px/1.4 system-ui,sans-serif;letter-spacing:.04em;color:var(--pt-ink);cursor:pointer}
|
|
22
|
-
.pt-menu button:hover{color:var(--pt-on-accent);background:var(--pt-accent)}
|
|
23
|
-
.pt-tip{position:absolute;display:none;pointer-events:none;z-index:4;min-width:110px;max-width:280px;background:var(--pt-bg);
|
|
24
|
-
color:var(--pt-ink);border:1px solid var(--pt-c);line-height:1.3;font-variant-numeric:tabular-nums}
|
|
25
|
-
.pt-tip.pt-pinned{border-width:2px;box-shadow:3px 3px 0 color-mix(in srgb,var(--pt-c) 35%,transparent)}
|
|
26
|
-
.pt-tip .pt-head{padding:3px 7px;background:var(--pt-c);color:var(--pt-on-c);font-weight:700;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
27
|
-
.pt-tip .pt-rows{display:grid;grid-template-columns:auto minmax(0,1fr) auto;column-gap:7px;row-gap:0;padding:4px 7px 5px}
|
|
28
|
-
.pt-tip .pt-sw{width:8px;height:8px;align-self:center}
|
|
29
|
-
.pt-tip .pt-k{color:var(--pt-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
30
|
-
.pt-tip .pt-v{text-align:right;white-space:nowrap}
|
|
31
|
-
.pt-tip .pt-b{color:var(--pt-ink);font-weight:700}
|
|
32
|
-
.pt-tip .pt-t{border-top:1px solid var(--pt-line);padding-top:2px;margin-top:1px}
|
|
33
|
-
.pt-tip .pt-more{grid-column:1/-1;color:var(--pt-muted);font-size:.9em}
|
|
34
|
-
.pt-error{padding:8px 10px;border-left:3px solid #d93025;background:#fdecea;color:#5f2120;font:12px/1.4 ui-monospace,monospace;white-space:pre-wrap}
|
|
35
|
-
`;function Dn(t){if(t.getElementById("plotto-style"))return;let e=t.createElement("style");e.id="plotto-style",e.textContent=ir,t.head.append(e)}function zn(t,e){let n={bg:e.background,ink:e.ink,muted:e.muted,line:e.grid,soft:e.strip,accent:e.accent,"on-accent":He(e.accent)};for(let[r,o]of Object.entries(n))t.style.setProperty(`--pt-${r}`,o)}function Pn(t,e){let n=t.createElement("div");n.className="pt-bar";let r={},o=null;e.forEach((i,l)=>{l&&n.append(Object.assign(t.createElement("div"),{className:"pt-sep"}));for(let a of i){let c=t.createElement("button");c.className="pt-btn",c.type="button",c.title=a.title,c.setAttribute("aria-label",a.title),c.innerHTML=Ln(a.name),c.addEventListener("pointerdown",u=>u.stopPropagation()),c.addEventListener("click",u=>(u.stopPropagation(),a.menu?s():a.action(c))),n.append(c),r[a.name]=c,a.menu&&(o=lr(t,n,a.menu))}});function s(){let i=!o.classList.contains("pt-open");o.classList.toggle("pt-open",i),n.classList.toggle("pt-open",i)}return o&&t.addEventListener("click",()=>o.classList.contains("pt-open")&&s()),{el:n,button:i=>r[i],setSize:i=>n.parentElement?.style.setProperty("--pt-size",`${Math.round(Math.min(30,Math.max(22,i/34)))}px`),flash(i,l){let a=r[i],[c,u]=[a.innerHTML,a.title];a.innerHTML=Ln("check"),a.title=l,a.classList.add("pt-on"),setTimeout(()=>(a.innerHTML=c,a.title=u,a.classList.remove("pt-on")),1100)}}}function lr(t,e,n){let r=t.createElement("div");r.className="pt-menu";for(let[o,s]of n){let i=t.createElement("button");i.type="button",i.textContent=o,i.addEventListener("click",l=>(l.stopPropagation(),r.classList.remove("pt-open"),e.classList.remove("pt-open"),s())),r.append(i)}return e.append(r),r}function Ln(t){return`<svg viewBox="0 0 24 24" aria-hidden="true">${sr[t]}</svg>`}var Zt=5,be=320,$n=.75,ar=300,cr={width:645,height:403},ur=3;function pr(t,e){let n=typeof t?.spec=="function"?t.spec():t,r={...n.theme,format:"slide",width:null,height:null,size:null},o=e.domains===e.home?void 0:e.domains;return Kt({...n,theme:r},{document:e.doc,domains:o,hidden:e.hidden})}function On(t,e,{interactive:n=!1,width:r}={}){let o=e.ownerDocument;Dn(o);let s=o.createElement("div");s.className="pt-root";let i=Object.assign(o.createElement("div"),{className:"pt-tip"}),l={state:null,mode:"zoom"},a=null,c=d=>{let g=l.state&&{domains:l.state.domains===l.state.home?void 0:l.state.domains,hidden:l.state.hidden},y=Kt(t,{document:o,width:d,...g}),w=l.state?.svg;y.overlay=y.svg.appendChild(B(o,"g",{class:"pt-overlay","pointer-events":"none"})),y.theme.reflow||(y.svg.setAttribute("width","100%"),y.svg.removeAttribute("height"),s.style.maxWidth=`${y.W}px`),w?w.replaceWith(y.svg):s.prepend(y.svg),l.state=y,zn(s,y.theme),p.setSize(y.theme.reflow?y.W:Math.min(y.W,e.clientWidth||y.W))},u=[[{name:"copy",title:"Copy as PNG",action:d=>xe(l.state.svg).then(g=>p.flash("copy",g))},{name:"slide",title:"Copy for a slide",action:()=>xe(pr(t,l.state).svg,cr,ur).then(d=>p.flash("slide",d))},{name:"download",title:"Download",menu:[["PNG",()=>bn(l.state.svg)],["SVG",()=>wn(l.state.svg)]]}]];n&&u.unshift([{name:"zoom",title:"Zoom: drag a box",action:()=>f("zoom")},{name:"pan",title:"Pan: drag the view",action:()=>f("pan")}],[{name:"zoomIn",title:"Zoom in",action:()=>Bn(l,$n)},{name:"zoomOut",title:"Zoom out",action:()=>Bn(l,1/$n)},{name:"home",title:"Reset view (double-click)",action:()=>Tn(l)}]);let p=Pn(o,u);s.append(p.el,i);let f=d=>{l.mode=d,p.button("zoom").classList.toggle("pt-on",d==="zoom"),p.button("pan").classList.toggle("pt-on",d==="pan"),s.style.cursor=d==="pan"?"grab":""};try{let d=r??(e.clientWidth?Math.max(be,e.clientWidth):void 0);c(d),e.replaceChildren(s)}catch(d){let g=Object.assign(o.createElement("div"),{className:"pt-error",textContent:`plotto: ${d.message}`});throw e.prepend(g),d}if(n&&(f("zoom"),dr(l,s,i)),l.state.theme.reflow&&r===void 0&&typeof ResizeObserver<"u"){let d;a=new ResizeObserver(()=>{clearTimeout(d),d=setTimeout(()=>{let g=Math.max(be,Math.round(e.clientWidth));g&&g!==l.state.W&&c(g)},100)}),a.observe(e)}return l.redraw=()=>xt(l.state),l.resize=d=>c(Math.max(be,d)),l.destroy=()=>a?.disconnect(),l}function dr(t,e,n){let r=null,o=null,s=()=>t.state.svg,i=b=>{let x=s().getBoundingClientRect(),k=t.state.W/x.width;return[(b.clientX-x.left)*k,(b.clientY-x.top)*k,k]},l=(b,x)=>t.state.layout.panels.findIndex(k=>b>=k.x+k.ml&&b<=k.x+k.ml+k.innerW&&x>=k.y&&x<=k.y+k.innerH),a=!1;e.addEventListener("pointerdown",b=>{if(b.button!==0||!s().contains(b.target))return;let[x,k]=i(b),h=l(x,k);h<0||(b.preventDefault(),e.focus({preventScroll:!0}),r={i:h,x,y:k,domains:t.state.domains,moving:!1,id:b.pointerId})}),e.addEventListener("pointermove",b=>{let[x,k,h]=i(b);if(r&&!r.moving&&Math.hypot(x-r.x,k-r.y)>=Zt&&(r.moving=!0,e.setPointerCapture(r.id),u(),w(),t.mode==="pan"&&(e.style.cursor="grabbing")),!r?.moving){!a&&!o&&(o=requestAnimationFrame(()=>(o=null,y(x,k,h))));return}if(t.mode==="pan")return xr(t,r,x,k);let m=t.state.layout.panels[r.i],v=z=>Math.max(m.x+m.ml,Math.min(m.x+m.ml+m.innerW,z)),M=z=>Math.max(m.y,Math.min(m.y+m.innerH,z)),[E,A]=[r.x,v(x)].sort((z,$)=>z-$),[D,L]=[r.y,M(k)].sort((z,$)=>z-$),O=L-D<Zt||t.state.kind.y==="category",I=A-E<Zt||t.state.kind.x==="category";if(O&&I)return t.state.overlay.replaceChildren();let Z={x:I?m.x+m.ml:E,y:O?m.y:D,width:I?m.innerW:A-E,height:O?m.innerH:L-D},G=t.state.theme.accent;t.state.overlay.replaceChildren(B(t.state.doc,"rect",{...Z,fill:G,"fill-opacity":.1,stroke:G,"stroke-opacity":.7,"stroke-width":1})),r.box={x0:E,x1:A,y0:D,y1:L}}),e.addEventListener("pointerup",b=>{if(r?.moving&&t.mode==="zoom"&&r.box)mr(t,r.i,r.box);else if(r&&!r.moving){let[x,k,h]=i(b);a?(u(),y(x,k,h)):(y(x,k,h),n.style.display==="block"&&c())}t.mode==="pan"&&(e.style.cursor="grab"),a||t.state.overlay.replaceChildren(),r=null}),e.addEventListener("pointerleave",()=>!r&&!a&&w()),e.addEventListener("keydown",b=>b.key==="Escape"&&(u(),w())),e.tabIndex=-1,t.clearHover=()=>(u(),w());function c(){a=!0,n.classList.add("pt-pinned")}function u(){a=!1,n.classList.remove("pt-pinned")}let p=b=>t.state.doc.elementFromPoint(b.clientX,b.clientY),f=b=>p(b)?.closest?.(".pt-key");e.addEventListener("dblclick",b=>{let[x,k]=i(b);l(x,k)<0||(u(),w(),Tn(t))});let d={value:void 0,time:0,before:null};e.addEventListener("click",b=>{let x=f(b);if(!x)return;let k=t.state.legend.items[Number(x.dataset.index)].value;t.clearHover();let h=performance.now();if(k===d.value&&h-d.time<ar)return t.state.hidden=d.before,d={value:void 0,time:0,before:null},fr(t,k);d={value:k,time:h,before:t.state.hidden};let m=new Set(t.state.hidden);m.has(k)?m.delete(k):m.add(k),t.state.hidden=m,xt(t.state)});let g=null;function y(b,x,k){let h=t.state,m=l(b,x),v=m<0?null:h.layout.panels[m],M=v?Sn(h,m,b-v.x,x-v.y,g):null;if(g=M,!M)return w();let E=h.doc,A=[];if(M.crosshair!==void 0){let $=v.x+M.crosshair;A.push(B(E,"line",{x1:$,x2:$,y1:v.y,y2:v.y+v.innerH,stroke:h.theme.muted,"stroke-opacity":.55,"stroke-width":1}))}for(let $ of M.marks)$.rect?A.push(B(E,"rect",{x:v.x+$.rect.x,y:v.y+$.rect.y,width:$.rect.width,height:$.rect.height,fill:"none",stroke:$.color,"stroke-width":1.5})):A.push(B(E,"circle",{cx:v.x+$.x,cy:v.y+$.y,r:h.theme.point+1.5,fill:$.color,stroke:h.theme.background,"stroke-width":1.5}));h.overlay.replaceChildren(...A);let D=ae(M.color);n.style.setProperty("--pt-c",D.bg),n.style.setProperty("--pt-on-c",D.fg),n.style.font=`${h.fonts.hover}px ${h.theme.font}`,n.replaceChildren(...hr(E,M)),n.style.display="block";let L=(v.x+M.anchor.x)/k,O=x/k,I=e.clientWidth,Z=e.clientHeight,G=L+16+n.offsetWidth>I?L-16-n.offsetWidth:L+16,z=Math.min(Math.max(0,O-18),Math.max(0,Z-n.offsetHeight));n.style.left=`${Math.max(0,G)}px`,n.style.top=`${z}px`}function w(){n.style.display="none",r||t.state.overlay.replaceChildren()}}function hr(t,e){let n=(s,i,l)=>Object.assign(t.createElement(s),{className:i,textContent:l??""}),r=[];e.header&&r.push(n("div","pt-head",e.header));let o=n("div","pt-rows");for(let s of e.rows){let i=n("span","pt-sw");s.swatch&&(i.style.background=s.swatch);let l=[i,n("span","pt-k",s.label),n("span","pt-v",s.value)];s.strong&&l.forEach(a=>a.classList.add("pt-b")),s.total&&l.forEach(a=>a.classList.add("pt-t")),o.append(...l)}return e.note&&o.append(n("span","pt-more",e.note)),r.push(o),r}function Tn(t){t.clearHover?.(),t.state.domains=t.state.home,xt(t.state)}function fr(t,e){let n=t.state.legend.items.map(o=>o.value),r=t.state.hidden.size===n.length-1&&!t.state.hidden.has(e);t.state.hidden=r?new Set:new Set(n.filter(o=>o!==e)),xt(t.state)}function mr(t,e,{x0:n,x1:r,y0:o,y1:s}){let i=t.state,l=i.layout.panels[e],a=i.panels[e].plot,c=i.domains.map(p=>({...p})),u=(p,f,d)=>{if(i.kind[p]==="category"||d-f<Zt)return;let g=a.scale(p),y=p==="x"?l.x:l.y,w=[g.invert(f-y),g.invert(d-y)].map(Number).sort((b,x)=>b-x);Nn(i,p,e).forEach(b=>c[b][p]=w)};u("x",n,r),u("y",o,s),i.domains=c,xt(i)}function Bn(t,e){t.clearHover?.();let n=t.state;n.domains=n.domains.map(r=>{let o={...r};for(let s of["x","y"]){let i=n.kind[s];if(i==="category")continue;let l=i==="log"?Math.log10:f=>f,a=i==="log"?f=>10**f:f=>f,[c,u]=r[s].map(f=>l(+f)),p=(c+u)/2;o[s]=[a(p-(u-c)/2*e),a(p+(u-c)/2*e)]}return o}),xt(n)}function xr(t,e,n,r){let o=t.state,s=o.layout.panels[e.i],i=o.panels[e.i].plot,l=e.domains.map(a=>({...a}));for(let[a,c,u,p]of[["x",e.x,n,s.x],["y",e.y,r,s.y]]){if(o.kind[a]==="category")continue;let f=i.scale(a),d=o.kind[a]==="log",g=b=>d?Math.log10(b):b,y=g(+f.invert(c-p))-g(+f.invert(u-p)),w=e.domains[e.i][a].map(b=>d?10**(g(b)+y):+b+y);Nn(o,a,e.i).forEach(b=>l[b][a]=w)}o.domains=l,o.frame||(o.frame=requestAnimationFrame(()=>(o.frame=null,xt(o))))}function Nn(t,e,n){let r=t.ns.facet?.free?.[e],o=t.grid.panels[n];return t.grid.panels.flatMap((s,i)=>r?t.grid.kind!=="grid"?i===n?[i]:[]:(e==="x"?s.col===o.col:s.row===o.row)?[i]:[]:[i])}globalThis.plotto={plot:$e,draw:On,toSVG:yn};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|