@martinomagnifico/tablechart 1.1.2 → 1.2.0

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.
@@ -1 +1 @@
1
- !function(){var t=Object.defineProperty,e=(e,n)=>{let a={};for(var o in e)t(a,o,{get:e[o],enumerable:!0});return n||t(a,Symbol.toStringTag,{value:"Module"}),a},n="tablechart",a="tablechart-value",o="tablechart-bar",r="tablechart-rule",s="tablechart-line",c="tablechart-reference",l="tablechart-head",i="tablechart-slice",u="tablechart-name",d="tablechart-legend",h="tablechart-point",f="tablechart-hole",m="tablechart-centre",b="tablechart-break",$="tablechart-sr",p="is-printing",g="tablechart-axis",w="tablechart-tick",y="tablechart-grid",M=1e3,v={selector:"[data-chart]",aspect:.38,barfill:.58,ringfill:.42,animate:!0,entrance:.5,labels:"outside",shape:"straight",legend:!1,axis:!1,grid:!1,names:!0,tooltip:"auto",tooltipparent:null,table:"never",totallabel:"Total",controls:!0,previouslabel:"Previous",nextlabel:"Next",stephint:"step of the chart",threshold:.5,replay:!1,langattribute:"data-i18n"},x="cubic-bezier(0.3, 0.3, 0.6, 1)",k=(t,e,n=1)=>({start:t,span:e,easing:t+e>=n-1e-4?x:"linear"}),N=(t,e)=>`${t}:${e}`,A=t=>Math.round(100*t)/100,S=(t,e={})=>{const n=document.createElementNS("http://www.w3.org/2000/svg",t);for(const a in e){const t=e[a];n.setAttribute(a,String("number"==typeof t?A(t):t))}return n},H=(t,e)=>[t,...e.classes].join(" "),C=(t,e)=>{const n=document.createElement("span");return n.className=t,n.inert=!0,e.appendChild(n),n},T=(t,e,n,a,o)=>{t.style.left=e/a*100+"%",t.style.top=n/o*100+"%"},L=0,O=(t,e,n,a,o,r)=>{if(!e.length)return;const s="tablechart-cut-"+ ++L,c=S("mask",{id:s,maskUnits:"userSpaceOnUse"});c.appendChild(S("rect",{x:-n,y:-a,width:3*n,height:3*a,fill:"white"}));for(const u of e)u.setAttribute("fill","black"),c.appendChild(u);let l=t.querySelector(":scope > defs");if(l||(l=S("defs"),t.prepend(l)),l.appendChild(c),o){for(const t of o)t.setAttribute("mask",`url(#${s})`);return}let i=null;for(const u of Array.from(t.childNodes))u!==l&&(r&&u instanceof Element&&u.matches(r)?(i=null,t.appendChild(u)):(i??(i=t.appendChild(S("g",{mask:`url(#${s})`}))),i.appendChild(u)))},E=0,z={create:()=>null,draw(t,e,n){const{rows:a,y:r,svg:s,breakAt:c}=n;if(null===c)return;const l="zigzag"===t.getAttribute("data-mark"),i=(t,e)=>{const n=t.sideways?t.height:t.width,a=.09*n,o=n+2*a,r=.3*o,s=.06*o;if(t.sideways){const n=t.y-a;if(!l)return[[e-r/2,n],[e+r/2,n+o]];const c=o/3;return[[e-s,n],[e+s,n+c],[e-s,n+2*c],[e+s,n+o]]}const c=t.x-a;if(!l)return[[c,e+r/2],[c+o,e-r/2]];const i=o/3;return[[c,e+s],[c+i,e-s],[c+2*i,e+s],[c+o,e-s]]},u=(t,e=!1)=>t.map(([t,e],n)=>`${0===n?"M":"L"} ${t.toFixed(1)} ${e.toFixed(1)}`).join(" ")+(e?" Z":""),d="tablechart-break-"+ ++E,h=S("mask",{id:d,maskUnits:"userSpaceOnUse"});h.appendChild(S("rect",{x:-1e3,y:-n.height,width:3e3,height:3*n.height,fill:"white"}));const f=[],m=r(c);for(const w of(t=>Array.from(t.querySelectorAll(`.${o}`)).map(t=>{const e="rect"===t.tagName?[t]:Array.from(t.querySelectorAll("rect")),n=(t,e)=>Number(t.getAttribute(e)),a=Math.min(...e.map(t=>n(t,"x"))),o=Math.min(...e.map(t=>n(t,"y"))),r=Math.max(...e.map(t=>n(t,"x")+n(t,"width"))),s=Math.max(...e.map(t=>n(t,"y")+n(t,"height"))),c=["--start","--span"].map(e=>t.style.getPropertyValue(e)&&`${e}:${t.style.getPropertyValue(e)}`).filter(Boolean).join("; ");return{row:Number(t.dataset.row),x:a,y:o,width:r-a,height:s-o,sideways:"right"===t.dataset.grow,part:c}}))(s)){const t=w.sideways?n.breakX:m;if(void 0===t)continue;if(!(w.sideways?w.x<t&&w.x+w.width>t:w.y<m&&w.y+w.height>m))continue;const[e,o]=w.sideways?[i(w,t),i(w,t+n.breakGap)]:[i(w,m-n.breakGap),i(w,m)];h.appendChild(S("path",{d:u([...e,...o.slice().reverse()],!0),fill:"black"})),f.push(e,o);const r=[N("--after",a[w.row-1]?.slot??0),w.part].filter(Boolean).join("; ");for(const a of[e,o])s.appendChild(S("path",{class:b,"data-part":"edge","data-note":n.note,d:u(a),style:r}))}if(!f.length)return;const $=Array.from(s.querySelectorAll(`.${b}`)),p=S("g",{mask:`url(#${d})`});for(const o of Array.from(s.childNodes))$.includes(o)||p.appendChild(o);const g=S("defs");g.appendChild(h),s.prepend(g,p)}},B=t=>{let e=Number.NEGATIVE_INFINITY;for(const n of t)e=Math.max(e,n);return e},_=t=>(t.split(/[.,]/)[1]||"").length,U=t=>Number.parseFloat((t.match(/-?[\d.,]+/)||["NaN"])[0].replace(",",".")),V=(t,e)=>{const n=document.createElement("span");if(n.className="tablechart-badge",n.inert=!0,t.childElementCount>0)for(const a of Array.from(t.children))n.appendChild(a.cloneNode(!0));else{n.textContent=(t.textContent||"").trim();const e=t.getAttribute("data-i18n");e&&n.setAttribute("data-i18n",e)}return e.appendChild(n),n},F=(t,e,a,o,r="%")=>{const s=t?.textContent||"",c=U(s),l=r?.5:.5*10**-_(s.match(/-?[\d.,]+/)?.[0]??""),i=!!Number.isNaN(c)||Math.abs(e-c)<=l+1e-9,u={label:a,computed:e,stated:c,agrees:i};o.checks.push(u),i||console.warn(`[${n}] An annotation reads ${c}${r}, but ${a} is ${Number(e.toFixed(2))}${r}. The chart shows your number.`)},q={create:V,draw(t,e,a){const{rows:o,cx:r,y:c,unit:i,labelHeight:u,badgeHeight:d,height:h,svg:f,after:m}=a,[b,$]=((t,e)=>{const n=(e,n)=>{const a=Number.parseInt(t.getAttribute(e)??"",10);return Number.isFinite(a)?a-1:n};return[n("data-from",0),n("data-to",e-1)]})(t,o.length),p=o[b],g=o[$];if(!p||!g)return void console.warn(`[${n}] A bracket points at a row that is not there (row ${b+1} to ${$+1}, of ${o.length}).`);const w=7*i,y=4*i,v=r(b),x=r($),k=Math.min(c(p.value),c(g.value))-u-y-.9*d,A=t=>c(t)-u-y,H=`M ${v} ${A(p.value)} L ${v} ${k} L ${x} ${k} L ${x} ${A(g.value)-w}`,C=(A(p.value)-k+Math.abs(x-v)+(A(g.value)-w-k))/i+1;f.appendChild(S("path",{class:s,"data-note":a.note,d:H,style:`--len:${C.toFixed(1)}; ${N("--after",m)}`}));const L=A(g.value);var O;f.appendChild(S("polygon",{class:l,"data-note":a.note,points:`${x},${L} ${x-.45*w},${L-w} ${x+.45*w},${L-w}`,style:N("--after",m)})),e&&(T(e,(v+x)/2,k,M,h),e.style.setProperty("--after",String(m))),F(e,(O=p.value,(g.value-O)/Math.abs(O)*100),`${p.value} to ${g.value}`,a)}},P=(t,e,n)=>{if(t.length>400)return t.map(()=>null);let a=1;for(const l of t)for(const[,,t,e]of l)a=Math.max(a,t,e);const o=new Map,r=([t,e,n,o])=>{const r=[];for(let s=Math.floor(t/a);s<=Math.floor((t+n)/a);s++)for(let t=Math.floor(e/a);t<=Math.floor((e+o)/a);t++)r.push(`${s} ${t}`);return r},s=t=>{for(const e of r(t))o.get(e)?.push(t)??o.set(e,[t])},c=t=>((t,e)=>t[0]>=e[0]&&t[1]>=e[1]&&t[0]+t[2]<=e[0]+e[2]&&t[1]+t[3]<=e[1]+e[3])(t,n)&&r(t).every(e=>!o.get(e)?.some(e=>{return a=e,(n=t)[0]<a[0]+a[2]&&a[0]<n[0]+n[2]&&n[1]<a[1]+a[3]&&a[1]<n[1]+n[3];var n,a}));return e.forEach(s),t.map(t=>{const e=t.findIndex(c);return e<0?null:(s(t[e]),e)})},j=new WeakMap,D=t=>{const e=[...t].filter(t=>!!t),n=e.map(t=>({width:t.offsetWidth,height:t.offsetHeight}));e.forEach((t,e)=>j.set(t,n[e]))},I=t=>j.get(t)??{width:t.offsetWidth,height:t.offsetHeight},R=(t,e,n)=>{const a=n.reduce((t,e)=>t+e,0);if("mean"===t)return a?e.reduce((t,e,a)=>t+e*n[a],0)/a:null;if("median"===t){const t=e.map((t,e)=>[t,n[e]]).sort((t,e)=>t[0]-e[0]);let o=0;for(const[e,[n,r]]of t.entries()){if(o+=r,Math.abs(o-a/2)<1e-9&&t[e+1])return(n+t[e+1][0])/2;if(o>a/2)return n}return null}const o=Number.parseFloat(t);return Number.isFinite(o)?o:null},W={create(t,e){if(!t.textContent?.trim())return null;const n=V(t,e);return n.dataset.kind="reference",n},draw(t,e,a){const{rows:o,cx:r,y:s,x:l,height:i,unit:u,svg:d,after:f}=a,m=o.filter(t=>!t.isTotal&&!t.missing),b=t.hasAttribute("data-name"),$=(t.getAttribute(b?"data-name":"data-value")??"").trim();let p,g,w;if(b){const t=m.map(t=>U(t.label));if("beside"===a.categories[0]?.parentElement?.dataset.place||t.some(Number.isNaN))return void console.warn(`[${n}] A reference line among the names needs names that are numbers, under columns or points.`);const e=R($,t,m.map(t=>t.value)),s=null===e?-1:t.findIndex((n,a)=>n<=e&&e<=(t[a+1]??n)),[c,l]=[m[s],m[s+1]??m[s]].map(t=>r(o.indexOf(t))),i=null===e||s<0||void 0===t[s+1]||t[s+1]===t[s]?0:(e-t[s])/(t[s+1]-t[s]);w=e,g=s<0?null:c+i*(l-c),p=!1}else{const e=Boolean(a.frame)&&"y"===t.getAttribute("data-axis"),n=a.frame?a.series.flatMap((t,e)=>t.group?[]:[e])[e?1:0]??0:0;w=R($,m.map(t=>t.cells[n]?.value??t.value),m.map(()=>1)),p=e||!l,g=null===w?null:l&&!e?l(w):s(w)}if(null===g||null===w)return void console.warn(`[${n}] A reference line needs a number, "mean" or "median", not "${$}".`);const[y,v,x,k]=a.frame?[a.frame[0],a.frame[1],a.frame[0]+a.frame[2],a.frame[1]+a.frame[3]]:[0,0,o.length>0?r(o.length-1)+r(0):M,l?i:s(0)];if(d.insertBefore(S("line",{class:c,"data-note":a.note,..."dotted"===t.getAttribute("data-line")&&{"data-line":"dotted"},...p?{x1:y,x2:x,y1:g,y2:g}:{x1:g,x2:g,y1:v,y2:k},style:N("--after",f)}),d.querySelector(`:scope > .${h}`)),e){const t=I(e).width*u,n=I(e).height*u,o=4*u,r=p?[[x-t,g-n/2,t,n],[x-t,g-n-o,t,n],[x-t,g+o,t,n]]:[v,v+n,v+2*n].flatMap(e=>[[g-t/2,e,t,n],[g+o,e,t,n],[g-o-t,e,t,n]]),[s]=P([r],a.taken,[0,0,M,i]),c=r[s??0];a.taken.push(c),T(e,c[0]+t/2,c[1]+n/2,M,i),e.style.setProperty("--after",String(f)),"mean"!==$&&"median"!==$||F(e,w,`the ${$}`,a,"")}}},G={create:V,draw(t,e,n){const{rows:a,cx:o,y:r,unit:c,labelHeight:i,height:u,svg:d,values:h,after:f}=n,m=a[0],b=a[a.length-1];if(!m||!b)return;const $=i+18*c,p=10*c,g=10*c;let w=o(0),y=r(m.value)-$,v=o(a.length-1),x=r(b.value)-$,k=0;a.forEach((t,e)=>{const n=v===w?0:(o(e)-w)/(v-w),a=y+n*(x-y)-(r(t.value)-$);a>k&&(k=a)}),y-=k,x-=k;const A=v-w,H=x-y,C=Math.hypot(A,H)||1,L=A/C,O=H/C;w-=L*p,y-=O*p,v+=L*p,x+=O*p;const E=Number.parseFloat(t.getAttribute("data-at")||"0.5");if(e){const t=w+(v-w)*E,n=y+(x-y)*E,s=I(e).width*c/2,l=n+I(e).height*c/2+8*c;let u=0;a.forEach((e,n)=>{const a=(h[n]?I(h[n]).width:0)*c/2;if(Math.abs(o(n)-t)>=s+a)return;const d=r(e.value)-7*c-i;u=Math.max(u,l-d)}),y-=u,x-=u}const z=v-L*g,B=x-O*g,_=Math.hypot(z-w,B-y)/c+1;d.appendChild(S("line",{class:s,"data-note":n.note,x1:w,y1:y,x2:z,y2:B,style:`--len:${_.toFixed(1)}; ${N("--after",f)}`}));const U=-O,V=L,q=.42*g;d.appendChild(S("polygon",{class:l,"data-note":n.note,points:[`${v},${x}`,`${z+U*q},${B+V*q}`,`${z-U*q},${B-V*q}`].join(" "),style:N("--after",f)})),e&&(T(e,w+(v-w)*E,y+(x-y)*E,M,u),e.style.setProperty("--after",String(f)));const P=Number.parseFloat(t.getAttribute("data-years")||"");!Number.isNaN(P)&&P>0&&F(e,((t,e,n)=>100*(Math.pow(e/t,1/n)-1))(m.value,b.value,P),`${m.value} to ${b.value} over ${P} years`,n)}},K=(t,e,n)=>{const a=.15,o=Math.min(.7*t/(e+(e-1)*a),n),r=e*o+(e-1)*o*a;return{size:o,gap:o*a,offset:t=>-r/2+t*o*1.15}},X=(t,e,n)=>{const a=t.series[n],o=t.series.some(t=>t.focus)&&!a.focus;return{"data-series":n+1,...o&&{"data-muted":""},style:`--n:${n}; --m:${o?1:0}; --palette:var(--tablechart-color-${n+1}); ${N("--i",e.slot)}`}},Y=(t,e,n=!1)=>{let a=0,o=0;return Array.from({length:e},(e,r)=>{const s=t.cells[r]??t.cells[0],c=s.missing?0:s.value;if(n){const t=a;return a+=c,{from:t,to:a,cell:s}}if(c<0){const t=o;return o+=c,{from:t,to:o,cell:s}}const l=a;return a+=c,{from:l,to:a,cell:s}})},Z=(t,e,n=!1)=>{const a=Y(t,e,n);return{top:Math.max(0,...a.map(t=>t.to)),bottom:Math.min(0,...a.map(t=>t.to))}},J=(t,e)=>{const{top:n,bottom:a}=Z(t,e);return n+a},Q=(t,e,n)=>{const a=e.series.some(t=>t.focus);t.style.setProperty("--n",String(n)),t.style.setProperty("--m",a&&!e.series[n].focus?"1":"0"),t.style.setProperty("--palette",`var(--tablechart-color-${n+1})`)},tt=(t,e,n,a={},r="")=>{const s={class:H(o,e),"data-kind":"bar","data-row":n+1,...a},c=N("--i",e.slot)+(r?`; transform-origin: ${r}`:""),l=S("g",{...s,"data-stack":"",style:c});return t.svg.appendChild(l),(o,r)=>{const s=void 0!==a["data-grow"]?{"data-grow":a["data-grow"]}:{};l.appendChild(S("rect",{...s,...r,class:H("tablechart-piece",e),"data-row":n+1,...X(t,e,o)}))}},et=(t,e,n)=>t.some(t=>I(t).width*n>e-6*n),nt=(t,e,n)=>e>=I(t).height*n*1.6,at=(t,e,n)=>e>=I(t).width*n*1.5,ot=(t,e,n,a,o=.7)=>{t.style.setProperty(a,"1");let r=1;for(const c of e){const{size:t,room:e}=n(c);t>e&&(r=Math.min(r,e/t))}const s=r>=o?r:0;return t.style.setProperty(a,String(s||o)),s},rt={segments:t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"})),series:!0,legend:"box",stackable:!0,totals:!0,breakable:!0,aspect:.5,minHeight:({labelHeight:t,nameHeight:e,rows:n,series:a,stacked:o})=>{const r=1.1*t,s=a>1&&!o?r*(a+.15*(a-1))/.7:r/.58;return n*Math.max(s,1.2*e)},categories:"beside",headroom:()=>0,draw(t){const{segments:e,height:n,unit:a,svg:s,values:c,categories:l,config:i,barMax:u}=t,d=t.series.length>1,h=Math.max(B(l.map(t=>I(t).width*a)),0),f=Math.min(h+10*a,420);l[0]?.parentElement?.style.setProperty("--_beside",`${((f-8*a)/M*100).toFixed(2)}%`);const m=M-4*a,b=t.stacked?Math.max(B(t.rows.map(e=>Z(e,t.series.length).top)),0)||1:Math.max(B(t.rows.flatMap(e=>e.cells.slice(0,t.series.length).map(t=>Math.abs(t.value)))),0)||1,$=t.stacked?Math.max(B(t.rows.map(e=>-Z(e,t.series.length).bottom)),0):Math.max(B(t.rows.flatMap(e=>e.cells.slice(0,t.series.length).map(t=>-t.value))),0),p=Math.max(b,t.domain?.[1]??0),g=Math.max($,-(t.domain?.[0]??0)),w=Math.max(p,t.squeeze?.hi??0)+g,y=(e,n)=>((t,e,n,a,o)=>{if(!a)return t/e*n;const{lo:r,hi:s,gap:c,share:l}=a,i=n*l,u=(n-i-o)/(r+(e-s)),d=i/(s-r);return t<=r?t*u:t<=c?r*u+(t-r)*d:t<=s?r*u+(t-r)*d+o:r*u+i+o+(t-s)*u})(Math.abs(e),w,n,t.squeeze,t.breakGap),v=n/e.length,x=t=>(t+.5)*v,k=Math.min(v*i.barfill,u),A=K(v,t.series.length,u),C=c[0]??t.totals[0],L=C?I(C).height*a*.56:0,O=Math.max(((d&&!t.stacked?A.size:k)-L)/2,5*a),E=t=>I(t).width*a,z=t=>t.length?B(t.map(E))+O+4*a:0,_=(e,n)=>(t.rows[n].cells[e]??t.rows[n].cells[0]).value,U=t.seriesValues.flatMap((t,e)=>t.map((t,n)=>({label:t,value:_(e,n)}))),V=e=>{const n=Z(t.rows[e],t.series.length);return 0===n.top&&n.bottom<0};let F=t.stacked?z(t.totals.filter((t,e)=>!V(e))):d?z(U.filter(t=>t.value>=0).map(t=>t.label)):0,q=t.stacked?z(t.totals.filter((t,e)=>V(e))):d?z(U.filter(t=>t.value<0).map(t=>t.label)):0;if(!d&&!t.stacked)for(let o=0;o<3;o++){const t=m-f-F-q,n=e.map((t,e)=>({seg:t,label:c[e]})).filter(({seg:e,label:n})=>!at(n,y(e.value,t),a)),o=z(n.filter(({seg:t})=>t.value>=0).map(({label:t})=>t)),r=z(n.filter(({seg:t})=>t.value<0).map(({label:t})=>t));if(o<=F&&r<=q)break;F=Math.max(F,o),q=Math.max(q,r)}const P=m-f-F-q,j=f+q+y(g,P),D=t=>t<0?j-y(t,P):j+y(t,P);if(t.squeeze&&(t.breakX=D(t.squeeze.gap)),t.x=D,t.stacked)return t.rows.forEach((e,o)=>{const r=Z(e,t.series.length),s=tt(t,e,o,{"data-grow":"right"},r.bottom<0?j-D(r.bottom)+"px center":""),c=x(o)-k/2;Y(e,t.series.length).forEach(({from:e,to:r,cell:l},i)=>{const u=t.seriesValues[i][o];if(u.dataset.place="none",l.missing||r===e)return;const d=Math.min(D(e),D(r)),h=Math.max(D(e),D(r));s(i,{x:d,y:c,width:Math.max(h-d,1),height:k,...r<e&&{"data-grow":"left"}}),u.dataset.place="inside",u.toggleAttribute("data-left-out",!at(u,h-d,a)||I(u).height*a>k),Q(u,t,i),T(u,(d+h)/2,x(o),M,n)});const i=t.totals[o];i&&(i.dataset.place=V(o)?"before":"after",T(i,V(o)?D(r.bottom)-O:D(r.top)+O,x(o),M,n));const u=l[o];u&&T(u,f-8*a,x(o),M,n)}),void s.appendChild(S("line",{class:r,x1:j,x2:j,y1:0,y2:n}));if(d){t.plot.dataset.grouped="";const e=t.seriesValues.flat().filter(t=>void 0===t.dataset.missing),c=ot(t.plot,e,t=>({size:I(t).height*a,room:A.size+.5*A.gap}),"--_fit");return t.rows.forEach((e,r)=>{t.series.forEach((a,l)=>{const i=e.cells[l]??e.cells[0],u=t.seriesValues[l][r];if(i.missing)return void(u.dataset.place="none");const d=D(i.value),h=i.value<0,f=x(r)+A.offset(l),m=Math.max(Math.abs(d-j),1);0!==i.value&&s.appendChild(S("rect",{class:H(o,e),"data-kind":"bar","data-row":r+1,"data-grow":h?"left":"right",x:h?j-m:j,y:f,width:m,height:A.size,...X(t,e,l)})),u.dataset.place=h?"before":"after",u.toggleAttribute("data-left-out",!c),T(u,h?d-O:d+O,f+A.size/2,M,n)});const i=l[r];i&&T(i,f-8*a,x(r),M,n)}),void s.appendChild(S("line",{class:r,x1:j,x2:j,y1:0,y2:n}))}const R=e.map((t,e)=>at(c[e],Math.abs(D(t.value)-j),a));e.forEach((e,r)=>{const i=D(e.value),u=x(r),d=e.value<0,h=Math.abs(i-j),m=Math.max(h,1);0!==e.value&&s.appendChild(S("rect",{class:H(o,e),"data-kind":e.kind,"data-row":r+1,"data-grow":d?"left":"right",x:d?j-m:j,y:u-k/2,width:m,height:k,style:N("--i",e.slot)}));const b=c[r],$=Math.max(Math.min(O,h-E(b)-6*a),6*a),p=d?1:-1;b.dataset.place=R[r]?"inside":d?"before":"after",b.dataset.kind=e.kind,T(b,R[r]?"center"===t.insideAlign?(j+i)/2:"start"===t.insideAlign?j-p*($+E(b)/2):i+p*($+E(b)/2):i-p*O,u,M,n);const g=l[r];g&&T(g,f-8*a,u,M,n)}),s.appendChild(S("line",{class:r,x1:j,x2:j,y1:0,y2:n}))}},st={segments:t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"})),series:!0,legend:"box",stackable:!0,totals:!0,breakable:!0,headroom:({labelHeight:t,badgeHeight:e,hasAnnotations:n,unit:a})=>t+4*a+(n?1.6*e:0),draw(t){const{segments:e,cx:n,y:a,barWidth:s,height:c,unit:l,svg:i,values:u,labels:d,insideAlign:h}=t,f=a(0);if(t.stacked)return t.rows.forEach((e,o)=>{const r=Z(e,t.series.length),i=tt(t,e,o,{},r.bottom<0?`center ${f-a(r.top)}px`:""),u=n(o)-s/2;Y(e,t.series.length).forEach(({from:e,to:r,cell:d},h)=>{const f=t.seriesValues[h][o];if(f.dataset.place="none",d.missing||r===e)return;const m=Math.min(a(r),a(e)),b=Math.max(a(r),a(e));i(h,{x:u,y:m,width:s,height:Math.max(b-m,1),...r<e&&{"data-grow":"down"}}),f.dataset.place="inside",f.toggleAttribute("data-left-out",!nt(f,b-m,l)||I(f).width*l>s-4*l),Q(f,t,h),T(f,n(o),(m+b)/2,M,c)});const d=t.totals[o];if(d){const t=0===r.top&&r.bottom<0;d.dataset.place=t?"below":"outside",T(d,n(o),t?a(r.bottom)+4*l:a(r.top)-4*l,M,c)}}),void i.appendChild(S("line",{class:r,x1:0,x2:M,y1:f,y2:f}));if(t.series.length>1){const e=n(1)-n(0)||2*n(0),s=K(e,t.series.length,t.barMax);t.plot.dataset.grouped="";const u=t.seriesValues.flat().filter(t=>void 0===t.dataset.missing),d=ot(t.plot,u,t=>({size:I(t).width*l,room:s.size+.5*s.gap}),"--_fit");return t.rows.forEach((e,r)=>{t.series.forEach((u,h)=>{const m=e.cells[h]??e.cells[0],b=t.seriesValues[h][r],$=n(r)+s.offset(h);if(m.missing)return void(b.dataset.place="none");const p=a(m.value),g=m.value<0,w=Math.max(Math.abs(f-p),1);0!==m.value&&i.appendChild(S("rect",{class:H(o,e),"data-kind":"bar","data-row":r+1,...g&&{"data-grow":"down"},x:$,y:g?f:f-w,width:s.size,height:w,...X(t,e,h)})),b.dataset.place=g?"below":"outside",b.toggleAttribute("data-left-out",!d),T(b,$+s.size/2,g?p+4*l:p-4*l,M,c)})}),void i.appendChild(S("line",{class:r,x1:0,x2:M,y1:f,y2:f}))}const m=et(u,s,l),b=e.map((t,e)=>"inside"===d&&!m&&!t.missing&&nt(u[e],Math.abs(f-a(t.value)),l)),$=u[0]?I(u[0]).height*l*.56:0;let p=Number.POSITIVE_INFINITY;for(const[o,r]of u.entries())b[o]&&(p=Math.min(p,(s-I(r).width*l)/2));e.forEach((t,e)=>{const r=a(t.value),d=t.value<0;if(t.missing)return T(u[e],n(e),f-4*l,M,c),void(u[e].dataset.place="outside");const m=Math.max(Math.abs(f-r),1);0!==t.value&&i.appendChild(S("rect",{class:H(o,t),"data-kind":t.kind,"data-row":e+1,...d&&{"data-grow":"down"},x:n(e)-s/2,y:d?f:f-m,width:s,height:m,style:N("--i",t.slot)}));const g=d?-1:1,w=Math.min(p,(Math.abs(f-r)-$)/2),y="center"===h?(r+f)/2:"start"===h?f-g*(w+$/2):r+g*(w+$/2),v=d?r+4*l:r-4*l;T(u[e],n(e),b[e]?y:v,M,c),u[e].dataset.place=b[e]?"inside":d?"below":"outside"}),i.appendChild(S("line",{class:r,x1:0,x2:M,y1:f,y2:f}))}},ct=0,lt={aspect:.66,centre:!0,headroom:()=>0,segments:t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"})),draw({rows:t,height:e,unit:n,labelHeight:a,svg:o,values:r,config:s,centre:c}){const l=500,u=e/2,d=(t=>t.filter(t=>!t.isTotal))(t).reduce((t,e)=>t+Math.abs(e.value),0);if(!d)return;const h=1.2*a+10*n,f=Math.max(Math.min(M,e)/2-h,10),m=f*s.ringfill,b=f-m/2,$=2*Math.PI*b,p=[];let g=0,w=0,y=0;if(t.forEach((t,s)=>{const c=r[s];if(t.isTotal)return void(c.dataset.place="none");const h=Math.abs(t.value)/d,v=k(y,h),x=`--share:${h.toFixed(4)}; --start:${v.start.toFixed(4)}; --span:${v.span.toFixed(4)};`,A=h*$,C=g/$*2*Math.PI-Math.PI/2;p.push(C),o.appendChild(S("circle",{class:H(i,t),"data-slice":w+1,"data-row":s+1,cx:l,cy:u,r:b,"stroke-width":m,transform:`rotate(-90 500 ${u})`,"stroke-dasharray":`${A.toFixed(1)} ${($-A).toFixed(1)}`,"stroke-dashoffset":(-g).toFixed(1),style:`--n:${w}; --palette:var(--tablechart-color-${w+1}); --arc:${A.toFixed(1)}; --circ:${$.toFixed(1)}; ${x} --ease:${v.easing}; ${N("--i",t.slot)}`}));const L=C+A/$*Math.PI,O=Math.cos(L),E=Math.sin(L);o.appendChild(S("line",{class:"tablechart-leader",x1:l+O*(f+2*n),y1:u+E*(f+2*n),x2:l+O*(f+7*n),y2:u+E*(f+7*n),"data-row":s+1,style:`${x} ${N("--i",t.slot)}`})),c.style.setProperty("--start",v.start.toFixed(4)),c.style.setProperty("--span",v.span.toFixed(4));const z=f+9*n,B=I(c).width*n/2;T(c,l+O*(z+Math.abs(O)*B),u+E*(z+Math.abs(E)*a*.7),M,e),c.dataset.place="around",g+=A,y+=h,w+=1}),p.length>1){const t=b-m/2-1,n=b+m/2+1,a="tablechart-slices-"+ ++ct,r=S("mask",{id:a,maskUnits:"userSpaceOnUse"});r.appendChild(S("rect",{x:0,y:0,width:M,height:e,fill:"white"}));for(const e of p)r.appendChild(S("line",{class:"tablechart-divide",x1:l+Math.cos(e)*t,y1:u+Math.sin(e)*t,x2:l+Math.cos(e)*n,y2:u+Math.sin(e)*n}));const s=S("g",{mask:`url(#${a})`});for(const e of Array.from(o.querySelectorAll(`.${i}`)))s.appendChild(e);const c=S("defs");c.appendChild(r),o.prepend(c,s)}c&&T(c,l,u,M,e)}},it=["circle","square","diamond"],ut=(t,e)=>{const n=t[e]?.marker?.toLowerCase().split(/\s+/)??[],a=it.find(t=>n.includes(t));return{shape:a??it[Math.floor(e/2)%it.length],open:n.includes("open")||!n.includes("filled")&&!a&&e%2==1}},dt=(t,e,n,a,o={})=>{if("square"===t){const t=.88*a;return S("rect",{x:e-t,y:n-t,width:2*t,height:2*t,...o})}if("diamond"===t){const t=1.2*a;return S("polygon",{points:`${e},${n-t} ${e+t},${n} ${e},${n+t} ${e-t},${n}`,...o})}if("triangle"===t){const t=1.3*a;return S("polygon",{points:`${e},${n-t} ${e+.87*t},${n+t/2} ${e-.87*t},${n+t/2}`,...o})}return S("circle",{cx:e,cy:n,r:a,...o})},ht=t=>Number(t.toFixed(2));function ft(t,e,n){const a=new Array(t).fill(0);let o=[];const r=()=>{(function(t,e){const n=t.length;if(n<2)return t.map(()=>0);const a=n=>(e[n+1]-e[n])/(t[n+1]-t[n]||1),o=new Array(n).fill(0);for(let s=1;s<n-1;s++){const e=a(s-1),n=a(s);if(e*n<=0)continue;const r=t[s]-t[s-1],c=t[s+1]-t[s],l=(e*c+n*r)/(r+c||1),i=Math.min(2*Math.abs(e),2*Math.abs(n),Math.abs(l));o[s]=Math.sign(e)*i||0}if(2===n)return o[0]=a(0),o[1]=a(0),o;const r=(n,a,o)=>{const r=t[a]-t[n];return r?((e[a]-e[n])/r*3-o)/2:o};return o[0]=r(0,1,o[1]),o[n-1]=r(n-2,n-1,o[n-2]),o})(o.map(t=>n(t)[0]),o.map(t=>n(t)[1])).forEach((t,e)=>{a[o[e]]=t}),o=[]};for(let s=0;s<t;s++)e(s)?r():o.push(s);return r(),a}var mt,bt,$t=t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"})),pt=t=>({segments:$t,series:!0,stackable:!0,running:!0,swatch:t?"box":void 0,headroom:({labelHeight:t,unit:e})=>1.6*t+6*e,footroom:({labelHeight:e,unit:n,series:a,focused:o,stacked:r})=>t||r||2!==a||o?0:e+7*n,draw(e){const{rows:n,series:a,seriesValues:o,names:s,cx:c,y:l,height:i,unit:u,labelHeight:d,svg:m,stacked:b}=e,$="step"===e.shape,p="smooth"===e.shape,g=a.length>1,w=a.some(t=>t.focus),y=n.length-1,v=l(0),x=n.length>1?c(1)-c(0):2*c(0);m.style.setProperty("--_base",`${ht(v)}px`);const k=(t,e)=>n[e]?.cells[t]??n[e]?.cells[0],N=(t,e)=>!k(t,e)||!!k(t,e)?.missing,A=n.map(t=>b?Y(t,a.length,!0):null),H=(t,e)=>A[e]?.[t].to??k(t,e)?.value??0,C=(t,e)=>A[e]?.[t].from??0,L=(t,e)=>[c(e),l(H(t,e))],E=a.map((t,e)=>{if(!g)return{attrs:{},ink:""};const n=w&&!t.focus;return{attrs:{"data-series":e+1,...n&&{"data-muted":""}},ink:`--n:${e}; --m:${n?1:0}; --palette:var(--tablechart-color-${e+1}); `}}),z=Math.min(y,6);e.plot.style.setProperty("--count",String(z+1));const B=y>0?z/($?n.length:y):1,_=t=>t*B,U=t=>`--i:${ht(_(t))}`,V=t=>{const e=[];let a=-1;return n.forEach((n,o)=>{N(t,o)||(a<0&&(a=o),(o===y||N(t,o+1))&&(($||o>a)&&e.push([a,o]),a=-1))}),e},F=(t,e)=>`--i:${ht(_(t)+1)}; --d:${ht(_($?e+1:e)-_(t))}`,q=(t,e)=>({"data-from":t+1,"data-to":e+1,...$&&{"data-flat":""}}),j=p?a.map((t,e)=>ft(n.length,t=>N(e,t),t=>L(e,t))):[],D=p&&t?a.map((t,e)=>ft(n.length,t=>N(e,t),t=>[c(t),l(C(e,t))])):[],R=(t,e,n)=>{const a=[];return t.forEach(([o,r],s)=>{$?(a.push(`H${ht(o+n*x/2)}`),s<t.length-1&&a.push(`V${ht(t[s+1][1])}`)):s>0&&a.push(e?function(t,e,n,a){const[o,r]=function(t,e,n,a){const o=(e[0]-t[0])/3;return[[t[0]+o,t[1]+n*o],[e[0]-o,e[1]-a*o]]}(t,e,n,a),s=([t,e])=>`${ht(t)},${ht(e)}`;return`C${s(o)} ${s(r)} ${s(e)}`}(t[s-1],[o,r],e[s-1],e[s]):`L${ht(o)},${ht(r)}`)}),a},W=(t,e,a,o)=>n.slice(e,a+1).map((n,a)=>[c(e+a),l(o(t,e+a))]),G=(t,e,n,a)=>p?t[e].slice(n,a+1):null,K=t=>c(t)-($?x/2:0),X=t=>c(t)+($?x/2:0);t&&a.forEach((t,e)=>(t=>{const e=S("g",{class:"tablechart-area",...E[t].attrs,...b&&{"data-stacked":""},style:E[t].ink}),n=V(t),a=S("g",{class:"tablechart-area-fill",style:`--rows:${ht(z+1)}; ${n.length?F(...n[0]):""}`});e.appendChild(a);for(const[o,r]of n){const e=W(t,o,r,H),n=W(t,o,r,C),s=G(D,t,o,r)?.reverse()??null,c=[`M${ht(K(o))},${ht(n[0][1])}`,`L${ht(K(o))},${ht(e[0][1])}`,...R(e,G(j,t,o,r),1),`L${ht(X(r))},${ht(n[n.length-1][1])}`,...R(n.reverse(),s,-1),"Z"].join(" ");a.appendChild(S("path",{d:c,...q(o,r),style:F(o,r)}))}m.appendChild(e)})(e)),a.forEach((t,e)=>(t=>{const e=a[t];for(const[n,a]of V(t)){const o=W(t,n,a,H),r=[`M${ht(K(n))},${ht(o[0][1])}`,...R(o,G(j,t,n,a),1)].join(" ");m.appendChild(S("path",{class:"tablechart-series",...E[t].attrs,d:r,...e.line&&{"data-line":e.line},...q(n,a),style:`${E[t].ink}${F(n,a)}`}))}})(e)),$||(()=>{const t=a.map((t,e)=>g?ut(a,e):{shape:"circle",open:!1}),e=(e,n,a)=>{const[o,r]=L(e,n);return dt(t[e].shape,o,r,4*u,{...a,style:`${a.style??""}${s=r,`--rise:${ht(v-s)}px; `}${U(n)}`});var s},o=t=>n.map((t,e)=>e).filter(e=>!N(t,e)),r=a.flatMap((n,a)=>t[a].open?o(a).map(t=>e(a,t,{class:f,"data-row":t+1,...g&&{"data-series":a+1}})):[]);O(m,r,M,i),a.forEach((n,a)=>{for(const r of o(a))m.appendChild(e(a,r,{class:h,...E[a].attrs,"data-marker":t[a].shape,...t[a].open&&{"data-open":""},"data-row":r+1,style:E[a].ink}))})})();const Z=(t,e)=>{let n=e;for(;n<y&&!N(t,n+1)&&k(t,n+1)?.value===k(t,e)?.value;)n++;return n},J=(e,n)=>{const o=k(e,n);if(!o||o.missing)return"none";if($&&n>0&&!N(e,n-1)&&k(e,n-1)?.value===o.value)return"none";if(w&&!a[e].focus)return"none";if(b)return"middle";const r=o.value<0?"below":"above";if(!g||w||a.length>2)return r;const s=k(1-e,n);return!s||s.missing?r:o.value>s.value||o.value===s.value&&0===e||t&&o.value>=0&&L(e,n)[1]+7*u+d>v?"above":"below"},Q=g&&!w&&a.length>2&&!b&&!$,tt=new Map;if(Q){const t=n.flatMap((t,e)=>a.map((t,n)=>({s:n,i:e,value:k(n,e)?.value??0}))).filter(({s:t,i:e})=>"none"!==J(t,e)).sort((t,e)=>t.i-e.i||e.value-t.value||t.s-e.s),e=t=>t<0?["below","above"]:["above","below"],r=t.map(({s:t,i:n,value:a})=>{const r=I(o[t][n]).width*u,[s,c]=L(t,n);return e(a).map(t=>[s-r/2,"above"===t?c-7*u-d:c+7*u,r,d])}),s=a.flatMap((t,e)=>n.flatMap((t,n)=>{if(N(e,n))return[];const[a,o]=L(e,n);return[[a-4*u,o-4*u,8*u,8*u]]})),l=P(r,s,[0,0,c(y)+c(0),i]);t.forEach(({s:t,i:n,value:a},r)=>tt.set(o[t][n],null===l[r]?null:e(a)[l[r]]))}o.forEach((t,e)=>{t.forEach((t,n)=>{t.style.setProperty("--i",String(ht($?(_(n)+_(n+1))/2:_(n))));const a=tt.get(t)??J(e,n);if(t.dataset.place="above"===a?"outside":a,t.toggleAttribute("data-left-out","none"!==a&&((t,e)=>Q?null===tt.get(o[t][e]):!(!b&&!$)&&(I(o[t][e]).width*u>($?Z(t,e)-e+1:1)*x-4*u||!!(b&&t>0&&H(t,e)<C(t,e))||b&&Math.abs(l(C(t,e))-l(H(t,e)))<1.2*d))(e,n)),$&&"none"!==a?t.dataset.rowEnd=String(Z(e,n)+1):delete t.dataset.rowEnd,"none"===a)return;const r=I(t).width*u/2+4*u;let s=c(n);$?s=(c(n)+c(Z(e,n)))/2:"middle"===a&&0===n?s+=r:"middle"===a&&n===y&&(s-=r);const h=l(H(e,n)),f={middle:(l(C(e,n))-h)/2,above:-7*u,below:7*u};T(t,s,h+f[a],M,i)})});const et=s.map((t,e)=>{let n=y;for(;n>0&&N(e,n);)n--;const[a,o]=L(e,n);return{name:t,x:($?a+x/2:a)+10*u,y:b?(o+l(C(e,n)))/2:o}}),nt=(s[0]?I(s[0]).height:0)*u;for(const t of((t,e)=>(t.sort((t,e)=>t.y-e.y),t.forEach((n,a)=>{const o=t[a-1];o&&n.y<o.y+e&&(n.y=o.y+e)}),t))(et,nt))T(t.name,t.x,t.y,M,i);const at=n.some(t=>t.cells.some(t=>!t.missing&&t.value<0)),ot=t||b||2!==a.length||w||at?v:i-2*u;m.appendChild(S("line",{class:r,x1:0,x2:c(y)+c(0),y1:ot,y2:ot}))}}),gt=pt(!1),wt=pt(!0),yt=new Set,Mt={segments:t=>{let e=0,a=!1;return t.map(t=>{if(t.isTotal)return a&&((t,e)=>{if(Math.abs(t-e)<=Math.abs(e)/100)return;const a=`[${n}] A total reads ${t}, but the steps before it add up to ${Number(e.toFixed(6))}. The chart shows your number.`;yt.has(a)||(yt.add(a),console.warn(a))})(t.value,e),a=!1,e=t.value,{...t,from:0,to:t.value,kind:"total"};const o=e;return e+=t.value,a=!0,{...t,from:o,to:e,kind:t.value>=0?"up":"down"}})},breakable:!0,headroom:({labelHeight:t,badgeHeight:e,hasAnnotations:n,unit:a})=>t+6*a+(n?1.6*e:0),draw({segments:t,cx:e,y:n,barWidth:a,height:s,unit:c,svg:l,values:i,breakAt:u,insideAlign:d}){const h=n(0),f=et(i,a,c),m=d??"center",b=t.map((e,a)=>{const o=n(Math.max(e.from,e.to)),r=Math.abs(n(e.from)-n(e.to)),s=null!==u&&Math.min(e.from,e.to)<u&&Math.max(e.from,e.to)>u,l="total"===e.kind&&a>0&&a===t.length-1;return{top:o,length:r,down:"down"===e.kind||"total"===e.kind&&(l?e.to>=0:e.to<0),inside:!s&&!f&&nt(i[a],r,c)}}),$=i[0]?I(i[0]).height*c*.56:0;let p=Number.POSITIVE_INFINITY;for(const[o,r]of b.entries())r.inside&&(p=Math.min(p,(a-I(i[o]).width*c)/2));const g=t.length,w=(t,e,n=!1)=>`--start:${(t/g).toFixed(4)}; --span:${(e/g).toFixed(4)}; --ease:${n?x:"linear"};`;t.forEach((o,r)=>{const s=t[r+1];if(!s)return;const c=n(o.to),i=e(r)+a/2,u=e(r+1)-a/2;l.appendChild(S("line",{class:"tablechart-connector",x1:i,x2:u,y1:c,y2:c,"data-row":r+2,style:`${N("--i",s.slot)}; ${w(r+1,1/3)}`}))}),t.forEach((n,r)=>{const{top:u,length:d,down:h,inside:f}=b[r];l.appendChild(S("rect",{class:H(o,n),"data-kind":n.kind,"data-row":r+1,"data-grow":h?"down":"up",x:e(r)-a/2,y:u,width:a,height:Math.max(d,1),style:`${N("--i",n.slot)}; ${w(r,1,r===t.length-1)}`}));const y=i[r];y.style.setProperty("--start",(r/g).toFixed(4)),y.style.setProperty("--span",(1/g).toFixed(4));const v=Math.min(p,(d-$)/2),x="center"===m?u+d/2:"end"===m!==h?u+v+$/2:u+d-v-$/2;y.dataset.place=f?"inside":"outside",y.dataset.kind=n.kind;const k=f?x:"down"===n.kind?u+d+I(y).height*c+3*c:u-3*c;T(y,e(r),k,M,s)}),l.appendChild(S("line",{class:r,x1:0,x2:M,y1:h,y2:h}))}},vt={enabled:!1,log(...t){vt.enabled&&console.log(`[${n}]`,...t)},timed(t,e,a){if(!vt.enabled)return a();const o=performance.now(),r=a(),s=performance.now()-o,c=e.querySelectorAll("tbody tr").length;return s>50?console.warn(`[${n}] ${t} took ${s.toFixed(1)} ms for ${c} rows, more than 50 ms.`,e):vt.log(`${t} took ${s.toFixed(1)} ms for ${c} rows.`,e),r}},xt=t=>{const e=(t?.textContent||"").trim(),n=e.match(/^(.*?)(-?\d+(?:[.,]\d+)?)(.*)$/);return{raw:e,number:n?.[2]??"",prefix:n?.[1]??"",suffix:n?.[3]??"",missing:!n,value:n?Number.parseFloat(n[2].replace(",",".")):0}},kt=t=>Array.from(t.querySelector("thead tr:last-child")?.children??[]).slice(1),Nt=t=>Number(t.toPrecision(12)),At=(t,e)=>{const n=t/Math.max(1,e)||1,a=10**Math.floor(Math.log10(n)),o=n/a;return Nt((o<1.42?1:o<3.17?2:o<7.08?5:10)*a)},St=(t,e,n)=>{const a=[];for(let o=Math.ceil(t/n-1e-9);o*n<=e+1e-9*n;o++)a.push(Nt(o*n));return a},Ht=(t,e=t)=>{do{const e=Math.round(t/10**Math.floor(Math.log10(t)+1e-9));t=Nt(t*(2===e?2.5:2))}while(Math.abs(t/e-Math.round(t/e))>1e-9);return t},Ct=t=>{const e=(t??"").trim().split(/\s+/).map(Number.parseFloat);return e.length>1&&e.every(Number.isFinite)?e.sort((t,e)=>t-e):null},Tt=(t,e)=>{let{step:n,ticks:a}=t;for(;n&&a.length>2&&!e(a);)n=Ht(n,t.step),a=St(t.min,t.max,n);return{...t,step:n,ticks:a}},Lt=["axis-break","trend","bracket"],Ot=t=>{const e=t.plan;if(!e)return;const n=e=>null===e||t.step-e>=1;for(const a of t.figure.querySelectorAll("[data-from]")){const t=Number(a.dataset.from)-1,o=Number(a.dataset.to)-1,r=a.closest("[data-series]")?.dataset.series,s=r?Number(r)-1:0,c=e.series[s],l=t=>e.cells[t]?.[s]?.step??e.rows[t]?.step??null;let i=t-1;if(c&&null!==c.step)i=n(c.step)?o:t-1;else for(;i<o&&n(l(i+1));)i++;const u=a.hasAttribute("data-flat")?(i-t+1)/(o-t+1):o>t?Math.max(0,i-t)/(o-t):0;a.style.setProperty("--reveal",String(u))}},Et=(t,e,n=!1)=>{const a=t.plan;if(!a)return;const o=Math.min(Math.max(Math.round(e),0),a.count),r=o!==t.step;t.step=o,t.figure.style.setProperty("--_step",String(o)),Ot(t);const[s,c]=t.controls?.querySelectorAll("button")??[];s&&(s.disabled=0===o),c&&(c.disabled=o===a.count),r&&!n&&t.figure.dispatchEvent(new CustomEvent("tablechart:step",{bubbles:!0,detail:{step:o,steps:a.count}}))},zt="tablechart-tooltip",Bt=["--tablechart-surface","--tablechart-tooltip-surface","--tablechart-tooltip-color","--tablechart-tooltip-border","--tablechart-tooltip-radius","--tablechart-tooltip-padding","--tablechart-tooltip-shadow"],_t=null,Ut=null,Vt=null,Ft=0,qt=()=>{clearTimeout(Ft),_t&&Ut&&(_t.hidden=!0,Ut=null,Vt=null)},Pt=!1,jt=!0,Dt=NaN,It=NaN,Rt=!1,Wt=(t,e)=>e/Number.parseFloat(getComputedStyle(t).width)||1,Gt=()=>{clearTimeout(Ft),Ft=window.setTimeout(qt,120)},Kt=(t,e)=>{const n=e?e.style.getPropertyValue("--step"):"x";return""===n||Number(n)<t.step},Xt=(t,e)=>{const n=t.svg.querySelector(`[data-series="${e+1}"]:not(.tablechart-hole)`);if(!n)return;const a=getComputedStyle(n);return a.fill&&"none"!==a.fill?a.fill:a.stroke},Yt=(t,e,n)=>{const a=t.series.length>1,o=[];for(const[s,c]of t.seriesValues.entries()){if(!Kt(t,c[e]))continue;const n=a?t.figure.querySelector(`.tablechart-name[data-series="${s+1}"]`):null;o.push({name:a?n?.textContent??t.series[s].name:"",value:c[e].textContent??"",colour:a?Xt(t,s):void 0,sample:n?{marker:n.dataset.marker??null,open:n.hasAttribute("data-open"),line:n.dataset.line??null,box:"box"===n.dataset.swatch}:void 0})}const r=t.totals[e];return o.length>1&&Kt(t,r)&&o.push({name:n.totallabel,value:r.textContent??""}),o},Zt=(t,e,n)=>{if(clearTimeout(Ft),Ut===t&&Vt===e)return;const a=(t.type.tooltip??Yt)(t,e,n);if(!a.length)return qt();Ut&&Ut!==t&&qt(),_t??(_t=(()=>{const t=document.createElement("div");return t.className=zt,t.setAttribute("aria-hidden","true"),t.hidden=!0,mt=document.createElement("div"),(bt=document.createElement("div")).className=`${zt}-arrow`,t.append(mt,bt),document.body.append(t),t.addEventListener("pointerenter",()=>clearTimeout(Ft)),t.addEventListener("pointerleave",t=>"mouse"===t.pointerType&&Gt()),document.addEventListener("pointerdown",e=>{const n=e.target;!Ut||Ut.plot.contains(n)||t.contains(n)||qt()}),window.addEventListener("resize",qt),t})());const o=(t,e,n,a=!1,o)=>{const r=document.createElement("div");if(r.className=`${zt}-line`,n){const t=document.createElement("span");t.className=`${zt}-key`,t.style.background=n,o?.box?t.dataset.sample="box":o&&(t.dataset.sample="line",o.marker&&(t.dataset.marker=o.marker),o.line&&(t.dataset.line=o.line),t.toggleAttribute("data-open",o.open)),r.append(t)}const s=document.createElement("span");if(s.className=`${zt}-${a?"title":"name"}`,s.textContent=t,r.append(s),e){t&&s.append(":");const n=document.createElement("span");n.className=`${zt}-value`,n.textContent=e,r.append(n)}return r},r=t.categories[e]?.textContent??t.rows[e].label,s=1===a.length&&!a[0].name,c=a.every(t=>t.name&&!t.value);mt.replaceChildren(...c?[]:[o(r,s?a[0].value:"",void 0,!0)],...s?[]:a.map(({name:t,value:e,colour:n,sample:a})=>o(t,e,n,!1,a)));const l=getComputedStyle(t.figure);for(const f of Bt){const t=l.getPropertyValue(f).trim();t?_t.style.setProperty(f,t):_t.style.removeProperty(f)}_t.style.setProperty("--_color",l.color),_t.style.colorScheme=l.colorScheme,_t.style.fontFamily=l.fontFamily;const i=(t=>{const e=t.tooltipparent;return("string"==typeof e?document.querySelector(e):e)??document.body})(n);_t.parentElement!==i&&i.append(_t),Ut=t,Vt=e,_t.hidden=!1,_t.style.left="0px",_t.style.top="0px";const u=_t.getBoundingClientRect(),d={x:u.left,y:u.top,scale:Wt(_t,u.width)},h=Wt(t.plot,t.plot.getBoundingClientRect().width);_t.style.fontSize=Number.parseFloat(l.fontSize)*h/d.scale+"px",((t,e,n,a={x:0,y:0,scale:1},o=2,r=8,s=12)=>{const c=t.getBoundingClientRect(),l=c.width,i=c.height,u=Number.parseFloat(getComputedStyle(t).borderLeftWidth)||0,d=e.getBoundingClientRect().height/2+(o-u)*a.scale,h=s*a.scale,{clientWidth:f,clientHeight:m}=document.documentElement,b=n.top-r,$=m-n.bottom-r,p=i+d<=b||!(i+d<=$)&&b>=$,g=p?n.top-d-i:n.bottom+d,w=n.left+n.width/2,y=Math.max(r,Math.min(w-l/2,f-l-r));t.style.left=(y-a.x)/a.scale+"px",t.style.top=(Math.max(r,Math.min(g,m-i-r))-a.y)/a.scale+"px",t.dataset.side=p?"top":"bottom",e.style.left=Math.max(h,Math.min(w-y,l-h))/a.scale-u+"px"})(_t,bt,((t,e)=>{if(t.type.centre&&t.values[e])return t.values[e].getBoundingClientRect();const n=t.svg.querySelectorAll(`[data-row="${e+1}"]:not(.tablechart-connector, .tablechart-leader)`);let a=null;for(const i of n){const t=i.getBoundingClientRect();(t.width||t.height)&&(a=a?new DOMRect(Math.min(a.left,t.left),Math.min(a.top,t.top),Math.max(a.right,t.right)-Math.min(a.left,t.left),Math.max(a.bottom,t.bottom)-Math.min(a.top,t.top)):t)}if(a)return a;const o=t.plot.getBoundingClientRect(),[r,s,c,l]=t.rowBox?.(e)??[0,0,100,100];return new DOMRect(o.left+o.width*r/100,o.top+o.height*s/100,o.width*c/100,o.height*l/100)})(t,e),d)},Jt=t=>{Ut===t&&qt()},Qt={area:wt,bar:rt,column:st,donut:lt,line:gt,waterfall:Mt},te={"axis-break":z,trend:G,bracket:q,reference:W},ee=Object.keys(te),ne=t=>{let e="";for(let n=t.previousSibling;n&&(e=(n.textContent??"")+e,!e.trim());n=n.previousSibling);return e.trim()},ae=["straight","step","smooth"],oe=(t,e,n,a,o)=>{const r=e===a,[s,c,l]=r?[Math.min(t,n),Math.max(t,n),e]:[Math.min(e,a),Math.max(e,a),t],i=o.filter(([t,e,n,a])=>r?e<=l&&l<=e+a:t<=l&&l<=t+n).map(([t,e,n,a])=>r?[t,t+n]:[e,e+a]).sort((t,e)=>t[0]-e[0]),u=[];let d=s;for(const[h,f]of i)h>d&&u.push([d,Math.min(h,c)]),d=Math.max(d,f);return d<c&&u.push([d,c]),u.map(([t,e])=>r?`M${A(t)},${A(l)}H${A(e)}`:`M${A(l)},${A(t)}V${A(e)}`).join("")},re=(t,e)=>{const[n,a,o,r]=["x1","y1","x2","y2"].map(e=>Number(t.getAttribute(e))),s=S("path",{d:oe(n,a,o,r,e)});for(const{name:c,value:l}of Array.from(t.attributes))/^[xy][12]$/.test(c)||s.setAttribute(c,l);t.replaceWith(s)},se=(t,[e,n,a,o])=>t.map(([t,r,s,c])=>r===c?n<=r&&r<=n+o&&Math.max(t,e)<Math.min(s,e+a)?`M${A(Math.max(t,e))},${A(r)}H${A(Math.min(s,e+a))}`:"":e<=t&&t<=e+a&&Math.max(r,n)<Math.min(c,n+o)?`M${A(t)},${A(Math.max(r,n))}V${A(Math.min(c,n+o))}`:"").join(""),ce=(t,e,n)=>{const a=t.getAttribute(e);return null===a?n:"false"!==a},le=(t,e)=>Boolean(e.animate)&&"false"!==t.getAttribute("data-chart-animate"),ie=(t,e)=>{const n=t.dataset.chartShape;return n&&ae.includes(n)?n:ae.includes(e.shape)?e.shape:"straight"},ue=0,de=(t,e,o=null)=>{const r=o??(t.getAttribute("data-chart")||"column"),s=Qt[r];if(!s)return console.warn(`[${n}] Unknown chart type "${r}". Known types: ${Object.keys(Qt).join(", ")}.`),t.setAttribute("data-chart-empty",""),null;const c=((t,e="data-i18n")=>Array.from(t.querySelectorAll("tbody tr")).map((t,n)=>{const a=t.querySelector("th"),o=Array.from(t.querySelectorAll("td")).map(xt);return o.length||o.push(xt(null)),{...o[0],label:(a?.textContent||"").trim(),key:e&&a?.getAttribute(e)||null,cells:o,classes:Array.from(t.classList),isTotal:"total"===t.getAttribute("data-kind"),slot:n}}))(t,e.langattribute);if(!c.length)return console.warn(t.querySelector("table")?`[${n}] A chart has no rows in its table, so there is nothing to draw.`:`[${n}] A chart has no table, so there is nothing to draw.`,t),t.setAttribute("data-chart-empty",""),null;(t=>{const e=t.querySelector(":scope > figcaption");if(!e)return;(t=>{for(const e of t.querySelectorAll("br")){if(e.previousElementSibling?.classList.contains("tablechart-sr"))continue;if(/[.!?:;,…]$/.test(ne(e)))continue;const t=document.createElement("span");t.className=$,t.textContent=". ",e.before(t)}})(e);const n=t=>t.hasAttribute("aria-label")||t.hasAttribute("aria-labelledby"),a=t=>{e.id||(e.id="tablechart-caption-"+ ++ue),t.setAttribute("aria-labelledby",e.id)};"FIGURE"!==t.tagName||n(t)||a(t);const o=t.querySelector("table");!o||n(o)||o.querySelector(":scope > caption")||a(o)})(t);let l=((t,e,n="data-i18n")=>{const a=kt(t),o=Math.max(1,B(e.map(t=>t.cells.length)));return Array.from({length:o},(t,e)=>{const o=a[e];return{name:(o?.textContent||"").trim(),key:n&&o?.getAttribute(n)||null,focus:"focus"===o?.getAttribute("data-kind"),marker:o?.getAttribute("data-marker")??null,line:(r=o?.getAttribute("data-line"),"dashed"===r||"dotted"===r?r:null),group:!!o?.hasAttribute("data-group")};var r})})(t,c,e.langattribute);l.length>1&&!s.series&&!s.columns&&(console.warn(`[${n}] A ${r} chart uses only the first of its ${l.length} value columns.`),l=l.slice(0,1));const i=l.length>1;i&&t.style.setProperty("--_series-count",String(l.length));const h=t.hasAttribute("data-chart-stack");h&&!s.stackable&&console.warn(`[${n}] A ${r} chart cannot be stacked.`);const f=h&&!!s.stackable&&i,b=document.createElement("div");b.className="tablechart-plot",b.setAttribute("aria-hidden","true");const p=S("svg",{role:"presentation",focusable:"false"});b.appendChild(p),t.appendChild(b);const y=s.centre?c.filter(t=>!t.isTotal):c,M=Math.max(0,B(y.flatMap(t=>t.cells.slice(0,l.length).map(t=>_(t.number))))),v=l.map((t,e)=>Math.max(0,B(c.map(t=>_(t.cells[e]?.number??""))))),x=document.createElement("div");x.className="tablechart-values",b.appendChild(x);const k=l.map((t,e)=>c.map((t,n)=>{const o=t.cells[e]??t.cells[0],r=C(a,x);return r.classList.add(...t.classes),r.dataset.value=String(o.value),o.prefix&&(r.dataset.prefix=o.prefix),o.suffix&&(r.dataset.suffix=o.suffix),o.missing&&(r.dataset.missing=o.raw),i&&(r.dataset.series=String(e+1)),s.columns&&(r.dataset.decimals=String(v[e])),r.dataset.row=String(n+1),r.style.setProperty("--i",String(t.slot)),r})),N=k[0],A=f&&s.totals?c.map((t,e)=>{const n=C(a,x);n.classList.add(...t.classes),n.dataset.kind="total",n.dataset.row=String(e+1),n.dataset.value=String(J(t,l.length));const o=t.cells[0];return o.prefix&&(n.dataset.prefix=o.prefix),o.suffix&&(n.dataset.suffix=o.suffix),n.style.setProperty("--i",String(t.slot)),n}):[],H=c[c.length-1],T=l.some(t=>t.focus),L=t.getAttribute("data-chart-legend"),O=i&&!s.columns&&(null===L?e.legend||void 0!==s.legend:"false"!==L)?document.createElement("div"):null;O&&(O.className=d,O.setAttribute("aria-hidden","true"),O.inert=!0);const E=i&&!s.columns?l.map((n,a)=>{const o=C(u,O??b);O&&(o.dataset.place="legend");const r=s.legend??s.swatch;if(r&&(o.dataset.swatch=r),o.textContent=n.name,!r&&"step"!==ie(t,e)){const t=ut(l,a);o.dataset.marker=t.shape,o.toggleAttribute("data-open",t.open)}return n.line&&!r&&(o.dataset.line=n.line),n.key&&e.langattribute&&o.setAttribute(e.langattribute,n.key),o.dataset.series=String(a+1),o.style.setProperty("--n",String(a)),o.style.setProperty("--palette",`var(--tablechart-color-${a+1})`),o.style.setProperty("--m",T&&!n.focus?"1":"0"),o.style.setProperty("--i",String(H.slot)),o}):[],z=s.centre?C(m,b):null;if(z){const t=c.find(t=>t.isTotal),e=t?t.value:c.reduce((t,e)=>t+Math.abs(e.value),0);z.dataset.value=String(e),t&&(z.dataset.decimals=String(_(t.number)))}const U=z&&!c.some(t=>t.isTotal)?((t,e,n)=>{const a=t.querySelector("table");if(!a)return null;const o=a.querySelector("tfoot [data-chart-total]");if(o)return o.dataset.value=e.dataset.value??"0",o;const r=(a.tFoot??a.createTFoot()).insertRow(),s=document.createElement("th");s.scope="row",s.textContent=n.totallabel;const c=t.getAttribute("data-chart-keys");c&&n.langattribute&&s.setAttribute(n.langattribute,`${c}-total`);const l=r.insertCell();return l.setAttribute("data-chart-total",""),l.dataset.value=e.dataset.value??"0",r.prepend(s),l})(t,z,e):null,V="beside"===s.categories,F=document.createElement("div");F.className="tablechart-categories",F.setAttribute("aria-hidden","true"),F.inert=!0,V?F.dataset.place="beside":s.centre&&(F.dataset.place="key"),F.style.setProperty("--_columns",String(c.length));let q=0;for(const[n,a]of c.entries()){const t=document.createElement("span");t.classList.add(...a.classes),t.textContent=a.label,a.key&&e.langattribute&&t.setAttribute(e.langattribute,a.key),s.centre&&(t.dataset.kind=a.isTotal?"total":"slice",a.isTotal||(t.dataset.slice=String(q+1),t.style.setProperty("--n",String(q)),t.style.setProperty("--palette",`var(--tablechart-color-${q+1})`),q+=1)),t.style.setProperty("--i",String(a.slot)),t.dataset.row=String(n+1),F.appendChild(t)}(V?b:t).appendChild(F),O&&t.appendChild(O);const P=l.filter(t=>!t.group),j=!s.axes&&!s.centre&&ce(t,"data-chart-axis",e.axis),D=s.axes?{titles:P.slice(0,2).map((t,n)=>{const a=C(`${g}-title`,b);return a.dataset.axis=n?"y":"x",a.textContent=t.name,t.key&&e.langattribute&&a.setAttribute(e.langattribute,t.key),a}),ticks:C(`${w}s`,b),numbers:!0}:j||!s.centre&&ce(t,"data-chart-grid",e.grid)?{titles:[],ticks:C(`${w}s`,b),numbers:j}:null;s.text?.({figure:t,plot:b,rows:c,series:l,config:e});const I=le(t,e)&&!s.axes?(t=>{const e=t.hasAttribute("data-fragment"),n=Array.from(t.querySelectorAll("tbody tr")),a=Array.from(t.querySelector("thead tr:last-child")?.children??[]).slice(1),o=Array.from(t.querySelectorAll("[data-annotation]")).filter(t=>Lt.includes(t.getAttribute("data-annotation")??"")),r=t=>t.hasAttribute("data-fragment"),s=n.map(t=>Array.from(t.querySelectorAll(":scope > td")));if(!(e||n.some(r)||a.some(r)||s.flat().some(r)||o.some(r)))return null;const c=[],l=new Map,i=[],u=t=>{let e=null!==t?l.get(t):void 0;return void 0===e&&(e=c.length,c.push(t),i.push(0),null!==t&&l.set(t,e)),e};let d=0;const h="donut"===t.getAttribute("data-chart"),f=t=>h&&"total"===t.getAttribute("data-kind"),m=n.map(t=>{if(f(t))return{step:null,slot:0};if(!e&&!r(t))return{step:null,slot:d++};const n=u(t.getAttribute("data-fragment-index"));return{step:n,slot:i[n]++}}),b=Math.max(-1,...m.map(t=>t.step??-1));if(b>=0)for(const[w,y]of n.entries())f(y)&&(m[w]={step:b,slot:i[b]++});const $=a.map(t=>({step:r(t)?u(t.getAttribute("data-fragment-index")):null})),p=s.map(t=>t.map(()=>({step:null,slot:0}))),g=Math.max(0,...s.map(t=>t.length));for(let w=0;w<g;w++)for(const[t,e]of s.entries()){const n=e[w];if(!n||!r(n))continue;const a=u(n.getAttribute("data-fragment-index"));p[t][w]={step:a,slot:i[a]++}}return{rows:m,series:$,cells:p,notes:o.map(t=>{const e=(e,n)=>{const a=Number.parseInt(t.getAttribute(e)??"",10);return Number.isFinite(a)?a-1:n},[n,a]="bracket"===t.getAttribute("data-annotation")?[e("data-from",0),e("data-to",m.length-1)]:[0,m.length-1];let o=null;for(let r=Math.min(n,a);r<=Math.max(n,a);r++)for(const t of[m[r]?.step??null,...(p[r]??[]).map(t=>t.step)])null!==t&&(null===o||t>o)&&(o=t);const s=$[e("data-series",0)]?.step??null;null!==s&&(null===o||s>o)&&(o=s),r(t)&&(o=u(t.getAttribute("data-fragment-index")));const c=null===o?m.length:m.filter(t=>t.step===o).length;return{step:o,after:c}}),count:c.length,indexes:c}})(t):null;s.axes&&t.querySelector("[data-fragment]")&&vt.log(`A ${r} chart has no steps, so it is shown whole.`,t),I&&t.setAttribute("data-steps","");const R=t.getAttribute("data-chart-keys"),W=I&&e.controls?((t,e,n)=>{const a=document.createElement("div");a.className="tablechart-controls";const o=a=>{const o=document.createElement("button");o.type="button",o.className=`tablechart-${a}`,o.dataset.go=a;const r=document.createElement("span");r.className="tablechart-control-icon",r.setAttribute("aria-hidden","true");const s=S("svg",{viewBox:"0 0 16 16",focusable:"false"});s.appendChild(S("path",{d:"next"===a?"M6 3l5 5-5 5":"M10 3L5 8l5 5"})),r.appendChild(s);const c=document.createElement("span");c.className="tablechart-control-label",c.textContent=t[a];const l=e[a];l&&n&&c.setAttribute(n,l);const i=document.createElement("span");return i.className=$,i.textContent=t.hint,e.hint&&n&&i.setAttribute(n,e.hint),o.append(..."next"===a?[c,i,r]:[r,c,i]),o};return a.append(o("previous"),o("next")),a})({previous:e.previouslabel,next:e.nextlabel,hint:e.stephint},{previous:R&&`${R}-previous`,next:R&&`${R}-next`,hint:R&&`${R}-step`},e.langattribute):null;W&&t.appendChild(W);const G=t.getAttribute("data-chart-table"),K=G&&fe.includes(G)?G:e.table;if("never"===K)t.removeAttribute("data-table");else{t.setAttribute("data-table",K);const e=t.querySelector(":scope > table");e&&t.append(e)}const X=Array.from(t.querySelectorAll("[data-annotation]")).map(t=>{const e=t.getAttribute("data-annotation"),a=te[e];if(!a)return console.warn(`[${n}] Unknown annotation "${e}". Known annotations: ${Object.keys(te).join(", ")}.`),null;const o=Number.parseInt(t.getAttribute("data-series")??"1",10),r=o>=1&&o<=l.length?o-1:0;return o!==r+1&&console.warn(`[${n}] An annotation reads line ${o}, which is not there; it reads line 1.`),{spec:t,type:a,badge:a.create(t,b),series:r,after:c.length}}).filter(t=>null!==t);le(t,e)&&t.setAttribute("data-animate",me(t,r,e,Boolean(I)));const Y={figure:t,plot:b,svg:p,rows:c,decimals:M,type:s,values:N,series:l,seriesValues:k,names:O?[]:E,categories:Array.from(F.children),centre:z,axes:D,stacked:f,totals:A,totalCell:U,rowAt:null,rowBox:null,annotations:X,checks:[],plan:I,step:0,controls:W},Z=()=>Me(t,p);p.addEventListener("transitionend",Z),p.addEventListener("transitioncancel",Z),W?.addEventListener("click",t=>{const e=t.target.closest("button")?.dataset.go;e&&Et(Y,Y.step+("next"===e?1:-1))}),Et(Y,0,!0);const Q=t.getAttribute("data-chart-tooltip"),tt="false"!==Q&&("auto"===Q?"auto":null!==Q||e.tooltip);return tt&&((t,e,n=!1)=>{const{plot:a}=t;a.setAttribute("data-hover",""),(()=>{if(Rt)return;Rt=!0,document.addEventListener("pointermove",t=>{"mouse"===t.pointerType&&(jt=t.screenX!==Dt||t.screenY!==It,Dt=t.screenX,It=t.screenY,jt&&(Pt=!1))},{capture:!0,passive:!0});const t=()=>{Pt=!0,qt()};document.addEventListener("keydown",t,!0),window.addEventListener("scroll",t,{capture:!0,passive:!0})})();const o=new Set,r=t=>{for(const e of o)if(e.isConnected){if(e.getAttribute("data-row")===String(t+1))return!0}else o.delete(e);return!1};let s=null;const c=o=>{if("pointerdown"===o.type)Pt=!1;else if("mouse"===o.pointerType&&(!jt||Pt))return;if(!a.classList.contains("is-placed")||!t.figure.classList.contains("is-shown"))return;if(n&&!t.figure.hasAttribute("data-left-out"))return Ut===t?qt():void 0;const c=(e=>{if(t.rowAt){const n=a.getBoundingClientRect(),o=Wt(a,n.width);return t.rowAt((e.clientX-n.left)/o,(e.clientY-n.top)/o)}const n=e.target.closest?.("[data-row]")?.getAttribute("data-row");return n?Number(n)-1:null})(o);if(s=c,null===c||r(c))return Ut===t?qt():void 0;Zt(t,c,e)},l=e=>{const n=e.target;return t.svg.contains(n)&&n.hasAttribute("data-row")?n:null};t.svg.addEventListener("transitionrun",t=>{const e=l(t);e&&o.add(e)});const i=n=>{const a=l(n);if(!a)return;o.delete(a);const c=Number(a.getAttribute("data-row"))-1;s!==c||r(c)||Pt||Zt(t,c,e)};t.svg.addEventListener("transitionend",i),t.svg.addEventListener("transitioncancel",i),a.addEventListener("pointermove",c),a.addEventListener("pointerdown",c),a.addEventListener("pointerleave",e=>{"mouse"===e.pointerType&&(s=null,Ut===t&&Gt())})})(Y,e,"auto"===tt),ge(Y,e),Y},he={grow:"grow",sweep:"sweep"},fe=["never","auto","print","always"],me=(t,e,n,a)=>{const o="line"===e||"area"===e,r=he[t.getAttribute("data-chart-animate")??""]??he[String(n.animate)];return o?a?"sweep":r??"sweep":"donut"===e||"waterfall"===e?r??"grow":"grow"},be=t=>{const e=getComputedStyle(t).getPropertyValue("--tablechart-value-align").trim();return"start"===e||"center"===e||"end"===e?e:null},$e=(t,e,n,a)=>{const o=getComputedStyle(t),r=(o.getPropertyValue(n).trim()||a).match(/^(\d+(?:\.\d+)?)(px|%|em|rem)$/);if(!r)return null;const s=Number(r[1]);return"%"===r[2]?s/100*M:s*("em"===r[2]?Number.parseFloat(o.fontSize):"rem"===r[2]?Number.parseFloat(getComputedStyle(document.documentElement).fontSize):1)*e},pe=(t,e)=>$e(t,e,"--tablechart-bar-max","60px")??Number.POSITIVE_INFINITY,ge=(t,e)=>{const n=[...t.seriesValues.flat(),...t.totals,...t.totalCell?[t.totalCell]:[]];for(const a of t.centre?[...n,t.centre]:n)void 0!==a.dataset.missing?a.textContent=a.dataset.missing:we(a,a.dataset.decimals?Number(a.dataset.decimals):t.decimals,e.locale)},we=(t,e,n)=>{const{prefix:a="",suffix:o=""}=t.dataset,[r,s]=((t,e,n)=>{const a=((t,e)=>new Intl.NumberFormat(e||document.documentElement.lang||void 0,{minimumFractionDigits:t,maximumFractionDigits:t}))(e,n).formatToParts(t),o="minusSign"===a[0]?.type?a[0].value:"";return[o,a.slice(o?1:0).map(t=>t.value).join("")]})(Number.parseFloat(t.dataset.value||"0"),e,n);if(t.textContent=a+(a?r:"")+s+o,r&&!a){const e=document.createElement("span");e.className="tablechart-minus",e.textContent=r,t.prepend(e)}},ye=(t,e)=>{e||t.figure.hasAttribute("data-steps")||ve(t.svg),t.figure.classList.toggle("is-shown",e),e&&requestAnimationFrame(()=>requestAnimationFrame(()=>Me(t.figure,t.svg)))},Me=(t,e)=>{t.classList.contains("is-shown")&&!e.getAnimations({subtree:!0}).length&&xe(e)},ve=t=>{for(const e of t.querySelectorAll('[mask^="url(#tablechart-cut-"]'))e.dataset.mask=e.getAttribute("mask")??"",e.removeAttribute("mask")},xe=t=>{for(const e of t.querySelectorAll("[data-mask]"))e.setAttribute("mask",e.dataset.mask??""),e.removeAttribute("data-mask")},ke=t=>"id"===t||"style"===t||t.startsWith("data-chart"),Ne=/^\s*(?:Table)?:\s+/,Ae=t=>"P"===t?.tagName&&Ne.test(t.textContent??""),Se=/^\s*([a-z][\w-]*)((?:\s+[\w-]+=[^\s:]+)*)\s*(:\s*|$)/,He=t=>{const e=Te(t);return"P"===e?.tagName?e:t},Ce=t=>{if(!t||"object"!=typeof t)return;const e=Object.entries(t),n=t=>null===t||"string"==typeof t||"number"==typeof t;return e.length&&e.every(([,t])=>n(t)||Array.isArray(t)&&t.every(n))?e.map(([t,e])=>Array.isArray(e)?{label:t,values:e}:{label:t,value:e}):void 0},Te=t=>{const e=Array.from(t.childNodes).filter(t=>t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE&&t.textContent?.trim());return 1===e.length&&e[0]instanceof HTMLElement?e[0]:null},Le="strong, b, span.total",Oe="data-chart-made",Ee=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,ze=new Set,Be=null,_e=["column","bar"],Ue=t=>{const e=t.getAttribute("data-chart")||"column";if(!_e.includes(e))return null;const n=getComputedStyle(t).getPropertyValue("--tablechart-type").trim();return _e.includes(n)?n:e},Ve=!1,Fe=async(t,e)=>{const a=(t=>t.map(t=>{const e=t.closest("p"),n=Ae(e)?e:t;if("TABLE"!==n.tagName&&"P"!==n.tagName)return n;const a=document.createElement("figure");((t,e)=>{for(const{name:n,value:a}of Array.from(t.attributes))("class"===n||ke(n))&&(e.setAttribute(n,a),t.removeAttribute(n))})(t,a),t.classList.length||t.removeAttribute("class");const o="TABLE"===n.tagName?n:null,r=n.previousElementSibling;let s=n.nextElementSibling;const c=o?Ae(r)?r:Ae(s)?s:null:n;o&&c===s&&(s=s?.nextElementSibling??null);const l=s?.classList.contains("chart-annotations")?s:(t=>{if("UL"!==t?.tagName&&"OL"!==t?.tagName)return null;const e=Array.from(t.children),n=e.map(t=>t.hasAttribute("data-annotation")?null:(t=>{const e=He(t).firstChild;if(e?.nodeType!==Node.TEXT_NODE)return null;const n=Se.exec(e.textContent??"");if(!n||!ee.includes(n[1]))return null;if(!n[3]&&e.nextSibling)return null;const a=n[2].trim().split(/\s+/).filter(Boolean).map(t=>t.split("="));return{name:n[1],options:a,text:e,length:n[0].length}})(t));return!e.length||e.some((t,e)=>!n[e]&&!t.hasAttribute("data-annotation"))?null:(e.forEach((t,e)=>{const a=n[e],o=He(t);if(o!==t&&o.replaceWith(...o.childNodes),a){t.setAttribute("data-annotation",a.name);for(const[e,n]of a.options)t.setAttribute(`data-${e}`,n);a.text.textContent=(a.text.textContent??"").slice(a.length)}t.children.length&&Array.from(t.childNodes).filter(t=>t.nodeType===Node.ELEMENT_NODE||t.textContent?.trim()).forEach((t,e)=>{const n=document.createElement("span");0===e&&t instanceof HTMLElement&&t.matches("em, i")?(n.className="tablechart-caption",n.append(...t.childNodes),t.replaceWith(n)):t.nodeType===Node.TEXT_NODE&&(n.textContent=(t.textContent??"").trim(),t.replaceWith(n))})}),t.classList.add("chart-annotations"),t)})(s);return n.replaceWith(a),c&&a.append((t=>{const e=document.createElement("figcaption");for(const{name:r,value:s}of Array.from(t.attributes))e.setAttribute(r,s);const n=t.firstChild;n?.nodeType===Node.TEXT_NODE&&(n.textContent=(n.textContent??"").replace(Ne,""),n.textContent||n.remove());const a=Array.from(t.childNodes),o=a.findIndex(t=>"BR"===t.nodeName);if(e.append(...-1===o?a:a.slice(0,o+1)),-1!==o&&o<a.length-1){const t=document.createElement("span");t.append(...a.slice(o+1)),e.append(t)}return t.remove(),e})(c)),o&&a.append(o),l&&a.append(l),vt?.log?.(`A ${o?"table":"caption"} with chart attributes was wrapped in a figure of its own`),a}))(t.filter(t=>!t.hasAttribute(Oe)));return(t=>{const e=t.find(t=>"FIGURE"!==t.tagName);!Ve&&e&&(Ve=!0,console.warn(`[${n}] A chart is a <${e.tagName.toLowerCase()}>. Use a <figure> with a <figcaption>, so the chart has a title, also for screen readers.`,e))})(a),await(async t=>{await Promise.all(t.filter(t=>t.hasAttribute("data-chart-src")).map(async t=>{const e=t.getAttribute("data-chart-src"),a=Array.from(t.querySelectorAll("table")).find(t=>t.tHead)??null;for(const n of t.querySelectorAll("table"))n!==a&&n.remove();try{const n=await fetch(e);if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);const o=await n.json(),r=Array.isArray(o)?o:o?.rows?Array.isArray(o.rows)?o.rows:Ce(o.rows):Ce(o);if(!Array.isArray(r))throw new Error("no rows in it: a list of rows, an object with rows, or names with their values");const s=((t,e,n,a=document.createElement("table"))=>{for(const r of a.querySelectorAll(":scope > tbody, :scope > tfoot, :scope > tr"))r.remove();if(!a.tHead&&(e.length||n)){const t=a.createTHead().insertRow(),o=document.createElement("th");o.textContent=n,t.append(o);for(const n of e){const e=document.createElement("th");e.textContent=n,t.append(e)}}const o=document.createElement("tbody");a.append(o);for(const r of t){const t=o.insertRow();"total"===r.kind&&(t.dataset.kind="total");const e=document.createElement("th");e.textContent=String(r.label??""),t.append(e);for(const n of r.values??[r.value??null])t.insertCell().textContent=null===n?"":String(n)}return a})(r,Array.isArray(o?.series)?o.series.map(String):[],"string"==typeof o?.label?o.label:"",a??void 0);if(!a){const e=t.querySelector(":scope > figcaption");e?e.after(s):t.prepend(s)}s.tHead||vt?.log?.(`The table from "${e}" has no header row, so a screen reader cannot name its columns.`),vt?.log?.(`Read ${r.length} rows from "${e}"`)}catch(o){const t="file:"===window.location.protocol;console.warn(`[${n}] Could not read the chart data in "${e}": ${o.message}.`+(t?" A page opened as a file cannot fetch files; open it from a server.":""))}}))})(a),(t=>{for(const e of t){for(const n of e.querySelectorAll("tbody tr")){const t=n.cells[0];if("TD"!==t?.tagName||n.cells.length<2)continue;const e=document.createElement("th");for(const{name:n,value:a}of Array.from(t.attributes))e.setAttribute(n,a);e.append(...t.childNodes),t.replaceWith(e);for(let a=Te(e);a?.matches(Le);a=Te(e))n.dataset.kind="total",a.replaceWith(...a.childNodes)}const t=Array.from(e.querySelector("thead tr:last-child")?.children??[]);for(const e of t.slice(1))for(let t=Te(e);t?.matches(Le);t=Te(e))e.setAttribute("data-kind","focus"),t.replaceWith(...t.childNodes)}})(a),((t,e)=>{if(!e)return;const a=new Map;for(const o of t){let t=o.getAttribute("data-chart-keys")||null;if(!t)continue;if(a.has(t)){const e=a.get(t)+1;a.set(t,e),console.warn(`[${n}] Two charts have data-chart-keys="${t}", so this one uses "${t}-${e}" to keep their translations apart.`),t=`${t}-${e}`}else a.set(t,1);o.querySelectorAll("tbody th").forEach((n,a)=>{n.getAttribute(e)||n.setAttribute(e,`${t}-row${a+1}`)});const r=kt(o);r.length>1&&r.forEach((n,a)=>{n.getAttribute(e)||n.setAttribute(e,`${t}-col${a+1}`)}),r.forEach((n,a)=>{if(!n.hasAttribute("data-group"))return;const r=[];o.querySelectorAll(`tbody tr > td:nth-of-type(${a+1})`).forEach(n=>{const a=(n.textContent||"").trim();r.includes(a)||r.push(a),n.getAttribute(e)||n.setAttribute(e,`${t}-group${r.indexOf(a)+1}`)})}),vt?.log?.(`Keys for "${t}" written onto ${o.querySelectorAll("tbody th").length} rows`)}})(a,e.langattribute),a},qe=(t,e)=>{const a=vt.timed("Building",t,()=>de(t,e));return a?(t.setAttribute(Oe,""),((t,e)=>{let a=t,r=Ue(a.figure),s=null,l=!1,u=!1;const h=async()=>{if(!le(a.figure,e))return ye(a,!0);const t=a.figure.classList.contains("is-shown");if(!l||null===s||t||u)!l&&e.replay&&t&&ye(a,!1);else{u=!0;const t=Ee()?null:(t=>{for(let e=t;e&&e!==document.body;e=e.parentElement)if("0"===getComputedStyle(e).opacity)return e;return null})(a.figure);t&&await(n=t,new Promise(t=>{const e=["animationstart","transitionrun"],a=()=>{for(const t of e)document.removeEventListener(t,o,!0);r.disconnect(),t()},o=t=>{t.target instanceof Node&&t.target.contains(n)&&a()},r=new MutationObserver(()=>{"0"!==getComputedStyle(n).opacity&&a()});for(const n of e)document.addEventListener(n,o,!0);r.observe(n,{attributes:!0,attributeFilter:["class","style"]})})),await(async(t,e)=>{if(Ee())return;await new Promise(requestAnimationFrame);const n=t.getAnimations().filter(t=>t instanceof CSSAnimation);for(let r=t.parentElement;r&&r!==document.body;r=r.parentElement)n.push(...r.getAnimations());let a=0;for(const r of n){const t=r.effect?.getComputedTiming(),n=Number(t?.activeDuration??0);if(!t||!Number.isFinite(n))continue;const o=Number(t.delay??0)+n*e;a=Math.max(a,o-Number(r.currentTime??0))}var o;a>0&&await(o=a,new Promise(t=>setTimeout(t,o)))})(a.figure,((t,e)=>{const n=Number.parseFloat(t.dataset.chartEntrance??""),a=Number.isFinite(n)?n:e.entrance;return Math.min(Math.max(a,0),1)})(a.figure,e)),u=!1,!l&&e.replay||ye(a,!0)}var n},b=()=>{const t=Ue(a.figure);if(!t||t===r)return;const n=vt.timed("Building",a.figure,()=>de(a.figure,e,t));n&&((t=>{Jt(t),t.plot.remove(),t.categories[0]?.parentElement?.remove(),t.figure.querySelector(`:scope > .${d}`)?.remove(),t.controls?.remove()})(a),Et(n,a.step,!0),a=n,r=t,s=null)},$=()=>{b();const t=a.plot.clientWidth;t&&t!==s&&vt.timed("Layout",a.figure,()=>((t,e)=>{const{plot:a,svg:r,rows:s,type:l,values:u,series:d,seriesValues:h,names:b,annotations:$}=t,p=Number.parseFloat(t.figure.dataset.chartAspect??""),v=p>0?p:l.aspect??e.aspect,x="beside"===l.categories,N=t.axes&&!l.axes?t.axes:null,H=x?null:t.categories[0]?.parentElement;let L=null;if(N){a.style.margin="",H&&(H.style.marginLeft="");const n=a.clientWidth;if(!n)return!1;const o=l.segments?.(s)??[],r=t.stacked?s.flatMap(t=>Object.values(Z(t,d.length,l.running))):o.some(t=>"up"===t.kind||"down"===t.kind)?o.flatMap(t=>[t.from,t.to]):s.flatMap(t=>t.cells.slice(0,d.length).filter(t=>!t.missing).map(t=>t.value)),c=Math.min(0,-B(r.map(t=>-t))),i=Math.max(0,B(r)),u=Number.parseFloat(getComputedStyle(a).fontSize)||16,{chartScaleY:h,chartScale:f}=t.figure.dataset,m=Ct(h??f);if(m&&m.length>2)L={min:m[0],max:m[m.length-1],step:0,ticks:m};else{const[t,e]=m??[c,i],a=At(e-t,Math.max((x?n/9:n*v/3)/u,2)),o=(t,e)=>m?t:Number(((e?Math.ceil:Math.floor)(t/a-1e-9*(e?1:-1))*a).toPrecision(12)),r=o(t,!1),s=o(e,!0);L={min:r,max:s,step:a,ticks:St(r,s,a)}}N.ticks.textContent="";const b=s.find(t=>!t.missing),$=B(L.ticks.map(t=>_(String(t))));for(const t of L.ticks){const n=C(w,N.ticks);n.dataset.value=String(t),n.dataset.place="none",b?.prefix&&(n.dataset.prefix=b.prefix),b?.suffix&&(n.dataset.suffix=b.suffix),we(n,$,e.locale)}if(N.numbers){const t=Array.from(N.ticks.children);for(const e of t)delete e.dataset.place;D(t),x?a.style.marginBottom=`${(t[0]?I(t[0]).height:0)+6}px`:(a.style.marginLeft=`${B([0,...t.map(t=>I(t).width)])+10}px`,H&&(H.style.marginLeft=a.style.marginLeft))}}const E=a.clientWidth;if(!E)return!1;const z=M/E,U=M*v;a.classList.add("is-placed");for(const n of[...h.flat(),...t.totals])delete n.dataset.place;a.style.removeProperty("--_fit"),t.categories[0]?.parentElement?.style.removeProperty("--_beside");const V=l.axes?t.axes:null;let F=[];if(V){const n=Number.parseFloat(getComputedStyle(a).fontSize)||16,o=d.flatMap((t,e)=>t.group?[]:[e]).slice(0,2),r=s.filter(t=>o.every(e=>t.cells[e]&&!t.cells[e].missing)),{chartScaleX:c,chartScaleY:l,chartScale:i}=t.figure.dataset,u=[Ct(c),Ct(l??i)];F=o.map((t,e)=>((t,e,n)=>{if(n&&n.length>2)return{min:n[0],max:n[n.length-1],step:0,ticks:n};let a=n?.[0]??-B(t.map(t=>-t)),o=n?.[1]??B(t);if(!n){const t=.05*(o-a||Math.abs(o)||1);a-=t,o+=t}const r=At(o-a,e);return{min:a,max:o,step:r,ticks:St(a,o,r)}})(r.length?r.map(e=>e.cells[t].value):[0,1],Math.max(e?U/z/(4*n):E/(9*n),4),u[e])),V.ticks.textContent="",F.forEach((t,n)=>{const a=r[0]?.cells[o[n]],s=B(t.ticks.map(t=>_(String(t))));for(const o of t.ticks){const t=C(w,V.ticks);t.dataset.axis=n?"y":"x",t.dataset.value=String(o),a?.prefix&&(t.dataset.prefix=a.prefix),a?.suffix&&(t.dataset.suffix=a.suffix),we(t,s,e.locale)}})}const q=V?Array.from(V.ticks.children):[];D([...h.flat(),...t.totals,...b,...t.categories,...$.map(t=>t.badge),...V?.titles??[],...q]);const P=(u[0]?I(u[0]).height:0)*z,j=$[0]?.badge?I($[0].badge).height*z:0,R=Math.max(U,$e(t.figure,z,"--tablechart-min-height","200px")??0,l.minHeight?.({labelHeight:P,nameHeight:Math.max(0,B(t.categories.map(t=>I(t).height)))*z,unit:z,rows:s.length,series:d.length,stacked:t.stacked})??0),W=t.stacked?s.map(t=>{const e=J(t,d.length);return{...t,value:e,cells:t.cells.map((t,n)=>0===n?{...t,value:e}:t)}}):s,G=(l.segments??(t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"}))))(t.stacked?W.map(t=>({...t,cells:[t.cells[0]]})):s),K={labelHeight:P,badgeHeight:j,hasAnnotations:$.length>0,unit:z,series:d.length,focused:d.some(t=>t.focus),stacked:t.stacked},X=Math.max((Y=B,t.stacked?Y(s.map(t=>Z(t,d.length,l.running).top)):Y([...G.flatMap(t=>[t.from,t.to,t.value]),...s.flatMap(t=>t.cells.slice(0,d.length).map(t=>t.value))])),0);var Y;const Q=G.some(t=>"up"===t.kind||"down"===t.kind)?G.flatMap(t=>[t.from,t.to]):t.stacked?s.map(t=>Z(t,d.length,l.running).bottom):s.flatMap(t=>t.cells.slice(0,d.length).map(t=>t.value)),tt=Math.min(-B(Q.map(t=>-t)),0),et=l.headroom?.(K)??P,nt=2*z+(l.footroom?.(K)??0)+(tt<0?P+4*z:0),at=R-et-nt,rt=L?Math.max(L.max,X):1.02*X,st=L?Math.min(L.min,tt):1.02*tt,ct=$.find(t=>"axis-break"===t.spec.getAttribute("data-annotation"))?.spec,lt=t=>{const e=Number.parseFloat(ct?.getAttribute(t)??"");return Number.isFinite(e)?e:null},it=lt("data-from")??lt("data-at"),ut=lt("data-to");let dt=null;if(ct&&(null!==it||null!==ut)){const t=it??0,e=ut??rt,a=null===ut?t:null===it?e:(t+e)/2,o=ct.getAttribute("data-size"),r=o?.match(/^\s*(\d+(?:\.\d+)?)\s*%\s*$/);null===o||r||console.warn(`[${n}] data-size="${o}" is not a percentage, such as 30%. Using the default.`);const s=Math.min(Math.max(r?Number(r[1])/100:null===ut?.22:.3,.05),.8),c=G.filter(n=>("up"===n.kind||"down"===n.kind)&&Math.max(n.from,n.to)>t&&Math.min(n.from,n.to)<e);l.breakable?tt<0?console.warn(`[${n}] A chart with values below zero cannot break its scale.`):t<0||e<=t||e>rt||0===t&&e===rt?console.warn(`[${n}] A break from ${t} to ${e} does not fit a scale that runs from 0 to ${X}.`):c.length?console.warn(`[${n}] A break from ${t} to ${e} would cut a step that floats. Keep it below or above the steps.`):dt={lo:t,hi:e,gap:a,share:s}:console.warn(`[${n}] This kind of chart cannot break its scale.`)}const ht=dt?dt.gap:null,ft=(dt&&$e(t.figure,z,"--tablechart-break-gap",""))??13,mt=R-nt,bt=rt-st||1;let $t,pt,gt=t=>mt-(t-st)/bt*at;if(dt){const{lo:t,hi:e,gap:n,share:a}=dt,o=at*a,r=(at-o-ft)/(t+(rt-e)),s=o/(e-t);gt=a=>a<=t?mt-a*r:a<=n?mt-t*r-(a-t)*s:a<=e?mt-t*r-(a-t)*s-ft:mt-t*r-o-ft-(a-e)*r}let wt=[];if(V){const t=6*z,[e,n]=V.titles,a=t=>t?I(t).width*z:0,o=t=>t?I(t).height*z:0,r=q.filter(t=>"x"===t.dataset.axis),s=q.filter(t=>"y"===t.dataset.axis),c=o(q[0]),l=a(n)+B([0,...s.map(a)])+2*t,i=c/2;pt=[l,i,M-l-B([0,...r.map(a)])/2,R-i-o(e)-c-2*t];const[u,d,h,f]=pt,[m,b]=F,$=t=>u+(t-m.min)/(m.max-m.min||1)*h,p=t=>d+f-(t-b.min)/(b.max-b.min||1)*f;$t=$,gt=p;const g=t=>a(r.find(e=>Number(e.dataset.value)===t));wt=[Tt(m,e=>e.every((n,a)=>!a||$(n)-$(e[a-1])>(g(n)+g(e[a-1]))/2+t)).ticks,Tt(b,e=>e.every((n,a)=>!a||p(e[a-1])-p(n)>c+t/2)).ticks];for(const w of q){const e=Number(w.dataset.value),n="x"===w.dataset.axis?0:1,a=wt[n].includes(e);w.dataset.place=a?n?"before":"below":"none",a&&T(w,n?u-t:$(e),n?p(e):d+f+t,M,R)}e&&T(e,u+h/2,R-o(e),M,R),n&&T(n,0,d+f/2,M,R)}const yt=b.length?B(b.map(t=>I(t).width))*z+12*z:0,Mt=t.categories[0]?.parentElement;Mt&&(Mt.style.paddingRight=yt?yt/M*100+"%":"");const vt=(M-yt)/s.length,xt=t=>t>=0&&t<s.length?t:null;t.rowAt=l.centre?null:"beside"===l.categories?(t,e)=>xt(Math.floor(e*z/(R/s.length))):t=>xt(Math.floor(t*z/vt));const kt=vt/M*100,Nt=100/s.length;if(t.rowBox="beside"===l.categories?t=>[0,t*Nt,100,Nt]:t=>[t*kt,0,kt,100],r.setAttribute("viewBox",`0 0 1000 ${A(R)}`),r.textContent="",pt&&$t){const[n,a,o,s]=pt,[c,l]=wt,i=$t;ce(t.figure,"data-chart-grid",e.grid)&&r.appendChild(S("path",{class:y,d:[...c.map(t=>`M${A(i(t))},${A(a)}V${A(a+s)}`),...l.map(t=>`M${A(n)},${A(gt(t))}H${A(n+o)}`)].join("")})),r.appendChild(S("path",{class:g,d:[`M${A(n)},${A(a)}V${A(a+s)}H${A(n+o)}`,...c.map(t=>`M${A(i(t))},${A(a+s)}v${A(4*z)}`),...l.map(t=>`M${A(n)},${A(gt(t))}h${A(-4*z)}`)].join("")}))}t.checks=[];const Ht={rows:s,segments:G,cx:t=>(t+.5)*vt,y:gt,x:$t,frame:pt,length:(e,n)=>$e(t.figure,z,e,n),barWidth:Math.min(vt*e.barfill,pe(t.figure,z)),barMax:pe(t.figure,z),height:R,unit:z,labelHeight:P,badgeHeight:j,after:s.length,note:0,labels:"inside"===t.figure.dataset.chartLabels||"outside"!==t.figure.dataset.chartLabels&&"inside"===e.labels?"inside":"outside",insideAlign:be(t.figure),breakAt:ht,squeeze:dt,breakGap:ft,domain:L?[L.min,L.max]:null,stacked:t.stacked,shape:ie(t.figure,e),totals:t.totals,svg:r,plot:a,values:u,series:d,seriesValues:h,names:b,categories:t.categories,centre:t.centre,config:e,checks:t.checks,taken:[]};if(a.style.setProperty("--count",String(Math.max(1,...s.map(t=>t.slot+1)))),l.draw(Ht),Ht.rowAt&&(t.rowAt=Ht.rowAt),N&&L){const n=6*z,a=x&&Ht.x?Ht.x:gt,o=Array.from(N.ticks.children),s=t=>I(o.find(e=>Number(e.dataset.value)===t)??o[0]),c=Tt(L,t=>t.every((e,o)=>!o||(x?a(e)-a(t[o-1])>(s(e).width+s(t[o-1]).width)/2*z+n:a(t[o-1])-a(e)>s(e).height*z+n/2))).ticks.filter(t=>!dt||t<=dt.lo||t>=dt.hi);for(const t of o){const e=Number(t.dataset.value),o=N.numbers&&c.includes(e);t.dataset.place=o?x?"below":"before":"none",o&&T(t,x?a(e):-n,x?R+n:a(e),M,R)}const l=M-yt;ce(t.figure,"data-chart-grid",e.grid)&&r.prepend(S("path",{class:y,d:c.map(t=>x?`M${A(a(t))},0V${A(R)}`:`M0,${A(a(t))}H${A(l)}`).join("")})),N.numbers&&r.appendChild(S("path",{class:g,d:[x?`M${A(a(L.min))},${A(R)}H${A(a(L.max))}`:`M0,${A(a(L.max))}V${A(a(L.min))}`,...c.map(t=>x?`M${A(a(t))},${A(R)}v${A(4*z)}`:`M0,${A(a(t))}h${A(-4*z)}`)].join("")}))}for(const[n,o]of $.entries()){o.badge?.setAttribute("data-note",String(n+1));const e=o.series,r=t=>({...t,...t.cells[e]??t.cells[0]});o.type.draw(o.spec,o.badge,{...Ht,...t.stacked&&{rows:W,...t.totals.length&&{values:t.totals}},...e>0&&!t.stacked&&{rows:s.map(r),segments:G.map(t=>{const e=r(t);return"bar"===t.kind?{...e,to:e.value}:e}),values:h[e]},after:t.plan?o.after:Math.min(o.after,Number(a.style.getPropertyValue("--count"))||o.after),note:n+1})}(t=>{const e=t.plan;if(!e)return;const n=e.rows.length-1,a=t=>e.series.map((n,a)=>e.cells[t]?.[a]?.step??n.step??e.rows[t]?.step??null),r=t=>{const e=a(t);return e.some(t=>null===t)?null:Math.min(...e)},s=new Set(t.totals),c=(t,e,n,a)=>{t.style.setProperty(n,String(a)),t.style.removeProperty("--d"),null===e?t.style.removeProperty("--step"):t.style.setProperty("--step",String(e))};for(const o of t.figure.querySelectorAll("[data-row], [data-series], [data-note]")){if(o.closest("table, .tablechart-controls")||o.hasAttribute("data-from"))continue;const t=Number(o.dataset.note);if(t>0){const n=e.notes[t-1];n&&c(o,n.step,"--after",n.after);continue}const l=o.dataset.row?Number(o.dataset.row)-1:n;if(o.classList.contains("tablechart-connector")){const t=e.rows[l-1],n=e.rows[l];if(t&&n){const e=(t.step??-1)>(n.step??-1);c(o,e?t.step:n.step,"--i",e?t.slot+1:n.slot)}continue}if(s.has(o)){const t=a(l).filter(t=>null!==t);c(o,t.length?Math.max(...t):null,"--i",e.rows[l]?.slot??0);continue}if(o.hasAttribute("data-stack")){c(o,r(l),"--i",e.rows[l]?.slot??0);continue}const i=o.dataset.series?Number(o.dataset.series)-1:0,u=o.dataset.series?e.series[i]:void 0;if(o.classList.contains("tablechart-piece")){const t=a(l)[i]??null,n=e.cells[l]?.[i];c(o,t===r(l)?null:t,"--i",n&&null!==n.step?n.slot:l);continue}if("legend"===o.dataset.place){const t=Math.min(...e.cells.map(t=>t[i]?.step??Number.POSITIVE_INFINITY));c(o,u?.step??(Number.isFinite(t)?t:null),"--i",0);continue}const d=e.cells[l]?.[i];d&&null!==d.step?c(o,d.step,"--i",d.slot):u&&null!==u.step?c(o,u.step,"--i",l):e.rows[l]&&c(o,e.rows[l].step,"--i",e.rows[l].slot)}const l=t.figure.querySelector(`.${m}`);if(l){const t=[...e.rows,...e.cells.flat()].map(t=>t.step??-1),n=Math.max(-1,...t);n<0?c(l,null,"--i",0):c(l,n,"--i",t.filter(t=>t===n).length)}const u=[...e.rows,...e.cells.flat()].map(t=>t.slot+1),d=e.series.some(t=>null!==t.step)?e.rows.length:1;t.plot.style.setProperty("--count",String(Math.max(d,...u)));const h=t.figure.querySelectorAll(`.${o}`),f=h[h.length-1];if("waterfall"===t.figure.dataset.chart&&"total"===f?.dataset.kind&&h.length>1){const t=Number(f.dataset.row)-1;(e.rows[t-1]?.step??-1)>(e.rows[t]?.step??-1)&&(f.dataset.grow="down"===f.dataset.grow?"up":"down")}const b=Array.from(t.figure.querySelectorAll(`.${i}`));if(b.length){const e=t=>t.style.getPropertyValue("--step")||"none",n=t=>Number(t.style.getPropertyValue("--share")||0),a=b.length,o=Math.max(0,b.findIndex((t,n)=>e(t)!==e(b[(n-1+a)%a]))),r=[];for(let t=0;t<a;t++){const n=b[(o+t)%a],s=r[r.length-1];s&&e(s[0])===e(n)?s.push(n):r.push([n])}const s=new Map;for(const t of r){const e=t.reduce((t,e)=>t+n(e),0);let a=0;for(const o of t)s.set(o.dataset.row??"",k(a,n(o),e)),a+=n(o)}for(const c of t.figure.querySelectorAll("[data-row]")){const t=s.get(c.dataset.row??"");t&&c.style.getPropertyValue("--start")&&(c.style.setProperty("--start",t.start.toFixed(4)),c.style.setProperty("--span",t.span.toFixed(4)),c.classList.contains("tablechart-slice")&&c.style.setProperty("--ease",t.easing))}}Ot(t)})(t);const Lt=t.categories[0]?.parentElement;Lt&&"beside"!==l.categories&&!l.centre&&ot(Lt,t.categories.filter(t=>null!==t.offsetParent),t=>({size:t.scrollWidth,room:t.clientWidth}),"--_name-fit");const Et=$.flatMap(({badge:t})=>{if(!(t instanceof HTMLElement&&t.offsetWidth))return[];const e=t.offsetWidth*z,n=t.offsetHeight*z,a=Number.parseFloat(t.style.left)/100*M,o=Number.parseFloat(t.style.top)/100*R,r=getComputedStyle(t).borderTopLeftRadius,s=r.endsWith("%")?Number.parseFloat(r)/100:null,c=(Number.parseFloat(r)||0)*z;return[S("rect",{class:f,"data-for":"badge","data-note":t.dataset.note??"",x:a-e/2,y:o-n/2,width:e,height:n,rx:null===s?c:e*s,ry:null===s?c:n*s,style:["--after","--step"].map(e=>t.style.getPropertyValue(e)&&`${e}:${t.style.getPropertyValue(e)}`).filter(Boolean).join("; ")})]}),zt=r.querySelector(`.${y}`),Bt=Array.from(r.querySelectorAll(`.${c}`));if(zt||Bt.length){const e=a.getBoundingClientRect(),n=M/e.width,o=getComputedStyle(a),s=Number.parseFloat(o.lineHeight)/Number.parseFloat(o.fontSize)||1.2,c=[...h.flat(),...t.totals,..."beside"===l.categories?t.categories:[]].flatMap(t=>{if("none"===t.dataset.place||t.hidden||t.hasAttribute("data-left-out"))return[];const a=t.getBoundingClientRect(),o=a.height*n/s,r=Array.from(t.style).filter(t=>t.startsWith("--")).map(e=>`${e}:${t.style.getPropertyValue(e)}`);return a.width?[S("rect",{class:f,"data-for":"text",x:(a.left-e.left)*n-3*z,y:(a.top-e.top)*n+(a.height*n-o)/2-z,width:a.width*n+6*z,height:o+2*z,style:r.join("; ")})]:[]}),i=t=>["x","y","width","height"].map(e=>Number(t.getAttribute(e)));for(const t of Bt)re(t,[...c,...Et].map(i));if(zt&&t.plan)O(r,c,M,R,[zt]);else if(zt){const t=(_t=zt,Array.from((_t.getAttribute("d")??"").matchAll(/M(-?[\d.]+),(-?[\d.]+)([HV])(-?[\d.]+)/g),([,t,e,n,a])=>"H"===n?[+t,+e,+a,+e]:[+t,+e,+t,+a]));zt.setAttribute("d",t.map(([t,e,n,a])=>oe(t,e,n,a,c.map(i))).join(""));for(const e of c){const n=se(t,i(e));n&&zt.after(S("path",{class:y,"data-gap":"",d:n,style:e.getAttribute("style")??""}))}}}var _t;O(r,Et,M,R,void 0,`.${c}`),!t.figure.hasAttribute("data-animate")||t.figure.hasAttribute("data-steps")||t.figure.classList.contains("is-shown")||ve(r);const Ut=t=>"none"!==t.dataset.place&&!t.hasAttribute("data-left-out");return t.figure.toggleAttribute("data-left-out",(l.columns?[t.categories]:[...h,t.totals]).some(t=>t.some(e=>!(t=>void 0!==t.dataset.missing||l.centre&&s[Number(t.dataset.row)-1]?.isTotal)(e)&&!Ut(e)&&!((t,e)=>{const n=Number(t.dataset.row);return e.some(t=>Ut(t)&&Number(t.dataset.row)<=n&&n<=Number(t.dataset.rowEnd??t.dataset.row))})(e,t)))),!0})(a,e))&&(s=t,h())};let v=!1;const x=new ResizeObserver(()=>{v||(v=!0,requestAnimationFrame(()=>{v=!1,$()}))}),N=new IntersectionObserver(t=>{for(const e of t)l=e.isIntersecting,h()},{threshold:e.threshold}),H=()=>{a.figure.classList.add(p),ye(a,!0),xe(a.svg),a.figure.offsetWidth},L=()=>a.figure.classList.remove(p),E=()=>{s=null,$()},z={relabel:()=>ge(a,e),refresh:E};b(),$(),x.observe(a.figure),N.observe(a.figure),window.addEventListener("beforeprint",H),window.addEventListener("afterprint",L),(t=>{ze.add(t),Be||(Be=new MutationObserver(()=>{for(const t of ze)t.relabel();requestAnimationFrame(()=>requestAnimationFrame(()=>{for(const t of ze)t.refresh()}))})).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]})})(z);const U={figure:a.figure,refresh:E,next:()=>Et(a,a.step+1),previous:()=>Et(a,a.step-1),stepTo:t=>Et(a,t),get step(){return a.step},get steps(){return a.plan?.count??0},destroy(){x.disconnect(),N.disconnect(),window.removeEventListener("beforeprint",H),window.removeEventListener("afterprint",L),(t=>{ze.delete(t),!ze.size&&Be&&(Be.disconnect(),Be=null)})(z),Jt(a),a.figure.tablechart===U&&delete a.figure.tablechart}};return a.figure.tablechart=U,U})(a,e)):null},Pe=e({LEGEND_CLASS:()=>d,NAME_CLASS:()=>u,POINT_CLASS:()=>h,VIEWBOX_WIDTH:()=>M,avoidCollisions:()=>P,htmlEl:()=>C,largest:()=>B,markerEl:()=>dt,placeAt:()=>T,short:()=>A,sizeOf:()=>I});window.Tablechart={init:async(t={},e=document)=>{const n={...v,...t};n.debug&&(vt.enabled=!0);const a=(await Fe(Array.from(e.querySelectorAll(n.selector)),n)).map(t=>qe(t,n)).filter(t=>null!==t);return vt.log(`Made ${a.length} chart(s).`),{charts:a,refresh:()=>{for(const t of a)t.refresh()},destroy:()=>{for(const t of a)t.destroy()}}},create:async(t,e={})=>{if(t.tablechart)return t.tablechart;const n={...v,...e};n.debug&&(vt.enabled=!0);const[a]=await Fe([t],n);return a?qe(a,n):null},defaultConfig:v,addType:(t,e)=>{Qt[t]=e},kit:Pe}}();
1
+ !function(){var t=Object.defineProperty,e=(e,n)=>{let o={};for(var a in e)t(o,a,{get:e[a],enumerable:!0});return n||t(o,Symbol.toStringTag,{value:"Module"}),o},n="tablechart",o="tablechart-value",a="tablechart-bar",r="tablechart-rule",s="tablechart-line",c="tablechart-reference",l="tablechart-quadrant",i="tablechart-head",u="tablechart-slice",d="tablechart-series",h="tablechart-area",f="tablechart-name",b="tablechart-legend",m="tablechart-point",$="tablechart-hole",p="tablechart-centre",g="tablechart-break",w="tablechart-sr",y="is-shown",M="is-printing",v="is-at-once",x="tablechart-axis",k="tablechart-tick",N="tablechart-grid",A=1e3,S={selector:"[data-chart]",aspect:.38,barfill:.58,ringfill:.42,animate:!0,entrance:.5,labels:"outside",values:"auto",ticks:!0,shape:"straight",legend:!1,axis:!1,grid:!1,names:!0,tooltip:"auto",tooltipparent:null,table:"never",tablelimit:15,summary:"auto",totallabel:"Total",controls:!0,previouslabel:"Previous",nextlabel:"Next",stephint:"step of the chart",threshold:.5,replay:!1,langattribute:"data-i18n"},H="cubic-bezier(0.3, 0.3, 0.6, 1)",C=(t,e,n=1)=>({start:t,span:e,easing:t+e>=n-1e-4?H:"linear"}),O=(t,e)=>`${t}:${e}`,T=t=>Math.round(100*t)/100,L=(t,e={})=>{const n=document.createElementNS("http://www.w3.org/2000/svg",t);for(const o in e){const t=e[o];n.setAttribute(o,String("number"==typeof t?T(t):t))}return n},_=(t,e)=>[t,...e.classes].join(" "),E=(t,e)=>{const n=document.createElement("span");return n.className=t,n.inert=!0,e.appendChild(n),n},z=(t,e,n,o,a)=>{t.style.left=e/o*100+"%",t.style.top=n/a*100+"%"},B=0,U=0,V=t=>{let e=t.querySelector(":scope > defs");return e||(e=L("defs"),t.prepend(e)),e},F=t=>{if("circle"===t.tagName){const[e,n,o]=["cx","cy","r"].map(e=>Number(t.getAttribute(e))||0);return`M${T(e-o)},${T(n)}a${T(o)},${T(o)} 0 1 0 ${T(2*o)},0a${T(o)},${T(o)} 0 1 0 ${T(-2*o)},0z`}if("polygon"===t.tagName)return`M${(t.getAttribute("points")??"").trim().split(/\s+/).join("L")}z`;const[e,n,o,a,r,s]=["x","y","width","height","rx","ry"].map(e=>Number(t.getAttribute(e))||0),c=Math.min(r,o/2),l=Math.min(s,a/2),i=(t,e)=>c&&l?`a${T(c)},${T(l)} 0 0 1 ${T(t)},${T(e)}`:"";return`M${T(e+c)},${T(n)}h${T(o-2*c)}${i(c,l)}v${T(a-2*l)}${i(-c,l)}h${T(2*c-o)}${i(-c,-l)}v${T(2*l-a)}${i(c,-l)}z`},R=(t,e,n,o,a)=>{if(!e.length||!a.length)return;const r="tablechart-clip-"+ ++U,s=L("clipPath",{id:r,clipPathUnits:"userSpaceOnUse"}),c=`M${-n},${-o}h${3*n}v${3*o}h${3*-n}z`;s.appendChild(L("path",{d:c+e.map(F).join(""),"clip-rule":"evenodd"})),V(t).appendChild(s);for(const l of a)l.setAttribute("clip-path",`url(#${r})`)},j=(t,e,n,o,a,r)=>{if(!e.length)return;const s="tablechart-cut-"+ ++B,c=L("mask",{id:s,maskUnits:"userSpaceOnUse"});c.appendChild(L("rect",{x:-n,y:-o,width:3*n,height:3*o,fill:"white"}));for(const u of e)u.setAttribute("fill","black"),c.appendChild(u);const l=V(t);if(l.appendChild(c),a){for(const t of a)t.setAttribute("mask",`url(#${s})`);return}let i=null;for(const u of Array.from(t.childNodes))u!==l&&(r&&u instanceof Element&&u.matches(r)?(i=null,t.appendChild(u)):(i??(i=t.appendChild(L("g",{mask:`url(#${s})`}))),i.appendChild(u)))},q=0,I={create:()=>null,draw(t,e,n){const{rows:o,y:r,svg:s,breakAt:c}=n;if(null===c)return;const l="zigzag"===t.getAttribute("data-mark"),i=(t,e)=>{const n=t.sideways?t.height:t.width,o=.09*n,a=n+2*o,r=.3*a,s=.06*a;if(t.sideways){const n=t.y-o;if(!l)return[[e-r/2,n],[e+r/2,n+a]];const c=a/3;return[[e-s,n],[e+s,n+c],[e-s,n+2*c],[e+s,n+a]]}const c=t.x-o;if(!l)return[[c,e+r/2],[c+a,e-r/2]];const i=a/3;return[[c,e+s],[c+i,e-s],[c+2*i,e+s],[c+a,e-s]]},u=(t,e=!1)=>t.map(([t,e],n)=>`${0===n?"M":"L"} ${t.toFixed(1)} ${e.toFixed(1)}`).join(" ")+(e?" Z":""),d="tablechart-break-"+ ++q,h=L("mask",{id:d,maskUnits:"userSpaceOnUse"});h.appendChild(L("rect",{x:-1e3,y:-n.height,width:3e3,height:3*n.height,fill:"white"}));const f=[],b=r(c);for(const w of(t=>Array.from(t.querySelectorAll(`.${a}`)).map(t=>{const e="rect"===t.tagName?[t]:Array.from(t.querySelectorAll("rect")),n=(t,e)=>Number(t.getAttribute(e)),o=Math.min(...e.map(t=>n(t,"x"))),a=Math.min(...e.map(t=>n(t,"y"))),r=Math.max(...e.map(t=>n(t,"x")+n(t,"width"))),s=Math.max(...e.map(t=>n(t,"y")+n(t,"height"))),c=["--start","--span"].map(e=>t.style.getPropertyValue(e)&&`${e}:${t.style.getPropertyValue(e)}`).filter(Boolean).join("; ");return{row:Number(t.dataset.row),x:o,y:a,width:r-o,height:s-a,sideways:"right"===t.dataset.grow,part:c}}))(s)){const t=w.sideways?n.breakX:b;if(void 0===t)continue;if(!(w.sideways?w.x<t&&w.x+w.width>t:w.y<b&&w.y+w.height>b))continue;const[e,a]=w.sideways?[i(w,t),i(w,t+n.breakGap)]:[i(w,b-n.breakGap),i(w,b)];h.appendChild(L("path",{d:u([...e,...a.slice().reverse()],!0),fill:"black"})),f.push(e,a);const r=[O("--after",o[w.row-1]?.slot??0),w.part].filter(Boolean).join("; ");for(const o of[e,a])s.appendChild(L("path",{class:g,"data-part":"edge","data-note":n.note,d:u(o),style:r}))}if(!f.length)return;const m=Array.from(s.querySelectorAll(`.${g}`)),$=L("g",{mask:`url(#${d})`});for(const a of Array.from(s.childNodes))m.includes(a)||$.appendChild(a);const p=L("defs");p.appendChild(h),s.prepend(p,$)}},P=t=>{let e=Number.NEGATIVE_INFINITY;for(const n of t)e=Math.max(e,n);return e},D=t=>(t.split(/[.,]/)[1]||"").length,W=(t,e,n)=>{const o=((t,e)=>new Intl.NumberFormat(e||document.documentElement.lang||void 0,{minimumFractionDigits:t,maximumFractionDigits:t}))(e,n).formatToParts(t),a="minusSign"===o[0]?.type?o[0].value:"";return[a,o.slice(a?1:0).map(t=>t.value).join("")]},G=t=>Number.parseFloat((t.match(/-?[\d.,]+/)||["NaN"])[0].replace(",",".")),K=(t,e)=>{const n=document.createElement("span");if(n.className="tablechart-badge",n.inert=!0,t.childElementCount>0)for(const o of Array.from(t.children))n.appendChild(o.cloneNode(!0));else{n.textContent=(t.textContent||"").trim();const e=t.getAttribute("data-i18n");e&&n.setAttribute("data-i18n",e)}return e.appendChild(n),n},Y=(t,e,o,a,r="%")=>{const s=t?.textContent||"",c=G(s),l=r?.5:.5*10**-D(s.match(/-?[\d.,]+/)?.[0]??""),i=!!Number.isNaN(c)||Math.abs(e-c)<=l+1e-9,u={label:o,computed:e,stated:c,agrees:i};a.checks.push(u),i||console.warn(`[${n}] An annotation reads ${c}${r}, but ${o} is ${Number(e.toFixed(2))}${r}. The chart shows your number.`)},X={create:K,draw(t,e,o){const{rows:a,cx:r,y:c,unit:l,labelHeight:u,badgeHeight:d,height:h,svg:f,after:b}=o,[m,$]=((t,e)=>{const n=(e,n)=>{const o=Number.parseInt(t.getAttribute(e)??"",10);return Number.isFinite(o)?o-1:n};return[n("data-from",0),n("data-to",e-1)]})(t,a.length),p=a[m],g=a[$];if(!p||!g)return void console.warn(`[${n}] A bracket points at a row that is not there (row ${m+1} to ${$+1}, of ${a.length}).`);const w=7*l,y=4*l,M=r(m),v=r($),x=Math.min(c(p.value),c(g.value))-u-y-.9*d,k=t=>c(t)-u-y,N=`M ${M} ${k(p.value)} L ${M} ${x} L ${v} ${x} L ${v} ${k(g.value)-w}`,S=(k(p.value)-x+Math.abs(v-M)+(k(g.value)-w-x))/l+1;f.appendChild(L("path",{class:s,"data-note":o.note,d:N,style:`--len:${S.toFixed(1)}; ${O("--after",b)}`}));const H=k(g.value);var C;f.appendChild(L("polygon",{class:i,"data-note":o.note,points:`${v},${H} ${v-.45*w},${H-w} ${v+.45*w},${H-w}`,style:O("--after",b)})),e&&(z(e,(M+v)/2,x,A,h),e.style.setProperty("--after",String(b))),Y(e,(C=p.value,(g.value-C)/Math.abs(C)*100),`${p.value} to ${g.value}`,o)}},Z=(t,e)=>t[0]<e[0]+e[2]&&e[0]<t[0]+t[2]&&t[1]<e[1]+e[3]&&e[1]<t[1]+t[3],Q=(t,e,n)=>{if(t.length>400)return t.map(()=>null);let o=1;for(const l of t)for(const[,,t,e]of l)o=Math.max(o,t,e);const a=new Map,r=([t,e,n,a])=>{const r=[];for(let s=Math.floor(t/o);s<=Math.floor((t+n)/o);s++)for(let t=Math.floor(e/o);t<=Math.floor((e+a)/o);t++)r.push(`${s} ${t}`);return r},s=t=>{for(const e of r(t))a.get(e)?.push(t)??a.set(e,[t])},c=t=>((t,e)=>t[0]>=e[0]&&t[1]>=e[1]&&t[0]+t[2]<=e[0]+e[2]&&t[1]+t[3]<=e[1]+e[3])(t,n)&&r(t).every(e=>!a.get(e)?.some(e=>Z(t,e)));return e.forEach(s),t.map(t=>{const e=t.findIndex(c);return e<0?null:(s(t[e]),e)})},J=new WeakMap,tt=t=>{const e=[...t].filter(t=>!!t),n=e.map(t=>({width:t.offsetWidth,height:t.offsetHeight}));e.forEach((t,e)=>J.set(t,n[e]))},et=t=>J.get(t)??{width:t.offsetWidth,height:t.offsetHeight},nt=(t,e,n)=>t.some(t=>et(t).width*n>e-6*n),ot=(t,e,n)=>e>=et(t).height*n*1.6,at=(t,e,n)=>e>=et(t).width*n*1.5,rt=(t,e,n,o,a=.7)=>{t.style.setProperty(o,"1");let r=1;for(const c of e){const{size:t,room:e}=n(c);t>e&&(r=Math.min(r,e/t))}const s=r>=a?r:0;return t.style.setProperty(o,String(s||a)),s},st={outside:[.5,1],below:[.5,0],after:[0,.5],before:[1,.5]},ct=(t,e,n,o,a=[.5,.5])=>{const[r,s]=st[t.dataset.place??""]??a,{width:c,height:l}=et(t);return[Number.parseFloat(t.style.left)/100*n-c*e*r,Number.parseFloat(t.style.top)/100*o-l*e*s,c*e,l*e]},lt=(t,e,n)=>{for(const o of t){if("none"===o.dataset.place||!o.style.left)continue;const[t]=st[o.dataset.place??""]??[.5,.5],a=et(o).width*e,r=Number.parseFloat(o.style.left)/100*n,s=Math.min(Math.max(r,a*t),n-a*(1-t));s!==r&&(o.style.left=s/n*100+"%")}},it=(t,e,n,o)=>{const a=t.filter(t=>"none"!==t.dataset.place&&!t.hasAttribute("data-left-out")),r=ut(a,e,n,o);a.forEach((t,e)=>{e%r&&t.setAttribute("data-left-out","")})},ut=(t,e,n,o)=>{if(t.length<2)return 1;const a=t.map(t=>ct(t,e,n,o)),r=2*e;let s=1;for(;s<t.length&&a.some((t,e)=>{return e>=s&&e%s===0&&(o=t,!((n=a[e-s])[0]+n[2]+r<=o[0]||o[0]+o[2]+r<=n[0]||n[1]+n[3]<=o[1]||o[1]+o[3]<=n[1]));var n,o});)s++;return s},dt={create(t,e){if(!t.textContent?.trim())return null;const n=K(t,e);return n.dataset.kind="note",n},draw(t,e,o){const{rows:a,cx:r,y:s,height:l,unit:i,svg:u,after:d,seriesValues:h}=o;if(o.x||o.centre||"beside"===o.categories[0]?.parentElement?.dataset.place)return void console.warn(`[${n}] A note works on a chart with its rows across, such as a line or column chart.`);const f=(t.getAttribute("data-row")??"").trim(),b=/^\d+$/.test(f)?Number(f)-1:a.findIndex(t=>t.label===f);if(b<0||b>=a.length)return void console.warn(`[${n}] A note is for row "${f}", which is not there.`);const $=r(b),p=s(0);if(u.insertBefore(L("line",{class:c,"data-kind":"note","data-note":o.note,x1:$,x2:$,y1:0,y2:p,style:O("--after",d)}),u.querySelector(`:scope > .${m}`)),!e)return;const g=et(e).width*i,w=et(e).height*i,y=4*i,M=h.flat().flatMap(t=>!t.style.left||"none"===t.dataset.place||t.hasAttribute("data-left-out")?[]:[{label:t,box:ct(t,i,A,l)}]),v=[0,w+y/2].flatMap(t=>[[$-g/2,t,g,w],[$+y,t,g,w],[$-y-g,t,g,w]]),[x]=Q([v],[...o.taken,...M.map(t=>t.box)],[0,0,A,l]),k=v[x??0];if(o.taken.push(k),z(e,k[0]+g/2,k[1]+w/2,A,l),e.style.setProperty("--after",String(d)),null===x)for(const n of M)Z(n.box,k)&&n.label.setAttribute("data-left-out","")}},ht=(t,e,n)=>{const o=n.reduce((t,e)=>t+e,0);if("mean"===t)return o?e.reduce((t,e,o)=>t+e*n[o],0)/o:null;if("median"===t){const t=e.map((t,e)=>[t,n[e]]).sort((t,e)=>t[0]-e[0]);let a=0;for(const[e,[n,r]]of t.entries()){if(a+=r,Math.abs(a-o/2)<1e-9&&t[e+1])return(n+t[e+1][0])/2;if(a>o/2)return n}return null}const a=Number.parseFloat(t);return Number.isFinite(a)?a:null},ft={create(t,e){if(!t.textContent?.trim())return null;const n=K(t,e);return n.dataset.kind="reference",n},draw(t,e,o){const{rows:a,cx:r,y:s,x:l,height:i,unit:u,svg:d,after:h}=o,f=a.filter(t=>!t.isTotal&&!t.missing),b=t.hasAttribute("data-name"),$=(t.getAttribute(b?"data-name":"data-value")??"").trim();let p,g,w;if(b){const t=f.map(t=>G(t.label));if("beside"===o.categories[0]?.parentElement?.dataset.place||t.some(Number.isNaN))return void console.warn(`[${n}] A reference line among the names needs names that are numbers, under columns or points.`);const e=ht($,t,f.map(t=>t.value)),s=null===e?-1:t.findIndex((n,o)=>n<=e&&e<=(t[o+1]??n)),[c,l]=[f[s],f[s+1]??f[s]].map(t=>r(a.indexOf(t))),i=null===e||s<0||void 0===t[s+1]||t[s+1]===t[s]?0:(e-t[s])/(t[s+1]-t[s]);w=e,g=s<0?null:c+i*(l-c),p=!1}else{const e=Boolean(o.frame)&&"y"===t.getAttribute("data-axis"),n=o.frame?o.series.flatMap((t,e)=>t.group?[]:[e])[e?1:0]??0:0;w=ht($,f.map(t=>t.cells[n]?.value??t.value),f.map(()=>1)),p=e||!l,g=null===w?null:l&&!e?l(w):s(w)}if(null===g||null===w)return void console.warn(`[${n}] A reference line needs a number, "mean" or "median", not "${$}".`);const[y,M,v,x]=o.frame?[o.frame[0],o.frame[1],o.frame[0]+o.frame[2],o.frame[1]+o.frame[3]]:[0,0,a.length>0?r(a.length-1)+r(0):A,l?i:s(0)];if(d.insertBefore(L("line",{class:c,"data-note":o.note,..."dotted"===t.getAttribute("data-line")&&{"data-line":"dotted"},...p?{x1:y,x2:v,y1:g,y2:g}:{x1:g,x2:g,y1:M,y2:x},style:O("--after",h)}),d.querySelector(`:scope > .${m}`)),e){const t=et(e).width*u,n=et(e).height*u,a=4*u,r=p?[[v-t,g-n/2,t,n],[v-t,g-n-a,t,n],[v-t,g+a,t,n]]:[M,M+n,M+2*n].flatMap(e=>[[g-t/2,e,t,n],[g+a,e,t,n],[g-a-t,e,t,n]]),[s]=Q([r],o.taken,[0,0,A,i]),c=r[s??0];o.taken.push(c),z(e,c[0]+t/2,c[1]+n/2,A,i),e.style.setProperty("--after",String(h)),"mean"!==$&&"median"!==$||Y(e,w,`the ${$}`,o,"")}}},bt={create:K,draw(t,e,n){const{rows:o,cx:a,y:r,unit:c,labelHeight:l,height:u,svg:d,values:h,after:f}=n,b=o[0],m=o[o.length-1];if(!b||!m)return;const $=l+18*c,p=10*c,g=10*c;let w=a(0),y=r(b.value)-$,M=a(o.length-1),v=r(m.value)-$,x=0;o.forEach((t,e)=>{const n=M===w?0:(a(e)-w)/(M-w),o=y+n*(v-y)-(r(t.value)-$);o>x&&(x=o)}),y-=x,v-=x;const k=M-w,N=v-y,S=Math.hypot(k,N)||1,H=k/S,C=N/S;w-=H*p,y-=C*p,M+=H*p,v+=C*p;const T=Number.parseFloat(t.getAttribute("data-at")||"0.5");if(e){const t=w+(M-w)*T,n=y+(v-y)*T,s=et(e).width*c/2,i=n+et(e).height*c/2+8*c;let u=0;o.forEach((e,n)=>{const o=(h[n]?et(h[n]).width:0)*c/2;if(Math.abs(a(n)-t)>=s+o)return;const d=r(e.value)-7*c-l;u=Math.max(u,i-d)}),y-=u,v-=u}const _=M-H*g,E=v-C*g,B=Math.hypot(_-w,E-y)/c+1;d.appendChild(L("line",{class:s,"data-note":n.note,x1:w,y1:y,x2:_,y2:E,style:`--len:${B.toFixed(1)}; ${O("--after",f)}`}));const U=-C,V=H,F=.42*g;d.appendChild(L("polygon",{class:i,"data-note":n.note,points:[`${M},${v}`,`${_+U*F},${E+V*F}`,`${_-U*F},${E-V*F}`].join(" "),style:O("--after",f)})),e&&(z(e,w+(M-w)*T,y+(v-y)*T,A,u),e.style.setProperty("--after",String(f)));const R=Number.parseFloat(t.getAttribute("data-years")||"");!Number.isNaN(R)&&R>0&&Y(e,((t,e,n)=>100*(Math.pow(e/t,1/n)-1))(b.value,m.value,R),`${b.value} to ${m.value} over ${R} years`,n)}},mt=(t,e,n)=>{const o=.15,a=Math.min(.7*t/(e+(e-1)*o),n),r=e*a+(e-1)*a*o;return{size:a,gap:a*o,offset:t=>-r/2+t*a*1.15}},$t=(t,e,n)=>{const o=t.series[n],a=t.series.some(t=>t.focus)&&!o.focus;return{"data-series":n+1,...a&&{"data-muted":""},style:`--n:${n}; --m:${a?1:0}; --palette:var(--tablechart-color-${n+1}); ${O("--i",e.slot)}`}},pt=(t,e,n=!1)=>{let o=0,a=0;return Array.from({length:e},(e,r)=>{const s=t.cells[r]??t.cells[0],c=s.missing?0:s.value;if(n){const t=o;return o+=c,{from:t,to:o,cell:s}}if(c<0){const t=a;return a+=c,{from:t,to:a,cell:s}}const l=o;return o+=c,{from:l,to:o,cell:s}})},gt=(t,e,n=!1)=>{const o=pt(t,e,n);return{top:Math.max(0,...o.map(t=>t.to)),bottom:Math.min(0,...o.map(t=>t.to))}},wt=(t,e)=>{const{top:n,bottom:o}=gt(t,e);return n+o},yt=(t,e,n)=>{const o=e.series.some(t=>t.focus);t.style.setProperty("--n",String(n)),t.style.setProperty("--m",o&&!e.series[n].focus?"1":"0"),t.style.setProperty("--palette",`var(--tablechart-color-${n+1})`)},Mt=(t,e,n,o={},r="")=>{const s={class:_(a,e),"data-kind":"bar","data-row":n+1,...o},c=O("--i",e.slot)+(r?`; transform-origin: ${r}`:""),l=L("g",{...s,"data-stack":"",style:c});return t.svg.appendChild(l),(a,r)=>{const s=void 0!==o["data-grow"]?{"data-grow":o["data-grow"]}:{};l.appendChild(L("rect",{...s,...r,class:_("tablechart-piece",e),"data-row":n+1,...$t(t,e,a)}))}},vt={segments:t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"})),series:!0,groups:!0,legend:"box",stackable:!0,totals:!0,breakable:!0,aspect:.5,minHeight:({labelHeight:t,nameHeight:e,rows:n,series:o,stacked:a})=>{const r=1.1*t,s=o>1&&!a?r*(o+.15*(o-1))/.7:r/.58;return n*Math.max(s,1.2*e)},categories:"beside",headroom:()=>0,draw(t){const{segments:e,height:n,unit:o,svg:s,values:c,categories:l,config:i,barMax:u}=t,d=t.series.length>1,h=Math.max(P(l.map(t=>et(t).width*o)),0),f=Math.min(h+10*o,420);l[0]?.parentElement?.style.setProperty("--_beside",`${((f-8*o)/A*100).toFixed(2)}%`);const b=A-4*o,m=t.stacked?Math.max(P(t.rows.map(e=>gt(e,t.series.length).top)),0)||1:Math.max(P(t.rows.flatMap(e=>e.cells.slice(0,t.series.length).map(t=>Math.abs(t.value)))),0)||1,$=t.stacked?Math.max(P(t.rows.map(e=>-gt(e,t.series.length).bottom)),0):Math.max(P(t.rows.flatMap(e=>e.cells.slice(0,t.series.length).map(t=>-t.value))),0),p=Math.max(m,t.domain?.[1]??0),g=Math.max($,-(t.domain?.[0]??0)),w=Math.max(p,t.squeeze?.hi??0)+g,y=(e,n)=>((t,e,n,o,a)=>{if(!o)return t/e*n;const{lo:r,hi:s,gap:c,share:l}=o,i=n*l,u=(n-i-a)/(r+(e-s)),d=i/(s-r);return t<=r?t*u:t<=c?r*u+(t-r)*d:t<=s?r*u+(t-r)*d+a:r*u+i+a+(t-s)*u})(Math.abs(e),w,n,t.squeeze,t.breakGap),M=n/e.length,v=t=>(t+.5)*M,x=Math.min(M*i.barfill,u),k=mt(M,t.series.length,u),N=c[0]??t.totals[0],S=N?et(N).height*o*.56:0,H=Math.max(((d&&!t.stacked?k.size:x)-S)/2,5*o),C=t=>et(t).width*o,T=t=>t.length?P(t.map(C))+H+4*o:0,E=(e,n)=>(t.rows[n].cells[e]??t.rows[n].cells[0]).value,B=t.seriesValues.flatMap((t,e)=>t.map((t,n)=>({label:t,value:E(e,n)}))),U=e=>{const n=gt(t.rows[e],t.series.length);return 0===n.top&&n.bottom<0};let V=t.stacked?T(t.totals.filter((t,e)=>!U(e))):d?T(B.filter(t=>t.value>=0).map(t=>t.label)):0,F=t.stacked?T(t.totals.filter((t,e)=>U(e))):d?T(B.filter(t=>t.value<0).map(t=>t.label)):0;const R=(e,n)=>"inside"===t.labels&&at(e,n,o);if(!d&&!t.stacked)for(let a=0;a<3;a++){const t=b-f-V-F,n=e.map((t,e)=>({seg:t,label:c[e]})).filter(({seg:e,label:n})=>!R(n,y(e.value,t))),o=T(n.filter(({seg:t})=>t.value>=0).map(({label:t})=>t)),a=T(n.filter(({seg:t})=>t.value<0).map(({label:t})=>t));if(o<=V&&a<=F)break;V=Math.max(V,o),F=Math.max(F,a)}const j=b-f-V-F,q=f+F+y(g,j),I=t=>t<0?q-y(t,j):q+y(t,j);if(t.squeeze&&(t.breakX=I(t.squeeze.gap)),t.x=I,t.stacked)return t.rows.forEach((e,a)=>{const r=gt(e,t.series.length),s=Mt(t,e,a,{"data-grow":"right"},r.bottom<0?q-I(r.bottom)+"px center":""),c=v(a)-x/2;pt(e,t.series.length).forEach(({from:e,to:r,cell:l},i)=>{const u=t.seriesValues[i][a];if(u.dataset.place="none",l.missing||r===e)return;const d=Math.min(I(e),I(r)),h=Math.max(I(e),I(r));s(i,{x:d,y:c,width:Math.max(h-d,1),height:x,...r<e&&{"data-grow":"left"}}),u.dataset.place="inside",u.toggleAttribute("data-left-out",!at(u,h-d,o)||et(u).height*o>x),yt(u,t,i),z(u,(d+h)/2,v(a),A,n)});const i=t.totals[a];i&&(i.dataset.place=U(a)?"before":"after",z(i,U(a)?I(r.bottom)-H:I(r.top)+H,v(a),A,n));const u=l[a];u&&z(u,f-8*o,v(a),A,n)}),void s.appendChild(L("line",{class:r,x1:q,x2:q,y1:0,y2:n}));if(d){const e=t.seriesValues.flat().filter(t=>void 0===t.dataset.missing),c=rt(t.plot,e,t=>({size:et(t).height*o,room:k.size+.5*k.gap}),"--_fit");return t.rows.forEach((e,r)=>{t.series.forEach((o,l)=>{const i=e.cells[l]??e.cells[0],u=t.seriesValues[l][r];if(i.missing)return void(u.dataset.place="none");const d=I(i.value),h=i.value<0,f=v(r)+k.offset(l),b=Math.max(Math.abs(d-q),1);0!==i.value&&s.appendChild(L("rect",{class:_(a,e),"data-kind":"bar","data-row":r+1,"data-grow":h?"left":"right",x:h?q-b:q,y:f,width:b,height:k.size,...$t(t,e,l)})),u.dataset.place=h?"before":"after",u.toggleAttribute("data-left-out",!c),z(u,h?d-H:d+H,f+k.size/2,A,n)});const i=l[r];i&&z(i,f-8*o,v(r),A,n)}),void s.appendChild(L("line",{class:r,x1:q,x2:q,y1:0,y2:n}))}const D=e.map((t,e)=>R(c[e],Math.abs(I(t.value)-q)));e.forEach((e,r)=>{const i=I(e.value),u=v(r),d=e.value<0,h=Math.abs(i-q),b=Math.max(h,1);0!==e.value&&s.appendChild(L("rect",{class:_(a,e),"data-kind":e.kind,"data-row":r+1,"data-grow":d?"left":"right",x:d?q-b:q,y:u-x/2,width:b,height:x,style:O("--i",e.slot)}));const m=c[r],$=Math.max(Math.min(H,h-C(m)-6*o),6*o),p=d?1:-1;m.dataset.place=D[r]?"inside":d?"before":"after",m.dataset.kind=e.kind,z(m,D[r]?"center"===t.insideAlign?(q+i)/2:"start"===t.insideAlign?q-p*($+C(m)/2):i+p*($+C(m)/2):i-p*H,u,A,n);const g=l[r];g&&z(g,f-8*o,u,A,n)}),s.appendChild(L("line",{class:r,x1:q,x2:q,y1:0,y2:n}))}},xt={segments:t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"})),series:!0,lines:!0,groups:!0,legend:"box",stackable:!0,totals:!0,breakable:!0,headroom:({labelHeight:t,badgeHeight:e,hasAnnotations:n,unit:o})=>t+4*o+(n?1.6*e:0),draw(t){const{segments:e,cx:n,y:o,barWidth:s,height:c,unit:l,svg:i,values:u,labels:d,insideAlign:h}=t,f=o(0);if(t.stacked)return t.rows.forEach((e,a)=>{const r=gt(e,t.series.length),i=Mt(t,e,a,{},r.bottom<0?`center ${f-o(r.top)}px`:""),u=n(a)-s/2;pt(e,t.series.length).forEach(({from:e,to:r,cell:d},h)=>{const f=t.seriesValues[h][a];if(f.dataset.place="none",d.missing||r===e)return;const b=Math.min(o(r),o(e)),m=Math.max(o(r),o(e));i(h,{x:u,y:b,width:s,height:Math.max(m-b,1),...r<e&&{"data-grow":"down"}}),f.dataset.place="inside",f.toggleAttribute("data-left-out",!ot(f,m-b,l)||et(f).width*l>s-4*l),yt(f,t,h),z(f,n(a),(b+m)/2,A,c)});const d=t.totals[a];if(d){const t=0===r.top&&r.bottom<0;d.dataset.place=t?"below":"outside",z(d,n(a),t?o(r.bottom)+4*l:o(r.top)-4*l,A,c)}}),void i.appendChild(L("line",{class:r,x1:0,x2:A,y1:f,y2:f}));if(t.own.length>1){const e=n(1)-n(0)||2*n(0),s=mt(e,t.own.length,t.barMax),u=t.own.flatMap(e=>t.seriesValues[e]).filter(t=>void 0===t.dataset.missing),d=rt(t.plot,u,t=>({size:et(t).width*l,room:s.size+.5*s.gap}),"--_fit");return t.rows.forEach((e,r)=>{t.own.forEach((u,h)=>{const b=e.cells[u]??e.cells[0],m=t.seriesValues[u][r],$=n(r)+s.offset(h);if(b.missing)return void(m.dataset.place="none");const p=o(b.value),g=b.value<0,w=Math.max(Math.abs(f-p),1);0!==b.value&&i.appendChild(L("rect",{class:_(a,e),"data-kind":"bar","data-row":r+1,...g&&{"data-grow":"down"},x:$,y:g?f:f-w,width:s.size,height:w,...$t(t,e,u)})),m.dataset.place=g?"below":"outside",m.toggleAttribute("data-left-out",!d),z(m,$+s.size/2,g?p+4*l:p-4*l,A,c)})}),void i.appendChild(L("line",{class:r,x1:0,x2:A,y1:f,y2:f}))}const b=t.own[0],m=t.own.length<t.series.length,$=nt(u,s,l),p=e.map((t,e)=>"inside"===d&&!$&&!t.missing&&ot(u[e],Math.abs(f-o(t.value)),l)),g=u[0]?et(u[0]).height*l*.56:0;let w=Number.POSITIVE_INFINITY;for(const[a,r]of u.entries())p[a]&&(w=Math.min(w,(s-et(r).width*l)/2));e.forEach((e,r)=>{const d=o(e.value),$=e.value<0;if(e.missing)return z(u[r],n(r),f-4*l,A,c),void(u[r].dataset.place="outside");const y=Math.max(Math.abs(f-d),1);0!==e.value&&i.appendChild(L("rect",{class:_(a,e),"data-kind":e.kind,"data-row":r+1,...$&&{"data-grow":"down"},x:n(r)-s/2,y:$?f:f-y,width:s,height:y,style:O("--i",e.slot),...m&&$t(t,e,b)}));const M=$?-1:1,v=Math.min(w,(Math.abs(f-d)-g)/2),x="center"===h?(d+f)/2:"start"===h?f-M*(v+g/2):d+M*(v+g/2),k=$?d+4*l:d-4*l;z(u[r],n(r),p[r]?x:k,A,c),u[r].dataset.place=p[r]?"inside":$?"below":"outside",m&&p[r]&&yt(u[r],t,b)}),i.appendChild(L("line",{class:r,x1:0,x2:A,y1:f,y2:f}))}},kt=0,Nt={aspect:.66,centre:!0,headroom:()=>0,segments:t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"})),draw({rows:t,height:e,unit:n,labelHeight:o,svg:a,values:r,config:s,centre:c}){const l=500,i=e/2,d=(t=>t.filter(t=>!t.isTotal))(t).reduce((t,e)=>t+Math.abs(e.value),0);if(!d)return;const h=1.2*o+10*n,f=Math.max(Math.min(A,e)/2-h,10),b=f*s.ringfill,m=f-b/2,$=2*Math.PI*m,p=[];let g=0,w=0,y=0;if(t.forEach((t,s)=>{const c=r[s];if(t.isTotal)return void(c.dataset.place="none");const h=Math.abs(t.value)/d,M=C(y,h),v=`--share:${h.toFixed(4)}; --start:${M.start.toFixed(4)}; --span:${M.span.toFixed(4)};`,x=h*$,k=g/$*2*Math.PI-Math.PI/2;p.push(k),a.appendChild(L("circle",{class:_(u,t),"data-slice":w+1,"data-row":s+1,cx:l,cy:i,r:m,"stroke-width":b,transform:`rotate(-90 500 ${i})`,"stroke-dasharray":`${x.toFixed(1)} ${($-x).toFixed(1)}`,"stroke-dashoffset":(-g).toFixed(1),style:`--n:${w}; --palette:var(--tablechart-color-${w+1}); --arc:${x.toFixed(1)}; --circ:${$.toFixed(1)}; ${v} --ease:${M.easing}; ${O("--i",t.slot)}`}));const N=k+x/$*Math.PI,S=Math.cos(N),H=Math.sin(N);a.appendChild(L("line",{class:"tablechart-leader",x1:l+S*(f+2*n),y1:i+H*(f+2*n),x2:l+S*(f+7*n),y2:i+H*(f+7*n),"data-row":s+1,style:`${v} ${O("--i",t.slot)}`})),c.style.setProperty("--start",M.start.toFixed(4)),c.style.setProperty("--span",M.span.toFixed(4));const T=f+9*n,E=et(c).width*n/2;z(c,l+S*(T+Math.abs(S)*E),i+H*(T+Math.abs(H)*o*.7),A,e),c.dataset.place="around",g+=x,y+=h,w+=1}),p.length>1){const t=m-b/2-1,n=m+b/2+1,o="tablechart-slices-"+ ++kt,r=L("mask",{id:o,maskUnits:"userSpaceOnUse"});r.appendChild(L("rect",{x:0,y:0,width:A,height:e,fill:"white"}));for(const e of p)r.appendChild(L("line",{class:"tablechart-divide",x1:l+Math.cos(e)*t,y1:i+Math.sin(e)*t,x2:l+Math.cos(e)*n,y2:i+Math.sin(e)*n}));const s=L("g",{mask:`url(#${o})`});for(const e of Array.from(a.querySelectorAll(`.${u}`)))s.appendChild(e);const c=L("defs");c.appendChild(r),a.prepend(c,s)}c&&z(c,l,i,A,e)}},At=["circle","square","diamond"],St=(t,e)=>{const n=t[e]?.marker?.toLowerCase().split(/\s+/)??[],o=At.find(t=>n.includes(t));return{shape:o??At[Math.floor(e/2)%At.length],open:n.includes("open")||!n.includes("filled")&&!o&&e%2==1}},Ht=(t,e,n,o,a={})=>{if("square"===t){const t=.88*o;return L("rect",{x:e-t,y:n-t,width:2*t,height:2*t,...a})}if("diamond"===t){const t=1.2*o;return L("polygon",{points:`${e},${n-t} ${e+t},${n} ${e},${n+t} ${e-t},${n}`,...a})}if("triangle"===t){const t=1.3*o;return L("polygon",{points:`${e},${n-.75*t} ${e+.87*t},${n+.75*t} ${e-.87*t},${n+.75*t}`,...a})}return L("circle",{cx:e,cy:n,r:o,...a})},Ct=t=>Number(t.toFixed(2));function Ot(t,e,n){const o=new Array(t).fill(0);let a=[];const r=()=>{(function(t,e){const n=t.length;if(n<2)return t.map(()=>0);const o=n=>(e[n+1]-e[n])/(t[n+1]-t[n]||1),a=new Array(n).fill(0);for(let s=1;s<n-1;s++){const e=o(s-1),n=o(s);if(e*n<=0)continue;const r=t[s]-t[s-1],c=t[s+1]-t[s],l=(e*c+n*r)/(r+c||1),i=Math.min(2*Math.abs(e),2*Math.abs(n),Math.abs(l));a[s]=Math.sign(e)*i||0}if(2===n)return a[0]=o(0),a[1]=o(0),a;const r=(n,o,a)=>{const r=t[o]-t[n];return r?((e[o]-e[n])/r*3-a)/2:a};return a[0]=r(0,1,a[1]),a[n-1]=r(n-2,n-1,a[n-2]),a})(a.map(t=>n(t)[0]),a.map(t=>n(t)[1])).forEach((t,e)=>{o[a[e]]=t}),a=[]};for(let s=0;s<t;s++)e(s)?r():a.push(s);return r(),o}var Tt,Lt,_t=t=>{const e=t.length,n=t.reduce((t,e)=>t+e.x,0)/e,o=t.reduce((t,e)=>t+e.y,0)/e,a=t.reduce((t,e)=>t+(e.x-n)**2,0),r=a?t.reduce((t,e)=>t+(e.x-n)*(e.y-o),0)/a:0,s=t=>o+r*(t-n),c=e>2?Math.sqrt(t.reduce((t,e)=>t+(e.y-s(e.x))**2,0)/(e-2)):0,l=a?c/Math.sqrt(a):0;return{at:s,spread:c,t:l?r/l:r?Number.POSITIVE_INFINITY:0,n:e}},Et=[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],zt=t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"})),Bt=t=>({segments:zt,series:!0,stackable:!0,running:!0,swatch:t?"box":void 0,headroom:({labelHeight:t,unit:e})=>1.6*t+6*e,footroom:({labelHeight:e,unit:n,series:o,focused:a,stacked:r})=>t||r||2!==o||a?0:e+7*n,draw(e){const{rows:n,series:o,own:a,seriesValues:s,names:c,cx:l,y:i,height:u,unit:f,labelHeight:b,svg:p,stacked:g}=e,w=a.length<o.length,y="step"===e.shape,M="smooth"===e.shape,v=o.length>1,x=o.some(t=>t.focus),k=n.length-1,N=i(0),S=n.length>1?l(1)-l(0):2*l(0);p.style.setProperty("--_base",`${Ct(N)}px`);const H=(t,e)=>n[e]?.cells[t]??n[e]?.cells[0],C=(t,e)=>!H(t,e)||!!H(t,e)?.missing,O=n.map(t=>g?pt(t,o.length,!0):null),T=(t,e)=>O[e]?.[t].to??H(t,e)?.value??0,_=(t,e)=>O[e]?.[t].from??0,E=(t,e)=>[l(e),i(T(t,e))],B=o.map((t,e)=>{if(!v)return{attrs:{},ink:""};const n=x&&!t.focus;return{attrs:{"data-series":e+1,...n&&{"data-muted":""}},ink:`--n:${e}; --m:${n?1:0}; --palette:var(--tablechart-color-${e+1}); `}}),U=w?k:Math.min(k,6);e.plot.style.setProperty("--count",String(U+1));const V=k>0?U/(y?n.length:k):1,F=t=>t*V,R=t=>`--i:${Ct(F(t))}`,q=t=>{const e=[];let o=-1;return n.forEach((n,a)=>{C(t,a)||(o<0&&(o=a),(a===k||C(t,a+1))&&((y||a>o)&&e.push([o,a]),o=-1))}),e},I=(t,e)=>`--i:${Ct(F(t)+1)}; --d:${Ct(F(y?e+1:e)-F(t))}`,P=(t,e)=>({"data-from":t+1,"data-to":e+1,...y&&{"data-flat":""}}),D=M?o.map((t,e)=>Ot(n.length,t=>C(e,t),t=>E(e,t))):[],W=M&&t?o.map((t,e)=>Ot(n.length,t=>C(e,t),t=>[l(t),i(_(e,t))])):[],G=(t,e,n)=>{const o=[];return t.forEach(([a,r],s)=>{y?(o.push(`H${Ct(a+n*S/2)}`),s<t.length-1&&o.push(`V${Ct(t[s+1][1])}`)):s>0&&o.push(e?function(t,e,n,o){const[a,r]=function(t,e,n,o){const a=(e[0]-t[0])/3;return[[t[0]+a,t[1]+n*a],[e[0]-a,e[1]-o*a]]}(t,e,n,o),s=([t,e])=>`${Ct(t)},${Ct(e)}`;return`C${s(a)} ${s(r)} ${s(e)}`}(t[s-1],[a,r],e[s-1],e[s]):`L${Ct(a)},${Ct(r)}`)}),o},K=(t,e,o,a)=>n.slice(e,o+1).map((n,o)=>[l(e+o),i(a(t,e+o))]),Y=(t,e,n,o)=>M?t[e].slice(n,o+1):null,X=t=>l(t)-(y?S/2:0),J=t=>l(t)+(y?S/2:0);t&&a.forEach(t=>(t=>{const e=L("g",{class:h,...B[t].attrs,...g&&{"data-stacked":""},style:B[t].ink}),n=q(t),o=L("g",{class:"tablechart-area-fill",style:`--rows:${Ct(U+1)}; ${n.length?I(...n[0]):""}`});e.appendChild(o);for(const[a,r]of n){const e=K(t,a,r,T),n=K(t,a,r,_),s=Y(W,t,a,r)?.reverse()??null,c=[`M${Ct(X(a))},${Ct(n[0][1])}`,`L${Ct(X(a))},${Ct(e[0][1])}`,...G(e,Y(D,t,a,r),1),`L${Ct(J(r))},${Ct(n[n.length-1][1])}`,...G(n.reverse(),s,-1),"Z"].join(" ");o.appendChild(L("path",{d:c,...P(a,r),style:I(a,r)}))}p.appendChild(e)})(t)),a.forEach(t=>(t=>{const e=o[t];for(const[n,o]of q(t)){const a=K(t,n,o,T),r=[`M${Ct(X(n))},${Ct(a[0][1])}`,...G(a,Y(D,t,n,o),1)].join(" ");p.appendChild(L("path",{class:d,...B[t].attrs,d:r,...e.line&&{"data-line":e.line},...P(n,o),style:`${B[t].ink}${I(n,o)}`}))}})(t));const tt=w?o.flatMap((t,e)=>a.includes(e)?[]:s[e].flatMap(t=>{const e=t.dataset.place;if(!e||"none"===e||t.hasAttribute("data-left-out"))return[];const[n,o,a,r]=ct(t,f,A,u);return[{label:t,box:[n-2*f,o-3*f,a+4*f,r+6*f]}]})):[],nt=y?[]:a.flatMap(t=>n.flatMap((e,n)=>{if(C(t,n))return[];const[o,a]=E(t,n);return[[o-4*f,a-4*f,8*f,8*f]]})),ot=tt.filter(({label:t,box:e})=>{const n=nt.some(t=>Z(t,e));return n&&t.setAttribute("data-left-out",""),!n}),at=(t,e)=>{let n=e;for(;n<k&&!C(t,n+1)&&H(t,n+1)?.value===H(t,e)?.value;)n++;return n},rt=t=>"above"===t?"below":"above",st=(t,e,n)=>{const[o,a]=E(t,e),r=et(s[t][e]).width*f,c=[o-r/2,"above"===n?a-7*f-b:a+7*f,r,b];return c[1]+b>u?Number.POSITIVE_INFINITY:[e-1,e+1].filter(e=>e>=0&&e<=k&&!C(t,e)).flatMap(n=>lt(t,e,n,0)).filter(t=>Z(t,c)).length},lt=(t,e,n,o)=>{const[a,r]=E(t,e),[s,c]=E(t,n),l=Math.max(1,Math.ceil(Math.hypot(s-a,c-r)/(3*f)));return Array.from({length:l+1},(t,e)=>{const n=e/l;return[a+(s-a)*n-o,r+(c-r)*n-o,2*o,2*o]})},it=(e,n)=>{const a=H(e,n);if(!a||a.missing)return"none";if(y&&n>0&&!C(e,n-1)&&H(e,n-1)?.value===a.value)return"none";if(x&&!o[e].focus)return"none";if(g)return"middle";const r=a.value<0?"below":"above";if(!v||x||o.length>2)return t||y||st(e,n,r)<=st(e,n,rt(r))?r:rt(r);const s=H(1-e,n);return!s||s.missing?r:a.value>s.value||a.value===s.value&&0===e||t&&a.value>=0&&E(e,n)[1]+7*f+b>N?"above":"below"},dt=(w||v&&!x&&o.length>2&&!g)&&!y,ht=new Map;if(dt){const t=n.flatMap((t,e)=>a.map(t=>({s:t,i:e,value:H(t,e)?.value??0}))).filter(({s:t,i:e})=>"none"!==it(t,e)).sort((t,e)=>t.i-e.i||e.value-t.value||t.s-e.s),e=t=>t<0?["below","above"]:["above","below"],o=t.map(({s:t,i:n,value:o})=>{const a=et(s[t][n]).width*f,[r,c]=E(t,n);return e(o).map(t=>[r-a/2,"above"===t?c-7*f-b:c+7*f,a,b])}),r=a.flatMap(t=>n.flatMap((e,n)=>{if(C(t,n))return[];const[o,a]=E(t,n);return[[o-4*f,a-4*f,8*f,8*f]]})),c=Q(o,[...r,...ot.map(({box:t})=>t)],[0,0,l(k)+l(0),u]);t.forEach(({s:t,i:n,value:o},a)=>ht.set(s[t][n],null===c[a]?null:e(o)[c[a]]))}a.forEach(t=>{s[t].forEach((e,n)=>{e.style.setProperty("--i",String(Ct(y?(F(n)+F(n+1))/2:F(n))));const o=ht.get(e)??it(t,n);if(e.dataset.place="above"===o?"outside":o,e.toggleAttribute("data-left-out","none"!==o&&((t,e)=>dt?null===ht.get(s[t][e]):!(!g&&!y)&&(et(s[t][e]).width*f>(y?at(t,e)-e+1:1)*S-4*f||!!(g&&t>0&&T(t,e)<_(t,e))||g&&Math.abs(i(_(t,e))-i(T(t,e)))<1.2*b))(t,n)),y&&"none"!==o?e.dataset.rowEnd=String(at(t,n)+1):delete e.dataset.rowEnd,"none"===o)return;const a=et(e).width*f/2+4*f;let r=l(n);y?r=(l(n)+l(at(t,n)))/2:"middle"===o&&0===n?r+=a:"middle"===o&&n===k&&(r-=a);const c=i(T(t,n)),d={middle:(i(_(t,n))-c)/2,above:-7*f,below:7*f};z(e,r,c+d[o],A,u)})});const ft=t=>{const o=n.flatMap((e,n)=>e.pinned&&!C(t,n)?[n]:[]),a=n.map((t,e)=>e).filter(e=>!C(t,e)),r=e=>H(t,e)?.value??0,{keys:c}=e.pick;a.length&&(c.includes("last")&&o.push(a[a.length-1]),c.includes("first")&&o.push(a[0]),c.includes("highest")&&o.push(a.reduce((t,e)=>r(e)>r(t)?e:t)),c.includes("lowest")&&o.push(a.reduce((t,e)=>r(e)<r(t)?e:t)),c.includes("outliers")&&o.push(...((t,e=5,n=25)=>{if(t.length<4)return null;const{mean:o,share:a}=(t=>{const e=t.map(t=>t.y),n=Math.min(...e),o=Math.max(...e),a=n<0&&o>0,r=o-n||1;return{mean:e.reduce((t,e)=>t+e,0)/e.length,share:(t,e)=>t/(a?r:Math.abs(e)||r)*100}})(t),r=e=>t.filter(t=>Math.abs(a(t.y-e(t.x),e(t.x)))>n),s=e=>e.length<=t.length/5;let c=_t(t),l=r(c.at);l.length&&s(l)&&(c=_t(t.filter(t=>!l.includes(t))),l=r(c.at)),s(l)||(c=_t(t),l=[]);const i=c.at,u=t[0],d=t[t.length-1],h=a(i(d.x)-i(u.x),o),f=Math.abs(c.t)>=(b=c.n-2,Et[b-1]??(b<30?2.1:2));var b;const m=Math.abs(a(c.spread,o))<e,$=Math.abs(h)<e?"flat":h>0?"up":"down",p="flat"===$?m?"flat":"unclear":f?$:"unclear";return{course:p,line:i,outside:"unclear"===p?[]:l}})(a.map(t=>({x:t,y:r(t)})))?.outside.map(t=>t.x)??[]));const l=[];for(const e of o){const n=s[t][e];l.includes(e)||"none"===n.dataset.place||l.every(e=>1===ut([s[t][e],n],f,1e3,u))&&l.push(e)}return new Set(l)},bt=t=>{const e=s[t].filter(t=>"none"!==t.dataset.place&&!t.hasAttribute("data-left-out"));return 1===ut(e,f,A,u)},mt=new Map;for(const t of a){const n="all"===e.pick.mode||"auto"===e.pick.mode&&bt(t)?null:ft(t);mt.set(t,n),n&&s[t].forEach((t,e)=>{"none"===t.dataset.place||n.has(e)||t.setAttribute("data-left-out","")})}if(!g&&!y&&a.some(t=>mt.get(t))){const t=l(k)+l(0),e=2*f,o=a.flatMap(t=>n.flatMap((n,o)=>o===k||C(t,o)||C(t,o+1)?[]:lt(t,o,o+1,e))),r=(c[0]?et(c[0]).height:0)*f,i=a.flatMap(t=>{const e=c[t];if(!e)return[];let n=k;for(;n>0&&C(t,n);)n--;const[o,a]=E(t,n);return[[o+10*f,a-r/2,et(e).width*f,r]]}),d=a.flatMap(t=>[...mt.get(t)??[]].map(e=>({s:t,i:e}))),h=({s:t,i:e})=>{const n=H(t,e)?.value??0,o=e>0&&!C(t,e-1)?H(t,e-1)?.value:void 0,a=e<k&&!C(t,e+1)?H(t,e+1)?.value:void 0;return void 0!==(o??a)&&(void 0===o||n<=o)&&(void 0===a||n<=a)?["below","outside","below far","outside far","after","before"]:["outside","below","outside far","below far","after","before"]},m=({s:e,i:n},o)=>{const a=et(s[e][n]).width*f,r=b,[c,l]=E(e,n),i=Math.min(Math.max(c-a/2,0),t-a);return"outside"===o?[i,l-7*f-r,a,r]:"below"===o?[i,l+7*f,a,r]:"outside far"===o?[i,l-7*f-2*r,a,r]:"below far"===o?[i,l+7*f+r,a,r]:"after"===o?[c+7*f,l-r/2,a,r]:[c-7*f-a,l-r/2,a,r]},$=d.map(h),p=e=>e[0]>=0&&e[1]>=0&&e[0]+e[2]<=t&&e[1]+e[3]<=u-2*f,g=d.map(({s:t,i:e})=>{const[n,o]=E(t,e);return[n-6*f,o-6*f,12*f,12*f]}),w=[],y=new Set,M=d.map((t,e)=>{const n=$[e].map(e=>m(t,e)),a=t=>p(t)&&![...w,...i,...g].some(e=>Z(t,e));let r=n.findIndex(t=>a(t)&&!o.some(e=>Z(t,e)));return r<0&&(r=n.findIndex(a),r>=0&&y.add(e)),r>=0&&w.push(n[r]),r<0?null:r});d.forEach((t,e)=>{const n=s[t.s][t.i];n.toggleAttribute("data-cut",y.has(e));const o=M[e];if(null===o)return n.setAttribute("data-left-out","");const a=$[e][o],[r,c,l,i]=m(t,a),d=a.split(" ")[0];n.dataset.place=d,z(n,"after"===d?r:"before"===d?r+l:r+l/2,"outside"===d?c+i:"below"===d?c:c+i/2,A,u)})}y||(()=>{const t=a.map(t=>o[t]),r=o.map((e,n)=>w?St(t,a.indexOf(n)):v?St(o,n):{shape:"circle",open:!1}),s=(t,e,n)=>{const[o,a]=E(t,e);return Ht(r[t].shape,o,a,4*f,{...n,style:`${n.style??""}${s=a,`--rise:${Ct(N-s)}px; `}${R(e)}`});var s},c=t=>n.map((t,e)=>e).filter(e=>!C(t,e)&&((t,e)=>{const n=mt.get(t);return n?n.has(e):S>=10*f})(t,e)),l=a.flatMap(t=>r[t].open?c(t).map(e=>s(t,e,{class:$,"data-row":e+1,...v&&{"data-series":t+1}})):[]);"grow"===p.closest("[data-animate]")?.getAttribute("data-animate")?j(p,l,A,u):e.lineHoles.push(...l),a.forEach(t=>{for(const e of c(t))p.appendChild(s(t,e,{class:m,...B[t].attrs,"data-marker":r[t].shape,...r[t].open&&{"data-open":""},"data-row":e+1,style:B[t].ink}))})})(),e.pointOf=t=>{const e=a.filter(e=>!C(e,t)).map(e=>E(e,t));return e.length?e.reduce((t,e)=>e[1]<t[1]?e:t):null};const $t=(w?[]:c).map((t,e)=>{const n=(t=>{let e=k;for(;e>0&&C(t,e);)e--;return e})(e),[o,a]=E(e,n);return{name:t,x:(y?o+S/2:o)+10*f,y:g?(a+i(_(e,n)))/2:a}}),gt=(c[0]?et(c[0]).height:0)*f;for(const t of((t,e)=>(t.sort((t,e)=>t.y-e.y),t.forEach((n,o)=>{const a=t[o-1];a&&n.y<a.y+e&&(n.y=a.y+e)}),t))($t,gt))z(t.name,t.x,t.y,A,u);const wt=n.some(t=>t.cells.some(t=>!t.missing&&t.value<0)),yt=t||g||2!==o.length||x||wt?N:u-2*f;w||p.appendChild(L("line",{class:r,x1:0,x2:l(k)+l(0),y1:yt,y2:yt}))}}),Ut=Bt(!1),Vt=Bt(!0),Ft=new Set,Rt={segments:t=>{let e=0,o=!1;return t.map(t=>{if(t.isTotal)return o&&((t,e)=>{if(Math.abs(t-e)<=Math.abs(e)/100)return;const o=`[${n}] A total reads ${t}, but the steps before it add up to ${Number(e.toFixed(6))}. The chart shows your number.`;Ft.has(o)||(Ft.add(o),console.warn(o))})(t.value,e),o=!1,e=t.value,{...t,from:0,to:t.value,kind:"total"};const a=e;return e+=t.value,o=!0,{...t,from:a,to:e,kind:t.value>=0?"up":"down"}})},breakable:!0,headroom:({labelHeight:t,badgeHeight:e,hasAnnotations:n,unit:o})=>t+6*o+(n?1.6*e:0),draw({segments:t,cx:e,y:n,barWidth:o,height:s,unit:c,svg:l,values:i,breakAt:u,insideAlign:d}){const h=n(0),f=nt(i,o,c),b=d??"center",m=t.map((e,o)=>{const a=n(Math.max(e.from,e.to)),r=Math.abs(n(e.from)-n(e.to)),s=null!==u&&Math.min(e.from,e.to)<u&&Math.max(e.from,e.to)>u,l="total"===e.kind&&o>0&&o===t.length-1;return{top:a,length:r,down:"down"===e.kind||"total"===e.kind&&(l?e.to>=0:e.to<0),inside:!s&&!f&&ot(i[o],r,c)}}),$=i[0]?et(i[0]).height*c*.56:0;let p=Number.POSITIVE_INFINITY;for(const[a,r]of m.entries())r.inside&&(p=Math.min(p,(o-et(i[a]).width*c)/2));const g=t.length,w=(t,e,n=!1)=>`--start:${(t/g).toFixed(4)}; --span:${(e/g).toFixed(4)}; --ease:${n?H:"linear"};`;t.forEach((a,r)=>{const s=t[r+1];if(!s)return;const c=n(a.to),i=e(r)+o/2,u=e(r+1)-o/2;l.appendChild(L("line",{class:"tablechart-connector",x1:i,x2:u,y1:c,y2:c,"data-row":r+2,style:`${O("--i",s.slot)}; ${w(r+1,1/3)}`}))}),t.forEach((n,r)=>{const{top:u,length:d,down:h,inside:f}=m[r];l.appendChild(L("rect",{class:_(a,n),"data-kind":n.kind,"data-row":r+1,"data-grow":h?"down":"up",x:e(r)-o/2,y:u,width:o,height:Math.max(d,1),style:`${O("--i",n.slot)}; ${w(r,1,r===t.length-1)}`}));const y=i[r];y.style.setProperty("--start",(r/g).toFixed(4)),y.style.setProperty("--span",(1/g).toFixed(4));const M=Math.min(p,(d-$)/2),v="center"===b?u+d/2:"end"===b!==h?u+M+$/2:u+d-M-$/2;y.dataset.place=f?"inside":"outside",y.dataset.kind=n.kind;const x=f?v:"down"===n.kind?u+d+et(y).height*c+3*c:u-3*c;z(y,e(r),x,A,s)}),l.appendChild(L("line",{class:r,x1:0,x2:A,y1:h,y2:h}))}},jt={enabled:!1,log(...t){jt.enabled&&console.log(`[${n}]`,...t)},timed(t,e,o){if(!jt.enabled)return o();const a=performance.now(),r=o(),s=performance.now()-a,c=e.querySelectorAll("tbody tr").length;return s>50?console.warn(`[${n}] ${t} took ${s.toFixed(1)} ms for ${c} rows, more than 50 ms.`,e):jt.log(`${t} took ${s.toFixed(1)} ms for ${c} rows.`,e),r}},qt=t=>{const e=(t?.textContent||"").trim(),n=e.match(/^(.*?)(-?\d+(?:[.,]\d+)?)(.*)$/);return{raw:e,number:n?.[2]??"",prefix:n?.[1]??"",suffix:n?.[3]??"",missing:!n,value:n?Number.parseFloat(n[2].replace(",",".")):0}},It=t=>Array.from(t.querySelector("thead tr:last-child")?.children??[]).slice(1).flatMap((t,e)=>t.hasAttribute("data-note")?[e]:[]),Pt=(t,e="data-i18n")=>{const n=It(t);return Array.from(t.querySelectorAll("tbody tr")).map((t,o)=>{const a=t.querySelector("th"),r=Array.from(t.querySelectorAll("td")),s=r.filter((t,e)=>!n.includes(e)).map(qt);s.length||s.push(qt(null));const c=n.map(t=>r[t]).find(t=>t?.textContent?.trim());return{...s[0],label:(a?.textContent||"").trim(),note:c?.textContent?.trim()??null,noteKey:e&&c?.getAttribute(e)||null,short:a?.getAttribute("data-short")||null,pinned:"show"===t.getAttribute("data-value"),key:e&&a?.getAttribute(e)||null,cells:s,classes:Array.from(t.classList),isTotal:"total"===t.getAttribute("data-kind"),slot:o}})},Dt=t=>Array.from(t.querySelector("thead tr:last-child")?.children??[]).slice(1).filter(t=>!t.hasAttribute("data-note")),Wt=(t,e,n="data-i18n")=>{const o=Dt(t),a=Math.max(1,P(e.map(t=>t.cells.length)));return Array.from({length:a},(t,e)=>{const a=o[e];return{name:(a?.textContent||"").trim(),key:n&&a?.getAttribute(n)||null,focus:"focus"===a?.getAttribute("data-kind"),marker:a?.getAttribute("data-marker")??null,line:(r=a?.getAttribute("data-line"),"dashed"===r||"dotted"===r?r:null),group:!!a?.hasAttribute("data-group"),chart:"line"===a?.getAttribute("data-chart")?"line":null};var r})},Gt=t=>Number(t.toPrecision(12)),Kt=(t,e)=>{const n=t/Math.max(1,e)||1,o=10**Math.floor(Math.log10(n)),a=n/o;return Gt((a<1.42?1:a<3.17?2:a<7.08?5:10)*o)},Yt=(t,e,n)=>{const o=[];for(let a=Math.ceil(t/n-1e-9);a*n<=e+1e-9*n;a++)o.push(Gt(a*n));return o},Xt=(t,e=t)=>{do{const e=Math.round(t/10**Math.floor(Math.log10(t)+1e-9));t=Gt(t*(2===e?2.5:2))}while(Math.abs(t/e-Math.round(t/e))>1e-9);return t},Zt=t=>{const e=(t??"").trim().split(/\s+/).map(Number.parseFloat);return e.length>1&&e.every(Number.isFinite)?e.sort((t,e)=>t-e):null},Qt=(t,e)=>{let{step:n,ticks:o}=t;for(;n&&o.length>2&&!e(o);)n=Xt(n,t.step),o=Yt(t.min,t.max,n);return{...t,step:n,ticks:o}},Jt=["axis-break","trend","bracket"],te=t=>{const e=t.plan;if(!e)return;const n=e=>null===e||t.step-e>=1;for(const o of t.figure.querySelectorAll("[data-from]")){const t=Number(o.dataset.from)-1,a=Number(o.dataset.to)-1,r=o.closest("[data-series]")?.dataset.series,s=r?Number(r)-1:0,c=e.series[s],l=t=>e.cells[t]?.[s]?.step??e.rows[t]?.step??null;let i=t-1;if(c&&null!==c.step)i=n(c.step)?a:t-1;else for(;i<a&&n(l(i+1));)i++;const u=o.hasAttribute("data-flat")?(i-t+1)/(a-t+1):a>t?Math.max(0,i-t)/(a-t):0;o.style.setProperty("--reveal",String(u))}},ee=(t,e,n=!1)=>{const o=t.plan;if(!o)return;const a=Math.min(Math.max(Math.round(e),0),o.count),r=a!==t.step;t.step=a,t.figure.style.setProperty("--_step",String(a)),te(t);const[s,c]=t.controls?.querySelectorAll("button")??[];s&&(s.disabled=0===a),c&&(c.disabled=a===o.count),r&&!n&&t.figure.dispatchEvent(new CustomEvent("tablechart:step",{bubbles:!0,detail:{step:a,steps:o.count}}))},ne="tablechart-tooltip",oe=["--tablechart-surface","--tablechart-tooltip-surface","--tablechart-tooltip-color","--tablechart-tooltip-border","--tablechart-tooltip-radius","--tablechart-tooltip-padding","--tablechart-tooltip-shadow"],ae=null,re=null,se=null,ce=0,le=()=>{clearTimeout(ce),ae&&re&&(ae.hidden=!0,re=null,se=null)},ie=!1,ue=!0,de=NaN,he=NaN,fe=!1,be=(t,e)=>e/Number.parseFloat(getComputedStyle(t).width)||1,me=()=>{clearTimeout(ce),ce=window.setTimeout(le,120)},$e=(t,e)=>{const n=e?e.style.getPropertyValue("--step"):"x";return""===n||Number(n)<t.step},pe=(t,e)=>{const n=t.svg.querySelector(`[data-series="${e+1}"]:not(.tablechart-hole)`);if(!n)return;const o=getComputedStyle(n);return o.fill&&"none"!==o.fill?o.fill:o.stroke},ge=(t,e,n)=>{const o=t.series.length>1,a=[];for(const[s,c]of t.seriesValues.entries()){if(!$e(t,c[e]))continue;const n=o?t.figure.querySelector(`.tablechart-name[data-series="${s+1}"]`):null;a.push({name:o?n?.textContent??t.series[s].name:"",value:c[e].textContent??"",colour:o?pe(t,s):void 0,sample:n?{marker:n.dataset.marker??null,open:n.hasAttribute("data-open"),line:n.dataset.line??null,box:"box"===n.dataset.swatch}:void 0})}const r=t.totals[e];return a.length>1&&$e(t,r)&&a.push({name:n.totallabel,value:r.textContent??""}),a},we=(t,e,n)=>{if(clearTimeout(ce),re===t&&se===e)return;const o=(t.type.tooltip??ge)(t,e,n);if(!o.length)return le();re&&re!==t&&le(),ae??(ae=(()=>{const t=document.createElement("div");return t.className=ne,t.setAttribute("aria-hidden","true"),t.hidden=!0,Tt=document.createElement("div"),(Lt=document.createElement("div")).className=`${ne}-arrow`,t.append(Tt,Lt),document.body.append(t),t.addEventListener("pointerenter",()=>clearTimeout(ce)),t.addEventListener("pointerleave",t=>"mouse"===t.pointerType&&me()),document.addEventListener("pointerdown",e=>{const n=e.target;!re||re.plot.contains(n)||t.contains(n)||le()}),window.addEventListener("resize",le),t})());const a=(t,e,n,o=!1,a)=>{const r=document.createElement("div");if(r.className=`${ne}-line`,n){const t=document.createElement("span");t.className=`${ne}-key`,t.style.background=n,a?.box?t.dataset.sample="box":a&&(t.dataset.sample="line",a.marker&&(t.dataset.marker=a.marker),a.line&&(t.dataset.line=a.line),t.toggleAttribute("data-open",a.open)),r.append(t)}const s=document.createElement("span");if(s.className=`${ne}-${o?"title":"name"}`,s.textContent=t,r.append(s),e){t&&s.append(":");const n=document.createElement("span");n.className=`${ne}-value`,n.textContent=e,r.append(n)}return r},r=(t.figure.querySelectorAll("tbody tr")[e]?.querySelector("th"))?.textContent?.trim()||t.categories[e]?.textContent||t.rows[e].label,s=1===o.length&&!o[0].name,c=o.every(t=>t.name&&!t.value),l=((t,e)=>{const n=It(t),o=t.querySelectorAll("tbody tr")[e]?.querySelectorAll("td")??[];return n.map(t=>o[t]).find(t=>t?.textContent?.trim())??null})(t.figure,e)?.textContent?.trim(),i=l?[Object.assign(document.createElement("div"),{className:`${ne}-note`,textContent:l})]:[];Tt.replaceChildren(...c?[]:[a(r,s?o[0].value:"",void 0,!0)],...s?[]:o.map(({name:t,value:e,colour:n,sample:o})=>a(t,e,n,!1,o)),...i);const u=getComputedStyle(t.figure);for(const m of oe){const t=u.getPropertyValue(m).trim();t?ae.style.setProperty(m,t):ae.style.removeProperty(m)}ae.style.setProperty("--_color",u.color),ae.style.colorScheme=u.colorScheme,ae.style.fontFamily=u.fontFamily;const d=(t=>{const e=t.tooltipparent;return("string"==typeof e?document.querySelector(e):e)??document.body})(n);ae.parentElement!==d&&d.append(ae),re=t,se=e,ae.hidden=!1,ae.style.left="0px",ae.style.top="0px";const h=ae.getBoundingClientRect(),f={x:h.left,y:h.top,scale:be(ae,h.width)},b=be(t.plot,t.plot.getBoundingClientRect().width);ae.style.fontSize=Number.parseFloat(u.fontSize)*b/f.scale+"px",((t,e,n,o={x:0,y:0,scale:1},a=2,r=8,s=12)=>{const c=t.getBoundingClientRect(),l=c.width,i=c.height,u=Number.parseFloat(getComputedStyle(t).borderLeftWidth)||0,d=e.getBoundingClientRect().height/2+(a-u)*o.scale,h=s*o.scale,{clientWidth:f,clientHeight:b}=document.documentElement,m=n.top-r,$=b-n.bottom-r,p=i+d<=m||!(i+d<=$)&&m>=$,g=p?n.top-d-i:n.bottom+d,w=n.left+n.width/2,y=Math.max(r,Math.min(w-l/2,f-l-r));t.style.left=(y-o.x)/o.scale+"px",t.style.top=(Math.max(r,Math.min(g,b-i-r))-o.y)/o.scale+"px",t.dataset.side=p?"top":"bottom",e.style.left=Math.max(h,Math.min(w-y,l-h))/o.scale-u+"px"})(ae,Lt,((t,e)=>{if(t.type.centre&&t.values[e])return t.values[e].getBoundingClientRect();const n=t.pointOf?.(e);if(n){const e=t.svg.getBoundingClientRect(),o=e.width/A,a=4*o*(A/t.plot.clientWidth);return new DOMRect(e.left+n[0]*o-a,e.top+n[1]*o-a,2*a,2*a)}const o=t.svg.querySelectorAll(`[data-row="${e+1}"]:not(.tablechart-connector, .tablechart-leader)`);let a=null;for(const u of o){const t=u.getBoundingClientRect();(t.width||t.height)&&(a=a?new DOMRect(Math.min(a.left,t.left),Math.min(a.top,t.top),Math.max(a.right,t.right)-Math.min(a.left,t.left),Math.max(a.bottom,t.bottom)-Math.min(a.top,t.top)):t)}if(a)return a;const r=t.plot.getBoundingClientRect(),[s,c,l,i]=t.rowBox?.(e)??[0,0,100,100];return new DOMRect(r.left+r.width*s/100,r.top+r.height*c/100,r.width*l/100,r.height*i/100)})(t,e),f)},ye=t=>{re===t&&le()},Me={area:Vt,bar:vt,column:xt,donut:Nt,line:Ut,waterfall:Rt},ve={"axis-break":I,trend:bt,bracket:X,reference:ft,note:dt},xe=Object.keys(ve),ke=t=>{let e="";for(let n=t.previousSibling;n&&(e=(n.textContent??"")+e,!e.trim());n=n.previousSibling);return e.trim()},Ne=["straight","step","smooth"],Ae=(t,e,n,o,a)=>{const r=e===o,[s,c,l]=r?[Math.min(t,n),Math.max(t,n),e]:[Math.min(e,o),Math.max(e,o),t],i=a.filter(([t,e,n,o])=>r?e<=l&&l<=e+o:t<=l&&l<=t+n).map(([t,e,n,o])=>r?[t,t+n]:[e,e+o]).sort((t,e)=>t[0]-e[0]),u=[];let d=s;for(const[h,f]of i)h>d&&u.push([d,Math.min(h,c)]),d=Math.max(d,f);return d<c&&u.push([d,c]),u.map(([t,e])=>r?`M${T(t)},${T(l)}H${T(e)}`:`M${T(l)},${T(t)}V${T(e)}`).join("")},Se=(t,e)=>{const[n,o,a,r]=["x1","y1","x2","y2"].map(e=>Number(t.getAttribute(e))),s=L("path",{d:Ae(n,o,a,r,e)});for(const{name:c,value:l}of Array.from(t.attributes))/^[xy][12]$/.test(c)||s.setAttribute(c,l);t.replaceWith(s)},He=t=>Array.from((t.getAttribute("d")??"").matchAll(/M(-?[\d.]+),(-?[\d.]+)([HV])(-?[\d.]+)/g),([,t,e,n,o])=>"H"===n?[+t,+e,+o,+e]:[+t,+e,+t,+o]),Ce=(t,[e,n,o,a])=>t.map(([t,r,s,c])=>r===c?n<=r&&r<=n+a&&Math.max(t,e)<Math.min(s,e+o)?`M${T(Math.max(t,e))},${T(r)}H${T(Math.min(s,e+o))}`:"":e<=t&&t<=e+o&&Math.max(r,n)<Math.min(c,n+a)?`M${T(t)},${T(Math.max(r,n))}V${T(Math.min(c,n+a))}`:"").join(""),Oe=(t,e,n)=>{const o=t.getAttribute(e);return null===o?n:"false"!==o},Te=(t,e)=>Boolean(e.animate)&&"false"!==t.getAttribute("data-chart-animate"),Le=(t,e)=>{const n=t.dataset.chartShape;return n&&Ne.includes(n)?n:Ne.includes(e.shape)?e.shape:"straight"},_e=0,Ee=(t,e,a=null)=>{const r=a??(t.getAttribute("data-chart")||"column"),s=Me[r];if(!s)return console.warn(`[${n}] Unknown chart type "${r}". Known types: ${Object.keys(Me).join(", ")}.`),t.setAttribute("data-chart-empty",""),null;const c=Pt(t,e.langattribute);if(!c.length)return console.warn(t.querySelector("table")?`[${n}] A chart has no rows in its table, so there is nothing to draw.`:`[${n}] A chart has no table, so there is nothing to draw.`,t),t.setAttribute("data-chart-empty",""),null;(t=>{const e=t.querySelector(":scope > figcaption");if(!e)return;(t=>{for(const e of t.querySelectorAll("br")){if(e.previousElementSibling?.classList.contains("tablechart-sr"))continue;if(/[.!?:;,…]$/.test(ke(e)))continue;const t=document.createElement("span");t.className=w,t.textContent=". ",e.before(t)}})(e);const n=t=>t.hasAttribute("aria-label")||t.hasAttribute("aria-labelledby"),o=t=>{e.id||(e.id="tablechart-caption-"+ ++_e),t.setAttribute("aria-labelledby",e.id)};"FIGURE"!==t.tagName||n(t)||o(t);const a=t.querySelector("table");!a||n(a)||a.querySelector(":scope > caption")||o(a)})(t);let l=Wt(t,c,e.langattribute);if(l.length>1&&!s.series&&!s.columns&&(console.warn(`[${n}] A ${r} chart uses only the first of its ${l.length} value columns.`),l=l.slice(0,1)),l.some(t=>t.chart)){const t=s.lines?l.every(t=>t.chart)?'Every series has data-chart="line", so the chart is a line chart: set data-chart="line" on the figure.':null:`A ${r} chart cannot draw a series as a line.`;t&&(console.warn(`[${n}] ${t}`),l=l.map(t=>({...t,chart:null})))}const i=l.some(t=>t.chart),u=l.length>1;u&&t.style.setProperty("--_series-count",String(l.length));const d=t.hasAttribute("data-chart-stack");d&&!s.stackable&&console.warn(`[${n}] A ${r} chart cannot be stacked.`),d&&i&&console.warn(`[${n}] A chart with a line cannot be stacked.`);const h=d&&!!s.stackable&&u&&!i,m=document.createElement("div");m.className="tablechart-plot",m.setAttribute("aria-hidden","true");const $=L("svg",{role:"presentation",focusable:"false"});m.appendChild($);const g=t.querySelector(":scope > table"),y=e=>g?g.before(e):t.append(e);y(m);const M=s.centre?c.filter(t=>!t.isTotal):c,v=Math.max(0,P(M.flatMap(t=>t.cells.slice(0,l.length).map(t=>D(t.number))))),N=l.map((t,e)=>Math.max(0,P(c.map(t=>D(t.cells[e]?.number??""))))),A=document.createElement("div");A.className="tablechart-values",m.appendChild(A);const S=l.map((t,e)=>c.map((t,n)=>{const a=t.cells[e]??t.cells[0],r=E(o,A);return r.classList.add(...t.classes),r.dataset.value=String(a.value),a.prefix&&(r.dataset.prefix=a.prefix),a.suffix&&(r.dataset.suffix=a.suffix),a.missing&&(r.dataset.missing=a.raw),u&&(r.dataset.series=String(e+1)),s.columns&&(r.dataset.decimals=String(N[e])),r.dataset.row=String(n+1),r.style.setProperty("--i",String(t.slot)),!1===s.numbers&&(e||n)&&(r.dataset.place="none"),r})),H=S[0],C=h&&s.totals?c.map((t,e)=>{const n=E(o,A);n.classList.add(...t.classes),n.dataset.kind="total",n.dataset.row=String(e+1),n.dataset.value=String(wt(t,l.length));const a=t.cells[0];return a.prefix&&(n.dataset.prefix=a.prefix),a.suffix&&(n.dataset.suffix=a.suffix),n.style.setProperty("--i",String(t.slot)),n}):[],O=c[c.length-1],T=l.some(t=>t.focus),_=t.getAttribute("data-chart-legend"),z=u&&!s.columns&&(null===_?e.legend||void 0!==s.legend:"false"!==_)?document.createElement("div"):null;z&&(z.className=b,z.setAttribute("aria-hidden","true"),z.inert=!0);const B=l.filter(t=>t.chart),U=u&&!s.columns?l.map((n,o)=>{const a=E(f,z??m);z&&(a.dataset.place="legend");const r=n.chart?void 0:s.legend??s.swatch;if(r&&(a.dataset.swatch=r),a.textContent=n.name,!r&&"step"!==Le(t,e)){const t=n.chart?St(B,B.indexOf(n)):St(l,o);a.dataset.marker=t.shape,a.toggleAttribute("data-open",t.open)}return n.line&&!r&&(a.dataset.line=n.line),n.key&&e.langattribute&&a.setAttribute(e.langattribute,n.key),a.dataset.series=String(o+1),a.style.setProperty("--n",String(o)),a.style.setProperty("--palette",`var(--tablechart-color-${o+1})`),a.style.setProperty("--m",T&&!n.focus?"1":"0"),a.style.setProperty("--i",String(O.slot)),a}):[],V=s.centre?E(p,m):null;if(V){const t=c.find(t=>t.isTotal),e=t?t.value:c.reduce((t,e)=>t+Math.abs(e.value),0);V.dataset.value=String(e),t&&(V.dataset.decimals=String(D(t.number)))}const F=V&&!c.some(t=>t.isTotal)?((t,e,n)=>{const o=t.querySelector("table");if(!o)return null;const a=o.querySelector("tfoot [data-chart-total]");if(a)return a.dataset.value=e.dataset.value??"0",a;const r=(o.tFoot??o.createTFoot()).insertRow(),s=document.createElement("th");s.scope="row",s.textContent=n.totallabel;const c=t.getAttribute("data-chart-keys");c&&n.langattribute&&s.setAttribute(n.langattribute,`${c}-total`);const l=r.insertCell();return l.setAttribute("data-chart-total",""),l.dataset.value=e.dataset.value??"0",r.prepend(s),l})(t,V,e):null,R="beside"===s.categories,j=document.createElement("div");j.className="tablechart-categories",j.setAttribute("aria-hidden","true"),j.inert=!0,R?j.dataset.place="beside":s.centre&&(j.dataset.place="key"),j.style.setProperty("--_columns",String(c.length));let q=0;for(const[n,o]of c.entries()){const t=document.createElement("span");t.classList.add(...o.classes),t.textContent=o.short??o.label,o.key&&e.langattribute&&t.setAttribute(e.langattribute,o.short?`${o.key}-short`:o.key),s.centre&&(t.dataset.kind=o.isTotal?"total":"slice",o.isTotal||(t.dataset.slice=String(q+1),t.style.setProperty("--n",String(q)),t.style.setProperty("--palette",`var(--tablechart-color-${q+1})`),q+=1)),t.style.setProperty("--i",String(o.slot)),t.dataset.row=String(n+1),j.appendChild(t)}R?m.appendChild(j):y(j),z&&y(z);const I=l.filter(t=>!t.group),W=!s.axes&&!s.centre&&Oe(t,"data-chart-axis",e.axis),G=s.axes?{titles:I.slice(0,2).map((t,n)=>{const o=E(`${x}-title`,m);return o.dataset.axis=n?"y":"x",o.textContent=t.name,t.key&&e.langattribute&&o.setAttribute(e.langattribute,t.key),o}),ticks:E(`${k}s`,m),numbers:!0}:W||!s.centre&&Oe(t,"data-chart-grid",e.grid)?{titles:[],ticks:E(`${k}s`,m),numbers:W}:null;s.text?.({figure:t,plot:m,rows:c,series:l,config:e});const K=Te(t,e)?((t,e=!1)=>{const n=t.hasAttribute("data-fragment"),o=Array.from(t.querySelectorAll("tbody tr")),a=Array.from(t.querySelector("thead tr:last-child")?.children??[]).slice(1),r=Array.from(t.querySelectorAll("[data-annotation]")).filter(t=>Jt.includes(t.getAttribute("data-annotation")??"")),s=t=>t.hasAttribute("data-fragment"),c=o.map(t=>Array.from(t.querySelectorAll(":scope > td")));if(!(n||o.some(s)||a.some(s)||c.flat().some(s)||r.some(s)))return null;if(e&&!n)return null;const l=[],i=new Map,u=[],d=t=>{let e=null!==t?i.get(t):void 0;return void 0===e&&(e=l.length,l.push(t),u.push(0),null!==t&&i.set(t,e)),e};let h=0;const f="donut"===t.getAttribute("data-chart"),b=t=>f&&"total"===t.getAttribute("data-kind"),m=e?d(t.getAttribute("data-fragment-index")):-1,$=o.map(t=>{if(b(t))return{step:null,slot:0};if(e)return{step:m,slot:u[m]++};if(!n&&!s(t))return{step:null,slot:h++};const o=d(t.getAttribute("data-fragment-index"));return{step:o,slot:u[o]++}}),p=Math.max(-1,...$.map(t=>t.step??-1));if(p>=0)for(const[M,v]of o.entries())b(v)&&($[M]={step:p,slot:u[p]++});const g=a.map(t=>({step:s(t)?d(t.getAttribute("data-fragment-index")):null})),w=c.map(t=>t.map(()=>({step:null,slot:0}))),y=Math.max(0,...c.map(t=>t.length));for(let M=0;M<y;M++)for(const[t,e]of c.entries()){const n=e[M];if(!n||!s(n))continue;const o=d(n.getAttribute("data-fragment-index"));w[t][M]={step:o,slot:u[o]++}}return{rows:$,series:g,cells:w,notes:r.map(t=>{const e=(e,n)=>{const o=Number.parseInt(t.getAttribute(e)??"",10);return Number.isFinite(o)?o-1:n},[n,o]="bracket"===t.getAttribute("data-annotation")?[e("data-from",0),e("data-to",$.length-1)]:[0,$.length-1];let a=null;for(let s=Math.min(n,o);s<=Math.max(n,o);s++)for(const t of[$[s]?.step??null,...(w[s]??[]).map(t=>t.step)])null!==t&&(null===a||t>a)&&(a=t);const r=g[e("data-series",0)]?.step??null;null!==r&&(null===a||r>a)&&(a=r),s(t)&&(a=d(t.getAttribute("data-fragment-index")));const c=null===a?$.length:$.filter(t=>t.step===a).length;return{step:a,after:c}}),count:l.length,indexes:l}})(t,Boolean(s.axes)):null;s.axes&&t.querySelector("tbody [data-fragment], thead [data-fragment]")&&jt.log(`A ${r} chart has one step, with data-fragment on the figure; its rows and columns have no steps of their own.`,t),K&&t.setAttribute("data-steps","");const Y=t.getAttribute("data-chart-keys"),X=K&&e.controls?((t,e,n)=>{const o=document.createElement("div");o.className="tablechart-controls";const a=o=>{const a=document.createElement("button");a.type="button",a.className=`tablechart-${o}`,a.dataset.go=o;const r=document.createElement("span");r.className="tablechart-control-icon",r.setAttribute("aria-hidden","true");const s=L("svg",{viewBox:"0 0 16 16",focusable:"false"});s.appendChild(L("path",{d:"next"===o?"M6 3l5 5-5 5":"M10 3L5 8l5 5"})),r.appendChild(s);const c=document.createElement("span");c.className="tablechart-control-label",c.textContent=t[o];const l=e[o];l&&n&&c.setAttribute(n,l);const i=document.createElement("span");return i.className=w,i.textContent=t.hint,e.hint&&n&&i.setAttribute(n,e.hint),a.append(..."next"===o?[c,i,r]:[r,c,i]),a};return o.append(a("previous"),a("next")),o})({previous:e.previouslabel,next:e.nextlabel,hint:e.stephint},{previous:Y&&`${Y}-previous`,next:Y&&`${Y}-next`,hint:Y&&`${Y}-step`},e.langattribute):null;X&&y(X);const Z=Array.from(t.querySelectorAll("[data-annotation]")).map(t=>{const e=t.getAttribute("data-annotation"),o=ve[e];if(!o)return console.warn(`[${n}] Unknown annotation "${e}". Known annotations: ${Object.keys(ve).join(", ")}.`),null;const a=Number.parseInt(t.getAttribute("data-series")??"1",10),r=a>=1&&a<=l.length?a-1:0;return a!==r+1&&console.warn(`[${n}] An annotation reads line ${a}, which is not there; it reads line 1.`),{spec:t,type:o,badge:o.create(t,m),series:r,after:c.length}}).filter(t=>null!==t);if(!R&&!s.centre&&!s.axes)for(const[n,o]of c.entries()){if(!o.note)continue;const t=document.createElement("span");t.dataset.annotation="note",t.dataset.row=String(n+1),t.textContent=o.note,o.noteKey&&t.setAttribute("data-i18n",o.noteKey),Z.push({spec:t,type:dt,badge:dt.create(t,m),series:0,after:c.length})}Te(t,e)&&t.setAttribute("data-animate",Ue(t,r,e,Boolean(K)));const Q={figure:t,plot:m,svg:$,rows:c,decimals:v,type:s,values:H,series:l,seriesValues:S,names:z?[]:U,categories:Array.from(j.children),centre:V,axes:G,stacked:h,totals:C,totalCell:F,rowAt:null,rowBox:null,pointOf:null,annotations:Z,checks:[],plan:K,step:0,controls:X},J=()=>We(t,$);$.addEventListener("transitionend",J),$.addEventListener("transitioncancel",J),X?.addEventListener("click",t=>{const e=t.target.closest("button")?.dataset.go;e&&ee(Q,Q.step+("next"===e?1:-1))}),ee(Q,0,!0);const tt=t.getAttribute("data-chart-tooltip"),et="false"!==tt&&("auto"===tt?"auto":null!==tt||e.tooltip);return et&&((t,e,n=!1)=>{const{plot:o}=t;o.setAttribute("data-hover",""),(()=>{if(fe)return;fe=!0,document.addEventListener("pointermove",t=>{"mouse"===t.pointerType&&(ue=t.screenX!==de||t.screenY!==he,de=t.screenX,he=t.screenY,ue&&(ie=!1))},{capture:!0,passive:!0});const t=()=>{ie=!0,le()};document.addEventListener("keydown",t,!0),window.addEventListener("scroll",t,{capture:!0,passive:!0})})();const a=new Set,r=t=>{for(const e of a)if(e.isConnected){if(e.getAttribute("data-row")===String(t+1))return!0}else a.delete(e);return!1};let s=null;const c=a=>{if("pointerdown"===a.type)ie=!1;else if("mouse"===a.pointerType&&(!ue||ie))return;if(!o.classList.contains("is-placed")||!t.figure.classList.contains("is-shown"))return;if(n&&!t.figure.hasAttribute("data-left-out"))return re===t?le():void 0;const c=(e=>{if(t.rowAt){const n=o.getBoundingClientRect(),a=be(o,n.width);return t.rowAt((e.clientX-n.left)/a,(e.clientY-n.top)/a)}const n=e.target.closest?.("[data-row]")?.getAttribute("data-row");return n?Number(n)-1:null})(a);if(s=c,null===c||r(c))return re===t?le():void 0;we(t,c,e)},l=e=>{const n=e.target;return t.svg.contains(n)&&n.hasAttribute("data-row")?n:null};t.svg.addEventListener("transitionrun",t=>{const e=l(t);e&&a.add(e)});const i=n=>{const o=l(n);if(!o)return;a.delete(o);const c=Number(o.getAttribute("data-row"))-1;s!==c||r(c)||ie||we(t,c,e)};t.svg.addEventListener("transitionend",i),t.svg.addEventListener("transitioncancel",i),o.addEventListener("pointermove",c),o.addEventListener("pointerdown",c),o.addEventListener("pointerleave",e=>{"mouse"===e.pointerType&&(s=null,re===t&&me())})})(Q,e,"auto"===et),Ie(Q,e),Q},ze={grow:"grow",sweep:"sweep"},Be=["never","auto","print","always"],Ue=(t,e,n,o)=>{const a="line"===e||"area"===e,r=ze[t.getAttribute("data-chart-animate")??""]??ze[String(n.animate)];return a?o?"sweep":r??"sweep":"donut"===e||"waterfall"===e?r??"grow":"grow"},Ve=t=>{const e=getComputedStyle(t).getPropertyValue("--tablechart-value-align").trim();return"start"===e||"center"===e||"end"===e?e:null},Fe=(t,e,n,o)=>{const a=getComputedStyle(t),r=(a.getPropertyValue(n).trim()||o).match(/^(\d+(?:\.\d+)?)(px|%|em|rem)$/);if(!r)return null;const s=Number(r[1]);return"%"===r[2]?s/100*A:s*("em"===r[2]?Number.parseFloat(a.fontSize):"rem"===r[2]?Number.parseFloat(getComputedStyle(document.documentElement).fontSize):1)*e},Re=(t,e)=>Fe(t,e,"--tablechart-bar-max","60px")??Number.POSITIVE_INFINITY,je=["first","last","highest","lowest","outliers"],qe=(t,e)=>{const o=(t.getAttribute("data-chart-values")??e.values).trim().toLowerCase().split(/\s+/).filter(Boolean);for(const r of o)["auto","all","none",...je].includes(r)||console.warn(`[${n}] data-chart-values knows no "${r}". It takes auto, all, none, ${je.join(", ")}.`);const a=o.filter(t=>je.includes(t));return o.includes("all")?{mode:"all",keys:[]}:o.includes("none")?{mode:"set",keys:[]}:o.includes("auto")||!a.length?{mode:"auto",keys:a.length?a:je}:{mode:"set",keys:a}},Ie=(t,e)=>{const n=[...t.seriesValues.flat(),...t.totals,...t.totalCell?[t.totalCell]:[]];for(const o of t.centre?[...n,t.centre]:n)void 0!==o.dataset.missing?o.textContent=o.dataset.missing:Pe(o,o.dataset.decimals?Number(o.dataset.decimals):t.decimals,e.locale)},Pe=(t,e,n)=>{const{prefix:o="",suffix:a=""}=t.dataset,[r,s]=W(Number.parseFloat(t.dataset.value||"0"),e,n);if(t.textContent=o+(o?r:"")+s+a,r&&!o){const e=document.createElement("span");e.className="tablechart-minus",e.textContent=r,t.prepend(e)}},De=(t,e,n=!1)=>{if(e||t.figure.hasAttribute("data-steps")||Ge(t.svg),n)return t.figure.classList.add(v),t.figure.classList.toggle(y,e),t.figure.offsetWidth,e&&Ke(t.svg),void requestAnimationFrame(()=>t.figure.classList.remove(v));t.figure.classList.toggle(y,e),e&&requestAnimationFrame(()=>requestAnimationFrame(()=>We(t.figure,t.svg)))},We=(t,e)=>{t.classList.contains("is-shown")&&Array.from(e.querySelectorAll("[data-mask]")).every(t=>!t.getAnimations({subtree:!0}).length)&&Ke(e)},Ge=t=>{for(const e of t.querySelectorAll('[mask^="url(#tablechart-cut-"]'))e.dataset.mask=e.getAttribute("mask")??"",e.removeAttribute("mask")},Ke=t=>{for(const e of t.querySelectorAll("[data-mask]"))e.setAttribute("mask",e.dataset.mask??""),e.removeAttribute("data-mask")},Ye=t=>"id"===t||"style"===t||t.startsWith("data-chart"),Xe=/^\s*(?:Table)?:\s+/,Ze=t=>"P"===t?.tagName&&Xe.test(t.textContent??""),Qe=/^\s*([a-z][\w-]*)((?:\s+[\w-]+=[^\s:]+)*)\s*(:\s*|$)/,Je=t=>{const e=en(t);return"P"===e?.tagName?e:t},tn=t=>{if(!t||"object"!=typeof t)return;const e=Object.entries(t),n=t=>null===t||"string"==typeof t||"number"==typeof t;return e.length&&e.every(([,t])=>n(t)||Array.isArray(t)&&t.every(n))?e.map(([t,e])=>Array.isArray(e)?{label:t,values:e}:{label:t,value:e}):void 0},en=t=>{const e=Array.from(t.childNodes).filter(t=>t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE&&t.textContent?.trim());return 1===e.length&&e[0]instanceof HTMLElement?e[0]:null},nn="strong, b, span.total",on="data-chart-made",an=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,rn=new Set,sn=null,cn=["column","bar"],ln=t=>{const e=t.getAttribute("data-chart")||"column";if(!cn.includes(e))return null;const n=getComputedStyle(t).getPropertyValue("--tablechart-type").trim();return cn.includes(n)?n:e},un=!1,dn=async(t,e)=>{const o=(t=>t.map(t=>{const e=t.closest("p"),n=Ze(e)?e:t;if("TABLE"!==n.tagName&&"P"!==n.tagName)return n;const o=document.createElement("figure");((t,e)=>{for(const{name:n,value:o}of Array.from(t.attributes))("class"===n||Ye(n))&&(e.setAttribute(n,o),t.removeAttribute(n))})(t,o),t.classList.length||t.removeAttribute("class");const a="TABLE"===n.tagName?n:null,r=n.previousElementSibling;let s=n.nextElementSibling;const c=a?Ze(r)?r:Ze(s)?s:null:n;a&&c===s&&(s=s?.nextElementSibling??null);const l=s?.classList.contains("chart-annotations")?s:(t=>{if("UL"!==t?.tagName&&"OL"!==t?.tagName)return null;const e=Array.from(t.children),n=e.map(t=>t.hasAttribute("data-annotation")?null:(t=>{const e=Je(t).firstChild;if(e?.nodeType!==Node.TEXT_NODE)return null;const n=Qe.exec(e.textContent??"");if(!n||!xe.includes(n[1]))return null;if(!n[3]&&e.nextSibling)return null;const o=n[2].trim().split(/\s+/).filter(Boolean).map(t=>t.split("="));return{name:n[1],options:o,text:e,length:n[0].length}})(t));return!e.length||e.some((t,e)=>!n[e]&&!t.hasAttribute("data-annotation"))?null:(e.forEach((t,e)=>{const o=n[e],a=Je(t);if(a!==t&&a.replaceWith(...a.childNodes),o){t.setAttribute("data-annotation",o.name);for(const[e,n]of o.options)t.setAttribute(`data-${e}`,n);o.text.textContent=(o.text.textContent??"").slice(o.length)}t.children.length&&Array.from(t.childNodes).filter(t=>t.nodeType===Node.ELEMENT_NODE||t.textContent?.trim()).forEach((t,e)=>{const n=document.createElement("span");0===e&&t instanceof HTMLElement&&t.matches("em, i")?(n.className="tablechart-caption",n.append(...t.childNodes),t.replaceWith(n)):t.nodeType===Node.TEXT_NODE&&(n.textContent=(t.textContent??"").trim(),t.replaceWith(n))})}),t.classList.add("chart-annotations"),t)})(s);return n.replaceWith(o),c&&o.append((t=>{const e=document.createElement("figcaption");for(const{name:r,value:s}of Array.from(t.attributes))e.setAttribute(r,s);const n=t.firstChild;n?.nodeType===Node.TEXT_NODE&&(n.textContent=(n.textContent??"").replace(Xe,""),n.textContent||n.remove());const o=Array.from(t.childNodes),a=o.findIndex(t=>"BR"===t.nodeName);if(e.append(...-1===a?o:o.slice(0,a+1)),-1!==a&&a<o.length-1){const t=document.createElement("span");t.append(...o.slice(a+1)),e.append(t)}return t.remove(),e})(c)),a&&o.append(a),l&&o.append(l),jt?.log?.(`A ${a?"table":"caption"} with chart attributes was wrapped in a figure of its own`),o}))(t.filter(t=>!t.hasAttribute(on)&&"TH"!==t.tagName));(t=>{const e=t.find(t=>"FIGURE"!==t.tagName);!un&&e&&(un=!0,console.warn(`[${n}] A chart is a <${e.tagName.toLowerCase()}>. Use a <figure> with a <figcaption>, so the chart has a title, also for screen readers.`,e))})(o),await(async t=>{await Promise.all(t.filter(t=>t.hasAttribute("data-chart-src")).map(async t=>{const e=t.getAttribute("data-chart-src"),o=Array.from(t.querySelectorAll("table")).find(t=>t.tHead)??null;for(const n of t.querySelectorAll("table"))n!==o&&n.remove();try{const n=await fetch(e);if(!n.ok)throw new Error(`${n.status} ${n.statusText}`);const a=await n.json(),r=Array.isArray(a)?a:a?.rows?Array.isArray(a.rows)?a.rows:tn(a.rows):tn(a);if(!Array.isArray(r))throw new Error("no rows in it: a list of rows, an object with rows, or names with their values");const s=((t,e,n,o=document.createElement("table"),a="Note")=>{for(const l of o.querySelectorAll(":scope > tbody, :scope > tfoot, :scope > tr"))l.remove();const r=t.some(t=>t.note);if(!o.tHead&&(e.length||n||r)){const t=o.createTHead().insertRow(),a=document.createElement("th");a.textContent=n,t.append(a);for(const n of e){const e=document.createElement("th");e.textContent=n,t.append(e)}}const s=document.createElement("tbody");o.append(s);for(const l of t){const t=s.insertRow();"total"===l.kind&&(t.dataset.kind="total");const e=document.createElement("th");e.textContent=String(l.label??""),l.short&&(e.dataset.short=l.short),t.append(e);for(const n of l.values??[l.value??null])t.insertCell().textContent=null===n?"":String(n);r&&(t.insertCell().textContent=l.note??"")}const c=o.tHead?.rows[o.tHead.rows.length-1];if(r&&c&&!c.querySelector("[data-note]")){const e=Math.max(...t.map(t=>(t.values??[t.value]).length));for(;c.cells.length<e+1;)c.append(document.createElement("th"));const n=document.createElement("th");n.dataset.note="",n.textContent=a,c.append(n)}return o})(r,Array.isArray(a?.series)?a.series.map(String):[],"string"==typeof a?.label?a.label:"",o??void 0,"string"==typeof a?.note?a.note:void 0);if(!o){const e=t.querySelector(":scope > figcaption");e?e.after(s):t.prepend(s)}s.tHead||jt?.log?.(`The table from "${e}" has no header row, so a screen reader cannot name its columns.`),jt?.log?.(`Read ${r.length} rows from "${e}"`)}catch(a){const t="file:"===window.location.protocol;console.warn(`[${n}] Could not read the chart data in "${e}": ${a.message}.`+(t?" A page opened as a file cannot fetch files; open it from a server.":""))}}))})(o),(t=>{for(const e of t){for(const n of e.querySelectorAll("tbody tr")){const t=n.cells[0];if("TD"!==t?.tagName||n.cells.length<2)continue;const e=document.createElement("th");for(const{name:n,value:o}of Array.from(t.attributes))e.setAttribute(n,o);e.append(...t.childNodes),t.replaceWith(e);for(let o=en(e);o?.matches(nn);o=en(e))n.dataset.kind="total",o.replaceWith(...o.childNodes)}const t=Array.from(e.querySelector("thead tr:last-child")?.children??[]);for(const e of t.slice(1))for(let t=en(e);t?.matches(nn);t=en(e))e.setAttribute("data-kind","focus"),t.replaceWith(...t.childNodes)}})(o),((t,e)=>{if(!e)return;const o=new Map;for(const a of t){let t=a.getAttribute("data-chart-keys")||null;if(!t)continue;if(o.has(t)){const e=o.get(t)+1;o.set(t,e),console.warn(`[${n}] Two charts have data-chart-keys="${t}", so this one uses "${t}-${e}" to keep their translations apart.`),t=`${t}-${e}`}else o.set(t,1);a.querySelectorAll("tbody th").forEach((n,o)=>{n.getAttribute(e)||n.setAttribute(e,`${t}-row${o+1}`)});const r=Dt(a);r.length>1&&r.forEach((n,o)=>{n.getAttribute(e)||n.setAttribute(e,`${t}-col${o+1}`)}),r.forEach((n,o)=>{if(!n.hasAttribute("data-group"))return;const r=[];a.querySelectorAll(`tbody tr > td:nth-of-type(${o+1})`).forEach(n=>{const o=(n.textContent||"").trim();r.includes(o)||r.push(o),n.getAttribute(e)||n.setAttribute(e,`${t}-group${r.indexOf(o)+1}`)})});const s=It(a);a.querySelectorAll("tbody tr").forEach((n,o)=>{const a=n.querySelectorAll("td");for(const r of s){const n=a[r];n?.textContent?.trim()&&!n.getAttribute(e)&&n.setAttribute(e,`${t}-note${o+1}`)}}),jt?.log?.(`Keys for "${t}" written onto ${a.querySelectorAll("tbody th").length} rows`)}})(o,e.langattribute);for(const n of o)n.dispatchEvent(new CustomEvent("tablechart:table",{bubbles:!0}));return o},hn=(t,e)=>{const o=jt.timed("Building",t,()=>Ee(t,e));return o?(t.setAttribute(on,""),((t,e)=>{let o=t,r=ln(o.figure),m=null,g=!1,w=!1;const y=async()=>{if(!Te(o.figure,e))return De(o,!0);const t=o.figure.classList.contains("is-shown");if(!g||null===m||t||w)!g&&e.replay&&t&&De(o,!1);else{w=!0;const t=an()?null:(t=>{for(let e=t;e&&e!==document.body;e=e.parentElement)if("0"===getComputedStyle(e).opacity)return e;return null})(o.figure);t&&await(n=t,new Promise(t=>{const e=["animationstart","transitionrun"],o=()=>{for(const t of e)document.removeEventListener(t,a,!0);r.disconnect(),t()},a=t=>{t.target instanceof Node&&t.target.contains(n)&&o()},r=new MutationObserver(()=>{"0"!==getComputedStyle(n).opacity&&o()});for(const n of e)document.addEventListener(n,a,!0);r.observe(n,{attributes:!0,attributeFilter:["class","style"]})})),await(async(t,e)=>{if(an())return;await new Promise(requestAnimationFrame);const n=t.getAnimations().filter(t=>t instanceof CSSAnimation);for(let r=t.parentElement;r&&r!==document.body;r=r.parentElement)n.push(...r.getAnimations());let o=0;for(const r of n){const t=r.effect?.getComputedTiming(),n=Number(t?.activeDuration??0);if(!t||!Number.isFinite(n))continue;const a=Number(t.delay??0)+n*e;o=Math.max(o,a-Number(r.currentTime??0))}var a;o>0&&await(a=o,new Promise(t=>setTimeout(t,a)))})(o.figure,((t,e)=>{const n=Number.parseFloat(t.dataset.chartEntrance??""),o=Number.isFinite(n)?n:e.entrance;return Math.min(Math.max(o,0),1)})(o.figure,e)),w=!1,!g&&e.replay||De(o,!0)}var n},v=()=>{const t=ln(o.figure);if(!t||t===r)return;const n=jt.timed("Building",o.figure,()=>Ee(o.figure,e,t));n&&((t=>{ye(t),t.plot.remove(),t.categories[0]?.parentElement?.remove(),t.figure.querySelector(`:scope > .${b}`)?.remove(),t.controls?.remove()})(o),ee(n,o.step,!0),o=n,r=t,m=null)},S=()=>{v();const t=o.plot.clientWidth;t&&t!==m&&jt.timed("Layout",o.figure,()=>((t,e)=>{const{plot:o,svg:r,rows:m,type:g,values:w,series:y,seriesValues:M,names:v,annotations:S}=t;(({figure:t,rows:e,series:n},o)=>{const a=t.getAttribute("data-chart-table"),r=a&&Be.includes(a)?a:o.table;"never"===r?t.removeAttribute("data-table"):t.setAttribute("data-table",r);const s=t.getAttribute("data-chart-summary");t.setAttribute("data-summary",s&&Be.includes(s)?s:o.summary),t.toggleAttribute("data-long",e.length*n.filter(t=>!t.group).length>o.tablelimit)})(t,e);const H=Number.parseFloat(t.figure.dataset.chartAspect??""),O=H>0?H:g.aspect??e.aspect,_="beside"===g.categories,B=t.axes&&!g.axes?t.axes:null,U=_?null:t.categories[0]?.parentElement;let V=null;if(B){o.style.margin="",U&&(U.style.marginLeft="");const n=o.clientWidth;if(!n)return!1;const a=g.segments?.(m)??[],r=t.stacked?m.flatMap(t=>Object.values(gt(t,y.length,g.running))):a.some(t=>"up"===t.kind||"down"===t.kind)?a.flatMap(t=>[t.from,t.to]):m.flatMap(t=>t.cells.slice(0,y.length).filter(t=>!t.missing).map(t=>t.value)),s=Math.min(0,-P(r.map(t=>-t))),c=Math.max(0,P(r)),l=Number.parseFloat(getComputedStyle(o).fontSize)||16,{chartScaleY:i,chartScale:u}=t.figure.dataset,d=Zt(i??u);if(d&&d.length>2)V={min:d[0],max:d[d.length-1],step:0,ticks:d};else{const[t,e]=d??[s,c],o=Kt(e-t,Math.max((_?n/9:n*O/3)/l,2)),a=(t,e)=>d?t:Number(((e?Math.ceil:Math.floor)(t/o-1e-9*(e?1:-1))*o).toPrecision(12)),r=a(t,!1),i=a(e,!0);V={min:r,max:i,step:o,ticks:Yt(r,i,o)}}B.ticks.textContent="";const h=m.find(t=>!t.missing),f=P(V.ticks.map(t=>D(String(t))));for(const t of V.ticks){const n=E(k,B.ticks);n.dataset.value=String(t),n.dataset.place="none",h?.prefix&&(n.dataset.prefix=h.prefix),h?.suffix&&(n.dataset.suffix=h.suffix),Pe(n,f,e.locale)}if(B.numbers){const t=Array.from(B.ticks.children);for(const e of t)delete e.dataset.place;tt(t),_?o.style.marginBottom=`${(t[0]?et(t[0]).height:0)+6}px`:(o.style.marginLeft=`${P([0,...t.map(t=>et(t).width)])+10}px`,U&&(U.style.marginLeft=o.style.marginLeft))}}const F=o.clientWidth;if(!F)return!1;const q=A/F,I=A*O;o.classList.add("is-placed");const W=!1===g.numbers?w.slice(0,1):[...M.flat(),...t.totals];for(const n of W)delete n.dataset.place,n.removeAttribute("data-left-out"),n.removeAttribute("data-cut");o.style.removeProperty("--_fit"),o.toggleAttribute("data-grouped",!!g.groups&&!t.stacked&&y.filter(t=>!t.chart&&!t.group).length>1),t.categories[0]?.parentElement?.style.removeProperty("--_beside");const G=g.axes?t.axes:null;let K=[];if(G){const n=Number.parseFloat(getComputedStyle(o).fontSize)||16,a=y.flatMap((t,e)=>t.group?[]:[e]).slice(0,2),r=m.filter(t=>a.every(e=>t.cells[e]&&!t.cells[e].missing)),{chartScaleX:s,chartScaleY:c,chartScale:l}=t.figure.dataset,i=[Zt(s),Zt(c??l)];K=a.map((t,e)=>((t,e,n)=>{if(n&&n.length>2)return{min:n[0],max:n[n.length-1],step:0,ticks:n};let o=n?.[0]??-P(t.map(t=>-t)),a=n?.[1]??P(t);if(!n){const t=.05*(a-o||Math.abs(a)||1);o-=t,a+=t}const r=Kt(a-o,e);return{min:o,max:a,step:r,ticks:Yt(o,a,r)}})(r.length?r.map(e=>e.cells[t].value):[0,1],Math.max(e?I/q/(4*n):F/(9*n),4),i[e])),G.ticks.textContent="",K.forEach((t,n)=>{const o=r[0]?.cells[a[n]],s=P(t.ticks.map(t=>D(String(t))));for(const a of t.ticks){const t=E(k,G.ticks);t.dataset.axis=n?"y":"x",t.dataset.value=String(a),o?.prefix&&(t.dataset.prefix=o.prefix),o?.suffix&&(t.dataset.suffix=o.suffix),Pe(t,s,e.locale)}})}const Y=G?Array.from(G.ticks.children):[];tt([...M.flat(),...t.totals,...v,...t.categories,...S.map(t=>t.badge),...G?.titles??[],...Y]);const X=(w[0]?et(w[0]).height:0)*q;!1===g.numbers&&w[0]&&(w[0].dataset.place="none");const Z=S[0]?.badge?et(S[0].badge).height*q:0,Q=Math.max(I,Fe(t.figure,q,"--tablechart-min-height","200px")??0,g.minHeight?.({labelHeight:X,nameHeight:Math.max(0,P(t.categories.map(t=>et(t).height)))*q,unit:q,rows:m.length,series:y.length,stacked:t.stacked})??0),J=t.stacked?m.map(t=>{const e=wt(t,y.length);return{...t,value:e,cells:t.cells.map((t,n)=>0===n?{...t,value:e}:t)}}):m,nt=(g.segments??(t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"}))))(t.stacked?J.map(t=>({...t,cells:[t.cells[0]]})):m),ot={labelHeight:X,badgeHeight:Z,hasAnnotations:S.length>0,unit:q,series:y.length,focused:y.some(t=>t.focus),stacked:t.stacked},at=Math.max((st=P,t.stacked?st(m.map(t=>gt(t,y.length,g.running).top)):st([...nt.flatMap(t=>[t.from,t.to,t.value]),...m.flatMap(t=>t.cells.slice(0,y.length).map(t=>t.value))])),0);var st;const ct=nt.some(t=>"up"===t.kind||"down"===t.kind)?nt.flatMap(t=>[t.from,t.to]):t.stacked?m.map(t=>gt(t,y.length,g.running).bottom):m.flatMap(t=>t.cells.slice(0,y.length).map(t=>t.value)),ut=Math.min(-P(ct.map(t=>-t)),0),dt=y.flatMap((t,e)=>t.chart?[e]:[]),ht=m.some(t=>t.note)?Z+4*q:0,ft=Math.max(g.headroom?.(ot)??X,dt.length?Ut.headroom?.(ot)??0:0)+ht,bt=2*q+(g.footroom?.(ot)??0)+(ut<0?X+4*q:0),mt=Q-ft-bt,$t=V?Math.max(V.max,at):1.02*at,pt=V?Math.min(V.min,ut):1.02*ut,yt=S.find(t=>"axis-break"===t.spec.getAttribute("data-annotation"))?.spec,Mt=t=>{const e=Number.parseFloat(yt?.getAttribute(t)??"");return Number.isFinite(e)?e:null},vt=Mt("data-from")??Mt("data-at"),xt=Mt("data-to");let kt=null;if(yt&&(null!==vt||null!==xt)){const t=vt??0,e=xt??$t,o=null===xt?t:null===vt?e:(t+e)/2,a=yt.getAttribute("data-size"),r=a?.match(/^\s*(\d+(?:\.\d+)?)\s*%\s*$/);null===a||r||console.warn(`[${n}] data-size="${a}" is not a percentage, such as 30%. Using the default.`);const s=Math.min(Math.max(r?Number(r[1])/100:null===xt?.22:.3,.05),.8),c=nt.filter(n=>("up"===n.kind||"down"===n.kind)&&Math.max(n.from,n.to)>t&&Math.min(n.from,n.to)<e);g.breakable?ut<0?console.warn(`[${n}] A chart with values below zero cannot break its scale.`):t<0||e<=t||e>$t||0===t&&e===$t?console.warn(`[${n}] A break from ${t} to ${e} does not fit a scale that runs from 0 to ${at}.`):c.length?console.warn(`[${n}] A break from ${t} to ${e} would cut a step that floats. Keep it below or above the steps.`):kt={lo:t,hi:e,gap:o,share:s}:console.warn(`[${n}] This kind of chart cannot break its scale.`)}const Nt=kt?kt.gap:null,At=(kt&&Fe(t.figure,q,"--tablechart-break-gap",""))??13,St=Q-bt,Ht=$t-pt||1;let Ct,Ot,Tt=t=>St-(t-pt)/Ht*mt;if(kt){const{lo:t,hi:e,gap:n,share:o}=kt,a=mt*o,r=(mt-a-At)/(t+($t-e)),s=a/(e-t);Tt=o=>o<=t?St-o*r:o<=n?St-t*r-(o-t)*s:o<=e?St-t*r-(o-t)*s-At:St-t*r-a-At-(o-e)*r}let Lt=[];if(G){const t=6*q,[e,n]=G.titles,o=t=>t?et(t).width*q:0,a=t=>t?et(t).height*q:0,r=Y.filter(t=>"x"===t.dataset.axis),s=Y.filter(t=>"y"===t.dataset.axis),c=a(Y[0]),l=o(n)+P([0,...s.map(o)])+2*t,i=c/2;Ot=[l,i,A-l-P([0,...r.map(o)])/2,Q-i-a(e)-c-2*t];const[u,d,h,f]=Ot,[b,m]=K,$=t=>u+(t-b.min)/(b.max-b.min||1)*h,p=t=>d+f-(t-m.min)/(m.max-m.min||1)*f;Ct=$,Tt=p;const g=t=>o(r.find(e=>Number(e.dataset.value)===t));Lt=[Qt(b,e=>e.every((n,o)=>!o||$(n)-$(e[o-1])>(g(n)+g(e[o-1]))/2+t)).ticks,Qt(m,e=>e.every((n,o)=>!o||p(e[o-1])-p(n)>c+t/2)).ticks];for(const w of Y){const e=Number(w.dataset.value),n="x"===w.dataset.axis?0:1,o=Lt[n].includes(e);w.dataset.place=o?n?"before":"below":"none",o&&z(w,n?u-t:$(e),n?p(e):d+f+t,A,Q)}e&&z(e,u+h/2,Q-a(e),A,Q),n&&z(n,0,d+f/2,A,Q)}const _t=v.length?P(v.map(t=>et(t).width))*q+12*q:0,Et=t.categories[0]?.parentElement;Et&&(Et.style.paddingRight=_t?_t/A*100+"%":"");const zt=(A-_t)/m.length,Bt=t=>t>=0&&t<m.length?t:null;t.rowAt=g.centre?null:"beside"===g.categories?(t,e)=>Bt(Math.floor(e*q/(Q/m.length))):t=>Bt(Math.floor(t*q/zt));const Ft=zt/A*100,Rt=100/m.length;if(t.rowBox="beside"===g.categories?t=>[0,t*Rt,100,Rt]:t=>[t*Ft,0,Ft,100],r.setAttribute("viewBox",`0 0 1000 ${T(Q)}`),r.textContent="",Ot&&Ct){const[n,o,a,s]=Ot,[c,l]=Lt,i=Ct;Oe(t.figure,"data-chart-grid",e.grid)&&r.appendChild(L("path",{class:N,d:[...c.map(t=>`M${T(i(t))},${T(o)}V${T(o+s)}`),...l.map(t=>`M${T(n)},${T(Tt(t))}H${T(n+a)}`)].join("")})),r.appendChild(L("path",{class:x,d:[`M${T(n)},${T(o)}V${T(o+s)}H${T(n+a)}`,...c.map(t=>`M${T(i(t))},${T(o+s)}v${T(4*q)}`),...l.map(t=>`M${T(n)},${T(Tt(t))}h${T(-4*q)}`)].join("")}))}t.checks=[];const jt={rows:m,segments:nt,cx:t=>(t+.5)*zt,y:Tt,x:Ct,frame:Ot,length:(e,n)=>Fe(t.figure,q,e,n),barWidth:Math.min(zt*e.barfill,Re(t.figure,q)),barMax:Re(t.figure,q),height:Q,unit:q,labelHeight:X,badgeHeight:Z,after:m.length,note:0,labels:"inside"===t.figure.dataset.chartLabels||"outside"!==t.figure.dataset.chartLabels&&("inside"===e.labels||dt.length>0)?"inside":"outside",insideAlign:Ve(t.figure),breakAt:Nt,squeeze:kt,breakGap:At,domain:V?[V.min,V.max]:null,stacked:t.stacked,shape:Le(t.figure,e),pick:qe(t.figure,e),totals:t.totals,svg:r,plot:o,values:w,series:y,own:y.map((t,e)=>e),seriesValues:M,names:v,categories:t.categories,centre:t.centre,config:e,checks:t.checks,taken:[],lineHoles:[]};o.style.setProperty("--count",String(Math.max(1,...m.map(t=>t.slot+1))));const qt=t=>{const e=e=>({...e,...e.cells[t]??e.cells[0]});return{rows:m.map(e),segments:nt.map(t=>{const n=e(t);return"bar"===t.kind?{...n,to:n.value}:n}),values:M[t]}};if(dt.length){const t=y.flatMap((t,e)=>t.chart?[]:[e]);g.draw({...jt,own:t,...1===t.length&&qt(t[0])}),Ut.draw({...jt,own:dt})}else g.draw(jt);jt.rowAt&&(t.rowAt=jt.rowAt),t.pointOf=jt.pointOf??null;const It=Number(o.style.getPropertyValue("--count"))||m.length;for(const n of t.figure.querySelectorAll(`.${f}`))n.style.setProperty("--i",String(Math.min(m[m.length-1].slot,It-1)));if(!t.stacked&&!o.hasAttribute("data-grouped"))for(const n of M)lt(n,q,A),it(n,q,A,Q);if(B&&V){const n=6*q,o=_&&jt.x?jt.x:Tt,a=Array.from(B.ticks.children),s=t=>et(a.find(e=>Number(e.dataset.value)===t)??a[0]),c=Qt(V,t=>t.every((e,a)=>!a||(_?o(e)-o(t[a-1])>(s(e).width+s(t[a-1]).width)/2*q+n:o(t[a-1])-o(e)>s(e).height*q+n/2))).ticks.filter(t=>!kt||t<=kt.lo||t>=kt.hi);for(const t of a){const e=Number(t.dataset.value),a=B.numbers&&c.includes(e);t.dataset.place=a?_?"below":"before":"none",a&&z(t,_?o(e):-n,_?Q+n:o(e),A,Q)}const l=A-_t;Oe(t.figure,"data-chart-grid",e.grid)&&r.prepend(L("path",{class:N,d:c.map(t=>_?`M${T(o(t))},0V${T(Q)}`:`M0,${T(o(t))}H${T(l)}`).join("")})),B.numbers&&r.appendChild(L("path",{class:x,d:[_?`M${T(o(V.min))},${T(Q)}H${T(o(V.max))}`:`M0,${T(o(V.max))}V${T(o(V.min))}`,...c.map(t=>_?`M${T(o(t))},${T(Q)}v${T(4*q)}`:`M0,${T(o(t))}h${T(-4*q)}`)].join("")}))}for(const[n,a]of S.entries()){a.badge?.setAttribute("data-note",String(n+1));const e=a.series;a.type.draw(a.spec,a.badge,{...jt,...t.stacked&&{rows:J,...t.totals.length&&{values:t.totals}},...e>0&&!t.stacked&&qt(e),after:t.plan?a.after:Math.min(a.after,Number(o.style.getPropertyValue("--count"))||a.after),note:n+1})}(t=>{const e=t.plan;if(!e)return;const n=e.rows.length-1,o=t=>e.series.map((n,o)=>e.cells[t]?.[o]?.step??n.step??e.rows[t]?.step??null),r=t=>{const e=o(t);return e.some(t=>null===t)?null:Math.min(...e)},s=new Set(t.totals),c=Boolean(t.type.axes),l=(t,e,n,o)=>{c&&"--i"===n||t.style.setProperty(n,String(o)),t.style.removeProperty("--d"),null===e?t.style.removeProperty("--step"):t.style.setProperty("--step",String(e))};for(const a of t.figure.querySelectorAll("[data-row], [data-series], [data-note]")){if(a.closest("table, .tablechart-controls")||a.hasAttribute("data-from"))continue;const t=Number(a.dataset.note);if(t>0){const n=e.notes[t-1];n&&l(a,n.step,"--after",n.after);continue}const c=a.dataset.row?Number(a.dataset.row)-1:n;if(a.classList.contains("tablechart-connector")){const t=e.rows[c-1],n=e.rows[c];if(t&&n){const e=(t.step??-1)>(n.step??-1);l(a,e?t.step:n.step,"--i",e?t.slot+1:n.slot)}continue}if(s.has(a)){const t=o(c).filter(t=>null!==t);l(a,t.length?Math.max(...t):null,"--i",e.rows[c]?.slot??0);continue}if(a.hasAttribute("data-stack")){l(a,r(c),"--i",e.rows[c]?.slot??0);continue}const i=a.dataset.series?Number(a.dataset.series)-1:0,u=a.dataset.series?e.series[i]:void 0;if(a.classList.contains("tablechart-piece")){const t=o(c)[i]??null,n=e.cells[c]?.[i];l(a,t===r(c)?null:t,"--i",n&&null!==n.step?n.slot:c);continue}if("legend"===a.dataset.place){const t=Math.min(...e.cells.map(t=>t[i]?.step??Number.POSITIVE_INFINITY));l(a,u?.step??(Number.isFinite(t)?t:null),"--i",0);continue}const d=e.cells[c]?.[i];d&&null!==d.step?l(a,d.step,"--i",d.slot):u&&null!==u.step?l(a,u.step,"--i",c):e.rows[c]&&l(a,e.rows[c].step,"--i",e.rows[c].slot)}const i=t.figure.querySelector(`.${p}`);if(i){const t=[...e.rows,...e.cells.flat()].map(t=>t.step??-1),n=Math.max(-1,...t);n<0?l(i,null,"--i",0):l(i,n,"--i",t.filter(t=>t===n).length)}const d=[...e.rows,...e.cells.flat()].map(t=>t.slot+1),h=e.series.some(t=>null!==t.step)?e.rows.length:1;c||t.plot.style.setProperty("--count",String(Math.max(h,...d)));const f=t.figure.querySelectorAll(`.${a}`),b=f[f.length-1];if("waterfall"===t.figure.dataset.chart&&"total"===b?.dataset.kind&&f.length>1){const t=Number(b.dataset.row)-1;(e.rows[t-1]?.step??-1)>(e.rows[t]?.step??-1)&&(b.dataset.grow="down"===b.dataset.grow?"up":"down")}const m=Array.from(t.figure.querySelectorAll(`.${u}`));if(m.length){const e=t=>t.style.getPropertyValue("--step")||"none",n=t=>Number(t.style.getPropertyValue("--share")||0),o=m.length,a=Math.max(0,m.findIndex((t,n)=>e(t)!==e(m[(n-1+o)%o]))),r=[];for(let t=0;t<o;t++){const n=m[(a+t)%o],s=r[r.length-1];s&&e(s[0])===e(n)?s.push(n):r.push([n])}const s=new Map;for(const t of r){const e=t.reduce((t,e)=>t+n(e),0);let o=0;for(const a of t)s.set(a.dataset.row??"",C(o,n(a),e)),o+=n(a)}for(const c of t.figure.querySelectorAll("[data-row]")){const t=s.get(c.dataset.row??"");t&&c.style.getPropertyValue("--start")&&(c.style.setProperty("--start",t.start.toFixed(4)),c.style.setProperty("--span",t.span.toFixed(4)),c.classList.contains("tablechart-slice")&&c.style.setProperty("--ease",t.easing))}}te(t)})(t);for(const n of t.figure.querySelectorAll(`.${b}`)){const e=Array.from(n.children);if(t.plan)for(const t of e)t.style.getPropertyValue("--step")||t.style.setProperty("--i","0");const o=e.map(t=>Number.parseFloat(t.style.getPropertyValue("--step")));n.style.setProperty("--i",String(Math.min(...e.map(t=>Number(t.style.getPropertyValue("--i"))||0)))),o.length&&o.every(Number.isFinite)?n.style.setProperty("--step",String(Math.min(...o))):n.style.removeProperty("--step")}const Pt=t.categories[0]?.parentElement;if(Pt&&"beside"!==g.categories&&!g.centre){Pt.style.height=`${Pt.offsetHeight}px`,Pt.removeAttribute("data-thinned");for(const e of t.categories)e.removeAttribute("data-left-out"),e.removeAttribute("data-edge");const n=t.categories.filter(t=>null!==t.offsetParent);if(!rt(Pt,n,t=>({size:t.scrollWidth,room:t.clientWidth}),"--_name-fit")&&n.length>1){const t=getComputedStyle(Pt),e=(Pt.clientWidth-Number.parseFloat(t.paddingLeft)-Number.parseFloat(t.paddingRight))/m.length;Pt.style.setProperty("--_name-fit","1"),Pt.setAttribute("data-thinned","");const o=P(n.map(t=>t.offsetWidth)),a=8,r=Math.max(Math.ceil((o+a)/e),Math.ceil((1.5*o+a)/e-.5),1);n.forEach((t,e)=>{e%r&&t.setAttribute("data-left-out","")});const s=n.filter(t=>!t.hasAttribute("data-left-out")),c=s[0],l=s.at(-1),i=Pt.getBoundingClientRect(),u=[c,l].map(t=>t?.getBoundingClientRect());if(c&&u[0]&&u[0].left<i.left&&c.setAttribute("data-edge","start"),l&&l!==c&&u[1]&&u[1].right>i.right-Number.parseFloat(t.paddingRight)){l.setAttribute("data-edge","end");const t=s.at(-2);t&&t.getBoundingClientRect().right+a>l.getBoundingClientRect().left&&l.setAttribute("data-left-out","")}}const o=(g===Ut||g===Vt)&&Oe(t.figure,"data-chart-ticks",e.ticks);if(Pt.toggleAttribute("data-ticks",o),Pt.style.removeProperty("--_tick-reach"),o){const e=Q-Number(r.querySelector(".tablechart-rule")?.getAttribute("y1")??Q);e>0&&e<10*q&&Pt.style.setProperty("--_tick-reach",`${T(e/q)}px`);const n=Pt.getBoundingClientRect(),o=n.width/(Pt.offsetWidth||1),a=getComputedStyle(Pt),s=Number.parseFloat(a.paddingLeft),c=(Pt.clientWidth-s-Number.parseFloat(a.paddingRight))/m.length;t.categories.forEach((t,e)=>{if(t.hasAttribute("data-left-out"))t.style.removeProperty("--_tick");else{const a=(t.getBoundingClientRect().left-n.left)/o-Pt.clientLeft;t.style.setProperty("--_tick",`${T(s+(e+.5)*c-a)}px`)}})}Pt.style.height=""}const Dt=S.flatMap(({badge:t})=>{if(!(t instanceof HTMLElement&&t.offsetWidth))return[];const e=t.offsetWidth*q,n=t.offsetHeight*q,o=Number.parseFloat(t.style.left)/100*A,a=Number.parseFloat(t.style.top)/100*Q,r=getComputedStyle(t).borderTopLeftRadius,s=r.endsWith("%")?Number.parseFloat(r)/100:null,c=(Number.parseFloat(r)||0)*q;return[L("rect",{class:$,"data-for":"badge","data-note":t.dataset.note??"",x:o-e/2,y:a-n/2,width:e,height:n,rx:null===s?c:e*s,ry:null===s?c:n*s,style:["--after","--step"].map(e=>t.style.getPropertyValue(e)&&`${e}:${t.style.getPropertyValue(e)}`).filter(Boolean).join("; ")})]}),Wt=r.querySelector(`.${N}`),Gt=Array.from(r.querySelectorAll(`.${c}`)),Xt=[...Wt?[Wt]:[],...r.querySelectorAll(`:scope > .${l}`)],Jt=((t,e)=>{const n=t.getBoundingClientRect(),o=A/n.width,a=getComputedStyle(t),r=Number.parseFloat(a.lineHeight)/Number.parseFloat(a.fontSize)||1.2;return t=>{if("none"===t.dataset.place||t.hidden||t.hasAttribute("data-left-out"))return[];const a=t.getBoundingClientRect(),s=a.height*o/r,c=Array.from(t.style).filter(t=>t.startsWith("--")).map(e=>`${e}:${t.style.getPropertyValue(e)}`);return a.width?[L("rect",{class:$,"data-for":"text",x:(a.left-n.left)*o-3*e,y:(a.top-n.top)*o+(a.height*o-s)/2-e,width:a.width*o+6*e,height:s+2*e,style:c.join("; ")})]:[]}})(o,q),ee="grow"===t.figure.getAttribute("data-animate"),ne=M.flat().filter(t=>t.hasAttribute("data-cut")).flatMap(Jt),oe=[...dt.flatMap(t=>M[t].flatMap(Jt)),...ee?ne:[]];if(Xt.length||Gt.length){const e=[...M.flat(),...t.totals,..."beside"===g.categories?t.categories:[]].flatMap(Jt),n=t=>["x","y","width","height"].map(e=>Number(t.getAttribute(e)));for(const t of Gt)Se(t,[...e,...Dt].map(n));if(Xt.length&&t.plan)j(r,e,A,Q,Xt);else for(const t of Xt){const o=[...e,...Dt],a=He(t);t.setAttribute("d",a.map(([t,e,a,r])=>Ae(t,e,a,r,o.map(n))).join(""));for(const e of o){const o=Ce(a,n(e)),r="badge"===e.dataset.for?"badge":"";o&&t.after(L("path",{class:t.getAttribute("class")??"tablechart-grid","data-gap":r,d:o,style:e.getAttribute("style")??""}))}}}if(R(r,Dt,A,Q,Array.from(r.querySelectorAll(`.${s}, .${i}`))),!ee&&(jt.lineHoles.length||ne.length)){const t=Array.from(r.querySelectorAll(`.${d}`)).map(t=>{const e=L("g",{});return t.before(e),e.append(t),e});R(r,[...jt.lineHoles,...ne],A,Q,[...t,...r.querySelectorAll(`.${h}`)])}const ae=[c,l,s,i,...t.plan?[]:[N]];j(r,[...Dt,...oe],A,Q,void 0,ae.map(t=>`.${t}`).join(", ")),!t.figure.hasAttribute("data-animate")||t.figure.hasAttribute("data-steps")||t.figure.classList.contains("is-shown")||Ge(r);const re=t=>"none"!==t.dataset.place&&!t.hasAttribute("data-left-out");return t.figure.toggleAttribute("data-left-out",(g.columns?[t.categories]:[...M,t.totals]).some(t=>t.some(e=>!(t=>void 0!==t.dataset.missing||g.centre&&m[Number(t.dataset.row)-1]?.isTotal)(e)&&!re(e)&&!((t,e)=>{const n=Number(t.dataset.row);return e.some(t=>re(t)&&Number(t.dataset.row)<=n&&n<=Number(t.dataset.rowEnd??t.dataset.row))})(e,t)))),!0})(o,e))&&(m=t,y())};let H=!1;const O=new ResizeObserver(()=>{H||(H=!0,requestAnimationFrame(()=>{H=!1,S()}))}),_=new IntersectionObserver(t=>{for(const e of t)g=e.isIntersecting,y()},{threshold:e.threshold}),B=()=>{o.figure.classList.add(M),De(o,!0),Ke(o.svg),o.figure.offsetWidth},U=()=>o.figure.classList.remove(M),V=()=>{m=null,S()},F={relabel:()=>Ie(o,e),refresh:V};v(),S(),O.observe(o.figure),_.observe(o.figure),window.addEventListener("beforeprint",B),window.addEventListener("afterprint",U),(t=>{rn.add(t),sn||(sn=new MutationObserver(()=>{for(const t of rn)t.relabel();requestAnimationFrame(()=>requestAnimationFrame(()=>{for(const t of rn)t.refresh()}))})).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]})})(F);const q={figure:o.figure,refresh:V,next:()=>ee(o,o.step+1),previous:()=>ee(o,o.step-1),stepTo:t=>ee(o,t),get step(){return o.step},get steps(){return o.plan?.count??0},destroy(){O.disconnect(),_.disconnect(),window.removeEventListener("beforeprint",B),window.removeEventListener("afterprint",U),(t=>{rn.delete(t),!rn.size&&sn&&(sn.disconnect(),sn=null)})(F),ye(o),o.figure.tablechart===q&&delete o.figure.tablechart}};return o.figure.tablechart=q,q})(o,e)):null},fn=e({GRID_CLASS:()=>N,LEGEND_CLASS:()=>b,LIBRARY_NAME:()=>n,NAME_CLASS:()=>f,POINT_CLASS:()=>m,QUADRANT_CLASS:()=>l,VIEWBOX_WIDTH:()=>A,avoidCollisions:()=>Q,boxOf:()=>ct,decimalsIn:()=>D,htmlEl:()=>E,largest:()=>P,markerEl:()=>Ht,overlaps:()=>Z,placeAt:()=>z,readSeries:()=>Wt,readTable:()=>Pt,short:()=>T,sizeOf:()=>et,splitSign:()=>W,svgEl:()=>L});window.Tablechart={init:async(t={},e=document)=>{const n={...S,...t};n.debug&&(jt.enabled=!0);const o=(await dn(Array.from(e.querySelectorAll(n.selector)),n)).map(t=>hn(t,n)).filter(t=>null!==t);return jt.log(`Made ${o.length} chart(s).`),{charts:o,refresh:()=>{for(const t of o)t.refresh()},destroy:()=>{for(const t of o)t.destroy()}}},create:async(t,e={})=>{if(t.tablechart)return t.tablechart;const n={...S,...e};n.debug&&(jt.enabled=!0);const[o]=await dn([t],n);return o?hn(o,n):null},defaultConfig:S,addType:(t,e)=>{Me[t]=e,Object.assign(ve,e.annotations),xe.splice(0,1/0,...Object.keys(ve))},kit:fn}}();
@@ -1 +1 @@
1
- export { c as addType, t as create, M as defaultConfig, r as init } from "./tablechart-shared.mjs";
1
+ export { c as addType, t as create, G as defaultConfig, r as init } from "./tablechart-shared.mjs";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@martinomagnifico/tablechart",
3
- "version": "1.1.2",
4
- "description": "Simple charts from an HTML or Markdown table: column, bar, line, area, waterfall and donut, with annotations. A chart builds when it scrolls into view.",
3
+ "version": "1.2.0",
4
+ "description": "Simple charts from an HTML or Markdown table: column, bar, line, area, waterfall, donut and scatter plot. Accessibility first.",
5
5
  "type": "module",
6
6
  "sideEffects": [
7
7
  "**/*.css",
@@ -24,6 +24,10 @@
24
24
  "types": "./dist/tablechart-additional-types.d.mts",
25
25
  "import": "./dist/tablechart-additional-types.mjs"
26
26
  },
27
+ "./summary": {
28
+ "types": "./dist/tablechart-summary.d.mts",
29
+ "import": "./dist/tablechart-summary.mjs"
30
+ },
27
31
  "./style.css": "./dist/tablechart.css"
28
32
  },
29
33
  "files": [
@@ -31,6 +35,9 @@
31
35
  "README.md",
32
36
  "CHANGELOG.md"
33
37
  ],
38
+ "workspaces": [
39
+ "docs"
40
+ ],
34
41
  "scripts": {
35
42
  "start": "cd docs && npm start",
36
43
  "dev": "vite",
@@ -39,14 +46,16 @@
39
46
  "check:variables": "node scripts/variables.mjs",
40
47
  "docs:preview": "npm run build && cd docs && rm -rf dist && npm run build && npm run preview",
41
48
  "preview": "npm run docs:preview",
49
+ "prebuild": "node scripts/lock-version.mjs",
42
50
  "build": "npm run clean && npm run build:lib",
43
51
  "build:lib": "vite build",
44
52
  "size": "node scripts/size.mjs",
45
53
  "test": "npm run build && node test/speed.test.mjs",
46
54
  "test:layout": "node test/layout.test.mjs",
55
+ "lab": "node lab/pdf/lab.mjs",
56
+ "lab:pdf": "node lab/pdf/lab.mjs --pdf",
47
57
  "prepack": "npm run build",
48
- "clean": "rm -rf dist",
49
- "setup": "cd docs && npm install"
58
+ "clean": "rm -rf dist"
50
59
  },
51
60
  "keywords": [
52
61
  "chart",
@@ -60,6 +69,7 @@
60
69
  "license": "MIT",
61
70
  "devDependencies": {
62
71
  "@vituum/vite-plugin-pug": "^2.0.1",
72
+ "liquidjs": "^10.30.0",
63
73
  "rolldown-plugin-dts": "^0.28.8",
64
74
  "sass": "^1.97.3",
65
75
  "terser": "^5.46.0",
@@ -74,5 +84,10 @@
74
84
  "allowScripts": {
75
85
  "@parcel/watcher": false,
76
86
  "fsevents": false
87
+ },
88
+ "overrides": {
89
+ "vite-plugin-static-copy": {
90
+ "chokidar": "^4.0.3"
91
+ }
77
92
  }
78
93
  }