@martinomagnifico/tablechart 1.0.7 → 1.1.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="tablechart",e="tablechart-value",n="tablechart-bar",a="tablechart-rule",o="tablechart-line",r="tablechart-head",s="tablechart-slice",c="tablechart-legend",l="tablechart-hole",i="tablechart-centre",u="tablechart-break",d="tablechart-sr",h="is-printing",f=1e3,b={selector:"[data-chart]",aspect:.38,barfill:.58,ringfill:.42,animate:!0,entrance:.5,labels:"outside",shape:"straight",legend:!1,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"},m="cubic-bezier(0.3, 0.3, 0.6, 1)",p=(t,e,n=1)=>({start:t,span:e,easing:t+e>=n-1e-4?m:"linear"}),g=(t,e)=>`${t}:${e}`,w=t=>Math.round(100*t)/100,$=(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?w(t):t))}return n},y=(t,e)=>[t,...e.classes].join(" "),M=(t,e)=>{const n=document.createElement("span");return n.className=t,n.inert=!0,e.appendChild(n),n},v=(t,e,n,a,o)=>{t.style.left=e/a*100+"%",t.style.top=n/o*100+"%"},k=0,x=(t,e,n,a)=>{if(!e.length)return;const o="tablechart-cut-"+ ++k,r=$("mask",{id:o,maskUnits:"userSpaceOnUse"});r.appendChild($("rect",{x:-n,y:-a,width:3*n,height:3*a,fill:"white"}));for(const l of e)l.setAttribute("fill","black"),r.appendChild(l);let s=t.querySelector(":scope > defs");s||(s=$("defs"),t.prepend(s)),s.appendChild(r);const c=$("g",{mask:`url(#${o})`});for(const l of Array.from(t.childNodes))l!==s&&c.appendChild(l);t.appendChild(c)},N=0,A={create:()=>null,draw(t,e,a){const{rows:o,y:r,svg:s,breakAt:c}=a;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]]},d=(t,e=!1)=>t.map(([t,e],n)=>`${0===n?"M":"L"} ${t.toFixed(1)} ${e.toFixed(1)}`).join(" ")+(e?" Z":""),h="tablechart-break-"+ ++N,f=$("mask",{id:h,maskUnits:"userSpaceOnUse"});f.appendChild($("rect",{x:-1e3,y:-a.height,width:3e3,height:3*a.height,fill:"white"}));const b=[],m=r(c);for(const M of(t=>Array.from(t.querySelectorAll(`.${n}`)).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=M.sideways?a.breakX:m;if(void 0===t)continue;if(!(M.sideways?M.x<t&&M.x+M.width>t:M.y<m&&M.y+M.height>m))continue;const[e,n]=M.sideways?[i(M,t),i(M,t+a.breakGap)]:[i(M,m-a.breakGap),i(M,m)];f.appendChild($("path",{d:d([...e,...n.slice().reverse()],!0),fill:"black"})),b.push(e,n);const r=[g("--after",o[M.row-1]?.slot??0),M.part].filter(Boolean).join("; ");for(const o of[e,n])s.appendChild($("path",{class:u,"data-part":"edge","data-note":a.note,d:d(o),style:r}))}if(!b.length)return;const p=Array.from(s.querySelectorAll(`.${u}`)),w=$("g",{mask:`url(#${h})`});for(const n of Array.from(s.childNodes))p.includes(n)||w.appendChild(n);const y=$("defs");y.appendChild(f),s.prepend(y,w)}},S=t=>{let e=Number.NEGATIVE_INFINITY;for(const n of t)e=Math.max(e,n);return e},H=t=>(t.split(/[.,]/)[1]||"").length,T=(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("")]},z=(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},C=(e,n,a,o)=>{const r=(s=e?.textContent||"",Number.parseFloat((s.match(/-?[\d.,]+/)||["NaN"])[0].replace(",",".")));var s;const c=!!Number.isNaN(r)||Math.abs(n-r)<=.5,l={label:a,computed:n,stated:r,agrees:c};o.checks.push(l),c||console.warn(`[${t}] An annotation reads ${r}%, but ${a} is ${n.toFixed(1)}%. The chart shows your number.`)},L={create:z,draw(e,n,a){const{rows:s,cx:c,y:l,unit:i,labelHeight:u,badgeHeight:d,height:h,svg:b,after:m}=a,[p,w]=((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)]})(e,s.length),y=s[p],M=s[w];if(!y||!M)return void console.warn(`[${t}] A bracket points at a row that is not there (row ${p+1} to ${w+1}, of ${s.length}).`);const k=7*i,x=4*i,N=c(p),A=c(w),S=Math.min(l(y.value),l(M.value))-u-x-.9*d,H=t=>l(t)-u-x,T=`M ${N} ${H(y.value)} L ${N} ${S} L ${A} ${S} L ${A} ${H(M.value)-k}`,z=(H(y.value)-S+Math.abs(A-N)+(H(M.value)-k-S))/i+1;b.appendChild($("path",{class:o,"data-note":a.note,d:T,style:`--len:${z.toFixed(1)}; ${g("--after",m)}`}));const L=H(M.value);var O;b.appendChild($("polygon",{class:r,"data-note":a.note,points:`${A},${L} ${A-.45*k},${L-k} ${A+.45*k},${L-k}`,style:g("--after",m)})),n&&(v(n,(N+A)/2,S,f,h),n.style.setProperty("--after",String(m))),C(n,(O=y.value,(M.value-O)/Math.abs(O)*100),`${y.value} to ${M.value}`,a)}},O=new WeakMap,B=t=>O.get(t)??{width:t.offsetWidth,height:t.offsetHeight},U={create:z,draw(t,e,n){const{rows:a,cx:s,y:c,unit:l,labelHeight:i,height:u,svg:d,values:h,after:b}=n,m=a[0],p=a[a.length-1];if(!m||!p)return;const w=i+18*l,y=10*l,M=10*l;let k=s(0),x=c(m.value)-w,N=s(a.length-1),A=c(p.value)-w,S=0;a.forEach((t,e)=>{const n=N===k?0:(s(e)-k)/(N-k),a=x+n*(A-x)-(c(t.value)-w);a>S&&(S=a)}),x-=S,A-=S;const H=N-k,T=A-x,z=Math.hypot(H,T)||1,L=H/z,O=T/z;k-=L*y,x-=O*y,N+=L*y,A+=O*y;const U=Number.parseFloat(t.getAttribute("data-at")||"0.5");if(e){const t=k+(N-k)*U,n=x+(A-x)*U,o=B(e).width*l/2,r=n+B(e).height*l/2+8*l;let u=0;a.forEach((e,n)=>{const a=(h[n]?B(h[n]).width:0)*l/2;if(Math.abs(s(n)-t)>=o+a)return;const d=c(e.value)-7*l-i;u=Math.max(u,r-d)}),x-=u,A-=u}const _=N-L*M,E=A-O*M,F=Math.hypot(_-k,E-x)/l+1;d.appendChild($("line",{class:o,"data-note":n.note,x1:k,y1:x,x2:_,y2:E,style:`--len:${F.toFixed(1)}; ${g("--after",b)}`}));const j=-O,P=L,q=.42*M;d.appendChild($("polygon",{class:r,"data-note":n.note,points:[`${N},${A}`,`${_+j*q},${E+P*q}`,`${_-j*q},${E-P*q}`].join(" "),style:g("--after",b)})),e&&(v(e,k+(N-k)*U,x+(A-x)*U,f,u),e.style.setProperty("--after",String(b)));const R=Number.parseFloat(t.getAttribute("data-years")||"");!Number.isNaN(R)&&R>0&&C(e,((t,e,n)=>100*(Math.pow(e/t,1/n)-1))(m.value,p.value,R),`${m.value} to ${p.value} over ${R} years`,n)}},_=(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}},E=(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}); ${g("--i",e.slot)}`}},F=(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}})},j=(t,e,n=!1)=>{const a=F(t,e,n);return{top:Math.max(0,...a.map(t=>t.to)),bottom:Math.min(0,...a.map(t=>t.to))}},P=(t,e)=>{const{top:n,bottom:a}=j(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})`)},R=(t,e,a,o={},r="")=>{const s={class:y(n,e),"data-kind":"bar","data-row":a+1,...o},c=g("--i",e.slot)+(r?`; transform-origin: ${r}`:""),l=$("g",{...s,"data-stack":"",style:c});return t.svg.appendChild(l),(n,r)=>{const s=void 0!==o["data-grow"]?{"data-grow":o["data-grow"]}:{};l.appendChild($("rect",{...s,...r,class:y("tablechart-piece",e),"data-row":a+1,...E(t,e,n)}))}},D=(t,e,n)=>t.some(t=>B(t).width*n>e-6*n),V=(t,e,n)=>e>=B(t).height*n*1.6,W=(t,e,n)=>e>=B(t).width*n*1.5,I=(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},K={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:o,unit:r,svg:s,values:c,categories:l,config:i,barMax:u}=t,d=t.series.length>1,h=Math.max(S(l.map(t=>B(t).width*r)),0),b=Math.min(h+10*r,420);l[0]?.parentElement?.style.setProperty("--_beside",`${((b-8*r)/f*100).toFixed(2)}%`);const m=f-4*r,p=t.stacked?Math.max(S(t.rows.map(e=>j(e,t.series.length).top)),0)||1:Math.max(S(t.rows.flatMap(e=>e.cells.slice(0,t.series.length).map(t=>Math.abs(t.value)))),0)||1,w=t.stacked?Math.max(S(t.rows.map(e=>-j(e,t.series.length).bottom)),0):Math.max(S(t.rows.flatMap(e=>e.cells.slice(0,t.series.length).map(t=>-t.value))),0),M=Math.max(p,t.squeeze?.hi??0)+w,k=(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),M,n,t.squeeze,t.breakGap),x=o/e.length,N=t=>(t+.5)*x,A=Math.min(x*i.barfill,u),H=_(x,t.series.length,u),T=c[0]??t.totals[0],z=T?B(T).height*r*.56:0,C=Math.max(((d&&!t.stacked?H.size:A)-z)/2,5*r),L=t=>B(t).width*r,O=t=>t.length?S(t.map(L))+C+4*r:0,U=(e,n)=>(t.rows[n].cells[e]??t.rows[n].cells[0]).value,P=t.seriesValues.flatMap((t,e)=>t.map((t,n)=>({label:t,value:U(e,n)}))),D=e=>{const n=j(t.rows[e],t.series.length);return 0===n.top&&n.bottom<0};let V=t.stacked?O(t.totals.filter((t,e)=>!D(e))):d?O(P.filter(t=>t.value>=0).map(t=>t.label)):0,K=t.stacked?O(t.totals.filter((t,e)=>D(e))):d?O(P.filter(t=>t.value<0).map(t=>t.label)):0;if(!d&&!t.stacked)for(let n=0;n<3;n++){const t=m-b-V-K,n=e.map((t,e)=>({seg:t,label:c[e]})).filter(({seg:e,label:n})=>!W(n,k(e.value,t),r)),a=O(n.filter(({seg:t})=>t.value>=0).map(({label:t})=>t)),o=O(n.filter(({seg:t})=>t.value<0).map(({label:t})=>t));if(a<=V&&o<=K)break;V=Math.max(V,a),K=Math.max(K,o)}const G=m-b-V-K,Z=b+K+k(w,G),J=t=>t<0?Z-k(t,G):Z+k(t,G);if(t.squeeze&&(t.breakX=J(t.squeeze.gap)),t.stacked)return t.rows.forEach((e,n)=>{const a=j(e,t.series.length),s=R(t,e,n,{"data-grow":"right"},a.bottom<0?Z-J(a.bottom)+"px center":""),c=N(n)-A/2;F(e,t.series.length).forEach(({from:e,to:a,cell:l},i)=>{const u=t.seriesValues[i][n];if(u.dataset.place="none",l.missing||a===e)return;const d=Math.min(J(e),J(a)),h=Math.max(J(e),J(a));s(i,{x:d,y:c,width:Math.max(h-d,1),height:A,...a<e&&{"data-grow":"left"}}),u.dataset.place="inside",u.toggleAttribute("data-left-out",!W(u,h-d,r)||B(u).height*r>A),q(u,t,i),v(u,(d+h)/2,N(n),f,o)});const i=t.totals[n];i&&(i.dataset.place=D(n)?"before":"after",v(i,D(n)?J(a.bottom)-C:J(a.top)+C,N(n),f,o));const u=l[n];u&&v(u,b-8*r,N(n),f,o)}),void s.appendChild($("line",{class:a,x1:Z,x2:Z,y1:0,y2:o}));if(d){t.plot.dataset.grouped="";const e=t.seriesValues.flat().filter(t=>void 0===t.dataset.missing),c=I(t.plot,e,t=>({size:B(t).height*r,room:H.size+.5*H.gap}),"--_fit");return t.rows.forEach((e,a)=>{t.series.forEach((r,l)=>{const i=e.cells[l]??e.cells[0],u=t.seriesValues[l][a];if(i.missing)return void(u.dataset.place="none");const d=J(i.value),h=i.value<0,b=N(a)+H.offset(l);s.appendChild($("rect",{class:y(n,e),"data-kind":"bar","data-row":a+1,"data-grow":h?"left":"right",x:Math.min(d,Z),y:b,width:Math.max(Math.abs(d-Z),1),height:H.size,...E(t,e,l)})),u.dataset.place=h?"before":"after",u.toggleAttribute("data-left-out",!c),v(u,h?d-C:d+C,b+H.size/2,f,o)});const i=l[a];i&&v(i,b-8*r,N(a),f,o)}),void s.appendChild($("line",{class:a,x1:Z,x2:Z,y1:0,y2:o}))}const Q=e.map((t,e)=>W(c[e],Math.abs(J(t.value)-Z),r));e.forEach((e,a)=>{const i=J(e.value),u=N(a),d=e.value<0,h=Math.abs(i-Z);s.appendChild($("rect",{class:y(n,e),"data-kind":e.kind,"data-row":a+1,"data-grow":d?"left":"right",x:Math.min(i,Z),y:u-A/2,width:Math.max(h,1),height:A,style:g("--i",e.slot)}));const m=c[a],p=Math.max(Math.min(C,h-L(m)-6*r),6*r),w=d?1:-1;m.dataset.place=Q[a]?"inside":d?"before":"after",m.dataset.kind=e.kind,v(m,Q[a]?"center"===t.insideAlign?(Z+i)/2:"start"===t.insideAlign?Z-w*(p+L(m)/2):i+w*(p+L(m)/2):i-w*C,u,f,o);const M=l[a];M&&v(M,b-8*r,u,f,o)}),s.appendChild($("line",{class:a,x1:Z,x2:Z,y1:0,y2:o}))}},G={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:o,y:r,barWidth:s,height:c,unit:l,svg:i,values:u,labels:d,insideAlign:h}=t,b=r(0);if(t.stacked)return t.rows.forEach((e,n)=>{const a=j(e,t.series.length),i=R(t,e,n,{},a.bottom<0?`center ${b-r(a.top)}px`:""),u=o(n)-s/2;F(e,t.series.length).forEach(({from:e,to:a,cell:d},h)=>{const b=t.seriesValues[h][n];if(b.dataset.place="none",d.missing||a===e)return;const m=Math.min(r(a),r(e)),p=Math.max(r(a),r(e));i(h,{x:u,y:m,width:s,height:Math.max(p-m,1),...a<e&&{"data-grow":"down"}}),b.dataset.place="inside",b.toggleAttribute("data-left-out",!V(b,p-m,l)||B(b).width*l>s-4*l),q(b,t,h),v(b,o(n),(m+p)/2,f,c)});const d=t.totals[n];if(d){const t=0===a.top&&a.bottom<0;d.dataset.place=t?"below":"outside",v(d,o(n),t?r(a.bottom)+4*l:r(a.top)-4*l,f,c)}}),void i.appendChild($("line",{class:a,x1:0,x2:f,y1:b,y2:b}));if(t.series.length>1){const e=o(1)-o(0)||2*o(0),s=_(e,t.series.length,t.barMax);t.plot.dataset.grouped="";const u=t.seriesValues.flat().filter(t=>void 0===t.dataset.missing),d=I(t.plot,u,t=>({size:B(t).width*l,room:s.size+.5*s.gap}),"--_fit");return t.rows.forEach((e,a)=>{t.series.forEach((u,h)=>{const m=e.cells[h]??e.cells[0],p=t.seriesValues[h][a],g=o(a)+s.offset(h);if(m.missing)return void(p.dataset.place="none");const w=r(m.value),M=m.value<0;i.appendChild($("rect",{class:y(n,e),"data-kind":"bar","data-row":a+1,...M&&{"data-grow":"down"},x:g,y:Math.min(w,b),width:s.size,height:Math.max(Math.abs(b-w),1),...E(t,e,h)})),p.dataset.place=M?"below":"outside",p.toggleAttribute("data-left-out",!d),v(p,g+s.size/2,M?w+4*l:w-4*l,f,c)})}),void i.appendChild($("line",{class:a,x1:0,x2:f,y1:b,y2:b}))}const m=D(u,s,l),p=e.map((t,e)=>"inside"===d&&!m&&!t.missing&&V(u[e],Math.abs(b-r(t.value)),l)),w=u[0]?B(u[0]).height*l*.56:0;let M=Number.POSITIVE_INFINITY;for(const[n,a]of u.entries())p[n]&&(M=Math.min(M,(s-B(a).width*l)/2));e.forEach((t,e)=>{const a=r(t.value),d=t.value<0;if(t.missing)return v(u[e],o(e),b-4*l,f,c),void(u[e].dataset.place="outside");i.appendChild($("rect",{class:y(n,t),"data-kind":t.kind,"data-row":e+1,...d&&{"data-grow":"down"},x:o(e)-s/2,y:Math.min(a,b),width:s,height:Math.max(Math.abs(b-a),1),style:g("--i",t.slot)}));const m=d?-1:1,k=Math.min(M,(Math.abs(b-a)-w)/2),x="center"===h?(a+b)/2:"start"===h?b-m*(k+w/2):a+m*(k+w/2),N=d?a+4*l:a-4*l;v(u[e],o(e),p[e]?x:N,f,c),u[e].dataset.place=p[e]?"inside":d?"below":"outside"}),i.appendChild($("line",{class:a,x1:0,x2:f,y1:b,y2:b}))}},Z=0,J={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:c,centre:l}){const i=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,b=Math.max(Math.min(f,e)/2-h,10),m=b*c.ringfill,w=b-m/2,M=2*Math.PI*w,k=[];let x=0,N=0,A=0;if(t.forEach((t,c)=>{const l=r[c];if(t.isTotal)return void(l.dataset.place="none");const h=Math.abs(t.value)/d,S=p(A,h),H=`--share:${h.toFixed(4)}; --start:${S.start.toFixed(4)}; --span:${S.span.toFixed(4)};`,T=h*M,z=x/M*2*Math.PI-Math.PI/2;k.push(z),o.appendChild($("circle",{class:y(s,t),"data-slice":N+1,"data-row":c+1,cx:i,cy:u,r:w,"stroke-width":m,transform:`rotate(-90 500 ${u})`,"stroke-dasharray":`${T.toFixed(1)} ${(M-T).toFixed(1)}`,"stroke-dashoffset":(-x).toFixed(1),style:`--n:${N}; --palette:var(--tablechart-color-${N+1}); --arc:${T.toFixed(1)}; --circ:${M.toFixed(1)}; ${H} --ease:${S.easing}; ${g("--i",t.slot)}`}));const C=z+T/M*Math.PI,L=Math.cos(C),O=Math.sin(C);o.appendChild($("line",{class:"tablechart-leader",x1:i+L*(b+2*n),y1:u+O*(b+2*n),x2:i+L*(b+7*n),y2:u+O*(b+7*n),"data-row":c+1,style:`${H} ${g("--i",t.slot)}`})),l.style.setProperty("--start",S.start.toFixed(4)),l.style.setProperty("--span",S.span.toFixed(4));const U=b+9*n,_=B(l).width*n/2;v(l,i+L*(U+Math.abs(L)*_),u+O*(U+Math.abs(O)*a*.7),f,e),l.dataset.place="around",x+=T,A+=h,N+=1}),k.length>1){const t=w-m/2-1,n=w+m/2+1,a="tablechart-slices-"+ ++Z,r=$("mask",{id:a,maskUnits:"userSpaceOnUse"});r.appendChild($("rect",{x:0,y:0,width:f,height:e,fill:"white"}));for(const e of k)r.appendChild($("line",{class:"tablechart-divide",x1:i+Math.cos(e)*t,y1:u+Math.sin(e)*t,x2:i+Math.cos(e)*n,y2:u+Math.sin(e)*n}));const c=$("g",{mask:`url(#${a})`});for(const e of Array.from(o.querySelectorAll(`.${s}`)))c.appendChild(e);const l=$("defs");l.appendChild(r),o.prepend(l,c)}l&&v(l,i,u,f,e)}},Q=["circle","square","diamond"],X=(t,e)=>{const n=t[e]?.marker?.toLowerCase().split(/\s+/)??[],a=Q.find(t=>n.includes(t));return{shape:a??Q[Math.floor(e/2)%Q.length],open:n.includes("open")||!n.includes("filled")&&!a&&e%2==1}},Y=t=>Number(t.toFixed(2));function tt(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 et,nt,at=t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"})),ot=t=>({segments:at,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:o,seriesValues:r,names:s,cx:c,y:i,height:u,unit:d,labelHeight:h,svg:b,stacked:m}=e,p="step"===e.shape,g="smooth"===e.shape,w=o.length>1,y=o.some(t=>t.focus),M=n.length-1,k=i(0),N=n.length>1?c(1)-c(0):2*c(0);b.style.setProperty("--_base",`${Y(k)}px`);const A=(t,e)=>n[e]?.cells[t]??n[e]?.cells[0],S=(t,e)=>!A(t,e)||!!A(t,e)?.missing,H=n.map(t=>m?F(t,o.length,!0):null),T=(t,e)=>H[e]?.[t].to??A(t,e)?.value??0,z=(t,e)=>H[e]?.[t].from??0,C=(t,e)=>[c(e),i(T(t,e))],L=o.map((t,e)=>{if(!w)return{attrs:{},ink:""};const n=y&&!t.focus;return{attrs:{"data-series":e+1,...n&&{"data-muted":""}},ink:`--n:${e}; --m:${n?1:0}; --palette:var(--tablechart-color-${e+1}); `}}),O=Math.min(M,6);e.plot.style.setProperty("--count",String(O+1));const U=M>0?O/(p?n.length:M):1,_=t=>t*U,E=t=>`--i:${Y(_(t))}`,j=t=>{const e=[];let a=-1;return n.forEach((n,o)=>{S(t,o)||(a<0&&(a=o),(o===M||S(t,o+1))&&((p||o>a)&&e.push([a,o]),a=-1))}),e},P=(t,e)=>`--i:${Y(_(t)+1)}; --d:${Y(_(p?e+1:e)-_(t))}`,q=(t,e)=>({"data-from":t+1,"data-to":e+1,...p&&{"data-flat":""}}),R=g?o.map((t,e)=>tt(n.length,t=>S(e,t),t=>C(e,t))):[],D=g&&t?o.map((t,e)=>tt(n.length,t=>S(e,t),t=>[c(t),i(z(e,t))])):[],V=(t,e,n)=>{const a=[];return t.forEach(([o,r],s)=>{p?(a.push(`H${Y(o+n*N/2)}`),s<t.length-1&&a.push(`V${Y(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])=>`${Y(t)},${Y(e)}`;return`C${s(o)} ${s(r)} ${s(e)}`}(t[s-1],[o,r],e[s-1],e[s]):`L${Y(o)},${Y(r)}`)}),a},W=(t,e,a,o)=>n.slice(e,a+1).map((n,a)=>[c(e+a),i(o(t,e+a))]),I=(t,e,n,a)=>g?t[e].slice(n,a+1):null,K=t=>c(t)-(p?N/2:0),G=t=>c(t)+(p?N/2:0);t&&o.forEach((t,e)=>(t=>{const e=$("g",{class:"tablechart-area",...L[t].attrs,...m&&{"data-stacked":""},style:L[t].ink}),n=j(t),a=$("g",{class:"tablechart-area-fill",style:`--rows:${Y(O+1)}; ${n.length?P(...n[0]):""}`});e.appendChild(a);for(const[o,r]of n){const e=W(t,o,r,T),n=W(t,o,r,z),s=I(D,t,o,r)?.reverse()??null,c=[`M${Y(K(o))},${Y(n[0][1])}`,`L${Y(K(o))},${Y(e[0][1])}`,...V(e,I(R,t,o,r),1),`L${Y(G(r))},${Y(n[n.length-1][1])}`,...V(n.reverse(),s,-1),"Z"].join(" ");a.appendChild($("path",{d:c,...q(o,r),style:P(o,r)}))}b.appendChild(e)})(e)),o.forEach((t,e)=>(t=>{const e=o[t];for(const[n,a]of j(t)){const o=W(t,n,a,T),r=[`M${Y(K(n))},${Y(o[0][1])}`,...V(o,I(R,t,n,a),1)].join(" ");b.appendChild($("path",{class:"tablechart-series",...L[t].attrs,d:r,...e.line&&{"data-line":e.line},...q(n,a),style:`${L[t].ink}${P(n,a)}`}))}})(e)),p||(()=>{const t=o.map((t,e)=>w?X(o,e):{shape:"circle",open:!1}),e=(e,n,a)=>{const[o,r]=C(e,n);return((t,e,n,a,o={})=>{if("square"===t){const t=.88*a;return $("rect",{x:e-t,y:n-t,width:2*t,height:2*t,...o})}if("diamond"===t){const t=1.2*a;return $("polygon",{points:`${e},${n-t} ${e+t},${n} ${e},${n+t} ${e-t},${n}`,...o})}return $("circle",{cx:e,cy:n,r:a,...o})})(t[e].shape,o,r,4*d,{...a,style:`${a.style??""}${s=r,`--rise:${Y(k-s)}px; `}${E(n)}`});var s},a=t=>n.map((t,e)=>e).filter(e=>!S(t,e)),r=o.flatMap((n,o)=>t[o].open?a(o).map(t=>e(o,t,{class:l,"data-row":t+1,...w&&{"data-series":o+1}})):[]);x(b,r,f,u),o.forEach((n,o)=>{for(const r of a(o))b.appendChild(e(o,r,{class:"tablechart-point",...L[o].attrs,"data-marker":t[o].shape,...t[o].open&&{"data-open":""},"data-row":r+1,style:L[o].ink}))})})();const Z=(t,e)=>{let n=e;for(;n<M&&!S(t,n+1)&&A(t,n+1)?.value===A(t,e)?.value;)n++;return n};r.forEach((e,n)=>{e.forEach((e,a)=>{e.style.setProperty("--i",String(Y(p?(_(a)+_(a+1))/2:_(a))));const s=((e,n)=>{const a=A(e,n);if(!a||a.missing)return"none";if(p&&n>0&&!S(e,n-1)&&A(e,n-1)?.value===a.value)return"none";if(y&&!o[e].focus)return"none";if(m)return"middle";const r=a.value<0?"below":"above";if(!w||y||o.length>2)return r;const s=A(1-e,n);return!s||s.missing?r:a.value>s.value||a.value===s.value&&0===e||t&&a.value>=0&&C(e,n)[1]+7*d+h>k?"above":"below"})(n,a);if(e.dataset.place="above"===s?"outside":s,e.toggleAttribute("data-left-out","none"!==s&&((t,e)=>m||p?B(r[t][e]).width*d>(p?Z(t,e)-e+1:1)*N-4*d||!!(m&&t>0&&T(t,e)<z(t,e))||m&&Math.abs(i(z(t,e))-i(T(t,e)))<1.2*h:w&&!y&&o.length>2)(n,a)),p&&"none"!==s?e.dataset.rowEnd=String(Z(n,a)+1):delete e.dataset.rowEnd,"none"===s)return;const l=B(e).width*d/2+4*d;let b=c(a);p?b=(c(a)+c(Z(n,a)))/2:"middle"===s&&0===a?b+=l:"middle"===s&&a===M&&(b-=l);const g=i(T(n,a)),$={middle:(i(z(n,a))-g)/2,above:-7*d,below:7*d};v(e,b,g+$[s],f,u)})});const J=s.map((t,e)=>{let n=M;for(;n>0&&S(e,n);)n--;const[a,o]=C(e,n);return{name:t,x:(p?a+N/2:a)+10*d,y:m?(o+i(z(e,n)))/2:o}}),Q=(s[0]?B(s[0]).height:0)*d;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))(J,Q))v(t.name,t.x,t.y,f,u);const et=n.some(t=>t.cells.some(t=>!t.missing&&t.value<0)),nt=t||m||2!==o.length||y||et?k:u-2*d;b.appendChild($("line",{class:a,x1:0,x2:c(M)+c(0),y1:nt,y2:nt}))}}),rt=ot(!1),st=ot(!0),ct=new Set,lt={segments:e=>{let n=0,a=!1;return e.map(e=>{if(e.isTotal)return a&&((e,n)=>{if(Math.abs(e-n)<=Math.abs(n)/100)return;const a=`[${t}] A total reads ${e}, but the steps before it add up to ${Number(n.toFixed(6))}. The chart shows your number.`;ct.has(a)||(ct.add(a),console.warn(a))})(e.value,n),a=!1,n=e.value,{...e,from:0,to:e.value,kind:"total"};const o=n;return n+=e.value,a=!0,{...e,from:o,to:n,kind:e.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:o,barWidth:r,height:s,unit:c,svg:l,values:i,breakAt:u,insideAlign:d}){const h=o(0),b=D(i,r,c),p=d??"center",w=t.map((e,n)=>{const a=o(Math.max(e.from,e.to)),r=Math.abs(o(e.from)-o(e.to)),s=null!==u&&Math.min(e.from,e.to)<u&&Math.max(e.from,e.to)>u,l="total"===e.kind&&n>0&&n===t.length-1;return{top:a,length:r,down:"down"===e.kind||"total"===e.kind&&(l?e.to>=0:e.to<0),inside:!s&&!b&&V(i[n],r,c)}}),M=i[0]?B(i[0]).height*c*.56:0;let k=Number.POSITIVE_INFINITY;for(const[n,a]of w.entries())a.inside&&(k=Math.min(k,(r-B(i[n]).width*c)/2));const x=t.length,N=(t,e,n=!1)=>`--start:${(t/x).toFixed(4)}; --span:${(e/x).toFixed(4)}; --ease:${n?m:"linear"};`;t.forEach((n,a)=>{const s=t[a+1];if(!s)return;const c=o(n.to),i=e(a)+r/2,u=e(a+1)-r/2;l.appendChild($("line",{class:"tablechart-connector",x1:i,x2:u,y1:c,y2:c,"data-row":a+2,style:`${g("--i",s.slot)}; ${N(a+1,1/3)}`}))}),t.forEach((a,o)=>{const{top:u,length:d,down:h,inside:b}=w[o];l.appendChild($("rect",{class:y(n,a),"data-kind":a.kind,"data-row":o+1,"data-grow":h?"down":"up",x:e(o)-r/2,y:u,width:r,height:Math.max(d,1),style:`${g("--i",a.slot)}; ${N(o,1,o===t.length-1)}`}));const m=i[o];m.style.setProperty("--start",(o/x).toFixed(4)),m.style.setProperty("--span",(1/x).toFixed(4));const A=Math.min(k,(d-M)/2),S="center"===p?u+d/2:"end"===p!==h?u+A+M/2:u+d-A-M/2;m.dataset.place=b?"inside":"outside",m.dataset.kind=a.kind;const H=b?S:"down"===a.kind?u+d+B(m).height*c+3*c:u-3*c;v(m,e(o),H,f,s)}),l.appendChild($("line",{class:a,x1:0,x2:f,y1:h,y2:h}))}},it={enabled:!1,log(...e){it.enabled&&console.log(`[${t}]`,...e)},timed(e,n,a){if(!it.enabled)return a();const o=performance.now(),r=a(),s=performance.now()-o,c=n.querySelectorAll("tbody tr").length;return s>50?console.warn(`[${t}] ${e} took ${s.toFixed(1)} ms for ${c} rows, more than 50 ms.`,n):it.log(`${e} took ${s.toFixed(1)} ms for ${c} rows.`,n),r}},ut=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}},dt=t=>Array.from(t.querySelector("thead tr:last-child")?.children??[]).slice(1),ht=["axis-break","trend","bracket"],ft=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))}},bt=(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)),ft(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}}))},mt="tablechart-tooltip",pt=["--tablechart-surface","--tablechart-tooltip-surface","--tablechart-tooltip-color","--tablechart-tooltip-border","--tablechart-tooltip-radius","--tablechart-tooltip-padding","--tablechart-tooltip-shadow"],gt=null,wt=null,$t=null,yt=0,Mt=()=>{clearTimeout(yt),gt&&wt&&(gt.hidden=!0,wt=null,$t=null)},vt=!1,kt=!0,xt=NaN,Nt=NaN,At=!1,St=(t,e)=>e/Number.parseFloat(getComputedStyle(t).width)||1,Ht=()=>{clearTimeout(yt),yt=window.setTimeout(Mt,120)},Tt=(t,e)=>{const n=e?e.style.getPropertyValue("--step"):"x";return""===n||Number(n)<t.step},zt=(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},Ct=(t,e,n)=>{const a=t.series.length>1,o=[];for(const[s,c]of t.seriesValues.entries()){if(!Tt(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?zt(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&&Tt(t,r)&&o.push({name:n.totallabel,value:r.textContent??""}),o},Lt=(t,e,n)=>{if(clearTimeout(yt),wt===t&&$t===e)return;const a=(t.type.tooltip??Ct)(t,e,n);if(!a.length)return Mt();wt&&wt!==t&&Mt(),gt??(gt=(()=>{const t=document.createElement("div");return t.className=mt,t.setAttribute("aria-hidden","true"),t.hidden=!0,et=document.createElement("div"),(nt=document.createElement("div")).className=`${mt}-arrow`,t.append(et,nt),document.body.append(t),t.addEventListener("pointerenter",()=>clearTimeout(yt)),t.addEventListener("pointerleave",t=>"mouse"===t.pointerType&&Ht()),document.addEventListener("pointerdown",e=>{const n=e.target;!wt||wt.plot.contains(n)||t.contains(n)||Mt()}),window.addEventListener("resize",Mt),t})());const o=(t,e,n,a=!1,o)=>{const r=document.createElement("div");if(r.className=`${mt}-line`,n){const t=document.createElement("span");t.className=`${mt}-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=`${mt}-${a?"title":"name"}`,s.textContent=t,r.append(s),e){t&&s.append(":");const n=document.createElement("span");n.className=`${mt}-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;et.replaceChildren(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 c=getComputedStyle(t.figure);for(const h of pt){const t=c.getPropertyValue(h).trim();t?gt.style.setProperty(h,t):gt.style.removeProperty(h)}gt.style.setProperty("--_color",c.color),gt.style.colorScheme=c.colorScheme,gt.style.fontFamily=c.fontFamily;const l=(t=>{const e=t.tooltipparent;return("string"==typeof e?document.querySelector(e):e)??document.body})(n);gt.parentElement!==l&&l.append(gt),wt=t,$t=e,gt.hidden=!1,gt.style.left="0px",gt.style.top="0px";const i=gt.getBoundingClientRect(),u={x:i.left,y:i.top,scale:St(gt,i.width)},d=St(t.plot,t.plot.getBoundingClientRect().width);gt.style.fontSize=Number.parseFloat(c.fontSize)*d/u.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:b}=document.documentElement,m=n.top-r,p=b-n.bottom-r,g=i+d<=m||!(i+d<=p)&&m>=p,w=g?n.top-d-i:n.bottom+d,$=n.left+n.width/2,y=Math.max(r,Math.min($-l/2,f-l-r));t.style.left=(y-a.x)/a.scale+"px",t.style.top=(Math.max(r,Math.min(w,b-i-r))-a.y)/a.scale+"px",t.dataset.side=g?"top":"bottom",e.style.left=Math.max(h,Math.min($-y,l-h))/a.scale-u+"px"})(gt,nt,((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),u)},Ot=t=>{wt===t&&Mt()},Bt={area:st,bar:K,column:G,donut:J,line:rt,waterfall:lt},Ut={"axis-break":A,trend:U,bracket:L},_t=Object.keys(Ut),Et=t=>{let e="";for(let n=t.previousSibling;n&&(e=(n.textContent??"")+e,!e.trim());n=n.previousSibling);return e.trim()},Ft=["straight","step","smooth"],jt=(t,e)=>{const n=t.dataset.chartShape;return n&&Ft.includes(n)?n:Ft.includes(e.shape)?e.shape:"straight"},Pt=0,qt=(n,a,o=null)=>{const r=o??(n.getAttribute("data-chart")||"column"),s=Bt[r];if(!s)return console.warn(`[${t}] Unknown chart type "${r}". Known types: ${Object.keys(Bt).join(", ")}.`),n.setAttribute("data-chart-empty",""),null;const l=((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(ut);return o.length||o.push(ut(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}}))(n,a.langattribute);if(!l.length)return console.warn(n.querySelector("table")?`[${t}] A chart has no rows in its table, so there is nothing to draw.`:`[${t}] A chart has no table, so there is nothing to draw.`,n),n.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(Et(e)))continue;const t=document.createElement("span");t.className=d,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-"+ ++Pt),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)})(n);let u=((t,e,n="data-i18n")=>{const a=dt(t),o=Math.max(1,S(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)};var r})})(n,l,a.langattribute);u.length>1&&!s.series&&(console.warn(`[${t}] A ${r} chart uses only the first of its ${u.length} value columns.`),u=u.slice(0,1));const h=u.length>1;h&&n.style.setProperty("--_series-count",String(u.length));const f=n.hasAttribute("data-chart-stack");f&&!s.stackable&&console.warn(`[${t}] A ${r} chart cannot be stacked.`);const b=f&&!!s.stackable&&h,m=document.createElement("div");m.className="tablechart-plot",m.setAttribute("aria-hidden","true");const p=$("svg",{role:"presentation",focusable:"false"});m.appendChild(p),n.appendChild(m);const g=s.centre?l.filter(t=>!t.isTotal):l,w=Math.max(0,S(g.flatMap(t=>t.cells.slice(0,u.length).map(t=>H(t.number))))),y=u.map((t,n)=>l.map((t,a)=>{const o=t.cells[n]??t.cells[0],r=M(e,m);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),h&&(r.dataset.series=String(n+1)),r.dataset.row=String(a+1),r.style.setProperty("--i",String(t.slot)),r})),v=y[0],k=b&&s.totals?l.map((t,n)=>{const a=M(e,m);a.classList.add(...t.classes),a.dataset.kind="total",a.dataset.row=String(n+1),a.dataset.value=String(P(t,u.length));const o=t.cells[0];return o.prefix&&(a.dataset.prefix=o.prefix),o.suffix&&(a.dataset.suffix=o.suffix),a.style.setProperty("--i",String(t.slot)),a}):[],x=l[l.length-1],N=u.some(t=>t.focus),A=n.getAttribute("data-chart-legend"),T=h&&(null===A?a.legend||void 0!==s.legend:"false"!==A)?document.createElement("div"):null;T&&(T.className=c,T.setAttribute("aria-hidden","true"),T.inert=!0);const z=h?u.map((t,e)=>{const o=M("tablechart-name",T??m);T&&(o.dataset.place="legend");const r=s.legend??s.swatch;if(r&&(o.dataset.swatch=r),o.textContent=t.name,!r&&"step"!==jt(n,a)){const t=X(u,e);o.dataset.marker=t.shape,o.toggleAttribute("data-open",t.open)}return t.line&&!r&&(o.dataset.line=t.line),t.key&&a.langattribute&&o.setAttribute(a.langattribute,t.key),o.dataset.series=String(e+1),o.style.setProperty("--n",String(e)),o.style.setProperty("--palette",`var(--tablechart-color-${e+1})`),o.style.setProperty("--m",N&&!t.focus?"1":"0"),o.style.setProperty("--i",String(x.slot)),o}):[],C=s.centre?M(i,m):null;if(C){const t=l.find(t=>t.isTotal),e=t?t.value:l.reduce((t,e)=>t+Math.abs(e.value),0);C.dataset.value=String(e),t&&(C.dataset.decimals=String(H(t.number)))}const L=C&&!l.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})(n,C,a):null,O="beside"===s.categories,B=document.createElement("div");B.className="tablechart-categories",B.setAttribute("aria-hidden","true"),B.inert=!0,O?B.dataset.place="beside":s.centre&&(B.dataset.place="key"),B.style.setProperty("--_columns",String(l.length));let U=0;for(const[t,e]of l.entries()){const n=document.createElement("span");n.classList.add(...e.classes),n.textContent=e.label,e.key&&a.langattribute&&n.setAttribute(a.langattribute,e.key),s.centre&&(n.dataset.kind=e.isTotal?"total":"slice",e.isTotal||(n.dataset.slice=String(U+1),n.style.setProperty("--n",String(U)),n.style.setProperty("--palette",`var(--tablechart-color-${U+1})`),U+=1)),n.style.setProperty("--i",String(e.slot)),n.dataset.row=String(t+1),B.appendChild(n)}(O?m:n).appendChild(B),T&&n.appendChild(T);const _=a.animate?(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=>ht.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"),b=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]++}}),m=Math.max(-1,...b.map(t=>t.step??-1));if(m>=0)for(const[$,y]of n.entries())f(y)&&(b[$]={step:m,slot:i[m]++});const p=a.map(t=>({step:r(t)?u(t.getAttribute("data-fragment-index")):null})),g=s.map(t=>t.map(()=>({step:null,slot:0}))),w=Math.max(0,...s.map(t=>t.length));for(let $=0;$<w;$++)for(const[t,e]of s.entries()){const n=e[$];if(!n||!r(n))continue;const a=u(n.getAttribute("data-fragment-index"));g[t][$]={step:a,slot:i[a]++}}return{rows:b,series:p,cells:g,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",b.length-1)]:[0,b.length-1];let o=null;for(let r=Math.min(n,a);r<=Math.max(n,a);r++)for(const t of[b[r]?.step??null,...(g[r]??[]).map(t=>t.step)])null!==t&&(null===o||t>o)&&(o=t);const s=p[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?b.length:b.filter(t=>t.step===o).length;return{step:o,after:c}}),count:c.length,indexes:c}})(n):null;_&&n.setAttribute("data-steps","");const E=n.getAttribute("data-chart-keys"),F=_&&a.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=$("svg",{viewBox:"0 0 16 16",focusable:"false"});s.appendChild($("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=d,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:a.previouslabel,next:a.nextlabel,hint:a.stephint},{previous:E&&`${E}-previous`,next:E&&`${E}-next`,hint:E&&`${E}-step`},a.langattribute):null;F&&n.appendChild(F);const j=n.getAttribute("data-chart-table"),q=j&&Dt.includes(j)?j:a.table;if("never"===q)n.removeAttribute("data-table");else{n.setAttribute("data-table",q);const t=n.querySelector(":scope > table");t&&n.append(t)}const R=Array.from(n.querySelectorAll("[data-annotation]")).map(e=>{const n=e.getAttribute("data-annotation"),a=Ut[n];if(!a)return console.warn(`[${t}] Unknown annotation "${n}". Known annotations: ${Object.keys(Ut).join(", ")}.`),null;const o=Number.parseInt(e.getAttribute("data-series")??"1",10),r=o>=1&&o<=u.length?o-1:0;return o!==r+1&&console.warn(`[${t}] An annotation reads line ${o}, which is not there; it reads line 1.`),{spec:e,type:a,badge:a.create(e,m),series:r,after:l.length}}).filter(t=>null!==t);a.animate&&n.setAttribute("data-animate",Wt(n,r,a,Boolean(_)));const D={figure:n,plot:m,svg:p,rows:l,decimals:w,type:s,values:v,series:u,seriesValues:y,names:T?[]:z,categories:Array.from(B.children),centre:C,stacked:b,totals:k,totalCell:L,rowAt:null,rowBox:null,annotations:R,checks:[],plan:_,step:0,controls:F};F?.addEventListener("click",t=>{const e=t.target.closest("button")?.dataset.go;e&&bt(D,D.step+("next"===e?1:-1))}),bt(D,0,!0);const V=n.getAttribute("data-chart-tooltip")??n.getAttribute("data-chart-hover"),W="false"!==V&&("auto"===V?"auto":null!==V||!1!==a.hover&&a.tooltip);return W&&((t,e,n=!1)=>{const{plot:a}=t;a.setAttribute("data-hover",""),(()=>{if(At)return;At=!0,document.addEventListener("pointermove",t=>{"mouse"===t.pointerType&&(kt=t.screenX!==xt||t.screenY!==Nt,xt=t.screenX,Nt=t.screenY,kt&&(vt=!1))},{capture:!0,passive:!0});const t=()=>{vt=!0,Mt()};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)vt=!1;else if("mouse"===o.pointerType&&(!kt||vt))return;if(!a.classList.contains("is-placed")||!t.figure.classList.contains("is-shown"))return;if(n&&!t.figure.hasAttribute("data-left-out"))return wt===t?Mt():void 0;const c=(e=>{if(t.rowAt){const n=a.getBoundingClientRect(),o=St(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 wt===t?Ht():void 0;Lt(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)||vt||Lt(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,wt===t&&Ht())})})(D,a,"auto"===W),Zt(D,a),D},Rt={grow:"grow",sweep:"sweep"},Dt=["never","auto","print","always"],Vt={...Rt,up:"grow",across:"sweep"},Wt=(t,e,n,a)=>{const o="line"===e||"area"===e,r=o?Vt:Rt,s=r[t.getAttribute("data-chart-animate")??""]??r[String(n.animate)];return o?a?"sweep":s??"sweep":"donut"===e||"waterfall"===e?s??"grow":"grow"},It=t=>{const e=getComputedStyle(t),n=(e.getPropertyValue("--tablechart-value-align")||e.getPropertyValue("--tablechart-inside-align")).trim();return"start"===n||"center"===n||"end"===n?n:null},Kt=(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*f:s*("em"===r[2]?Number.parseFloat(o.fontSize):"rem"===r[2]?Number.parseFloat(getComputedStyle(document.documentElement).fontSize):1)*e},Gt=(t,e)=>Kt(t,e,"--tablechart-bar-max","60px")??Number.POSITIVE_INFINITY,Zt=(t,e)=>{const n=[...t.seriesValues.flat(),...t.totals,...t.totalCell?[t.totalCell]:[]];for(const a of t.centre?[...n,t.centre]:n){const{missing:n,prefix:o="",suffix:r=""}=a.dataset;if(void 0!==n){a.textContent=n;continue}const s=Number.parseFloat(a.dataset.value||"0"),c=a.dataset.decimals?Number(a.dataset.decimals):t.decimals,[l,i]=T(s,c,e.locale);if(a.textContent=o+(o?l:"")+i+r,l&&!o){const t=document.createElement("span");t.className="tablechart-minus",t.textContent=l,a.prepend(t)}}},Jt=(t,e)=>{t.figure.classList.toggle("is-shown",e)},Qt=t=>"id"===t||"style"===t||t.startsWith("data-chart"),Xt=/^\s*(?:Table)?:\s+/,Yt=t=>"P"===t?.tagName&&Xt.test(t.textContent??""),te=/^\s*([a-z][\w-]*)((?:\s+[\w-]+=[^\s:]+)*)\s*(:\s*|$)/,ee=t=>{const e=ae(t);return"P"===e?.tagName?e:t},ne=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},ae=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},oe="strong, b, span.total",re="data-chart-made",se=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,ce=new Set,le=null,ie=["column","bar"],ue=t=>{const e=t.getAttribute("data-chart")||"column";if(!ie.includes(e))return null;const n=getComputedStyle(t).getPropertyValue("--tablechart-type").trim();return ie.includes(n)?n:e},de=!1,he=async(e,n)=>{const a=(t=>t.map(t=>{const e=t.closest("p"),n=Yt(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||Qt(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?Yt(r)?r:Yt(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=ee(t).firstChild;if(e?.nodeType!==Node.TEXT_NODE)return null;const n=te.exec(e.textContent??"");if(!n||!_t.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=ee(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(Xt,""),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),it?.log?.(`A ${o?"table":"caption"} with chart attributes was wrapped in a figure of its own`),a}))(e.filter(t=>!t.hasAttribute(re)));return(e=>{const n=e.find(t=>"FIGURE"!==t.tagName);!de&&n&&(de=!0,console.warn(`[${t}] A chart is a <${n.tagName.toLowerCase()}>. Use a <figure> with a <figcaption>, so the chart has a title, also for screen readers.`,n))})(a),await(async e=>{await Promise.all(e.filter(t=>t.hasAttribute("data-chart-src")).map(async e=>{const n=e.getAttribute("data-chart-src"),a=Array.from(e.querySelectorAll("table")).find(t=>t.tHead)??null;for(const t of e.querySelectorAll("table"))t!==a&&t.remove();try{const t=await fetch(n);if(!t.ok)throw new Error(`${t.status} ${t.statusText}`);const o=await t.json(),r=Array.isArray(o)?o:o?.rows?Array.isArray(o.rows)?o.rows:ne(o.rows):ne(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 t=e.querySelector(":scope > figcaption");t?t.after(s):e.prepend(s)}s.tHead||it?.log?.(`The table from "${n}" has no header row, so a screen reader cannot name its columns.`),it?.log?.(`Read ${r.length} rows from "${n}"`)}catch(o){const e="file:"===window.location.protocol;console.warn(`[${t}] Could not read the chart data in "${n}": ${o.message}.`+(e?" 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=ae(e);a?.matches(oe);a=ae(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=ae(e);t?.matches(oe);t=ae(e))e.setAttribute("data-kind","focus"),t.replaceWith(...t.childNodes)}})(a),((e,n)=>{if(!n)return;const a=new Map;for(const o of e){let e=o.getAttribute("data-chart-keys")||null;if(!e)continue;if(a.has(e)){const n=a.get(e)+1;a.set(e,n),console.warn(`[${t}] Two charts have data-chart-keys="${e}", so this one uses "${e}-${n}" to keep their translations apart.`),e=`${e}-${n}`}else a.set(e,1);o.querySelectorAll("tbody th").forEach((t,a)=>{t.getAttribute(n)||t.setAttribute(n,`${e}-row${a+1}`)});const r=dt(o);r.length>1&&r.forEach((t,a)=>{t.getAttribute(n)||t.setAttribute(n,`${e}-col${a+1}`)}),it?.log?.(`Keys for "${e}" written onto ${o.querySelectorAll("tbody th").length} rows`)}})(a,n.langattribute),a},fe=(e,a)=>{const o=it.timed("Building",e,()=>qt(e,a));return o?(e.setAttribute(re,""),((e,a)=>{let o=e,r=ue(o.figure),u=null,d=!1,b=!1;const m=async()=>{if(!a.animate)return Jt(o,!0);const t=o.figure.classList.contains("is-shown");if(!d||null===u||t||b)!d&&a.replay&&t&&Jt(o,!1);else{b=!0;const t=se()?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(e=t,new Promise(t=>{const n=["animationstart","transitionrun"],a=()=>{for(const t of n)document.removeEventListener(t,o,!0);r.disconnect(),t()},o=t=>{t.target instanceof Node&&t.target.contains(e)&&a()},r=new MutationObserver(()=>{"0"!==getComputedStyle(e).opacity&&a()});for(const e of n)document.addEventListener(e,o,!0);r.observe(e,{attributes:!0,attributeFilter:["class","style"]})})),await(async(t,e)=>{if(se())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)))})(o.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)})(o.figure,a)),b=!1,!d&&a.replay||Jt(o,!0)}var e},g=()=>{const t=ue(o.figure);if(!t||t===r)return;const e=it.timed("Building",o.figure,()=>qt(o.figure,a,t));e&&((t=>{Ot(t),t.plot.remove(),t.categories[0]?.parentElement?.remove(),t.figure.querySelector(`:scope > .${c}`)?.remove(),t.controls?.remove()})(o),bt(e,o.step,!0),o=e,r=t,u=null)},y=()=>{g();const e=o.plot.clientWidth;e&&e!==u&&it.timed("Layout",o.figure,()=>((e,a)=>{const{plot:o,svg:r,rows:c,type:u,values:d,series:h,seriesValues:b,names:m,annotations:g}=e,y=o.clientWidth;if(!y)return!1;const M=f/y,v=Number.parseFloat(e.figure.dataset.chartAspect??""),k=f*(v>0?v:u.aspect??a.aspect);o.classList.add("is-placed");for(const t of[...b.flat(),...e.totals])delete t.dataset.place;o.style.removeProperty("--_fit"),e.categories[0]?.parentElement?.style.removeProperty("--_beside"),(t=>{const e=[...t].filter(t=>!!t),n=e.map(t=>({width:t.offsetWidth,height:t.offsetHeight}));e.forEach((t,e)=>O.set(t,n[e]))})([...b.flat(),...e.totals,...m,...e.categories,...g.map(t=>t.badge)]);const N=(d[0]?B(d[0]).height:0)*M,A=g[0]?.badge?B(g[0].badge).height*M:0,H=Math.max(k,Kt(e.figure,M,"--tablechart-min-height","200px")??0,u.minHeight?.({labelHeight:N,nameHeight:Math.max(0,S(e.categories.map(t=>B(t).height)))*M,unit:M,rows:c.length,series:h.length,stacked:e.stacked})??0),T=e.stacked?c.map(t=>{const e=P(t,h.length);return{...t,value:e,cells:t.cells.map((t,n)=>0===n?{...t,value:e}:t)}}):c,z=(u.segments??(t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"}))))(e.stacked?T.map(t=>({...t,cells:[t.cells[0]]})):c),C={labelHeight:N,badgeHeight:A,hasAnnotations:g.length>0,unit:M,series:h.length,focused:h.some(t=>t.focus),stacked:e.stacked},L=Math.max((U=S,e.stacked?U(c.map(t=>j(t,h.length,u.running).top)):U([...z.flatMap(t=>[t.from,t.to,t.value]),...c.flatMap(t=>t.cells.slice(0,h.length).map(t=>t.value))])),0);var U;const _=z.some(t=>"up"===t.kind||"down"===t.kind)?z.flatMap(t=>[t.from,t.to]):e.stacked?c.map(t=>j(t,h.length,u.running).bottom):c.flatMap(t=>t.cells.slice(0,h.length).map(t=>t.value)),E=Math.min(-S(_.map(t=>-t)),0),F=u.headroom?.(C)??N,q=2*M+(u.footroom?.(C)??0)+(E<0?N+4*M:0),R=H-F-q,D=1.02*L,V=1.02*E,W=g.find(t=>"axis-break"===t.spec.getAttribute("data-annotation"))?.spec,K=t=>{const e=Number.parseFloat(W?.getAttribute(t)??"");return Number.isFinite(e)?e:null},G=K("data-from")??K("data-at"),Z=K("data-to");let J=null;if(W&&(null!==G||null!==Z)){const e=G??0,n=Z??D,a=null===Z?e:null===G?n:(e+n)/2,o=W.getAttribute("data-size"),r=o?.match(/^\s*(\d+(?:\.\d+)?)\s*%\s*$/);null===o||r||console.warn(`[${t}] 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===Z?.22:.3,.05),.8),c=z.filter(t=>("up"===t.kind||"down"===t.kind)&&Math.max(t.from,t.to)>e&&Math.min(t.from,t.to)<n);u.breakable?E<0?console.warn(`[${t}] A chart with values below zero cannot break its scale.`):e<0||n<=e||n>D||0===e&&n===D?console.warn(`[${t}] A break from ${e} to ${n} does not fit a scale that runs from 0 to ${L}.`):c.length?console.warn(`[${t}] A break from ${e} to ${n} would cut a step that floats. Keep it below or above the steps.`):J={lo:e,hi:n,gap:a,share:s}:console.warn(`[${t}] This kind of chart cannot break its scale.`)}const Q=J?J.gap:null,X=(J&&Kt(e.figure,M,"--tablechart-break-gap",""))??13,Y=H-q,tt=D-V||1;let et=t=>Y-(t-V)/tt*R;if(J){const{lo:t,hi:e,gap:n,share:a}=J,o=R*a,r=(R-o-X)/(t+(D-e)),s=o/(e-t);et=a=>a<=t?Y-a*r:a<=n?Y-t*r-(a-t)*s:a<=e?Y-t*r-(a-t)*s-X:Y-t*r-o-X-(a-e)*r}const nt=m.length?S(m.map(t=>B(t).width))*M+12*M:0,at=e.categories[0]?.parentElement;at&&(at.style.paddingRight=nt?nt/f*100+"%":"");const ot=(f-nt)/c.length,rt=t=>t>=0&&t<c.length?t:null;e.rowAt=u.centre?null:"beside"===u.categories?(t,e)=>rt(Math.floor(e*M/(H/c.length))):t=>rt(Math.floor(t*M/ot));const st=ot/f*100,ct=100/c.length;e.rowBox="beside"===u.categories?t=>[0,t*ct,100,ct]:t=>[t*st,0,st,100],r.setAttribute("viewBox",`0 0 1000 ${w(H)}`),r.textContent="",e.checks=[];const lt={rows:c,segments:z,cx:t=>(t+.5)*ot,y:et,barWidth:Math.min(ot*a.barfill,Gt(e.figure,M)),barMax:Gt(e.figure,M),height:H,unit:M,labelHeight:N,badgeHeight:A,after:c.length,note:0,labels:"inside"===e.figure.dataset.chartLabels||"outside"!==e.figure.dataset.chartLabels&&"inside"===a.labels?"inside":"outside",insideAlign:It(e.figure),breakAt:Q,squeeze:J,breakGap:X,stacked:e.stacked,shape:jt(e.figure,a),totals:e.totals,svg:r,plot:o,values:d,series:h,seriesValues:b,names:m,categories:e.categories,centre:e.centre,config:a,checks:e.checks};o.style.setProperty("--count",String(Math.max(1,...c.map(t=>t.slot+1)))),u.draw(lt);for(const[t,n]of g.entries()){n.badge?.setAttribute("data-note",String(t+1));const a=n.series,o=t=>({...t,...t.cells[a]??t.cells[0]});n.type.draw(n.spec,n.badge,{...lt,...e.stacked&&{rows:T,...e.totals.length&&{values:e.totals}},...a>0&&!e.stacked&&{rows:c.map(o),segments:z.map(t=>{const e=o(t);return"bar"===t.kind?{...e,to:e.value}:e}),values:b[a]},after:n.after,note:t+1})}(t=>{const e=t.plan;if(!e)return;const a=e.rows.length-1,o=t=>e.series.map((n,a)=>e.cells[t]?.[a]?.step??n.step??e.rows[t]?.step??null),r=t=>{const e=o(t);return e.some(t=>null===t)?null:Math.min(...e)},c=new Set(t.totals),l=(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 n of t.figure.querySelectorAll("[data-row], [data-series], [data-note]")){if(n.closest("table, .tablechart-controls")||n.hasAttribute("data-from"))continue;const t=Number(n.dataset.note);if(t>0){const a=e.notes[t-1];a&&l(n,a.step,"--after",a.after);continue}const s=n.dataset.row?Number(n.dataset.row)-1:a;if(n.classList.contains("tablechart-connector")){const t=e.rows[s-1],a=e.rows[s];if(t&&a){const e=(t.step??-1)>(a.step??-1);l(n,e?t.step:a.step,"--i",e?t.slot+1:a.slot)}continue}if(c.has(n)){const t=o(s).filter(t=>null!==t);l(n,t.length?Math.max(...t):null,"--i",e.rows[s]?.slot??0);continue}if(n.hasAttribute("data-stack")){l(n,r(s),"--i",e.rows[s]?.slot??0);continue}const i=n.dataset.series?Number(n.dataset.series)-1:0,u=n.dataset.series?e.series[i]:void 0;if(n.classList.contains("tablechart-piece")){const t=o(s)[i]??null,a=e.cells[s]?.[i];l(n,t===r(s)?null:t,"--i",a&&null!==a.step?a.slot:s);continue}if("legend"===n.dataset.place){const t=Math.min(...e.cells.map(t=>t[i]?.step??Number.POSITIVE_INFINITY));l(n,u?.step??(Number.isFinite(t)?t:null),"--i",0);continue}const d=e.cells[s]?.[i];d&&null!==d.step?l(n,d.step,"--i",d.slot):u&&null!==u.step?l(n,u.step,"--i",s):e.rows[s]&&l(n,e.rows[s].step,"--i",e.rows[s].slot)}const u=t.figure.querySelector(`.${i}`);if(u){const t=[...e.rows,...e.cells.flat()].map(t=>t.step??-1),n=Math.max(-1,...t);n<0?l(u,null,"--i",0):l(u,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;t.plot.style.setProperty("--count",String(Math.max(h,...d)));const f=t.figure.querySelectorAll(`.${n}`),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(`.${s}`));if(m.length){const e=t=>t.style.getPropertyValue("--step")||"none",n=t=>Number(t.style.getPropertyValue("--share")||0),a=m.length,o=Math.max(0,m.findIndex((t,n)=>e(t)!==e(m[(n-1+a)%a]))),r=[];for(let t=0;t<a;t++){const n=m[(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??"",p(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))}}ft(t)})(e);const it=e.categories[0]?.parentElement;it&&"beside"!==u.categories&&!u.centre&&I(it,e.categories.filter(t=>null!==t.offsetParent),t=>({size:t.scrollWidth,room:t.clientWidth}),"--_name-fit");const ut=g.flatMap(({badge:t})=>{if(!(t instanceof HTMLElement&&t.offsetWidth))return[];const e=t.offsetWidth*M,n=t.offsetHeight*M,a=Number.parseFloat(t.style.left)/100*f,o=Number.parseFloat(t.style.top)/100*H,r=getComputedStyle(t).borderTopLeftRadius,s=r.endsWith("%")?Number.parseFloat(r)/100:null,c=(Number.parseFloat(r)||0)*M;return[$("rect",{class:l,"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("; ")})]});x(r,ut,f,H);const dt=t=>"none"!==t.dataset.place&&!t.hasAttribute("data-left-out");return e.figure.toggleAttribute("data-left-out",[...b,e.totals].some(t=>t.some(e=>!(t=>void 0!==t.dataset.missing||u.centre&&c[Number(t.dataset.row)-1]?.isTotal)(e)&&!dt(e)&&!((t,e)=>{const n=Number(t.dataset.row);return e.some(t=>dt(t)&&Number(t.dataset.row)<=n&&n<=Number(t.dataset.rowEnd??t.dataset.row))})(e,t)))),!0})(o,a))&&(u=e,m())};let M=!1;const v=new ResizeObserver(()=>{M||(M=!0,requestAnimationFrame(()=>{M=!1,y()}))}),k=new IntersectionObserver(t=>{for(const e of t)d=e.isIntersecting,m()},{threshold:a.threshold}),N=()=>{o.figure.classList.add(h),Jt(o,!0),o.figure.offsetWidth},A=()=>o.figure.classList.remove(h),H=()=>{u=null,y()},T={relabel:()=>Zt(o,a),refresh:H};g(),y(),v.observe(o.figure),k.observe(o.figure),window.addEventListener("beforeprint",N),window.addEventListener("afterprint",A),(t=>{ce.add(t),le||(le=new MutationObserver(()=>{for(const t of ce)t.relabel();requestAnimationFrame(()=>requestAnimationFrame(()=>{for(const t of ce)t.refresh()}))})).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]})})(T);const z={figure:o.figure,refresh:H,next:()=>bt(o,o.step+1),previous:()=>bt(o,o.step-1),stepTo:t=>bt(o,t),get step(){return o.step},get steps(){return o.plan?.count??0},destroy(){v.disconnect(),k.disconnect(),window.removeEventListener("beforeprint",N),window.removeEventListener("afterprint",A),(t=>{ce.delete(t),!ce.size&&le&&(le.disconnect(),le=null)})(T),Ot(o),o.figure.tablechart===z&&delete o.figure.tablechart}};return o.figure.tablechart=z,z})(o,a)):null},be=[["--tablechart-duration","--tablechart-animation-element-duration"],["--tablechart-stagger","--tablechart-animation-stagger, a share of the element time"],["--tablechart-easing","--tablechart-animation-ease"],["--tablechart-category-size","--tablechart-name-size"],["--tablechart-category-padding","--tablechart-name-padding"],["--tablechart-categories-gap","--tablechart-name-gap"],["--tablechart-inside-align","--tablechart-value-align"],["--tablechart-bar-ink","--tablechart-bar-value-color"],["--tablechart-piece-ink","--tablechart-piece-value-color"],["--tablechart-up-ink","--tablechart-up-value-color"],["--tablechart-down-ink","--tablechart-down-value-color"],["--tablechart-total-ink","--tablechart-total-value-color"],["--tablechart-series-ink","--tablechart-series-own-color"],["--tablechart-dash","--tablechart-series-dash"],["--tablechart-dot","--tablechart-series-dot"],["--tablechart-muted-share","--tablechart-series-muted-share"],["--tablechart-rule-color","--tablechart-baseline-color"],["--tablechart-rule-width","--tablechart-baseline-width"],["--tablechart-rule-opacity","--tablechart-baseline-opacity"],["--tablechart-key-size","--tablechart-legend-key-size"],["--tablechart-controls-justify","--tablechart-control-justify"],["--tablechart-controls-gap","--tablechart-control-gap"]],me={up:"grow",across:"sweep"},pe=!1;window.Tablechart={init:async(e={},n=document)=>{const a={...b,...e};a.debug&&(it.enabled=!0);const o=await he(Array.from(n.querySelectorAll(a.selector)),a);((e,n)=>{if(pe)return;const a=t=>{const e=me[String(t)];return e?[`"${t}" is now "${e}"`]:[]},o=new Set(a(n.animate));void 0!==n.hover&&o.add('the "hover" option is now "tooltip"');for(const t of e){t.hasAttribute("data-chart-hover")&&o.add("data-chart-hover is now data-chart-tooltip");const e=getComputedStyle(t);for(const[t,n]of be)e.getPropertyValue(t).trim()&&o.add(`${t} is now ${n}`);for(const n of a(t.getAttribute("data-chart-animate")))o.add(n)}o.size&&(pe=!0,console.warn(`[${t}] ${[...o].join("; ")}. The old names work until the next minor version.`))})(o,a);const r=o.map(t=>fe(t,a)).filter(t=>null!==t);return it.log(`Made ${r.length} chart(s).`),{charts:r,refresh:()=>{for(const t of r)t.refresh()},destroy:()=>{for(const t of r)t.destroy()}}},create:async(t,e={})=>{if(t.tablechart)return t.tablechart;const n={...b,...e};n.debug&&(it.enabled=!0);const[a]=await he([t],n);return a?fe(a,n):null},defaultConfig:b}}();
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-head",l="tablechart-slice",i="tablechart-name",u="tablechart-legend",d="tablechart-point",h="tablechart-hole",f="tablechart-centre",b="tablechart-break",m="tablechart-sr",p="is-printing",g="tablechart-axis",$="tablechart-tick",w="tablechart-grid",y=1e3,M={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"},v="cubic-bezier(0.3, 0.3, 0.6, 1)",x=(t,e,n=1)=>({start:t,span:e,easing:t+e>=n-1e-4?v:"linear"}),k=(t,e)=>`${t}:${e}`,N=t=>Math.round(100*t)/100,A=(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?N(t):t))}return n},S=(t,e)=>[t,...e.classes].join(" "),H=(t,e)=>{const n=document.createElement("span");return n.className=t,n.inert=!0,e.appendChild(n),n},C=(t,e,n,a,o)=>{t.style.left=e/a*100+"%",t.style.top=n/o*100+"%"},T=0,L=(t,e,n,a,o)=>{if(!e.length)return;const r="tablechart-cut-"+ ++T,s=A("mask",{id:r,maskUnits:"userSpaceOnUse"});s.appendChild(A("rect",{x:-n,y:-a,width:3*n,height:3*a,fill:"white"}));for(const i of e)i.setAttribute("fill","black"),s.appendChild(i);let c=t.querySelector(":scope > defs");if(c||(c=A("defs"),t.prepend(c)),c.appendChild(s),o)return o.setAttribute("mask",`url(#${r})`);const l=A("g",{mask:`url(#${r})`});for(const i of Array.from(t.childNodes))i!==c&&l.appendChild(i);t.appendChild(l)},O=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-"+ ++O,h=A("mask",{id:d,maskUnits:"userSpaceOnUse"});h.appendChild(A("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(A("path",{d:u([...e,...o.slice().reverse()],!0),fill:"black"})),f.push(e,o);const r=[k("--after",a[w.row-1]?.slot??0),w.part].filter(Boolean).join("; ");for(const a of[e,o])s.appendChild(A("path",{class:b,"data-part":"edge","data-note":n.note,d:u(a),style:r}))}if(!f.length)return;const p=Array.from(s.querySelectorAll(`.${b}`)),g=A("g",{mask:`url(#${d})`});for(const o of Array.from(s.childNodes))p.includes(o)||g.appendChild(o);const $=A("defs");$.appendChild(h),s.prepend($,g)}},E=t=>{let e=Number.NEGATIVE_INFINITY;for(const n of t)e=Math.max(e,n);return e},B=t=>(t.split(/[.,]/)[1]||"").length,_=t=>Number.parseFloat((t.match(/-?[\d.,]+/)||["NaN"])[0].replace(",",".")),U=(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=_(s),l=r?.5:.5*10**-B(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.`)},V={create:U,draw(t,e,a){const{rows:o,cx:r,y:l,unit:i,labelHeight:u,badgeHeight:d,height:h,svg:f,after:b}=a,[m,p]=((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),g=o[m],$=o[p];if(!g||!$)return void console.warn(`[${n}] A bracket points at a row that is not there (row ${m+1} to ${p+1}, of ${o.length}).`);const w=7*i,M=4*i,v=r(m),x=r(p),N=Math.min(l(g.value),l($.value))-u-M-.9*d,S=t=>l(t)-u-M,H=`M ${v} ${S(g.value)} L ${v} ${N} L ${x} ${N} L ${x} ${S($.value)-w}`,T=(S(g.value)-N+Math.abs(x-v)+(S($.value)-w-N))/i+1;f.appendChild(A("path",{class:s,"data-note":a.note,d:H,style:`--len:${T.toFixed(1)}; ${k("--after",b)}`}));const L=S($.value);var O;f.appendChild(A("polygon",{class:c,"data-note":a.note,points:`${x},${L} ${x-.45*w},${L-w} ${x+.45*w},${L-w}`,style:k("--after",b)})),e&&(C(e,(v+x)/2,N,y,h),e.style.setProperty("--after",String(b))),F(e,(O=g.value,($.value-O)/Math.abs(O)*100),`${g.value} to ${$.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,q=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]))},D=t=>j.get(t)??{width:t.offsetWidth,height:t.offsetHeight},I=(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},R={create(t,e){if(!t.textContent?.trim())return null;const n=U(t,e);return n.dataset.kind="reference",n},draw(t,e,a){const{rows:o,cx:r,y:s,x:c,height:l,unit:i,svg:u,after:d}=a,h=o.filter(t=>!t.isTotal&&!t.missing),f=t.hasAttribute("data-name"),b=(t.getAttribute(f?"data-name":"data-value")??"").trim();let m,p,g;if(f){const t=h.map(t=>_(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=I(b,t,h.map(t=>t.value)),s=null===e?-1:t.findIndex((n,a)=>n<=e&&e<=(t[a+1]??n)),[c,l]=[h[s],h[s+1]??h[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]);g=e,p=s<0?null:c+i*(l-c),m=!1}else g=I(b,h.map(t=>t.value),h.map(()=>1)),m=!c,p=null===g?null:c?c(g):s(g);if(null===p||null===g)return void console.warn(`[${n}] A reference line needs a number, "mean" or "median", not "${b}".`);const $=o.length>0?r(o.length-1)+r(0):y,w=c?l:s(0);if(u.appendChild(A("line",{class:"tablechart-reference","data-note":a.note,..."dotted"===t.getAttribute("data-line")&&{"data-line":"dotted"},...m?{x1:0,x2:$,y1:p,y2:p}:{x1:p,x2:p,y1:0,y2:w},style:k("--after",d)})),e){const t=D(e).width*i,n=D(e).height*i,o=4*i,r=m?[[$-t,p-n/2,t,n],[$-t,p-n-o,t,n],[$-t,p+o,t,n]]:[0,n,2*n].flatMap(e=>[[p-t/2,e,t,n],[p+o,e,t,n],[p-o-t,e,t,n]]),[s]=P([r],a.taken,[0,0,y,l]),c=r[s??0];a.taken.push(c),C(e,c[0]+t/2,c[1]+n/2,y,l),e.style.setProperty("--after",String(d)),"mean"!==b&&"median"!==b||F(e,g,`the ${b}`,a,"")}}},W={create:U,draw(t,e,n){const{rows:a,cx:o,y:r,unit:l,labelHeight:i,height:u,svg:d,values:h,after:f}=n,b=a[0],m=a[a.length-1];if(!b||!m)return;const p=i+18*l,g=10*l,$=10*l;let w=o(0),M=r(b.value)-p,v=o(a.length-1),x=r(m.value)-p,N=0;a.forEach((t,e)=>{const n=v===w?0:(o(e)-w)/(v-w),a=M+n*(x-M)-(r(t.value)-p);a>N&&(N=a)}),M-=N,x-=N;const S=v-w,H=x-M,T=Math.hypot(S,H)||1,L=S/T,O=H/T;w-=L*g,M-=O*g,v+=L*g,x+=O*g;const z=Number.parseFloat(t.getAttribute("data-at")||"0.5");if(e){const t=w+(v-w)*z,n=M+(x-M)*z,s=D(e).width*l/2,c=n+D(e).height*l/2+8*l;let u=0;a.forEach((e,n)=>{const a=(h[n]?D(h[n]).width:0)*l/2;if(Math.abs(o(n)-t)>=s+a)return;const d=r(e.value)-7*l-i;u=Math.max(u,c-d)}),M-=u,x-=u}const E=v-L*$,B=x-O*$,_=Math.hypot(E-w,B-M)/l+1;d.appendChild(A("line",{class:s,"data-note":n.note,x1:w,y1:M,x2:E,y2:B,style:`--len:${_.toFixed(1)}; ${k("--after",f)}`}));const U=-O,V=L,P=.42*$;d.appendChild(A("polygon",{class:c,"data-note":n.note,points:[`${v},${x}`,`${E+U*P},${B+V*P}`,`${E-U*P},${B-V*P}`].join(" "),style:k("--after",f)})),e&&(C(e,w+(v-w)*z,M+(x-M)*z,y,u),e.style.setProperty("--after",String(f)));const j=Number.parseFloat(t.getAttribute("data-years")||"");!Number.isNaN(j)&&j>0&&F(e,((t,e,n)=>100*(Math.pow(e/t,1/n)-1))(b.value,m.value,j),`${b.value} to ${m.value} over ${j} years`,n)}},G=(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}},K=(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}); ${k("--i",e.slot)}`}},X=(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}})},Y=(t,e,n=!1)=>{const a=X(t,e,n);return{top:Math.max(0,...a.map(t=>t.to)),bottom:Math.min(0,...a.map(t=>t.to))}},Z=(t,e)=>{const{top:n,bottom:a}=Y(t,e);return n+a},J=(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})`)},Q=(t,e,n,a={},r="")=>{const s={class:S(o,e),"data-kind":"bar","data-row":n+1,...a},c=k("--i",e.slot)+(r?`; transform-origin: ${r}`:""),l=A("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(A("rect",{...s,...r,class:S("tablechart-piece",e),"data-row":n+1,...K(t,e,o)}))}},tt=(t,e,n)=>t.some(t=>D(t).width*n>e-6*n),et=(t,e,n)=>e>=D(t).height*n*1.6,nt=(t,e,n)=>e>=D(t).width*n*1.5,at=(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},ot={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(E(l.map(t=>D(t).width*a)),0),f=Math.min(h+10*a,420);l[0]?.parentElement?.style.setProperty("--_beside",`${((f-8*a)/y*100).toFixed(2)}%`);const b=y-4*a,m=t.stacked?Math.max(E(t.rows.map(e=>Y(e,t.series.length).top)),0)||1:Math.max(E(t.rows.flatMap(e=>e.cells.slice(0,t.series.length).map(t=>Math.abs(t.value)))),0)||1,p=t.stacked?Math.max(E(t.rows.map(e=>-Y(e,t.series.length).bottom)),0):Math.max(E(t.rows.flatMap(e=>e.cells.slice(0,t.series.length).map(t=>-t.value))),0),g=Math.max(m,t.domain?.[1]??0),$=Math.max(p,-(t.domain?.[0]??0)),w=Math.max(g,t.squeeze?.hi??0)+$,M=(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,N=Math.min(v*i.barfill,u),H=G(v,t.series.length,u),T=c[0]??t.totals[0],L=T?D(T).height*a*.56:0,O=Math.max(((d&&!t.stacked?H.size:N)-L)/2,5*a),z=t=>D(t).width*a,B=t=>t.length?E(t.map(z))+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)}))),F=e=>{const n=Y(t.rows[e],t.series.length);return 0===n.top&&n.bottom<0};let V=t.stacked?B(t.totals.filter((t,e)=>!F(e))):d?B(U.filter(t=>t.value>=0).map(t=>t.label)):0,P=t.stacked?B(t.totals.filter((t,e)=>F(e))):d?B(U.filter(t=>t.value<0).map(t=>t.label)):0;if(!d&&!t.stacked)for(let o=0;o<3;o++){const t=b-f-V-P,n=e.map((t,e)=>({seg:t,label:c[e]})).filter(({seg:e,label:n})=>!nt(n,M(e.value,t),a)),o=B(n.filter(({seg:t})=>t.value>=0).map(({label:t})=>t)),r=B(n.filter(({seg:t})=>t.value<0).map(({label:t})=>t));if(o<=V&&r<=P)break;V=Math.max(V,o),P=Math.max(P,r)}const j=b-f-V-P,q=f+P+M($,j),I=t=>t<0?q-M(t,j):q+M(t,j);if(t.squeeze&&(t.breakX=I(t.squeeze.gap)),t.x=I,t.stacked)return t.rows.forEach((e,o)=>{const r=Y(e,t.series.length),s=Q(t,e,o,{"data-grow":"right"},r.bottom<0?q-I(r.bottom)+"px center":""),c=x(o)-N/2;X(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(I(e),I(r)),h=Math.max(I(e),I(r));s(i,{x:d,y:c,width:Math.max(h-d,1),height:N,...r<e&&{"data-grow":"left"}}),u.dataset.place="inside",u.toggleAttribute("data-left-out",!nt(u,h-d,a)||D(u).height*a>N),J(u,t,i),C(u,(d+h)/2,x(o),y,n)});const i=t.totals[o];i&&(i.dataset.place=F(o)?"before":"after",C(i,F(o)?I(r.bottom)-O:I(r.top)+O,x(o),y,n));const u=l[o];u&&C(u,f-8*a,x(o),y,n)}),void s.appendChild(A("line",{class:r,x1:q,x2:q,y1:0,y2:n}));if(d){t.plot.dataset.grouped="";const e=t.seriesValues.flat().filter(t=>void 0===t.dataset.missing),c=at(t.plot,e,t=>({size:D(t).height*a,room:H.size+.5*H.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=I(i.value),h=i.value<0,f=x(r)+H.offset(l);s.appendChild(A("rect",{class:S(o,e),"data-kind":"bar","data-row":r+1,"data-grow":h?"left":"right",x:Math.min(d,q),y:f,width:Math.max(Math.abs(d-q),1),height:H.size,...K(t,e,l)})),u.dataset.place=h?"before":"after",u.toggleAttribute("data-left-out",!c),C(u,h?d-O:d+O,f+H.size/2,y,n)});const i=l[r];i&&C(i,f-8*a,x(r),y,n)}),void s.appendChild(A("line",{class:r,x1:q,x2:q,y1:0,y2:n}))}const R=e.map((t,e)=>nt(c[e],Math.abs(I(t.value)-q),a));e.forEach((e,r)=>{const i=I(e.value),u=x(r),d=e.value<0,h=Math.abs(i-q);s.appendChild(A("rect",{class:S(o,e),"data-kind":e.kind,"data-row":r+1,"data-grow":d?"left":"right",x:Math.min(i,q),y:u-N/2,width:Math.max(h,1),height:N,style:k("--i",e.slot)}));const b=c[r],m=Math.max(Math.min(O,h-z(b)-6*a),6*a),p=d?1:-1;b.dataset.place=R[r]?"inside":d?"before":"after",b.dataset.kind=e.kind,C(b,R[r]?"center"===t.insideAlign?(q+i)/2:"start"===t.insideAlign?q-p*(m+z(b)/2):i+p*(m+z(b)/2):i-p*O,u,y,n);const g=l[r];g&&C(g,f-8*a,u,y,n)}),s.appendChild(A("line",{class:r,x1:q,x2:q,y1:0,y2:n}))}},rt={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=Y(e,t.series.length),i=Q(t,e,o,{},r.bottom<0?`center ${f-a(r.top)}px`:""),u=n(o)-s/2;X(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 b=Math.min(a(r),a(e)),m=Math.max(a(r),a(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",!et(f,m-b,l)||D(f).width*l>s-4*l),J(f,t,h),C(f,n(o),(b+m)/2,y,c)});const d=t.totals[o];if(d){const t=0===r.top&&r.bottom<0;d.dataset.place=t?"below":"outside",C(d,n(o),t?a(r.bottom)+4*l:a(r.top)-4*l,y,c)}}),void i.appendChild(A("line",{class:r,x1:0,x2:y,y1:f,y2:f}));if(t.series.length>1){const e=n(1)-n(0)||2*n(0),s=G(e,t.series.length,t.barMax);t.plot.dataset.grouped="";const u=t.seriesValues.flat().filter(t=>void 0===t.dataset.missing),d=at(t.plot,u,t=>({size:D(t).width*l,room:s.size+.5*s.gap}),"--_fit");return t.rows.forEach((e,r)=>{t.series.forEach((u,h)=>{const b=e.cells[h]??e.cells[0],m=t.seriesValues[h][r],p=n(r)+s.offset(h);if(b.missing)return void(m.dataset.place="none");const g=a(b.value),$=b.value<0;i.appendChild(A("rect",{class:S(o,e),"data-kind":"bar","data-row":r+1,...$&&{"data-grow":"down"},x:p,y:Math.min(g,f),width:s.size,height:Math.max(Math.abs(f-g),1),...K(t,e,h)})),m.dataset.place=$?"below":"outside",m.toggleAttribute("data-left-out",!d),C(m,p+s.size/2,$?g+4*l:g-4*l,y,c)})}),void i.appendChild(A("line",{class:r,x1:0,x2:y,y1:f,y2:f}))}const b=tt(u,s,l),m=e.map((t,e)=>"inside"===d&&!b&&!t.missing&&et(u[e],Math.abs(f-a(t.value)),l)),p=u[0]?D(u[0]).height*l*.56:0;let g=Number.POSITIVE_INFINITY;for(const[o,r]of u.entries())m[o]&&(g=Math.min(g,(s-D(r).width*l)/2));e.forEach((t,e)=>{const r=a(t.value),d=t.value<0;if(t.missing)return C(u[e],n(e),f-4*l,y,c),void(u[e].dataset.place="outside");i.appendChild(A("rect",{class:S(o,t),"data-kind":t.kind,"data-row":e+1,...d&&{"data-grow":"down"},x:n(e)-s/2,y:Math.min(r,f),width:s,height:Math.max(Math.abs(f-r),1),style:k("--i",t.slot)}));const b=d?-1:1,$=Math.min(g,(Math.abs(f-r)-p)/2),w="center"===h?(r+f)/2:"start"===h?f-b*($+p/2):r+b*($+p/2),M=d?r+4*l:r-4*l;C(u[e],n(e),m[e]?w:M,y,c),u[e].dataset.place=m[e]?"inside":d?"below":"outside"}),i.appendChild(A("line",{class:r,x1:0,x2:y,y1:f,y2:f}))}},st=0,ct={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 i=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(y,e)/2-h,10),b=f*s.ringfill,m=f-b/2,p=2*Math.PI*m,g=[];let $=0,w=0,M=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=x(M,h),N=`--share:${h.toFixed(4)}; --start:${v.start.toFixed(4)}; --span:${v.span.toFixed(4)};`,H=h*p,T=$/p*2*Math.PI-Math.PI/2;g.push(T),o.appendChild(A("circle",{class:S(l,t),"data-slice":w+1,"data-row":s+1,cx:i,cy:u,r:m,"stroke-width":b,transform:`rotate(-90 500 ${u})`,"stroke-dasharray":`${H.toFixed(1)} ${(p-H).toFixed(1)}`,"stroke-dashoffset":(-$).toFixed(1),style:`--n:${w}; --palette:var(--tablechart-color-${w+1}); --arc:${H.toFixed(1)}; --circ:${p.toFixed(1)}; ${N} --ease:${v.easing}; ${k("--i",t.slot)}`}));const L=T+H/p*Math.PI,O=Math.cos(L),z=Math.sin(L);o.appendChild(A("line",{class:"tablechart-leader",x1:i+O*(f+2*n),y1:u+z*(f+2*n),x2:i+O*(f+7*n),y2:u+z*(f+7*n),"data-row":s+1,style:`${N} ${k("--i",t.slot)}`})),c.style.setProperty("--start",v.start.toFixed(4)),c.style.setProperty("--span",v.span.toFixed(4));const E=f+9*n,B=D(c).width*n/2;C(c,i+O*(E+Math.abs(O)*B),u+z*(E+Math.abs(z)*a*.7),y,e),c.dataset.place="around",$+=H,M+=h,w+=1}),g.length>1){const t=m-b/2-1,n=m+b/2+1,a="tablechart-slices-"+ ++st,r=A("mask",{id:a,maskUnits:"userSpaceOnUse"});r.appendChild(A("rect",{x:0,y:0,width:y,height:e,fill:"white"}));for(const e of g)r.appendChild(A("line",{class:"tablechart-divide",x1:i+Math.cos(e)*t,y1:u+Math.sin(e)*t,x2:i+Math.cos(e)*n,y2:u+Math.sin(e)*n}));const s=A("g",{mask:`url(#${a})`});for(const e of Array.from(o.querySelectorAll(`.${l}`)))s.appendChild(e);const c=A("defs");c.appendChild(r),o.prepend(c,s)}c&&C(c,i,u,y,e)}},lt=["circle","square","diamond"],it=(t,e)=>{const n=t[e]?.marker?.toLowerCase().split(/\s+/)??[],a=lt.find(t=>n.includes(t));return{shape:a??lt[Math.floor(e/2)%lt.length],open:n.includes("open")||!n.includes("filled")&&!a&&e%2==1}},ut=(t,e,n,a,o={})=>{if("square"===t){const t=.88*a;return A("rect",{x:e-t,y:n-t,width:2*t,height:2*t,...o})}if("diamond"===t){const t=1.2*a;return A("polygon",{points:`${e},${n-t} ${e+t},${n} ${e},${n+t} ${e-t},${n}`,...o})}if("triangle"===t){const t=1.3*a;return A("polygon",{points:`${e},${n-t} ${e+.87*t},${n+t/2} ${e-.87*t},${n+t/2}`,...o})}return A("circle",{cx:e,cy:n,r:a,...o})},dt=t=>Number(t.toFixed(2));function ht(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 ft,bt,mt=t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"})),pt=t=>({segments:mt,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:f,svg:b,stacked:m}=e,p="step"===e.shape,g="smooth"===e.shape,$=a.length>1,w=a.some(t=>t.focus),M=n.length-1,v=l(0),x=n.length>1?c(1)-c(0):2*c(0);b.style.setProperty("--_base",`${dt(v)}px`);const k=(t,e)=>n[e]?.cells[t]??n[e]?.cells[0],N=(t,e)=>!k(t,e)||!!k(t,e)?.missing,S=n.map(t=>m?X(t,a.length,!0):null),H=(t,e)=>S[e]?.[t].to??k(t,e)?.value??0,T=(t,e)=>S[e]?.[t].from??0,O=(t,e)=>[c(e),l(H(t,e))],z=a.map((t,e)=>{if(!$)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}); `}}),E=Math.min(M,6);e.plot.style.setProperty("--count",String(E+1));const B=M>0?E/(p?n.length:M):1,_=t=>t*B,U=t=>`--i:${dt(_(t))}`,F=t=>{const e=[];let a=-1;return n.forEach((n,o)=>{N(t,o)||(a<0&&(a=o),(o===M||N(t,o+1))&&((p||o>a)&&e.push([a,o]),a=-1))}),e},V=(t,e)=>`--i:${dt(_(t)+1)}; --d:${dt(_(p?e+1:e)-_(t))}`,j=(t,e)=>({"data-from":t+1,"data-to":e+1,...p&&{"data-flat":""}}),q=g?a.map((t,e)=>ht(n.length,t=>N(e,t),t=>O(e,t))):[],I=g&&t?a.map((t,e)=>ht(n.length,t=>N(e,t),t=>[c(t),l(T(e,t))])):[],R=(t,e,n)=>{const a=[];return t.forEach(([o,r],s)=>{p?(a.push(`H${dt(o+n*x/2)}`),s<t.length-1&&a.push(`V${dt(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])=>`${dt(t)},${dt(e)}`;return`C${s(o)} ${s(r)} ${s(e)}`}(t[s-1],[o,r],e[s-1],e[s]):`L${dt(o)},${dt(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)=>g?t[e].slice(n,a+1):null,K=t=>c(t)-(p?x/2:0),Y=t=>c(t)+(p?x/2:0);t&&a.forEach((t,e)=>(t=>{const e=A("g",{class:"tablechart-area",...z[t].attrs,...m&&{"data-stacked":""},style:z[t].ink}),n=F(t),a=A("g",{class:"tablechart-area-fill",style:`--rows:${dt(E+1)}; ${n.length?V(...n[0]):""}`});e.appendChild(a);for(const[o,r]of n){const e=W(t,o,r,H),n=W(t,o,r,T),s=G(I,t,o,r)?.reverse()??null,c=[`M${dt(K(o))},${dt(n[0][1])}`,`L${dt(K(o))},${dt(e[0][1])}`,...R(e,G(q,t,o,r),1),`L${dt(Y(r))},${dt(n[n.length-1][1])}`,...R(n.reverse(),s,-1),"Z"].join(" ");a.appendChild(A("path",{d:c,...j(o,r),style:V(o,r)}))}b.appendChild(e)})(e)),a.forEach((t,e)=>(t=>{const e=a[t];for(const[n,a]of F(t)){const o=W(t,n,a,H),r=[`M${dt(K(n))},${dt(o[0][1])}`,...R(o,G(q,t,n,a),1)].join(" ");b.appendChild(A("path",{class:"tablechart-series",...z[t].attrs,d:r,...e.line&&{"data-line":e.line},...j(n,a),style:`${z[t].ink}${V(n,a)}`}))}})(e)),p||(()=>{const t=a.map((t,e)=>$?it(a,e):{shape:"circle",open:!1}),e=(e,n,a)=>{const[o,r]=O(e,n);return ut(t[e].shape,o,r,4*u,{...a,style:`${a.style??""}${s=r,`--rise:${dt(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:h,"data-row":t+1,...$&&{"data-series":a+1}})):[]);L(b,r,y,i),a.forEach((n,a)=>{for(const r of o(a))b.appendChild(e(a,r,{class:d,...z[a].attrs,"data-marker":t[a].shape,...t[a].open&&{"data-open":""},"data-row":r+1,style:z[a].ink}))})})();const Z=(t,e)=>{let n=e;for(;n<M&&!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(p&&n>0&&!N(e,n-1)&&k(e,n-1)?.value===o.value)return"none";if(w&&!a[e].focus)return"none";if(m)return"middle";const r=o.value<0?"below":"above";if(!$||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&&O(e,n)[1]+7*u+f>v?"above":"below"},Q=$&&!w&&a.length>2&&!m&&!p,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=D(o[t][n]).width*u,[s,c]=O(t,n);return e(a).map(t=>[s-r/2,"above"===t?c-7*u-f:c+7*u,r,f])}),s=a.flatMap((t,e)=>n.flatMap((t,n)=>{if(N(e,n))return[];const[a,o]=O(e,n);return[[a-4*u,o-4*u,8*u,8*u]]})),l=P(r,s,[0,0,c(M)+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(dt(p?(_(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]):!(!m&&!p)&&(D(o[t][e]).width*u>(p?Z(t,e)-e+1:1)*x-4*u||!!(m&&t>0&&H(t,e)<T(t,e))||m&&Math.abs(l(T(t,e))-l(H(t,e)))<1.2*f))(e,n)),p&&"none"!==a?t.dataset.rowEnd=String(Z(e,n)+1):delete t.dataset.rowEnd,"none"===a)return;const r=D(t).width*u/2+4*u;let s=c(n);p?s=(c(n)+c(Z(e,n)))/2:"middle"===a&&0===n?s+=r:"middle"===a&&n===M&&(s-=r);const d=l(H(e,n)),h={middle:(l(T(e,n))-d)/2,above:-7*u,below:7*u};C(t,s,d+h[a],y,i)})});const et=s.map((t,e)=>{let n=M;for(;n>0&&N(e,n);)n--;const[a,o]=O(e,n);return{name:t,x:(p?a+x/2:a)+10*u,y:m?(o+l(T(e,n)))/2:o}}),nt=(s[0]?D(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))C(t.name,t.x,t.y,y,i);const at=n.some(t=>t.cells.some(t=>!t.missing&&t.value<0)),ot=t||m||2!==a.length||w||at?v:i-2*u;b.appendChild(A("line",{class:r,x1:0,x2:c(M)+c(0),y1:ot,y2:ot}))}}),gt=pt(!1),$t=pt(!0),wt=new Set,yt={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.`;wt.has(a)||(wt.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=tt(i,a,c),b=d??"center",m=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&&et(i[a],r,c)}}),p=i[0]?D(i[0]).height*c*.56:0;let g=Number.POSITIVE_INFINITY;for(const[o,r]of m.entries())r.inside&&(g=Math.min(g,(a-D(i[o]).width*c)/2));const $=t.length,w=(t,e,n=!1)=>`--start:${(t/$).toFixed(4)}; --span:${(e/$).toFixed(4)}; --ease:${n?v:"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(A("line",{class:"tablechart-connector",x1:i,x2:u,y1:c,y2:c,"data-row":r+2,style:`${k("--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(A("rect",{class:S(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:`${k("--i",n.slot)}; ${w(r,1,r===t.length-1)}`}));const M=i[r];M.style.setProperty("--start",(r/$).toFixed(4)),M.style.setProperty("--span",(1/$).toFixed(4));const v=Math.min(g,(d-p)/2),x="center"===b?u+d/2:"end"===b!==h?u+v+p/2:u+d-v-p/2;M.dataset.place=f?"inside":"outside",M.dataset.kind=n.kind;const N=f?x:"down"===n.kind?u+d+D(M).height*c+3*c:u-3*c;C(M,e(r),N,y,s)}),l.appendChild(A("line",{class:r,x1:0,x2:y,y1:h,y2:h}))}},Mt={enabled:!1,log(...t){Mt.enabled&&console.log(`[${n}]`,...t)},timed(t,e,a){if(!Mt.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):Mt.log(`${t} took ${s.toFixed(1)} ms for ${c} rows.`,e),r}},vt=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}},xt=t=>Array.from(t.querySelector("thead tr:last-child")?.children??[]).slice(1),kt=t=>Number(t.toPrecision(12)),Nt=(t,e)=>{const n=t/Math.max(1,e)||1,a=10**Math.floor(Math.log10(n)),o=n/a;return kt((o<1.42?1:o<3.17?2:o<7.08?5:10)*a)},At=(t,e,n)=>{const a=[];for(let o=Math.ceil(t/n-1e-9);o*n<=e+1e-9*n;o++)a.push(kt(o*n));return a},St=(t,e=t)=>{do{const e=Math.round(t/10**Math.floor(Math.log10(t)+1e-9));t=kt(t*(2===e?2.5:2))}while(Math.abs(t/e-Math.round(t/e))>1e-9);return t},Ht=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},Ct=(t,e)=>{let{step:n,ticks:a}=t;for(;n&&a.length>2&&!e(a);)n=St(n,t.step),a=At(t.min,t.max,n);return{...t,step:n,ticks:a}},Tt=["axis-break","trend","bracket"],Lt=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))}},Ot=(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)),Lt(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",Et=["--tablechart-surface","--tablechart-tooltip-surface","--tablechart-tooltip-color","--tablechart-tooltip-border","--tablechart-tooltip-radius","--tablechart-tooltip-padding","--tablechart-tooltip-shadow"],Bt=null,_t=null,Ut=null,Ft=0,Vt=()=>{clearTimeout(Ft),Bt&&_t&&(Bt.hidden=!0,_t=null,Ut=null)},Pt=!1,jt=!0,qt=NaN,Dt=NaN,It=!1,Rt=(t,e)=>e/Number.parseFloat(getComputedStyle(t).width)||1,Wt=()=>{clearTimeout(Ft),Ft=window.setTimeout(Vt,120)},Gt=(t,e)=>{const n=e?e.style.getPropertyValue("--step"):"x";return""===n||Number(n)<t.step},Kt=(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},Xt=(t,e,n)=>{const a=t.series.length>1,o=[];for(const[s,c]of t.seriesValues.entries()){if(!Gt(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?Kt(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&&Gt(t,r)&&o.push({name:n.totallabel,value:r.textContent??""}),o},Yt=(t,e,n)=>{if(clearTimeout(Ft),_t===t&&Ut===e)return;const a=(t.type.tooltip??Xt)(t,e,n);if(!a.length)return Vt();_t&&_t!==t&&Vt(),Bt??(Bt=(()=>{const t=document.createElement("div");return t.className=zt,t.setAttribute("aria-hidden","true"),t.hidden=!0,ft=document.createElement("div"),(bt=document.createElement("div")).className=`${zt}-arrow`,t.append(ft,bt),document.body.append(t),t.addEventListener("pointerenter",()=>clearTimeout(Ft)),t.addEventListener("pointerleave",t=>"mouse"===t.pointerType&&Wt()),document.addEventListener("pointerdown",e=>{const n=e.target;!_t||_t.plot.contains(n)||t.contains(n)||Vt()}),window.addEventListener("resize",Vt),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);ft.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 Et){const t=l.getPropertyValue(f).trim();t?Bt.style.setProperty(f,t):Bt.style.removeProperty(f)}Bt.style.setProperty("--_color",l.color),Bt.style.colorScheme=l.colorScheme,Bt.style.fontFamily=l.fontFamily;const i=(t=>{const e=t.tooltipparent;return("string"==typeof e?document.querySelector(e):e)??document.body})(n);Bt.parentElement!==i&&i.append(Bt),_t=t,Ut=e,Bt.hidden=!1,Bt.style.left="0px",Bt.style.top="0px";const u=Bt.getBoundingClientRect(),d={x:u.left,y:u.top,scale:Rt(Bt,u.width)},h=Rt(t.plot,t.plot.getBoundingClientRect().width);Bt.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:b}=document.documentElement,m=n.top-r,p=b-n.bottom-r,g=i+d<=m||!(i+d<=p)&&m>=p,$=g?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($,b-i-r))-a.y)/a.scale+"px",t.dataset.side=g?"top":"bottom",e.style.left=Math.max(h,Math.min(w-y,l-h))/a.scale-u+"px"})(Bt,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)},Zt=t=>{_t===t&&Vt()},Jt={area:$t,bar:ot,column:rt,donut:ct,line:gt,waterfall:yt},Qt={"axis-break":z,trend:W,bracket:V,reference:R},te=Object.keys(Qt),ee=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)=>{const a=t.getAttribute(e);return null===a?n:"false"!==a},oe=(t,e)=>Boolean(e.animate)&&"false"!==t.getAttribute("data-chart-animate"),re=(t,e)=>{const n=t.dataset.chartShape;return n&&ne.includes(n)?n:ne.includes(e.shape)?e.shape:"straight"},se=0,ce=(t,e,o=null)=>{const r=o??(t.getAttribute("data-chart")||"column"),s=Jt[r];if(!s)return console.warn(`[${n}] Unknown chart type "${r}". Known types: ${Object.keys(Jt).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(vt);return o.length||o.push(vt(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(ee(e)))continue;const t=document.createElement("span");t.className=m,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-"+ ++se),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=xt(t),o=Math.max(1,E(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 d=l.length>1;d&&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 b=h&&!!s.stackable&&d,p=document.createElement("div");p.className="tablechart-plot",p.setAttribute("aria-hidden","true");const w=A("svg",{role:"presentation",focusable:"false"});p.appendChild(w),t.appendChild(p);const y=s.centre?c.filter(t=>!t.isTotal):c,M=Math.max(0,E(y.flatMap(t=>t.cells.slice(0,l.length).map(t=>B(t.number))))),v=l.map((t,e)=>Math.max(0,E(c.map(t=>B(t.cells[e]?.number??""))))),x=l.map((t,e)=>c.map((t,n)=>{const o=t.cells[e]??t.cells[0],r=H(a,p);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),d&&(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})),k=x[0],N=b&&s.totals?c.map((t,e)=>{const n=H(a,p);n.classList.add(...t.classes),n.dataset.kind="total",n.dataset.row=String(e+1),n.dataset.value=String(Z(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}):[],S=c[c.length-1],C=l.some(t=>t.focus),T=t.getAttribute("data-chart-legend"),L=d&&!s.columns&&(null===T?e.legend||void 0!==s.legend:"false"!==T)?document.createElement("div"):null;L&&(L.className=u,L.setAttribute("aria-hidden","true"),L.inert=!0);const O=d&&!s.columns?l.map((n,a)=>{const o=H(i,L??p);L&&(o.dataset.place="legend");const r=s.legend??s.swatch;if(r&&(o.dataset.swatch=r),o.textContent=n.name,!r&&"step"!==re(t,e)){const t=it(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",C&&!n.focus?"1":"0"),o.style.setProperty("--i",String(S.slot)),o}):[],z=s.centre?H(f,p):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(B(t.number)))}const _=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,U="beside"===s.categories,F=document.createElement("div");F.className="tablechart-categories",F.setAttribute("aria-hidden","true"),F.inert=!0,U?F.dataset.place="beside":s.centre&&(F.dataset.place="key"),F.style.setProperty("--_columns",String(c.length));let V=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(V+1),t.style.setProperty("--n",String(V)),t.style.setProperty("--palette",`var(--tablechart-color-${V+1})`),V+=1)),t.style.setProperty("--i",String(a.slot)),t.dataset.row=String(n+1),F.appendChild(t)}(U?p:t).appendChild(F),L&&t.appendChild(L);const P=l.filter(t=>!t.group),j=!s.axes&&!s.centre&&ae(t,"data-chart-axis",e.axis),q=s.axes?{titles:P.slice(0,2).map((t,n)=>{const a=H(`${g}-title`,p);return a.dataset.axis=n?"y":"x",a.textContent=t.name,t.key&&e.langattribute&&a.setAttribute(e.langattribute,t.key),a}),ticks:H(`${$}s`,p),numbers:!0}:j||!s.centre&&ae(t,"data-chart-grid",e.grid)?{titles:[],ticks:H(`${$}s`,p),numbers:j}:null;s.text?.({figure:t,plot:p,rows:c,series:l,config:e});const D=oe(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=>Tt.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"),b=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]++}}),m=Math.max(-1,...b.map(t=>t.step??-1));if(m>=0)for(const[w,y]of n.entries())f(y)&&(b[w]={step:m,slot:i[m]++});const p=a.map(t=>({step:r(t)?u(t.getAttribute("data-fragment-index")):null})),g=s.map(t=>t.map(()=>({step:null,slot:0}))),$=Math.max(0,...s.map(t=>t.length));for(let w=0;w<$;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"));g[t][w]={step:a,slot:i[a]++}}return{rows:b,series:p,cells:g,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",b.length-1)]:[0,b.length-1];let o=null;for(let r=Math.min(n,a);r<=Math.max(n,a);r++)for(const t of[b[r]?.step??null,...(g[r]??[]).map(t=>t.step)])null!==t&&(null===o||t>o)&&(o=t);const s=p[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?b.length:b.filter(t=>t.step===o).length;return{step:o,after:c}}),count:c.length,indexes:c}})(t):null;s.axes&&t.querySelector("[data-fragment]")&&Mt.log(`A ${r} chart has no steps, so it is shown whole.`,t),D&&t.setAttribute("data-steps","");const I=t.getAttribute("data-chart-keys"),R=D&&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=A("svg",{viewBox:"0 0 16 16",focusable:"false"});s.appendChild(A("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=m,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:I&&`${I}-previous`,next:I&&`${I}-next`,hint:I&&`${I}-step`},e.langattribute):null;R&&t.appendChild(R);const W=t.getAttribute("data-chart-table"),G=W&&ie.includes(W)?W:e.table;if("never"===G)t.removeAttribute("data-table");else{t.setAttribute("data-table",G);const e=t.querySelector(":scope > table");e&&t.append(e)}const K=Array.from(t.querySelectorAll("[data-annotation]")).map(t=>{const e=t.getAttribute("data-annotation"),a=Qt[e];if(!a)return console.warn(`[${n}] Unknown annotation "${e}". Known annotations: ${Object.keys(Qt).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,p),series:r,after:c.length}}).filter(t=>null!==t);oe(t,e)&&t.setAttribute("data-animate",ue(t,r,e,Boolean(D)));const X={figure:t,plot:p,svg:w,rows:c,decimals:M,type:s,values:k,series:l,seriesValues:x,names:L?[]:O,categories:Array.from(F.children),centre:z,axes:q,stacked:b,totals:N,totalCell:_,rowAt:null,rowBox:null,annotations:K,checks:[],plan:D,step:0,controls:R};R?.addEventListener("click",t=>{const e=t.target.closest("button")?.dataset.go;e&&Ot(X,X.step+("next"===e?1:-1))}),Ot(X,0,!0);const Y=t.getAttribute("data-chart-tooltip"),J="false"!==Y&&("auto"===Y?"auto":null!==Y||e.tooltip);return J&&((t,e,n=!1)=>{const{plot:a}=t;a.setAttribute("data-hover",""),(()=>{if(It)return;It=!0,document.addEventListener("pointermove",t=>{"mouse"===t.pointerType&&(jt=t.screenX!==qt||t.screenY!==Dt,qt=t.screenX,Dt=t.screenY,jt&&(Pt=!1))},{capture:!0,passive:!0});const t=()=>{Pt=!0,Vt()};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 _t===t?Vt():void 0;const c=(e=>{if(t.rowAt){const n=a.getBoundingClientRect(),o=Rt(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 _t===t?Vt():void 0;Yt(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||Yt(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,_t===t&&Wt())})})(X,e,"auto"===J),be(X,e),X},le={grow:"grow",sweep:"sweep"},ie=["never","auto","print","always"],ue=(t,e,n,a)=>{const o="line"===e||"area"===e,r=le[t.getAttribute("data-chart-animate")??""]??le[String(n.animate)];return o?a?"sweep":r??"sweep":"donut"===e||"waterfall"===e?r??"grow":"grow"},de=t=>{const e=getComputedStyle(t).getPropertyValue("--tablechart-value-align").trim();return"start"===e||"center"===e||"end"===e?e:null},he=(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*y:s*("em"===r[2]?Number.parseFloat(o.fontSize):"rem"===r[2]?Number.parseFloat(getComputedStyle(document.documentElement).fontSize):1)*e},fe=(t,e)=>he(t,e,"--tablechart-bar-max","60px")??Number.POSITIVE_INFINITY,be=(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:me(a,a.dataset.decimals?Number(a.dataset.decimals):t.decimals,e.locale)},me=(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)}},pe=(t,e)=>{t.figure.classList.toggle("is-shown",e)},ge=t=>"id"===t||"style"===t||t.startsWith("data-chart"),$e=/^\s*(?:Table)?:\s+/,we=t=>"P"===t?.tagName&&$e.test(t.textContent??""),ye=/^\s*([a-z][\w-]*)((?:\s+[\w-]+=[^\s:]+)*)\s*(:\s*|$)/,Me=t=>{const e=xe(t);return"P"===e?.tagName?e:t},ve=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},xe=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},ke="strong, b, span.total",Ne="data-chart-made",Ae=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,Se=new Set,He=null,Ce=["column","bar"],Te=t=>{const e=t.getAttribute("data-chart")||"column";if(!Ce.includes(e))return null;const n=getComputedStyle(t).getPropertyValue("--tablechart-type").trim();return Ce.includes(n)?n:e},Le=!1,Oe=async(t,e)=>{const a=(t=>t.map(t=>{const e=t.closest("p"),n=we(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||ge(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?we(r)?r:we(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=Me(t).firstChild;if(e?.nodeType!==Node.TEXT_NODE)return null;const n=ye.exec(e.textContent??"");if(!n||!te.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=Me(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($e,""),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),Mt?.log?.(`A ${o?"table":"caption"} with chart attributes was wrapped in a figure of its own`),a}))(t.filter(t=>!t.hasAttribute(Ne)));return(t=>{const e=t.find(t=>"FIGURE"!==t.tagName);!Le&&e&&(Le=!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:ve(o.rows):ve(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||Mt?.log?.(`The table from "${e}" has no header row, so a screen reader cannot name its columns.`),Mt?.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=xe(e);a?.matches(ke);a=xe(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=xe(e);t?.matches(ke);t=xe(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=xt(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}`)})}),Mt?.log?.(`Keys for "${t}" written onto ${o.querySelectorAll("tbody th").length} rows`)}})(a,e.langattribute),a},ze=(t,e)=>{const a=Mt.timed("Building",t,()=>ce(t,e));return a?(t.setAttribute(Ne,""),((t,e)=>{let a=t,r=Te(a.figure),s=null,c=!1,i=!1;const d=async()=>{if(!oe(a.figure,e))return pe(a,!0);const t=a.figure.classList.contains("is-shown");if(!c||null===s||t||i)!c&&e.replay&&t&&pe(a,!1);else{i=!0;const t=Ae()?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(Ae())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)),i=!1,!c&&e.replay||pe(a,!0)}var n},b=()=>{const t=Te(a.figure);if(!t||t===r)return;const n=Mt.timed("Building",a.figure,()=>ce(a.figure,e,t));n&&((t=>{Zt(t),t.plot.remove(),t.categories[0]?.parentElement?.remove(),t.figure.querySelector(`:scope > .${u}`)?.remove(),t.controls?.remove()})(a),Ot(n,a.step,!0),a=n,r=t,s=null)},m=()=>{b();const t=a.plot.clientWidth;t&&t!==s&&Mt.timed("Layout",a.figure,()=>((t,e)=>{const{plot:a,svg:r,rows:s,type:c,values:i,series:u,seriesValues:d,names:b,annotations:m}=t,p=Number.parseFloat(t.figure.dataset.chartAspect??""),M=p>0?p:c.aspect??e.aspect,v="beside"===c.categories,k=t.axes&&!c.axes?t.axes:null,S=v?null:t.categories[0]?.parentElement;let T=null;if(k){a.style.margin="",S&&(S.style.marginLeft="");const n=a.clientWidth;if(!n)return!1;const o=c.segments?.(s)??[],r=t.stacked?s.flatMap(t=>Object.values(Y(t,u.length,c.running))):o.some(t=>"up"===t.kind||"down"===t.kind)?o.flatMap(t=>[t.from,t.to]):s.flatMap(t=>t.cells.slice(0,u.length).filter(t=>!t.missing).map(t=>t.value)),l=Math.min(0,-E(r.map(t=>-t))),i=Math.max(0,E(r)),d=Number.parseFloat(getComputedStyle(a).fontSize)||16,{chartScaleY:h,chartScale:f}=t.figure.dataset,b=Ht(h??f);if(b&&b.length>2)T={min:b[0],max:b[b.length-1],step:0,ticks:b};else{const[t,e]=b??[l,i],a=Nt(e-t,Math.max((v?n/9:n*M/3)/d,2)),o=(t,e)=>b?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);T={min:r,max:s,step:a,ticks:At(r,s,a)}}k.ticks.textContent="";const m=s.find(t=>!t.missing),p=E(T.ticks.map(t=>B(String(t))));for(const t of T.ticks){const n=H($,k.ticks);n.dataset.value=String(t),n.dataset.place="none",m?.prefix&&(n.dataset.prefix=m.prefix),m?.suffix&&(n.dataset.suffix=m.suffix),me(n,p,e.locale)}if(k.numbers){const t=Array.from(k.ticks.children);for(const e of t)delete e.dataset.place;q(t),v?a.style.marginBottom=`${(t[0]?D(t[0]).height:0)+6}px`:(a.style.marginLeft=`${E([0,...t.map(t=>D(t).width)])+10}px`,S&&(S.style.marginLeft=a.style.marginLeft))}}const O=a.clientWidth;if(!O)return!1;const z=y/O,_=y*M;a.classList.add("is-placed");for(const n of[...d.flat(),...t.totals])delete n.dataset.place;a.style.removeProperty("--_fit"),t.categories[0]?.parentElement?.style.removeProperty("--_beside");const U=c.axes?t.axes:null;let F=[];if(U){const n=Number.parseFloat(getComputedStyle(a).fontSize)||16,o=u.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,d=[Ht(c),Ht(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]??-E(t.map(t=>-t)),o=n?.[1]??E(t);if(!n){const t=.05*(o-a||Math.abs(o)||1);a-=t,o+=t}const r=Nt(o-a,e);return{min:a,max:o,step:r,ticks:At(a,o,r)}})(r.length?r.map(e=>e.cells[t].value):[0,1],Math.max(e?_/z/(4*n):O/(9*n),4),d[e])),U.ticks.textContent="",F.forEach((t,n)=>{const a=r[0]?.cells[o[n]],s=E(t.ticks.map(t=>B(String(t))));for(const o of t.ticks){const t=H($,U.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),me(t,s,e.locale)}})}const V=U?Array.from(U.ticks.children):[];q([...d.flat(),...t.totals,...b,...t.categories,...m.map(t=>t.badge),...U?.titles??[],...V]);const P=(i[0]?D(i[0]).height:0)*z,j=m[0]?.badge?D(m[0].badge).height*z:0,I=Math.max(_,he(t.figure,z,"--tablechart-min-height","200px")??0,c.minHeight?.({labelHeight:P,nameHeight:Math.max(0,E(t.categories.map(t=>D(t).height)))*z,unit:z,rows:s.length,series:u.length,stacked:t.stacked})??0),R=t.stacked?s.map(t=>{const e=Z(t,u.length);return{...t,value:e,cells:t.cells.map((t,n)=>0===n?{...t,value:e}:t)}}):s,W=(c.segments??(t=>t.map(t=>({...t,from:0,to:t.value,kind:"bar"}))))(t.stacked?R.map(t=>({...t,cells:[t.cells[0]]})):s),G={labelHeight:P,badgeHeight:j,hasAnnotations:m.length>0,unit:z,series:u.length,focused:u.some(t=>t.focus),stacked:t.stacked},K=Math.max((X=E,t.stacked?X(s.map(t=>Y(t,u.length,c.running).top)):X([...W.flatMap(t=>[t.from,t.to,t.value]),...s.flatMap(t=>t.cells.slice(0,u.length).map(t=>t.value))])),0);var X;const J=W.some(t=>"up"===t.kind||"down"===t.kind)?W.flatMap(t=>[t.from,t.to]):t.stacked?s.map(t=>Y(t,u.length,c.running).bottom):s.flatMap(t=>t.cells.slice(0,u.length).map(t=>t.value)),Q=Math.min(-E(J.map(t=>-t)),0),tt=c.headroom?.(G)??P,et=2*z+(c.footroom?.(G)??0)+(Q<0?P+4*z:0),nt=I-tt-et,ot=T?Math.max(T.max,K):1.02*K,rt=T?Math.min(T.min,Q):1.02*Q,st=m.find(t=>"axis-break"===t.spec.getAttribute("data-annotation"))?.spec,ct=t=>{const e=Number.parseFloat(st?.getAttribute(t)??"");return Number.isFinite(e)?e:null},lt=ct("data-from")??ct("data-at"),it=ct("data-to");let ut=null;if(st&&(null!==lt||null!==it)){const t=lt??0,e=it??ot,a=null===it?t:null===lt?e:(t+e)/2,o=st.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===it?.22:.3,.05),.8),l=W.filter(n=>("up"===n.kind||"down"===n.kind)&&Math.max(n.from,n.to)>t&&Math.min(n.from,n.to)<e);c.breakable?Q<0?console.warn(`[${n}] A chart with values below zero cannot break its scale.`):t<0||e<=t||e>ot||0===t&&e===ot?console.warn(`[${n}] A break from ${t} to ${e} does not fit a scale that runs from 0 to ${K}.`):l.length?console.warn(`[${n}] A break from ${t} to ${e} would cut a step that floats. Keep it below or above the steps.`):ut={lo:t,hi:e,gap:a,share:s}:console.warn(`[${n}] This kind of chart cannot break its scale.`)}const dt=ut?ut.gap:null,ht=(ut&&he(t.figure,z,"--tablechart-break-gap",""))??13,ft=I-et,bt=ot-rt||1;let mt,pt,gt=t=>ft-(t-rt)/bt*nt;if(ut){const{lo:t,hi:e,gap:n,share:a}=ut,o=nt*a,r=(nt-o-ht)/(t+(ot-e)),s=o/(e-t);gt=a=>a<=t?ft-a*r:a<=n?ft-t*r-(a-t)*s:a<=e?ft-t*r-(a-t)*s-ht:ft-t*r-o-ht-(a-e)*r}let $t=[];if(U){const t=6*z,[e,n]=U.titles,a=t=>t?D(t).width*z:0,o=t=>t?D(t).height*z:0,r=V.filter(t=>"x"===t.dataset.axis),s=V.filter(t=>"y"===t.dataset.axis),c=o(V[0]),l=a(n)+E([0,...s.map(a)])+2*t,i=c/2;pt=[l,i,y-l-E([0,...r.map(a)])/2,I-i-o(e)-c-2*t];const[u,d,h,f]=pt,[b,m]=F,p=t=>u+(t-b.min)/(b.max-b.min||1)*h,g=t=>d+f-(t-m.min)/(m.max-m.min||1)*f;mt=p,gt=g;const $=t=>a(r.find(e=>Number(e.dataset.value)===t));$t=[Ct(b,e=>e.every((n,a)=>!a||p(n)-p(e[a-1])>($(n)+$(e[a-1]))/2+t)).ticks,Ct(m,e=>e.every((n,a)=>!a||g(e[a-1])-g(n)>c+t/2)).ticks];for(const w of V){const e=Number(w.dataset.value),n="x"===w.dataset.axis?0:1,a=$t[n].includes(e);w.dataset.place=a?n?"before":"below":"none",a&&C(w,n?u-t:p(e),n?g(e):d+f+t,y,I)}e&&C(e,u+h/2,I-o(e),y,I),n&&C(n,0,d+f/2,y,I)}const wt=b.length?E(b.map(t=>D(t).width))*z+12*z:0,yt=t.categories[0]?.parentElement;yt&&(yt.style.paddingRight=wt?wt/y*100+"%":"");const Mt=(y-wt)/s.length,vt=t=>t>=0&&t<s.length?t:null;t.rowAt=c.centre?null:"beside"===c.categories?(t,e)=>vt(Math.floor(e*z/(I/s.length))):t=>vt(Math.floor(t*z/Mt));const xt=Mt/y*100,kt=100/s.length;if(t.rowBox="beside"===c.categories?t=>[0,t*kt,100,kt]:t=>[t*xt,0,xt,100],r.setAttribute("viewBox",`0 0 1000 ${N(I)}`),r.textContent="",pt&&mt){const[n,a,o,s]=pt,[c,l]=$t,i=mt;ae(t.figure,"data-chart-grid",e.grid)&&r.appendChild(A("path",{class:w,d:[...c.map(t=>`M${N(i(t))},${N(a)}V${N(a+s)}`),...l.map(t=>`M${N(n)},${N(gt(t))}H${N(n+o)}`)].join("")})),r.appendChild(A("path",{class:g,d:[`M${N(n)},${N(a)}V${N(a+s)}H${N(n+o)}`,...c.map(t=>`M${N(i(t))},${N(a+s)}v${N(4*z)}`),...l.map(t=>`M${N(n)},${N(gt(t))}h${N(-4*z)}`)].join("")}))}t.checks=[];const St={rows:s,segments:W,cx:t=>(t+.5)*Mt,y:gt,x:mt,frame:pt,length:(e,n)=>he(t.figure,z,e,n),barWidth:Math.min(Mt*e.barfill,fe(t.figure,z)),barMax:fe(t.figure,z),height:I,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:de(t.figure),breakAt:dt,squeeze:ut,breakGap:ht,domain:T?[T.min,T.max]:null,stacked:t.stacked,shape:re(t.figure,e),totals:t.totals,svg:r,plot:a,values:i,series:u,seriesValues:d,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)))),c.draw(St),St.rowAt&&(t.rowAt=St.rowAt),k&&T){const n=6*z,a=v&&St.x?St.x:gt,o=Array.from(k.ticks.children),s=t=>D(o.find(e=>Number(e.dataset.value)===t)??o[0]),c=Ct(T,t=>t.every((e,o)=>!o||(v?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=>!ut||t<=ut.lo||t>=ut.hi);for(const t of o){const e=Number(t.dataset.value),o=k.numbers&&c.includes(e);t.dataset.place=o?v?"below":"before":"none",o&&C(t,v?a(e):-n,v?I+n:a(e),y,I)}const l=y-wt;ae(t.figure,"data-chart-grid",e.grid)&&r.prepend(A("path",{class:w,d:c.map(t=>v?`M${N(a(t))},0V${N(I)}`:`M0,${N(a(t))}H${N(l)}`).join("")})),k.numbers&&r.appendChild(A("path",{class:g,d:[v?`M${N(a(T.min))},${N(I)}H${N(a(T.max))}`:`M0,${N(a(T.max))}V${N(a(T.min))}`,...c.map(t=>v?`M${N(a(t))},${N(I)}v${N(4*z)}`:`M0,${N(a(t))}h${N(-4*z)}`)].join("")}))}for(const[n,o]of m.entries()){o.badge?.setAttribute("data-note",String(n+1));const e=o.series,a=t=>({...t,...t.cells[e]??t.cells[0]});o.type.draw(o.spec,o.badge,{...St,...t.stacked&&{rows:R,...t.totals.length&&{values:t.totals}},...e>0&&!t.stacked&&{rows:s.map(a),segments:W.map(t=>{const e=a(t);return"bar"===t.kind?{...e,to:e.value}:e}),values:d[e]},after: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 i=t.figure.querySelector(`.${f}`);if(i){const t=[...e.rows,...e.cells.flat()].map(t=>t.step??-1),n=Math.max(-1,...t);n<0?c(i,null,"--i",0):c(i,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}`),b=h[h.length-1];if("waterfall"===t.figure.dataset.chart&&"total"===b?.dataset.kind&&h.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(`.${l}`));if(m.length){const e=t=>t.style.getPropertyValue("--step")||"none",n=t=>Number(t.style.getPropertyValue("--share")||0),a=m.length,o=Math.max(0,m.findIndex((t,n)=>e(t)!==e(m[(n-1+a)%a]))),r=[];for(let t=0;t<a;t++){const n=m[(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??"",x(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))}}Lt(t)})(t);const Tt=t.categories[0]?.parentElement;Tt&&"beside"!==c.categories&&!c.centre&&at(Tt,t.categories.filter(t=>null!==t.offsetParent),t=>({size:t.scrollWidth,room:t.clientWidth}),"--_name-fit");const Ot=m.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*y,o=Number.parseFloat(t.style.top)/100*I,r=getComputedStyle(t).borderTopLeftRadius,s=r.endsWith("%")?Number.parseFloat(r)/100:null,c=(Number.parseFloat(r)||0)*z;return[A("rect",{class:h,"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(`.${w}`);if(zt){const e=a.getBoundingClientRect(),n=y/e.width,o=getComputedStyle(a),s=Number.parseFloat(o.lineHeight)/Number.parseFloat(o.fontSize)||1.2,l=[...d.flat(),...t.totals,..."beside"===c.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?[A("rect",{class:h,"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("; ")})]:[]});L(r,l,y,I,zt)}L(r,Ot,y,I);const Et=t=>"none"!==t.dataset.place&&!t.hasAttribute("data-left-out");return t.figure.toggleAttribute("data-left-out",(c.columns?[t.categories]:[...d,t.totals]).some(t=>t.some(e=>!(t=>void 0!==t.dataset.missing||c.centre&&s[Number(t.dataset.row)-1]?.isTotal)(e)&&!Et(e)&&!((t,e)=>{const n=Number(t.dataset.row);return e.some(t=>Et(t)&&Number(t.dataset.row)<=n&&n<=Number(t.dataset.rowEnd??t.dataset.row))})(e,t)))),!0})(a,e))&&(s=t,d())};let M=!1;const v=new ResizeObserver(()=>{M||(M=!0,requestAnimationFrame(()=>{M=!1,m()}))}),k=new IntersectionObserver(t=>{for(const e of t)c=e.isIntersecting,d()},{threshold:e.threshold}),S=()=>{a.figure.classList.add(p),pe(a,!0),a.figure.offsetWidth},T=()=>a.figure.classList.remove(p),O=()=>{s=null,m()},z={relabel:()=>be(a,e),refresh:O};b(),m(),v.observe(a.figure),k.observe(a.figure),window.addEventListener("beforeprint",S),window.addEventListener("afterprint",T),(t=>{Se.add(t),He||(He=new MutationObserver(()=>{for(const t of Se)t.relabel();requestAnimationFrame(()=>requestAnimationFrame(()=>{for(const t of Se)t.refresh()}))})).observe(document.documentElement,{attributes:!0,attributeFilter:["lang"]})})(z);const _={figure:a.figure,refresh:O,next:()=>Ot(a,a.step+1),previous:()=>Ot(a,a.step-1),stepTo:t=>Ot(a,t),get step(){return a.step},get steps(){return a.plan?.count??0},destroy(){v.disconnect(),k.disconnect(),window.removeEventListener("beforeprint",S),window.removeEventListener("afterprint",T),(t=>{Se.delete(t),!Se.size&&He&&(He.disconnect(),He=null)})(z),Zt(a),a.figure.tablechart===_&&delete a.figure.tablechart}};return a.figure.tablechart=_,_})(a,e)):null},Ee=e({LEGEND_CLASS:()=>u,NAME_CLASS:()=>i,POINT_CLASS:()=>d,VIEWBOX_WIDTH:()=>y,avoidCollisions:()=>P,htmlEl:()=>H,largest:()=>E,markerEl:()=>ut,placeAt:()=>C,short:()=>N,sizeOf:()=>D});window.Tablechart={init:async(t={},e=document)=>{const n={...M,...t};n.debug&&(Mt.enabled=!0);const a=(await Oe(Array.from(e.querySelectorAll(n.selector)),n)).map(t=>ze(t,n)).filter(t=>null!==t);return Mt.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={...M,...e};n.debug&&(Mt.enabled=!0);const[a]=await Oe([t],n);return a?ze(a,n):null},defaultConfig:M,addType:(t,e)=>{Jt[t]=e},kit:Ee}}();
@@ -1 +1,3 @@
1
- export { t as create, b as defaultConfig, r as init } from "./tablechart-shared.mjs";
1
+ import { c as e, r as t, t as n } from "./tablechart-shared.mjs";
2
+ import { Q as r } from "./tablechart-shared2.mjs";
3
+ export { e as addType, n as create, r as defaultConfig, t as init };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@martinomagnifico/tablechart",
3
- "version": "1.0.7",
3
+ "version": "1.1.0",
4
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.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -20,6 +20,10 @@
20
20
  "types": "./dist/tablechart-core.d.mts",
21
21
  "import": "./dist/tablechart-core.mjs"
22
22
  },
23
+ "./additional-types": {
24
+ "types": "./dist/tablechart-additional-types.d.mts",
25
+ "import": "./dist/tablechart-additional-types.mjs"
26
+ },
23
27
  "./style.css": "./dist/tablechart.css"
24
28
  },
25
29
  "files": [