vizmatic 0.7.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import{a as xs}from"./chunk-VZNL6JY2.js";import{b as ws}from"./chunk-SQE76S5B.js";var zt=[1,0,0,1,0,0],ks={x:0,y:0,width:0,height:0},Ms=.5522847498307936,ae=10;function ot(n,t){return[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],n[0]*t[4]+n[2]*t[5]+n[4],n[1]*t[4]+n[3]*t[5]+n[5]]}function Wt(n){let t=n[0]*n[3]-n[1]*n[2];if(Math.abs(t)<1e-12)return zt;let e=1/t;return[n[3]*e,-n[1]*e,-n[2]*e,n[0]*e,(n[2]*n[5]-n[3]*n[4])*e,(n[1]*n[4]-n[0]*n[5])*e]}function Q(n,t,e){return[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]]}function fe(n,t,e,o,r,s,i){let a=e===0?1:Math.cos(e),l=e===0?0:Math.sin(e),c=a*o,u=l*o,h=-l*r,d=a*r;return[c,u,h,d,n-c*s-h*i,t-u*s-d*i]}function Xt(n){return Math.sqrt(Math.abs(n[0]*n[3]-n[1]*n[2]))}function Mt(n,t=!1){return{p:n instanceof Float64Array?n:Float64Array.from(n),closed:t}}function Vt(n){return Math.max(0,(n.p.length-2)/6)}function Ct(n,t,e,o,r){n.push(t+(o-t)/3,e+(r-e)/3,t+(o-t)*2/3,e+(r-e)*2/3,o,r)}function le(n,t){let e=[n[0],n[1]];return Ct(e,n[0],n[1],t[0],t[1]),[Mt(e)]}function Z(n,t=!1){if(n.length===0)return[];let e=n[0],o=[e[0],e[1]];for(let r=1;r<n.length;r++)Ct(o,n[r-1][0],n[r-1][1],n[r][0],n[r][1]);if(t){let r=n[n.length-1];(r[0]!==e[0]||r[1]!==e[1])&&Ct(o,r[0],r[1],e[0],e[1])}return[Mt(o,t)]}function Lt(n,t=!1,e=1/6){let o=n.length;if(o===0)return[];if(o<3)return Z(n,t);let r=a=>t?n[(a+o)%o]:n[Math.max(0,Math.min(o-1,a))],s=[n[0][0],n[0][1]],i=t?o:o-1;for(let a=0;a<i;a++){let l=r(a-1),c=r(a),u=r(a+1),h=r(a+2);s.push(c[0]+(u[0]-l[0])*e,c[1]+(u[1]-l[1])*e,u[0]-(h[0]-c[0])*e,u[1]-(h[1]-c[1])*e,u[0],u[1])}return[Mt(s,t)]}function St(n,t,e,o,r,s){let i=s-r;if(i===0)return[];let a=Math.abs(Math.abs(i)-Math.PI*2)<1e-9,l=Math.max(1,Math.ceil(Math.abs(i)/(Math.PI/4)-1e-9)),c=i/l,u=4/3*Math.tan(c/4),h=[n+Math.cos(r)*e,t+Math.sin(r)*o];for(let d=0;d<l;d++){let m=r+d*c,p=m+c,f=Math.cos(m),b=Math.sin(m),y=Math.cos(p),g=Math.sin(p);h.push(n+(f-u*b)*e,t+(b+u*f)*o,n+(y+u*g)*e,t+(g-u*y)*o,n+y*e,t+g*o)}return a&&(h[h.length-2]=h[0],h[h.length-1]=h[1]),[Mt(h,a)]}function Dt(n,t,e){return St(n,t,e,e,0,Math.PI*2)}function K(n,t,e,o,r=0){let s=Math.max(0,Math.min(r,Math.abs(e)/2,Math.abs(o)/2));if(s===0)return Z([[n,t],[n+e,t],[n+e,t+o],[n,t+o]],!0);let i=s*(1-Ms),a=n+e,l=t+o,c=[n+s,t];return Ct(c,n+s,t,a-s,t),c.push(a-i,t,a,t+i,a,t+s),Ct(c,a,t+s,a,l-s),c.push(a,l-i,a-i,l,a-s,l),Ct(c,a-s,l,n+s,l),c.push(n+i,l,n,l-i,n,l-s),Ct(c,n,l-s,n,t+s),c.push(n,t+i,n+i,t,n+s,t),[Mt(c,!0)]}function _e(n,t,e,o=64){let r=Math.max(2,Math.floor(o)),s=[];for(let i=0;i<=r;i++)s.push(n(t+(e-t)*i/r));return be(s)}function be(n){let t=[],e=[],o=()=>{e.length>=2&&t.push(...Lt(e)),e=[]};for(let r of n)Number.isFinite(r[0])&&Number.isFinite(r[1])?e.push(r):o();return o(),t}function ha(...n){return n.flat()}function rt(n,t){if(t===zt)return n;let e=new Array(n.length);for(let o=0;o<n.length;o++){let r=n[o].p,s=new Float64Array(r.length);for(let i=0;i<r.length;i+=2){let a=r[i],l=r[i+1];s[i]=t[0]*a+t[2]*l+t[4],s[i+1]=t[1]*a+t[3]*l+t[5]}e[o]={p:s,closed:n[o].closed}}return e}function _o(n,t,e=4){return(e>1?n.map(r=>On(r,e)):n).map(r=>{let s=Vt(r),i=[];for(let l=0;l<=s;l++){let c=t(r.p[l*6],r.p[l*6+1]);i.push(c)}let a=[i[0][0],i[0][1]];for(let l=0;l<s;l++){let c=t(r.p[l*6+2],r.p[l*6+3]),u=t(r.p[l*6+4],r.p[l*6+5]);a.push(c[0],c[1],u[0],u[1],i[l+1][0],i[l+1][1])}return Mt(a,r.closed)})}function Pn(n,t,e,o,r){let s=n[t],i=n[t+1],a=n[t+2],l=n[t+3],c=n[t+4],u=n[t+5],h=n[t+6],d=n[t+7],m=s+(a-s)*e,p=i+(l-i)*e,f=a+(c-a)*e,b=l+(u-l)*e,y=c+(h-c)*e,g=u+(d-u)*e,w=m+(f-m)*e,x=p+(b-p)*e,k=f+(y-f)*e,M=b+(g-b)*e,v=w+(k-w)*e,A=x+(M-x)*e;o.push(m,p,w,x,v,A),r.length=0,r.push(v,A,k,M,y,g,h,d)}function On(n,t){let e=Vt(n);if(t<=1||e===0)return n;let o=[n.p[0],n.p[1]];for(let r=0;r<e;r++){let s=Array.from(n.p.subarray(r*6,r*6+8));for(let i=t;i>1;i--){let a=[];Pn(s,0,1/i,o,a),s=a}o.push(s[2],s[3],s[4],s[5],s[6],s[7])}return Mt(o,n.closed)}var Do=new WeakMap;function Ke(n){let t=Do.get(n);if(t)return t;let e=Vt(n),o=new Float64Array(e),r=new Float64Array(e*ae),s=0,i=n.p;for(let l=0;l<e;l++){let c=l*6,u=i[c],h=i[c+1],d=i[c+2],m=i[c+3],p=i[c+4],f=i[c+5],b=i[c+6],y=i[c+7],g=u,w=h,x=0;for(let k=1;k<=ae;k++){let M=k/ae,v=1-M,A=v*v*v,O=3*v*v*M,N=3*v*M*M,T=M*M*M,V=A*u+O*d+N*p+T*b,z=A*h+O*m+N*f+T*y;x+=Math.hypot(V-g,z-w),r[l*ae+k-1]=x,g=V,w=z}s+=x,o[l]=s}let a={total:o,lut:r,length:s};return Do.set(n,a),a}function Re(n){return Ke(n).length}function At(n){let t=0;for(let e of n)t+=Ke(e).length;return t}function An(n,t){let e=n.total.length;if(e===0)return[0,0];if(t<=0)return[0,0];if(t>=n.length)return[e-1,1];let o=0,r=e-1;for(;o<r;){let d=o+r>>1;n.total[d]<t?o=d+1:r=d}let s=o===0?0:n.total[o-1],i=t-s,a=o*ae,l=0;for(;l<ae-1&&n.lut[a+l]<i;)l++;let c=l===0?0:n.lut[a+l-1],u=n.lut[a+l],h=u>c?(i-c)/(u-c):0;return[o,(l+h)/ae]}function Go(n,t,e){if(Vt(n)===0)return null;let r=Math.max(0,Math.min(1,t)),s=Math.max(0,Math.min(1,e));if(s<=r)return null;if(r===0&&s===1)return n;let i=Ke(n);if(i.length===0)return null;let[a,l]=An(i,r*i.length),[c,u]=An(i,s*i.length),h=[];for(let d=a;d<=c;d++){let m=Array.from(n.p.subarray(d*6,d*6+8)),p=d===a?l:0,f=d===c?u:1;if(p>0){let b=[];Pn(m,0,p,[],b),m=b}if(f<1){let b=[],y=[],g=p>0?(f-p)/(1-p):f;Pn(m,0,g,b,y),m=[m[0],m[1],...b]}h.length===0&&h.push(m[0],m[1]),h.push(m[2],m[3],m[4],m[5],m[6],m[7])}return Mt(h,!1)}function Jt(n,t,e,o=!1){if(t<=0&&e>=1)return n;let r=[];if(o){for(let a of n){let l=Go(a,t,e);l&&r.push(l)}return r}let s=At(n);if(s===0)return[];let i=0;for(let a of n){let l=Re(a),c=(t*s-i)/(l||1),u=(e*s-i)/(l||1);if(i+=l,u<=0||c>=1)continue;let h=Go(a,Math.max(0,c),Math.min(1,u));h&&r.push(h)}return r}function Pt(n,t){let e=At(n);if(e===0){let r=n[0]?.p;return r?[r[0],r[1]]:[0,0]}let o=Math.max(0,Math.min(1,t))*e;for(let r=0;r<n.length;r++){let s=n[r],i=Re(s);if(o<=i||r===n.length-1){let[a,l]=An(Ke(s),o);return vs(s.p,a*6,l)}o-=i}return[0,0]}function ge(n,t){let o=Pt(n,Math.max(0,t-.002)),r=Pt(n,Math.min(1,t+.002)),s=Math.hypot(r[0]-o[0],r[1]-o[1])||1;return[(r[0]-o[0])/s,(r[1]-o[1])/s]}function vs(n,t,e){let o=1-e,r=o*o*o,s=3*o*o*e,i=3*o*e*e,a=e*e*e;return[r*n[t]+s*n[t+2]+i*n[t+4]+a*n[t+6],r*n[t+1]+s*n[t+3]+i*n[t+5]+a*n[t+7]]}function jo(n,t,e,o,r){if(n[0]=Math.min(n[0],t,r),n[1]=Math.max(n[1],t,r),e>=n[0]&&e<=n[1]&&o>=n[0]&&o<=n[1])return;let s=-t+3*e-3*o+r,i=2*(t-2*e+o),a=e-t,l=[];if(Math.abs(s)<1e-9)Math.abs(i)>1e-9&&l.push(-a/i);else{let c=i*i-4*s*a;if(c>=0){let u=Math.sqrt(c);l.push((-i+u)/(2*s),(-i-u)/(2*s))}}for(let c of l){if(c<=0||c>=1)continue;let u=1-c,h=u*u*u*t+3*u*u*c*e+3*u*c*c*o+c*c*c*r;n[0]=Math.min(n[0],h),n[1]=Math.max(n[1],h)}}var Ho=new WeakMap;function Ko(n){let t=Ho.get(n);if(t)return t;let e=n.p;if(e.length<2)return ks;let o=[e[0],e[0]],r=[e[1],e[1]];for(let i=0;i+7<e.length;i+=6)jo(o,e[i],e[i+2],e[i+4],e[i+6]),jo(r,e[i+1],e[i+3],e[i+5],e[i+7]);let s={x:o[0],y:r[0],width:o[1]-o[0],height:r[1]-r[0]};return Ho.set(n,s),s}function bt(n){if(n.length===0)return null;let t=1/0,e=1/0,o=-1/0,r=-1/0;for(let s of n){if(s.p.length<2)continue;let i=Ko(s);t=Math.min(t,i.x),e=Math.min(e,i.y),o=Math.max(o,i.x+i.width),r=Math.max(r,i.y+i.height)}return t===1/0?null:{x:t,y:e,width:o-t,height:r-e}}function Xe(n,t){if(!n)return t;if(!t)return n;let e=Math.min(n.x,t.x),o=Math.min(n.y,t.y);return{x:e,y:o,width:Math.max(n.x+n.width,t.x+t.width)-e,height:Math.max(n.y+n.height,t.y+t.height)-o}}function ce(n){let t=n.p,e=0;for(let o=0;o+7<t.length;o+=6)e+=t[o]*t[o+7]-t[o+6]*t[o+1];return e/2}function ue(n){let t=Ko(n);return[t.x+t.width/2,t.y+t.height/2]}function Nn(n){let t=n.p,e=new Float64Array(t.length);for(let o=0;o<t.length;o+=2)e[o]=t[t.length-2-o],e[o+1]=t[t.length-1-o];return{p:e,closed:n.closed}}function vt(n){let t=n.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(!t)return[];let e=[],o=[],r=0,s=0,i=0,a=0,l=0,c="",u=0,h=0,d=()=>Number(t[r++]),m=()=>{let y=t[r];return y.length>1&&(y[0]==="0"||y[0]==="1")&&!y.startsWith("0.")&&!y.startsWith("1.")?(t[r]=y.slice(1),Number(y[0])):(r++,Number(y))},p=y=>{o.length>=8&&e.push(Mt(o,y)),o=[]},f=(y,g)=>{o.length===0&&o.push(y,g)},b="";for(;r<t.length;){let y=t[r];if(/^[a-zA-Z]$/.test(y))b=y,r++;else if(b==="M")b="L";else if(b==="m")b="l";else if(b==="")throw new Error(`Invalid SVG path data: ${n.slice(0,40)}`);let g=b>="a";switch(b.toUpperCase()){case"M":{p(!1),s=(g?s:0)+d(),i=(g?i:0)+d(),a=s,l=i,o.push(s,i);break}case"L":{let w=(g?s:0)+d(),x=(g?i:0)+d();f(s,i),Ct(o,s,i,w,x),s=w,i=x;break}case"H":{let w=(g?s:0)+d();f(s,i),Ct(o,s,i,w,i),s=w;break}case"V":{let w=(g?i:0)+d();f(s,i),Ct(o,s,i,s,w),i=w;break}case"C":{let w=g?s:0,x=g?i:0,k=w+d(),M=x+d(),v=w+d(),A=x+d(),O=w+d(),N=x+d();f(s,i),o.push(k,M,v,A,O,N),u=v,h=A,s=O,i=N;break}case"S":{let w=g?s:0,x=g?i:0,k="CScs".includes(c),M=k?2*s-u:s,v=k?2*i-h:i,A=w+d(),O=x+d(),N=w+d(),T=x+d();f(s,i),o.push(M,v,A,O,N,T),u=A,h=O,s=N,i=T;break}case"Q":{let w=g?s:0,x=g?i:0,k=w+d(),M=x+d(),v=w+d(),A=x+d();f(s,i),o.push(s+(k-s)*2/3,i+(M-i)*2/3,v+(k-v)*2/3,A+(M-A)*2/3,v,A),u=k,h=M,s=v,i=A;break}case"T":{let w=g?s:0,x=g?i:0,k="QTqt".includes(c),M=k?2*s-u:s,v=k?2*i-h:i,A=w+d(),O=x+d();f(s,i),o.push(s+(M-s)*2/3,i+(v-i)*2/3,A+(M-A)*2/3,O+(v-O)*2/3,A,O),u=M,h=v,s=A,i=O;break}case"A":{let w=d(),x=d(),k=d(),M=m(),v=m(),A=(g?s:0)+d(),O=(g?i:0)+d();f(s,i),Ps(o,s,i,w,x,k,M===1,v===1,A,O),s=A,i=O;break}case"Z":{o.length>0&&((s!==a||i!==l)&&Ct(o,s,i,a,l),p(!0)),s=a,i=l;break}default:throw new Error(`Unsupported SVG path command: ${b}`)}c=b}return p(!1),e}function Ps(n,t,e,o,r,s,i,a,l,c){let u=Math.abs(o),h=Math.abs(r);if(u===0||h===0||t===l&&e===c){Ct(n,t,e,l,c);return}let d=s*Math.PI/180,m=Math.cos(d),p=Math.sin(d),f=(t-l)/2,b=(e-c)/2,y=m*f+p*b,g=-p*f+m*b,w=y*y/(u*u)+g*g/(h*h);if(w>1){let G=Math.sqrt(w);u*=G,h*=G}let x=u*u*h*h-u*u*g*g-h*h*y*y,k=u*u*g*g+h*h*y*y,M=(i===a?-1:1)*Math.sqrt(Math.max(0,x/k)),v=M*u*g/h,A=-M*h*y/u,O=m*v-p*A+(t+l)/2,N=p*v+m*A+(e+c)/2,T=Math.atan2((g-A)/h,(y-v)/u),V=Math.atan2((-g-A)/h,(-y-v)/u)-T;a&&V<0&&(V+=Math.PI*2),!a&&V>0&&(V-=Math.PI*2);let z=Math.max(1,Math.ceil(Math.abs(V)/(Math.PI/2)-1e-9)),B=V/z,W=4/3*Math.tan(B/4);for(let G=0;G<z;G++){let U=T+G*B,C=U+B,L=Math.cos(U),I=Math.sin(U),F=Math.cos(C),E=Math.sin(C),R=(L-W*I)*u,$=(I+W*L)*h,j=(F+W*E)*u,J=(E-W*F)*h,at=F*u,tt=E*h;n.push(m*R-p*$+O,p*R+m*$+N,m*j-p*J+O,p*j+m*J+N,G===z-1?l:m*at-p*tt+O,G===z-1?c:p*at+m*tt+N)}}function Bt(n){let t=Math.round(n*100)/100;return t===0?"0":String(t)}function Xo(n){let t=[];for(let e of n){let o=e.p;if(!(o.length<2)){if(t.push("M",Bt(o[0])," ",Bt(o[1])),e.straight){for(let r=2;r+5<o.length;r+=6)t.push("L",Bt(o[r+4])," ",Bt(o[r+5]));e.closed&&t.push("Z");continue}for(let r=2;r+5<o.length;r+=6)t.push("C",Bt(o[r])," ",Bt(o[r+1])," ",Bt(o[r+2])," ",Bt(o[r+3])," ",Bt(o[r+4])," ",Bt(o[r+5]));e.closed&&t.push("Z")}}return t.join("")}var Sn=n=>n<=0?0:n>=1?1:n,Te=n=>n;function Cn(n){return 1/(1+Math.exp(-n))}function As(n){let t=Cn(-n/2),e=Cn(n/2);return o=>o<=0?0:o>=1?1:(Cn(n*(o-.5))-t)/(e-t)}var dt=As(10),ma=n=>{let t=Sn(n);return t*t*t*(t*(t*6-15)+10)},pa=n=>n*n,fa=n=>1-(1-n)*(1-n),ba=n=>n*n*n,ga=n=>1-Math.pow(1-n,3),ya=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,wa=n=>1-Math.pow(1-n,5),xa=n=>n<.5?16*n*n*n*n*n:1-Math.pow(-2*n+2,5)/2,ka=n=>n>=1?1:1-Math.pow(2,-10*n),Ma=n=>n<=0?0:Math.pow(2,10*n-10),va=n=>2*dt(n/2),Pa=n=>2*dt(n/2+.5)-1,Aa=n=>Math.sqrt(Math.max(0,1-(1-n)*(1-n)));function Oa(n=1.70158){return t=>{let e=t-1;return e*e*((n+1)*e+n)+1}}function Na(n={}){let t=n.bounce??.28,e=n.frequency??2.2,o=-Math.log(Math.max(1e-4,t))*2.4;return r=>r<=0?0:r>=1?1:1-Math.exp(-o*r)*Math.cos(e*Math.PI*2*r)*(1-r)}var Ca=n=>n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375,Rn=n=>dt(n<.5?2*n:2*(1-n));function Sa(n=1/3){let t=(1-n)/2;return e=>e<t?dt(e/t):e<1-t?1:dt((1-e)/t)}function Yo(n=2){return t=>Rn(t)*Math.sin(n*Math.PI*2*t)}function Ra(n=.7,t=dt){return e=>n*t(e)}function Ta(n=.25,t=dt){return e=>t(Sn(e/(1-n)))}function Fa(n=-.5){return t=>{let e=1-t;return 15*e**4*t**2*n+20*e**3*t**3*n+15*e**2*t**4+6*e*t**5+t**6}}function Ia(n,t,e=dt){return o=>e(Sn((o-n)/(t-n)))}function Ea(n,t,e,o){let r=3*n,s=3*(e-n)-r,i=1-r-s,a=3*t,l=3*(o-t)-a,c=1-a-l,u=m=>((i*m+s)*m+r)*m,h=m=>((c*m+l)*m+a)*m,d=m=>(3*i*m+2*s)*m+r;return m=>{if(m<=0)return 0;if(m>=1)return 1;let p=m;for(let f=0;f<8;f++){let b=u(p)-m,y=d(p);if(Math.abs(b)<1e-5||Math.abs(y)<1e-6)break;p-=b/y}return h(p)}}var Ye={name:"midnight",dark:!0,background:"#0b0c10",bloom:.2,colors:{bg:"#0b0c10",surface:"#15171d",ink:"#f2efe6",dim:"#a5a7ad",faint:"#5c5f68",grid:"#23303d",gridStrong:"#3d5266",blue:"#5cc4f0",teal:"#4fd8c4",green:"#8fe08a",yellow:"#ffd75e",gold:"#f2b84b",orange:"#ff9d57",red:"#ff6b6b",pink:"#ff8fc0",purple:"#b49cff"}},Os={name:"paper",dark:!1,background:"#f7f3ea",bloom:0,colors:{bg:"#f7f3ea",surface:"#efe9db",ink:"#1d1b16",dim:"#5e5a50",faint:"#a29c8d",grid:"#e2dbca",gridStrong:"#c4bba6",blue:"#1f6fb2",teal:"#0d8577",green:"#3f8a35",yellow:"#b98500",gold:"#a8740a",orange:"#cf5d12",red:"#c62f2f",pink:"#c2387e",purple:"#6a4bc4"}},Ns={name:"blueprint",dark:!0,background:"#0b2340",bloom:.16,colors:{bg:"#0b2340",surface:"#123054",ink:"#eaf6ff",dim:"#9cc0dc",faint:"#5d86a8",grid:"#1a3f66",gridStrong:"#2c5f8e",blue:"#7fd4ff",teal:"#6fe6d6",green:"#9de8a4",yellow:"#ffe27a",gold:"#f5c566",orange:"#ffb27a",red:"#ff8d8d",pink:"#ffa8cf",purple:"#c5b4ff"}},Cs={name:"chalk",dark:!0,background:"#10201b",bloom:.1,colors:{bg:"#10201b",surface:"#172c25",ink:"#f4f1e4",dim:"#b1b9a9",faint:"#67786d",grid:"#20392f",gridStrong:"#355547",blue:"#8ccbe8",teal:"#7dd9c1",green:"#a9dc8f",yellow:"#f6dd7c",gold:"#e6bf62",orange:"#f2a874",red:"#ee8a80",pink:"#efa2c2",purple:"#bfa9e6"}},Ss={name:"neon",dark:!0,background:"#050507",bloom:.4,colors:{bg:"#050507",surface:"#101016",ink:"#ffffff",dim:"#a9a9b8",faint:"#55555f",grid:"#1a1f2e",gridStrong:"#2f3a55",blue:"#3fb2ff",teal:"#21f0d0",green:"#6dff8e",yellow:"#fff04d",gold:"#ffc22e",orange:"#ff8a2e",red:"#ff4560",pink:"#ff5fb0",purple:"#a56bff"}},qo={midnight:Ye,paper:Os,blueprint:Ns,chalk:Cs,neon:Ss};function qe(n){if(n===void 0)return Ye;if(typeof n!="string")return n;let t=qo[n];if(!t)throw new Error(`Unknown look: ${JSON.stringify(n)}. Use one of: ${Object.keys(qo).join(", ")}.`);return t}var Qo=ws(xs(),1);var Rs=[0,0,0,0],Uo=new Map,tr=Ye.colors;function In(n){tr=n}function Gt(n){let e=tr[n]??n,o=Uo.get(e);if(o)return o;let r=(0,Qo.default)(e);if(!r)throw new Error(`Unknown color: ${JSON.stringify(n)}. Use a look token such as "blue" or a CSS color.`);let[s,i,a]=r.values;r.type==="hsl"&&([s,i,a]=Ts(s,i,a));let l=[s,i,a,r.alpha];return Uo.set(e,l),l}function Ts(n,t,e){let o=t/100*Math.min(e/100,1-e/100),r=s=>{let i=(s+n/30)%12;return 255*(e/100-o*Math.max(-1,Math.min(i-3,9-i,1)))};return[r(0),r(8),r(4)]}function X(n){return typeof n=="string"?Gt(n):n}function yt(n){return!Array.isArray(n)}function Yt(n,t=1){let e=n[3]*t,o=Math.round(n[0]),r=Math.round(n[1]),s=Math.round(n[2]);return e>=1?`rgb(${o},${r},${s})`:`rgba(${o},${r},${s},${Math.round(e*1e3)/1e3})`}function Tn(n){let t=n/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Fn(n){let t=n<=.0031308?12.92*n:1.055*Math.pow(n,.4166666666666667)-.055;return Math.max(0,Math.min(255,t*255))}function Zo(n){let t=Tn(n[0]),e=Tn(n[1]),o=Tn(n[2]),r=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*o),s=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*o),i=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*o);return[.2104542553*r+.793617785*s-.0040720468*i,1.9779984951*r-2.428592205*s+.4505937099*i,.0259040371*r+.7827717662*s-.808675766*i]}function Fs(n,t){let e=n[0]+.3963377774*n[1]+.2158037573*n[2],o=n[0]-.1055613458*n[1]-.0638541728*n[2],r=n[0]-.0894841775*n[1]-1.291485548*n[2],s=e*e*e,i=o*o*o,a=r*r*r;return[Fn(4.0767416621*s-3.3077115913*i+.2309699292*a),Fn(-1.2684380046*s+2.6097574011*i-.3413193965*a),Fn(-.0041960863*s-.7034186147*i+1.707614701*a),t]}function he(n,t,e){if(e<=0)return n;if(e>=1)return t;let o=Zo(n),r=Zo(t);return Fs([o[0]+(r[0]-o[0])*e,o[1]+(r[1]-o[1])*e,o[2]+(r[2]-o[2])*e],n[3]+(t[3]-n[3])*e)}function er(n,t,e){if(e<=0)return n;if(e>=1)return t;let o=yt(n),r=yt(t);if(!o&&!r)return he(n,t,e);if(o&&r&&n.type===t.type&&n.stops.length===t.stops.length){let a=n.stops.map((l,c)=>[l[0]+(t.stops[c][0]-l[0])*e,he(l[1],t.stops[c][1],e)]);return n.type==="linear"&&t.type==="linear"?{type:"linear",stops:a,from:[n.from[0]+(t.from[0]-n.from[0])*e,n.from[1]+(t.from[1]-n.from[1])*e],to:[n.to[0]+(t.to[0]-n.to[0])*e,n.to[1]+(t.to[1]-n.to[1])*e]}:n.type==="radial"&&t.type==="radial"?{type:"radial",stops:a,center:[n.center[0]+(t.center[0]-n.center[0])*e,n.center[1]+(t.center[1]-n.center[1])*e],radius:n.radius+(t.radius-n.radius)*e}:{type:"along",stops:a}}let s=o?lt(n.stops,.5):n,i=r?lt(t.stops,.5):t;return he(s,i,e)}function lt(n,t){if(n.length===0)return Rs;if(t<=n[0][0])return n[0][1];for(let e=1;e<n.length;e++)if(t<=n[e][0]){let[o,r]=n[e-1],[s,i]=n[e];return he(r,i,s>o?(t-o)/(s-o):0)}return n[n.length-1][1]}function Ue(n){let t=n.length;return n.map((e,o)=>Array.isArray(e)&&e.length===2&&typeof e[0]=="number"?[e[0],Jo(e[1])]:[t===1?0:o/(t-1),Jo(e)])}function Jo(n){let t=X(n);return yt(t)?lt(t.stops,.5):t}function Is(n,t,e){return{type:"linear",from:n,to:t,stops:Ue(e)}}function Es(n,t,e){return{type:"radial",center:n,radius:t,stops:Ue(e)}}function zs(...n){return{type:"along",stops:Ue(n)}}function Fe(n,...t){let e=Ue(t);return Array.from({length:n},(o,r)=>lt(e,n===1?0:r/(n-1)))}var S={now:0,mode:"free",frame:0,capture:null},ye=class{constructor(t){this.initial=t}initial;keys=[];sample(t){let e=this.keys,o=0,r=e.length-1,s=-1;for(;o<=r;){let c=o+r>>1;e[c].t0<=t?(s=c,o=c+1):r=c-1}if(s<0)return this.initial;let i=e[s];if(t>=i.t1||!i.at)return i.to;let a=i.t1-i.t0,l=a>0?(t-i.t0)/a:1;return i.at(i.ease?i.ease(l):l)}add(t){let e=this.keys,o=e.length;for(;o>0&&e[o-1].t0>t.t0;)o--;e.splice(o,0,t)}step(t,e){this.add({t0:t,t1:t,ease:null,to:e,at:null})}get end(){let t=0;for(let e of this.keys)e.t1>t&&(t=e.t1);return t}};function nr(n,t){let e=Vt(n);if(e>=t||e===0)return n;let o=[];for(let s=0;s<e;s++){let i=s*6,a=Array.from(n.p.subarray(i,i+8));o.push({pts:a,length:En(a)})}for(;o.length<t;){let s=0;for(let l=1;l<o.length;l++)o[l].length>o[s].length&&(s=l);let[i,a]=Vs(o[s].pts);o.splice(s,1,{pts:i,length:En(i)},{pts:a,length:En(a)})}let r=new Float64Array(2+t*6);r[0]=n.p[0],r[1]=n.p[1];for(let s=0;s<t;s++){let i=o[s].pts;for(let a=0;a<6;a++)r[2+s*6+a]=i[2+a]}return{p:r,closed:n.closed}}function En(n){return Math.hypot(n[2]-n[0],n[3]-n[1])+Math.hypot(n[4]-n[2],n[5]-n[3])+Math.hypot(n[6]-n[4],n[7]-n[5])}function Vs(n){let t=(n[0]+n[2])/2,e=(n[1]+n[3])/2,o=(n[2]+n[4])/2,r=(n[3]+n[5])/2,s=(n[4]+n[6])/2,i=(n[5]+n[7])/2,a=(t+o)/2,l=(e+r)/2,c=(o+s)/2,u=(r+i)/2,h=(a+c)/2,d=(l+u)/2;return[[n[0],n[1],t,e,a,l,h,d],[h,d,c,u,s,i,n[6],n[7]]]}function Ls(n,t){let e=Vt(t);if(!n.closed||!t.closed||e<2)return t;let[o,r]=ue(n),[s,i]=ue(t),a=Math.max(1,Math.floor(e/48)),l=0,c=1/0;for(let h=0;h<e;h+=a){let d=0;for(let m=0;m<e;m+=a){let p=(m+h)%e,f=n.p[m*6]-o-(t.p[p*6]-s),b=n.p[m*6+1]-r-(t.p[p*6+1]-i);d+=f*f+b*b}d<c&&(c=d,l=h)}if(l===0)return t;let u=new Float64Array(t.p.length);u[0]=t.p[l*6],u[1]=t.p[l*6+1];for(let h=0;h<e;h++){let d=(h+l)%e;for(let m=0;m<6;m++)u[2+h*6+m]=t.p[2+d*6+m]}return{p:u,closed:t.closed}}function or(n,t,e,o){let r=new Float64Array(2+e*6);for(let s=0;s<r.length;s+=2)r[s]=n,r[s+1]=t;return{p:r,closed:o}}function $s(n,t){let e=a=>[...a].sort((l,c)=>Math.abs(ce(c))+Re(c)*.01-(Math.abs(ce(l))+Re(l)*.01)),o=e(n),r=e(t),s=[],i=r.slice();for(let a of o){if(i.length===0){let[d,m]=ue(a);s.push([a,or(d,m,Vt(a),a.closed)]);continue}let[l,c]=ue(a),u=0,h=1/0;for(let d=0;d<Math.min(i.length,3);d++){let[m,p]=ue(i[d]),f=Math.hypot(l-m,c-p)+d*40;f<h&&(h=f,u=d)}s.push([a,i[u]]),i.splice(u,1)}for(let a of i){let[l,c]=ue(a);s.push([or(l,c,Vt(a),a.closed),a])}return s}function Bs(n,t,e=12){let o=$s(n,t),r=[],s=[],i=[];for(let[a,l]of o){let c=Math.max(Vt(a),Vt(l),a.closed&&l.closed?e:1),u=nr(a,c),h=nr(l,c);if(u.closed&&h.closed)Math.sign(ce(u))!==Math.sign(ce(h))&&ce(u)!==0&&ce(h)!==0&&(h=Nn(h)),h=Ls(u,h);else if(!u.closed&&!h.closed){let d=u.p.length,m=Math.hypot(u.p[0]-h.p[0],u.p[1]-h.p[1])+Math.hypot(u.p[d-2]-h.p[d-2],u.p[d-1]-h.p[d-1]);Math.hypot(u.p[0]-h.p[d-2],u.p[1]-h.p[d-1])+Math.hypot(u.p[d-2]-h.p[0],u.p[d-1]-h.p[1])<m&&(h=Nn(h))}r.push(u.p),s.push(h.p),i.push(u.closed&&h.closed)}return{from:r,to:s,closed:i}}function Ze(n,t){if(n===t)return()=>t;if(At(n)===0&&n.length===0)return o=>o>=1?t:n;let e=Bs(n,t);return o=>{if(o<=0)return n;if(o>=1)return t;let r=new Array(e.from.length);for(let s=0;s<r.length;s++){let i=e.from[s],a=e.to[s],l=new Float64Array(i.length);for(let c=0;c<i.length;c++)l[c]=i[c]+(a[c]-i[c])*o;r[s]={p:l,closed:e.closed[s]}}return r}}function Je(n,t){let e=n.length,o=t.length,r=Array.from({length:e+1},()=>new Uint16Array(o+1));for(let l=e-1;l>=0;l--)for(let c=o-1;c>=0;c--)r[l][c]=n[l]===t[c]?r[l+1][c+1]+1:Math.max(r[l+1][c],r[l][c+1]);let s=[],i=0,a=0;for(;i<e&&a<o;)n[i]===t[a]?s.push([i++,a++]):r[i+1][a]>=r[i][a+1]?i++:a++;return s}var zn={x:0,y:0,rotation:0,sx:1,sy:1,px:0,py:0,opacity:1,visible:!0,z:0,path:null,fill:null,fillOpacity:1,stroke:null,strokeOpacity:1,strokeWidth:3,cap:"round",join:"round",dash:null,dashOffset:0,trimFrom:0,trimTo:1,trimEach:!1,glow:0,glowColor:null,blend:"normal",fixed:!1,image:null},Ws=new Set(["x","y","rotation","sx","sy","px","py","opacity","z","fillOpacity","strokeOpacity","strokeWidth","dashOffset","trimFrom","trimTo","glow"]);function Ds(n,t,e){if(Ws.has(n)){let o=t,r=e;return(s=>o+(r-o)*s)}if(n==="fill"||n==="stroke"){let o=t,r=e;return o&&r?(s=>er(o,r,s)):null}if(n==="glowColor"){let o=t,r=e;return o&&r?(s=>he(o,r,s)):null}if(n==="path"){let o=t,r=e;return o&&r?Ze(o,r):null}return null}var rr=1,P=class n{id=rr++;parent=null;children=[];data={};label="";base=Object.create(zn);tracks=null;overlay=null;overlayFrame=-1;mounted=!1;draw=null;rawOps=null;constructor(t){t&&(this.base.path=t)}get(t){let e=this.overlay;if(e!==null&&e.has(t)&&(this.overlayFrame===S.frame||S.capture!==null))return e.get(t);let o=this.tracks?.get(t);return o?o.sample(S.now):this.base[t]}set(t,e){return S.capture?(this.overlay??=new Map,this.overlay.set(t,e),S.capture.add(this),this):this.mounted?S.mode==="render"?(this.overlay??=new Map,this.overlayFrame!==S.frame&&(this.overlay.clear(),this.overlayFrame=S.frame),this.overlay.set(t,e),this):(this.track(t).step(S.now,e),this):(this.base[t]=e,this)}track(t){this.tracks??=new Map;let e=this.tracks.get(t);return e||(e=new ye(this.base[t]),this.tracks.set(t,e)),e}tween(t,e,o,r,s){let i=S.now;S.now=o;let a=this.get(t);S.now=i;let l=r>o?Ds(t,a,e):null,c={t0:o,t1:r,ease:s,to:e,at:l};this.track(t).add(c)}add(...t){for(let e of t)e.parent!==this&&(e.parent?.drop(e),e.parent=this,this.children.push(e),this.mounted&&tn(e,S.now));return this}drop(t){let e=this.children.indexOf(t);return e>=0&&this.children.splice(e,1),t.parent=null,this}all(){let t=[],e=o=>{t.push(o);for(let r of o.children)e(r)};return e(this),t}leaves(){return this.all().filter(t=>t.get("path")!==null||t.draw!==null||t.get("image")!==null)}clone(){let t=Object.create(Object.getPrototypeOf(this));Object.assign(t,this),t.id=rr++,t.parent=null,t.mounted=!1,t.tracks=null,t.overlay=null,t.overlayFrame=-1,t.data={...this.data},t.base=Object.create(zn);for(let e of Object.keys(zn))t.base[e]=this.get(e);return t.children=this.children.map(e=>{let o=e.clone();return o.parent=t,o}),t}localMatrix(){return fe(this.get("x"),this.get("y"),this.get("rotation"),this.get("sx"),this.get("sy"),this.get("px"),this.get("py"))}worldMatrix(){let t=this.localMatrix();for(let e=this.parent;e;e=e.parent)t=ot(e.localMatrix(),t);return t}toWorld(t,e){return Q(this.worldMatrix(),t,e)}bounds(){return this.boundsFrom(this.parent?this.parent.worldMatrix():zt)??{x:0,y:0,width:0,height:0}}boundsFrom(t){let e=ot(t,this.localMatrix()),o=null,r=this.get("path");r&&(o=bt(rt(r,e)));let s=this.get("image");if(s&&(o=Xe(o,Gs(e,s.width,s.height))),this.draw){let i=this.draw(S.now),a=i===null?[]:Array.isArray(i)?i:[i];for(let l of a)o=Xe(o,l.boundsFrom(e))}for(let i of this.children)i.get("visible")&&(o=Xe(o,i.boundsFrom(e)));return o}get center(){let t=this.bounds();return[t.x+t.width/2,t.y+t.height/2]}get top(){let t=this.bounds();return[t.x+t.width/2,t.y]}get bottom(){let t=this.bounds();return[t.x+t.width/2,t.y+t.height]}get left(){let t=this.bounds();return[t.x,t.y+t.height/2]}get right(){let t=this.bounds();return[t.x+t.width,t.y+t.height/2]}get width(){return this.bounds().width}get height(){return this.bounds().height}at(t,e){let[o,r]=typeof t=="number"?[t,e??0]:t;return this.set("x",o),this.set("y",r),this}shift(t,e){let[o,r]=typeof t=="number"?[t,e??0]:t;return this.set("x",this.get("x")+o),this.set("y",this.get("y")+r),this}moveTo(t){let e=t instanceof n?t.center:t,[o,r]=this.center,s=this.parent?Wt(this.parent.worldMatrix()):zt,[i,a]=Q(s,o,r),[l,c]=Q(s,e[0],e[1]);return this.shift(l-i,c-a)}pivotAt(t){let e=this.parent?this.parent.worldMatrix():zt,o=ot(e,this.localMatrix()),[r,s]=Q(Wt(o),t[0],t[1]),[i,a]=Q(Wt(e),t[0],t[1]);return this.set("px",r),this.set("py",s),this.set("x",i),this.set("y",a),this}scale(t,e){let[o,r]=typeof t=="number"?[t,t]:t;return this.pivotAt(e??this.center),this.set("sx",this.get("sx")*o),this.set("sy",this.get("sy")*r),this}rotate(t,e){return this.pivotAt(e??this.center),this.set("rotation",this.get("rotation")+t),this}fitTo(t){let e=this.bounds(),o=[];return t.width!==void 0&&e.width>0&&o.push(t.width/e.width),t.height!==void 0&&e.height>0&&o.push(t.height/e.height),o.length?this.scale(Math.min(...o)):this}nextTo(t,e="right",o=28){let[r,s]=Qe(e),i=t instanceof n?t.bounds():{x:t[0],y:t[1],width:0,height:0},a=this.bounds(),l=i.x+i.width/2,c=i.y+i.height/2,u=l+r*(i.width/2+o+a.width/2),h=c+s*(i.height/2+o+a.height/2);return this.moveTo([u,h])}alignTo(t,e){let o=this.bounds(),r=t instanceof n?t.bounds():{x:t[0],y:t[1],width:0,height:0};return e==="left"?this.shift(r.x-o.x,0):e==="right"?this.shift(r.x+r.width-o.x-o.width,0):e==="top"?this.shift(0,r.y-o.y):this.shift(0,r.y+r.height-o.y-o.height)}arrange(t="right",e=24){let[o,r]=Qe(t),s=this.center,i=null;for(let a of this.children){if(i){let l=i.bounds(),c=a.bounds(),u=l.x+l.width/2+o*(l.width/2+e+c.width/2),h=l.y+l.height/2+r*(l.height/2+e+c.height/2);a.moveTo([o===0?l.x+l.width/2:u,r===0?l.y+l.height/2:h])}i=a}return this.moveTo(s)}fill(t,e){return this.set("fill",t===null?null:X(t)),e!==void 0&&this.set("fillOpacity",e),this}stroke(t,e,o){return this.set("stroke",t===null?null:X(t)),e!==void 0&&this.set("strokeWidth",e),o!==void 0&&this.set("strokeOpacity",o),this}color(t){let e=X(t);for(let o of this.all())o.get("stroke")&&o.set("stroke",e),o.get("fill")&&o.set("fill",e),o.get("glowColor")&&!yt(e)&&o.set("glowColor",e);return this}opacity(t){return this.set("opacity",t)}glow(t,e){if(this.set("glow",t),e!==void 0){let o=X(e);this.set("glowColor",yt(o)?null:o)}return this}dash(t,e=0){return this.set("dash",t),this.set("dashOffset",e)}zIndex(t){return this.set("z",t)}pin(){return this.set("fixed",!0)}hide(){return this.set("visible",!1)}show(){return this.set("visible",!0)}named(t){return this.label=t,this}};function Gs(n,t,e){let o=[Q(n,0,0),Q(n,t,0),Q(n,t,e),Q(n,0,e)],r=o.map(l=>l[0]),s=o.map(l=>l[1]),i=Math.min(...r),a=Math.min(...s);return{x:i,y:a,width:Math.max(...r)-i,height:Math.max(...s)-a}}function Qe(n){return typeof n!="string"?n:n==="left"?[-1,0]:n==="right"?[1,0]:n==="top"||n==="up"?[0,-1]:[0,1]}function tn(n,t){let e=n.base.visible;for(let o of n.all())o.mounted=!0;if(t>0||!e){let o=n.track("visible");o.initial=!1,e&&o.step(t,!0)}}function Vn(...n){return new P().add(...n)}function Ot(n){let t=new P;return t.draw=n,t}function Rt(n){return Array.isArray(n)?[...n]:[n]}function on(n,t,e,o){S.now=t,n.schedule({t0:t,t1:e,ease:n.ease??o.ease,stage:o.stage})}function Ln(...n){let t=Math.max(0,...n.map(e=>e.duration));return{label:"par",duration:t,schedule(e){let o=t>0?(e.t1-e.t0)/t:1;for(let r of n)on(r,e.t0,e.t0+r.duration*o,e)}}}function sr(...n){let t=n.reduce((e,o)=>e+o.duration,0);return{label:"seq",duration:t,schedule(e){let o=t>0?(e.t1-e.t0)/t:1,r=e.t0;for(let s of n){let i=r+s.duration*o;on(s,r,i,e),r=i}}}}function Qa(n,t={}){let e=t.lag??.15,o=Math.max(0,...n.map(s=>s.duration)),r=n.length===0?0:o*(1+(n.length-1)*e);return{label:"lagged",duration:t.duration??r,schedule(s){let i=s.t1-s.t0,a=n.length===0?0:i/(1+(n.length-1)*e);n.forEach((l,c)=>{let u=s.t0+c*e*a;on(l,u,u+a,s)})}}}function tl(n,t){return{label:n.label,duration:n.duration+t,ease:n.ease,schedule(e){let o=n.duration+t>0?(e.t1-e.t0)/(n.duration+t):1;on(n,e.t0+t*o,e.t1,e)}}}function js(n,t){return{...n,duration:t.duration??n.duration,ease:t.ease??n.ease}}function el(n){return{label:"call",duration:0,schedule:()=>n()}}function te(n,t,e){if(!n.mounted){let o=n;for(;o.parent&&o.parent!==e.root;)o=o.parent;e.mountAt(o,t)}for(let o=n;o&&o!==e.root;o=o.parent){let r=S.now;S.now=t;let s=o.get("visible");S.now=r,s||o.track("visible").step(t,!0)}}function jt(n,t){n.track("visible").step(t,!1)}function ir(n,t,e){e<=t||(n.track("visible").step(t,!1),n.track("visible").step(e,!0))}var et=(n,t,e,o)=>{n.track(t).step(o,e)};function Hs(n,t,e){let o=S.now;S.now=e;let r=n.get(t);return S.now=o,r}function _s(n){return yt(n)?lt(n.stops,.5):n}function Qt(n){return Rt(n).flatMap(t=>t.leaves().filter(e=>e.get("path")))}function Ks(n,t,e,o,r){let s=e-t,i=n.get("fill"),a=n.get("stroke"),l=n.get("fillOpacity"),c=n.get("strokeOpacity");if(i&&!a){let u=Hs(n,"strokeWidth",t);et(n,"stroke",_s(i),t),et(n,"strokeWidth",r,t),et(n,"strokeOpacity",1,t),et(n,"trimTo",0,t),et(n,"fillOpacity",0,t),n.tween("trimTo",1,t,t+s*.72,o),n.tween("fillOpacity",l,t+s*.42,e,o),n.tween("strokeOpacity",0,t+s*.62,e,o),et(n,"stroke",null,e),et(n,"strokeWidth",u,e),et(n,"strokeOpacity",c,e);return}et(n,"trimTo",0,t),n.tween("trimTo",1,t,i?t+s*.8:e,o),i&&(et(n,"fillOpacity",0,t),n.tween("fillOpacity",l,t+s*.5,e,o))}function ar(n,t,e,o){let r=Rt(t),s=Qt(r).length,i=e.lag??o.lag,a=e.duration??(s<=1?o.duration:Math.min(o.duration*2.4,o.duration+s*.035));return{label:n,duration:a,ease:e.ease,schedule(l){for(let d of r)te(d,l.t0,l.stage);let c=Qt(r);if(c.length===0)return;let h=(l.t1-l.t0)/(1+(c.length-1)*i);c.forEach((d,m)=>{let p=l.t0+m*i*h;S.now=p,ir(d,l.t0,p),Ks(d,p,p+h,l.ease,o.outline)}),S.now=l.t0}}}function nl(n,t={}){return ar("draw",n,t,{lag:.04,duration:1.3,outline:2})}function ol(n,t={}){return ar("write",n,t,{lag:.22,duration:1.1,outline:1.3})}function rl(n,t={}){let e=Rt(n);return{label:"erase",duration:t.duration??.8,ease:t.ease,schedule(o){let r=Qt(e),s=t.lag??.02,i=(o.t1-o.t0)/(1+Math.max(0,r.length-1)*s);r.forEach((a,l)=>{let c=o.t0+l*s*i;S.now=c;let u=a.get("fill");a.get("stroke")&&a.tween("trimFrom",1,c,c+i,o.ease),u&&a.tween("fillOpacity",0,c,c+i*.7,o.ease)});for(let a of e)jt(a,o.t1)}}}function sl(n,t={}){let e=Rt(n);return{label:"fadeIn",duration:t.duration??.8,ease:t.ease,schedule(o){let r=t.lag!==void 0&&e.length===1&&e[0].children.length>0?e[0].children:e;for(let a of e)te(a,o.t0,o.stage);let s=t.lag??0,i=(o.t1-o.t0)/(1+Math.max(0,r.length-1)*s);r.forEach((a,l)=>{let c=o.t0+l*s*i,u=c+i;S.now=c,ir(a,o.t0,c);let h=a.get("opacity");if(et(a,"opacity",0,c),a.tween("opacity",h,c,u,o.ease),t.shift){let d=a.get("x"),m=a.get("y");et(a,"x",d+t.shift[0],c),et(a,"y",m+t.shift[1],c),a.tween("x",d,c,u,o.ease),a.tween("y",m,c,u,o.ease)}t.scale!==void 0&&lr(a,t.scale,c,u,o.ease)}),S.now=o.t0}}}function lr(n,t,e,o,r,s){let i=S.now;S.now=e,n.pivotAt(s??n.center);let a=n.get("sx"),l=n.get("sy");et(n,"sx",a*t,e),et(n,"sy",l*t,e),n.tween("sx",a,e,o,r),n.tween("sy",l,e,o,r),S.now=i}function il(n,t={}){let e=Rt(n);return{label:"fadeOut",duration:t.duration??.6,ease:t.ease,schedule(o){for(let r of e){let s=r.get("opacity");r.tween("opacity",0,o.t0,o.t1,o.ease),t.shift&&(r.tween("x",r.get("x")+t.shift[0],o.t0,o.t1,o.ease),r.tween("y",r.get("y")+t.shift[1],o.t0,o.t1,o.ease)),t.scale!==void 0&&(r.pivotAt(r.center),r.tween("sx",r.get("sx")*t.scale,o.t0,o.t1,o.ease),r.tween("sy",r.get("sy")*t.scale,o.t0,o.t1,o.ease)),jt(r,o.t1),et(r,"opacity",s,o.t1)}}}}function al(n,t={}){let e=Rt(n);return{label:"grow",duration:t.duration??.9,ease:t.ease,schedule(o){for(let r of e)te(r,o.t0,o.stage),lr(r,.001,o.t0,o.t1,o.ease,t.from)}}}function ll(n){let t=Rt(n);return{label:"appear",duration:0,schedule:e=>{for(let o of t)te(o,e.t0,e.stage)}}}function cl(n){let t=Rt(n);return{label:"vanish",duration:0,schedule:e=>{for(let o of t)jt(o,e.t0)}}}function de(n,t,e={}){return{label:"to",duration:e.duration??1,ease:e.ease,schedule(o){te(n,o.t0,o.stage);let r=new Set;S.capture=r;try{t(n)}finally{S.capture=null}for(let s of r){let i=s,a=new Map(i.overlay);i.overlay.clear(),Xs(i,a,o,e.restore===!0)}}}}function Xs(n,t,e,o){let{t0:r,t1:s,ease:i}=e,a=t,l=new Map,c=a.get("px"),u=a.get("py");if(c!==void 0||u!==void 0){let h=c??n.get("px"),d=u??n.get("py"),m=fe(n.get("x"),n.get("y"),n.get("rotation"),n.get("sx"),n.get("sy"),n.get("px"),n.get("py")),[p,f]=Q(m,h,d);et(n,"px",h,r),et(n,"py",d,r),et(n,"x",p,r),et(n,"y",f,r),a.delete("px"),a.delete("py")}S.now=r;for(let[h,d]of a){let m=n.get(h);m!==d&&(o&&l.set(h,m),n.tween(h,d,r,s,i))}for(let[h,d]of l)et(n,h,d,s)}function ul(n,t,e={}){return{...de(n,o=>o.moveTo(t),e),label:"moveTo"}}function hl(n,t,e,o={}){return{...de(n,r=>r.shift(t,e),o),label:"shift"}}function dl(n,t,e={}){return{...de(n,o=>o.scale(t,e.about),e),label:"scale"}}function ml(n,t,e={}){return{...de(n,o=>o.rotate(t,e.about),e),label:"rotate"}}function cr(n,t,e={}){return{...de(n,o=>o.color(t),e),label:"recolor"}}function pl(n,t,e={}){return{...de(n,o=>o.opacity(t),{duration:.6,...e}),label:"fade"}}function fl(n,t,e={}){return{label:"along",duration:e.duration??2,ease:e.ease,schedule(o){te(n,o.t0,o.stage);let r=t instanceof P?rt(t.get("path")??[],t.worldMatrix()):t,s=n.parent?ur(n.parent.worldMatrix()):null,i=c=>{let[u,h]=Pt(r,c);return s?Q(s,u,h):[u,h]},[a,l]=i(1);if(n.track("x").add({t0:o.t0,t1:o.t1,ease:o.ease,to:a,at:c=>i(c)[0]}),n.track("y").add({t0:o.t0,t1:o.t1,ease:o.ease,to:l,at:c=>i(c)[1]}),e.orient){let c=u=>{let[h,d]=ge(r,u);return Math.atan2(d,h)};n.track("rotation").add({t0:o.t0,t1:o.t1,ease:o.ease,to:c(1),at:c})}}}}function ur(n){let t=n[0]*n[3]-n[1]*n[2];if(Math.abs(t)<1e-12)return[1,0,0,1,0,0];let e=1/t;return[n[3]*e,-n[1]*e,-n[2]*e,n[0]*e,(n[2]*n[5]-n[3]*n[4])*e,(n[1]*n[4]-n[0]*n[5])*e]}function $n(n,t,e={}){let o=Rt(n);return{label:"warp",duration:e.duration??2,ease:e.ease,schedule(r){for(let s of Qt(o)){te(s,r.t0,r.stage);let i=s.get("path"),a=s.worldMatrix(),l=ur(a),c=i.map(h=>On(h,e.subdivisions??6)),u=_o(c,(h,d)=>{let[m,p]=Q(a,h,d),[f,b]=t(m,p);return Q(l,f,b)},1);s.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:u,at:h=>c.map((d,m)=>{let p=d.p,f=u[m].p,b=new Float64Array(p.length);for(let y=0;y<p.length;y++)b[y]=p[y]+(f[y]-p[y])*h;return{p:b,closed:d.closed}})})}}}}function bl(n,t,e={}){let[o,r]=e.origin??[0,0],s=e.yUp===!1?1:-1,[[i,a],[l,c]]=t;return{...$n(n,(u,h)=>{let d=u-o,m=(h-r)*s,p=i*d+a*m,f=l*d+c*m;return[o+p,r+f*s]},{subdivisions:1,...e}),label:"applyMatrix"}}function Ys(n){let t=1;for(let e=n;e;e=e.parent)t*=e.get("opacity");return t}function nn(n){let t=n.worldMatrix(),e=Ys(n),o=0,r=!1;for(let s=n;s;s=s.parent)o+=s.get("z"),r||=s.get("fixed");return{path:rt(n.get("path")??[],t),fill:n.get("fill"),fillOpacity:n.get("fill")?n.get("fillOpacity")*e:0,stroke:n.get("stroke"),strokeOpacity:n.get("stroke")?n.get("strokeOpacity")*e:0,strokeWidth:n.get("strokeWidth")*Xt(t),glow:n.get("glow"),glowColor:n.get("glowColor"),cap:n.get("cap"),dash:n.get("dash"),z:o,fixed:r,key:n.data.key}}function en(n,t,e,o){let r=new P;return r.base.visible=!1,r.base.path=t.path,r.base.cap=t.cap,r.base.z=t.z,r.base.fixed=t.fixed,r.base.fill=t.fill??e.fill,r.base.stroke=t.stroke??e.stroke,r.base.fillOpacity=t.fillOpacity,r.base.strokeOpacity=t.strokeOpacity,r.base.strokeWidth=t.strokeWidth||e.strokeWidth,r.base.glow=t.glow,r.base.glowColor=t.glowColor??e.glowColor,n.root.add(r),r.track("visible").initial=!1,r.track("visible").keys.length=0,et(r,"visible",!0,o.appear??o.t0),r.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:e.path,at:Ze(t.path,e.path)}),t.fill&&e.fill&&r.tween("fill",e.fill,o.t0,o.t1,o.ease),t.stroke&&e.stroke&&r.tween("stroke",e.stroke,o.t0,o.t1,o.ease),r.tween("fillOpacity",e.fillOpacity,o.t0,o.t1,o.ease),r.tween("strokeOpacity",e.strokeOpacity,o.t0,o.t1,o.ease),r.tween("strokeWidth",e.strokeWidth||t.strokeWidth,o.t0,o.t1,o.ease),t.glow!==e.glow&&r.tween("glow",e.glow,o.t0,o.t1,o.ease),et(r,"visible",!1,o.hide??o.t1),r}function qs(n,t){let e=Math.max(n.length,t.length),o=[];for(let r=0;r<e;r++)o.push([n[Math.min(n.length-1,Math.floor(r*n.length/e))],t[Math.min(t.length-1,Math.floor(r*t.length/e))]]);return o}function gl(n,t,e={}){let o=Rt(n),r=Rt(t);return{label:"morph",duration:e.duration??1.2,ease:e.ease,schedule(s){hr(r,s);let i=Qt(o).map(nn),a=Qt(r).map(nn);if(i.length===0||a.length===0){for(let h of o)jt(h,s.t0);for(let h of r)te(h,s.t0,s.stage);return}let l=qs(i,a),c=e.lag??0,u=(s.t1-s.t0)/(1+Math.max(0,l.length-1)*c);l.forEach(([h,d],m)=>{let p=s.t0+m*c*u;en(s.stage,h,d,{t0:p,t1:p+u,ease:s.ease,appear:s.t0,hide:s.t1})}),dr(o,r,s)}}}function hr(n,t){S.now=t.t0;for(let e of n)t.stage.mountAt(e,t.t0),jt(e,t.t0)}function dr(n,t,e){for(let o of n)jt(o,e.t0);for(let o of t)o.track("visible").step(e.t1,!0);S.now=e.t0}function we(n,t,e={}){return{label:"morphMatching",duration:e.duration??1.4,ease:e.ease,schedule(o){hr([t],o);let r=e.key??(f=>f.data.key),s=Qt(n),i=Qt(t),a=s.map(nn),l=i.map(nn),c=Je(s.map(r),i.map(r)),u=new Set(c.map(([f])=>f)),h=new Set(c.map(([,f])=>f));for(let[f,b]of c)en(o.stage,a[f],l[b],o);let d=o.t1-o.t0,m=e.fadeShift??[0,0],p=(f,b,y)=>rt(f,[1,0,0,1,b,y]);a.forEach((f,b)=>{u.has(b)||en(o.stage,f,{...f,path:p(f.path,m[0],m[1]),fillOpacity:0,strokeOpacity:0},{t0:o.t0,t1:o.t0+d*.55,ease:o.ease})}),l.forEach((f,b)=>{h.has(b)||en(o.stage,{...f,path:p(f.path,-m[0],-m[1]),fillOpacity:0,strokeOpacity:0},f,{t0:o.t0+d*.35,t1:o.t1,ease:o.ease})}),dr([n],[t],o)}}}function yl(n,t={}){let o=Rt(n).map(r=>js(de(r,s=>{s.scale(t.scale??1.14),s.color(t.color??"yellow")},{restore:!0}),{ease:t.ease??Rn}));return{...Ln(...o),label:"indicate",duration:t.duration??.9}}function wl(n,t={}){return{label:"shake",duration:t.duration??.8,ease:Yo(t.cycles??3),schedule(e){S.now=e.t0;let[o,r]=n.center;n.pivotAt([o,r]);let s=n.get("rotation"),i=t.angle??.08;n.track("rotation").add({t0:e.t0,t1:e.t1,ease:e.ease,to:s,at:l=>s+i*l})}}}function xl(n,t={}){return{label:"circumscribe",duration:t.duration??1.3,ease:t.ease??Te,schedule(e){let o=n.bounds(),r=t.pad??14,s=new P(K(o.x-r,o.y-r,o.width+r*2,o.height+r*2,t.radius??12)).stroke(t.color??"yellow",t.width??3).glow(8);e.stage.add(s);let i=e.t0,a=e.t1,l=i+(a-i)*.55;et(s,"trimTo",0,i),s.tween("trimTo",1,i,l,dt),s.tween("trimFrom",1,l-(a-i)*.08,a,dt),jt(s,a)}}}function kl(n,t={}){return{label:"flash",duration:t.duration??.7,ease:t.ease??dt,schedule(e){let o=n instanceof P?n.center:n,r=t.radius??54,s=t.rays??12;for(let i=0;i<s;i++){let a=i/s*Math.PI*2,l=Math.cos(a),c=Math.sin(a),u=new P(le([o[0]+l*r*.35,o[1]+c*r*.35],[o[0]+l*r,o[1]+c*r])).stroke(t.color??"yellow",2.5).glow(5);e.stage.add(u),et(u,"trimTo",0,e.t0),u.tween("trimTo",1,e.t0,e.t0+(e.t1-e.t0)*.6,e.ease),u.tween("trimFrom",1,e.t0+(e.t1-e.t0)*.25,e.t1,e.ease),jt(u,e.t1)}}}}function Ml(n,t={}){return{label:"ripple",duration:t.duration??1,ease:t.ease??dt,schedule(e){let o=n instanceof P?n.center:n,r=new P(Dt(0,0,t.radius??90)).stroke(t.color??"blue",t.width??3).at(o);e.stage.add(r),et(r,"sx",.05,e.t0),et(r,"sy",.05,e.t0),r.tween("sx",1,e.t0,e.t1,e.ease),r.tween("sy",1,e.t0,e.t1,e.ease),r.tween("strokeOpacity",0,e.t0+(e.t1-e.t0)*.2,e.t1,e.ease),jt(r,e.t1)}}}function Bn(n,t={}){return{label:"pulse",duration:t.duration??1.1,ease:t.ease??dt,schedule(e){let o=n.get("path");if(!o)return;let r=new P(rt(o,n.worldMatrix())).stroke(t.color??"yellow",t.width??n.get("strokeWidth")+1.5).glow(t.glow??10);e.stage.add(r);let s=t.length??.18;et(r,"trimFrom",0,e.t0),et(r,"trimTo",0,e.t0),r.track("trimTo").add({t0:e.t0,t1:e.t1,ease:e.ease,to:1,at:i=>Math.min(1,i*(1+s))}),r.track("trimFrom").add({t0:e.t0,t1:e.t1,ease:e.ease,to:1,at:i=>Math.max(0,i*(1+s)-s)}),jt(r,e.t1)}}}var pt=class{track;constructor(t){this.track=new ye(t)}get value(){return this.track.sample(S.now)}set(t){return this.track.step(S.now,t),this}to(t,e={}){let o=this.track;return{label:"value",duration:e.duration??1,ease:e.ease,schedule(r){let s=o.sample(r.t0);o.add({t0:r.t0,t1:r.t1,ease:r.ease,to:t,at:i=>s+(t-s)*i})}}}};var Us=()=>S.now,Zs=14,Js=96;function mr(n,t){return!n||!yt(n)?n:n.type==="linear"?{...n,from:Q(t,n.from[0],n.from[1]),to:Q(t,n.to[0],n.to[1])}:n.type==="radial"?{...n,center:Q(t,n.center[0],n.center[1]),radius:n.radius*Xt(t)}:n}function Qs(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]&&n[4]===t[4]&&n[5]===t[5]}var pr=new WeakMap;function ti(n,t,e){let o=pr.get(n);if(o&&o.path===t&&Qs(o.matrix,e))return o.world;let r=rt(t,e);return pr.set(n,{path:t,matrix:e,world:r}),r}function ei(n,t,e,o,r){let s=n.get("fill"),i=n.get("stroke"),a=s?o*n.get("fillOpacity"):0,l=i?o*n.get("strokeOpacity"):0,c=n.get("glow");if(a<=.002&&l<=.002&&c<=0)return;let u=ti(n,t,e),h=Xt(e),d=n.get("trimFrom"),m=n.get("trimTo"),p=u;if((d>0||m<1)&&(p=Jt(u,d,m,n.get("trimEach"))),p.length===0&&a<=.002)return;let f=n.get("dash"),b={kind:"path",path:u,strokePath:p,fill:a>.002?mr(s,e):null,fillAlpha:a,stroke:l>.002?mr(i,e):null,strokeAlpha:l,strokeWidth:n.get("strokeWidth")*h,cap:n.get("cap"),join:n.get("join"),dash:f?f.map(y=>y*h):null,dashOffset:n.get("dashOffset")*h,glow:c*h,glowColor:n.get("glowColor"),blend:n.get("blend"),node:n};b.stroke&&yt(b.stroke)&&b.stroke.type==="along"?ni(b,b.stroke,r):r.push(b)}function ni(n,t,e){e.push({...n,stroke:null,strokeAlpha:0});let o={...n,fill:null,fillAlpha:0,glow:0},r=At(n.strokePath),s=At(n.path);if(r===0)return;let i=s>0?Math.min(1,r/s):1,a=Math.min(Js,Math.max(2,Math.ceil(r/Zs))),l=.6/a;for(let c=0;c<a;c++){let u=c/a,h=Math.min(1,(c+1)/a+l),d=Jt(n.strokePath,u,h);d.length!==0&&e.push({...o,strokePath:d,path:d,stroke:lt(t.stops,(c+.5)/a*i),cap:c===0||c===a-1?n.cap:"butt"})}}function Dn(n,t,e,o,r){if(!n.get("visible"))return;let s=n.get("opacity")*o;if(s<=.002)return;let i=n.get("fixed")?e:t,a=ot(i,n.localMatrix()),l=n.get("path");l&&l.length>0&&ei(n,l,a,s,r);let c=n.get("image");if(c&&r.push({kind:"image",image:c,matrix:a,alpha:s}),n.rawOps&&n.rawOps(a,s,r),n.draw){let m=n.draw(Us());if(m){let p=Array.isArray(m)?m:[m];for(let f of p)Dn(f,a,e,s,r)}}let u=n.children;if(u.length===0)return;let h=!1;for(let m=0;m<u.length;m++)if(u[m].get("z")!==0){h=!0;break}let d=h?u.map((m,p)=>({child:m,index:p,z:m.get("z")})).sort((m,p)=>m.z-p.z||m.index-p.index).map(m=>m.child):u;for(let m of d)Dn(m,a,e,s,r)}function Gn(n,t,e,o){let r=[1,0,0,1,e/2,o/2],s=ot(r,fe(0,0,-t.rotation,t.zoom,t.zoom,t.x,t.y)),i=[];return Dn(n,s,r,1,i),i}var fr=7;function xr(n,t){let e=[];for(let o=fr;o>=1;o--){let r=o/fr;e.push({width:t+n*2*r,alpha:.16*(1-r)*(1-r)+.018})}return e}function kr(n){if(n.glowColor)return n.glowColor;let t=n.stroke??n.fill;return t?yt(t)?lt(t.stops,.5):t:null}var br=new WeakMap;function rn(n){let t=br.get(n);return t===void 0&&(t=Xo(n),br.set(n,t)),t}function ft(n){return String(Math.round(n*1e3)/1e3)}function oi(n,t){let e=t.stops.map(([o,r])=>`<stop offset="${ft(o)}" stop-color="${Yt([r[0],r[1],r[2],1])}"${r[3]<1?` stop-opacity="${ft(r[3])}"`:""}/>`).join("");return t.type==="linear"?`<linearGradient id="${n}" gradientUnits="userSpaceOnUse" x1="${ft(t.from[0])}" y1="${ft(t.from[1])}" x2="${ft(t.to[0])}" y2="${ft(t.to[1])}">${e}</linearGradient>`:t.type==="radial"?`<radialGradient id="${n}" gradientUnits="userSpaceOnUse" cx="${ft(t.center[0])}" cy="${ft(t.center[1])}" r="${ft(t.radius)}">${e}</radialGradient>`:""}function gr(n){let t=` stroke-linecap="${n.cap}" stroke-linejoin="${n.join}"`;return n.dash&&(t+=` stroke-dasharray="${n.dash.map(ft).join(" ")}" stroke-dashoffset="${ft(n.dashOffset)}"`),t}function ri(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function jn(n,t={}){let e=t.scale??1,o=n.width,r=n.height,s=[],i=[],a=0,l=(u,h,d)=>{if(yt(u)){let f=`g${a++}`;return s.push(oi(f,u)),`${h}="url(#${f})"${d<1?` ${h}-opacity="${ft(d)}"`:""}`}let m=u,p=m[3]*d;return`${h}="${Yt([m[0],m[1],m[2],1])}"${p<1?` ${h}-opacity="${ft(p)}"`:""}`};n.background&&!t.transparent&&i.push(`<rect width="${o}" height="${r}" fill="${n.background}"/>`);for(let u of n.ops){if(u.kind==="image"){let d=u.matrix;i.push(`<image href="${ri(u.image.src)}" width="${u.image.width}" height="${u.image.height}" transform="matrix(${d.map(ft).join(" ")})"${u.alpha<1?` opacity="${ft(u.alpha)}"`:""} preserveAspectRatio="none"/>`);continue}let h=u.blend!=="normal"?` style="mix-blend-mode:${u.blend}"`:"";if(u.glow>0){let d=kr(u),m=rn(u.strokePath.length?u.strokePath:u.path);if(d&&m){let p=Math.max(u.fillAlpha,u.strokeAlpha),f=n.dark?' style="mix-blend-mode:screen"':"",b=xr(u.glow,u.stroke?u.strokeWidth:0).map(y=>`<path d="${m}" fill="none" stroke="${Yt([d[0],d[1],d[2],1])}" stroke-opacity="${ft(y.alpha*p)}" stroke-width="${ft(y.width)}" stroke-linecap="round" stroke-linejoin="round"/>`).join("");i.push(`<g${f}>${b}</g>`)}}if(u.fill&&u.stroke&&u.strokePath===u.path){i.push(`<path d="${rn(u.path)}" ${l(u.fill,"fill",u.fillAlpha)} ${l(u.stroke,"stroke",u.strokeAlpha)} stroke-width="${ft(u.strokeWidth)}"${gr(u)}${h}/>`);continue}u.fill&&i.push(`<path d="${rn(u.path)}" ${l(u.fill,"fill",u.fillAlpha)}${h}/>`),u.stroke&&u.strokePath.length&&i.push(`<path d="${rn(u.strokePath)}" fill="none" ${l(u.stroke,"stroke",u.strokeAlpha)} stroke-width="${ft(u.strokeWidth)}"${gr(u)}${h}/>`)}let c=s.length?`<defs>${s.join("")}</defs>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${o*e}" height="${r*e}" viewBox="0 0 ${o} ${r}">${c}${i.join("")}</svg>`}var yr=new WeakMap;function Wn(n){let t=yr.get(n);if(t)return t;t=new Path2D;for(let e of n){let o=e.p;if(!(o.length<2)){if(t.moveTo(o[0],o[1]),e.straight)for(let r=2;r+5<o.length;r+=6)t.lineTo(o[r+4],o[r+5]);else for(let r=2;r+5<o.length;r+=6)t.bezierCurveTo(o[r],o[r+1],o[r+2],o[r+3],o[r+4],o[r+5]);e.closed&&t.closePath()}}return yr.set(n,t),t}function wr(n,t){if(!yt(t))return Yt(t);let e=t.type==="linear"?n.createLinearGradient(t.from[0],t.from[1],t.to[0],t.to[1]):t.type==="radial"?n.createRadialGradient(t.center[0],t.center[1],0,t.center[0],t.center[1],t.radius):null;if(!e)return Yt(lt(t.stops,.5));for(let[o,r]of t.stops)e.addColorStop(o,Yt(r));return e}var si={normal:"source-over",screen:"screen",multiply:"multiply",overlay:"overlay"};function Hn(n,t,e=1,o){n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.globalCompositeOperation="source-over",n.clearRect(0,0,t.width*e,t.height*e),n.setTransform(e,0,0,e,0,0),t.background&&(n.fillStyle=t.background,n.fillRect(0,0,t.width,t.height));for(let r of t.ops){if(r.kind==="image"){let s=o?.(r.image);if(!s)continue;let i=r.matrix;n.save(),n.transform(i[0],i[1],i[2],i[3],i[4],i[5]),n.globalAlpha=r.alpha,n.drawImage(s,0,0,r.image.width,r.image.height),n.restore();continue}if(n.globalCompositeOperation=si[r.blend],r.glow>0){let s=kr(r);if(s){let i=Math.max(r.fillAlpha,r.strokeAlpha),a=n.globalCompositeOperation;t.dark&&(n.globalCompositeOperation="screen"),n.strokeStyle=Yt([s[0],s[1],s[2],1]),n.lineCap="round",n.lineJoin="round",n.setLineDash([]);let l=Wn(r.strokePath.length?r.strokePath:r.path);for(let c of xr(r.glow,r.stroke?r.strokeWidth:0))n.globalAlpha=c.alpha*i,n.lineWidth=c.width,n.stroke(l);n.globalCompositeOperation=a}}r.fill&&(n.globalAlpha=r.fillAlpha,n.fillStyle=wr(n,r.fill),n.fill(Wn(r.path))),r.stroke&&r.strokePath.length&&(n.globalAlpha=r.strokeAlpha,n.strokeStyle=wr(n,r.stroke),n.lineWidth=r.strokeWidth,n.lineCap=r.cap,n.lineJoin=r.join,n.setLineDash(r.dash?[...r.dash]:[]),n.lineDashOffset=r.dashOffset,n.stroke(Wn(r.strokePath)))}n.globalAlpha=1,n.globalCompositeOperation="source-over"}function ii(n){let t=null;for(let e of n.ops){if(e.kind!=="path")continue;let o=bt(e.path);if(!o)continue;let r=e.stroke?e.strokeWidth/2:0,s={x:o.x-r,y:o.y-r,width:o.width+r*2,height:o.height+r*2};if(!t)t=s;else{let i=Math.min(t.x,s.x),a=Math.min(t.y,s.y);t={x:i,y:a,width:Math.max(t.x+t.width,s.x+s.width)-i,height:Math.max(t.y+t.height,s.y+s.height)-a}}}return t}var ai={"16:9":[1920,1080],"9:16":[1080,1920],"1:1":[1080,1080],"4:3":[1440,1080],"21:9":[2520,1080]},sn=class{root=new P;camera=new P;width;height;fps;look;chapters=[];clips=[];captions=[];updaters=[];time=0;ending=0;constructor(t){let[e,o]=ai[t.aspect??"16:9"];this.width=t.width??e,this.height=t.height??o,this.fps=t.fps??60,this.look=qe(t.look),this.root.mounted=!0,this.camera.mounted=!0}get right(){return this.width/2}get left(){return-this.width/2}get top(){return-this.height/2}get bottom(){return this.height/2}add(t,...e){S.now=this.time;for(let o of[t,...e])o.mounted?o.get("visible")||o.track("visible").step(this.time,!0):(o.parent?.drop(o),o.parent=this.root,this.root.children.push(o),tn(o,this.time));return t}mountAt(t,e){t.mounted||(t.parent?.drop(t),t.parent=this.root,this.root.children.push(t),tn(t,e))}remove(...t){for(let e of t)e.track("visible").step(this.time,!1)}play(...t){let e=t.filter(l=>"schedule"in l),o=t.find(l=>!("schedule"in l))??{};if(e.length===0)return this;let r=Math.max(...e.map(l=>l.duration)),s=o.duration??r,i=this.time,a=i+s;for(let l of e){S.now=i;let c=o.duration!==void 0?a:i+l.duration;l.schedule({t0:i,t1:c,ease:o.ease??l.ease??dt,stage:this})}return this.clips.push({t0:i,t1:a,labels:o.label?[o.label]:e.map(l=>l.label)}),this.time=a,this.ending=Math.max(this.ending,a),S.now=a,this}wait(t=1){return this.time+=t,this.ending=Math.max(this.ending,this.time),S.now=this.time,this}at(t,e){let o=this.time;return this.time=t,S.now=t,e(),this.ending=Math.max(this.ending,this.time),this.time=o,S.now=o,this}chapter(t){return this.chapters.push({title:t,time:this.time}),this}caption(t,e=3){return this.captions.push({t0:this.time,t1:this.time+e,text:t}),this.ending=Math.max(this.ending,this.time+e),this}value(t=0){return new pt(t)}update(t,e,o={}){return this.updaters.push({node:t,fn:e,from:o.from??this.time,to:o.to??1/0}),t}get duration(){return Math.max(this.ending,this.time)}};function li(n,t){let e=typeof n=="function"?{}:n,o=typeof n=="function"?n:t;if(!o)throw new Error("film(options, build) needs a build function.");let r={kind:"vizmatic.film",options:e,build:o,compile:s=>ln(r,s)};return r}function Ie(n){return!!n&&typeof n=="object"&&n.kind==="vizmatic.film"}var Nt=class{constructor(t){this.promise=t}promise;isVizmaticSuspend=!0};function _n(n){return typeof n=="object"&&n!==null&&n.isVizmaticSuspend===!0}var an=class{width;height;fps;duration;title;description;look;bloom;background;posterTime;bleed;chapters;clips;captions;stage;constructor(t,e,o){this.stage=t,this.width=t.width,this.height=t.height,this.fps=o.fps??t.fps,this.duration=Math.max(t.duration,1/this.fps),this.title=e.title??"",this.description=e.description??"",this.look=t.look,this.bloom=o.bloom??e.bloom??t.look.bloom;let r=o.background!==void 0?o.background:e.background!==void 0?e.background:t.look.background;this.background=r===null?null:t.look.colors[r]??r,this.posterTime=e.poster,this.bleed=e.bleed===!0,this.chapters=t.chapters,this.clips=t.clips,this.captions=t.captions}get frameCount(){return Math.max(1,Math.round(this.duration*this.fps))}frame(t){let e=Math.max(0,Math.min(this.duration,t)),o=this.stage,r={mode:S.mode,now:S.now};In(o.look.colors),S.mode="render",S.now=e,S.frame++;try{for(let a of o.updaters)e>=a.from&&e<=a.to&&a.fn(a.node,e);let s=o.camera,i=Gn(o.root,{x:s.get("x"),y:s.get("y"),zoom:s.get("sx"),rotation:s.get("rotation")},o.width,o.height);return{width:o.width,height:o.height,background:this.background,bloom:this.bloom,dark:o.look.dark,ops:i}}finally{S.mode=r.mode,S.now=r.now}}svg(t,e={}){return jn(this.frame(t),e)}};async function ln(n,t={}){let e={...n.options,...t.look?{look:t.look}:{},...t.fps?{fps:t.fps}:{}};for(let o=0;o<64;o++){let r=new sn(e);In(r.look.colors);let s={mode:S.mode,now:S.now};S.mode="compile",S.now=0;try{await n.build(r),S.mode=s.mode,S.now=s.now;let i=new an(r,e,t);return await ci(i),i}catch(i){if(S.mode=s.mode,S.now=s.now,S.capture=null,i instanceof Nt){await i.promise;continue}throw i}}throw new Error("The film kept requesting new assets while compiling.")}async function ci(n){let t=[0,.25,.5,.75,1];for(let e of t)for(let o=0;o<16;o++)try{n.frame(n.duration*e);break}catch(r){if(!(r instanceof Nt))throw r;await r.promise}}function Mr(n){return{contours:n.filter(t=>t.length>=8)}}var vr=null;function Kn(n){vr=n}var ui=typeof process<"u"&&!!process.versions?.node&&typeof globalThis.document>"u";function Pr(){let n=import.meta.url;return n||`file://${typeof __filename<"u"?__filename:""}`}async function hi(n){let t="node:fs/promises",e="node:path",o="node:url",[r,s,i]=await Promise.all([import(t),import(e),import(o)]),a=s.dirname(i.fileURLToPath(Pr()));for(let l=0;l<6;l++){let c=s.join(a,"assets",n);try{let u=await r.readFile(c);return u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength)}catch(u){if(u.code!=="ENOENT")throw u}a=s.dirname(a)}throw new Error(`Bundled asset not found: assets/${n}`)}async function Ar(n){if(ui)return hi(n);let t=vr??new URL("./assets/",Pr()).href,e=await fetch(new URL(n,t)),o=e.headers.get("content-type")??"";if(!e.ok||o.includes("text/html"))throw new Error(`Could not load ${n} from ${e.url} (HTTP ${e.status}, ${o||"no content type"}). Call setAssetBase() with the folder that holds fonts/.`);return e.arrayBuffer()}var Yn=class{constructor(t,e=0){this.bytes=t;this.offset=e;this.view=new DataView(t)}bytes;offset;view;seek(t){return this.offset=t,this}get position(){return this.offset}u8(){return this.view.getUint8(this.offset++)}i8(){return this.view.getInt8(this.offset++)}u16(){let t=this.view.getUint16(this.offset);return this.offset+=2,t}i16(){let t=this.view.getInt16(this.offset);return this.offset+=2,t}u32(){let t=this.view.getUint32(this.offset);return this.offset+=4,t}tag(){let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.u8());return t}};function Tr(n){let t=new Yn(n),e=t.u32();if(e!==65536&&e!==1953658213)throw new Error("Stage text needs a TrueType (.ttf) font with glyf outlines.");let o=t.u16();t.seek(12);let r=new Map;for(let A=0;A<o;A++){let O=t.tag();t.u32(),r.set(O,{offset:t.u32(),length:t.u32()})}let s=A=>{let O=r.get(A);if(!O)throw new Error(`Font is missing its ${A} table.`);return O},i=s("head");t.seek(i.offset+18);let a=t.u16();t.seek(i.offset+50);let l=t.i16()===1,c=s("hhea");t.seek(c.offset+4);let u=t.i16(),h=t.i16(),d=t.i16();t.seek(c.offset+34);let m=t.u16();t.seek(s("maxp").offset+4);let p=t.u16(),f=s("hmtx"),b=s("loca"),y=s("glyf"),g=mi(t,s("cmap").offset),w=r.has("GPOS")?pi(t,r.get("GPOS").offset):()=>0,x=A=>{let O=Math.min(A,m-1);return t.seek(f.offset+O*4),t.u16()},k=new Map,M=(A,O)=>{if(A>=p||O>6)return[];t.seek(b.offset+(l?A*4:A*2));let N=l?t.u32():t.u16()*2,T=l?t.u32():t.u16()*2;if(N===T)return[];t.seek(y.offset+N);let V=t.i16();if(t.seek(t.position+8),V<0)return v(A,O);let z=[];for(let R=0;R<V;R++)z.push(t.u16());let B=t.u16();t.seek(t.position+B);let W=(z[z.length-1]??-1)+1,G=[];for(;G.length<W;){let R=t.u8();if(G.push(R),R&8){let $=t.u8();for(;$-- >0;)G.push(R)}}let U=new Array(W),C=0;for(let R=0;R<W;R++){let $=G[R];if($&2){let j=t.u8();C+=$&16?j:-j}else $&16||(C+=t.i16());U[R]=C}let L=new Array(W),I=0;for(let R=0;R<W;R++){let $=G[R];if($&4){let j=t.u8();I+=$&32?j:-j}else $&32||(I+=t.i16());L[R]=I}let F=[],E=0;for(let R of z)F.push(di(U,L,G,E,R)),E=R+1;return F};function v(A,O){let N=[],T=!0;for(;T;){let z=t.u16(),B=t.u16(),W=(z&1)!==0,G=(z&2)!==0,U=0,C=0;W?(U=t.i16(),C=t.i16()):(U=t.i8(),C=t.i8()),G||(U=0,C=0);let L=1,I=0,F=0,E=1,R=()=>t.i16()/16384;z&8?L=E=R():z&64?(L=R(),E=R()):z&128&&(L=R(),I=R(),F=R(),E=R()),N.push({glyph:B,m:[L,I,F,E,U,C]}),T=(z&32)!==0}let V=[];for(let z of N)for(let B of M(z.glyph,O+1)){let W=new Array(B.length),[G,U,C,L,I,F]=z.m;for(let E=0;E<B.length;E+=2)W[E]=G*B[E]+C*B[E+1]+I,W[E+1]=U*B[E]+L*B[E+1]+F;V.push(W)}return V}return{unitsPerEm:a,ascent:u,descent:h,lineGap:d,glyphFor(A){return g(A)},advance:x,kern(A,O){return w(A,O)},outline(A){if(k.has(A))return k.get(A);let O=M(A,0),N=O.length?Mr(O):null;return k.set(A,N),N}}}function di(n,t,e,o,r){let s=r-o+1;if(s<2)return[];let i=w=>o+(w%s+s)%s,a=w=>(e[i(w)]&1)!==0,l=0;for(;l<s&&!a(l);)l++;let c,u;l===s?(c=(n[i(0)]+n[i(s-1)])/2,u=(t[i(0)]+t[i(s-1)])/2,l=0):(c=n[i(l)],u=t[i(l)],l+=1);let h=[c,u],d=c,m=u,p=0,f=0,b=!1,y=(w,x,k,M)=>{h.push(d+(w-d)*2/3,m+(x-m)*2/3,k+(w-k)*2/3,M+(x-M)*2/3,k,M),d=k,m=M},g=(w,x)=>{h.push(d+(w-d)/3,m+(x-m)/3,d+(w-d)*2/3,m+(x-m)*2/3,w,x),d=w,m=x};for(let w=0;w<s;w++){let x=l+w,k=n[i(x)],M=t[i(x)];a(x)?b?(y(p,f,k,M),b=!1):(k!==d||M!==m)&&g(k,M):(b&&y(p,f,(p+k)/2,(f+M)/2),p=k,f=M,b=!0)}return b?y(p,f,c,u):(d!==c||m!==u)&&g(c,u),h}function mi(n,t){n.seek(t+2);let e=n.u16(),o=-1,r=-1;for(let i=0;i<e;i++){let a=n.u16(),l=n.u16(),c=n.u32(),u=a===3&&l===10?4:a===0&&l>=4?3:a===3&&l===1?2:a===0?1:0;u>r&&(r=u,o=t+c)}if(o<0)return()=>0;n.seek(o);let s=n.u16();if(s===12){n.seek(o+12);let i=n.u32(),a=[];for(let l=0;l<i;l++)a.push([n.u32(),n.u32(),n.u32()]);return l=>{let c=0,u=a.length-1;for(;c<=u;){let h=c+u>>1,[d,m,p]=a[h];if(l<d)u=h-1;else if(l>m)c=h+1;else return p+l-d}return 0}}if(s===4){n.seek(o+6);let i=n.u16(),a=i/2,l=o+14,c=l+i+2,u=c+i,h=u+i,d=new Map;for(let m=0;m<a;m++){let p=n.seek(l+m*2).u16(),f=n.seek(c+m*2).u16(),b=n.seek(u+m*2).i16(),y=n.seek(h+m*2).u16();for(let g=f;g<=p&&g!==65535;g++){let w;if(y===0)w=g+b&65535;else{let x=n.seek(h+m*2+y+(g-f)*2).u16();w=x===0?0:x+b&65535}w&&d.set(g,w)}}return m=>d.get(m)??0}return()=>0}function pi(n,t){let e=[];try{n.seek(t+6);let r=t+n.u16(),s=t+n.u16();n.seek(r);let i=n.u16(),a=new Set;for(let l=0;l<i;l++){n.seek(r+2+l*6);let c=n.tag(),u=n.u16();if(c!=="kern")continue;n.seek(r+u+2);let h=n.u16();for(let d=0;d<h;d++)a.add(n.u16())}for(let l of[...a].sort((c,u)=>c-u)){n.seek(s+2+l*2);let c=s+n.u16();n.seek(c);let u=n.u16();n.u16();let h=n.u16(),d=[];for(let p=0;p<h;p++)d.push(c+n.u16());let m=[];for(let p of d){let f=p,b=u;b===9&&(n.seek(f+2),b=n.u16(),f+=n.u32()),b===2&&m.push(bi(n,f))}e.push(m)}}catch{}let o=new Map;return(r,s)=>{let i=r*65536+s,a=o.get(i);if(a!==void 0)return a;let l=0;for(let c of e)for(let u of c){let h=u(r,s);if(h!==void 0){l+=h;break}}return o.set(i,l),l}}function fi(n,t){n.seek(t);let e=n.u16(),o=new Set;if(e===1){let r=n.u16();for(let s=0;s<r;s++)o.add(n.u16())}else if(e===2){let r=n.u16();for(let s=0;s<r;s++){let i=n.u16(),a=n.u16();n.u16();for(let l=i;l<=a;l++)o.add(l)}}return o}function Or(n,t){n.seek(t);let e=n.u16(),o=new Map;if(e===1){let r=n.u16(),s=n.u16();for(let i=0;i<s;i++)o.set(r+i,n.u16())}else if(e===2){let r=n.u16();for(let s=0;s<r;s++){let i=n.u16(),a=n.u16(),l=n.u16();for(let c=i;c<=a;c++)o.set(c,l)}}return r=>o.get(r)??0}function Nr(n){let t=0;for(let e=0;e<8;e++)n&1<<e&&t++;return t*2}function Cr(n,t){let e=0;t&1&&n.i16(),t&2&&n.i16(),t&4&&(e=n.i16()),t&8&&n.i16();for(let o=4;o<8;o++)t&1<<o&&n.u16();return e}function bi(n,t){n.seek(t);let e=n.u16(),o=n.u16(),r=n.u16(),s=n.u16(),i=Nr(r),a=Nr(s);if(e===1){let l=n.u16(),c=[];for(let m=0;m<l;m++)c.push(n.u16());n.seek(t+o);let u=n.u16(),h=[];if(u===1){let m=n.u16();for(let p=0;p<m;p++)h.push(n.u16())}else if(u===2){let m=n.u16();for(let p=0;p<m;p++){let f=n.u16(),b=n.u16();n.u16();for(let y=f;y<=b;y++)h.push(y)}}let d=new Map;for(let m=0;m<l;m++){n.seek(t+c[m]);let p=n.u16(),f=new Map;for(let b=0;b<p;b++){let y=n.u16(),g=Cr(n,r);n.seek(n.position+a),f.set(y,g)}h[m]!==void 0&&d.set(h[m],f)}return(m,p)=>d.get(m)?.get(p)}if(e===2){let l=n.u16(),c=n.u16(),u=n.u16(),h=n.u16(),d=n.position,m=fi(n,t+o),p=Or(n,t+l),f=Or(n,t+c);return(b,y)=>{if(!m.has(b))return;let g=p(b),w=f(y);if(!(g>=u||w>=h))return n.seek(d+g*h*(i+a)+w*(i+a)),Cr(n,r)}}return()=>{}}var gi={sans:{400:"Inter-Regular.ttf",600:"Inter-SemiBold.ttf",700:"Inter-Bold.ttf"},serif:{400:"InstrumentSerif-Regular.ttf",italic:"InstrumentSerif-Italic.ttf"},"text-serif":{400:"SourceSerif4-24pt-Regular.ttf",italic:"SourceSerif4-24pt-Italic.ttf"},mono:{400:"JetBrainsMono-Regular.ttf"},noto:{400:"NotoSans-Regular.ttf"},math:{400:"NotoSansMath-Regular.ttf"}},yi={sans:["noto","math"],serif:["text-serif","noto","math"],"text-serif":["noto","math"],mono:["noto","math"],noto:["math"]},Sr=new Map,Xn=new Map;function xe(n,t=400,e=!1){let o=gi[n],r=(e?o.italic:void 0)??o[String(t)]??o[400],s=Sr.get(r);if(s)return s;let i=Xn.get(r);throw i||(i=Ar(`fonts/${r}`).then(a=>{Sr.set(r,Tr(a)),Xn.delete(r)}),Xn.set(r,i)),new Nt(i)}function Fr(n,t,e=400,o=!1){for(let r of yi[n]){let s=xe(r,e,o),i=s.glyphFor(t);if(i!==0)return{font:s,glyph:i}}return null}var Rr=new WeakMap;function Ee(n,t,e){let o=Rr.get(n);o||Rr.set(n,o=new Map);let r=o.get(e);r||o.set(e,r=new Map);let s=r.get(t);if(s)return s;let i=n.outline(t),a=e/n.unitsPerEm,l=i?i.contours.map(c=>{let u=new Float64Array(c.length);for(let h=0;h<c.length;h+=2)u[h]=c[h]*a,u[h+1]=-c[h+1]*a;return Mt(u,!0)}):[];return r.set(t,l),l}var cn=class extends P{chars=[];source="";find(t){let e=[],o=this.chars.map(s=>s.data.key).join(""),r=t.replace(/\s/g,"");for(let s=o.indexOf(r);s>=0;s=o.indexOf(r,s+1))e.push(...this.chars.slice(s,s+r.length));return e}};function wi(n){let t=bt(n);if(!t)return{path:n,x:0,y:0};let e=t.x+t.width/2,o=t.y+t.height/2;return{path:rt(n,[1,0,0,1,-e,-o]),x:e,y:o}}function _(n,t={}){let e=t.size??40,o=t.font??"sans",r=t.weight??400,s=t.italic??!1,i=xe(o,r,s),a=e/i.unitsPerEm,l=(t.tracking??0)*e,c=(t.leading??1.3)*e,u=X(t.color??"ink"),h=t.uppercase?n.toUpperCase():n,d=x=>{let k=[],M=0,v=0,A=null;for(let O of x){let N=O.codePointAt(0),T=i,V=i.glyphFor(N);if(V===0){let B=Fr(o,N,r,s);B&&(T=B.font,V=B.glyph)}let z=e/T.unitsPerEm;v&&A===T&&(M+=T.kern(v,V)*z),k.push({font:T,glyph:V,x:M,char:O}),M+=T.advance(V)*z+l,v=V,A=T}return{glyphs:k,width:M}},m=[],p=i.advance(i.glyphFor(32))*a+l;for(let x of h.split(`
2
- `)){let k=[],M=0;for(let v of x.split(" ")){let A=d(v),O=k.length>0?p:0;t.maxWidth!==void 0&&k.length>0&&M+O+A.width>t.maxWidth&&(m.push({glyphs:k,width:M}),k=[],M=0);let N=M+(k.length>0?p:0);for(let T of A.glyphs)k.push({...T,x:T.x+N});M=N+A.width}m.push({glyphs:k,width:M})}let f=Math.max(0,...m.map(x=>x.width)),b=t.align??"left",y=new cn;y.source=n,m.forEach((x,k)=>{let M=b==="left"?0:b==="center"?(f-x.width)/2:f-x.width;for(let v of x.glyphs){let A=Ee(v.font,v.glyph,e);if(A.length===0)continue;let O=wi(A),N=new P(O.path).at(M+v.x+O.x,k*c+O.y);N.base.fill=u,N.base.trimEach=!0,N.data.key=v.char,v.glyph===0&&(N.data.missingGlyph=!0),y.chars.push(N),y.children.push(N),N.parent=y}});let g=i.ascent*a,w=(m.length-1)*c;return y.base.px=f/2,y.base.py=w/2-g*.36,y.data.size=e,y}var un=class extends P{glyphs=[];source="";part(t){let e=zr(t),o=this.glyphs.map(r=>r.data.key);for(let r=0;r+e.length<=o.length;r++)if(e.every((s,i)=>s===o[r+i]))return this.glyphs.slice(r,r+e.length);return[]}parts(t){let e=zr(t),o=this.glyphs.map(s=>s.data.key),r=[];for(let s=0;s+e.length<=o.length;s++)e.every((i,a)=>i===o[s+a])&&(r.push(this.glyphs.slice(s,s+e.length)),s+=e.length-1);return r}},qn=null,Ir=null,Er=new Map;function xi(){if(qn)return qn;throw Ir??=import("./math-4WFNHVV2.js").then(n=>{qn=(t,e)=>n.renderMathSvg(t,{fontSize:1e3,display:e,color:"#000000"}).svg}),new Nt(Ir)}function Vr(n,t){let e=`${t?"D":"I"}${n}`,o=Er.get(e);if(o)return o;let r=xi()(n,t),s=[],i=[],a=[1,0,0,1,0,0],l=/viewBox="([^"]+)"/.exec(r)?.[1]?.trim().split(/[ ,]+/).map(Number)??[0,0,1e3,1e3],u=Number(/\swidth="([\d.]+)px"/.exec(r)?.[1]??1e3)/l[2]/1e3,h=/<(\/?)([a-zA-Z]+)((?:\s+[-\w:]+="[^"]*")*)\s*(\/?)>/g,d=0,m=null,p=[];for(let b=h.exec(r);b;b=h.exec(r)){let[,y,g,w="",x]=b,k=A=>new RegExp(`\\s${A}="([^"]*)"`).exec(w)?.[1];if(g==="svg"){if(y){d--,d>=1&&(a=i.pop()??a,m=p.pop()??null);continue}if(d++,d>1){let A=(k("viewBox")??"0 0 1 1").trim().split(/[ ,]+/).map(Number),O=Number(k("width")??A[2]),N=Number(k("height")??A[3]),T=ot([O/(A[2]||1),0,0,N/(A[3]||1),Number(k("x")??0),Number(k("y")??0)],[1,0,0,1,-A[0],-A[1]]);i.push(a),p.push(m),a=ot(a,T),m=[A[0],A[1],A[0]+A[2],A[1]+A[3]]}continue}if(y){g==="g"&&(a=i.pop()??a);continue}let M=k("transform"),v=M?Mi(M):[1,0,0,1,0,0];if(g==="g"){x||(i.push(a),a=ot(a,v));continue}if(g==="path"){let A=k("d");if(!A)continue;let O=k("data-c"),N=rt(vt(A),v);s.push({path:rt(m?ki(N,m):N,a),key:O?String.fromCodePoint(parseInt(O,16)):"?"})}else if(g==="rect"){let A=Number(k("x")??0),O=Number(k("y")??0),N=Number(k("width")??0),T=Number(k("height")??0);N>0&&T>0&&s.push({path:rt(K(A,O,N,T),ot(a,v)),key:"rule"})}}let f=s.map(b=>({key:b.key,path:rt(b.path,[u,0,0,u,0,0])}));return Er.set(e,f),f}function ki(n,t){return n.map(e=>{let o=new Float64Array(e.p.length);for(let r=0;r<o.length;r+=2)o[r]=Math.max(t[0],Math.min(t[2],e.p[r])),o[r+1]=Math.max(t[1],Math.min(t[3],e.p[r+1]));return{p:o,closed:e.closed}})}function Mi(n){let t=[1,0,0,1,0,0];for(let e of n.matchAll(/(translate|scale|matrix)\(([^)]*)\)/g)){let o=e[2].trim().split(/[ ,]+/).map(Number);e[1]==="translate"?t=ot(t,[1,0,0,1,o[0]??0,o[1]??0]):e[1]==="scale"?t=ot(t,[o[0]??1,0,0,o[1]??o[0]??1,0,0]):o.length===6&&(t=ot(t,o))}return t}function zr(n){return Vr(n,!1).map(t=>t.key)}function st(n,t={}){let e=t.size??56,o=t.display??!0,r=Vr(n,o),s=X(t.color??"ink"),i=new un;i.source=n;let a=1/0,l=1/0,c=-1/0,u=-1/0;for(let h of r){let d=rt(h.path,[e,0,0,e,0,0]),m=bt(d);if(!m)continue;a=Math.min(a,m.x),l=Math.min(l,m.y),c=Math.max(c,m.x+m.width),u=Math.max(u,m.y+m.height);let p=m.x+m.width/2,f=m.y+m.height/2,b=new P(rt(d,[1,0,0,1,-p,-f])).at(p,f);b.base.fill=s,b.base.trimEach=!0,b.data.key=h.key,i.glyphs.push(b),i.children.push(b),b.parent=i}return a!==1/0&&(i.base.px=(a+c)/2,i.base.py=(l+u)/2),i}function Tt(n,t,e){let o=t.fill!==void 0?t.fill:e.fill,r=t.stroke!==void 0?t.stroke:e.stroke;return o&&n.fill(o),r&&n.stroke(r,t.width??e.width??3),t.opacity!==void 0&&n.opacity(t.opacity),t.glow&&n.glow(t.glow),t.dash&&n.dash(t.dash),t.z!==void 0&&n.zIndex(t.z),n}function vi(n,t={}){return Tt(new P(n),t,{stroke:"ink"})}function ec(n,t={}){return vi(vt(n),t)}function Y(n,t,e={}){return Tt(new P(le(n,t)),e,{stroke:"ink"})}function nc(n,t={}){return Tt(new P(Z(n,t.closed)),t,{stroke:"ink"})}function oc(n,t={}){return Tt(new P(t.closed?Lt(n,!0):be(n)),t,{stroke:"ink"})}function rc(n,t,e,o={}){return Tt(new P(_e(n,t,e,o.samples??96)),o,{stroke:"ink"})}function Lr(n,t={}){return Tt(new P(Dt(0,0,n)),t,{stroke:"ink"})}function sc(n,t,e={}){return Tt(new P(St(0,0,n,t,0,Math.PI*2)),e,{stroke:"ink"})}function ic(n,t,e,o={}){return Tt(new P(St(0,0,n,n,t,e)),o,{stroke:"ink"})}function $r(n,t,e={}){return Tt(new P(K(-n/2,-t/2,n,t,e.radius??0)),e,{stroke:"ink"})}function Pi(n,t={}){return Tt(new P(Z(n,!0)),t,{stroke:"ink"})}function ac(n,t,e={}){let o=[];for(let r=0;r<n;r++){let s=-Math.PI/2+r/n*Math.PI*2;o.push([Math.cos(s)*t,Math.sin(s)*t])}return Pi(o,e)}function gt(n=9,t="ink",e={}){return Tt(new P(Dt(0,0,n)),e,{fill:t})}function ze(n,t,e={}){let o=e.stroke??"ink",r=e.width??3,s=e.tip??Math.max(13,r*4.2),i=e.tipRatio??.72,a=e.pad??0,l=t[0]-n[0],c=t[1]-n[1],u=Math.hypot(l,c)||1;l/=u,c/=u;let h=[n[0]+l*a,n[1]+c*a],d=[t[0]-l*a,t[1]-c*a],m=Math.max(0,u-a*2),p=Math.min(s,m*.45),f=new P,b=e.bend??0,y=[-c,l],g=[(h[0]+d[0])/2+y[0]*b,(h[1]+d[1])/2+y[1]*b],w=d[0]-g[0],x=d[1]-g[1],k=Math.hypot(w,x)||1;w/=k,x/=k;let M=d[0]-w*p,v=d[1]-x*p,A=b===0?le(e.both?[h[0]+l*p,h[1]+c*p]:h,[M,v]):vt(`M${h[0]} ${h[1]}Q${g[0]} ${g[1]} ${M} ${v}`),O=new P(A).stroke(o,r);e.dash&&O.dash(e.dash);let N=p*i/2,T=(V,z,B,W)=>new P(Z([[V,z],[V-B*p-W*N,z-W*p+B*N],[V-B*p+W*N,z-W*p-B*N]],!0)).fill(o);return f.add(O,T(d[0],d[1],w,x)),e.both&&f.add(T(h[0],h[1],-l,-c)),e.opacity!==void 0&&f.opacity(e.opacity),e.glow&&O.glow(e.glow),f.data.shaft=O,f}function Br(n,t,e={}){let o=t[0]-n[0],r=t[1]-n[1],s=Math.hypot(o,r)||1,i=e.depth??Math.min(26,10+s*.05),a=s,l=i,c=1.6,u=Math.min(l,a/4),h=`M0 0C0 ${l*.5} ${u*.4} ${l*.5} ${u} ${l*.5}L${a/2-u} ${l*.5}C${a/2-u*.3} ${l*.5} ${a/2} ${l*.72} ${a/2} ${l}C${a/2} ${l*.72} ${a/2+u*.3} ${l*.5} ${a/2+u} ${l*.5}L${a-u} ${l*.5}C${a-u*.4} ${l*.5} ${a} ${l*.5} ${a} 0L${a-c*.2} ${c*.2}C${a-c*.4} ${l*.5-c} ${a-u*.4} ${l*.5-c} ${a-u} ${l*.5-c}L${a/2+u} ${l*.5-c}C${a/2+u*.3} ${l*.5-c} ${a/2+c*.4} ${l*.6} ${a/2} ${l*.82}C${a/2-c*.4} ${l*.6} ${a/2-u*.3} ${l*.5-c} ${a/2-u} ${l*.5-c}L${u} ${l*.5-c}C${u*.4} ${l*.5-c} ${c*.4} ${l*.5-c} ${c*.2} ${c*.2}Z`,d=o/s,m=r/s,p=rt(vt(h),[d,m,-m,d,n[0],n[1]]),f=Tt(new P(p),{...e,width:void 0},{fill:e.stroke??e.fill??"ink"});return f.data.tip=[(n[0]+t[0])/2-m*i,(n[1]+t[1])/2+d*i],f}var Un=class extends P{xRange;yRange;plotWidth;plotHeight;lines=new P;grid=new P;numbers=new P;constructor(t={}){super(),this.xRange=t.x??[-5,5],this.yRange=t.y??[-3,3],this.plotWidth=t.width??1100,this.plotHeight=t.height??640;let e=t.color??"dim",o=t.xStep??Wr(this.xRange[1]-this.xRange[0]),r=t.yStep??Wr(this.yRange[1]-this.yRange[0]),s=hn(0,this.xRange),i=hn(0,this.yRange),a=this.p(this.xRange[0],i),l=this.p(this.xRange[1],i),c=this.p(s,this.yRange[0]),u=this.p(s,this.yRange[1]);if(t.grid){for(let p of ke(this.xRange,o))this.grid.add(Y(this.p(p,this.yRange[0]),this.p(p,this.yRange[1]),{stroke:"grid",width:1.25}));for(let p of ke(this.yRange,r))this.grid.add(Y(this.p(this.xRange[0],p),this.p(this.xRange[1],p),{stroke:"grid",width:1.25}))}let h=t.tips??!0,d=(p,f)=>h?ze(p,f,{stroke:e,width:2,tip:13}):Y(p,f,{stroke:e,width:2});this.lines.add(d(a,l),d(c,u));let m=6;for(let p of ke(this.xRange,o)){if(p===s)continue;let[f,b]=this.p(p,i);this.lines.add(Y([f,b-m],[f,b+m],{stroke:e,width:2}))}for(let p of ke(this.yRange,r)){if(p===i)continue;let[f,b]=this.p(s,p);this.lines.add(Y([f-m,b],[f+m,b],{stroke:e,width:2}))}if(t.labels??!0){let p=t.labelSize??20;for(let f of ke(this.xRange,o)){if(f===s)continue;let[b,y]=this.p(f,i);this.numbers.add(st(Dr(f),{size:p,color:"dim",display:!1}).moveTo([b,y+26]))}for(let f of ke(this.yRange,r)){if(f===i)continue;let[b,y]=this.p(s,f);this.numbers.add(st(Dr(f),{size:p,color:"dim",display:!1}).moveTo([b-28,y]))}}if(this.add(this.grid,this.lines,this.numbers),t.xLabel&&this.add(st(t.xLabel,{size:28,color:"ink",display:!1}).moveTo([l[0]+4,l[1]-26])),t.yLabel){let p=st(t.yLabel,{size:28,color:"ink",display:!1});this.add(p.moveTo([u[0]+16+p.width/2,u[1]+4]))}}p(t,e){let[o,r]=this.xRange,[s,i]=this.yRange;return[((t-o)/(r-o)-.5)*this.plotWidth,(.5-(e-s)/(i-s))*this.plotHeight]}world(t,e){let[o,r]=this.p(t,e);return this.toWorld(o,r)}plotPath(t,e={}){let o=e.from??this.xRange[0],r=e.to??this.xRange[1],s=e.samples??160,[i,a]=this.yRange,l=(a-i)*.02,c=[];for(let u=0;u<=s;u++){let h=o+(r-o)*u/s,d=t(h);c.push(Number.isFinite(d)&&d>=i-l&&d<=a+l?this.p(h,d):[NaN,NaN])}return be(c)}plot(t,e={}){let o=new P(this.plotPath(t,e)).stroke(e.stroke??"blue",e.width??4);return e.glow&&o.glow(e.glow),e.dash&&o.dash(e.dash),this.add(o),o}dotAt(t,e,o="yellow",r=9){let s=gt(r,o).at(this.p(t,e));return this.add(s),s}guides(t,e,o={}){let r=hn(0,this.xRange),s=hn(0,this.yRange),i=Vn(Y(this.p(t,s),this.p(t,e),{stroke:"dim",width:2,dash:[6,7],...o}),Y(this.p(r,e),this.p(t,e),{stroke:"dim",width:2,dash:[6,7],...o}));return this.add(i),i}};function pc(n={}){return new Un(n)}function hn(n,t){return Math.max(t[0],Math.min(t[1],n))}function Wr(n){let t=n/8,e=Math.pow(10,Math.floor(Math.log10(t))),o=t/e;return(o<1.5?1:o<3.5?2:o<7.5?5:10)*e}function ke(n,t){let e=[],o=Math.ceil(n[0]/t-1e-9)*t;for(let r=o;r<=n[1]+1e-9;r+=t)e.push(Math.round(r/t)*t);return e}function Dr(n){let t=Math.round(n*1e3)/1e3;return String(t)}var Ve=class extends P{unit;major=new P;minor=new P;axes=new P;constructor(t={}){super(),this.unit=t.unit??120;let[e,o]=t.x??[-12,12],[r,s]=t.y??[-8,8],i=this.unit,a=t.color??"blue",l=t.width??1.6,c=t.minor??0,u=(p,f,b)=>{let y=[];for(let g=0;g<=b;g++)y.push([p[0]+(f[0]-p[0])*g/b,p[1]+(f[1]-p[1])*g/b]);return y.length>2?be(y):le(p,f)},h=16,d=(p,f,b,y,g,w)=>{p.add(new P(u(f,b,w)).stroke(y,g))};for(let p=e;p<=o;p++){if(c>0&&p<o)for(let f=1;f<c;f++){let b=p+f/c;d(this.minor,[b*i,r*i],[b*i,s*i],"grid",1,h)}p!==0&&d(this.major,[p*i,r*i],[p*i,s*i],a,l,h)}for(let p=r;p<=s;p++){if(c>0&&p<s)for(let f=1;f<c;f++){let b=p+f/c;d(this.minor,[e*i,b*i],[o*i,b*i],"grid",1,h)}p!==0&&d(this.major,[e*i,p*i],[o*i,p*i],a,l,h)}let m=t.axisColor??"ink";d(this.axes,[e*i,0],[o*i,0],m,2.6,h),d(this.axes,[0,r*i],[0,s*i],m,2.6,h),this.add(this.minor,this.major,this.axes)}p(t,e){return[t*this.unit,-e*this.unit]}vector(t,e,o={}){return ze([0,0],this.p(t,e),{stroke:"yellow",width:5,tip:22,...o})}};function fc(n={}){return new Ve(n)}function bc(n,t={}){let e=new P;return e.draw=()=>{let o=n(),r=(t.prefix??"")+o.toFixed(t.digits??2)+(t.suffix??"");return _(r,{size:t.size??36,color:t.color??"ink",font:t.font??"mono"})},e}var dn=1,Gr=.08,jr=.15,Ai=.12,Oi=.12,Ni=5,Hr=12,_r=6,Ci=2,Si=2,Ri=1.6,Kr=.9;function Xr(n){return yt(n)?lt(n.stops,.5):n}function Yr(n){let t=e=>{let o=e/255;return o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4)};return .2126*t(n[0])+.7152*t(n[1])+.0722*t(n[2])}function Ti(n,t,e){let o=n[3]*t,r=[n[0]*o+e[0]*(1-o),n[1]*o+e[1]*(1-o),n[2]*o+e[2]*(1-o),1],s=Yr(r),i=Yr(e);return(Math.max(s,i)+.05)/(Math.min(s,i)+.05)}function qr(n,t){return{x:n.x-t,y:n.y-t,width:n.width+t*2,height:n.height+t*2}}function Fi(n,t){let e=n.width*t,o=n.height*t;return{x:n.x+e,y:n.y+o,width:n.width-e*2,height:n.height-o*2}}function Le(n,t){return n.x<t.x+t.width&&t.x<n.x+n.width&&n.y<t.y+t.height&&t.y<n.y+n.height}function Ii(n,t){let e=Math.max(n.x,t.x),o=Math.max(n.y,t.y),r=Math.min(n.x+n.width,t.x+t.width),s=Math.min(n.y+n.height,t.y+t.height);return r>e&&s>o?{x:e,y:o,width:r-e,height:s-o}:null}function Ei(n,t){return n.x<=t.x&&n.y<=t.y&&n.x+n.width>=t.x+t.width&&n.y+n.height>=t.y+t.height}function mn(n,t){let e=Math.min(n.x,t.x),o=Math.min(n.y,t.y);return{x:e,y:o,width:Math.max(n.x+n.width,t.x+t.width)-e,height:Math.max(n.y+n.height,t.y+t.height)-o}}function zi(n,t,e,o,r){let s=0,i=1,a=e-n,l=o-t,c=[[-a,n-r.x],[a,r.x+r.width-n],[-l,t-r.y],[l,r.y+r.height-t]];for(let[u,h]of c)if(u===0){if(h<0)return!1}else{let d=h/u;if(u<0){if(d>i)return!1;d>s&&(s=d)}else{if(d<s)return!1;d<i&&(i=d)}}return s<=i}function Vi(n,t){for(let e of n){let o=e.p;for(let r=0;r+7<o.length;r+=6){let s=o[r],i=o[r+1],a=o[r+2],l=o[r+3],c=o[r+4],u=o[r+5],h=o[r+6],d=o[r+7],m=Math.min(s,a,c,h),p=Math.max(s,a,c,h),f=Math.min(i,l,u,d),b=Math.max(i,l,u,d);if(p<t.x||m>t.x+t.width||b<t.y||f>t.y+t.height)continue;let y=s,g=i;for(let w=1;w<=_r;w++){let x=w/_r,k=1-x,M=k*k*k,v=3*k*k*x,A=3*k*x*x,O=x*x*x,N=M*s+v*a+A*c+O*h,T=M*i+v*l+A*u+O*d;if(zi(y,g,N,T,t))return!0;y=N,g=T}}}return!1}function Li(n){return n.data.key!==void 0?n.parent:null}function $i(n){return!!n.node&&n.node.data.key!==void 0}function Zn(n){let t=n.source;return typeof t=="string"?t:""}function Bi(n){if(!n)return"unknown";let t=n;for(;t.parent&&t.parent.parent;)t=t.parent;return t.mounted?String(t.id):"dynamic"}function Wi(n,t){let e=new Set,o=n.clips,r=i=>o.some(a=>a.t0<i&&i<a.t1),s=.001;for(let i of o){let a=i.t1+s;a<n.duration&&!r(a)&&e.add(a)}e.add(Math.max(0,n.duration-s));for(let i=0;i<t;i++)e.add((i+.5)/t*n.duration);if(e.size<Ni)for(let i=0;i<Hr;i++){let a=(i+.5)/Hr*n.duration;r(a)||e.add(a)}return[...e].sort((i,a)=>i-a)}function Ur(n,t){try{return n.frame(t)}catch(e){if(!_n(e))throw e;return e.promise.then(()=>Ur(n,t))}}function Di(n,t){let e=n.stage.camera,o=e.tracks?.get("sx");return o?o.sample(t):e.base.sx}function Gi(n,t,e,o){let r=[],{width:s,height:i,ops:a}=n,l=n.background?Gt(n.background):n.dark?[0,0,0,1]:[255,255,255,1],c={x:0,y:0,width:s,height:i},u=new Map,h=[],d=[],m=new Map,p=0;a.forEach((g,w)=>{if(g.kind!=="path"||g.path.length===0)return;let x=$i(g);if(Math.max(g.fillAlpha,g.strokeAlpha)<Gr)return;let M=bt(g.path);if(!M)return;let v=g.stroke?qr(M,g.strokeWidth/2):M,A=x?Li(g.node):null,O=v.x<-dn||v.y<-dn||v.x+v.width>s+dn||v.y+v.height>i+dn,N=v.x<=0&&v.x+v.width>=s||v.y<=0&&v.y+v.height>=i;if(O&&(x||!N&&!e&&!o)){let T=Le(v,c),V=A?Zn(A):void 0,z=x?`text:${V}`:"marks",B=m.get(z),W=x&&T&&!e?"error":"warning";B?(B.box=mn(B.box,v),x||(p+=1)):(x||(p=1),m.set(z,{key:`film.off_canvas:${z}`,code:"film.off_canvas",severity:W,time:t,box:v,message:x?`Text ${JSON.stringify(V??"")} runs off the canvas${T?" and is clipped":""}.`:"",...V?{text:V}:{}}))}if(x&&g.node.data.missingGlyph&&g.fillAlpha>=jr){let V=`U+${String(g.node.data.key).codePointAt(0).toString(16).toUpperCase().padStart(4,"0")}`,z=A?Zn(A):"";r.push({key:`film.missing_glyph:${z}:${V}`,code:"film.missing_glyph",severity:"error",time:t,box:M,message:`Text ${JSON.stringify(z)} has a character that no bundled font can draw (${V}). It renders as an empty box.`,text:z})}if(x&&A&&g.fillAlpha>=jr){let T=u.get(A);T||u.set(A,T={id:A,source:Zn(A),bounds:M,glyphs:[]}),T.bounds=mn(T.bounds,M),T.glyphs.push({box:M,order:w})}else if(!x&&(g.fill&&g.fillAlpha>=Kr&&Xr(g.fill)[3]>=Kr&&g.path.some(T=>T.closed)&&h.push({order:w,bounds:M}),g.stroke&&g.strokeAlpha>=Gr&&g.strokePath.length>0)){let T=Ti(Xr(g.stroke),g.strokeAlpha,l);T>=Ri&&d.push({op:g,order:w,contrast:T})}});let f=m.get("marks");f&&(f.message=`${p===1?"A mark extends":`${p} marks extend`} past the ${s}x${i} canvas.`),r.push(...m.values());let b=(g,w,x)=>h.some(k=>k.order>g&&k.order<w&&Ei(k.bounds,x)),y=[...u.values()];for(let g=0;g<y.length;g++){let w=y[g];for(let x=g+1;x<y.length;x++){let k=y[x];if(!Le(w.bounds,k.bounds))continue;let M=null;for(let v of w.glyphs)if(Le(v.box,k.bounds))for(let A of k.glyphs){let O=Ii(v.box,A.box);if(!O)continue;let N=Math.min(v.box.width*v.box.height,A.box.width*A.box.height);N<=0||O.width*O.height/N<Ai||b(Math.min(v.order,A.order),Math.max(v.order,A.order),v.order<A.order?v.box:A.box)||(M=M?mn(M,O):O)}M&&r.push({key:`film.text_overlap:${w.source}|${k.source}`,code:"film.text_overlap",severity:"error",time:t,box:M,message:`Text ${JSON.stringify(w.source)} overlaps text ${JSON.stringify(k.source)}.`,text:w.source,other:k.source})}}for(let g of y)for(let{op:w,order:x,contrast:k}of d){let M=bt(w.strokePath);if(!M||!Le(qr(M,w.strokeWidth),g.bounds))continue;let v=null;for(let A of g.glyphs){let O=Fi(A.box,Oi);Le(M,O)&&Vi(w.strokePath,O)&&(x<A.order&&b(x,A.order,A.box)||(v=v?mn(v,A.box):A.box))}if(v){let A=w.strokeWidth>=Ci&&k>=Si;r.push({key:`film.text_crossed:${g.source}:${Bi(w.node)}`,code:"film.text_crossed",severity:A?"error":"warning",time:t,box:v,message:`A stroke crosses text ${JSON.stringify(g.source)}.`,text:g.source})}}return r}async function ji(n,t={}){let e=Ie(n)?await n.compile(t):n,o=t.times?[...t.times]:Wi(e,t.samples??0),r=new Map;for(let l of o){let c=await Ur(e,l);for(let{key:u,...h}of Gi(c,l,Di(e,l)!==1,e.bleed)){let d=r.get(u);d?(d.until=l,h.severity==="error"&&(d.severity="error")):r.set(u,{...h,until:l,stage:{x:0,y:0}})}}let s=l=>Math.round(l*100)/100,i=[...r.values()].map(l=>({...l,time:Math.round(l.time*1e3)/1e3,until:Math.round(l.until*1e3)/1e3,box:{x:s(l.box.x),y:s(l.box.y),width:s(l.box.width),height:s(l.box.height)},stage:{x:s(l.box.x+l.box.width/2-e.width/2),y:s(l.box.y+l.box.height/2-e.height/2)}})).sort((l,c)=>l.severity===c.severity?l.time-c.time:l.severity==="error"?-1:1),a=i.filter(l=>l.severity==="error").length;return{ok:a===0,width:e.width,height:e.height,duration:e.duration,sampled:o.map(l=>Math.round(l*1e3)/1e3),diagnostics:i,summary:{errors:a,warnings:i.length-a}}}function it(n,t,e){n.mounted||(S.now=t,e.add(n));for(let o=n;o&&o!==e.root;o=o.parent)me(o,"visible",t)||o.track("visible").step(t,!0)}function me(n,t,e){let o=S.now;S.now=e;let r=n.get(t);return S.now=o,r}function D(n,t,e,o){n.track(t).step(o,e)}function wt(n,t,e,o,r){let s=n.track.sample(e);n.track.add({t0:e,t1:o,ease:r,to:t,at:i=>s+(t-s)*i})}function $t(n,t,e,o){if(n===0)return[];let r=(o-e)/(1+(n-1)*t);return Array.from({length:n},(s,i)=>{let a=e+i*t*r;return[a,a+r]})}function Jn(n,t){return typeof n!="string"?n:t.math?st(n,{size:t.size,color:t.color??"ink",display:!1}):_(n,{size:t.size,color:t.color??"ink",font:t.font??"sans",weight:t.weight??400})}function Zr(n){let t=e=>{let o=e/255;return o<=.04045?o/12.92:Math.pow((o+.055)/1.055,2.4)};return .2126*t(n[0])+.7152*t(n[1])+.0722*t(n[2])}function Ft(n){return typeof n=="string"?Gt(n):Array.isArray(n)?n:n.stops[0][1]}function $e(n){let t=n>>>0;return()=>{t=t+1831565813>>>0;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Ht(n,t,e){let o=[],r=Math.ceil(n/e-1e-9)*e;for(let s=r;s<=t+e*1e-6;s+=e)o.push(Math.round(s/e)*e);return o}function pn(n,t,e=5){let r=(t-n||1)/Math.max(1,e),s=Math.pow(10,Math.floor(Math.log10(r))),i=r/s,a=(i<1.5?1:i<3.5?2:i<7.5?5:10)*s;return{ticks:Ht(n,t,a),step:a}}function Be(n,t){if(t!==void 0&&t<1){let o=Math.min(4,Math.ceil(-Math.log10(t)-1e-9));return n.toFixed(o)}let e=Math.round(n*1e3)/1e3;return Math.abs(e)>=1e3&&Number.isInteger(e)?e.toLocaleString("en-US"):String(e)}function pe(n){let t=n[0],e=new Array(2+(n.length-1)*6);e[0]=t[0],e[1]=t[1];for(let o=1;o<n.length;o++){let r=n[o-1],s=n[o],i=2+(o-1)*6;e[i]=r[0]+(s[0]-r[0])/3,e[i+1]=r[1]+(s[1]-r[1])/3,e[i+2]=r[0]+(s[0]-r[0])*2/3,e[i+3]=r[1]+(s[1]-r[1])*2/3,e[i+4]=s[0],e[i+5]=s[1]}return{p:Float64Array.from(e),closed:!1,straight:!0}}var ee=n=>typeof n=="function"?n():n,Qn=class extends P{range;length;line;ticks=new P;numbers=new P;constructor(t={}){super(),this.range=t.range??[-5,5],this.length=t.length??1200;let e=t.color??"dim",o=t.width??2,r=this.length/2,s=t.tips??!0;this.line=s?ze([-r-36,0],[r+36,0],{stroke:e,width:o,tip:14,both:!0}):Y([-r,0],[r,0],{stroke:e,width:o});let i=t.step??1;for(let a of Ht(this.range[0],this.range[1],i)){let[l]=this.p(a);if(this.ticks.add(Y([l,-7],[l,7],{stroke:e,width:o})),t.labels??!0){let c=t.labelSize??24,u=st(String(Math.round(a*1e3)/1e3),{size:c,color:"dim",display:!1});u.set("py",-c*.25),this.numbers.add(u.at(l,34))}}this.add(this.line,this.ticks,this.numbers)}p(t){let[e,o]=this.range;return[((t-e)/(o-e)-.5)*this.length,0]}world(t){let[e,o]=this.p(t);return this.toWorld(e,o)}marker(t,e={}){let o=e.color??"yellow",r=e.labelSize??28,s=()=>{let[a]=this.p(ee(t)),l=[gt(e.radius??9,o).at(a,0)];return e.label&&l.push(st(e.label,{size:r,color:o,display:!1}).at(a,-r*1.15)),l},i=typeof t=="function"?Ot(s):new P().add(...s());return this.add(i),i}interval(t,e,o={}){let r=o.color??"blue",s=o.offset??0,[i]=this.p(t),[a]=this.p(e),l=Y([i,s],[a,s],{stroke:r,width:o.width??7}),c=(h,d)=>d?gt(9,"bg").stroke(r,4).at(h,s):gt(9,r).at(h,s),u=new P().add(l,c(i,o.openLeft),c(a,o.openRight));return this.add(u),u}};function $c(n={}){return new Qn(n)}var to=class extends Ve{numbers=new P;constructor(t={}){super(t);let e=t.labelRange??3,o=t.labelSize??22;for(let r=-e;r<=e;r++){if(r===0)continue;let s=st(String(r),{size:o,color:"ink",display:!1});s.set("py",-o*.25),this.numbers.add(s.at(r*this.unit,22));let i=r===1?"i":r===-1?"-i":`${r}i`,a=st(i,{size:o,color:"ink",display:!1});a.set("py",-o*.25),this.numbers.add(a.at(-o*.9,-r*this.unit))}this.add(this.numbers)}z(t,e){return this.p(t,e)}};function Bc(n={}){return new to(n)}function Wc(n,t,e={}){let o=Wt(n.worldMatrix()),r=n.worldMatrix(),s=n.unit;return{...$n([n.minor,n.major,n.axes],(a,l)=>{let[c,u]=Q(o,a,l),[h,d]=t(c/s,-u/s);return Q(r,h*s,-d*s)},{duration:3,...e}),label:"applyComplex"}}var Dc={mul:(n,t)=>[n[0]*t[0]-n[1]*t[1],n[0]*t[1]+n[1]*t[0]],div:(n,t)=>{let e=t[0]*t[0]+t[1]*t[1]||1e-12;return[(n[0]*t[0]+n[1]*t[1])/e,(n[1]*t[0]-n[0]*t[1])/e]},exp:n=>{let t=Math.exp(n[0]);return[t*Math.cos(n[1]),t*Math.sin(n[1])]},log:n=>[Math.log(Math.hypot(n[0],n[1])||1e-12),Math.atan2(n[1],n[0])],pow:(n,t)=>{let e=Math.pow(Math.hypot(n[0],n[1]),t),o=Math.atan2(n[1],n[0])*t;return[e*Math.cos(o),e*Math.sin(o)]},sin:n=>[Math.sin(n[0])*Math.cosh(n[1]),Math.cos(n[0])*Math.sinh(n[1])],cos:n=>[Math.cos(n[0])*Math.cosh(n[1]),-Math.sin(n[0])*Math.sinh(n[1])],inv:n=>{let t=n[0]*n[0]+n[1]*n[1]||1e-12;return[n[0]/t,-n[1]/t]}};function Hi(n,t,e,o,r){let s=Math.hypot(e,o)||1e-6,i=e/s,a=o/s,l=Math.min(s*.42,r*5.2),c=r/2,u=l*.42,h=n+e-i*l,d=t+o-a*l,m=-a,p=i;return Z([[n+m*c,t+p*c],[h+m*c,d+p*c],[h+m*u,d+p*u],[n+e,t+o],[h-m*u,d-p*u],[h-m*c,d-p*c],[n-m*c,t-p*c]],!0)[0]}var eo=class extends P{constructor(e,o={}){super();this.f=e;let r=this.unit=o.unit??120,[s,i]=o.x??[-8,8],[a,l]=o.y??[-4.5,4.5],c=o.step??.5,u=o.maxLength??c*r*.92,h=o.width??2.6,d=(o.colors??["blue","teal","green","yellow","orange","red"]).map(y=>X(y)),m=d.map((y,g)=>[d.length===1?0:g/(d.length-1),y]),p=[];for(let y of Ht(a,l,c))for(let g of Ht(s,i,c))p.push([g,y]);let f=o.max??(()=>{let y=p.map(([g,w])=>{let[x,k]=e(g,w,0);return Math.hypot(x,k)}).filter(Number.isFinite).sort((g,w)=>g-w);return y[Math.floor(y.length*.9)]||1})(),b=(y,g,w)=>{let[x,k]=e(y,g,w),M=Math.hypot(x,k);if(!Number.isFinite(M)||M<1e-9)return null;let v=Math.min(1,M/f),A=u*(.22+.78*(1-Math.exp(-2.2*M/f))),O=x/M*A,N=-(k/M)*A,T=y*r,V=-g*r;return{ring:Hi(T-O/2,V-N/2,O,N,h),at:v,cx:T,cy:V}};if(o.animate){this.draw=g=>{let w=Array.from({length:12},()=>[]);for(let[x,k]of p){let M=b(x,k,g);M&&w[Math.min(11,Math.floor(M.at*12))].push(M.ring)}return w.flatMap((x,k)=>x.length===0?[]:[new P(x).fill(lt(m,(k+.5)/12))])};return}for(let[y,g]of p){let w=b(y,g,0);if(!w)continue;let x=ts([w.ring]).fill(lt(m,w.at));this.arrows.push(x),this.add(x)}}f;unit;arrows=[]};function ts(n){let t=bt(n);if(!t)return new P(n);let e=t.x+t.width/2,o=t.y+t.height/2,r=n.map(s=>{let i=new Float64Array(s.p.length);for(let a=0;a<i.length;a+=2)i[a]=s.p[a]-e,i[a+1]=s.p[a+1]-o;return{p:i,closed:s.closed}});return new P(r).at(e,o)}function Gc(n,t={}){return new eo(n,t)}var no=class extends P{lineCount;constructor(t,e={}){super();let o=e.unit??120,[r,s]=e.x??[-8.5,8.5],[i,a]=e.y??[-5,5],l=e.spacing??.55,c=e.dt??.03,u=e.steps??130,h=e.width??2.2,d=e.speed??.35,m=e.tail??.42,p=$e(e.seed??7),f=(e.colors??["blue","teal","green","yellow","orange","red"]).map(N=>X(N)),b=f.map((N,T)=>[f.length===1?0:T/(f.length-1),N]),y=[],g=[],w=.6;for(let N=i;N<=a;N+=l)for(let T=r;T<=s;T+=l){let V=T+(p()-.5)*l,z=N+(p()-.5)*l,B=p(),W=[[V*o,-z*o]],G=0;for(let C=0;C<u;C++){let[L,I]=t(V,z,0),[F,E]=t(V+L*c/2,z+I*c/2,0),[R,$]=t(V+F*c/2,z+E*c/2,0),[j,J]=t(V+R*c,z+$*c,0),at=(L+2*F+2*R+j)/6,tt=(I+2*E+2*$+J)/6;if(!Number.isFinite(at)||!Number.isFinite(tt))break;let ut=Math.hypot(at,tt);if(G+=ut,ut<1e-6||(V+=at*c,z+=tt*c,V<r-w||V>s+w||z<i-w||z>a+w))break;C%2===1&&W.push([V*o,-z*o])}if(W.length<5)continue;let U=G/(W.length*2);g.push(U),y.push({points:W,phase:B,speedRate:.8+p()*.4,color:U})}let x=[...g].sort((N,T)=>N-T),k=e.max??(x[Math.floor(x.length*.92)]||1),M=8;for(let N of y)N.color=Math.min(M-1,Math.floor(Math.min(1,N.color/k)*M));this.lineCount=y.length;let v=6,A=e.trace??0,O=Array.from({length:M},()=>[]);if(A>0)for(let N of y)O[N.color].push(pe(N.points));this.draw=N=>{let T=Array.from({length:M*v},()=>[]);for(let z of y){let B=z.points.length,W=Math.max(3,Math.floor(B*m)),G=B+W,U=(N*d*z.speedRate+z.phase)%1*G;for(let C=0;C<v;C++){let L=Math.floor(U-W*(1-C/v)),I=Math.floor(U-W*(1-(C+1)/v)),F=Math.max(0,L),E=Math.min(B-1,I);E-F<1||T[z.color*v+C].push(pe(z.points.slice(F,E+1)))}}let V=[];return A>0&&O.forEach((z,B)=>{z.length&&V.push(new P(z).stroke(lt(b,(B+.5)/M),h*.6).set("strokeOpacity",A))}),T.forEach((z,B)=>{if(z.length===0)return;let W=Math.floor(B/v),G=B%v,U=new P(z).stroke(lt(b,(W+.5)/M),h);U.set("strokeOpacity",Math.pow((G+1)/v,1.6)),G<v-1&&U.set("cap","butt"),V.push(U)}),V}}};function jc(n,t={}){return new no(n,t)}function Hc(n,t,e={}){let o=e.from??n.xRange[0],r=e.to??n.xRange[1],s=e.n??12,i=e.rule??"mid",a=Fe(s,...e.colors??["blue","teal","green"]),l=new P,c=(r-o)/s;for(let u=0;u<s;u++){let h=o+u*c,d=i==="left"?h:i==="right"?h+c:h+c/2,m=t(d),[p,f]=n.p(h,0),[b,y]=n.p(h+c,m),g=ts(Z([[p,f],[b,f],[b,y],[p,y]],!0));g.fill(a[u],e.opacity??.72),g.stroke(e.stroke??"bg",e.strokeWidth??(s>40?.5:1.4)),l.add(g)}return n.add(l),l}function Jr(n,t,e,o,r){let s=[];for(let i=0;i<=r;i++){let a=e+(o-e)*i/r;s.push(n.p(a,t(a)))}return s.push(n.p(o,0),n.p(e,0)),Z(s,!0)}function _c(n,t,e={}){let o=e.samples??96,r=e.fill??"blue",s=e.opacity??.28,i=e.from??n.xRange[0],a=e.to??n.xRange[1],l=typeof i=="function"||typeof a=="function"?Ot(()=>{let c=ee(i),u=ee(a);return Math.abs(u-c)<1e-9?null:new P(Jr(n,t,c,u,o)).fill(r,s)}):new P(Jr(n,t,i,a,o)).fill(r,s);return n.add(l),l}function _i(n,t,e){let r=(n.xRange[1]-n.xRange[0])*1e-4,s=n.p(e-r,t(e-r)),i=n.p(e+r,t(e+r)),a=Math.hypot(i[0]-s[0],i[1]-s[1])||1;return{point:n.p(e,t(e)),ux:(i[0]-s[0])/a,uy:(i[1]-s[1])/a}}function Kc(n,t,e,o={}){let r=o.length??420,s=o.stroke??"yellow",i=()=>{let{point:l,ux:c,uy:u}=_i(n,t,ee(e)),h=[Y([l[0]-c*r/2,l[1]-u*r/2],[l[0]+c*r/2,l[1]+u*r/2],{stroke:s,width:o.width??3.5,glow:o.glow,dash:o.dash})];return(o.point??!0)&&h.push(gt(8,s).at(l)),h},a=typeof e=="function"?Ot(i):new P().add(...i());return n.add(a),a}function Xc(n,t,e,o,r={}){let s=r.extend??140,i=r.stroke??"yellow",a=()=>{let c=ee(e),u=ee(o),h=n.p(c,t(c)),d=n.p(u,t(u)),m=Math.hypot(d[0]-h[0],d[1]-h[1])||1,p=(d[0]-h[0])/m,f=(d[1]-h[1])/m,b=[Y([h[0]-p*s,h[1]-f*s],[d[0]+p*s,d[1]+f*s],{stroke:i,width:r.width??3.5,glow:r.glow})];if(r.legs){let y=[d[0],h[1]],g=r.legColor??"dim";b.unshift(Y(h,y,{stroke:g,width:2,dash:[6,7]}),Y(y,d,{stroke:g,width:2,dash:[6,7]}))}return(r.points??!0)&&b.push(gt(8,i).at(h),gt(8,i).at(d)),b},l=typeof e=="function"||typeof o=="function"?Ot(a):new P().add(...a());return n.add(l),l}function Yc(n,t,e,o={}){let r=()=>{let i=ee(t),a=ee(e),l=Math.max(n.xRange[0],Math.min(n.xRange[1],0)),c=Math.max(n.yRange[0],Math.min(n.yRange[1],0)),u={stroke:"dim",width:2,dash:[6,7],...o};return[Y(n.p(i,c),n.p(i,a),u),Y(n.p(l,a),n.p(i,a),u)]},s=typeof t=="function"||typeof e=="function"?Ot(r):new P().add(...r());return n.add(s),s}function qc(n,t,e,o={}){let r=o.radius??54,s=o.color??"yellow",i=Math.atan2(t[1]-n[1],t[0]-n[0]),a=Math.atan2(e[1]-n[1],e[0]-n[0])-i;for(;a<=-Math.PI;)a+=Math.PI*2;for(;a>Math.PI;)a-=Math.PI*2;o.reflex&&(a+=a>0?-Math.PI*2:Math.PI*2);let l=new P;if(o.fillOpacity){let c=[n];for(let u=0;u<=24;u++){let h=i+a*u/24;c.push([n[0]+Math.cos(h)*r,n[1]+Math.sin(h)*r])}l.add(new P(Z(c,!0)).fill(s,o.fillOpacity))}if(l.add(new P(St(n[0],n[1],r,r,i,i+a)).stroke(s,o.width??3)),o.label){let c=o.labelSize??30,u=i+a/2,h=r+c*.72;l.add(st(o.label,{size:c,color:s,display:!1}).at(n[0]+Math.cos(u)*h,n[1]+Math.sin(u)*h))}return l}function Uc(n,t,e,o={}){let r=o.size??26,s=u=>{let h=u[0]-n[0],d=u[1]-n[1],m=Math.hypot(h,d)||1;return[h/m,d/m]},[i,a]=s(t),[l,c]=s(e);return new P(Z([[n[0]+i*r,n[1]+a*r],[n[0]+(i+l)*r,n[1]+(a+c)*r],[n[0]+l*r,n[1]+c*r]])).stroke(o.color??"ink",o.width??2.5)}var Ki={"[":["[","]"],"(":["(",")"],"|":["|","|"]},oo=class extends P{cells;entries=new P;brackets=new P;rowCount;colCount;positions;options;constructor(t,e={}){super(),this.options=e;let o=e.size??52,r=e.color??"ink";this.rowCount=t.length,this.colCount=Math.max(0,...t.map(w=>w.length));let s=t.map(w=>w.map(x=>{let k=st(String(x),{size:o,color:r,display:!1});return k.set("py",-o*.25),k})),i=Array.from({length:this.colCount},(w,x)=>Math.max(0,...s.map(k=>k[x]?.width??0))),a=(e.gapX??.85)*o,l=(e.gapY??1.32)*o,c=i.reduce((w,x)=>w+x,0)+a*Math.max(0,this.colCount-1),u=l*Math.max(0,this.rowCount-1)+o,h=[],d=-c/2;for(let w of i)h.push(d+w/2),d+=w+a;this.positions=s.map((w,x)=>w.map((k,M)=>{let v=[h[M],(x-(this.rowCount-1)/2)*l];return k.at(v),this.entries.add(k),v})),this.cells=s;let m=Ki[e.bracket??"["],f=`\\rule{0pt}{${((u+o*.5)/o/2+.25).toFixed(3)}em}`,b=o*.42,y=st(`\\left${m[0]}${f}\\right.`,{size:o,color:e.bracketColor??r}),g=st(`\\left.${f}\\right${m[1]}`,{size:o,color:e.bracketColor??r});y.moveTo([-c/2-b-y.width/2,0]),g.moveTo([c/2+b+g.width/2,0]),this.brackets.add(y,g),this.add(this.brackets,this.entries)}cell(t,e){let o=this.cells[t]?.[e];if(!o)throw new Error(`Matrix has no cell (${t}, ${e}). It is ${this.rowCount} by ${this.colCount}.`);return o}row(t){return[...this.cells[t]??[]]}col(t){return this.cells.map(e=>e[t]).filter(Boolean)}setCell(t,e,o,r={}){let s=this.options.size??52,i=st(String(o),{size:s,color:this.options.color??"ink",display:!1});i.set("py",-s*.25);let a=this.positions[t][e];i.at(a);let l=this.cell(t,e),c=this,u=we(l,i,{duration:.8,...r});return{...u,schedule(h){c.entries.add(i),i.track("visible").initial=!1,c.cells[t][e]=i,u.schedule(h)}}}};function Zc(n,t={}){return new oo(n,t)}function es(n){let t=Array.isArray(n)?n:[n],e=1/0,o=1/0,r=-1/0,s=-1/0;for(let i of t){let a=i.bounds();e=Math.min(e,a.x),o=Math.min(o,a.y),r=Math.max(r,a.x+a.width),s=Math.max(s,a.y+a.height)}return{x:e,y:o,width:r-e,height:s-o}}function Jc(n,t,e={}){let o=es(n),r=e.side??"bottom",s=e.gap??12,i=e.color??"ink",a=e.size??34,l=o.x,c=o.x+o.width,u=o.y,h=o.y+o.height,[d,m]=r==="bottom"?[[l,h+s],[c,h+s]]:r==="top"?[[c,u-s],[l,u-s]]:r==="left"?[[l-s,u],[l-s,h]]:[[c+s,h],[c+s,u]],p=Br(d,m,{stroke:i,depth:e.depth}),f=p.data.tip,b=Jn(t,{size:a,color:i,math:!e.plain});b.moveTo(f);let y=Qe(r),g=10+(y[0]!==0?b.width/2:b.height/2);return b.shift(y[0]*g,y[1]*g),new P().add(p,b)}function Qc(n,t={}){let e=es(n),o=t.pad??12,r=$r(e.width+o*2,e.height+o*2,{radius:t.radius??8,stroke:t.color??"yellow",width:t.width??2.5,glow:t.glow});return t.fill&&r.fill(t.fill,t.fillOpacity??.14),r.at(e.x+e.width/2,e.y+e.height/2)}var ro=class extends P{mark;caption;constructor(t,e={}){super();let o=e.color??"yellow";this.mark=gt(e.radius??9,o),this.caption=Jn(t,{size:e.size??30,color:e.labelColor??o,math:!e.plain}),this.add(this.mark,this.caption),this.caption.nextTo(this.mark,e.side??[.72,-.72],e.gap??8)}};function tu(n,t={}){return new ro(n,t)}function eu(n,t,e,o={}){let r=o.color??"yellow",s=o.width??3,i=o.rate??60,a=o.fade??(o.tail!==void 0?0:1),l=a>=1?1:10,c=new Map,u=h=>{let d=c.get(h);if(d)return d;let m=S.now;S.now=t+h/i;let p=n();return S.now=m,S.mode==="render"&&c.set(h,p),p};return Ot(h=>{if(h<=t)return null;let d=Math.min(h,e),m=o.tail!==void 0?Math.max(t,d-o.tail):t,p=Math.ceil((m-t)*i),f=Math.floor((d-t)*i);if(f-p<1)return null;let b=[];for(let w=p;w<=f;w++)b.push(u(w));let y=S.now;S.now=d,b.push(n()),S.now=y;let g=[];for(let w=0;w<l;w++){let x=Math.floor((b.length-1)*w/l),k=Math.min(b.length-1,Math.floor((b.length-1)*(w+1)/l));if(k-x<1)continue;let M=new P([pe(b.slice(x,k+1))]).stroke(r,s),v=l===1?1:a+(1-a)*Math.pow((w+1)/l,1.5);M.set("strokeOpacity",v),w<l-1&&M.set("cap","butt"),o.glow&&M.glow(o.glow),g.push(M)}return g})}function nu(n,t={}){let e=n.length,o=[];for(let r=0;r<e;r++){let s=r<=e/2?r:r-e,i=0,a=0;for(let l=0;l<e;l++){let c=-2*Math.PI*s*l/e,u=Math.cos(c),h=Math.sin(c),[d,m]=n[l];i+=d*u-m*h,a+=d*h+m*u}o.push({freq:s,amp:Math.hypot(i,a)/e,phase:Math.atan2(a,i)})}return o.sort((r,s)=>s.amp-r.amp||r.freq-s.freq),t.terms?o.slice(0,t.terms):o}function Qr(n,t){let e=0,o=0;for(let r of n){let s=2*Math.PI*r.freq*t+r.phase;e+=r.amp*Math.cos(s),o+=r.amp*Math.sin(s)}return[e,o]}function ou(n,t){return At(n)===0?[]:Array.from({length:t},(o,r)=>Pt(n,r/t))}var so=class extends P{terms;outlinePoints;constructor(t,e){super(),this.terms=[...t].sort((h,d)=>(h.freq===0?-1:d.freq===0?1:0)||d.amp-h.amp);let o=e.samples??1024;this.outlinePoints=Array.from({length:o+1},(h,d)=>Qr(this.terms,d/o));let r=e.circles??64,s=e.circleColor??"blue",i=e.armColor??"ink",a=e.traceColor??"yellow",l=e.traceWidth??3.5,c=e.tail??1,u=12;this.draw=()=>{let h=e.u(),d=h-Math.floor(h),m=[],p=0,f=0,b=[],y=[[],[],[],[]];this.terms.forEach((k,M)=>{let v=2*Math.PI*k.freq*d+k.phase,A=p+k.amp*Math.cos(v),O=f+k.amp*Math.sin(v);M<r&&k.freq!==0&&k.amp>.4&&y[Math.min(3,Math.floor(M/Math.max(1,r)*4))].push(...Dt(p,f,k.amp)),p=A,f=O,M<r&&b.push([p,f])}),y.forEach((k,M)=>{k.length&&m.push(new P(k).stroke(s,1.2).set("strokeOpacity",[.55,.36,.22,.14][M]))}),b.length>=2&&m.push(new P([pe(b)]).stroke(i,1.4).set("strokeOpacity",.85));let g=this.outlinePoints.length-1,w=h>=1?g:Math.floor(d*g),x=Math.max(0,w-Math.floor(g*c));if(w-x>=2)if(c>=1){let k=new P([pe(this.outlinePoints.slice(x,w+1))]).stroke(a,l);e.glow&&k.glow(e.glow),m.push(k)}else for(let k=0;k<u;k++){let M=x+Math.floor((w-x)*k/u),v=Math.min(w,x+Math.floor((w-x)*(k+1)/u));if(v-M<1)continue;let A=new P([pe(this.outlinePoints.slice(M,v+1))]).stroke(a,l);A.set("strokeOpacity",Math.pow((k+1)/u,1.5)),k<u-1&&A.set("cap","butt"),m.push(A)}return h<1&&m.push(gt(5,a).at(p,f)),m}}outline(){return Z(this.outlinePoints.slice(0,-1),!0)}point(t){return Qr(this.terms,t)}};function ru(n,t){return new so(n,t)}function su(n,t=200){return _e(n,0,1,t).map(o=>Mt(o.p,!0))}var oe=["blue","yellow","teal","orange","purple","green","pink","red"];function It(n,t,e="dim",o="sans"){return _(n,{size:t,color:e,font:o})}var ao=class extends P{bars=[];labels=[];readouts=[];baseline;values;maxValue;minValue;w;h;horizontal;band;gap;fixedMax;fixedMin;constructor(t,e={}){super(),this.w=e.width??900,this.h=e.height??520,this.horizontal=e.horizontal??!1,this.gap=e.gap??.28,this.fixedMax=e.max,this.fixedMin=e.min;let o=e.labelSize??20,r=Math.max(1,t.length);this.band=(this.horizontal?this.h:this.w)/r;let s=t.map(d=>d.value);this.maxValue=new pt(e.max??Math.max(0,...s)),this.minValue=new pt(e.min??Math.min(0,...s)),this.values=t.map(d=>new pt(d.value));let i=e.format??(d=>Be(Math.round(d*100)/100)),a=e.color??"faint",[l,c]=this.place(0,0,"start"),[u,h]=this.place(r-1,0,"end");this.baseline=Y([l,c],[u,h],{stroke:a,width:1.5}),t.forEach((d,m)=>{let p=d.color??oe[m%oe.length],f=new P(this.barPath(m,d.value)).fill(p,.84);this.bars.push(f);let b=It(d.label,o);this.labels.push(b);let[y,g]=this.place(m,0,"mid");if(this.horizontal?b.at(y-12-b.width/2,g):b.at(y,g+12+o/2),e.showValues??!0){let w=Ot(()=>{let x=this.values[m].value,[k,M]=this.tip(m,x),v=It(i(x),o,"ink","mono");return this.horizontal?v.at(k+12+v.width/2,M):v.at(k,M+(x>=0?-1:1)*(10+o*.6))});this.readouts.push(w)}}),this.add(...this.bars,this.baseline,...this.labels,...this.readouts)}lengthOf(t){let e=this.maxValue.value-this.minValue.value||1;return t/e*(this.horizontal?this.w:this.h)}place(t,e,o){let r=(t+.5)*this.band,s=this.band/2,i=o==="mid"?r:o==="start"?r-s:r+s,a=this.maxValue.value-this.minValue.value||1;if(this.horizontal)return[-this.minValue.value/a*this.w-this.w/2,i-this.h/2];let l=this.h/2- -this.minValue.value/a*this.h;return[i-this.w/2,l]}tip(t,e){let[o,r]=this.place(t,0,"mid"),s=this.lengthOf(e);return this.horizontal?[o+s,r]:[o,r-s]}barPath(t,e){let[o,r]=this.place(t,0,"mid"),s=this.band*(1-this.gap),i=this.lengthOf(e);return this.horizontal?K(o,r-s/2,i,s):K(o-s/2,r-i,s,i)}bar(t){return this.bars[t]}enter(t={}){let e=t.lag??.12;return{label:"barChart.enter",duration:t.duration??1.6,ease:t.ease,schedule:o=>{it(this,o.t0,o.stage);let r=o.t1-o.t0;D(this.baseline,"trimTo",0,o.t0),this.baseline.tween("trimTo",1,o.t0,o.t0+r*.4,o.ease);let s=$t(this.bars.length,e,o.t0+r*.1,o.t1);this.bars.forEach((i,a)=>{let[l,c]=s[a],u=this.values[a].track.sample(o.t0);this.values[a].track.step(o.t0,0),wt(this.values[a],u,l,c,o.ease),i.track("path").step(o.t0,this.barPath(a,0)),i.track("path").add({t0:l,t1:c,ease:o.ease,to:this.barPath(a,u),at:m=>this.barPath(a,u*m)});let h=this.labels[a];D(h,"opacity",0,o.t0),h.tween("opacity",1,l,l+(c-l)*.6,o.ease);let d=this.readouts[a];d&&(D(d,"opacity",0,o.t0),d.tween("opacity",1,l,l+(c-l)*.5,o.ease))})}}}update(t,e={}){return{label:"barChart.update",duration:e.duration??1.1,ease:e.ease,schedule:o=>{let r=this.values.map(c=>c.track.sample(o.t0)),s=this.maxValue.track.sample(o.t0),i=this.minValue.track.sample(o.t0),a=this.fixedMax??Math.max(0,...t),l=this.fixedMin??Math.min(0,...t);wt(this.maxValue,a,o.t0,o.t1,o.ease),wt(this.minValue,l,o.t0,o.t1,o.ease),t.forEach((c,u)=>{wt(this.values[u],c,o.t0,o.t1,o.ease);let h=this.bars[u];if(!h)return;let d=m=>this.barPathAt(u,r[u]+(c-r[u])*m,s+(a-s)*m,i+(l-i)*m);h.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:d(1),at:d})})}}}barPathAt(t,e,o,r){let s=o-r||1,i=(t+.5)*this.band,a=this.band*(1-this.gap);if(this.horizontal){let u=-r/s*this.w-this.w/2;return K(u,i-this.h/2-a/2,e/s*this.w,a)}let l=this.h/2- -r/s*this.h,c=e/s*this.h;return K(i-this.w/2-a/2,l-c,a,c)}};function pu(n,t={}){return new ao(n,t)}var lo=class extends P{shown;bins;range;chartWidth;chartHeight;axis=new P;total;assigned;peak;constructor(t,e={}){super(),this.chartWidth=e.width??900,this.chartHeight=e.height??480,this.bins=e.bins??24;let o=e.range?.[0]??Math.min(...t),r=e.range?.[1]??Math.max(...t);this.range=[o,r],this.total=t.length,this.assigned=new Int32Array(t.length);let s=new Int32Array(this.bins);t.forEach((b,y)=>{let g=Math.min(this.bins-1,Math.floor((b-o)/(r-o||1)*this.bins));this.assigned[y]=b<o||b>r?-1:g,this.assigned[y]>=0&&s[g]++}),this.peak=e.max??Math.max(1,...s),this.shown=new pt(t.length);let i=e.labelSize??20,a=this.chartWidth,l=this.chartHeight,c=Y([-a/2,l/2],[a/2,l/2],{stroke:e.color??"faint",width:1.5});this.axis.add(c);let{ticks:u,step:h}=pn(o,r,e.ticks??6);for(let b of u){let y=this.xAt(b);this.axis.add(Y([y,l/2],[y,l/2+6],{stroke:"faint",width:1.5})),this.axis.add(It(Be(b,h),i).at(y,l/2+12+i*.6))}let d=(e.colors??["blue"]).map(b=>Ft(b)),m=d.map((b,y)=>[d.length===1?0:y/(d.length-1),b]),p=e.gap??.12,f=Ot(()=>{let b=Math.max(0,Math.min(this.total,Math.round(this.shown.value))),y=new Int32Array(this.bins);for(let k=0;k<b;k++){let M=this.assigned[k];M>=0&&y[M]++}let g=a/this.bins,w=[],x=[];for(let k=0;k<this.bins;k++){let M=y[k]/this.peak*l;if(M<=0)continue;let v=K(-a/2+k*g+g*p/2,l/2-M,g*(1-p),M);d.length===1?w.push(...v):x.push(new P(v).fill(lt(m,k/Math.max(1,this.bins-1))))}return w.length&&x.push(new P(w).fill(d[0])),x});this.add(f,this.axis)}xAt(t){let[e,o]=this.range;return((t-e)/(o-e||1)-.5)*this.chartWidth}p(t,e){return[this.xAt(t),this.chartHeight/2-e/this.peak*this.chartHeight]}fillUp(t={}){let e=this.shown,o=t.count??this.total;return{label:"histogram.fill",duration:t.duration??3,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage),e.track.keys.length===0&&(e.track.initial=0),wt(e,o,r.t0,r.t1,r.ease)}}}curve(t,e={}){let[o,r]=this.range,s=e.samples??120,i=[];for(let l=0;l<=s;l++){let c=o+(r-o)*l/s;i.push(this.p(c,t(c)))}let a=new P(Lt(i)).stroke(e.color??"yellow",e.width??4);return this.add(a),a}};function fu(n,t={}){return new lo(n,t)}function ne(n,t,e){let{xRange:o,yRange:r,w:s,h:i}=n;return[((t-o[0])/(o[1]-o[0]||1)-.5)*s,(.5-(e-r[0])/(r[1]-r[0]||1))*i]}function ns(n,t){let e=new P,o=t.labelSize,r=t.color??"faint",{w:s,h:i}=n,a=pn(n.xRange[0],n.xRange[1],t.xTicks??6),l=pn(n.yRange[0],n.yRange[1],t.yTicks??5);for(let c of l.ticks){let[,u]=ne(n,n.xRange[0],c);t.gridY!==!1&&e.add(Y([-s/2,u],[s/2,u],{stroke:"grid",width:1.25}));let h=It(t.yFormat?t.yFormat(c):Be(c,l.step),o);e.add(h.at(-s/2-12-h.width/2,u))}e.add(Y([-s/2,i/2],[s/2,i/2],{stroke:r,width:1.5}));for(let c of a.ticks){let[u]=ne(n,c,n.yRange[0]);e.add(Y([u,i/2],[u,i/2+6],{stroke:r,width:1.5})),e.add(It(t.xFormat?t.xFormat(c):Be(c,a.step),o).at(u,i/2+12+o*.6))}if(t.xLabel){let c=It(t.xLabel,o,"ink");e.add(c.at(s/2-c.width/2,i/2+18+o*1.6))}if(t.yLabel){let c=It(t.yLabel,o,"ink");e.add(c.at(-s/2+c.width/2,-i/2-12-o/2))}return e}var co=class extends P{dots=[];axis;groupLabels=[];frame;constructor(t,e={}){super();let o=t.map(h=>h.x),r=t.map(h=>h.y),s=(h,d)=>(d-h||1)*.06,i=e.x??[Math.min(...o)-s(Math.min(...o),Math.max(...o)),Math.max(...o)+s(Math.min(...o),Math.max(...o))],a=e.y??[Math.min(...r)-s(Math.min(...r),Math.max(...r)),Math.max(...r)+s(Math.min(...r),Math.max(...r))];this.frame={xRange:i,yRange:a,w:e.width??900,h:e.height??520};let l=e.labelSize??18;this.axis=ns(this.frame,{labelSize:l,color:e.color,xLabel:e.xLabel,yLabel:e.yLabel});let c=new Map,u=t.map(h=>{let d=h.color;if(h.group!==void 0){let p=c.get(h.group);p||(p={color:d??oe[c.size%oe.length],sumX:0,top:-1/0,count:0},c.set(h.group,p)),d??=p.color,p.sumX+=h.x,p.top=Math.max(p.top,h.y),p.count++}let m=gt(h.radius??e.radius??6,d??"blue").at(ne(this.frame,h.x,h.y));return m.set("fillOpacity",.92),m});if(this.dots.push(...u),this.add(this.axis,...u),e.groupLabels??!0)for(let[h,d]of c){let m=It(h,l+2,d.color),[p,f]=ne(this.frame,d.sumX/d.count,d.top);m.at(p,f-l*1.2),this.groupLabels.push(m),this.add(m)}}p(t,e){return ne(this.frame,t,e)}enter(t={}){let e=t.lag??Math.min(.2,8/Math.max(1,this.dots.length));return{label:"scatter.enter",duration:t.duration??2,ease:t.ease,schedule:o=>{it(this,o.t0,o.stage);let r=o.t1-o.t0;D(this.axis,"opacity",0,o.t0),this.axis.tween("opacity",1,o.t0,o.t0+r*.3,o.ease);let s=[...this.dots].sort((a,l)=>a.get("x")-l.get("x")),i=$t(s.length,e,o.t0+r*.15,o.t1);s.forEach((a,l)=>{let[c,u]=i[l],h=a.get("sx");D(a,"sx",.001,o.t0),D(a,"sy",.001,o.t0),a.tween("sx",h,c,u,o.ease),a.tween("sy",h,c,u,o.ease)});for(let a of this.groupLabels)D(a,"opacity",0,o.t0),a.tween("opacity",1,o.t0+r*.7,o.t1,o.ease)}}}fit(t,e={}){let[o,r]=this.frame.xRange,s=e.samples??60,i=[];for(let l=0;l<=s;l++){let c=o+(r-o)*l/s;i.push(this.p(c,t(c)))}let a=new P(Lt(i)).stroke(e.color??"yellow",e.width??3.5);return this.add(a),a}};function bu(n,t={}){return new co(n,t)}var uo=class extends P{lines=[];areas=[];names=[];axis;byName=new Map;frame;constructor(t,e={}){super();let o=t.map(b=>b.points??(b.values??[]).map((y,g)=>[g,y])),r=o.flat().map(b=>b[0]),s=o.flat().map(b=>b[1]),i=Math.min(...s),a=Math.max(...s),l=(a-i||1)*.08,c=e.x??[Math.min(...r),Math.max(...r)],u=e.y??[i>=0&&i<(a-i)*.4?0:i-l,a+l],h=e.width??900,d=e.height??480;this.frame={xRange:c,yRange:u,w:h,h:d};let m=e.labelSize??18;this.axis=ns(this.frame,{labelSize:m,color:e.color,xLabel:e.xLabel,yLabel:e.yLabel,xFormat:e.xFormat,yFormat:e.yFormat,xTicks:e.xTicks,yTicks:e.yTicks}),this.add(this.axis);let p=[];t.forEach((b,y)=>{let g=b.color??oe[y%oe.length],w=o[y].map(([M,v])=>ne(this.frame,M,v));if(b.area){let M=ne(this.frame,c[0],Math.max(u[0],0))[1],v=Z([...w,[w[w.length-1][0],M],[w[0][0],M]],!0),A=new P(v).fill(g,b.area);this.areas.push(A),this.add(A)}let x=b.smooth===!1?Z(w):Lt(w),k=new P(x).stroke(g,b.width??3.5);if(b.dash&&k.dash(b.dash),this.lines.push(k),this.add(k),b.name){this.byName.set(b.name,k);let M=It(b.name,m+1,g),v=w[w.length-1];p.push({label:M,y:v[1]}),M.at(v[0]+12+M.width/2,v[1]),this.names.push(M),this.add(M)}}),p.sort((b,y)=>b.y-y.y);let f=m*1.25;for(let b=0;b<8;b++)for(let y=1;y<p.length;y++){let g=f-(p[y].y-p[y-1].y);g>0&&(p[y-1].y-=g/2,p[y].y+=g/2)}for(let b of p)b.label.at(b.label.get("x"),b.y)}p(t,e){return ne(this.frame,t,e)}series(t){let e=this.byName.get(t);if(!e)throw new Error(`No series named ${JSON.stringify(t)}.`);return e}enter(t={}){let e=t.lag??.1;return{label:"lineChart.enter",duration:t.duration??2.2,ease:t.ease,schedule:o=>{it(this,o.t0,o.stage);let r=o.t1-o.t0;D(this.axis,"opacity",0,o.t0),this.axis.tween("opacity",1,o.t0,o.t0+r*.3,o.ease);let s=$t(this.lines.length,e,o.t0+r*.15,o.t1);this.lines.forEach((i,a)=>{let[l,c]=s[a];D(i,"trimTo",0,o.t0),i.tween("trimTo",1,l,c,o.ease);let u=this.names[a];u&&(D(u,"opacity",0,o.t0),u.tween("opacity",1,c-(c-l)*.2,Math.min(o.t1,c+r*.1),o.ease))});for(let i of this.areas){let a=i.get("fillOpacity");D(i,"fillOpacity",0,o.t0),i.tween("fillOpacity",a,o.t0+r*.5,o.t1,o.ease)}}}}};function gu(n,t={}){return new uo(n,t)}function io(n,t,e,o){if(t-n<1e-4)return[];let r=St(0,0,o,o,n,t)[0].p,s=Array.from(r),i=s[s.length-2],a=s[s.length-1],l=(c,u,h,d)=>{s.push(c+(h-c)/3,u+(d-u)/3,c+(h-c)*2/3,u+(d-u)*2/3,h,d)};if(e>.01){let c=St(0,0,e,e,t,n)[0].p;l(i,a,c[0],c[1]);for(let u=2;u<c.length;u++)s.push(c[u]);l(c[c.length-2],c[c.length-1],r[0],r[1])}else l(i,a,0,0),l(0,0,r[0],r[1]);return[Mt(s,!0)]}var fn=class extends P{wedges=[];labels=[];leaders=[];centerText=null;shares;inner;outer;gap;constructor(t,e={}){super(),this.outer=e.radius??240,this.inner=this.outer*(e.hole??0),this.gap=e.gap??(this.inner>0?.018:.008);let o=t.reduce((i,a)=>i+Math.max(0,a.value),0)||1;this.shares=t.map(i=>Math.max(0,i.value)/o);let r=e.labelSize??20,s=this.angles(this.shares);if(t.forEach((i,a)=>{let l=i.color??oe[a%oe.length],[c,u]=s[a],h=new P(io(c,u,this.inner,this.outer)).fill(l,.86);this.wedges.push(h),this.add(h)}),(e.labels??!0)&&t.forEach((i,a)=>{let[l,c]=s[a],u=(l+c)/2,h=Math.cos(u),d=Math.sin(u),m=this.outer+6,p=this.outer+30,f=h*p,b=d*p,y=f+(h>=0?18:-18),g=new P(Z([[h*m,d*m],[f,b],[y,b]])).stroke("faint",1.25),x=e.percent??!0?`${i.label} ${Math.round(this.shares[a]*100)}%`:i.label,k=It(x,r,"ink");k.at(y+(h>=0?8+k.width/2:-8-k.width/2),b),this.leaders.push(g),this.labels.push(k),this.add(g,k)}),e.centerLabel){let i=_(e.centerLabel,{size:e.centerSize??Math.max(24,this.inner*.34),font:"serif",color:"ink"}).at(0,0);this.centerText=i,this.add(i)}}angles(t,e=1){let o=-Math.PI/2;return t.map(r=>{let s=r*Math.PI*2*e,i=Math.min(this.gap*e,s*.45),a=[o+i/2,o+s-i/2];return o+=s,a})}enter(t={}){return{label:"pie.enter",duration:t.duration??1.6,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let o=e.t1-e.t0,r=e.t0+o*.78;this.wedges.forEach((s,i)=>{let a=l=>{let[c,u]=this.angles(this.shares,l)[i];return io(c,u,this.inner,this.outer)};s.track("path").step(e.t0,[]),s.track("path").add({t0:e.t0,t1:r,ease:e.ease,to:a(1),at:a})});for(let s of[...this.labels,...this.leaders,...this.centerText?[this.centerText]:[]])D(s,"opacity",0,e.t0),s.tween("opacity",1,e.t0+o*.62,e.t1,e.ease)}}}update(t,e={}){return{label:"pie.update",duration:e.duration??1.1,ease:e.ease,schedule:o=>{let r=t.reduce((a,l)=>a+Math.max(0,l),0)||1,s=t.map(a=>Math.max(0,a)/r),i=[...this.shares];this.wedges.forEach((a,l)=>{let c=u=>{let h=i.map((p,f)=>p+((s[f]??0)-p)*u),[d,m]=this.angles(h)[l];return io(d,m,this.inner,this.outer)};a.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:c(1),at:c})});for(let a of[...this.labels,...this.leaders])a.tween("opacity",0,o.t0,o.t0+(o.t1-o.t0)*.3,o.ease);s.forEach((a,l)=>{this.shares[l]=a})}}}};function yu(n,t={}){return new fn(n,t)}function wu(n,t={}){return new fn(n,{hole:.62,...t})}var We=class extends P{cells=[];rowLabels=[];columnLabels=[];numbers=[];rowCount;colCount;stops;domain;constructor(t,e={}){super(),this.rowCount=t.length,this.colCount=Math.max(0,...t.map(m=>m.length));let o=e.cellWidth??e.cell??44,r=e.cellHeight??e.cell??44,s=e.gap??2,i=t.flat();this.domain=e.domain??[Math.min(...i),Math.max(...i)];let a=(e.colors??["surface","blue","yellow"]).map(m=>Ft(m));this.stops=a.map((m,p)=>[a.length===1?0:p/(a.length-1),m]);let l=this.colCount*o+(this.colCount-1)*s,c=this.rowCount*r+(this.rowCount-1)*s,u=e.labelSize??16,h=e.valueSize??Math.min(r*.38,o*.36),d=e.format??(m=>(Math.round(m*100)/100).toString());t.forEach((m,p)=>{let f=[],b=[];m.forEach((y,g)=>{let w=-l/2+g*(o+s)+o/2,x=-c/2+p*(r+s)+r/2,k=this.colorFor(y),M=new P(K(-o/2,-r/2,o,r,e.radius??0)).fill(k).at(w,x);if(f.push(M),this.add(M),e.values){let v=_(d(y),{size:h,font:"mono",color:Zr(k)>.32?"#101114":"#f2efe6"}).at(w,x);b.push(v),this.add(v)}}),this.cells.push(f),this.numbers.push(b)}),e.rowLabels?.forEach((m,p)=>{let f=It(m,u),b=-c/2+p*(r+s)+r/2;f.at(-l/2-10-f.width/2,b),this.rowLabels.push(f),this.add(f)}),e.columnLabels?.forEach((m,p)=>{let f=It(m,u),b=-l/2+p*(o+s)+o/2,y=e.columnLabelAngle??0;if(y!==0){let g=f.width;f.at(b+Math.cos(y)*g/2,-c/2-12+Math.sin(y)*g/2),f.set("rotation",y)}else f.at(b,-c/2-10-u/2);this.columnLabels.push(f),this.add(f)})}colorFor(t){let[e,o]=this.domain;return lt(this.stops,Math.max(0,Math.min(1,(t-e)/(o-e||1))))}cell(t,e){let o=this.cells[t]?.[e];if(!o)throw new Error(`Heatmap has no cell (${t}, ${e}). It is ${this.rowCount} by ${this.colCount}.`);return o}row(t){return[...this.cells[t]??[]]}col(t){return this.cells.map(e=>e[t]).filter(Boolean)}enter(t={}){return{label:"heatmap.enter",duration:t.duration??1.6,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let o=e.t1-e.t0,r=this.rowCount+this.colCount-1,s=o*.5,i=r>1?(o-s)/(r-1):0;this.cells.forEach((a,l)=>a.forEach((c,u)=>{let h=e.t0+(l+u)*i;D(c,"opacity",0,e.t0),c.tween("opacity",1,h,h+s,e.ease);let d=this.numbers[l]?.[u];d&&(D(d,"opacity",0,e.t0),d.tween("opacity",1,h,h+s,e.ease))}));for(let a of[...this.rowLabels,...this.columnLabels])D(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0,e.t0+o*.4,e.ease)}}}update(t,e={}){return{label:"heatmap.update",duration:e.duration??1,ease:e.ease,schedule:o=>{t.forEach((r,s)=>r.forEach((i,a)=>{let l=this.cells[s]?.[a];l&&l.tween("fill",this.colorFor(i),o.t0,o.t1,o.ease)}))}}}};function xu(n,t={}){return new We(n,t)}var ho=null,os=null;function Xi(){if(ho)return ho;throw os??=import("./dagre.esm-6F3RIGLP.js").then(n=>{ho=n.default??n}),new Nt(os)}var po=class extends P{shape;caption=null;halfWidth=0;halfHeight=0;round=!0;edgePoint(t,e,o,r,s=0){let i=o-t,a=r-e,l=Math.hypot(i,a)||1;if(this.round)return[t+i/l*(this.halfWidth+s),e+a/l*(this.halfWidth+s)];let c=i===0?1/0:this.halfWidth/Math.abs(i),u=a===0?1/0:this.halfHeight/Math.abs(a),h=Math.min(c,u);return[t+i*h+i/l*s,e+a*h+a/l*s]}},fo=class extends P{shaft;tip=null;caption=null;from="";to="";tipSize=14};function mo(n,t){let e=At(n);if(e<=t*1.1)return{head:[],trimmed:n};let o=1-t/e,r=Jt(n,0,o),[s,i]=Pt(n,1),[a,l]=ge(n,.997),c=t*.38,u=s-a*t,h=i-l*t;return{head:Z([[s,i],[u-l*c,h+a*c],[u+l*c,h-a*c]],!0),trimmed:r}}var bn=class extends P{nodes=new Map;edges=[];edgeLayer=new P;nodeLayer=new P;specs;constructor(t,e,o={}){super(),this.specs=t;let r=o.radius??30,s=o.labelSize??26,i=p=>p.width?[p.width,p.height??s*2]:[(p.radius??r)*2,(p.radius??r)*2],a=o.layout??"dagre",l=new Map,c=new Map;if(a==="dagre"){let p=Xi(),f=new p.graphlib.Graph({multigraph:!0});f.setGraph({rankdir:o.direction??"LR",nodesep:o.nodeGap??60,ranksep:o.rankGap??110,edgesep:24,ranker:"network-simplex"}),f.setDefaultEdgeLabel(()=>({}));for(let w of t){let[x,k]=i(w);f.setNode(w.id,{width:x,height:k})}e.forEach((w,x)=>f.setEdge(w.from,w.to,{},String(x))),p.layout(f);let b=f.graph(),y=(b.width??0)/2,g=(b.height??0)/2;for(let w of t){let x=f.node(w.id);l.set(w.id,[x.x-y,x.y-g])}e.forEach((w,x)=>{let k=f.edge({v:w.from,w:w.to,name:String(x)});k?.points&&c.set(w,k.points.map(M=>[M.x-y,M.y-g]))})}else if(a==="circle"){let p=Math.min(o.width??700,o.height??700)/2;t.forEach((f,b)=>{let y=-Math.PI/2+b/t.length*Math.PI*2;l.set(f.id,[Math.cos(y)*p,Math.sin(y)*p])})}else if(a==="force")l=qi(t,e,o.width??900,o.height??620,o.seed??3);else for(let p of t)l.set(p.id,p.at??[0,0]);let u=o.nodeColor??"blue";for(let p of t){let f=new po,b=p.color??u,[y,g]=i(p);f.halfWidth=y/2,f.halfHeight=g/2,f.round=!p.width,f.shape=new P(p.width?K(-y/2,-g/2,y,g,8):Dt(0,0,y/2)).fill(b,o.fillOpacity??.16).stroke(b,2.5),f.add(f.shape),p.label&&(f.caption=p.math?st(p.label,{size:s,color:"ink",display:!1}):_(p.label,{size:s,color:"ink"}),f.add(f.caption.at(0,0))),f.named(p.id),f.at(l.get(p.id)??[0,0]),this.nodes.set(p.id,f),this.nodeLayer.add(f)}let h=o.directed??!0,d=o.edgeColor??"dim",m=o.edgeLabelSize??20;for(let p of e){let f=this.nodes.get(p.from),b=this.nodes.get(p.to);if(!f||!b)throw new Error(`Graph edge ${p.from} -> ${p.to} refers to a node that does not exist.`);let y=new fo;y.from=p.from,y.to=p.to;let g=l.get(p.from),w=l.get(p.to),x=c.get(p),k=(o.direction??"LR")==="LR"||o.direction==="RL",M=Yi(f,b,g,w,x,k),v=p.directed??h,A=p.color??d,{head:O,trimmed:N}=v?mo(M,y.tipSize):{head:[],trimmed:M};if(y.shaft=new P(N).stroke(A,p.width??2.2),p.dash&&y.shaft.dash(p.dash),y.add(y.shaft),O.length&&(y.tip=new P(O).fill(A),y.add(y.tip)),p.label){let[T,V]=Pt(M,.5),z=_(p.label,{size:m,color:"ink",font:"mono"}).at(T,V),B=m*.34,W=new P(K(T-z.width/2-B,V-m*.68,z.width+B*2,m*1.36,4)).fill("bg");y.caption=new P().add(W,z),y.add(y.caption)}this.edges.push(y),this.edgeLayer.add(y)}this.add(this.edgeLayer,this.nodeLayer)}node(t){let e=this.nodes.get(t);if(!e)throw new Error(`Graph has no node ${JSON.stringify(t)}.`);return e}edge(t,e){let o=this.edges.find(r=>r.from===t&&r.to===e)??this.edges.find(r=>r.from===e&&r.to===t);if(!o)throw new Error(`Graph has no edge ${t} -> ${e}.`);return o}enter(t={}){let e=t.lag??.14;return{label:"graph.enter",duration:t.duration??2,ease:t.ease,schedule:o=>{it(this,o.t0,o.stage);let r=this.specs.map(a=>this.nodes.get(a.id)),s=$t(r.length,e,o.t0,o.t0+(o.t1-o.t0)*.78),i=new Map;r.forEach((a,l)=>{let[c,u]=s[l];i.set(a,u),gn(a,o.t0,c,u,o.ease)});for(let a of this.edges){let l=i.get(this.nodes.get(a.from))??o.t0,c=Math.min(o.t1,l+(o.t1-o.t0)*.22);D(a.shaft,"trimTo",0,o.t0),a.shaft.tween("trimTo",1,l,c,o.ease);for(let u of[a.tip,a.caption])u&&(D(u,"opacity",0,o.t0),u.tween("opacity",1,c-(c-l)*.3,c,o.ease))}}}}pulseEdge(t,e,o={}){let r=this.edge(t,e);return{...Bn(r.shaft,{color:o.color??"yellow",length:o.length??.3,...o}),label:"graph.pulse"}}visit(t,e={}){let o=this.node(t),r=e.color??"yellow";return{label:"graph.visit",duration:e.duration??.6,ease:e.ease,schedule:s=>{let i=X(r);o.shape.tween("stroke",i,s.t0,s.t1,s.ease),o.shape.tween("fill",i,s.t0,s.t1,s.ease);let a=s.t1-s.t0,l=o.get("sx");o.tween("sx",l*1.16,s.t0,s.t0+a*.45,s.ease),o.tween("sy",l*1.16,s.t0,s.t0+a*.45,s.ease),o.tween("sx",l,s.t0+a*.45,s.t1,s.ease),o.tween("sy",l,s.t0+a*.45,s.t1,s.ease)}}}moveNode(t,e,o={}){let r=this.node(t);return{label:"graph.move",duration:o.duration??1,ease:o.ease,schedule:s=>{let i=r.get("x"),a=r.get("y");r.tween("x",e[0],s.t0,s.t1,s.ease),r.tween("y",e[1],s.t0,s.t1,s.ease);for(let l of this.edges){if(l.from!==t&&l.to!==t)continue;let c=this.node(l.from===t?l.to:l.from),u=me(c,"x",s.t0),h=me(c,"y",s.t0),d=p=>{let f=i+(e[0]-i)*p,b=a+(e[1]-a)*p,y=l.from===t?r.edgePoint(f,b,u,h,2):c.edgePoint(u,h,f,b,2),g=l.from===t?c.edgePoint(u,h,f,b,4):r.edgePoint(f,b,u,h,4);return Z([y,g])},m=p=>l.tip?mo(d(p),l.tipSize).trimmed:d(p);if(l.shaft.track("path").add({t0:s.t0,t1:s.t1,ease:s.ease,to:m(1),at:m}),l.tip){let p=f=>mo(d(f),l.tipSize).head;l.tip.track("path").add({t0:s.t0,t1:s.t1,ease:s.ease,to:p(1),at:p})}}}}}};function Yi(n,t,e,o,r,s){let i=r?r.slice(1,-1):[],a=i[0]??o,l=i[i.length-1]??e,c=n.edgePoint(e[0],e[1],a[0],a[1],2),u=t.edgePoint(o[0],o[1],l[0],l[1],4);if(!r)return Z([c,u]);if(i.length<=1){let h=u[0]-c[0],d=u[1]-c[1];if(Math.abs(s?d:h)<2)return Z([c,u]);let m=(s?h:d)*.5,p=s?`${c[0]+m} ${c[1]}`:`${c[0]} ${c[1]+m}`,f=s?`${u[0]-m} ${u[1]}`:`${u[0]} ${u[1]-m}`;return vt(`M${c[0]} ${c[1]}C${p} ${f} ${u[0]} ${u[1]}`)}return Lt([c,...i.slice(1,-1),u])}function gn(n,t,e,o,r){let s=me(n,"sx",e),i=me(n,"sy",e);D(n,"sx",s*.001,t),D(n,"sy",i*.001,t),n.tween("sx",s,e,o,r),n.tween("sy",i,e,o,r)}function qi(n,t,e,o,r){let s=$e(r),i=n.map(d=>d.id),a=new Float64Array(i.length),l=new Float64Array(i.length);for(let d=0;d<i.length;d++)a[d]=(s()-.5)*e,l[d]=(s()-.5)*o;let c=new Map(i.map((d,m)=>[d,m])),u=Math.sqrt(e*o/Math.max(1,i.length))*.72,h=Math.max(e,o)*.12;for(let d=0;d<420;d++){let m=new Float64Array(i.length),p=new Float64Array(i.length);for(let f=0;f<i.length;f++)for(let b=f+1;b<i.length;b++){let y=a[f]-a[b],g=l[f]-l[b],w=Math.max(1,Math.hypot(y,g)),x=u*u/w;m[f]+=y/w*x,p[f]+=g/w*x,m[b]-=y/w*x,p[b]-=g/w*x}for(let f of t){let b=c.get(f.from),y=c.get(f.to);if(b===void 0||y===void 0)continue;let g=a[b]-a[y],w=l[b]-l[y],x=Math.max(1,Math.hypot(g,w)),k=x*x/u;m[b]-=g/x*k,p[b]-=w/x*k,m[y]+=g/x*k,p[y]+=w/x*k}for(let f=0;f<i.length;f++){let b=Math.max(1e-6,Math.hypot(m[f],p[f]));a[f]+=m[f]/b*Math.min(b,h),l[f]+=p[f]/b*Math.min(b,h),a[f]=Math.max(-e/2,Math.min(e/2,a[f])),l[f]=Math.max(-o/2,Math.min(o/2,l[f]))}h*=.985}return new Map(i.map((d,m)=>[d,[a[m],l[m]]]))}function Eu(n,t,e={}){return new bn(n,t,e)}var bo=class extends bn{depths=new Map;constructor(t,e={}){let o=[],r=[],s=new Map,i=e.levelGap??130,a=e.siblingGap??96,l=0,c=0,u=(f,b)=>{let y=f.id??`n${l++}`;s.set(y,b);let g=f.children??[],w,x={id:y,label:f.label,color:f.color,math:f.math};if(o.push(x),g.length===0)w=c++;else{let k=g.map(M=>u(M,b+1));w=(k[0].position+k[k.length-1].position)/2;for(let M of k)r.push({from:y,to:M.id,directed:!1})}return x.at=e.direction==="right"?[b*i,w*a]:[w*a,b*i],{id:y,position:w}};u(t,0);let h=o.map(f=>f.at[0]),d=o.map(f=>f.at[1]),m=(Math.min(...h)+Math.max(...h))/2,p=(Math.min(...d)+Math.max(...d))/2;for(let f of o)f.at=[f.at[0]-m,f.at[1]-p];super(o,r,{layout:"manual",radius:e.radius??28,labelSize:e.labelSize??24,nodeColor:e.nodeColor,edgeColor:e.edgeColor,fillOpacity:e.fillOpacity,directed:!1});for(let[f,b]of s)this.depths.set(f,b)}enter(t={}){return{label:"tree.enter",duration:t.duration??2,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let o=Math.max(...this.depths.values())+1,r=(e.t1-e.t0)/o;for(let[s,i]of this.nodes){let a=this.depths.get(s)??0,l=e.t0+a*r;gn(i,e.t0,l,l+r,e.ease)}for(let s of this.edges){let i=this.depths.get(s.to)??1,a=e.t0+(i-1)*r+r*.3;D(s.shaft,"trimTo",0,e.t0),s.shaft.tween("trimTo",1,a,a+r*.8,e.ease)}}}}};function zu(n,t={}){return new bo(n,t)}var go=class extends P{slots=[];indexLabels=[];items=[];cellSize;step;constructor(t,e={}){super();let o=this.cellSize=e.cell??72,r=e.gap??6;this.step=o+r;let s=e.size??o*.38,i=e.color??"blue",a=-((t.length-1)*this.step)/2;t.forEach((l,c)=>{let u=a+c*this.step,h=new P(K(-o/2,-o/2,o,o,6)).stroke("faint",1.5).at(u,0);if(this.slots.push(h),this.add(h),e.indices??!0){let d=_(String(c),{size:e.indexSize??Math.max(13,o*.2),color:"faint",font:"mono"}).at(u,o/2+(e.indexSize??o*.2)+2);this.indexLabels.push(d),this.add(d)}}),t.forEach((l,c)=>{let u=a+c*this.step,h=new P().at(u,0),d=new P(K(-o/2+2,-o/2+2,o-4,o-4,5)).fill(i,.16).stroke(i,2),m=_(String(l),{size:s,font:e.font??"mono",color:"ink"}).at(0,0);h.add(d,m),h.data.box=d,h.data.value=l,this.items.push(h),this.add(h)})}cell(t){let e=this.items[t];if(!e)throw new Error(`Array has no index ${t}.`);return e}slotAt(t){return[this.slots[t].get("x"),this.slots[t].get("y")]}swap(t,e,o={}){return{label:"array.swap",duration:o.duration??.8,ease:o.ease,schedule:r=>{let s=this.items[t],i=this.items[e],[a,l]=this.slotAt(t),[c,u]=this.slotAt(e),h=o.lift??this.cellSize*.9+Math.abs(t-e)*6,d=(m,p,f,b,y,g)=>{m.track("x").add({t0:r.t0,t1:r.t1,ease:r.ease,to:b,at:w=>p+(b-p)*w}),m.track("y").add({t0:r.t0,t1:r.t1,ease:r.ease,to:y,at:w=>f+(y-f)*w-g*h*4*w*(1-w)})};d(s,a,l,c,u,1),d(i,c,u,a,l,-1),this.items[t]=i,this.items[e]=s}}}mark(t,e,o={}){let r=this.cell(t);return{...cr(r.data.box,e,{duration:.35,...o}),label:"array.mark"}}enter(t={}){let e=t.lag??.2;return{label:"array.enter",duration:t.duration??1.2,ease:t.ease,schedule:o=>{it(this,o.t0,o.stage);let r=$t(this.items.length,e,o.t0,o.t1);this.items.forEach((s,i)=>{let[a,l]=r[i];gn(s,o.t0,a,l,o.ease),D(this.slots[i],"opacity",0,o.t0),this.slots[i].tween("opacity",1,a,l,o.ease);let c=this.indexLabels[i];c&&(D(c,"opacity",0,o.t0),c.tween("opacity",1,a,l,o.ease))})}}}};function Vu(n,t={}){return new go(n,t)}var rs={ts:new Set("const let var function return if else for while do switch case break continue new class extends implements interface type enum import export from default async await yield try catch finally throw typeof instanceof in of this super null undefined true false void as readonly public private protected static get set".split(" ")),python:new Set("def return if elif else for while in not and or is class import from as with try except finally raise lambda yield pass break continue global nonlocal None True False self async await assert del print".split(" ")),rust:new Set("fn let mut pub struct enum impl trait use mod match if else for while loop return self Self as in where const static crate super true false ref move async await dyn type".split(" ")),go:new Set("func var const type struct interface package import return if else for range switch case default break continue go defer select chan map nil true false".split(" ")),sql:new Set("select from where join left right inner outer on group by order having limit as and or not in is null insert into values update set delete create table with distinct count sum avg min max".split(" ")),bash:new Set("if then else elif fi for do done while case esac in function return export local echo cd exit set".split(" ")),plain:new Set};function Ui(n,t="ts"){let e=t==="js"||t==="tsx"||t==="jsx"||t==="typescript"||t==="javascript"?"ts":t==="py"?"python":t,o=rs[e]??rs.ts,r=e==="sql",s=e==="python"||e==="bash",i=e==="sql",a=[];return n.split(`
3
- `).forEach((l,c)=>{let u=0;for(;u<l.length;){let h=l.slice(u),d=(y,g)=>{a.push({text:y,kind:g,line:c}),u+=y.length},m=/^\s+/.exec(h);if(m){d(m[0],"space");continue}if(!s&&!i&&h.startsWith("//")||s&&h[0]==="#"||i&&h.startsWith("--")){d(h,"comment");continue}let p=/^("(?:[^"\\]|\\.)*"?|'(?:[^'\\]|\\.)*'?|`(?:[^`\\]|\\.)*`?)/.exec(h);if(p){d(p[0],"string");continue}let f=/^(0x[\da-fA-F_]+|\d[\d_]*(?:\.\d+)?(?:e[-+]?\d+)?)/.exec(h);if(f){d(f[0],"number");continue}let b=/^[A-Za-z_$][\w$]*/.exec(h);if(b){let y=b[0],g=h.slice(y.length),x=o.has(r?y.toLowerCase():y)?"keyword":/^\s*\(/.test(g)?"function":/^[A-Z]/.test(y)?"type":"plain";d(y,x);continue}d(h[0],"punctuation")}}),a}var Zi={keyword:"purple",string:"green",number:"orange",comment:"faint",function:"blue",type:"teal",punctuation:"dim",plain:"ink"},yo=class extends P{lines=[];tokens=[];chars=[];panelNode=null;body=new P;source;bar;rowHeight;originY;contentWidth;constructor(t,e={}){super(),this.source=t;let o=e.size??26,r=this.rowHeight=o*(e.leading??1.5),s=xe("mono",400),i=o/s.unitsPerEm,a=s.advance(s.glyphFor(48))*i,l=Ui(t,e.language??"ts"),c=t.split(`
4
- `),u=e.lineNumbers?(String(c.length).length+2)*a:0,h=e.padding??o*.9,d=Math.max(e.minWidth??0,Math.max(...c.map(g=>g.length))*a+u+h*2),m=c.length*r+h*2-(r-o);this.contentWidth=d;let p=-d/2+h+u,f=-m/2+h+o*.82;if(this.originY=f,e.panel??!0){let g=new P(K(-d/2,-m/2,d,m,8)).fill("surface").stroke("gridStrong",1);this.panelNode=g,this.add(g)}this.bar=new P().fill("yellow",.1),this.bar.base.visible=!1,this.add(this.bar);for(let g=0;g<c.length;g++){let w=new P;if(this.lines.push(w),this.body.add(w),e.lineNumbers){let x=String(g+1).padStart(String(c.length).length," "),k=p-u;for(let M of x)M!==" "&&w.add(ss(s,M,o,"faint",k,f+g*r)),k+=a}}let b={...Zi,...e.colors},y=new Map;for(let g of l){let w=y.get(g.line)??0;y.set(g.line,w+g.text.length);let x={...g,glyphs:[]};if(this.tokens.push(x),g.kind==="space")continue;let k=b[g.kind];[...g.text].forEach((M,v)=>{let A=ss(s,M,o,k,p+(w+v)*a,f+g.line*r);x.glyphs.push(A),this.chars.push(A),this.lines[g.line].add(A)})}this.add(this.body)}line(t){let e=this.lines[t];if(!e)throw new Error(`Code has no line ${t}.`);return e}find(t){return this.tokens.filter(e=>e.text===t).flatMap(e=>e.glyphs)}focus(t,e={}){let o=new Set(typeof t=="number"?[t]:t);return{label:"code.focus",duration:e.duration??.6,ease:e.ease,schedule:r=>{this.lines.forEach((d,m)=>{d.tween("opacity",o.has(m)?1:e.dim??.28,r.t0,r.t1,r.ease)});let s=[...o].sort((d,m)=>d-m),i=s[0]??0,a=s[s.length-1]??i,l=this.originY-this.rowHeight*.32+(i+a)/2*this.rowHeight,c=a-i+1,u=K(-this.contentWidth/2+2,-this.rowHeight*c/2,this.contentWidth-4,this.rowHeight*c,3);me(this.bar,"visible",r.t0)?(this.bar.tween("y",l,r.t0,r.t1,r.ease),this.bar.tween("path",u,r.t0,r.t1,r.ease)):(D(this.bar,"x",0,r.t0),D(this.bar,"y",l,r.t0),this.bar.track("path").step(r.t0,u),D(this.bar,"visible",!0,r.t0),D(this.bar,"opacity",0,r.t0),this.bar.tween("opacity",1,r.t0,r.t1,r.ease)),e.color&&this.bar.tween("fill",X(e.color),r.t0,r.t1,r.ease)}}}unfocus(t={}){return{label:"code.unfocus",duration:t.duration??.5,ease:t.ease,schedule:e=>{for(let o of this.lines)o.tween("opacity",1,e.t0,e.t1,e.ease);this.bar.tween("opacity",0,e.t0,e.t1,e.ease),D(this.bar,"visible",!1,e.t1)}}}};function ss(n,t,e,o,r,s){let i=new P(Ee(n,n.glyphFor(t.codePointAt(0)),e));return i.base.fill=X(o),i.base.trimEach=!0,i.data.key=t,i.at(r,s)}function Lu(n,t={}){return new yo(n,t)}function $u(n,t,e={}){let o=u=>u.tokens.filter(h=>h.kind!=="space"&&h.glyphs.length>0),r=o(n),s=o(t),i=Je(r.map(u=>u.text),s.map(u=>u.text)),a=new Map;i.forEach(([u,h],d)=>{r[u].glyphs.forEach((m,p)=>a.set(m,`m${d}:${p}`)),s[h].glyphs.forEach((m,p)=>a.set(m,`m${d}:${p}`))}),n.panelNode&&t.panelNode&&(a.set(n.panelNode,"panel"),a.set(t.panelNode,"panel"));let l=0;return{...we(n,t,{duration:1.5,...e,key:u=>{let h=a.get(u);return h===void 0&&(h=`only:${l++}`,a.set(u,h)),h}}),label:"morphCode"}}var wo=class extends P{neurons=[];links=[];edgeLayer=new P;neuronLayer=new P;captions=[];seed;layerColors;constructor(t,e={}){super();let o=e.width??1e3,r=e.height??560,s=e.radius??15,i=e.collapse??8,a=t.length>1?o/(t.length-1):0;this.seed=e.seed??11,this.layerColors=e.colors??["blue","teal","teal","yellow"];let l=e.edgeColor??"dim",c=e.edgeOpacity??.32,u=[];t.forEach((h,d)=>{let m=h>i?i:h,p=Math.min(s*3.6,r/Math.max(1,m+(h>i?1:0))),f=-o/2+d*a,b=[],y=[],g=this.layerColors[Math.min(d,this.layerColors.length-1)],w=Math.ceil(m/2);for(let k=0;k<m+(h>i?1:0);k++){let M=(k-(m+(h>i?1:0)-1)/2)*p;if(h>i&&k===w){this.neuronLayer.add(st("\\vdots",{size:s*1.9,color:"dim",display:!1}).at(f,M));continue}b.push([f,M]);let v=new P(Dt(0,0,s)).stroke(g,2.2).fill(g,.08).at(f,M);y.push(v),this.neuronLayer.add(v)}u.push(b),this.neurons.push(y);let x=e.layerLabels?.[d];if(x){let k=e.labelSize??22,M=_(x,{size:k,color:"dim"}).at(f,r/2+k*1.5);this.captions.push(M),this.add(M)}});for(let h=0;h+1<u.length;h++){let d=[];for(let m of u[h]){let p=[];for(let f of u[h+1]){let b=Math.hypot(f[0]-m[0],f[1]-m[1])||1,y=(f[0]-m[0])/b,g=(f[1]-m[1])/b,w=Y([m[0]+y*s,m[1]+g*s],[f[0]-y*s,f[1]-g*s],{stroke:l,width:1.1});w.set("strokeOpacity",c),p.push(w),this.edgeLayer.add(w)}d.push(p)}this.links.push(d)}this.add(this.edgeLayer,this.neuronLayer)}layer(t){return this.neurons[t]??[]}enter(t={}){return{label:"net.enter",duration:t.duration??2.2,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let o=e.t1-e.t0,r=this.neurons.length,s=o*.45,i=r>1?o*.55/(r-1):0;this.neurons.forEach((a,l)=>{let c=$t(a.length,.12,e.t0+l*i,e.t0+l*i+s);a.forEach((u,h)=>gn(u,e.t0,c[h][0],c[h][1],e.ease))}),this.links.forEach((a,l)=>{let c=e.t0+l*i+s*.45;for(let u of a)for(let h of u)D(h,"trimTo",0,e.t0),h.tween("trimTo",1,c,c+s,e.ease)});for(let a of this.neuronLayer.children)a.get("path")||(D(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0+o*.3,e.t1,e.ease));for(let a of this.captions)D(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0+o*.3,e.t1,e.ease)}}}activate(t,e,o={}){return{label:"net.activate",duration:o.duration??.45,ease:o.ease,schedule:r=>{this.neurons[t].forEach((s,i)=>{let a=Math.max(.04,Math.min(1,e[i]??0));s.tween("fillOpacity",a,r.t0,r.t1,r.ease),o.color&&s.tween("fill",X(o.color),r.t0,r.t1,r.ease)})}}}forward(t={}){let e=$e(this.seed),o=this.neurons.map((a,l)=>t.activations?.[l]??a.map(()=>e()*e())),r=t.color??"yellow",s=[];o.forEach((a,l)=>{if(s.push(this.activate(l,a,{duration:.35})),l+1>=this.neurons.length)return;let c=[];this.links[l].forEach((h,d)=>h.forEach((m,p)=>{c.push({link:m,score:(a[d]??0)*(o[l+1]?.[p]??0)})})),c.sort((h,d)=>d.score-h.score);let u=c.slice(0,t.pulses??10);s.push(Ln(...u.map(({link:h,score:d})=>Bn(h,{color:r,length:.42,width:1.5+d*3,glow:4,duration:.7}))))});let i=sr(...s);return{...i,label:"net.forward",duration:t.duration??i.duration,ease:t.ease}}};function Bu(n,t={}){return new wo(n,t)}var xo=class extends P{chips=[];constructor(t,e={}){super();let o=e.size??22,r=e.gap??o*.28,s=e.subSize??o*.62,i=o*.42,a=o*.3,l=t.map(b=>typeof b=="string"?{text:b}:b),c=e.colors?Fe(l.length,...e.colors):null,u=0,h=0,d=[],m=o+a*2+(l.some(b=>b.sub)?s*1.4:0);for(let b=0;b<l.length;b++){let y=l[b],g=y.color??(c?c[b]:e.color??"blue"),w=_(y.text.replace(/ /g,"\xB7"),{size:o,font:e.font??"mono",color:"ink"}),x=Math.max(w.width,o*.5)+i*2,k=o+a*2;e.maxWidth!==void 0&&u>0&&u+x>e.maxWidth&&(u=0,h+=m+r);let M=new P,v=new P(K(-x/2,-k/2,x,k,e.radius??4)).fill(g,.18).stroke(g,1.5);M.add(v,w.at(0,0)),y.sub&&M.add(_(y.sub,{size:s,font:"mono",color:"dim"}).at(0,k/2+s*.82)),M.data.box=v,d.push({node:M,x:u+x/2,y:h,w:x}),u+=x+r}let p=Math.max(...d.map(b=>b.x+b.w/2),0),f=Math.max(...d.map(b=>b.y),0);for(let b of d)b.node.at(b.x-p/2,b.y-f/2),this.chips.push(b.node),this.add(b.node)}token(t){let e=this.chips[t];if(!e)throw new Error(`Token row has no token ${t}.`);return e}enter(t={}){let e=t.lag??.16;return{label:"tokens.enter",duration:t.duration??1.2,ease:t.ease,schedule:o=>{it(this,o.t0,o.stage);let r=$t(this.chips.length,e,o.t0,o.t1);this.chips.forEach((s,i)=>{let[a,l]=r[i],c=s.get("y");D(s,"opacity",0,o.t0),D(s,"y",c+16,o.t0),s.tween("opacity",1,a,l,o.ease),s.tween("y",c,a,l,o.ease)})}}}arcs(t,e,o={}){let r=this.token(t).bounds(),s=new P,i=r.x+r.width/2,a=r.y-3;return e.forEach((l,c)=>{if(c===t||l<=.01)return;let u=this.token(c).bounds(),h=u.x+u.width/2,d=u.y-3,m=o.lift??40+Math.abs(h-i)*.22,p=vt(`M${i} ${a}C${i} ${a-m} ${h} ${d-m} ${h} ${d}`),f=new P(p).stroke(o.color??"yellow",.8+l*(o.maxWidth??6));f.set("strokeOpacity",.2+l*.8),s.add(f)}),s}};function Wu(n,t={}){return new xo(n,t)}function Du(n,t,e,o={}){return new We(e,{cell:o.cell??42,gap:o.gap??2,colors:o.colors??["surface","teal","yellow"],domain:[0,Math.max(...e.flat())],values:o.values,rowLabels:n,columnLabels:t,labelSize:o.labelSize??18,columnLabelAngle:-Math.PI/4})}function qt(n,t,e,o="left"){let r=n.get("px");return n.at(o==="left"?t+r:o==="right"?t-r:t,e)}function _t(n){return n.get("px")*2}var Mo=class extends P{frame;accentBar=null;titleNode;subtitleNode=null;badgeNode=null;rowLabels=[];rowValues=[];meters=[];tagNodes=[];boxWidth;boxHeight;valueSize;constructor(t){super();let e=t.size??14;this.valueSize=e;let o=e*.8,r=t.rows??[],s=e*1.56,i=_(t.title,{size:e*1.14,weight:600,color:"ink"}),a=t.subtitle?_(t.subtitle,{size:e*.86,font:"mono",color:"dim"}):null,l=t.badgeTone??t.accent??"dim",c=t.badge?_(t.badge,{size:e*.78,font:"mono",color:l}):null,u=r.map(M=>_(M.label,{size:e,color:"dim"})),h=r.map(M=>M.value!==void 0?_(M.value,{size:e,font:"mono",color:M.tone??"ink"}):null),d=e*3.6,m=Math.max(_t(i)+(c?_t(c)+e*1.6:0),a?_t(a):0,...r.map((M,v)=>_t(u[v])+(h[v]?_t(h[v])+e*1.1:0)+(M.spark?d+e*.6:0)),0),p=this.boxWidth=Math.max(t.width??0,m+o*2),f=e*1.4+(a?e*1.2:0),b=r.reduce((M,v)=>M+s+(v.meter!==void 0?e*.32:0),0),y=t.tags?.length?e*1.72:0,g=this.boxHeight=o*1.5+f+(r.length?e*.55:0)+b+y,w=-p/2+o,x=p/2-o;if(this.frame=new P(K(-p/2,-g/2,p,g,t.radius??4)).fill(t.fill??"surface").stroke(t.border??"gridStrong",1),this.add(this.frame),t.accent){let M=new P(K(-p/2,-g/2+1,2.5,g-2)).fill(t.accent);this.accentBar=M,this.add(M)}let k=-g/2+o*.75+e*.62;if(this.titleNode=qt(i,w,k),this.add(i),c&&(this.badgeNode=qt(c,x,k,"right"),this.add(c)),k+=e*1.3,a&&(this.subtitleNode=qt(a,w,k-e*.1),this.add(a),k+=e*1.2),r.length){let M=k-e*.38;this.add(Y([-p/2+o,M],[p/2-o,M],{stroke:"grid",width:1})),k+=e*.5}if(r.forEach((M,v)=>{qt(u[v],w,k),this.rowLabels.push(u[v]),this.add(u[v]);let A=x,O=h[v];if(O&&(qt(O,A,k,"right"),this.add(O),A-=_t(O)+e*.7),this.rowValues.push(O??null),M.spark){let N=Ji(M.spark,{width:d,height:e*.82,color:M.tone??"blue",dotted:!0,weight:1.2});this.add(N.at(A-d/2,k-e*.1))}if(k+=s,M.meter!==void 0){let N=k-e*.62;this.add(Y([w,N],[x,N],{stroke:"grid",width:2}));let T=Y([w,N],[w+(x-w)*Math.max(0,Math.min(1,M.meter)),N],{stroke:M.tone??"blue",width:2});T.set("cap","butt"),this.meters.push(T),this.add(T),k+=e*.32}}),t.tags?.length){let M=w,v=g/2-o*.7-e*.4;for(let A of t.tags){let O=_(A,{size:e*.78,font:"mono",color:"dim"}),N=_t(O)+e*.7,T=new P(K(M,v-e*.62,N,e*1.24,2)).stroke("gridStrong",1);qt(O,M+e*.35,v),this.tagNodes.push(O),this.add(T,O),M+=N+e*.34}}}port(t,e=0){let o=this.bounds(),r=o.x+o.width/2,s=o.y+o.height/2;return t==="left"?[o.x,s+e*o.height/2]:t==="right"?[o.x+o.width,s+e*o.height/2]:t==="top"?[r+e*o.width/2,o.y]:[r+e*o.width/2,o.y+o.height]}enter(t={}){return{label:"infoBox.enter",duration:t.duration??.9,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let o=e.t1-e.t0,r=this.frame.get("fillOpacity");D(this.frame,"trimTo",0,e.t0),D(this.frame,"fillOpacity",0,e.t0),this.frame.tween("trimTo",1,e.t0,e.t0+o*.65,e.ease),this.frame.tween("fillOpacity",r,e.t0+o*.2,e.t0+o*.8,e.ease);let s=this.children.filter(a=>a!==this.frame),i=$t(s.length,.06,e.t0+o*.25,e.t1);s.forEach((a,l)=>{let[c,u]=i[l],h=a.get("opacity");D(a,"opacity",0,e.t0),a.tween("opacity",h,c,u,e.ease)})}}}setValue(t,e,o={}){let r=this.rowValues[t];if(!r)throw new Error(`Info box row ${t} has no value to change.`);let s=_(e,{size:this.valueSize,font:"mono",color:o.tone??"ink"}),i=r.get("x")+r.get("px");qt(s,i,r.get("y"),"right");let a=we(r,s,{duration:.5,...o});return{...a,label:"infoBox.setValue",schedule:l=>{this.add(s),this.rowValues[t]=s,a.schedule(l)}}}};function Uu(n){return new Mo(n)}function Ji(n,t={}){let e=t.width??80,o=t.height??20,r=Math.min(...n),i=Math.max(...n)-r||1,a=n.map((u,h)=>[(h/Math.max(1,n.length-1)-.5)*e,(.5-(u-r)/i)*o]),l=t.color??"blue",c=new P;return t.area&&c.add(new P(Z([...a,[e/2,o/2],[-e/2,o/2]],!0)).fill(l,t.area)),c.add(new P(n.length>2?Lt(a):Z(a)).stroke(l,t.weight??1.5)),t.dotted&&c.add(gt((t.weight??1.5)*1.5,l).at(a[a.length-1])),c}var is={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]};function as(n,t,e){let o=n.x+n.width/2,r=n.y+n.height/2;return t==="left"?[n.x,r+e*n.height/2]:t==="right"?[n.x+n.width,r+e*n.height/2]:t==="top"?[o+e*n.width/2,n.y]:[o+e*n.width/2,n.y+n.height]}function Qi(n,t){let e=Math.max(t.x-(n.x+n.width),n.x-(t.x+t.width)),o=Math.max(t.y-(n.y+n.height),n.y-(t.y+t.height)),r=n.x+n.width/2,s=n.y+n.height/2,i=t.x+t.width/2,a=t.y+t.height/2;return e>=o?i>=r?["right","left"]:["left","right"]:a>=s?["bottom","top"]:["top","bottom"]}function ko(n,t){let e=`M${n[0][0]} ${n[0][1]}`;for(let r=1;r<n.length-1;r++){let s=n[r-1],i=n[r],a=n[r+1],l=Math.hypot(i[0]-s[0],i[1]-s[1]),c=Math.hypot(a[0]-i[0],a[1]-i[1]),u=Math.min(t,l/2,c/2);if(u<.5){e+=`L${i[0]} ${i[1]}`;continue}let h=i[0]-(i[0]-s[0])/(l||1)*u,d=i[1]-(i[1]-s[1])/(l||1)*u,m=i[0]+(a[0]-i[0])/(c||1)*u,p=i[1]+(a[1]-i[1])/(c||1)*u;e+=`L${h} ${d}Q${i[0]} ${i[1]} ${m} ${p}`}let o=n[n.length-1];return vt(`${e}L${o[0]} ${o[1]}`)}var vo=class extends P{fromEnd;toEnd;options;pulses=[];plate=null;caption=null;constructor(t,e,o={}){super([]),this.fromEnd=t,this.toEnd=e,this.options=o,this.base.stroke=X(o.color??"dim"),this.base.strokeWidth=o.width??1.6,this.draw=r=>this.build(r)}anchors(){let{fromEnd:t,toEnd:e,options:o}=this,r=o.gap??3,s=m=>m instanceof P?m.bounds():{x:m[0],y:m[1],width:0,height:0},i=s(t),a=s(e),[l,c]=Qi(i,a),u=o.from??l,h=o.to??c,d=(m,p,f,b)=>{let y=is[f];if(!(m instanceof P))return{point:m,normal:y};let[g,w]=as(p,f,b);return{point:[g+y[0]*r,w+y[1]*r],normal:y}};return[d(t,i,u,o.fromOffset??0),d(e,a,h,o.toOffset??0)]}routeNow(){let[t,e]=this.anchors(),o=this.options.route??"curve";if(o==="straight")return Z([t.point,e.point]);if(o==="ortho"){let l=this.options.radius??8,c=t.normal[0]!==0,u=e.normal[0]!==0;if(c&&u){let d=(t.point[0]+e.point[0])/2;return ko([t.point,[d,t.point[1]],[d,e.point[1]],e.point],l)}if(!c&&!u){let d=(t.point[1]+e.point[1])/2;return ko([t.point,[t.point[0],d],[e.point[0],d],e.point],l)}let h=c?[e.point[0],t.point[1]]:[t.point[0],e.point[1]];return ko([t.point,h,e.point],l)}let r=Math.hypot(e.point[0]-t.point[0],e.point[1]-t.point[1]),s=Math.max(18,r*(this.options.curvature??.42)),i=[t.point[0]+t.normal[0]*s,t.point[1]+t.normal[1]*s],a=[e.point[0]+e.normal[0]*s,e.point[1]+e.normal[1]*s];return vt(`M${t.point[0]} ${t.point[1]}C${i[0]} ${i[1]} ${a[0]} ${a[1]} ${e.point[0]} ${e.point[1]}`)}build(t){let e=this.parent&&this.parent!==null?Wt(this.worldMatrix()):zt,o=rt(this.routeNow(),e),r=At(o);if(r<1)return[];let s=this.get("trimTo"),i=this.options,a=this.get("stroke"),l=this.get("strokeWidth"),c=[],u=i.tip??!0,h=u?i.tipSize??Math.max(7,l*4.4):0,d=s*(1-h/r),m=Jt(o,this.get("trimFrom"),d),p=a??X("dim");if(m.length){let f=new P(m).stroke(p,l);(i.dash||i.flow)&&f.dash(i.dash??[6,6],i.flow?-t*i.flow:0),f.set("strokeOpacity",this.get("strokeOpacity")),c.push(f)}if(u&&s>.02){let[f,b]=Pt(o,s),[y,g]=ge(o,Math.min(.997,s)),w=h*.38,x=f-y*h,k=b-g*h;c.push(new P(Z([[f,b],[x-g*w,k+y*w],[x+g*w,k-y*w]],!0)).fill(p))}for(let f of this.pulses){if(t<f.t0||t>=f.t1)continue;let b=f.ease((t-f.t0)/(f.t1-f.t0)),y=Math.max(0,b*(1+f.length)-f.length),g=Math.min(1,b*(1+f.length)),w=Jt(o,y,g);w.length&&c.push(new P(w).stroke(f.color,f.width).glow(f.glow))}if(i.label&&s>.5){let f=i.labelSize??12;this.caption??=_(i.label,{size:f,font:"mono",color:i.labelColor??"dim"});let b=_t(this.caption),y=f*.35;this.plate??=new P(K(-b/2-y,-f*.72,b+y*2,f*1.44,2)).fill(i.labelBackground??"bg");let[g,w]=Pt(o,i.labelAt??.5),x=Math.min(1,(s-.5)*4);c.push(this.plate.at(g,w).opacity(x),this.caption.at(g,w).opacity(x))}return c}pulse(t={}){return{label:"connector.pulse",duration:t.duration??.9,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage),this.pulses.push({t0:e.t0,t1:e.t1,ease:e.ease,color:t.color??"yellow",length:t.length??.22,width:t.width??this.get("strokeWidth")+1.2,glow:t.glow??6})}}}pointNow(t=.5){return Pt(this.routeNow(),t)}};function Zu(n,t,e={}){return new vo(n,t,e)}function Ju(n,t={}){let e=t.size??13,o=(t.direction??"row")==="row",r=t.gap??(o?e*1.5:e*.6),s=e*1.5,i=new P,a=0,l=[];for(let d of n){let m=d.color??"dim",p=d.kind??"swatch",f=p==="line"?Y([-s/2,0],[s/2,0],{stroke:m,width:2.2}):p==="dash"?Y([-s/2,0],[s/2,0],{stroke:m,width:2,dash:[4,3.5]}):p==="dot"?gt(e*.32,m):p==="ring"?Lr(e*.32,{stroke:m,width:1.6}):new P(K(-e*.42,-e*.42,e*.84,e*.84,1.5)).fill(m),b=_(d.label,{size:e,color:"dim"}),y=s+e*.5+_t(b),g=new P;g.add(f.at(s/2,0)),qt(b,s+e*.5,0),g.add(b),l.push({node:g,width:y})}let c=l.reduce((d,m)=>d+m.width,0)+r*Math.max(0,l.length-1),u=Math.max(0,...l.map(d=>d.width)),h=e*1.2+r;return l.forEach((d,m)=>{o?(d.node.at(-c/2+a,0),a+=d.width+r):d.node.at(-u/2,(m-(l.length-1)/2)*h),i.add(d.node)}),i}var Po=class extends P{leader;marker;body;titleNode=null;constructor(t,e,o={}){super();let r=o.size??15,s=o.color??"yellow",i=o.side??"right",a=o.distance??72,l=o.width??280,c=is[i],u=t instanceof P?t.bounds():{x:t[0],y:t[1],width:0,height:0},h=t instanceof P?as(u,i,0):t,d=o.title?_(o.title,{size:r,weight:600,color:s}):null,m=_(e,{size:r*.94,color:o.bodyColor??"dim",maxWidth:l,leading:1.36}),p=d?r*1.42:0,f=Math.max(m.width,d?_t(d):0),b=m.height,y=p+b,g=o.offset??0,w=i==="right"?h[0]+a:i==="left"?h[0]-a-f:h[0]-f/2+g,x=i==="bottom"?h[1]+a:i==="top"?h[1]-a-y:h[1]-y/2+g;if(o.plate){let v=r*.5;this.add(new P(K(w-v,x-v,f+v*2,y+v*2,3)).fill("bg",.86))}d&&(this.titleNode=qt(d,w,x+r*.62),this.add(d)),m.moveTo([w+m.width/2,x+p+b/2]),this.body=m,this.add(m);let k=i==="right"?[w-8,x+y/2]:i==="left"?[w+f+8,x+y/2]:i==="bottom"?[w+f/2,x-8]:[w+f/2,x+y+8],M=c[0]!==0?[h[0]+c[0]*a*.45,k[1]]:[k[0],h[1]+c[1]*a*.45];this.leader=new P(Z([h,M,k])).stroke(s,1.25),this.marker=gt(3,s).at(h),this.add(this.leader,this.marker)}enter(t={}){return{label:"callout.enter",duration:t.duration??.9,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let o=e.t1-e.t0;D(this.marker,"opacity",0,e.t0),this.marker.tween("opacity",1,e.t0,e.t0+o*.2,e.ease),D(this.leader,"trimTo",0,e.t0),this.leader.tween("trimTo",1,e.t0,e.t0+o*.55,e.ease);for(let r of this.children){if(r===this.marker||r===this.leader)continue;let s=r.get("opacity");D(r,"opacity",0,e.t0),r.tween("opacity",s,e.t0+o*.42,e.t1,e.ease)}}}}};function Qu(n,t,e={}){return new Po(n,t,e)}function De(n){return Array.isArray(n)?[...n]:[n]}function ls(n){return De(n).flatMap(t=>t.leaves().filter(e=>e.get("path")))}function ch(n,t={}){let e=ls(n);return{label:"typewriter",duration:t.duration??Math.max(.5,e.length*.035),ease:t.ease??Te,schedule(o){for(let a of De(n))it(a,o.t0,o.stage);let r=ls(n);if(r.length===0)return;let s=o.t1-o.t0,i=null;if(t.cursor){let l=r[0].bounds().height*1.35||24;i=new P(K(0,-l/2,Math.max(3,l*.1),l)).fill(t.cursorColor??"ink"),o.stage.add(i)}r.forEach((a,l)=>{let c=o.t0+s*o.ease(l/r.length),u=a.get("opacity");if(D(a,"opacity",0,o.t0),D(a,"opacity",u,c),i){S.now=c;let h=a.bounds();D(i,"x",h.x+h.width+3,c),D(i,"y",h.y+h.height/2,c),S.now=o.t0}}),i&&D(i,"visible",!1,o.t1)}}}function uh(n,t={}){return{label:"wipe",duration:t.duration??1.2,ease:t.ease??dt,schedule(e){let o=t.from??"left";for(let p of De(n))it(p,e.t0,e.stage);let r=De(n).flatMap(p=>p.leaves()),s=p=>{let f=p.bounds(),b=f.x+f.width/2,y=f.y+f.height/2;return o==="left"?b:o==="right"?-b:o==="top"?y:-y},i=r.map(s),a=Math.min(...i),l=Math.max(...i),c=t.soft??.25,u=t.travel??0,h=e.t1-e.t0,d=o==="left"?-u:o==="right"?u:0,m=o==="top"?-u:o==="bottom"?u:0;r.forEach((p,f)=>{let b=l>a?(i[f]-a)/(l-a):0,y=e.t0+h*(1-c)*e.ease(b),g=y+h*c,w=p.get("opacity");if(D(p,"opacity",0,e.t0),p.tween("opacity",w,y,g,dt),u){let x=p.get("x"),k=p.get("y");D(p,"x",x+d,e.t0),D(p,"y",k+m,e.t0),p.tween("x",x,y,g,dt),p.tween("y",k,y,g,dt)}})}}}var Ge=class extends P{value;constructor(t=0,e={}){super(),this.value=new pt(t);let o=e.digits??0,r=new Intl.NumberFormat("en-US",{minimumFractionDigits:o,maximumFractionDigits:o,useGrouping:e.grouped??!0}),s=Ot(()=>{let i=`${e.prefix??""}${r.format(this.value.value)}${e.suffix??""}`;return _(i,{size:e.size??48,color:e.color??"ink",font:e.font??"mono",weight:e.weight??400})});this.add(s)}};function hh(n=0,t={}){return new Ge(n,t)}function dh(n,t,e={}){let o=n instanceof Ge?n.value:n;return{label:"countUp",duration:e.duration??1.2,ease:e.ease,schedule(r){n instanceof Ge&&it(n,r.t0,r.stage),wt(o,t,r.t0,r.t1,r.ease)}}}function mh(n,t,e={}){return{label:"spin",duration:e.duration??2,ease:e.ease??Te,schedule(o){it(n,o.t0,o.stage),S.now=o.t0,n.pivotAt(e.about??n.center);let r=n.get("rotation"),s=o.t1-o.t0;n.tween("rotation",r+t*s,o.t0,o.t1,o.ease)}}}function ph(n,t,e={}){return{label:"swap",duration:e.duration??.9,ease:e.ease,schedule(o){it(n,o.t0,o.stage),it(t,o.t0,o.stage),S.now=o.t0;let r=n.center,s=t.center,i=e.lift??Math.max(60,Math.hypot(s[0]-r[0],s[1]-r[1])*.3),a=(l,c,u,h)=>{let d=l.parent?Wt(l.parent.worldMatrix()):[1,0,0,1,0,0],m=l.get("x"),p=l.get("y"),[f,b]=Q(d,c[0],c[1]),[y,g]=Q(d,u[0],u[1]),w=m+y-f,x=p+g-b;l.track("x").add({t0:o.t0,t1:o.t1,ease:o.ease,to:w,at:k=>m+(w-m)*k}),l.track("y").add({t0:o.t0,t1:o.t1,ease:o.ease,to:x,at:k=>p+(x-p)*k-h*i*4*k*(1-k)})};a(n,r,s,1),a(t,s,r,-1)}}}function fh(n,t={}){let e=new P([]),o=De(n);return{mark:e,label:"highlightSweep",duration:t.duration??.7,ease:t.ease,schedule(r){let s=1/0,i=1/0,a=-1/0,l=-1/0;for(let M of o){let v=M.bounds();s=Math.min(s,v.x),i=Math.min(i,v.y),a=Math.max(a,v.x+v.width),l=Math.max(l,v.y+v.height)}let c=t.pad??6,u=s-c,h=i-c,d=a-s+c*2,m=l-i+c*2,p=t.radius??3,f=t.color??"yellow";e.base.fill=X(f),e.base.fillOpacity=t.opacity??.26;let b=r.stage.root;b.add(e);let g=o[0];for(;g.parent&&g.parent!==b;)g=g.parent;let w=b.children.indexOf(g);b.children.splice(b.children.indexOf(e),1),b.children.splice(w>=0?w:b.children.length,0,e);let x=t.from==="right",k=M=>{let v=Math.max(.01,d*M);return K(x?u+d-v:u,h,v,m,p)};e.track("path").step(r.t0,k(0)),e.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:k(1),at:k})}}}function cs(n){return n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&#(\d+);/g,(t,e)=>String.fromCodePoint(Number(e))).replace(/&#x([\da-fA-F]+);/g,(t,e)=>String.fromCodePoint(parseInt(e,16))).replace(/&amp;/g,"&")}function ta(n){let t={name:"#root",attrs:{},children:[],text:""},e=[t],o=/<!--[\s\S]*?-->|<!\[CDATA\[([\s\S]*?)\]\]>|<\?[\s\S]*?\?>|<!DOCTYPE[^>]*>|<\/([\w:.-]+)\s*>|<([\w:.-]+)((?:\s+[\w:.-]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>|([^<]+)/g;for(let r=o.exec(n);r;r=o.exec(n)){let s=e[e.length-1],[,i,a,l,c,u,h]=r;if(i!==void 0)s.text+=i;else if(a)e.length>1&&e.pop();else if(l){let d={name:l.replace(/^.*:/,""),attrs:{},children:[],text:""};for(let m of(c??"").matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))d.attrs[m[1]]=cs(m[2]??m[3]??"");s.children.push(d),u||e.push(d)}else h&&(s.text+=cs(h))}return t}function ea(n){if(!n)return zt;let t=zt;for(let e of n.matchAll(/(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/g)){let o=e[2].trim().split(/[\s,]+/).filter(Boolean).map(Number),r=e[1];if(r==="matrix"&&o.length===6)t=ot(t,o);else if(r==="translate")t=ot(t,[1,0,0,1,o[0]??0,o[1]??0]);else if(r==="scale")t=ot(t,[o[0]??1,0,0,o[1]??o[0]??1,0,0]);else if(r==="rotate"){let s=(o[0]??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),l=o[1]??0,c=o[2]??0;t=ot(t,[1,0,0,1,l,c]),t=ot(t,[i,a,-a,i,0,0]),t=ot(t,[1,0,0,1,-l,-c])}else r==="skewX"?t=ot(t,[1,0,Math.tan((o[0]??0)*Math.PI/180),1,0,0]):r==="skewY"&&(t=ot(t,[1,Math.tan((o[0]??0)*Math.PI/180),0,1,0,0]))}return t}var na=new Set(["defs","clipPath","mask","pattern","filter","symbol","marker","linearGradient","radialGradient","title","desc","metadata","style","script"]),wn=class extends P{byId=new Map;pictureWidth=0;pictureHeight=0;find(t){let e=this.byId.get(t);if(!e)throw new Error(`The SVG has no element with id ${JSON.stringify(t)}.`);return e}};function oa(n){let t=new Map,e=o=>{if(o.name==="style")for(let r of o.text.matchAll(/([^{}]+)\{([^{}]*)\}/g)){let s=Ao(r[2]);for(let i of r[1].split(",")){let a=i.trim();t.set(a,{...t.get(a),...s})}}o.children.forEach(e)};return e(n),t}function Ao(n){let t={};if(!n)return t;for(let e of n.split(";")){let o=e.indexOf(":");o>0&&(t[e.slice(0,o).trim()]=e.slice(o+1).trim())}return t}function yn(n){if(!n||n==="none"||n==="transparent")return null;try{return Gt(n)}catch{return null}}function ra(n){let t=n.map(s=>{let i=bt([s]);return{ring:s,b:i,area:i.width*i.height,owner:-1}}),e=t.map((s,i)=>i).sort((s,i)=>t[i].area-t[s].area);for(let s=0;s<e.length;s++){let i=t[e[s]];for(let a=s-1;a>=0;a--){let l=t[e[a]];if(l.owner!==-1)continue;if(i.b.x>=l.b.x-.01&&i.b.y>=l.b.y-.01&&i.b.x+i.b.width<=l.b.x+l.b.width+.01&&i.b.y+i.b.height<=l.b.y+l.b.height+.01){i.owner=e[a];break}}}let o=[],r=new Map;return t.forEach((s,i)=>{if(s.owner!==-1)return;let a={x:s.b.x,rings:[s.ring]};r.set(i,a),o.push(a)}),t.forEach(s=>{s.owner!==-1&&r.get(s.owner)?.rings.push(s.ring)}),o.sort((s,i)=>s.x-i.x).map(s=>s.rings)}function sa(n,t={}){let o=ta(n).children.find(C=>C.name==="svg");if(!o)throw new Error("fromSvg needs markup with an <svg> element.");let r=oa(o),s=new Map,i=C=>{C.attrs.id&&s.set(C.attrs.id,C),C.children.forEach(i)};i(o);let a=(o.attrs.viewBox??"").trim().split(/[\s,]+/).map(Number),l=parseFloat(o.attrs.width??""),c=parseFloat(o.attrs.height??""),u=a.length===4&&a[2]?a[2]:l||300,h=a.length===4&&a[3]?a[3]:c||150,d=a.length===4?a[0]:0,m=a.length===4?a[1]:0,p=Number.isFinite(l)&&l>0?l:u,f=Number.isFinite(c)&&c>0?c:h,b=1;if(t.width!==void 0||t.height!==void 0){let C=t.width!==void 0?t.width/u:1/0,L=t.height!==void 0?t.height/h:1/0;b=Math.min(C,L)}else b=Math.min(p/u,f/h);let y=t.center??!0,g=y?-(d+u/2)*b:-d*b,w=y?-(m+h/2)*b:-m*b,x=[b,0,0,b,g,w],k=new wn;k.pictureWidth=u*b,k.pictureHeight=h*b;let M=t.splitGlyphs??!0,v=t.background??!1,A=!0,O=(C,L,I)=>{let F=s.get(C);if(!F)return null;if(F.name==="pattern"){let E=F.children.find(j=>j.name==="linearGradient");if(E)return T(E,L,I,!0);let $=F.children.find(j=>j.attrs.fill?.startsWith("url(#"))?.attrs.fill?.match(/url\(#([^)]+)\)/)?.[1];return $?O($,L,I):null}if(F.name==="linearGradient")return T(F,L,I,F.attrs.gradientUnits!=="userSpaceOnUse");if(F.name==="radialGradient"){let E=N(F);return E.length?E[E.length-1][1]:null}return null},N=C=>{let L=C.attrs.href??C.attrs["xlink:href"];return(C.children.some(F=>F.name==="stop")||!L?C:s.get(L.replace(/^#/,""))??C).children.filter(F=>F.name==="stop").map(F=>{let E=Ao(F.attrs.style),R=F.attrs.offset??"0",$=R.endsWith("%")?parseFloat(R)/100:parseFloat(R),j=yn(E["stop-color"]??F.attrs["stop-color"]??"#000000")??[0,0,0,1],J=parseFloat(E["stop-opacity"]??F.attrs["stop-opacity"]??"1");return[$,[j[0],j[1],j[2],j[3]*J]]})},T=(C,L,I,F)=>{let E=N(C);if(E.length===0)return null;let R=(H,ct)=>H===void 0?ct:H.endsWith("%")?parseFloat(H)/100:parseFloat(H),$=R(C.attrs.x1,0),j=R(C.attrs.y1,0),J=R(C.attrs.x2,1),at=R(C.attrs.y2,0),tt,ut;if(F){let H=bt(I)??{x:0,y:0,width:1,height:1};tt=[H.x+$*H.width,H.y+j*H.height],ut=[H.x+J*H.width,H.y+at*H.height]}else tt=Q(L,$,j),ut=Q(L,J,at);return{type:"linear",from:tt,to:ut,stops:E}},V=C=>{let L=C.attrs,I=(F,E=0)=>{let R=parseFloat(L[F]??"");return Number.isFinite(R)?R:E};switch(C.name){case"path":return L.d?vt(L.d):null;case"rect":{let F=I("width"),E=I("height");return F<=0||E<=0?null:K(I("x"),I("y"),F,E,I("rx",I("ry")))}case"circle":return I("r")>0?St(I("cx"),I("cy"),I("r"),I("r"),0,Math.PI*2):null;case"ellipse":return I("rx")>0&&I("ry")>0?St(I("cx"),I("cy"),I("rx"),I("ry"),0,Math.PI*2):null;case"line":return Z([[I("x1"),I("y1")],[I("x2"),I("y2")]]);case"polyline":case"polygon":{let F=(L.points??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),E=[];for(let R=0;R+1<F.length;R+=2)E.push([F[R],F[R+1]]);return E.length>=2?Z(E,C.name==="polygon"):null}default:return null}},z=(C,L)=>{let I=C.attrs,F=(I.class??"").split(/\s+/).filter(Boolean),E={...r.get(C.name)};for(let q of F)Object.assign(E,r.get(`.${q}`));I.id&&Object.assign(E,r.get(`#${I.id}`));let R=q=>Ao(I.style)[q]??I[q]??E[q],$={...L},j=R("color");j&&($.color=j);let J=R("fill");J&&($.fill=J==="currentColor"?$.color:J);let at=R("stroke");at&&($.stroke=at==="currentColor"?$.color:at);let tt=R("stroke-width");tt!==void 0&&($.strokeWidth=parseFloat(tt)||0);let ut=R("fill-opacity");ut!==void 0&&($.fillOpacity=parseFloat(ut));let H=R("stroke-opacity");H!==void 0&&($.strokeOpacity=parseFloat(H));let ct=R("stroke-linecap");(ct==="round"||ct==="butt"||ct==="square")&&($.cap=ct);let mt=R("stroke-linejoin");(mt==="round"||mt==="miter"||mt==="bevel")&&($.join=mt);let nt=R("stroke-dasharray");nt!==void 0&&($.dash=nt==="none"?null:nt.trim().split(/[\s,]+/).map(Number));let ht=R("stroke-dashoffset");ht!==void 0&&($.dashOffset=parseFloat(ht)||0);let xt=R("font-size");xt!==void 0&&($.fontSize=parseFloat(xt)||$.fontSize);let kt=R("text-anchor");return kt&&($.anchor=kt),{style:$,opacity:parseFloat(R("opacity")??"1")}},B=(C,L,I,F)=>{let E=rt(C,L),R=Xt(L),$=nt=>nt?.match(/^url\(#([^)]+)\)/)?.[1],j=$(F.fill),J=$(F.stroke),at=j?O(j,L,E):yn(F.fill),tt=J?O(J,L,E):yn(F.stroke),ut=at&&F.fillOpacity>0&&!(Array.isArray(at)&&at[3]===0),H=tt&&F.strokeOpacity>0&&F.strokeWidth>0&&!(Array.isArray(tt)&&tt[3]===0);if(!ut&&!H)return[];let ct=I.attrs["clip-path"]?.5:1;return(M&&ut&&!H&&E.length>1?ra(E):[E]).map(nt=>{let ht=bt(nt)??{x:0,y:0,width:0,height:0},xt=ht.x+ht.width/2,kt=ht.y+ht.height/2,q=new P(rt(nt,[1,0,0,1,-xt,-kt])).at(xt,kt);return ut&&(q.base.fill=us(at,-xt,-kt),q.base.fillOpacity=F.fillOpacity),H&&(q.base.stroke=us(tt,-xt,-kt),q.base.strokeWidth=F.strokeWidth*R*ct,q.base.strokeOpacity=F.strokeOpacity,q.base.cap=F.cap,q.base.join=F.join,F.dash&&(q.base.dash=F.dash.map(ie=>ie*R)),q.base.dashOffset=F.dashOffset*R),q.base.trimEach=!0,q})},W=(C,L,I,F)=>{if(na.has(C.name)||C.attrs.filter)return;let{style:E,opacity:R}=z(C,I),$=ot(F,ea(C.attrs.transform)),j=H=>{C.attrs.id&&k.byId.set(C.attrs.id,H)};if(C.name==="g"||C.name==="svg"||C.name==="a"){let H=new P;R<1&&(H.base.opacity=R),j(H),L.add(H);for(let ct of C.children)W(ct,H,E,$);return}if(C.name==="use"){let H=(C.attrs.href??C.attrs["xlink:href"]??"").replace(/^#/,""),ct=s.get(H);if(!ct)return;let mt=ot($,[1,0,0,1,parseFloat(C.attrs.x??"0")||0,parseFloat(C.attrs.y??"0")||0]),nt=new P;if(R<1&&(nt.base.opacity=R),L.add(nt),ct.name==="symbol")for(let ht of ct.children)W(ht,nt,E,mt);else W(ct,nt,E,mt);return}if(C.name==="image"){let H=C.attrs.href??C.attrs["xlink:href"];if(!H)return;let ct=parseFloat(C.attrs.width??"0"),mt=parseFloat(C.attrs.height??"0"),[nt,ht]=Q($,parseFloat(C.attrs.x??"0")||0,parseFloat(C.attrs.y??"0")||0),xt=Xt($),kt={src:H,width:ct,height:mt},q=new P().at(nt,ht);q.base.image=kt,q.base.sx=xt,q.base.sy=xt,R<1&&(q.base.opacity=R),j(q),L.add(q);return}if(C.name==="text"){let H=(C.text+C.children.map(q=>q.text).join("")).trim();if(!H)return;let ct=yn(E.fill)??[0,0,0,1],mt=E.fontSize*Xt($),nt=_(H,{size:mt,color:ct}),[ht,xt]=Q($,parseFloat(C.attrs.x??"0")||0,parseFloat(C.attrs.y??"0")||0),kt=nt.get("px");nt.at(E.anchor==="middle"?ht:E.anchor==="end"?ht-kt:ht+kt,xt-mt*.34),R<1&&(nt.base.opacity=R),j(nt),L.add(nt);return}let J=V(C);if(!J||J.length===0)return;let at=A&&C.name==="rect"&&!v&&parseFloat(C.attrs.width??"0")>=u-.5&&parseFloat(C.attrs.height??"0")>=h-.5;if(A=!1,at)return;let tt=B(J,$,C,E);if(tt.length===0)return;if(tt.length===1){R<1&&(tt[0].base.opacity=R),j(tt[0]),L.add(tt[0]);return}let ut=new P;R<1&&(ut.base.opacity=R),ut.add(...tt),j(ut),L.add(ut)},G={fill:"#000000",stroke:null,strokeWidth:1,fillOpacity:1,strokeOpacity:1,cap:"butt",join:"miter",dash:null,dashOffset:0,color:"#000000",fontSize:16,anchor:"start"},{style:U}=z(o,G);for(let C of o.children)W(C,k,U,x);return k}function us(n,t,e){if(Array.isArray(n))return n;let o=n;return o.type==="linear"?{...o,from:[o.from[0]+t,o.from[1]+e],to:[o.to[0]+t,o.to[1]+e]}:o.type==="radial"?{...o,center:[o.center[0]+t,o.center[1]+e]}:o}var re=n=>typeof n=="function"?n():n,hs=n=>{let t=Math.hypot(n[0],n[1],n[2])||1;return[n[0]/t,n[1]/t,n[2]/t]},Oo=class{ops=[];depths=[];rx=0;ry=0;ux=0;uy=0;uz=0;dx=0;dy=0;dz=0;fx=0;fy=0;fz=0;distance=12;unit=100;perspective=!0;matrix=[1,0,0,1,0,0];alpha=1;scale=1;light=[0,0,1];half=[0,0,1];ambient=.4;shine=.2;fog=0;fogColor=[0,0,0,1];depthRange=1;brightness=1;px=0;py=0;pz=0;ps=1;project(t,e,o){let r=t-this.fx,s=e-this.fy,i=o-this.fz,a=r*this.rx+s*this.ry,l=r*this.ux+s*this.uy+i*this.uz,c=r*this.dx+s*this.dy+i*this.dz,u=1;if(this.perspective){let p=this.distance-c;if(p<=.05)return!1;u=this.distance/p}let h=a*this.unit*u,d=-l*this.unit*u,m=this.matrix;return this.px=m[0]*h+m[2]*d+m[4],this.py=m[1]*h+m[3]*d+m[5],this.pz=c,this.ps=u,!0}screen(t,e,o){let r=t-this.fx,s=e-this.fy,i=o-this.fz,a=r*this.rx+s*this.ry,l=r*this.ux+s*this.uy+i*this.uz,c=r*this.dx+s*this.dy+i*this.dz,u=1;if(this.perspective){let h=this.distance-c;if(h<=.05)return null;u=this.distance/h}return[a*this.unit*u,-l*this.unit*u]}fogged(t,e,o,r){if(this.fog<=0)return[t,e,o,1];let s=Math.max(0,Math.min(1,-r/this.depthRange*this.fog));return[t+(this.fogColor[0]-t)*s,e+(this.fogColor[1]-e)*s,o+(this.fogColor[2]-o)*s,1]}push(t,e){this.ops.push(t),this.depths.push(e)}};function Me(n,t,e,o,r=0,s="round"){return{kind:"path",path:n,strokePath:n,fill:null,fillAlpha:0,stroke:t,strokeAlpha:e,strokeWidth:o,cap:s,join:"round",dash:null,dashOffset:0,glow:r,glowColor:null,blend:"normal"}}function ve(n,t,e,o,r,s){return{kind:"path",path:n,strokePath:n,fill:t,fillAlpha:e,stroke:o,strokeAlpha:r,strokeWidth:s,cap:"round",join:"round",dash:null,dashOffset:0,glow:0,glowColor:null,blend:"normal"}}function xn(n,t,e,o){let r=e-n,s=o-t,i=new Float64Array(8);return i[0]=n,i[1]=t,i[2]=n+r/3,i[3]=t+s/3,i[4]=n+r*2/3,i[5]=t+s*2/3,i[6]=e,i[7]=o,{p:i,closed:!1,straight:!0}}function Eo(n){let t=n.length/2,e=new Float64Array(2+t*6);e[0]=n[0],e[1]=n[1];let o=2;for(let r=0;r<t;r++){let s=n[r*2],i=n[r*2+1],a=n[(r+1)%t*2],l=n[(r+1)%t*2+1];e[o++]=s+(a-s)/3,e[o++]=i+(l-i)/3,e[o++]=s+(a-s)*2/3,e[o++]=i+(l-i)*2/3,e[o++]=a,e[o++]=l}return{p:e,closed:!0,straight:!0}}var ia=.5522847498307936;function ds(n,t,e){let o=e*ia;return{closed:!0,p:Float64Array.of(n+e,t,n+e,t+o,n+o,t+e,n,t+e,n-o,t+e,n-e,t+o,n-e,t,n-e,t-o,n-o,t-e,n,t-e,n+o,t-e,n+e,t-o,n+e,t)}}var Et=class extends P{constructor(){super([])}labelsNow(t){return[]}objectAlpha(t){return t.alpha*this.get("opacity")}},No=class extends P{phi;theta;distance;unit;focusX;focusY;focusZ;orthographic;settings;spins=[];openSpin=null;constructor(t={}){super(),this.settings=t,this.phi=new pt(t.phi??1.15),this.theta=new pt(t.theta??-1),this.distance=new pt(t.distance??14),this.unit=new pt(t.unit??120),this.focusX=new pt(t.focus?.[0]??0),this.focusY=new pt(t.focus?.[1]??0),this.focusZ=new pt(t.focus?.[2]??0),this.orthographic=t.perspective===!1,this.rawOps=(e,o,r)=>this.render(e,o,r),this.draw=e=>{let o=this.view(this.worldless,1,e);return this.children.flatMap(r=>r instanceof Et&&r.get("visible")?r.labelsNow(o):[])}}worldless=[1,0,0,1,0,0];view(t,e,o){let r=new Oo,s=this.phi.value,i=this.theta.value;for(let m of this.spins)o>m.from&&(i+=(Math.min(o,m.to)-m.from)*m.rate);let a=Math.sin(s),l=Math.cos(s),c=Math.sin(i),u=Math.cos(i);r.rx=-c,r.ry=u,r.ux=-l*u,r.uy=-l*c,r.uz=a,r.dx=a*u,r.dy=a*c,r.dz=l,r.fx=this.focusX.value,r.fy=this.focusY.value,r.fz=this.focusZ.value,r.distance=this.distance.value,r.unit=this.unit.value,r.perspective=!this.orthographic,r.matrix=t,r.alpha=e,r.scale=Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]));let h=hs(this.settings.light??[-.45,-.55,.85]);r.light=h,r.half=hs([h[0]+r.dx,h[1]+r.dy,h[2]+r.dz]),r.ambient=this.settings.ambient??.26,r.shine=this.settings.shine??.2,r.fog=this.settings.fog??.6;let d=Gt("bg");return r.fogColor=this.settings.fogColor?Ft(this.settings.fogColor):d,r.depthRange=Math.max(3,r.distance*.5),r.brightness=this.settings.brightness??(d[0]+d[1]+d[2]<200?.8:1),r}render(t,e,o){let r=S.now,s=this.view(t,e,r);for(let c of this.children)c instanceof Et&&c.get("visible")&&c.emit(s,r);let i=s.ops.length,a=new Uint32Array(i);for(let c=0;c<i;c++)a[c]=c;let l=s.depths;a.sort((c,u)=>l[c]-l[u]);for(let c=0;c<i;c++)o.push(s.ops[a[c]])}orbit(t,e={}){return{label:"camera3d",duration:e.duration??2,ease:e.ease,schedule:o=>{t.phi!==void 0&&wt(this.phi,t.phi,o.t0,o.t1,o.ease),t.theta!==void 0&&wt(this.theta,t.theta,o.t0,o.t1,o.ease),t.distance!==void 0&&wt(this.distance,t.distance,o.t0,o.t1,o.ease),t.unit!==void 0&&wt(this.unit,t.unit,o.t0,o.t1,o.ease),t.focus&&(wt(this.focusX,t.focus[0],o.t0,o.t1,o.ease),wt(this.focusY,t.focus[1],o.t0,o.t1,o.ease),wt(this.focusZ,t.focus[2],o.t0,o.t1,o.ease))}}}spin(t=.12){return this.stopSpin(),this.openSpin={from:S.now,to:1/0,rate:t},this.spins.push(this.openSpin),this}stopSpin(){return this.openSpin&&(this.openSpin.to=S.now),this.openSpin=null,this}stagePoint(t){let e=this.view(this.worldMatrix(),1,S.now);return e.project(t[0],t[1],t[2])?[e.px,e.py]:[0,0]}};function Sh(n={}){return new No(n)}var je=class extends Et{constructor(e,o,r,s={}){super();this.fn=e;this.uRange=o;this.vRange=r;this.options=s;let i=s.resolution??40;this.nu=typeof i=="number"?i:i[0],this.nv=typeof i=="number"?i:i[1];let a=(this.nu+1)*(this.nv+1);if(this.positions=new Float64Array(a*3),this.normals=new Float64Array(this.nu*this.nv*3),this.vertexNormals=new Float64Array(a*3),this.shadingNormals=new Float64Array(this.nu*this.nv*3),this.faceColors=new Float32Array(this.nu*this.nv*3),this.screenX=new Float64Array(a),this.screenY=new Float64Array(a),this.screenZ=new Float64Array(a),this.valid=new Uint8Array(a),this.meshColor=s.mesh?Ft(s.mesh):null,s.colors){let l=s.colors.map(c=>Ft(c));this.ramp=l.map((c,u)=>[l.length===1?0:u/(l.length-1),c])}s.checker&&(this.checkerColors=[Ft(s.checker[0]),Ft(s.checker[1])]),(s.color||!s.colors&&!s.checker&&!s.colorAt)&&(this.base.fill=X(s.color??"blue"))}fn;uRange;vRange;options;nu;nv;positions;normals;vertexNormals;shadingNormals;faceColors;computedFor=-1/0;screenX;screenY;screenZ;valid;meshColor;ramp=null;checkerColors=null;compute(e){let{nu:o,nv:r,positions:s,normals:i,faceColors:a,fn:l,uRange:c,vRange:u,options:h}=this,d=0,m=1/0,p=-1/0;for(let g=0;g<=o;g++){let w=c[0]+(c[1]-c[0])*g/o;for(let x=0;x<=r;x++){let k=u[0]+(u[1]-u[0])*x/r,M=l(w,k,e);s[d++]=M[0],s[d++]=M[1],s[d++]=M[2],M[2]<m&&(m=M[2]),M[2]>p&&(p=M[2])}}let f=r+1,b=this.vertexNormals;b.fill(0);for(let g=0;g<o;g++)for(let w=0;w<r;w++){let x=(g*f+w)*3,k=((g+1)*f+w)*3,M=((g+1)*f+w+1)*3,v=(g*f+w+1)*3,A=s[M]-s[x],O=s[M+1]-s[x+1],N=s[M+2]-s[x+2],T=s[v]-s[k],V=s[v+1]-s[k+1],z=s[v+2]-s[k+2],B=O*z-N*V,W=N*T-A*z,G=A*V-O*T,U=Math.hypot(B,W,G)||1;if(B/=U,W/=U,G/=U,h.outwardFrom){let[L,I,F]=h.outwardFrom,E=(s[x]+s[M])/2-L,R=(s[x+1]+s[M+1])/2-I,$=(s[x+2]+s[M+2])/2-F;B*E+W*R+G*$<0&&(B=-B,W=-W,G=-G)}let C=(g*r+w)*3;i[C]=B,i[C+1]=W,i[C+2]=G;for(let L of[x/3,k/3,M/3,v/3])b[L*3]+=B,b[L*3+1]+=W,b[L*3+2]+=G;if(this.ramp||this.checkerColors||h.colorAt){let L;if(h.colorAt){let I=(s[x]+s[M])/2,F=(s[x+1]+s[M+1])/2,E=(s[x+2]+s[M+2])/2;L=h.colorAt(I,F,E,(g+.5)/o,(w+.5)/r)}else if(this.checkerColors)L=this.checkerColors[(g+w)%2];else{let I=(s[x+2]+s[M+2]+s[k+2]+s[v+2])/4;L=lt(this.ramp,p>m?(I-m)/(p-m):0)}a[C]=L[0],a[C+1]=L[1],a[C+2]=L[2]}}let y=this.shadingNormals;for(let g=0;g<o;g++)for(let w=0;w<r;w++){let x=(g*f+w)*3,k=((g+1)*f+w)*3,M=((g+1)*f+w+1)*3,v=(g*f+w+1)*3,A=0,O=0,N=0;for(let z of[x,k,M,v])A+=b[z],O+=b[z+1],N+=b[z+2];let T=Math.hypot(A,O,N)||1,V=(g*r+w)*3;y[V]=A/T,y[V+1]=O/T,y[V+2]=N/T}}emit(e,o){let{options:r,nu:s,nv:i,normals:a,shadingNormals:l,faceColors:c,screenX:u,screenY:h,screenZ:d,valid:m}=this,p=this.objectAlpha(e)*(r.opacity??1)*this.get("fillOpacity");if(p<=.002)return;(r.animate?this.computedFor!==o:this.computedFor===-1/0)&&(this.compute(r.animate?o:0),this.computedFor=o);let f=this.positions,b=i+1,y=(s+1)*(i+1);for(let I=0;I<y;I++){let F=I*3;e.project(f[F],f[F+1],f[F+2])?(u[I]=e.px,h[I]=e.py,d[I]=e.pz,m[I]=1):m[I]=0}let g=this.ramp||this.checkerColors||r.colorAt?null:se(this.get("fill")),w=r.shaded??!0,x=p>=.995,k=this.get("trimTo"),M=Math.ceil(k*s),{light:v,half:A,ambient:O,shine:N,brightness:T,dx:V,dy:z,dz:B}=e,W=r.cull??!1,G=this.meshColor,U=(r.meshOpacity??.35)*p,C=(r.meshWidth??1)*e.scale,L=.55*e.scale;for(let I=0;I<M;I++)for(let F=0;F<i;F++){let E=I*b+F,R=(I+1)*b+F,$=(I+1)*b+F+1,j=I*b+F+1;if(!m[E]||!m[R]||!m[$]||!m[j])continue;let J=(I*i+F)*3,at=a[J]*V+a[J+1]*z+a[J+2]*B;if(at<0&&W)continue;let tt=at<0?-1:1,ut=l[J]*tt,H=l[J+1]*tt,ct=l[J+2]*tt,mt,nt,ht;if(g?(mt=g[0],nt=g[1],ht=g[2]):(mt=c[J],nt=c[J+1],ht=c[J+2]),w){let Ut=.5+.5*(ut*v[0]+H*v[1]+ct*v[2]),Kt=(O+(1-O)*Ut*Ut)*T,Zt=N>0?N*Math.pow(Math.max(0,ut*A[0]+H*A[1]+ct*A[2]),42)*255:0;mt=Math.min(255,mt*Kt+Zt),nt=Math.min(255,nt*Kt+Zt),ht=Math.min(255,ht*Kt+Zt)}let xt=(d[E]+d[R]+d[$]+d[j])/4,kt=e.fogged(mt,nt,ht,xt),q=u[E],ie=h[E],Pe=u[R],Ae=h[R],Oe=u[$],Ne=h[$],Ce=u[j],Se=h[j];if(x&&!G){let Ut=(q+Pe+Oe+Ce)/4,Kt=(ie+Ae+Ne+Se)/4,Zt=(gs,ys)=>L/(Math.hypot(gs-Ut,ys-Kt)||1),Lo=Zt(q,ie),$o=Zt(Pe,Ae),Bo=Zt(Oe,Ne),Wo=Zt(Ce,Se);q+=(q-Ut)*Lo,ie+=(ie-Kt)*Lo,Pe+=(Pe-Ut)*$o,Ae+=(Ae-Kt)*$o,Oe+=(Oe-Ut)*Bo,Ne+=(Ne-Kt)*Bo,Ce+=(Ce-Ut)*Wo,Se+=(Se-Kt)*Wo}let Vo=Eo([q,ie,Pe,Ae,Oe,Ne,Ce,Se]);e.push(G?ve([Vo],kt,p,G,U,C):ve([Vo],kt,p,null,0,0),xt)}}};function se(n){return n?Array.isArray(n)?n:Ft(n):[90,180,240,1]}function Rh(n,t,e,o={}){return new je(n,t,e,o)}function Th(n,t={}){let e=t.x??[-4,4],o=t.y??[-4,4];return new je((r,s,i)=>[r,s,n(r,s,i)],e,o,{colors:t.color||t.checker||t.colorAt?void 0:["blue","teal","yellow"],...t})}function Fh(n=1,t={}){let[e,o,r]=t.center??[0,0,0];return new je((s,i)=>[e+n*Math.sin(i)*Math.cos(s),o+n*Math.sin(i)*Math.sin(s),r+n*Math.cos(i)],[0,Math.PI*2],[0,Math.PI],{cull:!0,resolution:[64,40],outwardFrom:[e,o,r],...t})}var He=1e6,Co=class extends Et{constructor(e,o,r,s={}){super();this.style=s;let i=s.samples??240;this.points=new Float64Array((i+1)*3);for(let a=0;a<=i;a++){let[l,c,u]=e(o+(r-o)*a/i);this.points[a*3]=l,this.points[a*3+1]=c,this.points[a*3+2]=u}if(this.base.stroke=X(s.color??"yellow"),this.base.strokeWidth=s.width??3,s.colors){let a=s.colors.map(l=>Ft(l));this.stops=a.map((l,c)=>[a.length===1?0:c/(a.length-1),l])}else this.stops=null}style;points;stops;emit(e){let o=this.objectAlpha(e)*(this.style.opacity??1)*this.get("strokeOpacity");if(o<=.002)return;let r=this.get("trimTo"),s=this.points.length/3-1,i=Math.floor(r*s);if(i<1)return;let a=Math.max(2,Math.ceil(s/72)),l=this.get("stroke")??X("yellow"),c=this.get("strokeWidth")*e.scale,u=this.style.onTop?He:this.style.bias??.12,h=(this.style.glow??0)*e.scale;for(let d=0;d<i;d+=a){let m=Math.min(i,d+a),p=[],f=0,b=0,y=0;for(let x=d;x<=m;x++)e.project(this.points[x*3],this.points[x*3+1],this.points[x*3+2])&&(p.push([e.px,e.py]),f+=e.pz,b+=e.ps,y++);if(y<2)continue;f/=y,b/=y;let g=this.stops?lt(this.stops,(d+m)/2/s):se(l),w=e.fogged(g[0],g[1],g[2],f);e.push(Me([ms(p)],w,o,c*b,h,"round"),f+u)}}};function ms(n){let t=new Float64Array(2+(n.length-1)*6);t[0]=n[0][0],t[1]=n[0][1];let e=2;for(let o=1;o<n.length;o++){let r=n[o-1],s=n[o];t[e++]=r[0]+(s[0]-r[0])/3,t[e++]=r[1]+(s[1]-r[1])/3,t[e++]=r[0]+(s[0]-r[0])*2/3,t[e++]=r[1]+(s[1]-r[1])*2/3,t[e++]=s[0],t[e++]=s[1]}return{p:t,closed:!1,straight:!0}}function Ih(n,t,e,o={}){return new Co(n,t,e,o)}var kn=class extends Et{constructor(e,o,r={}){super();this.a=e;this.b=o;this.style=r;this.base.stroke=X(r.color??"ink"),this.base.strokeWidth=r.width??2.5}a;b;style;emit(e){let o=this.objectAlpha(e)*(this.style.opacity??1)*this.get("strokeOpacity");if(o<=.002)return;let r=re(this.a),s=re(this.b),i=this.style.pieces??14,a=this.get("trimTo"),l=se(this.get("stroke")),c=this.get("strokeWidth")*e.scale,u=this.style.onTop?He:this.style.bias??0;for(let h=0;h<i;h++){let d=h/i*a,m=(h+1)/i*a;if(!e.project(r[0]+(s[0]-r[0])*d,r[1]+(s[1]-r[1])*d,r[2]+(s[2]-r[2])*d))continue;let p=e.px,f=e.py,b=e.pz,y=e.ps;if(!e.project(r[0]+(s[0]-r[0])*m,r[1]+(s[1]-r[1])*m,r[2]+(s[2]-r[2])*m))continue;let g=(b+e.pz)/2,w=e.fogged(l[0],l[1],l[2],g);e.push(Me([xn(p,f,e.px,e.py)],w,o,c*(y+e.ps)/2,0,"butt"),g+u)}}};function Eh(n,t,e={}){return new kn(n,t,e)}var So=class extends kn{from3;to3;tipSize;constructor(t,e,o={}){super(t,()=>{let r=re(t),s=re(e),i=Math.hypot(s[0]-r[0],s[1]-r[1],s[2]-r[2])||1,a=Math.min(.9,.22/i);return[s[0]-(s[0]-r[0])*a,s[1]-(s[1]-r[1])*a,s[2]-(s[2]-r[2])*a]},{color:"yellow",width:4,...o}),this.from3=t,this.to3=e,this.tipSize=o.tip??24}emit(t){if(super.emit(t),this.get("trimTo")<.98)return;let o=re(this.from3),r=re(this.to3),s=this.objectAlpha(t);if(!t.project(o[0],o[1],o[2]))return;let i=t.px,a=t.py;if(!t.project(r[0],r[1],r[2]))return;let l=t.px,c=t.py,u=t.pz,h=t.ps,d=Math.hypot(l-i,c-a)||1,m=(l-i)/d,p=(c-a)/d,f=this.tipSize*t.scale*h,b=f*.42,y=se(this.get("stroke")),g=t.fogged(y[0],y[1],y[2],u),w=Eo([l,c,l-m*f-p*b,c-p*f+m*b,l-m*f+p*b,c-p*f-m*b]);t.push(ve([w],g,s,null,0,0),u+.01)}};function zh(n,t,e={}){return new So(n,t,e)}var Mn=class extends Et{constructor(e,o={}){super();this.source=e;this.style=o;this.base.fill=X(o.color??"yellow")}source;style;emit(e){let o=this.objectAlpha(e)*(this.style.opacity??1)*this.get("fillOpacity");if(o<=.002)return;let r=typeof this.source=="function"?this.source():this.source,s=(this.style.radius??8)*e.scale,i=this.get("trimTo"),a=Math.ceil(r.length*i),l=se(this.get("fill")),c=this.style.onTop?He:0;for(let u=0;u<a;u++){let h=r[u];if(!e.project(h[0],h[1],h[2]))continue;let d=this.style.colorAt?Ft(this.style.colorAt(u,h)):l,m=e.fogged(d[0],d[1],d[2],e.pz),p=s*e.ps;this.style.halo&&e.push(ve([ds(e.px,e.py,p*(1+this.style.halo))],m,o*.18,null,0,0),e.pz+c-.001),e.push(ve([ds(e.px,e.py,p)],m,o,null,0,0),e.pz+c)}}};function Vh(n,t={}){return new Mn(n,t)}function Lh(n,t={}){return new Mn(()=>[re(n)],t)}var Ro=class extends Et{constructor(e,o,r,s={}){super();this.point=e;this.from=o;this.to=r;this.style=s;this.base.stroke=X(s.color??"yellow"),this.base.strokeWidth=s.width??3}point;from;to;style;cache=new Map;sample(e,o){let r=this.cache.get(e);if(r)return r;let s=S.now;S.now=this.from+e/o;let i=this.point();return S.now=s,S.mode==="render"&&this.cache.set(e,i),i}emit(e,o){if(o<=this.from)return;let r=this.objectAlpha(e)*(this.style.opacity??1),s=this.style.rate??30,i=Math.min(o,this.to),a=this.style.tail,l=a!==void 0?Math.max(this.from,i-a):this.from,c=Math.ceil((l-this.from)*s),u=Math.floor((i-this.from)*s);if(u-c<1)return;let h=this.get("strokeWidth")*e.scale,d=se(this.get("stroke")),m=this.style.fade??(a!==void 0?0:1),p=this.style.onTop?He:this.style.bias??0,f=(this.style.glow??0)*e.scale,b=Math.max(1,Math.ceil((u-c)/48));for(let y=c;y<u;y+=b){let g=[],w=0,x=0;for(let A=y;A<=Math.min(u,y+b);A++){let O=this.sample(A,s);e.project(O[0],O[1],O[2])&&(g.push([e.px,e.py]),w+=e.pz,x+=e.ps)}if(g.length<2)continue;w/=g.length,x/=g.length;let k=(y+b/2-c)/(u-c),M=m+(1-m)*Math.pow(k,1.6),v=e.fogged(d[0],d[1],d[2],w);e.push(Me([ms(g)],v,r*M,h*x,f,"butt"),w+p)}}};function $h(n,t,e,o={}){return new Ro(n,t,e,o)}var To=class extends Et{constructor(e={}){super();this.options=e;this.ranges=[e.x??[-4,4],e.y??[-4,4],e.z??[-2.5,2.5]],this.step=e.step??1,this.base.stroke=X(e.color??"dim"),this.base.strokeWidth=e.width??2;let o=e.labelSize??34,r=e.labels===!1?null:Array.isArray(e.labels)?e.labels:["x","y","z"];if(this.tags=r?r.map(s=>st(s,{size:o,display:!1,color:"ink"})):[],e.numbers){let s=[[1,0,0],[0,1,0],[0,0,1]];this.ranges.forEach((i,a)=>{for(let l of Ht(i[0],i[1],this.step)){if(l===0)continue;let c=[s[a][0]*l,s[a][1]*l,s[a][2]*l];this.numberNodes.push({node:_(String(l),{size:18,color:"dim"}),at:c})}})}}options;ranges;step;tags;numberNodes=[];emit(e){let o=this.objectAlpha(e)*this.get("strokeOpacity");if(o<=.002)return;let r=this.get("trimTo"),s=se(this.get("stroke")),i=this.get("strokeWidth")*e.scale,a=[[1,0,0],[0,1,0],[0,0,1]],l=this.options.onTop?He:this.options.bias??.4;this.ranges.forEach((c,u)=>{let h=a[u],d=16,m=c[0],p=m+(c[1]-m)*r;for(let f=0;f<d;f++){let b=m+(p-m)*f/d,y=m+(p-m)*(f+1)/d;if(!e.project(h[0]*b,h[1]*b,h[2]*b))continue;let g=e.px,w=e.py,x=e.pz;if(!e.project(h[0]*y,h[1]*y,h[2]*y))continue;let k=(x+e.pz)/2;e.push(Me([xn(g,w,e.px,e.py)],e.fogged(s[0],s[1],s[2],k),o,i,0,"butt"),k+l)}if(this.options.ticks??!0)for(let f of Ht(c[0],p,this.step)){if(f===0||!e.project(h[0]*f,h[1]*f,h[2]*f))continue;let b=e.px,y=e.py,g=e.pz,w=5*e.ps*e.scale,x=xn(b-(u===2?w:0),y-(u===2?0:w),b+(u===2?w:0),y+(u===2?0:w));e.push(Me([x],e.fogged(s[0],s[1],s[2],g),o,i*.8,0,"butt"),g+l)}if(r>.98&&e.project(h[0]*c[1],h[1]*c[1],h[2]*c[1])){let f=e.px,b=e.py,y=e.pz,g=c[1]-.2;if(e.project(h[0]*g,h[1]*g,h[2]*g)){let w=Math.hypot(f-e.px,b-e.py)||1,x=(f-e.px)/w,k=(b-e.py)/w,M=14*e.scale,v=M*.42,A=Eo([f,b,f-x*M-k*v,b-k*M+x*v,f-x*M+k*v,b-k*M-x*v]);e.push(ve([A],e.fogged(s[0],s[1],s[2],y),o,null,0,0),y+l)}}})}labelsNow(e){let o=this.get("opacity")*this.get("strokeOpacity");if(o<=.002||this.get("trimTo")<.9)return[];let r=[],s=[[1,0,0],[0,1,0],[0,0,1]];this.tags.forEach((i,a)=>{let l=s[a],c=this.ranges[a][1]+.35,u=e.screen(l[0]*c,l[1]*c,l[2]*c);u&&(i.at(u),i.set("opacity",o),r.push(i))});for(let{node:i,at:a}of this.numberNodes){let l=e.screen(a[0],a[1],a[2]);l&&(i.at(l[0]+12,l[1]+14),i.set("opacity",o),r.push(i))}return r}};function Bh(n={}){return new To(n)}var Fo=class extends Et{constructor(e={}){super();this.options=e;this.base.stroke=X(e.color??"grid"),this.base.strokeWidth=e.width??1.2}options;emit(e){let o=this.objectAlpha(e)*(this.options.opacity??1)*this.get("strokeOpacity");if(o<=.002)return;let[r,s]=this.options.x??[-5,5],[i,a]=this.options.y??[-5,5],l=this.options.z??0,c=this.options.step??1,u=se(this.get("stroke")),h=this.get("strokeWidth")*e.scale,d=this.get("trimTo"),m=(p,f,b,y)=>{for(let w=0;w<10;w++){let x=w/10*d,k=(w+1)/10*d;if(!e.project(p+(b-p)*x,f+(y-f)*x,l))continue;let M=e.px,v=e.py,A=e.pz;if(!e.project(p+(b-p)*k,f+(y-f)*k,l))continue;let O=(A+e.pz)/2;e.push(Me([xn(M,v,e.px,e.py)],e.fogged(u[0],u[1],u[2],O),o,h,0,"butt"),O-.05)}};for(let p of Ht(r,s,c))m(p,i,p,a);for(let p of Ht(i,a,c))m(r,p,s,p)}};function Wh(n={}){return new Fo(n)}var Io=class extends Et{constructor(e,o,r={}){super();this.position=o;this.content=typeof e=="string"?r.math===!1?_(e,{size:r.size??28,color:r.color??"ink"}):st(e,{size:r.size??32,color:r.color??"ink",display:!1}):e,this.offset=r.offset??[0,0]}position;content;offset;emit(){}labelsNow(e){let o=this.get("opacity");if(o<=.002)return[];let r=re(this.position),s=e.screen(r[0],r[1],r[2]);return s?(this.content.at(s[0]+this.offset[0],s[1]+this.offset[1]),this.content.set("opacity",o*this.get("trimTo")),[this.content]):[]}};function Dh(n,t,e={}){return new Io(n,t,e)}var vn=class{film;canvas;ctx;options;raf=0;last=0;currentTime=0;playing=!1;scale=1;images=new Map;bloomLayers=[];observer=null;speed;constructor(t,e,o={}){this.canvas=t,this.film=e,this.options=o,this.speed=o.speed??1;let r=t.getContext("2d",{alpha:e.background===null});if(!r)throw new Error("This browser could not create a 2D canvas.");this.ctx=r,this.resize(),typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(()=>this.resize()),this.observer.observe(t)),this.paint(),o.autoplay&&this.play()}get time(){return this.currentTime}get isPlaying(){return this.playing}swap(t){let e=t.width!==this.film.width||t.height!==this.film.height;this.film=t,e&&(this.bloomLayers=[],this.resize()),this.paint()}resize(){let t=this.canvas.getBoundingClientRect(),e=this.options.pixelRatio??Math.min(2,globalThis.devicePixelRatio||1),o=t.width||this.film.width,r=Math.max(2,Math.round(o*e)),s=Math.max(2,Math.round(r*this.film.height/this.film.width));(this.canvas.width!==r||this.canvas.height!==s)&&(this.canvas.width=r,this.canvas.height=s,this.bloomLayers=[]),this.scale=r/this.film.width,this.playing||this.paint()}play(){this.playing||(this.currentTime>=this.film.duration-1e-6&&(this.currentTime=0),this.playing=!0,this.last=performance.now(),this.options.onState?.({playing:!0}),this.raf=requestAnimationFrame(this.tick))}pause(){this.playing&&(this.playing=!1,cancelAnimationFrame(this.raf),this.options.onState?.({playing:!1}))}toggle(){this.playing?this.pause():this.play()}seek(t){this.currentTime=Math.max(0,Math.min(this.film.duration,t)),this.paint(),this.options.onTime?.(this.currentTime)}next(){let t=this.film.chapters.find(e=>e.time>this.currentTime+.001);this.seek(t?t.time:this.film.duration)}previous(){let t=[...this.film.chapters].reverse().find(e=>e.time<this.currentTime-.25);this.seek(t?t.time:0)}destroy(){this.pause(),this.observer?.disconnect()}tick=t=>{if(!this.playing)return;let e=Math.max(0,Math.min(.1,(t-this.last)/1e3));this.last=t;let o=this.currentTime,r=o+e*this.speed;if(this.options.stepped){let s=this.film.chapters.find(i=>i.time>o+.001&&i.time<=r);if(s){this.currentTime=s.time,this.paint(),this.options.onTime?.(this.currentTime),this.pause();return}}if(r>=this.film.duration)if(this.options.loop)r%=this.film.duration;else{this.currentTime=this.film.duration,this.paint(),this.options.onTime?.(this.currentTime),this.pause();return}this.currentTime=r,this.paint(),this.options.onTime?.(this.currentTime),this.raf=requestAnimationFrame(this.tick)};lookupImage=t=>{let e=this.images.get(t.src);return e||(e=new Image,e.src=t.src,e.onload=()=>{this.playing||this.paint()},this.images.set(t.src,e)),e.complete&&e.naturalWidth>0?e:null};paint(){let t;try{t=this.film.frame(this.currentTime)}catch(e){if(e instanceof Nt){e.promise.then(()=>this.paint());return}throw e}Hn(this.ctx,t,this.scale,this.lookupImage),t.bloom>0&&t.dark&&this.applyBloom(t)}applyBloom(t){if(this.bloomLayers.length===0){let{width:a,height:l}=this.canvas;this.bloomLayers=[[4,.55],[8,.3],[16,.15]].map(([c,u])=>{let h=document.createElement("canvas");return h.width=Math.max(1,Math.round(a/c)),h.height=Math.max(1,Math.round(l/c)),{canvas:h,ctx:h.getContext("2d"),factor:c,weight:u}})}let{width:e}=this.canvas,o="filter"in this.ctx,r=[2.83,3.65,3.65],s=this.canvas;this.bloomLayers.forEach((a,l)=>{let{ctx:c,canvas:u}=a;c.setTransform(1,0,0,1,0,0),c.globalCompositeOperation="source-over",c.clearRect(0,0,u.width,u.height),c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="medium",o&&(c.filter=`blur(${(r[l]*e/1920).toFixed(2)}px)`),c.drawImage(s,0,0,u.width,u.height),o&&(c.filter="none"),l===0&&t.background&&(c.globalCompositeOperation="difference",c.fillStyle=t.background,c.fillRect(0,0,u.width,u.height),c.globalCompositeOperation="source-over"),s=u});let i=this.ctx;i.setTransform(1,0,0,1,0,0),i.globalCompositeOperation="screen",i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high";for(let a of this.bloomLayers)i.globalAlpha=Math.min(1,t.bloom*a.weight*2.4),i.drawImage(a.canvas,0,0,this.canvas.width,this.canvas.height);i.globalAlpha=1,i.globalCompositeOperation="source-over"}};function ps(n){let t=Math.floor(n/60),e=Math.floor(n%60);return`${t}:${String(e).padStart(2,"0")}`}var aa=`
1
+ import{a as Ps}from"./chunk-VZNL6JY2.js";import{b as Ns}from"./chunk-SQE76S5B.js";var zt=[1,0,0,1,0,0],Os={x:0,y:0,width:0,height:0},As=.5522847498307936,ae=10;function rt(n,t){return[n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],n[0]*t[4]+n[2]*t[5]+n[4],n[1]*t[4]+n[3]*t[5]+n[5]]}function Wt(n){let t=n[0]*n[3]-n[1]*n[2];if(Math.abs(t)<1e-12)return zt;let e=1/t;return[n[3]*e,-n[1]*e,-n[2]*e,n[0]*e,(n[2]*n[5]-n[3]*n[4])*e,(n[1]*n[4]-n[0]*n[5])*e]}function Q(n,t,e){return[n[0]*t+n[2]*e+n[4],n[1]*t+n[3]*e+n[5]]}function fe(n,t,e,r,o,s,i){let a=e===0?1:Math.cos(e),l=e===0?0:Math.sin(e),c=a*r,u=l*r,h=-l*o,d=a*o;return[c,u,h,d,n-c*s-h*i,t-u*s-d*i]}function Xt(n){return Math.sqrt(Math.abs(n[0]*n[3]-n[1]*n[2]))}function Mt(n,t=!1){return{p:n instanceof Float64Array?n:Float64Array.from(n),closed:t}}function $t(n){return Math.max(0,(n.p.length-2)/6)}function Ct(n,t,e,r,o){n.push(t+(r-t)/3,e+(o-e)/3,t+(r-t)*2/3,e+(o-e)*2/3,r,o)}function le(n,t){let e=[n[0],n[1]];return Ct(e,n[0],n[1],t[0],t[1]),[Mt(e)]}function Z(n,t=!1){if(n.length===0)return[];let e=n[0],r=[e[0],e[1]];for(let o=1;o<n.length;o++)Ct(r,n[o-1][0],n[o-1][1],n[o][0],n[o][1]);if(t){let o=n[n.length-1];(o[0]!==e[0]||o[1]!==e[1])&&Ct(r,o[0],o[1],e[0],e[1])}return[Mt(r,t)]}function Lt(n,t=!1,e=1/6){let r=n.length;if(r===0)return[];if(r<3)return Z(n,t);let o=a=>t?n[(a+r)%r]:n[Math.max(0,Math.min(r-1,a))],s=[n[0][0],n[0][1]],i=t?r:r-1;for(let a=0;a<i;a++){let l=o(a-1),c=o(a),u=o(a+1),h=o(a+2);s.push(c[0]+(u[0]-l[0])*e,c[1]+(u[1]-l[1])*e,u[0]-(h[0]-c[0])*e,u[1]-(h[1]-c[1])*e,u[0],u[1])}return[Mt(s,t)]}function St(n,t,e,r,o,s){let i=s-o;if(i===0)return[];let a=Math.abs(Math.abs(i)-Math.PI*2)<1e-9,l=Math.max(1,Math.ceil(Math.abs(i)/(Math.PI/4)-1e-9)),c=i/l,u=4/3*Math.tan(c/4),h=[n+Math.cos(o)*e,t+Math.sin(o)*r];for(let d=0;d<l;d++){let m=o+d*c,p=m+c,f=Math.cos(m),b=Math.sin(m),y=Math.cos(p),g=Math.sin(p);h.push(n+(f-u*b)*e,t+(b+u*f)*r,n+(y+u*g)*e,t+(g-u*y)*r,n+y*e,t+g*r)}return a&&(h[h.length-2]=h[0],h[h.length-1]=h[1]),[Mt(h,a)]}function Dt(n,t,e){return St(n,t,e,e,0,Math.PI*2)}function K(n,t,e,r,o=0){let s=Math.max(0,Math.min(o,Math.abs(e)/2,Math.abs(r)/2));if(s===0)return Z([[n,t],[n+e,t],[n+e,t+r],[n,t+r]],!0);let i=s*(1-As),a=n+e,l=t+r,c=[n+s,t];return Ct(c,n+s,t,a-s,t),c.push(a-i,t,a,t+i,a,t+s),Ct(c,a,t+s,a,l-s),c.push(a,l-i,a-i,l,a-s,l),Ct(c,a-s,l,n+s,l),c.push(n+i,l,n,l-i,n,l-s),Ct(c,n,l-s,n,t+s),c.push(n,t+i,n+i,t,n+s,t),[Mt(c,!0)]}function _e(n,t,e,r=64){let o=Math.max(2,Math.floor(r)),s=[];for(let i=0;i<=o;i++)s.push(n(t+(e-t)*i/o));return be(s)}function be(n){let t=[],e=[],r=()=>{e.length>=2&&t.push(...Lt(e)),e=[]};for(let o of n)Number.isFinite(o[0])&&Number.isFinite(o[1])?e.push(o):r();return r(),t}function ya(...n){return n.flat()}function ot(n,t){if(t===zt)return n;let e=new Array(n.length);for(let r=0;r<n.length;r++){let o=n[r].p,s=new Float64Array(o.length);for(let i=0;i<o.length;i+=2){let a=o[i],l=o[i+1];s[i]=t[0]*a+t[2]*l+t[4],s[i+1]=t[1]*a+t[3]*l+t[5]}e[r]={p:s,closed:n[r].closed}}return e}function Kr(n,t,e=4){return(e>1?n.map(o=>Cn(o,e)):n).map(o=>{let s=$t(o),i=[];for(let l=0;l<=s;l++){let c=t(o.p[l*6],o.p[l*6+1]);i.push(c)}let a=[i[0][0],i[0][1]];for(let l=0;l<s;l++){let c=t(o.p[l*6+2],o.p[l*6+3]),u=t(o.p[l*6+4],o.p[l*6+5]);a.push(c[0],c[1],u[0],u[1],i[l+1][0],i[l+1][1])}return Mt(a,o.closed)})}function On(n,t,e,r,o){let s=n[t],i=n[t+1],a=n[t+2],l=n[t+3],c=n[t+4],u=n[t+5],h=n[t+6],d=n[t+7],m=s+(a-s)*e,p=i+(l-i)*e,f=a+(c-a)*e,b=l+(u-l)*e,y=c+(h-c)*e,g=u+(d-u)*e,w=m+(f-m)*e,k=p+(b-p)*e,x=f+(y-f)*e,M=b+(g-b)*e,v=w+(x-w)*e,P=k+(M-k)*e;r.push(m,p,w,k,v,P),o.length=0,o.push(v,P,x,M,y,g,h,d)}function Cn(n,t){let e=$t(n);if(t<=1||e===0)return n;let r=[n.p[0],n.p[1]];for(let o=0;o<e;o++){let s=Array.from(n.p.subarray(o*6,o*6+8));for(let i=t;i>1;i--){let a=[];On(s,0,1/i,r,a),s=a}r.push(s[2],s[3],s[4],s[5],s[6],s[7])}return Mt(r,n.closed)}var Gr=new WeakMap;function Ke(n){let t=Gr.get(n);if(t)return t;let e=$t(n),r=new Float64Array(e),o=new Float64Array(e*ae),s=0,i=n.p;for(let l=0;l<e;l++){let c=l*6,u=i[c],h=i[c+1],d=i[c+2],m=i[c+3],p=i[c+4],f=i[c+5],b=i[c+6],y=i[c+7],g=u,w=h,k=0;for(let x=1;x<=ae;x++){let M=x/ae,v=1-M,P=v*v*v,O=3*v*v*M,A=3*v*M*M,R=M*M*M,$=P*u+O*d+A*p+R*b,z=P*h+O*m+A*f+R*y;k+=Math.hypot($-g,z-w),o[l*ae+x-1]=k,g=$,w=z}s+=k,r[l]=s}let a={total:r,lut:o,length:s};return Gr.set(n,a),a}function Te(n){return Ke(n).length}function Pt(n){let t=0;for(let e of n)t+=Ke(e).length;return t}function An(n,t){let e=n.total.length;if(e===0)return[0,0];if(t<=0)return[0,0];if(t>=n.length)return[e-1,1];let r=0,o=e-1;for(;r<o;){let d=r+o>>1;n.total[d]<t?r=d+1:o=d}let s=r===0?0:n.total[r-1],i=t-s,a=r*ae,l=0;for(;l<ae-1&&n.lut[a+l]<i;)l++;let c=l===0?0:n.lut[a+l-1],u=n.lut[a+l],h=u>c?(i-c)/(u-c):0;return[r,(l+h)/ae]}function jr(n,t,e){if($t(n)===0)return null;let o=Math.max(0,Math.min(1,t)),s=Math.max(0,Math.min(1,e));if(s<=o)return null;if(o===0&&s===1)return n;let i=Ke(n);if(i.length===0)return null;let[a,l]=An(i,o*i.length),[c,u]=An(i,s*i.length),h=[];for(let d=a;d<=c;d++){let m=Array.from(n.p.subarray(d*6,d*6+8)),p=d===a?l:0,f=d===c?u:1;if(p>0){let b=[];On(m,0,p,[],b),m=b}if(f<1){let b=[],y=[],g=p>0?(f-p)/(1-p):f;On(m,0,g,b,y),m=[m[0],m[1],...b]}h.length===0&&h.push(m[0],m[1]),h.push(m[2],m[3],m[4],m[5],m[6],m[7])}return Mt(h,!1)}function Jt(n,t,e,r=!1){if(t<=0&&e>=1)return n;let o=[];if(r){for(let a of n){let l=jr(a,t,e);l&&o.push(l)}return o}let s=Pt(n);if(s===0)return[];let i=0;for(let a of n){let l=Te(a),c=(t*s-i)/(l||1),u=(e*s-i)/(l||1);if(i+=l,u<=0||c>=1)continue;let h=jr(a,Math.max(0,c),Math.min(1,u));h&&o.push(h)}return o}function Nt(n,t){let e=Pt(n);if(e===0){let o=n[0]?.p;return o?[o[0],o[1]]:[0,0]}let r=Math.max(0,Math.min(1,t))*e;for(let o=0;o<n.length;o++){let s=n[o],i=Te(s);if(r<=i||o===n.length-1){let[a,l]=An(Ke(s),r);return Cs(s.p,a*6,l)}r-=i}return[0,0]}function ge(n,t){let r=Nt(n,Math.max(0,t-.002)),o=Nt(n,Math.min(1,t+.002)),s=Math.hypot(o[0]-r[0],o[1]-r[1])||1;return[(o[0]-r[0])/s,(o[1]-r[1])/s]}function Cs(n,t,e){let r=1-e,o=r*r*r,s=3*r*r*e,i=3*r*e*e,a=e*e*e;return[o*n[t]+s*n[t+2]+i*n[t+4]+a*n[t+6],o*n[t+1]+s*n[t+3]+i*n[t+5]+a*n[t+7]]}function Hr(n,t,e,r,o){if(n[0]=Math.min(n[0],t,o),n[1]=Math.max(n[1],t,o),e>=n[0]&&e<=n[1]&&r>=n[0]&&r<=n[1])return;let s=-t+3*e-3*r+o,i=2*(t-2*e+r),a=e-t,l=[];if(Math.abs(s)<1e-9)Math.abs(i)>1e-9&&l.push(-a/i);else{let c=i*i-4*s*a;if(c>=0){let u=Math.sqrt(c);l.push((-i+u)/(2*s),(-i-u)/(2*s))}}for(let c of l){if(c<=0||c>=1)continue;let u=1-c,h=u*u*u*t+3*u*u*c*e+3*u*c*c*r+c*c*c*o;n[0]=Math.min(n[0],h),n[1]=Math.max(n[1],h)}}var _r=new WeakMap;function Xr(n){let t=_r.get(n);if(t)return t;let e=n.p;if(e.length<2)return Os;let r=[e[0],e[0]],o=[e[1],e[1]];for(let i=0;i+7<e.length;i+=6)Hr(r,e[i],e[i+2],e[i+4],e[i+6]),Hr(o,e[i+1],e[i+3],e[i+5],e[i+7]);let s={x:r[0],y:o[0],width:r[1]-r[0],height:o[1]-o[0]};return _r.set(n,s),s}function bt(n){if(n.length===0)return null;let t=1/0,e=1/0,r=-1/0,o=-1/0;for(let s of n){if(s.p.length<2)continue;let i=Xr(s);t=Math.min(t,i.x),e=Math.min(e,i.y),r=Math.max(r,i.x+i.width),o=Math.max(o,i.y+i.height)}return t===1/0?null:{x:t,y:e,width:r-t,height:o-e}}function Xe(n,t){if(!n)return t;if(!t)return n;let e=Math.min(n.x,t.x),r=Math.min(n.y,t.y);return{x:e,y:r,width:Math.max(n.x+n.width,t.x+t.width)-e,height:Math.max(n.y+n.height,t.y+t.height)-r}}function ce(n){let t=n.p,e=0;for(let r=0;r+7<t.length;r+=6)e+=t[r]*t[r+7]-t[r+6]*t[r+1];return e/2}function ue(n){let t=Xr(n);return[t.x+t.width/2,t.y+t.height/2]}function Sn(n){let t=n.p,e=new Float64Array(t.length);for(let r=0;r<t.length;r+=2)e[r]=t[t.length-2-r],e[r+1]=t[t.length-1-r];return{p:e,closed:n.closed}}function vt(n){let t=n.match(/[a-zA-Z]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g);if(!t)return[];let e=[],r=[],o=0,s=0,i=0,a=0,l=0,c="",u=0,h=0,d=()=>Number(t[o++]),m=()=>{let y=t[o];return y.length>1&&(y[0]==="0"||y[0]==="1")&&!y.startsWith("0.")&&!y.startsWith("1.")?(t[o]=y.slice(1),Number(y[0])):(o++,Number(y))},p=y=>{r.length>=8&&e.push(Mt(r,y)),r=[]},f=(y,g)=>{r.length===0&&r.push(y,g)},b="";for(;o<t.length;){let y=t[o];if(/^[a-zA-Z]$/.test(y))b=y,o++;else if(b==="M")b="L";else if(b==="m")b="l";else if(b==="")throw new Error(`Invalid SVG path data: ${n.slice(0,40)}`);let g=b>="a";switch(b.toUpperCase()){case"M":{p(!1),s=(g?s:0)+d(),i=(g?i:0)+d(),a=s,l=i,r.push(s,i);break}case"L":{let w=(g?s:0)+d(),k=(g?i:0)+d();f(s,i),Ct(r,s,i,w,k),s=w,i=k;break}case"H":{let w=(g?s:0)+d();f(s,i),Ct(r,s,i,w,i),s=w;break}case"V":{let w=(g?i:0)+d();f(s,i),Ct(r,s,i,s,w),i=w;break}case"C":{let w=g?s:0,k=g?i:0,x=w+d(),M=k+d(),v=w+d(),P=k+d(),O=w+d(),A=k+d();f(s,i),r.push(x,M,v,P,O,A),u=v,h=P,s=O,i=A;break}case"S":{let w=g?s:0,k=g?i:0,x="CScs".includes(c),M=x?2*s-u:s,v=x?2*i-h:i,P=w+d(),O=k+d(),A=w+d(),R=k+d();f(s,i),r.push(M,v,P,O,A,R),u=P,h=O,s=A,i=R;break}case"Q":{let w=g?s:0,k=g?i:0,x=w+d(),M=k+d(),v=w+d(),P=k+d();f(s,i),r.push(s+(x-s)*2/3,i+(M-i)*2/3,v+(x-v)*2/3,P+(M-P)*2/3,v,P),u=x,h=M,s=v,i=P;break}case"T":{let w=g?s:0,k=g?i:0,x="QTqt".includes(c),M=x?2*s-u:s,v=x?2*i-h:i,P=w+d(),O=k+d();f(s,i),r.push(s+(M-s)*2/3,i+(v-i)*2/3,P+(M-P)*2/3,O+(v-O)*2/3,P,O),u=M,h=v,s=P,i=O;break}case"A":{let w=d(),k=d(),x=d(),M=m(),v=m(),P=(g?s:0)+d(),O=(g?i:0)+d();f(s,i),Ss(r,s,i,w,k,x,M===1,v===1,P,O),s=P,i=O;break}case"Z":{r.length>0&&((s!==a||i!==l)&&Ct(r,s,i,a,l),p(!0)),s=a,i=l;break}default:throw new Error(`Unsupported SVG path command: ${b}`)}c=b}return p(!1),e}function Ss(n,t,e,r,o,s,i,a,l,c){let u=Math.abs(r),h=Math.abs(o);if(u===0||h===0||t===l&&e===c){Ct(n,t,e,l,c);return}let d=s*Math.PI/180,m=Math.cos(d),p=Math.sin(d),f=(t-l)/2,b=(e-c)/2,y=m*f+p*b,g=-p*f+m*b,w=y*y/(u*u)+g*g/(h*h);if(w>1){let G=Math.sqrt(w);u*=G,h*=G}let k=u*u*h*h-u*u*g*g-h*h*y*y,x=u*u*g*g+h*h*y*y,M=(i===a?-1:1)*Math.sqrt(Math.max(0,k/x)),v=M*u*g/h,P=-M*h*y/u,O=m*v-p*P+(t+l)/2,A=p*v+m*P+(e+c)/2,R=Math.atan2((g-P)/h,(y-v)/u),$=Math.atan2((-g-P)/h,(-y-v)/u)-R;a&&$<0&&($+=Math.PI*2),!a&&$>0&&($-=Math.PI*2);let z=Math.max(1,Math.ceil(Math.abs($)/(Math.PI/2)-1e-9)),B=$/z,W=4/3*Math.tan(B/4);for(let G=0;G<z;G++){let U=R+G*B,C=U+B,L=Math.cos(U),I=Math.sin(U),F=Math.cos(C),E=Math.sin(C),T=(L-W*I)*u,V=(I+W*L)*h,j=(F+W*E)*u,J=(E-W*F)*h,at=F*u,tt=E*h;n.push(m*T-p*V+O,p*T+m*V+A,m*j-p*J+O,p*j+m*J+A,G===z-1?l:m*at-p*tt+O,G===z-1?c:p*at+m*tt+A)}}function Bt(n){let t=Math.round(n*100)/100;return t===0?"0":String(t)}function Yr(n){let t=[];for(let e of n){let r=e.p;if(!(r.length<2)){if(t.push("M",Bt(r[0])," ",Bt(r[1])),e.straight){for(let o=2;o+5<r.length;o+=6)t.push("L",Bt(r[o+4])," ",Bt(r[o+5]));e.closed&&t.push("Z");continue}for(let o=2;o+5<r.length;o+=6)t.push("C",Bt(r[o])," ",Bt(r[o+1])," ",Bt(r[o+2])," ",Bt(r[o+3])," ",Bt(r[o+4])," ",Bt(r[o+5]));e.closed&&t.push("Z")}}return t.join("")}var Tn=n=>n<=0?0:n>=1?1:n,Fe=n=>n;function Rn(n){return 1/(1+Math.exp(-n))}function Rs(n){let t=Rn(-n/2),e=Rn(n/2);return r=>r<=0?0:r>=1?1:(Rn(n*(r-.5))-t)/(e-t)}var dt=Rs(10),xa=n=>{let t=Tn(n);return t*t*t*(t*(t*6-15)+10)},ka=n=>n*n,Ma=n=>1-(1-n)*(1-n),va=n=>n*n*n,Na=n=>1-Math.pow(1-n,3),Pa=n=>n<.5?4*n*n*n:1-Math.pow(-2*n+2,3)/2,Oa=n=>1-Math.pow(1-n,5),Aa=n=>n<.5?16*n*n*n*n*n:1-Math.pow(-2*n+2,5)/2,Ca=n=>n>=1?1:1-Math.pow(2,-10*n),Sa=n=>n<=0?0:Math.pow(2,10*n-10),Ra=n=>2*dt(n/2),Ta=n=>2*dt(n/2+.5)-1,Fa=n=>Math.sqrt(Math.max(0,1-(1-n)*(1-n)));function Ia(n=1.70158){return t=>{let e=t-1;return e*e*((n+1)*e+n)+1}}function Ea(n={}){let t=n.bounce??.28,e=n.frequency??2.2,r=-Math.log(Math.max(1e-4,t))*2.4;return o=>o<=0?0:o>=1?1:1-Math.exp(-r*o)*Math.cos(e*Math.PI*2*o)*(1-o)}var za=n=>n<1/2.75?7.5625*n*n:n<2/2.75?7.5625*(n-=1.5/2.75)*n+.75:n<2.5/2.75?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375,Fn=n=>dt(n<.5?2*n:2*(1-n));function $a(n=1/3){let t=(1-n)/2;return e=>e<t?dt(e/t):e<1-t?1:dt((1-e)/t)}function qr(n=2){return t=>Fn(t)*Math.sin(n*Math.PI*2*t)}function La(n=.7,t=dt){return e=>n*t(e)}function Va(n=.25,t=dt){return e=>t(Tn(e/(1-n)))}function Ba(n=-.5){return t=>{let e=1-t;return 15*e**4*t**2*n+20*e**3*t**3*n+15*e**2*t**4+6*e*t**5+t**6}}function Wa(n,t,e=dt){return r=>e(Tn((r-n)/(t-n)))}function Da(n,t,e,r){let o=3*n,s=3*(e-n)-o,i=1-o-s,a=3*t,l=3*(r-t)-a,c=1-a-l,u=m=>((i*m+s)*m+o)*m,h=m=>((c*m+l)*m+a)*m,d=m=>(3*i*m+2*s)*m+o;return m=>{if(m<=0)return 0;if(m>=1)return 1;let p=m;for(let f=0;f<8;f++){let b=u(p)-m,y=d(p);if(Math.abs(b)<1e-5||Math.abs(y)<1e-6)break;p-=b/y}return h(p)}}var Ye={name:"midnight",dark:!0,background:"#0b0c10",bloom:.2,colors:{bg:"#0b0c10",surface:"#15171d",ink:"#f2efe6",dim:"#a5a7ad",faint:"#5c5f68",grid:"#23303d",gridStrong:"#3d5266",blue:"#5cc4f0",teal:"#4fd8c4",green:"#8fe08a",yellow:"#ffd75e",gold:"#f2b84b",orange:"#ff9d57",red:"#ff6b6b",pink:"#ff8fc0",purple:"#b49cff"}},Ts={name:"paper",dark:!1,background:"#f7f3ea",bloom:0,colors:{bg:"#f7f3ea",surface:"#efe9db",ink:"#1d1b16",dim:"#5e5a50",faint:"#a29c8d",grid:"#e2dbca",gridStrong:"#c4bba6",blue:"#1f6fb2",teal:"#0d8577",green:"#3f8a35",yellow:"#b98500",gold:"#a8740a",orange:"#cf5d12",red:"#c62f2f",pink:"#c2387e",purple:"#6a4bc4"}},Fs={name:"blueprint",dark:!0,background:"#0b2340",bloom:.16,colors:{bg:"#0b2340",surface:"#123054",ink:"#eaf6ff",dim:"#9cc0dc",faint:"#5d86a8",grid:"#1a3f66",gridStrong:"#2c5f8e",blue:"#7fd4ff",teal:"#6fe6d6",green:"#9de8a4",yellow:"#ffe27a",gold:"#f5c566",orange:"#ffb27a",red:"#ff8d8d",pink:"#ffa8cf",purple:"#c5b4ff"}},Is={name:"chalk",dark:!0,background:"#10201b",bloom:.1,colors:{bg:"#10201b",surface:"#172c25",ink:"#f4f1e4",dim:"#b1b9a9",faint:"#67786d",grid:"#20392f",gridStrong:"#355547",blue:"#8ccbe8",teal:"#7dd9c1",green:"#a9dc8f",yellow:"#f6dd7c",gold:"#e6bf62",orange:"#f2a874",red:"#ee8a80",pink:"#efa2c2",purple:"#bfa9e6"}},Es={name:"neon",dark:!0,background:"#050507",bloom:.4,colors:{bg:"#050507",surface:"#101016",ink:"#ffffff",dim:"#a9a9b8",faint:"#55555f",grid:"#1a1f2e",gridStrong:"#2f3a55",blue:"#3fb2ff",teal:"#21f0d0",green:"#6dff8e",yellow:"#fff04d",gold:"#ffc22e",orange:"#ff8a2e",red:"#ff4560",pink:"#ff5fb0",purple:"#a56bff"}},Ur={midnight:Ye,paper:Ts,blueprint:Fs,chalk:Is,neon:Es};function qe(n){if(n===void 0)return Ye;if(typeof n!="string")return n;let t=Ur[n];if(!t)throw new Error(`Unknown look: ${JSON.stringify(n)}. Use one of: ${Object.keys(Ur).join(", ")}.`);return t}var to=Ns(Ps(),1);var zs=[0,0,0,0],Zr=new Map,eo=Ye.colors;function zn(n){eo=n}function Gt(n){let e=eo[n]??n,r=Zr.get(e);if(r)return r;let o=(0,to.default)(e);if(!o)throw new Error(`Unknown color: ${JSON.stringify(n)}. Use a look token such as "blue" or a CSS color.`);let[s,i,a]=o.values;o.type==="hsl"&&([s,i,a]=$s(s,i,a));let l=[s,i,a,o.alpha];return Zr.set(e,l),l}function $s(n,t,e){let r=t/100*Math.min(e/100,1-e/100),o=s=>{let i=(s+n/30)%12;return 255*(e/100-r*Math.max(-1,Math.min(i-3,9-i,1)))};return[o(0),o(8),o(4)]}function X(n){return typeof n=="string"?Gt(n):n}function yt(n){return!Array.isArray(n)}function Yt(n,t=1){let e=n[3]*t,r=Math.round(n[0]),o=Math.round(n[1]),s=Math.round(n[2]);return e>=1?`rgb(${r},${o},${s})`:`rgba(${r},${o},${s},${Math.round(e*1e3)/1e3})`}function In(n){let t=n/255;return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function En(n){let t=n<=.0031308?12.92*n:1.055*Math.pow(n,.4166666666666667)-.055;return Math.max(0,Math.min(255,t*255))}function Jr(n){let t=In(n[0]),e=In(n[1]),r=In(n[2]),o=Math.cbrt(.4122214708*t+.5363325363*e+.0514459929*r),s=Math.cbrt(.2119034982*t+.6806995451*e+.1073969566*r),i=Math.cbrt(.0883024619*t+.2817188376*e+.6299787005*r);return[.2104542553*o+.793617785*s-.0040720468*i,1.9779984951*o-2.428592205*s+.4505937099*i,.0259040371*o+.7827717662*s-.808675766*i]}function Ls(n,t){let e=n[0]+.3963377774*n[1]+.2158037573*n[2],r=n[0]-.1055613458*n[1]-.0638541728*n[2],o=n[0]-.0894841775*n[1]-1.291485548*n[2],s=e*e*e,i=r*r*r,a=o*o*o;return[En(4.0767416621*s-3.3077115913*i+.2309699292*a),En(-1.2684380046*s+2.6097574011*i-.3413193965*a),En(-.0041960863*s-.7034186147*i+1.707614701*a),t]}function he(n,t,e){if(e<=0)return n;if(e>=1)return t;let r=Jr(n),o=Jr(t);return Ls([r[0]+(o[0]-r[0])*e,r[1]+(o[1]-r[1])*e,r[2]+(o[2]-r[2])*e],n[3]+(t[3]-n[3])*e)}function no(n,t,e){if(e<=0)return n;if(e>=1)return t;let r=yt(n),o=yt(t);if(!r&&!o)return he(n,t,e);if(r&&o&&n.type===t.type&&n.stops.length===t.stops.length){let a=n.stops.map((l,c)=>[l[0]+(t.stops[c][0]-l[0])*e,he(l[1],t.stops[c][1],e)]);return n.type==="linear"&&t.type==="linear"?{type:"linear",stops:a,from:[n.from[0]+(t.from[0]-n.from[0])*e,n.from[1]+(t.from[1]-n.from[1])*e],to:[n.to[0]+(t.to[0]-n.to[0])*e,n.to[1]+(t.to[1]-n.to[1])*e]}:n.type==="radial"&&t.type==="radial"?{type:"radial",stops:a,center:[n.center[0]+(t.center[0]-n.center[0])*e,n.center[1]+(t.center[1]-n.center[1])*e],radius:n.radius+(t.radius-n.radius)*e}:{type:"along",stops:a}}let s=r?lt(n.stops,.5):n,i=o?lt(t.stops,.5):t;return he(s,i,e)}function lt(n,t){if(n.length===0)return zs;if(t<=n[0][0])return n[0][1];for(let e=1;e<n.length;e++)if(t<=n[e][0]){let[r,o]=n[e-1],[s,i]=n[e];return he(o,i,s>r?(t-r)/(s-r):0)}return n[n.length-1][1]}function Ue(n){let t=n.length;return n.map((e,r)=>Array.isArray(e)&&e.length===2&&typeof e[0]=="number"?[e[0],Qr(e[1])]:[t===1?0:r/(t-1),Qr(e)])}function Qr(n){let t=X(n);return yt(t)?lt(t.stops,.5):t}function Vs(n,t,e){return{type:"linear",from:n,to:t,stops:Ue(e)}}function Bs(n,t,e){return{type:"radial",center:n,radius:t,stops:Ue(e)}}function Ws(...n){return{type:"along",stops:Ue(n)}}function Ie(n,...t){let e=Ue(t);return Array.from({length:n},(r,o)=>lt(e,n===1?0:o/(n-1)))}var S={now:0,mode:"free",frame:0,capture:null},ye=class{constructor(t){this.initial=t}initial;keys=[];sample(t){let e=this.keys,r=0,o=e.length-1,s=-1;for(;r<=o;){let c=r+o>>1;e[c].t0<=t?(s=c,r=c+1):o=c-1}if(s<0)return this.initial;let i=e[s];if(t>=i.t1||!i.at)return i.to;let a=i.t1-i.t0,l=a>0?(t-i.t0)/a:1;return i.at(i.ease?i.ease(l):l)}add(t){let e=this.keys,r=e.length;for(;r>0&&e[r-1].t0>t.t0;)r--;e.splice(r,0,t)}step(t,e){this.add({t0:t,t1:t,ease:null,to:e,at:null})}get end(){let t=0;for(let e of this.keys)e.t1>t&&(t=e.t1);return t}};function ro(n,t){let e=$t(n);if(e>=t||e===0)return n;let r=[];for(let s=0;s<e;s++){let i=s*6,a=Array.from(n.p.subarray(i,i+8));r.push({pts:a,length:$n(a)})}for(;r.length<t;){let s=0;for(let l=1;l<r.length;l++)r[l].length>r[s].length&&(s=l);let[i,a]=Ds(r[s].pts);r.splice(s,1,{pts:i,length:$n(i)},{pts:a,length:$n(a)})}let o=new Float64Array(2+t*6);o[0]=n.p[0],o[1]=n.p[1];for(let s=0;s<t;s++){let i=r[s].pts;for(let a=0;a<6;a++)o[2+s*6+a]=i[2+a]}return{p:o,closed:n.closed}}function $n(n){return Math.hypot(n[2]-n[0],n[3]-n[1])+Math.hypot(n[4]-n[2],n[5]-n[3])+Math.hypot(n[6]-n[4],n[7]-n[5])}function Ds(n){let t=(n[0]+n[2])/2,e=(n[1]+n[3])/2,r=(n[2]+n[4])/2,o=(n[3]+n[5])/2,s=(n[4]+n[6])/2,i=(n[5]+n[7])/2,a=(t+r)/2,l=(e+o)/2,c=(r+s)/2,u=(o+i)/2,h=(a+c)/2,d=(l+u)/2;return[[n[0],n[1],t,e,a,l,h,d],[h,d,c,u,s,i,n[6],n[7]]]}function Gs(n,t){let e=$t(t);if(!n.closed||!t.closed||e<2)return t;let[r,o]=ue(n),[s,i]=ue(t),a=Math.max(1,Math.floor(e/48)),l=0,c=1/0;for(let h=0;h<e;h+=a){let d=0;for(let m=0;m<e;m+=a){let p=(m+h)%e,f=n.p[m*6]-r-(t.p[p*6]-s),b=n.p[m*6+1]-o-(t.p[p*6+1]-i);d+=f*f+b*b}d<c&&(c=d,l=h)}if(l===0)return t;let u=new Float64Array(t.p.length);u[0]=t.p[l*6],u[1]=t.p[l*6+1];for(let h=0;h<e;h++){let d=(h+l)%e;for(let m=0;m<6;m++)u[2+h*6+m]=t.p[2+d*6+m]}return{p:u,closed:t.closed}}function oo(n,t,e,r){let o=new Float64Array(2+e*6);for(let s=0;s<o.length;s+=2)o[s]=n,o[s+1]=t;return{p:o,closed:r}}function js(n,t){let e=a=>[...a].sort((l,c)=>Math.abs(ce(c))+Te(c)*.01-(Math.abs(ce(l))+Te(l)*.01)),r=e(n),o=e(t),s=[],i=o.slice();for(let a of r){if(i.length===0){let[d,m]=ue(a);s.push([a,oo(d,m,$t(a),a.closed)]);continue}let[l,c]=ue(a),u=0,h=1/0;for(let d=0;d<Math.min(i.length,3);d++){let[m,p]=ue(i[d]),f=Math.hypot(l-m,c-p)+d*40;f<h&&(h=f,u=d)}s.push([a,i[u]]),i.splice(u,1)}for(let a of i){let[l,c]=ue(a);s.push([oo(l,c,$t(a),a.closed),a])}return s}function Hs(n,t,e=12){let r=js(n,t),o=[],s=[],i=[];for(let[a,l]of r){let c=Math.max($t(a),$t(l),a.closed&&l.closed?e:1),u=ro(a,c),h=ro(l,c);if(u.closed&&h.closed)Math.sign(ce(u))!==Math.sign(ce(h))&&ce(u)!==0&&ce(h)!==0&&(h=Sn(h)),h=Gs(u,h);else if(!u.closed&&!h.closed){let d=u.p.length,m=Math.hypot(u.p[0]-h.p[0],u.p[1]-h.p[1])+Math.hypot(u.p[d-2]-h.p[d-2],u.p[d-1]-h.p[d-1]);Math.hypot(u.p[0]-h.p[d-2],u.p[1]-h.p[d-1])+Math.hypot(u.p[d-2]-h.p[0],u.p[d-1]-h.p[1])<m&&(h=Sn(h))}o.push(u.p),s.push(h.p),i.push(u.closed&&h.closed)}return{from:o,to:s,closed:i}}function Ze(n,t){if(n===t)return()=>t;if(Pt(n)===0&&n.length===0)return r=>r>=1?t:n;let e=Hs(n,t);return r=>{if(r<=0)return n;if(r>=1)return t;let o=new Array(e.from.length);for(let s=0;s<o.length;s++){let i=e.from[s],a=e.to[s],l=new Float64Array(i.length);for(let c=0;c<i.length;c++)l[c]=i[c]+(a[c]-i[c])*r;o[s]={p:l,closed:e.closed[s]}}return o}}function Je(n,t){let e=n.length,r=t.length,o=Array.from({length:e+1},()=>new Uint16Array(r+1));for(let l=e-1;l>=0;l--)for(let c=r-1;c>=0;c--)o[l][c]=n[l]===t[c]?o[l+1][c+1]+1:Math.max(o[l+1][c],o[l][c+1]);let s=[],i=0,a=0;for(;i<e&&a<r;)n[i]===t[a]?s.push([i++,a++]):o[i+1][a]>=o[i][a+1]?i++:a++;return s}var Ln={x:0,y:0,rotation:0,sx:1,sy:1,px:0,py:0,opacity:1,visible:!0,z:0,path:null,fill:null,fillOpacity:1,stroke:null,strokeOpacity:1,strokeWidth:3,cap:"round",join:"round",dash:null,dashOffset:0,trimFrom:0,trimTo:1,trimEach:!1,glow:0,glowColor:null,blend:"normal",fixed:!1,image:null},_s=new Set(["x","y","rotation","sx","sy","px","py","opacity","z","fillOpacity","strokeOpacity","strokeWidth","dashOffset","trimFrom","trimTo","glow"]);function Ks(n,t,e){if(_s.has(n)){let r=t,o=e;return(s=>r+(o-r)*s)}if(n==="fill"||n==="stroke"){let r=t,o=e;return r&&o?(s=>no(r,o,s)):null}if(n==="glowColor"){let r=t,o=e;return r&&o?(s=>he(r,o,s)):null}if(n==="path"){let r=t,o=e;return r&&o?Ze(r,o):null}return null}var so=1,N=class n{id=so++;parent=null;children=[];data={};label="";base=Object.create(Ln);tracks=null;overlay=null;overlayFrame=-1;mounted=!1;draw=null;rawOps=null;constructor(t){t&&(this.base.path=t)}get(t){let e=this.overlay;if(e!==null&&e.has(t)&&(this.overlayFrame===S.frame||S.capture!==null))return e.get(t);let r=this.tracks?.get(t);return r?r.sample(S.now):this.base[t]}set(t,e){return S.capture?(this.overlay??=new Map,this.overlay.set(t,e),S.capture.add(this),this):this.mounted?S.mode==="render"?(this.overlay??=new Map,this.overlayFrame!==S.frame&&(this.overlay.clear(),this.overlayFrame=S.frame),this.overlay.set(t,e),this):(this.track(t).step(S.now,e),this):(this.base[t]=e,this)}track(t){this.tracks??=new Map;let e=this.tracks.get(t);return e||(e=new ye(this.base[t]),this.tracks.set(t,e)),e}tween(t,e,r,o,s){let i=S.now;S.now=r;let a=this.get(t);S.now=i;let l=o>r?Ks(t,a,e):null,c={t0:r,t1:o,ease:s,to:e,at:l};this.track(t).add(c)}add(...t){for(let e of t)e.parent!==this&&(e.parent?.drop(e),e.parent=this,this.children.push(e),this.mounted&&tn(e,S.now));return this}drop(t){let e=this.children.indexOf(t);return e>=0&&this.children.splice(e,1),t.parent=null,this}all(){let t=[],e=r=>{t.push(r);for(let o of r.children)e(o)};return e(this),t}leaves(){return this.all().filter(t=>t.get("path")!==null||t.draw!==null||t.get("image")!==null)}clone(){let t=Object.create(Object.getPrototypeOf(this));Object.assign(t,this),t.id=so++,t.parent=null,t.mounted=!1,t.tracks=null,t.overlay=null,t.overlayFrame=-1,t.data={...this.data},t.base=Object.create(Ln);for(let e of Object.keys(Ln))t.base[e]=this.get(e);return t.children=this.children.map(e=>{let r=e.clone();return r.parent=t,r}),t}localMatrix(){return fe(this.get("x"),this.get("y"),this.get("rotation"),this.get("sx"),this.get("sy"),this.get("px"),this.get("py"))}worldMatrix(){let t=this.localMatrix();for(let e=this.parent;e;e=e.parent)t=rt(e.localMatrix(),t);return t}toWorld(t,e){return Q(this.worldMatrix(),t,e)}bounds(){return this.boundsFrom(this.parent?this.parent.worldMatrix():zt)??{x:0,y:0,width:0,height:0}}boundsFrom(t){let e=rt(t,this.localMatrix()),r=null,o=this.get("path");o&&(r=bt(ot(o,e)));let s=this.get("image");if(s&&(r=Xe(r,Xs(e,s.width,s.height))),this.draw){let i=this.draw(S.now),a=i===null?[]:Array.isArray(i)?i:[i];for(let l of a)r=Xe(r,l.boundsFrom(e))}for(let i of this.children)i.get("visible")&&(r=Xe(r,i.boundsFrom(e)));return r}get center(){let t=this.bounds();return[t.x+t.width/2,t.y+t.height/2]}get top(){let t=this.bounds();return[t.x+t.width/2,t.y]}get bottom(){let t=this.bounds();return[t.x+t.width/2,t.y+t.height]}get left(){let t=this.bounds();return[t.x,t.y+t.height/2]}get right(){let t=this.bounds();return[t.x+t.width,t.y+t.height/2]}get width(){return this.bounds().width}get height(){return this.bounds().height}at(t,e){let[r,o]=typeof t=="number"?[t,e??0]:t;return this.set("x",r),this.set("y",o),this}shift(t,e){let[r,o]=typeof t=="number"?[t,e??0]:t;return this.set("x",this.get("x")+r),this.set("y",this.get("y")+o),this}moveTo(t){let e=t instanceof n?t.center:t,[r,o]=this.center,s=this.parent?Wt(this.parent.worldMatrix()):zt,[i,a]=Q(s,r,o),[l,c]=Q(s,e[0],e[1]);return this.shift(l-i,c-a)}pivotAt(t){let e=this.parent?this.parent.worldMatrix():zt,r=rt(e,this.localMatrix()),[o,s]=Q(Wt(r),t[0],t[1]),[i,a]=Q(Wt(e),t[0],t[1]);return this.set("px",o),this.set("py",s),this.set("x",i),this.set("y",a),this}scale(t,e){let[r,o]=typeof t=="number"?[t,t]:t;return this.pivotAt(e??this.center),this.set("sx",this.get("sx")*r),this.set("sy",this.get("sy")*o),this}rotate(t,e){return this.pivotAt(e??this.center),this.set("rotation",this.get("rotation")+t),this}fitTo(t){let e=this.bounds(),r=[];return t.width!==void 0&&e.width>0&&r.push(t.width/e.width),t.height!==void 0&&e.height>0&&r.push(t.height/e.height),r.length?this.scale(Math.min(...r)):this}nextTo(t,e="right",r=28){let[o,s]=Qe(e),i=t instanceof n?t.bounds():{x:t[0],y:t[1],width:0,height:0},a=this.bounds(),l=i.x+i.width/2,c=i.y+i.height/2,u=l+o*(i.width/2+r+a.width/2),h=c+s*(i.height/2+r+a.height/2);return this.moveTo([u,h])}alignTo(t,e){let r=this.bounds(),o=t instanceof n?t.bounds():{x:t[0],y:t[1],width:0,height:0};return e==="left"?this.shift(o.x-r.x,0):e==="right"?this.shift(o.x+o.width-r.x-r.width,0):e==="top"?this.shift(0,o.y-r.y):this.shift(0,o.y+o.height-r.y-r.height)}arrange(t="right",e=24){let[r,o]=Qe(t),s=this.center,i=null;for(let a of this.children){if(i){let l=i.bounds(),c=a.bounds(),u=l.x+l.width/2+r*(l.width/2+e+c.width/2),h=l.y+l.height/2+o*(l.height/2+e+c.height/2);a.moveTo([r===0?l.x+l.width/2:u,o===0?l.y+l.height/2:h])}i=a}return this.moveTo(s)}fill(t,e){return this.set("fill",t===null?null:X(t)),e!==void 0&&this.set("fillOpacity",e),this}stroke(t,e,r){return this.set("stroke",t===null?null:X(t)),e!==void 0&&this.set("strokeWidth",e),r!==void 0&&this.set("strokeOpacity",r),this}color(t){let e=X(t);for(let r of this.all())r.get("stroke")&&r.set("stroke",e),r.get("fill")&&r.set("fill",e),r.get("glowColor")&&!yt(e)&&r.set("glowColor",e);return this}opacity(t){return this.set("opacity",t)}glow(t,e){if(this.set("glow",t),e!==void 0){let r=X(e);this.set("glowColor",yt(r)?null:r)}return this}dash(t,e=0){return this.set("dash",t),this.set("dashOffset",e)}zIndex(t){return this.set("z",t)}pin(){return this.set("fixed",!0)}hide(){return this.set("visible",!1)}show(){return this.set("visible",!0)}named(t){return this.label=t,this}};function Xs(n,t,e){let r=[Q(n,0,0),Q(n,t,0),Q(n,t,e),Q(n,0,e)],o=r.map(l=>l[0]),s=r.map(l=>l[1]),i=Math.min(...o),a=Math.min(...s);return{x:i,y:a,width:Math.max(...o)-i,height:Math.max(...s)-a}}function Qe(n){return typeof n!="string"?n:n==="left"?[-1,0]:n==="right"?[1,0]:n==="top"||n==="up"?[0,-1]:[0,1]}function tn(n,t){let e=n.base.visible;for(let r of n.all())r.mounted=!0;if(t>0||!e){let r=n.track("visible");r.initial=!1,e&&r.step(t,!0)}}function Vn(...n){return new N().add(...n)}function Ot(n){let t=new N;return t.draw=n,t}function Rt(n){return Array.isArray(n)?[...n]:[n]}function rn(n,t,e,r){S.now=t,n.schedule({t0:t,t1:e,ease:n.ease??r.ease,stage:r.stage})}function Bn(...n){let t=Math.max(0,...n.map(e=>e.duration));return{label:"par",duration:t,schedule(e){let r=t>0?(e.t1-e.t0)/t:1;for(let o of n)rn(o,e.t0,e.t0+o.duration*r,e)}}}function io(...n){let t=n.reduce((e,r)=>e+r.duration,0);return{label:"seq",duration:t,schedule(e){let r=t>0?(e.t1-e.t0)/t:1,o=e.t0;for(let s of n){let i=o+s.duration*r;rn(s,o,i,e),o=i}}}}function il(n,t={}){let e=t.lag??.15,r=Math.max(0,...n.map(s=>s.duration)),o=n.length===0?0:r*(1+(n.length-1)*e);return{label:"lagged",duration:t.duration??o,schedule(s){let i=s.t1-s.t0,a=n.length===0?0:i/(1+(n.length-1)*e);n.forEach((l,c)=>{let u=s.t0+c*e*a;rn(l,u,u+a,s)})}}}function al(n,t){return{label:n.label,duration:n.duration+t,ease:n.ease,schedule(e){let r=n.duration+t>0?(e.t1-e.t0)/(n.duration+t):1;rn(n,e.t0+t*r,e.t1,e)}}}function Ys(n,t){return{...n,duration:t.duration??n.duration,ease:t.ease??n.ease}}function ll(n){return{label:"call",duration:0,schedule:()=>n()}}function te(n,t,e){if(!n.mounted){let r=n;for(;r.parent&&r.parent!==e.root;)r=r.parent;e.mountAt(r,t)}for(let r=n;r&&r!==e.root;r=r.parent){let o=S.now;S.now=t;let s=r.get("visible");S.now=o,s||r.track("visible").step(t,!0)}}function jt(n,t){n.track("visible").step(t,!1)}function ao(n,t,e){e<=t||(n.track("visible").step(t,!1),n.track("visible").step(e,!0))}var et=(n,t,e,r)=>{n.track(t).step(r,e)};function qs(n,t,e){let r=S.now;S.now=e;let o=n.get(t);return S.now=r,o}function Us(n){return yt(n)?lt(n.stops,.5):n}function Qt(n){return Rt(n).flatMap(t=>t.leaves().filter(e=>e.get("path")))}function Zs(n,t,e,r,o){let s=e-t,i=n.get("fill"),a=n.get("stroke"),l=n.get("fillOpacity"),c=n.get("strokeOpacity");if(i&&!a){let u=qs(n,"strokeWidth",t);et(n,"stroke",Us(i),t),et(n,"strokeWidth",o,t),et(n,"strokeOpacity",1,t),et(n,"trimTo",0,t),et(n,"fillOpacity",0,t),n.tween("trimTo",1,t,t+s*.72,r),n.tween("fillOpacity",l,t+s*.42,e,r),n.tween("strokeOpacity",0,t+s*.62,e,r),et(n,"stroke",null,e),et(n,"strokeWidth",u,e),et(n,"strokeOpacity",c,e);return}et(n,"trimTo",0,t),n.tween("trimTo",1,t,i?t+s*.8:e,r),i&&(et(n,"fillOpacity",0,t),n.tween("fillOpacity",l,t+s*.5,e,r))}function lo(n,t,e,r){let o=Rt(t),s=Qt(o).length,i=e.lag??r.lag,a=e.duration??(s<=1?r.duration:Math.min(r.duration*2.4,r.duration+s*.035));return{label:n,duration:a,ease:e.ease,schedule(l){for(let d of o)te(d,l.t0,l.stage);let c=Qt(o);if(c.length===0)return;let h=(l.t1-l.t0)/(1+(c.length-1)*i);c.forEach((d,m)=>{let p=l.t0+m*i*h;S.now=p,ao(d,l.t0,p),Zs(d,p,p+h,l.ease,r.outline)}),S.now=l.t0}}}function cl(n,t={}){return lo("draw",n,t,{lag:.04,duration:1.3,outline:2})}function ul(n,t={}){return lo("write",n,t,{lag:.22,duration:1.1,outline:1.3})}function hl(n,t={}){let e=Rt(n);return{label:"erase",duration:t.duration??.8,ease:t.ease,schedule(r){let o=Qt(e),s=t.lag??.02,i=(r.t1-r.t0)/(1+Math.max(0,o.length-1)*s);o.forEach((a,l)=>{let c=r.t0+l*s*i;S.now=c;let u=a.get("fill");a.get("stroke")&&a.tween("trimFrom",1,c,c+i,r.ease),u&&a.tween("fillOpacity",0,c,c+i*.7,r.ease)});for(let a of e)jt(a,r.t1)}}}function dl(n,t={}){let e=Rt(n);return{label:"fadeIn",duration:t.duration??.8,ease:t.ease,schedule(r){let o=t.lag!==void 0&&e.length===1&&e[0].children.length>0?e[0].children:e;for(let a of e)te(a,r.t0,r.stage);let s=t.lag??0,i=(r.t1-r.t0)/(1+Math.max(0,o.length-1)*s);o.forEach((a,l)=>{let c=r.t0+l*s*i,u=c+i;S.now=c,ao(a,r.t0,c);let h=a.get("opacity");if(et(a,"opacity",0,c),a.tween("opacity",h,c,u,r.ease),t.shift){let d=a.get("x"),m=a.get("y");et(a,"x",d+t.shift[0],c),et(a,"y",m+t.shift[1],c),a.tween("x",d,c,u,r.ease),a.tween("y",m,c,u,r.ease)}t.scale!==void 0&&co(a,t.scale,c,u,r.ease)}),S.now=r.t0}}}function co(n,t,e,r,o,s){let i=S.now;S.now=e,n.pivotAt(s??n.center);let a=n.get("sx"),l=n.get("sy");et(n,"sx",a*t,e),et(n,"sy",l*t,e),n.tween("sx",a,e,r,o),n.tween("sy",l,e,r,o),S.now=i}function ml(n,t={}){let e=Rt(n);return{label:"fadeOut",duration:t.duration??.6,ease:t.ease,schedule(r){for(let o of e){let s=o.get("opacity");o.tween("opacity",0,r.t0,r.t1,r.ease),t.shift&&(o.tween("x",o.get("x")+t.shift[0],r.t0,r.t1,r.ease),o.tween("y",o.get("y")+t.shift[1],r.t0,r.t1,r.ease)),t.scale!==void 0&&(o.pivotAt(o.center),o.tween("sx",o.get("sx")*t.scale,r.t0,r.t1,r.ease),o.tween("sy",o.get("sy")*t.scale,r.t0,r.t1,r.ease)),jt(o,r.t1),et(o,"opacity",s,r.t1)}}}}function pl(n,t={}){let e=Rt(n);return{label:"grow",duration:t.duration??.9,ease:t.ease,schedule(r){for(let o of e)te(o,r.t0,r.stage),co(o,.001,r.t0,r.t1,r.ease,t.from)}}}function fl(n){let t=Rt(n);return{label:"appear",duration:0,schedule:e=>{for(let r of t)te(r,e.t0,e.stage)}}}function bl(n){let t=Rt(n);return{label:"vanish",duration:0,schedule:e=>{for(let r of t)jt(r,e.t0)}}}function de(n,t,e={}){return{label:"to",duration:e.duration??1,ease:e.ease,schedule(r){te(n,r.t0,r.stage);let o=new Set;S.capture=o;try{t(n)}finally{S.capture=null}for(let s of o){let i=s,a=new Map(i.overlay);i.overlay.clear(),Js(i,a,r,e.restore===!0)}}}}function Js(n,t,e,r){let{t0:o,t1:s,ease:i}=e,a=t,l=new Map,c=a.get("px"),u=a.get("py");if(c!==void 0||u!==void 0){let h=c??n.get("px"),d=u??n.get("py"),m=fe(n.get("x"),n.get("y"),n.get("rotation"),n.get("sx"),n.get("sy"),n.get("px"),n.get("py")),[p,f]=Q(m,h,d);et(n,"px",h,o),et(n,"py",d,o),et(n,"x",p,o),et(n,"y",f,o),a.delete("px"),a.delete("py")}S.now=o;for(let[h,d]of a){let m=n.get(h);m!==d&&(r&&l.set(h,m),n.tween(h,d,o,s,i))}for(let[h,d]of l)et(n,h,d,s)}function gl(n,t,e={}){return{...de(n,r=>r.moveTo(t),e),label:"moveTo"}}function yl(n,t,e,r={}){return{...de(n,o=>o.shift(t,e),r),label:"shift"}}function wl(n,t,e={}){return{...de(n,r=>r.scale(t,e.about),e),label:"scale"}}function xl(n,t,e={}){return{...de(n,r=>r.rotate(t,e.about),e),label:"rotate"}}function uo(n,t,e={}){return{...de(n,r=>r.color(t),e),label:"recolor"}}function ho(n,t,e={}){return{...de(n,r=>r.opacity(t),{duration:.6,...e}),label:"fade"}}function kl(n,t,e={}){return{label:"along",duration:e.duration??2,ease:e.ease,schedule(r){te(n,r.t0,r.stage);let o=t instanceof N?ot(t.get("path")??[],t.worldMatrix()):t,s=n.parent?mo(n.parent.worldMatrix()):null,i=c=>{let[u,h]=Nt(o,c);return s?Q(s,u,h):[u,h]},[a,l]=i(1);if(n.track("x").add({t0:r.t0,t1:r.t1,ease:r.ease,to:a,at:c=>i(c)[0]}),n.track("y").add({t0:r.t0,t1:r.t1,ease:r.ease,to:l,at:c=>i(c)[1]}),e.orient){let c=u=>{let[h,d]=ge(o,u);return Math.atan2(d,h)};n.track("rotation").add({t0:r.t0,t1:r.t1,ease:r.ease,to:c(1),at:c})}}}}function mo(n){let t=n[0]*n[3]-n[1]*n[2];if(Math.abs(t)<1e-12)return[1,0,0,1,0,0];let e=1/t;return[n[3]*e,-n[1]*e,-n[2]*e,n[0]*e,(n[2]*n[5]-n[3]*n[4])*e,(n[1]*n[4]-n[0]*n[5])*e]}function Wn(n,t,e={}){let r=Rt(n);return{label:"warp",duration:e.duration??2,ease:e.ease,schedule(o){for(let s of Qt(r)){te(s,o.t0,o.stage);let i=s.get("path"),a=s.worldMatrix(),l=mo(a),c=i.map(h=>Cn(h,e.subdivisions??6)),u=Kr(c,(h,d)=>{let[m,p]=Q(a,h,d),[f,b]=t(m,p);return Q(l,f,b)},1);s.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:u,at:h=>c.map((d,m)=>{let p=d.p,f=u[m].p,b=new Float64Array(p.length);for(let y=0;y<p.length;y++)b[y]=p[y]+(f[y]-p[y])*h;return{p:b,closed:d.closed}})})}}}}function Ml(n,t,e={}){let[r,o]=e.origin??[0,0],s=e.yUp===!1?1:-1,[[i,a],[l,c]]=t;return{...Wn(n,(u,h)=>{let d=u-r,m=(h-o)*s,p=i*d+a*m,f=l*d+c*m;return[r+p,o+f*s]},{subdivisions:1,...e}),label:"applyMatrix"}}function Qs(n){let t=1;for(let e=n;e;e=e.parent)t*=e.get("opacity");return t}function nn(n){let t=n.worldMatrix(),e=Qs(n),r=0,o=!1;for(let s=n;s;s=s.parent)r+=s.get("z"),o||=s.get("fixed");return{path:ot(n.get("path")??[],t),fill:n.get("fill"),fillOpacity:n.get("fill")?n.get("fillOpacity")*e:0,stroke:n.get("stroke"),strokeOpacity:n.get("stroke")?n.get("strokeOpacity")*e:0,strokeWidth:n.get("strokeWidth")*Xt(t),glow:n.get("glow"),glowColor:n.get("glowColor"),cap:n.get("cap"),dash:n.get("dash"),z:r,fixed:o,key:n.data.key}}function en(n,t,e,r){let o=new N;return o.base.visible=!1,o.base.path=t.path,o.base.cap=t.cap,o.base.z=t.z,o.base.fixed=t.fixed,o.base.fill=t.fill??e.fill,o.base.stroke=t.stroke??e.stroke,o.base.fillOpacity=t.fillOpacity,o.base.strokeOpacity=t.strokeOpacity,o.base.strokeWidth=t.strokeWidth||e.strokeWidth,o.base.glow=t.glow,o.base.glowColor=t.glowColor??e.glowColor,n.root.add(o),o.track("visible").initial=!1,o.track("visible").keys.length=0,et(o,"visible",!0,r.appear??r.t0),o.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:e.path,at:Ze(t.path,e.path)}),t.fill&&e.fill&&o.tween("fill",e.fill,r.t0,r.t1,r.ease),t.stroke&&e.stroke&&o.tween("stroke",e.stroke,r.t0,r.t1,r.ease),o.tween("fillOpacity",e.fillOpacity,r.t0,r.t1,r.ease),o.tween("strokeOpacity",e.strokeOpacity,r.t0,r.t1,r.ease),o.tween("strokeWidth",e.strokeWidth||t.strokeWidth,r.t0,r.t1,r.ease),t.glow!==e.glow&&o.tween("glow",e.glow,r.t0,r.t1,r.ease),et(o,"visible",!1,r.hide??r.t1),o}function ti(n,t){let e=Math.max(n.length,t.length),r=[];for(let o=0;o<e;o++)r.push([n[Math.min(n.length-1,Math.floor(o*n.length/e))],t[Math.min(t.length-1,Math.floor(o*t.length/e))]]);return r}function vl(n,t,e={}){let r=Rt(n),o=Rt(t);return{label:"morph",duration:e.duration??1.2,ease:e.ease,schedule(s){po(o,s);let i=Qt(r).map(nn),a=Qt(o).map(nn);if(i.length===0||a.length===0){for(let h of r)jt(h,s.t0);for(let h of o)te(h,s.t0,s.stage);return}let l=ti(i,a),c=e.lag??0,u=(s.t1-s.t0)/(1+Math.max(0,l.length-1)*c);l.forEach(([h,d],m)=>{let p=s.t0+m*c*u;en(s.stage,h,d,{t0:p,t1:p+u,ease:s.ease,appear:s.t0,hide:s.t1})}),fo(r,o,s)}}}function po(n,t){S.now=t.t0;for(let e of n)t.stage.mountAt(e,t.t0),jt(e,t.t0)}function fo(n,t,e){for(let r of n)jt(r,e.t0);for(let r of t)r.track("visible").step(e.t1,!0);S.now=e.t0}function we(n,t,e={}){return{label:"morphMatching",duration:e.duration??1.4,ease:e.ease,schedule(r){po([t],r);let o=e.key??(f=>f.data.key),s=Qt(n),i=Qt(t),a=s.map(nn),l=i.map(nn),c=Je(s.map(o),i.map(o)),u=new Set(c.map(([f])=>f)),h=new Set(c.map(([,f])=>f));for(let[f,b]of c)en(r.stage,a[f],l[b],r);let d=r.t1-r.t0,m=e.fadeShift??[0,0],p=(f,b,y)=>ot(f,[1,0,0,1,b,y]);a.forEach((f,b)=>{u.has(b)||en(r.stage,f,{...f,path:p(f.path,m[0],m[1]),fillOpacity:0,strokeOpacity:0},{t0:r.t0,t1:r.t0+d*.55,ease:r.ease})}),l.forEach((f,b)=>{h.has(b)||en(r.stage,{...f,path:p(f.path,-m[0],-m[1]),fillOpacity:0,strokeOpacity:0},f,{t0:r.t0+d*.35,t1:r.t1,ease:r.ease})}),fo([n],[t],r)}}}function Nl(n,t={}){let r=Rt(n).map(o=>Ys(de(o,s=>{s.scale(t.scale??1.14),s.color(t.color??"yellow")},{restore:!0}),{ease:t.ease??Fn}));return{...Bn(...r),label:"indicate",duration:t.duration??.9}}function Pl(n,t={}){return{label:"shake",duration:t.duration??.8,ease:qr(t.cycles??3),schedule(e){S.now=e.t0;let[r,o]=n.center;n.pivotAt([r,o]);let s=n.get("rotation"),i=t.angle??.08;n.track("rotation").add({t0:e.t0,t1:e.t1,ease:e.ease,to:s,at:l=>s+i*l})}}}function Ol(n,t={}){return{label:"circumscribe",duration:t.duration??1.3,ease:t.ease??Fe,schedule(e){let r=n.bounds(),o=t.pad??14,s=new N(K(r.x-o,r.y-o,r.width+o*2,r.height+o*2,t.radius??12)).stroke(t.color??"yellow",t.width??3).glow(8);e.stage.add(s);let i=e.t0,a=e.t1,l=i+(a-i)*.55;et(s,"trimTo",0,i),s.tween("trimTo",1,i,l,dt),s.tween("trimFrom",1,l-(a-i)*.08,a,dt),jt(s,a)}}}function Al(n,t={}){return{label:"flash",duration:t.duration??.7,ease:t.ease??dt,schedule(e){let r=n instanceof N?n.center:n,o=t.radius??54,s=t.rays??12;for(let i=0;i<s;i++){let a=i/s*Math.PI*2,l=Math.cos(a),c=Math.sin(a),u=new N(le([r[0]+l*o*.35,r[1]+c*o*.35],[r[0]+l*o,r[1]+c*o])).stroke(t.color??"yellow",2.5).glow(5);e.stage.add(u),et(u,"trimTo",0,e.t0),u.tween("trimTo",1,e.t0,e.t0+(e.t1-e.t0)*.6,e.ease),u.tween("trimFrom",1,e.t0+(e.t1-e.t0)*.25,e.t1,e.ease),jt(u,e.t1)}}}}function Cl(n,t={}){return{label:"ripple",duration:t.duration??1,ease:t.ease??dt,schedule(e){let r=n instanceof N?n.center:n,o=new N(Dt(0,0,t.radius??90)).stroke(t.color??"blue",t.width??3).at(r);e.stage.add(o),et(o,"sx",.05,e.t0),et(o,"sy",.05,e.t0),o.tween("sx",1,e.t0,e.t1,e.ease),o.tween("sy",1,e.t0,e.t1,e.ease),o.tween("strokeOpacity",0,e.t0+(e.t1-e.t0)*.2,e.t1,e.ease),jt(o,e.t1)}}}function Dn(n,t={}){return{label:"pulse",duration:t.duration??1.1,ease:t.ease??dt,schedule(e){let r=n.get("path");if(!r)return;let o=new N(ot(r,n.worldMatrix())).stroke(t.color??"yellow",t.width??n.get("strokeWidth")+1.5).glow(t.glow??10);e.stage.add(o);let s=t.length??.18;et(o,"trimFrom",0,e.t0),et(o,"trimTo",0,e.t0),o.track("trimTo").add({t0:e.t0,t1:e.t1,ease:e.ease,to:1,at:i=>Math.min(1,i*(1+s))}),o.track("trimFrom").add({t0:e.t0,t1:e.t1,ease:e.ease,to:1,at:i=>Math.max(0,i*(1+s)-s)}),jt(o,e.t1)}}}var pt=class{track;constructor(t){this.track=new ye(t)}get value(){return this.track.sample(S.now)}set(t){return this.track.step(S.now,t),this}to(t,e={}){let r=this.track;return{label:"value",duration:e.duration??1,ease:e.ease,schedule(o){let s=r.sample(o.t0);r.add({t0:o.t0,t1:o.t1,ease:o.ease,to:t,at:i=>s+(t-s)*i})}}}};var ei=()=>S.now,ni=14,ri=96;function bo(n,t){return!n||!yt(n)?n:n.type==="linear"?{...n,from:Q(t,n.from[0],n.from[1]),to:Q(t,n.to[0],n.to[1])}:n.type==="radial"?{...n,center:Q(t,n.center[0],n.center[1]),radius:n.radius*Xt(t)}:n}function oi(n,t){return n[0]===t[0]&&n[1]===t[1]&&n[2]===t[2]&&n[3]===t[3]&&n[4]===t[4]&&n[5]===t[5]}var go=new WeakMap;function si(n,t,e){let r=go.get(n);if(r&&r.path===t&&oi(r.matrix,e))return r.world;let o=ot(t,e);return go.set(n,{path:t,matrix:e,world:o}),o}function ii(n,t,e,r,o){let s=n.get("fill"),i=n.get("stroke"),a=s?r*n.get("fillOpacity"):0,l=i?r*n.get("strokeOpacity"):0,c=n.get("glow");if(a<=.002&&l<=.002&&c<=0)return;let u=si(n,t,e),h=Xt(e),d=n.get("trimFrom"),m=n.get("trimTo"),p=u;if((d>0||m<1)&&(p=Jt(u,d,m,n.get("trimEach"))),p.length===0&&a<=.002)return;let f=n.get("dash"),b={kind:"path",path:u,strokePath:p,fill:a>.002?bo(s,e):null,fillAlpha:a,stroke:l>.002?bo(i,e):null,strokeAlpha:l,strokeWidth:n.get("strokeWidth")*h,cap:n.get("cap"),join:n.get("join"),dash:f?f.map(y=>y*h):null,dashOffset:n.get("dashOffset")*h,glow:c*h,glowColor:n.get("glowColor"),blend:n.get("blend"),node:n};b.stroke&&yt(b.stroke)&&b.stroke.type==="along"?ai(b,b.stroke,o):o.push(b)}function ai(n,t,e){e.push({...n,stroke:null,strokeAlpha:0});let r={...n,fill:null,fillAlpha:0,glow:0},o=Pt(n.strokePath),s=Pt(n.path);if(o===0)return;let i=s>0?Math.min(1,o/s):1,a=Math.min(ri,Math.max(2,Math.ceil(o/ni))),l=.6/a;for(let c=0;c<a;c++){let u=c/a,h=Math.min(1,(c+1)/a+l),d=Jt(n.strokePath,u,h);d.length!==0&&e.push({...r,strokePath:d,path:d,stroke:lt(t.stops,(c+.5)/a*i),cap:c===0||c===a-1?n.cap:"butt"})}}function jn(n,t,e,r,o){if(!n.get("visible"))return;let s=n.get("opacity")*r;if(s<=.002)return;let i=n.get("fixed")?e:t,a=rt(i,n.localMatrix()),l=n.get("path");l&&l.length>0&&ii(n,l,a,s,o);let c=n.get("image");if(c&&o.push({kind:"image",image:c,matrix:a,alpha:s}),n.rawOps&&n.rawOps(a,s,o),n.draw){let m=n.draw(ei());if(m){let p=Array.isArray(m)?m:[m];for(let f of p)jn(f,a,e,s,o)}}let u=n.children;if(u.length===0)return;let h=!1;for(let m=0;m<u.length;m++)if(u[m].get("z")!==0){h=!0;break}let d=h?u.map((m,p)=>({child:m,index:p,z:m.get("z")})).sort((m,p)=>m.z-p.z||m.index-p.index).map(m=>m.child):u;for(let m of d)jn(m,a,e,s,o)}function Hn(n,t,e,r){let o=[1,0,0,1,e/2,r/2],s=rt(o,fe(0,0,-t.rotation,t.zoom,t.zoom,t.x,t.y)),i=[];return jn(n,s,o,1,i),i}var yo=7;function vo(n,t){let e=[];for(let r=yo;r>=1;r--){let o=r/yo;e.push({width:t+n*2*o,alpha:.16*(1-o)*(1-o)+.018})}return e}function No(n){if(n.glowColor)return n.glowColor;let t=n.stroke??n.fill;return t?yt(t)?lt(t.stops,.5):t:null}var wo=new WeakMap;function on(n){let t=wo.get(n);return t===void 0&&(t=Yr(n),wo.set(n,t)),t}function ft(n){return String(Math.round(n*1e3)/1e3)}function li(n,t){let e=t.stops.map(([r,o])=>`<stop offset="${ft(r)}" stop-color="${Yt([o[0],o[1],o[2],1])}"${o[3]<1?` stop-opacity="${ft(o[3])}"`:""}/>`).join("");return t.type==="linear"?`<linearGradient id="${n}" gradientUnits="userSpaceOnUse" x1="${ft(t.from[0])}" y1="${ft(t.from[1])}" x2="${ft(t.to[0])}" y2="${ft(t.to[1])}">${e}</linearGradient>`:t.type==="radial"?`<radialGradient id="${n}" gradientUnits="userSpaceOnUse" cx="${ft(t.center[0])}" cy="${ft(t.center[1])}" r="${ft(t.radius)}">${e}</radialGradient>`:""}function xo(n){let t=` stroke-linecap="${n.cap}" stroke-linejoin="${n.join}"`;return n.dash&&(t+=` stroke-dasharray="${n.dash.map(ft).join(" ")}" stroke-dashoffset="${ft(n.dashOffset)}"`),t}function ci(n){return n.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function _n(n,t={}){let e=t.scale??1,r=n.width,o=n.height,s=[],i=[],a=0,l=(u,h,d)=>{if(yt(u)){let f=`g${a++}`;return s.push(li(f,u)),`${h}="url(#${f})"${d<1?` ${h}-opacity="${ft(d)}"`:""}`}let m=u,p=m[3]*d;return`${h}="${Yt([m[0],m[1],m[2],1])}"${p<1?` ${h}-opacity="${ft(p)}"`:""}`};n.background&&!t.transparent&&i.push(`<rect width="${r}" height="${o}" fill="${n.background}"/>`);for(let u of n.ops){if(u.kind==="image"){let d=u.matrix;i.push(`<image href="${ci(u.image.src)}" width="${u.image.width}" height="${u.image.height}" transform="matrix(${d.map(ft).join(" ")})"${u.alpha<1?` opacity="${ft(u.alpha)}"`:""} preserveAspectRatio="none"/>`);continue}let h=u.blend!=="normal"?` style="mix-blend-mode:${u.blend}"`:"";if(u.glow>0){let d=No(u),m=on(u.strokePath.length?u.strokePath:u.path);if(d&&m){let p=Math.max(u.fillAlpha,u.strokeAlpha),f=n.dark?' style="mix-blend-mode:screen"':"",b=vo(u.glow,u.stroke?u.strokeWidth:0).map(y=>`<path d="${m}" fill="none" stroke="${Yt([d[0],d[1],d[2],1])}" stroke-opacity="${ft(y.alpha*p)}" stroke-width="${ft(y.width)}" stroke-linecap="round" stroke-linejoin="round"/>`).join("");i.push(`<g${f}>${b}</g>`)}}if(u.fill&&u.stroke&&u.strokePath===u.path){i.push(`<path d="${on(u.path)}" ${l(u.fill,"fill",u.fillAlpha)} ${l(u.stroke,"stroke",u.strokeAlpha)} stroke-width="${ft(u.strokeWidth)}"${xo(u)}${h}/>`);continue}u.fill&&i.push(`<path d="${on(u.path)}" ${l(u.fill,"fill",u.fillAlpha)}${h}/>`),u.stroke&&u.strokePath.length&&i.push(`<path d="${on(u.strokePath)}" fill="none" ${l(u.stroke,"stroke",u.strokeAlpha)} stroke-width="${ft(u.strokeWidth)}"${xo(u)}${h}/>`)}let c=s.length?`<defs>${s.join("")}</defs>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${r*e}" height="${o*e}" viewBox="0 0 ${r} ${o}">${c}${i.join("")}</svg>`}var ko=new WeakMap;function Gn(n){let t=ko.get(n);if(t)return t;t=new Path2D;for(let e of n){let r=e.p;if(!(r.length<2)){if(t.moveTo(r[0],r[1]),e.straight)for(let o=2;o+5<r.length;o+=6)t.lineTo(r[o+4],r[o+5]);else for(let o=2;o+5<r.length;o+=6)t.bezierCurveTo(r[o],r[o+1],r[o+2],r[o+3],r[o+4],r[o+5]);e.closed&&t.closePath()}}return ko.set(n,t),t}function Mo(n,t){if(!yt(t))return Yt(t);let e=t.type==="linear"?n.createLinearGradient(t.from[0],t.from[1],t.to[0],t.to[1]):t.type==="radial"?n.createRadialGradient(t.center[0],t.center[1],0,t.center[0],t.center[1],t.radius):null;if(!e)return Yt(lt(t.stops,.5));for(let[r,o]of t.stops)e.addColorStop(r,Yt(o));return e}var ui={normal:"source-over",screen:"screen",multiply:"multiply",overlay:"overlay"};function Kn(n,t,e=1,r){n.setTransform(1,0,0,1,0,0),n.globalAlpha=1,n.globalCompositeOperation="source-over",n.clearRect(0,0,t.width*e,t.height*e),n.setTransform(e,0,0,e,0,0),t.background&&(n.fillStyle=t.background,n.fillRect(0,0,t.width,t.height));for(let o of t.ops){if(o.kind==="image"){let s=r?.(o.image);if(!s)continue;let i=o.matrix;n.save(),n.transform(i[0],i[1],i[2],i[3],i[4],i[5]),n.globalAlpha=o.alpha,n.drawImage(s,0,0,o.image.width,o.image.height),n.restore();continue}if(n.globalCompositeOperation=ui[o.blend],o.glow>0){let s=No(o);if(s){let i=Math.max(o.fillAlpha,o.strokeAlpha),a=n.globalCompositeOperation;t.dark&&(n.globalCompositeOperation="screen"),n.strokeStyle=Yt([s[0],s[1],s[2],1]),n.lineCap="round",n.lineJoin="round",n.setLineDash([]);let l=Gn(o.strokePath.length?o.strokePath:o.path);for(let c of vo(o.glow,o.stroke?o.strokeWidth:0))n.globalAlpha=c.alpha*i,n.lineWidth=c.width,n.stroke(l);n.globalCompositeOperation=a}}o.fill&&(n.globalAlpha=o.fillAlpha,n.fillStyle=Mo(n,o.fill),n.fill(Gn(o.path))),o.stroke&&o.strokePath.length&&(n.globalAlpha=o.strokeAlpha,n.strokeStyle=Mo(n,o.stroke),n.lineWidth=o.strokeWidth,n.lineCap=o.cap,n.lineJoin=o.join,n.setLineDash(o.dash?[...o.dash]:[]),n.lineDashOffset=o.dashOffset,n.stroke(Gn(o.strokePath)))}n.globalAlpha=1,n.globalCompositeOperation="source-over"}function hi(n){let t=null;for(let e of n.ops){if(e.kind!=="path")continue;let r=bt(e.path);if(!r)continue;let o=e.stroke?e.strokeWidth/2:0,s={x:r.x-o,y:r.y-o,width:r.width+o*2,height:r.height+o*2};if(!t)t=s;else{let i=Math.min(t.x,s.x),a=Math.min(t.y,s.y);t={x:i,y:a,width:Math.max(t.x+t.width,s.x+s.width)-i,height:Math.max(t.y+t.height,s.y+s.height)-a}}}return t}var di={"16:9":[1920,1080],"9:16":[1080,1920],"1:1":[1080,1080],"4:3":[1440,1080],"21:9":[2520,1080]},sn=class{root=new N;camera=new N;width;height;fps;look;chapters=[];clips=[];captions=[];updaters=[];time=0;ending=0;constructor(t){let[e,r]=di[t.aspect??"16:9"];this.width=t.width??e,this.height=t.height??r,this.fps=t.fps??60,this.look=qe(t.look),this.root.mounted=!0,this.camera.mounted=!0}get right(){return this.width/2}get left(){return-this.width/2}get top(){return-this.height/2}get bottom(){return this.height/2}add(t,...e){S.now=this.time;for(let r of[t,...e])r.mounted?r.get("visible")||r.track("visible").step(this.time,!0):(r.parent?.drop(r),r.parent=this.root,this.root.children.push(r),tn(r,this.time));return t}mountAt(t,e){t.mounted||(t.parent?.drop(t),t.parent=this.root,this.root.children.push(t),tn(t,e))}remove(...t){for(let e of t)e.track("visible").step(this.time,!1)}play(...t){let e=t.filter(l=>"schedule"in l),r=t.find(l=>!("schedule"in l))??{};if(e.length===0)return this;let o=Math.max(...e.map(l=>l.duration)),s=r.duration??o,i=this.time,a=i+s;for(let l of e){S.now=i;let c=r.duration!==void 0?a:i+l.duration;l.schedule({t0:i,t1:c,ease:r.ease??l.ease??dt,stage:this})}return this.clips.push({t0:i,t1:a,labels:r.label?[r.label]:e.map(l=>l.label)}),this.time=a,this.ending=Math.max(this.ending,a),S.now=a,this}wait(t=1){return this.time+=t,this.ending=Math.max(this.ending,this.time),S.now=this.time,this}at(t,e){let r=this.time;return this.time=t,S.now=t,e(),this.ending=Math.max(this.ending,this.time),this.time=r,S.now=r,this}chapter(t){return this.chapters.push({title:t,time:this.time}),this}caption(t,e=3){return this.captions.push({t0:this.time,t1:this.time+e,text:t}),this.ending=Math.max(this.ending,this.time+e),this}value(t=0){return new pt(t)}update(t,e,r={}){return this.updaters.push({node:t,fn:e,from:r.from??this.time,to:r.to??1/0}),t}get duration(){return Math.max(this.ending,this.time)}};function mi(n,t){let e=typeof n=="function"?{}:n,r=typeof n=="function"?n:t;if(!r)throw new Error("film(options, build) needs a build function.");let o={kind:"vizmatic.film",options:e,build:r,compile:s=>ln(o,s)};return o}function Ee(n){return!!n&&typeof n=="object"&&n.kind==="vizmatic.film"}var At=class{constructor(t){this.promise=t}promise;isVizmaticSuspend=!0};function Xn(n){return typeof n=="object"&&n!==null&&n.isVizmaticSuspend===!0}var an=class{width;height;fps;duration;title;description;look;bloom;background;posterTime;bleed;chapters;clips;captions;stage;constructor(t,e,r){this.stage=t,this.width=t.width,this.height=t.height,this.fps=r.fps??t.fps,this.duration=Math.max(t.duration,1/this.fps),this.title=e.title??"",this.description=e.description??"",this.look=t.look,this.bloom=r.bloom??e.bloom??t.look.bloom;let o=r.background!==void 0?r.background:e.background!==void 0?e.background:t.look.background;this.background=o===null?null:t.look.colors[o]??o,this.posterTime=e.poster,this.bleed=e.bleed===!0,this.chapters=t.chapters,this.clips=t.clips,this.captions=t.captions}get frameCount(){return Math.max(1,Math.round(this.duration*this.fps))}frame(t){let e=Math.max(0,Math.min(this.duration,t)),r=this.stage,o={mode:S.mode,now:S.now};zn(r.look.colors),S.mode="render",S.now=e,S.frame++;try{for(let a of r.updaters)e>=a.from&&e<=a.to&&a.fn(a.node,e);let s=r.camera,i=Hn(r.root,{x:s.get("x"),y:s.get("y"),zoom:s.get("sx"),rotation:s.get("rotation")},r.width,r.height);return{width:r.width,height:r.height,background:this.background,bloom:this.bloom,dark:r.look.dark,ops:i}}finally{S.mode=o.mode,S.now=o.now}}svg(t,e={}){return _n(this.frame(t),e)}};async function ln(n,t={}){let e={...n.options,...t.look?{look:t.look}:{},...t.fps?{fps:t.fps}:{}};for(let r=0;r<64;r++){let o=new sn(e);zn(o.look.colors);let s={mode:S.mode,now:S.now};S.mode="compile",S.now=0;try{await n.build(o),S.mode=s.mode,S.now=s.now;let i=new an(o,e,t);return await pi(i),i}catch(i){if(S.mode=s.mode,S.now=s.now,S.capture=null,i instanceof At){await i.promise;continue}throw i}}throw new Error("The film kept requesting new assets while compiling.")}async function pi(n){let t=[0,.25,.5,.75,1];for(let e of t)for(let r=0;r<16;r++)try{n.frame(n.duration*e);break}catch(o){if(!(o instanceof At))throw o;await o.promise}}function Po(n){return{contours:n.filter(t=>t.length>=8)}}var Oo=null;function Yn(n){Oo=n}var fi=typeof process<"u"&&!!process.versions?.node&&typeof globalThis.document>"u";function Ao(){let n=import.meta.url;return n||`file://${typeof __filename<"u"?__filename:""}`}async function bi(n){let t="node:fs/promises",e="node:path",r="node:url",[o,s,i]=await Promise.all([import(t),import(e),import(r)]),a=s.dirname(i.fileURLToPath(Ao()));for(let l=0;l<6;l++){let c=s.join(a,"assets",n);try{let u=await o.readFile(c);return u.buffer.slice(u.byteOffset,u.byteOffset+u.byteLength)}catch(u){if(u.code!=="ENOENT")throw u}a=s.dirname(a)}throw new Error(`Bundled asset not found: assets/${n}`)}async function Co(n){if(fi)return bi(n);let t=Oo??new URL("./assets/",Ao()).href,e=await fetch(new URL(n,t)),r=e.headers.get("content-type")??"";if(!e.ok||r.includes("text/html"))throw new Error(`Could not load ${n} from ${e.url} (HTTP ${e.status}, ${r||"no content type"}). Call setAssetBase() with the folder that holds fonts/.`);return e.arrayBuffer()}var Un=class{constructor(t,e=0){this.bytes=t;this.offset=e;this.view=new DataView(t)}bytes;offset;view;seek(t){return this.offset=t,this}get position(){return this.offset}u8(){return this.view.getUint8(this.offset++)}i8(){return this.view.getInt8(this.offset++)}u16(){let t=this.view.getUint16(this.offset);return this.offset+=2,t}i16(){let t=this.view.getInt16(this.offset);return this.offset+=2,t}u32(){let t=this.view.getUint32(this.offset);return this.offset+=4,t}tag(){let t="";for(let e=0;e<4;e++)t+=String.fromCharCode(this.u8());return t}};function Eo(n){let t=new Un(n),e=t.u32();if(e!==65536&&e!==1953658213)throw new Error("Stage text needs a TrueType (.ttf) font with glyf outlines.");let r=t.u16();t.seek(12);let o=new Map;for(let P=0;P<r;P++){let O=t.tag();t.u32(),o.set(O,{offset:t.u32(),length:t.u32()})}let s=P=>{let O=o.get(P);if(!O)throw new Error(`Font is missing its ${P} table.`);return O},i=s("head");t.seek(i.offset+18);let a=t.u16();t.seek(i.offset+50);let l=t.i16()===1,c=s("hhea");t.seek(c.offset+4);let u=t.i16(),h=t.i16(),d=t.i16();t.seek(c.offset+34);let m=t.u16();t.seek(s("maxp").offset+4);let p=t.u16(),f=s("hmtx"),b=s("loca"),y=s("glyf"),g=yi(t,s("cmap").offset),w=o.has("GPOS")?wi(t,o.get("GPOS").offset):()=>0,k=P=>{let O=Math.min(P,m-1);return t.seek(f.offset+O*4),t.u16()},x=new Map,M=(P,O)=>{if(P>=p||O>6)return[];t.seek(b.offset+(l?P*4:P*2));let A=l?t.u32():t.u16()*2,R=l?t.u32():t.u16()*2;if(A===R)return[];t.seek(y.offset+A);let $=t.i16();if(t.seek(t.position+8),$<0)return v(P,O);let z=[];for(let T=0;T<$;T++)z.push(t.u16());let B=t.u16();t.seek(t.position+B);let W=(z[z.length-1]??-1)+1,G=[];for(;G.length<W;){let T=t.u8();if(G.push(T),T&8){let V=t.u8();for(;V-- >0;)G.push(T)}}let U=new Array(W),C=0;for(let T=0;T<W;T++){let V=G[T];if(V&2){let j=t.u8();C+=V&16?j:-j}else V&16||(C+=t.i16());U[T]=C}let L=new Array(W),I=0;for(let T=0;T<W;T++){let V=G[T];if(V&4){let j=t.u8();I+=V&32?j:-j}else V&32||(I+=t.i16());L[T]=I}let F=[],E=0;for(let T of z)F.push(gi(U,L,G,E,T)),E=T+1;return F};function v(P,O){let A=[],R=!0;for(;R;){let z=t.u16(),B=t.u16(),W=(z&1)!==0,G=(z&2)!==0,U=0,C=0;W?(U=t.i16(),C=t.i16()):(U=t.i8(),C=t.i8()),G||(U=0,C=0);let L=1,I=0,F=0,E=1,T=()=>t.i16()/16384;z&8?L=E=T():z&64?(L=T(),E=T()):z&128&&(L=T(),I=T(),F=T(),E=T()),A.push({glyph:B,m:[L,I,F,E,U,C]}),R=(z&32)!==0}let $=[];for(let z of A)for(let B of M(z.glyph,O+1)){let W=new Array(B.length),[G,U,C,L,I,F]=z.m;for(let E=0;E<B.length;E+=2)W[E]=G*B[E]+C*B[E+1]+I,W[E+1]=U*B[E]+L*B[E+1]+F;$.push(W)}return $}return{unitsPerEm:a,ascent:u,descent:h,lineGap:d,glyphFor(P){return g(P)},advance:k,kern(P,O){return w(P,O)},outline(P){if(x.has(P))return x.get(P);let O=M(P,0),A=O.length?Po(O):null;return x.set(P,A),A}}}function gi(n,t,e,r,o){let s=o-r+1;if(s<2)return[];let i=w=>r+(w%s+s)%s,a=w=>(e[i(w)]&1)!==0,l=0;for(;l<s&&!a(l);)l++;let c,u;l===s?(c=(n[i(0)]+n[i(s-1)])/2,u=(t[i(0)]+t[i(s-1)])/2,l=0):(c=n[i(l)],u=t[i(l)],l+=1);let h=[c,u],d=c,m=u,p=0,f=0,b=!1,y=(w,k,x,M)=>{h.push(d+(w-d)*2/3,m+(k-m)*2/3,x+(w-x)*2/3,M+(k-M)*2/3,x,M),d=x,m=M},g=(w,k)=>{h.push(d+(w-d)/3,m+(k-m)/3,d+(w-d)*2/3,m+(k-m)*2/3,w,k),d=w,m=k};for(let w=0;w<s;w++){let k=l+w,x=n[i(k)],M=t[i(k)];a(k)?b?(y(p,f,x,M),b=!1):(x!==d||M!==m)&&g(x,M):(b&&y(p,f,(p+x)/2,(f+M)/2),p=x,f=M,b=!0)}return b?y(p,f,c,u):(d!==c||m!==u)&&g(c,u),h}function yi(n,t){n.seek(t+2);let e=n.u16(),r=-1,o=-1;for(let i=0;i<e;i++){let a=n.u16(),l=n.u16(),c=n.u32(),u=a===3&&l===10?4:a===0&&l>=4?3:a===3&&l===1?2:a===0?1:0;u>o&&(o=u,r=t+c)}if(r<0)return()=>0;n.seek(r);let s=n.u16();if(s===12){n.seek(r+12);let i=n.u32(),a=[];for(let l=0;l<i;l++)a.push([n.u32(),n.u32(),n.u32()]);return l=>{let c=0,u=a.length-1;for(;c<=u;){let h=c+u>>1,[d,m,p]=a[h];if(l<d)u=h-1;else if(l>m)c=h+1;else return p+l-d}return 0}}if(s===4){n.seek(r+6);let i=n.u16(),a=i/2,l=r+14,c=l+i+2,u=c+i,h=u+i,d=new Map;for(let m=0;m<a;m++){let p=n.seek(l+m*2).u16(),f=n.seek(c+m*2).u16(),b=n.seek(u+m*2).i16(),y=n.seek(h+m*2).u16();for(let g=f;g<=p&&g!==65535;g++){let w;if(y===0)w=g+b&65535;else{let k=n.seek(h+m*2+y+(g-f)*2).u16();w=k===0?0:k+b&65535}w&&d.set(g,w)}}return m=>d.get(m)??0}return()=>0}function wi(n,t){let e=[];try{n.seek(t+6);let o=t+n.u16(),s=t+n.u16();n.seek(o);let i=n.u16(),a=new Set;for(let l=0;l<i;l++){n.seek(o+2+l*6);let c=n.tag(),u=n.u16();if(c!=="kern")continue;n.seek(o+u+2);let h=n.u16();for(let d=0;d<h;d++)a.add(n.u16())}for(let l of[...a].sort((c,u)=>c-u)){n.seek(s+2+l*2);let c=s+n.u16();n.seek(c);let u=n.u16();n.u16();let h=n.u16(),d=[];for(let p=0;p<h;p++)d.push(c+n.u16());let m=[];for(let p of d){let f=p,b=u;b===9&&(n.seek(f+2),b=n.u16(),f+=n.u32()),b===2&&m.push(ki(n,f))}e.push(m)}}catch{}let r=new Map;return(o,s)=>{let i=o*65536+s,a=r.get(i);if(a!==void 0)return a;let l=0;for(let c of e)for(let u of c){let h=u(o,s);if(h!==void 0){l+=h;break}}return r.set(i,l),l}}function xi(n,t){n.seek(t);let e=n.u16(),r=new Set;if(e===1){let o=n.u16();for(let s=0;s<o;s++)r.add(n.u16())}else if(e===2){let o=n.u16();for(let s=0;s<o;s++){let i=n.u16(),a=n.u16();n.u16();for(let l=i;l<=a;l++)r.add(l)}}return r}function So(n,t){n.seek(t);let e=n.u16(),r=new Map;if(e===1){let o=n.u16(),s=n.u16();for(let i=0;i<s;i++)r.set(o+i,n.u16())}else if(e===2){let o=n.u16();for(let s=0;s<o;s++){let i=n.u16(),a=n.u16(),l=n.u16();for(let c=i;c<=a;c++)r.set(c,l)}}return o=>r.get(o)??0}function Ro(n){let t=0;for(let e=0;e<8;e++)n&1<<e&&t++;return t*2}function To(n,t){let e=0;t&1&&n.i16(),t&2&&n.i16(),t&4&&(e=n.i16()),t&8&&n.i16();for(let r=4;r<8;r++)t&1<<r&&n.u16();return e}function ki(n,t){n.seek(t);let e=n.u16(),r=n.u16(),o=n.u16(),s=n.u16(),i=Ro(o),a=Ro(s);if(e===1){let l=n.u16(),c=[];for(let m=0;m<l;m++)c.push(n.u16());n.seek(t+r);let u=n.u16(),h=[];if(u===1){let m=n.u16();for(let p=0;p<m;p++)h.push(n.u16())}else if(u===2){let m=n.u16();for(let p=0;p<m;p++){let f=n.u16(),b=n.u16();n.u16();for(let y=f;y<=b;y++)h.push(y)}}let d=new Map;for(let m=0;m<l;m++){n.seek(t+c[m]);let p=n.u16(),f=new Map;for(let b=0;b<p;b++){let y=n.u16(),g=To(n,o);n.seek(n.position+a),f.set(y,g)}h[m]!==void 0&&d.set(h[m],f)}return(m,p)=>d.get(m)?.get(p)}if(e===2){let l=n.u16(),c=n.u16(),u=n.u16(),h=n.u16(),d=n.position,m=xi(n,t+r),p=So(n,t+l),f=So(n,t+c);return(b,y)=>{if(!m.has(b))return;let g=p(b),w=f(y);if(!(g>=u||w>=h))return n.seek(d+g*h*(i+a)+w*(i+a)),To(n,o)}}return()=>{}}var Mi={sans:{400:"Inter-Regular.ttf",600:"Inter-SemiBold.ttf",700:"Inter-Bold.ttf"},serif:{400:"InstrumentSerif-Regular.ttf",italic:"InstrumentSerif-Italic.ttf"},"text-serif":{400:"SourceSerif4-24pt-Regular.ttf",italic:"SourceSerif4-24pt-Italic.ttf"},mono:{400:"JetBrainsMono-Regular.ttf"},noto:{400:"NotoSans-Regular.ttf"},math:{400:"NotoSansMath-Regular.ttf"}},vi={sans:["noto","math"],serif:["text-serif","noto","math"],"text-serif":["noto","math"],mono:["noto","math"],noto:["math"]},Fo=new Map,qn=new Map;function xe(n,t=400,e=!1){let r=Mi[n],o=(e?r.italic:void 0)??r[String(t)]??r[400],s=Fo.get(o);if(s)return s;let i=qn.get(o);throw i||(i=Co(`fonts/${o}`).then(a=>{Fo.set(o,Eo(a)),qn.delete(o)}),qn.set(o,i)),new At(i)}function zo(n,t,e=400,r=!1){for(let o of vi[n]){let s=xe(o,e,r),i=s.glyphFor(t);if(i!==0)return{font:s,glyph:i}}return null}var Io=new WeakMap;function ze(n,t,e){let r=Io.get(n);r||Io.set(n,r=new Map);let o=r.get(e);o||r.set(e,o=new Map);let s=o.get(t);if(s)return s;let i=n.outline(t),a=e/n.unitsPerEm,l=i?i.contours.map(c=>{let u=new Float64Array(c.length);for(let h=0;h<c.length;h+=2)u[h]=c[h]*a,u[h+1]=-c[h+1]*a;return Mt(u,!0)}):[];return o.set(t,l),l}var cn=class extends N{chars=[];source="";find(t){let e=[],r=this.chars.map(s=>s.data.key).join(""),o=t.replace(/\s/g,"");for(let s=r.indexOf(o);s>=0;s=r.indexOf(o,s+1))e.push(...this.chars.slice(s,s+o.length));return e}};function Ni(n){let t=bt(n);if(!t)return{path:n,x:0,y:0};let e=t.x+t.width/2,r=t.y+t.height/2;return{path:ot(n,[1,0,0,1,-e,-r]),x:e,y:r}}function _(n,t={}){let e=t.size??40,r=t.font??"sans",o=t.weight??400,s=t.italic??!1,i=xe(r,o,s),a=e/i.unitsPerEm,l=(t.tracking??0)*e,c=(t.leading??1.3)*e,u=X(t.color??"ink"),h=t.uppercase?n.toUpperCase():n,d=k=>{let x=[],M=0,v=0,P=null;for(let O of k){let A=O.codePointAt(0),R=i,$=i.glyphFor(A);if($===0){let B=zo(r,A,o,s);B&&(R=B.font,$=B.glyph)}let z=e/R.unitsPerEm;v&&P===R&&(M+=R.kern(v,$)*z),x.push({font:R,glyph:$,x:M,char:O}),M+=R.advance($)*z+l,v=$,P=R}return{glyphs:x,width:M}},m=[],p=i.advance(i.glyphFor(32))*a+l;for(let k of h.split(`
2
+ `)){let x=[],M=0;for(let v of k.split(" ")){let P=d(v),O=x.length>0?p:0;t.maxWidth!==void 0&&x.length>0&&M+O+P.width>t.maxWidth&&(m.push({glyphs:x,width:M}),x=[],M=0);let A=M+(x.length>0?p:0);for(let R of P.glyphs)x.push({...R,x:R.x+A});M=A+P.width}m.push({glyphs:x,width:M})}let f=Math.max(0,...m.map(k=>k.width)),b=t.align??"left",y=new cn;y.source=n,m.forEach((k,x)=>{let M=b==="left"?0:b==="center"?(f-k.width)/2:f-k.width;for(let v of k.glyphs){let P=ze(v.font,v.glyph,e);if(P.length===0)continue;let O=Ni(P),A=new N(O.path).at(M+v.x+O.x,x*c+O.y);A.base.fill=u,A.base.trimEach=!0,A.data.key=v.char,v.glyph===0&&(A.data.missingGlyph=!0),y.chars.push(A),y.children.push(A),A.parent=y}});let g=i.ascent*a,w=(m.length-1)*c;return y.base.px=f/2,y.base.py=w/2-g*.36,y.data.size=e,y}var un=class extends N{glyphs=[];source="";part(t){let e=Vo(t),r=this.glyphs.map(o=>o.data.key);for(let o=0;o+e.length<=r.length;o++)if(e.every((s,i)=>s===r[o+i]))return this.glyphs.slice(o,o+e.length);return[]}parts(t){let e=Vo(t),r=this.glyphs.map(s=>s.data.key),o=[];for(let s=0;s+e.length<=r.length;s++)e.every((i,a)=>i===r[s+a])&&(o.push(this.glyphs.slice(s,s+e.length)),s+=e.length-1);return o}},Zn=null,$o=null,Lo=new Map;function Pi(){if(Zn)return Zn;throw $o??=import("./math-4WFNHVV2.js").then(n=>{Zn=(t,e)=>n.renderMathSvg(t,{fontSize:1e3,display:e,color:"#000000"}).svg}),new At($o)}function Bo(n,t){let e=`${t?"D":"I"}${n}`,r=Lo.get(e);if(r)return r;let o=Pi()(n,t),s=[],i=[],a=[1,0,0,1,0,0],l=/viewBox="([^"]+)"/.exec(o)?.[1]?.trim().split(/[ ,]+/).map(Number)??[0,0,1e3,1e3],u=Number(/\swidth="([\d.]+)px"/.exec(o)?.[1]??1e3)/l[2]/1e3,h=/<(\/?)([a-zA-Z]+)((?:\s+[-\w:]+="[^"]*")*)\s*(\/?)>/g,d=0,m=null,p=[];for(let b=h.exec(o);b;b=h.exec(o)){let[,y,g,w="",k]=b,x=P=>new RegExp(`\\s${P}="([^"]*)"`).exec(w)?.[1];if(g==="svg"){if(y){d--,d>=1&&(a=i.pop()??a,m=p.pop()??null);continue}if(d++,d>1){let P=(x("viewBox")??"0 0 1 1").trim().split(/[ ,]+/).map(Number),O=Number(x("width")??P[2]),A=Number(x("height")??P[3]),R=rt([O/(P[2]||1),0,0,A/(P[3]||1),Number(x("x")??0),Number(x("y")??0)],[1,0,0,1,-P[0],-P[1]]);i.push(a),p.push(m),a=rt(a,R),m=[P[0],P[1],P[0]+P[2],P[1]+P[3]]}continue}if(y){g==="g"&&(a=i.pop()??a);continue}let M=x("transform"),v=M?Ai(M):[1,0,0,1,0,0];if(g==="g"){k||(i.push(a),a=rt(a,v));continue}if(g==="path"){let P=x("d");if(!P)continue;let O=x("data-c"),A=ot(vt(P),v);s.push({path:ot(m?Oi(A,m):A,a),key:O?String.fromCodePoint(parseInt(O,16)):"?"})}else if(g==="rect"){let P=Number(x("x")??0),O=Number(x("y")??0),A=Number(x("width")??0),R=Number(x("height")??0);A>0&&R>0&&s.push({path:ot(K(P,O,A,R),rt(a,v)),key:"rule"})}}let f=s.map(b=>({key:b.key,path:ot(b.path,[u,0,0,u,0,0])}));return Lo.set(e,f),f}function Oi(n,t){return n.map(e=>{let r=new Float64Array(e.p.length);for(let o=0;o<r.length;o+=2)r[o]=Math.max(t[0],Math.min(t[2],e.p[o])),r[o+1]=Math.max(t[1],Math.min(t[3],e.p[o+1]));return{p:r,closed:e.closed}})}function Ai(n){let t=[1,0,0,1,0,0];for(let e of n.matchAll(/(translate|scale|matrix)\(([^)]*)\)/g)){let r=e[2].trim().split(/[ ,]+/).map(Number);e[1]==="translate"?t=rt(t,[1,0,0,1,r[0]??0,r[1]??0]):e[1]==="scale"?t=rt(t,[r[0]??1,0,0,r[1]??r[0]??1,0,0]):r.length===6&&(t=rt(t,r))}return t}function Vo(n){return Bo(n,!1).map(t=>t.key)}function st(n,t={}){let e=t.size??56,r=t.display??!0,o=Bo(n,r),s=X(t.color??"ink"),i=new un;i.source=n;let a=1/0,l=1/0,c=-1/0,u=-1/0;for(let h of o){let d=ot(h.path,[e,0,0,e,0,0]),m=bt(d);if(!m)continue;a=Math.min(a,m.x),l=Math.min(l,m.y),c=Math.max(c,m.x+m.width),u=Math.max(u,m.y+m.height);let p=m.x+m.width/2,f=m.y+m.height/2,b=new N(ot(d,[1,0,0,1,-p,-f])).at(p,f);b.base.fill=s,b.base.trimEach=!0,b.data.key=h.key,i.glyphs.push(b),i.children.push(b),b.parent=i}return a!==1/0&&(i.base.px=(a+c)/2,i.base.py=(l+u)/2),i}function Tt(n,t,e){let r=t.fill!==void 0?t.fill:e.fill,o=t.stroke!==void 0?t.stroke:e.stroke;return r&&n.fill(r),o&&n.stroke(o,t.width??e.width??3),t.opacity!==void 0&&n.opacity(t.opacity),t.glow&&n.glow(t.glow),t.dash&&n.dash(t.dash),t.z!==void 0&&n.zIndex(t.z),n}function Ci(n,t={}){return Tt(new N(n),t,{stroke:"ink"})}function ac(n,t={}){return Ci(vt(n),t)}function Y(n,t,e={}){return Tt(new N(le(n,t)),e,{stroke:"ink"})}function lc(n,t={}){return Tt(new N(Z(n,t.closed)),t,{stroke:"ink"})}function cc(n,t={}){return Tt(new N(t.closed?Lt(n,!0):be(n)),t,{stroke:"ink"})}function uc(n,t,e,r={}){return Tt(new N(_e(n,t,e,r.samples??96)),r,{stroke:"ink"})}function Wo(n,t={}){return Tt(new N(Dt(0,0,n)),t,{stroke:"ink"})}function hc(n,t,e={}){return Tt(new N(St(0,0,n,t,0,Math.PI*2)),e,{stroke:"ink"})}function dc(n,t,e,r={}){return Tt(new N(St(0,0,n,n,t,e)),r,{stroke:"ink"})}function Do(n,t,e={}){return Tt(new N(K(-n/2,-t/2,n,t,e.radius??0)),e,{stroke:"ink"})}function Si(n,t={}){return Tt(new N(Z(n,!0)),t,{stroke:"ink"})}function mc(n,t,e={}){let r=[];for(let o=0;o<n;o++){let s=-Math.PI/2+o/n*Math.PI*2;r.push([Math.cos(s)*t,Math.sin(s)*t])}return Si(r,e)}function Ri(n){let t=/^data:image\/(png|gif|jpeg|jpg);base64,/.exec(n);if(!t||typeof atob!="function")return null;let e;try{e=atob(n.slice(t[0].length,t[0].length+(t[1]==="jpeg"||t[1]==="jpg"?87384:44)))}catch{return null}let r=o=>e.charCodeAt(o);if(t[1]==="png")return e.length>=24?[r(16)*16777216+r(17)*65536+r(18)*256+r(19),r(20)*16777216+r(21)*65536+r(22)*256+r(23)]:null;if(t[1]==="gif")return e.length>=10?[r(6)+r(7)*256,r(8)+r(9)*256]:null;for(let o=2;o+9<e.length;){if(r(o)!==255)return null;let s=r(o+1);if(s>=192&&s<=207&&s!==196&&s!==200&&s!==204)return[r(o+7)*256+r(o+8),r(o+5)*256+r(o+6)];o+=2+r(o+2)*256+r(o+3)}return null}function pc(n,t={}){let e=Ri(n),r=t.width,o=t.height;if(r===void 0&&o===void 0){if(!e)throw new Error("image() needs a width or a height when the picture is not a PNG, GIF, or JPEG data URL.");[r,o]=e}else if(r===void 0||o===void 0){if(!e)throw new Error("image() needs both width and height when the picture is not a PNG, GIF, or JPEG data URL.");r===void 0?r=o*e[0]/e[1]:o=r*e[1]/e[0]}if(!(r>0)||!(o>0))throw new Error("image() needs a positive width and height.");let s=new N().at(-r/2,-o/2);s.base.image={src:n,width:r,height:o};let i=new N;return i.add(s),t.opacity!==void 0&&i.opacity(t.opacity),i}function gt(n=9,t="ink",e={}){return Tt(new N(Dt(0,0,n)),e,{fill:t})}function $e(n,t,e={}){let r=e.stroke??"ink",o=e.width??3,s=e.tip??Math.max(13,o*4.2),i=e.tipRatio??.72,a=e.pad??0,l=t[0]-n[0],c=t[1]-n[1],u=Math.hypot(l,c)||1;l/=u,c/=u;let h=[n[0]+l*a,n[1]+c*a],d=[t[0]-l*a,t[1]-c*a],m=Math.max(0,u-a*2),p=Math.min(s,m*.45),f=new N,b=e.bend??0,y=[-c,l],g=[(h[0]+d[0])/2+y[0]*b,(h[1]+d[1])/2+y[1]*b],w=d[0]-g[0],k=d[1]-g[1],x=Math.hypot(w,k)||1;w/=x,k/=x;let M=d[0]-w*p,v=d[1]-k*p,P=b===0?le(e.both?[h[0]+l*p,h[1]+c*p]:h,[M,v]):vt(`M${h[0]} ${h[1]}Q${g[0]} ${g[1]} ${M} ${v}`),O=new N(P).stroke(r,o);e.dash&&O.dash(e.dash);let A=p*i/2,R=($,z,B,W)=>new N(Z([[$,z],[$-B*p-W*A,z-W*p+B*A],[$-B*p+W*A,z-W*p-B*A]],!0)).fill(r);return f.add(O,R(d[0],d[1],w,k)),e.both&&f.add(R(h[0],h[1],-l,-c)),e.opacity!==void 0&&f.opacity(e.opacity),e.glow&&O.glow(e.glow),f.data.shaft=O,f}function Go(n,t,e={}){let r=t[0]-n[0],o=t[1]-n[1],s=Math.hypot(r,o)||1,i=e.depth??Math.min(26,10+s*.05),a=s,l=i,c=1.6,u=Math.min(l,a/4),h=`M0 0C0 ${l*.5} ${u*.4} ${l*.5} ${u} ${l*.5}L${a/2-u} ${l*.5}C${a/2-u*.3} ${l*.5} ${a/2} ${l*.72} ${a/2} ${l}C${a/2} ${l*.72} ${a/2+u*.3} ${l*.5} ${a/2+u} ${l*.5}L${a-u} ${l*.5}C${a-u*.4} ${l*.5} ${a} ${l*.5} ${a} 0L${a-c*.2} ${c*.2}C${a-c*.4} ${l*.5-c} ${a-u*.4} ${l*.5-c} ${a-u} ${l*.5-c}L${a/2+u} ${l*.5-c}C${a/2+u*.3} ${l*.5-c} ${a/2+c*.4} ${l*.6} ${a/2} ${l*.82}C${a/2-c*.4} ${l*.6} ${a/2-u*.3} ${l*.5-c} ${a/2-u} ${l*.5-c}L${u} ${l*.5-c}C${u*.4} ${l*.5-c} ${c*.4} ${l*.5-c} ${c*.2} ${c*.2}Z`,d=r/s,m=o/s,p=ot(vt(h),[d,m,-m,d,n[0],n[1]]),f=Tt(new N(p),{...e,width:void 0},{fill:e.stroke??e.fill??"ink"});return f.data.tip=[(n[0]+t[0])/2-m*i,(n[1]+t[1])/2+d*i],f}var Jn=class extends N{xRange;yRange;plotWidth;plotHeight;lines=new N;grid=new N;numbers=new N;constructor(t={}){super(),this.xRange=t.x??[-5,5],this.yRange=t.y??[-3,3],this.plotWidth=t.width??1100,this.plotHeight=t.height??640;let e=t.color??"dim",r=t.xStep??jo(this.xRange[1]-this.xRange[0]),o=t.yStep??jo(this.yRange[1]-this.yRange[0]),s=hn(0,this.xRange),i=hn(0,this.yRange),a=this.p(this.xRange[0],i),l=this.p(this.xRange[1],i),c=this.p(s,this.yRange[0]),u=this.p(s,this.yRange[1]);if(t.grid){for(let p of ke(this.xRange,r))this.grid.add(Y(this.p(p,this.yRange[0]),this.p(p,this.yRange[1]),{stroke:"grid",width:1.25}));for(let p of ke(this.yRange,o))this.grid.add(Y(this.p(this.xRange[0],p),this.p(this.xRange[1],p),{stroke:"grid",width:1.25}))}let h=t.tips??!0,d=(p,f)=>h?$e(p,f,{stroke:e,width:2,tip:13}):Y(p,f,{stroke:e,width:2});this.lines.add(d(a,l),d(c,u));let m=6;for(let p of ke(this.xRange,r)){if(p===s)continue;let[f,b]=this.p(p,i);this.lines.add(Y([f,b-m],[f,b+m],{stroke:e,width:2}))}for(let p of ke(this.yRange,o)){if(p===i)continue;let[f,b]=this.p(s,p);this.lines.add(Y([f-m,b],[f+m,b],{stroke:e,width:2}))}if(t.labels??!0){let p=t.labelSize??20;for(let f of ke(this.xRange,r)){if(f===s)continue;let[b,y]=this.p(f,i);this.numbers.add(st(Ho(f),{size:p,color:"dim",display:!1}).moveTo([b,y+26]))}for(let f of ke(this.yRange,o)){if(f===i)continue;let[b,y]=this.p(s,f);this.numbers.add(st(Ho(f),{size:p,color:"dim",display:!1}).moveTo([b-28,y]))}}if(this.add(this.grid,this.lines,this.numbers),t.xLabel&&this.add(st(t.xLabel,{size:28,color:"ink",display:!1}).moveTo([l[0]+4,l[1]-26])),t.yLabel){let p=st(t.yLabel,{size:28,color:"ink",display:!1});this.add(p.moveTo([u[0]+16+p.width/2,u[1]+4]))}}p(t,e){let[r,o]=this.xRange,[s,i]=this.yRange;return[((t-r)/(o-r)-.5)*this.plotWidth,(.5-(e-s)/(i-s))*this.plotHeight]}world(t,e){let[r,o]=this.p(t,e);return this.toWorld(r,o)}plotPath(t,e={}){let r=e.from??this.xRange[0],o=e.to??this.xRange[1],s=e.samples??160,[i,a]=this.yRange,l=(a-i)*.02,c=[];for(let u=0;u<=s;u++){let h=r+(o-r)*u/s,d=t(h);c.push(Number.isFinite(d)&&d>=i-l&&d<=a+l?this.p(h,d):[NaN,NaN])}return be(c)}plot(t,e={}){let r=new N(this.plotPath(t,e)).stroke(e.stroke??"blue",e.width??4);return e.glow&&r.glow(e.glow),e.dash&&r.dash(e.dash),this.add(r),r}dotAt(t,e,r="yellow",o=9){let s=gt(o,r).at(this.p(t,e));return this.add(s),s}guides(t,e,r={}){let o=hn(0,this.xRange),s=hn(0,this.yRange),i=Vn(Y(this.p(t,s),this.p(t,e),{stroke:"dim",width:2,dash:[6,7],...r}),Y(this.p(o,e),this.p(t,e),{stroke:"dim",width:2,dash:[6,7],...r}));return this.add(i),i}};function kc(n={}){return new Jn(n)}function hn(n,t){return Math.max(t[0],Math.min(t[1],n))}function jo(n){let t=n/8,e=Math.pow(10,Math.floor(Math.log10(t))),r=t/e;return(r<1.5?1:r<3.5?2:r<7.5?5:10)*e}function ke(n,t){let e=[],r=Math.ceil(n[0]/t-1e-9)*t;for(let o=r;o<=n[1]+1e-9;o+=t)e.push(Math.round(o/t)*t);return e}function Ho(n){let t=Math.round(n*1e3)/1e3;return String(t)}var Le=class extends N{unit;major=new N;minor=new N;axes=new N;constructor(t={}){super(),this.unit=t.unit??120;let[e,r]=t.x??[-12,12],[o,s]=t.y??[-8,8],i=this.unit,a=t.color??"blue",l=t.width??1.6,c=t.minor??0,u=(p,f,b)=>{let y=[];for(let g=0;g<=b;g++)y.push([p[0]+(f[0]-p[0])*g/b,p[1]+(f[1]-p[1])*g/b]);return y.length>2?be(y):le(p,f)},h=16,d=(p,f,b,y,g,w)=>{p.add(new N(u(f,b,w)).stroke(y,g))};for(let p=e;p<=r;p++){if(c>0&&p<r)for(let f=1;f<c;f++){let b=p+f/c;d(this.minor,[b*i,o*i],[b*i,s*i],"grid",1,h)}p!==0&&d(this.major,[p*i,o*i],[p*i,s*i],a,l,h)}for(let p=o;p<=s;p++){if(c>0&&p<s)for(let f=1;f<c;f++){let b=p+f/c;d(this.minor,[e*i,b*i],[r*i,b*i],"grid",1,h)}p!==0&&d(this.major,[e*i,p*i],[r*i,p*i],a,l,h)}let m=t.axisColor??"ink";d(this.axes,[e*i,0],[r*i,0],m,2.6,h),d(this.axes,[0,o*i],[0,s*i],m,2.6,h),this.add(this.minor,this.major,this.axes)}p(t,e){return[t*this.unit,-e*this.unit]}vector(t,e,r={}){return $e([0,0],this.p(t,e),{stroke:"yellow",width:5,tip:22,...r})}};function Mc(n={}){return new Le(n)}function vc(n,t={}){let e=new N;return e.draw=()=>{let r=n(),o=(t.prefix??"")+r.toFixed(t.digits??2)+(t.suffix??"");return _(o,{size:t.size??36,color:t.color??"ink",font:t.font??"mono"})},e}var dn=1,_o=.08,Ko=.15,Ti=.12,Fi=.12,Ii=5,Xo=12,Yo=6,Ei=2,zi=2,$i=1.6,qo=.9;function Uo(n){return yt(n)?lt(n.stops,.5):n}function Zo(n){let t=e=>{let r=e/255;return r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)};return .2126*t(n[0])+.7152*t(n[1])+.0722*t(n[2])}function Li(n,t,e){let r=n[3]*t,o=[n[0]*r+e[0]*(1-r),n[1]*r+e[1]*(1-r),n[2]*r+e[2]*(1-r),1],s=Zo(o),i=Zo(e);return(Math.max(s,i)+.05)/(Math.min(s,i)+.05)}function Jo(n,t){return{x:n.x-t,y:n.y-t,width:n.width+t*2,height:n.height+t*2}}function Vi(n,t){let e=n.width*t,r=n.height*t;return{x:n.x+e,y:n.y+r,width:n.width-e*2,height:n.height-r*2}}function Ve(n,t){return n.x<t.x+t.width&&t.x<n.x+n.width&&n.y<t.y+t.height&&t.y<n.y+n.height}function Bi(n,t){let e=Math.max(n.x,t.x),r=Math.max(n.y,t.y),o=Math.min(n.x+n.width,t.x+t.width),s=Math.min(n.y+n.height,t.y+t.height);return o>e&&s>r?{x:e,y:r,width:o-e,height:s-r}:null}function Wi(n,t){return n.x<=t.x&&n.y<=t.y&&n.x+n.width>=t.x+t.width&&n.y+n.height>=t.y+t.height}function mn(n,t){let e=Math.min(n.x,t.x),r=Math.min(n.y,t.y);return{x:e,y:r,width:Math.max(n.x+n.width,t.x+t.width)-e,height:Math.max(n.y+n.height,t.y+t.height)-r}}function Di(n,t,e,r,o){let s=0,i=1,a=e-n,l=r-t,c=[[-a,n-o.x],[a,o.x+o.width-n],[-l,t-o.y],[l,o.y+o.height-t]];for(let[u,h]of c)if(u===0){if(h<0)return!1}else{let d=h/u;if(u<0){if(d>i)return!1;d>s&&(s=d)}else{if(d<s)return!1;d<i&&(i=d)}}return s<=i}function Gi(n,t){for(let e of n){let r=e.p;for(let o=0;o+7<r.length;o+=6){let s=r[o],i=r[o+1],a=r[o+2],l=r[o+3],c=r[o+4],u=r[o+5],h=r[o+6],d=r[o+7],m=Math.min(s,a,c,h),p=Math.max(s,a,c,h),f=Math.min(i,l,u,d),b=Math.max(i,l,u,d);if(p<t.x||m>t.x+t.width||b<t.y||f>t.y+t.height)continue;let y=s,g=i;for(let w=1;w<=Yo;w++){let k=w/Yo,x=1-k,M=x*x*x,v=3*x*x*k,P=3*x*k*k,O=k*k*k,A=M*s+v*a+P*c+O*h,R=M*i+v*l+P*u+O*d;if(Di(y,g,A,R,t))return!0;y=A,g=R}}}return!1}function ji(n){return n.data.key!==void 0?n.parent:null}function Hi(n){return!!n.node&&n.node.data.key!==void 0}function Qn(n){let t=n.source;return typeof t=="string"?t:""}function _i(n){if(!n)return"unknown";let t=n;for(;t.parent&&t.parent.parent;)t=t.parent;return t.mounted?String(t.id):"dynamic"}function Ki(n,t){let e=new Set,r=n.clips,o=i=>r.some(a=>a.t0<i&&i<a.t1),s=.001;for(let i of r){let a=i.t1+s;a<n.duration&&!o(a)&&e.add(a)}e.add(Math.max(0,n.duration-s));for(let i=0;i<t;i++)e.add((i+.5)/t*n.duration);if(e.size<Ii)for(let i=0;i<Xo;i++){let a=(i+.5)/Xo*n.duration;o(a)||e.add(a)}return[...e].sort((i,a)=>i-a)}function Qo(n,t){try{return n.frame(t)}catch(e){if(!Xn(e))throw e;return e.promise.then(()=>Qo(n,t))}}function Xi(n,t){let e=n.stage.camera,r=e.tracks?.get("sx");return r?r.sample(t):e.base.sx}function Yi(n,t,e,r){let o=[],{width:s,height:i,ops:a}=n,l=n.background?Gt(n.background):n.dark?[0,0,0,1]:[255,255,255,1],c={x:0,y:0,width:s,height:i},u=new Map,h=[],d=[],m=new Map,p=0;a.forEach((g,w)=>{if(g.kind!=="path"||g.path.length===0)return;let k=Hi(g);if(Math.max(g.fillAlpha,g.strokeAlpha)<_o)return;let M=bt(g.path);if(!M)return;let v=g.stroke?Jo(M,g.strokeWidth/2):M,P=k?ji(g.node):null,O=v.x<-dn||v.y<-dn||v.x+v.width>s+dn||v.y+v.height>i+dn,A=v.x<=0&&v.x+v.width>=s||v.y<=0&&v.y+v.height>=i;if(O&&(k||!A&&!e&&!r)){let R=Ve(v,c),$=P?Qn(P):void 0,z=k?`text:${$}`:"marks",B=m.get(z),W=k&&R&&!e?"error":"warning";B?(B.box=mn(B.box,v),k||(p+=1)):(k||(p=1),m.set(z,{key:`film.off_canvas:${z}`,code:"film.off_canvas",severity:W,time:t,box:v,message:k?`Text ${JSON.stringify($??"")} runs off the canvas${R?" and is clipped":""}.`:"",...$?{text:$}:{}}))}if(k&&g.node.data.missingGlyph&&g.fillAlpha>=Ko){let $=`U+${String(g.node.data.key).codePointAt(0).toString(16).toUpperCase().padStart(4,"0")}`,z=P?Qn(P):"";o.push({key:`film.missing_glyph:${z}:${$}`,code:"film.missing_glyph",severity:"error",time:t,box:M,message:`Text ${JSON.stringify(z)} has a character that no bundled font can draw (${$}). It renders as an empty box.`,text:z})}if(k&&P&&g.fillAlpha>=Ko){let R=u.get(P);R||u.set(P,R={id:P,source:Qn(P),bounds:M,glyphs:[]}),R.bounds=mn(R.bounds,M),R.glyphs.push({box:M,order:w})}else if(!k&&(g.fill&&g.fillAlpha>=qo&&Uo(g.fill)[3]>=qo&&g.path.some(R=>R.closed)&&h.push({order:w,bounds:M}),g.stroke&&g.strokeAlpha>=_o&&g.strokePath.length>0)){let R=Li(Uo(g.stroke),g.strokeAlpha,l);R>=$i&&d.push({op:g,order:w,contrast:R})}});let f=m.get("marks");f&&(f.message=`${p===1?"A mark extends":`${p} marks extend`} past the ${s}x${i} canvas.`),o.push(...m.values());let b=(g,w,k)=>h.some(x=>x.order>g&&x.order<w&&Wi(x.bounds,k)),y=[...u.values()];for(let g=0;g<y.length;g++){let w=y[g];for(let k=g+1;k<y.length;k++){let x=y[k];if(!Ve(w.bounds,x.bounds))continue;let M=null;for(let v of w.glyphs)if(Ve(v.box,x.bounds))for(let P of x.glyphs){let O=Bi(v.box,P.box);if(!O)continue;let A=Math.min(v.box.width*v.box.height,P.box.width*P.box.height);A<=0||O.width*O.height/A<Ti||b(Math.min(v.order,P.order),Math.max(v.order,P.order),v.order<P.order?v.box:P.box)||(M=M?mn(M,O):O)}M&&o.push({key:`film.text_overlap:${w.source}|${x.source}`,code:"film.text_overlap",severity:"error",time:t,box:M,message:`Text ${JSON.stringify(w.source)} overlaps text ${JSON.stringify(x.source)}.`,text:w.source,other:x.source})}}for(let g of y)for(let{op:w,order:k,contrast:x}of d){let M=bt(w.strokePath);if(!M||!Ve(Jo(M,w.strokeWidth),g.bounds))continue;let v=null;for(let P of g.glyphs){let O=Vi(P.box,Fi);Ve(M,O)&&Gi(w.strokePath,O)&&(k<P.order&&b(k,P.order,P.box)||(v=v?mn(v,P.box):P.box))}if(v){let P=w.strokeWidth>=Ei&&x>=zi;o.push({key:`film.text_crossed:${g.source}:${_i(w.node)}`,code:"film.text_crossed",severity:P?"error":"warning",time:t,box:v,message:`A stroke crosses text ${JSON.stringify(g.source)}.`,text:g.source})}}return o}async function qi(n,t={}){let e=Ee(n)?await n.compile(t):n,r=t.times?[...t.times]:Ki(e,t.samples??0),o=new Map;for(let l of r){let c=await Qo(e,l);for(let{key:u,...h}of Yi(c,l,Xi(e,l)!==1,e.bleed)){let d=o.get(u);d?(d.until=l,h.severity==="error"&&(d.severity="error")):o.set(u,{...h,until:l,stage:{x:0,y:0}})}}let s=l=>Math.round(l*100)/100,i=[...o.values()].map(l=>({...l,time:Math.round(l.time*1e3)/1e3,until:Math.round(l.until*1e3)/1e3,box:{x:s(l.box.x),y:s(l.box.y),width:s(l.box.width),height:s(l.box.height)},stage:{x:s(l.box.x+l.box.width/2-e.width/2),y:s(l.box.y+l.box.height/2-e.height/2)}})).sort((l,c)=>l.severity===c.severity?l.time-c.time:l.severity==="error"?-1:1),a=i.filter(l=>l.severity==="error").length;return{ok:a===0,width:e.width,height:e.height,duration:e.duration,sampled:r.map(l=>Math.round(l*1e3)/1e3),diagnostics:i,summary:{errors:a,warnings:i.length-a}}}function it(n,t,e){n.mounted||(S.now=t,e.add(n));for(let r=n;r&&r!==e.root;r=r.parent)me(r,"visible",t)||r.track("visible").step(t,!0)}function me(n,t,e){let r=S.now;S.now=e;let o=n.get(t);return S.now=r,o}function D(n,t,e,r){n.track(t).step(r,e)}function wt(n,t,e,r,o){let s=n.track.sample(e);n.track.add({t0:e,t1:r,ease:o,to:t,at:i=>s+(t-s)*i})}function Vt(n,t,e,r){if(n===0)return[];let o=(r-e)/(1+(n-1)*t);return Array.from({length:n},(s,i)=>{let a=e+i*t*o;return[a,a+o]})}function tr(n,t){return typeof n!="string"?n:t.math?st(n,{size:t.size,color:t.color??"ink",display:!1}):_(n,{size:t.size,color:t.color??"ink",font:t.font??"sans",weight:t.weight??400})}function ts(n){let t=e=>{let r=e/255;return r<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4)};return .2126*t(n[0])+.7152*t(n[1])+.0722*t(n[2])}function Ft(n){return typeof n=="string"?Gt(n):Array.isArray(n)?n:n.stops[0][1]}function Be(n){let t=n>>>0;return()=>{t=t+1831565813>>>0;let e=Math.imul(t^t>>>15,1|t);return e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}function Ht(n,t,e){let r=[],o=Math.ceil(n/e-1e-9)*e;for(let s=o;s<=t+e*1e-6;s+=e)r.push(Math.round(s/e)*e);return r}function pn(n,t,e=5){let o=(t-n||1)/Math.max(1,e),s=Math.pow(10,Math.floor(Math.log10(o))),i=o/s,a=(i<1.5?1:i<3.5?2:i<7.5?5:10)*s;return{ticks:Ht(n,t,a),step:a}}function We(n,t){if(t!==void 0&&t<1){let r=Math.min(4,Math.ceil(-Math.log10(t)-1e-9));return n.toFixed(r)}let e=Math.round(n*1e3)/1e3;return Math.abs(e)>=1e3&&Number.isInteger(e)?e.toLocaleString("en-US"):String(e)}function pe(n){let t=n[0],e=new Array(2+(n.length-1)*6);e[0]=t[0],e[1]=t[1];for(let r=1;r<n.length;r++){let o=n[r-1],s=n[r],i=2+(r-1)*6;e[i]=o[0]+(s[0]-o[0])/3,e[i+1]=o[1]+(s[1]-o[1])/3,e[i+2]=o[0]+(s[0]-o[0])*2/3,e[i+3]=o[1]+(s[1]-o[1])*2/3,e[i+4]=s[0],e[i+5]=s[1]}return{p:Float64Array.from(e),closed:!1,straight:!0}}var ee=n=>typeof n=="function"?n():n,er=class extends N{range;length;line;ticks=new N;numbers=new N;constructor(t={}){super(),this.range=t.range??[-5,5],this.length=t.length??1200;let e=t.color??"dim",r=t.width??2,o=this.length/2,s=t.tips??!0;this.line=s?$e([-o-36,0],[o+36,0],{stroke:e,width:r,tip:14,both:!0}):Y([-o,0],[o,0],{stroke:e,width:r});let i=t.step??1;for(let a of Ht(this.range[0],this.range[1],i)){let[l]=this.p(a);if(this.ticks.add(Y([l,-7],[l,7],{stroke:e,width:r})),t.labels??!0){let c=t.labelSize??24,u=st(String(Math.round(a*1e3)/1e3),{size:c,color:"dim",display:!1});u.set("py",-c*.25),this.numbers.add(u.at(l,34))}}this.add(this.line,this.ticks,this.numbers)}p(t){let[e,r]=this.range;return[((t-e)/(r-e)-.5)*this.length,0]}world(t){let[e,r]=this.p(t);return this.toWorld(e,r)}marker(t,e={}){let r=e.color??"yellow",o=e.labelSize??28,s=()=>{let[a]=this.p(ee(t)),l=[gt(e.radius??9,r).at(a,0)];return e.label&&l.push(st(e.label,{size:o,color:r,display:!1}).at(a,-o*1.15)),l},i=typeof t=="function"?Ot(s):new N().add(...s());return this.add(i),i}interval(t,e,r={}){let o=r.color??"blue",s=r.offset??0,[i]=this.p(t),[a]=this.p(e),l=Y([i,s],[a,s],{stroke:o,width:r.width??7}),c=(h,d)=>d?gt(9,"bg").stroke(o,4).at(h,s):gt(9,o).at(h,s),u=new N().add(l,c(i,r.openLeft),c(a,r.openRight));return this.add(u),u}};function _c(n={}){return new er(n)}var nr=class extends Le{numbers=new N;constructor(t={}){super(t);let e=t.labelRange??3,r=t.labelSize??22;for(let o=-e;o<=e;o++){if(o===0)continue;let s=st(String(o),{size:r,color:"ink",display:!1});s.set("py",-r*.25),this.numbers.add(s.at(o*this.unit,22));let i=o===1?"i":o===-1?"-i":`${o}i`,a=st(i,{size:r,color:"ink",display:!1});a.set("py",-r*.25),this.numbers.add(a.at(-r*.9,-o*this.unit))}this.add(this.numbers)}z(t,e){return this.p(t,e)}};function Kc(n={}){return new nr(n)}function Xc(n,t,e={}){let r=Wt(n.worldMatrix()),o=n.worldMatrix(),s=n.unit;return{...Wn([n.minor,n.major,n.axes],(a,l)=>{let[c,u]=Q(r,a,l),[h,d]=t(c/s,-u/s);return Q(o,h*s,-d*s)},{duration:3,...e}),label:"applyComplex"}}var Yc={mul:(n,t)=>[n[0]*t[0]-n[1]*t[1],n[0]*t[1]+n[1]*t[0]],div:(n,t)=>{let e=t[0]*t[0]+t[1]*t[1]||1e-12;return[(n[0]*t[0]+n[1]*t[1])/e,(n[1]*t[0]-n[0]*t[1])/e]},exp:n=>{let t=Math.exp(n[0]);return[t*Math.cos(n[1]),t*Math.sin(n[1])]},log:n=>[Math.log(Math.hypot(n[0],n[1])||1e-12),Math.atan2(n[1],n[0])],pow:(n,t)=>{let e=Math.pow(Math.hypot(n[0],n[1]),t),r=Math.atan2(n[1],n[0])*t;return[e*Math.cos(r),e*Math.sin(r)]},sin:n=>[Math.sin(n[0])*Math.cosh(n[1]),Math.cos(n[0])*Math.sinh(n[1])],cos:n=>[Math.cos(n[0])*Math.cosh(n[1]),-Math.sin(n[0])*Math.sinh(n[1])],inv:n=>{let t=n[0]*n[0]+n[1]*n[1]||1e-12;return[n[0]/t,-n[1]/t]}};function Ui(n,t,e,r,o){let s=Math.hypot(e,r)||1e-6,i=e/s,a=r/s,l=Math.min(s*.42,o*5.2),c=o/2,u=l*.42,h=n+e-i*l,d=t+r-a*l,m=-a,p=i;return Z([[n+m*c,t+p*c],[h+m*c,d+p*c],[h+m*u,d+p*u],[n+e,t+r],[h-m*u,d-p*u],[h-m*c,d-p*c],[n-m*c,t-p*c]],!0)[0]}var rr=class extends N{constructor(e,r={}){super();this.f=e;let o=this.unit=r.unit??120,[s,i]=r.x??[-8,8],[a,l]=r.y??[-4.5,4.5],c=r.step??.5,u=r.maxLength??c*o*.92,h=r.width??2.6,d=(r.colors??["blue","teal","green","yellow","orange","red"]).map(y=>X(y)),m=d.map((y,g)=>[d.length===1?0:g/(d.length-1),y]),p=[];for(let y of Ht(a,l,c))for(let g of Ht(s,i,c))p.push([g,y]);let f=r.max??(()=>{let y=p.map(([g,w])=>{let[k,x]=e(g,w,0);return Math.hypot(k,x)}).filter(Number.isFinite).sort((g,w)=>g-w);return y[Math.floor(y.length*.9)]||1})(),b=(y,g,w)=>{let[k,x]=e(y,g,w),M=Math.hypot(k,x);if(!Number.isFinite(M)||M<1e-9)return null;let v=Math.min(1,M/f),P=u*(.22+.78*(1-Math.exp(-2.2*M/f))),O=k/M*P,A=-(x/M)*P,R=y*o,$=-g*o;return{ring:Ui(R-O/2,$-A/2,O,A,h),at:v,cx:R,cy:$}};if(r.animate){this.draw=g=>{let w=Array.from({length:12},()=>[]);for(let[k,x]of p){let M=b(k,x,g);M&&w[Math.min(11,Math.floor(M.at*12))].push(M.ring)}return w.flatMap((k,x)=>k.length===0?[]:[new N(k).fill(lt(m,(x+.5)/12))])};return}for(let[y,g]of p){let w=b(y,g,0);if(!w)continue;let k=rs([w.ring]).fill(lt(m,w.at));this.arrows.push(k),this.add(k)}}f;unit;arrows=[]};function rs(n){let t=bt(n);if(!t)return new N(n);let e=t.x+t.width/2,r=t.y+t.height/2,o=n.map(s=>{let i=new Float64Array(s.p.length);for(let a=0;a<i.length;a+=2)i[a]=s.p[a]-e,i[a+1]=s.p[a+1]-r;return{p:i,closed:s.closed}});return new N(o).at(e,r)}function qc(n,t={}){return new rr(n,t)}var or=class extends N{lineCount;constructor(t,e={}){super();let r=e.unit??120,[o,s]=e.x??[-8.5,8.5],[i,a]=e.y??[-5,5],l=e.spacing??.55,c=e.dt??.03,u=e.steps??130,h=e.width??2.2,d=e.speed??.35,m=e.tail??.42,p=Be(e.seed??7),f=(e.colors??["blue","teal","green","yellow","orange","red"]).map(A=>X(A)),b=f.map((A,R)=>[f.length===1?0:R/(f.length-1),A]),y=[],g=[],w=.6;for(let A=i;A<=a;A+=l)for(let R=o;R<=s;R+=l){let $=R+(p()-.5)*l,z=A+(p()-.5)*l,B=p(),W=[[$*r,-z*r]],G=0;for(let C=0;C<u;C++){let[L,I]=t($,z,0),[F,E]=t($+L*c/2,z+I*c/2,0),[T,V]=t($+F*c/2,z+E*c/2,0),[j,J]=t($+T*c,z+V*c,0),at=(L+2*F+2*T+j)/6,tt=(I+2*E+2*V+J)/6;if(!Number.isFinite(at)||!Number.isFinite(tt))break;let ut=Math.hypot(at,tt);if(G+=ut,ut<1e-6||($+=at*c,z+=tt*c,$<o-w||$>s+w||z<i-w||z>a+w))break;C%2===1&&W.push([$*r,-z*r])}if(W.length<5)continue;let U=G/(W.length*2);g.push(U),y.push({points:W,phase:B,speedRate:.8+p()*.4,color:U})}let k=[...g].sort((A,R)=>A-R),x=e.max??(k[Math.floor(k.length*.92)]||1),M=8;for(let A of y)A.color=Math.min(M-1,Math.floor(Math.min(1,A.color/x)*M));this.lineCount=y.length;let v=6,P=e.trace??0,O=Array.from({length:M},()=>[]);if(P>0)for(let A of y)O[A.color].push(pe(A.points));this.draw=A=>{let R=Array.from({length:M*v},()=>[]);for(let z of y){let B=z.points.length,W=Math.max(3,Math.floor(B*m)),G=B+W,U=(A*d*z.speedRate+z.phase)%1*G;for(let C=0;C<v;C++){let L=Math.floor(U-W*(1-C/v)),I=Math.floor(U-W*(1-(C+1)/v)),F=Math.max(0,L),E=Math.min(B-1,I);E-F<1||R[z.color*v+C].push(pe(z.points.slice(F,E+1)))}}let $=[];return P>0&&O.forEach((z,B)=>{z.length&&$.push(new N(z).stroke(lt(b,(B+.5)/M),h*.6).set("strokeOpacity",P))}),R.forEach((z,B)=>{if(z.length===0)return;let W=Math.floor(B/v),G=B%v,U=new N(z).stroke(lt(b,(W+.5)/M),h);U.set("strokeOpacity",Math.pow((G+1)/v,1.6)),G<v-1&&U.set("cap","butt"),$.push(U)}),$}}};function Uc(n,t={}){return new or(n,t)}function Zc(n,t,e={}){let r=e.from??n.xRange[0],o=e.to??n.xRange[1],s=e.n??12,i=e.rule??"mid",a=Ie(s,...e.colors??["blue","teal","green"]),l=new N,c=(o-r)/s;for(let u=0;u<s;u++){let h=r+u*c,d=i==="left"?h:i==="right"?h+c:h+c/2,m=t(d),[p,f]=n.p(h,0),[b,y]=n.p(h+c,m),g=rs(Z([[p,f],[b,f],[b,y],[p,y]],!0));g.fill(a[u],e.opacity??.72),g.stroke(e.stroke??"bg",e.strokeWidth??(s>40?.5:1.4)),l.add(g)}return n.add(l),l}function es(n,t,e,r,o){let s=[];for(let i=0;i<=o;i++){let a=e+(r-e)*i/o;s.push(n.p(a,t(a)))}return s.push(n.p(r,0),n.p(e,0)),Z(s,!0)}function Jc(n,t,e={}){let r=e.samples??96,o=e.fill??"blue",s=e.opacity??.28,i=e.from??n.xRange[0],a=e.to??n.xRange[1],l=typeof i=="function"||typeof a=="function"?Ot(()=>{let c=ee(i),u=ee(a);return Math.abs(u-c)<1e-9?null:new N(es(n,t,c,u,r)).fill(o,s)}):new N(es(n,t,i,a,r)).fill(o,s);return n.add(l),l}function Zi(n,t,e){let o=(n.xRange[1]-n.xRange[0])*1e-4,s=n.p(e-o,t(e-o)),i=n.p(e+o,t(e+o)),a=Math.hypot(i[0]-s[0],i[1]-s[1])||1;return{point:n.p(e,t(e)),ux:(i[0]-s[0])/a,uy:(i[1]-s[1])/a}}function Qc(n,t,e,r={}){let o=r.length??420,s=r.stroke??"yellow",i=()=>{let{point:l,ux:c,uy:u}=Zi(n,t,ee(e)),h=[Y([l[0]-c*o/2,l[1]-u*o/2],[l[0]+c*o/2,l[1]+u*o/2],{stroke:s,width:r.width??3.5,glow:r.glow,dash:r.dash})];return(r.point??!0)&&h.push(gt(8,s).at(l)),h},a=typeof e=="function"?Ot(i):new N().add(...i());return n.add(a),a}function tu(n,t,e,r,o={}){let s=o.extend??140,i=o.stroke??"yellow",a=()=>{let c=ee(e),u=ee(r),h=n.p(c,t(c)),d=n.p(u,t(u)),m=Math.hypot(d[0]-h[0],d[1]-h[1])||1,p=(d[0]-h[0])/m,f=(d[1]-h[1])/m,b=[Y([h[0]-p*s,h[1]-f*s],[d[0]+p*s,d[1]+f*s],{stroke:i,width:o.width??3.5,glow:o.glow})];if(o.legs){let y=[d[0],h[1]],g=o.legColor??"dim";b.unshift(Y(h,y,{stroke:g,width:2,dash:[6,7]}),Y(y,d,{stroke:g,width:2,dash:[6,7]}))}return(o.points??!0)&&b.push(gt(8,i).at(h),gt(8,i).at(d)),b},l=typeof e=="function"||typeof r=="function"?Ot(a):new N().add(...a());return n.add(l),l}function eu(n,t,e,r={}){let o=()=>{let i=ee(t),a=ee(e),l=Math.max(n.xRange[0],Math.min(n.xRange[1],0)),c=Math.max(n.yRange[0],Math.min(n.yRange[1],0)),u={stroke:"dim",width:2,dash:[6,7],...r};return[Y(n.p(i,c),n.p(i,a),u),Y(n.p(l,a),n.p(i,a),u)]},s=typeof t=="function"||typeof e=="function"?Ot(o):new N().add(...o());return n.add(s),s}function nu(n,t,e,r={}){let o=r.radius??54,s=r.color??"yellow",i=Math.atan2(t[1]-n[1],t[0]-n[0]),a=Math.atan2(e[1]-n[1],e[0]-n[0])-i;for(;a<=-Math.PI;)a+=Math.PI*2;for(;a>Math.PI;)a-=Math.PI*2;r.reflex&&(a+=a>0?-Math.PI*2:Math.PI*2);let l=new N;if(r.fillOpacity){let c=[n];for(let u=0;u<=24;u++){let h=i+a*u/24;c.push([n[0]+Math.cos(h)*o,n[1]+Math.sin(h)*o])}l.add(new N(Z(c,!0)).fill(s,r.fillOpacity))}if(l.add(new N(St(n[0],n[1],o,o,i,i+a)).stroke(s,r.width??3)),r.label){let c=r.labelSize??30,u=i+a/2,h=o+c*.72;l.add(st(r.label,{size:c,color:s,display:!1}).at(n[0]+Math.cos(u)*h,n[1]+Math.sin(u)*h))}return l}function ru(n,t,e,r={}){let o=r.size??26,s=u=>{let h=u[0]-n[0],d=u[1]-n[1],m=Math.hypot(h,d)||1;return[h/m,d/m]},[i,a]=s(t),[l,c]=s(e);return new N(Z([[n[0]+i*o,n[1]+a*o],[n[0]+(i+l)*o,n[1]+(a+c)*o],[n[0]+l*o,n[1]+c*o]])).stroke(r.color??"ink",r.width??2.5)}var Ji={"[":["[","]"],"(":["(",")"],"|":["|","|"]},sr=class extends N{cells;entries=new N;brackets=new N;rowCount;colCount;positions;options;constructor(t,e={}){super(),this.options=e;let r=e.size??52,o=e.color??"ink";this.rowCount=t.length,this.colCount=Math.max(0,...t.map(w=>w.length));let s=t.map(w=>w.map(k=>{let x=st(String(k),{size:r,color:o,display:!1});return x.set("py",-r*.25),x})),i=Array.from({length:this.colCount},(w,k)=>Math.max(0,...s.map(x=>x[k]?.width??0))),a=(e.gapX??.85)*r,l=(e.gapY??1.32)*r,c=i.reduce((w,k)=>w+k,0)+a*Math.max(0,this.colCount-1),u=l*Math.max(0,this.rowCount-1)+r,h=[],d=-c/2;for(let w of i)h.push(d+w/2),d+=w+a;this.positions=s.map((w,k)=>w.map((x,M)=>{let v=[h[M],(k-(this.rowCount-1)/2)*l];return x.at(v),this.entries.add(x),v})),this.cells=s;let m=Ji[e.bracket??"["],f=`\\rule{0pt}{${((u+r*.5)/r/2+.25).toFixed(3)}em}`,b=r*.42,y=st(`\\left${m[0]}${f}\\right.`,{size:r,color:e.bracketColor??o}),g=st(`\\left.${f}\\right${m[1]}`,{size:r,color:e.bracketColor??o});y.moveTo([-c/2-b-y.width/2,0]),g.moveTo([c/2+b+g.width/2,0]),this.brackets.add(y,g),this.add(this.brackets,this.entries)}cell(t,e){let r=this.cells[t]?.[e];if(!r)throw new Error(`Matrix has no cell (${t}, ${e}). It is ${this.rowCount} by ${this.colCount}.`);return r}row(t){return[...this.cells[t]??[]]}col(t){return this.cells.map(e=>e[t]).filter(Boolean)}setCell(t,e,r,o={}){let s=this.options.size??52,i=st(String(r),{size:s,color:this.options.color??"ink",display:!1});i.set("py",-s*.25);let a=this.positions[t][e];i.at(a);let l=this.cell(t,e),c=this,u=we(l,i,{duration:.8,...o});return{...u,schedule(h){c.entries.add(i),i.track("visible").initial=!1,c.cells[t][e]=i,u.schedule(h)}}}};function ou(n,t={}){return new sr(n,t)}function os(n){let t=Array.isArray(n)?n:[n],e=1/0,r=1/0,o=-1/0,s=-1/0;for(let i of t){let a=i.bounds();e=Math.min(e,a.x),r=Math.min(r,a.y),o=Math.max(o,a.x+a.width),s=Math.max(s,a.y+a.height)}return{x:e,y:r,width:o-e,height:s-r}}function su(n,t,e={}){let r=os(n),o=e.side??"bottom",s=e.gap??12,i=e.color??"ink",a=e.size??34,l=r.x,c=r.x+r.width,u=r.y,h=r.y+r.height,[d,m]=o==="bottom"?[[l,h+s],[c,h+s]]:o==="top"?[[c,u-s],[l,u-s]]:o==="left"?[[l-s,u],[l-s,h]]:[[c+s,h],[c+s,u]],p=Go(d,m,{stroke:i,depth:e.depth}),f=p.data.tip,b=tr(t,{size:a,color:i,math:!e.plain});b.moveTo(f);let y=Qe(o),g=10+(y[0]!==0?b.width/2:b.height/2);return b.shift(y[0]*g,y[1]*g),new N().add(p,b)}function iu(n,t={}){let e=os(n),r=t.pad??12,o=Do(e.width+r*2,e.height+r*2,{radius:t.radius??8,stroke:t.color??"yellow",width:t.width??2.5,glow:t.glow});return t.fill&&o.fill(t.fill,t.fillOpacity??.14),o.at(e.x+e.width/2,e.y+e.height/2)}var ir=class extends N{mark;caption;constructor(t,e={}){super();let r=e.color??"yellow";this.mark=gt(e.radius??9,r),this.caption=tr(t,{size:e.size??30,color:e.labelColor??r,math:!e.plain}),this.add(this.mark,this.caption),this.caption.nextTo(this.mark,e.side??[.72,-.72],e.gap??8)}};function au(n,t={}){return new ir(n,t)}function lu(n,t,e,r={}){let o=r.color??"yellow",s=r.width??3,i=r.rate??60,a=r.fade??(r.tail!==void 0?0:1),l=a>=1?1:10,c=new Map,u=h=>{let d=c.get(h);if(d)return d;let m=S.now;S.now=t+h/i;let p=n();return S.now=m,S.mode==="render"&&c.set(h,p),p};return Ot(h=>{if(h<=t)return null;let d=Math.min(h,e),m=r.tail!==void 0?Math.max(t,d-r.tail):t,p=Math.ceil((m-t)*i),f=Math.floor((d-t)*i);if(f-p<1)return null;let b=[];for(let w=p;w<=f;w++)b.push(u(w));let y=S.now;S.now=d,b.push(n()),S.now=y;let g=[];for(let w=0;w<l;w++){let k=Math.floor((b.length-1)*w/l),x=Math.min(b.length-1,Math.floor((b.length-1)*(w+1)/l));if(x-k<1)continue;let M=new N([pe(b.slice(k,x+1))]).stroke(o,s),v=l===1?1:a+(1-a)*Math.pow((w+1)/l,1.5);M.set("strokeOpacity",v),w<l-1&&M.set("cap","butt"),r.glow&&M.glow(r.glow),g.push(M)}return g})}function cu(n,t={}){let e=n.length,r=[];for(let o=0;o<e;o++){let s=o<=e/2?o:o-e,i=0,a=0;for(let l=0;l<e;l++){let c=-2*Math.PI*s*l/e,u=Math.cos(c),h=Math.sin(c),[d,m]=n[l];i+=d*u-m*h,a+=d*h+m*u}r.push({freq:s,amp:Math.hypot(i,a)/e,phase:Math.atan2(a,i)})}return r.sort((o,s)=>s.amp-o.amp||o.freq-s.freq),t.terms?r.slice(0,t.terms):r}function ns(n,t){let e=0,r=0;for(let o of n){let s=2*Math.PI*o.freq*t+o.phase;e+=o.amp*Math.cos(s),r+=o.amp*Math.sin(s)}return[e,r]}function uu(n,t){return Pt(n)===0?[]:Array.from({length:t},(r,o)=>Nt(n,o/t))}var ar=class extends N{terms;outlinePoints;constructor(t,e){super(),this.terms=[...t].sort((h,d)=>(h.freq===0?-1:d.freq===0?1:0)||d.amp-h.amp);let r=e.samples??1024;this.outlinePoints=Array.from({length:r+1},(h,d)=>ns(this.terms,d/r));let o=e.circles??64,s=e.circleColor??"blue",i=e.armColor??"ink",a=e.traceColor??"yellow",l=e.traceWidth??3.5,c=e.tail??1,u=12;this.draw=()=>{let h=e.u(),d=h-Math.floor(h),m=[],p=0,f=0,b=[],y=[[],[],[],[]];this.terms.forEach((x,M)=>{let v=2*Math.PI*x.freq*d+x.phase,P=p+x.amp*Math.cos(v),O=f+x.amp*Math.sin(v);M<o&&x.freq!==0&&x.amp>.4&&y[Math.min(3,Math.floor(M/Math.max(1,o)*4))].push(...Dt(p,f,x.amp)),p=P,f=O,M<o&&b.push([p,f])}),y.forEach((x,M)=>{x.length&&m.push(new N(x).stroke(s,1.2).set("strokeOpacity",[.55,.36,.22,.14][M]))}),b.length>=2&&m.push(new N([pe(b)]).stroke(i,1.4).set("strokeOpacity",.85));let g=this.outlinePoints.length-1,w=h>=1?g:Math.floor(d*g),k=Math.max(0,w-Math.floor(g*c));if(w-k>=2)if(c>=1){let x=new N([pe(this.outlinePoints.slice(k,w+1))]).stroke(a,l);e.glow&&x.glow(e.glow),m.push(x)}else for(let x=0;x<u;x++){let M=k+Math.floor((w-k)*x/u),v=Math.min(w,k+Math.floor((w-k)*(x+1)/u));if(v-M<1)continue;let P=new N([pe(this.outlinePoints.slice(M,v+1))]).stroke(a,l);P.set("strokeOpacity",Math.pow((x+1)/u,1.5)),x<u-1&&P.set("cap","butt"),m.push(P)}return h<1&&m.push(gt(5,a).at(p,f)),m}}outline(){return Z(this.outlinePoints.slice(0,-1),!0)}point(t){return ns(this.terms,t)}};function hu(n,t){return new ar(n,t)}function du(n,t=200){return _e(n,0,1,t).map(r=>Mt(r.p,!0))}var re=["blue","yellow","teal","orange","purple","green","pink","red"];function It(n,t,e="dim",r="sans"){return _(n,{size:t,color:e,font:r})}var cr=class extends N{bars=[];labels=[];readouts=[];baseline;values;maxValue;minValue;w;h;horizontal;band;gap;fixedMax;fixedMin;constructor(t,e={}){super(),this.w=e.width??900,this.h=e.height??520,this.horizontal=e.horizontal??!1,this.gap=e.gap??.28,this.fixedMax=e.max,this.fixedMin=e.min;let r=e.labelSize??20,o=Math.max(1,t.length);this.band=(this.horizontal?this.h:this.w)/o;let s=t.map(d=>d.value);this.maxValue=new pt(e.max??Math.max(0,...s)),this.minValue=new pt(e.min??Math.min(0,...s)),this.values=t.map(d=>new pt(d.value));let i=e.format??(d=>We(Math.round(d*100)/100)),a=e.color??"faint",[l,c]=this.place(0,0,"start"),[u,h]=this.place(o-1,0,"end");this.baseline=Y([l,c],[u,h],{stroke:a,width:1.5}),t.forEach((d,m)=>{let p=d.color??re[m%re.length],f=new N(this.barPath(m,d.value)).fill(p,.84);this.bars.push(f);let b=It(d.label,r);this.labels.push(b);let[y,g]=this.place(m,0,"mid");if(this.horizontal?b.at(y-12-b.width/2,g):b.at(y,g+12+r/2),e.showValues??!0){let w=Ot(()=>{let k=this.values[m].value,[x,M]=this.tip(m,k),v=It(i(k),r,"ink","mono");return this.horizontal?v.at(x+12+v.width/2,M):v.at(x,M+(k>=0?-1:1)*(10+r*.6))});this.readouts.push(w)}}),this.add(...this.bars,this.baseline,...this.labels,...this.readouts)}lengthOf(t){let e=this.maxValue.value-this.minValue.value||1;return t/e*(this.horizontal?this.w:this.h)}place(t,e,r){let o=(t+.5)*this.band,s=this.band/2,i=r==="mid"?o:r==="start"?o-s:o+s,a=this.maxValue.value-this.minValue.value||1;if(this.horizontal)return[-this.minValue.value/a*this.w-this.w/2,i-this.h/2];let l=this.h/2- -this.minValue.value/a*this.h;return[i-this.w/2,l]}tip(t,e){let[r,o]=this.place(t,0,"mid"),s=this.lengthOf(e);return this.horizontal?[r+s,o]:[r,o-s]}barPath(t,e){let[r,o]=this.place(t,0,"mid"),s=this.band*(1-this.gap),i=this.lengthOf(e);return this.horizontal?K(r,o-s/2,i,s):K(r-s/2,o-i,s,i)}bar(t){return this.bars[t]}enter(t={}){let e=t.lag??.12;return{label:"barChart.enter",duration:t.duration??1.6,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=r.t1-r.t0;D(this.baseline,"trimTo",0,r.t0),this.baseline.tween("trimTo",1,r.t0,r.t0+o*.4,r.ease);let s=Vt(this.bars.length,e,r.t0+o*.1,r.t1);this.bars.forEach((i,a)=>{let[l,c]=s[a],u=this.values[a].track.sample(r.t0);this.values[a].track.step(r.t0,0),wt(this.values[a],u,l,c,r.ease),i.track("path").step(r.t0,this.barPath(a,0)),i.track("path").add({t0:l,t1:c,ease:r.ease,to:this.barPath(a,u),at:m=>this.barPath(a,u*m)});let h=this.labels[a];D(h,"opacity",0,r.t0),h.tween("opacity",1,l,l+(c-l)*.6,r.ease);let d=this.readouts[a];d&&(D(d,"opacity",0,r.t0),d.tween("opacity",1,l,l+(c-l)*.5,r.ease))})}}}update(t,e={}){return{label:"barChart.update",duration:e.duration??1.1,ease:e.ease,schedule:r=>{let o=this.values.map(c=>c.track.sample(r.t0)),s=this.maxValue.track.sample(r.t0),i=this.minValue.track.sample(r.t0),a=this.fixedMax??Math.max(0,...t),l=this.fixedMin??Math.min(0,...t);wt(this.maxValue,a,r.t0,r.t1,r.ease),wt(this.minValue,l,r.t0,r.t1,r.ease),t.forEach((c,u)=>{wt(this.values[u],c,r.t0,r.t1,r.ease);let h=this.bars[u];if(!h)return;let d=m=>this.barPathAt(u,o[u]+(c-o[u])*m,s+(a-s)*m,i+(l-i)*m);h.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:d(1),at:d})})}}}barPathAt(t,e,r,o){let s=r-o||1,i=(t+.5)*this.band,a=this.band*(1-this.gap);if(this.horizontal){let u=-o/s*this.w-this.w/2;return K(u,i-this.h/2-a/2,e/s*this.w,a)}let l=this.h/2- -o/s*this.h,c=e/s*this.h;return K(i-this.w/2-a/2,l-c,a,c)}};function ku(n,t={}){return new cr(n,t)}var ur=class extends N{shown;bins;range;chartWidth;chartHeight;axis=new N;total;assigned;peak;constructor(t,e={}){super(),this.chartWidth=e.width??900,this.chartHeight=e.height??480,this.bins=e.bins??24;let r=e.range?.[0]??Math.min(...t),o=e.range?.[1]??Math.max(...t);this.range=[r,o],this.total=t.length,this.assigned=new Int32Array(t.length);let s=new Int32Array(this.bins);t.forEach((b,y)=>{let g=Math.min(this.bins-1,Math.floor((b-r)/(o-r||1)*this.bins));this.assigned[y]=b<r||b>o?-1:g,this.assigned[y]>=0&&s[g]++}),this.peak=e.max??Math.max(1,...s),this.shown=new pt(t.length);let i=e.labelSize??20,a=this.chartWidth,l=this.chartHeight,c=Y([-a/2,l/2],[a/2,l/2],{stroke:e.color??"faint",width:1.5});this.axis.add(c);let{ticks:u,step:h}=pn(r,o,e.ticks??6);for(let b of u){let y=this.xAt(b);this.axis.add(Y([y,l/2],[y,l/2+6],{stroke:"faint",width:1.5})),this.axis.add(It(We(b,h),i).at(y,l/2+12+i*.6))}let d=(e.colors??["blue"]).map(b=>Ft(b)),m=d.map((b,y)=>[d.length===1?0:y/(d.length-1),b]),p=e.gap??.12,f=Ot(()=>{let b=Math.max(0,Math.min(this.total,Math.round(this.shown.value))),y=new Int32Array(this.bins);for(let x=0;x<b;x++){let M=this.assigned[x];M>=0&&y[M]++}let g=a/this.bins,w=[],k=[];for(let x=0;x<this.bins;x++){let M=y[x]/this.peak*l;if(M<=0)continue;let v=K(-a/2+x*g+g*p/2,l/2-M,g*(1-p),M);d.length===1?w.push(...v):k.push(new N(v).fill(lt(m,x/Math.max(1,this.bins-1))))}return w.length&&k.push(new N(w).fill(d[0])),k});this.add(f,this.axis)}xAt(t){let[e,r]=this.range;return((t-e)/(r-e||1)-.5)*this.chartWidth}p(t,e){return[this.xAt(t),this.chartHeight/2-e/this.peak*this.chartHeight]}fillUp(t={}){let e=this.shown,r=t.count??this.total;return{label:"histogram.fill",duration:t.duration??3,ease:t.ease,schedule:o=>{it(this,o.t0,o.stage),e.track.keys.length===0&&(e.track.initial=0),wt(e,r,o.t0,o.t1,o.ease)}}}curve(t,e={}){let[r,o]=this.range,s=e.samples??120,i=[];for(let l=0;l<=s;l++){let c=r+(o-r)*l/s;i.push(this.p(c,t(c)))}let a=new N(Lt(i)).stroke(e.color??"yellow",e.width??4);return this.add(a),a}};function Mu(n,t={}){return new ur(n,t)}function ne(n,t,e){let{xRange:r,yRange:o,w:s,h:i}=n;return[((t-r[0])/(r[1]-r[0]||1)-.5)*s,(.5-(e-o[0])/(o[1]-o[0]||1))*i]}function ss(n,t){let e=new N,r=t.labelSize,o=t.color??"faint",{w:s,h:i}=n,a=pn(n.xRange[0],n.xRange[1],t.xTicks??6),l=pn(n.yRange[0],n.yRange[1],t.yTicks??5);for(let c of l.ticks){let[,u]=ne(n,n.xRange[0],c);t.gridY!==!1&&e.add(Y([-s/2,u],[s/2,u],{stroke:"grid",width:1.25}));let h=It(t.yFormat?t.yFormat(c):We(c,l.step),r);e.add(h.at(-s/2-12-h.width/2,u))}e.add(Y([-s/2,i/2],[s/2,i/2],{stroke:o,width:1.5}));for(let c of a.ticks){let[u]=ne(n,c,n.yRange[0]);e.add(Y([u,i/2],[u,i/2+6],{stroke:o,width:1.5})),e.add(It(t.xFormat?t.xFormat(c):We(c,a.step),r).at(u,i/2+12+r*.6))}if(t.xLabel){let c=It(t.xLabel,r,"ink");e.add(c.at(s/2-c.width/2,i/2+18+r*1.6))}if(t.yLabel){let c=It(t.yLabel,r,"ink");e.add(c.at(-s/2+c.width/2,-i/2-12-r/2))}return e}var hr=class extends N{dots=[];axis;groupLabels=[];frame;constructor(t,e={}){super();let r=t.map(h=>h.x),o=t.map(h=>h.y),s=(h,d)=>(d-h||1)*.06,i=e.x??[Math.min(...r)-s(Math.min(...r),Math.max(...r)),Math.max(...r)+s(Math.min(...r),Math.max(...r))],a=e.y??[Math.min(...o)-s(Math.min(...o),Math.max(...o)),Math.max(...o)+s(Math.min(...o),Math.max(...o))];this.frame={xRange:i,yRange:a,w:e.width??900,h:e.height??520};let l=e.labelSize??18;this.axis=ss(this.frame,{labelSize:l,color:e.color,xLabel:e.xLabel,yLabel:e.yLabel});let c=new Map,u=t.map(h=>{let d=h.color;if(h.group!==void 0){let p=c.get(h.group);p||(p={color:d??re[c.size%re.length],sumX:0,top:-1/0,count:0},c.set(h.group,p)),d??=p.color,p.sumX+=h.x,p.top=Math.max(p.top,h.y),p.count++}let m=gt(h.radius??e.radius??6,d??"blue").at(ne(this.frame,h.x,h.y));return m.set("fillOpacity",.92),m});if(this.dots.push(...u),this.add(this.axis,...u),e.groupLabels??!0)for(let[h,d]of c){let m=It(h,l+2,d.color),[p,f]=ne(this.frame,d.sumX/d.count,d.top);m.at(p,f-l*1.2),this.groupLabels.push(m),this.add(m)}}p(t,e){return ne(this.frame,t,e)}enter(t={}){let e=t.lag??Math.min(.2,8/Math.max(1,this.dots.length));return{label:"scatter.enter",duration:t.duration??2,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=r.t1-r.t0;D(this.axis,"opacity",0,r.t0),this.axis.tween("opacity",1,r.t0,r.t0+o*.3,r.ease);let s=[...this.dots].sort((a,l)=>a.get("x")-l.get("x")),i=Vt(s.length,e,r.t0+o*.15,r.t1);s.forEach((a,l)=>{let[c,u]=i[l],h=a.get("sx");D(a,"sx",.001,r.t0),D(a,"sy",.001,r.t0),a.tween("sx",h,c,u,r.ease),a.tween("sy",h,c,u,r.ease)});for(let a of this.groupLabels)D(a,"opacity",0,r.t0),a.tween("opacity",1,r.t0+o*.7,r.t1,r.ease)}}}fit(t,e={}){let[r,o]=this.frame.xRange,s=e.samples??60,i=[];for(let l=0;l<=s;l++){let c=r+(o-r)*l/s;i.push(this.p(c,t(c)))}let a=new N(Lt(i)).stroke(e.color??"yellow",e.width??3.5);return this.add(a),a}};function vu(n,t={}){return new hr(n,t)}var dr=class extends N{lines=[];areas=[];names=[];axis;byName=new Map;frame;constructor(t,e={}){super();let r=t.map(b=>b.points??(b.values??[]).map((y,g)=>[g,y])),o=r.flat().map(b=>b[0]),s=r.flat().map(b=>b[1]),i=Math.min(...s),a=Math.max(...s),l=(a-i||1)*.08,c=e.x??[Math.min(...o),Math.max(...o)],u=e.y??[i>=0&&i<(a-i)*.4?0:i-l,a+l],h=e.width??900,d=e.height??480;this.frame={xRange:c,yRange:u,w:h,h:d};let m=e.labelSize??18;this.axis=ss(this.frame,{labelSize:m,color:e.color,xLabel:e.xLabel,yLabel:e.yLabel,xFormat:e.xFormat,yFormat:e.yFormat,xTicks:e.xTicks,yTicks:e.yTicks}),this.add(this.axis);let p=[];t.forEach((b,y)=>{let g=b.color??re[y%re.length],w=r[y].map(([M,v])=>ne(this.frame,M,v));if(b.area){let M=ne(this.frame,c[0],Math.max(u[0],0))[1],v=Z([...w,[w[w.length-1][0],M],[w[0][0],M]],!0),P=new N(v).fill(g,b.area);this.areas.push(P),this.add(P)}let k=b.smooth===!1?Z(w):Lt(w),x=new N(k).stroke(g,b.width??3.5);if(b.dash&&x.dash(b.dash),this.lines.push(x),this.add(x),b.name){this.byName.set(b.name,x);let M=It(b.name,m+1,g),v=w[w.length-1];p.push({label:M,y:v[1]}),M.at(v[0]+12+M.width/2,v[1]),this.names.push(M),this.add(M)}}),p.sort((b,y)=>b.y-y.y);let f=m*1.25;for(let b=0;b<8;b++)for(let y=1;y<p.length;y++){let g=f-(p[y].y-p[y-1].y);g>0&&(p[y-1].y-=g/2,p[y].y+=g/2)}for(let b of p)b.label.at(b.label.get("x"),b.y)}p(t,e){return ne(this.frame,t,e)}series(t){let e=this.byName.get(t);if(!e)throw new Error(`No series named ${JSON.stringify(t)}.`);return e}enter(t={}){let e=t.lag??.1;return{label:"lineChart.enter",duration:t.duration??2.2,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=r.t1-r.t0;D(this.axis,"opacity",0,r.t0),this.axis.tween("opacity",1,r.t0,r.t0+o*.3,r.ease);let s=Vt(this.lines.length,e,r.t0+o*.15,r.t1);this.lines.forEach((i,a)=>{let[l,c]=s[a];D(i,"trimTo",0,r.t0),i.tween("trimTo",1,l,c,r.ease);let u=this.names[a];u&&(D(u,"opacity",0,r.t0),u.tween("opacity",1,c-(c-l)*.2,Math.min(r.t1,c+o*.1),r.ease))});for(let i of this.areas){let a=i.get("fillOpacity");D(i,"fillOpacity",0,r.t0),i.tween("fillOpacity",a,r.t0+o*.5,r.t1,r.ease)}}}}};function Nu(n,t={}){return new dr(n,t)}function lr(n,t,e,r){if(t-n<1e-4)return[];let o=St(0,0,r,r,n,t)[0].p,s=Array.from(o),i=s[s.length-2],a=s[s.length-1],l=(c,u,h,d)=>{s.push(c+(h-c)/3,u+(d-u)/3,c+(h-c)*2/3,u+(d-u)*2/3,h,d)};if(e>.01){let c=St(0,0,e,e,t,n)[0].p;l(i,a,c[0],c[1]);for(let u=2;u<c.length;u++)s.push(c[u]);l(c[c.length-2],c[c.length-1],o[0],o[1])}else l(i,a,0,0),l(0,0,o[0],o[1]);return[Mt(s,!0)]}var fn=class extends N{wedges=[];labels=[];leaders=[];centerText=null;shares;inner;outer;gap;constructor(t,e={}){super(),this.outer=e.radius??240,this.inner=this.outer*(e.hole??0),this.gap=e.gap??(this.inner>0?.018:.008);let r=t.reduce((i,a)=>i+Math.max(0,a.value),0)||1;this.shares=t.map(i=>Math.max(0,i.value)/r);let o=e.labelSize??20,s=this.angles(this.shares);if(t.forEach((i,a)=>{let l=i.color??re[a%re.length],[c,u]=s[a],h=new N(lr(c,u,this.inner,this.outer)).fill(l,.86);this.wedges.push(h),this.add(h)}),(e.labels??!0)&&t.forEach((i,a)=>{let[l,c]=s[a],u=(l+c)/2,h=Math.cos(u),d=Math.sin(u),m=this.outer+6,p=this.outer+30,f=h*p,b=d*p,y=f+(h>=0?18:-18),g=new N(Z([[h*m,d*m],[f,b],[y,b]])).stroke("faint",1.25),k=e.percent??!0?`${i.label} ${Math.round(this.shares[a]*100)}%`:i.label,x=It(k,o,"ink");x.at(y+(h>=0?8+x.width/2:-8-x.width/2),b),this.leaders.push(g),this.labels.push(x),this.add(g,x)}),e.centerLabel){let i=_(e.centerLabel,{size:e.centerSize??Math.max(24,this.inner*.34),font:"serif",color:"ink"}).at(0,0);this.centerText=i,this.add(i)}}angles(t,e=1){let r=-Math.PI/2;return t.map(o=>{let s=o*Math.PI*2*e,i=Math.min(this.gap*e,s*.45),a=[r+i/2,r+s-i/2];return r+=s,a})}enter(t={}){return{label:"pie.enter",duration:t.duration??1.6,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=e.t1-e.t0,o=e.t0+r*.78;this.wedges.forEach((s,i)=>{let a=l=>{let[c,u]=this.angles(this.shares,l)[i];return lr(c,u,this.inner,this.outer)};s.track("path").step(e.t0,[]),s.track("path").add({t0:e.t0,t1:o,ease:e.ease,to:a(1),at:a})});for(let s of[...this.labels,...this.leaders,...this.centerText?[this.centerText]:[]])D(s,"opacity",0,e.t0),s.tween("opacity",1,e.t0+r*.62,e.t1,e.ease)}}}update(t,e={}){return{label:"pie.update",duration:e.duration??1.1,ease:e.ease,schedule:r=>{let o=t.reduce((a,l)=>a+Math.max(0,l),0)||1,s=t.map(a=>Math.max(0,a)/o),i=[...this.shares];this.wedges.forEach((a,l)=>{let c=u=>{let h=i.map((p,f)=>p+((s[f]??0)-p)*u),[d,m]=this.angles(h)[l];return lr(d,m,this.inner,this.outer)};a.track("path").add({t0:r.t0,t1:r.t1,ease:r.ease,to:c(1),at:c})});for(let a of[...this.labels,...this.leaders])a.tween("opacity",0,r.t0,r.t0+(r.t1-r.t0)*.3,r.ease);s.forEach((a,l)=>{this.shares[l]=a})}}}};function Pu(n,t={}){return new fn(n,t)}function Ou(n,t={}){return new fn(n,{hole:.62,...t})}var De=class extends N{cells=[];rowLabels=[];columnLabels=[];numbers=[];rowCount;colCount;stops;domain;constructor(t,e={}){super(),this.rowCount=t.length,this.colCount=Math.max(0,...t.map(m=>m.length));let r=e.cellWidth??e.cell??44,o=e.cellHeight??e.cell??44,s=e.gap??2,i=t.flat();this.domain=e.domain??[Math.min(...i),Math.max(...i)];let a=(e.colors??["surface","blue","yellow"]).map(m=>Ft(m));this.stops=a.map((m,p)=>[a.length===1?0:p/(a.length-1),m]);let l=this.colCount*r+(this.colCount-1)*s,c=this.rowCount*o+(this.rowCount-1)*s,u=e.labelSize??16,h=e.valueSize??Math.min(o*.38,r*.36),d=e.format??(m=>(Math.round(m*100)/100).toString());t.forEach((m,p)=>{let f=[],b=[];m.forEach((y,g)=>{let w=-l/2+g*(r+s)+r/2,k=-c/2+p*(o+s)+o/2,x=this.colorFor(y),M=new N(K(-r/2,-o/2,r,o,e.radius??0)).fill(x).at(w,k);if(f.push(M),this.add(M),e.values){let v=_(d(y),{size:h,font:"mono",color:ts(x)>.32?"#101114":"#f2efe6"}).at(w,k);b.push(v),this.add(v)}}),this.cells.push(f),this.numbers.push(b)}),e.rowLabels?.forEach((m,p)=>{let f=It(m,u),b=-c/2+p*(o+s)+o/2;f.at(-l/2-10-f.width/2,b),this.rowLabels.push(f),this.add(f)}),e.columnLabels?.forEach((m,p)=>{let f=It(m,u),b=-l/2+p*(r+s)+r/2,y=e.columnLabelAngle??0;if(y!==0){let g=f.width;f.at(b+Math.cos(y)*g/2,-c/2-12+Math.sin(y)*g/2),f.set("rotation",y)}else f.at(b,-c/2-10-u/2);this.columnLabels.push(f),this.add(f)})}colorFor(t){let[e,r]=this.domain;return lt(this.stops,Math.max(0,Math.min(1,(t-e)/(r-e||1))))}cell(t,e){let r=this.cells[t]?.[e];if(!r)throw new Error(`Heatmap has no cell (${t}, ${e}). It is ${this.rowCount} by ${this.colCount}.`);return r}row(t){return[...this.cells[t]??[]]}col(t){return this.cells.map(e=>e[t]).filter(Boolean)}enter(t={}){return{label:"heatmap.enter",duration:t.duration??1.6,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=e.t1-e.t0,o=this.rowCount+this.colCount-1,s=r*.5,i=o>1?(r-s)/(o-1):0;this.cells.forEach((a,l)=>a.forEach((c,u)=>{let h=e.t0+(l+u)*i;D(c,"opacity",0,e.t0),c.tween("opacity",1,h,h+s,e.ease);let d=this.numbers[l]?.[u];d&&(D(d,"opacity",0,e.t0),d.tween("opacity",1,h,h+s,e.ease))}));for(let a of[...this.rowLabels,...this.columnLabels])D(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0,e.t0+r*.4,e.ease)}}}update(t,e={}){return{label:"heatmap.update",duration:e.duration??1,ease:e.ease,schedule:r=>{t.forEach((o,s)=>o.forEach((i,a)=>{let l=this.cells[s]?.[a];l&&l.tween("fill",this.colorFor(i),r.t0,r.t1,r.ease)}))}}}};function Au(n,t={}){return new De(n,t)}var mr=null,is=null;function Qi(){if(mr)return mr;throw is??=import("./dagre.esm-6F3RIGLP.js").then(n=>{mr=n.default??n}),new At(is)}var fr=class extends N{shape;caption=null;halfWidth=0;halfHeight=0;round=!0;edgePoint(t,e,r,o,s=0){let i=r-t,a=o-e,l=Math.hypot(i,a)||1;if(this.round)return[t+i/l*(this.halfWidth+s),e+a/l*(this.halfWidth+s)];let c=i===0?1/0:this.halfWidth/Math.abs(i),u=a===0?1/0:this.halfHeight/Math.abs(a),h=Math.min(c,u);return[t+i*h+i/l*s,e+a*h+a/l*s]}},br=class extends N{shaft;tip=null;caption=null;from="";to="";tipSize=14};function pr(n,t){let e=Pt(n);if(e<=t*1.1)return{head:[],trimmed:n};let r=1-t/e,o=Jt(n,0,r),[s,i]=Nt(n,1),[a,l]=ge(n,.997),c=t*.38,u=s-a*t,h=i-l*t;return{head:Z([[s,i],[u-l*c,h+a*c],[u+l*c,h-a*c]],!0),trimmed:o}}var bn=class extends N{nodes=new Map;edges=[];edgeLayer=new N;nodeLayer=new N;specs;constructor(t,e,r={}){super(),this.specs=t;let o=r.radius??30,s=r.labelSize??26,i=p=>p.width?[p.width,p.height??s*2]:[(p.radius??o)*2,(p.radius??o)*2],a=r.layout??"dagre",l=new Map,c=new Map;if(a==="dagre"){let p=Qi(),f=new p.graphlib.Graph({multigraph:!0});f.setGraph({rankdir:r.direction??"LR",nodesep:r.nodeGap??60,ranksep:r.rankGap??110,edgesep:24,ranker:"network-simplex"}),f.setDefaultEdgeLabel(()=>({}));for(let w of t){let[k,x]=i(w);f.setNode(w.id,{width:k,height:x})}e.forEach((w,k)=>f.setEdge(w.from,w.to,{},String(k))),p.layout(f);let b=f.graph(),y=(b.width??0)/2,g=(b.height??0)/2;for(let w of t){let k=f.node(w.id);l.set(w.id,[k.x-y,k.y-g])}e.forEach((w,k)=>{let x=f.edge({v:w.from,w:w.to,name:String(k)});x?.points&&c.set(w,x.points.map(M=>[M.x-y,M.y-g]))})}else if(a==="circle"){let p=Math.min(r.width??700,r.height??700)/2;t.forEach((f,b)=>{let y=-Math.PI/2+b/t.length*Math.PI*2;l.set(f.id,[Math.cos(y)*p,Math.sin(y)*p])})}else if(a==="force")l=ea(t,e,r.width??900,r.height??620,r.seed??3);else for(let p of t)l.set(p.id,p.at??[0,0]);let u=r.nodeColor??"blue";for(let p of t){let f=new fr,b=p.color??u,[y,g]=i(p);f.halfWidth=y/2,f.halfHeight=g/2,f.round=!p.width,f.shape=new N(p.width?K(-y/2,-g/2,y,g,8):Dt(0,0,y/2)).fill(b,r.fillOpacity??.16).stroke(b,2.5),f.add(f.shape),p.label&&(f.caption=p.math?st(p.label,{size:s,color:"ink",display:!1}):_(p.label,{size:s,color:"ink"}),f.add(f.caption.at(0,0))),f.named(p.id),f.at(l.get(p.id)??[0,0]),this.nodes.set(p.id,f),this.nodeLayer.add(f)}let h=r.directed??!0,d=r.edgeColor??"dim",m=r.edgeLabelSize??20;for(let p of e){let f=this.nodes.get(p.from),b=this.nodes.get(p.to);if(!f||!b)throw new Error(`Graph edge ${p.from} -> ${p.to} refers to a node that does not exist.`);let y=new br;y.from=p.from,y.to=p.to;let g=l.get(p.from),w=l.get(p.to),k=c.get(p),x=(r.direction??"LR")==="LR"||r.direction==="RL",M=ta(f,b,g,w,k,x),v=p.directed??h,P=p.color??d,{head:O,trimmed:A}=v?pr(M,y.tipSize):{head:[],trimmed:M};if(y.shaft=new N(A).stroke(P,p.width??2.2),p.dash&&y.shaft.dash(p.dash),y.add(y.shaft),O.length&&(y.tip=new N(O).fill(P),y.add(y.tip)),p.label){let[R,$]=Nt(M,.5),z=_(p.label,{size:m,color:"ink",font:"mono"}).at(R,$),B=m*.34,W=new N(K(R-z.width/2-B,$-m*.68,z.width+B*2,m*1.36,4)).fill("bg");y.caption=new N().add(W,z),y.add(y.caption)}this.edges.push(y),this.edgeLayer.add(y)}this.add(this.edgeLayer,this.nodeLayer)}node(t){let e=this.nodes.get(t);if(!e)throw new Error(`Graph has no node ${JSON.stringify(t)}.`);return e}edge(t,e){let r=this.edges.find(o=>o.from===t&&o.to===e)??this.edges.find(o=>o.from===e&&o.to===t);if(!r)throw new Error(`Graph has no edge ${t} -> ${e}.`);return r}enter(t={}){let e=t.lag??.14;return{label:"graph.enter",duration:t.duration??2,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=this.specs.map(a=>this.nodes.get(a.id)),s=Vt(o.length,e,r.t0,r.t0+(r.t1-r.t0)*.78),i=new Map;o.forEach((a,l)=>{let[c,u]=s[l];i.set(a,u),gn(a,r.t0,c,u,r.ease)});for(let a of this.edges){let l=i.get(this.nodes.get(a.from))??r.t0,c=Math.min(r.t1,l+(r.t1-r.t0)*.22);D(a.shaft,"trimTo",0,r.t0),a.shaft.tween("trimTo",1,l,c,r.ease);for(let u of[a.tip,a.caption])u&&(D(u,"opacity",0,r.t0),u.tween("opacity",1,c-(c-l)*.3,c,r.ease))}}}}pulseEdge(t,e,r={}){let o=this.edge(t,e);return{...Dn(o.shaft,{color:r.color??"yellow",length:r.length??.3,...r}),label:"graph.pulse"}}visit(t,e={}){let r=this.node(t),o=e.color??"yellow";return{label:"graph.visit",duration:e.duration??.6,ease:e.ease,schedule:s=>{let i=X(o);r.shape.tween("stroke",i,s.t0,s.t1,s.ease),r.shape.tween("fill",i,s.t0,s.t1,s.ease);let a=s.t1-s.t0,l=r.get("sx");r.tween("sx",l*1.16,s.t0,s.t0+a*.45,s.ease),r.tween("sy",l*1.16,s.t0,s.t0+a*.45,s.ease),r.tween("sx",l,s.t0+a*.45,s.t1,s.ease),r.tween("sy",l,s.t0+a*.45,s.t1,s.ease)}}}moveNode(t,e,r={}){let o=this.node(t);return{label:"graph.move",duration:r.duration??1,ease:r.ease,schedule:s=>{let i=o.get("x"),a=o.get("y");o.tween("x",e[0],s.t0,s.t1,s.ease),o.tween("y",e[1],s.t0,s.t1,s.ease);for(let l of this.edges){if(l.from!==t&&l.to!==t)continue;let c=this.node(l.from===t?l.to:l.from),u=me(c,"x",s.t0),h=me(c,"y",s.t0),d=p=>{let f=i+(e[0]-i)*p,b=a+(e[1]-a)*p,y=l.from===t?o.edgePoint(f,b,u,h,2):c.edgePoint(u,h,f,b,2),g=l.from===t?c.edgePoint(u,h,f,b,4):o.edgePoint(f,b,u,h,4);return Z([y,g])},m=p=>l.tip?pr(d(p),l.tipSize).trimmed:d(p);if(l.shaft.track("path").add({t0:s.t0,t1:s.t1,ease:s.ease,to:m(1),at:m}),l.tip){let p=f=>pr(d(f),l.tipSize).head;l.tip.track("path").add({t0:s.t0,t1:s.t1,ease:s.ease,to:p(1),at:p})}}}}}};function ta(n,t,e,r,o,s){let i=o?o.slice(1,-1):[],a=i[0]??r,l=i[i.length-1]??e,c=n.edgePoint(e[0],e[1],a[0],a[1],2),u=t.edgePoint(r[0],r[1],l[0],l[1],4);if(!o)return Z([c,u]);if(i.length<=1){let h=u[0]-c[0],d=u[1]-c[1];if(Math.abs(s?d:h)<2)return Z([c,u]);let m=(s?h:d)*.5,p=s?`${c[0]+m} ${c[1]}`:`${c[0]} ${c[1]+m}`,f=s?`${u[0]-m} ${u[1]}`:`${u[0]} ${u[1]-m}`;return vt(`M${c[0]} ${c[1]}C${p} ${f} ${u[0]} ${u[1]}`)}return Lt([c,...i.slice(1,-1),u])}function gn(n,t,e,r,o){let s=me(n,"sx",e),i=me(n,"sy",e);D(n,"sx",s*.001,t),D(n,"sy",i*.001,t),n.tween("sx",s,e,r,o),n.tween("sy",i,e,r,o)}function ea(n,t,e,r,o){let s=Be(o),i=n.map(d=>d.id),a=new Float64Array(i.length),l=new Float64Array(i.length);for(let d=0;d<i.length;d++)a[d]=(s()-.5)*e,l[d]=(s()-.5)*r;let c=new Map(i.map((d,m)=>[d,m])),u=Math.sqrt(e*r/Math.max(1,i.length))*.72,h=Math.max(e,r)*.12;for(let d=0;d<420;d++){let m=new Float64Array(i.length),p=new Float64Array(i.length);for(let f=0;f<i.length;f++)for(let b=f+1;b<i.length;b++){let y=a[f]-a[b],g=l[f]-l[b],w=Math.max(1,Math.hypot(y,g)),k=u*u/w;m[f]+=y/w*k,p[f]+=g/w*k,m[b]-=y/w*k,p[b]-=g/w*k}for(let f of t){let b=c.get(f.from),y=c.get(f.to);if(b===void 0||y===void 0)continue;let g=a[b]-a[y],w=l[b]-l[y],k=Math.max(1,Math.hypot(g,w)),x=k*k/u;m[b]-=g/k*x,p[b]-=w/k*x,m[y]+=g/k*x,p[y]+=w/k*x}for(let f=0;f<i.length;f++){let b=Math.max(1e-6,Math.hypot(m[f],p[f]));a[f]+=m[f]/b*Math.min(b,h),l[f]+=p[f]/b*Math.min(b,h),a[f]=Math.max(-e/2,Math.min(e/2,a[f])),l[f]=Math.max(-r/2,Math.min(r/2,l[f]))}h*=.985}return new Map(i.map((d,m)=>[d,[a[m],l[m]]]))}function Du(n,t,e={}){return new bn(n,t,e)}var gr=class extends bn{depths=new Map;constructor(t,e={}){let r=[],o=[],s=new Map,i=e.levelGap??130,a=e.siblingGap??96,l=0,c=0,u=(f,b)=>{let y=f.id??`n${l++}`;s.set(y,b);let g=f.children??[],w,k={id:y,label:f.label,color:f.color,math:f.math};if(r.push(k),g.length===0)w=c++;else{let x=g.map(M=>u(M,b+1));w=(x[0].position+x[x.length-1].position)/2;for(let M of x)o.push({from:y,to:M.id,directed:!1})}return k.at=e.direction==="right"?[b*i,w*a]:[w*a,b*i],{id:y,position:w}};u(t,0);let h=r.map(f=>f.at[0]),d=r.map(f=>f.at[1]),m=(Math.min(...h)+Math.max(...h))/2,p=(Math.min(...d)+Math.max(...d))/2;for(let f of r)f.at=[f.at[0]-m,f.at[1]-p];super(r,o,{layout:"manual",radius:e.radius??28,labelSize:e.labelSize??24,nodeColor:e.nodeColor,edgeColor:e.edgeColor,fillOpacity:e.fillOpacity,directed:!1});for(let[f,b]of s)this.depths.set(f,b)}enter(t={}){return{label:"tree.enter",duration:t.duration??2,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=Math.max(...this.depths.values())+1,o=(e.t1-e.t0)/r;for(let[s,i]of this.nodes){let a=this.depths.get(s)??0,l=e.t0+a*o;gn(i,e.t0,l,l+o,e.ease)}for(let s of this.edges){let i=this.depths.get(s.to)??1,a=e.t0+(i-1)*o+o*.3;D(s.shaft,"trimTo",0,e.t0),s.shaft.tween("trimTo",1,a,a+o*.8,e.ease)}}}}};function Gu(n,t={}){return new gr(n,t)}var yr=class extends N{slots=[];indexLabels=[];items=[];cellSize;step;constructor(t,e={}){super();let r=this.cellSize=e.cell??72,o=e.gap??6;this.step=r+o;let s=e.size??r*.38,i=e.color??"blue",a=-((t.length-1)*this.step)/2;t.forEach((l,c)=>{let u=a+c*this.step,h=new N(K(-r/2,-r/2,r,r,6)).stroke("faint",1.5).at(u,0);if(this.slots.push(h),this.add(h),e.indices??!0){let d=_(String(c),{size:e.indexSize??Math.max(13,r*.2),color:"faint",font:"mono"}).at(u,r/2+(e.indexSize??r*.2)+2);this.indexLabels.push(d),this.add(d)}}),t.forEach((l,c)=>{let u=a+c*this.step,h=new N().at(u,0),d=new N(K(-r/2+2,-r/2+2,r-4,r-4,5)).fill(i,.16).stroke(i,2),m=_(String(l),{size:s,font:e.font??"mono",color:"ink"}).at(0,0);h.add(d,m),h.data.box=d,h.data.value=l,this.items.push(h),this.add(h)})}cell(t){let e=this.items[t];if(!e)throw new Error(`Array has no index ${t}.`);return e}slotAt(t){return[this.slots[t].get("x"),this.slots[t].get("y")]}swap(t,e,r={}){return{label:"array.swap",duration:r.duration??.8,ease:r.ease,schedule:o=>{let s=this.items[t],i=this.items[e],[a,l]=this.slotAt(t),[c,u]=this.slotAt(e),h=r.lift??this.cellSize*.9+Math.abs(t-e)*6,d=(m,p,f,b,y,g)=>{m.track("x").add({t0:o.t0,t1:o.t1,ease:o.ease,to:b,at:w=>p+(b-p)*w}),m.track("y").add({t0:o.t0,t1:o.t1,ease:o.ease,to:y,at:w=>f+(y-f)*w-g*h*4*w*(1-w)})};d(s,a,l,c,u,1),d(i,c,u,a,l,-1),this.items[t]=i,this.items[e]=s}}}mark(t,e,r={}){let o=this.cell(t);return{...uo(o.data.box,e,{duration:.35,...r}),label:"array.mark"}}enter(t={}){let e=t.lag??.2;return{label:"array.enter",duration:t.duration??1.2,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=Vt(this.items.length,e,r.t0,r.t1);this.items.forEach((s,i)=>{let[a,l]=o[i];gn(s,r.t0,a,l,r.ease),D(this.slots[i],"opacity",0,r.t0),this.slots[i].tween("opacity",1,a,l,r.ease);let c=this.indexLabels[i];c&&(D(c,"opacity",0,r.t0),c.tween("opacity",1,a,l,r.ease))})}}}};function ju(n,t={}){return new yr(n,t)}var as={ts:new Set("const let var function return if else for while do switch case break continue new class extends implements interface type enum import export from default async await yield try catch finally throw typeof instanceof in of this super null undefined true false void as readonly public private protected static get set".split(" ")),python:new Set("def return if elif else for while in not and or is class import from as with try except finally raise lambda yield pass break continue global nonlocal None True False self async await assert del print".split(" ")),rust:new Set("fn let mut pub struct enum impl trait use mod match if else for while loop return self Self as in where const static crate super true false ref move async await dyn type".split(" ")),go:new Set("func var const type struct interface package import return if else for range switch case default break continue go defer select chan map nil true false".split(" ")),sql:new Set("select from where join left right inner outer on group by order having limit as and or not in is null insert into values update set delete create table with distinct count sum avg min max".split(" ")),bash:new Set("if then else elif fi for do done while case esac in function return export local echo cd exit set".split(" ")),plain:new Set};function na(n,t="ts"){let e=t==="js"||t==="tsx"||t==="jsx"||t==="typescript"||t==="javascript"?"ts":t==="py"?"python":t,r=as[e]??as.ts,o=e==="sql",s=e==="python"||e==="bash",i=e==="sql",a=[];return n.split(`
3
+ `).forEach((l,c)=>{let u=0;for(;u<l.length;){let h=l.slice(u),d=(y,g)=>{a.push({text:y,kind:g,line:c}),u+=y.length},m=/^\s+/.exec(h);if(m){d(m[0],"space");continue}if(!s&&!i&&h.startsWith("//")||s&&h[0]==="#"||i&&h.startsWith("--")){d(h,"comment");continue}let p=/^("(?:[^"\\]|\\.)*"?|'(?:[^'\\]|\\.)*'?|`(?:[^`\\]|\\.)*`?)/.exec(h);if(p){d(p[0],"string");continue}let f=/^(0x[\da-fA-F_]+|\d[\d_]*(?:\.\d+)?(?:e[-+]?\d+)?)/.exec(h);if(f){d(f[0],"number");continue}let b=/^[A-Za-z_$][\w$]*/.exec(h);if(b){let y=b[0],g=h.slice(y.length),k=r.has(o?y.toLowerCase():y)?"keyword":/^\s*\(/.test(g)?"function":/^[A-Z]/.test(y)?"type":"plain";d(y,k);continue}d(h[0],"punctuation")}}),a}var ra={keyword:"purple",string:"green",number:"orange",comment:"faint",function:"blue",type:"teal",punctuation:"dim",plain:"ink"},wr=class extends N{lines=[];tokens=[];chars=[];panelNode=null;body=new N;source;bar;rowHeight;originY;contentWidth;constructor(t,e={}){super(),this.source=t;let r=e.size??26,o=this.rowHeight=r*(e.leading??1.5),s=xe("mono",400),i=r/s.unitsPerEm,a=s.advance(s.glyphFor(48))*i,l=na(t,e.language??"ts"),c=t.split(`
4
+ `),u=e.lineNumbers?(String(c.length).length+2)*a:0,h=e.padding??r*.9,d=Math.max(e.minWidth??0,Math.max(...c.map(g=>g.length))*a+u+h*2),m=c.length*o+h*2-(o-r);this.contentWidth=d;let p=-d/2+h+u,f=-m/2+h+r*.82;if(this.originY=f,e.panel??!0){let g=new N(K(-d/2,-m/2,d,m,8)).fill("surface").stroke("gridStrong",1);this.panelNode=g,this.add(g)}this.bar=new N().fill("yellow",.1),this.bar.base.visible=!1,this.add(this.bar);for(let g=0;g<c.length;g++){let w=new N;if(this.lines.push(w),this.body.add(w),e.lineNumbers){let k=String(g+1).padStart(String(c.length).length," "),x=p-u;for(let M of k)M!==" "&&w.add(ls(s,M,r,"faint",x,f+g*o)),x+=a}}let b={...ra,...e.colors},y=new Map;for(let g of l){let w=y.get(g.line)??0;y.set(g.line,w+g.text.length);let k={...g,glyphs:[]};if(this.tokens.push(k),g.kind==="space")continue;let x=b[g.kind];[...g.text].forEach((M,v)=>{let P=ls(s,M,r,x,p+(w+v)*a,f+g.line*o);k.glyphs.push(P),this.chars.push(P),this.lines[g.line].add(P)})}this.add(this.body)}line(t){let e=this.lines[t];if(!e)throw new Error(`Code has no line ${t}.`);return e}find(t){return this.tokens.filter(e=>e.text===t).flatMap(e=>e.glyphs)}focus(t,e={}){let r=new Set(typeof t=="number"?[t]:t);return{label:"code.focus",duration:e.duration??.6,ease:e.ease,schedule:o=>{this.lines.forEach((d,m)=>{d.tween("opacity",r.has(m)?1:e.dim??.28,o.t0,o.t1,o.ease)});let s=[...r].sort((d,m)=>d-m),i=s[0]??0,a=s[s.length-1]??i,l=this.originY-this.rowHeight*.32+(i+a)/2*this.rowHeight,c=a-i+1,u=K(-this.contentWidth/2+2,-this.rowHeight*c/2,this.contentWidth-4,this.rowHeight*c,3);me(this.bar,"visible",o.t0)?(this.bar.tween("y",l,o.t0,o.t1,o.ease),this.bar.tween("path",u,o.t0,o.t1,o.ease)):(D(this.bar,"x",0,o.t0),D(this.bar,"y",l,o.t0),this.bar.track("path").step(o.t0,u),D(this.bar,"visible",!0,o.t0),D(this.bar,"opacity",0,o.t0),this.bar.tween("opacity",1,o.t0,o.t1,o.ease)),e.color&&this.bar.tween("fill",X(e.color),o.t0,o.t1,o.ease)}}}unfocus(t={}){return{label:"code.unfocus",duration:t.duration??.5,ease:t.ease,schedule:e=>{for(let r of this.lines)r.tween("opacity",1,e.t0,e.t1,e.ease);this.bar.tween("opacity",0,e.t0,e.t1,e.ease),D(this.bar,"visible",!1,e.t1)}}}};function ls(n,t,e,r,o,s){let i=new N(ze(n,n.glyphFor(t.codePointAt(0)),e));return i.base.fill=X(r),i.base.trimEach=!0,i.data.key=t,i.at(o,s)}function Hu(n,t={}){return new wr(n,t)}function _u(n,t,e={}){let r=u=>u.tokens.filter(h=>h.kind!=="space"&&h.glyphs.length>0),o=r(n),s=r(t),i=Je(o.map(u=>u.text),s.map(u=>u.text)),a=new Map;i.forEach(([u,h],d)=>{o[u].glyphs.forEach((m,p)=>a.set(m,`m${d}:${p}`)),s[h].glyphs.forEach((m,p)=>a.set(m,`m${d}:${p}`))}),n.panelNode&&t.panelNode&&(a.set(n.panelNode,"panel"),a.set(t.panelNode,"panel"));let l=0;return{...we(n,t,{duration:1.5,...e,key:u=>{let h=a.get(u);return h===void 0&&(h=`only:${l++}`,a.set(u,h)),h}}),label:"morphCode"}}var xr=class extends N{neurons=[];links=[];edgeLayer=new N;neuronLayer=new N;captions=[];seed;layerColors;constructor(t,e={}){super();let r=e.width??1e3,o=e.height??560,s=e.radius??15,i=e.collapse??8,a=t.length>1?r/(t.length-1):0;this.seed=e.seed??11,this.layerColors=e.colors??["blue","teal","teal","yellow"];let l=e.edgeColor??"dim",c=e.edgeOpacity??.32,u=[];t.forEach((h,d)=>{let m=h>i?i:h,p=Math.min(s*3.6,o/Math.max(1,m+(h>i?1:0))),f=-r/2+d*a,b=[],y=[],g=this.layerColors[Math.min(d,this.layerColors.length-1)],w=Math.ceil(m/2);for(let x=0;x<m+(h>i?1:0);x++){let M=(x-(m+(h>i?1:0)-1)/2)*p;if(h>i&&x===w){this.neuronLayer.add(st("\\vdots",{size:s*1.9,color:"dim",display:!1}).at(f,M));continue}b.push([f,M]);let v=new N(Dt(0,0,s)).stroke(g,2.2).fill(g,.08).at(f,M);y.push(v),this.neuronLayer.add(v)}u.push(b),this.neurons.push(y);let k=e.layerLabels?.[d];if(k){let x=e.labelSize??22,M=_(k,{size:x,color:"dim"}).at(f,o/2+x*1.5);this.captions.push(M),this.add(M)}});for(let h=0;h+1<u.length;h++){let d=[];for(let m of u[h]){let p=[];for(let f of u[h+1]){let b=Math.hypot(f[0]-m[0],f[1]-m[1])||1,y=(f[0]-m[0])/b,g=(f[1]-m[1])/b,w=Y([m[0]+y*s,m[1]+g*s],[f[0]-y*s,f[1]-g*s],{stroke:l,width:1.1});w.set("strokeOpacity",c),p.push(w),this.edgeLayer.add(w)}d.push(p)}this.links.push(d)}this.add(this.edgeLayer,this.neuronLayer)}layer(t){return this.neurons[t]??[]}enter(t={}){return{label:"net.enter",duration:t.duration??2.2,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=e.t1-e.t0,o=this.neurons.length,s=r*.45,i=o>1?r*.55/(o-1):0;this.neurons.forEach((a,l)=>{let c=Vt(a.length,.12,e.t0+l*i,e.t0+l*i+s);a.forEach((u,h)=>gn(u,e.t0,c[h][0],c[h][1],e.ease))}),this.links.forEach((a,l)=>{let c=e.t0+l*i+s*.45;for(let u of a)for(let h of u)D(h,"trimTo",0,e.t0),h.tween("trimTo",1,c,c+s,e.ease)});for(let a of this.neuronLayer.children)a.get("path")||(D(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0+r*.3,e.t1,e.ease));for(let a of this.captions)D(a,"opacity",0,e.t0),a.tween("opacity",1,e.t0+r*.3,e.t1,e.ease)}}}activate(t,e,r={}){return{label:"net.activate",duration:r.duration??.45,ease:r.ease,schedule:o=>{this.neurons[t].forEach((s,i)=>{let a=Math.max(.04,Math.min(1,e[i]??0));s.tween("fillOpacity",a,o.t0,o.t1,o.ease),r.color&&s.tween("fill",X(r.color),o.t0,o.t1,o.ease)})}}}forward(t={}){let e=Be(this.seed),r=this.neurons.map((a,l)=>t.activations?.[l]??a.map(()=>e()*e())),o=t.color??"yellow",s=[];r.forEach((a,l)=>{if(s.push(this.activate(l,a,{duration:.35})),l+1>=this.neurons.length)return;let c=[];this.links[l].forEach((h,d)=>h.forEach((m,p)=>{c.push({link:m,score:(a[d]??0)*(r[l+1]?.[p]??0)})})),c.sort((h,d)=>d.score-h.score);let u=c.slice(0,t.pulses??10);s.push(Bn(...u.map(({link:h,score:d})=>Dn(h,{color:o,length:.42,width:1.5+d*3,glow:4,duration:.7}))))});let i=io(...s);return{...i,label:"net.forward",duration:t.duration??i.duration,ease:t.ease}}};function Ku(n,t={}){return new xr(n,t)}var kr=class extends N{chips=[];constructor(t,e={}){super();let r=e.size??22,o=e.gap??r*.28,s=e.subSize??r*.62,i=r*.42,a=r*.3,l=t.map(b=>typeof b=="string"?{text:b}:b),c=e.colors?Ie(l.length,...e.colors):null,u=0,h=0,d=[],m=r+a*2+(l.some(b=>b.sub)?s*1.4:0);for(let b=0;b<l.length;b++){let y=l[b],g=y.color??(c?c[b]:e.color??"blue"),w=_(y.text.replace(/ /g,"\xB7"),{size:r,font:e.font??"mono",color:"ink"}),k=Math.max(w.width,r*.5)+i*2,x=r+a*2;e.maxWidth!==void 0&&u>0&&u+k>e.maxWidth&&(u=0,h+=m+o);let M=new N,v=new N(K(-k/2,-x/2,k,x,e.radius??4)).fill(g,.18).stroke(g,1.5);M.add(v,w.at(0,0)),y.sub&&M.add(_(y.sub,{size:s,font:"mono",color:"dim"}).at(0,x/2+s*.82)),M.data.box=v,d.push({node:M,x:u+k/2,y:h,w:k}),u+=k+o}let p=Math.max(...d.map(b=>b.x+b.w/2),0),f=Math.max(...d.map(b=>b.y),0);for(let b of d)b.node.at(b.x-p/2,b.y-f/2),this.chips.push(b.node),this.add(b.node)}token(t){let e=this.chips[t];if(!e)throw new Error(`Token row has no token ${t}.`);return e}enter(t={}){let e=t.lag??.16;return{label:"tokens.enter",duration:t.duration??1.2,ease:t.ease,schedule:r=>{it(this,r.t0,r.stage);let o=Vt(this.chips.length,e,r.t0,r.t1);this.chips.forEach((s,i)=>{let[a,l]=o[i],c=s.get("y");D(s,"opacity",0,r.t0),D(s,"y",c+16,r.t0),s.tween("opacity",1,a,l,r.ease),s.tween("y",c,a,l,r.ease)})}}}arcs(t,e,r={}){let o=this.token(t).bounds(),s=new N,i=o.x+o.width/2,a=o.y-3;return e.forEach((l,c)=>{if(c===t||l<=.01)return;let u=this.token(c).bounds(),h=u.x+u.width/2,d=u.y-3,m=r.lift??40+Math.abs(h-i)*.22,p=vt(`M${i} ${a}C${i} ${a-m} ${h} ${d-m} ${h} ${d}`),f=new N(p).stroke(r.color??"yellow",.8+l*(r.maxWidth??6));f.set("strokeOpacity",.2+l*.8),s.add(f)}),s}};function Xu(n,t={}){return new kr(n,t)}function Yu(n,t,e,r={}){return new De(e,{cell:r.cell??42,gap:r.gap??2,colors:r.colors??["surface","teal","yellow"],domain:[0,Math.max(...e.flat())],values:r.values,rowLabels:n,columnLabels:t,labelSize:r.labelSize??18,columnLabelAngle:-Math.PI/4})}function qt(n,t,e,r="left"){let o=n.get("px");return n.at(r==="left"?t+o:r==="right"?t-o:t,e)}function _t(n){return n.get("px")*2}var vr=class extends N{frame;accentBar=null;titleNode;subtitleNode=null;badgeNode=null;rowLabels=[];rowValues=[];meters=[];tagNodes=[];boxWidth;boxHeight;valueSize;constructor(t){super();let e=t.size??14;this.valueSize=e;let r=e*.8,o=t.rows??[],s=e*1.56,i=_(t.title,{size:e*1.14,weight:600,color:"ink"}),a=t.subtitle?_(t.subtitle,{size:e*.86,font:"mono",color:"dim"}):null,l=t.badgeTone??t.accent??"dim",c=t.badge?_(t.badge,{size:e*.78,font:"mono",color:l}):null,u=o.map(M=>_(M.label,{size:e,color:"dim"})),h=o.map(M=>M.value!==void 0?_(M.value,{size:e,font:"mono",color:M.tone??"ink"}):null),d=e*3.6,m=Math.max(_t(i)+(c?_t(c)+e*1.6:0),a?_t(a):0,...o.map((M,v)=>_t(u[v])+(h[v]?_t(h[v])+e*1.1:0)+(M.spark?d+e*.6:0)),0),p=this.boxWidth=Math.max(t.width??0,m+r*2),f=e*1.4+(a?e*1.2:0),b=o.reduce((M,v)=>M+s+(v.meter!==void 0?e*.32:0),0),y=t.tags?.length?e*1.72:0,g=this.boxHeight=r*1.5+f+(o.length?e*.55:0)+b+y,w=-p/2+r,k=p/2-r;if(this.frame=new N(K(-p/2,-g/2,p,g,t.radius??4)).fill(t.fill??"surface").stroke(t.border??"gridStrong",1),this.add(this.frame),t.accent){let M=new N(K(-p/2,-g/2+1,2.5,g-2)).fill(t.accent);this.accentBar=M,this.add(M)}let x=-g/2+r*.75+e*.62;if(this.titleNode=qt(i,w,x),this.add(i),c&&(this.badgeNode=qt(c,k,x,"right"),this.add(c)),x+=e*1.3,a&&(this.subtitleNode=qt(a,w,x-e*.1),this.add(a),x+=e*1.2),o.length){let M=x-e*.38;this.add(Y([-p/2+r,M],[p/2-r,M],{stroke:"grid",width:1})),x+=e*.5}if(o.forEach((M,v)=>{qt(u[v],w,x),this.rowLabels.push(u[v]),this.add(u[v]);let P=k,O=h[v];if(O&&(qt(O,P,x,"right"),this.add(O),P-=_t(O)+e*.7),this.rowValues.push(O??null),M.spark){let A=oa(M.spark,{width:d,height:e*.82,color:M.tone??"blue",dotted:!0,weight:1.2});this.add(A.at(P-d/2,x-e*.1))}if(x+=s,M.meter!==void 0){let A=x-e*.62;this.add(Y([w,A],[k,A],{stroke:"grid",width:2}));let R=Y([w,A],[w+(k-w)*Math.max(0,Math.min(1,M.meter)),A],{stroke:M.tone??"blue",width:2});R.set("cap","butt"),this.meters.push(R),this.add(R),x+=e*.32}}),t.tags?.length){let M=w,v=g/2-r*.7-e*.4;for(let P of t.tags){let O=_(P,{size:e*.78,font:"mono",color:"dim"}),A=_t(O)+e*.7,R=new N(K(M,v-e*.62,A,e*1.24,2)).stroke("gridStrong",1);qt(O,M+e*.35,v),this.tagNodes.push(O),this.add(R,O),M+=A+e*.34}}}port(t,e=0){let r=this.bounds(),o=r.x+r.width/2,s=r.y+r.height/2;return t==="left"?[r.x,s+e*r.height/2]:t==="right"?[r.x+r.width,s+e*r.height/2]:t==="top"?[o+e*r.width/2,r.y]:[o+e*r.width/2,r.y+r.height]}enter(t={}){return{label:"infoBox.enter",duration:t.duration??.9,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=e.t1-e.t0,o=this.frame.get("fillOpacity");D(this.frame,"trimTo",0,e.t0),D(this.frame,"fillOpacity",0,e.t0),this.frame.tween("trimTo",1,e.t0,e.t0+r*.65,e.ease),this.frame.tween("fillOpacity",o,e.t0+r*.2,e.t0+r*.8,e.ease);let s=this.children.filter(a=>a!==this.frame),i=Vt(s.length,.06,e.t0+r*.25,e.t1);s.forEach((a,l)=>{let[c,u]=i[l],h=a.get("opacity");D(a,"opacity",0,e.t0),a.tween("opacity",h,c,u,e.ease)})}}}setValue(t,e,r={}){let o=this.rowValues[t];if(!o)throw new Error(`Info box row ${t} has no value to change.`);let s=_(e,{size:this.valueSize,font:"mono",color:r.tone??"ink"}),i=o.get("x")+o.get("px");qt(s,i,o.get("y"),"right");let a=we(o,s,{duration:.5,...r});return{...a,label:"infoBox.setValue",schedule:l=>{this.add(s),this.rowValues[t]=s,a.schedule(l)}}}};function rh(n){return new vr(n)}function oa(n,t={}){let e=t.width??80,r=t.height??20,o=Math.min(...n),i=Math.max(...n)-o||1,a=n.map((u,h)=>[(h/Math.max(1,n.length-1)-.5)*e,(.5-(u-o)/i)*r]),l=t.color??"blue",c=new N;return t.area&&c.add(new N(Z([...a,[e/2,r/2],[-e/2,r/2]],!0)).fill(l,t.area)),c.add(new N(n.length>2?Lt(a):Z(a)).stroke(l,t.weight??1.5)),t.dotted&&c.add(gt((t.weight??1.5)*1.5,l).at(a[a.length-1])),c}var cs={left:[-1,0],right:[1,0],top:[0,-1],bottom:[0,1]};function us(n,t,e){let r=n.x+n.width/2,o=n.y+n.height/2;return t==="left"?[n.x,o+e*n.height/2]:t==="right"?[n.x+n.width,o+e*n.height/2]:t==="top"?[r+e*n.width/2,n.y]:[r+e*n.width/2,n.y+n.height]}function sa(n,t){let e=Math.max(t.x-(n.x+n.width),n.x-(t.x+t.width)),r=Math.max(t.y-(n.y+n.height),n.y-(t.y+t.height)),o=n.x+n.width/2,s=n.y+n.height/2,i=t.x+t.width/2,a=t.y+t.height/2;return e>=r?i>=o?["right","left"]:["left","right"]:a>=s?["bottom","top"]:["top","bottom"]}function Mr(n,t){let e=`M${n[0][0]} ${n[0][1]}`;for(let o=1;o<n.length-1;o++){let s=n[o-1],i=n[o],a=n[o+1],l=Math.hypot(i[0]-s[0],i[1]-s[1]),c=Math.hypot(a[0]-i[0],a[1]-i[1]),u=Math.min(t,l/2,c/2);if(u<.5){e+=`L${i[0]} ${i[1]}`;continue}let h=i[0]-(i[0]-s[0])/(l||1)*u,d=i[1]-(i[1]-s[1])/(l||1)*u,m=i[0]+(a[0]-i[0])/(c||1)*u,p=i[1]+(a[1]-i[1])/(c||1)*u;e+=`L${h} ${d}Q${i[0]} ${i[1]} ${m} ${p}`}let r=n[n.length-1];return vt(`${e}L${r[0]} ${r[1]}`)}var Nr=class extends N{fromEnd;toEnd;options;pulses=[];plate=null;caption=null;constructor(t,e,r={}){super([]),this.fromEnd=t,this.toEnd=e,this.options=r,this.base.stroke=X(r.color??"dim"),this.base.strokeWidth=r.width??1.6,this.draw=o=>this.build(o)}anchors(){let{fromEnd:t,toEnd:e,options:r}=this,o=r.gap??3,s=m=>m instanceof N?m.bounds():{x:m[0],y:m[1],width:0,height:0},i=s(t),a=s(e),[l,c]=sa(i,a),u=r.from??l,h=r.to??c,d=(m,p,f,b)=>{let y=cs[f];if(!(m instanceof N))return{point:m,normal:y};let[g,w]=us(p,f,b);return{point:[g+y[0]*o,w+y[1]*o],normal:y}};return[d(t,i,u,r.fromOffset??0),d(e,a,h,r.toOffset??0)]}routeNow(){let[t,e]=this.anchors(),r=this.options.route??"curve";if(r==="straight")return Z([t.point,e.point]);if(r==="ortho"){let l=this.options.radius??8,c=t.normal[0]!==0,u=e.normal[0]!==0;if(c&&u){let d=(t.point[0]+e.point[0])/2;return Mr([t.point,[d,t.point[1]],[d,e.point[1]],e.point],l)}if(!c&&!u){let d=(t.point[1]+e.point[1])/2;return Mr([t.point,[t.point[0],d],[e.point[0],d],e.point],l)}let h=c?[e.point[0],t.point[1]]:[t.point[0],e.point[1]];return Mr([t.point,h,e.point],l)}let o=Math.hypot(e.point[0]-t.point[0],e.point[1]-t.point[1]),s=Math.max(18,o*(this.options.curvature??.42)),i=[t.point[0]+t.normal[0]*s,t.point[1]+t.normal[1]*s],a=[e.point[0]+e.normal[0]*s,e.point[1]+e.normal[1]*s];return vt(`M${t.point[0]} ${t.point[1]}C${i[0]} ${i[1]} ${a[0]} ${a[1]} ${e.point[0]} ${e.point[1]}`)}build(t){let e=this.parent&&this.parent!==null?Wt(this.worldMatrix()):zt,r=ot(this.routeNow(),e),o=Pt(r);if(o<1)return[];let s=this.get("trimTo"),i=this.options,a=this.get("stroke"),l=this.get("strokeWidth"),c=[],u=i.tip??!0,h=u?i.tipSize??Math.max(7,l*4.4):0,d=s*(1-h/o),m=Jt(r,this.get("trimFrom"),d),p=a??X("dim");if(m.length){let f=new N(m).stroke(p,l);(i.dash||i.flow)&&f.dash(i.dash??[6,6],i.flow?-t*i.flow:0),f.set("strokeOpacity",this.get("strokeOpacity")),c.push(f)}if(u&&s>.02){let[f,b]=Nt(r,s),[y,g]=ge(r,Math.min(.997,s)),w=h*.38,k=f-y*h,x=b-g*h;c.push(new N(Z([[f,b],[k-g*w,x+y*w],[k+g*w,x-y*w]],!0)).fill(p))}for(let f of this.pulses){if(t<f.t0||t>=f.t1)continue;let b=f.ease((t-f.t0)/(f.t1-f.t0)),y=Math.max(0,b*(1+f.length)-f.length),g=Math.min(1,b*(1+f.length)),w=Jt(r,y,g);w.length&&c.push(new N(w).stroke(f.color,f.width).glow(f.glow))}if(i.label&&s>.5){let f=i.labelSize??12;this.caption??=_(i.label,{size:f,font:"mono",color:i.labelColor??"dim"});let b=_t(this.caption),y=f*.35;this.plate??=new N(K(-b/2-y,-f*.72,b+y*2,f*1.44,2)).fill(i.labelBackground??"bg");let[g,w]=Nt(r,i.labelAt??.5),k=Math.min(1,(s-.5)*4);c.push(this.plate.at(g,w).opacity(k),this.caption.at(g,w).opacity(k))}return c}pulse(t={}){return{label:"connector.pulse",duration:t.duration??.9,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage),this.pulses.push({t0:e.t0,t1:e.t1,ease:e.ease,color:t.color??"yellow",length:t.length??.22,width:t.width??this.get("strokeWidth")+1.2,glow:t.glow??6})}}}pointNow(t=.5){return Nt(this.routeNow(),t)}};function oh(n,t,e={}){return new Nr(n,t,e)}function sh(n,t={}){let e=t.size??13,r=(t.direction??"row")==="row",o=t.gap??(r?e*1.5:e*.6),s=e*1.5,i=new N,a=0,l=[];for(let d of n){let m=d.color??"dim",p=d.kind??"swatch",f=p==="line"?Y([-s/2,0],[s/2,0],{stroke:m,width:2.2}):p==="dash"?Y([-s/2,0],[s/2,0],{stroke:m,width:2,dash:[4,3.5]}):p==="dot"?gt(e*.32,m):p==="ring"?Wo(e*.32,{stroke:m,width:1.6}):new N(K(-e*.42,-e*.42,e*.84,e*.84,1.5)).fill(m),b=_(d.label,{size:e,color:"dim"}),y=s+e*.5+_t(b),g=new N;g.add(f.at(s/2,0)),qt(b,s+e*.5,0),g.add(b),l.push({node:g,width:y})}let c=l.reduce((d,m)=>d+m.width,0)+o*Math.max(0,l.length-1),u=Math.max(0,...l.map(d=>d.width)),h=e*1.2+o;return l.forEach((d,m)=>{r?(d.node.at(-c/2+a,0),a+=d.width+o):d.node.at(-u/2,(m-(l.length-1)/2)*h),i.add(d.node)}),i}var Pr=class extends N{leader;marker;body;titleNode=null;constructor(t,e,r={}){super();let o=r.size??15,s=r.color??"yellow",i=r.side??"right",a=r.distance??72,l=r.width??280,c=cs[i],u=t instanceof N?t.bounds():{x:t[0],y:t[1],width:0,height:0},h=t instanceof N?us(u,i,0):t,d=r.title?_(r.title,{size:o,weight:600,color:s}):null,m=_(e,{size:o*.94,color:r.bodyColor??"dim",maxWidth:l,leading:1.36}),p=d?o*1.42:0,f=Math.max(m.width,d?_t(d):0),b=m.height,y=p+b,g=r.offset??0,w=i==="right"?h[0]+a:i==="left"?h[0]-a-f:h[0]-f/2+g,k=i==="bottom"?h[1]+a:i==="top"?h[1]-a-y:h[1]-y/2+g;if(r.plate){let v=o*.5;this.add(new N(K(w-v,k-v,f+v*2,y+v*2,3)).fill("bg",.86))}d&&(this.titleNode=qt(d,w,k+o*.62),this.add(d)),m.moveTo([w+m.width/2,k+p+b/2]),this.body=m,this.add(m);let x=i==="right"?[w-8,k+y/2]:i==="left"?[w+f+8,k+y/2]:i==="bottom"?[w+f/2,k-8]:[w+f/2,k+y+8],M=c[0]!==0?[h[0]+c[0]*a*.45,x[1]]:[x[0],h[1]+c[1]*a*.45];this.leader=new N(Z([h,M,x])).stroke(s,1.25),this.marker=gt(3,s).at(h),this.add(this.leader,this.marker)}enter(t={}){return{label:"callout.enter",duration:t.duration??.9,ease:t.ease,schedule:e=>{it(this,e.t0,e.stage);let r=e.t1-e.t0;D(this.marker,"opacity",0,e.t0),this.marker.tween("opacity",1,e.t0,e.t0+r*.2,e.ease),D(this.leader,"trimTo",0,e.t0),this.leader.tween("trimTo",1,e.t0,e.t0+r*.55,e.ease);for(let o of this.children){if(o===this.marker||o===this.leader)continue;let s=o.get("opacity");D(o,"opacity",0,e.t0),o.tween("opacity",s,e.t0+r*.42,e.t1,e.ease)}}}}};function ih(n,t,e={}){return new Pr(n,t,e)}function Ge(n){return Array.isArray(n)?[...n]:[n]}function hs(n){return Ge(n).flatMap(t=>t.leaves().filter(e=>e.get("path")))}function bh(n,t={}){let e=hs(n);return{label:"typewriter",duration:t.duration??Math.max(.5,e.length*.035),ease:t.ease??Fe,schedule(r){for(let a of Ge(n))it(a,r.t0,r.stage);let o=hs(n);if(o.length===0)return;let s=r.t1-r.t0,i=null;if(t.cursor){let l=o[0].bounds().height*1.35||24;i=new N(K(0,-l/2,Math.max(3,l*.1),l)).fill(t.cursorColor??"ink"),r.stage.add(i)}o.forEach((a,l)=>{let c=r.t0+s*r.ease(l/o.length),u=a.get("opacity");if(D(a,"opacity",0,r.t0),D(a,"opacity",u,c),i){S.now=c;let h=a.bounds();D(i,"x",h.x+h.width+3,c),D(i,"y",h.y+h.height/2,c),S.now=r.t0}}),i&&D(i,"visible",!1,r.t1)}}}function gh(n,t={}){return{label:"wipe",duration:t.duration??1.2,ease:t.ease??dt,schedule(e){let r=t.from??"left";for(let p of Ge(n))it(p,e.t0,e.stage);let o=Ge(n).flatMap(p=>p.leaves()),s=p=>{let f=p.bounds(),b=f.x+f.width/2,y=f.y+f.height/2;return r==="left"?b:r==="right"?-b:r==="top"?y:-y},i=o.map(s),a=Math.min(...i),l=Math.max(...i),c=t.soft??.25,u=t.travel??0,h=e.t1-e.t0,d=r==="left"?-u:r==="right"?u:0,m=r==="top"?-u:r==="bottom"?u:0;o.forEach((p,f)=>{let b=l>a?(i[f]-a)/(l-a):0,y=e.t0+h*(1-c)*e.ease(b),g=y+h*c,w=p.get("opacity");if(D(p,"opacity",0,e.t0),p.tween("opacity",w,y,g,dt),u){let k=p.get("x"),x=p.get("y");D(p,"x",k+d,e.t0),D(p,"y",x+m,e.t0),p.tween("x",k,y,g,dt),p.tween("y",x,y,g,dt)}})}}}var je=class extends N{value;constructor(t=0,e={}){super(),this.value=new pt(t);let r=e.digits??0,o=new Intl.NumberFormat("en-US",{minimumFractionDigits:r,maximumFractionDigits:r,useGrouping:e.grouped??!0}),s=Ot(()=>{let i=`${e.prefix??""}${o.format(this.value.value)}${e.suffix??""}`;return _(i,{size:e.size??48,color:e.color??"ink",font:e.font??"mono",weight:e.weight??400})});this.add(s)}};function yh(n=0,t={}){return new je(n,t)}function wh(n,t,e={}){let r=n instanceof je?n.value:n;return{label:"countUp",duration:e.duration??1.2,ease:e.ease,schedule(o){n instanceof je&&it(n,o.t0,o.stage),wt(r,t,o.t0,o.t1,o.ease)}}}function xh(n,t,e={}){return{label:"spin",duration:e.duration??2,ease:e.ease??Fe,schedule(r){it(n,r.t0,r.stage),S.now=r.t0,n.pivotAt(e.about??n.center);let o=n.get("rotation"),s=r.t1-r.t0;n.tween("rotation",o+t*s,r.t0,r.t1,r.ease)}}}function kh(n,t,e={}){return{label:"swap",duration:e.duration??.9,ease:e.ease,schedule(r){it(n,r.t0,r.stage),it(t,r.t0,r.stage),S.now=r.t0;let o=n.center,s=t.center,i=e.lift??Math.max(60,Math.hypot(s[0]-o[0],s[1]-o[1])*.3),a=(l,c,u,h)=>{let d=l.parent?Wt(l.parent.worldMatrix()):[1,0,0,1,0,0],m=l.get("x"),p=l.get("y"),[f,b]=Q(d,c[0],c[1]),[y,g]=Q(d,u[0],u[1]),w=m+y-f,k=p+g-b;l.track("x").add({t0:r.t0,t1:r.t1,ease:r.ease,to:w,at:x=>m+(w-m)*x}),l.track("y").add({t0:r.t0,t1:r.t1,ease:r.ease,to:k,at:x=>p+(k-p)*x-h*i*4*x*(1-x)})};a(n,o,s,1),a(t,s,o,-1)}}}function Mh(n,t={}){let e=new N([]),r=Ge(n);return{mark:e,label:"highlightSweep",duration:t.duration??.7,ease:t.ease,schedule(o){let s=1/0,i=1/0,a=-1/0,l=-1/0;for(let M of r){let v=M.bounds();s=Math.min(s,v.x),i=Math.min(i,v.y),a=Math.max(a,v.x+v.width),l=Math.max(l,v.y+v.height)}let c=t.pad??6,u=s-c,h=i-c,d=a-s+c*2,m=l-i+c*2,p=t.radius??3,f=t.color??"yellow";e.base.fill=X(f),e.base.fillOpacity=t.opacity??.26;let b=o.stage.root;b.add(e);let g=r[0];for(;g.parent&&g.parent!==b;)g=g.parent;let w=b.children.indexOf(g);b.children.splice(b.children.indexOf(e),1),b.children.splice(w>=0?w:b.children.length,0,e);let k=t.from==="right",x=M=>{let v=Math.max(.01,d*M);return K(k?u+d-v:u,h,v,m,p)};e.track("path").step(o.t0,x(0)),e.track("path").add({t0:o.t0,t1:o.t1,ease:o.ease,to:x(1),at:x})}}}function ds(n){return n.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/&apos;/g,"'").replace(/&#(\d+);/g,(t,e)=>String.fromCodePoint(Number(e))).replace(/&#x([\da-fA-F]+);/g,(t,e)=>String.fromCodePoint(parseInt(e,16))).replace(/&amp;/g,"&")}function ia(n){let t={name:"#root",attrs:{},children:[],text:""},e=[t],r=/<!--[\s\S]*?-->|<!\[CDATA\[([\s\S]*?)\]\]>|<\?[\s\S]*?\?>|<!DOCTYPE[^>]*>|<\/([\w:.-]+)\s*>|<([\w:.-]+)((?:\s+[\w:.-]+\s*=\s*(?:"[^"]*"|'[^']*'))*)\s*(\/?)>|([^<]+)/g;for(let o=r.exec(n);o;o=r.exec(n)){let s=e[e.length-1],[,i,a,l,c,u,h]=o;if(i!==void 0)s.text+=i;else if(a)e.length>1&&e.pop();else if(l){let d={name:l.replace(/^.*:/,""),attrs:{},children:[],text:""};for(let m of(c??"").matchAll(/([\w:.-]+)\s*=\s*(?:"([^"]*)"|'([^']*)')/g))d.attrs[m[1]]=ds(m[2]??m[3]??"");s.children.push(d),u||e.push(d)}else h&&(s.text+=ds(h))}return t}function aa(n){if(!n)return zt;let t=zt;for(let e of n.matchAll(/(matrix|translate|scale|rotate|skewX|skewY)\s*\(([^)]*)\)/g)){let r=e[2].trim().split(/[\s,]+/).filter(Boolean).map(Number),o=e[1];if(o==="matrix"&&r.length===6)t=rt(t,r);else if(o==="translate")t=rt(t,[1,0,0,1,r[0]??0,r[1]??0]);else if(o==="scale")t=rt(t,[r[0]??1,0,0,r[1]??r[0]??1,0,0]);else if(o==="rotate"){let s=(r[0]??0)*Math.PI/180,i=Math.cos(s),a=Math.sin(s),l=r[1]??0,c=r[2]??0;t=rt(t,[1,0,0,1,l,c]),t=rt(t,[i,a,-a,i,0,0]),t=rt(t,[1,0,0,1,-l,-c])}else o==="skewX"?t=rt(t,[1,0,Math.tan((r[0]??0)*Math.PI/180),1,0,0]):o==="skewY"&&(t=rt(t,[1,Math.tan((r[0]??0)*Math.PI/180),0,1,0,0]))}return t}var la=new Set(["defs","clipPath","mask","pattern","filter","symbol","marker","linearGradient","radialGradient","title","desc","metadata","style","script"]),wn=class extends N{byId=new Map;pictureWidth=0;pictureHeight=0;find(t){let e=this.byId.get(t);if(!e)throw new Error(`The SVG has no element with id ${JSON.stringify(t)}.`);return e}};function ca(n){let t=new Map,e=r=>{if(r.name==="style")for(let o of r.text.matchAll(/([^{}]+)\{([^{}]*)\}/g)){let s=Or(o[2]);for(let i of o[1].split(",")){let a=i.trim();t.set(a,{...t.get(a),...s})}}r.children.forEach(e)};return e(n),t}function Or(n){let t={};if(!n)return t;for(let e of n.split(";")){let r=e.indexOf(":");r>0&&(t[e.slice(0,r).trim()]=e.slice(r+1).trim())}return t}function yn(n){if(!n||n==="none"||n==="transparent")return null;try{return Gt(n)}catch{return null}}function ua(n){let t=n.map(s=>{let i=bt([s]);return{ring:s,b:i,area:i.width*i.height,owner:-1}}),e=t.map((s,i)=>i).sort((s,i)=>t[i].area-t[s].area);for(let s=0;s<e.length;s++){let i=t[e[s]];for(let a=s-1;a>=0;a--){let l=t[e[a]];if(l.owner!==-1)continue;if(i.b.x>=l.b.x-.01&&i.b.y>=l.b.y-.01&&i.b.x+i.b.width<=l.b.x+l.b.width+.01&&i.b.y+i.b.height<=l.b.y+l.b.height+.01){i.owner=e[a];break}}}let r=[],o=new Map;return t.forEach((s,i)=>{if(s.owner!==-1)return;let a={x:s.b.x,rings:[s.ring]};o.set(i,a),r.push(a)}),t.forEach(s=>{s.owner!==-1&&o.get(s.owner)?.rings.push(s.ring)}),r.sort((s,i)=>s.x-i.x).map(s=>s.rings)}function ha(n,t={}){let r=ia(n).children.find(C=>C.name==="svg");if(!r)throw new Error("fromSvg needs markup with an <svg> element.");let o=ca(r),s=new Map,i=C=>{C.attrs.id&&s.set(C.attrs.id,C),C.children.forEach(i)};i(r);let a=(r.attrs.viewBox??"").trim().split(/[\s,]+/).map(Number),l=parseFloat(r.attrs.width??""),c=parseFloat(r.attrs.height??""),u=a.length===4&&a[2]?a[2]:l||300,h=a.length===4&&a[3]?a[3]:c||150,d=a.length===4?a[0]:0,m=a.length===4?a[1]:0,p=Number.isFinite(l)&&l>0?l:u,f=Number.isFinite(c)&&c>0?c:h,b=1;if(t.width!==void 0||t.height!==void 0){let C=t.width!==void 0?t.width/u:1/0,L=t.height!==void 0?t.height/h:1/0;b=Math.min(C,L)}else b=Math.min(p/u,f/h);let y=t.center??!0,g=y?-(d+u/2)*b:-d*b,w=y?-(m+h/2)*b:-m*b,k=[b,0,0,b,g,w],x=new wn;x.pictureWidth=u*b,x.pictureHeight=h*b;let M=t.splitGlyphs??!0,v=t.background??!1,P=!0,O=(C,L,I)=>{let F=s.get(C);if(!F)return null;if(F.name==="pattern"){let E=F.children.find(j=>j.name==="linearGradient");if(E)return R(E,L,I,!0);let V=F.children.find(j=>j.attrs.fill?.startsWith("url(#"))?.attrs.fill?.match(/url\(#([^)]+)\)/)?.[1];return V?O(V,L,I):null}if(F.name==="linearGradient")return R(F,L,I,F.attrs.gradientUnits!=="userSpaceOnUse");if(F.name==="radialGradient"){let E=A(F);return E.length?E[E.length-1][1]:null}return null},A=C=>{let L=C.attrs.href??C.attrs["xlink:href"];return(C.children.some(F=>F.name==="stop")||!L?C:s.get(L.replace(/^#/,""))??C).children.filter(F=>F.name==="stop").map(F=>{let E=Or(F.attrs.style),T=F.attrs.offset??"0",V=T.endsWith("%")?parseFloat(T)/100:parseFloat(T),j=yn(E["stop-color"]??F.attrs["stop-color"]??"#000000")??[0,0,0,1],J=parseFloat(E["stop-opacity"]??F.attrs["stop-opacity"]??"1");return[V,[j[0],j[1],j[2],j[3]*J]]})},R=(C,L,I,F)=>{let E=A(C);if(E.length===0)return null;let T=(H,ct)=>H===void 0?ct:H.endsWith("%")?parseFloat(H)/100:parseFloat(H),V=T(C.attrs.x1,0),j=T(C.attrs.y1,0),J=T(C.attrs.x2,1),at=T(C.attrs.y2,0),tt,ut;if(F){let H=bt(I)??{x:0,y:0,width:1,height:1};tt=[H.x+V*H.width,H.y+j*H.height],ut=[H.x+J*H.width,H.y+at*H.height]}else tt=Q(L,V,j),ut=Q(L,J,at);return{type:"linear",from:tt,to:ut,stops:E}},$=C=>{let L=C.attrs,I=(F,E=0)=>{let T=parseFloat(L[F]??"");return Number.isFinite(T)?T:E};switch(C.name){case"path":return L.d?vt(L.d):null;case"rect":{let F=I("width"),E=I("height");return F<=0||E<=0?null:K(I("x"),I("y"),F,E,I("rx",I("ry")))}case"circle":return I("r")>0?St(I("cx"),I("cy"),I("r"),I("r"),0,Math.PI*2):null;case"ellipse":return I("rx")>0&&I("ry")>0?St(I("cx"),I("cy"),I("rx"),I("ry"),0,Math.PI*2):null;case"line":return Z([[I("x1"),I("y1")],[I("x2"),I("y2")]]);case"polyline":case"polygon":{let F=(L.points??"").trim().split(/[\s,]+/).filter(Boolean).map(Number),E=[];for(let T=0;T+1<F.length;T+=2)E.push([F[T],F[T+1]]);return E.length>=2?Z(E,C.name==="polygon"):null}default:return null}},z=(C,L)=>{let I=C.attrs,F=(I.class??"").split(/\s+/).filter(Boolean),E={...o.get(C.name)};for(let q of F)Object.assign(E,o.get(`.${q}`));I.id&&Object.assign(E,o.get(`#${I.id}`));let T=q=>Or(I.style)[q]??I[q]??E[q],V={...L},j=T("color");j&&(V.color=j);let J=T("fill");J&&(V.fill=J==="currentColor"?V.color:J);let at=T("stroke");at&&(V.stroke=at==="currentColor"?V.color:at);let tt=T("stroke-width");tt!==void 0&&(V.strokeWidth=parseFloat(tt)||0);let ut=T("fill-opacity");ut!==void 0&&(V.fillOpacity=parseFloat(ut));let H=T("stroke-opacity");H!==void 0&&(V.strokeOpacity=parseFloat(H));let ct=T("stroke-linecap");(ct==="round"||ct==="butt"||ct==="square")&&(V.cap=ct);let mt=T("stroke-linejoin");(mt==="round"||mt==="miter"||mt==="bevel")&&(V.join=mt);let nt=T("stroke-dasharray");nt!==void 0&&(V.dash=nt==="none"?null:nt.trim().split(/[\s,]+/).map(Number));let ht=T("stroke-dashoffset");ht!==void 0&&(V.dashOffset=parseFloat(ht)||0);let xt=T("font-size");xt!==void 0&&(V.fontSize=parseFloat(xt)||V.fontSize);let kt=T("text-anchor");return kt&&(V.anchor=kt),{style:V,opacity:parseFloat(T("opacity")??"1")}},B=(C,L,I,F)=>{let E=ot(C,L),T=Xt(L),V=nt=>nt?.match(/^url\(#([^)]+)\)/)?.[1],j=V(F.fill),J=V(F.stroke),at=j?O(j,L,E):yn(F.fill),tt=J?O(J,L,E):yn(F.stroke),ut=at&&F.fillOpacity>0&&!(Array.isArray(at)&&at[3]===0),H=tt&&F.strokeOpacity>0&&F.strokeWidth>0&&!(Array.isArray(tt)&&tt[3]===0);if(!ut&&!H)return[];let ct=I.attrs["clip-path"]?.5:1;return(M&&ut&&!H&&E.length>1?ua(E):[E]).map(nt=>{let ht=bt(nt)??{x:0,y:0,width:0,height:0},xt=ht.x+ht.width/2,kt=ht.y+ht.height/2,q=new N(ot(nt,[1,0,0,1,-xt,-kt])).at(xt,kt);return ut&&(q.base.fill=ms(at,-xt,-kt),q.base.fillOpacity=F.fillOpacity),H&&(q.base.stroke=ms(tt,-xt,-kt),q.base.strokeWidth=F.strokeWidth*T*ct,q.base.strokeOpacity=F.strokeOpacity,q.base.cap=F.cap,q.base.join=F.join,F.dash&&(q.base.dash=F.dash.map(ie=>ie*T)),q.base.dashOffset=F.dashOffset*T),q.base.trimEach=!0,q})},W=(C,L,I,F)=>{if(la.has(C.name)||C.attrs.filter)return;let{style:E,opacity:T}=z(C,I),V=rt(F,aa(C.attrs.transform)),j=H=>{C.attrs.id&&x.byId.set(C.attrs.id,H)};if(C.name==="g"||C.name==="svg"||C.name==="a"){let H=new N;T<1&&(H.base.opacity=T),j(H),L.add(H);for(let ct of C.children)W(ct,H,E,V);return}if(C.name==="use"){let H=(C.attrs.href??C.attrs["xlink:href"]??"").replace(/^#/,""),ct=s.get(H);if(!ct)return;let mt=rt(V,[1,0,0,1,parseFloat(C.attrs.x??"0")||0,parseFloat(C.attrs.y??"0")||0]),nt=new N;if(T<1&&(nt.base.opacity=T),L.add(nt),ct.name==="symbol")for(let ht of ct.children)W(ht,nt,E,mt);else W(ct,nt,E,mt);return}if(C.name==="image"){let H=C.attrs.href??C.attrs["xlink:href"];if(!H)return;let ct=parseFloat(C.attrs.width??"0"),mt=parseFloat(C.attrs.height??"0"),[nt,ht]=Q(V,parseFloat(C.attrs.x??"0")||0,parseFloat(C.attrs.y??"0")||0),xt=Xt(V),kt={src:H,width:ct,height:mt},q=new N().at(nt,ht);q.base.image=kt,q.base.sx=xt,q.base.sy=xt,T<1&&(q.base.opacity=T),j(q),L.add(q);return}if(C.name==="text"){let H=(C.text+C.children.map(q=>q.text).join("")).trim();if(!H)return;let ct=yn(E.fill)??[0,0,0,1],mt=E.fontSize*Xt(V),nt=_(H,{size:mt,color:ct}),[ht,xt]=Q(V,parseFloat(C.attrs.x??"0")||0,parseFloat(C.attrs.y??"0")||0),kt=nt.get("px");nt.at(E.anchor==="middle"?ht:E.anchor==="end"?ht-kt:ht+kt,xt-mt*.34),T<1&&(nt.base.opacity=T),j(nt),L.add(nt);return}let J=$(C);if(!J||J.length===0)return;let at=P&&C.name==="rect"&&!v&&parseFloat(C.attrs.width??"0")>=u-.5&&parseFloat(C.attrs.height??"0")>=h-.5;if(P=!1,at)return;let tt=B(J,V,C,E);if(tt.length===0)return;if(tt.length===1){T<1&&(tt[0].base.opacity=T),j(tt[0]),L.add(tt[0]);return}let ut=new N;T<1&&(ut.base.opacity=T),ut.add(...tt),j(ut),L.add(ut)},G={fill:"#000000",stroke:null,strokeWidth:1,fillOpacity:1,strokeOpacity:1,cap:"butt",join:"miter",dash:null,dashOffset:0,color:"#000000",fontSize:16,anchor:"start"},{style:U}=z(r,G);for(let C of r.children)W(C,x,U,k);return x}function ms(n,t,e){if(Array.isArray(n))return n;let r=n;return r.type==="linear"?{...r,from:[r.from[0]+t,r.from[1]+e],to:[r.to[0]+t,r.to[1]+e]}:r.type==="radial"?{...r,center:[r.center[0]+t,r.center[1]+e]}:r}var ps=n=>n.toLowerCase().replace(/[^a-z0-9.]+/g," ").split(" ").map(t=>t.replace(/^\.+|\.+$/g,"")).filter(Boolean);function fs(n,t=74){let e=[];for(let r of n.match(/[^.?!]+(?:[.?!]+(?=\s|$)|\.\d[^.?!]*[.?!]?|$)/g)??[]){let o="";for(let s of r.split(/\s+/).filter(Boolean))o&&o.length+s.length+1>t?(e.push(o),o=s):o=o?`${o} ${s}`:s;o&&e.push(o)}return e}var xn=class{constructor(t,e,r,o,s){this.stage=t;this.id=e;this.start=r;this.end=o;this.beats=s}stage;id;start;end;beats;cue(t,e){let r=ps(t);if(r.length===0)throw new Error(`narration: scene "${this.id}": a cue needs at least one word`);if(e!==void 0&&!this.beats[e])throw new Error(`narration: scene "${this.id}" has no beat ${e}`);let o=e===void 0?this.beats:[this.beats[e]];for(let i of o){let a=i.words.flatMap(l=>ps(l.text).map(c=>({token:c,start:l.start,end:l.end})));for(let l=0;l+r.length<=a.length;l++)if(r.every((c,u)=>a[l+u].token===c))return{start:i.start+a[l].start,end:i.start+a[l+r.length-1].end}}let s=e===void 0?"":` in beat ${e}`;throw new Error(`narration: scene "${this.id}": the voice never says "${t}"${s}`)}on(t,e,r=0,o){return this.stage.at(Math.max(0,this.cue(t,o).start+r),e),this}after(t,e,r=0,o){return this.stage.at(Math.max(0,this.cue(t,o).end+r),e),this}onBeat(t,e,r=0){let o=this.beats[t];if(!o)throw new Error(`narration: scene "${this.id}" has no beat ${t}`);return this.stage.at(Math.max(0,o.start+r),e),this}at(t,e){return this.stage.at(Math.max(0,this.start+t),e),this}clear(t,e=.24,r=.26){return this.stage.at(this.end-e,()=>this.stage.play(...t.map(o=>ho(o,0,{duration:r})))),this}},kn=class{scenes;duration;lead;gap;constructor(t,e,r={}){if(this.lead=r.lead??e.lead??.6,this.gap=r.gap??e.gap??.4,!(this.lead>=0)||!(this.gap>=0))throw new Error("narration: lead and gap must be zero or more seconds");let o=new Set,s=[],i=this.lead,a=i;for(let l of e.scenes){if(o.has(l.id))throw new Error(`narration: two scenes are named "${l.id}"`);o.add(l.id);let c=i,u=[];for(let h of l.beats){if(!(h.duration>0))throw new Error(`narration: scene "${l.id}" has a beat without a measured duration: "${h.say}"`);let d=h.hold??0;u.push({start:i,end:i+h.duration,until:i+h.duration+d,text:h.say,words:h.words??[]}),i+=h.duration+d}if(s.push(new xn(t,l.id,c,i,u)),r.chapters!==!1&&l.title&&t.chapters.push({title:l.title,time:s.length===1?0:c}),r.captions!==!1)for(let h of u){let d=fs(h.text,r.captionLength),m=d.reduce((f,b)=>f+b.length,0),p=h.start;for(let f of d){let b=p+(h.end-h.start)*f.length/m;t.captions.push({t0:p,t1:b,text:f}),p=b}}a=i,i+=this.gap}this.scenes=s,this.duration=a,t.at(a,()=>{})}scene(t){let e=this.scenes.find(r=>r.id===t);if(!e)throw new Error(`narration: no scene "${t}". The scenes are: ${this.scenes.map(r=>r.id).join(", ")}`);return e}placements(){return this.scenes.flatMap(t=>t.beats.map((e,r)=>({scene:t.id,beat:r,start:e.start,end:e.end})))}};function da(n,t,e={}){return new kn(n,t,e)}var oe=n=>typeof n=="function"?n():n,bs=n=>{let t=Math.hypot(n[0],n[1],n[2])||1;return[n[0]/t,n[1]/t,n[2]/t]},Ar=class{ops=[];depths=[];rx=0;ry=0;ux=0;uy=0;uz=0;dx=0;dy=0;dz=0;fx=0;fy=0;fz=0;distance=12;unit=100;perspective=!0;matrix=[1,0,0,1,0,0];alpha=1;scale=1;light=[0,0,1];half=[0,0,1];ambient=.4;shine=.2;fog=0;fogColor=[0,0,0,1];depthRange=1;brightness=1;px=0;py=0;pz=0;ps=1;project(t,e,r){let o=t-this.fx,s=e-this.fy,i=r-this.fz,a=o*this.rx+s*this.ry,l=o*this.ux+s*this.uy+i*this.uz,c=o*this.dx+s*this.dy+i*this.dz,u=1;if(this.perspective){let p=this.distance-c;if(p<=.05)return!1;u=this.distance/p}let h=a*this.unit*u,d=-l*this.unit*u,m=this.matrix;return this.px=m[0]*h+m[2]*d+m[4],this.py=m[1]*h+m[3]*d+m[5],this.pz=c,this.ps=u,!0}screen(t,e,r){let o=t-this.fx,s=e-this.fy,i=r-this.fz,a=o*this.rx+s*this.ry,l=o*this.ux+s*this.uy+i*this.uz,c=o*this.dx+s*this.dy+i*this.dz,u=1;if(this.perspective){let h=this.distance-c;if(h<=.05)return null;u=this.distance/h}return[a*this.unit*u,-l*this.unit*u]}fogged(t,e,r,o){if(this.fog<=0)return[t,e,r,1];let s=Math.max(0,Math.min(1,-o/this.depthRange*this.fog));return[t+(this.fogColor[0]-t)*s,e+(this.fogColor[1]-e)*s,r+(this.fogColor[2]-r)*s,1]}push(t,e){this.ops.push(t),this.depths.push(e)}};function Me(n,t,e,r,o=0,s="round"){return{kind:"path",path:n,strokePath:n,fill:null,fillAlpha:0,stroke:t,strokeAlpha:e,strokeWidth:r,cap:s,join:"round",dash:null,dashOffset:0,glow:o,glowColor:null,blend:"normal"}}function ve(n,t,e,r,o,s){return{kind:"path",path:n,strokePath:n,fill:t,fillAlpha:e,stroke:r,strokeAlpha:o,strokeWidth:s,cap:"round",join:"round",dash:null,dashOffset:0,glow:0,glowColor:null,blend:"normal"}}function Mn(n,t,e,r){let o=e-n,s=r-t,i=new Float64Array(8);return i[0]=n,i[1]=t,i[2]=n+o/3,i[3]=t+s/3,i[4]=n+o*2/3,i[5]=t+s*2/3,i[6]=e,i[7]=r,{p:i,closed:!1,straight:!0}}function zr(n){let t=n.length/2,e=new Float64Array(2+t*6);e[0]=n[0],e[1]=n[1];let r=2;for(let o=0;o<t;o++){let s=n[o*2],i=n[o*2+1],a=n[(o+1)%t*2],l=n[(o+1)%t*2+1];e[r++]=s+(a-s)/3,e[r++]=i+(l-i)/3,e[r++]=s+(a-s)*2/3,e[r++]=i+(l-i)*2/3,e[r++]=a,e[r++]=l}return{p:e,closed:!0,straight:!0}}var ma=.5522847498307936;function gs(n,t,e){let r=e*ma;return{closed:!0,p:Float64Array.of(n+e,t,n+e,t+r,n+r,t+e,n,t+e,n-r,t+e,n-e,t+r,n-e,t,n-e,t-r,n-r,t-e,n,t-e,n+r,t-e,n+e,t-r,n+e,t)}}var Et=class extends N{constructor(){super([])}labelsNow(t){return[]}objectAlpha(t){return t.alpha*this.get("opacity")}},Cr=class extends N{phi;theta;distance;unit;focusX;focusY;focusZ;orthographic;settings;spins=[];openSpin=null;constructor(t={}){super(),this.settings=t,this.phi=new pt(t.phi??1.15),this.theta=new pt(t.theta??-1),this.distance=new pt(t.distance??14),this.unit=new pt(t.unit??120),this.focusX=new pt(t.focus?.[0]??0),this.focusY=new pt(t.focus?.[1]??0),this.focusZ=new pt(t.focus?.[2]??0),this.orthographic=t.perspective===!1,this.rawOps=(e,r,o)=>this.render(e,r,o),this.draw=e=>{let r=this.view(this.worldless,1,e);return this.children.flatMap(o=>o instanceof Et&&o.get("visible")?o.labelsNow(r):[])}}worldless=[1,0,0,1,0,0];view(t,e,r){let o=new Ar,s=this.phi.value,i=this.theta.value;for(let m of this.spins)r>m.from&&(i+=(Math.min(r,m.to)-m.from)*m.rate);let a=Math.sin(s),l=Math.cos(s),c=Math.sin(i),u=Math.cos(i);o.rx=-c,o.ry=u,o.ux=-l*u,o.uy=-l*c,o.uz=a,o.dx=a*u,o.dy=a*c,o.dz=l,o.fx=this.focusX.value,o.fy=this.focusY.value,o.fz=this.focusZ.value,o.distance=this.distance.value,o.unit=this.unit.value,o.perspective=!this.orthographic,o.matrix=t,o.alpha=e,o.scale=Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]));let h=bs(this.settings.light??[-.45,-.55,.85]);o.light=h,o.half=bs([h[0]+o.dx,h[1]+o.dy,h[2]+o.dz]),o.ambient=this.settings.ambient??.26,o.shine=this.settings.shine??.2,o.fog=this.settings.fog??.6;let d=Gt("bg");return o.fogColor=this.settings.fogColor?Ft(this.settings.fogColor):d,o.depthRange=Math.max(3,o.distance*.5),o.brightness=this.settings.brightness??(d[0]+d[1]+d[2]<200?.8:1),o}render(t,e,r){let o=S.now,s=this.view(t,e,o);for(let c of this.children)c instanceof Et&&c.get("visible")&&c.emit(s,o);let i=s.ops.length,a=new Uint32Array(i);for(let c=0;c<i;c++)a[c]=c;let l=s.depths;a.sort((c,u)=>l[c]-l[u]);for(let c=0;c<i;c++)r.push(s.ops[a[c]])}orbit(t,e={}){return{label:"camera3d",duration:e.duration??2,ease:e.ease,schedule:r=>{t.phi!==void 0&&wt(this.phi,t.phi,r.t0,r.t1,r.ease),t.theta!==void 0&&wt(this.theta,t.theta,r.t0,r.t1,r.ease),t.distance!==void 0&&wt(this.distance,t.distance,r.t0,r.t1,r.ease),t.unit!==void 0&&wt(this.unit,t.unit,r.t0,r.t1,r.ease),t.focus&&(wt(this.focusX,t.focus[0],r.t0,r.t1,r.ease),wt(this.focusY,t.focus[1],r.t0,r.t1,r.ease),wt(this.focusZ,t.focus[2],r.t0,r.t1,r.ease))}}}spin(t=.12){return this.stopSpin(),this.openSpin={from:S.now,to:1/0,rate:t},this.spins.push(this.openSpin),this}stopSpin(){return this.openSpin&&(this.openSpin.to=S.now),this.openSpin=null,this}stagePoint(t){let e=this.view(this.worldMatrix(),1,S.now);return e.project(t[0],t[1],t[2])?[e.px,e.py]:[0,0]}};function Vh(n={}){return new Cr(n)}var He=class extends Et{constructor(e,r,o,s={}){super();this.fn=e;this.uRange=r;this.vRange=o;this.options=s;let i=s.resolution??40;this.nu=typeof i=="number"?i:i[0],this.nv=typeof i=="number"?i:i[1];let a=(this.nu+1)*(this.nv+1);if(this.positions=new Float64Array(a*3),this.normals=new Float64Array(this.nu*this.nv*3),this.vertexNormals=new Float64Array(a*3),this.shadingNormals=new Float64Array(this.nu*this.nv*3),this.faceColors=new Float32Array(this.nu*this.nv*3),this.screenX=new Float64Array(a),this.screenY=new Float64Array(a),this.screenZ=new Float64Array(a),this.valid=new Uint8Array(a),this.meshColor=s.mesh?Ft(s.mesh):null,s.colors){let l=s.colors.map(c=>Ft(c));this.ramp=l.map((c,u)=>[l.length===1?0:u/(l.length-1),c])}s.checker&&(this.checkerColors=[Ft(s.checker[0]),Ft(s.checker[1])]),(s.color||!s.colors&&!s.checker&&!s.colorAt)&&(this.base.fill=X(s.color??"blue"))}fn;uRange;vRange;options;nu;nv;positions;normals;vertexNormals;shadingNormals;faceColors;computedFor=-1/0;screenX;screenY;screenZ;valid;meshColor;ramp=null;checkerColors=null;compute(e){let{nu:r,nv:o,positions:s,normals:i,faceColors:a,fn:l,uRange:c,vRange:u,options:h}=this,d=0,m=1/0,p=-1/0;for(let g=0;g<=r;g++){let w=c[0]+(c[1]-c[0])*g/r;for(let k=0;k<=o;k++){let x=u[0]+(u[1]-u[0])*k/o,M=l(w,x,e);s[d++]=M[0],s[d++]=M[1],s[d++]=M[2],M[2]<m&&(m=M[2]),M[2]>p&&(p=M[2])}}let f=o+1,b=this.vertexNormals;b.fill(0);for(let g=0;g<r;g++)for(let w=0;w<o;w++){let k=(g*f+w)*3,x=((g+1)*f+w)*3,M=((g+1)*f+w+1)*3,v=(g*f+w+1)*3,P=s[M]-s[k],O=s[M+1]-s[k+1],A=s[M+2]-s[k+2],R=s[v]-s[x],$=s[v+1]-s[x+1],z=s[v+2]-s[x+2],B=O*z-A*$,W=A*R-P*z,G=P*$-O*R,U=Math.hypot(B,W,G)||1;if(B/=U,W/=U,G/=U,h.outwardFrom){let[L,I,F]=h.outwardFrom,E=(s[k]+s[M])/2-L,T=(s[k+1]+s[M+1])/2-I,V=(s[k+2]+s[M+2])/2-F;B*E+W*T+G*V<0&&(B=-B,W=-W,G=-G)}let C=(g*o+w)*3;i[C]=B,i[C+1]=W,i[C+2]=G;for(let L of[k/3,x/3,M/3,v/3])b[L*3]+=B,b[L*3+1]+=W,b[L*3+2]+=G;if(this.ramp||this.checkerColors||h.colorAt){let L;if(h.colorAt){let I=(s[k]+s[M])/2,F=(s[k+1]+s[M+1])/2,E=(s[k+2]+s[M+2])/2;L=h.colorAt(I,F,E,(g+.5)/r,(w+.5)/o)}else if(this.checkerColors)L=this.checkerColors[(g+w)%2];else{let I=(s[k+2]+s[M+2]+s[x+2]+s[v+2])/4;L=lt(this.ramp,p>m?(I-m)/(p-m):0)}a[C]=L[0],a[C+1]=L[1],a[C+2]=L[2]}}let y=this.shadingNormals;for(let g=0;g<r;g++)for(let w=0;w<o;w++){let k=(g*f+w)*3,x=((g+1)*f+w)*3,M=((g+1)*f+w+1)*3,v=(g*f+w+1)*3,P=0,O=0,A=0;for(let z of[k,x,M,v])P+=b[z],O+=b[z+1],A+=b[z+2];let R=Math.hypot(P,O,A)||1,$=(g*o+w)*3;y[$]=P/R,y[$+1]=O/R,y[$+2]=A/R}}emit(e,r){let{options:o,nu:s,nv:i,normals:a,shadingNormals:l,faceColors:c,screenX:u,screenY:h,screenZ:d,valid:m}=this,p=this.objectAlpha(e)*(o.opacity??1)*this.get("fillOpacity");if(p<=.002)return;(o.animate?this.computedFor!==r:this.computedFor===-1/0)&&(this.compute(o.animate?r:0),this.computedFor=r);let f=this.positions,b=i+1,y=(s+1)*(i+1);for(let I=0;I<y;I++){let F=I*3;e.project(f[F],f[F+1],f[F+2])?(u[I]=e.px,h[I]=e.py,d[I]=e.pz,m[I]=1):m[I]=0}let g=this.ramp||this.checkerColors||o.colorAt?null:se(this.get("fill")),w=o.shaded??!0,k=p>=.995,x=this.get("trimTo"),M=Math.ceil(x*s),{light:v,half:P,ambient:O,shine:A,brightness:R,dx:$,dy:z,dz:B}=e,W=o.cull??!1,G=this.meshColor,U=(o.meshOpacity??.35)*p,C=(o.meshWidth??1)*e.scale,L=.55*e.scale;for(let I=0;I<M;I++)for(let F=0;F<i;F++){let E=I*b+F,T=(I+1)*b+F,V=(I+1)*b+F+1,j=I*b+F+1;if(!m[E]||!m[T]||!m[V]||!m[j])continue;let J=(I*i+F)*3,at=a[J]*$+a[J+1]*z+a[J+2]*B;if(at<0&&W)continue;let tt=at<0?-1:1,ut=l[J]*tt,H=l[J+1]*tt,ct=l[J+2]*tt,mt,nt,ht;if(g?(mt=g[0],nt=g[1],ht=g[2]):(mt=c[J],nt=c[J+1],ht=c[J+2]),w){let Ut=.5+.5*(ut*v[0]+H*v[1]+ct*v[2]),Kt=(O+(1-O)*Ut*Ut)*R,Zt=A>0?A*Math.pow(Math.max(0,ut*P[0]+H*P[1]+ct*P[2]),42)*255:0;mt=Math.min(255,mt*Kt+Zt),nt=Math.min(255,nt*Kt+Zt),ht=Math.min(255,ht*Kt+Zt)}let xt=(d[E]+d[T]+d[V]+d[j])/4,kt=e.fogged(mt,nt,ht,xt),q=u[E],ie=h[E],Pe=u[T],Oe=h[T],Ae=u[V],Ce=h[V],Se=u[j],Re=h[j];if(k&&!G){let Ut=(q+Pe+Ae+Se)/4,Kt=(ie+Oe+Ce+Re)/4,Zt=(Ms,vs)=>L/(Math.hypot(Ms-Ut,vs-Kt)||1),Vr=Zt(q,ie),Br=Zt(Pe,Oe),Wr=Zt(Ae,Ce),Dr=Zt(Se,Re);q+=(q-Ut)*Vr,ie+=(ie-Kt)*Vr,Pe+=(Pe-Ut)*Br,Oe+=(Oe-Kt)*Br,Ae+=(Ae-Ut)*Wr,Ce+=(Ce-Kt)*Wr,Se+=(Se-Ut)*Dr,Re+=(Re-Kt)*Dr}let Lr=zr([q,ie,Pe,Oe,Ae,Ce,Se,Re]);e.push(G?ve([Lr],kt,p,G,U,C):ve([Lr],kt,p,null,0,0),xt)}}};function se(n){return n?Array.isArray(n)?n:Ft(n):[90,180,240,1]}function Bh(n,t,e,r={}){return new He(n,t,e,r)}function Wh(n,t={}){let e=t.x??[-4,4],r=t.y??[-4,4];return new He((o,s,i)=>[o,s,n(o,s,i)],e,r,{colors:t.color||t.checker||t.colorAt?void 0:["blue","teal","yellow"],...t})}function Dh(n=1,t={}){let[e,r,o]=t.center??[0,0,0];return new He((s,i)=>[e+n*Math.sin(i)*Math.cos(s),r+n*Math.sin(i)*Math.sin(s),o+n*Math.cos(i)],[0,Math.PI*2],[0,Math.PI],{cull:!0,resolution:[64,40],outwardFrom:[e,r,o],...t})}var Ne=1e6,Sr=class extends Et{constructor(e,r,o,s={}){super();this.style=s;let i=s.samples??240;this.points=new Float64Array((i+1)*3);for(let a=0;a<=i;a++){let[l,c,u]=e(r+(o-r)*a/i);this.points[a*3]=l,this.points[a*3+1]=c,this.points[a*3+2]=u}if(this.base.stroke=X(s.color??"yellow"),this.base.strokeWidth=s.width??3,s.colors){let a=s.colors.map(l=>Ft(l));this.stops=a.map((l,c)=>[a.length===1?0:c/(a.length-1),l])}else this.stops=null}style;points;stops;emit(e){let r=this.objectAlpha(e)*(this.style.opacity??1)*this.get("strokeOpacity");if(r<=.002)return;let o=this.get("trimTo"),s=this.points.length/3-1,i=Math.floor(o*s);if(i<1)return;let a=Math.max(2,Math.ceil(s/72)),l=this.get("stroke")??X("yellow"),c=this.get("strokeWidth")*e.scale,u=this.style.onTop?Ne:this.style.bias??.12,h=(this.style.glow??0)*e.scale;for(let d=0;d<i;d+=a){let m=Math.min(i,d+a),p=[],f=0,b=0,y=0;for(let k=d;k<=m;k++)e.project(this.points[k*3],this.points[k*3+1],this.points[k*3+2])&&(p.push([e.px,e.py]),f+=e.pz,b+=e.ps,y++);if(y<2)continue;f/=y,b/=y;let g=this.stops?lt(this.stops,(d+m)/2/s):se(l),w=e.fogged(g[0],g[1],g[2],f);e.push(Me([ys(p)],w,r,c*b,h,"round"),f+u)}}};function ys(n){let t=new Float64Array(2+(n.length-1)*6);t[0]=n[0][0],t[1]=n[0][1];let e=2;for(let r=1;r<n.length;r++){let o=n[r-1],s=n[r];t[e++]=o[0]+(s[0]-o[0])/3,t[e++]=o[1]+(s[1]-o[1])/3,t[e++]=o[0]+(s[0]-o[0])*2/3,t[e++]=o[1]+(s[1]-o[1])*2/3,t[e++]=s[0],t[e++]=s[1]}return{p:t,closed:!1,straight:!0}}function Gh(n,t,e,r={}){return new Sr(n,t,e,r)}var vn=class extends Et{constructor(e,r,o={}){super();this.a=e;this.b=r;this.style=o;this.base.stroke=X(o.color??"ink"),this.base.strokeWidth=o.width??2.5}a;b;style;emit(e){let r=this.objectAlpha(e)*(this.style.opacity??1)*this.get("strokeOpacity");if(r<=.002)return;let o=oe(this.a),s=oe(this.b),i=this.style.pieces??14,a=this.get("trimTo"),l=se(this.get("stroke")),c=this.get("strokeWidth")*e.scale,u=this.style.onTop?Ne:this.style.bias??0;for(let h=0;h<i;h++){let d=h/i*a,m=(h+1)/i*a;if(!e.project(o[0]+(s[0]-o[0])*d,o[1]+(s[1]-o[1])*d,o[2]+(s[2]-o[2])*d))continue;let p=e.px,f=e.py,b=e.pz,y=e.ps;if(!e.project(o[0]+(s[0]-o[0])*m,o[1]+(s[1]-o[1])*m,o[2]+(s[2]-o[2])*m))continue;let g=(b+e.pz)/2,w=e.fogged(l[0],l[1],l[2],g);e.push(Me([Mn(p,f,e.px,e.py)],w,r,c*(y+e.ps)/2,0,"butt"),g+u)}}};function jh(n,t,e={}){return new vn(n,t,e)}var Rr=class extends vn{from3;to3;tipSize;tipBias;constructor(t,e,r={}){super(t,()=>{let o=oe(t),s=oe(e),i=Math.hypot(s[0]-o[0],s[1]-o[1],s[2]-o[2])||1,a=Math.min(.9,.22/i);return[s[0]-(s[0]-o[0])*a,s[1]-(s[1]-o[1])*a,s[2]-(s[2]-o[2])*a]},{color:"yellow",width:4,...r}),this.from3=t,this.to3=e,this.tipSize=r.tip??24,this.tipBias=r.onTop?Ne:r.bias??0}emit(t){if(super.emit(t),this.get("trimTo")<.98)return;let r=oe(this.from3),o=oe(this.to3),s=this.objectAlpha(t);if(!t.project(r[0],r[1],r[2]))return;let i=t.px,a=t.py;if(!t.project(o[0],o[1],o[2]))return;let l=t.px,c=t.py,u=t.pz,h=t.ps,d=Math.hypot(l-i,c-a)||1,m=(l-i)/d,p=(c-a)/d,f=this.tipSize*t.scale*h,b=f*.42,y=se(this.get("stroke")),g=t.fogged(y[0],y[1],y[2],u),w=zr([l,c,l-m*f-p*b,c-p*f+m*b,l-m*f+p*b,c-p*f-m*b]);t.push(ve([w],g,s,null,0,0),u+.01+this.tipBias)}};function Hh(n,t,e={}){return new Rr(n,t,e)}var Nn=class extends Et{constructor(e,r={}){super();this.source=e;this.style=r;this.base.fill=X(r.color??"yellow")}source;style;emit(e){let r=this.objectAlpha(e)*(this.style.opacity??1)*this.get("fillOpacity");if(r<=.002)return;let o=typeof this.source=="function"?this.source():this.source,s=(this.style.radius??8)*e.scale,i=this.get("trimTo"),a=Math.ceil(o.length*i),l=se(this.get("fill")),c=this.style.onTop?Ne:this.style.bias??0;for(let u=0;u<a;u++){let h=o[u];if(!e.project(h[0],h[1],h[2]))continue;let d=this.style.colorAt?Ft(this.style.colorAt(u,h)):l,m=e.fogged(d[0],d[1],d[2],e.pz),p=s*e.ps;this.style.halo&&e.push(ve([gs(e.px,e.py,p*(1+this.style.halo))],m,r*.18,null,0,0),e.pz+c-.001),e.push(ve([gs(e.px,e.py,p)],m,r,null,0,0),e.pz+c)}}};function _h(n,t={}){return new Nn(n,t)}function Kh(n,t={}){return new Nn(()=>[oe(n)],t)}var Tr=class extends Et{constructor(e,r,o,s={}){super();this.point=e;this.from=r;this.to=o;this.style=s;this.base.stroke=X(s.color??"yellow"),this.base.strokeWidth=s.width??3}point;from;to;style;cache=new Map;sample(e,r){let o=this.cache.get(e);if(o)return o;let s=S.now;S.now=this.from+e/r;let i=this.point();return S.now=s,S.mode==="render"&&this.cache.set(e,i),i}emit(e,r){if(r<=this.from)return;let o=this.objectAlpha(e)*(this.style.opacity??1),s=this.style.rate??30,i=Math.min(r,this.to),a=this.style.tail,l=a!==void 0?Math.max(this.from,i-a):this.from,c=Math.ceil((l-this.from)*s),u=Math.floor((i-this.from)*s);if(u-c<1)return;let h=this.get("strokeWidth")*e.scale,d=se(this.get("stroke")),m=this.style.fade??(a!==void 0?0:1),p=this.style.onTop?Ne:this.style.bias??0,f=(this.style.glow??0)*e.scale,b=[],y=null;for(let k=c;k<=u;k++){let x=this.sample(k,s);y&&Math.abs(x[0]-y[0])+Math.abs(x[1]-y[1])+Math.abs(x[2]-y[2])<1e-9||(b.push(x),y=x)}let g=b.length-1;if(g<1)return;let w=Math.max(1,Math.ceil(g/48));for(let k=0;k<g;k+=w){let x=[],M=0,v=0;for(let R=k;R<=Math.min(g,k+w);R++){let $=b[R];e.project($[0],$[1],$[2])&&(x.push([e.px,e.py]),M+=e.pz,v+=e.ps)}if(x.length<2)continue;M/=x.length,v/=x.length;let P=Math.min(1,(k+w/2)/g),O=m+(1-m)*Math.pow(P,1.6),A=e.fogged(d[0],d[1],d[2],M);e.push(Me([ys(x)],A,o*O,h*v,f,"butt"),M+p)}}};function Xh(n,t,e,r={}){return new Tr(n,t,e,r)}var Fr=class extends Et{constructor(e={}){super();this.options=e;this.ranges=[e.x??[-4,4],e.y??[-4,4],e.z??[-2.5,2.5]],this.step=e.step??1,this.base.stroke=X(e.color??"dim"),this.base.strokeWidth=e.width??2;let r=e.labelSize??34,o=e.labels===!1?null:Array.isArray(e.labels)?e.labels:["x","y","z"];if(this.tags=o?o.map(s=>st(s,{size:r,display:!1,color:"ink"})):[],e.numbers){let s=[[1,0,0],[0,1,0],[0,0,1]];this.ranges.forEach((i,a)=>{for(let l of Ht(i[0],i[1],this.step)){if(l===0)continue;let c=[s[a][0]*l,s[a][1]*l,s[a][2]*l];this.numberNodes.push({node:_(String(l),{size:18,color:"dim"}),at:c})}})}}options;ranges;step;tags;numberNodes=[];emit(e){let r=this.objectAlpha(e)*this.get("strokeOpacity");if(r<=.002)return;let o=this.get("trimTo"),s=se(this.get("stroke")),i=this.get("strokeWidth")*e.scale,a=[[1,0,0],[0,1,0],[0,0,1]],l=this.options.onTop?Ne:this.options.bias??.4;this.ranges.forEach((c,u)=>{let h=a[u],d=16,m=c[0],p=m+(c[1]-m)*o;for(let f=0;f<d;f++){let b=m+(p-m)*f/d,y=m+(p-m)*(f+1)/d;if(!e.project(h[0]*b,h[1]*b,h[2]*b))continue;let g=e.px,w=e.py,k=e.pz;if(!e.project(h[0]*y,h[1]*y,h[2]*y))continue;let x=(k+e.pz)/2;e.push(Me([Mn(g,w,e.px,e.py)],e.fogged(s[0],s[1],s[2],x),r,i,0,"butt"),x+l)}if(this.options.ticks??!0)for(let f of Ht(c[0],p,this.step)){if(f===0||!e.project(h[0]*f,h[1]*f,h[2]*f))continue;let b=e.px,y=e.py,g=e.pz,w=5*e.ps*e.scale,k=Mn(b-(u===2?w:0),y-(u===2?0:w),b+(u===2?w:0),y+(u===2?0:w));e.push(Me([k],e.fogged(s[0],s[1],s[2],g),r,i*.8,0,"butt"),g+l)}if(o>.98&&e.project(h[0]*c[1],h[1]*c[1],h[2]*c[1])){let f=e.px,b=e.py,y=e.pz,g=c[1]-.2;if(e.project(h[0]*g,h[1]*g,h[2]*g)){let w=Math.hypot(f-e.px,b-e.py)||1,k=(f-e.px)/w,x=(b-e.py)/w,M=14*e.scale,v=M*.42,P=zr([f,b,f-k*M-x*v,b-x*M+k*v,f-k*M+x*v,b-x*M-k*v]);e.push(ve([P],e.fogged(s[0],s[1],s[2],y),r,null,0,0),y+l)}}})}labelsNow(e){let r=this.get("opacity")*this.get("strokeOpacity");if(r<=.002||this.get("trimTo")<.9)return[];let o=[],s=[[1,0,0],[0,1,0],[0,0,1]];this.tags.forEach((i,a)=>{let l=s[a],c=this.ranges[a][1]+.35,u=e.screen(l[0]*c,l[1]*c,l[2]*c);u&&(i.at(u),i.set("opacity",r),o.push(i))});for(let{node:i,at:a}of this.numberNodes){let l=e.screen(a[0],a[1],a[2]);l&&(i.at(l[0]+12,l[1]+14),i.set("opacity",r),o.push(i))}return o}};function Yh(n={}){return new Fr(n)}var Ir=class extends Et{constructor(e={}){super();this.options=e;this.base.stroke=X(e.color??"grid"),this.base.strokeWidth=e.width??1.2}options;emit(e){let r=this.objectAlpha(e)*(this.options.opacity??1)*this.get("strokeOpacity");if(r<=.002)return;let[o,s]=this.options.x??[-5,5],[i,a]=this.options.y??[-5,5],l=this.options.z??0,c=this.options.step??1,u=se(this.get("stroke")),h=this.get("strokeWidth")*e.scale,d=this.get("trimTo"),m=(p,f,b,y)=>{for(let w=0;w<10;w++){let k=w/10*d,x=(w+1)/10*d;if(!e.project(p+(b-p)*k,f+(y-f)*k,l))continue;let M=e.px,v=e.py,P=e.pz;if(!e.project(p+(b-p)*x,f+(y-f)*x,l))continue;let O=(P+e.pz)/2;e.push(Me([Mn(M,v,e.px,e.py)],e.fogged(u[0],u[1],u[2],O),r,h,0,"butt"),O-.05)}};for(let p of Ht(o,s,c))m(p,i,p,a);for(let p of Ht(i,a,c))m(o,p,s,p)}};function qh(n={}){return new Ir(n)}var Er=class extends Et{constructor(e,r,o={}){super();this.position=r;this.content=typeof e=="string"?o.math===!1?_(e,{size:o.size??28,color:o.color??"ink"}):st(e,{size:o.size??32,color:o.color??"ink",display:!1}):e,this.offset=o.offset??[0,0]}position;content;offset;emit(){}labelsNow(e){let r=this.get("opacity");if(r<=.002)return[];let o=oe(this.position),s=e.screen(o[0],o[1],o[2]);return s?(this.content.at(s[0]+this.offset[0],s[1]+this.offset[1]),this.content.set("opacity",r*this.get("trimTo")),[this.content]):[]}};function Uh(n,t,e={}){return new Er(n,t,e)}var Pn=class{film;canvas;ctx;options;raf=0;last=0;currentTime=0;playing=!1;scale=1;images=new Map;bloomLayers=[];observer=null;speed;constructor(t,e,r={}){this.canvas=t,this.film=e,this.options=r,this.speed=r.speed??1;let o=t.getContext("2d",{alpha:e.background===null});if(!o)throw new Error("This browser could not create a 2D canvas.");this.ctx=o,this.resize(),typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(()=>this.resize()),this.observer.observe(t)),this.paint(),r.autoplay&&this.play()}get time(){return this.currentTime}get isPlaying(){return this.playing}swap(t){let e=t.width!==this.film.width||t.height!==this.film.height;this.film=t,e&&(this.bloomLayers=[],this.resize()),this.paint()}resize(){let t=this.canvas.getBoundingClientRect(),e=this.options.pixelRatio??Math.min(2,globalThis.devicePixelRatio||1),r=t.width||this.film.width,o=Math.max(2,Math.round(r*e)),s=Math.max(2,Math.round(o*this.film.height/this.film.width));(this.canvas.width!==o||this.canvas.height!==s)&&(this.canvas.width=o,this.canvas.height=s,this.bloomLayers=[]),this.scale=o/this.film.width,this.playing||this.paint()}play(){this.playing||(this.currentTime>=this.film.duration-1e-6&&(this.currentTime=0),this.playing=!0,this.last=performance.now(),this.options.onState?.({playing:!0}),this.raf=requestAnimationFrame(this.tick))}pause(){this.playing&&(this.playing=!1,cancelAnimationFrame(this.raf),this.options.onState?.({playing:!1}))}toggle(){this.playing?this.pause():this.play()}seek(t){this.currentTime=Math.max(0,Math.min(this.film.duration,t)),this.paint(),this.options.onTime?.(this.currentTime)}next(){let t=this.film.chapters.find(e=>e.time>this.currentTime+.001);this.seek(t?t.time:this.film.duration)}previous(){let t=[...this.film.chapters].reverse().find(e=>e.time<this.currentTime-.25);this.seek(t?t.time:0)}destroy(){this.pause(),this.observer?.disconnect()}tick=t=>{if(!this.playing)return;let e=Math.max(0,Math.min(.1,(t-this.last)/1e3));this.last=t;let r=this.currentTime,o=r+e*this.speed;if(this.options.stepped){let s=this.film.chapters.find(i=>i.time>r+.001&&i.time<=o);if(s){this.currentTime=s.time,this.paint(),this.options.onTime?.(this.currentTime),this.pause();return}}if(o>=this.film.duration)if(this.options.loop)o%=this.film.duration;else{this.currentTime=this.film.duration,this.paint(),this.options.onTime?.(this.currentTime),this.pause();return}this.currentTime=o,this.paint(),this.options.onTime?.(this.currentTime),this.raf=requestAnimationFrame(this.tick)};lookupImage=t=>{let e=this.images.get(t.src);return e||(e=new Image,e.src=t.src,e.onload=()=>{this.playing||this.paint()},this.images.set(t.src,e)),e.complete&&e.naturalWidth>0?e:null};paint(){let t;try{t=this.film.frame(this.currentTime)}catch(e){if(e instanceof At){e.promise.then(()=>this.paint());return}throw e}Kn(this.ctx,t,this.scale,this.lookupImage),t.bloom>0&&t.dark&&this.applyBloom(t)}applyBloom(t){if(this.bloomLayers.length===0){let{width:a,height:l}=this.canvas;this.bloomLayers=[[4,.55],[8,.3],[16,.15]].map(([c,u])=>{let h=document.createElement("canvas");return h.width=Math.max(1,Math.round(a/c)),h.height=Math.max(1,Math.round(l/c)),{canvas:h,ctx:h.getContext("2d"),factor:c,weight:u}})}let{width:e}=this.canvas,r="filter"in this.ctx,o=[2.83,3.65,3.65],s=this.canvas;this.bloomLayers.forEach((a,l)=>{let{ctx:c,canvas:u}=a;c.setTransform(1,0,0,1,0,0),c.globalCompositeOperation="source-over",c.clearRect(0,0,u.width,u.height),c.imageSmoothingEnabled=!0,c.imageSmoothingQuality="medium",r&&(c.filter=`blur(${(o[l]*e/1920).toFixed(2)}px)`),c.drawImage(s,0,0,u.width,u.height),r&&(c.filter="none"),l===0&&t.background&&(c.globalCompositeOperation="difference",c.fillStyle=t.background,c.fillRect(0,0,u.width,u.height),c.globalCompositeOperation="source-over"),s=u});let i=this.ctx;i.setTransform(1,0,0,1,0,0),i.globalCompositeOperation="screen",i.imageSmoothingEnabled=!0,i.imageSmoothingQuality="high";for(let a of this.bloomLayers)i.globalAlpha=Math.min(1,t.bloom*a.weight*2.4),i.drawImage(a.canvas,0,0,this.canvas.width,this.canvas.height);i.globalAlpha=1,i.globalCompositeOperation="source-over"}};function ws(n){let t=Math.floor(n/60),e=Math.floor(n%60);return`${t}:${String(e).padStart(2,"0")}`}var pa=`
5
5
  :host { display: block; position: relative; background: #0b0c10; border-radius: inherit; overflow: hidden; font: 12px/1 ui-monospace, "JetBrains Mono", monospace; color: #f2efe6; aspect-ratio: var(--vz-aspect, 16 / 9); }
6
6
  canvas { display: block; width: 100%; height: 100%; }
7
7
  .chrome { position: absolute; inset: auto 0 0 0; display: flex; align-items: center; gap: 12px; padding: 28px 14px 12px; background: linear-gradient(to top, rgba(0,0,0,.62), rgba(0,0,0,0)); opacity: 0; transition: opacity .18s ease; }
@@ -16,4 +16,4 @@ button:hover { background: rgba(255,255,255,.12); }
16
16
  .tick { position: absolute; top: 4px; width: 1px; height: 8px; background: rgba(255,255,255,.55); }
17
17
  .time { font-variant-numeric: tabular-nums; opacity: .82; white-space: nowrap; }
18
18
  svg { width: 14px; height: 14px; fill: currentColor; }
19
- `,fs='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2.5v11l9-5.5z"/></svg>',la='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2.5h3v11H4zM9 2.5h3v11H9z"/></svg>',ca='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 6V2h4v1.5H3.5V6zM10 2h4v4h-1.5V3.5H10zM2 10h1.5v2.5H6V14H2zM12.5 10H14v4h-4v-1.5h2.5z"/></svg>';function zo(n,t="vz-film"){if(typeof customElements>"u"||customElements.get(t))return;class e extends HTMLElement{player=null;visible=!1;started=!1;wantsPlay=!1;intersection=null;keys=null;connectedCallback(){let r=this.shadowRoot??this.attachShadow({mode:"open"}),s=this.getAttribute("label")??"Animation";r.innerHTML=`<style>${aa}</style><canvas role="img"></canvas><div class="chrome"><button class="toggle" type="button" aria-label="Play">${fs}</button><div class="track" role="slider" tabindex="0" aria-label="Seek" aria-valuemin="0"><div class="fill"></div></div><span class="time">0:00</span><button class="full" type="button" aria-label="Full screen">${ca}</button></div>`,r.querySelector("canvas").setAttribute("aria-label",s),this.setAttribute("data-paused",""),this.intersection=new IntersectionObserver(i=>{this.visible=i.some(a=>a.isIntersecting),this.visible&&!this.started&&this.start(),this.player&&(!this.visible&&this.player.isPlaying?(this.wantsPlay=!0,this.player.pause()):this.visible&&this.wantsPlay&&(this.wantsPlay=!1,this.player.play()))},{rootMargin:"240px"}),this.intersection.observe(this)}disconnectedCallback(){this.intersection?.disconnect(),this.player?.destroy(),this.player=null,this.started=!1}get controller(){return this.player}async start(){this.started=!0;let r=this.getAttribute("src");if(!r)return;let s=this.shadowRoot,i;try{i=await n(r,{look:this.getAttribute("look")??void 0,background:this.getAttribute("background")??void 0})}catch(g){let w=g instanceof Error?g.message:String(g);console.error(`vz-film: could not load ${r}:`,g);let x=document.createElement("div");x.setAttribute("role","alert"),x.style.cssText="position:absolute;inset:0;display:grid;place-items:center;padding:24px;text-align:center;line-height:1.5;color:#ff8d8d",x.textContent=`This film could not load: ${w}`,s.append(x),this.dispatchEvent(new CustomEvent("error",{detail:{error:g}}));return}this.style.setProperty("--vz-aspect",`${i.width} / ${i.height}`);let a=s.querySelector("canvas"),l=s.querySelector(".toggle"),c=s.querySelector(".fill"),u=s.querySelector(".time"),h=s.querySelector(".track"),d=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,m=this.hasAttribute("autoplay")&&!d;h.setAttribute("aria-valuemax",String(Math.round(i.duration)));for(let g of i.chapters){if(g.time<=0)continue;let w=document.createElement("div");w.className="tick",w.style.left=`${g.time/i.duration*100}%`,h.append(w)}let p=g=>{c.style.width=`${g/i.duration*100}%`,u.textContent=`${ps(g)} / ${ps(i.duration)}`,h.setAttribute("aria-valuenow",String(Math.round(g))),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:g}}))},f=new vn(a,i,{loop:this.hasAttribute("loop"),stepped:this.hasAttribute("stepped"),onTime:p,onState:({playing:g})=>{l.innerHTML=g?la:fs,l.setAttribute("aria-label",g?"Pause":"Play"),g?this.removeAttribute("data-paused"):this.setAttribute("data-paused","")}});this.player=f;let b=this.getAttribute("start");d&&!this.hasAttribute("start")?f.seek(i.duration):b?f.seek(Number(b)):p(0),l.addEventListener("click",()=>f.toggle()),a.addEventListener("click",()=>f.toggle()),s.querySelector(".full").addEventListener("click",()=>{document.fullscreenElement?document.exitFullscreen():this.requestFullscreen()});let y=g=>{let w=h.getBoundingClientRect();f.seek((g.clientX-w.left)/w.width*i.duration)};h.addEventListener("pointerdown",g=>{h.setPointerCapture(g.pointerId),y(g);let w=x=>y(x);h.addEventListener("pointermove",w),h.addEventListener("pointerup",()=>h.removeEventListener("pointermove",w),{once:!0})}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.keys?.abort(),this.keys=new AbortController,this.addEventListener("keydown",g=>{g.metaKey||g.ctrlKey||g.altKey||(g.key===" "||g.key==="k"?(g.preventDefault(),f.toggle()):g.key==="ArrowRight"?(g.preventDefault(),this.hasAttribute("stepped")?f.play():f.seek(f.time+5)):g.key==="ArrowLeft"?(g.preventDefault(),this.hasAttribute("stepped")?f.previous():f.seek(f.time-5)):g.key==="f"&&(document.fullscreenElement?document.exitFullscreen():this.requestFullscreen()))},{signal:this.keys.signal}),m&&this.visible?f.play():m&&(this.wantsPlay=!0),this.dispatchEvent(new CustomEvent("ready",{detail:{film:i,player:f}}))}}customElements.define(t,e)}Kn(new URL("../../assets/",import.meta.url).href);var bs=new Map;function ua(n,t={}){let e=new URL(n,document.baseURI).href,o=`${e}|${t.look??""}|${t.background??""}`,r=bs.get(o);return r||(r=import(e).then(s=>{if(!Ie(s.default))throw new Error(`${n} must export a film as its default export.`);let i={};if(t.look&&(i.look=t.look),t.background){let a=qe(i.look??s.default.options.look);i.look={...a,background:t.background,colors:{...a.colors,bg:t.background}},i.background=t.background}return ln(s.default,i)}),bs.set(o,r)),r}zo(ua);export{go as ArrayCells,Un as Axes,To as Axes3D,ao as BarChart,Po as Callout,yo as CodeBlock,an as CompiledFilm,to as ComplexPlane,vo as Connector,Ge as Counter,Co as Curve3D,ks as EMPTY_BOUNDS,so as Epicycles,vn as FilmPlayer,bn as Graph,fo as GraphEdge,po as GraphNode,Fo as GridPlane3D,We as Heatmap,lo as Histogram,zt as IDENTITY,Mo as InfoBox,qo as LOOKS,Io as Label3D,ro as LabeledDot,kn as Line3D,uo as LineChart,oo as MatrixNode,wo as NeuralNet,P as Node,Qn as NumberLine,Ve as NumberPlane,Et as Object3D,fn as PieChart,Mn as Points3D,co as Scatter,No as Scene3D,sn as Stage,no as StreamLines,je as Surface3D,Nt as Suspend,wn as SvgNode,un as TexNode,cn as TextNode,xo as TokenRow,Ro as Trail3D,bo as TreeGraph,pt as Value,So as Vector3D,eo as VectorField,Oo as View3D,fl as along,qc as angleMark,ll as appear,Q as apply,Wc as applyComplex,bl as applyMatrix,ic as arc,St as arcPath,_c as areaUnder,Vu as arrayCells,ze as arrow,Du as attentionMatrix,pc as axes,Bh as axes3d,pu as barChart,Ns as blueprint,Ca as bounce,Br as brace,Jc as braceLabel,Gn as buildOps,el as call,Qu as callout,Cs as chalk,ji as checkFilm,Lr as circle,Dt as circlePath,xl as circumscribe,Lu as codeBlock,zs as colorAlong,ln as compileFilm,Dc as complex,Bc as complexPlane,fe as compose,ha as concat,Zu as connector,dh as countUp,hh as counter,Yt as css,Ea as cubicBezier,oc as curve,Ih as curve3d,be as curveThrough,Yc as dashedGuides,bc as decimal,zo as defineFilmElement,tl as delay,wu as donut,gt as dot,nl as draw,Ia as during,Ot as dynamic,ba as easeInCubic,Ma as easeInExpo,ya as easeInOutCubic,xa as easeInOutQuint,pa as easeInQuad,ga as easeOutCubic,ka as easeOutExpo,fa as easeOutQuad,wa as easeOutQuint,sc as ellipse,ru as epicycles,rl as erase,pl as fade,sl as fadeIn,il as fadeOut,li as film,kl as flash,xe as fontFor,nu as fourier,Qr as fourierPoint,ii as frameInkBounds,jn as frameToSvg,sa as fromSvg,Ee as glyphPath,Eu as graph,Wh as gridPlane3d,Vn as group,al as grow,xu as heatmap,fh as highlightSweep,fu as histogram,yl as indicate,Uu as infoBox,Wt as invert,Ie as isFilm,_n as isSuspend,Dh as label3d,tu as labeledDot,Qa as lagged,Ju as legend,Y as line,Eh as line3d,gu as lineChart,le as linePath,Te as linear,Is as linearGradient,Ta as lingering,ua as loadFilm,Xt as matScale,Zc as matrix,Ye as midnight,he as mixColor,gl as morph,$u as morphCode,we as morphMatching,ul as moveTo,ot as mul,Ss as neon,Bu as neuralNet,Ra as notQuiteThere,$c as numberLine,Oa as overshoot,Hn as paintFrame,Os as paper,Ln as par,rc as parametric,_e as parametricPath,Rh as parametricSurface,Gt as parseColor,Tr as parseFont,vt as parseSvgPath,bt as pathBounds,At as pathLength,Xo as pathToD,yu as pie,fc as plane,Lh as point3d,Pt as pointAt,Vh as points3d,Z as polyPath,Pi as polygon,nc as polyline,Bn as pulse,Es as radialGradient,Fe as ramp,cr as recolor,$r as rect,K as rectPath,ac as regularPolygon,qe as resolveLook,js as retime,Nn as reverseRing,Hc as riemann,Uc as rightAngle,Mt as ring,ue as ringCenter,Re as ringLength,su as ringThrough,Ml as ripple,ml as rotate,Fa as runningStart,Pa as rushFrom,va as rushInto,ou as samplePath,dl as scaleBy,bu as scatter,Sh as scene3d,Xc as secantLine,Vt as segmentCount,sr as seq,Kn as setAssetBase,wl as shake,vi as shape,hl as shift,ce as signedArea,Aa as slowInto,dt as smooth,As as smoothBy,Lt as smoothPath,ma as smoother,Ji as sparkline,Fh as sphere,mh as spin,Na as spring,jc as streamLines,On as subdivideEach,Th as surface,Qc as surroundingBox,ec as svgPath,ph as swap,ge as tangentAt,Kc as tangentLine,st as tex,_ as text,Rn as thereAndBack,Sa as thereAndBackWithPause,de as to,X as toPaint,Ui as tokenize,Wu as tokens,eu as traced,$h as trail3d,rt as transformPath,zu as tree,Jt as trimPath,Go as trimRing,ch as typewriter,Xe as unionBounds,cl as vanish,zh as vector3d,Gc as vectorField,$n as warp,_o as warpPath,Yo as wiggle,uh as wipe,ol as write};
19
+ `,xs='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2.5v11l9-5.5z"/></svg>',fa='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M4 2.5h3v11H4zM9 2.5h3v11H9z"/></svg>',ba='<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M2 6V2h4v1.5H3.5V6zM10 2h4v4h-1.5V3.5H10zM2 10h1.5v2.5H6V14H2zM12.5 10H14v4h-4v-1.5h2.5z"/></svg>';function $r(n,t="vz-film"){if(typeof customElements>"u"||customElements.get(t))return;class e extends HTMLElement{player=null;visible=!1;started=!1;wantsPlay=!1;intersection=null;keys=null;connectedCallback(){let o=this.shadowRoot??this.attachShadow({mode:"open"}),s=this.getAttribute("label")??"Animation";o.innerHTML=`<style>${pa}</style><canvas role="img"></canvas><div class="chrome"><button class="toggle" type="button" aria-label="Play">${xs}</button><div class="track" role="slider" tabindex="0" aria-label="Seek" aria-valuemin="0"><div class="fill"></div></div><span class="time">0:00</span><button class="full" type="button" aria-label="Full screen">${ba}</button></div>`,o.querySelector("canvas").setAttribute("aria-label",s),this.setAttribute("data-paused",""),this.intersection=new IntersectionObserver(i=>{this.visible=i.some(a=>a.isIntersecting),this.visible&&!this.started&&this.start(),this.player&&(!this.visible&&this.player.isPlaying?(this.wantsPlay=!0,this.player.pause()):this.visible&&this.wantsPlay&&(this.wantsPlay=!1,this.player.play()))},{rootMargin:"240px"}),this.intersection.observe(this)}disconnectedCallback(){this.intersection?.disconnect(),this.player?.destroy(),this.player=null,this.started=!1}get controller(){return this.player}async start(){this.started=!0;let o=this.getAttribute("src");if(!o)return;let s=this.shadowRoot,i;try{i=await n(o,{look:this.getAttribute("look")??void 0,background:this.getAttribute("background")??void 0})}catch(g){let w=g instanceof Error?g.message:String(g);console.error(`vz-film: could not load ${o}:`,g);let k=document.createElement("div");k.setAttribute("role","alert"),k.style.cssText="position:absolute;inset:0;display:grid;place-items:center;padding:24px;text-align:center;line-height:1.5;color:#ff8d8d",k.textContent=`This film could not load: ${w}`,s.append(k),this.dispatchEvent(new CustomEvent("error",{detail:{error:g}}));return}this.style.setProperty("--vz-aspect",`${i.width} / ${i.height}`);let a=s.querySelector("canvas"),l=s.querySelector(".toggle"),c=s.querySelector(".fill"),u=s.querySelector(".time"),h=s.querySelector(".track"),d=typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches,m=this.hasAttribute("autoplay")&&!d;h.setAttribute("aria-valuemax",String(Math.round(i.duration)));for(let g of i.chapters){if(g.time<=0)continue;let w=document.createElement("div");w.className="tick",w.style.left=`${g.time/i.duration*100}%`,h.append(w)}let p=g=>{c.style.width=`${g/i.duration*100}%`,u.textContent=`${ws(g)} / ${ws(i.duration)}`,h.setAttribute("aria-valuenow",String(Math.round(g))),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:g}}))},f=new Pn(a,i,{loop:this.hasAttribute("loop"),stepped:this.hasAttribute("stepped"),onTime:p,onState:({playing:g})=>{l.innerHTML=g?fa:xs,l.setAttribute("aria-label",g?"Pause":"Play"),g?this.removeAttribute("data-paused"):this.setAttribute("data-paused","")}});this.player=f;let b=this.getAttribute("start");d&&!this.hasAttribute("start")?f.seek(i.duration):b?f.seek(Number(b)):p(0),l.addEventListener("click",()=>f.toggle()),a.addEventListener("click",()=>f.toggle()),s.querySelector(".full").addEventListener("click",()=>{document.fullscreenElement?document.exitFullscreen():this.requestFullscreen()});let y=g=>{let w=h.getBoundingClientRect();f.seek((g.clientX-w.left)/w.width*i.duration)};h.addEventListener("pointerdown",g=>{h.setPointerCapture(g.pointerId),y(g);let w=k=>y(k);h.addEventListener("pointermove",w),h.addEventListener("pointerup",()=>h.removeEventListener("pointermove",w),{once:!0})}),this.hasAttribute("tabindex")||(this.tabIndex=0),this.keys?.abort(),this.keys=new AbortController,this.addEventListener("keydown",g=>{g.metaKey||g.ctrlKey||g.altKey||(g.key===" "||g.key==="k"?(g.preventDefault(),f.toggle()):g.key==="ArrowRight"?(g.preventDefault(),this.hasAttribute("stepped")?f.play():f.seek(f.time+5)):g.key==="ArrowLeft"?(g.preventDefault(),this.hasAttribute("stepped")?f.previous():f.seek(f.time-5)):g.key==="f"&&(document.fullscreenElement?document.exitFullscreen():this.requestFullscreen()))},{signal:this.keys.signal}),m&&this.visible?f.play():m&&(this.wantsPlay=!0),this.dispatchEvent(new CustomEvent("ready",{detail:{film:i,player:f}}))}}customElements.define(t,e)}Yn(new URL("../../assets/",import.meta.url).href);var ks=new Map;function ga(n,t={}){let e=new URL(n,document.baseURI).href,r=`${e}|${t.look??""}|${t.background??""}`,o=ks.get(r);return o||(o=import(e).then(s=>{if(!Ee(s.default))throw new Error(`${n} must export a film as its default export.`);let i={};if(t.look&&(i.look=t.look),t.background){let a=qe(i.look??s.default.options.look);i.look={...a,background:t.background,colors:{...a.colors,bg:t.background}},i.background=t.background}return ln(s.default,i)}),ks.set(r,o)),o}$r(ga);export{yr as ArrayCells,Jn as Axes,Fr as Axes3D,cr as BarChart,Pr as Callout,wr as CodeBlock,an as CompiledFilm,nr as ComplexPlane,Nr as Connector,je as Counter,Sr as Curve3D,Os as EMPTY_BOUNDS,ar as Epicycles,Pn as FilmPlayer,bn as Graph,br as GraphEdge,fr as GraphNode,Ir as GridPlane3D,De as Heatmap,ur as Histogram,zt as IDENTITY,vr as InfoBox,Ur as LOOKS,Er as Label3D,ir as LabeledDot,vn as Line3D,dr as LineChart,sr as MatrixNode,kn as Narration,xr as NeuralNet,N as Node,er as NumberLine,Le as NumberPlane,Et as Object3D,fn as PieChart,Nn as Points3D,hr as Scatter,Cr as Scene3D,xn as SceneClock,sn as Stage,or as StreamLines,He as Surface3D,At as Suspend,wn as SvgNode,un as TexNode,cn as TextNode,kr as TokenRow,Tr as Trail3D,gr as TreeGraph,pt as Value,Rr as Vector3D,rr as VectorField,Ar as View3D,kl as along,nu as angleMark,fl as appear,Q as apply,Xc as applyComplex,Ml as applyMatrix,dc as arc,St as arcPath,Jc as areaUnder,ju as arrayCells,$e as arrow,Yu as attentionMatrix,kc as axes,Yh as axes3d,ku as barChart,Fs as blueprint,za as bounce,Go as brace,su as braceLabel,Hn as buildOps,ll as call,ih as callout,fs as captionLines,Is as chalk,qi as checkFilm,Wo as circle,Dt as circlePath,Ol as circumscribe,Hu as codeBlock,Ws as colorAlong,ln as compileFilm,Yc as complex,Kc as complexPlane,fe as compose,ya as concat,oh as connector,wh as countUp,yh as counter,Yt as css,Da as cubicBezier,cc as curve,Gh as curve3d,be as curveThrough,eu as dashedGuides,vc as decimal,$r as defineFilmElement,al as delay,Ou as donut,gt as dot,cl as draw,Wa as during,Ot as dynamic,va as easeInCubic,Sa as easeInExpo,Pa as easeInOutCubic,Aa as easeInOutQuint,ka as easeInQuad,Na as easeOutCubic,Ca as easeOutExpo,Ma as easeOutQuad,Oa as easeOutQuint,hc as ellipse,hu as epicycles,hl as erase,ho as fade,dl as fadeIn,ml as fadeOut,mi as film,Al as flash,xe as fontFor,cu as fourier,ns as fourierPoint,hi as frameInkBounds,_n as frameToSvg,ha as fromSvg,ze as glyphPath,Du as graph,qh as gridPlane3d,Vn as group,pl as grow,Au as heatmap,Mh as highlightSweep,Mu as histogram,pc as image,Nl as indicate,rh as infoBox,Wt as invert,Ee as isFilm,Xn as isSuspend,Uh as label3d,au as labeledDot,il as lagged,sh as legend,Y as line,jh as line3d,Nu as lineChart,le as linePath,Fe as linear,Vs as linearGradient,Va as lingering,ga as loadFilm,Xt as matScale,ou as matrix,Ye as midnight,he as mixColor,vl as morph,_u as morphCode,we as morphMatching,gl as moveTo,rt as mul,da as narration,Es as neon,Ku as neuralNet,La as notQuiteThere,_c as numberLine,Ia as overshoot,Kn as paintFrame,Ts as paper,Bn as par,uc as parametric,_e as parametricPath,Bh as parametricSurface,Gt as parseColor,Eo as parseFont,vt as parseSvgPath,bt as pathBounds,Pt as pathLength,Yr as pathToD,Pu as pie,Mc as plane,Kh as point3d,Nt as pointAt,_h as points3d,Z as polyPath,Si as polygon,lc as polyline,Dn as pulse,Bs as radialGradient,Ie as ramp,uo as recolor,Do as rect,K as rectPath,mc as regularPolygon,qe as resolveLook,Ys as retime,Sn as reverseRing,Zc as riemann,ru as rightAngle,Mt as ring,ue as ringCenter,Te as ringLength,du as ringThrough,Cl as ripple,xl as rotate,Ba as runningStart,Ta as rushFrom,Ra as rushInto,uu as samplePath,wl as scaleBy,vu as scatter,Vh as scene3d,tu as secantLine,$t as segmentCount,io as seq,Yn as setAssetBase,Pl as shake,Ci as shape,yl as shift,ce as signedArea,Fa as slowInto,dt as smooth,Rs as smoothBy,Lt as smoothPath,xa as smoother,oa as sparkline,Dh as sphere,xh as spin,Ea as spring,Uc as streamLines,Cn as subdivideEach,Wh as surface,iu as surroundingBox,ac as svgPath,kh as swap,ge as tangentAt,Qc as tangentLine,st as tex,_ as text,Fn as thereAndBack,$a as thereAndBackWithPause,de as to,X as toPaint,na as tokenize,Xu as tokens,lu as traced,Xh as trail3d,ot as transformPath,Gu as tree,Jt as trimPath,jr as trimRing,bh as typewriter,Xe as unionBounds,bl as vanish,Hh as vector3d,qc as vectorField,Wn as warp,Kr as warpPath,qr as wiggle,gh as wipe,ul as write};