expressive-charts 0.13.0 → 1.0.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.
@@ -93,5 +93,5 @@ ${xn(gn.dark,` `)}
93
93
  `),i=2*e.inner*.85,a=n(r[0],`ec-center-value`,26),o=a>i&&a>0?Math.max(14,26*i/a):26,s=r.map((e,t)=>t===0?0:20+(t-1)*16),c=s[s.length-1],l=e.cy+(.72*o-c)/2;return r.map((t,n)=>({x:e.cx,y:l+s[n],anchor:`middle`,text:t,size:n===0?o:ni}))}function di({data:e,encoding:t}){let n=new Set;return e.map((e,r)=>{let i=String(t.key(e,r));if(n.has(i))throw Error(`donutChart: two rows have the key "${i}". Keys must be unique; pass a key accessor if categories repeat.`);n.add(i);let a=yi(t.value(e,r),t.series,i);return{key:i,category:String(t.category(e,r)??``),datum:e,index:r,value:a}})}function fi(e,t){if(t===void 0||t===`none`)return e;if(t===`value`)return[...e].sort((e,t)=>t.value-e.value);throw TypeError(`donutChart: sort must be "value" or "none", got ${String(t)}.`)}function pi(e,t){let{width:n,measure:r}=e,i=e.height??300,a=n/2,o=i/2,s=r(`100%`,`ec-value`,ri),c=t.reduce((e,t)=>Math.max(e,r(t.category,`ec-label`,ni)),s),l=Math.min(a-4-10-c,o-4-10-28),u=Math.max(0,Math.min(a,o)-4),d=Math.max(0,l,u/2);return{width:n,height:i,cx:a,cy:o,inner:d*.6,outer:d}}function mi(e,t,n){let r=(t.start+t.end)/2,i=Math.sin(r),a=Math.cos(r),o=e.outer+10,s=e.cx+o*i,c=e.cy-o*a,l=or(t.share),u=[n(t.category,`ec-label`,ni),n(l,`ec-value`,ri)],d=Math.max(...u),f=c-28*(a+1)/2,p=e=>s+i*e/2;return{category:{x:p(u[0]),y:f+10,anchor:`middle`,text:t.category},share:{x:p(u[1]),y:f+10+15,anchor:`middle`,text:l},box:{x:p(d)-d/2,y:f,width:d,height:28}}}function hi(e,t){let n=[];return e.category.text!==``&&n.push(Pt(e.category,t,`ec-label`,ni)),e.share.text!==``&&n.push(Pt(e.share,t,`ec-value`,ri)),n}function gi(e,t){return e.x<t.x+t.width+2&&t.x<e.x+e.width+2&&e.y<t.y+t.height+2&&t.y<e.y+e.height+2}function _i(e,t,n){let r={datum:e,samples:[{t:0,value:0},{t:1,value:t}],related:e=>e===n?r:void 0};return r}function vi(e){return typeof e==`function`?e:t=>t[e]}function yi(e,t,n){if(e==null)return 0;if(typeof e==`number`&&Number.isFinite(e)&&e>=0)return e;throw RangeError(`donutChart: "${t}" for "${n}" must be a finite number of 0 or more, got ${typeof e==`string`?JSON.stringify(e):String(e)}.`)}let bi=2*Math.PI;function xi(e,n,r){let i=yr(e,`donutChart`);Si(n);let o=n,s=zn(n.motion,r.motion),c=lt(n.on,r.presets),l=Dn(n.colors),u=r.clock??a,d=i.ownerDocument;Tn(d);let f=Y(`svg`,{class:`ec-chart ec-donut-chart`,role:`group`},i),p=Y(`g`,{class:`ec-center`,"aria-hidden":`true`},f),m=Y(`g`,{class:`ec-marks`},f),h=Y(`g`,{class:`ec-overlay`,"aria-hidden":`true`},f),g=Y(`g`,{class:`ec-halos`},h),_=Hn(h),v=Y(`g`,{class:`ec-runs`},h),y=It(f),x=[],w=new Map,T=fr(e=>e.value.animating||e.presence.animating),E=new WeakMap,D=er(`donutChart`),O=br(i),k=!1,A,j,M;try{A=re(o),j=G(o,A),M=wi(o,A)}catch(e){throw f.remove(),e}let N=e=>w.get(e)??T.get(e),P=Zn({overlay:v,measure:y,mark:e=>({set:t=>{N(e)?.handle.set(t),K.restyled(e)},reset:()=>{N(e)?.handle.reset(),K.restyled(e)}}),colors:e=>N(e)?.parts[0]?.colors}),F=Ct({effects:c,motion:s,icons:r.icons,clock:u,surface:P}),I=Rr(f,{motion:s,option:()=>o.tooltip,description:()=>o.markDescription}),ee=An(f),L=vr(f),R=o.announce?Ot(f):void 0,z=[],B=[],V=!1,te=C(A.frame,S,{clock:u,motion:s,onChange:()=>V=!0}),H,U,ne=Tr({clock:u,runner:F,leaving:T,draw:_e,land:ye});function re(e,t=c){let n=ii(e);return Sr(t,[n.series],`donutChart`),ai({data:e.data,encoding:n,sort:e.sort,width:e.width??O,height:e.height,center:t=>Ei(e,n.series,t),measure:y})}function ie(e,t){let n=Y(`g`,{class:`ec-mark`,"data-key":e.key,role:`img`},m),r={clock:u,motion:s,onChange:()=>V=!0},i=Y(`g`,{class:`ec-body`},n),a={key:e.key,row:e,shown:e,group:n,hit:Y(`path`,{class:`ec-hit`},n),body:i,path:Y(`path`,{class:`ec-slice`,"data-series":e.series},i),label:Y(`text`,{class:`ec-label`,"aria-hidden":`true`},n),share:Y(`text`,{class:`ec-value`,"aria-hidden":`true`},n),drawnLabel:void 0,parts:[],handle:Wn(()=>a,{halos:()=>g}),value:C(t?0:e.value,b,r),turn:C(1,b,r),offset:0,planned:0,presence:C(+!t,b,r),leave:void 0};return n.insertBefore(a.hit,i),E.set(n,a),a}function ae(e,t,n){let r=e.parts[0]?.colors.color;e.shown=t;let{outline:i}=t.geometry,a=t.geometry.length>=.5,o=a?void 0:`hidden`;X(e.path,{d:i.d,visibility:o}),X(e.hit,{d:i.d,visibility:o});let s=vn(l.slot(e.key));At(e.path,bn(s)),e.parts=[{element:e.path,d:i.d,colors:s,visible:a}];let c=e.presence.value,u=c<1?c:void 0;e.drawnLabel=n;for(let[t,r]of[[e.label,n?.category],[e.share,n?.share]])r&&Ft(t,r),X(t,{visibility:r?void 0:`hidden`,opacity:u});e.handle.repaint(),s.color!==r&&P.recolor(e.key),e.key===K.ringKey&&oe(e.key)}function oe(e){let t=e===void 0?void 0:w.get(e);_.draw(t&&{outline:t.shown.geometry.outline,thickness:t.shown.geometry.thickness,transform:t.handle.style.transform})}function se(e,t,n){let r=Or(e.shown.geometry,t.geometry)||e.shown.datum!==t.datum;ae(e,t,n),r&&F.change(t.geometry,t.data),e.key===K.key&&ce(e)}function ce(e){let{row:t}=e;I.show(e.shown.geometry,t,()=>({title:t.category,lines:[`${Ci(t,o)} · ${or(t.share)}`]}),e.handle.style.transform)}function le(e){for(;p.childElementCount>e.length;)p.lastElementChild.remove();e.forEach((e,t)=>{let n=p.children[t]??Y(`text`,{},p);X(n,{class:t===0?`ec-center-value`:`ec-center-label`}),Ft(n,e),At(n,{"font-size":t===0&&e.size!==26?`${e.size}px`:void 0})})}let W=()=>ee.categories(A.slices.map(e=>({key:e.key,label:e.category})),l,o.legend);function G(e,t){let{series:n}=ii(e);return gr({option:e.table,caption:e.label,category:typeof e.category==`string`?e.category:void 0,series:[n],label:t=>Qn(e.seriesLabels,t),rows:t.slices.map(e=>({key:e.key,category:e.category,datum:e.datum,index:e.index,values:[{series:n,value:e.value}],total:e.value})),format:tr(e),shares:!0})}function ue(){xr(f,{label:o.label,description:Di(o.description,A.centerText)})}function de(e,n){let r=o.announce;if(!R||!r)return;let i=ii(o).series,a=ii(e).series,s=o.sort??`none`,c=e=>e.row.category,l=n.changed.map(({record:e})=>e),u=Et({...o.label===e.label?{}:{label:o.label},...i===a?{}:{series:[Qn(o.seriesLabels,i)]},...s===(e.sort??`none`)?{}:{sort:s},changed:l.map(c),added:n.entering.map(c),removed:n.exiting.map(c),count:x.length});if(typeof r!=`function`){R.say(u);return}let d=e=>e.key;try{let e=r({text:u,changed:l.map(d),added:n.entering.map(d),removed:n.exiting.map(d)});e!=null&&R.say(String(e))}catch(e){t(e)}}let fe=e=>w.get(e.key)===e||T.get(e.key)===e,pe=e=>Math.max(0,e.value.value);function me(e,t,n=pe){let r=new Map,i=0;for(let a of e)r.set(a,t>0?i/t:0),i+=n(a);return r}function he(){z=z.filter(fe),B=B.filter(fe);let e=z.reduce((e,t)=>e+pe(t),0),t=me(z,e),n=me(B,e),r=new Map;for(let i of z){let a=t.get(i),o=i.turn.value,s=n.get(i),c=a;if(s!==void 0&&o<1){let e=s+i.offset-a;c=a+(1-o)*(e-Math.round(e-i.planned))}r.set(i,{start:c,span:e>0?pe(i)/e:0})}return r}function ge(e){let t=[...he()].map(([e,{start:t,span:n}])=>{let{row:r}=e;return{record:e,state:{key:r.key,datum:r.datum,index:r.index,category:r.category,series:r.series,value:pe(e),share:n,start:t*bi,end:(t+n)*bi}}}),n=li(e,t.map(({state:e})=>e),y),r=si(e,t.map(({state:e})=>e),n,y);return t.map(({record:e},t)=>({record:e,slice:r[t],label:n[t]}))}function _e(){if(!V)return;V=!1;let e=te.value;X(f,jt(e));let t=ge(e);for(let{record:e,slice:n,label:r}of t)se(e,n,r);let n=t.reduce((e,{slice:t})=>e+t.value,0);le(ui(e,H===void 0?A.centerText:ve(ar(n,H)),y))}function ve(e){return U?.total!==e&&(U={total:e,text:Ei(o,ii(o).series,e)}),U.text}function ye(){z=z.filter(fe),B=z;for(let e of z)e.turn.set(1),e.offset=0,e.planned=0;H=void 0,U=void 0,X(f,jt(A.frame)),A.slices.forEach((e,t)=>se(w.get(e.key),e,A.labels[t])),le(A.center),V=!1}function be(e){let t=new Set(e.slices.map(e=>e.key)),n={entering:[],exiting:[],changed:[]};for(let e of x)t.has(e.key)||(w.delete(e.key),T.start(e),n.exiting.push(e));let r=x;return x=e.slices.map(e=>{let t=w.get(e.key);return t?(t.row.value!==e.value||t.row.series!==e.series)&&n.changed.push({record:t,from:t.shown.geometry}):(t=T.recall(e.key)??ie(e,!0),w.set(e.key,t),n.entering.push(t)),t.row=e,t.path.setAttribute(`data-series`,e.series),xe(t),t}),mr(m,r.map(e=>e.group),x.map(e=>e.group),K.active),n}function xe(e){e.group.setAttribute(`aria-label`,M.get(e.key)),I.describe(e.group,e.row)}function Se(e,t){V=!0;let n=he(),r=new Set(x.filter(e=>e.presence.value===0)),i=x.filter(e=>!r.has(e)),a=[...T.values()],o=B.length>0&&B.every(e=>e.turn.value===0),c=z;if(z=Oi(c,x),!o){B=c;let e=me(c,c.reduce((e,t)=>e+pe(t),0));for(let t of c)t.offset=n.get(t).start-e.get(t)}B=B.filter(e=>!r.has(e));let l=e=>w.get(e.key)===e?e.row.value:0,u=z.reduce((e,t)=>e+l(t),0),d=me(z,u,l),f=me(B,u,l),p=!1;for(let e of B){let t=f.get(e)+e.offset-d.get(e);e.planned=t-Math.round(t),Math.abs(e.planned)>1e-9&&(p=!0)}let m=i.some(e=>Q(e.value,e.row.value,$)||Q(e.presence,1,$))||a.some(e=>Q(e.value,0,$)||Q(e.presence,0,$)),h=p||r.size>0||Q(te,e.frame,Dr),g,_,v;if(!t&&s.staged){let e=m?500:0;g={duration:500},_={duration:500,delay:e},v={duration:250,delay:e+250}}else t||(g=_=v={duration:(m&&h?2:1)*500});let y=[],b=(e,t,n,r)=>{Q(e,t,n)&&(r?y.push(e.to(t,r)):e.set(t))};b(te,e.frame,Dr,_);for(let e of i)b(e.value,e.row.value,$,g),b(e.presence,1,$,g);for(let e of r)b(e.value,e.row.value,$,v),b(e.presence,1,$,v);for(let e of a)b(e.value,0,$,g),b(e.presence,0,$,g);if(t){B=z;for(let e of z)e.turn.set(1),e.offset=0,e.planned=0;return y}let S=new Set(B);for(let e of z)e.turn.set(+!S.has(e));if(p)for(let e of B)b(e.turn,1,$,_);return y}function Ce(e,t){return A=e,ne.run(Se(e,t))}let we=e=>({mark:e.row.geometry,data:e.row.data}),Te=e=>({mark:e.shown.geometry,data:e.shown.data});function Ee(e){let t=e,n=typeof t?.closest==`function`?t.closest(`.ec-mark`):null,r=n?E.get(n):void 0;return r&&w.get(r.key)===r?r:void 0}let K=ur({svg:f,runner:F,events:D,dim:()=>o.dim!==!1,find(e){let t=Ee(e);return t&&{key:t.key}},live:e=>w.has(e),order:()=>x.map(e=>e.key),element:e=>N(e)?.group,hot:P.hot,onScreen(e){let t=N(e);return t&&Te(t)},ring:oe,tooltip:{show(e){let t=w.get(e);t&&ce(t)},hide:()=>I.hide(),element:()=>I.element()}}),De=Pr(f,s);function Oe(){if(k)return;let e=re(o),t=new Map(e.slices.map(e=>[e.key,e]));for(let e of x)e.row=t.get(e.key)??e.row;Ce(e,!0)}let ke=()=>{y.clear(),Oe()},Ae=Nr(f,u,ke),je=jr(i,u,O,e=>{O=e,o.width===void 0&&Oe()}),Me=Mr(d,ke);return ue(),W(),L.render(j),X(f,jt(A.frame)),x=A.slices.map(e=>{let t=ie(e,!1);return w.set(e.key,t),xe(t),t}),z=B=x,A.slices.forEach((e,t)=>ae(x[t],e,A.labels[t])),le(A.center),K.sync(),F.enter(x.map(we)),Fn(K.link,{element:f,async update(e){if(k)return;if(e.motion!==void 0&&e.motion!==o.motion)throw TypeError("donutChart: `motion` can't be changed by update() yet.");let t={...o,...e};Si(t);let n=`on`in e?Cr(c,o.on,t.on,r.presets):c,i=re(t,n),a=G(t,i),u=wi(t,i);`colors`in e&&(l=Dn(t.colors));let d=o,p=A.total;o=t,A=i,M=u,ue(),W(),L.render(a);let m=R!==void 0;o.announce&&!R?R=Ot(f):!o.announce&&R&&(R.destroy(),R=void 0),K.syncDim(),ne.supersede();let h=n!==c;c=n;let g=Er({runner:F,events:D,hover:K,leaving:T,input:we,onScreen:Te,data:`data`in e,...h?{swap:e=>{let t=new Set(e.entering);F.swap(n,x.filter(e=>!t.has(e)).map(we))}}:{}},()=>be(i),e=>{m&&de(d,e)});H=i.total===p?void 0:Math.max(ir(p),ir(i.total));let _=Ce(i,s.mode===`off`);await ne.wait(_,g)},on:D.on,marks:()=>x.map(e=>e.shown.geometry),focus(e){k||K.focus(e)},leave(){k||K.leave()},labels:()=>x.flatMap(e=>[...dr(e.key,`category`,e.drawnLabel?.category,e.label),...dr(e.key,`value`,e.drawnLabel?.share,e.share)]),paintOf:e=>w.has(e)?{color:e,drawn:!0}:void 0,moveTabStop:e=>!k&&K.moveTabStop(e),destroy(){if(!k){k=!0,ne.destroy(),K.destroy(),F.destroy(),I.destroy(),ee.destroy(),L.destroy(),R?.destroy(),De(),Ae(),je(),Me();for(let e of[...x,...T.values()]){for(let t of[e.value,e.turn,e.presence])t.stop();e.leave?.resolve()}te.stop(),D.clear(),w.clear(),T.clear(),x=z=B=[],f.remove()}}})}function Si(e){wr(e,`donutChart`);let{center:t,sort:n}=e;if(t!==void 0&&t!==!1&&typeof t!=`function`)throw TypeError(`donutChart: center must be false or a function that returns the text for the total.`);if(n!==void 0&&n!==`none`&&n!==`value`)throw TypeError(`donutChart: sort must be "value" or "none", got ${String(n)}.`)}function Ci(e,t){let n=tr(t)(e.value),r=Qn(t.seriesLabels,e.series);return e.series===`value`&&r===`value`?n:`${n} ${r}`}function wi(e,t){return new Map(t.slices.map(t=>[t.key,Ti(t,e)]))}function Ti(e,n){let r=`${e.category}: ${Ci(e,n)}, ${or(e.share)}`;if(!n.markLabel)return r;try{let t={series:e.series,label:Qn(n.seriesLabels,e.series),value:e.value},i=n.markLabel(e.datum,{key:e.key,category:e.category,values:[t],total:e.value,share:e.share,format:tr(n),text:r});if(i!=null&&String(i).trim()!==``)return String(i)}catch(e){t(e)}return r}function Ei(e,n,r){let{center:i}=e,a=tr(e);if(i===!1)return``;if(i===void 0){let t=Qn(e.seriesLabels,n);return n===`value`&&t===`value`?a(r):`${a(r)}\n${t}`}try{let e=i(r,a);return e==null?``:String(e)}catch(e){return t(e),``}}function Di(e,t){let n=t.split(`
94
94
  `).join(` `).trim(),r=e?.trim();return n===``?e:r?/[.!?:;]$/.test(r)?`${r} ${n}`:`${r}. ${n}`:n}function Oi(e,t){let n=[...t];return e.forEach((t,r)=>{if(n.includes(t))return;let i=0;for(let t=r-1;t>=0;t--){let r=n.indexOf(e[t]);if(r>=0){i=r+1;break}}n.splice(i,0,t)}),n}let ki=[`linear`,`monotone`];function Ai(e){return+(e===`monotone`)}function ji(e,t,n,r,i){let a=new Int32Array(e.length).fill(-1),o=[],s=[],c=[],l=[],u=0,d=!1;for(let n=0;n<e.length;n++){let r=t[n];if(r===void 0){d=!1;continue}let f=o.length-1;d&&e[n]===o[f]&&r===s[f]?(a[n]=f,l[f]=Math.max(l[f],i?.[n]??1)):(d&&e[n]!==o[f]||u++,o.push(e[n]),s.push(r),c.push(u),l.push(i?.[n]??1),a[n]=f+1,d=!0)}let f=n>0?new Float64Array(o.length):void 0;if(f)for(let e=0;e<o.length;){let t=e+1;for(;t<o.length&&c[t]===c[e];)t++;Mi(o,s,e,t,f),i&&Ni(o,s,l,e,t,f),e=t}let p=(e,t)=>{let r=a[e];if(r<0||a[t]!==r+1||c[r+1]!==c[r])return;let i=o[r+1]-o[r],l=s[r],u=s[r+1],d=(u-l)/i,[p,m]=d<0?[3*d,0]:[0,3*d],h=e=>Math.min(m,Math.max(p,n===1?e:d+n*(e-d))),g=f?h(f[r]):d,_=f?h(f[r+1]):d;return[l,l+i*g/3,u-i*_/3,u,r]};return{between(e,t,n=1/0){let i=p(e,t);if(!i||!f)return[];let[a,s,c,l,u]=i,d=o[u],m=o[u+1]-d,h=r.x(d),g=r.x(o[u+1]),_=Math.min(Te({x:h,y:r.y(a)},{x:h+(g-h)/3,y:r.y(s)},{x:g-(g-h)/3,y:r.y(c)},{x:g,y:r.y(l)}),Math.max(1,Math.ceil(Math.abs(g-h)/xe))),v=[];for(let e=1;e<_;e++){let t=d+e/_*m;if(!(t<n))break;v.push({x:t,value:Fi(a,s,c,l,e/_)})}return v},valueAt(e,n,r){let i=p(e,n);if(!i)return t[e]??0;let[a,s,c,l,u]=i;return Fi(a,s,c,l,(r-o[u])/(o[u+1]-o[u]))}}}function Mi(e,t,n,r,i){let a=r-n;if(a<2){a===1&&(i[n]=0);return}let o=n=>(t[n+1]-t[n])/(e[n+1]-e[n]);if(a===2)i[n]=i[n+1]=o(n);else{for(let t=n+1;t<r-1;t++){let n=e[t]-e[t-1],r=e[t+1]-e[t],a=o(t-1),s=o(t),c=(a*r+s*n)/(n+r);i[t]=(Pi(a)+Pi(s))*Math.min(Math.abs(a),Math.abs(s),.5*Math.abs(c))||0}i[n]=(3*o(n)-i[n+1])/2,i[r-1]=(3*o(r-2)-i[r-2])/2}}function Ni(e,t,n,r,i,a){let o=[];for(let e=r;e<i;e++)n[e]>=1&&o.push(e);if(o.length===i-r||o.length<2)return;let s=o.map(t=>e[t]),c=o.map(e=>t[e]),l=new Float64Array(o.length);Mi(s,c,0,o.length,l);let u=new Float64Array(i-r),d=0,f=0;for(let t=r;t<i;t++){for(;d<s.length-2&&s[d+1]<=e[t];)d++;let p=o[f]===t?f++:-1,m=1;for(let e=Math.max(r,t-2);e<Math.min(i,t+3);e++)m=Math.min(m,n[e]);if(m>=1){u[t-r]=a[t];continue}let h;if(p>=0)h=l[p];else{let n=s[d+1]-s[d],r=Math.min(1,Math.max(0,(e[t]-s[d])/n));h=(6*r*r-6*r)*(c[d]-c[d+1])/n+(3*r*r-4*r+1)*l[d]+(3*r*r-2*r)*l[d+1]}u[t-r]=m*a[t]+(1-m)*h}a.set(u,r)}let Pi=e=>e<0?-1:1;function Fi(e,t,n,r,i){let a=1-i;return a*a*a*e+3*a*a*i*t+3*a*i*i*n+i*i*i*r}let Ii=1e3,Li=60*Ii,Ri=60*Li,zi=24*Ri,Bi={second:Ii,minute:Li,hour:Ri,day:9e7,week:6084e5,month:31*zi,year:366*zi},Vi=[...[1,5,15,30].map(e=>({unit:`second`,count:e})),...[1,5,15,30].map(e=>({unit:`minute`,count:e})),...[1,3,6,12].map(e=>({unit:`hour`,count:e})),{unit:`day`,count:1},{unit:`day`,count:2},{unit:`week`,count:1},{unit:`month`,count:1},{unit:`month`,count:3}],Hi=[`year`,`month`,`day`,`hour`,`minute`,`second`,`millisecond`],Ui={second:`second`,minute:`minute`,hour:`hour`,day:`day`,week:`day`,month:`month`,year:`year`},Wi={year:{year:`numeric`},month:{month:`short`},day:{month:`short`,day:`numeric`},hour:{hour:`numeric`,minute:`2-digit`},minute:{hour:`numeric`,minute:`2-digit`},second:{hour:`numeric`,minute:`2-digit`,second:`2-digit`},millisecond:{hour:`numeric`,minute:`2-digit`,second:`2-digit`,fractionalSecondDigits:3}};function Gi(e){if(e===`UTC`||e===`local`)return!0;if(typeof e!=`string`)return!1;try{return la(e),!0}catch{return!1}}function Ki(e){for(let t of Vi)if(Bi[t.unit]*t.count>=e)return t;return{unit:`year`,count:Math.max(1,on(e/Bi.year))}}function qi(e,t,n){let r=$i(n);if(!(t>e))return[{value:e,text:r(e,`year`)}];let i=Ki((t-e)/4),a=Hi[Math.min(Hi.indexOf(Ui[i.unit]),Hi.indexOf(Ji(e,t,n)))],o=Yi(e,t,i,n).map(e=>({value:e,text:r(e,`millisecond`)}));return[{value:e,text:r(e,a)},...o,{value:t,text:r(t,a)}]}function Ji(e,t,n){let[r,i]=[ta(e,n),ta(t,n)];return r.year===i.year?r.month===i.month?r.date===i.date?r.hours===i.hours?r.minutes===i.minutes?`second`:`minute`:`hour`:`day`:`month`:`year`}function Yi(e,t,n,r){let{unit:i,count:a}=n,o=[],s=ta(e,r);if(i===`second`||i===`minute`||i===`hour`){let n=i===`hour`?15*Li:Bi[i],c=e-s.ms-(i===`second`?0:s.seconds*Ii)-(i===`hour`?s.minutes%15*Li:0);for(;c<t;c+=n){let t=ta(c,r),n=i!==`hour`||t.minutes===0,s=i===`second`?t.seconds:i===`minute`?t.minutes:t.hours;c>e&&n&&s%a===0&&o.push(c)}return o}let c=i===`day`?e=>na(r,s.year,s.month,s.date+e):i===`week`?e=>na(r,s.year,s.month,s.date-(s.weekday+6)%7+7*e):i===`month`?e=>na(r,s.year,Math.floor(s.month/a)*a+a*e,1):e=>na(r,Math.floor(s.year/a)*a+a*e,0,1),l=-1/0;for(let n=0;;n++){let s=c(n);if(s>=t||s<=l)break;l=s,s>e&&(i!==`day`||(ta(s,r).date-1)%a==0)&&o.push(s)}return o}function Xi(e,t,n){let{year:r,month:i,date:a,hours:o,minutes:s,seconds:c,ms:l}=ta(e,n),u=new Date(0);u.setUTCFullYear(r,i+t+1,0);let d=Math.min(a,u.getUTCDate());return ra(n,r,i+t,d,o,s,c,l)}function Zi(e,t){let{ms:n,seconds:r,minutes:i,hours:a,date:o,month:s}=ta(e,t);return n===0?r===0?i===0?a===0?o===1?s===0?`year`:`month`:`day`:`hour`:`minute`:`second`:`millisecond`}function Qi(e,t){let n=oa(t),r=e.reduce((e,t)=>Math.max(e,Hi.indexOf(Zi(n(t),`UTC`))),0),i=ea(t),a=r>=Hi.indexOf(`second`)?`medium`:r>=Hi.indexOf(`hour`)?`short`:void 0,o=r===Hi.indexOf(`millisecond`)?{year:`numeric`,...Wi.day,...Wi.millisecond,timeZone:i}:{dateStyle:`medium`,...a?{timeStyle:a}:{},timeZone:i},s=new Intl.DateTimeFormat(void 0,o);if(t===`UTC`||!a)return e=>s.format(e);let c=new Intl.DateTimeFormat(void 0,{timeZone:i,timeZoneName:`short`});return e=>{let t=s.format(e);if(sa(e,n)===void 0)return t;let r=c.formatToParts(e).find(e=>e.type===`timeZoneName`)?.value;return r?`${t} ${r}`:t}}function $i(e){let t=new Map;return(n,r)=>{let i=Hi.indexOf(Zi(n,e)),a={};for(let e=Math.min(i,Hi.indexOf(r));e<=i;e++)Object.assign(a,Wi[Hi[e]]);let o=JSON.stringify(a),s=t.get(o);return s||t.set(o,s=new Intl.DateTimeFormat(void 0,{...a,timeZone:ea(e)})),s.format(n)}}let ea=e=>e===`local`?void 0:e;function ta(e,t){let n=new Date(t===`UTC`||t===`local`?e:aa(e,t));return t===`local`?{year:n.getFullYear(),month:n.getMonth(),date:n.getDate(),weekday:n.getDay(),hours:n.getHours(),minutes:n.getMinutes(),seconds:n.getSeconds(),ms:n.getMilliseconds()}:{year:n.getUTCFullYear(),month:n.getUTCMonth(),date:n.getUTCDate(),weekday:n.getUTCDay(),hours:n.getUTCHours(),minutes:n.getUTCMinutes(),seconds:n.getUTCSeconds(),ms:n.getUTCMilliseconds()}}function na(e,t,n,r){return ra(e,t,n,r)}function ra(e,t,n,r,i=0,a=0,o=0,s=0){if(e===`local`){let e=new Date(0);return e.setFullYear(t,n,r),e.setHours(i,a,o,s),e.getTime()}let c=ia(t,n,r,i,a,o,s);if(e===`UTC`)return c;let l=c-(aa(c-zi,e)-(c-zi)),u=c-(aa(c+zi,e)-(c+zi));if(l===u)return l;let d=[l,u].filter(t=>aa(t,e)===c);return d.length>0?Math.min(...d):l}function ia(e,t,n,r=0,i=0,a=0,o=0){let s=new Date(0);return s.setUTCFullYear(e,t,n),s.setUTCHours(r,i,a,o),s.getTime()}function aa(e,t){if(t===`UTC`)return e;if(t===`local`){let t=new Date(e);return ia(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds())}let n=(e%Ii+Ii)%Ii,r={};for(let i of la(t).formatToParts(e-n))r[i.type]=i.value;let i=Number(r.year);return ia(r.era===`BC`?1-i:i,Number(r.month)-1,Number(r.day),Number(r.hour)%24,Number(r.minute),Number(r.second),n)}function oa(e){if(e===`UTC`||e===`local`)return t=>aa(t,e);let t=new Map;return n=>{let r=t.get(n);return r===void 0&&t.set(n,r=aa(n,e)),r}}function sa(e,t){let n=t(e);for(let r of[e-zi,e+zi]){let i=n-(t(r)-r);if(i!==e&&t(i)===n)return i}}let ca=new Map;function la(e){let t=ca.get(e);return t||(t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,hourCycle:`h23`,era:`short`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),ca.set(e,t)),t}let ua=2.25,da=4.5,fa=12.5,pa=.36;function ma(e){let{x:t,series:n,key:r}=e;if(typeof t!=`string`&&typeof t!=`function`)throw TypeError(`lineChart needs x: a field of numbers or Dates, or a function that returns each row's x.`);if(!Array.isArray(n)||n.length===0)throw TypeError(`lineChart needs series: the numeric fields to draw as lines.`);let i=new Set;for(let e of n){if(typeof e!=`string`||e===``)throw TypeError(`lineChart: each series must be a field name, got ${Ba(e)}.`);if(i.has(e))throw TypeError(`lineChart: "${e}" appears twice in series.`);i.add(e)}if(r!==void 0&&typeof r!=`string`&&typeof r!=`function`)throw TypeError(`lineChart: key must be a field name or a function.`);let a=e.labels;if(a!==void 0&&a!==!1&&typeof a!=`function`)throw TypeError(`lineChart: labels must be false or a function that returns a line's end label.`);let o=e.timeZone??`UTC`;if(!Gi(o))throw TypeError(`lineChart: timeZone must be "UTC", "local" or the name of a zone Intl knows, such as "Europe/London", got ${Ba(o)}.`);let s=e.xFormat;if(s!==void 0&&typeof s!=`function`)throw TypeError(`lineChart: xFormat must be a function that turns an x into text.`);let c=e.curve??`linear`;if(!ki.includes(c))throw TypeError(`lineChart: curve must be "linear" or "monotone", got ${Ba(c)}.`);return{x:za(t),key:r===void 0?void 0:za(r),series:n.map(e=>({series:e,value:za(e)})),timeZone:o,xFormat:e.xFormat,curve:c}}function ha(e){let t=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0;if(typeof e!=`object`||!e||Array.isArray(e)){if(e!==void 0&&!t(e))throw RangeError(`lineChart: room must be a number of px, 0 or more, got ${typeof e==`object`?JSON.stringify(e):String(e)}.`)}else for(let n of[`right`,`top`]){let r=e[n];if(r!==void 0&&!t(r))throw RangeError(`lineChart: room.${n} must be a number of px, 0 or more, got ${String(r)}.`)}}function ga(e){let{width:t,measure:n}=e,r=e.height??300,{rows:i,time:a}=ja(e),o=e.encoding.series.map(e=>e.series),s=an(i.flatMap(e=>e.values.flatMap(e=>e.value===void 0?[]:[e.value]))),c=s.ticks.map(e.format),l=i[0]?.x??0,u=i[i.length-1]?.x??0,d=i.length===0?[]:a?qi(l,u,e.encoding.timeZone):Oa(l,u).map(e=>({value:e,text:ka(e)})),f=d.map(e=>e.value),p=d.map(e=>e.text),m=p.map(e=>n(e,`ec-tick`,11)),h=typeof e.room==`number`?{right:e.room}:e.room,g=e.label?Ra(La(i,e.label),`ec-value`,fa,n):0,_=Math.max(Ra(c,`ec-tick`,11,n)+10,(m[0]??0)/2+2),v=Math.max(10,(m[m.length-1]??0)/2+2,(g>0?10+g+4:0)+(h?.right??0)),y=12+(h?.top??0),b={scale:{lo:s.lo,hi:s.hi},box:{xLo:l,xHi:u,left:_,right:Math.max(_,t-v),top:y,bottom:Math.max(y,r-32),width:t,height:r}},x={};for(let e of o)x[e]=0;for(let e of i)for(let t of e.values)t.value!==void 0&&(x[t.series]=Math.max(x[t.series],ir(t.value)));let S=f.map((e,t)=>Da(b,e,p[t]));return{width:t,height:r,frame:b,rows:i,time:a,series:o,yTicks:s.ticks.map((e,t)=>Ea(b,e,c[t])),xTicks:Aa(S,m),decimals:x,curve:e.encoding.curve}}function _a(e){let{scale:t,box:n}=e,r=n.xHi-n.xLo,i=t.hi-t.lo;return{x:e=>r>0?n.left+(e-n.xLo)/r*(n.right-n.left):(n.left+n.right)/2,y:e=>i>0?n.bottom-(e-t.lo)/i*(n.bottom-n.top):n.bottom}}function va(e,t,n,r,i=!1,a,o=0){let s=t[0];if(!s)return[];let c=_a(e),l=0;for(;l+1<t.length&&t[l+1].x<=r;)l++;let u=t[l],d=t[l+1],f=d&&d.x>u.x&&r>u.x?(r-u.x)/(d.x-u.x):void 0,p=t.slice(0,l+1),m=o>0?t.map(e=>e.x):[],h=o>0&&t.some(e=>e.presence!==void 0&&e.presence<1)?t.map(e=>e.presence??1):void 0,g=new Map,_=e=>t=>t===e?void 0:g.get(t),v=n.map(e=>{let n=t=>!t.missing?.has(e),i=o>0?ji(m,t.map(t=>n(t)?t.values[e]??0:void 0),o,c,h):void 0,a=[],g=!1,_=-1;if(p.forEach((r,o)=>{if(!n(r))g=a.length>0;else{if(i&&_>=0)for(let e of i.between(_,o))a.push({at:e.x,value:e.value,datum:t[_].datum,gapBefore:!1});a.push({at:r.x,value:r.values[e]??0,datum:r.datum,gapBefore:g}),g=!1,_=o}}),f!==void 0&&n(u)&&n(d)){if(i)for(let e of i.between(l,l+1,r))a.push({at:e.x,value:e.value,datum:u.datum,gapBefore:!1});let t=u.values[e]??0,n=i?i.valueAt(l,l+1,r):t+f*((d.values[e]??0)-t);a.push({at:r,value:n,datum:u.datum,gapBefore:!1})}return{name:e,vertices:a,points:a.length>0?a.map(e=>({x:c.x(e.at),y:c.y(e.value)})):[{x:c.x(s.x),y:c.y(s.values[e]??0)}]}}),y=v.filter(({vertices:e})=>e.length>0),b=a?wa(e,y.map(({name:e,vertices:t,points:n})=>({...n[n.length-1],text:a.text(e,t[t.length-1].value)}))):[],x=a?b.map(e=>e.text===``?void 0:Pt(e,a.measure,`ec-value`,fa)):[];return v.map(({name:e,vertices:t,points:n})=>{let r=n[n.length-1],o=y.findIndex(t=>t.name===e),c=a?b[o]??{x:r.x+10,y:r.y+fa*pa,anchor:`start`,text:``}:void 0,l=x[o],d=a?l?[l]:[]:void 0,f=a?x.filter((e,t)=>e!==void 0&&t!==o):void 0,p=t.flatMap((e,t)=>e.gapBefore?[t]:[]),m=ge({key:e,series:e,points:n,width:ua,...p.length>0?{breaks:p}:{},...d?{labelBounds:d}:{},...f?{nearbyLabels:f}:{}}),h=0,v=t.map((e,r)=>(r>0&&(h+=Math.hypot(n[r].x-n[r-1].x,n[r].y-n[r-1].y)),{t:m.length>0?r===t.length-1?1:Math.min(1,h/m.length):0,value:e.value,at:Fa(e.at,i),...e.gapBefore?{gapBefore:!0}:{}})),S=t[t.length-1],C={datum:S?S.datum:u.datum,samples:v,related:_(e)};return g.set(e,C),{series:e,geometry:m,data:C,end:{...r,value:S?S.value:s.values[e]??0},label:c}})}function ya(e,t){let n=new Set;if(!e.some(e=>e.missing!==void 0&&e.missing.size>0))return n;let r=(e,t)=>e!==void 0&&!e.missing?.has(t);return e.forEach((i,a)=>{for(let o of t){let t=e[a-1],s=e[a+1];!r(i,o)||r(t,o)||r(s,o)||t===void 0&&s===void 0||n.add(ba(o,i.key))}}),n}function ba(e,t){return`${e}@${t}`}function xa(e,t,n,r=!1){let i=_a(e),a=i.x(t.x),o=new Map;return n.filter(e=>!t.missing?.has(e)).map(e=>{let n=t.values[e]??0,s=ba(e,t.key),c={datum:t.datum,samples:[{t:0,value:n,at:Fa(t.x,r)}],related:t=>t===e?void 0:o.get(t)};return o.set(e,c),{key:s,series:e,geometry:be({key:s,series:e,x:a,y:i.y(n),r:da}),data:c}})}function Sa(e,t){let{width:n,height:r}=e.box;return t.map((e,i)=>{let a=i===0?0:(t[i-1]+e)/2,o=i===t.length-1?n:(e+t[i+1])/2;return{x:a,y:0,width:Math.max(0,o-a),height:r}})}function Ca(e,t){return{x1:t,y1:e.box.top,x2:t,y2:e.box.bottom}}function wa(e,t){let n=fa/2,r=Ta(t.map(e=>e.y),16,n,e.box.height-n);return t.map((e,t)=>({x:e.x+10,y:r[t]+fa*pa,anchor:`start`,text:e.text}))}function Ta(e,t,n,r){let i=e.map((e,t)=>({value:e,index:t})).sort((e,t)=>e.value-t.value||e.index-t.index),a=[],o=e=>{let i=e.reduce((e,t)=>e+t.value,0)/e.length,a=(e.length-1)*t;return Math.max(n,Math.min(r-a,i-a/2))};for(let e of i)for(a.push({members:[e],start:o([e])});a.length>1;){let e=a[a.length-1],n=a[a.length-2];if(e.start-(n.start+(n.members.length-1)*t)>=t)break;a.pop(),n.members.push(...e.members),n.start=o(n.members)}let s=Array(e.length);for(let e of a)e.members.forEach((n,r)=>s[n.index]=e.start+r*t);return s}function Ea(e,t,n){let{box:r}=e,i=_a(e).y(t);return{value:t,line:{x1:r.left,y1:i,x2:r.right+8,y2:i},label:{x:r.left-8,y:i+11*pa,anchor:`end`,text:n}}}function Da(e,t,n){return{value:t,label:{x:_a(e).x(t),y:e.box.bottom+18,anchor:`middle`,text:n}}}function Oa(e,t){if(!(t>e))return[e];let n=on((t-e)/4),r=[e];for(let i=Math.floor(e/n)+1;hn(i*n)<t;i++){let t=hn(i*n);t>e&&r.push(t)}return r.push(t),r}function ka(e){return String(e)}function Aa(e,t){if(e.length<=1)return[...e];let n=e.map((e,n)=>({tick:e,from:e.label.x-t[n]/2,to:e.label.x+t[n]/2})),r=n[n.length-1],i=[n[0]];for(let e of n.slice(1,-1))e.from-i[i.length-1].to>=8&&r.from-e.to>=8&&i.push(e);return r.from-i[i.length-1].to>=8&&i.push(r),i.map(e=>e.tick)}function ja({data:e,encoding:t}){let n=new Set,r=!1,i=e.map((e,i)=>{let a=t.x(e,i);i===0&&(r=a instanceof Date);let o=Na(a,i,r),s=String(t.key?t.key(e,i):r?new Date(o).toISOString():o);if(n.has(s))throw Error(`lineChart: two rows have the key "${s}". Keys must be unique.`);return n.add(s),{key:s,datum:e,index:i,x:o,values:t.series.map(({series:t,value:n})=>({series:t,value:Ia(n(e,i),t,s)}))}});i.sort((e,t)=>e.x-t.x);for(let e=1;e<i.length;e++){let[t,n]=[i[e-1],i[e]];if(t.x===n.x){let e=r?new Date(t.x).toISOString():ka(t.x);throw Error(`lineChart: the rows "${t.key}" and "${n.key}" have the same x, ${e}. Each x is one point on every line, so x values must be unique.`)}}let a=Pa(t,r,i.map(e=>e.x)),o=Ma(i,t.series.length);return{rows:i.map((e,t)=>({...e,label:a(e.x),missing:new Set(e.values.flatMap(e=>e.value===void 0?[e.series]:[])),levels:o[t]})),time:r}}function Ma(e,t){let n=e.map(()=>({}));for(let r=0;r<t;r++){let t=-1,i=-1;e.forEach((a,o)=>{let{series:s,value:c}=a.values[r];if(c!==void 0){n[o][s]=c,t=o;return}if(i<=o)for(i=o+1;i<e.length&&e[i].values[r].value===void 0;)i++;let l=e[t]?.values[r].value,u=e[i]?.values[r].value;n[o][s]=l!==void 0&&u!==void 0?l+(a.x-e[t].x)/(e[i].x-e[t].x)*(u-l):l??u??0})}return n}function Na(e,t,n){if(e instanceof Date){if(!n)throw TypeError(`lineChart: x must be all numbers or all Dates, but row 0's is a number and row ${t}'s a Date.`);let r=e.getTime();if(Number.isNaN(r))throw TypeError(`lineChart: x must be a valid Date, got an invalid Date in row ${t}.`);return r}if(n)throw TypeError(typeof e==`number`?`lineChart: x must be all numbers or all Dates, but row 0's is a Date and row ${t}'s a number.`:`lineChart: x must be a valid Date, got ${Ba(e)} in row ${t}.`);if(typeof e!=`number`||!Number.isFinite(e))throw RangeError(`lineChart: x must be a finite number, got ${Ba(e)} in row ${t}.`);return e}function Pa(e,t,n){let{xFormat:r}=e;return r?e=>r(t?new Date(e):e):t?Qi(n,e.timeZone):ka}function Fa(e,t){return t?new Date(e):e}function Ia(e,t,n){if(typeof e==`number`&&Number.isFinite(e))return e;if(e!=null)throw RangeError(`lineChart: "${t}" for "${n}" must be a finite number, or null or undefined where it has no value, got ${Ba(e)}.`)}function La(e,t){let n=new Map;for(let r of e)for(let{series:e,value:i}of r.values){if(i===void 0)continue;let r=t(e,i),a=r.replace(/\d/g,`0`);n.has(a)||n.set(a,r)}return[...n.values()]}function Ra(e,t,n,r){return e.reduce((e,i)=>Math.max(e,r(i,t,n)),0)}function za(e){return typeof e==`function`?e:t=>t[e]}let Ba=e=>typeof e==`string`?JSON.stringify(e):String(e);function Va(e,n,r){let i=yr(e,`lineChart`);wr(n,`lineChart`);let o=oo(n);so(n);let s=n,c=zn(n.motion,r.motion),l=lt(n.on,r.presets),u=Dn(n.colors),d=r.clock??a,f=i.ownerDocument;Tn(f);let p=Y(`svg`,{class:`ec-chart ec-line-chart`,role:`group`},i),m=Y(`g`,{class:`ec-grid`,"aria-hidden":`true`},p),h=Y(`g`,{class:`ec-axis`,"aria-hidden":`true`},p),g=Y(`line`,{class:`ec-crosshair`,"aria-hidden":`true`,visibility:`hidden`},p),_=Y(`g`,{class:`ec-focus`,"aria-hidden":`true`,visibility:`hidden`},p),v=Y(`g`,{class:`ec-lines`},Y(`g`,{class:`ec-marks`,"aria-hidden":`true`},p)),y=Y(`g`,{class:`ec-overlay`,"aria-hidden":`true`},p),x=Y(`g`,{class:`ec-points`},Y(`g`,{class:`ec-marks`,"aria-hidden":`true`},p)),w=Y(`g`,{class:`ec-columns`},p),T=It(p),E=[],D=new Map,O=new Map,k=new WeakMap,A=[],j=new Map,M=new Map,N=fr(e=>e.kind===`line`?e.presence.animating:e.row.presence.animating||e.row.values.animating||e.row.x.animating),P=er(`lineChart`),F=br(i),I=!1,ee=1/0,L=new WeakSet,R,z,B,V;try{R=he(s),z=wt(s,R),B=o===`x`?io(s,R):void 0,V=o===`point`?ao(s,R):void 0}catch(e){throw p.remove(),e}let te=e=>M.get(e)??j.get(e)??N.get(e),H=Zn({overlay:y,measure:T,mark:e=>({set:t=>{te(e)?.handle.set(t),J.restyled(e)},reset:()=>{te(e)?.handle.reset(),J.restyled(e)}}),colors:e=>te(e)?.parts[0]?.colors}),U=Ct({effects:l,motion:c,icons:r.icons,clock:d,surface:H}),ne=Rr(p,{motion:c,option:()=>s.tooltip,description:()=>s.markDescription}),re=An(p),ie=vr(p),ae=s.announce?Ot(p):void 0,oe=!1,se=()=>{oe=!0},ce=C(R.frame.scale,S,{clock:d,motion:c,onChange:se}),le=C(R.frame.box,S,{clock:d,motion:c,onChange:se}),W=C(Ai(R.curve),b,{clock:d,motion:c,onChange:se}),G=new Map,ue=new Map,de=R.decimals,fe={changed:[],added:[],removed:[]},pe=R.frame,me=Tr({clock:d,runner:U,leaving:N,draw:Ae,land:Me});function he(e,t=l){let n=ma(e);Sr(t,n.series.map(e=>e.series),`lineChart`);let{room:r}=e;ha(r);let i=ga({data:e.data,encoding:n,width:e.width??F,height:e.height,format:tr(e),measure:T,label:ge(e,!0),room:r}),a=new Set(i.series);for(let e of i.rows)for(let t of i.series){let n=ba(t,e.key);if(a.has(n))throw RangeError(`lineChart: two marks would have the key "${n}". Series and keys joined with "@" must be unique.`);a.add(n)}for(let e of i.rows)if(a.has(e.key))throw RangeError(`lineChart: the key "${e.key}" would name both an x and a line or point. A row's key can't be a series, or a series and a key joined with "@".`);return i}function ge(e,n=!1){let{labels:r}=e;if(r===!1)return;let i=tr(e);return(a,o)=>{let s=`${i(o)} ${Qn(e.seriesLabels,a)}`;if(typeof r!=`function`)return s;try{let e=r(o,a,i);return e==null?``:String(e)}catch(e){return!n&&!L.has(r)&&(L.add(r),t(e)),s}}}function _e(e){let t=ge(s);if(t)return{text:(n,r)=>t(n,ar(r,e[n]??ir(r))),measure:T}}function ve(e){let t=e.rows.map(Ha);return{lines:new Map(va(e.frame,t,e.series,xe(e),e.time,_e(e.decimals),Ai(e.curve)).map(e=>[e.series,e])),points:new Map(t.flatMap(t=>xa(e.frame,t,e.series,e.time)).map(e=>[e.key,e]))}}function ye(e){let t=e.rows[0],n=e.rows[e.rows.length-1];return t&&n?Math.min(Math.max(ee,t.x),n.x):ee}function xe(e){let t=e.rows[e.rows.length-1];return t&&ee<t.x?ye(e):1/0}let Se=e=>!e.leaving&&e.row.x<=ye(R);function Ce(e,t){let n=Y(`g`,{class:`ec-column`,"data-key":e.key,role:`img`},w),r={clock:d,motion:c,onChange:se},i={key:e.key,row:e,column:n,hit:Y(`rect`,{class:`ec-hit`},n),x:C(e.x,b,r),values:C(e.levels,S,r),presence:C(+!t,b,r),anchor:void 0,points:[],leaving:!1,shown:!0,px:0};return k.set(n,i),i}function we(e,t,n){let r=Y(`g`,{class:`ec-line`,"data-key":e,"data-series":e},v),i=Y(`g`,{class:`ec-body`},r),a={kind:`line`,key:e,series:e,group:r,body:i,path:Y(`path`,{class:`ec-stroke`,"stroke-width":ua},i),end:Y(`circle`,{class:`ec-end`,r:da},i),label:Y(`text`,{class:`ec-value ec-end-label`},r),drawnLabel:void 0,parts:[],handle:Wn(()=>a),target:t,shown:t,presence:C(+!n,b,{clock:d,motion:c,onChange:se}),leave:void 0};return a}function Te(e,t){let n=Y(`g`,{class:`ec-point`,"data-key":t.key,"data-series":t.series},x),r=Y(`g`,{class:`ec-body`},n),i={kind:`point`,key:t.key,series:t.series,row:e,group:n,body:r,path:Y(`path`,{class:`ec-dot`},r),parts:[],handle:Wn(()=>i),target:t,shown:t,hidden:void 0,leave:void 0};return i}let Ee=e=>te(e.key)===e,K=e=>e.points.filter(e=>M.get(e.key)===e),De=()=>[...N.values()].filter(e=>e.kind===`line`),Oe=()=>({scale:ce.value,box:le.value});function ke(){let e=e=>({x:e.x.value,values:e.values.value}),t=new Map,n=new Set,r=i=>{let a=t.get(i);if(a)return a;let o=i.presence.value,s=e(i);if(i.anchor&&o<1&&!n.has(i)){n.add(i);let e=r(i.anchor);n.delete(i),s={x:e.x+o*(s.x-e.x),values:S(e.values,s.values)(o)}}return t.set(i,s),s};return[...E,...[...O.values()].filter(e=>e.presence.value>0&&e.anchor)].map(e=>{let{x:t,values:n}=r(e),i=e.anchor&&e.presence.value<1?{presence:e.presence.value}:{};return{record:e,state:{key:e.key,datum:e.row.datum,x:t,values:n,missing:e.row.missing,...i}}}).sort((e,t)=>e.state.x-t.state.x)}function Ae(){if(!oe)return;oe=!1;let e=Oe(),t=ke();Ne(e),Pe(e,t.map(e=>e.state));for(let{record:n,state:r}of t){let t=new Map(xa(e,r,n.points.map(e=>e.series),R.time).map(e=>[e.key,e]));Ie(n.points.filter(Ee).flatMap(e=>t.has(e.key)?[{record:e,placed:t.get(e.key)}]:[]))}Ve(t.map(e=>e.state)),He(e,t),Je()}function je(){let e=Oe(),t=ke();Pe(e,t.map(e=>e.state)),He(e,t),Je()}function Me(){for(let e of O.values()){for(let t of[e.x,e.values,e.presence])t.stop();e.column.remove()}O.clear();for(let e of E)e.anchor=void 0,e.points=e.points.filter(Ee);for(let[e,t]of[[G,R.yTicks],[ue,R.xTicks]]){for(let t of[...e.values()])t.wanted||(t.line?.remove(),t.label.remove(),e.delete(t.value));for(let n of t){let t=e.get(n.value);t&&(t.line&&`line`in n&&X(t.line,{...n.line,opacity:void 0}),Ft(t.label,n.label),t.label.removeAttribute(`opacity`))}}de=R.decimals;let{frame:e}=R;X(p,jt(e.box)),pe=e;let t=ve(R),n=(e,t)=>{let n=e.flatMap(e=>{let n=t(e);return n?[{record:e,to:n}]:[]});if(!n.every(({record:e,to:t})=>qa(e.target.geometry,t.geometry)&&Ja(e.target.data,t.data)))for(let{record:e,to:t}of n)e.target=t;Ie(n.map(({record:e})=>({record:e,placed:e.target})))};n(A,e=>t.lines.get(e.series)),Fe(new Map(A.flatMap(e=>t.lines.has(e.series)?[[e,t.lines.get(e.series)]]:[])));let r=E.map(e=>({record:e,state:Ha(e.row)}));for(let{record:e}of r)n(K(e),e=>t.points.get(e.key));Ve(r.map(e=>e.state)),He(e,r),Je(),oe=!1}function Ne(e){pe=e,X(p,jt(e.box));let t=tr(s);for(let n of G.values()){let r=Ea(e,n.value,t(n.value)),i=n.opacity.value<1?n.opacity.value:void 0;X(n.line,{...r.line,opacity:i}),Ft(n.label,r.label),X(n.label,{opacity:i})}for(let t of ue.values())Ft(t.label,Da(e,t.value,t.text).label),X(t.label,{opacity:t.opacity.value<1?t.opacity.value:void 0})}function Pe(e,t){let n=[...A,...De()];if(t.length===0||n.length===0)return;let r=va(e,t,n.map(e=>e.series),xe(R),R.time,_e(de),W.value);Ie(n.map((e,t)=>({record:e,placed:r[t]}))),Fe(new Map(n.map((e,t)=>[e,r[t]])))}function Fe(e){for(let[t,{label:n}]of e)n&&Ft(t.label,n),t.drawnLabel=n&&n.text!==``?n:void 0,X(t.label,{visibility:t.drawnLabel?void 0:`hidden`})}function Ie(e){let t=e.some(({record:e,placed:t})=>!Ja(e.shown.data,t.data));for(let{record:n,placed:r}of e)n.kind===`line`?Le(n,r,t):Re(n,r,t)}function Le(e,t,n){let r=n||Or(e.shown.geometry,t.geometry);e.shown=t;let{geometry:i}=t;ze(e,vn(u.slot(e.series)),{visible:i.length>=.5,open:{width:i.thickness}}),X(e.end,{cx:i.end.x,cy:i.end.y,visibility:t.data.samples.length===0?`hidden`:void 0});let a=e.presence.value;X(e.group,{opacity:a<1?a:void 0}),r&&U.change(i,t.data)}function Re(e,t,n){let r=n||Or(e.shown.geometry,t.geometry);e.shown=t,ze(e,vn(u.slot(e.series)),{visible:!0}),r&&U.change(t.geometry,t.data)}function ze(e,t,n){let r=e.parts[0],{d:i}=e.shown.geometry.outline,a=r?.colors.color!==t.color;(a||r?.d!==i||r.visible!==n.visible||r.open?.width!==n.open?.width)&&(e.path.getAttribute(`d`)!==i&&e.path.setAttribute(`d`,i),a&&At(e.group,bn(t)),e.parts=[{element:e.path,d:i,colors:t,...n}],e.handle.repaint(),r&&a&&H.recolor(e.key))}let Be=!1;function Ve(e){let t=ya(e,R.series);if(t.size!==0||Be){for(let e of M.values())e.group.classList.toggle(`ec-alone`,t.has(e.key));Be=t.size>0}}function He(e,t){let{x:n}=_a(e),r=t.filter(({record:e})=>Se(e)),i=Sa(e,r.map(({state:e})=>n(e.x)));r.forEach(({record:e,state:t},r)=>{X(e.hit,{...i[r]}),e.px=n(t.x)});let a=new Set(r.map(({record:e})=>e));for(let e of[...E,...O.values()]){let t=a.has(e);e.shown!==t&&(e.shown=t,X(e.column,{visibility:t?void 0:`hidden`,"aria-hidden":e.leaving?`true`:void 0}));let n=!Se(e);for(let t of e.points)t.hidden!==n&&(t.hidden=n,X(t.group,{visibility:n?`hidden`:void 0}),H.hide(t.key,n))}et&&gt(e)}function Ue(e){let t=M.get(e);if(t){if(!Se(t.row))return;let{row:e}=t.row;ne.show(t.shown.geometry,mt(e,t.series),()=>no(e,t.series,s),t.handle.style.transform);return}let n=D.get(e);if(!n||!Se(n))return;let r=K(n),i=r[0]?.shown.geometry.center.x??n.px;X(g,{...Ca(pe,i),visibility:void 0});let a=r.map(e=>{let{transform:t}=e.handle.style,{center:n}=e.shown.geometry;return(t?q.apply(t,n):n).y}),{row:o}=n,c=a.length>0?{top:Math.min(...a)-da,bottom:Math.max(...a)+da}:{top:pe.box.top,bottom:pe.box.top};ne.showAt({x:i,...c},o,()=>to(o,s))}function We(){g.setAttribute(`visibility`,`hidden`),ne.hide()}function Ge(e){let t=e===void 0?void 0:D.get(e);!t||!Se(t)?g.setAttribute(`visibility`,`hidden`):X(g,{...Ca(pe,t.px),visibility:void 0})}let Ke;function qe(e){let t=e===void 0?void 0:M.get(e),n=e===void 0?void 0:t?.row??D.get(e),r=n!==void 0&&Se(n),i=r?t?[t]:K(n):[];if(r&&i.length===0)Ke??(Ke=Y(`line`,{class:`ec-focus-ring`,"stroke-width":2},_)),(_.childElementCount>1||_.firstElementChild!==Ke)&&_.replaceChildren(Ke),X(Ke,Ca(pe,n.px)),_.removeAttribute(`visibility`);else{for(Ke?.remove();_.childElementCount>i.length;)_.lastElementChild.remove();i.forEach((e,t)=>{let n=_.children[t];n||(n=Y(`g`,{},_),Y(`path`,{class:`ec-focus-ring`,"stroke-width":8},n),Y(`path`,{class:`ec-focus-gap`,"stroke-width":4},n));for(let t of Array.from(n.children))t.setAttribute(`d`,e.shown.geometry.outline.d);let{transform:r}=e.handle.style;X(n,{transform:r&&Mt(r)})}),X(_,{visibility:i.length>0?void 0:`hidden`})}}function Je(){J.key!==void 0&&Ue(J.key),J.standing!==void 0&&Ge(J.standing),J.ringKey!==void 0&&qe(J.ringKey)}let Ye=e=>({mark:e.target.geometry,data:e.target.data}),Xe=e=>({mark:e.shown.geometry,data:e.shown.data});function Ze(e){let t=D.get(e);if(!t||!Se(t))return;let{row:n}=t;return{mark:be({key:e,x:t.px,y:pe.box.top,r:da}),data:{datum:n.datum,samples:[{t:0,value:NaN,at:R.time?new Date(n.x):n.x}],related:()=>void 0}}}function Qe(e){let t=e,n=typeof t?.closest==`function`?t.closest(`.ec-column`):null,r=n?k.get(n):void 0;return r&&D.get(r.key)===r&&Se(r)?r:void 0}let et,tt,nt=new Map,rt=[],it=new WeakMap;function at(){let e=new Map(R.series.map(e=>[e,[]]));for(let t of E)for(let n of K(t))e.get(n.series)?.push(n);return[...e.values()].flat()}let ot=e=>E.filter(Se).flatMap(t=>K(t).filter(t=>t.series===e));function st(e){let t=E.filter(Se).flatMap(K),n,r=1/0,i=1/0;for(let a of t){let t=Xa(a.shown.geometry.center,e),o=R.series.indexOf(a.series);(t<r||t===r&&o<i)&&([n,r,i]=[a,t,o])}if(!n)return;let a=n.shown.geometry.center,o=new Map;for(let n of t){let{center:t}=n.shown.geometry,r=o.get(n.series);Xa(t,a)<=1&&(!r||Xa(t,e)<Xa(r.shown.geometry.center,e))&&o.set(n.series,n)}if(o.size<2)return n;let s=n,c=1/0;for(let t of R.series){let n=o.get(t);if(!n)continue;let r=ct(n,e);r<c&&([s,c]=[n,r])}return s}function ct(e,t){let{geometry:n,data:r}=e.shown,i=j.get(e.series);return(i&&Za(i.shown,r.samples[0].at,n.center,t,9))??Math.max(0,Math.hypot(t.x-n.center.x,t.y-n.center.y)-4.5)}function ut(e){let t=J.key===void 0||!ne.element()?void 0:M.get(J.key);if(!t||!Se(t.row))return;let{transform:n}=t.handle.style,r=e;if(n)try{r=q.apply($e(n),e)}catch{return}let{center:i}=t.shown.geometry;return(r.x-i.x)**2+(r.y-i.y)**2<=4.5**2?t:void 0}function dt(e,t){let n=ft(e,t);return ut(n)??st(n)}function ft(e,t){let n=p.getBoundingClientRect(),r=n.width>0&&pe.box.width>0?n.width/pe.box.width:1;return{x:(e-n.left)/r,y:(t-n.top)/r}}let pt=new WeakMap;function mt(e,t){let n=pt.get(e);n||pt.set(e,n=new Map);let r=n.get(t);return r||n.set(t,r={datum:e.datum,series:t}),r}function ht(){if(o!==`point`)return;et||(et=Y(`g`,{class:`ec-stops`},p),p.insertBefore(et,w.nextSibling),tt=Y(`rect`,{class:`ec-hit`},et),et.addEventListener(`click`,e=>{let t=dt(e.clientX,e.clientY);t&&nt.get(t.key)?.element.focus()}));let e=at(),t=new Set(e.map(e=>e.key));for(let[e,n]of nt)t.has(e)||(n.element.remove(),nt.delete(e));let n=e.map(e=>{let t=nt.get(e.key);if(!t){let n=Y(`g`,{class:`ec-stop`,"data-key":e.key,role:`img`},et);t={element:n,bounds:Y(`circle`,{r:8.5,fill:`none`},n),x:NaN,y:NaN,hidden:void 0},nt.set(e.key,t),it.set(n,e.key)}let n=V?.get(e.key)??e.key;return t.element.getAttribute(`aria-label`)!==n&&t.element.setAttribute(`aria-label`,n),ne.describe(t.element,mt(e.row.row,e.series)),t.element});mr(et,rt,n,J.active),rt=n}function gt(e){let{left:t,right:n,top:r,bottom:i}=e.box;X(tt,{x:t-da,y:r-da,width:n-t+2*da,height:i-r+2*da});for(let[e,t]of nt){let n=M.get(e);if(!n)continue;let r=!Se(n.row);t.hidden!==r&&(t.hidden=r,X(t.element,{visibility:r?`hidden`:void 0}));let{x:i,y:a}=n.shown.geometry.center;(t.x!==i||t.y!==a)&&(t.x=i,t.y=a,X(t.bounds,{cx:i,cy:a}))}}function _t(e){let t=M.get(e);if(t)return t.row.key;let n=E.filter(Se),r=n.findIndex(t=>t.key===e);for(let e=0;r>=0&&e<n.length;e++)for(let t of[r+e,r-e]){let e=n[t]&&K(n[t])[0];if(e)return e.key}}function vt(e){e!==o&&(J.leave(),o=e,e===`point`?(ht(),gt(pe)):w.removeAttribute(`display`),J.retarget(_t),e===`point`?w.setAttribute(`display`,`none`):(et?.remove(),et=tt=void 0,nt.clear(),rt=[]))}let yt=new Map;function bt(e,t){let n=t?o===`point`?te(e)?.series:void 0:yt.get(e);n!==void 0&&(t?yt.set(e,n):yt.delete(e),H.hot(e,t),(t||![...yt.values()].includes(n))&&(te(n)?.group.classList.toggle(`ec-hot-line`,t),H.hot(n,t)))}function xt(e){let t=o===`point`?M.get(e):void 0,n=o===`point`?t?.row:D.get(e);return n!==void 0&&Se(n)}let J=ur({svg:p,runner:U,events:P,dim:()=>o===`point`&&s.dim!==!1&&J.key!==void 0,hot:bt,find(e,t){if(o===`x`){let t=Qe(e);return t&&{key:t.key}}let n=e;if(!et||typeof n?.closest!=`function`||!et.contains(n))return;if(t){let e=dt(t.x,t.y);return e&&{key:e.key}}let r=n.closest(`.ec-stop`),i=r?it.get(r):void 0;return i!==void 0&&xt(i)?{key:i}:void 0},moves:()=>o===`point`,live:xt,order:()=>(o===`point`?at().filter(e=>Se(e.row)):E.filter(Se)).map(e=>e.key),page(e,t){let n=o===`point`?M.get(e):void 0,r=n?ot(n.series).map(e=>({key:e.key,x:e.row.row.x})):E.filter(Se).map(e=>({key:e.key,x:e.row.x})),i=r.findIndex(t=>t.key===e);if(i<0)return;if(!R.time)return n?r[Math.min(r.length-1,Math.max(0,i+t*Math.ceil(r.length/10)))].key:void 0;let a=Xi(r[i].x,t,ma(s).timeZone);if(t>0)return(r.find(e=>e.x>=a)??r[r.length-1])?.key;for(let e=r.length-1;e>=0;e--)if(r[e].x<=a)return r[e].key;return r[0]?.key},move(e,t){let n=o===`point`?M.get(e):void 0;if(!n)return;let r=t===`ArrowUp`||t===`ArrowDown`?K(n.row).sort((e,t)=>e.shown.geometry.center.y-t.shown.geometry.center.y):ot(n.series),i=r.indexOf(n),a=t===`Home`?0:t===`End`?r.length-1:i+(t===`ArrowDown`||t===`ArrowRight`?1:-1);return r[Math.max(0,Math.min(r.length-1,a))]?.key},marks:e=>{let t=D.get(e);return t?K(t).map(e=>e.key):M.has(e)?[e]:[]},element:e=>(D.get(e)??O.get(e))?.column??nt.get(e)?.element,markElement:e=>te(e)?.group,onScreen(e){let t=te(e);return t&&Xe(t)},standIn:Ze,stand:Ge,ring:qe,tooltip:{show:Ue,hide:We,element:()=>ne.element()}}),St=()=>re.update(R.series.map(e=>({series:e,label:Qn(s.seriesLabels,e)})),u,s.legend);function wt(e,t){return gr({option:e.table,caption:e.label,category:typeof e.x==`string`?e.x:void 0,series:t.series,label:t=>Qn(e.seriesLabels,t),rows:t.rows.map(e=>({key:e.key,category:e.label,datum:e.datum,index:e.index,values:Ua(e.values),missing:e.missing,total:Ga(e.values)})),format:tr(e),total:!1,missing:so(e)})}function Tt(e){o===`x`&&(e.column.setAttribute(`aria-label`,B.get(e.key)),ne.describe(e.column,e.row))}function Dt(e,n){let r=s.announce;if(!ae||!r)return;let i=R.series,a=e=>e.row.label,{changed:o,added:c,removed:l}=fe,u=Et({...s.label===e.label?{}:{label:s.label},...i.join(`
95
95
  `)===n.join(`
96
- `)?{}:{series:i.map(e=>Qn(s.seriesLabels,e))},changed:o.map(a),added:c.map(a),removed:l.map(a),count:E.length});if(typeof r!=`function`){ae.say(u);return}let d=e=>e.key;try{let e=r({text:u,changed:o.map(d),added:c.map(d),removed:l.map(d)});e!=null&&ae.say(String(e))}catch(e){t(e)}}function kt(e){R=e;let t=ve(e),n={entering:[],exiting:[],changed:[]},r=new Set(e.rows.map(e=>e.key)),i=e.rows.length>0?e.series:[],a={changed:[],added:[],removed:[]},o=E,s=new Map(o.map(e=>[e,e.row])),c=new Map(e.rows.map(e=>[e.key,e])),l=A.filter(e=>!i.includes(e.series)),u=[];for(let e of o){let t=!r.has(e.key),n=c.get(e.key)?.missing;t&&(D.delete(e.key),e.leaving=!0,O.set(e.key,e),a.removed.push(e));for(let r of K(e))(t||!i.includes(r.series)||n?.has(r.series))&&u.push(r)}for(let e of l)j.delete(e.series);for(let e of u)M.delete(e.key);for(let e of[...l,...u])N.start(e);n.exiting.push(...l,...u);let d=new Set,f=a.removed.length>0;E=e.rows.map(e=>{let t=D.get(e.key);return t?(d.add(t),t.row.x!==e.x&&(f=!0),e.values.some((e,n)=>t.row.values[n]?.series!==e.series||t.row.values[n]?.value!==e.value)&&a.changed.push(t)):(t=O.get(e.key)??Ce(e,!0),O.delete(e.key),t.leaving=!1,t.x.set(e.x),t.values.set(e.levels),D.set(e.key,t),a.added.push(t),f=!0),t.row=e,t}),E.forEach((e,t)=>{d.has(e)?e.presence.value===1&&(e.anchor=void 0):e.anchor=Ka(E,t,d)});for(let e of a.removed)e.anchor??(e.anchor=Ka(o,o.indexOf(e),d));let p=A;A=i.map(e=>{let r=j.get(e),i=t.lines.get(e);if(r){let t=[...d].some(t=>Wa(s.get(t),e)!==Wa(t.row,e));(f||t)&&n.changed.push({record:r,from:r.shown.geometry})}else r=Nt(e,`line`)??we(e,i,!0),j.set(e,r),n.entering.push(r);return r.target=i,r});for(let e of E){let r=d.has(e)?s.get(e):void 0,a=i.filter(t=>!e.row.missing.has(t)).map(i=>{let a=ba(i,e.key),o=t.points.get(a),s=M.get(a);return s?r&&Wa(r,i)!==Wa(e.row,i)&&n.changed.push({record:s,from:s.shown.geometry}):(s=Nt(a,`point`)??Te(e,o),s.row=e,M.set(a,s),n.entering.push(s)),s.target=o,s}),o=new Set(a);e.points=[...a,...e.points.filter(e=>!o.has(e)&&Ee(e))]}for(let e of E)Tt(e);return ht(),mr(w,o.filter(e=>!e.leaving).map(e=>e.column),E.map(e=>e.column),J.active),mr(v,p.map(e=>e.group),A.map(e=>e.group),()=>null),fe=a,oe=!0,Ae(),n}function Nt(e,t){return N.get(e)?.kind===t?N.recall(e):void 0}function Pt(e,t){oe=!0;let{frame:n}=e;for(let[t,n,r]of[[G,e.yTicks,!0],[ue,e.xTicks,!1]]){let e=new Set(n.map(e=>e.value));for(let n of e)t.has(n)||Lt(t,n,0,r);for(let n of t.values())n.wanted=e.has(n.value)}for(let t of e.xTicks)ue.get(t.value).text=t.label.text;let r=De(),i=[...O.values()],a=Q(ce,n.scale,Dr)||[...G.values()].some(e=>Q(e.opacity,+!!e.wanted,$))||E.some(e=>Q(e.values,e.row.levels,Dr))||A.some(e=>Q(e.presence,1,$))||r.some(e=>Q(e.presence,0,$))||Q(W,Ai(e.curve),$),o=Q(le,n.box,Dr)||[...ue.values()].some(e=>Q(e.opacity,+!!e.wanted,$))||E.some(e=>Q(e.x,e.row.x,$)||e.anchor!==void 0&&Q(e.presence,1,$))||i.some(e=>e.anchor!==void 0&&Q(e.presence,0,$)),s,l;!t&&c.staged?(s={duration:500},l={duration:500,delay:a?500:0}):t||(s=l={duration:(a&&o?2:1)*500});let u=[],d=(e,t,n,r)=>{Q(e,t,n)&&(r?u.push(e.to(t,r)):e.set(t))};d(ce,n.scale,Dr,s),d(W,Ai(e.curve),$,s),d(le,n.box,Dr,l);for(let e of G.values())d(e.opacity,+!!e.wanted,$,s);for(let e of ue.values())d(e.opacity,+!!e.wanted,$,l);for(let e of E)d(e.values,e.row.levels,Dr,s),d(e.x,e.row.x,$,l),d(e.presence,1,$,e.anchor?l:void 0);for(let e of i)d(e.presence,0,$,e.anchor?l:void 0);for(let e of A)d(e.presence,1,$,s);for(let e of r)d(e.presence,0,$,s);return u}function Lt(e,t,n,r,i=``){let a={value:t,line:r?Y(`line`,{class:t===0?`ec-baseline`:`ec-gridline`},m):void 0,label:Y(`text`,{class:`ec-tick`},h),text:i,opacity:C(n,b,{clock:d,motion:c,onChange:se}),wanted:!0};e.set(t,a);for(let t of[...e.values()].sort((e,t)=>e.value-t.value))t.line&&m.appendChild(t.line),h.appendChild(t.label)}function Rt(e,t){return R=e,de=Object.fromEntries(e.series.map(t=>[t,Math.max(de[t]??0,e.decimals[t]??0)])),me.run(Pt(e,t))}let zt=Pr(p,c);function Bt(){if(I)return;let e=he(s),t=new Map(e.rows.map(e=>[e.key,e]));for(let e of E)e.row=t.get(e.key)??e.row;let n=ve(e);for(let e of A)e.target=n.lines.get(e.series)??e.target;for(let e of M.values())e.target=n.points.get(e.key)??e.target;Rt(e,!0)}let Vt=()=>{T.clear(),Bt()},Ht=Nr(p,d,Vt),Ut=jr(i,d,F,e=>{F=e,s.width===void 0&&Bt()}),Wt=Mr(f,Vt);xr(p,s),St(),ie.render(z);{let e=ve(R);for(let e of R.yTicks)Lt(G,e.value,1,!0);for(let e of R.xTicks)Lt(ue,e.value,1,!1,e.label.text);E=R.rows.map(t=>{let n=Ce(t,!1);return D.set(t.key,n),n.points=R.series.filter(e=>!t.missing.has(e)).map(r=>{let i=Te(n,e.points.get(ba(r,t.key)));return M.set(i.key,i),i}),Tt(n),n}),A=R.rows.length>0?R.series.map(t=>we(t,e.lines.get(t),!1)):[];for(let e of A)j.set(e.series,e);ht(),o===`point`&&w.setAttribute(`display`,`none`),Me()}let Gt=()=>[...A,...E.flatMap(K)];J.sync(),U.enter(Gt().map(Ye));function Kt(e){let t=D.get(e);return o===`x`?(t??M.get(e)?.row)?.key:(M.get(e)??(t&&K(t)[0]))?.key}return Fn(J.link,{element:p,async update(e){if(I)return;if(e.motion!==void 0&&e.motion!==s.motion)throw TypeError("lineChart: `motion` can't be changed by update() yet.");let t={...s,...e};wr(t,`lineChart`);let n=oo(t);so(t);let i=`on`in e?Cr(l,s.on,t.on,r.presets):l,a=he(t,i),o=wt(t,a),d=n===`x`?io(t,a):void 0,f=n===`point`?ao(t,a):void 0;`colors`in e&&(u=Dn(t.colors));let m=s,h=R.series;s=t,B=d,V=f,xr(p,s),ie.render(o);let g=ae!==void 0;s.announce&&!ae?ae=Ot(p):!s.announce&&ae&&(ae.destroy(),ae=void 0),vt(n),J.syncDim(),me.supersede();let _=i!==l;l=i;let v=Er({runner:U,events:P,hover:J,leaving:N,input:Ye,onScreen:Xe,data:`data`in e,..._?{swap:e=>{let t=new Set(e.entering);U.swap(i,Gt().filter(e=>!t.has(e)).map(Ye))}}:{}},()=>kt(a),()=>{g&&Dt(m,h)});St();let y=Rt(a,c.mode===`off`);await me.wait(y,v)},reveal(e){if(I)return;if(e instanceof Date&&Number.isNaN(e.getTime()))throw RangeError(`lineChart: reveal(x) needs a valid Date, got an invalid Date.`);let t=e instanceof Date?e.getTime():e;if(typeof t!=`number`||Number.isNaN(t))throw RangeError(`lineChart: reveal(x) needs a number, got ${typeof t==`string`?JSON.stringify(t):String(t)}.`);let n=ye(R);ee=t,ye(R)!==n&&(je(),J.dropGone(),J.sync())},on:P.on,marks:()=>[...A.map(e=>e.shown.geometry),...E.filter(Se).flatMap(e=>K(e).map(e=>e.shown.geometry))],focus(e){let t=I?void 0:Kt(e);t!==void 0&&J.focus(t)},leave(){I||J.leave()},labels:()=>A.flatMap(e=>dr(e.key,`value`,e.drawnLabel,e.label)),paintOf(e){let t=j.get(e);if(t)return{color:t.series,drawn:!0,...t.end.getAttribute(`visibility`)===`hidden`?{}:{end:da,ring:2}};let n=M.get(e);return n&&(n.group.classList.contains(`ec-alone`)?{color:n.series,drawn:!0,ring:2}:{color:n.series,drawn:!1})},standsFor(e){return D.has(e)?[...R.series.map(t=>ba(t,e)),e]:[e]},moveTabStop(e){let t=I?void 0:Kt(e);return t!==void 0&&J.moveTabStop(t)},destroy(){if(!I){I=!0,me.destroy(),J.destroy(),U.destroy(),ne.destroy(),re.destroy(),ie.destroy(),ae?.destroy(),zt(),Ht(),Ut(),Wt();for(let e of[...E,...O.values()])for(let t of[e.x,e.values,e.presence])t.stop();for(let e of[...A,...De()])e.presence.stop();for(let e of N.values())e.leave?.resolve();ce.stop(),le.stop(),W.stop();for(let e of[...G.values(),...ue.values()])e.opacity.stop();P.clear(),D.clear(),O.clear(),j.clear(),M.clear(),N.clear(),E=[],A=[],p.remove()}}})}function Ha(e){return{key:e.key,datum:e.datum,x:e.x,values:e.levels,missing:e.missing}}function Ua(e){return e.flatMap(e=>e.value===void 0?[]:[{series:e.series,value:e.value}])}function Wa(e,t){return e.values.find(e=>e.series===t)?.value}function Ga(e){return e.reduce((e,t)=>e+(t.value??0),0)}function Ka(e,t,n){for(let r=t-1;r>=0;r--)if(n.has(e[r]))return e[r];for(let r=t+1;r<e.length;r++)if(n.has(e[r]))return e[r]}function qa(e,t){return e.key===t.key&&!Or(e,t)&&e.start.x===t.start.x&&e.start.y===t.start.y&&e.end.x===t.end.x&&e.end.y===t.end.y}function Ja(e,t){return e.datum!==t.datum||e.samples.length!==t.samples.length?!1:e.samples.every((e,n)=>{let r=t.samples[n];return e.t===r.t&&e.value===r.value&&Ya(e.at,r.at)&&e.gapBefore===r.gapBefore})}function Ya(e,t){return e===t||e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function Xa(e,t){return(e.x-t.x)**2+(e.y-t.y)**2}function Za({geometry:e,data:{samples:t}},n,r,i,a){let o=t.findIndex(e=>Ya(e.at,n));if(o<0||!(e.length>0))return;let s=t[o].t,c=a/e.length,l;for(let n of[-1,1]){let a=r;for(let r=o;;r+=n){let o=t[r+n];if(!o||(n>0?o:t[r]).gapBefore)break;let u=n>0?Math.min(o.t,s+c):Math.max(o.t,s-c),d=e.path(u);if(l=Math.min(l??1/0,Qa(i,a,d)),u!==o.t)break;a=d}}return l}function Qa(e,t,n){let r=n.x-t.x,i=n.y-t.y,a=r*r+i*i,o=a>0?Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*i)/a)):0;return Math.hypot(e.x-t.x-o*r,e.y-t.y-o*i)}function $a(e,t){return Ua(e).map(e=>({series:e.series,label:Qn(t.seriesLabels,e.series),value:e.value}))}function eo(e,t){let n=tr(t),r=so(t);return e.map(e=>{let i=Qn(t.seriesLabels,e.series);return e.value===void 0?`${i} ${r}`:`${n(e.value)} ${i}`})}function to(e,t){return e.missing.size===0?Lr(e.label,$a(e.values,t),tr(t),{total:!1}):{title:e.label,lines:[eo(e.values,t).join(` · `)]}}function no(e,t,n){return Lr(e.label,$a(e.values,n).filter(e=>e.series===t),tr(n),{total:!1})}function ro(e,n,r){if(!e.markLabel)return r.text;try{let t=e.markLabel(n,r);if(t!=null&&String(t).trim()!==``)return String(t)}catch(e){t(e)}return r.text}function io(e,t){let n=tr(e);return new Map(t.rows.map(t=>{let r=`${t.label}: ${eo(t.values,e).join(`, `)}`;return[t.key,ro(e,t.datum,{key:t.key,category:t.label,values:$a(t.values,e),total:Ga(t.values),format:n,text:r})]}))}function ao(e,t){let n=tr(e);return new Map(t.rows.flatMap(t=>$a(t.values,e).map(r=>{let i=ba(r.series,t.key),a=`${t.label}: ${n(r.value)} ${r.label}`;return[i,ro(e,t.datum,{key:i,category:t.label,values:[r],total:r.value,format:n,text:a})]})))}function oo(e){let{hover:t=`x`}=e;if(t!==`x`&&t!==`point`)throw TypeError(`lineChart: hover must be "x" or "point", got ${typeof t==`string`?JSON.stringify(t):String(t)}.`);return t}function so(e){let{missing:t=`missing`}=e;if(typeof t!=`string`||t.trim()===``)throw TypeError(`lineChart: missing must be a word for a missing value, such as "no data", got ${typeof t==`string`?JSON.stringify(t):String(t)}.`);return t}let co=.5;function lo(e){let t=uo(e.start,e.pivot);return t>co&&Math.abs(uo(e.center,e.pivot)-t)<=co&&Math.abs(uo(e.end,e.pivot)-t)<=co}let uo=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),fo=.5,po=[`left`,`right`,`top`,`bottom`];function mo(e){return typeof e==`string`&&po.includes(e)}function ho(e,t){if(t!==`auto`)return e.map(()=>t);if(e.length===0)return[];let n=yo(e,e=>e.x,e=>e.x+e.width,`left`,`right`),r=yo(e,e=>e.y+e.height,e=>e.y,`bottom`,`top`);if(n&&r)return bo(e)?n:r;let i=n??r;if(!i)throw RangeError(`expressive: baseline "auto" found no edge that every mark grows from. Pass baseline: "left", "right", "top" or "bottom".`);return i}function go(e,t,n){let r=vo(t.map(e=>e.box)),i=xo(r,n),a=t.map((e,t)=>({index:t,...i(e.box)})).sort((e,t)=>e.near-t.near||e.far-t.far||e.index-t.index),o=0,s=1/0,c=a.map(({index:e,near:n,far:r})=>{o>0&&r>n&&(s=Math.min(s,n-o));let i=Math.max(0,r-o);return o=Math.max(o,r),{series:t[e].series,size:i}}),l=t[a[a.length-1].index],u=t.length===1?t[0].series:void 0;return{geometry:me({key:e,...u===void 0?{}:{series:u},...r,baseline:n,radius:l.radius,gap:Number.isFinite(s)?Math.max(0,So(s)):0,...c.every(e=>e.series!==void 0)?{segments:c.map(e=>({series:e.series,size:So(e.size)}))}:{}}),order:a.map(e=>e.index)}}function _o(e,t){let n=t[0]===`left`||t[0]===`right`,r=e=>n?e.y:e.x,i=e=>n?e.x:e.y;return e.map((e,t)=>t).sort((t,n)=>r(e[t])-r(e[n])||i(e[t])-i(e[n])||t-n)}function vo(e){let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y));return{x:t,y:n,width:So(Math.max(...e.map(e=>e.x+e.width))-t),height:So(Math.max(...e.map(e=>e.y+e.height))-n)}}function yo(e,t,n,r,i){let a=e[0];if(!a)return[];for(let o of[t(a),n(a)]){let a=[];for(let s of e)if(Math.abs(t(s)-o)<fo)a.push(r);else if(Math.abs(n(s)-o)<fo)a.push(i);else break;if(a.length===e.length)return a}}function bo(e){let t=e=>Math.max(...e)-Math.min(...e),n=t(e.map(e=>e.y+e.height/2)),r=t(e.map(e=>e.x+e.width/2));return n===r?e[0].width>=e[0].height:n>r}function xo(e,t){switch(t){case`left`:return t=>({near:t.x-e.x,far:t.x+t.width-e.x});case`right`:return t=>({near:e.x+e.width-(t.x+t.width),far:e.x+e.width-t.x});case`top`:return t=>({near:t.y-e.y,far:t.y+t.height-e.y});case`bottom`:return t=>({near:e.y+e.height-(t.y+t.height),far:e.y+e.height-t.y})}}function So(e){return Math.round(e*1e3)/1e3}function Co(){let e=new Map,t=t=>{let n=e.get(t);return n||(n={attributes:new Map,styles:new Map,classes:new Set,before:{}},e.set(t,n)),n},n=e=>e.style,r=(e,t,n)=>{n===null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)},i=(e,t)=>{let i=t.before.style;t.styles.size>0||!i||(t.before.style=void 0,n(e)?.cssText===i.css&&r(e,`style`,i.text))},a=(e,t)=>{let n=t.before.class;if(t.classes.size>0||n===void 0)return;t.before.class=void 0;let i=e=>[...new Set((e??``).split(/\s+/).filter(Boolean))].sort().join(` `);i(e.getAttribute(`class`))===i(n)&&r(e,`class`,n)};function o(e,n,i){let a=e.getAttribute(n),o=t(e).attributes,s=o.get(n);s?(a!==s.written&&(s.original=a),s.written=i):o.set(n,{original:a,written:i}),r(e,n,i)}function s(t,n,i){if(i!==null){o(t,n,i);return}let a=e.get(t)?.attributes,s=a?.get(n);a&&s&&(t.getAttribute(n)===s.written&&r(t,n,s.original),a.delete(n))}function c(e,r,a){let o=n(e);if(!o)return;let s=t(e),c=s.styles.get(r);if(a===void 0){if(!c)return;c.value===``?o.removeProperty(r):o.setProperty(r,c.value,c.priority),s.styles.delete(r),i(e,s)}else c||(s.styles.size===0&&(s.before.style={text:e.getAttribute(`style`),css:o.cssText}),s.styles.set(r,{value:o.getPropertyValue(r),priority:o.getPropertyPriority(r)})),o.getPropertyValue(r)!==a&&o.setProperty(r,a)}function l(n,r,i){let o=n.classList;if(i){if(o.contains(r))return;let e=t(n);e.classes.size===0&&(e.before.class=n.getAttribute(`class`)),e.classes.add(r),o.add(r);return}let s=e.get(n);s?.classes.delete(r)&&(o.remove(r),a(n,s))}function u(t){let n=e.get(t);if(n){for(let e of[...n.styles.keys()])c(t,e,void 0);for(let e of[...n.classes])l(t,e,!1);for(let e of[...n.attributes.keys()])s(t,e,null);e.delete(t)}}return{attribute:s,remove:(e,t)=>o(e,t,null),style:c,styled:(t,n)=>e.get(t)?.styles.has(n)??!1,toggleClass:l,restore:u,restoreAll(){for(let t of[...e.keys()])u(t)},elements:()=>[...e.keys()]}}function wo(){let e=new Map;return t=>(e.has(t)||e.set(t,Fo(t)),e.get(t))}function To(e,t,n,r=Fo){let i=r(e),a=i&&r(t);return i&&a?q.multiply($e(i),a):q.multiply($e(Io(e,n)),Io(t,n))}function Eo(e,t){if(Do(t))return e;let n=e=>q.apply(t,e),r=e=>ze(Le(je(e),t)),i=jo(t),{outline:a}=e;return{key:e.key,...e.series===void 0?{}:{series:e.series},start:n(e.start),end:n(e.end),length:e.length*i,path:t=>n(e.path(t)),angle:n=>{let r=e.angle(n),i=Math.cos(r),a=Math.sin(r);return Math.atan2(t[1]*i+t[3]*a,t[0]*i+t[2]*a)},slice:(t,n)=>r(e.slice(t,n)),...e.gaps===void 0?{}:{gaps:e.gaps},thickness:e.thickness*i,outline:{d:r(a.d),closed:a.closed,sample:e=>a.sample(e).map(n)},bounds:Mo(t,e.bounds),center:n(e.center),pivot:n(e.pivot),...e.segments===void 0?{}:{segments:e.segments.map(e=>Eo(e,t))}}}let Do=e=>e[0]===1&&e[1]===0&&e[2]===0&&e[3]===1&&e[4]===0&&e[5]===0;function Oo(e){return et(e.getAttribute(`transform`)??``)}function ko(e){let[t,n,r,i]=e,a=1e-9*Math.max(Math.abs(t),Math.abs(n),Math.abs(r),Math.abs(i));return Math.abs(n)<=a&&Math.abs(r)<=a||Math.abs(t)<=a&&Math.abs(i)<=a}function Ao(e){let[t,n,r,i]=e,a=t*t+n*n,o=r*r+i*i,s=1e-4*Math.max(a,o);return Math.abs(a-o)<=s&&Math.abs(t*r+n*i)<=s}function jo(e){return Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2]))}function Mo(e,t){let n=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}].map(t=>q.apply(e,t)),r=n.map(e=>e.x),i=n.map(e=>e.y),a=Lo(Math.min(...r)),o=Lo(Math.min(...i));return{x:a,y:o,width:Lo(Lo(Math.max(...r))-a),height:Lo(Lo(Math.max(...i))-o)}}function No(e){let t=Po(e),n=e=>{let n=Number.parseFloat(t(e)??``);return Number.isFinite(n)?n:0};return{x:n(`x`),y:n(`y`),width:Math.max(0,n(`width`)),height:Math.max(0,n(`height`))}}function Po(e){return t=>{if(!e.hasAttribute(t))return null;let n=e[t];return typeof n?.baseVal?.value==`number`?String(n.baseVal.value):e.getAttribute(t)}}function Fo(e){let t=typeof e.getScreenCTM==`function`?e.getScreenCTM():null;return t?[t.a,t.b,t.c,t.d,t.e,t.f]:void 0}function Io(e,t){let n=[1,0,0,1,0,0];for(let r=e;r&&r!==t;r=r.parentElement)n=q.multiply(Oo(r),n);return n}function Lo(e){return Math.round(e*1e3)/1e3}function Ro(e,t,n){let r={},i=!1,a=Un(),o=()=>{let{transform:n,opacity:a,emphasis:o}=r;for(let r of e()){let{element:e,colors:s}=r,c=n&&r.parentInverse?q.multiply(r.parentInverse,n,r.parent,Oo(e)):void 0;t.style(e,`transform`,c&&Zo(c)),t.style(e,`transform-origin`,c&&`0 0`),t.style(e,`transform-box`,c&&`view-box`),t.style(e,`opacity`,a===void 0?void 0:String(a));let l=s?o===void 0?i?s.strong:void 0:Xo(s,o):void 0;t.style(e,`fill`,s?.paint===`fill`?l:void 0),t.style(e,`stroke`,s?.paint===`stroke`?l:void 0),t.style(e,`transition`,o===void 0||!s?void 0:`none`)}s()},s=()=>{let t=e().flatMap(e=>e.outline===void 0?[]:[{...e.outline,color:e.colors?.color}]);a.paint(n(),t,r.halo,r.transform)};return{get style(){return r},set(e){r=ft(r,e),o()},reset(){r={},o()},repaint:o,hot(e){e!==i&&(i=e,o())}}}function zo(e,t){let n=e.localName===`line`?Uo:Ko(e,t,`fill`),r=n===Uo?`stroke`:`fill`,i=r===`fill`?n:Ko(e,t,`stroke`);if(i!==void 0&&i!==Uo)return{...Bo(i),paint:r}}function Bo(e){return{color:e,strong:`color-mix(in oklab, ${e}, ${yn(`text`)} ${Ho})`}}function Vo(e,t,n){let r=e.ownerDocument.defaultView?.getComputedStyle?.(e).getPropertyValue(n).trim()??``;if(Go(t))return r;for(let r=e;r;r=r===t?null:r.parentElement){let e=r.style?.getPropertyValue(n)||r.getAttribute(n);if(e)return e.trim()}return r}let Ho=`25%`,Uo=`none`,Wo=new WeakMap;function Go(e){let t=Wo.get(e);if(t!==void 0)return t;let n=e.ownerDocument.defaultView;if(!e.isConnected||typeof n?.getComputedStyle!=`function`)return!1;let r=e.ownerDocument.createElementNS(`http://www.w3.org/2000/svg`,`g`);r.setAttribute(`stroke-miterlimit`,`7`),e.appendChild(r);let i=n.getComputedStyle(r).getPropertyValue(`stroke-miterlimit`).trim()===`7`;return r.remove(),Wo.set(e,i),i}function Ko(e,t,n){let r=e.ownerDocument.defaultView?.getComputedStyle?.(e).getPropertyValue(n),i=Yo(r);if(r&&Go(t))return i;let a;for(let r=e;r&&a===void 0;r=r===t?null:r.parentElement){let e=r.style?.getPropertyValue(n)||r.getAttribute(n);e&&(a=e)}let o=n===`fill`?i?.replace(/\s/g,``)===`rgb(0,0,0)`:i===Uo;return i!==void 0&&!(o&&a!==void 0)?i:Yo(a)}function qo(e,t){let n=e.ownerDocument.defaultView?.getComputedStyle?.(e),r=n?.getPropertyValue(`stroke-width`),i=Jo(r),a=n?.getPropertyValue(`vector-effect`).trim().toLowerCase(),o=e.style?.getPropertyValue(`vector-effect`)?a:e.getAttribute(`vector-effect`)?.trim().toLowerCase(),s=(a&&(a!==`none`||Go(t))?a:o)===`non-scaling-stroke`;if(r&&Go(t)||i!==void 0&&i!==1)return{width:i,screen:s};for(let n=e;n&&!n.style?.getPropertyValue(`stroke-width`);n=n===t?null:n.parentElement){let e=Jo(n.getAttribute(`stroke-width`));if(e!==void 0)return{width:e,screen:s}}return{width:i,screen:s}}function Jo(e){let t=/^\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)\s*(?:px\s*)?$/i.exec(e??``),n=t?Number(t[1]):NaN;return n>=0&&Number.isFinite(n)?n:void 0}function Yo(e){let t=e?.trim().toLowerCase();if(t&&t!==`inherit`&&!t.startsWith(`url(`))return t===Uo||t===`transparent`||/^rgba\((?:[^,]+,){3}\s*0(?:\.0*)?\s*\)$/.test(t)?Uo:e.trim()}function Xo(e,t){let n=Math.min(1,Math.max(0,t));return n===0?e.color:n===1?e.strong:`color-mix(in srgb, ${e.strong} ${Math.round(n*1e3)/10}%, ${e.color})`}function Zo(e){return`matrix(${e.map((e,t)=>t<4?Math.round(e*1e6)/1e6:Math.round(e*1e3)/1e3).join(`, `)})`}function Qo(e,t){let n=jo(t);if(!Ao(t)||!(n>0)||e.length>32||e.some(e=>e.op===`C`||e.op===`Q`))return;let r=.5/n,i=Ce(e);if(i.length===0||i.length>2||!i.every(ss))return;let a=i.map(e=>os(e.segments,r)),o=i.length===2?$o(a[0],a[1],r):es(a[0],r);return o&&as(o,t)}function $o(e,t,n){let[r,i]=[e[0],t[0]];if(e.length!==1||t.length!==1||r?.kind!==`arc`||i?.kind!==`arc`)return;let[a,o]=r.radius>=i.radius?[r,i]:[i,r],s=(e,t)=>Math.abs(Math.abs(e)-O)*t<=n;for(let e of[rs(a),a.arcs[0].center]){if(!e)continue;let[t,r]=[ls(a.from,e),ls(o.from,e)],[i,c]=[ns(a,e),ns(o,e)];if(t>n&&t-r>n&&Math.sign(i)!==Math.sign(c)&&s(i,t)&&s(c,r)&&is(a,e,t,n)&&is(o,e,r,n))return{center:e,inner:r,outer:t,start:cs(a.from,e),sweep:Math.sign(i)*O}}}function es(e,t){let n=-1;if(e.forEach((t,r)=>{t.kind===`arc`&&(n<0||t.radius>e[n].radius)&&(n=r)}),n<0)return;let r=[...e.slice(n),...e.slice(0,n)],i=r[0],[,a,o,s]=r,c=r.length===3&&a?.kind===`line`&&o?.kind===`line`,l=r.length===4&&a?.kind===`line`&&o?.kind===`arc`&&s?.kind===`line`?o:void 0;if(!c&&!l)return;let[u,d]=l?[l.from,l.to]:[a.to,a.to],f=(e,n)=>{let r=ls(e,n);return r>t?{x:e.x+(n.x-e.x)*i.radius/r,y:e.y+(n.y-e.y)*i.radius/r}:void 0},p=f(i.from,d),m=f(i.to,u);if(!p||!m)return;let h={x:(p.x+m.x)/2,y:(p.y+m.y)/2};c&&ls(u,h)<=t&&(h=u);let g=h===u?0:(ls(u,h)+ls(d,h))/2,_=ns(i,h);if(_===0)return;let v={center:h,inner:g,outer:(ls(i.from,h)+ls(i.to,h))/2,start:cs(i.from,h),sweep:_};return ts(v,i,l,[u,d],t)?v:void 0}function ts(e,t,n,[r,i],a){let{center:o,start:s,sweep:c}=e,l=(e,t)=>({x:o.x+e*Math.cos(t),y:o.y+e*Math.sin(t)});return e.outer>a&&e.outer-e.inner>a&&ls(t.from,l(e.outer,s))<=a&&ls(t.to,l(e.outer,s+c))<=a&&is(t,o,e.outer,a)&&ls(r,l(e.inner,s+c))<=a&&ls(i,l(e.inner,s))<=a&&(!n||Math.abs(ns(n,o)+c)*e.inner<=a&&is(n,o,e.inner,a))}function ns(e,t){let n=0;for(let r of e.arcs){let e=P(cs(j(r,1),t)-cs(j(r,0),t));n+=e+O*Math.round((r.sweep-e)/O)}return n}function rs(e){let t=[e.from,...e.arcs.slice(0,-1).map(e=>j(e,1))];if(t.length<2)return;if(t.length===2)return{x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2};let[n,r,i]=[t[0],t[Math.floor(t.length/3)],t[Math.floor(2*t.length/3)]],a=2*(n.x*(r.y-i.y)+r.x*(i.y-n.y)+i.x*(n.y-r.y));if(!(Math.abs(a)>0))return;let[o,s,c]=[n,r,i].map(({x:e,y:t})=>e*e+t*t);return{x:(o*(r.y-i.y)+s*(i.y-n.y)+c*(n.y-r.y))/a,y:(o*(i.x-r.x)+s*(n.x-i.x)+c*(r.x-n.x))/a}}let is=(e,t,n,r)=>Math.abs(e.radius-n)<=r&&e.arcs.every(e=>[0,.5,1].every(i=>Math.abs(ls(j(e,i),t)-n)<=r));function as(e,t){let n=jo(t),r=q.apply(t,e.center),i=q.apply(t,{x:e.center.x+e.outer*Math.cos(e.start),y:e.center.y+e.outer*Math.sin(e.start)}),a=t[0]*t[3]-t[1]*t[2]<0?-e.sweep:e.sweep,o=((cs(i,r)+Math.PI/2)%O+O)%O;return o>O-1e-9&&(o=0),{cx:us(r.x),cy:us(r.y),inner:us(e.inner*n),outer:us(e.outer*n),start:o,end:o+a}}function os(e,t){let n=[],r=(e,n)=>e!==void 0&&Math.sign(e.sweep)===Math.sign(n.sweep)&&Math.abs(e.radius-n.radius)<=t;for(let t of e){let e=n[n.length-1];t.kind===`line`?n.push({kind:`line`,from:t.from,to:t.to}):e?.kind===`arc`&&r(e,t)?n[n.length-1]={...e,arcs:[...e.arcs,t],to:j(t,1),sweep:e.sweep+t.sweep}:n.push({kind:`arc`,arcs:[t],from:j(t,0),to:j(t,1),radius:t.radius,sweep:t.sweep})}let[i]=n,a=n[n.length-1];return n.length>1&&i?.kind===`arc`&&a?.kind===`arc`&&a.arcs.every(e=>r(i,e))&&(n[0]={...i,arcs:[...a.arcs,...i.arcs],from:a.from,sweep:a.sweep+i.sweep},n.pop()),n}let ss=({closed:e,start:t,end:n})=>e||t.x===n.x&&t.y===n.y,cs=(e,t)=>Math.atan2(e.y-t.y,e.x-t.x),ls=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),us=e=>Math.round(e*1e3)/1e3+0;function ds(e){if(typeof e==`string`){if(typeof document>`u`)throw TypeError(`expressive: a selector needs a document.`);return{elements:Array.from(document.querySelectorAll(e)),data:void 0}}if(hs(e))return{elements:[e],data:void 0};if(gs(e)){let t=Array.from(e.nodes()),n=Array.from(e.data());return{elements:t,data:n.length===t.length?n:void 0}}if(typeof e==`object`&&e&&typeof e.length==`number`)return{elements:Array.from(e),data:void 0};throw TypeError(`expressive needs marks: a selector, an element, a list of elements or a D3 selection.`)}function fs(e){if(!gs(e))return;let{elements:t,data:n}=ds(e);return n&&new Map(t.map((e,t)=>[e,n[t]]))}function ps(e){let t;for(let n of e){if(!hs(n))throw TypeError(`expressive: marks must be elements, got ${String(n)}.`);let e=n.ownerSVGElement??null;if(!e){let e=n.localName;throw TypeError(e===`svg`?`expressive: got an <svg>, not its marks. Pass the marks, for example svg.querySelectorAll("rect").`:`expressive: marks must be SVG elements inside an <svg>, got <${e}>.`)}for(;e.ownerSVGElement;)e=e.ownerSVGElement;if(t&&e!==t)throw TypeError(`expressive: all marks must be in the same <svg>.`);t=e}if(!t)throw TypeError(`expressive: no marks.`);return t}function ms(e,t){let n=e[0].parentElement??t;for(;n!==t&&!e.every(e=>e!==n&&n.contains(e));)n=n.parentElement??t;return n}function hs(e){return typeof e==`object`&&!!e&&e.nodeType===1}function gs(e){return typeof e==`object`&&!!e&&typeof e.nodes==`function`&&typeof e.data==`function`}let _s=[`d`,`x`,`y`,`width`,`height`,`cx`,`cy`,`r`,`rx`,`ry`,`x1`,`y1`,`x2`,`y2`,`points`,`transform`],vs=[`transform`,`style`];function ys(e,t,n){let r=e.defaultView?.MutationObserver??(typeof MutationObserver>`u`?void 0:MutationObserver);if(!r)throw TypeError(`expressive: watch needs MutationObserver, which this DOM doesn't have.`);let i=new Set,a=new Set,o=new Set,s=new Set,c,l=e=>{for(let{target:t,attributeName:n}of e){let e=t;o.has(e)&&i.add(e),s.has(e)&&(n===`transform`||n===`style`)&&a.add(e)}},u=new r(e=>{l(e),(i.size>0||a.size>0)&&!c&&(c=t.onFrame(d))});function d(){if(l(u.takeRecords()),i.size===0&&a.size===0){c?.(),c=void 0;return}let e={marks:i,ancestors:a};i=new Set,a=new Set,n(e)}function f(){u.takeRecords(),c?.(),c=void 0,i=new Set,a=new Set}return{observe(e,t){f(),u.disconnect(),o=new Set(e),s=new Set;for(let n of e)for(let e=n.parentElement;e&&!s.has(e);e=e===t?null:e.parentElement)s.add(e);for(let e of s)o.has(e)||u.observe(e,{attributes:!0,attributeFilter:vs});for(let e of o)u.observe(e,{attributes:!0,attributeFilter:_s})},destroy(){f(),u.disconnect(),o=new Set,s=new Set}}}let bs=`Since 0.13.0 geometry is called with (datum, element, key), not (element, datum, key).`,xs=new Set([`circle`,`ellipse`,`line`,`path`,`polygon`,`polyline`]),Ss=new Set([`img`,`image`,`graphics-symbol`,`graphics-object`]),Cs=new WeakMap,ws=e=>e?Cs.get(e):void 0;function Ts(e,n,r){Es(n);let i=zn(n.motion,r.motion),o=lt(n.on,r.presets),s=n.on,c=r.clock??a,l=n.dim===!0,u=Co(),d=new WeakMap,f=e,p=!1,m=!1;function h(e){let{elements:t,data:r}=ds(e);if(t.length===0)return{root:void 0,ancestor:void 0,marks:[]};let i=ps(t),a=ms(t,i),s=new Map;t.forEach((e,t)=>{let i=D(e,t,r),a=n.key(i,e);if(a==null||a===``)throw TypeError(`expressive: key returned ${JSON.stringify(a)??String(a)} for a <${e.localName}>. Every mark needs a key.`);let o=String(a),c=e.localName;if(!n.geometry&&c!==`rect`&&!xs.has(c))throw TypeError(`expressive: can't read the geometry of a <${c}> (mark "${o}"). <rect>, <circle>, <ellipse>, <line>, <path>, <polygon> and <polyline> are read; describe others with the geometry option.`);let l=O(i,e,o),u=s.get(o);if(!u)s.set(o,u=[]);else if(!n.geometry&&(xs.has(c)||xs.has(u[0].element.localName))){let e=xs.has(c)?c:u[0].element.localName;throw TypeError(`expressive: two elements have the key "${o}", and one is a <${e}>. A circle or a shape is a mark of its own: give each its own key.`)}else if(l===void 0)throw RangeError(`expressive: two elements have the key "${o}". Keys must be unique, or name each part with segment.`);else if(u.some(e=>e.series===l))throw RangeError(`expressive: the mark "${o}" has two "${l}" segments.`);u.push({element:e,datum:i,series:l,value:n.value?.(i,e)})});let c={svg:i,common:a,screen:wo(),colors:e=>A(e,i),stroke:e=>qo(e,i)},l=e=>({...e,label:k(e.key,e.parts)}),u=[...s.keys()];if(n.geometry)return{root:i,ancestor:a,marks:E(T(Ps(u.map((e,t)=>l(g(e,s.get(e),t,c))),e=>e.geometry)),o)};let d=[],f=[];u.forEach((e,t)=>{let n=s.get(e);if(n[0].element.localName===`rect`&&!_(n,c))d.push(t);else{let r=b(e,n[0],t,c);r&&f.push(r)}});let p=d.map(e=>s.get(u[e]).map(t=>v(u[e],t,c))),m=p.map(e=>vo(e.map(e=>e.rect.box))),h=ho(m,n.baseline??`auto`),x=e=>y(u[d[e]],p[e],h[e],d[e],c);return{root:i,ancestor:a,marks:E(T(f.length===0?_o(m,h).map(e=>l(x(e))):Ps([...d.map((e,t)=>x(t)),...f].sort((e,t)=>e.index-t.index),e=>e.geometry).map(e=>l(e))),o)}}function g(e,t,r,i){let a=t[0],o;try{o=n.geometry(a.datum,a.element,e)}catch(t){throw Object.assign(TypeError(`expressive: geometry for "${e}" threw. ${bs} Its error: ${t instanceof Error?t.message:String(t)}`),{cause:t})}if(typeof o!=`object`||!o||o.key!==e)throw TypeError(`expressive: geometry for "${e}" must be a MarkGeometry with the key "${e}". Build it with describe and the key passed in. ${bs}`);let s=t.map(e=>w(e,Is(o,e.series,t.length),i));return{key:e,geometry:o,parts:s,index:r}}function _(e,t){return e.length===1&&!ko(C(e[0].element,t))}function v(e,t,n){let r=C(t.element,n);if(!ko(r))throw TypeError(`expressive: the <rect> of "${e}" is rotated or skewed, so it isn't an upright bar's segment. A rect turned on its own is a shape, a mark of its own: give each its own key, or describe the bar with the geometry option.`);return{...t,rect:{box:Mo(r,No(t.element)),series:t.series,radius:Ls(t.element)}}}function y(e,t,n,r,i){let{geometry:a,order:o}=go(e,t.map(e=>e.rect),n),s=a.segments??[],c=o.map((e,n)=>{let r=s[n];return w(t[e],r&&r.length>=.5?{d:r.outline.d}:void 0,i)});return{key:e,geometry:x(a,c[0]),parts:c,index:r,rect:{edge:n,box:vo(t.map(e=>e.rect.box))}}}function b(e,t,n,r){let{element:i,series:a}=t,o=i.localName,s=C(i,r),c=Po(i),l=e=>{let t=Number.parseFloat(c(e)??``);return Number.isFinite(t)?t:0},u=o===`circle`?l(`r`):0,d,f;if(o===`circle`&&(Ao(s)||!(u>0))){let t=q.apply(s,{x:l(`cx`),y:l(`cy`)});d=be({key:e,series:a,x:Rs(t.x),y:Rs(t.y),r:Rs(Math.max(0,u)*jo(s))})}else{let t=Pe(o,c);if(t[0]?.op!==`M`||t.every(e=>e.op===`M`))return;f=o===`circle`?void 0:r.stroke(i);let n=o===`path`?Qo(t,s):void 0;if(n)d=fe({key:e,series:a,...n});else{let n=Rs(S(f,s,r));d=Be({key:e,series:a,d:o===`path`?c(`d`)??``:ze(t),matrix:s,width:n>0?n:1})}}let p=[{...w(t,Is(d,a,1),r),stroke:f}];return{key:e,geometry:x(d,t),parts:p,index:n,...o===`circle`?{circle:!0}:{}}}function x(e,t){return n.labelBounds?Os(e,n.labelBounds(t.datum,t.element)):e}function S(e,t,n){let r=e?.width??1;if(!e?.screen)return r*jo(t);let i=n.screen(n.common),a=i?jo(i):0;return a>0?r/a:r}function C(e,t){return q.multiply(To(t.common,e.parentElement??t.svg,t.svg,t.screen),Oo(e))}function w(e,t,n){let r=To(n.common,e.element.parentElement??n.svg,n.svg,n.screen);return{element:e.element,datum:e.datum,series:e.series,value:e.value,parent:r,parentInverse:zs(r),colors:n.colors(e.element),outline:t}}function T(e){return e.map(e=>{let{key:t,geometry:r,parts:i}=e,a=e.rect?As(i):void 0,o=i[0].value,s=e.circle&&typeof o==`number`&&Number.isFinite(o)?o:void 0,c=(e,i,o)=>n.samples?Ms(n.samples(e,i),o===void 0?`"${t}"`:`"${t}" (${o})`):a===void 0?s===void 0?[]:[{t:0,value:s}]:js(r,i,a),l=new Map,u=e=>l.get(e)??He(e,t);for(let t of ks(e)){let e=(i.find(e=>e.series===t)??i[0]).datum;l.set(t,{datum:e,samples:c(e,r.segments?.find(e=>e.series===t)??r,t),related:u})}return{...e,data:{datum:i[0].datum,samples:c(i[0].datum,r),related:u}}})}function E(e,t){if(e.length===0)return e;let n=new Set(e.flatMap(e=>[...e.geometry.series===void 0?[]:[e.geometry.series],...ks(e)]));for(let e of ct){let r=t[e];if(r?.kind===`data`)for(let t of r.needs?.related??[]){if(n.has(t))continue;let r=n.size>0?`the marks' series are ${[...n].map(e=>`"${e}"`).join(`, `)}`:`the marks have no series`;throw RangeError(`expressive: on.${e} needs the series "${t}", but ${r}. Name each mark's series in its geometry (describe.line({ key, series, … })), or a stack's parts with segment.`)}}return e}function D(e,t,r){if(n.datum)return n.datum(e);if(r)return r[t];let i=e.__data__;return typeof i==`number`&&!p&&(p=!0,console.warn(`expressive: element.__data__ is a number, which looks like Observable Plot's row index. Pass datum: (el) => rows[el.__data__].`)),i}function O(e,t,r){if(!n.segment)return;let i=n.segment(e,t);if(i==null||i===``)throw TypeError(`expressive: segment returned ${String(i)} for a part of "${r}".`);return String(i)}function k(e,r){if(n.markLabel)try{let t=String(n.markLabel(r[0].datum,{key:e,parts:r.map(({series:e,datum:t})=>({series:e,datum:t}))})??``);return t.trim()===``?void 0:t}catch(e){t(e);return}}function A(e,t){if((u.styled(e,`fill`)||u.styled(e,`stroke`))&&d.has(e))return d.get(e);let n=zo(e,t);return d.set(e,n),n}let j=h(f),M=j.root?.ownerDocument??(typeof document>`u`?void 0:document);if(!M)throw TypeError(`expressive needs a DOM.`);Tn(M);let N,P,F=new Map,I=[],ee=new Map,L=new Map,R=new Set,z={enter:new Set,update:new Set,exit:new Set,hover:new Set,leave:new Set},B,V,te,H,U=!1,ne=(e,t,n)=>{let r=M.createElementNS(`http://www.w3.org/2000/svg`,e);return X(r,t),n?.appendChild(r),r},re=ne(`g`,{class:`ec-overlay`,"aria-hidden":`true`});At(re,{"pointer-events":`none`});let ie=ne(`g`,{class:`ec-halos`},re),ae=ne(`g`,{class:`ec-runs`},re),oe=Hn(re),se=e=>F.get(e)??ee.get(e),ce=It(ae),le=Zn({overlay:ae,measure:ce,mark:e=>({set:t=>se(e)?.handle.set(t),reset:()=>se(e)?.handle.reset()}),colors:(e,t)=>Ds(se(e)?.mark,t)?.colors}),W=Ct({effects:o,motion:i,icons:r.icons,clock:c,surface:le}),G=e=>({mark:e.mark.geometry,data:e.mark.data});function ue(){ce.clear();for(let e of I)W.change(e.mark.geometry,e.mark.data)}let de=()=>{},pe=Mr(M,ue);function me(e){let t={key:e.key,mark:e,handle:Ro(()=>t.mark.parts.filter(e=>(L.get(e.element)?.record??t)===t),u,()=>ie)};return t}function he(e){e.root&&e.root!==N&&ye(e.root),P=e.ancestor??P;let t=new Set(e.marks.map(e=>e.key)),r={entering:[],exiting:[],changed:[],moved:[],newRow:!1},i=[];for(let e of I)t.has(e.key)||(F.delete(e.key),ee.set(e.key,e),r.exiting.push(e));let a=L;L=new Map,I=e.marks.map(e=>{let t=F.get(e.key);if(t){let a=t.mark,o=n.value?Vs(a.parts,e.parts):Hs(a.geometry,e.geometry),s=a.data.datum!==e.data.datum;s&&(r.newRow=!0),o?r.changed.push({record:t,from:a.geometry}):(s||Ws(a.geometry,e.geometry)||Us(a.data.samples,e.data.samples))&&r.moved.push(t),(a.parts.length!==e.parts.length||e.parts.some((e,t)=>e.colors?.color!==a.parts[t].colors?.color))&&i.push(e.key),t.mark=e}else t=ee.get(e.key),t?(ee.delete(e.key),t.mark=e):t=me(e),F.set(e.key,t),r.entering.push(t);for(let n of e.parts)L.set(n.element,{record:t,part:n});return t});for(let[e,t]of a)L.get(e)?.record!==t.record&&u.restore(e);for(let e of I)ge(e);_e(),ve(),K();for(let e of I)e.handle.repaint();for(let e of i)le.recolor(e);return Ae(),r}function ge(e){if(!n.markLabel)return;let{label:t,parts:r}=e.mark;r.forEach((e,n)=>{let r=t!==void 0&&n===0;u.attribute(e.element,`role`,r?`img`:null),u.attribute(e.element,`aria-label`,r?t:null),r?u.remove(e.element,`aria-hidden`):u.attribute(e.element,`aria-hidden`,t===void 0?null:`true`)})}function _e(){let e=N,t=new Set;for(let r of n.markLabel&&e?I:[])if(r.mark.label!==void 0)for(let n of r.mark.parts)for(let r=n.element.parentElement;r&&r!==e&&e?.contains(r);r=r.parentElement){if(t.has(r)||r.hasAttribute(`aria-label`)||r.hasAttribute(`aria-labelledby`))continue;let e=r.getAttribute(`role`)?.trim().split(/\s+/)[0];(e!==void 0&&Ss.has(e)||e===void 0&&R.has(r))&&t.add(r)}for(let e of R)t.has(e)||(u.attribute(e,`role`,null),u.attribute(e,`aria-roledescription`,null));for(let e of t)u.remove(e,`role`),u.remove(e,`aria-roledescription`);R=t}function ve(){if(!N||!P)return;N.lastElementChild!==re&&N.appendChild(re),re.removeAttribute(`transform`);let e=To(re,P,N);Bs(e)||re.setAttribute(`transform`,Mt(e))}function ye(e){xe(),N=e,de=Nr(N,c,ue),N.appendChild(re),(n.keyboard===!0||n.markLabel)&&N.getAttribute(`role`)===`img`&&!m&&(m=!0,console.warn(`expressive: the <svg> is role="img", so screen readers read it as one picture and skip the marks inside, with their names and keyboard focus. Make it role="group"; its aria-label can stay.`)),te=sr(N,{find(e){let t=Se(e);if(!t)return;let{key:n}=t.record;return t.part.series===void 0?{key:n}:{key:n,segment:t.part.series}},hover(e,t){let n=F.get(e.key);!n||jn(B)&&B.keys[0]===e.key||(we(),Ce([n],t,e.segment))},leave(){(B?.source===`pointer`||B?.source===`touch`)&&we()}})}function xe(){N&&(we(),te?.destroy(),te=void 0,de())}function Se(e){for(let t=e;t&&t!==N;t=t.parentElement){let e=L.get(t);if(e)return e}}function Ce(e,t,n,r=!0){let i={keys:e.map(e=>e.key),source:t,effects:r};B=i,K(),r&&W.hover(e.map(G)),e.forEach((r,i)=>Ue(`hover`,{...G(r),batch:{index:i,count:e.length},source:t,...n===void 0?{}:{segment:n}})),t!==`linked`&&B===i&&H?.hover(e.map(G))}function we(){let e=B;e&&(B=void 0,K(),Te(e.keys),jn(e)&&H?.leave())}function Te(e){let t=e.flatMap(e=>se(e)??[]);W.leave(e),t.forEach((e,n)=>Ue(`leave`,{...G(e),batch:{index:n,count:t.length}}))}function Ee(){if(B===void 0)return;let e=B.keys.filter(e=>F.has(e));if(e.length===B.keys.length)return;if(e.length===0){te?.clear(),we();return}let t=B.keys.filter(e=>!F.has(e));B={...B,keys:e},Te(t)}function K(){if(!l)return;let e=`${i.duration(100,`feedback`)}ms`;re.classList.toggle(`ec-hovering`,B!==void 0),At(re,{"--ec-hover-duration":e});for(let t of I){let n=B?.keys.includes(t.key)===!0;for(let r of t.mark.parts)u.toggleClass(r.element,`ec-attached`,!0),u.toggleClass(r.element,`ec-dimmed`,B!==void 0&&!n),u.style(r.element,`--ec-hover-duration`,e);t.handle.hot(n),le.hot(t.key,n)}for(let e of ee.values())e.handle.hot(!1),le.hot(e.key,!1)}let De=l?i.subscribe(K):void 0,Oe=e=>new Set(ct.flatMap(t=>{let n=e[t];return n?.kind===`data`?n.needs?.related??[]:[]})),ke=Oe(o);function Ae(){let e=V===void 0?void 0:F.get(V);oe.draw(e?.mark.geometry)}let je=n.keyboard===!0?cr(()=>N,{find:e=>Se(e)?.record.key,order:()=>I.map(e=>e.key),element:e=>F.get(e)?.mark.parts[0]?.element,tabIndex(e,t){let n=F.get(e);n&&t!==void 0&&n.mark.parts.forEach((e,n)=>{u.attribute(e.element,`tabindex`,n===0?t:`-1`),u.style(e.element,`outline`,`none`)})},focus(e,t){V=t?e:void 0,Ae();let n=F.get(e);n&&(t?jn(B)&&B.keys[0]===e?B={...B,source:`keyboard`}:(we(),Ce([n],`keyboard`)):B?.source===`keyboard`&&B.keys[0]!==e&&we())},blur(){V=void 0,Ae(),B?.source===`keyboard`&&(te?.current===B.keys[0]?B={...B,source:`pointer`}:we())},escape(){return B?(B.source===`linked`&&H?H.dismiss():we(),!0):!1}}):void 0,Me=n.watch===!0?ys(M,c,Fe):void 0;function Ne(){Me?.observe(I.flatMap(e=>e.mark.parts.map(e=>e.element)),N)}function Fe(e){if(U||!P)return;let t=new Set;for(let n of e.marks){let e=L.get(n)?.record;e&&t.add(e)}let n=!1;for(let r of e.ancestors)if(r.contains(P))n=!0;else for(let e of I)e.mark.parts.some(e=>r.contains(e.element))&&t.add(e);let r=new Set;if(n){ve();for(let e of I)!t.has(e)&&e.mark.parts.some(e=>e.stroke?.screen)&&r.add(e)}if(t.size===0&&r.size===0)return;let i=Ie([...t,...r]),a=i.records.flatMap((e,t)=>r.has(e)&&!Ws(e.mark.geometry,i.marks[t].geometry)?[]:[t]);if(a.length===0)return;let o=a.map(e=>i.records[e]),s=a.map(e=>i.marks[e]);o.forEach((e,t)=>{let n=s[t];e.mark=n;for(let t of n.parts)L.set(t.element,{record:e,part:t});e.handle.repaint()}),I=Ve(I),o.some(e=>e.key===V)&&Ae();let c=new Set(o);if(o.some(e=>ke.has(e.mark.geometry.series??``)))for(let e of I)c.add(e);for(let e of c)W.change(e.mark.geometry,e.mark.data)}function Ie(e){let t={svg:N,common:P,screen:wo(),colors:e=>L.get(e)?.part.colors,stroke:e=>L.get(e)?.part.stroke},r=Re(),i=({parts:e})=>e.map(e=>({element:e.element,datum:r(e.element),series:e.series,value:e.value}));if(n.geometry){let n=e.map(({mark:e})=>({...g(e.key,i(e),e.index,t),label:e.label}));return{records:[...e],marks:T(n)}}let a=new Set(e.filter(e=>!e.mark.rect||_(e.mark.parts,t))),o=new Map(e.flatMap(e=>a.has(e)?[]:[[e,i(e.mark).map(n=>v(e.key,n,t))]])),s=Le(o,a);for(let e of I)e.mark.rect&&!o.has(e)&&!a.has(e)&&s.get(e)!==e.mark.rect.edge&&o.set(e,i(e.mark).map(n=>v(e.key,n,t)));let c=[...o.keys()],l=c.map(e=>({...y(e.key,o.get(e),s.get(e),e.mark.index,t),label:e.mark.label}));for(let n of e){if(!a.has(n))continue;let e=b(n.key,i(n.mark)[0],n.mark.index,t);e&&(c.push(n),l.push({...e,label:n.mark.label}))}return{records:c,marks:T(l)}}function Le(e,t){let r=I.filter(e=>e.mark.rect&&!t.has(e)),i=new Map(r.map(e=>[e,e.mark.rect.edge]));if(n.baseline!==void 0&&n.baseline!==`auto`)return i;let a=r.map(t=>{let n=e.get(t);return n?vo(n.map(e=>e.rect.box)):t.mark.rect.box});try{let e=ho(a,`auto`);return new Map(r.map((t,n)=>[t,e[n]]))}catch{return i}}function Re(){if(n.datum)return n.datum;let e=fs(f);return t=>e?.has(t)?e.get(t):D(t,0,void 0)}function Ve(e){let t=[...e].sort((e,t)=>e.mark.index-t.mark.index);return n.geometry||!t.every(e=>e.mark.rect)?[...Ps(t,e=>e.mark.geometry)]:_o(t.map(e=>e.mark.rect.box),t.map(e=>e.mark.rect.edge)).map(e=>t[e])}function He(e,t){return I.find(n=>n.key!==t&&n.mark.geometry.series===e)?.mark.data}function Ue(e,n){for(let r of[...z[e]])try{r(n)}catch(e){t(e)}}function We(e,t){t.forEach((n,r)=>Ue(e,{...G(n),batch:{index:r,count:t.length}}))}W.enter(he(j).entering.map(G)),je?.sync(),Ne();let Ge={targets:()=>I.map(e=>({key:e.key,marks:[G(e)]})),hover(e,t){we();let n=e.flatMap(e=>F.get(e)??[]);n.length>0&&Ce(n,`linked`,void 0,t)},unlink(){B?.source===`linked`&&we()},leave(){te?.clear(),we()},listen(e){return!U&&(H=e,!0)}},Ke=new Set;return Cs.set(Ge,{root:()=>N,ancestor:()=>P,elements:()=>I.flatMap(e=>e.mark.parts.map(e=>e.element)),keyOf:e=>Se(e)?.record.key,colorOf:e=>F.get(e)?.mark.parts[0]?.colors?.color,moveTabStop:e=>je?.moveTabStop(e)??!1,edits:u,refreshed:Ke}),Fn(Ge,{refresh(e){if(U)return;let t=h(e??f);e!==void 0&&(f=e);let n=he(t);Ne(),Ee();let r=B?.effects?n.changed.flatMap(({record:e})=>B.keys.includes(e.key)?[e]:[]):[];W.leave(r.map(e=>e.key));let i=W.exit(n.exiting.map(G));We(`exit`,n.exiting),(n.newRow||n.changed.length>0||n.entering.length>0||n.exiting.length>0)&&W.update(n.changed.map(({record:e,from:t})=>({...G(e),from:t}))),n.changed.forEach(({record:e,from:t},r)=>Ue(`update`,{...G(e),from:t,batch:{index:r,count:n.changed.length}})),W.enter(n.entering.map(G)),We(`enter`,n.entering);let a=new Set([...n.changed.map(e=>e.record),...n.moved]);if([...a,...n.entering,...n.exiting].some(e=>ke.has(e.mark.geometry.series??``))){let e=new Set(n.entering);for(let t of I)e.has(t)||a.add(t)}for(let e of a)W.change(e.mark.geometry,e.mark.data);W.hover(r.filter(e=>B?.effects&&B.keys.includes(e.key)&&F.get(e.key)===e).map(G)),je?.sync();for(let e of Ke)e();i.then(()=>{for(let e of n.exiting)ee.get(e.key)===e&&ee.delete(e.key)})},async update(e){if(U)return;if(typeof e!=`object`||!e)throw TypeError(`expressive: update() needs options, such as { on: { hover: "lift" } }.`);let t=Object.keys(e).find(e=>e!==`on`);if(t!==void 0)throw TypeError(`expressive: \`${t}\` can't be changed by update() yet. Only \`on\` can.`);if(!(`on`in e))return;let n=Cr(o,s,e.on,r.presets);E(I.map(e=>e.mark),n),s=e.on,o=n,ke=Oe(n),W.swap(n,I.map(G))},on(e,t){let n=z[e];if(!n)throw TypeError(`expressive: unknown event "${String(e)}". Use one of: ${Object.keys(z).join(`, `)}.`);return n.add(t),()=>{n.delete(t)}},marks:()=>I.map(e=>e.mark.geometry),focus(e){F.has(e)&&!U&&je?.focus(e)},leave(){U||Ge.leave()},destroy(){if(!U){U=!0,B=void 0,H?.gone(),H=void 0,Me?.destroy(),W.destroy(),De?.(),pe(),je?.destroy(),xe(),re.remove(),u.restoreAll();for(let e of Object.values(z))e.clear();F.clear(),ee.clear(),I=[],L=new Map}}})}function Es(e){if(typeof e!=`object`||!e)throw TypeError(`expressive needs options, with at least a key: { key: (d) => d.name }.`);if(typeof e.key!=`function`)throw TypeError(`expressive needs a key function, for example key: (d) => d.name. Marks are matched by key.`);for(let t of[`datum`,`segment`,`value`,`geometry`,`labelBounds`,`markLabel`])if(e[t]!==void 0&&typeof e[t]!=`function`)throw TypeError(`expressive: ${t} must be a function.`);if(e.baseline!==void 0&&e.baseline!==`auto`&&!mo(e.baseline))throw RangeError(`expressive: baseline must be "left", "right", "top", "bottom" or "auto", got ${String(e.baseline)}.`)}function Ds(e,t){if(t===void 0)return e?.parts[0];let n=e?.geometry.segments?.find(e=>e.key===t);return n&&e.parts.find(e=>e.series===n.series)}function Os(e,t){if(!Array.isArray(t))throw TypeError(`expressive: labelBounds for "${e.key}" must return a list of boxes { x, y, width, height }, got ${Ns(t)}.`);let n=t.map(e=>({x:e?.x,y:e?.y,width:e?.width,height:e?.height}));return{...e,labelBounds:ue(`shape, for expressive's labelBounds for "${e.key}"`,n)}}function ks(e){let t=[...(e.geometry.segments??[]).map(e=>e.series),...e.parts.map(e=>e.series)];return[...new Set(t.filter(e=>e!==void 0))]}function As(e){let t=0;for(let{value:n}of e){if(typeof n!=`number`||!Number.isFinite(n))return;t+=n}return t}function js(e,t,n){let r=t=>e.length>0?n*t/e.length:0;if(t===e)return[{t:0,value:0},{t:1,value:n}];let i=Fs(e.start,t.start);return[{t:0,value:r(i)},{t:1,value:r(i+t.length)}]}function Ms(e,t){if(!Array.isArray(e))throw TypeError(`expressive: samples for ${t} must return an array of { t, value }, got ${Ns(e)}.`);let n=0;return e.map((e,r)=>{let{t:i,value:a,at:o,gapBefore:s}=typeof e==`object`&&e?e:{};if(typeof i!=`number`||!(i>=0&&i<=1))throw RangeError(`expressive: samples for ${t}: samples[${r}].t must be in [0, 1], got ${Ns(i)}.`);if(i<n)throw RangeError(`expressive: samples for ${t} must be in t order: samples[${r}].t is ${i}, after ${n}.`);if(typeof a!=`number`||!Number.isFinite(a))throw RangeError(`expressive: samples for ${t}: samples[${r}].value must be a finite number, got ${Ns(a)}.`);if(s!==void 0&&typeof s!=`boolean`)throw RangeError(`expressive: samples for ${t}: samples[${r}].gapBefore must be true or false, got ${Ns(s)}.`);return n=i,{t:i,value:a,...o===void 0?{}:{at:o},...s?{gapBefore:s}:{}}})}function Ns(e){return typeof e==`string`?JSON.stringify(e):String(e)}function Ps(e,t){let n=e[0]&&t(e[0]).pivot;if(!n||!e.every(e=>Fs(t(e).pivot,n)<=.5&&lo(t(e))))return e;let r=2*Math.PI,i=e=>{let{center:i}=t(e),a=Math.atan2(i.x-n.x,n.y-i.y),o=a<0?a+r:a;return o>=r?0:o};return e.map(e=>({mark:e,angle:i(e)})).sort((e,t)=>e.angle-t.angle).map(({mark:e})=>e)}function Fs(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Is(e,t,n){let r=t===void 0?void 0:e.segments?.find(e=>e.series===t),i=r??(n===1?e:void 0);if(!(!i||r&&r.length<.5))return i.outline.closed?{d:i.outline.d}:{d:i.outline.d,stroke:i.thickness}}function Ls(e){let t=Number.parseFloat(e.getAttribute(`rx`)??``),n=Number.parseFloat(e.getAttribute(`ry`)??``),r=Number.isFinite(t)?t:n;return Number.isFinite(r)&&r>0?r:0}function Rs(e){return Math.round(e*1e3)/1e3}function zs(e){try{return $e(e)}catch{return}}function Bs(e){return Math.abs(e[0]-1)<1e-9&&Math.abs(e[1])<1e-9&&Math.abs(e[2])<1e-9&&Math.abs(e[3]-1)<1e-9&&Math.abs(e[4])<1e-6&&Math.abs(e[5])<1e-6}function Vs(e,t){if(e.length!==t.length)return!0;let n=new Map(e.map(e=>[e.series,e.value]));return t.some(e=>{let t=n.get(e.series);return!n.has(e.series)||!(t===e.value||Object.is(t,e.value))})}function Hs(e,t){let n=e.segments??[],r=t.segments??[];return Math.abs(e.length-t.length)>.01||n.length!==r.length||n.some((e,t)=>e.key!==r[t].key||Math.abs(e.length-r[t].length)>.01)}function Us(e,t){let n=(e,t)=>e===t||e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime();return e.length!==t.length||e.some((e,r)=>e.t!==t[r].t||e.value!==t[r].value||!n(e.at,t[r].at))}function Ws(e,t){if(e.outline.d!==t.outline.d||e.thickness!==t.thickness||kr(e,t))return!0;let n=e.segments??[],r=t.segments??[];return n.length!==r.length||n.some((e,t)=>e.key!==r[t].key||e.outline.d!==r[t].outline.d)}let Gs=[`font-family`,`font-size`,`font-style`,`font-weight`,`font-variant-numeric`,`letter-spacing`,`word-spacing`,`dominant-baseline`,`fill`],Ks=new Set([`font-size`,`letter-spacing`,`word-spacing`]);function qs(e,t){let n=e[t]?.baseVal;return n&&n.numberOfItems>0?n.getItem(0).value:Number.parseFloat(e.getAttribute(t)??``)||0}function Js(e,t){return t===1?e:e.replace(/(-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(px)?(?![\w.%])/gi,(e,n,r)=>`${Math.round(Number(n)*t*1e3)/1e3}${r??``}`)}function Ys(e,n={}){let r=Array.isArray(e)?e:[e];if(r.length===0)throw TypeError(`hostView needs an attachment, or an array of attachments on one <svg>: hostView([dots, connectors]).`);let i=r.map((t,n)=>{let i=typeof t==`object`&&t?In(t):void 0,a=ws(i);if(!i||!a?.root())throw TypeError(r===e?`hostView needs attachments that expressive() or fromVegaView() returned, each with marks in an <svg>: attachments[${n}] isn't one.`:`hostView needs an attachment that expressive() or fromVegaView() returned, with marks in an <svg>.`);if(r.indexOf(t)!==n)throw TypeError(`hostView: attachments[${n}] is attachments[${r.indexOf(t)}] again. Each attachment is in a view once.`);return{attachment:t,port:i,inside:a,hidden:[]}});if(typeof n!=`object`||!n||n.labels!==void 0&&typeof n.labels!=`function`)throw TypeError(`hostView: labels must be a function that returns the host's labels, such as () => names.map((element) => ({ element, key: element.textContent, role: "category" })).`);if(n.guides!==void 0&&typeof n.guides!=`function`)throw TypeError(`hostView: guides must be a function that returns the host's guides, such as () => [{ element: svg.querySelector("g.axis"), key: "y" }].`);let a=i[0],o=i.length>1,{edits:s}=a.inside,c=()=>a.inside.root(),l,u,d,f=o?Xs(i,c()):void 0;if(f)throw TypeError(`hostView: ${f.problem}.`);let p=()=>i.filter(e=>e.inside.root()===c()),m=e=>p().find(t=>t.attachment.marks().some(t=>t.key===e));function h(){if(!n.labels)return[];let e=new Set(p().flatMap(e=>e.attachment.marks().map(e=>e.key)));try{return Array.from(n.labels()).filter(t=>t?.element?.localName===`text`&&c().contains(t.element)&&e.has(t.key)&&(t.role===`category`||t.role===`value`))}catch(e){return t(e),[]}}function g(){if(!n.guides)return[];let e=c();try{return Array.from(n.guides()).filter(t=>t?.element?.nodeType===1&&t.element!==e&&e.contains(t.element)&&typeof t.key==`string`)}catch(e){return t(e),[]}}function _({element:e,key:t,role:n}){let r=c(),i=To(y.space,e,r),a=q.apply(i,{x:qs(e,`x`),y:qs(e,`y`)}),o=jo(i),s=e.ownerDocument.createElementNS(kt,`text`);s.textContent=e.textContent;for(let t of[`dx`,`dy`]){let n=e.getAttribute(t);n!==null&&s.setAttribute(t,Js(n,o))}At(s,Object.fromEntries(Gs.map(t=>{let n=Vo(e,r,t);return[t,(Ks.has(t)?Js(n,o):n)||void 0]})));let l=Vo(e,r,`text-anchor`);return{key:t,role:n,text:e.textContent??``,x:a.x,y:a.y,anchor:l===`middle`||l===`end`?l:`start`,element:s}}let v=e=>{if(e&&l===void 0&&o){let e=Xs(i,c());e&&t(TypeError(`hostView: ${e.problem}. The switch plays on, and ${e.left}.`))}let n=e?c():void 0;l=e?h():void 0,u=e?g():void 0;let r=[...(l??[]).map(e=>e.element),...(u??[]).map(e=>e.element)],a=i.map(({inside:e,hidden:t},i)=>new Set(l?[...e.elements(),...i===0?r:[],...t.filter(e=>n?.contains(e))]:[]));for(let e=1;e<a.length;e++)for(let t of a[e])a.some((n,r)=>r<e&&n.has(t))&&a[e].delete(t);i.forEach((e,t)=>{for(let n of e.hidden)a[t].has(n)||e.inside.edits.style(n,`visibility`,void 0)}),i.forEach((e,t)=>{e.hidden=[...a[t]];for(let t of e.hidden)e.inside.edits.style(t,`visibility`,`hidden`)}),d!==n&&(d&&s.toggleClass(d,`ec-morphing`,!1),n&&s.toggleClass(n,`ec-morphing`,!0),d=n)},y={get element(){return c()},get space(){let e=c(),[t,...n]=p().map(t=>t.inside.ancestor()??e),r=t;for(let t of n)for(;r!==e&&!r.contains(t);)r=r.parentElement??e;return r},refresh(e){if(o&&e!==void 0)throw TypeError(`hostView: a view of several attachments refreshes each from what it last read, with refresh(). To read new sources, refresh each attachment with its own.`);for(let{attachment:t}of i)t.refresh(e)},update:e=>o?Promise.all(i.map(({attachment:t})=>t.update(e))).then(()=>{}):a.attachment.update(e),on(e,t){let n=i.map(({attachment:n})=>n.on(e,t));return o?()=>n.forEach(e=>e()):n[0]},marks(){let e=c(),t=y.space,n=new Set;return p().flatMap(({attachment:r,inside:i})=>{let a=i.ancestor()??e,o=a===t?void 0:To(t,a,e);return r.marks().flatMap(e=>n.has(e.key)?[]:(n.add(e.key),[o?Eo(e,o):e]))})},focus:e=>m(e)?.attachment.focus(e),leave(){for(let{attachment:e}of i)e.leave()},destroy(){l=u=d=void 0;for(let e of i)e.hidden=[];for(let{attachment:e}of[...i].reverse())e.destroy()},labels:()=>(l??h()).map(_),guides:()=>u??g(),paintOf(e){for(let{inside:t}of p()){let n=t.colorOf(e);if(n!==void 0)return{color:e,drawn:!0,cssColor:n}}},keyOf(e){for(let{inside:t}of i){let n=t.keyOf(e);if(n!==void 0)return n}},moveTabStop:e=>p().some(({inside:t})=>t.moveTabStop(e)),morphing:v};for(let{inside:e}of i)e.refreshed.add(()=>{l&&v(!0)});return o?y:Fn(a.port,y)}function Xs(e,t){let n=new Map;for(let[r,{attachment:i,inside:a}]of e.entries()){if(a.root()!==t)return{problem:`attachments[${r}]'s marks are in another <svg> than attachments[0]'s, and a view's attachments share one`,left:`attachments[${r}]'s marks are left out`};for(let{key:e}of i.marks()){let t=n.get(e);if(t!==void 0&&t!==r)return{problem:`attachments[${t}] and attachments[${r}] both have a mark with the key ${JSON.stringify(e)}, and each key must be one mark's. Key each one's marks apart, such as (d) => \`first@\${d.name}\``,left:`the key stays attachments[${t}]'s: attachments[${r}]'s mark is left out`};n.set(e,r)}}}let Zs=[`line`,`rect`,`arc`,`symbol`],Qs=[`d`,`transform`,`x`,`y`,`width`,`height`,`stroke-width`];function $s(e,n,r){if(ec(e),typeof n!=`object`||!n||typeof n.key!=`function`)throw TypeError(`fromVegaView needs options with a key: { key: (d) => d.series }. Marks are matched by key.`);let i=n.mark??`marks`;if(typeof i!=`string`||i===``)throw TypeError(`fromVegaView: mark must be a mark's name, got ${String(i)}.`);if(n.sample!==void 0&&typeof n.sample!=`function`)throw TypeError(`fromVegaView: sample must be a function.`);let o=v(),{mark:s,sample:c,...l}=n,u=new WeakMap,d=Ts(o.elements,{...l,datum:e=>_(e).datum,geometry:(e,t,r)=>{let i=o.geometry.get(r);if(!i)throw TypeError(`fromVegaView: no geometry for "${r}". Its key must be the same for every item of a mark.`);if(!n.labelBounds)return i;let a=Os(i,n.labelBounds(e,t));return u.set(a,i),a},...n.samples||!n.sample?{}:{samples:(e,t)=>o.samples.get(u.get(t)??t)??[]},...n.value||!n.sample?{}:{value:(e,t)=>o.values.get(t)}},r),f=r.clock??a,p,m,h=!1,g=typeof MutationObserver==`function`?new MutationObserver(e=>e.some(C)&&w()):void 0;T(o.root);function _(e){let t=o.items.get(e);if(!t)throw TypeError(`fromVegaView: an element that isn't one of the View's items.`);return t}function v(){let t=nc(tc(e),i),r=rc(t,i,e),a=e.container(),o=a?.localName===`svg`?a:a?.querySelector(`svg`),s={root:o??void 0,elements:[],items:new Map,geometry:new Map,samples:new Map,values:new Map};if(!r||!o)return s;let c=new Set(r===`line`?t.flatMap(e=>e.items?.[0]&&oc(e.items[0])?[e.items[0]]:[]):t.flatMap(e=>e.items??[])),l=new Map;for(let e of Array.from(o.querySelectorAll(`*`))){let t=e.__data__;c.has(t)&&l.set(e,t)}let u=[...l.keys()];if(u.length===0)return s;let d=ps(u),f=ms(u,d),p=wo(),m=e=>To(f,e.parentElement??d,d,p),h=e=>String(n.key(l.get(e).datum,e)),g=e=>n.segment?String(n.segment(l.get(e).datum,e)):void 0,_={root:d,items:l,elements:u,geometry:new Map,samples:new Map,values:new Map};if(n.sample)for(let[e,t]of l){let n=r===`line`?ac(t):[t];_.values.set(e,n.map(e=>e.defined===!1?``:b(e).value).join(`,`))}if(r===`rect`)return y(_,m,h,g);for(let e of u){let t=l.get(e),i=h(e);if(_.geometry.has(i))continue;let a=m(e),o=r===`line`?lc(i,e,t,a):r===`arc`?uc(i,t,a):dc(i,t,a);_.geometry.set(i,o),n.sample&&_.samples.set(o,r===`line`?x(o,t,a):S(o,t,r))}return _}function y(e,t,r,i){let a=new Map;for(let n of e.elements){let o=e.items.get(n),s=r(n),c={box:Mo(t(n),fc(o)),series:i(n),radius:Math.max(0,o.cornerRadius??0)},l=a.get(s);l?l.push({element:n,part:c}):a.set(s,[{element:n,part:c}])}let o=[...a.keys()],s=o.map(e=>vo(a.get(e).map(e=>e.part.box))),c=ho(s,n.baseline??`auto`),l=[];for(let t of _o(s,c)){let r=o[t],i=a.get(r),{geometry:s,order:u}=go(r,i.map(e=>e.part),c[t]);if(e.geometry.set(r,s),l.push(...u.map(e=>i[e].element)),n.sample){let t=u.map(t=>b(e.items.get(i[t].element)).value),n=t.reduce((e,t)=>e+t,0);e.samples.set(s,[{t:0,value:0},{t:1,value:n}]);let r=0;(s.segments??[]).forEach((n,i)=>{let a=r;r+=t[i]??0,e.samples.set(n,[{t:0,value:a},{t:1,value:r}])})}}return{...e,elements:l}}function b(e){let t=n.sample(e.datum),r=typeof t==`number`?{value:t}:t;if(typeof r!=`object`||!r||!Number.isFinite(r.value))throw RangeError(`fromVegaView: sample must give a finite number, or { value, at }, got ${JSON.stringify(t)}.`);return r.at===void 0?{value:r.value}:{value:r.value,at:r.at}}function x(e,t,n){return rt(e,cc(t).map(({item:e,point:t})=>({...q.apply(n,t),...b(e)})))}function S(e,t,n){let{value:r,at:i}=b(t),a=i===void 0?{t:1,value:r}:{t:1,value:r,at:i};return n===`symbol`?[{...a,t:0}]:e.length>0?[{t:0,value:0},a]:[{...a,t:0}]}function C(e){let t=p?.querySelector(`:scope > .ec-overlay`),n=e=>e===t||(t?.contains(e)??!1);return n(e.target)?!1:e.type!==`childList`||[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].some(e=>!n(e))}function w(){if(m||h)return;let e=f.onFrame(()=>{e(),m=void 0;try{E()}catch(e){t(e)}});m=e}function T(e){g&&e!==p&&(g.disconnect(),p=e,e&&g.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:Qs}))}function E(){if(h)return;let e=v(),t=o;o=e;try{d.refresh(e.elements)}catch(e){throw o=t,e}T(e.root)}return Fn(In(d),{refresh:E,update:d.update,on:d.on,marks:d.marks,focus:d.focus,leave:d.leave,destroy(){h||(h=!0,g?.disconnect(),m?.(),m=void 0,d.destroy())}})}function ec(e){if(typeof e!=`object`||!e||typeof e.renderer!=`function`||typeof e.scenegraph!=`function`||typeof e.container!=`function`)throw TypeError(`fromVegaView needs a Vega View: new vega.View(runtime, { renderer: "svg", container }), or vega-embed's result.view.`);let t=e.renderer();if(t!==`svg`)throw TypeError(`fromVegaView: the View renders with "${t}", which draws no SVG elements to attach to. Use renderer: "svg" (vega-embed's default; a bare vega.View uses canvas).`)}function tc(e){let t=e.scenegraph();return t.root??t}function nc(e,t){let n=[],r=e=>{if(e.name===t&&e.marktype!==`group`&&n.push(e),e.marktype===`group`)for(let t of e.items??[])for(let e of t.items??[])r(e)};return r(e),n}function rc(e,t,n){if(e.length===0){let e=ic(tc(n));if(e.length===0)return;throw RangeError(`fromVegaView: the View has no mark named "${t}". Its named marks: ${e.map(e=>`"${e}"`).join(`, `)}.`)}let r=e[0].marktype;if(!e.every(e=>e.marktype===r)||!Zs.includes(r))throw TypeError(`fromVegaView: "${t}" is a ${String(r)} mark. Rects, arcs, symbols and lines can be read; describe others with expressive()'s geometry option.`);return r}function ic(e){let t=new Set,n=e=>{e.name&&e.marktype!==`group`&&t.add(e.name);for(let t of e.items??[])for(let e of t.items??[])n(e)};return n(e),[...t]}let ac=e=>e.mark?.items??[e],oc=e=>ac(e).some(e=>e.defined!==!1),sc=e=>{let t=ac(e)[0]?.interpolate;return t===void 0||t===`linear`};function cc(e){let t=ac(e),n=[],r=!1;for(let e of t)e.defined===!1?r=n.length>0:(n.push({item:e,point:{x:mc(e.x),y:mc(e.y)},gapBefore:r}),r=!1);return n}function lc(e,t,n,r){let i=n.strokeWidth??Number.parseFloat(t.getAttribute(`stroke-width`)??`1`);if(!sc(n)){let n=i*pc(r);return Be({key:e,series:e,d:t.getAttribute(`d`)??``,matrix:r,width:n>0&&Number.isFinite(n)?n:1})}let a=cc(n),o=a.flatMap((e,t)=>e.gapBefore?[t]:[]);return ge({key:e,series:e,points:a.map(({point:e})=>q.apply(r,e)),...o.length>0?{breaks:o}:{},width:(Number.isFinite(i)?i:1)*pc(r)})}function uc(e,t,n){let r=q.apply(n,{x:mc(t.x),y:mc(t.y)}),i=pc(n),[a,o]=[mc(t.startAngle),mc(t.endAngle)].sort((e,t)=>e-t);return fe({key:e,cx:r.x,cy:r.y,inner:mc(t.innerRadius)*i,outer:mc(t.outerRadius)*i,start:a,end:o})}function dc(e,t,n){let r=q.apply(n,{x:mc(t.x),y:mc(t.y)});return be({key:e,x:r.x,y:r.y,r:Math.sqrt(Math.max(0,t.size??64)/Math.PI)*pc(n)})}function fc(e){let t=mc(e.x),n=mc(e.y),r=mc(e.width),i=mc(e.height);return{x:Math.min(t,t+r),y:Math.min(n,n+i),width:Math.abs(r),height:Math.abs(i)}}function pc(e){return Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2]))}function mc(e){return typeof e==`number`&&Number.isFinite(e)?e:0}let hc={get:()=>void 0},gc={set(){},reset(){}},_c={place(){},update(){},remove(){}};function vc(e,n){let{effect:r,surface:i}=n;if(!yc(r))throw TypeError(`playTransition needs a transition effect (kind "transition" with run, end and clear), got ${bc(r)}.`);let o=n.start??0;if(!(typeof o==`number`&&o>=0&&o<=1))throw RangeError(`playTransition: start must be a number from 0 to 1, got ${String(o)}.`);let s=n.motion??v,c=n.clock??a,l=n.icons??hc,u=e.length,d=[],f=!1,p=u,m,h=new Promise(e=>{m=e}),g=u>0?s.subscribe(()=>{s.mode===`off`&&w()}):void 0,_=()=>{--p>0||(g?.(),g=void 0,m())};function y(e,t,n){let i=vt({clock:c,motion:s,icons:l,batch:{index:t,count:u},layer:T(e.to.key,t,()=>a.state!==`cleared`),mark:gc}),a={pair:e,index:t,scope:i,context:{...i.context,start:o},state:`running`,done:n};d[t]=a;let{from:f,to:p}=e;try{s.mode===`off`?(r.end(f,p,a.context),b(a)):Promise.resolve(r.run(f,p,a.context)).then(()=>b(a),e=>x(a,e))}catch(e){x(a,e)}}function b(e){e.state===`running`&&(e.state=`ended`,S(e))}function x(e,n){let{signal:r}=e.context;(!r.aborted||n!==r.reason&&n?.name!==`AbortError`)&&(t(n),C(e))}function S(e){let t=e.done;e.done=void 0,t?.()}function C(e){if(e.state!==`cleared`){e.state=`cleared`,e.scope.abort();try{r.clear(e.context)}catch(e){t(e)}e.scope.clear(),S(e)}}function w(){for(let e of[...d]){if(e.state!==`running`)continue;let t=e.done;e.done=void 0,C(e),y(e.pair,e.index,t)}}function T(e,t,n){let r,a=()=>n()?r??(r=i.group(e,t)):void 0;return{icon:(e,t)=>a()?.icon(e,t)??_c,path:(e,t)=>a()?.path(e,t)??_c,text:(e,t)=>a()?.text(e,t)??_c,clear(){let e=r;r=void 0,e?.clear()}}}return e.forEach((e,t)=>y(e,t,_)),u===0&&m(),{finished:h,clear(){if(!f){f=!0;for(let e of[...d])C(e)}}}}function yc(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`transition`&&typeof t.run==`function`&&typeof t.end==`function`&&typeof t.clear==`function`}function bc(e){if(typeof e!=`object`||!e)return e===null?`null`:typeof e;let t=e.kind;return t===`geometry`||t===`data`?`a ${t} effect, which plays on one mark: put it in a chart's \`on\` option`:t===`transition`?`a transition effect without run(), end() and clear()`:t===void 0?`an object with no kind`:`an effect of kind ${JSON.stringify(t)}`}let xc=.5;function Sc(e,t,n){let r=yr(e,`chartSwitch`),i=Xc(t),o=t.transition,s=Dn(t.colors),c=n.motion,l=n.clock??a,u=r.ownerDocument;Tn(u);let d=u.createElement(`div`);d.className=`ec-switch`,r.appendChild(d);let f=new Map;try{for(let e of i){let n=u.createElement(`div`);n.className=`ec-switch-view`,n.setAttribute(`data-view`,e),d.appendChild(n),Tc(n,e===t.initial);let r=t.views[e](n,s);if(!Yc(r,n))throw r?.destroy?.(),TypeError(`chartSwitch: views.${e} must return the chart it draws in the container it's given (with element, marks(), labels(), focus(), leave() and destroy()), such as donutChart(container, { ... }).`);f.set(e,{name:e,container:n,chart:r,port:In(r)})}}catch(e){for(let e of f.values())e.chart.destroy();throw d.remove(),e}let p=Y(`svg`,{class:`ec-chart ec-switch-overlay`,"aria-hidden":`true`},d),m=Y(`g`,{class:`ec-switch-fades`},p),h=Y(`g`,{class:`ec-switch-runs`},p),g=Y(`g`,{class:`ec-switch-labels`},p),_=t.announce?Ot(p):void 0,v=e=>bn(e.cssColor===void 0?vn(s.slot(e.color)):Bo(e.cssColor)),y=new WeakMap,b=(e,t)=>({group(n,r){let i=Y(`g`,{class:`ec-run`,"data-key":n},h);At(i,v(e[r]??{color:n})),y.set(i,r);let a=Array.from(h.children).find(e=>(y.get(e)??-1/0)>r);h.insertBefore(i,a??null);let o=qn(i);return{...t[r]?.wrap(o,i)??o,clear:()=>i.remove()}}});function x(e,t,n){let[r,i]=e,[a,o]=t;if(r===0&&i===0&&!a&&!o)return;let s=[];if(a&&o){let e=ae();s.push({element:e,draw:t=>Kc(e,{at:{x:Vc(a.at.x,o.at.x,t),y:Vc(a.at.y,o.at.y,t)},r:Vc(a.r,o.r,t),ring:Vc(a.ring,o.ring,t)})})}else[[a,Ic,n[0]],[o,Lc,n[1]]].forEach(([e,t,n])=>{if(!e)return;let r=ae();At(r,v(n)),Kc(r,e),s.push({element:r,draw:e=>X(r,{opacity:t(e)})})});let c=r>0||i>0,l=r,u=new Map;return{wrap(e,t){u.clear();let n=()=>{for(let e of s)t.appendChild(e.element)};return n(),{...e,path(t,r){let i=c&&r.fill!==void 0&&r.stroke===void 0,a=e.path(t,i?{...r,stroke:`surface`,width:l}:r);return n(),i?(u.set(a,t),{update(e,t){u.set(a,e),a.update(e,t)},remove(){u.delete(a),a.remove()}}):a}}},draw(e){l=Vc(r,i,e);for(let[e,t]of u)e.update(t,{width:l});for(let t of s)t.draw(e)}}}let S=t.initial,C,w=!1,T,E,D=!1,O,k=c.subscribe(()=>{c.mode===`off`&&C&&U(C,!0)}),A,j=typeof ResizeObserver==`function`?new ResizeObserver(e=>{let t=e[e.length-1]?.contentRect.width??0;if(A!==void 0&&Math.abs(t-A)<.5)return;let n=A===void 0;A=t,!n&&C&&U(C,!0)}):void 0;j?.observe(d);let M=e=>f.get(e),N=(e,t=``)=>TypeError(`chartSwitch: there's no view ${JSON.stringify(e)}${t}. The views are ${i.map(e=>JSON.stringify(e)).join(`, `)}.`);function P(){return d.getRootNode().activeElement??null}function F(e){let t=P(),n=t!==null&&e.container.contains(t),r=n?t:e.chart.element.querySelector(`[tabindex="0"]`),i=r?.closest(`[data-key]`),a=(r&&e.chart.keyOf?.(r))??(i&&e.chart.element.contains(i)?i.getAttribute(`data-key`):null);if(n||a!==null)return{keys:a===null?[]:e.chart.standsFor?.(a)??[a],focused:n}}function I(e,t){if(!t)return;let n=P(),r=n!==null&&n!==u.body&&n!==u.documentElement&&!d.contains(n);if(!t.focused||r){for(let n of t.keys)if(e.chart.moveTabStop?.(n))return;return}let i=()=>e.chart.element.contains(P());for(let n of[...t.keys,...e.chart.marks().map(e=>e.key)])if(e.chart.focus(n),i())return}function ee(e){_?.say(e.chart.element.getAttribute(`aria-label`)??``)}function L(){D&&T?.shown()}function R(e,t,n,r){return n===void 0||!c.staged||n===e.name||n===t.name?z(e,t,r):z(e,M(n),r,t)}function z(e,t,n,r){let i=n?n.focus:F(e),a=[];O=a;try{e.chart.leave()}finally{O=void 0}let o=w?Promise.resolve():B(e,t,i,r);for(let e of a)e();return o}function B(e,t,n,r,i){if(S=(r??t).name,c.mode===`off`){let e=M(S);for(let t of f.values())Tc(t.container,t===e);return I(e,n),ee(e),L(),Promise.resolve()}let a=[];for(let n of[e,t])n.container.classList.remove(`ec-switch-inactive`),a.push(re(n)),n.container.classList.add(`ec-switching`),n.container.setAttribute(`inert`,``),n.chart.morphing?.(!0),n.chart.element.classList.add(`ec-morphing`);let{pairs:o,surface:s,scene:l}=ne(e,t,a),{done:u,settle:d}=i??Jc(),p={a:e,b:t,forward:!0,pairs:o,reversed:o.map(({from:e,to:t})=>({from:t,to:e})),surface:s,scene:l,focus:n,next:r,progress:0,transition:void 0,driver:void 0,run:0,done:u,settle:d};return C=p,V(p,0),p.done}function V(e,t){let r=++e.run;if(t>=1){te(e);return}let i=t=>{e.progress=t,e.scene.draw(e.forward?t:1-t)},a=wc(l);e.transition=vc(e.forward?e.pairs:e.reversed,{effect:o,surface:e.surface,start:t,motion:c,clock:a.clock,icons:n.icons}),e.driver=Cc(t,i,{clock:a.clock,motion:c}),a.release(),Promise.all([e.driver.finished,e.transition.finished]).then(([t])=>{C===e&&e.run===r&&t===`done`&&te(e)})}function te(e){let t=e.forward?e.next:void 0;if(!t||c.mode===`off`)return U(e,!0);let{done:n,settle:r}=e;e.next=void 0,e.settle=()=>{},U(e,!1),B(e.b,t,e.focus,void 0,{done:n,settle:r})}function H(e){return e.driver?.cancel(),e.transition?.clear(),e.forward=!e.forward,S=(e.forward?e.b:e.a).name,e.settle(),{done:e.done,settle:e.settle}=Jc(),V(e,1-e.progress),e.done}function U(e,t){if(C!==e)return;C=void 0,e.run++,e.driver?.cancel(),e.transition?.clear(),e.scene.clear();let n=e.forward?e.next??e.b:e.a;for(let t of[e.a,e.b])t.chart.element.classList.remove(`ec-morphing`),t.chart.morphing?.(!1),t.container.classList.remove(`ec-switching`),t.container.style.removeProperty(`opacity`);for(let e of f.values())Tc(e.container,e===n);t&&(I(n,e.focus),ee(n),L()),e.settle()}function ne(e,t,n){let r=To(p,e.chart.space??e.chart.element,d),i=To(p,t.chart.space??t.chart.element,d),a=qc(r),o=qc(i),s=e.chart.marks().map(e=>Eo(e,r)),c=t.chart.marks().map(e=>Eo(e,i)),l=new Map(s.map(e=>[e.key,e])),f=new Set(c.map(e=>e.key)),_=[],v=[],y=[];for(let n of c){let r=l.get(n.key);if(!r)continue;let i=Hc(e,r),s=Hc(t,n);(i.drawn||s.drawn)&&(_.push({from:i.drawn?r:Uc(r),to:s.drawn?n:Uc(n)}),v.push(s),y.push(x([Wc(i,a),Wc(s,o)],[Gc(i,r,a),Gc(s,n,o)],[i,s])))}let S=[];y.some(e=>e!==void 0)&&S.push(e=>{for(let t of y)t?.draw(e)});let C=(e,t,n,r)=>{let i=Hc(e,t);i.drawn&&S.push(ie(t,i,n,r))};for(let t of s)f.has(t.key)||C(e,t,a,Ic);for(let e of c)l.has(e.key)||C(t,e,o,Lc);let w=e=>`${e.role}\n${e.key}`,T=e.chart.labels(),E=t.chart.labels(),D=e.chart.space?a:1,O=t.chart.space?o:1,k=new Map(T.map(e=>[w(e),e])),A=new Set;for(let e of E){let t=k.get(w(e));t&&(A.add(w(e)),S.push(Nc(oe(t,r,D),oe(e,i,O))))}for(let e of T)A.has(w(e))||S.push(Fc(oe(e,r,D),Ic));for(let e of E)k.has(w(e))||S.push(Fc(oe(e,i,O),Lc));let[j=[],M=[]]=n,N=new Map;for(let e of j)N.has(e.key)||N.set(e.key,e);let P=new Set;for(let e of M){let t=N.get(e.key);N.delete(e.key),t&&Mc(t,e)&&P.add(t).add(e)}let F;if(j.length+M.length>0){let e=F=u.createElementNS(kt,`g`);e.setAttribute(`class`,`ec-switch-guides`),p.insertBefore(e,m),[[j,e=>+(e<xc),Rc],[M,e=>e<xc?0:1,zc]].forEach(([t,n,r])=>{for(let i of t){e.appendChild(i.group);let t=P.has(i)?n:r;S.push(e=>i.group.setAttribute(`opacity`,Dc(t(e))))}})}return S.push(n=>{Ec(e.container,Rc(n)),Ec(t.container,zc(n))}),{pairs:_,surface:b(v,y),scene:{draw:e=>{for(let t of S)t(e)},clear:()=>{F?.remove(),m.replaceChildren(),h.replaceChildren(),g.replaceChildren()}}}}function re(e){let t=e.chart.element;return(e.chart.guides?.()??[]).flatMap(e=>{let n=e?.element,r=n?.parentElement;if(typeof e?.key!=`string`||!r||!t.contains(r))return[];let i=To(p,r,d),a=Ac(n,t),o=u.createElementNS(kt,`g`);X(o,{class:`ec-switch-guide`,"data-key":e.key,transform:Do(i)?void 0:Mt(i)}),o.appendChild(a);let s=Oo(n);return[{key:e.key,group:o,markup:a.outerHTML,corners:jc(n).map(e=>q.apply(i,q.apply(s,e))),place:i}]})}function ie(e,t,n,r){let i=Y(`g`,{class:`ec-switch-fade`,"data-key":e.key},m);At(i,v(t));let a=Wc(t,n);qn(i).path(e.outline.d,e.outline.closed?{fill:`mark`,...a>0?{stroke:`surface`,width:a}:{}}:{stroke:`mark`,width:e.thickness});let o=Gc(t,e,n);return o&&Kc(i.appendChild(ae()),o),e=>X(i,{opacity:r(e)})}function ae(){let e=u.createElementNS(kt,`circle`);return e.setAttribute(`class`,`ec-switch-end`),At(e,{fill:yn(`mark`),stroke:yn(`surface`)}),e}function oe(e,t,n){let r=e.element.cloneNode(!0);for(let e of[`id`,`opacity`,`visibility`,`aria-hidden`])r.removeAttribute(e);r.textContent=e.text;let i={text:r,at:q.apply(t,e),scale:n};return X(r,{x:i.at.x,y:i.at.y,"text-anchor":e.anchor,...Pc(i,i.at.x,i.at.y)}),g.appendChild(r),i}let se={get current(){return S},show(e,t){if(!f.has(e))return Promise.reject(N(e));let n=t?.via;if(n!==void 0&&!f.has(n))return Promise.reject(N(n,` to go via`));if(w)return Promise.resolve();let r=O;if(r)return new Promise(n=>r.push(()=>n(se.show(e,t))));let i=C;if(!i)return e===S?Promise.resolve():R(M(S),M(e),n);let a=i.forward?i.b:i.a,o=i.forward?i.a:i.b,s=i.next;return e===(s??a).name?i.done:s&&(i.next=void 0,e===a.name)?(S=e,i.settle(),{done:i.done,settle:i.settle}=Jc(),i.done):e===o.name?H(i):(U(i,!1),R(a,M(e),n,{focus:i.focus}))},chart(e){let t=f.get(e);if(!t)throw N(e);return t.chart},on(e,t){let n=Array.from(f.values(),n=>{let r=n.chart.on;if(typeof r==`function`)return r.call(n.chart,e,e=>{n.name===S&&t(e)})});return()=>{for(let e of n)e?.()}},marks:()=>M(S).chart.marks(),leave(){D=!1,w||M(S).chart.leave()},destroy(){if(w)return;w=!0;let e=C;if(e){C=void 0,e.run++,e.driver?.cancel(),e.transition?.clear(),e.scene.clear();for(let t of[e.a,e.b])t.chart.morphing?.(!1);e.settle()}k(),j?.disconnect(),_?.destroy();let t=T;T=void 0,t?.gone();for(let e of f.values())e.chart.destroy();d.remove()}},ce=e=>C===void 0&&e.name===S;function le(e){let t=()=>{E===e&&(E=void 0,T?.leave())};return{hover(t){ce(e)&&(E=e,T?.hover(t))},leave:t,dismiss(){ce(e)&&T?.dismiss()},shown(){},gone:t}}return Fn({targets:()=>C===void 0?M(S).port?.targets()??[]:[],hover(e,t){D=!0,C===void 0&&M(S).port?.hover(e,t)},unlink(){D=!1;for(let e of f.values())e.port?.unlink()},leave:()=>se.leave(),listen(e){if(w)return!1;T=e,E=void 0,D=!1;for(let t of f.values())t.port?.listen(e&&le(t));return!0},parts:Array.from(f.values()).flatMap(e=>e.port?[e.port]:[])},se)}function Cc(e,t,n){let r=l(e),i;return i=y({duration:950,timing:`transition`,ease:o,update:n=>{let a=Math.min(1,r+n);t(n===0?e:s(a)),a>=1&&n<1&&i?.finish()}},n),i}function wc(e){let t=e.now();return{clock:{now:()=>t??e.now(),onFrame:t=>e.onFrame(t)},release(){t=void 0}}}function Tc(e,t){e.classList.toggle(`ec-switch-inactive`,!t),e.toggleAttribute(`inert`,!t),t?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,`true`)}function Ec(e,t){e.style.setProperty(`opacity`,Dc(t))}let Dc=e=>String(Math.round(e*1e3)/1e3),Oc=`fill.fill-opacity.fill-rule.stroke.stroke-opacity.stroke-width.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.paint-order.marker-start.marker-mid.marker-end.color.visibility.font-family.font-size.font-style.font-weight.font-stretch.font-variant-caps.font-variant-ligatures.font-variant-numeric.font-feature-settings.font-kerning.letter-spacing.word-spacing.text-anchor.dominant-baseline.text-rendering.shape-rendering.writing-mode.direction`.split(`.`),kc={opacity:`1`,display:`inline`,"clip-path":`none`,mask:`none`,filter:`none`,"vector-effect":`none`};function Ac(e,t){let n=e.cloneNode(!0),r=[e,...e.querySelectorAll(`*`)],i=[n,...n.querySelectorAll(`*`)];return r.forEach((e,n)=>{let r=i[n];r.removeAttribute(`id`);let a=e.ownerDocument.defaultView?.getComputedStyle?.(e),o={};for(let n of Oc)o[n]=Vo(e,t,n)||void 0;for(let[e,t]of Object.entries(kc)){let n=a?.getPropertyValue(e).trim();n&&n!==t&&(o[e]=n)}At(r,o)}),n}function jc(e){try{let t=e.getBBox?.();if(t)return[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}]}catch{}return[{x:0,y:0}]}let Mc=(e,t)=>e.markup===t.markup&&e.corners.length===t.corners.length&&e.corners.every((e,n)=>Math.hypot(e.x-t.corners[n].x,e.y-t.corners[n].y)<=.5)&&[0,1,2,3].every(n=>Math.abs(e.place[n]-t.place[n])<=1e-4);function Nc(e,t){return n=>{let r=Vc(e.at.x,t.at.x,n),i=Vc(e.at.y,t.at.y,n),a=n>=xc;X(e.text,{x:r,y:i,visibility:a?`hidden`:void 0,...Pc(e,r,i)}),X(t.text,{x:r,y:i,visibility:a?void 0:`hidden`,...Pc(t,r,i)})}}let Pc=(e,t,n)=>e.scale===1?{}:{transform:Mt([e.scale,0,0,e.scale,t*(1-e.scale),n*(1-e.scale)])};function Fc(e,t){return n=>X(e.text,{opacity:t(n)})}let Ic=e=>1-Bc(e/xc),Lc=e=>Bc((e-xc)/.5),Rc=e=>1-Bc(e/.4),zc=Lc,Bc=e=>Math.min(1,Math.max(0,e)),Vc=(e,t,n)=>e*(1-n)+t*n;function Hc(e,t){return e.chart.paintOf?.(t.key)??{color:t.key,drawn:!0}}function Uc(e){return be({key:e.key,...e.series===void 0?{}:{series:e.series},x:e.center.x,y:e.center.y,r:0})}let Wc=(e,t)=>e.drawn&&e.end===void 0?(e.ring??0)*t:0;function Gc(e,t,n){return e.drawn&&e.end!==void 0?{at:t.end,r:e.end*n,ring:(e.ring??0)*n}:void 0}function Kc(e,t){X(e,{cx:t.at.x,cy:t.at.y,r:t.r,"stroke-width":t.ring})}let qc=e=>Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2]));function Jc(){let e;return{done:new Promise(t=>{e=t}),settle:e}}function Yc(e,t){if(typeof e!=`object`||!e)return!1;let n=e,r=n.element;return[`marks`,`labels`,`focus`,`leave`,`destroy`].every(e=>typeof n[e]==`function`)&&r?.nodeType===1&&t.contains(r)}function Xc(e){if(typeof e!=`object`||!e)throw TypeError(`chartSwitch needs options.`);let{views:t,initial:n,transition:r,announce:i}=e;if(typeof t!=`object`||!t)throw TypeError(`chartSwitch needs views: by name, a function that draws each view's chart in the container it's given.`);let a=Object.keys(t);if(a.length===0)throw TypeError(`chartSwitch needs at least one view.`);for(let e of a)if(typeof t[e]!=`function`)throw TypeError(`chartSwitch: views.${e} must be a function that draws the view's chart in the container it's given.`);if(typeof n!=`string`||!a.includes(n))throw TypeError(`chartSwitch: initial must be one of the views (${a.map(e=>JSON.stringify(e)).join(`, `)}), got ${typeof n==`string`?JSON.stringify(n):String(n)}.`);if(!yc(r))throw TypeError(`chartSwitch: transition must be a transition effect, such as morph().`);if(i!==void 0&&typeof i!=`boolean`)throw TypeError(`chartSwitch: announce must be true or false.`);return a}let Zc=[`presentation`,`analysis`,`off`],Qc={presentation:`Presentation`,analysis:`Analysis`,off:`Off`},$c={presentation:`Staged, unhurried motion. Best for walking someone through a change.`,analysis:`Quick, unstaged motion. Best for exploring.`,off:`No motion: charts jump straight to their end state.`,reduced:`Your device asks for reduced motion, so motion is off. Picking a mode here overrides it.`},el=0;function tl(e,t){let n=rl(e),r=t?.motion;il(r),al(t);let i={...Qc,...t.labels},a={...$c,...t.hints},{persist:o}=t,s=n.ownerDocument;Tn(s);let c=`ec-motion-${++el}`,l=s.createElement(`div`);l.className=`ec-motion-switch`,l.setAttribute(`role`,`group`),l.setAttribute(`aria-labelledby`,`${c}-label`),l.setAttribute(`aria-describedby`,`${c}-hint`);let u=l.appendChild(s.createElement(`span`));u.className=`ec-motion-label`,u.id=`${c}-label`,u.textContent=t.label??`Motion`;let d=l.appendChild(s.createElement(`span`));d.className=`ec-motion-modes`;let f=Zc.map(e=>{let t=d.appendChild(s.createElement(`button`));return t.type=`button`,t.dataset.mode=e,t.textContent=i[e],t.addEventListener(`click`,()=>r.chooseMode(e)),t}),p=l.appendChild(s.createElement(`span`));p.className=`ec-motion-hint`,p.id=`${c}-hint`,p.setAttribute(`aria-live`,`polite`);let m=()=>{let e=r.mode;for(let t of f)t.setAttribute(`aria-pressed`,String(t.dataset.mode===e));p.textContent=r.prefersReduced&&r.viewerChoice===void 0?a.reduced:a[e]};if(o!==void 0){let e=nl(s,e=>e.getItem(o));Zc.includes(e)&&r.chooseMode(e)}m(),n.appendChild(l);let h=r.subscribe(()=>{if(m(),o===void 0)return;let e=r.viewerChoice;nl(s,t=>e===void 0?t.removeItem(o):t.setItem(o,e))}),g=!1;return{element:l,destroy(){g||(g=!0,h(),l.remove())}}}function nl(e,t){try{let n=e.defaultView?.localStorage;return n?t(n):void 0}catch{return}}function rl(e){if(typeof e==`string`){let t=typeof document>`u`?null:document.querySelector(e);if(!t)throw TypeError(`motionSwitch: no element matches "${e}".`);return t}if(typeof e!=`object`||!e||typeof e.appendChild!=`function`)throw TypeError(`motionSwitch needs an element or a selector to build the switch in.`);return e}function il(e){if(typeof e!=`object`||!e||typeof e.chooseMode!=`function`||typeof e.subscribe!=`function`)throw TypeError("motionSwitch needs a Motion, such as the page-wide `motion` or one from createMotion().")}function al(e){let{label:t,labels:n,hints:r,persist:i}=e;if(t!==void 0&&typeof t!=`string`)throw TypeError(`motionSwitch: label must be a string, got ${typeof t}.`);for(let[e,t]of[[`labels`,n],[`hints`,r]])if(t!==void 0){for(let[n,r]of Object.entries(t))if(typeof r!=`string`)throw TypeError(`motionSwitch: ${e}.${n} must be a string, got ${typeof r}.`)}if(i!==void 0&&(typeof i!=`string`||i===``))throw TypeError(`motionSwitch: persist must be a localStorage key, got ${JSON.stringify(i)??String(i)}.`)}let ol={play:`Play`,pause:`Pause`};function sl(e,t,n={}){let r=cl(e);ll(t),ul(n);let i={...ol,...n.labels},a=r.ownerDocument;Tn(a);let o=a.createElement(`button`);o.type=`button`,o.className=`ec-play`,o.addEventListener(`click`,()=>t.playing?t.pause():t.play());let s=()=>{let e=t.playing?i.pause:i.play;o.textContent!==e&&(o.textContent=e)};s(),r.appendChild(o);let c=t.subscribe(s),l=!1;return{element:o,destroy(){l||(l=!0,c(),o.remove())}}}function cl(e){if(typeof e==`string`){let t=typeof document>`u`?null:document.querySelector(e);if(!t)throw TypeError(`playButton: no element matches "${e}".`);return t}if(typeof e!=`object`||!e||typeof e.appendChild!=`function`)throw TypeError(`playButton needs an element or a selector to build the button in.`);return e}function ll(e){if(typeof e!=`object`||!e||typeof e.play!=`function`||typeof e.pause!=`function`||typeof e.subscribe!=`function`)throw TypeError(`playButton needs a Playback, from playback().`)}function ul(e){let{labels:t}=e;if(t!==void 0){for(let[e,n]of Object.entries(t))if(typeof n!=`string`||n.trim()===``)throw TypeError(`playButton: labels.${e} must be a string with some text, got ${JSON.stringify(n)??String(n)}.`)}}let dl=Object.freeze({lift:0,spin:0,tilt:0});function fl(){return e=>({lift:0,spin:e.distance/e.radius,tilt:0})}function pl(e={}){let t=e.stride??42,n=e.lift??3.2,r=e.tilt??9;if(!(t>0)||!Number.isFinite(t))throw RangeError(`gaits.step: stride must be more than 0, got ${t}.`);if(!(n>=0)||!Number.isFinite(n))throw RangeError(`gaits.step: lift can't be negative, got ${n}.`);if(!Number.isFinite(r))throw RangeError(`gaits.step: tilt must be a finite number of degrees, got ${r}.`);let i=r*Math.PI/180;return Object.assign(e=>{let r=Math.max(1,Math.round(e.length/t)),a=Math.abs(Math.sin(Math.PI*(e.progress*r%1)));return{lift:a*n,spin:0,tilt:a*i*(1-.3*e.progress)}},{ease:s,pace:1.15})}function ml(){return()=>dl}let hl={roll:fl,step:pl,slide:ml},gl=[1,0,0,1,0,0],_l=[`auto`,`follow`,`level`],vl=[`center`,`on`];function yl(e,t={}){El(e,t);function n(n,r){let i=typeof e==`string`?r.icons.get(e):e;if(!i)throw RangeError(`travel: unknown icon "${String(e)}". Register it with registerIcon(icon), or pass the icon itself.`);let a=xl(n,t.along);if(!a||!(Cl(a)>=.5))return;let o=t.size===void 0?1:t.size===`fit`?.85*a.thickness/i.box.height:t.size/i.size;if(o>0)return bl(a,i,o,t)}function r(e,t){let r=n(e,t),i,a,o=0,s=()=>{r?(i&&a?.icon===r.icon&&a.size===r.size||(i?.remove(),i=t.layer.icon(r.icon,{size:r.size}),a={icon:r.icon,size:r.size}),i.place(r.transform(o))):(i?.remove(),i=a=void 0)};return t.onChange(e=>{r=n(e,t),s()}),{get trip(){return r},show(e){o=e,s()}}}return{kind:`geometry`,async run(e,t){if(t.signal.aborted)return;let n=r(e,t),i=n.trip;!i||i.span<=0?n.show(1):await t.tween({duration:i.duration,timing:`effect`,ease:i.gait.ease??c,update:e=>n.show(e)}).finished},end(e,t){r(e,t).show(1)},clear(){}}}function bl(e,t,n,r){let i=typeof r.gait==`function`?r.gait:hl[r.gait??t.gait??`slide`](),a=e.length,o=t.footprint[0]*n,s=t.footprint[1]*n,c=0,l=Sl(e).map(([e,t])=>{let n={from:e,to:t,span:Math.max(0,t-e-o-s),before:c};return c+=n.span,n}),u=Math.max(2,(o+s)/2),d=t.radius??t.box.height/2,{anchor:f}=t,p={x:f.x+n*(t.pivot.x-f.x),y:f.y+n*(t.pivot.y-f.y)},m=r.ride===`on`?e.thickness/2+(t.box.y+t.box.height-f.y)*n:0,h=r.orient??`auto`;return{icon:t,size:t.size*n,span:c,duration:Math.min(4e3,Math.max(260,c/360*1e3)*(i.pace??1)),gait:i,transform(r){let s=r*c,g=l.length-1;for(;g>0&&l[g].before>s;)g--;let _=l[g],v=_.from+o+Math.min(_.span,s-_.before),y=i({distance:s/n,length:c/n,progress:r,radius:d}),b=wl(e,v),x=Tl(e,Math.min(v,a),u,_),S=h===`auto`&&t.upright===!0&&Math.cos(x)<-1e-9,C=h===`level`?0:S?P(x-Math.PI):x;return q.multiply(q.translate(b.x,b.y),q.rotate(C),S?q.scale(-1,1):gl,q.translate(-f.x,-f.y-y.lift*n-m),q.rotate(y.spin-y.tilt,p))}}}function xl(e,t){return t===void 0?e:e.segments?e.segments.find(e=>e.series===t):e.series===t?e:void 0}function Sl(e){let{length:t}=e,n=[],r=0;for(let[i,a]of e.gaps??[])a>i&&a>r&&(i>r&&n.push([r*t,Math.min(1,i)*t]),r=Math.min(1,a));return n.push([r*t,t]),n}function Cl(e){return Sl(e).reduce((e,[t,n])=>e+(n-t),0)}function wl(e,t){let{length:n}=e;return t<=n?e.path(t/n):tt(e.end,e.angle(1),t-n)}function Tl(e,t,n,r){let{length:i}=e,a=Math.min(n,t-r.from,r.to-t);if(a>1e-6){let n=e.path((t-a)/i),r=e.path((t+a)/i);if(Math.hypot(r.x-n.x,r.y-n.y)>1e-9)return Math.atan2(r.y-n.y,r.x-n.x)}return e.angle(t/i)}function El(e,t){if((typeof e!=`string`||e===``)&&(typeof e!=`object`||!e||typeof e.name!=`string`))throw TypeError(`travel needs an icon or an icon's name, got ${e===null?`null`:typeof e}.`);let{along:n,gait:r,size:i,orient:a,ride:o}=t;if(n!==void 0&&typeof n!=`string`)throw RangeError(`travel: along must be a series name, got ${String(n)}.`);if(r!==void 0&&typeof r!=`function`&&!Object.prototype.hasOwnProperty.call(hl,r))throw RangeError(`travel: gait must be a gait or one of roll, step, slide, got ${String(r)}.`);if(i!==void 0&&i!==`fit`&&!(typeof i==`number`&&i>0&&Number.isFinite(i)))throw RangeError(`travel: size must be more than 0 px, or "fit", got ${String(i)}.`);if(a!==void 0&&!_l.includes(a))throw RangeError(`travel: orient must be auto, follow or level, got ${String(a)}.`);if(o!==void 0&&!vl.includes(o))throw RangeError(`travel: ride must be center or on, got ${String(o)}.`)}let Dl=.25;function Ol(e={}){jl(e);let t=e.width??8,n=e.opacity??.35,{color:r}=e,i=(e,i)=>{let a=t*kl(i);e.mark.set({halo:a>0?{width:a,opacity:n,...r===void 0?{}:{color:r}}:void 0})};return{kind:`geometry`,async run(e,t){t.signal.aborted||await t.tween({duration:900,timing:`effect`,ease:o,update:e=>i(t,e)}).finished},end(){},clear(){}}}function kl(e){return!(e>0)||e>=1?0:e<Dl?Al(e/Dl):1-Al((e-Dl)/.75)}function Al(e){if(!(e>0))return 0;if(e>=1)return 1;let t=0,n=1;for(let r=0;r<24;r++){let r=(t+n)/2;1.74*r*r*(1-r)+r*r*r<e?t=r:n=r}let r=(t+n)/2;return 3*r*r-2*r*r*r}function jl(e){let{width:t,opacity:n,color:r}=e;if(t!==void 0&&!(typeof t==`number`&&t>0&&Number.isFinite(t)))throw RangeError(`flash: width must be more than 0 px, got ${String(t)}.`);if(n!==void 0&&!(typeof n==`number`&&n>0&&n<=1))throw RangeError(`flash: opacity must be more than 0 and at most 1, got ${String(n)}.`);if(r!==void 0&&(typeof r!=`string`||r===``))throw RangeError(`flash: color must be a theme token or a CSS colour, got ${JSON.stringify(r)??String(r)}.`)}let Ml=[1,-.5,.25],Nl=Math.PI/12;function Pl(e={}){Ll(e);let t=e.swing??3;return{kind:`geometry`,async run(e,n){if(n.signal.aborted)return;let r=e,i=Fl(e,t),a=0,s=()=>{let e=i*Il(a);n.mark.set({transform:e===0?void 0:q.rotate(e,r.pivot)})};n.onChange(e=>{r=e,i=Fl(e,t),s()}),await n.tween({duration:450,timing:`effect`,ease:o,update:e=>{a=e,s()}}).finished},end(){},clear(){}}}function Fl(e,t){let{pivot:n}=e,r=0;for(let t of e.outline.sample(64))r=Math.max(r,Math.hypot(t.x-n.x,t.y-n.y));return r>=.5?Math.min(Nl,2*Math.asin(Math.min(1,t/(2*r)))):0}function Il(e){if(!(e>0)||e>=1)return 0;let t=e*Ml.length,n=Math.floor(t);return Ml[n]*Math.sin(Math.PI*(t-n))}function Ll(e){let{swing:t}=e;if(t!==void 0&&!(typeof t==`number`&&t>0&&t<=3))throw RangeError(`wiggle: swing must be more than 0 and at most 3 px, got ${String(t)}.`)}function Rl(e={}){zl(e);let t=e.times??2,n=e.width??12,{color:r}=e,i=(e,t)=>{let i=t>0&&t<1;e.mark.set({halo:i?{width:n*c(t),opacity:.4*(1-t),...r===void 0?{}:{color:r}}:void 0})};return{kind:`geometry`,async run(e,n){let r=0;for(let e=0;e<t;e++){if(n.signal.aborted)return;let e=n.motion.duration(600,`effect`);if(r+e>=5e3)return;r+=e,await n.tween({duration:600,timing:`effect`,ease:o,update:e=>i(n,e)}).finished}},end(){},clear(){}}}function zl(e){let{times:t,width:n,color:r}=e;if(t!==void 0&&!(Number.isInteger(t)&&t>=1&&t<=6))throw RangeError(`pulse: times must be a whole number from 1 to 6, got ${String(t)}.`);if(n!==void 0&&!(typeof n==`number`&&n>0&&Number.isFinite(n)))throw RangeError(`pulse: width must be more than 0 px, got ${String(n)}.`);if(r!==void 0&&(typeof r!=`string`||r===``))throw RangeError(`pulse: color must be a theme token or a CSS colour, got ${JSON.stringify(r)??String(r)}.`)}let Bl=.5;function Vl(e={}){Hl(e);let t=e.duration??500,n={stroke:e.color??`mark`,width:e.width??3,opacity:e.opacity??.5,linecap:`round`},r=(e,t)=>{let r=e,i=0,a,o=()=>{if(!(r.length>=Bl)){a?.remove(),a=void 0;return}let e=r.slice(0,i);a?a.update(e):a=t.layer.path(e,n)};return t.onChange(e=>{r=e,o()}),o(),e=>{i=e,o()}};return{kind:`geometry`,async run(e,n){if(n.signal.aborted)return;let i=r(e,n);e.length>=Bl?await n.tween({duration:t,timing:`effect`,ease:s,update:i}).finished:i(1)},end(e,t){r(e,t)(1)},clear(){}}}function Hl(e){let{color:t,width:n,opacity:r,duration:i}=e;if(t!==void 0&&(typeof t!=`string`||t===``))throw RangeError(`trace: color must be a theme token or a CSS colour, got ${JSON.stringify(t)??String(t)}.`);if(n!==void 0&&!(typeof n==`number`&&n>=0&&Number.isFinite(n)))throw RangeError(`trace: width must be 0 px or more, got ${String(n)}.`);if(r!==void 0&&!(typeof r==`number`&&r>=0&&r<=1))throw RangeError(`trace: opacity must be from 0 to 1, got ${String(r)}.`);if(i!==void 0&&!(typeof i==`number`&&i>=0&&Number.isFinite(i)))throw RangeError(`trace: duration must be 0 ms or more, got ${String(i)}.`)}function Ul(e={}){Gl(e);let t=e.duration??750,n=e.faint??.3;return{kind:`geometry`,async run(e,r){if(r.signal.aborted||!(Wl(e)>=.5))return;let i=e,a=0,c=!1,l=[],u=e=>{let{segments:t}=i,n=t??[i],o=a*Wl(i),c=0;n.forEach((n,i)=>{let a=n.length>0?Math.min(1,Math.max(0,(o-c)/n.length)):0;c+=n.length;let u=n.slice(0,s(a)),d={stroke:`mark`,width:n.thickness,linecap:`butt`,...t&&{part:n.key}},f=l[i];f?f.update(u,e?{part:void 0,...d}:void 0):l[i]=r.layer.path(u,d)});for(let e of l.splice(n.length))e.remove()};r.onChange(e=>{i=e,c||u(!0)}),r.mark.set({opacity:n}),u(!1),await r.tween({duration:t,timing:`effect`,ease:o,update:e=>{a=e,u(!1)}}).finished,c=!0;for(let e of l)e.remove();r.mark.set({opacity:void 0})},end(){},clear(){}}}let Wl=e=>(e.segments??[e]).reduce((e,t)=>e+t.length,0);function Gl(e){let{duration:t,faint:n}=e;if(t!==void 0&&!(typeof t==`number`&&t>=0&&Number.isFinite(t)))throw RangeError(`drawIn: duration must be 0 ms or more, got ${String(t)}.`);if(n!==void 0&&!(typeof n==`number`&&n>=0&&n<=1))throw RangeError(`drawIn: faint must be from 0 to 1, got ${String(n)}.`)}let Kl=.36;function ql(e,t){let n=e.labelBounds??[],r=[...n,...e.nearbyLabels??[],...t?.held??[]],i=e.angle(1);if($l(e.end,i,n)===void 0){let i=e.angle(.5)-Math.PI/2;if($l(e.center,i,n)!==void 0)return Jl(e.center,i,0,n,r,t)}return Jl(e.end,i,10,n,r,t)}function Jl(e,t,n,r,i,a){if(!a)return Zl(e,t,Math.max(n,$l(e,t,i)??-1/0));let{x:o,y:s,width:c,height:l}=a.box(Zl(e,t,0));return Zl(e,t,Yl(e,t,Math.max(n,$l(e,t,r)??-1/0),i,{x:o-e.x,y:s-e.y,width:c,height:l},new Set(a.held)))}function Yl(e,t,n,r,i,a){let o=Math.cos(t),s=Math.sin(t),c=Ql(o),l=t=>tu(e,o,s,{x:t.x-i.x-i.width,y:t.y-i.y-i.height,width:t.width+i.width,height:t.height+i.height}),u=r.map(t=>{let n=Xl(t,6),r=tu(e,o,s,n);if(!r&&a.has(t))return l(t);let i=l(n);if(!r||!i)return i;let u=c?Math.max(r[1],((s>0?n.y+n.height:n.y)-e.y)/s):r[1];return[i[0],Math.max(u,l(t)?.[1]??-1/0)]}),d=n;for(let e=!0;e;){e=!1;for(let t of u)t&&d>t[0]+1e-6&&d<t[1]-1e-6&&(d=t[1],e=!0)}return d}let Xl=({x:e,y:t,width:n,height:r},i)=>({x:e-i,y:t-i,width:n+2*i,height:r+2*i});function Zl(e,t,n){let r=Math.cos(t),i=Math.sin(t),a=tt(e,t,n),o=12.5*(i<0?Kl*(1+i):Kl+.44000000000000006*i),s=Ql(r)?`middle`:r>0?`start`:`end`;return{at:{x:a.x,y:a.y+o},anchor:s,toward:t}}function Ql(e){return Math.abs(e)<=Math.SQRT1_2+1e-9}function $l(e,t,n){let r=Math.cos(t),i=Math.sin(t),a=Ql(r),o;for(let t of n){let n=Xl(t,6),s=eu(e,r,i,n);s!==void 0&&a&&(s=Math.max(s,((i>0?n.y+n.height:n.y)-e.y)/i)),s!==void 0&&(o=Math.max(o??s,s))}return o}function eu(e,t,n,r){return tu(e,t,n,r)?.[1]}function tu(e,t,n,r){let i=0,a=1/0;for(let[o,s,c,l]of[[e.x,t,r.x,r.x+r.width],[e.y,n,r.y,r.y+r.height]]){if(Math.abs(s)<1e-12){if(o<c||o>l)return;continue}let e=(c-o)/s,t=(l-o)/s;i=Math.max(i,Math.min(e,t)),a=Math.min(a,Math.max(e,t))}return a>=i?[i,a]:void 0}function nu(e,t,n,r,i){let a=e,o=i(e,t)??``,s=t,c=0,l,{texts:u}=n,d=()=>{if(o===``){l?.remove(),l=void 0,u?.hold(void 0);return}let{at:e,anchor:t,toward:i}=ql(a,u&&{held:u.held(),box:e=>u.box(o,e)});u?.hold(u.box(o,{at:e,anchor:t}));let s={at:tt(e,i-Math.PI/2,-8*(1-c)),anchor:t,color:r,opacity:c};l?l.update(s,o):l=n.layer.text(o,s)};return n.onChange((e,t)=>{a=e,s=t??s,o=i(a,s)??``,d()}),d(),e=>{c=e,d()}}let ru=e=>{let{samples:t}=e;return t[t.length-1]?.value??NaN},iu,au=e=>(iu??(iu=new Intl.NumberFormat(void 0,{signDisplay:`always`,maximumFractionDigits:2})),iu.format(e));function ou(e={}){su(e);let t=e.value??ru,n=e.format??au,r=e.color??`text`,i=e=>{if(!e.previous)return;let r=t(e),i=t(e.previous),a=r-i;if(!(!Number.isFinite(a)||Math.abs(a)<=1e-9*Math.max(Math.abs(r),Math.abs(i))))return n(a)};return{kind:`data`,run:async(e,t,n)=>{if(n.signal.aborted)return;let a=i(t);if(a===void 0||a===``)return;let o=nu(e,t,n,r,()=>a);await n.tween({duration:400,timing:`effect`,update:o}).finished},end:(e,t,n)=>{let a=i(t);a!==void 0&&a!==``&&nu(e,t,n,r,()=>a)(1)},clear(){}}}function su(e){let{value:t,format:n,color:r}=e;if(t!==void 0&&typeof t!=`function`)throw TypeError(`delta: value must be a function that reads the mark's value from its data, got ${typeof t}.`);if(n!==void 0&&typeof n!=`function`)throw TypeError(`delta: format must be a function that words the change, got ${typeof n}.`);if(r!==void 0&&(typeof r!=`string`||r===``))throw RangeError(`delta: color must be a theme token or a CSS colour, got ${JSON.stringify(r)??String(r)}.`)}function cu(e,t={}){if(typeof e!=`function`)throw TypeError(`label needs a function that returns the text from the mark's data, got ${typeof e}.`);let{color:n=`text`}=t;if(typeof n!=`string`||n===``)throw RangeError(`label: color must be a theme token or a CSS colour, got ${JSON.stringify(n)??String(n)}.`);let r=(t,n)=>{let r=e(n,t);return r==null?void 0:String(r)};return{kind:`data`,run:async(e,t,i)=>{if(i.signal.aborted)return;let a=nu(e,t,i,n,r);await i.tween({duration:400,timing:`effect`,update:a}).finished},end:(e,t,i)=>nu(e,t,i,n,r)(1),clear(){}}}let lu=[`below`,`above`];function uu(e){yu(e);let{compareTo:t}=e,n=e.when??`below`,r=e.color??`negative`,i=(e,i,a)=>{let o=[],s=i,c=e=>{let i=e.length>=.5?gu(s.samples,du(t,s),n):[],c={stroke:r,width:e.thickness,linecap:`butt`};i.forEach(([t,n],r)=>{let i=e.slice(t,n),s=o[r];s?s.update(i,c):o.push(a.layer.path(i,c))});for(let e of o.splice(i.length))e.remove()};a.onChange((e,t)=>{s=t??s,c(e)}),c(e)};return{kind:`data`,...typeof t==`string`?{needs:Object.freeze({related:Object.freeze([t])})}:{},run:async(e,t,n)=>{n.signal.aborted||i(e,t,n)},end:(e,t,n)=>i(e,t,n),clear(){}}}function du(e,t){if(typeof e==`number`)return{place:e=>e.t,valueAt:()=>e,bends:[]};let n=t.related(e);if(!n)return;let r=t.samples.every(e=>mu(e.at)!==void 0)&&n.samples.every(e=>mu(e.at)!==void 0)?e=>mu(e.at):e=>e.t,i=n.samples.map(e=>({u:r(e),value:e.value})).filter(e=>Number.isFinite(e.u)).sort((e,t)=>e.u-t.u),a=fu(n.samples,r);return{place:r,valueAt:e=>pu(a,e)?void 0:hu(i,e),bends:i.map(e=>e.u)}}function fu(e,t){let n=[];e.forEach((r,i)=>{let a=e[i-1];if(r.gapBefore!==!0||!a)return;let o=t(a),s=t(r);Number.isFinite(o)&&Number.isFinite(s)&&o!==s&&n.push([Math.min(o,s),Math.max(o,s)])}),n.sort((e,t)=>e[0]-t[0]);let r=[];for(let e of n){let t=r[r.length-1];t&&e[0]<t[1]?t[1]=Math.max(t[1],e[1]):r.push(e)}return r}function pu(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i][0]<t?n=i+1:r=i}let i=e[n-1];return i!==void 0&&t<i[1]}function mu(e){let t=typeof e==`number`?e:e instanceof Date?e.getTime():void 0;return t!==void 0&&Number.isFinite(t)?t:void 0}function hu(e,t){let n=e[0],r=e[e.length-1];if(!n||!r||t<n.u||t>r.u)return;let i=0,a=e.length-1;for(;i<a;){let n=i+a>>1;e[n].u<t?i=n+1:a=n}let o=e[i];if(i===0||o.u===t)return o.value;let s=e[i-1];return s.value+(t-s.u)/(o.u-s.u)*(o.value-s.value)}function gu(e,t,n){if(!t)return[];let r=n===`below`?1:-1,i=(e,n,i,a=!0)=>{let o=t.valueAt(n);if(o===void 0||!Number.isFinite(o)||!Number.isFinite(i)||!Number.isFinite(e))return{t:e,u:n,past:void 0,joined:a};let s=r*(o-i);return{t:e,u:n,past:Math.abs(s)<=1e-9*Math.max(Math.abs(o),Math.abs(i))?0:s,joined:a}},a=[];e.forEach((n,r)=>{let o=t.place(n);a.push(i(n.t,o,n.value,n.gapBefore!==!0));let s=e[r+1];if(!s||s.gapBefore===!0)return;let c=t.place(s);if(o===c||!Number.isFinite(o)||!Number.isFinite(c))return;let l=[],{bends:u}=t;for(let e=vu(u,Math.min(o,c));e<u.length&&u[e]<Math.max(o,c);e++)l.push((u[e]-o)/(c-o));c<o&&l.reverse();for(let e of l)a.push(i(n.t+e*(s.t-n.t),o+e*(c-o),n.value+e*(s.value-n.value)))});let o=[],s=(e,t)=>{let n=_u(e),r=_u(t);if(!(r>n))return;let i=o[o.length-1];i&&i[1]>=n?i[1]=Math.max(i[1],r):o.push([n,r])};for(let e=1;e<a.length;e++){let n=a[e-1],r=a[e];n.past!==void 0&&r.past!==void 0&&r.joined&&r.t>n.t&&(n.u===r.u||t.valueAt((n.u+r.u)/2)!==void 0)&&(n.past>0&&r.past>0?s(n.t,r.t):n.past>0?s(n.t,n.t+(r.t-n.t)*(n.past/(n.past-r.past))):r.past>0&&s(n.t+(r.t-n.t)*(n.past/(n.past-r.past)),r.t))}return o}let _u=e=>Math.min(1,Math.max(0,e));function vu(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i]<=t?n=i+1:r=i}return n}function yu(e){let{compareTo:t,when:n,color:r}=e??{};if(!(typeof t==`string`?t!==``:typeof t==`number`&&Number.isFinite(t)))throw RangeError(`threshold: compareTo must be a finite number or a series name, got ${bu(t)}.`);if(n!==void 0&&!lu.includes(n))throw RangeError(`threshold: when must be "below" or "above", got ${bu(n)}.`);if(r!==void 0&&(typeof r!=`string`||r===``))throw RangeError(`threshold: color must be a theme token or a CSS colour, got ${bu(r)}.`)}let bu=e=>typeof e==`string`?JSON.stringify(e):String(e);function xu(e={}){Su(e);let t={stroke:e.color??`text`,width:e.width??2},n=(e,n)=>{let r=n.layer.path(e.outline.d,t);n.onChange(e=>r.update(e.outline.d))};return{kind:`geometry`,async run(e,t){t.signal.aborted||n(e,t)},end:n,clear(){}}}function Su(e){let{color:t,width:n}=e;if(t!==void 0&&(typeof t!=`string`||t===``))throw RangeError(`outline: color must be a theme token or a CSS colour, got ${JSON.stringify(t)??String(t)}.`);if(n!==void 0&&!(typeof n==`number`&&n>0&&Number.isFinite(n)))throw RangeError(`outline: width must be more than 0 px, got ${String(n)}.`)}function Cu(e){if(!(typeof e==`number`&&e>=0&&Number.isFinite(e)))throw RangeError(`wait: duration must be 0 ms or more, got ${String(e)}.`);return{kind:`geometry`,async run(t,n){n.signal.aborted||await n.tween({duration:e,timing:`effect`,update(){}}).finished},end(){},clear(){}}}let wu=[`unroll`,`drop`],Tu=.01;function Eu(e={}){sd(e);let t=e?.points??160,n=e?.align??`unroll`;return{kind:`transition`,async run(e,r,i){if(i.signal.aborted)return;let a=Du(e,r,i.layer,t,n),c=od(i.start);if(c>=1){a(1);return}let u=l(c),d;d=i.tween({duration:950,timing:`transition`,ease:o,update:e=>{let t=Math.min(1,u+e);a(e===0?c:s(t)),t>=1&&e<1&&d?.finish()}}),await d.finished},end(e,r,i){Du(e,r,i.layer,t,n)(1)},clear(){}}}function Du(e,t,n,r,i){let a=e.outline.closed;if(a!==t.outline.closed)return td(e,t,n);let o=a?void 0:Nu(e,t,r);if(o)return Au(e,t,n,o.stops,o.kinds);let s=a?zu(e,t,r):void 0,c=s?.from??e.outline.sample(r),l=s?.to??t.outline.sample(r);if(!a)return e.gaps?.length||t.gaps?.length?ku(e,t,n,c,l):Ou(e,t,n,c,l);let[u,d]=!s&&i===`drop`?ad(e,t,r):[0,0],f=Hu(e,t,c,l,[u,d],r/4),p;return r=>{let i=r<=0?e.outline.d:r>=1?t.outline.d:nd(c,l,u,d,r,!0)+f.map(e=>Gu(e,r)).join(``);p?p.update(i):p=n.path(i,{fill:`mark`})}}function Ou(e,t,n,r,i){let a;return o=>{let s=o<=0?e.outline.d:o>=1?t.outline.d:nd(r,i,0,0,o,!1),c=o<=0?e.thickness:o>=1?t.thickness:id(e.thickness,t.thickness,o);a?a.update(s,{width:c}):a=n.path(s,{stroke:`mark`,width:c})}}function ku(e,t,n,r,i){let a=r.length,o=r.map((e,t)=>({t:t/(a-1),from:e,to:i[t]}));for(let n of[...e.gaps??[],...t.gaps??[]])for(let r of n)r>0&&r<1&&o.every(e=>Math.abs(e.t-r)>1e-9)&&o.push({t:r,from:e.path(r),to:t.path(r)});return o.sort((e,t)=>e.t-t.t),Au(e,t,n,o,o.slice(1).map((n,r)=>{let i=(o[r].t+n.t)/2;return+!!ju(e,i)+(ju(t,i)?2:0)}))}function Au(e,t,n,r,i){let a=[[],[],[]];for(let e=0;e<i.length;e++){let t=i[e];if(t===3)continue;let n=a[t][a[t].length-1];n&&n[1]===e?n[1]=e+1:a[t].push([e,e+1])}let o=[0,1,2].filter(e=>a[e].length>0).sort((e,t)=>a[e][0][0]-a[t][0][0]),s=[];return i=>{let c=i<=0?e.thickness:i>=1?t.thickness:id(e.thickness,t.thickness,i),l=[void 0,i,1-i],u=i<=0||i>=1?[[i<=0?e.outline.d:t.outline.d,void 0]]:o.map(e=>[a[e].map(e=>Mu(r,e,i)).join(``),l[e]]);u.forEach(([e,t],r)=>{s[r]?s[r].update(e,{width:c,opacity:t}):s[r]=n.path(e,{stroke:`mark`,width:c,...t===void 0?{}:{opacity:t}})});for(let e of s.splice(u.length))e.remove()}}let ju=(e,t)=>(e.gaps??[]).some(([e,n])=>e<t&&t<n);function Mu(e,[t,n],r){let i=``;for(let a=t;a<=n;a++)i+=`${a===t?`M`:`L`}${rd(e[a].from,e[a].to,r)}`;return i}function Nu(e,t,n){let r=Fu(e),i=r&&Fu(t);if(r&&i&&r.way===i.way)return Pu(r,i,n)}function Pu(e,t,n){let r=[...Array.from({length:n},(e,t)=>[t/(n-1),0]),...Lu(e).map(e=>[e,1]),...Lu(t).map(e=>[e,2])].sort((e,t)=>e[0]-t[0]),i=Tu/Math.max(Math.abs(e.span),Math.abs(t.span)),a=[];for(let[e,t]of r){var o,s;let n=a[a.length-1];(!n||e-n[0]>i||t>0&&n[t]!==void 0)&&a.push(n=[e]),t===1&&((o=n)[1]??(o[1]=e)),t===2&&((s=n)[2]??(s[2]=e))}let c=a.length-1;if(c<1)return;let l=e=>a.map((t,n)=>n===0?0:n===c?1:t[e]??t[0]),[u,d]=[l(1),l(2)],[f,p]=[Ru(e,u),Ru(t,d)],m=a.map(([e],t)=>({t:e,from:f[t],to:p[t]})),[h,g]=[Vu(e.gaps),Vu(t.gaps)];return{stops:m,kinds:m.slice(1).map((e,t)=>+!!h((u[t]+u[t+1])/2)+(g((d[t]+d[t+1])/2)?2:0))}}function Fu(e){let t=Ce(je(e.outline.d)),n=[],r=[],i=0,a=0,o=r=>{if(!(r>a))return n.push(e.path(a)),!0;let o=t[i++];if(!o)return!1;n.push(o.start);for(let e of o.segments){if(e.kind!==`line`)return!1;n.push(e.to)}return!0};for(let[t,i]of e.gaps??[]){if(!o(t))return;r.push(n.length-1),a=i}return!o(1)||i<t.length||n.length<2?void 0:Iu(n,r)}function Iu(e,t=[]){let n=e[0].x,r=e[e.length-1].x-n,i=Math.sign(r);for(let t=1;t<e.length;t++)if(!((e[t].x-e[t-1].x)*i>0))return;let a=e.map(e=>(e.x-n)/r);return{points:e,shares:a,gaps:t.map(e=>[a[e],a[e+1]]),span:r,way:i}}function Lu(e){let{points:t,shares:n,gaps:r}=e;if(t.length<=1e3)return n;let i=e=>Math.min(249,Math.floor(n[e]*250)),a=r.flat();for(let e=0,r=1;r<=t.length;r++){if(r<t.length&&i(r)===i(e))continue;let[o,s]=[e,e];for(let n=e;n<r;n++)t[n].y<t[o].y&&(o=n),t[n].y>t[s].y&&(s=n);a.push(n[e],n[o],n[s],n[r-1]),e=r}return Array.from(new Set(a))}function Ru(e,t){let{points:n,shares:r}=e,i=0;return t.map(e=>{for(;i+2<n.length&&r[i+1]<=e;)i++;let t=r[i+1]-r[i];return Ku(n[i],n[i+1],t>0?Math.min(1,Math.max(0,(e-r[i])/t)):0)})}function zu(e,t,n){let r=Bu(e.outline),i=r&&Bu(t.outline);if(!r||!i||Math.abs(r.left-i.left)>Tu||Math.abs(r.right-i.right)>Tu)return;let a=Pu(r.upper,i.upper,n),o=Pu(r.lower,i.lower,n);if(!a||!o)return;let s=[...a.stops,...o.stops];return{from:s.map(e=>e.from),to:s.map(e=>e.to)}}function Bu(e){let t=Qu(e),n=[];for(let e of t[$u(t)]??[]){if(e.kind!==`line`)return;n.push(e.to)}ed(n)<0&&n.reverse();let r=n.reduce((e,t)=>Math.min(e,t.x),1/0),i=n.reduce((e,t)=>Math.max(e,t.x),-1/0);if(!(i-r>2*Tu))return;let a=e=>e.x-r<=Tu,o=e=>i-e.x<=Tu,s=n.findIndex((e,t)=>a(e)&&!a(n[(t+1)%n.length])),c=[...n.slice(s),...n.slice(0,s+1)],l=c.findIndex(o),u=l;for(;o(c[u+1]);)u++;let d=c.findIndex((e,t)=>t>u&&a(e));if(c.slice(d).some(e=>!a(e)))return;let f=Iu(c.slice(0,l+1)),p=Iu(c.slice(u,d+1));return f&&p&&f.points.length>2&&p.points.length>2?{upper:f,lower:p,left:r,right:i}:void 0}function Vu(e){let t=0;return n=>{for(;t<e.length&&e[t][1]<=n;)t++;return t<e.length&&e[t][0]<n}}function Hu(e,t,n,r,[i,a],o){let s=Zu(e.outline,o),c=Zu(t.outline,o),l=Math.min(s.length,c.length),u=s.slice(0,l).map((e,t)=>({from:e.points,to:c[t].points})),d=s.length>c.length,[f,p,m,h,g,_,v]=d?[s,c,t,n,r,i,a]:[c,s,e,r,n,a,i],y=h.length,b=h.map((e,t)=>[h[(t+_)%y],g[(t+v)%y]]),x=f.slice(0,l).map((e,t)=>e.points.map((e,n)=>[e,p[t].points[n]])),S=[g,...p.map(e=>e.points)];for(let n of f.slice(l)){let{end:r,point:i}=Uu(n,qu(n,(d?e:t).bounds,m,S),b,x),a=Array(o).fill(i);u.push(d?{from:n.points,to:a,end:r}:{from:a,to:n.points,end:r,opens:!0})}return u}function Uu(e,t,n,r){let i=.5;for(;i>1/16&&!Wu(e,Ku(e.center,t,i),i,n,r);)i/=2;return{end:i,point:Ku(e.center,t,i)}}function Wu(e,t,n,r,i){for(let a=1;a<8;a++){let o=n*a/8,s=e=>Ku(e[0],e[1],o),c=[r.map(s),...i.map(e=>e.map(s))];if(e.points.some(e=>Yu(Ku(e,t,a/8),c)===0))return!1}return!0}function Gu({from:e,to:t,end:n,opens:r},i){if(n===void 0)return nd(e,t,0,0,i,!0);let a=r?(i-(1-n))/n:i/n;return(r?a<=0:a>=1)?``:nd(e,t,0,0,a,!0)}let Ku=(e,t,n)=>({x:id(e.x,t.x,n),y:id(e.y,t.y,n)});function qu(e,t,n,r){let i=Xu(e.center,t,n.bounds);if(Ju(i,r)>=e.size/4)return i;let{x:a,y:o,width:s,height:c}=n.bounds,l=n.center,u=Ju(l,r);for(let e=0;e<9;e++)for(let t=0;t<9;t++){let n={x:a+s*(e+.5)/9,y:o+c*(t+.5)/9},i=Ju(n,r);i>u&&([l,u]=[n,i])}return l}function Ju(e,t){if(Yu(e,t)===0)return 0;let n=1/0;for(let r of t)r.forEach((t,i)=>{let a=r[(i+1)%r.length],o=a.x-t.x,s=a.y-t.y,c=o===0&&s===0?0:Math.max(0,Math.min(1,((e.x-t.x)*o+(e.y-t.y)*s)/(o*o+s*s)));n=Math.min(n,Math.hypot(e.x-t.x-c*o,e.y-t.y-c*s))});return n}function Yu(e,t){let n=0;for(let r of t)r.forEach((t,i)=>{let a=r[(i+1)%r.length],o=(a.x-t.x)*(e.y-t.y)-(e.x-t.x)*(a.y-t.y);t.y<=e.y&&a.y>e.y&&o>0?n++:t.y>e.y&&a.y<=e.y&&o<0&&n--});return n}function Xu(e,t,n){let r=(e,t,n)=>n>0?(e-t)/n:.5;return{x:n.x+r(e.x,t.x,t.width)*n.width,y:n.y+r(e.y,t.y,t.height)*n.height}}function Zu(e,t){let n=Qu(e);if(n.length<2)return[];let r=$u(n);return n.filter((e,t)=>t!==r).map(e=>{let n=ne([e]).sample(4*t),r=n.filter((e,t)=>t%4==0),i=I(e.flatMap(F));return{points:[r[0],...r.slice(1).reverse()],area:Math.abs(ed(n)),center:{x:i.x+i.width/2,y:i.y+i.height/2},size:Math.max(i.width,i.height)/2}}).sort((e,t)=>t.area-e.area)}let Qu=e=>Ce(je(e.d)).map(e=>e.segments).filter(e=>e.length>0);function $u(e){let t=e.map(e=>e.reduce((e,t)=>e+t.length,0)),n=0;return t.forEach((e,r)=>{e>t[n]+Math.max(.01,t[n]/1e3)&&(n=r)}),n}function ed(e){let t=0;return e.forEach((n,r)=>{let i=e[(r+1)%e.length];t+=n.x*i.y-i.x*n.y}),t/2}function td(e,t,n){let r=(e,t)=>({...e.outline.closed?{fill:`mark`}:{stroke:`mark`,width:e.thickness},...t===void 0?{}:{opacity:t}}),i,a;return o=>{o>=1?(i?.remove(),i=void 0,a?a.update(t.outline.d,{opacity:void 0}):a=n.path(t.outline.d,r(t))):a?(i?.update(e.outline.d,{opacity:1-o}),a.update(t.outline.d,{opacity:o})):e.outline.closed?(i=n.path(e.outline.d,r(e,1-o)),a=n.path(t.outline.d,r(t,o))):(a=n.path(t.outline.d,r(t,o)),i=n.path(e.outline.d,r(e,1-o)))}}function nd(e,t,n,r,i,a){let o=e.length,s=``;for(let a=0;a<o;a++)s+=`${a===0?`M`:`L`}${rd(e[(a+n)%o],t[(a+r)%o],i)}`;return a?`${s}Z`:s}let rd=(e,t,n)=>`${L(id(e.x,t.x,n))},${L(id(e.y,t.y,n))}`,id=(e,t,n)=>e*(1-n)+t*n;function ad(e,t,n){let r=n/4,i=lo(e);return i===lo(t)?[0,0]:i?[0,r]:[r,0]}function od(e){return typeof e==`number`&&e>0?Math.min(1,e):0}function sd(e){let{points:t,align:n}=e??{};if(t!==void 0&&!(Number.isInteger(t)&&t>=4&&t%4==0))throw RangeError(`morph: points must be a whole multiple of 4, got ${String(t)}.`);if(n!==void 0&&!wu.includes(n))throw RangeError(`morph: align must be "unroll" or "drop", got ${typeof n==`string`?JSON.stringify(n):String(n)}.`)}function cd(...e){let t=md(`sequence`,e);return pd(t,async(e,n)=>{for(let r of t){if(n.signal.aborted)return;await e(r)}})}function ld(...e){let t=md(`parallel`,e);return pd(t,async e=>{await Promise.all(t.map(e))})}function ud(e,t){if(typeof e!=`string`&&typeof e!=`function`)throw TypeError(`only needs a key, a series name or a predicate, got ${dt(e)}.`);let[n]=md(`only`,[t]),r=typeof e==`string`?t=>t.key===e||t.series===e:e;if(n.kind===`data`){let e=n;return{kind:`data`,...e.needs?{needs:e.needs}:{},run:(t,n,i)=>r(t)?e.run(t,n,i):Promise.resolve(),end:(t,n,i)=>{r(t)&&e.end(t,n,i)},clear:t=>e.clear(t)}}let i=n;return{kind:`geometry`,run:(e,t)=>r(e)?i.run(e,t):Promise.resolve(),end(e,t){r(e)&&i.end(e,t)},clear:e=>i.clear(e)}}function dd(e,t={}){let[n]=md(`stagger`,[e]),r=t.delay??50;if(!(typeof r==`number`&&r>=0&&Number.isFinite(r)))throw RangeError(`stagger: delay must be 0 ms or more, got ${String(r)}.`);let i=async(e,t,n)=>{if(n.signal.aborted)return;let{index:i,count:a}=n.batch,o=a>1?Math.min(r,500/(a-1)):0,s=i>0?i*o:0;if(!(s>0))return{mark:e,data:t};let c=fd(e,t,n);return await n.tween({duration:s,timing:`stagger`,update:()=>{}}).finished,n.signal.aborted?void 0:c()};if(n.kind===`data`){let e=n;return{kind:`data`,...e.needs?{needs:e.needs}:{},run:async(t,n,r)=>{let a=await i(t,n,r);a&&await e.run(a.mark,a.data,r)},end:(t,n,r)=>e.end(t,n,r),clear:t=>e.clear(t)}}let a=n;return{kind:`geometry`,async run(e,t){let n=await i(e,void 0,t);n&&await a.run(n.mark,t)},end:(e,t)=>a.end(e,t),clear:e=>a.clear(e)}}function fd(e,t,n){let r={mark:e,data:t};return n.onChange((e,t)=>{r={mark:e,data:t??r.data}}),()=>r}function pd(e,t){let n=(e,t,n)=>{let r=fd(e,t,n);return e=>{let{mark:t,data:i}=r();return e.kind===`data`?e.run(t,i,n):e.run(t,n)}},r=(t,n,r)=>{for(let i of e)i.kind===`data`?i.end(t,n,r):i.end(t,r)},i=t=>{let n;for(let r of e)try{r.clear(t)}catch(e){n??(n={error:e})}if(n)throw n.error};if(e.some(e=>e.kind===`data`)){let a=[...new Set(e.flatMap(e=>e.kind===`data`?e.needs?.related??[]:[]))];return{kind:`data`,...a.length>0?{needs:{related:a}}:{},run:(e,r,i)=>t(n(e,r,i),i),end:(e,t,n)=>r(e,t,n),clear:i}}return{kind:`geometry`,run:(e,r)=>t(n(e,void 0,r),r),end:(e,t)=>r(e,void 0,t),clear:i}}function md(e,t){return t.forEach((t,n)=>{if(!ut(t))throw TypeError(`${e}: part ${n+1} needs to be a mark effect (kind "geometry" or "data"), got ${dt(t)}.`)}),[...t]}let hd=()=>{};function gd(e){vd(`defineEffect`,e);let t={kind:`geometry`,run:e.run,end:e.end,clear:e.clear??hd};return Object.freeze(t)}function _d(e){vd(`defineDataEffect`,e);let t=yd(e.needs),n={kind:`data`,...t?{needs:t}:{},run:e.run,end:e.end,clear:e.clear??hd};return Object.freeze(n)}function vd(e,t){if(typeof t!=`object`||!t)throw TypeError(`${e} needs a spec object { run, end }, got ${t===null?`null`:typeof t}.`);let{run:n,end:r,clear:i}=t;if(typeof n!=`function`)throw TypeError(`${e}: run must be a function that animates the mark, got ${typeof n}.`);if(typeof r!=`function`)throw TypeError(`${e}: end must be a function that draws the final state, got ${typeof r}. Every effect needs one: reduced motion shows only end states.`);if(i!==void 0&&typeof i!=`function`)throw TypeError(`${e}: clear must be a function if it's given, got ${typeof i}.`)}function yd(e){if(e===void 0)return;let t=typeof e==`object`&&e?e.related:void 0;if(!(typeof e==`object`&&e&&(t===void 0||Array.isArray(t)&&t.every(e=>typeof e==`string`&&e!==``))))throw TypeError(`defineDataEffect: needs must be { related: [series names] }, got ${JSON.stringify(e)??String(e)}.`);return t===void 0?void 0:Object.freeze({related:Object.freeze([...t])})}let bd=[`roll`,`step`,`slide`],xd=[`butt`,`round`,`square`],Sd=[`miter`,`round`,`bevel`],Cd=[`nonzero`,`evenodd`],wd=/^\s*[Mm][MmLlHhVvCcSsQqTtAaZz0-9eE.,+\-\s]*$/;function Td(e){let t=e?.name;if(typeof t!=`string`||t===``)throw TypeError(`defineIcon needs a non-empty string name, got ${JSON.stringify(t)}.`);let n=(e,n)=>{throw RangeError(`defineIcon: "${t}" ${e} ${n}.`)},r=(e,t)=>typeof t==`number`&&Number.isFinite(t)?t:n(e,`must be a finite number, got ${String(t)}`),i=(e,t)=>r(e,t)>0?t:n(e,`must be more than 0, got ${String(t)}`),a=(e,t)=>t&&typeof t==`object`?Dd({x:r(`${e}.x`,t.x),y:r(`${e}.y`,t.y)}):n(e,`must be a point { x, y }`);Array.isArray(e.shapes)&&e.shapes.length!==0||n(`shapes`,`must be a non-empty array`);let o=e.shapes.map((e,t)=>Ed(e,`shapes[${t}]`,n,r)),s=e.box;s&&typeof s==`object`||n(`box`,`must be a rectangle { x, y, width, height }`);let c=Dd({x:r(`box.x`,s.x),y:r(`box.y`,s.y),width:i(`box.width`,s.width),height:i(`box.height`,s.height)}),l=a(`anchor`,e.anchor),u=e.pivot===void 0?l:a(`pivot`,e.pivot),d=e.footprint??[Math.max(0,l.x-c.x),Math.max(0,c.x+c.width-l.x)];Array.isArray(d)&&d.length===2||n(`footprint`,`must be [behind, ahead]`),d.forEach((e,t)=>{r(`footprint[${t}]`,e)<0&&n(`footprint[${t}]`,`can't be negative, got ${e}`)});let f=e.size===void 0?c.width:i(`size`,e.size),p=e.radius===void 0?c.height/2:i(`radius`,e.radius);return e.gait!==void 0&&!bd.includes(e.gait)&&n(`gait`,`must be roll, step or slide, got ${String(e.gait)}`),e.upright!==void 0&&typeof e.upright!=`boolean`&&n(`upright`,`must be true or false, got ${String(e.upright)}`),Dd({name:t,shapes:Dd(o),box:c,size:f,anchor:l,pivot:u,footprint:Dd([d[0],d[1]]),...e.gait===void 0?{}:{gait:e.gait},radius:p,...e.upright===void 0?{}:{upright:e.upright}})}function Ed(e,t,n,r){e&&typeof e==`object`||n(t,`must be a shape { d, fill?, stroke?, … }`),typeof e.d==`string`&&wd.test(e.d)||n(`${t}.d`,`must be path data starting with a move`),e.clip===void 0||typeof e.clip==`string`&&wd.test(e.clip)||n(`${t}.clip`,`must be path data starting with a move`);for(let r of[`fill`,`stroke`]){let i=e[r];i!==void 0&&(typeof i!=`string`||i===``)&&n(`${t}.${r}`,`must be a colour, got ${String(i)}`)}e.width!==void 0&&r(`${t}.width`,e.width)<0&&n(`${t}.width`,`can't be negative, got ${e.width}`),e.linecap!==void 0&&!xd.includes(e.linecap)&&n(`${t}.linecap`,`must be butt, round or square, got ${String(e.linecap)}`),e.linejoin!==void 0&&!Sd.includes(e.linejoin)&&n(`${t}.linejoin`,`must be miter, round or bevel, got ${String(e.linejoin)}`),e.fillRule!==void 0&&!Cd.includes(e.fillRule)&&n(`${t}.fillRule`,`must be nonzero or evenodd, got ${String(e.fillRule)}`);for(let i of[`opacity`,`fillOpacity`,`strokeOpacity`]){let a=e[i]===void 0?1:r(`${t}.${i}`,e[i]);(a<0||a>1)&&n(`${t}.${i}`,`must be from 0 to 1, got ${a}`)}let i={d:e.d};for(let t of[`fill`,`stroke`,`width`,`linecap`,`linejoin`,`clip`,`fillRule`,`opacity`,`fillOpacity`,`strokeOpacity`])e[t]!==void 0&&(i[t]=e[t]);return Dd(i)}let Dd=e=>Object.freeze(e),Od=new Set([`svg`,`g`,`a`]),kd=new Set([`path`,`circle`,`rect`,`ellipse`,`line`,`polyline`,`polygon`]),Ad=/<![^<>]*>|<(\/?)([A-Za-z][\w:.-]*)((?:\s+[^\s=/<>]+(?:\s*=\s*(?:"[^"<]*"|'[^'<]*'|[^\s"'<>]+))?)*)\s*(\/?)>/g,jd=/([^\s=/<>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>]+)))?/g,Md=/^(?:#[0-9a-fA-F]{3,8}|[a-zA-Z][a-zA-Z0-9-]*|(?:rgba?|hsla?)\([\d\s.,%+\-/]*\))$/;function Nd(e,t){if(typeof e!=`string`)throw TypeError(`iconFromSvg needs SVG markup as a string.`);let n=typeof t?.name==`string`?`"${t.name}"`:`an icon`,r=e=>{throw RangeError(`iconFromSvg: ${n} ${e}.`)},i,a=1,o=[],s=[],c;for(let n of Pd(e).matchAll(Ad)){let[,e,l,u=``,d]=n;if(l===void 0)continue;let f=l.toLowerCase();if(e){let e=Hd(s,f);e>=0&&(s.length=e);continue}let p=Fd(u),m=!i&&f===`svg`;m&&(i=Id(p)??r(`needs a viewBox, or a width and height in px, on its <svg>`),t.size!==void 0&&(typeof t.size==`number`&&t.size>0&&Number.isFinite(t.size)||r(`size must be more than 0, got ${String(t.size)}`),a=t.size/i.width),c={fill:`#000000`,stroke:`none`,width:1,linecap:void 0,linejoin:void 0,fillRule:`nonzero`,opacity:1,fillOpacity:1,strokeOpacity:1,transform:q.scale(a)});let h=s.length>0?s[s.length-1].state:m?c:void 0,g=h&&!zd(p)?Bd(h,p):void 0;if(g&&kd.has(f)){let e=Vd(f,p,g);e&&o.push(e)}d||s.push({tag:f,state:Od.has(f)?g:void 0})}i||r(`needs an <svg> element`),o.length===0&&r(`has nothing to draw: no path, circle, rect, ellipse, line, polyline or polygon with a fill or stroke`);let l={x:i.x*a,y:i.y*a,width:i.width*a,height:i.height*a},u=e=>e&&typeof e==`object`?{x:e.x*a,y:e.y*a}:e;return Td({...t,shapes:o,box:l,anchor:u(t.anchor),...t.pivot?{pivot:u(t.pivot)}:{},...Array.isArray(t.footprint)?{footprint:[t.footprint[0]*a,t.footprint[1]*a]}:{},...typeof t.radius==`number`?{radius:t.radius*a}:{}})}function Pd(e){let t=[[`<!--`,`-->`],[`<![CDATA[`,`]]>`],[`<?`,`?>`]],n=t.map(([t])=>e.indexOf(t)),r=``,i=0;for(;;){let a=-1;if(n.forEach((e,t)=>{e>=0&&(a<0||e<n[a])&&(a=t)}),a<0)return r+e.slice(i);let o=n[a],s=t[a][1];r+=e.slice(i,o);let c=e.indexOf(s,o+t[a][0].length);if(c<0)return r;i=c+s.length,n.forEach((r,a)=>{r>=0&&r<i&&(n[a]=e.indexOf(t[a][0],i))})}}function Fd(e){let t=new Map;for(let[,n,r,i,a]of e.matchAll(jd))n!==void 0&&t.set(n,r??i??a??``);for(let e of(t.get(`style`)??``).split(`;`)){let n=e.indexOf(`:`);n>0&&t.set(e.slice(0,n).trim(),e.slice(n+1).replace(/!important/i,``).trim())}return t}function Id(e){let t=(e.get(`viewBox`)??``).trim().split(/[\s,]+/).map(Number);if(t.length===4&&t.every(Number.isFinite)&&t[2]>0&&t[3]>0)return{x:t[0],y:t[1],width:t[2],height:t[3]};let n=Ld(e.get(`width`)),r=Ld(e.get(`height`));return n!==void 0&&r!==void 0?{x:0,y:0,width:n,height:r}:void 0}function Ld(e){let t=/^\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)\s*(?:px\s*)?$/i.exec(e??``),n=t?Number(t[1]):NaN;return n>0&&Number.isFinite(n)?n:void 0}function Rd(e){let t=/^\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(%?)\s*$/i.exec(e??``);return t?Math.min(1,Math.max(0,Number(t[1])/(t[2]?100:1))):void 0}function zd(e){return e.get(`display`)?.trim()===`none`||e.get(`visibility`)?.trim()===`hidden`}function Bd(e,t){let n=(e,n)=>{let r=t.get(e)?.trim();if(r===void 0||!Md.test(r))return n;let i=r.toLowerCase();return i===`inherit`?n:i===`currentcolor`?`text`:i===`none`?i:r},r=Number.parseFloat(t.get(`stroke-width`)??``),i=t.get(`stroke-linecap`)?.trim(),a=t.get(`stroke-linejoin`)?.trim(),o=t.get(`fill-rule`)?.trim().toLowerCase(),s=t.get(`transform`);return{fill:n(`fill`,e.fill),stroke:n(`stroke`,e.stroke),width:r>=0?r:e.width,linecap:i===`butt`||i===`round`||i===`square`?i:e.linecap,linejoin:a===`miter`||a===`round`||a===`bevel`?a:e.linejoin,fillRule:o===`nonzero`||o===`evenodd`?o:e.fillRule,opacity:e.opacity*(Rd(t.get(`opacity`))??1),fillOpacity:Rd(t.get(`fill-opacity`))??e.fillOpacity,strokeOpacity:Rd(t.get(`stroke-opacity`))??e.strokeOpacity,transform:s?q.multiply(e.transform,et(s)):e.transform}}function Vd(e,t,n){let r=Ud(n.fillOpacity),i=Ud(n.strokeOpacity),a=n.fill===`none`||!(r>0)?void 0:n.fill,o=n.stroke===`none`||!(n.width>0)||!(i>0)?void 0:n.stroke,s=Ud(n.opacity);if(a===void 0&&o===void 0||!(s>0))return;let c=Pe(e,e=>t.get(e));if(!c.some(e=>e.op!==`M`))return;let l=n.transform;return{d:ze(Le(c,l)),...a===void 0?{}:{fill:a,...n.fillRule===`evenodd`?{fillRule:n.fillRule}:{},...r<1?{fillOpacity:r}:{}},...o===void 0?{}:{stroke:o,width:Ud(n.width*Math.sqrt(Math.abs(l[0]*l[3]-l[1]*l[2]))),...n.linecap?{linecap:n.linecap}:{},...n.linejoin?{linejoin:n.linejoin}:{},...i<1?{strokeOpacity:i}:{}},...s<1?{opacity:s}:{}}}function Hd(e,t){for(let n=e.length-1;n>=0;n--)if(e[n].tag===t)return n;return-1}let Ud=e=>Math.round(e*1e3)/1e3,Wd=Object.freeze({dot:Td({name:`dot`,shapes:[{d:`M4,0A4,4 0 0 1 -4,0A4,4 0 0 1 4,0Z`,fill:`surface`,stroke:`text`,width:1.5}],box:{x:-5,y:-5,width:10,height:10},anchor:{x:0,y:0}}),arrow:Td({name:`arrow`,shapes:[{d:`M-7,-1.5L1,-1.5L1,-5L7,0L1,5L1,1.5L-7,1.5Z`,fill:`text`,stroke:`surface`,width:1.5,linejoin:`round`}],box:{x:-8,y:-6,width:16,height:12},anchor:{x:0,y:0}}),chevron:Td({name:`chevron`,shapes:[{d:`M-2.5,-5L2.5,0L-2.5,5`,stroke:`surface`,width:4.5,linecap:`round`,linejoin:`round`},{d:`M-2.5,-5L2.5,0L-2.5,5`,stroke:`text`,width:2,linecap:`round`,linejoin:`round`}],box:{x:-5,y:-7.5,width:10,height:15},anchor:{x:0,y:0}})}),Gd=st({kind:`preset`,entries:{flash:()=>Ol(),wiggle:()=>Pl(),pulse:()=>Rl()},hint:`Register custom presets with registerPreset(name, factory).`}),Kd=st({kind:`icon`,entries:Wd,hint:`Register icons with registerIcon(icon) or registerIcons(icons).`});function qd(e,t){if(typeof t!=`function`)throw TypeError(`registerPreset("${e}") needs a function that returns an effect.`);Gd.register(e,t)}function Jd(e){if(typeof e!=`object`||!e||typeof e.name!=`string`)throw TypeError(`registerIcon needs an icon with a name.`);Kd.register(e.name,e)}function Yd(e){for(let t of e)Jd(t)}function Xd(e){if(typeof e!=`object`||!e)throw TypeError(`configure needs an options object.`);if(`nonce`in e){if(e.nonce!==void 0&&(typeof e.nonce!=`string`||e.nonce===``))throw TypeError(`configure: nonce must be a non-empty string.`);wn.nonce=e.nonce}if(`injectStyles`in e){if(e.injectStyles!==void 0&&typeof e.injectStyles!=`boolean`)throw TypeError(`configure: injectStyles must be true or false.`);wn.injectStyles=e.injectStyles}}let Zd={presets:Gd,icons:Kd,motion:v};function Qd(e,t){return Wr(e,t,Zd)}function $d(e,t){return xi(e,t,Zd)}function ef(e,t){return Va(e,t,Zd)}function tf(e,t){return Sc(e,typeof t==`object`&&t&&t.transition===void 0?{...t,transition:Eu()}:t,Zd)}function nf(e,t){return Ts(e,t,Zd)}function rf(e,t){return $s(e,t,Zd)}function af(e,t,n){let r=n!==void 0||t!==void 0&&(typeof t!=`object`||!t||`chooseMode`in t),i=(r?n:t)??{},a=r&&t!==void 0?t:i.motion??v;return tl(e,{...i,motion:a})}return e.VERSION=`0.13.0`,e.animated=C,e.barChart=Qd,e.chartSwitch=tf,e.colorAssignment=En,e.configure=Xd,e.createClock=n,e.createMotion=p,e.defaultClock=a,e.defaultScaling=u,e.defineDataEffect=_d,e.defineEffect=gd,e.defineIcon=Td,e.delta=ou,e.describe=Ge,e.donutChart=$d,e.drawIn=Ul,e.easeInOutCubic=s,e.easeOutCubic=c,e.expressive=nf,e.flash=Ol,e.fromVegaView=rf,e.gaits=hl,e.hostView=Ys,e.iconFromSvg=Nd,e.icons=Wd,e.interpolateNumber=b,e.interpolatePoint=x,e.interpolateRecord=S,e.label=cu,e.lineChart=ef,e.linear=o,e.link=Ln,e.manualClock=r,e.matrix=q,e.mediaReducedMotion=h,e.morph=Eu,e.motion=v,e.motionSwitch=af,e.offset=tt,e.only=ud,e.outline=xu,e.parallel=ld,e.playButton=sl,e.playback=w,e.pulse=Rl,e.registerIcon=Jd,e.registerIcons=Yd,e.registerPreset=qd,e.samplesAlong=rt,e.scaleDuration=m,e.sequence=cd,e.stagger=dd,e.threshold=uu,e.trace=Vl,e.travel=yl,e.tween=y,e.wait=Cu,e.wiggle=Pl,e})({});
96
+ `)?{}:{series:i.map(e=>Qn(s.seriesLabels,e))},changed:o.map(a),added:c.map(a),removed:l.map(a),count:E.length});if(typeof r!=`function`){ae.say(u);return}let d=e=>e.key;try{let e=r({text:u,changed:o.map(d),added:c.map(d),removed:l.map(d)});e!=null&&ae.say(String(e))}catch(e){t(e)}}function kt(e){R=e;let t=ve(e),n={entering:[],exiting:[],changed:[]},r=new Set(e.rows.map(e=>e.key)),i=e.rows.length>0?e.series:[],a={changed:[],added:[],removed:[]},o=E,s=new Map(o.map(e=>[e,e.row])),c=new Map(e.rows.map(e=>[e.key,e])),l=A.filter(e=>!i.includes(e.series)),u=[];for(let e of o){let t=!r.has(e.key),n=c.get(e.key)?.missing;t&&(D.delete(e.key),e.leaving=!0,O.set(e.key,e),a.removed.push(e));for(let r of K(e))(t||!i.includes(r.series)||n?.has(r.series))&&u.push(r)}for(let e of l)j.delete(e.series);for(let e of u)M.delete(e.key);for(let e of[...l,...u])N.start(e);n.exiting.push(...l,...u);let d=new Set,f=a.removed.length>0;E=e.rows.map(e=>{let t=D.get(e.key);return t?(d.add(t),t.row.x!==e.x&&(f=!0),e.values.some((e,n)=>t.row.values[n]?.series!==e.series||t.row.values[n]?.value!==e.value)&&a.changed.push(t)):(t=O.get(e.key)??Ce(e,!0),O.delete(e.key),t.leaving=!1,t.x.set(e.x),t.values.set(e.levels),D.set(e.key,t),a.added.push(t),f=!0),t.row=e,t}),E.forEach((e,t)=>{d.has(e)?e.presence.value===1&&(e.anchor=void 0):e.anchor=Ka(E,t,d)});for(let e of a.removed)e.anchor??(e.anchor=Ka(o,o.indexOf(e),d));let p=A;A=i.map(e=>{let r=j.get(e),i=t.lines.get(e);if(r){let t=[...d].some(t=>Wa(s.get(t),e)!==Wa(t.row,e));(f||t)&&n.changed.push({record:r,from:r.shown.geometry})}else r=Nt(e,`line`)??we(e,i,!0),j.set(e,r),n.entering.push(r);return r.target=i,r});for(let e of E){let r=d.has(e)?s.get(e):void 0,a=i.filter(t=>!e.row.missing.has(t)).map(i=>{let a=ba(i,e.key),o=t.points.get(a),s=M.get(a);return s?r&&Wa(r,i)!==Wa(e.row,i)&&n.changed.push({record:s,from:s.shown.geometry}):(s=Nt(a,`point`)??Te(e,o),s.row=e,M.set(a,s),n.entering.push(s)),s.target=o,s}),o=new Set(a);e.points=[...a,...e.points.filter(e=>!o.has(e)&&Ee(e))]}for(let e of E)Tt(e);return ht(),mr(w,o.filter(e=>!e.leaving).map(e=>e.column),E.map(e=>e.column),J.active),mr(v,p.map(e=>e.group),A.map(e=>e.group),()=>null),fe=a,oe=!0,Ae(),n}function Nt(e,t){return N.get(e)?.kind===t?N.recall(e):void 0}function Pt(e,t){oe=!0;let{frame:n}=e;for(let[t,n,r]of[[G,e.yTicks,!0],[ue,e.xTicks,!1]]){let e=new Set(n.map(e=>e.value));for(let n of e)t.has(n)||Lt(t,n,0,r);for(let n of t.values())n.wanted=e.has(n.value)}for(let t of e.xTicks)ue.get(t.value).text=t.label.text;let r=De(),i=[...O.values()],a=Q(ce,n.scale,Dr)||[...G.values()].some(e=>Q(e.opacity,+!!e.wanted,$))||E.some(e=>Q(e.values,e.row.levels,Dr))||A.some(e=>Q(e.presence,1,$))||r.some(e=>Q(e.presence,0,$))||Q(W,Ai(e.curve),$),o=Q(le,n.box,Dr)||[...ue.values()].some(e=>Q(e.opacity,+!!e.wanted,$))||E.some(e=>Q(e.x,e.row.x,$)||e.anchor!==void 0&&Q(e.presence,1,$))||i.some(e=>e.anchor!==void 0&&Q(e.presence,0,$)),s,l;!t&&c.staged?(s={duration:500},l={duration:500,delay:a?500:0}):t||(s=l={duration:(a&&o?2:1)*500});let u=[],d=(e,t,n,r)=>{Q(e,t,n)&&(r?u.push(e.to(t,r)):e.set(t))};d(ce,n.scale,Dr,s),d(W,Ai(e.curve),$,s),d(le,n.box,Dr,l);for(let e of G.values())d(e.opacity,+!!e.wanted,$,s);for(let e of ue.values())d(e.opacity,+!!e.wanted,$,l);for(let e of E)d(e.values,e.row.levels,Dr,s),d(e.x,e.row.x,$,l),d(e.presence,1,$,e.anchor?l:void 0);for(let e of i)d(e.presence,0,$,e.anchor?l:void 0);for(let e of A)d(e.presence,1,$,s);for(let e of r)d(e.presence,0,$,s);return u}function Lt(e,t,n,r,i=``){let a={value:t,line:r?Y(`line`,{class:t===0?`ec-baseline`:`ec-gridline`},m):void 0,label:Y(`text`,{class:`ec-tick`},h),text:i,opacity:C(n,b,{clock:d,motion:c,onChange:se}),wanted:!0};e.set(t,a);for(let t of[...e.values()].sort((e,t)=>e.value-t.value))t.line&&m.appendChild(t.line),h.appendChild(t.label)}function Rt(e,t){return R=e,de=Object.fromEntries(e.series.map(t=>[t,Math.max(de[t]??0,e.decimals[t]??0)])),me.run(Pt(e,t))}let zt=Pr(p,c);function Bt(){if(I)return;let e=he(s),t=new Map(e.rows.map(e=>[e.key,e]));for(let e of E)e.row=t.get(e.key)??e.row;let n=ve(e);for(let e of A)e.target=n.lines.get(e.series)??e.target;for(let e of M.values())e.target=n.points.get(e.key)??e.target;Rt(e,!0)}let Vt=()=>{T.clear(),Bt()},Ht=Nr(p,d,Vt),Ut=jr(i,d,F,e=>{F=e,s.width===void 0&&Bt()}),Wt=Mr(f,Vt);xr(p,s),St(),ie.render(z);{let e=ve(R);for(let e of R.yTicks)Lt(G,e.value,1,!0);for(let e of R.xTicks)Lt(ue,e.value,1,!1,e.label.text);E=R.rows.map(t=>{let n=Ce(t,!1);return D.set(t.key,n),n.points=R.series.filter(e=>!t.missing.has(e)).map(r=>{let i=Te(n,e.points.get(ba(r,t.key)));return M.set(i.key,i),i}),Tt(n),n}),A=R.rows.length>0?R.series.map(t=>we(t,e.lines.get(t),!1)):[];for(let e of A)j.set(e.series,e);ht(),o===`point`&&w.setAttribute(`display`,`none`),Me()}let Gt=()=>[...A,...E.flatMap(K)];J.sync(),U.enter(Gt().map(Ye));function Kt(e){let t=D.get(e);return o===`x`?(t??M.get(e)?.row)?.key:(M.get(e)??(t&&K(t)[0]))?.key}return Fn(J.link,{element:p,async update(e){if(I)return;if(e.motion!==void 0&&e.motion!==s.motion)throw TypeError("lineChart: `motion` can't be changed by update() yet.");let t={...s,...e};wr(t,`lineChart`);let n=oo(t);so(t);let i=`on`in e?Cr(l,s.on,t.on,r.presets):l,a=he(t,i),o=wt(t,a),d=n===`x`?io(t,a):void 0,f=n===`point`?ao(t,a):void 0;`colors`in e&&(u=Dn(t.colors));let m=s,h=R.series;s=t,B=d,V=f,xr(p,s),ie.render(o);let g=ae!==void 0;s.announce&&!ae?ae=Ot(p):!s.announce&&ae&&(ae.destroy(),ae=void 0),vt(n),J.syncDim(),me.supersede();let _=i!==l;l=i;let v=Er({runner:U,events:P,hover:J,leaving:N,input:Ye,onScreen:Xe,data:`data`in e,..._?{swap:e=>{let t=new Set(e.entering);U.swap(i,Gt().filter(e=>!t.has(e)).map(Ye))}}:{}},()=>kt(a),()=>{g&&Dt(m,h)});St();let y=Rt(a,c.mode===`off`);await me.wait(y,v)},reveal(e){if(I)return;if(e instanceof Date&&Number.isNaN(e.getTime()))throw RangeError(`lineChart: reveal(x) needs a valid Date, got an invalid Date.`);let t=e instanceof Date?e.getTime():e;if(typeof t!=`number`||Number.isNaN(t))throw RangeError(`lineChart: reveal(x) needs a number, got ${typeof t==`string`?JSON.stringify(t):String(t)}.`);let n=ye(R);ee=t,ye(R)!==n&&(je(),J.dropGone(),J.sync())},on:P.on,marks:()=>[...A.map(e=>e.shown.geometry),...E.filter(Se).flatMap(e=>K(e).map(e=>e.shown.geometry))],focus(e){let t=I?void 0:Kt(e);t!==void 0&&J.focus(t)},leave(){I||J.leave()},labels:()=>A.flatMap(e=>dr(e.key,`value`,e.drawnLabel,e.label)),paintOf(e){let t=j.get(e);if(t)return{color:t.series,drawn:!0,...t.end.getAttribute(`visibility`)===`hidden`?{}:{end:da,ring:2}};let n=M.get(e);return n&&(n.group.classList.contains(`ec-alone`)?{color:n.series,drawn:!0,ring:2}:{color:n.series,drawn:!1})},standsFor(e){return D.has(e)?[...R.series.map(t=>ba(t,e)),e]:[e]},moveTabStop(e){let t=I?void 0:Kt(e);return t!==void 0&&J.moveTabStop(t)},destroy(){if(!I){I=!0,me.destroy(),J.destroy(),U.destroy(),ne.destroy(),re.destroy(),ie.destroy(),ae?.destroy(),zt(),Ht(),Ut(),Wt();for(let e of[...E,...O.values()])for(let t of[e.x,e.values,e.presence])t.stop();for(let e of[...A,...De()])e.presence.stop();for(let e of N.values())e.leave?.resolve();ce.stop(),le.stop(),W.stop();for(let e of[...G.values(),...ue.values()])e.opacity.stop();P.clear(),D.clear(),O.clear(),j.clear(),M.clear(),N.clear(),E=[],A=[],p.remove()}}})}function Ha(e){return{key:e.key,datum:e.datum,x:e.x,values:e.levels,missing:e.missing}}function Ua(e){return e.flatMap(e=>e.value===void 0?[]:[{series:e.series,value:e.value}])}function Wa(e,t){return e.values.find(e=>e.series===t)?.value}function Ga(e){return e.reduce((e,t)=>e+(t.value??0),0)}function Ka(e,t,n){for(let r=t-1;r>=0;r--)if(n.has(e[r]))return e[r];for(let r=t+1;r<e.length;r++)if(n.has(e[r]))return e[r]}function qa(e,t){return e.key===t.key&&!Or(e,t)&&e.start.x===t.start.x&&e.start.y===t.start.y&&e.end.x===t.end.x&&e.end.y===t.end.y}function Ja(e,t){return e.datum!==t.datum||e.samples.length!==t.samples.length?!1:e.samples.every((e,n)=>{let r=t.samples[n];return e.t===r.t&&e.value===r.value&&Ya(e.at,r.at)&&e.gapBefore===r.gapBefore})}function Ya(e,t){return e===t||e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime()}function Xa(e,t){return(e.x-t.x)**2+(e.y-t.y)**2}function Za({geometry:e,data:{samples:t}},n,r,i,a){let o=t.findIndex(e=>Ya(e.at,n));if(o<0||!(e.length>0))return;let s=t[o].t,c=a/e.length,l;for(let n of[-1,1]){let a=r;for(let r=o;;r+=n){let o=t[r+n];if(!o||(n>0?o:t[r]).gapBefore)break;let u=n>0?Math.min(o.t,s+c):Math.max(o.t,s-c),d=e.path(u);if(l=Math.min(l??1/0,Qa(i,a,d)),u!==o.t)break;a=d}}return l}function Qa(e,t,n){let r=n.x-t.x,i=n.y-t.y,a=r*r+i*i,o=a>0?Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*i)/a)):0;return Math.hypot(e.x-t.x-o*r,e.y-t.y-o*i)}function $a(e,t){return Ua(e).map(e=>({series:e.series,label:Qn(t.seriesLabels,e.series),value:e.value}))}function eo(e,t){let n=tr(t),r=so(t);return e.map(e=>{let i=Qn(t.seriesLabels,e.series);return e.value===void 0?`${i} ${r}`:`${n(e.value)} ${i}`})}function to(e,t){return e.missing.size===0?Lr(e.label,$a(e.values,t),tr(t),{total:!1}):{title:e.label,lines:[eo(e.values,t).join(` · `)]}}function no(e,t,n){return Lr(e.label,$a(e.values,n).filter(e=>e.series===t),tr(n),{total:!1})}function ro(e,n,r){if(!e.markLabel)return r.text;try{let t=e.markLabel(n,r);if(t!=null&&String(t).trim()!==``)return String(t)}catch(e){t(e)}return r.text}function io(e,t){let n=tr(e);return new Map(t.rows.map(t=>{let r=`${t.label}: ${eo(t.values,e).join(`, `)}`;return[t.key,ro(e,t.datum,{key:t.key,category:t.label,values:$a(t.values,e),total:Ga(t.values),format:n,text:r})]}))}function ao(e,t){let n=tr(e);return new Map(t.rows.flatMap(t=>$a(t.values,e).map(r=>{let i=ba(r.series,t.key),a=`${t.label}: ${n(r.value)} ${r.label}`;return[i,ro(e,t.datum,{key:i,category:t.label,values:[r],total:r.value,format:n,text:a})]})))}function oo(e){let{hover:t=`x`}=e;if(t!==`x`&&t!==`point`)throw TypeError(`lineChart: hover must be "x" or "point", got ${typeof t==`string`?JSON.stringify(t):String(t)}.`);return t}function so(e){let{missing:t=`missing`}=e;if(typeof t!=`string`||t.trim()===``)throw TypeError(`lineChart: missing must be a word for a missing value, such as "no data", got ${typeof t==`string`?JSON.stringify(t):String(t)}.`);return t}let co=.5;function lo(e){let t=uo(e.start,e.pivot);return t>co&&Math.abs(uo(e.center,e.pivot)-t)<=co&&Math.abs(uo(e.end,e.pivot)-t)<=co}let uo=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y),fo=.5,po=[`left`,`right`,`top`,`bottom`];function mo(e){return typeof e==`string`&&po.includes(e)}function ho(e,t){if(t!==`auto`)return e.map(()=>t);if(e.length===0)return[];let n=yo(e,e=>e.x,e=>e.x+e.width,`left`,`right`),r=yo(e,e=>e.y+e.height,e=>e.y,`bottom`,`top`);if(n&&r)return bo(e)?n:r;let i=n??r;if(!i)throw RangeError(`expressive: baseline "auto" found no edge that every mark grows from. Pass baseline: "left", "right", "top" or "bottom".`);return i}function go(e,t,n){let r=vo(t.map(e=>e.box)),i=xo(r,n),a=t.map((e,t)=>({index:t,...i(e.box)})).sort((e,t)=>e.near-t.near||e.far-t.far||e.index-t.index),o=0,s=1/0,c=a.map(({index:e,near:n,far:r})=>{o>0&&r>n&&(s=Math.min(s,n-o));let i=Math.max(0,r-o);return o=Math.max(o,r),{series:t[e].series,size:i}}),l=t[a[a.length-1].index],u=t.length===1?t[0].series:void 0;return{geometry:me({key:e,...u===void 0?{}:{series:u},...r,baseline:n,radius:l.radius,gap:Number.isFinite(s)?Math.max(0,So(s)):0,...c.every(e=>e.series!==void 0)?{segments:c.map(e=>({series:e.series,size:So(e.size)}))}:{}}),order:a.map(e=>e.index)}}function _o(e,t){let n=t[0]===`left`||t[0]===`right`,r=e=>n?e.y:e.x,i=e=>n?e.x:e.y;return e.map((e,t)=>t).sort((t,n)=>r(e[t])-r(e[n])||i(e[t])-i(e[n])||t-n)}function vo(e){let t=Math.min(...e.map(e=>e.x)),n=Math.min(...e.map(e=>e.y));return{x:t,y:n,width:So(Math.max(...e.map(e=>e.x+e.width))-t),height:So(Math.max(...e.map(e=>e.y+e.height))-n)}}function yo(e,t,n,r,i){let a=e[0];if(!a)return[];for(let o of[t(a),n(a)]){let a=[];for(let s of e)if(Math.abs(t(s)-o)<fo)a.push(r);else if(Math.abs(n(s)-o)<fo)a.push(i);else break;if(a.length===e.length)return a}}function bo(e){let t=e=>Math.max(...e)-Math.min(...e),n=t(e.map(e=>e.y+e.height/2)),r=t(e.map(e=>e.x+e.width/2));return n===r?e[0].width>=e[0].height:n>r}function xo(e,t){switch(t){case`left`:return t=>({near:t.x-e.x,far:t.x+t.width-e.x});case`right`:return t=>({near:e.x+e.width-(t.x+t.width),far:e.x+e.width-t.x});case`top`:return t=>({near:t.y-e.y,far:t.y+t.height-e.y});case`bottom`:return t=>({near:e.y+e.height-(t.y+t.height),far:e.y+e.height-t.y})}}function So(e){return Math.round(e*1e3)/1e3}function Co(){let e=new Map,t=t=>{let n=e.get(t);return n||(n={attributes:new Map,styles:new Map,classes:new Set,before:{}},e.set(t,n)),n},n=e=>e.style,r=(e,t,n)=>{n===null?e.removeAttribute(t):e.getAttribute(t)!==n&&e.setAttribute(t,n)},i=(e,t)=>{let i=t.before.style;t.styles.size>0||!i||(t.before.style=void 0,n(e)?.cssText===i.css&&r(e,`style`,i.text))},a=(e,t)=>{let n=t.before.class;if(t.classes.size>0||n===void 0)return;t.before.class=void 0;let i=e=>[...new Set((e??``).split(/\s+/).filter(Boolean))].sort().join(` `);i(e.getAttribute(`class`))===i(n)&&r(e,`class`,n)};function o(e,n,i){let a=e.getAttribute(n),o=t(e).attributes,s=o.get(n);s?(a!==s.written&&(s.original=a),s.written=i):o.set(n,{original:a,written:i}),r(e,n,i)}function s(t,n,i){if(i!==null){o(t,n,i);return}let a=e.get(t)?.attributes,s=a?.get(n);a&&s&&(t.getAttribute(n)===s.written&&r(t,n,s.original),a.delete(n))}function c(e,r,a){let o=n(e);if(!o)return;let s=t(e),c=s.styles.get(r);if(a===void 0){if(!c)return;c.value===``?o.removeProperty(r):o.setProperty(r,c.value,c.priority),s.styles.delete(r),i(e,s)}else c||(s.styles.size===0&&(s.before.style={text:e.getAttribute(`style`),css:o.cssText}),s.styles.set(r,{value:o.getPropertyValue(r),priority:o.getPropertyPriority(r)})),o.getPropertyValue(r)!==a&&o.setProperty(r,a)}function l(n,r,i){let o=n.classList;if(i){if(o.contains(r))return;let e=t(n);e.classes.size===0&&(e.before.class=n.getAttribute(`class`)),e.classes.add(r),o.add(r);return}let s=e.get(n);s?.classes.delete(r)&&(o.remove(r),a(n,s))}function u(t){let n=e.get(t);if(n){for(let e of[...n.styles.keys()])c(t,e,void 0);for(let e of[...n.classes])l(t,e,!1);for(let e of[...n.attributes.keys()])s(t,e,null);e.delete(t)}}return{attribute:s,remove:(e,t)=>o(e,t,null),style:c,styled:(t,n)=>e.get(t)?.styles.has(n)??!1,toggleClass:l,restore:u,restoreAll(){for(let t of[...e.keys()])u(t)},elements:()=>[...e.keys()]}}function wo(){let e=new Map;return t=>(e.has(t)||e.set(t,Fo(t)),e.get(t))}function To(e,t,n,r=Fo){let i=r(e),a=i&&r(t);return i&&a?q.multiply($e(i),a):q.multiply($e(Io(e,n)),Io(t,n))}function Eo(e,t){if(Do(t))return e;let n=e=>q.apply(t,e),r=e=>ze(Le(je(e),t)),i=jo(t),{outline:a}=e;return{key:e.key,...e.series===void 0?{}:{series:e.series},start:n(e.start),end:n(e.end),length:e.length*i,path:t=>n(e.path(t)),angle:n=>{let r=e.angle(n),i=Math.cos(r),a=Math.sin(r);return Math.atan2(t[1]*i+t[3]*a,t[0]*i+t[2]*a)},slice:(t,n)=>r(e.slice(t,n)),...e.gaps===void 0?{}:{gaps:e.gaps},thickness:e.thickness*i,outline:{d:r(a.d),closed:a.closed,sample:e=>a.sample(e).map(n)},bounds:Mo(t,e.bounds),center:n(e.center),pivot:n(e.pivot),...e.segments===void 0?{}:{segments:e.segments.map(e=>Eo(e,t))}}}let Do=e=>e[0]===1&&e[1]===0&&e[2]===0&&e[3]===1&&e[4]===0&&e[5]===0;function Oo(e){return et(e.getAttribute(`transform`)??``)}function ko(e){let[t,n,r,i]=e,a=1e-9*Math.max(Math.abs(t),Math.abs(n),Math.abs(r),Math.abs(i));return Math.abs(n)<=a&&Math.abs(r)<=a||Math.abs(t)<=a&&Math.abs(i)<=a}function Ao(e){let[t,n,r,i]=e,a=t*t+n*n,o=r*r+i*i,s=1e-4*Math.max(a,o);return Math.abs(a-o)<=s&&Math.abs(t*r+n*i)<=s}function jo(e){return Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2]))}function Mo(e,t){let n=[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}].map(t=>q.apply(e,t)),r=n.map(e=>e.x),i=n.map(e=>e.y),a=Lo(Math.min(...r)),o=Lo(Math.min(...i));return{x:a,y:o,width:Lo(Lo(Math.max(...r))-a),height:Lo(Lo(Math.max(...i))-o)}}function No(e){let t=Po(e),n=e=>{let n=Number.parseFloat(t(e)??``);return Number.isFinite(n)?n:0};return{x:n(`x`),y:n(`y`),width:Math.max(0,n(`width`)),height:Math.max(0,n(`height`))}}function Po(e){return t=>{if(!e.hasAttribute(t))return null;let n=e[t];return typeof n?.baseVal?.value==`number`?String(n.baseVal.value):e.getAttribute(t)}}function Fo(e){let t=typeof e.getScreenCTM==`function`?e.getScreenCTM():null;return t?[t.a,t.b,t.c,t.d,t.e,t.f]:void 0}function Io(e,t){let n=[1,0,0,1,0,0];for(let r=e;r&&r!==t;r=r.parentElement)n=q.multiply(Oo(r),n);return n}function Lo(e){return Math.round(e*1e3)/1e3}function Ro(e,t,n){let r={},i=!1,a=Un(),o=()=>{let{transform:n,opacity:a,emphasis:o}=r;for(let r of e()){let{element:e,colors:s}=r,c=n&&r.parentInverse?q.multiply(r.parentInverse,n,r.parent,Oo(e)):void 0;t.style(e,`transform`,c&&Zo(c)),t.style(e,`transform-origin`,c&&`0 0`),t.style(e,`transform-box`,c&&`view-box`),t.style(e,`opacity`,a===void 0?void 0:String(a));let l=s?o===void 0?i?s.strong:void 0:Xo(s,o):void 0;t.style(e,`fill`,s?.paint===`fill`?l:void 0),t.style(e,`stroke`,s?.paint===`stroke`?l:void 0),t.style(e,`transition`,o===void 0||!s?void 0:`none`)}s()},s=()=>{let t=e().flatMap(e=>e.outline===void 0?[]:[{...e.outline,color:e.colors?.color}]);a.paint(n(),t,r.halo,r.transform)};return{get style(){return r},set(e){r=ft(r,e),o()},reset(){r={},o()},repaint:o,hot(e){e!==i&&(i=e,o())}}}function zo(e,t){let n=e.localName===`line`?Uo:Ko(e,t,`fill`),r=n===Uo?`stroke`:`fill`,i=r===`fill`?n:Ko(e,t,`stroke`);if(i!==void 0&&i!==Uo)return{...Bo(i),paint:r}}function Bo(e){return{color:e,strong:`color-mix(in oklab, ${e}, ${yn(`text`)} ${Ho})`}}function Vo(e,t,n){let r=e.ownerDocument.defaultView?.getComputedStyle?.(e).getPropertyValue(n).trim()??``;if(Go(t))return r;for(let r=e;r;r=r===t?null:r.parentElement){let e=r.style?.getPropertyValue(n)||r.getAttribute(n);if(e)return e.trim()}return r}let Ho=`25%`,Uo=`none`,Wo=new WeakMap;function Go(e){let t=Wo.get(e);if(t!==void 0)return t;let n=e.ownerDocument.defaultView;if(!e.isConnected||typeof n?.getComputedStyle!=`function`)return!1;let r=e.ownerDocument.createElementNS(`http://www.w3.org/2000/svg`,`g`);r.setAttribute(`stroke-miterlimit`,`7`),e.appendChild(r);let i=n.getComputedStyle(r).getPropertyValue(`stroke-miterlimit`).trim()===`7`;return r.remove(),Wo.set(e,i),i}function Ko(e,t,n){let r=e.ownerDocument.defaultView?.getComputedStyle?.(e).getPropertyValue(n),i=Yo(r);if(r&&Go(t))return i;let a;for(let r=e;r&&a===void 0;r=r===t?null:r.parentElement){let e=r.style?.getPropertyValue(n)||r.getAttribute(n);e&&(a=e)}let o=n===`fill`?i?.replace(/\s/g,``)===`rgb(0,0,0)`:i===Uo;return i!==void 0&&!(o&&a!==void 0)?i:Yo(a)}function qo(e,t){let n=e.ownerDocument.defaultView?.getComputedStyle?.(e),r=n?.getPropertyValue(`stroke-width`),i=Jo(r),a=n?.getPropertyValue(`vector-effect`).trim().toLowerCase(),o=e.style?.getPropertyValue(`vector-effect`)?a:e.getAttribute(`vector-effect`)?.trim().toLowerCase(),s=(a&&(a!==`none`||Go(t))?a:o)===`non-scaling-stroke`;if(r&&Go(t)||i!==void 0&&i!==1)return{width:i,screen:s};for(let n=e;n&&!n.style?.getPropertyValue(`stroke-width`);n=n===t?null:n.parentElement){let e=Jo(n.getAttribute(`stroke-width`));if(e!==void 0)return{width:e,screen:s}}return{width:i,screen:s}}function Jo(e){let t=/^\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)\s*(?:px\s*)?$/i.exec(e??``),n=t?Number(t[1]):NaN;return n>=0&&Number.isFinite(n)?n:void 0}function Yo(e){let t=e?.trim().toLowerCase();if(t&&t!==`inherit`&&!t.startsWith(`url(`))return t===Uo||t===`transparent`||/^rgba\((?:[^,]+,){3}\s*0(?:\.0*)?\s*\)$/.test(t)?Uo:e.trim()}function Xo(e,t){let n=Math.min(1,Math.max(0,t));return n===0?e.color:n===1?e.strong:`color-mix(in srgb, ${e.strong} ${Math.round(n*1e3)/10}%, ${e.color})`}function Zo(e){return`matrix(${e.map((e,t)=>t<4?Math.round(e*1e6)/1e6:Math.round(e*1e3)/1e3).join(`, `)})`}function Qo(e,t){let n=jo(t);if(!Ao(t)||!(n>0)||e.length>32||e.some(e=>e.op===`C`||e.op===`Q`))return;let r=.5/n,i=Ce(e);if(i.length===0||i.length>2||!i.every(ss))return;let a=i.map(e=>os(e.segments,r)),o=i.length===2?$o(a[0],a[1],r):es(a[0],r);return o&&as(o,t)}function $o(e,t,n){let[r,i]=[e[0],t[0]];if(e.length!==1||t.length!==1||r?.kind!==`arc`||i?.kind!==`arc`)return;let[a,o]=r.radius>=i.radius?[r,i]:[i,r],s=(e,t)=>Math.abs(Math.abs(e)-O)*t<=n;for(let e of[rs(a),a.arcs[0].center]){if(!e)continue;let[t,r]=[ls(a.from,e),ls(o.from,e)],[i,c]=[ns(a,e),ns(o,e)];if(t>n&&t-r>n&&Math.sign(i)!==Math.sign(c)&&s(i,t)&&s(c,r)&&is(a,e,t,n)&&is(o,e,r,n))return{center:e,inner:r,outer:t,start:cs(a.from,e),sweep:Math.sign(i)*O}}}function es(e,t){let n=-1;if(e.forEach((t,r)=>{t.kind===`arc`&&(n<0||t.radius>e[n].radius)&&(n=r)}),n<0)return;let r=[...e.slice(n),...e.slice(0,n)],i=r[0],[,a,o,s]=r,c=r.length===3&&a?.kind===`line`&&o?.kind===`line`,l=r.length===4&&a?.kind===`line`&&o?.kind===`arc`&&s?.kind===`line`?o:void 0;if(!c&&!l)return;let[u,d]=l?[l.from,l.to]:[a.to,a.to],f=(e,n)=>{let r=ls(e,n);return r>t?{x:e.x+(n.x-e.x)*i.radius/r,y:e.y+(n.y-e.y)*i.radius/r}:void 0},p=f(i.from,d),m=f(i.to,u);if(!p||!m)return;let h={x:(p.x+m.x)/2,y:(p.y+m.y)/2};c&&ls(u,h)<=t&&(h=u);let g=h===u?0:(ls(u,h)+ls(d,h))/2,_=ns(i,h);if(_===0)return;let v={center:h,inner:g,outer:(ls(i.from,h)+ls(i.to,h))/2,start:cs(i.from,h),sweep:_};return ts(v,i,l,[u,d],t)?v:void 0}function ts(e,t,n,[r,i],a){let{center:o,start:s,sweep:c}=e,l=(e,t)=>({x:o.x+e*Math.cos(t),y:o.y+e*Math.sin(t)});return e.outer>a&&e.outer-e.inner>a&&ls(t.from,l(e.outer,s))<=a&&ls(t.to,l(e.outer,s+c))<=a&&is(t,o,e.outer,a)&&ls(r,l(e.inner,s+c))<=a&&ls(i,l(e.inner,s))<=a&&(!n||Math.abs(ns(n,o)+c)*e.inner<=a&&is(n,o,e.inner,a))}function ns(e,t){let n=0;for(let r of e.arcs){let e=P(cs(j(r,1),t)-cs(j(r,0),t));n+=e+O*Math.round((r.sweep-e)/O)}return n}function rs(e){let t=[e.from,...e.arcs.slice(0,-1).map(e=>j(e,1))];if(t.length<2)return;if(t.length===2)return{x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2};let[n,r,i]=[t[0],t[Math.floor(t.length/3)],t[Math.floor(2*t.length/3)]],a=2*(n.x*(r.y-i.y)+r.x*(i.y-n.y)+i.x*(n.y-r.y));if(!(Math.abs(a)>0))return;let[o,s,c]=[n,r,i].map(({x:e,y:t})=>e*e+t*t);return{x:(o*(r.y-i.y)+s*(i.y-n.y)+c*(n.y-r.y))/a,y:(o*(i.x-r.x)+s*(n.x-i.x)+c*(r.x-n.x))/a}}let is=(e,t,n,r)=>Math.abs(e.radius-n)<=r&&e.arcs.every(e=>[0,.5,1].every(i=>Math.abs(ls(j(e,i),t)-n)<=r));function as(e,t){let n=jo(t),r=q.apply(t,e.center),i=q.apply(t,{x:e.center.x+e.outer*Math.cos(e.start),y:e.center.y+e.outer*Math.sin(e.start)}),a=t[0]*t[3]-t[1]*t[2]<0?-e.sweep:e.sweep,o=((cs(i,r)+Math.PI/2)%O+O)%O;return o>O-1e-9&&(o=0),{cx:us(r.x),cy:us(r.y),inner:us(e.inner*n),outer:us(e.outer*n),start:o,end:o+a}}function os(e,t){let n=[],r=(e,n)=>e!==void 0&&Math.sign(e.sweep)===Math.sign(n.sweep)&&Math.abs(e.radius-n.radius)<=t;for(let t of e){let e=n[n.length-1];t.kind===`line`?n.push({kind:`line`,from:t.from,to:t.to}):e?.kind===`arc`&&r(e,t)?n[n.length-1]={...e,arcs:[...e.arcs,t],to:j(t,1),sweep:e.sweep+t.sweep}:n.push({kind:`arc`,arcs:[t],from:j(t,0),to:j(t,1),radius:t.radius,sweep:t.sweep})}let[i]=n,a=n[n.length-1];return n.length>1&&i?.kind===`arc`&&a?.kind===`arc`&&a.arcs.every(e=>r(i,e))&&(n[0]={...i,arcs:[...a.arcs,...i.arcs],from:a.from,sweep:a.sweep+i.sweep},n.pop()),n}let ss=({closed:e,start:t,end:n})=>e||t.x===n.x&&t.y===n.y,cs=(e,t)=>Math.atan2(e.y-t.y,e.x-t.x),ls=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y),us=e=>Math.round(e*1e3)/1e3+0;function ds(e){if(typeof e==`string`){if(typeof document>`u`)throw TypeError(`expressive: a selector needs a document.`);return{elements:Array.from(document.querySelectorAll(e)),data:void 0}}if(hs(e))return{elements:[e],data:void 0};if(gs(e)){let t=Array.from(e.nodes()),n=Array.from(e.data());return{elements:t,data:n.length===t.length?n:void 0}}if(typeof e==`object`&&e&&typeof e.length==`number`)return{elements:Array.from(e),data:void 0};throw TypeError(`expressive needs marks: a selector, an element, a list of elements or a D3 selection.`)}function fs(e){if(!gs(e))return;let{elements:t,data:n}=ds(e);return n&&new Map(t.map((e,t)=>[e,n[t]]))}function ps(e){let t;for(let n of e){if(!hs(n))throw TypeError(`expressive: marks must be elements, got ${String(n)}.`);let e=n.ownerSVGElement??null;if(!e){let e=n.localName;throw TypeError(e===`svg`?`expressive: got an <svg>, not its marks. Pass the marks, for example svg.querySelectorAll("rect").`:`expressive: marks must be SVG elements inside an <svg>, got <${e}>.`)}for(;e.ownerSVGElement;)e=e.ownerSVGElement;if(t&&e!==t)throw TypeError(`expressive: all marks must be in the same <svg>.`);t=e}if(!t)throw TypeError(`expressive: no marks.`);return t}function ms(e,t){let n=e[0].parentElement??t;for(;n!==t&&!e.every(e=>e!==n&&n.contains(e));)n=n.parentElement??t;return n}function hs(e){return typeof e==`object`&&!!e&&e.nodeType===1}function gs(e){return typeof e==`object`&&!!e&&typeof e.nodes==`function`&&typeof e.data==`function`}let _s=[`d`,`x`,`y`,`width`,`height`,`cx`,`cy`,`r`,`rx`,`ry`,`x1`,`y1`,`x2`,`y2`,`points`,`transform`],vs=[`transform`,`style`];function ys(e,t,n){let r=e.defaultView?.MutationObserver??(typeof MutationObserver>`u`?void 0:MutationObserver);if(!r)throw TypeError(`expressive: watch needs MutationObserver, which this DOM doesn't have.`);let i=new Set,a=new Set,o=new Set,s=new Set,c,l=e=>{for(let{target:t,attributeName:n}of e){let e=t;o.has(e)&&i.add(e),s.has(e)&&(n===`transform`||n===`style`)&&a.add(e)}},u=new r(e=>{l(e),(i.size>0||a.size>0)&&!c&&(c=t.onFrame(d))});function d(){if(l(u.takeRecords()),i.size===0&&a.size===0){c?.(),c=void 0;return}let e={marks:i,ancestors:a};i=new Set,a=new Set,n(e)}function f(){u.takeRecords(),c?.(),c=void 0,i=new Set,a=new Set}return{observe(e,t){f(),u.disconnect(),o=new Set(e),s=new Set;for(let n of e)for(let e=n.parentElement;e&&!s.has(e);e=e===t?null:e.parentElement)s.add(e);for(let e of s)o.has(e)||u.observe(e,{attributes:!0,attributeFilter:vs});for(let e of o)u.observe(e,{attributes:!0,attributeFilter:_s})},destroy(){f(),u.disconnect(),o=new Set,s=new Set}}}let bs=`Since 0.13.0 geometry is called with (datum, element, key), not (element, datum, key).`,xs=new Set([`circle`,`ellipse`,`line`,`path`,`polygon`,`polyline`]),Ss=new Set([`img`,`image`,`graphics-symbol`,`graphics-object`]),Cs=new WeakMap,ws=e=>e?Cs.get(e):void 0;function Ts(e,n,r){Es(n);let i=zn(n.motion,r.motion),o=lt(n.on,r.presets),s=n.on,c=r.clock??a,l=n.dim===!0,u=Co(),d=new WeakMap,f=e,p=!1,m=!1;function h(e){let{elements:t,data:r}=ds(e);if(t.length===0)return{root:void 0,ancestor:void 0,marks:[]};let i=ps(t),a=ms(t,i),s=new Map;t.forEach((e,t)=>{let i=D(e,t,r),a=n.key(i,e);if(a==null||a===``)throw TypeError(`expressive: key returned ${JSON.stringify(a)??String(a)} for a <${e.localName}>. Every mark needs a key.`);let o=String(a),c=e.localName;if(!n.geometry&&c!==`rect`&&!xs.has(c))throw TypeError(`expressive: can't read the geometry of a <${c}> (mark "${o}"). <rect>, <circle>, <ellipse>, <line>, <path>, <polygon> and <polyline> are read; describe others with the geometry option.`);let l=O(i,e,o),u=s.get(o);if(!u)s.set(o,u=[]);else if(!n.geometry&&(xs.has(c)||xs.has(u[0].element.localName))){let e=xs.has(c)?c:u[0].element.localName;throw TypeError(`expressive: two elements have the key "${o}", and one is a <${e}>. A circle or a shape is a mark of its own: give each its own key.`)}else if(l===void 0)throw RangeError(`expressive: two elements have the key "${o}". Keys must be unique, or name each part with segment.`);else if(u.some(e=>e.series===l))throw RangeError(`expressive: the mark "${o}" has two "${l}" segments.`);u.push({element:e,datum:i,series:l,value:n.value?.(i,e)})});let c={svg:i,common:a,screen:wo(),colors:e=>A(e,i),stroke:e=>qo(e,i)},l=e=>({...e,label:k(e.key,e.parts)}),u=[...s.keys()];if(n.geometry)return{root:i,ancestor:a,marks:E(T(Ps(u.map((e,t)=>l(g(e,s.get(e),t,c))),e=>e.geometry)),o)};let d=[],f=[];u.forEach((e,t)=>{let n=s.get(e);if(n[0].element.localName===`rect`&&!_(n,c))d.push(t);else{let r=b(e,n[0],t,c);r&&f.push(r)}});let p=d.map(e=>s.get(u[e]).map(t=>v(u[e],t,c))),m=p.map(e=>vo(e.map(e=>e.rect.box))),h=ho(m,n.baseline??`auto`),x=e=>y(u[d[e]],p[e],h[e],d[e],c);return{root:i,ancestor:a,marks:E(T(f.length===0?_o(m,h).map(e=>l(x(e))):Ps([...d.map((e,t)=>x(t)),...f].sort((e,t)=>e.index-t.index),e=>e.geometry).map(e=>l(e))),o)}}function g(e,t,r,i){let a=t[0],o;try{o=n.geometry(a.datum,a.element,e)}catch(t){throw Object.assign(TypeError(`expressive: geometry for "${e}" threw. ${bs} Its error: ${t instanceof Error?t.message:String(t)}`),{cause:t})}if(typeof o!=`object`||!o||o.key!==e)throw TypeError(`expressive: geometry for "${e}" must be a MarkGeometry with the key "${e}". Build it with describe and the key passed in. ${bs}`);let s=t.map(e=>w(e,Is(o,e.series,t.length),i));return{key:e,geometry:o,parts:s,index:r}}function _(e,t){return e.length===1&&!ko(C(e[0].element,t))}function v(e,t,n){let r=C(t.element,n);if(!ko(r))throw TypeError(`expressive: the <rect> of "${e}" is rotated or skewed, so it isn't an upright bar's segment. A rect turned on its own is a shape, a mark of its own: give each its own key, or describe the bar with the geometry option.`);return{...t,rect:{box:Mo(r,No(t.element)),series:t.series,radius:Ls(t.element)}}}function y(e,t,n,r,i){let{geometry:a,order:o}=go(e,t.map(e=>e.rect),n),s=a.segments??[],c=o.map((e,n)=>{let r=s[n];return w(t[e],r&&r.length>=.5?{d:r.outline.d}:void 0,i)});return{key:e,geometry:x(a,c[0]),parts:c,index:r,rect:{edge:n,box:vo(t.map(e=>e.rect.box))}}}function b(e,t,n,r){let{element:i,series:a}=t,o=i.localName,s=C(i,r),c=Po(i),l=e=>{let t=Number.parseFloat(c(e)??``);return Number.isFinite(t)?t:0},u=o===`circle`?l(`r`):0,d,f;if(o===`circle`&&(Ao(s)||!(u>0))){let t=q.apply(s,{x:l(`cx`),y:l(`cy`)});d=be({key:e,series:a,x:Rs(t.x),y:Rs(t.y),r:Rs(Math.max(0,u)*jo(s))})}else{let t=Pe(o,c);if(t[0]?.op!==`M`||t.every(e=>e.op===`M`))return;f=o===`circle`?void 0:r.stroke(i);let n=o===`path`?Qo(t,s):void 0;if(n)d=fe({key:e,series:a,...n});else{let n=Rs(S(f,s,r));d=Be({key:e,series:a,d:o===`path`?c(`d`)??``:ze(t),matrix:s,width:n>0?n:1})}}let p=[{...w(t,Is(d,a,1),r),stroke:f}];return{key:e,geometry:x(d,t),parts:p,index:n,...o===`circle`?{circle:!0}:{}}}function x(e,t){return n.labelBounds?Os(e,n.labelBounds(t.datum,t.element)):e}function S(e,t,n){let r=e?.width??1;if(!e?.screen)return r*jo(t);let i=n.screen(n.common),a=i?jo(i):0;return a>0?r/a:r}function C(e,t){return q.multiply(To(t.common,e.parentElement??t.svg,t.svg,t.screen),Oo(e))}function w(e,t,n){let r=To(n.common,e.element.parentElement??n.svg,n.svg,n.screen);return{element:e.element,datum:e.datum,series:e.series,value:e.value,parent:r,parentInverse:zs(r),colors:n.colors(e.element),outline:t}}function T(e){return e.map(e=>{let{key:t,geometry:r,parts:i}=e,a=e.rect?As(i):void 0,o=i[0].value,s=e.circle&&typeof o==`number`&&Number.isFinite(o)?o:void 0,c=(e,i,o)=>n.samples?Ms(n.samples(e,i),o===void 0?`"${t}"`:`"${t}" (${o})`):a===void 0?s===void 0?[]:[{t:0,value:s}]:js(r,i,a),l=new Map,u=e=>l.get(e)??He(e,t);for(let t of ks(e)){let e=(i.find(e=>e.series===t)??i[0]).datum;l.set(t,{datum:e,samples:c(e,r.segments?.find(e=>e.series===t)??r,t),related:u})}return{...e,data:{datum:i[0].datum,samples:c(i[0].datum,r),related:u}}})}function E(e,t){if(e.length===0)return e;let n=new Set(e.flatMap(e=>[...e.geometry.series===void 0?[]:[e.geometry.series],...ks(e)]));for(let e of ct){let r=t[e];if(r?.kind===`data`)for(let t of r.needs?.related??[]){if(n.has(t))continue;let r=n.size>0?`the marks' series are ${[...n].map(e=>`"${e}"`).join(`, `)}`:`the marks have no series`;throw RangeError(`expressive: on.${e} needs the series "${t}", but ${r}. Name each mark's series in its geometry (describe.line({ key, series, … })), or a stack's parts with segment.`)}}return e}function D(e,t,r){if(n.datum)return n.datum(e);if(r)return r[t];let i=e.__data__;return typeof i==`number`&&!p&&(p=!0,console.warn(`expressive: element.__data__ is a number, which looks like Observable Plot's row index. Pass datum: (el) => rows[el.__data__].`)),i}function O(e,t,r){if(!n.segment)return;let i=n.segment(e,t);if(i==null||i===``)throw TypeError(`expressive: segment returned ${String(i)} for a part of "${r}".`);return String(i)}function k(e,r){if(n.markLabel)try{let t=String(n.markLabel(r[0].datum,{key:e,parts:r.map(({series:e,datum:t})=>({series:e,datum:t}))})??``);return t.trim()===``?void 0:t}catch(e){t(e);return}}function A(e,t){if((u.styled(e,`fill`)||u.styled(e,`stroke`))&&d.has(e))return d.get(e);let n=zo(e,t);return d.set(e,n),n}let j=h(f),M=j.root?.ownerDocument??(typeof document>`u`?void 0:document);if(!M)throw TypeError(`expressive needs a DOM.`);Tn(M);let N,P,F=new Map,I=[],ee=new Map,L=new Map,R=new Set,z={enter:new Set,update:new Set,exit:new Set,hover:new Set,leave:new Set},B,V,te,H,U=!1,ne=(e,t,n)=>{let r=M.createElementNS(`http://www.w3.org/2000/svg`,e);return X(r,t),n?.appendChild(r),r},re=ne(`g`,{class:`ec-overlay`,"aria-hidden":`true`});At(re,{"pointer-events":`none`});let ie=ne(`g`,{class:`ec-halos`},re),ae=ne(`g`,{class:`ec-runs`},re),oe=Hn(re),se=e=>F.get(e)??ee.get(e),ce=It(ae),le=Zn({overlay:ae,measure:ce,mark:e=>({set:t=>se(e)?.handle.set(t),reset:()=>se(e)?.handle.reset()}),colors:(e,t)=>Ds(se(e)?.mark,t)?.colors}),W=Ct({effects:o,motion:i,icons:r.icons,clock:c,surface:le}),G=e=>({mark:e.mark.geometry,data:e.mark.data});function ue(){ce.clear();for(let e of I)W.change(e.mark.geometry,e.mark.data)}let de=()=>{},pe=Mr(M,ue);function me(e){let t={key:e.key,mark:e,handle:Ro(()=>t.mark.parts.filter(e=>(L.get(e.element)?.record??t)===t),u,()=>ie)};return t}function he(e){e.root&&e.root!==N&&ye(e.root),P=e.ancestor??P;let t=new Set(e.marks.map(e=>e.key)),r={entering:[],exiting:[],changed:[],moved:[],newRow:!1},i=[];for(let e of I)t.has(e.key)||(F.delete(e.key),ee.set(e.key,e),r.exiting.push(e));let a=L;L=new Map,I=e.marks.map(e=>{let t=F.get(e.key);if(t){let a=t.mark,o=n.value?Vs(a.parts,e.parts):Hs(a.geometry,e.geometry),s=a.data.datum!==e.data.datum;s&&(r.newRow=!0),o?r.changed.push({record:t,from:a.geometry}):(s||Ws(a.geometry,e.geometry)||Us(a.data.samples,e.data.samples))&&r.moved.push(t),(a.parts.length!==e.parts.length||e.parts.some((e,t)=>e.colors?.color!==a.parts[t].colors?.color))&&i.push(e.key),t.mark=e}else t=ee.get(e.key),t?(ee.delete(e.key),t.mark=e):t=me(e),F.set(e.key,t),r.entering.push(t);for(let n of e.parts)L.set(n.element,{record:t,part:n});return t});for(let[e,t]of a)L.get(e)?.record!==t.record&&u.restore(e);for(let e of I)ge(e);_e(),ve(),K();for(let e of I)e.handle.repaint();for(let e of i)le.recolor(e);return Ae(),r}function ge(e){if(!n.markLabel)return;let{label:t,parts:r}=e.mark;r.forEach((e,n)=>{let r=t!==void 0&&n===0;u.attribute(e.element,`role`,r?`img`:null),u.attribute(e.element,`aria-label`,r?t:null),r?u.remove(e.element,`aria-hidden`):u.attribute(e.element,`aria-hidden`,t===void 0?null:`true`)})}function _e(){let e=N,t=new Set;for(let r of n.markLabel&&e?I:[])if(r.mark.label!==void 0)for(let n of r.mark.parts)for(let r=n.element.parentElement;r&&r!==e&&e?.contains(r);r=r.parentElement){if(t.has(r)||r.hasAttribute(`aria-label`)||r.hasAttribute(`aria-labelledby`))continue;let e=r.getAttribute(`role`)?.trim().split(/\s+/)[0];(e!==void 0&&Ss.has(e)||e===void 0&&R.has(r))&&t.add(r)}for(let e of R)t.has(e)||(u.attribute(e,`role`,null),u.attribute(e,`aria-roledescription`,null));for(let e of t)u.remove(e,`role`),u.remove(e,`aria-roledescription`);R=t}function ve(){if(!N||!P)return;N.lastElementChild!==re&&N.appendChild(re),re.removeAttribute(`transform`);let e=To(re,P,N);Bs(e)||re.setAttribute(`transform`,Mt(e))}function ye(e){xe(),N=e,de=Nr(N,c,ue),N.appendChild(re),(n.keyboard===!0||n.markLabel)&&N.getAttribute(`role`)===`img`&&!m&&(m=!0,console.warn(`expressive: the <svg> is role="img", so screen readers read it as one picture and skip the marks inside, with their names and keyboard focus. Make it role="group"; its aria-label can stay.`)),te=sr(N,{find(e){let t=Se(e);if(!t)return;let{key:n}=t.record;return t.part.series===void 0?{key:n}:{key:n,segment:t.part.series}},hover(e,t){let n=F.get(e.key);!n||jn(B)&&B.keys[0]===e.key||(we(),Ce([n],t,e.segment))},leave(){(B?.source===`pointer`||B?.source===`touch`)&&we()}})}function xe(){N&&(we(),te?.destroy(),te=void 0,de())}function Se(e){for(let t=e;t&&t!==N;t=t.parentElement){let e=L.get(t);if(e)return e}}function Ce(e,t,n,r=!0){let i={keys:e.map(e=>e.key),source:t,effects:r};B=i,K(),r&&W.hover(e.map(G)),e.forEach((r,i)=>Ue(`hover`,{...G(r),batch:{index:i,count:e.length},source:t,...n===void 0?{}:{segment:n}})),t!==`linked`&&B===i&&H?.hover(e.map(G))}function we(){let e=B;e&&(B=void 0,K(),Te(e.keys),jn(e)&&H?.leave())}function Te(e){let t=e.flatMap(e=>se(e)??[]);W.leave(e),t.forEach((e,n)=>Ue(`leave`,{...G(e),batch:{index:n,count:t.length}}))}function Ee(){if(B===void 0)return;let e=B.keys.filter(e=>F.has(e));if(e.length===B.keys.length)return;if(e.length===0){te?.clear(),we();return}let t=B.keys.filter(e=>!F.has(e));B={...B,keys:e},Te(t)}function K(){if(!l)return;let e=`${i.duration(100,`feedback`)}ms`;re.classList.toggle(`ec-hovering`,B!==void 0),At(re,{"--ec-hover-duration":e});for(let t of I){let n=B?.keys.includes(t.key)===!0;for(let r of t.mark.parts)u.toggleClass(r.element,`ec-attached`,!0),u.toggleClass(r.element,`ec-dimmed`,B!==void 0&&!n),u.style(r.element,`--ec-hover-duration`,e);t.handle.hot(n),le.hot(t.key,n)}for(let e of ee.values())e.handle.hot(!1),le.hot(e.key,!1)}let De=l?i.subscribe(K):void 0,Oe=e=>new Set(ct.flatMap(t=>{let n=e[t];return n?.kind===`data`?n.needs?.related??[]:[]})),ke=Oe(o);function Ae(){let e=V===void 0?void 0:F.get(V);oe.draw(e?.mark.geometry)}let je=n.keyboard===!0?cr(()=>N,{find:e=>Se(e)?.record.key,order:()=>I.map(e=>e.key),element:e=>F.get(e)?.mark.parts[0]?.element,tabIndex(e,t){let n=F.get(e);n&&t!==void 0&&n.mark.parts.forEach((e,n)=>{u.attribute(e.element,`tabindex`,n===0?t:`-1`),u.style(e.element,`outline`,`none`)})},focus(e,t){V=t?e:void 0,Ae();let n=F.get(e);n&&(t?jn(B)&&B.keys[0]===e?B={...B,source:`keyboard`}:(we(),Ce([n],`keyboard`)):B?.source===`keyboard`&&B.keys[0]!==e&&we())},blur(){V=void 0,Ae(),B?.source===`keyboard`&&(te?.current===B.keys[0]?B={...B,source:`pointer`}:we())},escape(){return B?(B.source===`linked`&&H?H.dismiss():we(),!0):!1}}):void 0,Me=n.watch===!0?ys(M,c,Fe):void 0;function Ne(){Me?.observe(I.flatMap(e=>e.mark.parts.map(e=>e.element)),N)}function Fe(e){if(U||!P)return;let t=new Set;for(let n of e.marks){let e=L.get(n)?.record;e&&t.add(e)}let n=!1;for(let r of e.ancestors)if(r.contains(P))n=!0;else for(let e of I)e.mark.parts.some(e=>r.contains(e.element))&&t.add(e);let r=new Set;if(n){ve();for(let e of I)!t.has(e)&&e.mark.parts.some(e=>e.stroke?.screen)&&r.add(e)}if(t.size===0&&r.size===0)return;let i=Ie([...t,...r]),a=i.records.flatMap((e,t)=>r.has(e)&&!Ws(e.mark.geometry,i.marks[t].geometry)?[]:[t]);if(a.length===0)return;let o=a.map(e=>i.records[e]),s=a.map(e=>i.marks[e]);o.forEach((e,t)=>{let n=s[t];e.mark=n;for(let t of n.parts)L.set(t.element,{record:e,part:t});e.handle.repaint()}),I=Ve(I),o.some(e=>e.key===V)&&Ae();let c=new Set(o);if(o.some(e=>ke.has(e.mark.geometry.series??``)))for(let e of I)c.add(e);for(let e of c)W.change(e.mark.geometry,e.mark.data)}function Ie(e){let t={svg:N,common:P,screen:wo(),colors:e=>L.get(e)?.part.colors,stroke:e=>L.get(e)?.part.stroke},r=Re(),i=({parts:e})=>e.map(e=>({element:e.element,datum:r(e.element),series:e.series,value:e.value}));if(n.geometry){let n=e.map(({mark:e})=>({...g(e.key,i(e),e.index,t),label:e.label}));return{records:[...e],marks:T(n)}}let a=new Set(e.filter(e=>!e.mark.rect||_(e.mark.parts,t))),o=new Map(e.flatMap(e=>a.has(e)?[]:[[e,i(e.mark).map(n=>v(e.key,n,t))]])),s=Le(o,a);for(let e of I)e.mark.rect&&!o.has(e)&&!a.has(e)&&s.get(e)!==e.mark.rect.edge&&o.set(e,i(e.mark).map(n=>v(e.key,n,t)));let c=[...o.keys()],l=c.map(e=>({...y(e.key,o.get(e),s.get(e),e.mark.index,t),label:e.mark.label}));for(let n of e){if(!a.has(n))continue;let e=b(n.key,i(n.mark)[0],n.mark.index,t);e&&(c.push(n),l.push({...e,label:n.mark.label}))}return{records:c,marks:T(l)}}function Le(e,t){let r=I.filter(e=>e.mark.rect&&!t.has(e)),i=new Map(r.map(e=>[e,e.mark.rect.edge]));if(n.baseline!==void 0&&n.baseline!==`auto`)return i;let a=r.map(t=>{let n=e.get(t);return n?vo(n.map(e=>e.rect.box)):t.mark.rect.box});try{let e=ho(a,`auto`);return new Map(r.map((t,n)=>[t,e[n]]))}catch{return i}}function Re(){if(n.datum)return n.datum;let e=fs(f);return t=>e?.has(t)?e.get(t):D(t,0,void 0)}function Ve(e){let t=[...e].sort((e,t)=>e.mark.index-t.mark.index);return n.geometry||!t.every(e=>e.mark.rect)?[...Ps(t,e=>e.mark.geometry)]:_o(t.map(e=>e.mark.rect.box),t.map(e=>e.mark.rect.edge)).map(e=>t[e])}function He(e,t){return I.find(n=>n.key!==t&&n.mark.geometry.series===e)?.mark.data}function Ue(e,n){for(let r of[...z[e]])try{r(n)}catch(e){t(e)}}function We(e,t){t.forEach((n,r)=>Ue(e,{...G(n),batch:{index:r,count:t.length}}))}W.enter(he(j).entering.map(G)),je?.sync(),Ne();let Ge={targets:()=>I.map(e=>({key:e.key,marks:[G(e)]})),hover(e,t){we();let n=e.flatMap(e=>F.get(e)??[]);n.length>0&&Ce(n,`linked`,void 0,t)},unlink(){B?.source===`linked`&&we()},leave(){te?.clear(),we()},listen(e){return!U&&(H=e,!0)}},Ke=new Set;return Cs.set(Ge,{root:()=>N,ancestor:()=>P,elements:()=>I.flatMap(e=>e.mark.parts.map(e=>e.element)),keyOf:e=>Se(e)?.record.key,colorOf:e=>F.get(e)?.mark.parts[0]?.colors?.color,moveTabStop:e=>je?.moveTabStop(e)??!1,edits:u,refreshed:Ke}),Fn(Ge,{refresh(e){if(U)return;let t=h(e??f);e!==void 0&&(f=e);let n=he(t);Ne(),Ee();let r=B?.effects?n.changed.flatMap(({record:e})=>B.keys.includes(e.key)?[e]:[]):[];W.leave(r.map(e=>e.key));let i=W.exit(n.exiting.map(G));We(`exit`,n.exiting),(n.newRow||n.changed.length>0||n.entering.length>0||n.exiting.length>0)&&W.update(n.changed.map(({record:e,from:t})=>({...G(e),from:t}))),n.changed.forEach(({record:e,from:t},r)=>Ue(`update`,{...G(e),from:t,batch:{index:r,count:n.changed.length}})),W.enter(n.entering.map(G)),We(`enter`,n.entering);let a=new Set([...n.changed.map(e=>e.record),...n.moved]);if([...a,...n.entering,...n.exiting].some(e=>ke.has(e.mark.geometry.series??``))){let e=new Set(n.entering);for(let t of I)e.has(t)||a.add(t)}for(let e of a)W.change(e.mark.geometry,e.mark.data);W.hover(r.filter(e=>B?.effects&&B.keys.includes(e.key)&&F.get(e.key)===e).map(G)),je?.sync();for(let e of Ke)e();i.then(()=>{for(let e of n.exiting)ee.get(e.key)===e&&ee.delete(e.key)})},async update(e){if(U)return;if(typeof e!=`object`||!e)throw TypeError(`expressive: update() needs options, such as { on: { hover: "lift" } }.`);let t=Object.keys(e).find(e=>e!==`on`);if(t!==void 0)throw TypeError(`expressive: \`${t}\` can't be changed by update() yet. Only \`on\` can.`);if(!(`on`in e))return;let n=Cr(o,s,e.on,r.presets);E(I.map(e=>e.mark),n),s=e.on,o=n,ke=Oe(n),W.swap(n,I.map(G))},on(e,t){let n=z[e];if(!n)throw TypeError(`expressive: unknown event "${String(e)}". Use one of: ${Object.keys(z).join(`, `)}.`);return n.add(t),()=>{n.delete(t)}},marks:()=>I.map(e=>e.mark.geometry),focus(e){F.has(e)&&!U&&je?.focus(e)},leave(){U||Ge.leave()},destroy(){if(!U){U=!0,B=void 0,H?.gone(),H=void 0,Me?.destroy(),W.destroy(),De?.(),pe(),je?.destroy(),xe(),re.remove(),u.restoreAll();for(let e of Object.values(z))e.clear();F.clear(),ee.clear(),I=[],L=new Map}}})}function Es(e){if(typeof e!=`object`||!e)throw TypeError(`expressive needs options, with at least a key: { key: (d) => d.name }.`);if(typeof e.key!=`function`)throw TypeError(`expressive needs a key function, for example key: (d) => d.name. Marks are matched by key.`);for(let t of[`datum`,`segment`,`value`,`geometry`,`labelBounds`,`markLabel`])if(e[t]!==void 0&&typeof e[t]!=`function`)throw TypeError(`expressive: ${t} must be a function.`);if(e.baseline!==void 0&&e.baseline!==`auto`&&!mo(e.baseline))throw RangeError(`expressive: baseline must be "left", "right", "top", "bottom" or "auto", got ${String(e.baseline)}.`)}function Ds(e,t){if(t===void 0)return e?.parts[0];let n=e?.geometry.segments?.find(e=>e.key===t);return n&&e.parts.find(e=>e.series===n.series)}function Os(e,t){if(!Array.isArray(t))throw TypeError(`expressive: labelBounds for "${e.key}" must return a list of boxes { x, y, width, height }, got ${Ns(t)}.`);let n=t.map(e=>({x:e?.x,y:e?.y,width:e?.width,height:e?.height}));return{...e,labelBounds:ue(`shape, for expressive's labelBounds for "${e.key}"`,n)}}function ks(e){let t=[...(e.geometry.segments??[]).map(e=>e.series),...e.parts.map(e=>e.series)];return[...new Set(t.filter(e=>e!==void 0))]}function As(e){let t=0;for(let{value:n}of e){if(typeof n!=`number`||!Number.isFinite(n))return;t+=n}return t}function js(e,t,n){let r=t=>e.length>0?n*t/e.length:0;if(t===e)return[{t:0,value:0},{t:1,value:n}];let i=Fs(e.start,t.start);return[{t:0,value:r(i)},{t:1,value:r(i+t.length)}]}function Ms(e,t){if(!Array.isArray(e))throw TypeError(`expressive: samples for ${t} must return an array of { t, value }, got ${Ns(e)}.`);let n=0;return e.map((e,r)=>{let{t:i,value:a,at:o,gapBefore:s}=typeof e==`object`&&e?e:{};if(typeof i!=`number`||!(i>=0&&i<=1))throw RangeError(`expressive: samples for ${t}: samples[${r}].t must be in [0, 1], got ${Ns(i)}.`);if(i<n)throw RangeError(`expressive: samples for ${t} must be in t order: samples[${r}].t is ${i}, after ${n}.`);if(typeof a!=`number`||!Number.isFinite(a))throw RangeError(`expressive: samples for ${t}: samples[${r}].value must be a finite number, got ${Ns(a)}.`);if(s!==void 0&&typeof s!=`boolean`)throw RangeError(`expressive: samples for ${t}: samples[${r}].gapBefore must be true or false, got ${Ns(s)}.`);return n=i,{t:i,value:a,...o===void 0?{}:{at:o},...s?{gapBefore:s}:{}}})}function Ns(e){return typeof e==`string`?JSON.stringify(e):String(e)}function Ps(e,t){let n=e[0]&&t(e[0]).pivot;if(!n||!e.every(e=>Fs(t(e).pivot,n)<=.5&&lo(t(e))))return e;let r=2*Math.PI,i=e=>{let{center:i}=t(e),a=Math.atan2(i.x-n.x,n.y-i.y),o=a<0?a+r:a;return o>=r?0:o};return e.map(e=>({mark:e,angle:i(e)})).sort((e,t)=>e.angle-t.angle).map(({mark:e})=>e)}function Fs(e,t){return Math.hypot(e.x-t.x,e.y-t.y)}function Is(e,t,n){let r=t===void 0?void 0:e.segments?.find(e=>e.series===t),i=r??(n===1?e:void 0);if(!(!i||r&&r.length<.5))return i.outline.closed?{d:i.outline.d}:{d:i.outline.d,stroke:i.thickness}}function Ls(e){let t=Number.parseFloat(e.getAttribute(`rx`)??``),n=Number.parseFloat(e.getAttribute(`ry`)??``),r=Number.isFinite(t)?t:n;return Number.isFinite(r)&&r>0?r:0}function Rs(e){return Math.round(e*1e3)/1e3}function zs(e){try{return $e(e)}catch{return}}function Bs(e){return Math.abs(e[0]-1)<1e-9&&Math.abs(e[1])<1e-9&&Math.abs(e[2])<1e-9&&Math.abs(e[3]-1)<1e-9&&Math.abs(e[4])<1e-6&&Math.abs(e[5])<1e-6}function Vs(e,t){if(e.length!==t.length)return!0;let n=new Map(e.map(e=>[e.series,e.value]));return t.some(e=>{let t=n.get(e.series);return!n.has(e.series)||!(t===e.value||Object.is(t,e.value))})}function Hs(e,t){let n=e.segments??[],r=t.segments??[];return Math.abs(e.length-t.length)>.01||n.length!==r.length||n.some((e,t)=>e.key!==r[t].key||Math.abs(e.length-r[t].length)>.01)}function Us(e,t){let n=(e,t)=>e===t||e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime();return e.length!==t.length||e.some((e,r)=>e.t!==t[r].t||e.value!==t[r].value||!n(e.at,t[r].at))}function Ws(e,t){if(e.outline.d!==t.outline.d||e.thickness!==t.thickness||kr(e,t))return!0;let n=e.segments??[],r=t.segments??[];return n.length!==r.length||n.some((e,t)=>e.key!==r[t].key||e.outline.d!==r[t].outline.d)}let Gs=[`font-family`,`font-size`,`font-style`,`font-weight`,`font-variant-numeric`,`letter-spacing`,`word-spacing`,`dominant-baseline`,`fill`],Ks=new Set([`font-size`,`letter-spacing`,`word-spacing`]);function qs(e,t){let n=e[t]?.baseVal;return n&&n.numberOfItems>0?n.getItem(0).value:Number.parseFloat(e.getAttribute(t)??``)||0}function Js(e,t){return t===1?e:e.replace(/(-?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?)(px)?(?![\w.%])/gi,(e,n,r)=>`${Math.round(Number(n)*t*1e3)/1e3}${r??``}`)}function Ys(e,n={}){let r=Array.isArray(e)?e:[e];if(r.length===0)throw TypeError(`hostView needs an attachment, or an array of attachments on one <svg>: hostView([dots, connectors]).`);let i=r.map((t,n)=>{let i=typeof t==`object`&&t?In(t):void 0,a=ws(i);if(!i||!a?.root())throw TypeError(r===e?`hostView needs attachments that expressive() or fromVegaView() returned, each with marks in an <svg>: attachments[${n}] isn't one.`:`hostView needs an attachment that expressive() or fromVegaView() returned, with marks in an <svg>.`);if(r.indexOf(t)!==n)throw TypeError(`hostView: attachments[${n}] is attachments[${r.indexOf(t)}] again. Each attachment is in a view once.`);return{attachment:t,port:i,inside:a,hidden:[]}});if(typeof n!=`object`||!n||n.labels!==void 0&&typeof n.labels!=`function`)throw TypeError(`hostView: labels must be a function that returns the host's labels, such as () => names.map((element) => ({ element, key: element.textContent, role: "category" })).`);if(n.guides!==void 0&&typeof n.guides!=`function`)throw TypeError(`hostView: guides must be a function that returns the host's guides, such as () => [{ element: svg.querySelector("g.axis"), key: "y" }].`);let a=i[0],o=i.length>1,{edits:s}=a.inside,c=()=>a.inside.root(),l,u,d,f=o?Xs(i,c()):void 0;if(f)throw TypeError(`hostView: ${f.problem}.`);let p=()=>i.filter(e=>e.inside.root()===c()),m=e=>p().find(t=>t.attachment.marks().some(t=>t.key===e));function h(){if(!n.labels)return[];let e=new Set(p().flatMap(e=>e.attachment.marks().map(e=>e.key)));try{return Array.from(n.labels()).filter(t=>t?.element?.localName===`text`&&c().contains(t.element)&&e.has(t.key)&&(t.role===`category`||t.role===`value`))}catch(e){return t(e),[]}}function g(){if(!n.guides)return[];let e=c();try{return Array.from(n.guides()).filter(t=>t?.element?.nodeType===1&&t.element!==e&&e.contains(t.element)&&typeof t.key==`string`)}catch(e){return t(e),[]}}function _({element:e,key:t,role:n}){let r=c(),i=To(y.space,e,r),a=q.apply(i,{x:qs(e,`x`),y:qs(e,`y`)}),o=jo(i),s=e.ownerDocument.createElementNS(kt,`text`);s.textContent=e.textContent;for(let t of[`dx`,`dy`]){let n=e.getAttribute(t);n!==null&&s.setAttribute(t,Js(n,o))}At(s,Object.fromEntries(Gs.map(t=>{let n=Vo(e,r,t);return[t,(Ks.has(t)?Js(n,o):n)||void 0]})));let l=Vo(e,r,`text-anchor`);return{key:t,role:n,text:e.textContent??``,x:a.x,y:a.y,anchor:l===`middle`||l===`end`?l:`start`,element:s}}let v=e=>{if(e&&l===void 0&&o){let e=Xs(i,c());e&&t(TypeError(`hostView: ${e.problem}. The switch plays on, and ${e.left}.`))}let n=e?c():void 0;l=e?h():void 0,u=e?g():void 0;let r=[...(l??[]).map(e=>e.element),...(u??[]).map(e=>e.element)],a=i.map(({inside:e,hidden:t},i)=>new Set(l?[...e.elements(),...i===0?r:[],...t.filter(e=>n?.contains(e))]:[]));for(let e=1;e<a.length;e++)for(let t of a[e])a.some((n,r)=>r<e&&n.has(t))&&a[e].delete(t);i.forEach((e,t)=>{for(let n of e.hidden)a[t].has(n)||e.inside.edits.style(n,`visibility`,void 0)}),i.forEach((e,t)=>{e.hidden=[...a[t]];for(let t of e.hidden)e.inside.edits.style(t,`visibility`,`hidden`)}),d!==n&&(d&&s.toggleClass(d,`ec-morphing`,!1),n&&s.toggleClass(n,`ec-morphing`,!0),d=n)},y={get element(){return c()},get space(){let e=c(),[t,...n]=p().map(t=>t.inside.ancestor()??e),r=t;for(let t of n)for(;r!==e&&!r.contains(t);)r=r.parentElement??e;return r},refresh(e){if(o&&e!==void 0)throw TypeError(`hostView: a view of several attachments refreshes each from what it last read, with refresh(). To read new sources, refresh each attachment with its own.`);for(let{attachment:t}of i)t.refresh(e)},update:e=>o?Promise.all(i.map(({attachment:t})=>t.update(e))).then(()=>{}):a.attachment.update(e),on(e,t){let n=i.map(({attachment:n})=>n.on(e,t));return o?()=>n.forEach(e=>e()):n[0]},marks(){let e=c(),t=y.space,n=new Set;return p().flatMap(({attachment:r,inside:i})=>{let a=i.ancestor()??e,o=a===t?void 0:To(t,a,e);return r.marks().flatMap(e=>n.has(e.key)?[]:(n.add(e.key),[o?Eo(e,o):e]))})},focus:e=>m(e)?.attachment.focus(e),leave(){for(let{attachment:e}of i)e.leave()},destroy(){l=u=d=void 0;for(let e of i)e.hidden=[];for(let{attachment:e}of[...i].reverse())e.destroy()},labels:()=>(l??h()).map(_),guides:()=>u??g(),paintOf(e){for(let{inside:t}of p()){let n=t.colorOf(e);if(n!==void 0)return{color:e,drawn:!0,cssColor:n}}},keyOf(e){for(let{inside:t}of i){let n=t.keyOf(e);if(n!==void 0)return n}},moveTabStop:e=>p().some(({inside:t})=>t.moveTabStop(e)),morphing:v};for(let{inside:e}of i)e.refreshed.add(()=>{l&&v(!0)});return o?y:Fn(a.port,y)}function Xs(e,t){let n=new Map;for(let[r,{attachment:i,inside:a}]of e.entries()){if(a.root()!==t)return{problem:`attachments[${r}]'s marks are in another <svg> than attachments[0]'s, and a view's attachments share one`,left:`attachments[${r}]'s marks are left out`};for(let{key:e}of i.marks()){let t=n.get(e);if(t!==void 0&&t!==r)return{problem:`attachments[${t}] and attachments[${r}] both have a mark with the key ${JSON.stringify(e)}, and each key must be one mark's. Key each one's marks apart, such as (d) => \`first@\${d.name}\``,left:`the key stays attachments[${t}]'s: attachments[${r}]'s mark is left out`};n.set(e,r)}}}let Zs=[`line`,`rect`,`arc`,`symbol`],Qs=[`d`,`transform`,`x`,`y`,`width`,`height`,`stroke-width`];function $s(e,n,r){if(ec(e),typeof n!=`object`||!n||typeof n.key!=`function`)throw TypeError(`fromVegaView needs options with a key: { key: (d) => d.series }. Marks are matched by key.`);let i=n.mark??`marks`;if(typeof i!=`string`||i===``)throw TypeError(`fromVegaView: mark must be a mark's name, got ${String(i)}.`);if(n.sample!==void 0&&typeof n.sample!=`function`)throw TypeError(`fromVegaView: sample must be a function.`);let o=v(),{mark:s,sample:c,...l}=n,u=new WeakMap,d=Ts(o.elements,{...l,datum:e=>_(e).datum,geometry:(e,t,r)=>{let i=o.geometry.get(r);if(!i)throw TypeError(`fromVegaView: no geometry for "${r}". Its key must be the same for every item of a mark.`);if(!n.labelBounds)return i;let a=Os(i,n.labelBounds(e,t));return u.set(a,i),a},...n.samples||!n.sample?{}:{samples:(e,t)=>o.samples.get(u.get(t)??t)??[]},...n.value||!n.sample?{}:{value:(e,t)=>o.values.get(t)}},r),f=r.clock??a,p,m,h=!1,g=typeof MutationObserver==`function`?new MutationObserver(e=>e.some(C)&&w()):void 0;T(o.root);function _(e){let t=o.items.get(e);if(!t)throw TypeError(`fromVegaView: an element that isn't one of the View's items.`);return t}function v(){let t=nc(tc(e),i),r=rc(t,i,e),a=e.container(),o=a?.localName===`svg`?a:a?.querySelector(`svg`),s={root:o??void 0,elements:[],items:new Map,geometry:new Map,samples:new Map,values:new Map};if(!r||!o)return s;let c=new Set(r===`line`?t.flatMap(e=>e.items?.[0]&&oc(e.items[0])?[e.items[0]]:[]):t.flatMap(e=>e.items??[])),l=new Map;for(let e of Array.from(o.querySelectorAll(`*`))){let t=e.__data__;c.has(t)&&l.set(e,t)}let u=[...l.keys()];if(u.length===0)return s;let d=ps(u),f=ms(u,d),p=wo(),m=e=>To(f,e.parentElement??d,d,p),h=e=>String(n.key(l.get(e).datum,e)),g=e=>n.segment?String(n.segment(l.get(e).datum,e)):void 0,_={root:d,items:l,elements:u,geometry:new Map,samples:new Map,values:new Map};if(n.sample)for(let[e,t]of l){let n=r===`line`?ac(t):[t];_.values.set(e,n.map(e=>e.defined===!1?``:b(e).value).join(`,`))}if(r===`rect`)return y(_,m,h,g);for(let e of u){let t=l.get(e),i=h(e);if(_.geometry.has(i))continue;let a=m(e),o=r===`line`?lc(i,e,t,a):r===`arc`?uc(i,t,a):dc(i,t,a);_.geometry.set(i,o),n.sample&&_.samples.set(o,r===`line`?x(o,t,a):S(o,t,r))}return _}function y(e,t,r,i){let a=new Map;for(let n of e.elements){let o=e.items.get(n),s=r(n),c={box:Mo(t(n),fc(o)),series:i(n),radius:Math.max(0,o.cornerRadius??0)},l=a.get(s);l?l.push({element:n,part:c}):a.set(s,[{element:n,part:c}])}let o=[...a.keys()],s=o.map(e=>vo(a.get(e).map(e=>e.part.box))),c=ho(s,n.baseline??`auto`),l=[];for(let t of _o(s,c)){let r=o[t],i=a.get(r),{geometry:s,order:u}=go(r,i.map(e=>e.part),c[t]);if(e.geometry.set(r,s),l.push(...u.map(e=>i[e].element)),n.sample){let t=u.map(t=>b(e.items.get(i[t].element)).value),n=t.reduce((e,t)=>e+t,0);e.samples.set(s,[{t:0,value:0},{t:1,value:n}]);let r=0;(s.segments??[]).forEach((n,i)=>{let a=r;r+=t[i]??0,e.samples.set(n,[{t:0,value:a},{t:1,value:r}])})}}return{...e,elements:l}}function b(e){let t=n.sample(e.datum),r=typeof t==`number`?{value:t}:t;if(typeof r!=`object`||!r||!Number.isFinite(r.value))throw RangeError(`fromVegaView: sample must give a finite number, or { value, at }, got ${JSON.stringify(t)}.`);return r.at===void 0?{value:r.value}:{value:r.value,at:r.at}}function x(e,t,n){return rt(e,cc(t).map(({item:e,point:t})=>({...q.apply(n,t),...b(e)})))}function S(e,t,n){let{value:r,at:i}=b(t),a=i===void 0?{t:1,value:r}:{t:1,value:r,at:i};return n===`symbol`?[{...a,t:0}]:e.length>0?[{t:0,value:0},a]:[{...a,t:0}]}function C(e){let t=p?.querySelector(`:scope > .ec-overlay`),n=e=>e===t||(t?.contains(e)??!1);return n(e.target)?!1:e.type!==`childList`||[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].some(e=>!n(e))}function w(){if(m||h)return;let e=f.onFrame(()=>{e(),m=void 0;try{E()}catch(e){t(e)}});m=e}function T(e){g&&e!==p&&(g.disconnect(),p=e,e&&g.observe(e,{subtree:!0,childList:!0,attributes:!0,attributeFilter:Qs}))}function E(){if(h)return;let e=v(),t=o;o=e;try{d.refresh(e.elements)}catch(e){throw o=t,e}T(e.root)}return Fn(In(d),{refresh:E,update:d.update,on:d.on,marks:d.marks,focus:d.focus,leave:d.leave,destroy(){h||(h=!0,g?.disconnect(),m?.(),m=void 0,d.destroy())}})}function ec(e){if(typeof e!=`object`||!e||typeof e.renderer!=`function`||typeof e.scenegraph!=`function`||typeof e.container!=`function`)throw TypeError(`fromVegaView needs a Vega View: new vega.View(runtime, { renderer: "svg", container }), or vega-embed's result.view.`);let t=e.renderer();if(t!==`svg`)throw TypeError(`fromVegaView: the View renders with "${t}", which draws no SVG elements to attach to. Use renderer: "svg" (vega-embed's default; a bare vega.View uses canvas).`)}function tc(e){let t=e.scenegraph();return t.root??t}function nc(e,t){let n=[],r=e=>{if(e.name===t&&e.marktype!==`group`&&n.push(e),e.marktype===`group`)for(let t of e.items??[])for(let e of t.items??[])r(e)};return r(e),n}function rc(e,t,n){if(e.length===0){let e=ic(tc(n));if(e.length===0)return;throw RangeError(`fromVegaView: the View has no mark named "${t}". Its named marks: ${e.map(e=>`"${e}"`).join(`, `)}.`)}let r=e[0].marktype;if(!e.every(e=>e.marktype===r)||!Zs.includes(r))throw TypeError(`fromVegaView: "${t}" is a ${String(r)} mark. Rects, arcs, symbols and lines can be read; describe others with expressive()'s geometry option.`);return r}function ic(e){let t=new Set,n=e=>{e.name&&e.marktype!==`group`&&t.add(e.name);for(let t of e.items??[])for(let e of t.items??[])n(e)};return n(e),[...t]}let ac=e=>e.mark?.items??[e],oc=e=>ac(e).some(e=>e.defined!==!1),sc=e=>{let t=ac(e)[0]?.interpolate;return t===void 0||t===`linear`};function cc(e){let t=ac(e),n=[],r=!1;for(let e of t)e.defined===!1?r=n.length>0:(n.push({item:e,point:{x:mc(e.x),y:mc(e.y)},gapBefore:r}),r=!1);return n}function lc(e,t,n,r){let i=n.strokeWidth??Number.parseFloat(t.getAttribute(`stroke-width`)??`1`);if(!sc(n)){let n=i*pc(r);return Be({key:e,series:e,d:t.getAttribute(`d`)??``,matrix:r,width:n>0&&Number.isFinite(n)?n:1})}let a=cc(n),o=a.flatMap((e,t)=>e.gapBefore?[t]:[]);return ge({key:e,series:e,points:a.map(({point:e})=>q.apply(r,e)),...o.length>0?{breaks:o}:{},width:(Number.isFinite(i)?i:1)*pc(r)})}function uc(e,t,n){let r=q.apply(n,{x:mc(t.x),y:mc(t.y)}),i=pc(n),[a,o]=[mc(t.startAngle),mc(t.endAngle)].sort((e,t)=>e-t);return fe({key:e,cx:r.x,cy:r.y,inner:mc(t.innerRadius)*i,outer:mc(t.outerRadius)*i,start:a,end:o})}function dc(e,t,n){let r=q.apply(n,{x:mc(t.x),y:mc(t.y)});return be({key:e,x:r.x,y:r.y,r:Math.sqrt(Math.max(0,t.size??64)/Math.PI)*pc(n)})}function fc(e){let t=mc(e.x),n=mc(e.y),r=mc(e.width),i=mc(e.height);return{x:Math.min(t,t+r),y:Math.min(n,n+i),width:Math.abs(r),height:Math.abs(i)}}function pc(e){return Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2]))}function mc(e){return typeof e==`number`&&Number.isFinite(e)?e:0}let hc={get:()=>void 0},gc={set(){},reset(){}},_c={place(){},update(){},remove(){}};function vc(e,n){let{effect:r,surface:i}=n;if(!yc(r))throw TypeError(`playTransition needs a transition effect (kind "transition" with run, end and clear), got ${bc(r)}.`);let o=n.start??0;if(!(typeof o==`number`&&o>=0&&o<=1))throw RangeError(`playTransition: start must be a number from 0 to 1, got ${String(o)}.`);let s=n.motion??v,c=n.clock??a,l=n.icons??hc,u=e.length,d=[],f=!1,p=u,m,h=new Promise(e=>{m=e}),g=u>0?s.subscribe(()=>{s.mode===`off`&&w()}):void 0,_=()=>{--p>0||(g?.(),g=void 0,m())};function y(e,t,n){let i=vt({clock:c,motion:s,icons:l,batch:{index:t,count:u},layer:T(e.to.key,t,()=>a.state!==`cleared`),mark:gc}),a={pair:e,index:t,scope:i,context:{...i.context,start:o},state:`running`,done:n};d[t]=a;let{from:f,to:p}=e;try{s.mode===`off`?(r.end(f,p,a.context),b(a)):Promise.resolve(r.run(f,p,a.context)).then(()=>b(a),e=>x(a,e))}catch(e){x(a,e)}}function b(e){e.state===`running`&&(e.state=`ended`,S(e))}function x(e,n){let{signal:r}=e.context;(!r.aborted||n!==r.reason&&n?.name!==`AbortError`)&&(t(n),C(e))}function S(e){let t=e.done;e.done=void 0,t?.()}function C(e){if(e.state!==`cleared`){e.state=`cleared`,e.scope.abort();try{r.clear(e.context)}catch(e){t(e)}e.scope.clear(),S(e)}}function w(){for(let e of[...d]){if(e.state!==`running`)continue;let t=e.done;e.done=void 0,C(e),y(e.pair,e.index,t)}}function T(e,t,n){let r,a=()=>n()?r??(r=i.group(e,t)):void 0;return{icon:(e,t)=>a()?.icon(e,t)??_c,path:(e,t)=>a()?.path(e,t)??_c,text:(e,t)=>a()?.text(e,t)??_c,clear(){let e=r;r=void 0,e?.clear()}}}return e.forEach((e,t)=>y(e,t,_)),u===0&&m(),{finished:h,clear(){if(!f){f=!0;for(let e of[...d])C(e)}}}}function yc(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.kind===`transition`&&typeof t.run==`function`&&typeof t.end==`function`&&typeof t.clear==`function`}function bc(e){if(typeof e!=`object`||!e)return e===null?`null`:typeof e;let t=e.kind;return t===`geometry`||t===`data`?`a ${t} effect, which plays on one mark: put it in a chart's \`on\` option`:t===`transition`?`a transition effect without run(), end() and clear()`:t===void 0?`an object with no kind`:`an effect of kind ${JSON.stringify(t)}`}let xc=.5;function Sc(e,t,n){let r=yr(e,`chartSwitch`),i=Xc(t),o=t.transition,s=Dn(t.colors),c=n.motion,l=n.clock??a,u=r.ownerDocument;Tn(u);let d=u.createElement(`div`);d.className=`ec-switch`,r.appendChild(d);let f=new Map;try{for(let e of i){let n=u.createElement(`div`);n.className=`ec-switch-view`,n.setAttribute(`data-view`,e),d.appendChild(n),Tc(n,e===t.initial);let r=t.views[e](n,s);if(!Yc(r,n))throw r?.destroy?.(),TypeError(`chartSwitch: views.${e} must return the chart it draws in the container it's given (with element, marks(), labels(), focus(), leave() and destroy()), such as donutChart(container, { ... }).`);f.set(e,{name:e,container:n,chart:r,port:In(r)})}}catch(e){for(let e of f.values())e.chart.destroy();throw d.remove(),e}let p=Y(`svg`,{class:`ec-chart ec-switch-overlay`,"aria-hidden":`true`},d),m=Y(`g`,{class:`ec-switch-fades`},p),h=Y(`g`,{class:`ec-switch-runs`},p),g=Y(`g`,{class:`ec-switch-labels`},p),_=t.announce?Ot(p):void 0,v=e=>bn(e.cssColor===void 0?vn(s.slot(e.color)):Bo(e.cssColor)),y=new WeakMap,b=(e,t)=>({group(n,r){let i=Y(`g`,{class:`ec-run`,"data-key":n},h);At(i,v(e[r]??{color:n})),y.set(i,r);let a=Array.from(h.children).find(e=>(y.get(e)??-1/0)>r);h.insertBefore(i,a??null);let o=qn(i);return{...t[r]?.wrap(o,i)??o,clear:()=>i.remove()}}});function x(e,t,n){let[r,i]=e,[a,o]=t;if(r===0&&i===0&&!a&&!o)return;let s=[];if(a&&o){let e=ae();s.push({element:e,draw:t=>Kc(e,{at:{x:Vc(a.at.x,o.at.x,t),y:Vc(a.at.y,o.at.y,t)},r:Vc(a.r,o.r,t),ring:Vc(a.ring,o.ring,t)})})}else[[a,Ic,n[0]],[o,Lc,n[1]]].forEach(([e,t,n])=>{if(!e)return;let r=ae();At(r,v(n)),Kc(r,e),s.push({element:r,draw:e=>X(r,{opacity:t(e)})})});let c=r>0||i>0,l=r,u=new Map;return{wrap(e,t){u.clear();let n=()=>{for(let e of s)t.appendChild(e.element)};return n(),{...e,path(t,r){let i=c&&r.fill!==void 0&&r.stroke===void 0,a=e.path(t,i?{...r,stroke:`surface`,width:l}:r);return n(),i?(u.set(a,t),{update(e,t){u.set(a,e),a.update(e,t)},remove(){u.delete(a),a.remove()}}):a}}},draw(e){l=Vc(r,i,e);for(let[e,t]of u)e.update(t,{width:l});for(let t of s)t.draw(e)}}}let S=t.initial,C,w=!1,T,E,D=!1,O,k=c.subscribe(()=>{c.mode===`off`&&C&&U(C,!0)}),A,j=typeof ResizeObserver==`function`?new ResizeObserver(e=>{let t=e[e.length-1]?.contentRect.width??0;if(A!==void 0&&Math.abs(t-A)<.5)return;let n=A===void 0;A=t,!n&&C&&U(C,!0)}):void 0;j?.observe(d);let M=e=>f.get(e),N=(e,t=``)=>TypeError(`chartSwitch: there's no view ${JSON.stringify(e)}${t}. The views are ${i.map(e=>JSON.stringify(e)).join(`, `)}.`);function P(){return d.getRootNode().activeElement??null}function F(e){let t=P(),n=t!==null&&e.container.contains(t),r=n?t:e.chart.element.querySelector(`[tabindex="0"]`),i=r?.closest(`[data-key]`),a=(r&&e.chart.keyOf?.(r))??(i&&e.chart.element.contains(i)?i.getAttribute(`data-key`):null);if(n||a!==null)return{keys:a===null?[]:e.chart.standsFor?.(a)??[a],focused:n}}function I(e,t){if(!t)return;let n=P(),r=n!==null&&n!==u.body&&n!==u.documentElement&&!d.contains(n);if(!t.focused||r){for(let n of t.keys)if(e.chart.moveTabStop?.(n))return;return}let i=()=>e.chart.element.contains(P());for(let n of[...t.keys,...e.chart.marks().map(e=>e.key)])if(e.chart.focus(n),i())return}function ee(e){_?.say(e.chart.element.getAttribute(`aria-label`)??``)}function L(){D&&T?.shown()}function R(e,t,n,r){return n===void 0||!c.staged||n===e.name||n===t.name?z(e,t,r):z(e,M(n),r,t)}function z(e,t,n,r){let i=n?n.focus:F(e),a=[];O=a;try{e.chart.leave()}finally{O=void 0}let o=w?Promise.resolve():B(e,t,i,r);for(let e of a)e();return o}function B(e,t,n,r,i){if(S=(r??t).name,c.mode===`off`){let e=M(S);for(let t of f.values())Tc(t.container,t===e);return I(e,n),ee(e),L(),Promise.resolve()}let a=[];for(let n of[e,t])n.container.classList.remove(`ec-switch-inactive`),a.push(re(n)),n.container.classList.add(`ec-switching`),n.container.setAttribute(`inert`,``),n.chart.morphing?.(!0),n.chart.element.classList.add(`ec-morphing`);let{pairs:o,surface:s,scene:l}=ne(e,t,a),{done:u,settle:d}=i??Jc(),p={a:e,b:t,forward:!0,pairs:o,reversed:o.map(({from:e,to:t})=>({from:t,to:e})),surface:s,scene:l,focus:n,next:r,progress:0,transition:void 0,driver:void 0,run:0,done:u,settle:d};return C=p,V(p,0),p.done}function V(e,t){let r=++e.run;if(t>=1){te(e);return}let i=t=>{e.progress=t,e.scene.draw(e.forward?t:1-t)},a=wc(l);e.transition=vc(e.forward?e.pairs:e.reversed,{effect:o,surface:e.surface,start:t,motion:c,clock:a.clock,icons:n.icons}),e.driver=Cc(t,i,{clock:a.clock,motion:c}),a.release(),Promise.all([e.driver.finished,e.transition.finished]).then(([t])=>{C===e&&e.run===r&&t===`done`&&te(e)})}function te(e){let t=e.forward?e.next:void 0;if(!t||c.mode===`off`)return U(e,!0);let{done:n,settle:r}=e;e.next=void 0,e.settle=()=>{},U(e,!1),B(e.b,t,e.focus,void 0,{done:n,settle:r})}function H(e){return e.driver?.cancel(),e.transition?.clear(),e.forward=!e.forward,S=(e.forward?e.b:e.a).name,e.settle(),{done:e.done,settle:e.settle}=Jc(),V(e,1-e.progress),e.done}function U(e,t){if(C!==e)return;C=void 0,e.run++,e.driver?.cancel(),e.transition?.clear(),e.scene.clear();let n=e.forward?e.next??e.b:e.a;for(let t of[e.a,e.b])t.chart.element.classList.remove(`ec-morphing`),t.chart.morphing?.(!1),t.container.classList.remove(`ec-switching`),t.container.style.removeProperty(`opacity`);for(let e of f.values())Tc(e.container,e===n);t&&(I(n,e.focus),ee(n),L()),e.settle()}function ne(e,t,n){let r=To(p,e.chart.space??e.chart.element,d),i=To(p,t.chart.space??t.chart.element,d),a=qc(r),o=qc(i),s=e.chart.marks().map(e=>Eo(e,r)),c=t.chart.marks().map(e=>Eo(e,i)),l=new Map(s.map(e=>[e.key,e])),f=new Set(c.map(e=>e.key)),_=[],v=[],y=[];for(let n of c){let r=l.get(n.key);if(!r)continue;let i=Hc(e,r),s=Hc(t,n);(i.drawn||s.drawn)&&(_.push({from:i.drawn?r:Uc(r),to:s.drawn?n:Uc(n)}),v.push(s),y.push(x([Wc(i,a),Wc(s,o)],[Gc(i,r,a),Gc(s,n,o)],[i,s])))}let S=[];y.some(e=>e!==void 0)&&S.push(e=>{for(let t of y)t?.draw(e)});let C=(e,t,n,r)=>{let i=Hc(e,t);i.drawn&&S.push(ie(t,i,n,r))};for(let t of s)f.has(t.key)||C(e,t,a,Ic);for(let e of c)l.has(e.key)||C(t,e,o,Lc);let w=e=>`${e.role}\n${e.key}`,T=e.chart.labels(),E=t.chart.labels(),D=e.chart.space?a:1,O=t.chart.space?o:1,k=new Map(T.map(e=>[w(e),e])),A=new Set;for(let e of E){let t=k.get(w(e));t&&(A.add(w(e)),S.push(Nc(oe(t,r,D),oe(e,i,O))))}for(let e of T)A.has(w(e))||S.push(Fc(oe(e,r,D),Ic));for(let e of E)k.has(w(e))||S.push(Fc(oe(e,i,O),Lc));let[j=[],M=[]]=n,N=new Map;for(let e of j)N.has(e.key)||N.set(e.key,e);let P=new Set;for(let e of M){let t=N.get(e.key);N.delete(e.key),t&&Mc(t,e)&&P.add(t).add(e)}let F;if(j.length+M.length>0){let e=F=u.createElementNS(kt,`g`);e.setAttribute(`class`,`ec-switch-guides`),p.insertBefore(e,m),[[j,e=>+(e<xc),Rc],[M,e=>e<xc?0:1,zc]].forEach(([t,n,r])=>{for(let i of t){e.appendChild(i.group);let t=P.has(i)?n:r;S.push(e=>i.group.setAttribute(`opacity`,Dc(t(e))))}})}return S.push(n=>{Ec(e.container,Rc(n)),Ec(t.container,zc(n))}),{pairs:_,surface:b(v,y),scene:{draw:e=>{for(let t of S)t(e)},clear:()=>{F?.remove(),m.replaceChildren(),h.replaceChildren(),g.replaceChildren()}}}}function re(e){let t=e.chart.element;return(e.chart.guides?.()??[]).flatMap(e=>{let n=e?.element,r=n?.parentElement;if(typeof e?.key!=`string`||!r||!t.contains(r))return[];let i=To(p,r,d),a=Ac(n,t),o=u.createElementNS(kt,`g`);X(o,{class:`ec-switch-guide`,"data-key":e.key,transform:Do(i)?void 0:Mt(i)}),o.appendChild(a);let s=Oo(n);return[{key:e.key,group:o,markup:a.outerHTML,corners:jc(n).map(e=>q.apply(i,q.apply(s,e))),place:i}]})}function ie(e,t,n,r){let i=Y(`g`,{class:`ec-switch-fade`,"data-key":e.key},m);At(i,v(t));let a=Wc(t,n);qn(i).path(e.outline.d,e.outline.closed?{fill:`mark`,...a>0?{stroke:`surface`,width:a}:{}}:{stroke:`mark`,width:e.thickness});let o=Gc(t,e,n);return o&&Kc(i.appendChild(ae()),o),e=>X(i,{opacity:r(e)})}function ae(){let e=u.createElementNS(kt,`circle`);return e.setAttribute(`class`,`ec-switch-end`),At(e,{fill:yn(`mark`),stroke:yn(`surface`)}),e}function oe(e,t,n){let r=e.element.cloneNode(!0);for(let e of[`id`,`opacity`,`visibility`,`aria-hidden`])r.removeAttribute(e);r.textContent=e.text;let i={text:r,at:q.apply(t,e),scale:n};return X(r,{x:i.at.x,y:i.at.y,"text-anchor":e.anchor,...Pc(i,i.at.x,i.at.y)}),g.appendChild(r),i}let se={get current(){return S},show(e,t){if(!f.has(e))return Promise.reject(N(e));let n=t?.via;if(n!==void 0&&!f.has(n))return Promise.reject(N(n,` to go via`));if(w)return Promise.resolve();let r=O;if(r)return new Promise(n=>r.push(()=>n(se.show(e,t))));let i=C;if(!i)return e===S?Promise.resolve():R(M(S),M(e),n);let a=i.forward?i.b:i.a,o=i.forward?i.a:i.b,s=i.next;return e===(s??a).name?i.done:s&&(i.next=void 0,e===a.name)?(S=e,i.settle(),{done:i.done,settle:i.settle}=Jc(),i.done):e===o.name?H(i):(U(i,!1),R(a,M(e),n,{focus:i.focus}))},chart(e){let t=f.get(e);if(!t)throw N(e);return t.chart},on(e,t){let n=Array.from(f.values(),n=>{let r=n.chart.on;if(typeof r==`function`)return r.call(n.chart,e,e=>{n.name===S&&t(e)})});return()=>{for(let e of n)e?.()}},marks:()=>M(S).chart.marks(),leave(){D=!1,w||M(S).chart.leave()},destroy(){if(w)return;w=!0;let e=C;if(e){C=void 0,e.run++,e.driver?.cancel(),e.transition?.clear(),e.scene.clear();for(let t of[e.a,e.b])t.chart.morphing?.(!1);e.settle()}k(),j?.disconnect(),_?.destroy();let t=T;T=void 0,t?.gone();for(let e of f.values())e.chart.destroy();d.remove()}},ce=e=>C===void 0&&e.name===S;function le(e){let t=()=>{E===e&&(E=void 0,T?.leave())};return{hover(t){ce(e)&&(E=e,T?.hover(t))},leave:t,dismiss(){ce(e)&&T?.dismiss()},shown(){},gone:t}}return Fn({targets:()=>C===void 0?M(S).port?.targets()??[]:[],hover(e,t){D=!0,C===void 0&&M(S).port?.hover(e,t)},unlink(){D=!1;for(let e of f.values())e.port?.unlink()},leave:()=>se.leave(),listen(e){if(w)return!1;T=e,E=void 0,D=!1;for(let t of f.values())t.port?.listen(e&&le(t));return!0},parts:Array.from(f.values()).flatMap(e=>e.port?[e.port]:[])},se)}function Cc(e,t,n){let r=l(e),i;return i=y({duration:950,timing:`transition`,ease:o,update:n=>{let a=Math.min(1,r+n);t(n===0?e:s(a)),a>=1&&n<1&&i?.finish()}},n),i}function wc(e){let t=e.now();return{clock:{now:()=>t??e.now(),onFrame:t=>e.onFrame(t)},release(){t=void 0}}}function Tc(e,t){e.classList.toggle(`ec-switch-inactive`,!t),e.toggleAttribute(`inert`,!t),t?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,`true`)}function Ec(e,t){e.style.setProperty(`opacity`,Dc(t))}let Dc=e=>String(Math.round(e*1e3)/1e3),Oc=`fill.fill-opacity.fill-rule.stroke.stroke-opacity.stroke-width.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.paint-order.marker-start.marker-mid.marker-end.color.visibility.font-family.font-size.font-style.font-weight.font-stretch.font-variant-caps.font-variant-ligatures.font-variant-numeric.font-feature-settings.font-kerning.letter-spacing.word-spacing.text-anchor.dominant-baseline.text-rendering.shape-rendering.writing-mode.direction`.split(`.`),kc={opacity:`1`,display:`inline`,"clip-path":`none`,mask:`none`,filter:`none`,"vector-effect":`none`};function Ac(e,t){let n=e.cloneNode(!0),r=[e,...e.querySelectorAll(`*`)],i=[n,...n.querySelectorAll(`*`)];return r.forEach((e,n)=>{let r=i[n];r.removeAttribute(`id`);let a=e.ownerDocument.defaultView?.getComputedStyle?.(e),o={};for(let n of Oc)o[n]=Vo(e,t,n)||void 0;for(let[e,t]of Object.entries(kc)){let n=a?.getPropertyValue(e).trim();n&&n!==t&&(o[e]=n)}At(r,o)}),n}function jc(e){try{let t=e.getBBox?.();if(t)return[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x,y:t.y+t.height},{x:t.x+t.width,y:t.y+t.height}]}catch{}return[{x:0,y:0}]}let Mc=(e,t)=>e.markup===t.markup&&e.corners.length===t.corners.length&&e.corners.every((e,n)=>Math.hypot(e.x-t.corners[n].x,e.y-t.corners[n].y)<=.5)&&[0,1,2,3].every(n=>Math.abs(e.place[n]-t.place[n])<=1e-4);function Nc(e,t){return n=>{let r=Vc(e.at.x,t.at.x,n),i=Vc(e.at.y,t.at.y,n),a=n>=xc;X(e.text,{x:r,y:i,visibility:a?`hidden`:void 0,...Pc(e,r,i)}),X(t.text,{x:r,y:i,visibility:a?void 0:`hidden`,...Pc(t,r,i)})}}let Pc=(e,t,n)=>e.scale===1?{}:{transform:Mt([e.scale,0,0,e.scale,t*(1-e.scale),n*(1-e.scale)])};function Fc(e,t){return n=>X(e.text,{opacity:t(n)})}let Ic=e=>1-Bc(e/xc),Lc=e=>Bc((e-xc)/.5),Rc=e=>1-Bc(e/.4),zc=Lc,Bc=e=>Math.min(1,Math.max(0,e)),Vc=(e,t,n)=>e*(1-n)+t*n;function Hc(e,t){return e.chart.paintOf?.(t.key)??{color:t.key,drawn:!0}}function Uc(e){return be({key:e.key,...e.series===void 0?{}:{series:e.series},x:e.center.x,y:e.center.y,r:0})}let Wc=(e,t)=>e.drawn&&e.end===void 0?(e.ring??0)*t:0;function Gc(e,t,n){return e.drawn&&e.end!==void 0?{at:t.end,r:e.end*n,ring:(e.ring??0)*n}:void 0}function Kc(e,t){X(e,{cx:t.at.x,cy:t.at.y,r:t.r,"stroke-width":t.ring})}let qc=e=>Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2]));function Jc(){let e;return{done:new Promise(t=>{e=t}),settle:e}}function Yc(e,t){if(typeof e!=`object`||!e)return!1;let n=e,r=n.element;return[`marks`,`labels`,`focus`,`leave`,`destroy`].every(e=>typeof n[e]==`function`)&&r?.nodeType===1&&t.contains(r)}function Xc(e){if(typeof e!=`object`||!e)throw TypeError(`chartSwitch needs options.`);let{views:t,initial:n,transition:r,announce:i}=e;if(typeof t!=`object`||!t)throw TypeError(`chartSwitch needs views: by name, a function that draws each view's chart in the container it's given.`);let a=Object.keys(t);if(a.length===0)throw TypeError(`chartSwitch needs at least one view.`);for(let e of a)if(typeof t[e]!=`function`)throw TypeError(`chartSwitch: views.${e} must be a function that draws the view's chart in the container it's given.`);if(typeof n!=`string`||!a.includes(n))throw TypeError(`chartSwitch: initial must be one of the views (${a.map(e=>JSON.stringify(e)).join(`, `)}), got ${typeof n==`string`?JSON.stringify(n):String(n)}.`);if(!yc(r))throw TypeError(`chartSwitch: transition must be a transition effect, such as morph().`);if(i!==void 0&&typeof i!=`boolean`)throw TypeError(`chartSwitch: announce must be true or false.`);return a}let Zc=[`presentation`,`analysis`,`off`],Qc={presentation:`Presentation`,analysis:`Analysis`,off:`Off`},$c={presentation:`Staged, unhurried motion. Best for walking someone through a change.`,analysis:`Quick, unstaged motion. Best for exploring.`,off:`No motion: charts jump straight to their end state.`,reduced:`Your device asks for reduced motion, so motion is off. Picking a mode here overrides it.`},el=0;function tl(e,t){let n=rl(e),r=t?.motion;il(r),al(t);let i={...Qc,...t.labels},a={...$c,...t.hints},{persist:o}=t,s=n.ownerDocument;Tn(s);let c=`ec-motion-${++el}`,l=s.createElement(`div`);l.className=`ec-motion-switch`,l.setAttribute(`role`,`group`),l.setAttribute(`aria-labelledby`,`${c}-label`),l.setAttribute(`aria-describedby`,`${c}-hint`);let u=l.appendChild(s.createElement(`span`));u.className=`ec-motion-label`,u.id=`${c}-label`,u.textContent=t.label??`Motion`;let d=l.appendChild(s.createElement(`span`));d.className=`ec-motion-modes`;let f=Zc.map(e=>{let t=d.appendChild(s.createElement(`button`));return t.type=`button`,t.dataset.mode=e,t.textContent=i[e],t.addEventListener(`click`,()=>r.chooseMode(e)),t}),p=l.appendChild(s.createElement(`span`));p.className=`ec-motion-hint`,p.id=`${c}-hint`,p.setAttribute(`aria-live`,`polite`);let m=()=>{let e=r.mode;for(let t of f)t.setAttribute(`aria-pressed`,String(t.dataset.mode===e));p.textContent=r.prefersReduced&&r.viewerChoice===void 0?a.reduced:a[e]};if(o!==void 0){let e=nl(s,e=>e.getItem(o));Zc.includes(e)&&r.chooseMode(e)}m(),n.appendChild(l);let h=r.subscribe(()=>{if(m(),o===void 0)return;let e=r.viewerChoice;nl(s,t=>e===void 0?t.removeItem(o):t.setItem(o,e))}),g=!1;return{element:l,destroy(){g||(g=!0,h(),l.remove())}}}function nl(e,t){try{let n=e.defaultView?.localStorage;return n?t(n):void 0}catch{return}}function rl(e){if(typeof e==`string`){let t=typeof document>`u`?null:document.querySelector(e);if(!t)throw TypeError(`motionSwitch: no element matches "${e}".`);return t}if(typeof e!=`object`||!e||typeof e.appendChild!=`function`)throw TypeError(`motionSwitch needs an element or a selector to build the switch in.`);return e}function il(e){if(typeof e!=`object`||!e||typeof e.chooseMode!=`function`||typeof e.subscribe!=`function`)throw TypeError("motionSwitch needs a Motion, such as the page-wide `motion` or one from createMotion().")}function al(e){let{label:t,labels:n,hints:r,persist:i}=e;if(t!==void 0&&typeof t!=`string`)throw TypeError(`motionSwitch: label must be a string, got ${typeof t}.`);for(let[e,t]of[[`labels`,n],[`hints`,r]])if(t!==void 0){for(let[n,r]of Object.entries(t))if(typeof r!=`string`)throw TypeError(`motionSwitch: ${e}.${n} must be a string, got ${typeof r}.`)}if(i!==void 0&&(typeof i!=`string`||i===``))throw TypeError(`motionSwitch: persist must be a localStorage key, got ${JSON.stringify(i)??String(i)}.`)}let ol={play:`Play`,pause:`Pause`};function sl(e,t,n={}){let r=cl(e);ll(t),ul(n);let i={...ol,...n.labels},a=r.ownerDocument;Tn(a);let o=a.createElement(`button`);o.type=`button`,o.className=`ec-play`,o.addEventListener(`click`,()=>t.playing?t.pause():t.play());let s=()=>{let e=t.playing?i.pause:i.play;o.textContent!==e&&(o.textContent=e)};s(),r.appendChild(o);let c=t.subscribe(s),l=!1;return{element:o,destroy(){l||(l=!0,c(),o.remove())}}}function cl(e){if(typeof e==`string`){let t=typeof document>`u`?null:document.querySelector(e);if(!t)throw TypeError(`playButton: no element matches "${e}".`);return t}if(typeof e!=`object`||!e||typeof e.appendChild!=`function`)throw TypeError(`playButton needs an element or a selector to build the button in.`);return e}function ll(e){if(typeof e!=`object`||!e||typeof e.play!=`function`||typeof e.pause!=`function`||typeof e.subscribe!=`function`)throw TypeError(`playButton needs a Playback, from playback().`)}function ul(e){let{labels:t}=e;if(t!==void 0){for(let[e,n]of Object.entries(t))if(typeof n!=`string`||n.trim()===``)throw TypeError(`playButton: labels.${e} must be a string with some text, got ${JSON.stringify(n)??String(n)}.`)}}let dl=Object.freeze({lift:0,spin:0,tilt:0});function fl(){return e=>({lift:0,spin:e.distance/e.radius,tilt:0})}function pl(e={}){let t=e.stride??42,n=e.lift??3.2,r=e.tilt??9;if(!(t>0)||!Number.isFinite(t))throw RangeError(`gaits.step: stride must be more than 0, got ${t}.`);if(!(n>=0)||!Number.isFinite(n))throw RangeError(`gaits.step: lift can't be negative, got ${n}.`);if(!Number.isFinite(r))throw RangeError(`gaits.step: tilt must be a finite number of degrees, got ${r}.`);let i=r*Math.PI/180;return Object.assign(e=>{let r=Math.max(1,Math.round(e.length/t)),a=Math.abs(Math.sin(Math.PI*(e.progress*r%1)));return{lift:a*n,spin:0,tilt:a*i*(1-.3*e.progress)}},{ease:s,pace:1.15})}function ml(){return()=>dl}let hl={roll:fl,step:pl,slide:ml},gl=[1,0,0,1,0,0],_l=[`auto`,`follow`,`level`],vl=[`center`,`on`];function yl(e,t={}){El(e,t);function n(n,r){let i=typeof e==`string`?r.icons.get(e):e;if(!i)throw RangeError(`travel: unknown icon "${String(e)}". Register it with registerIcon(icon), or pass the icon itself.`);let a=xl(n,t.along);if(!a||!(Cl(a)>=.5))return;let o=t.size===void 0?1:t.size===`fit`?.85*a.thickness/i.box.height:t.size/i.size;if(o>0)return bl(a,i,o,t)}function r(e,t){let r=n(e,t),i,a,o=0,s=()=>{r?(i&&a?.icon===r.icon&&a.size===r.size||(i?.remove(),i=t.layer.icon(r.icon,{size:r.size}),a={icon:r.icon,size:r.size}),i.place(r.transform(o))):(i?.remove(),i=a=void 0)};return t.onChange(e=>{r=n(e,t),s()}),{get trip(){return r},show(e){o=e,s()}}}return{kind:`geometry`,async run(e,t){if(t.signal.aborted)return;let n=r(e,t),i=n.trip;!i||i.span<=0?n.show(1):await t.tween({duration:i.duration,timing:`effect`,ease:i.gait.ease??c,update:e=>n.show(e)}).finished},end(e,t){r(e,t).show(1)},clear(){}}}function bl(e,t,n,r){let i=typeof r.gait==`function`?r.gait:hl[r.gait??t.gait??`slide`](),a=e.length,o=t.footprint[0]*n,s=t.footprint[1]*n,c=0,l=Sl(e).map(([e,t])=>{let n={from:e,to:t,span:Math.max(0,t-e-o-s),before:c};return c+=n.span,n}),u=Math.max(2,(o+s)/2),d=t.radius??t.box.height/2,{anchor:f}=t,p={x:f.x+n*(t.pivot.x-f.x),y:f.y+n*(t.pivot.y-f.y)},m=r.ride===`on`?e.thickness/2+(t.box.y+t.box.height-f.y)*n:0,h=r.orient??`auto`;return{icon:t,size:t.size*n,span:c,duration:Math.min(4e3,Math.max(260,c/360*1e3)*(i.pace??1)),gait:i,transform(r){let s=r*c,g=l.length-1;for(;g>0&&l[g].before>s;)g--;let _=l[g],v=_.from+o+Math.min(_.span,s-_.before),y=i({distance:s/n,length:c/n,progress:r,radius:d}),b=wl(e,v),x=Tl(e,Math.min(v,a),u,_),S=h===`auto`&&t.upright===!0&&Math.cos(x)<-1e-9,C=h===`level`?0:S?P(x-Math.PI):x;return q.multiply(q.translate(b.x,b.y),q.rotate(C),S?q.scale(-1,1):gl,q.translate(-f.x,-f.y-y.lift*n-m),q.rotate(y.spin-y.tilt,p))}}}function xl(e,t){return t===void 0?e:e.segments?e.segments.find(e=>e.series===t):e.series===t?e:void 0}function Sl(e){let{length:t}=e,n=[],r=0;for(let[i,a]of e.gaps??[])a>i&&a>r&&(i>r&&n.push([r*t,Math.min(1,i)*t]),r=Math.min(1,a));return n.push([r*t,t]),n}function Cl(e){return Sl(e).reduce((e,[t,n])=>e+(n-t),0)}function wl(e,t){let{length:n}=e;return t<=n?e.path(t/n):tt(e.end,e.angle(1),t-n)}function Tl(e,t,n,r){let{length:i}=e,a=Math.min(n,t-r.from,r.to-t);if(a>1e-6){let n=e.path((t-a)/i),r=e.path((t+a)/i);if(Math.hypot(r.x-n.x,r.y-n.y)>1e-9)return Math.atan2(r.y-n.y,r.x-n.x)}return e.angle(t/i)}function El(e,t){if((typeof e!=`string`||e===``)&&(typeof e!=`object`||!e||typeof e.name!=`string`))throw TypeError(`travel needs an icon or an icon's name, got ${e===null?`null`:typeof e}.`);let{along:n,gait:r,size:i,orient:a,ride:o}=t;if(n!==void 0&&typeof n!=`string`)throw RangeError(`travel: along must be a series name, got ${String(n)}.`);if(r!==void 0&&typeof r!=`function`&&!Object.prototype.hasOwnProperty.call(hl,r))throw RangeError(`travel: gait must be a gait or one of roll, step, slide, got ${String(r)}.`);if(i!==void 0&&i!==`fit`&&!(typeof i==`number`&&i>0&&Number.isFinite(i)))throw RangeError(`travel: size must be more than 0 px, or "fit", got ${String(i)}.`);if(a!==void 0&&!_l.includes(a))throw RangeError(`travel: orient must be auto, follow or level, got ${String(a)}.`);if(o!==void 0&&!vl.includes(o))throw RangeError(`travel: ride must be center or on, got ${String(o)}.`)}let Dl=.25;function Ol(e={}){jl(e);let t=e.width??8,n=e.opacity??.35,{color:r}=e,i=(e,i)=>{let a=t*kl(i);e.mark.set({halo:a>0?{width:a,opacity:n,...r===void 0?{}:{color:r}}:void 0})};return{kind:`geometry`,async run(e,t){t.signal.aborted||await t.tween({duration:900,timing:`effect`,ease:o,update:e=>i(t,e)}).finished},end(){},clear(){}}}function kl(e){return!(e>0)||e>=1?0:e<Dl?Al(e/Dl):1-Al((e-Dl)/.75)}function Al(e){if(!(e>0))return 0;if(e>=1)return 1;let t=0,n=1;for(let r=0;r<24;r++){let r=(t+n)/2;1.74*r*r*(1-r)+r*r*r<e?t=r:n=r}let r=(t+n)/2;return 3*r*r-2*r*r*r}function jl(e){let{width:t,opacity:n,color:r}=e;if(t!==void 0&&!(typeof t==`number`&&t>0&&Number.isFinite(t)))throw RangeError(`flash: width must be more than 0 px, got ${String(t)}.`);if(n!==void 0&&!(typeof n==`number`&&n>0&&n<=1))throw RangeError(`flash: opacity must be more than 0 and at most 1, got ${String(n)}.`);if(r!==void 0&&(typeof r!=`string`||r===``))throw RangeError(`flash: color must be a theme token or a CSS colour, got ${JSON.stringify(r)??String(r)}.`)}let Ml=[1,-.5,.25],Nl=Math.PI/12;function Pl(e={}){Ll(e);let t=e.swing??3;return{kind:`geometry`,async run(e,n){if(n.signal.aborted)return;let r=e,i=Fl(e,t),a=0,s=()=>{let e=i*Il(a);n.mark.set({transform:e===0?void 0:q.rotate(e,r.pivot)})};n.onChange(e=>{r=e,i=Fl(e,t),s()}),await n.tween({duration:450,timing:`effect`,ease:o,update:e=>{a=e,s()}}).finished},end(){},clear(){}}}function Fl(e,t){let{pivot:n}=e,r=0;for(let t of e.outline.sample(64))r=Math.max(r,Math.hypot(t.x-n.x,t.y-n.y));return r>=.5?Math.min(Nl,2*Math.asin(Math.min(1,t/(2*r)))):0}function Il(e){if(!(e>0)||e>=1)return 0;let t=e*Ml.length,n=Math.floor(t);return Ml[n]*Math.sin(Math.PI*(t-n))}function Ll(e){let{swing:t}=e;if(t!==void 0&&!(typeof t==`number`&&t>0&&t<=3))throw RangeError(`wiggle: swing must be more than 0 and at most 3 px, got ${String(t)}.`)}function Rl(e={}){zl(e);let t=e.times??2,n=e.width??12,{color:r}=e,i=(e,t)=>{let i=t>0&&t<1;e.mark.set({halo:i?{width:n*c(t),opacity:.4*(1-t),...r===void 0?{}:{color:r}}:void 0})};return{kind:`geometry`,async run(e,n){let r=0;for(let e=0;e<t;e++){if(n.signal.aborted)return;let e=n.motion.duration(600,`effect`);if(r+e>=5e3)return;r+=e,await n.tween({duration:600,timing:`effect`,ease:o,update:e=>i(n,e)}).finished}},end(){},clear(){}}}function zl(e){let{times:t,width:n,color:r}=e;if(t!==void 0&&!(Number.isInteger(t)&&t>=1&&t<=6))throw RangeError(`pulse: times must be a whole number from 1 to 6, got ${String(t)}.`);if(n!==void 0&&!(typeof n==`number`&&n>0&&Number.isFinite(n)))throw RangeError(`pulse: width must be more than 0 px, got ${String(n)}.`);if(r!==void 0&&(typeof r!=`string`||r===``))throw RangeError(`pulse: color must be a theme token or a CSS colour, got ${JSON.stringify(r)??String(r)}.`)}let Bl=.5;function Vl(e={}){Hl(e);let t=e.duration??500,n={stroke:e.color??`mark`,width:e.width??3,opacity:e.opacity??.5,linecap:`round`},r=(e,t)=>{let r=e,i=0,a,o=()=>{if(!(r.length>=Bl)){a?.remove(),a=void 0;return}let e=r.slice(0,i);a?a.update(e):a=t.layer.path(e,n)};return t.onChange(e=>{r=e,o()}),o(),e=>{i=e,o()}};return{kind:`geometry`,async run(e,n){if(n.signal.aborted)return;let i=r(e,n);e.length>=Bl?await n.tween({duration:t,timing:`effect`,ease:s,update:i}).finished:i(1)},end(e,t){r(e,t)(1)},clear(){}}}function Hl(e){let{color:t,width:n,opacity:r,duration:i}=e;if(t!==void 0&&(typeof t!=`string`||t===``))throw RangeError(`trace: color must be a theme token or a CSS colour, got ${JSON.stringify(t)??String(t)}.`);if(n!==void 0&&!(typeof n==`number`&&n>=0&&Number.isFinite(n)))throw RangeError(`trace: width must be 0 px or more, got ${String(n)}.`);if(r!==void 0&&!(typeof r==`number`&&r>=0&&r<=1))throw RangeError(`trace: opacity must be from 0 to 1, got ${String(r)}.`);if(i!==void 0&&!(typeof i==`number`&&i>=0&&Number.isFinite(i)))throw RangeError(`trace: duration must be 0 ms or more, got ${String(i)}.`)}function Ul(e={}){Gl(e);let t=e.duration??750,n=e.faint??.3;return{kind:`geometry`,async run(e,r){if(r.signal.aborted||!(Wl(e)>=.5))return;let i=e,a=0,c=!1,l=[],u=e=>{let{segments:t}=i,n=t??[i],o=a*Wl(i),c=0;n.forEach((n,i)=>{let a=n.length>0?Math.min(1,Math.max(0,(o-c)/n.length)):0;c+=n.length;let u=n.slice(0,s(a)),d={stroke:`mark`,width:n.thickness,linecap:`butt`,...t&&{part:n.key}},f=l[i];f?f.update(u,e?{part:void 0,...d}:void 0):l[i]=r.layer.path(u,d)});for(let e of l.splice(n.length))e.remove()};r.onChange(e=>{i=e,c||u(!0)}),r.mark.set({opacity:n}),u(!1),await r.tween({duration:t,timing:`effect`,ease:o,update:e=>{a=e,u(!1)}}).finished,c=!0;for(let e of l)e.remove();r.mark.set({opacity:void 0})},end(){},clear(){}}}let Wl=e=>(e.segments??[e]).reduce((e,t)=>e+t.length,0);function Gl(e){let{duration:t,faint:n}=e;if(t!==void 0&&!(typeof t==`number`&&t>=0&&Number.isFinite(t)))throw RangeError(`drawIn: duration must be 0 ms or more, got ${String(t)}.`);if(n!==void 0&&!(typeof n==`number`&&n>=0&&n<=1))throw RangeError(`drawIn: faint must be from 0 to 1, got ${String(n)}.`)}let Kl=.36;function ql(e,t){let n=e.labelBounds??[],r=[...n,...e.nearbyLabels??[],...t?.held??[]],i=e.angle(1);if($l(e.end,i,n)===void 0){let i=e.angle(.5)-Math.PI/2;if($l(e.center,i,n)!==void 0)return Jl(e.center,i,0,n,r,t)}return Jl(e.end,i,10,n,r,t)}function Jl(e,t,n,r,i,a){if(!a)return Zl(e,t,Math.max(n,$l(e,t,i)??-1/0));let{x:o,y:s,width:c,height:l}=a.box(Zl(e,t,0));return Zl(e,t,Yl(e,t,Math.max(n,$l(e,t,r)??-1/0),i,{x:o-e.x,y:s-e.y,width:c,height:l},new Set(a.held)))}function Yl(e,t,n,r,i,a){let o=Math.cos(t),s=Math.sin(t),c=Ql(o),l=t=>tu(e,o,s,{x:t.x-i.x-i.width,y:t.y-i.y-i.height,width:t.width+i.width,height:t.height+i.height}),u=r.map(t=>{let n=Xl(t,6),r=tu(e,o,s,n);if(!r&&a.has(t))return l(t);let i=l(n);if(!r||!i)return i;let u=c?Math.max(r[1],((s>0?n.y+n.height:n.y)-e.y)/s):r[1];return[i[0],Math.max(u,l(t)?.[1]??-1/0)]}),d=n;for(let e=!0;e;){e=!1;for(let t of u)t&&d>t[0]+1e-6&&d<t[1]-1e-6&&(d=t[1],e=!0)}return d}let Xl=({x:e,y:t,width:n,height:r},i)=>({x:e-i,y:t-i,width:n+2*i,height:r+2*i});function Zl(e,t,n){let r=Math.cos(t),i=Math.sin(t),a=tt(e,t,n),o=12.5*(i<0?Kl*(1+i):Kl+.44000000000000006*i),s=Ql(r)?`middle`:r>0?`start`:`end`;return{at:{x:a.x,y:a.y+o},anchor:s,toward:t}}function Ql(e){return Math.abs(e)<=Math.SQRT1_2+1e-9}function $l(e,t,n){let r=Math.cos(t),i=Math.sin(t),a=Ql(r),o;for(let t of n){let n=Xl(t,6),s=eu(e,r,i,n);s!==void 0&&a&&(s=Math.max(s,((i>0?n.y+n.height:n.y)-e.y)/i)),s!==void 0&&(o=Math.max(o??s,s))}return o}function eu(e,t,n,r){return tu(e,t,n,r)?.[1]}function tu(e,t,n,r){let i=0,a=1/0;for(let[o,s,c,l]of[[e.x,t,r.x,r.x+r.width],[e.y,n,r.y,r.y+r.height]]){if(Math.abs(s)<1e-12){if(o<c||o>l)return;continue}let e=(c-o)/s,t=(l-o)/s;i=Math.max(i,Math.min(e,t)),a=Math.min(a,Math.max(e,t))}return a>=i?[i,a]:void 0}function nu(e,t,n,r,i){let a=e,o=i(e,t)??``,s=t,c=0,l,{texts:u}=n,d=()=>{if(o===``){l?.remove(),l=void 0,u?.hold(void 0);return}let{at:e,anchor:t,toward:i}=ql(a,u&&{held:u.held(),box:e=>u.box(o,e)});u?.hold(u.box(o,{at:e,anchor:t}));let s={at:tt(e,i-Math.PI/2,-8*(1-c)),anchor:t,color:r,opacity:c};l?l.update(s,o):l=n.layer.text(o,s)};return n.onChange((e,t)=>{a=e,s=t??s,o=i(a,s)??``,d()}),d(),e=>{c=e,d()}}let ru=e=>{let{samples:t}=e;return t[t.length-1]?.value??NaN},iu,au=e=>(iu??(iu=new Intl.NumberFormat(void 0,{signDisplay:`always`,maximumFractionDigits:2})),iu.format(e));function ou(e={}){su(e);let t=e.value??ru,n=e.format??au,r=e.color??`text`,i=e=>{if(!e.previous)return;let r=t(e),i=t(e.previous),a=r-i;if(!(!Number.isFinite(a)||Math.abs(a)<=1e-9*Math.max(Math.abs(r),Math.abs(i))))return n(a)};return{kind:`data`,run:async(e,t,n)=>{if(n.signal.aborted)return;let a=i(t);if(a===void 0||a===``)return;let o=nu(e,t,n,r,()=>a);await n.tween({duration:400,timing:`effect`,update:o}).finished},end:(e,t,n)=>{let a=i(t);a!==void 0&&a!==``&&nu(e,t,n,r,()=>a)(1)},clear(){}}}function su(e){let{value:t,format:n,color:r}=e;if(t!==void 0&&typeof t!=`function`)throw TypeError(`delta: value must be a function that reads the mark's value from its data, got ${typeof t}.`);if(n!==void 0&&typeof n!=`function`)throw TypeError(`delta: format must be a function that words the change, got ${typeof n}.`);if(r!==void 0&&(typeof r!=`string`||r===``))throw RangeError(`delta: color must be a theme token or a CSS colour, got ${JSON.stringify(r)??String(r)}.`)}function cu(e,t={}){if(typeof e!=`function`)throw TypeError(`label needs a function that returns the text from the mark's data, got ${typeof e}.`);let{color:n=`text`}=t;if(typeof n!=`string`||n===``)throw RangeError(`label: color must be a theme token or a CSS colour, got ${JSON.stringify(n)??String(n)}.`);let r=(t,n)=>{let r=e(n,t);return r==null?void 0:String(r)};return{kind:`data`,run:async(e,t,i)=>{if(i.signal.aborted)return;let a=nu(e,t,i,n,r);await i.tween({duration:400,timing:`effect`,update:a}).finished},end:(e,t,i)=>nu(e,t,i,n,r)(1),clear(){}}}let lu=[`below`,`above`];function uu(e){yu(e);let{compareTo:t}=e,n=e.when??`below`,r=e.color??`negative`,i=(e,i,a)=>{let o=[],s=i,c=e=>{let i=e.length>=.5?gu(s.samples,du(t,s),n):[],c={stroke:r,width:e.thickness,linecap:`butt`};i.forEach(([t,n],r)=>{let i=e.slice(t,n),s=o[r];s?s.update(i,c):o.push(a.layer.path(i,c))});for(let e of o.splice(i.length))e.remove()};a.onChange((e,t)=>{s=t??s,c(e)}),c(e)};return{kind:`data`,...typeof t==`string`?{needs:Object.freeze({related:Object.freeze([t])})}:{},run:async(e,t,n)=>{n.signal.aborted||i(e,t,n)},end:(e,t,n)=>i(e,t,n),clear(){}}}function du(e,t){if(typeof e==`number`)return{place:e=>e.t,valueAt:()=>e,bends:[]};let n=t.related(e);if(!n)return;let r=t.samples.every(e=>mu(e.at)!==void 0)&&n.samples.every(e=>mu(e.at)!==void 0)?e=>mu(e.at):e=>e.t,i=n.samples.map(e=>({u:r(e),value:e.value})).filter(e=>Number.isFinite(e.u)).sort((e,t)=>e.u-t.u),a=fu(n.samples,r);return{place:r,valueAt:e=>pu(a,e)?void 0:hu(i,e),bends:i.map(e=>e.u)}}function fu(e,t){let n=[];e.forEach((r,i)=>{let a=e[i-1];if(r.gapBefore!==!0||!a)return;let o=t(a),s=t(r);Number.isFinite(o)&&Number.isFinite(s)&&o!==s&&n.push([Math.min(o,s),Math.max(o,s)])}),n.sort((e,t)=>e[0]-t[0]);let r=[];for(let e of n){let t=r[r.length-1];t&&e[0]<t[1]?t[1]=Math.max(t[1],e[1]):r.push(e)}return r}function pu(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i][0]<t?n=i+1:r=i}let i=e[n-1];return i!==void 0&&t<i[1]}function mu(e){let t=typeof e==`number`?e:e instanceof Date?e.getTime():void 0;return t!==void 0&&Number.isFinite(t)?t:void 0}function hu(e,t){let n=e[0],r=e[e.length-1];if(!n||!r||t<n.u||t>r.u)return;let i=0,a=e.length-1;for(;i<a;){let n=i+a>>1;e[n].u<t?i=n+1:a=n}let o=e[i];if(i===0||o.u===t)return o.value;let s=e[i-1];return s.value+(t-s.u)/(o.u-s.u)*(o.value-s.value)}function gu(e,t,n){if(!t)return[];let r=n===`below`?1:-1,i=(e,n,i,a=!0)=>{let o=t.valueAt(n);if(o===void 0||!Number.isFinite(o)||!Number.isFinite(i)||!Number.isFinite(e))return{t:e,u:n,past:void 0,joined:a};let s=r*(o-i);return{t:e,u:n,past:Math.abs(s)<=1e-9*Math.max(Math.abs(o),Math.abs(i))?0:s,joined:a}},a=[];e.forEach((n,r)=>{let o=t.place(n);a.push(i(n.t,o,n.value,n.gapBefore!==!0));let s=e[r+1];if(!s||s.gapBefore===!0)return;let c=t.place(s);if(o===c||!Number.isFinite(o)||!Number.isFinite(c))return;let l=[],{bends:u}=t;for(let e=vu(u,Math.min(o,c));e<u.length&&u[e]<Math.max(o,c);e++)l.push((u[e]-o)/(c-o));c<o&&l.reverse();for(let e of l)a.push(i(n.t+e*(s.t-n.t),o+e*(c-o),n.value+e*(s.value-n.value)))});let o=[],s=(e,t)=>{let n=_u(e),r=_u(t);if(!(r>n))return;let i=o[o.length-1];i&&i[1]>=n?i[1]=Math.max(i[1],r):o.push([n,r])};for(let e=1;e<a.length;e++){let n=a[e-1],r=a[e];n.past!==void 0&&r.past!==void 0&&r.joined&&r.t>n.t&&(n.u===r.u||t.valueAt((n.u+r.u)/2)!==void 0)&&(n.past>0&&r.past>0?s(n.t,r.t):n.past>0?s(n.t,n.t+(r.t-n.t)*(n.past/(n.past-r.past))):r.past>0&&s(n.t+(r.t-n.t)*(n.past/(n.past-r.past)),r.t))}return o}let _u=e=>Math.min(1,Math.max(0,e));function vu(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>1;e[i]<=t?n=i+1:r=i}return n}function yu(e){let{compareTo:t,when:n,color:r}=e??{};if(!(typeof t==`string`?t!==``:typeof t==`number`&&Number.isFinite(t)))throw RangeError(`threshold: compareTo must be a finite number or a series name, got ${bu(t)}.`);if(n!==void 0&&!lu.includes(n))throw RangeError(`threshold: when must be "below" or "above", got ${bu(n)}.`);if(r!==void 0&&(typeof r!=`string`||r===``))throw RangeError(`threshold: color must be a theme token or a CSS colour, got ${bu(r)}.`)}let bu=e=>typeof e==`string`?JSON.stringify(e):String(e);function xu(e={}){Su(e);let t={stroke:e.color??`text`,width:e.width??2},n=(e,n)=>{let r=n.layer.path(e.outline.d,t);n.onChange(e=>r.update(e.outline.d))};return{kind:`geometry`,async run(e,t){t.signal.aborted||n(e,t)},end:n,clear(){}}}function Su(e){let{color:t,width:n}=e;if(t!==void 0&&(typeof t!=`string`||t===``))throw RangeError(`outline: color must be a theme token or a CSS colour, got ${JSON.stringify(t)??String(t)}.`);if(n!==void 0&&!(typeof n==`number`&&n>0&&Number.isFinite(n)))throw RangeError(`outline: width must be more than 0 px, got ${String(n)}.`)}function Cu(e){if(!(typeof e==`number`&&e>=0&&Number.isFinite(e)))throw RangeError(`wait: duration must be 0 ms or more, got ${String(e)}.`);return{kind:`geometry`,async run(t,n){n.signal.aborted||await n.tween({duration:e,timing:`effect`,update(){}}).finished},end(){},clear(){}}}let wu=[`unroll`,`drop`],Tu=.01;function Eu(e={}){sd(e);let t=e?.points??160,n=e?.align??`unroll`;return{kind:`transition`,async run(e,r,i){if(i.signal.aborted)return;let a=Du(e,r,i.layer,t,n),c=od(i.start);if(c>=1){a(1);return}let u=l(c),d;d=i.tween({duration:950,timing:`transition`,ease:o,update:e=>{let t=Math.min(1,u+e);a(e===0?c:s(t)),t>=1&&e<1&&d?.finish()}}),await d.finished},end(e,r,i){Du(e,r,i.layer,t,n)(1)},clear(){}}}function Du(e,t,n,r,i){let a=e.outline.closed;if(a!==t.outline.closed)return td(e,t,n);let o=a?void 0:Nu(e,t,r);if(o)return Au(e,t,n,o.stops,o.kinds);let s=a?zu(e,t,r):void 0,c=s?.from??e.outline.sample(r),l=s?.to??t.outline.sample(r);if(!a)return e.gaps?.length||t.gaps?.length?ku(e,t,n,c,l):Ou(e,t,n,c,l);let[u,d]=!s&&i===`drop`?ad(e,t,r):[0,0],f=Hu(e,t,c,l,[u,d],r/4),p;return r=>{let i=r<=0?e.outline.d:r>=1?t.outline.d:nd(c,l,u,d,r,!0)+f.map(e=>Gu(e,r)).join(``);p?p.update(i):p=n.path(i,{fill:`mark`})}}function Ou(e,t,n,r,i){let a;return o=>{let s=o<=0?e.outline.d:o>=1?t.outline.d:nd(r,i,0,0,o,!1),c=o<=0?e.thickness:o>=1?t.thickness:id(e.thickness,t.thickness,o);a?a.update(s,{width:c}):a=n.path(s,{stroke:`mark`,width:c})}}function ku(e,t,n,r,i){let a=r.length,o=r.map((e,t)=>({t:t/(a-1),from:e,to:i[t]}));for(let n of[...e.gaps??[],...t.gaps??[]])for(let r of n)r>0&&r<1&&o.every(e=>Math.abs(e.t-r)>1e-9)&&o.push({t:r,from:e.path(r),to:t.path(r)});return o.sort((e,t)=>e.t-t.t),Au(e,t,n,o,o.slice(1).map((n,r)=>{let i=(o[r].t+n.t)/2;return+!!ju(e,i)+(ju(t,i)?2:0)}))}function Au(e,t,n,r,i){let a=[[],[],[]];for(let e=0;e<i.length;e++){let t=i[e];if(t===3)continue;let n=a[t][a[t].length-1];n&&n[1]===e?n[1]=e+1:a[t].push([e,e+1])}let o=[0,1,2].filter(e=>a[e].length>0).sort((e,t)=>a[e][0][0]-a[t][0][0]),s=[];return i=>{let c=i<=0?e.thickness:i>=1?t.thickness:id(e.thickness,t.thickness,i),l=[void 0,i,1-i],u=i<=0||i>=1?[[i<=0?e.outline.d:t.outline.d,void 0]]:o.map(e=>[a[e].map(e=>Mu(r,e,i)).join(``),l[e]]);u.forEach(([e,t],r)=>{s[r]?s[r].update(e,{width:c,opacity:t}):s[r]=n.path(e,{stroke:`mark`,width:c,...t===void 0?{}:{opacity:t}})});for(let e of s.splice(u.length))e.remove()}}let ju=(e,t)=>(e.gaps??[]).some(([e,n])=>e<t&&t<n);function Mu(e,[t,n],r){let i=``;for(let a=t;a<=n;a++)i+=`${a===t?`M`:`L`}${rd(e[a].from,e[a].to,r)}`;return i}function Nu(e,t,n){let r=Fu(e),i=r&&Fu(t);if(r&&i&&r.way===i.way)return Pu(r,i,n)}function Pu(e,t,n){let r=[...Array.from({length:n},(e,t)=>[t/(n-1),0]),...Lu(e).map(e=>[e,1]),...Lu(t).map(e=>[e,2])].sort((e,t)=>e[0]-t[0]),i=Tu/Math.max(Math.abs(e.span),Math.abs(t.span)),a=[];for(let[e,t]of r){var o,s;let n=a[a.length-1];(!n||e-n[0]>i||t>0&&n[t]!==void 0)&&a.push(n=[e]),t===1&&((o=n)[1]??(o[1]=e)),t===2&&((s=n)[2]??(s[2]=e))}let c=a.length-1;if(c<1)return;let l=e=>a.map((t,n)=>n===0?0:n===c?1:t[e]??t[0]),[u,d]=[l(1),l(2)],[f,p]=[Ru(e,u),Ru(t,d)],m=a.map(([e],t)=>({t:e,from:f[t],to:p[t]})),[h,g]=[Vu(e.gaps),Vu(t.gaps)];return{stops:m,kinds:m.slice(1).map((e,t)=>+!!h((u[t]+u[t+1])/2)+(g((d[t]+d[t+1])/2)?2:0))}}function Fu(e){let t=Ce(je(e.outline.d)),n=[],r=[],i=0,a=0,o=r=>{if(!(r>a))return n.push(e.path(a)),!0;let o=t[i++];if(!o)return!1;n.push(o.start);for(let e of o.segments){if(e.kind!==`line`)return!1;n.push(e.to)}return!0};for(let[t,i]of e.gaps??[]){if(!o(t))return;r.push(n.length-1),a=i}return!o(1)||i<t.length||n.length<2?void 0:Iu(n,r)}function Iu(e,t=[]){let n=e[0].x,r=e[e.length-1].x-n,i=Math.sign(r);for(let t=1;t<e.length;t++)if(!((e[t].x-e[t-1].x)*i>0))return;let a=e.map(e=>(e.x-n)/r);return{points:e,shares:a,gaps:t.map(e=>[a[e],a[e+1]]),span:r,way:i}}function Lu(e){let{points:t,shares:n,gaps:r}=e;if(t.length<=1e3)return n;let i=e=>Math.min(249,Math.floor(n[e]*250)),a=r.flat();for(let e=0,r=1;r<=t.length;r++){if(r<t.length&&i(r)===i(e))continue;let[o,s]=[e,e];for(let n=e;n<r;n++)t[n].y<t[o].y&&(o=n),t[n].y>t[s].y&&(s=n);a.push(n[e],n[o],n[s],n[r-1]),e=r}return Array.from(new Set(a))}function Ru(e,t){let{points:n,shares:r}=e,i=0;return t.map(e=>{for(;i+2<n.length&&r[i+1]<=e;)i++;let t=r[i+1]-r[i];return Ku(n[i],n[i+1],t>0?Math.min(1,Math.max(0,(e-r[i])/t)):0)})}function zu(e,t,n){let r=Bu(e.outline),i=r&&Bu(t.outline);if(!r||!i||Math.abs(r.left-i.left)>Tu||Math.abs(r.right-i.right)>Tu)return;let a=Pu(r.upper,i.upper,n),o=Pu(r.lower,i.lower,n);if(!a||!o)return;let s=[...a.stops,...o.stops];return{from:s.map(e=>e.from),to:s.map(e=>e.to)}}function Bu(e){let t=Qu(e),n=[];for(let e of t[$u(t)]??[]){if(e.kind!==`line`)return;n.push(e.to)}ed(n)<0&&n.reverse();let r=n.reduce((e,t)=>Math.min(e,t.x),1/0),i=n.reduce((e,t)=>Math.max(e,t.x),-1/0);if(!(i-r>2*Tu))return;let a=e=>e.x-r<=Tu,o=e=>i-e.x<=Tu,s=n.findIndex((e,t)=>a(e)&&!a(n[(t+1)%n.length])),c=[...n.slice(s),...n.slice(0,s+1)],l=c.findIndex(o),u=l;for(;o(c[u+1]);)u++;let d=c.findIndex((e,t)=>t>u&&a(e));if(c.slice(d).some(e=>!a(e)))return;let f=Iu(c.slice(0,l+1)),p=Iu(c.slice(u,d+1));return f&&p&&f.points.length>2&&p.points.length>2?{upper:f,lower:p,left:r,right:i}:void 0}function Vu(e){let t=0;return n=>{for(;t<e.length&&e[t][1]<=n;)t++;return t<e.length&&e[t][0]<n}}function Hu(e,t,n,r,[i,a],o){let s=Zu(e.outline,o),c=Zu(t.outline,o),l=Math.min(s.length,c.length),u=s.slice(0,l).map((e,t)=>({from:e.points,to:c[t].points})),d=s.length>c.length,[f,p,m,h,g,_,v]=d?[s,c,t,n,r,i,a]:[c,s,e,r,n,a,i],y=h.length,b=h.map((e,t)=>[h[(t+_)%y],g[(t+v)%y]]),x=f.slice(0,l).map((e,t)=>e.points.map((e,n)=>[e,p[t].points[n]])),S=[g,...p.map(e=>e.points)];for(let n of f.slice(l)){let{end:r,point:i}=Uu(n,qu(n,(d?e:t).bounds,m,S),b,x),a=Array(o).fill(i);u.push(d?{from:n.points,to:a,end:r}:{from:a,to:n.points,end:r,opens:!0})}return u}function Uu(e,t,n,r){let i=.5;for(;i>1/16&&!Wu(e,Ku(e.center,t,i),i,n,r);)i/=2;return{end:i,point:Ku(e.center,t,i)}}function Wu(e,t,n,r,i){for(let a=1;a<8;a++){let o=n*a/8,s=e=>Ku(e[0],e[1],o),c=[r.map(s),...i.map(e=>e.map(s))];if(e.points.some(e=>Yu(Ku(e,t,a/8),c)===0))return!1}return!0}function Gu({from:e,to:t,end:n,opens:r},i){if(n===void 0)return nd(e,t,0,0,i,!0);let a=r?(i-(1-n))/n:i/n;return(r?a<=0:a>=1)?``:nd(e,t,0,0,a,!0)}let Ku=(e,t,n)=>({x:id(e.x,t.x,n),y:id(e.y,t.y,n)});function qu(e,t,n,r){let i=Xu(e.center,t,n.bounds);if(Ju(i,r)>=e.size/4)return i;let{x:a,y:o,width:s,height:c}=n.bounds,l=n.center,u=Ju(l,r);for(let e=0;e<9;e++)for(let t=0;t<9;t++){let n={x:a+s*(e+.5)/9,y:o+c*(t+.5)/9},i=Ju(n,r);i>u&&([l,u]=[n,i])}return l}function Ju(e,t){if(Yu(e,t)===0)return 0;let n=1/0;for(let r of t)r.forEach((t,i)=>{let a=r[(i+1)%r.length],o=a.x-t.x,s=a.y-t.y,c=o===0&&s===0?0:Math.max(0,Math.min(1,((e.x-t.x)*o+(e.y-t.y)*s)/(o*o+s*s)));n=Math.min(n,Math.hypot(e.x-t.x-c*o,e.y-t.y-c*s))});return n}function Yu(e,t){let n=0;for(let r of t)r.forEach((t,i)=>{let a=r[(i+1)%r.length],o=(a.x-t.x)*(e.y-t.y)-(e.x-t.x)*(a.y-t.y);t.y<=e.y&&a.y>e.y&&o>0?n++:t.y>e.y&&a.y<=e.y&&o<0&&n--});return n}function Xu(e,t,n){let r=(e,t,n)=>n>0?(e-t)/n:.5;return{x:n.x+r(e.x,t.x,t.width)*n.width,y:n.y+r(e.y,t.y,t.height)*n.height}}function Zu(e,t){let n=Qu(e);if(n.length<2)return[];let r=$u(n);return n.filter((e,t)=>t!==r).map(e=>{let n=ne([e]).sample(4*t),r=n.filter((e,t)=>t%4==0),i=I(e.flatMap(F));return{points:[r[0],...r.slice(1).reverse()],area:Math.abs(ed(n)),center:{x:i.x+i.width/2,y:i.y+i.height/2},size:Math.max(i.width,i.height)/2}}).sort((e,t)=>t.area-e.area)}let Qu=e=>Ce(je(e.d)).map(e=>e.segments).filter(e=>e.length>0);function $u(e){let t=e.map(e=>e.reduce((e,t)=>e+t.length,0)),n=0;return t.forEach((e,r)=>{e>t[n]+Math.max(.01,t[n]/1e3)&&(n=r)}),n}function ed(e){let t=0;return e.forEach((n,r)=>{let i=e[(r+1)%e.length];t+=n.x*i.y-i.x*n.y}),t/2}function td(e,t,n){let r=(e,t)=>({...e.outline.closed?{fill:`mark`}:{stroke:`mark`,width:e.thickness},...t===void 0?{}:{opacity:t}}),i,a;return o=>{o>=1?(i?.remove(),i=void 0,a?a.update(t.outline.d,{opacity:void 0}):a=n.path(t.outline.d,r(t))):a?(i?.update(e.outline.d,{opacity:1-o}),a.update(t.outline.d,{opacity:o})):e.outline.closed?(i=n.path(e.outline.d,r(e,1-o)),a=n.path(t.outline.d,r(t,o))):(a=n.path(t.outline.d,r(t,o)),i=n.path(e.outline.d,r(e,1-o)))}}function nd(e,t,n,r,i,a){let o=e.length,s=``;for(let a=0;a<o;a++)s+=`${a===0?`M`:`L`}${rd(e[(a+n)%o],t[(a+r)%o],i)}`;return a?`${s}Z`:s}let rd=(e,t,n)=>`${L(id(e.x,t.x,n))},${L(id(e.y,t.y,n))}`,id=(e,t,n)=>e*(1-n)+t*n;function ad(e,t,n){let r=n/4,i=lo(e);return i===lo(t)?[0,0]:i?[0,r]:[r,0]}function od(e){return typeof e==`number`&&e>0?Math.min(1,e):0}function sd(e){let{points:t,align:n}=e??{};if(t!==void 0&&!(Number.isInteger(t)&&t>=4&&t%4==0))throw RangeError(`morph: points must be a whole multiple of 4, got ${String(t)}.`);if(n!==void 0&&!wu.includes(n))throw RangeError(`morph: align must be "unroll" or "drop", got ${typeof n==`string`?JSON.stringify(n):String(n)}.`)}function cd(...e){let t=md(`sequence`,e);return pd(t,async(e,n)=>{for(let r of t){if(n.signal.aborted)return;await e(r)}})}function ld(...e){let t=md(`parallel`,e);return pd(t,async e=>{await Promise.all(t.map(e))})}function ud(e,t){if(typeof e!=`string`&&typeof e!=`function`)throw TypeError(`only needs a key, a series name or a predicate, got ${dt(e)}.`);let[n]=md(`only`,[t]),r=typeof e==`string`?t=>t.key===e||t.series===e:e;if(n.kind===`data`){let e=n;return{kind:`data`,...e.needs?{needs:e.needs}:{},run:(t,n,i)=>r(t)?e.run(t,n,i):Promise.resolve(),end:(t,n,i)=>{r(t)&&e.end(t,n,i)},clear:t=>e.clear(t)}}let i=n;return{kind:`geometry`,run:(e,t)=>r(e)?i.run(e,t):Promise.resolve(),end(e,t){r(e)&&i.end(e,t)},clear:e=>i.clear(e)}}function dd(e,t={}){let[n]=md(`stagger`,[e]),r=t.delay??50;if(!(typeof r==`number`&&r>=0&&Number.isFinite(r)))throw RangeError(`stagger: delay must be 0 ms or more, got ${String(r)}.`);let i=async(e,t,n)=>{if(n.signal.aborted)return;let{index:i,count:a}=n.batch,o=a>1?Math.min(r,500/(a-1)):0,s=i>0?i*o:0;if(!(s>0))return{mark:e,data:t};let c=fd(e,t,n);return await n.tween({duration:s,timing:`stagger`,update:()=>{}}).finished,n.signal.aborted?void 0:c()};if(n.kind===`data`){let e=n;return{kind:`data`,...e.needs?{needs:e.needs}:{},run:async(t,n,r)=>{let a=await i(t,n,r);a&&await e.run(a.mark,a.data,r)},end:(t,n,r)=>e.end(t,n,r),clear:t=>e.clear(t)}}let a=n;return{kind:`geometry`,async run(e,t){let n=await i(e,void 0,t);n&&await a.run(n.mark,t)},end:(e,t)=>a.end(e,t),clear:e=>a.clear(e)}}function fd(e,t,n){let r={mark:e,data:t};return n.onChange((e,t)=>{r={mark:e,data:t??r.data}}),()=>r}function pd(e,t){let n=(e,t,n)=>{let r=fd(e,t,n);return e=>{let{mark:t,data:i}=r();return e.kind===`data`?e.run(t,i,n):e.run(t,n)}},r=(t,n,r)=>{for(let i of e)i.kind===`data`?i.end(t,n,r):i.end(t,r)},i=t=>{let n;for(let r of e)try{r.clear(t)}catch(e){n??(n={error:e})}if(n)throw n.error};if(e.some(e=>e.kind===`data`)){let a=[...new Set(e.flatMap(e=>e.kind===`data`?e.needs?.related??[]:[]))];return{kind:`data`,...a.length>0?{needs:{related:a}}:{},run:(e,r,i)=>t(n(e,r,i),i),end:(e,t,n)=>r(e,t,n),clear:i}}return{kind:`geometry`,run:(e,r)=>t(n(e,void 0,r),r),end:(e,t)=>r(e,void 0,t),clear:i}}function md(e,t){return t.forEach((t,n)=>{if(!ut(t))throw TypeError(`${e}: part ${n+1} needs to be a mark effect (kind "geometry" or "data"), got ${dt(t)}.`)}),[...t]}let hd=()=>{};function gd(e){vd(`defineEffect`,e);let t={kind:`geometry`,run:e.run,end:e.end,clear:e.clear??hd};return Object.freeze(t)}function _d(e){vd(`defineDataEffect`,e);let t=yd(e.needs),n={kind:`data`,...t?{needs:t}:{},run:e.run,end:e.end,clear:e.clear??hd};return Object.freeze(n)}function vd(e,t){if(typeof t!=`object`||!t)throw TypeError(`${e} needs a spec object { run, end }, got ${t===null?`null`:typeof t}.`);let{run:n,end:r,clear:i}=t;if(typeof n!=`function`)throw TypeError(`${e}: run must be a function that animates the mark, got ${typeof n}.`);if(typeof r!=`function`)throw TypeError(`${e}: end must be a function that draws the final state, got ${typeof r}. Every effect needs one: reduced motion shows only end states.`);if(i!==void 0&&typeof i!=`function`)throw TypeError(`${e}: clear must be a function if it's given, got ${typeof i}.`)}function yd(e){if(e===void 0)return;let t=typeof e==`object`&&e?e.related:void 0;if(!(typeof e==`object`&&e&&(t===void 0||Array.isArray(t)&&t.every(e=>typeof e==`string`&&e!==``))))throw TypeError(`defineDataEffect: needs must be { related: [series names] }, got ${JSON.stringify(e)??String(e)}.`);return t===void 0?void 0:Object.freeze({related:Object.freeze([...t])})}let bd=[`roll`,`step`,`slide`],xd=[`butt`,`round`,`square`],Sd=[`miter`,`round`,`bevel`],Cd=[`nonzero`,`evenodd`],wd=/^\s*[Mm][MmLlHhVvCcSsQqTtAaZz0-9eE.,+\-\s]*$/;function Td(e){let t=e?.name;if(typeof t!=`string`||t===``)throw TypeError(`defineIcon needs a non-empty string name, got ${JSON.stringify(t)}.`);let n=(e,n)=>{throw RangeError(`defineIcon: "${t}" ${e} ${n}.`)},r=(e,t)=>typeof t==`number`&&Number.isFinite(t)?t:n(e,`must be a finite number, got ${String(t)}`),i=(e,t)=>r(e,t)>0?t:n(e,`must be more than 0, got ${String(t)}`),a=(e,t)=>t&&typeof t==`object`?Dd({x:r(`${e}.x`,t.x),y:r(`${e}.y`,t.y)}):n(e,`must be a point { x, y }`);Array.isArray(e.shapes)&&e.shapes.length!==0||n(`shapes`,`must be a non-empty array`);let o=e.shapes.map((e,t)=>Ed(e,`shapes[${t}]`,n,r)),s=e.box;s&&typeof s==`object`||n(`box`,`must be a rectangle { x, y, width, height }`);let c=Dd({x:r(`box.x`,s.x),y:r(`box.y`,s.y),width:i(`box.width`,s.width),height:i(`box.height`,s.height)}),l=a(`anchor`,e.anchor),u=e.pivot===void 0?l:a(`pivot`,e.pivot),d=e.footprint??[Math.max(0,l.x-c.x),Math.max(0,c.x+c.width-l.x)];Array.isArray(d)&&d.length===2||n(`footprint`,`must be [behind, ahead]`),d.forEach((e,t)=>{r(`footprint[${t}]`,e)<0&&n(`footprint[${t}]`,`can't be negative, got ${e}`)});let f=e.size===void 0?c.width:i(`size`,e.size),p=e.radius===void 0?c.height/2:i(`radius`,e.radius);return e.gait!==void 0&&!bd.includes(e.gait)&&n(`gait`,`must be roll, step or slide, got ${String(e.gait)}`),e.upright!==void 0&&typeof e.upright!=`boolean`&&n(`upright`,`must be true or false, got ${String(e.upright)}`),Dd({name:t,shapes:Dd(o),box:c,size:f,anchor:l,pivot:u,footprint:Dd([d[0],d[1]]),...e.gait===void 0?{}:{gait:e.gait},radius:p,...e.upright===void 0?{}:{upright:e.upright}})}function Ed(e,t,n,r){e&&typeof e==`object`||n(t,`must be a shape { d, fill?, stroke?, … }`),typeof e.d==`string`&&wd.test(e.d)||n(`${t}.d`,`must be path data starting with a move`),e.clip===void 0||typeof e.clip==`string`&&wd.test(e.clip)||n(`${t}.clip`,`must be path data starting with a move`);for(let r of[`fill`,`stroke`]){let i=e[r];i!==void 0&&(typeof i!=`string`||i===``)&&n(`${t}.${r}`,`must be a colour, got ${String(i)}`)}e.width!==void 0&&r(`${t}.width`,e.width)<0&&n(`${t}.width`,`can't be negative, got ${e.width}`),e.linecap!==void 0&&!xd.includes(e.linecap)&&n(`${t}.linecap`,`must be butt, round or square, got ${String(e.linecap)}`),e.linejoin!==void 0&&!Sd.includes(e.linejoin)&&n(`${t}.linejoin`,`must be miter, round or bevel, got ${String(e.linejoin)}`),e.fillRule!==void 0&&!Cd.includes(e.fillRule)&&n(`${t}.fillRule`,`must be nonzero or evenodd, got ${String(e.fillRule)}`);for(let i of[`opacity`,`fillOpacity`,`strokeOpacity`]){let a=e[i]===void 0?1:r(`${t}.${i}`,e[i]);(a<0||a>1)&&n(`${t}.${i}`,`must be from 0 to 1, got ${a}`)}let i={d:e.d};for(let t of[`fill`,`stroke`,`width`,`linecap`,`linejoin`,`clip`,`fillRule`,`opacity`,`fillOpacity`,`strokeOpacity`])e[t]!==void 0&&(i[t]=e[t]);return Dd(i)}let Dd=e=>Object.freeze(e),Od=new Set([`svg`,`g`,`a`]),kd=new Set([`path`,`circle`,`rect`,`ellipse`,`line`,`polyline`,`polygon`]),Ad=/<![^<>]*>|<(\/?)([A-Za-z][\w:.-]*)((?:\s+[^\s=/<>]+(?:\s*=\s*(?:"[^"<]*"|'[^'<]*'|[^\s"'<>]+))?)*)\s*(\/?)>/g,jd=/([^\s=/<>]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'<>]+)))?/g,Md=/^(?:#[0-9a-fA-F]{3,8}|[a-zA-Z][a-zA-Z0-9-]*|(?:rgba?|hsla?)\([\d\s.,%+\-/]*\))$/;function Nd(e,t){if(typeof e!=`string`)throw TypeError(`iconFromSvg needs SVG markup as a string.`);let n=typeof t?.name==`string`?`"${t.name}"`:`an icon`,r=e=>{throw RangeError(`iconFromSvg: ${n} ${e}.`)},i,a=1,o=[],s=[],c;for(let n of Pd(e).matchAll(Ad)){let[,e,l,u=``,d]=n;if(l===void 0)continue;let f=l.toLowerCase();if(e){let e=Hd(s,f);e>=0&&(s.length=e);continue}let p=Fd(u),m=!i&&f===`svg`;m&&(i=Id(p)??r(`needs a viewBox, or a width and height in px, on its <svg>`),t.size!==void 0&&(typeof t.size==`number`&&t.size>0&&Number.isFinite(t.size)||r(`size must be more than 0, got ${String(t.size)}`),a=t.size/i.width),c={fill:`#000000`,stroke:`none`,width:1,linecap:void 0,linejoin:void 0,fillRule:`nonzero`,opacity:1,fillOpacity:1,strokeOpacity:1,transform:q.scale(a)});let h=s.length>0?s[s.length-1].state:m?c:void 0,g=h&&!zd(p)?Bd(h,p):void 0;if(g&&kd.has(f)){let e=Vd(f,p,g);e&&o.push(e)}d||s.push({tag:f,state:Od.has(f)?g:void 0})}i||r(`needs an <svg> element`),o.length===0&&r(`has nothing to draw: no path, circle, rect, ellipse, line, polyline or polygon with a fill or stroke`);let l={x:i.x*a,y:i.y*a,width:i.width*a,height:i.height*a},u=e=>e&&typeof e==`object`?{x:e.x*a,y:e.y*a}:e;return Td({...t,shapes:o,box:l,anchor:u(t.anchor),...t.pivot?{pivot:u(t.pivot)}:{},...Array.isArray(t.footprint)?{footprint:[t.footprint[0]*a,t.footprint[1]*a]}:{},...typeof t.radius==`number`?{radius:t.radius*a}:{}})}function Pd(e){let t=[[`<!--`,`-->`],[`<![CDATA[`,`]]>`],[`<?`,`?>`]],n=t.map(([t])=>e.indexOf(t)),r=``,i=0;for(;;){let a=-1;if(n.forEach((e,t)=>{e>=0&&(a<0||e<n[a])&&(a=t)}),a<0)return r+e.slice(i);let o=n[a],s=t[a][1];r+=e.slice(i,o);let c=e.indexOf(s,o+t[a][0].length);if(c<0)return r;i=c+s.length,n.forEach((r,a)=>{r>=0&&r<i&&(n[a]=e.indexOf(t[a][0],i))})}}function Fd(e){let t=new Map;for(let[,n,r,i,a]of e.matchAll(jd))n!==void 0&&t.set(n,r??i??a??``);for(let e of(t.get(`style`)??``).split(`;`)){let n=e.indexOf(`:`);n>0&&t.set(e.slice(0,n).trim(),e.slice(n+1).replace(/!important/i,``).trim())}return t}function Id(e){let t=(e.get(`viewBox`)??``).trim().split(/[\s,]+/).map(Number);if(t.length===4&&t.every(Number.isFinite)&&t[2]>0&&t[3]>0)return{x:t[0],y:t[1],width:t[2],height:t[3]};let n=Ld(e.get(`width`)),r=Ld(e.get(`height`));return n!==void 0&&r!==void 0?{x:0,y:0,width:n,height:r}:void 0}function Ld(e){let t=/^\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)\s*(?:px\s*)?$/i.exec(e??``),n=t?Number(t[1]):NaN;return n>0&&Number.isFinite(n)?n:void 0}function Rd(e){let t=/^\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?)(%?)\s*$/i.exec(e??``);return t?Math.min(1,Math.max(0,Number(t[1])/(t[2]?100:1))):void 0}function zd(e){return e.get(`display`)?.trim()===`none`||e.get(`visibility`)?.trim()===`hidden`}function Bd(e,t){let n=(e,n)=>{let r=t.get(e)?.trim();if(r===void 0||!Md.test(r))return n;let i=r.toLowerCase();return i===`inherit`?n:i===`currentcolor`?`text`:i===`none`?i:r},r=Number.parseFloat(t.get(`stroke-width`)??``),i=t.get(`stroke-linecap`)?.trim(),a=t.get(`stroke-linejoin`)?.trim(),o=t.get(`fill-rule`)?.trim().toLowerCase(),s=t.get(`transform`);return{fill:n(`fill`,e.fill),stroke:n(`stroke`,e.stroke),width:r>=0?r:e.width,linecap:i===`butt`||i===`round`||i===`square`?i:e.linecap,linejoin:a===`miter`||a===`round`||a===`bevel`?a:e.linejoin,fillRule:o===`nonzero`||o===`evenodd`?o:e.fillRule,opacity:e.opacity*(Rd(t.get(`opacity`))??1),fillOpacity:Rd(t.get(`fill-opacity`))??e.fillOpacity,strokeOpacity:Rd(t.get(`stroke-opacity`))??e.strokeOpacity,transform:s?q.multiply(e.transform,et(s)):e.transform}}function Vd(e,t,n){let r=Ud(n.fillOpacity),i=Ud(n.strokeOpacity),a=n.fill===`none`||!(r>0)?void 0:n.fill,o=n.stroke===`none`||!(n.width>0)||!(i>0)?void 0:n.stroke,s=Ud(n.opacity);if(a===void 0&&o===void 0||!(s>0))return;let c=Pe(e,e=>t.get(e));if(!c.some(e=>e.op!==`M`))return;let l=n.transform;return{d:ze(Le(c,l)),...a===void 0?{}:{fill:a,...n.fillRule===`evenodd`?{fillRule:n.fillRule}:{},...r<1?{fillOpacity:r}:{}},...o===void 0?{}:{stroke:o,width:Ud(n.width*Math.sqrt(Math.abs(l[0]*l[3]-l[1]*l[2]))),...n.linecap?{linecap:n.linecap}:{},...n.linejoin?{linejoin:n.linejoin}:{},...i<1?{strokeOpacity:i}:{}},...s<1?{opacity:s}:{}}}function Hd(e,t){for(let n=e.length-1;n>=0;n--)if(e[n].tag===t)return n;return-1}let Ud=e=>Math.round(e*1e3)/1e3,Wd=Object.freeze({dot:Td({name:`dot`,shapes:[{d:`M4,0A4,4 0 0 1 -4,0A4,4 0 0 1 4,0Z`,fill:`surface`,stroke:`text`,width:1.5}],box:{x:-5,y:-5,width:10,height:10},anchor:{x:0,y:0}}),arrow:Td({name:`arrow`,shapes:[{d:`M-7,-1.5L1,-1.5L1,-5L7,0L1,5L1,1.5L-7,1.5Z`,fill:`text`,stroke:`surface`,width:1.5,linejoin:`round`}],box:{x:-8,y:-6,width:16,height:12},anchor:{x:0,y:0}}),chevron:Td({name:`chevron`,shapes:[{d:`M-2.5,-5L2.5,0L-2.5,5`,stroke:`surface`,width:4.5,linecap:`round`,linejoin:`round`},{d:`M-2.5,-5L2.5,0L-2.5,5`,stroke:`text`,width:2,linecap:`round`,linejoin:`round`}],box:{x:-5,y:-7.5,width:10,height:15},anchor:{x:0,y:0}})}),Gd=st({kind:`preset`,entries:{flash:()=>Ol(),wiggle:()=>Pl(),pulse:()=>Rl()},hint:`Register custom presets with registerPreset(name, factory).`}),Kd=st({kind:`icon`,entries:Wd,hint:`Register icons with registerIcon(icon) or registerIcons(icons).`});function qd(e,t){if(typeof t!=`function`)throw TypeError(`registerPreset("${e}") needs a function that returns an effect.`);Gd.register(e,t)}function Jd(e){if(typeof e!=`object`||!e||typeof e.name!=`string`)throw TypeError(`registerIcon needs an icon with a name.`);Kd.register(e.name,e)}function Yd(e){for(let t of e)Jd(t)}function Xd(e){if(typeof e!=`object`||!e)throw TypeError(`configure needs an options object.`);if(`nonce`in e){if(e.nonce!==void 0&&(typeof e.nonce!=`string`||e.nonce===``))throw TypeError(`configure: nonce must be a non-empty string.`);wn.nonce=e.nonce}if(`injectStyles`in e){if(e.injectStyles!==void 0&&typeof e.injectStyles!=`boolean`)throw TypeError(`configure: injectStyles must be true or false.`);wn.injectStyles=e.injectStyles}}let Zd={presets:Gd,icons:Kd,motion:v};function Qd(e,t){return Wr(e,t,Zd)}function $d(e,t){return xi(e,t,Zd)}function ef(e,t){return Va(e,t,Zd)}function tf(e,t){return Sc(e,typeof t==`object`&&t&&t.transition===void 0?{...t,transition:Eu()}:t,Zd)}function nf(e,t){return Ts(e,t,Zd)}function rf(e,t){return $s(e,t,Zd)}function af(e,t={}){if(arguments[2]!==void 0||typeof t==`object`&&t&&`chooseMode`in t)throw TypeError(`Since 1.0 motionSwitch takes (target, options), with the motion among the options: motionSwitch(target, { motion, ...options }).`);if(typeof t!=`object`||!t)throw TypeError(`motionSwitch: options must be an object, got ${t===null?`null`:typeof t}.`);return tl(e,{...t,motion:t.motion??v})}return e.VERSION=`1.0.0`,e.animated=C,e.barChart=Qd,e.chartSwitch=tf,e.colorAssignment=En,e.configure=Xd,e.createClock=n,e.createMotion=p,e.defaultClock=a,e.defaultScaling=u,e.defineDataEffect=_d,e.defineEffect=gd,e.defineIcon=Td,e.delta=ou,e.describe=Ge,e.donutChart=$d,e.drawIn=Ul,e.easeInOutCubic=s,e.easeOutCubic=c,e.expressive=nf,e.flash=Ol,e.fromVegaView=rf,e.gaits=hl,e.hostView=Ys,e.iconFromSvg=Nd,e.icons=Wd,e.interpolateNumber=b,e.interpolatePoint=x,e.interpolateRecord=S,e.label=cu,e.lineChart=ef,e.linear=o,e.link=Ln,e.manualClock=r,e.matrix=q,e.mediaReducedMotion=h,e.morph=Eu,e.motion=v,e.motionSwitch=af,e.offset=tt,e.only=ud,e.outline=xu,e.parallel=ld,e.playButton=sl,e.playback=w,e.pulse=Rl,e.registerIcon=Jd,e.registerIcons=Yd,e.registerPreset=qd,e.samplesAlong=rt,e.scaleDuration=m,e.sequence=cd,e.stagger=dd,e.threshold=uu,e.trace=Vl,e.travel=yl,e.tween=y,e.wait=Cu,e.wiggle=Pl,e})({});
97
97
  //# sourceMappingURL=expressive-charts.global.js.map