@weasel-js/headless 1.15.2 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- "use strict";(()=>{var eG=Object.create;var fy=Object.defineProperty;var tG=Object.getOwnPropertyDescriptor;var nG=Object.getOwnPropertyNames;var rG=Object.getPrototypeOf,oG=Object.prototype.hasOwnProperty;var Q=(e,t)=>()=>(e&&(t=e(e=0)),t);var iG=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),sG=(e,t)=>{for(var n in t)fy(e,n,{get:t[n],enumerable:!0})},aG=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of nG(t))!oG.call(e,o)&&o!==n&&fy(e,o,{get:()=>t[o],enumerable:!(r=tG(t,o))||r.enumerable});return e};var lG=(e,t,n)=>(n=e!=null?eG(rG(e)):{},aG(t||!e||!e.__esModule?fy(n,"default",{value:e,enumerable:!0}):n,e));function ls(e){return e<0?0:e>1?1:e}function fr(e,t,n){return e+(t-e)*n}function us(e){return e>0?1:e<0?-1:0}var ml=Q(()=>{"use strict"});function xd(e,t){return[1,0,0,1,e,t]}function yl(e){let t=Math.cos(e),n=Math.sin(e);return[t,n,-n,t,0,0]}function ht(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function pr(e){let t=e[0]*e[3]-e[1]*e[2],n=Math.max(e[0]*e[0]+e[1]*e[1],e[2]*e[2]+e[3]*e[3]);if(!(Math.abs(t)>1e-12*n))return null;let r=1/t,o=e[3]*r,i=-e[1]*r,s=-e[2]*r,a=e[0]*r;return[o,i,s,a,-(e[4]*o+e[5]*s),-(e[4]*i+e[5]*a)]}function wn(e,t,n){return[e[0]*t+e[2]*n+e[4],e[1]*t+e[3]*n+e[5]]}function hr(e,t,n,r,o,i,s,a){let l=n===0?1:s/n,u=r===0?1:a/r;return[l,0,0,u,o-e*l,i-t*u]}function ro(e,t,n){return ht(xd(e,t),ht(yl(n),xd(-e,-t)))}function $y(e,t){let n=new Float64Array(e.length),r=t[0],o=t[1],i=t[2],s=t[3],a=t[4],l=t[5];for(let u=0;u+1<e.length;u+=2){let c=e[u],d=e[u+1];n[u]=r*c+i*d+a,n[u+1]=o*c+s*d+l}return n}var cs=Q(()=>{"use strict"});function wd(e,t){return t[0]>=e[0]&&t[1]>=e[1]&&t[2]<=e[2]&&t[3]<=e[3]}function gl(e,t,n,r){return Float64Array.of(e,t,e+n,t,e+n,t+r,e,t+r)}function Yy(e,t){return e[0]<=t[2]&&t[0]<=e[2]&&e[1]<=t[3]&&t[1]<=e[3]}var bl=Q(()=>{"use strict"});function qG(){let e=[];for(let{code:t,coords:n}of Object.values(Zo))e[t]=n;return e}function oo(e){return zS[e]}function Ge(e,t,n){let r=0,o=0,i=0,s=0,a=0,l=!1;for(let u=0;u<e.length;u++){let c=e[u],d=!l&&c!==le&&c!==fe;if(d&&(s=o,a=i),l=c!==fe,n(c,r,o,i,u,d)===!1)return;let f=oo(c);if(f===void 0)throw new Error(`forEachSegment: unknown command code ${c}`);f>0?(o=t[r+f-2],i=t[r+f-1],r+=f,c===le&&(s=o,a=i)):c===fe&&(o=s,i=a)}}var Zo,le,ce,xe,we,fe,zS,Je=Q(()=>{"use strict";Zo={M:{code:0,coords:2},L:{code:1,coords:2},C:{code:2,coords:6},Q:{code:3,coords:4},Z:{code:4,coords:0}},le=Zo.M.code,ce=Zo.L.code,xe=Zo.C.code,we=Zo.Q.code,fe=Zo.Z.code,zS=qG()});function Ve(e,t,n,r,o,i,s,a,l){let u=1-l,c=u*u*u,d=3*u*u*l,f=3*u*l*l,p=l*l*l;return[c*e+d*n+f*o+p*s,c*t+d*r+f*i+p*a]}function io(e,t,n,r,o,i){return[e+2/3*(n-e),t+2/3*(r-t),o+2/3*(n-o),i+2/3*(r-i)]}function KS(e,t,n,r){let o=-e+3*t-3*n+r,i=2*(e-2*t+n),s=-e+t,a=[],l=u=>{u>0&&u<1&&a.push(u)};if(Math.abs(o)<1e-12)Math.abs(i)>1e-12&&l(-s/i);else{let u=i*i-4*o*s;if(u>=0){let c=Math.sqrt(u);l((-i+c)/(2*o)),l((-i-c)/(2*o))}}return a}function qy(e,t,n,r,o,i,s,a){let l=Math.min(e,s),u=Math.max(e,s),c=Math.min(t,a),d=Math.max(t,a);for(let f of KS(e,n,o,s)){let[p]=Ve(e,t,n,r,o,i,s,a,f);p<l&&(l=p),p>u&&(u=p)}for(let f of KS(t,r,i,a)){let[,p]=Ve(e,t,n,r,o,i,s,a,f);p<c&&(c=p),p>d&&(d=p)}return[l,c,u,d]}function so(e,t,n,r,o,i,s,a,l){let u=e+(n-e)*l,c=t+(r-t)*l,d=n+(o-n)*l,f=r+(i-r)*l,p=o+(s-o)*l,h=i+(a-i)*l,m=u+(d-u)*l,g=c+(f-c)*l,b=d+(p-d)*l,x=f+(h-f)*l,w=m+(b-m)*l,y=g+(x-g)*l;return[[e,t,u,c,m,g,w,y],[w,y,b,x,p,h,s,a]]}function jS(e,t,n,r,o,i,s){let a=e+(n-e)*s,l=t+(r-t)*s,u=n+(o-n)*s,c=r+(i-r)*s,d=a+(u-a)*s,f=l+(c-l)*s;return[[e,t,a,l,d,f],[d,f,u,c,o,i]]}var Pn=Q(()=>{"use strict"});function $S(e,t){if(!(t>0))return 0;let n=e/t;return n<0?0:n>1?1:n}var YS=Q(()=>{"use strict"});function XG(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function Bt(e,t){return Math.sqrt(XG(e,t))}function ei(e,t,n){return{x:fr(e.x,t.x,n),y:fr(e.y,t.y,n)}}function Xy(e,t,n,r,o,i){let s=o-n,a=i-r;return $S((e-n)*s+(t-r)*a,s*s+a*a)}function JG(e,t,n,r,o,i){let s=Xy(e,t,n,r,o,i),a=e-(s===1?o:fr(n,o,s)),l=t-(s===1?i:fr(r,i,s));return a*a+l*l}function Tn(e,t,n,r,o,i){return Math.sqrt(JG(e,t,n,r,o,i))}var ti=Q(()=>{"use strict";YS();ml()});function xl(e,t,n,r,o,i){let s=Xy(e,t,n,r,o,i),a=s===1?o:fr(n,o,s),l=s===1?i:fr(r,i,s);return{x:a,y:l,t:s,dist:Math.sqrt((e-a)*(e-a)+(t-l)*(t-l))}}function ni(e,t,n,r,o,i,s,a,l,u){let c=-n+3*o-3*s+l,d=-r+3*i-3*a+u,f=3*n-6*o+3*s,p=3*r-6*i+3*a,h=3*(o-n),m=3*(i-r),g=S=>{let[v,A]=Ve(n,r,o,i,s,a,l,u,S);return(v-e)**2+(A-t)**2},b=[];for(let S=0;S<=ao;S++)b.push(g(S/ao));let x=0,w=b[0];for(let S=0;S<=ao;S++){let v=b[S],A=S>0?b[S-1]:1/0,N=S<ao?b[S+1]:1/0;if(!(v<=A&&v<=N))continue;let M=Math.max(0,(S-1)/ao),C=Math.min(1,(S+1)/ao),F=S/ao;for(let W=0;W<QG;W++){let J=F*F,se=c*J*F+f*J+h*F+n-e,ke=d*J*F+p*J+m*F+r-t,ae=3*c*J+2*f*F+h,ve=3*d*J+2*p*F+m,G=6*c*F+2*f,K=6*d*F+2*p,$=se*ae+ke*ve,ee=ae*ae+ve*ve+se*G+ke*K;if($>0)C=F;else if($<0)M=F;else break;let te=ee>0?F-$/ee:NaN;te>M&&te<C||(te=(M+C)/2);let he=Math.abs(te-F);if(F=te,he<qS||C-M<qS)break}let B=g(F),[D,j]=B<=v?[F,B]:[S/ao,v];j<w&&(w=j,x=D)}let[y,P]=Ve(n,r,o,i,s,a,l,u,x);return{x:y,y:P,t:x,dist:Math.hypot(y-e,P-t)}}function XS(e,t,n,r,o,i,s,a){let[l,u,c,d]=io(n,r,o,i,s,a);return ni(e,t,n,r,l,u,c,d,s,a)}var ao,QG,qS,Pd=Q(()=>{"use strict";Pn();ti();ml();ao=32,QG=40,qS=1e-14});function $e(e){return e.origin?JS(e,Float64Array.from(e.coords)):e.coords}function JS(e,t){let n=e.origin;if(n===void 0)return t;for(let r=0;r+1<t.length;r+=2)t[r]+=n.x,t[r+1]+=n.y;return t}function At(e,t){let n=e?.x??0,r=e?.y??0,o=new Float32Array(t.length);for(let i=0;i+1<t.length;i+=2)o[i]=t[i]-n,o[i+1]=t[i+1]-r;return o}function Sn(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let s=0;s+1<e.length;s+=2){let a=e[s],l=e[s+1];a<t&&(t=a),a>r&&(r=a),l<n&&(n=l),l>o&&(o=l)}let i=Math.max(Math.abs(t),Math.abs(r),Math.abs(n),Math.abs(o));if(!(!(i>=QS)||!Number.isFinite(i)))return{x:Math.round((t+r)/2),y:Math.round((n+o)/2)}}function Jy(e){let t=0,n=0;for(let l of e)t+=l.commands.length,n+=l.coords.length;let r=e[0]?.origin,o=new Uint8Array(t),i=new Float32Array(n),s=0,a=0;for(let l of e)o.set(l.commands,s),s+=l.commands.length,i.set(l.origin===r?l.coords:At(r,$e(l)),a),a+=l.coords.length;return{kind:"polygon",commands:o,coords:i,fillRule:"nonzero",...r?{origin:r}:{}}}var IQ,QS,tn=Q(()=>{"use strict";IQ=Object.freeze({x:0,y:0});QS=16384});function ek(e,t,n,r){return{kind:"rect",x:e,y:t,width:n,height:r}}function Td(e){let t=new _e,n=e[0];if(!n)return ek(0,0,0,0);t.moveTo(n.x,n.y);for(let r=1;r<e.length;r++){let o=e[r];o&&t.lineTo(o.x,o.y)}return t.build()}function Qy(e,t={}){if(e.length===0)return{kind:"polygon",commands:new Uint8Array,coords:new Float32Array,fillRule:t.fillRule??"nonzero"};let n=new _e;t.fillRule&&n.setFillRule(t.fillRule),n.moveTo(e[0].x,e[0].y);for(let r=1;r<e.length;r++)n.lineTo(e[r].x,e[r].y);return n.close(),n.build()}function Zy(e){let t=e.x+e.width/2,n=e.y+e.height/2,r=e.width/2,o=e.height/2,i=r*ZS,s=o*ZS,a=new _e;return a.moveTo(t+r,n),a.curveTo(t+r,n+s,t+i,n+o,t,n+o),a.curveTo(t-i,n+o,t-r,n+s,t-r,n),a.curveTo(t-r,n-s,t-i,n-o,t,n-o),a.curveTo(t+i,n-o,t+r,n-s,t+r,n),a.close(),a.build()}function eg(e,t,n,r=0){let o=new _e;for(let i=0;i<n;i++){let s=r+i/n*Math.PI*2,a=e.x+t*Math.cos(s),l=e.y+t*Math.sin(s);i===0?o.moveTo(a,l):o.lineTo(a,l)}return o.close(),o.build()}function tg(e,t,n=5,r=t/2,o=0){let i=new _e,s=n*2;for(let a=0;a<s;a++){let l=o+a/s*Math.PI*2,u=a%2===0?t:r,c=e.x+u*Math.cos(l),d=e.y+u*Math.sin(l);a===0?i.moveTo(c,d):i.lineTo(c,d)}return i.close(),i.build()}function ng(e,t){let n=new _e;return n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.build()}var _e,ZS,mr=Q(()=>{"use strict";Je();tn();_e=class e{cmds=[];xs=[];fillRule="nonzero";origin;auto=!1;static fromPath(t){let n=new e;return n.cmds=Array.from(t.commands),n.xs=Array.from(t.coords),n.fillRule=t.fillRule,t.origin&&(n.origin={x:t.origin.x,y:t.origin.y}),n}setOrigin(t,n){let r=this.origin?.x??0,o=this.origin?.y??0;for(let i=0;i<this.xs.length;i+=2)this.xs[i]+=r-t,this.xs[i+1]+=o-n;return this.origin=t===0&&n===0?void 0:{x:t,y:n},this}autoOrigin(){return this.auto=!0,this}push(...t){let n=this.origin?.x??0,r=this.origin?.y??0;for(let o=0;o<t.length;o+=2)this.xs.push(t[o]-n,t[o+1]-r)}setFillRule(t){return this.fillRule=t,this}moveTo(t,n){return this.cmds.push(le),this.push(t,n),this}lineTo(t,n){return this.cmds.push(ce),this.push(t,n),this}curveTo(t,n,r,o,i,s){return this.cmds.push(xe),this.push(t,n,r,o,i,s),this}quadTo(t,n,r,o){return this.cmds.push(we),this.push(t,n,r,o),this}close(){return this.cmds.push(fe),this}build(){if(this.auto&&!this.origin){let t=Sn(this.xs);t&&this.setOrigin(t.x,t.y)}return{kind:"polygon",commands:new Uint8Array(this.cmds),coords:new Float32Array(this.xs),fillRule:this.fillRule,...this.origin?{origin:{...this.origin}}:{}}}};ZS=.5522847498307936});function rg(e,t){let n=e.corners?.[t];return n&&n.radius>0?n:null}function Sd(e){let t=e.corners;if(!t)return!1;for(let n of t)if(n&&n.radius>0)return!0;return!1}function kd(e){let t=e.length;for(;t>0&&!e[t-1];)t--;if(t===0)return;let n=new Array(t);for(let r=0;r<t;r++)n[r]=e[r]??null;return n}function ri(e){if(e.corners===void 0)return e;let{corners:t,...n}=e;return n}function og(e,t){return!e.corners||t===1?e:{...e,corners:e.corners.map(n=>n?{shape:n.shape,radius:n.radius*t}:null)}}function ig(e,t,n){if(!e&&!t)return;let r=Math.max(e?.length??0,t?.length??0),o=new Array(r);for(let i=0;i<r;i++){let s=e?.[i]??null,a=t?.[i]??null,l=s??a;l?s&&a&&s.shape!==a.shape?o[i]=n<.5?s:a:o[i]={shape:l.shape,radius:(s?.radius??0)+((a?.radius??0)-(s?.radius??0))*n}:o[i]=null}return kd(o)}var wl=Q(()=>{"use strict"});function tk(e,t,n,r,o){let[i,s]=Ve(e.x,e.y,t.x,t.y,n.x,n.y,r.x,r.y,o);return{x:i,y:s}}var nk=Q(()=>{"use strict";Pn()});function ok(e,t,n,r={}){let{cp1:o,cp2:i}=ZG(e,t,n,r.passes??4,r.params);return{cp1:o,cp2:i}}function ZG(e,t,n,r,o){let i=e.length,s=e[0],a=e[i-1],l=o?[...o]:e4(e);if(l===null)return{cp1:{...s},cp2:{...a},end:a,ts:e.map(()=>0)};let u=rk(e,l,s,a,t,n);for(let c=0;c<r;c++)t4(e,l,s,a,u),u=rk(e,l,s,a,t,n);return u}function e4(e){let t=e.length,n=new Array(t);n[0]=0;let r=0;for(let o=1;o<t;o++)r+=Bt(e[o-1],e[o]),n[o]=r;if(r===0)return null;for(let o=0;o<t;o++)n[o]/=r;return n}function rk(e,t,n,r,o,i){let s=e.length,a=0,l=0,u=0,c=0,d=0;for(let m=0;m<s;m++){let g=t[m],b=1-g,x=b*b*b,w=3*b*b*g,y=3*b*g*g,P=g*g*g,S=w*o.x,v=w*o.y,A=y*i.x,N=y*i.y;a+=S*S+v*v,l+=S*A+v*N,u+=A*A+N*N;let M=e[m].x-(x+w)*n.x-(y+P)*r.x,C=e[m].y-(x+w)*n.y-(y+P)*r.y;c+=S*M+v*C,d+=A*M+N*C}let f=a*u-l*l,p,h;return Math.abs(f)<1e-12?p=h=Bt(n,r)/3:(p=(u*c-l*d)/f,h=(a*d-l*c)/f,(p<1e-6||h<1e-6)&&(p=h=Bt(n,r)/3)),{cp1:{x:n.x+o.x*p,y:n.y+o.y*p},cp2:{x:r.x+i.x*h,y:r.y+i.y*h},end:r,ts:t}}function t4(e,t,n,r,o){for(let i=1;i<e.length-1;i++)t[i]=n4(e[i],t[i],e[0],o.cp1,o.cp2,e[e.length-1])}function n4(e,t,n,r,o,i){let s=1-t,{x:a,y:l}=tk(n,r,o,i,t),u=3*s*s*(r.x-n.x)+6*s*t*(o.x-r.x)+3*t*t*(i.x-o.x),c=3*s*s*(r.y-n.y)+6*s*t*(o.y-r.y)+3*t*t*(i.y-o.y),d=6*s*(o.x-2*r.x+n.x)+6*t*(i.x-2*o.x+r.x),f=6*s*(o.y-2*r.y+n.y)+6*t*(i.y-2*o.y+r.y),p=a-e.x,h=l-e.y,m=p*u+h*c,g=u*u+c*c+p*d+h*f;if(Math.abs(g)<1e-12)return t;let b=t-m/g;return b<0?0:b>1?1:b}var ik=Q(()=>{"use strict";nk();ti()});function ck(e){return typeof e=="number"?e:r4[e]}function o4(e){let t=2**Math.abs(e);return 1-.5**(1/t)<dk/4?1/0:t}function Pl(e,t){let n=.5**(1/e),r=i=>Math.max(0,1-i**e)**(1/e);if(t<=1){let i=t*n;return{x:i,y:r(i)}}let o=(2-t)*n;return{x:r(o),y:o}}function ak(e,t){let n=Pl(e,t),[r,o]=t<=1?[1,-((n.x/n.y)**(e-1))]:[(n.y/n.x)**(e-1),-1],i=Math.hypot(r,o);return{x:r/i,y:o/i}}function i4(e,t,n,r,[o,i,s]){let a=f=>{let p=Pl(e,f);return ni(p.x,p.y,r.x,r.y,o.x,o.y,i.x,i.y,s.x,s.y).dist},l=0,u=1;for(let f=1;f<vd;f++){let p=a(t+(n-t)*(f/vd));p>l&&(l=p,u=f)}let c=t+(n-t)*((u-1)/vd),d=t+(n-t)*((u+1)/vd);for(let f=0;f<24;f++){let p=c+(d-c)/3,h=d-(d-c)/3;a(p)>a(h)?d=h:c=p}return Math.max(l,a((c+d)/2))}function sg(e,t,n,r,o,i){let s=Pl(e,t),a=Pl(e,n),l=[],u=[];for(let m=0;m<=12;m++)l.push(Pl(e,t+(n-t)*(m/12))),u.push(m/12);let c=ak(e,n),{cp1:d,cp2:f}=ok(l,ak(e,t),{x:-c.x,y:-c.y},{params:u}),p=[d,f,a];if(o>=10||i4(e,t,n,s,p)<=r){i.push(p);return}let h=(t+n)/2;sg(e,t,h,r,o+1,i),sg(e,h,n,r,o+1,i)}function s4(e,t){if(e===2)return[[{x:sk,y:1},{x:1,y:sk},{x:1,y:0}]];let n=`${e}:${t}`,r=Ad.get(n);return r||(r=[],sg(e,0,2,t,0,r),Ad.size>256&&Ad.clear(),Ad.set(n,r)),r}function a4(e,t){let n=lk(e.end,t),r=lk(e.start,t);return o=>({x:t.x+o.x*n.x+o.y*r.x,y:t.y+o.x*n.y+o.y*r.y})}function uk(e){return{x:e.start.x+e.end.x-e.outer.x,y:e.start.y+e.end.y-e.outer.y}}function fk(e,t,n=dk){if(e===0)return[{kind:"line",to:t.end}];let r=o4(e);if(r===1/0)return[{kind:"line",to:e>0?t.outer:uk(t)},{kind:"line",to:t.end}];let o=a4(t,e>0?uk(t):t.outer);return s4(r,n).map(([i,s,a])=>({kind:"cubic",c1:o(i),c2:o(s),to:o(a)}))}var r4,dk,sk,lk,vd,Ad,pk=Q(()=>{"use strict";ik();Pd();r4={square:1/0,squircle:2,round:1,bevel:0,scoop:-1,notch:-1/0};dk=.001,sk=4/3*Math.tan(Math.PI/8);lk=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),vd=32;Ad=new Map});function Sl(e){let{commands:t}=e,n=$e(e),r=[],o=null,i=0,s=0,a=!1,l=()=>o.anchors[o.anchors.length-1],u=(c,d)=>{o.segs.push(d),o.anchors.push(c),o.sources.push(s++),i++};return Ge(t,n,(c,d,f,p,h,m)=>{if(m)return a=!0,!1;let g=b=>({x:n[d+b],y:n[d+b+1]});switch(c){case le:o&&r.push(o),o={anchors:[g(0)],segs:[],closed:!1,first:i++,sources:[s++]};break;case ce:u(g(0),mk(l(),g(0)));break;case xe:u(g(4),{line:!1,p0:l(),c1:g(0),c2:g(2),p3:g(4)});break;case we:{let b=l(),x=g(0),w=g(2),y={x:b.x+2/3*(x.x-b.x),y:b.y+2/3*(x.y-b.y)},P={x:w.x+2/3*(x.x-w.x),y:w.y+2/3*(x.y-w.y)};u(w,{line:!1,p0:b,c1:y,c2:P,p3:w});break}case fe:o&&l4(o,()=>i--),o&&r.push(o),o=null;break}}),a?null:(o&&r.push(o),r)}function l4(e,t){e.closed=!0;let n=e.anchors.length,r=e.anchors[0],o=e.anchors[n-1];if(n>1&&!e.segs[n-2].line&&o.x===r.x&&o.y===r.y){e.anchors.pop(),e.sources.pop(),t();return}e.segs.push(mk(o,r))}function Rd(e){return e.line?Math.hypot(e.p3.x-e.p0.x,e.p3.y-e.p0.y):yk(e)[Tl]}function yk(e){let t=hk.get(e);if(t)return t;t=new Float64Array(Tl+1);let n=e.p0;for(let r=1;r<=Tl;r++){let o=fs(e,r/Tl);t[r]=t[r-1]+Math.hypot(o.x-n.x,o.y-n.y),n=o}return hk.set(e,t),t}function ag(e,t){let n=Rd(e);if(n<=0)return 0;if(e.line)return Math.min(1,Math.max(0,t/n));let r=yk(e);if(t<=0)return 0;if(t>=n)return 1;let o=1;for(;r[o]<t;)o++;let i=r[o]-r[o-1],s=i>0?(t-r[o-1])/i:0;return(o-1+s)/Tl}function fs(e,t){if(e.line)return{x:e.p0.x+(e.p3.x-e.p0.x)*t,y:e.p0.y+(e.p3.y-e.p0.y)*t};let{p0:n,c1:r,c2:o,p3:i}=e,[s,a]=Ve(n.x,n.y,r.x,r.y,o.x,o.y,i.x,i.y,t);return{x:s,y:a}}function ds(e,t){let n=Math.hypot(e,t);return n>1e-12?{x:e/n,y:t/n}:null}function kl(e,t){let{p0:n,c1:r,c2:o,p3:i}=e;if(e.line)return ds(i.x-n.x,i.y-n.y);let s=1-t,a=3*(s*s*(r.x-n.x)+2*s*t*(o.x-r.x)+t*t*(i.x-o.x)),l=3*(s*s*(r.y-n.y)+2*s*t*(o.y-r.y)+t*t*(i.y-o.y)),u=ds(a,l);return u||(t<.5?ds(o.x-n.x,o.y-n.y)??ds(i.x-n.x,i.y-n.y):ds(i.x-r.x,i.y-r.y)??ds(i.x-n.x,i.y-n.y))}function gk(e,t,n){let{p0:r,c1:o,c2:i,p3:s}=e,a=[r.x,r.y,o.x,o.y,i.x,i.y,s.x,s.y];t>0&&(a=[...so(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],t)[1]]);let l=t<1?(n-t)/(1-t):1;return l<1&&(a=[...so(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],l)[0]]),[{x:a[2],y:a[3]},{x:a[4],y:a[5]},{x:a[6],y:a[7]}]}var mk,Tl,hk,lg=Q(()=>{"use strict";Je();Pn();tn();mk=(e,t)=>({line:!0,p0:e,c1:e,c2:t,p3:t});Tl=32;hk=new WeakMap});function wk(e,t){let n=t.anchors.length,r=t.segs.map(Rd),o=t.anchors.map((s,a)=>{let l=a>0?t.segs[a-1]:t.closed?t.segs[n-1]:null,u=a<t.segs.length?t.segs[a]:null;if(!l||!u||l===u)return null;let c=kl(l,1),d=kl(u,0);if(!c||!d)return null;let f=Math.acos(Math.max(-1,Math.min(1,c.x*d.x+c.y*d.y)));if(f<bk||f>Math.PI-bk)return null;let p=d.x-c.x,h=d.y-c.y,m=Math.hypot(p,h),g=(Math.PI-f)/2,b=rg(e,t.first+a),x=b?b.radius:0;return{frame:{index:t.first+a,x:s.x,y:s.y,bisector:{x:p/m,y:h/m},halfAngle:g},spec:b,want:x,trim:x}}),i=o.map(()=>1);return t.segs.forEach((s,a)=>{let l=a,u=(a+1)%n,c=(o[l]?.want??0)+(o[u]?.want??0);if(c<=r[a])return;let d=r[a]/c;i[l]=Math.min(i[l],d),i[u]=Math.min(i[u],d)}),o.forEach((s,a)=>{s&&(s.trim=s.want*i[a])}),o}function ps(e){if(e.corners===void 0)return{path:e,anchorSources:null};let t=xk.get(e);if(t)return t;let n=Sd(e)?u4(e):{path:ri(e),anchorSources:null};return xk.set(e,n),n}function Qe(e){return e.kind!=="polygon"?e:ps(e).path}function vl(e,t,n){let r=new Array(t.length*n);for(let o=0;o<t.length;o++)for(let i=0;i<n;i++)r[o*n+i]=e[t[o]*n+i];return r}function u4(e){let t=Sl(e);if(!t)return{path:ri(e),anchorSources:null};let n=new ug;e.origin&&n.b.setOrigin(e.origin.x,e.origin.y);for(let i of t)c4(n,i,wk(e,i));let{commands:r,coords:o}=n.b.build();return{path:{...ri(e),commands:r,coords:o},anchorSources:Uint32Array.from(n.sources)}}function Pk(e,t,n){let r=e.segs[n],o=Rd(r),i=ag(r,t[n]?.trim??0),s=ag(r,o-(t[(n+1)%e.anchors.length]?.trim??0));return[i,Math.max(i,s)]}function Tk(e,t,n,r){let o=(r+1)%e.anchors.length,i=t[o],s=e.segs[o];if(!i?.spec||i.trim<=0||!s)return null;let a=e.segs[r],l=fs(a,n[r][1]),u=fs(s,n[o][0]),c=d4({x:i.frame.x,y:i.frame.y},l,kl(a,n[r][1]),u,kl(s,n[o][0]));return{cut:i,start:l,end:u,pieces:fk(ck(i.spec.shape),c)}}function Nd(e){if(!Sd(e))return[];let t=[];for(let n of Sl(e)??[]){let r=wk(e,n),o=n.segs.map((i,s)=>Pk(n,r,s));n.segs.forEach((i,s)=>{let a=Tk(n,r,o,s);if(!a)return;let{frame:l}=a.cut;t.push({index:l.index,anchor:{x:l.x,y:l.y},spec:a.cut.spec,start:a.start,end:a.end,pieces:a.pieces})})}return t}function c4(e,t,n){let r=t.anchors.length,o=t.segs.map((s,a)=>Pk(t,n,a)),i=t.closed&&t.segs.length>0?fs(t.segs[0],o[0][0]):t.anchors[0];e.src=t.sources[0],e.moveTo(i.x,i.y),t.segs.forEach((s,a)=>{let[l,u]=o[a];e.src=t.sources[(a+1)%r];let c=t.closed&&a===r-1&&!(n[0]?.spec&&n[0].trim>0);if(u>l&&!(c&&s.line))if(s.line){let p=fs(s,u);e.lineTo(p.x,p.y)}else{let[p,h,m]=gk(s,l,u);e.curveTo(p.x,p.y,h.x,h.y,m.x,m.y)}let d=Tk(t,n,o,a);if(!d)return;let f=[...d.pieces];(a+1)%r===0&&f.at(-1)?.kind==="line"&&f.pop();for(let p of f)p.kind==="line"?e.lineTo(p.to.x,p.to.y):e.curveTo(p.c1.x,p.c1.y,p.c2.x,p.c2.y,p.to.x,p.to.y)}),t.closed&&e.close()}function d4(e,t,n,r,o){let i=n&&o?f4(t,n,r,o):null,s=Math.hypot(r.x-t.x,r.y-t.y),a=!i||Math.hypot(i.x-e.x,i.y-e.y)>4*s;return{start:t,end:r,outer:a?e:i}}function f4(e,t,n,r){let o=t.x*r.y-t.y*r.x;if(Math.abs(o)<1e-9)return null;let i=((n.x-e.x)*r.y-(n.y-e.y)*r.x)/o;return{x:e.x+t.x*i,y:e.y+t.y*i}}var bk,xk,ug,nn=Q(()=>{"use strict";mr();wl();pk();lg();bk=.001;xk=new WeakMap;ug=class{b=new _e;sources=[];src=0;moveTo(t,n){this.b.moveTo(t,n),this.sources.push(this.src)}lineTo(t,n){this.b.lineTo(t,n),this.sources.push(this.src)}curveTo(t,n,r,o,i,s){this.b.curveTo(t,n,r,o,i,s),this.sources.push(this.src)}close(){this.b.close()}}});function Ed(e){return e>0?e:p4}function mg(e,t,n,r,o,i){return Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(o)&&Number.isFinite(i)}function Sk(e,t,n,r,o,i,s,a){return mg(e,t,n,r,o,i)&&Number.isFinite(s)&&Number.isFinite(a)}function kk(e,t,n,r,o,i,s,a,l,u){let c=cg(n-e,r-t,o-n,i-r)+cg(o-n,i-r,s-o,a-i);return o===n&&i===r&&(c+=cg(n-e,r-t,s-o,a-i)),c===0?!0:c>=Math.PI?!1:((Math.hypot(n-e,r-t)+Math.hypot(o-n,i-r)+Math.hypot(s-o,a-i))/c+l)*(1-Math.cos(c/2))<=u}function cg(e,t,n,r){let o=Math.sqrt((e*e+t*t)*(n*n+r*r));return o===0?0:Math.acos(Math.max(-1,Math.min(1,(e*n+t*r)/o)))}function lo(e,t,n,r,o,i,s,a,l,u){if(!Sk(e,t,n,r,o,i,s,a)){u.push(s,a);return}dg(e,t,n,r,o,i,s,a,Ed(l),u,0)}function dg(e,t,n,r,o,i,s,a,l,u,c){let d=Tn(n,r,e,t,s,a),f=Tn(o,i,e,t,s,a);if(Math.max(d,f)<=l||c>=Id){u.push(s,a);return}let p=(e+n)*.5,h=(t+r)*.5,m=(n+o)*.5,g=(r+i)*.5,b=(o+s)*.5,x=(i+a)*.5,w=(p+m)*.5,y=(h+g)*.5,P=(m+b)*.5,S=(g+x)*.5,v=(w+P)*.5,A=(y+S)*.5;dg(e,t,p,h,w,y,v,A,l,u,c+1),dg(v,A,P,S,b,x,s,a,l,u,c+1)}function yg(e,t,n,r,o,i,s,a){if(!mg(e,t,n,r,o,i)){a.push(o,i);return}fg(e,t,n,r,o,i,Ed(s),a,0)}function fg(e,t,n,r,o,i,s,a,l){if(Tn(n,r,e,t,o,i)<=s||l>=Id){a.push(o,i);return}let c=(e+n)*.5,d=(t+r)*.5,f=(n+o)*.5,p=(r+i)*.5,h=(c+f)*.5,m=(d+p)*.5;fg(e,t,c,d,h,m,s,a,l+1),fg(h,m,f,p,o,i,s,a,l+1)}function Al(e,t,n,r,o,i,s,a,l,u,c,d=0){return Sk(e,t,n,r,o,i,s,a)?pg(e,t,n,r,o,i,s,a,Ed(l),d,u,c,0,0):(u.push(s,a),c.push(0),0)}function pg(e,t,n,r,o,i,s,a,l,u,c,d,f,p){let h=Tn(n,r,e,t,s,a),m=Tn(o,i,e,t,s,a);if(Math.max(h,m)<=l&&(u===0||kk(e,t,n,r,o,i,s,a,u,l))||p>=Id){let B=c.length>=2?c[c.length-2]:e,D=c.length>=2?c[c.length-1]:t,j=Math.hypot(s-B,a-D);return f+=j,c.push(s,a),d.push(f),f}let b=(e+n)*.5,x=(t+r)*.5,w=(n+o)*.5,y=(r+i)*.5,P=(o+s)*.5,S=(i+a)*.5,v=(b+w)*.5,A=(x+y)*.5,N=(w+P)*.5,M=(y+S)*.5,C=(v+N)*.5,F=(A+M)*.5;return f=pg(e,t,b,x,v,A,C,F,l,u,c,d,f,p+1),f=pg(C,F,N,M,P,S,s,a,l,u,c,d,f,p+1),f}function Rl(e,t,n,r,o,i,s,a,l,u=0){return mg(e,t,n,r,o,i)?hg(e,t,n,r,o,i,Ed(s),u,a,l,0,0):(a.push(o,i),l.push(0),0)}function hg(e,t,n,r,o,i,s,a,l,u,c,d){if(Tn(n,r,e,t,o,i)<=s&&(a===0||kk(e,t,n,r,o,i,o,i,a,s))||d>=Id){let y=l.length>=2?l[l.length-2]:e,P=l.length>=2?l[l.length-1]:t,S=Math.hypot(o-y,i-P);return c+=S,l.push(o,i),u.push(c),c}let h=(e+n)*.5,m=(t+r)*.5,g=(n+o)*.5,b=(r+i)*.5,x=(h+g)*.5,w=(m+b)*.5;return c=hg(e,t,h,m,x,w,s,a,l,u,c,d+1),c=hg(x,w,g,b,o,i,s,a,l,u,c,d+1),c}var mt,p4,Id,oi=Q(()=>{"use strict";ti();mt=.5,p4=1e-6,Id=16});function hs(e,t={}){return e.kind==="rect"?[h4(e)]:m4(Qe(e),t)}function h4(e){let{x:t,y:n,width:r,height:o}=e;return{points:Array.from(gl(t,n,r,o)),closed:!0,anchorA:new Uint32Array([0,1,2,3]),anchorB:new Uint32Array([0,1,2,3]),anchorT:new Float32Array([0,0,0,0])}}function m4(e,t){let n=t.flattenTolerance??mt,{commands:r,coords:o}=e,i=[],s=0,a=null,l=null,u=null,c=null,d=null,f=-1,p=0,h=()=>{a=[],l=[],u=[],c=[];let x={points:a,closed:!1};return i.push(x),x},m=()=>{if(!a||!l||!u||!c)return;let x=a.length/2;x<2||a[0]!==a[(x-1)*2]||a[1]!==a[(x-1)*2+1]||(a.length-=2,l.length-=1,u.length-=1,c.length-=1)},g=x=>{!a||!l||!u||!c||(x.anchorA=new Uint32Array(l),x.anchorB=new Uint32Array(u),x.anchorT=new Float32Array(c))},b=(x,w,y,P)=>{for(let v=0;v<w.length;v++)l.push(f),u.push(P),c.push(y>0?w[v]/y:0);let S=x+w.length-1;l[S]=P,u[S]=P,c[S]=0};return Ge(r,o,(x,w,y,P,S,v)=>{switch(v&&(d&&g(d),d=h(),a.push(y,P),l.push(p),u.push(p),c.push(0),f=p),x){case le:case ce:{x===le&&(d&&g(d),d=h(),p=s),a.push(o[w],o[w+1]),l.push(s),u.push(s),c.push(0),f=s,s++;break}case we:{let A=s,N=a.length/2,M=[],C=Rl(y,P,o[w],o[w+1],o[w+2],o[w+3],n,a,M,t.offset);b(N,M,C,A),f=A,s++;break}case xe:{let A=s,N=a.length/2,M=[],C=Al(y,P,o[w],o[w+1],o[w+2],o[w+3],o[w+4],o[w+5],n,a,M,t.offset);b(N,M,C,A),f=A,s++;break}case fe:{d&&(d.closed=!0,m());break}default:throw new Error(`extractPolylines: unknown command code ${x}`)}}),d&&g(d),i}var vk=Q(()=>{"use strict";Je();nn();bl();oi()});function gg(e){let t=Qe(e);if(t.kind==="rect"){let{x:s,y:a,width:l,height:u}=t;return`M${Ze(s)} ${Ze(a)}h${Ze(l)}v${Ze(u)}h${Ze(-l)}Z`}let n=t.commands,r=$e(t),o=[],i=0;for(let s=0;s<n.length;s++){let a=n[s];a===le?(o.push(`M${Ze(r[i])} ${Ze(r[i+1])}`),i+=2):a===ce?(o.push(`L${Ze(r[i])} ${Ze(r[i+1])}`),i+=2):a===xe?(o.push(`C${Ze(r[i])} ${Ze(r[i+1])} ${Ze(r[i+2])} ${Ze(r[i+3])} ${Ze(r[i+4])} ${Ze(r[i+5])}`),i+=6):a===we?(o.push(`Q${Ze(r[i])} ${Ze(r[i+1])} ${Ze(r[i+2])} ${Ze(r[i+3])}`),i+=4):a===fe&&o.push("Z")}return o.join("")}var Ze,Ak=Q(()=>{"use strict";Je();nn();tn();Ze=e=>Number.isFinite(e)?String(Math.round(e*1e6)/1e6):"0"});function Un(e,t,n,r=0,o=e.length>>1){if(o-r<3)return!1;let i=!1;for(let s=r,a=o-1;s<o;a=s++){let l=e[s*2],u=e[s*2+1],c=e[a*2],d=e[a*2+1];u>n!=d>n&&t<(c-l)*(n-u)/(d-u)+l&&(i=!i)}return i}function yr(e,t=0,n=e.length>>1){let r=0;for(let o=t;o<n;o++){let i=o+1===n?t:o+1;r+=e[o*2]*e[i*2+1]-e[i*2]*e[o*2+1]}return r*.5}function gr(e,t,n,r,o,i,s,a){let l=us((s-o)*(t-i)-(a-i)*(e-o)),u=us((s-o)*(r-i)-(a-i)*(n-o)),c=us((n-e)*(i-t)-(r-t)*(o-e)),d=us((n-e)*(a-t)-(r-t)*(s-e));return l!==u&&c!==d}var Nl=Q(()=>{"use strict";ml()});function bg(){return Rk}function kn(e){return(e.openFill??Rk)==="close"}var Rk,ii=Q(()=>{"use strict";Rk="close"});function et(e){if(e.kind==="rect")return e;let{commands:t,coords:n}=Qe(e);if(t.length===0)return{kind:"rect",x:0,y:0,width:0,height:0};let r=1/0,o=1/0,i=-1/0,s=-1/0,a=!1,l=(u,c)=>{u<r&&(r=u),u>i&&(i=u),c<o&&(o=c),c>s&&(s=c),a=!0};return Ge(t,n,(u,c,d,f)=>{switch(u){case le:case ce:{l(n[c],n[c+1]);break}case xe:{let[p,h,m,g]=qy(d,f,n[c],n[c+1],n[c+2],n[c+3],n[c+4],n[c+5]);l(p,h),l(m,g);break}case we:{let p=n[c+2],h=n[c+3],[m,g,b,x]=io(d,f,n[c],n[c+1],p,h),[w,y,P,S]=qy(d,f,m,g,b,x,p,h);l(w,y),l(P,S);break}case fe:break;default:throw new Error(`boundsOfPath: unknown command ${u}`)}}),a?{kind:"rect",x:r+(e.origin?.x??0),y:o+(e.origin?.y??0),width:i-r,height:s-o}:{kind:"rect",x:0,y:0,width:0,height:0}}var xg=Q(()=>{"use strict";Pn();Je();nn()});function Ik(e){let t=Nk.get(e);if(t)return t;let{commands:n,coords:r}=e,o=[],i=0,s=0,a=0,l=0,u=0,c=0,d=0,f=!1;Ge(n,r,(h,m)=>{if(h===fe){a>1&&f&&c===l&&d===u&&(o[o.length-1]=s,i--),a=0;return}let g=oo(h);c=r[m+g-2],d=r[m+g-1],f=h===xe||h===we,(h===le||a===0)&&(s=i,l=c,u=d,a=0),a++,o.push(i++)});let p=Int32Array.from(o);return Nk.set(e,p),p}var Nk,Ek=Q(()=>{"use strict";Je();Nk=new WeakMap});function y4(e){return e.kind!=="polygon"?[]:Nd(e).map(({anchor:t,spec:n,start:r,end:o,pieces:i})=>({anchor:t,spec:n,start:r,end:o,pieces:i}))}function Tg(e,t,n=Ok){let r=e.flatMap(y4);return r.length===0?t:T4(t,r,n)}function wg(e,t,n){let r=t.start;for(let o of t.pieces){if((o.kind==="line"?xl(e.x,e.y,r.x,r.y,o.to.x,o.to.y).dist:ni(e.x,e.y,r.x,r.y,o.c1.x,o.c1.y,o.c2.x,o.c2.y,o.to.x,o.to.y).dist)<=n)return!0;r=o.to}return!1}function ms(e,t,n,r){let o=ei(e.p0,e.c1,t),i=ei(e.c1,e.c2,t),s=ei(e.c2,e.p3,t),a=ei(o,i,n),l=ei(i,s,n);return ei(a,l,r)}function Mk(e,t,n,r){let o=l=>ms(e,l,l,l),i=l=>{let u=ms(e,l,l,0),c=ms(e,l,l,1);return{x:3*(c.x-u.x),y:3*(c.y-u.y)}},s=Math.hypot(i(n).x,i(n).y);if(s===0)return null;let a=n+(n===1?1:-1)*Bt(o(n),t)/s;for(let l=0;l<30;l++){let u=o(a),c=i(a),d=c.x*c.x+c.y*c.y;if(d===0)break;a-=((u.x-t.x)*c.x+(u.y-t.y)*c.y)/d}return Bt(o(a),t)<=r?a:null}function g4(e,t,n,r){let o=t??e.p0,i=n??e.p3;if(e.line)return{line:!0,p0:o,c1:o,c2:i,p3:i};let s=t?Mk(e,t,0,r):0,a=n?Mk(e,n,1,r):1;return s===null||a===null?null:{line:!1,p0:o,c1:ms(e,s,s,a),c2:ms(e,s,a,a),p3:i}}function Ck(e,t,n,r,o){return Bt(e,n)<=o?!0:t.line&&wg(e,r,o)&&xl(n.x,n.y,t.p0.x,t.p0.y,t.p3.x,t.p3.y).dist<=o}function b4(e,t,n){let r=e.anchors.length;for(let o=e.closed?0:1;o<r;o++)for(let[i,s]of[[t.start,t.end],[t.end,t.start]])if(Ck(e.anchors[o],e.segs[(o-1+r)%r],i,t,n))for(let a=o+1,l=1;l<e.segs.length&&!(!e.closed&&a>=r-1);a++,l++){let u=e.anchors[a%r],c=e.segs[(a-1)%r];if(!c.line&&!wg(ms(c,.5,.5,.5),t,n))break;if(Ck(u,e.segs[a%r],s,t,n))return{from:o,to:a%r,trace:t};if(!wg(u,t,n))break}return null}function Pg(e,t){let n=[];for(let r=e.from;;r=(r+1)%t)if(n.push(r),r===e.to)return n}function x4(e,t,n,r){let o=e.anchors.length,i=new Map,s=new Set;for(let p of t){i.set(p.from,p);for(let h of Pg(p,o))s.add(h)}let a=0;if(e.closed){let p=e.anchors.findIndex((h,m)=>!s.has(m));a=p>=0?p:t[0].from}let l=[],u=[];for(let p=0,h=a;p<o;){let m=i.get(h);if(m){l.push({at:m.trace.anchor,spec:m.trace.spec}),u.push(m.to);let g=Pg(m,o).length;p+=g,h=(m.to+1)%o}else l.push({at:e.anchors[h],spec:n[h]??null}),u.push(h),p++,h=(h+1)%o}let c=new Set(t.map(p=>p.to)),d=[],f=e.closed?l.length:l.length-1;for(let p=0;p<f;p++){let h=u[p],m=c.has(h)?l[p].at:void 0,g=i.has((h+1)%o)?l[(p+1)%l.length].at:void 0,b=g4(e.segs[h],m,g,r);if(!b)return null;d.push(b)}return{nodes:l,segs:d,closed:e.closed,folded:[...t]}}function w4(e,t){let n=new _e;t.origin&&n.setOrigin(t.origin.x,t.origin.y);let r=[];for(let{nodes:c,segs:d,closed:f}of e)n.moveTo(c[0].at.x,c[0].at.y),r.push(c[0].spec),d.forEach((p,h)=>{let m=c[(h+1)%c.length];f&&h===d.length-1&&p.line||(p.line?n.lineTo(m.at.x,m.at.y):n.curveTo(p.c1.x,p.c1.y,p.c2.x,p.c2.y,m.at.x,m.at.y),r.push(m.spec))}),f&&n.close();let{commands:o,coords:i}=n.build(),s={...ri(t),commands:o,coords:i},a=Ik(s),l=[];r.forEach((c,d)=>{if(c){for(;l.length<a[d];)l.push(null);l[a[d]]=c}});let u=kd(l);return u?{...s,corners:u}:s}function P4(e,t,n){let r=new Set(n.map(o=>o.trace));for(let o of Nd(e))for(let i of r){if(Bt(o.anchor,i.anchor)>t)continue;(Bt(o.start,i.start)<=t&&Bt(o.end,i.end)<=t||Bt(o.start,i.end)<=t&&Bt(o.end,i.start)<=t)&&r.delete(i)}return r}function T4(e,t,n=Ok){let r=Sl(e);if(!r||t.length===0)return e;let o=new Set;for(let i=0;i<=t.length;i++){let s=[];for(let c of r){let d=[],f=new Set;for(let m of t){if(o.has(m))continue;let g=b4(c,m,n);if(!g)continue;let b=Pg(g,c.anchors.length);b.some(x=>f.has(x))||(b.forEach(x=>f.add(x)),d.push(g))}let p=c.anchors.map((m,g)=>e.corners?.[c.first+g]??null),h=d.length>0?x4(c,d,p,n):null;if(d.length>0&&!h){d.forEach(m=>o.add(m.trace)),s.length=0;break}s.push(h??{nodes:c.anchors.map((m,g)=>({at:m,spec:p[g]})),segs:c.segs,closed:c.closed,folded:[]})}if(s.length!==r.length)continue;let a=s.flatMap(c=>c.folded);if(a.length===0)return e;let l=w4(s,e),u=P4(l,n,a);if(u.size===0)return l;u.forEach(c=>o.add(c))}return e}var Ok,Fk=Q(()=>{"use strict";Pd();mr();Ek();lg();wl();nn();ti();Ok=.001});function Lk(e,t){let n=Qe(e),{commands:r}=n,o=$e(n),i=[],s=[],a=[];return Ge(r,o,(l,u,c,d,f,p)=>{switch(p&&(a=[c,d]),l){case le:a.length>=2&&s.push(a),a=[o[u],o[u+1]];break;case ce:a.push(o[u],o[u+1]);break;case xe:lo(c,d,o[u],o[u+1],o[u+2],o[u+3],o[u+4],o[u+5],t,a);break;case we:yg(c,d,o[u],o[u+1],o[u+2],o[u+3],t,a);break;case fe:a.length>=6?i.push(a):a.length>=2&&s.push(a),a=[];break;default:throw new Error(`pathHitTest: unknown command ${l}`)}}),a.length>=2&&s.push(a),{closed:i,open:s}}function Md(e,t){let n=Lk(e,t.tolerance??mt);return kn(e)?{closed:[...n.closed,...n.open.filter(r=>r.length>=6)],open:n.open.filter(r=>r.length<6)}:n}function Sg(e,t){return Md(e,t).closed}var _k=Q(()=>{"use strict";Je();oi();ii();nn();tn()});function kg(e,t,n,r={}){if(e.kind==="rect")return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height;let o=0,i=0;for(let s of Sg(e,r)){let a=s.length;for(let l=0;l<a;l+=2){let u=(l+2)%a,c=s[l+1],d=s[u+1];if(c>n==d>n)continue;let f=s[l],p=s[u];t>=f+(n-c)/(d-c)*(p-f)||(o++,i+=c<=n?1:-1)}}return e.fillRule==="evenodd"?(o&1)===1:i!==0}function Cd(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]}function ys(e){let t=new Array(e.length*2);for(let n=0;n<e.length;n++)t[n*2]=e[n].x,t[n*2+1]=e[n].y;return t}function S4(e,t){if(e.length===0||t.length===0)return!1;if(Un(ys(e),t[0].x,t[0].y)||Un(ys(t),e[0].x,e[0].y))return!0;for(let n=0;n<e.length;n++){let r=e[n],o=e[(n+1)%e.length];for(let i=0;i<t.length;i++){let s=t[i],a=t[(i+1)%t.length];if(gr(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y))return!0}}return!1}function Bk(e,t){for(let n of e){let r=n.length;for(let o=0;o<r;o+=2){let i=(o+2)%r;if(t(n[o],n[o+1],n[i],n[i+1]))return!0}}return!1}function k4(e,t){let n=t.x,r=t.y,o=t.x+t.width,i=t.y+t.height;return Bk(e,(s,a,l,u)=>gr(s,a,l,u,n,r,o,r)||gr(s,a,l,u,o,r,o,i)||gr(s,a,l,u,o,i,n,i)||gr(s,a,l,u,n,i,n,r))}function Hk(e,t){return t.length===0?!1:Bk(e,(n,r,o,i)=>{for(let s=0;s<t.length;s++){let a=t[s],l=t[(s+1)%t.length];if(gr(n,r,o,i,a.x,a.y,l.x,l.y))return!0}return!1})}function v4(e,t){for(let n of e)for(let r=0;r+3<n.length;r+=2){let o=n[r],i=n[r+1],s=n[r+2],a=n[r+3];for(let l=0;l<t.length;l++){let u=t[l],c=t[(l+1)%t.length];if(gr(o,i,s,a,u.x,u.y,c.x,c.y))return!0}}return!1}function A4(e,t){for(let n of e)for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];if(o>=t.x&&o<=t.x+t.width&&i>=t.y&&i<=t.y+t.height)return!0}return!1}function Dk(e,t){for(let n of e)for(let r=0;r<n.length;r+=2)if(Un(t,n[r],n[r+1]))return!0;return!1}function Od(e,t,n={}){if(e.kind==="rect")return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y;let r=Sg(e,n);if(r.length===0)return!1;for(let o of Cd(t))if(kg(e,o.x,o.y,n))return!0;return A4(r,t)?!0:k4(r,t)}function vg(e,t,n={}){if(e.length<3)return!1;let r;if(t.kind==="rect")r=[ys(Cd(t))];else{let{closed:i,open:s}=Md(t,n);r=[...i,...s]}if(r.length===0)return!1;let o=ys(e);for(let i of r)for(let s=0;s<i.length;s+=2)if(!Un(o,i[s],i[s+1]))return!1;return!Hk(r,e)}function Fd(e,t,n={}){if(e.length<3)return!1;let r=n.filled!==!1;if(t.kind==="rect"&&r)return S4(Cd(t),e);let{closed:o,open:i}=t.kind==="rect"?{closed:[ys(Cd(t))],open:[]}:Md(t,n),s=ys(e);return Dk(o,s)||Dk(i,s)||Hk(o,e)||v4(i,e)?!0:r&&o.length>0&&kg(t,e[0].x,e[0].y,n)}var Gk=Q(()=>{"use strict";Nl();_k()});function Rt(e,t,n={}){let[r,o,i,s,a,l]=t;if(e.kind==="rect"){if(Math.abs(o)<Uk&&Math.abs(i)<Uk){let c=r*e.x+a,d=s*e.y+l,f=r*(e.x+e.width)+a,p=s*(e.y+e.height)+l;return{kind:"rect",x:Math.min(c,f),y:Math.min(d,p),width:Math.abs(f-c),height:Math.abs(p-d)}}let u=new _e().autoOrigin().moveTo(e.x,e.y).lineTo(e.x+e.width,e.y).lineTo(e.x+e.width,e.y+e.height).lineTo(e.x,e.y+e.height).close().build();return Wk(u,t,n)}return Wk(e,t,n)}function Wk(e,t,n){let r=og(e,Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]))),o=e.origin;if(o===void 0){let d=$y(e.coords,t),f=n.autoOrigin!==!1?Sn(d):void 0;return f?{...r,coords:At(f,d),origin:f}:{...r,coords:Float32Array.from(d)}}let[i,s,a,l,u,c]=t;return{...r,coords:Float32Array.from($y(e.coords,[i,s,a,l,0,0])),origin:{x:i*o.x+a*o.y+u,y:s*o.x+l*o.y+c}}}var Uk,Il=Q(()=>{"use strict";cs();mr();wl();tn();Uk=1e-9});function Ag(e,t,n){return e.kind==="rect"?{kind:"rect",x:e.x+t,y:e.y+n,width:e.width,height:e.height}:R4(e,t,n)}function R4(e,t,n){let r=e.origin;if(r)return{...e,coords:e.coords.slice(),origin:{x:r.x+t,y:r.y+n}};let o=new Float32Array(e.coords.length),{commands:i,coords:s}=e;return Ge(i,s,(a,l)=>{for(let u=0,c=oo(a);u<c;u+=2)o[l+u]=s[l+u]+t,o[l+u+1]=s[l+u+1]+n}),{...e,coords:o}}var Vk=Q(()=>{"use strict";Je()});function Rg(e){if(e.kind==="rect")return 4;let t=e.commands,n=0;for(let r=0;r<t.length;r++){let o=t[r];(o===le||o===ce||o===xe||o===we)&&n++}return n}var zk=Q(()=>{"use strict";Je()});function Ld(e){if(e.kind==="rect")return e.width*e.height;let{commands:t,coords:n}=e,r=kn(e),o=0,i=0,s=0,a=0,l=!1,u=0,c=0,d=f=>{l&&(f||r)&&(o+=i+u*a-s*c),i=0,l=!1};return Ge(t,n,(f,p,h,m)=>{if(f===le){d(!1),s=u=n[p],a=c=n[p+1],l=!0;return}if(f===fe){d(!0),u=s,c=a;return}if(l||(s=h,a=m,l=!0),f===ce){u=n[p],c=n[p+1],i+=h*c-u*m;return}let g=f===xe,b=n[p],x=n[p+1],w=n[p+2],y=n[p+3],P=g?n[p+4]:w,S=g?n[p+5]:y;for(let v=0;v<3;v++){let A=N4[v],N=1-A,M,C,F,B;g?(M=N*N*N*h+3*N*N*A*b+3*N*A*A*w+A*A*A*P,C=N*N*N*m+3*N*N*A*x+3*N*A*A*y+A*A*A*S,F=3*(N*N*(b-h)+2*N*A*(w-b)+A*A*(P-w)),B=3*(N*N*(x-m)+2*N*A*(y-x)+A*A*(S-y))):(M=N*N*h+2*N*A*b+A*A*w,C=N*N*m+2*N*A*x+A*A*y,F=2*(N*(b-h)+A*(w-b)),B=2*(N*(x-m)+A*(y-x))),i+=I4[v]*(M*B-C*F)}u=P,c=S}),d(!1),o/2}var N4,I4,Ng=Q(()=>{"use strict";Je();ii();N4=[.5-Math.sqrt(15)/10,.5,.5+Math.sqrt(15)/10],I4=[5/18,8/18,5/18]});function jk(e,t){let n=e[t];if(!/[A-Za-z]/.test(n))return!1;if(n!=="e"&&n!=="E"||!/[\d.]/.test(e[t-1]??""))return!0;let r=e[t+1]==="+"||e[t+1]==="-"?t+2:t+1;return!/\d/.test(e[r]??"")}function E4(e){let t=[],n=0;for(;n<e.length;)if(jk(e,n)){let r=n+1;for(;r<e.length&&!jk(e,r);)r++;let o=e.slice(n+1,r),i=e[n];t.push({cmd:i,args:i==="A"||i==="a"?C4(o):M4(o)}),n=r}else n++;return t}function M4(e){let t=[],n;for(Kk.lastIndex=0;(n=Kk.exec(e))!==null;){let r=Number(n[0]);Number.isFinite(r)&&t.push(r)}return t}function C4(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===","||r===" "||r===" "||r===`
2
- `||r==="\r"){n++;continue}let o=t.length%7;if(o===3||o===4){if(r!=="0"&&r!=="1")return t;t.push(r==="1"?1:0),n++;continue}Ig.lastIndex=n;let i=Ig.exec(e);if(!i)return t;t.push(Number(i[0])),n=Ig.lastIndex}return t}function si(e,t){let n=E4(e),r=new _e().autoOrigin(),o={x:0,y:0,startX:0,startY:0,lastCubicCtrl:null,lastQuadCtrl:null},i=!1;for(let{cmd:s,args:a}of n){let l=s.toUpperCase(),u=s!==l,c=O4[l];if(c===void 0){t?.(`unknown path command: ${s}`);continue}if(!i&&l!=="M"){t?.(`path data does not begin with a moveto ("${s}" comes first); nothing is drawn`);break}if(l==="Z"){r.close(),o.x=o.startX,o.y=o.startY,o.lastCubicCtrl=null,o.lastQuadCtrl=null;continue}let d=Math.floor(a.length/c);for(let f=0;f<d;f++){let p=a.slice(f*c,(f+1)*c),h=l==="M"&&f>0?"L":l;F4(h,u,p,o,r),i=!0}if(d===0||a.length%c!==0){t?.(`path command "${s}" takes ${c} arguments at a time and has ${a.length}; the path ends before it`);break}}return r.build()}function F4(e,t,n,r,o){let i=t?r.x:0,s=t?r.y:0;switch(e){case"M":{let a=n[0]+i,l=n[1]+s;o.moveTo(a,l),r.x=a,r.y=l,r.startX=a,r.startY=l,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"L":{let a=n[0]+i,l=n[1]+s;o.lineTo(a,l),r.x=a,r.y=l,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"H":{let a=n[0]+(t?r.x:0);o.lineTo(a,r.y),r.x=a,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"V":{let a=n[0]+(t?r.y:0);o.lineTo(r.x,a),r.y=a,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"C":{let a=n[0]+i,l=n[1]+s,u=n[2]+i,c=n[3]+s,d=n[4]+i,f=n[5]+s;o.curveTo(a,l,u,c,d,f),r.x=d,r.y=f,r.lastCubicCtrl={x:u,y:c},r.lastQuadCtrl=null;return}case"S":{let a=r.lastCubicCtrl??{x:r.x,y:r.y},l=2*r.x-a.x,u=2*r.y-a.y,c=n[0]+i,d=n[1]+s,f=n[2]+i,p=n[3]+s;o.curveTo(l,u,c,d,f,p),r.x=f,r.y=p,r.lastCubicCtrl={x:c,y:d},r.lastQuadCtrl=null;return}case"Q":{let a=n[0]+i,l=n[1]+s,u=n[2]+i,c=n[3]+s;o.quadTo(a,l,u,c),r.x=u,r.y=c,r.lastQuadCtrl={x:a,y:l},r.lastCubicCtrl=null;return}case"T":{let a=r.lastQuadCtrl??{x:r.x,y:r.y},l=2*r.x-a.x,u=2*r.y-a.y,c=n[0]+i,d=n[1]+s;o.quadTo(l,u,c,d),r.x=c,r.y=d,r.lastQuadCtrl={x:l,y:u},r.lastCubicCtrl=null;return}case"A":{let a=Math.abs(n[0]),l=Math.abs(n[1]),u=n[2],c=n[3]!==0,d=n[4]!==0,f=n[5]+i,p=n[6]+s;L4(r.x,r.y,f,p,a,l,u,c,d,o),r.x=f,r.y=p,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}default:return}}function L4(e,t,n,r,o,i,s,a,l,u){if(e===n&&t===r)return;if(o===0||i===0){u.lineTo(n,r);return}let c=s*Math.PI/180,d=Math.cos(c),f=Math.sin(c),p=(e-n)/2,h=(t-r)/2,m=d*p+f*h,g=-f*p+d*h,b=o*o,x=i*i,w=m*m,y=g*g,P=w/b+y/x,S=o,v=i;if(P>1){let te=Math.sqrt(P);S=te*o,v=te*i,b=S*S,x=v*v}let A=a===l?-1:1,N=b*x-b*y-x*w,M=b*y+x*w,C=A*Math.sqrt(Math.max(0,N/M)),F=C*(S*g)/v,B=C*-(v*m)/S,D=d*F-f*B+(e+n)/2,j=f*F+d*B+(t+r)/2,W=(te,he,be,Fe)=>{let Se=te*be+he*Fe,ur=Math.sqrt((te*te+he*he)*(be*be+Fe*Fe)),Le=Math.acos(Math.max(-1,Math.min(1,Se/ur)));return te*Fe-he*be<0&&(Le=-Le),Le},J=W(1,0,(m-F)/S,(g-B)/v),se=W((m-F)/S,(g-B)/v,(-m-F)/S,(-g-B)/v);!l&&se>0?se-=2*Math.PI:l&&se<0&&(se+=2*Math.PI);let ke=Math.max(1,Math.ceil(Math.abs(se)/(Math.PI/2))),ae=se/ke,ve=4/3*Math.tan(ae/4),G=e,K=t,$=-Math.sin(J)*S,ee=Math.cos(J)*v;for(let te=1;te<=ke;te++){let he=J+te*ae,be=Math.cos(he),Fe=Math.sin(he),Se=d*(be*S)-f*(Fe*v)+D,ur=f*(be*S)+d*(Fe*v)+j,Le=-Fe*S,vt=be*v,Xt=G+d*(ve*$)-f*(ve*ee),Vc=K+f*(ve*$)+d*(ve*ee),dy=Se-d*(ve*Le)+f*(ve*vt),zc=ur-f*(ve*Le)-d*(ve*vt);u.curveTo(Xt,Vc,dy,zc,Se,ur),G=Se,K=ur,$=Le,ee=vt}}var Kk,Ig,O4,$k=Q(()=>{"use strict";mr();Kk=/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g,Ig=/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/y;O4={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0}});function Ue(e,t,n,r){let o=(n-e)/3,i=(r-t)/3;return{c:[e,t,e+o,t+i,n-o,r-i,n,r],line:!0}}function ai(e){if(e.kind==="rect"){let{x:c,y:d,width:f,height:p}=e;return[{closed:!0,segs:[Ue(c,d,c+f,d),Ue(c+f,d,c+f,d+p),Ue(c+f,d+p,c,d+p),Ue(c,d+p,c,d)]}]}let t=[],n=null,r=0,o=0,i=(c,d,f)=>{n!==null&&(c&&((d!==r||f!==o)&&n.segs.push(Ue(d,f,r,o)),n.closed=!0),n.segs.length>0&&t.push(n),n=null)},s=Qe(e),{commands:a}=s,l=$e(s);Ge(a,l,(c,d,f,p,h,m)=>{switch(m&&(n={segs:[],closed:!1},r=f,o=p),c){case le:i(!1,f,p),n={segs:[],closed:!1},r=l[d],o=l[d+1];break;case ce:{let g=l[d],b=l[d+1];(g!==f||b!==p)&&n.segs.push(Ue(f,p,g,b));break}case we:{let[g,b,x,w]=io(f,p,l[d],l[d+1],l[d+2],l[d+3]);n.segs.push({c:[f,p,g,b,x,w,l[d+2],l[d+3]],line:!1});break}case xe:n.segs.push({c:[f,p,l[d],l[d+1],l[d+2],l[d+3],l[d+4],l[d+5]],line:!1});break;case fe:i(!0,f,p);break}});let u=n;if(u!==null){let c=u.segs.at(-1);i(!1,c?c.c[6]:r,c?c.c[7]:o)}return t}function Eg(e,t="nonzero"){let n=new _e().setFillRule(t);for(let{segs:r,closed:o}of e)if(r.length!==0){n.moveTo(r[0].c[0],r[0].c[1]);for(let{c:i,line:s}of r)s?n.lineTo(i[6],i[7]):n.curveTo(i[2],i[3],i[4],i[5],i[6],i[7]);o&&n.close()}return n.build()}function gs(e,t){let[n,r]=so(...e.c,t);return[{c:[...n],line:e.line},{c:[...r],line:e.line}]}var _d=Q(()=>{"use strict";Pn();Je();mr();nn();tn()});function tt(e,t){let n=1-t;if(e.length===2)return{x:n*e[0].x+t*e[1].x,y:n*e[0].y+t*e[1].y};if(e.length===3){let a=n*n,l=2*n*t,u=t*t;return{x:a*e[0].x+l*e[1].x+u*e[2].x,y:a*e[0].y+l*e[1].y+u*e[2].y}}let r=n*n*n,o=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:r*e[0].x+o*e[1].x+i*e[2].x+s*e[3].x,y:r*e[0].y+o*e[1].y+i*e[2].y+s*e[3].y}}function Ml(e,t){let n=e.length-1,r=[];for(let o=0;o<n;o++)r.push({x:n*(e[o+1].x-e[o].x),y:n*(e[o+1].y-e[o].y)});return r.length===1?r[0]:tt(r,t)}function Yk(e,t){let n=i=>{let s=[];for(let a=0;a<i.length;a+=2)s.push({x:i[a],y:i[a+1]});return s};if(e.length===2){let i=tt(e,t);return[[e[0],i],[i,e[1]]]}if(e.length===3){let[i,s]=jS(e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,t);return[n(i),n(s)]}let[r,o]=so(e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y,t);return[n(r),n(o)]}function bs(e,t,n,r,o){if(n-t<=0)return null;let i=e;t>0&&(i=Yk(i,t)[1]);let s=(n-t)/(1-t);return s<1&&(i=Yk(i,s)[0]),i=i.slice(),i[0]=r,i[i.length-1]=o,i}function _4(e){let t=[];for(let n of e){let r=n.length===2?1:16;for(let o=0;o<r;o++){let i=tt(n,o/r);t.push(i.x,i.y)}}return t}function Xk(e){return yr(_4(e))}function Jk(e,t,n){return e.map(r=>n.x*(r.y-t.y)-n.y*(r.x-t.x))}function El(e,t){let n=1-t;return e.length===2?n*e[0]+t*e[1]:e.length===3?n*n*e[0]+2*n*t*e[1]+t*t*e[2]:n*n*n*e[0]+3*n*n*t*e[1]+3*n*t*t*e[2]+t*t*t*e[3]}function Qk(e,t){let n=i=>i>0?1:i<0?-1:t?1:0,r=[0,...D4(e),1],o=[];for(let i=0;i+1<r.length;i++){let s=r[i],a=r[i+1],l=n(El(e,s)),u=n(El(e,a));if(l===0&&i>0){let c=n(El(e,s-1e-7)),d=n(El(e,s+1e-7));c*d<0&&o.push({t:s,before:c,after:d})}if(!(l*u>=0)){for(let c=0;c<64;c++){let d=(s+a)/2;n(El(e,d))===l?s=d:a=d}o.push({t:(s+a)/2,before:l,after:u})}}return o}function D4(e){if(e.length<3)return[];let t=e.length-1,n=e.slice(1).map((l,u)=>t*(l-e[u])),r=0,o,i;n.length===2?(o=n[1]-n[0],i=n[0]):(r=n[0]-2*n[1]+n[2],o=2*(n[1]-n[0]),i=n[0]);let s=[],a=Math.max(Math.abs(r),Math.abs(o),Math.abs(i))||1;if(Math.abs(r)/a<1e-12)Math.abs(o)/a>1e-12&&s.push(-i/o);else{let l=o*o-4*r*i;if(l>=0){let u=-.5*(o+Math.sign(o||1)*Math.sqrt(l));s.push(u/r),u!==0&&s.push(i/u)}}return s.filter(l=>l>0&&l<1).sort((l,u)=>l-u)}var qk,li=Q(()=>{"use strict";Pn();Nl();qk=e=>e.map(t=>t.slice().reverse()).reverse()});function ev(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let i of e)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return[t,n,r,o]}function tv(e){if(e.length===2)return 0;let t=e[0],n=e[e.length-1],r=n.x-t.x,o=n.y-t.y,i=Math.hypot(r,o),s=0;for(let a=1;a<e.length-1;a++){let l=e[a],u=i===0?Math.hypot(l.x-t.x,l.y-t.y):Math.abs((l.x-t.x)*o-(l.y-t.y)*r)/i;u>s&&(s=u)}return s}function nv(e){let t=e.pts,n=[t[0]],r=[t[t.length-1]];for(;t.length>1;){let i=[];for(let s=0;s+1<t.length;s++)i.push({x:(t[s].x+t[s+1].x)/2,y:(t[s].y+t[s+1].y)/2});t=i,n.push(t[0]),r.unshift(t[t.length-1])}let o=(e.t0+e.t1)/2;return[{pts:n,t0:e.t0,t1:o},{pts:r,t0:o,t1:e.t1}]}function rv(e,t,n,r,o){let i=t.x-e.x,s=t.y-e.y,a=r.x-n.x,l=r.y-n.y,u=i*l-s*a;if(u===0)return null;let c=n.x-e.x,d=n.y-e.y,f=(c*l-d*a)/u,p=(c*s-d*i)/u;return f<-o||f>1+o||p<-o||p>1+o?null:[f,p]}function G4(e,t,n,r){for(let o=0;o<12;o++){let i=tt(e,n),s=tt(t,r),a=i.x-s.x,l=i.y-s.y;if(Math.abs(a)+Math.abs(l)<1e-12)break;let u=Ml(e,n),c=Ml(t,r),d=-u.x*c.y+u.y*c.x;if(d===0)break;let f=(-a*-c.y- -l*-c.x)/d,p=(u.x*-l-u.y*-a)/d;n=Math.min(1,Math.max(0,n+f)),r=Math.min(1,Math.max(0,r+p))}return[n,r]}function Mg(e,t){if(e.length===2&&t.length===2){let i=rv(e[0],e[1],t[0],t[1],1e-12);if(!i)return[];let s=Math.min(1,Math.max(0,i[0])),a=Math.min(1,Math.max(0,i[1])),l=tt(e,s);return[{ta:s,tb:a,x:l.x,y:l.y}]}let n=[],r=(i,s)=>{[i,s]=G4(e,t,i,s);let a=tt(e,i),l=tt(t,s);Math.hypot(a.x-l.x,a.y-l.y)>1e-6*(1+Math.abs(a.x)+Math.abs(a.y))||n.some(u=>Math.abs(u.ta-i)<Zk&&Math.abs(u.tb-s)<Zk)||n.push({ta:i,tb:s,x:a.x,y:a.y})},o=[[{pts:e,t0:0,t1:1},{pts:t,t0:0,t1:1},0]];for(;o.length>0&&n.length<H4;){let[i,s,a]=o.pop(),l=ev(i.pts),u=ev(s.pts);if(l[0]>u[2]+xs||u[0]>l[2]+xs||l[1]>u[3]+xs||u[1]>l[3]+xs)continue;let c=tv(i.pts),d=tv(s.pts);if(c<=xs&&d<=xs||a>=B4){let f=rv(i.pts[0],i.pts[i.pts.length-1],s.pts[0],s.pts[s.pts.length-1],1e-6);f&&r(i.t0+f[0]*(i.t1-i.t0),s.t0+f[1]*(s.t1-s.t0));continue}if(c>=d){let[f,p]=nv(i);o.push([f,s,a+1],[p,s,a+1])}else{let[f,p]=nv(s);o.push([i,f,a+1],[i,p,a+1])}}return n.sort((i,s)=>i.ta-s.ta)}var xs,B4,Zk,H4,ov=Q(()=>{"use strict";li();xs=1e-4,B4=48,Zk=1e-7,H4=16});function iv(e){let t=e.kind==="rect"||kn(e);return U4(e).filter(n=>n.closed||t).map(n=>n.segs)}function U4(e,t=!0){let n=Qe(e);if(n.kind==="rect"){let{x:c,y:d,width:f,height:p}=n,h=[{x:c,y:d},{x:c+f,y:d},{x:c+f,y:d+p},{x:c,y:d+p}];return[{segs:h.map((m,g)=>[m,h[(g+1)%4]]),closed:!0}]}let r=[],o=[],i={x:0,y:0},s=i,a=c=>{o.length>0&&(c||t)&&(s.x!==i.x||s.y!==i.y)&&o.push([s,i]),o.length>0&&r.push({segs:o,closed:c}),o=[],s=i},l=$e(n),u=0;for(let c of n.commands)if(c===le)a(!1),i=s={x:l[u],y:l[u+1]},u+=2;else if(c===ce){let d={x:l[u],y:l[u+1]};(d.x!==s.x||d.y!==s.y)&&o.push([s,d]),s=d,u+=2}else if(c===we){let d={x:l[u+2],y:l[u+3]};o.push([s,{x:l[u],y:l[u+1]},d]),s=d,u+=4}else if(c===xe){let d={x:l[u+4],y:l[u+5]};o.push([s,{x:l[u],y:l[u+1]},{x:l[u+2],y:l[u+3]},d]),s=d,u+=6}else c===fe&&a(!0);return a(!1),r}function sv(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let i of e)for(let s of i)for(let a of s)t=Math.min(t,a.x),r=Math.max(r,a.x),n=Math.min(n,a.y),o=Math.max(o,a.y);return Math.hypot(r-t,o-n)}var av=Q(()=>{"use strict";Je();ii();nn();tn()});function Wn(e,t){let n=new e.constructor(t);return n.set(e),n}function Cg(e,t,n,r,o){for(let i=0;i<o;i++)n[r+i]<e[t+i]&&(e[t+i]=n[r+i]),n[r+o+i]>e[t+o+i]&&(e[t+o+i]=n[r+o+i])}var Dd,lv=Q(()=>{"use strict";Dd=class{dim;root=-1;nodeBox;left;right;parent;leafCount;leafItems;count;nodeCap=0;nodeTop=0;freeNodes=[];itemBox;itemCentroid2;itemLeaf;keys=[];itemCap=0;itemTop=0;freeItems=[];constructor(t){this.dim=t,this.nodeBox=new Float64Array(0),this.left=this.right=this.parent=this.leafCount=this.leafItems=this.count=new Int32Array(0),this.itemBox=new Float64Array(0),this.itemCentroid2=new Float64Array(0),this.itemLeaf=new Int32Array(0),this.growNodes(16),this.growItems(16)}growNodes(t){let n=2*this.dim;this.nodeBox=Wn(this.nodeBox,t*n),this.left=Wn(this.left,t),this.right=Wn(this.right,t),this.parent=Wn(this.parent,t),this.leafCount=Wn(this.leafCount,t),this.leafItems=Wn(this.leafItems,t*4),this.count=Wn(this.count,t),this.nodeCap=t}growItems(t){this.itemBox=Wn(this.itemBox,t*2*this.dim),this.itemCentroid2=Wn(this.itemCentroid2,t*this.dim),this.itemLeaf=Wn(this.itemLeaf,t),this.itemCap=t}allocNode(t){let n=this.freeNodes.pop();return n===void 0&&(this.nodeTop===this.nodeCap&&this.growNodes(this.nodeCap*2),n=this.nodeTop++),this.left[n]=-1,this.right[n]=-1,this.parent[n]=t,this.leafCount[n]=0,n}freeNode(t){this.freeNodes.push(t)}allocItem(t,n){let r=this.freeItems.pop();return r===void 0&&(this.itemTop===this.itemCap&&this.growItems(this.itemCap*2),r=this.itemTop++),this.keys[r]=t,this.writeItemBox(r,n),r}freeItem(t){this.keys[t]=void 0,this.itemLeaf[t]=-1,this.freeItems.push(t)}writeItemBox(t,n){let r=this.dim,o=2*r;for(let i=0;i<o;i++)this.itemBox[t*o+i]=n[i];for(let i=0;i<r;i++)this.itemCentroid2[t*r+i]=n[i]+n[r+i]}computeBox(t){let n=this.dim,r=2*n,o=this.nodeBox,i=t*r;for(let a=0;a<n;a++)o[i+a]=1/0,o[i+n+a]=-1/0;if(this.left[t]!==-1){Cg(o,i,o,this.left[t]*r,n),Cg(o,i,o,this.right[t]*r,n),this.count[t]=this.count[this.left[t]]+this.count[this.right[t]];return}this.count[t]=this.leafCount[t];let s=t*4;for(let a=0;a<this.leafCount[t];a++)Cg(o,i,this.itemBox,this.leafItems[s+a]*r,n)}refitUp(t){for(;t!==-1;t=this.parent[t])this.computeBox(t)}build(){this.freeNodes=[],this.nodeTop=0,this.root=-1;let t=[];for(let r=0;r<this.itemTop;r++)this.itemLeaf[r]!==-1&&t.push(r);if(t.length===0)return;this.nodeCap<2*t.length&&this.growNodes(2*t.length);let n=Int32Array.from(t);this.root=this.buildRange(n,0,n.length,-1)}rebuildSubtree(t){let n=this.parent[t],r=n!==-1&&this.left[n]===t,o=new Int32Array(this.count[t]),i=[t],s=0;for(;i.length>0;){let l=i.pop();if(this.left[l]!==-1)i.push(this.left[l],this.right[l]);else for(let u=0;u<this.leafCount[l];u++)o[s++]=this.leafItems[l*4+u];this.freeNode(l)}let a=this.buildRange(o,0,s,n);n===-1?this.root=a:r?this.left[n]=a:this.right[n]=a}buildRange(t,n,r,o,i=new Float64Array(t.length)){let s=this.allocNode(o);if(r-n<=4)for(let a=n;a<r;a++)this.placeInLeaf(s,t[a]);else{let a=n+r>>1;this.select(t,i,n,r,a,this.longestCentroidAxis(t,n,r));let l=this.buildRange(t,n,a,s,i),u=this.buildRange(t,a,r,s,i);this.left[s]=l,this.right[s]=u}return this.computeBox(s),s}placeInLeaf(t,n){this.leafItems[t*4+this.leafCount[t]++]=n,this.itemLeaf[n]=t}splitLeaf(t,n){let r=t*4,o=new Int32Array(5);for(let l=0;l<4;l++)o[l]=this.leafItems[r+l];o[4]=n;let i=o.length>>1;this.select(o,new Float64Array(o.length),0,o.length,i,this.longestCentroidAxis(o,0,o.length)),this.leafCount[t]=0;let s=this.allocNode(t),a=this.allocNode(t);for(let l=0;l<i;l++)this.placeInLeaf(s,o[l]);for(let l=i;l<o.length;l++)this.placeInLeaf(a,o[l]);this.left[t]=s,this.right[t]=a,this.computeBox(s),this.computeBox(a)}longestCentroidAxis(t,n,r){let o=this.dim,i=this.itemCentroid2,s=0,a=-1;for(let l=0;l<this.dim;l++){let u=1/0,c=-1/0;for(let d=n;d<r;d++){let f=i[t[d]*o+l];f<u&&(u=f),f>c&&(c=f)}c-u>a&&(a=c-u,s=l)}return s}select(t,n,r,o,i,s){let a=this.dim,l=this.itemCentroid2;for(let d=r;d<o;d++)n[d]=l[t[d]*a+s];let u=r,c=o-1;for(;u<c;){let d=n[u+c>>1],f=u,p=c;for(;f<=p;){for(;n[f]<d;)f++;for(;n[p]>d;)p--;if(f<=p){let h=t[f];t[f]=t[p],t[p]=h;let m=n[f];n[f]=n[p],n[p]=m,f++,p--}}if(i<=p)c=p;else if(i>=f)u=f;else return}}}});function Bd(e,t,n,r){e.ensureHeap(t+1);let o=e.heapT,i=e.heapId,s=t;for(;s>0;){let a=s-1>>1;if(o[a]<=n)break;o[s]=o[a],i[s]=i[a],s=a}return o[s]=n,i[s]=r,t+1}function W4(e,t){let n=e.heapT,r=e.heapId,o=t-1,i=n[o],s=r[o],a=0;for(;;){let l=2*a+1;if(l>=o||(l+1<o&&n[l+1]<n[l]&&l++,n[l]>=i))break;n[a]=n[l],r[a]=r[l],a=l}n[a]=i,r[a]=s}function uv(e,t,n,r,o,i){for(let s=0;s<n;s++)if(e[t+s]>r[i+s]||r[o+s]>e[t+n+s])return!1;return!0}function Og(e,t,n,r,o,i){if(e.root===-1)return;let s=t.take(),a=e.dim,l=2*a;try{let u=s.stackAt(0),c=0;for(u[c++]=e.root;c>0;){let d=u[--c];if(uv(e.nodeBox,d*l,a,n,r,o)){if(e.left[d]===-1){let f=d*4;for(let p=0;p<e.leafCount[d];p++){let h=e.leafItems[f+p];if(uv(e.itemBox,h*l,a,n,r,o)&&i(e.keys[h])===!1)return}continue}u=s.stackAt(c+1),u[c++]=e.left[d],u[c++]=e.right[d]}}}finally{s.release()}}function cv(e,t,n,r){for(let o=0;o<r.length;o++){let{normal:i,offset:s}=r[o],a=s;for(let l=0;l<n;l++)a+=i[l]*(i[l]>=0?e[t+n+l]:e[t+l]);if(a<0)return!1}return!0}function dv(e,t,n,r){if(e.root===-1)return;let o=t.take(),i=e.dim,s=2*i;try{let a=o.stackAt(0),l=0;for(a[l++]=e.root;l>0;){let u=a[--l];if(cv(e.nodeBox,u*s,i,n)){if(e.left[u]===-1){let c=u*4;for(let d=0;d<e.leafCount[u];d++){let f=e.leafItems[c+d];if(cv(e.itemBox,f*s,i,n)&&r(e.keys[f])===!1)return}continue}a=o.stackAt(l+1),a[l++]=e.left[u],a[l++]=e.right[u]}}}finally{o.release()}}function Hd(e,t,n,r,o,i){let s=0,a=i;for(let l=0;l<n;l++){let u=e[t+l],c=e[t+n+l];if(o[l]===0){if(r[l]<u||r[l]>c)return-1;continue}let d=(u-r[l])/o[l],f=(c-r[l])/o[l];if(d<f?(d>s&&(s=d),f<a&&(a=f)):(f>s&&(s=f),d<a&&(a=d)),s>a)return-1}return s}function fv(e,t,n,r,o,i){if(e.root===-1)return;let s=e.dim,a=2*s,l=Hd(e.nodeBox,e.root*a,s,n,r,i);if(l<0)return;let u=t.take();try{let c=Bd(u,0,l,e.root);for(;c>0;){let d=u.heapT[0],f=u.heapId[0];if(W4(u,c--),f<0){if(o(e.keys[-f-1],d)===!1)return;continue}if(e.left[f]===-1){let b=f*4;for(let x=0;x<e.leafCount[f];x++){let w=e.leafItems[b+x],y=Hd(e.itemBox,w*a,s,n,r,i);y>=0&&(c=Bd(u,c,y,-w-1))}continue}let p=e.left[f],h=e.right[f],m=Hd(e.nodeBox,p*a,s,n,r,i);m>=0&&(c=Bd(u,c,m,p));let g=Hd(e.nodeBox,h*a,s,n,r,i);g>=0&&(c=Bd(u,c,g,h))}}finally{u.release()}}var Gd,pv=Q(()=>{"use strict";Gd=class e{stack=new Int32Array(64);heapT=new Float64Array(64);heapId=new Int32Array(64);busy=!1;take(){return this.busy?new e:(this.busy=!0,this)}release(){this.busy=!1}stackAt(t){if(t>=this.stack.length){let n=new Int32Array(this.stack.length*2);n.set(this.stack),this.stack=n}return this.stack}ensureHeap(t){if(t<this.heapT.length)return;let n=new Float64Array(this.heapT.length*2),r=new Int32Array(this.heapId.length*2);n.set(this.heapT),r.set(this.heapId),this.heapT=n,this.heapId=r}}});function hv(e){return 2*Math.ceil(Math.log2(Math.max(e,2)))}function z4(e){let t=0;for(;e>4;e=Math.ceil(e/2))t++;return t}function Fg(e,t){if(e.length<2*t)return!1;for(let n=0;n<t;n++){let r=e[n],o=e[t+n];if(!Number.isFinite(r)||!Number.isFinite(o)||r>o)return!1}return!0}function _g(e,t){if(!Number.isInteger(e)||e<1)throw new RangeError(`createBvh: dim must be a positive integer, got ${e}`);let n=new Lg(e);return t&&(n.load(t),n.rebuild()),n}var V4,Lg,mv=Q(()=>{"use strict";lv();pv();V4=.7;Lg=class{dim;tree;items=new Map;scratch=new Gd;peakSize=0;constructor(t){this.dim=t,this.tree=new Dd(t)}get size(){return this.items.size}load(t){for(let[n,r]of t){if(!Fg(r,this.dim))continue;let o=this.items.get(n);if(o!==void 0){this.tree.writeItemBox(o,r);continue}let i=this.tree.allocItem(n,r);this.tree.itemLeaf[i]=0,this.items.set(n,i)}}insert(t,n){if(!Fg(n,this.dim))return!1;if(this.items.has(t))return this.update(t,n);let r=this.tree.allocItem(t,n);return this.items.set(t,r),this.items.size>this.peakSize&&(this.peakSize=this.items.size),this.place(r),!0}update(t,n){let r=this.items.get(t);if(r===void 0||!Fg(n,this.dim))return!1;let o=this.tree,i=o.itemLeaf[r];return this.leafHolds(i,n)?(o.writeItemBox(r,n),!0):(this.detach(r),o.writeItemBox(r,n),this.place(r),!0)}remove(t){let n=this.items.get(t);return n===void 0?!1:(this.detach(n),this.items.delete(t),this.tree.freeItem(n),this.items.size<this.peakSize>>1&&this.rebuild(),!0)}refit(){let t=this.tree;if(t.root===-1)return;let n=this.scratch.take();try{let r=n.stackAt(0);r[0]=t.root;let o=1;for(let i=0;i<o;i++){let s=r[i];t.left[s]!==-1&&(r=n.stackAt(o+1),r[o++]=t.left[s],r[o++]=t.right[s])}for(let i=o-1;i>=0;i--)t.computeBox(r[i])}finally{n.release()}}rebuild(){this.tree.build(),this.peakSize=this.items.size}maxDepth(){let t=this.tree;if(t.root===-1)return 0;let n=0,r=[[t.root,0]];for(;r.length>0;){let[o,i]=r.pop();t.left[o]===-1?n=Math.max(n,i):r.push([t.left[o],i+1],[t.right[o],i+1])}return n}queryBox(t,n){Og(this.tree,this.scratch,t,0,this.dim,n)}queryPoint(t,n){Og(this.tree,this.scratch,t,0,0,n)}raycast(t,n,r,o=1/0){fv(this.tree,this.scratch,t,n,r,o)}queryHalfSpaces(t,n){dv(this.tree,this.scratch,t,n)}leafHolds(t,n){let r=this.dim,o=t*2*r,i=this.tree.nodeBox;for(let s=0;s<r;s++)if(n[s]<i[o+s]||n[r+s]>i[o+r+s])return!1;return!0}place(t){let n=this.tree;if(n.root===-1){n.root=n.allocNode(-1),n.placeInLeaf(n.root,t),n.computeBox(n.root);return}let r=n.root,o=0;for(;n.left[r]!==-1;){let i=n.left[r],s=n.right[r],a=this.enlargement(i,t),l=this.enlargement(s,t);r=a<l||a===l&&n.count[i]<=n.count[s]?i:s,o++}n.leafCount[r]<4?n.placeInLeaf(r,t):(n.splitLeaf(r,t),o++),n.refitUp(r),o>hv(this.items.size)&&this.rebalance(n.itemLeaf[t],o)}rebalance(t,n){let r=this.tree,o=hv(this.items.size),i=-1;for(let s=t,a=r.parent[t],l=n-1;a!==-1;s=a,a=r.parent[a],l--)if(!(l+z4(r.count[a])>o)){if(r.count[s]>V4*r.count[a]){r.rebuildSubtree(a);return}i===-1&&(i=a)}i!==-1?r.rebuildSubtree(i):this.rebuild()}enlargement(t,n){let r=this.dim,o=this.tree.nodeBox,i=this.tree.itemBox,s=t*2*r,a=n*2*r,l=0;for(let u=0;u<r;u++){let c=Math.min(o[s+u],i[a+u]),d=Math.max(o[s+r+u],i[a+r+u]);l+=d-c-(o[s+r+u]-o[s+u])}return l}detach(t){let n=this.tree,r=n.itemLeaf[t],o=r*4,i=n.leafCount[r];for(let u=0;u<i;u++)if(n.leafItems[o+u]===t){n.leafItems[o+u]=n.leafItems[o+i-1];break}if(n.leafCount[r]=i-1,n.itemLeaf[t]=-1,i>1){n.refitUp(r);return}let s=n.parent[r];if(n.freeNode(r),s===-1){n.root=-1;return}let a=n.left[s]===r?n.right[s]:n.left[s],l=n.parent[s];n.parent[a]=l,l===-1?n.root=a:n.left[l]===s?n.left[l]=a:n.right[l]=a,n.freeNode(s),n.refitUp(l)}}});function yv(e,t){let n=[],r=[];for(let{segs:i,closed:s}of e){n.push(le),r.push(i[0][0].x,i[0][0].y);for(let a of i){n.push(a.length===2?ce:a.length===3?we:xe);for(let l=1;l<a.length;l++)r.push(a[l].x,a[l].y)}s&&n.push(fe)}let o=Sn(r);return{kind:"polygon",commands:new Uint8Array(n),coords:At(o,r),fillRule:t,...o?{origin:o}:{}}}var gv=Q(()=>{"use strict";Je();tn()});function Bg(e,t,n={}){let r=new _e;if(!(t>0))return r.build();let o=Ld(e)<0?-1:1,i={d:t,sigma:o,tol:n.tolerance??.1,join:n.join??"miter",miterLimit:n.miterLimit??4};for(let s of ai(e)){let a=s.segs.filter(c=>!rU(c));if(a.length===0)continue;let l=a.at(-1).c,u=a[0].c;(l[6]!==u[0]||l[7]!==u[1])&&a.push(Ue(l[6],l[7],u[0],u[1])),sU(r,$4(a,i))}return r.build()}function $4(e,t){let n=e.map(r=>({pieces:Dg(r,t,0),join:[]}));for(let r=0;r<e.length;r++){let o=(r+1)%e.length,i=Pv(e[r].c),s=wv(e[o].c),a=[e[o].c[0],e[o].c[1]];n[r].join=Y4(n[r],n[o],a,i,s,t)}return n}function Y4(e,t,n,r,o,i){let s=iU(e.pieces.at(-1)),a=oU(t.pieces[0]),l=Math.hypot(a[0]-s[0],a[1]-s[1]);if(l<=i.tol*.001)return[];let u=r[0]*o[1]-r[1]*o[0],c=r[0]*o[0]+r[1]*o[1],d=i.sigma*u>0||Math.abs(u)<1e-9&&c<0;if(l<=i.tol)return q4(e,t,s);if(!d)return J4(e,t)?[]:[Ue(s[0],s[1],n[0],n[1]),Ue(n[0],n[1],a[0],a[1])];let f=Ud(r,i.sigma),p=Ud(o,i.sigma);if(i.join==="round")return eU(n,i.d,f,Math.atan2(u,c));let h=f[0]*p[0]+f[1]*p[1];if(1+h<1e-9||Math.sqrt(2/(1+h))>i.miterLimit)return[Ue(s[0],s[1],a[0],a[1])];let m=i.d/(1+h),g=[n[0]+(f[0]+p[0])*m,n[1]+(f[1]+p[1])*m];return X4(e,t,g)}function q4(e,t,n){let r=t.pieces[0];return r===e.pieces.at(-1)?[Ue(r.c[6],r.c[7],n[0],n[1])]:(t.pieces[0]=r.line?Ue(n[0],n[1],r.c[6],r.c[7]):{c:[n[0],n[1],r.c[2]+n[0]-r.c[0],r.c[3]+n[1]-r.c[1],r.c[4],r.c[5],r.c[6],r.c[7]],line:!1},[])}function X4(e,t,n){let r=e.pieces.at(-1),o=t.pieces[0],i=[];return r.line&&r!==o?e.pieces[e.pieces.length-1]=Ue(r.c[0],r.c[1],n[0],n[1]):i.push(Ue(r.c[6],r.c[7],n[0],n[1])),o.line&&r!==o?t.pieces[0]=Ue(n[0],n[1],o.c[6],o.c[7]):i.push(Ue(n[0],n[1],o.c[0],o.c[1])),i}function J4(e,t){let n=e.pieces.at(-1),r=t.pieces[0];if(n===r)return!1;let o=Q4(n.c,r.c);if(o===null)return!1;let i=o[0]>=1?n:gs(n,o[0])[0],s=o[1]<=0?r:gs(r,o[1])[1],a=(i.c[6]+s.c[0])/2,l=(i.c[7]+s.c[1])/2;return e.pieces[e.pieces.length-1]=i.line?Ue(i.c[0],i.c[1],a,l):{c:[i.c[0],i.c[1],i.c[2],i.c[3],i.c[4]+a-i.c[6],i.c[5]+l-i.c[7],a,l],line:!1},t.pieces[0]=s.line?Ue(a,l,s.c[6],s.c[7]):{c:[a,l,s.c[2]+a-s.c[0],s.c[3]+l-s.c[1],s.c[4],s.c[5],s.c[6],s.c[7]],line:!1},!0}function Q4(e,t){let n=bv(e),r=bv(t),o=null,i=1/0;for(let s=0;s<Ps;s++)for(let a=0;a<Ps;a++){let l=Z4(n[s],n[s+1],r[a],r[a+1]);if(l===null)continue;let u=(s+l[0])/Ps,c=(a+l[1])/Ps;u<=1e-9||c>=1-1e-9||1-u+c>=i||(i=1-u+c,o=[u,c])}return o}function bv(e){let t=[];for(let n=0;n<=Ps;n++)t.push(Ve(...e,n/Ps));return t}function Z4(e,t,n,r){let o=t[0]-e[0],i=t[1]-e[1],s=r[0]-n[0],a=r[1]-n[1],l=o*a-i*s;if(Math.abs(l)<1e-18)return null;let u=((n[0]-e[0])*a-(n[1]-e[1])*s)/l,c=((n[0]-e[0])*i-(n[1]-e[1])*o)/l;return u>=0&&u<=1&&c>=0&&c<=1?[u,c]:null}function eU(e,t,n,r){let o=Math.max(1,Math.ceil(Math.abs(r)/(Math.PI/2))),i=r/o,s=4/3*Math.tan(i/4)*t,a=Math.atan2(n[1],n[0]),l=[];for(let u=0;u<o;u++){let c=a+i*u,d=c+i,f=e[0]+Math.cos(c)*t,p=e[1]+Math.sin(c)*t,h=e[0]+Math.cos(d)*t,m=e[1]+Math.sin(d)*t;l.push({c:[f,p,f-Math.sin(c)*s,p+Math.cos(c)*s,h+Math.sin(d)*s,m-Math.cos(d)*s,h,m],line:!1})}return l}function Dg(e,t,n){let r=e.c,o=Ud(wv(r),t.sigma),i=Ud(Pv(r),t.sigma),{d:s}=t;if(e.line)return[Ue(r[0]+o[0]*s,r[1]+o[1]*s,r[6]+o[0]*s,r[7]+o[1]*s)];let a=Math.max(0,1+t.sigma*s*xv(r,0)),l=Math.max(0,1+t.sigma*s*xv(r,1)),u=r[0]+o[0]*s,c=r[1]+o[1]*s,d=r[6]+i[0]*s,f=r[7]+i[1]*s,p={c:[u,c,u+(r[2]-r[0])*a,c+(r[3]-r[1])*a,d+(r[4]-r[6])*l,f+(r[5]-r[7])*l,d,f],line:!1};if(n>=K4||tU(r,p.c,t)<=t.tol)return[p];let[h,m]=gs(e,.5);return[...Dg(h,t,n+1),...Dg(m,t,n+1)]}function tU(e,t,n){let r=0;for(let o of j4){let[i,s]=nU(e,o),a=Math.hypot(i,s);if(a<1e-12)continue;let[l,u]=Ve(...e,o),c=l+n.sigma*s/a*n.d,d=u-n.sigma*i/a*n.d,[f,p]=Ve(...t,o);r=Math.max(r,Math.hypot(f-c,p-d))}return r}function nU(e,t){let n=1-t,r=3*n*n,o=6*n*t,i=3*t*t;return[r*(e[2]-e[0])+o*(e[4]-e[2])+i*(e[6]-e[4]),r*(e[3]-e[1])+o*(e[5]-e[3])+i*(e[7]-e[5])]}function xv(e,t){let[n,r]=t===0?[e[2]-e[0],e[3]-e[1]]:[e[6]-e[4],e[7]-e[5]],[o,i]=t===0?[e[0]-2*e[2]+e[4],e[1]-2*e[3]+e[5]]:[e[6]-2*e[4]+e[2],e[7]-2*e[5]+e[3]],s=Math.hypot(n,r);return s<1e-12?0:2/3*(n*i-r*o)/(s*s*s)}function wv(e){return Ts(e[2]-e[0],e[3]-e[1])??Ts(e[4]-e[0],e[5]-e[1])??Ts(e[6]-e[0],e[7]-e[1])??[1,0]}function Pv(e){return Ts(e[6]-e[4],e[7]-e[5])??Ts(e[6]-e[2],e[7]-e[3])??Ts(e[6]-e[0],e[7]-e[1])??[1,0]}function Ts(e,t){let n=Math.hypot(e,t);return n<1e-12?null:[e/n,t/n]}function Ud(e,t){return[t*e[1],-t*e[0]]}function rU(e){let t=e.c;return t[0]===t[6]&&t[1]===t[7]&&t[0]===t[2]&&t[1]===t[3]&&t[0]===t[4]&&t[1]===t[5]}function sU(e,t){let n=t[0].pieces[0];e.moveTo(n.c[0],n.c[1]);for(let r of t)for(let o of[...r.pieces,...r.join])o.line?e.lineTo(o.c[6],o.c[7]):e.curveTo(o.c[2],o.c[3],o.c[4],o.c[5],o.c[6],o.c[7]);e.close()}var K4,j4,Ps,oU,iU,Tv=Q(()=>{"use strict";Pn();mr();_d();Ng();K4=6,j4=[.2,.35,.5,.65,.8];Ps=32;oU=e=>[e.c[0],e.c[1]],iU=e=>[e.c[6],e.c[7]]});function Rv(e){let t=e.map(o=>aU(o)),n=t.map(lU),r=[];for(let o=0;o<e.length;o++)for(let i=o+1;i<e.length;i++){if(!Yy(n[o],n[i]))continue;let s=t[o],a=t[i];for(let l=0;l+1<s.length;l++)for(let u=0;u+1<a.length;u++){let c=uU(s[l],s[l+1],a[u],a[u+1]);if(c===null)continue;let d=[(l+c[0])/(s.length-1),(u+c[1])/(a.length-1)],[f,p]=e[o].line&&e[i].line?d:cU(e[o].c,e[i].c,d);vv(f)&&vv(p)||r.some(h=>h.a===o&&h.b===i&&Math.abs(h.s-f)<1e-6&&Math.abs(h.t-p)<1e-6)||r.push({a:o,b:i,s:f,t:p})}}return r}function aU(e){if(e.line)return[[e.c[0],e.c[1]],[e.c[6],e.c[7]]];let t=[];for(let n=0;n<=Sv;n++)t.push(Ve(...e.c,n/Sv));return t}function lU(e){let t=[1/0,1/0,-1/0,-1/0];for(let[n,r]of e)t[0]=Math.min(t[0],n),t[1]=Math.min(t[1],r),t[2]=Math.max(t[2],n),t[3]=Math.max(t[3],r);return t}function uU(e,t,n,r){let o=t[0]-e[0],i=t[1]-e[1],s=r[0]-n[0],a=r[1]-n[1],l=o*a-i*s;if(Math.abs(l)<1e-18)return null;let u=((n[0]-e[0])*a-(n[1]-e[1])*s)/l,c=((n[0]-e[0])*i-(n[1]-e[1])*o)/l;return u>=0&&u<=1&&c>=0&&c<=1?[u,c]:null}function cU(e,t,n){let r=(l,u)=>{let c=Ve(...e,l),d=Ve(...t,u);return[c[0]-d[0],c[1]-d[1]]},[o,i]=n,s=r(o,i),a=Math.hypot(...s);for(let l=0;l<8&&Math.hypot(...s)>1e-13;l++){let u=Av(e,o),c=Av(t,i),d=-u[0]*c[1]+c[0]*u[1];if(Math.abs(d)<1e-18)break;o=Math.min(1,Math.max(0,o-(-c[1]*s[0]+c[0]*s[1])/d)),i=Math.min(1,Math.max(0,i-(-u[1]*s[0]+u[0]*s[1])/d)),s=r(o,i)}return Math.hypot(...s)<=a?[o,i]:n}function Av(e,t){let n=1-t,r=3*n*n,o=6*n*t,i=3*t*t;return[r*(e[2]-e[0])+o*(e[4]-e[2])+i*(e[6]-e[4]),r*(e[3]-e[1])+o*(e[5]-e[3])+i*(e[7]-e[5])]}var Sv,kv,vv,Nv=Q(()=>{"use strict";bl();Pn();Sv=16,kv=1e-7;vv=e=>e<kv||e>1-kv});function Gg(e,t={}){let n=t.tolerance??.01,r=ai(e).filter(d=>d.segs.length>0),o=r.flatMap(d=>Iv(d.segs,n*.001)),i=Ld(e)<0,s=o.map(()=>[]);for(let d of Rv(o)){let f=dU(o[d.a],d.s,o[d.b],d.t);s[d.a].push({t:d.s,p:f}),s[d.b].push({t:d.t,p:f})}let a=hU(o,n/4),l=[],u=!1;o.forEach((d,f)=>{let p=fU(d,s[f]);p.length>1&&(u=!0);for(let h of p){let m=mU(h,a,n);m===null?u=!0:m===i?l.push(h):(u=!0,l.push(pU(h)))}});let c=new _e;if(!u){for(let d of r)Mv(c,Iv(d.segs,n*.001));return c.build()}for(let d of yU(l))Mv(c,d);return c.build()}function Iv(e,t){let n=o=>o.line&&Math.hypot(o.c[6]-o.c[0],o.c[7]-o.c[1])<=t,r=e.filter(o=>!n(o));if(r.length===0)return[];for(let o=0;o<r.length;o++){let i=r[(o+r.length-1)%r.length].c,s=r[o];(i[6]!==s.c[0]||i[7]!==s.c[1])&&(Math.hypot(i[6]-s.c[0],i[7]-s.c[1])<=t?r[o]=Hg(s,[i[6],i[7]],[s.c[6],s.c[7]]):o===0&&r.push(Ue(i[6],i[7],s.c[0],s.c[1])))}return r}function dU(e,t,n,r){let o=(l,u)=>u<=1e-7?[l.c[0],l.c[1]]:u>=.9999999?[l.c[6],l.c[7]]:null,i=o(e,t)??o(n,r);if(i)return i;let s=Ve(...e.c,t),a=Ve(...n.c,r);return[(s[0]+a[0])/2,(s[1]+a[1])/2]}function fU(e,t){let n=t.filter(a=>a.t>1e-7&&a.t<.9999999).sort((a,l)=>a.t-l.t),r=[],o=e,i=0,s=[e.c[0],e.c[1]];for(let a of n){if(a.t-i<1e-9)continue;let[l,u]=gs(o,(a.t-i)/(1-i));r.push(Hg(l,s,a.p)),o=u,i=a.t,s=a.p}return r.push(Hg(o,s,[e.c[6],e.c[7]])),r}function Hg(e,t,n){let r=e.c;return{c:[t[0],t[1],r[2]+t[0]-r[0],r[3]+t[1]-r[1],r[4]+n[0]-r[6],r[5]+n[1]-r[7],n[0],n[1]],line:e.line}}function pU(e){let t=e.c;return{c:[t[6],t[7],t[4],t[5],t[2],t[3],t[0],t[1]],line:e.line}}function hU(e,t){let n=[],r=[];for(let{c:o,line:i}of e)r.length===0?r.push(o[0],o[1]):(r[r.length-2]!==o[0]||r[r.length-1]!==o[1])&&(n.push(r),r=[o[0],o[1]]),i?r.push(o[6],o[7]):lo(...o,t,r);return r.length>0&&n.push(r),n}function Ev(e,t,n){let r=0;for(let o of e)for(let i=0;i+3<o.length;i+=2){let s=o[i+1],a=o[i+3];if(s>n==a>n)continue;let l=o[i],u=o[i+2];t>=l+(n-s)/(a-s)*(u-l)||(r+=s<=n?1:-1)}return r}function mU(e,t,n){let r=e.c,[o,i]=Ve(...r,.5),s=r[6]+r[4]-r[2]-r[0],a=r[7]+r[5]-r[3]-r[1],l=Math.hypot(s,a);if(l<1e-12)return null;let u=a/l*n,c=-s/l*n,d=Ev(t,o+u,i+c)!==0,f=Ev(t,o-u,i-c)!==0;return d===f?null:d}function yU(e){let t=(i,s)=>`${i},${s}`,n=new Map;e.forEach((i,s)=>{let a=t(i.c[0],i.c[1]),l=n.get(a);l?l.push(s):n.set(a,[s])});let r=new Uint8Array(e.length),o=[];for(let i=0;i<e.length;i++){if(r[i])continue;let s=[],a=i;for(;a!==void 0&&!r[a];){r[a]=1;let l=e[a];s.push(l),a=n.get(t(l.c[6],l.c[7]))?.find(u=>!r[u])}o.push(s)}return o}function Mv(e,t){if(t.length===0)return;let[n,r]=t[0].c;e.moveTo(n,r);for(let[o,{c:i,line:s}]of t.entries()){if(s&&o===t.length-1&&i[6]===n&&i[7]===r)break;s?e.lineTo(i[6],i[7]):e.curveTo(i[2],i[3],i[4],i[5],i[6],i[7])}e.close()}var Cv=Q(()=>{"use strict";Pn();oi();mr();_d();Nv();Ng()});function Ss(e,t,n,r,o,i){return new Float64Array([e,t,0,n,r,0,o,i,1])}function gU(){return Ss(1,0,0,1,0,0)}function Ug(e,t){let n=e[0],r=e[1],o=e[3],i=e[4],s=e[6],a=e[7],l=t[0],u=t[1],c=t[3],d=t[4],f=t[6],p=t[7];return Ss(n*l+o*u,r*l+i*u,n*c+o*d,r*c+i*d,n*f+o*p+s,r*f+i*p+a)}function bU(e,t,n){let r=Ss(1,0,0,1,t,n);return Ug(e,r)}function xU(e,t,n){let r=Ss(t,0,0,n,0,0);return Ug(e,r)}function Ov(e){return[e[0],e[1],e[3],e[4],e[6],e[7]]}function Fv(e){return Ss(e[0],e[1],e[2],e[3],e[4],e[5])}function wU(e){let t=pr(Ov(e));return t&&Fv(t)}function PU(e){return Float32Array.from(e)}function TU(e,t,n){let r=e[0],o=e[1],i=e[3],s=e[4],a=e[6],l=e[7];return[r*t+i*n+a,o*t+s*n+l]}function SU(e,t){return Ss(2/e,0,0,-2/t,-1,1)}function kU(e){return Math.sqrt(Math.abs(e[0]*e[4]-e[1]*e[3]))}function vU(e){let t=e[0]*e[0]+e[1]*e[1]+e[3]*e[3]+e[4]*e[4],n=e[0]*e[4]-e[1]*e[3];return Math.sqrt(Math.max(0,(t-Math.sqrt(Math.max(0,t*t-4*n*n)))/2))}var q,Lv=Q(()=>{"use strict";cs();q={identity:gU,toAffine:Ov,fromAffine:Fv,multiply:Ug,translated:bU,scaled:xU,invert:wU,toUniform:PU,apply:TU,screenToClip:SU,meanScaleOf:kU,minScaleOf:vU}});function br(e){let t=e.scale.x,n=e.scale.y,r=-e.x*t+0,o=-e.y*n+0;return new Float64Array([t,0,0,0,n,0,r,o,1])}var _v=Q(()=>{"use strict"});function Wg(e){let t=e;return t.rotation&&t.x!=null&&t.y!=null&&t.width!=null&&t.height!=null?{cx:t.x+t.width/2,cy:t.y+t.height/2,rotation:t.rotation}:null}function Dv(e,t,n,r){return e.kind==="rect"?RU(e.x,e.y,e.width,e.height,t,n,r):AU(e,t,n,r)}function AU(e,t,n,r){let o=Math.cos(r),i=Math.sin(r);if(e.origin)return Rt(e,[o,i,-i,o,t-t*o+n*i,n-t*i-n*o]);let{commands:s,coords:a}=e,l=new Float32Array(a.length);return Ge(s,a,(u,c)=>{for(let d=0,f=oo(u);d<f;d+=2){let p=a[c+d]-t,h=a[c+d+1]-n;l[c+d]=t+p*o-h*i,l[c+d+1]=n+p*i+h*o}}),{...e,coords:l}}function RU(e,t,n,r,o,i,s){let a=Math.cos(s),l=Math.sin(s),u=(y,P)=>{let S=y-o,v=P-i;return[o+S*a-v*l,i+S*l+v*a]},[c,d]=u(e,t),[f,p]=u(e+n,t),[h,m]=u(e+n,t+r),[g,b]=u(e,t+r),x=new Uint8Array([le,ce,ce,ce,fe]),w=new Float32Array([c,d,f,p,h,m,g,b]);return{kind:"polygon",commands:x,coords:w,fillRule:"nonzero"}}var Bv=Q(()=>{"use strict";Je();Il()});function Vn(e){let t=e?.transform;return!Array.isArray(t)||t.length!==4||t[0]===1&&t[1]===0&&t[2]===0&&t[3]===1?null:t}function Ce(e){let t=e;if(!t||t.x==null||t.y==null||t.width==null||t.height==null)return null;let n=Vn(t);if(!t.rotation&&!n)return null;let r=t.x+t.width/2,o=t.y+t.height/2;if(!n)return ro(r,o,t.rotation);let[i,s,a,l]=n,u=[i,s,a,l,r-(i*r+a*o),o-(s*r+l*o)];return t.rotation?ht(ro(r,o,t.rotation),u):u}function ui(e){if(!Vn(e)){let n=Wg(e);return n&&ro(n.cx,n.cy,-n.rotation)}let t=Ce(e);return t&&pr(t)}function Cl(e,t){if(Vn(t)){let r=Ce(t);return r?Rt(e,r):e}let n=Wg(t);return n?Dv(e,n.cx,n.cy,n.rotation):e}var Hv=Q(()=>{"use strict";cs();Il();Bv()});function Ol(e,t){if(e.kind==="rect")return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height?e:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height};let n=et(e);if(n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height)return e;let r=hr(n.x,n.y,n.width,n.height,t.x,t.y,t.width,t.height);return Rt(e,r)}var Gv=Q(()=>{"use strict";cs();xg();Il()});function Uv(e){if(e===null||typeof e!="object")return;let{__ta:t,data:n}=e;if(!(typeof t!="string"||!Object.hasOwn(Fl,t)||!Array.isArray(n)))return Fl[t].from(n)}function Vg(e,t){let n=t(e);if(n!==void 0)return n;if(Array.isArray(e))return e.map(o=>Vg(o,t));if(!IU(e))return e;let r={};for(let o of Object.keys(e))r[o]=Vg(e[o],t);return r}function zg(e){return Vg(e,Uv)}var Fl,Yee,NU,IU,Wv=Q(()=>{"use strict";Fl={i8:Int8Array,u8:Uint8Array,u8c:Uint8ClampedArray,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array},Yee=new Map(Object.keys(Fl).map(e=>[Fl[e].name,e])),NU=e=>Object.prototype.toString.call(e).slice(8,-1);IU=e=>NU(e)==="Object"});var Z=Q(()=>{"use strict";ml();cs();bl();Je();oi();Nl();ii();mr();xg();tn();nn();wl();Vk();Il();$k();Ak();_d();Tv();Cv();Gk();zk();Lv();_v();Hv();Gv();Wv()});function Ht(e){return e!=null&&(e.kind===void 0||e.kind==="solid")}var sb=Q(()=>{"use strict"});function Ne(e,t=null){return e===rn?t:e?.paint==null?null:e}function Re(e,t=null){return e===rn?t:e?.paint==null?null:e}var rn,ab=Q(()=>{"use strict";rn="inherit"});function of(e){return Array.isArray(e)?`[${e.map(of).join(",")}]`:typeof e!="object"||e===null?JSON.stringify(e)??"null":`{${Object.keys(e).sort().filter(n=>e[n]!==void 0).map(n=>`${JSON.stringify(n)}:${of(e[n])}`).join(",")}}`}function fo(e){if(e==null)return"none";if(Ht(e))return`solid:${e.color}:${e.opacity??1}`;let t=DA.get(e);return t===void 0&&(t=of(e),DA.set(e,t)),t}function sf(e){return Ne(e)!==null}function xr(e){let t=Re(e);if(t===null)return!1;let n=t.width??1;return(typeof n=="number"?n:n.px)>0}function Vl(e){if(!xr(e))return"none";let t=BA.get(e);if(t===void 0){let{paint:n,width:r,join:o,cap:i,miterLimit:s,align:a,dash:l,...u}=e;t=of({...u,width:r??1,join:o??"miter",cap:i??"butt",miterLimit:s??4,align:a??"center",dash:l??[]}),BA.set(e,t)}return`${t}|${fo(e.paint)}`}var DA,BA,HA=Q(()=>{"use strict";sb();ab();DA=new WeakMap,BA=new WeakMap});function zl(e){return e!==void 0&&qU.has(e)}function lb(e){return zl(e.kind)}function ub(e){return e.kind==="image"}function af(e){return e.kind==="texture"||e.kind==="image"||zl(e.kind)}function lf(e){let{units:t,origin:n,transform:r,opacity:o}=e;return{...t!==void 0?{units:t}:{},...n!==void 0?{origin:n}:{},...r!==void 0?{transform:r}:{},...o!==void 0?{opacity:o}:{}}}function cb(e){let{units:t,origin:n,transform:r,opacity:o,...i}=e;return i}var GA,qU,UA=Q(()=>{"use strict";GA=["hatch","crosshatch","dots","chunks"],qU=new Set(GA)});function uf(e,t){let n=t/2;return typeof e=="number"?db(e)?{left:e/2,right:e/2}:{left:n,right:n}:e==null||typeof e!="object"?{left:n,right:n}:{left:db(e.left)?e.left:n,right:db(e.right)?e.right:n}}function Kl(e,t){return typeof e=="number"?e*t:{left:e.left*t,right:e.right*t}}function fb(e,t){let n=e/2;if(t)for(let r of t){let{left:o,right:i}=uf(r,e);n=Math.max(n,o,i)}return n}var db,WA=Q(()=>{"use strict";db=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0});function Gt(e,t){return typeof e=="number"?e:!Number.isFinite(t)||t===0?e.px:e.px/t}function pb(e,t,n=1){if(t==="center")return e;let o=(t==="inner"?-1:1)*n/2;return{x:e.x-o,y:e.y-o,width:e.width+2*o,height:e.height+2*o}}function cf(e,t){if(e===void 0||e.length===0)return"solid";if(!e.every(Number.isFinite))return"non-finite";if(e.some(n=>n<0)||!e.some(n=>n>0))return"solid";if(t!==void 0){let n=e.reduce((r,o)=>r+o,0);if(t/n*e.length>VA)return"solid"}return e}var VA,zA=Q(()=>{"use strict";VA=1e5});function KA(e){if(!XU.test(e))return null;let t=e.slice(1),n=t.length<=4?t.replace(/./g,"$&$&"):t,r=o=>Number.parseInt(n.slice(o,o+2),16);return[r(0),r(2),r(4),n.length===8?r(6):255]}var XU,jA=Q(()=>{"use strict";XU=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i});function $A(e){let t=e%hb;return t>Math.PI?t-hb:t<-Math.PI?t+hb:t}var hb,YA=Q(()=>{"use strict";hb=Math.PI*2});function yb(e){if(e<=0)return 0;if(e>=1)return 255;let t=e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055;return Math.round(t*255)}function df(e,t,n){return JU(mb[e&255],mb[t&255],mb[n&255])}function JU(e,t,n){let r=.4122214708*e+.5363325363*t+.0514459929*n,o=.2119034982*e+.6806995451*t+.1073969566*n,i=.0883024619*e+.2817188376*t+.6299787005*n,s=Math.cbrt(r),a=Math.cbrt(o),l=Math.cbrt(i);return[.2104542553*s+.793617785*a-.0040720468*l,1.9779984951*s-2.428592205*a+.4505937099*l,.0259040371*s+.7827717662*a-.808675766*l]}function jl(e,t,n){let r=e+.3963377774*t+.2158037573*n,o=e-.1055613458*t-.0638541728*n,i=e-.0894841775*t-1.291485548*n,s=r*r*r,a=o*o*o,l=i*i*i;return[4.0767416621*s-3.3077115913*a+.2309699292*l,-1.2684380046*s+2.6097574011*a-.3413193965*l,-.0041960863*s-.7034186147*a+1.707614701*l]}function qA(e,t,n){return e>=-1e-6&&e<=1+1e-6&&t>=-1e-6&&t<=1+1e-6&&n>=-1e-6&&n<=1+1e-6}function QU(e,t,n){let[r,o,i]=jl(e,t,n);if(qA(r,o,i))return[r,o,i];let s=0,a=1;for(let l=0;l<5;l++){let u=(s+a)/2;[r,o,i]=jl(e,t*u,n*u),qA(r,o,i)?s=u:a=u}return[r,o,i]=jl(e,t*s,n*s),[r,o,i]}function XA(e,t,n){let[r,o,i]=QU(e,t,n);return[yb(r),yb(o),yb(i)]}function ZU(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function JA(e,t,n){let r=Math.hypot(t,n),o=Math.atan2(n,t);return[e,r,o]}function bb(e,t,n){return[e,t*Math.cos(n),t*Math.sin(n)]}function eW(e,t,n){let[r,o,i]=e,[s,a,l]=t,u=1e-4,c=o<u?l:i,d=a<u?i:l,f=$A(d-c);return[r+(s-r)*n,o+(a-o)*n,c+f*n]}function QA(e,t,n,r="rgb"){if(e.length!==t.length)throw new Error(`lerpColorArray: length mismatch (from=${e.length}, to=${t.length})`);if(e.length%4!==0)throw new Error(`lerpColorArray: length ${e.length} not divisible by 4`);let o=new Array(e.length),i=e.length/4;if(r==="rgb"){for(let s=0;s<e.length;s++)o[s]=e[s]+(t[s]-e[s])*n;return o}if(r==="oklch"){for(let s=0;s<i;s++){let a=s*4,l=df(on(e[a]),on(e[a+1]),on(e[a+2])),u=df(on(t[a]),on(t[a+1]),on(t[a+2])),c=JA(l[0],l[1],l[2]),d=JA(u[0],u[1],u[2]),f=eW(c,d,n),p=bb(f[0],f[1],f[2]),[h,m,g]=XA(p[0],p[1],p[2]);o[a]=Cs(h),o[a+1]=Cs(m),o[a+2]=Cs(g),o[a+3]=e[a+3]+(t[a+3]-e[a+3])*n}return o}for(let s=0;s<i;s++){let a=s*4,l=df(on(e[a]),on(e[a+1]),on(e[a+2])),u=df(on(t[a]),on(t[a+1]),on(t[a+2])),c=ZU(l,u,n),[d,f,p]=XA(c[0],c[1],c[2]);o[a]=Cs(d),o[a+1]=Cs(f),o[a+2]=Cs(p),o[a+3]=e[a+3]+(t[a+3]-e[a+3])*n}return o}function xb(e){let t=Math.abs(e),n=t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055;return e<0?-n:n}function ZA(e,t,n){if(t===0)return[n,n,n];let r=n<.5?n*(1+t):n+t-n*t,o=2*n-r,i=e/360;return[gb(o,r,i+1/3),gb(o,r,i),gb(o,r,i-1/3)]}function gb(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var mb,on,Cs,wb=Q(()=>{"use strict";YA();mb=(()=>{let e=new Float64Array(256);for(let t=0;t<256;t++){let n=t/255;e[t]=n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}return e})();on=e=>Math.max(0,Math.min(255,Math.round(e*255)));Cs=e=>e/255});function eR(e){let t=ff.get(e);if(t!==void 0)return t;let n=nW(e);return ff.size>=tW&&ff.clear(),ff.set(e,n),n}function nW(e){let t=e.trim();if(t.startsWith("#"))return oW(t);let n=t.toLowerCase(),r=uW[n];if(r!==void 0)return r;if(n.startsWith("rgb")){let o=iW(n);if(o)return o}if(n.startsWith("hsl")){let o=sW(n);if(o)return o}if(n.startsWith("color(")){let o=aW(n);if(o)return o}if(n.startsWith("ok")){let o=lW(n);if(o)return o}throw new Error(`parseColor: unrecognized color "${e}"`)}function jn(e){let t=pf.get(e);if(t)return t;pf.size>=rW&&pf.clear();let r=eR(e);return pf.set(e,r),r}function oW(e){let t=KA(e);if(!t)throw new Error(`parseColor: invalid hex "${e}"`);return[t[0]/255,t[1]/255,t[2]/255,t[3]/255]}function hi(e,t){return!e.startsWith(t+"(")||!e.endsWith(")")?null:e.slice(t.length+1,-1).trim()}function mf(e){if(e.includes(",")){let i=e.split(",").map(s=>s.trim());return i.length!==3&&i.length!==4?null:{rgb:[i[0],i[1],i[2]],alpha:i.length===4?i[3]:null}}let t=e.indexOf("/"),n=(t===-1?e:e.slice(0,t)).trim(),r=t===-1?null:e.slice(t+1).trim(),o=n.split(/\s+/);return o.length!==3||r!==null&&r===""?null:{rgb:[o[0],o[1],o[2]],alpha:r}}function hf(e,t){if(e.endsWith("%")){let r=Number(e.slice(0,-1));return Number.isFinite(r)?Kn(r/100):null}let n=Number(e);return Number.isFinite(n)?Kn(n/t):null}function yf(e){if(e===null)return 1;if(e.endsWith("%")){let n=Number(e.slice(0,-1));return Number.isFinite(n)?Kn(n/100):1}let t=Number(e);return Number.isFinite(t)?Kn(t):1}function iW(e){let t=hi(e,"rgba")??hi(e,"rgb");if(t===null)return null;let n=mf(t);if(!n)return null;let r=hf(n.rgb[0],255),o=hf(n.rgb[1],255),i=hf(n.rgb[2],255);return r===null||o===null||i===null?null:[r,o,i,yf(n.alpha)]}function sW(e){let t=hi(e,"hsla")??hi(e,"hsl");if(t===null)return null;let n=mf(t);if(!n)return null;let r=tR(n.rgb[0]),o=Pb(n.rgb[1]),i=Pb(n.rgb[2]);if(r===null||o===null||i===null)return null;let[s,a,l]=ZA(r,o,i);return[s,a,l,yf(n.alpha)]}function aW(e){let t=hi(e,"color"),n=t?.match(/^(srgb-linear|srgb)\s+/);if(!t||!n||t.includes(","))return null;let r=mf(t.slice(n[0].length));if(!r)return null;let o=r.rgb.map(l=>hf(l,1));if(o.some(l=>l===null))return null;let[i,s,a]=n[1]==="srgb"?o:o.map(l=>xb(l));return[Kn(i),Kn(s),Kn(a),yf(r.alpha)]}function lW(e){let t=hi(e,"oklch"),n=t??hi(e,"oklab");if(n===null||n.includes(","))return null;let r=mf(n);if(!r)return null;let o=Pb(r.rgb[0]),i=Number(r.rgb[1]);if(o===null||!Number.isFinite(i))return null;let s=i,a=Number(r.rgb[2]);if(t!==null){let d=tR(r.rgb[2]);if(d===null)return null;[,s,a]=bb(o,i,d*(Math.PI/180))}else if(!Number.isFinite(a))return null;let[l,u,c]=jl(o,s,a).map(d=>Kn(xb(d)));return[l,u,c,yf(r.alpha)]}function tR(e){let t;return e.endsWith("deg")?t=Number(e.slice(0,-3)):e.endsWith("grad")?t=Number(e.slice(0,-4))*.9:e.endsWith("rad")?t=Number(e.slice(0,-3))*(180/Math.PI):e.endsWith("turn")?t=Number(e.slice(0,-4))*360:t=Number(e),Number.isFinite(t)?(t%360+360)%360:null}function Pb(e){if(e.endsWith("%")){let n=Number(e.slice(0,-1));return Number.isFinite(n)?Kn(n/100):null}let t=Number(e);return Number.isFinite(t)?Kn(t):null}function Kn(e){return e<0?0:e>1?1:e}var ff,tW,rW,pf,uW,Tb=Q(()=>{"use strict";wb();jA();ff=new Map,tW=1024;rW=1024,pf=new Map;uW=(()=>{let e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},t={transparent:[0,0,0,0]};for(let n in e){let r=e[n];t[n]=[(r>>16&255)/255,(r>>8&255)/255,(r&255)/255,1]}return t})()});function Sb(e){return[...e].sort((t,n)=>t.offset-n.offset).map(t=>({offset:t.offset,rgba:jn(t.color)}))}function kb(e,t,n="rgb"){if(e.length===0)return dW;let r=e[0],o=e[e.length-1];if(t<=r.offset)return r.rgba;if(t>=o.offset)return o.rgba;for(let i=0;i<e.length-1;i++){let s=e[i],a=e[i+1];if(t<s.offset||t>a.offset)continue;let l=a.offset-s.offset;if(l<=0)return a.rgba;let u=(t-s.offset)/l,[c,d,f,p]=QA(s.rgba,a.rgba,u,n);return[c,d,f,p]}return o.rgba}var dW,nR=Q(()=>{"use strict";Tb();wb();dW=[0,0,0,0]});var Pe=Q(()=>{"use strict";sb();HA();ab();UA();WA();zA();Tb();nR()});var AN=iG((fx,px)=>{"use strict";(function(e,t){typeof fx=="object"&&typeof px<"u"?px.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.polygonClipping=t())})(fx,(function(){"use strict";function e(O,T){var k={label:0,sent:function(){if(I[0]&1)throw I[1];return I[1]},trys:[],ops:[]},R,E,I,H;return H={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function _(U){return function(X){return V([U,X])}}function V(U){if(R)throw new TypeError("Generator is already executing.");for(;k;)try{if(R=1,E&&(I=U[0]&2?E.return:U[0]?E.throw||((I=E.return)&&I.call(E),0):E.next)&&!(I=I.call(E,U[1])).done)return I;switch(E=0,I&&(U=[U[0]&2,I.value]),U[0]){case 0:case 1:I=U;break;case 4:return k.label++,{value:U[1],done:!1};case 5:k.label++,E=U[1],U=[0];continue;case 7:U=k.ops.pop(),k.trys.pop();continue;default:if(I=k.trys,!(I=I.length>0&&I[I.length-1])&&(U[0]===6||U[0]===2)){k=0;continue}if(U[0]===3&&(!I||U[1]>I[0]&&U[1]<I[3])){k.label=U[1];break}if(U[0]===6&&k.label<I[1]){k.label=I[1],I=U;break}if(I&&k.label<I[2]){k.label=I[2],k.ops.push(U);break}I[2]&&k.ops.pop(),k.trys.pop();continue}U=T.call(O,k)}catch(X){U=[6,X],E=0}finally{R=I=0}if(U[0]&5)throw U[1];return{value:U[0]?U[1]:void 0,done:!0}}}var t=(function(){function O(T,k){this.next=null,this.key=T,this.data=k,this.left=null,this.right=null}return O})();function n(O,T){return O>T?1:O<T?-1:0}function r(O,T,k){for(var R=new t(null,null),E=R,I=R;;){var H=k(O,T.key);if(H<0){if(T.left===null)break;if(k(O,T.left.key)<0){var _=T.left;if(T.left=_.right,_.right=T,T=_,T.left===null)break}I.left=T,I=T,T=T.left}else if(H>0){if(T.right===null)break;if(k(O,T.right.key)>0){var _=T.right;if(T.right=_.left,_.left=T,T=_,T.right===null)break}E.right=T,E=T,T=T.right}else break}return E.right=T.left,I.left=T.right,T.left=R.right,T.right=R.left,T}function o(O,T,k,R){var E=new t(O,T);if(k===null)return E.left=E.right=null,E;k=r(O,k,R);var I=R(O,k.key);return I<0?(E.left=k.left,E.right=k,k.left=null):I>=0&&(E.right=k.right,E.left=k,k.right=null),E}function i(O,T,k){var R=null,E=null;if(T){T=r(O,T,k);var I=k(T.key,O);I===0?(R=T.left,E=T.right):I<0?(E=T.right,T.right=null,R=T):(R=T.left,T.left=null,E=T)}return{left:R,right:E}}function s(O,T,k){return T===null?O:(O===null||(T=r(O.key,T,k),T.left=O),T)}function a(O,T,k,R,E){if(O){R(""+T+(k?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+E(O)+`
3
- `);var I=T+(k?" ":"\u2502 ");O.left&&a(O.left,I,!1,R,E),O.right&&a(O.right,I,!0,R,E)}}var l=(function(){function O(T){T===void 0&&(T=n),this._root=null,this._size=0,this._comparator=T}return O.prototype.insert=function(T,k){return this._size++,this._root=o(T,k,this._root,this._comparator)},O.prototype.add=function(T,k){var R=new t(T,k);this._root===null&&(R.left=R.right=null,this._size++,this._root=R);var E=this._comparator,I=r(T,this._root,E),H=E(T,I.key);return H===0?this._root=I:(H<0?(R.left=I.left,R.right=I,I.left=null):H>0&&(R.right=I.right,R.left=I,I.right=null),this._size++,this._root=R),this._root},O.prototype.remove=function(T){this._root=this._remove(T,this._root,this._comparator)},O.prototype._remove=function(T,k,R){var E;if(k===null)return null;k=r(T,k,R);var I=R(T,k.key);return I===0?(k.left===null?E=k.right:(E=r(T,k.left,R),E.right=k.right),this._size--,E):k},O.prototype.pop=function(){var T=this._root;if(T){for(;T.left;)T=T.left;return this._root=r(T.key,this._root,this._comparator),this._root=this._remove(T.key,this._root,this._comparator),{key:T.key,data:T.data}}return null},O.prototype.findStatic=function(T){for(var k=this._root,R=this._comparator;k;){var E=R(T,k.key);if(E===0)return k;E<0?k=k.left:k=k.right}return null},O.prototype.find=function(T){return this._root&&(this._root=r(T,this._root,this._comparator),this._comparator(T,this._root.key)!==0)?null:this._root},O.prototype.contains=function(T){for(var k=this._root,R=this._comparator;k;){var E=R(T,k.key);if(E===0)return!0;E<0?k=k.left:k=k.right}return!1},O.prototype.forEach=function(T,k){for(var R=this._root,E=[],I=!1;!I;)R!==null?(E.push(R),R=R.left):E.length!==0?(R=E.pop(),T.call(k,R),R=R.right):I=!0;return this},O.prototype.range=function(T,k,R,E){for(var I=[],H=this._comparator,_=this._root,V;I.length!==0||_;)if(_)I.push(_),_=_.left;else{if(_=I.pop(),V=H(_.key,k),V>0)break;if(H(_.key,T)>=0&&R.call(E,_))return this;_=_.right}return this},O.prototype.keys=function(){var T=[];return this.forEach(function(k){var R=k.key;return T.push(R)}),T},O.prototype.values=function(){var T=[];return this.forEach(function(k){var R=k.data;return T.push(R)}),T},O.prototype.min=function(){return this._root?this.minNode(this._root).key:null},O.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},O.prototype.minNode=function(T){if(T===void 0&&(T=this._root),T)for(;T.left;)T=T.left;return T},O.prototype.maxNode=function(T){if(T===void 0&&(T=this._root),T)for(;T.right;)T=T.right;return T},O.prototype.at=function(T){for(var k=this._root,R=!1,E=0,I=[];!R;)if(k)I.push(k),k=k.left;else if(I.length>0){if(k=I.pop(),E===T)return k;E++,k=k.right}else R=!0;return null},O.prototype.next=function(T){var k=this._root,R=null;if(T.right){for(R=T.right;R.left;)R=R.left;return R}for(var E=this._comparator;k;){var I=E(T.key,k.key);if(I===0)break;I<0?(R=k,k=k.left):k=k.right}return R},O.prototype.prev=function(T){var k=this._root,R=null;if(T.left!==null){for(R=T.left;R.right;)R=R.right;return R}for(var E=this._comparator;k;){var I=E(T.key,k.key);if(I===0)break;I<0?k=k.left:(R=k,k=k.right)}return R},O.prototype.clear=function(){return this._root=null,this._size=0,this},O.prototype.toList=function(){return d(this._root)},O.prototype.load=function(T,k,R){k===void 0&&(k=[]),R===void 0&&(R=!1);var E=T.length,I=this._comparator;if(R&&h(T,k,0,E-1,I),this._root===null)this._root=u(T,k,0,E),this._size=E;else{var H=p(this.toList(),c(T,k),I);E=this._size+E,this._root=f({head:H},0,E)}return this},O.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(O.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),O.prototype.toString=function(T){T===void 0&&(T=function(R){return String(R.key)});var k=[];return a(this._root,"",!0,function(R){return k.push(R)},T),k.join("")},O.prototype.update=function(T,k,R){var E=this._comparator,I=i(T,this._root,E),H=I.left,_=I.right;E(T,k)<0?_=o(k,R,_,E):H=o(k,R,H,E),this._root=s(H,_,E)},O.prototype.split=function(T){return i(T,this._root,this._comparator)},O.prototype[Symbol.iterator]=function(){var T,k,R;return e(this,function(E){switch(E.label){case 0:T=this._root,k=[],R=!1,E.label=1;case 1:return R?[3,6]:T===null?[3,2]:(k.push(T),T=T.left,[3,5]);case 2:return k.length===0?[3,4]:(T=k.pop(),[4,T]);case 3:return E.sent(),T=T.right,[3,5];case 4:R=!0,E.label=5;case 5:return[3,1];case 6:return[2]}})},O})();function u(O,T,k,R){var E=R-k;if(E>0){var I=k+Math.floor(E/2),H=O[I],_=T[I],V=new t(H,_);return V.left=u(O,T,k,I),V.right=u(O,T,I+1,R),V}return null}function c(O,T){for(var k=new t(null,null),R=k,E=0;E<O.length;E++)R=R.next=new t(O[E],T[E]);return R.next=null,k.next}function d(O){for(var T=O,k=[],R=!1,E=new t(null,null),I=E;!R;)T?(k.push(T),T=T.left):k.length>0?(T=I=I.next=k.pop(),T=T.right):R=!0;return I.next=null,E.next}function f(O,T,k){var R=k-T;if(R>0){var E=T+Math.floor(R/2),I=f(O,T,E),H=O.head;return H.left=I,O.head=O.head.next,H.right=f(O,E+1,k),H}return null}function p(O,T,k){for(var R=new t(null,null),E=R,I=O,H=T;I!==null&&H!==null;)k(I.key,H.key)<0?(E.next=I,I=I.next):(E.next=H,H=H.next),E=E.next;return I!==null?E.next=I:H!==null&&(E.next=H),R.next}function h(O,T,k,R,E){if(!(k>=R)){for(var I=O[k+R>>1],H=k-1,_=R+1;;){do H++;while(E(O[H],I)<0);do _--;while(E(O[_],I)>0);if(H>=_)break;var V=O[H];O[H]=O[_],O[_]=V,V=T[H],T[H]=T[_],T[_]=V}h(O,T,k,_,E),h(O,T,_+1,R,E)}}let m=(O,T)=>O.ll.x<=T.x&&T.x<=O.ur.x&&O.ll.y<=T.y&&T.y<=O.ur.y,g=(O,T)=>{if(T.ur.x<O.ll.x||O.ur.x<T.ll.x||T.ur.y<O.ll.y||O.ur.y<T.ll.y)return null;let k=O.ll.x<T.ll.x?T.ll.x:O.ll.x,R=O.ur.x<T.ur.x?O.ur.x:T.ur.x,E=O.ll.y<T.ll.y?T.ll.y:O.ll.y,I=O.ur.y<T.ur.y?O.ur.y:T.ur.y;return{ll:{x:k,y:E},ur:{x:R,y:I}}},b=Number.EPSILON;b===void 0&&(b=Math.pow(2,-52));let x=b*b,w=(O,T)=>{if(-b<O&&O<b&&-b<T&&T<b)return 0;let k=O-T;return k*k<x*O*T?0:O<T?-1:1};class y{constructor(){this.reset()}reset(){this.xRounder=new P,this.yRounder=new P}round(T,k){return{x:this.xRounder.round(T),y:this.yRounder.round(k)}}}class P{constructor(){this.tree=new l,this.round(0)}round(T){let k=this.tree.add(T),R=this.tree.prev(k);if(R!==null&&w(k.key,R.key)===0)return this.tree.remove(T),R.key;let E=this.tree.next(k);return E!==null&&w(k.key,E.key)===0?(this.tree.remove(T),E.key):T}}let S=new y,v=11102230246251565e-32,A=134217729,N=(3+8*v)*v;function M(O,T,k,R,E){let I,H,_,V,U=T[0],X=R[0],L=0,z=0;X>U==X>-U?(I=U,U=T[++L]):(I=X,X=R[++z]);let Y=0;if(L<O&&z<k)for(X>U==X>-U?(H=U+I,_=I-(H-U),U=T[++L]):(H=X+I,_=I-(H-X),X=R[++z]),I=H,_!==0&&(E[Y++]=_);L<O&&z<k;)X>U==X>-U?(H=I+U,V=H-I,_=I-(H-V)+(U-V),U=T[++L]):(H=I+X,V=H-I,_=I-(H-V)+(X-V),X=R[++z]),I=H,_!==0&&(E[Y++]=_);for(;L<O;)H=I+U,V=H-I,_=I-(H-V)+(U-V),U=T[++L],I=H,_!==0&&(E[Y++]=_);for(;z<k;)H=I+X,V=H-I,_=I-(H-V)+(X-V),X=R[++z],I=H,_!==0&&(E[Y++]=_);return(I!==0||Y===0)&&(E[Y++]=I),Y}function C(O,T){let k=T[0];for(let R=1;R<O;R++)k+=T[R];return k}function F(O){return new Float64Array(O)}let B=(3+16*v)*v,D=(2+12*v)*v,j=(9+64*v)*v*v,W=F(4),J=F(8),se=F(12),ke=F(16),ae=F(4);function ve(O,T,k,R,E,I,H){let _,V,U,X,L,z,Y,ie,re,ge,de,Ee,ct,je,dt,ft,Jt,pt,hn=O-E,mn=k-E,yn=T-I,gn=R-I;je=hn*gn,z=A*hn,Y=z-(z-hn),ie=hn-Y,z=A*gn,re=z-(z-gn),ge=gn-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=yn*mn,z=A*yn,Y=z-(z-yn),ie=yn-Y,z=A*mn,re=z-(z-mn),ge=mn-re,Jt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Jt,L=dt-de,W[0]=dt-(de+L)+(L-Jt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,W[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,W[2]=Ee-(pt-L)+(de-L),W[3]=pt;let cr=C(4,W),el=D*H;if(cr>=el||-cr>=el||(L=O-hn,_=O-(hn+L)+(L-E),L=k-mn,U=k-(mn+L)+(L-E),L=T-yn,V=T-(yn+L)+(L-I),L=R-gn,X=R-(gn+L)+(L-I),_===0&&V===0&&U===0&&X===0)||(el=j*H+N*Math.abs(cr),cr+=hn*X+gn*_-(yn*U+mn*V),cr>=el||-cr>=el))return cr;je=_*gn,z=A*_,Y=z-(z-_),ie=_-Y,z=A*gn,re=z-(z-gn),ge=gn-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=V*mn,z=A*V,Y=z-(z-V),ie=V-Y,z=A*mn,re=z-(z-mn),ge=mn-re,Jt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Jt,L=dt-de,ae[0]=dt-(de+L)+(L-Jt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,ae[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,ae[2]=Ee-(pt-L)+(de-L),ae[3]=pt;let JH=M(4,W,4,ae,J);je=hn*X,z=A*hn,Y=z-(z-hn),ie=hn-Y,z=A*X,re=z-(z-X),ge=X-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=yn*U,z=A*yn,Y=z-(z-yn),ie=yn-Y,z=A*U,re=z-(z-U),ge=U-re,Jt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Jt,L=dt-de,ae[0]=dt-(de+L)+(L-Jt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,ae[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,ae[2]=Ee-(pt-L)+(de-L),ae[3]=pt;let QH=M(JH,J,4,ae,se);je=_*X,z=A*_,Y=z-(z-_),ie=_-Y,z=A*X,re=z-(z-X),ge=X-re,dt=ie*ge-(je-Y*re-ie*re-Y*ge),ft=V*U,z=A*V,Y=z-(z-V),ie=V-Y,z=A*U,re=z-(z-U),ge=U-re,Jt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Jt,L=dt-de,ae[0]=dt-(de+L)+(L-Jt),Ee=je+de,L=Ee-je,ct=je-(Ee-L)+(de-L),de=ct-ft,L=ct-de,ae[1]=ct-(de+L)+(L-ft),pt=Ee+de,L=pt-Ee,ae[2]=Ee-(pt-L)+(de-L),ae[3]=pt;let ZH=M(QH,se,4,ae,ke);return ke[ZH-1]}function G(O,T,k,R,E,I){let H=(T-I)*(k-E),_=(O-E)*(R-I),V=H-_,U=Math.abs(H+_);return Math.abs(V)>=B*U?V:-ve(O,T,k,R,E,I,U)}let K=(O,T)=>O.x*T.y-O.y*T.x,$=(O,T)=>O.x*T.x+O.y*T.y,ee=(O,T,k)=>{let R=G(O.x,O.y,T.x,T.y,k.x,k.y);return R>0?-1:R<0?1:0},te=O=>Math.sqrt($(O,O)),he=(O,T,k)=>{let R={x:T.x-O.x,y:T.y-O.y},E={x:k.x-O.x,y:k.y-O.y};return K(E,R)/te(E)/te(R)},be=(O,T,k)=>{let R={x:T.x-O.x,y:T.y-O.y},E={x:k.x-O.x,y:k.y-O.y};return $(E,R)/te(E)/te(R)},Fe=(O,T,k)=>T.y===0?null:{x:O.x+T.x/T.y*(k-O.y),y:k},Se=(O,T,k)=>T.x===0?null:{x:k,y:O.y+T.y/T.x*(k-O.x)},ur=(O,T,k,R)=>{if(T.x===0)return Se(k,R,O.x);if(R.x===0)return Se(O,T,k.x);if(T.y===0)return Fe(k,R,O.y);if(R.y===0)return Fe(O,T,k.y);let E=K(T,R);if(E==0)return null;let I={x:k.x-O.x,y:k.y-O.y},H=K(I,T)/E,_=K(I,R)/E,V=O.x+_*T.x,U=k.x+H*R.x,X=O.y+_*T.y,L=k.y+H*R.y,z=(V+U)/2,Y=(X+L)/2;return{x:z,y:Y}};class Le{static compare(T,k){let R=Le.comparePoints(T.point,k.point);return R!==0?R:(T.point!==k.point&&T.link(k),T.isLeft!==k.isLeft?T.isLeft?1:-1:Xt.compare(T.segment,k.segment))}static comparePoints(T,k){return T.x<k.x?-1:T.x>k.x?1:T.y<k.y?-1:T.y>k.y?1:0}constructor(T,k){T.events===void 0?T.events=[this]:T.events.push(this),this.point=T,this.isLeft=k}link(T){if(T.point===this.point)throw new Error("Tried to link already linked events");let k=T.point.events;for(let R=0,E=k.length;R<E;R++){let I=k[R];this.point.events.push(I),I.point=this.point}this.checkForConsuming()}checkForConsuming(){let T=this.point.events.length;for(let k=0;k<T;k++){let R=this.point.events[k];if(R.segment.consumedBy===void 0)for(let E=k+1;E<T;E++){let I=this.point.events[E];I.consumedBy===void 0&&R.otherSE.point.events===I.otherSE.point.events&&R.segment.consume(I.segment)}}}getAvailableLinkedEvents(){let T=[];for(let k=0,R=this.point.events.length;k<R;k++){let E=this.point.events[k];E!==this&&!E.segment.ringOut&&E.segment.isInResult()&&T.push(E)}return T}getLeftmostComparator(T){let k=new Map,R=E=>{let I=E.otherSE;k.set(E,{sine:he(this.point,T.point,I.point),cosine:be(this.point,T.point,I.point)})};return(E,I)=>{k.has(E)||R(E),k.has(I)||R(I);let{sine:H,cosine:_}=k.get(E),{sine:V,cosine:U}=k.get(I);return H>=0&&V>=0?_<U?1:_>U?-1:0:H<0&&V<0?_<U?-1:_>U?1:0:V<H?-1:V>H?1:0}}}let vt=0;class Xt{static compare(T,k){let R=T.leftSE.point.x,E=k.leftSE.point.x,I=T.rightSE.point.x,H=k.rightSE.point.x;if(H<R)return 1;if(I<E)return-1;let _=T.leftSE.point.y,V=k.leftSE.point.y,U=T.rightSE.point.y,X=k.rightSE.point.y;if(R<E){if(V<_&&V<U)return 1;if(V>_&&V>U)return-1;let L=T.comparePoint(k.leftSE.point);if(L<0)return 1;if(L>0)return-1;let z=k.comparePoint(T.rightSE.point);return z!==0?z:-1}if(R>E){if(_<V&&_<X)return-1;if(_>V&&_>X)return 1;let L=k.comparePoint(T.leftSE.point);if(L!==0)return L;let z=T.comparePoint(k.rightSE.point);return z<0?1:z>0?-1:1}if(_<V)return-1;if(_>V)return 1;if(I<H){let L=k.comparePoint(T.rightSE.point);if(L!==0)return L}if(I>H){let L=T.comparePoint(k.rightSE.point);if(L<0)return 1;if(L>0)return-1}if(I!==H){let L=U-_,z=I-R,Y=X-V,ie=H-E;if(L>z&&Y<ie)return 1;if(L<z&&Y>ie)return-1}return I>H?1:I<H||U<X?-1:U>X?1:T.id<k.id?-1:T.id>k.id?1:0}constructor(T,k,R,E){this.id=++vt,this.leftSE=T,T.segment=this,T.otherSE=k,this.rightSE=k,k.segment=this,k.otherSE=T,this.rings=R,this.windings=E}static fromRing(T,k,R){let E,I,H,_=Le.comparePoints(T,k);if(_<0)E=T,I=k,H=1;else if(_>0)E=k,I=T,H=-1;else throw new Error(`Tried to create degenerate segment at [${T.x}, ${T.y}]`);let V=new Le(E,!0),U=new Le(I,!1);return new Xt(V,U,[R],[H])}replaceRightSE(T){this.rightSE=T,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let T=this.leftSE.point.y,k=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:T<k?T:k},ur:{x:this.rightSE.point.x,y:T>k?T:k}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(T){return T.x===this.leftSE.point.x&&T.y===this.leftSE.point.y||T.x===this.rightSE.point.x&&T.y===this.rightSE.point.y}comparePoint(T){if(this.isAnEndpoint(T))return 0;let k=this.leftSE.point,R=this.rightSE.point,E=this.vector();if(k.x===R.x)return T.x===k.x?0:T.x<k.x?1:-1;let I=(T.y-k.y)/E.y,H=k.x+I*E.x;if(T.x===H)return 0;let _=(T.x-k.x)/E.x,V=k.y+_*E.y;return T.y===V?0:T.y<V?-1:1}getIntersection(T){let k=this.bbox(),R=T.bbox(),E=g(k,R);if(E===null)return null;let I=this.leftSE.point,H=this.rightSE.point,_=T.leftSE.point,V=T.rightSE.point,U=m(k,_)&&this.comparePoint(_)===0,X=m(R,I)&&T.comparePoint(I)===0,L=m(k,V)&&this.comparePoint(V)===0,z=m(R,H)&&T.comparePoint(H)===0;if(X&&U)return z&&!L?H:!z&&L?V:null;if(X)return L&&I.x===V.x&&I.y===V.y?null:I;if(U)return z&&H.x===_.x&&H.y===_.y?null:_;if(z&&L)return null;if(z)return H;if(L)return V;let Y=ur(I,this.vector(),_,T.vector());return Y===null||!m(E,Y)?null:S.round(Y.x,Y.y)}split(T){let k=[],R=T.events!==void 0,E=new Le(T,!0),I=new Le(T,!1),H=this.rightSE;this.replaceRightSE(I),k.push(I),k.push(E);let _=new Xt(E,H,this.rings.slice(),this.windings.slice());return Le.comparePoints(_.leftSE.point,_.rightSE.point)>0&&_.swapEvents(),Le.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),R&&(E.checkForConsuming(),I.checkForConsuming()),k}swapEvents(){let T=this.rightSE;this.rightSE=this.leftSE,this.leftSE=T,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let k=0,R=this.windings.length;k<R;k++)this.windings[k]*=-1}consume(T){let k=this,R=T;for(;k.consumedBy;)k=k.consumedBy;for(;R.consumedBy;)R=R.consumedBy;let E=Xt.compare(k,R);if(E!==0){if(E>0){let I=k;k=R,R=I}if(k.prev===R){let I=k;k=R,R=I}for(let I=0,H=R.rings.length;I<H;I++){let _=R.rings[I],V=R.windings[I],U=k.rings.indexOf(_);U===-1?(k.rings.push(_),k.windings.push(V)):k.windings[U]+=V}R.rings=null,R.windings=null,R.consumedBy=k,R.leftSE.consumedBy=k.leftSE,R.rightSE.consumedBy=k.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{let T=this.prev.consumedBy||this.prev;this._beforeState=T.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;let T=this.beforeState();this._afterState={rings:T.rings.slice(0),windings:T.windings.slice(0),multiPolys:[]};let k=this._afterState.rings,R=this._afterState.windings,E=this._afterState.multiPolys;for(let _=0,V=this.rings.length;_<V;_++){let U=this.rings[_],X=this.windings[_],L=k.indexOf(U);L===-1?(k.push(U),R.push(X)):R[L]+=X}let I=[],H=[];for(let _=0,V=k.length;_<V;_++){if(R[_]===0)continue;let U=k[_],X=U.poly;if(H.indexOf(X)===-1)if(U.isExterior)I.push(X);else{H.indexOf(X)===-1&&H.push(X);let L=I.indexOf(U.poly);L!==-1&&I.splice(L,1)}}for(let _=0,V=I.length;_<V;_++){let U=I[_].multiPoly;E.indexOf(U)===-1&&E.push(U)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;let T=this.beforeState().multiPolys,k=this.afterState().multiPolys;switch(pn.type){case"union":{let R=T.length===0,E=k.length===0;this._isInResult=R!==E;break}case"intersection":{let R,E;T.length<k.length?(R=T.length,E=k.length):(R=k.length,E=T.length),this._isInResult=E===pn.numMultiPolys&&R<E;break}case"xor":{let R=Math.abs(T.length-k.length);this._isInResult=R%2===1;break}case"difference":{let R=E=>E.length===1&&E[0].isSubject;this._isInResult=R(T)!==R(k);break}default:throw new Error(`Unrecognized operation type found ${pn.type}`)}return this._isInResult}}class Vc{constructor(T,k,R){if(!Array.isArray(T)||T.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=k,this.isExterior=R,this.segments=[],typeof T[0][0]!="number"||typeof T[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let E=S.round(T[0][0],T[0][1]);this.bbox={ll:{x:E.x,y:E.y},ur:{x:E.x,y:E.y}};let I=E;for(let H=1,_=T.length;H<_;H++){if(typeof T[H][0]!="number"||typeof T[H][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let V=S.round(T[H][0],T[H][1]);V.x===I.x&&V.y===I.y||(this.segments.push(Xt.fromRing(I,V,this)),V.x<this.bbox.ll.x&&(this.bbox.ll.x=V.x),V.y<this.bbox.ll.y&&(this.bbox.ll.y=V.y),V.x>this.bbox.ur.x&&(this.bbox.ur.x=V.x),V.y>this.bbox.ur.y&&(this.bbox.ur.y=V.y),I=V)}(E.x!==I.x||E.y!==I.y)&&this.segments.push(Xt.fromRing(I,E,this))}getSweepEvents(){let T=[];for(let k=0,R=this.segments.length;k<R;k++){let E=this.segments[k];T.push(E.leftSE),T.push(E.rightSE)}return T}}class dy{constructor(T,k){if(!Array.isArray(T))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new Vc(T[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let R=1,E=T.length;R<E;R++){let I=new Vc(T[R],this,!1);I.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=I.bbox.ll.x),I.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=I.bbox.ll.y),I.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=I.bbox.ur.x),I.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=I.bbox.ur.y),this.interiorRings.push(I)}this.multiPoly=k}getSweepEvents(){let T=this.exteriorRing.getSweepEvents();for(let k=0,R=this.interiorRings.length;k<R;k++){let E=this.interiorRings[k].getSweepEvents();for(let I=0,H=E.length;I<H;I++)T.push(E[I])}return T}}class zc{constructor(T,k){if(!Array.isArray(T))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof T[0][0][0]=="number"&&(T=[T])}catch{}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let R=0,E=T.length;R<E;R++){let I=new dy(T[R],this);I.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=I.bbox.ll.x),I.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=I.bbox.ll.y),I.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=I.bbox.ur.x),I.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=I.bbox.ur.y),this.polys.push(I)}this.isSubject=k}getSweepEvents(){let T=[];for(let k=0,R=this.polys.length;k<R;k++){let E=this.polys[k].getSweepEvents();for(let I=0,H=E.length;I<H;I++)T.push(E[I])}return T}}class Kc{static factory(T){let k=[];for(let R=0,E=T.length;R<E;R++){let I=T[R];if(!I.isInResult()||I.ringOut)continue;let H=null,_=I.leftSE,V=I.rightSE,U=[_],X=_.point,L=[];for(;H=_,_=V,U.push(_),_.point!==X;)for(;;){let z=_.getAvailableLinkedEvents();if(z.length===0){let re=U[0].point,ge=U[U.length-1].point;throw new Error(`Unable to complete output ring starting at [${re.x}, ${re.y}]. Last matching segment found ends at [${ge.x}, ${ge.y}].`)}if(z.length===1){V=z[0].otherSE;break}let Y=null;for(let re=0,ge=L.length;re<ge;re++)if(L[re].point===_.point){Y=re;break}if(Y!==null){let re=L.splice(Y)[0],ge=U.splice(re.index);ge.unshift(ge[0].otherSE),k.push(new Kc(ge.reverse()));continue}L.push({index:U.length,point:_.point});let ie=_.getLeftmostComparator(H);V=z.sort(ie)[0].otherSE;break}k.push(new Kc(U))}return k}constructor(T){this.events=T;for(let k=0,R=T.length;k<R;k++)T[k].segment.ringOut=this;this.poly=null}getGeom(){let T=this.events[0].point,k=[T];for(let U=1,X=this.events.length-1;U<X;U++){let L=this.events[U].point,z=this.events[U+1].point;ee(L,T,z)!==0&&(k.push(L),T=L)}if(k.length===1)return null;let R=k[0],E=k[1];ee(R,T,E)===0&&k.shift(),k.push(k[0]);let I=this.isExteriorRing()?1:-1,H=this.isExteriorRing()?0:k.length-1,_=this.isExteriorRing()?k.length:-1,V=[];for(let U=H;U!=_;U+=I)V.push([k[U].x,k[U].y]);return V}isExteriorRing(){if(this._isExteriorRing===void 0){let T=this.enclosingRing();this._isExteriorRing=T?!T.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let T=this.events[0];for(let E=1,I=this.events.length;E<I;E++){let H=this.events[E];Le.compare(T,H)>0&&(T=H)}let k=T.segment.prevInResult(),R=k?k.prevInResult():null;for(;;){if(!k)return null;if(!R)return k.ringOut;if(R.ringOut!==k.ringOut)return R.ringOut.enclosingRing()!==k.ringOut?k.ringOut:k.ringOut.enclosingRing();k=R.prevInResult(),R=k?k.prevInResult():null}}}class F1{constructor(T){this.exteriorRing=T,T.poly=this,this.interiorRings=[]}addInterior(T){this.interiorRings.push(T),T.poly=this}getGeom(){let T=[this.exteriorRing.getGeom()];if(T[0]===null)return null;for(let k=0,R=this.interiorRings.length;k<R;k++){let E=this.interiorRings[k].getGeom();E!==null&&T.push(E)}return T}}class jH{constructor(T){this.rings=T,this.polys=this._composePolys(T)}getGeom(){let T=[];for(let k=0,R=this.polys.length;k<R;k++){let E=this.polys[k].getGeom();E!==null&&T.push(E)}return T}_composePolys(T){let k=[];for(let R=0,E=T.length;R<E;R++){let I=T[R];if(!I.poly)if(I.isExteriorRing())k.push(new F1(I));else{let H=I.enclosingRing();H.poly||k.push(new F1(H)),H.poly.addInterior(I)}}return k}}class $H{constructor(T){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Xt.compare;this.queue=T,this.tree=new l(k),this.segments=[]}process(T){let k=T.segment,R=[];if(T.consumedBy)return T.isLeft?this.queue.remove(T.otherSE):this.tree.remove(k),R;let E=T.isLeft?this.tree.add(k):this.tree.find(k);if(!E)throw new Error(`Unable to find segment #${k.id} [${k.leftSE.point.x}, ${k.leftSE.point.y}] -> [${k.rightSE.point.x}, ${k.rightSE.point.y}] in SweepLine tree.`);let I=E,H=E,_,V;for(;_===void 0;)I=this.tree.prev(I),I===null?_=null:I.key.consumedBy===void 0&&(_=I.key);for(;V===void 0;)H=this.tree.next(H),H===null?V=null:H.key.consumedBy===void 0&&(V=H.key);if(T.isLeft){let U=null;if(_){let L=_.getIntersection(k);if(L!==null&&(k.isAnEndpoint(L)||(U=L),!_.isAnEndpoint(L))){let z=this._splitSafely(_,L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}}let X=null;if(V){let L=V.getIntersection(k);if(L!==null&&(k.isAnEndpoint(L)||(X=L),!V.isAnEndpoint(L))){let z=this._splitSafely(V,L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}}if(U!==null||X!==null){let L=null;U===null?L=X:X===null?L=U:L=Le.comparePoints(U,X)<=0?U:X,this.queue.remove(k.rightSE),R.push(k.rightSE);let z=k.split(L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}R.length>0?(this.tree.remove(k),R.push(T)):(this.segments.push(k),k.prev=_)}else{if(_&&V){let U=_.getIntersection(V);if(U!==null){if(!_.isAnEndpoint(U)){let X=this._splitSafely(_,U);for(let L=0,z=X.length;L<z;L++)R.push(X[L])}if(!V.isAnEndpoint(U)){let X=this._splitSafely(V,U);for(let L=0,z=X.length;L<z;L++)R.push(X[L])}}}this.tree.remove(k)}return R}_splitSafely(T,k){this.tree.remove(T);let R=T.rightSE;this.queue.remove(R);let E=T.split(k);return E.push(R),T.consumedBy===void 0&&this.tree.add(T),E}}let L1=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,YH=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class qH{run(T,k,R){pn.type=T,S.reset();let E=[new zc(k,!0)];for(let L=0,z=R.length;L<z;L++)E.push(new zc(R[L],!1));if(pn.numMultiPolys=E.length,pn.type==="difference"){let L=E[0],z=1;for(;z<E.length;)g(E[z].bbox,L.bbox)!==null?z++:E.splice(z,1)}if(pn.type==="intersection")for(let L=0,z=E.length;L<z;L++){let Y=E[L];for(let ie=L+1,re=E.length;ie<re;ie++)if(g(Y.bbox,E[ie].bbox)===null)return[]}let I=new l(Le.compare);for(let L=0,z=E.length;L<z;L++){let Y=E[L].getSweepEvents();for(let ie=0,re=Y.length;ie<re;ie++)if(I.insert(Y[ie]),I.size>L1)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}let H=new $H(I),_=I.size,V=I.pop();for(;V;){let L=V.key;if(I.size===_){let Y=L.segment;throw new Error(`Unable to pop() ${L.isLeft?"left":"right"} SweepEvent [${L.point.x}, ${L.point.y}] from segment #${Y.id} [${Y.leftSE.point.x}, ${Y.leftSE.point.y}] -> [${Y.rightSE.point.x}, ${Y.rightSE.point.y}] from queue.`)}if(I.size>L1)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(H.segments.length>YH)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");let z=H.process(L);for(let Y=0,ie=z.length;Y<ie;Y++){let re=z[Y];re.consumedBy===void 0&&I.insert(re)}_=I.size,V=I.pop()}S.reset();let U=Kc.factory(H.segments);return new jH(U).getGeom()}}let pn=new qH;var XH={union:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("union",O,k)},intersection:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("intersection",O,k)},xor:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("xor",O,k)},difference:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("difference",O,k)}};return XH}))});function tl(){let e=[];return{onRelease(t){e?e.push(t):t()},release(){let t=e;e=null;for(let n of t??[])n()}}}var jc=class extends Error{constructor(n,r){super(`shader ${n} failure: ${r}`);this.stage=n;this.log=r;this.name="ShaderCompileError"}stage;log},$c=0,Jr=class{constructor(t,n,r){this.gl=t;let o=this.compile(t.VERTEX_SHADER,n,"vertex"),i;try{i=this.compile(t.FRAGMENT_SHADER,r,"fragment")}catch(a){throw t.deleteShader(o),a}let s=t.createProgram();if(!s)throw t.deleteShader(o),t.deleteShader(i),new Error("createProgram returned null");if(t.attachShader(s,o),t.attachShader(s,i),t.bindAttribLocation(s,$c,"a_position"),t.linkProgram(s),t.deleteShader(o),t.deleteShader(i),!t.getProgramParameter(s,t.LINK_STATUS)){let a=t.getProgramInfoLog(s)??"";throw t.deleteProgram(s),new jc("link",a)}this.handle=s}gl;handle;uniforms=new Map;arrays=new Map;attributes=new Map;compile(t,n,r){let o=this.gl,i=o.createShader(t);if(!i)throw new Error("createShader returned null");if(o.shaderSource(i,n),o.compileShader(i),!o.getShaderParameter(i,o.COMPILE_STATUS)){let s=o.getShaderInfoLog(i)??"";throw o.deleteShader(i),new jc(r,s)}return i}lookupUniforms(t){for(let n of t){let r=this.gl.getUniformLocation(this.handle,n);r!==null&&this.uniforms.set(n,r)}}lookupUniformArrays(t){for(let[n,{type:r,size:o}]of t){let i=`${n}[0]`,s=this.uniforms.get(i)??this.gl.getUniformLocation(this.handle,i);s!==null&&this.arrays.set(n,{type:r,size:o,location:s})}}lookupAttributes(t){for(let n of t){let r=this.gl.getAttribLocation(this.handle,n);r>=0&&this.attributes.set(n,r)}}uniform(t){return this.uniforms.get(t)}uniformArray(t){return this.arrays.get(t)}attribute(t){return this.attributes.get(t)}};var _1=`#version 300 es
1
+ "use strict";(()=>{var dG=Object.create;var Oy=Object.defineProperty;var fG=Object.getOwnPropertyDescriptor;var pG=Object.getOwnPropertyNames;var hG=Object.getPrototypeOf,mG=Object.prototype.hasOwnProperty;var J=(e,t)=>()=>(e&&(t=e(e=0)),t);var yG=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),gG=(e,t)=>{for(var n in t)Oy(e,n,{get:t[n],enumerable:!0})},bG=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of pG(t))!mG.call(e,o)&&o!==n&&Oy(e,o,{get:()=>t[o],enumerable:!(r=fG(t,o))||r.enumerable});return e};var xG=(e,t,n)=>(n=e!=null?dG(hG(e)):{},bG(t||!e||!e.__esModule?Oy(n,"default",{value:e,enumerable:!0}):n,e));function ys(e){return e<0?0:e>1?1:e}function pr(e,t,n){return e+(t-e)*n}function gs(e){return e>0?1:e<0?-1:0}var kl=J(()=>{"use strict"});var eee,Un,sU,hg=J(()=>{"use strict";eee=Math.PI*2,Un=Math.PI/180,sU=180/Math.PI});function Fd(e,t){return[1,0,0,1,e,t]}function vl(e){let t=Math.cos(e),n=Math.sin(e);return[t,n,-n,t,0,0]}function ht(e,t){return[e[0]*t[0]+e[2]*t[1],e[1]*t[0]+e[3]*t[1],e[0]*t[2]+e[2]*t[3],e[1]*t[2]+e[3]*t[3],e[0]*t[4]+e[2]*t[5]+e[4],e[1]*t[4]+e[3]*t[5]+e[5]]}function hr(e){let t=e[0]*e[3]-e[1]*e[2],n=Math.max(e[0]*e[0]+e[1]*e[1],e[2]*e[2]+e[3]*e[3]);if(!(Math.abs(t)>1e-12*n))return null;let r=1/t,o=e[3]*r,i=-e[1]*r,s=-e[2]*r,a=e[0]*r;return[o,i,s,a,-(e[4]*o+e[5]*s),-(e[4]*i+e[5]*a)]}function wn(e,t,n){return[e[0]*t+e[2]*n+e[4],e[1]*t+e[3]*n+e[5]]}function mr(e,t,n,r,o,i,s,a){let l=n===0?1:s/n,u=r===0?1:a/r;return[l,0,0,u,o-e*l,i-t*u]}function ao(e,t,n){return ht(Fd(e,t),ht(vl(n),Fd(-e,-t)))}function mg(e,t){let n=new Float64Array(e.length),r=t[0],o=t[1],i=t[2],s=t[3],a=t[4],l=t[5];for(let u=0;u+1<e.length;u+=2){let c=e[u],d=e[u+1];n[u]=r*c+i*d+a,n[u+1]=o*c+s*d+l}return n}var bs=J(()=>{"use strict"});function Ld(e,t){return t[0]>=e[0]&&t[1]>=e[1]&&t[2]<=e[2]&&t[3]<=e[3]}function Al(e,t,n,r){return Float64Array.of(e,t,e+n,t,e+n,t+r,e,t+r)}function yg(e,t){return e[0]<=t[2]&&t[0]<=e[2]&&e[1]<=t[3]&&t[1]<=e[3]}var Rl=J(()=>{"use strict"});function aU(){let e=[];for(let{code:t,coords:n}of Object.values(ii))e[t]=n;return e}function lo(e){return Rk[e]}function Oe(e,t,n){let r=0,o=0,i=0,s=0,a=0,l=!1;for(let u=0;u<e.length;u++){let c=e[u],d=!l&&c!==se&&c!==fe;if(d&&(s=o,a=i),l=c!==fe,n(c,r,o,i,u,d)===!1)return;let f=lo(c);if(f===void 0)throw new Error(`forEachSegment: unknown command code ${c}`);f>0?(o=t[r+f-2],i=t[r+f-1],r+=f,c===se&&(s=o,a=i)):c===fe&&(o=s,i=a)}}var ii,se,ae,be,we,fe,Rk,Ye=J(()=>{"use strict";ii={M:{code:0,coords:2},L:{code:1,coords:2},C:{code:2,coords:6},Q:{code:3,coords:4},Z:{code:4,coords:0}},se=ii.M.code,ae=ii.L.code,be=ii.C.code,we=ii.Q.code,fe=ii.Z.code,Rk=aU()});function Ve(e,t,n,r,o,i,s,a,l){let u=1-l,c=u*u*u,d=3*u*u*l,f=3*u*l*l,p=l*l*l;return[c*e+d*n+f*o+p*s,c*t+d*r+f*i+p*a]}function uo(e,t,n,r,o,i){return[e+2/3*(n-e),t+2/3*(r-t),o+2/3*(n-o),i+2/3*(r-i)]}function Nk(e,t,n,r){let o=-e+3*t-3*n+r,i=2*(e-2*t+n),s=-e+t,a=[],l=u=>{u>0&&u<1&&a.push(u)};if(Math.abs(o)<1e-12)Math.abs(i)>1e-12&&l(-s/i);else{let u=i*i-4*o*s;if(u>=0){let c=Math.sqrt(u);l((-i+c)/(2*o)),l((-i-c)/(2*o))}}return a}function gg(e,t,n,r,o,i,s,a){let l=Math.min(e,s),u=Math.max(e,s),c=Math.min(t,a),d=Math.max(t,a);for(let f of Nk(e,n,o,s)){let[p]=Ve(e,t,n,r,o,i,s,a,f);p<l&&(l=p),p>u&&(u=p)}for(let f of Nk(t,r,i,a)){let[,p]=Ve(e,t,n,r,o,i,s,a,f);p<c&&(c=p),p>d&&(d=p)}return[l,c,u,d]}function co(e,t,n,r,o,i,s,a,l){let u=e+(n-e)*l,c=t+(r-t)*l,d=n+(o-n)*l,f=r+(i-r)*l,p=o+(s-o)*l,h=i+(a-i)*l,m=u+(d-u)*l,y=c+(f-c)*l,b=d+(p-d)*l,x=f+(h-f)*l,w=m+(b-m)*l,g=y+(x-y)*l;return[[e,t,u,c,m,y,w,g],[w,g,b,x,p,h,s,a]]}function Ik(e,t,n,r,o,i,s){let a=e+(n-e)*s,l=t+(r-t)*s,u=n+(o-n)*s,c=r+(i-r)*s,d=a+(u-a)*s,f=l+(c-l)*s;return[[e,t,a,l,d,f],[d,f,u,c,o,i]]}var Pn=J(()=>{"use strict"});function Ek(e,t){if(!(t>0))return 0;let n=e/t;return n<0?0:n>1?1:n}var Mk=J(()=>{"use strict"});function lU(e,t){let n=e.x-t.x,r=e.y-t.y;return n*n+r*r}function Gt(e,t){return Math.sqrt(lU(e,t))}function si(e,t,n){return{x:pr(e.x,t.x,n),y:pr(e.y,t.y,n)}}function bg(e,t,n,r,o,i){let s=o-n,a=i-r;return Ek((e-n)*s+(t-r)*a,s*s+a*a)}function uU(e,t,n,r,o,i){let s=bg(e,t,n,r,o,i),a=e-(s===1?o:pr(n,o,s)),l=t-(s===1?i:pr(r,i,s));return a*a+l*l}function Tn(e,t,n,r,o,i){return Math.sqrt(uU(e,t,n,r,o,i))}var ai=J(()=>{"use strict";Mk();kl()});function Nl(e,t,n,r,o,i){let s=bg(e,t,n,r,o,i),a=s===1?o:pr(n,o,s),l=s===1?i:pr(r,i,s);return{x:a,y:l,t:s,dist:Math.sqrt((e-a)*(e-a)+(t-l)*(t-l))}}function li(e,t,n,r,o,i,s,a,l,u){let c=-n+3*o-3*s+l,d=-r+3*i-3*a+u,f=3*n-6*o+3*s,p=3*r-6*i+3*a,h=3*(o-n),m=3*(i-r),y=S=>{let[v,A]=Ve(n,r,o,i,s,a,l,u,S);return(v-e)**2+(A-t)**2},b=[];for(let S=0;S<=fo;S++)b.push(y(S/fo));let x=0,w=b[0];for(let S=0;S<=fo;S++){let v=b[S],A=S>0?b[S-1]:1/0,N=S<fo?b[S+1]:1/0;if(!(v<=A&&v<=N))continue;let M=Math.max(0,(S-1)/fo),C=Math.min(1,(S+1)/fo),F=S/fo;for(let W=0;W<cU;W++){let Q=F*F,le=c*Q*F+f*Q+h*F+n-e,ke=d*Q*F+p*Q+m*F+r-t,ue=3*c*Q+2*f*F+h,ve=3*d*Q+2*p*F+m,G=6*c*F+2*f,j=6*d*F+2*p,$=le*ue+ke*ve,ee=ue*ue+ve*ve+le*G+ke*j;if($>0)C=F;else if($<0)M=F;else break;let te=ee>0?F-$/ee:NaN;te>M&&te<C||(te=(M+C)/2);let he=Math.abs(te-F);if(F=te,he<Ck||C-M<Ck)break}let D=y(F),[B,K]=D<=v?[F,D]:[S/fo,v];K<w&&(w=K,x=B)}let[g,P]=Ve(n,r,o,i,s,a,l,u,x);return{x:g,y:P,t:x,dist:Math.hypot(g-e,P-t)}}function Ok(e,t,n,r,o,i,s,a){let[l,u,c,d]=uo(n,r,o,i,s,a);return li(e,t,n,r,l,u,c,d,s,a)}var fo,cU,Ck,_d=J(()=>{"use strict";Pn();ai();kl();fo=32,cU=40,Ck=1e-14});function Il(e,t,n){let r=e.length/t-1,o=1-n,i=0;for(let s=0;s<t;s++){let a=e[t+s]-e[s],l=r===1?a:r===2?2*(o*a+n*(e[2*t+s]-e[t+s])):3*(o*o*a+2*o*n*(e[2*t+s]-e[t+s])+n*n*(e[3*t+s]-e[2*t+s]));i+=l*l}return Math.sqrt(i)}function Dd(e,t,n,r,o,i){let s=(n+r)/2,a=(r-n)/2,l=0;for(let u=0;u<o.length;u++)l+=i[u]*Il(e,t,s+o[u]*a);return l*a}function Tg(e,t,n,r,o,i,s){let a=(n+r)/2,l=Dd(e,t,n,a,wg,Pg),u=Dd(e,t,a,r,wg,Pg);return s>=20||!(Math.abs(l+u-o)>i)?l+u:Tg(e,t,n,a,l,i,s+1)+Tg(e,t,a,r,u,i,s+1)}function Sg(e,t){let n=0;for(let r=t;r<e.length;r+=t){let o=0;for(let i=0;i<t;i++)o+=(e[r+i]-e[r-t+i])**2;n+=Math.sqrt(o)}return n}function Fk(e){for(let t=0;t<e.length;t++)if(!Number.isFinite(e[t]))return!1;return!0}function gU(e,t,n,r){let o=e.length/t-1,i=[],s=a=>{a>n&&a<r&&i.push(a)};for(let a=0;a<t;a++){let l=e[t+a]-e[a],u=e[2*t+a]-e[t+a];if(o===2){l!==u&&s(l/(l-u));continue}let c=e[3*t+a]-e[2*t+a],d=l-2*u+c,f=2*(u-l),p=l;if(Math.abs(d)<=1e-12*(Math.abs(f)+Math.abs(p))){f!==0&&s(-p/f);continue}let h=f*f-4*d*p;if(h<0)continue;let m=-(f+Math.sign(f||1)*Math.sqrt(h))/2;s(m/d),m!==0&&s(p/m)}return i.sort((a,l)=>a-l),i.filter((a,l)=>l===0||a!==i[l-1])}function xg(e,t,n,r,o,i){if(!(r>n))return 0;let s=Dd(e,t,n,r,wg,Pg);return!i&&!(Math.abs(s-Dd(e,t,n,r,dU,fU))>pU*o)?s:Tg(e,t,n,r,s,yU*o,0)}function po(e,t,n=0,r=1){if(!Fk(e))return NaN;if(e.length===2*t)return Il(e,t,0)*(r-n);let o=Sg(e,t);return Bd(e,t,n,r,o,kg(e,t))}function bU(e,t,n){let r=e.length/t-1,o=0;for(let i=0;i<t;i++){let s=e[2*t+i]-2*e[t+i]+e[i],a=r===2?2*s:6*((1-n)*s+n*(e[3*t+i]-2*e[2*t+i]+e[t+i]));o+=a*a}return Math.sqrt(o)}function kg(e,t){return gU(e,t,0,1).map(n=>{let r=bU(e,t,n);return{t:n,width:r>0?Il(e,t,n)/r:1/0}})}function xU(e,t){let n=[];for(let r of e)r.width<hU*t&&n.push(r.t);return n}function Bd(e,t,n,r,o,i,s=8){let a=(r-n)/s,l=s-1,u=0,c=xU(i,a);if(c.length===0){for(let p=0;p<s;p++)u+=xg(e,t,n+p*a,p===l?r:n+(p+1)*a,o,!1);return u}let d=p=>c.some(h=>Math.abs(h-p)<=mU*a),f=0;for(;f<c.length&&c[f]<=n;)f++;for(let p=0;p<s;p++){let h=n+p*a,m=p===l?r:h+a,y=h;for(;f<c.length&&c[f]<m;)u+=xg(e,t,y,c[f],o,!0),y=c[f++];u+=xg(e,t,y,m,o,d(y)||d(m))}return u}function Lk(e,t,n,r=po(e,t)){if(n<=0||!(r>0)||!Number.isFinite(r))return 0;if(n>=r)return 1;if(e.length===2*t)return n/r;let o=Sg(e,t),i=kg(e,t),s=0,a=1,l=n/r;for(let u=0;u<30;u++){let c=Bd(e,t,0,l,o,i)-n;if(Math.abs(c)<1e-10*r)break;c>0?a=l:s=l;let d=Il(e,t,l),f=d>0?l-c/d:NaN;f>s&&f<a||(f=(s+a)/2),l=f}return l}function _k(e,t){let n=Sg(e,t),r=Fk(e)?kg(e,t):[],o=new Float64Array(yr+1);for(let i=0;i<yr;i++)o[i+1]=o[i]+Bd(e,t,i/yr,(i+1)/yr,n,r,1);return{s:o,size:n,dips:r}}function Dk(e,t,n,r){let{s:o}=n,i=o[yr];if(r<=0||!(i>0)||!Number.isFinite(i))return 0;if(r>=i)return 1;let s=0,a=yr-1;for(;s<a;){let p=s+a+1>>1;o[p]<=r?s=p:a=p-1}let l=s/yr,u=l,c=(s+1)/yr,d=o[s+1]-o[s],f=d>0?l+(r-o[s])/d/yr:l;for(let p=0;p<30;p++){let h=o[s]+Bd(e,t,l,f,n.size,n.dips,1)-r;if(Math.abs(h)<1e-10*i)break;h>0?c=f:u=f;let m=Il(e,t,f),y=m>0?f-h/m:NaN;y>u&&y<c||(y=(u+c)/2),f=y}return f}var wg,Pg,dU,fU,pU,hU,mU,yU,yr,El=J(()=>{"use strict";wg=[-.9602898564975363,-.7966664774136267,-.525532409916329,-.1834346424956498,.1834346424956498,.525532409916329,.7966664774136267,.9602898564975363],Pg=[.1012285362903763,.2223810344533745,.3137066458778873,.362683783378362,.362683783378362,.3137066458778873,.2223810344533745,.1012285362903763],dU=[-.8611363115940526,-.3399810435848563,.3399810435848563,.8611363115940526],fU=[.3478548451374538,.6521451548625461,.6521451548625461,.3478548451374538],pU=1e-9,hU=1,mU=.05,yU=1e-13;yr=16});function Bk(e,t,n){let r=e.length/t-1,o=1-n,i=r===1?[o,n]:r===2?[o*o,2*o*n,n*n]:[o*o*o,3*o*o*n,3*o*n*n,n*n*n],s=[0,0,0];for(let a=0;a<t;a++){let l=0;for(let u=0;u<=r;u++)l+=i[u]*e[u*t+a];s[a]=l}return s}function Ml(e,t,n,r){let o=Math.floor(e.length/n),i=r*n,s=(r+1)%o*n,a=[];for(let l=0;l<n;l++)a.push(e[i+l]);if(t)for(let l=0;l<t.length;l++)a.push(t[l]);for(let l=0;l<n;l++)a.push(e[s+l]);return a}var vg=J(()=>{"use strict"});function Gd(e,t,n){let r=new Float64Array(e.length+1),o=[],i=0;e.forEach((l,u)=>{let c=wU(l,t,i);o.push(c),i=c[c.length-1],r[u+1]=i});let s=PU(e,t,o,n??null),a={dim:t,runs:e,total:i,runStart:r,segments:s.segments};return a[Hk]={cum:o,...s,arcs:e.map(()=>[])},a}function Gk(e,t,n){let r=e.runs[t].controls?.[n];if(!r||r.length===0)return null;let o=Cl(e).arcs[t],i=o[n];if(!i){let s=Ml(e.runs[t].points,r,e.dim,n);o[n]=i={coords:s,lookup:_k(s,e.dim)}}return i}function Cl(e){let t=e[Hk];if(!t)throw new Error("LengthTable: not built by lengthTable(); build one with it rather than by hand");return t}function Ud(e,t){if(Number.isNaN(t))return NaN;let{bpAnchor:n,bpLength:r}=Cl(e),o=n.length;if(o===0)return 0;if(t<=n[0])return r[0];if(t>=n[o-1])return r[o-1];let i=0,s=o-1;for(;s-i>1;){let u=i+s>>1;n[u]<=t?i=u:s=u}let a=n[s]-n[i],l=a>0?(t-n[i])/a:1;return r[i]+l*(r[s]-r[i])}function Ag(e,t){if(Number.isNaN(t))return NaN;let n=e.runs.length,r=Math.min(Math.max(t,0),n),o=Math.floor(r);return o>=n?e.total:e.runStart[o]+(r-o)*(e.runStart[o+1]-e.runStart[o])}function Rg(e,t){if(Number.isNaN(t))return NaN;let n=Math.min(Math.max(t,0),1);if(e.segments<=0)return n*e.total;let{runAnchor:r}=Cl(e),o=n*e.segments;for(let i=0;i<r.length/2;i++){let s=r[i*2],a=r[i*2+1]-s;if(a>0&&o<=a)return Ud(e,s+o);o-=Math.max(a,0)}return e.total}function wU(e,t,n){let r=e.points,o=Math.floor(r.length/t),i=Hd(e,o),s=new Float64Array(Math.max(o+(i?1:0),1));s[0]=n;for(let a=1;a<s.length;a++){let l=e.controls?.[a-1];if(l&&l.length>0){let f=po(Ml(r,l,t,a-1),t);s[a]=s[a-1]+(Number.isFinite(f)?f:0);continue}let u=(a-1)*t,c=a%o*t,d=0;for(let f=0;f<t;f++)d+=(r[c+f]-r[u+f])**2;s[a]=s[a-1]+Math.sqrt(d)}return s}function PU(e,t,n,r){let o=[],i=[],s=new Float64Array(e.length*2),a=0,l=0;return e.forEach((u,c)=>{let d=Math.floor(u.points.length/t),f=n[c],p=TU(u,d,f,l);l+=d;let h=SU(p,r,Hd(u,d));if(h.ids.length===0)return;let m=h.ids[0],y=h.ids[h.ids.length-1];Hd(u,d)&&(y+=1,h.ids.push(y),h.lens.push(f[f.length-1])),s[c*2]=m,s[c*2+1]=y,a+=y-m,o.push(...h.ids),i.push(...h.lens)}),{bpAnchor:Float64Array.from(o),bpLength:Float64Array.from(i),runAnchor:s,segments:a}}function TU(e,t,n,r){let o=[],i=[],{anchorA:s,anchorB:a}=e;if(!s||!a){for(let u=0;u<t;u++)o.push(r+u),i.push(n[u]);return{ids:o,lens:i}}for(let u=0;u<t;u++)s[u]===a[u]&&(o.push(s[u]),i.push(n[u]));let l=Uk(e,t);return l!==void 0&&(o.push(l),i.push(n[t])),{ids:o,lens:i}}function Ol(e,t=2){return Uk(e,Math.floor(e.points.length/t))}function Uk(e,t){let{anchorA:n,anchorB:r}=e;if(Hd(e,t))return e.closeAnchor!==void 0?e.closeAnchor:n&&r&&n[t-1]!==r[t-1]?r[t-1]:void 0}function SU(e,t,n){let r=[],o=[],i=0,s=0,a=()=>{r.length>o.length&&o.push((i+s)/2)};for(let l=0;l<e.ids.length;l++){let u=t?t[e.ids[l]]??e.ids[l]:e.ids[l],c=e.lens[l];if(!(n&&r.length>0&&u===r[0])){if(r.length>0&&u===r[r.length-1]){s=c;continue}a(),r.push(u),i=c,s=c}}return a(),{ids:r,lens:o}}var Hk,Hd,Wd=J(()=>{"use strict";El();vg();Hk=Symbol("lengthTable.internals");Hd=(e,t)=>e.closed&&(t>=2||t===1&&(e.controls?.[0]?.length??0)>0)});function qe(e){return e.origin?Wk(e,Float64Array.from(e.coords)):e.coords}function Wk(e,t){let n=e.origin;if(n===void 0)return t;for(let r=0;r+1<t.length;r+=2)t[r]+=n.x,t[r+1]+=n.y;return t}function At(e,t){let n=e?.x??0,r=e?.y??0,o=new Float32Array(t.length);for(let i=0;i+1<t.length;i+=2)o[i]=t[i]-n,o[i+1]=t[i+1]-r;return o}function Sn(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let s=0;s+1<e.length;s+=2){let a=e[s],l=e[s+1];a<t&&(t=a),a>r&&(r=a),l<n&&(n=l),l>o&&(o=l)}let i=Math.max(Math.abs(t),Math.abs(r),Math.abs(n),Math.abs(o));if(!(!(i>=Vk)||!Number.isFinite(i)))return{x:Math.round((t+r)/2),y:Math.round((n+o)/2)}}function Ng(e){let t=0,n=0;for(let l of e)t+=l.commands.length,n+=l.coords.length;let r=e[0]?.origin,o=new Uint8Array(t),i=new Float32Array(n),s=0,a=0;for(let l of e)o.set(l.commands,s),s+=l.commands.length,i.set(l.origin===r?l.coords:At(r,qe(l)),a),a+=l.coords.length;return{kind:"polygon",commands:o,coords:i,fillRule:"nonzero",...r?{origin:r}:{}}}var wee,Vk,rn=J(()=>{"use strict";wee=Object.freeze({x:0,y:0});Vk=16384});function Kk(e,t,n,r){return{kind:"rect",x:e,y:t,width:n,height:r}}function Vd(e){let t=new De,n=e[0];if(!n)return Kk(0,0,0,0);t.moveTo(n.x,n.y);for(let r=1;r<e.length;r++){let o=e[r];o&&t.lineTo(o.x,o.y)}return t.build()}function Ig(e,t={}){if(e.length===0)return{kind:"polygon",commands:new Uint8Array,coords:new Float32Array,fillRule:t.fillRule??"nonzero"};let n=new De;t.fillRule&&n.setFillRule(t.fillRule),n.moveTo(e[0].x,e[0].y);for(let r=1;r<e.length;r++)n.lineTo(e[r].x,e[r].y);return n.close(),n.build()}function Eg(e){let t=e.x+e.width/2,n=e.y+e.height/2,r=e.width/2,o=e.height/2,i=r*zk,s=o*zk,a=new De;return a.moveTo(t+r,n),a.curveTo(t+r,n+s,t+i,n+o,t,n+o),a.curveTo(t-i,n+o,t-r,n+s,t-r,n),a.curveTo(t-r,n-s,t-i,n-o,t,n-o),a.curveTo(t+i,n-o,t+r,n-s,t+r,n),a.close(),a.build()}function Mg(e,t,n,r=0){let o=new De;for(let i=0;i<n;i++){let s=r+i/n*Math.PI*2,a=e.x+t*Math.cos(s),l=e.y+t*Math.sin(s);i===0?o.moveTo(a,l):o.lineTo(a,l)}return o.close(),o.build()}function Cg(e,t,n=5,r=t/2,o=0){let i=new De,s=n*2;for(let a=0;a<s;a++){let l=o+a/s*Math.PI*2,u=a%2===0?t:r,c=e.x+u*Math.cos(l),d=e.y+u*Math.sin(l);a===0?i.moveTo(c,d):i.lineTo(c,d)}return i.close(),i.build()}function Og(e,t){let n=new De;return n.moveTo(e.x,e.y),n.lineTo(t.x,t.y),n.build()}var De,zk,gr=J(()=>{"use strict";Ye();rn();De=class e{cmds=[];xs=[];fillRule="nonzero";origin;auto=!1;static fromPath(t){let n=new e;return n.cmds=Array.from(t.commands),n.xs=Array.from(t.coords),n.fillRule=t.fillRule,t.origin&&(n.origin={x:t.origin.x,y:t.origin.y}),n}setOrigin(t,n){let r=this.origin?.x??0,o=this.origin?.y??0;for(let i=0;i<this.xs.length;i+=2)this.xs[i]+=r-t,this.xs[i+1]+=o-n;return this.origin=t===0&&n===0?void 0:{x:t,y:n},this}autoOrigin(){return this.auto=!0,this}push(...t){let n=this.origin?.x??0,r=this.origin?.y??0;for(let o=0;o<t.length;o+=2)this.xs.push(t[o]-n,t[o+1]-r)}setFillRule(t){return this.fillRule=t,this}moveTo(t,n){return this.cmds.push(se),this.push(t,n),this}lineTo(t,n){return this.cmds.push(ae),this.push(t,n),this}curveTo(t,n,r,o,i,s){return this.cmds.push(be),this.push(t,n,r,o,i,s),this}quadTo(t,n,r,o){return this.cmds.push(we),this.push(t,n,r,o),this}close(){return this.cmds.push(fe),this}build(){if(this.auto&&!this.origin){let t=Sn(this.xs);t&&this.setOrigin(t.x,t.y)}return{kind:"polygon",commands:new Uint8Array(this.cmds),coords:new Float32Array(this.xs),fillRule:this.fillRule,...this.origin?{origin:{...this.origin}}:{}}}};zk=.5522847498307936});function Fg(e,t){let n=e.corners?.[t];return n&&n.radius>0?n:null}function zd(e){let t=e.corners;if(!t)return!1;for(let n of t)if(n&&n.radius>0)return!0;return!1}function Kd(e){let t=e.length;for(;t>0&&!e[t-1];)t--;if(t===0)return;let n=new Array(t);for(let r=0;r<t;r++)n[r]=e[r]??null;return n}function ui(e){if(e.corners===void 0)return e;let{corners:t,...n}=e;return n}function Lg(e,t){return!e.corners||t===1?e:{...e,corners:e.corners.map(n=>n?{shape:n.shape,radius:n.radius*t}:null)}}function _g(e,t,n){if(!e&&!t)return;let r=Math.max(e?.length??0,t?.length??0),o=new Array(r);for(let i=0;i<r;i++){let s=e?.[i]??null,a=t?.[i]??null,l=s??a;l?s&&a&&s.shape!==a.shape?o[i]=n<.5?s:a:o[i]={shape:l.shape,radius:(s?.radius??0)+((a?.radius??0)-(s?.radius??0))*n}:o[i]=null}return Kd(o)}var Fl=J(()=>{"use strict"});function jk(e,t,n,r,o){let[i,s]=Ve(e.x,e.y,t.x,t.y,n.x,n.y,r.x,r.y,o);return{x:i,y:s}}var $k=J(()=>{"use strict";Pn()});function qk(e,t,n,r={}){let{cp1:o,cp2:i}=kU(e,t,n,r.passes??4,r.params);return{cp1:o,cp2:i}}function kU(e,t,n,r,o){let i=e.length,s=e[0],a=e[i-1],l=o?[...o]:vU(e);if(l===null)return{cp1:{...s},cp2:{...a},end:a,ts:e.map(()=>0)};let u=Yk(e,l,s,a,t,n);for(let c=0;c<r;c++)AU(e,l,s,a,u),u=Yk(e,l,s,a,t,n);return u}function vU(e){let t=e.length,n=new Array(t);n[0]=0;let r=0;for(let o=1;o<t;o++)r+=Gt(e[o-1],e[o]),n[o]=r;if(r===0)return null;for(let o=0;o<t;o++)n[o]/=r;return n}function Yk(e,t,n,r,o,i){let s=e.length,a=0,l=0,u=0,c=0,d=0;for(let m=0;m<s;m++){let y=t[m],b=1-y,x=b*b*b,w=3*b*b*y,g=3*b*y*y,P=y*y*y,S=w*o.x,v=w*o.y,A=g*i.x,N=g*i.y;a+=S*S+v*v,l+=S*A+v*N,u+=A*A+N*N;let M=e[m].x-(x+w)*n.x-(g+P)*r.x,C=e[m].y-(x+w)*n.y-(g+P)*r.y;c+=S*M+v*C,d+=A*M+N*C}let f=a*u-l*l,p,h;return Math.abs(f)<1e-12?p=h=Gt(n,r)/3:(p=(u*c-l*d)/f,h=(a*d-l*c)/f,(p<1e-6||h<1e-6)&&(p=h=Gt(n,r)/3)),{cp1:{x:n.x+o.x*p,y:n.y+o.y*p},cp2:{x:r.x+i.x*h,y:r.y+i.y*h},end:r,ts:t}}function AU(e,t,n,r,o){for(let i=1;i<e.length-1;i++)t[i]=RU(e[i],t[i],e[0],o.cp1,o.cp2,e[e.length-1])}function RU(e,t,n,r,o,i){let s=1-t,{x:a,y:l}=jk(n,r,o,i,t),u=3*s*s*(r.x-n.x)+6*s*t*(o.x-r.x)+3*t*t*(i.x-o.x),c=3*s*s*(r.y-n.y)+6*s*t*(o.y-r.y)+3*t*t*(i.y-o.y),d=6*s*(o.x-2*r.x+n.x)+6*t*(i.x-2*o.x+r.x),f=6*s*(o.y-2*r.y+n.y)+6*t*(i.y-2*o.y+r.y),p=a-e.x,h=l-e.y,m=p*u+h*c,y=u*u+c*c+p*d+h*f;if(Math.abs(y)<1e-12)return t;let b=t-m/y;return b<0?0:b>1?1:b}var Xk=J(()=>{"use strict";$k();ai()});function tv(e){return typeof e=="number"?e:NU[e]}function IU(e){let t=2**Math.abs(e);return 1-.5**(1/t)<nv/4?1/0:t}function Ll(e,t){let n=.5**(1/e),r=i=>Math.max(0,1-i**e)**(1/e);if(t<=1){let i=t*n;return{x:i,y:r(i)}}let o=(2-t)*n;return{x:r(o),y:o}}function Qk(e,t){let n=Ll(e,t),[r,o]=t<=1?[1,-((n.x/n.y)**(e-1))]:[(n.y/n.x)**(e-1),-1],i=Math.hypot(r,o);return{x:r/i,y:o/i}}function EU(e,t,n,r,[o,i,s]){let a=f=>{let p=Ll(e,f);return li(p.x,p.y,r.x,r.y,o.x,o.y,i.x,i.y,s.x,s.y).dist},l=0,u=1;for(let f=1;f<jd;f++){let p=a(t+(n-t)*(f/jd));p>l&&(l=p,u=f)}let c=t+(n-t)*((u-1)/jd),d=t+(n-t)*((u+1)/jd);for(let f=0;f<24;f++){let p=c+(d-c)/3,h=d-(d-c)/3;a(p)>a(h)?d=h:c=p}return Math.max(l,a((c+d)/2))}function Dg(e,t,n,r,o,i){let s=Ll(e,t),a=Ll(e,n),l=[],u=[];for(let m=0;m<=12;m++)l.push(Ll(e,t+(n-t)*(m/12))),u.push(m/12);let c=Qk(e,n),{cp1:d,cp2:f}=qk(l,Qk(e,t),{x:-c.x,y:-c.y},{params:u}),p=[d,f,a];if(o>=10||EU(e,t,n,s,p)<=r){i.push(p);return}let h=(t+n)/2;Dg(e,t,h,r,o+1,i),Dg(e,h,n,r,o+1,i)}function MU(e,t){if(e===2)return[[{x:Jk,y:1},{x:1,y:Jk},{x:1,y:0}]];let n=`${e}:${t}`,r=$d.get(n);return r||(r=[],Dg(e,0,2,t,0,r),$d.size>256&&$d.clear(),$d.set(n,r)),r}function CU(e,t){let n=Zk(e.end,t),r=Zk(e.start,t);return o=>({x:t.x+o.x*n.x+o.y*r.x,y:t.y+o.x*n.y+o.y*r.y})}function ev(e){return{x:e.start.x+e.end.x-e.outer.x,y:e.start.y+e.end.y-e.outer.y}}function rv(e,t,n=nv){if(e===0)return[{kind:"line",to:t.end}];let r=IU(e);if(r===1/0)return[{kind:"line",to:e>0?t.outer:ev(t)},{kind:"line",to:t.end}];let o=CU(t,e>0?ev(t):t.outer);return MU(r,n).map(([i,s,a])=>({kind:"cubic",c1:o(i),c2:o(s),to:o(a)}))}var NU,nv,Jk,Zk,jd,$d,ov=J(()=>{"use strict";Xk();_d();NU={square:1/0,squircle:2,round:1,bevel:0,scoop:-1,notch:-1/0};nv=.001,Jk=4/3*Math.tan(Math.PI/8);Zk=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),jd=32;$d=new Map});function _l(e){let{commands:t}=e,n=qe(e),r=[],o=null,i=0,s=0,a=!1,l=()=>o.anchors[o.anchors.length-1],u=(c,d)=>{o.segs.push(d),o.anchors.push(c),o.sources.push(s++),i++};return Oe(t,n,(c,d,f,p,h,m)=>{if(m)return a=!0,!1;let y=b=>({x:n[d+b],y:n[d+b+1]});switch(c){case se:o&&r.push(o),o={anchors:[y(0)],segs:[],closed:!1,first:i++,sources:[s++]};break;case ae:u(y(0),sv(l(),y(0)));break;case be:u(y(4),{line:!1,p0:l(),c1:y(0),c2:y(2),p3:y(4)});break;case we:{let b=l(),x=y(0),w=y(2),g={x:b.x+2/3*(x.x-b.x),y:b.y+2/3*(x.y-b.y)},P={x:w.x+2/3*(x.x-w.x),y:w.y+2/3*(x.y-w.y)};u(w,{line:!1,p0:b,c1:g,c2:P,p3:w});break}case fe:o&&OU(o,()=>i--),o&&r.push(o),o=null;break}}),a?null:(o&&r.push(o),r)}function OU(e,t){e.closed=!0;let n=e.anchors.length,r=e.anchors[0],o=e.anchors[n-1];if(n>1&&!e.segs[n-2].line&&o.x===r.x&&o.y===r.y){e.anchors.pop(),e.sources.pop(),t();return}e.segs.push(sv(o,r))}function Yd(e){if(e.line)return Math.hypot(e.p3.x-e.p0.x,e.p3.y-e.p0.y);let t=iv.get(e);return t===void 0&&iv.set(e,t=po(av(e),2)),t}function Bg(e,t){let n=Yd(e);return n>0?e.line?Math.min(1,Math.max(0,t/n)):Lk(av(e),2,t,n):0}function Dl(e,t){if(e.line)return{x:e.p0.x+(e.p3.x-e.p0.x)*t,y:e.p0.y+(e.p3.y-e.p0.y)*t};let{p0:n,c1:r,c2:o,p3:i}=e,[s,a]=Ve(n.x,n.y,r.x,r.y,o.x,o.y,i.x,i.y,t);return{x:s,y:a}}function xs(e,t){let n=Math.hypot(e,t);return n>1e-12?{x:e/n,y:t/n}:null}function Bl(e,t){let{p0:n,c1:r,c2:o,p3:i}=e;if(e.line)return xs(i.x-n.x,i.y-n.y);let s=1-t,a=3*(s*s*(r.x-n.x)+2*s*t*(o.x-r.x)+t*t*(i.x-o.x)),l=3*(s*s*(r.y-n.y)+2*s*t*(o.y-r.y)+t*t*(i.y-o.y)),u=xs(a,l);return u||(t<.5?xs(o.x-n.x,o.y-n.y)??xs(i.x-n.x,i.y-n.y):xs(i.x-r.x,i.y-r.y)??xs(i.x-n.x,i.y-n.y))}function lv(e,t,n){let{p0:r,c1:o,c2:i,p3:s}=e,a=[r.x,r.y,o.x,o.y,i.x,i.y,s.x,s.y];t>0&&(a=[...co(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],t)[1]]);let l=t<1?(n-t)/(1-t):1;return l<1&&(a=[...co(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],l)[0]]),[{x:a[2],y:a[3]},{x:a[4],y:a[5]},{x:a[6],y:a[7]}]}var sv,iv,av,Hg=J(()=>{"use strict";Ye();Pn();rn();El();sv=(e,t)=>({line:!0,p0:e,c1:e,c2:t,p3:t});iv=new WeakMap,av=({p0:e,c1:t,c2:n,p3:r})=>[e.x,e.y,t.x,t.y,n.x,n.y,r.x,r.y]});function dv(e,t){let n=t.anchors.length,r=t.segs.map(Yd),o=t.anchors.map((s,a)=>{let l=a>0?t.segs[a-1]:t.closed?t.segs[n-1]:null,u=a<t.segs.length?t.segs[a]:null;if(!l||!u||l===u)return null;let c=Bl(l,1),d=Bl(u,0);if(!c||!d)return null;let f=Math.acos(Math.max(-1,Math.min(1,c.x*d.x+c.y*d.y)));if(f<uv||f>Math.PI-uv)return null;let p=d.x-c.x,h=d.y-c.y,m=Math.hypot(p,h),y=(Math.PI-f)/2,b=Fg(e,t.first+a),x=b?b.radius:0;return{frame:{index:t.first+a,x:s.x,y:s.y,bisector:{x:p/m,y:h/m},halfAngle:y},spec:b,want:x,trim:x}}),i=o.map(()=>1);return t.segs.forEach((s,a)=>{let l=a,u=(a+1)%n,c=(o[l]?.want??0)+(o[u]?.want??0);if(c<=r[a])return;let d=r[a]/c;i[l]=Math.min(i[l],d),i[u]=Math.min(i[u],d)}),o.forEach((s,a)=>{s&&(s.trim=s.want*i[a])}),o}function ho(e){if(e.corners===void 0)return{path:e,anchorSources:null};let t=cv.get(e);if(t)return t;let n=zd(e)?FU(e):{path:ui(e),anchorSources:null};return cv.set(e,n),n}function ze(e){return e.kind!=="polygon"?e:ho(e).path}function Hl(e,t,n){let r=new Array(t.length*n);for(let o=0;o<t.length;o++)for(let i=0;i<n;i++)r[o*n+i]=e[t[o]*n+i];return r}function FU(e){let t=_l(e);if(!t)return{path:ui(e),anchorSources:null};let n=new Gg;e.origin&&n.b.setOrigin(e.origin.x,e.origin.y);for(let i of t)LU(n,i,dv(e,i));let{commands:r,coords:o}=n.b.build();return{path:{...ui(e),commands:r,coords:o},anchorSources:Uint32Array.from(n.sources)}}function fv(e,t,n){let r=e.segs[n],o=Yd(r),i=Bg(r,t[n]?.trim??0),s=Bg(r,o-(t[(n+1)%e.anchors.length]?.trim??0));return[i,Math.max(i,s)]}function pv(e,t,n,r){let o=(r+1)%e.anchors.length,i=t[o],s=e.segs[o];if(!i?.spec||i.trim<=0||!s)return null;let a=e.segs[r],l=Dl(a,n[r][1]),u=Dl(s,n[o][0]),c=_U({x:i.frame.x,y:i.frame.y},l,Bl(a,n[r][1]),u,Bl(s,n[o][0]));return{cut:i,start:l,end:u,pieces:rv(tv(i.spec.shape),c)}}function qd(e){if(!zd(e))return[];let t=[];for(let n of _l(e)??[]){let r=dv(e,n),o=n.segs.map((i,s)=>fv(n,r,s));n.segs.forEach((i,s)=>{let a=pv(n,r,o,s);if(!a)return;let{frame:l}=a.cut;t.push({index:l.index,anchor:{x:l.x,y:l.y},spec:a.cut.spec,start:a.start,end:a.end,pieces:a.pieces})})}return t}function LU(e,t,n){let r=t.anchors.length,o=t.segs.map((s,a)=>fv(t,n,a)),i=t.closed&&t.segs.length>0?Dl(t.segs[0],o[0][0]):t.anchors[0];e.src=t.sources[0],e.moveTo(i.x,i.y),t.segs.forEach((s,a)=>{let[l,u]=o[a];e.src=t.sources[(a+1)%r];let c=t.closed&&a===r-1&&!(n[0]?.spec&&n[0].trim>0);if(u>l&&!(c&&s.line))if(s.line){let p=Dl(s,u);e.lineTo(p.x,p.y)}else{let[p,h,m]=lv(s,l,u);e.curveTo(p.x,p.y,h.x,h.y,m.x,m.y)}let d=pv(t,n,o,a);if(!d)return;let f=[...d.pieces];(a+1)%r===0&&f.at(-1)?.kind==="line"&&f.pop();for(let p of f)p.kind==="line"?e.lineTo(p.to.x,p.to.y):e.curveTo(p.c1.x,p.c1.y,p.c2.x,p.c2.y,p.to.x,p.to.y)}),t.closed&&e.close()}function _U(e,t,n,r,o){let i=n&&o?DU(t,n,r,o):null,s=Math.hypot(r.x-t.x,r.y-t.y),a=!i||Math.hypot(i.x-e.x,i.y-e.y)>4*s;return{start:t,end:r,outer:a?e:i}}function DU(e,t,n,r){let o=t.x*r.y-t.y*r.x;if(Math.abs(o)<1e-9)return null;let i=((n.x-e.x)*r.y-(n.y-e.y)*r.x)/o;return{x:e.x+t.x*i,y:e.y+t.y*i}}var uv,cv,Gg,Rt=J(()=>{"use strict";gr();Fl();ov();Hg();uv=.001;cv=new WeakMap;Gg=class{b=new De;sources=[];src=0;moveTo(t,n){this.b.moveTo(t,n),this.sources.push(this.src)}lineTo(t,n){this.b.lineTo(t,n),this.sources.push(this.src)}curveTo(t,n,r,o,i,s){this.b.curveTo(t,n,r,o,i,s),this.sources.push(this.src)}close(){this.b.close()}}});function Jd(e){return e>0?e:BU}function jg(e,t,n,r,o,i){return Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(o)&&Number.isFinite(i)}function hv(e,t,n,r,o,i,s,a){return jg(e,t,n,r,o,i)&&Number.isFinite(s)&&Number.isFinite(a)}function mv(e,t,n,r,o,i,s,a,l,u){let c=Ug(n-e,r-t,o-n,i-r)+Ug(o-n,i-r,s-o,a-i);return o===n&&i===r&&(c+=Ug(n-e,r-t,s-o,a-i)),c===0?!0:c>=Math.PI?!1:((Math.hypot(n-e,r-t)+Math.hypot(o-n,i-r)+Math.hypot(s-o,a-i))/c+l)*(1-Math.cos(c/2))<=u}function Ug(e,t,n,r){let o=Math.sqrt((e*e+t*t)*(n*n+r*r));return o===0?0:Math.acos(Math.max(-1,Math.min(1,(e*n+t*r)/o)))}function mo(e,t,n,r,o,i,s,a,l,u){if(!hv(e,t,n,r,o,i,s,a)){u.push(s,a);return}Wg(e,t,n,r,o,i,s,a,Jd(l),u,0)}function Wg(e,t,n,r,o,i,s,a,l,u,c){let d=Tn(n,r,e,t,s,a),f=Tn(o,i,e,t,s,a);if(Math.max(d,f)<=l||c>=Xd){u.push(s,a);return}let p=(e+n)*.5,h=(t+r)*.5,m=(n+o)*.5,y=(r+i)*.5,b=(o+s)*.5,x=(i+a)*.5,w=(p+m)*.5,g=(h+y)*.5,P=(m+b)*.5,S=(y+x)*.5,v=(w+P)*.5,A=(g+S)*.5;Wg(e,t,p,h,w,g,v,A,l,u,c+1),Wg(v,A,P,S,b,x,s,a,l,u,c+1)}function $g(e,t,n,r,o,i,s,a){if(!jg(e,t,n,r,o,i)){a.push(o,i);return}Vg(e,t,n,r,o,i,Jd(s),a,0)}function Vg(e,t,n,r,o,i,s,a,l){if(Tn(n,r,e,t,o,i)<=s||l>=Xd){a.push(o,i);return}let c=(e+n)*.5,d=(t+r)*.5,f=(n+o)*.5,p=(r+i)*.5,h=(c+f)*.5,m=(d+p)*.5;Vg(e,t,c,d,h,m,s,a,l+1),Vg(h,m,f,p,o,i,s,a,l+1)}function Gl(e,t,n,r,o,i,s,a,l,u,c,d=0){return hv(e,t,n,r,o,i,s,a)?zg(e,t,n,r,o,i,s,a,Jd(l),d,u,c,0,0):(u.push(s,a),c.push(0),0)}function zg(e,t,n,r,o,i,s,a,l,u,c,d,f,p){let h=Tn(n,r,e,t,s,a),m=Tn(o,i,e,t,s,a);if(Math.max(h,m)<=l&&(u===0||mv(e,t,n,r,o,i,s,a,u,l))||p>=Xd){let D=c.length>=2?c[c.length-2]:e,B=c.length>=2?c[c.length-1]:t,K=Math.hypot(s-D,a-B);return f+=K,c.push(s,a),d.push(f),f}let b=(e+n)*.5,x=(t+r)*.5,w=(n+o)*.5,g=(r+i)*.5,P=(o+s)*.5,S=(i+a)*.5,v=(b+w)*.5,A=(x+g)*.5,N=(w+P)*.5,M=(g+S)*.5,C=(v+N)*.5,F=(A+M)*.5;return f=zg(e,t,b,x,v,A,C,F,l,u,c,d,f,p+1),f=zg(C,F,N,M,P,S,s,a,l,u,c,d,f,p+1),f}function Ul(e,t,n,r,o,i,s,a,l,u=0){return jg(e,t,n,r,o,i)?Kg(e,t,n,r,o,i,Jd(s),u,a,l,0,0):(a.push(o,i),l.push(0),0)}function Kg(e,t,n,r,o,i,s,a,l,u,c,d){if(Tn(n,r,e,t,o,i)<=s&&(a===0||mv(e,t,n,r,o,i,o,i,a,s))||d>=Xd){let g=l.length>=2?l[l.length-2]:e,P=l.length>=2?l[l.length-1]:t,S=Math.hypot(o-g,i-P);return c+=S,l.push(o,i),u.push(c),c}let h=(e+n)*.5,m=(t+r)*.5,y=(n+o)*.5,b=(r+i)*.5,x=(h+y)*.5,w=(m+b)*.5;return c=Kg(e,t,h,m,x,w,s,a,l,u,c,d+1),c=Kg(x,w,y,b,o,i,s,a,l,u,c,d+1),c}var mt,BU,Xd,ci=J(()=>{"use strict";ai();mt=.5,BU=1e-6,Xd=16});function br(e,t={}){return e.kind==="rect"?[HU(e)]:GU(ze(e),t)}function HU(e){let{x:t,y:n,width:r,height:o}=e;return{points:Array.from(Al(t,n,r,o)),closed:!0,anchorA:new Uint32Array([0,1,2,3]),anchorB:new Uint32Array([0,1,2,3]),anchorT:new Float32Array([0,0,0,0])}}function GU(e,t){let n=t.flattenTolerance??mt,{commands:r,coords:o}=e,i=[],s=0,a=null,l=null,u=null,c=null,d=null,f=-1,p,h=0,m=()=>{a=[],l=[],u=[],c=[];let x={points:a,closed:!1};return i.push(x),x},y=x=>{!a||!l||!u||!c||(x.anchorA=new Uint32Array(l),x.anchorB=new Uint32Array(u),x.anchorT=new Float32Array(c),p!==void 0&&(x.closeAnchor=p),p=void 0)},b=(x,w,g,P)=>{for(let v=0;v<w.length;v++)l.push(f),u.push(P),c.push(g>0?w[v]/g:0);let S=x+w.length-1;l[S]=P,u[S]=P,c[S]=0};return Oe(r,o,(x,w,g,P,S,v)=>{switch(v&&(d&&y(d),d=m(),a.push(g,P),l.push(h),u.push(h),c.push(0),f=h),x){case se:case ae:{x===se&&(d&&y(d),d=m(),h=s),a.push(o[w],o[w+1]),l.push(s),u.push(s),c.push(0),f=s,s++;break}case we:{let A=s,N=a.length/2,M=[],C=Ul(g,P,o[w],o[w+1],o[w+2],o[w+3],n,a,M,t.offset);b(N,M,C,A),f=A,s++;break}case be:{let A=s,N=a.length/2,M=[],C=Gl(g,P,o[w],o[w+1],o[w+2],o[w+3],o[w+4],o[w+5],n,a,M,t.offset);b(N,M,C,A),f=A,s++;break}case fe:{d&&(d.closed=!0,a&&l&&u&&c&&(p=UU(a,l,u,c)??p));break}default:throw new Error(`extractPolylines: unknown command code ${x}`)}}),d&&y(d),i}function UU(e,t,n,r){let o=e.length/2;if(o<2||e[0]!==e[(o-1)*2]||e[1]!==e[(o-1)*2+1])return;let i=t[o-1]===n[o-1]?t[o-1]:void 0;return e.length-=2,t.length-=1,n.length-=1,r.length-=1,i}var Yg=J(()=>{"use strict";Ye();Rt();Rl();ci()});function Wl(e){let t=yv.get(e);if(t)return t;let n;if(e.kind==="rect")n=Gd(br(e),2);else{let{path:r,anchorSources:o}=ho(e),i=WU(r);n=Gd(br(r).map(s=>VU(s,i)),2,o)}return yv.set(e,n),n}function WU(e){let t=[],{commands:n,coords:r}=e;return Oe(n,r,(o,i)=>{o===se||o===ae?t.push(null):o===we?t.push([r[i],r[i+1]]):o===be&&t.push([r[i],r[i+1],r[i+2],r[i+3]])}),t}function VU(e,t){let n=e.points.length/2,{anchorA:r,anchorB:o}=e,i=[],s=[];for(let c=0;c<n;c++)r&&o&&r[c]!==o[c]||(i.push(e.points[c*2],e.points[c*2+1]),s.push(r?r[c]:c));let a=s.slice(1).map(c=>t[c]??null),l=Ol(e);e.closed&&n>=2&&a.push(l===void 0?null:t[l]??null);let u=Uint32Array.from(s);return{points:i,closed:e.closed,anchorA:u,anchorB:u.slice(),anchorT:new Float32Array(s.length),...l!==void 0?{closeAnchor:l}:{},controls:a}}var yv,gv=J(()=>{"use strict";Ye();Rt();Yg();Wd();yv=new WeakMap});function qg(e){let t=ze(e);if(t.kind==="rect"){let{x:s,y:a,width:l,height:u}=t;return`M${Ze(s)} ${Ze(a)}h${Ze(l)}v${Ze(u)}h${Ze(-l)}Z`}let n=t.commands,r=qe(t),o=[],i=0;for(let s=0;s<n.length;s++){let a=n[s];a===se?(o.push(`M${Ze(r[i])} ${Ze(r[i+1])}`),i+=2):a===ae?(o.push(`L${Ze(r[i])} ${Ze(r[i+1])}`),i+=2):a===be?(o.push(`C${Ze(r[i])} ${Ze(r[i+1])} ${Ze(r[i+2])} ${Ze(r[i+3])} ${Ze(r[i+4])} ${Ze(r[i+5])}`),i+=6):a===we?(o.push(`Q${Ze(r[i])} ${Ze(r[i+1])} ${Ze(r[i+2])} ${Ze(r[i+3])}`),i+=4):a===fe&&o.push("Z")}return o.join("")}var Ze,bv=J(()=>{"use strict";Ye();Rt();rn();Ze=e=>Number.isFinite(e)?String(Math.round(e*1e6)/1e6):"0"});function Wn(e,t,n,r=0,o=e.length>>1){if(o-r<3)return!1;let i=!1;for(let s=r,a=o-1;s<o;a=s++){let l=e[s*2],u=e[s*2+1],c=e[a*2],d=e[a*2+1];u>n!=d>n&&t<(c-l)*(n-u)/(d-u)+l&&(i=!i)}return i}function xr(e,t=0,n=e.length>>1){let r=0;for(let o=t;o<n;o++){let i=o+1===n?t:o+1;r+=e[o*2]*e[i*2+1]-e[i*2]*e[o*2+1]}return r*.5}function wr(e,t,n,r,o,i,s,a){let l=gs((s-o)*(t-i)-(a-i)*(e-o)),u=gs((s-o)*(r-i)-(a-i)*(n-o)),c=gs((n-e)*(i-t)-(r-t)*(o-e)),d=gs((n-e)*(a-t)-(r-t)*(s-e));return l!==u&&c!==d}var Vl=J(()=>{"use strict";kl()});function Xg(e,t){let n=Math.max(t.from,0),r=Math.min(t.to,e.total);if(!(n<r))return null;let o=xv(e,n,!0),i=xv(e,r,!1);return o&&i?{from:o,to:i}:null}function xv(e,t,n){let{cum:r}=Cl(e);for(let o=0;o<r.length;o++){let i=r[o],s=i[i.length-1];if(!(i.length<2||!(s>i[0])||(n?t>=s:t>s)))for(let a=0;a<i.length-1;a++){let l=i[a+1]-i[a];if(!(!(l>0)||(n?t>=i[a+1]:t>i[a+1])))return{run:o,segment:a,t:zU(e,o,a,t-i[a],l)}}}return null}function zU(e,t,n,r,o){let i=Gk(e,t,n);return i?Dk(i.coords,e.dim,i.lookup,r):Math.min(Math.max(r/o,0),1)}var wv=J(()=>{"use strict";El();Wd()});function Jg(){return Pv}function kn(e){return(e.openFill??Pv)==="close"}var Pv,di=J(()=>{"use strict";Pv="close"});function et(e){if(e.kind==="rect")return e;let{commands:t,coords:n}=ze(e);if(t.length===0)return{kind:"rect",x:0,y:0,width:0,height:0};let r=1/0,o=1/0,i=-1/0,s=-1/0,a=!1,l=(u,c)=>{u<r&&(r=u),u>i&&(i=u),c<o&&(o=c),c>s&&(s=c),a=!0};return Oe(t,n,(u,c,d,f)=>{switch(u){case se:case ae:{l(n[c],n[c+1]);break}case be:{let[p,h,m,y]=gg(d,f,n[c],n[c+1],n[c+2],n[c+3],n[c+4],n[c+5]);l(p,h),l(m,y);break}case we:{let p=n[c+2],h=n[c+3],[m,y,b,x]=uo(d,f,n[c],n[c+1],p,h),[w,g,P,S]=gg(d,f,m,y,b,x,p,h);l(w,g),l(P,S);break}case fe:break;default:throw new Error(`boundsOfPath: unknown command ${u}`)}}),a?{kind:"rect",x:r+(e.origin?.x??0),y:o+(e.origin?.y??0),width:i-r,height:s-o}:{kind:"rect",x:0,y:0,width:0,height:0}}var Qg=J(()=>{"use strict";Pn();Ye();Rt()});function Sv(e){let t=Tv.get(e);if(t)return t;let{commands:n,coords:r}=e,o=[],i=0,s=0,a=0,l=0,u=0,c=0,d=0,f=!1;Oe(n,r,(h,m)=>{if(h===fe){a>1&&f&&c===l&&d===u&&(o[o.length-1]=s,i--),a=0;return}let y=lo(h);c=r[m+y-2],d=r[m+y-1],f=h===be||h===we,(h===se||a===0)&&(s=i,l=c,u=d,a=0),a++,o.push(i++)});let p=Int32Array.from(o);return Tv.set(e,p),p}var Tv,kv=J(()=>{"use strict";Ye();Tv=new WeakMap});function KU(e){return e.kind!=="polygon"?[]:qd(e).map(({anchor:t,spec:n,start:r,end:o,pieces:i})=>({anchor:t,spec:n,start:r,end:o,pieces:i}))}function tb(e,t,n=Rv){let r=e.flatMap(KU);return r.length===0?t:JU(t,r,n)}function Zg(e,t,n){let r=t.start;for(let o of t.pieces){if((o.kind==="line"?Nl(e.x,e.y,r.x,r.y,o.to.x,o.to.y).dist:li(e.x,e.y,r.x,r.y,o.c1.x,o.c1.y,o.c2.x,o.c2.y,o.to.x,o.to.y).dist)<=n)return!0;r=o.to}return!1}function ws(e,t,n,r){let o=si(e.p0,e.c1,t),i=si(e.c1,e.c2,t),s=si(e.c2,e.p3,t),a=si(o,i,n),l=si(i,s,n);return si(a,l,r)}function vv(e,t,n,r){let o=l=>ws(e,l,l,l),i=l=>{let u=ws(e,l,l,0),c=ws(e,l,l,1);return{x:3*(c.x-u.x),y:3*(c.y-u.y)}},s=Math.hypot(i(n).x,i(n).y);if(s===0)return null;let a=n+(n===1?1:-1)*Gt(o(n),t)/s;for(let l=0;l<30;l++){let u=o(a),c=i(a),d=c.x*c.x+c.y*c.y;if(d===0)break;a-=((u.x-t.x)*c.x+(u.y-t.y)*c.y)/d}return Gt(o(a),t)<=r?a:null}function jU(e,t,n,r){let o=t??e.p0,i=n??e.p3;if(e.line)return{line:!0,p0:o,c1:o,c2:i,p3:i};let s=t?vv(e,t,0,r):0,a=n?vv(e,n,1,r):1;return s===null||a===null?null:{line:!1,p0:o,c1:ws(e,s,s,a),c2:ws(e,s,a,a),p3:i}}function Av(e,t,n,r,o){return Gt(e,n)<=o?!0:t.line&&Zg(e,r,o)&&Nl(n.x,n.y,t.p0.x,t.p0.y,t.p3.x,t.p3.y).dist<=o}function $U(e,t,n){let r=e.anchors.length;for(let o=e.closed?0:1;o<r;o++)for(let[i,s]of[[t.start,t.end],[t.end,t.start]])if(Av(e.anchors[o],e.segs[(o-1+r)%r],i,t,n))for(let a=o+1,l=1;l<e.segs.length&&!(!e.closed&&a>=r-1);a++,l++){let u=e.anchors[a%r],c=e.segs[(a-1)%r];if(!c.line&&!Zg(ws(c,.5,.5,.5),t,n))break;if(Av(u,e.segs[a%r],s,t,n))return{from:o,to:a%r,trace:t};if(!Zg(u,t,n))break}return null}function eb(e,t){let n=[];for(let r=e.from;;r=(r+1)%t)if(n.push(r),r===e.to)return n}function YU(e,t,n,r){let o=e.anchors.length,i=new Map,s=new Set;for(let p of t){i.set(p.from,p);for(let h of eb(p,o))s.add(h)}let a=0;if(e.closed){let p=e.anchors.findIndex((h,m)=>!s.has(m));a=p>=0?p:t[0].from}let l=[],u=[];for(let p=0,h=a;p<o;){let m=i.get(h);if(m){l.push({at:m.trace.anchor,spec:m.trace.spec}),u.push(m.to);let y=eb(m,o).length;p+=y,h=(m.to+1)%o}else l.push({at:e.anchors[h],spec:n[h]??null}),u.push(h),p++,h=(h+1)%o}let c=new Set(t.map(p=>p.to)),d=[],f=e.closed?l.length:l.length-1;for(let p=0;p<f;p++){let h=u[p],m=c.has(h)?l[p].at:void 0,y=i.has((h+1)%o)?l[(p+1)%l.length].at:void 0,b=jU(e.segs[h],m,y,r);if(!b)return null;d.push(b)}return{nodes:l,segs:d,closed:e.closed,folded:[...t]}}function qU(e,t){let n=new De;t.origin&&n.setOrigin(t.origin.x,t.origin.y);let r=[];for(let{nodes:c,segs:d,closed:f}of e)n.moveTo(c[0].at.x,c[0].at.y),r.push(c[0].spec),d.forEach((p,h)=>{let m=c[(h+1)%c.length];f&&h===d.length-1&&p.line||(p.line?n.lineTo(m.at.x,m.at.y):n.curveTo(p.c1.x,p.c1.y,p.c2.x,p.c2.y,m.at.x,m.at.y),r.push(m.spec))}),f&&n.close();let{commands:o,coords:i}=n.build(),s={...ui(t),commands:o,coords:i},a=Sv(s),l=[];r.forEach((c,d)=>{if(c){for(;l.length<a[d];)l.push(null);l[a[d]]=c}});let u=Kd(l);return u?{...s,corners:u}:s}function XU(e,t,n){let r=new Set(n.map(o=>o.trace));for(let o of qd(e))for(let i of r){if(Gt(o.anchor,i.anchor)>t)continue;(Gt(o.start,i.start)<=t&&Gt(o.end,i.end)<=t||Gt(o.start,i.end)<=t&&Gt(o.end,i.start)<=t)&&r.delete(i)}return r}function JU(e,t,n=Rv){let r=_l(e);if(!r||t.length===0)return e;let o=new Set;for(let i=0;i<=t.length;i++){let s=[];for(let c of r){let d=[],f=new Set;for(let m of t){if(o.has(m))continue;let y=$U(c,m,n);if(!y)continue;let b=eb(y,c.anchors.length);b.some(x=>f.has(x))||(b.forEach(x=>f.add(x)),d.push(y))}let p=c.anchors.map((m,y)=>e.corners?.[c.first+y]??null),h=d.length>0?YU(c,d,p,n):null;if(d.length>0&&!h){d.forEach(m=>o.add(m.trace)),s.length=0;break}s.push(h??{nodes:c.anchors.map((m,y)=>({at:m,spec:p[y]})),segs:c.segs,closed:c.closed,folded:[]})}if(s.length!==r.length)continue;let a=s.flatMap(c=>c.folded);if(a.length===0)return e;let l=qU(s,e),u=XU(l,n,a);if(u.size===0)return l;u.forEach(c=>o.add(c))}return e}var Rv,Nv=J(()=>{"use strict";_d();gr();kv();Hg();Fl();Rt();ai();Rv=.001});function QU(e,t){let n=ze(e),{commands:r}=n,o=qe(n),i=[],s=[],a=[];return Oe(r,o,(l,u,c,d,f,p)=>{switch(p&&(a=[c,d]),l){case se:a.length>=2&&s.push(a),a=[o[u],o[u+1]];break;case ae:a.push(o[u],o[u+1]);break;case be:mo(c,d,o[u],o[u+1],o[u+2],o[u+3],o[u+4],o[u+5],t,a);break;case we:$g(c,d,o[u],o[u+1],o[u+2],o[u+3],t,a);break;case fe:a.length>=6?i.push(a):a.length>=2&&s.push(a),a=[];break;default:throw new Error(`pathHitTest: unknown command ${l}`)}}),a.length>=2&&s.push(a),{closed:i,open:s}}function Qd(e,t){let n=QU(e,t.tolerance??mt);return kn(e)?{closed:[...n.closed,...n.open.filter(r=>r.length>=6)],open:n.open.filter(r=>r.length<6)}:n}function nb(e,t){return Qd(e,t).closed}var Iv=J(()=>{"use strict";Ye();ci();di();Rt();rn()});function rb(e,t,n,r){let o=e.points,i=o.length/2,s=ZU(e,i);if(s.length<2)return{length:0,x:o[0]??0,y:o[1]??0};let a=Math.min(Math.max(Math.floor(t),0),s.length-2),l=Math.min(Math.max(n,0),1),u=s[a],c=s[a+1],d=r?.controls?.[a],f=d&&d.length>0?Ml([o[u*2],o[u*2+1],o[c%i*2],o[c%i*2+1]],d,2,0):null,p,h;f?[p,h]=Bk(f,2,l):(p=Cv(o[u*2],o[c%i*2],l),h=Cv(o[u*2+1],o[c%i*2+1],l));let{chord:m,u:y}=!f&&c-u===1?{chord:u,u:l}:e6(e,i,u,c,p,h,f?t6(f,l):l),b=0;for(let x=0;x<m;x++)b+=Mv(o,i,x);return{length:b+y*Mv(o,i,m),x:p,y:h}}function ZU(e,t){let{anchorA:n,anchorB:r}=e,o=[];for(let i=0;i<t;i++)(!n||!r||n[i]===r[i])&&o.push(i);return e.closed&&t>=2&&o.push(t),o}function e6(e,t,n,r,o,i,s){let a=e.anchorT,l=f=>f>=r?1:f<=n?0:a?a[f]:(f-n)/(r-n),u=n;for(;u<r-1&&l(u+1)<=s;)u++;let c=Ev(e.points,t,u,o,i),d=c<0?-1:c>1?1:0;for(;d!==0&&u+d>=n&&u+d<r&&(d<0?c<0:c>1);)u+=d,c=Ev(e.points,t,u,o,i);return{chord:u,u:Math.min(Math.max(c,0),1)}}function Ev(e,t,n,r,o){let i=e[n*2],s=e[n*2+1],a=(n+1)%t,l=e[a*2]-i,u=e[a*2+1]-s,c=l*l+u*u;return c>0?((r-i)*l+(o-s)*u)/c:0}function Mv(e,t,n){let r=(n+1)%t;return Math.hypot(e[r*2]-e[n*2],e[r*2+1]-e[n*2+1])}function t6(e,t){let n=po(e,2);return n>0?po(e,2,0,t)/n:t}var Cv,Ov=J(()=>{"use strict";vg();El();Cv=(e,t,n)=>e+(t-e)*n});function Fv(e){let t=(e.a+e.d)/2,n=(e.a-e.d)/2,r=(e.b+e.c)/2,o=(e.b-e.c)/2,i=Math.hypot(t,o),s=Math.hypot(n,r),a=(Math.atan2(o,t)+Math.atan2(r,n))/2;return{s1:i+s,s2:Math.abs(i-s),phi:a}}function Lv(e){return e.s1-e.s2<=1e-9*e.s1}var _v=J(()=>{"use strict"});function ob(e,t,n,r={}){if(e.kind==="rect")return t>=e.x&&t<=e.x+e.width&&n>=e.y&&n<=e.y+e.height;let o=0,i=0;for(let s of nb(e,r)){let a=s.length;for(let l=0;l<a;l+=2){let u=(l+2)%a,c=s[l+1],d=s[u+1];if(c>n==d>n)continue;let f=s[l],p=s[u];t>=f+(n-c)/(d-c)*(p-f)||(o++,i+=c<=n?1:-1)}}return e.fillRule==="evenodd"?(o&1)===1:i!==0}function Zd(e){return[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}]}function Ps(e){let t=new Array(e.length*2);for(let n=0;n<e.length;n++)t[n*2]=e[n].x,t[n*2+1]=e[n].y;return t}function n6(e,t){if(e.length===0||t.length===0)return!1;if(Wn(Ps(e),t[0].x,t[0].y)||Wn(Ps(t),e[0].x,e[0].y))return!0;for(let n=0;n<e.length;n++){let r=e[n],o=e[(n+1)%e.length];for(let i=0;i<t.length;i++){let s=t[i],a=t[(i+1)%t.length];if(wr(r.x,r.y,o.x,o.y,s.x,s.y,a.x,a.y))return!0}}return!1}function Bv(e,t){for(let n of e){let r=n.length;for(let o=0;o<r;o+=2){let i=(o+2)%r;if(t(n[o],n[o+1],n[i],n[i+1]))return!0}}return!1}function r6(e,t){let n=t.x,r=t.y,o=t.x+t.width,i=t.y+t.height;return Bv(e,(s,a,l,u)=>wr(s,a,l,u,n,r,o,r)||wr(s,a,l,u,o,r,o,i)||wr(s,a,l,u,o,i,n,i)||wr(s,a,l,u,n,i,n,r))}function Hv(e,t){return t.length===0?!1:Bv(e,(n,r,o,i)=>{for(let s=0;s<t.length;s++){let a=t[s],l=t[(s+1)%t.length];if(wr(n,r,o,i,a.x,a.y,l.x,l.y))return!0}return!1})}function o6(e,t){for(let n of e)for(let r=0;r+3<n.length;r+=2){let o=n[r],i=n[r+1],s=n[r+2],a=n[r+3];for(let l=0;l<t.length;l++){let u=t[l],c=t[(l+1)%t.length];if(wr(o,i,s,a,u.x,u.y,c.x,c.y))return!0}}return!1}function i6(e,t){for(let n of e)for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];if(o>=t.x&&o<=t.x+t.width&&i>=t.y&&i<=t.y+t.height)return!0}return!1}function Dv(e,t){for(let n of e)for(let r=0;r<n.length;r+=2)if(Wn(t,n[r],n[r+1]))return!0;return!1}function ef(e,t,n={}){if(e.kind==="rect")return t.x<e.x+e.width&&t.x+t.width>e.x&&t.y<e.y+e.height&&t.y+t.height>e.y;let r=nb(e,n);if(r.length===0)return!1;for(let o of Zd(t))if(ob(e,o.x,o.y,n))return!0;return i6(r,t)?!0:r6(r,t)}function ib(e,t,n={}){if(e.length<3)return!1;let r;if(t.kind==="rect")r=[Ps(Zd(t))];else{let{closed:i,open:s}=Qd(t,n);r=[...i,...s]}if(r.length===0)return!1;let o=Ps(e);for(let i of r)for(let s=0;s<i.length;s+=2)if(!Wn(o,i[s],i[s+1]))return!1;return!Hv(r,e)}function tf(e,t,n={}){if(e.length<3)return!1;let r=n.filled!==!1;if(t.kind==="rect"&&r)return n6(Zd(t),e);let{closed:o,open:i}=t.kind==="rect"?{closed:[Ps(Zd(t))],open:[]}:Qd(t,n),s=Ps(e);return Dv(o,s)||Dv(i,s)||Hv(o,e)||o6(i,e)?!0:r&&o.length>0&&ob(t,e[0].x,e[0].y,n)}var Gv=J(()=>{"use strict";Vl();Iv()});function Nt(e,t,n={}){let[r,o,i,s,a,l]=t;if(e.kind==="rect"){if(Math.abs(o)<Uv&&Math.abs(i)<Uv){let c=r*e.x+a,d=s*e.y+l,f=r*(e.x+e.width)+a,p=s*(e.y+e.height)+l;return{kind:"rect",x:Math.min(c,f),y:Math.min(d,p),width:Math.abs(f-c),height:Math.abs(p-d)}}let u=new De().autoOrigin().moveTo(e.x,e.y).lineTo(e.x+e.width,e.y).lineTo(e.x+e.width,e.y+e.height).lineTo(e.x,e.y+e.height).close().build();return Wv(u,t,n)}return Wv(e,t,n)}function Wv(e,t,n){let r=Lg(e,Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]))),o=e.origin;if(o===void 0){let d=mg(e.coords,t),f=n.autoOrigin!==!1?Sn(d):void 0;return f?{...r,coords:At(f,d),origin:f}:{...r,coords:Float32Array.from(d)}}let[i,s,a,l,u,c]=t;return{...r,coords:Float32Array.from(mg(e.coords,[i,s,a,l,0,0])),origin:{x:i*o.x+a*o.y+u,y:s*o.x+l*o.y+c}}}var Uv,zl=J(()=>{"use strict";bs();gr();Fl();rn();Uv=1e-9});function sb(e,t,n){return e.kind==="rect"?{kind:"rect",x:e.x+t,y:e.y+n,width:e.width,height:e.height}:s6(e,t,n)}function s6(e,t,n){let r=e.origin;if(r)return{...e,coords:e.coords.slice(),origin:{x:r.x+t,y:r.y+n}};let o=new Float32Array(e.coords.length),{commands:i,coords:s}=e;return Oe(i,s,(a,l)=>{for(let u=0,c=lo(a);u<c;u+=2)o[l+u]=s[l+u]+t,o[l+u+1]=s[l+u+1]+n}),{...e,coords:o}}var Vv=J(()=>{"use strict";Ye()});function ab(e){if(e.kind==="rect")return 4;let t=e.commands,n=0;for(let r=0;r<t.length;r++){let o=t[r];(o===se||o===ae||o===be||o===we)&&n++}return n}var zv=J(()=>{"use strict";Ye()});function nf(e){if(e.kind==="rect")return e.width*e.height;let{commands:t,coords:n}=e,r=kn(e),o=0,i=0,s=0,a=0,l=!1,u=0,c=0,d=f=>{l&&(f||r)&&(o+=i+u*a-s*c),i=0,l=!1};return Oe(t,n,(f,p,h,m)=>{if(f===se){d(!1),s=u=n[p],a=c=n[p+1],l=!0;return}if(f===fe){d(!0),u=s,c=a;return}if(l||(s=h,a=m,l=!0),f===ae){u=n[p],c=n[p+1],i+=h*c-u*m;return}let y=f===be,b=n[p],x=n[p+1],w=n[p+2],g=n[p+3],P=y?n[p+4]:w,S=y?n[p+5]:g;for(let v=0;v<3;v++){let A=a6[v],N=1-A,M,C,F,D;y?(M=N*N*N*h+3*N*N*A*b+3*N*A*A*w+A*A*A*P,C=N*N*N*m+3*N*N*A*x+3*N*A*A*g+A*A*A*S,F=3*(N*N*(b-h)+2*N*A*(w-b)+A*A*(P-w)),D=3*(N*N*(x-m)+2*N*A*(g-x)+A*A*(S-g))):(M=N*N*h+2*N*A*b+A*A*w,C=N*N*m+2*N*A*x+A*A*g,F=2*(N*(b-h)+A*(w-b)),D=2*(N*(x-m)+A*(g-x))),i+=l6[v]*(M*D-C*F)}u=P,c=S}),d(!1),o/2}var a6,l6,lb=J(()=>{"use strict";Ye();di();a6=[.5-Math.sqrt(15)/10,.5,.5+Math.sqrt(15)/10],l6=[5/18,8/18,5/18]});function jv(e,t){let n=e[t];if(!/[A-Za-z]/.test(n))return!1;if(n!=="e"&&n!=="E"||!/[\d.]/.test(e[t-1]??""))return!0;let r=e[t+1]==="+"||e[t+1]==="-"?t+2:t+1;return!/\d/.test(e[r]??"")}function u6(e){let t=[],n=0;for(;n<e.length;)if(jv(e,n)){let r=n+1;for(;r<e.length&&!jv(e,r);)r++;let o=e.slice(n+1,r),i=e[n];t.push({cmd:i,args:i==="A"||i==="a"?d6(o):c6(o)}),n=r}else n++;return t}function c6(e){let t=[],n;for(Kv.lastIndex=0;(n=Kv.exec(e))!==null;){let r=Number(n[0]);Number.isFinite(r)&&t.push(r)}return t}function d6(e){let t=[],n=0;for(;n<e.length;){let r=e[n];if(r===","||r===" "||r===" "||r===`
2
+ `||r==="\r"){n++;continue}let o=t.length%7;if(o===3||o===4){if(r!=="0"&&r!=="1")return t;t.push(r==="1"?1:0),n++;continue}ub.lastIndex=n;let i=ub.exec(e);if(!i)return t;t.push(Number(i[0])),n=ub.lastIndex}return t}function fi(e,t){let n=u6(e),r=new De().autoOrigin(),o={x:0,y:0,startX:0,startY:0,lastCubicCtrl:null,lastQuadCtrl:null},i=!1;for(let{cmd:s,args:a}of n){let l=s.toUpperCase(),u=s!==l,c=f6[l];if(c===void 0){t?.(`unknown path command: ${s}`);continue}if(!i&&l!=="M"){t?.(`path data does not begin with a moveto ("${s}" comes first); nothing is drawn`);break}if(l==="Z"){r.close(),o.x=o.startX,o.y=o.startY,o.lastCubicCtrl=null,o.lastQuadCtrl=null;continue}let d=Math.floor(a.length/c);for(let f=0;f<d;f++){let p=a.slice(f*c,(f+1)*c),h=l==="M"&&f>0?"L":l;p6(h,u,p,o,r),i=!0}if(d===0||a.length%c!==0){t?.(`path command "${s}" takes ${c} arguments at a time and has ${a.length}; the path ends before it`);break}}return r.build()}function p6(e,t,n,r,o){let i=t?r.x:0,s=t?r.y:0;switch(e){case"M":{let a=n[0]+i,l=n[1]+s;o.moveTo(a,l),r.x=a,r.y=l,r.startX=a,r.startY=l,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"L":{let a=n[0]+i,l=n[1]+s;o.lineTo(a,l),r.x=a,r.y=l,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"H":{let a=n[0]+(t?r.x:0);o.lineTo(a,r.y),r.x=a,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"V":{let a=n[0]+(t?r.y:0);o.lineTo(r.x,a),r.y=a,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}case"C":{let a=n[0]+i,l=n[1]+s,u=n[2]+i,c=n[3]+s,d=n[4]+i,f=n[5]+s;o.curveTo(a,l,u,c,d,f),r.x=d,r.y=f,r.lastCubicCtrl={x:u,y:c},r.lastQuadCtrl=null;return}case"S":{let a=r.lastCubicCtrl??{x:r.x,y:r.y},l=2*r.x-a.x,u=2*r.y-a.y,c=n[0]+i,d=n[1]+s,f=n[2]+i,p=n[3]+s;o.curveTo(l,u,c,d,f,p),r.x=f,r.y=p,r.lastCubicCtrl={x:c,y:d},r.lastQuadCtrl=null;return}case"Q":{let a=n[0]+i,l=n[1]+s,u=n[2]+i,c=n[3]+s;o.quadTo(a,l,u,c),r.x=u,r.y=c,r.lastQuadCtrl={x:a,y:l},r.lastCubicCtrl=null;return}case"T":{let a=r.lastQuadCtrl??{x:r.x,y:r.y},l=2*r.x-a.x,u=2*r.y-a.y,c=n[0]+i,d=n[1]+s;o.quadTo(l,u,c,d),r.x=c,r.y=d,r.lastQuadCtrl={x:l,y:u},r.lastCubicCtrl=null;return}case"A":{let a=Math.abs(n[0]),l=Math.abs(n[1]),u=n[2],c=n[3]!==0,d=n[4]!==0,f=n[5]+i,p=n[6]+s;h6(r.x,r.y,f,p,a,l,u,c,d,o),r.x=f,r.y=p,r.lastCubicCtrl=null,r.lastQuadCtrl=null;return}default:return}}function h6(e,t,n,r,o,i,s,a,l,u){if(e===n&&t===r)return;if(o===0||i===0){u.lineTo(n,r);return}let c=s*Un,d=Math.cos(c),f=Math.sin(c),p=(e-n)/2,h=(t-r)/2,m=d*p+f*h,y=-f*p+d*h,b=o*o,x=i*i,w=m*m,g=y*y,P=w/b+g/x,S=o,v=i;if(P>1){let te=Math.sqrt(P);S=te*o,v=te*i,b=S*S,x=v*v}let A=a===l?-1:1,N=b*x-b*g-x*w,M=b*g+x*w,C=A*Math.sqrt(Math.max(0,N/M)),F=C*(S*y)/v,D=C*-(v*m)/S,B=d*F-f*D+(e+n)/2,K=f*F+d*D+(t+r)/2,W=(te,he,xe,Le)=>{let Se=te*xe+he*Le,cr=Math.sqrt((te*te+he*he)*(xe*xe+Le*Le)),_e=Math.acos(Math.max(-1,Math.min(1,Se/cr)));return te*Le-he*xe<0&&(_e=-_e),_e},Q=W(1,0,(m-F)/S,(y-D)/v),le=W((m-F)/S,(y-D)/v,(-m-F)/S,(-y-D)/v);!l&&le>0?le-=2*Math.PI:l&&le<0&&(le+=2*Math.PI);let ke=Math.max(1,Math.ceil(Math.abs(le)/(Math.PI/2))),ue=le/ke,ve=4/3*Math.tan(ue/4),G=e,j=t,$=-Math.sin(Q)*S,ee=Math.cos(Q)*v;for(let te=1;te<=ke;te++){let he=Q+te*ue,xe=Math.cos(he),Le=Math.sin(he),Se=d*(xe*S)-f*(Le*v)+B,cr=f*(xe*S)+d*(Le*v)+K,_e=-Le*S,vt=xe*v,Qt=G+d*(ve*$)-f*(ve*ee),od=j+f*(ve*$)+d*(ve*ee),Cy=Se-d*(ve*_e)+f*(ve*vt),id=cr-f*(ve*_e)-d*(ve*vt);u.curveTo(Qt,od,Cy,id,Se,cr),G=Se,j=cr,$=_e,ee=vt}}var Kv,ub,f6,$v=J(()=>{"use strict";gr();hg();Kv=/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/g,ub=/[+-]?(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?/y;f6={M:2,L:2,H:1,V:1,C:6,S:4,Q:4,T:2,A:7,Z:0}});function Ue(e,t,n,r){let o=(n-e)/3,i=(r-t)/3;return{c:[e,t,e+o,t+i,n-o,r-i,n,r],line:!0}}function pi(e){if(e.kind==="rect"){let{x:c,y:d,width:f,height:p}=e;return[{closed:!0,segs:[Ue(c,d,c+f,d),Ue(c+f,d,c+f,d+p),Ue(c+f,d+p,c,d+p),Ue(c,d+p,c,d)]}]}let t=[],n=null,r=0,o=0,i=(c,d,f)=>{n!==null&&(c&&((d!==r||f!==o)&&n.segs.push(Ue(d,f,r,o)),n.closed=!0),n.segs.length>0&&t.push(n),n=null)},s=ze(e),{commands:a}=s,l=qe(s);Oe(a,l,(c,d,f,p,h,m)=>{switch(m&&(n={segs:[],closed:!1},r=f,o=p),c){case se:i(!1,f,p),n={segs:[],closed:!1},r=l[d],o=l[d+1];break;case ae:{let y=l[d],b=l[d+1];(y!==f||b!==p)&&n.segs.push(Ue(f,p,y,b));break}case we:{let[y,b,x,w]=uo(f,p,l[d],l[d+1],l[d+2],l[d+3]);n.segs.push({c:[f,p,y,b,x,w,l[d+2],l[d+3]],line:!1});break}case be:n.segs.push({c:[f,p,l[d],l[d+1],l[d+2],l[d+3],l[d+4],l[d+5]],line:!1});break;case fe:i(!0,f,p);break}});let u=n;if(u!==null){let c=u.segs.at(-1);i(!1,c?c.c[6]:r,c?c.c[7]:o)}return t}function cb(e,t="nonzero"){let n=new De().setFillRule(t);for(let{segs:r,closed:o}of e)if(r.length!==0){n.moveTo(r[0].c[0],r[0].c[1]);for(let{c:i,line:s}of r)s?n.lineTo(i[6],i[7]):n.curveTo(i[2],i[3],i[4],i[5],i[6],i[7]);o&&n.close()}return n.build()}function Ts(e,t){let[n,r]=co(...e.c,t);return[{c:[...n],line:e.line},{c:[...r],line:e.line}]}var rf=J(()=>{"use strict";Pn();Ye();gr();Rt();rn()});function tt(e,t){let n=1-t;if(e.length===2)return{x:n*e[0].x+t*e[1].x,y:n*e[0].y+t*e[1].y};if(e.length===3){let a=n*n,l=2*n*t,u=t*t;return{x:a*e[0].x+l*e[1].x+u*e[2].x,y:a*e[0].y+l*e[1].y+u*e[2].y}}let r=n*n*n,o=3*n*n*t,i=3*n*t*t,s=t*t*t;return{x:r*e[0].x+o*e[1].x+i*e[2].x+s*e[3].x,y:r*e[0].y+o*e[1].y+i*e[2].y+s*e[3].y}}function jl(e,t){let n=e.length-1,r=[];for(let o=0;o<n;o++)r.push({x:n*(e[o+1].x-e[o].x),y:n*(e[o+1].y-e[o].y)});return r.length===1?r[0]:tt(r,t)}function Yv(e,t){let n=i=>{let s=[];for(let a=0;a<i.length;a+=2)s.push({x:i[a],y:i[a+1]});return s};if(e.length===2){let i=tt(e,t);return[[e[0],i],[i,e[1]]]}if(e.length===3){let[i,s]=Ik(e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,t);return[n(i),n(s)]}let[r,o]=co(e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y,t);return[n(r),n(o)]}function Ss(e,t,n,r,o){if(n-t<=0)return null;let i=e;t>0&&(i=Yv(i,t)[1]);let s=(n-t)/(1-t);return s<1&&(i=Yv(i,s)[0]),i=i.slice(),i[0]=r,i[i.length-1]=o,i}function m6(e){let t=[];for(let n of e){let r=n.length===2?1:16;for(let o=0;o<r;o++){let i=tt(n,o/r);t.push(i.x,i.y)}}return t}function Xv(e){return xr(m6(e))}function Jv(e,t,n){return e.map(r=>n.x*(r.y-t.y)-n.y*(r.x-t.x))}function Kl(e,t){let n=1-t;return e.length===2?n*e[0]+t*e[1]:e.length===3?n*n*e[0]+2*n*t*e[1]+t*t*e[2]:n*n*n*e[0]+3*n*n*t*e[1]+3*n*t*t*e[2]+t*t*t*e[3]}function Qv(e,t){let n=i=>i>0?1:i<0?-1:t?1:0,r=[0,...y6(e),1],o=[];for(let i=0;i+1<r.length;i++){let s=r[i],a=r[i+1],l=n(Kl(e,s)),u=n(Kl(e,a));if(l===0&&i>0){let c=n(Kl(e,s-1e-7)),d=n(Kl(e,s+1e-7));c*d<0&&o.push({t:s,before:c,after:d})}if(!(l*u>=0)){for(let c=0;c<64;c++){let d=(s+a)/2;n(Kl(e,d))===l?s=d:a=d}o.push({t:(s+a)/2,before:l,after:u})}}return o}function y6(e){if(e.length<3)return[];let t=e.length-1,n=e.slice(1).map((l,u)=>t*(l-e[u])),r=0,o,i;n.length===2?(o=n[1]-n[0],i=n[0]):(r=n[0]-2*n[1]+n[2],o=2*(n[1]-n[0]),i=n[0]);let s=[],a=Math.max(Math.abs(r),Math.abs(o),Math.abs(i))||1;if(Math.abs(r)/a<1e-12)Math.abs(o)/a>1e-12&&s.push(-i/o);else{let l=o*o-4*r*i;if(l>=0){let u=-.5*(o+Math.sign(o||1)*Math.sqrt(l));s.push(u/r),u!==0&&s.push(i/u)}}return s.filter(l=>l>0&&l<1).sort((l,u)=>l-u)}var qv,hi=J(()=>{"use strict";Pn();Vl();qv=e=>e.map(t=>t.slice().reverse()).reverse()});function eA(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let i of e)i.x<t&&(t=i.x),i.x>r&&(r=i.x),i.y<n&&(n=i.y),i.y>o&&(o=i.y);return[t,n,r,o]}function tA(e){if(e.length===2)return 0;let t=e[0],n=e[e.length-1],r=n.x-t.x,o=n.y-t.y,i=Math.hypot(r,o),s=0;for(let a=1;a<e.length-1;a++){let l=e[a],u=i===0?Math.hypot(l.x-t.x,l.y-t.y):Math.abs((l.x-t.x)*o-(l.y-t.y)*r)/i;u>s&&(s=u)}return s}function nA(e){let t=e.pts,n=[t[0]],r=[t[t.length-1]];for(;t.length>1;){let i=[];for(let s=0;s+1<t.length;s++)i.push({x:(t[s].x+t[s+1].x)/2,y:(t[s].y+t[s+1].y)/2});t=i,n.push(t[0]),r.unshift(t[t.length-1])}let o=(e.t0+e.t1)/2;return[{pts:n,t0:e.t0,t1:o},{pts:r,t0:o,t1:e.t1}]}function rA(e,t,n,r,o){let i=t.x-e.x,s=t.y-e.y,a=r.x-n.x,l=r.y-n.y,u=i*l-s*a;if(u===0)return null;let c=n.x-e.x,d=n.y-e.y,f=(c*l-d*a)/u,p=(c*s-d*i)/u;return f<-o||f>1+o||p<-o||p>1+o?null:[f,p]}function x6(e,t,n,r){for(let o=0;o<12;o++){let i=tt(e,n),s=tt(t,r),a=i.x-s.x,l=i.y-s.y;if(Math.abs(a)+Math.abs(l)<1e-12)break;let u=jl(e,n),c=jl(t,r),d=-u.x*c.y+u.y*c.x;if(d===0)break;let f=(-a*-c.y- -l*-c.x)/d,p=(u.x*-l-u.y*-a)/d;n=Math.min(1,Math.max(0,n+f)),r=Math.min(1,Math.max(0,r+p))}return[n,r]}function db(e,t){if(e.length===2&&t.length===2){let i=rA(e[0],e[1],t[0],t[1],1e-12);if(!i)return[];let s=Math.min(1,Math.max(0,i[0])),a=Math.min(1,Math.max(0,i[1])),l=tt(e,s);return[{ta:s,tb:a,x:l.x,y:l.y}]}let n=[],r=(i,s)=>{[i,s]=x6(e,t,i,s);let a=tt(e,i),l=tt(t,s);Math.hypot(a.x-l.x,a.y-l.y)>1e-6*(1+Math.abs(a.x)+Math.abs(a.y))||n.some(u=>Math.abs(u.ta-i)<Zv&&Math.abs(u.tb-s)<Zv)||n.push({ta:i,tb:s,x:a.x,y:a.y})},o=[[{pts:e,t0:0,t1:1},{pts:t,t0:0,t1:1},0]];for(;o.length>0&&n.length<b6;){let[i,s,a]=o.pop(),l=eA(i.pts),u=eA(s.pts);if(l[0]>u[2]+ks||u[0]>l[2]+ks||l[1]>u[3]+ks||u[1]>l[3]+ks)continue;let c=tA(i.pts),d=tA(s.pts);if(c<=ks&&d<=ks||a>=g6){let f=rA(i.pts[0],i.pts[i.pts.length-1],s.pts[0],s.pts[s.pts.length-1],1e-6);f&&r(i.t0+f[0]*(i.t1-i.t0),s.t0+f[1]*(s.t1-s.t0));continue}if(c>=d){let[f,p]=nA(i);o.push([f,s,a+1],[p,s,a+1])}else{let[f,p]=nA(s);o.push([i,f,a+1],[i,p,a+1])}}return n.sort((i,s)=>i.ta-s.ta)}var ks,g6,Zv,b6,oA=J(()=>{"use strict";hi();ks=1e-4,g6=48,Zv=1e-7,b6=16});function iA(e){let t=e.kind==="rect"||kn(e);return w6(e).filter(n=>n.closed||t).map(n=>n.segs)}function w6(e,t=!0){let n=ze(e);if(n.kind==="rect"){let{x:c,y:d,width:f,height:p}=n,h=[{x:c,y:d},{x:c+f,y:d},{x:c+f,y:d+p},{x:c,y:d+p}];return[{segs:h.map((m,y)=>[m,h[(y+1)%4]]),closed:!0}]}let r=[],o=[],i={x:0,y:0},s=i,a=c=>{o.length>0&&(c||t)&&(s.x!==i.x||s.y!==i.y)&&o.push([s,i]),o.length>0&&r.push({segs:o,closed:c}),o=[],s=i},l=qe(n),u=0;for(let c of n.commands)if(c===se)a(!1),i=s={x:l[u],y:l[u+1]},u+=2;else if(c===ae){let d={x:l[u],y:l[u+1]};(d.x!==s.x||d.y!==s.y)&&o.push([s,d]),s=d,u+=2}else if(c===we){let d={x:l[u+2],y:l[u+3]};o.push([s,{x:l[u],y:l[u+1]},d]),s=d,u+=4}else if(c===be){let d={x:l[u+4],y:l[u+5]};o.push([s,{x:l[u],y:l[u+1]},{x:l[u+2],y:l[u+3]},d]),s=d,u+=6}else c===fe&&a(!0);return a(!1),r}function sA(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let i of e)for(let s of i)for(let a of s)t=Math.min(t,a.x),r=Math.max(r,a.x),n=Math.min(n,a.y),o=Math.max(o,a.y);return Math.hypot(r-t,o-n)}var aA=J(()=>{"use strict";Ye();di();Rt();rn()});function Vn(e,t){let n=new e.constructor(t);return n.set(e),n}function fb(e,t,n,r,o){for(let i=0;i<o;i++)n[r+i]<e[t+i]&&(e[t+i]=n[r+i]),n[r+o+i]>e[t+o+i]&&(e[t+o+i]=n[r+o+i])}var of,lA=J(()=>{"use strict";of=class{dim;root=-1;nodeBox;left;right;parent;leafCount;leafItems;count;nodeCap=0;nodeTop=0;freeNodes=[];itemBox;itemCentroid2;itemLeaf;keys=[];itemCap=0;itemTop=0;freeItems=[];constructor(t){this.dim=t,this.nodeBox=new Float64Array(0),this.left=this.right=this.parent=this.leafCount=this.leafItems=this.count=new Int32Array(0),this.itemBox=new Float64Array(0),this.itemCentroid2=new Float64Array(0),this.itemLeaf=new Int32Array(0),this.growNodes(16),this.growItems(16)}growNodes(t){let n=2*this.dim;this.nodeBox=Vn(this.nodeBox,t*n),this.left=Vn(this.left,t),this.right=Vn(this.right,t),this.parent=Vn(this.parent,t),this.leafCount=Vn(this.leafCount,t),this.leafItems=Vn(this.leafItems,t*4),this.count=Vn(this.count,t),this.nodeCap=t}growItems(t){this.itemBox=Vn(this.itemBox,t*2*this.dim),this.itemCentroid2=Vn(this.itemCentroid2,t*this.dim),this.itemLeaf=Vn(this.itemLeaf,t),this.itemCap=t}allocNode(t){let n=this.freeNodes.pop();return n===void 0&&(this.nodeTop===this.nodeCap&&this.growNodes(this.nodeCap*2),n=this.nodeTop++),this.left[n]=-1,this.right[n]=-1,this.parent[n]=t,this.leafCount[n]=0,n}freeNode(t){this.freeNodes.push(t)}allocItem(t,n){let r=this.freeItems.pop();return r===void 0&&(this.itemTop===this.itemCap&&this.growItems(this.itemCap*2),r=this.itemTop++),this.keys[r]=t,this.writeItemBox(r,n),r}freeItem(t){this.keys[t]=void 0,this.itemLeaf[t]=-1,this.freeItems.push(t)}writeItemBox(t,n){let r=this.dim,o=2*r;for(let i=0;i<o;i++)this.itemBox[t*o+i]=n[i];for(let i=0;i<r;i++)this.itemCentroid2[t*r+i]=n[i]+n[r+i]}computeBox(t){let n=this.dim,r=2*n,o=this.nodeBox,i=t*r;for(let a=0;a<n;a++)o[i+a]=1/0,o[i+n+a]=-1/0;if(this.left[t]!==-1){fb(o,i,o,this.left[t]*r,n),fb(o,i,o,this.right[t]*r,n),this.count[t]=this.count[this.left[t]]+this.count[this.right[t]];return}this.count[t]=this.leafCount[t];let s=t*4;for(let a=0;a<this.leafCount[t];a++)fb(o,i,this.itemBox,this.leafItems[s+a]*r,n)}refitUp(t){for(;t!==-1;t=this.parent[t])this.computeBox(t)}build(){this.freeNodes=[],this.nodeTop=0,this.root=-1;let t=[];for(let r=0;r<this.itemTop;r++)this.itemLeaf[r]!==-1&&t.push(r);if(t.length===0)return;this.nodeCap<2*t.length&&this.growNodes(2*t.length);let n=Int32Array.from(t);this.root=this.buildRange(n,0,n.length,-1)}rebuildSubtree(t){let n=this.parent[t],r=n!==-1&&this.left[n]===t,o=new Int32Array(this.count[t]),i=[t],s=0;for(;i.length>0;){let l=i.pop();if(this.left[l]!==-1)i.push(this.left[l],this.right[l]);else for(let u=0;u<this.leafCount[l];u++)o[s++]=this.leafItems[l*4+u];this.freeNode(l)}let a=this.buildRange(o,0,s,n);n===-1?this.root=a:r?this.left[n]=a:this.right[n]=a}buildRange(t,n,r,o,i=new Float64Array(t.length)){let s=this.allocNode(o);if(r-n<=4)for(let a=n;a<r;a++)this.placeInLeaf(s,t[a]);else{let a=n+r>>1;this.select(t,i,n,r,a,this.longestCentroidAxis(t,n,r));let l=this.buildRange(t,n,a,s,i),u=this.buildRange(t,a,r,s,i);this.left[s]=l,this.right[s]=u}return this.computeBox(s),s}placeInLeaf(t,n){this.leafItems[t*4+this.leafCount[t]++]=n,this.itemLeaf[n]=t}splitLeaf(t,n){let r=t*4,o=new Int32Array(5);for(let l=0;l<4;l++)o[l]=this.leafItems[r+l];o[4]=n;let i=o.length>>1;this.select(o,new Float64Array(o.length),0,o.length,i,this.longestCentroidAxis(o,0,o.length)),this.leafCount[t]=0;let s=this.allocNode(t),a=this.allocNode(t);for(let l=0;l<i;l++)this.placeInLeaf(s,o[l]);for(let l=i;l<o.length;l++)this.placeInLeaf(a,o[l]);this.left[t]=s,this.right[t]=a,this.computeBox(s),this.computeBox(a)}longestCentroidAxis(t,n,r){let o=this.dim,i=this.itemCentroid2,s=0,a=-1;for(let l=0;l<this.dim;l++){let u=1/0,c=-1/0;for(let d=n;d<r;d++){let f=i[t[d]*o+l];f<u&&(u=f),f>c&&(c=f)}c-u>a&&(a=c-u,s=l)}return s}select(t,n,r,o,i,s){let a=this.dim,l=this.itemCentroid2;for(let d=r;d<o;d++)n[d]=l[t[d]*a+s];let u=r,c=o-1;for(;u<c;){let d=n[u+c>>1],f=u,p=c;for(;f<=p;){for(;n[f]<d;)f++;for(;n[p]>d;)p--;if(f<=p){let h=t[f];t[f]=t[p],t[p]=h;let m=n[f];n[f]=n[p],n[p]=m,f++,p--}}if(i<=p)c=p;else if(i>=f)u=f;else return}}}});function sf(e,t,n,r){e.ensureHeap(t+1);let o=e.heapT,i=e.heapId,s=t;for(;s>0;){let a=s-1>>1;if(o[a]<=n)break;o[s]=o[a],i[s]=i[a],s=a}return o[s]=n,i[s]=r,t+1}function P6(e,t){let n=e.heapT,r=e.heapId,o=t-1,i=n[o],s=r[o],a=0;for(;;){let l=2*a+1;if(l>=o||(l+1<o&&n[l+1]<n[l]&&l++,n[l]>=i))break;n[a]=n[l],r[a]=r[l],a=l}n[a]=i,r[a]=s}function uA(e,t,n,r,o,i){for(let s=0;s<n;s++)if(e[t+s]>r[i+s]||r[o+s]>e[t+n+s])return!1;return!0}function pb(e,t,n,r,o,i){if(e.root===-1)return;let s=t.take(),a=e.dim,l=2*a;try{let u=s.stackAt(0),c=0;for(u[c++]=e.root;c>0;){let d=u[--c];if(uA(e.nodeBox,d*l,a,n,r,o)){if(e.left[d]===-1){let f=d*4;for(let p=0;p<e.leafCount[d];p++){let h=e.leafItems[f+p];if(uA(e.itemBox,h*l,a,n,r,o)&&i(e.keys[h])===!1)return}continue}u=s.stackAt(c+1),u[c++]=e.left[d],u[c++]=e.right[d]}}}finally{s.release()}}function cA(e,t,n,r){for(let o=0;o<r.length;o++){let{normal:i,offset:s}=r[o],a=s;for(let l=0;l<n;l++)a+=i[l]*(i[l]>=0?e[t+n+l]:e[t+l]);if(a<0)return!1}return!0}function dA(e,t,n,r){if(e.root===-1)return;let o=t.take(),i=e.dim,s=2*i;try{let a=o.stackAt(0),l=0;for(a[l++]=e.root;l>0;){let u=a[--l];if(cA(e.nodeBox,u*s,i,n)){if(e.left[u]===-1){let c=u*4;for(let d=0;d<e.leafCount[u];d++){let f=e.leafItems[c+d];if(cA(e.itemBox,f*s,i,n)&&r(e.keys[f])===!1)return}continue}a=o.stackAt(l+1),a[l++]=e.left[u],a[l++]=e.right[u]}}}finally{o.release()}}function af(e,t,n,r,o,i){let s=0,a=i;for(let l=0;l<n;l++){let u=e[t+l],c=e[t+n+l];if(o[l]===0){if(r[l]<u||r[l]>c)return-1;continue}let d=(u-r[l])/o[l],f=(c-r[l])/o[l];if(d<f?(d>s&&(s=d),f<a&&(a=f)):(f>s&&(s=f),d<a&&(a=d)),s>a)return-1}return s}function fA(e,t,n,r,o,i){if(e.root===-1)return;let s=e.dim,a=2*s,l=af(e.nodeBox,e.root*a,s,n,r,i);if(l<0)return;let u=t.take();try{let c=sf(u,0,l,e.root);for(;c>0;){let d=u.heapT[0],f=u.heapId[0];if(P6(u,c--),f<0){if(o(e.keys[-f-1],d)===!1)return;continue}if(e.left[f]===-1){let b=f*4;for(let x=0;x<e.leafCount[f];x++){let w=e.leafItems[b+x],g=af(e.itemBox,w*a,s,n,r,i);g>=0&&(c=sf(u,c,g,-w-1))}continue}let p=e.left[f],h=e.right[f],m=af(e.nodeBox,p*a,s,n,r,i);m>=0&&(c=sf(u,c,m,p));let y=af(e.nodeBox,h*a,s,n,r,i);y>=0&&(c=sf(u,c,y,h))}}finally{u.release()}}var lf,pA=J(()=>{"use strict";lf=class e{stack=new Int32Array(64);heapT=new Float64Array(64);heapId=new Int32Array(64);busy=!1;take(){return this.busy?new e:(this.busy=!0,this)}release(){this.busy=!1}stackAt(t){if(t>=this.stack.length){let n=new Int32Array(this.stack.length*2);n.set(this.stack),this.stack=n}return this.stack}ensureHeap(t){if(t<this.heapT.length)return;let n=new Float64Array(this.heapT.length*2),r=new Int32Array(this.heapId.length*2);n.set(this.heapT),r.set(this.heapId),this.heapT=n,this.heapId=r}}});function hA(e){return 2*Math.ceil(Math.log2(Math.max(e,2)))}function S6(e){let t=0;for(;e>4;e=Math.ceil(e/2))t++;return t}function hb(e,t){if(e.length<2*t)return!1;for(let n=0;n<t;n++){let r=e[n],o=e[t+n];if(!Number.isFinite(r)||!Number.isFinite(o)||r>o)return!1}return!0}function yb(e,t){if(!Number.isInteger(e)||e<1)throw new RangeError(`createBvh: dim must be a positive integer, got ${e}`);let n=new mb(e);return t&&(n.load(t),n.rebuild()),n}var T6,mb,mA=J(()=>{"use strict";lA();pA();T6=.7;mb=class{dim;tree;items=new Map;scratch=new lf;peakSize=0;constructor(t){this.dim=t,this.tree=new of(t)}get size(){return this.items.size}load(t){for(let[n,r]of t){if(!hb(r,this.dim))continue;let o=this.items.get(n);if(o!==void 0){this.tree.writeItemBox(o,r);continue}let i=this.tree.allocItem(n,r);this.tree.itemLeaf[i]=0,this.items.set(n,i)}}insert(t,n){if(!hb(n,this.dim))return!1;if(this.items.has(t))return this.update(t,n);let r=this.tree.allocItem(t,n);return this.items.set(t,r),this.items.size>this.peakSize&&(this.peakSize=this.items.size),this.place(r),!0}update(t,n){let r=this.items.get(t);if(r===void 0||!hb(n,this.dim))return!1;let o=this.tree,i=o.itemLeaf[r];return this.leafHolds(i,n)?(o.writeItemBox(r,n),!0):(this.detach(r),o.writeItemBox(r,n),this.place(r),!0)}remove(t){let n=this.items.get(t);return n===void 0?!1:(this.detach(n),this.items.delete(t),this.tree.freeItem(n),this.items.size<this.peakSize>>1&&this.rebuild(),!0)}refit(){let t=this.tree;if(t.root===-1)return;let n=this.scratch.take();try{let r=n.stackAt(0);r[0]=t.root;let o=1;for(let i=0;i<o;i++){let s=r[i];t.left[s]!==-1&&(r=n.stackAt(o+1),r[o++]=t.left[s],r[o++]=t.right[s])}for(let i=o-1;i>=0;i--)t.computeBox(r[i])}finally{n.release()}}rebuild(){this.tree.build(),this.peakSize=this.items.size}maxDepth(){let t=this.tree;if(t.root===-1)return 0;let n=0,r=[[t.root,0]];for(;r.length>0;){let[o,i]=r.pop();t.left[o]===-1?n=Math.max(n,i):r.push([t.left[o],i+1],[t.right[o],i+1])}return n}queryBox(t,n){pb(this.tree,this.scratch,t,0,this.dim,n)}queryPoint(t,n){pb(this.tree,this.scratch,t,0,0,n)}raycast(t,n,r,o=1/0){fA(this.tree,this.scratch,t,n,r,o)}queryHalfSpaces(t,n){dA(this.tree,this.scratch,t,n)}leafHolds(t,n){let r=this.dim,o=t*2*r,i=this.tree.nodeBox;for(let s=0;s<r;s++)if(n[s]<i[o+s]||n[r+s]>i[o+r+s])return!1;return!0}place(t){let n=this.tree;if(n.root===-1){n.root=n.allocNode(-1),n.placeInLeaf(n.root,t),n.computeBox(n.root);return}let r=n.root,o=0;for(;n.left[r]!==-1;){let i=n.left[r],s=n.right[r],a=this.enlargement(i,t),l=this.enlargement(s,t);r=a<l||a===l&&n.count[i]<=n.count[s]?i:s,o++}n.leafCount[r]<4?n.placeInLeaf(r,t):(n.splitLeaf(r,t),o++),n.refitUp(r),o>hA(this.items.size)&&this.rebalance(n.itemLeaf[t],o)}rebalance(t,n){let r=this.tree,o=hA(this.items.size),i=-1;for(let s=t,a=r.parent[t],l=n-1;a!==-1;s=a,a=r.parent[a],l--)if(!(l+S6(r.count[a])>o)){if(r.count[s]>T6*r.count[a]){r.rebuildSubtree(a);return}i===-1&&(i=a)}i!==-1?r.rebuildSubtree(i):this.rebuild()}enlargement(t,n){let r=this.dim,o=this.tree.nodeBox,i=this.tree.itemBox,s=t*2*r,a=n*2*r,l=0;for(let u=0;u<r;u++){let c=Math.min(o[s+u],i[a+u]),d=Math.max(o[s+r+u],i[a+r+u]);l+=d-c-(o[s+r+u]-o[s+u])}return l}detach(t){let n=this.tree,r=n.itemLeaf[t],o=r*4,i=n.leafCount[r];for(let u=0;u<i;u++)if(n.leafItems[o+u]===t){n.leafItems[o+u]=n.leafItems[o+i-1];break}if(n.leafCount[r]=i-1,n.itemLeaf[t]=-1,i>1){n.refitUp(r);return}let s=n.parent[r];if(n.freeNode(r),s===-1){n.root=-1;return}let a=n.left[s]===r?n.right[s]:n.left[s],l=n.parent[s];n.parent[a]=l,l===-1?n.root=a:n.left[l]===s?n.left[l]=a:n.right[l]=a,n.freeNode(s),n.refitUp(l)}}});function yA(e,t){let n=[],r=[];for(let{segs:i,closed:s}of e){n.push(se),r.push(i[0][0].x,i[0][0].y);for(let a of i){n.push(a.length===2?ae:a.length===3?we:be);for(let l=1;l<a.length;l++)r.push(a[l].x,a[l].y)}s&&n.push(fe)}let o=Sn(r);return{kind:"polygon",commands:new Uint8Array(n),coords:At(o,r),fillRule:t,...o?{origin:o}:{}}}var gA=J(()=>{"use strict";Ye();rn()});function bb(e,t,n={}){let r=new De;if(!(t>0))return r.build();let o=nf(e)<0?-1:1,i={d:t,sigma:o,tol:n.tolerance??.1,join:n.join??"miter",miterLimit:n.miterLimit??4};for(let s of pi(e)){let a=s.segs.filter(c=>!_6(c));if(a.length===0)continue;let l=a.at(-1).c,u=a[0].c;(l[6]!==u[0]||l[7]!==u[1])&&a.push(Ue(l[6],l[7],u[0],u[1])),H6(r,A6(a,i))}return r.build()}function A6(e,t){let n=e.map(r=>({pieces:gb(r,t,0),join:[]}));for(let r=0;r<e.length;r++){let o=(r+1)%e.length,i=PA(e[r].c),s=wA(e[o].c),a=[e[o].c[0],e[o].c[1]];n[r].join=R6(n[r],n[o],a,i,s,t)}return n}function R6(e,t,n,r,o,i){let s=B6(e.pieces.at(-1)),a=D6(t.pieces[0]),l=Math.hypot(a[0]-s[0],a[1]-s[1]);if(l<=i.tol*.001)return[];let u=r[0]*o[1]-r[1]*o[0],c=r[0]*o[0]+r[1]*o[1],d=i.sigma*u>0||Math.abs(u)<1e-9&&c<0;if(l<=i.tol)return N6(e,t,s);if(!d)return E6(e,t)?[]:[Ue(s[0],s[1],n[0],n[1]),Ue(n[0],n[1],a[0],a[1])];let f=uf(r,i.sigma),p=uf(o,i.sigma);if(i.join==="round")return O6(n,i.d,f,Math.atan2(u,c));let h=f[0]*p[0]+f[1]*p[1];if(1+h<1e-9||Math.sqrt(2/(1+h))>i.miterLimit)return[Ue(s[0],s[1],a[0],a[1])];let m=i.d/(1+h),y=[n[0]+(f[0]+p[0])*m,n[1]+(f[1]+p[1])*m];return I6(e,t,y)}function N6(e,t,n){let r=t.pieces[0];return r===e.pieces.at(-1)?[Ue(r.c[6],r.c[7],n[0],n[1])]:(t.pieces[0]=r.line?Ue(n[0],n[1],r.c[6],r.c[7]):{c:[n[0],n[1],r.c[2]+n[0]-r.c[0],r.c[3]+n[1]-r.c[1],r.c[4],r.c[5],r.c[6],r.c[7]],line:!1},[])}function I6(e,t,n){let r=e.pieces.at(-1),o=t.pieces[0],i=[];return r.line&&r!==o?e.pieces[e.pieces.length-1]=Ue(r.c[0],r.c[1],n[0],n[1]):i.push(Ue(r.c[6],r.c[7],n[0],n[1])),o.line&&r!==o?t.pieces[0]=Ue(n[0],n[1],o.c[6],o.c[7]):i.push(Ue(n[0],n[1],o.c[0],o.c[1])),i}function E6(e,t){let n=e.pieces.at(-1),r=t.pieces[0];if(n===r)return!1;let o=M6(n.c,r.c);if(o===null)return!1;let i=o[0]>=1?n:Ts(n,o[0])[0],s=o[1]<=0?r:Ts(r,o[1])[1],a=(i.c[6]+s.c[0])/2,l=(i.c[7]+s.c[1])/2;return e.pieces[e.pieces.length-1]=i.line?Ue(i.c[0],i.c[1],a,l):{c:[i.c[0],i.c[1],i.c[2],i.c[3],i.c[4]+a-i.c[6],i.c[5]+l-i.c[7],a,l],line:!1},t.pieces[0]=s.line?Ue(a,l,s.c[6],s.c[7]):{c:[a,l,s.c[2]+a-s.c[0],s.c[3]+l-s.c[1],s.c[4],s.c[5],s.c[6],s.c[7]],line:!1},!0}function M6(e,t){let n=bA(e),r=bA(t),o=null,i=1/0;for(let s=0;s<As;s++)for(let a=0;a<As;a++){let l=C6(n[s],n[s+1],r[a],r[a+1]);if(l===null)continue;let u=(s+l[0])/As,c=(a+l[1])/As;u<=1e-9||c>=1-1e-9||1-u+c>=i||(i=1-u+c,o=[u,c])}return o}function bA(e){let t=[];for(let n=0;n<=As;n++)t.push(Ve(...e,n/As));return t}function C6(e,t,n,r){let o=t[0]-e[0],i=t[1]-e[1],s=r[0]-n[0],a=r[1]-n[1],l=o*a-i*s;if(Math.abs(l)<1e-18)return null;let u=((n[0]-e[0])*a-(n[1]-e[1])*s)/l,c=((n[0]-e[0])*i-(n[1]-e[1])*o)/l;return u>=0&&u<=1&&c>=0&&c<=1?[u,c]:null}function O6(e,t,n,r){let o=Math.max(1,Math.ceil(Math.abs(r)/(Math.PI/2))),i=r/o,s=4/3*Math.tan(i/4)*t,a=Math.atan2(n[1],n[0]),l=[];for(let u=0;u<o;u++){let c=a+i*u,d=c+i,f=e[0]+Math.cos(c)*t,p=e[1]+Math.sin(c)*t,h=e[0]+Math.cos(d)*t,m=e[1]+Math.sin(d)*t;l.push({c:[f,p,f-Math.sin(c)*s,p+Math.cos(c)*s,h+Math.sin(d)*s,m-Math.cos(d)*s,h,m],line:!1})}return l}function gb(e,t,n){let r=e.c,o=uf(wA(r),t.sigma),i=uf(PA(r),t.sigma),{d:s}=t;if(e.line)return[Ue(r[0]+o[0]*s,r[1]+o[1]*s,r[6]+o[0]*s,r[7]+o[1]*s)];let a=Math.max(0,1+t.sigma*s*xA(r,0)),l=Math.max(0,1+t.sigma*s*xA(r,1)),u=r[0]+o[0]*s,c=r[1]+o[1]*s,d=r[6]+i[0]*s,f=r[7]+i[1]*s,p={c:[u,c,u+(r[2]-r[0])*a,c+(r[3]-r[1])*a,d+(r[4]-r[6])*l,f+(r[5]-r[7])*l,d,f],line:!1};if(n>=k6||F6(r,p.c,t)<=t.tol)return[p];let[h,m]=Ts(e,.5);return[...gb(h,t,n+1),...gb(m,t,n+1)]}function F6(e,t,n){let r=0;for(let o of v6){let[i,s]=L6(e,o),a=Math.hypot(i,s);if(a<1e-12)continue;let[l,u]=Ve(...e,o),c=l+n.sigma*s/a*n.d,d=u-n.sigma*i/a*n.d,[f,p]=Ve(...t,o);r=Math.max(r,Math.hypot(f-c,p-d))}return r}function L6(e,t){let n=1-t,r=3*n*n,o=6*n*t,i=3*t*t;return[r*(e[2]-e[0])+o*(e[4]-e[2])+i*(e[6]-e[4]),r*(e[3]-e[1])+o*(e[5]-e[3])+i*(e[7]-e[5])]}function xA(e,t){let[n,r]=t===0?[e[2]-e[0],e[3]-e[1]]:[e[6]-e[4],e[7]-e[5]],[o,i]=t===0?[e[0]-2*e[2]+e[4],e[1]-2*e[3]+e[5]]:[e[6]-2*e[4]+e[2],e[7]-2*e[5]+e[3]],s=Math.hypot(n,r);return s<1e-12?0:2/3*(n*i-r*o)/(s*s*s)}function wA(e){return Rs(e[2]-e[0],e[3]-e[1])??Rs(e[4]-e[0],e[5]-e[1])??Rs(e[6]-e[0],e[7]-e[1])??[1,0]}function PA(e){return Rs(e[6]-e[4],e[7]-e[5])??Rs(e[6]-e[2],e[7]-e[3])??Rs(e[6]-e[0],e[7]-e[1])??[1,0]}function Rs(e,t){let n=Math.hypot(e,t);return n<1e-12?null:[e/n,t/n]}function uf(e,t){return[t*e[1],-t*e[0]]}function _6(e){let t=e.c;return t[0]===t[6]&&t[1]===t[7]&&t[0]===t[2]&&t[1]===t[3]&&t[0]===t[4]&&t[1]===t[5]}function H6(e,t){let n=t[0].pieces[0];e.moveTo(n.c[0],n.c[1]);for(let r of t)for(let o of[...r.pieces,...r.join])o.line?e.lineTo(o.c[6],o.c[7]):e.curveTo(o.c[2],o.c[3],o.c[4],o.c[5],o.c[6],o.c[7]);e.close()}var k6,v6,As,D6,B6,TA=J(()=>{"use strict";Pn();gr();rf();lb();k6=6,v6=[.2,.35,.5,.65,.8];As=32;D6=e=>[e.c[0],e.c[1]],B6=e=>[e.c[6],e.c[7]]});function RA(e){let t=e.map(o=>G6(o)),n=t.map(U6),r=[];for(let o=0;o<e.length;o++)for(let i=o+1;i<e.length;i++){if(!yg(n[o],n[i]))continue;let s=t[o],a=t[i];for(let l=0;l+1<s.length;l++)for(let u=0;u+1<a.length;u++){let c=W6(s[l],s[l+1],a[u],a[u+1]);if(c===null)continue;let d=[(l+c[0])/(s.length-1),(u+c[1])/(a.length-1)],[f,p]=e[o].line&&e[i].line?d:V6(e[o].c,e[i].c,d);vA(f)&&vA(p)||r.some(h=>h.a===o&&h.b===i&&Math.abs(h.s-f)<1e-6&&Math.abs(h.t-p)<1e-6)||r.push({a:o,b:i,s:f,t:p})}}return r}function G6(e){if(e.line)return[[e.c[0],e.c[1]],[e.c[6],e.c[7]]];let t=[];for(let n=0;n<=SA;n++)t.push(Ve(...e.c,n/SA));return t}function U6(e){let t=[1/0,1/0,-1/0,-1/0];for(let[n,r]of e)t[0]=Math.min(t[0],n),t[1]=Math.min(t[1],r),t[2]=Math.max(t[2],n),t[3]=Math.max(t[3],r);return t}function W6(e,t,n,r){let o=t[0]-e[0],i=t[1]-e[1],s=r[0]-n[0],a=r[1]-n[1],l=o*a-i*s;if(Math.abs(l)<1e-18)return null;let u=((n[0]-e[0])*a-(n[1]-e[1])*s)/l,c=((n[0]-e[0])*i-(n[1]-e[1])*o)/l;return u>=0&&u<=1&&c>=0&&c<=1?[u,c]:null}function V6(e,t,n){let r=(l,u)=>{let c=Ve(...e,l),d=Ve(...t,u);return[c[0]-d[0],c[1]-d[1]]},[o,i]=n,s=r(o,i),a=Math.hypot(...s);for(let l=0;l<8&&Math.hypot(...s)>1e-13;l++){let u=AA(e,o),c=AA(t,i),d=-u[0]*c[1]+c[0]*u[1];if(Math.abs(d)<1e-18)break;o=Math.min(1,Math.max(0,o-(-c[1]*s[0]+c[0]*s[1])/d)),i=Math.min(1,Math.max(0,i-(-u[1]*s[0]+u[0]*s[1])/d)),s=r(o,i)}return Math.hypot(...s)<=a?[o,i]:n}function AA(e,t){let n=1-t,r=3*n*n,o=6*n*t,i=3*t*t;return[r*(e[2]-e[0])+o*(e[4]-e[2])+i*(e[6]-e[4]),r*(e[3]-e[1])+o*(e[5]-e[3])+i*(e[7]-e[5])]}var SA,kA,vA,NA=J(()=>{"use strict";Rl();Pn();SA=16,kA=1e-7;vA=e=>e<kA||e>1-kA});function wb(e,t={}){let n=t.tolerance??.01,r=pi(e).filter(d=>d.segs.length>0),o=r.flatMap(d=>IA(d.segs,n*.001)),i=nf(e)<0,s=o.map(()=>[]);for(let d of RA(o)){let f=z6(o[d.a],d.s,o[d.b],d.t);s[d.a].push({t:d.s,p:f}),s[d.b].push({t:d.t,p:f})}let a=$6(o,n/4),l=[],u=!1;o.forEach((d,f)=>{let p=K6(d,s[f]);p.length>1&&(u=!0);for(let h of p){let m=Y6(h,a,n);m===null?u=!0:m===i?l.push(h):(u=!0,l.push(j6(h)))}});let c=new De;if(!u){for(let d of r)MA(c,IA(d.segs,n*.001));return c.build()}for(let d of q6(l))MA(c,d);return c.build()}function IA(e,t){let n=o=>o.line&&Math.hypot(o.c[6]-o.c[0],o.c[7]-o.c[1])<=t,r=e.filter(o=>!n(o));if(r.length===0)return[];for(let o=0;o<r.length;o++){let i=r[(o+r.length-1)%r.length].c,s=r[o];(i[6]!==s.c[0]||i[7]!==s.c[1])&&(Math.hypot(i[6]-s.c[0],i[7]-s.c[1])<=t?r[o]=xb(s,[i[6],i[7]],[s.c[6],s.c[7]]):o===0&&r.push(Ue(i[6],i[7],s.c[0],s.c[1])))}return r}function z6(e,t,n,r){let o=(l,u)=>u<=1e-7?[l.c[0],l.c[1]]:u>=.9999999?[l.c[6],l.c[7]]:null,i=o(e,t)??o(n,r);if(i)return i;let s=Ve(...e.c,t),a=Ve(...n.c,r);return[(s[0]+a[0])/2,(s[1]+a[1])/2]}function K6(e,t){let n=t.filter(a=>a.t>1e-7&&a.t<.9999999).sort((a,l)=>a.t-l.t),r=[],o=e,i=0,s=[e.c[0],e.c[1]];for(let a of n){if(a.t-i<1e-9)continue;let[l,u]=Ts(o,(a.t-i)/(1-i));r.push(xb(l,s,a.p)),o=u,i=a.t,s=a.p}return r.push(xb(o,s,[e.c[6],e.c[7]])),r}function xb(e,t,n){let r=e.c;return{c:[t[0],t[1],r[2]+t[0]-r[0],r[3]+t[1]-r[1],r[4]+n[0]-r[6],r[5]+n[1]-r[7],n[0],n[1]],line:e.line}}function j6(e){let t=e.c;return{c:[t[6],t[7],t[4],t[5],t[2],t[3],t[0],t[1]],line:e.line}}function $6(e,t){let n=[],r=[];for(let{c:o,line:i}of e)r.length===0?r.push(o[0],o[1]):(r[r.length-2]!==o[0]||r[r.length-1]!==o[1])&&(n.push(r),r=[o[0],o[1]]),i?r.push(o[6],o[7]):mo(...o,t,r);return r.length>0&&n.push(r),n}function EA(e,t,n){let r=0;for(let o of e)for(let i=0;i+3<o.length;i+=2){let s=o[i+1],a=o[i+3];if(s>n==a>n)continue;let l=o[i],u=o[i+2];t>=l+(n-s)/(a-s)*(u-l)||(r+=s<=n?1:-1)}return r}function Y6(e,t,n){let r=e.c,[o,i]=Ve(...r,.5),s=r[6]+r[4]-r[2]-r[0],a=r[7]+r[5]-r[3]-r[1],l=Math.hypot(s,a);if(l<1e-12)return null;let u=a/l*n,c=-s/l*n,d=EA(t,o+u,i+c)!==0,f=EA(t,o-u,i-c)!==0;return d===f?null:d}function q6(e){let t=(i,s)=>`${i},${s}`,n=new Map;e.forEach((i,s)=>{let a=t(i.c[0],i.c[1]),l=n.get(a);l?l.push(s):n.set(a,[s])});let r=new Uint8Array(e.length),o=[];for(let i=0;i<e.length;i++){if(r[i])continue;let s=[],a=i;for(;a!==void 0&&!r[a];){r[a]=1;let l=e[a];s.push(l),a=n.get(t(l.c[6],l.c[7]))?.find(u=>!r[u])}o.push(s)}return o}function MA(e,t){if(t.length===0)return;let[n,r]=t[0].c;e.moveTo(n,r);for(let[o,{c:i,line:s}]of t.entries()){if(s&&o===t.length-1&&i[6]===n&&i[7]===r)break;s?e.lineTo(i[6],i[7]):e.curveTo(i[2],i[3],i[4],i[5],i[6],i[7])}e.close()}var CA=J(()=>{"use strict";Pn();ci();gr();rf();NA();lb()});function Ns(e,t,n,r,o,i){return new Float64Array([e,t,0,n,r,0,o,i,1])}function X6(){return Ns(1,0,0,1,0,0)}function Pb(e,t){let n=e[0],r=e[1],o=e[3],i=e[4],s=e[6],a=e[7],l=t[0],u=t[1],c=t[3],d=t[4],f=t[6],p=t[7];return Ns(n*l+o*u,r*l+i*u,n*c+o*d,r*c+i*d,n*f+o*p+s,r*f+i*p+a)}function J6(e,t,n){let r=Ns(1,0,0,1,t,n);return Pb(e,r)}function Q6(e,t,n){let r=Ns(t,0,0,n,0,0);return Pb(e,r)}function OA(e){return[e[0],e[1],e[3],e[4],e[6],e[7]]}function FA(e){return Ns(e[0],e[1],e[2],e[3],e[4],e[5])}function Z6(e){let t=hr(OA(e));return t&&FA(t)}function eW(e){return Float32Array.from(e)}function tW(e,t,n){let r=e[0],o=e[1],i=e[3],s=e[4],a=e[6],l=e[7];return[r*t+i*n+a,o*t+s*n+l]}function nW(e,t){return Ns(2/e,0,0,-2/t,-1,1)}function rW(e){return Math.sqrt(Math.abs(e[0]*e[4]-e[1]*e[3]))}function oW(e){let t=e[0]*e[0]+e[1]*e[1]+e[3]*e[3]+e[4]*e[4],n=e[0]*e[4]-e[1]*e[3];return Math.sqrt(Math.max(0,(t-Math.sqrt(Math.max(0,t*t-4*n*n)))/2))}var q,LA=J(()=>{"use strict";bs();q={identity:X6,toAffine:OA,fromAffine:FA,multiply:Pb,translated:J6,scaled:Q6,invert:Z6,toUniform:eW,apply:tW,screenToClip:nW,meanScaleOf:rW,minScaleOf:oW}});function Pr(e){let t=e.scale.x,n=e.scale.y,r=-e.x*t+0,o=-e.y*n+0;return new Float64Array([t,0,0,0,n,0,r,o,1])}var _A=J(()=>{"use strict"});function Tb(e){let t=e;return t.rotation&&t.x!=null&&t.y!=null&&t.width!=null&&t.height!=null?{cx:t.x+t.width/2,cy:t.y+t.height/2,rotation:t.rotation}:null}function DA(e,t,n,r){return e.kind==="rect"?sW(e.x,e.y,e.width,e.height,t,n,r):iW(e,t,n,r)}function iW(e,t,n,r){let o=Math.cos(r),i=Math.sin(r);if(e.origin)return Nt(e,[o,i,-i,o,t-t*o+n*i,n-t*i-n*o]);let{commands:s,coords:a}=e,l=new Float32Array(a.length);return Oe(s,a,(u,c)=>{for(let d=0,f=lo(u);d<f;d+=2){let p=a[c+d]-t,h=a[c+d+1]-n;l[c+d]=t+p*o-h*i,l[c+d+1]=n+p*i+h*o}}),{...e,coords:l}}function sW(e,t,n,r,o,i,s){let a=Math.cos(s),l=Math.sin(s),u=(g,P)=>{let S=g-o,v=P-i;return[o+S*a-v*l,i+S*l+v*a]},[c,d]=u(e,t),[f,p]=u(e+n,t),[h,m]=u(e+n,t+r),[y,b]=u(e,t+r),x=new Uint8Array([se,ae,ae,ae,fe]),w=new Float32Array([c,d,f,p,h,m,y,b]);return{kind:"polygon",commands:x,coords:w,fillRule:"nonzero"}}var BA=J(()=>{"use strict";Ye();zl()});function zn(e){let t=e?.transform;return!Array.isArray(t)||t.length!==4||t[0]===1&&t[1]===0&&t[2]===0&&t[3]===1?null:t}function Re(e){let t=e;if(!t||t.x==null||t.y==null||t.width==null||t.height==null)return null;let n=zn(t);if(!t.rotation&&!n)return null;let r=t.x+t.width/2,o=t.y+t.height/2;if(!n)return ao(r,o,t.rotation);let[i,s,a,l]=n,u=[i,s,a,l,r-(i*r+a*o),o-(s*r+l*o)];return t.rotation?ht(ao(r,o,t.rotation),u):u}function mi(e){if(!zn(e)){let n=Tb(e);return n&&ao(n.cx,n.cy,-n.rotation)}let t=Re(e);return t&&hr(t)}function Is(e,t){if(zn(t)){let r=Re(t);if(!r)return e;let[o,i,s,a]=r,l=Lv(Fv({a:o,b:i,c:s,d:a}));return Nt(e.kind==="polygon"&&!l?ze(e):e,r)}let n=Tb(t);return n?DA(e,n.cx,n.cy,n.rotation):e}var HA=J(()=>{"use strict";bs();Rt();zl();_v();BA()});function $l(e,t){if(e.kind==="rect")return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height?e:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height};let n=et(e);if(n.x===t.x&&n.y===t.y&&n.width===t.width&&n.height===t.height)return e;let r=mr(n.x,n.y,n.width,n.height,t.x,t.y,t.width,t.height);return Nt(e,r)}var GA=J(()=>{"use strict";bs();Qg();zl()});function UA(e){if(e===null||typeof e!="object")return;let{__ta:t,data:n}=e;if(!(typeof t!="string"||!Object.hasOwn(Yl,t)||!Array.isArray(n)))return Yl[t].from(n)}function Sb(e,t){let n=t(e);if(n!==void 0)return n;if(Array.isArray(e))return e.map(o=>Sb(o,t));if(!lW(e))return e;let r={};for(let o of Object.keys(e))r[o]=Sb(e[o],t);return r}function kb(e){return Sb(e,UA)}var Yl,nre,aW,lW,WA=J(()=>{"use strict";Yl={i8:Int8Array,u8:Uint8Array,u8c:Uint8ClampedArray,i16:Int16Array,u16:Uint16Array,i32:Int32Array,u32:Uint32Array,f32:Float32Array,f64:Float64Array},nre=new Map(Object.keys(Yl).map(e=>[Yl[e].name,e])),aW=e=>Object.prototype.toString.call(e).slice(8,-1);lW=e=>aW(e)==="Object"});var Z=J(()=>{"use strict";kl();hg();bs();Rl();Ye();ci();Vl();Wd();wv();gv();di();gr();Qg();rn();Rt();Fl();Vv();zl();$v();bv();rf();TA();CA();Gv();zv();LA();_A();HA();GA();WA()});function Ut(e){return e!=null&&(e.kind===void 0||e.kind==="solid")}var Gb=J(()=>{"use strict"});function Tr(e){return e===void 0?"":`trim(${DR(e.start??0)},${DR(e.end??1)},${e.pace??"length"})`}function DR(e){return typeof e=="number"?String(e):"length"in e?`l${e.length}`:"anchor"in e?`a${e.anchor}`:`s${e.subpath}`}var BR=J(()=>{"use strict"});function Ie(e,t=null){return e===It?t:e?.paint==null?null:e}function Ne(e,t=null){return e===It?t:e?.paint==null?null:e}var It,Ub=J(()=>{"use strict";It="inherit"});function Af(e){return Array.isArray(e)?`[${e.map(Af).join(",")}]`:typeof e!="object"||e===null?JSON.stringify(e)??"null":`{${Object.keys(e).sort().filter(n=>e[n]!==void 0).map(n=>`${JSON.stringify(n)}:${Af(e[n])}`).join(",")}}`}function bo(e){if(e==null)return"none";if(Ut(e))return`solid:${e.color}:${e.opacity??1}`;let t=HR.get(e);return t===void 0&&(t=Af(e),HR.set(e,t)),t}function Rf(e){return Ie(e)!==null}function Sr(e){let t=Ne(e);if(t===null)return!1;let n=t.width??1;return(typeof n=="number"?n:n.px)>0}function ru(e){if(!Sr(e))return"none";let t=GR.get(e);if(t===void 0){let{paint:n,width:r,join:o,cap:i,miterLimit:s,align:a,dash:l,...u}=e;t=Af({...u,width:r??1,join:o??"miter",cap:i??"butt",miterLimit:s??4,align:a??"center",dash:l??[]}),GR.set(e,t)}return`${t}|${bo(e.paint)}`}var HR,GR,UR=J(()=>{"use strict";Gb();Ub();HR=new WeakMap,GR=new WeakMap});function ou(e){return e!==void 0&&NW.has(e)}function Wb(e){return ou(e.kind)}function Vb(e){return e.kind==="image"}function Nf(e){return e.kind==="texture"||e.kind==="image"||ou(e.kind)}function If(e){let{units:t,origin:n,transform:r,opacity:o}=e;return{...t!==void 0?{units:t}:{},...n!==void 0?{origin:n}:{},...r!==void 0?{transform:r}:{},...o!==void 0?{opacity:o}:{}}}function zb(e){let{units:t,origin:n,transform:r,opacity:o,...i}=e;return i}var WR,NW,VR=J(()=>{"use strict";WR=["hatch","crosshatch","dots","chunks"],NW=new Set(WR)});function Ef(e,t){let n=t/2;return typeof e=="number"?Kb(e)?{left:e/2,right:e/2}:{left:n,right:n}:e==null||typeof e!="object"?{left:n,right:n}:{left:Kb(e.left)?e.left:n,right:Kb(e.right)?e.right:n}}function iu(e,t){return typeof e=="number"?e*t:{left:e.left*t,right:e.right*t}}function jb(e,t){let n=e/2;if(t)for(let r of t){let{left:o,right:i}=Ef(r,e);n=Math.max(n,o,i)}return n}var Kb,zR=J(()=>{"use strict";Kb=e=>typeof e=="number"&&Number.isFinite(e)&&e>=0});function Wt(e,t){return typeof e=="number"?e:!Number.isFinite(t)||t===0?e.px:e.px/t}function $b(e,t,n=1){if(t==="center")return e;let o=(t==="inner"?-1:1)*n/2;return{x:e.x-o,y:e.y-o,width:e.width+2*o,height:e.height+2*o}}function Mf(e,t){if(e===void 0||e.length===0)return"solid";if(!e.every(Number.isFinite))return"non-finite";if(e.some(n=>n<0)||!e.some(n=>n>0))return"solid";if(t!==void 0){let n=e.reduce((r,o)=>r+o,0);if(t/n*e.length>KR)return"solid"}return e}var KR,jR=J(()=>{"use strict";KR=1e5});function $R(e){if(!IW.test(e))return null;let t=e.slice(1),n=t.length<=4?t.replace(/./g,"$&$&"):t,r=o=>Number.parseInt(n.slice(o,o+2),16);return[r(0),r(2),r(4),n.length===8?r(6):255]}var IW,YR=J(()=>{"use strict";IW=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i});function qR(e){let t=e%Yb;return t>Math.PI?t-Yb:t<-Math.PI?t+Yb:t}var Yb,XR=J(()=>{"use strict";Yb=Math.PI*2});function Xb(e){if(e<=0)return 0;if(e>=1)return 255;let t=e<=.0031308?e*12.92:1.055*Math.pow(e,1/2.4)-.055;return Math.round(t*255)}function Cf(e,t,n){return EW(qb[e&255],qb[t&255],qb[n&255])}function EW(e,t,n){let r=.4122214708*e+.5363325363*t+.0514459929*n,o=.2119034982*e+.6806995451*t+.1073969566*n,i=.0883024619*e+.2817188376*t+.6299787005*n,s=Math.cbrt(r),a=Math.cbrt(o),l=Math.cbrt(i);return[.2104542553*s+.793617785*a-.0040720468*l,1.9779984951*s-2.428592205*a+.4505937099*l,.0259040371*s+.7827717662*a-.808675766*l]}function su(e,t,n){let r=e+.3963377774*t+.2158037573*n,o=e-.1055613458*t-.0638541728*n,i=e-.0894841775*t-1.291485548*n,s=r*r*r,a=o*o*o,l=i*i*i;return[4.0767416621*s-3.3077115913*a+.2309699292*l,-1.2684380046*s+2.6097574011*a-.3413193965*l,-.0041960863*s-.7034186147*a+1.707614701*l]}function JR(e,t,n){return e>=-1e-6&&e<=1+1e-6&&t>=-1e-6&&t<=1+1e-6&&n>=-1e-6&&n<=1+1e-6}function MW(e,t,n){let[r,o,i]=su(e,t,n);if(JR(r,o,i))return[r,o,i];let s=0,a=1;for(let l=0;l<5;l++){let u=(s+a)/2;[r,o,i]=su(e,t*u,n*u),JR(r,o,i)?s=u:a=u}return[r,o,i]=su(e,t*s,n*s),[r,o,i]}function QR(e,t,n){let[r,o,i]=MW(e,t,n);return[Xb(r),Xb(o),Xb(i)]}function CW(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function ZR(e,t,n){let r=Math.hypot(t,n),o=Math.atan2(n,t);return[e,r,o]}function Qb(e,t,n){return[e,t*Math.cos(n),t*Math.sin(n)]}function OW(e,t,n){let[r,o,i]=e,[s,a,l]=t,u=1e-4,c=o<u?l:i,d=a<u?i:l,f=qR(d-c);return[r+(s-r)*n,o+(a-o)*n,c+f*n]}function eN(e,t,n,r="rgb"){if(e.length!==t.length)throw new Error(`lerpColorArray: length mismatch (from=${e.length}, to=${t.length})`);if(e.length%4!==0)throw new Error(`lerpColorArray: length ${e.length} not divisible by 4`);let o=new Array(e.length),i=e.length/4;if(r==="rgb"){for(let s=0;s<e.length;s++)o[s]=e[s]+(t[s]-e[s])*n;return o}if(r==="oklch"){for(let s=0;s<i;s++){let a=s*4,l=Cf(on(e[a]),on(e[a+1]),on(e[a+2])),u=Cf(on(t[a]),on(t[a+1]),on(t[a+2])),c=ZR(l[0],l[1],l[2]),d=ZR(u[0],u[1],u[2]),f=OW(c,d,n),p=Qb(f[0],f[1],f[2]),[h,m,y]=QR(p[0],p[1],p[2]);o[a]=Bs(h),o[a+1]=Bs(m),o[a+2]=Bs(y),o[a+3]=e[a+3]+(t[a+3]-e[a+3])*n}return o}for(let s=0;s<i;s++){let a=s*4,l=Cf(on(e[a]),on(e[a+1]),on(e[a+2])),u=Cf(on(t[a]),on(t[a+1]),on(t[a+2])),c=CW(l,u,n),[d,f,p]=QR(c[0],c[1],c[2]);o[a]=Bs(d),o[a+1]=Bs(f),o[a+2]=Bs(p),o[a+3]=e[a+3]+(t[a+3]-e[a+3])*n}return o}function Zb(e){let t=Math.abs(e),n=t<=.0031308?t*12.92:1.055*Math.pow(t,1/2.4)-.055;return e<0?-n:n}function tN(e,t,n){if(t===0)return[n,n,n];let r=n<.5?n*(1+t):n+t-n*t,o=2*n-r,i=e/360;return[Jb(o,r,i+1/3),Jb(o,r,i),Jb(o,r,i-1/3)]}function Jb(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}var qb,on,Bs,ex=J(()=>{"use strict";XR();qb=(()=>{let e=new Float64Array(256);for(let t=0;t<256;t++){let n=t/255;e[t]=n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}return e})();on=e=>Math.max(0,Math.min(255,Math.round(e*255)));Bs=e=>e/255});function nN(e){let t=Of.get(e);if(t!==void 0)return t;let n=LW(e);return Of.size>=FW&&Of.clear(),Of.set(e,n),n}function LW(e){let t=e.trim();if(t.startsWith("#"))return DW(t);let n=t.toLowerCase(),r=WW[n];if(r!==void 0)return r;if(n.startsWith("rgb")){let o=BW(n);if(o)return o}if(n.startsWith("hsl")){let o=HW(n);if(o)return o}if(n.startsWith("color(")){let o=GW(n);if(o)return o}if(n.startsWith("ok")){let o=UW(n);if(o)return o}throw new Error(`parseColor: unrecognized color "${e}"`)}function $n(e){let t=Ff.get(e);if(t)return t;Ff.size>=_W&&Ff.clear();let r=nN(e);return Ff.set(e,r),r}function DW(e){let t=$R(e);if(!t)throw new Error(`parseColor: invalid hex "${e}"`);return[t[0]/255,t[1]/255,t[2]/255,t[3]/255]}function wi(e,t){return!e.startsWith(t+"(")||!e.endsWith(")")?null:e.slice(t.length+1,-1).trim()}function _f(e){if(e.includes(",")){let i=e.split(",").map(s=>s.trim());return i.length!==3&&i.length!==4?null:{rgb:[i[0],i[1],i[2]],alpha:i.length===4?i[3]:null}}let t=e.indexOf("/"),n=(t===-1?e:e.slice(0,t)).trim(),r=t===-1?null:e.slice(t+1).trim(),o=n.split(/\s+/);return o.length!==3||r!==null&&r===""?null:{rgb:[o[0],o[1],o[2]],alpha:r}}function Lf(e,t){if(e.endsWith("%")){let r=Number(e.slice(0,-1));return Number.isFinite(r)?jn(r/100):null}let n=Number(e);return Number.isFinite(n)?jn(n/t):null}function Df(e){if(e===null)return 1;if(e.endsWith("%")){let n=Number(e.slice(0,-1));return Number.isFinite(n)?jn(n/100):1}let t=Number(e);return Number.isFinite(t)?jn(t):1}function BW(e){let t=wi(e,"rgba")??wi(e,"rgb");if(t===null)return null;let n=_f(t);if(!n)return null;let r=Lf(n.rgb[0],255),o=Lf(n.rgb[1],255),i=Lf(n.rgb[2],255);return r===null||o===null||i===null?null:[r,o,i,Df(n.alpha)]}function HW(e){let t=wi(e,"hsla")??wi(e,"hsl");if(t===null)return null;let n=_f(t);if(!n)return null;let r=rN(n.rgb[0]),o=tx(n.rgb[1]),i=tx(n.rgb[2]);if(r===null||o===null||i===null)return null;let[s,a,l]=tN(r,o,i);return[s,a,l,Df(n.alpha)]}function GW(e){let t=wi(e,"color"),n=t?.match(/^(srgb-linear|srgb)\s+/);if(!t||!n||t.includes(","))return null;let r=_f(t.slice(n[0].length));if(!r)return null;let o=r.rgb.map(l=>Lf(l,1));if(o.some(l=>l===null))return null;let[i,s,a]=n[1]==="srgb"?o:o.map(l=>Zb(l));return[jn(i),jn(s),jn(a),Df(r.alpha)]}function UW(e){let t=wi(e,"oklch"),n=t??wi(e,"oklab");if(n===null||n.includes(","))return null;let r=_f(n);if(!r)return null;let o=tx(r.rgb[0]),i=Number(r.rgb[1]);if(o===null||!Number.isFinite(i))return null;let s=i,a=Number(r.rgb[2]);if(t!==null){let d=rN(r.rgb[2]);if(d===null)return null;[,s,a]=Qb(o,i,d*(Math.PI/180))}else if(!Number.isFinite(a))return null;let[l,u,c]=su(o,s,a).map(d=>jn(Zb(d)));return[l,u,c,Df(r.alpha)]}function rN(e){let t;return e.endsWith("deg")?t=Number(e.slice(0,-3)):e.endsWith("grad")?t=Number(e.slice(0,-4))*.9:e.endsWith("rad")?t=Number(e.slice(0,-3))*(180/Math.PI):e.endsWith("turn")?t=Number(e.slice(0,-4))*360:t=Number(e),Number.isFinite(t)?(t%360+360)%360:null}function tx(e){if(e.endsWith("%")){let n=Number(e.slice(0,-1));return Number.isFinite(n)?jn(n/100):null}let t=Number(e);return Number.isFinite(t)?jn(t):null}function jn(e){return e<0?0:e>1?1:e}var Of,FW,_W,Ff,WW,nx=J(()=>{"use strict";ex();YR();Of=new Map,FW=1024;_W=1024,Ff=new Map;WW=(()=>{let e={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},t={transparent:[0,0,0,0]};for(let n in e){let r=e[n];t[n]=[(r>>16&255)/255,(r>>8&255)/255,(r&255)/255,1]}return t})()});function rx(e){return[...e].sort((t,n)=>t.offset-n.offset).map(t=>({offset:t.offset,rgba:$n(t.color)}))}function ox(e,t,n="rgb"){if(e.length===0)return zW;let r=e[0],o=e[e.length-1];if(t<=r.offset)return r.rgba;if(t>=o.offset)return o.rgba;for(let i=0;i<e.length-1;i++){let s=e[i],a=e[i+1];if(t<s.offset||t>a.offset)continue;let l=a.offset-s.offset;if(l<=0)return a.rgba;let u=(t-s.offset)/l,[c,d,f,p]=eN(s.rgba,a.rgba,u,n);return[c,d,f,p]}return o.rgba}var zW,oN=J(()=>{"use strict";nx();ex();zW=[0,0,0,0]});var Pe=J(()=>{"use strict";Gb();BR();UR();Ub();VR();zR();jR();nx();oN()});var _I=yG((Yx,qx)=>{"use strict";(function(e,t){typeof Yx=="object"&&typeof qx<"u"?qx.exports=t():typeof define=="function"&&define.amd?define(t):(e=typeof globalThis<"u"?globalThis:e||self,e.polygonClipping=t())})(Yx,(function(){"use strict";function e(O,T){var k={label:0,sent:function(){if(I[0]&1)throw I[1];return I[1]},trys:[],ops:[]},R,E,I,H;return H={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(H[Symbol.iterator]=function(){return this}),H;function _(U){return function(X){return V([U,X])}}function V(U){if(R)throw new TypeError("Generator is already executing.");for(;k;)try{if(R=1,E&&(I=U[0]&2?E.return:U[0]?E.throw||((I=E.return)&&I.call(E),0):E.next)&&!(I=I.call(E,U[1])).done)return I;switch(E=0,I&&(U=[U[0]&2,I.value]),U[0]){case 0:case 1:I=U;break;case 4:return k.label++,{value:U[1],done:!1};case 5:k.label++,E=U[1],U=[0];continue;case 7:U=k.ops.pop(),k.trys.pop();continue;default:if(I=k.trys,!(I=I.length>0&&I[I.length-1])&&(U[0]===6||U[0]===2)){k=0;continue}if(U[0]===3&&(!I||U[1]>I[0]&&U[1]<I[3])){k.label=U[1];break}if(U[0]===6&&k.label<I[1]){k.label=I[1],I=U;break}if(I&&k.label<I[2]){k.label=I[2],k.ops.push(U);break}I[2]&&k.ops.pop(),k.trys.pop();continue}U=T.call(O,k)}catch(X){U=[6,X],E=0}finally{R=I=0}if(U[0]&5)throw U[1];return{value:U[0]?U[1]:void 0,done:!0}}}var t=(function(){function O(T,k){this.next=null,this.key=T,this.data=k,this.left=null,this.right=null}return O})();function n(O,T){return O>T?1:O<T?-1:0}function r(O,T,k){for(var R=new t(null,null),E=R,I=R;;){var H=k(O,T.key);if(H<0){if(T.left===null)break;if(k(O,T.left.key)<0){var _=T.left;if(T.left=_.right,_.right=T,T=_,T.left===null)break}I.left=T,I=T,T=T.left}else if(H>0){if(T.right===null)break;if(k(O,T.right.key)>0){var _=T.right;if(T.right=_.left,_.left=T,T=_,T.right===null)break}E.right=T,E=T,T=T.right}else break}return E.right=T.left,I.left=T.right,T.left=R.right,T.right=R.left,T}function o(O,T,k,R){var E=new t(O,T);if(k===null)return E.left=E.right=null,E;k=r(O,k,R);var I=R(O,k.key);return I<0?(E.left=k.left,E.right=k,k.left=null):I>=0&&(E.right=k.right,E.left=k,k.right=null),E}function i(O,T,k){var R=null,E=null;if(T){T=r(O,T,k);var I=k(T.key,O);I===0?(R=T.left,E=T.right):I<0?(E=T.right,T.right=null,R=T):(R=T.left,T.left=null,E=T)}return{left:R,right:E}}function s(O,T,k){return T===null?O:(O===null||(T=r(O.key,T,k),T.left=O),T)}function a(O,T,k,R,E){if(O){R(""+T+(k?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+E(O)+`
3
+ `);var I=T+(k?" ":"\u2502 ");O.left&&a(O.left,I,!1,R,E),O.right&&a(O.right,I,!0,R,E)}}var l=(function(){function O(T){T===void 0&&(T=n),this._root=null,this._size=0,this._comparator=T}return O.prototype.insert=function(T,k){return this._size++,this._root=o(T,k,this._root,this._comparator)},O.prototype.add=function(T,k){var R=new t(T,k);this._root===null&&(R.left=R.right=null,this._size++,this._root=R);var E=this._comparator,I=r(T,this._root,E),H=E(T,I.key);return H===0?this._root=I:(H<0?(R.left=I.left,R.right=I,I.left=null):H>0&&(R.right=I.right,R.left=I,I.right=null),this._size++,this._root=R),this._root},O.prototype.remove=function(T){this._root=this._remove(T,this._root,this._comparator)},O.prototype._remove=function(T,k,R){var E;if(k===null)return null;k=r(T,k,R);var I=R(T,k.key);return I===0?(k.left===null?E=k.right:(E=r(T,k.left,R),E.right=k.right),this._size--,E):k},O.prototype.pop=function(){var T=this._root;if(T){for(;T.left;)T=T.left;return this._root=r(T.key,this._root,this._comparator),this._root=this._remove(T.key,this._root,this._comparator),{key:T.key,data:T.data}}return null},O.prototype.findStatic=function(T){for(var k=this._root,R=this._comparator;k;){var E=R(T,k.key);if(E===0)return k;E<0?k=k.left:k=k.right}return null},O.prototype.find=function(T){return this._root&&(this._root=r(T,this._root,this._comparator),this._comparator(T,this._root.key)!==0)?null:this._root},O.prototype.contains=function(T){for(var k=this._root,R=this._comparator;k;){var E=R(T,k.key);if(E===0)return!0;E<0?k=k.left:k=k.right}return!1},O.prototype.forEach=function(T,k){for(var R=this._root,E=[],I=!1;!I;)R!==null?(E.push(R),R=R.left):E.length!==0?(R=E.pop(),T.call(k,R),R=R.right):I=!0;return this},O.prototype.range=function(T,k,R,E){for(var I=[],H=this._comparator,_=this._root,V;I.length!==0||_;)if(_)I.push(_),_=_.left;else{if(_=I.pop(),V=H(_.key,k),V>0)break;if(H(_.key,T)>=0&&R.call(E,_))return this;_=_.right}return this},O.prototype.keys=function(){var T=[];return this.forEach(function(k){var R=k.key;return T.push(R)}),T},O.prototype.values=function(){var T=[];return this.forEach(function(k){var R=k.data;return T.push(R)}),T},O.prototype.min=function(){return this._root?this.minNode(this._root).key:null},O.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},O.prototype.minNode=function(T){if(T===void 0&&(T=this._root),T)for(;T.left;)T=T.left;return T},O.prototype.maxNode=function(T){if(T===void 0&&(T=this._root),T)for(;T.right;)T=T.right;return T},O.prototype.at=function(T){for(var k=this._root,R=!1,E=0,I=[];!R;)if(k)I.push(k),k=k.left;else if(I.length>0){if(k=I.pop(),E===T)return k;E++,k=k.right}else R=!0;return null},O.prototype.next=function(T){var k=this._root,R=null;if(T.right){for(R=T.right;R.left;)R=R.left;return R}for(var E=this._comparator;k;){var I=E(T.key,k.key);if(I===0)break;I<0?(R=k,k=k.left):k=k.right}return R},O.prototype.prev=function(T){var k=this._root,R=null;if(T.left!==null){for(R=T.left;R.right;)R=R.right;return R}for(var E=this._comparator;k;){var I=E(T.key,k.key);if(I===0)break;I<0?k=k.left:(R=k,k=k.right)}return R},O.prototype.clear=function(){return this._root=null,this._size=0,this},O.prototype.toList=function(){return d(this._root)},O.prototype.load=function(T,k,R){k===void 0&&(k=[]),R===void 0&&(R=!1);var E=T.length,I=this._comparator;if(R&&h(T,k,0,E-1,I),this._root===null)this._root=u(T,k,0,E),this._size=E;else{var H=p(this.toList(),c(T,k),I);E=this._size+E,this._root=f({head:H},0,E)}return this},O.prototype.isEmpty=function(){return this._root===null},Object.defineProperty(O.prototype,"size",{get:function(){return this._size},enumerable:!0,configurable:!0}),Object.defineProperty(O.prototype,"root",{get:function(){return this._root},enumerable:!0,configurable:!0}),O.prototype.toString=function(T){T===void 0&&(T=function(R){return String(R.key)});var k=[];return a(this._root,"",!0,function(R){return k.push(R)},T),k.join("")},O.prototype.update=function(T,k,R){var E=this._comparator,I=i(T,this._root,E),H=I.left,_=I.right;E(T,k)<0?_=o(k,R,_,E):H=o(k,R,H,E),this._root=s(H,_,E)},O.prototype.split=function(T){return i(T,this._root,this._comparator)},O.prototype[Symbol.iterator]=function(){var T,k,R;return e(this,function(E){switch(E.label){case 0:T=this._root,k=[],R=!1,E.label=1;case 1:return R?[3,6]:T===null?[3,2]:(k.push(T),T=T.left,[3,5]);case 2:return k.length===0?[3,4]:(T=k.pop(),[4,T]);case 3:return E.sent(),T=T.right,[3,5];case 4:R=!0,E.label=5;case 5:return[3,1];case 6:return[2]}})},O})();function u(O,T,k,R){var E=R-k;if(E>0){var I=k+Math.floor(E/2),H=O[I],_=T[I],V=new t(H,_);return V.left=u(O,T,k,I),V.right=u(O,T,I+1,R),V}return null}function c(O,T){for(var k=new t(null,null),R=k,E=0;E<O.length;E++)R=R.next=new t(O[E],T[E]);return R.next=null,k.next}function d(O){for(var T=O,k=[],R=!1,E=new t(null,null),I=E;!R;)T?(k.push(T),T=T.left):k.length>0?(T=I=I.next=k.pop(),T=T.right):R=!0;return I.next=null,E.next}function f(O,T,k){var R=k-T;if(R>0){var E=T+Math.floor(R/2),I=f(O,T,E),H=O.head;return H.left=I,O.head=O.head.next,H.right=f(O,E+1,k),H}return null}function p(O,T,k){for(var R=new t(null,null),E=R,I=O,H=T;I!==null&&H!==null;)k(I.key,H.key)<0?(E.next=I,I=I.next):(E.next=H,H=H.next),E=E.next;return I!==null?E.next=I:H!==null&&(E.next=H),R.next}function h(O,T,k,R,E){if(!(k>=R)){for(var I=O[k+R>>1],H=k-1,_=R+1;;){do H++;while(E(O[H],I)<0);do _--;while(E(O[_],I)>0);if(H>=_)break;var V=O[H];O[H]=O[_],O[_]=V,V=T[H],T[H]=T[_],T[_]=V}h(O,T,k,_,E),h(O,T,_+1,R,E)}}let m=(O,T)=>O.ll.x<=T.x&&T.x<=O.ur.x&&O.ll.y<=T.y&&T.y<=O.ur.y,y=(O,T)=>{if(T.ur.x<O.ll.x||O.ur.x<T.ll.x||T.ur.y<O.ll.y||O.ur.y<T.ll.y)return null;let k=O.ll.x<T.ll.x?T.ll.x:O.ll.x,R=O.ur.x<T.ur.x?O.ur.x:T.ur.x,E=O.ll.y<T.ll.y?T.ll.y:O.ll.y,I=O.ur.y<T.ur.y?O.ur.y:T.ur.y;return{ll:{x:k,y:E},ur:{x:R,y:I}}},b=Number.EPSILON;b===void 0&&(b=Math.pow(2,-52));let x=b*b,w=(O,T)=>{if(-b<O&&O<b&&-b<T&&T<b)return 0;let k=O-T;return k*k<x*O*T?0:O<T?-1:1};class g{constructor(){this.reset()}reset(){this.xRounder=new P,this.yRounder=new P}round(T,k){return{x:this.xRounder.round(T),y:this.yRounder.round(k)}}}class P{constructor(){this.tree=new l,this.round(0)}round(T){let k=this.tree.add(T),R=this.tree.prev(k);if(R!==null&&w(k.key,R.key)===0)return this.tree.remove(T),R.key;let E=this.tree.next(k);return E!==null&&w(k.key,E.key)===0?(this.tree.remove(T),E.key):T}}let S=new g,v=11102230246251565e-32,A=134217729,N=(3+8*v)*v;function M(O,T,k,R,E){let I,H,_,V,U=T[0],X=R[0],L=0,z=0;X>U==X>-U?(I=U,U=T[++L]):(I=X,X=R[++z]);let Y=0;if(L<O&&z<k)for(X>U==X>-U?(H=U+I,_=I-(H-U),U=T[++L]):(H=X+I,_=I-(H-X),X=R[++z]),I=H,_!==0&&(E[Y++]=_);L<O&&z<k;)X>U==X>-U?(H=I+U,V=H-I,_=I-(H-V)+(U-V),U=T[++L]):(H=I+X,V=H-I,_=I-(H-V)+(X-V),X=R[++z]),I=H,_!==0&&(E[Y++]=_);for(;L<O;)H=I+U,V=H-I,_=I-(H-V)+(U-V),U=T[++L],I=H,_!==0&&(E[Y++]=_);for(;z<k;)H=I+X,V=H-I,_=I-(H-V)+(X-V),X=R[++z],I=H,_!==0&&(E[Y++]=_);return(I!==0||Y===0)&&(E[Y++]=I),Y}function C(O,T){let k=T[0];for(let R=1;R<O;R++)k+=T[R];return k}function F(O){return new Float64Array(O)}let D=(3+16*v)*v,B=(2+12*v)*v,K=(9+64*v)*v*v,W=F(4),Q=F(8),le=F(12),ke=F(16),ue=F(4);function ve(O,T,k,R,E,I,H){let _,V,U,X,L,z,Y,ie,re,ge,de,Me,ct,$e,dt,ft,Zt,pt,hn=O-E,mn=k-E,yn=T-I,gn=R-I;$e=hn*gn,z=A*hn,Y=z-(z-hn),ie=hn-Y,z=A*gn,re=z-(z-gn),ge=gn-re,dt=ie*ge-($e-Y*re-ie*re-Y*ge),ft=yn*mn,z=A*yn,Y=z-(z-yn),ie=yn-Y,z=A*mn,re=z-(z-mn),ge=mn-re,Zt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Zt,L=dt-de,W[0]=dt-(de+L)+(L-Zt),Me=$e+de,L=Me-$e,ct=$e-(Me-L)+(de-L),de=ct-ft,L=ct-de,W[1]=ct-(de+L)+(L-ft),pt=Me+de,L=pt-Me,W[2]=Me-(pt-L)+(de-L),W[3]=pt;let dr=C(4,W),ul=B*H;if(dr>=ul||-dr>=ul||(L=O-hn,_=O-(hn+L)+(L-E),L=k-mn,U=k-(mn+L)+(L-E),L=T-yn,V=T-(yn+L)+(L-I),L=R-gn,X=R-(gn+L)+(L-I),_===0&&V===0&&U===0&&X===0)||(ul=K*H+N*Math.abs(dr),dr+=hn*X+gn*_-(yn*U+mn*V),dr>=ul||-dr>=ul))return dr;$e=_*gn,z=A*_,Y=z-(z-_),ie=_-Y,z=A*gn,re=z-(z-gn),ge=gn-re,dt=ie*ge-($e-Y*re-ie*re-Y*ge),ft=V*mn,z=A*V,Y=z-(z-V),ie=V-Y,z=A*mn,re=z-(z-mn),ge=mn-re,Zt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Zt,L=dt-de,ue[0]=dt-(de+L)+(L-Zt),Me=$e+de,L=Me-$e,ct=$e-(Me-L)+(de-L),de=ct-ft,L=ct-de,ue[1]=ct-(de+L)+(L-ft),pt=Me+de,L=pt-Me,ue[2]=Me-(pt-L)+(de-L),ue[3]=pt;let lG=M(4,W,4,ue,Q);$e=hn*X,z=A*hn,Y=z-(z-hn),ie=hn-Y,z=A*X,re=z-(z-X),ge=X-re,dt=ie*ge-($e-Y*re-ie*re-Y*ge),ft=yn*U,z=A*yn,Y=z-(z-yn),ie=yn-Y,z=A*U,re=z-(z-U),ge=U-re,Zt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Zt,L=dt-de,ue[0]=dt-(de+L)+(L-Zt),Me=$e+de,L=Me-$e,ct=$e-(Me-L)+(de-L),de=ct-ft,L=ct-de,ue[1]=ct-(de+L)+(L-ft),pt=Me+de,L=pt-Me,ue[2]=Me-(pt-L)+(de-L),ue[3]=pt;let uG=M(lG,Q,4,ue,le);$e=_*X,z=A*_,Y=z-(z-_),ie=_-Y,z=A*X,re=z-(z-X),ge=X-re,dt=ie*ge-($e-Y*re-ie*re-Y*ge),ft=V*U,z=A*V,Y=z-(z-V),ie=V-Y,z=A*U,re=z-(z-U),ge=U-re,Zt=ie*ge-(ft-Y*re-ie*re-Y*ge),de=dt-Zt,L=dt-de,ue[0]=dt-(de+L)+(L-Zt),Me=$e+de,L=Me-$e,ct=$e-(Me-L)+(de-L),de=ct-ft,L=ct-de,ue[1]=ct-(de+L)+(L-ft),pt=Me+de,L=pt-Me,ue[2]=Me-(pt-L)+(de-L),ue[3]=pt;let cG=M(uG,le,4,ue,ke);return ke[cG-1]}function G(O,T,k,R,E,I){let H=(T-I)*(k-E),_=(O-E)*(R-I),V=H-_,U=Math.abs(H+_);return Math.abs(V)>=D*U?V:-ve(O,T,k,R,E,I,U)}let j=(O,T)=>O.x*T.y-O.y*T.x,$=(O,T)=>O.x*T.x+O.y*T.y,ee=(O,T,k)=>{let R=G(O.x,O.y,T.x,T.y,k.x,k.y);return R>0?-1:R<0?1:0},te=O=>Math.sqrt($(O,O)),he=(O,T,k)=>{let R={x:T.x-O.x,y:T.y-O.y},E={x:k.x-O.x,y:k.y-O.y};return j(E,R)/te(E)/te(R)},xe=(O,T,k)=>{let R={x:T.x-O.x,y:T.y-O.y},E={x:k.x-O.x,y:k.y-O.y};return $(E,R)/te(E)/te(R)},Le=(O,T,k)=>T.y===0?null:{x:O.x+T.x/T.y*(k-O.y),y:k},Se=(O,T,k)=>T.x===0?null:{x:k,y:O.y+T.y/T.x*(k-O.x)},cr=(O,T,k,R)=>{if(T.x===0)return Se(k,R,O.x);if(R.x===0)return Se(O,T,k.x);if(T.y===0)return Le(k,R,O.y);if(R.y===0)return Le(O,T,k.y);let E=j(T,R);if(E==0)return null;let I={x:k.x-O.x,y:k.y-O.y},H=j(I,T)/E,_=j(I,R)/E,V=O.x+_*T.x,U=k.x+H*R.x,X=O.y+_*T.y,L=k.y+H*R.y,z=(V+U)/2,Y=(X+L)/2;return{x:z,y:Y}};class _e{static compare(T,k){let R=_e.comparePoints(T.point,k.point);return R!==0?R:(T.point!==k.point&&T.link(k),T.isLeft!==k.isLeft?T.isLeft?1:-1:Qt.compare(T.segment,k.segment))}static comparePoints(T,k){return T.x<k.x?-1:T.x>k.x?1:T.y<k.y?-1:T.y>k.y?1:0}constructor(T,k){T.events===void 0?T.events=[this]:T.events.push(this),this.point=T,this.isLeft=k}link(T){if(T.point===this.point)throw new Error("Tried to link already linked events");let k=T.point.events;for(let R=0,E=k.length;R<E;R++){let I=k[R];this.point.events.push(I),I.point=this.point}this.checkForConsuming()}checkForConsuming(){let T=this.point.events.length;for(let k=0;k<T;k++){let R=this.point.events[k];if(R.segment.consumedBy===void 0)for(let E=k+1;E<T;E++){let I=this.point.events[E];I.consumedBy===void 0&&R.otherSE.point.events===I.otherSE.point.events&&R.segment.consume(I.segment)}}}getAvailableLinkedEvents(){let T=[];for(let k=0,R=this.point.events.length;k<R;k++){let E=this.point.events[k];E!==this&&!E.segment.ringOut&&E.segment.isInResult()&&T.push(E)}return T}getLeftmostComparator(T){let k=new Map,R=E=>{let I=E.otherSE;k.set(E,{sine:he(this.point,T.point,I.point),cosine:xe(this.point,T.point,I.point)})};return(E,I)=>{k.has(E)||R(E),k.has(I)||R(I);let{sine:H,cosine:_}=k.get(E),{sine:V,cosine:U}=k.get(I);return H>=0&&V>=0?_<U?1:_>U?-1:0:H<0&&V<0?_<U?-1:_>U?1:0:V<H?-1:V>H?1:0}}}let vt=0;class Qt{static compare(T,k){let R=T.leftSE.point.x,E=k.leftSE.point.x,I=T.rightSE.point.x,H=k.rightSE.point.x;if(H<R)return 1;if(I<E)return-1;let _=T.leftSE.point.y,V=k.leftSE.point.y,U=T.rightSE.point.y,X=k.rightSE.point.y;if(R<E){if(V<_&&V<U)return 1;if(V>_&&V>U)return-1;let L=T.comparePoint(k.leftSE.point);if(L<0)return 1;if(L>0)return-1;let z=k.comparePoint(T.rightSE.point);return z!==0?z:-1}if(R>E){if(_<V&&_<X)return-1;if(_>V&&_>X)return 1;let L=k.comparePoint(T.leftSE.point);if(L!==0)return L;let z=T.comparePoint(k.rightSE.point);return z<0?1:z>0?-1:1}if(_<V)return-1;if(_>V)return 1;if(I<H){let L=k.comparePoint(T.rightSE.point);if(L!==0)return L}if(I>H){let L=T.comparePoint(k.rightSE.point);if(L<0)return 1;if(L>0)return-1}if(I!==H){let L=U-_,z=I-R,Y=X-V,ie=H-E;if(L>z&&Y<ie)return 1;if(L<z&&Y>ie)return-1}return I>H?1:I<H||U<X?-1:U>X?1:T.id<k.id?-1:T.id>k.id?1:0}constructor(T,k,R,E){this.id=++vt,this.leftSE=T,T.segment=this,T.otherSE=k,this.rightSE=k,k.segment=this,k.otherSE=T,this.rings=R,this.windings=E}static fromRing(T,k,R){let E,I,H,_=_e.comparePoints(T,k);if(_<0)E=T,I=k,H=1;else if(_>0)E=k,I=T,H=-1;else throw new Error(`Tried to create degenerate segment at [${T.x}, ${T.y}]`);let V=new _e(E,!0),U=new _e(I,!1);return new Qt(V,U,[R],[H])}replaceRightSE(T){this.rightSE=T,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}bbox(){let T=this.leftSE.point.y,k=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:T<k?T:k},ur:{x:this.rightSE.point.x,y:T>k?T:k}}}vector(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}isAnEndpoint(T){return T.x===this.leftSE.point.x&&T.y===this.leftSE.point.y||T.x===this.rightSE.point.x&&T.y===this.rightSE.point.y}comparePoint(T){if(this.isAnEndpoint(T))return 0;let k=this.leftSE.point,R=this.rightSE.point,E=this.vector();if(k.x===R.x)return T.x===k.x?0:T.x<k.x?1:-1;let I=(T.y-k.y)/E.y,H=k.x+I*E.x;if(T.x===H)return 0;let _=(T.x-k.x)/E.x,V=k.y+_*E.y;return T.y===V?0:T.y<V?-1:1}getIntersection(T){let k=this.bbox(),R=T.bbox(),E=y(k,R);if(E===null)return null;let I=this.leftSE.point,H=this.rightSE.point,_=T.leftSE.point,V=T.rightSE.point,U=m(k,_)&&this.comparePoint(_)===0,X=m(R,I)&&T.comparePoint(I)===0,L=m(k,V)&&this.comparePoint(V)===0,z=m(R,H)&&T.comparePoint(H)===0;if(X&&U)return z&&!L?H:!z&&L?V:null;if(X)return L&&I.x===V.x&&I.y===V.y?null:I;if(U)return z&&H.x===_.x&&H.y===_.y?null:_;if(z&&L)return null;if(z)return H;if(L)return V;let Y=cr(I,this.vector(),_,T.vector());return Y===null||!m(E,Y)?null:S.round(Y.x,Y.y)}split(T){let k=[],R=T.events!==void 0,E=new _e(T,!0),I=new _e(T,!1),H=this.rightSE;this.replaceRightSE(I),k.push(I),k.push(E);let _=new Qt(E,H,this.rings.slice(),this.windings.slice());return _e.comparePoints(_.leftSE.point,_.rightSE.point)>0&&_.swapEvents(),_e.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),R&&(E.checkForConsuming(),I.checkForConsuming()),k}swapEvents(){let T=this.rightSE;this.rightSE=this.leftSE,this.leftSE=T,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(let k=0,R=this.windings.length;k<R;k++)this.windings[k]*=-1}consume(T){let k=this,R=T;for(;k.consumedBy;)k=k.consumedBy;for(;R.consumedBy;)R=R.consumedBy;let E=Qt.compare(k,R);if(E!==0){if(E>0){let I=k;k=R,R=I}if(k.prev===R){let I=k;k=R,R=I}for(let I=0,H=R.rings.length;I<H;I++){let _=R.rings[I],V=R.windings[I],U=k.rings.indexOf(_);U===-1?(k.rings.push(_),k.windings.push(V)):k.windings[U]+=V}R.rings=null,R.windings=null,R.consumedBy=k,R.leftSE.consumedBy=k.leftSE,R.rightSE.consumedBy=k.rightSE}}prevInResult(){return this._prevInResult!==void 0?this._prevInResult:(this.prev?this.prev.isInResult()?this._prevInResult=this.prev:this._prevInResult=this.prev.prevInResult():this._prevInResult=null,this._prevInResult)}beforeState(){if(this._beforeState!==void 0)return this._beforeState;if(!this.prev)this._beforeState={rings:[],windings:[],multiPolys:[]};else{let T=this.prev.consumedBy||this.prev;this._beforeState=T.afterState()}return this._beforeState}afterState(){if(this._afterState!==void 0)return this._afterState;let T=this.beforeState();this._afterState={rings:T.rings.slice(0),windings:T.windings.slice(0),multiPolys:[]};let k=this._afterState.rings,R=this._afterState.windings,E=this._afterState.multiPolys;for(let _=0,V=this.rings.length;_<V;_++){let U=this.rings[_],X=this.windings[_],L=k.indexOf(U);L===-1?(k.push(U),R.push(X)):R[L]+=X}let I=[],H=[];for(let _=0,V=k.length;_<V;_++){if(R[_]===0)continue;let U=k[_],X=U.poly;if(H.indexOf(X)===-1)if(U.isExterior)I.push(X);else{H.indexOf(X)===-1&&H.push(X);let L=I.indexOf(U.poly);L!==-1&&I.splice(L,1)}}for(let _=0,V=I.length;_<V;_++){let U=I[_].multiPoly;E.indexOf(U)===-1&&E.push(U)}return this._afterState}isInResult(){if(this.consumedBy)return!1;if(this._isInResult!==void 0)return this._isInResult;let T=this.beforeState().multiPolys,k=this.afterState().multiPolys;switch(pn.type){case"union":{let R=T.length===0,E=k.length===0;this._isInResult=R!==E;break}case"intersection":{let R,E;T.length<k.length?(R=T.length,E=k.length):(R=k.length,E=T.length),this._isInResult=E===pn.numMultiPolys&&R<E;break}case"xor":{let R=Math.abs(T.length-k.length);this._isInResult=R%2===1;break}case"difference":{let R=E=>E.length===1&&E[0].isSubject;this._isInResult=R(T)!==R(k);break}default:throw new Error(`Unrecognized operation type found ${pn.type}`)}return this._isInResult}}class od{constructor(T,k,R){if(!Array.isArray(T)||T.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=k,this.isExterior=R,this.segments=[],typeof T[0][0]!="number"||typeof T[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let E=S.round(T[0][0],T[0][1]);this.bbox={ll:{x:E.x,y:E.y},ur:{x:E.x,y:E.y}};let I=E;for(let H=1,_=T.length;H<_;H++){if(typeof T[H][0]!="number"||typeof T[H][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");let V=S.round(T[H][0],T[H][1]);V.x===I.x&&V.y===I.y||(this.segments.push(Qt.fromRing(I,V,this)),V.x<this.bbox.ll.x&&(this.bbox.ll.x=V.x),V.y<this.bbox.ll.y&&(this.bbox.ll.y=V.y),V.x>this.bbox.ur.x&&(this.bbox.ur.x=V.x),V.y>this.bbox.ur.y&&(this.bbox.ur.y=V.y),I=V)}(E.x!==I.x||E.y!==I.y)&&this.segments.push(Qt.fromRing(I,E,this))}getSweepEvents(){let T=[];for(let k=0,R=this.segments.length;k<R;k++){let E=this.segments[k];T.push(E.leftSE),T.push(E.rightSE)}return T}}class Cy{constructor(T,k){if(!Array.isArray(T))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");this.exteriorRing=new od(T[0],this,!0),this.bbox={ll:{x:this.exteriorRing.bbox.ll.x,y:this.exteriorRing.bbox.ll.y},ur:{x:this.exteriorRing.bbox.ur.x,y:this.exteriorRing.bbox.ur.y}},this.interiorRings=[];for(let R=1,E=T.length;R<E;R++){let I=new od(T[R],this,!1);I.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=I.bbox.ll.x),I.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=I.bbox.ll.y),I.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=I.bbox.ur.x),I.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=I.bbox.ur.y),this.interiorRings.push(I)}this.multiPoly=k}getSweepEvents(){let T=this.exteriorRing.getSweepEvents();for(let k=0,R=this.interiorRings.length;k<R;k++){let E=this.interiorRings[k].getSweepEvents();for(let I=0,H=E.length;I<H;I++)T.push(E[I])}return T}}class id{constructor(T,k){if(!Array.isArray(T))throw new Error("Input geometry is not a valid Polygon or MultiPolygon");try{typeof T[0][0][0]=="number"&&(T=[T])}catch{}this.polys=[],this.bbox={ll:{x:Number.POSITIVE_INFINITY,y:Number.POSITIVE_INFINITY},ur:{x:Number.NEGATIVE_INFINITY,y:Number.NEGATIVE_INFINITY}};for(let R=0,E=T.length;R<E;R++){let I=new Cy(T[R],this);I.bbox.ll.x<this.bbox.ll.x&&(this.bbox.ll.x=I.bbox.ll.x),I.bbox.ll.y<this.bbox.ll.y&&(this.bbox.ll.y=I.bbox.ll.y),I.bbox.ur.x>this.bbox.ur.x&&(this.bbox.ur.x=I.bbox.ur.x),I.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=I.bbox.ur.y),this.polys.push(I)}this.isSubject=k}getSweepEvents(){let T=[];for(let k=0,R=this.polys.length;k<R;k++){let E=this.polys[k].getSweepEvents();for(let I=0,H=E.length;I<H;I++)T.push(E[I])}return T}}class sd{static factory(T){let k=[];for(let R=0,E=T.length;R<E;R++){let I=T[R];if(!I.isInResult()||I.ringOut)continue;let H=null,_=I.leftSE,V=I.rightSE,U=[_],X=_.point,L=[];for(;H=_,_=V,U.push(_),_.point!==X;)for(;;){let z=_.getAvailableLinkedEvents();if(z.length===0){let re=U[0].point,ge=U[U.length-1].point;throw new Error(`Unable to complete output ring starting at [${re.x}, ${re.y}]. Last matching segment found ends at [${ge.x}, ${ge.y}].`)}if(z.length===1){V=z[0].otherSE;break}let Y=null;for(let re=0,ge=L.length;re<ge;re++)if(L[re].point===_.point){Y=re;break}if(Y!==null){let re=L.splice(Y)[0],ge=U.splice(re.index);ge.unshift(ge[0].otherSE),k.push(new sd(ge.reverse()));continue}L.push({index:U.length,point:_.point});let ie=_.getLeftmostComparator(H);V=z.sort(ie)[0].otherSE;break}k.push(new sd(U))}return k}constructor(T){this.events=T;for(let k=0,R=T.length;k<R;k++)T[k].segment.ringOut=this;this.poly=null}getGeom(){let T=this.events[0].point,k=[T];for(let U=1,X=this.events.length-1;U<X;U++){let L=this.events[U].point,z=this.events[U+1].point;ee(L,T,z)!==0&&(k.push(L),T=L)}if(k.length===1)return null;let R=k[0],E=k[1];ee(R,T,E)===0&&k.shift(),k.push(k[0]);let I=this.isExteriorRing()?1:-1,H=this.isExteriorRing()?0:k.length-1,_=this.isExteriorRing()?k.length:-1,V=[];for(let U=H;U!=_;U+=I)V.push([k[U].x,k[U].y]);return V}isExteriorRing(){if(this._isExteriorRing===void 0){let T=this.enclosingRing();this._isExteriorRing=T?!T.isExteriorRing():!0}return this._isExteriorRing}enclosingRing(){return this._enclosingRing===void 0&&(this._enclosingRing=this._calcEnclosingRing()),this._enclosingRing}_calcEnclosingRing(){let T=this.events[0];for(let E=1,I=this.events.length;E<I;E++){let H=this.events[E];_e.compare(T,H)>0&&(T=H)}let k=T.segment.prevInResult(),R=k?k.prevInResult():null;for(;;){if(!k)return null;if(!R)return k.ringOut;if(R.ringOut!==k.ringOut)return R.ringOut.enclosingRing()!==k.ringOut?k.ringOut:k.ringOut.enclosingRing();k=R.prevInResult(),R=k?k.prevInResult():null}}}class gS{constructor(T){this.exteriorRing=T,T.poly=this,this.interiorRings=[]}addInterior(T){this.interiorRings.push(T),T.poly=this}getGeom(){let T=[this.exteriorRing.getGeom()];if(T[0]===null)return null;for(let k=0,R=this.interiorRings.length;k<R;k++){let E=this.interiorRings[k].getGeom();E!==null&&T.push(E)}return T}}class rG{constructor(T){this.rings=T,this.polys=this._composePolys(T)}getGeom(){let T=[];for(let k=0,R=this.polys.length;k<R;k++){let E=this.polys[k].getGeom();E!==null&&T.push(E)}return T}_composePolys(T){let k=[];for(let R=0,E=T.length;R<E;R++){let I=T[R];if(!I.poly)if(I.isExteriorRing())k.push(new gS(I));else{let H=I.enclosingRing();H.poly||k.push(new gS(H)),H.poly.addInterior(I)}}return k}}class oG{constructor(T){let k=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Qt.compare;this.queue=T,this.tree=new l(k),this.segments=[]}process(T){let k=T.segment,R=[];if(T.consumedBy)return T.isLeft?this.queue.remove(T.otherSE):this.tree.remove(k),R;let E=T.isLeft?this.tree.add(k):this.tree.find(k);if(!E)throw new Error(`Unable to find segment #${k.id} [${k.leftSE.point.x}, ${k.leftSE.point.y}] -> [${k.rightSE.point.x}, ${k.rightSE.point.y}] in SweepLine tree.`);let I=E,H=E,_,V;for(;_===void 0;)I=this.tree.prev(I),I===null?_=null:I.key.consumedBy===void 0&&(_=I.key);for(;V===void 0;)H=this.tree.next(H),H===null?V=null:H.key.consumedBy===void 0&&(V=H.key);if(T.isLeft){let U=null;if(_){let L=_.getIntersection(k);if(L!==null&&(k.isAnEndpoint(L)||(U=L),!_.isAnEndpoint(L))){let z=this._splitSafely(_,L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}}let X=null;if(V){let L=V.getIntersection(k);if(L!==null&&(k.isAnEndpoint(L)||(X=L),!V.isAnEndpoint(L))){let z=this._splitSafely(V,L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}}if(U!==null||X!==null){let L=null;U===null?L=X:X===null?L=U:L=_e.comparePoints(U,X)<=0?U:X,this.queue.remove(k.rightSE),R.push(k.rightSE);let z=k.split(L);for(let Y=0,ie=z.length;Y<ie;Y++)R.push(z[Y])}R.length>0?(this.tree.remove(k),R.push(T)):(this.segments.push(k),k.prev=_)}else{if(_&&V){let U=_.getIntersection(V);if(U!==null){if(!_.isAnEndpoint(U)){let X=this._splitSafely(_,U);for(let L=0,z=X.length;L<z;L++)R.push(X[L])}if(!V.isAnEndpoint(U)){let X=this._splitSafely(V,U);for(let L=0,z=X.length;L<z;L++)R.push(X[L])}}}this.tree.remove(k)}return R}_splitSafely(T,k){this.tree.remove(T);let R=T.rightSE;this.queue.remove(R);let E=T.split(k);return E.push(R),T.consumedBy===void 0&&this.tree.add(T),E}}let bS=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE||1e6,iG=typeof process<"u"&&process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS||1e6;class sG{run(T,k,R){pn.type=T,S.reset();let E=[new id(k,!0)];for(let L=0,z=R.length;L<z;L++)E.push(new id(R[L],!1));if(pn.numMultiPolys=E.length,pn.type==="difference"){let L=E[0],z=1;for(;z<E.length;)y(E[z].bbox,L.bbox)!==null?z++:E.splice(z,1)}if(pn.type==="intersection")for(let L=0,z=E.length;L<z;L++){let Y=E[L];for(let ie=L+1,re=E.length;ie<re;ie++)if(y(Y.bbox,E[ie].bbox)===null)return[]}let I=new l(_e.compare);for(let L=0,z=E.length;L<z;L++){let Y=E[L].getSweepEvents();for(let ie=0,re=Y.length;ie<re;ie++)if(I.insert(Y[ie]),I.size>bS)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).")}let H=new oG(I),_=I.size,V=I.pop();for(;V;){let L=V.key;if(I.size===_){let Y=L.segment;throw new Error(`Unable to pop() ${L.isLeft?"left":"right"} SweepEvent [${L.point.x}, ${L.point.y}] from segment #${Y.id} [${Y.leftSE.point.x}, ${Y.leftSE.point.y}] -> [${Y.rightSE.point.x}, ${Y.rightSE.point.y}] from queue.`)}if(I.size>bS)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");if(H.segments.length>iG)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");let z=H.process(L);for(let Y=0,ie=z.length;Y<ie;Y++){let re=z[Y];re.consumedBy===void 0&&I.insert(re)}_=I.size,V=I.pop()}S.reset();let U=sd.factory(H.segments);return new rG(U).getGeom()}}let pn=new sG;var aG={union:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("union",O,k)},intersection:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("intersection",O,k)},xor:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("xor",O,k)},difference:function(O){for(var T=arguments.length,k=new Array(T>1?T-1:0),R=1;R<T;R++)k[R-1]=arguments[R];return pn.run("difference",O,k)}};return aG}))});function cl(){let e=[];return{onRelease(t){e?e.push(t):t()},release(){let t=e;e=null;for(let n of t??[])n()}}}var ad=class extends Error{constructor(n,r){super(`shader ${n} failure: ${r}`);this.stage=n;this.log=r;this.name="ShaderCompileError"}stage;log},ld=0,to=class{constructor(t,n,r){this.gl=t;let o=this.compile(t.VERTEX_SHADER,n,"vertex"),i;try{i=this.compile(t.FRAGMENT_SHADER,r,"fragment")}catch(a){throw t.deleteShader(o),a}let s=t.createProgram();if(!s)throw t.deleteShader(o),t.deleteShader(i),new Error("createProgram returned null");if(t.attachShader(s,o),t.attachShader(s,i),t.bindAttribLocation(s,ld,"a_position"),t.linkProgram(s),t.deleteShader(o),t.deleteShader(i),!t.getProgramParameter(s,t.LINK_STATUS)){let a=t.getProgramInfoLog(s)??"";throw t.deleteProgram(s),new ad("link",a)}this.handle=s}gl;handle;uniforms=new Map;arrays=new Map;attributes=new Map;compile(t,n,r){let o=this.gl,i=o.createShader(t);if(!i)throw new Error("createShader returned null");if(o.shaderSource(i,n),o.compileShader(i),!o.getShaderParameter(i,o.COMPILE_STATUS)){let s=o.getShaderInfoLog(i)??"";throw o.deleteShader(i),new ad(r,s)}return i}lookupUniforms(t){for(let n of t){let r=this.gl.getUniformLocation(this.handle,n);r!==null&&this.uniforms.set(n,r)}}lookupUniformArrays(t){for(let[n,{type:r,size:o}]of t){let i=`${n}[0]`,s=this.uniforms.get(i)??this.gl.getUniformLocation(this.handle,i);s!==null&&this.arrays.set(n,{type:r,size:o,location:s})}}lookupAttributes(t){for(let n of t){let r=this.gl.getAttribLocation(this.handle,n);r>=0&&this.attributes.set(n,r)}}uniform(t){return this.uniforms.get(t)}uniformArray(t){return this.arrays.get(t)}attribute(t){return this.attributes.get(t)}};var xS=`#version 300 es
4
4
  in vec2 a_position;
5
5
  uniform mat3 u_proj;
6
6
  uniform mat3 u_model;
@@ -10,7 +10,7 @@ void main() {
10
10
  vec3 clip = u_proj * vec3(screen.xy, 1.0);
11
11
  gl_Position = vec4(clip.xy, 0.0, 1.0);
12
12
  }
13
- `,D1=`#version 300 es
13
+ `,wS=`#version 300 es
14
14
  precision highp float;
15
15
  uniform vec4 u_color;
16
16
  uniform float u_alpha;
@@ -22,7 +22,7 @@ void main() {
22
22
  float a = mapped.a * u_alpha;
23
23
  outColor = vec4(mapped.rgb * a, a);
24
24
  }
25
- `,B1=`#version 300 es
25
+ `,PS=`#version 300 es
26
26
  in vec2 a_position;
27
27
  in vec4 a_vertexColor;
28
28
  uniform mat3 u_proj;
@@ -35,7 +35,7 @@ void main() {
35
35
  gl_Position = vec4(clip.xy, 0.0, 1.0);
36
36
  v_vertexColor = a_vertexColor;
37
37
  }
38
- `,H1=`#version 300 es
38
+ `,TS=`#version 300 es
39
39
  precision highp float;
40
40
  in vec4 v_vertexColor;
41
41
  uniform vec4 u_color;
@@ -49,8 +49,8 @@ void main() {
49
49
  float a = mapped.a * u_alpha;
50
50
  outColor = vec4(mapped.rgb * a, a);
51
51
  }
52
- `,py=["u_proj","u_model","u_origin","u_color","u_alpha","u_colorMatrix","u_colorBias"],G1=["a_position"],U1=["a_position","a_vertexColor"];var nl=e=>typeof e=="number"&&Number.isFinite(e);function W1(e){if(e===void 0)return;if(typeof e!="object"||e===null)throw new Error("parseBmFont: faceMetrics must be an object");let t=e,n={};if(t.ascent!==void 0||t.descent!==void 0){if(!nl(t.ascent)||!nl(t.descent)||t.ascent+t.descent<=0)throw new Error("parseBmFont: malformed faceMetrics.ascent/descent");n.ascent=t.ascent,n.descent=t.descent}let r=(o,i,s,a)=>{let l=t[o];if(l===void 0)return;let u=l;if(typeof u!="object"||u===null||!nl(u[i])||!nl(u[s])||u[a]<=0)throw new Error(`parseBmFont: malformed faceMetrics.${o}`);n[o]={[i]:u[i],[s]:u[s]}};r("underline","offset","thickness","thickness"),r("strikethrough","offset","thickness","thickness"),r("superscript","size","shift","size"),r("subscript","size","shift","size");for(let o of["xHeight","capHeight"]){let i=t[o];if(i!==void 0){if(!nl(i)||i<=0)throw new Error(`parseBmFont: malformed faceMetrics.${o}`);n[o]=i}}return Object.keys(n).length>0?n:void 0}function Yo(e){return e.outlineFace?.faceMetrics??e.entry?.font.faceMetrics}function V1(e){if(typeof e!="object"||e===null)throw new Error("parseBmFont: expected object");let t=e;if(!t.info||typeof t.info!="object")throw new Error("parseBmFont: missing info");if(!t.common||typeof t.common!="object")throw new Error("parseBmFont: missing common");if(!Array.isArray(t.chars))throw new Error("parseBmFont: chars must be an array");let n=t.info,r=t.common,o=[["info.size",n.size],["common.scaleW",r.scaleW],["common.scaleH",r.scaleH]];for(let[d,f]of o)if(typeof f!="number"||!(f>0)||!Number.isFinite(f))throw new Error(`parseBmFont: ${d} must be a positive number`);if(typeof r.base!="number"||!Number.isFinite(r.base))throw new Error("parseBmFont: common.base must be a number");let i=t.chars,s=Array.isArray(t.kernings)?t.kernings:[],a=new Map;for(let d of i)a.set(d.id,d);let l=new Map;for(let d of s){let f=l.get(d.first);f||(f=new Map,l.set(d.first,f)),f.set(d.second,d.amount)}let u=W1(t.faceMetrics),c=t.distanceField?.distanceRange;return{info:n,common:r,chars:i,kernings:s,charMap:a,kerningMap:l,...u?{faceMetrics:u}:{},...typeof c=="number"&&c>0?{distanceRange:c}:{}}}var Zi={family:"",weight:NaN,style:"",key:""};function es(e,t,n){return Zi.family===e&&Zi.weight===t&&Zi.style===n||(Zi={family:e,weight:t,style:n,key:`${e}|${t}|${n}`}),Zi.key}var z1=new Map;function Qr(e,t){let n=z1.get(t);n===void 0&&z1.set(t,n=new Map);let r=n.get(e);return r===void 0&&(r=`${e}|${t}`,n.size<1024&&n.set(e,r)),r}function Me(){let e=new Set;return{subscribe(t){return e.add(t),()=>{e.delete(t)}},emit(...t){if(e.size!==0){for(let n of[...e])if(e.has(n))try{n(...t)}catch(r){console.error("weasel: a subscriber threw",r)}}},get size(){return e.size}}}function xt(){let e=new Map,t=Me(),n=0,r=null;function o(){n++,t.emit()}let i={get:a=>e.get(a)?.at(-1)?.value,has:a=>e.has(a),entries(){if(r?.version===n)return r.entries;let a=[];for(let[l,u]of e){let c=u.at(-1);a.push(Object.freeze({key:l,live:c,value:c.value,source:c.source,shadowed:Object.freeze(u.slice(0,-1))}))}return r={version:n,entries:Object.freeze(a)},r.entries},subscribe:t.subscribe,getVersion:()=>n};function s(a,l){let u=e.get(a),c=u?u.lastIndexOf(l):-1;return c===-1?!1:(u.splice(c,1),u.length===0&&e.delete(a),o(),!0)}return{...i,reflection:i,release:s,push(a,l,u){let c=Object.freeze({value:l,source:u?.source}),d=e.get(a);return d?d.push(c):e.set(a,[c]),o(),()=>{s(a,c)}},set(a,l,u){let c=Object.freeze({value:l,source:u?.source}),d=e.get(a);d?d[d.length-1]=c:e.set(a,[c]),o()},delete(a){return e.delete(a)?(o(),!0):!1},clear(){e.size!==0&&(e.clear(),o())},bump:o}}function Qt(){try{return!1}catch{return!0}}function ts(e){return e===Object.prototype||e===null||Object.getPrototypeOf(e)===null}function Zt(e){return typeof e=="object"&&e!==null&&ts(Object.getPrototypeOf(e))}function Zr(e,t,n={}){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((o,i)=>Zr(o,t[i],n));if(!Zt(e)||!Zt(t))return!1;if(n.undefinedAsAbsent)return[...new Set([...Object.keys(e),...Object.keys(t)])].every(o=>Zr(e[o],t[o],n));let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(o=>Object.hasOwn(t,o)&&Zr(e[o],t[o],n))}function Yc(e,t,n=(r,o)=>r===o){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}var K1=Me(),hy=0;function qo(){return hy}var j1=0;function rl(){return j1}function bn(){hy++,j1++,K1.emit()}function $1(){hy++,K1.emit()}var uG="substitute",cG=null;function ns(){return uG}function ol(){return cG}var my=new Set;function eo(e){return my.has(e)?!1:(my.add(e),!0)}function Y1(e){return my.has(e)}var il=class{constructor(t){this.format=t}format;pages=[];uploaded=new WeakMap;textureId(t){return`${this.format.idPrefix}${t}`}blit(t,n,r,o,i,s){let a=this.format.channels;for(;this.pages.length<=t;)this.pages.push({data:new Uint8Array(1024*1024*a),version:0,patches:[]});let l=this.pages[t];for(let u=0;u<i;u++)l.data.set(s.subarray(u*o*a,(u+1)*o*a),((r+u)*1024+n)*a);l.version++,l.patches.push({seq:l.version,x:n,y:r,w:o,h:i})}clear(){for(let t of this.pages)t.data.fill(0),t.version++,t.patches=[{seq:t.version,x:0,y:0,w:1024,h:1024}]}sync(t,n){let r=this.pages[n];if(!r)return!1;let o=this.format.channels,i=this.textureId(n),s=this.uploaded.get(t);if(s||(s=new Map,this.uploaded.set(t,s)),!t.has(i))return this.format.upload(t,i,r.data),s.set(n,r.version),!0;let a=s.get(n)??0;if(a>=r.version)return!0;for(let l of r.patches){if(l.seq<=a)continue;let u=new Uint8Array(l.w*l.h*o);for(let c=0;c<l.h;c++){let d=((l.y+c)*1024+l.x)*o;u.set(r.data.subarray(d,d+l.w*o),c*l.w*o)}this.format.patch(t,i,l.x,l.y,l.w,l.h,u)}return s.set(n,r.version),!0}},qc=new il({channels:1,idPrefix:"weasel-dyn-sdf-page-",upload:(e,t,n)=>e.uploadR8(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageR8(t,n,r,o,i,s)}),Xc=new il({channels:4,idPrefix:"weasel-dyn-color-page-",upload:(e,t,n)=>e.uploadRGBA(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageRGBA(t,n,r,o,i,s)}),sl=new il({channels:4,idPrefix:"weasel-dyn-color-sharp-page-",upload:(e,t,n)=>e.uploadRGBA(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageRGBA(t,n,r,o,i,s)});function q1(e,t,n,r,o,i){qc.blit(e,t,n,r,o,i)}function X1(e,t,n,r,o,i){Xc.blit(e,t,n,r,o,i)}function J1(e,t,n,r,o,i){sl.blit(e,t,n,r,o,i)}function Q1(){qc.clear(),Xc.clear(),sl.clear()}function Z1(){sl.clear()}function Jc(e){return qc.textureId(e)}function Qc(e){return Xc.textureId(e)}function Zc(e){return sl.textureId(e)}function ed(e,t){return qc.sync(e,t)}function td(e,t){return Xc.sync(e,t)}function nd(e,t){return sl.sync(e,t)}var rd=class{constructor(t,n){this.pageSize=t;this.maxPages=n}pageSize;maxPages;pages=[];get pageCount(){return this.pages.length}fits(t,n){return t<=this.pageSize&&n<=this.pageSize}alloc(t,n){if(!this.fits(t,n))return null;for(let r=0;r<this.pages.length;r++){let o=this.allocInPage(this.pages[r],t,n);if(o)return{page:r,...o}}if(this.pages.length<this.maxPages){let r={shelves:[],nextY:0};this.pages.push(r);let o=this.allocInPage(r,t,n);if(o)return{page:this.pages.length-1,...o}}return null}allocInPage(t,n,r){for(let o of t.shelves)if(r<=o.height&&o.x+n<=this.pageSize){let i=o.x;return o.x+=n,{x:i,y:o.y}}if(t.nextY+r<=this.pageSize){let o={y:t.nextY,height:r,x:n};return t.shelves.push(o),t.nextY+=r,{x:0,y:o.y}}return null}};function eS(e,t,n,r,o){n[0]=0,r[0]=-1e20,r[1]=1e20;let i=0;for(let s=1;s<o;s++){let a=(e[s]+s*s-(e[n[i]]+n[i]*n[i]))/(2*s-2*n[i]);for(;a<=r[i];)i--,a=(e[s]+s*s-(e[n[i]]+n[i]*n[i]))/(2*s-2*n[i]);i++,n[i]=s,r[i]=a,r[i+1]=1e20}i=0;for(let s=0;s<o;s++){for(;r[i+1]<s;)i++;t[s]=(s-n[i])*(s-n[i])+e[n[i]]}}function tS(e,t,n,r,o,i,s){for(let a=0;a<t;a++){for(let l=0;l<n;l++)r[l]=e[l*t+a];eS(r,o,i,s,n);for(let l=0;l<n;l++)e[l*t+a]=o[l]}for(let a=0;a<n;a++){for(let l=0;l<t;l++)r[l]=e[a*t+l];eS(r,o,i,s,t);for(let l=0;l<t;l++)e[a*t+l]=o[l]}}function nS(e,t,n,r,o){let i=t*n,s=new Float64Array(i),a=new Float64Array(i),l=Math.max(t,n),u=new Float64Array(l),c=new Float64Array(l),d=new Int32Array(l),f=new Float64Array(l+1);for(let h=0;h<i;h++){let m=e[h]/255;s[h]=m===1?0:m===0?1e20:Math.max(0,.5-m)**2,a[h]=m===1?1e20:m===0?0:Math.max(0,m-.5)**2}tS(s,t,n,u,c,d,f),tS(a,t,n,u,c,d,f);let p=new Uint8Array(i);for(let h=0;h<i;h++){let m=Math.sqrt(s[h])-Math.sqrt(a[h]),g=Math.round(255-255*(m/r+o));p[h]=g<0?0:g>255?255:g}return p}var rs=8,sS=.5,Jo=16,Xo=()=>({packer:new rd(1024,4),settled:!0,reclaimScheduled:!1}),xy=Xo(),wy=Xo(),al=Xo(),Gn=[],yy=!1,gy=Jo,by=0,aS=()=>{},Py=()=>{},rS=new Set;function lS(e){aS=e}function uS(e){Py=e}function os(e,t,n=!1){if(by++,t.width===0||t.height===0){e.page=0;return}gy>0?(gy--,dS(e,t,n)):(Gn.push({char:e,raster:t,sharp:n}),fS())}function cS(e){Gn=Gn.filter(t=>!e.has(t.char))}function dS(e,t,n){let r="rgba"in t,o=n?al:r?wy:xy,i=o.packer.alloc(t.width,t.height);if(!i){dG(o,t,n?pG:fG);return}if(r&&n)J1(i.page,i.x,i.y,t.width,t.height,t.rgba);else if(r)X1(i.page,i.x,i.y,t.width,t.height,t.rgba);else{let s=nS(t.alpha,t.width,t.height,rs,sS);q1(i.page,i.x,i.y,t.width,t.height,s)}e.x=i.x,e.y=i.y,e.width=t.width,e.height=t.height,e.page=i.page}function dG(e,t,n){if(!e.packer.fits(t.width,t.height))oS("weasel DynamicGlyphAtlas: a glyph is larger than a page and will not render.");else if(e.settled)e.reclaimScheduled||(e.reclaimScheduled=!0,setTimeout(n,0));else{if(e===al)return;oS(`weasel DynamicGlyphAtlas: more glyphs are in use at once than its pages hold (${4} \xD7 ${1024}\xB2); the rest will not render.`)}}function oS(e){rS.has(e)||(rS.add(e),console.warn(e))}function fG(){xy={...Xo(),settled:!1},wy={...Xo(),settled:!1},al={...Xo(),settled:!1},Gn=[],Q1(),aS(),Py(),bn()}function pG(){al={...Xo(),settled:!1},Gn=Gn.filter(e=>!e.sharp),Z1(),Py(),bn()}function fS(){yy||(yy=!0,setTimeout(hG,0))}function hG(){yy=!1;let e=0;for(;Gn.length>0&&e<Jo;){let t=Gn.shift();t.char.page===-1&&(dS(t.char,t.raster,t.sharp),e++)}Gn.length>0&&fS(),$1()}function od(e=Jo){gy=e,by===0&&Gn.length===0&&(xy.settled=!0,wy.settled=!0,al.settled=!0),by=0}function Ty(e){return e.trim().replace(/^(["'])(.*)\1$/,"$2").toLowerCase()}function pS(e){let t=typeof document>"u"?void 0:document.fonts;if(!t?.addEventListener)return()=>{};let n=r=>{let o=r.fontfaces??[];o.length>0&&e(o.map(i=>i.family))};return t.addEventListener("loadingdone",n),()=>t.removeEventListener("loadingdone",n)}function hS(e){return/[,"']/.test(e)?e:mG.has(e.trim().toLowerCase())?e.trim():JSON.stringify(e)}var mG=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]);var He=48,en=8;function yG(e){let t=[1/0,1/0,-1/0,-1/0],n=e.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[];for(let r=0;r+1<n.length;r+=2){let o=Number(n[r]),i=Number(n[r+1]);o<t[0]&&(t[0]=o),i<t[1]&&(t[1]=i),o>t[2]&&(t[2]=o),i>t[3]&&(t[3]=i)}return t}var gG=240;function bG(e){let t=new Uint8ClampedArray(e.length),n=!1;for(let r=0;r<e.length;r+=4){let o=e[r+3];if(o===0)continue;let i=e[r],s=e[r+1],a=e[r+2];o>=128&&Math.min(i,s,a)<gG&&(n=!0),t[r]=Math.round(i*o/255),t[r+1]=Math.round(s*o/255),t[r+2]=Math.round(a*o/255),t[r+3]=o}return n?t:null}var id=1e3;function xG(e,t,n,r=He){return`${t==="italic"?"italic ":""}${e} ${r}px ${hS(n)}`}function mS(){let e;if(typeof OffscreenCanvas<"u")e=new OffscreenCanvas(He*3,He*3);else if(typeof document<"u")e=document.createElement("canvas"),e.width=He*3,e.height=He*3;else throw new Error("weasel DynamicGlyphAtlas: no canvas available for glyph rasterization");let t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw new Error("weasel DynamicGlyphAtlas: 2D context unavailable");function n(o,i,s,a=He){t.font=xG(i,s,o,a),t.textBaseline="alphabetic",t.textAlign="left"}function r(o,i,s,a,l=He){n(o,i,s,l);let u=t.measureText(a),c=u.width,d=Math.ceil(u.actualBoundingBoxLeft??0),f=Math.ceil(u.actualBoundingBoxRight??c),p=Math.ceil(u.actualBoundingBoxAscent??l*.8),h=Math.ceil(u.actualBoundingBoxDescent??l*.2),m=d+f,g=p+h;if(m<=0||g<=0)return{data:new Uint8ClampedArray(0),width:0,height:0,left:0,top:0,advance:c};let b=m+2*en,x=g+2*en;return(e.width<b||e.height<x)&&(e.width=Math.max(e.width,b),e.height=Math.max(e.height,x),n(o,i,s,l)),t.clearRect(0,0,b,x),t.fillStyle="#fff",t.fillText(a,en+d,en+p),{data:t.getImageData(0,0,b,x).data,width:b,height:x,left:-(d+en),top:p+en,advance:c}}return{faceMetrics(o,i,s){n(o,i,s,id);let a=t.measureText("Hg"),l=He/id;return{ascent:(a.fontBoundingBoxAscent??id*.8)*l,descent:(a.fontBoundingBoxDescent??id*.2)*l}},rasterize(o,i,s,a){let{data:l,...u}=r(o,i,s,String.fromCodePoint(a)),c=new Uint8ClampedArray(u.width*u.height);for(let d=0;d<c.length;d++)c[d]=l[d*4+3];return{...u,alpha:c}},rasterizePath(o){let[i,s,a,l]=yG(o),u={width:0,height:0,alpha:new Uint8ClampedArray(0),left:0,top:0,advance:0};if(!(a>i&&l>s))return u;let c=Math.floor(i*He),d=Math.floor(s*He),f=Math.ceil(a*He)-c+2*en,p=Math.ceil(l*He)-d+2*en;(e.width<f||e.height<p)&&(e.width=Math.max(e.width,f),e.height=Math.max(e.height,p)),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,f,p),t.setTransform(He,0,0,He,en-c,en-d),t.fillStyle="#fff",t.fill(new Path2D(o)),t.setTransform(1,0,0,1,0,0);let h=t.getImageData(0,0,f,p).data,m=new Uint8ClampedArray(f*p);for(let g=0;g<m.length;g++)m[g]=h[g*4+3];return{width:f,height:p,alpha:m,left:c-en,top:en-d,advance:0}},rasterizeColor(o,i,s,a,l){let{data:u,...c}=r(o,i,s,a,l),d=bG(u);return d&&{...c,rgba:d}}}}var Sy=3,ky=new WeakMap,sd=0;uS(()=>{sd++});function yS(e,t,n){ky.set(e,{raster:n,base:t,levels:[],generation:sd})}function vy(e){return e.generation!==sd&&(e.levels=[],e.generation=sd),e.levels}function gS(e){let t=ky.get(e);return t?vy(t).flatMap(n=>n?[n.glyph]:[]):[]}function wG(e,t){let n=vy(e),r=n[t];if(r!==void 0)return r;let o=2**t,i=e.raster(He*o),s=i&&{level:t,glyph:{id:0,x:0,y:0,width:0,height:0,xoffset:i.left/o,yoffset:e.base-i.top/o,xadvance:i.advance/o,page:-1,color:!0}};return n[t]=s,s&&i&&os(s.glyph,i,!0),s}function ad(e,t){let n=ky.get(e);if(!n||!(t>1))return null;let r=Math.min(Sy,Math.ceil(Math.log2(t)));wG(n,r);let o=vy(n);for(let i=r;i>0;i--){let s=o[i];if(s&&s.glyph.page>=0)return s}return null}var ld=new Set,ud=new Set,cd=new Map,Ay=null,PG=null;function bS(e){e.font.charMap.clear(),e.font.chars.length=0,e.clusters.clear(),e.shaped.clear()}lS(()=>{for(let e of cd.values())bS(e)});function xS(){return Ay||(Ay=mS()),Ay}function dd(e){return ld.has(e)?!ud.has(e)||ns()==="canvas":!1}function wS(e){ld.has(e)&&!ud.has(e)||(ld.add(e),ud.add(e))}function Ry(e){return ld.has(e)&&!ud.has(e)}function fd(e,t,n){let r=`${e}|${t}|${n}`,o=cd.get(r);if(o)return o;let i=xS(),s={info:{face:e,size:He},common:{lineHeight:0,base:0,scaleW:1024,scaleH:1024},chars:[],kernings:[],charMap:new Map,kerningMap:new Map},a=(d,f)=>({id:d,x:0,y:0,width:0,height:0,xoffset:f.left,yoffset:s.common.base-f.top,xadvance:f.advance,page:-1}),l=new Map,u=new Map,c={family:e,weight:t,style:n,font:s,clusters:l,shaped:u,requestGlyph(d){let f=s.charMap.get(d);if(f)return f;let p=i.rasterize(e,t,n,d),h=a(d,p);return s.charMap.set(d,h),s.chars.push(h),os(h,p),h},requestCluster(d){let f=l.get(d);if(f!==void 0)return f;let p=i.rasterizeColor?.(e,t,n,d)??null,h=p&&{...a(d.codePointAt(0),p),color:!0};return l.set(d,h),h&&p&&(os(h,p),yS(h,s.common.base,m=>i.rasterizeColor?.(e,t,n,d,m)??null)),h},requestShaped(d,f){let p=u.get(d);if(p!==void 0)return p;let h=typeof Path2D>"u"?null:i.rasterizePath?.(f)??null,m=h&&a(0,h);return u.set(d,m),m&&h&&os(m,h),m}};return PS(c),cd.set(r,c),PG??=pS(TG),c}function PS(e){let{font:t}=e,n=xS().faceMetrics(e.family,e.weight,e.style);t.common.lineHeight=Math.round(n.ascent+n.descent),t.common.base=Math.round(n.ascent),t.faceMetrics={ascent:n.ascent/He,descent:n.descent/He},bS(e)}function TG(e){let t=e&&new Set(e.map(Ty)),n=new Set,r=0;for(let o of cd.values())if(!(t&&!o.family.split(",").some(i=>t.has(Ty(i))))){for(let i of o.font.chars)n.add(i);for(let i of o.shaped.values())i&&n.add(i);for(let i of o.clusters.values())if(i){n.add(i);for(let s of gS(i))n.add(s)}PS(o),r++}r!==0&&(cS(n),bn())}var dr=xt(),SG=dr.reflection;function Qo(e,t,n){return`${e}|${t}|${n}`}function kG(e){return{weight:e.weight??400,style:e.style??"normal"}}function Ny(e,t=400,n="normal"){return dr.has(Qo(e,t,n))}function Iy(e,t=400,n="normal"){return dr.get(Qo(e,t,n))?.status??null}function vG(e){let t="",n=0;for(let r=1;r<e.length;r++){let o=e[r];o!=="M"&&o!=="m"||(t+=TS(e.slice(n,r)),n=r)}return t+TS(e.slice(n))}function TS(e){let t=e.trimEnd();if(t.length===0)return"";let n=t[t.length-1];return n==="Z"||n==="z"?t:`${t}Z`}function Ey(e,t,n,r){let o=dr.get(Qo(e,t,n));if(!o)return null;if(o.status==="idle")return Cy(o),null;if(o.status!=="ready")return null;let i=o.glyphs.get(r);if(i!==void 0)return i;let s=null;try{let a=o.face.glyphD(r);s=a===null?null:vG(a)}catch(a){kS(`glyph|${Qo(e,t,n)}`,`weasel: outline face "${e}" (${t}/${n}) could not produce a glyph for U+${r.toString(16).toUpperCase().padStart(4,"0")} \u2014 ${a instanceof Error?a.message:String(a)}. Falling back to the SDF tier.`)}return o.glyphs.set(r,s),s}function ll(e,t,n){let r=dr.get(Qo(e,t,n));return r?r.status==="idle"?(Cy(r),null):r.status==="ready"?r.face:null:null}async function My(e,t={}){let{weight:n,style:r}=kG(t),o=dr.get(Qo(e,n,r));return o?(await Cy(o),o.status):null}function Cy(e){return e.load??=AG(e),e.load}async function AG(e){e.status="loading",dr.bump();try{let t=await IG(e.source);NG(e,t),e.face=await e.parser(t),e.status="ready",dr.bump(),bn()}catch(t){e.status="failed",dr.bump(),bn(),kS(`load|${Qo(e.family,e.weight,e.style)}`,`weasel registerFontOutlines("${e.family}" ${e.weight}/${e.style}): ${t instanceof Error?t.message:String(t)}. Large text in this face keeps rendering from the SDF tier.`)}}var RG=null;function NG(e,t){try{RG?.(e,t)}catch{}}async function IG(e){let t=typeof e=="function"?await e():e;if(typeof t=="string"){let n=await fetch(t);if(!n.ok)throw new Error(`HTTP ${n.status} fetching ${t}`);return n.arrayBuffer()}return t instanceof ArrayBuffer?t:t.arrayBuffer()}var SS=new Set;function kS(e,t){SS.has(e)||(SS.add(e),console.warn(t))}function to(e,t,n,r,o,i){return{entry:e,resolved:{family:t,weight:n,style:r},synthetic:{bold:o,italic:i},source:"atlas"}}var vS=new WeakMap;function AS(e,t,n,r){let o=vS.get(e);if(o!==void 0&&o.resolved.family===t&&o.resolved.weight===n&&o.resolved.style===r)return o;let i=to(e,t,n,r,!1,!1);return Object.freeze(i.resolved),Object.freeze(i.synthetic),vS.set(e,Object.freeze(i)),i}var Dt=xt(),MG=Dt.reflection;function CG(e){return{weight:e.weight??400,style:e.style??"normal"}}var ul=new Map,no=new Map,is=new Map,Fy=new Set;function cl(e,t=400,n="normal"){return Dt.get(e)?.get(Qr(t,n))??null}function IS(e,t,n,r){let o=`${e}|${t}`,i=no.get(o);if(i)return i;let s=OG(e,t,n,r);no.set(o,s);let a=()=>{no.get(o)===s&&no.delete(o)};s.then(a,a);let l=is.get(e)?.get(t);if(l){let u=is.get(e);u.delete(t),u.size===0&&is.delete(e),l.settle(s)}return s}async function OG(e,t,n,r){let[o,i]=t.split("|"),s={},a=ul.get(e)??new Set;ul.set(e,a.add(s));try{let[l,u]=await Promise.all([fetch(n),fetch(r)]);if(!l.ok)throw new Error(`HTTP ${l.status} fetching metrics from ${n}`);if(!u.ok)throw new Error(`HTTP ${u.status} fetching atlas from ${r}`);let[c,d]=await Promise.all([l.json(),u.blob()]),f=V1(c),p=await createImageBitmap(d);Dt.set(e,new Map(Dt.get(e)).set(t,{font:f,bitmap:p})),RS(e,s),bn()}catch(l){throw RS(e,s),bn(),new Error(`weasel registerFont("${e}" ${o}/${i}): ${l instanceof Error?l.message:String(l)}`)}}function ES(e,t,n){let r=is.get(e);if(!r)return;let o=Qr(t,n),i=r.has(o)?[o]:[...r.keys()];for(let s of i){let{metricsUrl:a,atlasUrl:l}=r.get(s);IS(e,s,a,l).catch(()=>{})}}function Ly(e){let t=[];for(let n of e??[...Fy]){if(typeof n!="string"){let{weight:r,style:o}=CG(n);t.push(...CS(n.family,r,o));continue}if(!Fy.has(n))return Promise.reject(new Error(`weasel warmFonts: "${n}" was never registered.`));for(let[r,{metricsUrl:o,atlasUrl:i}]of[...is.get(n)??[]])IS(n,r,o,i);t.push(...MS(n))}return Promise.all(t).then(()=>{})}function MS(e){return[...no].filter(([t])=>t.startsWith(`${e}|`)).map(([,t])=>t)}function CS(e,t,n){let r=[],o=Ny(e,t,n);o&&r.push(My(e,{weight:t,style:n}));let i=Qr(t,n);if(Dt.get(e)?.has(i))return r;ES(e,t,n);let s=no.get(`${e}|${i}`);if(s)return[...r,s];if(Dt.has(e)||ss(e))return[...r,...MS(e)];if(o||Ry(e)||ns()!=="substitute")return r;let a=ol()??OS();return a!==null&&a!==e?[...r,...CS(a,t,n)]:r}function ss(e){return ul.has(e)||is.has(e)}function RS(e,t){let n=ul.get(e);n?.delete(t)&&n.size===0&&ul.delete(e)}function hd(e,t=400,n="normal"){if(ss(e))return!0;let r=Iy(e,t,n==="italic"?"italic":"normal");return r==="idle"||r==="loading"}function _y(e,t,n,r){let o=cl(e,t,n);return o?(r.upload(es(e,t,n),o.bitmap),!0):!1}function NS(e,t,n,r=!1){if(Ry(e))return{entry:null,dynamicFace:fd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"};let o=ll(e,t,n==="italic"?"italic":"normal");if(o)return{entry:null,outlineFace:o,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"outline"};if(hd(e,t,n))return pd(e,t,n);let i=ns();if(i==="canvas")return wS(e),{entry:null,dynamicFace:fd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"};if(i==="substitute"){let s=ol()??OS();if(s!==null&&s!==e){if(Dt.has(s)||dd(s)||ss(s)){let a=FS(s,t,n,!0,!1);if(a.entry!==null||a.dynamicFace!==void 0)return r||FG(e,t,n,s),{...a,substituted:{requested:e,resolved:s}};if(ss(s))return pd(e,t,n)}r||LG(e,t,n,s)}else s===e&&!r&&(Dt.has(e)?_G(e,t,n):DG(e,t,n))}return{entry:null,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"atlas"}}function OS(){for(let e of Fy)if(Dt.has(e)||ss(e))return e;return null}function pd(e,t,n){return{entry:null,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"atlas"}}function FG(e,t,n,r){if(!eo(`substituted|${e}|${t}|${n}`))return;let o=Dt.has(e)?`has no variant matching ${t}/${n}, and none of its registered variants are close enough for the within-family chain to substitute \u2014 rendering with "${r}" instead. Bake that variant with registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026)`:`is not registered \u2014 rendering with "${r}" instead. Call registerFont("${e}", \u2026)`;console.warn(`weasel: font family "${e}" (${t}/${n}) ${o}. Advance widths will differ from the requested font. Use setFontFallbackPolicy('none') to make this a hard miss instead.`)}function LG(e,t,n,r){if(!eo(`unusable-default|${e}|${t}|${n}`))return;let o=ol()===r?"set via setDefaultFontFamily":"the first registered family, since setDefaultFontFamily was never called",i=Dt.has(r)||dd(r)?`has no variant that can serve ${t}/${n}`:"is not registered either";console.warn(`weasel: font family "${e}" (${t}/${n}) is not available, and the fallback family "${r}" (${o}) ${i} \u2014 this text will not render at all. Bake that variant with registerFont("${r}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a family that covers it.`)}function _G(e,t,n){if(!eo(`self-unusable-default|${e}|${t}|${n}`))return;let r=ol()===e?"set via setDefaultFontFamily":"the first registered family, since setDefaultFontFamily was never called";console.warn(`weasel: font family "${e}" (${t}/${n}) has no variant that can serve this request, and "${e}" is also the fallback family (${r}) \u2014 there is nothing left to fall back to, so this text will not render at all. Bake that variant with registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a different family.`)}function DG(e,t,n){eo(`unregistered-default|${e}|${t}|${n}`)&&console.warn(`weasel: font family "${e}" (${t}/${n}) was never registered, and it is also the fallback family \u2014 setDefaultFontFamily("${e}") names a family with no registered variants at all, so there is nothing left to fall back to and this text will not render at all. Call registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a family you have registered.`)}function Oy(e){return e>=600?"bold":"regular"}function xn(e,t,n){return FS(e,t,n,!1,!0)}function md(e,t,n){if(ns()==="none")return null;try{return{entry:null,dynamicFace:fd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"}}catch{return null}}function FS(e,t,n,r,o){ES(e,t,n);let i=Qr(t,n);if(no.size>0&&no.has(`${e}|${i}`)&&!Dt.get(e)?.has(i))return pd(e,t,n);let s=Dt.get(e);if(!s||s.size===0)return ss(e)?pd(e,t,n):NS(e,t,n,r);let a=s.get(i);if(a)return o?AS(a,e,t,n):to(a,e,t,n,!1,!1);let l=Oy(t),u=null;for(let[h,m]of s){let[g,b]=h.split("|"),x=Number(g);if(b!==n||Oy(x)!==l)continue;let w=Math.abs(x-t);(u===null||w<u.distance||w===u.distance&&x>u.weight)&&(u={entry:m,weight:x,distance:w})}if(u)return to(u.entry,e,u.weight,n,!1,!1);let c=s.get(Qr(400,n));if(c)return to(c,e,400,n,t>=600,!1);let d=s.get(Qr(t,"normal"));if(d)return to(d,e,t,"normal",!1,n==="italic");let f=null;for(let[h,m]of s){let[g,b]=h.split("|"),x=Number(g);if(b!=="normal"||Oy(x)!==l)continue;let w=Math.abs(x-t);(f===null||w<f.distance||w===f.distance&&x>f.weight)&&(f={entry:m,weight:x,distance:w})}if(f)return to(f.entry,e,f.weight,"normal",!1,n==="italic");let p=s.get(Qr(400,"normal"));return p?to(p,e,400,"normal",t>=600,n==="italic"):NS(e,t,n,r)}var BG=[[173,173],[847,847],[1564,1564],[4447,4448],[6068,6069],[6155,6159],[8203,8207],[8234,8238],[8288,8303],[12644,12644],[65024,65039],[65279,65279],[65440,65440],[65520,65528],[113824,113827],[119155,119162],[917504,921599]];function LS(e){return BG.some(([t,n])=>e>=t&&e<=n)}function By(e){return e.xadvance>0||e.width>0||e.page<0||LS(e.id)}function DS(e,t){let n=null,r=.5,o,i=()=>{let s=e.faceMetrics;if(s!==n){n=s;let a=s?.ascent!==void 0&&s.descent!==void 0;r=a?s.ascent*e.info.size:.5,o=a?s.descent*e.info.size:void 0}return o!==void 0};return{size:e.info.size,get base(){return e.common.base},get ascent(){return i()?r:e.common.base},get descent(){return i()?o:void 0},advanceOf:t,kernOf:(s,a)=>e.kerningMap.get(s)?.get(a)??0}}function HG(e){let t=e.faceMetrics?.descent;return{size:1,base:e.ascender,ascent:e.faceMetrics?.ascent??e.ascender,...t!==void 0?{descent:t}:{},advanceOf:n=>e.advanceOf(n),kernOf:(n,r)=>e.kernOf(n,r)}}function GG(e){return DS(e.font,t=>{let n=e.requestGlyph(t);return By(n)?n.xadvance:null})}var _S=new WeakMap;function Dy(e,t){let n=_S.get(e);return n||(n=t(e),_S.set(e,n)),n}function as(e){if(e.outlineFace)return Dy(e.outlineFace,HG);if(e.entry)return Dy(e.entry.font,t=>DS(t,n=>t.charMap.get(n)?.xadvance??null));if(e.dynamicFace)return Dy(e.dynamicFace,GG)}var UG=/\p{Emoji_Presentation}|\p{Extended_Pictographic}\uFE0F|\uFE0F\u20E3/u;function BS(e){return e.length===1&&e.charCodeAt(0)<8986?!1:UG.test(e)&&!e.includes("\uFE0E")}function HS(e,t){if(!eo(`missing-glyph|${e}|${t}`))return;let n=String.fromCodePoint(t);console.warn(`weasel: no glyph for U+${t.toString(16).toUpperCase().padStart(4,"0")} (${JSON.stringify(n)}) in "${e}", and the dynamic tier could not rasterize it \u2014 skipping the character. Bake it into the atlas, or call registerCanvasFont("${e}") to serve missing codepoints from installed fonts.`)}var WG=["unusable-default","self-unusable-default","unregistered-default"];function Hy(e,t,n){if(hd(e,t,n))return;let r=`${e}|${t}|${n}`;WG.some(o=>Y1(`${o}|${r}`))||eo(`no-metrics|${r}`)&&console.warn(`weasel: no metrics for "${e}" ${t}/${n} \u2014 neither an atlas nor an outline face resolved, so every run set in it lays out as nothing. Register it with registerFont / registerCanvasFont / registerFontOutlines. If you did, check for a duplicated @weasel-js/font in node_modules \u2014 its registry is module state, so a second copy is a second, empty one.`)}function dl(e,t,n){let r=as(e);if(!r)return null;if(e.outlineFace){let a=r.advanceOf(t);return a===null?null:GS(n,e,r,a,null,null)}let o=e.dynamicFace,i=e.entry?.font??o?.font,s=e.entry?i?.charMap.get(t):o?.requestGlyph(t);return!i||!s||o&&!By(s)?null:GS(n,e,r,s.xadvance,i,s)}function GS(e,t,n,r,o,i){return e?(e.resolved=t,e.metrics=n,e.advance=r,e.font=o,e.glyph=i,e):{resolved:t,metrics:n,advance:r,font:o,glyph:i}}function fl(e,t,n,r,o,i=!0,s){let a=dl(e,o,s);if(a)return a;let l=md(t,n,r),u=l&&dl(l,o,s);return u||(i&&HS(e.resolved.family,o),null)}function Gy(e,t,n,r,o){if(!BS(o))return null;let i=e.dynamicFace?e:md(t,n,r),s=i?.dynamicFace,a=i&&as(i),l=s?.requestCluster(o);return!i||!s||!a||!l?null:{resolved:i,metrics:a,advance:l.xadvance,font:s.font,glyph:l}}var Uy=1,Wy=2,US=.2,VG=.3,gd=1;function Vy(e,t,n){return .5*(e[0]/t+e[1]/n)>US*.9}var zG=`
53
- float area = smoothstep(${US.toFixed(2)}, ${VG.toFixed(2)}, fieldPerPx);
52
+ `,Fy=["u_proj","u_model","u_origin","u_color","u_alpha","u_colorMatrix","u_colorBias"],SS=["a_position"],kS=["a_position","a_vertexColor"];var dl=e=>typeof e=="number"&&Number.isFinite(e);function vS(e){if(e===void 0)return;if(typeof e!="object"||e===null)throw new Error("parseBmFont: faceMetrics must be an object");let t=e,n={};if(t.ascent!==void 0||t.descent!==void 0){if(!dl(t.ascent)||!dl(t.descent)||t.ascent+t.descent<=0)throw new Error("parseBmFont: malformed faceMetrics.ascent/descent");n.ascent=t.ascent,n.descent=t.descent}let r=(o,i,s,a)=>{let l=t[o];if(l===void 0)return;let u=l;if(typeof u!="object"||u===null||!dl(u[i])||!dl(u[s])||u[a]<=0)throw new Error(`parseBmFont: malformed faceMetrics.${o}`);n[o]={[i]:u[i],[s]:u[s]}};r("underline","offset","thickness","thickness"),r("strikethrough","offset","thickness","thickness"),r("superscript","size","shift","size"),r("subscript","size","shift","size");for(let o of["xHeight","capHeight"]){let i=t[o];if(i!==void 0){if(!dl(i)||i<=0)throw new Error(`parseBmFont: malformed faceMetrics.${o}`);n[o]=i}}return Object.keys(n).length>0?n:void 0}function ei(e){return e.outlineFace?.faceMetrics??e.entry?.font.faceMetrics}function AS(e){if(typeof e!="object"||e===null)throw new Error("parseBmFont: expected object");let t=e;if(!t.info||typeof t.info!="object")throw new Error("parseBmFont: missing info");if(!t.common||typeof t.common!="object")throw new Error("parseBmFont: missing common");if(!Array.isArray(t.chars))throw new Error("parseBmFont: chars must be an array");let n=t.info,r=t.common,o=[["info.size",n.size],["common.scaleW",r.scaleW],["common.scaleH",r.scaleH]];for(let[d,f]of o)if(typeof f!="number"||!(f>0)||!Number.isFinite(f))throw new Error(`parseBmFont: ${d} must be a positive number`);if(typeof r.base!="number"||!Number.isFinite(r.base))throw new Error("parseBmFont: common.base must be a number");let i=t.chars,s=Array.isArray(t.kernings)?t.kernings:[],a=new Map;for(let d of i)a.set(d.id,d);let l=new Map;for(let d of s){let f=l.get(d.first);f||(f=new Map,l.set(d.first,f)),f.set(d.second,d.amount)}let u=vS(t.faceMetrics),c=t.distanceField?.distanceRange;return{info:n,common:r,chars:i,kernings:s,charMap:a,kerningMap:l,...u?{faceMetrics:u}:{},...typeof c=="number"&&c>0?{distanceRange:c}:{}}}var as={family:"",weight:NaN,style:"",key:""};function ls(e,t,n){return as.family===e&&as.weight===t&&as.style===n||(as={family:e,weight:t,style:n,key:`${e}|${t}|${n}`}),as.key}var RS=new Map;function no(e,t){let n=RS.get(t);n===void 0&&RS.set(t,n=new Map);let r=n.get(e);return r===void 0&&(r=`${e}|${t}`,n.size<1024&&n.set(e,r)),r}function Ce(){let e=new Set;return{subscribe(t){return e.add(t),()=>{e.delete(t)}},emit(...t){if(e.size!==0){for(let n of[...e])if(e.has(n))try{n(...t)}catch(r){console.error("weasel: a subscriber threw",r)}}},get size(){return e.size}}}function xt(){let e=new Map,t=Ce(),n=0,r=null;function o(){n++,t.emit()}let i={get:a=>e.get(a)?.at(-1)?.value,has:a=>e.has(a),entries(){if(r?.version===n)return r.entries;let a=[];for(let[l,u]of e){let c=u.at(-1);a.push(Object.freeze({key:l,live:c,value:c.value,source:c.source,shadowed:Object.freeze(u.slice(0,-1))}))}return r={version:n,entries:Object.freeze(a)},r.entries},subscribe:t.subscribe,getVersion:()=>n};function s(a,l){let u=e.get(a),c=u?u.lastIndexOf(l):-1;return c===-1?!1:(u.splice(c,1),u.length===0&&e.delete(a),o(),!0)}return{...i,reflection:i,release:s,push(a,l,u){let c=Object.freeze({value:l,source:u?.source}),d=e.get(a);return d?d.push(c):e.set(a,[c]),o(),()=>{s(a,c)}},set(a,l,u){let c=Object.freeze({value:l,source:u?.source}),d=e.get(a);d?d[d.length-1]=c:e.set(a,[c]),o()},delete(a){return e.delete(a)?(o(),!0):!1},clear(){e.size!==0&&(e.clear(),o())},bump:o}}function en(){try{return!1}catch{return!0}}function us(e){return e===Object.prototype||e===null||Object.getPrototypeOf(e)===null}function tn(e){return typeof e=="object"&&e!==null&&us(Object.getPrototypeOf(e))}function ro(e,t,n={}){if(Object.is(e,t))return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((o,i)=>ro(o,t[i],n));if(!tn(e)||!tn(t))return!1;if(n.undefinedAsAbsent)return[...new Set([...Object.keys(e),...Object.keys(t)])].every(o=>ro(e[o],t[o],n));let r=Object.keys(e);return r.length===Object.keys(t).length&&r.every(o=>Object.hasOwn(t,o)&&ro(e[o],t[o],n))}function ud(e,t,n=(r,o)=>r===o){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!n(e[r],t[r]))return!1;return!0}var NS=Ce(),Ly=0;function ti(){return Ly}var IS=0;function fl(){return IS}function bn(){Ly++,IS++,NS.emit()}function ES(){Ly++,NS.emit()}var wG="substitute",PG=null;function cs(){return wG}function pl(){return PG}var _y=new Set;function oo(e){return _y.has(e)?!1:(_y.add(e),!0)}function MS(e){return _y.has(e)}var hl=class{constructor(t){this.format=t}format;pages=[];uploaded=new WeakMap;textureId(t){return`${this.format.idPrefix}${t}`}blit(t,n,r,o,i,s){let a=this.format.channels;for(;this.pages.length<=t;)this.pages.push({data:new Uint8Array(1024*1024*a),version:0,patches:[]});let l=this.pages[t];for(let u=0;u<i;u++)l.data.set(s.subarray(u*o*a,(u+1)*o*a),((r+u)*1024+n)*a);l.version++,l.patches.push({seq:l.version,x:n,y:r,w:o,h:i})}clear(){for(let t of this.pages)t.data.fill(0),t.version++,t.patches=[{seq:t.version,x:0,y:0,w:1024,h:1024}]}sync(t,n){let r=this.pages[n];if(!r)return!1;let o=this.format.channels,i=this.textureId(n),s=this.uploaded.get(t);if(s||(s=new Map,this.uploaded.set(t,s)),!t.has(i))return this.format.upload(t,i,r.data),s.set(n,r.version),!0;let a=s.get(n)??0;if(a>=r.version)return!0;for(let l of r.patches){if(l.seq<=a)continue;let u=new Uint8Array(l.w*l.h*o);for(let c=0;c<l.h;c++){let d=((l.y+c)*1024+l.x)*o;u.set(r.data.subarray(d,d+l.w*o),c*l.w*o)}this.format.patch(t,i,l.x,l.y,l.w,l.h,u)}return s.set(n,r.version),!0}},cd=new hl({channels:1,idPrefix:"weasel-dyn-sdf-page-",upload:(e,t,n)=>e.uploadR8(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageR8(t,n,r,o,i,s)}),dd=new hl({channels:4,idPrefix:"weasel-dyn-color-page-",upload:(e,t,n)=>e.uploadRGBA(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageRGBA(t,n,r,o,i,s)}),ml=new hl({channels:4,idPrefix:"weasel-dyn-color-sharp-page-",upload:(e,t,n)=>e.uploadRGBA(t,1024,1024,n),patch:(e,t,n,r,o,i,s)=>e.subImageRGBA(t,n,r,o,i,s)});function CS(e,t,n,r,o,i){cd.blit(e,t,n,r,o,i)}function OS(e,t,n,r,o,i){dd.blit(e,t,n,r,o,i)}function FS(e,t,n,r,o,i){ml.blit(e,t,n,r,o,i)}function LS(){cd.clear(),dd.clear(),ml.clear()}function _S(){ml.clear()}function fd(e){return cd.textureId(e)}function pd(e){return dd.textureId(e)}function hd(e){return ml.textureId(e)}function md(e,t){return cd.sync(e,t)}function yd(e,t){return dd.sync(e,t)}function gd(e,t){return ml.sync(e,t)}var bd=class{constructor(t,n){this.pageSize=t;this.maxPages=n}pageSize;maxPages;pages=[];get pageCount(){return this.pages.length}fits(t,n){return t<=this.pageSize&&n<=this.pageSize}alloc(t,n){if(!this.fits(t,n))return null;for(let r=0;r<this.pages.length;r++){let o=this.allocInPage(this.pages[r],t,n);if(o)return{page:r,...o}}if(this.pages.length<this.maxPages){let r={shelves:[],nextY:0};this.pages.push(r);let o=this.allocInPage(r,t,n);if(o)return{page:this.pages.length-1,...o}}return null}allocInPage(t,n,r){for(let o of t.shelves)if(r<=o.height&&o.x+n<=this.pageSize){let i=o.x;return o.x+=n,{x:i,y:o.y}}if(t.nextY+r<=this.pageSize){let o={y:t.nextY,height:r,x:n};return t.shelves.push(o),t.nextY+=r,{x:0,y:o.y}}return null}};function DS(e,t,n,r,o){n[0]=0,r[0]=-1e20,r[1]=1e20;let i=0;for(let s=1;s<o;s++){let a=(e[s]+s*s-(e[n[i]]+n[i]*n[i]))/(2*s-2*n[i]);for(;a<=r[i];)i--,a=(e[s]+s*s-(e[n[i]]+n[i]*n[i]))/(2*s-2*n[i]);i++,n[i]=s,r[i]=a,r[i+1]=1e20}i=0;for(let s=0;s<o;s++){for(;r[i+1]<s;)i++;t[s]=(s-n[i])*(s-n[i])+e[n[i]]}}function BS(e,t,n,r,o,i,s){for(let a=0;a<t;a++){for(let l=0;l<n;l++)r[l]=e[l*t+a];DS(r,o,i,s,n);for(let l=0;l<n;l++)e[l*t+a]=o[l]}for(let a=0;a<n;a++){for(let l=0;l<t;l++)r[l]=e[a*t+l];DS(r,o,i,s,t);for(let l=0;l<t;l++)e[a*t+l]=o[l]}}function HS(e,t,n,r,o){let i=t*n,s=new Float64Array(i),a=new Float64Array(i),l=Math.max(t,n),u=new Float64Array(l),c=new Float64Array(l),d=new Int32Array(l),f=new Float64Array(l+1);for(let h=0;h<i;h++){let m=e[h]/255;s[h]=m===1?0:m===0?1e20:Math.max(0,.5-m)**2,a[h]=m===1?1e20:m===0?0:Math.max(0,m-.5)**2}BS(s,t,n,u,c,d,f),BS(a,t,n,u,c,d,f);let p=new Uint8Array(i);for(let h=0;h<i;h++){let m=Math.sqrt(s[h])-Math.sqrt(a[h]),y=Math.round(255-255*(m/r+o));p[h]=y<0?0:y>255?255:y}return p}var ds=8,VS=.5,ri=16,ni=()=>({packer:new bd(1024,4),settled:!0,reclaimScheduled:!1}),Gy=ni(),Uy=ni(),yl=ni(),Gn=[],Dy=!1,By=ri,Hy=0,zS=()=>{},Wy=()=>{},GS=new Set;function KS(e){zS=e}function jS(e){Wy=e}function fs(e,t,n=!1){if(Hy++,t.width===0||t.height===0){e.page=0;return}By>0?(By--,YS(e,t,n)):(Gn.push({char:e,raster:t,sharp:n}),qS())}function $S(e){Gn=Gn.filter(t=>!e.has(t.char))}function YS(e,t,n){let r="rgba"in t,o=n?yl:r?Uy:Gy,i=o.packer.alloc(t.width,t.height);if(!i){TG(o,t,n?kG:SG);return}if(r&&n)FS(i.page,i.x,i.y,t.width,t.height,t.rgba);else if(r)OS(i.page,i.x,i.y,t.width,t.height,t.rgba);else{let s=HS(t.alpha,t.width,t.height,ds,VS);CS(i.page,i.x,i.y,t.width,t.height,s)}e.x=i.x,e.y=i.y,e.width=t.width,e.height=t.height,e.page=i.page}function TG(e,t,n){if(!e.packer.fits(t.width,t.height))US("weasel DynamicGlyphAtlas: a glyph is larger than a page and will not render.");else if(e.settled)e.reclaimScheduled||(e.reclaimScheduled=!0,setTimeout(n,0));else{if(e===yl)return;US(`weasel DynamicGlyphAtlas: more glyphs are in use at once than its pages hold (${4} \xD7 ${1024}\xB2); the rest will not render.`)}}function US(e){GS.has(e)||(GS.add(e),console.warn(e))}function SG(){Gy={...ni(),settled:!1},Uy={...ni(),settled:!1},yl={...ni(),settled:!1},Gn=[],LS(),zS(),Wy(),bn()}function kG(){yl={...ni(),settled:!1},Gn=Gn.filter(e=>!e.sharp),_S(),Wy(),bn()}function qS(){Dy||(Dy=!0,setTimeout(vG,0))}function vG(){Dy=!1;let e=0;for(;Gn.length>0&&e<ri;){let t=Gn.shift();t.char.page===-1&&(YS(t.char,t.raster,t.sharp),e++)}Gn.length>0&&qS(),ES()}function xd(e=ri){By=e,Hy===0&&Gn.length===0&&(Gy.settled=!0,Uy.settled=!0,yl.settled=!0),Hy=0}function Vy(e){return e.trim().replace(/^(["'])(.*)\1$/,"$2").toLowerCase()}function XS(e){let t=typeof document>"u"?void 0:document.fonts;if(!t?.addEventListener)return()=>{};let n=r=>{let o=r.fontfaces??[];o.length>0&&e(o.map(i=>i.family))};return t.addEventListener("loadingdone",n),()=>t.removeEventListener("loadingdone",n)}function JS(e){return/[,"']/.test(e)?e:AG.has(e.trim().toLowerCase())?e.trim():JSON.stringify(e)}var AG=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","emoji","fangsong"]);var Ge=48,nn=8;function RG(e){let t=[1/0,1/0,-1/0,-1/0],n=e.match(/-?\d*\.?\d+(?:e-?\d+)?/gi)??[];for(let r=0;r+1<n.length;r+=2){let o=Number(n[r]),i=Number(n[r+1]);o<t[0]&&(t[0]=o),i<t[1]&&(t[1]=i),o>t[2]&&(t[2]=o),i>t[3]&&(t[3]=i)}return t}var NG=240;function IG(e){let t=new Uint8ClampedArray(e.length),n=!1;for(let r=0;r<e.length;r+=4){let o=e[r+3];if(o===0)continue;let i=e[r],s=e[r+1],a=e[r+2];o>=128&&Math.min(i,s,a)<NG&&(n=!0),t[r]=Math.round(i*o/255),t[r+1]=Math.round(s*o/255),t[r+2]=Math.round(a*o/255),t[r+3]=o}return n?t:null}var wd=1e3;function EG(e,t,n,r=Ge){return`${t==="italic"?"italic ":""}${e} ${r}px ${JS(n)}`}function QS(){let e;if(typeof OffscreenCanvas<"u")e=new OffscreenCanvas(Ge*3,Ge*3);else if(typeof document<"u")e=document.createElement("canvas"),e.width=Ge*3,e.height=Ge*3;else throw new Error("weasel DynamicGlyphAtlas: no canvas available for glyph rasterization");let t=e.getContext("2d",{willReadFrequently:!0});if(!t)throw new Error("weasel DynamicGlyphAtlas: 2D context unavailable");function n(o,i,s,a=Ge){t.font=EG(i,s,o,a),t.textBaseline="alphabetic",t.textAlign="left"}function r(o,i,s,a,l=Ge){n(o,i,s,l);let u=t.measureText(a),c=u.width,d=Math.ceil(u.actualBoundingBoxLeft??0),f=Math.ceil(u.actualBoundingBoxRight??c),p=Math.ceil(u.actualBoundingBoxAscent??l*.8),h=Math.ceil(u.actualBoundingBoxDescent??l*.2),m=d+f,y=p+h;if(m<=0||y<=0)return{data:new Uint8ClampedArray(0),width:0,height:0,left:0,top:0,advance:c};let b=m+2*nn,x=y+2*nn;return(e.width<b||e.height<x)&&(e.width=Math.max(e.width,b),e.height=Math.max(e.height,x),n(o,i,s,l)),t.clearRect(0,0,b,x),t.fillStyle="#fff",t.fillText(a,nn+d,nn+p),{data:t.getImageData(0,0,b,x).data,width:b,height:x,left:-(d+nn),top:p+nn,advance:c}}return{faceMetrics(o,i,s){n(o,i,s,wd);let a=t.measureText("Hg"),l=Ge/wd;return{ascent:(a.fontBoundingBoxAscent??wd*.8)*l,descent:(a.fontBoundingBoxDescent??wd*.2)*l}},rasterize(o,i,s,a){let{data:l,...u}=r(o,i,s,String.fromCodePoint(a)),c=new Uint8ClampedArray(u.width*u.height);for(let d=0;d<c.length;d++)c[d]=l[d*4+3];return{...u,alpha:c}},rasterizePath(o){let[i,s,a,l]=RG(o),u={width:0,height:0,alpha:new Uint8ClampedArray(0),left:0,top:0,advance:0};if(!(a>i&&l>s))return u;let c=Math.floor(i*Ge),d=Math.floor(s*Ge),f=Math.ceil(a*Ge)-c+2*nn,p=Math.ceil(l*Ge)-d+2*nn;(e.width<f||e.height<p)&&(e.width=Math.max(e.width,f),e.height=Math.max(e.height,p)),t.setTransform(1,0,0,1,0,0),t.clearRect(0,0,f,p),t.setTransform(Ge,0,0,Ge,nn-c,nn-d),t.fillStyle="#fff",t.fill(new Path2D(o)),t.setTransform(1,0,0,1,0,0);let h=t.getImageData(0,0,f,p).data,m=new Uint8ClampedArray(f*p);for(let y=0;y<m.length;y++)m[y]=h[y*4+3];return{width:f,height:p,alpha:m,left:c-nn,top:nn-d,advance:0}},rasterizeColor(o,i,s,a,l){let{data:u,...c}=r(o,i,s,a,l),d=IG(u);return d&&{...c,rgba:d}}}}var zy=3,Ky=new WeakMap,Pd=0;jS(()=>{Pd++});function ZS(e,t,n){Ky.set(e,{raster:n,base:t,levels:[],generation:Pd})}function jy(e){return e.generation!==Pd&&(e.levels=[],e.generation=Pd),e.levels}function ek(e){let t=Ky.get(e);return t?jy(t).flatMap(n=>n?[n.glyph]:[]):[]}function MG(e,t){let n=jy(e),r=n[t];if(r!==void 0)return r;let o=2**t,i=e.raster(Ge*o),s=i&&{level:t,glyph:{id:0,x:0,y:0,width:0,height:0,xoffset:i.left/o,yoffset:e.base-i.top/o,xadvance:i.advance/o,page:-1,color:!0}};return n[t]=s,s&&i&&fs(s.glyph,i,!0),s}function Td(e,t){let n=Ky.get(e);if(!n||!(t>1))return null;let r=Math.min(zy,Math.ceil(Math.log2(t)));MG(n,r);let o=jy(n);for(let i=r;i>0;i--){let s=o[i];if(s&&s.glyph.page>=0)return s}return null}var Sd=new Set,kd=new Set,vd=new Map,$y=null,CG=null;function tk(e){e.font.charMap.clear(),e.font.chars.length=0,e.clusters.clear(),e.shaped.clear()}KS(()=>{for(let e of vd.values())tk(e)});function nk(){return $y||($y=QS()),$y}function Ad(e){return Sd.has(e)?!kd.has(e)||cs()==="canvas":!1}function rk(e){Sd.has(e)&&!kd.has(e)||(Sd.add(e),kd.add(e))}function Yy(e){return Sd.has(e)&&!kd.has(e)}function Rd(e,t,n){let r=`${e}|${t}|${n}`,o=vd.get(r);if(o)return o;let i=nk(),s={info:{face:e,size:Ge},common:{lineHeight:0,base:0,scaleW:1024,scaleH:1024},chars:[],kernings:[],charMap:new Map,kerningMap:new Map},a=(d,f)=>({id:d,x:0,y:0,width:0,height:0,xoffset:f.left,yoffset:s.common.base-f.top,xadvance:f.advance,page:-1}),l=new Map,u=new Map,c={family:e,weight:t,style:n,font:s,clusters:l,shaped:u,requestGlyph(d){let f=s.charMap.get(d);if(f)return f;let p=i.rasterize(e,t,n,d),h=a(d,p);return s.charMap.set(d,h),s.chars.push(h),fs(h,p),h},requestCluster(d){let f=l.get(d);if(f!==void 0)return f;let p=i.rasterizeColor?.(e,t,n,d)??null,h=p&&{...a(d.codePointAt(0),p),color:!0};return l.set(d,h),h&&p&&(fs(h,p),ZS(h,s.common.base,m=>i.rasterizeColor?.(e,t,n,d,m)??null)),h},requestShaped(d,f){let p=u.get(d);if(p!==void 0)return p;let h=typeof Path2D>"u"?null:i.rasterizePath?.(f)??null,m=h&&a(0,h);return u.set(d,m),m&&h&&fs(m,h),m}};return ok(c),vd.set(r,c),CG??=XS(OG),c}function ok(e){let{font:t}=e,n=nk().faceMetrics(e.family,e.weight,e.style);t.common.lineHeight=Math.round(n.ascent+n.descent),t.common.base=Math.round(n.ascent),t.faceMetrics={ascent:n.ascent/Ge,descent:n.descent/Ge},tk(e)}function OG(e){let t=e&&new Set(e.map(Vy)),n=new Set,r=0;for(let o of vd.values())if(!(t&&!o.family.split(",").some(i=>t.has(Vy(i))))){for(let i of o.font.chars)n.add(i);for(let i of o.shaped.values())i&&n.add(i);for(let i of o.clusters.values())if(i){n.add(i);for(let s of ek(i))n.add(s)}ok(o),r++}r!==0&&($S(n),bn())}var fr=xt(),FG=fr.reflection;function oi(e,t,n){return`${e}|${t}|${n}`}function LG(e){return{weight:e.weight??400,style:e.style??"normal"}}function qy(e,t=400,n="normal"){return fr.has(oi(e,t,n))}function Xy(e,t=400,n="normal"){return fr.get(oi(e,t,n))?.status??null}function _G(e){let t="",n=0;for(let r=1;r<e.length;r++){let o=e[r];o!=="M"&&o!=="m"||(t+=ik(e.slice(n,r)),n=r)}return t+ik(e.slice(n))}function ik(e){let t=e.trimEnd();if(t.length===0)return"";let n=t[t.length-1];return n==="Z"||n==="z"?t:`${t}Z`}function Jy(e,t,n,r){let o=fr.get(oi(e,t,n));if(!o)return null;if(o.status==="idle")return Zy(o),null;if(o.status!=="ready")return null;let i=o.glyphs.get(r);if(i!==void 0)return i;let s=null;try{let a=o.face.glyphD(r);s=a===null?null:_G(a)}catch(a){ak(`glyph|${oi(e,t,n)}`,`weasel: outline face "${e}" (${t}/${n}) could not produce a glyph for U+${r.toString(16).toUpperCase().padStart(4,"0")} \u2014 ${a instanceof Error?a.message:String(a)}. Falling back to the SDF tier.`)}return o.glyphs.set(r,s),s}function gl(e,t,n){let r=fr.get(oi(e,t,n));return r?r.status==="idle"?(Zy(r),null):r.status==="ready"?r.face:null:null}async function Qy(e,t={}){let{weight:n,style:r}=LG(t),o=fr.get(oi(e,n,r));return o?(await Zy(o),o.status):null}function Zy(e){return e.load??=DG(e),e.load}async function DG(e){e.status="loading",fr.bump();try{let t=await GG(e.source);HG(e,t),e.face=await e.parser(t),e.status="ready",fr.bump(),bn()}catch(t){e.status="failed",fr.bump(),bn(),ak(`load|${oi(e.family,e.weight,e.style)}`,`weasel registerFontOutlines("${e.family}" ${e.weight}/${e.style}): ${t instanceof Error?t.message:String(t)}. Large text in this face keeps rendering from the SDF tier.`)}}var BG=null;function HG(e,t){try{BG?.(e,t)}catch{}}async function GG(e){let t=typeof e=="function"?await e():e;if(typeof t=="string"){let n=await fetch(t);if(!n.ok)throw new Error(`HTTP ${n.status} fetching ${t}`);return n.arrayBuffer()}return t instanceof ArrayBuffer?t:t.arrayBuffer()}var sk=new Set;function ak(e,t){sk.has(e)||(sk.add(e),console.warn(t))}function io(e,t,n,r,o,i){return{entry:e,resolved:{family:t,weight:n,style:r},synthetic:{bold:o,italic:i},source:"atlas"}}var lk=new WeakMap;function uk(e,t,n,r){let o=lk.get(e);if(o!==void 0&&o.resolved.family===t&&o.resolved.weight===n&&o.resolved.style===r)return o;let i=io(e,t,n,r,!1,!1);return Object.freeze(i.resolved),Object.freeze(i.synthetic),lk.set(e,Object.freeze(i)),i}var Ht=xt(),WG=Ht.reflection;function VG(e){return{weight:e.weight??400,style:e.style??"normal"}}var bl=new Map,so=new Map,ps=new Map,tg=new Set;function xl(e,t=400,n="normal"){return Ht.get(e)?.get(no(t,n))??null}function fk(e,t,n,r){let o=`${e}|${t}`,i=so.get(o);if(i)return i;let s=zG(e,t,n,r);so.set(o,s);let a=()=>{so.get(o)===s&&so.delete(o)};s.then(a,a);let l=ps.get(e)?.get(t);if(l){let u=ps.get(e);u.delete(t),u.size===0&&ps.delete(e),l.settle(s)}return s}async function zG(e,t,n,r){let[o,i]=t.split("|"),s={},a=bl.get(e)??new Set;bl.set(e,a.add(s));try{let[l,u]=await Promise.all([fetch(n),fetch(r)]);if(!l.ok)throw new Error(`HTTP ${l.status} fetching metrics from ${n}`);if(!u.ok)throw new Error(`HTTP ${u.status} fetching atlas from ${r}`);let[c,d]=await Promise.all([l.json(),u.blob()]),f=AS(c),p=await createImageBitmap(d);Ht.set(e,new Map(Ht.get(e)).set(t,{font:f,bitmap:p})),ck(e,s),bn()}catch(l){throw ck(e,s),bn(),new Error(`weasel registerFont("${e}" ${o}/${i}): ${l instanceof Error?l.message:String(l)}`)}}function pk(e,t,n){let r=ps.get(e);if(!r)return;let o=no(t,n),i=r.has(o)?[o]:[...r.keys()];for(let s of i){let{metricsUrl:a,atlasUrl:l}=r.get(s);fk(e,s,a,l).catch(()=>{})}}function ng(e){let t=[];for(let n of e??[...tg]){if(typeof n!="string"){let{weight:r,style:o}=VG(n);t.push(...mk(n.family,r,o));continue}if(!tg.has(n))return Promise.reject(new Error(`weasel warmFonts: "${n}" was never registered.`));for(let[r,{metricsUrl:o,atlasUrl:i}]of[...ps.get(n)??[]])fk(n,r,o,i);t.push(...hk(n))}return Promise.all(t).then(()=>{})}function hk(e){return[...so].filter(([t])=>t.startsWith(`${e}|`)).map(([,t])=>t)}function mk(e,t,n){let r=[],o=qy(e,t,n);o&&r.push(Qy(e,{weight:t,style:n}));let i=no(t,n);if(Ht.get(e)?.has(i))return r;pk(e,t,n);let s=so.get(`${e}|${i}`);if(s)return[...r,s];if(Ht.has(e)||hs(e))return[...r,...hk(e)];if(o||Yy(e)||cs()!=="substitute")return r;let a=pl()??yk();return a!==null&&a!==e?[...r,...mk(a,t,n)]:r}function hs(e){return bl.has(e)||ps.has(e)}function ck(e,t){let n=bl.get(e);n?.delete(t)&&n.size===0&&bl.delete(e)}function Id(e,t=400,n="normal"){if(hs(e))return!0;let r=Xy(e,t,n==="italic"?"italic":"normal");return r==="idle"||r==="loading"}function rg(e,t,n,r){let o=xl(e,t,n);return o?(r.upload(ls(e,t,n),o.bitmap),!0):!1}function dk(e,t,n,r=!1){if(Yy(e))return{entry:null,dynamicFace:Rd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"};let o=gl(e,t,n==="italic"?"italic":"normal");if(o)return{entry:null,outlineFace:o,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"outline"};if(Id(e,t,n))return Nd(e,t,n);let i=cs();if(i==="canvas")return rk(e),{entry:null,dynamicFace:Rd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"};if(i==="substitute"){let s=pl()??yk();if(s!==null&&s!==e){if(Ht.has(s)||Ad(s)||hs(s)){let a=gk(s,t,n,!0,!1);if(a.entry!==null||a.dynamicFace!==void 0)return r||KG(e,t,n,s),{...a,substituted:{requested:e,resolved:s}};if(hs(s))return Nd(e,t,n)}r||jG(e,t,n,s)}else s===e&&!r&&(Ht.has(e)?$G(e,t,n):YG(e,t,n))}return{entry:null,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"atlas"}}function yk(){for(let e of tg)if(Ht.has(e)||hs(e))return e;return null}function Nd(e,t,n){return{entry:null,resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"atlas"}}function KG(e,t,n,r){if(!oo(`substituted|${e}|${t}|${n}`))return;let o=Ht.has(e)?`has no variant matching ${t}/${n}, and none of its registered variants are close enough for the within-family chain to substitute \u2014 rendering with "${r}" instead. Bake that variant with registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026)`:`is not registered \u2014 rendering with "${r}" instead. Call registerFont("${e}", \u2026)`;console.warn(`weasel: font family "${e}" (${t}/${n}) ${o}. Advance widths will differ from the requested font. Use setFontFallbackPolicy('none') to make this a hard miss instead.`)}function jG(e,t,n,r){if(!oo(`unusable-default|${e}|${t}|${n}`))return;let o=pl()===r?"set via setDefaultFontFamily":"the first registered family, since setDefaultFontFamily was never called",i=Ht.has(r)||Ad(r)?`has no variant that can serve ${t}/${n}`:"is not registered either";console.warn(`weasel: font family "${e}" (${t}/${n}) is not available, and the fallback family "${r}" (${o}) ${i} \u2014 this text will not render at all. Bake that variant with registerFont("${r}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a family that covers it.`)}function $G(e,t,n){if(!oo(`self-unusable-default|${e}|${t}|${n}`))return;let r=pl()===e?"set via setDefaultFontFamily":"the first registered family, since setDefaultFontFamily was never called";console.warn(`weasel: font family "${e}" (${t}/${n}) has no variant that can serve this request, and "${e}" is also the fallback family (${r}) \u2014 there is nothing left to fall back to, so this text will not render at all. Bake that variant with registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a different family.`)}function YG(e,t,n){oo(`unregistered-default|${e}|${t}|${n}`)&&console.warn(`weasel: font family "${e}" (${t}/${n}) was never registered, and it is also the fallback family \u2014 setDefaultFontFamily("${e}") names a family with no registered variants at all, so there is nothing left to fall back to and this text will not render at all. Call registerFont("${e}", { weight: ${t}, style: '${n}' }, \u2026), or point setDefaultFontFamily() at a family you have registered.`)}function eg(e){return e>=600?"bold":"regular"}function xn(e,t,n){return gk(e,t,n,!1,!0)}function Ed(e,t,n){if(cs()==="none")return null;try{return{entry:null,dynamicFace:Rd(e,t,n),resolved:{family:e,weight:t,style:n},synthetic:{bold:!1,italic:!1},source:"canvas"}}catch{return null}}function gk(e,t,n,r,o){pk(e,t,n);let i=no(t,n);if(so.size>0&&so.has(`${e}|${i}`)&&!Ht.get(e)?.has(i))return Nd(e,t,n);let s=Ht.get(e);if(!s||s.size===0)return hs(e)?Nd(e,t,n):dk(e,t,n,r);let a=s.get(i);if(a)return o?uk(a,e,t,n):io(a,e,t,n,!1,!1);let l=eg(t),u=null;for(let[h,m]of s){let[y,b]=h.split("|"),x=Number(y);if(b!==n||eg(x)!==l)continue;let w=Math.abs(x-t);(u===null||w<u.distance||w===u.distance&&x>u.weight)&&(u={entry:m,weight:x,distance:w})}if(u)return io(u.entry,e,u.weight,n,!1,!1);let c=s.get(no(400,n));if(c)return io(c,e,400,n,t>=600,!1);let d=s.get(no(t,"normal"));if(d)return io(d,e,t,"normal",!1,n==="italic");let f=null;for(let[h,m]of s){let[y,b]=h.split("|"),x=Number(y);if(b!=="normal"||eg(x)!==l)continue;let w=Math.abs(x-t);(f===null||w<f.distance||w===f.distance&&x>f.weight)&&(f={entry:m,weight:x,distance:w})}if(f)return io(f.entry,e,f.weight,"normal",!1,n==="italic");let p=s.get(no(400,"normal"));return p?io(p,e,400,"normal",t>=600,n==="italic"):dk(e,t,n,r)}var qG=[[173,173],[847,847],[1564,1564],[4447,4448],[6068,6069],[6155,6159],[8203,8207],[8234,8238],[8288,8303],[12644,12644],[65024,65039],[65279,65279],[65440,65440],[65520,65528],[113824,113827],[119155,119162],[917504,921599]];function bk(e){return qG.some(([t,n])=>e>=t&&e<=n)}function ig(e){return e.xadvance>0||e.width>0||e.page<0||bk(e.id)}function wk(e,t){let n=null,r=.5,o,i=()=>{let s=e.faceMetrics;if(s!==n){n=s;let a=s?.ascent!==void 0&&s.descent!==void 0;r=a?s.ascent*e.info.size:.5,o=a?s.descent*e.info.size:void 0}return o!==void 0};return{size:e.info.size,get base(){return e.common.base},get ascent(){return i()?r:e.common.base},get descent(){return i()?o:void 0},advanceOf:t,kernOf:(s,a)=>e.kerningMap.get(s)?.get(a)??0}}function XG(e){let t=e.faceMetrics?.descent;return{size:1,base:e.ascender,ascent:e.faceMetrics?.ascent??e.ascender,...t!==void 0?{descent:t}:{},advanceOf:n=>e.advanceOf(n),kernOf:(n,r)=>e.kernOf(n,r)}}function JG(e){return wk(e.font,t=>{let n=e.requestGlyph(t);return ig(n)?n.xadvance:null})}var xk=new WeakMap;function og(e,t){let n=xk.get(e);return n||(n=t(e),xk.set(e,n)),n}function ms(e){if(e.outlineFace)return og(e.outlineFace,XG);if(e.entry)return og(e.entry.font,t=>wk(t,n=>t.charMap.get(n)?.xadvance??null));if(e.dynamicFace)return og(e.dynamicFace,JG)}var QG=/\p{Emoji_Presentation}|\p{Extended_Pictographic}\uFE0F|\uFE0F\u20E3/u;function Pk(e){return e.length===1&&e.charCodeAt(0)<8986?!1:QG.test(e)&&!e.includes("\uFE0E")}function Tk(e,t){if(!oo(`missing-glyph|${e}|${t}`))return;let n=String.fromCodePoint(t);console.warn(`weasel: no glyph for U+${t.toString(16).toUpperCase().padStart(4,"0")} (${JSON.stringify(n)}) in "${e}", and the dynamic tier could not rasterize it \u2014 skipping the character. Bake it into the atlas, or call registerCanvasFont("${e}") to serve missing codepoints from installed fonts.`)}var ZG=["unusable-default","self-unusable-default","unregistered-default"];function sg(e,t,n){if(Id(e,t,n))return;let r=`${e}|${t}|${n}`;ZG.some(o=>MS(`${o}|${r}`))||oo(`no-metrics|${r}`)&&console.warn(`weasel: no metrics for "${e}" ${t}/${n} \u2014 neither an atlas nor an outline face resolved, so every run set in it lays out as nothing. Register it with registerFont / registerCanvasFont / registerFontOutlines. If you did, check for a duplicated @weasel-js/font in node_modules \u2014 its registry is module state, so a second copy is a second, empty one.`)}function wl(e,t,n){let r=ms(e);if(!r)return null;if(e.outlineFace){let a=r.advanceOf(t);return a===null?null:Sk(n,e,r,a,null,null)}let o=e.dynamicFace,i=e.entry?.font??o?.font,s=e.entry?i?.charMap.get(t):o?.requestGlyph(t);return!i||!s||o&&!ig(s)?null:Sk(n,e,r,s.xadvance,i,s)}function Sk(e,t,n,r,o,i){return e?(e.resolved=t,e.metrics=n,e.advance=r,e.font=o,e.glyph=i,e):{resolved:t,metrics:n,advance:r,font:o,glyph:i}}function Pl(e,t,n,r,o,i=!0,s){let a=wl(e,o,s);if(a)return a;let l=Ed(t,n,r),u=l&&wl(l,o,s);return u||(i&&Tk(e.resolved.family,o),null)}function ag(e,t,n,r,o){if(!Pk(o))return null;let i=e.dynamicFace?e:Ed(t,n,r),s=i?.dynamicFace,a=i&&ms(i),l=s?.requestCluster(o);return!i||!s||!a||!l?null:{resolved:i,metrics:a,advance:l.xadvance,font:s.font,glyph:l}}var lg=1,ug=2,kk=.2,eU=.3,Cd=1;function cg(e,t,n){return .5*(e[0]/t+e[1]/n)>kk*.9}var tU=`
53
+ float area = smoothstep(${kk.toFixed(2)}, ${eU.toFixed(2)}, fieldPerPx);
54
54
  if (area > 0.0) {
55
55
  float band = 0.5 * aaW;
56
56
  float lo = threshold - 0.5 * band;
@@ -62,15 +62,15 @@ void main() {
62
62
  at = vec2(-at.y, at.x);
63
63
  }
64
64
  coverage = mix(coverage, 0.25 * sum, area);
65
- }`,KG=`
65
+ }`,nU=`
66
66
  float glyphInCell(vec2 c, vec2 margin) {
67
67
  vec2 inside = step(margin, c) * step(c, 1.0 - margin);
68
68
  return inside.x * inside.y;
69
69
  }
70
- `,jG=`
70
+ `,rU=`
71
71
  vec2 dcx = dFdx(cell);
72
72
  vec2 dcy = dFdy(cell);
73
- vec2 margin = ${gd.toFixed(1)} * vec2(length(vec2(dcx.x, dcy.x)), length(vec2(dcx.y, dcy.y)));`;function WS(e){return`
73
+ vec2 margin = ${Cd.toFixed(1)} * vec2(length(vec2(dcx.x, dcy.x)), length(vec2(dcx.y, dcy.y)));`;function vk(e){return`
74
74
  float median(float r, float g, float b) {
75
75
  return max(min(r, g), min(max(r, g), b));
76
76
  }
@@ -78,53 +78,53 @@ float median(float r, float g, float b) {
78
78
  float glyphField(vec4 texel, float mode) {
79
79
  return mix(median(texel.r, texel.g, texel.b), texel.r, step(1.5, mode));
80
80
  }
81
- ${e?KG:""}
81
+ ${e?nU:""}
82
82
  float glyphCoverage(vec4 texel, float mode, float synthBold, vec2 uv, vec2 fieldPerUv${e?", vec2 cell":""}) {
83
83
  vec2 du = dFdx(uv);
84
- vec2 dv = dFdy(uv);${e?jG:""}
84
+ vec2 dv = dFdy(uv);${e?rU:""}
85
85
  float fieldPerPx = 0.5 * (length(du * fieldPerUv) + length(dv * fieldPerUv));
86
86
  float aaW = max(0.5 * fieldPerPx, 0.0005);
87
87
  float threshold = 0.5 - synthBold;
88
88
  float field = glyphField(texel, mode);
89
- float coverage = smoothstep(threshold - aaW, threshold + aaW, field)${e?" * glyphInCell(cell, margin)":""};${e?zG:""}
89
+ float coverage = smoothstep(threshold - aaW, threshold + aaW, field)${e?" * glyphInCell(cell, margin)":""};${e?tU:""}
90
90
  return coverage;
91
91
  }
92
- `}var hl=WS(!0),zy=WS(!1),VS=4,$G=[1024/rs,1024/rs];function Ky(e,t,n,r){if(e==="canvas")return $G;let o=cl(t,n,r)?.font;if(!o)return;let i=o.distanceRange??VS,s=o.common.scaleW/i,a=o.common.scaleH/i;return(yd[0]!==s||yd[1]!==a)&&(yd=[s,a]),yd}var yd=[NaN,NaN],pl=.08;function jy(e,t,n,r){if(e==="canvas")return pl*rs/He;let o=cl(t,n,r)?.font;if(o)return pl*(o.distanceRange??VS)/o.info.size}var bd=`
92
+ `}var Sl=vk(!0),dg=vk(!1),Ak=4,oU=[1024/ds,1024/ds];function fg(e,t,n,r){if(e==="canvas")return oU;let o=xl(t,n,r)?.font;if(!o)return;let i=o.distanceRange??Ak,s=o.common.scaleW/i,a=o.common.scaleH/i;return(Md[0]!==s||Md[1]!==a)&&(Md=[s,a]),Md}var Md=[NaN,NaN],Tl=.08;function pg(e,t,n,r){if(e==="canvas")return Tl*ds/Ge;let o=xl(t,n,r)?.font;if(o)return Tl*(o.distanceRange??Ak)/o.info.size}var Od=`
93
93
  vec3 straightRgb(vec4 premultiplied) {
94
94
  return premultiplied.rgb / max(premultiplied.a, 0.0001);
95
95
  }
96
- `;Z();var uo=8,vs=64,Vd=16,vn=Vd,Vv=2**24,jg=16384,zd=32768,ks=jg,Kg=zd;function $v(e,t,n,r){let o=n/2,i=r/2;return{ax:e[0]*o,bx:e[3]*o,cx:(e[6]+1)*o+t[0],ay:e[1]*i,by:e[4]*i,cy:(e[7]+1)*i+t[1],midX:t[0]+o,midY:t[1]+i}}var zv=new WeakMap;function $g(e,t,n){let r=zv.get(e);if(r!==void 0&&CU(r.m,t)&&OU(r.map,n))return r.hull;let o=FU(e,t,n);return zv.set(e,{m:Float64Array.of(t[0],t[1],t[3],t[4],t[6],t[7]),map:n,hull:o}),o}var Kv=new WeakMap;function Yv(e,t,n){if(n.bx!==0||n.ay!==0)return null;let r=$g(e,t,n);if(r===null)return null;let o=Kv.get(r);return o===void 0&&(o={rect:MU(r.path),hull:r},Kv.set(r,o)),o}function MU(e){if(e.kind==="rect")return{x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+e.height};let t=e.origin?.x??0,n=e.origin?.y??0,r=e.coords,o=1/0,i=1/0,s=-1/0,a=-1/0;for(let l=0;l<r.length;l+=2){let u=r[l]+t,c=r[l+1]+n;u<o&&(o=u),u>s&&(s=u),c<i&&(i=c),c>a&&(a=c)}return{x0:o,y0:i,x1:s,y1:a}}function CU(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[3]&&e[3]===t[4]&&e[4]===t[6]&&e[5]===t[7]}function OU(e,t){return e.ax===t.ax&&e.bx===t.bx&&e.cx===t.cx&&e.ay===t.ay&&e.by===t.by&&e.cy===t.cy&&e.midX===t.midX&&e.midY===t.midY}function FU(e,t,n){let r=qg(e);if(r===null||r.length<6)return null;let o=[];for(let a=0;a<r.length;a+=2){let l=t[0]*r[a]+t[3]*r[a+1]+t[6],u=t[1]*r[a]+t[4]*r[a+1]+t[7],c=Math.round((n.ax*l+n.bx*u+n.cx)*vn),d=Math.round((n.ay*l+n.by*u+n.cy)*vn);if(!(Math.abs(c)<Vv&&Math.abs(d)<Vv))return null;let f=o.length;f>=2&&o[f-2]===c&&o[f-1]===d||o.push(c,d)}for(;o.length>=4&&o[0]===o[o.length-2]&&o[1]===o[o.length-1];)o.length-=2;yr(o)<0&&Xg(o);let i=Jg(o),s=HU(i.length>=6?i:o,n);return i.length<6?{set:qv,path:s}:i.length/2>uo||!Qg(i)?null:{set:BU(i,n),path:s}}var qv={planes:Int32Array.of(0,0,-1,Wd(0,0)),count:1},LU={planes:Int32Array.of(0,0,0,Wd(0,0)),count:1};function Yg(e,t){let n=[];for(let r of[e,t])for(let o=0;o<r.count;o++){let i=r.planes.subarray(4*o,4*o+4);if(i[0]===0&&i[1]===0){if(i[2]<0)return qv;continue}let s=_U(n,i[0],i[1]);s<0?n.push(i[0],i[1],i[2],i[3]):jv(i,0)>jv(n,s)&&n.splice(s,4,i[0],i[1],i[2],i[3])}return n.length===0?LU:n.length/4>uo?null:{planes:Int32Array.from(n),count:n.length/4}}function _U(e,t,n){for(let r=0;r<e.length;r+=4){let o=e[r],i=e[r+1];if(o*n===i*t&&o*t+i*n>0)return r}return-1}function jv(e,t){let n=e[t],r=e[t+1],o=e[t+3],i=o%Kg-ks,s=Math.floor(o/Kg)-ks,a=e[t+2]-vn*(n*i+r*s);return Math.ceil(-a/DU(Math.abs(n),Math.abs(r)))}function DU(e,t){for(;t!==0;)[e,t]=[t,e%t];return e}function qg(e){if(e.kind==="rect"){let{x:i,y:s,width:a,height:l}=e;return[i,s,i+a,s,i+a,s+l,i,s+l]}if(e.corners?.some(i=>i!==null))return null;let{commands:t,coords:n}=e;if(t.length<4||t[0]!==le||t[t.length-1]!==fe)return null;for(let i=1;i<t.length-1;i++)if(t[i]!==ce)return null;let r=e.origin?.x??0,o=e.origin?.y??0;return Array.from(n.subarray(0,(t.length-1)*2),(i,s)=>i+(s&1?o:r))}function Xg(e){for(let t=0,n=e.length-2;t<n;t+=2,n-=2){let r=e[t],o=e[t+1];e[t]=e[n],e[t+1]=e[n+1],e[n]=r,e[n+1]=o}}function Xv(e,t,n,r){return(e[n]-e[t])*(e[r+1]-e[n+1])-(e[n+1]-e[t+1])*(e[r]-e[n])}function Jg(e){let t=[],n=e.length;for(let r=0;r<n;r+=2)Xv(e,(r-2+n)%n,r,(r+2)%n)!==0&&t.push(e[r],e[r+1]);return t}function Qg(e){let t=e.length,n=0,r=0;for(let o=0;o<t;o+=2){if(Xv(e,o,(o+2)%t,(o+4)%t)<=0)return!1;let i=Math.sign(e[(o+2)%t]-e[o]);i!==0&&(r!==0&&i!==r&&n++,r=i)}return n<=2}function Wd(e,t){return e+ks+(t+ks)*Kg}function BU(e,t){let n=e.length/2,r=new Int32Array(n*4),o=t.midX*vn,i=t.midY*vn;for(let s=0;s<n;s++){let a=e[2*s],l=e[2*s+1],u=e[(2*s+2)%e.length]-a,c=e[(2*s+3)%e.length]-l,d=-c,f=u,p=d>0||d===0&&f>0?0:1,h=((o-a)*u+(i-l)*c)/(u*u+c*c),m=Math.round((a+h*u)/vn),g=Math.round((l+h*c)/vn),b;Math.abs(m)<ks&&Math.abs(g)<ks?b=[d,f,d*(vn*m-a)+f*(vn*g-l)-p,Wd(m,g)]:b=[0,0,d*(o-a)+f*(i-l)>=p?0:-1,Wd(0,0)],r.set(b,s*4)}return{planes:r,count:n}}function HU(e,t){let n=t.ax*t.by-t.bx*t.ay,r=[];for(let o=0;o<e.length;o+=2){let i=e[o]/vn-t.cx,s=e[o+1]/vn-t.cy;r.push({x:(t.by*i-t.bx*s)/n,y:(t.ax*s-t.ay*i)/n})}return Qy(r)}var Jv=(2**30).toFixed(1),Qv=`
97
- uniform ivec4 u_hullPlanes[${vs}];
96
+ `;Z();var yo=8,Ms=64,df=16,vn=df,VA=2**24,Ab=16384,ff=32768,Es=Ab,vb=ff;function $A(e,t,n,r){let o=n/2,i=r/2;return{ax:e[0]*o,bx:e[3]*o,cx:(e[6]+1)*o+t[0],ay:e[1]*i,by:e[4]*i,cy:(e[7]+1)*i+t[1],midX:t[0]+o,midY:t[1]+i}}var zA=new WeakMap;function Rb(e,t,n){let r=zA.get(e);if(r!==void 0&&dW(r.m,t)&&fW(r.map,n))return r.hull;let o=pW(e,t,n);return zA.set(e,{m:Float64Array.of(t[0],t[1],t[3],t[4],t[6],t[7]),map:n,hull:o}),o}var KA=new WeakMap;function YA(e,t,n){if(n.bx!==0||n.ay!==0)return null;let r=Rb(e,t,n);if(r===null)return null;let o=KA.get(r);return o===void 0&&(o={rect:cW(r.path),hull:r},KA.set(r,o)),o}function cW(e){if(e.kind==="rect")return{x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+e.height};let t=e.origin?.x??0,n=e.origin?.y??0,r=e.coords,o=1/0,i=1/0,s=-1/0,a=-1/0;for(let l=0;l<r.length;l+=2){let u=r[l]+t,c=r[l+1]+n;u<o&&(o=u),u>s&&(s=u),c<i&&(i=c),c>a&&(a=c)}return{x0:o,y0:i,x1:s,y1:a}}function dW(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[3]&&e[3]===t[4]&&e[4]===t[6]&&e[5]===t[7]}function fW(e,t){return e.ax===t.ax&&e.bx===t.bx&&e.cx===t.cx&&e.ay===t.ay&&e.by===t.by&&e.cy===t.cy&&e.midX===t.midX&&e.midY===t.midY}function pW(e,t,n){let r=Ib(e);if(r===null||r.length<6)return null;let o=[];for(let a=0;a<r.length;a+=2){let l=t[0]*r[a]+t[3]*r[a+1]+t[6],u=t[1]*r[a]+t[4]*r[a+1]+t[7],c=Math.round((n.ax*l+n.bx*u+n.cx)*vn),d=Math.round((n.ay*l+n.by*u+n.cy)*vn);if(!(Math.abs(c)<VA&&Math.abs(d)<VA))return null;let f=o.length;f>=2&&o[f-2]===c&&o[f-1]===d||o.push(c,d)}for(;o.length>=4&&o[0]===o[o.length-2]&&o[1]===o[o.length-1];)o.length-=2;xr(o)<0&&Eb(o);let i=Mb(o),s=bW(i.length>=6?i:o,n);return i.length<6?{set:qA,path:s}:i.length/2>yo||!Cb(i)?null:{set:gW(i,n),path:s}}var qA={planes:Int32Array.of(0,0,-1,cf(0,0)),count:1},hW={planes:Int32Array.of(0,0,0,cf(0,0)),count:1};function Nb(e,t){let n=[];for(let r of[e,t])for(let o=0;o<r.count;o++){let i=r.planes.subarray(4*o,4*o+4);if(i[0]===0&&i[1]===0){if(i[2]<0)return qA;continue}let s=mW(n,i[0],i[1]);s<0?n.push(i[0],i[1],i[2],i[3]):jA(i,0)>jA(n,s)&&n.splice(s,4,i[0],i[1],i[2],i[3])}return n.length===0?hW:n.length/4>yo?null:{planes:Int32Array.from(n),count:n.length/4}}function mW(e,t,n){for(let r=0;r<e.length;r+=4){let o=e[r],i=e[r+1];if(o*n===i*t&&o*t+i*n>0)return r}return-1}function jA(e,t){let n=e[t],r=e[t+1],o=e[t+3],i=o%vb-Es,s=Math.floor(o/vb)-Es,a=e[t+2]-vn*(n*i+r*s);return Math.ceil(-a/yW(Math.abs(n),Math.abs(r)))}function yW(e,t){for(;t!==0;)[e,t]=[t,e%t];return e}function Ib(e){if(e.kind==="rect"){let{x:i,y:s,width:a,height:l}=e;return[i,s,i+a,s,i+a,s+l,i,s+l]}if(e.corners?.some(i=>i!==null))return null;let{commands:t,coords:n}=e;if(t.length<4||t[0]!==se||t[t.length-1]!==fe)return null;for(let i=1;i<t.length-1;i++)if(t[i]!==ae)return null;let r=e.origin?.x??0,o=e.origin?.y??0;return Array.from(n.subarray(0,(t.length-1)*2),(i,s)=>i+(s&1?o:r))}function Eb(e){for(let t=0,n=e.length-2;t<n;t+=2,n-=2){let r=e[t],o=e[t+1];e[t]=e[n],e[t+1]=e[n+1],e[n]=r,e[n+1]=o}}function XA(e,t,n,r){return(e[n]-e[t])*(e[r+1]-e[n+1])-(e[n+1]-e[t+1])*(e[r]-e[n])}function Mb(e){let t=[],n=e.length;for(let r=0;r<n;r+=2)XA(e,(r-2+n)%n,r,(r+2)%n)!==0&&t.push(e[r],e[r+1]);return t}function Cb(e){let t=e.length,n=0,r=0;for(let o=0;o<t;o+=2){if(XA(e,o,(o+2)%t,(o+4)%t)<=0)return!1;let i=Math.sign(e[(o+2)%t]-e[o]);i!==0&&(r!==0&&i!==r&&n++,r=i)}return n<=2}function cf(e,t){return e+Es+(t+Es)*vb}function gW(e,t){let n=e.length/2,r=new Int32Array(n*4),o=t.midX*vn,i=t.midY*vn;for(let s=0;s<n;s++){let a=e[2*s],l=e[2*s+1],u=e[(2*s+2)%e.length]-a,c=e[(2*s+3)%e.length]-l,d=-c,f=u,p=d>0||d===0&&f>0?0:1,h=((o-a)*u+(i-l)*c)/(u*u+c*c),m=Math.round((a+h*u)/vn),y=Math.round((l+h*c)/vn),b;Math.abs(m)<Es&&Math.abs(y)<Es?b=[d,f,d*(vn*m-a)+f*(vn*y-l)-p,cf(m,y)]:b=[0,0,d*(o-a)+f*(i-l)>=p?0:-1,cf(0,0)],r.set(b,s*4)}return{planes:r,count:n}}function bW(e,t){let n=t.ax*t.by-t.bx*t.ay,r=[];for(let o=0;o<e.length;o+=2){let i=e[o]/vn-t.cx,s=e[o+1]/vn-t.cy;r.push({x:(t.by*i-t.bx*s)/n,y:(t.ax*s-t.ay*i)/n})}return Ig(r)}var JA=(2**30).toFixed(1),QA=`
97
+ uniform ivec4 u_hullPlanes[${Ms}];
98
98
  flat in int v_hullStart;
99
99
  flat in int v_hullCount;
100
100
  float hullCoverage() {
101
101
  ivec2 pixel = ivec2(gl_FragCoord.xy);
102
- for (int k = 0; k < ${uo}; k++) {
102
+ for (int k = 0; k < ${yo}; k++) {
103
103
  if (k >= v_hullCount) break;
104
104
  ivec4 p = u_hullPlanes[v_hullStart + k];
105
- ivec2 origin = ivec2(p.w % ${zd}, p.w / ${zd}) - ${jg};
106
- ivec2 d = (pixel - origin) * ${Vd} + ${Vd/2};
105
+ ivec2 origin = ivec2(p.w % ${ff}, p.w / ${ff}) - ${Ab};
106
+ ivec2 d = (pixel - origin) * ${df} + ${df/2};
107
107
  float estimate = float(p.x) * float(d.x) + float(p.y) * float(d.y) + float(p.z);
108
- if (estimate < -${Jv}) return 0.0;
109
- if (estimate < ${Jv}) {
108
+ if (estimate < -${JA}) return 0.0;
109
+ if (estimate < ${JA}) {
110
110
  uint e = uint(p.x) * uint(d.x) + uint(p.y) * uint(d.y) + uint(p.z);
111
111
  if (int(e) < 0) return 0.0;
112
112
  }
113
113
  }
114
114
  return 1.0;
115
115
  }
116
- `;var Zv=[0,2,6,4],Kd=`
116
+ `;var ZA=[0,2,6,4],pf=`
117
117
  vec3 glyphCellOf(float post) {
118
118
  float corner = floor(post * 0.5);
119
119
  return vec3(mod(corner, 2.0), floor(corner * 0.5), post - 2.0 * corner);
120
120
  }
121
- `;var yt=16,eA=0,As=yt-1,zn=8,tA=8,Zg=yt*tA,nA=Zg*zn,ci=0,rA=3,jd=4,Rs=5,GU=(1/(2*Math.PI)).toFixed(10);function di(e,t){return e+yt*t}function co(e,t){return e+Zg*t}function oA(e,t,n){return e+nA*(1+t*uo+n-1)}var eb={a_position:0,a_vertexColor:1,a_uv:2,a_post:3,a_texSlot:4},Ll=eb;function $d(e,t,n,r=" "){if(e===t)return`${r}return ${n.replace("%s",`u_samplers[${e}]`)};`;let o=e+t+1>>1;return[`${r}if (slot < ${o}) {`,$d(e,o-1,n,`${r} `),`${r}} else {`,$d(o,t,n,`${r} `),`${r}}`].join(`
122
- `)}function iA(e){return`#version 300 es
123
- layout(location = ${Ll.a_position}) in vec2 a_position;
124
- layout(location = ${Ll.a_vertexColor}) in vec4 a_vertexColor;
125
- layout(location = ${Ll.a_uv}) in vec2 a_uv;
126
- layout(location = ${Ll.a_post}) in float a_post;
127
- layout(location = ${Ll.a_texSlot}) in float a_texSlot;
121
+ `;var yt=16,eR=0,Cs=yt-1,Kn=8,tR=8,Ob=yt*tR,nR=Ob*Kn,yi=0,rR=3,hf=4,Os=5,xW=(1/(2*Math.PI)).toFixed(10);function gi(e,t){return e+yt*t}function go(e,t){return e+Ob*t}function oR(e,t,n){return e+nR*(1+t*yo+n-1)}var Fb={a_position:0,a_vertexColor:1,a_uv:2,a_post:3,a_texSlot:4},ql=Fb;function mf(e,t,n,r=" "){if(e===t)return`${r}return ${n.replace("%s",`u_samplers[${e}]`)};`;let o=e+t+1>>1;return[`${r}if (slot < ${o}) {`,mf(e,o-1,n,`${r} `),`${r}} else {`,mf(o,t,n,`${r} `),`${r}}`].join(`
122
+ `)}function iR(e){return`#version 300 es
123
+ layout(location = ${ql.a_position}) in vec2 a_position;
124
+ layout(location = ${ql.a_vertexColor}) in vec4 a_vertexColor;
125
+ layout(location = ${ql.a_uv}) in vec2 a_uv;
126
+ layout(location = ${ql.a_post}) in float a_post;
127
+ layout(location = ${ql.a_texSlot}) in float a_texSlot;
128
128
  uniform mat3 u_proj;
129
129
  uniform mat3 u_model;
130
130
  out vec4 v_vertexColor;
@@ -135,7 +135,7 @@ flat out float v_paintMode;
135
135
  flat out int v_matrix;
136
136
  flat out int v_hullStart;
137
137
  flat out int v_hullCount;${e?`
138
- out vec2 v_cell;${Kd}`:""}
138
+ out vec2 v_cell;${pf}`:""}
139
139
  void main() {
140
140
  vec3 screen = u_model * vec3(a_position, 1.0);
141
141
  vec3 clip = u_proj * vec3(screen.xy, 1.0);
@@ -147,21 +147,21 @@ void main() {
147
147
  // header for why they share a float.
148
148
  int packed = int(a_texSlot + 0.5);
149
149
  v_texSlot = packed % ${yt};
150
- v_paintMode = float((packed / ${yt}) % ${tA});
151
- v_matrix = (packed / ${Zg}) % ${zn};
152
- int hull = packed / ${nA};
153
- v_hullStart = hull == 0 ? 0 : (hull - 1) / ${uo};
154
- v_hullCount = hull == 0 ? 0 : (hull - 1) % ${uo} + 1;${e?UU:""}
150
+ v_paintMode = float((packed / ${yt}) % ${tR});
151
+ v_matrix = (packed / ${Ob}) % ${Kn};
152
+ int hull = packed / ${nR};
153
+ v_hullStart = hull == 0 ? 0 : (hull - 1) / ${yo};
154
+ v_hullCount = hull == 0 ? 0 : (hull - 1) % ${yo} + 1;${e?wW:""}
155
155
  }
156
- `}var UU=`
156
+ `}var wW=`
157
157
  bool glyph = v_paintMode > 0.5 && v_paintMode < 2.5;
158
158
  vec3 cell = glyph ? glyphCellOf(a_post) : vec3(0.0, 0.0, a_post);
159
159
  v_cell = cell.xy;
160
- v_post = cell.z;`,_l=iA(!1),sA=iA(!0),WU=`vec4 glyphTap(vec2 uv) {
160
+ v_post = cell.z;`,Xl=iR(!1),sR=iR(!0),PW=`vec4 glyphTap(vec2 uv) {
161
161
  int slot = v_texSlot;
162
- ${$d(1,yt-1,"textureLod(%s, uv, 0.0)")}
162
+ ${mf(1,yt-1,"textureLod(%s, uv, 0.0)")}
163
163
  return vec4(0.0);
164
- }`;function Dl(e,t=!1,n=!1){let r=e===1?"0":"v_matrix";return`#version 300 es
164
+ }`;function Jl(e,t=!1,n=!1){let r=e===1?"0":"v_matrix";return`#version 300 es
165
165
  precision highp float;
166
166
  ${t?"precision highp int;":""}
167
167
  in vec4 v_vertexColor;
@@ -180,16 +180,16 @@ uniform vec4 u_colorBias[${e}];
180
180
  out vec4 outColor;
181
181
 
182
182
  vec4 sampleSlot(int slot, vec2 uv) {
183
- ${$d(0,yt-1,"texture(%s, uv)")}
183
+ ${mf(0,yt-1,"texture(%s, uv)")}
184
184
  // Never reached: every slot returns above.
185
185
  return vec4(0.0);
186
186
  }
187
- ${n?WU:""}
188
- ${n?hl:zy}
189
- ${bd}
190
- ${t?Qv:""}
187
+ ${n?PW:""}
188
+ ${n?Sl:dg}
189
+ ${Od}
190
+ ${t?QA:""}
191
191
  void main() {
192
- float isGrad = step(2.5, v_paintMode) * step(v_paintMode, ${jd+.5});
192
+ float isGrad = step(2.5, v_paintMode) * step(v_paintMode, ${hf+.5});
193
193
  // A radial or conic vertex carries a gradient-space coordinate rather than a
194
194
  // texture coordinate, and its atlas row rather than an alpha. The sample is
195
195
  // split across the branch rather than the coordinate selected before it: an
@@ -204,15 +204,15 @@ void main() {
204
204
  // nothing in either arm is a derivative.
205
205
  vec4 texel;
206
206
  if (isGrad > 0.5) {
207
- float t = v_paintMode > ${jd-.5}
208
- ? fract(atan(v_uv.y, v_uv.x) * ${GU})
207
+ float t = v_paintMode > ${hf-.5}
208
+ ? fract(atan(v_uv.y, v_uv.x) * ${xW})
209
209
  : length(v_uv);
210
- texel = texture(u_samplers[${As}], vec2(t, v_post));
210
+ texel = texture(u_samplers[${Cs}], vec2(t, v_post));
211
211
  } else {
212
212
  texel = sampleSlot(v_texSlot, v_uv);
213
213
  }
214
214
  // At 0 the mix is the texel itself, so a solid still gets its color exactly.
215
- texel.rgb = mix(texel.rgb, straightRgb(texel), step(${Rs-.5}, v_paintMode));
215
+ texel.rgb = mix(texel.rgb, straightRgb(texel), step(${Os-.5}, v_paintMode));
216
216
  float isGlyph = step(0.5, v_paintMode) * step(v_paintMode, 2.5);
217
217
  // Unconditional, and multiplied out afterwards rather than branched around:
218
218
  // see the file header. A glyph's a_post is its synthetic-bold shift. A slot
@@ -226,7 +226,7 @@ void main() {
226
226
  float a = mapped.a * u_alpha[${r}] * mix(v_post, 1.0, max(isGrad, isGlyph)) * mix(1.0, coverage, isGlyph)${t?" * hullCoverage()":""};
227
227
  outColor = vec4(mapped.rgb * a, a);
228
228
  }
229
- `}var aA=Dl(1),lA=Dl(zn),uA=Dl(1,!0),cA=Dl(zn,!0);function dA(e,t){return Dl(e?zn:1,t,!0)}var Bl=["u_proj","u_model","u_samplers","u_color","u_alpha","u_fieldScale","u_colorMatrix","u_colorBias"],Yd=[...Bl,"u_hullPlanes"],Ns=["a_position","a_vertexColor","a_uv","a_post","a_texSlot"];var fA=`#version 300 es
229
+ `}var aR=Jl(1),lR=Jl(Kn),uR=Jl(1,!0),cR=Jl(Kn,!0);function dR(e,t){return Jl(e?Kn:1,t,!0)}var Ql=["u_proj","u_model","u_samplers","u_color","u_alpha","u_fieldScale","u_colorMatrix","u_colorBias"],yf=[...Ql,"u_hullPlanes"],Fs=["a_position","a_vertexColor","a_uv","a_post","a_texSlot"];var fR=`#version 300 es
230
230
  in vec2 a_position;
231
231
  uniform mat3 u_proj;
232
232
  uniform mat3 u_model;
@@ -240,7 +240,7 @@ void main() {
240
240
  vec3 world = u_worldInv * vec3(screen.xy, 1.0);
241
241
  v_world = world.xy;
242
242
  }
243
- `,tb=`
243
+ `,Lb=`
244
244
  uniform sampler2D u_ramp;
245
245
  uniform float u_rampV;
246
246
  uniform float u_alpha;
@@ -275,15 +275,15 @@ vec4 shadePaint(vec2 world) {
275
275
  float a = mapped.a * u_alpha;
276
276
  return vec4(mapped.rgb * a, a);
277
277
  }
278
- `,pA=`#version 300 es
278
+ `,pR=`#version 300 es
279
279
  precision highp float;
280
280
  in vec2 v_world;
281
- ${tb}
281
+ ${Lb}
282
282
  out vec4 outColor;
283
283
  void main() {
284
284
  outColor = shadePaint(v_world);
285
285
  }
286
- `,qd=["u_proj","u_model","u_origin","u_worldInv","u_ramp","u_rampV","u_alpha","u_opacity","u_colorMatrix","u_colorBias","u_gradKind","u_gradDir","u_gradLen","u_gradRadius","u_gradAngle"],hA=["a_position"];var mA=`#version 300 es
286
+ `,gf=["u_proj","u_model","u_origin","u_worldInv","u_ramp","u_rampV","u_alpha","u_opacity","u_colorMatrix","u_colorBias","u_gradKind","u_gradDir","u_gradLen","u_gradRadius","u_gradAngle"],hR=["a_position"];var mR=`#version 300 es
287
287
  in vec2 a_position;
288
288
  uniform mat3 u_proj;
289
289
  uniform mat3 u_model;
@@ -297,14 +297,14 @@ void main() {
297
297
  vec3 world = u_worldInv * vec3(screen.xy, 1.0);
298
298
  v_world = world.xy;
299
299
  }
300
- `,nb=`
300
+ `,_b=`
301
301
  uniform sampler2D u_sampler;
302
302
  uniform vec2 u_tileSize;
303
303
  uniform float u_opacity;
304
304
  uniform float u_alpha;
305
305
  uniform mat4 u_colorMatrix;
306
306
  uniform vec4 u_colorBias;
307
- ${bd}
307
+ ${Od}
308
308
  vec4 shadePaint(vec2 world) {
309
309
  vec2 uv = world / max(u_tileSize, vec2(0.0001));
310
310
  vec4 texel = texture(u_sampler, uv);
@@ -312,19 +312,19 @@ vec4 shadePaint(vec2 world) {
312
312
  float a = mapped.a * u_opacity * u_alpha;
313
313
  return vec4(mapped.rgb * a, a);
314
314
  }
315
- `,yA=`#version 300 es
315
+ `,yR=`#version 300 es
316
316
  precision highp float;
317
317
  in vec2 v_world;
318
- ${nb}
318
+ ${_b}
319
319
  out vec4 outColor;
320
320
  void main() {
321
321
  outColor = shadePaint(v_world);
322
322
  }
323
- `,Xd=["u_proj","u_model","u_origin","u_worldInv","u_sampler","u_tileSize","u_opacity","u_alpha","u_colorMatrix","u_colorBias"],gA=["a_position"];var An=class{constructor(t,n){this.gl=t;this.spec=n}gl;spec;program=null;get(){if(!this.program){let{vert:t,frag:n,uniforms:r,attributes:o}=this.spec,i=new Jr(this.gl,t,n);i.lookupUniforms(r),i.lookupAttributes(o),this.program=i}return this.program}release(){this.program&&this.gl.deleteProgram(this.program.handle),this.program=null}abandon(){this.program=null}},bA={vert:_1,frag:D1,uniforms:py,attributes:G1},xA={vert:B1,frag:H1,uniforms:py,attributes:U1},wA={vert:fA,frag:pA,uniforms:qd,attributes:hA},VU={vert:_l,frag:lA,uniforms:Bl,attributes:Ns},zU={vert:_l,frag:uA,uniforms:Yd,attributes:Ns},KU={vert:_l,frag:cA,uniforms:Yd,attributes:Ns},PA={vert:mA,frag:yA,uniforms:Xd,attributes:gA};function rb(e){let t=new Jr(e,_l,aA);return t.lookupUniforms(Bl),t.lookupAttributes(Ns),t}var Jd=class{hulls;cuts=!0;matrices;hull;matricesHull;area;constructor(t){this.hulls=t.getParameter(t.SAMPLES)===0,this.matrices=new An(t,VU),this.hull=new An(t,zU),this.matricesHull=new An(t,KU),this.area=[!1,!0].flatMap(n=>[!1,!0].map(r=>new An(t,{vert:sA,frag:dA(r,n),uniforms:n?Yd:Bl,attributes:Ns})))}get(t,n,r=!1){return r?this.area[Number(t)+2*Number(n)].get():n?(t?this.matricesHull:this.hull).get():this.matrices.get()}lazy(){return[this.matrices,this.hull,this.matricesHull,...this.area]}};var Qd=eb,TA=`#version 300 es
324
- layout(location = ${Qd.a_position}) in vec2 a_position;
325
- layout(location = ${Qd.a_uv}) in vec2 a_uv;
326
- layout(location = ${Qd.a_post}) in float a_post;
327
- layout(location = ${Qd.a_texSlot}) in float a_texSlot;
323
+ `,bf=["u_proj","u_model","u_origin","u_worldInv","u_sampler","u_tileSize","u_opacity","u_alpha","u_colorMatrix","u_colorBias"],gR=["a_position"];var An=class{constructor(t,n){this.gl=t;this.spec=n}gl;spec;program=null;get(){if(!this.program){let{vert:t,frag:n,uniforms:r,attributes:o}=this.spec,i=new to(this.gl,t,n);i.lookupUniforms(r),i.lookupAttributes(o),this.program=i}return this.program}release(){this.program&&this.gl.deleteProgram(this.program.handle),this.program=null}abandon(){this.program=null}},bR={vert:xS,frag:wS,uniforms:Fy,attributes:SS},xR={vert:PS,frag:TS,uniforms:Fy,attributes:kS},wR={vert:fR,frag:pR,uniforms:gf,attributes:hR},TW={vert:Xl,frag:lR,uniforms:Ql,attributes:Fs},SW={vert:Xl,frag:uR,uniforms:yf,attributes:Fs},kW={vert:Xl,frag:cR,uniforms:yf,attributes:Fs},PR={vert:mR,frag:yR,uniforms:bf,attributes:gR};function Db(e){let t=new to(e,Xl,aR);return t.lookupUniforms(Ql),t.lookupAttributes(Fs),t}var xf=class{hulls;cuts=!0;matrices;hull;matricesHull;area;constructor(t){this.hulls=t.getParameter(t.SAMPLES)===0,this.matrices=new An(t,TW),this.hull=new An(t,SW),this.matricesHull=new An(t,kW),this.area=[!1,!0].flatMap(n=>[!1,!0].map(r=>new An(t,{vert:sR,frag:dR(r,n),uniforms:n?yf:Ql,attributes:Fs})))}get(t,n,r=!1){return r?this.area[Number(t)+2*Number(n)].get():n?(t?this.matricesHull:this.hull).get():this.matrices.get()}lazy(){return[this.matrices,this.hull,this.matricesHull,...this.area]}};var wf=Fb,TR=`#version 300 es
324
+ layout(location = ${wf.a_position}) in vec2 a_position;
325
+ layout(location = ${wf.a_uv}) in vec2 a_uv;
326
+ layout(location = ${wf.a_post}) in float a_post;
327
+ layout(location = ${wf.a_texSlot}) in float a_texSlot;
328
328
  uniform mat3 u_proj;
329
329
  uniform mat3 u_model;
330
330
  uniform mat3 u_worldInv;
@@ -332,7 +332,7 @@ out vec2 v_world;
332
332
  out vec2 v_uv;
333
333
  flat out float v_glyphMode;
334
334
  out vec2 v_cell;
335
- ${Kd}
335
+ ${pf}
336
336
  void main() {
337
337
  vec3 screen = u_model * vec3(a_position, 1.0);
338
338
  vec3 clip = u_proj * vec3(screen.xy, 1.0);
@@ -342,7 +342,7 @@ void main() {
342
342
  v_glyphMode = float(int(a_texSlot + 0.5) / ${yt});
343
343
  v_cell = glyphCellOf(a_post).xy;
344
344
  }
345
- `;function ob(e){return`#version 300 es
345
+ `;function Bb(e){return`#version 300 es
346
346
  precision highp float;
347
347
  in vec2 v_world;
348
348
  in vec2 v_uv;
@@ -355,18 +355,18 @@ ${e}
355
355
  vec4 glyphTap(vec2 uv) {
356
356
  return textureLod(u_atlas, uv, 0.0);
357
357
  }
358
- ${hl}
358
+ ${Sl}
359
359
  out vec4 outColor;
360
360
  void main() {
361
361
  float coverage = glyphCoverage(texture(u_atlas, v_uv), v_glyphMode, u_synthBold, v_uv, u_fieldScale, v_cell);
362
362
  outColor = shadePaint(v_world) * coverage;
363
363
  }
364
- `}var jU=`
364
+ `}var vW=`
365
365
  uniform sampler2D u_sampler;
366
366
  vec4 shadePaint(vec2 uv) {
367
367
  return texture(u_sampler, uv);
368
368
  }
369
- `,SA=ob(nb),kA=ob(tb),vA=ob(jU),ib=["u_atlas","u_synthBold","u_fieldScale"],AA=e=>e!=="u_origin",RA=[...Xd.filter(AA),...ib],NA=[...qd.filter(AA),...ib],IA=["u_proj","u_model","u_worldInv","u_sampler",...ib],EA=["a_position","a_uv","a_post","a_texSlot"];var Zd=class{gl;target=null;constructor(t){this.gl=t}acquire(t,n){let r=this.target;if(r&&r.width>=t&&r.height>=n)return r;let o=Math.max(r?.width??0,MA(t)),i=Math.max(r?.height??0,MA(n));return this.release(),this.target=this.create(o,i),this.target}release(){this.target&&(this.gl.deleteFramebuffer(this.target.fbo),this.gl.deleteTexture(this.target.texture),this.target=null)}create(t,n){let r=this.gl,o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texImage2D(r.TEXTURE_2D,0,r.RGBA8,t,n,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null);let i=r.createFramebuffer();return r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,o,0),r.bindFramebuffer(r.FRAMEBUFFER,null),{fbo:i,texture:o,width:t,height:n}}};function MA(e){let t=64;for(;t<e;)t*=2;return t}var Hl=class{constructor(t){this.gl=t;this.finalizer=new FinalizationRegistry(n=>{this.persistent.delete(n)&&this.pendingDeletes.push(n)})}gl;map=new WeakMap;seen=new WeakSet;finalizer;persistent=new Set;pendingDeletes=[];disposed=!1;transientThisFrame=[];handleFor(t){let n=this.map.get(t);if(n)return n;let{handle:r,vbo:o,ibo:i}=this.upload(t);this.map.set(t,r);let s={vao:r.vao,vbo:o,ibo:i};return this.persistent.add(s),this.finalizer.register(t,s,t),r}uploadTransient(t){let{handle:n,vbo:r,ibo:o}=this.upload(t);return this.transientThisFrame.push({vao:n.vao,vbo:r,ibo:o}),n}uploadRecurring(t){return this.seen.has(t)?this.handleFor(t):(this.seen.add(t),this.uploadTransient(t))}freeTransient(){if(this.transientThisFrame.length===0)return;let t=this.gl;if(t.isContextLost()){this.transientThisFrame.length=0;return}for(let n of this.transientThisFrame)t.deleteVertexArray(n.vao),t.deleteBuffer(n.vbo),t.deleteBuffer(n.ibo);this.transientThisFrame.length=0}_transientCount(){return this.transientThisFrame.length}drainPendingDeletes(){if(this.pendingDeletes.length===0)return;let t=this.gl;if(t.isContextLost()){this.pendingDeletes.length=0;return}for(let n of this.pendingDeletes)t.deleteVertexArray(n.vao),t.deleteBuffer(n.vbo),t.deleteBuffer(n.ibo);this.pendingDeletes.length=0}dispose(){if(!this.disposed){this.disposed=!0,this.freeTransient();for(let t of this.persistent)this.pendingDeletes.push(t);this.persistent.clear(),this.drainPendingDeletes()}}_pendingDeleteCount(){return this.pendingDeletes.length}_enqueueDeleteForTest(t){this.pendingDeletes.push(t)}upload(t){let n=this.gl,r=n.createVertexArray();if(!r)throw new Error("createVertexArray returned null");n.bindVertexArray(r);let o=n.createBuffer();if(!o)throw new Error("createBuffer (VBO) returned null");n.bindBuffer(n.ARRAY_BUFFER,o),n.bufferData(n.ARRAY_BUFFER,t.vertices,n.STATIC_DRAW),n.enableVertexAttribArray($c),n.vertexAttribPointer($c,2,n.FLOAT,!1,0,0);let i=n.createBuffer();if(!i)throw new Error("createBuffer (IBO) returned null");return n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.indices,n.STATIC_DRAW),n.bindVertexArray(null),{handle:{vao:r,indexCount:t.indices.length,requiresStencil:t.requiresStencil??!1,anchorA:t.anchorA,anchorB:t.anchorB,anchorT:t.anchorT},vbo:o,ibo:i}}};function Gl(e,t){e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1)}function $U(e,t){e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t)}var Ul=class{constructor(t){this.gl=t}gl;map=new Map;wraps=new Map;registered=new Map;sweptVersion=-1;has(t){return this.map.has(t)}upload(t,n,r="clamp"){return this.ensure(t,n,r,$U)}ensure(t,n,r,o){let i=this.map.get(t);if(i)return this.wraps.get(t)!==r&&this.applyWrap(t,i,r),t;let s=this.gl,a=s.createTexture();if(!a)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);let l=r==="repeat"?s.REPEAT:s.CLAMP_TO_EDGE;return s.bindTexture(s.TEXTURE_2D,a),o(s,n),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,l),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,l),s.bindTexture(s.TEXTURE_2D,null),this.map.set(t,a),this.wraps.set(t,r),t}uploadRegistered(t,n,r="clamp"){let o=this.map.get(t);if(o&&this.registered.get(t)!==n){let i=this.gl;i.bindTexture(i.TEXTURE_2D,o),Gl(i,n),i.bindTexture(i.TEXTURE_2D,null)}return this.registered.set(t,n),this.ensure(t,n,r,Gl)}replaces(t,n){return this.map.has(t)&&this.registered.get(t)!==n}sweep(t){let n=t.getVersion();if(n!==this.sweptVersion){this.sweptVersion=n;for(let r of this.registered.keys())t.has(r)||(this.gl.deleteTexture(this.map.get(r)??null),this.map.delete(r),this.wraps.delete(r),this.registered.delete(r))}}applyWrap(t,n,r){let o=this.gl,i=r==="repeat"?o.REPEAT:o.CLAMP_TO_EDGE;o.bindTexture(o.TEXTURE_2D,n),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,i),o.bindTexture(o.TEXTURE_2D,null),this.wraps.set(t,r)}uploadR8(t,n,r,o){if(this.map.has(t))return;let i=this.gl,s=i.createTexture();if(!s)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);i.bindTexture(i.TEXTURE_2D,s),i.pixelStorei(i.UNPACK_ALIGNMENT,1),i.texImage2D(i.TEXTURE_2D,0,i.R8,n,r,0,i.RED,i.UNSIGNED_BYTE,o),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.wraps.set(t,"clamp")}subImageR8(t,n,r,o,i,s){let a=this.map.get(t);if(!a)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let l=this.gl;l.bindTexture(l.TEXTURE_2D,a),l.pixelStorei(l.UNPACK_ALIGNMENT,1),l.texSubImage2D(l.TEXTURE_2D,0,n,r,o,i,l.RED,l.UNSIGNED_BYTE,s),l.pixelStorei(l.UNPACK_ALIGNMENT,4),l.bindTexture(l.TEXTURE_2D,null)}uploadRGBA(t,n,r,o){if(this.map.has(t))return;let i=this.gl,s=i.createTexture();if(!s)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n,r,0,i.RGBA,i.UNSIGNED_BYTE,o),i.generateMipmap(i.TEXTURE_2D),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.wraps.set(t,"clamp")}subImageRGBA(t,n,r,o,i,s){let a=this.map.get(t);if(!a)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let l=this.gl;l.bindTexture(l.TEXTURE_2D,a),l.texSubImage2D(l.TEXTURE_2D,0,n,r,o,i,l.RGBA,l.UNSIGNED_BYTE,s),l.generateMipmap(l.TEXTURE_2D),l.bindTexture(l.TEXTURE_2D,null)}bind(t,n){let r=this.map.get(t);if(!r)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let o=this.gl;o.activeTexture(o.TEXTURE0+n),o.bindTexture(o.TEXTURE_2D,r)}free(){let t=this.gl;for(let n of this.map.values())t.deleteTexture(n);this.map.clear(),this.wraps.clear(),this.registered.clear()}};var Is=xt(),pi=Is.reflection;var fi=[];function ef(e,t){let n={prefix:e,owner:t};return fi.push(n),()=>{let r=fi.indexOf(n);r!==-1&&fi.splice(r,1)}}function CA(e){return OA(e)!==void 0}function OA(e){for(let t=0;t<fi.length;t++)if(e.startsWith(fi[t].prefix))return fi[t].owner}function Es(e){let t=fi.length>0?OA(e):void 0,n=Is.get(e);return n?t?.touched?(t.touched(e),Is.get(e)??null):n:t?(t.revive(e),Is.get(e)??null):null}function tf(e,t,n){return Is.set(e,n?{source:t,size:n}:{source:t}),{id:e}}function nf(e){return Is.delete(e.id)}var FA=4096,Wl=new Set;function rf(e){for(let t of Wl)t.release(e)}function LA(e){for(let t of Wl)if(t.drewInLatestFrame(e))return!0;return!1}function _A(){let e=1/0;for(let t of Wl)e=Math.min(e,t.maxTextureSide);return Number.isFinite(e)?e:FA}var Ms=class{constructor(t,n="linear"){this.gl=t;this.minification=n;let r=t.getParameter(t.MAX_TEXTURE_SIZE);this.maxTextureSide=typeof r=="number"&&r>0?r:FA,this.finalizer=new FinalizationRegistry(o=>{this.textures.delete(o)&&this.pendingDeletes.push(o)}),Wl.add(this)}gl;minification;maxTextureSide;map=new WeakMap;textures=new Set;magFilters=new WeakMap;minFilters=new WeakMap;finalizer;pendingDeletes=[];mipped=new WeakSet;frame=0;lastDrawn=new WeakMap;beginFrame(){this.frame++,this.drainPendingDeletes()}drewInLatestFrame(t){return this.lastDrawn.get(t)===this.frame}drainPendingDeletes(){if(this.pendingDeletes.length!==0){for(let t of this.pendingDeletes)this.gl.deleteTexture(t);this.pendingDeletes.length=0}}release(t){let n=this.map.get(t);n&&(this.gl.deleteTexture(n),this.textures.delete(n),this.finalizer.unregister(t),this.map.delete(t),this.magFilters.delete(t),this.minFilters.delete(t),this.lastDrawn.delete(t),this.mipped.delete(t))}dispose(){for(let t of this.textures)this.gl.deleteTexture(t);this.drainPendingDeletes(),this.abandon()}abandon(){this.textures.clear(),this.pendingDeletes.length=0,Wl.delete(this)}upload(t,n,r){this.lastDrawn.set(t,this.frame);let o=this.map.get(t);if(o)return o;let i=this.gl,s=i.createTexture();if(!s)throw new Error("GLImageCache: createTexture failed");i.bindTexture(i.TEXTURE_2D,s),Gl(i,n),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),this.minFilters.set(t,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),this.magFilters.set(t,i.LINEAR);let[a,l]=YU(i,r);return i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,a),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,l),this.minification==="mipmap"&&(i.generateMipmap(i.TEXTURE_2D),this.mipped.add(t)),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.textures.add(s),this.finalizer.register(t,s,t),s}lacksMipmaps(t){return this.minification==="auto"&&!this.mipped.has(t)}hasMipmaps(t){return this.mipped.has(t)}buildMipmaps(t){let n=this.map.get(t);if(!n||this.mipped.has(t))return;let r=this.gl;r.bindTexture(r.TEXTURE_2D,n),r.generateMipmap(r.TEXTURE_2D),r.bindTexture(r.TEXTURE_2D,null),this.mipped.add(t)}setMinFilter(t,n){let r=this.gl,o=n&&this.mipped.has(t)?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;this.minFilters.get(t)!==o&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),this.minFilters.set(t,o))}bind(t,n){let r=this.map.get(t);if(!r)throw new Error("GLImageCache: image not uploaded; call upload() first");this.lastDrawn.set(t,this.frame);let o=this.gl;o.activeTexture(o.TEXTURE0+n),o.bindTexture(o.TEXTURE_2D,r)}setMagFilter(t,n){this.magFilters.get(t)!==n&&(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,n),this.magFilters.set(t,n))}};function YU(e,t){switch(t){case"repeat":return[e.REPEAT,e.REPEAT];case"repeat-x":return[e.REPEAT,e.CLAMP_TO_EDGE];case"repeat-y":return[e.CLAMP_TO_EDGE,e.REPEAT];default:return[e.CLAMP_TO_EDGE,e.CLAMP_TO_EDGE]}}Pe();var mi=256,fW=16,pW=1024;function hW(e,t="rgb"){let n=new Uint8ClampedArray(mi*4);if(e.length===0)return n;let r=Sb(e);for(let o=0;o<mi;o++){let[i,s,a,l]=kb(r,o/(mi-1),t);n[o*4]=i*255,n[o*4+1]=s*255,n[o*4+2]=a*255,n[o*4+3]=l*255}return n}function rR(e,t){return`${t}|${JSON.stringify(e)}`}var $l=class{constructor(t){this.gl=t}gl;rowByKey=new Map;texture=null;rows=0;pixels=new Uint8ClampedArray(0);totalQueries=0;cacheHits=0;get height(){return this.rows}upload(t,n="rgb"){let r=rR(t,n);this.totalQueries++;let o=this.rowByKey.get(r);if(o!==void 0)return this.cacheHits++,this.rowByKey.delete(r),this.rowByKey.set(r,o),o;let i=this.claimRow();return this.writeRow(i,hW(t,n)),this.rowByKey.set(r,i),i}wouldReshape(t,n="rgb"){return this.rowByKey.size===0?!1:!this.rowByKey.has(rR(t,n))&&this.rowByKey.size>=this.rows}rowV(t){return(t+.5)/(this.rows||1)}bind(t){let n=this.gl;n.activeTexture(n.TEXTURE0+t),n.bindTexture(n.TEXTURE_2D,this.texture)}hitRate(){return this.totalQueries===0?0:this.cacheHits/this.totalQueries}resetStats(){this.totalQueries=0,this.cacheHits=0}free(){this.texture&&this.gl.deleteTexture(this.texture),this.texture=null,this.rows=0,this.pixels=new Uint8ClampedArray(0),this.rowByKey.clear()}claimRow(){if(this.rowByKey.size<this.rows)return this.rowByKey.size;if(this.rows<pW)return this.resize(this.rows===0?fW:this.rows*2),this.rowByKey.size;let[t,n]=this.rowByKey.entries().next().value;return this.rowByKey.delete(t),n}resize(t){let n=this.gl,r=new Uint8ClampedArray(mi*t*4);if(r.set(this.pixels),this.pixels=r,this.rows=t,this.texture)n.bindTexture(n.TEXTURE_2D,this.texture);else{let o=n.createTexture();if(!o)throw new Error("GradientRampAtlas: createTexture failed");this.texture=o,n.bindTexture(n.TEXTURE_2D,o),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}n.texImage2D(n.TEXTURE_2D,0,n.RGBA,mi,t,0,n.RGBA,n.UNSIGNED_BYTE,this.pixels),n.bindTexture(n.TEXTURE_2D,null)}writeRow(t,n){let r=this.gl;this.pixels.set(n,t*mi*4),r.bindTexture(r.TEXTURE_2D,this.texture),r.texSubImage2D(r.TEXTURE_2D,0,0,t,mi,1,r.RGBA,r.UNSIGNED_BYTE,n),r.bindTexture(r.TEXTURE_2D,null)}};Z();Z();function oR(e,t,n){for(let r=0;r<4;r++)for(let o=0;o<5;o++){let i=o===4?e[r*5+4]:0;for(let s=0;s<4;s++)i+=e[r*5+s]*t[s*5+o];n[r*5+o]=i}return n}function iR(e,t,n,r,o){return[ls(e[0]*t+e[1]*n+e[2]*r+e[3]*o+e[4]),ls(e[5]*t+e[6]*n+e[7]*r+e[8]*o+e[9]),ls(e[10]*t+e[11]*n+e[12]*r+e[13]*o+e[14]),ls(e[15]*t+e[16]*n+e[17]*r+e[18]*o+e[19])]}var Ut=new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),gf=class{transformStack=[q.identity()];alphaStack=[1];colorMatrixStack=[Ut];get transform(){return this.transformStack[this.transformStack.length-1]}get alpha(){return this.alphaStack[this.alphaStack.length-1]}get colorMatrix(){return this.colorMatrixStack[this.colorMatrixStack.length-1]}push(t){let n=this.transform,r=t.transform?q.multiply(n,t.transform):n,o=t.alpha!==void 0?this.alpha*t.alpha:this.alpha,i=t.colorMatrix?oR(this.colorMatrix,t.colorMatrix instanceof Float32Array?t.colorMatrix:new Float32Array(t.colorMatrix),new Float32Array(20)):this.colorMatrix;this.transformStack.push(r),this.alphaStack.push(o),this.colorMatrixStack.push(i)}pushIsolated(t){this.push(t);let n={alpha:this.alpha,colorMatrix:this.colorMatrix};this.pop();let r=this.transform;return this.transformStack.push(t.transform?q.multiply(r,t.transform):r),this.alphaStack.push(1),this.colorMatrixStack.push(Ut),n}reset(){this.transformStack.length=1,this.alphaStack.length=1,this.colorMatrixStack.length=1}pop(){if(this.transformStack.length<=1)throw new Error("GroupState.pop: cannot pop root frame");this.transformStack.pop(),this.alphaStack.pop(),this.colorMatrixStack.pop()}};Z();var sR=mt;function aR(e,t){if(typeof e=="number")return e;let n=e?.px??sR,[r,o,,i,s]=t,a=r*r+o*o+i*i+s*s,l=r*s-o*i,u=Math.sqrt((a+Math.sqrt(Math.max(0,a*a-4*l*l)))/2),c=n/u;return!(c>0)||!Number.isFinite(c)?mt:2**Math.floor(Math.log2(c))}function lR(e,t){return typeof e=="number"?e:{px:(e?.px??sR)/t}}Z();var Xl=new Set,vb=!1;function Tf(e,t,n=2){let r=t&&t.length,o=r?t[0]*n:e.length;Xl.size&&Xl.clear();let i=fR(e,0,o,n,!0),s=[];if(!i||i.next===i.prev)return s;let a=0,l=0,u=0;if(r&&(i=xW(e,t,i,n)),e.length>80*n){a=e[0],l=e[1];let c=a,d=l;for(let f=n;f<o;f+=n){let p=e[f],h=e[f+1];p<a&&(a=p),h<l&&(l=h),p>c&&(c=p),h>d&&(d=h)}u=Math.max(c-a,d-l),u=u!==0?32767/u:0}return Ab(i,s,a,l,u),s}function fR(e,t,n,r,o){let i=null;if(o===CW(e,t,n,r)>0)for(let s=t;s<n;s+=r)i=dR(s/r|0,e[s],e[s+1],i);else for(let s=n-r;s>=t;s-=r)i=dR(s/r|0,e[s],e[s+1],i);return i&&Jl(i,i.next)&&(Zl(i),i=i.next),i}function gi(e,t=e){let n=t===e,r=e,o;do o=!1,r!==r.next&&(Xl.size===0||!Xl.has(r))&&(Jl(r,r.next)||Ye(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),vb=!0,Zl(r),r=r.prev,o=!0):(n||r!==t)&&(r=r.next,o=!n);while(o||r!==t);return t}function Ab(e,t,n,r,o){o&&AW(e,n,r,o);let i=e,s=!1;for(;e.prev!==e.next;){let a=e.prev,l=e.next;if(Ye(a,e,l)<0&&(o?yW(e,n,r,o):mW(e))){t.push(a.i,e.i,l.i),Zl(e),e=l,i=l;continue}if(e=l,e===i){if(vb=!1,e=gi(e),vb){i=e;continue}if(!s){e=gW(e,t),i=e,s=!0;continue}bW(e,t,n,r,o);break}}}function mW(e){let t=e.prev,n=e,r=e.next,o=t.x,i=n.x,s=r.x,a=t.y,l=n.y,u=r.y,c=Math.min(o,i,s),d=Math.min(a,l,u),f=Math.max(o,i,s),p=Math.max(a,l,u),h=r.next;for(;h!==t;){if(h.x>=c&&h.x<=f&&h.y>=d&&h.y<=p&&!(o===h.x&&a===h.y)&&Pf(o,a,i,l,s,u,h.x,h.y)&&Ye(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function yW(e,t,n,r){let o=e.prev,i=e,s=e.next,a=o.x,l=i.x,u=s.x,c=o.y,d=i.y,f=s.y,p=Math.min(a,l,u),h=Math.min(c,d,f),m=Math.max(a,l,u),g=Math.max(c,d,f),b=Eb(p,h,t,n,r),x=Eb(m,g,t,n,r),w=e.prevZ;for(;w&&w.z>=b;){if(w.x>=p&&w.x<=m&&w.y>=h&&w.y<=g&&w!==s&&!(a===w.x&&c===w.y)&&Pf(a,c,l,d,u,f,w.x,w.y)&&Ye(w.prev,w,w.next)>=0)return!1;w=w.prevZ}let y=e.nextZ;for(;y&&y.z<=x;){if(y.x>=p&&y.x<=m&&y.y>=h&&y.y<=g&&y!==s&&!(a===y.x&&c===y.y)&&Pf(a,c,l,d,u,f,y.x,y.y)&&Ye(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function gW(e,t){let n=e,r=!1;do{let o=n.prev,i=n.next.next;mR(o,n,n.next,i,!1)&&Ql(o,i)&&Ql(i,o)&&(t.push(o.i,n.i,i.i),Zl(n),Zl(n.next),n=e=i,r=!0),n=n.next}while(n!==e);return r?gi(n):n}function bW(e,t,n,r,o){let i=e;do{let s=i.next.next;for(;s!==i.prev;){if(i.i!==s.i&&IW(i,s)){let a=yR(i,s);i=gi(i,i.next),a=gi(a,a.next),Ab(i,t,n,r,o),Ab(a,t,n,r,o);return}s=s.next}i=i.next}while(i!==e)}var Rb=!1;function xW(e,t,n,r){let o=[];for(let i=0,s=t.length;i<s;i++){let a=t[i]*r,l=i<s-1?t[i+1]*r:e.length,u=fR(e,a,l,r,!1);u===u.next&&Xl.add(u),o.push(NW(u))}o.sort(wW),TW(e.length/r,t.length),hR(n,n),Rb=!0;for(let i=0;i<o.length;i++)n=PW(o[i],n);return Rb=!1,gi(n)}function wW(e,t){return e.x-t.x||e.y-t.y||(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}function PW(e,t){let n=kW(e,t);if(!n)return t;let r=yR(n,e),o=r.next;return hR(n,o.next),gi(r,r.next),gi(n,n.next)}var pR=16,We=new Float64Array(0),wf=0,Nb=[],Ib=[];function TW(e,t){let n=Math.ceil((e+2*t)/pR)+t+2;We.length<n*4&&(We=new Float64Array(n*4)),wf=0}function hR(e,t){let n=e;do{let r=wf++;Nb[r]=n;let o=n.x,i=n.y,s=n.x,a=n.y,l=0;do{let c=n.next;n.z=r,c.x<o&&(o=c.x),c.x>s&&(s=c.x),c.y<i&&(i=c.y),c.y>a&&(a=c.y),n=c}while(++l<pR&&n!==t);Ib[r]=n;let u=r*4;We[u]=o,We[u+1]=i,We[u+2]=s,We[u+3]=a}while(n!==t)}function SW(e,t){let n=e.z*4;t.x<We[n]&&(We[n]=t.x),t.y<We[n+1]&&(We[n+1]=t.y),t.x>We[n+2]&&(We[n+2]=t.x),t.y>We[n+3]&&(We[n+3]=t.y)}function uR(e){let t=Ib[e];for(;t.prev.next!==t;)t=t.next;return Ib[e]=t,t}function cR(e){let t=Nb[e];for(;t.prev.next!==t;)t=t.next;return Nb[e]=t,t}function kW(e,t){let n=t,r=e.x,o=e.y,i=-1/0,s;if(Jl(e,n))return n;for(let f=0,p=0;f<wf;f++,p+=4){if(o<We[p+1]||o>We[p+3]||We[p]>r||We[p+2]<=i)continue;let h=uR(f);n=cR(f);do{if(n.prev.next===n){if(Jl(e,n.next))return n.next;if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){let m=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(m<=r&&m>i&&(i=m,s=n.x<n.next.x?n:n.next,m===r))return s}}n=n.next}while(n!==h)}if(!s)return null;let a=s.x,l=s.y,u=Math.min(o,l),c=Math.max(o,l),d=1/0;for(let f=0,p=0;f<wf;f++,p+=4){if(We[p+2]<a||We[p]>r||We[p+3]<u||We[p+1]>c)continue;let h=uR(f);n=cR(f);do{if(n.prev.next===n&&r>=n.x&&n.x>=a&&r!==n.x&&Pf(o<l?r:i,o,a,l,o<l?i:r,o,n.x,n.y)){let m=Math.abs(o-n.y)/(r-n.x);(Ql(n,e)||n.y===o&&n.next.y===o&&n.next.x>r)&&(m<d||m===d&&(n.x>s.x||n.x===s.x&&vW(s,n)))&&(s=n,d=m)}n=n.next}while(n!==h)}return s}function vW(e,t){return Ye(e.prev,e,t.prev)<0&&Ye(t.next,e,e.next)<0}var Wt=[],Os=[],yi=new Uint32Array(0),Yl=new Uint32Array(0),ql=new Uint32Array(256);function AW(e,t,n,r){let o=e,i=0;do o.z=Eb(o.x,o.y,t,n,r),Wt[i++]=o,o=o.next;while(o!==e);RW(i);let s=null;for(let a=0;a<i;a++){let l=Wt[a];l.prevZ=s,s&&(s.nextZ=l),s=l}s.nextZ=null,Wt.fill(null,0,i),Os.fill(null,0,i)}function RW(e){if(e<=32){for(let t=1;t<e;t++){let n=Wt[t],r=n.z,o=t-1;for(;o>=0&&Wt[o].z>r;)Wt[o+1]=Wt[o],o--;Wt[o+1]=n}return}yi.length<e&&(yi=new Uint32Array(e),Yl=new Uint32Array(e),Os=new Array(e));for(let t=0;t<e;t++)yi[t]=Wt[t].z;bf(e,Wt,yi,Os,Yl,0),bf(e,Os,Yl,Wt,yi,8),bf(e,Wt,yi,Os,Yl,16),bf(e,Os,Yl,Wt,yi,24)}function bf(e,t,n,r,o,i){ql.fill(0);for(let a=0;a<e;a++)ql[n[a]>>>i&255]++;let s=0;for(let a=0;a<256;a++){let l=ql[a];ql[a]=s,s+=l}for(let a=0;a<e;a++){let l=n[a],u=ql[l>>>i&255]++;r[u]=t[a],o[u]=l}}function Eb(e,t,n,r,o){return e=(e-n)*o|0,t=(t-r)*o|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function NW(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Pf(e,t,n,r,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(r-a)>=(n-s)*(t-a)&&(n-s)*(i-a)>=(o-s)*(r-a)}function IW(e,t){let n=Jl(e,t)&&Ye(e.prev,e,e.next)>0&&Ye(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||Ql(e,t)&&Ql(t,e)&&(Ye(e.prev,e,t.prev)!==0||Ye(e,t.prev,t)!==0))&&!EW(e,t)&&(n||MW(e,t))}function Ye(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Jl(e,t){return e.x===t.x&&e.y===t.y}function mR(e,t,n,r,o=!0){let i=Ye(e,t,n),s=Ye(e,t,r),a=Ye(n,r,e),l=Ye(n,r,t);return(i>0&&s<0||i<0&&s>0)&&(a>0&&l<0||a<0&&l>0)?!0:o?!!(i===0&&xf(e,n,t)||s===0&&xf(e,r,t)||a===0&&xf(n,e,r)||l===0&&xf(n,t,r)):!1}function xf(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function EW(e,t){let n=Math.min(e.x,t.x),r=Math.max(e.x,t.x),o=Math.min(e.y,t.y),i=Math.max(e.y,t.y),s=e;do{let a=s.next;if(s.x>r&&a.x>r||s.x<n&&a.x<n||s.y>i&&a.y>i||s.y<o&&a.y<o){s=a;continue}if(s.i!==e.i&&a.i!==e.i&&s.i!==t.i&&a.i!==t.i&&mR(s,a,e,t))return!0;s=a}while(s!==e);return!1}function Ql(e,t){return Ye(e.prev,e,e.next)<0?Ye(e,t,e.next)>=0&&Ye(e,e.prev,t)>=0:Ye(e,t,e.prev)<0||Ye(e,e.next,t)<0}function MW(e,t){let n=e,r=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do{let s=n.next;n.y>i!=s.y>i&&o<(s.x-n.x)*(i-n.y)/(s.y-n.y)+n.x&&(r=!r),n=s}while(n!==e);return r}function yR(e,t){let n=Mb(e.i,e.x,e.y),r=Mb(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function dR(e,t,n,r){let o=Mb(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function Zl(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ),Rb&&SW(e.prev,e.next)}function Mb(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function CW(e,t,n,r){let o=0;for(let i=t,s=n-r;i<n;i+=r)o+=(e[s]-e[i])*(e[i+1]+e[s+1]),s=i;return o}Je();nn();tn();bl();ii();oi();var Cb=new Uint8Array(new Uint16Array([1]).buffer)[0]===1?0:1,OW=2**-19;function Ob(e,t,n){let r=FW(e,t),o=new Uint32Array(r.buffer);for(let i=0;i<t;i++){let s=o[i*2+Cb],a=s*4,l=e[a],u=e[a+1],c=e[a+2],d=e[a+3],f=Math.max(l,c),p=f+Math.abs(f)*OW+1e-300;for(let h=i+1;h<t&&!(r[h]>p);h++){let m=o[h*2+Cb],g=m*4,b=e[g],x=e[g+1],w=e[g+2],y=e[g+3];if(Math.max(u,d)<Math.min(x,y)||Math.max(x,y)<Math.min(u,d))continue;let P=LW(l,u,c,d,b,x,w,y);if(P&&n(s,m,P[0],P[1]))return}}}function FW(e,t){let n=new Float64Array(t),r=new Uint32Array(n.buffer);for(let o=0;o<t;o++)n[o]=Math.min(e[o*4],e[o*4+2]),r[o*2+Cb]=o;return n.sort()}function LW(e,t,n,r,o,i,s,a){let l=n-e,u=r-t,c=s-o,d=a-i,f=l*d-u*c;if(f===0)return null;let p=o-e,h=i-t,m=(p*d-h*c)/f,g=(p*u-h*l)/f,b=1e-9,x=1-1e-9;return m<=b||m>=x||g<=b||g>=x?null:[m,g]}var bi=e=>`${e.x},${e.y}`;function Fb(e,t=!1){return!t&&!BW(e)?null:bR(e,n=>n!==0).contours}var _W=2**20;function gR(e){let t=DW(e),n=Math.floor((_W/t-t)/2);if(!(n>=0))return null;let r=bR(e,o=>(o&1)!==0,n);return r!==null&&r.complete?r.contours:null}function bR(e,t,n=1/0){let r=HW(e),o=WW(r);if(!GW(r,n))return null;UW(r,o),VW(r,o);let i=KW(r,t),{loops:s,complete:a}=$W(i);return{contours:qW(s),complete:a}}function DW(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=0;return n.forEach((i,s)=>{let a=s+1<n.length?n[s+1]:r;for(let l=i;l<a;l++){let u=l+1<a?l+1:i;(t[l*2]!==t[u*2]||t[l*2+1]!==t[u*2+1])&&o++}}),o}function BW(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=new Float64Array(r*4),i=0;n.forEach((a,l)=>{let u=l+1<n.length?n[l+1]:r;for(let c=a;c<u;c++){let d=c+1<u?c+1:a,f=t[c*2],p=t[c*2+1],h=t[d*2],m=t[d*2+1];f===h&&p===m||(o[i*4]=f,o[i*4+1]=p,o[i*4+2]=h,o[i*4+3]=m,i++)}});let s=!1;return Ob(o,i,()=>s=!0),s}function HW(e){let{coords:t,contourStarts:n,anchorA:r,anchorB:o,anchorT:i}=e,s=t.length/2,a=u=>({x:t[u*2],y:t[u*2+1],a:r[u],b:o[u],t:i[u]}),l=[];return n.forEach((u,c)=>{let d=c+1<n.length?n[c+1]:s;for(let f=u;f<d;f++){let p=a(f),h=a(f+1<d?f+1:u);(p.x!==h.x||p.y!==h.y)&&l.push({from:p,to:h,cuts:[]})}}),l}function GW(e,t){let n=new Float64Array(e.length*4);e.forEach(({from:o,to:i},s)=>n.set([o.x,o.y,i.x,i.y],s*4));let r=0;return Ob(n,e.length,(o,i,s,a)=>{if(++r>t)return!0;let l=e[o],u={x:l.from.x+(l.to.x-l.from.x)*s,y:l.from.y+(l.to.y-l.from.y)*s,...zW(l,s)};return l.cuts.push({s,node:u}),e[i].cuts.push({s:a,node:u}),!1}),r<=t}function UW(e,t){let n=e.map((o,i)=>i),r=o=>Math.min(o.from.x,o.to.x);n.sort((o,i)=>r(e[o])-r(e[i]));for(let o=0;o<n.length;o++){let i=e[n[o]],s=Math.max(i.from.x,i.to.x)+t;for(let a=o+1;a<n.length;a++){let l=e[n[a]];if(r(l)>s)break;Math.max(i.from.y,i.to.y)+t<Math.min(l.from.y,l.to.y)||Math.max(l.from.y,l.to.y)+t<Math.min(i.from.y,i.to.y)||(Sf(i,l.from,t),Sf(i,l.to,t),Sf(l,i.from,t),Sf(l,i.to,t))}}}function WW(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let{from:i}of e)t=Math.min(t,i.x),r=Math.max(r,i.x),n=Math.min(n,i.y),o=Math.max(o,i.y);return Math.max(r-t,o-n,Math.abs(t),Math.abs(r),Math.abs(n),Math.abs(o))*1e-9}function VW(e,t){let n=[];for(let r of e){n.push(r.from,r.to);for(let o of r.cuts)n.push(o.node)}n.sort((r,o)=>r.x-o.x);for(let r=0;r<n.length;r++){let o=n[r];for(let i=r+1;i<n.length&&n[i].x-o.x<=t;i++){let s=n[i];s!==o&&Math.abs(s.y-o.y)<=t&&(s.x!==o.x||s.y!==o.y)&&(s.x=o.x,s.y=o.y)}}}function Sf(e,t,n){let r=e.to.x-e.from.x,o=e.to.y-e.from.y,i=r*r+o*o,s=((t.x-e.from.x)*r+(t.y-e.from.y)*o)/i;if(!(s>0&&s<1)||Math.hypot(e.from.x+r*s-t.x,e.from.y+o*s-t.y)>n)return;let a=l=>Math.abs(l.x-t.x)<=n&&Math.abs(l.y-t.y)<=n;a(e.from)||a(e.to)||e.cuts.some(l=>a(l.node))||e.cuts.push({s,node:t})}function zW(e,t){let{from:n,to:r}=e;if(n.a===r.a&&n.b===r.b)return{a:n.a,b:n.b,t:n.t+(r.t-n.t)*t};let o=t<.5?n:r;return{a:o.a,b:o.b,t:o.t}}function KW(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let{from:d}of e)n=Math.min(n,d.x),o=Math.max(o,d.x),r=Math.min(r,d.y),i=Math.max(i,d.y);let s=Math.max(Math.hypot(o-n,i-r)*1e-7,1e-9),a=(d,f)=>t(jW(e,d,f)),l=[],u=new Set,c=(d,f)=>{let p=`${bi(d)}>${bi(f)}`;u.has(p)||(u.add(p),l.push({from:d,to:f}))};for(let d of e){let f=[d.from,...d.cuts.sort((p,h)=>p.s-h.s).map(p=>p.node),d.to];for(let p=0;p+1<f.length;p++){let h=f[p],m=f[p+1],g=m.x-h.x,b=m.y-h.y,x=Math.hypot(g,b);if(x===0)continue;let w=(h.x+m.x)/2,y=(h.y+m.y)/2,P=-b/x*s,S=g/x*s,v=a(w+P,y+S),A=a(w-P,y-S);v&&!A?c(h,m):A&&!v&&c(m,h)}}return l}function jW(e,t,n){let r=0;for(let{from:o,to:i}of e){let s=(i.x-o.x)*(n-o.y)-(t-o.x)*(i.y-o.y);o.y<=n&&i.y>n&&s>0?r++:i.y<=n&&o.y>n&&s<0&&r--}return r}function $W(e){let t=new Map;for(let i of e){let s=bi(i.from),a=t.get(s);a?a.push(i):t.set(s,[i])}let n=new Set,r=[],o=!0;for(let i of e){if(n.has(i))continue;n.add(i);let s=[i.from],a=bi(i.from),l=i;for(;bi(l.to)!==a;){let u=YW(l,(t.get(bi(l.to))??[]).filter(c=>!n.has(c)));if(!u)break;n.add(u),s.push(u.from),l=u}bi(l.to)!==a?o=!1:s.length>=3&&r.push(s)}return{loops:r,complete:o}}function YW(e,t){let n=e.to.x-e.from.x,r=e.to.y-e.from.y,o,i=-1/0;for(let s of t){let a=s.to.x-s.from.x,l=s.to.y-s.from.y,u=Math.atan2(n*l-r*a,n*a+r*l);u>i&&(i=u,o=s)}return o}function qW(e){let t={coords:[],contourStarts:[],anchorA:[],anchorB:[],anchorT:[]};for(let n of e){t.contourStarts.push(t.coords.length/2);for(let r of n)t.coords.push(r.x,r.y),t.anchorA.push(r.a),t.anchorB.push(r.b),t.anchorT.push(r.t)}return t}Nl();ti();function xi(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=n.map((a,l)=>{let u=l+1<n.length?n[l+1]:r;return{start:a,end:u,area:yr(t,a,u),parent:-1,winding:0}}),i=o.map(a=>QW(t,a.start,a.end)),s=o.map((a,l)=>l).filter(a=>o[a].area!==0);s.sort((a,l)=>Math.abs(o[l].area)-Math.abs(o[a].area));for(let a=0;a<s.length;a++){let l=o[s[a]];for(let u=a-1;u>=0;u--){let c=s[u];if(XW(t,o[c],i[c],l)){l.parent=c;break}}l.winding=Math.sign(l.area)+(l.parent>=0?o[l.parent].winding:0)}return o}function XW(e,t,n,r){let o=Math.max(n[2]-n[0],n[3]-n[1])*1e-9;for(let i=r.start;i<r.end;i++){let s=e[i*2],a=e[i*2+1];if(s<n[0]||s>n[2]||a<n[1]||a>n[3])return!1;if(!JW(e,t,s,a,o))return Un(e,s,a,t.start,t.end)}return!1}function JW(e,t,n,r,o){for(let i=t.start;i<t.end;i++){let s=i+1===t.end?t.start:i+1,a=e[i*2],l=e[i*2+1];if(Tn(n,r,a,l,e[s*2],e[s*2+1])<=o)return!0}return!1}function QW(e,t,n){let r=1/0,o=1/0,i=-1/0,s=-1/0;for(let a=t;a<n;a++){let l=e[a*2],u=e[a*2+1];r=Math.min(r,l),i=Math.max(i,l),o=Math.min(o,u),s=Math.max(s,u)}return[r,o,i,s]}ti();function wR(e){if(eV(e))return null;let t=xi(e);if(t.some(n=>n.area===0))return null;for(let n of t){let r=0;for(let o=n.parent;o>=0;o=t[o].parent)r++;n.winding=r%2===0?1:0}return t}function ZW(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=new Float64Array(r*4),i=new Uint32Array(r),s=new Uint32Array(r),a=[],l=0;return n.forEach((u,c)=>{let d=c+1<n.length?n[c+1]:r,f=0;for(let p=u;p<d;p++){let h=p+1<d?p+1:u,m=t[p*2],g=t[p*2+1],b=t[h*2],x=t[h*2+1];m===b&&g===x||(o.set([m,g,b,x],l*4),i[l]=c,s[l]=f++,l++)}a.push(f)}),{ends:o,contour:i,pos:s,count:a,n:l}}function eV(e){let t=ZW(e),{ends:n,n:r}=t,o=1/0,i=1/0,s=-1/0,a=-1/0;for(let d=0;d<r*4;d+=2)o=Math.min(o,n[d]),s=Math.max(s,n[d]),i=Math.min(i,n[d+1]),a=Math.max(a,n[d+1]);let l=Math.max(s-o,a-i,Math.abs(o),Math.abs(s),Math.abs(i),Math.abs(a))*1e-9,u=Array.from({length:r},(d,f)=>f),c=d=>Math.min(n[d*4],n[d*4+2]);u.sort((d,f)=>c(d)-c(f));for(let d=0;d<r;d++){let f=u[d],p=Math.max(n[f*4],n[f*4+2])+l;for(let h=d+1;h<r;h++){let m=u[h];if(c(m)>p)break;if(tV(t,f,m,l))return!0}}return!1}function tV(e,t,n,r){let{ends:o}=e,i=o[t*4],s=o[t*4+1],a=o[t*4+2],l=o[t*4+3],u=o[n*4],c=o[n*4+1],d=o[n*4+2],f=o[n*4+3];if(Math.max(s,l)+r<Math.min(c,f)||Math.max(c,f)+r<Math.min(s,l))return!1;let p=nV(e,t,n);return p==="e-to"?xR(a-i,l-s,d-u,f-c)||Fs(i,s,u,c,d,f,r):p==="f-to"?xR(d-u,f-c,a-i,l-s)||Fs(u,c,i,s,a,l,r):Fs(i,s,u,c,d,f,r)||Fs(a,l,u,c,d,f,r)||Fs(u,c,i,s,a,l,r)||Fs(d,f,i,s,a,l,r)||rV(i,s,a,l,u,c,d,f)}function nV(e,t,n){if(e.contour[t]!==e.contour[n])return null;let r=e.count[e.contour[t]];return r<3?null:(e.pos[t]+1)%r===e.pos[n]?"e-to":(e.pos[n]+1)%r===e.pos[t]?"f-to":null}function xR(e,t,n,r){let o=e*r-t*n;return Math.abs(o)<=1e-9*Math.hypot(e,t)*Math.hypot(n,r)&&e*n+t*r<0}function Fs(e,t,n,r,o,i,s){return Tn(e,t,n,r,o,i)<=s}function rV(e,t,n,r,o,i,s,a){let l=kf(e,t,n,r,o,i),u=kf(e,t,n,r,s,a),c=kf(o,i,s,a,e,t),d=kf(o,i,s,a,n,r);return l*u<=0&&c*d<=0}var kf=(e,t,n,r,o,i)=>Math.sign((n-e)*(i-t)-(r-t)*(o-e));function tu(e,t={}){if(e.kind==="rect")return oV(e);let n=aV(Qe(e),t);return e.origin?{...n,origin:e.origin}:n}function oV(e){let t=gl(e.x,e.y,e.width,e.height),n=Sn(t);return{vertices:At(n,t),indices:new Uint32Array([0,1,2,0,2,3]),anchorA:new Uint32Array([0,1,2,3]),anchorB:new Uint32Array([0,1,2,3]),anchorT:new Float32Array([0,0,0,0]),...n?{origin:n}:{}}}function iV(e,t){let n=new Set,r=sV(e,t,n);if(kn(e))return r;let o={coords:[],contourStarts:[],anchorA:[],anchorB:[],anchorT:[]};return r.contourStarts.forEach((i,s)=>{if(!n.has(s))return;let a=s+1<r.contourStarts.length?r.contourStarts[s+1]:r.coords.length/2;o.contourStarts.push(o.coords.length/2),o.coords.push(...r.coords.slice(i*2,a*2)),o.anchorA.push(...r.anchorA.slice(i,a)),o.anchorB.push(...r.anchorB.slice(i,a)),o.anchorT.push(...r.anchorT.slice(i,a))}),o}function sV(e,t,n){let{commands:r,coords:o}=e,i=[],s=[],a=[],l=[],u=[],c=-1,d=-1,f=0,p=(h,m,g,b)=>{for(let w=0;w<m.length;w++)s.push(d),a.push(b),l.push(g>0?m[w]/g:0);let x=h+m.length-1;s[x]=b,a[x]=b,l[x]=0};return Ge(r,o,(h,m,g,b,x,w)=>{if(w){let y=Math.max(c,0);u.push(i.length/2),i.push(g,b),s.push(y),a.push(y),l.push(0),d=y}switch(h){case le:case ce:{h===le&&(u.push(i.length/2),c=f),i.push(o[m],o[m+1]),s.push(f),a.push(f),l.push(0),d=f,f++;break}case we:{let y=f,P=[],S=s.length,v=Rl(g,b,o[m],o[m+1],o[m+2],o[m+3],t,i,P);p(S,P,v,y),d=y,f++;break}case xe:{let y=f,P=[],S=s.length,v=Al(g,b,o[m],o[m+1],o[m+2],o[m+3],o[m+4],o[m+5],t,i,P);p(S,P,v,y),d=y,f++;break}case fe:n.add(u.length-1),d=c;break;default:throw new Error(`tessellate: unknown command code ${h}`)}}),{coords:i,contourStarts:u,anchorA:s,anchorB:a,anchorT:l}}function aV(e,t){let n=t.flattenTolerance??mt,r=iV(e,n);if(e.fillRule==="evenodd"){let a=wR(r);if(a)return eu(r,a);let l=gR(r);if(l)return eu(l,xi(l));let{coords:u,contourStarts:c,anchorA:d,anchorB:f,anchorT:p}=r;return lV(u,c,d,f,p)}let o=Fb(r);if(o)return eu(o,xi(o));let i=xi(r);if(i.every(a=>Math.abs(a.winding)<=1))return eu(r,i);let s=Fb(r,!0);return eu(s,xi(s))}function eu(e,t){let{coords:n,contourStarts:r,anchorA:o,anchorB:i,anchorT:s}=e,a=[],l=new Map;if(t.forEach((h,m)=>{h.area!==0&&(h.winding!==0?a.push(m):l.has(h.parent)?l.get(h.parent).push(m):l.set(h.parent,[m]))}),a.length<=1&&(a[0]??0)===0){let h=Tf(n,r.length>1?r.slice(1):void 0);return{vertices:new Float32Array(n),indices:new Uint32Array(h),anchorA:new Uint32Array(o),anchorB:new Uint32Array(i),anchorT:new Float32Array(s)}}let u=[],c=[],d=[],f=[],p=[];for(let h of a){let m=l.get(h)??[],g=u.length/2,b=[],x=[0];for(let y=t[h].start;y<t[h].end;y++)b.push(n[y*2],n[y*2+1]),c.push(o[y]),d.push(i[y]),f.push(s[y]);for(let y of m){x.push(b.length/2);for(let P=t[y].start;P<t[y].end;P++)b.push(n[P*2],n[P*2+1]),c.push(o[P]),d.push(i[P]),f.push(s[P])}let w=Tf(b,x.length>1?x.slice(1):void 0);for(let y of b)u.push(y);for(let y of w)p.push(y+g)}return{vertices:new Float32Array(u),indices:new Uint32Array(p),anchorA:new Uint32Array(c),anchorB:new Uint32Array(d),anchorT:new Float32Array(f)}}function lV(e,t,n,r,o){let i=[],s=e.length/2;for(let a=0;a<t.length;a++){let l=t[a],u=a+1<t.length?t[a+1]:s;for(let c=l+1;c<u-1;c++)i.push(l,c,c+1)}return{vertices:new Float32Array(e),indices:new Uint32Array(i),requiresStencil:!0,anchorA:new Uint32Array(n),anchorB:new Uint32Array(r),anchorT:new Float32Array(o)}}vk();function nu(e,t,n,r,o,i,s){return e===r&&t===o?[e,t,n+(i-n)*s]:s<.5?[e,t,n]:[r,o,i]}var TR=1e-9;function PR(e,t,n,r,o,i,s,a,l){let u=t.length,c=1;for(;c<u-1&&(l?t[c]<=a:t[c]<a);)c++;let d=t[c-1],f=t[c]-d,p=f>TR?(a-d)/f:0,h=e.points[(c-1)*2],m=e.points[(c-1)*2+1],g=e.points[c*2],b=e.points[c*2+1],[x,w,y]=nu(n[c-1],r[c-1],o[c-1],n[c],r[c],o[c],p),P=i?i[c-1]+(i[c]-i[c-1])*p:0,S=s?s[c-1]+(s[c]-s[c-1])*p:0;return{x:h+(g-h)*p,y:m+(b-m)*p,a:x,b:w,t:y,w:P,o:S,next:c}}function vf(e,t,n){let r=Math.max(0,t),o=Math.max(0,n);if(r<=0&&o<=0||e.closed)return e;let i=e.points.length/2;if(i<2)return null;let s=e.anchorA??new Uint32Array(i),a=e.anchorB??new Uint32Array(i),l=e.anchorT??new Float32Array(i),u=e.widths,c=e.offsets,d=new Float64Array(i);for(let v=1;v<i;v++){let A=e.points[v*2]-e.points[(v-1)*2],N=e.points[v*2+1]-e.points[(v-1)*2+1];d[v]=d[v-1]+Math.hypot(A,N)}let f=d[i-1],p=r,h=f-o;if(h-p<=TR)return null;let m=PR(e,d,s,a,l,u,c,p,!0),g=PR(e,d,s,a,l,u,c,h,!1),b=[m.x,m.y],x=[m.a],w=[m.b],y=[m.t],P=u?[m.w]:void 0,S=c?[m.o]:void 0;for(let v=m.next;v<g.next;v++)b.push(e.points[v*2],e.points[v*2+1]),x.push(s[v]),w.push(a[v]),y.push(l[v]),P&&P.push(u[v]),S&&S.push(c[v]);return b.push(g.x,g.y),x.push(g.a),w.push(g.b),y.push(g.t),P&&P.push(g.w),S&&S.push(g.o),{points:b,closed:!1,anchorA:new Uint32Array(x),anchorB:new Uint32Array(w),anchorT:new Float32Array(y),...P?{widths:new Float32Array(P)}:{},...S?{offsets:new Float32Array(S)}:{}}}var uV=4,SR=new WeakMap;function kR(e,t=mt){let n=bg(),r=SR.get(e);r===void 0&&SR.set(e,r=new Map);let o=r.get(t);if(o!==void 0&&o.openFill===n)return o.mesh;let i=tu(e,{flattenTolerance:t});return o===void 0&&r.size>=uV&&r.clear(),r.set(t,{mesh:i,openFill:n}),i}var cV={"source-over":{source:"one",destination:"one-minus-source-alpha"},"source-in":{source:"destination-alpha",destination:"zero"},"source-out":{source:"one-minus-destination-alpha",destination:"zero"},"source-atop":{source:"destination-alpha",destination:"one-minus-source-alpha"},"destination-over":{source:"one-minus-destination-alpha",destination:"one"},"destination-in":{source:"zero",destination:"source-alpha"},"destination-out":{source:"zero",destination:"one-minus-source-alpha"},"destination-atop":{source:"one-minus-destination-alpha",destination:"source-alpha"},xor:{source:"one-minus-destination-alpha",destination:"one-minus-source-alpha"},lighter:{source:"one",destination:"one"},copy:{source:"one",destination:"zero"}};function Lb(e){return typeof e=="string"?cV[e]:e}function $n(e){if(e===void 0)return!1;let{source:t,destination:n}=Lb(e);return t!=="one"||n!=="one-minus-source-alpha"}function RR(e){let{destination:t}=Lb(e);return t==="one"||t==="one-minus-source-alpha"}var vR=new WeakMap;function _b(e){let t=vR.get(e);if(t!==void 0)return t;let n=e.some(r=>r.kind==="group"&&($n(r.composite)||_b(r.children)));return vR.set(e,n),n}function AR(e,t){switch(t){case"zero":return e.ZERO;case"one":return e.ONE;case"source-alpha":return e.SRC_ALPHA;case"one-minus-source-alpha":return e.ONE_MINUS_SRC_ALPHA;case"destination-alpha":return e.DST_ALPHA;case"one-minus-destination-alpha":return e.ONE_MINUS_DST_ALPHA}}function Db(e,t){let{source:n,destination:r}=Lb(t);e.blendFunc(AR(e,n),AR(e,r))}Z();function De(e,t,n){e.gl.drawElements(e.gl.TRIANGLES,t,n,0),e.stats&&e.stats.drawCalls++}function wt(e,t=e.clipDepth){let n=e.gl;if(t===0){n.disable(n.STENCIL_TEST);return}let r=wi(t);n.enable(n.STENCIL_TEST),n.stencilFunc(n.EQUAL,r,r),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)}function wi(e){return e===0?0:(1<<e+1)-1&254}function Bb(e,t){let n=e.gl;n.enable(n.STENCIL_TEST),n.colorMask(!1,!1,!1,!1),n.stencilMask(1),n.stencilFunc(n.ALWAYS,0,1),n.stencilOp(n.KEEP,n.KEEP,n.INVERT),De(e,t,e.gl.UNSIGNED_INT);let r=wi(e.clipDepth);n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.EQUAL,r|1,r|1),n.stencilOp(n.KEEP,n.KEEP,n.INVERT)}function Hb(e){let t=e.gl;t.stencilMask(1),t.clear(t.STENCIL_BUFFER_BIT),t.disable(t.STENCIL_TEST)}Z();Pe();var NR=new WeakMap,IR=new WeakMap;function Nf(e,t){let n=NR.get(e);n||(n=new WeakMap,NR.set(e,n));let r=n.get(t);return r||(r={},n.set(t,r)),r}function wr(e,t){if(e===void 0||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Gb(e,t,n,r,o,i){let s=t.uniform("u_color");if(s===void 0)return;let a=Nf(e,t),l=a.color;l!==void 0&&l[0]===n&&l[1]===r&&l[2]===o&&l[3]===i||(e.gl.uniform4f(s,n,r,o,i),a.color=[n,r,o,i])}function If(e,t,n){let r=t.uniform("u_alpha");if(r===void 0)return;let o=Nf(e,t);o.alpha!==n&&(e.gl.uniform1f(r,n),o.alpha=n)}function ru(e){if(e.projection)return e.projection;let t=IR.get(e);return t||(t=q.toUniform(q.screenToClip(e.widthCss,e.heightCss)),IR.set(e,t)),t}var Af=new Float32Array(16);function Rn(e,t,n=e.state.colorMatrix){let r=e.gl,o=Nf(e,t),i=t.uniform("u_colorMatrix");if(i!==void 0){for(let a=0;a<4;a++)for(let l=0;l<4;l++)Af[l*4+a]=n[a*5+l];wr(o.colorMatrix,Af)||(r.uniformMatrix4fv(i,!1,Af),o.colorMatrix=Float32Array.from(Af))}let s=t.uniform("u_colorBias");if(s!==void 0){let a=[n[4],n[9],n[14],n[19]];wr(o.colorBias,a)||(r.uniform4f(s,a[0],a[1],a[2],a[3]),o.colorBias=Float32Array.from(a))}}var ER=65536;function Ef(e){let t=e.meshOrigin;return t?q.translated(e.state.transform,t.x,t.y):e.state.transform}function Mf(e,t,n){let r=e.meshOrigin;if(t===r)return n();e.meshOrigin=t;try{return n()}finally{e.meshOrigin=r}}var Ls=new Float32Array(9),Rf=new Float32Array(9);function nt(e,t,n=Ef(e),r=ru(e)){let o=e.gl,i=Nf(e,t);Rf.set(r),wr(i.proj,Rf)||(o.uniformMatrix3fv(t.uniform("u_proj"),!1,Rf),i.proj=Float32Array.from(Rf)),Ls.set(n);let s=t.uniform("u_origin");if(s!==void 0){let a=0,l=0,u=n[6],c=n[7];if(Math.abs(u)>=ER||Math.abs(c)>=ER){let d=n[0],f=n[1],p=n[3],h=n[4],m=d*h-f*p,g=Math.fround((p*c-h*u)/m),b=Math.fround((f*u-d*c)/m);Number.isFinite(g)&&Number.isFinite(b)&&(a=g,l=b,Ls[6]=d*a+p*l+u,Ls[7]=f*a+h*l+c)}(i.originX!==a||i.originY!==l)&&(o.uniform2f(s,a,l),i.originX=a,i.originY=l)}wr(i.model,Ls)||(o.uniformMatrix3fv(t.uniform("u_model"),!1,Ls),i.model=Float32Array.from(Ls))}function _s(e,t,n,r){let[o,i,s,a]=jn(n);Gb(e,t,o,i,s,a*(r??1)),If(e,t,e.state.alpha)}var MR=new Set;function OR(e,t){MR.has(e)||(MR.add(e),Qt()&&console.warn(t))}function Ub(e,t){OR(`${e}:${t}`,`weasel drawShader: uniform "${t}" not found in program "${e}". Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`)}function dV(e,t,n,r,o){if(n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Float32Array)&&"id"in n&&typeof n.id=="string"){let i=n,s=Es(i.id);if(!s){Qt()&&console.warn(`weasel setUniform: TextureHandle "${i.id}" not registered`);return}let a=o.value++;e.activeTexture(e.TEXTURE0+a),r.uploadRegistered(i.id,s.source),r.bind(i.id,a),e.uniform1i(t,a);return}if(n instanceof Float64Array&&(n=Float32Array.from(n)),n instanceof Float32Array){if(n.length===9)e.uniformMatrix3fv(t,!1,n);else if(n.length===16)e.uniformMatrix4fv(t,!1,n);else if(Qt())throw new TypeError(`weasel setUniform: Float32Array must be length 9 (mat3) or 16 (mat4), got ${n.length}`);return}if(Array.isArray(n)){let i=n;switch(i.length){case 2:e.uniform2fv(t,i);break;case 3:e.uniform3fv(t,i);break;case 4:e.uniform4fv(t,i);break;default:if(Qt())throw new TypeError(`weasel setUniform: array length ${i.length} not supported`)}return}if(typeof n=="number"){e.uniform1f(t,n);return}}var fV={float:{fn:"uniform1fv",n:1},vec2:{fn:"uniform2fv",n:2},vec3:{fn:"uniform3fv",n:3},vec4:{fn:"uniform4fv",n:4},int:{fn:"uniform1iv",n:1},ivec2:{fn:"uniform2iv",n:2},ivec3:{fn:"uniform3iv",n:3},ivec4:{fn:"uniform4iv",n:4},bool:{fn:"uniform1iv",n:1},bvec2:{fn:"uniform2iv",n:2},bvec3:{fn:"uniform3iv",n:3},bvec4:{fn:"uniform4iv",n:4},uint:{fn:"uniform1uiv",n:1},uvec2:{fn:"uniform2uiv",n:2},uvec3:{fn:"uniform3uiv",n:3},uvec4:{fn:"uniform4uiv",n:4},mat2:{fn:"uniformMatrix2fv",n:4,matrix:!0},mat3:{fn:"uniformMatrix3fv",n:9,matrix:!0},mat4:{fn:"uniformMatrix4fv",n:16,matrix:!0},mat2x2:{fn:"uniformMatrix2fv",n:4,matrix:!0},mat3x3:{fn:"uniformMatrix3fv",n:9,matrix:!0},mat4x4:{fn:"uniformMatrix4fv",n:16,matrix:!0},mat2x3:{fn:"uniformMatrix2x3fv",n:6,matrix:!0},mat2x4:{fn:"uniformMatrix2x4fv",n:8,matrix:!0},mat3x2:{fn:"uniformMatrix3x2fv",n:6,matrix:!0},mat3x4:{fn:"uniformMatrix3x4fv",n:12,matrix:!0},mat4x2:{fn:"uniformMatrix4x2fv",n:8,matrix:!0},mat4x3:{fn:"uniformMatrix4x3fv",n:12,matrix:!0}};function pV(e){return Array.isArray(e)||e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint32Array}function hV(e,t,n,r){let o=fV[n.type];if(!o){Qt()&&console.warn(`weasel setUniform: array uniform "${t}" has type ${n.type}, which cannot be written as a whole`);return}if(r.length%o.n!==0||r.length>o.n*n.size){if(Qt())throw new TypeError(`weasel setUniform: "${t}" is ${n.type}[${n.size}], so its value must hold a multiple of ${o.n} numbers, at most ${o.n*n.size}; got ${r.length}`);return}if(r.length===0)return;let i=e[o.fn];o.matrix?i.call(e,n.location,!1,r):i.call(e,n.location,r)}function Wb(e,t,n,r,o,i){for(let[s,a]of Object.entries(r)){let l=t.uniformArray(s);if(l&&pV(a)){hV(e,s,l,a);continue}let u=t.uniform(s);if(u===void 0){Ub(n,s);continue}dV(e,u,a,o,i)}}function FR(e,t){let{gl:n,programRegistry:r,quadVbo:o,quadIbo:i,textureCache:s}=e,a=e.ensureProgram?.(t.program.id)??r.get(t.program.id);if(!a){OR(`${t.program.id}:(program)`,`weasel drawShader: program "${t.program.id}" has no compiled program on this renderer. Register its source with the module-level registerProgram() first; a source that failed to compile is reported above.`);return}if(!o||!i){console.warn("weasel drawShader: quad geometry not initialized");return}n.useProgram(a.handle);let l=a.attribute("a_position"),u=a.attribute("a_uv");n.bindBuffer(n.ARRAY_BUFFER,o),l!==void 0&&(n.enableVertexAttribArray(l),n.vertexAttribPointer(l,2,n.FLOAT,!1,16,0)),u!==void 0&&(n.enableVertexAttribArray(u),n.vertexAttribPointer(u,2,n.FLOAT,!1,16,8)),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i);let c=a.uniform("u_proj");c!==void 0&&n.uniformMatrix3fv(c,!1,q.toUniform(ru(e)));let d=a.uniform("u_bounds");d!==void 0&&n.uniform4f(d,t.bounds.x,t.bounds.y,t.bounds.w,t.bounds.h);let f=a.uniform("u_fragOrigin");if(f!==void 0){let[h,m]=(e.renderTarget?e.renderTarget.fragOrigin:e.fragOrigin)??[0,0];n.uniform2f(f,h,m)}let p=a.uniform("u_view");p!==void 0&&n.uniformMatrix3fv(p,!1,q.toUniform(e.state.transform)),mV(n,a,e.state.transform,t.bounds),Wb(n,a,t.program.id,t.uniforms,s,{value:1}),wt(e),De(e,6,e.gl.UNSIGNED_SHORT),l!==void 0&&n.disableVertexAttribArray(l),u!==void 0&&n.disableVertexAttribArray(u),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}function mV(e,t,n,r){let o=t.uniform("u_screenToLocal"),i=t.uniform("u_worldOrigin");if(o===void 0&&i===void 0)return;let s=q.invert(n),a=0,l=0,u=q.scaled(q.identity(),0,0);if(s){let c=s[0]*r.x+s[3]*r.y+s[6],d=s[1]*r.x+s[4]*r.y+s[7];(Math.abs(c)>=CR||Math.abs(d)>=CR)&&(a=Math.fround(c),l=Math.fround(d)),u=q.multiply(q.translated(q.identity(),-a,-l),s)}o!==void 0&&e.uniformMatrix3fv(o,!1,q.toUniform(u)),i!==void 0&&e.uniform2f(i,a,l)}var CR=8192;Z();Z();function _R(e,t){if(e.kind!=="rect"||!(t[1]===0&&t[3]===0||t[0]===0&&t[4]===0))return null;let r=t[0]*e.x+t[3]*e.y+t[6],o=t[1]*e.x+t[4]*e.y+t[7],i=e.x+e.width,s=e.y+e.height,a=t[0]*i+t[3]*s+t[6],l=t[1]*i+t[4]*s+t[7];return{x0:Math.min(r,a),y0:Math.min(o,l),x1:Math.max(r,a),y1:Math.max(o,l)}}function DR(e,t){return{x0:Math.max(e.x0,t.x0),y0:Math.max(e.y0,t.y0),x1:Math.min(e.x1,t.x1),y1:Math.min(e.y1,t.y1)}}var BR=16,yV=8,gV=new Float64Array(0);function HR(e,t,n){if(e===null&&t.length===0)return null;let r=gV;if(t.length===1)r=t[0];else if(t.length>1){r=new Float64Array(t.reduce((i,s)=>i+s.length,0));let o=0;for(let i of t)r.set(i,o),o+=i.length}return{rect:e,planes:r,slanted:n}}var LR=new WeakMap;function GR(e,t){let n=LR.get(e);if(n!==void 0&&n.m[0]===t[0]&&n.m[1]===t[1]&&n.m[2]===t[3]&&n.m[3]===t[4]&&n.m[4]===t[6]&&n.m[5]===t[7])return n.planes;let r=bV(e,t);return LR.set(e,{m:Float64Array.of(t[0],t[1],t[3],t[4],t[6],t[7]),planes:r}),r}function bV(e,t){let n=qg(e);if(n===null)return null;let r=[];for(let o=0;o<n.length;o+=2)r.push(t[0]*n[o]+t[3]*n[o+1]+t[6],t[1]*n[o]+t[4]*n[o+1]+t[7]);return zb(r,yV)}function zb(e,t){let n=[];for(let s=0;s<e.length;s+=2){let a=n.length;a>=2&&n[a-2]===e[s]&&n[a-1]===e[s+1]||n.push(e[s],e[s+1])}for(;n.length>=4&&n[0]===n[n.length-2]&&n[1]===n[n.length-1];)n.length-=2;if(n.length<6)return null;yr(n)<0&&Xg(n);let r=Jg(n);if(r.length<6||r.length/2>t||!Qg(r))return null;let o=r.length/2,i=new Float64Array(o*3);for(let s=0;s<o;s++){let a=r[s*2],l=r[s*2+1],u=r[(s+1)%o*2],c=r[(s+1)%o*2+1],d=Math.hypot(u-a,c-l),f=-(c-l)/d,p=(u-a)/d;i[s*3]=f,i[s*3+1]=p,i[s*3+2]=-(f*a+p*l)}return i}function Pr(e,t,n){let r=e.rect;if(r!==null&&(t<r.x0||t>r.x1||n<r.y0||n>r.y1))return!1;let o=e.planes;for(let i=0;i<o.length;i+=3)if(o[i]*t+o[i+1]*n+o[i+2]<0)return!1;return!0}function Cf(e,t,n,r,o){let i=e.rect;if(i!==null){let a=!0,l=!0,u=!0,c=!0;for(let d=0,f=n;d<r;d++,f+=o){let p=t[f],h=t[f+1];a&&=p<=i.x0,l&&=p>=i.x1,u&&=h<=i.y0,c&&=h>=i.y1}if(a||l||u||c)return!0}let s=e.planes;for(let a=0;a<s.length;a+=3){let l=!0;for(let u=0,c=n;u<r&&l;u++,c+=o)l=s[a]*t[c]+s[a+1]*t[c+1]+s[a+2]<=0;if(l)return!0}return!1}function Kb(e,t,n,r,o,i){let s=r.rect,a=r.planes,l=s===null?0:4,u=l+a.length/3;if(u===0)return o.set(e.subarray(0,t*n)),t;let c=e,d=u%2===0?i:o,f=t;for(let p=0;p<u;p++){if(p<l){let h=p<2?0:1,m=p===0?s.x0:p===1?s.x1:p===2?s.y0:s.y1;f=xV(c,f,n,h,m,p%2===0?1:-1,d)}else{let h=(p-l)*3;f=ou(c,f,n,a[h],a[h+1],a[h+2],d)}c=d,d=d===o?i:o}return f}function xV(e,t,n,r,o,i,s){if(t===0)return 0;let a=0,l=t-1,u=i*(e[l*n+r]-o)>=0;for(let c=0;c<t;c++){let d=i*(e[c*n+r]-o)>=0;if(d!==u){let[f,p]=UR(e,l*n,c*n),h=(o-e[f+r])/(e[p+r]-e[f+r]);WR(e,f,p,h,n,s,a*n),s[a*n+r]=o,a++}d&&(s.set(e.subarray(c*n,c*n+n),a*n),a++),l=c,u=d}return a}function ou(e,t,n,r,o,i,s){if(t===0)return 0;let a=0,l=t-1,u=r*e[l*n]+o*e[l*n+1]+i>=0;for(let c=0;c<t;c++){let d=c*n,f=r*e[d]+o*e[d+1]+i>=0;if(f!==u){let[p,h]=UR(e,l*n,d),m=r*e[p]+o*e[p+1]+i,g=r*e[h]+o*e[h+1]+i;WR(e,p,h,m/(m-g),n,s,a*n),a++}f&&(s.set(e.subarray(c*n,c*n+n),a*n),a++),l=c,u=f}return a}var Vb=[0,0];function UR(e,t,n){let r=e[n]<e[t]||e[n]===e[t]&&e[n+1]<e[t+1];return Vb[0]=r?n:t,Vb[1]=r?t:n,Vb}function WR(e,t,n,r,o,i,s){for(let a=0;a<o;a++)i[s+a]=e[t+a]+r*(e[n+a]-e[t+a])}function Ds(e){return aR(e.flattenTolerance,e.state.transform)}function Of(e,t){return kR(t,Ds(e))}function jb(e,t){return e.meshCache.handleFor(t)}function iu(e,t){return jb(e,Of(e,t))}Z();function Ff(e){return e===Ut||wr(Ut,e)}var su={enabled:!0};function au(e){return su.enabled||Ff(e.state.colorMatrix)}function $b(e,t,n,r,o){let i=e.state.colorMatrix,s=e.state.alpha;if(Ff(i))return[t,n,r,o*s];if(!su.enabled)return[t,n,r,o];let a=iR(i,t,n,r,o);return a[3]*=s,a}function Lf(e,t,n,r,o,i){return Ff(e.state.colorMatrix)?(i[0]=t,i[1]=n,i[2]=r,i[3]=o*e.state.alpha,i):$b(e,t,n,r,o)}var VR=[1,1,1,1],wV=[0,6,12,18];function PV(e){let t=e.state.colorMatrix,n=e.state.alpha;if(Ff(t))return n===1?VR:[1,1,1,n];if(!su.enabled)return null;for(let r=0;r<20;r++){let o=t[r];if(wV.includes(r)?o<0||o>1:o!==0)return null}return[t[0],t[6],t[12],t[18]*n]}function Bs(e,t){let n=PV(e);if(n!==null)return{colorMatrix:Ut,alpha:1,tint:n,slot:0};let r=e.state.colorMatrix,o=e.state.alpha;return t?{colorMatrix:r,alpha:o,tint:VR,slot:0}:{colorMatrix:r,alpha:1,tint:[1,1,1,o],slot:0}}function Yb(e,t,n){for(let r=0;r<e.length;r++){let o=e[r];if(o.alpha===n&&(o.colorMatrix===t||wr(o.colorMatrix,t)))return r}return e.length<(su.enabled?zn:1)?e.length:-1}var zR=new Float32Array(16*zn),KR=new Float32Array(4*zn),jR=new Float32Array(zn),$R=new WeakMap;function TV(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;n++){let r=e[n],o=t[n];if(r.alpha!==o.alpha||r.colorMatrix!==o.colorMatrix&&!wr(r.colorMatrix,o.colorMatrix))return!1}return!0}function YR(e,t,n){let r=$R.get(e);r||(r=new WeakMap,$R.set(e,r));let o=r.get(t);if(o!==void 0&&TV(o,n))return;let i=n.length;for(let a=0;a<i;a++){let l=n[a].colorMatrix;for(let u=0;u<4;u++){for(let c=0;c<4;c++)zR[16*a+c*4+u]=l[u*5+c];KR[4*a+u]=l[u*5+4]}jR[a]=n[a].alpha}let s=e.gl;s.uniformMatrix4fv(t.uniform("u_colorMatrix"),!1,zR.subarray(0,16*i)),s.uniform4fv(t.uniform("u_colorBias"),KR.subarray(0,4*i)),s.uniform1fv(t.uniform("u_alpha"),jR.subarray(0,i)),r.set(t,n.slice())}var Hs=q.identity(),SV=new Int32Array(Array.from({length:yt},(e,t)=>t)),qb=new Float32Array(2*yt),qR=new Int32Array(4*vs);function ye(e){let t=e.drawBatch,n=e.batchState;if(t.length===0||n===void 0){e.batchState=void 0;return}let r=e.gl,o=n.matrices.length>1,i=n.hulls!==void 0,s=n.areaGlyphs,a=(o||i||s)&&e.batchVariants?e.batchVariants.get(o,i,s):e.batchFill;r.useProgram(a.handle);let l=t.uploadAndBind();nt(e,a,Hs),Gb(e,a,1,1,1,1),YR(e,a,n.matrices),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,e.whiteTexture);for(let u=0;u<n.textures.length;u++){let c=n.textures[u];if(c.kind==="atlas"){e.textureCache.bind(c.id,u+1),qb[2*(u+1)]=c.fieldScale[0],qb[2*(u+1)+1]=c.fieldScale[1];continue}e.imageCache.bind(c.image,u+1),e.imageCache.setMagFilter(c.image,c.sampling==="nearest"?r.NEAREST:r.LINEAR),e.imageCache.setMinFilter(c.image,c.mips)}n.ramps&&e.gradRamps.bind(As),r.uniform1iv(a.uniform("u_samplers"),SV),r.uniform2fv(a.uniform("u_fieldScale"),qb),i&&kV(r,a,n),wt(e,n.clipDepth),De(e,l,e.gl.UNSIGNED_INT),r.activeTexture(r.TEXTURE0),r.bindVertexArray(null),t.reset(),e.batchState=void 0}function kV(e,t,n){for(let{set:r,start:o}of n.hulls)qR.set(r.planes,4*o);e.uniform4iv(t.uniform("u_hullPlanes"),qR,0,4*n.hullPlanes)}function uu(e,t,n=e.state.transform){let r=e.clipStack.reduce((o,i)=>o+(i.depth===0?1:0),0);if(e.clipDepth+r+1>7)throw new Error("weasel: clip nesting depth exceeded (max 7). You can't nest more than 7 levels of clipped containers in a single draw tree. Flatten the hierarchy or compose poses outside the scene graph.");AV(e,t,n)}var vV=q.identity();function AV(e,t,n){let r=_R(t,n),o=r===null?null:Xb(e),i=o===null?null:Yv(t,n,o),s=i?i.rect:r,a=_f(e),l=e.clipStack[e.clipStack.length-1],u=l===void 0?null:l.uncutHulls,c=s===null?NV(e,t,n):null,d=c&&(a?Yg(a,c.set):c.set),f=s===null&&c===null?RV(e,t,n):null;if(s!==null){let p=i?i.hull:null,h=p?XR(u,p.set):!1;e.clipStack.push({path:t,transform:n,rect:s,hull:p,planes:null,hulls:a,uncutHulls:h,depth:0})}else if(c&&d){let p=XR(u,c.set);e.clipStack.push({path:t,transform:n,rect:null,hull:c,planes:null,hulls:d,uncutHulls:p,depth:0})}else if(f!==null)e.clipStack.push({path:t,transform:n,rect:null,hull:null,planes:f,hulls:a,uncutHulls:u,depth:0});else{Qb(e);let p=e.clipDepth+1;tN(e,t,p,n),e.clipDepth=p,e.clipStack.push({path:t,transform:n,rect:null,hull:null,planes:null,hulls:a,uncutHulls:u,depth:p})}eN(e)}function RV(e,t,n){if(!JR(e))return null;let r=GR(t,n);if(r===null)return null;let o=r.length/3;for(let i of e.clipStack)i.planes&&(o+=i.planes.length/3);return o<=BR?r:null}function XR(e,t){return e===!1?!1:(e?Yg(e,t):t)??!1}function Xb(e){return!e.batchVariants?.hulls||e.renderTarget||e.projection||e.deviceWidth===void 0||e.deviceHeight===void 0?null:$v(ru(e),e.fragOrigin??[0,0],e.deviceWidth,e.deviceHeight)}function JR(e){return e.batchVariants?.cuts!==!1&&Xb(e)===null}function NV(e,t,n){let r=Xb(e);return r===null?null:$g(t,n,r)}function _f(e){if(e.uncutHulls!==void 0)return e.uncutHulls;let t=e.clipStack;return t.length===0?null:t[t.length-1].hulls}function Jb(e){let t=e.clipStack.pop();t.depth>0&&(IV(e,QR(t),t.depth-1,ZR(t)),e.clipDepth=t.depth-1),eN(e)}function QR(e){return e.hull?e.hull.path:e.path}function ZR(e){return e.hull?vV:e.transform}function Qb(e){for(let t of e.clipStack){if(t.depth!==0)continue;let n=e.clipDepth+1;tN(e,QR(t),n,ZR(t)),t.depth=n,e.clipDepth=n}}function eN(e){let t=null,n=[];for(let r of e.clipStack)r.rect&&(t=t?DR(t,r.rect):r.rect),r.planes&&n.push(r.planes);e.drawBatch.clip=HR(t,n,JR(e))}function Zb(e){let t=e.clipStack;if(t.length===0||e.uncut)return e.clipDepth;for(let n=t.length-1;n>=0;n--)if(t[n].rect===null&&t[n].hull===null&&t[n].planes===null)return t[n].depth;for(let n of t)if(n.depth>0)return n.depth-1;return e.clipDepth}function po(e){let t=e.drawBatch.clip;e.drawBatch.clip=null;let n=e.clipStack[e.clipStack.length-1];return n!==void 0&&n.uncutHulls?(e.uncutHulls=n.uncutHulls,t):(Qb(e),e.uncut=!0,t)}function ho(e,t){e.drawBatch.clip=t,e.uncut=!1,e.uncutHulls=void 0}function sn(e,t,n,r){let o=po(e);r(e,t,n),ho(e,o)}function an(e){ye(e),e.clipStack.length>0&&Qb(e)}function lu(e,t,n){let r=e.gl,o=iu(e,t);r.useProgram(e.pathFill.handle),r.bindVertexArray(o.vao);let i=t.kind==="polygon"?t.origin:void 0;nt(e,e.pathFill,i?q.translated(n,i.x,i.y):n),De(e,o.indexCount,e.gl.UNSIGNED_INT),r.bindVertexArray(null)}function tN(e,t,n,r=e.state.transform){ye(e);let o=e.gl,i=wi(n-1),s=1<<n,a=i|s;o.enable(o.STENCIL_TEST),o.colorMask(!1,!1,!1,!1),iu(e,t).requiresStencil?(o.stencilMask(1),o.stencilFunc(o.ALWAYS,0,1),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),lu(e,t,r),o.stencilMask(s),o.stencilFunc(o.EQUAL,a|1,i|1),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),lu(e,t,r),o.stencilMask(1),o.stencilFunc(o.ALWAYS,0,1),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),lu(e,t,r)):(o.stencilMask(s),o.stencilFunc(o.EQUAL,a,i),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),lu(e,t,r)),o.colorMask(!0,!0,!0,!0),o.stencilMask(255)}function IV(e,t,n,r=e.state.transform){e.batchState!==void 0&&e.batchState.clipDepth>n&&ye(e);let o=e.gl;o.enable(o.STENCIL_TEST);let i=1<<n+1,s=wi(n)|i;o.colorMask(!1,!1,!1,!1),o.stencilMask(i),o.stencilFunc(o.EQUAL,s,s),o.stencilOp(o.KEEP,o.KEEP,o.ZERO),lu(e,t,r),o.colorMask(!0,!0,!0,!0),o.stencilMask(255)}var Df=xt(),fie=Df.reflection;function Nn(e){return Df.get(e)??null}function Bf(e,t,n){if(Df.has(e)&&!Qt())throw new Error(`weasel registerProgram: duplicate program id "${e}". In production, re-registration is not allowed. Pass a unique id or call in dev mode.`);return Df.set(e,{vert:t,frag:n}),{id:e}}var nN=`#version 300 es
369
+ `,SR=Bb(_b),kR=Bb(Lb),vR=Bb(vW),Hb=["u_atlas","u_synthBold","u_fieldScale"],AR=e=>e!=="u_origin",RR=[...bf.filter(AR),...Hb],NR=[...gf.filter(AR),...Hb],IR=["u_proj","u_model","u_worldInv","u_sampler",...Hb],ER=["a_position","a_uv","a_post","a_texSlot"];var Pf=class{gl;target=null;constructor(t){this.gl=t}acquire(t,n){let r=this.target;if(r&&r.width>=t&&r.height>=n)return r;let o=Math.max(r?.width??0,MR(t)),i=Math.max(r?.height??0,MR(n));return this.release(),this.target=this.create(o,i),this.target}release(){this.target&&(this.gl.deleteFramebuffer(this.target.fbo),this.gl.deleteTexture(this.target.texture),this.target=null)}create(t,n){let r=this.gl,o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texImage2D(r.TEXTURE_2D,0,r.RGBA8,t,n,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null);let i=r.createFramebuffer();return r.bindFramebuffer(r.FRAMEBUFFER,i),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,o,0),r.bindFramebuffer(r.FRAMEBUFFER,null),{fbo:i,texture:o,width:t,height:n}}};function MR(e){let t=64;for(;t<e;)t*=2;return t}var Zl=class{constructor(t){this.gl=t;this.finalizer=new FinalizationRegistry(n=>{this.persistent.delete(n)&&this.pendingDeletes.push(n)})}gl;map=new WeakMap;seen=new WeakSet;finalizer;persistent=new Set;pendingDeletes=[];disposed=!1;transientThisFrame=[];handleFor(t){let n=this.map.get(t);if(n)return n;let{handle:r,vbo:o,ibo:i}=this.upload(t);this.map.set(t,r);let s={vao:r.vao,vbo:o,ibo:i};return this.persistent.add(s),this.finalizer.register(t,s,t),r}uploadTransient(t){let{handle:n,vbo:r,ibo:o}=this.upload(t);return this.transientThisFrame.push({vao:n.vao,vbo:r,ibo:o}),n}uploadRecurring(t){return this.seen.has(t)?this.handleFor(t):(this.seen.add(t),this.uploadTransient(t))}freeTransient(){if(this.transientThisFrame.length===0)return;let t=this.gl;if(t.isContextLost()){this.transientThisFrame.length=0;return}for(let n of this.transientThisFrame)t.deleteVertexArray(n.vao),t.deleteBuffer(n.vbo),t.deleteBuffer(n.ibo);this.transientThisFrame.length=0}_transientCount(){return this.transientThisFrame.length}drainPendingDeletes(){if(this.pendingDeletes.length===0)return;let t=this.gl;if(t.isContextLost()){this.pendingDeletes.length=0;return}for(let n of this.pendingDeletes)t.deleteVertexArray(n.vao),t.deleteBuffer(n.vbo),t.deleteBuffer(n.ibo);this.pendingDeletes.length=0}dispose(){if(!this.disposed){this.disposed=!0,this.freeTransient();for(let t of this.persistent)this.pendingDeletes.push(t);this.persistent.clear(),this.drainPendingDeletes()}}_pendingDeleteCount(){return this.pendingDeletes.length}_enqueueDeleteForTest(t){this.pendingDeletes.push(t)}upload(t){let n=this.gl,r=n.createVertexArray();if(!r)throw new Error("createVertexArray returned null");n.bindVertexArray(r);let o=n.createBuffer();if(!o)throw new Error("createBuffer (VBO) returned null");n.bindBuffer(n.ARRAY_BUFFER,o),n.bufferData(n.ARRAY_BUFFER,t.vertices,n.STATIC_DRAW),n.enableVertexAttribArray(ld),n.vertexAttribPointer(ld,2,n.FLOAT,!1,0,0);let i=n.createBuffer();if(!i)throw new Error("createBuffer (IBO) returned null");return n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.indices,n.STATIC_DRAW),n.bindVertexArray(null),{handle:{vao:r,indexCount:t.indices.length,requiresStencil:t.requiresStencil??!1,anchorA:t.anchorA,anchorB:t.anchorB,anchorT:t.anchorT},vbo:o,ibo:i}}};function eu(e,t){e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1)}function AW(e,t){e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,t)}var tu=class{constructor(t){this.gl=t}gl;map=new Map;wraps=new Map;registered=new Map;sweptVersion=-1;has(t){return this.map.has(t)}upload(t,n,r="clamp"){return this.ensure(t,n,r,AW)}ensure(t,n,r,o){let i=this.map.get(t);if(i)return this.wraps.get(t)!==r&&this.applyWrap(t,i,r),t;let s=this.gl,a=s.createTexture();if(!a)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);let l=r==="repeat"?s.REPEAT:s.CLAMP_TO_EDGE;return s.bindTexture(s.TEXTURE_2D,a),o(s,n),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,l),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,l),s.bindTexture(s.TEXTURE_2D,null),this.map.set(t,a),this.wraps.set(t,r),t}uploadRegistered(t,n,r="clamp"){let o=this.map.get(t);if(o&&this.registered.get(t)!==n){let i=this.gl;i.bindTexture(i.TEXTURE_2D,o),eu(i,n),i.bindTexture(i.TEXTURE_2D,null)}return this.registered.set(t,n),this.ensure(t,n,r,eu)}replaces(t,n){return this.map.has(t)&&this.registered.get(t)!==n}sweep(t){let n=t.getVersion();if(n!==this.sweptVersion){this.sweptVersion=n;for(let r of this.registered.keys())t.has(r)||(this.gl.deleteTexture(this.map.get(r)??null),this.map.delete(r),this.wraps.delete(r),this.registered.delete(r))}}applyWrap(t,n,r){let o=this.gl,i=r==="repeat"?o.REPEAT:o.CLAMP_TO_EDGE;o.bindTexture(o.TEXTURE_2D,n),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,i),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,i),o.bindTexture(o.TEXTURE_2D,null),this.wraps.set(t,r)}uploadR8(t,n,r,o){if(this.map.has(t))return;let i=this.gl,s=i.createTexture();if(!s)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);i.bindTexture(i.TEXTURE_2D,s),i.pixelStorei(i.UNPACK_ALIGNMENT,1),i.texImage2D(i.TEXTURE_2D,0,i.R8,n,r,0,i.RED,i.UNSIGNED_BYTE,o),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.wraps.set(t,"clamp")}subImageR8(t,n,r,o,i,s){let a=this.map.get(t);if(!a)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let l=this.gl;l.bindTexture(l.TEXTURE_2D,a),l.pixelStorei(l.UNPACK_ALIGNMENT,1),l.texSubImage2D(l.TEXTURE_2D,0,n,r,o,i,l.RED,l.UNSIGNED_BYTE,s),l.pixelStorei(l.UNPACK_ALIGNMENT,4),l.bindTexture(l.TEXTURE_2D,null)}uploadRGBA(t,n,r,o){if(this.map.has(t))return;let i=this.gl,s=i.createTexture();if(!s)throw new Error(`GLTextureCache: createTexture failed for id="${t}"`);i.bindTexture(i.TEXTURE_2D,s),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,n,r,0,i.RGBA,i.UNSIGNED_BYTE,o),i.generateMipmap(i.TEXTURE_2D),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR_MIPMAP_LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.wraps.set(t,"clamp")}subImageRGBA(t,n,r,o,i,s){let a=this.map.get(t);if(!a)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let l=this.gl;l.bindTexture(l.TEXTURE_2D,a),l.texSubImage2D(l.TEXTURE_2D,0,n,r,o,i,l.RGBA,l.UNSIGNED_BYTE,s),l.generateMipmap(l.TEXTURE_2D),l.bindTexture(l.TEXTURE_2D,null)}bind(t,n){let r=this.map.get(t);if(!r)throw new Error(`GLTextureCache: texture "${t}" not uploaded`);let o=this.gl;o.activeTexture(o.TEXTURE0+n),o.bindTexture(o.TEXTURE_2D,r)}free(){let t=this.gl;for(let n of this.map.values())t.deleteTexture(n);this.map.clear(),this.wraps.clear(),this.registered.clear()}};var Ls=xt(),xi=Ls.reflection;var bi=[];function Tf(e,t){let n={prefix:e,owner:t};return bi.push(n),()=>{let r=bi.indexOf(n);r!==-1&&bi.splice(r,1)}}function CR(e){return OR(e)!==void 0}function OR(e){for(let t=0;t<bi.length;t++)if(e.startsWith(bi[t].prefix))return bi[t].owner}function _s(e){let t=bi.length>0?OR(e):void 0,n=Ls.get(e);return n?t?.touched?(t.touched(e),Ls.get(e)??null):n:t?(t.revive(e),Ls.get(e)??null):null}function Sf(e,t,n){return Ls.set(e,n?{source:t,size:n}:{source:t}),{id:e}}function kf(e){return Ls.delete(e.id)}var FR=4096,nu=new Set;function vf(e){for(let t of nu)t.release(e)}function LR(e){for(let t of nu)if(t.drewInLatestFrame(e))return!0;return!1}function _R(){let e=1/0;for(let t of nu)e=Math.min(e,t.maxTextureSide);return Number.isFinite(e)?e:FR}var Ds=class{constructor(t,n="linear"){this.gl=t;this.minification=n;let r=t.getParameter(t.MAX_TEXTURE_SIZE);this.maxTextureSide=typeof r=="number"&&r>0?r:FR,this.finalizer=new FinalizationRegistry(o=>{this.textures.delete(o)&&this.pendingDeletes.push(o)}),nu.add(this)}gl;minification;maxTextureSide;map=new WeakMap;textures=new Set;magFilters=new WeakMap;minFilters=new WeakMap;finalizer;pendingDeletes=[];mipped=new WeakSet;frame=0;lastDrawn=new WeakMap;beginFrame(){this.frame++,this.drainPendingDeletes()}drewInLatestFrame(t){return this.lastDrawn.get(t)===this.frame}drainPendingDeletes(){if(this.pendingDeletes.length!==0){for(let t of this.pendingDeletes)this.gl.deleteTexture(t);this.pendingDeletes.length=0}}release(t){let n=this.map.get(t);n&&(this.gl.deleteTexture(n),this.textures.delete(n),this.finalizer.unregister(t),this.map.delete(t),this.magFilters.delete(t),this.minFilters.delete(t),this.lastDrawn.delete(t),this.mipped.delete(t))}dispose(){for(let t of this.textures)this.gl.deleteTexture(t);this.drainPendingDeletes(),this.abandon()}abandon(){this.textures.clear(),this.pendingDeletes.length=0,nu.delete(this)}upload(t,n,r){this.lastDrawn.set(t,this.frame);let o=this.map.get(t);if(o)return o;let i=this.gl,s=i.createTexture();if(!s)throw new Error("GLImageCache: createTexture failed");i.bindTexture(i.TEXTURE_2D,s),eu(i,n),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),this.minFilters.set(t,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),this.magFilters.set(t,i.LINEAR);let[a,l]=RW(i,r);return i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,a),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,l),this.minification==="mipmap"&&(i.generateMipmap(i.TEXTURE_2D),this.mipped.add(t)),i.bindTexture(i.TEXTURE_2D,null),this.map.set(t,s),this.textures.add(s),this.finalizer.register(t,s,t),s}lacksMipmaps(t){return this.minification==="auto"&&!this.mipped.has(t)}hasMipmaps(t){return this.mipped.has(t)}buildMipmaps(t){let n=this.map.get(t);if(!n||this.mipped.has(t))return;let r=this.gl;r.bindTexture(r.TEXTURE_2D,n),r.generateMipmap(r.TEXTURE_2D),r.bindTexture(r.TEXTURE_2D,null),this.mipped.add(t)}setMinFilter(t,n){let r=this.gl,o=n&&this.mipped.has(t)?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;this.minFilters.get(t)!==o&&(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),this.minFilters.set(t,o))}bind(t,n){let r=this.map.get(t);if(!r)throw new Error("GLImageCache: image not uploaded; call upload() first");this.lastDrawn.set(t,this.frame);let o=this.gl;o.activeTexture(o.TEXTURE0+n),o.bindTexture(o.TEXTURE_2D,r)}setMagFilter(t,n){this.magFilters.get(t)!==n&&(this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,n),this.magFilters.set(t,n))}};function RW(e,t){switch(t){case"repeat":return[e.REPEAT,e.REPEAT];case"repeat-x":return[e.REPEAT,e.CLAMP_TO_EDGE];case"repeat-y":return[e.CLAMP_TO_EDGE,e.REPEAT];default:return[e.CLAMP_TO_EDGE,e.CLAMP_TO_EDGE]}}Pe();var Pi=256,KW=16,jW=1024;function $W(e,t="rgb"){let n=new Uint8ClampedArray(Pi*4);if(e.length===0)return n;let r=rx(e);for(let o=0;o<Pi;o++){let[i,s,a,l]=ox(r,o/(Pi-1),t);n[o*4]=i*255,n[o*4+1]=s*255,n[o*4+2]=a*255,n[o*4+3]=l*255}return n}function iN(e,t){return`${t}|${JSON.stringify(e)}`}var au=class{constructor(t){this.gl=t}gl;rowByKey=new Map;texture=null;rows=0;pixels=new Uint8ClampedArray(0);totalQueries=0;cacheHits=0;get height(){return this.rows}upload(t,n="rgb"){let r=iN(t,n);this.totalQueries++;let o=this.rowByKey.get(r);if(o!==void 0)return this.cacheHits++,this.rowByKey.delete(r),this.rowByKey.set(r,o),o;let i=this.claimRow();return this.writeRow(i,$W(t,n)),this.rowByKey.set(r,i),i}wouldReshape(t,n="rgb"){return this.rowByKey.size===0?!1:!this.rowByKey.has(iN(t,n))&&this.rowByKey.size>=this.rows}rowV(t){return(t+.5)/(this.rows||1)}bind(t){let n=this.gl;n.activeTexture(n.TEXTURE0+t),n.bindTexture(n.TEXTURE_2D,this.texture)}hitRate(){return this.totalQueries===0?0:this.cacheHits/this.totalQueries}resetStats(){this.totalQueries=0,this.cacheHits=0}free(){this.texture&&this.gl.deleteTexture(this.texture),this.texture=null,this.rows=0,this.pixels=new Uint8ClampedArray(0),this.rowByKey.clear()}claimRow(){if(this.rowByKey.size<this.rows)return this.rowByKey.size;if(this.rows<jW)return this.resize(this.rows===0?KW:this.rows*2),this.rowByKey.size;let[t,n]=this.rowByKey.entries().next().value;return this.rowByKey.delete(t),n}resize(t){let n=this.gl,r=new Uint8ClampedArray(Pi*t*4);if(r.set(this.pixels),this.pixels=r,this.rows=t,this.texture)n.bindTexture(n.TEXTURE_2D,this.texture);else{let o=n.createTexture();if(!o)throw new Error("GradientRampAtlas: createTexture failed");this.texture=o,n.bindTexture(n.TEXTURE_2D,o),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}n.texImage2D(n.TEXTURE_2D,0,n.RGBA,Pi,t,0,n.RGBA,n.UNSIGNED_BYTE,this.pixels),n.bindTexture(n.TEXTURE_2D,null)}writeRow(t,n){let r=this.gl;this.pixels.set(n,t*Pi*4),r.bindTexture(r.TEXTURE_2D,this.texture),r.texSubImage2D(r.TEXTURE_2D,0,0,t,Pi,1,r.RGBA,r.UNSIGNED_BYTE,n),r.bindTexture(r.TEXTURE_2D,null)}};Z();Z();function sN(e,t,n){for(let r=0;r<4;r++)for(let o=0;o<5;o++){let i=o===4?e[r*5+4]:0;for(let s=0;s<4;s++)i+=e[r*5+s]*t[s*5+o];n[r*5+o]=i}return n}function aN(e,t,n,r,o){return[ys(e[0]*t+e[1]*n+e[2]*r+e[3]*o+e[4]),ys(e[5]*t+e[6]*n+e[7]*r+e[8]*o+e[9]),ys(e[10]*t+e[11]*n+e[12]*r+e[13]*o+e[14]),ys(e[15]*t+e[16]*n+e[17]*r+e[18]*o+e[19])]}var Vt=new Float32Array([1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0]),Bf=class{transformStack=[q.identity()];alphaStack=[1];colorMatrixStack=[Vt];get transform(){return this.transformStack[this.transformStack.length-1]}get alpha(){return this.alphaStack[this.alphaStack.length-1]}get colorMatrix(){return this.colorMatrixStack[this.colorMatrixStack.length-1]}push(t){let n=this.transform,r=t.transform?q.multiply(n,t.transform):n,o=t.alpha!==void 0?this.alpha*t.alpha:this.alpha,i=t.colorMatrix?sN(this.colorMatrix,t.colorMatrix instanceof Float32Array?t.colorMatrix:new Float32Array(t.colorMatrix),new Float32Array(20)):this.colorMatrix;this.transformStack.push(r),this.alphaStack.push(o),this.colorMatrixStack.push(i)}pushIsolated(t){this.push(t);let n={alpha:this.alpha,colorMatrix:this.colorMatrix};this.pop();let r=this.transform;return this.transformStack.push(t.transform?q.multiply(r,t.transform):r),this.alphaStack.push(1),this.colorMatrixStack.push(Vt),n}reset(){this.transformStack.length=1,this.alphaStack.length=1,this.colorMatrixStack.length=1}pop(){if(this.transformStack.length<=1)throw new Error("GroupState.pop: cannot pop root frame");this.transformStack.pop(),this.alphaStack.pop(),this.colorMatrixStack.pop()}};Z();var lN=mt;function uN(e,t){if(typeof e=="number")return e;let n=e?.px??lN,[r,o,,i,s]=t,a=r*r+o*o+i*i+s*s,l=r*s-o*i,u=Math.sqrt((a+Math.sqrt(Math.max(0,a*a-4*l*l)))/2),c=n/u;return!(c>0)||!Number.isFinite(c)?mt:2**Math.floor(Math.log2(c))}function cN(e,t){return typeof e=="number"?e:{px:(e?.px??lN)/t}}Z();var cu=new Set,ix=!1;function Vf(e,t,n=2){let r=t&&t.length,o=r?t[0]*n:e.length;cu.size&&cu.clear();let i=hN(e,0,o,n,!0),s=[];if(!i||i.next===i.prev)return s;let a=0,l=0,u=0;if(r&&(i=QW(e,t,i,n)),e.length>80*n){a=e[0],l=e[1];let c=a,d=l;for(let f=n;f<o;f+=n){let p=e[f],h=e[f+1];p<a&&(a=p),h<l&&(l=h),p>c&&(c=p),h>d&&(d=h)}u=Math.max(c-a,d-l),u=u!==0?32767/u:0}return sx(i,s,a,l,u),s}function hN(e,t,n,r,o){let i=null;if(o===dV(e,t,n,r)>0)for(let s=t;s<n;s+=r)i=pN(s/r|0,e[s],e[s+1],i);else for(let s=n-r;s>=t;s-=r)i=pN(s/r|0,e[s],e[s+1],i);return i&&du(i,i.next)&&(pu(i),i=i.next),i}function Si(e,t=e){let n=t===e,r=e,o;do o=!1,r!==r.next&&(cu.size===0||!cu.has(r))&&(du(r,r.next)||Xe(r.prev,r,r.next)===0)?((n||r===t)&&(t=r.prev),ix=!0,pu(r),r=r.prev,o=!0):(n||r!==t)&&(r=r.next,o=!n);while(o||r!==t);return t}function sx(e,t,n,r,o){o&&iV(e,n,r,o);let i=e,s=!1;for(;e.prev!==e.next;){let a=e.prev,l=e.next;if(Xe(a,e,l)<0&&(o?qW(e,n,r,o):YW(e))){t.push(a.i,e.i,l.i),pu(e),e=l,i=l;continue}if(e=l,e===i){if(ix=!1,e=Si(e),ix){i=e;continue}if(!s){e=XW(e,t),i=e,s=!0;continue}JW(e,t,n,r,o);break}}}function YW(e){let t=e.prev,n=e,r=e.next,o=t.x,i=n.x,s=r.x,a=t.y,l=n.y,u=r.y,c=Math.min(o,i,s),d=Math.min(a,l,u),f=Math.max(o,i,s),p=Math.max(a,l,u),h=r.next;for(;h!==t;){if(h.x>=c&&h.x<=f&&h.y>=d&&h.y<=p&&!(o===h.x&&a===h.y)&&Wf(o,a,i,l,s,u,h.x,h.y)&&Xe(h.prev,h,h.next)>=0)return!1;h=h.next}return!0}function qW(e,t,n,r){let o=e.prev,i=e,s=e.next,a=o.x,l=i.x,u=s.x,c=o.y,d=i.y,f=s.y,p=Math.min(a,l,u),h=Math.min(c,d,f),m=Math.max(a,l,u),y=Math.max(c,d,f),b=cx(p,h,t,n,r),x=cx(m,y,t,n,r),w=e.prevZ;for(;w&&w.z>=b;){if(w.x>=p&&w.x<=m&&w.y>=h&&w.y<=y&&w!==s&&!(a===w.x&&c===w.y)&&Wf(a,c,l,d,u,f,w.x,w.y)&&Xe(w.prev,w,w.next)>=0)return!1;w=w.prevZ}let g=e.nextZ;for(;g&&g.z<=x;){if(g.x>=p&&g.x<=m&&g.y>=h&&g.y<=y&&g!==s&&!(a===g.x&&c===g.y)&&Wf(a,c,l,d,u,f,g.x,g.y)&&Xe(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function XW(e,t){let n=e,r=!1;do{let o=n.prev,i=n.next.next;gN(o,n,n.next,i,!1)&&fu(o,i)&&fu(i,o)&&(t.push(o.i,n.i,i.i),pu(n),pu(n.next),n=e=i,r=!0),n=n.next}while(n!==e);return r?Si(n):n}function JW(e,t,n,r,o){let i=e;do{let s=i.next.next;for(;s!==i.prev;){if(i.i!==s.i&&lV(i,s)){let a=bN(i,s);i=Si(i,i.next),a=Si(a,a.next),sx(i,t,n,r,o),sx(a,t,n,r,o);return}s=s.next}i=i.next}while(i!==e)}var ax=!1;function QW(e,t,n,r){let o=[];for(let i=0,s=t.length;i<s;i++){let a=t[i]*r,l=i<s-1?t[i+1]*r:e.length,u=hN(e,a,l,r,!1);u===u.next&&cu.add(u),o.push(aV(u))}o.sort(ZW),tV(e.length/r,t.length),yN(n,n),ax=!0;for(let i=0;i<o.length;i++)n=eV(o[i],n);return ax=!1,Si(n)}function ZW(e,t){return e.x-t.x||e.y-t.y||(e.next.y-e.y)/(e.next.x-e.x)-(t.next.y-t.y)/(t.next.x-t.x)}function eV(e,t){let n=rV(e,t);if(!n)return t;let r=bN(n,e),o=r.next;return yN(n,o.next),Si(r,r.next),Si(n,n.next)}var mN=16,We=new Float64Array(0),Uf=0,lx=[],ux=[];function tV(e,t){let n=Math.ceil((e+2*t)/mN)+t+2;We.length<n*4&&(We=new Float64Array(n*4)),Uf=0}function yN(e,t){let n=e;do{let r=Uf++;lx[r]=n;let o=n.x,i=n.y,s=n.x,a=n.y,l=0;do{let c=n.next;n.z=r,c.x<o&&(o=c.x),c.x>s&&(s=c.x),c.y<i&&(i=c.y),c.y>a&&(a=c.y),n=c}while(++l<mN&&n!==t);ux[r]=n;let u=r*4;We[u]=o,We[u+1]=i,We[u+2]=s,We[u+3]=a}while(n!==t)}function nV(e,t){let n=e.z*4;t.x<We[n]&&(We[n]=t.x),t.y<We[n+1]&&(We[n+1]=t.y),t.x>We[n+2]&&(We[n+2]=t.x),t.y>We[n+3]&&(We[n+3]=t.y)}function dN(e){let t=ux[e];for(;t.prev.next!==t;)t=t.next;return ux[e]=t,t}function fN(e){let t=lx[e];for(;t.prev.next!==t;)t=t.next;return lx[e]=t,t}function rV(e,t){let n=t,r=e.x,o=e.y,i=-1/0,s;if(du(e,n))return n;for(let f=0,p=0;f<Uf;f++,p+=4){if(o<We[p+1]||o>We[p+3]||We[p]>r||We[p+2]<=i)continue;let h=dN(f);n=fN(f);do{if(n.prev.next===n){if(du(e,n.next))return n.next;if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){let m=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(m<=r&&m>i&&(i=m,s=n.x<n.next.x?n:n.next,m===r))return s}}n=n.next}while(n!==h)}if(!s)return null;let a=s.x,l=s.y,u=Math.min(o,l),c=Math.max(o,l),d=1/0;for(let f=0,p=0;f<Uf;f++,p+=4){if(We[p+2]<a||We[p]>r||We[p+3]<u||We[p+1]>c)continue;let h=dN(f);n=fN(f);do{if(n.prev.next===n&&r>=n.x&&n.x>=a&&r!==n.x&&Wf(o<l?r:i,o,a,l,o<l?i:r,o,n.x,n.y)){let m=Math.abs(o-n.y)/(r-n.x);(fu(n,e)||n.y===o&&n.next.y===o&&n.next.x>r)&&(m<d||m===d&&(n.x>s.x||n.x===s.x&&oV(s,n)))&&(s=n,d=m)}n=n.next}while(n!==h)}return s}function oV(e,t){return Xe(e.prev,e,t.prev)<0&&Xe(t.next,e,e.next)<0}var zt=[],Hs=[],Ti=new Uint32Array(0),lu=new Uint32Array(0),uu=new Uint32Array(256);function iV(e,t,n,r){let o=e,i=0;do o.z=cx(o.x,o.y,t,n,r),zt[i++]=o,o=o.next;while(o!==e);sV(i);let s=null;for(let a=0;a<i;a++){let l=zt[a];l.prevZ=s,s&&(s.nextZ=l),s=l}s.nextZ=null,zt.fill(null,0,i),Hs.fill(null,0,i)}function sV(e){if(e<=32){for(let t=1;t<e;t++){let n=zt[t],r=n.z,o=t-1;for(;o>=0&&zt[o].z>r;)zt[o+1]=zt[o],o--;zt[o+1]=n}return}Ti.length<e&&(Ti=new Uint32Array(e),lu=new Uint32Array(e),Hs=new Array(e));for(let t=0;t<e;t++)Ti[t]=zt[t].z;Hf(e,zt,Ti,Hs,lu,0),Hf(e,Hs,lu,zt,Ti,8),Hf(e,zt,Ti,Hs,lu,16),Hf(e,Hs,lu,zt,Ti,24)}function Hf(e,t,n,r,o,i){uu.fill(0);for(let a=0;a<e;a++)uu[n[a]>>>i&255]++;let s=0;for(let a=0;a<256;a++){let l=uu[a];uu[a]=s,s+=l}for(let a=0;a<e;a++){let l=n[a],u=uu[l>>>i&255]++;r[u]=t[a],o[u]=l}}function cx(e,t,n,r,o){return e=(e-n)*o|0,t=(t-r)*o|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function aV(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function Wf(e,t,n,r,o,i,s,a){return(o-s)*(t-a)>=(e-s)*(i-a)&&(e-s)*(r-a)>=(n-s)*(t-a)&&(n-s)*(i-a)>=(o-s)*(r-a)}function lV(e,t){let n=du(e,t)&&Xe(e.prev,e,e.next)>0&&Xe(t.prev,t,t.next)>0;return e.next.i!==t.i&&(n||fu(e,t)&&fu(t,e)&&(Xe(e.prev,e,t.prev)!==0||Xe(e,t.prev,t)!==0))&&!uV(e,t)&&(n||cV(e,t))}function Xe(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function du(e,t){return e.x===t.x&&e.y===t.y}function gN(e,t,n,r,o=!0){let i=Xe(e,t,n),s=Xe(e,t,r),a=Xe(n,r,e),l=Xe(n,r,t);return(i>0&&s<0||i<0&&s>0)&&(a>0&&l<0||a<0&&l>0)?!0:o?!!(i===0&&Gf(e,n,t)||s===0&&Gf(e,r,t)||a===0&&Gf(n,e,r)||l===0&&Gf(n,t,r)):!1}function Gf(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function uV(e,t){let n=Math.min(e.x,t.x),r=Math.max(e.x,t.x),o=Math.min(e.y,t.y),i=Math.max(e.y,t.y),s=e;do{let a=s.next;if(s.x>r&&a.x>r||s.x<n&&a.x<n||s.y>i&&a.y>i||s.y<o&&a.y<o){s=a;continue}if(s.i!==e.i&&a.i!==e.i&&s.i!==t.i&&a.i!==t.i&&gN(s,a,e,t))return!0;s=a}while(s!==e);return!1}function fu(e,t){return Xe(e.prev,e,e.next)<0?Xe(e,t,e.next)>=0&&Xe(e,e.prev,t)>=0:Xe(e,t,e.prev)<0||Xe(e,e.next,t)<0}function cV(e,t){let n=e,r=!1,o=(e.x+t.x)/2,i=(e.y+t.y)/2;do{let s=n.next;n.y>i!=s.y>i&&o<(s.x-n.x)*(i-n.y)/(s.y-n.y)+n.x&&(r=!r),n=s}while(n!==e);return r}function bN(e,t){let n=dx(e.i,e.x,e.y),r=dx(t.i,t.x,t.y),o=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=o,o.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function pN(e,t,n,r){let o=dx(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o}function pu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ),ax&&nV(e.prev,e.next)}function dx(e,t,n){return{i:e,x:t,y:n,prev:null,next:null,z:0,prevZ:null,nextZ:null}}function dV(e,t,n,r){let o=0;for(let i=t,s=n-r;i<n;i+=r)o+=(e[s]-e[i])*(e[i+1]+e[s+1]),s=i;return o}Ye();Rt();rn();Rl();di();ci();var fx=new Uint8Array(new Uint16Array([1]).buffer)[0]===1?0:1,fV=2**-19;function px(e,t,n){let r=pV(e,t),o=new Uint32Array(r.buffer);for(let i=0;i<t;i++){let s=o[i*2+fx],a=s*4,l=e[a],u=e[a+1],c=e[a+2],d=e[a+3],f=Math.max(l,c),p=f+Math.abs(f)*fV+1e-300;for(let h=i+1;h<t&&!(r[h]>p);h++){let m=o[h*2+fx],y=m*4,b=e[y],x=e[y+1],w=e[y+2],g=e[y+3];if(Math.max(u,d)<Math.min(x,g)||Math.max(x,g)<Math.min(u,d))continue;let P=hV(l,u,c,d,b,x,w,g);if(P&&n(s,m,P[0],P[1]))return}}}function pV(e,t){let n=new Float64Array(t),r=new Uint32Array(n.buffer);for(let o=0;o<t;o++)n[o]=Math.min(e[o*4],e[o*4+2]),r[o*2+fx]=o;return n.sort()}function hV(e,t,n,r,o,i,s,a){let l=n-e,u=r-t,c=s-o,d=a-i,f=l*d-u*c;if(f===0)return null;let p=o-e,h=i-t,m=(p*d-h*c)/f,y=(p*u-h*l)/f,b=1e-9,x=1-1e-9;return m<=b||m>=x||y<=b||y>=x?null:[m,y]}var ki=e=>`${e.x},${e.y}`;function hx(e,t=!1){return!t&&!gV(e)?null:wN(e,n=>n!==0).contours}var mV=2**20;function xN(e){let t=yV(e),n=Math.floor((mV/t-t)/2);if(!(n>=0))return null;let r=wN(e,o=>(o&1)!==0,n);return r!==null&&r.complete?r.contours:null}function wN(e,t,n=1/0){let r=bV(e),o=PV(r);if(!xV(r,n))return null;wV(r,o),TV(r,o);let i=kV(r,t),{loops:s,complete:a}=AV(i);return{contours:NV(s),complete:a}}function yV(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=0;return n.forEach((i,s)=>{let a=s+1<n.length?n[s+1]:r;for(let l=i;l<a;l++){let u=l+1<a?l+1:i;(t[l*2]!==t[u*2]||t[l*2+1]!==t[u*2+1])&&o++}}),o}function gV(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=new Float64Array(r*4),i=0;n.forEach((a,l)=>{let u=l+1<n.length?n[l+1]:r;for(let c=a;c<u;c++){let d=c+1<u?c+1:a,f=t[c*2],p=t[c*2+1],h=t[d*2],m=t[d*2+1];f===h&&p===m||(o[i*4]=f,o[i*4+1]=p,o[i*4+2]=h,o[i*4+3]=m,i++)}});let s=!1;return px(o,i,()=>s=!0),s}function bV(e){let{coords:t,contourStarts:n,anchorA:r,anchorB:o,anchorT:i}=e,s=t.length/2,a=u=>({x:t[u*2],y:t[u*2+1],a:r[u],b:o[u],t:i[u]}),l=[];return n.forEach((u,c)=>{let d=c+1<n.length?n[c+1]:s;for(let f=u;f<d;f++){let p=a(f),h=a(f+1<d?f+1:u);(p.x!==h.x||p.y!==h.y)&&l.push({from:p,to:h,cuts:[]})}}),l}function xV(e,t){let n=new Float64Array(e.length*4);e.forEach(({from:o,to:i},s)=>n.set([o.x,o.y,i.x,i.y],s*4));let r=0;return px(n,e.length,(o,i,s,a)=>{if(++r>t)return!0;let l=e[o],u={x:l.from.x+(l.to.x-l.from.x)*s,y:l.from.y+(l.to.y-l.from.y)*s,...SV(l,s)};return l.cuts.push({s,node:u}),e[i].cuts.push({s:a,node:u}),!1}),r<=t}function wV(e,t){let n=e.map((o,i)=>i),r=o=>Math.min(o.from.x,o.to.x);n.sort((o,i)=>r(e[o])-r(e[i]));for(let o=0;o<n.length;o++){let i=e[n[o]],s=Math.max(i.from.x,i.to.x)+t;for(let a=o+1;a<n.length;a++){let l=e[n[a]];if(r(l)>s)break;Math.max(i.from.y,i.to.y)+t<Math.min(l.from.y,l.to.y)||Math.max(l.from.y,l.to.y)+t<Math.min(i.from.y,i.to.y)||(zf(i,l.from,t),zf(i,l.to,t),zf(l,i.from,t),zf(l,i.to,t))}}}function PV(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let{from:i}of e)t=Math.min(t,i.x),r=Math.max(r,i.x),n=Math.min(n,i.y),o=Math.max(o,i.y);return Math.max(r-t,o-n,Math.abs(t),Math.abs(r),Math.abs(n),Math.abs(o))*1e-9}function TV(e,t){let n=[];for(let r of e){n.push(r.from,r.to);for(let o of r.cuts)n.push(o.node)}n.sort((r,o)=>r.x-o.x);for(let r=0;r<n.length;r++){let o=n[r];for(let i=r+1;i<n.length&&n[i].x-o.x<=t;i++){let s=n[i];s!==o&&Math.abs(s.y-o.y)<=t&&(s.x!==o.x||s.y!==o.y)&&(s.x=o.x,s.y=o.y)}}}function zf(e,t,n){let r=e.to.x-e.from.x,o=e.to.y-e.from.y,i=r*r+o*o,s=((t.x-e.from.x)*r+(t.y-e.from.y)*o)/i;if(!(s>0&&s<1)||Math.hypot(e.from.x+r*s-t.x,e.from.y+o*s-t.y)>n)return;let a=l=>Math.abs(l.x-t.x)<=n&&Math.abs(l.y-t.y)<=n;a(e.from)||a(e.to)||e.cuts.some(l=>a(l.node))||e.cuts.push({s,node:t})}function SV(e,t){let{from:n,to:r}=e;if(n.a===r.a&&n.b===r.b)return{a:n.a,b:n.b,t:n.t+(r.t-n.t)*t};let o=t<.5?n:r;return{a:o.a,b:o.b,t:o.t}}function kV(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let{from:d}of e)n=Math.min(n,d.x),o=Math.max(o,d.x),r=Math.min(r,d.y),i=Math.max(i,d.y);let s=Math.max(Math.hypot(o-n,i-r)*1e-7,1e-9),a=(d,f)=>t(vV(e,d,f)),l=[],u=new Set,c=(d,f)=>{let p=`${ki(d)}>${ki(f)}`;u.has(p)||(u.add(p),l.push({from:d,to:f}))};for(let d of e){let f=[d.from,...d.cuts.sort((p,h)=>p.s-h.s).map(p=>p.node),d.to];for(let p=0;p+1<f.length;p++){let h=f[p],m=f[p+1],y=m.x-h.x,b=m.y-h.y,x=Math.hypot(y,b);if(x===0)continue;let w=(h.x+m.x)/2,g=(h.y+m.y)/2,P=-b/x*s,S=y/x*s,v=a(w+P,g+S),A=a(w-P,g-S);v&&!A?c(h,m):A&&!v&&c(m,h)}}return l}function vV(e,t,n){let r=0;for(let{from:o,to:i}of e){let s=(i.x-o.x)*(n-o.y)-(t-o.x)*(i.y-o.y);o.y<=n&&i.y>n&&s>0?r++:i.y<=n&&o.y>n&&s<0&&r--}return r}function AV(e){let t=new Map;for(let i of e){let s=ki(i.from),a=t.get(s);a?a.push(i):t.set(s,[i])}let n=new Set,r=[],o=!0;for(let i of e){if(n.has(i))continue;n.add(i);let s=[i.from],a=ki(i.from),l=i;for(;ki(l.to)!==a;){let u=RV(l,(t.get(ki(l.to))??[]).filter(c=>!n.has(c)));if(!u)break;n.add(u),s.push(u.from),l=u}ki(l.to)!==a?o=!1:s.length>=3&&r.push(s)}return{loops:r,complete:o}}function RV(e,t){let n=e.to.x-e.from.x,r=e.to.y-e.from.y,o,i=-1/0;for(let s of t){let a=s.to.x-s.from.x,l=s.to.y-s.from.y,u=Math.atan2(n*l-r*a,n*a+r*l);u>i&&(i=u,o=s)}return o}function NV(e){let t={coords:[],contourStarts:[],anchorA:[],anchorB:[],anchorT:[]};for(let n of e){t.contourStarts.push(t.coords.length/2);for(let r of n)t.coords.push(r.x,r.y),t.anchorA.push(r.a),t.anchorB.push(r.b),t.anchorT.push(r.t)}return t}Vl();ai();function vi(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=n.map((a,l)=>{let u=l+1<n.length?n[l+1]:r;return{start:a,end:u,area:xr(t,a,u),parent:-1,winding:0}}),i=o.map(a=>MV(t,a.start,a.end)),s=o.map((a,l)=>l).filter(a=>o[a].area!==0);s.sort((a,l)=>Math.abs(o[l].area)-Math.abs(o[a].area));for(let a=0;a<s.length;a++){let l=o[s[a]];for(let u=a-1;u>=0;u--){let c=s[u];if(IV(t,o[c],i[c],l)){l.parent=c;break}}l.winding=Math.sign(l.area)+(l.parent>=0?o[l.parent].winding:0)}return o}function IV(e,t,n,r){let o=Math.max(n[2]-n[0],n[3]-n[1])*1e-9;for(let i=r.start;i<r.end;i++){let s=e[i*2],a=e[i*2+1];if(s<n[0]||s>n[2]||a<n[1]||a>n[3])return!1;if(!EV(e,t,s,a,o))return Wn(e,s,a,t.start,t.end)}return!1}function EV(e,t,n,r,o){for(let i=t.start;i<t.end;i++){let s=i+1===t.end?t.start:i+1,a=e[i*2],l=e[i*2+1];if(Tn(n,r,a,l,e[s*2],e[s*2+1])<=o)return!0}return!1}function MV(e,t,n){let r=1/0,o=1/0,i=-1/0,s=-1/0;for(let a=t;a<n;a++){let l=e[a*2],u=e[a*2+1];r=Math.min(r,l),i=Math.max(i,l),o=Math.min(o,u),s=Math.max(s,u)}return[r,o,i,s]}ai();function TN(e){if(OV(e))return null;let t=vi(e);if(t.some(n=>n.area===0))return null;for(let n of t){let r=0;for(let o=n.parent;o>=0;o=t[o].parent)r++;n.winding=r%2===0?1:0}return t}function CV(e){let{coords:t,contourStarts:n}=e,r=t.length/2,o=new Float64Array(r*4),i=new Uint32Array(r),s=new Uint32Array(r),a=[],l=0;return n.forEach((u,c)=>{let d=c+1<n.length?n[c+1]:r,f=0;for(let p=u;p<d;p++){let h=p+1<d?p+1:u,m=t[p*2],y=t[p*2+1],b=t[h*2],x=t[h*2+1];m===b&&y===x||(o.set([m,y,b,x],l*4),i[l]=c,s[l]=f++,l++)}a.push(f)}),{ends:o,contour:i,pos:s,count:a,n:l}}function OV(e){let t=CV(e),{ends:n,n:r}=t,o=1/0,i=1/0,s=-1/0,a=-1/0;for(let d=0;d<r*4;d+=2)o=Math.min(o,n[d]),s=Math.max(s,n[d]),i=Math.min(i,n[d+1]),a=Math.max(a,n[d+1]);let l=Math.max(s-o,a-i,Math.abs(o),Math.abs(s),Math.abs(i),Math.abs(a))*1e-9,u=Array.from({length:r},(d,f)=>f),c=d=>Math.min(n[d*4],n[d*4+2]);u.sort((d,f)=>c(d)-c(f));for(let d=0;d<r;d++){let f=u[d],p=Math.max(n[f*4],n[f*4+2])+l;for(let h=d+1;h<r;h++){let m=u[h];if(c(m)>p)break;if(FV(t,f,m,l))return!0}}return!1}function FV(e,t,n,r){let{ends:o}=e,i=o[t*4],s=o[t*4+1],a=o[t*4+2],l=o[t*4+3],u=o[n*4],c=o[n*4+1],d=o[n*4+2],f=o[n*4+3];if(Math.max(s,l)+r<Math.min(c,f)||Math.max(c,f)+r<Math.min(s,l))return!1;let p=LV(e,t,n);return p==="e-to"?PN(a-i,l-s,d-u,f-c)||Gs(i,s,u,c,d,f,r):p==="f-to"?PN(d-u,f-c,a-i,l-s)||Gs(u,c,i,s,a,l,r):Gs(i,s,u,c,d,f,r)||Gs(a,l,u,c,d,f,r)||Gs(u,c,i,s,a,l,r)||Gs(d,f,i,s,a,l,r)||_V(i,s,a,l,u,c,d,f)}function LV(e,t,n){if(e.contour[t]!==e.contour[n])return null;let r=e.count[e.contour[t]];return r<3?null:(e.pos[t]+1)%r===e.pos[n]?"e-to":(e.pos[n]+1)%r===e.pos[t]?"f-to":null}function PN(e,t,n,r){let o=e*r-t*n;return Math.abs(o)<=1e-9*Math.hypot(e,t)*Math.hypot(n,r)&&e*n+t*r<0}function Gs(e,t,n,r,o,i,s){return Tn(e,t,n,r,o,i)<=s}function _V(e,t,n,r,o,i,s,a){let l=Kf(e,t,n,r,o,i),u=Kf(e,t,n,r,s,a),c=Kf(o,i,s,a,e,t),d=Kf(o,i,s,a,n,r);return l*u<=0&&c*d<=0}var Kf=(e,t,n,r,o,i)=>Math.sign((n-e)*(i-t)-(r-t)*(o-e));function mu(e,t={}){if(e.kind==="rect")return DV(e);let n=GV(ze(e),t);return e.origin?{...n,origin:e.origin}:n}function DV(e){let t=Al(e.x,e.y,e.width,e.height),n=Sn(t);return{vertices:At(n,t),indices:new Uint32Array([0,1,2,0,2,3]),anchorA:new Uint32Array([0,1,2,3]),anchorB:new Uint32Array([0,1,2,3]),anchorT:new Float32Array([0,0,0,0]),...n?{origin:n}:{}}}function BV(e,t){let n=new Set,r=HV(e,t,n);if(kn(e))return r;let o={coords:[],contourStarts:[],anchorA:[],anchorB:[],anchorT:[]};return r.contourStarts.forEach((i,s)=>{if(!n.has(s))return;let a=s+1<r.contourStarts.length?r.contourStarts[s+1]:r.coords.length/2;o.contourStarts.push(o.coords.length/2),o.coords.push(...r.coords.slice(i*2,a*2)),o.anchorA.push(...r.anchorA.slice(i,a)),o.anchorB.push(...r.anchorB.slice(i,a)),o.anchorT.push(...r.anchorT.slice(i,a))}),o}function HV(e,t,n){let{commands:r,coords:o}=e,i=[],s=[],a=[],l=[],u=[],c=-1,d=-1,f=0,p=(h,m,y,b)=>{for(let w=0;w<m.length;w++)s.push(d),a.push(b),l.push(y>0?m[w]/y:0);let x=h+m.length-1;s[x]=b,a[x]=b,l[x]=0};return Oe(r,o,(h,m,y,b,x,w)=>{if(w){let g=Math.max(c,0);u.push(i.length/2),i.push(y,b),s.push(g),a.push(g),l.push(0),d=g}switch(h){case se:case ae:{h===se&&(u.push(i.length/2),c=f),i.push(o[m],o[m+1]),s.push(f),a.push(f),l.push(0),d=f,f++;break}case we:{let g=f,P=[],S=s.length,v=Ul(y,b,o[m],o[m+1],o[m+2],o[m+3],t,i,P);p(S,P,v,g),d=g,f++;break}case be:{let g=f,P=[],S=s.length,v=Gl(y,b,o[m],o[m+1],o[m+2],o[m+3],o[m+4],o[m+5],t,i,P);p(S,P,v,g),d=g,f++;break}case fe:n.add(u.length-1),d=c;break;default:throw new Error(`tessellate: unknown command code ${h}`)}}),{coords:i,contourStarts:u,anchorA:s,anchorB:a,anchorT:l}}function GV(e,t){let n=t.flattenTolerance??mt,r=BV(e,n);if(e.fillRule==="evenodd"){let a=TN(r);if(a)return hu(r,a);let l=xN(r);if(l)return hu(l,vi(l));let{coords:u,contourStarts:c,anchorA:d,anchorB:f,anchorT:p}=r;return UV(u,c,d,f,p)}let o=hx(r);if(o)return hu(o,vi(o));let i=vi(r);if(i.every(a=>Math.abs(a.winding)<=1))return hu(r,i);let s=hx(r,!0);return hu(s,vi(s))}function hu(e,t){let{coords:n,contourStarts:r,anchorA:o,anchorB:i,anchorT:s}=e,a=[],l=new Map;if(t.forEach((h,m)=>{h.area!==0&&(h.winding!==0?a.push(m):l.has(h.parent)?l.get(h.parent).push(m):l.set(h.parent,[m]))}),a.length<=1&&(a[0]??0)===0){let h=Vf(n,r.length>1?r.slice(1):void 0);return{vertices:new Float32Array(n),indices:new Uint32Array(h),anchorA:new Uint32Array(o),anchorB:new Uint32Array(i),anchorT:new Float32Array(s)}}let u=[],c=[],d=[],f=[],p=[];for(let h of a){let m=l.get(h)??[],y=u.length/2,b=[],x=[0];for(let g=t[h].start;g<t[h].end;g++)b.push(n[g*2],n[g*2+1]),c.push(o[g]),d.push(i[g]),f.push(s[g]);for(let g of m){x.push(b.length/2);for(let P=t[g].start;P<t[g].end;P++)b.push(n[P*2],n[P*2+1]),c.push(o[P]),d.push(i[P]),f.push(s[P])}let w=Vf(b,x.length>1?x.slice(1):void 0);for(let g of b)u.push(g);for(let g of w)p.push(g+y)}return{vertices:new Float32Array(u),indices:new Uint32Array(p),anchorA:new Uint32Array(c),anchorB:new Uint32Array(d),anchorT:new Float32Array(f)}}function UV(e,t,n,r,o){let i=[],s=e.length/2;for(let a=0;a<t.length;a++){let l=t[a],u=a+1<t.length?t[a+1]:s;for(let c=l+1;c<u-1;c++)i.push(l,c,c+1)}return{vertices:new Float32Array(e),indices:new Uint32Array(i),requiresStencil:!0,anchorA:new Uint32Array(n),anchorB:new Uint32Array(r),anchorT:new Float32Array(o)}}Yg();function yu(e,t,n,r,o,i,s){return e===r&&t===o?[e,t,n+(i-n)*s]:s<.5?[e,t,n]:[r,o,i]}var vN=1e-9;function SN(e,t,n,r,o,i,s,a,l){let u=t.length,c=1;for(;c<u-1&&(l?t[c]<=a:t[c]<a);)c++;let d=t[c-1],f=t[c]-d,p=f>vN?(a-d)/f:0,h=e.points[(c-1)*2],m=e.points[(c-1)*2+1],y=e.points[c*2],b=e.points[c*2+1],[x,w,g]=yu(n[c-1],r[c-1],o[c-1],n[c],r[c],o[c],p),P=i?i[c-1]+(i[c]-i[c-1])*p:0,S=s?s[c-1]+(s[c]-s[c-1])*p:0;return{x:h+(y-h)*p,y:m+(b-m)*p,a:x,b:w,t:g,w:P,o:S,next:c}}var WV=4*2**-23;function kN(e,t,n){let r=e.points[n*2],o=e.points[n*2+1];return Math.hypot(t.x-r,t.y-o)<=WV*Math.max(1,Math.abs(r),Math.abs(o))}function Us(e,t,n){let r=Math.max(0,t),o=Math.max(0,n);if(r<=0&&o<=0||e.closed)return e;let i=e.points.length/2;if(i<2)return null;let s=e.anchorA??new Uint32Array(i),a=e.anchorB??new Uint32Array(i),l=e.anchorT??new Float32Array(i),u=e.widths,c=e.offsets,d=new Float64Array(i);for(let C=1;C<i;C++){let F=e.points[C*2]-e.points[(C-1)*2],D=e.points[C*2+1]-e.points[(C-1)*2+1];d[C]=d[C-1]+Math.hypot(F,D)}let f=d[i-1],p=r,h=f-o;if(h-p<=vN)return null;let m=SN(e,d,s,a,l,u,c,p,!0),y=SN(e,d,s,a,l,u,c,h,!1),b=y.next-m.next,x=b>0&&kN(e,m,m.next),w=b>0&&kN(e,y,y.next-1)&&b+(x?0:1)>=2,g=[],P=[],S=[],v=[],A=u?[]:void 0,N=c?[]:void 0,M=C=>{g.push(C.x,C.y),P.push(C.a),S.push(C.b),v.push(C.t),A&&A.push(C.w),N&&N.push(C.o)};x||M(m);for(let C=m.next;C<y.next;C++)g.push(e.points[C*2],e.points[C*2+1]),P.push(s[C]),S.push(a[C]),v.push(l[C]),A&&A.push(u[C]),N&&N.push(c[C]);return w||M(y),{points:g,closed:!1,anchorA:new Uint32Array(P),anchorB:new Uint32Array(S),anchorT:new Float32Array(v),...A?{widths:new Float32Array(A)}:{},...N?{offsets:new Float32Array(N)}:{}}}Ov();var VV=4,AN=new WeakMap;function RN(e,t=mt){let n=Jg(),r=AN.get(e);r===void 0&&AN.set(e,r=new Map);let o=r.get(t);if(o!==void 0&&o.openFill===n)return o.mesh;let i=mu(e,{flattenTolerance:t});return o===void 0&&r.size>=VV&&r.clear(),r.set(t,{mesh:i,openFill:n}),i}var zV={"source-over":{source:"one",destination:"one-minus-source-alpha"},"source-in":{source:"destination-alpha",destination:"zero"},"source-out":{source:"one-minus-destination-alpha",destination:"zero"},"source-atop":{source:"destination-alpha",destination:"one-minus-source-alpha"},"destination-over":{source:"one-minus-destination-alpha",destination:"one"},"destination-in":{source:"zero",destination:"source-alpha"},"destination-out":{source:"zero",destination:"one-minus-source-alpha"},"destination-atop":{source:"one-minus-destination-alpha",destination:"source-alpha"},xor:{source:"one-minus-destination-alpha",destination:"one-minus-source-alpha"},lighter:{source:"one",destination:"one"},copy:{source:"one",destination:"zero"}};function mx(e){return typeof e=="string"?zV[e]:e}function Yn(e){if(e===void 0)return!1;let{source:t,destination:n}=mx(e);return t!=="one"||n!=="one-minus-source-alpha"}function EN(e){let{destination:t}=mx(e);return t==="one"||t==="one-minus-source-alpha"}var NN=new WeakMap;function yx(e){let t=NN.get(e);if(t!==void 0)return t;let n=e.some(r=>r.kind==="group"&&(Yn(r.composite)||yx(r.children)));return NN.set(e,n),n}function IN(e,t){switch(t){case"zero":return e.ZERO;case"one":return e.ONE;case"source-alpha":return e.SRC_ALPHA;case"one-minus-source-alpha":return e.ONE_MINUS_SRC_ALPHA;case"destination-alpha":return e.DST_ALPHA;case"one-minus-destination-alpha":return e.ONE_MINUS_DST_ALPHA}}function gx(e,t){let{source:n,destination:r}=mx(t);e.blendFunc(IN(e,n),IN(e,r))}Z();function Be(e,t,n){e.gl.drawElements(e.gl.TRIANGLES,t,n,0),e.stats&&e.stats.drawCalls++}function wt(e,t=e.clipDepth){let n=e.gl;if(t===0){n.disable(n.STENCIL_TEST);return}let r=Ai(t);n.enable(n.STENCIL_TEST),n.stencilFunc(n.EQUAL,r,r),n.stencilOp(n.KEEP,n.KEEP,n.KEEP)}function Ai(e){return e===0?0:(1<<e+1)-1&254}function bx(e,t){let n=e.gl;n.enable(n.STENCIL_TEST),n.colorMask(!1,!1,!1,!1),n.stencilMask(1),n.stencilFunc(n.ALWAYS,0,1),n.stencilOp(n.KEEP,n.KEEP,n.INVERT),Be(e,t,e.gl.UNSIGNED_INT);let r=Ai(e.clipDepth);n.colorMask(!0,!0,!0,!0),n.stencilFunc(n.EQUAL,r|1,r|1),n.stencilOp(n.KEEP,n.KEEP,n.INVERT)}function xx(e){let t=e.gl;t.stencilMask(1),t.clear(t.STENCIL_BUFFER_BIT),t.disable(t.STENCIL_TEST)}Z();Pe();var MN=new WeakMap,CN=new WeakMap;function Yf(e,t){let n=MN.get(e);n||(n=new WeakMap,MN.set(e,n));let r=n.get(t);return r||(r={},n.set(t,r)),r}function kr(e,t){if(e===void 0||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function wx(e,t,n,r,o,i){let s=t.uniform("u_color");if(s===void 0)return;let a=Yf(e,t),l=a.color;l!==void 0&&l[0]===n&&l[1]===r&&l[2]===o&&l[3]===i||(e.gl.uniform4f(s,n,r,o,i),a.color=[n,r,o,i])}function qf(e,t,n){let r=t.uniform("u_alpha");if(r===void 0)return;let o=Yf(e,t);o.alpha!==n&&(e.gl.uniform1f(r,n),o.alpha=n)}function gu(e){if(e.projection)return e.projection;let t=CN.get(e);return t||(t=q.toUniform(q.screenToClip(e.widthCss,e.heightCss)),CN.set(e,t)),t}var jf=new Float32Array(16);function Rn(e,t,n=e.state.colorMatrix){let r=e.gl,o=Yf(e,t),i=t.uniform("u_colorMatrix");if(i!==void 0){for(let a=0;a<4;a++)for(let l=0;l<4;l++)jf[l*4+a]=n[a*5+l];kr(o.colorMatrix,jf)||(r.uniformMatrix4fv(i,!1,jf),o.colorMatrix=Float32Array.from(jf))}let s=t.uniform("u_colorBias");if(s!==void 0){let a=[n[4],n[9],n[14],n[19]];kr(o.colorBias,a)||(r.uniform4f(s,a[0],a[1],a[2],a[3]),o.colorBias=Float32Array.from(a))}}var ON=65536;function Xf(e){let t=e.meshOrigin;return t?q.translated(e.state.transform,t.x,t.y):e.state.transform}function Jf(e,t,n){let r=e.meshOrigin;if(t===r)return n();e.meshOrigin=t;try{return n()}finally{e.meshOrigin=r}}var Ws=new Float32Array(9),$f=new Float32Array(9);function nt(e,t,n=Xf(e),r=gu(e)){let o=e.gl,i=Yf(e,t);$f.set(r),kr(i.proj,$f)||(o.uniformMatrix3fv(t.uniform("u_proj"),!1,$f),i.proj=Float32Array.from($f)),Ws.set(n);let s=t.uniform("u_origin");if(s!==void 0){let a=0,l=0,u=n[6],c=n[7];if(Math.abs(u)>=ON||Math.abs(c)>=ON){let d=n[0],f=n[1],p=n[3],h=n[4],m=d*h-f*p,y=Math.fround((p*c-h*u)/m),b=Math.fround((f*u-d*c)/m);Number.isFinite(y)&&Number.isFinite(b)&&(a=y,l=b,Ws[6]=d*a+p*l+u,Ws[7]=f*a+h*l+c)}(i.originX!==a||i.originY!==l)&&(o.uniform2f(s,a,l),i.originX=a,i.originY=l)}kr(i.model,Ws)||(o.uniformMatrix3fv(t.uniform("u_model"),!1,Ws),i.model=Float32Array.from(Ws))}function Vs(e,t,n,r){let[o,i,s,a]=$n(n);wx(e,t,o,i,s,a*(r??1)),qf(e,t,e.state.alpha)}var FN=new Set;function _N(e,t){FN.has(e)||(FN.add(e),en()&&console.warn(t))}function Px(e,t){_N(`${e}:${t}`,`weasel drawShader: uniform "${t}" not found in program "${e}". Check spelling, ensure it's used in the shader (unused uniforms are optimized away by the driver).`)}function KV(e,t,n,r,o){if(n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Float32Array)&&"id"in n&&typeof n.id=="string"){let i=n,s=_s(i.id);if(!s){en()&&console.warn(`weasel setUniform: TextureHandle "${i.id}" not registered`);return}let a=o.value++;e.activeTexture(e.TEXTURE0+a),r.uploadRegistered(i.id,s.source),r.bind(i.id,a),e.uniform1i(t,a);return}if(n instanceof Float64Array&&(n=Float32Array.from(n)),n instanceof Float32Array){if(n.length===9)e.uniformMatrix3fv(t,!1,n);else if(n.length===16)e.uniformMatrix4fv(t,!1,n);else if(en())throw new TypeError(`weasel setUniform: Float32Array must be length 9 (mat3) or 16 (mat4), got ${n.length}`);return}if(Array.isArray(n)){let i=n;switch(i.length){case 2:e.uniform2fv(t,i);break;case 3:e.uniform3fv(t,i);break;case 4:e.uniform4fv(t,i);break;default:if(en())throw new TypeError(`weasel setUniform: array length ${i.length} not supported`)}return}if(typeof n=="number"){e.uniform1f(t,n);return}}var jV={float:{fn:"uniform1fv",n:1},vec2:{fn:"uniform2fv",n:2},vec3:{fn:"uniform3fv",n:3},vec4:{fn:"uniform4fv",n:4},int:{fn:"uniform1iv",n:1},ivec2:{fn:"uniform2iv",n:2},ivec3:{fn:"uniform3iv",n:3},ivec4:{fn:"uniform4iv",n:4},bool:{fn:"uniform1iv",n:1},bvec2:{fn:"uniform2iv",n:2},bvec3:{fn:"uniform3iv",n:3},bvec4:{fn:"uniform4iv",n:4},uint:{fn:"uniform1uiv",n:1},uvec2:{fn:"uniform2uiv",n:2},uvec3:{fn:"uniform3uiv",n:3},uvec4:{fn:"uniform4uiv",n:4},mat2:{fn:"uniformMatrix2fv",n:4,matrix:!0},mat3:{fn:"uniformMatrix3fv",n:9,matrix:!0},mat4:{fn:"uniformMatrix4fv",n:16,matrix:!0},mat2x2:{fn:"uniformMatrix2fv",n:4,matrix:!0},mat3x3:{fn:"uniformMatrix3fv",n:9,matrix:!0},mat4x4:{fn:"uniformMatrix4fv",n:16,matrix:!0},mat2x3:{fn:"uniformMatrix2x3fv",n:6,matrix:!0},mat2x4:{fn:"uniformMatrix2x4fv",n:8,matrix:!0},mat3x2:{fn:"uniformMatrix3x2fv",n:6,matrix:!0},mat3x4:{fn:"uniformMatrix3x4fv",n:12,matrix:!0},mat4x2:{fn:"uniformMatrix4x2fv",n:8,matrix:!0},mat4x3:{fn:"uniformMatrix4x3fv",n:12,matrix:!0}};function $V(e){return Array.isArray(e)||e instanceof Float32Array||e instanceof Int32Array||e instanceof Uint32Array}function YV(e,t,n,r){let o=jV[n.type];if(!o){en()&&console.warn(`weasel setUniform: array uniform "${t}" has type ${n.type}, which cannot be written as a whole`);return}if(r.length%o.n!==0||r.length>o.n*n.size){if(en())throw new TypeError(`weasel setUniform: "${t}" is ${n.type}[${n.size}], so its value must hold a multiple of ${o.n} numbers, at most ${o.n*n.size}; got ${r.length}`);return}if(r.length===0)return;let i=e[o.fn];o.matrix?i.call(e,n.location,!1,r):i.call(e,n.location,r)}function Tx(e,t,n,r,o,i){for(let[s,a]of Object.entries(r)){let l=t.uniformArray(s);if(l&&$V(a)){YV(e,s,l,a);continue}let u=t.uniform(s);if(u===void 0){Px(n,s);continue}KV(e,u,a,o,i)}}function DN(e,t){let{gl:n,programRegistry:r,quadVbo:o,quadIbo:i,textureCache:s}=e,a=e.ensureProgram?.(t.program.id)??r.get(t.program.id);if(!a){_N(`${t.program.id}:(program)`,`weasel drawShader: program "${t.program.id}" has no compiled program on this renderer. Register its source with the module-level registerProgram() first; a source that failed to compile is reported above.`);return}if(!o||!i){console.warn("weasel drawShader: quad geometry not initialized");return}n.useProgram(a.handle);let l=a.attribute("a_position"),u=a.attribute("a_uv");n.bindBuffer(n.ARRAY_BUFFER,o),l!==void 0&&(n.enableVertexAttribArray(l),n.vertexAttribPointer(l,2,n.FLOAT,!1,16,0)),u!==void 0&&(n.enableVertexAttribArray(u),n.vertexAttribPointer(u,2,n.FLOAT,!1,16,8)),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,i);let c=a.uniform("u_proj");c!==void 0&&n.uniformMatrix3fv(c,!1,q.toUniform(gu(e)));let d=a.uniform("u_bounds");d!==void 0&&n.uniform4f(d,t.bounds.x,t.bounds.y,t.bounds.w,t.bounds.h);let f=a.uniform("u_fragOrigin");if(f!==void 0){let[h,m]=(e.renderTarget?e.renderTarget.fragOrigin:e.fragOrigin)??[0,0];n.uniform2f(f,h,m)}let p=a.uniform("u_view");p!==void 0&&n.uniformMatrix3fv(p,!1,q.toUniform(e.state.transform)),qV(n,a,e.state.transform,t.bounds),Tx(n,a,t.program.id,t.uniforms,s,{value:1}),wt(e),Be(e,6,e.gl.UNSIGNED_SHORT),l!==void 0&&n.disableVertexAttribArray(l),u!==void 0&&n.disableVertexAttribArray(u),n.bindBuffer(n.ARRAY_BUFFER,null),n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,null)}function qV(e,t,n,r){let o=t.uniform("u_screenToLocal"),i=t.uniform("u_worldOrigin");if(o===void 0&&i===void 0)return;let s=q.invert(n),a=0,l=0,u=q.scaled(q.identity(),0,0);if(s){let c=s[0]*r.x+s[3]*r.y+s[6],d=s[1]*r.x+s[4]*r.y+s[7];(Math.abs(c)>=LN||Math.abs(d)>=LN)&&(a=Math.fround(c),l=Math.fround(d)),u=q.multiply(q.translated(q.identity(),-a,-l),s)}o!==void 0&&e.uniformMatrix3fv(o,!1,q.toUniform(u)),i!==void 0&&e.uniform2f(i,a,l)}var LN=8192;Z();Z();function HN(e,t){if(e.kind!=="rect"||!(t[1]===0&&t[3]===0||t[0]===0&&t[4]===0))return null;let r=t[0]*e.x+t[3]*e.y+t[6],o=t[1]*e.x+t[4]*e.y+t[7],i=e.x+e.width,s=e.y+e.height,a=t[0]*i+t[3]*s+t[6],l=t[1]*i+t[4]*s+t[7];return{x0:Math.min(r,a),y0:Math.min(o,l),x1:Math.max(r,a),y1:Math.max(o,l)}}function GN(e,t){return{x0:Math.max(e.x0,t.x0),y0:Math.max(e.y0,t.y0),x1:Math.min(e.x1,t.x1),y1:Math.min(e.y1,t.y1)}}var UN=16,XV=8,JV=new Float64Array(0);function WN(e,t,n){if(e===null&&t.length===0)return null;let r=JV;if(t.length===1)r=t[0];else if(t.length>1){r=new Float64Array(t.reduce((i,s)=>i+s.length,0));let o=0;for(let i of t)r.set(i,o),o+=i.length}return{rect:e,planes:r,slanted:n}}var BN=new WeakMap;function VN(e,t){let n=BN.get(e);if(n!==void 0&&n.m[0]===t[0]&&n.m[1]===t[1]&&n.m[2]===t[3]&&n.m[3]===t[4]&&n.m[4]===t[6]&&n.m[5]===t[7])return n.planes;let r=QV(e,t);return BN.set(e,{m:Float64Array.of(t[0],t[1],t[3],t[4],t[6],t[7]),planes:r}),r}function QV(e,t){let n=Ib(e);if(n===null)return null;let r=[];for(let o=0;o<n.length;o+=2)r.push(t[0]*n[o]+t[3]*n[o+1]+t[6],t[1]*n[o]+t[4]*n[o+1]+t[7]);return kx(r,XV)}function kx(e,t){let n=[];for(let s=0;s<e.length;s+=2){let a=n.length;a>=2&&n[a-2]===e[s]&&n[a-1]===e[s+1]||n.push(e[s],e[s+1])}for(;n.length>=4&&n[0]===n[n.length-2]&&n[1]===n[n.length-1];)n.length-=2;if(n.length<6)return null;xr(n)<0&&Eb(n);let r=Mb(n);if(r.length<6||r.length/2>t||!Cb(r))return null;let o=r.length/2,i=new Float64Array(o*3);for(let s=0;s<o;s++){let a=r[s*2],l=r[s*2+1],u=r[(s+1)%o*2],c=r[(s+1)%o*2+1],d=Math.hypot(u-a,c-l),f=-(c-l)/d,p=(u-a)/d;i[s*3]=f,i[s*3+1]=p,i[s*3+2]=-(f*a+p*l)}return i}function vr(e,t,n){let r=e.rect;if(r!==null&&(t<r.x0||t>r.x1||n<r.y0||n>r.y1))return!1;let o=e.planes;for(let i=0;i<o.length;i+=3)if(o[i]*t+o[i+1]*n+o[i+2]<0)return!1;return!0}function Qf(e,t,n,r,o){let i=e.rect;if(i!==null){let a=!0,l=!0,u=!0,c=!0;for(let d=0,f=n;d<r;d++,f+=o){let p=t[f],h=t[f+1];a&&=p<=i.x0,l&&=p>=i.x1,u&&=h<=i.y0,c&&=h>=i.y1}if(a||l||u||c)return!0}let s=e.planes;for(let a=0;a<s.length;a+=3){let l=!0;for(let u=0,c=n;u<r&&l;u++,c+=o)l=s[a]*t[c]+s[a+1]*t[c+1]+s[a+2]<=0;if(l)return!0}return!1}function vx(e,t,n,r,o,i){let s=r.rect,a=r.planes,l=s===null?0:4,u=l+a.length/3;if(u===0)return o.set(e.subarray(0,t*n)),t;let c=e,d=u%2===0?i:o,f=t;for(let p=0;p<u;p++){if(p<l){let h=p<2?0:1,m=p===0?s.x0:p===1?s.x1:p===2?s.y0:s.y1;f=ZV(c,f,n,h,m,p%2===0?1:-1,d)}else{let h=(p-l)*3;f=bu(c,f,n,a[h],a[h+1],a[h+2],d)}c=d,d=d===o?i:o}return f}function ZV(e,t,n,r,o,i,s){if(t===0)return 0;let a=0,l=t-1,u=i*(e[l*n+r]-o)>=0;for(let c=0;c<t;c++){let d=i*(e[c*n+r]-o)>=0;if(d!==u){let[f,p]=zN(e,l*n,c*n),h=(o-e[f+r])/(e[p+r]-e[f+r]);KN(e,f,p,h,n,s,a*n),s[a*n+r]=o,a++}d&&(s.set(e.subarray(c*n,c*n+n),a*n),a++),l=c,u=d}return a}function bu(e,t,n,r,o,i,s){if(t===0)return 0;let a=0,l=t-1,u=r*e[l*n]+o*e[l*n+1]+i>=0;for(let c=0;c<t;c++){let d=c*n,f=r*e[d]+o*e[d+1]+i>=0;if(f!==u){let[p,h]=zN(e,l*n,d),m=r*e[p]+o*e[p+1]+i,y=r*e[h]+o*e[h+1]+i;KN(e,p,h,m/(m-y),n,s,a*n),a++}f&&(s.set(e.subarray(c*n,c*n+n),a*n),a++),l=c,u=f}return a}var Sx=[0,0];function zN(e,t,n){let r=e[n]<e[t]||e[n]===e[t]&&e[n+1]<e[t+1];return Sx[0]=r?n:t,Sx[1]=r?t:n,Sx}function KN(e,t,n,r,o,i,s){for(let a=0;a<o;a++)i[s+a]=e[t+a]+r*(e[n+a]-e[t+a])}function zs(e){return uN(e.flattenTolerance,e.state.transform)}function Zf(e,t){return RN(t,zs(e))}function Ax(e,t){return e.meshCache.handleFor(t)}function xu(e,t){return Ax(e,Zf(e,t))}Z();function ep(e){return e===Vt||kr(Vt,e)}var wu={enabled:!0};function Pu(e){return wu.enabled||ep(e.state.colorMatrix)}function Rx(e,t,n,r,o){let i=e.state.colorMatrix,s=e.state.alpha;if(ep(i))return[t,n,r,o*s];if(!wu.enabled)return[t,n,r,o];let a=aN(i,t,n,r,o);return a[3]*=s,a}function tp(e,t,n,r,o,i){return ep(e.state.colorMatrix)?(i[0]=t,i[1]=n,i[2]=r,i[3]=o*e.state.alpha,i):Rx(e,t,n,r,o)}var jN=[1,1,1,1],ez=[0,6,12,18];function tz(e){let t=e.state.colorMatrix,n=e.state.alpha;if(ep(t))return n===1?jN:[1,1,1,n];if(!wu.enabled)return null;for(let r=0;r<20;r++){let o=t[r];if(ez.includes(r)?o<0||o>1:o!==0)return null}return[t[0],t[6],t[12],t[18]*n]}function Ks(e,t){let n=tz(e);if(n!==null)return{colorMatrix:Vt,alpha:1,tint:n,slot:0};let r=e.state.colorMatrix,o=e.state.alpha;return t?{colorMatrix:r,alpha:o,tint:jN,slot:0}:{colorMatrix:r,alpha:1,tint:[1,1,1,o],slot:0}}function Nx(e,t,n){for(let r=0;r<e.length;r++){let o=e[r];if(o.alpha===n&&(o.colorMatrix===t||kr(o.colorMatrix,t)))return r}return e.length<(wu.enabled?Kn:1)?e.length:-1}var $N=new Float32Array(16*Kn),YN=new Float32Array(4*Kn),qN=new Float32Array(Kn),XN=new WeakMap;function nz(e,t){if(e.length<t.length)return!1;for(let n=0;n<t.length;n++){let r=e[n],o=t[n];if(r.alpha!==o.alpha||r.colorMatrix!==o.colorMatrix&&!kr(r.colorMatrix,o.colorMatrix))return!1}return!0}function JN(e,t,n){let r=XN.get(e);r||(r=new WeakMap,XN.set(e,r));let o=r.get(t);if(o!==void 0&&nz(o,n))return;let i=n.length;for(let a=0;a<i;a++){let l=n[a].colorMatrix;for(let u=0;u<4;u++){for(let c=0;c<4;c++)$N[16*a+c*4+u]=l[u*5+c];YN[4*a+u]=l[u*5+4]}qN[a]=n[a].alpha}let s=e.gl;s.uniformMatrix4fv(t.uniform("u_colorMatrix"),!1,$N.subarray(0,16*i)),s.uniform4fv(t.uniform("u_colorBias"),YN.subarray(0,4*i)),s.uniform1fv(t.uniform("u_alpha"),qN.subarray(0,i)),r.set(t,n.slice())}var js=q.identity(),rz=new Int32Array(Array.from({length:yt},(e,t)=>t)),Ix=new Float32Array(2*yt),QN=new Int32Array(4*Ms);function ye(e){let t=e.drawBatch,n=e.batchState;if(t.length===0||n===void 0){e.batchState=void 0;return}let r=e.gl,o=n.matrices.length>1,i=n.hulls!==void 0,s=n.areaGlyphs,a=(o||i||s)&&e.batchVariants?e.batchVariants.get(o,i,s):e.batchFill;r.useProgram(a.handle);let l=t.uploadAndBind();nt(e,a,js),wx(e,a,1,1,1,1),JN(e,a,n.matrices),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,e.whiteTexture);for(let u=0;u<n.textures.length;u++){let c=n.textures[u];if(c.kind==="atlas"){e.textureCache.bind(c.id,u+1),Ix[2*(u+1)]=c.fieldScale[0],Ix[2*(u+1)+1]=c.fieldScale[1];continue}e.imageCache.bind(c.image,u+1),e.imageCache.setMagFilter(c.image,c.sampling==="nearest"?r.NEAREST:r.LINEAR),e.imageCache.setMinFilter(c.image,c.mips)}n.ramps&&e.gradRamps.bind(Cs),r.uniform1iv(a.uniform("u_samplers"),rz),r.uniform2fv(a.uniform("u_fieldScale"),Ix),i&&oz(r,a,n),wt(e,n.clipDepth),Be(e,l,e.gl.UNSIGNED_INT),r.activeTexture(r.TEXTURE0),r.bindVertexArray(null),t.reset(),e.batchState=void 0}function oz(e,t,n){for(let{set:r,start:o}of n.hulls)QN.set(r.planes,4*o);e.uniform4iv(t.uniform("u_hullPlanes"),QN,0,4*n.hullPlanes)}function Su(e,t,n=e.state.transform){let r=e.clipStack.reduce((o,i)=>o+(i.depth===0?1:0),0);if(e.clipDepth+r+1>7)throw new Error("weasel: clip nesting depth exceeded (max 7). You can't nest more than 7 levels of clipped containers in a single draw tree. Flatten the hierarchy or compose poses outside the scene graph.");sz(e,t,n)}var iz=q.identity();function sz(e,t,n){let r=HN(t,n),o=r===null?null:Ex(e),i=o===null?null:YA(t,n,o),s=i?i.rect:r,a=np(e),l=e.clipStack[e.clipStack.length-1],u=l===void 0?null:l.uncutHulls,c=s===null?lz(e,t,n):null,d=c&&(a?Nb(a,c.set):c.set),f=s===null&&c===null?az(e,t,n):null;if(s!==null){let p=i?i.hull:null,h=p?ZN(u,p.set):!1;e.clipStack.push({path:t,transform:n,rect:s,hull:p,planes:null,hulls:a,uncutHulls:h,depth:0})}else if(c&&d){let p=ZN(u,c.set);e.clipStack.push({path:t,transform:n,rect:null,hull:c,planes:null,hulls:d,uncutHulls:p,depth:0})}else if(f!==null)e.clipStack.push({path:t,transform:n,rect:null,hull:null,planes:f,hulls:a,uncutHulls:u,depth:0});else{Cx(e);let p=e.clipDepth+1;oI(e,t,p,n),e.clipDepth=p,e.clipStack.push({path:t,transform:n,rect:null,hull:null,planes:null,hulls:a,uncutHulls:u,depth:p})}rI(e)}function az(e,t,n){if(!eI(e))return null;let r=VN(t,n);if(r===null)return null;let o=r.length/3;for(let i of e.clipStack)i.planes&&(o+=i.planes.length/3);return o<=UN?r:null}function ZN(e,t){return e===!1?!1:(e?Nb(e,t):t)??!1}function Ex(e){return!e.batchVariants?.hulls||e.renderTarget||e.projection||e.deviceWidth===void 0||e.deviceHeight===void 0?null:$A(gu(e),e.fragOrigin??[0,0],e.deviceWidth,e.deviceHeight)}function eI(e){return e.batchVariants?.cuts!==!1&&Ex(e)===null}function lz(e,t,n){let r=Ex(e);return r===null?null:Rb(t,n,r)}function np(e){if(e.uncutHulls!==void 0)return e.uncutHulls;let t=e.clipStack;return t.length===0?null:t[t.length-1].hulls}function Mx(e){let t=e.clipStack.pop();t.depth>0&&(uz(e,tI(t),t.depth-1,nI(t)),e.clipDepth=t.depth-1),rI(e)}function tI(e){return e.hull?e.hull.path:e.path}function nI(e){return e.hull?iz:e.transform}function Cx(e){for(let t of e.clipStack){if(t.depth!==0)continue;let n=e.clipDepth+1;oI(e,tI(t),n,nI(t)),t.depth=n,e.clipDepth=n}}function rI(e){let t=null,n=[];for(let r of e.clipStack)r.rect&&(t=t?GN(t,r.rect):r.rect),r.planes&&n.push(r.planes);e.drawBatch.clip=WN(t,n,eI(e))}function Ox(e){let t=e.clipStack;if(t.length===0||e.uncut)return e.clipDepth;for(let n=t.length-1;n>=0;n--)if(t[n].rect===null&&t[n].hull===null&&t[n].planes===null)return t[n].depth;for(let n of t)if(n.depth>0)return n.depth-1;return e.clipDepth}function xo(e){let t=e.drawBatch.clip;e.drawBatch.clip=null;let n=e.clipStack[e.clipStack.length-1];return n!==void 0&&n.uncutHulls?(e.uncutHulls=n.uncutHulls,t):(Cx(e),e.uncut=!0,t)}function wo(e,t){e.drawBatch.clip=t,e.uncut=!1,e.uncutHulls=void 0}function sn(e,t,n,r){let o=xo(e);r(e,t,n),wo(e,o)}function an(e){ye(e),e.clipStack.length>0&&Cx(e)}function Tu(e,t,n){let r=e.gl,o=xu(e,t);r.useProgram(e.pathFill.handle),r.bindVertexArray(o.vao);let i=t.kind==="polygon"?t.origin:void 0;nt(e,e.pathFill,i?q.translated(n,i.x,i.y):n),Be(e,o.indexCount,e.gl.UNSIGNED_INT),r.bindVertexArray(null)}function oI(e,t,n,r=e.state.transform){ye(e);let o=e.gl,i=Ai(n-1),s=1<<n,a=i|s;o.enable(o.STENCIL_TEST),o.colorMask(!1,!1,!1,!1),xu(e,t).requiresStencil?(o.stencilMask(1),o.stencilFunc(o.ALWAYS,0,1),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),Tu(e,t,r),o.stencilMask(s),o.stencilFunc(o.EQUAL,a|1,i|1),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),Tu(e,t,r),o.stencilMask(1),o.stencilFunc(o.ALWAYS,0,1),o.stencilOp(o.KEEP,o.KEEP,o.INVERT),Tu(e,t,r)):(o.stencilMask(s),o.stencilFunc(o.EQUAL,a,i),o.stencilOp(o.KEEP,o.KEEP,o.REPLACE),Tu(e,t,r)),o.colorMask(!0,!0,!0,!0),o.stencilMask(255)}function uz(e,t,n,r=e.state.transform){e.batchState!==void 0&&e.batchState.clipDepth>n&&ye(e);let o=e.gl;o.enable(o.STENCIL_TEST);let i=1<<n+1,s=Ai(n)|i;o.colorMask(!1,!1,!1,!1),o.stencilMask(i),o.stencilFunc(o.EQUAL,s,s),o.stencilOp(o.KEEP,o.KEEP,o.ZERO),Tu(e,t,r),o.colorMask(!0,!0,!0,!0),o.stencilMask(255)}var rp=xt(),Cae=rp.reflection;function Nn(e){return rp.get(e)??null}function op(e,t,n){if(rp.has(e)&&!en())throw new Error(`weasel registerProgram: duplicate program id "${e}". In production, re-registration is not allowed. Pass a unique id or call in dev mode.`);return rp.set(e,{vert:t,frag:n}),{id:e}}var iI=`#version 300 es
370
370
  in vec2 a_position;
371
371
  in vec2 a_uv;
372
372
  out vec2 v_uv;
@@ -375,7 +375,7 @@ void main() {
375
375
  v_uv = a_uv;
376
376
  gl_Position = vec4(a_position, 0.0, 1.0);
377
377
  }
378
- `;var rN=`#version 300 es
378
+ `;var sI=`#version 300 es
379
379
  precision highp float;
380
380
  in vec2 v_uv;
381
381
  uniform sampler2D u_source;
@@ -394,7 +394,7 @@ void main() {
394
394
  c.a *= u_alpha;
395
395
  outColor = vec4(clamp(c.rgb, 0.0, 1.0) * c.a, c.a);
396
396
  }
397
- `;var ex="weasel:effect-composite";function Hf(){return Nn(ex)||Bf(ex,nN,rN),ex}function Gs(e){let t=0;for(let n of e){if(n.reach===void 0||!(n.reach>=0))return 1/0;t+=n.reach}return t}Z();Z();Pe();Z();Pe();Pe();function oN(e,t,n){return{pts:[e.x,e.y],a:[e.a],b:[e.b],t:[e.t],w:t?[e.w]:null,o:n?[e.o]:null}}function tx(e,t){e.pts.push(t.x,t.y),e.a.push(t.a),e.b.push(t.b),e.t.push(t.t),e.w?.push(t.w),e.o?.push(t.o)}function Gf(e,t=!1){let n={points:e.pts,closed:t,anchorA:new Uint32Array(e.a),anchorB:new Uint32Array(e.b),anchorT:new Float32Array(e.t)};return e.w&&(n.widths=new Float32Array(e.w)),e.o&&(n.offsets=new Float32Array(e.o)),n}function iN(e,t){let n=cf(t,EV(e));return n==="solid"?[...e]:n==="non-finite"?[]:e.flatMap(r=>MV(r,n))}function EV(e){return e.reduce((t,n)=>t+sN(n),0)}function sN(e){let t=e.points,n=t.length/2,r=0;for(let o=1;o<n;o++)r+=Math.hypot(t[o*2]-t[o*2-2],t[o*2+1]-t[o*2-1]);return e.closed&&n>1&&(r+=Math.hypot(t[0]-t[n*2-2],t[1]-t[n*2-1])),r}function MV(e,t){let n=cf(t,sN(e));if(n==="solid")return[e];if(n==="non-finite")return[];let r=[],o=e.points.length/2,i=e.anchorA??new Uint32Array(o),s=e.anchorB??new Uint32Array(o),a=e.anchorT??new Float32Array(o),l=e.widths,u=e.offsets,c=y=>({x:e.points[y*2],y:e.points[y*2+1],a:i[y],b:s[y],t:a[y],w:l?l[y]:0,o:u?u[y]:0}),d=0,f=n[0],p=!0,h=oN(c(0),!!l,!!u),m=y=>{h&&h.pts.length>=4&&r.push(Gf(h)),d=(d+1)%n.length,f=n[d],p=!p,h=p?oN(y,!!l,!!u):null},g=e.points[0],b=e.points[1],x=e.closed?o:o-1;for(let y=0;y<x;y++){let P=c(y),S=c((y+1)%o),v=Math.hypot(S.x-g,S.y-b);if(v<=1e-9){p&&h&&tx(h,S);continue}let A=v,N=0;for(;A>1e-9;)if(A<=f)p&&h&&tx(h,S),f-=A,g=S.x,b=S.y,A=0,f<=1e-9&&m(S);else{N+=f;let M=N/v,[C,F,B]=nu(P.a,P.b,P.t,S.a,S.b,S.t,M),D={x:P.x+(S.x-P.x)*M,y:P.y+(S.y-P.y)*M,a:C,b:F,t:B,w:P.w+(S.w-P.w)*M,o:P.o+(S.o-P.o)*M};p&&h&&tx(h,D),g=D.x,b=D.y,A=Math.hypot(S.x-g,S.y-b),m(D)}}let w=h;return w&&w.pts.length>=4&&CV(e,w,r),r}function CV(e,t,n){let r=t.pts[t.pts.length-2],o=t.pts[t.pts.length-1],i=(s,a)=>Math.hypot(r-s,o-a)<=1e-9;e.closed&&n.length>0&&i(n[0].points[0],n[0].points[1])?n[0]=OV(Gf(t),n[0]):e.closed&&n.length===0&&i(t.pts[0],t.pts[1])?n.push(Gf({pts:t.pts.slice(0,-2),a:t.a.slice(0,-1),b:t.b.slice(0,-1),t:t.t.slice(0,-1),w:t.w?t.w.slice(0,-1):null,o:t.o?t.o.slice(0,-1):null},!0)):n.push(Gf(t))}function OV(e,t){let n={points:[...e.points,...t.points.slice(2)],closed:!1,anchorA:Uint32Array.from([...e.anchorA,...t.anchorA.subarray(1)]),anchorB:Uint32Array.from([...e.anchorB,...t.anchorB.subarray(1)]),anchorT:Float32Array.from([...e.anchorT,...t.anchorT.subarray(1)])};return e.widths&&t.widths&&(n.widths=Float32Array.from([...e.widths,...t.widths.subarray(1)])),e.offsets&&t.offsets&&(n.offsets=Float32Array.from([...e.offsets,...t.offsets.subarray(1)])),n}Z();Pe();function FV(e){let t=Math.cos(e.angle),n=-Math.sin(e.angle),r=Math.min(1,Math.max(0,e.ratio));return(o,i)=>{let s=t*i-n*o,a=t*o+n*i;return Math.sqrt(s*s+r*r*a*a)}}function aN(e,t,n){let r=e.points.length/2;if(r<2)return;let o=e.points,i=FV(t),s=e.closed?r:r-1,a=[];for(let y=0;y<s;y++){let P=(y+1)%r,S=o[P*2]-o[y*2],v=o[P*2+1]-o[y*2+1],A=Math.hypot(S,v);a.push(A>0?i(S/A,v/A):NaN)}for(let y=0;y<s;y++)Number.isNaN(a[y])&&(a[y]=y>0?a[y-1]:a.find(P=>!Number.isNaN(P))??1);let l=e.anchorA,u=e.anchorB,c=e.anchorT,d=e.widths,f=e.offsets,p=[],h=[],m=[],g=[],b=[],x=[],w=(y,P)=>{p.push(o[y*2],o[y*2+1]),h.push(l?l[y]:0),m.push(u?u[y]:0),g.push(c?c[y]:0),b.push((d?d[y]:n)*P),f&&x.push(f[y]*P)};w(0,a[0]);for(let y=1;y<r;y++)w(y,a[y-1]),y<s&&w(y,a[y]);e.closed&&w(0,a[s-1]),e.points=p,e.anchorA=Uint32Array.from(h),e.anchorB=Uint32Array.from(m),e.anchorT=Float32Array.from(g),e.widths=Float32Array.from(b),f&&(e.offsets=Float32Array.from(x))}function lN(e,t,n,r){let o=e.points.length/2;if(o===0)return;let i=e.anchorA??new Uint32Array(o),s=e.anchorB??new Uint32Array(o),a=e.anchorT??new Float32Array(o),l=new Float32Array(o),u=new Float32Array(o),c=!1,d=n/2,f=1,p=h=>{let m=uf(t[h],NaN);return[Number.isNaN(m.left)?d:m.left*f,Number.isNaN(m.right)?d:m.right*f]};for(let h=0;h<o;h++){r&&(f=LV(e,h,r));let m=i[h],g=s[h],b=a[h],[x,w]=p(m);if(m!==g){let[y,P]=p(g);x+=(y-x)*b,w+=(P-w)*b}l[h]=x+w,u[h]=(w-x)/2,u[h]!==0&&(c=!0)}e.widths=l,c&&(e.offsets=u)}function Pi(e,t){return 2*fb(e,t)}function uN(e,t,n,r,o){t&&lN(e,t,r,o),n&&aN(e,n,r)}function LV(e,t,n){let r=e.points,o=r.length/2,i=0,s=0,a=(u,c)=>{let d=r[c*2]-r[u*2],f=r[c*2+1]-r[u*2+1],p=Math.hypot(d,f);p>0&&(i+=d/p,s+=f/p)};t>0?a(t-1,t):e.closed&&o>1&&a(o-1,0),t<o-1?a(t,t+1):e.closed&&o>1&&a(o-1,0);let l=Math.hypot(i,s);return l>0?n(i/l,s/l):1}function Uf(e,t,n){let r=e??mt,o=Pi(t,n);return o/2>r?{flattenTolerance:e,offset:o/2}:{flattenTolerance:e}}function cu(e){return e===void 0?"":`${mo(e.metric)}@${e.pxPerUnit}`}var cN=1e-9;function du(e,t,n,r){let o=Math.abs(e*r-t*n),i=Math.sqrt(o);if(!(o>0)||!Number.isFinite(o))return{scale:0,metric:null};let s=(e*e+t*t)/o,a=(e*n+t*r)/o,l=(n*n+r*r)/o,u=Math.sqrt(s+l+2),c=(s+1)/u,d=a/u,f=(l+1)/u;return Math.abs(d)<cN&&Math.abs(c-f)<cN?{scale:i,metric:null}:{scale:i,metric:{p:c,q:d,r:f}}}function mo(e){return e===void 0?"":`${e.p},${e.q},${e.r}`}function fu(e,t){let n=e.points;for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];n[r]=t.p*o+t.q*i,n[r+1]=t.q*o+t.r*i}}function nx(e,t){let n=e.points;for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];n[r]=t.r*o-t.q*i,n[r+1]=t.p*i-t.q*o}}function Wf(e,t){return e===t?!0:e!==null&&t!==null&&e.p===t.p&&e.q===t.q&&e.r===t.r}function rx(e,t,n){return Math.hypot(e.r*t-e.q*n,e.p*n-e.q*t)}function ox(e,t,n){return 1/Math.hypot(e.p*t+e.q*n,e.q*t+e.r*n)}function pu(e,t){for(let n=0;n<e.length;n+=2){let r=e[n],o=e[n+1];e[n]=t.r*r-t.q*o,e[n+1]=t.p*o-t.q*r}}function Vf(e){return e.q===0}function ix(e,t){return Vf(t)?{kind:"rect",x:t.p*e.x,y:t.r*e.y,width:t.p*e.width,height:t.r*e.height}:null}var dN=(e,t)=>e===void 0?{length:0,metric:t}:typeof e=="number"?{length:e,metric:t}:e;function fN(e,t,n,r,o){let i=dN(r,n),s=dN(o,n),a=e,l=t,u=c=>{a===null||Wf(l,c)||(l!==null&&nx(a,l),c!==null&&fu(a,c),l=c)};if(i.length>0||s.length>0)if(Wf(i.metric,s.metric))u(i.metric),a=vf(a,i.length,s.length);else for(let[c,d,f]of[[i.length,i.metric,!0],[s.length,s.metric,!1]])!(c>0)||a===null||(u(d),a=vf(a,f?c:0,f?0:c));return u(n),a}var _V=10*Math.PI/180;function ax(e,t,n,r,o,i,s,a,l,u,c,d,f,p,h){let m=r?1:-1,g=(e.bx-e.ax)/e.len*m,b=(e.by-e.ay)/e.len*m,x=(o+i)/2,w=(o-i)/2,y=(r?e.bx:e.ax)+e.nxUnit*w,P=(r?e.by:e.ay)+e.nyUnit*w,S=e.nxUnit*x,v=e.nyUnit*x;if(s==="square"){let A=y+g*x,N=P+b*x,M=a.length/2;a.push(A+S,N+v),u.push(f),c.push(p),d.push(h);let C=a.length/2;a.push(A-S,N-v),u.push(f),c.push(p),d.push(h),r?l.push(t,M,C,t,C,n):l.push(t,C,M,t,n,C);return}if(s==="round"){let A=a.length/2;a.push(y,P),u.push(f),c.push(p),d.push(h);let N=Math.atan2(v,S),M=r?-Math.PI:Math.PI,C=Math.max(1,Math.ceil(Math.abs(M)/_V)),F=M/C,B=t;for(let D=1;D<C;D++){let j=N+D*F,W=y+Math.cos(j)*x,J=P+Math.sin(j)*x,se=a.length/2;a.push(W,J),u.push(f),c.push(p),d.push(h),r?l.push(B,se,A):l.push(B,A,se),B=se}r?l.push(B,n,A):l.push(B,A,n)}}function lx(e,t,n,r,o,i,s,a){let l=n-e,u=r-t,c=Math.hypot(l,u);return c===0?null:{ax:e,ay:t,bx:n,by:r,nxUnit:-u/c,nyUnit:l/c,posA:o,negA:i,posB:s,negB:a,len:c}}function pN(e,t,n,r,o,i,s,a,l,u,c,d,f,p,h,m=-1){let g=e[n],b=e[(n+1)%e.length],x=t[n],w=t[(n+1)%e.length],y=g.bx-g.ax,P=g.by-g.ay,S=b.bx-b.ax,v=b.by-b.ay,A=y*v-P*S;if(A===0)return;let N=A>0,M=N?x+3:x+2,C=N?w+1:w+0,F=(n+1)%e.length,B=d[F],D=f[B],j=p[B],W=h[B],J=N?[g.negA,g.negB]:[g.posA,g.posB],se=N?[b.negA,b.negB]:[b.posA,b.posB],ke=J[1],ae=Math.max(...J)/Math.max(1e-9,Math.min(...J)),ve=Math.max(...se)/Math.max(1e-9,Math.min(...se)),G=ae>i||ve>i;if(r==="bevel"||G){sx(g,M,C,N,s,a,l,u,c,D,j,W,m);return}if(r==="miter"){let K=s[M*2],$=s[M*2+1],ee=s[C*2],te=s[C*2+1],he=HV(K,$,y,P,ee,te,-S,-v);if(!he){sx(g,M,C,N,s,a,l,u,c,D,j,W,m);return}if(Math.hypot(he[0]-g.bx,he[1]-g.by)>o*ke){sx(g,M,C,N,s,a,l,u,c,D,j,W,m);return}let Fe=s.length/2;s.push(he[0],he[1]),l.push(D),u.push(j),c.push(W);let Se=m>=0?m:ux(g,s,l,u,c,D,j,W);N?(a.push(M,Fe,C),a.push(M,C,Se)):(a.push(M,C,Fe),a.push(M,Se,C));return}if(r==="round"){BV(g,M,C,N,s,a,l,u,c,D,j,W,m);return}}var DV=10*Math.PI/180;function BV(e,t,n,r,o,i,s,a,l,u,c,d,f){let p=e.bx,h=e.by,m=f>=0?f:ux(e,o,s,a,l,u,c,d),g=o[t*2]-p,b=o[t*2+1]-h,x=o[n*2]-p,w=o[n*2+1]-h,y=Math.hypot(g,b),P=Math.hypot(x,w),S=Math.atan2(b,g),A=Math.atan2(w,x)-S;r&&A<0?A+=2*Math.PI:!r&&A>0&&(A-=2*Math.PI);let N=Math.max(1,Math.ceil(Math.abs(A)/DV)),M=A/N,C=t;for(let F=1;F<N;F++){let B=S+F*M,D=y+(P-y)*F/N;o.push(p+Math.cos(B)*D,h+Math.sin(B)*D);let j=o.length/2-1;s.push(u),a.push(c),l.push(d),r?i.push(C,m,j):i.push(C,j,m),C=j}r?i.push(C,m,n):i.push(C,n,m)}function sx(e,t,n,r,o,i,s,a,l,u,c,d,f){let p=f>=0?f:ux(e,o,s,a,l,u,c,d);r?i.push(t,p,n):i.push(t,n,p)}function ux(e,t,n,r,o,i,s,a){let l=t.length/2;return t.push(e.bx,e.by),n.push(i),r.push(s),o.push(a),l}function HV(e,t,n,r,o,i,s,a){let l=n*a-r*s;if(Math.abs(l)<1e-9)return null;let u=((o-e)*a-(i-t)*s)/l;return[e+u*n,t+u*r]}function hN(e,t,n,r){let o=e.length,i=n?o:o-1,s=[];for(let l=0;l<i;l++)s.push(GV(e,t,l,r));for(let l=!0;l;){l=!1;for(let u=0;u<o;u++){let c=u>0||n?s[(u-1+o)%o]??null:null,d=u<i?s[u]:null;c&&d&&c.side===d.side&&c.u>d.s&&(s[(u-1+o)%o]=null,s[u]=null,l=!0)}}let a=[];for(let l=0;l<i;l++){let u=s[l];if(!u){a.push(-1);continue}let c=t[l]+2+u.side,d=t[(l+1)%o]+u.side;r[c*2]=u.x,r[c*2+1]=u.y,r[d*2]=u.x,r[d*2+1]=u.y,a.push(c)}return a}function GV(e,t,n,r){let o=e[n],i=e[(n+1)%e.length],s=(o.bx-o.ax)*(i.by-i.ay)-(o.by-o.ay)*(i.bx-i.ax);if(s===0)return null;let a=s>0?0:1,l=t[n],u=t[(n+1)%e.length],c=r[(l+a)*2],d=r[(l+a)*2+1],f=r[(l+2+a)*2],p=r[(l+2+a)*2+1],h=r[(u+a)*2],m=r[(u+a)*2+1],g=r[(u+2+a)*2],b=r[(u+2+a)*2+1],x=f-c,w=p-d,y=g-h,P=b-m,S=x*P-w*y;if(S===0)return null;let v=h-c,A=m-d,N=(v*P-A*y)/S,M=(v*w-A*x)/S;return N>0&&N<=1&&M>=0&&M<1?{side:a,x:c+x*N,y:d+w*N,s:N,u:M}:null}var UV={vertices:new Float32Array(0),indices:new Uint32Array(0),anchorA:new Uint32Array(0),anchorB:new Uint32Array(0),anchorT:new Float32Array(0)};function at(e,t){return Gt(e,t)}function Ti(e,t,n={}){let r=at(t.width??1,1);if(r<=0)return UV;let o=t.join??"miter",i=t.cap??"butt",s=t.align??"center",a=t.miterLimit??VV,l=t.varyingWidthJoinThreshold??zV,u=n.metric,c=u&&e.kind==="rect"?ix(e,u):null,d=c??e;d.kind==="rect"&&s!=="center"&&(d={kind:"rect",...pb(d,s,r)});let f=d.kind==="polygon"?ps(d):null;f&&(d=f.path);let p=t.vertexWidths&&t.vertexWidths.length>0?t.vertexWidths:null,h=p&&f?.anchorSources?vl(p,f.anchorSources,1):p,m=hs(d,Uf(n.flattenTolerance,r,h??void 0)),g=u?c?(N,M)=>rx(u,N,M):(N,M)=>ox(u,N,M):void 0,b=[],x=[],w=[],y=[],P=[],S=u??null,v=[];for(let N of m){uN(N,h,t.nib,r,g);let M=fN(N,c?S:null,S,n.startInset,n.endInset);M!==null&&v.push(M)}for(let N of iN(v,t.dash))WV(N,r,o,i,a,l,b,x,w,y,P);let A=new Float32Array(b);return u&&pu(A,u),{vertices:A,indices:new Uint32Array(x),anchorA:new Uint32Array(w),anchorB:new Uint32Array(y),anchorT:new Float32Array(P),...e.kind==="polygon"&&e.origin?{origin:e.origin}:{}}}function WV(e,t,n,r,o,i,s,a,l,u,c){let d=t/2,f=e.points,p=f.length/2,h=p-1;if(h<1)return;let m=e.anchorA??new Uint32Array(p),g=e.anchorB??new Uint32Array(p),b=e.anchorT??new Float32Array(p),x=e.widths,w=e.offsets,y=F=>(x?x[F]/2:d)+(w?w[F]:0),P=F=>(x?x[F]/2:d)-(w?w[F]:0),S=[],v=[];for(let F=0;F<h;F++){let B=lx(f[F*2],f[F*2+1],f[(F+1)*2],f[(F+1)*2+1],y(F),P(F),y(F+1),P(F+1));B&&(S.push(B),v.push(F))}let A=-1;if(e.closed&&S.length>=1){let F=S[S.length-1],B=S[0],D=lx(F.bx,F.by,B.ax,B.ay,y(p-1),P(p-1),y(0),P(0));D&&(S.push(D),A=p-1,v.push(A))}if(S.length===0)return;let N=[];for(let F=0;F<S.length;F++){let B=S[F],D=v[F],j=F===S.length-1&&e.closed&&A>=0?0:D+1,W=s.length/2;N.push(W);let{nxUnit:J,nyUnit:se}=B;s.push(B.ax+J*B.posA,B.ay+se*B.posA),l.push(m[D]),u.push(g[D]),c.push(b[D]),s.push(B.ax-J*B.negA,B.ay-se*B.negA),l.push(m[D]),u.push(g[D]),c.push(b[D]),s.push(B.bx+J*B.posB,B.by+se*B.posB),l.push(m[j]),u.push(g[j]),c.push(b[j]),s.push(B.bx-J*B.negB,B.by-se*B.negB),l.push(m[j]),u.push(g[j]),c.push(b[j]),a.push(W,W+1,W+2,W+1,W+3,W+2)}let M=e.closed?S.length:S.length-1,C=hN(S,N,e.closed,s);for(let F=0;F<M;F++)pN(S,N,F,n,o,i,s,a,l,u,c,v,m,g,b,C[F]);if(!e.closed&&r!=="butt"){let F=S[0],B=N[0];ax(F,B+0,B+1,!1,F.posA,F.negA,r,s,a,l,u,c,m[0],g[0],b[0]);let D=S[S.length-1],j=N[S.length-1],W=v[S.length-1]+1;ax(D,j+2,j+3,!0,D.posB,D.negB,r,s,a,l,u,c,m[W],g[W],b[W])}}var VV=4,zV=1.5;Z();function Us(e,...t){let n=0,r=0;for(let[l,u]of t)n+=l.length/2+(u?1:0),r+=l.length;let o=new Uint8Array(n),i=new Float32Array(r),s=0,a=0;for(let[l,u]of t){for(let c=0;c<l.length;c+=2)o[s++]=c===0?le:ce,i[a++]=l[c]*e,i[a++]=l[c+1]*e;u&&(o[s++]=fe)}return{kind:"polygon",commands:o,coords:i,fillRule:"nonzero"}}function Tr(e,t,n=!0){return Us(t,[e,n])}function bN(e,t,n=32){let r=[];for(let o=0;o<n;o++){let i=o/n*Math.PI*2;r.push(e+t*Math.cos(i),t*Math.sin(i))}return r}function mN(e,t,n){return Tr(bN(e,t),n)}var zf=e=>[[e,-2,e,2],!1],cx=[[[-4,0,0,-2.5],!1],[[-4,0,0,2.5],!1]],yN=2,gN=e=>[[bN(e,yN),!0],[[e+yN,0,0,0],!1]],hu={reads:[],fill:"none",outline:{width:1}},xN=[{id:"arrow",reads:[],inset:3,path:({size:e})=>Tr([0,0,-3,-1.5,-3,1.5],e)},{id:"arrow-open",reads:[],inset:0,fill:"none",outline:{width:1},path:({size:e})=>Tr([-2.867,-2.007,0,0,-2.867,2.007],e,!1)},{id:"arrow-concave",reads:[],inset:3,path:({size:e})=>Tr([0,0,-3,-1.5,-2,0,-3,1.5],e)},{id:"triangle-hollow",reads:[],inset:4,fill:"none",outline:{width:.5},path:({size:e})=>Tr([0,0,-4,-2,-4,2],e)},{id:"diamond",reads:[],inset:4,path:({size:e})=>Tr([0,0,-2,-1.2,-4,0,-2,1.2],e)},{id:"diamond-hollow",reads:[],inset:4,fill:"none",outline:{width:.5},path:({size:e})=>Tr([0,0,-2,-1.2,-4,0,-2,1.2],e)},{id:"circle",reads:[],inset:2,path:({size:e})=>mN(-1,1,e)},{id:"square",reads:[],inset:2,path:({size:e})=>Tr([0,-1,0,1,-2,1,-2,-1],e)},{id:"bar",reads:[],inset:0,fill:"none",outline:{width:1},path:({size:e})=>Tr([0,-1.5,0,1.5],e,!1)},{id:"dot",reads:[],inset:0,path:({size:e})=>mN(0,1.2,e)},{id:"crow-one",...hu,inset:0,path:({size:e})=>Us(e,zf(-2),zf(-4),[[-4,0,0,0],!1])},{id:"crow-many",...hu,inset:0,path:({size:e})=>Us(e,...cx)},{id:"crow-zero-one",...hu,inset:7.5,path:({size:e})=>Us(e,zf(-2),...gN(-5.5))},{id:"crow-one-many",...hu,inset:0,path:({size:e})=>Us(e,...cx,zf(-5.5))},{id:"crow-zero-many",...hu,inset:9.5,path:({size:e})=>Us(e,...cx,...gN(-7.5))}];var Kf=xt();function KV(){for(let e of xN)Kf.push(e.id,e,{source:"kit"})}KV();var jV=Kf.reflection;function mu(){return Kf.getVersion()}function yo(e){return e===void 0?void 0:Kf.get(e)}Pe();function Ws(e,t,n=1){return typeof e=="string"||e.size===void 0?t:Gt(e.size,n)}function Si(e){return typeof e=="string"?e:e.key}function dx(e,t,n=1){if(e===void 0)return 0;let r=yo(Si(e));return r===void 0?0:(r.inset??0)*Ws(e,t,n)}function Vs(e,t){return{start:dx(e.markerStart,t),end:dx(e.markerEnd,t)}}function zs(e,t,n){let r=e.points[n*2]-e.points[t*2],o=e.points[n*2+1]-e.points[t*2+1],i=Math.hypot(r,o);return i<1e-9?null:{x:r/i,y:o/i}}function wN(e,t,n){for(let r=t+1;r<n;r++)if(zs(e,t,r))return r;return-1}function PN(e,t){for(let n=t-1;n>=0;n--)if(zs(e,n,t))return n;return-1}function TN(e,t){let n=[],r=e.points.length/2;if(r<2)return n;if(t.start&&!e.closed){let o=wN(e,0,r),i=o>=0?zs(e,0,o):null;i&&n.push({x:e.points[0],y:e.points[1],angle:Math.atan2(-i.y,-i.x),role:"start"})}if(t.mid){let o=e.anchorA,i=e.anchorB,s=e.anchorT;if(o&&i&&s)for(let a=1;a<r-1;a++){if(o[a]!==i[a]||s[a]!==0)continue;let l=PN(e,a),u=wN(e,a,r);if(l<0||u<0)continue;let c=zs(e,l,a),d=zs(e,a,u),f=c.x+d.x,p=c.y+d.y;Math.hypot(f,p)<1e-9&&(f=c.x,p=c.y),n.push({x:e.points[a*2],y:e.points[a*2+1],angle:Math.atan2(p,f),role:"mid"})}}if(t.end&&!e.closed){let o=r-1,i=PN(e,o),s=i>=0?zs(e,i,o):null;s&&n.push({x:e.points[o*2],y:e.points[o*2+1],angle:Math.atan2(s.y,s.x),role:"end"})}return n}Z();function $V(e,t,n){let{origin:r,...o}=e,i=Math.cos(t.angle),s=Math.sin(t.angle),a=new Float32Array(o.coords.length);for(let l=0;l<o.coords.length;l+=2){let u=o.coords[l],c=o.coords[l+1];a[l]=t.x+u*i-c*s,a[l+1]=t.y+u*s+c*i}return n?{...o,coords:a,origin:n}:{...o,coords:a}}function yu(e,t,n,r,o={}){let i={start:t.markerStart,mid:t.markerMid,end:t.markerEnd};if(i.start===void 0&&i.mid===void 0&&i.end===void 0)return[];let s=new Map;for(let u of["start","mid","end"]){if(i[u]===void 0)continue;let c=o[u],d=s.get(c);d===void 0&&s.set(c,d={start:!1,mid:!1,end:!1}),d[u]=!0}let a=[],l=e.kind==="polygon"?e.origin:void 0;for(let u of hs(e,Uf(r,n,t.vertexWidths)))for(let[c,d]of s){let f=c?{...u,points:u.points.slice()}:u;c&&fu(f,c.metric);for(let p of TN(f,d)){let h=i[p.role];if(h===void 0)continue;let m=yo(Si(h));if(m===void 0)continue;let g=Ws(h,n),b=m.orient===void 0||m.orient==="auto"?p.angle:m.orient,x=$V(m.path({size:g,stroke:t}),{...p,angle:b},l);c&&pu(x.coords,c.metric),a.push(c?{entry:m,size:g,path:x,space:c}:{entry:m,size:g,path:x})}}return a}function jf(e,t){if(e.reads===void 0)return null;let n="";for(let r of e.reads)n+=`${JSON.stringify(t[r])??""}|`;return n}var YV=64,SN=new WeakMap,kN=new WeakMap;function vN(e,t){let n=et(e.path({size:1,stroke:t}));return Math.max(Math.abs(n.x),Math.abs(n.x+n.width),Math.abs(n.y),Math.abs(n.y+n.height))+(e.outline?e.outline.width/2:0)}function qV(e,t){let n=jf(e,t);if(n===null){let i=kN.get(e);i===void 0&&kN.set(e,i=new WeakMap);let s=i.get(t);return s===void 0&&i.set(t,s=vN(e,t)),s}let r=SN.get(e);r===void 0&&SN.set(e,r=new Map);let o=r.get(n);return o===void 0&&(r.size>=YV&&r.clear(),r.set(n,o=vN(e,t))),o}function gu(e){let t={world:0,px:0},n=e.width??1;for(let r of[e.markerStart,e.markerMid,e.markerEnd]){if(r===void 0)continue;let o=yo(Si(r));if(o===void 0)continue;let i=typeof r=="string"||r.size===void 0?n:r.size,s=qV(o,e);typeof i=="number"?t.world=Math.max(t.world,s*i):t.px=Math.max(t.px,s*i.px)}return t}var bu=lG(AN(),1);Je();Pn();oi();ii();nn();tn();function RN(e,t={}){let n=Qe(e);if(n.kind==="rect"){let{x:m,y:g,width:b,height:x}=n;return[[[[m,g],[m+b,g],[m+b,g+x],[m,g+x],[m,g]]]]}let r=t.tolerance??mt,o=[],i=null,s=0,a=0,l=0,u=0,c=0,{commands:d}=n,f=$e(n),p=kn(n),h=(m=p)=>{if(m||(i=null),!i||i.length===0)return;let g=i[0],b=i[i.length-1];(g[0]!==b[0]||g[1]!==b[1])&&i.push([g[0],g[1]]),i.length>=4&&o.push(i),i=null};for(let m=0;m<d.length;m++){let g=d[m];switch(g){case le:{h(),s=f[c],a=f[c+1],l=s,u=a,i=[[s,a]],c+=2;break}case ce:{i??=[[s,a]],s=f[c],a=f[c+1],i.push([s,a]),c+=2;break}case xe:{let b=f[c],x=f[c+1],w=f[c+2],y=f[c+3],P=f[c+4],S=f[c+5],v=[];lo(s,a,b,x,w,y,P,S,r,v),i??=[[s,a]];for(let A=0;A<v.length;A+=2)i.push([v[A],v[A+1]]);s=P,a=S,c+=6;break}case we:{let b=f[c],x=f[c+1],w=f[c+2],y=f[c+3],[P,S,v,A]=io(s,a,b,x,w,y),N=[];lo(s,a,P,S,v,A,w,y,r,N),i??=[[s,a]];for(let M=0;M<N.length;M+=2)i.push([N[M],N[M+1]]);s=w,a=y,c+=4;break}case fe:{h(!0),s=l,a=u;break}default:throw new Error(`pathToMultiPolygon: unknown command ${g}`)}}return h(),o.length===0?[]:e6(o,n.fillRule)}function XV(e){let t=0;for(let n=0,r=e.length-1;n<r;n++)t+=e[n][0]*e[n+1][1]-e[n+1][0]*e[n][1];return t*.5}function JV(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let[i,s]of e)i<t&&(t=i),i>r&&(r=i),s<n&&(n=s),s>o&&(o=s);return[t,n,r,o]}function QV(e,t,n){let r=!1;for(let o=0,i=e.length-1;o<i;o++){let[s,a]=e[o],[l,u]=e[o+1];a>n!=u>n&&t<(l-s)*(n-a)/(u-a)+s&&(r=!r)}return r}function ZV(e,t,n,r){if(r[0]<t[0]||r[1]<t[1]||r[2]>t[2]||r[3]>t[3])return!1;let o=n.length-1,i=0;for(let s of[0,Math.floor(o/3),Math.floor(2*o/3)])QV(e,n[s][0],n[s][1])&&i++;return i>=2}function e6(e,t){let n=e.length;if(n===1)return[[e[0]]];let r=e.map(JV),o=e.map(u=>XV(u)>=0?1:-1),i=new Array(n).fill(-1),s=e.map(()=>[]);for(let u=0;u<n;u++){let c=-1,d=1/0;for(let f=0;f<n;f++){if(u===f||!ZV(e[f],r[f],e[u],r[u]))continue;let p=(r[f][2]-r[f][0])*(r[f][3]-r[f][1]);p<d&&(d=p,c=f)}i[u]=c}for(let u=0;u<n;u++)i[u]>=0&&s[i[u]].push(u);let a=new Array(n);for(let u=0;u<n;u++){let c=0,d=0;for(let f=u;f>=0;f=i[f])d+=o[f],f!==u&&c++;a[u]=t==="evenodd"?c%2===0:d!==0}let l=[];for(let u=0;u<n;u++){if(!a[u]||i[u]>=0&&a[i[u]])continue;let c=[e[u]],d=[...s[u]];for(;d.length>0;){let f=d.pop();a[f]?d.push(...s[f]):c.push(e[f])}l.push(c)}return l}function hx(e){let t=0,n=0;for(let l of e)for(let u of l){if(u.length<4)continue;let c=u.length-1;t+=1+(c-1)+1,n+=c*2}let r=new Uint8Array(t),o=new Float64Array(n),i=0,s=0;for(let l of e)for(let u of l){if(u.length<4)continue;let c=u.length-1;r[i++]=le,o[s++]=u[0][0],o[s++]=u[0][1];for(let d=1;d<c;d++)r[i++]=ce,o[s++]=u[d][0],o[s++]=u[d][1];r[i++]=fe}let a=Sn(o);return{kind:"polygon",commands:r,coords:At(a,o),fillRule:"nonzero",...a?{origin:a}:{}}}Je();nn();li();av();gv();ov();li();Pd();li();function $f(e,t){return e.length===2?xl(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y):e.length===3?XS(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y):ni(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y)}var NN=[.25,.5,.75];function IN(e,t,n){let r=[],o=s=>{r.some(a=>Math.hypot(a.p.x-s.p.x,a.p.y-s.p.y)<=n)||r.push(s)};for(let[s,a]of[[0,t[0]],[1,t[t.length-1]]]){let l=$f(e,a);l.dist<=n&&o({ta:l.t,tb:s,p:a})}for(let[s,a]of[[0,e[0]],[1,e[e.length-1]]]){let l=$f(t,a);l.dist<=n&&o({ta:s,tb:l.t,p:a})}let i=null;for(let s=0;s<r.length;s++)for(let a=s+1;a<r.length;a++){let[l,u]=r[s].ta<=r[a].ta?[r[s],r[a]]:[r[a],r[s]];if(i&&u.ta-l.ta<=i[1].ta-i[0].ta)continue;NN.every(d=>$f(t,tt(e,l.ta+(u.ta-l.ta)*d)).dist<=n)&&(i=[l,u])}return i}function t6(e,t,n){return!(e.from===t.from&&e.to===t.to)&&!(e.from===t.to&&e.to===t.from)?!1:NN.every(o=>$f(t.seg,tt(e.seg,o)).dist<=n)}function EN(e,t){let n=new Map,r=[];for(let o of e){let i=o.from<o.to?`${o.from},${o.to}`:`${o.to},${o.from}`,s=n.get(i)??[],a=s.find(l=>t6(l,o,t));if(a){(a.also??=[]).push({operand:o.operand,sign:a.from===o.from?1:-1});continue}s.push(o),n.set(i,s),r.push(o)}return r}var n6=16,Yf=1e-9,mx=class{constructor(t){this.snap=t}snap;points=[];grid=new Map;id(t){let n=Math.floor(t.x/this.snap),r=Math.floor(t.y/this.snap);for(let a=-1;a<=1;a++)for(let l=-1;l<=1;l++)for(let u of this.grid.get(`${n+a},${r+l}`)??[]){let c=this.points[u];if(Math.hypot(c.x-t.x,c.y-t.y)<=this.snap)return u}let o=this.points.length;this.points.push({x:t.x,y:t.y});let i=`${n},${r}`,s=this.grid.get(i);return s?s.push(o):this.grid.set(i,[o]),o}};function r6(e){let t=[];return e.forEach((n,r)=>n.forEach((o,i)=>o.forEach((s,a)=>{let l=1/0,u=1/0,c=-1/0,d=-1/0;for(let f of s)l=Math.min(l,f.x),c=Math.max(c,f.x),u=Math.min(u,f.y),d=Math.max(d,f.y);t.push({seg:s,operand:r,contour:i,index:a,count:o.length,box:[l,u,c,d]})}))),t}var o6=(e,t)=>{if(e.operand!==t.operand||e.contour!==t.contour)return!1;let n=Math.abs(e.index-t.index);return n===1||n===e.count-1};function i6(e){if(e.length<4)return!1;let t=tt(e,.5),n=bs(e,0,.5,e[0],t),r=bs(e,.5,1,t,e[3]);return!n||!r?!1:Mg(n,r).some(o=>o.ta<1-1e-6||o.tb>1e-6)}function MN(e,t){let n=r6(e);if(n.some(a=>i6(a.seg)))return null;let r=new mx(t),o=n.map(({seg:a})=>[r.id(a[0]),r.id(a[a.length-1])]),i=n.map(()=>[]);for(let a=0;a<n.length;a++){let l=n[a];for(let u=a+1;u<n.length;u++){let c=n[u];if(l.box[0]>c.box[2]+t||c.box[0]>l.box[2]+t||l.box[1]>c.box[3]+t||c.box[1]>l.box[3]+t)continue;let d=IN(l.seg,c.seg,t);if(d){for(let h of d){let m=r.id(h.p);i[a].push({t:h.ta,v:m}),i[u].push({t:h.tb,v:m})}continue}let f=Mg(l.seg,c.seg);if(f.length>=n6)return null;let p=o6(l,c);for(let h of f){if(p&&(h.ta>1-Yf&&h.tb<Yf||h.ta<Yf&&h.tb>1-Yf))continue;let m=r.id(h);i[a].push({t:h.ta,v:m}),i[u].push({t:h.tb,v:m})}}}let s=[];return n.forEach((a,l)=>{let{seg:u}=a,c=[{t:0,v:o[l][0]},...i[l].sort((p,h)=>p.t-h.t),{t:1,v:o[l][1]}],d=[c[0]];for(let p=1;p<c.length;p++){let h=c[p];h.v!==d[d.length-1].v?d.push(h):p===c.length-1&&d.length>1&&(d[d.length-1]=h)}let f=Math.hypot(a.box[2]-a.box[0],a.box[3]-a.box[1]);d.length===1&&u.length>2&&f>100*t&&d.push(c[c.length-1]);for(let p=0;p+1<d.length;p++){let h=d[p],m=d[p+1],g=h.t===0&&m.t===1?u.slice():bs(u,h.t,m.t,r.points[h.v],r.points[m.v]);g&&(g[0]=r.points[h.v],g[g.length-1]=r.points[m.v],s.push({seg:g,from:h.v,to:m.v,operand:a.operand,source:u,t0:h.t,t1:m.t,key:l+h.t*.5,reversed:!1}))}}),{edges:EN(s,t),points:r.points}}li();function FN(e,t){let n=e.flat(),r=new Float64Array(n.length*4);return n.forEach((o,i)=>{let s=1/0,a=1/0,l=-1/0,u=-1/0;for(let c of o)s=Math.min(s,c.x),l=Math.max(l,c.x),a=Math.min(a,c.y),u=Math.max(u,c.y);r.set([s,a,l,u],i*4)}),{segs:n,boxes:r,fillRule:t}}var s6={x:1,y:0};function CN(e,t){let n=0,{segs:r,boxes:o}=t;for(let i=0;i<r.length;i++){if(e.y<o[i*4+1]||e.y>o[i*4+3]||o[i*4+2]<e.x)continue;let s=r[i];for(let a of Qk(Jk(s,e,s6),!0))tt(s,a.t).x>e.x&&(n+=a.after>0?1:-1)}return n}var ON=(e,t)=>t==="evenodd"?(e&1)!==0:e!==0,LN=e=>({...e,seg:e.seg.slice().reverse(),from:e.to,to:e.from,reversed:!0});function a6(e,t){let n=new Array(t).fill(0);n[e.operand]=1;for(let{operand:r,sign:o}of e.also??[])n[r]+=o;return n}function _N(e,t,n){let r=[];for(let o of e){let i=(o.t0+o.t1)/2,s=tt(o.source,i),a=Ml(o.source,i),l=Math.hypot(a.x,a.y);if(l===0){let g=o.seg[0],b=o.seg[o.seg.length-1];if(a={x:b.x-g.x,y:b.y-g.y},l=Math.hypot(a.x,a.y),l===0)continue}let u=-a.y/l*n,c=a.x/l*n,d={x:s.x+u,y:s.y+c},f={x:s.x-u,y:s.y-c},p=a6(o,t.length),h=new Array(t.length),m=new Array(t.length);for(let g=0;g<t.length;g++){let b=CN(d,t[g]),x=CN(f,t[g]);if(Math.abs(b-x)!==Math.abs(p[g]))return null;h[g]=ON(b,t[g].fillRule),m[g]=ON(x,t[g].fillRule)}r.push({edge:o,inL:h,inR:m})}return r}li();var gx=Math.PI*2,yx=1e-7;function l6(e){let t=e[0];for(let n=1;n<e.length;n++)if(e[n].x!==t.x||e[n].y!==t.y)return{x:e[n].x-t.x,y:e[n].y-t.y};return{x:0,y:0}}var u6=e=>e.slice().reverse();function c6(e,t){let n=0;for(let o=0;o+1<e.length;o++)n+=Math.hypot(e[o+1].x-e[o].x,e[o+1].y-e[o].y);let r=tt(e,n===0?0:Math.min(1,t/n));return{x:r.x-e[0].x,y:r.y-e[0].y}}var DN=e=>Math.atan2(e.y,e.x);function d6(e,t){let n=(e-t)%gx;return n<=0?n+gx:n}function BN(e){let t=e[0],n=e[e.length-1];return Math.hypot(n.x-t.x,n.y-t.y)||Math.hypot(e[1].x-t.x,e[1].y-t.y)}function f6(e,t){let n=t[e.to];if(!n||n.length===0)return-1;if(n.length===1)return n[0].key;let r=u6(e.seg),o=l=>{let u=DN(l(r));return n.map(c=>d6(u,DN(l(c.seg))))},i=l=>{let u=l.slice().sort((c,d)=>c-d);return u[0]<yx||u[u.length-1]>gx-yx||u[1]-u[0]<yx},s=o(l6);if(i(s)){let l=.001*Math.min(BN(e.seg),...n.map(u=>BN(u.seg)));if(s=o(u=>c6(u,l)),i(s))return-1}let a=0;for(let l=1;l<s.length;l++)s[l]<s[a]&&(a=l);return n[a].key}function HN(e,t){if(e.source!==t.source||e.reversed!==t.reversed)return null;let[n,r]=e.reversed?[t,e]:[e,t];if(n.t1!==r.t0)return null;let o=n.t0,i=r.t1,s=n.seg[e.reversed?n.seg.length-1:0],a=r.seg[e.reversed?0:r.seg.length-1],l=o===0&&i===1?n.source.slice():bs(n.source,o,i,s,a);return l?(l[0]=s,l[l.length-1]=a,e.reversed&&l.reverse(),{...e,seg:l,from:e.from,to:t.to,t0:o,t1:i}):null}function p6(e){let t=[];for(let n of e){let r=t.length>0?HN(t[t.length-1],n):null;r?t[t.length-1]=r:t.push(n)}for(;t.length>1;){let n=HN(t[t.length-1],t[0]);if(!n)break;t.pop(),t[0]=n}return t.map(n=>n.seg)}function GN(e,t){let n=new Map,r=Array.from({length:t},()=>[]);if(e.forEach((a,l)=>{n.set(a.key,l),r[a.from].push(a)}),n.size!==e.length)return null;let o=e.map(a=>{let l=f6(a,r);return l<0?-1:n.get(l)});if(o.includes(-1))return null;let i=new Int32Array(e.length).fill(-1),s=[];for(let a=0;a<e.length;a++){if(i[a]>=0)continue;let l=[],u=a;do{if(i[u]>=0)return null;i[u]=s.length,l.push(u),u=o[u]}while(u!==a);let c=0;for(let d=1;d<l.length;d++)e[l[d]].key<e[l[c]].key&&(c=d);s.push(p6([...l.slice(c),...l.slice(0,c)].map(d=>e[d])))}return s}var h6=4096;function m6(e){let t=Qe(e);return t.kind==="polygon"&&t.commands.some(n=>n===xe||n===we)}function y6(e){return e.length<2?e:e[e.length-1].length===2?e.slice(0,-1):e}function g6(e){if(!e.some(m6))return null;let t=e.map(a=>iv(a)),n=t.reduce((a,l)=>a+l.reduce((u,c)=>u+c.length,0),0);if(n===0||n>h6)return null;let r=sv(t.flat())||1,o=MN(t,r*1e-6);if(!o)return null;let i=t.map((a,l)=>{let u=e[l];return FN(a,u.kind==="polygon"?u.fillRule:"nonzero")}),s=_N(o.edges,i,r*1e-7);return s?{edges:s,vertexCount:o.points.length,clockwise:t.map(w6)}:null}function b6(e,t){let n=new Map,r=(i,s)=>{let a=n.get(i);a?a.push(s):n.set(i,[s])};for(let{edge:i,inL:s,inR:a}of e.edges){let l=t(s),u=t(a);l!==u&&(l!==-1&&r(l,i),u!==-1&&r(u,LN(i)))}let o=new Map;for(let[i,s]of n){let a=GN(s,e.vertexCount);if(!a)return null;o.set(i,a)}return o}function x6(e,t){let n=t?e.map(P6):e;return yv(n.map(r=>({segs:y6(r),closed:!0})),"nonzero")}function UN(e,t){let n=g6(e);if(!n)return null;let r=b6(n,o=>t(o)?0:-1);return r?x6(r.get(0)??[],n.clockwise[0]):null}function w6(e){let t=0;for(let n of e){let r=Xk(n);Math.abs(r)>Math.abs(t)&&(t=r)}return t<0}function P6(e){let t=qk(e);return[t[t.length-1],...t.slice(0,-1)]}Fk();function T6(e,t){return Tg(t,hx(e))}function qf(e,t,n){if(e.length===0)return hx([]);let r=UN(e,t);if(r)return Tg(e,r);let[o,...i]=e.map(s=>RN(s));return T6(n(o,...i),e)}var S6=e=>e.includes(!0),k6=e=>!e.includes(!1),v6=e=>e[0]&&!e[1],A6=e=>e.filter(Boolean).length%2===1;function Xf(...e){return qf(e,S6,bu.default.union)}function bx(...e){return qf(e,k6,bu.default.intersection)}function xx(e,t){return qf([e,t],v6,bu.default.difference)}function wx(...e){return qf(e,A6,bu.default.xor)}Z();function WN(e){if(typeof e=="string")return e.length===0?[]:[{text:e}];for(let t=0;t<e.length;t++)if(typeof e[t]?.text!="string")throw new Error(`toRuns: run at index ${t} is missing string \`text\``);return e}Pe();function Px(e,t,n){if(!(t>0))return 0;let r=(Math.floor(e/t)+1)*t-e;return r<n?r+t:r}function VN(e,t,n,r,o,i){let s=0,a=e,l=u=>{u<=a||(i?.(a,u,s),s+=o(a,u))};for(let u of n){if(u<e)continue;if(u>=t)break;l(u);let{stop:c,min:d}=r(u);s+=Px(s,c,d),a=u+1}return l(t),s}function Sx(e,t){return e==="start"||e==="justify"?t==="rtl"?"right":"left":e==="end"?t==="rtl"?"left":"right":e}var zN={kind:"solid",color:"#000"};function Tx(e){return Ht(e)?e.color:"#000"}var KN="",jN="";function $N(e){return e!==KN&&(jN=`color-mix(in srgb, ${e} 25%, transparent)`,KN=e),jN}var Ie={fontSize:16,fontFamily:"sans-serif",fontWeight:400,fontStyle:"normal",align:"left",direction:"auto",lineHeight:1.2,tabSize:8,wrap:!1,fill:null,caretColor:Tx(zN),selectionBackground:$N(Tx(zN)),selectionColor:null,letterSpacing:0,underline:!1,strikethrough:!1,overline:!1,textTransform:"none",fontVariantCaps:"normal"};function kx(e,t,n=1){return!e&&Ne(t?.fill)===null&&(t?.stroke??void 0)===void 0?Ie:Qf({...Ie},e,t,n)}function Qf(e,t,n,r=1){let o=t??R6,i=Ne(n?.fill),s=n?.stroke??void 0,a=o.caretColor??Tx(i?.paint??null),l;o.selectionBackground==="none"?l=null:o.selectionBackground!=null?l=o.selectionBackground:l=$N(a),e.fontSize=Gt(o.fontSize??Ie.fontSize,r),e.fontFamily=o.fontFamily??Ie.fontFamily,e.fontWeight=o.fontWeight??Ie.fontWeight,e.fontStyle=o.fontStyle??Ie.fontStyle,e.align=o.align??Ie.align,e.direction=o.direction??Ie.direction,e.lineHeight=o.lineHeight??Ie.lineHeight,e.tabSize=o.tabSize??Ie.tabSize,e.wrap=o.wrap??Ie.wrap,e.fill=i,e.caretColor=a,e.selectionBackground=l,e.selectionColor=o.selectionColor??null,e.letterSpacing=Gt(o.letterSpacing??Ie.letterSpacing,r),e.underline=o.underline??Ie.underline,e.strikethrough=o.strikethrough??Ie.strikethrough,e.overline=o.overline??Ie.overline,e.textTransform=o.textTransform??Ie.textTransform,e.fontVariantCaps=o.fontVariantCaps??Ie.fontVariantCaps,(o.script!==void 0||e.script!==void 0)&&(e.script=o.script);let u=o.lang||void 0;return(u!==void 0||e.lang!==void 0)&&(e.lang=u),(s!==void 0||e.stroke!==void 0)&&(e.stroke=s),e}var R6=Object.freeze({});Pe();var N6=new Map([[223,"Ss"],[452,"\u01C5"],[453,"\u01C5"],[454,"\u01C5"],[455,"\u01C8"],[456,"\u01C8"],[457,"\u01C8"],[458,"\u01CB"],[459,"\u01CB"],[460,"\u01CB"],[497,"\u01F2"],[498,"\u01F2"],[499,"\u01F2"],[1415,"\u0535\u0582"],[64256,"Ff"],[64257,"Fi"],[64258,"Fl"],[64259,"Ffi"],[64260,"Ffl"],[64261,"St"],[64262,"St"],[64275,"\u0544\u0576"],[64276,"\u0544\u0565"],[64277,"\u0544\u056B"],[64278,"\u054E\u0576"],[64279,"\u0544\u056D"],[8115,"\u1FBC"],[8124,"\u1FBC"],[8131,"\u1FCC"],[8140,"\u1FCC"],[8179,"\u1FFC"],[8188,"\u1FFC"],[8114,"\u1FBA\u0345"],[8116,"\u0386\u0345"],[8119,"\u0391\u0342\u0345"],[8130,"\u1FCA\u0345"],[8132,"\u0389\u0345"],[8135,"\u0397\u0342\u0345"],[8178,"\u1FFA\u0345"],[8180,"\u038F\u0345"],[8183,"\u03A9\u0342\u0345"]]);function I6(e,t){let n=e.codePointAt(0);return n>=8064&&n<=8111?String.fromCodePoint(n|8):N6.get(n)??e.toLocaleUpperCase(t)}function vx(e){if(e)try{return Intl.getCanonicalLocales(e)[0]}catch{return}}var E6=/[\p{L}\p{N}][\p{L}\p{N}\p{M}\p{Pc}'’]*/gu;function M6(e){let t=new Set;if(typeof Intl<"u"&&"Segmenter"in Intl){let n=new Intl.Segmenter(void 0,{granularity:"word"});for(let r of n.segment(e))r.isWordLike&&t.add(r.index);return t}for(let n of e.matchAll(E6))t.add(n.index);return t}function YN(e,t,n){let r=0;for(let o of e)for(let i of o)r+=n(i).length;return r===t.length}function qN(e,t,n=[]){if(t.every(b=>b==="none"))return e.map(b=>({text:b}));let r=e.map((b,x)=>vx(n[x])),o=r.every(b=>b===r[0])?r[0]:void 0,i=(b,x=o)=>b.toLocaleUpperCase(x),s=(b,x=o)=>b.toLocaleLowerCase(x),a=e.join(""),l=t.includes("uppercase")?a.toLocaleUpperCase(o):"",u=t.includes("lowercase")?a.toLocaleLowerCase(o):"",c=l!==""&&YN(e,l,i),d=u!==""&&YN(e,u,s),f=t.includes("capitalize")?M6(a):null,p=[],h=0,m=0,g=0;for(let b=0;b<e.length;b++){let x=e[b],w=t[b]??"none",y=r[b],P=y===o,S="",v=[],A=[],N=!1,M=0;for(let C of x){let F=i(C),B=s(C),D=C;w==="uppercase"?D=c&&P?l.slice(m,m+F.length):i(C,y):w==="lowercase"?D=d&&P?u.slice(g,g+B.length):s(C,y):w==="capitalize"&&f.has(h+M)&&i(C,y)!==C&&(D=I6(C,y)),m+=F.length,g+=B.length,D.length!==C.length&&(N=!0),S+=D;for(let j=0;j<D.length;j++)v.push(M),A.push(M+C.length);M+=C.length}p.push(N?{text:S,srcMap:{length:x.length,starts:v,ends:A}}:{text:S}),h+=x.length}return p}var C6=.7;function O6(e){let t=e?.xHeight,n=e?.capHeight;return t===void 0||n===void 0||t>=n?C6:t/n}function XN(e,t,n){return O6(Yo(xn(e,t,n)))}function JN(e,t,n){let r=vx(n),o="",i=[],s=[],a=[],l=!1,u=!1,c=0;for(let f of e){let p=f.toLocaleUpperCase(r),h=p!==f,m=h?p:f;m.length!==f.length&&(l=!0),u||=h;let g=t?t.starts[c]:c,b=t?t.ends[c]:c+f.length;for(let x=0;x<m.length;x++)i.push(h),s.push(g),a.push(b);o+=m,c+=f.length}if(!u)return t?{text:e,srcMap:t}:{text:e};let d=l?{length:t?.length??e.length,starts:s,ends:a}:t;return{text:o,...d?{srcMap:d}:{},small:i}}var ZN=null;function eI(){return ZN}var QN=new WeakMap;function Ax(e){let{family:t,weight:n,style:r}=e.resolved,o=e.outlineFace??(e.source==="outline"?void 0:ll(t,n,r==="italic"?"italic":"normal"));if(!o)return null;let i=QN.get(o);return i===void 0&&(i=o.embedding?.()??null,QN.set(o,i)),i}function F6(e){return Ax(e)?.sfnt??null}function tI(e,t,n,r,o=ZN){if(o===null)return!1;let i=F6(xn(e,t,n));return i!==null&&o.hasFeature(i,r)}var L6=Object.freeze(["smcp"]),Zf=Object.freeze({super:Object.freeze({size:.583,shift:.333}),sub:Object.freeze({size:.583,shift:-.333})}),nI=new WeakMap;function rI(e){if(!e||!e.superscript&&!e.subscript)return Zf;let t=nI.get(e);return t||(t=Object.freeze({super:e.superscript??Zf.super,sub:e.subscript??Zf.sub}),nI.set(e,t)),t}function oI(e,t,n){return rI(Yo(xn(e,t,n)))}function iI(e){if(typeof e=="number")return e;if(e==="bold"||e==="bolder")return 700;if(e==="normal")return 400;let t=Number(e);return Number.isFinite(t)?t:400}function sI(e,t){return{fontFamily:e.fontFamily??t.fontFamily,fontWeight:e.fontWeight??(e.bold?700:iI(t.fontWeight)),fontStyle:e.italic?"italic":t.fontStyle}}function xu(e,t,n=1){return Rx(new Array(e.length),e,t,n)}function Rx(e,t,n,r=1){e.length!==t.length&&(e.length=t.length);let o=!1;for(let s of t)(s.textTransform??n.textTransform)!=="none"&&(o=!0);let i=o?qN(t.map(s=>s.text),t.map(s=>s.textTransform??n.textTransform),t.map(s=>s.lang??n.lang)):null;for(let s=0;s<t.length;s++){let a=t[s],l=i?i[s].text:a.text,u=i?.[s].srcMap,c=a.script??n.script,{fontFamily:d,fontWeight:f,fontStyle:p}=sI(a,n),h=c?oI(d,f,p)[c]:void 0,m=a.baselineShift??h?.shift??0,g=a.fontScale??h?.size??1,b=a.fontSize===void 0&&g!==1,x=a.fontSize!==void 0?Gt(a.fontSize,r):n.fontSize*g,w,y,P=(a.fontVariantCaps??n.fontVariantCaps)==="small-caps";if(P&&tI(d,f,p,"smcp"))y=L6;else if(P){let W=JN(l,u,a.lang??n.lang);if(l=W.text,u=W.srcMap,W.small){let J=x*XN(d,f,p);w=W.small.map(se=>se?J:x)}}let S=a.lang??n.lang,v=a.fill!==void 0?a.fill:n.fill,A=a.letterSpacing!==void 0?Gt(a.letterSpacing,r):n.letterSpacing,N=a.underline||n.underline,M=a.strikethrough||n.strikethrough,C=a.overline||n.overline,F=a.stroke??n.stroke,B=a.rotate&&Number.isFinite(a.rotate)?a.rotate:void 0,D=e[s];if(D!==void 0&&D.srcMap!==void 0==(u!==void 0)&&D.sizeMap!==void 0==(w!==void 0)&&D.stroke!==void 0==(F!==void 0)&&D.strutSize!==void 0===b&&D.rotate!==void 0==(B!==void 0)&&D.fontFeatures!==void 0==(y!==void 0)&&D.lang!==void 0==!!S){D.text=l,D.fontFamily=d,D.fontSize=x,D.fontWeight=f,D.fontStyle=p,D.fill=v,D.letterSpacing=A,D.underline=N,D.strikethrough=M,D.overline=C,D.baselineShift=m*n.fontSize,u&&(D.srcMap=u),w&&(D.sizeMap=w),F!==void 0&&(D.stroke=F),b&&(D.strutSize=n.fontSize),B!==void 0&&(D.rotate=B),y&&(D.fontFeatures=y),S&&(D.lang=S);continue}let j={text:l,fontFamily:d,fontSize:x,fontWeight:f,fontStyle:p,fill:v,letterSpacing:A,underline:N,strikethrough:M,overline:C,baselineShift:m*n.fontSize};u&&(j.srcMap=u),w&&(j.sizeMap=w),F!==void 0&&(j.stroke=F),b&&(j.strutSize=n.fontSize),B!==void 0&&(j.rotate=B),y&&(j.fontFeatures=y),S&&(j.lang=S),e[s]=j}return e}var aI=["underline","strikethrough","overline"],ep=Object.freeze({underline:Object.freeze({offset:.1,thickness:.05}),strikethrough:Object.freeze({offset:-.3,thickness:.05}),overline:Object.freeze({offset:-.9,thickness:.05})}),lI=new WeakMap;function _6(e){if(!e)return ep;let t=lI.get(e);if(!t){let n=e.underline??ep.underline;t=Object.freeze({underline:n,strikethrough:e.strikethrough??ep.strikethrough,overline:Object.freeze({offset:ep.overline.offset,thickness:n.thickness})}),lI.set(e,t)}return t}function D6(e,t,n,r){let o=_6(r)[e],i=t+n*o.offset;return{y0:i,y1:i+n*o.thickness}}function uI(e,t,n){let r=[],o=null,i=()=>{let s=o;if(o=null,!(!s||s.x1<=s.x0))for(let a of aI){if(!s.style[a])continue;let{y0:l,y1:u}=D6(a,s.baselineY,s.style.fontSize,s.face);r.push({kind:a,x0:s.x0,y0:l,x1:s.x1,y1:u,run:s.run})}};return{add(s){let a=e[s.run],l=a.underline||a.strikethrough||a.overline?n(s.run):null;if(l===null){o!==null&&i();return}let u=t(s.run);o!==null&&aI.every(d=>o.style[d]===a[d])&&o.style.fontSize===a.fontSize&&o.face===u&&o.baselineY===s.baselineY&&o.paint===l?o.x1=s.x+s.step:(i(),o={run:s.run,style:a,face:u,paint:l,baselineY:s.baselineY,x0:s.x,x1:s.x+s.step})},end(){return i(),r}}}function dI(e,t,n,r){let o=[],i=0;for(let a=0;a<=t.length;a++)a<t.length&&!n(a)||(a>i&&o.push({start:i,end:a,analysis:e.analyze(t.slice(i,a),r)}),i=a+1);let s=a=>{let l=0,u=o.length-1;for(;l<u;){let d=l+u>>1;o[d].end<=a?l=d+1:u=d}let c=o[l];return c!==void 0&&a>=c.start&&a<c.end?c:void 0};return{reorder(a,l){let u=s(a);if(u===void 0||l>u.end)return{order:[],levels:[]};let c=e.reorder(u.analysis,a-u.start,l-u.start);return{order:c.order.map(d=>d+u.start),levels:c.levels}},baseLevel(a){let l=s(a);return l===void 0?0:e.baseLevel(l.analysis)}}}function B6(e,t,n){if(e.length===t)return[...e];let r=new Set(e),o=[],i=new Map,s=-1,a=-1;for(let u=0;u<t;u++)if(r.has(u))s=u,a<0&&(a=u);else if(s<0)o.push(u);else{let c=i.get(s);c?c.push(u):i.set(s,[u])}if(a<0)return o;let l=[];for(let u of e){let c=i.get(u)??[],d=u===a?o:[];n(u)?l.push(...[...c].reverse(),u,...[...d].reverse()):l.push(...d,u,...c)}return l}var H6=1024,cI=[];function G6(e){let t=cI[e];if(t!==void 0)return t;let n={visual:Array.from({length:e},(r,o)=>o),levels:new Array(e).fill(0)};return e<=H6&&(cI[e]=n),n}function fI(e,t,n){return e===null||n===0?G6(n):U6(e,t,n)}function U6(e,t,n){let r=new Array(n).fill(0),o=e.reorder(t,t+n);for(let s=0;s<n;s++){let a=o.levels[s];typeof a=="number"&&a>=0&&(r[s]=a)}let i=new Set;for(let s of o.order){let a=s-t;Number.isInteger(a)&&a>=0&&a<n&&i.add(a)}return{visual:B6([...i],n,s=>r[s]%2===1),levels:r}}var Ix={};sG(Ix,{AK:()=>Rz,AL:()=>yz,AP:()=>Nz,AS:()=>Iz,B2:()=>tz,BA:()=>Z6,BB:()=>ez,BK:()=>V6,CB:()=>rz,CL:()=>oz,CLASS_MASK:()=>Fz,CM:()=>X6,CP:()=>iz,CR:()=>z6,EAST_ASIAN:()=>Lz,EB:()=>xz,EM:()=>wz,EX:()=>sz,GL:()=>Q6,H2:()=>Pz,H3:()=>Tz,HL:()=>gz,HY:()=>nz,ID:()=>bz,IN:()=>az,IS:()=>dz,JL:()=>Sz,JT:()=>vz,JV:()=>kz,LF:()=>K6,NL:()=>j6,NS:()=>lz,NU:()=>fz,OP:()=>uz,PICTOGRAPHIC_CN:()=>_z,PO:()=>pz,PR:()=>hz,QU:()=>cz,QU_PF:()=>Oz,QU_PI:()=>Cz,RI:()=>Az,SP:()=>$6,SY:()=>mz,UNICODE_VERSION:()=>W6,VF:()=>Ez,VI:()=>Mz,WJ:()=>J6,ZW:()=>Y6,ZWJ:()=>q6,lineBreakPropsOf:()=>Hz});var W6="16.0.0",V6=0,z6=1,K6=2,j6=3,$6=4,Y6=5,q6=6,X6=7,J6=8,Q6=9,Z6=10,ez=11,tz=12,nz=13,rz=14,oz=15,iz=16,sz=17,az=18,lz=19,uz=20,cz=21,dz=22,fz=23,pz=24,hz=25,mz=26,yz=27,gz=28,bz=29,xz=30,wz=31,Pz=32,Tz=33,Sz=34,kz=35,vz=36,Az=37,Rz=38,Nz=39,Iz=40,Ez=41,Mz=42,Cz=43,Oz=44,Fz=63,Lz=64,_z=128,pI="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+,-./:;<=>?@[]^_{|}~",Dz=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,35,36,37,38,39,40,41,42,43,44,71,73,74,79,81,82,83,84,88,89,91,93,94,95,96,97,98,155,157],hI=2787,mI="9H1K1C2A1B18H1E1R1V1b1Z1Y1b1V1U1Q1b1Z1W1N1W1a10X2W3b1R27b1U1Z1Q29b1U1K1P1b6H1D26H1J1U1Y3Z5b1n1b1K2b1Y1Z2b1L6b1o3b1U520b1L3b1L18b1L32b79H1J12H7J13H14b1W260b7H255b1W1K4b1Z1b45H1K1H1b2H1b2H1R1H8b27c4b4c13b6X3b3Y2W2b11H1R1H3R43b21H10X1Y2X3b1H99b1R1b7H1X1b6H2b2H1b4H2b10X23b1H30b27H91b11H15b10X33b9H4b1W1R3b1H2Z22b4H1b9H1b3H1b5H43b3H52b2X5b9H42b24H1X33H54b3H1b18H1b7H10b2H2K10X17b3H56b1H1b7H2b2H2b3H9b1H10b2H2b10X2b2Y5b1Y1b1Z2b1H2b3H56b1H1b5H4b2H2b3H3b1H20b10X2H3b1H11b3H56b1H1b8H1b3H1b3H20b2H2b10X1b1Z8b6H1b3H56b1H1b7H2b2H2b3H7b3H10b2H2b10X18b1H59b5H3b3H1b4H9b1H14b10X9b1Z6b5H55b1H1b7H1b3H1b4H7b2H11b2H2b10X7b1L9b3H1L55b1H1b7H1b3H1b4H7b2H11b2H2b10X3b1H12b4H55b2H1b7H1b3H1b4H9b1H10b2H2b10X9b1Y7b3H70b1H4b6H1b1H1b8H6b10X2b2H61b1H2b7H4b1Z7b8H1b10X2K85b1H2b9H11b7H1b10X39b4L1b2L1J2L1K1J5R1J1b1R3b2H6b10X10b1K1H1b1H1b1H1U1P1U1P2H49b14H1K5H1K2H5b11H1b36H1b2K6b1H9b2L1K1L5b2J80b20H1b10X2K10b4H4b3H1b3H2b7H3b4H13b12H1b1H10X4H98b96(72f88g349b3H1b1K158b1K639b1K26b1U1P78b3K36b4H28b3H2K27b2H30b2H64b32H2K1T1b1K1b1K1Z1b1H2b10X24b2R2K1L1b2R1b3H1J1H10X107b2H34b1H118b12H4b12H8b2R10X128b11X60b5H57b10H1b29H2b1H10X6b10X22b31H49b5H47i16H1m8i1b2K10k2K1d4K10d9H9d3K3H30b13H2b10X6b38k12H2l48b20H3b5K10X6b10X36b2K80b3H1b21H4b1H6b1H2b3H198b13H1J46H1J3H509b1L2b7K1J3K1F1H1G2H1K1J2K1M3b1n1o1U2n1o1U1n4b3S1K2A5H1J8Y1b1n1o1b2T6b1W1U1P3T12b1K1Y4K1b3K1I5b10H13b1U1P14b1U1P17b7Z1Y1Z1y12Z1Y4Z1Y2Z1Y1Z1Y15Z33H18b1Y5b1Y12b1Z251b2Z219b1S24b1U1P1U1P14b2!13b1w1s190b4z3b1!2d1!521b2z1b4d16b2!2b1d1b3d1e2d16b8z1b3d12b12z20b1d22b1!10b6z3b1z13b1z8b2z17b2!5d2!3d4b1d1z3d1b1d1!3b2d2b1d2b3d8b1!6b1d2!1d1!1b2d1e1!2b1!7d1z2b2d2#2e26b1z35b1z1b1z4b3z1b1z3b6V1b2R1d3b1U1P1U1P1U1P1U1P1U1P1U1P1U1P31b3z24b1z14b1z5b1U1P31b1U1P1U1P1U1P1U1P1U1P403b1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P63b1U1P1U1P32b1U1P285b2z51b1z4b1z409b3H7b1R3K1b1R1K112b1K14b1H96b32H2V1n1o1n1o3V1n1o1V1n1o8K1b1K1U1K2b1n1o2b1n1o1U1P1U1P1U1P1U1P4K1R1b2K1b2K5b2M3K1b2K1U8K1b1K1b2K3b2R1U1Q1U1Q1U1Q1U1Q1K34b26!1b89!12b214!26b16!1r2s2!1v2!1w1s1w1s1w1s1w1s1w1s2!1w1s1w1s1w1s1w1s1v1w2s10!6p5!1p5!2v2!1d1b1v1!1v1!1v1!1v1!1v25!1v31!1v1!1v1!1v6!1v6!2v2b2p4v1!2v1!1v1!1v1!1v1!1v25!1v31!1v1!1v1!1v6!1v6!2v4!4v1!5b43!1b94!1b86!9b1!16v31!1b40!8b7024!64z21013!1v1143!3b55!55b2K269b1K1R1K16b10X69b4H1b10H32b2H80b2H1b5K266b1H3b1H4b1H23b5H4b1H11b1Y59b2L2R8b2H50b18H8b2K10X6b18H10b1L2b1H10X28b8H2K23b13H12b29(3b4H47i13H1m6d3K4d1b1K10k4b2d5b1H10b10X6b41k14H9b3K1H8K2H2b10k2b1d3K27b3H50b1H1b3H2b2H5b2H1b1H41b5H2K3b2H236b8H1K2H2b10X6b1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&12b23f4b49g8452b512!29b1c1H10c1b13c1b5c1b1c1b2c1b2c1b10c494b1P1U188b1Y3b16H3s2v2t1w1s1u6b1J1H1J1H1J1H2J1H1J1H1J1H2J1H5!1w1s1w1s1w1s1w1s1w1s1w1s1w1s1w1s2!1w1s7!1s1!1s1b2v2t1!1w1s1w1s1w1s8!1b1!1y1x1!147b1I1b1t2!1y1x2!1w1s2!1s1!1s11!2v3!1t27!1w1!1s29!1w1!1s1!1w2s1w2s1v1!10v45!2v31!3b6!2b6!2b6!2b3!3b1x1y3!2y1b7z10b3H1O259b3K250b1H226b1H149b5H36b1K48b1K207b10X941b1K199b1K225b3H1b2H5b4H40b3H4b1H16b8K141b2H9b6K1S66b7K484b4H8b10X6b10X31b5H1K316b2H1K78b4H70b11H49b4H122b3H2j51i14H1m2K5d4b20d10k1H2i2H1i9b1J3H45b11H2b1X4K1H10b1X34b10X6b3H36b14H1b10X4K1b2H44b1H1b1L10b3H48b14H4b2K1b1K4H1b2H10X1b1L1b3K76b12H2K1b2K1b1H2b1H103b1K53b12H5b10X6b4H1b8i2b2i2b22i1b7i1b2i1b5i1b2H1K7H2b2H2b2H1m2b1k6b1H5b1K2k2i2H2b7H3b5H11b10k1b1k2b1k1b2k36i1b1d9H1b1H2b1H1b4H1b4H1m1j1H3d1b2d8b2H82b18H4b4K1b10X2K2b1H81b20H12b10X213b7H2b9H1L2K2R3b15K4b2H82b17H2K13b10X6b13L62b13H8b10X6b20X57b15H4b10X2b3K237b15H165b10X22b7i2b1i2b8i1b2i1b24i6H1b2H2b3H1m1j1H1j2H3K9b10k119b7H2b7H1b1L1b1H28b10H40b7H1b4H1L1b4K1L1b1H9b11H46b16H3K1b3L2K93b10L230b10X53b8H1b8H1b5K10b10X22b1L1R32b22H1b14H122b6H3b1H1b2H1b7H1b1H8b10X48b5H1b2H1b5H8b10X310b18k1K4H2K7b2H1j1H13i1b34i7H3b4H1m2K11d10k1H130b4Y30b1K1136b5K3555b3U3P36b1P3b1U1P1U1P239b1U2P179b1U7J1U1P3J1U1P1U1P1H6b15H4472b1U1P6960b30k18H10k2342b10X4b2K80b10X38b5H1K58b7H3K10b1K11b10X532b2K10X285b2K182b1H1b55H7b4H77b4v1q11b2p14b6136!8b768!470z41b1z9!8935b4z1b7z1b2z1b291!15b1v29b3v2b1v14b4v8b396!2465b2H1K4H4172b10X518b46H2b23H542b5H3b22H2b7H30b4H148b3H187b87z9b23z1111b50X512b55H4b50H8b1H14b1H2b4K16b5H1b15H1360b7H1b17H2b7H1b2H1b5H100b1H160b7H9b10X356b1H61b4H10X5b1Z492b4H10X244b2H1b10X725b7H109b7H5b10X4b2U844b1Y3b1Y847b4d1!39d4*100d12*15d2*15d1*14d1!1*37d10*142b1z2b10z19b56*26h3!13*44!4*9!7*2!14*6!154*33!12d9!1d70!1d7!1#14!8d2b2d21!2z5!1z5!3#2!1#2!1#2e2d5!12d17!3d1!3d3!5$63!1d1!1d2#2!11#21!19#3!1#4!3#1!3#7!1#1!1#14!1z1!1z1!1z5!1#4!1z1!2z74!2d1!7z16!14z13!12z12b1d4!1d24!12d2e4d1#21d1e4d2#13d1!47d8b24d6b1d74!3#3!5#38b3V3T4b35!1#16!3#9!1#5!6d1#3d3!2d3!4*4!11d2!3*4d9!3*116b3d4*5d85b5d6*12!4*1!15*12b4)56b8)10b6)40b8)30b2)12b4)2b62)12b1#2!1#8!8#6!1#9!10#1!1d3#7!1d48!1#61!2#1!2#1!1#17!3#1!13#34!84b12*14d2*13!3*10!5*52!3#1!7*15!2*11!6*9#7*240b10X6b1022*2b65534!2b65534!655363b1H30b96H128b240H196112b",Nx=null,yI=null,gI=null;function Bz(){let e=new Uint8Array(65536),t=new Int32Array(hI),n=new Uint8Array(hI),r=new Uint8Array(128);for(let a=0;a<pI.length;a++)r[pI.charCodeAt(a)]=Dz[a];let o=0,i=0,s=0;for(let a=0;a<mI.length;a++){let l=mI.charCodeAt(a);if(l<=57&&l>=48)s=s*10+l-48;else{let u=r[l];t[i]=o,n[i]=u,o<65536&&e.fill(u,o,Math.min(o+s,65536)),i++,o+=s,s=0}}Nx=e,yI=t,gI=n}function Hz(e){if(Nx===null&&Bz(),e<65536)return Nx[e];if(e>1114111)return 27;let t=yI,n=0,r=t.length-1;for(;n<r;){let o=n+r+1>>1;t[o]<=e?n=o:r=o-1}return gI[n]}var{lineBreakPropsOf:Vx,CLASS_MASK:zx,EAST_ASIAN:Gz,PICTOGRAPHIC_CN:Uz,BK:Wz,CR:AI,LF:RI,NL:Vz,SP:kr,ZW:$s,ZWJ:Lx,CM:bI,WJ:Ex,GL:wu,BA:Mx,BB:zz,B2:xI,HY:Pu,CB:Cx,CL:tp,CP:Tu,EX:wI,IN:Kz,NS:PI,OP:np,QU:_x,IS:go,NU:ln,PO:Ks,PR:js,SY:Su,AL:Kx,HL:sp,ID:jz,EB:NI,EM:II,H2:Dx,H3:Bx,JL:Hx,JV:ap,JT:lp,RI:Ox,AK:rp,AP:$z,AS:Fx,VF:TI,VI:SI,QU_PI:Gx,QU_PF:Ux}=Ix,ne=0,ku=1,EI=2,Yz=8208,op=9676,ip=e=>e===_x||e===Gx||e===Ux,ki=e=>e===Wz||e===AI||e===RI||e===Vz;function vi(e){return ki(Vx(e)&zx)}var Sr=e=>e===Kx||e===sp,kI=e=>e===Hx||e===ap||e===lp||e===Dx||e===Bx,vI=e=>e===jz||e===NI||e===II,jx=e=>({cls:new Uint8Array(e),ea:new Uint8Array(e),pict:new Uint8Array(e),cp:new Int32Array(e),start:new Int32Array(e)}),MI=65536,En=jx(64);function qz(e){return En.cls.length<e&&(En=jx(Math.min(MI,Math.max(e,En.cls.length*2)))),En}var CI=[],Wx=CI,Ae=En.cls,In=En.ea,vu=En.pict,xo=En.cp,Au=En.start,bo=0;function OI(e){return $x(e,new Uint8Array(e.length+1))}function $x(e,t){let n=e.length;for(let i=0;i<n;i++)t[i]=ne;if(n===0)return t[0]=ne,t;t[n]=EI;let r=n<=MI?qz(n):jx(n);Wx=e,{cls:Ae,ea:In,pict:vu,cp:xo,start:Au}=r;let o=0;for(let i=0;i<n;i++){let s=Vx(e[i]),a=s&zx;if((a===bI||a===Lx)&&o>0){let l=Ae[o-1];if(!ki(l)&&l!==kr&&l!==$s)continue}a===bI||a===Lx?(Ae[o]=Kx,In[o]=0,vu[o]=0):(Ae[o]=a,In[o]=s&Gz?1:0,vu[o]=s&Uz?1:0),xo[o]=e[i],Au[o]=i,o++}bo=o;for(let i=1;i<bo;i++)t[Au[i]]=Qz(i);return Wx=CI,r!==En&&({cls:Ae,ea:In,pict:vu,cp:xo,start:Au}=En),t}var Xz=e=>(Vx(Wx[Au[e]-1])&zx)===Lx;function Jz(e){for(;e>=0&&Ae[e]===kr;)e--;return e}function Qz(e){let t=e-1,n=Ae[t],r=Ae[e];if(n===AI&&r===RI)return ne;if(ki(n))return EI;if(ki(r)||r===kr||r===$s)return ne;let o=Jz(t);if(o>=0&&Ae[o]===$s)return ku;if(Xz(e)||n===Ex||r===Ex||n===wu||r===wu&&n!==kr&&n!==Mx&&n!==Pu||r===tp||r===Tu||r===wI||r===Su)return ne;let i=o>=0?Ae[o]:-1;if(i===np)return ne;if(i===Gx){let l=o-1;if(l<0)return ne;let u=Ae[l];if(ki(u)||u===np||ip(u)||u===wu||u===kr||u===$s)return ne}if(r===Ux){if(e+1>=bo)return ne;let l=Ae[e+1];if(l===kr||l===wu||l===Ex||l===tp||ip(l)||l===Tu||l===wI||l===go||l===Su||ki(l)||l===$s)return ne}if(n===kr&&r===go&&e+1<bo&&Ae[e+1]===ln)return ku;if(r===go||(i===tp||i===Tu)&&r===PI||i===xI&&r===xI)return ne;if(n===kr)return ku;if(r===_x||r===Ux||n===_x||n===Gx||ip(r)&&(!In[t]||e+1>=bo||!In[e+1])||ip(n)&&(!In[e]||t===0||!In[t-1]))return ne;if(n===Cx||r===Cx)return ku;if((n===Pu||xo[t]===Yz)&&r===Kx){if(t===0)return ne;let l=Ae[t-1];if(ki(l)||l===kr||l===$s||l===Cx||l===wu)return ne}if(r===Mx||r===Pu||r===PI||n===zz||t>0&&Ae[t-1]===sp&&(n===Pu||n===Mx&&!In[t])&&r!==sp||n===Su&&r===sp||r===Kz||Sr(n)&&r===ln||n===ln&&Sr(r)||n===js&&vI(r)||vI(n)&&r===Ks||(n===js||n===Ks)&&Sr(r)||Sr(n)&&(r===js||r===Ks))return ne;if(r===Ks||r===js){let l=n===tp||n===Tu?t-1:t;for(;l>=0&&(Ae[l]===Su||Ae[l]===go);)l--;if(l>=0&&Ae[l]===ln)return ne}if(n===Ks||n===js){if(r===ln)return ne;if(r===np&&e+1<bo){let l=Ae[e+1];if(l===ln||l===go&&e+2<bo&&Ae[e+2]===ln)return ne}}if((n===Pu||n===go)&&r===ln)return ne;if(r===ln){let l=t;for(;l>=0&&(Ae[l]===Su||Ae[l]===go);)l--;if(l>=0&&Ae[l]===ln)return ne}if(n===Hx&&(r===Hx||r===ap||r===Dx||r===Bx)||(n===ap||n===Dx)&&(r===ap||r===lp)||(n===lp||n===Bx)&&r===lp||kI(n)&&r===Ks||n===js&&kI(r)||Sr(n)&&Sr(r))return ne;let s=n===rp||n===Fx||xo[t]===op,a=r===rp||r===Fx||xo[e]===op;if(n===$z&&a||s&&(r===TI||r===SI)||n===SI&&t>0&&(Ae[t-1]===rp||Ae[t-1]===Fx||xo[t-1]===op)&&(r===rp||xo[e]===op)||s&&a&&e+1<bo&&Ae[e+1]===TI||n===go&&Sr(r)||(Sr(n)||n===ln)&&r===np&&!In[e]||n===Tu&&!In[t]&&(Sr(r)||r===ln))return ne;if(n===Ox&&r===Ox){let l=t;for(;l>=0&&Ae[l]===Ox;)l--;if((t-l)%2===1)return ne}return r===II&&(n===NI||vu[t])?ne:ku}var Zz=null;function LI(){return Zz}function _I(e){return e%2===1?"rtl":"ltr"}var e7=[[1424,1535],[1536,1983],[2144,2303],[64285,65023],[65136,65279],[67584,69631],[124928,126975]],t7=[[1536,1541],[1632,1644],[1757,1757],[1776,1785],[2274,2274],[68912,68921],[69216,69246]],n7=[[1548,1548],[64830,64831],[65279,65279]];function Yx(e,t){for(let n=0;n<e.length;n++)if(t>=e[n][0]&&t<=e[n][1])return!0;return!1}var FI=!1;function DI(e,t="weasel layoutRuns"){if(!FI)for(let n=0;n<e.length;n++){let r=e[n];if(!(!Yx(e7,r)||Yx(t7,r)||Yx(n7,r))){FI=!0,console.warn(`${t}: this text contains right-to-left characters but no \`bidi\` engine is registered, so it is being laid out in logical order \u2014 the glyphs will appear reversed. Import \`bidi\` out of the \`@weasel-js/bidi\` package and call \`registerBidi(bidi)\` once at startup.`);return}}}var Ru=[.5];function Ai(e){if(e>65536)return new Array(e).fill(.5);for(;Ru.length<e;)Ru=Ru.concat(Ru);return Ru.slice(0,e)}var r7=1<<18,BI=new Map,HI=new Map,qx=0;function GI(e,t){let n=e.get(t);if(n===void 0||n.n===0)return;qx-=t;let r=n.items[--n.n];return n.items[n.n]=void 0,r}function UI(e,t){let n=t.length;if(n===0||qx+n>r7)return;let r=e.get(n);r===void 0&&e.set(n,r={items:[],n:0}),r.items[r.n++]=t,qx+=n}function Nu(e){return GI(BI,e)??Ai(e)}function Xx(e){return GI(HI,e)??new Array(e)}function up(e){UI(BI,e)}function WI(e){UI(HI,e)}function gt(e,t){for(;e.length>t;)e.pop()}var vr=13,Jx=0,cp=1,VI=2,zI=3,KI=4,jI=5,$I=6,Qx=7,YI=8,Zx=9,qI=10,XI=11,JI=12,e0=1,QI=2,dp=5,o7=[],i7=[],t0=[],s7=1024,a7=0,fp=class e{num;ref;boxes=[];bounds={width:.5,height:.5};laid=null;stamp=0;paintings=[];owners=0;listed=!1;pinned=!1;constructor(t){this.num=Nu(t*vr),this.ref=Xx(t*dp)}static take(t){let n=t0.pop();return n===void 0?n=new e(t):(n.num=Nu(t*vr),n.ref=Xx(t*dp)),n.stamp=++a7,n}recycle(){up(this.num);let{ref:t}=this;for(let n=0;n<t.length;n++)t[n]=void 0;WI(t),this.num=o7,this.ref=i7,gt(this.paintings,0),this.owners=0,this.listed=!1,this.pinned=!1,t0.length<s7&&t0.push(this)}set(t,n,r,o,i,s){let a=t*vr,l=t*dp,{num:u,ref:c}=this;u[a+Jx]=o,u[a+cp]=i,u[a+VI]=n.advance,u[a+zI]=n.fontSize,u[a+KI]=s,u[a+jI]=n.srcIndex,u[a+$I]=n.srcEnd,u[a+Qx]=n.cp,u[a+YI]=r,u[a+qI]=n.run,u[a+JI]=n.rotate,u[a+Zx]=(n.drawsInk?e0:0)|(n.clusterEnd?QI:0),c[l]=n.resolved,c[l+1]=n.metrics,c[l+2]=n.font,c[l+3]=n.glyph,c[l+4]=n.shaped}widen(t,n){this.num[t*vr+cp]+=n}setVisual(t,n,r){this.num[(t+n)*vr+XI]=r}visual(t,n){return this.num[(t+n)*vr+XI]}glyph(t,n,r){let o=t+n,i=o*vr,s=o*dp,{num:a,ref:l}=this;return r.run=a[i+qI],r.cell=n,r.cp=a[i+Qx],r.fontSize=a[i+zI],r.resolved=l[s],r.metrics=l[s+1],r.font=l[s+2],r.glyph=l[s+3],r.shaped=l[s+4],r.x=a[i+Jx],r.baselineY=a[i+KI],r.advance=a[i+VI],r.step=a[i+cp],r.rotate=a[i+JI],r}drawsInk(t,n){return(this.num[(t+n)*vr+Zx]&e0)!==0}cell(t,n){let r=(t+n)*vr,{num:o}=this,i=o[r+Zx];return{srcIndex:o[r+jI],srcEnd:o[r+$I],cp:o[r+Qx],x:o[r+Jx],advance:o[r+cp],level:o[r+YI],drawsInk:(i&e0)!==0,clusterEnd:(i&QI)!==0}}};function n0(){return{run:0,cell:0,cp:0,fontSize:.5,resolved:null,metrics:null,font:null,glyph:null,shaped:null,x:.5,baselineY:.5,advance:.5,step:.5,rotate:.5}}var Pt=class e{#t;#n;#e;#r=!1;constructor(t,n,r,o,i,s,a,l,u,c){this.x0=t,this.y0=n,this.x1=r,this.y1=o,this.baselineY=i,this.srcEnd=s,this.justified=a,this.#t=l,this.#n=u,this.#e=c,Object.defineProperties(this,e.#o)}refill(t,n,r,o,i,s,a,l,u){return this.x0=t,this.y0=n,this.x1=r,this.y1=o,this.baselineY=i,this.srcEnd=s,this.justified=a,this.#n=l,this.#e=u,this.#r&&(this.#r=!1,Object.defineProperties(this,e.#o)),this}static columns(t){return t instanceof e?t.#t:null}static start(t){return t instanceof e?t.#n:0}static count(t){return t instanceof e?t.#e:t.glyphs.length}static#o={cells:pp("cells",t=>{t.#r=!0;let n=new Array(t.#e);for(let r=0;r<t.#e;r++)n[r]=t.#t.cell(t.#n,r);return n}),glyphs:pp("glyphs",t=>{t.#r=!0;let n=new Array(t.#e);for(let r=0;r<t.#e;r++)n[r]=t.#t.glyph(t.#n,t.#t.visual(t.#n,r),n0());return n})}};function pp(e,t){return{enumerable:!0,configurable:!0,get(){let n=t(this);return Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!1}),n}}}var r0,l7=/[\r\u0300-\uffff]/;function u7(){return r0===void 0&&(r0=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null),r0}function mp(e,t){let n=t??[],r=0;if(l7.test(e)){let o=u7();if(o)r=c7(o,e,n);else{let i=0;for(let s of e)n[r++]=i+=s.length}}else for(let o=1;o<=e.length;o++)n[r++]=o;return n.length=r,n}var hp=e=>e<768&&e!==13;function c7(e,t,n){let r=t.length,o=null,i=0,s=0;for(;s<r;){if(hp(t.charCodeAt(s))&&(s+1===r||hp(t.charCodeAt(s+1)))){n[i++]=++s;continue}let a=s+1;for(;;){for(;a<r&&!hp(t.charCodeAt(a));)a++;if(a===r||(a++,a===r||hp(t.charCodeAt(a))))break}for(o??=e.segment(t);s<a;){let l=o.containing(s);n[i++]=s=l.index+l.segment.length}}return i}var tE=Object.freeze({d:null,key:"",glyphs:Object.freeze([]),rtl:!1,text:""}),ZI=Object.freeze({cluster:tE,advance:0}),d7=new WeakMap,f7=new WeakMap,eE=e=>String(Math.round(e*1e5)/1e5);function nE(e,t,n){if(n===null)return null;let r=Ax(t);if(r===null)return null;let o=r.sfnt,i=n.shape(o,e.text,e.fontFeatures,e.lang),s=t.source==="outline"?d7:f7,a=s.get(i);if(a)return a;let l=t.source==="outline"?null:u=>r.glyphIndexOf(u);return a=p7(n,o,e.text,i,l),s.set(i,a),a}function p7(e,t,n,r,o){let i=new Array(n.length),s=mp(n),a=0,l=0;for(;l<r.length;){let u=r[l].cluster,c=l;for(;c<r.length&&r[c].cluster===u;)c++;let d=c<r.length?r[c].cluster:n.length;for(;a<s.length&&s[a]<=u;)a++;let f=0;for(let p=a;p<s.length&&s[p]<d;p++)f++;if(!y7(r,l,c)&&!(o&&h7(r[l],c-l,n,u,d,o))){let p=m7(r,l,c),h=p/(f+1),m=r[l].rtl?h-p:0;i[u]=g7(e,t,r,l,c,n.slice(u,d),m,h);let g=h===0?ZI:{cluster:tE,advance:h};for(let b=u+1,x=a;b<d;b++){let w=x<s.length&&s[x]===b;w&&x++,i[b]=w?g:ZI}}l=c}return i}function h7(e,t,n,r,o,i){if(t!==1||e.dx!==0||e.dy!==0)return!1;let s=n.codePointAt(r);return o-r===(s>65535?2:1)&&i(s)===e.gid}function m7(e,t,n){let r=0;for(let o=t;o<n;o++)r+=e[o].advance;return r}function y7(e,t,n){for(let r=t;r<n;r++)if(e[r].gid===0)return!0;return!1}function g7(e,t,n,r,o,i,s,a){let l=[],u=s,c="",d="";for(let f=r;f<o;f++){let p=n[f],h=u+p.dx,m=p.dy;l.push({gid:p.gid,x:h,y:m,advance:p.advance}),c+=e.glyphD(t,p.gid,h,m)??"",d+=`${f===r?"":";"}${p.gid}${h===0&&m===0?"":`@${eE(h)},${eE(m)}`}`,u+=p.advance}return{cluster:{d:c.length>0?c:null,key:d,glyphs:l,rtl:n[r].rtl,text:i},advance:a}}var b7=/^[\p{Mn}\p{Me}]$/u;function iE(e,t,n,r,o=null){let i=r??[],s=0,a,l=0;for(let u=0;u<e.length;u++){let c=e[u],d=xn(c.fontFamily,c.fontWeight,c.fontStyle),f=as(d);if(!f){Hy(c.fontFamily,c.fontWeight,c.fontStyle),l+=c.srcMap?.length??c.text.length,a=void 0;continue}let p=l,h=c.srcMap,m=mp(c.text,w7),g=nE(c,d,o),b=0,x=0,w=null,y=0,P=c.text;for(;y<P.length;){let S=P.codePointAt(y),v=S>65535?2:1,A=g?.[y],N=c.sizeMap?c.sizeMap[y]:c.fontSize;y===x&&(w=Gy(d,c.fontFamily,c.fontWeight,c.fontStyle,c.text.slice(y,m[b])));let M=y+v===m[b];M&&(x=m[b++]);let C=M?c.letterSpacing:0,F=h?p+h.starts[y]:p+y,B=h?p+h.ends[y]:p+y+v;y+=v,l=h?p+h.length:B;let D=x7(S),j=a&&!D?a.metrics.kernOf(a.cp,S)*(a.fontSize/a.metrics.size):0,W=T7(n,s,u,c,S,N,F,B,M,d,f);if(w)M&&(W.tracking=C,oE(W,w)),i[s++]=W,a=void 0;else if(vi(S))i[s++]=W,a=void 0;else if(S===9||S===32){let J=f.advanceOf(32),se=J!==null?J*(N/f.size):N*.25;if(S===9)i[s++]={...W,tab:{stop:t*(se+c.letterSpacing),min:se/2}},a=void 0;else{let ke=dl(d,32,rE);W.font=ke?.font??null,W.glyph=ke?.glyph??null,W.advance=se,W.tracking=C,W.kerningBefore=j,a=W,i[s++]=a}}else if(A!==void 0)W.tracking=C,i[s++]=S7(W,A),a=void 0;else{let J=fl(d,c.fontFamily,c.fontWeight,c.fontStyle,S,!0,rE);J&&(W.kerningBefore=j,W.tracking=C,oE(W,J)),i[s++]=W,D||(a=W)}}}return i.length=s,i}function x7(e){return e>=768&&b7.test(String.fromCodePoint(e))}var w7=[],rE={resolved:null,metrics:null,advance:0,font:null,glyph:null},P7=4096;function T7(e,t,n,r,o,i,s,a,l,u,c){let d=Math.max(r.fontSize,r.strutSize??0),f=r.baselineShift??0,p=r.rotate??0,h=e?.[t];if(!h){let m={run:n,cp:o,fontSize:i,lineSize:d,baselineShift:f,rotate:p,srcIndex:s,srcEnd:a,clusterEnd:l,resolved:u,metrics:c,font:null,glyph:null,advance:0,tracking:0,kerningBefore:0,tab:void 0,shaped:null,drawsInk:!1};return e&&t<P7&&(e[t]=m),m}return h.run=n,h.cp=o,h.fontSize=i,h.lineSize=d,h.baselineShift=f,h.rotate=p,h.srcIndex=s,h.srcEnd=a,h.clusterEnd=l,h.resolved=u,h.metrics=c,h.font=null,h.glyph=null,h.advance=0,h.tracking=0,h.kerningBefore=0,h.tab=void 0,h.shaped=null,h.drawsInk=!1,h}function oE(e,t){e.resolved=t.resolved,e.metrics=t.metrics,e.font=t.font,e.glyph=t.glyph,e.advance=t.advance*(e.fontSize/t.metrics.size),e.drawsInk=!0}function S7(e,t){return e.shaped=t.cluster,e.advance=t.advance*e.fontSize,e.drawsInk=t.cluster.d!==null,e}function sE(e,t,n,r){return e.map((o,i)=>{let s=t[i]%2===1;if(o.shaped!==null&&o.shaped.rtl!==s){let c=n(o.cp);c!==null&&c!==o.cp&&(o=k7(o,r[o.run]))}if(!s||o.shaped!==null)return o;let a=n(o.cp);if(a===null||a===o.cp)return o;if(o.font===null)return{...o,cp:a};let l=r[o.run],u=fl(o.resolved,l.fontFamily,l.fontWeight,l.fontStyle,a,!1);return u?{...o,cp:a,resolved:u.resolved,metrics:u.metrics,font:u.font,glyph:u.glyph}:o})}function k7(e,t){if(e.resolved.source==="outline")return{...e,shaped:null};let n=fl(e.resolved,t.fontFamily,t.fontWeight,t.fontStyle,e.cp,!1);return n?{...e,shaped:null,resolved:n.resolved,metrics:n.metrics,font:n.font,glyph:n.glyph}:{...e,shaped:null}}var gp=e=>e===32||e===9;var yp=new Uint8Array(64),o0=!1,v7=65536;function aE(e,t,n,r){let o=e.length;if(!Number.isFinite(t.maxWidth))i0(e,t,n,r,null);else if(o0||o>=v7)i0(e,t,n,r,OI(e));else{yp.length<o+1&&(yp=new Uint8Array(Math.max(o+1,yp.length*2))),o0=!0;try{i0(e,t,n,r,$x(e,yp))}finally{o0=!1}}}function i0(e,t,n,r,o){let i=e.length,s=0,a=0;for(;a<i;){let l=e[a];if(vi(l)){r(s,a,!1),a+=l===13&&e[a+1]===10?2:1,s=a;continue}if(gp(l)){a++;continue}let u=a+1,c=a+1;for(;u<i&&!vi(e[u])&&(!o||o[u]===ne);)gp(e[u])||(c=u+1),u++;o&&a>s&&n(s,c)>t.maxWidth&&(r(s,a,!0),s=a),a=u}s<i&&r(s,i,!1)}function lE(e,t){let n=e.lineSize/e.metrics.size,r=e.metrics.ascent*n;return e.metrics.descent===void 0?r:(e.lineSize*t-r-e.metrics.descent*n)/2+r}var cE=[],Eu=cE,Ri=Ai(64),a0=[],Iu=[],l0=0,uE=[],A7=64;function dE(e,t){return Eu[e].advance+Eu[e].tracking+Ri[t]-Ri[e+1]}var R7=e=>Eu[e].tab;function N7(e,t){return VN(e,t,a0,R7,dE)}function I7(e,t,n){let r=l0++,o=uE[r];o===void 0&&(o={start:0,entries:[],width:.5,height:.5,ascent:.5,wrapped:!1,srcEnd:0,end:0},r<A7&&(uE[r]=o)),o.start=e,o.end=t,o.wrapped=n,o.width=0,o.height=0,o.ascent=0,o.srcEnd=0,Iu[r]=o}function fE(e,t,n){let{lineHeight:r}=n;Ri.length<e.length+1&&(Ri=Ai(e.length+1)),Ri[0]=0;let o=0;l0=0;for(let i=0;i<e.length;i++){let s=e[i];Ri[i+1]=Ri[i]+s.kerningBefore+s.advance+s.tracking,s.tab&&(a0[o++]=i)}a0.length=o,Eu=e,aE(t,n,o===0?dE:N7,I7),Eu=cE,Iu.length=l0;for(let i=0;i<Iu.length;i++){let s=Iu[i];if(s.start===s.end){let l=e[s.end];s.height=l.lineSize*r,s.ascent=lE(l,r),s.srcEnd=l.srcIndex,gt(s.entries,0);continue}let a=s.entries;for(let l=s.start;l<s.end;l++){let u=e[l];l===s.start&&(u.kerningBefore=0),u.tab&&(u.advance=Px(s.width,u.tab.stop,u.tab.min)),a[l-s.start]=u,s.width+=u.kerningBefore+u.advance+u.tracking,s.height=Math.max(s.height,u.lineSize*r),s.ascent=Math.max(s.ascent,lE(u,r))}a.length=s.end-s.start,s.srcEnd=e[s.end-1].srcEnd}return Iu}function E7(e){let t=0;for(let n=e.length-1;n>=0&&gp(e[n].cp);n--){let r=e[n];t+=r.kerningBefore+r.advance+r.tracking}return t}function M7(e){let t=new Set,n=0;for(;n<e.length&&e[n].cp===32;)n++;let r=e.length-1;for(;r>n&&e[r].cp===32;)r--;for(let o=n+1;o<r;o++)e[o].cp===32&&t.add(o);return t}function C7(e,t,n){if(e==="left")return 0;if(!Number.isFinite(t))return e==="center"?-n/2:-n;let r=t-n;return e==="center"?r/2:r}var O7=new Set,s0={box:null,inkWidth:.5};function pE(e,t,n,r,o,i,s,a){let{alignWidth:l,justify:u}=o,{entries:c}=e,d=E7(c),f=e.width-d,p=l-f,h=u&&e.wrapped&&Number.isFinite(l)&&p>0?M7(c):O7,m=h.size>0?p/h.size:0,g=m*h.size,b=g>0?0:C7(r,l,f),w=d>0&&n.levels[c.length-1]%2===1?b-d:b,y=t+e.ascent,P=w,S=-1,v=-1,A=0,{visual:N}=n;for(let B=0;B<N.length;B++){let D=N[B],j=c[D],W=S<0?0:D===S+1?j.kerningBefore:S===D+1?c[S].kerningBefore:0;W!==0&&i.widen(s+(v>=0?v:S),W),P+=W,S=D;let J=j.advance+j.tracking+(h.has(D)?m:0);J!==0&&(v=D),i.set(s+D,j,n.levels[D],P,J,y-j.baselineShift),i.setVisual(s,A++,D),P+=J}let M=w+e.width+g,C=t+e.height,F=i.boxes[a];return s0.box=F!==void 0?F.refill(w,t,M,C,y,e.srcEnd,g>0,s,c.length):i.boxes[a]=new Pt(w,t,M,C,y,e.srcEnd,g>0,i,s,c.length),s0.inkWidth=f+g,s0}function u0(e,t={maxWidth:0,alignWidth:0,lineHeight:0,align:"left",justify:!1,bidi:null,shaper:null,direction:"auto",tabSize:0}){return t.maxWidth=e.maxWidth,bp(t,e),t.lineHeight=e.lineHeight,t.align=e.align,t.justify=e.justify===!0||e.align==="justify",t.bidi=c0(e),t.shaper=Mu(e),t.direction=e.direction??"auto",t.tabSize=e.tabSize??8,t}function bp(e,t){t.alignWidth===void 0?e.alignWidth=t.maxWidth:e.alignWidth=t.alignWidth}function c0(e){return e.bidi??LI()}function Mu(e){return e.shaper??eI()}var F7=[],L7=[],hE=[],_7=u0({maxWidth:0,lineHeight:0,align:"left"}),D7={maxWidth:.5,alignWidth:.5,lineHeight:.5,justify:!1},B7=e=>vi(hE[e]);function H7(e,t,n,r){return sE(t,n,o=>e.mirror(o),r)}function mE(e,t){let{maxWidth:n,alignWidth:r,lineHeight:o,align:i,justify:s,bidi:a,shaper:l,direction:u,tabSize:c}=u0(t,_7),d=iE(e,c,F7,L7,l),f=hE;f.length=d.length;for(let S=0;S<d.length;S++)f[S]=d[S].cp;let p=a?dI(a,f,B7,u):null;a||DI(f);let h=D7;h.maxWidth=n,h.alignWidth=r,h.lineHeight=o,h.justify=s;let m=fE(d,f,h),g=0;for(let S=0;S<m.length;S++)g+=m[S].entries.length;let b=m.length>0?fp.take(g):null,x=b!==null?b.boxes:[],w=0,y=0,P=0;for(let S=0;S<m.length;S++){let v=m[S],A=fI(p,v.start,v.entries.length);a&&(v.entries=H7(a,v.entries,A.levels,e));let N=u!=="auto"?u:_I(v.entries.length>0?p?.baseLevel(v.start)??0:0),M=pE(v,w,A,Sx(i,N),h,b,P,S);P+=v.entries.length,y=Math.max(y,M.inkWidth),w+=v.height}return x.length=m.length,b===null?{lines:x,bounds:{width:y,height:w}}:(b.bounds.width=y,b.bounds.height=w,b.laid??={lines:x,bounds:b.bounds})}Pe();Pe();var Ar=11;function yE(e){let{font:t,glyph:n}=e;return t!==null&&n!==null&&n.width!==0&&n.page>=0}function d0(e,t,n){let r=e.font,o=e.glyph,i=e.fontSize/e.metrics.size,s=e.x+o.xoffset*i,a=e.baselineY+(o.yoffset-e.metrics.base)*i;t[n]=s,t[n+1]=a,t[n+2]=s+o.width*i,t[n+3]=a+o.height*i,t[n+4]=o.x/r.common.scaleW,t[n+5]=o.y/r.common.scaleH,t[n+6]=(o.x+o.width)/r.common.scaleW,t[n+7]=(o.y+o.height)/r.common.scaleH,t[n+8]=e.baselineY,t[n+9]=e.x,t[n+10]=e.rotate??0}var f0=new WeakSet,gE={quads:pp("quads",e=>{f0.add(e);let t=e.quadData,n=[];for(let r=0,o=0;r<t.length;r+=Ar,o++){let i={x0:t[r],y0:t[r+1],x1:t[r+2],y1:t[r+3],u0:t[r+4],v0:t[r+5],u1:t[r+6],v1:t[r+7],baselineY:t[r+8],penX:t[r+9],rotate:t[r+10]};e.colorGlyphs&&(i.colorGlyph=e.colorGlyphs[o]),n.push(i)}return n})};function wE(e,t){return t==="outline"&&xr(e.stroke)?e.stroke:void 0}function bE(e,t){return`${fo(e.fill?.paint)}|${Vl(wE(e,t))}`}function h0(e,t,n){let{family:r,weight:o,style:i}=t.resolved.resolved,{synthetic:s}=t.resolved,a=n==="outline"?0:t.glyph.page;if(qe.group!==null&&qe.run===t.run&&qe.source===n&&qe.page===a&&qe.family===r&&qe.weight===o&&qe.style===i&&qe.bold===s.bold&&qe.italic===s.italic)return qe.group;let l=e[t.run],u=null,c=null;for(let d=0;d<wo.length;d++){let f=wo[d],p=f.group;if(!(p.source!==n||p.page!==a||p.family!==r||p.weight!==o||p.style!==i||p.synthetic.bold!==s.bold||p.synthetic.italic!==s.italic)&&!(f.run!==t.run&&(c??=bE(l,n),f.paint??=bE(e[f.run],n),f.paint!==c))){u=p;break}}if(u===null){let d=wE(l,n);u=d===void 0&&n!=="color"?p0.pop()??null:null,u!==null?(u.family=r,u.weight=o,u.style=i,u.synthetic.bold=s.bold,u.synthetic.italic=s.italic,u.source=n,u.page=a,u.fill=l.fill):(u=Object.defineProperties({family:r,weight:o,style:i,synthetic:{bold:s.bold,italic:s.italic},source:n,page:a,fill:l.fill,quadData:Ys,glyphs:[]},gE),d&&(u.stroke=d),n==="color"&&(u.colorGlyphs=[]));let f=wo.length,p=xE[f];p===void 0?(p={group:u,run:t.run,paint:c},f<U7&&(xE[f]=p)):(p.group=u,p.run=t.run,p.paint=c),wo.push(p)}return qe.group=u,qe.run=t.run,qe.family=r,qe.weight=o,qe.style=i,qe.bold=s.bold,qe.italic=s.italic,qe.source=n,qe.page=a,u}var Ys=[],p0=[],G7=1024;function PE(e){p0.length>=G7||e.stroke!==void 0||e.colorGlyphs!==void 0||f0.has(e)||(e.quadData=Ys,gt(e.glyphs,0),p0.push(e))}var wo=[],xE=[],U7=64,qe={group:null,run:-1,family:"",weight:0,style:"normal",bold:!1,italic:!1,source:"atlas",page:0};function TE(e){for(let t=0;t<wo.length;t++)e.push(wo[t].group),wo[t].group=null;gt(wo,0),qe.group=null}Pe();Z();var SE=5e-4,kE=4096,xp=new Map,wp=new Map;function vE(e){if(!e.synthetic.bold)return null;let{source:t}=e;if(t!=="atlas"&&t!=="canvas")return null;let{family:n,weight:r,style:o}=e.resolved,i=jy(t,n,r,o);return i===void 0||!(i>0)?null:{growth:i,join:t==="atlas"?"miter":"round"}}function W7(e,t,n){let r=vE(n);if(r===null)return e;let o=`${r.growth}|${r.join}|${t}`,i=xp.get(o);return i||(i=Gg(Bg(e,r.growth,{join:r.join,tolerance:SE}),{tolerance:SE}),xp.size>=kE&&xp.clear(),xp.set(o,i),i)}function AE(e,t){let n=vE(t);if(n===null)return null;let r=`bold:${n.growth}:${n.join}`,o=`${r}|${e}`,i=wp.get(o);return i===void 0&&(i=gg(W7(si(e),e,t)),wp.size>=kE&&wp.clear(),wp.set(o,i)),{d:i,tag:r}}function RE(e,t,n,r=!1){let o=e.resolved.source==="outline";if(!o&&!r&&(n===void 0||t.fontSize<n&&!xr(t.stroke)))return null;let i=V7(e);if(i===null)return null;let{family:s,weight:a,style:l}=e.resolved.resolved,u=e.shaped?`${s}|${a}|${l}|#${e.shaped.key}`:`${s}|${a}|${l}|${e.cp}`;if(o||!e.resolved.synthetic.bold)return{d:i,key:u};let c=AE(i,e.resolved);return c&&{d:c.d,key:`${u}|${c.tag}`}}function V7(e){if(e.shaped)return e.shaped.d;if(e.glyph?.color)return null;let{family:t,weight:n,style:r}=e.resolved.resolved;return e.resolved.source!=="outline"&&e.glyph===null?null:Ey(t,n,r,e.cp)}function z7(e){let t=e.resolved.dynamicFace,n=e.shaped;if(!t||n.d===null)return null;let r=t.requestShaped(n.key,n.d);return!r||r.page<0||r.width===0?null:{...e,font:t.font,glyph:r}}function K7(e){let t=e.map(n=>Yo(xn(n.fontFamily,n.fontWeight,n.fontStyle)));return n=>t[n]}var j7=e=>e.underline||e.strikethrough||e.overline;function $7(e){return t=>sf(e[t].fill)?fo(e[t].fill.paint):null}var Y7=n0(),Cu=[],NE=16384;function m0(e,t,n,r){let{groups:o,decorations:i}=r;gt(o,0),gt(i,0);let s=t.some(j7)?K7(t):null,a=s&&$7(t),l=0,{lines:u}=e;for(let h=0;h<u.length;h++)l+=Pt.count(u[h]);let c=l*Ar;c<=NE&&Cu.length<c&&(Cu=Ai(c));let d=c<=NE?Cu:Ai(c),f=null,p=0;for(let h=0;h<u.length;h++){let m=u[h],g=Pt.columns(m),b=g!==null?Pt.start(m):0,x=Pt.count(m),w=s&&uI(t,s,a);for(let y=0;y<x;y++){let P=g!==null?g.visual(b,y):-1,S=g!==null?g.glyph(b,P,Y7):m.glyphs[y];w?.add(S);let v=t[S.run],A=g!==null?g.drawsInk(b,P):m.cells[S.cell].drawsInk,N=A?RE(S,v,n.outlineMinSize):null,M=S;if(A&&N===null&&S.shaped){let B=z7(S);B?M=B:N=RE(S,v,n.outlineMinSize,!0)}if(!sf(v.fill)&&!(N!==null&&xr(v.stroke)))continue;if(N!==null){let B={...N,x:S.x,baselineY:S.baselineY,scale:S.fontSize};S.rotate&&(B.rotate=S.rotate),h0(t,S,"outline").glyphs.push(B);continue}if(!yE(M))continue;let C=h0(t,M,M.glyph.color?"color":M.resolved.source);f===null&&(f=C,C.quadData=d);let F=C.quadData;F===Ys&&(C.quadData=F=[]),C===f?(d0(M,F,p),p+=Ar):d0(M,F,F.length),C.colorGlyphs?.push(M.glyph)}if(w)for(let y of w.end()){let{run:P,...S}=y;i.push({...S,fill:t[P].fill})}}if(f!==null&&d!==Cu)d.length=p;else if(f!==null){let h=Nu(p);for(let m=0;m<p;m++)h[m]=Cu[m];f.quadData=h}return TE(o),r}var y0=new WeakMap,q7=[];function g0(e){return y0.get(e)}function Pp(e){let t=y0.get(e);return t===void 0&&(t=q7.pop()??{generation:-1,variants:[],painting:null,paintedOn:null,paintedStamp:0,paintMin:void 0,listed:null},y0.set(e,t)),t}var X7=32,Tp=new WeakMap;function J7(e){return e.lines.length>0?Pt.columns(e.lines[0])?.stamp??0:0}function Q7(e){let t=e.lines.length>0?Pt.columns(e.lines[0]):null;if(t!==null)return t.paintings;let n=Tp.get(e);return n===void 0&&Tp.set(e,n=[]),n}var x0=[],Z7=1024;function IE(e,t,n,r,o,i){let s=x0.pop();return s===void 0?{generation:r,key:o,bucket:i,runs:o===null?t:null,painted:m0(e,t,n,{groups:[],decorations:[]}),pinned:!1}:(s.generation=r,s.key=o,s.bucket=i,s.runs=o===null?t:null,s.pinned=!1,m0(e,t,n,s.painted),s)}function e5(e,t){if(t===void 0)return-1;let n=0;for(let r=0;r<e.length;r++){let o=e[r].fontSize;if(!(o>=t))continue;let i=!1;for(let s=0;s<r&&!i;s++)i=e[s].fontSize===o;i||n++}return n}function EE(e,t){let n=`${t}`;for(let r of e)n+=`|${r.underline?1:0}${r.strikethrough?1:0}${r.overline?1:0}${fo(r.fill?.paint)}|${Vl(r.stroke)}`;return n}function ME(e){return e.key===null&&(e.key=EE(e.runs,e.bucket),e.runs=null),e.key}function w0(e,t,n={},r="keep"){let o=qo(),i=n.outlineMinSize,s=g0(t),a=J7(e),l=s!==void 0&&s.paintedOn===e&&s.paintedStamp===a?s.painting:null,u=l!==null&&l.generation===o;if(u&&s.paintMin===i)return b0(l,r);let c=e5(t,i);if(u&&l.bucket===c)return s.paintMin=i,b0(l,r);let d=Q7(e),f=null;if(d.length>0){let h=EE(t,c);for(let m=0;m<d.length;m++){let g=d[m];if(!(g.bucket!==c||ME(g)!==h)){d.splice(m,1),g.generation===o&&(f=g);break}}f??=IE(e,t,n,o,h,c)}else f=IE(e,t,n,o,null,c);d.length>=X7&&d.shift(),d.push(f);let p=s??Pp(t);return p.painting!==null&&p.painting!==f&&CE(p.painting,t),p.paintedOn=e,p.paintedStamp=a,p.painting=f,p.paintMin=i,b0(f,r)}function CE(e,t){e.runs===t&&ME(e)}function b0(e,t){return t==="keep"&&(e.pinned=!0),e.painted}function OE(e){let t=e.lines.length>0?Pt.columns(e.lines[0]):null,n;if(t!==null)n=t.paintings;else{if(n=Tp.get(e),n===void 0)return;Tp.delete(e)}for(let r=0;r<n.length;r++){let o=n[r];if(o.pinned)continue;let{groups:i}=o.painted;for(let s=0;s<i.length;s++){let a=i[s];a.quadData.length>0&&up(a.quadData),a.quadData=Ys,PE(a)}gt(i,0),gt(o.painted.decorations,0),o.runs=null,o.key=null,x0.length<Z7&&x0.push(o)}gt(n,0)}var UE=8,WE=64,Rr=[],FE=-1,LE=0,Mn=(e,t)=>e===t||e!==e&&t!==t;function VE(e,t,n){return Mn(e.maxWidth,t.maxWidth)&&Mn(e.alignWidth,t.alignWidth??t.maxWidth)&&Mn(e.lineHeight,t.lineHeight)&&e.align===t.align&&e.justify===(t.justify===!0||t.align==="justify")&&e.direction===(t.direction??"auto")&&Mn(e.tabSize,t.tabSize??8)&&e.bidi===n&&e.shaper===Mu(t)}var Js=e=>e.lines.length>0?Pt.columns(e.lines[0]):null;function _E(e,t){if(t==="keep"){let n=Js(e);n!==null&&(n.pinned=!0)}return e}function zE(e){let t=Js(e);t===null||t.owners>0||t.listed||t.pinned||(OE(e),t.recycle())}var T0=[],t5=1024;function DE(e){for(let t=0;t<e.length;t++){let n=e[t],r=Js(n.laid);r!==null&&(r.owners--,zE(n.laid)),n.laid=n5,T0.length<t5&&T0.push(n)}gt(e,0)}var n5={lines:[],bounds:{width:0,height:0}};function S0(e,t,n,r){return e.maxWidth=t.maxWidth,bp(e,t),e.lineHeight=t.lineHeight,e.align=t.align,e.justify=t.justify===!0||t.align==="justify",e.direction=t.direction??"auto",e.tabSize=t.tabSize??8,e.bidi=n,e.shaper=Mu(t),e.laid=r,e}function r5(e,t,n){let r=T0.pop();if(r!==void 0)return S0(r,e,t,n);let o={maxWidth:e.maxWidth,alignWidth:e.maxWidth,lineHeight:e.lineHeight,align:e.align,justify:e.justify===!0||e.align==="justify",direction:e.direction??"auto",tabSize:e.tabSize??8,bidi:t,shaper:Mu(e),laid:n};return bp(o,e),o}function Xs(e,t){return Math.imul(e^t,16777619)}function qs(e,t){return Xs(e,t===(t|0)?t:Math.round(t*4096))}function P0(e,t){e=Xs(e,t.length);for(let n=0;n<t.length;n++)e=Xs(e,t.charCodeAt(n));return e}function o5(e){let t=Xs(2166136261,e.length);for(let n=0;n<e.length;n++){let r=e[n];t=P0(t,r.text),t=P0(t,r.fontFamily),t=qs(t,r.fontSize),t=qs(t,r.fontWeight),t=Xs(t,r.fontStyle==="italic"?1:0),t=qs(t,r.letterSpacing),t=qs(t,r.baselineShift),t=qs(t,r.rotate??0),t=qs(t,r.strutSize??-1),t=Xs(t,r.fontFeatures?.length??0),t=P0(t,r.lang??"")}return t&1073741823}var BE=[];function HE(e,t){return e===t||e!==void 0&&t!==void 0&&Yc(e,t,Mn)}var i5=(e,t)=>Yc(e??BE,t??BE);function s5(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],o=t[n];if(r===o)continue;if(r.text!==o.text||r.fontFamily!==o.fontFamily||!Mn(r.fontSize,o.fontSize)||!Mn(r.fontWeight,o.fontWeight)||r.fontStyle!==o.fontStyle||!Mn(r.letterSpacing,o.letterSpacing)||!Mn(r.baselineShift,o.baselineShift)||!Mn(r.strutSize,o.strutSize)||!Mn(r.rotate??0,o.rotate??0)||!HE(r.sizeMap,o.sizeMap)||!i5(r.fontFeatures,o.fontFeatures)||r.lang!==o.lang)return!1;let i=r.srcMap,s=o.srcMap;if(i!==s&&(i===void 0||s===void 0||i.length!==s.length||!HE(i.starts,s.starts)))return!1}return!0}function Ou(e,t,n="keep"){let r=rl(),o=c0(t),i=Pp(e);if(i.generation!==r)i.generation=r,DE(i.variants);else{let u=i.variants;for(let c=0;c<u.length;c++){let d=u[c];if(VE(d,t,o)){for(let f=c;f>0;f--)u[f]=u[f-1];return u[0]=d,_E(d.laid,n)}}}let s=a5(e,t,o,r,i),a=i.variants;a.length>=UE&&DE(a),a.unshift(r5(t,o,s));let l=Js(s);return l!==null&&l.owners++,_E(s,n)}function a5(e,t,n,r,o){if(FE!==r){for(let d of Rr)GE(d),d.runs=l5;Rr=[],FE=r}let i=o5(e),s=0;for(let d=0;d<Rr.length;d++){let f=Rr[d];if(f.hash===i&&VE(f,t,n)&&s5(f.runs,e))return f.used=++LE,f.laid;f.used<Rr[s].used&&(s=d)}let a=Rr.length>=WE;a&&GE(Rr[s]);let l=mE(e,t),u=a?S0(Rr[s],t,n,l):u5(t,n,l);u.hash=i,u.runs=e,u.used=++LE,o.listed=u;let c=Js(l);return c!==null&&(c.listed=!0),a||Rr.push(u),l}var l5=[];function u5(e,t,n){return S0({maxWidth:0,alignWidth:0,lineHeight:0,align:"left",justify:!1,direction:"auto",tabSize:0,bidi:null,shaper:null,laid:n,hash:0,runs:[],used:0},e,t,n)}function GE(e){let t=Js(e.laid);t!==null&&(t.listed=!1,zE(e.laid))}function Fu(e,t,n){if(e===void 0||e==="top"||t===void 0)return 0;let r=t-n;return e==="center"?r/2:r}function Sp(e,t=1){let n=kx(e.style,{fill:e.fill,stroke:e.stroke},t),r=e.runs&&e.runs.length>0?e.runs:e.text;return{style:n,runs:xu(WN(r),n,t),opts:{maxWidth:n.wrap?e.width:1/0,alignWidth:e.width,lineHeight:n.lineHeight,align:n.align,direction:n.direction,tabSize:n.tabSize,justify:n.align==="justify"}}}function k0(e,t=1){let{runs:n,opts:r}=Sp(e,t),o=Ou(n,r);return{laid:o,x:e.x,y:e.y+Fu(e.verticalAlign,e.height,o.bounds.height)}}function kp(e,t={}){let n=t.padding??0,{laid:r,x:o,y:i}=k0(e),s=[];for(let a of r.lines)!t.includeEmpty&&a.x1<=a.x0||s.push({x:a.x0+o-n,y:a.y0+i-n,width:a.x1-a.x0+n*2,height:a.y1-a.y0+n*2});return s}function Po(e){if(!e)return c5;let t=e*Math.PI/180;return[Math.cos(t),Math.sin(t)]}var c5=[1,0];var To={maxWidth:0,alignWidth:void 0,lineHeight:0,align:"left",direction:"auto",tabSize:0,justify:void 0},vp={laid:null,dx:0,dy:0};function Ap(e){let t=e.style;To.maxWidth=e.maxWidth??1/0,To.alignWidth=e.width,To.lineHeight=t.lineHeight??Ie.lineHeight,To.align=e.align??t.align??Ie.align,To.direction=e.direction??t.direction??Ie.direction,To.tabSize=t.tabSize??Ie.tabSize,To.justify=e.justify;let n=Ou(e.runs,To,"read");return vp.laid=n,vp.dx=e.x,vp.dy=e.y+Fu(e.verticalAlign,e.height,n.bounds.height),vp}var Rp={side:.5,above:1.5,below:1};function KE(e,t){let{laid:n,dx:r,dy:o}=Ap(e),i=q.meanScaleOf(t),s=q.minScaleOf(t),a=e.runs.map(f=>f.stroke?Qs(f.stroke,i,s):0),l=1/0,u=1/0,c=-1/0,d=-1/0;for(let f of n.lines)for(let p of f.glyphs){let h=p.fontSize,m=a[p.run]??0,g=-Rp.side*h-m,b=p.advance+Rp.side*h+m,x=-Rp.above*h-m,w=Rp.below*h+m,[y,P]=Po(p.rotate);for(let S=0;S<4;S++){let v=S===0||S===3?g:b,A=S<2?x:w,N=p.x+v*y-A*P,M=p.baselineY+v*P+A*y;N<l&&(l=N),N>c&&(c=N),M<u&&(u=M),M>d&&(d=M)}}return l===1/0?null:Ni(l+r,u+o,c+r,d+o,t)}var d5=4,Ii={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Ei={minX:-1/0,minY:-1/0,maxX:1/0,maxY:1/0};function A0(e,t,n){let r=Ii;for(let o of e)if(r=h5(r,R0(o,t,n)),r===Ei)break;return r}function R0(e,t,n){switch(e.kind){case"group":{let r=e.transform?q.multiply(t,e.transform):t,o=A0(e.children,r,n);return e.effects&&e.effects.length>0&&(o=p5(o,Gs(e.effects)/n)),e.clip?N0(o,Np(e.clip,void 0,r)):o}case"path":case"image":case"sprites":return I0(e,t)??Ei;case"text":return KE(e,t)??Ii;case"shader":return f5(e)??Ei}}function f5(e){let t=Nn(e.program.id);if(!t||t.vert!==""||/\bgl_FragCoord\b/.test(t.frag)&&!/\bu_fragOrigin\b/.test(t.frag))return null;let{x:n,y:r,w:o,h:i}=e.bounds;return{minX:Math.min(n,n+o),minY:Math.min(r,r+i),maxX:Math.max(n,n+o),maxY:Math.max(r,r+i)}}function p5(e,t){return e===Ii||e===Ei||t===0?e:Number.isFinite(t)?{minX:e.minX-t,minY:e.minY-t,maxX:e.maxX+t,maxY:e.maxY+t}:Ei}function h5(e,t){return e===Ii||t===Ei?t:t===Ii||e===Ei?e:{minX:Math.min(e.minX,t.minX),minY:Math.min(e.minY,t.minY),maxX:Math.max(e.maxX,t.maxX),maxY:Math.max(e.maxY,t.maxY)}}function N0(e,t){if(!t||e===Ii)return e;let n={minX:Math.max(e.minX,t.minX),minY:Math.max(e.minY,t.minY),maxX:Math.min(e.maxX,t.maxX),maxY:Math.min(e.maxY,t.maxY)};return n.minX>n.maxX||n.minY>n.maxY?Ii:n}function I0(e,t){switch(e.kind){case"path":return Np(e.path,e.stroke,t);case"image":return Ni(e.x,e.y,e.x+e.w,e.y+e.h,t);case"sprites":return y5(e.sprites,t)}}function Np(e,t,n){let r,o,i,s;if(e.kind==="rect")r=Math.min(e.x,e.x+e.width),i=Math.max(e.x,e.x+e.width),o=Math.min(e.y,e.y+e.height),s=Math.max(e.y,e.y+e.height);else if(e.kind==="polygon"){let l=e.coords;if(l.length<2)return null;r=i=l[0],o=s=l[1];for(let c=2;c+1<l.length;c+=2){let d=l[c],f=l[c+1];d<r?r=d:d>i&&(i=d),f<o?o=f:f>s&&(s=f)}let u=e.origin;u&&(r+=u.x,i+=u.x,o+=u.y,s+=u.y)}else return null;let a=t?m5(t,n):0;return Ni(r-a,o-a,i+a,s+a,n)}function m5(e,t){return Qs(e,q.meanScaleOf(t),q.minScaleOf(t))}function Qs(e,t,n=t){let r=n>0?n:t,o=at(e.width??1,typeof e.width=="object"?r:t),i=Pi(o,e.vertexWidths),s=Math.max(e.miterLimit??d5,Math.SQRT2),a=gu(e);return Math.max(Math.abs(i)*s,a.world,Gt({px:a.px},r))}function y5(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let s=0;s+9<=e.length;s+=9){let a=e[s],l=e[s+1],u=a+e[s+2],c=l+e[s+3];n=Math.min(n,a,u),o=Math.max(o,a,u),r=Math.min(r,l,c),i=Math.max(i,l,c)}return n===1/0?null:Ni(n,r,o,i,t)}function Ni(e,t,n,r,o){let[i,s]=q.apply(o,e,t),[a,l]=q.apply(o,n,t),[u,c]=q.apply(o,n,r),[d,f]=q.apply(o,e,r);return{minX:Math.min(i,a,u,d),minY:Math.min(s,l,c,f),maxX:Math.max(i,a,u,d),maxY:Math.max(s,l,c,f)}}var Nr=1;function M0(e,t,n,r){return jE(e,t,$E(n),r)}function jE(e,t,n,r){let o=null;for(let i=0;i<e.length;i++){let s=e[i],a=g5(s,t,n,r);if(a===s){o?.push(s);continue}o??=e.slice(0,i),a&&o.push(a)}return o??e}function g5(e,t,n,r){switch(e.kind){case"group":{if($n(e.composite))return e;if(e.effects&&e.effects.length>0)return E0(R0(e,t,r),n)?null:e;let o=e.transform?q.multiply(t,e.transform):t,i=jE(e.children,o,n,r);return i===e.children?e:i.length===0?null:{...e,children:i}}case"path":case"image":case"sprites":return E0(I0(e,t),n)?null:e;default:return e}}function C0(e,t,n){let r=Math.min(e.x,e.x+e.width),o=Math.max(e.x,e.x+e.width),i=Math.min(e.y,e.y+e.height),s=Math.max(e.y,e.y+e.height);return E0(Ni(r,i,o,s,t),$E(n))}function $E(e){return{minX:e.x-Nr,minY:e.y-Nr,maxX:e.x+e.width+Nr,maxY:e.y+e.height+Nr}}function E0(e,t){return e!==null&&(e.maxX<t.minX||e.minX>t.maxX||e.maxY<t.minY||e.minY>t.maxY)}function Lu(e,t,n,r){let o=A0(e,t,r);for(let i of n)o=N0(o,Np(i.path,void 0,i.transform));return b5(o,r)}function b5(e,t){let n=Math.floor((e.minX-Nr)*t),r=Math.floor((e.minY-Nr)*t),o=Math.ceil((e.maxX+Nr)*t),i=Math.ceil((e.maxY+Nr)*t);return[n,r,o,i].some(Number.isNaN)?{x0:-1/0,y0:-1/0,x1:1/0,y1:1/0}:{x0:n,y0:r,x1:o,y1:i}}function Mi(e,t){let n=Math.max(t.x,e.x0),r=Math.max(t.y,e.y0),o=Math.min(t.x+t.width,e.x1),i=Math.min(t.y+t.height,e.y1);return o<=n||i<=r?{x:0,y:0,width:0,height:0}:{x:n,y:r,width:o-n,height:i-r}}Z();function Zs(e,t,n,r){let o=e.gl,i=e.renderTarget??null;o.bindFramebuffer(o.FRAMEBUFFER,i?i.fbo:null),i?i.restore?i.restore():o.viewport(0,0,t,n):(e.restoreTargetRect?.(),r&&o.enable(o.SCISSOR_TEST))}function O0(e,t,n,r,o,i,s,a){let l=e.gl;l.useProgram(t.handle);let u=t.attribute("a_position"),c=t.attribute("a_uv");l.bindBuffer(l.ARRAY_BUFFER,e.quadVbo),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.quadIbo),u!==void 0&&u>=0&&(l.enableVertexAttribArray(u),l.vertexAttribPointer(u,2,l.FLOAT,!1,16,0)),c!==void 0&&c>=0&&(l.enableVertexAttribArray(c),l.vertexAttribPointer(c,2,l.FLOAT,!1,16,8)),l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,n);let d=t.uniform("u_source");d!==void 0&&l.uniform1i(d,0);let f=t.uniform("u_resolution");f!==void 0&&l.uniform2f(f,r,o);let p=t.uniform("u_texel");if(p!==void 0&&l.uniform2f(p,1/r,1/o),s){let h=t.uniform("u_alpha");h!==void 0&&l.uniform1f(h,s.alpha),Rn(e,t,s.colorMatrix)}i&&Wb(l,t,a??"effect",i,e.textureCache,{value:1}),De(e,6,e.gl.UNSIGNED_SHORT),u!==void 0&&u>=0&&l.disableVertexAttribArray(u),c!==void 0&&c>=0&&l.disableVertexAttribArray(c),l.bindBuffer(l.ARRAY_BUFFER,null),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null)}function Ip(e,t,n,r,o){let i=e.gl,s=e.deviceWidth,a=e.deviceHeight,l=e.renderTarget??null,[u,c]=(l?l.fragOrigin:e.fragOrigin)??[0,0];i.viewport(u+r.x,c+a-r.y-r.height,r.width,r.height),O0(e,t,n,r.width,r.height,void 0,o),l?l.restore?l.restore():i.viewport(0,0,s,a):e.restoreTargetRect?.()}function Ep(e,t){let n=q.screenToClip(e.width/t,e.height/t);return q.toUniform(q.translated(n,-e.x/t,-e.y/t))}function _u(e,t,n){return e.x>=0&&e.y>=0&&e.x+e.width<=t&&e.y+e.height<=n}var Mp=64;function x5(e,t,n,r,o,i,s){let a=e.effects&&e.effects.length>0?Gs(e.effects):0;if(!Number.isFinite(a))return{x:0,y:0,width:r,height:o};if($n(e.composite)&&!RR(e.composite))return n;let l=Math.ceil(a),u={x:n.x-l,y:n.y-l,width:n.width+2*l,height:n.height+2*l},c=Lu([{...e,clip:void 0}],t,[],i),d=Mi(c,u);if(d.width===0||d.height===0)return null;let f=Math.min(s,Math.ceil(d.width/Mp)*Mp),p=Math.min(s,Math.ceil(d.height/Mp)*Mp),h=_u(d,r,o);return{x:h&&f<=r?Math.min(d.x,r-f):d.x,y:h&&p<=o?Math.min(d.y,o-p):d.y,width:f,height:p}}function YE(e,t,n,r,o,i){let s=e.gl,a=e.renderTarget??null,l=r/e.widthCss,u=x5(t,e.state.transform,a?.window??{x:0,y:0,width:r,height:o},r,o,l,e.imageCache.maxTextureSide);if(!u)return;an(e);let c=e.clipDepth,d=e.clipStack,f=e.drawBatch.clip,p=e.projection,h=s.isEnabled(s.SCISSOR_TEST),m=n.acquire(u.width,u.height),g=e.state.pushIsolated({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix});e.clipDepth=0,e.clipStack=[],e.drawBatch.clip=null;let b=_u(u,r,o);e.projection=b?void 0:Ep(u,l);let x=()=>{b?s.viewport(-u.x,u.y+u.height-o,r,o):s.viewport(0,0,u.width,u.height),s.disable(s.SCISSOR_TEST)};e.renderTarget={fbo:m.fbo,restore:x,fragOrigin:[-u.x,u.y+u.height-o],window:u},s.bindFramebuffer(s.FRAMEBUFFER,m.fbo),x(),s.stencilMask(255),s.clear(s.COLOR_BUFFER_BIT|s.STENCIL_BUFFER_BIT);for(let y of t.children)i(e,y);ye(e),s.disable(s.BLEND),s.disable(s.STENCIL_TEST);for(let y of t.effects??[]){let P=e.ensureProgram?.(y.program.id)??null;if(!P){Ub(y.program.id,"(program)");continue}let S=n.acquire(u.width,u.height);s.bindFramebuffer(s.FRAMEBUFFER,S.fbo),s.viewport(0,0,u.width,u.height),s.clear(s.COLOR_BUFFER_BIT),O0(e,P,m.texture,u.width,u.height,y.uniforms,void 0,y.program.id),n.release(m),m=S}s.enable(s.BLEND),e.state.pop(),e.clipDepth=c,e.clipStack=d,e.drawBatch.clip=f,e.projection=p,e.renderTarget=a,Zs(e,r,o,h);let w=e.ensureProgram?.(Hf())??null;if(w){wt(e);let y=$n(t.composite);y&&Db(s,t.composite),Ip(e,w,m.texture,u,g),y&&Db(s,"source-over")}n.release(m)}var w5=new WeakMap,P5=new WeakMap;function F0(e,t){let n=t?w5:P5,r=n.get(e);if(r!==void 0)return r;let o=e.every(i=>T5(i,t));return n.set(e,o),o}function T5(e,t){switch(e.kind){case"group":return e.effects&&e.effects.length>0&&!Number.isFinite(Gs(e.effects))?!1:F0(e.children,t);case"path":return Cp(e.fill?.paint,t)&&Cp(e.stroke?.paint,t);case"text":return e.runs.every(n=>Cp(n.fill?.paint,t,!0)&&Cp(n.stroke?.paint,t,!0));case"image":case"sprites":return!0;case"shader":return!1}}function Cp(e,t,n=!1){if(!e||e.kind===void 0||e.kind==="solid")return!0;if(n&&e.kind==="texture")return!1;let r="units"in e?e.units:void 0;return r==="local"||r==="world"&&t}var S5={alpha:1,colorMatrix:Ut},qE=new WeakSet;function XE(e,t,n,r){let o=e.retained,i=e.deviceWidth,s=e.deviceHeight;if(!o||!i||!s)return!1;if(e.renderTarget!=null&&qE.has(e.renderTarget)||$n(t.composite)||_b(t.children))return o.decline(),!1;let l=t.retain;e.state.push({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix});let u=e.clipStack.map(({path:y,transform:P})=>({path:y,transform:P}));t.clip&&u.push({path:t.clip,transform:e.state.transform});let c={children:t.children,transform:e.state.transform,alpha:e.state.alpha,colorMatrix:e.state.colorMatrix,viewMatrix:e.viewMatrix,screenMatrix:e.screenMatrix,clips:u,effects:t.effects,isolate:t.isolate===!0,window:e.renderTarget?.window},d=!e.renderTarget,f=n?[{kind:"group",effects:t.effects,isolate:t.isolate,children:t.children}]:t.children,p=i/e.widthCss,h=d&&F0(f,e.viewMatrix!==void 0),m=o.lookup(l,i,s,c,d,h?p:void 0),g;if(m.kind==="through")return e.state.pop(),!1;if(m.kind==="kept")g=m.pixels;else{let y=c.window??m.window,P=Lu(f,e.state.transform,u,p),S=o.reserve(l,i,s,Mi(P,y),d,h?{box:P,window:y}:void 0);if(!S)return e.state.pop(),!1;ye(e),S.fbo&&k5(e,f,u,S.fbo,S,r),g=S.commit(c)}e.state.pop();let{texture:b,rect:x}=g;if(!b)return!0;ye(e);let w=e.ensureProgram?.(Hf())??null;return w&&(wt(e,0),Ip(e,w,b,x,S5)),!0}function k5(e,t,n,r,o,i){let s=e.gl,a=e.deviceWidth,l=e.deviceHeight,{rect:u,tiles:c}=o,d=e.renderTarget??null,f=e.clipDepth,p=e.clipStack,h=e.drawBatch.clip,m=e.projection,g=s.isEnabled(s.SCISSOR_TEST),b=a/e.widthCss,x=_u(u,a,l);e.projection=x?void 0:Ep(u,b);let w=c.length>1?t.map(y=>Lu([y],e.state.transform,[],b)):null;for(let y of c){let P=y.y+y.height,S=()=>{x?s.viewport(-y.x,P-l,a,l):s.viewport(u.x-y.x,P-u.y-u.height,u.width,u.height),s.scissor(0,0,y.width,y.height),s.enable(s.SCISSOR_TEST)},v={fbo:r,restore:S,fragOrigin:[-y.x,P-l],window:y};qE.add(v),e.renderTarget=v,e.clipDepth=0,e.clipStack=[],e.drawBatch.clip=null,s.bindFramebuffer(s.FRAMEBUFFER,r),S(),s.stencilMask(255),s.clear(s.COLOR_BUFFER_BIT|s.STENCIL_BUFFER_BIT);for(let A of n)uu(e,A.path,A.transform);for(let A=0;A<t.length;A++)(!w||v5(w[A],y))&&i(e,t[A]);ye(e),o.resolve(y)}e.clipDepth=f,e.clipStack=p,e.drawBatch.clip=h,e.projection=m,e.renderTarget=d,Zs(e,a,l,g)}function v5(e,t){return e.x0<t.x+t.width&&e.x1>t.x&&e.y0<t.y+t.height&&e.y1>t.y}Pe();var ea=xt(),Bu=ea.reflection;function QE(e){if(e.inPoseFrame===void 0!=(e.toBoundsFrame===void 0)){let t=e.inPoseFrame===void 0?"inPoseFrame":"toBoundsFrame";throw new Error(`weasel registerPaintKind: kind "${e.id}" is missing ${t}. A kind that converts one frame direction and not the other drifts on the next resize; supply both or neither.`)}for(let[t,n]of Object.entries(e.programs??{})){let r=Nn(t);(!r||r.vert!==n.vert||r.frag!==n.frag)&&Bf(t,n.vert,n.frag)}return ea.push(e.id,e)}function Ci(e){let t=e??"solid",n=ea.get(t);return!n&&Du.has(t)&&ZE(t).catch(()=>{}),n}var Du=new Map,JE=new Map;function ZE(e){let t=JE.get(e);if(t)return t;let r=Du.get(e)().then(o=>{if(o.id!==e)throw new Error(`weasel: the loader for paint kind "${e}" resolved to "${o.id}".`);ea.has(e)||QE(o)}).catch(o=>{throw console.error(`weasel: paint kind "${e}" failed to load:`,o),o});return JE.set(e,r),r}function L0(e){return ea.has(e)||Du.has(e)}function _0(e){let t=e??[...Du.keys()],n=[];for(let r of t)if(!ea.has(r)){if(!Du.has(r))return Promise.reject(new Error(`weasel warmPaintKinds: "${r}" is neither registered nor loadable.`));n.push(ZE(r))}return Promise.all(n).then(()=>{})}var D0=8,A5=1/8;function Op(e,t){if(!(e>0)||!(t>0)||!Number.isFinite(t))return t;let n=Math.ceil(Math.LN2/(2*Math.log1p(A5/e)));return 2**(Math.round(Math.log2(t)*n)/n)}var eM=new WeakMap;function R5(e,t,n){let r=at(e.width??1,1),o=Vs(e,r),i=n.ribbon?.metric;return[r,e.cap??"butt",e.join??"miter",e.miterLimit??"",e.align??"center",(e.dash??[]).join(","),e.varyingWidthJoinThreshold??"",e.nib?`${e.nib.angle}:${e.nib.ratio}`:"",t??"",o.start,o.end,mo(i),mo(n.start?.metric),mo(n.end?.metric)].join("|")}function Fp(e,t,n,r={}){let o=eM.get(e);o===void 0&&(o=new Map,eM.set(e,o));let i=R5(t,n,r),s=o.get(i);if(s!==void 0&&s.vertexWidths===t.vertexWidths)return s.mesh;let a=at(t.width??1,1),l=Vs(t,a),u=Ti(e,t,{flattenTolerance:n,startInset:tM(l.start,r.start,r.ribbon),endInset:tM(l.end,r.end,r.ribbon),metric:r.ribbon?.metric});return s===void 0&&o.size>=D0&&o.clear(),o.set(i,{mesh:u,vertexWidths:t.vertexWidths}),u}function tM(e,t,n){return t?.metric===n?.metric?e:{length:e,metric:t?.metric??null}}var N5={};function Hu(e,t,n={}){let r=n.quantize===!1?(m,g)=>g:Op,o=t.stroke,{markerStart:i,markerMid:s,markerEnd:a}=o;if(typeof o.width!="object"&&!ta(i)&&!ta(s)&&!ta(a))return{cmd:t,spaces:N5};let l={...o},{scale:u,metric:c}=du(e[0],e[1],e[3],e[4]),d=m=>c===null?void 0:{metric:c,pxPerUnit:m},f;if(typeof o.width=="object"){let m=r(o.width.px,u);l.width=at(o.width,m),o.dash&&m>0&&(l.dash=o.dash.map(g=>g/m)),f=d(m)}let p=m=>{if(m===void 0||typeof m=="string"||m.size===void 0)return f;if(typeof m.size!="number")return d(r(m.size.px,u))},h={ribbon:f,start:p(i),mid:p(s),end:p(a)};return ta(i)&&(l.markerStart=B0(i,u,r)),ta(s)&&(l.markerMid=B0(s,u,r)),ta(a)&&(l.markerEnd=B0(a,u,r)),{cmd:{...t,stroke:l},spaces:h}}function ta(e){return typeof e=="object"&&typeof e.size=="object"}function B0(e,t,n){return{...e,size:Ws(e,0,n(e.size.px,t))}}Z();Pe();function nM(e,t){if(!M5(e))return Ci(e.kind)?.inPoseFrame?.(e,t)??e;if(I5(e)){let r=e.origin??{x:0,y:0};return{...e,origin:{x:t.x+r.x,y:t.y+r.y},units:"local"}}if(!E5(e))return e;let n=r=>({x:t.x+r.x*t.width,y:t.y+r.y*t.height});if(e.kind==="linear-gradient")return{...e,from:n(e.from),to:n(e.to),units:"local"};if(e.kind==="radial-gradient"){let r=Math.hypot(t.width,t.height)/Math.SQRT2;return{...e,center:n(e.center),radius:e.radius*r,units:"local"}}return{...e,center:n(e.center),units:"local"}}function I5(e){return af(e)&&e.units==="bounds"}function E5(e){if(e===void 0)return!1;let t=e.kind;return t!=="linear-gradient"&&t!=="radial-gradient"&&t!=="conic-gradient"?!1:e.units==="bounds"}function M5(e){let t=e.kind??"solid";return t==="solid"||af(e)||t==="linear-gradient"||t==="radial-gradient"||t==="conic-gradient"}Pe();function rM(e){let t;try{t=new OffscreenCanvas(e.size,e.size)}catch{if(typeof document>"u")return null;let r=document.createElement("canvas");r.width=e.size,r.height=e.size,t=r}let n=t.getContext("2d");return!n||(e.draw(n,e.size),typeof t.transferToImageBitmap!="function")?null:t.transferToImageBitmap()}var C5=4096*4096,O5=4,F5=300,L5=150,_5=256*1024*1024,Nt=new Map,oM=_5,G0=0,iM=0,D5=Me(),Lp=new Map;function U0(e){return/^data:image\/svg\+xml[;,]/i.test(e)?!0:/^(data|blob):/i.test(e)?!1:/\.svgz?$/i.test(e.replace(/[?#].*$/,""))}function B5(){if(typeof Image>"u"||typeof createImageBitmap>"u")throw new Error("weasel imageCache: no DOM image loader in this environment")}async function aM(e){let t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}function H5(e){let t=Lp.get(e);return t||(t=aM(e),Lp.set(e,t),t.catch(()=>Lp.delete(e))),t}async function G5(e,t){let n=await H5(e),r=t?.width??(n.naturalWidth||F5),o=t?.height??(n.naturalHeight||L5),i=typeof OffscreenCanvas<"u"?new OffscreenCanvas(r,o):Object.assign(document.createElement("canvas"),{width:r,height:o}),s=i.getContext("2d");if(!s)throw new Error("weasel imageCache: no 2D context to rasterize an SVG");return s.drawImage(n,0,0,r,o),createImageBitmap(i)}var U5=async(e,t)=>(B5(),U0(e)?G5(e,t):createImageBitmap(await aM(e))),lM=U5;function H0(){D5.emit()}var sM=e=>e?e.width*e.height*4:0;function uM(e){let t=0;for(let n of Nt.values())t+=sM(n.bitmap);if(t>oM){let n=[...Nt].filter(([r,o])=>r!==e&&o.bitmap!==void 0&&o.readAt<=iM&&!LA(o.bitmap));n.sort((r,o)=>r[1].readAt-o[1].readAt);for(let[r,o]of n){if(t<=oM)break;t-=sM(o.bitmap),fM(r)}}iM=G0}function W5(e){let t={status:"loading",readAt:++G0};Nt.set(e,t),lM(e).then(n=>{Nt.get(e)===t&&(Nt.set(e,{status:"ready",bitmap:n,readAt:t.readAt,...U0(e)?{vector:{natural:{width:n.width,height:n.height},scale:1,failed:new Set,floor:0}}:{}}),uM(e),H0())},()=>{Nt.get(e)===t&&(Nt.set(e,{status:"error",readAt:t.readAt}),H0())})}function V5(e,t){let n=Math.max(t.width/e.width,t.height/e.height);if(!(n>0)||!Number.isFinite(n))return;let r=_A(),o=Math.min(r/e.width,r/e.height,Math.sqrt(C5/(e.width*e.height)));return Math.min(2**Math.ceil(Math.log2(n)),o)}function z5(e,t,n,r){if(n.pending!==void 0)return;let o=V5(n.natural,r);if(o===void 0)return;let i=o>n.scale;i&&n.shrunkTo===n.scale&&(n.floor=Math.max(n.floor,o));let s=i?o:Math.max(o,n.floor);if(!i&&s*O5>n.scale)return;for(let l of n.failed)if(s===l||i&&l>n.scale&&s>=l)return;n.pending=s;let a={width:Math.max(1,Math.round(n.natural.width*s)),height:Math.max(1,Math.round(n.natural.height*s))};lM(e,a).then(l=>{if(Nt.get(e)!==t)return;n.pending=void 0;let u=t.bitmap;t.bitmap=l,n.shrunkTo=i?void 0:s,n.scale=s,u&&u!==l&&rf(u),uM(e),H0()},()=>{Nt.get(e)===t&&(n.pending=void 0,n.failed.add(s))})}function ra(e,t){if(e.startsWith(cM))return na.get(e)?.deref();let n=Nt.get(e);if(!n){W5(e);return}return n.readAt=++G0,t&&n.vector&&z5(e,n,n.vector,t),n.bitmap}var cM="weasel-bitmap:",na=new Map,K5=new WeakMap;var j5=new FinalizationRegistry(e=>{na.get(e)?.deref()===void 0&&na.delete(e)});function dM(e){let t=Nt.get(e);if(t?.vector)return t.vector.natural;let n=t?.bitmap??na.get(e)?.deref();return n?{width:n.width,height:n.height}:void 0}function W0(e){return e.startsWith(cM)?ra(e)===void 0?"idle":"ready":Nt.get(e)?.status??"idle"}function fM(e){let t=na.get(e)?.deref();na.delete(e),t!==void 0&&(K5.delete(t),j5.unregister(t),rf(t));let n=Nt.get(e);Nt.delete(e),Lp.delete(e),n?.bitmap&&rf(n.bitmap)}var V0="image:";function hM(e){return{id:V0+e.src}}function pM(e){let t=e.slice(V0.length),n=ra(t),r=pi.get(e)?.source;n!==r&&(n?tf(e,n,dM(t)):nf({id:e}))}ef(V0,{revive:pM,touched:pM});function z0(e){if(e.size!==void 0)return e.size;switch(e.kind){case"hatch":return 5;case"crosshatch":return 6;case"dots":return 6;case"chunks":return 48;default:return 8}}function $5(e){let t=e|0;return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function yM(e){let t=z0(e),{color:n}=e;switch(e.kind){case"hatch":{let r=e.lineWidth??1;return{size:t,shapes:mM(t,r,n)}}case"crosshatch":{let r=e.lineWidth??.8;return{size:t,shapes:[...mM(t,r,n),...Y5(t,r,n)]}}case"dots":{let r=e.radius??1;return{size:t,shapes:[{kind:"circle",cx:t/2,cy:t/2,r,color:n}]}}case"chunks":{let r=e.density??.35,o=e.chunkSize??3,i=$5(e.seed??42),s=Math.round(t*t*r/(o*o)),a=[];e.bg!==void 0&&a.push({kind:"rect",x:0,y:0,width:t,height:t,color:e.bg});for(let l=0;l<s;l++){let u=i()*t,c=i()*t,d=o*(.5+i()),f=o*(.5+i()),p=i()*Math.PI;a.push({kind:"ellipse",cx:u,cy:c,rx:d/2,ry:f/2,rotation:p,color:n})}return{size:t,shapes:a}}default:return{size:t,shapes:[]}}}function mM(e,t,n){return[{kind:"line",x1:-1,y1:e+1,x2:e+1,y2:-1,width:t,color:n},{kind:"line",x1:-1,y1:1,x2:1,y2:-1,width:t,color:n},{kind:"line",x1:e-1,y1:e+1,x2:e+1,y2:e-1,width:t,color:n}]}function Y5(e,t,n){return[{kind:"line",x1:-1,y1:-1,x2:e+1,y2:e+1,width:t,color:n},{kind:"line",x1:e-1,y1:-1,x2:e+1,y2:1,width:t,color:n},{kind:"line",x1:-1,y1:e-1,x2:1,y2:e+1,width:t,color:n}]}function gM(e,t){for(let n of t.shapes){if(n.kind==="line"){e.strokeStyle=n.color,e.lineWidth=n.width,e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.stroke();continue}if(e.fillStyle=n.color,n.kind==="rect"){e.fillRect(n.x,n.y,n.width,n.height);continue}e.beginPath(),n.kind==="circle"?e.arc(n.cx,n.cy,n.r,0,Math.PI*2):e.ellipse(n.cx,n.cy,n.rx,n.ry,n.rotation,0,Math.PI*2),e.fill()}}var q5=256,K0="pattern:",Ir=new Map;function X5(e){let t=e,n={};for(let r of Object.keys(t).sort())n[r]=t[r];return K0+JSON.stringify(n)}function J5(e){let t=cb(e),n=X5(t),r=Ir.get(n);return r!==void 0?(bM(n),r):xM(n,t)}function bM(e){let t=Ir.get(e);t!==void 0&&(Ir.delete(e),Ir.set(e,t))}function xM(e,t){let n=zl(t.kind)?rM({size:z0(t),draw:o=>gM(o,yM(t))}):null,r=n?tf(e,n):null;for(Ir.delete(e),Ir.set(e,r);Ir.size>q5;)Q5(Ir.keys().next().value);return r}function Q5(e){Ir.delete(e);let t=pi.get(e)?.source;nf({id:e}),t&&"close"in t&&t.close()}function Z5(e){let t;try{t=JSON.parse(e.slice(K0.length))}catch{return}typeof t!="object"||t===null||!("kind"in t)||xM(e,t)}ef(K0,{revive:Z5,touched:bM});function wM(e){if(ub(e)){let{width:n,height:r}=e;return{kind:"texture",texture:hM(e),...n!==void 0?{width:n}:{},...r!==void 0?{height:r}:{},...lf(e)}}if(!lb(e))return e;let t=J5(e);return t?{kind:"texture",texture:t,...lf(e)}:null}function Oi(e,t){return wM(nM(e,t))}function Vt(e,t){if(e.paint==null)return null;let n=Oi(e.paint,t);return n===null?null:n===e.paint?e:{...e,paint:n}}function Fi(e,t){if(e.paint==null)return null;let n=Oi(e.paint,t);return n===null?null:n===e.paint?e:{...e,paint:n}}function PM(e,t,n,r){let o=e??n;if(o!=="none")return o==="line"?t.paint:Oi(o,et(r))??void 0}function j0(e,t){let n=[];for(let{entry:r,path:o,size:i,space:s}of e){let a=PM(r.fill,t,"line",o),l=r.outline?r.outline.width*i:0,u=r.outline?{paint:PM(r.outline.paint,t,"line",o),width:s?{px:l*s.pxPerUnit}:l}:null;a===void 0&&(u===null||u.paint===void 0)||n.push({kind:"path",path:o,...a?{fill:{paint:a}}:{},...u&&u.paint?{stroke:{paint:u.paint,width:u.width,cap:"round",join:"round"}}:{}})}return n}var TM=new WeakMap,SM=new WeakMap,$0=e=>e===void 0?"":typeof e=="string"?e:`${e.key}@${String(e.size??"")}`;function eK(e){let t="";for(let n of[e.markerStart,e.markerMid,e.markerEnd]){let r=n===void 0?void 0:yo(Si(n));if(r===void 0){t+="/";continue}let o=jf(r,e);if(o===null)return null;t+=`${o}/`}return t}function tK(e,t,n){if(n!==null){let i=TM.get(e);return i===void 0&&TM.set(e,i=new Map),i}let r=SM.get(e);r===void 0&&SM.set(e,r=new WeakMap);let o=r.get(t);return o===void 0&&r.set(t,o=new Map),o}function kM(e,t,n,r,o,i={}){if(n.markerStart===void 0&&n.markerMid===void 0&&n.markerEnd===void 0)return[];let s=eK(n),a=tK(e,t,s),l=[r,o??"",mu(),$0(n.markerStart),$0(n.markerMid),$0(n.markerEnd),s??"",cu(i.start),cu(i.mid),cu(i.end)].join("|"),u=a.get(l);if(u===void 0){let c=yu(e,n,r,o,i);u={heads:c,paint:n.paint,cmds:j0(c,n)},a.size>=D0&&a.clear(),a.set(l,u)}else u.paint!==n.paint&&(u.paint=n.paint,u.cmds=j0(u.heads,n));return u.cmds}Z();var vM=new WeakMap;function Y0(e,t,n){let r=vM.get(e);r===void 0&&(r=new WeakMap,vM.set(e,r));let o=r.get(t);return o===void 0&&(o=vl(e,t,n),r.set(t,o)),o}function AM(e){if(e.path.kind!=="polygon")return e;let{path:t,anchorSources:n}=ps(e.path);if(t===e.path)return e;let r={...e,path:t};if(n&&e.vertexColors&&(r.vertexColors=Y0(e.vertexColors,n,4)),n&&e.stroke&&(e.stroke.vertexColors||e.stroke.vertexWidths)){let{vertexColors:o,vertexWidths:i}=e.stroke;r.stroke={...e.stroke,...o?{vertexColors:Y0(o,n,4)}:{},...i?{vertexWidths:Y0(i,n,1)}:{}}}return r}var nK=65536;function NM(e,t,n,r=nK){let o=sK(t,e.origin),i={verts:[],idx:[]},s={left:r},a=new Int32Array(o.count),l=[],u=e.vertices,c=e.indices,d=new Float32Array(6);for(let f=0;f<c.length;f+=3){for(let h=0;h<3;h++)d[h*2]=u[c[f+h]*2],d[h*2+1]=u[c[f+h]*2+1];if(iK(o,d,f/3+1,a,l),!(n?rK(d,o,l,i,s):oK(d,o,l,i,s)))return null}return{vertices:new Float32Array(i.verts),indices:new Uint32Array(i.idx),...e.origin?{origin:e.origin}:{}}}function rK(e,t,n,r,o){for(let i of n){if(--o.left<0)return!1;let s=IM(e,3,t.planes,i);if(s===J0)continue;if(s===0)return X0(e,3,r),!0;let a=e,l=3;for(let u=0;u<3&&l>=3;u++)if((s&1<<u)!==0){if(--o.left<0)return!1;[a,l]=q0(a,l,t.planes,(i*3+u)*3,1)}X0(a,l,r)}return!0}function oK(e,t,n,r,o){let i=[[e,3]];for(let s of n){let a=[];for(let[l,u]of i){if(--o.left<0)return!1;let c=IM(l,u,t.planes,s);if(c===J0){a.push([l,u]);continue}let d=l,f=u;for(let p=0;p<3&&f>=3;p++){if((c&1<<p)===0)continue;if(o.left-=2,o.left<0)return!1;let h=(s*3+p)*3,[m,g]=q0(d,f,t.planes,h,-1);g>=3&&a.push([m,g]),[d,f]=q0(d,f,t.planes,h,1)}}if(i=a,i.length===0)return!0}for(let[s,a]of i)X0(s,a,r);return!0}var J0=-1;function IM(e,t,n,r){let o=0;for(let i=0;i<3;i++){let s=(r*3+i)*3,a=0;for(let l=0;l<t;l++)n[s]*e[l*2]+n[s+1]*e[l*2+1]+n[s+2]>=0&&a++;if(a===0)return J0;a<t&&(o|=1<<i)}return o}var _p={buf:new Float32Array(16)};function q0(e,t,n,r,o){_p.buf.length<(t+1)*2&&(_p.buf=new Float32Array((t+1)*4));let i=ou(e,t,2,o*n[r],o*n[r+1],o*n[r+2],_p.buf);return[_p.buf.slice(0,i*2),i]}function X0(e,t,n){if(t<3)return;let r=n.verts.length/2;for(let o=0;o<t*2;o++)n.verts.push(e[o]);for(let o=1;o<t-1;o++)n.idx.push(r,r+o,r+o+1)}function iK(e,t,n,r,o){o.length=0;let i=Math.min(t[0],t[2],t[4]),s=Math.max(t[0],t[2],t[4]),a=Math.min(t[1],t[3],t[5]),l=Math.max(t[1],t[3],t[5]),u=e.grid,c=Math.max(0,Math.floor((i-u.x0)/u.cell)),d=Math.min(u.cols-1,Math.floor((s-u.x0)/u.cell)),f=Math.max(0,Math.floor((a-u.y0)/u.cell)),p=Math.min(u.rows-1,Math.floor((l-u.y0)/u.cell)),h=e.boxes;for(let m=f;m<=p;m++)for(let g=c;g<=d;g++)for(let b of u.cells[m*u.cols+g])r[b]!==n&&(r[b]=n,!(h[b*4]>s||h[b*4+2]<i||h[b*4+1]>l||h[b*4+3]<a)&&o.push(b))}var RM=new WeakMap;function sK(e,t){let n=RM.get(e);if(n!==void 0&&n.origin===t)return n.tris;let r=aK(e,t);return RM.set(e,{origin:t,tris:r}),r}function aK(e,t){let n=(e.origin?.x??0)-(t?.x??0),r=(e.origin?.y??0)-(t?.y??0),o=e.vertices,i=e.indices,s=[],a=[],l=new Float64Array(6);for(let c=0;c<i.length;c+=3){for(let p=0;p<3;p++)l[p*2]=o[i[c+p]*2]+n,l[p*2+1]=o[i[c+p]*2+1]+r;let d=(l[2]-l[0])*(l[5]-l[1])-(l[4]-l[0])*(l[3]-l[1]);if(d===0)continue;let f=d>0?[0,1,2]:[0,2,1];for(let p=0;p<3;p++)lK(l,f[p],f[(p+1)%3],s);a.push(Math.min(l[0],l[2],l[4]),Math.min(l[1],l[3],l[5]),Math.max(l[0],l[2],l[4]),Math.max(l[1],l[3],l[5]))}let u=a.length/4;return{planes:new Float64Array(s),boxes:new Float64Array(a),count:u,grid:uK(a,u)}}function lK(e,t,n,r){let o=e[n*2]<e[t*2]||e[n*2]===e[t*2]&&e[n*2+1]<e[t*2+1],[i,s]=o?[n,t]:[t,n],a=e[i*2],l=e[i*2+1],u=e[s*2],c=e[s*2+1],d=Math.hypot(u-a,c-l),f=-(c-l)/d,p=(u-a)/d,h=-(f*a+p*l),m=o?-1:1;r.push(m*f,m*p,m*h)}function uK(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let d=0;d<t;d++)n=Math.min(n,e[d*4]),r=Math.min(r,e[d*4+1]),o=Math.max(o,e[d*4+2]),i=Math.max(i,e[d*4+3]);if(t===0)return{x0:0,y0:0,cell:1,cols:1,rows:1,cells:[[]]};let s=Math.min(64,Math.max(1,Math.ceil(Math.sqrt(t)))),a=Math.max(o-n,i-r,1e-6)/s,l=Math.max(1,Math.ceil((o-n)/a)),u=Math.max(1,Math.ceil((i-r)/a)),c=Array.from({length:l*u},()=>[]);for(let d=0;d<t;d++){let f=Math.min(l-1,Math.floor((e[d*4]-n)/a)),p=Math.min(l-1,Math.floor((e[d*4+2]-n)/a)),h=Math.min(u-1,Math.floor((e[d*4+1]-r)/a)),m=Math.min(u-1,Math.floor((e[d*4+3]-r)/a));for(let g=h;g<=m;g++)for(let b=f;b<=p;b++)c[g*l+b].push(d)}return{x0:n,y0:r,cell:a,cols:l,rows:u,cells:c}}var cK=512,EM=new WeakMap;function CM(e,t,n){let r=EM.get(e);if(r!==void 0&&r.fill===t&&r.inner===n)return r.mesh;let o=t.requiresStencil?null:dK(e,t,n);return EM.set(e,{fill:t,inner:n,mesh:o}),o}function dK(e,t,n){let r=fK(t,e.origin);return r===null?NM(e,t,n):pK(e,r,n)}function fK(e,t){let n=e.vertices,r=(e.origin?.x??0)-(t?.x??0),o=(e.origin?.y??0)-(t?.y??0),i=[];for(let a=0;a<n.length;a+=2){let l=i.length,u=n[a]+r,c=n[a+1]+o;l>=2&&i[l-2]===u&&i[l-1]===c||i.push(u,c)}for(;i.length>=4&&i[0]===i[i.length-2]&&i[1]===i[i.length-1];)i.length-=2;let s=i.length/2;return s<3||e.indices.length!==(s-2)*3?null:zb(i,cK)}var Er={a:new Float32Array(0),b:new Float32Array(0)};function pK(e,t,n){let r=t.length/3;Er.a.length<(r+4)*2&&(Er.a=new Float32Array((r+4)*2),Er.b=new Float32Array((r+4)*2));let o=e.vertices,i=e.indices,s=[],a=[],l=[],u=new Float32Array(6);for(let c=0;c<i.length;c+=3){for(let f=0;f<3;f++)u[f*2]=o[i[c+f]*2],u[f*2+1]=o[i[c+f]*2+1];l.length=0;let d=!1;for(let f=0;f<t.length&&!d;f+=3){let p=0;for(let h=0;h<3;h++)t[f]*u[h*2]+t[f+1]*u[h*2+1]+t[f+2]>=0&&p++;p===0?d=!0:p<3&&l.push(f)}if(d){n||Q0(u,3,s,a);continue}if(n)Q0(Er.a,MM(u,l,l.length,t,-1),s,a);else for(let f=0;f<l.length;f++)Q0(Er.a,MM(u,l,f,t,l[f]),s,a)}return{vertices:new Float32Array(s),indices:new Uint32Array(a),...e.origin?{origin:e.origin}:{}}}function MM(e,t,n,r,o){let i=Er.a,s=Er.b;i.set(e);let a=3;for(let l=0;l<=n&&a>=3&&!(l===n&&o<0);l++){let u=l===n?o:t[l],c=l===n?-1:1;a=ou(i,a,2,c*r[u],c*r[u+1],c*r[u+2],s);let d=i;i=s,s=d}return i!==Er.a&&Er.a.set(i.subarray(0,a*2)),a}function Q0(e,t,n,r){if(t<3)return;let o=n.length/2;for(let i=0;i<t*2;i++)n.push(e[i]);for(let i=1;i<t-1;i++)r.push(o,o+i,o+i+1)}Pe();function Z0(e,t,n,r){for(let o=0;o<e.textures.length;o++){let i=e.textures[o];if(!(i.kind!=="bitmap"||i.image!==t))return i.sampling===n&&i.mips===r?o+1:-1}return tw(e)}function ew(e){return e.ramps?As:tw(e)<0?-1:As}function Mr(e,t){for(let n=0;n<e.textures.length;n++){let r=e.textures[n];if(r.kind==="atlas"&&r.id===t)return n+1}return tw(e)}function tw(e){return e.textures.length+(e.ramps?1:0)+1<yt?e.textures.length+1:-1}function So(e,t,n,r){return t.clipDepth===Zb(e)&&Yb(t.matrices,n,r)>=0&&hK(t,_f(e))}function hK(e,t){return t===null||OM(e,t)!==void 0?!0:e.hullPlanes+t.count<=vs}function OM(e,t){let n=e.hulls;if(n!==void 0){for(let r=0;r<n.length;r++)if(n[r].set===t)return n[r]}}function ko(e){return e.batchState??={clipDepth:Zb(e),matrices:[],textures:[],ramps:!1,hullPlanes:0,areaGlyphs:!1},e.batchState}function vo(e,t,n){let r=_f(e);if(r===null)return n;let o=OM(t,r);return o===void 0&&(o={set:r,start:t.hullPlanes},(t.hulls??=[]).push(o),t.hullPlanes+=r.count),oA(n,o.start,r.count)}function Ao(e,t,n){let r=Yb(e.matrices,t,n);return r===e.matrices.length&&e.matrices.push({colorMatrix:t,alpha:n}),r}Z();Z();Z();function Dp(e,t,n){let r=n??mK,o=pr([r[0],r[1],r[2],r[3],t.x,t.y]);if(!o)return null;let i=e;return q.fromAffine([o[0]*i[0]+o[2]*i[1],o[1]*i[0]+o[3]*i[1],o[0]*i[3]+o[2]*i[4],o[1]*i[3]+o[3]*i[4],o[0]*i[6]+o[2]*i[7]+o[4],o[1]*i[6]+o[3]*i[7]+o[5]])}var mK=[1,0,0,1];var yK=[0,0];function FM(e,t){let n=Es(t.texture.id);if(!n)return;let r=Li(e,t.units),o=r&&Dp(r,t.origin??{x:0,y:0},t.transform);if(!o)return null;let i=q.multiply(o,e.state.transform),[s,a]=nw(t,n);return{kind:"pattern",id:t.texture.id,source:n.source,opacity:t.opacity??1,uv:{ux:i[0]/s,uy:i[3]/s,u0:i[6]/s,vx:i[1]/a,vy:i[4]/a,v0:i[7]/a}}}function nw(e,{source:t,size:n}){let r=e.width??n?.width??("naturalWidth"in t?t.naturalWidth:t.width),o=e.height??n?.height??("naturalHeight"in t?t.naturalHeight:t.height);return[r>0?r:1,o>0?o:1]}function LM(e,t,n){let r=Bs(e,!1),o=e.batchState;o!==void 0&&(!So(e,o,r.colorMatrix,r.alpha)||Mr(o,t.id)<0||Mr(o,t.id)<=o.textures.length&&e.textureCache.replaces(t.id,t.source))&&ye(e),e.drawBatch.wouldOverflow(n)&&ye(e),e.textureCache.uploadRegistered(t.id,t.source,"repeat");let i=ko(e),s=Mr(i,t.id);return s>i.textures.length&&(i.textures.push({kind:"atlas",id:t.id,fieldScale:yK}),s=i.textures.length),r.slot=vo(e,i,co(s,Ao(i,r.colorMatrix,r.alpha))),r}function _M(e,t,n){return{...e,u0:e.u0-Math.floor(e.ux*t+e.uy*n+e.u0),v0:e.v0-Math.floor(e.vx*t+e.vy*n+e.v0)}}function rw(e,t,n){let{slot:r,tint:o}=LM(e,n,4);e.drawBatch.pushGradientRect(t.x,t.y,t.width,t.height,e.state.transform,_M(n.uv,t.x,t.y),n.opacity*o[3],r,Rs,o[0],o[1],o[2],1)||sn(e,t,n,rw)}function ow(e,t,n){let{slot:r,tint:o}=LM(e,n,t.vertices.length>>1),i=t.vertices.length>0?{x:t.vertices[0]+(t.origin?.x??0),y:t.vertices[1]+(t.origin?.y??0)}:{x:0,y:0};e.drawBatch.pushGradientMesh(t,e.state.transform,_M(n.uv,i.x,i.y),n.opacity*o[3],r,Rs,o[0],o[1],o[2],1)||sn(e,t,n,ow)}function Gu(e,t,n){if(n)return;let r=t.kind??"solid";if(r==="solid"){let s=t;return{kind:"solid",color:s.color,opacity:s.opacity}}if(r==="texture")return FM(e,t);if(r!=="linear-gradient"&&r!=="radial-gradient"&&r!=="conic-gradient")return;let o=t,i=gK(e,o.units);return i?o.kind==="linear-gradient"?iw(o,ci,bK(i,o)):o.kind==="radial-gradient"?iw(o,rA,xK(i,o)):iw(o,jd,wK(i,o)):null}function iw(e,t,n){return{kind:"ramp",stops:e.stops,space:e.interpolate??"rgb",opacity:e.opacity,mode:t,uv:n}}function gK(e,t){let n=Li(e,t);return n&&q.multiply(n,e.state.transform)}function bK(e,t){let n=t.to.x-t.from.x,r=t.to.y-t.from.y,o=Math.hypot(n,r)||1,i=1/(o*o);return{ux:(e[0]*n+e[1]*r)*i,uy:(e[3]*n+e[4]*r)*i,u0:((e[6]-t.from.x)*n+(e[7]-t.from.y)*r)*i,vx:0,vy:0,v0:0}}function xK(e,t){let n=1/Math.max(t.radius,1e-4);return{ux:e[0]*n,uy:e[3]*n,u0:(e[6]-t.center.x)*n,vx:e[1]*n,vy:e[4]*n,v0:(e[7]-t.center.y)*n}}function wK(e,t){let n=Math.cos(t.angle),r=Math.sin(t.angle),o=e[6]-t.center.x,i=e[7]-t.center.y;return{ux:n*e[0]+r*e[1],uy:n*e[3]+r*e[4],u0:n*o+r*i,vx:n*e[1]-r*e[0],vy:n*e[4]-r*e[3],v0:n*i-r*o}}function sw(e,t){return e.mode===ci?{uv:{...e.uv,v0:t},post:1}:{uv:e.uv,post:t}}function Li(e,t){return t==="local"?q.invert(e.state.transform):t==="world"&&e.viewMatrix?q.invert(e.viewMatrix):e.screenMatrix?q.invert(e.screenMatrix):q.identity()}function aw(e,t,n){let r=Li(e,t);return!r||!n||n.x===0&&n.y===0?r:q.multiply(q.translated(q.identity(),-n.x,-n.y),r)}function DM(e,t){let n=Li(e,t),r=n&&q.invert(n);if(!r)return null;let o=e.deviceWidth&&e.widthCss>0?e.deviceWidth/e.widthCss:1;return q.multiply(q.scaled(q.identity(),o,o),r)}var PK=96,TK=1024,BM={maxVertices:PK,maxVerticesInRun:TK};function lw(e,t){if(t.requiresStencil)return!1;let n=e.drawBatch.length>0?BM.maxVerticesInRun:BM.maxVertices;return t.vertices.length>>1<=n}function Bp(e,t){let n=au(e);return Hp(e,t,n?Ut:e.state.colorMatrix,n?1:e.state.alpha)}function Hp(e,t,n,r){let o=e.batchState;o!==void 0&&!So(e,o,n,r)&&ye(e),e.drawBatch.wouldOverflow(t)&&ye(e);let i=ko(e),s=Ao(i,n,r);return di(vo(e,i,co(eA,s)),ci)}function uw(e,t,n,r){let o=Bs(e,!1),i=e.batchState;i!==void 0&&(!So(e,i,o.colorMatrix,o.alpha)||Z0(i,t,n,r)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let s=ko(e),a=Z0(s,t,n,r);return a>s.textures.length&&(s.textures.push({kind:"bitmap",image:t,sampling:n,mips:r}),a=s.textures.length),o.slot=vo(e,s,co(a,Ao(s,o.colorMatrix,o.alpha))),o}function Uu(e,t,n,r){let o=au(e),i=o?Ut:e.state.colorMatrix,s=o?1:e.state.alpha,a=e.batchState;a!==void 0&&(!So(e,a,i,s)||Mr(a,t)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let l=ko(e),u=Mr(l,t);return u>l.textures.length&&(l.textures.push({kind:"atlas",id:t,fieldScale:n}),u=l.textures.length),r&&(l.areaGlyphs=!0),vo(e,l,co(u,Ao(l,i,s)))}function HM(e,t,n,r){e.gradRamps.wouldReshape(t,n)&&ye(e);let o=Bs(e,!0),i=e.batchState;i!==void 0&&(!So(e,i,o.colorMatrix,o.alpha)||ew(i)<0)&&ye(e),e.drawBatch.wouldOverflow(r)&&ye(e);let s=ko(e),a=ew(s);return s.ramps=!0,{slot:vo(e,s,co(a,Ao(s,o.colorMatrix,o.alpha))),tint:o.tint,rowV:e.gradRamps.rowV(e.gradRamps.upload(t,n))}}function oa(e){let[t,n,r,o]=jn(e.color);return[t,n,r,o*(e.opacity??1)]}var SK=[0,0,0,0];function GM(e,t){let n=jn(t.color);return Lf(e,n[0],n[1],n[2],n[3]*(t.opacity??1),SK)}function cw(e,t,n){let r=Bp(e,4);e.drawBatch.pushRect(t.x,t.y,t.width,t.height,e.state.transform,GM(e,n),r)||sn(e,t,n,cw)}function UM(e,t,n){let r=Bp(e,t.vertices.length>>1),[o,i,s,a]=GM(e,n);e.drawBatch.pushMesh(t,e.state.transform,o,i,s,a,r)||sn(e,t,n,UM)}function dw(e,t,n){let{slot:r,tint:o,rowV:i}=HM(e,n.stops,n.space,4),{uv:s,post:a}=sw(n,i);e.drawBatch.pushGradientRect(t.x,t.y,t.width,t.height,e.state.transform,s,a,r,n.mode,o[0],o[1],o[2],(n.opacity??1)*o[3])||sn(e,t,n,dw)}function WM(e,t,n){let{slot:r,tint:o,rowV:i}=HM(e,n.stops,n.space,t.vertices.length>>1),{uv:s,post:a}=sw(n,i);e.drawBatch.pushGradientMesh(t,e.state.transform,s,a,r,n.mode,o[0],o[1],o[2],(n.opacity??1)*o[3])||sn(e,t,n,WM)}function Wu(e,t,n){return n!==void 0&&lw(e,t)?(n.kind==="ramp"?WM(e,t,n):n.kind==="pattern"?ow(e,t,n):UM(e,t,n),!0):(an(e),!1)}var kK=[0,0];function fw(e,t){let n=Bs(e,!1),r=e.batchState;r!==void 0&&(!So(e,r,n.colorMatrix,n.alpha)||Mr(r,t)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let o=ko(e),i=Mr(o,t);return i>o.textures.length&&(o.textures.push({kind:"atlas",id:t,fieldScale:kK}),i=o.textures.length),n.slot=vo(e,o,co(i,Ao(o,n.colorMatrix,n.alpha))),n}Z();function Gp(e){let t=VM.get(e);if(t)return t;let n={gl:e.gl,get alpha(){return e.state.alpha},program:r=>e.ensureProgram?.(r)??e.programRegistry.get(r)??null,setProjAndModel:r=>nt(e,r),spaceInverse:(r,o)=>aw(e,r,o),spaceToDevice:r=>DM(e,r),get maxTextureSize(){return e.imageCache.maxTextureSide},resources:e.paintResources??vK(e.gl),bindRamp:(r,o,i)=>{let s=e.gradRamps.upload(r,i);return e.gradRamps.bind(o),e.gradRamps.rowV(s)}};return VM.set(e,n),n}var VM=new WeakMap,zM=new WeakMap;function vK(e){let t=zM.get(e);return t||(t=tl(),zM.set(e,t)),t}function Up(e,t,n,r){let o=n.texture,i=Es(o.id);if(!i)return Qt()&&!CA(o.id)&&console.warn(`weasel: pattern TextureHandle "${o.id}" not registered`),null;let s=Li(e,n.units);if(!s)return null;let a=Dp(s,n.origin??{x:0,y:0},n.transform);if(!a)return null;e.textureCache.uploadRegistered(o.id,i.source,"repeat");let l=e.gl;l.useProgram(t.handle),nt(e,t,r),Rn(e,t);let[u,c]=nw(n,i);return a[6]-=Math.floor(a[6]/u)*u,a[7]-=Math.floor(a[7]/c)*c,l.uniformMatrix3fv(t.uniform("u_worldInv"),!1,q.toUniform(a)),l.uniform2f(t.uniform("u_tileSize"),u,c),e.textureCache.bind(o.id,0),l.uniform1i(t.uniform("u_sampler"),0),l.uniform1f(t.uniform("u_opacity"),n.opacity??1),If(e,t,e.state.alpha),t}function Wp(e,t,n,r){let o=aw(e,n.units,n.kind==="linear-gradient"?n.from:n.center);if(!o)return null;let i=e.gl,s=e.gradRamps.upload(n.stops,n.interpolate??"rgb");if(i.useProgram(t.handle),nt(e,t,r),i.uniformMatrix3fv(t.uniform("u_worldInv"),!1,q.toUniform(o)),Rn(e,t),e.gradRamps.bind(0),i.uniform1i(t.uniform("u_ramp"),0),i.uniform1f(t.uniform("u_rampV"),e.gradRamps.rowV(s)),If(e,t,e.state.alpha),i.uniform1f(t.uniform("u_opacity"),n.opacity??1),n.kind==="linear-gradient"){i.uniform1i(t.uniform("u_gradKind"),0);let a=n.to.x-n.from.x,l=n.to.y-n.from.y,u=Math.hypot(a,l)||1;i.uniform2f(t.uniform("u_gradDir"),a/u,l/u),i.uniform1f(t.uniform("u_gradLen"),u),i.uniform1f(t.uniform("u_gradRadius"),0),i.uniform1f(t.uniform("u_gradAngle"),0)}else n.kind==="radial-gradient"?(i.uniform1i(t.uniform("u_gradKind"),1),i.uniform2f(t.uniform("u_gradDir"),0,0),i.uniform1f(t.uniform("u_gradLen"),0),i.uniform1f(t.uniform("u_gradRadius"),n.radius),i.uniform1f(t.uniform("u_gradAngle"),0)):(i.uniform1i(t.uniform("u_gradKind"),2),i.uniform2f(t.uniform("u_gradDir"),0,0),i.uniform1f(t.uniform("u_gradLen"),0),i.uniform1f(t.uniform("u_gradRadius"),0),i.uniform1f(t.uniform("u_gradAngle"),n.angle));return t}function KM(e,t,n){let r=t.anchorA,o=t.anchorB,i=t.anchorT;if(!r||!o||!i){if(n===void 0)return Float32Array.from(e);let l=Math.min(n.length,e.length);for(let u=0;u<l;u++)n[u]=e[u];return n}let s=r.length,a=n??new Float32Array(s*4);for(let l=0;l<s;l++){let u=r[l]*4,c=o[l]*4,d=i[l];for(let f=0;f<4;f++)a[l*4+f]=e[u+f]+(e[c+f]-e[u+f])*d}return a}function zp(e,t,n,r){let o=e.createBuffer();if(!o)throw new Error("attachVertexColors: createBuffer returned null");e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,KM(n,r),e.DYNAMIC_DRAW);let i=t.attribute("a_vertexColor");return i!==void 0&&(e.enableVertexAttribArray(i),e.vertexAttribPointer(i,4,e.FLOAT,!1,0,0)),{vbo:o,location:i}}function Kp(e,{vbo:t,location:n}){n!==void 0&&e.disableVertexAttribArray(n),e.deleteBuffer(t)}var Vp=new Float32Array(256);function AK(e,t,n,r){for(let s=0;s<n*4;s++)t[s]*=r[s&3];if(!au(e))return!1;let o=e.state.colorMatrix,i=e.state.alpha;for(let s=0;s<n*4;s+=4){let a=t[s],l=t[s+1],u=t[s+2],c=t[s+3];for(let d=0;d<4;d++){let f=d*5,p=o[f]*a+o[f+1]*l+o[f+2]*u+o[f+3]*c+o[f+4];if(!(p>=0&&p<=1))return!1}}for(let s=0;s<n*4;s+=4){let a=t[s],l=t[s+1],u=t[s+2],c=t[s+3];t[s]=o[0]*a+o[1]*l+o[2]*u+o[3]*c+o[4],t[s+1]=o[5]*a+o[6]*l+o[7]*u+o[8]*c+o[9],t[s+2]=o[10]*a+o[11]*l+o[12]*u+o[13]*c+o[14],t[s+3]=(o[15]*a+o[16]*l+o[17]*u+o[18]*c+o[19])*i}return!0}function jp(e){return e.kind===void 0||e.kind==="solid"?e:{color:"#ffffff",opacity:e.opacity}}function jM(e,t,n){let r=t.vertices.length>>1;Vp.length<r*4&&(Vp=new Float32Array(Math.max(r*4,Vp.length*2)));let o=KM(n.perAnchor,t,Vp),s=AK(e,o,r,oa(n.paint))?Hp(e,r,Ut,1):Hp(e,r,e.state.colorMatrix,e.state.alpha);e.drawBatch.pushMesh(t,e.state.transform,1,1,1,1,s,o)||sn(e,t,n,jM)}function pw(e,t,n,r){let o=t.vertices.length>>1;return(t.anchorA!==void 0||n.length>=o*4)&&lw(e,t)?(jM(e,t,{perAnchor:n,paint:r}),!0):(an(e),!1)}function hw(e,t){let n=AM(t);n.fill?.paint&&RK(e,n,n.fill.paint),n.stroke?.paint&&OK(e,n)}function RK(e,t,n){let r=n.kind===void 0||n.kind==="solid",o=!!(t.vertexColors&&t.vertexColors.length>0),i=n,s=Gu(e,n,o);if(s===null)return;if(s!==void 0&&t.path.kind==="rect"){s.kind==="ramp"?dw(e,t.path,s):s.kind==="pattern"?rw(e,t.path,s):cw(e,t.path,s);return}let a=Of(e,t.path);if(r&&o?pw(e,a,t.vertexColors,i):Wu(e,a,s))return;let u=jb(e,a);Mf(e,a.origin,()=>{r&&o?NK(e,t,i,u):u.requiresStencil?CK(e,n,u):$p(e,n,u)})}function NK(e,t,n,r){let o=e.gl,i=e.pathFillVColor;o.useProgram(i.handle),o.bindVertexArray(r.vao),nt(e,i),_s(e,i,n.color,n.opacity),Rn(e,i);let s=zp(o,i,t.vertexColors,r);r.requiresStencil?(Bb(e,r.indexCount),De(e,r.indexCount,e.gl.UNSIGNED_INT),Hb(e)):(wt(e),De(e,r.indexCount,e.gl.UNSIGNED_INT)),Kp(o,s),o.bindVertexArray(null)}function mw(e,t){let n=t.kind??"solid";if(n==="solid")return IK(e,t);if(n==="texture")return EK(e,t);if(n==="linear-gradient"||n==="radial-gradient"||n==="conic-gradient")return MK(e,t);let r=Ci(n)?.bind;return r?r(Gp(e),t):null}function $p(e,t,n){if(!mw(e,t))return;let o=e.gl;o.bindVertexArray(n.vao),wt(e),De(e,n.indexCount,e.gl.UNSIGNED_INT),o.bindVertexArray(null)}function IK(e,t){let n=e.pathFill;return e.gl.useProgram(n.handle),nt(e,n),_s(e,n,t.color,t.opacity),Rn(e,n),n}function EK(e,t){return Up(e,e.patternFill,t,Ef(e))}function MK(e,t){return Wp(e,e.gradFill,t,Ef(e))}function CK(e,t,n){let r=e.gl;r.useProgram(e.pathFill.handle),r.bindVertexArray(n.vao),nt(e,e.pathFill),Bb(e,n.indexCount),mw(e,t)&&De(e,n.indexCount,e.gl.UNSIGNED_INT),Hb(e),r.bindVertexArray(null)}function OK(e,t){let{cmd:n,spaces:r}=Hu(e.state.transform,t),o=n.stroke,i=o.align??"center",s=r.ribbon?.metric,a=n.path.kind==="polygon"||s!==void 0&&!Vf(s),l=a&&i!=="center"?LK(e,n,i,r):null;l!==null?YM(e,n,l):a&&i!=="center"?(an(e),Mf(e,n.path.kind==="polygon"?n.path.origin:void 0,()=>BK(e,n,i,r))):FK(e,n,r);let u=at(o.width??1,1),c=kM(n.path,t.stroke,o,u,Ds(e),r);for(let d of c)hw(e,d)}function FK(e,t,n){YM(e,t,Fp(t.path,t.stroke,Ds(e),n))}function LK(e,t,n,r){if(t.stroke.vertexColors&&t.stroke.vertexColors.length>0||e.batchVariants?.cuts===!1)return null;let o=Fp(t.path,qM(t.stroke),Ds(e),r);return CM(o,Of(e,t.path),n==="inner")}function YM(e,t,n){let r=t.stroke,o=r.paint;if(n.indices.length===0)return;let i=!!(r.vertexColors&&r.vertexColors.length>0),s=Gu(e,o,i);s===null||(i?pw(e,n,r.vertexColors,jp(o)):Wu(e,n,s))||Mf(e,n.origin,()=>_K(e,r,n,i))}function _K(e,t,n,r){let o=t.paint,i=o.kind===void 0||o.kind==="solid",s=o,a=r?e.meshCache.uploadTransient(n):e.meshCache.uploadRecurring(n);if(!i&&!r){$p(e,o,a);return}let l=e.gl;if(r){let u=e.pathFillVColor;l.useProgram(u.handle),l.bindVertexArray(a.vao),nt(e,u);let c=jp(o);_s(e,u,c.color,c.opacity),Rn(e,u);let d=zp(l,u,t.vertexColors,a);wt(e),De(e,a.indexCount,e.gl.UNSIGNED_INT),Kp(l,d),l.bindVertexArray(null);return}l.useProgram(e.pathFill.handle),l.bindVertexArray(a.vao),nt(e,e.pathFill),_s(e,e.pathFill,s.color,s.opacity),Rn(e,e.pathFill),wt(e),De(e,a.indexCount,e.gl.UNSIGNED_INT),l.bindVertexArray(null)}var $M=new WeakMap;function DK(e){let t=$M.get(e);return t===void 0&&(t=e.map(n=>Kl(n,2)),$M.set(e,t)),t}function qM(e){return{...e,width:at(e.width??1,1)*2,...e.vertexWidths?{vertexWidths:DK(e.vertexWidths)}:{},align:"center"}}function BK(e,t,n,r){let o=t.stroke,i=o.paint,s=qM(o),a=!!(o.vertexColors&&o.vertexColors.length>0),l=iu(e,t.path),u=Fp(t.path,s,Ds(e),r);if(u.indices.length===0)return;let c=a?e.meshCache.uploadTransient(u):e.meshCache.uploadRecurring(u),d=e.gl,f=a?e.pathFillVColor:e.pathFill;d.useProgram(f.handle),nt(e,f),d.enable(d.STENCIL_TEST),d.colorMask(!1,!1,!1,!1),d.stencilMask(1),d.stencilFunc(d.ALWAYS,1,1),d.stencilOp(d.KEEP,d.KEEP,l.requiresStencil?d.INVERT:d.REPLACE),d.bindVertexArray(l.vao),De(e,l.indexCount,e.gl.UNSIGNED_INT);let p=wi(e.clipDepth);d.colorMask(!0,!0,!0,!0),n==="inner"?d.stencilFunc(d.EQUAL,p|1,p|1):d.stencilFunc(d.EQUAL,p,p|1),d.stencilOp(d.KEEP,d.KEEP,d.KEEP);let h=f;if(a){let g=jp(i);_s(e,f,g.color,g.opacity),Rn(e,f)}else h=mw(e,i);if(!h){d.stencilMask(1),d.clear(d.STENCIL_BUFFER_BIT),d.disable(d.STENCIL_TEST),d.bindVertexArray(null);return}d.bindVertexArray(c.vao);let m=a?zp(d,h,o.vertexColors,c):null;De(e,c.indexCount,e.gl.UNSIGNED_INT),d.stencilMask(1),d.clear(d.STENCIL_BUFFER_BIT),d.disable(d.STENCIL_TEST),m&&Kp(d,m),d.bindVertexArray(null)}Pe();Pe();Z();var yw=1/4096,HK=2048,Yp=new Map;function XM(e,t){let n=Yp.get(e);if(n!==void 0)return n;Yp.size>=HK&&(Yp=new Map);let r=tu(si(t),{flattenTolerance:yw});return Yp.set(e,r),r}Z();var GK=2048,JM=1/1024,qp=new Map;function QM(e){return Math.round(e/JM)*JM}function gw(e,t,n,r,o){if(!(n>0))return null;let i=[e,n,r.join??"miter",r.cap??"butt",r.miterLimit??"",r.align??"center",(r.dash??[]).join(","),mo(o)].join("|"),s=qp.get(i);if(s!==void 0)return s.indices.length===0?null:s;qp.size>=GK&&(qp=new Map);let a=Ti(si(t),{...r,width:n},{flattenTolerance:yw,metric:o});return qp.set(i,a),a.indices.length===0?null:a}function ZM(e,t,n){return bw(e,t,n,r=>XM(r.key,r.d))}function eC(e,t,n,r){let o=e.stroke;if(!xr(o))return null;let i=o.width??1;if(typeof i=="object"){let s=tC(e),[a,l,u,c]=[r[0],r[1],r[3],r[4]];return bw(e,t,n,d=>{if(!(d.scale>0))return null;let f=d.scale,[p,h]=Po(d.rotate),m=[p*f,h*f],g=[-(p*s+h)*f,(p-h*s)*f],b=du(a*m[0]+u*m[1],l*m[0]+c*m[1],a*g[0]+u*g[1],l*g[0]+c*g[1]),x=Op(i.px,b.scale);if(!(x>0))return null;let w=o.dash?.map(y=>y/x);return gw(d.key,d.d,i.px/x,{...o,dash:w},b.metric??void 0)})}return bw(e,t,n,s=>s.scale>0?gw(s.key,s.d,QM(i/s.scale),{...o,dash:o.dash?.map(a=>a/s.scale)}):null)}var tC=e=>e.synthetic.italic?Math.tan(.2094):0;function bw(e,t,n,r){let o=[],i=0,s=0;for(let p of e.glyphs){let h=r(p);!h||h.indices.length===0||(o.push({mesh:h,glyph:p}),i+=h.vertices.length,s+=h.indices.length)}if(o.length===0)return null;let a=tC(e),l=new Float32Array(i),u=new Uint32Array(s),c=0,d=0,f=0;for(let{mesh:p,glyph:h}of o){let{x:m,baselineY:g,scale:b}=h,[x,w]=Po(h.rotate);for(let y=0;y<p.vertices.length;y+=2){let P=p.vertices[y],S=p.vertices[y+1],v=(P-S*a)*b,A=S*b;l[c++]=m+t+v*x-A*w,l[c++]=g+n+v*w+A*x}for(let y=0;y<p.indices.length;y++)u[d++]=f+p.indices[y];f+=p.vertices.length/2}return{vertices:l,indices:u}}function nC(e,t,n,r,o,i){let s=e[t]+n,a=e[t+1]+r,l=e[t+2]+n,u=e[t+3]+r,c=e[t+8]+r,d=(c-a)*o,f=(c-u)*o;i[0]=s+d,i[1]=a,i[2]=l+d,i[3]=a,i[4]=l+f,i[5]=u,i[6]=s+f,i[7]=u;let p=e[t+10];if(!p)return;let[h,m]=Po(p),g=e[t+9]+n;for(let b=0;b<8;b+=2){let x=i[b]-g,w=i[b+1]-c;i[b]=g+x*h-w*m,i[b+1]=c+x*m+w*h}}var ia=new Array(11).fill(0);function Xp(e,t,n,r,o,i,s,a){let l=a.xy;nC(e,t,n,r,o,l),rC(i,l);let u=a.uv;for(let b=0;b<4;b++)u[b]=e[t+4+b];if(s<=0)return;let c=Math.abs((l[2]-l[0])*(l[7]-l[1])-(l[3]-l[1])*(l[6]-l[0]));if(c===0)return;let d=e[t+2]-e[t],f=e[t+3]-e[t+1],p=s*d*Math.hypot(l[6]-l[0],l[7]-l[1])/c,h=s*f*Math.hypot(l[2]-l[0],l[3]-l[1])/c;for(let b=0;b<11;b++)ia[b]=e[t+b];ia[0]-=p,ia[2]+=p,ia[1]-=h,ia[3]+=h;let m=(u[2]-u[0])*p/d,g=(u[3]-u[1])*h/f;u[0]-=m,u[2]+=m,u[1]-=g,u[3]+=g,nC(ia,0,n,r,o,l),rC(i,l)}function rC(e,t){for(let n=0;n<8;n+=2){let r=t[n],o=t[n+1];t[n]=e[0]*r+e[3]*o+e[6],t[n+1]=e[1]*r+e[4]*o+e[7]}}Pe();Z();function Jp(e){let t=Math.hypot(e[0],e[1]),n=Math.hypot(e[3],e[4]);return Math.sqrt(t*n)||1}function oC(e,t,n,r){let o=t.fill?.paint;if(o===void 0||t.quads.length===0||!td(e.textureCache,t.page))return;let i=Ht(o)?oa(o)[3]:1,s=Qc(t.page),a=e.drawBatch,l=e.state.transform,u=e.deviceWidth&&e.widthCss?e.deviceWidth/e.widthCss:1,c=Jp(l)*u,d=s,{slot:f,tint:p}=fw(e,d),h=()=>{({slot:f,tint:p}=fw(e,d))};for(let m of t.quads){let g=UK(e,m,c),b=g?.quad??m,x=g?.atlasId??s;x!==d&&(d=x,h()),a.wouldOverflow(4)&&(ye(e),h());let w,y=b.rotate?q.multiply(l,q.fromAffine(ro(b.penX+n,b.baselineY+r,b.rotate*Math.PI/180))):l;for(;!a.pushQuad(b.x0+n,b.y0+r,b.x1-b.x0,b.y1-b.y0,y,b.u0,b.v0,b.u1,b.v1,i*p[3],f,p[0],p[1],p[2]);)w=po(e),h();w!==void 0&&(ho(e,w),h())}}function UK(e,t,n){let r=t.colorGlyph;if(!r||r.width===0)return null;let o=(t.x1-t.x0)/r.width,i=ad(r,o*n);if(!i||!nd(e.textureCache,i.glyph.page))return null;let s=i.glyph,a=2**i.level,l=t.x0+(s.xoffset-r.xoffset)*o,u=t.y0+(s.yoffset-r.yoffset)*o;return{quad:{x0:l,y0:u,x1:l+s.width/a*o,y1:u+s.height/a*o,u0:s.x/1024,v0:s.y/1024,u1:(s.x+s.width)/1024,v1:(s.y+s.height)/1024,baselineY:t.baselineY,penX:t.penX,rotate:t.rotate},atlasId:Zc(s.page)}}var iC={vertices:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])};function sC(e,t,n){let r=e.paintScratch,o=Ci(t.kind)?.bind;if(!r||!o)return null;let i=e.deviceWidth&&e.widthCss>0?e.deviceWidth/e.widthCss:1,s=e.deviceWidth??Math.round(e.widthCss),a=e.deviceHeight??Math.round(e.heightCss),l=e.renderTarget?.window??{x:0,y:0,width:s,height:a},u=Math.max(l.x,Math.floor(n.x0*i)),c=Math.max(l.y,Math.floor(n.y0*i)),d=e.imageCache.maxTextureSide,f=Math.min(d,Math.min(l.x+l.width,Math.ceil(n.x1*i))-u),p=Math.min(d,Math.min(l.y+l.height,Math.ceil(n.y1*i))-c);if(!(f>0&&p>0))return null;let h=u/i,m=c/i,g=f/i,b=p/i,x=new Float32Array([g,0,0,0,b,0,h,m,1]),w=new Float32Array([2/g,0,0,0,2/b,0,-1-2*h/g,-1-2*m/b,1]),y=Gp(e),P={...y,alpha:e.state.alpha,maxTextureSize:y.maxTextureSize,setProjAndModel:M=>nt(e,M,x,w)},S=e.gl,v=r.acquire(f,p),A=S.isEnabled(S.SCISSOR_TEST);S.activeTexture(S.TEXTURE0),S.bindTexture(S.TEXTURE_2D,null),S.bindFramebuffer(S.FRAMEBUFFER,v.fbo),S.viewport(0,0,f,p),S.disable(S.SCISSOR_TEST),S.disable(S.STENCIL_TEST),S.clear(S.COLOR_BUFFER_BIT),S.disable(S.BLEND);let N=o(P,t);return N&&(S.bindVertexArray(e.meshCache.uploadRecurring(iC).vao),De(e,iC.indices.length,S.UNSIGNED_INT),S.bindVertexArray(null)),S.enable(S.BLEND),Zs(e,s,a,A),N?{texture:v.texture,uvFromScreen:new Float32Array([i/v.width,0,0,0,i/v.height,0,-u/v.width,-c/v.height,1])}:null}function aC(e,t,n){let r=e.gl;return r.useProgram(t.handle),nt(e,t,Hs),r.uniformMatrix3fv(t.uniform("u_worldInv"),!1,n.uvFromScreen),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.texture),r.uniform1i(t.uniform("u_sampler"),0),t}var Qp=48,lC={outlineMinSize:void 0};function cC(e,t){let n=e.textOutlineMinScreenSize??Qp,r=Number.isFinite(n)?n/Jp(e.state.transform):void 0,{laid:o,dx:i,dy:s}=Ap(t);lC.outlineMinSize=r;let{groups:a,decorations:l}=w0(o,t.runs,lC,"read");if(!(a.length===0&&l.length===0)){for(let u of a)u.source==="outline"?WK(e,u,i,s):u.source==="color"?oC(e,u,i,s):KK(e,u,i,s);VK(e,l,i,s)}}function WK(e,t,n,r){let o=t.fill?.paint;if(o!==void 0){let a=ZM(t,n,r);a&&Pw(e,o,a)}let i=t.stroke?.paint;if(!i)return;let s=eC(t,n,r,e.state.transform);s&&Pw(e,i,s)}function Pw(e,t,n){let r=Gu(e,t,!1);r!==null&&(Wu(e,n,r)||$p(e,t,e.meshCache.uploadTransient(n)))}function VK(e,t,n,r){for(let o of t){let i=o.fill.paint;if(i===void 0)continue;if(fC(i)!==null){Pw(e,i,zK(o.x0+n,o.y0+r,o.x1+n,o.y1+r));continue}let[s,a,l,u]=Ht(i)?oa(i):[0,0,0,1],c;for(;;){let d=Bp(e,4),f=$b(e,s,a,l,u);if(e.drawBatch.pushRect(o.x0+n,o.y0+r,o.x1-o.x0,o.y1-o.y0,e.state.transform,f,d))break;c=po(e)}c!==void 0&&ho(e,c)}}function zK(e,t,n,r){return{vertices:new Float32Array([e,t,n,t,n,r,e,r]),indices:new Uint32Array([0,1,2,0,2,3])}}function dC(e,t,n,r){let o=(e.deviceWidth??e.widthCss)/(e.widthCss||1),i=Math.hypot(n[0],n[1])*o*(t[2]-t[0])/Math.abs(t[6]-t[4]),s=Math.hypot(n[3],n[4])*o*(t[3]-t[1])/Math.abs(t[7]-t[5]);return Vy(r,i,s)?gd/o:0}function KK(e,t,n,r){if(t.source==="canvas"){if(!ed(e.textureCache,t.page))return}else if(!_y(t.family,t.weight,t.style,e.textureCache))return;if(t.quadData.length===0)return;let o=t.source==="canvas"?Jc(t.page):es(t.family,t.weight,t.style),i=t.source==="canvas"?Wy:Uy,s=Ky(t.source==="canvas"?"canvas":"atlas",t.family,t.weight,t.style);if(!s)return;let a=t.synthetic.bold?pl:0,l=t.synthetic.italic?Math.tan(.2094):0,u=t.fill?.paint;if(u===void 0)return;let c=fC(u);if(c!==null){qK(e,t,n,r,c,o,i,a,l,s);return}let d=Ht(u)?jn(u.color):jK,f=Ht(u)?u.opacity??1:1,p=e.drawBatch,h=e.state.transform,m=dC(e,t.quadData,h,s),g=m>0,b=Uu(e,o,s,g),x=Lf(e,d[0],d[1],d[2],d[3]*f,$K),w=t.quadData;for(let y=0;y<w.length;y+=Ar){p.wouldOverflow(4)&&(ye(e),b=Uu(e,o,s,g));let P;for(;!p.pushGlyph(w,y,n,r,l,h,x,b,i,a,m);)P=po(e),b=Uu(e,o,s,g);P!==void 0&&(ho(e,P),b=Uu(e,o,s,g))}}var jK=[0,0,0,1],$K=[0,0,0,0];function fC(e){let t=e.kind??"solid";return t==="texture"?"pattern":t==="linear-gradient"||t==="radial-gradient"||t==="conic-gradient"?"gradient":t==="solid"?null:"texture"}var ww=1,YK=[1,1,1,1];function qK(e,t,n,r,o,i,s,a,l,u){let c=e.glyphPaintProgram?.(o);if(!c)return;an(e);let d=t.fill.paint,f=e.state.transform,p=dC(e,t.quadData,f,u),h;if(o==="pattern")h=Up(e,c,d,Hs);else if(o==="gradient")h=Wp(e,c,d,Hs);else{let w=sC(e,d,XK(t,n,r,l,f,p));h=w&&aC(e,c,w)}if(!h)return;let m=e.gl;e.textureCache.bind(i,ww),m.uniform1i(c.uniform("u_atlas"),ww),m.uniform1f(c.uniform("u_synthBold"),a),m.uniform2f(c.uniform("u_fieldScale"),u[0],u[1]),wt(e);let g=e.drawBatch,b=g.clip;g.clip=null;let x=t.quadData;for(let w=0;w<x.length;w+=Ar)g.wouldOverflow(4)&&uC(e),g.pushGlyph(x,w,n,r,l,f,YK,ww,s,0,p);uC(e),g.clip=b,m.activeTexture(m.TEXTURE0),m.bindVertexArray(null)}function uC(e){let t=e.drawBatch;t.length!==0&&(De(e,t.uploadAndBind(),e.gl.UNSIGNED_INT),t.reset())}function XK(e,t,n,r,o,i){let s={x0:1/0,y0:1/0,x1:-1/0,y1:-1/0},a=e.quadData,l={xy:[],uv:[]};for(let u=0;u<a.length;u+=Ar){Xp(a,u,t,n,r,o,i,l);let c=l.xy;for(let d=0;d<8;d+=2)s.x0=Math.min(s.x0,c[d]),s.x1=Math.max(s.x1,c[d]),s.y0=Math.min(s.y0,c[d+1]),s.y1=Math.max(s.y1,c[d+1])}return s}var JK=2;function QK(e){let t=e.state.transform,n=e.deviceWidth&&e.widthCss?e.deviceWidth/e.widthCss:1,r=(JK*n)**2;return[r*(t[0]*t[0]+t[1]*t[1]),r*(t[3]*t[3]+t[4]*t[4])]}var ZK=(e,t,n,r,o)=>t*t>=e[0]*r*r||n*n>=e[1]*o*o,ej=(e,t)=>!t||t.x<=0&&t.y<=0&&t.x+t.w>=e.width&&t.y+t.h>=e.height;function Tw(e,t){e.imageCache.upload(t.image,t.image);let n=ej(t.image,t.source);n&&e.imageCache.lacksMipmaps(t.image)&&ZK(QK(e),t.image.width,t.image.height,t.w,t.h)&&e.imageCache.buildMipmaps(t.image);let r=n&&e.imageCache.hasMipmaps(t.image),{slot:o,tint:i}=uw(e,t.image,t.sampling??"linear",r),s=t.source,a=0,l=0,u=1,c=1;if(s){let d=t.image.width,f=t.image.height;a=s.x/d,u=(s.x+s.w)/d,l=s.y/f,c=(s.y+s.h)/f}if(t.flipX){let d=a;a=u,u=d}if(t.flipY){let d=l;l=c,c=d}e.drawBatch.pushQuad(t.x,t.y,t.w,t.h,e.state.transform,a,l,u,c,(t.opacity??1)*i[3],o,i[0],i[1],i[2])||sn(e,t,void 0,Tw)}function pC(e,t){let n=t.sprites,r=Math.floor(n.length/9);if(r===0)return;e.imageCache.upload(t.image,t.image);let o=t.sampling??"linear",i=()=>uw(e,t.image,o,!1),{slot:s,tint:a}=i(),l=e.drawBatch,u=e.state.transform,c=t.image.width,d=t.image.height;for(let f=0,p=0;f<r;f++,p+=9){l.wouldOverflow(4)&&(ye(e),{slot:s,tint:a}=i());let h=n[p+4],m=n[p+5],g=n[p+6],b=n[p+7],x;for(;!l.pushQuad(n[p],n[p+1],n[p+2],n[p+3],u,h/c,m/d,(h+g)/c,(m+b)/d,n[p+8]*a[3],s,a[0],a[1],a[2]);)x=po(e),{slot:s,tint:a}=i();x!==void 0&&(ho(e,x),{slot:s,tint:a}=i())}}function _i(e,t){switch(t.kind){case"group":return tj(e,t);case"path":return hw(e,t);case"text":return cC(e,t);case"image":return Tw(e,t);case"sprites":return pC(e,t);case"shader":return an(e),FR(e,t)}}function hC(e){return e.isolate===!0||$n(e.composite)||e.effects!==void 0&&e.effects.length>0}function tj(e,t){if(!(t.retain!==void 0&&XE(e,t,hC(t),_i))){if(hC(t)&&e.effectTargets&&e.deviceWidth&&e.deviceHeight){if(t.clip){e.state.push({transform:t.transform});try{uu(e,t.clip)}finally{e.state.pop()}}YE(e,t,e.effectTargets,e.deviceWidth,e.deviceHeight,_i),t.clip&&Jb(e);return}if(e.state.push({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix}),t.clip)try{uu(e,t.clip)}catch(n){throw e.state.pop(),n}for(let n of t.children)_i(e,n);t.clip&&Jb(e),e.state.pop()}}var Yn=10,oe=Yn,nj=256,rj=384,Sw=32;function Ro(e,t){let n=e;for(;n<t;)n*=2;return n}var Zp=class{verts=new Float32Array(nj*oe);idx=new Uint32Array(rj);nVerts=0;nIdx=0;pureRects=!0;clip=null;polyIn=new Float32Array(Sw*oe);polyOut=new Float32Array(Sw*oe);polyTmp=new Float32Array(Sw*oe);triangles=new Uint32Array(0);writeVertex(t,n,r,o,i,s,a,l,u,c,d){let f=this.verts;return f[t]=n,f[t+1]=r,f[t+2]=o,f[t+3]=i,f[t+4]=s,f[t+5]=a,f[t+6]=l,f[t+7]=u,f[t+8]=c,f[t+9]=d,t+oe}pushQuadIndices(){let t=this.nVerts,n=this.nIdx;this.idx[n++]=t,this.idx[n++]=t+1,this.idx[n++]=t+2,this.idx[n++]=t,this.idx[n++]=t+2,this.idx[n++]=t+3,this.nVerts+=4,this.nIdx+=6}reserve(t,n){let r=(this.nVerts+t)*oe;if(r>this.verts.length){let i=new Float32Array(Ro(this.verts.length,r));i.set(this.verts),this.verts=i}let o=this.nIdx+n;if(o>this.idx.length){let i=new Uint32Array(Ro(this.idx.length,o));i.set(this.idx),this.idx=i}}fitQuad(t,n){let r=this.clip;if(r===null)return!0;let o=this.verts,i=t*oe;if(Pr(r,o[i],o[i+1])&&Pr(r,o[i+oe],o[i+oe+1])&&Pr(r,o[i+2*oe],o[i+2*oe+1])&&Pr(r,o[i+3*oe],o[i+3*oe+1])||(this.nVerts=t,this.nIdx=n,Cf(r,o,i,4,oe)))return!0;if(!r.slanted){let s=o[i],a=o[i+1],l=o[i+oe],u=o[i+oe+1],c=o[i+2*oe],d=o[i+2*oe+1],f=o[i+3*oe],p=o[i+3*oe+1];if(!(a===u&&l===c&&d===p&&f===s||s===l&&u===d&&c===f&&p===a)||r.planes.length>0)return!1}return this.polyIn.set(o.subarray(i,i+4*oe)),this.appendFan(Kb(this.polyIn,4,oe,r,this.polyOut,this.polyTmp)),!0}fitMesh(t,n){let r=this.clip;if(r===null)return!0;let o=this.verts,i=!0;for(let u=t*oe;u<this.nVerts*oe&&i;u+=oe)i=Pr(r,o[u],o[u+1]);if(i)return!0;let s=this.nIdx,a=Cf(r,o,t*oe,this.nVerts-t,oe);if(a||!r.slanted)return this.nVerts=t,this.nIdx=n,a;this.triangles.length<s-n&&(this.triangles=new Uint32Array(Ro(64,s-n)));let l=this.triangles;l.set(this.idx.subarray(n,s)),this.nIdx=n;for(let u=0;u<s-n;u+=3)this.fitTriangle(r,l[u],l[u+1],l[u+2]);return!0}fitTriangle(t,n,r,o){let i=this.verts;if(Pr(t,i[n*oe],i[n*oe+1])&&Pr(t,i[r*oe],i[r*oe+1])&&Pr(t,i[o*oe],i[o*oe+1])){this.reserve(0,3),this.idx[this.nIdx++]=n,this.idx[this.nIdx++]=r,this.idx[this.nIdx++]=o;return}let s=this.polyIn;s.set(i.subarray(n*oe,n*oe+oe),0),s.set(i.subarray(r*oe,r*oe+oe),oe),s.set(i.subarray(o*oe,o*oe+oe),2*oe),!Cf(t,s,0,3,oe)&&this.appendFan(Kb(s,3,oe,t,this.polyOut,this.polyTmp))}appendFan(t){if(t<3)return;this.reserve(t,(t-2)*3),t!==4&&(this.pureRects=!1);let n=this.nVerts;this.verts.set(this.polyOut.subarray(0,t*oe),n*oe);let r=this.nIdx;for(let o=1;o<t-1;o++)this.idx[r++]=n,this.idx[r++]=n+o,this.idx[r++]=n+o+1;this.nVerts+=t,this.nIdx=r}};var oj=32768;var kw={xy:new Array(8).fill(0),uv:[0,0,0,0]},ij=[0,0,0,0],Vu=.5,zu=.5,sj={ux:0,uy:0,u0:Vu,vx:0,vy:0,v0:zu},aj=64,Cr=[{vertices:16,indices:24},{vertices:1024,indices:3072}],lj=Cr[Cr.length-1].vertices,mC=4;function uj(e){let t=new Uint32Array(e*6);for(let n=0;n<e;n++){let r=n*4,o=n*6;t[o]=r,t[o+1]=r+1,t[o+2]=r+2,t[o+3]=r,t[o+4]=r+2,t[o+5]=r+3}return t}var Ku=class extends Zp{gl;aPos;aColor;aUv;aPost;aSlot;rings=Cr.map(()=>new Array(aj).fill(void 0));nextInRing=Cr.map(()=>0);largeRing=new Array(mC).fill(void 0);nextLarge=0;constructor(t,n){super();let r=n.attribute("a_position"),o=n.attribute("a_vertexColor"),i=n.attribute("a_uv"),s=n.attribute("a_post"),a=n.attribute("a_texSlot");if(r===void 0||o===void 0||i===void 0||s===void 0||a===void 0)throw new Error("DrawBatch: batch program is missing a_position / a_vertexColor / a_uv / a_post / a_texSlot");this.gl=t,this.aPos=r,this.aColor=o,this.aUv=i,this.aPost=s,this.aSlot=a}get length(){return this.nIdx}wouldOverflow(t){return this.nVerts+t>oj}pushRect(t,n,r,o,i,s,a){let l=s[0],u=s[1],c=s[2],d=s[3];this.reserve(4,6);let f=this.nVerts*Yn,p=i[0],h=i[1],m=i[3],g=i[4],b=i[6],x=i[7],w=t+r,y=n+o,P=p*t+m*n+b,S=h*t+g*n+x,v=p*w+m*n+b,A=h*w+g*n+x,N=p*w+m*y+b,M=h*w+g*y+x,C=p*t+m*y+b,F=h*t+g*y+x;return f=this.writeVertex(f,P,S,l,u,c,d,Vu,zu,1,a),f=this.writeVertex(f,v,A,l,u,c,d,Vu,zu,1,a),f=this.writeVertex(f,N,M,l,u,c,d,Vu,zu,1,a),this.writeVertex(f,C,F,l,u,c,d,Vu,zu,1,a),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushQuad(t,n,r,o,i,s,a,l,u,c,d,f=1,p=1,h=1){this.reserve(4,6);let m=this.nVerts*Yn,g=i[0],b=i[1],x=i[3],w=i[4],y=i[6],P=i[7],S=t+r,v=n+o,A=g*t+x*n+y,N=b*t+w*n+P,M=g*S+x*n+y,C=b*S+w*n+P,F=g*S+x*v+y,B=b*S+w*v+P,D=g*t+x*v+y,j=b*t+w*v+P,W=di(d,Rs);return m=this.writeVertex(m,A,N,f,p,h,1,s,a,c,W),m=this.writeVertex(m,M,C,f,p,h,1,l,a,c,W),m=this.writeVertex(m,F,B,f,p,h,1,l,u,c,W),this.writeVertex(m,D,j,f,p,h,1,s,u,c,W),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGlyph(t,n,r,o,i,s,a,l,u,c,d=0){this.reserve(4,6);let f=this.nVerts*Yn;Xp(t,n,r,o,i,s,d,kw);let p=kw.xy,h=kw.uv,m=a[0],g=a[1],b=a[2],x=a[3],w=di(l,u),y=d>0?Zv:ij;return f=this.writeVertex(f,p[0],p[1],m,g,b,x,h[0],h[1],c+y[0],w),f=this.writeVertex(f,p[2],p[3],m,g,b,x,h[2],h[1],c+y[1],w),f=this.writeVertex(f,p[4],p[5],m,g,b,x,h[2],h[3],c+y[2],w),this.writeVertex(f,p[6],p[7],m,g,b,x,h[0],h[3],c+y[3],w),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGradientRect(t,n,r,o,i,s,a,l,u,c,d,f,p){this.reserve(4,6);let h=this.nVerts*Yn,m=i[0],g=i[1],b=i[3],x=i[4],w=i[6],y=i[7],P=t+r,S=n+o,v=di(l,u),A=(N,M)=>{let C=h;return h=this.writeVertex(C,m*N+b*M+w,g*N+x*M+y,c,d,f,p,s.ux*N+s.uy*M+s.u0,s.vx*N+s.vy*M+s.v0,a,v),h};return A(t,n),A(P,n),A(P,S),A(t,S),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGradientMesh(t,n,r,o,i,s,a,l,u,c,d){let f=t.vertices,p=t.indices,h=f.length>>1;this.reserve(h,p.length),this.pureRects=!1;let m=this.verts,g=this.nVerts*Yn,b=n[0],x=n[1],w=n[3],y=n[4],P=n[6],S=n[7],v=di(i,s),A=t.origin?.x??0,N=t.origin?.y??0;for(let B=0;B<h;B++){let D=f[B*2]+A,j=f[B*2+1]+N;if(m[g++]=b*D+w*j+P,m[g++]=x*D+y*j+S,d===void 0)m[g++]=a,m[g++]=l,m[g++]=u,m[g++]=c;else{let W=B*4;m[g++]=a*d[W],m[g++]=l*d[W+1],m[g++]=u*d[W+2],m[g++]=c*d[W+3]}m[g++]=r.ux*D+r.uy*j+r.u0,m[g++]=r.vx*D+r.vy*j+r.v0,m[g++]=o,m[g++]=v}let M=this.nVerts,C=this.idx,F=this.nIdx;for(let B=0;B<p.length;B++)C[F++]=M+p[B];return this.nVerts+=h,this.nIdx+=p.length,this.fitMesh(M,this.nIdx-p.length)}pushMesh(t,n,r,o,i,s,a,l){return this.pushGradientMesh(t,n,sj,1,a,ci,r,o,i,s,l)}uploadAndBind(){let t=this.gl,n=Cr.findIndex(o=>this.nVerts<=o.vertices&&this.nIdx<=o.indices),r=n<0?this.nextLargeSlot():this.nextRingSlot(n);if(t.bindVertexArray(r.vao),t.bindBuffer(t.ARRAY_BUFFER,r.vbo),t.bufferSubData(t.ARRAY_BUFFER,0,this.verts,0,this.nVerts*Yn),!this.pureRects)t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,this.idx,0,this.nIdx),r.canonicalQuads=0;else if(r.canonicalQuads<this.nVerts>>2){let o=Math.min(r.vertexCapacity>>2,Math.floor(r.indexCapacity/6));t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,uj(o)),r.canonicalQuads=o}return this.nIdx}reset(){this.nVerts=0,this.nIdx=0,this.pureRects=!0}dispose(){for(let t of[...this.rings.flat(),...this.largeRing])t&&this.deleteSet(t);for(let t of this.rings)t.fill(void 0);this.largeRing.fill(void 0)}nextRingSlot(t){let n=this.rings[t],r=this.nextInRing[t];this.nextInRing[t]=(r+1)%n.length;let o=n[r];if(o)return o;let i=this.createSet(Cr[t].vertices,Cr[t].indices);return n[r]=i,i}nextLargeSlot(){let t=this.gl,n=this.nextLarge;this.nextLarge=(n+1)%mC;let r=this.largeRing[n];return r?(this.nVerts>r.vertexCapacity&&(r.vertexCapacity=Ro(r.vertexCapacity,this.nVerts),t.bindBuffer(t.ARRAY_BUFFER,r.vbo),t.bufferData(t.ARRAY_BUFFER,r.vertexCapacity*Yn*4,t.DYNAMIC_DRAW)),this.nIdx>r.indexCapacity&&(r.indexCapacity=Ro(r.indexCapacity,this.nIdx),t.bindVertexArray(r.vao),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r.ibo),t.bufferData(t.ELEMENT_ARRAY_BUFFER,r.indexCapacity*4,t.DYNAMIC_DRAW),t.bindVertexArray(null),r.canonicalQuads=0),r):(r=this.createSet(Ro(lj,this.nVerts),Ro(Cr[Cr.length-1].indices,this.nIdx)),this.largeRing[n]=r,r)}createSet(t,n){let r=this.gl,o=r.createVertexArray(),i=r.createBuffer(),s=r.createBuffer();if(!o||!i||!s)throw new Error("DrawBatch: failed to create GL objects");let a=Yn*4;return r.bindVertexArray(o),r.bindBuffer(r.ARRAY_BUFFER,i),r.bufferData(r.ARRAY_BUFFER,t*a,r.DYNAMIC_DRAW),r.enableVertexAttribArray(this.aPos),r.vertexAttribPointer(this.aPos,2,r.FLOAT,!1,a,0),r.enableVertexAttribArray(this.aColor),r.vertexAttribPointer(this.aColor,4,r.FLOAT,!1,a,8),r.enableVertexAttribArray(this.aUv),r.vertexAttribPointer(this.aUv,2,r.FLOAT,!1,a,24),r.enableVertexAttribArray(this.aPost),r.vertexAttribPointer(this.aPost,1,r.FLOAT,!1,a,32),r.enableVertexAttribArray(this.aSlot),r.vertexAttribPointer(this.aSlot,1,r.FLOAT,!1,a,36),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,s),r.bufferData(r.ELEMENT_ARRAY_BUFFER,n*4,r.DYNAMIC_DRAW),r.bindVertexArray(null),{vao:o,vbo:i,ibo:s,vertexCapacity:t,indexCapacity:n,canonicalQuads:0}}deleteSet(t){let n=this.gl;n.deleteBuffer(t.vbo),n.deleteBuffer(t.ibo),n.deleteVertexArray(t.vao)}};var yC=`#version 300 es
397
+ `;var Fx="weasel:effect-composite";function ip(){return Nn(Fx)||op(Fx,iI,sI),Fx}function $s(e){let t=0;for(let n of e){if(n.reach===void 0||!(n.reach>=0))return 1/0;t+=n.reach}return t}Z();Z();Pe();Z();Pe();Pe();function aI(e,t,n){return{pts:[e.x,e.y],a:[e.a],b:[e.b],t:[e.t],w:t?[e.w]:null,o:n?[e.o]:null}}function Lx(e,t){e.pts.push(t.x,t.y),e.a.push(t.a),e.b.push(t.b),e.t.push(t.t),e.w?.push(t.w),e.o?.push(t.o)}function sp(e,t=!1){let n={points:e.pts,closed:t,anchorA:new Uint32Array(e.a),anchorB:new Uint32Array(e.b),anchorT:new Float32Array(e.t)};return e.w&&(n.widths=new Float32Array(e.w)),e.o&&(n.offsets=new Float32Array(e.o)),n}function lI(e,t,n,r=Ri(e)){let o=Mf(t,r);return o==="solid"?[...e]:o==="non-finite"?[]:e.flatMap((i,s)=>cz(i,o,n?.[s]??0))}function Ri(e){return e.reduce((t,n)=>t+uI(n),0)}function uI(e){let t=e.points,n=t.length/2,r=0;for(let o=1;o<n;o++)r+=Math.hypot(t[o*2]-t[o*2-2],t[o*2+1]-t[o*2-1]);return e.closed&&n>1&&(r+=Math.hypot(t[0]-t[n*2-2],t[1]-t[n*2-1])),r}function cz(e,t,n=0){let r=Mf(t,uI(e));if(r==="solid")return[e];if(r==="non-finite")return[];let o=[],i=e.points.length/2,s=e.anchorA??new Uint32Array(i),a=e.anchorB??new Uint32Array(i),l=e.anchorT??new Float32Array(i),u=e.widths,c=e.offsets,d=P=>({x:e.points[P*2],y:e.points[P*2+1],a:s[P],b:a[P],t:l[P],w:u?u[P]:0,o:c?c[P]:0}),f=0,p=r[0],h=!0;if(n>0){let P=n%(r.reduce((S,v)=>S+v,0)*(r.length%2+1));for(;P>=r[f];)P-=r[f],f=(f+1)%r.length,h=!h;p=r[f]-P}let m=h?aI(d(0),!!u,!!c):null,y=P=>{m&&m.pts.length>=4&&o.push(sp(m)),f=(f+1)%r.length,p=r[f],h=!h,m=h?aI(P,!!u,!!c):null},b=e.points[0],x=e.points[1],w=e.closed?i:i-1;for(let P=0;P<w;P++){let S=d(P),v=d((P+1)%i),A=Math.hypot(v.x-b,v.y-x);if(A<=1e-9){h&&m&&Lx(m,v);continue}let N=A,M=0;for(;N>1e-9;)if(N<=p)h&&m&&Lx(m,v),p-=N,b=v.x,x=v.y,N=0,p<=1e-9&&y(v);else{M+=p;let C=M/A,[F,D,B]=yu(S.a,S.b,S.t,v.a,v.b,v.t,C),K={x:S.x+(v.x-S.x)*C,y:S.y+(v.y-S.y)*C,a:F,b:D,t:B,w:S.w+(v.w-S.w)*C,o:S.o+(v.o-S.o)*C};h&&m&&Lx(m,K),b=K.x,x=K.y,N=Math.hypot(v.x-b,v.y-x),y(K)}}let g=m;return g&&g.pts.length>=4&&dz(e,g,o),o}function dz(e,t,n){let r=t.pts[t.pts.length-2],o=t.pts[t.pts.length-1],i=(s,a)=>Math.hypot(r-s,o-a)<=1e-9;e.closed&&n.length>0&&i(n[0].points[0],n[0].points[1])?n[0]=fz(sp(t),n[0]):e.closed&&n.length===0&&i(t.pts[0],t.pts[1])?n.push(sp({pts:t.pts.slice(0,-2),a:t.a.slice(0,-1),b:t.b.slice(0,-1),t:t.t.slice(0,-1),w:t.w?t.w.slice(0,-1):null,o:t.o?t.o.slice(0,-1):null},!0)):n.push(sp(t))}function fz(e,t){let n={points:[...e.points,...t.points.slice(2)],closed:!1,anchorA:Uint32Array.from([...e.anchorA,...t.anchorA.subarray(1)]),anchorB:Uint32Array.from([...e.anchorB,...t.anchorB.subarray(1)]),anchorT:Float32Array.from([...e.anchorT,...t.anchorT.subarray(1)])};return e.widths&&t.widths&&(n.widths=Float32Array.from([...e.widths,...t.widths.subarray(1)])),e.offsets&&t.offsets&&(n.offsets=Float32Array.from([...e.offsets,...t.offsets.subarray(1)])),n}Z();Pe();function pz(e){let t=Math.cos(e.angle),n=-Math.sin(e.angle),r=Math.min(1,Math.max(0,e.ratio));return(o,i)=>{let s=t*i-n*o,a=t*o+n*i;return Math.sqrt(s*s+r*r*a*a)}}function cI(e,t,n){let r=e.points.length/2;if(r<2)return;let o=e.points,i=pz(t),s=e.closed?r:r-1,a=[];for(let g=0;g<s;g++){let P=(g+1)%r,S=o[P*2]-o[g*2],v=o[P*2+1]-o[g*2+1],A=Math.hypot(S,v);a.push(A>0?i(S/A,v/A):NaN)}for(let g=0;g<s;g++)Number.isNaN(a[g])&&(a[g]=g>0?a[g-1]:a.find(P=>!Number.isNaN(P))??1);let l=e.anchorA,u=e.anchorB,c=e.anchorT,d=e.widths,f=e.offsets,p=[],h=[],m=[],y=[],b=[],x=[],w=(g,P)=>{p.push(o[g*2],o[g*2+1]),h.push(l?l[g]:0),m.push(u?u[g]:0),y.push(c?c[g]:0),b.push((d?d[g]:n)*P),f&&x.push(f[g]*P)};w(0,a[0]);for(let g=1;g<r;g++)w(g,a[g-1]),g<s&&w(g,a[g]);e.closed&&w(0,a[s-1]),e.points=p,e.anchorA=Uint32Array.from(h),e.anchorB=Uint32Array.from(m),e.anchorT=Float32Array.from(y),e.widths=Float32Array.from(b),f&&(e.offsets=Float32Array.from(x))}function dI(e,t,n,r){let o=e.points.length/2;if(o===0)return;let i=e.anchorA??new Uint32Array(o),s=e.anchorB??new Uint32Array(o),a=e.anchorT??new Float32Array(o),l=new Float32Array(o),u=new Float32Array(o),c=!1,d=n/2,f=1,p=h=>{let m=Ef(t[h],NaN);return[Number.isNaN(m.left)?d:m.left*f,Number.isNaN(m.right)?d:m.right*f]};for(let h=0;h<o;h++){r&&(f=hz(e,h,r));let m=i[h],y=s[h],b=a[h],[x,w]=p(m);if(m!==y){let[g,P]=p(y);x+=(g-x)*b,w+=(P-w)*b}l[h]=x+w,u[h]=(w-x)/2,u[h]!==0&&(c=!0)}e.widths=l,c&&(e.offsets=u)}function Ni(e,t){return 2*jb(e,t)}function fI(e,t,n,r,o){t&&dI(e,t,r,o),n&&cI(e,n,r)}function hz(e,t,n){let r=e.points,o=r.length/2,i=0,s=0,a=(u,c)=>{let d=r[c*2]-r[u*2],f=r[c*2+1]-r[u*2+1],p=Math.hypot(d,f);p>0&&(i+=d/p,s+=f/p)};t>0?a(t-1,t):e.closed&&o>1&&a(o-1,0),t<o-1?a(t,t+1):e.closed&&o>1&&a(o-1,0);let l=Math.hypot(i,s);return l>0?n(i/l,s/l):1}function ap(e,t,n){let r=e??mt,o=Ni(t,n);return o/2>r?{flattenTolerance:e,offset:o/2}:{flattenTolerance:e}}function ku(e){return e===void 0?"":`${Po(e.metric)}@${e.pxPerUnit}`}var pI=1e-9;function vu(e,t,n,r){let o=Math.abs(e*r-t*n),i=Math.sqrt(o);if(!(o>0)||!Number.isFinite(o))return{scale:0,metric:null};let s=(e*e+t*t)/o,a=(e*n+t*r)/o,l=(n*n+r*r)/o,u=Math.sqrt(s+l+2),c=(s+1)/u,d=a/u,f=(l+1)/u;return Math.abs(d)<pI&&Math.abs(c-f)<pI?{scale:i,metric:null}:{scale:i,metric:{p:c,q:d,r:f}}}function Po(e){return e===void 0?"":`${e.p},${e.q},${e.r}`}function Au(e,t){let n=e.points;for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];n[r]=t.p*o+t.q*i,n[r+1]=t.q*o+t.r*i}}function Ru(e,t){let n=e.points;for(let r=0;r<n.length;r+=2){let o=n[r],i=n[r+1];n[r]=t.r*o-t.q*i,n[r+1]=t.p*i-t.q*o}}function lp(e,t){return e===t?!0:e!==null&&t!==null&&e.p===t.p&&e.q===t.q&&e.r===t.r}function _x(e,t,n){return Math.hypot(e.r*t-e.q*n,e.p*n-e.q*t)}function Dx(e,t,n){return 1/Math.hypot(e.p*t+e.q*n,e.q*t+e.r*n)}function Nu(e,t){for(let n=0;n<e.length;n+=2){let r=e[n],o=e[n+1];e[n]=t.r*r-t.q*o,e[n+1]=t.p*o-t.q*r}}function up(e){return e.q===0}function Bx(e,t){return up(t)?{kind:"rect",x:t.p*e.x,y:t.r*e.y,width:t.p*e.width,height:t.r*e.height}:null}var hI=(e,t)=>e===void 0?{length:0,metric:t}:typeof e=="number"?{length:e,metric:t}:e;function Ii(e,t,n,r,o){let i=hI(r,n),s=hI(o,n),a=e,l=t,u=c=>{a===null||lp(l,c)||(l!==null&&Ru(a,l),c!==null&&Au(a,c),l=c)};if(i.length>0||s.length>0)if(lp(i.metric,s.metric))u(i.metric),a=Us(a,i.length,s.length);else for(let[c,d,f]of[[i.length,i.metric,!0],[s.length,s.metric,!1]])!(c>0)||a===null||(u(d),a=Us(a,f?c:0,f?0:c));return u(n),a}Z();Z();Z();function gI(e,t){let{start:n=0,end:r=1,pace:o="length"}=t??{},i=mI(e,n,o),s=mI(e,r,o);return Number.isNaN(i)||Number.isNaN(s)||i>=s?null:{from:i,to:s}}function mI(e,t,n){return typeof t=="number"?n==="anchor"?Rg(e,t):yI(e,t*e.total):"length"in t?yI(e,t.length):"anchor"in t?Ud(e,t.anchor):Ag(e,t.subpath)}var yI=(e,t)=>Number.isNaN(t)?NaN:Math.min(Math.max(t,0),e.total);function bI(e,t){let n=Wl(e),r=gI(n,t);return r&&Xg(n,r)}var Hx=1e-9;function Gx(e,t,n){let r=[];for(let o=Math.max(t.from.run,0);o<=Math.min(t.to.run,e.length-1);o++){let i=e[o],s=m=>rb(i,m.segment,m.t,n?.[o]),a=o===t.from.run?s(t.from):null,l=o===t.to.run?s(t.to):null,u=Ri([i]),c=a?.length??0,d=l?.length??u;if(d-c<=Hx)continue;if(i.closed&&c<=Hx&&u-d<=Hx){r.push({polyline:i,fromClosed:!0,dashPhase:0});continue}let f=i.closed?mz(i):i,p=Us(f,c,u-d);if(!p)continue;let h=c;if(p!==f){let m=p.points,y=m.length-2;if(a&&c>0){let b=(x,w)=>y>=2?Math.hypot(m[2]-x,m[3]-w):0;h=Math.max(0,c+b(m[0],m[1])-b(a.x,a.y)),[m[0],m[1]]=[a.x,a.y]}l&&u-d>0&&([m[y],m[y+1]]=[l.x,l.y])}r.push({polyline:p,fromClosed:i.closed,dashPhase:h})}return r}function cp(e,t,n){let r=bI(t,n);if(!r)return null;let{runs:o}=Wl(t);return{span:r,runs:o,windowed:Gx(e,r,o)}}function mz(e){let t=e.points.length/2,{anchorA:n,anchorB:r,anchorT:o,widths:i,offsets:s}=e,a=Ol(e)??n?.[0]??0,l=(u,c)=>{let d=new u.constructor(t+1);return d.set(u),d[t]=c,d};return{points:[...e.points,e.points[0],e.points[1]],closed:!1,anchorA:l(n??new Uint32Array(t),a),anchorB:l(r??new Uint32Array(t),a),anchorT:l(o??new Float32Array(t),0),...i?{widths:l(i,i[0])}:{},...s?{offsets:l(s,s[0])}:{}}}var Ux=e=>({...e,points:e.points.slice()}),xI=e=>e?Ri([e]):0,wI=e=>e===void 0||typeof e=="number"||e.metric===null,PI=e=>e===void 0?0:typeof e=="number"?e:e.length;function TI(e,t,n,r,o,i){let s=t?.windowed??[],a=n===null&&wI(r)&&wI(o),l=i?a?yz(e,PI(r),PI(o)):Ri(e.flatMap(f=>Ii(Ux(f),null,n,r,o)??[])):void 0,u=s.map(f=>!i||f.dashPhase<=0||a?f.dashPhase:gz(e,t.runs,f,t.span.from,n,r)),c=[],d=[];return s.forEach(({polyline:f,fromClosed:p},h)=>{let m=Ii(f,null,n,p?void 0:r,p?void 0:o);m!==null&&(c.push(m),d.push(u[h]))}),{runs:c,phases:d,dashLength:l}}function yz(e,t,n){let r=Math.max(0,t)+Math.max(0,n),o=0;for(let i of e){let s=Ri([i]);o+=i.closed||r<=0?s:Math.max(0,s-r)}return o}function gz(e,t,n,r,o,i){let s=e[r.run],a=n.fromClosed?void 0:i,l=Ii(Ux(s),null,o,a,void 0),u={from:{...r,run:0},to:{run:0,segment:1/0,t:1}},[c]=Gx([s],u,t&&[t[r.run]]),d=c?Ii(Ux(c.polyline),null,o,a,void 0):null;return Math.max(0,xI(l)-xI(d))}Z();var bz=10*Un;function Vx(e,t,n,r,o,i,s,a,l,u,c,d,f,p,h){let m=r?1:-1,y=(e.bx-e.ax)/e.len*m,b=(e.by-e.ay)/e.len*m,x=(o+i)/2,w=(o-i)/2,g=(r?e.bx:e.ax)+e.nxUnit*w,P=(r?e.by:e.ay)+e.nyUnit*w,S=e.nxUnit*x,v=e.nyUnit*x;if(s==="square"){let A=g+y*x,N=P+b*x,M=a.length/2;a.push(A+S,N+v),u.push(f),c.push(p),d.push(h);let C=a.length/2;a.push(A-S,N-v),u.push(f),c.push(p),d.push(h),r?l.push(t,M,C,t,C,n):l.push(t,C,M,t,n,C);return}if(s==="round"){let A=a.length/2;a.push(g,P),u.push(f),c.push(p),d.push(h);let N=Math.atan2(v,S),M=r?-Math.PI:Math.PI,C=Math.max(1,Math.ceil(Math.abs(M)/bz)),F=M/C,D=t;for(let B=1;B<C;B++){let K=N+B*F,W=g+Math.cos(K)*x,Q=P+Math.sin(K)*x,le=a.length/2;a.push(W,Q),u.push(f),c.push(p),d.push(h),r?l.push(D,le,A):l.push(D,A,le),D=le}r?l.push(D,n,A):l.push(D,A,n)}}function zx(e,t,n,r,o,i,s,a){let l=n-e,u=r-t,c=Math.hypot(l,u);return c===0?null:{ax:e,ay:t,bx:n,by:r,nxUnit:-u/c,nyUnit:l/c,posA:o,negA:i,posB:s,negB:a,len:c}}function SI(e,t,n,r,o,i,s,a,l,u,c,d,f,p,h,m=-1){let y=e[n],b=e[(n+1)%e.length],x=t[n],w=t[(n+1)%e.length],g=y.bx-y.ax,P=y.by-y.ay,S=b.bx-b.ax,v=b.by-b.ay,A=g*v-P*S;if(A===0)return;let N=A>0,M=N?x+3:x+2,C=N?w+1:w+0,F=(n+1)%e.length,D=d[F],B=f[D],K=p[D],W=h[D],Q=N?[y.negA,y.negB]:[y.posA,y.posB],le=N?[b.negA,b.negB]:[b.posA,b.posB],ke=Q[1],ue=Math.max(...Q)/Math.max(1e-9,Math.min(...Q)),ve=Math.max(...le)/Math.max(1e-9,Math.min(...le)),G=ue>i||ve>i;if(r==="bevel"||G){Wx(y,M,C,N,s,a,l,u,c,B,K,W,m);return}if(r==="miter"){let j=s[M*2],$=s[M*2+1],ee=s[C*2],te=s[C*2+1],he=Pz(j,$,g,P,ee,te,-S,-v);if(!he){Wx(y,M,C,N,s,a,l,u,c,B,K,W,m);return}if(Math.hypot(he[0]-y.bx,he[1]-y.by)>o*ke){Wx(y,M,C,N,s,a,l,u,c,B,K,W,m);return}let Le=s.length/2;s.push(he[0],he[1]),l.push(B),u.push(K),c.push(W);let Se=m>=0?m:Kx(y,s,l,u,c,B,K,W);N?(a.push(M,Le,C),a.push(M,C,Se)):(a.push(M,C,Le),a.push(M,Se,C));return}if(r==="round"){wz(y,M,C,N,s,a,l,u,c,B,K,W,m);return}}var xz=10*Un;function wz(e,t,n,r,o,i,s,a,l,u,c,d,f){let p=e.bx,h=e.by,m=f>=0?f:Kx(e,o,s,a,l,u,c,d),y=o[t*2]-p,b=o[t*2+1]-h,x=o[n*2]-p,w=o[n*2+1]-h,g=Math.hypot(y,b),P=Math.hypot(x,w),S=Math.atan2(b,y),A=Math.atan2(w,x)-S;r&&A<0?A+=2*Math.PI:!r&&A>0&&(A-=2*Math.PI);let N=Math.max(1,Math.ceil(Math.abs(A)/xz)),M=A/N,C=t;for(let F=1;F<N;F++){let D=S+F*M,B=g+(P-g)*F/N;o.push(p+Math.cos(D)*B,h+Math.sin(D)*B);let K=o.length/2-1;s.push(u),a.push(c),l.push(d),r?i.push(C,m,K):i.push(C,K,m),C=K}r?i.push(C,m,n):i.push(C,n,m)}function Wx(e,t,n,r,o,i,s,a,l,u,c,d,f){let p=f>=0?f:Kx(e,o,s,a,l,u,c,d);r?i.push(t,p,n):i.push(t,n,p)}function Kx(e,t,n,r,o,i,s,a){let l=t.length/2;return t.push(e.bx,e.by),n.push(i),r.push(s),o.push(a),l}function Pz(e,t,n,r,o,i,s,a){let l=n*a-r*s;if(Math.abs(l)<1e-9)return null;let u=((o-e)*a-(i-t)*s)/l;return[e+u*n,t+u*r]}function kI(e,t,n,r){let o=e.length,i=n?o:o-1,s=[];for(let l=0;l<i;l++)s.push(Tz(e,t,l,r));for(let l=!0;l;){l=!1;for(let u=0;u<o;u++){let c=u>0||n?s[(u-1+o)%o]??null:null,d=u<i?s[u]:null;c&&d&&c.side===d.side&&c.u>d.s&&(s[(u-1+o)%o]=null,s[u]=null,l=!0)}}let a=[];for(let l=0;l<i;l++){let u=s[l];if(!u){a.push(-1);continue}let c=t[l]+2+u.side,d=t[(l+1)%o]+u.side;r[c*2]=u.x,r[c*2+1]=u.y,r[d*2]=u.x,r[d*2+1]=u.y,a.push(c)}return a}function Tz(e,t,n,r){let o=e[n],i=e[(n+1)%e.length],s=(o.bx-o.ax)*(i.by-i.ay)-(o.by-o.ay)*(i.bx-i.ax);if(s===0)return null;let a=s>0?0:1,l=t[n],u=t[(n+1)%e.length],c=r[(l+a)*2],d=r[(l+a)*2+1],f=r[(l+2+a)*2],p=r[(l+2+a)*2+1],h=r[(u+a)*2],m=r[(u+a)*2+1],y=r[(u+2+a)*2],b=r[(u+2+a)*2+1],x=f-c,w=p-d,g=y-h,P=b-m,S=x*P-w*g;if(S===0)return null;let v=h-c,A=m-d,N=(v*P-A*g)/S,M=(v*w-A*x)/S;return N>0&&N<=1&&M>=0&&M<1?{side:a,x:c+x*N,y:d+w*N,s:N,u:M}:null}var Sz={vertices:new Float32Array(0),indices:new Uint32Array(0),anchorA:new Uint32Array(0),anchorB:new Uint32Array(0),anchorT:new Float32Array(0)};function at(e,t){return Wt(e,t)}function Ei(e,t,n={}){let r=at(t.width??1,1);if(r<=0)return Sz;let o=t.join??"miter",i=t.cap??"butt",s=t.align??"center",a=t.miterLimit??vz,l=t.varyingWidthJoinThreshold??Az,u=n.metric,c=u&&e.kind==="rect"?Bx(e,u):null,d=c??e;d.kind==="rect"&&s!=="center"&&(d={kind:"rect",...$b(d,s,r)});let f=d.kind==="polygon"?ho(d):null;f&&(d=f.path);let p=t.vertexWidths&&t.vertexWidths.length>0?t.vertexWidths:null,h=p&&f?.anchorSources?Hl(p,f.anchorSources,1):p,m=br(d,ap(n.flattenTolerance,r,h??void 0)),y=u?c?(F,D)=>_x(u,F,D):(F,D)=>Dx(u,F,D):void 0,b=[],x=[],w=[],g=[],P=[],S=u??null,v=c?S:null;for(let F of m)fI(F,h,t.nib,r,y);let A,N,M;if(t.trim!==void 0){if(v)for(let F of m)Ru(F,v);({runs:A,phases:N,dashLength:M}=TI(m,cp(m,e,t.trim),S,n.startInset,n.endInset,t.dash!==void 0))}else A=m.flatMap(F=>Ii(F,v,S,n.startInset,n.endInset)??[]);for(let F of lI(A,t.dash,N,M))kz(F,r,o,i,a,l,b,x,w,g,P);let C=new Float32Array(b);return u&&Nu(C,u),{vertices:C,indices:new Uint32Array(x),anchorA:new Uint32Array(w),anchorB:new Uint32Array(g),anchorT:new Float32Array(P),...e.kind==="polygon"&&e.origin?{origin:e.origin}:{}}}function kz(e,t,n,r,o,i,s,a,l,u,c){let d=t/2,f=e.points,p=f.length/2,h=p-1;if(h<1)return;let m=e.anchorA??new Uint32Array(p),y=e.anchorB??new Uint32Array(p),b=e.anchorT??new Float32Array(p),x=e.widths,w=e.offsets,g=F=>(x?x[F]/2:d)+(w?w[F]:0),P=F=>(x?x[F]/2:d)-(w?w[F]:0),S=[],v=[];for(let F=0;F<h;F++){let D=zx(f[F*2],f[F*2+1],f[(F+1)*2],f[(F+1)*2+1],g(F),P(F),g(F+1),P(F+1));D&&(S.push(D),v.push(F))}let A=-1;if(e.closed&&S.length>=1){let F=S[S.length-1],D=S[0],B=zx(F.bx,F.by,D.ax,D.ay,g(p-1),P(p-1),g(0),P(0));B&&(S.push(B),A=p-1,v.push(A))}if(S.length===0)return;let N=[];for(let F=0;F<S.length;F++){let D=S[F],B=v[F],K=F===S.length-1&&e.closed&&A>=0?0:B+1,W=s.length/2;N.push(W);let{nxUnit:Q,nyUnit:le}=D;s.push(D.ax+Q*D.posA,D.ay+le*D.posA),l.push(m[B]),u.push(y[B]),c.push(b[B]),s.push(D.ax-Q*D.negA,D.ay-le*D.negA),l.push(m[B]),u.push(y[B]),c.push(b[B]),s.push(D.bx+Q*D.posB,D.by+le*D.posB),l.push(m[K]),u.push(y[K]),c.push(b[K]),s.push(D.bx-Q*D.negB,D.by-le*D.negB),l.push(m[K]),u.push(y[K]),c.push(b[K]),a.push(W,W+1,W+2,W+1,W+3,W+2)}let M=e.closed?S.length:S.length-1,C=kI(S,N,e.closed,s);for(let F=0;F<M;F++)SI(S,N,F,n,o,i,s,a,l,u,c,v,m,y,b,C[F]);if(!e.closed&&r!=="butt"){let F=S[0],D=N[0];Vx(F,D+0,D+1,!1,F.posA,F.negA,r,s,a,l,u,c,m[0],y[0],b[0]);let B=S[S.length-1],K=N[S.length-1],W=v[S.length-1]+1;Vx(B,K+2,K+3,!0,B.posB,B.negB,r,s,a,l,u,c,m[W],y[W],b[W])}}var vz=4,Az=1.5;Z();function Ys(e,...t){let n=0,r=0;for(let[l,u]of t)n+=l.length/2+(u?1:0),r+=l.length;let o=new Uint8Array(n),i=new Float32Array(r),s=0,a=0;for(let[l,u]of t){for(let c=0;c<l.length;c+=2)o[s++]=c===0?se:ae,i[a++]=l[c]*e,i[a++]=l[c+1]*e;u&&(o[s++]=fe)}return{kind:"polygon",commands:o,coords:i,fillRule:"nonzero"}}function Ar(e,t,n=!0){return Ys(t,[e,n])}function NI(e,t,n=32){let r=[];for(let o=0;o<n;o++){let i=o/n*Math.PI*2;r.push(e+t*Math.cos(i),t*Math.sin(i))}return r}function vI(e,t,n){return Ar(NI(e,t),n)}var dp=e=>[[e,-2,e,2],!1],jx=[[[-4,0,0,-2.5],!1],[[-4,0,0,2.5],!1]],AI=2,RI=e=>[[NI(e,AI),!0],[[e+AI,0,0,0],!1]],Iu={reads:[],fill:"none",outline:{width:1}},II=[{id:"arrow",reads:[],inset:3,path:({size:e})=>Ar([0,0,-3,-1.5,-3,1.5],e)},{id:"arrow-open",reads:[],inset:0,fill:"none",outline:{width:1},path:({size:e})=>Ar([-2.867,-2.007,0,0,-2.867,2.007],e,!1)},{id:"arrow-concave",reads:[],inset:3,path:({size:e})=>Ar([0,0,-3,-1.5,-2,0,-3,1.5],e)},{id:"triangle-hollow",reads:[],inset:4,fill:"none",outline:{width:.5},path:({size:e})=>Ar([0,0,-4,-2,-4,2],e)},{id:"diamond",reads:[],inset:4,path:({size:e})=>Ar([0,0,-2,-1.2,-4,0,-2,1.2],e)},{id:"diamond-hollow",reads:[],inset:4,fill:"none",outline:{width:.5},path:({size:e})=>Ar([0,0,-2,-1.2,-4,0,-2,1.2],e)},{id:"circle",reads:[],inset:2,path:({size:e})=>vI(-1,1,e)},{id:"square",reads:[],inset:2,path:({size:e})=>Ar([0,-1,0,1,-2,1,-2,-1],e)},{id:"bar",reads:[],inset:0,fill:"none",outline:{width:1},path:({size:e})=>Ar([0,-1.5,0,1.5],e,!1)},{id:"dot",reads:[],inset:0,path:({size:e})=>vI(0,1.2,e)},{id:"crow-one",...Iu,inset:0,path:({size:e})=>Ys(e,dp(-2),dp(-4),[[-4,0,0,0],!1])},{id:"crow-many",...Iu,inset:0,path:({size:e})=>Ys(e,...jx)},{id:"crow-zero-one",...Iu,inset:7.5,path:({size:e})=>Ys(e,dp(-2),...RI(-5.5))},{id:"crow-one-many",...Iu,inset:0,path:({size:e})=>Ys(e,...jx,dp(-5.5))},{id:"crow-zero-many",...Iu,inset:9.5,path:({size:e})=>Ys(e,...jx,...RI(-7.5))}];var fp=xt();function Rz(){for(let e of II)fp.push(e.id,e,{source:"kit"})}Rz();var Nz=fp.reflection;function Eu(){return fp.getVersion()}function To(e){return e===void 0?void 0:fp.get(e)}Pe();function qs(e,t,n=1){return typeof e=="string"||e.size===void 0?t:Wt(e.size,n)}function Mi(e){return typeof e=="string"?e:e.key}function $x(e,t,n=1){if(e===void 0)return 0;let r=To(Mi(e));return r===void 0?0:(r.inset??0)*qs(e,t,n)}function Xs(e,t){return{start:$x(e.markerStart,t),end:$x(e.markerEnd,t)}}function Js(e,t,n){let r=e.points[n*2]-e.points[t*2],o=e.points[n*2+1]-e.points[t*2+1],i=Math.hypot(r,o);return i<1e-9?null:{x:r/i,y:o/i}}function EI(e,t,n){for(let r=t+1;r<n;r++)if(Js(e,t,r))return r;return-1}function MI(e,t){for(let n=t-1;n>=0;n--)if(Js(e,n,t))return n;return-1}function CI(e,t,n=e.closed){let r=[],o=e.points.length/2;if(o<2)return r;if(t.start&&!n){let i=EI(e,0,o),s=i>=0?Js(e,0,i):null;s&&r.push({x:e.points[0],y:e.points[1],angle:Math.atan2(-s.y,-s.x),role:"start"})}if(t.mid){let i=e.anchorA,s=e.anchorB,a=e.anchorT;if(i&&s&&a)for(let l=1;l<o-1;l++){if(i[l]!==s[l]||a[l]!==0)continue;let u=MI(e,l),c=EI(e,l,o);if(u<0||c<0)continue;let d=Js(e,u,l),f=Js(e,l,c),p=d.x+f.x,h=d.y+f.y;Math.hypot(p,h)<1e-9&&(p=d.x,h=d.y),r.push({x:e.points[l*2],y:e.points[l*2+1],angle:Math.atan2(h,p),role:"mid"})}}if(t.end&&!n){let i=o-1,s=MI(e,i),a=s>=0?Js(e,s,i):null;a&&r.push({x:e.points[i*2],y:e.points[i*2+1],angle:Math.atan2(a.y,a.x),role:"end"})}return r}Z();function Iz(e,t,n){let{origin:r,...o}=e,i=Math.cos(t.angle),s=Math.sin(t.angle),a=new Float32Array(o.coords.length);for(let l=0;l<o.coords.length;l+=2){let u=o.coords[l],c=o.coords[l+1];a[l]=t.x+u*i-c*s,a[l+1]=t.y+u*s+c*i}return n?{...o,coords:a,origin:n}:{...o,coords:a}}function Mu(e,t,n,r,o={}){let i={start:t.markerStart,mid:t.markerMid,end:t.markerEnd};if(i.start===void 0&&i.mid===void 0&&i.end===void 0)return[];let s=new Map;for(let u of["start","mid","end"]){if(i[u]===void 0)continue;let c=o[u],d=s.get(c);d===void 0&&s.set(c,d={start:!1,mid:!1,end:!1}),d[u]=!0}let a=[],l=e.kind==="polygon"?e.origin:void 0;for(let{polyline:u,fromClosed:c}of Ez(e,t,n,r))for(let[d,f]of s){let p=d?{...u,points:u.points.slice()}:u;d&&Au(p,d.metric);for(let h of CI(p,f,c)){let m=i[h.role];if(m===void 0)continue;let y=To(Mi(m));if(y===void 0)continue;let b=qs(m,n),x=y.orient===void 0||y.orient==="auto"?h.angle:y.orient,w=Iz(y.path({size:b,stroke:t}),{...h,angle:x},l);d&&Nu(w.coords,d.metric),a.push(d?{entry:y,size:b,path:w,space:d}:{entry:y,size:b,path:w})}}return a}function Ez(e,t,n,r){let o=br(e,ap(r,n,t.vertexWidths));return t.trim===void 0?o.map(i=>({polyline:i,fromClosed:i.closed})):cp(o,e,t.trim)?.windowed??[]}function pp(e,t){if(e.reads===void 0)return null;let n="";for(let r of e.reads)n+=`${JSON.stringify(t[r])??""}|`;return n}var Mz=64,OI=new WeakMap,FI=new WeakMap;function LI(e,t){let n=et(e.path({size:1,stroke:t}));return Math.max(Math.abs(n.x),Math.abs(n.x+n.width),Math.abs(n.y),Math.abs(n.y+n.height))+(e.outline?e.outline.width/2:0)}function Cz(e,t){let n=pp(e,t);if(n===null){let i=FI.get(e);i===void 0&&FI.set(e,i=new WeakMap);let s=i.get(t);return s===void 0&&i.set(t,s=LI(e,t)),s}let r=OI.get(e);r===void 0&&OI.set(e,r=new Map);let o=r.get(n);return o===void 0&&(r.size>=Mz&&r.clear(),r.set(n,o=LI(e,t))),o}function Cu(e){let t={world:0,px:0},n=e.width??1;for(let r of[e.markerStart,e.markerMid,e.markerEnd]){if(r===void 0)continue;let o=To(Mi(r));if(o===void 0)continue;let i=typeof r=="string"||r.size===void 0?n:r.size,s=Cz(o,e);typeof i=="number"?t.world=Math.max(t.world,s*i):t.px=Math.max(t.px,s*i.px)}return t}var Ou=xG(_I(),1);Ye();Pn();ci();di();Rt();rn();function DI(e,t={}){let n=ze(e);if(n.kind==="rect"){let{x:m,y,width:b,height:x}=n;return[[[[m,y],[m+b,y],[m+b,y+x],[m,y+x],[m,y]]]]}let r=t.tolerance??mt,o=[],i=null,s=0,a=0,l=0,u=0,c=0,{commands:d}=n,f=qe(n),p=kn(n),h=(m=p)=>{if(m||(i=null),!i||i.length===0)return;let y=i[0],b=i[i.length-1];(y[0]!==b[0]||y[1]!==b[1])&&i.push([y[0],y[1]]),i.length>=4&&o.push(i),i=null};for(let m=0;m<d.length;m++){let y=d[m];switch(y){case se:{h(),s=f[c],a=f[c+1],l=s,u=a,i=[[s,a]],c+=2;break}case ae:{i??=[[s,a]],s=f[c],a=f[c+1],i.push([s,a]),c+=2;break}case be:{let b=f[c],x=f[c+1],w=f[c+2],g=f[c+3],P=f[c+4],S=f[c+5],v=[];mo(s,a,b,x,w,g,P,S,r,v),i??=[[s,a]];for(let A=0;A<v.length;A+=2)i.push([v[A],v[A+1]]);s=P,a=S,c+=6;break}case we:{let b=f[c],x=f[c+1],w=f[c+2],g=f[c+3],[P,S,v,A]=uo(s,a,b,x,w,g),N=[];mo(s,a,P,S,v,A,w,g,r,N),i??=[[s,a]];for(let M=0;M<N.length;M+=2)i.push([N[M],N[M+1]]);s=w,a=g,c+=4;break}case fe:{h(!0),s=l,a=u;break}default:throw new Error(`pathToMultiPolygon: unknown command ${y}`)}}return h(),o.length===0?[]:Dz(o,n.fillRule)}function Oz(e){let t=0;for(let n=0,r=e.length-1;n<r;n++)t+=e[n][0]*e[n+1][1]-e[n+1][0]*e[n][1];return t*.5}function Fz(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let[i,s]of e)i<t&&(t=i),i>r&&(r=i),s<n&&(n=s),s>o&&(o=s);return[t,n,r,o]}function Lz(e,t,n){let r=!1;for(let o=0,i=e.length-1;o<i;o++){let[s,a]=e[o],[l,u]=e[o+1];a>n!=u>n&&t<(l-s)*(n-a)/(u-a)+s&&(r=!r)}return r}function _z(e,t,n,r){if(r[0]<t[0]||r[1]<t[1]||r[2]>t[2]||r[3]>t[3])return!1;let o=n.length-1,i=0;for(let s of[0,Math.floor(o/3),Math.floor(2*o/3)])Lz(e,n[s][0],n[s][1])&&i++;return i>=2}function Dz(e,t){let n=e.length;if(n===1)return[[e[0]]];let r=e.map(Fz),o=e.map(u=>Oz(u)>=0?1:-1),i=new Array(n).fill(-1),s=e.map(()=>[]);for(let u=0;u<n;u++){let c=-1,d=1/0;for(let f=0;f<n;f++){if(u===f||!_z(e[f],r[f],e[u],r[u]))continue;let p=(r[f][2]-r[f][0])*(r[f][3]-r[f][1]);p<d&&(d=p,c=f)}i[u]=c}for(let u=0;u<n;u++)i[u]>=0&&s[i[u]].push(u);let a=new Array(n);for(let u=0;u<n;u++){let c=0,d=0;for(let f=u;f>=0;f=i[f])d+=o[f],f!==u&&c++;a[u]=t==="evenodd"?c%2===0:d!==0}let l=[];for(let u=0;u<n;u++){if(!a[u]||i[u]>=0&&a[i[u]])continue;let c=[e[u]],d=[...s[u]];for(;d.length>0;){let f=d.pop();a[f]?d.push(...s[f]):c.push(e[f])}l.push(c)}return l}function Xx(e){let t=0,n=0;for(let l of e)for(let u of l){if(u.length<4)continue;let c=u.length-1;t+=1+(c-1)+1,n+=c*2}let r=new Uint8Array(t),o=new Float64Array(n),i=0,s=0;for(let l of e)for(let u of l){if(u.length<4)continue;let c=u.length-1;r[i++]=se,o[s++]=u[0][0],o[s++]=u[0][1];for(let d=1;d<c;d++)r[i++]=ae,o[s++]=u[d][0],o[s++]=u[d][1];r[i++]=fe}let a=Sn(o);return{kind:"polygon",commands:r,coords:At(a,o),fillRule:"nonzero",...a?{origin:a}:{}}}Ye();Rt();hi();aA();gA();oA();hi();_d();hi();function hp(e,t){return e.length===2?Nl(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y):e.length===3?Ok(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y):li(t.x,t.y,e[0].x,e[0].y,e[1].x,e[1].y,e[2].x,e[2].y,e[3].x,e[3].y)}var BI=[.25,.5,.75];function HI(e,t,n){let r=[],o=s=>{r.some(a=>Math.hypot(a.p.x-s.p.x,a.p.y-s.p.y)<=n)||r.push(s)};for(let[s,a]of[[0,t[0]],[1,t[t.length-1]]]){let l=hp(e,a);l.dist<=n&&o({ta:l.t,tb:s,p:a})}for(let[s,a]of[[0,e[0]],[1,e[e.length-1]]]){let l=hp(t,a);l.dist<=n&&o({ta:s,tb:l.t,p:a})}let i=null;for(let s=0;s<r.length;s++)for(let a=s+1;a<r.length;a++){let[l,u]=r[s].ta<=r[a].ta?[r[s],r[a]]:[r[a],r[s]];if(i&&u.ta-l.ta<=i[1].ta-i[0].ta)continue;BI.every(d=>hp(t,tt(e,l.ta+(u.ta-l.ta)*d)).dist<=n)&&(i=[l,u])}return i}function Bz(e,t,n){return!(e.from===t.from&&e.to===t.to)&&!(e.from===t.to&&e.to===t.from)?!1:BI.every(o=>hp(t.seg,tt(e.seg,o)).dist<=n)}function GI(e,t){let n=new Map,r=[];for(let o of e){let i=o.from<o.to?`${o.from},${o.to}`:`${o.to},${o.from}`,s=n.get(i)??[],a=s.find(l=>Bz(l,o,t));if(a){(a.also??=[]).push({operand:o.operand,sign:a.from===o.from?1:-1});continue}s.push(o),n.set(i,s),r.push(o)}return r}var Hz=16,mp=1e-9,Jx=class{constructor(t){this.snap=t}snap;points=[];grid=new Map;id(t){let n=Math.floor(t.x/this.snap),r=Math.floor(t.y/this.snap);for(let a=-1;a<=1;a++)for(let l=-1;l<=1;l++)for(let u of this.grid.get(`${n+a},${r+l}`)??[]){let c=this.points[u];if(Math.hypot(c.x-t.x,c.y-t.y)<=this.snap)return u}let o=this.points.length;this.points.push({x:t.x,y:t.y});let i=`${n},${r}`,s=this.grid.get(i);return s?s.push(o):this.grid.set(i,[o]),o}};function Gz(e){let t=[];return e.forEach((n,r)=>n.forEach((o,i)=>o.forEach((s,a)=>{let l=1/0,u=1/0,c=-1/0,d=-1/0;for(let f of s)l=Math.min(l,f.x),c=Math.max(c,f.x),u=Math.min(u,f.y),d=Math.max(d,f.y);t.push({seg:s,operand:r,contour:i,index:a,count:o.length,box:[l,u,c,d]})}))),t}var Uz=(e,t)=>{if(e.operand!==t.operand||e.contour!==t.contour)return!1;let n=Math.abs(e.index-t.index);return n===1||n===e.count-1};function Wz(e){if(e.length<4)return!1;let t=tt(e,.5),n=Ss(e,0,.5,e[0],t),r=Ss(e,.5,1,t,e[3]);return!n||!r?!1:db(n,r).some(o=>o.ta<1-1e-6||o.tb>1e-6)}function UI(e,t){let n=Gz(e);if(n.some(a=>Wz(a.seg)))return null;let r=new Jx(t),o=n.map(({seg:a})=>[r.id(a[0]),r.id(a[a.length-1])]),i=n.map(()=>[]);for(let a=0;a<n.length;a++){let l=n[a];for(let u=a+1;u<n.length;u++){let c=n[u];if(l.box[0]>c.box[2]+t||c.box[0]>l.box[2]+t||l.box[1]>c.box[3]+t||c.box[1]>l.box[3]+t)continue;let d=HI(l.seg,c.seg,t);if(d){for(let h of d){let m=r.id(h.p);i[a].push({t:h.ta,v:m}),i[u].push({t:h.tb,v:m})}continue}let f=db(l.seg,c.seg);if(f.length>=Hz)return null;let p=Uz(l,c);for(let h of f){if(p&&(h.ta>1-mp&&h.tb<mp||h.ta<mp&&h.tb>1-mp))continue;let m=r.id(h);i[a].push({t:h.ta,v:m}),i[u].push({t:h.tb,v:m})}}}let s=[];return n.forEach((a,l)=>{let{seg:u}=a,c=[{t:0,v:o[l][0]},...i[l].sort((p,h)=>p.t-h.t),{t:1,v:o[l][1]}],d=[c[0]];for(let p=1;p<c.length;p++){let h=c[p];h.v!==d[d.length-1].v?d.push(h):p===c.length-1&&d.length>1&&(d[d.length-1]=h)}let f=Math.hypot(a.box[2]-a.box[0],a.box[3]-a.box[1]);d.length===1&&u.length>2&&f>100*t&&d.push(c[c.length-1]);for(let p=0;p+1<d.length;p++){let h=d[p],m=d[p+1],y=h.t===0&&m.t===1?u.slice():Ss(u,h.t,m.t,r.points[h.v],r.points[m.v]);y&&(y[0]=r.points[h.v],y[y.length-1]=r.points[m.v],s.push({seg:y,from:h.v,to:m.v,operand:a.operand,source:u,t0:h.t,t1:m.t,key:l+h.t*.5,reversed:!1}))}}),{edges:GI(s,t),points:r.points}}hi();function zI(e,t){let n=e.flat(),r=new Float64Array(n.length*4);return n.forEach((o,i)=>{let s=1/0,a=1/0,l=-1/0,u=-1/0;for(let c of o)s=Math.min(s,c.x),l=Math.max(l,c.x),a=Math.min(a,c.y),u=Math.max(u,c.y);r.set([s,a,l,u],i*4)}),{segs:n,boxes:r,fillRule:t}}var Vz={x:1,y:0};function WI(e,t){let n=0,{segs:r,boxes:o}=t;for(let i=0;i<r.length;i++){if(e.y<o[i*4+1]||e.y>o[i*4+3]||o[i*4+2]<e.x)continue;let s=r[i];for(let a of Qv(Jv(s,e,Vz),!0))tt(s,a.t).x>e.x&&(n+=a.after>0?1:-1)}return n}var VI=(e,t)=>t==="evenodd"?(e&1)!==0:e!==0,KI=e=>({...e,seg:e.seg.slice().reverse(),from:e.to,to:e.from,reversed:!0});function zz(e,t){let n=new Array(t).fill(0);n[e.operand]=1;for(let{operand:r,sign:o}of e.also??[])n[r]+=o;return n}function jI(e,t,n){let r=[];for(let o of e){let i=(o.t0+o.t1)/2,s=tt(o.source,i),a=jl(o.source,i),l=Math.hypot(a.x,a.y);if(l===0){let y=o.seg[0],b=o.seg[o.seg.length-1];if(a={x:b.x-y.x,y:b.y-y.y},l=Math.hypot(a.x,a.y),l===0)continue}let u=-a.y/l*n,c=a.x/l*n,d={x:s.x+u,y:s.y+c},f={x:s.x-u,y:s.y-c},p=zz(o,t.length),h=new Array(t.length),m=new Array(t.length);for(let y=0;y<t.length;y++){let b=WI(d,t[y]),x=WI(f,t[y]);if(Math.abs(b-x)!==Math.abs(p[y]))return null;h[y]=VI(b,t[y].fillRule),m[y]=VI(x,t[y].fillRule)}r.push({edge:o,inL:h,inR:m})}return r}hi();var Zx=Math.PI*2,Qx=1e-7;function Kz(e){let t=e[0];for(let n=1;n<e.length;n++)if(e[n].x!==t.x||e[n].y!==t.y)return{x:e[n].x-t.x,y:e[n].y-t.y};return{x:0,y:0}}var jz=e=>e.slice().reverse();function $z(e,t){let n=0;for(let o=0;o+1<e.length;o++)n+=Math.hypot(e[o+1].x-e[o].x,e[o+1].y-e[o].y);let r=tt(e,n===0?0:Math.min(1,t/n));return{x:r.x-e[0].x,y:r.y-e[0].y}}var $I=e=>Math.atan2(e.y,e.x);function Yz(e,t){let n=(e-t)%Zx;return n<=0?n+Zx:n}function YI(e){let t=e[0],n=e[e.length-1];return Math.hypot(n.x-t.x,n.y-t.y)||Math.hypot(e[1].x-t.x,e[1].y-t.y)}function qz(e,t){let n=t[e.to];if(!n||n.length===0)return-1;if(n.length===1)return n[0].key;let r=jz(e.seg),o=l=>{let u=$I(l(r));return n.map(c=>Yz(u,$I(l(c.seg))))},i=l=>{let u=l.slice().sort((c,d)=>c-d);return u[0]<Qx||u[u.length-1]>Zx-Qx||u[1]-u[0]<Qx},s=o(Kz);if(i(s)){let l=.001*Math.min(YI(e.seg),...n.map(u=>YI(u.seg)));if(s=o(u=>$z(u,l)),i(s))return-1}let a=0;for(let l=1;l<s.length;l++)s[l]<s[a]&&(a=l);return n[a].key}function qI(e,t){if(e.source!==t.source||e.reversed!==t.reversed)return null;let[n,r]=e.reversed?[t,e]:[e,t];if(n.t1!==r.t0)return null;let o=n.t0,i=r.t1,s=n.seg[e.reversed?n.seg.length-1:0],a=r.seg[e.reversed?0:r.seg.length-1],l=o===0&&i===1?n.source.slice():Ss(n.source,o,i,s,a);return l?(l[0]=s,l[l.length-1]=a,e.reversed&&l.reverse(),{...e,seg:l,from:e.from,to:t.to,t0:o,t1:i}):null}function Xz(e){let t=[];for(let n of e){let r=t.length>0?qI(t[t.length-1],n):null;r?t[t.length-1]=r:t.push(n)}for(;t.length>1;){let n=qI(t[t.length-1],t[0]);if(!n)break;t.pop(),t[0]=n}return t.map(n=>n.seg)}function XI(e,t){let n=new Map,r=Array.from({length:t},()=>[]);if(e.forEach((a,l)=>{n.set(a.key,l),r[a.from].push(a)}),n.size!==e.length)return null;let o=e.map(a=>{let l=qz(a,r);return l<0?-1:n.get(l)});if(o.includes(-1))return null;let i=new Int32Array(e.length).fill(-1),s=[];for(let a=0;a<e.length;a++){if(i[a]>=0)continue;let l=[],u=a;do{if(i[u]>=0)return null;i[u]=s.length,l.push(u),u=o[u]}while(u!==a);let c=0;for(let d=1;d<l.length;d++)e[l[d]].key<e[l[c]].key&&(c=d);s.push(Xz([...l.slice(c),...l.slice(0,c)].map(d=>e[d])))}return s}var Jz=4096;function Qz(e){let t=ze(e);return t.kind==="polygon"&&t.commands.some(n=>n===be||n===we)}function Zz(e){return e.length<2?e:e[e.length-1].length===2?e.slice(0,-1):e}function e7(e){if(!e.some(Qz))return null;let t=e.map(a=>iA(a)),n=t.reduce((a,l)=>a+l.reduce((u,c)=>u+c.length,0),0);if(n===0||n>Jz)return null;let r=sA(t.flat())||1,o=UI(t,r*1e-6);if(!o)return null;let i=t.map((a,l)=>{let u=e[l];return zI(a,u.kind==="polygon"?u.fillRule:"nonzero")}),s=jI(o.edges,i,r*1e-7);return s?{edges:s,vertexCount:o.points.length,clockwise:t.map(r7)}:null}function t7(e,t){let n=new Map,r=(i,s)=>{let a=n.get(i);a?a.push(s):n.set(i,[s])};for(let{edge:i,inL:s,inR:a}of e.edges){let l=t(s),u=t(a);l!==u&&(l!==-1&&r(l,i),u!==-1&&r(u,KI(i)))}let o=new Map;for(let[i,s]of n){let a=XI(s,e.vertexCount);if(!a)return null;o.set(i,a)}return o}function n7(e,t){let n=t?e.map(o7):e;return yA(n.map(r=>({segs:Zz(r),closed:!0})),"nonzero")}function JI(e,t){let n=e7(e);if(!n)return null;let r=t7(n,o=>t(o)?0:-1);return r?n7(r.get(0)??[],n.clockwise[0]):null}function r7(e){let t=0;for(let n of e){let r=Xv(n);Math.abs(r)>Math.abs(t)&&(t=r)}return t<0}function o7(e){let t=qv(e);return[t[t.length-1],...t.slice(0,-1)]}Nv();function i7(e,t){return tb(t,Xx(e))}function yp(e,t,n){if(e.length===0)return Xx([]);let r=JI(e,t);if(r)return tb(e,r);let[o,...i]=e.map(s=>DI(s));return i7(n(o,...i),e)}var s7=e=>e.includes(!0),a7=e=>!e.includes(!1),l7=e=>e[0]&&!e[1],u7=e=>e.filter(Boolean).length%2===1;function gp(...e){return yp(e,s7,Ou.default.union)}function e0(...e){return yp(e,a7,Ou.default.intersection)}function t0(e,t){return yp([e,t],l7,Ou.default.difference)}function n0(...e){return yp(e,u7,Ou.default.xor)}Z();function QI(e){if(typeof e=="string")return e.length===0?[]:[{text:e}];for(let t=0;t<e.length;t++)if(typeof e[t]?.text!="string")throw new Error(`toRuns: run at index ${t} is missing string \`text\``);return e}Pe();function r0(e,t,n){if(!(t>0))return 0;let r=(Math.floor(e/t)+1)*t-e;return r<n?r+t:r}function ZI(e,t,n,r,o,i){let s=0,a=e,l=u=>{u<=a||(i?.(a,u,s),s+=o(a,u))};for(let u of n){if(u<e)continue;if(u>=t)break;l(u);let{stop:c,min:d}=r(u);s+=r0(s,c,d),a=u+1}return l(t),s}function i0(e,t){return e==="start"||e==="justify"?t==="rtl"?"right":"left":e==="end"?t==="rtl"?"left":"right":e}var eE={kind:"solid",color:"#000"};function o0(e){return Ut(e)?e.color:"#000"}var tE="",nE="";function rE(e){return e!==tE&&(nE=`color-mix(in srgb, ${e} 25%, transparent)`,tE=e),nE}var Ee={fontSize:16,fontFamily:"sans-serif",fontWeight:400,fontStyle:"normal",align:"left",direction:"auto",lineHeight:1.2,tabSize:8,wrap:!1,fill:null,caretColor:o0(eE),selectionBackground:rE(o0(eE)),selectionColor:null,letterSpacing:0,underline:!1,strikethrough:!1,overline:!1,textTransform:"none",fontVariantCaps:"normal"};function s0(e,t,n=1){return!e&&Ie(t?.fill)===null&&(t?.stroke??void 0)===void 0?Ee:xp({...Ee},e,t,n)}function xp(e,t,n,r=1){let o=t??c7,i=Ie(n?.fill),s=n?.stroke??void 0,a=o.caretColor??o0(i?.paint??null),l;o.selectionBackground==="none"?l=null:o.selectionBackground!=null?l=o.selectionBackground:l=rE(a),e.fontSize=Wt(o.fontSize??Ee.fontSize,r),e.fontFamily=o.fontFamily??Ee.fontFamily,e.fontWeight=o.fontWeight??Ee.fontWeight,e.fontStyle=o.fontStyle??Ee.fontStyle,e.align=o.align??Ee.align,e.direction=o.direction??Ee.direction,e.lineHeight=o.lineHeight??Ee.lineHeight,e.tabSize=o.tabSize??Ee.tabSize,e.wrap=o.wrap??Ee.wrap,e.fill=i,e.caretColor=a,e.selectionBackground=l,e.selectionColor=o.selectionColor??null,e.letterSpacing=Wt(o.letterSpacing??Ee.letterSpacing,r),e.underline=o.underline??Ee.underline,e.strikethrough=o.strikethrough??Ee.strikethrough,e.overline=o.overline??Ee.overline,e.textTransform=o.textTransform??Ee.textTransform,e.fontVariantCaps=o.fontVariantCaps??Ee.fontVariantCaps,(o.script!==void 0||e.script!==void 0)&&(e.script=o.script);let u=o.lang||void 0;return(u!==void 0||e.lang!==void 0)&&(e.lang=u),(s!==void 0||e.stroke!==void 0)&&(e.stroke=s),e}var c7=Object.freeze({});Pe();var d7=new Map([[223,"Ss"],[452,"\u01C5"],[453,"\u01C5"],[454,"\u01C5"],[455,"\u01C8"],[456,"\u01C8"],[457,"\u01C8"],[458,"\u01CB"],[459,"\u01CB"],[460,"\u01CB"],[497,"\u01F2"],[498,"\u01F2"],[499,"\u01F2"],[1415,"\u0535\u0582"],[64256,"Ff"],[64257,"Fi"],[64258,"Fl"],[64259,"Ffi"],[64260,"Ffl"],[64261,"St"],[64262,"St"],[64275,"\u0544\u0576"],[64276,"\u0544\u0565"],[64277,"\u0544\u056B"],[64278,"\u054E\u0576"],[64279,"\u0544\u056D"],[8115,"\u1FBC"],[8124,"\u1FBC"],[8131,"\u1FCC"],[8140,"\u1FCC"],[8179,"\u1FFC"],[8188,"\u1FFC"],[8114,"\u1FBA\u0345"],[8116,"\u0386\u0345"],[8119,"\u0391\u0342\u0345"],[8130,"\u1FCA\u0345"],[8132,"\u0389\u0345"],[8135,"\u0397\u0342\u0345"],[8178,"\u1FFA\u0345"],[8180,"\u038F\u0345"],[8183,"\u03A9\u0342\u0345"]]);function f7(e,t){let n=e.codePointAt(0);return n>=8064&&n<=8111?String.fromCodePoint(n|8):d7.get(n)??e.toLocaleUpperCase(t)}function a0(e){if(e)try{return Intl.getCanonicalLocales(e)[0]}catch{return}}var p7=/[\p{L}\p{N}][\p{L}\p{N}\p{M}\p{Pc}'’]*/gu;function h7(e){let t=new Set;if(typeof Intl<"u"&&"Segmenter"in Intl){let n=new Intl.Segmenter(void 0,{granularity:"word"});for(let r of n.segment(e))r.isWordLike&&t.add(r.index);return t}for(let n of e.matchAll(p7))t.add(n.index);return t}function oE(e,t,n){let r=0;for(let o of e)for(let i of o)r+=n(i).length;return r===t.length}function iE(e,t,n=[]){if(t.every(b=>b==="none"))return e.map(b=>({text:b}));let r=e.map((b,x)=>a0(n[x])),o=r.every(b=>b===r[0])?r[0]:void 0,i=(b,x=o)=>b.toLocaleUpperCase(x),s=(b,x=o)=>b.toLocaleLowerCase(x),a=e.join(""),l=t.includes("uppercase")?a.toLocaleUpperCase(o):"",u=t.includes("lowercase")?a.toLocaleLowerCase(o):"",c=l!==""&&oE(e,l,i),d=u!==""&&oE(e,u,s),f=t.includes("capitalize")?h7(a):null,p=[],h=0,m=0,y=0;for(let b=0;b<e.length;b++){let x=e[b],w=t[b]??"none",g=r[b],P=g===o,S="",v=[],A=[],N=!1,M=0;for(let C of x){let F=i(C),D=s(C),B=C;w==="uppercase"?B=c&&P?l.slice(m,m+F.length):i(C,g):w==="lowercase"?B=d&&P?u.slice(y,y+D.length):s(C,g):w==="capitalize"&&f.has(h+M)&&i(C,g)!==C&&(B=f7(C,g)),m+=F.length,y+=D.length,B.length!==C.length&&(N=!0),S+=B;for(let K=0;K<B.length;K++)v.push(M),A.push(M+C.length);M+=C.length}p.push(N?{text:S,srcMap:{length:x.length,starts:v,ends:A}}:{text:S}),h+=x.length}return p}var m7=.7;function y7(e){let t=e?.xHeight,n=e?.capHeight;return t===void 0||n===void 0||t>=n?m7:t/n}function sE(e,t,n){return y7(ei(xn(e,t,n)))}function aE(e,t,n){let r=a0(n),o="",i=[],s=[],a=[],l=!1,u=!1,c=0;for(let f of e){let p=f.toLocaleUpperCase(r),h=p!==f,m=h?p:f;m.length!==f.length&&(l=!0),u||=h;let y=t?t.starts[c]:c,b=t?t.ends[c]:c+f.length;for(let x=0;x<m.length;x++)i.push(h),s.push(y),a.push(b);o+=m,c+=f.length}if(!u)return t?{text:e,srcMap:t}:{text:e};let d=l?{length:t?.length??e.length,starts:s,ends:a}:t;return{text:o,...d?{srcMap:d}:{},small:i}}var uE=null;function cE(){return uE}var lE=new WeakMap;function l0(e){let{family:t,weight:n,style:r}=e.resolved,o=e.outlineFace??(e.source==="outline"?void 0:gl(t,n,r==="italic"?"italic":"normal"));if(!o)return null;let i=lE.get(o);return i===void 0&&(i=o.embedding?.()??null,lE.set(o,i)),i}function g7(e){return l0(e)?.sfnt??null}function dE(e,t,n,r,o=uE){if(o===null)return!1;let i=g7(xn(e,t,n));return i!==null&&o.hasFeature(i,r)}var b7=Object.freeze(["smcp"]),wp=Object.freeze({super:Object.freeze({size:.583,shift:.333}),sub:Object.freeze({size:.583,shift:-.333})}),fE=new WeakMap;function pE(e){if(!e||!e.superscript&&!e.subscript)return wp;let t=fE.get(e);return t||(t=Object.freeze({super:e.superscript??wp.super,sub:e.subscript??wp.sub}),fE.set(e,t)),t}function hE(e,t,n){return pE(ei(xn(e,t,n)))}function mE(e){if(typeof e=="number")return e;if(e==="bold"||e==="bolder")return 700;if(e==="normal")return 400;let t=Number(e);return Number.isFinite(t)?t:400}function yE(e,t){return{fontFamily:e.fontFamily??t.fontFamily,fontWeight:e.fontWeight??(e.bold?700:mE(t.fontWeight)),fontStyle:e.italic?"italic":t.fontStyle}}function Fu(e,t,n=1){return u0(new Array(e.length),e,t,n)}function u0(e,t,n,r=1){e.length!==t.length&&(e.length=t.length);let o=!1;for(let s of t)(s.textTransform??n.textTransform)!=="none"&&(o=!0);let i=o?iE(t.map(s=>s.text),t.map(s=>s.textTransform??n.textTransform),t.map(s=>s.lang??n.lang)):null;for(let s=0;s<t.length;s++){let a=t[s],l=i?i[s].text:a.text,u=i?.[s].srcMap,c=a.script??n.script,{fontFamily:d,fontWeight:f,fontStyle:p}=yE(a,n),h=c?hE(d,f,p)[c]:void 0,m=a.baselineShift??h?.shift??0,y=a.fontScale??h?.size??1,b=a.fontSize===void 0&&y!==1,x=a.fontSize!==void 0?Wt(a.fontSize,r):n.fontSize*y,w,g,P=(a.fontVariantCaps??n.fontVariantCaps)==="small-caps";if(P&&dE(d,f,p,"smcp"))g=b7;else if(P){let W=aE(l,u,a.lang??n.lang);if(l=W.text,u=W.srcMap,W.small){let Q=x*sE(d,f,p);w=W.small.map(le=>le?Q:x)}}let S=a.lang??n.lang,v=a.fill!==void 0?a.fill:n.fill,A=a.letterSpacing!==void 0?Wt(a.letterSpacing,r):n.letterSpacing,N=a.underline||n.underline,M=a.strikethrough||n.strikethrough,C=a.overline||n.overline,F=a.stroke??n.stroke,D=a.rotate&&Number.isFinite(a.rotate)?a.rotate:void 0,B=e[s];if(B!==void 0&&B.srcMap!==void 0==(u!==void 0)&&B.sizeMap!==void 0==(w!==void 0)&&B.stroke!==void 0==(F!==void 0)&&B.strutSize!==void 0===b&&B.rotate!==void 0==(D!==void 0)&&B.fontFeatures!==void 0==(g!==void 0)&&B.lang!==void 0==!!S){B.text=l,B.fontFamily=d,B.fontSize=x,B.fontWeight=f,B.fontStyle=p,B.fill=v,B.letterSpacing=A,B.underline=N,B.strikethrough=M,B.overline=C,B.baselineShift=m*n.fontSize,u&&(B.srcMap=u),w&&(B.sizeMap=w),F!==void 0&&(B.stroke=F),b&&(B.strutSize=n.fontSize),D!==void 0&&(B.rotate=D),g&&(B.fontFeatures=g),S&&(B.lang=S);continue}let K={text:l,fontFamily:d,fontSize:x,fontWeight:f,fontStyle:p,fill:v,letterSpacing:A,underline:N,strikethrough:M,overline:C,baselineShift:m*n.fontSize};u&&(K.srcMap=u),w&&(K.sizeMap=w),F!==void 0&&(K.stroke=F),b&&(K.strutSize=n.fontSize),D!==void 0&&(K.rotate=D),g&&(K.fontFeatures=g),S&&(K.lang=S),e[s]=K}return e}var gE=["underline","strikethrough","overline"],Pp=Object.freeze({underline:Object.freeze({offset:.1,thickness:.05}),strikethrough:Object.freeze({offset:-.3,thickness:.05}),overline:Object.freeze({offset:-.9,thickness:.05})}),bE=new WeakMap;function x7(e){if(!e)return Pp;let t=bE.get(e);if(!t){let n=e.underline??Pp.underline;t=Object.freeze({underline:n,strikethrough:e.strikethrough??Pp.strikethrough,overline:Object.freeze({offset:Pp.overline.offset,thickness:n.thickness})}),bE.set(e,t)}return t}function w7(e,t,n,r){let o=x7(r)[e],i=t+n*o.offset;return{y0:i,y1:i+n*o.thickness}}function xE(e,t,n){let r=[],o=null,i=()=>{let s=o;if(o=null,!(!s||s.x1<=s.x0))for(let a of gE){if(!s.style[a])continue;let{y0:l,y1:u}=w7(a,s.baselineY,s.style.fontSize,s.face);r.push({kind:a,x0:s.x0,y0:l,x1:s.x1,y1:u,run:s.run})}};return{add(s){let a=e[s.run],l=a.underline||a.strikethrough||a.overline?n(s.run):null;if(l===null){o!==null&&i();return}let u=t(s.run);o!==null&&gE.every(d=>o.style[d]===a[d])&&o.style.fontSize===a.fontSize&&o.face===u&&o.baselineY===s.baselineY&&o.paint===l?o.x1=s.x+s.step:(i(),o={run:s.run,style:a,face:u,paint:l,baselineY:s.baselineY,x0:s.x,x1:s.x+s.step})},end(){return i(),r}}}function PE(e,t,n,r){let o=[],i=0;for(let a=0;a<=t.length;a++)a<t.length&&!n(a)||(a>i&&o.push({start:i,end:a,analysis:e.analyze(t.slice(i,a),r)}),i=a+1);let s=a=>{let l=0,u=o.length-1;for(;l<u;){let d=l+u>>1;o[d].end<=a?l=d+1:u=d}let c=o[l];return c!==void 0&&a>=c.start&&a<c.end?c:void 0};return{reorder(a,l){let u=s(a);if(u===void 0||l>u.end)return{order:[],levels:[]};let c=e.reorder(u.analysis,a-u.start,l-u.start);return{order:c.order.map(d=>d+u.start),levels:c.levels}},baseLevel(a){let l=s(a);return l===void 0?0:e.baseLevel(l.analysis)}}}function P7(e,t,n){if(e.length===t)return[...e];let r=new Set(e),o=[],i=new Map,s=-1,a=-1;for(let u=0;u<t;u++)if(r.has(u))s=u,a<0&&(a=u);else if(s<0)o.push(u);else{let c=i.get(s);c?c.push(u):i.set(s,[u])}if(a<0)return o;let l=[];for(let u of e){let c=i.get(u)??[],d=u===a?o:[];n(u)?l.push(...[...c].reverse(),u,...[...d].reverse()):l.push(...d,u,...c)}return l}var T7=1024,wE=[];function S7(e){let t=wE[e];if(t!==void 0)return t;let n={visual:Array.from({length:e},(r,o)=>o),levels:new Array(e).fill(0)};return e<=T7&&(wE[e]=n),n}function TE(e,t,n){return e===null||n===0?S7(n):k7(e,t,n)}function k7(e,t,n){let r=new Array(n).fill(0),o=e.reorder(t,t+n);for(let s=0;s<n;s++){let a=o.levels[s];typeof a=="number"&&a>=0&&(r[s]=a)}let i=new Set;for(let s of o.order){let a=s-t;Number.isInteger(a)&&a>=0&&a<n&&i.add(a)}return{visual:P7([...i],n,s=>r[s]%2===1),levels:r}}var d0={};gG(d0,{AK:()=>c5,AL:()=>Z7,AP:()=>d5,AS:()=>f5,B2:()=>B7,BA:()=>_7,BB:()=>D7,BK:()=>A7,CB:()=>G7,CL:()=>U7,CLASS_MASK:()=>g5,CM:()=>O7,CP:()=>W7,CR:()=>R7,EAST_ASIAN:()=>b5,EB:()=>n5,EM:()=>r5,EX:()=>V7,GL:()=>L7,H2:()=>o5,H3:()=>i5,HL:()=>e5,HY:()=>H7,ID:()=>t5,IN:()=>z7,IS:()=>Y7,JL:()=>s5,JT:()=>l5,JV:()=>a5,LF:()=>N7,NL:()=>I7,NS:()=>K7,NU:()=>q7,OP:()=>j7,PICTOGRAPHIC_CN:()=>x5,PO:()=>X7,PR:()=>J7,QU:()=>$7,QU_PF:()=>y5,QU_PI:()=>m5,RI:()=>u5,SP:()=>E7,SY:()=>Q7,UNICODE_VERSION:()=>v7,VF:()=>p5,VI:()=>h5,WJ:()=>F7,ZW:()=>M7,ZWJ:()=>C7,lineBreakPropsOf:()=>T5});var v7="16.0.0",A7=0,R7=1,N7=2,I7=3,E7=4,M7=5,C7=6,O7=7,F7=8,L7=9,_7=10,D7=11,B7=12,H7=13,G7=14,U7=15,W7=16,V7=17,z7=18,K7=19,j7=20,$7=21,Y7=22,q7=23,X7=24,J7=25,Q7=26,Z7=27,e5=28,t5=29,n5=30,r5=31,o5=32,i5=33,s5=34,a5=35,l5=36,u5=37,c5=38,d5=39,f5=40,p5=41,h5=42,m5=43,y5=44,g5=63,b5=64,x5=128,SE="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!#$%&()*+,-./:;<=>?@[]^_{|}~",w5=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,35,36,37,38,39,40,41,42,43,44,71,73,74,79,81,82,83,84,88,89,91,93,94,95,96,97,98,155,157],kE=2787,vE="9H1K1C2A1B18H1E1R1V1b1Z1Y1b1V1U1Q1b1Z1W1N1W1a10X2W3b1R27b1U1Z1Q29b1U1K1P1b6H1D26H1J1U1Y3Z5b1n1b1K2b1Y1Z2b1L6b1o3b1U520b1L3b1L18b1L32b79H1J12H7J13H14b1W260b7H255b1W1K4b1Z1b45H1K1H1b2H1b2H1R1H8b27c4b4c13b6X3b3Y2W2b11H1R1H3R43b21H10X1Y2X3b1H99b1R1b7H1X1b6H2b2H1b4H2b10X23b1H30b27H91b11H15b10X33b9H4b1W1R3b1H2Z22b4H1b9H1b3H1b5H43b3H52b2X5b9H42b24H1X33H54b3H1b18H1b7H10b2H2K10X17b3H56b1H1b7H2b2H2b3H9b1H10b2H2b10X2b2Y5b1Y1b1Z2b1H2b3H56b1H1b5H4b2H2b3H3b1H20b10X2H3b1H11b3H56b1H1b8H1b3H1b3H20b2H2b10X1b1Z8b6H1b3H56b1H1b7H2b2H2b3H7b3H10b2H2b10X18b1H59b5H3b3H1b4H9b1H14b10X9b1Z6b5H55b1H1b7H1b3H1b4H7b2H11b2H2b10X7b1L9b3H1L55b1H1b7H1b3H1b4H7b2H11b2H2b10X3b1H12b4H55b2H1b7H1b3H1b4H9b1H10b2H2b10X9b1Y7b3H70b1H4b6H1b1H1b8H6b10X2b2H61b1H2b7H4b1Z7b8H1b10X2K85b1H2b9H11b7H1b10X39b4L1b2L1J2L1K1J5R1J1b1R3b2H6b10X10b1K1H1b1H1b1H1U1P1U1P2H49b14H1K5H1K2H5b11H1b36H1b2K6b1H9b2L1K1L5b2J80b20H1b10X2K10b4H4b3H1b3H2b7H3b4H13b12H1b1H10X4H98b96(72f88g349b3H1b1K158b1K639b1K26b1U1P78b3K36b4H28b3H2K27b2H30b2H64b32H2K1T1b1K1b1K1Z1b1H2b10X24b2R2K1L1b2R1b3H1J1H10X107b2H34b1H118b12H4b12H8b2R10X128b11X60b5H57b10H1b29H2b1H10X6b10X22b31H49b5H47i16H1m8i1b2K10k2K1d4K10d9H9d3K3H30b13H2b10X6b38k12H2l48b20H3b5K10X6b10X36b2K80b3H1b21H4b1H6b1H2b3H198b13H1J46H1J3H509b1L2b7K1J3K1F1H1G2H1K1J2K1M3b1n1o1U2n1o1U1n4b3S1K2A5H1J8Y1b1n1o1b2T6b1W1U1P3T12b1K1Y4K1b3K1I5b10H13b1U1P14b1U1P17b7Z1Y1Z1y12Z1Y4Z1Y2Z1Y1Z1Y15Z33H18b1Y5b1Y12b1Z251b2Z219b1S24b1U1P1U1P14b2!13b1w1s190b4z3b1!2d1!521b2z1b4d16b2!2b1d1b3d1e2d16b8z1b3d12b12z20b1d22b1!10b6z3b1z13b1z8b2z17b2!5d2!3d4b1d1z3d1b1d1!3b2d2b1d2b3d8b1!6b1d2!1d1!1b2d1e1!2b1!7d1z2b2d2#2e26b1z35b1z1b1z4b3z1b1z3b6V1b2R1d3b1U1P1U1P1U1P1U1P1U1P1U1P1U1P31b3z24b1z14b1z5b1U1P31b1U1P1U1P1U1P1U1P1U1P403b1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P1U1P63b1U1P1U1P32b1U1P285b2z51b1z4b1z409b3H7b1R3K1b1R1K112b1K14b1H96b32H2V1n1o1n1o3V1n1o1V1n1o8K1b1K1U1K2b1n1o2b1n1o1U1P1U1P1U1P1U1P4K1R1b2K1b2K5b2M3K1b2K1U8K1b1K1b2K3b2R1U1Q1U1Q1U1Q1U1Q1K34b26!1b89!12b214!26b16!1r2s2!1v2!1w1s1w1s1w1s1w1s1w1s2!1w1s1w1s1w1s1w1s1v1w2s10!6p5!1p5!2v2!1d1b1v1!1v1!1v1!1v1!1v25!1v31!1v1!1v1!1v6!1v6!2v2b2p4v1!2v1!1v1!1v1!1v1!1v25!1v31!1v1!1v1!1v6!1v6!2v4!4v1!5b43!1b94!1b86!9b1!16v31!1b40!8b7024!64z21013!1v1143!3b55!55b2K269b1K1R1K16b10X69b4H1b10H32b2H80b2H1b5K266b1H3b1H4b1H23b5H4b1H11b1Y59b2L2R8b2H50b18H8b2K10X6b18H10b1L2b1H10X28b8H2K23b13H12b29(3b4H47i13H1m6d3K4d1b1K10k4b2d5b1H10b10X6b41k14H9b3K1H8K2H2b10k2b1d3K27b3H50b1H1b3H2b2H5b2H1b1H41b5H2K3b2H236b8H1K2H2b10X6b1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&1%27&12b23f4b49g8452b512!29b1c1H10c1b13c1b5c1b1c1b2c1b2c1b10c494b1P1U188b1Y3b16H3s2v2t1w1s1u6b1J1H1J1H1J1H2J1H1J1H1J1H2J1H5!1w1s1w1s1w1s1w1s1w1s1w1s1w1s1w1s2!1w1s7!1s1!1s1b2v2t1!1w1s1w1s1w1s8!1b1!1y1x1!147b1I1b1t2!1y1x2!1w1s2!1s1!1s11!2v3!1t27!1w1!1s29!1w1!1s1!1w2s1w2s1v1!10v45!2v31!3b6!2b6!2b6!2b3!3b1x1y3!2y1b7z10b3H1O259b3K250b1H226b1H149b5H36b1K48b1K207b10X941b1K199b1K225b3H1b2H5b4H40b3H4b1H16b8K141b2H9b6K1S66b7K484b4H8b10X6b10X31b5H1K316b2H1K78b4H70b11H49b4H122b3H2j51i14H1m2K5d4b20d10k1H2i2H1i9b1J3H45b11H2b1X4K1H10b1X34b10X6b3H36b14H1b10X4K1b2H44b1H1b1L10b3H48b14H4b2K1b1K4H1b2H10X1b1L1b3K76b12H2K1b2K1b1H2b1H103b1K53b12H5b10X6b4H1b8i2b2i2b22i1b7i1b2i1b5i1b2H1K7H2b2H2b2H1m2b1k6b1H5b1K2k2i2H2b7H3b5H11b10k1b1k2b1k1b2k36i1b1d9H1b1H2b1H1b4H1b4H1m1j1H3d1b2d8b2H82b18H4b4K1b10X2K2b1H81b20H12b10X213b7H2b9H1L2K2R3b15K4b2H82b17H2K13b10X6b13L62b13H8b10X6b20X57b15H4b10X2b3K237b15H165b10X22b7i2b1i2b8i1b2i1b24i6H1b2H2b3H1m1j1H1j2H3K9b10k119b7H2b7H1b1L1b1H28b10H40b7H1b4H1L1b4K1L1b1H9b11H46b16H3K1b3L2K93b10L230b10X53b8H1b8H1b5K10b10X22b1L1R32b22H1b14H122b6H3b1H1b2H1b7H1b1H8b10X48b5H1b2H1b5H8b10X310b18k1K4H2K7b2H1j1H13i1b34i7H3b4H1m2K11d10k1H130b4Y30b1K1136b5K3555b3U3P36b1P3b1U1P1U1P239b1U2P179b1U7J1U1P3J1U1P1U1P1H6b15H4472b1U1P6960b30k18H10k2342b10X4b2K80b10X38b5H1K58b7H3K10b1K11b10X532b2K10X285b2K182b1H1b55H7b4H77b4v1q11b2p14b6136!8b768!470z41b1z9!8935b4z1b7z1b2z1b291!15b1v29b3v2b1v14b4v8b396!2465b2H1K4H4172b10X518b46H2b23H542b5H3b22H2b7H30b4H148b3H187b87z9b23z1111b50X512b55H4b50H8b1H14b1H2b4K16b5H1b15H1360b7H1b17H2b7H1b2H1b5H100b1H160b7H9b10X356b1H61b4H10X5b1Z492b4H10X244b2H1b10X725b7H109b7H5b10X4b2U844b1Y3b1Y847b4d1!39d4*100d12*15d2*15d1*14d1!1*37d10*142b1z2b10z19b56*26h3!13*44!4*9!7*2!14*6!154*33!12d9!1d70!1d7!1#14!8d2b2d21!2z5!1z5!3#2!1#2!1#2e2d5!12d17!3d1!3d3!5$63!1d1!1d2#2!11#21!19#3!1#4!3#1!3#7!1#1!1#14!1z1!1z1!1z5!1#4!1z1!2z74!2d1!7z16!14z13!12z12b1d4!1d24!12d2e4d1#21d1e4d2#13d1!47d8b24d6b1d74!3#3!5#38b3V3T4b35!1#16!3#9!1#5!6d1#3d3!2d3!4*4!11d2!3*4d9!3*116b3d4*5d85b5d6*12!4*1!15*12b4)56b8)10b6)40b8)30b2)12b4)2b62)12b1#2!1#8!8#6!1#9!10#1!1d3#7!1d48!1#61!2#1!2#1!1#17!3#1!13#34!84b12*14d2*13!3*10!5*52!3#1!7*15!2*11!6*9#7*240b10X6b1022*2b65534!2b65534!655363b1H30b96H128b240H196112b",c0=null,AE=null,RE=null;function P5(){let e=new Uint8Array(65536),t=new Int32Array(kE),n=new Uint8Array(kE),r=new Uint8Array(128);for(let a=0;a<SE.length;a++)r[SE.charCodeAt(a)]=w5[a];let o=0,i=0,s=0;for(let a=0;a<vE.length;a++){let l=vE.charCodeAt(a);if(l<=57&&l>=48)s=s*10+l-48;else{let u=r[l];t[i]=o,n[i]=u,o<65536&&e.fill(u,o,Math.min(o+s,65536)),i++,o+=s,s=0}}c0=e,AE=t,RE=n}function T5(e){if(c0===null&&P5(),e<65536)return c0[e];if(e>1114111)return 27;let t=AE,n=0,r=t.length-1;for(;n<r;){let o=n+r+1>>1;t[o]<=e?n=o:r=o-1}return RE[n]}var{lineBreakPropsOf:v0,CLASS_MASK:A0,EAST_ASIAN:S5,PICTOGRAPHIC_CN:k5,BK:v5,CR:_E,LF:DE,NL:A5,SP:Nr,ZW:ea,ZWJ:g0,CM:NE,WJ:f0,GL:Lu,BA:p0,BB:R5,B2:IE,HY:_u,CB:h0,CL:Tp,CP:Du,EX:EE,IN:N5,NS:ME,OP:Sp,QU:b0,IS:So,NU:ln,PO:Qs,PR:Zs,SY:Bu,AL:R0,HL:Rp,ID:I5,EB:BE,EM:HE,H2:x0,H3:w0,JL:P0,JV:Np,JT:Ip,RI:m0,AK:kp,AP:E5,AS:y0,VF:CE,VI:OE,QU_PI:T0,QU_PF:S0}=d0,ne=0,Hu=1,GE=2,M5=8208,vp=9676,Ap=e=>e===b0||e===T0||e===S0,Ci=e=>e===v5||e===_E||e===DE||e===A5;function Oi(e){return Ci(v0(e)&A0)}var Rr=e=>e===R0||e===Rp,FE=e=>e===P0||e===Np||e===Ip||e===x0||e===w0,LE=e=>e===I5||e===BE||e===HE,N0=e=>({cls:new Uint8Array(e),ea:new Uint8Array(e),pict:new Uint8Array(e),cp:new Int32Array(e),start:new Int32Array(e)}),UE=65536,En=N0(64);function C5(e){return En.cls.length<e&&(En=N0(Math.min(UE,Math.max(e,En.cls.length*2)))),En}var WE=[],k0=WE,Ae=En.cls,In=En.ea,Gu=En.pict,vo=En.cp,Uu=En.start,ko=0;function VE(e){return I0(e,new Uint8Array(e.length+1))}function I0(e,t){let n=e.length;for(let i=0;i<n;i++)t[i]=ne;if(n===0)return t[0]=ne,t;t[n]=GE;let r=n<=UE?C5(n):N0(n);k0=e,{cls:Ae,ea:In,pict:Gu,cp:vo,start:Uu}=r;let o=0;for(let i=0;i<n;i++){let s=v0(e[i]),a=s&A0;if((a===NE||a===g0)&&o>0){let l=Ae[o-1];if(!Ci(l)&&l!==Nr&&l!==ea)continue}a===NE||a===g0?(Ae[o]=R0,In[o]=0,Gu[o]=0):(Ae[o]=a,In[o]=s&S5?1:0,Gu[o]=s&k5?1:0),vo[o]=e[i],Uu[o]=i,o++}ko=o;for(let i=1;i<ko;i++)t[Uu[i]]=L5(i);return k0=WE,r!==En&&({cls:Ae,ea:In,pict:Gu,cp:vo,start:Uu}=En),t}var O5=e=>(v0(k0[Uu[e]-1])&A0)===g0;function F5(e){for(;e>=0&&Ae[e]===Nr;)e--;return e}function L5(e){let t=e-1,n=Ae[t],r=Ae[e];if(n===_E&&r===DE)return ne;if(Ci(n))return GE;if(Ci(r)||r===Nr||r===ea)return ne;let o=F5(t);if(o>=0&&Ae[o]===ea)return Hu;if(O5(e)||n===f0||r===f0||n===Lu||r===Lu&&n!==Nr&&n!==p0&&n!==_u||r===Tp||r===Du||r===EE||r===Bu)return ne;let i=o>=0?Ae[o]:-1;if(i===Sp)return ne;if(i===T0){let l=o-1;if(l<0)return ne;let u=Ae[l];if(Ci(u)||u===Sp||Ap(u)||u===Lu||u===Nr||u===ea)return ne}if(r===S0){if(e+1>=ko)return ne;let l=Ae[e+1];if(l===Nr||l===Lu||l===f0||l===Tp||Ap(l)||l===Du||l===EE||l===So||l===Bu||Ci(l)||l===ea)return ne}if(n===Nr&&r===So&&e+1<ko&&Ae[e+1]===ln)return Hu;if(r===So||(i===Tp||i===Du)&&r===ME||i===IE&&r===IE)return ne;if(n===Nr)return Hu;if(r===b0||r===S0||n===b0||n===T0||Ap(r)&&(!In[t]||e+1>=ko||!In[e+1])||Ap(n)&&(!In[e]||t===0||!In[t-1]))return ne;if(n===h0||r===h0)return Hu;if((n===_u||vo[t]===M5)&&r===R0){if(t===0)return ne;let l=Ae[t-1];if(Ci(l)||l===Nr||l===ea||l===h0||l===Lu)return ne}if(r===p0||r===_u||r===ME||n===R5||t>0&&Ae[t-1]===Rp&&(n===_u||n===p0&&!In[t])&&r!==Rp||n===Bu&&r===Rp||r===N5||Rr(n)&&r===ln||n===ln&&Rr(r)||n===Zs&&LE(r)||LE(n)&&r===Qs||(n===Zs||n===Qs)&&Rr(r)||Rr(n)&&(r===Zs||r===Qs))return ne;if(r===Qs||r===Zs){let l=n===Tp||n===Du?t-1:t;for(;l>=0&&(Ae[l]===Bu||Ae[l]===So);)l--;if(l>=0&&Ae[l]===ln)return ne}if(n===Qs||n===Zs){if(r===ln)return ne;if(r===Sp&&e+1<ko){let l=Ae[e+1];if(l===ln||l===So&&e+2<ko&&Ae[e+2]===ln)return ne}}if((n===_u||n===So)&&r===ln)return ne;if(r===ln){let l=t;for(;l>=0&&(Ae[l]===Bu||Ae[l]===So);)l--;if(l>=0&&Ae[l]===ln)return ne}if(n===P0&&(r===P0||r===Np||r===x0||r===w0)||(n===Np||n===x0)&&(r===Np||r===Ip)||(n===Ip||n===w0)&&r===Ip||FE(n)&&r===Qs||n===Zs&&FE(r)||Rr(n)&&Rr(r))return ne;let s=n===kp||n===y0||vo[t]===vp,a=r===kp||r===y0||vo[e]===vp;if(n===E5&&a||s&&(r===CE||r===OE)||n===OE&&t>0&&(Ae[t-1]===kp||Ae[t-1]===y0||vo[t-1]===vp)&&(r===kp||vo[e]===vp)||s&&a&&e+1<ko&&Ae[e+1]===CE||n===So&&Rr(r)||(Rr(n)||n===ln)&&r===Sp&&!In[e]||n===Du&&!In[t]&&(Rr(r)||r===ln))return ne;if(n===m0&&r===m0){let l=t;for(;l>=0&&Ae[l]===m0;)l--;if((t-l)%2===1)return ne}return r===HE&&(n===BE||Gu[t])?ne:Hu}var _5=null;function KE(){return _5}function jE(e){return e%2===1?"rtl":"ltr"}var D5=[[1424,1535],[1536,1983],[2144,2303],[64285,65023],[65136,65279],[67584,69631],[124928,126975]],B5=[[1536,1541],[1632,1644],[1757,1757],[1776,1785],[2274,2274],[68912,68921],[69216,69246]],H5=[[1548,1548],[64830,64831],[65279,65279]];function E0(e,t){for(let n=0;n<e.length;n++)if(t>=e[n][0]&&t<=e[n][1])return!0;return!1}var zE=!1;function $E(e,t="weasel layoutRuns"){if(!zE)for(let n=0;n<e.length;n++){let r=e[n];if(!(!E0(D5,r)||E0(B5,r)||E0(H5,r))){zE=!0,console.warn(`${t}: this text contains right-to-left characters but no \`bidi\` engine is registered, so it is being laid out in logical order \u2014 the glyphs will appear reversed. Import \`bidi\` out of the \`@weasel-js/bidi\` package and call \`registerBidi(bidi)\` once at startup.`);return}}}var Wu=[.5];function Fi(e){if(e>65536)return new Array(e).fill(.5);for(;Wu.length<e;)Wu=Wu.concat(Wu);return Wu.slice(0,e)}var G5=1<<18,YE=new Map,qE=new Map,M0=0;function XE(e,t){let n=e.get(t);if(n===void 0||n.n===0)return;M0-=t;let r=n.items[--n.n];return n.items[n.n]=void 0,r}function JE(e,t){let n=t.length;if(n===0||M0+n>G5)return;let r=e.get(n);r===void 0&&e.set(n,r={items:[],n:0}),r.items[r.n++]=t,M0+=n}function Vu(e){return XE(YE,e)??Fi(e)}function C0(e){return XE(qE,e)??new Array(e)}function Ep(e){JE(YE,e)}function QE(e){JE(qE,e)}function gt(e,t){for(;e.length>t;)e.pop()}var Ir=13,O0=0,Mp=1,ZE=2,eM=3,tM=4,nM=5,rM=6,F0=7,oM=8,L0=9,iM=10,sM=11,aM=12,_0=1,lM=2,Cp=5,U5=[],W5=[],D0=[],V5=1024,z5=0,Op=class e{num;ref;boxes=[];bounds={width:.5,height:.5};laid=null;stamp=0;paintings=[];owners=0;listed=!1;pinned=!1;constructor(t){this.num=Vu(t*Ir),this.ref=C0(t*Cp)}static take(t){let n=D0.pop();return n===void 0?n=new e(t):(n.num=Vu(t*Ir),n.ref=C0(t*Cp)),n.stamp=++z5,n}recycle(){Ep(this.num);let{ref:t}=this;for(let n=0;n<t.length;n++)t[n]=void 0;QE(t),this.num=U5,this.ref=W5,gt(this.paintings,0),this.owners=0,this.listed=!1,this.pinned=!1,D0.length<V5&&D0.push(this)}set(t,n,r,o,i,s){let a=t*Ir,l=t*Cp,{num:u,ref:c}=this;u[a+O0]=o,u[a+Mp]=i,u[a+ZE]=n.advance,u[a+eM]=n.fontSize,u[a+tM]=s,u[a+nM]=n.srcIndex,u[a+rM]=n.srcEnd,u[a+F0]=n.cp,u[a+oM]=r,u[a+iM]=n.run,u[a+aM]=n.rotate,u[a+L0]=(n.drawsInk?_0:0)|(n.clusterEnd?lM:0),c[l]=n.resolved,c[l+1]=n.metrics,c[l+2]=n.font,c[l+3]=n.glyph,c[l+4]=n.shaped}widen(t,n){this.num[t*Ir+Mp]+=n}setVisual(t,n,r){this.num[(t+n)*Ir+sM]=r}visual(t,n){return this.num[(t+n)*Ir+sM]}glyph(t,n,r){let o=t+n,i=o*Ir,s=o*Cp,{num:a,ref:l}=this;return r.run=a[i+iM],r.cell=n,r.cp=a[i+F0],r.fontSize=a[i+eM],r.resolved=l[s],r.metrics=l[s+1],r.font=l[s+2],r.glyph=l[s+3],r.shaped=l[s+4],r.x=a[i+O0],r.baselineY=a[i+tM],r.advance=a[i+ZE],r.step=a[i+Mp],r.rotate=a[i+aM],r}drawsInk(t,n){return(this.num[(t+n)*Ir+L0]&_0)!==0}cell(t,n){let r=(t+n)*Ir,{num:o}=this,i=o[r+L0];return{srcIndex:o[r+nM],srcEnd:o[r+rM],cp:o[r+F0],x:o[r+O0],advance:o[r+Mp],level:o[r+oM],drawsInk:(i&_0)!==0,clusterEnd:(i&lM)!==0}}};function B0(){return{run:0,cell:0,cp:0,fontSize:.5,resolved:null,metrics:null,font:null,glyph:null,shaped:null,x:.5,baselineY:.5,advance:.5,step:.5,rotate:.5}}var Pt=class e{#t;#n;#e;#r=!1;constructor(t,n,r,o,i,s,a,l,u,c){this.x0=t,this.y0=n,this.x1=r,this.y1=o,this.baselineY=i,this.srcEnd=s,this.justified=a,this.#t=l,this.#n=u,this.#e=c,Object.defineProperties(this,e.#o)}refill(t,n,r,o,i,s,a,l,u){return this.x0=t,this.y0=n,this.x1=r,this.y1=o,this.baselineY=i,this.srcEnd=s,this.justified=a,this.#n=l,this.#e=u,this.#r&&(this.#r=!1,Object.defineProperties(this,e.#o)),this}static columns(t){return t instanceof e?t.#t:null}static start(t){return t instanceof e?t.#n:0}static count(t){return t instanceof e?t.#e:t.glyphs.length}static#o={cells:Fp("cells",t=>{t.#r=!0;let n=new Array(t.#e);for(let r=0;r<t.#e;r++)n[r]=t.#t.cell(t.#n,r);return n}),glyphs:Fp("glyphs",t=>{t.#r=!0;let n=new Array(t.#e);for(let r=0;r<t.#e;r++)n[r]=t.#t.glyph(t.#n,t.#t.visual(t.#n,r),B0());return n})}};function Fp(e,t){return{enumerable:!0,configurable:!0,get(){let n=t(this);return Object.defineProperty(this,e,{value:n,enumerable:!0,configurable:!0,writable:!1}),n}}}var H0,K5=/[\r\u0300-\uffff]/;function j5(){return H0===void 0&&(H0=typeof Intl<"u"&&"Segmenter"in Intl?new Intl.Segmenter(void 0,{granularity:"grapheme"}):null),H0}function _p(e,t){let n=t??[],r=0;if(K5.test(e)){let o=j5();if(o)r=$5(o,e,n);else{let i=0;for(let s of e)n[r++]=i+=s.length}}else for(let o=1;o<=e.length;o++)n[r++]=o;return n.length=r,n}var Lp=e=>e<768&&e!==13;function $5(e,t,n){let r=t.length,o=null,i=0,s=0;for(;s<r;){if(Lp(t.charCodeAt(s))&&(s+1===r||Lp(t.charCodeAt(s+1)))){n[i++]=++s;continue}let a=s+1;for(;;){for(;a<r&&!Lp(t.charCodeAt(a));)a++;if(a===r||(a++,a===r||Lp(t.charCodeAt(a))))break}for(o??=e.segment(t);s<a;){let l=o.containing(s);n[i++]=s=l.index+l.segment.length}}return i}var dM=Object.freeze({d:null,key:"",glyphs:Object.freeze([]),rtl:!1,text:""}),uM=Object.freeze({cluster:dM,advance:0}),Y5=new WeakMap,q5=new WeakMap,cM=e=>String(Math.round(e*1e5)/1e5);function fM(e,t,n){if(n===null)return null;let r=l0(t);if(r===null)return null;let o=r.sfnt,i=n.shape(o,e.text,e.fontFeatures,e.lang),s=t.source==="outline"?Y5:q5,a=s.get(i);if(a)return a;let l=t.source==="outline"?null:u=>r.glyphIndexOf(u);return a=X5(n,o,e.text,i,l),s.set(i,a),a}function X5(e,t,n,r,o){let i=new Array(n.length),s=_p(n),a=0,l=0;for(;l<r.length;){let u=r[l].cluster,c=l;for(;c<r.length&&r[c].cluster===u;)c++;let d=c<r.length?r[c].cluster:n.length;for(;a<s.length&&s[a]<=u;)a++;let f=0;for(let p=a;p<s.length&&s[p]<d;p++)f++;if(!Z5(r,l,c)&&!(o&&J5(r[l],c-l,n,u,d,o))){let p=Q5(r,l,c),h=p/(f+1),m=r[l].rtl?h-p:0;i[u]=eK(e,t,r,l,c,n.slice(u,d),m,h);let y=h===0?uM:{cluster:dM,advance:h};for(let b=u+1,x=a;b<d;b++){let w=x<s.length&&s[x]===b;w&&x++,i[b]=w?y:uM}}l=c}return i}function J5(e,t,n,r,o,i){if(t!==1||e.dx!==0||e.dy!==0)return!1;let s=n.codePointAt(r);return o-r===(s>65535?2:1)&&i(s)===e.gid}function Q5(e,t,n){let r=0;for(let o=t;o<n;o++)r+=e[o].advance;return r}function Z5(e,t,n){for(let r=t;r<n;r++)if(e[r].gid===0)return!0;return!1}function eK(e,t,n,r,o,i,s,a){let l=[],u=s,c="",d="";for(let f=r;f<o;f++){let p=n[f],h=u+p.dx,m=p.dy;l.push({gid:p.gid,x:h,y:m,advance:p.advance}),c+=e.glyphD(t,p.gid,h,m)??"",d+=`${f===r?"":";"}${p.gid}${h===0&&m===0?"":`@${cM(h)},${cM(m)}`}`,u+=p.advance}return{cluster:{d:c.length>0?c:null,key:d,glyphs:l,rtl:n[r].rtl,text:i},advance:a}}var tK=/^[\p{Mn}\p{Me}]$/u;function mM(e,t,n,r,o=null){let i=r??[],s=0,a,l=0;for(let u=0;u<e.length;u++){let c=e[u],d=xn(c.fontFamily,c.fontWeight,c.fontStyle),f=ms(d);if(!f){sg(c.fontFamily,c.fontWeight,c.fontStyle),l+=c.srcMap?.length??c.text.length,a=void 0;continue}let p=l,h=c.srcMap,m=_p(c.text,rK),y=fM(c,d,o),b=0,x=0,w=null,g=0,P=c.text;for(;g<P.length;){let S=P.codePointAt(g),v=S>65535?2:1,A=y?.[g],N=c.sizeMap?c.sizeMap[g]:c.fontSize;g===x&&(w=ag(d,c.fontFamily,c.fontWeight,c.fontStyle,c.text.slice(g,m[b])));let M=g+v===m[b];M&&(x=m[b++]);let C=M?c.letterSpacing:0,F=h?p+h.starts[g]:p+g,D=h?p+h.ends[g]:p+g+v;g+=v,l=h?p+h.length:D;let B=nK(S),K=a&&!B?a.metrics.kernOf(a.cp,S)*(a.fontSize/a.metrics.size):0,W=iK(n,s,u,c,S,N,F,D,M,d,f);if(w)M&&(W.tracking=C,hM(W,w)),i[s++]=W,a=void 0;else if(Oi(S))i[s++]=W,a=void 0;else if(S===9||S===32){let Q=f.advanceOf(32),le=Q!==null?Q*(N/f.size):N*.25;if(S===9)i[s++]={...W,tab:{stop:t*(le+c.letterSpacing),min:le/2}},a=void 0;else{let ke=wl(d,32,pM);W.font=ke?.font??null,W.glyph=ke?.glyph??null,W.advance=le,W.tracking=C,W.kerningBefore=K,a=W,i[s++]=a}}else if(A!==void 0)W.tracking=C,i[s++]=sK(W,A),a=void 0;else{let Q=Pl(d,c.fontFamily,c.fontWeight,c.fontStyle,S,!0,pM);Q&&(W.kerningBefore=K,W.tracking=C,hM(W,Q)),i[s++]=W,B||(a=W)}}}return i.length=s,i}function nK(e){return e>=768&&tK.test(String.fromCodePoint(e))}var rK=[],pM={resolved:null,metrics:null,advance:0,font:null,glyph:null},oK=4096;function iK(e,t,n,r,o,i,s,a,l,u,c){let d=Math.max(r.fontSize,r.strutSize??0),f=r.baselineShift??0,p=r.rotate??0,h=e?.[t];if(!h){let m={run:n,cp:o,fontSize:i,lineSize:d,baselineShift:f,rotate:p,srcIndex:s,srcEnd:a,clusterEnd:l,resolved:u,metrics:c,font:null,glyph:null,advance:0,tracking:0,kerningBefore:0,tab:void 0,shaped:null,drawsInk:!1};return e&&t<oK&&(e[t]=m),m}return h.run=n,h.cp=o,h.fontSize=i,h.lineSize=d,h.baselineShift=f,h.rotate=p,h.srcIndex=s,h.srcEnd=a,h.clusterEnd=l,h.resolved=u,h.metrics=c,h.font=null,h.glyph=null,h.advance=0,h.tracking=0,h.kerningBefore=0,h.tab=void 0,h.shaped=null,h.drawsInk=!1,h}function hM(e,t){e.resolved=t.resolved,e.metrics=t.metrics,e.font=t.font,e.glyph=t.glyph,e.advance=t.advance*(e.fontSize/t.metrics.size),e.drawsInk=!0}function sK(e,t){return e.shaped=t.cluster,e.advance=t.advance*e.fontSize,e.drawsInk=t.cluster.d!==null,e}function yM(e,t,n,r){return e.map((o,i)=>{let s=t[i]%2===1;if(o.shaped!==null&&o.shaped.rtl!==s){let c=n(o.cp);c!==null&&c!==o.cp&&(o=aK(o,r[o.run]))}if(!s||o.shaped!==null)return o;let a=n(o.cp);if(a===null||a===o.cp)return o;if(o.font===null)return{...o,cp:a};let l=r[o.run],u=Pl(o.resolved,l.fontFamily,l.fontWeight,l.fontStyle,a,!1);return u?{...o,cp:a,resolved:u.resolved,metrics:u.metrics,font:u.font,glyph:u.glyph}:o})}function aK(e,t){if(e.resolved.source==="outline")return{...e,shaped:null};let n=Pl(e.resolved,t.fontFamily,t.fontWeight,t.fontStyle,e.cp,!1);return n?{...e,shaped:null,resolved:n.resolved,metrics:n.metrics,font:n.font,glyph:n.glyph}:{...e,shaped:null}}var Bp=e=>e===32||e===9;var Dp=new Uint8Array(64),G0=!1,lK=65536;function gM(e,t,n,r){let o=e.length;if(!Number.isFinite(t.maxWidth))U0(e,t,n,r,null);else if(G0||o>=lK)U0(e,t,n,r,VE(e));else{Dp.length<o+1&&(Dp=new Uint8Array(Math.max(o+1,Dp.length*2))),G0=!0;try{U0(e,t,n,r,I0(e,Dp))}finally{G0=!1}}}function U0(e,t,n,r,o){let i=e.length,s=0,a=0;for(;a<i;){let l=e[a];if(Oi(l)){r(s,a,!1),a+=l===13&&e[a+1]===10?2:1,s=a;continue}if(Bp(l)){a++;continue}let u=a+1,c=a+1;for(;u<i&&!Oi(e[u])&&(!o||o[u]===ne);)Bp(e[u])||(c=u+1),u++;o&&a>s&&n(s,c)>t.maxWidth&&(r(s,a,!0),s=a),a=u}s<i&&r(s,i,!1)}function bM(e,t){let n=e.lineSize/e.metrics.size,r=e.metrics.ascent*n;return e.metrics.descent===void 0?r:(e.lineSize*t-r-e.metrics.descent*n)/2+r}var wM=[],Ku=wM,Li=Fi(64),V0=[],zu=[],z0=0,xM=[],uK=64;function PM(e,t){return Ku[e].advance+Ku[e].tracking+Li[t]-Li[e+1]}var cK=e=>Ku[e].tab;function dK(e,t){return ZI(e,t,V0,cK,PM)}function fK(e,t,n){let r=z0++,o=xM[r];o===void 0&&(o={start:0,entries:[],width:.5,height:.5,ascent:.5,wrapped:!1,srcEnd:0,end:0},r<uK&&(xM[r]=o)),o.start=e,o.end=t,o.wrapped=n,o.width=0,o.height=0,o.ascent=0,o.srcEnd=0,zu[r]=o}function TM(e,t,n){let{lineHeight:r}=n;Li.length<e.length+1&&(Li=Fi(e.length+1)),Li[0]=0;let o=0;z0=0;for(let i=0;i<e.length;i++){let s=e[i];Li[i+1]=Li[i]+s.kerningBefore+s.advance+s.tracking,s.tab&&(V0[o++]=i)}V0.length=o,Ku=e,gM(t,n,o===0?PM:dK,fK),Ku=wM,zu.length=z0;for(let i=0;i<zu.length;i++){let s=zu[i];if(s.start===s.end){let l=e[s.end];s.height=l.lineSize*r,s.ascent=bM(l,r),s.srcEnd=l.srcIndex,gt(s.entries,0);continue}let a=s.entries;for(let l=s.start;l<s.end;l++){let u=e[l];l===s.start&&(u.kerningBefore=0),u.tab&&(u.advance=r0(s.width,u.tab.stop,u.tab.min)),a[l-s.start]=u,s.width+=u.kerningBefore+u.advance+u.tracking,s.height=Math.max(s.height,u.lineSize*r),s.ascent=Math.max(s.ascent,bM(u,r))}a.length=s.end-s.start,s.srcEnd=e[s.end-1].srcEnd}return zu}function pK(e){let t=0;for(let n=e.length-1;n>=0&&Bp(e[n].cp);n--){let r=e[n];t+=r.kerningBefore+r.advance+r.tracking}return t}function hK(e){let t=new Set,n=0;for(;n<e.length&&e[n].cp===32;)n++;let r=e.length-1;for(;r>n&&e[r].cp===32;)r--;for(let o=n+1;o<r;o++)e[o].cp===32&&t.add(o);return t}function mK(e,t,n){if(e==="left")return 0;if(!Number.isFinite(t))return e==="center"?-n/2:-n;let r=t-n;return e==="center"?r/2:r}var yK=new Set,W0={box:null,inkWidth:.5};function SM(e,t,n,r,o,i,s,a){let{alignWidth:l,justify:u}=o,{entries:c}=e,d=pK(c),f=e.width-d,p=l-f,h=u&&e.wrapped&&Number.isFinite(l)&&p>0?hK(c):yK,m=h.size>0?p/h.size:0,y=m*h.size,b=y>0?0:mK(r,l,f),w=d>0&&n.levels[c.length-1]%2===1?b-d:b,g=t+e.ascent,P=w,S=-1,v=-1,A=0,{visual:N}=n;for(let D=0;D<N.length;D++){let B=N[D],K=c[B],W=S<0?0:B===S+1?K.kerningBefore:S===B+1?c[S].kerningBefore:0;W!==0&&i.widen(s+(v>=0?v:S),W),P+=W,S=B;let Q=K.advance+K.tracking+(h.has(B)?m:0);Q!==0&&(v=B),i.set(s+B,K,n.levels[B],P,Q,g-K.baselineShift),i.setVisual(s,A++,B),P+=Q}let M=w+e.width+y,C=t+e.height,F=i.boxes[a];return W0.box=F!==void 0?F.refill(w,t,M,C,g,e.srcEnd,y>0,s,c.length):i.boxes[a]=new Pt(w,t,M,C,g,e.srcEnd,y>0,i,s,c.length),W0.inkWidth=f+y,W0}function K0(e,t={maxWidth:0,alignWidth:0,lineHeight:0,align:"left",justify:!1,bidi:null,shaper:null,direction:"auto",tabSize:0}){return t.maxWidth=e.maxWidth,Hp(t,e),t.lineHeight=e.lineHeight,t.align=e.align,t.justify=e.justify===!0||e.align==="justify",t.bidi=j0(e),t.shaper=ju(e),t.direction=e.direction??"auto",t.tabSize=e.tabSize??8,t}function Hp(e,t){t.alignWidth===void 0?e.alignWidth=t.maxWidth:e.alignWidth=t.alignWidth}function j0(e){return e.bidi??KE()}function ju(e){return e.shaper??cE()}var gK=[],bK=[],kM=[],xK=K0({maxWidth:0,lineHeight:0,align:"left"}),wK={maxWidth:.5,alignWidth:.5,lineHeight:.5,justify:!1},PK=e=>Oi(kM[e]);function TK(e,t,n,r){return yM(t,n,o=>e.mirror(o),r)}function vM(e,t){let{maxWidth:n,alignWidth:r,lineHeight:o,align:i,justify:s,bidi:a,shaper:l,direction:u,tabSize:c}=K0(t,xK),d=mM(e,c,gK,bK,l),f=kM;f.length=d.length;for(let S=0;S<d.length;S++)f[S]=d[S].cp;let p=a?PE(a,f,PK,u):null;a||$E(f);let h=wK;h.maxWidth=n,h.alignWidth=r,h.lineHeight=o,h.justify=s;let m=TM(d,f,h),y=0;for(let S=0;S<m.length;S++)y+=m[S].entries.length;let b=m.length>0?Op.take(y):null,x=b!==null?b.boxes:[],w=0,g=0,P=0;for(let S=0;S<m.length;S++){let v=m[S],A=TE(p,v.start,v.entries.length);a&&(v.entries=TK(a,v.entries,A.levels,e));let N=u!=="auto"?u:jE(v.entries.length>0?p?.baseLevel(v.start)??0:0),M=SM(v,w,A,i0(i,N),h,b,P,S);P+=v.entries.length,g=Math.max(g,M.inkWidth),w+=v.height}return x.length=m.length,b===null?{lines:x,bounds:{width:g,height:w}}:(b.bounds.width=g,b.bounds.height=w,b.laid??={lines:x,bounds:b.bounds})}Pe();Pe();var Er=11;function AM(e){let{font:t,glyph:n}=e;return t!==null&&n!==null&&n.width!==0&&n.page>=0}function $0(e,t,n){let r=e.font,o=e.glyph,i=e.fontSize/e.metrics.size,s=e.x+o.xoffset*i,a=e.baselineY+(o.yoffset-e.metrics.base)*i;t[n]=s,t[n+1]=a,t[n+2]=s+o.width*i,t[n+3]=a+o.height*i,t[n+4]=o.x/r.common.scaleW,t[n+5]=o.y/r.common.scaleH,t[n+6]=(o.x+o.width)/r.common.scaleW,t[n+7]=(o.y+o.height)/r.common.scaleH,t[n+8]=e.baselineY,t[n+9]=e.x,t[n+10]=e.rotate??0}var Y0=new WeakSet,RM={quads:Fp("quads",e=>{Y0.add(e);let t=e.quadData,n=[];for(let r=0,o=0;r<t.length;r+=Er,o++){let i={x0:t[r],y0:t[r+1],x1:t[r+2],y1:t[r+3],u0:t[r+4],v0:t[r+5],u1:t[r+6],v1:t[r+7],baselineY:t[r+8],penX:t[r+9],rotate:t[r+10]};e.colorGlyphs&&(i.colorGlyph=e.colorGlyphs[o]),n.push(i)}return n})};function EM(e,t){return t==="outline"&&Sr(e.stroke)?e.stroke:void 0}function NM(e,t){return`${bo(e.fill?.paint)}|${ru(EM(e,t))}`}function X0(e,t,n){let{family:r,weight:o,style:i}=t.resolved.resolved,{synthetic:s}=t.resolved,a=n==="outline"?0:t.glyph.page;if(Je.group!==null&&Je.run===t.run&&Je.source===n&&Je.page===a&&Je.family===r&&Je.weight===o&&Je.style===i&&Je.bold===s.bold&&Je.italic===s.italic)return Je.group;let l=e[t.run],u=null,c=null;for(let d=0;d<Ao.length;d++){let f=Ao[d],p=f.group;if(!(p.source!==n||p.page!==a||p.family!==r||p.weight!==o||p.style!==i||p.synthetic.bold!==s.bold||p.synthetic.italic!==s.italic)&&!(f.run!==t.run&&(c??=NM(l,n),f.paint??=NM(e[f.run],n),f.paint!==c))){u=p;break}}if(u===null){let d=EM(l,n);u=d===void 0&&n!=="color"?q0.pop()??null:null,u!==null?(u.family=r,u.weight=o,u.style=i,u.synthetic.bold=s.bold,u.synthetic.italic=s.italic,u.source=n,u.page=a,u.fill=l.fill):(u=Object.defineProperties({family:r,weight:o,style:i,synthetic:{bold:s.bold,italic:s.italic},source:n,page:a,fill:l.fill,quadData:ta,glyphs:[]},RM),d&&(u.stroke=d),n==="color"&&(u.colorGlyphs=[]));let f=Ao.length,p=IM[f];p===void 0?(p={group:u,run:t.run,paint:c},f<kK&&(IM[f]=p)):(p.group=u,p.run=t.run,p.paint=c),Ao.push(p)}return Je.group=u,Je.run=t.run,Je.family=r,Je.weight=o,Je.style=i,Je.bold=s.bold,Je.italic=s.italic,Je.source=n,Je.page=a,u}var ta=[],q0=[],SK=1024;function MM(e){q0.length>=SK||e.stroke!==void 0||e.colorGlyphs!==void 0||Y0.has(e)||(e.quadData=ta,gt(e.glyphs,0),q0.push(e))}var Ao=[],IM=[],kK=64,Je={group:null,run:-1,family:"",weight:0,style:"normal",bold:!1,italic:!1,source:"atlas",page:0};function CM(e){for(let t=0;t<Ao.length;t++)e.push(Ao[t].group),Ao[t].group=null;gt(Ao,0),Je.group=null}Pe();Z();var OM=5e-4,FM=4096,Gp=new Map,Up=new Map;function LM(e){if(!e.synthetic.bold)return null;let{source:t}=e;if(t!=="atlas"&&t!=="canvas")return null;let{family:n,weight:r,style:o}=e.resolved,i=pg(t,n,r,o);return i===void 0||!(i>0)?null:{growth:i,join:t==="atlas"?"miter":"round"}}function vK(e,t,n){let r=LM(n);if(r===null)return e;let o=`${r.growth}|${r.join}|${t}`,i=Gp.get(o);return i||(i=wb(bb(e,r.growth,{join:r.join,tolerance:OM}),{tolerance:OM}),Gp.size>=FM&&Gp.clear(),Gp.set(o,i),i)}function _M(e,t){let n=LM(t);if(n===null)return null;let r=`bold:${n.growth}:${n.join}`,o=`${r}|${e}`,i=Up.get(o);return i===void 0&&(i=qg(vK(fi(e),e,t)),Up.size>=FM&&Up.clear(),Up.set(o,i)),{d:i,tag:r}}function DM(e,t,n,r=!1){let o=e.resolved.source==="outline";if(!o&&!r&&(n===void 0||t.fontSize<n&&!Sr(t.stroke)))return null;let i=AK(e);if(i===null)return null;let{family:s,weight:a,style:l}=e.resolved.resolved,u=e.shaped?`${s}|${a}|${l}|#${e.shaped.key}`:`${s}|${a}|${l}|${e.cp}`;if(o||!e.resolved.synthetic.bold)return{d:i,key:u};let c=_M(i,e.resolved);return c&&{d:c.d,key:`${u}|${c.tag}`}}function AK(e){if(e.shaped)return e.shaped.d;if(e.glyph?.color)return null;let{family:t,weight:n,style:r}=e.resolved.resolved;return e.resolved.source!=="outline"&&e.glyph===null?null:Jy(t,n,r,e.cp)}function RK(e){let t=e.resolved.dynamicFace,n=e.shaped;if(!t||n.d===null)return null;let r=t.requestShaped(n.key,n.d);return!r||r.page<0||r.width===0?null:{...e,font:t.font,glyph:r}}function NK(e){let t=e.map(n=>ei(xn(n.fontFamily,n.fontWeight,n.fontStyle)));return n=>t[n]}var IK=e=>e.underline||e.strikethrough||e.overline;function EK(e){return t=>Rf(e[t].fill)?bo(e[t].fill.paint):null}var MK=B0(),$u=[],BM=16384;function J0(e,t,n,r){let{groups:o,decorations:i}=r;gt(o,0),gt(i,0);let s=t.some(IK)?NK(t):null,a=s&&EK(t),l=0,{lines:u}=e;for(let h=0;h<u.length;h++)l+=Pt.count(u[h]);let c=l*Er;c<=BM&&$u.length<c&&($u=Fi(c));let d=c<=BM?$u:Fi(c),f=null,p=0;for(let h=0;h<u.length;h++){let m=u[h],y=Pt.columns(m),b=y!==null?Pt.start(m):0,x=Pt.count(m),w=s&&xE(t,s,a);for(let g=0;g<x;g++){let P=y!==null?y.visual(b,g):-1,S=y!==null?y.glyph(b,P,MK):m.glyphs[g];w?.add(S);let v=t[S.run],A=y!==null?y.drawsInk(b,P):m.cells[S.cell].drawsInk,N=A?DM(S,v,n.outlineMinSize):null,M=S;if(A&&N===null&&S.shaped){let D=RK(S);D?M=D:N=DM(S,v,n.outlineMinSize,!0)}if(!Rf(v.fill)&&!(N!==null&&Sr(v.stroke)))continue;if(N!==null){let D={...N,x:S.x,baselineY:S.baselineY,scale:S.fontSize};S.rotate&&(D.rotate=S.rotate),X0(t,S,"outline").glyphs.push(D);continue}if(!AM(M))continue;let C=X0(t,M,M.glyph.color?"color":M.resolved.source);f===null&&(f=C,C.quadData=d);let F=C.quadData;F===ta&&(C.quadData=F=[]),C===f?($0(M,F,p),p+=Er):$0(M,F,F.length),C.colorGlyphs?.push(M.glyph)}if(w)for(let g of w.end()){let{run:P,...S}=g;i.push({...S,fill:t[P].fill})}}if(f!==null&&d!==$u)d.length=p;else if(f!==null){let h=Vu(p);for(let m=0;m<p;m++)h[m]=$u[m];f.quadData=h}return CM(o),r}var Q0=new WeakMap,CK=[];function Z0(e){return Q0.get(e)}function Wp(e){let t=Q0.get(e);return t===void 0&&(t=CK.pop()??{generation:-1,variants:[],painting:null,paintedOn:null,paintedStamp:0,paintMin:void 0,listed:null},Q0.set(e,t)),t}var OK=32,Vp=new WeakMap;function FK(e){return e.lines.length>0?Pt.columns(e.lines[0])?.stamp??0:0}function LK(e){let t=e.lines.length>0?Pt.columns(e.lines[0]):null;if(t!==null)return t.paintings;let n=Vp.get(e);return n===void 0&&Vp.set(e,n=[]),n}var tw=[],_K=1024;function HM(e,t,n,r,o,i){let s=tw.pop();return s===void 0?{generation:r,key:o,bucket:i,runs:o===null?t:null,painted:J0(e,t,n,{groups:[],decorations:[]}),pinned:!1}:(s.generation=r,s.key=o,s.bucket=i,s.runs=o===null?t:null,s.pinned=!1,J0(e,t,n,s.painted),s)}function DK(e,t){if(t===void 0)return-1;let n=0;for(let r=0;r<e.length;r++){let o=e[r].fontSize;if(!(o>=t))continue;let i=!1;for(let s=0;s<r&&!i;s++)i=e[s].fontSize===o;i||n++}return n}function GM(e,t){let n=`${t}`;for(let r of e)n+=`|${r.underline?1:0}${r.strikethrough?1:0}${r.overline?1:0}${bo(r.fill?.paint)}|${ru(r.stroke)}`;return n}function UM(e){return e.key===null&&(e.key=GM(e.runs,e.bucket),e.runs=null),e.key}function nw(e,t,n={},r="keep"){let o=ti(),i=n.outlineMinSize,s=Z0(t),a=FK(e),l=s!==void 0&&s.paintedOn===e&&s.paintedStamp===a?s.painting:null,u=l!==null&&l.generation===o;if(u&&s.paintMin===i)return ew(l,r);let c=DK(t,i);if(u&&l.bucket===c)return s.paintMin=i,ew(l,r);let d=LK(e),f=null;if(d.length>0){let h=GM(t,c);for(let m=0;m<d.length;m++){let y=d[m];if(!(y.bucket!==c||UM(y)!==h)){d.splice(m,1),y.generation===o&&(f=y);break}}f??=HM(e,t,n,o,h,c)}else f=HM(e,t,n,o,null,c);d.length>=OK&&d.shift(),d.push(f);let p=s??Wp(t);return p.painting!==null&&p.painting!==f&&WM(p.painting,t),p.paintedOn=e,p.paintedStamp=a,p.painting=f,p.paintMin=i,ew(f,r)}function WM(e,t){e.runs===t&&UM(e)}function ew(e,t){return t==="keep"&&(e.pinned=!0),e.painted}function VM(e){let t=e.lines.length>0?Pt.columns(e.lines[0]):null,n;if(t!==null)n=t.paintings;else{if(n=Vp.get(e),n===void 0)return;Vp.delete(e)}for(let r=0;r<n.length;r++){let o=n[r];if(o.pinned)continue;let{groups:i}=o.painted;for(let s=0;s<i.length;s++){let a=i[s];a.quadData.length>0&&Ep(a.quadData),a.quadData=ta,MM(a)}gt(i,0),gt(o.painted.decorations,0),o.runs=null,o.key=null,tw.length<_K&&tw.push(o)}gt(n,0)}var JM=8,QM=64,Mr=[],zM=-1,KM=0,Mn=(e,t)=>e===t||e!==e&&t!==t;function ZM(e,t,n){return Mn(e.maxWidth,t.maxWidth)&&Mn(e.alignWidth,t.alignWidth??t.maxWidth)&&Mn(e.lineHeight,t.lineHeight)&&e.align===t.align&&e.justify===(t.justify===!0||t.align==="justify")&&e.direction===(t.direction??"auto")&&Mn(e.tabSize,t.tabSize??8)&&e.bidi===n&&e.shaper===ju(t)}var oa=e=>e.lines.length>0?Pt.columns(e.lines[0]):null;function jM(e,t){if(t==="keep"){let n=oa(e);n!==null&&(n.pinned=!0)}return e}function e2(e){let t=oa(e);t===null||t.owners>0||t.listed||t.pinned||(VM(e),t.recycle())}var ow=[],BK=1024;function $M(e){for(let t=0;t<e.length;t++){let n=e[t],r=oa(n.laid);r!==null&&(r.owners--,e2(n.laid)),n.laid=HK,ow.length<BK&&ow.push(n)}gt(e,0)}var HK={lines:[],bounds:{width:0,height:0}};function iw(e,t,n,r){return e.maxWidth=t.maxWidth,Hp(e,t),e.lineHeight=t.lineHeight,e.align=t.align,e.justify=t.justify===!0||t.align==="justify",e.direction=t.direction??"auto",e.tabSize=t.tabSize??8,e.bidi=n,e.shaper=ju(t),e.laid=r,e}function GK(e,t,n){let r=ow.pop();if(r!==void 0)return iw(r,e,t,n);let o={maxWidth:e.maxWidth,alignWidth:e.maxWidth,lineHeight:e.lineHeight,align:e.align,justify:e.justify===!0||e.align==="justify",direction:e.direction??"auto",tabSize:e.tabSize??8,bidi:t,shaper:ju(e),laid:n};return Hp(o,e),o}function ra(e,t){return Math.imul(e^t,16777619)}function na(e,t){return ra(e,t===(t|0)?t:Math.round(t*4096))}function rw(e,t){e=ra(e,t.length);for(let n=0;n<t.length;n++)e=ra(e,t.charCodeAt(n));return e}function UK(e){let t=ra(2166136261,e.length);for(let n=0;n<e.length;n++){let r=e[n];t=rw(t,r.text),t=rw(t,r.fontFamily),t=na(t,r.fontSize),t=na(t,r.fontWeight),t=ra(t,r.fontStyle==="italic"?1:0),t=na(t,r.letterSpacing),t=na(t,r.baselineShift),t=na(t,r.rotate??0),t=na(t,r.strutSize??-1),t=ra(t,r.fontFeatures?.length??0),t=rw(t,r.lang??"")}return t&1073741823}var YM=[];function qM(e,t){return e===t||e!==void 0&&t!==void 0&&ud(e,t,Mn)}var WK=(e,t)=>ud(e??YM,t??YM);function VK(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let r=e[n],o=t[n];if(r===o)continue;if(r.text!==o.text||r.fontFamily!==o.fontFamily||!Mn(r.fontSize,o.fontSize)||!Mn(r.fontWeight,o.fontWeight)||r.fontStyle!==o.fontStyle||!Mn(r.letterSpacing,o.letterSpacing)||!Mn(r.baselineShift,o.baselineShift)||!Mn(r.strutSize,o.strutSize)||!Mn(r.rotate??0,o.rotate??0)||!qM(r.sizeMap,o.sizeMap)||!WK(r.fontFeatures,o.fontFeatures)||r.lang!==o.lang)return!1;let i=r.srcMap,s=o.srcMap;if(i!==s&&(i===void 0||s===void 0||i.length!==s.length||!qM(i.starts,s.starts)))return!1}return!0}function Yu(e,t,n="keep"){let r=fl(),o=j0(t),i=Wp(e);if(i.generation!==r)i.generation=r,$M(i.variants);else{let u=i.variants;for(let c=0;c<u.length;c++){let d=u[c];if(ZM(d,t,o)){for(let f=c;f>0;f--)u[f]=u[f-1];return u[0]=d,jM(d.laid,n)}}}let s=zK(e,t,o,r,i),a=i.variants;a.length>=JM&&$M(a),a.unshift(GK(t,o,s));let l=oa(s);return l!==null&&l.owners++,jM(s,n)}function zK(e,t,n,r,o){if(zM!==r){for(let d of Mr)XM(d),d.runs=KK;Mr=[],zM=r}let i=UK(e),s=0;for(let d=0;d<Mr.length;d++){let f=Mr[d];if(f.hash===i&&ZM(f,t,n)&&VK(f.runs,e))return f.used=++KM,f.laid;f.used<Mr[s].used&&(s=d)}let a=Mr.length>=QM;a&&XM(Mr[s]);let l=vM(e,t),u=a?iw(Mr[s],t,n,l):jK(t,n,l);u.hash=i,u.runs=e,u.used=++KM,o.listed=u;let c=oa(l);return c!==null&&(c.listed=!0),a||Mr.push(u),l}var KK=[];function jK(e,t,n){return iw({maxWidth:0,alignWidth:0,lineHeight:0,align:"left",justify:!1,direction:"auto",tabSize:0,bidi:null,shaper:null,laid:n,hash:0,runs:[],used:0},e,t,n)}function XM(e){let t=oa(e.laid);t!==null&&(t.listed=!1,e2(e.laid))}function qu(e,t,n){if(e===void 0||e==="top"||t===void 0)return 0;let r=t-n;return e==="center"?r/2:r}function zp(e,t=1){let n=s0(e.style,{fill:e.fill,stroke:e.stroke},t),r=e.runs&&e.runs.length>0?e.runs:e.text;return{style:n,runs:Fu(QI(r),n,t),opts:{maxWidth:n.wrap?e.width:1/0,alignWidth:e.width,lineHeight:n.lineHeight,align:n.align,direction:n.direction,tabSize:n.tabSize,justify:n.align==="justify"}}}function sw(e,t=1){let{runs:n,opts:r}=zp(e,t),o=Yu(n,r);return{laid:o,x:e.x,y:e.y+qu(e.verticalAlign,e.height,o.bounds.height)}}function Kp(e,t={}){let n=t.padding??0,{laid:r,x:o,y:i}=sw(e),s=[];for(let a of r.lines)!t.includeEmpty&&a.x1<=a.x0||s.push({x:a.x0+o-n,y:a.y0+i-n,width:a.x1-a.x0+n*2,height:a.y1-a.y0+n*2});return s}Z();function Ro(e){if(!e)return $K;let t=e*Un;return[Math.cos(t),Math.sin(t)]}var $K=[1,0];var No={maxWidth:0,alignWidth:void 0,lineHeight:0,align:"left",direction:"auto",tabSize:0,justify:void 0},jp={laid:null,dx:0,dy:0};function $p(e){let t=e.style;No.maxWidth=e.maxWidth??1/0,No.alignWidth=e.width,No.lineHeight=t.lineHeight??Ee.lineHeight,No.align=e.align??t.align??Ee.align,No.direction=e.direction??t.direction??Ee.direction,No.tabSize=t.tabSize??Ee.tabSize,No.justify=e.justify;let n=Yu(e.runs,No,"read");return jp.laid=n,jp.dx=e.x,jp.dy=e.y+qu(e.verticalAlign,e.height,n.bounds.height),jp}var Yp={side:.5,above:1.5,below:1};function t2(e,t){let{laid:n,dx:r,dy:o}=$p(e),i=q.meanScaleOf(t),s=q.minScaleOf(t),a=e.runs.map(f=>f.stroke?ia(f.stroke,i,s):0),l=1/0,u=1/0,c=-1/0,d=-1/0;for(let f of n.lines)for(let p of f.glyphs){let h=p.fontSize,m=a[p.run]??0,y=-Yp.side*h-m,b=p.advance+Yp.side*h+m,x=-Yp.above*h-m,w=Yp.below*h+m,[g,P]=Ro(p.rotate);for(let S=0;S<4;S++){let v=S===0||S===3?y:b,A=S<2?x:w,N=p.x+v*g-A*P,M=p.baselineY+v*P+A*g;N<l&&(l=N),N>c&&(c=N),M<u&&(u=M),M>d&&(d=M)}}return l===1/0?null:_i(l+r,u+o,c+r,d+o,t)}var YK=4,Di={minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},Bi={minX:-1/0,minY:-1/0,maxX:1/0,maxY:1/0};function lw(e,t,n){let r=Di;for(let o of e)if(r=JK(r,uw(o,t,n)),r===Bi)break;return r}function uw(e,t,n){switch(e.kind){case"group":{let r=e.transform?q.multiply(t,e.transform):t,o=lw(e.children,r,n);return e.effects&&e.effects.length>0&&(o=XK(o,$s(e.effects)/n)),e.clip?cw(o,qp(e.clip,void 0,r)):o}case"path":case"image":case"sprites":return dw(e,t)??Bi;case"text":return t2(e,t)??Di;case"shader":return qK(e)??Bi}}function qK(e){let t=Nn(e.program.id);if(!t||t.vert!==""||/\bgl_FragCoord\b/.test(t.frag)&&!/\bu_fragOrigin\b/.test(t.frag))return null;let{x:n,y:r,w:o,h:i}=e.bounds;return{minX:Math.min(n,n+o),minY:Math.min(r,r+i),maxX:Math.max(n,n+o),maxY:Math.max(r,r+i)}}function XK(e,t){return e===Di||e===Bi||t===0?e:Number.isFinite(t)?{minX:e.minX-t,minY:e.minY-t,maxX:e.maxX+t,maxY:e.maxY+t}:Bi}function JK(e,t){return e===Di||t===Bi?t:t===Di||e===Bi?e:{minX:Math.min(e.minX,t.minX),minY:Math.min(e.minY,t.minY),maxX:Math.max(e.maxX,t.maxX),maxY:Math.max(e.maxY,t.maxY)}}function cw(e,t){if(!t||e===Di)return e;let n={minX:Math.max(e.minX,t.minX),minY:Math.max(e.minY,t.minY),maxX:Math.min(e.maxX,t.maxX),maxY:Math.min(e.maxY,t.maxY)};return n.minX>n.maxX||n.minY>n.maxY?Di:n}function dw(e,t){switch(e.kind){case"path":return qp(e.path,e.stroke,t);case"image":return _i(e.x,e.y,e.x+e.w,e.y+e.h,t);case"sprites":return ZK(e.sprites,t)}}function qp(e,t,n){let r,o,i,s;if(e.kind==="rect")r=Math.min(e.x,e.x+e.width),i=Math.max(e.x,e.x+e.width),o=Math.min(e.y,e.y+e.height),s=Math.max(e.y,e.y+e.height);else if(e.kind==="polygon"){let l=e.coords;if(l.length<2)return null;r=i=l[0],o=s=l[1];for(let c=2;c+1<l.length;c+=2){let d=l[c],f=l[c+1];d<r?r=d:d>i&&(i=d),f<o?o=f:f>s&&(s=f)}let u=e.origin;u&&(r+=u.x,i+=u.x,o+=u.y,s+=u.y)}else return null;let a=t?QK(t,n):0;return _i(r-a,o-a,i+a,s+a,n)}function QK(e,t){return ia(e,q.meanScaleOf(t),q.minScaleOf(t))}function ia(e,t,n=t){let r=n>0?n:t,o=at(e.width??1,typeof e.width=="object"?r:t),i=Ni(o,e.vertexWidths),s=Math.max(e.miterLimit??YK,Math.SQRT2),a=Cu(e);return Math.max(Math.abs(i)*s,a.world,Wt({px:a.px},r))}function ZK(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let s=0;s+9<=e.length;s+=9){let a=e[s],l=e[s+1],u=a+e[s+2],c=l+e[s+3];n=Math.min(n,a,u),o=Math.max(o,a,u),r=Math.min(r,l,c),i=Math.max(i,l,c)}return n===1/0?null:_i(n,r,o,i,t)}function _i(e,t,n,r,o){let[i,s]=q.apply(o,e,t),[a,l]=q.apply(o,n,t),[u,c]=q.apply(o,n,r),[d,f]=q.apply(o,e,r);return{minX:Math.min(i,a,u,d),minY:Math.min(s,l,c,f),maxX:Math.max(i,a,u,d),maxY:Math.max(s,l,c,f)}}var Cr=1;function pw(e,t,n,r){return n2(e,t,r2(n),r)}function n2(e,t,n,r){let o=null;for(let i=0;i<e.length;i++){let s=e[i],a=ej(s,t,n,r);if(a===s){o?.push(s);continue}o??=e.slice(0,i),a&&o.push(a)}return o??e}function ej(e,t,n,r){switch(e.kind){case"group":{if(Yn(e.composite))return e;if(e.effects&&e.effects.length>0)return fw(uw(e,t,r),n)?null:e;let o=e.transform?q.multiply(t,e.transform):t,i=n2(e.children,o,n,r);return i===e.children?e:i.length===0?null:{...e,children:i}}case"path":case"image":case"sprites":return fw(dw(e,t),n)?null:e;default:return e}}function hw(e,t,n){let r=Math.min(e.x,e.x+e.width),o=Math.max(e.x,e.x+e.width),i=Math.min(e.y,e.y+e.height),s=Math.max(e.y,e.y+e.height);return fw(_i(r,i,o,s,t),r2(n))}function r2(e){return{minX:e.x-Cr,minY:e.y-Cr,maxX:e.x+e.width+Cr,maxY:e.y+e.height+Cr}}function fw(e,t){return e!==null&&(e.maxX<t.minX||e.minX>t.maxX||e.maxY<t.minY||e.minY>t.maxY)}function Xu(e,t,n,r){let o=lw(e,t,r);for(let i of n)o=cw(o,qp(i.path,void 0,i.transform));return tj(o,r)}function tj(e,t){let n=Math.floor((e.minX-Cr)*t),r=Math.floor((e.minY-Cr)*t),o=Math.ceil((e.maxX+Cr)*t),i=Math.ceil((e.maxY+Cr)*t);return[n,r,o,i].some(Number.isNaN)?{x0:-1/0,y0:-1/0,x1:1/0,y1:1/0}:{x0:n,y0:r,x1:o,y1:i}}function Hi(e,t){let n=Math.max(t.x,e.x0),r=Math.max(t.y,e.y0),o=Math.min(t.x+t.width,e.x1),i=Math.min(t.y+t.height,e.y1);return o<=n||i<=r?{x:0,y:0,width:0,height:0}:{x:n,y:r,width:o-n,height:i-r}}Z();function sa(e,t,n,r){let o=e.gl,i=e.renderTarget??null;o.bindFramebuffer(o.FRAMEBUFFER,i?i.fbo:null),i?i.restore?i.restore():o.viewport(0,0,t,n):(e.restoreTargetRect?.(),r&&o.enable(o.SCISSOR_TEST))}function mw(e,t,n,r,o,i,s,a){let l=e.gl;l.useProgram(t.handle);let u=t.attribute("a_position"),c=t.attribute("a_uv");l.bindBuffer(l.ARRAY_BUFFER,e.quadVbo),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,e.quadIbo),u!==void 0&&u>=0&&(l.enableVertexAttribArray(u),l.vertexAttribPointer(u,2,l.FLOAT,!1,16,0)),c!==void 0&&c>=0&&(l.enableVertexAttribArray(c),l.vertexAttribPointer(c,2,l.FLOAT,!1,16,8)),l.activeTexture(l.TEXTURE0),l.bindTexture(l.TEXTURE_2D,n);let d=t.uniform("u_source");d!==void 0&&l.uniform1i(d,0);let f=t.uniform("u_resolution");f!==void 0&&l.uniform2f(f,r,o);let p=t.uniform("u_texel");if(p!==void 0&&l.uniform2f(p,1/r,1/o),s){let h=t.uniform("u_alpha");h!==void 0&&l.uniform1f(h,s.alpha),Rn(e,t,s.colorMatrix)}i&&Tx(l,t,a??"effect",i,e.textureCache,{value:1}),Be(e,6,e.gl.UNSIGNED_SHORT),u!==void 0&&u>=0&&l.disableVertexAttribArray(u),c!==void 0&&c>=0&&l.disableVertexAttribArray(c),l.bindBuffer(l.ARRAY_BUFFER,null),l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,null)}function Xp(e,t,n,r,o){let i=e.gl,s=e.deviceWidth,a=e.deviceHeight,l=e.renderTarget??null,[u,c]=(l?l.fragOrigin:e.fragOrigin)??[0,0];i.viewport(u+r.x,c+a-r.y-r.height,r.width,r.height),mw(e,t,n,r.width,r.height,void 0,o),l?l.restore?l.restore():i.viewport(0,0,s,a):e.restoreTargetRect?.()}function Jp(e,t){let n=q.screenToClip(e.width/t,e.height/t);return q.toUniform(q.translated(n,-e.x/t,-e.y/t))}function Ju(e,t,n){return e.x>=0&&e.y>=0&&e.x+e.width<=t&&e.y+e.height<=n}var Qp=64;function nj(e,t,n,r,o,i,s){let a=e.effects&&e.effects.length>0?$s(e.effects):0;if(!Number.isFinite(a))return{x:0,y:0,width:r,height:o};if(Yn(e.composite)&&!EN(e.composite))return n;let l=Math.ceil(a),u={x:n.x-l,y:n.y-l,width:n.width+2*l,height:n.height+2*l},c=Xu([{...e,clip:void 0}],t,[],i),d=Hi(c,u);if(d.width===0||d.height===0)return null;let f=Math.min(s,Math.ceil(d.width/Qp)*Qp),p=Math.min(s,Math.ceil(d.height/Qp)*Qp),h=Ju(d,r,o);return{x:h&&f<=r?Math.min(d.x,r-f):d.x,y:h&&p<=o?Math.min(d.y,o-p):d.y,width:f,height:p}}function o2(e,t,n,r,o,i){let s=e.gl,a=e.renderTarget??null,l=r/e.widthCss,u=nj(t,e.state.transform,a?.window??{x:0,y:0,width:r,height:o},r,o,l,e.imageCache.maxTextureSide);if(!u)return;an(e);let c=e.clipDepth,d=e.clipStack,f=e.drawBatch.clip,p=e.projection,h=s.isEnabled(s.SCISSOR_TEST),m=n.acquire(u.width,u.height),y=e.state.pushIsolated({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix});e.clipDepth=0,e.clipStack=[],e.drawBatch.clip=null;let b=Ju(u,r,o);e.projection=b?void 0:Jp(u,l);let x=()=>{b?s.viewport(-u.x,u.y+u.height-o,r,o):s.viewport(0,0,u.width,u.height),s.disable(s.SCISSOR_TEST)};e.renderTarget={fbo:m.fbo,restore:x,fragOrigin:[-u.x,u.y+u.height-o],window:u},s.bindFramebuffer(s.FRAMEBUFFER,m.fbo),x(),s.stencilMask(255),s.clear(s.COLOR_BUFFER_BIT|s.STENCIL_BUFFER_BIT);for(let g of t.children)i(e,g);ye(e),s.disable(s.BLEND),s.disable(s.STENCIL_TEST);for(let g of t.effects??[]){let P=e.ensureProgram?.(g.program.id)??null;if(!P){Px(g.program.id,"(program)");continue}let S=n.acquire(u.width,u.height);s.bindFramebuffer(s.FRAMEBUFFER,S.fbo),s.viewport(0,0,u.width,u.height),s.clear(s.COLOR_BUFFER_BIT),mw(e,P,m.texture,u.width,u.height,g.uniforms,void 0,g.program.id),n.release(m),m=S}s.enable(s.BLEND),e.state.pop(),e.clipDepth=c,e.clipStack=d,e.drawBatch.clip=f,e.projection=p,e.renderTarget=a,sa(e,r,o,h);let w=e.ensureProgram?.(ip())??null;if(w){wt(e);let g=Yn(t.composite);g&&gx(s,t.composite),Xp(e,w,m.texture,u,y),g&&gx(s,"source-over")}n.release(m)}var rj=new WeakMap,oj=new WeakMap;function yw(e,t){let n=t?rj:oj,r=n.get(e);if(r!==void 0)return r;let o=e.every(i=>ij(i,t));return n.set(e,o),o}function ij(e,t){switch(e.kind){case"group":return e.effects&&e.effects.length>0&&!Number.isFinite($s(e.effects))?!1:yw(e.children,t);case"path":return Zp(e.fill?.paint,t)&&Zp(e.stroke?.paint,t);case"text":return e.runs.every(n=>Zp(n.fill?.paint,t,!0)&&Zp(n.stroke?.paint,t,!0));case"image":case"sprites":return!0;case"shader":return!1}}function Zp(e,t,n=!1){if(!e||e.kind===void 0||e.kind==="solid")return!0;if(n&&e.kind==="texture")return!1;let r="units"in e?e.units:void 0;return r==="local"||r==="world"&&t}var sj={alpha:1,colorMatrix:Vt},i2=new WeakSet;function s2(e,t,n,r){let o=e.retained,i=e.deviceWidth,s=e.deviceHeight;if(!o||!i||!s)return!1;if(e.renderTarget!=null&&i2.has(e.renderTarget)||Yn(t.composite)||yx(t.children))return o.decline(),!1;let l=t.retain;e.state.push({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix});let u=e.clipStack.map(({path:g,transform:P})=>({path:g,transform:P}));t.clip&&u.push({path:t.clip,transform:e.state.transform});let c={children:t.children,transform:e.state.transform,alpha:e.state.alpha,colorMatrix:e.state.colorMatrix,viewMatrix:e.viewMatrix,screenMatrix:e.screenMatrix,clips:u,effects:t.effects,isolate:t.isolate===!0,window:e.renderTarget?.window},d=!e.renderTarget,f=n?[{kind:"group",effects:t.effects,isolate:t.isolate,children:t.children}]:t.children,p=i/e.widthCss,h=d&&yw(f,e.viewMatrix!==void 0),m=o.lookup(l,i,s,c,d,h?p:void 0),y;if(m.kind==="through")return e.state.pop(),!1;if(m.kind==="kept")y=m.pixels;else{let g=c.window??m.window,P=Xu(f,e.state.transform,u,p),S=o.reserve(l,i,s,Hi(P,g),d,h?{box:P,window:g}:void 0);if(!S)return e.state.pop(),!1;ye(e),S.fbo&&aj(e,f,u,S.fbo,S,r),y=S.commit(c)}e.state.pop();let{texture:b,rect:x}=y;if(!b)return!0;ye(e);let w=e.ensureProgram?.(ip())??null;return w&&(wt(e,0),Xp(e,w,b,x,sj)),!0}function aj(e,t,n,r,o,i){let s=e.gl,a=e.deviceWidth,l=e.deviceHeight,{rect:u,tiles:c}=o,d=e.renderTarget??null,f=e.clipDepth,p=e.clipStack,h=e.drawBatch.clip,m=e.projection,y=s.isEnabled(s.SCISSOR_TEST),b=a/e.widthCss,x=Ju(u,a,l);e.projection=x?void 0:Jp(u,b);let w=c.length>1?t.map(g=>Xu([g],e.state.transform,[],b)):null;for(let g of c){let P=g.y+g.height,S=()=>{x?s.viewport(-g.x,P-l,a,l):s.viewport(u.x-g.x,P-u.y-u.height,u.width,u.height),s.scissor(0,0,g.width,g.height),s.enable(s.SCISSOR_TEST)},v={fbo:r,restore:S,fragOrigin:[-g.x,P-l],window:g};i2.add(v),e.renderTarget=v,e.clipDepth=0,e.clipStack=[],e.drawBatch.clip=null,s.bindFramebuffer(s.FRAMEBUFFER,r),S(),s.stencilMask(255),s.clear(s.COLOR_BUFFER_BIT|s.STENCIL_BUFFER_BIT);for(let A of n)Su(e,A.path,A.transform);for(let A=0;A<t.length;A++)(!w||lj(w[A],g))&&i(e,t[A]);ye(e),o.resolve(g)}e.clipDepth=f,e.clipStack=p,e.drawBatch.clip=h,e.projection=m,e.renderTarget=d,sa(e,a,l,y)}function lj(e,t){return e.x0<t.x+t.width&&e.x1>t.x&&e.y0<t.y+t.height&&e.y1>t.y}Pe();var aa=xt(),Zu=aa.reflection;function l2(e){if(e.inPoseFrame===void 0!=(e.toBoundsFrame===void 0)){let t=e.inPoseFrame===void 0?"inPoseFrame":"toBoundsFrame";throw new Error(`weasel registerPaintKind: kind "${e.id}" is missing ${t}. A kind that converts one frame direction and not the other drifts on the next resize; supply both or neither.`)}for(let[t,n]of Object.entries(e.programs??{})){let r=Nn(t);(!r||r.vert!==n.vert||r.frag!==n.frag)&&op(t,n.vert,n.frag)}return aa.push(e.id,e)}function Gi(e){let t=e??"solid",n=aa.get(t);return!n&&Qu.has(t)&&u2(t).catch(()=>{}),n}var Qu=new Map,a2=new Map;function u2(e){let t=a2.get(e);if(t)return t;let r=Qu.get(e)().then(o=>{if(o.id!==e)throw new Error(`weasel: the loader for paint kind "${e}" resolved to "${o.id}".`);aa.has(e)||l2(o)}).catch(o=>{throw console.error(`weasel: paint kind "${e}" failed to load:`,o),o});return a2.set(e,r),r}function gw(e){return aa.has(e)||Qu.has(e)}function bw(e){let t=e??[...Qu.keys()],n=[];for(let r of t)if(!aa.has(r)){if(!Qu.has(r))return Promise.reject(new Error(`weasel warmPaintKinds: "${r}" is neither registered nor loadable.`));n.push(u2(r))}return Promise.all(n).then(()=>{})}Pe();var xw=8,uj=1/8;function eh(e,t){if(!(e>0)||!(t>0)||!Number.isFinite(t))return t;let n=Math.ceil(Math.LN2/(2*Math.log1p(uj/e)));return 2**(Math.round(Math.log2(t)*n)/n)}var c2=new WeakMap;function cj(e,t,n){let r=at(e.width??1,1),o=Xs(e,r),i=n.ribbon?.metric;return[r,e.cap??"butt",e.join??"miter",e.miterLimit??"",e.align??"center",(e.dash??[]).join(","),e.varyingWidthJoinThreshold??"",e.nib?`${e.nib.angle}:${e.nib.ratio}`:"",t??"",o.start,o.end,Po(i),Po(n.start?.metric),Po(n.end?.metric),Tr(e.trim)].join("|")}function th(e,t,n,r={}){let o=c2.get(e);o===void 0&&(o=new Map,c2.set(e,o));let i=cj(t,n,r),s=o.get(i);if(s!==void 0&&s.vertexWidths===t.vertexWidths)return s.mesh;let a=at(t.width??1,1),l=Xs(t,a),u=Ei(e,t,{flattenTolerance:n,startInset:d2(l.start,r.start,r.ribbon),endInset:d2(l.end,r.end,r.ribbon),metric:r.ribbon?.metric});return s===void 0&&o.size>=xw&&o.clear(),o.set(i,{mesh:u,vertexWidths:t.vertexWidths}),u}function d2(e,t,n){return t?.metric===n?.metric?e:{length:e,metric:t?.metric??null}}var dj={};function ec(e,t,n={}){let r=n.quantize===!1?(m,y)=>y:eh,o=t.stroke,{markerStart:i,markerMid:s,markerEnd:a}=o;if(typeof o.width!="object"&&!la(i)&&!la(s)&&!la(a))return{cmd:t,spaces:dj};let l={...o},{scale:u,metric:c}=vu(e[0],e[1],e[3],e[4]),d=m=>c===null?void 0:{metric:c,pxPerUnit:m},f;if(typeof o.width=="object"){let m=r(o.width.px,u);l.width=at(o.width,m),o.dash&&m>0&&(l.dash=o.dash.map(y=>y/m)),f=d(m)}let p=m=>{if(m===void 0||typeof m=="string"||m.size===void 0)return f;if(typeof m.size!="number")return d(r(m.size.px,u))},h={ribbon:f,start:p(i),mid:p(s),end:p(a)};return la(i)&&(l.markerStart=ww(i,u,r)),la(s)&&(l.markerMid=ww(s,u,r)),la(a)&&(l.markerEnd=ww(a,u,r)),{cmd:{...t,stroke:l},spaces:h}}function la(e){return typeof e=="object"&&typeof e.size=="object"}function ww(e,t,n){return{...e,size:qs(e,0,n(e.size.px,t))}}Pe();Z();Pe();function f2(e,t){if(!hj(e))return Gi(e.kind)?.inPoseFrame?.(e,t)??e;if(fj(e)){let r=e.origin??{x:0,y:0};return{...e,origin:{x:t.x+r.x,y:t.y+r.y},units:"local"}}if(!pj(e))return e;let n=r=>({x:t.x+r.x*t.width,y:t.y+r.y*t.height});if(e.kind==="linear-gradient")return{...e,from:n(e.from),to:n(e.to),units:"local"};if(e.kind==="radial-gradient"){let r=Math.hypot(t.width,t.height)/Math.SQRT2;return{...e,center:n(e.center),radius:e.radius*r,units:"local"}}return{...e,center:n(e.center),units:"local"}}function fj(e){return Nf(e)&&e.units==="bounds"}function pj(e){if(e===void 0)return!1;let t=e.kind;return t!=="linear-gradient"&&t!=="radial-gradient"&&t!=="conic-gradient"?!1:e.units==="bounds"}function hj(e){let t=e.kind??"solid";return t==="solid"||Nf(e)||t==="linear-gradient"||t==="radial-gradient"||t==="conic-gradient"}Pe();function p2(e){let t;try{t=new OffscreenCanvas(e.size,e.size)}catch{if(typeof document>"u")return null;let r=document.createElement("canvas");r.width=e.size,r.height=e.size,t=r}let n=t.getContext("2d");return!n||(e.draw(n,e.size),typeof t.transferToImageBitmap!="function")?null:t.transferToImageBitmap()}var mj=4096*4096,yj=4,gj=300,bj=150,xj=256*1024*1024,Et=new Map,h2=xj,Tw=0,m2=0,wj=Ce(),nh=new Map;function Sw(e){return/^data:image\/svg\+xml[;,]/i.test(e)?!0:/^(data|blob):/i.test(e)?!1:/\.svgz?$/i.test(e.replace(/[?#].*$/,""))}function Pj(){if(typeof Image>"u"||typeof createImageBitmap>"u")throw new Error("weasel imageCache: no DOM image loader in this environment")}async function g2(e){let t=new Image;return t.crossOrigin="anonymous",t.src=e,await t.decode(),t}function Tj(e){let t=nh.get(e);return t||(t=g2(e),nh.set(e,t),t.catch(()=>nh.delete(e))),t}async function Sj(e,t){let n=await Tj(e),r=t?.width??(n.naturalWidth||gj),o=t?.height??(n.naturalHeight||bj),i=typeof OffscreenCanvas<"u"?new OffscreenCanvas(r,o):Object.assign(document.createElement("canvas"),{width:r,height:o}),s=i.getContext("2d");if(!s)throw new Error("weasel imageCache: no 2D context to rasterize an SVG");return s.drawImage(n,0,0,r,o),createImageBitmap(i)}var kj=async(e,t)=>(Pj(),Sw(e)?Sj(e,t):createImageBitmap(await g2(e))),b2=kj;function Pw(){wj.emit()}var y2=e=>e?e.width*e.height*4:0;function x2(e){let t=0;for(let n of Et.values())t+=y2(n.bitmap);if(t>h2){let n=[...Et].filter(([r,o])=>r!==e&&o.bitmap!==void 0&&o.readAt<=m2&&!LR(o.bitmap));n.sort((r,o)=>r[1].readAt-o[1].readAt);for(let[r,o]of n){if(t<=h2)break;t-=y2(o.bitmap),T2(r)}}m2=Tw}function vj(e){let t={status:"loading",readAt:++Tw};Et.set(e,t),b2(e).then(n=>{Et.get(e)===t&&(Et.set(e,{status:"ready",bitmap:n,readAt:t.readAt,...Sw(e)?{vector:{natural:{width:n.width,height:n.height},scale:1,failed:new Set,floor:0}}:{}}),x2(e),Pw())},()=>{Et.get(e)===t&&(Et.set(e,{status:"error",readAt:t.readAt}),Pw())})}function Aj(e,t){let n=Math.max(t.width/e.width,t.height/e.height);if(!(n>0)||!Number.isFinite(n))return;let r=_R(),o=Math.min(r/e.width,r/e.height,Math.sqrt(mj/(e.width*e.height)));return Math.min(2**Math.ceil(Math.log2(n)),o)}function Rj(e,t,n,r){if(n.pending!==void 0)return;let o=Aj(n.natural,r);if(o===void 0)return;let i=o>n.scale;i&&n.shrunkTo===n.scale&&(n.floor=Math.max(n.floor,o));let s=i?o:Math.max(o,n.floor);if(!i&&s*yj>n.scale)return;for(let l of n.failed)if(s===l||i&&l>n.scale&&s>=l)return;n.pending=s;let a={width:Math.max(1,Math.round(n.natural.width*s)),height:Math.max(1,Math.round(n.natural.height*s))};b2(e,a).then(l=>{if(Et.get(e)!==t)return;n.pending=void 0;let u=t.bitmap;t.bitmap=l,n.shrunkTo=i?void 0:s,n.scale=s,u&&u!==l&&vf(u),x2(e),Pw()},()=>{Et.get(e)===t&&(n.pending=void 0,n.failed.add(s))})}function ca(e,t){if(e.startsWith(w2))return ua.get(e)?.deref();let n=Et.get(e);if(!n){vj(e);return}return n.readAt=++Tw,t&&n.vector&&Rj(e,n,n.vector,t),n.bitmap}var w2="weasel-bitmap:",ua=new Map,Nj=new WeakMap;var Ij=new FinalizationRegistry(e=>{ua.get(e)?.deref()===void 0&&ua.delete(e)});function P2(e){let t=Et.get(e);if(t?.vector)return t.vector.natural;let n=t?.bitmap??ua.get(e)?.deref();return n?{width:n.width,height:n.height}:void 0}function kw(e){return e.startsWith(w2)?ca(e)===void 0?"idle":"ready":Et.get(e)?.status??"idle"}function T2(e){let t=ua.get(e)?.deref();ua.delete(e),t!==void 0&&(Nj.delete(t),Ij.unregister(t),vf(t));let n=Et.get(e);Et.delete(e),nh.delete(e),n?.bitmap&&vf(n.bitmap)}var vw="image:";function k2(e){return{id:vw+e.src}}function S2(e){let t=e.slice(vw.length),n=ca(t),r=xi.get(e)?.source;n!==r&&(n?Sf(e,n,P2(t)):kf({id:e}))}Tf(vw,{revive:S2,touched:S2});function Aw(e){if(e.size!==void 0)return e.size;switch(e.kind){case"hatch":return 5;case"crosshatch":return 6;case"dots":return 6;case"chunks":return 48;default:return 8}}function Ej(e){let t=e|0;return()=>{t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}function A2(e){let t=Aw(e),{color:n}=e;switch(e.kind){case"hatch":{let r=e.lineWidth??1;return{size:t,shapes:v2(t,r,n)}}case"crosshatch":{let r=e.lineWidth??.8;return{size:t,shapes:[...v2(t,r,n),...Mj(t,r,n)]}}case"dots":{let r=e.radius??1;return{size:t,shapes:[{kind:"circle",cx:t/2,cy:t/2,r,color:n}]}}case"chunks":{let r=e.density??.35,o=e.chunkSize??3,i=Ej(e.seed??42),s=Math.round(t*t*r/(o*o)),a=[];e.bg!==void 0&&a.push({kind:"rect",x:0,y:0,width:t,height:t,color:e.bg});for(let l=0;l<s;l++){let u=i()*t,c=i()*t,d=o*(.5+i()),f=o*(.5+i()),p=i()*Math.PI;a.push({kind:"ellipse",cx:u,cy:c,rx:d/2,ry:f/2,rotation:p,color:n})}return{size:t,shapes:a}}default:return{size:t,shapes:[]}}}function v2(e,t,n){return[{kind:"line",x1:-1,y1:e+1,x2:e+1,y2:-1,width:t,color:n},{kind:"line",x1:-1,y1:1,x2:1,y2:-1,width:t,color:n},{kind:"line",x1:e-1,y1:e+1,x2:e+1,y2:e-1,width:t,color:n}]}function Mj(e,t,n){return[{kind:"line",x1:-1,y1:-1,x2:e+1,y2:e+1,width:t,color:n},{kind:"line",x1:e-1,y1:-1,x2:e+1,y2:1,width:t,color:n},{kind:"line",x1:-1,y1:e-1,x2:1,y2:e+1,width:t,color:n}]}function R2(e,t){for(let n of t.shapes){if(n.kind==="line"){e.strokeStyle=n.color,e.lineWidth=n.width,e.beginPath(),e.moveTo(n.x1,n.y1),e.lineTo(n.x2,n.y2),e.stroke();continue}if(e.fillStyle=n.color,n.kind==="rect"){e.fillRect(n.x,n.y,n.width,n.height);continue}e.beginPath(),n.kind==="circle"?e.arc(n.cx,n.cy,n.r,0,Math.PI*2):e.ellipse(n.cx,n.cy,n.rx,n.ry,n.rotation,0,Math.PI*2),e.fill()}}var Cj=256,Rw="pattern:",Or=new Map;function Oj(e){let t=e,n={};for(let r of Object.keys(t).sort())n[r]=t[r];return Rw+JSON.stringify(n)}function Fj(e){let t=zb(e),n=Oj(t),r=Or.get(n);return r!==void 0?(N2(n),r):I2(n,t)}function N2(e){let t=Or.get(e);t!==void 0&&(Or.delete(e),Or.set(e,t))}function I2(e,t){let n=ou(t.kind)?p2({size:Aw(t),draw:o=>R2(o,A2(t))}):null,r=n?Sf(e,n):null;for(Or.delete(e),Or.set(e,r);Or.size>Cj;)Lj(Or.keys().next().value);return r}function Lj(e){Or.delete(e);let t=xi.get(e)?.source;kf({id:e}),t&&"close"in t&&t.close()}function _j(e){let t;try{t=JSON.parse(e.slice(Rw.length))}catch{return}typeof t!="object"||t===null||!("kind"in t)||I2(e,t)}Tf(Rw,{revive:_j,touched:N2});function E2(e){if(Vb(e)){let{width:n,height:r}=e;return{kind:"texture",texture:k2(e),...n!==void 0?{width:n}:{},...r!==void 0?{height:r}:{},...If(e)}}if(!Wb(e))return e;let t=Fj(e);return t?{kind:"texture",texture:t,...If(e)}:null}function Ui(e,t){return E2(f2(e,t))}function Kt(e,t){if(e.paint==null)return null;let n=Ui(e.paint,t);return n===null?null:n===e.paint?e:{...e,paint:n}}function Wi(e,t){if(e.paint==null)return null;let n=Ui(e.paint,t);return n===null?null:n===e.paint?e:{...e,paint:n}}function M2(e,t,n,r){let o=e??n;if(o!=="none")return o==="line"?t.paint:Ui(o,et(r))??void 0}function Nw(e,t){let n=[];for(let{entry:r,path:o,size:i,space:s}of e){let a=M2(r.fill,t,"line",o),l=r.outline?r.outline.width*i:0,u=r.outline?{paint:M2(r.outline.paint,t,"line",o),width:s?{px:l*s.pxPerUnit}:l}:null;a===void 0&&(u===null||u.paint===void 0)||n.push({kind:"path",path:o,...a?{fill:{paint:a}}:{},...u&&u.paint?{stroke:{paint:u.paint,width:u.width,cap:"round",join:"round"}}:{}})}return n}var C2=new WeakMap,O2=new WeakMap,Iw=e=>e===void 0?"":typeof e=="string"?e:`${e.key}@${String(e.size??"")}`;function Dj(e){let t="";for(let n of[e.markerStart,e.markerMid,e.markerEnd]){let r=n===void 0?void 0:To(Mi(n));if(r===void 0){t+="/";continue}let o=pp(r,e);if(o===null)return null;t+=`${o}/`}return t}function Bj(e,t,n){if(n!==null){let i=C2.get(e);return i===void 0&&C2.set(e,i=new Map),i}let r=O2.get(e);r===void 0&&O2.set(e,r=new WeakMap);let o=r.get(t);return o===void 0&&r.set(t,o=new Map),o}function F2(e,t,n,r,o,i={}){if(n.markerStart===void 0&&n.markerMid===void 0&&n.markerEnd===void 0)return[];let s=Dj(n),a=Bj(e,t,s),l=[r,o??"",Eu(),Iw(n.markerStart),Iw(n.markerMid),Iw(n.markerEnd),s??"",ku(i.start),ku(i.mid),ku(i.end),Tr(n.trim)].join("|"),u=a.get(l);if(u===void 0){let c=Mu(e,n,r,o,i);u={heads:c,paint:n.paint,cmds:Nw(c,n)},a.size>=xw&&a.clear(),a.set(l,u)}else u.paint!==n.paint&&(u.paint=n.paint,u.cmds=Nw(u.heads,n));return u.cmds}Z();var L2=new WeakMap;function Ew(e,t,n){let r=L2.get(e);r===void 0&&(r=new WeakMap,L2.set(e,r));let o=r.get(t);return o===void 0&&(o=Hl(e,t,n),r.set(t,o)),o}function _2(e){if(e.path.kind!=="polygon")return e;let{path:t,anchorSources:n}=ho(e.path);if(t===e.path)return e;let r={...e,path:t};if(n&&e.vertexColors&&(r.vertexColors=Ew(e.vertexColors,n,4)),n&&e.stroke&&(e.stroke.vertexColors||e.stroke.vertexWidths)){let{vertexColors:o,vertexWidths:i}=e.stroke;r.stroke={...e.stroke,...o?{vertexColors:Ew(o,n,4)}:{},...i?{vertexWidths:Ew(i,n,1)}:{}}}return r}var Hj=65536;function B2(e,t,n,r=Hj){let o=Vj(t,e.origin),i={verts:[],idx:[]},s={left:r},a=new Int32Array(o.count),l=[],u=e.vertices,c=e.indices,d=new Float32Array(6);for(let f=0;f<c.length;f+=3){for(let h=0;h<3;h++)d[h*2]=u[c[f+h]*2],d[h*2+1]=u[c[f+h]*2+1];if(Wj(o,d,f/3+1,a,l),!(n?Gj(d,o,l,i,s):Uj(d,o,l,i,s)))return null}return{vertices:new Float32Array(i.verts),indices:new Uint32Array(i.idx),...e.origin?{origin:e.origin}:{}}}function Gj(e,t,n,r,o){for(let i of n){if(--o.left<0)return!1;let s=H2(e,3,t.planes,i);if(s===Ow)continue;if(s===0)return Cw(e,3,r),!0;let a=e,l=3;for(let u=0;u<3&&l>=3;u++)if((s&1<<u)!==0){if(--o.left<0)return!1;[a,l]=Mw(a,l,t.planes,(i*3+u)*3,1)}Cw(a,l,r)}return!0}function Uj(e,t,n,r,o){let i=[[e,3]];for(let s of n){let a=[];for(let[l,u]of i){if(--o.left<0)return!1;let c=H2(l,u,t.planes,s);if(c===Ow){a.push([l,u]);continue}let d=l,f=u;for(let p=0;p<3&&f>=3;p++){if((c&1<<p)===0)continue;if(o.left-=2,o.left<0)return!1;let h=(s*3+p)*3,[m,y]=Mw(d,f,t.planes,h,-1);y>=3&&a.push([m,y]),[d,f]=Mw(d,f,t.planes,h,1)}}if(i=a,i.length===0)return!0}for(let[s,a]of i)Cw(s,a,r);return!0}var Ow=-1;function H2(e,t,n,r){let o=0;for(let i=0;i<3;i++){let s=(r*3+i)*3,a=0;for(let l=0;l<t;l++)n[s]*e[l*2]+n[s+1]*e[l*2+1]+n[s+2]>=0&&a++;if(a===0)return Ow;a<t&&(o|=1<<i)}return o}var rh={buf:new Float32Array(16)};function Mw(e,t,n,r,o){rh.buf.length<(t+1)*2&&(rh.buf=new Float32Array((t+1)*4));let i=bu(e,t,2,o*n[r],o*n[r+1],o*n[r+2],rh.buf);return[rh.buf.slice(0,i*2),i]}function Cw(e,t,n){if(t<3)return;let r=n.verts.length/2;for(let o=0;o<t*2;o++)n.verts.push(e[o]);for(let o=1;o<t-1;o++)n.idx.push(r,r+o,r+o+1)}function Wj(e,t,n,r,o){o.length=0;let i=Math.min(t[0],t[2],t[4]),s=Math.max(t[0],t[2],t[4]),a=Math.min(t[1],t[3],t[5]),l=Math.max(t[1],t[3],t[5]),u=e.grid,c=Math.max(0,Math.floor((i-u.x0)/u.cell)),d=Math.min(u.cols-1,Math.floor((s-u.x0)/u.cell)),f=Math.max(0,Math.floor((a-u.y0)/u.cell)),p=Math.min(u.rows-1,Math.floor((l-u.y0)/u.cell)),h=e.boxes;for(let m=f;m<=p;m++)for(let y=c;y<=d;y++)for(let b of u.cells[m*u.cols+y])r[b]!==n&&(r[b]=n,!(h[b*4]>s||h[b*4+2]<i||h[b*4+1]>l||h[b*4+3]<a)&&o.push(b))}var D2=new WeakMap;function Vj(e,t){let n=D2.get(e);if(n!==void 0&&n.origin===t)return n.tris;let r=zj(e,t);return D2.set(e,{origin:t,tris:r}),r}function zj(e,t){let n=(e.origin?.x??0)-(t?.x??0),r=(e.origin?.y??0)-(t?.y??0),o=e.vertices,i=e.indices,s=[],a=[],l=new Float64Array(6);for(let c=0;c<i.length;c+=3){for(let p=0;p<3;p++)l[p*2]=o[i[c+p]*2]+n,l[p*2+1]=o[i[c+p]*2+1]+r;let d=(l[2]-l[0])*(l[5]-l[1])-(l[4]-l[0])*(l[3]-l[1]);if(d===0)continue;let f=d>0?[0,1,2]:[0,2,1];for(let p=0;p<3;p++)Kj(l,f[p],f[(p+1)%3],s);a.push(Math.min(l[0],l[2],l[4]),Math.min(l[1],l[3],l[5]),Math.max(l[0],l[2],l[4]),Math.max(l[1],l[3],l[5]))}let u=a.length/4;return{planes:new Float64Array(s),boxes:new Float64Array(a),count:u,grid:jj(a,u)}}function Kj(e,t,n,r){let o=e[n*2]<e[t*2]||e[n*2]===e[t*2]&&e[n*2+1]<e[t*2+1],[i,s]=o?[n,t]:[t,n],a=e[i*2],l=e[i*2+1],u=e[s*2],c=e[s*2+1],d=Math.hypot(u-a,c-l),f=-(c-l)/d,p=(u-a)/d,h=-(f*a+p*l),m=o?-1:1;r.push(m*f,m*p,m*h)}function jj(e,t){let n=1/0,r=1/0,o=-1/0,i=-1/0;for(let d=0;d<t;d++)n=Math.min(n,e[d*4]),r=Math.min(r,e[d*4+1]),o=Math.max(o,e[d*4+2]),i=Math.max(i,e[d*4+3]);if(t===0)return{x0:0,y0:0,cell:1,cols:1,rows:1,cells:[[]]};let s=Math.min(64,Math.max(1,Math.ceil(Math.sqrt(t)))),a=Math.max(o-n,i-r,1e-6)/s,l=Math.max(1,Math.ceil((o-n)/a)),u=Math.max(1,Math.ceil((i-r)/a)),c=Array.from({length:l*u},()=>[]);for(let d=0;d<t;d++){let f=Math.min(l-1,Math.floor((e[d*4]-n)/a)),p=Math.min(l-1,Math.floor((e[d*4+2]-n)/a)),h=Math.min(u-1,Math.floor((e[d*4+1]-r)/a)),m=Math.min(u-1,Math.floor((e[d*4+3]-r)/a));for(let y=h;y<=m;y++)for(let b=f;b<=p;b++)c[y*l+b].push(d)}return{x0:n,y0:r,cell:a,cols:l,rows:u,cells:c}}var $j=512,G2=new WeakMap;function W2(e,t,n){let r=G2.get(e);if(r!==void 0&&r.fill===t&&r.inner===n)return r.mesh;let o=t.requiresStencil?null:Yj(e,t,n);return G2.set(e,{fill:t,inner:n,mesh:o}),o}function Yj(e,t,n){let r=qj(t,e.origin);return r===null?B2(e,t,n):Xj(e,r,n)}function qj(e,t){let n=e.vertices,r=(e.origin?.x??0)-(t?.x??0),o=(e.origin?.y??0)-(t?.y??0),i=[];for(let a=0;a<n.length;a+=2){let l=i.length,u=n[a]+r,c=n[a+1]+o;l>=2&&i[l-2]===u&&i[l-1]===c||i.push(u,c)}for(;i.length>=4&&i[0]===i[i.length-2]&&i[1]===i[i.length-1];)i.length-=2;let s=i.length/2;return s<3||e.indices.length!==(s-2)*3?null:kx(i,$j)}var Fr={a:new Float32Array(0),b:new Float32Array(0)};function Xj(e,t,n){let r=t.length/3;Fr.a.length<(r+4)*2&&(Fr.a=new Float32Array((r+4)*2),Fr.b=new Float32Array((r+4)*2));let o=e.vertices,i=e.indices,s=[],a=[],l=[],u=new Float32Array(6);for(let c=0;c<i.length;c+=3){for(let f=0;f<3;f++)u[f*2]=o[i[c+f]*2],u[f*2+1]=o[i[c+f]*2+1];l.length=0;let d=!1;for(let f=0;f<t.length&&!d;f+=3){let p=0;for(let h=0;h<3;h++)t[f]*u[h*2]+t[f+1]*u[h*2+1]+t[f+2]>=0&&p++;p===0?d=!0:p<3&&l.push(f)}if(d){n||Fw(u,3,s,a);continue}if(n)Fw(Fr.a,U2(u,l,l.length,t,-1),s,a);else for(let f=0;f<l.length;f++)Fw(Fr.a,U2(u,l,f,t,l[f]),s,a)}return{vertices:new Float32Array(s),indices:new Uint32Array(a),...e.origin?{origin:e.origin}:{}}}function U2(e,t,n,r,o){let i=Fr.a,s=Fr.b;i.set(e);let a=3;for(let l=0;l<=n&&a>=3&&!(l===n&&o<0);l++){let u=l===n?o:t[l],c=l===n?-1:1;a=bu(i,a,2,c*r[u],c*r[u+1],c*r[u+2],s);let d=i;i=s,s=d}return i!==Fr.a&&Fr.a.set(i.subarray(0,a*2)),a}function Fw(e,t,n,r){if(t<3)return;let o=n.length/2;for(let i=0;i<t*2;i++)n.push(e[i]);for(let i=1;i<t-1;i++)r.push(o,o+i,o+i+1)}Pe();function Lw(e,t,n,r){for(let o=0;o<e.textures.length;o++){let i=e.textures[o];if(!(i.kind!=="bitmap"||i.image!==t))return i.sampling===n&&i.mips===r?o+1:-1}return Dw(e)}function _w(e){return e.ramps?Cs:Dw(e)<0?-1:Cs}function Lr(e,t){for(let n=0;n<e.textures.length;n++){let r=e.textures[n];if(r.kind==="atlas"&&r.id===t)return n+1}return Dw(e)}function Dw(e){return e.textures.length+(e.ramps?1:0)+1<yt?e.textures.length+1:-1}function Io(e,t,n,r){return t.clipDepth===Ox(e)&&Nx(t.matrices,n,r)>=0&&Jj(t,np(e))}function Jj(e,t){return t===null||V2(e,t)!==void 0?!0:e.hullPlanes+t.count<=Ms}function V2(e,t){let n=e.hulls;if(n!==void 0){for(let r=0;r<n.length;r++)if(n[r].set===t)return n[r]}}function Eo(e){return e.batchState??={clipDepth:Ox(e),matrices:[],textures:[],ramps:!1,hullPlanes:0,areaGlyphs:!1},e.batchState}function Mo(e,t,n){let r=np(e);if(r===null)return n;let o=V2(t,r);return o===void 0&&(o={set:r,start:t.hullPlanes},(t.hulls??=[]).push(o),t.hullPlanes+=r.count),oR(n,o.start,r.count)}function Co(e,t,n){let r=Nx(e.matrices,t,n);return r===e.matrices.length&&e.matrices.push({colorMatrix:t,alpha:n}),r}Z();Z();Z();function oh(e,t,n){let r=n??Qj,o=hr([r[0],r[1],r[2],r[3],t.x,t.y]);if(!o)return null;let i=e;return q.fromAffine([o[0]*i[0]+o[2]*i[1],o[1]*i[0]+o[3]*i[1],o[0]*i[3]+o[2]*i[4],o[1]*i[3]+o[3]*i[4],o[0]*i[6]+o[2]*i[7]+o[4],o[1]*i[6]+o[3]*i[7]+o[5]])}var Qj=[1,0,0,1];var Zj=[0,0];function z2(e,t){let n=_s(t.texture.id);if(!n)return;let r=Vi(e,t.units),o=r&&oh(r,t.origin??{x:0,y:0},t.transform);if(!o)return null;let i=q.multiply(o,e.state.transform),[s,a]=Bw(t,n);return{kind:"pattern",id:t.texture.id,source:n.source,opacity:t.opacity??1,uv:{ux:i[0]/s,uy:i[3]/s,u0:i[6]/s,vx:i[1]/a,vy:i[4]/a,v0:i[7]/a}}}function Bw(e,{source:t,size:n}){let r=e.width??n?.width??("naturalWidth"in t?t.naturalWidth:t.width),o=e.height??n?.height??("naturalHeight"in t?t.naturalHeight:t.height);return[r>0?r:1,o>0?o:1]}function K2(e,t,n){let r=Ks(e,!1),o=e.batchState;o!==void 0&&(!Io(e,o,r.colorMatrix,r.alpha)||Lr(o,t.id)<0||Lr(o,t.id)<=o.textures.length&&e.textureCache.replaces(t.id,t.source))&&ye(e),e.drawBatch.wouldOverflow(n)&&ye(e),e.textureCache.uploadRegistered(t.id,t.source,"repeat");let i=Eo(e),s=Lr(i,t.id);return s>i.textures.length&&(i.textures.push({kind:"atlas",id:t.id,fieldScale:Zj}),s=i.textures.length),r.slot=Mo(e,i,go(s,Co(i,r.colorMatrix,r.alpha))),r}function j2(e,t,n){return{...e,u0:e.u0-Math.floor(e.ux*t+e.uy*n+e.u0),v0:e.v0-Math.floor(e.vx*t+e.vy*n+e.v0)}}function Hw(e,t,n){let{slot:r,tint:o}=K2(e,n,4);e.drawBatch.pushGradientRect(t.x,t.y,t.width,t.height,e.state.transform,j2(n.uv,t.x,t.y),n.opacity*o[3],r,Os,o[0],o[1],o[2],1)||sn(e,t,n,Hw)}function Gw(e,t,n){let{slot:r,tint:o}=K2(e,n,t.vertices.length>>1),i=t.vertices.length>0?{x:t.vertices[0]+(t.origin?.x??0),y:t.vertices[1]+(t.origin?.y??0)}:{x:0,y:0};e.drawBatch.pushGradientMesh(t,e.state.transform,j2(n.uv,i.x,i.y),n.opacity*o[3],r,Os,o[0],o[1],o[2],1)||sn(e,t,n,Gw)}function tc(e,t,n){if(n)return;let r=t.kind??"solid";if(r==="solid"){let s=t;return{kind:"solid",color:s.color,opacity:s.opacity}}if(r==="texture")return z2(e,t);if(r!=="linear-gradient"&&r!=="radial-gradient"&&r!=="conic-gradient")return;let o=t,i=e$(e,o.units);return i?o.kind==="linear-gradient"?Uw(o,yi,t$(i,o)):o.kind==="radial-gradient"?Uw(o,rR,n$(i,o)):Uw(o,hf,r$(i,o)):null}function Uw(e,t,n){return{kind:"ramp",stops:e.stops,space:e.interpolate??"rgb",opacity:e.opacity,mode:t,uv:n}}function e$(e,t){let n=Vi(e,t);return n&&q.multiply(n,e.state.transform)}function t$(e,t){let n=t.to.x-t.from.x,r=t.to.y-t.from.y,o=Math.hypot(n,r)||1,i=1/(o*o);return{ux:(e[0]*n+e[1]*r)*i,uy:(e[3]*n+e[4]*r)*i,u0:((e[6]-t.from.x)*n+(e[7]-t.from.y)*r)*i,vx:0,vy:0,v0:0}}function n$(e,t){let n=1/Math.max(t.radius,1e-4);return{ux:e[0]*n,uy:e[3]*n,u0:(e[6]-t.center.x)*n,vx:e[1]*n,vy:e[4]*n,v0:(e[7]-t.center.y)*n}}function r$(e,t){let n=Math.cos(t.angle),r=Math.sin(t.angle),o=e[6]-t.center.x,i=e[7]-t.center.y;return{ux:n*e[0]+r*e[1],uy:n*e[3]+r*e[4],u0:n*o+r*i,vx:n*e[1]-r*e[0],vy:n*e[4]-r*e[3],v0:n*i-r*o}}function Ww(e,t){return e.mode===yi?{uv:{...e.uv,v0:t},post:1}:{uv:e.uv,post:t}}function Vi(e,t){return t==="local"?q.invert(e.state.transform):t==="world"&&e.viewMatrix?q.invert(e.viewMatrix):e.screenMatrix?q.invert(e.screenMatrix):q.identity()}function Vw(e,t,n){let r=Vi(e,t);return!r||!n||n.x===0&&n.y===0?r:q.multiply(q.translated(q.identity(),-n.x,-n.y),r)}function $2(e,t){let n=Vi(e,t),r=n&&q.invert(n);if(!r)return null;let o=e.deviceWidth&&e.widthCss>0?e.deviceWidth/e.widthCss:1;return q.multiply(q.scaled(q.identity(),o,o),r)}var o$=96,i$=1024,Y2={maxVertices:o$,maxVerticesInRun:i$};function zw(e,t){if(t.requiresStencil)return!1;let n=e.drawBatch.length>0?Y2.maxVerticesInRun:Y2.maxVertices;return t.vertices.length>>1<=n}function ih(e,t){let n=Pu(e);return sh(e,t,n?Vt:e.state.colorMatrix,n?1:e.state.alpha)}function sh(e,t,n,r){let o=e.batchState;o!==void 0&&!Io(e,o,n,r)&&ye(e),e.drawBatch.wouldOverflow(t)&&ye(e);let i=Eo(e),s=Co(i,n,r);return gi(Mo(e,i,go(eR,s)),yi)}function Kw(e,t,n,r){let o=Ks(e,!1),i=e.batchState;i!==void 0&&(!Io(e,i,o.colorMatrix,o.alpha)||Lw(i,t,n,r)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let s=Eo(e),a=Lw(s,t,n,r);return a>s.textures.length&&(s.textures.push({kind:"bitmap",image:t,sampling:n,mips:r}),a=s.textures.length),o.slot=Mo(e,s,go(a,Co(s,o.colorMatrix,o.alpha))),o}function nc(e,t,n,r){let o=Pu(e),i=o?Vt:e.state.colorMatrix,s=o?1:e.state.alpha,a=e.batchState;a!==void 0&&(!Io(e,a,i,s)||Lr(a,t)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let l=Eo(e),u=Lr(l,t);return u>l.textures.length&&(l.textures.push({kind:"atlas",id:t,fieldScale:n}),u=l.textures.length),r&&(l.areaGlyphs=!0),Mo(e,l,go(u,Co(l,i,s)))}function q2(e,t,n,r){e.gradRamps.wouldReshape(t,n)&&ye(e);let o=Ks(e,!0),i=e.batchState;i!==void 0&&(!Io(e,i,o.colorMatrix,o.alpha)||_w(i)<0)&&ye(e),e.drawBatch.wouldOverflow(r)&&ye(e);let s=Eo(e),a=_w(s);return s.ramps=!0,{slot:Mo(e,s,go(a,Co(s,o.colorMatrix,o.alpha))),tint:o.tint,rowV:e.gradRamps.rowV(e.gradRamps.upload(t,n))}}function da(e){let[t,n,r,o]=$n(e.color);return[t,n,r,o*(e.opacity??1)]}var s$=[0,0,0,0];function X2(e,t){let n=$n(t.color);return tp(e,n[0],n[1],n[2],n[3]*(t.opacity??1),s$)}function jw(e,t,n){let r=ih(e,4);e.drawBatch.pushRect(t.x,t.y,t.width,t.height,e.state.transform,X2(e,n),r)||sn(e,t,n,jw)}function J2(e,t,n){let r=ih(e,t.vertices.length>>1),[o,i,s,a]=X2(e,n);e.drawBatch.pushMesh(t,e.state.transform,o,i,s,a,r)||sn(e,t,n,J2)}function $w(e,t,n){let{slot:r,tint:o,rowV:i}=q2(e,n.stops,n.space,4),{uv:s,post:a}=Ww(n,i);e.drawBatch.pushGradientRect(t.x,t.y,t.width,t.height,e.state.transform,s,a,r,n.mode,o[0],o[1],o[2],(n.opacity??1)*o[3])||sn(e,t,n,$w)}function Q2(e,t,n){let{slot:r,tint:o,rowV:i}=q2(e,n.stops,n.space,t.vertices.length>>1),{uv:s,post:a}=Ww(n,i);e.drawBatch.pushGradientMesh(t,e.state.transform,s,a,r,n.mode,o[0],o[1],o[2],(n.opacity??1)*o[3])||sn(e,t,n,Q2)}function rc(e,t,n){return n!==void 0&&zw(e,t)?(n.kind==="ramp"?Q2(e,t,n):n.kind==="pattern"?Gw(e,t,n):J2(e,t,n),!0):(an(e),!1)}var a$=[0,0];function Yw(e,t){let n=Ks(e,!1),r=e.batchState;r!==void 0&&(!Io(e,r,n.colorMatrix,n.alpha)||Lr(r,t)<0)&&ye(e),e.drawBatch.wouldOverflow(4)&&ye(e);let o=Eo(e),i=Lr(o,t);return i>o.textures.length&&(o.textures.push({kind:"atlas",id:t,fieldScale:a$}),i=o.textures.length),n.slot=Mo(e,o,go(i,Co(o,n.colorMatrix,n.alpha))),n}Z();function ah(e){let t=Z2.get(e);if(t)return t;let n={gl:e.gl,get alpha(){return e.state.alpha},program:r=>e.ensureProgram?.(r)??e.programRegistry.get(r)??null,setProjAndModel:r=>nt(e,r),spaceInverse:(r,o)=>Vw(e,r,o),spaceToDevice:r=>$2(e,r),get maxTextureSize(){return e.imageCache.maxTextureSide},resources:e.paintResources??l$(e.gl),bindRamp:(r,o,i)=>{let s=e.gradRamps.upload(r,i);return e.gradRamps.bind(o),e.gradRamps.rowV(s)}};return Z2.set(e,n),n}var Z2=new WeakMap,eC=new WeakMap;function l$(e){let t=eC.get(e);return t||(t=cl(),eC.set(e,t)),t}function lh(e,t,n,r){let o=n.texture,i=_s(o.id);if(!i)return en()&&!CR(o.id)&&console.warn(`weasel: pattern TextureHandle "${o.id}" not registered`),null;let s=Vi(e,n.units);if(!s)return null;let a=oh(s,n.origin??{x:0,y:0},n.transform);if(!a)return null;e.textureCache.uploadRegistered(o.id,i.source,"repeat");let l=e.gl;l.useProgram(t.handle),nt(e,t,r),Rn(e,t);let[u,c]=Bw(n,i);return a[6]-=Math.floor(a[6]/u)*u,a[7]-=Math.floor(a[7]/c)*c,l.uniformMatrix3fv(t.uniform("u_worldInv"),!1,q.toUniform(a)),l.uniform2f(t.uniform("u_tileSize"),u,c),e.textureCache.bind(o.id,0),l.uniform1i(t.uniform("u_sampler"),0),l.uniform1f(t.uniform("u_opacity"),n.opacity??1),qf(e,t,e.state.alpha),t}function uh(e,t,n,r){let o=Vw(e,n.units,n.kind==="linear-gradient"?n.from:n.center);if(!o)return null;let i=e.gl,s=e.gradRamps.upload(n.stops,n.interpolate??"rgb");if(i.useProgram(t.handle),nt(e,t,r),i.uniformMatrix3fv(t.uniform("u_worldInv"),!1,q.toUniform(o)),Rn(e,t),e.gradRamps.bind(0),i.uniform1i(t.uniform("u_ramp"),0),i.uniform1f(t.uniform("u_rampV"),e.gradRamps.rowV(s)),qf(e,t,e.state.alpha),i.uniform1f(t.uniform("u_opacity"),n.opacity??1),n.kind==="linear-gradient"){i.uniform1i(t.uniform("u_gradKind"),0);let a=n.to.x-n.from.x,l=n.to.y-n.from.y,u=Math.hypot(a,l)||1;i.uniform2f(t.uniform("u_gradDir"),a/u,l/u),i.uniform1f(t.uniform("u_gradLen"),u),i.uniform1f(t.uniform("u_gradRadius"),0),i.uniform1f(t.uniform("u_gradAngle"),0)}else n.kind==="radial-gradient"?(i.uniform1i(t.uniform("u_gradKind"),1),i.uniform2f(t.uniform("u_gradDir"),0,0),i.uniform1f(t.uniform("u_gradLen"),0),i.uniform1f(t.uniform("u_gradRadius"),n.radius),i.uniform1f(t.uniform("u_gradAngle"),0)):(i.uniform1i(t.uniform("u_gradKind"),2),i.uniform2f(t.uniform("u_gradDir"),0,0),i.uniform1f(t.uniform("u_gradLen"),0),i.uniform1f(t.uniform("u_gradRadius"),0),i.uniform1f(t.uniform("u_gradAngle"),n.angle));return t}function tC(e,t,n){let r=t.anchorA,o=t.anchorB,i=t.anchorT;if(!r||!o||!i){if(n===void 0)return Float32Array.from(e);let l=Math.min(n.length,e.length);for(let u=0;u<l;u++)n[u]=e[u];return n}let s=r.length,a=n??new Float32Array(s*4);for(let l=0;l<s;l++){let u=r[l]*4,c=o[l]*4,d=i[l];for(let f=0;f<4;f++)a[l*4+f]=e[u+f]+(e[c+f]-e[u+f])*d}return a}function dh(e,t,n,r){let o=e.createBuffer();if(!o)throw new Error("attachVertexColors: createBuffer returned null");e.bindBuffer(e.ARRAY_BUFFER,o),e.bufferData(e.ARRAY_BUFFER,tC(n,r),e.DYNAMIC_DRAW);let i=t.attribute("a_vertexColor");return i!==void 0&&(e.enableVertexAttribArray(i),e.vertexAttribPointer(i,4,e.FLOAT,!1,0,0)),{vbo:o,location:i}}function fh(e,{vbo:t,location:n}){n!==void 0&&e.disableVertexAttribArray(n),e.deleteBuffer(t)}var ch=new Float32Array(256);function u$(e,t,n,r){for(let s=0;s<n*4;s++)t[s]*=r[s&3];if(!Pu(e))return!1;let o=e.state.colorMatrix,i=e.state.alpha;for(let s=0;s<n*4;s+=4){let a=t[s],l=t[s+1],u=t[s+2],c=t[s+3];for(let d=0;d<4;d++){let f=d*5,p=o[f]*a+o[f+1]*l+o[f+2]*u+o[f+3]*c+o[f+4];if(!(p>=0&&p<=1))return!1}}for(let s=0;s<n*4;s+=4){let a=t[s],l=t[s+1],u=t[s+2],c=t[s+3];t[s]=o[0]*a+o[1]*l+o[2]*u+o[3]*c+o[4],t[s+1]=o[5]*a+o[6]*l+o[7]*u+o[8]*c+o[9],t[s+2]=o[10]*a+o[11]*l+o[12]*u+o[13]*c+o[14],t[s+3]=(o[15]*a+o[16]*l+o[17]*u+o[18]*c+o[19])*i}return!0}function ph(e){return e.kind===void 0||e.kind==="solid"?e:{color:"#ffffff",opacity:e.opacity}}function nC(e,t,n){let r=t.vertices.length>>1;ch.length<r*4&&(ch=new Float32Array(Math.max(r*4,ch.length*2)));let o=tC(n.perAnchor,t,ch),s=u$(e,o,r,da(n.paint))?sh(e,r,Vt,1):sh(e,r,e.state.colorMatrix,e.state.alpha);e.drawBatch.pushMesh(t,e.state.transform,1,1,1,1,s,o)||sn(e,t,n,nC)}function qw(e,t,n,r){let o=t.vertices.length>>1;return(t.anchorA!==void 0||n.length>=o*4)&&zw(e,t)?(nC(e,t,{perAnchor:n,paint:r}),!0):(an(e),!1)}function Xw(e,t){let n=_2(t);n.fill?.paint&&c$(e,n,n.fill.paint),n.stroke?.paint&&y$(e,n)}function c$(e,t,n){let r=n.kind===void 0||n.kind==="solid",o=!!(t.vertexColors&&t.vertexColors.length>0),i=n,s=tc(e,n,o);if(s===null)return;if(s!==void 0&&t.path.kind==="rect"){s.kind==="ramp"?$w(e,t.path,s):s.kind==="pattern"?Hw(e,t.path,s):jw(e,t.path,s);return}let a=Zf(e,t.path);if(r&&o?qw(e,a,t.vertexColors,i):rc(e,a,s))return;let u=Ax(e,a);Jf(e,a.origin,()=>{r&&o?d$(e,t,i,u):u.requiresStencil?m$(e,n,u):hh(e,n,u)})}function d$(e,t,n,r){let o=e.gl,i=e.pathFillVColor;o.useProgram(i.handle),o.bindVertexArray(r.vao),nt(e,i),Vs(e,i,n.color,n.opacity),Rn(e,i);let s=dh(o,i,t.vertexColors,r);r.requiresStencil?(bx(e,r.indexCount),Be(e,r.indexCount,e.gl.UNSIGNED_INT),xx(e)):(wt(e),Be(e,r.indexCount,e.gl.UNSIGNED_INT)),fh(o,s),o.bindVertexArray(null)}function Jw(e,t){let n=t.kind??"solid";if(n==="solid")return f$(e,t);if(n==="texture")return p$(e,t);if(n==="linear-gradient"||n==="radial-gradient"||n==="conic-gradient")return h$(e,t);let r=Gi(n)?.bind;return r?r(ah(e),t):null}function hh(e,t,n){if(!Jw(e,t))return;let o=e.gl;o.bindVertexArray(n.vao),wt(e),Be(e,n.indexCount,e.gl.UNSIGNED_INT),o.bindVertexArray(null)}function f$(e,t){let n=e.pathFill;return e.gl.useProgram(n.handle),nt(e,n),Vs(e,n,t.color,t.opacity),Rn(e,n),n}function p$(e,t){return lh(e,e.patternFill,t,Xf(e))}function h$(e,t){return uh(e,e.gradFill,t,Xf(e))}function m$(e,t,n){let r=e.gl;r.useProgram(e.pathFill.handle),r.bindVertexArray(n.vao),nt(e,e.pathFill),bx(e,n.indexCount),Jw(e,t)&&Be(e,n.indexCount,e.gl.UNSIGNED_INT),xx(e),r.bindVertexArray(null)}function y$(e,t){let{cmd:n,spaces:r}=ec(e.state.transform,t),o=n.stroke,i=o.align??"center",s=r.ribbon?.metric,a=n.path.kind==="polygon"||s!==void 0&&!up(s),l=a&&i!=="center"?b$(e,n,i,r):null;l!==null?oC(e,n,l):a&&i!=="center"?(an(e),Jf(e,n.path.kind==="polygon"?n.path.origin:void 0,()=>P$(e,n,i,r))):g$(e,n,r);let u=at(o.width??1,1),c=F2(n.path,t.stroke,o,u,zs(e),r);for(let d of c)Xw(e,d)}function g$(e,t,n){oC(e,t,th(t.path,t.stroke,zs(e),n))}function b$(e,t,n,r){if(t.stroke.vertexColors&&t.stroke.vertexColors.length>0||e.batchVariants?.cuts===!1)return null;let o=th(t.path,iC(t.stroke),zs(e),r);return W2(o,Zf(e,t.path),n==="inner")}function oC(e,t,n){let r=t.stroke,o=r.paint;if(n.indices.length===0)return;let i=!!(r.vertexColors&&r.vertexColors.length>0),s=tc(e,o,i);s===null||(i?qw(e,n,r.vertexColors,ph(o)):rc(e,n,s))||Jf(e,n.origin,()=>x$(e,r,n,i))}function x$(e,t,n,r){let o=t.paint,i=o.kind===void 0||o.kind==="solid",s=o,a=r?e.meshCache.uploadTransient(n):e.meshCache.uploadRecurring(n);if(!i&&!r){hh(e,o,a);return}let l=e.gl;if(r){let u=e.pathFillVColor;l.useProgram(u.handle),l.bindVertexArray(a.vao),nt(e,u);let c=ph(o);Vs(e,u,c.color,c.opacity),Rn(e,u);let d=dh(l,u,t.vertexColors,a);wt(e),Be(e,a.indexCount,e.gl.UNSIGNED_INT),fh(l,d),l.bindVertexArray(null);return}l.useProgram(e.pathFill.handle),l.bindVertexArray(a.vao),nt(e,e.pathFill),Vs(e,e.pathFill,s.color,s.opacity),Rn(e,e.pathFill),wt(e),Be(e,a.indexCount,e.gl.UNSIGNED_INT),l.bindVertexArray(null)}var rC=new WeakMap;function w$(e){let t=rC.get(e);return t===void 0&&(t=e.map(n=>iu(n,2)),rC.set(e,t)),t}function iC(e){return{...e,width:at(e.width??1,1)*2,...e.vertexWidths?{vertexWidths:w$(e.vertexWidths)}:{},align:"center"}}function P$(e,t,n,r){let o=t.stroke,i=o.paint,s=iC(o),a=!!(o.vertexColors&&o.vertexColors.length>0),l=xu(e,t.path),u=th(t.path,s,zs(e),r);if(u.indices.length===0)return;let c=a?e.meshCache.uploadTransient(u):e.meshCache.uploadRecurring(u),d=e.gl,f=a?e.pathFillVColor:e.pathFill;d.useProgram(f.handle),nt(e,f),d.enable(d.STENCIL_TEST),d.colorMask(!1,!1,!1,!1),d.stencilMask(1),d.stencilFunc(d.ALWAYS,1,1),d.stencilOp(d.KEEP,d.KEEP,l.requiresStencil?d.INVERT:d.REPLACE),d.bindVertexArray(l.vao),Be(e,l.indexCount,e.gl.UNSIGNED_INT);let p=Ai(e.clipDepth);d.colorMask(!0,!0,!0,!0),n==="inner"?d.stencilFunc(d.EQUAL,p|1,p|1):d.stencilFunc(d.EQUAL,p,p|1),d.stencilOp(d.KEEP,d.KEEP,d.KEEP);let h=f;if(a){let y=ph(i);Vs(e,f,y.color,y.opacity),Rn(e,f)}else h=Jw(e,i);if(!h){d.stencilMask(1),d.clear(d.STENCIL_BUFFER_BIT),d.disable(d.STENCIL_TEST),d.bindVertexArray(null);return}d.bindVertexArray(c.vao);let m=a?dh(d,h,o.vertexColors,c):null;Be(e,c.indexCount,e.gl.UNSIGNED_INT),d.stencilMask(1),d.clear(d.STENCIL_BUFFER_BIT),d.disable(d.STENCIL_TEST),m&&fh(d,m),d.bindVertexArray(null)}Pe();Pe();Z();var Qw=1/4096,T$=2048,mh=new Map;function sC(e,t){let n=mh.get(e);if(n!==void 0)return n;mh.size>=T$&&(mh=new Map);let r=mu(fi(t),{flattenTolerance:Qw});return mh.set(e,r),r}Z();var S$=2048,aC=1/1024,yh=new Map;function lC(e){return Math.round(e/aC)*aC}function Zw(e,t,n,r,o){if(!(n>0))return null;let i=[e,n,r.join??"miter",r.cap??"butt",r.miterLimit??"",r.align??"center",(r.dash??[]).join(","),Po(o)].join("|"),s=yh.get(i);if(s!==void 0)return s.indices.length===0?null:s;yh.size>=S$&&(yh=new Map);let a=Ei(fi(t),{...r,width:n},{flattenTolerance:Qw,metric:o});return yh.set(i,a),a.indices.length===0?null:a}function uC(e,t,n){return eP(e,t,n,r=>sC(r.key,r.d))}function cC(e,t,n,r){if(!Sr(e.stroke))return null;let{trim:o,...i}=e.stroke,s=i.width??1;if(typeof s=="object"){let a=dC(e),[l,u,c,d]=[r[0],r[1],r[3],r[4]];return eP(e,t,n,f=>{if(!(f.scale>0))return null;let p=f.scale,[h,m]=Ro(f.rotate),y=[h*p,m*p],b=[-(h*a+m)*p,(h-m*a)*p],x=vu(l*y[0]+c*y[1],u*y[0]+d*y[1],l*b[0]+c*b[1],u*b[0]+d*b[1]),w=eh(s.px,x.scale);if(!(w>0))return null;let g=i.dash?.map(P=>P/w);return Zw(f.key,f.d,s.px/w,{...i,dash:g},x.metric??void 0)})}return eP(e,t,n,a=>a.scale>0?Zw(a.key,a.d,lC(s/a.scale),{...i,dash:i.dash?.map(l=>l/a.scale)}):null)}var dC=e=>e.synthetic.italic?Math.tan(.2094):0;function eP(e,t,n,r){let o=[],i=0,s=0;for(let p of e.glyphs){let h=r(p);!h||h.indices.length===0||(o.push({mesh:h,glyph:p}),i+=h.vertices.length,s+=h.indices.length)}if(o.length===0)return null;let a=dC(e),l=new Float32Array(i),u=new Uint32Array(s),c=0,d=0,f=0;for(let{mesh:p,glyph:h}of o){let{x:m,baselineY:y,scale:b}=h,[x,w]=Ro(h.rotate);for(let g=0;g<p.vertices.length;g+=2){let P=p.vertices[g],S=p.vertices[g+1],v=(P-S*a)*b,A=S*b;l[c++]=m+t+v*x-A*w,l[c++]=y+n+v*w+A*x}for(let g=0;g<p.indices.length;g++)u[d++]=f+p.indices[g];f+=p.vertices.length/2}return{vertices:l,indices:u}}function fC(e,t,n,r,o,i){let s=e[t]+n,a=e[t+1]+r,l=e[t+2]+n,u=e[t+3]+r,c=e[t+8]+r,d=(c-a)*o,f=(c-u)*o;i[0]=s+d,i[1]=a,i[2]=l+d,i[3]=a,i[4]=l+f,i[5]=u,i[6]=s+f,i[7]=u;let p=e[t+10];if(!p)return;let[h,m]=Ro(p),y=e[t+9]+n;for(let b=0;b<8;b+=2){let x=i[b]-y,w=i[b+1]-c;i[b]=y+x*h-w*m,i[b+1]=c+x*m+w*h}}var fa=new Array(11).fill(0);function gh(e,t,n,r,o,i,s,a){let l=a.xy;fC(e,t,n,r,o,l),pC(i,l);let u=a.uv;for(let b=0;b<4;b++)u[b]=e[t+4+b];if(s<=0)return;let c=Math.abs((l[2]-l[0])*(l[7]-l[1])-(l[3]-l[1])*(l[6]-l[0]));if(c===0)return;let d=e[t+2]-e[t],f=e[t+3]-e[t+1],p=s*d*Math.hypot(l[6]-l[0],l[7]-l[1])/c,h=s*f*Math.hypot(l[2]-l[0],l[3]-l[1])/c;for(let b=0;b<11;b++)fa[b]=e[t+b];fa[0]-=p,fa[2]+=p,fa[1]-=h,fa[3]+=h;let m=(u[2]-u[0])*p/d,y=(u[3]-u[1])*h/f;u[0]-=m,u[2]+=m,u[1]-=y,u[3]+=y,fC(fa,0,n,r,o,l),pC(i,l)}function pC(e,t){for(let n=0;n<8;n+=2){let r=t[n],o=t[n+1];t[n]=e[0]*r+e[3]*o+e[6],t[n+1]=e[1]*r+e[4]*o+e[7]}}Pe();Z();function bh(e){let t=Math.hypot(e[0],e[1]),n=Math.hypot(e[3],e[4]);return Math.sqrt(t*n)||1}function hC(e,t,n,r){let o=t.fill?.paint;if(o===void 0||t.quads.length===0||!yd(e.textureCache,t.page))return;let i=Ut(o)?da(o)[3]:1,s=pd(t.page),a=e.drawBatch,l=e.state.transform,u=e.deviceWidth&&e.widthCss?e.deviceWidth/e.widthCss:1,c=bh(l)*u,d=s,{slot:f,tint:p}=Yw(e,d),h=()=>{({slot:f,tint:p}=Yw(e,d))};for(let m of t.quads){let y=k$(e,m,c),b=y?.quad??m,x=y?.atlasId??s;x!==d&&(d=x,h()),a.wouldOverflow(4)&&(ye(e),h());let w,g=b.rotate?q.multiply(l,q.fromAffine(ao(b.penX+n,b.baselineY+r,b.rotate*Un))):l;for(;!a.pushQuad(b.x0+n,b.y0+r,b.x1-b.x0,b.y1-b.y0,g,b.u0,b.v0,b.u1,b.v1,i*p[3],f,p[0],p[1],p[2]);)w=xo(e),h();w!==void 0&&(wo(e,w),h())}}function k$(e,t,n){let r=t.colorGlyph;if(!r||r.width===0)return null;let o=(t.x1-t.x0)/r.width,i=Td(r,o*n);if(!i||!gd(e.textureCache,i.glyph.page))return null;let s=i.glyph,a=2**i.level,l=t.x0+(s.xoffset-r.xoffset)*o,u=t.y0+(s.yoffset-r.yoffset)*o;return{quad:{x0:l,y0:u,x1:l+s.width/a*o,y1:u+s.height/a*o,u0:s.x/1024,v0:s.y/1024,u1:(s.x+s.width)/1024,v1:(s.y+s.height)/1024,baselineY:t.baselineY,penX:t.penX,rotate:t.rotate},atlasId:hd(s.page)}}var mC={vertices:new Float32Array([0,0,1,0,1,1,0,1]),indices:new Uint32Array([0,1,2,0,2,3])};function yC(e,t,n){let r=e.paintScratch,o=Gi(t.kind)?.bind;if(!r||!o)return null;let i=e.deviceWidth&&e.widthCss>0?e.deviceWidth/e.widthCss:1,s=e.deviceWidth??Math.round(e.widthCss),a=e.deviceHeight??Math.round(e.heightCss),l=e.renderTarget?.window??{x:0,y:0,width:s,height:a},u=Math.max(l.x,Math.floor(n.x0*i)),c=Math.max(l.y,Math.floor(n.y0*i)),d=e.imageCache.maxTextureSide,f=Math.min(d,Math.min(l.x+l.width,Math.ceil(n.x1*i))-u),p=Math.min(d,Math.min(l.y+l.height,Math.ceil(n.y1*i))-c);if(!(f>0&&p>0))return null;let h=u/i,m=c/i,y=f/i,b=p/i,x=new Float32Array([y,0,0,0,b,0,h,m,1]),w=new Float32Array([2/y,0,0,0,2/b,0,-1-2*h/y,-1-2*m/b,1]),g=ah(e),P={...g,alpha:e.state.alpha,maxTextureSize:g.maxTextureSize,setProjAndModel:M=>nt(e,M,x,w)},S=e.gl,v=r.acquire(f,p),A=S.isEnabled(S.SCISSOR_TEST);S.activeTexture(S.TEXTURE0),S.bindTexture(S.TEXTURE_2D,null),S.bindFramebuffer(S.FRAMEBUFFER,v.fbo),S.viewport(0,0,f,p),S.disable(S.SCISSOR_TEST),S.disable(S.STENCIL_TEST),S.clear(S.COLOR_BUFFER_BIT),S.disable(S.BLEND);let N=o(P,t);return N&&(S.bindVertexArray(e.meshCache.uploadRecurring(mC).vao),Be(e,mC.indices.length,S.UNSIGNED_INT),S.bindVertexArray(null)),S.enable(S.BLEND),sa(e,s,a,A),N?{texture:v.texture,uvFromScreen:new Float32Array([i/v.width,0,0,0,i/v.height,0,-u/v.width,-c/v.height,1])}:null}function gC(e,t,n){let r=e.gl;return r.useProgram(t.handle),nt(e,t,js),r.uniformMatrix3fv(t.uniform("u_worldInv"),!1,n.uvFromScreen),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.texture),r.uniform1i(t.uniform("u_sampler"),0),t}var xh=48,bC={outlineMinSize:void 0};function wC(e,t){let n=e.textOutlineMinScreenSize??xh,r=Number.isFinite(n)?n/bh(e.state.transform):void 0,{laid:o,dx:i,dy:s}=$p(t);bC.outlineMinSize=r;let{groups:a,decorations:l}=nw(o,t.runs,bC,"read");if(!(a.length===0&&l.length===0)){for(let u of a)u.source==="outline"?v$(e,u,i,s):u.source==="color"?hC(e,u,i,s):N$(e,u,i,s);A$(e,l,i,s)}}function v$(e,t,n,r){let o=t.fill?.paint;if(o!==void 0){let a=uC(t,n,r);a&&rP(e,o,a)}let i=t.stroke?.paint;if(!i)return;let s=cC(t,n,r,e.state.transform);s&&rP(e,i,s)}function rP(e,t,n){let r=tc(e,t,!1);r!==null&&(rc(e,n,r)||hh(e,t,e.meshCache.uploadTransient(n)))}function A$(e,t,n,r){for(let o of t){let i=o.fill.paint;if(i===void 0)continue;if(TC(i)!==null){rP(e,i,R$(o.x0+n,o.y0+r,o.x1+n,o.y1+r));continue}let[s,a,l,u]=Ut(i)?da(i):[0,0,0,1],c;for(;;){let d=ih(e,4),f=Rx(e,s,a,l,u);if(e.drawBatch.pushRect(o.x0+n,o.y0+r,o.x1-o.x0,o.y1-o.y0,e.state.transform,f,d))break;c=xo(e)}c!==void 0&&wo(e,c)}}function R$(e,t,n,r){return{vertices:new Float32Array([e,t,n,t,n,r,e,r]),indices:new Uint32Array([0,1,2,0,2,3])}}function PC(e,t,n,r){let o=(e.deviceWidth??e.widthCss)/(e.widthCss||1),i=Math.hypot(n[0],n[1])*o*(t[2]-t[0])/Math.abs(t[6]-t[4]),s=Math.hypot(n[3],n[4])*o*(t[3]-t[1])/Math.abs(t[7]-t[5]);return cg(r,i,s)?Cd/o:0}function N$(e,t,n,r){if(t.source==="canvas"){if(!md(e.textureCache,t.page))return}else if(!rg(t.family,t.weight,t.style,e.textureCache))return;if(t.quadData.length===0)return;let o=t.source==="canvas"?fd(t.page):ls(t.family,t.weight,t.style),i=t.source==="canvas"?ug:lg,s=fg(t.source==="canvas"?"canvas":"atlas",t.family,t.weight,t.style);if(!s)return;let a=t.synthetic.bold?Tl:0,l=t.synthetic.italic?Math.tan(.2094):0,u=t.fill?.paint;if(u===void 0)return;let c=TC(u);if(c!==null){C$(e,t,n,r,c,o,i,a,l,s);return}let d=Ut(u)?$n(u.color):I$,f=Ut(u)?u.opacity??1:1,p=e.drawBatch,h=e.state.transform,m=PC(e,t.quadData,h,s),y=m>0,b=nc(e,o,s,y),x=tp(e,d[0],d[1],d[2],d[3]*f,E$),w=t.quadData;for(let g=0;g<w.length;g+=Er){p.wouldOverflow(4)&&(ye(e),b=nc(e,o,s,y));let P;for(;!p.pushGlyph(w,g,n,r,l,h,x,b,i,a,m);)P=xo(e),b=nc(e,o,s,y);P!==void 0&&(wo(e,P),b=nc(e,o,s,y))}}var I$=[0,0,0,1],E$=[0,0,0,0];function TC(e){let t=e.kind??"solid";return t==="texture"?"pattern":t==="linear-gradient"||t==="radial-gradient"||t==="conic-gradient"?"gradient":t==="solid"?null:"texture"}var nP=1,M$=[1,1,1,1];function C$(e,t,n,r,o,i,s,a,l,u){let c=e.glyphPaintProgram?.(o);if(!c)return;an(e);let d=t.fill.paint,f=e.state.transform,p=PC(e,t.quadData,f,u),h;if(o==="pattern")h=lh(e,c,d,js);else if(o==="gradient")h=uh(e,c,d,js);else{let w=yC(e,d,O$(t,n,r,l,f,p));h=w&&gC(e,c,w)}if(!h)return;let m=e.gl;e.textureCache.bind(i,nP),m.uniform1i(c.uniform("u_atlas"),nP),m.uniform1f(c.uniform("u_synthBold"),a),m.uniform2f(c.uniform("u_fieldScale"),u[0],u[1]),wt(e);let y=e.drawBatch,b=y.clip;y.clip=null;let x=t.quadData;for(let w=0;w<x.length;w+=Er)y.wouldOverflow(4)&&xC(e),y.pushGlyph(x,w,n,r,l,f,M$,nP,s,0,p);xC(e),y.clip=b,m.activeTexture(m.TEXTURE0),m.bindVertexArray(null)}function xC(e){let t=e.drawBatch;t.length!==0&&(Be(e,t.uploadAndBind(),e.gl.UNSIGNED_INT),t.reset())}function O$(e,t,n,r,o,i){let s={x0:1/0,y0:1/0,x1:-1/0,y1:-1/0},a=e.quadData,l={xy:[],uv:[]};for(let u=0;u<a.length;u+=Er){gh(a,u,t,n,r,o,i,l);let c=l.xy;for(let d=0;d<8;d+=2)s.x0=Math.min(s.x0,c[d]),s.x1=Math.max(s.x1,c[d]),s.y0=Math.min(s.y0,c[d+1]),s.y1=Math.max(s.y1,c[d+1])}return s}var F$=2;function L$(e){let t=e.state.transform,n=e.deviceWidth&&e.widthCss?e.deviceWidth/e.widthCss:1,r=(F$*n)**2;return[r*(t[0]*t[0]+t[1]*t[1]),r*(t[3]*t[3]+t[4]*t[4])]}var _$=(e,t,n,r,o)=>t*t>=e[0]*r*r||n*n>=e[1]*o*o,D$=(e,t)=>!t||t.x<=0&&t.y<=0&&t.x+t.w>=e.width&&t.y+t.h>=e.height;function oP(e,t){e.imageCache.upload(t.image,t.image);let n=D$(t.image,t.source);n&&e.imageCache.lacksMipmaps(t.image)&&_$(L$(e),t.image.width,t.image.height,t.w,t.h)&&e.imageCache.buildMipmaps(t.image);let r=n&&e.imageCache.hasMipmaps(t.image),{slot:o,tint:i}=Kw(e,t.image,t.sampling??"linear",r),s=t.source,a=0,l=0,u=1,c=1;if(s){let d=t.image.width,f=t.image.height;a=s.x/d,u=(s.x+s.w)/d,l=s.y/f,c=(s.y+s.h)/f}if(t.flipX){let d=a;a=u,u=d}if(t.flipY){let d=l;l=c,c=d}e.drawBatch.pushQuad(t.x,t.y,t.w,t.h,e.state.transform,a,l,u,c,(t.opacity??1)*i[3],o,i[0],i[1],i[2])||sn(e,t,void 0,oP)}function SC(e,t){let n=t.sprites,r=Math.floor(n.length/9);if(r===0)return;e.imageCache.upload(t.image,t.image);let o=t.sampling??"linear",i=()=>Kw(e,t.image,o,!1),{slot:s,tint:a}=i(),l=e.drawBatch,u=e.state.transform,c=t.image.width,d=t.image.height;for(let f=0,p=0;f<r;f++,p+=9){l.wouldOverflow(4)&&(ye(e),{slot:s,tint:a}=i());let h=n[p+4],m=n[p+5],y=n[p+6],b=n[p+7],x;for(;!l.pushQuad(n[p],n[p+1],n[p+2],n[p+3],u,h/c,m/d,(h+y)/c,(m+b)/d,n[p+8]*a[3],s,a[0],a[1],a[2]);)x=xo(e),{slot:s,tint:a}=i();x!==void 0&&(wo(e,x),{slot:s,tint:a}=i())}}function zi(e,t){switch(t.kind){case"group":return B$(e,t);case"path":return Xw(e,t);case"text":return wC(e,t);case"image":return oP(e,t);case"sprites":return SC(e,t);case"shader":return an(e),DN(e,t)}}function kC(e){return e.isolate===!0||Yn(e.composite)||e.effects!==void 0&&e.effects.length>0}function B$(e,t){if(!(t.retain!==void 0&&s2(e,t,kC(t),zi))){if(kC(t)&&e.effectTargets&&e.deviceWidth&&e.deviceHeight){if(t.clip){e.state.push({transform:t.transform});try{Su(e,t.clip)}finally{e.state.pop()}}o2(e,t,e.effectTargets,e.deviceWidth,e.deviceHeight,zi),t.clip&&Mx(e);return}if(e.state.push({transform:t.transform,alpha:t.alpha,colorMatrix:t.colorMatrix}),t.clip)try{Su(e,t.clip)}catch(n){throw e.state.pop(),n}for(let n of t.children)zi(e,n);t.clip&&Mx(e),e.state.pop()}}var qn=10,oe=qn,H$=256,G$=384,iP=32;function Oo(e,t){let n=e;for(;n<t;)n*=2;return n}var wh=class{verts=new Float32Array(H$*oe);idx=new Uint32Array(G$);nVerts=0;nIdx=0;pureRects=!0;clip=null;polyIn=new Float32Array(iP*oe);polyOut=new Float32Array(iP*oe);polyTmp=new Float32Array(iP*oe);triangles=new Uint32Array(0);writeVertex(t,n,r,o,i,s,a,l,u,c,d){let f=this.verts;return f[t]=n,f[t+1]=r,f[t+2]=o,f[t+3]=i,f[t+4]=s,f[t+5]=a,f[t+6]=l,f[t+7]=u,f[t+8]=c,f[t+9]=d,t+oe}pushQuadIndices(){let t=this.nVerts,n=this.nIdx;this.idx[n++]=t,this.idx[n++]=t+1,this.idx[n++]=t+2,this.idx[n++]=t,this.idx[n++]=t+2,this.idx[n++]=t+3,this.nVerts+=4,this.nIdx+=6}reserve(t,n){let r=(this.nVerts+t)*oe;if(r>this.verts.length){let i=new Float32Array(Oo(this.verts.length,r));i.set(this.verts),this.verts=i}let o=this.nIdx+n;if(o>this.idx.length){let i=new Uint32Array(Oo(this.idx.length,o));i.set(this.idx),this.idx=i}}fitQuad(t,n){let r=this.clip;if(r===null)return!0;let o=this.verts,i=t*oe;if(vr(r,o[i],o[i+1])&&vr(r,o[i+oe],o[i+oe+1])&&vr(r,o[i+2*oe],o[i+2*oe+1])&&vr(r,o[i+3*oe],o[i+3*oe+1])||(this.nVerts=t,this.nIdx=n,Qf(r,o,i,4,oe)))return!0;if(!r.slanted){let s=o[i],a=o[i+1],l=o[i+oe],u=o[i+oe+1],c=o[i+2*oe],d=o[i+2*oe+1],f=o[i+3*oe],p=o[i+3*oe+1];if(!(a===u&&l===c&&d===p&&f===s||s===l&&u===d&&c===f&&p===a)||r.planes.length>0)return!1}return this.polyIn.set(o.subarray(i,i+4*oe)),this.appendFan(vx(this.polyIn,4,oe,r,this.polyOut,this.polyTmp)),!0}fitMesh(t,n){let r=this.clip;if(r===null)return!0;let o=this.verts,i=!0;for(let u=t*oe;u<this.nVerts*oe&&i;u+=oe)i=vr(r,o[u],o[u+1]);if(i)return!0;let s=this.nIdx,a=Qf(r,o,t*oe,this.nVerts-t,oe);if(a||!r.slanted)return this.nVerts=t,this.nIdx=n,a;this.triangles.length<s-n&&(this.triangles=new Uint32Array(Oo(64,s-n)));let l=this.triangles;l.set(this.idx.subarray(n,s)),this.nIdx=n;for(let u=0;u<s-n;u+=3)this.fitTriangle(r,l[u],l[u+1],l[u+2]);return!0}fitTriangle(t,n,r,o){let i=this.verts;if(vr(t,i[n*oe],i[n*oe+1])&&vr(t,i[r*oe],i[r*oe+1])&&vr(t,i[o*oe],i[o*oe+1])){this.reserve(0,3),this.idx[this.nIdx++]=n,this.idx[this.nIdx++]=r,this.idx[this.nIdx++]=o;return}let s=this.polyIn;s.set(i.subarray(n*oe,n*oe+oe),0),s.set(i.subarray(r*oe,r*oe+oe),oe),s.set(i.subarray(o*oe,o*oe+oe),2*oe),!Qf(t,s,0,3,oe)&&this.appendFan(vx(s,3,oe,t,this.polyOut,this.polyTmp))}appendFan(t){if(t<3)return;this.reserve(t,(t-2)*3),t!==4&&(this.pureRects=!1);let n=this.nVerts;this.verts.set(this.polyOut.subarray(0,t*oe),n*oe);let r=this.nIdx;for(let o=1;o<t-1;o++)this.idx[r++]=n,this.idx[r++]=n+o,this.idx[r++]=n+o+1;this.nVerts+=t,this.nIdx=r}};var U$=32768;var sP={xy:new Array(8).fill(0),uv:[0,0,0,0]},W$=[0,0,0,0],oc=.5,ic=.5,V$={ux:0,uy:0,u0:oc,vx:0,vy:0,v0:ic},z$=64,_r=[{vertices:16,indices:24},{vertices:1024,indices:3072}],K$=_r[_r.length-1].vertices,vC=4;function j$(e){let t=new Uint32Array(e*6);for(let n=0;n<e;n++){let r=n*4,o=n*6;t[o]=r,t[o+1]=r+1,t[o+2]=r+2,t[o+3]=r,t[o+4]=r+2,t[o+5]=r+3}return t}var sc=class extends wh{gl;aPos;aColor;aUv;aPost;aSlot;rings=_r.map(()=>new Array(z$).fill(void 0));nextInRing=_r.map(()=>0);largeRing=new Array(vC).fill(void 0);nextLarge=0;constructor(t,n){super();let r=n.attribute("a_position"),o=n.attribute("a_vertexColor"),i=n.attribute("a_uv"),s=n.attribute("a_post"),a=n.attribute("a_texSlot");if(r===void 0||o===void 0||i===void 0||s===void 0||a===void 0)throw new Error("DrawBatch: batch program is missing a_position / a_vertexColor / a_uv / a_post / a_texSlot");this.gl=t,this.aPos=r,this.aColor=o,this.aUv=i,this.aPost=s,this.aSlot=a}get length(){return this.nIdx}wouldOverflow(t){return this.nVerts+t>U$}pushRect(t,n,r,o,i,s,a){let l=s[0],u=s[1],c=s[2],d=s[3];this.reserve(4,6);let f=this.nVerts*qn,p=i[0],h=i[1],m=i[3],y=i[4],b=i[6],x=i[7],w=t+r,g=n+o,P=p*t+m*n+b,S=h*t+y*n+x,v=p*w+m*n+b,A=h*w+y*n+x,N=p*w+m*g+b,M=h*w+y*g+x,C=p*t+m*g+b,F=h*t+y*g+x;return f=this.writeVertex(f,P,S,l,u,c,d,oc,ic,1,a),f=this.writeVertex(f,v,A,l,u,c,d,oc,ic,1,a),f=this.writeVertex(f,N,M,l,u,c,d,oc,ic,1,a),this.writeVertex(f,C,F,l,u,c,d,oc,ic,1,a),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushQuad(t,n,r,o,i,s,a,l,u,c,d,f=1,p=1,h=1){this.reserve(4,6);let m=this.nVerts*qn,y=i[0],b=i[1],x=i[3],w=i[4],g=i[6],P=i[7],S=t+r,v=n+o,A=y*t+x*n+g,N=b*t+w*n+P,M=y*S+x*n+g,C=b*S+w*n+P,F=y*S+x*v+g,D=b*S+w*v+P,B=y*t+x*v+g,K=b*t+w*v+P,W=gi(d,Os);return m=this.writeVertex(m,A,N,f,p,h,1,s,a,c,W),m=this.writeVertex(m,M,C,f,p,h,1,l,a,c,W),m=this.writeVertex(m,F,D,f,p,h,1,l,u,c,W),this.writeVertex(m,B,K,f,p,h,1,s,u,c,W),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGlyph(t,n,r,o,i,s,a,l,u,c,d=0){this.reserve(4,6);let f=this.nVerts*qn;gh(t,n,r,o,i,s,d,sP);let p=sP.xy,h=sP.uv,m=a[0],y=a[1],b=a[2],x=a[3],w=gi(l,u),g=d>0?ZA:W$;return f=this.writeVertex(f,p[0],p[1],m,y,b,x,h[0],h[1],c+g[0],w),f=this.writeVertex(f,p[2],p[3],m,y,b,x,h[2],h[1],c+g[1],w),f=this.writeVertex(f,p[4],p[5],m,y,b,x,h[2],h[3],c+g[2],w),this.writeVertex(f,p[6],p[7],m,y,b,x,h[0],h[3],c+g[3],w),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGradientRect(t,n,r,o,i,s,a,l,u,c,d,f,p){this.reserve(4,6);let h=this.nVerts*qn,m=i[0],y=i[1],b=i[3],x=i[4],w=i[6],g=i[7],P=t+r,S=n+o,v=gi(l,u),A=(N,M)=>{let C=h;return h=this.writeVertex(C,m*N+b*M+w,y*N+x*M+g,c,d,f,p,s.ux*N+s.uy*M+s.u0,s.vx*N+s.vy*M+s.v0,a,v),h};return A(t,n),A(P,n),A(P,S),A(t,S),this.pushQuadIndices(),this.fitQuad(this.nVerts-4,this.nIdx-6)}pushGradientMesh(t,n,r,o,i,s,a,l,u,c,d){let f=t.vertices,p=t.indices,h=f.length>>1;this.reserve(h,p.length),this.pureRects=!1;let m=this.verts,y=this.nVerts*qn,b=n[0],x=n[1],w=n[3],g=n[4],P=n[6],S=n[7],v=gi(i,s),A=t.origin?.x??0,N=t.origin?.y??0;for(let D=0;D<h;D++){let B=f[D*2]+A,K=f[D*2+1]+N;if(m[y++]=b*B+w*K+P,m[y++]=x*B+g*K+S,d===void 0)m[y++]=a,m[y++]=l,m[y++]=u,m[y++]=c;else{let W=D*4;m[y++]=a*d[W],m[y++]=l*d[W+1],m[y++]=u*d[W+2],m[y++]=c*d[W+3]}m[y++]=r.ux*B+r.uy*K+r.u0,m[y++]=r.vx*B+r.vy*K+r.v0,m[y++]=o,m[y++]=v}let M=this.nVerts,C=this.idx,F=this.nIdx;for(let D=0;D<p.length;D++)C[F++]=M+p[D];return this.nVerts+=h,this.nIdx+=p.length,this.fitMesh(M,this.nIdx-p.length)}pushMesh(t,n,r,o,i,s,a,l){return this.pushGradientMesh(t,n,V$,1,a,yi,r,o,i,s,l)}uploadAndBind(){let t=this.gl,n=_r.findIndex(o=>this.nVerts<=o.vertices&&this.nIdx<=o.indices),r=n<0?this.nextLargeSlot():this.nextRingSlot(n);if(t.bindVertexArray(r.vao),t.bindBuffer(t.ARRAY_BUFFER,r.vbo),t.bufferSubData(t.ARRAY_BUFFER,0,this.verts,0,this.nVerts*qn),!this.pureRects)t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,this.idx,0,this.nIdx),r.canonicalQuads=0;else if(r.canonicalQuads<this.nVerts>>2){let o=Math.min(r.vertexCapacity>>2,Math.floor(r.indexCapacity/6));t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,j$(o)),r.canonicalQuads=o}return this.nIdx}reset(){this.nVerts=0,this.nIdx=0,this.pureRects=!0}dispose(){for(let t of[...this.rings.flat(),...this.largeRing])t&&this.deleteSet(t);for(let t of this.rings)t.fill(void 0);this.largeRing.fill(void 0)}nextRingSlot(t){let n=this.rings[t],r=this.nextInRing[t];this.nextInRing[t]=(r+1)%n.length;let o=n[r];if(o)return o;let i=this.createSet(_r[t].vertices,_r[t].indices);return n[r]=i,i}nextLargeSlot(){let t=this.gl,n=this.nextLarge;this.nextLarge=(n+1)%vC;let r=this.largeRing[n];return r?(this.nVerts>r.vertexCapacity&&(r.vertexCapacity=Oo(r.vertexCapacity,this.nVerts),t.bindBuffer(t.ARRAY_BUFFER,r.vbo),t.bufferData(t.ARRAY_BUFFER,r.vertexCapacity*qn*4,t.DYNAMIC_DRAW)),this.nIdx>r.indexCapacity&&(r.indexCapacity=Oo(r.indexCapacity,this.nIdx),t.bindVertexArray(r.vao),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,r.ibo),t.bufferData(t.ELEMENT_ARRAY_BUFFER,r.indexCapacity*4,t.DYNAMIC_DRAW),t.bindVertexArray(null),r.canonicalQuads=0),r):(r=this.createSet(Oo(K$,this.nVerts),Oo(_r[_r.length-1].indices,this.nIdx)),this.largeRing[n]=r,r)}createSet(t,n){let r=this.gl,o=r.createVertexArray(),i=r.createBuffer(),s=r.createBuffer();if(!o||!i||!s)throw new Error("DrawBatch: failed to create GL objects");let a=qn*4;return r.bindVertexArray(o),r.bindBuffer(r.ARRAY_BUFFER,i),r.bufferData(r.ARRAY_BUFFER,t*a,r.DYNAMIC_DRAW),r.enableVertexAttribArray(this.aPos),r.vertexAttribPointer(this.aPos,2,r.FLOAT,!1,a,0),r.enableVertexAttribArray(this.aColor),r.vertexAttribPointer(this.aColor,4,r.FLOAT,!1,a,8),r.enableVertexAttribArray(this.aUv),r.vertexAttribPointer(this.aUv,2,r.FLOAT,!1,a,24),r.enableVertexAttribArray(this.aPost),r.vertexAttribPointer(this.aPost,1,r.FLOAT,!1,a,32),r.enableVertexAttribArray(this.aSlot),r.vertexAttribPointer(this.aSlot,1,r.FLOAT,!1,a,36),r.bindBuffer(r.ELEMENT_ARRAY_BUFFER,s),r.bufferData(r.ELEMENT_ARRAY_BUFFER,n*4,r.DYNAMIC_DRAW),r.bindVertexArray(null),{vao:o,vbo:i,ibo:s,vertexCapacity:t,indexCapacity:n,canonicalQuads:0}}deleteSet(t){let n=this.gl;n.deleteBuffer(t.vbo),n.deleteBuffer(t.ibo),n.deleteVertexArray(t.vao)}};var AC=`#version 300 es
398
398
  in vec2 a_position;
399
399
  in vec2 a_uv;
400
400
  uniform vec4 u_bounds;
@@ -419,15 +419,15 @@ void main() {
419
419
  vec3 clip = u_proj * vec3(sx, sy, 1.0);
420
420
  gl_Position = vec4(clip.xy, 0.0, 1.0);
421
421
  }
422
- `,gC=["a_position","a_uv"],bC=["u_bounds","u_view","u_proj","u_screenToLocal","u_worldOrigin"],xC=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),wC=new Uint16Array([0,1,2,0,2,3]);var eh=class{gl;all=[];free=[];constructor(t){this.gl=t}get allocated(){return this.all.length>0}acquire(t,n){let r=this.free.findIndex(i=>i.width===t&&i.height===n),o=r>=0?this.free.splice(r,1)[0]:this.create(t,n);return o.used=!0,o}release(t){this.free.push(t)}reclaim(){let t=[];for(let n of this.all)n.used?t.push(n):this.destroy(n),n.used=!1;this.all=t,this.free=[...t]}releaseAll(){for(let t of this.all)this.destroy(t);this.all=[],this.free=[]}destroy(t){let n=this.gl;n.deleteFramebuffer(t.fbo),n.deleteTexture(t.texture),n.deleteRenderbuffer(t.stencil)}create(t,n){let r=this.gl,o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texImage2D(r.TEXTURE_2D,0,r.RGBA8,t,n,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null);let i=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,i),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH24_STENCIL8,t,n),r.bindRenderbuffer(r.RENDERBUFFER,null);let s=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,s),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,o,0),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,i),r.bindFramebuffer(r.FRAMEBUFFER,null);let a={fbo:s,texture:o,stencil:i,width:t,height:n,used:!1};return this.all.push(a),a}};function SC(e){return{...e,transform:e.transform.slice(),colorMatrix:e.colorMatrix.slice(),viewMatrix:e.viewMatrix?.slice(),screenMatrix:e.screenMatrix?.slice(),clips:e.clips.map(t=>({path:t.path,transform:t.transform.slice()})),window:e.window&&{...e.window}}}function kC(e,t){return e.children===t.children&&e.alpha===t.alpha&&sa(e.transform,t.transform)&&sa(e.colorMatrix,t.colorMatrix)&&vw(e.viewMatrix,t.viewMatrix)&&vw(e.screenMatrix,t.screenMatrix)&&fj(e.clips,t.clips)&&e.isolate===t.isolate&&AC(e.effects,t.effects)&&RC(e.window,t.window)}function vC(e,t){if(e.children!==t.children||e.alpha!==t.alpha||e.isolate!==t.isolate||!sa(e.colorMatrix,t.colorMatrix)||!vw(e.screenMatrix,t.screenMatrix)||!AC(e.effects,t.effects)||e.clips.length!==t.clips.length||!RC(e.window,t.window))return null;let n=PC(e.transform,t.transform);if(!n)return null;let r=(o,i)=>{if(o===void 0||i===void 0)return o===i;let s=PC(o,i);return s!==null&&TC(s[0],n[0])&&TC(s[1],n[1])};if(!r(e.viewMatrix,t.viewMatrix))return null;for(let o=0;o<e.clips.length;o++)if(e.clips[o].path!==t.clips[o].path||!r(e.clips[o].transform,t.clips[o].transform))return null;return n}function PC(e,t){for(let n of[0,1,2,3,4,5,8])if(e[n]!==t[n])return null;return[t[6]-e[6],t[7]-e[7]]}function TC(e,t){return Math.abs(e-t)<=1e-6*Math.max(1,Math.abs(e),Math.abs(t))}function AC(e,t){if(e===t)return!0;if((e?.length??0)!==(t?.length??0))return!1;for(let n=0;n<(e?.length??0);n++){let r=e[n],o=t[n];if(r.program.id!==o.program.id||r.reach!==o.reach||!cj(r.uniforms,o.uniforms))return!1}return!0}function cj(e,t){if(e===t)return!0;let n=Object.keys(e??{});return n.length!==Object.keys(t??{}).length?!1:n.every(r=>dj(e[r],t?.[r]))}function dj(e,t){return typeof e=="number"||t===void 0||typeof t=="number"?e===t:"id"in e||"id"in t?"id"in e&&"id"in t&&e.id===t.id:sa(e,t)}function vw(e,t){return e===void 0?t===void 0:t!==void 0&&sa(e,t)}function RC(e,t){return e===void 0||t===void 0?e===t:e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function fj(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].path!==t[n].path||!sa(e[n].transform,t[n].transform))return!1;return!0}function sa(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function NC(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function IC(e,t,n){let r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,t,n,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null);let o=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,o),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0),e.bindFramebuffer(e.FRAMEBUFFER,null),{texture:r,fbo:o}}function EC(e,t){e.deleteFramebuffer(t.fbo),e.deleteTexture(t.texture)}function MC(e,t,n,r){let o=l=>{let u=e.createRenderbuffer();return e.bindRenderbuffer(e.RENDERBUFFER,u),r>0?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,l,t,n):e.renderbufferStorage(e.RENDERBUFFER,l,t,n),u},i=o(e.RGBA8),s=o(e.DEPTH24_STENCIL8);e.bindRenderbuffer(e.RENDERBUFFER,null);let a=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,s),e.bindFramebuffer(e.FRAMEBUFFER,null),{fbo:a,color:i,stencil:s,width:t,height:n,samples:r,resolved:null}}function CC(e,t){e.deleteFramebuffer(t.fbo),e.deleteRenderbuffer(t.color),e.deleteRenderbuffer(t.stencil),t.resolved&&(e.deleteFramebuffer(t.resolved.fbo),e.deleteRenderbuffer(t.resolved.color))}function OC(e,t,n,r,o,i=0,s=0){let a=e.isEnabled(e.SCISSOR_TEST),l=e.getParameter(e.READ_FRAMEBUFFER_BINDING)??null,u=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING)??null;if(e.disable(e.SCISSOR_TEST),e.bindFramebuffer(e.READ_FRAMEBUFFER,t.fbo),t.samples>0&&(i!==0||s!==0||r!==t.width||o!==t.height)){let c=pj(e,t);e.bindFramebuffer(e.DRAW_FRAMEBUFFER,c),e.blitFramebuffer(0,0,r,o,0,0,r,o,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,c)}e.bindFramebuffer(e.DRAW_FRAMEBUFFER,n.fbo),e.blitFramebuffer(0,0,r,o,i,s,i+r,s+o,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,l),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,u),a&&e.enable(e.SCISSOR_TEST)}function pj(e,t){if(t.resolved)return t.resolved.fbo;let n=e.createRenderbuffer();e.bindRenderbuffer(e.RENDERBUFFER,n),e.renderbufferStorage(e.RENDERBUFFER,e.RGBA8,t.width,t.height),e.bindRenderbuffer(e.RENDERBUFFER,null);let r=e.createFramebuffer(),o=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING);return e.bindFramebuffer(e.DRAW_FRAMEBUFFER,r),e.framebufferRenderbuffer(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,n),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,o),t.resolved={fbo:r,color:n},r}var FC=1e-4,LC=1/8,hj=1024,th=class{gl;budget;samples;surfaces=new Map;scratches=new Map;width=0;height=0;frame=0;stamp=[];tile=hj;composited=0;redrawn=0;declined=0;constructor(t,n){this.gl=t,this.budget=n;let r=t.getParameter(t.SAMPLES);this.samples=typeof r=="number"&&r>1?r:0}get bytes(){let t=this.keptBytes();for(let[n,r]of this.scratches)t+=r.width*r.height*(Math.max(1,n)*8+(r.resolved?4:0));return t}setBudget(t){this.budget=t,this.keptBytes()>t&&this.releaseAll()}beginFrame(t){this.frame++,this.stamp=t,this.composited=0,this.redrawn=0,this.declined=0}lookup(t,n,r,o,i=!0,s){this.fitTo(n,r);let a={x:0,y:0,width:n,height:r},l=this.surfaces.get(t);if(!l?.key||l.samples!==(i?this.samples:0)||!NC(l.stamp,this.stamp))return{kind:"redraw",window:a};let u=[o.transform[6],o.transform[7]],c=l.seen!==null&&l.seen[0]===u[0]&&l.seen[1]===u[1];if(kC(l.key,o))return l.frame=this.frame,l.seen=u,this.composited++,{kind:"kept",pixels:Aw(l,0,0)};let d=vC(l.key,o),f=s!==void 0&&l.reach!==null,p=Math.round(n*LC),h=Math.round(r*LC),m={x:-p,y:-h,width:n+2*p,height:r+2*h};if(!d)return{kind:"redraw",window:l.panned&&f?m:a};if(l.seen=u,l.frame=this.frame,!f)return c?{kind:"redraw",window:a}:(this.declined++,{kind:"through"});let g=l.panned&&l.reach.window.width===n&&l.reach.window.height===r;l.panned=!0;let b=d[0]*s,x=d[1]*s,w=Math.round(b),y=Math.round(x),P=Math.abs(b-w)<=FC&&Math.abs(x-y)<=FC;return P&&mj(l.reach,w,y,n,r)?(this.composited++,{kind:"kept",pixels:Aw(l,w,y)}):(!P||g)&&!c?(this.declined++,{kind:"through"}):{kind:"redraw",window:m}}reserve(t,n,r,o,i=!0,s){this.fitTo(n,r);let a={x:0,y:0,width:n,height:r};if(s&&(s.window.width>n||s.window.height>r)&&!this.fits(t,o))return this.reserve(t,n,r,Mi(s.box,a),i,{box:s.box,window:a});let l=this.surfaces.get(t),u=o.width===0||o.height===0,c=i?this.samples:0,d=this.scratches.get(c),f=Math.max(d?.width??0,u?0:Math.min(o.width,this.tile)),p=Math.max(d?.height??0,u?0:Math.min(o.height,this.tile));if(!this.fits(t,o))return this.declined++,null;let h=l??{gl:null,rect:o,key:null,stamp:[],frame:this.frame,samples:c,reach:null,panned:!1,seen:null};this.surfaces.set(t,h),this.fitSurface(h,o),h.frame=this.frame,h.samples=c,this.redrawn++;let m=h.gl?this.scratchFor(c,f,p):null,g=h.rect;return{fbo:m?.fbo??null,rect:g,tiles:m?yj(g,this.tile):[],resolve:b=>{!m||!h.gl||OC(this.gl,m,h.gl,b.width,b.height,b.x-g.x,g.y+g.height-b.y-b.height)},commit:b=>(h.key=SC(b),h.stamp=this.stamp,h.reach=s?{box:{...s.box},window:{...s.window}}:null,h.seen=[b.transform[6],b.transform[7]],Aw(h,0,0))}}decline(){this.declined++}endFrame(){let t=new Map;for(let[n,r]of this.surfaces){if(r.frame===this.frame){let o=t.get(r.samples)??{w:0,h:0},{width:i,height:s}=r.rect;t.set(r.samples,{w:Math.max(o.w,Math.min(i,this.tile)),h:Math.max(o.h,Math.min(s,this.tile))});continue}this.deleteSurface(r),this.surfaces.delete(n)}for(let[n,r]of this.scratches){let o=t.get(n)??{w:0,h:0};(this.redrawn===0||r.width>o.w||r.height>o.h)&&this.dropScratch(n)}}releaseAll(){for(let t of this.surfaces.values())this.deleteSurface(t);this.surfaces.clear();for(let t of[...this.scratches.keys()])this.dropScratch(t)}fitTo(t,n){t===this.width&&n===this.height||(this.releaseAll(),this.width=t,this.height=n)}fits(t,n){let r=this.surfaces.get(t);return this.keptBytes()+Rw(n)-(r?Rw(r.rect):0)<=this.budget}keptBytes(){let t=0;for(let n of this.surfaces.values())t+=Rw(n.rect);return t}scratchFor(t,n,r){let o=this.scratches.get(t);if(o&&o.width===n&&o.height===r)return o;this.dropScratch(t);let i=MC(this.gl,n,r,t);return this.scratches.set(t,i),i}fitSurface(t,n){let r=t.rect;t.rect={...n},!(t.gl&&r.width===n.width&&r.height===n.height)&&(this.deleteSurface(t),n.width>0&&n.height>0&&(t.gl=IC(this.gl,n.width,n.height)))}deleteSurface(t){t.gl&&EC(this.gl,t.gl),t.gl=null}dropScratch(t){let n=this.scratches.get(t);n&&CC(this.gl,n),this.scratches.delete(t)}};function Aw(e,t,n){let{rect:r}=e;return{texture:e.gl?.texture??null,rect:t===0&&n===0?r:{...r,x:r.x+t,y:r.y+n}}}function mj(e,t,n,r,o){let i=Mi(e.box,{x:-t,y:-n,width:r,height:o});if(i.width===0||i.height===0)return!0;let s=e.window;return i.x>=s.x&&i.y>=s.y&&i.x+i.width<=s.x+s.width&&i.y+i.height<=s.y+s.height}function yj(e,t){let n=[];for(let r=0;r<e.height;r+=t)for(let o=0;o<e.width;o+=t)n.push({x:e.x+o,y:e.y+r,width:Math.min(t,e.width-o),height:Math.min(t,e.height-r)});return n}function Rw(e){return e.width*e.height*4}function Nw(e){let t=e.createTexture();return t?(e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([255,255,255,255])),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),t):null}var Iw=new Set(["lowp","mediump","highp","precise","invariant","centroid","flat","smooth","noperspective"]),Ew=/^[A-Za-z_]\w*$/,_C=16;function Mw(e){return[...HC(e).names]}function Cw(e){return HC(e).arrays}function HC(e){let{code:t,defines:n}=gj(e),r=DC(t),o=new Map,i=new Map,s=new Set,a=new Map,l=(g,b)=>{if(b>_C)return null;let x=null;for(let w of n.get(g)??[]){let y=BC(DC(w),P=>l(P,b+1));y!==null&&(x===null||y>x)&&(x=y)}return x??o.get(g)??null},u=(g,b)=>BC(r.slice(g,b),x=>l(x,0)),c=g=>{let b=0;for(let x=g;x<r.length;x++)if(r[x]==="("||r[x]==="["||r[x]==="{")b++;else if((r[x]===")"||r[x]==="]"||r[x]==="}")&&--b===0)return x;return r.length},d=g=>{if(r[g]!=="[")return[void 0,g];let b=c(g);return[u(g+1,b),b+1]},f=(g,b)=>{let x=[];for(;g<r.length&&r[g]!==";"&&r[g]!=="}";){let w=r[g],[y,P]=d(g+1);for(g=P,Ew.test(w)&&x.push({name:w,size:y===void 0?b:y});g<r.length&&r[g]!==","&&r[g]!==";"&&r[g]!=="}";)g=r[g]==="("||r[g]==="["||r[g]==="{"?c(g)+1:g+1;r[g]===","&&g++}return[x,g]},p=g=>{let b=g+1,x=r[b]!=="{"?r[b++]:void 0,w=[];if(r[b]!=="{")return[w,b];let y=c(b);for(b++;b<y;){for(;Iw.has(r[b]);)b++;let P;r[b]==="struct"?[P,b]=p(b):P=r[b++];let[S,v]=d(b),[A,N]=f(v,S);for(let M of A)M.size!==null&&w.push({type:P,name:M.name,size:M.size??null});b=N+1}if(x){let P=i.get(x)??[];for(let S of w)P.some(v=>v.name===S.name)||P.push(S);i.set(x,P)}return[w,y+1]},h=(g,b,x,w)=>{if(w>_C)return;if(x!==null){if(typeof b=="string"&&!i.has(b)){let P=a.get(g);(!P||x>P.size)&&a.set(g,{type:b,size:x})}for(let P=0;P<x;P++)h(`${g}[${P}]`,b,null,w+1);return}let y=typeof b=="string"?i.get(b):b;if(!y){s.add(g);return}for(let P of y)h(`${g}.${P.name}`,P.type,P.size,w+1)},m=0;for(let g=0;g<r.length;g++){let b=r[g];if(b==="{")m++;else if(b==="}")m--;else if(b==="struct")g=p(g)[1]-1;else if(m===0&&b==="const"){let x=g+1;for(;Iw.has(r[x]);)x++;if((r[x]==="int"||r[x]==="uint")&&Ew.test(r[x+1]??"")&&r[x+2]==="="){let w=x+3;for(;w<r.length&&r[w]!==";";)w++;let y=u(x+3,w),P=o.get(r[x+1]);y!==null&&(P===void 0||y>P)&&o.set(r[x+1],y)}}else if(m===0&&b==="uniform"){let x=g+1;for(;Iw.has(r[x]);)x++;let w;if(r[x]==="struct")[w,x]=p(x);else if(r[x+1]==="{"){for(x=c(x+1)+1;x<r.length&&r[x]!==";";)x++;g=x;continue}else w=r[x++];let[y,P]=d(x),[S,v]=f(P,y);for(let A of S)A.size!==null&&h(A.name,w,A.size??null,0);g=v}}return{names:s,arrays:a}}function gj(e){let t=e.replace(/\\\r?\n/g,""),n="";for(let i=0;i<t.length;i++)if(t[i]==="/"&&t[i+1]==="/"){for(;i<t.length&&t[i]!==`
422
+ `,RC=["a_position","a_uv"],NC=["u_bounds","u_view","u_proj","u_screenToLocal","u_worldOrigin"],IC=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),EC=new Uint16Array([0,1,2,0,2,3]);var Ph=class{gl;all=[];free=[];constructor(t){this.gl=t}get allocated(){return this.all.length>0}acquire(t,n){let r=this.free.findIndex(i=>i.width===t&&i.height===n),o=r>=0?this.free.splice(r,1)[0]:this.create(t,n);return o.used=!0,o}release(t){this.free.push(t)}reclaim(){let t=[];for(let n of this.all)n.used?t.push(n):this.destroy(n),n.used=!1;this.all=t,this.free=[...t]}releaseAll(){for(let t of this.all)this.destroy(t);this.all=[],this.free=[]}destroy(t){let n=this.gl;n.deleteFramebuffer(t.fbo),n.deleteTexture(t.texture),n.deleteRenderbuffer(t.stencil)}create(t,n){let r=this.gl,o=r.createTexture();r.bindTexture(r.TEXTURE_2D,o),r.texImage2D(r.TEXTURE_2D,0,r.RGBA8,t,n,0,r.RGBA,r.UNSIGNED_BYTE,null),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.bindTexture(r.TEXTURE_2D,null);let i=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,i),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH24_STENCIL8,t,n),r.bindRenderbuffer(r.RENDERBUFFER,null);let s=r.createFramebuffer();r.bindFramebuffer(r.FRAMEBUFFER,s),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,o,0),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,i),r.bindFramebuffer(r.FRAMEBUFFER,null);let a={fbo:s,texture:o,stencil:i,width:t,height:n,used:!1};return this.all.push(a),a}};function OC(e){return{...e,transform:e.transform.slice(),colorMatrix:e.colorMatrix.slice(),viewMatrix:e.viewMatrix?.slice(),screenMatrix:e.screenMatrix?.slice(),clips:e.clips.map(t=>({path:t.path,transform:t.transform.slice()})),window:e.window&&{...e.window}}}function FC(e,t){return e.children===t.children&&e.alpha===t.alpha&&pa(e.transform,t.transform)&&pa(e.colorMatrix,t.colorMatrix)&&aP(e.viewMatrix,t.viewMatrix)&&aP(e.screenMatrix,t.screenMatrix)&&q$(e.clips,t.clips)&&e.isolate===t.isolate&&_C(e.effects,t.effects)&&DC(e.window,t.window)}function LC(e,t){if(e.children!==t.children||e.alpha!==t.alpha||e.isolate!==t.isolate||!pa(e.colorMatrix,t.colorMatrix)||!aP(e.screenMatrix,t.screenMatrix)||!_C(e.effects,t.effects)||e.clips.length!==t.clips.length||!DC(e.window,t.window))return null;let n=MC(e.transform,t.transform);if(!n)return null;let r=(o,i)=>{if(o===void 0||i===void 0)return o===i;let s=MC(o,i);return s!==null&&CC(s[0],n[0])&&CC(s[1],n[1])};if(!r(e.viewMatrix,t.viewMatrix))return null;for(let o=0;o<e.clips.length;o++)if(e.clips[o].path!==t.clips[o].path||!r(e.clips[o].transform,t.clips[o].transform))return null;return n}function MC(e,t){for(let n of[0,1,2,3,4,5,8])if(e[n]!==t[n])return null;return[t[6]-e[6],t[7]-e[7]]}function CC(e,t){return Math.abs(e-t)<=1e-6*Math.max(1,Math.abs(e),Math.abs(t))}function _C(e,t){if(e===t)return!0;if((e?.length??0)!==(t?.length??0))return!1;for(let n=0;n<(e?.length??0);n++){let r=e[n],o=t[n];if(r.program.id!==o.program.id||r.reach!==o.reach||!$$(r.uniforms,o.uniforms))return!1}return!0}function $$(e,t){if(e===t)return!0;let n=Object.keys(e??{});return n.length!==Object.keys(t??{}).length?!1:n.every(r=>Y$(e[r],t?.[r]))}function Y$(e,t){return typeof e=="number"||t===void 0||typeof t=="number"?e===t:"id"in e||"id"in t?"id"in e&&"id"in t&&e.id===t.id:pa(e,t)}function aP(e,t){return e===void 0?t===void 0:t!==void 0&&pa(e,t)}function DC(e,t){return e===void 0||t===void 0?e===t:e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function q$(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n].path!==t[n].path||!pa(e[n].transform,t[n].transform))return!1;return!0}function pa(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function BC(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function HC(e,t,n){let r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,t,n,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null);let o=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,o),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0),e.bindFramebuffer(e.FRAMEBUFFER,null),{texture:r,fbo:o}}function GC(e,t){e.deleteFramebuffer(t.fbo),e.deleteTexture(t.texture)}function UC(e,t,n,r){let o=l=>{let u=e.createRenderbuffer();return e.bindRenderbuffer(e.RENDERBUFFER,u),r>0?e.renderbufferStorageMultisample(e.RENDERBUFFER,r,l,t,n):e.renderbufferStorage(e.RENDERBUFFER,l,t,n),u},i=o(e.RGBA8),s=o(e.DEPTH24_STENCIL8);e.bindRenderbuffer(e.RENDERBUFFER,null);let a=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,a),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,i),e.framebufferRenderbuffer(e.FRAMEBUFFER,e.DEPTH_STENCIL_ATTACHMENT,e.RENDERBUFFER,s),e.bindFramebuffer(e.FRAMEBUFFER,null),{fbo:a,color:i,stencil:s,width:t,height:n,samples:r,resolved:null}}function WC(e,t){e.deleteFramebuffer(t.fbo),e.deleteRenderbuffer(t.color),e.deleteRenderbuffer(t.stencil),t.resolved&&(e.deleteFramebuffer(t.resolved.fbo),e.deleteRenderbuffer(t.resolved.color))}function VC(e,t,n,r,o,i=0,s=0){let a=e.isEnabled(e.SCISSOR_TEST),l=e.getParameter(e.READ_FRAMEBUFFER_BINDING)??null,u=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING)??null;if(e.disable(e.SCISSOR_TEST),e.bindFramebuffer(e.READ_FRAMEBUFFER,t.fbo),t.samples>0&&(i!==0||s!==0||r!==t.width||o!==t.height)){let c=X$(e,t);e.bindFramebuffer(e.DRAW_FRAMEBUFFER,c),e.blitFramebuffer(0,0,r,o,0,0,r,o,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,c)}e.bindFramebuffer(e.DRAW_FRAMEBUFFER,n.fbo),e.blitFramebuffer(0,0,r,o,i,s,i+r,s+o,e.COLOR_BUFFER_BIT,e.NEAREST),e.bindFramebuffer(e.READ_FRAMEBUFFER,l),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,u),a&&e.enable(e.SCISSOR_TEST)}function X$(e,t){if(t.resolved)return t.resolved.fbo;let n=e.createRenderbuffer();e.bindRenderbuffer(e.RENDERBUFFER,n),e.renderbufferStorage(e.RENDERBUFFER,e.RGBA8,t.width,t.height),e.bindRenderbuffer(e.RENDERBUFFER,null);let r=e.createFramebuffer(),o=e.getParameter(e.DRAW_FRAMEBUFFER_BINDING);return e.bindFramebuffer(e.DRAW_FRAMEBUFFER,r),e.framebufferRenderbuffer(e.DRAW_FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.RENDERBUFFER,n),e.bindFramebuffer(e.DRAW_FRAMEBUFFER,o),t.resolved={fbo:r,color:n},r}var zC=1e-4,KC=1/8,J$=1024,Th=class{gl;budget;samples;surfaces=new Map;scratches=new Map;width=0;height=0;frame=0;stamp=[];tile=J$;composited=0;redrawn=0;declined=0;constructor(t,n){this.gl=t,this.budget=n;let r=t.getParameter(t.SAMPLES);this.samples=typeof r=="number"&&r>1?r:0}get bytes(){let t=this.keptBytes();for(let[n,r]of this.scratches)t+=r.width*r.height*(Math.max(1,n)*8+(r.resolved?4:0));return t}setBudget(t){this.budget=t,this.keptBytes()>t&&this.releaseAll()}beginFrame(t){this.frame++,this.stamp=t,this.composited=0,this.redrawn=0,this.declined=0}lookup(t,n,r,o,i=!0,s){this.fitTo(n,r);let a={x:0,y:0,width:n,height:r},l=this.surfaces.get(t);if(!l?.key||l.samples!==(i?this.samples:0)||!BC(l.stamp,this.stamp))return{kind:"redraw",window:a};let u=[o.transform[6],o.transform[7]],c=l.seen!==null&&l.seen[0]===u[0]&&l.seen[1]===u[1];if(FC(l.key,o))return l.frame=this.frame,l.seen=u,this.composited++,{kind:"kept",pixels:lP(l,0,0)};let d=LC(l.key,o),f=s!==void 0&&l.reach!==null,p=Math.round(n*KC),h=Math.round(r*KC),m={x:-p,y:-h,width:n+2*p,height:r+2*h};if(!d)return{kind:"redraw",window:l.panned&&f?m:a};if(l.seen=u,l.frame=this.frame,!f)return c?{kind:"redraw",window:a}:(this.declined++,{kind:"through"});let y=l.panned&&l.reach.window.width===n&&l.reach.window.height===r;l.panned=!0;let b=d[0]*s,x=d[1]*s,w=Math.round(b),g=Math.round(x),P=Math.abs(b-w)<=zC&&Math.abs(x-g)<=zC;return P&&Q$(l.reach,w,g,n,r)?(this.composited++,{kind:"kept",pixels:lP(l,w,g)}):(!P||y)&&!c?(this.declined++,{kind:"through"}):{kind:"redraw",window:m}}reserve(t,n,r,o,i=!0,s){this.fitTo(n,r);let a={x:0,y:0,width:n,height:r};if(s&&(s.window.width>n||s.window.height>r)&&!this.fits(t,o))return this.reserve(t,n,r,Hi(s.box,a),i,{box:s.box,window:a});let l=this.surfaces.get(t),u=o.width===0||o.height===0,c=i?this.samples:0,d=this.scratches.get(c),f=Math.max(d?.width??0,u?0:Math.min(o.width,this.tile)),p=Math.max(d?.height??0,u?0:Math.min(o.height,this.tile));if(!this.fits(t,o))return this.declined++,null;let h=l??{gl:null,rect:o,key:null,stamp:[],frame:this.frame,samples:c,reach:null,panned:!1,seen:null};this.surfaces.set(t,h),this.fitSurface(h,o),h.frame=this.frame,h.samples=c,this.redrawn++;let m=h.gl?this.scratchFor(c,f,p):null,y=h.rect;return{fbo:m?.fbo??null,rect:y,tiles:m?Z$(y,this.tile):[],resolve:b=>{!m||!h.gl||VC(this.gl,m,h.gl,b.width,b.height,b.x-y.x,y.y+y.height-b.y-b.height)},commit:b=>(h.key=OC(b),h.stamp=this.stamp,h.reach=s?{box:{...s.box},window:{...s.window}}:null,h.seen=[b.transform[6],b.transform[7]],lP(h,0,0))}}decline(){this.declined++}endFrame(){let t=new Map;for(let[n,r]of this.surfaces){if(r.frame===this.frame){let o=t.get(r.samples)??{w:0,h:0},{width:i,height:s}=r.rect;t.set(r.samples,{w:Math.max(o.w,Math.min(i,this.tile)),h:Math.max(o.h,Math.min(s,this.tile))});continue}this.deleteSurface(r),this.surfaces.delete(n)}for(let[n,r]of this.scratches){let o=t.get(n)??{w:0,h:0};(this.redrawn===0||r.width>o.w||r.height>o.h)&&this.dropScratch(n)}}releaseAll(){for(let t of this.surfaces.values())this.deleteSurface(t);this.surfaces.clear();for(let t of[...this.scratches.keys()])this.dropScratch(t)}fitTo(t,n){t===this.width&&n===this.height||(this.releaseAll(),this.width=t,this.height=n)}fits(t,n){let r=this.surfaces.get(t);return this.keptBytes()+uP(n)-(r?uP(r.rect):0)<=this.budget}keptBytes(){let t=0;for(let n of this.surfaces.values())t+=uP(n.rect);return t}scratchFor(t,n,r){let o=this.scratches.get(t);if(o&&o.width===n&&o.height===r)return o;this.dropScratch(t);let i=UC(this.gl,n,r,t);return this.scratches.set(t,i),i}fitSurface(t,n){let r=t.rect;t.rect={...n},!(t.gl&&r.width===n.width&&r.height===n.height)&&(this.deleteSurface(t),n.width>0&&n.height>0&&(t.gl=HC(this.gl,n.width,n.height)))}deleteSurface(t){t.gl&&GC(this.gl,t.gl),t.gl=null}dropScratch(t){let n=this.scratches.get(t);n&&WC(this.gl,n),this.scratches.delete(t)}};function lP(e,t,n){let{rect:r}=e;return{texture:e.gl?.texture??null,rect:t===0&&n===0?r:{...r,x:r.x+t,y:r.y+n}}}function Q$(e,t,n,r,o){let i=Hi(e.box,{x:-t,y:-n,width:r,height:o});if(i.width===0||i.height===0)return!0;let s=e.window;return i.x>=s.x&&i.y>=s.y&&i.x+i.width<=s.x+s.width&&i.y+i.height<=s.y+s.height}function Z$(e,t){let n=[];for(let r=0;r<e.height;r+=t)for(let o=0;o<e.width;o+=t)n.push({x:e.x+o,y:e.y+r,width:Math.min(t,e.width-o),height:Math.min(t,e.height-r)});return n}function uP(e){return e.width*e.height*4}function cP(e){let t=e.createTexture();return t?(e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,1,1,0,e.RGBA,e.UNSIGNED_BYTE,new Uint8Array([255,255,255,255])),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.NEAREST),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindTexture(e.TEXTURE_2D,null),t):null}var dP=new Set(["lowp","mediump","highp","precise","invariant","centroid","flat","smooth","noperspective"]),fP=/^[A-Za-z_]\w*$/,jC=16;function pP(e){return[...qC(e).names]}function hP(e){return qC(e).arrays}function qC(e){let{code:t,defines:n}=e8(e),r=$C(t),o=new Map,i=new Map,s=new Set,a=new Map,l=(y,b)=>{if(b>jC)return null;let x=null;for(let w of n.get(y)??[]){let g=YC($C(w),P=>l(P,b+1));g!==null&&(x===null||g>x)&&(x=g)}return x??o.get(y)??null},u=(y,b)=>YC(r.slice(y,b),x=>l(x,0)),c=y=>{let b=0;for(let x=y;x<r.length;x++)if(r[x]==="("||r[x]==="["||r[x]==="{")b++;else if((r[x]===")"||r[x]==="]"||r[x]==="}")&&--b===0)return x;return r.length},d=y=>{if(r[y]!=="[")return[void 0,y];let b=c(y);return[u(y+1,b),b+1]},f=(y,b)=>{let x=[];for(;y<r.length&&r[y]!==";"&&r[y]!=="}";){let w=r[y],[g,P]=d(y+1);for(y=P,fP.test(w)&&x.push({name:w,size:g===void 0?b:g});y<r.length&&r[y]!==","&&r[y]!==";"&&r[y]!=="}";)y=r[y]==="("||r[y]==="["||r[y]==="{"?c(y)+1:y+1;r[y]===","&&y++}return[x,y]},p=y=>{let b=y+1,x=r[b]!=="{"?r[b++]:void 0,w=[];if(r[b]!=="{")return[w,b];let g=c(b);for(b++;b<g;){for(;dP.has(r[b]);)b++;let P;r[b]==="struct"?[P,b]=p(b):P=r[b++];let[S,v]=d(b),[A,N]=f(v,S);for(let M of A)M.size!==null&&w.push({type:P,name:M.name,size:M.size??null});b=N+1}if(x){let P=i.get(x)??[];for(let S of w)P.some(v=>v.name===S.name)||P.push(S);i.set(x,P)}return[w,g+1]},h=(y,b,x,w)=>{if(w>jC)return;if(x!==null){if(typeof b=="string"&&!i.has(b)){let P=a.get(y);(!P||x>P.size)&&a.set(y,{type:b,size:x})}for(let P=0;P<x;P++)h(`${y}[${P}]`,b,null,w+1);return}let g=typeof b=="string"?i.get(b):b;if(!g){s.add(y);return}for(let P of g)h(`${y}.${P.name}`,P.type,P.size,w+1)},m=0;for(let y=0;y<r.length;y++){let b=r[y];if(b==="{")m++;else if(b==="}")m--;else if(b==="struct")y=p(y)[1]-1;else if(m===0&&b==="const"){let x=y+1;for(;dP.has(r[x]);)x++;if((r[x]==="int"||r[x]==="uint")&&fP.test(r[x+1]??"")&&r[x+2]==="="){let w=x+3;for(;w<r.length&&r[w]!==";";)w++;let g=u(x+3,w),P=o.get(r[x+1]);g!==null&&(P===void 0||g>P)&&o.set(r[x+1],g)}}else if(m===0&&b==="uniform"){let x=y+1;for(;dP.has(r[x]);)x++;let w;if(r[x]==="struct")[w,x]=p(x);else if(r[x+1]==="{"){for(x=c(x+1)+1;x<r.length&&r[x]!==";";)x++;y=x;continue}else w=r[x++];let[g,P]=d(x),[S,v]=f(P,g);for(let A of S)A.size!==null&&h(A.name,w,A.size??null,0);y=v}}return{names:s,arrays:a}}function e8(e){let t=e.replace(/\\\r?\n/g,""),n="";for(let i=0;i<t.length;i++)if(t[i]==="/"&&t[i+1]==="/"){for(;i<t.length&&t[i]!==`
423
423
  `;)i++;n+=`
424
424
  `}else if(t[i]==="/"&&t[i+1]==="*"){let s=t.indexOf("*/",i+2);i=s<0?t.length:s+1,n+=" "}else n+=t[i];let r=new Map;return{code:n.split(`
425
425
  `).map(i=>{if(!/^\s*#/.test(i))return i;let s=/^\s*#\s*define\s+([A-Za-z_]\w*)(\(?)(.*)$/.exec(i);return s&&!s[2]&&r.set(s[1],[...r.get(s[1])??[],s[3].trim()]),""}).join(`
426
- `),defines:r}}function DC(e){return e.match(/[A-Za-z_]\w*|\d[\w.]*|\S/g)??[]}function bj(e){let t=/^(?:0[xX]([0-9a-fA-F]+)|(0[0-7]*)|([1-9]\d*))[uU]?$/.exec(e);return t?t[1]!==void 0?parseInt(t[1],16):t[2]!==void 0?parseInt(t[2],8):parseInt(t[3],10):null}function BC(e,t){let n=0,r=()=>{let a=e[n++];if(a==="("){let l=i();return e[n++]===")"?l:null}if(a==="-"){let l=r();return l===null?null:-l}return a==="+"?r():a===void 0?null:bj(a)??(Ew.test(a)?t(a):null)},o=()=>{let a=r();for(;a!==null&&(e[n]==="*"||e[n]==="/"||e[n]==="%");){let l=e[n++],u=r();if(u===null||l!=="*"&&u===0)return null;a=l==="*"?a*u:l==="/"?Math.trunc(a/u):a%u}return a},i=()=>{let a=o();for(;a!==null&&(e[n]==="+"||e[n]==="-");){let l=e[n++],u=o();if(u===null)return null;a=l==="+"?a+u:a-u}return a},s=i();return n===e.length&&s!==null&&s>=0?s:null}function xj(e,t){return[...bC,...Mw(e),...Mw(t)]}function Ow(e,t){let n=t.vert===""?yC:t.vert,r=new Jr(e,n,t.frag);return r.lookupUniforms(xj(n,t.frag)),r.lookupUniformArrays(new Map([...Cw(n),...Cw(t.frag)])),r.lookupAttributes(gC),r}var UC={composited:0,redrawn:0,declined:0,bytes:0};function nh(){return typeof performance<"u"?performance.now():Date.now()}var wj={pattern:[SA,RA],gradient:[kA,NA],texture:[vA,IA]},ju=class{gl;stats={drawCalls:0,ms:0,spans:[],retained:UC};pathFill;pathFillVColor;batchFill;batchVariants;gradFill;patternFill;glyphPaintPrograms=new Map;meshCache;textureCache;imageCache;gradRamps;programRegistry=new Map;programSources=new Map;quadVbo=null;quadIbo=null;drawBatch;whiteTexture=null;groupState=new gf;widthCss;heightCss;dpr;canvas=null;lossTarget=null;target=null;effectTargets;retained;programEpoch=0;paintScratch;imageMinification;flattenTolerance;bakeBudget;textOutlineMinScreenSize;contextLost=!1;boundOnLost=t=>this.onContextLost(t);boundOnRestored=()=>this.onContextRestored();disposed=!1;paintResources=tl();constructor(t){if(!t.gl&&!t.canvas)throw new Error("WeaselRenderer requires either gl or canvas");let n=t.gl??t.canvas.getContext("webgl2",{stencil:!0});if(!n)throw new Error("WeaselRenderer: WebGL2 not available");this.gl=n,this.effectTargets=new eh(this.gl),this.retained=new th(this.gl,t.retainBudget??402653184),this.paintScratch=new Zd(this.gl);let r=typeof this.gl.getContextAttributes=="function"?this.gl.getContextAttributes():null;if(r&&r.stencil===!1)throw new Error("WeaselRenderer: the supplied WebGL2 context has no stencil buffer. Create it with { stencil: true } \u2014 clips and even-odd fills need one.");this.widthCss=t.width,this.heightCss=t.height,this.dpr=t.dpr,this.imageMinification=t.imageMinification??"auto",this.flattenTolerance=t.flattenTolerance,this.bakeBudget=t.bakeBudget??Jo,this.textOutlineMinScreenSize=t.textOutlineMinScreenSize??Qp,this.canvas=t.canvas??null,this.canvas&&(this.canvas.width=Math.round(t.width*t.dpr),this.canvas.height=Math.round(t.height*t.dpr));let o=this.canvas??this.gl.canvas??null;o&&typeof o.addEventListener=="function"&&(this.lossTarget=o,this.lossTarget.addEventListener("webglcontextlost",this.boundOnLost),this.lossTarget.addEventListener("webglcontextrestored",this.boundOnRestored)),this.applyGlState(),this.applyTarget(),this.pathFill=new An(this.gl,bA),this.pathFillVColor=new An(this.gl,xA),this.gradFill=new An(this.gl,wA),this.patternFill=new An(this.gl,PA),this.batchVariants=new Jd(this.gl),this.batchFill=rb(this.gl),this.meshCache=new Hl(this.gl),this.textureCache=new Ul(this.gl),this.imageCache=new Ms(this.gl,this.imageMinification),this.gradRamps=new $l(this.gl),this.uploadQuadGeometry(),this.drawBatch=new Ku(this.gl,this.batchFill),this.whiteTexture=Nw(this.gl)}lazyPrograms(){return[this.pathFill,this.pathFillVColor,this.gradFill,this.patternFill,...this.batchVariants.lazy()]}uploadQuadGeometry(){let t=this.gl;if(this.quadVbo=t.createBuffer(),this.quadIbo=t.createBuffer(),!this.quadVbo||!this.quadIbo)throw new Error("WeaselRenderer: failed to create quad geometry buffers");t.bindBuffer(t.ARRAY_BUFFER,this.quadVbo),t.bufferData(t.ARRAY_BUFFER,xC,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.quadIbo),t.bufferData(t.ELEMENT_ARRAY_BUFFER,wC,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}registerProgram(t){if(this.disposed)return;let n=Nn(t.id);if(!n)throw new Error(`WeaselRenderer.registerProgram: program "${t.id}" not found in source registry. Call the module-level registerProgram() first.`);this.installProgram(t.id,n,Ow(this.gl,n))}installProgram(t,n,r){let o=this.programRegistry.get(t);o&&(this.gl.deleteProgram(o.handle),this.programEpoch++),this.programRegistry.set(t,r),this.programSources.set(t,n)}refreshPrograms(){for(let[t,n]of this.programSources){let r=Nn(t);if(!(!r||r===n)){if(r.vert===n.vert&&r.frag===n.frag){this.programSources.set(t,r);continue}try{this.installProgram(t,r,Ow(this.gl,r))}catch(o){this.programSources.set(t,r),console.error(`weasel: failed to recompile re-registered program "${t}"; still drawing the previous one:`,o)}}}}ensureProgram(t){let n=this.programRegistry.get(t);if(n)return n;if(this.disposed||!Nn(t))return null;try{this.registerProgram({id:t})}catch(r){return console.error(`weasel: failed to compile paint program "${t}":`,r),null}return this.programRegistry.get(t)??null}glyphPaintProgram(t){let n=this.glyphPaintPrograms.get(t);if(n)return n;let[r,o]=wj[t],i=new Jr(this.gl,TA,r);return i.lookupUniforms(o),i.lookupAttributes(EA),this.glyphPaintPrograms.set(t,i),i}applyGlState(){let t=this.gl;t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.clearColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.bindVertexArray(null),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1)}deviceRect(){let t=this.target?.origin.x??0,n=this.target?.origin.y??0,r=Math.round(t*this.dpr),o=Math.round(n*this.dpr),i=Math.round((t+this.widthCss)*this.dpr)-r;return{x:r,y:o,width:i,height:Math.round((n+this.heightCss)*this.dpr)-o}}applyTarget(){let t=this.gl,{x:n,y:r,width:o,height:i}=this.glRect();if(t.viewport(n,r,o,i),!this.target){t.disable(t.SCISSOR_TEST);return}t.scissor(n,r,o,i),t.enable(t.SCISSOR_TEST)}glRect(){let{x:t,y:n,width:r,height:o}=this.deviceRect();return this.target?{x:t,y:this.gl.drawingBufferHeight-n-o,width:r,height:o}:{x:0,y:0,width:r,height:o}}setTarget(t){this.target=t,this.applyTarget()}getTarget(){return this.target}isContextLost(){return this.contextLost}onContextLost(t){t.preventDefault(),this.contextLost=!0}onContextRestored(){this.contextLost=!1,this.applyGlState(),this.applyTarget(),this.effectTargets.releaseAll(),this.retained.releaseAll(),this.paintScratch.release(),this.paintResources.release(),this.paintResources=tl();for(let t of this.lazyPrograms())t.abandon();this.batchFill=rb(this.gl),this.glyphPaintPrograms.clear(),this.meshCache=new Hl(this.gl),this.textureCache=new Ul(this.gl),this.imageCache.abandon(),this.imageCache=new Ms(this.gl,this.imageMinification),this.gradRamps=new $l(this.gl),this.uploadQuadGeometry(),this.drawBatch=new Ku(this.gl,this.batchFill),this.whiteTexture=Nw(this.gl);for(let t of this.programRegistry.keys()){let n=Nn(t);if(n)try{this.programRegistry.set(t,Ow(this.gl,n)),this.programSources.set(t,n)}catch(r){console.error(`weasel: failed to recompile program "${t}" after context restore:`,r)}}}dispose(){if(this.disposed)return;this.disposed=!0;let t=this.gl;this.lossTarget&&(this.lossTarget.removeEventListener("webglcontextlost",this.boundOnLost),this.lossTarget.removeEventListener("webglcontextrestored",this.boundOnRestored)),this.meshCache.dispose(),this.paintResources.release();for(let n of this.lazyPrograms())n.release();for(let n of[this.batchFill,...this.glyphPaintPrograms.values()])t.deleteProgram(n.handle);this.glyphPaintPrograms.clear();for(let n of this.programRegistry.values())t.deleteProgram(n.handle);this.programRegistry.clear(),this.programSources.clear(),this.textureCache.free(),this.imageCache.dispose(),this.gradRamps.free(),this.quadVbo&&t.deleteBuffer(this.quadVbo),this.quadIbo&&t.deleteBuffer(this.quadIbo),this.drawBatch.dispose(),this.whiteTexture&&t.deleteTexture(this.whiteTexture),this.whiteTexture=null,this.effectTargets.releaseAll(),this.retained.releaseAll(),this.paintScratch.release()}render(t,n,r){if(this.contextLost||this.disposed)return;let o=nh(),i={drawCalls:0},s=[];this.stats={drawCalls:0,ms:0,spans:s,retained:UC};let a=this.gl;this.meshCache.drainPendingDeletes(),this.imageCache.beginFrame(),this.textureCache.sweep(pi),this.refreshPrograms(),this.retained.beginFrame([qo(),pi.getVersion(),Bu.getVersion(),this.programEpoch,this.flattenTolerance,this.widthCss,this.heightCss,this.dpr]),od(this.bakeBudget),this.groupState.reset(),this.drawBatch.reset(),this.effectTargets.reclaim(),a.bindFramebuffer(a.FRAMEBUFFER,null),this.applyGlState(),this.applyTarget(),this.target?.clear!==!1&&(a.stencilMask(255),a.clear(a.COLOR_BUFFER_BIT|a.STENCIL_BUFFER_BIT));let l=this.deviceRect(),u=this.glRect(),{pathFill:c,pathFillVColor:d,gradFill:f,patternFill:p}=this,h={gl:a,get pathFill(){return c.get()},get pathFillVColor(){return d.get()},batchFill:this.batchFill,batchVariants:this.batchVariants,get gradFill(){return f.get()},get patternFill(){return p.get()},meshCache:this.meshCache,textureCache:this.textureCache,imageCache:this.imageCache,gradRamps:this.gradRamps,programRegistry:this.programRegistry,ensureProgram:x=>this.ensureProgram(x),glyphPaintProgram:x=>this.glyphPaintProgram(x),quadVbo:this.quadVbo,quadIbo:this.quadIbo,drawBatch:this.drawBatch,whiteTexture:this.whiteTexture,state:this.groupState,widthCss:this.widthCss,heightCss:this.heightCss,clipDepth:0,clipStack:[],flattenTolerance:lR(this.flattenTolerance,this.dpr),textOutlineMinScreenSize:this.textOutlineMinScreenSize,viewMatrix:n,screenMatrix:r?.screen,effectTargets:this.effectTargets,retained:this.retained,paintScratch:this.paintScratch,renderTarget:null,fragOrigin:[u.x,u.y],deviceWidth:l.width,deviceHeight:l.height,restoreTargetRect:()=>this.applyTarget(),paintResources:this.paintResources,stats:i};this.drawBatch.clip=null;let m=r?.spans??[],g=0;for(let x=0;x<m.length;x++){let w=m[x];for(;g<w.start;g++)_i(h,t[g]);let y=i.drawCalls,P=nh();for(;g<w.end;g++)_i(h,t[g]);x===m.length-1&&g>=t.length&&ye(h),s.push({id:w.id,drawCalls:i.drawCalls-y,ms:nh()-P})}for(;g<t.length;g++)_i(h,t[g]);ye(h),this.meshCache.freeTransient();let b=this.retained;b.endFrame(),this.stats.retained={composited:b.composited,redrawn:b.redrawn,declined:b.declined,bytes:b.bytes},this.stats.drawCalls=i.drawCalls,this.stats.ms=nh()-o}lastFrameStats(){return this.stats}setFlattenTolerance(t){this.flattenTolerance=t}setRetainBudget(t){this.retained.setBudget(t??402653184)}setImageMinification(t){let n=t??"auto";n!==this.imageMinification&&(this.imageMinification=n,this.imageCache.dispose(),this.imageCache=new Ms(this.gl,n))}resize(t){this.widthCss=t.width,this.heightCss=t.height,this.dpr=t.dpr,this.canvas&&(this.canvas.width=Math.round(t.width*t.dpr),this.canvas.height=Math.round(t.height*t.dpr)),this.applyTarget()}_gl(){return this.gl}_pathFill(){return this.pathFill.get()}_pathFillVColor(){return this.pathFillVColor.get()}_drawBatch(){return this.drawBatch}_batchFill(){return this.batchFill}_batchVariants(){return this.batchVariants}_gradFill(){return this.gradFill.get()}_patternFill(){return this.patternFill.get()}_meshCache(){return this.meshCache}_textureCache(){return this.textureCache}_imageCache(){return this.imageCache}_gradRamps(){return this.gradRamps}_groupState(){return this.groupState}_widthCss(){return this.widthCss}_heightCss(){return this.heightCss}_dpr(){return this.dpr}};Pe();var Pj={...Ie};function Fw(e,t,n,r,o,i,s,a,l,u=1){let c=Qf(Pj,r,a,u);return{kind:"text",x:e,y:t,runs:xu(n,c,u),align:c.align,direction:c.direction,justify:c.align==="justify",maxWidth:o,style:r??{},height:i,verticalAlign:s,width:l}}function Lw(e,t=1){let{runs:n,opts:r}=Sp(e,t);return{kind:"text",x:e.x,y:e.y,runs:Tj(n,e),align:r.align,direction:r.direction,justify:r.justify,maxWidth:r.maxWidth,width:r.alignWidth,style:e.style??{},height:e.height,verticalAlign:e.verticalAlign}}function Tj(e,t){return e.every(n=>WC(n.fill?.paint)&&WC(n.stroke?.paint))?e:e.map(n=>{let r=n.fill&&Vt(n.fill,t),o=n.stroke?.paint&&Oi(n.stroke.paint,t);return{...n,fill:r,stroke:n.stroke&&{...n.stroke,paint:o||void 0}}})}function WC(e){return e==null||Ht(e)}function VC(e){return typeof e=="number"?{x:e,y:e}:e}function _w(e,t){let n=VC(t.pan),r=VC(t.zoom??1),o=t.anchor??{x:0,y:0};return{x:o.x+(e.x-o.x)*n.x,y:o.y+(e.y-o.y)*n.y,scale:{x:1+(e.scale.x-1)*r.x,y:1+(e.scale.y-1)*r.y}}}function rh(e,t){let n=_w(e,t),r=e.scale.x/n.scale.x,o=e.scale.y/n.scale.y;return{scale:{x:r,y:o},offset:{x:n.x-r*e.x,y:n.y-o*e.y}}}function Dw(e,t){return{x:t.x*e.scale.x+e.offset.x,y:t.y*e.scale.y+e.offset.y}}function Sj(e,t){let n=t({x:e.x,y:e.y}),r=t({x:e.x+e.width,y:e.y+e.height});return{x:Math.min(n.x,r.x),y:Math.min(n.y,r.y),width:Math.abs(r.x-n.x),height:Math.abs(r.y-n.y)}}function KC(e,t){return{...t,...Sj(t,n=>Dw(e,n))}}function Bw(e,t){if(e===t)return null;let n=e??zC,r=t??zC,o=r.scale.x/n.scale.x,i=r.scale.y/n.scale.y,s={scale:{x:o,y:i},offset:{x:r.offset.x-n.offset.x*o,y:r.offset.y-n.offset.y*i}};return s.scale.x===1&&s.scale.y===1&&s.offset.x===0&&s.offset.y===0?null:s}var zC={scale:{x:1,y:1},offset:{x:0,y:0}};function Hw(e){return[e.scale.x,0,0,e.scale.y,e.offset.x,e.offset.y]}var kj=["weasel.debug","weaseldraw.debug"],Gw=null;function vj(){let e={all:!1,set:new Set};if(typeof localStorage>"u")return e;try{for(let t of kj){let n=localStorage.getItem(t);if(!(n==null||n===""))return n==="1"||n==="true"||n==="*"?{all:!0,set:new Set}:{all:!1,set:new Set(n.split(/[\s,]+/).filter(Boolean))}}return e}catch{return e}}function Aj(){return Gw===null&&(Gw=vj()),Gw}function oh(e){let t=Aj();return t.all?!0:e===void 0?t.set.size>0:t.set.has(e)}function ih(e,...t){oh(e)&&console.debug(`[${e}]`,...t)}function It(e,...t){oh(e)&&console.warn(`[${e}]`,...t)}Z();function Et(e){return e.closure!=="identity"}function zt(e,t,n){let r=[t],o=new Set([t]),i=e.getParent(t);for(;i!==null&&!o.has(i);)o.add(i),(e.definesFrame?.(i)??!0)&&r.push(i),i=e.getParent(i);let s=e.getPose(r[r.length-1]),a=e.childFrame;for(let l=r.length-2;l>=0;l--){let u=a===void 0?s:a.call(e,r[l+1],s);s=n(u,e.getPose(r[l]))}return s}function aa(e,t,n){return $C(e,t,zt(e,t,n))}function $C(e,t,n){return e.childFrame===void 0||!(e.definesFrame?.(t)??!0)?n:e.childFrame(t,n)}function la(e,t,n,r,o){let i=qn(e,n);return i===null?t:o(aa(e,i,r),t)}function qn(e,t){let n=new Set,r=t;for(;r!==null&&!n.has(r);){if(e.definesFrame?.(r)??!0)return r;n.add(r),r=e.getParent(r)}return null}var jC=new WeakMap;function YC(e){let t=jC.get(e);if(t!==void 0)return t;let n=new WeakMap,r=(o,i)=>{if(typeof o!="object"||o===null||typeof i!="object"||i===null)return e(o,i);let s=n.get(o);s===void 0&&n.set(o,s=new WeakMap);let a=s.get(i);return a===void 0&&s.set(i,a=e(o,i)),a};return jC.set(e,r),r}function qC(e,t,n){return{...e,x:e.x+t,y:e.y+n}}function Uw(e,t){return t===0&&e.rotation===void 0?e:{...e,rotation:t}}function XC(e,t,n){let[r,o,i,s]=ht(yl(-t),n),a=Math.abs(r-1)<1e-12&&Math.abs(o)<1e-12&&Math.abs(i)<1e-12&&Math.abs(s-1)<1e-12,l=Uw({...e},t);return a?delete l.transform:l.transform=[r,o,i,s],l}function JC(e,t,n){return{...e,x:t-e.width/2,y:n-e.height/2}}var QC=[1,0,0,1,0,0];function ZC(e,t,n,r,o){let i=Math.cos(n),s=Math.sin(n);return[e+(r-e)*i-(o-t)*s,t+(r-e)*s+(o-t)*i]}function Rj(e,t){let n=e.rotation??0,r=Vn(e)&&Ce(e);if(r){let[s,a]=wn(r,e.x+t.x+t.width/2,e.y+t.y+t.height/2),l=ht(r,Ce(t)??QC);return XC(JC(t,s,a),(t.rotation??0)+n,l)}let[o,i]=ZC(e.x+e.width/2,e.y+e.height/2,n,e.x+t.x+t.width/2,e.y+t.y+t.height/2);return Uw({...t,x:o-t.width/2,y:i-t.height/2},(t.rotation??0)+n)}function Nj(e,t){let n=e.rotation??0,r=Vn(e)&&ui(e);if(r){let[s,a]=wn(r,t.x+t.width/2,t.y+t.height/2),l=ht(r,Ce(t)??QC);return XC(JC(t,s-e.x,a-e.y),(t.rotation??0)-n,l)}let[o,i]=ZC(e.x+e.width/2,e.y+e.height/2,-n,t.x+t.width/2,t.y+t.height/2);return Uw({...t,x:o-e.x-t.width/2,y:i-e.y-t.height/2},(t.rotation??0)-n)}function Ij(e,t){return qC(e,-t.x,-t.y)}function Ej(e,t){let n=Ce(e);if(!n)return Ij(e,t);let[r,o,i,s]=n;return qC(e,-(r*t.x+i*t.y),-(o*t.x+s*t.y))}var sh={compose:Rj,decompose:Nj,closure:"rigid",scroll:Ej};var ua=!1;function e2(){ua=!0}function t2(e){let t=ua;ua=!1;try{return{value:e(),fonts:ua}}finally{ua=t||ua}}function Ww(){return rl()}var n2=4;function Vw(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ah(e,t=n2){if(t<=0)return e;if(Array.isArray(e))return e.map(n=>ah(n,t-1));if(Vw(e))return e.slice();if(Zt(e)){let n={...e};for(let r in n){let o=n[r];typeof o=="object"&&o!==null&&(n[r]=ah(o,t-1))}return n}return e}function No(e,t,n=n2){if(e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return Object.is(e,t);if(n<=0)return!1;let r=Object.getPrototypeOf(e);if(ts(r)){if(!ts(Object.getPrototypeOf(t)))return!1;let o=e,i=t,s=0;for(let a in o){s++;let l=o[a],u=i[a];if(l===u){if(u===void 0&&!(a in i))return!1;continue}if(!No(l,u,n-1))return!1}for(let a in i)if(--s<0)return!1;return!0}if(Array.isArray(e)||Vw(e)){let o=e;if(!(Array.isArray(t)||Vw(t)))return!1;let i=t;if(o.length!==i.length)return!1;for(let s=0;s<o.length;s++)if(!No(o[s],i[s],n-1))return!1;return!0}return!1}function $u(){return{nodes:[],poses:[],data:[],layers:[],paths:[],children:[],faces:null}}var zw=class{constructor(t,n,r){this.dep=t;this.record=n;this.index=r;this.node=t.node,this.pose=t.pose}dep;record;index;node;pose;get path(){return this.record.paths[this.index]=this.dep.path}get inherited(){return this.dep.inherited}get children(){let t=this.dep.children;if(t===void 0)return;let n=this.record.children[this.index]=$u();return r2(n,t)}};function r2(e,t){return e.nodes.length=0,e.poses.length=0,e.data.length=0,e.layers.length=0,e.paths.length=0,e.children.length=0,t.map((n,r)=>(e.nodes.push(n?.node),e.poses.push(n===void 0?void 0:ah(n.pose)),e.data.push(n?.node.data),e.layers.push(n?.node.layer),e.paths.push(void 0),e.children.push(void 0),n===void 0?void 0:new zw(n,e,r)))}function lh(e,t,n){let r=r2(e,t),o=Ww(),{value:i,fonts:s}=t2(()=>n(r));return e.faces=s?o:null,i}function uh(e,t,n){if(e.nodes.length!==t.length||e.faces!==null&&e.faces!==Ww())return!1;for(let r=0;r<t.length;r++)if(!o2(e,r,n(t[r])))return!1;return e.faces!==null&&e2(),!0}function o2(e,t,n){if(e.nodes[t]!==(n===void 0?void 0:n.node))return!1;if(n===void 0)return!0;if(e.data[t]!==n.node.data||e.layers[t]!==n.node.layer||!No(e.poses[t],n.pose))return!1;let r=e.paths[t];if(r!==void 0&&r!==n.path)return!1;let o=e.children[t];if(o===void 0)return!0;let i=n.children;return i===void 0||i.length!==o.nodes.length?!1:i.every((s,a)=>o2(o,a,s))}Z();Z();Pe();function i2(e,t,n){return{fill:Ne(e.fill,Ne(t?.fill,n?.fill)),stroke:Re(e.stroke,Re(t?.stroke,n?.stroke))}}var s2=new WeakMap;function a2(e){if(e.length===0)return null;let t=e.length===1?e[0].path:Mj(e.map(r=>r.path)),n=t===e[0].path?{...t}:t;return s2.set(n,e),n}function ch(e){return e==null?void 0:s2.get(e)}function Mj(e){return Jy(e.map(t=>t.kind==="rect"?Eg(ai(t)):t))}function u2(e,t,n,r,o){if(e===void 0||!Et(e))return null;let i={getPose:a=>r(a),getParent:a=>n(a)?.parent??null,definesFrame:a=>o(a)},s=qn(i,t.parent??null);return(a,l)=>{let u=qn(i,n(a)?.parent??null);if(u===s)return l;let c=u===null?l:e.compose(zt(i,u,e.compose),l);return s===null?c:e.decompose(zt(i,s,e.compose),c)}}function ca(e){let t=e;return typeof t=="object"&&t!==null&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"}function dh(e,t,n){return!ca(t)||!ca(n)||t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height?e:Yu(e,hr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height))}function c2(e,t,n){if(!ca(t)||!ca(n))return e;let r=ui(t),o=Ce(n),i=hr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height);return r!==null&&(i=ht(i,r)),o!==null&&(i=ht(o,i)),Yu(e,i)}function fh(e,t,n){if(!ca(t)||!ca(n))return e;let r=Ce(n),o=t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height;if(r===null&&o)return e;let i=hr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height);return Yu(e,r===null?i:ht(r,i))}function Yu(e,t){let n=t.join(","),r=l2.get(e);if(r?.key===n)return r.path;let o=ch(e),i=o===void 0?Rt(e,t):a2(o.map(s=>({...s,path:Rt(s.path,t)})));return l2.set(e,{key:n,path:i}),i}var l2=new WeakMap;var ph=Object.freeze([]);var qu=e=>Array.isArray(e?.dependsOn)?e.dependsOn:ph;function hh(e,t){let n=e.dependsOn;return n===void 0?ph:n==="children"?t(e.id):n}function d2(){let e=new Map,t=new Map;function n(r){let o=t.get(r);if(o!==void 0){for(let i of o){let s=e.get(i);s!==void 0&&(s.delete(r),s.size===0&&e.delete(i))}t.delete(r)}}return{add(r,o){if(n(r),o.length!==0){t.set(r,[...o]);for(let i of o){let s=e.get(i);s===void 0&&(s=new Set,e.set(i,s)),s.add(r)}}},remove(r){n(r)},clear(){e.clear(),t.clear()},isEmpty(){return e.size===0},dependentsOf(r){let o=e.get(r);return o===void 0?ph:[...o]},transitiveDependentsOf(r){let o=e.get(r);if(o===void 0)return ph;let i=new Set,s=[...o];for(;s.length>0;){let a=s.pop();if(!i.has(a)){i.add(a);for(let l of e.get(a)??[])s.push(l)}}return i}}}function f2(e,t){if(e===t)return!0;if(e===void 0||t===void 0||e==="children"||t==="children"||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function p2(){return new WeakMap}var da=new WeakMap,Or=0;function rt(e,t,n,r,o){if(typeof t!="string")return Cj(e,t,n,r,o);let i=da.get(e);i===void 0?(i={generation:Or,slots:new Map,drops:0},da.set(e,i)):i.generation!==Or&&(i.generation=Or,i.slots.clear());let s=e.data,a=i.slots.get(t);if(a!==void 0&&a.pose===n&&a.data===s&&a.also===o)return a.value;let l=r();return a!==void 0?(a.pose=n,a.data=s,a.also=o,a.value=l):i.slots.set(t,{pose:n,data:s,also:o,value:l}),l}function Cj(e,t,n,r,o){let i=t,s=e.data,a=da.get(e)?.drops??0,l=i.get(e);if(l!==void 0&&l.generation===Or&&l.pose===n&&l.data===s&&l.also===o&&(n===void 0||l.drops===a))return l.value;let u=r(),c=da.get(e)?.drops??0;return l!==void 0?(l.pose=n,l.data=s,l.also=o,l.value=u,l.generation=Or,l.drops=c):i.set(e,{pose:n,data:s,also:o,value:u,generation:Or,drops:c}),u}function Xu(){Or++}function h2(){return Or}function un(e){let t=da.get(e);if(t===void 0){da.set(e,{generation:Or,slots:new Map,drops:1});return}t.drops++;for(let[n,r]of t.slots)r.pose!==void 0&&t.slots.delete(n)}var Oj="kit:derivedPath",Kw=new Set,jw=0;function Fr(e,t,n,r=Oj){let o=e.derivePath;if(o===void 0)return null;let i=hh(e,n);if(i.length===0)return null;if(Kw.has(e.id))return jw++,null;Kw.add(e.id);let s=jw;try{let a=!1,l=rt(e,r,e.pose,()=>(a=!0,m2(e,o,i.map(t),{...$u(),path:null})));return!a&&!uh(l,i,t)&&m2(e,o,i.map(t),l),jw!==s&&un(e),l.path}finally{Kw.delete(e.id)}}function m2(e,t,n,r){return r.path=lh(r,n,o=>t(e,o)),r}Pe();function Ju(e){let t=e.data;return t?.fill===rn||t?.stroke===rn}var y2=new WeakMap;function fa(e,t){let n=e.data,r=n?.fill===rn,o=n?.stroke===rn,i=null,s=null;for(let u of t){if(!r&&!o)break;let c=u.data;r&&c?.fill!==rn&&(i=Ne(c?.fill),r=!1),o&&c?.stroke!==rn&&(s=Re(c?.stroke),o=!1)}let a=y2.get(e);if(a!==void 0&&a.fill===i&&a.stroke===s)return a;let l={fill:i,stroke:s};return y2.set(e,l),l}function pa(e,t){if(Ju(t))return fa(t,g2(n=>e.get(n),t))}function*g2(e,t){let n=new Set,r=t.parent??null;for(;r!==null&&!n.has(r);){n.add(r);let o=e(r);if(o===void 0)return;yield o,r=o.parent??null}}var Qu=()=>{throw new Error("documentOf: the document reading holds no overrides; write them to the scene")},Fj=Object.freeze({set:Qu,get:()=>{},read:e=>{},has:()=>!1,ids:()=>[],clear:Qu,clearAll:Qu,commit:Qu,subscribe:()=>()=>{},getGeneration:()=>0,hold:()=>Qu()});function mh(e){return e.overrides===Fj}var x2=Symbol("weasel.shownData"),$w=new WeakMap;function Tt(e,t){if(x2 in t)return t;let n=e.read(t.id)?.data;if(n===void 0)return t;let r=$w.get(t);if(r!==void 0&&r.data===n&&r.stored===t.data)return r.shown;let o=Lj(t,n(t.data));return $w.set(t,{stored:t.data,data:n,shown:o}),o}function Lj(e,t){return{...e,data:t,[x2]:!0}}function w2(e){return $w.get(e)?.shown}function ha(e){return{get:t=>{let n=e.get(t);return n===void 0?void 0:Tt(e.overrides,n)}}}var b2=new WeakMap;function yh(e,t){let n=e.getGeneration(),r=b2.get(e);return(r===void 0||r.at!==n)&&(r={at:n,any:e.ids().some(o=>e.read(o)?.data!==void 0)},b2.set(e,r)),r.any?t.map(o=>Tt(e,o)):t}var _j={effective:"kit:derivedPose",document:"kit:derivedPose:document"},Dj={effective:void 0,document:"kit:derivedPath:document"},Yw=new Set,qw=0;function T2(e){return mh(e)?"document":"effective"}function S2(e,t,n){let r=k2(e,t,n),o=r.derivePose;if(o===void 0)return null;let i=hh(r,e.childrenOf);if(i.length===0)return null;if(Yw.has(r.id))return qw++,null;Yw.add(r.id);let s=qw;try{let a=Qw(e,r,n),l=!1,u=rt(r,_j[n],r.pose,()=>(l=!0,P2(r,o,i.map(a),{...$u(),value:null})));return!l&&!uh(u,i,a)&&P2(r,o,i.map(a),u),qw!==s&&un(r),u.value}finally{Yw.delete(r.id)}}function P2(e,t,n,r){return r.value=lh(r,n,o=>t(e,o)),r}function Jw(e,t,n){let r=T2(e);return n===void 0?Zw(e,t,r):Qw(e,n,r)(t)}function Qw(e,t,n){let r=i=>Zw(e,i,n);if(t.dependsOn==="children")return r;let o=u2(e.composition,t,i=>e.get(i),i=>eP(e,e.get(i),n),i=>{let s=e.get(i);return s===void 0||lt(s)});return o===null?r:i=>{let s=r(i);if(s===void 0)return;let a=o(i,s.pose);return a===s.pose?s:new gh(s,a)}}var gh=class{constructor(t,n){this.dep=t;this.pose=n;this.node=t.node}dep;pose;node;get path(){let t=this.dep.path;return t===null?null:c2(t,this.dep.pose,this.pose)}get inherited(){return this.dep.inherited}};function Zw(e,t,n){let r=e.get(t);if(r!==void 0)return new Xw(e,r,n)}var Xw=class{constructor(t,n,r){this.source=t;this.reading=r;let o=k2(t,n,r);this.posed=o,this.node=o;let i=r==="effective"?t.overrides.read(o.id):void 0;this.shown=i?.path,this.pose=i?.pose??S2(t,o,r)??o.pose}source;reading;node;pose;shown;posed;get path(){if(this.shown!==void 0)return fh(this.shown,this.pose,this.pose);let{source:t,reading:n}=this;return Fr(this.posed,Qw(t,this.posed,n),r=>t.childrenOf(r),Dj[n])}get inherited(){let{source:t,reading:n}=this;return pa(n==="effective"?ha(t):t,this.posed)}get children(){let{source:t,reading:n}=this,r=t.composition,o=r&&Et(r)&&lt(this.posed)?r.compose:null;return t.childrenOf(this.posed.id).map(i=>{let s=Zw(t,i,n);return s===void 0||o===null?s:new gh(s,o(this.pose,s.pose))})}};function k2(e,t,n){return n==="effective"?Tt(e.overrides,t):t}function eP(e,t,n){if(n==="effective"){let r=e.overrides.read(t.id)?.pose;if(r!==void 0)return r}return S2(e,t,n)??t.pose}function Lr(e,t){return eP(e,t,"document")}function Xn(e,t){return eP(e,t,T2(e))}function lt(e){return!Bj(e)}function Bj(e){return e.dependsOn==="children"&&e.derivePose!==void 0}Z();Z();function tP(e){let t=Ce(e);if(!t)return{x:e.x,y:e.y,width:e.width,height:e.height};let n=1/0,r=1/0,o=-1/0,i=-1/0,s=[[e.x,e.y],[e.x+e.width,e.y],[e.x+e.width,e.y+e.height],[e.x,e.y+e.height]];for(let[a,l]of s){let[u,c]=wn(t,a,l);u<n&&(n=u),u>o&&(o=u),c<r&&(r=c),c>i&&(i=c)}return{x:n,y:r,width:o-n,height:i-r}}function v2(e){let t=1/0,n=1/0,r=-1/0,o=-1/0,i=!1;for(let s of e){if(!s)continue;let a=tP(s);i=!0,a.x<t&&(t=a.x),a.y<n&&(n=a.y);let l=a.x+a.width,u=a.y+a.height;l>r&&(r=l),u>o&&(o=u)}return i?{x:t,y:n,width:r-t,height:o-n}:null}Z();function _r(e,t){return e.forNode?.(t)??e}var Mt={getBounds:e=>e,remapBounds:(e,t,n)=>{let r=t.width===0?1:n.width/t.width,o=t.height===0?1:n.height/t.height;return{...e,x:n.x+(e.x-t.x)*r,y:n.y+(e.y-t.y)*o,width:e.width*r,height:e.height*o}},fromBounds:e=>({x:e.x,y:e.y,width:e.width,height:e.height}),translate:(e,t,n)=>({...e,x:e.x+t,y:e.y+n}),lerp:(e,t,n)=>({...e,x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,width:e.width+(t.width-e.width)*n,height:e.height+(t.height-e.height)*n}),axes:e=>[e.x,e.y,e.width,e.height].every(n=>typeof n=="number")?{count:5,names:["x","y","width","height","rotation"],angles:[4],to:n=>[n.x,n.y,n.width,n.height,n.rotation??0],from:n=>{let r={...e,x:n[0],y:n[1],width:n[2],height:n[3]};return(e.rotation!==void 0||n[4]!==0)&&(r.rotation=n[4]),r},add:(n,r)=>{let o={...n,x:n.x+r[0],y:n.y+r[1],width:n.width+r[2],height:n.height+r[3]},i=(n.rotation??0)+r[4];return(n.rotation!==void 0||i!==0)&&(o.rotation=i),o},write:(n,r,o)=>{r[o]=n.x,r[o+1]=n.y,r[o+2]=n.width,r[o+3]=n.height,r[o+4]=n.rotation??0}}:null,getRotation:e=>e.rotation??0,withRotation:(e,t)=>({...e,rotation:t})},Hj={getBounds:Mt.getBounds,remapBounds:Mt.remapBounds,translate:Mt.translate,lerp:Mt.lerp,axes:Mt.axes,fromBounds:e=>({x:e.x,y:e.y,width:e.width,height:e.height,rotation:0}),getRotation:e=>e.rotation,withRotation:(e,t)=>({...e,rotation:t})};function Di(e,t){return tP(nP(e,t))}function nP(e,t){let n=t.getBounds(e),r=t.getRotation?.(e)??n.rotation??0,o=Vn(e)??Vn(n);return!r&&!o?n:{...n,...r?{rotation:r}:{},...o?{transform:o}:{}}}function rP(e,t,n,r,o){if(r.translate)return o?r.translate(e,t,n,o):r.translate(e,t,n);let i=r.getBounds(e),s={x:i.x+t,y:i.y+n,width:i.width,height:i.height};return r.remapBounds(e,i,s)}function R2(){let e=new Map,t=Me(),n=0,r=()=>{n++,t.emit()};return{get:o=>e.get(o),set(o,i){let s=e.get(o);if(i===null||i.x===0&&i.y===0&&!i.z){if(s===void 0)return;e.delete(o)}else{if(s!==void 0&&s.x===i.x&&s.y===i.y&&(s.z??0)===(i.z??0))return;e.set(o,{...i})}r()},ids:()=>e.keys(),clearAll(){e.size!==0&&(e.clear(),r())},subscribe:t.subscribe,getGeneration:()=>n}}var A2=new WeakMap;function Gj(e,t,n){if(typeof t!="object"||t===null)return e(t,n);let r=A2.get(e);r===void 0&&A2.set(e,r=new WeakMap);let o=r.get(t);if(o!==void 0&&o.offset===n)return o.out;let i=e(t,n);return r.set(t,{offset:n,out:i}),i}function oP(e){let t=e.scroll,n=e.composition?.scroll;if(!(t===void 0||n===void 0)&&!(e.overrides!==void 0&&mh(e)))return(r,o)=>{let i=t.get(r);return i===void 0?o:Gj(n,o,i)}}function bh(e,t){let n=oP(e);return n===void 0?t:{...t,childFrame:n}}function N2(e,t,n,r=()=>!1){let{poses:o,composition:i}=e,s=new Set([t]),a=new Map,l=u=>{for(let c of e.childrenOf(u)){if(r(c))continue;s.add(c);let d=o.getParent(c),f=qn(o,d);if(f===null||!s.has(f)){let p=n(zt(o,c,i.compose),c);p!==null&&a.set(c,la(o,p,d,i.compose,i.decompose))}l(c)}};return l(t),a}function I2(e,t,n="animator: `axes`"){let{count:r,names:o}=e,i=[];for(let s of t){if(typeof s=="number"){if(!Number.isInteger(s)||s<0||s>=r)throw new Error(`${n} names axis ${s} of a target with ${r}`);i.push(s);continue}if(!o)throw new Error(`${n} names "${s}" on a target whose axes have no names`);let a=i.length,l=`${s}.`;for(let u=0;u<o.length;u++)(o[u]===s||o[u].startsWith(l))&&i.push(u);if(i.length===a){let u=o.slice(0,8).map(c=>`"${c}"`).join(", ");throw new Error(`${n} names "${s}", and the target's axes are ${u}${o.length>8?", \u2026":""}`)}}return i}function Uj(e){let[t,n,r,o]=e;switch(e.length){case 1:return{add:(i,s)=>({[t]:i[t]+s[0]}),write:(i,s,a)=>{s[a]=i[t]}};case 2:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n]}};case 3:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1],[r]:i[r]+s[2]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n],s[a+2]=i[r]}};case 4:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1],[r]:i[r]+s[2],[o]:i[o]+s[3]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n],s[a+2]=i[r],s[a+3]=i[o]}};default:return null}}function Zu(e){if(typeof e=="number")return{count:1,shape:"number",to:n=>[n],from:(n,r=0)=>n[r],add:(n,r)=>n+r[0],write:(n,r,o)=>{r[o]=n}};if(Array.isArray(e))return e.every(n=>typeof n=="number")?{count:e.length,shape:`array:${e.length}`,to:n=>n.slice(),from:(n,r=0)=>{let o=new Array(e.length);for(let i=0;i<o.length;i++)o[i]=n[r+i];return o},add:(n,r)=>{let o=new Array(e.length);for(let i=0;i<o.length;i++)o[i]=n[i]+r[i];return o},write:(n,r,o)=>{for(let i=0;i<e.length;i++)r[o+i]=n[i]}}:null;if(!Zt(e))return null;let t=Object.keys(e).sort();return t.length===0||!t.every(n=>typeof e[n]=="number")?null:{count:t.length,shape:`object:${JSON.stringify(t)}`,names:t,to:n=>t.map(r=>n[r]),from:(n,r=0)=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[r+i];return o},...Uj(t)??{add:(n,r)=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[t[i]]+r[i];return o},write:(n,r,o)=>{for(let i=0;i<t.length;i++)r[o+i]=n[t[i]]}}}}var Wj=new WeakMap,iP=new Float64Array(16),E2=(e,t,n)=>1-e*(1-(1-t)*n);function Vj(e,t,n,r,o){let i=e.axes.count,{behind:s}=e;for(let a=0;a<s.length;a++){let l=s[a],{slot:u,adjust:c,kept:d,share:f}=l;if(u)for(let p=0;p<i;p++){let h=u.cols[u.at+p]+(c?c[p]:0);t[n+p]=t[n+p]+(r||d?h*E2(f[p],r?r[o+p]:0,d?d[p]:1):h)}else if(r||d){let p=l.own();for(let h=0;h<i;h++)t[n+h]=t[n+h]-p[h]*(1-E2(f[h],r?r[o+h]:0,d?d[h]:1))}}}function sP(e,t,n){let r=e.axes.count,{slot:o,adjust:i,beside:s}=e;for(let l=0;l<r;l++)t[n+l]=t[n+l]+(o?o.cols[o.at+l]:0)+i[l]+(s?s[l]:0);let a=e.holds;e.behind.length>0&&(e.row||a||e.dimmed)&&Vj(e,t,n,a?a.store.cover:null,a?a.row*r:0)}function M2(e,t){let n=e.axes.to(t),r=e.holds;if(!r)return n;let o=r.row*n.length,{store:i}=r;for(let s=0;s<n.length;s++)if(n[s]!==i.at[o+s]){i.refold(r.row);break}for(let s=0;s<n.length;s++)n[s]=n[s]+i.delta[o+s];return n}function zj(e){let t=e.get();if(e.live===0)return t;let{axes:n}=e;if(!n.add||e.holds||e.dimmed){let i=M2(e,t);return sP(e,i,0),n.from(i)}let r=n.count;iP.length<r&&(iP=new Float64Array(r));let o=iP;return o.fill(0,0,r),sP(e,o,0),n.add(t,o)}function Kj(e,t,n){let r=e.get(),{axes:o}=e,i=e.live>0;if(o.write&&!(i&&e.holds))o.write(r,t,n);else{let s=i?M2(e,r):o.to(r);for(let a=0;a<s.length;a++)t[n+a]=s[a]}i&&sP(e,t,n)}function aP(e){let t=e.axes??Zu(e.get());if(!t)throw new Error("createTarget: `axes` is required for a value that is not a number, an array of numbers, or an object of numeric fields");let n={get:e.get,set:e.set,show:e.show,publish:e.publish,axes:t,write:null,owner:null,discard:!1,held:0,holds:null,behind:[],dimmed:!1,beside:null,parts:new Set,row:null,live:0,slot:null,adjust:new Array(t.count).fill(0),stale:!1},r={read:()=>zj(n),readInto:(o,i=0)=>Kj(n,o,i),axisCount:t.count,axes:t,axisIndexes:o=>I2(t,o),committed:e.get,commit:e.set,get active(){return n.live>0},stop(o){let i=n.owner;if(i){n.discard=o?.commit===!1;try{i.stop(n)}finally{n.discard=!1}}}};return Wj.set(r,n),r}var xh="0.16.1";function wh(e){let t=Symbol.for(`@msb235/blits/${e}`),n=globalThis,r=n[t];return r===void 0&&(r=new WeakMap,n[t]=r),r}var O2={on:Number.MIN_VALUE,off:0},Ct=(e,t,n)=>e+(t-e)*n,jj=Ct,$j=wh("lerp-into@1");function Ph(e){return $j.get(e)}var Yj=(e,t)=>e+t,C2=(e,t)=>e*t,F2=(e,t)=>e*t,L2=(e,t)=>1+(e-1)*t,qj=(e,t)=>e>t?e:t,_2=wh("numeric@1");function Jn(e){return _2.get(e)}var Xj=wh("width@1");function D2(e){let t=e.rest;return Array.isArray(t)?t.length:Xj.get(e)??1}function Oe(e,t,n,r){return e==="sum"?Yj(t,C2(n,r)):e==="mul"?F2(t,L2(n,r)):e==="max"?qj(t,C2(n,r)):+n}function B2(e){let t=Jn(e);if(!(t===void 0||t.axes!==1||t.turn!==void 0||e.fold!==void 0)&&typeof e.rest=="number")return t.op==="sum"||t.op==="mul"||t.op==="max"?t.op:void 0}var Jj=(e,t)=>t===void 0?e:`${e}[${t[0]}, ${t[1]}]`;function lP(e){let t={kind:Jj("mul",e?.bounds),bounds:e?.bounds,rest:1,merge:F2,scale:L2,lerp:jj};return _2.set(t,{op:"mul",axes:1}),t}function Th(e){return{kind:e?.lerp?void 0:"last",merge:(t,n)=>n,lerp:e?.lerp??((t,n,r)=>r<.5?t:n)}}function Qn(e,t){if(e===0)return[];let n=[.5];for(let r=1;r<e;r++)n.push(.5);for(let r=0;r<e;r++)n[r]=t;return n}function H2(e){let t=e??!1;return t===!0?Number.POSITIVE_INFINITY:t===!1?1:t}var G2=(e,t,n)=>Number.isFinite(n)&&e>=t*n;function Dr(e,t,n){return t>0?G2(e,t,n)?1:e%t/t:0}function Zn(e,t,n){return t>0?G2(e,t,n)?n-1:Math.floor(e/t):0}function Sh(e,t,n,r,o,i,s=Number.POSITIVE_INFINITY){let a=t&&!t.rest&&t.at<r?t.at:r;s<a&&(a=s);let l=a-o;if(i!==null)for(let c=0;c<i.length;c+=2){let d=Math.max(i[c],o),f=Math.min(i[c+1],a);f>d&&(l-=f-d)}let u=l/e;return u>=1?1:n?n(Math.max(0,u)):Math.max(0,u)}function ma(e,t,n,r,o,i,s=null,a=null){let l=1;if(e>0&&!r&&(l*=Sh(e,t,n,o,i,a)),s&&!r){let u=s.from+(o-s.at)/s.over;u<1&&(l*=n?n(Math.max(0,u)):Math.max(0,u))}if(t&&!t.rest){if(r||t.over===0)return 0;let u=1-(o-t.at)/t.over,c=u<0?0:u>1?1:u;l*=n?n(c):c}return l}function kh(e,t,n,r){return e>=0?n&&e>r?r:e:t?0:Number.NaN}function Kt(e,t){return e===t?e!==0||1/e===1/t:Number.isNaN(e)&&Number.isNaN(t)}function Br(e){return e<0?0:e>1?1:e}function jt(e,t,n){return Br(e*(t*n))}function vh(e,t){return!(t>0)&&e.out?.rest!==!0}function ze(e,t){let n=t-e.anchorNow,r=e.ramp;if(r===null)return e.anchorElapsed+n*e.rate;if(n<=0)return e.anchorElapsed+n*r.from;let o=r.to-r.from;return n<=r.over?e.anchorElapsed+r.from*n+o*n*n/(2*r.over):e.anchorElapsed+r.from*r.over+o*r.over/2+r.to*(n-r.over)}function Cn(e,t){let n=e.anchorElapsed,r=e.ramp;if(r===null)return e.rate>0?e.anchorNow+(t-n)/e.rate:t<=n?e.anchorNow:Number.POSITIVE_INFINITY;if(t<=n)return r.from>0?e.anchorNow+(t-n)/r.from:e.anchorNow;let o=(r.to-r.from)/(2*r.over),i=n+r.from*r.over+o*r.over*r.over,s=r.from>0&&r.to<0?n-r.from*r.from/(4*o):i;if(t<=s){let a=n-t,l=Math.abs(o)<1e-12?-a/r.from:(-r.from+Math.sqrt(Math.max(0,r.from*r.from-4*o*a)))/(2*o);return e.anchorNow+l}return r.to<=0?Number.POSITIVE_INFINITY:e.anchorNow+r.over+(t-i)/r.to}function ec(e,t){let n=e.ramp;return Cn({anchorNow:e.anchorNow,anchorElapsed:-e.anchorElapsed,rate:-e.rate,ramp:n===null?null:{from:-n.from,to:-n.to,over:n.over}},-t)}function U2(e,t){if(!(t>0))return 0;let n=e%t;return(n<0?n+t:n)/t}function ya(e,t){let n=e.ramp;if(n===null)return e.rate;let r=(t-e.anchorNow)/n.over;return r>=1?n.to:r<=0?n.from:n.from+(n.to-n.from)*r}function uP(e,t){let n=ya(e,t);e.anchorElapsed=ze(e,t);let r=e.ramp;if(r!==null){let o=e.anchorNow+r.over-t;e.ramp=o>0?{from:n,to:r.to,over:o}:null}e.anchorNow=t}function ga(e,t,n,r){uP(e,t);let o=ya(e,t);e.ramp=r>0&&n!==o?{from:o,to:n,over:r}:null,e.rate=n}function Io(e,t){let n=t.spec.stepMs??e.opts.stepMs;return n!==void 0&&n>0&&!e.reducedNow?n:void 0}var Qj=!1,ba={u:Number.NaN,ease:void 0,left:0};function Hr(e,t,n){return Math.max(0,e-t)/n}function Eo(e,t){return(t!==ba.u||e!==ba.ease)&&(ba.u=t,ba.ease=e,ba.left=t>=1?0:1-e(t)),ba.left}function Mo(e,t,n){return n===0?t:t+(e-t)*n}function W2(e,t,n,r,o,i,s,a,l,u){let c=Eo(e,n),d=0;if(Qj&&n<1){let f=Math.max(0,n-1e-4),p=Math.min(1,n+1e-4);d=(e(p)-e(f))/(p-f)*(1e3/r)}for(let f=0;f<t;f++){let p=o[i+f],h=s[a+f];l[f]=Mo(p,h,c),u[f]=-(p-h)*d}return c===0}var V2=0,z2=1,K2=2;var Zj=4,e$=5,ot={y:0,dy:0},St={e:0,e2:0,cos:0,sin:0},t$={form:Number.NaN,k1:Number.NaN,k2:Number.NaN,k3:Number.NaN,t:Number.NaN};function n$(e,t){let n=e[0],r=e[2],o=e[3],i=e[4],s=t$;if(!(Kt(t,s.t)&&n===s.form&&r===s.k1&&o===s.k2&&i===s.k3))switch(s.form=n,s.k1=r,s.k2=o,s.k3=i,s.t=t,n){case V2:{let a=e[2],l=e[3],u=e[4];St.e=Math.exp(-a*l*t),St.cos=Math.cos(u*t),St.sin=Math.sin(u*t);return}case z2:{let a=e[3];St.e=Math.exp(-a*t);return}case K2:{St.e=Math.exp(e[2]*t),St.e2=Math.exp(e[3]*t);return}default:St.e=Math.exp(-t/e[2])}}function r$(e,t,n,r){let o=e[0];o===V2?o$(e,t,n):o===z2?i$(e,t,n,r):o===K2?s$(e,t,n):j2(e,t)}function o$(e,t,n){let r=e[2],o=e[3],i=e[4],s=St.e,a=(n+r*o*t)/i,l=St.cos,u=St.sin,c=s*(t*l+a*u);ot.y=c,ot.dy=-r*o*c+s*i*(a*l-t*u)}function i$(e,t,n,r){let o=e[3],i=St.e,s=n+o*t,a=i*(t+s*r);ot.y=a,ot.dy=i*s-o*a}function s$(e,t,n){let r=e[2],o=e[3],i=(n-o*t)/(r-o),s=t-i,a=St.e,l=St.e2;ot.y=i*a+s*l,ot.dy=i*r*a+s*o*l}function j2(e,t){let n=e[2],r=St.e;ot.y=t*r,ot.dy=-t/n*r}function a$(e,t,n,r,o){let i=e[2],s=t-n,a=t+r*i-n;if(a===0){j2(e,s);return}let l=e[3];if(s*a>0){let h=Math.exp(-l*o),m=r+l*s,g=h*(s+m*o);ot.y=g,ot.dy=h*m-l*g;return}let u=1+s/(r*i),c=u>0?-i*Math.log(u):Number.POSITIVE_INFINITY;if(o<c){let h=St.e;ot.y=s+r*i*(1-h),ot.dy=r*h;return}let d=o-c,f=r*u,p=Math.exp(-l*d);ot.y=p*f*d,ot.dy=p*f*(1-l*d)}function $2(e,t,n,r,o,i,s,a,l,u,c,d,f,p){if(e[0]===Zj)return W2(t,n,Hr(d,r,o),o,i,s,u,c,f,p);let h=Math.max(0,d-r)/1e3,m=e[1],g=m>0;n$(e,h);for(let b=0;b<n;b++){let x=u[c+b];e[0]===e$?a$(e,i[s+b],x,a[l+b],h):r$(e,i[s+b]-x,a[l+b],h),f[b]=x+ot.y,p[b]=ot.dy,(Math.abs(ot.y)>m||Math.abs(ot.dy)>m)&&(g=!1)}if(g)for(let b=0;b<n;b++)f[b]=u[c+b],p[b]=0;return g}var Y2=1e-4,Gr=[0,0];function cP(e,t,n,r){let o=t<Y2?n:e,s=(r<Y2?e:n)-o;s>Math.PI?s-=2*Math.PI:s<-Math.PI&&(s+=2*Math.PI),Gr[0]=o,Gr[1]=s}function q2(e,t,n,r,o){let i=e[t+3]??0,s=n[r+3]??0,a=s>0?1/s:0,l=(n[r]??0)*a,u=(n[r+1]??0)*a,c=(n[r+2]??0)*a,d=i>0?1/i:0,f=i>0?(e[t]??0)*d:l,p=i>0?(e[t+1]??0)*d:u,h=i>0?(e[t+2]??0)*d:c,m=s>0?l:f,g=s>0?u:p,b=s>0?c:h,x=Math.sqrt(p*p+h*h),w=Math.sqrt(g*g+b*b);cP(Math.atan2(h,p),x,Math.atan2(b,g),w),o[0]=f,o[1]=x,o[2]=Gr[0],o[3]=i,o[4]=m,o[5]=w,o[6]=Gr[0]+Gr[1],o[7]=s}var nye=new Float64Array(8),rye=new Float64Array(4),oye=new Float64Array(4),iye=new Float64Array(4),sye=new Float64Array(4);function tc(){try{return!0}catch{return!1}}var X2=new WeakSet;function er(e,t){X2.has(e)||tc()||(X2.add(e),console.warn(`blits: ${t}`))}var xa=Ct,c$=Array.from({length:256},(e,t)=>{let n=t/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),d$=c$.map((e,t)=>{let n=(t-.5)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),J2=4096,pye=Array.from({length:J2+1},(e,t)=>{let n=0;for(;n<255&&t/J2>=d$[n+1];)n++;return n});var Ah=256,hye=new Int32Array(Ah).fill(-1),mye=new Float64Array(Ah),yye=new Float64Array(Ah),gye=new Float64Array(Ah);var eO=new Float64Array(8);function f$(e,t,n){let r=eO;q2(e,0,t,0,r);let o=xa(r[3],r[7],n),i=xa(r[1],r[5],n),s=r[2]+Gr[1]*n;return[xa(r[0],r[4],n)*o,i*Math.cos(s)*o,i*Math.sin(s)*o,o]}var p$=1e-9;function Q2(e,t,n){let r=e.length>4,o=(r?e[4]:e[3])??0,i=o>0?1/o:0,s=(e[1]??0)*i,a=(e[2]??0)*i,l=Math.sqrt(s*s+a*a);t[n]=(e[0]??0)*i,t[n+1]=r?l<p$?0:(e[3]??0)*i:l,t[n+2]=Math.atan2(a,s),t[n+3]=o}function Z2(e,t,n){let r=e[1]??0,o=e[2]??0,i=e.length>4;return n[0]=(e[0]??0)*t,n[1]=r*t,n[2]=o*t,n[3]=(i?e[3]??0:Math.sqrt(r*r+o*o))*t,n[4]=((i?e[4]:e[3])??0)*t,n}function h$(e,t,n){if(n===0)return Z2(e,1,Qn(5,0));if(n===1)return Z2(t,1,Qn(5,0));let r=eO;Q2(e,r,0),Q2(t,r,4);let o=r[3]>0?0:4,i=r[7]>0?4:0,s=r[o+1],a=r[i+1];cP(r[o+2],s,r[i+2],a);let l=xa(r[3],r[7],n),u=xa(s,a,n)*l,c=Gr[0]+Gr[1]*n;return[xa(r[o],r[i],n)*l,Math.cos(c)*u,Math.sin(c)*u,u,l]}function dP(e){let t=e.lerp;return t===f$||t===h$}var bye=Qn(5,0);var pP=e=>e;function nO(e){return e===void 0||e===pP}function nc(e,t,n,r){let o=3*e,i=3*(n-e)-o,s=1-o-i,a=3*t,l=3*(r-t)-a,u=1-a-l,c=p=>((s*p+i)*p+o)*p,d=p=>(3*s*p+2*i)*p+o,f=p=>((u*p+l)*p+a)*p;return p=>{if(p<=0)return 0;if(p>=1)return 1;let h=p;for(let b=0;b<8;b++){let x=c(h)-p;if(Math.abs(x)<1e-7)return f(h);let w=d(h);if(Math.abs(w)<1e-6)break;h-=x/w}let m=0,g=1;for(h=p;g-m>1e-7;)c(h)<p?m=h:g=h,h=(m+g)/2;return f(h)}}var m$={linear:pP,ease:nc(.25,.1,.25,1),"ease-in":nc(.42,0,1,1),"ease-out":nc(0,0,.58,1),"ease-in-out":nc(.42,0,.58,1)},tO=new WeakMap,fP=new WeakMap([[pP,1]]);function y$(e,t,n,r){return e>0?t/e:t>0?Number.POSITIVE_INFINITY:n>0?r/n:r>0?Number.POSITIVE_INFINITY:1}function rO(e){let t=fP.get(e);if(t!==void 0)return t;let n=1e-6,r=e(n);return r>.001?Number.POSITIVE_INFINITY:r/n}function Co(e){if(typeof e=="function")return e;if(typeof e=="string"){let r=m$[e];if(!r)throw new Error(`blits: no easing named ${e}`);return r}let t=tO.get(e);if(t)return t;let n;if("bezier"in e)n=nc(...e.bezier),fP.set(n,y$(...e.bezier));else{let r=e.steps,o=e.jump==="start";n=i=>{let s=i<=0?0:i>=1?1:i;return(o?Math.min(r,Math.floor(s*r)+1):Math.floor(s*r))/r},fP.set(n,o?Number.POSITIVE_INFINITY:0)}return tO.set(e,n),n}function oO(e,t){return e==="queue"?1:e==="together"?0:t}function g$(e,t){return{rate:t.map(()=>1),skip:t.map(()=>!1),share:oO(e.order,e.share),allow:0}}function mP(e,t,n){let r=oO(e.order,e.share),o=[],i=0,s=0,a=0;return t.forEach((l,u)=>{let c=n.skip[u]?0:l.natural/n.rate[u],d=l.state==="playing"?0:Math.max(u===0?Number.NEGATIVE_INFINITY:s+(l.overlap?Math.min(n.share,r):r)*a,l.floor??0);o.push(d),i=Math.max(i,d+c),s=d,a=c}),{at:o,length:i}}var tr=(e,t,n)=>mP(e,t,n).length<=e.left+n.allow+1e-9;function hP(e,t,n){if(n(e))return e;if(!n(t))return t;if(t===Number.POSITIVE_INFINITY)for(t=Math.max(e,1)*2;!n(t);)e=t,t*=2;for(let r=0;r<60;r++){let o=(e+t)/2;n(o)?t=o:e=o}return t}function b$(e,t,n){if(!tr(e,t,n)){let s=Math.max(1,...t.map(l=>l.faster)),a=l=>({...n,rate:t.map((u,c)=>Math.max(n.rate[c],Math.min(l,u.faster)))});return a(hP(1,s,l=>tr(e,t,a(l))))}if(!Number.isFinite(e.left))return n;let r=Math.max(1,...t.map(s=>s.slower));if(r===1)return n;let o=s=>({...n,rate:t.map((a,l)=>n.rate[l]/Math.min(s,a.slower))}),i=hP(1,r,s=>!tr(e,t,o(s)));return tr(e,t,o(i))?o(i):o(Math.max(1,i-1e-9))}function x$(){return(e,t,n)=>{if(tr(e,t,n)||!t.some(i=>i.overlap))return n;let r=i=>({...n,share:i}),o=hP(0,n.share,i=>tr(e,t,r(n.share-i)));return r(n.share-o)}}function w$(){return(e,t,n)=>{let r=n;for(let o=t.length-1;o>=0&&!tr(e,t,r);o--){if(!t[o].ballast||r.skip[o])continue;let i=r.skip.slice();i[o]=!0,r={...r,skip:i}}return r}}function P$(...e){return(t,n,r)=>{let o=r;for(let i of e){if(tr(t,n,o))break;o=i(t,n,o)}return o}}var iO=P$(x$(),w$()),Rh={weak:0,strong:1,required:2};function sO(e,t,n,r){let o=n(e,t,b$(e,t,g$(e,t)));return tr(e,t,o)||Rh[e.priority]===0||r==="overrun"?{plan:o,fell:!tr(e,t,o)&&Rh[e.priority]>0}:(o={...o,skip:t.map((i,s)=>o.skip[s]||Rh[i.priority]<Rh[e.priority])},{plan:o,fell:!0})}var Oo=e=>!Number.isNaN(e.restedAt);function On(e,t,n){return{reaches:t,delay:0,since:0,shown:0,weight:0,restedAt:Number.NaN,bands:null,state:n,stepped:-0,ticks:0,probed:Number.NaN,delta:null,phase:0,seeks:0,rebuilt:0,copied:!1,base:void 0,slope:void 0,kept:null,unkept:void 0,snaps:void 0,from:void 0,unknown:void 0,inputs:void 0,replay:void 0,voice:e,next:null,version:Number.NaN,roles:null,slot:-1,run:-1,freed:-1,restored:null}}function T$(){return On(null,!1,void 0)}function aO(e){let t=this.chains.get(e);return t!==void 0&&t.version===this.version?t:this.relink(e,t)}function lO(e,t){let n=this.lanes,r=t!==void 0?t.slot:n!==null?n.number(e):-1;t===void 0&&r>=0&&this.places?.number(e,r);let o=t!==void 0&&r>=0&&n?.renew(r)===!0,i=t===void 0||o?void 0:this.steps.patch(t.voice===null?null:t,t.version,this,e,r);i===void 0&&(i=S$(this,e,r,t??null));let s=i??T$();return s.version=this.version,t!==void 0&&t!==s&&(o||(s.roles=t.roles),t.roles=null,t.slot=-1),s.slot=r,t!==s&&this.chains.set(e,s),s}function ut(e,t){let n=e.chains.get(t);return n!==void 0&&n.slot>=0&&e.lanes?.sought(n.slot)===!0?void 0:n}function S$(e,t,n,r){let o=null,i=r,s=null,a=e.naming===0?void 0:e.named.get(t),l=0,u=e.general;for(let c=0;c<=u.length;c++){let d=c<u.length?u[c]:null;for(;;){let f=a!==void 0&&l<a.length?a[l]:null,p=f!==null&&(d===null||f.id<d.id)?f:d;if(p===null)break;p===f&&l++;let h=i!==null&&i.voice===p?i:null;h!==null&&(i=h.next);let m=e.linkable(p,t,n,h);if(m!==null&&(m.voice=p,m.next=null,s===null?o=m:s.next=m,s=m),p===d)break}}return o}function uO(e,t,n,r=null){let o=e.state;if(o==="done"||o==="pending"&&!e.freezesBefore)return null;if(e.sharing&&this.share.everyoneOf(this,e)!==null)return n>=0&&this.share.sight(e,n,this.lanes.cap),null;let i=this.held(e,t,n,r);return i.reaches?i:null}function cO(e,t){return dO(e,t,this.now)}function dO(e,t,n,r=Number.POSITIVE_INFINITY){let o=e.parted?.get(t);return o!==void 0&&!(n<o.at)&&o.seq<=r?!1:e.named!==null?e.named.has(t):e.spec.target?e.spec.target(t):!0}function Nh(e,t,n,r,o){return n!==void 0&&!n.reaches&&dO(e,t,r,o)?void 0:n}function Ur(e,t){if(t.holding!==null){e.lanes?.refill();return}if(e.lanes?.touch(t),t.named===null){e.steps.push(t,++e.version);return}for(let n of t.named.list){let r=ut(e,n);r!==void 0&&rc(e,r)}e.relinks++}function rc(e,t){t.version=Number.NaN;let n=++e.relinks;t.slot>=0&&e.lanes!==null&&(e.lanes.unlinked[t.slot]=n)}function yP(e,t){if(t.holding===null){if(t.named===null){if(e.general.push(t),t.sharing){let n=e.sharers,r=n.length;for(;r>0&&n[r-1].id>t.id;)r--;n.splice(r,0,t)}return}e.naming++;for(let n of t.named.list){let r=e.named.get(n);r===void 0?e.named.set(n,[t]):r.push(t)}}}function fO(e,t){e.naming--;for(let n of t.named.list){let r=e.named.get(n);if(r===void 0)continue;let o=r.indexOf(t);o>=0&&r.splice(o,1),r.length===0&&e.named.delete(n)}}var Ih=class{size=0;every=[];everyTokens=[];spare=[];spareTokens=[];everySorted=!0;at=new Float64Array(64);tokens=new Float64Array(64);voices=[];limit=64;push(t,n,r){if(t===Number.NEGATIVE_INFINITY){this.every.length>=this.limit&&this.pruneEvery(),this.every.push(n),this.everyTokens.push(r);return}this.size>=this.limit&&this.prune(),this.size===this.at.length&&this.grow();let o=this.at,i=this.size++;for(;i>0;){let s=i-1>>1;if(o[s]<=t)break;this.move(s,i),i=s}o[i]=t,this.tokens[i]=r,this.voices[i]=n}first(){return this.every.length>0?Number.NEGATIVE_INFINITY:this.size>0?this.at[0]:Number.POSITIVE_INFINITY}takeEvery(){let t=this.every,n=this.everyTokens,r=0,o=!0,i=Number.NEGATIVE_INFINITY;for(let s=0;s<t.length;s++){let a=t[s];n[s]!==a.dueToken||a.state==="done"||(a.dueToken++,a.id<i&&(o=!1),i=a.id,t[r++]=a)}return t.length=r,n.length=0,this.spare.length=0,this.every=this.spare,this.everyTokens=this.spareTokens,this.spare=t,this.spareTokens=n,this.everySorted=o,t}pop(){let t=this.voices[0],n=this.tokens[0],r=--this.size;return r>0&&this.sink(0,this.at[r],this.tokens[r],this.voices[r]),this.voices[r]=void 0,n===t.dueToken&&t.state!=="done"?t:void 0}clear(){this.size=0,this.every.length=0,this.everyTokens.length=0,this.spare.length=0,this.spareTokens.length=0,this.voices=[],this.limit=64}move(t,n){this.at[n]=this.at[t],this.tokens[n]=this.tokens[t],this.voices[n]=this.voices[t]}sink(t,n,r,o){let i=this.at,s=this.size;for(;;){let a=2*t+1,l=a+1,u=t,c=n;if(a<s&&i[a]<c&&(u=a,c=i[a]),l<s&&i[l]<c&&(u=l),u===t)break;this.move(u,t),t=u}i[t]=n,this.tokens[t]=r,this.voices[t]=o}grow(){let t=new Float64Array(this.at.length*2);t.set(this.at),this.at=t;let n=new Float64Array(this.tokens.length*2);n.set(this.tokens),this.tokens=n}pruneEvery(){let t=this.every,n=this.everyTokens,r=0;for(let o=0;o<t.length;o++){let i=t[o];n[o]===i.dueToken&&(t[r]=i,n[r++]=n[o])}t.length=r,n.length=r,this.limit=Math.max(this.limit,2*r)}prune(){let t=0;for(let n=0;n<this.size;n++){let r=this.voices[n];this.tokens[n]===r.dueToken&&(t!==n&&this.move(n,t),t++)}for(let n=t;n<this.size;n++)this.voices[n]=void 0;this.size=t;for(let n=(t>>1)-1;n>=0;n--)this.sink(n,this.at[n],this.tokens[n],this.voices[n]);this.limit=Math.max(64,2*t)}};function k$(e,t){if(t.state==="done")return Number.POSITIVE_INFINITY;if(Number.isNaN(t.opened)||t.owner!==null||t.holding!==null)return Number.NEGATIVE_INFINITY;let n=Number.POSITIVE_INFINITY;if(t.parts!==null)for(let o of t.parts.values())n=Math.min(n,o.at+o.over);let r=t.back;if(r!==null&&(n=Math.min(n,r.at+(1-r.from)*r.over)),t.state==="pending")return Math.min(n,Number.isNaN(t.start)?n:t.start);if(t.turns)return Number.NEGATIVE_INFINITY;if(t.state==="fading"){let o=t.out;return o===null||o.rest?Number.NEGATIVE_INFINITY:Math.min(n,o.at+o.over)}if(n=Math.min(n,t.outAt),t.state==="frozen"){let o=Number.isNaN(e.now)?Number.NaN:t.elapsedAt(e.now),i=t.ramp;if((i===null?t.rate<=0:i.from<=0&&i.to<=0)&&!t.beginless&&o<=t.soonest)return n;if(t.rate<=0||i!==null||o<t.span+t.latest)return Number.NEGATIVE_INFINITY}return t.state==="live"&&(n=Math.min(n,t.endsAt())),n}function it(e,t){if(e.projecting)return;e.lanes?.voiceChanged(t);let n=++t.dueToken,r=k$(e,t);r!==Number.POSITIVE_INFINITY&&e.due.push(Number.isNaN(r)?Number.NEGATIVE_INFINITY:r,t,n)}function pO(e,t){let n=e.due,r=n.takeEvery(),o=n.everySorted,i=r.length;for(;n.first()<=t;){let s=n.pop();s!==void 0&&(s.dueToken++,r.push(s))}return i===0||!o?Bi(r):i===r.length?r:v$(r,i)}function v$(e,t){let n=Bi(e.slice(t)),r=[],o=0,i=0;for(;o<t&&i<n.length;){let s=e[o],a=n[i];a.id<s.id?(r.push(a),i++):(r.push(s),o++)}for(;o<t;)r.push(e[o++]);for(;i<n.length;)r.push(n[i++]);return r}var A$=8;function Bi(e){if(e.length>A$)return e.sort((t,n)=>t.id-n.id);for(let t=1;t<e.length;t++){let n=e[t],r=t;for(;r>0&&e[r-1].id>n.id;r--)e[r]=e[r-1];e[r]=n}return e}var cn=Symbol("slow");function bt(e){let t=gP(e,2);for(let n=0;n<Eh;n++)bP[n]=void 0;return Eh=0,t===cn?structuredClone(e):t}var bP=[],Eh=0;function R$(e){for(let t=0;t<Eh;t++)if(bP[t]===e)return!0;return!1}function gP(e,t){if(typeof e=="symbol"||typeof e=="function")return cn;if(typeof e!="object"||e===null)return e;if(t===0||R$(e))return cn;if(bP[Eh++]=e,Array.isArray(e)){if(Object.getPrototypeOf(e)!==Array.prototype)return cn;let o=[];for(let s=0;s<e.length;s++){if(!(s in e))return cn;let a=gP(e[s],t-1);if(a===cn)return cn;o.push(a)}let i=0;for(let s in e)if(++i>e.length)return cn;return o}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)return cn;let r={};for(let o in e){if(o==="__proto__")return cn;let i=gP(e[o],t-1);if(i===cn)return cn;r[o]=i}return r}function wa(e){return typeof e!="object"||e===null?e:Array.isArray(e)?[...e]:ArrayBuffer.isView(e)?e.slice():mO(e)?bt(e):e}function Hi(e){return Array.isArray(e)?[...e]:e}function hO(e){return Array.isArray(e)||ArrayBuffer.isView(e)||mO(e)}function mO(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function $t(e,t,n=!1){return t<e.seq||t===e.seq&&(!e.strict||n)}var yO=new WeakMap,xP=new Map,me=class{weak=yO;strong=xP;oneKey=Pa;oneValue=void 0;get(t){return typeof t=="object"&&t!==null?this.weak.get(t):wP(this.oneKey,t)?this.oneValue:this.strong.get(t)}set(t,n){if(typeof t=="object"&&t!==null){this.weak===yO&&(this.weak=new WeakMap),this.weak.set(t,n);return}if(this.strong===xP&&(this.oneKey===Pa||wP(this.oneKey,t))){this.oneKey=t,this.oneValue=n;return}this.strong===xP&&(this.strong=new Map),this.oneKey!==Pa&&(this.strong.set(this.oneKey,this.oneValue),this.oneKey=Pa,this.oneValue=void 0),this.strong.set(t,n)}find(t,n){return this.get(t)}has(t){return this.get(t)!==void 0}delete(t){typeof t=="object"&&t!==null?this.weak.delete(t):wP(this.oneKey,t)?(this.oneKey=Pa,this.oneValue=void 0):this.strong.delete(t)}clear(){this.oneKey=Pa,this.oneValue=void 0,this.strong.clear()}},oc=class extends me{under;hidden=new me;constructor(t){super(),this.under=t}get(t){return super.get(t)??(this.hidden.get(t)?void 0:this.under.get(t))}delete(t){super.delete(t),this.hidden.set(t,!0)}},Pa=Symbol("none"),wP=(e,t)=>e===t||Object.is(e,t),Mh=class extends me{make;gone=null;constructor(t){super(),this.make=t}get(t){let n=super.get(t);return n===void 0&&this.gone?.get(t)!==!0&&(n=this.make(t),n!==void 0&&super.set(t,n)),n}delete(t){super.delete(t),this.gone??=new me,this.gone.set(t,!0)}};var Fn=class e{list=[];head=0;by=new me;static from(t){if(t.length===0)return null;let n=new e;for(let r of t)n.push(r);return n}push(t){this.list.push(t);let n=this.by.get(t.subject);n===void 0?this.by.set(t.subject,[t]):n.push(t)}expire(t,n){let r=this.list,o=this.head;for(;o<r.length&&!(r[o].at>=t);){let i=r[o++];n!==null&&n(i);let s=this.by.get(i.subject);s.length===1?this.by.delete(i.subject):s.shift()}this.head=o,o>=32&&o*2>=r.length&&(this.list=r.slice(o),this.head=0)}at(t,n){let r=this.by.get(t);if(r!==void 0){for(let o of r)if(!$t(n,o.seq,o.sync))return!o.held.reaches&&o.parted!==null&&o.parted.seq>n.seq?void 0:o.held}}after(t){let n=[],r=new Set;for(let o of this.all())!$t(t,o.seq,o.sync)&&!r.has(o.subject)&&(r.add(o.subject),n.push(o));return n}of(t){return this.by.get(t)??[]}all(){return this.head===0?this.list:this.list.slice(this.head)}};function Gi(e,t){let n=e.patch,r=[...t.kept?.values()??[],...t.unkept??[]],o={reaches:t.reaches,delay:t.delay,since:t.since,shown:t.shown,weight:t.weight,rested:Oo(t),restedAt:t.restedAt,bands:t.bands===null?null:Array.from(t.bands),state:t.state===void 0?void 0:n.pack?n.pack(t.state):bt(t.state),stepped:t.stepped,ticks:t.ticks,rebuilt:t.rebuilt,kept:r.length===0?null:r.map(bt)};return t.copied&&(o.copied=!0),t.base!==void 0&&(o.base=bt(t.base)),t.slope!==void 0&&(o.slope=bt(t.slope)),t.snaps!==void 0&&(o.snaps=t.snaps.map(i=>[i.at,i.seq,Gi(e,i.held)])),t.inputs!==void 0&&(o.inputs=t.inputs.map(i=>({...i}))),o}function Ui(e,t){let n=e.patch,r=t.bands===null?null:Uint8Array.from(t.bands),o=On(e,t.reaches,t.state===void 0?void 0:n.unpack?n.unpack(t.state):t.state);return o.delay=t.delay,o.since=t.since,o.shown=t.shown,o.weight=t.weight,o.restedAt=t.restedAt,o.bands=r,o.stepped=t.stepped,o.ticks=t.ticks,o.rebuilt=t.rebuilt,o.copied=t.copied===!0,t.kept!==null&&(o.unkept=t.kept),t.base!==void 0&&(o.base=t.base),t.slope!==void 0&&(o.slope=t.slope),t.snaps!==void 0&&(o.snaps=t.snaps.map(([i,s,a])=>({at:i,seq:s,held:Ui(e,a)}))),t.inputs!==void 0&&(o.inputs=t.inputs),o}var ic=class extends Error{mix;stream;at;constructor(t,n,r){super(`blits: ${r} reaches past memory into ${n} records of ${t===""?"the mix":t} that were not loaded; await prepare(${r}) first`),this.mix=t,this.stream=n,this.at=r,this.name="HistoryMiss"}},Ch=class{store;loaded=null;last=null;constructor(t){this.store=t}},Oh=class{of;refs=new Map;gone=new FinalizationRegistry(t=>{let n=this.refs.get(t);n!==void 0&&n.deref()===void 0&&this.refs.delete(t)});constructor(t){this.of=t}key(t){if(t===void 0||typeof t=="string"||typeof t=="number")return t;let n=this.of;if(n===void 0||typeof t!="object"||t===null)throw new Error("blits: a mix whose history has a store pages its subjects by key; give it keyOf for subjects that are not strings or numbers");let r=n(t);return this.refs.get(r)?.deref()!==t&&(this.refs.set(r,new WeakRef(t)),this.gone.register(t,r)),r}subject(t){if(t!==void 0)return this.refs.get(t)?.deref()??t}};function nr(e,t,n,r,o,i,s){if(e.transport.pager===null||o.length===0)return;let l=e.name??"",u=[];for(let c=0;c<o.length;c++){let d=o[c];if(c+1<o.length&&o[c+1].seq===d.seq)continue;let f={mix:l,stream:t,at:d.at,seq:d.seq,data:i(d)};n!==void 0&&(f.voice=n),r!==void 0&&(f.subject=r),u.push(f)}gO(e.transport,u,s)}function gO(e,t,n){let r=e.pager;r.store.page(t);let o=r.loaded;o!==null&&(e.now-o.now>(e.history?.ms??0)?r.loaded=null:o.records.push(...t));let i=t[t.length-1];r.last={mix:i.mix,stream:i.stream},n>e.floor&&(e.floor=n)}function bO(e){let t=e.history;if(t===void 0||e.pager===null)return;let n=e.now-t.ms,r=[];e.frames.shed(n,s=>r.push({mix:"",stream:"frame",at:s.at,seq:s.seq,data:s.u}));let o=e.pace,i=s=>o===null?s:o.reading(s);if(e.announced.some(s=>i(s.at)<n)){let s=[];for(let a of e.announced)i(a.at)<n?r.push({mix:"",stream:"mark",subject:a.order,at:i(a.at),seq:a.seq,data:a}):s.push(a);e.announced=s}if(o!==null)for(let s of o.shed(n))r.push({mix:"",stream:"pace",at:s.anchorElapsed,seq:s.seq,data:s});r.length>0&&gO(e,r,n)}async function xO(e,t){let n=e.pager;if(n===null||e.reaches(t))return;let r=await n.store.load(t);n.loaded={t,now:e.now,records:[...r]}}var Fh=class{cued=null;by=new Map;gone=null;goneBy=new Map;versions=new Map;held=new Set};function Lh(e,t){let n=e.scored.held;if(n.has(t)||e.dropped)return;n.add(t);let r=e.transport.holders,o=e,i=r.get(t);if(i===void 0){r.set(t,[o]);return}let s=i.findIndex(a=>a.slot>o.slot);s<0?i.push(o):i.splice(s,0,o)}function wO(e,t){return e.transport.holders.get(t)??RO}function PP(e,t){e.scored.held.delete(t);let n=e.transport.holders,r=n.get(t);if(r===void 0)return;let o=r.indexOf(e);o>=0&&r.splice(o,1),r.length===0&&n.delete(t)}function PO(e){for(let t of e.cued)t.spec.score!==void 0&&Lh(e,t.spec.score);for(let t of e.gone)t.spec.score!==void 0&&Lh(e,t.spec.score)}function TO(e){for(let t of[...e.scored.held])PP(e,t)}function Ta(e,t,n=!1){let r=t.spec.score;if(r===void 0)return;let o=e.scored;if(o.versions.set(r,(o.versions.get(r)??0)+1),!n||t.state!=="done")return;let i=o.goneBy.get(r);i!==void 0&&o.goneBy.set(r,[...i])}function SO(e,t){return e.scored.versions.get(t)??0}function kO(e,t){let n=t.spec.score;if(n===void 0)return;let r=e.get(n);r===void 0?e.set(n,new Set([t])):r.add(t)}function vO(e,t){let n=e.scored;if(n.cued!==e.cued){n.by=new Map;for(let r of e.cued)kO(n.by,r);n.cued=e.cued}return n.by.get(t)??N$}var N$=new Set;function AO(e,t){let n=e.scored;if(n.gone!==e.gone){n.goneBy=new Map;for(let r of e.gone)NO(n.goneBy,r);n.gone=e.gone}return n.goneBy.get(t)??RO}var RO=[];function NO(e,t){let n=t.spec.score;if(n===void 0)return;let r=e.get(n);r===void 0?e.set(n,[t]):r.push(t)}function _h(e,t){t.spec.score!==void 0&&Lh(e,t.spec.score);let n=e.scored;n.gone===e.gone&&NO(n.goneBy,t)}function TP(e,t,n){let r=e.scored;if(r.gone!==t)return;r.gone=e.gone;let o=new Map;for(let i of n){let s=i.spec.score;if(s===void 0)continue;let a=o.get(s);a===void 0?o.set(s,new Set([i])):a.add(i)}for(let[i,s]of o){let a=(r.goneBy.get(i)??[]).filter(l=>!s.has(l));a.length===0?r.goneBy.delete(i):r.goneBy.set(i,a)}}function IO(e,t){Ta(e,t),t.spec.score!==void 0&&Lh(e,t.spec.score);let n=e.scored;n.cued===e.cued&&kO(n.by,t)}function EO(e,t){for(let r of t)Ta(e,r);let n=e.scored;if(n.cued===e.cued)for(let r of t){let o=r.spec.score;if(o===void 0)continue;let i=n.by.get(o);i!==void 0&&(i.delete(r),i.size===0&&n.by.delete(o))}}var rr=Symbol("absent"),MO=Symbol("unit"),Dh=class{owner;next=0;free=null;refs=[void 0];registry=null;lone=null;loneSlot=-1;constructor(t){this.owner=t}adopt(t){this.owner=t}get size(){return this.next}take(t){let n=this.free?.pop()??this.next++,r=-1;if(typeof t=="object"&&t!==null){let o=new WeakRef(t);if(this.refs[n]=o,this.registry===null){if(this.lone===null)return this.lone=o,this.loneSlot=n,n;this.registry=new FinalizationRegistry(s=>this.release(s));let i=this.lone.deref();i!==void 0?this.registry.register(i,this.loneSlot,this.lone):r=this.loneSlot,this.lone=null}this.registry.register(t,n,o)}else this.refs[n]=t===void 0?MO:t;return r>=0&&this.release(r),n}has(t){return this.refs[t]!==void 0}subject(t){let n=this.refs[t];if(n===void 0)return rr;if(n!==MO){if(n instanceof WeakRef){let r=n.deref();return r===void 0?rr:r}return n}}move(t,n){let r=this.refs[t],o=this.free;if(r===void 0||n>=this.next||this.refs[n]!==void 0||o===null)return!1;let i=o.lastIndexOf(n);if(i<0)return!1;if(r instanceof WeakRef){let s=r.deref();if(s===void 0)return!1;r===this.lone?this.loneSlot=n:this.registry!==null&&(this.registry.unregister(r),this.registry.register(s,n,r))}return o.splice(i,1),o.push(t),this.refs[n]=r,this.refs[t]=void 0,!0}release(t){let n=this.refs[t];n!==void 0&&(n===this.lone?this.lone=null:n instanceof WeakRef&&this.registry?.unregister(n),this.refs[t]=void 0,this.owner.forget(t),this.free===null?this.free=[t]:this.free.push(t))}};var pe={live:!0,horizon:Number.POSITIVE_INFINITY,kept:0,moved:0,inputs:0,ahead:null,back:null};var I$=(e,t)=>e.seq===void 0||Number.isNaN(e.seq)||$t(t,e.seq,e.early===!0);function E$(e,t){let n=e[e.length-1];if(t>=n.at||e.length===1)return n;if(e[0].at>t)return e[0];let r=0,o=e.length-2;for(;r<o;){let i=r+o+1>>1;e[i].at<=t?r=i:o=i-1}return e[r]}function Bh(e,t,n,r){let o=e.runThen(t,r)??e.freshRun(t),i=o.stretches,s=o.pending??[],a=[],l=!1;for(let c of[...i.slice(1).map(d=>d.change),...s])c===void 0||I$(c,r)?c!==void 0&&a.push(c):l=!0;l&&(i=[i[0]],s=a.filter(c=>c.at!==void 0).sort((c,d)=>c.at-d.at));let u=E$(i,n);for(let c of s){let d=c.at;if(d===void 0||!(d<=n))break;d>=u.at&&(u=e.applied(t,u,c,d))}return e.evaluateSegment(u,n,e.xs,e.vs),o.flags}var M$=e=>typeof e=="number"?[e]:[...e];var OO=Symbol.for(`@msb235/blits/motions@${xh}`),CO=new Map,SP=class{motions;writes;constructor(t,n){this.motions=n;let r=CO.get(t);r===void 0&&(r=Object.freeze([t]),CO.set(t,r)),this.writes=r}form="motion";duration=0;get motion(){return this.motions.spec()}get[OO](){return this.motions}at(t,n,r){let o=this.motions,i=pe.back;if(i!==null){let a=Bh(o,n,r.elapsed,i);return{[this.writes[0]]:o.valueOf(a,o.xs)}}let s=o.slot(n);return o.sample(s,r.elapsed,o.xs,o.vs),{[this.writes[0]]:o.value(s,o.xs)}}set(t,n,r){this.motions.change(t,{at:r,x:M$(n)})}read(t,n){let r=this.motions,o=r.read(t,n);if(o!==void 0)return{value:r.value(o.s,o.x),velocity:r.value(o.s,o.v)}}};function Ln(e){return e instanceof SP?e.motions:e[OO]}var Hh=class{list;set;delays=null;latest=0;soonest=0;constructor(t,n){if(Array.isArray(t)&&C$(t)){this.list=t.slice(),this.set=null,n&&(this.delays=FO(this.list,n)),[this.latest,this.soonest]=LO(this.delays);return}let r=[],o=null;for(let i of t)o!==null?o.has(i)||(o.add(i),r.push(i)):r.includes(i)||(r.push(i),r.length>8&&(o=new Set(r)));this.list=r.slice(),this.set=o,n&&(this.delays=FO(this.list,n)),[this.latest,this.soonest]=LO(this.delays)}get size(){return this.list.length}has(t){return this.set===null?this.list.includes(t):this.set.has(t)}};function FO(e,t){let n=new Map;for(let r of e)n.set(r,t(r));return n}function LO(e){let t=0,n=0;for(let r of e?.values()??[])r>t&&(t=r),r<n&&(n=r);return[t,n]}function C$(e){let t=e.length;if(t>8)return!1;for(let n=1;n<t;n++){let r=e[n];for(let o=0;o<n;o++){let i=e[o];if(r===i||Number.isNaN(r)&&Number.isNaN(i))return!1}}return!0}var O$=256;function Fo(e,t,n=!1){let r=e.clocks;if(r!==null&&r.length>=O$)return;let o=e.holding!==null||e.spec.stagger!==void 0?Number.POSITIVE_INFINITY:0;if(r!==null&&_O(r,0)>=o&&_O(r,DO(e))>=o)return;let{anchorNow:i,anchorElapsed:s,rate:a,ramp:l,rebuilds:u}=e,c={anchorNow:i,anchorElapsed:s,rate:a,ramp:l,until:t,rebuilds:u,sought:n};r===null?e.clocks=[c]:r.push(c)}function _O(e,t){let n=Number.NEGATIVE_INFINITY;for(let r=t;r<e.length;r++){let o=e[r],i=ze(o,o.until);i>n&&(n=i)}return n}function DO(e){let t=e.clocks;if(t===null)return 0;let n=0;for(;n<t.length&&t[n].rebuilds!==e.rebuilds;)n++;return n}function F$(e,t,n){for(let r=t.length-1;r>=0;r--)if(t[r].sought&&(t[r+1]?.anchorElapsed??e.anchorElapsed)<n)return r+1;return 0}function Gh(e,t,n){let r=e.clocks,o=e.beginless?e.start:Number.NaN;if(r!==null&&Number.isNaN(o)){let i=n?Math.max(DO(e),F$(e,r,t)):0;for(let s=i;s<r.length;s++){let a=r[s],l=Cn(a,t);if(l<=a.until){o=l;break}}}return Number.isNaN(o)&&(o=Cn(e,t),o===Number.POSITIVE_INFINITY&&(o=e.start+t)),e.owner===null?o:Gh(e.owner,o,n)}function Lo(e){return e.owner===null?e.start:Gh(e.owner,e.start,!1)}var Wi=Object.freeze({form:"fn",duration:0,writes:[],at:()=>({})}),_o=class{children=[];kids=0;played=0;coasts=[];cutSeq=Number.POSITIVE_INFINITY;get coast(){let t=this.coasts.length;return t===0?Number.NEGATIVE_INFINITY:this.coasts[t-1]}left(t,n){t===void 0?n<this.cutSeq&&(this.cutSeq=n):t>this.coast&&this.coasts.push(n,t)}back(t){let n=this.coasts;for(;n.length>0&&n[n.length-2]>t;)n.length-=2;this.cutSeq>t&&(this.cutSeq=Number.POSITIVE_INFINITY)}};function Te(e,t){let n=e.owner===null?t:Te(e.owner,t);return n>=e.start?ze(e,n):Number.NEGATIVE_INFINITY}function BO(e,t,n){let r=Te(t,n);return r===Number.NEGATIVE_INFINITY?r:ze(e,r)}function Do(e,t){let n=e.backs?ec(e,t):Cn(e,t);return e.owner===null?n:Do(e.owner,n)}function Uh(e){let t=!1;for(let n=e.owner;n!==null;n=n.owner)n.backs&&(t=!t);return t}function HO(e,t){let n=e.holding;n.children.push(t),n.kids++}function GO(e,t){let n=e.owner,r=n.holding,o=r.children.indexOf(e);return o>=0&&r.children.splice(o,1),!Wr(n,t)&&n.state!=="done"?n:null}function Wr(e,t){for(let n of e.holding.children)if(!n.quietAt(t))return!0;return!1}function UO(e,t,n){let r=e.holding;++r.played===r.kids&&e.play(!0,t,n)}function Vi(e,t){for(let n of e.holding.children)t(n),n.holding!==null&&Vi(n,t)}function WO(e){for(let t=e.owner;t!==null;t=t.owner)if(typeof t.spec.weight=="function")return!0;return!1}function VO(e){for(let t=e.owner;t!==null;t=t.owner){let n=t.spec.weight;if(typeof n=="function"&&n.input)return!0}return!1}function kP(e,t,n,r){let o=typeof e.spec.weight=="function"?r(e):e.weight,i=Lo(e),s=e.freezesBefore&&e.opened<i?e.opened:i;return Br(o*ma(e.fade.in??0,e.out,e.ease,n,t,s,e.back,e.stalls))}function zO(e,t,n,r){let o=1,i=e;for(let s=e.owner;s!==null;i=s,s=s.owner)o*=kP(s,t,n,r),s.arc!==null&&(o*=KO(s,i,t,n));return o}function Sa(e,t){let n=new Map;for(let r of e)if(n.set(r.id,r),r.holding!==null){let o=new _o;o.kids=r.holding.kids,o.played=r.holding.played,o.coasts=r.holding.coasts.slice(),o.cutSeq=r.holding.cutSeq,t!==void 0&&o.back(t),r.holding=o}for(let r of e){let o=r.owner===null?void 0:n.get(r.owner.id);o!==void 0&&(r.owner=o,o.holding.children.push(r))}}function AP(e,t,n){let r=n.writes??(n.kit?Object.keys(n.kit):void 0);if(r===void 0)throw new Error("blits: a patch needs writes, or a kit to take them from");return{form:"fn",duration:e,writes:r,kit:n.kit,reads:n.reads,at:t,state:n.state,step:n.step,pack:n.pack,unpack:n.unpack}}var L$=(e,t,n)=>e+(t-e)*n;function vP(e,t,n){if(typeof e=="number"&&typeof t=="number")return L$(e,t,n);if(Array.isArray(e)&&Array.isArray(t)){let r=new Array(e.length);for(let o=0;o<e.length;o++)r[o]=vP(e[o],t[o],n);return r}return n<.5?e:t}function _$(e,t,n,r){let o=r.ease===void 0?void 0:Co(r.ease),i=[];for(let s of t){let a=r.easeBy?.(s),l=a===void 0?o:Co(a),u=[];for(let p of e){let h=p.delta[s];h!==void 0&&u.push({at:p.at,value:Array.isArray(h)?[...h]:ArrayBuffer.isView(h)?h.slice():h,ease:p.ease===void 0?l:Co(p.ease)})}u.sort((p,h)=>p.at-h.at);let c=u.filter(p=>p.at!==0),d=r.lerpBy?.(s)??r.kit?.[s]?.lerp,f=u.length>0&&(d===void 0||d===Ct)&&u.every(p=>typeof p.value=="number");i.push({channel:s,all:u,tail:c,ats:u.map(p=>p.at),tailAts:null,delay:r.delayBy?.(s)??0,lerp:d,numbers:f?{ats:Float64Array.from(u,p=>p.at),values:Float64Array.from(u,p=>p.value),eases:u.map(p=>p.ease)}:null})}return{tracks:i,duration:n}}var Vh=0,ka=1,D$=2,Be={a:void 0,b:void 0,u:0,eased:0,first:!1,len:0,ease:void 0};function RP(e,t,n){return NP(e.delay,t,n)}function NP(e,t,n){return e===0||n===0?t:e>=n?t>=1?1:0:Math.max(0,(t*n-e)/(n-e))}function IP(e,t,n,r,o){return r===0?-2:o<=e[t]?-1:o>=e[t+(r-1)*n]?r:$O(e,t,n,1,r-1,o)}function $O(e,t,n,r,o,i){for(;r<o;){let s=r+o>>1;e[t+s*n]>=i?o=s:r=s+1}return r}function EP(e,t,n){return(e-t)/(n-t)}function MP(e,t,n){let r,o=n===void 0?0:1,i=o===0?e.all:e.tail;if(o===0){let c=i.length;if(r=IP(e.ats,0,1,c,t),r===-2)return Vh;if(r===-1||r===c)return Be.a=i[r===-1?0:c-1].value,ka}else{let c=i.length+1;if(t<=0)return Be.a=n,ka;let d=i[i.length-1];if(d===void 0||t>=d.at)return Be.a=d===void 0?n:d.value,ka;e.tailAts??=i.map(f=>f.at),r=$O(e.tailAts,-1,1,1,c-1,t)}let s=i[r-o],a=r-1<o?0:i[r-1-o].at,l=EP(t,a,s.at),u=s.ease?s.ease(l):l;return Be.a=r-1<o?n:i[r-1-o].value,Be.b=s.value,Be.u=l,Be.eased=u,Be.first=r-1<o,Be.len=s.at-a,Be.ease=s.ease,D$}function B$(e,t){let n=e.ats,r=e.values,o=n.length;if(t<=n[0])return r[0];if(t>=n[o-1])return r[o-1];let i=1,s=o-1;for(;i<s;){let f=i+s>>1;n[f]>=t?s=f:i=f+1}let a=n[i-1],l=(t-a)/(n[i]-a),u=e.eases[i],c=u?u(l):l,d=r[i-1];return d+(r[i]-d)*c}function H$(e,t,n,r,o,i,s,a){let l=e.numbers;if(l!==null&&n===void 0&&o===void 0&&(r===void 0||r===Ct||e.lerp!==void 0))return B$(l,t);let u=MP(e,t,n);if(u===Vh)return;if(u===ka)return Be.a;let c=Be.a,d=Be.b,f=Be.u,p=Be.eased,h=Be.first,m=Be.len,g=Be.ease,b;if(s!==void 0)b=s(a,c,d,p),Wh.wrote=b;else{let y=e.lerp??r;b=y?y(c,d,p):vP(c,d,p)}if(o===void 0||!h)return b;let x=g?rO(g):1;if(x===Number.POSITIVE_INFINITY)return b;let w=(y,P,S)=>(y*i*m-(S-P)*x)*f*(1-f)*(1-f);if(typeof b=="number"&&typeof o=="number")return b+w(o,c,d);if(Array.isArray(b)&&Array.isArray(o)){let y=b===Wh.wrote?b:new Array(b.length),P,S=()=>{let v=e.lerp??r,A=N=>s!==void 0?s(void 0,c,d,N):v?v(c,d,N):vP(c,d,N);return P=[A(0),A(1)],P};for(let v=0;v<b.length;v++){let A=b[v],N=o[v];if(typeof A!="number"||typeof N!="number"){y[v]=A;continue}let M=c[v],C=d[v];if(typeof M!="number"||typeof C!="number"){let[F,B]=P??S();M=F?.[v],C=B?.[v]}y[v]=typeof M=="number"&&typeof C=="number"?A+w(N,M,C):A}return y}return b}var Wh={wrote:void 0};function YO(e,t){return e.tracks.map((n,r)=>{let o=t[r];return n.lerp===void 0||n.lerp===o.lerp?Ph(o):void 0})}function zh(e,t,n,r,o,i,s,a){let l=e.duration;for(let u=0;u<e.tracks.length;u++){let c=e.tracks[u],d=i?.[c.channel],f=a===void 0?void 0:s?.[u];Wh.wrote=void 0;let p=H$(c,RP(c,t,l),r?.[c.channel],o?.[u],l===0?void 0:d,l,f,f===void 0?void 0:a[u]);f!==void 0&&p===Wh.wrote&&(a[u]=p),p!==void 0?n[c.channel]=p:n[c.channel]!==void 0&&(n[c.channel]=void 0)}return n}var jO=new WeakMap;function qO(e){let t=jO.get(e);return t===void 0&&(t=_$(e.keys,e.writes,e.duration,e),jO.set(e,t)),t}function CP(e){return function(n,r){let o=e.keepOn,i=o===null?e.ownKept:o.kept;if(i===null&&(i=new Map,o===null?e.ownKept=i:o.kept=i),i.has(n))return i.get(n);let s=o?.unkept,a=s===void 0?r():s.shift();return s?.length===0&&o!==null&&(o.unkept=void 0),i.set(n,a),pe.kept++,a}}var Kh=class{host;send;voice;timestamp=0;dt=0;elapsed=0;pass=0;weight=0;state=void 0;mark=0;kept=null;constructor(t,n,r){this.host=t,this.send=n,this.voice=r}get keep(){return this.kept===null&&(this.kept=CP(this.voice)),this.kept}};function sc(e,t){let n=e.named?.delays?.get(t);return n!==void 0?n:e.spec.stagger?e.spec.stagger(t):0}function ac(e,t){let n=e.unreachedBits;if(n===null||t<0)return!1;let r=t>>>5;return r<n.length&&(n[r]&1<<(t&31))!==0}function Vr(e,t,n){let r=e.unreachedBits,o=t>>>5;if(r===null||o>=r.length){if(!n)return;let s=new Uint32Array(Math.max(o+1,(r?.length??0)*2,2));r!==null&&s.set(r),e.unreachedBits=s,r=s}let i=1<<(t&31);r[o]=n?r[o]|i:r[o]&~i}function OP(e,t,n){ac(e,t)&&(Vr(e,n,!0),Vr(e,t,!1))}function XO(e,t){let n=this.sinceOf(e,0),r=On(e,!1,void 0);return r.since=n,r.shown=this.shownOf(e,n),r.stepped=t,r.rebuilt=e.rebuilds,e.unreached=r,r}function JO(e,t,n,r=null){if(e.sharing){let d=this.share.everyoneOf(this,e);if(d!==null)return d}if(ac(e,n))return e.unreached;let o=r===null?e.subjects.get(t):e.subjects.find(t,r);if(o!==void 0)return o;let i=this.now;if(!this.aims(e,t)){let d=e.unreached??this.unreachedOf(e,i);return n>=0&&e.named===null?Vr(e,n,!0):e.subjects.set(t,d),d}this.keys!==null&&(e.keyed??=new Set,e.keyed.add(this.keys.key(t)));let a=sc(e,t),l=this.sinceOf(e,a),u=this.shownOf(e,l);o=On(e,!0,e.patch.state?e.patch.state(t):void 0),o.delay=a,o.since=l,o.shown=u;let c=FP(this,e,o,i);return o.rebuilt=e.rebuilds,this.projecting&&(o.from=o.stepped,o.unknown=this.backward&&e.spec.from==="current"||c),e.subjects.set(t,o),LP(e,o,i),e.sighted!==null&&this.share?.sighted(e,n)?this.share.inherit(e,o,n):e.seen++,a>e.latest&&(e.latest=a,e.state==="frozen"&&it(this,e)),a<e.soonest&&(e.soonest=a,it(this,e)),o}function FP(e,t,n,r){let o=n.since;if(!(o<r))return n.stepped=r,!1;if(t.spec.catchUp!=="fresh"||t.patch.step===void 0)return n.stepped=o,!1;let i=Io(e,t);return i===void 0?n.stepped=r:(n.ticks=Math.floor((r-o)/i+1e-9),n.stepped=o+n.ticks*i),n.stepped>o}function QO(e,t){let n=e.patch;return Gh(e,t,n.state!==void 0||n.step!==void 0||e.keeping)}function ZO(e,t){let n=Lo(e),r=t<n?n:t;return e.freezesBefore&&e.opened<r?e.opened:r}function eF(e,t,n){return!(t.since<=n)||e.motion!==void 0&&!(t.probed>=t.since)}function LP(e,t,n){if(t.since<=n)return;e.early??=[];let r=e.early;if(r.length>=64&&(r.length&r.length-1)===0){let o=0;for(let i of r)eF(e,i,n)&&(r[o++]=i);r.length=o}r.push(t)}function va(e,t,n){t.state="live",t.begunSeq=e.transport.seq,t.anchorElapsed!==0&&(t.seeks++,t.rebuilds++,t.note(n,e.transport.seq,!0)),dn(e,t,n),Ur(e,t)}function Aa(e,t,n){let r=n.since;n.since=e.sinceOf(t,n.delay),n.since!==r&&(n.ticks>0||n.stepped>r)&&(n.rebuilt=-1),n.shown=e.shownOf(t,n.since),n.ticks===0&&n.stepped>n.since&&(n.stepped=n.since)}function dn(e,t,n){let r=t.early;if(r===null)return;let o=0;for(let i of r)Aa(e,t,i),eF(t,i,n)&&(r[o++]=i);r.length=o,o===0&&(t.early=null),e.lanes?.reshown(t.id)}var jh=class{of=null;count=0;general=[];named=new me;latest=Number.NEGATIVE_INFINITY;slack=0};function G$(e,t){let n=t.reachedTo;if(n<e.latest?e.slack=Math.max(e.slack,e.latest-n):e.latest=n,t.named===null){e.general.push(t);return}for(let r of t.named.list){let o=e.named.get(r);o===void 0?e.named.set(r,[t]):o.push(t)}}function tF(e,t){let n=!1;for(let r of t){if(r.named===null){n=!0;continue}for(let o of r.named.list){let i=e.named.get(o);if(i===void 0)continue;let s=i.indexOf(r);s>=0&&i.splice(s,1),i.length===0&&e.named.delete(o)}}if(n){let r=new Set(t);e.general=e.general.filter(o=>!r.has(o))}}function Bo(e){let t=e.goneIx,n=e.gone;(t.of!==n||t.count>n.length)&&(t.general=[],t.named=new me,t.count=0,t.of=n,t.latest=Number.NEGATIVE_INFINITY,t.slack=0);for(let r=t.count;r<n.length;r++)G$(t,n[r]);return t.count=n.length,t}function nF(e,t){for(let n of t)e.parters.delete(n),e.departed.add(e,n),n.doneAt>e.transport.forgotTo&&(e.transport.forgotTo=n.doneAt)}function _P(e,t){let n=Bo(e),r=e.gone,o=0;for(;o<r.length&&t(r[o]);)o++;if(o===r.length)return;let i=r.slice(0,o),s=[r[o]];for(o++;o<r.length;o++){let a=r[o];(t(a)?i:s).push(a)}tF(n,s),nF(e,s),e.gone=i,TP(e,r,s),n.of=i,n.count=i.length}function rF(e,t){let n=Bo(e);if(!Number.isFinite(n.slack)){_P(e,u=>u.reachedTo>=t);return}let r=e.gone,o=t+n.slack,i=0,s=!1;for(let u=Number.NEGATIVE_INFINITY;i<r.length&&u<o;i++){let c=r[i].reachedTo;c<t&&(s=!0),c>u&&(u=c)}if(!s)return;let a=[],l=[];for(let u=0;u<i;u++){let c=r[u];(c.reachedTo<t?l:a).push(c)}r.splice(0,i,...a),tF(n,l),nF(e,l),TP(e,r,l),n.count=r.length}var oF=[];function DP(e,t){return e>=0&&(t>0?e<t:Number.isFinite(e))}function iF(e,t){for(let n of e)if(!DP(n.at,t))throw new RangeError(t>0?`blits: a hit's at is voice ms into a pass, 0 up to ${t}, not ${n.at}`:`blits: a hit's at is voice ms, 0 or more, not ${n.at}`)}var $h=class{host;opts;est=Number.NaN;last=Number.NaN;prev=Number.NaN;round=0;canceled=!1;floor=Number.NEGATIVE_INFINITY;marked=new Map;tracks=new Map;due=[];constructor(t,n){this.host=t,this.opts=n}sync(){if(this.canceled)return;let t=this.host,n=t.timestamp,r=this.opts.clock();if(Number.isNaN(this.est))this.est=r;else{let a=this.est+(n-this.last),l=r-a;this.est=Math.abs(l)>50?r:a+l*.05}this.last=n;let o=Number.isNaN(this.prev)?t.now:this.prev;this.prev=t.now,this.round++,this.marks(n),this.hits(n,o);let i=this.due;i.sort((a,l)=>a.time-l.time);let s=this.opts.late;for(let a of i){let l=a.time<n?n-a.time:0;if(l>s)continue;let u=this.est+(a.time-n),c={time:a.time,at:u,taken:void 0};a.into.set(a.key,c),c.taken=this.opts.take(a.item,l>0?r:Math.max(u,r),l)}i.length=0;for(let a of this.tracks.values())for(let[l,u]of a.booked)u.time<=n&&a.booked.delete(l)}cancel(){if(!this.canceled){this.canceled=!0;for(let t of this.marked.values())t.time>this.last&&t.taken?.cancel();for(let t of this.tracks.values())for(let n of t.booked.values())n.time>this.last&&n.taken?.cancel();this.marked.clear(),this.tracks.clear(),this.host.unhook(this)}}sought(){if(this.canceled)return;let t=this.last;for(let r of this.marked.values())r.time>t&&r.taken?.cancel();for(let r of this.tracks.values())for(let o of r.booked.values())o.time>t&&o.taken?.cancel();this.marked.clear(),this.tracks.clear();let n=this.host;this.floor=n.timestamp,this.prev=n.now;for(let r of n.voices)r.spec.hits!==void 0&&r.state!=="done"&&this.tracks.set(r,{seenTo:r.elapsedAt(n.now),jumps:r.jumps,booked:new Map,met:this.round})}at(t){return this.est+(t-this.last)}stands(t,n){return n===void 0||!Number.isFinite(n)?!1:Math.abs(this.est+(n-this.last)-t.at)<=1}fits(t,n){let{tag:r,score:o}=this.opts;return(o===void 0||t===o)&&(r===void 0||n.includes(r))}marks(t){let n=this.host.marks(t-this.opts.late,t+this.opts.ahead),r=this.marked,o=new Set;for(let i of n){if(!this.fits(i.score,i.tags)||i.timestamp<=this.floor)continue;let s=U$(i);o.add(s);let a=r.get(s);if(a!==void 0){if(a.time<=t||this.stands(a,i.timestamp))continue;a.taken?.cancel(),r.delete(s)}let{order:l,...u}=i;this.due.push({time:i.timestamp,item:u,into:r,key:s})}for(let[i,s]of r)o.has(i)||(s.time>t&&s.taken?.cancel(),r.delete(i))}hits(t,n){let r=this.host,o=this.round,{ahead:i,late:s}=this.opts,a=r.readingAt(t+i),l=Number.isFinite(s)?r.readingAt(t-s):Number.NEGATIVE_INFINITY;for(let u of r.voices){let c=u.spec.hits;if(c===void 0||c.length===0||u.state==="done"||!this.fits(u.spec.score,u.spec.tags??oF))continue;let d=this.tracks.get(u);d===void 0&&(d={seenTo:Number.NEGATIVE_INFINITY,jumps:u.jumps,booked:new Map,met:o},this.tracks.set(u,d)),d.met=o,d.jumps!==u.jumps&&(d.jumps=u.jumps,d.seenTo=u.elapsedAt(n));let f=r.endOf(u),p=c.length,h=!1;for(let[w,y]of d.booked){if(y.time<=t)continue;let P=this.timeOfHit(u,c,Math.floor(w/p),w%p,f);this.stands(y,P)||(y.taken?.cancel(),d.booked.delete(w),h=!0)}h&&(d.seenTo=Math.min(d.seenTo,u.elapsedAt(n)));let m=u.elapsedAt(a);if(!(m>d.seenTo))continue;let g=Math.max(d.seenTo,u.elapsedAt(l));if(!(g<=m)){d.seenTo=m;continue}let b=u.duration,x=b>0?Math.min(u.passes-1,Math.floor(m/b)):0;for(let w=b>0?Math.max(0,Math.floor(g/b)):0;w<=x;w++)for(let y=0;y<p;y++){let P=w*b+c[y].at;if(!(P>d.seenTo&&P<=m))continue;let S=w*p+y;if(d.booked.has(S))continue;let v=this.timeOfHit(u,c,w,y,f);if(v===void 0||!Number.isFinite(v))continue;let A={timestamp:v,voice:u.id,hit:y,pass:w,event:c[y].event,score:u.spec.score,name:u.spec.name,tags:u.spec.tags??oF,subjects:u.named?.list};this.due.push({time:v,item:A,into:d.booked,key:S})}d.seenTo=m}for(let[u,c]of this.tracks)if(c.met!==o){for(let d of c.booked.values())d.time>t&&d.taken?.cancel();this.tracks.delete(u)}}timeOfHit(t,n,r,o,i){if(t.state==="done"||r>=t.passes)return;let s=t.timeAt(r*t.duration+n[o].at);if(!(!Number.isFinite(s)||i!==void 0&&s>=i))return this.host.hostOf(s)}};function U$(e){let t=e.order*6;switch(e.mark){case void 0:return t;case"start":return t+1;case"in":return t+2;case"coast":return t+3;case"out":return t+4;case"end":return t+5;default:return`${e.order}\0${e.mark}`}}var zi=["start","in","coast","out","end"];function lF(e,t){for(let n of Object.keys(e)){if(zi.includes(n))throw new Error(`blits: ${n} is one of a voice's own marks; a mark placed inside it needs another name`);let r=e[n];if(!DP(r,t))throw new RangeError(t>0?`blits: mark ${n} is voice ms into a pass, 0 up to ${t}, not ${r}`:`blits: mark ${n} is voice ms, 0 or more, not ${r}`)}}function BP(e,t){return(e.pace===null?t:e.pace.timeOf(t))+e.offset}function uF(e,t){return e.pace===null?t:e.pace.reading(t)}function Yh(e,t,n){let r=pF(e,t,n);for(let o of fF(e.transport,t,n))(o.score!==void 0||o.slot===e.slot)&&r.push(o.listed);return dF(r)}function cF(e,t,n){let r=[];for(let o of e.members)r.push(...pF(o,t,n));for(let o of fF(e,t,n))r.push(o.listed);return dF(r)}function dF(e){return e.sort((t,n)=>t.timestamp-n.timestamp||t.order-n.order)}function fF(e,t,n){let r=t-e.offset,o=n-e.offset,i=[];for(let s of e.announced)s.at>=r&&s.at<=o&&i.push({score:s.score,slot:s.slot,listed:{timestamp:s.at+e.offset,mark:void 0,voice:void 0,score:s.score,name:s.name,tags:s.tags,mix:s.mix,order:s.order}});return i}function pF(e,t,n){let r=t-e.offset,o=n-e.offset,i=[];for(let s of[...e.cued,...e.gone]){for(let l of zi)sF(e,s,l,r,o,i);let a=s.spec.marks;if(a!==void 0)for(let l of Object.keys(a))sF(e,s,l,r,o,i)}return i}function sF(e,t,n,r,o,i){let s=Xe(e,t,n),a=s===void 0?s:BP(e,s)-e.offset;a===void 0||a<r||a>o||i.push({timestamp:a+e.offset,mark:n,voice:t.id,score:t.spec.score,name:t.spec.name,tags:t.spec.tags??fn,mix:e.name,order:t.id})}function Xe(e,t,n){if(!Number.isFinite(t.start))return;let r=_n(t);if(!Number.isFinite(r))return;if(n==="start")return r;if(t.arc!==null&&(n==="in"||n==="coast"||n==="out"||n==="end"))return mF(t,r,n);if(n==="in")return r+(t.fade.in??0);if(n==="coast")return V$(e,t,r);if(n!=="out"&&n!=="end")return W$(e,t,r,n);let o=t.out,i,s=!1;if(o!==null)i=o.at;else if(Number.isFinite(t.outAt))i=t.outAt;else if(t.fitting!==null){let l=t.timeAt(t.fitting.end);Number.isFinite(l)&&(i=Math.max(r,l))}else if(t.holding!==null){let l=hF(e,t.holding.children,"end");l!==void 0&&(i=Math.max(r,l),s=!0)}else if(!(t.backs?t.freezesBefore:t.freezesAfter)){let l=t.endsAt();Number.isFinite(l)&&(i=Math.max(r,l))}if(n==="out")return t.state==="done"&&i===void 0?t.doneAt:i;if(t.state==="done")return t.doneAt;if(o!==null)return o.rest?o.deadline===void 0?void 0:o.at+o.deadline:o.at+o.over;if(s)return i;let a=Number.isNaN(t.outOver)?t.fade.out??0:t.outOver;return i===void 0?void 0:i+(e.reduced?0:a)}var aF=1e-9;function W$(e,t,n,r){let o=t.spec.marks;if(o===void 0||!Object.hasOwn(o,r)||t.backs)return;let i=o[r],s=t.elapsedAt(n),a=t.duration,l=0;if(a>0)l=Math.max(0,Math.ceil((s-i)/a-aF));else if(i<s-aF)return;if(l>=t.passes)return;let u=t.timeAt(l*a+i);if(!Number.isFinite(u))return;let c=Xe(e,t,"end");return c!==void 0&&u>=c?void 0:Math.max(n,u)}function V$(e,t,n){if(t.unplayed)return;let r;if(t.fitting!==null)r=t.timeAt(t.fitting.end);else if(t.holding!==null){let i=t.holding;if(i.cutSeq!==Number.POSITIVE_INFINITY)return;i.children.length===0?r=t.state==="done"?i.coast:void 0:(r=hF(e,i.children,"coast"),r!==void 0&&(r=Math.max(r,i.coast)))}else r=t.endsAt();return r===void 0||!Number.isFinite(r)?void 0:(r=Math.max(n,r),(t.out!==null?t.out.at:t.state==="done"?t.doneAt:t.outAt)<r?void 0:r)}function hF(e,t,n){if(t.length===0)return;let r=Number.NEGATIVE_INFINITY;for(let o of t){let i=Xe(e,o,n);if(i===void 0)return;i>r&&(r=i)}return r}var qh=class{start=void 0;in=void 0;coast=void 0;out=void 0;end=void 0};Object.setPrototypeOf(qh.prototype,null);var Xh=class{scopes=new Map;all=new Set;add(t,n){if(n.owner?.state==="done")return;let r=new qh;for(let a=0;a<zi.length;a++){let l=zi[a];r[l]=Xe(t,n,l)}let o=n.spec.marks;if(o!==void 0)for(let a of Object.keys(o))r[a]=Xe(t,n,a);let i={id:n.id,score:n.spec.score,owner:n.owner?.id??-1,name:n.spec.name,tags:n.spec.tags??fn,writes:n.patch.writes,marks:r,held:0},s=this.scopeOf(i.score,i.owner);s.whole===void 0?(s.whole={first:i,last:i},i.held+=2):this.hold(s.whole,i),i.name!==void 0&&this.keep(s.names,i.name,i);for(let a=0;a<i.tags.length;a++)this.keep(s.tags,i.tags[a],i);for(let a=0;a<i.writes.length;a++)this.keep(s.writes,i.writes[a],i);i.held>0&&this.all.add(i),n.holding!==null&&this.dropOwner(n.id)}dropOwner(t){for(let n of this.scopes.values()){let r=n.get(t);if(r!==void 0){n.delete(t),r.whole!==void 0&&this.forget(r.whole);for(let o of r.names.values())this.forget(o);for(let o of r.tags.values())this.forget(o);for(let o of r.writes.values())this.forget(o)}}}scopeOf(t,n){let r=this.scopes.get(t);r===void 0&&(r=new Map,this.scopes.set(t,r));let o=r.get(n);return o===void 0&&(o={whole:void 0,names:new Map,tags:new Map,writes:new Map},r.set(n,o)),o}keep(t,n,r){let o=t.get(n);o===void 0?(t.set(n,{first:r,last:r}),r.held+=2):this.hold(o,r)}hold(t,n){this.release(t.last),t.last=n,n.held++}forget(t){this.all.delete(t.first),this.all.delete(t.last)}release(t){--t.held===0&&this.all.delete(t)}};function yF(e,t,n,r,o){return e.score===n&&(r||e.owner===o)&&(t.name===void 0||e.name===t.name)&&(t.tag===void 0||e.tags.includes(t.tag))&&(t.writes===void 0||e.writes.includes(t.writes))}function lc(e,t){return t.owner===null?e.now:Te(t.owner,e.now)}function _n(e){return e.owner===null?e.start:Do(e.owner,e.start)}function Ki(e,t){return e.pace===null?t:e.pace.at(t,e.u)}function Ho(e,t,n){e.pins??=new Map,e.pins.set(t,n),t.pinned=n}function bF(e){let t=e.pins;for(let[n,r]of t)n.state!=="pending"?t.delete(n):Ia(e,n,Ki(e,r))}function Ia(e,t,n){return n===t.start?!1:(t.start=n,t.anchorNow=n,t.clocks=null,t.seeks++,dn(e,t,e.now),Ke(e,t),!0)}function xF(e,t,n,r){if(n.start!==void 0&&n.in!==void 0)throw new Error("blits: a placement anchors start or in, not both");if(n.out!==void 0&&n.end!==void 0)throw new Error("blits: a placement anchors out or end, not both");if(t.start!==void 0&&(n.start!==void 0||n.in!==void 0))throw new Error("blits: a voice takes start or an anchored start, not both");let o={id:e.nextId,spec:t,owner:r,slot:e.slot,writes:t.patch?.writes??fn},i=[o];for(let u of e.transport.members)for(let c of[u.gone,u.cued])for(let d of c)i.push({id:d.id,spec:d.spec,owner:d.owner,slot:u.slot,writes:d.patch.writes});let s=()=>{throw new Error(`blits: ${t.name??"a voice"}'s placement waits on itself`)},a=(u,c)=>{if("all"in c)return c.all.flatMap(y=>a(u,y));if("any"in c)return c.any.flatMap(y=>a(u,y));let d="of"in c?c.of:"after"in c?c.after:"with"in c?c.with:c.before,f="of"in c?c.mark:"after"in c?"end":"start",p=typeof d=="string"?{name:d}:d,h=p.score??u.spec.score,m=p.score!==void 0;u===o&&p.name!==void 0&&p.name===t.name&&h===t.score&&s();let g=i.filter(y=>y!==u&&y.spec.score===h&&(m||y.owner===u.owner&&y.slot===u.slot)&&(p.name===void 0||y.spec.name===p.name)&&(p.tag===void 0||(y.spec.tags??fn).includes(p.tag))&&(p.writes===void 0||y.writes.includes(p.writes))),b=p.resolver??"last",x=g.length>1&&(b==="first"||b==="last")?[g.reduce((y,P)=>(b==="last"?P.id>y.id:P.id<y.id)?P:y)]:g,w=f==="out"||f==="end"?"out":"start";return x.map(y=>({voice:y,side:w}))},l=(u,c)=>{let d=u.spec.anchor,f=c==="start"?[d?.start,d?.in]:[d?.out,d?.end],p=c==="out"?[{voice:u,side:"start"}]:[];for(let h of f)h!==void 0&&typeof h!="number"&&p.push(...a(u,h));return p};for(let u of["start","out"]){let c={start:new Set,out:new Set},d=l(o,u);for(;d.length>0;){let{voice:f,side:p}=d.pop();f===o&&p===u&&s(),!c[p].has(f)&&(c[p].add(f),d.push(...l(f,p)))}}}function zr(e){for(let t=0;t<=e.cued.length;t++){let n=!1;for(let r of e.cued){let o=r.spec.anchor;if(!(o===void 0||r.state==="done")){if(r.placing&&r.state==="pending"){let i=o.start??o.in,s=i===void 0?void 0:Na(e,i,r);if(s!==void 0){let a=r.owner,l=r.fade.in??0,u=o.start!==void 0?s:a===null?s-l:Te(a,Do(a,s)-l);Number.isFinite(u)&&Ia(e,r,u)&&(n=!0)}}if(r.state!=="fading"&&!r.outSet){let i=o.out??o.end,s=i===void 0?void 0:Na(e,i,r);if(s!==void 0){let a=r.owner===null?s:Do(r.owner,s),l=_n(r),u=o.out!==void 0?a:a-(r.fade.out??0),c=Number.NaN;u<l&&Number.isFinite(l)&&(u=l,o.end!==void 0&&(c=a>l?a-l:0,a<l&&!e.projecting&&er(r,`${r.spec.name??`voice ${r.id}`}'s placement ends before it starts, so it plays as an instant`))),(u!==r.outAt||!Kt(c,r.outOver))&&(r.outAt=u,r.outOver=c,Ke(e,r),n=!0)}}}}if(!n)break}wF(e)}function Na(e,t,n,r){let o=n.owner;if(typeof t=="number")return o===null?Ki(e,t-n.offset):t;if("all"in t){let c=Number.NEGATIVE_INFINITY;for(let d of t.all){let f=gF(e,d,n,r);if(f===void 0)return;c=Math.max(c,f)}return t.all.length===0?void 0:c}if("any"in t){let c=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:lc(e,n),d=Number.POSITIVE_INFINITY,f=!1;for(let p of t.any){let h=gF(e,p,n,r);h===void 0?f=!0:d=Math.min(d,h)}return d===Number.POSITIVE_INFINITY||f&&d>c?void 0:d}let i,s,a=t.by??0;"of"in t?(i=t.of,s=t.mark):"after"in t?(i=t.after,s="end"):"with"in t?(i=t.with,s="start"):(i=t.before,s="start",a=-a);let l=z$(e,i,s,n);if(l===void 0)return;if(o===null)return l+a;let u=Te(o,l);return u===Number.NEGATIVE_INFINITY?r:Number.isFinite(u)?u+a:void 0}function gF(e,t,n,r){let o=Na(e,t,n,r);return o===void 0?n.answers?.get(t):(e.projecting||(n.answers??=new Map,n.answers.set(t,o)),o)}var Ra=class{resolver;now;any=!1;firstOrder=Number.POSITIVE_INFINITY;lastOrder=Number.NEGATIVE_INFINITY;first;last;pick;constructor(t,n){this.resolver=t,this.now=n}take(t,n){this.any=!0,t<this.firstOrder&&(this.firstOrder=t,this.first=n),t>this.lastOrder&&(this.lastOrder=t,this.last=n),n!==void 0&&this.consider(n)}merge(t){t.any&&(this.any=!0,t.firstOrder<this.firstOrder&&(this.firstOrder=t.firstOrder,this.first=t.first),t.lastOrder>this.lastOrder&&(this.lastOrder=t.lastOrder,this.last=t.last),t.pick!==void 0&&this.consider(t.pick))}consider(t){let n=this.pick;(this.resolver==="earliest"?n===void 0||t<n:this.resolver==="latest"?n===void 0||t>n:this.resolver==="next"&&t>=this.now&&(n===void 0||t<n))&&(this.pick=t)}answer(){if(this.any)return this.resolver==="first"?this.first:this.resolver==="last"?this.last:this.pick}};function z$(e,t,n,r){let o=typeof t=="string"?{name:t}:t,i=o.score??r.spec.score,s=o.score!==void 0,a=o.resolver??"last",l=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,u=new Ra(a,l),c=m=>m!==r&&m.spec.score===i&&(s||m.owner===r.owner)&&(o.name===void 0||m.spec.name===o.name)&&(o.tag===void 0||(m.spec.tags??fn).includes(o.tag))&&(o.writes===void 0||m.patch.writes.includes(o.writes)),d=s&&i!==void 0&&!e.projecting,f=s?d?wO(e,i):e.transport.members:[e],p=r.owner?.id??-1,h=new Ra(a,l);for(let m=0;m<f.length;m++){let g=f[m],b=!1;for(let v of g.departed.all)yF(v,o,i,s,p)&&(h.take(v.id,v.marks[n]),b=!0);if(i===void 0||g.projecting||e.projecting){for(let v of[...g.gone,...g.cued])c(v)&&u.take(v.id,Xe(g,v,n));continue}let x=vO(g,i),w=AO(g,i);if(x.size===0&&w.length===0&&!b){d&&(PP(g,i),m--);continue}if(a==="next"){for(let v of x)c(v)&&u.take(v.id,Xe(g,v,n));for(let v of w)c(v)&&u.take(v.id,Xe(g,v,n));continue}let y=K$(g,w,t,n,r,a),P=SO(g,i),S=g.reduced;if(y.live===null||y.liveOf!==g.cued||y.liveVersion!==P||y.liveReduced!==S){let v=new Ra(a,Number.NEGATIVE_INFINITY),A=!0;for(let N of x)c(N)&&((N.owner!==null||N.holding!==null||N.fitting!==null)&&(A=!1),v.take(N.id,Xe(g,N,n)));y.live=v,y.liveOf=A?g.cued:null,y.liveVersion=P,y.liveReduced=S}for(u.merge(y.live);y.seen<w.length;y.seen++){let v=w[y.seen];c(v)&&(v.owner===null?y.pick.take(v.id,Xe(g,v,n)):y.owned.push(v))}u.merge(y.pick);for(let v of y.owned)u.take(v.id,Xe(g,v,n))}if(o.writes===void 0&&(s||r.owner===null))for(let m of e.announced)m.score===i&&(i!==void 0||m.slot===e.slot)&&(o.name===void 0||m.name===o.name)&&(o.tag===void 0||m.tags.includes(o.tag))&&u.take(m.order,Number.isNaN(m.at)?void 0:Ki(e,m.at));return(u.any?u:h).answer()}function K$(e,t,n,r,o,i){o.folds??=new Map;let s=o.folds.get(n);s===void 0&&(s=new Map,o.folds.set(n,s));let a=s.get(e);return(a===void 0||a.list!==t||a.mark!==r)&&(a={list:t,mark:r,seen:0,pick:new Ra(i,Number.NEGATIVE_INFINITY),owned:[],live:null,liveOf:null,liveVersion:-1,liveReduced:!1},s.set(e,a)),a}function GP(e){if(!Number.isFinite(e))throw new RangeError(`blits: a voice's rate is a finite number, not ${e}`)}function UP(e){if(Number.isNaN(e))throw new RangeError("blits: a voice\u2019s weight is a number, not NaN")}var Kr=class{id;#t;#n=null;#e;constructor(t,n){this.id=t.id,this.#t=t,this.#e=n}static voiceOf(t){return t.#t}static page(t,n){t.#t=null,t.#n=n}static rehome(t,n){t.#t=n,t.#n=null}get state(){return this.#t?.state??"done"}get owner(){return this.#t?.owner?.handle??void 0}get played(){return this.#t?.played??Promise.resolve(this.#n?.played??!1)}get done(){return this.#t?.done??Promise.resolve()}get result(){return this.#t?.fitting?.report}get weight(){return this.#t?.weight??this.#n?.weight??0}get#r(){let t=this.#t;return t===null||t.parked?null:t}set weight(t){UP(t);let n=this.#r;n!==null&&(n.written=!0,n.weight=t,this.#e.changed(n),this.#e.taping()&&this.#e.record(this,"weight",r=>{r.weight=t}))}get rate(){let t=this.#t;return t===null?0:t.rateAt(this.#e.nowFor(t))}set rate(t){this.ramp(t,0)}ramp(t,n){GP(t);let r=this.#r;if(r!==null){if(r.written=!0,r.state==="pending"){let o=r.ramp===null?r.rate:r.ramp.from;r.ramp=n>0&&t!==o?{from:o,to:t,over:n}:null,r.rate=t}else{let o=this.#e.nowFor(r);Fo(r,o),ga(r,o,t,n)}this.#e.changed(r),this.#e.taping()&&this.#e.record(this,"rate",o=>o.ramp(t,n))}}seek(t,n){let r=this.#r;if(r===null)return"exact";r.written=!0;let o=!1;if(r.state!=="pending"){let s=this.#e.nowFor(r);Fo(r,s,!0),r.rebase(s),o=t>r.anchorElapsed}r.anchorElapsed=t,r.seeks++;let i=this.#e.sought(r,n?.state!=="keep",o);return this.#e.changed(r),this.#e.taping()&&this.#e.record(this,"seek",s=>s.seek(t,n)),i}fade(t){let n=this.#r;n!==null&&(n.written=!0,this.#e.fade(n,t),this.#e.taping()&&this.#e.record(this,"fade",r=>r.fade(t)))}rise(t){let n=this.#r;n!==null&&(n.written=!0,this.#e.rise(n,t),this.#e.taping()&&this.#e.record(this,"rise",r=>r.rise(t)))}release(){let t=this.#r;t!==null&&(t.written=!0,this.#e.release(t),this.#e.taping()&&this.#e.record(this,"release",n=>n.release()))}weightOf(t){let n=this.#t;return n===null?0:this.#e.weightOf(n,t)}to(t,n,r){let o=this.#t;o!==null&&HP(o.patch,"to","a spring or a tween").to(t,n,r)}push(t,n,r){let o=this.#t;o!==null&&HP(o.patch,"push","a spring or a glide").push(t,n,r)}set(t,n,r){let o=this.#t;o!==null&&HP(o.patch,"set","a motion patch").set(t,n,r)}read(t,n){let r=this.#t;if(!(r===null||Ln(r.patch)===void 0))return r.patch.read(t,n)}};function HP(e,t,n){if(Ln(e)===void 0||typeof e[t]!="function")throw new Error(`blits: ${t} needs a voice playing ${n}`);return e}var j$=new WeakSet,PF=e=>j$.has(e);function uc(e,t,n){let r=n===0?0:Math.abs(e*n-t);return r>=1?0:1-r}var Qh={transport:e=>e,mix:e=>e},cc=Qh,Jh;function Ea(e){throw new Error(`blits: the tape holds ${e}, which a read ahead cannot play; seek there to see it`)}var TF={apply(){},invert:()=>TF};function SF(e){let t=e.history?.tape;if(t!==void 0)return t(e,{now:()=>Number.isNaN(e.u)?Number.NEGATIVE_INFINITY:e.u,branching:!0,coalesceWindowMs:0})}function jr(e){return e.tape!==void 0&&!e.replaying&&!e.projecting}function Ot(e,t,n){let r=e.tape;if(r===void 0||!jr(e))return;let o={label:t,apply(){if(cc===Qh)n(cc);else try{n(cc)}catch(i){Jh??={error:i}}},invert:()=>TF};r.recordEntry([o],t)}function ji(e,t){return e.pace===null?t:e.pace.timeOf(t)}function $r(e,t){let n=ji(e,t);return e.u>n?e.u:n}function Ma(e,t,n=e,r=Qh){let o=e.tape;if(o===void 0)return Number.NaN;let i=n.u,s=Number.NaN;try{for(;;){let a=o.timestampAt(o.undoDepth());if(a===void 0||!t(a))return s;if(a!==s){s=a,n.u=a;let l=n.pace===null?a:n.pace.reading(a);if(l>n.now)for(let u of n.members)Yr(u,l);n.tick(n.now)}e.replaying=!0,cc=r;try{o.redo()}finally{e.replaying=!1,cc=Qh}if(Jh!==void 0){let{error:l}=Jh;throw Jh=void 0,l}}}finally{n.u=i}}function kF(e,t,n){let r=e.strays.get(n);r===void 0?e.strays.set(n,[t]):r.includes(t)||r.push(t)}function vF(e,t){let n=t.motion;if(n===void 0)return;let r=(e.playing.get(n)??1)-1;if(r<=0){e.playing.delete(n),e.strayAll.delete(n);return}if(e.playing.set(n,r),t.named===null)e.strayAll.add(n);else for(let o of t.named.list)kF(e,n,o)}function AF(e){return{frame(t,n){let r=e.deref(),o=r===void 0?void 0:Go(r,t);return r===void 0||o===void 0?Number.NaN:RF(r,o,n)},now(){return e.deref()?.now??Number.NaN},seq(){return e.deref()?.transport.seq??Number.NaN},early(){let t=e.deref();return t!==void 0&&(t.syncing||!t.looked)},changed(t,n,r,o){let i=e.deref();i!==void 0&&jr(i)&&$$(i,t,n,r,o)},page(t,n,r,o){let i=e.deref(),s=i?.opts.history?.ms;i===void 0||i.keys===null||s===void 0||nr(i,n,t,i.keys.key(r),o,a=>a.data,i.now-s)},revive(t,n){let r=e.deref();if(r===void 0)return Number.NaN;r.stir();let o=Go(r,t);return o===void 0||(o.motion!==void 0&&o.named!==null&&!o.named.has(n)&&kF(r,o.motion,n),o.parted?.has(n)!==!0)?Number.NaN:(VP(r,o,n),WP(r,o,sc(o,n)))}}}function $$(e,t,n,r,o){Ot(e,"motion",i=>{let s=i.mix(e);if(s===void 0)return;if(s!==e)return Y$(s,t,n,r,o);((Go(e,t)??e.gone.find(l=>l.id===t))?.motion??n).change(r,{...o})})}function Y$(e,t,n,r,o){let i=r,s=Go(e,t),a=o.at;if(s!==void 0){let p=s.parted?.has(i)===!0;if(p&&VP(e,s,i),a===void 0){let h=RF(e,s,i),m=p?WP(e,s,sc(s,i)):h;Number.isNaN(h)?Number.isNaN(m)||(a=m):a=h}}a===void 0&&Ea("a change to a motion made before its voice met the subject");let l=a,u=e.transport.ahead,c=u.get(n);c===void 0&&(c=new Map,u.set(n,c));let d=c.get(i),f={at:a,to:o.to,x:o.x,v:o.v};if(d===void 0)c.set(i,[f]);else{let p=d.length;for(;p>0&&d[p-1].at>l;)p--;d.splice(p,0,f)}}function Go(e,t){let n=e.cued,r=0,o=n.length-1;for(;r<=o;){let i=r+o>>1,s=n[i];if(s.id===t)return s;s.id<t?r=i+1:o=i-1}}function RF(e,t,n){let r=t.subjects.get(n);return r===void 0||!r.reaches?Number.NaN:WP(e,t,r.delay)}function WP(e,t,n){if(Number.isNaN(e.now)||t.state==="pending")return Number.NaN;let r=t.elapsedAt(e.now)-n;return r<0?Number.NaN:r}function EF(e,t){if(e.projecting)throw new Error("blits: a projection books nothing");let n={get voices(){return e.cued},get timestamp(){return e.last},get now(){return e.now},hostOf:o=>BP(e,o),readingAt:o=>uF(e,o-e.offset),endOf:o=>Xe(e,o,"end"),marks:(o,i)=>Yh(e,o,i),unhook:o=>{let i=(e.bookers??[]).filter(s=>s!==o);e.bookers=i.length===0?null:i}},r=new $h(n,t);return e.bookers=[...e.bookers??[],r],r}function Zh(e){return{get voices(){return e.cued},channels:e.channels,names:e.names,clock:e,fits:t=>q$(e,t),meet:(t,n,r,o)=>{for(let i=r;i!==null;i=i.next)if(i.voice===t)return i;return e.held(t,n,o)},forgot:t=>{e.places?.forgot(t);for(let n of e.general)Vr(n,t,!1),n.sighted!==null&&e.share?.unsight(n,t);for(let n of Bo(e).general)Vr(n,t,!1)},passes:(t,n)=>e.passes(t,n),naming:t=>e.naming===0?void 0:e.named.get(t),slotOf:t=>ut(e,t)?.slot??-1,envelope:(t,n)=>t.owner===null?e.envelope(t,e.now,n):e.envelope(t,e.now,n)*e.ownedBy(t,void 0),parting:(t,n)=>e.parting(t,n,e.now),ready:(t,n,r)=>{let o=e.lanes.arg;e.primeLaned(t,r,o),t.setting.weight=o[0],e.sending.voice=t,e.sending.subject=n},signal:(t,n,r,o)=>{let i=e.lanes.arg,s=t.blend===null?Number.NaN:e.laneRead(t,o);if(!Number.isNaN(s)){i[0]=s;return}e.primeLaned(t,r,i);let a=pe.kept,l=e.base(t,n,e.now,r,o);pe.kept!==a&&!t.keeping&&$i(e,t),i[0]=l},horizon:(t,n)=>{t.motion!==void 0&&(pe.horizon=e.horizonFor(t,n,e.now))},keeps:e.opts.history!==void 0,after:(t,n,r)=>em(e,t,n,r),kept:t=>$i(e,t)}}function Yi(e){return e.named!==null&&e.named.size===1&&e.spec.role===void 0&&(e.slots.length===1||e.motion===void 0)&&e.motion?.round!==!0}function q$(e,t){let n=t.spec,r=t.patch;if(t.keeping||(t.freezesBefore||t.state==="fading")&&t.unstarted(e.now)||t.beginless||t.out?.back===!0||t.owner!==null&&WO(t))return!1;let o=n.weight;if(typeof o=="function"&&o.input&&(e.opts.history?.inputs||!PF(o))||r.reads!==void 0&&r.reads.length>0||n.role!==void 0&&t.motion!==void 0||n.from==="current"||(t.motion!==void 0||n.role!==void 0||Yi(t))&&t.slots.some(s=>Jn(e.channels[s])?.op==="last")||t.out?.rest||r.state!==void 0||r.step!==void 0)return!1;let i=t.built;return i===null||i.tracks.every((s,a)=>s.lerp===void 0||s.lerp===t.lerps[a])}var NF={exact:0,stepped:1,held:2};function IF(e,t,n){let r=t.patch;if(r.state===void 0&&r.step===void 0&&!t.keeping)return"exact";if(!n)return"held";let o=t.spec.weight;return r.reads!==void 0&&r.reads.length>0||typeof o=="function"&&o.input?"held":t.keeping?"stepped":r.step===void 0||Io(e,t)!==void 0&&e.opts.maxDt===void 0?"exact":"stepped"}function $i(e,t){t.keeping||(t.keeping=!0,t.sharing&&e.share?.unshare(e,t,!0,e.sending.subject),e.lanes?.invalidate())}function dc(e,t){return e.handles??=X$(e),new Kr(t,e.handles)}function X$(e){return{nowFor:t=>{if(Number.isNaN(e.now))return t.start;let n=lc(e,t);return Number.isFinite(n)?n:t.start},changed:t=>{e.frame=st(),dn(e,t,e.now),t.holding!==null&&Vi(t,n=>dn(e,n,e.now)),Ke(e,t),e.lanes?.refill()},sought:(t,n,r)=>{r&&t.holding!==null&&!e.projecting&&(e.leapt??=new Set,e.leapt.add(t)),n&&t.rebuilds++;let o=IF(e,t,n);return t.holding!==null&&Vi(t,i=>{i.seeks++,n&&i.rebuilds++;let s=IF(e,i,n);NF[s]>NF[o]&&(o=s),it(e,i)}),o},fade:(t,n)=>{if(t.holding!==null&&n!==void 0&&("subject"in n||n.at==="rest"))throw new Error("blits: an owner fades as a whole, not by subject or at rest");n!==void 0&&"subject"in n?MF(e,t,n.subject,n.over):typeof n?.at=="number"?OF(e,t,n.at,n.over):qr(e,t,n??{})},rise:(t,n)=>CF(e,t,n??{}),release:t=>FF(e,t),weightOf:(t,n)=>{if(t.state==="done")return 0;if(t.holding!==null)return kP(t,e.now,e.reducedNow,i=>e.ownerBase(i,n));let r=e.lanes===null?-1:ut(e,n)?.slot??-1;if(t.laned&&e.lanes!==null){let i=e.lanes.weightOf(t.id,r);if(i!==void 0)return i}let o=t.sharing?void 0:t.subjects.get(n);return o!==void 0?o.weight:e.share===null?0:e.share.weightAt(t,r)},taping:()=>jr(e),record:(t,n,r)=>Ot(e,n,o=>{let i=o.mix(e);if(i===e)r(t);else if(i!==void 0){let s=Go(i,t.id);s!==void 0&&r(dc(i,s))}})}}function fc(e,t){return{by:e,stops:t,members:[],frame:0,subject:void 0,value:0,reads:new me,frames:new Float64Array(0),values:new Float64Array(0)}}function Ca(e){let t=new Map;for(let n of e){if(n.blend===null)continue;let r=t.get(n.blend.of);r===void 0&&(r=fc(n.blend.of.by,n.blend.of.stops),t.set(n.blend.of,r)),n.blend={of:r,i:n.blend.i},r.members.push(n)}}function LF(e,t,n,r){let{of:o,i}=e.blend,s=this.frame,a;if(r<0){if(o.frame===s&&o.subject===t)return uc(o.value,i,o.stops);if(a=o.reads.get(t),a?.frame===s)return uc(a.value,i,o.stops)}else if(r>=o.frames.length){let c=Math.max(r+1,o.frames.length*2,64),d=new Float64Array(c),f=new Float64Array(c);d.set(o.frames),f.set(o.values),o.frames=d,o.values=f}let l=pe.kept,u=o.by(t,e.setting);return pe.kept!==l&&!this.projecting&&this.shareKept(o,e,t,n),r<0?(o.frame=s,o.subject=t,o.value=u,a===void 0?o.reads.set(t,{frame:s,value:u}):(a.frame=s,a.value=u)):(o.frames[r]=s,o.values[r]=u),uc(u,i,o.stops)}function _F(e,t){let{of:n,i:r}=e.blend;return t<n.frames.length&&n.frames[t]===this.frame?uc(n.values[t],r,n.stops):Number.NaN}function DF(e,t,n,r){for(let o of e.members){let i=o===t?void 0:o.subjects.get(n);i?.reaches&&i.kept===null&&(i.kept=r.kept),$i(this,o)}}var BF=new WeakMap,HF=e=>typeof e=="function"?BF.get(e):void 0;function GF(e,t={}){if(typeof e!="object"||e===null)throw new TypeError("blits: around takes a circle, { x, y, r }");let n=Co(t.ease??"linear"),r=o=>{let i=this.places;if(i===null)return 0;let s=i.cur>=0?i.cur:i.at.get(o)??-1,a=i.xy;if(s<0||2*s+1>=a.length)return 0;let l=e.r,u=a[2*s]-e.x,c=a[2*s+1]-e.y,d=u*u+c*c;return!(l>0)||!(d<=l*l)?0:n(1-Math.sqrt(d)/l)};return BF.set(r,e),r}var J$=wa;function Q$(e,t){let n=new Uint8Array(t);return e.bands=n,n}function hc(e,t){return typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<1e-9:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,r)=>hc(n,t[r])):e===t}function pc(e,t,n){let r=e.merge(t,n);if(r!==n||!Array.isArray(r))return r;if(!Array.isArray(t)||t.length!==r.length)return[...r];for(let o=0;o<r.length;o++)t[o]=r[o];return t}function kt(e){e?.bands&&e.bands.fill(2)}function UF(e,t){let{on:n,off:r}=this.band;return t>=n?!0:t<=r?!1:e??t>=n}function WF(e,t,n,r,o){let i=t.slots;for(let s=0;s<i.length;s++){let a=i[s],l=this.names[a],u=r[l];if(u===void 0)continue;let c=this.scalars[a];if(c!==void 0&&typeof u=="number"){e[l]=Oe(c,e[l],u,o);continue}let d=this.channels[a];if(d.rest!==void 0&&d.scale){e[l]=d.fold?d.fold(e[l],u,o):pc(d,e[l],d.scale(u,o));continue}let f=n.bands??Q$(n,i.length),p=f[s],h=this.passes(p===0?void 0:p===1,o);f[s]=h?1:2,h&&(e[l]=e[l]===void 0?Hi(u):pc(d,e[l],u))}}function VF(e){for(let t of this.bounded){let n=this.names[t];e[n]=Z$(this.channels[t],e[n])}return e}function Z$(e,t){let[n,r]=e.bounds;if(typeof t=="number")return t<n?n:t>r?r:t;if(Array.isArray(t))for(let o=0;o<t.length;o++){let i=t[o];t[o]=i<n?n:i>r?r:i}return t}function zF(e,t,n,r){if(e.sharing){if(t<0)return r;let s=this.lanes;return this.share.weighAt(e,t,n.weight,s.cap),this.share.shut(e,n,t,s.cap),r}let o=this.sharers,i=0;for(;i<o.length&&o[i].id<e.id;)i++;return i}function KF(e,t,n=!1,r){let o=this.folded(e,t,n,r);return this.bounded.length===0?o:this.clamp(o)}function jF(e,t,n=!1,r){let o=this.linked(e);return this.foldWith(e,t??this.pose(),o,this.linkedLaned,n,r)}function $F(e){let t=Number.isNaN(this.now)?null:this.chain(e),n=this.lanes;return t!==null&&n!==null&&n.laned.length===0&&n.frameAt===this.now&&n.qualifiedVersion===this.version&&n.touched.length===0&&!n.filling?(t.slot>=0&&(n.per[t.slot*6+4]=++n.probes),this.linkedLaned=!1,t):(this.linkedLaned=t!==null&&n?.prepare(t.slot,e,this.version,t)===!0,t)}function YF(e,t,n,r,o,i){let s=t,a=this.lanes,l=r?a.copies:null;for(let c=0;c<this.names.length;c++){if(l?.[c])continue;let d=this.channels[c],f=d.rest,p=this.names[c];if(f===void 0){s[p]!==void 0&&(s[p]=void 0);continue}let h=this.lerpsInto[c]===void 0?void 0:s[p];if(Array.isArray(h)&&h!==f&&h.length===f.length)for(let m=0;m<h.length;m++)h[m]=f[m];else s[p]=d.copy?d.copy(f):J$(f)}if(n===null)return s;let u=-1;if(r){let c=a;if(c.copy(n.slot,s),c.owes(n.slot))u=n.slot;else if(c.whole)return s}if(this.detours===0){let c=this.now;for(let d=n;d!==null;d=d.next){let f=d.voice;if(f===null||r&&f.laned&&!this.owedBy(u,f)||f.id===i||f.state==="done")continue;let p=this.read(f,e,c,o,d);u>=0&&f.laned&&a.paid(f.id,u,d.weight),d.weight>0||kt(d),!(p===null||this.w<=0)&&this.apply(s,f,d,p,this.w)}return s}return this.foldDetour(e,s,n,r,o,i,u)}function qF(e,t,n,r,o,i,s){let a=n.version===this.version?n:this.chain(e);if(this.roleVoices!==0)return this.foldRoles(e,t,a,r,o,i,s);let l=this.now,u=this.lanes,c=this.sharers,d=0;for(let f=a;f!==null;f=f.next){let p=f.voice;if(p===null||(d<c.length&&c[d].id<p.id&&(d=this.foldSharers(t,e,a,d,p.id,r,o,i,s)),r&&p.laned&&!this.owedBy(s,p))||p.id===i||p.state==="done")continue;let h=this.read(p,e,l,o,f);s>=0&&p.laned&&u.paid(p.id,s,f.weight),f.weight>0||kt(f),!(h===null||this.w<=0)&&this.apply(t,p,f,h,this.w)}return d<c.length&&this.foldSharers(t,e,a,d,Number.MAX_SAFE_INTEGER,r,o,i,s),t}function XF(e,t,n,r,o,i,s,a,l){let u=this.sharers,c=this.now;for(;r<u.length;){let d=u[r];if(d.id>=o)break;r++;let f=d.state==="pending"?null:d.everyone;if(f===null||i&&d.laned&&!this.owedBy(l,d)||d.id===a||d.state==="done")continue;this.share.open(d,f,n.slot);let p=this.read(d,t,c,s,f);l>=0&&d.laned&&this.lanes.paid(d.id,l,f.weight),r=this.shared(d,n.slot,f,r),!(p===null||this.w<=0)&&this.apply(e,d,f,p,this.w)}return r}function JF(e,t){return e>=0&&this.lanes.owesVoice(e,t.id)}var tm=5,nm=new Map,QF=new WeakMap,ZF=0,e8=0;function t8(e){if(e===void 0)return 0;let t=QF.get(e);return t===void 0&&(t=++e8,QF.set(e,t)),t}var zP=e=>Object.is(e,-0)?"-0":String(e);function n8(e){let t=zP(e.duration);for(let r of e.tracks){if(r===void 0)return++ZF;t+=`|${zP(r.delay)}`;for(let o of r.all)t+=`,${zP(o.at)}:${t8(o.ease)}`}let n=nm.get(t);return n===void 0&&(nm.size>=4096&&nm.clear(),n=++ZF,nm.set(t,n)),n}var Oa=class{data=new Float64Array(64);used=0;eases=[];lastTiming=-1;lastPhase=Number.NaN;found=new Int32Array(4);easedAt=new Float64Array(4);add(t,n){let r=tm,o=0;for(let l=0;l<t.tracks.length;l++){let u=t.tracks[l],c=n[l];if(u===void 0||c===void 0||!c.plain||!c.straight)return-1;for(let d of u.all)if(!r8(d.value,c))return-1;r+=2+u.all.length*(1+c.axes),o+=u.all.length}let i=this.reserve(r),s=this.data;s[i]=r,s[i+1]=this.eases.length,s[i+2]=t.duration,s[i+3]=o,s[i+4]=n8(t);let a=i+tm;for(let l=0;l<t.tracks.length;l++){let u=t.tracks[l],c=n[l];s[a++]=u.all.length,s[a++]=u.delay;for(let d of u.all){if(s[a++]=d.at,c.scalar)s[a++]=d.value;else{let f=d.value;for(let p=0;p<c.axes;p++)s[a++]=f[p]??c.rest}this.eases.push(d.ease)}}return i}copy(t,n){let r=t.data[n],o=this.reserve(r);this.data.set(t.data.subarray(n,n+r),o);let i=t.data[n+1],s=t.data[n+3];this.data[o+1]=this.eases.length;for(let a=0;a<s;a++)this.eases.push(t.eases[i+a]);return o}fold(t,n,r,o,i){let s=this.data;(s[t+4]!==this.lastTiming||n!==this.lastPhase||n===0)&&this.search(t,n,r);let l=this.found,u=this.easedAt,c=t+tm,d=t+s[t];for(let f=0;c<d;f++){let p=r[f],h=p.axes,m=1+h,g=s[c],b=c+2;c=b+g*m;let x=l[f];if(x===-2)continue;let w=p.values,y=o*h;if(x===-1||x===g){let A=b+(x===-1?0:g-1)*m+1;for(let N=0;N<h;N++)w[y+N]=Oe(p.op,w[y+N],s[A+N],i);continue}let P=b+x*m,S=P-m,v=u[f];for(let A=0;A<h;A++){let N=Ct(s[S+1+A],s[P+1+A],v);w[y+A]=Oe(p.op,w[y+A],N,i)}}}search(t,n,r){let o=this.data;this.lastTiming=-1;let i=o[t+2],s=o[t+1],a=t+tm,l=t+o[t];for(let u=0;a<l;u++){u>=this.found.length&&this.grow(u+1);let c=1+r[u].axes,d=o[a],f=NP(o[a+1],n,i),p=a+2;a=p+d*c;let h=IP(o,p,c,d,f);if(this.found[u]=h,h>=0&&h<d){let m=p+h*c,g=EP(f,o[m-c],o[m]),b=this.eases[s+h];this.easedAt[u]=b?b(g):g}s+=d}this.lastTiming=o[t+4],this.lastPhase=n}grow(t){let n=new Int32Array(t*2);n.set(this.found),this.found=n;let r=new Float64Array(t*2);r.set(this.easedAt),this.easedAt=r}reserve(t){let n=this.used;if(n+t>this.data.length){let r=new Float64Array(Math.max(n+t,this.data.length*2));r.set(this.data.subarray(0,n)),this.data=r}return this.used=n+t,n}};function r8(e,t){if(t.scalar)return typeof e=="number";if(!(Array.isArray(e)||ArrayBuffer.isView(e)))return!1;let n=e;for(let r=0;r<t.axes;r++){let o=n[r];if(o!==void 0&&typeof o!="number")return!1}return!0}function eL(e,t,n){let r=t.voice,o=t.data,i=e.per,s=t.list,a=t.records,l=t.chans[0],u=e.fills,c=e.frameProbes,d=e.lately,f=r.seeks,p=r.elapsedAt(e.now),h=t.flat,m=r.parts!==null,g=typeof r.spec.weight=="function",b=e.probes!==c,x=Br(r.weight),w=e.arg,y=n.n,P=l.op;if(y>0&&(t.axes!==y&&(t.axes=y,t.samples=new Float64Array(0)),s.length*y>t.samples.length)){let D=new Float64Array(Math.max(s.length,t.samples.length/y*2,4)*y);D.set(t.samples),t.samples=D}let S=t.samples,v=n.xs,A=n.round?void 0:n.ease;n.watcher===null&&(n.watcher=e,n.watchId=r.id);let N=A!==void 0&&!g&&n.watcher===e&&n.watchId===r.id,M=y===l.axes&&l.plain,C=Number.NaN,F=Number.NaN,B=0;for(let D=0;D<s.length;D++){if(g&&r.keeping)return;let j=s[D],W=D*8,J=j*6;if(Ft(o,W,i,J,u),d>=0&&e.unread(j)){Fa(t,D);continue}let se=o[W+0],ke=p-se;if(!(ke>=0)){Fa(t,D),o[W+2]=0;continue}if(!h){let ee=o[W+1];(!t.weighed||!Kt(ee,t.weighedSince))&&(t.fade=e.host.envelope(r,ee),t.weighed=!0,t.weighedSince=ee)}let ae;if(g){if(w[1]=ke,w[3]=Zn(ke,r.duration,r.passes),w[5]=t.fade,!e.signalled(r,j,a[D])){o[W+2]=0;continue}ae=w[0]}else if(m)ae=jt(r.weight,t.fade,e.parting(r,j));else if(h)ae=x;else{let ee=t.fade,te=r.weight;(ee!==C||te!==F||ee===0||te===0)&&(C=ee,F=te,B=jt(te,ee,1)),ae=B}if(o[W+2]=ae,o[W+7]===0){if(Number.isNaN(a[D].probed)){Fa(t,D),e.late.push(j);continue}o[W+7]=1}let ve=o[W+4],G=-1,K=!1;if(ve>=0){G=5+ve*n.stride;let ee=n.runs[G+1];(ee&6)!==0&&(G=-1),K=(ee&1)!==0}if(G<0||b&&(i[J+3]>c||i[J+4]>c)){w[1]=ke,w[4]=se,w[0]=ae,mc(e,t,n,D,j,a[D]);continue}let $=n.runs;if(N&&M&&K===l.scalar){if(o[W+5]!==-2&&(o[W+5]=-2,t.deltas[D]=null),ae<=0)continue;let ee=Eo(A,Hr(ke,$[G],$[G+2])),te=l.values,he=j*y,be=G+3,Fe=be+2*y;for(let Se=0;Se<y;Se++)te[he+Se]=Oe(P,te[he+Se],Mo($[be+Se],$[Fe+Se],ee),ae);continue}if(A!==void 0){let ee=Eo(A,Hr(ke,$[G],$[G+2])),te=G+3,he=te+2*y;for(let be=0;be<y;be++)v[be]=Mo($[te+be],$[he+be],ee)}else n.sampleBare(ve,ke,v,n.vs);for(let ee=0;ee<y;ee++)S[D*y+ee]=v[ee];if(t.deltas[D]!==null&&(t.deltas[D]=null),o[W+5]=u,o[W+6]=f,!(ae<=0))if(M&&K===l.scalar){let ee=l.values,te=j*y;for(let he=0;he<y;he++)ee[te+he]=Oe(P,ee[te+he],v[he],ae)}else w[0]=ae,e.foldInto(l,j,n.value(ve,v))}N&&(t.bareFill=u,t.bareElapsed=p,t.bareSeeks=f)}function mc(e,t,n,r,o,i){let s=e.arg[1],a=e.arg[4],l=e.arg[0],u=t.voiceAt(r),c=t.data,d=r*8,f=t.chans[0];if(yc(e,t,r,o,i),!(l>0))return;let p=i.delta;if(p===null||i.probed!==e.now||i.seeks!==u.seeks||!e.probedThisFrame(o)){let h=c[d+4];if(h<0){let g=e.subjectAt(o);if(g===rr)return;h=n.slot(g),c[d+4]=h,t.numbered(r,h)}if(e.keeps?e.host.horizon(u,a):pe.horizon=Number.POSITIVE_INFINITY,!n.quiet(h,s)){e.late.push(o);return}n.sample(h,s,n.xs,n.vs);let m=n.n;if(t.keep(r,n.xs,m),t.deltas[r]=null,c[d+5]=e.fills,c[d+6]=u.seeks,l<=0)return;m===f.axes&&n.scalar(h)===f.scalar?e.foldRun(f,o,n.xs):e.foldInto(f,o,n.value(h,n.xs));return}t.deltas[r]=p,c[d+5]=e.fills,c[d+6]=u.seeks,l>0&&e.foldInto(f,o,p[f.name])}function o8(e,t){let n=e.motionAt(t);e.kept(t,n.xs);let r=e.data[t*8+4],o={[e.chans[0].name]:n.value(r,n.xs)};return e.deltas[t]=o,o}function yc(e,t,n,r,o){t.fix(n);let i=n*8;o.probed===e.now&&o.seeks===t.data[i+6]||!(e.per[r*6+3]>e.frameProbes)||t.data[i+5]!==e.per[r*6+5]||(o.delta=t.deltas[n]??o8(t,n),o.probed=e.now,o.seeks=t.data[i+6])}var nL=new Float64Array(0);function KP(e){return(e&2043)===1211}var rm=class{chans;axes;list=[];data=new Float64Array(0);hot=new Float64Array(0);stride;samples=new Float64Array(0);deltas=[];records=[];voices=[];motions=[];eases=[];laws=[];idle=!1;line=sm.other;cursor=0;dead=0;stale=!1;staleRows=[];xs;vs;delta={};keys=new Oa;scratch=[];bareFill=-1;bareNow=Number.NaN;constructor(t,n){this.chans=t,this.axes=n,this.stride=11+3*n,this.xs=new Float64Array(n),this.vs=new Float64Array(n)}voiceAt(t){return this.voices[t]}fix(t){im(this,t)}numbered(){}restale(t,n){this.hot[t*this.stride+0]=(n|4)&-2049,this.stale=!0,this.staleRows.push(t)}odd=null;keep(t,n,r){if(r===this.axes){for(let o=0;o<r;o++)this.samples[t*r+o]=n[o];this.odd?.delete(t);return}this.odd??=new Map,this.odd.set(t,n.slice(0,r))}kept(t,n){let r=this.odd?.get(t);if(r!==void 0){n.set(r);return}let o=this.axes;for(let i=0;i<o;i++)n[i]=this.samples[t*o+i]}motionAt(t){return this.motions[t]}get size(){return this.list.length}reserve(t){if(t*8<=this.data.length)return;let n=Math.max(t,this.data.length/8*2,16),r=new Float64Array(n*8);r.set(this.data),this.data=r;let o=new Float64Array(n*this.stride);o.set(this.hot),this.hot=o;let i=new Float64Array(n*this.axes);i.set(this.samples),this.samples=i}};function jP(e,t){if(!e.overlap){for(let n of e.crowds)!n.idle&&n.cursor<n.size&&tL(e,n,t);return}for(;;){let n,r=t,o=t;for(let i of e.crowds){if(i.idle||i.cursor>=i.size)continue;let s=i.hot[i.cursor*i.stride+7];s<r?(o=r,r=s,n=i):s<o&&(o=s)}if(n===void 0)return;tL(e,n,o)}}function tL(e,t,n){let r=t.list,o=t.hot,i=t.cursor;for(;i=iL(e,t,i,n),!(i>=r.length||o[i*t.stride+7]>=n);)i=i8(e,t,i,n);t.cursor=i}function i8(e,t,n,r){let o=t.data,i=t.hot,s=t.stride,a=e.per,l=e.arg,u=t.list,c=t.chans[0],d=t.axes,f=e.fills,p=e.frameProbes,h=e.probes!==p,m=e.now,g=t.xs,b=t.vs,x=t.samples,w=n;for(;w<u.length;w++){let y=w*s;if(i[y+7]>=r)break;let P=i[y+0];if(w>n&&KP(P))break;if(o[w*8+5]===-2&&im(t,w),(P&64)!==0&&(P=s8(t,w)),(P&1)===0||(P&16)===0)continue;let S=u[w],v=w*8,A=S*6;if(Ft(o,v,a,A,f),e.lately>=0&&e.unread(S))continue;let N=o[v+0],M=(P&2)!==0,C=t.voices[w],B=(M?om(i,y,m):C.elapsedAt(m))-N;if((P&256)!==0&&(B=B>=0?B>C.span?C.hidesPast?Number.NaN:C.freezesAfter?C.span:B:B:C.freezesBefore?0:Number.NaN),!(B>=0)){o[v+2]=0;continue}let D;if(M)D=i[y+4];else if(typeof C.spec.weight=="function"){let W=e.host.envelope(C,o[v+1]);if(l[1]=B,l[3]=Zn(B,C.duration,C.passes),l[5]=W,!e.signalled(C,S,t.records[w])){o[v+2]=0;continue}D=l[0]}else D=jt(C.weight,e.host.envelope(C,o[v+1]),e.parting(C,S));if(o[v+2]=D,(P&512)!==0){D>0&&t.keys.fold(i[y+9],Dr(B,i[y+11],i[y+10]),t.chans,S,D);continue}if(l[1]=B,l[4]=N,l[0]=D,(P&128)===0){e.row(t,w,C,S);continue}if(o[v+7]===0){if(Number.isNaN(t.records[w].probed)){e.late.push(S);continue}o[v+7]=1}let j=o[v+4];if(j<0||(P&8)===0||h&&(a[A+3]>p||a[A+4]>p)){let W=t.motions[w];mc(e,t,W,w,S,t.records[w]),j<0&&t.restale(w,i[y+0]);continue}$2(t.laws[w],t.eases[w],d,i[y+9],i[y+10],i,y+11,i,y+11+d,i,y+11+2*d,B,g,b);for(let W=0;W<d;W++)x[w*d+W]=g[W];t.deltas[w]!==null&&(t.deltas[w]=null),o[v+5]=f,o[v+6]=i[y+5],!(D<=0)&&((P&32)!==0?e.foldRun(c,S,g):e.foldInto(c,S,t.motions[w].value(j,g)))}return w}function rL(e,t,n,r){let o=this.arg,i=o[1],s=n.duration;if(o[2]=Dr(i,s,n.passes),n.built!==null){o[0]>0&&this.foldKeys(n,e.chans,r);return}let a=e.records[t];if(Number.isNaN(a.probed)){this.late.push(r);return}o[3]=Zn(i,s,n.passes),this.call(n,e.chans,a,r)}function s8(e,t){let n=e.voices[t],r=t*e.stride,o=e.hot[r+0]&-324;return(n.state==="live"||n.state==="frozen"||n.state==="fading")&&(o|=1),(n.freezesBefore||n.freezesAfter||n.motion===void 0&&(n.owner!==null||n.hidesPast))&&(o|=256),n.ramp===null&&n.owner===null&&!((n.fade.in??0)>0)&&n.out===null&&n.back===null&&n.parts===null&&!n.keeping&&typeof n.spec.weight!="function"&&(o|=2),e.hot[r+1]=n.anchorNow,e.hot[r+2]=n.anchorElapsed,e.hot[r+3]=n.rate,e.hot[r+4]=Br(n.weight),e.hot[r+5]=n.seeks,e.hot[r+0]=o,o}function oL(e){e.stale=!1;let t=e.hot,n=e.stride,r=e.staleRows;e.staleRows=[];for(let o=0;o<r.length;o++){let i=r[o];if(i>=e.list.length)continue;let s=t[i*n+0];if((s&4)===0||(s&128)===0)continue;let a=e.data[i*8+4];a>=0&&a8(e,i,a)}}function a8(e,t,n){im(e,t);let r=e.motions[t],o=t*e.stride,i=e.hot[o+0]&-45,s=e.chans[0];return r.n===e.axes&&r.stretchInto(n,e.hot,o+9)&&(i|=8,r.scalar(n)===s.scalar&&s.plain&&(i|=32)),e.hot[o+0]=i,i}function om(e,t,n){return e[t+2]+(n-e[t+1])*e[t+3]}function iL(e,t,n,r){let o=t.data,i=t.hot,s=t.stride,a=e.per,l=t.list,u=t.chans[0],c=t.axes,d=e.fills,f=e.frameProbes,p=e.probes!==f,h=e.lately,m=e.now,g=u.op,b=r!==Number.POSITIVE_INFINITY;for(;n<l.length;n++){let x=n*s,w=i[x+0];if(b&&i[x+7]>=r||!KP(w))break;let y=n*8,P=(w&2048)!==0;if(!P&&(o[y+4]<0||o[y+7]===0))break;let S=l[n],v=S*6;if(p&&(a[v+3]>f||a[v+4]>f)||h>=0&&!(a[v+3]>h||a[v+4]>h))break;let A=P&&m>=i[x+8],N=0;if(!A&&(N=om(i,x,m)-o[y+0],!(N>=0)))break;Ft(o,y,a,v,d);let M=i[x+4];if(o[y+2]=M,P||(o[y+5]!==-2&&(o[y+5]=-2,t.deltas[n]=null),i[x+0]=w|2048,i[x+8]=Number.POSITIVE_INFINITY),M<=0)continue;let C=u.values,F=S*c,B=x+11,D=B+2*c;if(A){for(let J=0;J<c;J++)C[F+J]=Oe(g,C[F+J],i[D+J],M);continue}let j=Hr(N,i[x+9],i[x+10]),W=Eo(t.eases[n],j);j>=1&&i[x+3]>0&&(i[x+8]=m);for(let J=0;J<c;J++)C[F+J]=Oe(g,C[F+J],Mo(i[B+J],i[D+J],W),M)}return n}function im(e,t){let n=t*8,r=e.data;if(r[n+5]!==-2)return;let o=e.hot,i=t*e.stride;o[i+0]=o[i+0]&-2049;let s=e.axes,a=om(o,i,e.bareNow)-r[n+0],l=Eo(e.eases[t],Hr(a,o[i+9],o[i+10])),u=i+11,c=u+2*s;for(let d=0;d<s;d++)e.samples[t*s+d]=Mo(o[u+d],o[c+d],l);r[n+5]=e.bareFill,r[n+6]=o[i+5]}function Fa(e,t){let n=t*8,r=e.data;if(r[n+5]!==-2)return;let o=e.motion,i=o.runs,s=o.n,a=o.base(r[n+4]),l=e.bareElapsed-r[n+0],u=Eo(o.ease,Hr(l,i[a],i[a+2])),c=a+3,d=c+2*s;for(let f=0;f<s;f++)e.samples[t*s+f]=Mo(i[c+f],i[d+f],u);r[n+5]=e.bareFill,r[n+6]=e.bareSeeks}function Ft(e,t,n,r,o){let i=e[t+2];(i!==e[t+3]||i===0)&&n[r+5]===o-1&&(e[t+3]=i)}var sm={keys:{stop:.15,start:.25},other:{stop:.6,start:.8}},gc=class{voice;list=[];at=new Int32Array(0);idle=!1;line;epoch=0;made=0;data=new Float64Array(0);records=[];deltas=[];samples=new Float64Array(0);axes=0;delta={};scratch=[];chans=[];values=[];nums=new Float64Array(0);kinds=new Uint8Array(0);placed=!1;placedAt=0;phase=0;pass=0;read=!1;readAt=0;weighed=!1;weighedSince=0;fade=1;flat=!1;ran=-1;elapsedNow=0;motion;byMotion=new Int32Array(0);bareFill=-1;bareElapsed=Number.NaN;bareSeeks=Number.NaN;group=null;mark=Number.NaN;every=!1;voiceAt(){return this.voice}fix(t){Fa(this,t)}numbered(t,n){if(n>=this.byMotion.length){let r=new Int32Array(Math.max(n+1,this.byMotion.length*2,64));r.set(this.byMotion),this.byMotion=r}this.byMotion[n]=t+1}positionOfMotion(t){return t<this.byMotion.length?this.byMotion[t]-1:-1}keep(t,n,r){if(this.axes!==r&&(this.axes=r,this.samples=new Float64Array(0)),(t+1)*r>this.samples.length){let o=new Float64Array(Math.max(t+1,this.samples.length/r*2,4)*r);o.set(this.samples),this.samples=o}for(let o=0;o<r;o++)this.samples[t*r+o]=n[o]}kept(t,n){let r=this.axes;for(let o=0;o<r;o++)n[o]=this.samples[t*r+o]}motionAt(){return this.motion}constructor(t){this.voice=t,this.motion=Ln(t.patch),this.line=t.built!==null?sm.keys:sm.other}positionOf(t){return t<this.at.length?this.at[t]-1:-1}reserve(t,n){if(t*8>this.data.length){let r=new Float64Array(t*8);r.set(this.data),this.data=r}if(n>this.at.length){let r=new Int32Array(n);r.set(this.at),this.at=r}}add(t,n){let r=this.list.length;if(this.list.push(t),t>=this.at.length){let i=new Int32Array(Math.max(t+1,this.at.length*2,64));i.set(this.at),this.at=i}if(this.at[t]=r+1,(r+1)*8>this.data.length){let i=new Float64Array(Math.max(r+1,this.data.length/8*2,4)*8);i.set(this.data),this.data=i}let o=r*8;this.data[o+0]=n.delay,this.data[o+1]=n.shown,this.data[o+2]=0,this.data[o+3]=0,this.data[o+4]=-1,this.data[o+5]=-1,this.data[o+7]=0,this.records[r]=n,this.deltas[r]=null}renumber(t,n){let r=this.positionOf(t);if(!(r<0)){if(n>=this.at.length){let o=new Int32Array(Math.max(n+1,this.at.length*2,64));o.set(this.at),this.at=o}this.list[r]=n,this.at[n]=r+1,this.at[t]=0}}remove(t){let n=this.positionOf(t);if(n<0)return;let r=this.list.length-1,o=this.data[n*8+4];if(o>=0&&(this.byMotion[o]=0),n!==r){let i=this.data[r*8+4];i>=0&&(this.byMotion[i]=n+1);let s=this.list[r];this.list[n]=s,this.at[s]=n+1,this.data.copyWithin(n*8,r*8,(r+1)*8),this.records[n]=this.records[r],this.deltas[n]=this.deltas[r]??null;let a=this.axes;a>0&&this.samples.copyWithin(n*a,r*a,(r+1)*a)}this.list.pop(),this.at[t]=0,this.records[r]=void 0,this.deltas[r]=null}};var um=8,am=4,$P=class{mix;voice;area;finder;hitAt=new Float64Array(0);marks=0;markedIn=Number.NaN;missed=new Int32Array(am);vets;frame=Number.NaN;x=0;y=0;r=0;r2=0;lit=[];spare=[];inAt=new Float64Array(0);litAt=new Float64Array(0);checks;frames=0;checkedAt=-1;constructor(t,n,r){this.mix=t,this.voice=n,this.area=r,this.finder=l8(r)?r:null,this.checks=!tc(),this.vets=this.checks&&this.finder!==null}},l8=e=>typeof e.find=="function";function sL(e,t){let n=t.within;if(n!==void 0){if(typeof n!="object"||n===null)throw new TypeError("blits: within takes a circle, { x, y, r }, or a finder, { find(out) }");if(e.places===null)throw new Error("blits: within needs indices: call mix.place or mix.plot first");if(typeof t.weight!="function")throw new Error("blits: within needs a signal weight; for a hard-edged disk use weight: mix.around(circle, { steps: 1, jump: 'start' })")}}function cm(e,t){let n=t.spec,r=HF(n.weight),o=n.within??(r!==void 0&&e.places!==null?r:void 0);o!==void 0&&(t.bound=new $P(e,t,o),o===r&&(t.bound.checks=!1))}function aL(e,t){if(e.frame!==t.frame&&(e.frame=t.frame,e.checks&&e.frames++,e.finder===null)){let n=e.area;if(e.x=n.x,e.y=n.y,e.r=n.r,e.r2=n.r*n.r,e.checks&&e.frames%um===0){let r=t.places;lL(e,r.found,r.ring(e.x,e.y,e.r))}}}function YP(e){let t=e.mix.places;aL(e,e.mix);let n=e.finder;if(n===null)return t.query(e.x,e.y,e.r,e.r2);t.found.length<t.n&&(t.found=new Int32Array(Math.max(t.n,t.found.length*2)));let r=t.found,o=n.find(r);if(!(Number.isInteger(o)&&o>=0&&o<=r.length))throw new RangeError(`blits: within's find returned ${o}, not a count of the indices it wrote, 0 to ${r.length}`);return t.count=o,e.vets&&u8(e,r,o,t.n),e.checks&&e.frames%um===0&&e.checkedAt!==e.frames&&(e.checkedAt=e.frames,lL(e,e.missed,c8(e,t,o))),o}function u8(e,t,n,r){for(let o=0;o<n;o++){let i=t[o];if(i>=0&&i<r)continue;e.vets=!1;let s=e.voice;er(s,`${s.spec.name??`voice ${s.id}`}'s within finder found index ${i}, which place never handed out: it is skipped`);return}}function lL(e,t,n){if(n===0)return;let r=e.mix.places,o=e.voice,i=o.spec.weight,s=e.mix.now,a={timestamp:s,dt:0,elapsed:o.elapsedAt(s),pass:o.setting.pass,weight:0,state:void 0,host:o.setting.host,keep:(f,p)=>p(),send:()=>{}},l=Math.max(1,Math.floor(n/am)),u=e.frames/um%l,c=t.slice(0,n),d=o.named;for(let f=u;f<n;f+=l){let p=r.subjectAt(c[f]);if(p===void 0||d!==null&&!d.has(p))continue;let h=i(p,a);if(h>0){e.checks=!1,er(o,e.finder===null?`${o.spec.name??`voice ${o.id}`}'s weight signal reads ${h} just outside its within circle (r ${e.r}), which cuts it off there: widen r to where the signal falls to 0`:`${o.spec.name??`voice ${o.id}`}'s weight signal reads ${h} for a subject its within finder did not find, which cuts it off there: find every subject the signal is above 0 for`);return}}}function c8(e,t,n){let r=uL(e,t,n),o=t.n,i=e.hitAt,s=o===0?0:e.frames/um*am%o,a=0;for(let l=0;l<o&&a<am;l++){let u=(s+l)%o;i[u]!==r&&t.subjectAt(u)!==void 0&&(e.missed[a++]=u)}return a}function uL(e,t,n){e.markedIn=e.mix.frame,e.hitAt.length<t.n&&(e.hitAt=new Float64Array(Math.max(t.n,e.hitAt.length*2)));let r=++e.marks,o=t.found,i=e.hitAt;for(let s=0;s<n;s++){let a=o[s];a>=0&&a<i.length&&(i[a]=r)}return r}function d8(e){if(e.markedIn===e.mix.frame)return e.marks;let t=YP(e);return e.markedIn===e.mix.frame?e.marks:uL(e,e.mix.places,t)}function cL(e,t,n){let r=e.places;if(r===null)return!1;if(t.finder!==null){let o=r.at.get(n);if(o===void 0)return!1;let i=d8(t);return t.hitAt[o]===i}if(e.projecting){let o=t.area;return r.inside(n,o.x,o.y,o.r*o.r)}return aL(t,e),r.inside(n,t.x,t.y,t.r2)}function lm(e,t,n){t>=e.litAt.length&&qP(e,t+1),e.litAt[t]!==n&&(e.litAt[t]=n,e.lit.push(t))}function qP(e,t){if(t<=e.inAt.length)return;let n=Math.max(t,e.inAt.length*2,64),r=new Float64Array(n);r.set(e.inAt),e.inAt=r;let o=new Float64Array(n);o.set(e.litAt),e.litAt=o}function dL(e,t,n){let r=n.mix.places,o=YP(n),i=e.fills;qP(n,e.cap);let s=n.lit;n.lit=n.spare,n.lit.length=0,n.spare=s;let a=t.voice,l=n.inAt,u=r.found,c=r.slots;for(let p=0;p<o;p++){let h=c[u[p]]??-1;if(h<0||l[h]===i)continue;l[h]=i;let m=t.positionOf(h);if(!(m<0)){lm(n,h,i),r.cur=u[p];try{e.one(t,m,h)}finally{r.cur=-1}if(a.keeping)return}}let d=t.data,f=e.per;for(let p=0;p<s.length;p++){let h=s[p];if(l[h]===i||l[h]===-i)continue;l[h]=-i;let m=t.positionOf(h);if(m<0)continue;let g=m*8;Ft(d,g,f,h*6,i),d[g+2]!==0&&(d[g+2]=0,kt(t.records[m])),d[g+3]!==0&&lm(n,h,i)}}function XP(e,t){let n=t.mix.places,r=YP(t),o=e.fills;qP(t,e.cap);let i=t.inAt,s=n.found,a=n.slots;for(let l=0;l<r;l++){let u=a[s[l]]??-1;u>=0&&(i[u]=o)}}var JP=(e,t,n)=>e.inAt[t]===n;function QP(e,t,n,r){let o=t.data,i=n*8;Ft(o,i,e.per,r*6,e.fills),o[i+2]!==0&&(o[i+2]=0,kt(t.records[n]))}function Uo(e){e.detours=e.roleVoices+e.sharers.length+(e.unshared?1:0)}function ZP(e,t,n){t.spec.role!==void 0&&(e.roleVoices+=n);let r=t.spec.earliest;(t.spec.anchor!==void 0||r!==void 0&&typeof r!="number")&&(e.anchored+=n)}function fL(e,t){t.holding!==null&&(e.owners??=[],e.owners.push(t)),yP(e,t),ZP(e,t,1),Uo(e)}function pL(e,t){t.named!==null&&fO(e,t),t.holding!==null&&e.owners!==null&&(e.owners=e.owners.filter(n=>n!==t)),ZP(e,t,-1),Uo(e)}function Wo(e){e.named=new me,e.naming=0,e.general=[],e.sharers=[],e.roleVoices=0,e.anchored=0;for(let t of e.cued)yP(e,t),ZP(e,t,1);Uo(e),e.steps.push(null,++e.version)}function yL(e,t){let n=eT(e,t),r=n.patch;if(tT(e,n),n.from==="current"&&r.form!=="keys")throw new Error("blits: from: 'current' needs a keys patch");if(n.subjects!==void 0&&n.target!==void 0)throw new Error("blits: a voice takes target or subjects, not both");let o=n.anchor,i=n.owner===void 0?null:g8(e,n.owner);o&&xF(e,n,o,i),n.hits!==void 0&&iF(n.hits,r.duration),n.marks!==void 0&&lF(n.marks,r.duration),sL(e,n);let s=o!==void 0&&(o.start!==void 0||o.in!==void 0),a=i===null?e.now:Te(i,e.now),l=s||i?.fitting?Number.POSITIVE_INFINITY:i!==null?n.start??(a>0?a:0):n.start!==void 0?Ki(e,n.start-e.offset):Number.isNaN(e.now)?0:e.asleep?Number.POSITIVE_INFINITY:e.now,u=new La(e.nextId++,n,r,n.fade??f8,a,l,e.slotOf,e.channels,e.opts.host,e.send,i);u.offset=e.offset,r===Wi&&e.fitting!==null&&(u.fitting=e.fitting),r===Wi&&e.arcing!==null&&(u.arc=e.arcing,u.hold=e.arcing.hold),i?.fitting&&xL(n,u),e.pace!==null&&i===null&&n.start!==void 0&&u.state==="pending"&&(u.pinned=n.start-e.offset),l===Number.POSITIVE_INFINITY&&!s&&!i?.fitting&&Number.isNaN(u.pinned)&&(u.waking=!0,e.waking=!0),cm(e,u),bL(e,u);let c=dc(e,u);return u.handle=c,jr(e)&&p8(e,c),c}var f8=Object.freeze({});function p8(e,t){Ot(e,"cue",n=>{let r=Kr.voiceOf(t)??y8(t),o=n.mix(e);o===e?hL(e,r):o!==void 0&&hL(o,m8(o,r))})}function h8(e,t){for(let n of e.writes){if(!(n in t))throw new Error(`blits: kit has no channel ${String(n)}, which this patch writes`);let r=e.kit?.[n],o=t[n],i=o.rest;if(o.fold&&!o.copy&&typeof i=="object"&&i!==null&&!hO(i))throw new Error(`blits: channel ${String(n)} folds into a copy of its rest, which the mix cannot copy; give the channel a copy`);if(r&&r!==o&&(r.kind===void 0||r.kind!==o.kind))throw new Error(`blits: channel ${String(n)} is ${o.kind??"a custom channel"} in this kit, but the patch was written for ${r.kind??"a custom channel"}`)}}function eT(e,t){let n=t;if(n.locus!==void 0){if(n.role!==void 0&&n.role!==n.locus)throw new Error(`blits: a voice plays one role, not both role ${n.role} and locus ${n.locus}; locus is role's old name`);er(e,"locus is renamed role; cue the voice with role");let{locus:s,...a}=n;n={...a,role:s}}let r=e.roleTags,o=n.tags;if(r===void 0||o===void 0)return n;let i=n.role;for(let s of o)if(!(!r.includes(s)||s===i)){if(i!==void 0)throw new Error(`blits: a voice plays one role, not both ${i} and ${s}`);i=s}return i===n.role?n:{...n,role:i}}function gL(e){let{roles:t,loci:n}=e;if(n===void 0)return t;if(t!==void 0&&(t.length!==n.length||t.some((r,o)=>r!==n[o])))throw new Error("blits: a mix takes roles or loci, not both; loci is roles' old name");return er(e,"the mix option loci is renamed roles; make the mix with roles"),n}function tT(e,t){let n=t.patch,r=t.loop;if(typeof r=="number"&&!(Number.isInteger(r)&&r>=1))throw new RangeError(`blits: loop takes true, false or a whole number of passes, not ${r}`);if(t.rate!==void 0&&GP(t.rate),t.seek!==void 0&&!Number.isFinite(t.seek))throw new RangeError(`blits: a voice's seek is a finite number of ms, not ${t.seek}`);if(t.stepMs!==void 0&&!(t.stepMs>=0&&t.stepMs<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a voice's stepMs is a finite number of ms, 0 or more, not ${t.stepMs}`);if(t.catchUp!==void 0&&t.catchUp!=="exact"&&t.catchUp!=="fresh")throw new RangeError(`blits: catchUp takes 'exact' or 'fresh', not ${String(t.catchUp)}`);typeof t.weight=="number"&&UP(t.weight),h8(n,e.kit);let o=Ln(n);if(o!==void 0){let i=n.writes[0],s=e.kit[i],a=s.rest;typeof a=="number"?o.cuedOn(String(i),!0):Array.isArray(a)||ArrayBuffer.isView(a)?o.cuedOn(String(i),!1,dP(s)):dP(s)&&o.cuedOn(String(i),!1,!0)}if(n.reads){let i=e.opts.host;for(let s of n.reads)if(typeof i!="object"||i===null||!(s in i))throw new Error(`blits: the patch reads host.${s}, which this mix's host lacks`)}if(e.transport.pager!==null&&(n.state!==void 0||n.step!==void 0)&&(n.pack===void 0||n.unpack===void 0))throw new Error("blits: this mix's history has a store, which keeps a stateful patch's state as data; give the patch pack and unpack");if(t.as!==void 0&&e.transport.pager!==null&&!e.opts.history?.revive)throw new Error("blits: a voice cued with as needs history.revive to rebuild it from")}function hL(e,t){let n=t.owner;!n?.fitting&&(n===null?e.now:Te(n,e.now))>=t.start&&(t.state="live"),bL(e,t)}var mL=new WeakMap;function m8(e,t){let n=t.copy(()=>{});if(t.owner!==null){let r=Go(e,t.owner.id);(r===void 0||r.holding===null)&&Ea("a cue under an owner that has left"),n.owner=r}if(n.holding!==null&&(n.holding=new _o),n.blend!==null){let r=mL.get(e);r===void 0&&(r=new Map,mL.set(e,r));let o=n.blend.of,i=r.get(o);i===void 0&&(i=fc(n.blend.of.by,n.blend.of.stops),r.set(o,i)),n.blend={of:i,i:n.blend.i},i.members.push(n)}return n}function y8(e){throw new Error(`blits: voice ${e.id} is paged out, and the seek that plays its cue again did not load it`)}function bL(e,t){let n=t.spec,r=t.owner,o=n.anchor,i=o!==void 0&&(o.start!==void 0||o.in!==void 0),s=t.motion;t.parked=!1,r!==null&&HO(r,t),Number.isNaN(e.now)||(t.cuedAt=e.now,t.cuedSeq=e.transport.seq,t.opened=e.now,t.state!=="pending"&&(t.begunSeq=e.transport.seq)),t.placing=i,!Number.isNaN(t.pinned)&&t.state==="pending"&&Ho(e,t,t.pinned),s!==void 0&&!e.projecting&&(e.playing.set(s,(e.playing.get(s)??0)+1),e.owner??=AF(new WeakRef(e)),s.owner=e.owner,s.ownerId=t.id);let a=e.cued,l=a.length;for(;l>0&&a[l-1].id>t.id;)l--;a.splice(l,0,t),IO(e,t),t.sharing=e.share?.shares(e,t)===!0,fL(e,t),Ur(e,t),e.stir(),n.from==="current"&&(e.wantsPose=!0),o&&(zr(e),!Number.isNaN(e.now)&&t.state==="pending"&&lc(e,t)>=t.start&&va(e,t,e.now)),r?.fitting&&Dn(e,r),e.opts.history&&(t.log=[],t.note(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),t.first??=t.log[0]),it(e,t)}function g8(e,t){let n=e.owners?.find(r=>r.handle===t);if(n===void 0)throw new Error("blits: owner is not a handle mix.owns returned on this mix");if(n.state==="done")throw new Error("blits: that owner has left the mix");return n}var dm=class{out=new Map;gone=new FinalizationRegistry(t=>{this.out.get(t)?.handle.deref()===void 0&&this.out.delete(t)});add(t,n,r){this.out.set(t,{doneAt:n,handle:new WeakRef(r)}),this.gone.register(r,t)}take(t){let n=this.out.get(t);return this.out.delete(t),n?.handle.deref()}missing(t,n){for(let[r,o]of this.out)if(o.doneAt>t&&!n(r))return r}};function b8(e){return e.spec.as!==void 0&&e.owner===null&&e.holding===null&&e.blend===null&&e.answers===null&&e.fitting===null}function wL(e,t,n){if(!b8(t))return!1;let r=e.keys,o=x8(t,r);nr(e,"voice",t.id,void 0,[{at:t.doneAt,seq:t.doneSeq}],()=>o,n);let i=t.handle;return Kr.page(i,{weight:t.weight,played:t.settled.played===!0}),e.outs.add(t.id,t.doneAt,i),e.parters.delete(t),!0}function x8(e,t){let n=s=>t.subject(s),r=[],o=[];for(let s of e.keyed??[]){let a=n(s),l=e.subjects.get(a);l?.reaches&&r.push([s,Gi(e,l)]);let u=e.motion?.pack(a);u!==void 0&&o.push([s,u])}let i=e.settled;return{as:e.spec.as,start:e.start,anchorNow:e.anchorNow,anchorElapsed:e.anchorElapsed,rate:e.rate,ramp:e.ramp,weight:e.weight,out:e.out,back:e.back,stalls:e.stalls,outAt:e.outAt,outOver:e.outOver,outSet:e.outSet,rebuilds:e.rebuilds,hold:e.hold,past:e.clocks?.length??0,earlier:e.earlier,later:e.later,clocks:e.clocks,cuedAt:e.cuedAt,cuedSeq:e.cuedSeq,begunSeq:e.begunSeq,doneAt:e.doneAt,doneSeq:e.doneSeq,opened:e.opened,pinned:e.pinned,offset:e.offset,latest:e.latest,soonest:e.soonest,keeping:e.keeping,first:e.first,log:e.log,played:i.played,playedAt:i.at,playedSeq:i.seq,records:r,runs:o,left:(e.left?.all()??[]).map(s=>[t.key(s.subject),s.at,s.seq,Gi(e,s.held),s.sync,s.ramp,s.parted]),parts:[...e.parts??[]].map(([s,a])=>[t.key(s),a.at,a.over,a.seq]),parted:[...e.parted??[]].map(([s,a])=>a.ramp===void 0?[t.key(s),a.at,a.seq]:[t.key(s),a.at,a.seq,a.ramp])}}function PL(e,t,n){let r=e.opts.history?.revive;if(r===void 0)throw new Error("blits: a paged voice needs history.revive");let o=eT(e,{...r(n.as),as:n.as});tT(e,o);let i=new La(t,o,o.patch,o.fade??{},Number.NEGATIVE_INFINITY,n.start,e.slotOf,e.channels,e.opts.host,e.send,null);i.clocks=n.clocks,i.take(n),i.cuedAt=n.cuedAt,i.cuedSeq=n.cuedSeq,i.begunSeq=n.begunSeq??Number.POSITIVE_INFINITY,i.doneAt=n.doneAt,i.doneSeq=n.doneSeq,i.opened=n.opened,i.pinned=n.pinned,i.offset=n.offset??0,i.latest=n.latest,i.soonest=n.soonest??0,i.keeping=n.keeping,i.first=n.first,i.log=n.log,i.state="done",n.played!==void 0&&i.play(n.played,n.playedAt,n.playedSeq),i.resolve();let s=e.keys,a=u=>s.subject(u);i.keyed=new Set;for(let[u,c]of n.records)i.subjects.set(a(u),Ui(i,c)),i.keyed.add(u);for(let[u,c]of n.runs)i.motion?.unpack(a(u),c);i.left=Fn.from(n.left.map(([u,c,d,f,p,h=null,m=null])=>({subject:a(u),at:c,seq:d,sync:p,held:Ui(i,f),ramp:h,parted:m}))),n.parts.length>0&&(i.parts=new Map(n.parts.map(([u,c,d,f])=>[a(u),{at:c,over:d,seq:f}]))),n.parted.length>0&&(i.parted=new Map(n.parted.map(([u,c,d,f])=>[a(u),{at:c,seq:d,ramp:f??void 0}])));let l=e.outs?.take(t);return l===void 0?i.handle=dc(e,i):(Kr.rehome(l,i),i.handle=l),i}var w8=0;function st(){return++w8}function AL(e){return e.stirred||e.anchored>0||e.pins!==null&&e.pins.size>0}function Yr(e,t){e.moving=!0;try{P8(e,t)}finally{e.moving=!1}}function P8(e,t){e.now=t,e.looked=!1,e.unshared&&(e.unshared=!1,Uo(e)),e.frame=st(),e.reducedNow=e.reduced;for(let i of e.announced)Number.isNaN(i.at)&&(i.at=e.u);if(e.waking&&A8(e,t),e.pins!==null&&e.pins.size>0&&bF(e),e.anchored>0&&zr(e),e.announced.length>0){let i=e.opts.history===void 0?t:e.transport.keepsFrom();e.announced=e.announced.filter(s=>Ki(e,s.at)>=i)}let n=e.projecting||e.walkAll?e.cued:pO(e,t),r=null;for(let i of n)i.state!=="done"&&bc(e,i,t,i.owner!==null&&i.owner.fitting!==null)&&(r??=[],r.push(i));let o=e.leapt===null&&r===null?null:T8(e,r,t);e.leapt=null,o===null?RL(e,r,t):S8(e,o,r,t),e.sharers.length>0&&!e.projecting&&e.share?.outgrow(e),e.stirred=!1,e.asleep=!1,e.retired.length>0&&M8(e),O8(e)}function RL(e,t,n){t!==null&&k8(e,t,n),e.owners!==null&&(EL(e,n),ML(e,n))}function T8(e,t,n){let r=null;if(e.leapt!==null)for(let o of e.leapt)r=TL(o,n,r);if(t!==null)for(let o of t)r=TL(o.owner,n,r);return r}function TL(e,t,n){for(let r=e;r!==null;r=r.owner)r.state==="done"||r.owner?.fitting||n?.includes(r)||r.rateAt(r.owner===null?t:Te(r.owner,t))>0||(n??=[],n.push(r));return n}function S8(e,t,n,r){let o=t.map(i=>{let{anchorNow:s,anchorElapsed:a,rate:l,ramp:u,start:c}=i,d=i.owner===null?r:Te(i.owner,r);return i.anchorElapsed=ze(i,d),i.anchorNow=d,i.rate=1,i.ramp=null,i.start=d-i.anchorElapsed,{anchorNow:s,anchorElapsed:a,rate:l,ramp:u,start:c,logged:i.log?.length??0}});try{if(e.anchored>0){zr(e);for(let i of t)Vi(i,s=>{s.state==="pending"&&s.spec.anchor!==void 0&&s.owner?.fitting===null&&bc(e,s,r)})}RL(e,n,r)}finally{t.forEach((i,s)=>{let{logged:a,...l}=o[s];Object.assign(i,l);let u=i.log;if(u!==null)for(let c=a;c<u.length;c++)Object.assign(u[c],l)})}e.frame=st();for(let i of t)i.state!=="done"&&it(e,i),Vi(i,s=>{s.state!=="done"&&(dn(e,s,r),it(e,s))});e.lanes?.refill()}function bc(e,t,n,r=!1){Number.isNaN(t.opened)&&(t.opened=n),(t.earlier!==null||t.later!==null)&&oT(e,t,n);let o=t.owner===null?n:Te(t.owner,n);if(r&&IL(t,o,n))return!0;if(t.state==="pending"&&NL(t,o,n)&&va(e,t,n),(t.state==="live"||t.state==="frozen")&&t.outAt<=n&&!(t.state==="live"&&!t.freezesAfter&&!t.freezesBefore&&t.endsAt()<t.outAt)&&qr(e,t,{over:Number.isNaN(t.outOver)?void 0:t.outOver},Math.max(Lo(t),t.outAt)),t.state!=="pending"){t.turns&&R8(e,t,n),t.state==="live"&&t.out!==null&&!t.quietAt(n)&&lT(e,t,n);let s=Math.sign(t.rateAt(o))*(t.owner===null?1:rT(t.owner,n)),a=o===Number.NEGATIVE_INFINITY?o:ze(t,o),l=s<0,u=!t.beginless&&a<=t.soonest,c=t.holding!==null&&Wr(t,n);(l?u&&!c:Number.isFinite(t.span)&&a>=t.span+t.latest)?(t.play(!0,n,e.transport.seq),t.state==="live"&&t.out===null&&((l?t.freezesBefore:t.freezesAfter)?t.state="frozen":qr(e,t,{back:l,stays:t.owner!==null&&e.opts.history!==void 0},Math.max(_n(t),Math.min(n,t.endsAt()))))):t.state==="frozen"&&!(u&&s===0)&&(t.state="live")}if(t.parts!==null&&!e.projecting)for(let[s,a]of t.parts)n-a.at>=a.over&&sT(e,t,s,a.at+a.over);let i=t.back;if(i!==null&&n>=i.at+(1-i.from)*i.over&&!e.projecting&&(t.back=null,e.lanes?.refill()),t.state==="fading"&&t.out){let{at:s,over:a,rest:l,deadline:u}=t.out,c=n-s;if(l){let d=u!==void 0&&c>=u,f=t.seen>0&&t.restedCount>=t.seen;d?Bn(e,t,s+u):f&&Bn(e,t)}else c>=a&&(t.out.stays?aT(e,t,s+a):Bn(e,t,s+a))}return e.projecting||it(e,t),!1}function NL(e,t,n){return t>e.start||t===e.start&&(e.owner===null||rT(e.owner,n)>=0)}function nT(e,t,n){return(t.earlier!==null||t.later!==null)&&oT(e,t,n),IL(t,Te(t.owner,n),n)}function IL(e,t,n){if(e.state==="pending")return NL(e,t,n);if(e.state!=="live")return!1;let r=e.out;if(e.fitting!==null)return r===null&&iT(e,n);if(!Number.isFinite(e.span)||r!==null&&!(r.stays===!0&&r.back===!0))return!1;let o=t===Number.NEGATIVE_INFINITY?t:ze(e,t),i=r===null?e.span+e.latest:e.soonest;return o>i||o===i&&rT(e,n)>0}function k8(e,t,n){let r=t.length===1?t[0]:null;if(r!==null&&r.state==="pending"&&r.holding===null&&(va(e,r,n),!nT(e,r,n))){bc(e,r,n);return}let o=t,i=[];for(;;){let s,a=Number.POSITIVE_INFINITY;for(let l=0;l<o.length;l++){let u=o[l];if(u.state==="done"||i.includes(u)||!nT(e,u,n))continue;let c=u.state==="pending"?_n(u):u.fitting!==null?v8(u):u.out!==null?u.reaches(u.soonest):u.endsAt();(s===void 0||c<a||c===a&&kL(u)<kL(s))&&(s=u,a=c)}if(s===void 0)break;if(s.state==="pending")va(e,s,n),s.holding!==null&&SL(e,s,n,o,i);else if(s.out!==null)lT(e,s,n);else{i.push(s),s.fitting!==null?xc(e,s,a):bc(e,s,n);for(let l=s.owner;l?.fitting;l=l.owner)SL(e,l,n,o,i)}}Bi(o);for(let s=0;s<o.length;s++){let a=o[s];!i.includes(a)&&a.state!=="done"&&bc(e,a,n)}}function v8(e){return e.timeAt(e.fitting.budget)}function SL(e,t,n,r,o){let i=t.holding.children;for(let s=0;s<i.length;s++){let a=i[s];a.state!=="done"&&!o.includes(a)&&!r.includes(a)&&nT(e,a,n)&&r.push(a)}}function kL(e){return(e.state==="pending"||e.out!==null?2**40:0)+e.id}function A8(e,t){e.waking=!1;for(let n of e.cued){if(!n.waking||(n.waking=!1,n.state!=="pending"))continue;Ia(e,n,t);let r=n.first;r!==null&&(r.start=t,r.anchorNow=t),e.projecting||it(e,n)}}function rT(e,t){let n=1;for(let r=e;r!==null;r=r.owner)n*=Math.sign(r.rateAt(r.owner===null?t:Te(r.owner,t)));return n}function R8(e,t,n){let r=t.ramp,o=t.anchorNow+r.over*r.from/(r.from-r.to);(t.owner===null?n:Te(t.owner,n))<o||(Fo(t,o),t.anchorElapsed=ze(t,o),t.ramp={from:0,to:r.to,over:t.anchorNow+r.over-o},t.anchorNow=o,Ke(e,t))}var N8=8,I8=32,E8=4;function M8(e){let t=e.retired;e.retired=[];let n=e.cued,r=null;if((t.length<=N8||t.length*I8<=n.length)&&!e.projecting){Bi(t),r=[];for(let i=0;i<t.length;i++){let s=t[i],a=s===t[i-1]?-1:C8(n,s);if(a<0){r=null;break}r.push(a)}}let o=!1;if(r!==null){for(let i of t)o=vL(e,i)||o;if(r.length<=E8)for(let i=r.length-1;i>=0;i--)n.splice(r[i],1);else{let i=r[0],s=0;for(let a=i;a<n.length;a++)r[s]===a?s++:n[i++]=n[a];n.length=i}}else{let i=0;for(let s=0;s<n.length;s++){let a=n[s];a.state!=="done"?n[i++]=a:o=vL(e,a)||o}n.length=i}o&&(e.general=e.general.filter(i=>i.state!=="done"),e.sharers.length>0&&(e.sharers=e.sharers.filter(i=>i.state!=="done")),Uo(e))}function C8(e,t){let n=0,r=e.length-1;for(;n<=r;){let o=n+r>>>1,i=e[o].id;if(i===t.id)return e[o]===t?o:-1;i<t.id?n=o+1:r=o-1}return-1}function vL(e,t){return EO(e,[t]),e.opts.history?(e.gone.push(t),_h(e,t)):(e.parters.delete(t),e.departed.add(e,t)),vF(e,t),Ur(e,t),pL(e,t),t.named===null}function O8(e){let t=e.opts.history;if(t&&e.gone.length>0)if(e.transport.pager!==null){let n=e.now-t.ms;_P(e,r=>r.reachedTo>=n||!wL(e,r,n))}else rF(e,e.transport.keepsFrom())}var fm=class{budget;claim;fit;spill;end;report;constructor(t){let n=t.duration??Number.POSITIVE_INFINITY;if(!(n>=0))throw new Error("blits: a span lasts 0 ms or more");let r=t.share??.5;if(!(r>=0&&r<=1))throw new Error("blits: a span staggers by a share in 0..1");this.budget=n,this.claim={budget:n,priority:t.priority??"strong",order:t.order??"queue",share:r},this.fit=t.fit??iO,this.spill=t.spill??"instant",this.end=Number.isFinite(n)?n:0,this.report={budget:n,length:0,over:0,skipped:0,fell:!1}}};function xL(e,t){if(e.start!==void 0||e.anchor?.start!==void 0||e.anchor?.in!==void 0)throw new Error("blits: a span places the voices it holds, so one takes no start of its own");if(t.arc!==null){if(!Number.isFinite(Tc(t)))throw new Error("blits: a span cannot fit an arc held open, which never ends")}else if(t.holding!==null){if(t.fitting===null)throw new Error("blits: a span holds voices, spans and arcs, not owners")}else if(!Number.isFinite(t.span))throw new Error("blits: a span cannot fit a voice that never ends")}function F8(e,t){for(let n of e.holding.children)if(n.out?.stays===!0&&(n.out.back===!0||n.start>t))return!0;return!1}function oT(e,t,n){let r=Te(t.owner,n),o=!1;for(let i=t.earlier;i!==null&&r<t.anchorNow;i=t.earlier)t.later={...uT(t),prev:t.later},CL(t,i),t.earlier=i.prev,o=!0;for(let i=t.later;i!==null&&r>=i.anchorNow;i=t.later)t.earlier={...uT(t),prev:t.earlier},CL(t,i),t.later=i.prev,o=!0;o&&(e.frame=st(),dn(e,t,n),Ke(e,t),e.lanes?.refill())}function uT(e){let{anchorNow:t,anchorElapsed:n,rate:r,ramp:o,skipped:i}=e;return{anchorNow:t,anchorElapsed:n,rate:r,ramp:o,skipped:i}}function CL(e,t){e.anchorNow=t.anchorNow,e.anchorElapsed=t.anchorElapsed,e.rate=t.rate,e.ramp=t.ramp,e.skipped!==t.skipped&&e.seeks++,e.skipped=t.skipped}function L8(e,t){if(Number.isNaN(t))return 0;let n=OL(e,t);return Number.isFinite(n)?Math.max(0,n):0}function OL(e,t){let n=e.owner===null?t:OL(e.owner,t);return n===Number.NEGATIVE_INFINITY||e.state==="pending"&&!(n>=e.start)?Number.NEGATIVE_INFINITY:ze(e,n)}function wc(e,t){return e.state!=="pending"||e.start<t}function _8(e,t,n){return wc(e,n)?Math.max(0,ze(e,t)):0}function FL(e,t,n){let r=e.fitting!==null?e.fitting.end:e.arc!==null?Tc(e):e.span;return Math.max(0,r-_8(e,t,n))}function Dn(e,t,n=e.now){let r=t.fitting;if(e.projecting||t.state==="done")return;let o=L8(t,n);if(F8(t,o))return;let i=n<e.now?o:Number.NEGATIVE_INFINITY,{kids:s,floors:a,waiting:l}=D8(e,t,o,i),u=s.map((P,S)=>{let v=P.spec;return{floor:a[S],natural:FL(P,o,i)/(v.rate??1),state:wc(P,i)?"playing":"pending",faster:Math.max(1,v.faster??1),slower:Math.max(1,v.slower??1),overlap:v.overlap===!0,ballast:v.ballast===!0&&P.holding===null,priority:v.priority??"weak"}}),c={...r.claim,left:r.budget-o},{plan:d,fell:f}=sO(c,u,r.fit,r.spill),{at:p,length:h}=mP(c,u,d);s.forEach((P,S)=>{let v=(P.spec.rate??1)*d.rate[S],A=d.skip[S]&&P.holding===null,N=P.skipped;P.skipped=A;let M=!1;if(wc(P,i))(A||P.rate!==v||P.ramp!==null)&&(P.earlier={...uT(P),skipped:N,prev:P.earlier},P.later=null),A&&(Fo(P,o),P.rebase(o),P.anchorElapsed=P.span,P.seeks++,M=!0),(P.rate!==v||P.ramp!==null)&&(Fo(P,o),ga(P,o,v,0),M=!0);else{let C=o+p[S],F=A?P.span:0;(P.start!==C||P.rate!==v||P.anchorElapsed!==F||P.ramp!==null)&&(P.start=C,P.anchorNow=C,P.anchorElapsed=F,P.rate=v,P.ramp=null,P.clocks=null,P.earlier=null,P.later=null,M=!0)}M&&(e.frame=st(),dn(e,P,e.now),Ke(e,P))});for(let P of l)P.start!==Number.POSITIVE_INFINITY&&(P.start=Number.POSITIVE_INFINITY,P.anchorNow=Number.POSITIVE_INFINITY,P.anchorElapsed=0,P.clocks=null,P.earlier=null,P.later=null,e.frame=st(),dn(e,P,e.now),Ke(e,P));s.length>0&&e.lanes?.refill();let m=o+h,g=Number.isFinite(r.budget)?Math.max(0,m-r.budget):0,b=g<1e-6,x=Number.isFinite(r.budget)&&b?r.budget:m,w=r.report,y={budget:r.budget,length:m,over:b?0:g,skipped:d.skip.filter((P,S)=>P&&s[S]?.holding===null).length,fell:f};r.report=y,x!==r.end?(r.end=x,Ke(e,t),t.owner?.fitting&&Dn(e,t.owner,n)):(y.length!==w.length||y.over!==w.over||y.skipped!==w.skipped||y.fell!==w.fell)&&Ke(e,t)}function D8(e,t,n,r){let o=(t.holding?.children??[]).filter(c=>c.state!=="done"&&c.state!=="frozen"&&c.out===null&&FL(c,n,r)>0),i=o.filter(c=>wc(c,r)),s=i.map(()=>{}),a=[],l=o.filter(c=>!wc(c,r)).sort((c,d)=>(c.spec.rank??0)-(d.spec.rank??0)),u=t.fitting.claim.order!=="together";for(let c of l){let d=c.spec.earliest,f=d===void 0?void 0:Na(e,d,c,Number.NEGATIVE_INFINITY);if(c.floorSeen=f??Number.NaN,d!==void 0&&f===void 0||u&&a.length>0){a.push(c);continue}i.push(c);let p=f===void 0||f===Number.NEGATIVE_INFINITY?void 0:f-n;s.push(p===void 0||c.cuedSeq===e.transport.seq?p:Math.max(0,p))}return{kids:i,floors:s,waiting:a}}function wF(e){if(!e.projecting)for(let t of e.owners??[]){if(t.fitting===null||t.state==="done")continue;(t.holding?.children??[]).some(r=>{let o=r.spec.earliest;if(r.state!=="pending"||o===void 0||typeof o=="number")return!1;let i=Na(e,o,r,Number.NEGATIVE_INFINITY)??Number.NaN;return!Object.is(i,r.floorSeen)})&&Dn(e,t)}}function Pc(e,t){let n=e.fitting;return n!==null&&Number.isFinite(n.budget)&&Te(e,t)<n.budget}function EL(e,t){let n=e.owners??[];for(let r=n.length-1;r>=0;r--){let o=n[r];o.out?.stays!==!0&&iT(o,t)&&xc(e,o,o.timeAt(o.fitting.budget))}}function iT(e,t){let n=e.fitting;return n===null||e.state==="done"||!Number.isFinite(n.budget)?!1:!Wr(e,t)&&Te(e,t)>=n.budget}var fn=Object.freeze([]),B8=()=>{},LL=new WeakMap;function H8(e,t,n){if(e.length!==1)return _L(e,t,n);let r=LL.get(t);r===void 0&&(r=new Map,LL.set(t,r));let o=e[0],i=r.get(o);return i===void 0&&(i=_L(e,t,n),r.set(o,i)),i}function _L(e,t,n){let r=e.map(o=>t.get(o));return{slots:r,lerps:r.map(o=>n[o].lerp)}}var La=class e{id;spec;patch;fade;start;owner;state="pending";rate;weight;anchorNow;anchorElapsed=0;ramp=null;out=null;back=null;stalls=null;subjects=new me;named;slots;built;lerps;intos;scratch=[];holder=null;laned=!1;seat=null;seeks=0;written=!1;touches=0;get jumps(){return this.seeks-this.touches}rebuilds=0;skipped=!1;floorSeen=Number.NaN;keeping=!1;parts=null;parted=null;left=null;ease;passes;duration;span;motion;beginless;freezesBefore;freezesAfter;opened=Number.NaN;unchecked=!0;dueToken=0;early=null;clocks=null;earlier=null;later=null;setting;seen=0;latest=0;soonest=0;restedCount=0;parked=!1;cuedAt=Number.NEGATIVE_INFINITY;cuedSeq=Number.NEGATIVE_INFINITY;begunSeq=Number.POSITIVE_INFINITY;doneAt=Number.POSITIVE_INFINITY;doneSeq=Number.POSITIVE_INFINITY;decidedAt=Number.NEGATIVE_INFINITY;get reachedTo(){return this.doneAt>this.decidedAt?this.doneAt:this.decidedAt}log=null;first=null;outAt=Number.POSITIVE_INFINITY;outOver=Number.NaN;outSet=!1;pinned=Number.NaN;offset=0;waking=!1;placing=!1;answers=null;folds=null;keepOn=null;ownKept=null;blend=null;spares=null;unreached=null;unreachedBits=null;sharing=!1;bound=null;shared=0;everyone=null;sighted=null;weights=null;stamps=null;deltas=null;handle=null;keyed=null;holding;fitting=null;arc=null;hold=0;part=-1;finished=!1;playedAs=void 0;playedAt=Number.NaN;playedSeq=Number.NaN;donePromise=null;doneSettle=null;playedPromise=null;playedSettle=null;quiet=!1;get done(){return this.donePromise===null&&(this.donePromise=this.finished?Promise.resolve():new Promise(t=>{this.doneSettle=t})),this.donePromise}get played(){if(this.playedPromise===null){let t=this.playedAs;this.playedPromise=t!==void 0?Promise.resolve(t):new Promise(n=>{this.playedSettle=n})}return this.playedPromise}resolve(){this.quiet||this.finished||(this.finished=!0,this.doneSettle?.())}play(t,n,r){this.quiet||this.playedAs!==void 0||(this.playedAs=t,this.playedAt=n,this.playedSeq=r,this.playedSettle?.(t),t&&this.owner!==null&&UO(this.owner,n,r))}get settled(){return{played:this.playedAs,at:this.playedAt,seq:this.playedSeq}}get passed(){return this.playedAs===!0}get unplayed(){return this.playedAs===!1}reopen(t){let n=!1;return this.playedAs!==void 0&&!(this.playedSeq<=t)&&(n=this.playedAs,this.playedAs=void 0,this.playedPromise=null,this.playedSettle=null),this.finished&&!(this.doneSeq<=t)&&(this.finished=!1,this.donePromise=null,this.doneSettle=null),n}take(t){this.anchorNow=t.anchorNow,this.anchorElapsed=t.anchorElapsed,this.rate=t.rate,this.ramp=t.ramp,this.weight=t.weight,this.out=t.out,this.back=t.back,this.stalls=t.stalls??null,this.start=t.start,this.outAt=t.outAt,this.outOver=t.outOver,this.outSet=t.outSet,this.rebuilds=t.rebuilds,this.hold=t.hold,this.earlier=t.earlier??null,this.later=t.later??null;let n=t.fitted;n&&this.fitting!==null&&(this.fitting.end=n.end,this.fitting.report=n.report);let r=this.clocks;r!==null&&r.length!==t.past&&(this.clocks=t.past===0?null:r.slice(0,t.past))}park(){this.reopen(Number.NEGATIVE_INFINITY),this.take(this.first),this.parked=!0,this.log=null,this.state="pending",this.subjects=new me,this.scratch=[],this.holder=null,this.laned=!1,this.seeks++,this.keeping=!1,this.parts=null,this.parted=null,this.opened=Number.NaN,this.dueToken++,this.early=null,this.seen=0,this.latest=this.named?.latest??0,this.soonest=this.named?.soonest??0,this.restedCount=0,this.cuedAt=Number.NEGATIVE_INFINITY,this.cuedSeq=Number.NEGATIVE_INFINITY,this.begunSeq=Number.POSITIVE_INFINITY,this.doneAt=Number.POSITIVE_INFINITY,this.doneSeq=Number.POSITIVE_INFINITY,this.placing=!1,this.answers=null,this.folds=null,this.keepOn=null,this.ownKept=null,this.unreached=null,this.unreachedBits=null,this.sharing=!1,this.everyone=null,this.sighted=null,this.weights=null,this.stamps=null,this.deltas=null,this.holding!==null&&(this.holding=new _o)}constructor(t,n,r,o,i,s,a,l,u,c,d){this.id=t,this.spec=n,this.patch=r,this.fade=o,this.start=s,this.owner=d,this.holding=r===Wi?new _o:null;let f=H8(r.writes,a,l);this.slots=f.slots,this.named=n.subjects?new Hh(n.subjects,n.stagger):null,this.latest=this.named?.latest??0,this.soonest=this.named?.soonest??0,this.built=r.form==="keys"&&r.keys?qO(r):null,this.lerps=f.lerps,this.intos=this.built?YO(this.built,this.slots.map(g=>l[g])):void 0,this.ease=o.ease===void 0?void 0:Co(o.ease),this.passes=H2(n.loop),this.duration=r.duration,this.span=this.duration>0&&Number.isFinite(this.passes)?this.duration*this.passes:Number.POSITIVE_INFINITY,this.motion=Ln(r);let p=this.motion===void 0?n.freeze:void 0,h=p===void 0&&this.motion===void 0&&d!==null;this.freezesBefore=h?d.freezesBefore:p==="before"||p==="both",this.freezesAfter=h?d.freezesAfter:p==="after"||p==="both",this.setting=new Kh(u,c,this),this.rate=n.rate??1,this.weight=typeof n.weight=="number"?n.weight:1;let m=!Number.isFinite(this.span);this.beginless=this.rate<0&&m&&this.motion===void 0,this.anchorNow=s,this.anchorElapsed=n.seek??(this.rate<0&&!m?this.span:0),i>=s&&(this.state="live")}elapsedAt(t){return this.owner===null?ze(this,t):BO(this,this.owner,t)}timeAt(t){let n=Cn(this,t);return this.owner===null?n:Do(this.owner,n)}get backs(){let t=this.ramp;return t===null?this.rate<0:t.from<=0&&t.to<=0&&(t.from<0||t.to<0)}get turns(){let t=this.ramp;return t!==null&&t.from*t.to<0}endsAt(){if(this.turns)return Number.POSITIVE_INFINITY;let t=this.backs,n;if(t!==(this.owner!==null&&Uh(this))){if(this.beginless)return Number.POSITIVE_INFINITY;n=this.soonest}else{if(!Number.isFinite(this.span))return Number.POSITIVE_INFINITY;n=this.span+this.latest}return this.reaches(n)}reaches(t){let n=this.backs?ec(this,t):Cn(this,t);return this.owner===null?n:Do(this.owner,n)}stateAt(t,n){let r=this.out;return r!==null?r.stays&&t>=r.at+r.over?"live":"fading":(this.owner===null?t:Te(this.owner,t))<this.start&&!(n!==void 0&&$t(n,this.begunSeq,!0))?"pending":this.freezesAfter&&this.elapsedAt(t)>=this.span+this.latest?"frozen":"live"}quietAt(t){let n=this.out;if(this.state!=="live"||n?.stays!==!0)return!1;if(this.holding!==null&&n.back!==!0)return!Wr(this,t)&&!Pc(this,t);if(this.skipped&&Te(this.owner,t)<this.start)return!0;let r=this.elapsedAt(t),o=this.span+this.latest,i=this.backs!==(this.owner!==null&&Uh(this));return r>o||r===o&&!i?!0:!this.beginless&&(r<this.soonest||r===this.soonest&&i)}ranBackTo(t,n){if(this.beginless||!this.backs||this.owner!==null)return Number.NaN;let r=ec(this,t);return r>=this.anchorNow&&r<=n?r:Number.NaN}unstarted(t){let n=this.state;return n==="pending"?!0:n!=="fading"?!1:!((this.owner===null?t:Te(this.owner,t))>=this.start)}rawAt(t,n){return(this.unstarted(t)?this.anchorElapsed:this.elapsedAt(t))-n}before(t,n){return!(t>=0)&&!this.beginless||this.unstarted(n)}get holdsFirst(){return this.freezesBefore||this.out?.back===!0}get hidesPast(){return!this.freezesAfter&&this.backs!==(this.owner!==null&&Uh(this))}shownAt(t){return this.beginless?t:t>this.span&&this.hidesPast?Number.NaN:kh(t,this.holdsFirst,this.freezesAfter,this.span)}note(t,n,r=!1){this.log?.push({at:t,seq:n,sync:r,anchorNow:this.anchorNow,anchorElapsed:this.anchorElapsed,rate:this.rate,ramp:this.ramp,weight:this.weight,out:this.out,back:this.back,stalls:this.stalls,start:this.start,outAt:this.outAt,outOver:this.outOver,outSet:this.outSet,rebuilds:this.rebuilds,hold:this.hold,past:this.clocks?.length??0,earlier:this.earlier,later:this.later,fitted:this.fitting===null?null:{end:this.fitting.end,report:this.fitting.report}})}copy(t,n,r=!1){let o={__proto__:e.prototype,...this},i=o;i.subjects=new Mh(t),i.setting={...this.setting,keep:CP(o),send:B8},o.keepOn=null,o.ownKept=null,o.scratch=[],o.holder=null,o.laned=!1,o.seat=null,o.log=null,o.early=null,n&&o.take(n),o.clocks===this.clocks&&o.clocks!==null&&(o.clocks=o.clocks.slice()),o.quiet=!0,o.unreached=null,o.unreachedBits=null;let s=r&&this.sharing?this.everyone:null;return o.sharing=s!==null,o.everyone=s===null?null:{...s,delta:null,probed:Number.NaN,from:s.stepped},o.sighted=null,o.weights=null,o.stamps=null,o.deltas=null,o}rateAt(t){return ya(this,t)}rebase(t){uP(this,t)}};function DL(e,t){if(e.unchecked=!1,t===null||typeof t!="object")return;let n=e.patch.writes;for(let r in t)n.includes(r)||er(e.patch,`${e.spec.name??`voice ${e.id}`}'s patch returns ${r} from at(), which is not in its writes, so the mix drops it`)}function _a(e,t,n){return e[cT(e,t,n)]}function cT(e,t,n){let r=0,o=e.length-1,i=-1;for(;r<=o;){let s=r+o>>1,a=e[s];a.at<t||a.at===t&&(typeof n=="function"?n(a):n)?(i=s,r=s+1):o=s-1}return i}function Sc(e,t){let n=0,r=e.length-1,o;for(;n<=r;){let i=n+r>>1,s=e[i];$t(t,s.seq,s.sync)?(o=s,n=i+1):r=i-1}return o}function BL(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let o of n)if(!BL(e[o],t[o]))return!1;return!0}function dT(e,t,n){let r=t.log,o=r===null?void 0:_a(r,n,!0);return ze(o??t,t.owner===null?n:G8(e,t.owner,n))}function G8(e,t,n){return dT(e,t,n)}function Ke(e,t){Ta(e,t,!0),e.stir(),it(e,t);let n=t.log;if(n===null)return;t.note(Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,e.transport.seq,e.moving||!e.looked);let r=e.now-e.opts.history.ms,o=0;for(;o+1<n.length&&n[o+1].at<=r;)o++;o>0&&nr(e,"controls",t.id,void 0,n.splice(0,o),U8,r)}var U8=e=>({...e}),W8=Object.freeze([]);function HL(e,t){let n=GL(e,t);return n===0?W8:e.splice(0,n)}function GL(e,t){let n=0;for(;n+1<e.length&&e[n+1].at<=t;)n++;return n}function Da(e,t){let n=e.patch;return n.clone?n.clone(t):bt(t)}function Vo(e,t,n=!1){let r=UL(t);return Ba({reaches:t.reaches,delay:t.delay,since:t.since,shown:t.shown,weight:t.weight,restedAt:t.restedAt,bands:t.bands===null?null:t.bands.slice(),state:t.state===void 0||n?t.state:Da(e,t.state),stepped:t.stepped,ticks:t.ticks,probed:t.probed,delta:t.delta,phase:t.phase,seeks:t.seeks,rebuilt:t.rebuilt,copied:t.copied,base:t.base===void 0?void 0:bt(t.base),slope:t.slope===void 0?void 0:bt(t.slope),kept:r,unkept:t.unkept?.map(bt),snaps:t.snaps,from:t.from,unknown:t.unknown,inputs:t.inputs,replay:t.replay,voice:t.voice,next:t.next,version:t.version,roles:t.roles,slot:t.slot,run:t.run,freed:t.freed,restored:null})}function UL(e){if(e.kept===null)return null;let t=new Map;for(let[n,r]of e.kept)t.set(n,bt(r));return t}function fT(e,t,n,r=!1){return n.reaches=t.reaches,n.delay=t.delay,n.since=t.since,n.shown=t.shown,n.weight=t.weight,n.restedAt=t.restedAt,n.bands=t.bands===null?null:t.bands.slice(),n.state=t.state===void 0||r?t.state:Da(e,t.state),n.stepped=t.stepped,n.ticks=t.ticks,n.rebuilt=t.rebuilt,n.copied=t.copied,n.base=t.base===void 0?void 0:bt(t.base),n.slope=t.slope===void 0?void 0:bt(t.slope),n.kept=UL(t),n.unkept=t.unkept?.map(bt),n.from=t.from,n.unknown=t.unknown,n.replay=t.replay,n.voice=t.voice,n.slot=t.slot,n.run=t.run,n.freed=t.freed,n.restored=null,Ba(n)}function Ba(e){return e.probed=Number.NaN,e.delta=null,e.phase=0,e.seeks=0,e.snaps=void 0,e.inputs=void 0,e.next=null,e.version=Number.NaN,e.roles=null,e}function WL(e,t){let n=e.hostLog,r=n[n.length-1],o=e.transport.seq;if(r!==void 0&&r.seq===o)return;let i=e.opts.host,s={};for(let l of e.cued)for(let u of l.patch.reads??fn)u in s||(s[u]=bt(i[u]));if(r!==void 0&&BL(r.fields,s))return;n.push({at:t,seq:o,fields:s});let a=t-e.opts.history.ms;nr(e,"host",void 0,void 0,HL(n,a),l=>l.fields,a)}function pm(e,t,n,r,o){let i=e.opts.history;if(!i?.inputs||e.projecting)return;let s=r.inputs??[];r.inputs=s;let a=s[s.length-1];if(a!==void 0&&(a.value===o||a.at===e.now)){a.at===e.now&&(a.value=o);return}s.push({at:e.now,seq:e.transport.seq,value:o});let l=e.now-i.ms,u=HL(s,l);u.length>0&&nr(e,"input",t.id,e.keys?.key(n),u,c=>c.value,l)}function kc(e){return e.every??200}function V8(e,t,n,r){let o=t.spares?.pop()??r;return o===void 0?{at:e.now,seq:e.transport.seq,held:Vo(t,n)}:(o.at=e.now,o.seq=e.transport.seq,fT(t,n,o.held),o)}function em(e,t,n,r){let o=e.opts.history;if(!o||e.projecting||t.patch.step===void 0&&(r.kept===null||r.kept.size===0)&&r.base===void 0)return;let i=r.snaps??[];r.snaps=i;let s=i[i.length-1];if(s!==void 0&&e.now-s.at<kc(o))return;let a=e.now-o.ms,l=GL(i,a),u;l>0&&(e.transport.pager!==null&&nr(e,"snap",t.id,e.keys?.key(n),i.slice(0,l),c=>Gi(t,c.held),a),u=z8(i,l),l===1?i.shift():i.splice(0,l)),i.push(V8(e,t,r,u))}function z8(e,t){for(let n=0;n<t;n++){let r=e[n];if(!r.shared)return r.ahead=void 0,r}}function hm(e,t,n,r){let o=e.opts.history;if(o===void 0||r===void 0)return;let i=e.now-o.ms,s=t.left??new Fn;t.left=s;let a=e.keys;s.expire(i,a===null?null:l=>nr(e,"left",t.id,a.key(l.subject),[l],u=>[Gi(t,u.held),u.sync,u.ramp,u.parted],i)),s.push({subject:n,at:Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,seq:e.transport.seq,sync:e.syncing||!e.looked,held:r,ramp:t.parts?.get(n)??null,parted:t.parted?.get(n)??null})}function mm(e){let t=e.opts.history;return t===void 0||Number.isNaN(e.now)?[]:[e.now,e.now-t.ms,e.transport.seq,e.syncing||!e.looked]}function MF(e,t,n,r){if(t.state==="done"||t.parted?.has(n)||t.parts?.has(n))return;e.share?.unshare(e,t),e.stir();let o=e.reduced?0:r??t.fade.out??0,i=Number.isNaN(e.now)?_n(t):e.now;if(o===0){sT(e,t,n,i);return}t.parts??=new Map,t.parts.set(n,{at:i,over:o,seq:e.transport.seq}),e.parters.add(t),it(e,t),e.lanes?.refill()}function VL(e,t,n){let r=e.parts?.get(t);if(r===void 0)return 1;let o=this.reducedNow,i=ma(0,{at:r.at,over:r.over,rest:!1},e.ease,o,n,0),s=e.fade.in??0,a=e.subjects.get(t)?.shown;if(!(s>0)||o||a===void 0||!(r.at<n))return i;let l=e.out,u=Sh(s,l,e.ease,n,a,e.stalls);return u>0?i*(Sh(s,l,e.ease,n,a,e.stalls,r.at)/u):i}function sT(e,t,n,r){let o=t.parts?.get(n);t.parts?.delete(n),t.parts?.size===0&&(t.parts=null),t.parted??=new Map,t.parted.set(n,{at:r,seq:e.transport.seq,ramp:o}),e.parters.add(t),zL(e,t,n);let i=t.motion;i!==void 0&&KL(e,i,t)&&i.release(n,...mm(e))}function VP(e,t,n){if(t.parted?.has(n)!==!0)return;t.subjects.get(n)===void 0&&pT(e,t,n),zL(e,t,n),t.parted.delete(n),t.parted.size===0&&(t.parted=null);let r=ut(e,n)?.slot??-1;r>=0&&e.lanes?.rejoin(r)}function pT(e,t,n){let r=t.subjects.get(n);r!==void 0||t.parted?.has(n)!==!0?hm(e,t,n,r):hm(e,t,n,t.unreached??e.unreachedOf(t,e.now))}function ym(e,t,n){for(let r of t){let o=r.parted;if(o!==null&&o.seq<=n){e.parted??=new Map,e.parted.set(r.subject,o);continue}let i=r.ramp??o?.ramp;i==null||i.seq>n||(e.parts??=new Map,e.parts.set(r.subject,i))}}function zL(e,t,n){let r=ut(e,n);r!==void 0&&r.slot>=0&&(Vr(t,r.slot,!1),e.share?.unsight(t,r.slot));let o=t.subjects.get(n);o!==void 0&&(hm(e,t,n,o),t.subjects.delete(n),o.reaches&&t.seen--,Oo(o)&&t.restedCount--,t.holder===o&&(t.holder=null)),r!==void 0&&(rc(e,r),t.laned&&r.slot>=0&&e.lanes?.part(t.id,r.slot),e.lanes?.refill())}function qr(e,t,n,r){if(t.state==="done"||t.state==="fading")return;let o=e.reduced?0:n.over??t.fade.out??0,i=t.state==="pending";i&&Ur(e,t),n.at==="rest"&&(e.share?.unshare(e,t),t.seeks++),t.state="fading",t.out={from:1,at:r??(Number.isNaN(e.now)?_n(t):e.now),over:o,rest:n.at==="rest",deadline:n.deadline},n.back&&(t.out.back=!0),n.stays&&(t.out.stays=!0),Ke(e,t),n.at==="rest"||n.back||i?e.lanes?.invalidate():e.lanes?.refill(),o===0&&n.at!=="rest"&&(n.stays?aT(e,t,t.out.at):Bn(e,t,t.out.at))}function aT(e,t,n){t.state="live",e.lanes?.refill();let r=t.owner;if(r.state==="done")return;let o=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now;Wr(r,o)||Pc(r,n)?r.fitting!==null&&!t.skipped&&Dn(e,r,n):xc(e,r,n)}function xc(e,t,n){t.owner!==null&&t.state==="live"&&e.opts.history!==void 0?qr(e,t,{over:0,stays:!0},n):Bn(e,t,n)}function CF(e,t,n){let r=t.out;if(t.state!=="fading"&&t.outSet){t.outAt=Number.POSITIVE_INFINITY,t.outOver=Number.NaN,t.outSet=!1,Ke(e,t);return}if(t.state!=="fading"||r===null)return;let o=Number.isNaN(e.now)?_n(t):e.now,i=e.reduced?0:n.over??t.fade.in??t.fade.out??0,s=r.rest||r.over===0?1:1-(o-r.at)/r.over,a=s<0?0:s>1?1:s,l=Number.isNaN(e.now)||(t.owner===null?o:Te(t.owner,o))<t.start;t.out=null,t.outAt=Number.POSITIVE_INFINITY,t.state=l?"pending":"live",l&&(t.begunSeq=Number.POSITIVE_INFINITY),t.back=i>0&&a<1?{from:a,at:o,over:i}:null,!r.rest&&r.at<o&&(t.stalls=[...t.stalls??[],r.at,o]),l&&Ur(e,t),Ke(e,t),l?e.lanes?.invalidate():e.lanes?.refill()}function OF(e,t,n,r){if(t.state==="done"||t.state==="fading")return;let o=Number.isNaN(e.now)?_n(t):e.now;if(n<=o){qr(e,t,{over:r},Math.max(Lo(t),n)),e.stir();return}t.outAt=n,t.outOver=r??Number.NaN,t.outSet=!0,Ke(e,t)}function lT(e,t,n){let r=t.out,o=r.back===!0?t.soonest:t.span+t.latest,i=t.reaches(o),s=Math.max(r.at+r.over,i<=n?i:n),a=e.reduced?0:r.over;t.out=null,t.back=a>0?{from:0,at:s,over:a}:null,Ke(e,t),e.lanes?.refill()}function KL(e,t,n){return t.owner===e.owner&&t.ownerId===n.id}function K8(e,t){t.owner.holding.left(t.passed?Xe(e,t,"coast"):void 0,t.doneSeq)}function Bn(e,t,n){t.holding===null&&e.lanes?.touch(t);let r=t.motion;r!==void 0&&KL(e,r,t)&&(r.owner=null),t.state="done",Ta(e,t),t.keepOn=null,e.retired.push(t);let o=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now;if(t.doneAt=n??o,t.decidedAt=o,t.doneSeq=e.transport.seq,e.transport.settle(),t.play(!1,t.doneAt,t.doneSeq),t.resolve(),t.holding!==null)for(let i of[...t.holding.children])i.state!=="done"&&Bn(e,i,t.doneAt);if(t.owner!==null){let i=t.owner;K8(e,t);let s=GO(t,o);s!==null&&!Pc(s,t.doneAt)?Bn(e,s,t.doneAt):i.fitting!==null&&i.state!=="done"&&!t.skipped&&Dn(e,i,t.doneAt)}}var j8=["enter","active","exit"],mT=class{enter;exit;blend;has;hold;constructor(t,n,r,o,i){this.enter=t,this.exit=n,this.blend=r,this.has=o,this.hold=i}};function $L(e,t){let n=[0,e.enter,e.enter+t,e.enter+t+e.exit],r=n[3],o=[null,null,null];for(let i=0;i<3;i++){if(!e.has[i])continue;let s=i+1;for(;s<3&&!e.has[s];)s++;o[i]=[n[i],s<3?n[s]:r]}return o}function Tc(e){let t=e.arc;return t.enter+e.hold+t.exit}function jL(e,t,n,r,o){if(t<=e)return 0;let i=r/2,s=e===0,a=t===n;if(!s&&o<e-i||!a&&o>=t+i)return 0;let l=s?1:r>0?Math.min(1,(o-e+i)/r):1,u=a?1:r>0?Math.min(1,(t+i-o)/r):1;return Math.min(l,u)}function KO(e,t,n,r){let o=e.arc,i=Te(e,n);if(!(i>=0))return 0;let s=$L(o,e.hold),a=o.enter+e.hold+o.exit,l=r?0:o.blend,u=s[t.part];if(u==null)return 0;let c=jL(u[0],u[1],a,l,i);if(c<=0)return 0;let d=0;for(let f of s)f!==null&&(d+=jL(f[0],f[1],a,l,i));return d>1?c/d:c}function $8(e){let t=0;for(let n of e){let r=n.loop,o=r===void 0||r===!1?1:r===!0?1/0:r,i=n.duration??(n.patch.duration>0?n.patch.duration*o:0);if(!(i>=0))throw new RangeError(`blits: an arc's part lasts 0 ms or more, not ${i}`);i>t&&(t=i)}return t}var hT=e=>e===void 0?void 0:Array.isArray(e)?e:[e];function YL(e,t){if((t.rate??1)<0)throw new Error("blits: an arc plays its parts forward from its start, so it is not cued backward");if(t.freeze!==void 0)throw new Error("blits: an arc holds each part\u2019s first and last frames itself, so it takes no freeze");let{enter:n,active:r,exit:o,hold:i,blend:s,...a}=t,l=[hT(n),hT(r),hT(o)],u=l.map(m=>m===void 0?0:$8(m));for(let m of[0,2])if(!Number.isFinite(u[m]))throw new Error(`blits: an arc's ${j8[m]} has to end, so it cannot loop for good`);let c=i==="open"?Number.POSITIVE_INFINITY:i??u[1]??0;if(!(c>=0))throw new RangeError(`blits: an arc holds for 0 ms or more, not ${i}`);let d=s??0;if(!(d>=0&&Number.isFinite(d)))throw new RangeError(`blits: an arc blends over 0 ms or more, not ${s}`);let f=new mT(u[0],u[2],d,l.map(m=>m!==void 0),c);e.arcing=f;let p;try{p=e.owns(a)}finally{e.arcing=null}let h=[0,f.enter,f.enter+c];return l.forEach((m,g)=>{for(let b of m??[]){let{duration:x,...w}=b,y={...w,owner:p,start:h[g],freeze:"both"};g===1&&i!==void 0&&b.loop===void 0&&(y.loop=!0),e.cue(y),e.cued[e.cued.length-1].part=g}}),p}function FF(e,t){let n=t.arc;if(n===null)throw new Error("blits: release ends an arc\u2019s hold, and this is no arc");if(t.state==="done"||t.state==="fading")return;let r=Te(t,e.now),o=n.exit>0&&!e.reduced?n.blend/2:0,i=Math.max(n.enter,r+o);if(i<n.enter+t.hold){t.hold=i-n.enter;for(let s of t.holding?.children??[])s.part===2&&s.state==="pending"&&Ia(e,s,i);Y8(e,t)}}function Y8(e,t){Ke(e,t),t.owner?.fitting&&Dn(e,t.owner),e.lanes?.refill()}function ML(e,t){for(let n of e.owners??[]){let r=n.arc;if(r===null||n.state==="done"||n.state==="pending")continue;let o=Te(n,t);if(!Number.isFinite(o))continue;let i=Tc(n);if(o>=i){let l=n.timeAt(i);n.play(!0,l,e.transport.seq),Bn(e,n,l);continue}let s=$L(r,n.hold),a=e.reduced?0:r.blend/2;for(let l of[...n.holding?.children??[]]){let u=s[l.part];u==null||u[1]===i||l.state==="done"||o>=u[1]+a&&Bn(e,l,n.timeAt(u[1]+a))}}}function mF(e,t,n){let r=e.arc,o=u=>{let c=e.timeAt(u);return Number.isFinite(c)?Math.max(t,c):void 0};if(n==="in"){let u=o(r.enter);return u===void 0?u:Math.max(u,t+(e.fade.in??0))}let i=o(r.enter+e.hold),s=e.out,a=s!==null?s.at:Number.isFinite(e.outAt)?e.outAt:void 0,l=a!==void 0&&(i===void 0||a<i);if(n==="coast")return l?void 0:i;if(n==="out")return l?a:e.state==="done"&&i===void 0?e.doneAt:i;if(e.state==="done")return e.doneAt;if(l){if(s!==null)return s.at+s.over;let u=Number.isNaN(e.outOver)?e.fade.out??0:e.outOver;return a+u}return o(Tc(e))}function qL(e,t){let n=[],r=[];for(let s=0;s<e.length;s++){let a=t[s].rest;a!==void 0&&(n.push(e[s]),r.push(typeof a=="number"?a:void 0))}function o(){for(let s=0;s<n.length;s++)this[n[s]]=r[s]}o.prototype=Object.prototype;let i=o;return()=>new i}function XL(e,t,n,r,o){let i,s=pe.back;if(s!==null)i=(Bh(e,n,r.elapsed,s)&1)!==0;else{let f=o.run;o.freed!==e.freed&&(f=e.slot(n),o.run=f,o.freed=e.freed),e.sample(f,r.elapsed,e.xs,e.vs),i=e.scalar(f)}let a=e.xs,l=o.delta??{};if(i)return l[t]=a[0],l;let u=e.n,c=l[t],d=Array.isArray(c)&&c.length===u?c:Qn(u,0);for(let f=0;f<u;f++)d[f]=a[f];return l[t]=d,l}var JL=wa;function QL(e,t,n,r,o){o.rebuilt=t.rebuilds;let i=t.patch;i.state===void 0&&i.step===void 0&&o.kept===null||(o.state=i.state?i.state(n):void 0,o.kept=null,o.unkept=void 0,o.since=e.sinceOf(t,o.delay),o.shown=e.shownOf(t,o.since),o.ticks=0,o.stepped=o.since<r?o.since:r,o.probed=Number.NaN)}function q8(e,t,n){let r=t.patch;return r.state===void 0&&r.step===void 0&&!t.keeping?!1:e.sinceOf(t,n.delay)!==n.since}function ZL(e,t,n){return e<0?U2(e,t):Dr(e,t,n)}var X8=Object.freeze({});function e_(e,t,n,r){if(r.weight=0,!r.reaches)return null;let o=e.bound!==null&&r.replay===void 0&&!cL(this,e.bound,t),i=o&&e.spec.weight.input===!0&&!!this.opts.history?.inputs;if(o&&!i&&e.patch.step===void 0&&e.spec.from!=="current"||e.out?.rest&&Oo(r))return null;r.rebuilt!==e.rebuilds?QL(this,e,t,n,r):r.seeks!==e.seeks&&q8(this,e,r)&&(QL(this,e,t,n,r),LP(e,r,n));let s=e.rawAt(n,r.delay),a=e.before(s,n);if(a&&!e.holdsFirst)return null;let l=e.shownAt(s);if(Number.isNaN(l))return null;let u=a?-1:e.freezesAfter&&s>e.span?1:0,c=e.duration,d=Zn(l,c,e.passes),f=this.primed;f[0]=n,f[1]=l,f[2]=d,this.prime(e,r);let p=e.setting,h=pe.kept,m=o?0:this.weigh(e,t,n,r);if(i&&pm(this,e,t,r,0),pe.kept!==h&&!e.keeping&&$i(this,e),p.weight=m,r.weight=m,r.probed===n&&r.delta&&r.seeks===e.seeks)return e.holder!==r&&e.scratch.length>0&&this.keyed(e,t,r),this.w=m,r.delta;let g=pe.kept,b=this.opts.history;if(b?.inputs&&e.patch.reads!==void 0&&!this.projecting&&WL(this,n),e.motion!==void 0&&(pe.horizon=this.horizonFor(e,r.delay,n)),e.patch.step&&r.probed!==n){let y=u===0?n:u===1?e.timeAt(r.delay+e.span):e.ranBackTo(r.delay,n),P=r.snaps,S=Number.isNaN(r.probed)&&P!==void 0;if(Number.isNaN(y))S&&yT(e,r);else{r.stepped<r.since&&(r.stepped=r.since,p.dt=this.capped(n-r.since));let v=Io(this,e);v!==void 0&&S&&J8(this,e,t,r,P,v,y),S&&yT(e,r),v!==void 0?this.tick(e,t,r,v,y):(u===0?n!==r.stepped:y>r.stepped)&&(u!==0&&(p.dt=this.capped(y-r.stepped)),e.patch.step(r.state,p.dt,t,p),r.stepped=y)}}let x=null,w=!1;if(vh(e,m)&&(e.built===null||e.spec.role===void 0))w=e.spec.role!==void 0,e.built&&e.spec.from==="current"&&r.base===void 0&&(r.base=this.baseFor(e,t),r.slope=this.slopeFor(e,t));else if(e.built)r.phase=ZL(l,c,e.passes),x=this.keyed(e,t,r);else if(e.motion!==void 0)x=XL(e.motion,e.patch.writes[0],t,p,r);else{let y=ZL(l,c,e.passes);x=e.patch.at(y,t,p),e.unchecked&&DL(e,x)}return r.delta=x,r.probed=n,r.seeks=e.seeks,b!==void 0&&em(this,e,t,r),pe.kept!==g&&!e.keeping&&$i(this,e),x===null?w?(this.w=m,X8):null:e.out?.rest&&this.isRest(x)?(r.weight=0,r.restedAt=n,e.restedCount++,null):(this.w=m,x)}function t_(e,t,n){let r;e.spec.from==="current"&&(n.base===void 0&&(n.base=this.baseFor(e,t),n.slope=this.slopeFor(e,t)),r=n.base);let o=zh(e.built,n.phase,n.delta??{},r,e.lerps,n.slope,e.intos,e.scratch);return n.delta=o,e.scratch.length>0&&(e.holder=n),o}function n_(e,t,n){return Math.floor((n-e.since)/t+1e-9)}function J8(e,t,n,r,o,i,s){let a=o[o.length-1],l=a?.ahead;if(a===void 0||l===void 0||l.put!==r)return;l.put=null;let u=t.patch.reads;if(e.opts.maxDt!==void 0||u!==void 0&&u.length>0)return;let c=a.held;if(r.ticks!==c.ticks||r.since!==l.since||r.rebuilt!==c.rebuilt)return;let d=l.sought,f=n_(r,i,s),p=l.state!==void 0&&l.ticks<=f;if(l.left!==void 0&&l.leftTicks<=f&&!(p&&l.ticks>l.leftTicks)){r.state=l.left,l.left=void 0,t.setting.state=r.state,r.ticks=l.leftTicks;return}p&&(r.state=Da(t,l.state),t.setting.state=r.state,r.ticks=l.ticks);let h=p?l.at:a.at;!(d<s)||d-h<kc(e.opts.history)||(yT(t,r),e.tick(t,n,r,i,d),l.state=Da(t,r.state),l.ticks=r.ticks,l.at=d)}function yT(e,t){let n=t.snaps,r=n[n.length-1];r!==void 0&&t.state!==void 0&&t.state===r.held.state&&(t.state=Da(e,t.state),e.setting.state=t.state)}function r_(e,t,n,r,o){let i=this.now,s=e.setting,a=s.dt,l=n.ticks,u=n_(n,r,o),c=this.opts.maxDt;if(c!==void 0){let f=Math.floor(c/r);u-l>f&&(l=u-f)}let d=e.patch.step;for(s.dt=r,l++;l<=u;l++)s.timestamp=n.since+l*r,d(n.state,r,t,s);n.ticks=u>n.ticks?u:n.ticks,n.stepped=n.since+n.ticks*r,s.timestamp=i,s.dt=a}function o_(e,t){let n=this.lastPoses.get(t)?.pose;if(n===void 0&&!this.folding.has(e.id)){this.folding.add(e.id);try{n=this.fold(t,void 0,!1,e.id)}finally{this.folding.delete(e.id)}}let r={};for(let o of e.patch.writes){let i=this.kit[o],s=n?.[o],a=i.rest;s!==void 0?r[o]=JL(s):a!==void 0&&(r[o]=JL(a))}return r}function i_(e,t){let n=this.lastPoses.get(t);if(n?.prev===void 0||!(n.at>n.prevAt))return;let r=n.at-n.prevAt,o=n.pose,i=n.prev,s={};for(let a of e.patch.writes){let l=i[a],u=o[a];typeof l=="number"&&typeof u=="number"?s[a]=(u-l)/r:Array.isArray(l)&&Array.isArray(u)&&l.length===u.length&&(s[a]=u.map((c,d)=>(c-l[d])/r))}return s}function s_(e){for(let t of Object.keys(e)){if(e[t]===void 0)continue;let n=this.kit[t];if(n.rest===void 0||!hc(e[t],n.rest))return!1}return!0}function a_(e,t,n,r,o){if(r&&o.reaches&&o.probed===n&&o.delta&&o.seeks===e.seeks){let i=e.setting,s=e.shownAt(e.rawAt(n,o.delay));return i.timestamp=n,i.dt=0,i.elapsed=s,i.pass=Zn(s,e.duration,e.passes),i.weight=0,i.state=o.state,i.mark=0,e.keepOn=o,this.w=this.weigh(e,t,n,o),o.weight=this.w,e.holder!==o&&e.scratch.length>0&&this.keyed(e,t,o),o.delta}return this.contribution(e,t,n,o)}function l_(e){this.frame=st();let t=ut(this,e);t!==void 0&&rc(this,t);let n=this.chains.get(e)?.slot??-1;n>=0&&this.lanes!==null&&this.lanes.release(n),this.projecting&&!(this.lastPoses instanceof oc)&&(this.lastPoses=new oc(this.lastPoses)),this.projecting||this.places?.drop(e),this.lastPoses.delete(e),this.restStamps?.delete(e),this.chains.delete(e),this.stir();let r=mm(this);for(let l of this.general)this.forgetIn(l,e,r);let o=this.named.get(e);if(o!==void 0)for(let l of[...o])this.forgetIn(l,e,r);let i=Bo(this);for(let l of i.general)this.forgetIn(l,e,r);let s=i.named.get(e);if(s!==void 0)for(let l of s)this.forgetIn(l,e,r);if(this.owners!==null)for(let l of this.owners)this.forgetIn(l,e,r);for(let l of this.parters)this.forgetIn(l,e,r),l.parts?.size===0&&(l.parts=null),l.parted?.size===0&&(l.parted=null),l.parts===null&&l.parted===null&&this.parters.delete(l);let a=this.strays.get(e);if(a!==void 0)for(let l of a)this.releaseIn(l,e,r);this.strays.delete(e);for(let l of this.strayAll)this.releaseIn(l,e,r);jr(this)&&this.recordDrop(e)}function u_(e,t,n){pT(this,e,t),e.subjects.delete(t),e.motion!==void 0&&this.releaseIn(e.motion,t,n),e.parts?.delete(t),e.parted?.delete(t),e.blend?.of.reads.delete(t)}function c_(e,t,n){this.projecting?e.holds(t)&&Ea("a drop of a subject a motion patch holds"):e.release(t,n[0],n[1],n[2],n[3])}function d_(e){Ot(this,"drop",t=>t.mix(this)?.drop(e))}var Q8=Symbol("unread");function gT(e,t,n,[r,o]){for(let i=t;i<t+n;i++){let s=e[i];e[i]=s<r?r:s>o?o:s}}function Z8(e,t,n){let r=n*e.axes;if(typeof t=="number"&&e.axes===1)e.out[r]=t;else if(Array.isArray(t)&&t.length===e.axes)for(let o=0;o<e.axes;o++)e.out[r+o]=t[o];else if(t===void 0)e.out.fill(Number.NaN,r,r+e.axes);else throw new TypeError(`blits: pull reads ${e.key} as ${e.axes===1?"a number":`${e.axes} numbers`} a subject, and the pose has ${String(t)}`)}function f_(e,t,n){let r;if(n===void 0||this.wantsPose){r={};for(let o of this.names){let i=t[o];i!==void 0&&(r[o]=wa(i))}}if(r!==void 0){let o=this.lastPoses.get(e);o===void 0?this.lastPoses.set(e,{pose:r,at:this.now,prev:void 0,prevAt:Number.NaN}):o.at===this.now?o.pose=r:(o.prev=o.pose,o.prevAt=o.at,o.pose=r,o.at=this.now)}}function p_(e,t,n){let r=tY(e,n),o=e.lanes,i=e.now;e.scratch===void 0&&(e.scratch=e.pose());let s=Number.POSITIVE_INFINITY,a="";for(let x of r){let w=Math.floor(x.out.length/x.axes);w<s&&(s=w,a=x.key)}let l;if(Array.isArray(t))l=t;else{let x=[];for(let w of t)if(x.push(w)>s)break;l=x}if(l.length>s)throw new RangeError(`blits: pull's array for ${a} has room for ${s} subjects, and was given more`);let u=o!==null&&!e.wantsPose,c=e.pulled,d=e.pulledHeads;if(e.pulledSlots.length<l.length){let x=new Int32Array(Math.max(64,l.length)).fill(-1);x.set(e.pulledSlots),e.pulledSlots=x}l.length<c.length&&e.pulledSlots.fill(-1,l.length,c.length);for(let x=c.length;x<l.length;x++)c.push(Q8);c.length=l.length,d.length=l.length;let f=e.version,p=e.relinks,h=!Number.isNaN(i),m=h&&e.pulledVersion===f&&e.pulledRelinks===p,g=m?Number.POSITIVE_INFINITY:h&&e.pulledVersion===f?e.pulledRelinks:-1;try{eY(e,l,r,h,m,g,u)}finally{o!==null&&o.pulls.flush(o)}let b=h&&e.version===f&&e.relinks===p;e.pulledVersion=b?f:Number.NaN,e.pulledRelinks=p}function eY(e,t,n,r,o,i,s){let a=e.lanes,l=e.now,u=e.scratch,c=e.pulled,d=e.pulledHeads,f=e.pulledSlots,p=e.version,h=r&&s;for(let m=0;m<t.length&&!(h&&(m=a.pulls.pullRun(a,f,t,c,i,m,n,l,e.version),m===t.length));m++){let g=t[m],b=-1;if(r)if(o&&c[m]===g)b=f[m];else{let S=d[m],v=c[m]===g&&S!==void 0&&S.version===p?S:e.chain(g);c[m]=g,d[m]=v,b=v.slot;let A=m===0?0:f[m-1]+1;if(h&&b>=0&&b!==A&&A>=0&&a.pulls.renumber(e,g,v,A)){for(let N=c.indexOf(g);N>=0;N=c.indexOf(g,N+1))f[N]=A;b=A}f[m]=b}let x=r&&a?.prepare(b,g,e.version,d[m]??null)===!0;if(x&&s&&a.whole&&!a.owes(b)){a.pulls.writeLater(a,b,n,m,f);continue}let w=r?d[m]:null,y=e.foldWith(g,u,w,x,!1),P=e.bounded.length===0?y:e.clamp(y);e.keep(g,P,u);for(let S of n)Z8(S,P[S.key],m)}}function tY(e,t){let n=[];e.pullColumns??=new Map;let r=e.pullColumns;for(let o of Object.keys(t)){let i=t[o];if(i===void 0)continue;let s=r.get(o);if(s!==void 0){s.out=i,n.push(s);continue}let a=e.slotOf.get(o);if(a===void 0)throw new Error(`blits: pull was handed ${o}, which the kit lacks`);let l=e.channels[a],u=l.rest,c=D2(l),d=l.bounds,f=new Float64Array(c).fill(Number.NaN);typeof u=="number"?f[0]=u:Array.isArray(u)&&f.set(u),d!==void 0&&gT(f,0,c,d);let p={key:o,slot:a,axes:c,out:i,rest:f,bounds:d};r.set(o,p),n.push(p)}return n}function h_(e){e.pulled=[],e.pulledHeads=[],e.pulledSlots=new Int32Array(0),e.pulledVersion=Number.NaN,e.pulledRelinks=-1}function y_(e,t,n,r,o,i,s,a,l){if((e.filled(a,l)?1:e.begin(a,l))!==1||!e.whole)return i;let c=e.per,d=e.fills,f=e.busyFill,p=e.wide,h=e.frameProbes,m=e.subjects,g=e.unlinked,b=e.holds,x=e.owed.any(),w=o===Number.POSITIVE_INFINITY;b_(e,s,t),x_(e,e.queued+n.length-i);let y=i,P=-1,S=i;for(;y<n.length;y++){let v=n[y];if(r[y]!==v)break;let A=t[y],N=A*6;if(A<0||!w&&!(g[A]<=o)||c[N+0]>=f||c[N+2]!==0||c[N+1]<p||x&&e.owes(A))break;c[N+3]>h||c[N+4]>h||e.distinct++,c[N+3]=++e.probes,c[N+5]=d,b&&(m[A]=v),A!==P+(y-S)&&(P>=0&&xT(e,P,S,y-S),P=A,S=y)}return P>=0&&xT(e,P,S,y-S),y>i&&b&&(e.holding=!0),y}function g_(e,t,n,r,o){b_(e,n,o),xT(e,t,r,1)}function b_(e,t,n){t===e.queuedFor&&n===e.queueFrom||(qi(e),e.queuedFor=t,e.queueFrom=n)}var m_=16;function xT(e,t,n,r){let o=e.queued;if(o>0){let i=o-1,s=e.queueCounts[i];if(n===e.queueRows[i]+s){let a=e.queueSlots[i];if(a>=0&&t===a+s){e.queueCounts[i]=s+r;return}if(r<m_&&(a<0||s<m_)){e.queueSlots[i]=-1,e.queueCounts[i]=s+r;return}}}x_(e,o+1),e.queueSlots[o]=t,e.queueRows[o]=n,e.queueCounts[o]=r,e.queued=o+1}function x_(e,t){if(t<=e.queueSlots.length)return;let n=Math.max(64,t,e.queueSlots.length*2);e.queueSlots=bT(e.queueSlots,n),e.queueRows=bT(e.queueRows,n),e.queueCounts=bT(e.queueCounts,n)}function bT(e,t){let n=new Int32Array(t);return n.set(e),n}function qi(e){let t=e.queued,n=e.queuedFor;if(!(t===0||n===null)){e.queued=0;for(let r=0;r<n.length;r++){let o=n[r],i=e.bySlot[o.slot];if(i===void 0?nY(e,o,t):oY(e,o,i.values,t),o.bounds!==void 0)for(let s=0;s<t;s++)gT(o.out,e.queueRows[s]*o.axes,e.queueCounts[s]*o.axes,o.bounds)}}}function nY(e,t,n){let r=e.queueRows,o=e.queueCounts,i=t.out,s=t.axes;if(s===1){let a=t.rest[0];for(let l=0;l<n;l++){let u=r[l],c=u+o[l];if(c-u>64)i.fill(a,u,c);else for(let d=u;d<c;d++)i[d]=a}return}for(let a=0;a<n;a++){let l=r[a]*s,u=l+o[a]*s;for(let c=l;c<u;c+=s)for(let d=0;d<s;d++)i[c+d]=t.rest[d]}}var rY=256;function oY(e,t,n,r){let o=e.queueSlots,i=e.queueRows,s=e.queueCounts,a=t.out,l=t.axes,u=e.queueFrom;for(let c=0;c<r;c++){let d=o[c];if(d<0){let m=i[c],g=m+s[c];if(l===1)for(let b=m;b<g;b++)a[b]=n[u[b]];else for(let b=m;b<g;b++){let x=b*l,w=u[b]*l;for(let y=0;y<l;y++)a[x+y]=n[w+y]}continue}let f=i[c]*l,p=d*l,h=s[c]*l;if(h>rY)a.set(n.subarray(p,p+h),f);else for(let m=0;m<h;m++)a[f+m]=n[p+m]}}function T_(e,t){this.copier===null&&(this.copier=iY(this.laned)),this.copier(t,e)}function S_(e,t,n){let r=e.start,o=e.axes,i=t*o;if(Array.isArray(n)&&n!==r&&n.length===(r.length>o?r.length:o)){for(let a=0;a<o;a++)n[a]=e.values[i+a];for(let a=o;a<r.length;a++)n[a]=r[a];return n}let s=[...r];for(let a=0;a<o;a++)s[a]=e.values[i+a];return s}var w_=new Map,P_=!1;function iY(e){let t=[];for(let o=0;o<e.length;o++){let i=e[o],s=`o[${JSON.stringify(i.name)}]`,a=i.scalar?"s":`s * ${i.axes}`,l=`if (${s} !== undefined) ${s} = undefined;`,u=i.scalar?`${s} = v;`:`{ const h = ${s}, a = f(c${o}, s, h); if (a !== h) ${s} = a; }`;t.push(`{ const v = c${o}.values[${a}];`),t.push(i.op==="last"?`if (v !== v) { ${l} } else ${u} }`:`${u} }`)}let n=t.join(`
427
- `),r=w_.get(n);if(r===void 0&&!P_){let o=e.map((i,s)=>`const c${s} = chans[${s}];`).join(" ");try{r=new Function("chans","f",`${o}
426
+ `),defines:r}}function $C(e){return e.match(/[A-Za-z_]\w*|\d[\w.]*|\S/g)??[]}function t8(e){let t=/^(?:0[xX]([0-9a-fA-F]+)|(0[0-7]*)|([1-9]\d*))[uU]?$/.exec(e);return t?t[1]!==void 0?parseInt(t[1],16):t[2]!==void 0?parseInt(t[2],8):parseInt(t[3],10):null}function YC(e,t){let n=0,r=()=>{let a=e[n++];if(a==="("){let l=i();return e[n++]===")"?l:null}if(a==="-"){let l=r();return l===null?null:-l}return a==="+"?r():a===void 0?null:t8(a)??(fP.test(a)?t(a):null)},o=()=>{let a=r();for(;a!==null&&(e[n]==="*"||e[n]==="/"||e[n]==="%");){let l=e[n++],u=r();if(u===null||l!=="*"&&u===0)return null;a=l==="*"?a*u:l==="/"?Math.trunc(a/u):a%u}return a},i=()=>{let a=o();for(;a!==null&&(e[n]==="+"||e[n]==="-");){let l=e[n++],u=o();if(u===null)return null;a=l==="+"?a+u:a-u}return a},s=i();return n===e.length&&s!==null&&s>=0?s:null}function n8(e,t){return[...NC,...pP(e),...pP(t)]}function mP(e,t){let n=t.vert===""?AC:t.vert,r=new to(e,n,t.frag);return r.lookupUniforms(n8(n,t.frag)),r.lookupUniformArrays(new Map([...hP(n),...hP(t.frag)])),r.lookupAttributes(RC),r}var JC={composited:0,redrawn:0,declined:0,bytes:0};function Sh(){return typeof performance<"u"?performance.now():Date.now()}var r8={pattern:[SR,RR],gradient:[kR,NR],texture:[vR,IR]},ac=class{gl;stats={drawCalls:0,ms:0,spans:[],retained:JC};pathFill;pathFillVColor;batchFill;batchVariants;gradFill;patternFill;glyphPaintPrograms=new Map;meshCache;textureCache;imageCache;gradRamps;programRegistry=new Map;programSources=new Map;quadVbo=null;quadIbo=null;drawBatch;whiteTexture=null;groupState=new Bf;widthCss;heightCss;dpr;canvas=null;lossTarget=null;target=null;effectTargets;retained;programEpoch=0;paintScratch;imageMinification;flattenTolerance;bakeBudget;textOutlineMinScreenSize;contextLost=!1;boundOnLost=t=>this.onContextLost(t);boundOnRestored=()=>this.onContextRestored();disposed=!1;paintResources=cl();constructor(t){if(!t.gl&&!t.canvas)throw new Error("WeaselRenderer requires either gl or canvas");let n=t.gl??t.canvas.getContext("webgl2",{stencil:!0});if(!n)throw new Error("WeaselRenderer: WebGL2 not available");this.gl=n,this.effectTargets=new Ph(this.gl),this.retained=new Th(this.gl,t.retainBudget??402653184),this.paintScratch=new Pf(this.gl);let r=typeof this.gl.getContextAttributes=="function"?this.gl.getContextAttributes():null;if(r&&r.stencil===!1)throw new Error("WeaselRenderer: the supplied WebGL2 context has no stencil buffer. Create it with { stencil: true } \u2014 clips and even-odd fills need one.");this.widthCss=t.width,this.heightCss=t.height,this.dpr=t.dpr,this.imageMinification=t.imageMinification??"auto",this.flattenTolerance=t.flattenTolerance,this.bakeBudget=t.bakeBudget??ri,this.textOutlineMinScreenSize=t.textOutlineMinScreenSize??xh,this.canvas=t.canvas??null,this.canvas&&(this.canvas.width=Math.round(t.width*t.dpr),this.canvas.height=Math.round(t.height*t.dpr));let o=this.canvas??this.gl.canvas??null;o&&typeof o.addEventListener=="function"&&(this.lossTarget=o,this.lossTarget.addEventListener("webglcontextlost",this.boundOnLost),this.lossTarget.addEventListener("webglcontextrestored",this.boundOnRestored)),this.applyGlState(),this.applyTarget(),this.pathFill=new An(this.gl,bR),this.pathFillVColor=new An(this.gl,xR),this.gradFill=new An(this.gl,wR),this.patternFill=new An(this.gl,PR),this.batchVariants=new xf(this.gl),this.batchFill=Db(this.gl),this.meshCache=new Zl(this.gl),this.textureCache=new tu(this.gl),this.imageCache=new Ds(this.gl,this.imageMinification),this.gradRamps=new au(this.gl),this.uploadQuadGeometry(),this.drawBatch=new sc(this.gl,this.batchFill),this.whiteTexture=cP(this.gl)}lazyPrograms(){return[this.pathFill,this.pathFillVColor,this.gradFill,this.patternFill,...this.batchVariants.lazy()]}uploadQuadGeometry(){let t=this.gl;if(this.quadVbo=t.createBuffer(),this.quadIbo=t.createBuffer(),!this.quadVbo||!this.quadIbo)throw new Error("WeaselRenderer: failed to create quad geometry buffers");t.bindBuffer(t.ARRAY_BUFFER,this.quadVbo),t.bufferData(t.ARRAY_BUFFER,IC,t.STATIC_DRAW),t.bindBuffer(t.ARRAY_BUFFER,null),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,this.quadIbo),t.bufferData(t.ELEMENT_ARRAY_BUFFER,EC,t.STATIC_DRAW),t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,null)}registerProgram(t){if(this.disposed)return;let n=Nn(t.id);if(!n)throw new Error(`WeaselRenderer.registerProgram: program "${t.id}" not found in source registry. Call the module-level registerProgram() first.`);this.installProgram(t.id,n,mP(this.gl,n))}installProgram(t,n,r){let o=this.programRegistry.get(t);o&&(this.gl.deleteProgram(o.handle),this.programEpoch++),this.programRegistry.set(t,r),this.programSources.set(t,n)}refreshPrograms(){for(let[t,n]of this.programSources){let r=Nn(t);if(!(!r||r===n)){if(r.vert===n.vert&&r.frag===n.frag){this.programSources.set(t,r);continue}try{this.installProgram(t,r,mP(this.gl,r))}catch(o){this.programSources.set(t,r),console.error(`weasel: failed to recompile re-registered program "${t}"; still drawing the previous one:`,o)}}}}ensureProgram(t){let n=this.programRegistry.get(t);if(n)return n;if(this.disposed||!Nn(t))return null;try{this.registerProgram({id:t})}catch(r){return console.error(`weasel: failed to compile paint program "${t}":`,r),null}return this.programRegistry.get(t)??null}glyphPaintProgram(t){let n=this.glyphPaintPrograms.get(t);if(n)return n;let[r,o]=r8[t],i=new to(this.gl,TR,r);return i.lookupUniforms(o),i.lookupAttributes(ER),this.glyphPaintPrograms.set(t,i),i}applyGlState(){let t=this.gl;t.enable(t.BLEND),t.blendFunc(t.ONE,t.ONE_MINUS_SRC_ALPHA),t.disable(t.DEPTH_TEST),t.disable(t.CULL_FACE),t.clearColor(0,0,0,0),t.colorMask(!0,!0,!0,!0),t.bindVertexArray(null),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1)}deviceRect(){let t=this.target?.origin.x??0,n=this.target?.origin.y??0,r=Math.round(t*this.dpr),o=Math.round(n*this.dpr),i=Math.round((t+this.widthCss)*this.dpr)-r;return{x:r,y:o,width:i,height:Math.round((n+this.heightCss)*this.dpr)-o}}applyTarget(){let t=this.gl,{x:n,y:r,width:o,height:i}=this.glRect();if(t.viewport(n,r,o,i),!this.target){t.disable(t.SCISSOR_TEST);return}t.scissor(n,r,o,i),t.enable(t.SCISSOR_TEST)}glRect(){let{x:t,y:n,width:r,height:o}=this.deviceRect();return this.target?{x:t,y:this.gl.drawingBufferHeight-n-o,width:r,height:o}:{x:0,y:0,width:r,height:o}}setTarget(t){this.target=t,this.applyTarget()}getTarget(){return this.target}isContextLost(){return this.contextLost}onContextLost(t){t.preventDefault(),this.contextLost=!0}onContextRestored(){this.contextLost=!1,this.applyGlState(),this.applyTarget(),this.effectTargets.releaseAll(),this.retained.releaseAll(),this.paintScratch.release(),this.paintResources.release(),this.paintResources=cl();for(let t of this.lazyPrograms())t.abandon();this.batchFill=Db(this.gl),this.glyphPaintPrograms.clear(),this.meshCache=new Zl(this.gl),this.textureCache=new tu(this.gl),this.imageCache.abandon(),this.imageCache=new Ds(this.gl,this.imageMinification),this.gradRamps=new au(this.gl),this.uploadQuadGeometry(),this.drawBatch=new sc(this.gl,this.batchFill),this.whiteTexture=cP(this.gl);for(let t of this.programRegistry.keys()){let n=Nn(t);if(n)try{this.programRegistry.set(t,mP(this.gl,n)),this.programSources.set(t,n)}catch(r){console.error(`weasel: failed to recompile program "${t}" after context restore:`,r)}}}dispose(){if(this.disposed)return;this.disposed=!0;let t=this.gl;this.lossTarget&&(this.lossTarget.removeEventListener("webglcontextlost",this.boundOnLost),this.lossTarget.removeEventListener("webglcontextrestored",this.boundOnRestored)),this.meshCache.dispose(),this.paintResources.release();for(let n of this.lazyPrograms())n.release();for(let n of[this.batchFill,...this.glyphPaintPrograms.values()])t.deleteProgram(n.handle);this.glyphPaintPrograms.clear();for(let n of this.programRegistry.values())t.deleteProgram(n.handle);this.programRegistry.clear(),this.programSources.clear(),this.textureCache.free(),this.imageCache.dispose(),this.gradRamps.free(),this.quadVbo&&t.deleteBuffer(this.quadVbo),this.quadIbo&&t.deleteBuffer(this.quadIbo),this.drawBatch.dispose(),this.whiteTexture&&t.deleteTexture(this.whiteTexture),this.whiteTexture=null,this.effectTargets.releaseAll(),this.retained.releaseAll(),this.paintScratch.release()}render(t,n,r){if(this.contextLost||this.disposed)return;let o=Sh(),i={drawCalls:0},s=[];this.stats={drawCalls:0,ms:0,spans:s,retained:JC};let a=this.gl;this.meshCache.drainPendingDeletes(),this.imageCache.beginFrame(),this.textureCache.sweep(xi),this.refreshPrograms(),this.retained.beginFrame([ti(),xi.getVersion(),Zu.getVersion(),this.programEpoch,this.flattenTolerance,this.widthCss,this.heightCss,this.dpr]),xd(this.bakeBudget),this.groupState.reset(),this.drawBatch.reset(),this.effectTargets.reclaim(),a.bindFramebuffer(a.FRAMEBUFFER,null),this.applyGlState(),this.applyTarget(),this.target?.clear!==!1&&(a.stencilMask(255),a.clear(a.COLOR_BUFFER_BIT|a.STENCIL_BUFFER_BIT));let l=this.deviceRect(),u=this.glRect(),{pathFill:c,pathFillVColor:d,gradFill:f,patternFill:p}=this,h={gl:a,get pathFill(){return c.get()},get pathFillVColor(){return d.get()},batchFill:this.batchFill,batchVariants:this.batchVariants,get gradFill(){return f.get()},get patternFill(){return p.get()},meshCache:this.meshCache,textureCache:this.textureCache,imageCache:this.imageCache,gradRamps:this.gradRamps,programRegistry:this.programRegistry,ensureProgram:x=>this.ensureProgram(x),glyphPaintProgram:x=>this.glyphPaintProgram(x),quadVbo:this.quadVbo,quadIbo:this.quadIbo,drawBatch:this.drawBatch,whiteTexture:this.whiteTexture,state:this.groupState,widthCss:this.widthCss,heightCss:this.heightCss,clipDepth:0,clipStack:[],flattenTolerance:cN(this.flattenTolerance,this.dpr),textOutlineMinScreenSize:this.textOutlineMinScreenSize,viewMatrix:n,screenMatrix:r?.screen,effectTargets:this.effectTargets,retained:this.retained,paintScratch:this.paintScratch,renderTarget:null,fragOrigin:[u.x,u.y],deviceWidth:l.width,deviceHeight:l.height,restoreTargetRect:()=>this.applyTarget(),paintResources:this.paintResources,stats:i};this.drawBatch.clip=null;let m=r?.spans??[],y=0;for(let x=0;x<m.length;x++){let w=m[x];for(;y<w.start;y++)zi(h,t[y]);let g=i.drawCalls,P=Sh();for(;y<w.end;y++)zi(h,t[y]);x===m.length-1&&y>=t.length&&ye(h),s.push({id:w.id,drawCalls:i.drawCalls-g,ms:Sh()-P})}for(;y<t.length;y++)zi(h,t[y]);ye(h),this.meshCache.freeTransient();let b=this.retained;b.endFrame(),this.stats.retained={composited:b.composited,redrawn:b.redrawn,declined:b.declined,bytes:b.bytes},this.stats.drawCalls=i.drawCalls,this.stats.ms=Sh()-o}lastFrameStats(){return this.stats}setFlattenTolerance(t){this.flattenTolerance=t}setRetainBudget(t){this.retained.setBudget(t??402653184)}setImageMinification(t){let n=t??"auto";n!==this.imageMinification&&(this.imageMinification=n,this.imageCache.dispose(),this.imageCache=new Ds(this.gl,n))}resize(t){this.widthCss=t.width,this.heightCss=t.height,this.dpr=t.dpr,this.canvas&&(this.canvas.width=Math.round(t.width*t.dpr),this.canvas.height=Math.round(t.height*t.dpr)),this.applyTarget()}_gl(){return this.gl}_pathFill(){return this.pathFill.get()}_pathFillVColor(){return this.pathFillVColor.get()}_drawBatch(){return this.drawBatch}_batchFill(){return this.batchFill}_batchVariants(){return this.batchVariants}_gradFill(){return this.gradFill.get()}_patternFill(){return this.patternFill.get()}_meshCache(){return this.meshCache}_textureCache(){return this.textureCache}_imageCache(){return this.imageCache}_gradRamps(){return this.gradRamps}_groupState(){return this.groupState}_widthCss(){return this.widthCss}_heightCss(){return this.heightCss}_dpr(){return this.dpr}};Pe();var o8={...Ee};function yP(e,t,n,r,o,i,s,a,l,u=1){let c=xp(o8,r,a,u);return{kind:"text",x:e,y:t,runs:Fu(n,c,u),align:c.align,direction:c.direction,justify:c.align==="justify",maxWidth:o,style:r??{},height:i,verticalAlign:s,width:l}}function gP(e,t=1){let{runs:n,opts:r}=zp(e,t);return{kind:"text",x:e.x,y:e.y,runs:i8(n,e),align:r.align,direction:r.direction,justify:r.justify,maxWidth:r.maxWidth,width:r.alignWidth,style:e.style??{},height:e.height,verticalAlign:e.verticalAlign}}function i8(e,t){return e.every(n=>QC(n.fill?.paint)&&QC(n.stroke?.paint))?e:e.map(n=>{let r=n.fill&&Kt(n.fill,t),o=n.stroke?.paint&&Ui(n.stroke.paint,t);return{...n,fill:r,stroke:n.stroke&&{...n.stroke,paint:o||void 0}}})}function QC(e){return e==null||Ut(e)}function ZC(e){return typeof e=="number"?{x:e,y:e}:e}function bP(e,t){let n=ZC(t.pan),r=ZC(t.zoom??1),o=t.anchor??{x:0,y:0};return{x:o.x+(e.x-o.x)*n.x,y:o.y+(e.y-o.y)*n.y,scale:{x:1+(e.scale.x-1)*r.x,y:1+(e.scale.y-1)*r.y}}}function kh(e,t){let n=bP(e,t),r=e.scale.x/n.scale.x,o=e.scale.y/n.scale.y;return{scale:{x:r,y:o},offset:{x:n.x-r*e.x,y:n.y-o*e.y}}}function xP(e,t){return{x:t.x*e.scale.x+e.offset.x,y:t.y*e.scale.y+e.offset.y}}function s8(e,t){let n=t({x:e.x,y:e.y}),r=t({x:e.x+e.width,y:e.y+e.height});return{x:Math.min(n.x,r.x),y:Math.min(n.y,r.y),width:Math.abs(r.x-n.x),height:Math.abs(r.y-n.y)}}function tO(e,t){return{...t,...s8(t,n=>xP(e,n))}}function wP(e,t){if(e===t)return null;let n=e??eO,r=t??eO,o=r.scale.x/n.scale.x,i=r.scale.y/n.scale.y,s={scale:{x:o,y:i},offset:{x:r.offset.x-n.offset.x*o,y:r.offset.y-n.offset.y*i}};return s.scale.x===1&&s.scale.y===1&&s.offset.x===0&&s.offset.y===0?null:s}var eO={scale:{x:1,y:1},offset:{x:0,y:0}};function PP(e){return[e.scale.x,0,0,e.scale.y,e.offset.x,e.offset.y]}var a8=["weasel.debug","weaseldraw.debug"],TP=null;function l8(){let e={all:!1,set:new Set};if(typeof localStorage>"u")return e;try{for(let t of a8){let n=localStorage.getItem(t);if(!(n==null||n===""))return n==="1"||n==="true"||n==="*"?{all:!0,set:new Set}:{all:!1,set:new Set(n.split(/[\s,]+/).filter(Boolean))}}return e}catch{return e}}function u8(){return TP===null&&(TP=l8()),TP}function vh(e){let t=u8();return t.all?!0:e===void 0?t.set.size>0:t.set.has(e)}function Ah(e,...t){vh(e)&&console.debug(`[${e}]`,...t)}function Mt(e,...t){vh(e)&&console.warn(`[${e}]`,...t)}Z();function Ct(e){return e.closure!=="identity"}function jt(e,t,n){let r=[t],o=new Set([t]),i=e.getParent(t);for(;i!==null&&!o.has(i);)o.add(i),(e.definesFrame?.(i)??!0)&&r.push(i),i=e.getParent(i);let s=e.getPose(r[r.length-1]),a=e.childFrame;for(let l=r.length-2;l>=0;l--){let u=a===void 0?s:a.call(e,r[l+1],s);s=n(u,e.getPose(r[l]))}return s}function ha(e,t,n){return rO(e,t,jt(e,t,n))}function rO(e,t,n){return e.childFrame===void 0||!(e.definesFrame?.(t)??!0)?n:e.childFrame(t,n)}function ma(e,t,n,r,o){let i=Xn(e,n);return i===null?t:o(ha(e,i,r),t)}function Xn(e,t){let n=new Set,r=t;for(;r!==null&&!n.has(r);){if(e.definesFrame?.(r)??!0)return r;n.add(r),r=e.getParent(r)}return null}var nO=new WeakMap;function oO(e){let t=nO.get(e);if(t!==void 0)return t;let n=new WeakMap,r=(o,i)=>{if(typeof o!="object"||o===null||typeof i!="object"||i===null)return e(o,i);let s=n.get(o);s===void 0&&n.set(o,s=new WeakMap);let a=s.get(i);return a===void 0&&s.set(i,a=e(o,i)),a};return nO.set(e,r),r}function iO(e,t,n){return{...e,x:e.x+t,y:e.y+n}}function SP(e,t){return t===0&&e.rotation===void 0?e:{...e,rotation:t}}function sO(e,t,n){let[r,o,i,s]=ht(vl(-t),n),a=Math.abs(r-1)<1e-12&&Math.abs(o)<1e-12&&Math.abs(i)<1e-12&&Math.abs(s-1)<1e-12,l=SP({...e},t);return a?delete l.transform:l.transform=[r,o,i,s],l}function aO(e,t,n){return{...e,x:t-e.width/2,y:n-e.height/2}}var lO=[1,0,0,1,0,0];function uO(e,t,n,r,o){let i=Math.cos(n),s=Math.sin(n);return[e+(r-e)*i-(o-t)*s,t+(r-e)*s+(o-t)*i]}function c8(e,t){let n=e.rotation??0,r=zn(e)&&Re(e);if(r){let[s,a]=wn(r,e.x+t.x+t.width/2,e.y+t.y+t.height/2),l=ht(r,Re(t)??lO);return sO(aO(t,s,a),(t.rotation??0)+n,l)}let[o,i]=uO(e.x+e.width/2,e.y+e.height/2,n,e.x+t.x+t.width/2,e.y+t.y+t.height/2);return SP({...t,x:o-t.width/2,y:i-t.height/2},(t.rotation??0)+n)}function d8(e,t){let n=e.rotation??0,r=zn(e)&&mi(e);if(r){let[s,a]=wn(r,t.x+t.width/2,t.y+t.height/2),l=ht(r,Re(t)??lO);return sO(aO(t,s-e.x,a-e.y),(t.rotation??0)-n,l)}let[o,i]=uO(e.x+e.width/2,e.y+e.height/2,-n,t.x+t.width/2,t.y+t.height/2);return SP({...t,x:o-e.x-t.width/2,y:i-e.y-t.height/2},(t.rotation??0)-n)}function f8(e,t){return iO(e,-t.x,-t.y)}function p8(e,t){let n=Re(e);if(!n)return f8(e,t);let[r,o,i,s]=n;return iO(e,-(r*t.x+i*t.y),-(o*t.x+s*t.y))}var Rh={compose:c8,decompose:d8,closure:"rigid",scroll:p8};var ya=!1;function cO(){ya=!0}function dO(e){let t=ya;ya=!1;try{return{value:e(),fonts:ya}}finally{ya=t||ya}}function kP(){return fl()}var fO=4;function vP(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Nh(e,t=fO){if(t<=0)return e;if(Array.isArray(e))return e.map(n=>Nh(n,t-1));if(vP(e))return e.slice();if(tn(e)){let n={...e};for(let r in n){let o=n[r];typeof o=="object"&&o!==null&&(n[r]=Nh(o,t-1))}return n}return e}function Fo(e,t,n=fO){if(e===t)return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return Object.is(e,t);if(n<=0)return!1;let r=Object.getPrototypeOf(e);if(us(r)){if(!us(Object.getPrototypeOf(t)))return!1;let o=e,i=t,s=0;for(let a in o){s++;let l=o[a],u=i[a];if(l===u){if(u===void 0&&!(a in i))return!1;continue}if(!Fo(l,u,n-1))return!1}for(let a in i)if(--s<0)return!1;return!0}if(Array.isArray(e)||vP(e)){let o=e;if(!(Array.isArray(t)||vP(t)))return!1;let i=t;if(o.length!==i.length)return!1;for(let s=0;s<o.length;s++)if(!Fo(o[s],i[s],n-1))return!1;return!0}return!1}function lc(){return{nodes:[],poses:[],data:[],layers:[],paths:[],children:[],faces:null}}var AP=class{constructor(t,n,r){this.dep=t;this.record=n;this.index=r;this.node=t.node,this.pose=t.pose}dep;record;index;node;pose;get path(){return this.record.paths[this.index]=this.dep.path}get inherited(){return this.dep.inherited}get children(){let t=this.dep.children;if(t===void 0)return;let n=this.record.children[this.index]=lc();return pO(n,t)}};function pO(e,t){return e.nodes.length=0,e.poses.length=0,e.data.length=0,e.layers.length=0,e.paths.length=0,e.children.length=0,t.map((n,r)=>(e.nodes.push(n?.node),e.poses.push(n===void 0?void 0:Nh(n.pose)),e.data.push(n?.node.data),e.layers.push(n?.node.layer),e.paths.push(void 0),e.children.push(void 0),n===void 0?void 0:new AP(n,e,r)))}function Ih(e,t,n){let r=pO(e,t),o=kP(),{value:i,fonts:s}=dO(()=>n(r));return e.faces=s?o:null,i}function Eh(e,t,n){if(e.nodes.length!==t.length||e.faces!==null&&e.faces!==kP())return!1;for(let r=0;r<t.length;r++)if(!hO(e,r,n(t[r])))return!1;return e.faces!==null&&cO(),!0}function hO(e,t,n){if(e.nodes[t]!==(n===void 0?void 0:n.node))return!1;if(n===void 0)return!0;if(e.data[t]!==n.node.data||e.layers[t]!==n.node.layer||!Fo(e.poses[t],n.pose))return!1;let r=e.paths[t];if(r!==void 0&&r!==n.path)return!1;let o=e.children[t];if(o===void 0)return!0;let i=n.children;return i===void 0||i.length!==o.nodes.length?!1:i.every((s,a)=>hO(o,a,s))}Z();Z();Pe();function mO(e,t,n){return{fill:Ie(e.fill,Ie(t?.fill,n?.fill)),stroke:Ne(e.stroke,Ne(t?.stroke,n?.stroke))}}var yO=new WeakMap;function gO(e){if(e.length===0)return null;let t=e.length===1?e[0].path:h8(e.map(r=>r.path)),n=t===e[0].path?{...t}:t;return yO.set(n,e),n}function Mh(e){return e==null?void 0:yO.get(e)}function h8(e){return Ng(e.map(t=>t.kind==="rect"?cb(pi(t)):t))}function xO(e,t,n,r,o){if(e===void 0||!Ct(e))return null;let i={getPose:a=>r(a),getParent:a=>n(a)?.parent??null,definesFrame:a=>o(a)},s=Xn(i,t.parent??null);return(a,l)=>{let u=Xn(i,n(a)?.parent??null);if(u===s)return l;let c=u===null?l:e.compose(jt(i,u,e.compose),l);return s===null?c:e.decompose(jt(i,s,e.compose),c)}}function ga(e){let t=e;return typeof t=="object"&&t!==null&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"}function Ch(e,t,n){return!ga(t)||!ga(n)||t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height?e:uc(e,mr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height))}function wO(e,t,n){if(!ga(t)||!ga(n))return e;let r=mi(t),o=Re(n),i=mr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height);return r!==null&&(i=ht(i,r)),o!==null&&(i=ht(o,i)),uc(e,i)}function Oh(e,t,n){if(!ga(t)||!ga(n))return e;let r=Re(n),o=t.x===n.x&&t.y===n.y&&t.width===n.width&&t.height===n.height;if(r===null&&o)return e;let i=mr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height);return uc(e,r===null?i:ht(r,i))}function uc(e,t){let n=t.join(","),r=bO.get(e);if(r?.key===n)return r.path;let o=Mh(e),i=o===void 0?Nt(e,t):gO(o.map(s=>({...s,path:Nt(s.path,t)})));return bO.set(e,{key:n,path:i}),i}var bO=new WeakMap;var Fh=Object.freeze([]);var cc=e=>Array.isArray(e?.dependsOn)?e.dependsOn:Fh;function Lh(e,t){let n=e.dependsOn;return n===void 0?Fh:n==="children"?t(e.id):n}function PO(){let e=new Map,t=new Map;function n(r){let o=t.get(r);if(o!==void 0){for(let i of o){let s=e.get(i);s!==void 0&&(s.delete(r),s.size===0&&e.delete(i))}t.delete(r)}}return{add(r,o){if(n(r),o.length!==0){t.set(r,[...o]);for(let i of o){let s=e.get(i);s===void 0&&(s=new Set,e.set(i,s)),s.add(r)}}},remove(r){n(r)},clear(){e.clear(),t.clear()},isEmpty(){return e.size===0},dependentsOf(r){let o=e.get(r);return o===void 0?Fh:[...o]},transitiveDependentsOf(r){let o=e.get(r);if(o===void 0)return Fh;let i=new Set,s=[...o];for(;s.length>0;){let a=s.pop();if(!i.has(a)){i.add(a);for(let l of e.get(a)??[])s.push(l)}}return i}}}function TO(e,t){if(e===t)return!0;if(e===void 0||t===void 0||e==="children"||t==="children"||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function SO(){return new WeakMap}var ba=new WeakMap,Dr=0;function rt(e,t,n,r,o){if(typeof t!="string")return m8(e,t,n,r,o);let i=ba.get(e);i===void 0?(i={generation:Dr,slots:new Map,drops:0},ba.set(e,i)):i.generation!==Dr&&(i.generation=Dr,i.slots.clear());let s=e.data,a=i.slots.get(t);if(a!==void 0&&a.pose===n&&a.data===s&&a.also===o)return a.value;let l=r();return a!==void 0?(a.pose=n,a.data=s,a.also=o,a.value=l):i.slots.set(t,{pose:n,data:s,also:o,value:l}),l}function m8(e,t,n,r,o){let i=t,s=e.data,a=ba.get(e)?.drops??0,l=i.get(e);if(l!==void 0&&l.generation===Dr&&l.pose===n&&l.data===s&&l.also===o&&(n===void 0||l.drops===a))return l.value;let u=r(),c=ba.get(e)?.drops??0;return l!==void 0?(l.pose=n,l.data=s,l.also=o,l.value=u,l.generation=Dr,l.drops=c):i.set(e,{pose:n,data:s,also:o,value:u,generation:Dr,drops:c}),u}function dc(){Dr++}function kO(){return Dr}function un(e){let t=ba.get(e);if(t===void 0){ba.set(e,{generation:Dr,slots:new Map,drops:1});return}t.drops++;for(let[n,r]of t.slots)r.pose!==void 0&&t.slots.delete(n)}var y8="kit:derivedPath",RP=new Set,NP=0;function Br(e,t,n,r=y8){let o=e.derivePath;if(o===void 0)return null;let i=Lh(e,n);if(i.length===0)return null;if(RP.has(e.id))return NP++,null;RP.add(e.id);let s=NP;try{let a=!1,l=rt(e,r,e.pose,()=>(a=!0,vO(e,o,i.map(t),{...lc(),path:null})));return!a&&!Eh(l,i,t)&&vO(e,o,i.map(t),l),NP!==s&&un(e),l.path}finally{RP.delete(e.id)}}function vO(e,t,n,r){return r.path=Ih(r,n,o=>t(e,o)),r}Pe();function fc(e){let t=e.data;return t?.fill===It||t?.stroke===It}var AO=new WeakMap;function xa(e,t){let n=e.data,r=n?.fill===It,o=n?.stroke===It,i=null,s=null;for(let u of t){if(!r&&!o)break;let c=u.data;r&&c?.fill!==It&&(i=Ie(c?.fill),r=!1),o&&c?.stroke!==It&&(s=Ne(c?.stroke),o=!1)}let a=AO.get(e);if(a!==void 0&&a.fill===i&&a.stroke===s)return a;let l={fill:i,stroke:s};return AO.set(e,l),l}function wa(e,t){if(fc(t))return xa(t,RO(n=>e.get(n),t))}function*RO(e,t){let n=new Set,r=t.parent??null;for(;r!==null&&!n.has(r);){n.add(r);let o=e(r);if(o===void 0)return;yield o,r=o.parent??null}}var pc=()=>{throw new Error("documentOf: the document reading holds no overrides; write them to the scene")},g8=Object.freeze({set:pc,get:()=>{},read:e=>{},has:()=>!1,ids:()=>[],clear:pc,clearAll:pc,commit:pc,subscribe:()=>()=>{},getGeneration:()=>0,hold:()=>pc()});function _h(e){return e.overrides===g8}var IO=Symbol("weasel.shownData"),IP=new WeakMap;function Tt(e,t){if(IO in t)return t;let n=e.read(t.id)?.data;if(n===void 0)return t;let r=IP.get(t);if(r!==void 0&&r.data===n&&r.stored===t.data)return r.shown;let o=b8(t,n(t.data));return IP.set(t,{stored:t.data,data:n,shown:o}),o}function b8(e,t){return{...e,data:t,[IO]:!0}}function EO(e){return IP.get(e)?.shown}function Pa(e){return{get:t=>{let n=e.get(t);return n===void 0?void 0:Tt(e.overrides,n)}}}var NO=new WeakMap;function Dh(e,t){let n=e.getGeneration(),r=NO.get(e);return(r===void 0||r.at!==n)&&(r={at:n,any:e.ids().some(o=>e.read(o)?.data!==void 0)},NO.set(e,r)),r.any?t.map(o=>Tt(e,o)):t}var x8={effective:"kit:derivedPose",document:"kit:derivedPose:document"},w8={effective:void 0,document:"kit:derivedPath:document"},EP=new Set,MP=0;function CO(e){return _h(e)?"document":"effective"}function OO(e,t,n){let r=FO(e,t,n),o=r.derivePose;if(o===void 0)return null;let i=Lh(r,e.childrenOf);if(i.length===0)return null;if(EP.has(r.id))return MP++,null;EP.add(r.id);let s=MP;try{let a=FP(e,r,n),l=!1,u=rt(r,x8[n],r.pose,()=>(l=!0,MO(r,o,i.map(a),{...lc(),value:null})));return!l&&!Eh(u,i,a)&&MO(r,o,i.map(a),u),MP!==s&&un(r),u.value}finally{EP.delete(r.id)}}function MO(e,t,n,r){return r.value=Ih(r,n,o=>t(e,o)),r}function OP(e,t,n){let r=CO(e);return n===void 0?LP(e,t,r):FP(e,n,r)(t)}function FP(e,t,n){let r=i=>LP(e,i,n);if(t.dependsOn==="children")return r;let o=xO(e.composition,t,i=>e.get(i),i=>_P(e,e.get(i),n),i=>{let s=e.get(i);return s===void 0||lt(s)});return o===null?r:i=>{let s=r(i);if(s===void 0)return;let a=o(i,s.pose);return a===s.pose?s:new Bh(s,a)}}var Bh=class{constructor(t,n){this.dep=t;this.pose=n;this.node=t.node}dep;pose;node;get path(){let t=this.dep.path;return t===null?null:wO(t,this.dep.pose,this.pose)}get inherited(){return this.dep.inherited}};function LP(e,t,n){let r=e.get(t);if(r!==void 0)return new CP(e,r,n)}var CP=class{constructor(t,n,r){this.source=t;this.reading=r;let o=FO(t,n,r);this.posed=o,this.node=o;let i=r==="effective"?t.overrides.read(o.id):void 0;this.shown=i?.path,this.pose=i?.pose??OO(t,o,r)??o.pose}source;reading;node;pose;shown;posed;get path(){if(this.shown!==void 0)return Oh(this.shown,this.pose,this.pose);let{source:t,reading:n}=this;return Br(this.posed,FP(t,this.posed,n),r=>t.childrenOf(r),w8[n])}get inherited(){let{source:t,reading:n}=this;return wa(n==="effective"?Pa(t):t,this.posed)}get children(){let{source:t,reading:n}=this,r=t.composition,o=r&&Ct(r)&&lt(this.posed)?r.compose:null;return t.childrenOf(this.posed.id).map(i=>{let s=LP(t,i,n);return s===void 0||o===null?s:new Bh(s,o(this.pose,s.pose))})}};function FO(e,t,n){return n==="effective"?Tt(e.overrides,t):t}function _P(e,t,n){if(n==="effective"){let r=e.overrides.read(t.id)?.pose;if(r!==void 0)return r}return OO(e,t,n)??t.pose}function Hr(e,t){return _P(e,t,"document")}function Jn(e,t){return _P(e,t,CO(e))}function lt(e){return!P8(e)}function P8(e){return e.dependsOn==="children"&&e.derivePose!==void 0}Z();Z();function DP(e){let t=Re(e);if(!t)return{x:e.x,y:e.y,width:e.width,height:e.height};let n=1/0,r=1/0,o=-1/0,i=-1/0,s=[[e.x,e.y],[e.x+e.width,e.y],[e.x+e.width,e.y+e.height],[e.x,e.y+e.height]];for(let[a,l]of s){let[u,c]=wn(t,a,l);u<n&&(n=u),u>o&&(o=u),c<r&&(r=c),c>i&&(i=c)}return{x:n,y:r,width:o-n,height:i-r}}function LO(e){let t=1/0,n=1/0,r=-1/0,o=-1/0,i=!1;for(let s of e){if(!s)continue;let a=DP(s);i=!0,a.x<t&&(t=a.x),a.y<n&&(n=a.y);let l=a.x+a.width,u=a.y+a.height;l>r&&(r=l),u>o&&(o=u)}return i?{x:t,y:n,width:r-t,height:o-n}:null}Z();function Gr(e,t){return e.forNode?.(t)??e}var Ot={getBounds:e=>e,remapBounds:(e,t,n)=>{let r=t.width===0?1:n.width/t.width,o=t.height===0?1:n.height/t.height;return{...e,x:n.x+(e.x-t.x)*r,y:n.y+(e.y-t.y)*o,width:e.width*r,height:e.height*o}},fromBounds:e=>({x:e.x,y:e.y,width:e.width,height:e.height}),translate:(e,t,n)=>({...e,x:e.x+t,y:e.y+n}),lerp:(e,t,n)=>({...e,x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,width:e.width+(t.width-e.width)*n,height:e.height+(t.height-e.height)*n}),axes:e=>[e.x,e.y,e.width,e.height].every(n=>typeof n=="number")?{count:5,names:["x","y","width","height","rotation"],angles:[4],to:n=>[n.x,n.y,n.width,n.height,n.rotation??0],from:n=>{let r={...e,x:n[0],y:n[1],width:n[2],height:n[3]};return(e.rotation!==void 0||n[4]!==0)&&(r.rotation=n[4]),r},add:(n,r)=>{let o={...n,x:n.x+r[0],y:n.y+r[1],width:n.width+r[2],height:n.height+r[3]},i=(n.rotation??0)+r[4];return(n.rotation!==void 0||i!==0)&&(o.rotation=i),o},write:(n,r,o)=>{r[o]=n.x,r[o+1]=n.y,r[o+2]=n.width,r[o+3]=n.height,r[o+4]=n.rotation??0}}:null,getRotation:e=>e.rotation??0,withRotation:(e,t)=>({...e,rotation:t})},T8={getBounds:Ot.getBounds,remapBounds:Ot.remapBounds,translate:Ot.translate,lerp:Ot.lerp,axes:Ot.axes,fromBounds:e=>({x:e.x,y:e.y,width:e.width,height:e.height,rotation:0}),getRotation:e=>e.rotation,withRotation:(e,t)=>({...e,rotation:t})};function Ki(e,t){return DP(BP(e,t))}function BP(e,t){let n=t.getBounds(e),r=t.getRotation?.(e)??n.rotation??0,o=zn(e)??zn(n);return!r&&!o?n:{...n,...r?{rotation:r}:{},...o?{transform:o}:{}}}function HP(e,t,n,r,o){if(r.translate)return o?r.translate(e,t,n,o):r.translate(e,t,n);let i=r.getBounds(e),s={x:i.x+t,y:i.y+n,width:i.width,height:i.height};return r.remapBounds(e,i,s)}function DO(){let e=new Map,t=Ce(),n=0,r=()=>{n++,t.emit()};return{get:o=>e.get(o),set(o,i){let s=e.get(o);if(i===null||i.x===0&&i.y===0&&!i.z){if(s===void 0)return;e.delete(o)}else{if(s!==void 0&&s.x===i.x&&s.y===i.y&&(s.z??0)===(i.z??0))return;e.set(o,{...i})}r()},ids:()=>e.keys(),clearAll(){e.size!==0&&(e.clear(),r())},subscribe:t.subscribe,getGeneration:()=>n}}var _O=new WeakMap;function S8(e,t,n){if(typeof t!="object"||t===null)return e(t,n);let r=_O.get(e);r===void 0&&_O.set(e,r=new WeakMap);let o=r.get(t);if(o!==void 0&&o.offset===n)return o.out;let i=e(t,n);return r.set(t,{offset:n,out:i}),i}function GP(e){let t=e.scroll,n=e.composition?.scroll;if(!(t===void 0||n===void 0)&&!(e.overrides!==void 0&&_h(e)))return(r,o)=>{let i=t.get(r);return i===void 0?o:S8(n,o,i)}}function Hh(e,t){let n=GP(e);return n===void 0?t:{...t,childFrame:n}}function BO(e,t,n,r=()=>!1){let{poses:o,composition:i}=e,s=new Set([t]),a=new Map,l=u=>{for(let c of e.childrenOf(u)){if(r(c))continue;s.add(c);let d=o.getParent(c),f=Xn(o,d);if(f===null||!s.has(f)){let p=n(jt(o,c,i.compose),c);p!==null&&a.set(c,ma(o,p,d,i.compose,i.decompose))}l(c)}};return l(t),a}function HO(e,t,n="animator: `axes`"){let{count:r,names:o}=e,i=[];for(let s of t){if(typeof s=="number"){if(!Number.isInteger(s)||s<0||s>=r)throw new Error(`${n} names axis ${s} of a target with ${r}`);i.push(s);continue}if(!o)throw new Error(`${n} names "${s}" on a target whose axes have no names`);let a=i.length,l=`${s}.`;for(let u=0;u<o.length;u++)(o[u]===s||o[u].startsWith(l))&&i.push(u);if(i.length===a){let u=o.slice(0,8).map(c=>`"${c}"`).join(", ");throw new Error(`${n} names "${s}", and the target's axes are ${u}${o.length>8?", \u2026":""}`)}}return i}function k8(e){let[t,n,r,o]=e;switch(e.length){case 1:return{add:(i,s)=>({[t]:i[t]+s[0]}),write:(i,s,a)=>{s[a]=i[t]}};case 2:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n]}};case 3:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1],[r]:i[r]+s[2]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n],s[a+2]=i[r]}};case 4:return{add:(i,s)=>({[t]:i[t]+s[0],[n]:i[n]+s[1],[r]:i[r]+s[2],[o]:i[o]+s[3]}),write:(i,s,a)=>{s[a]=i[t],s[a+1]=i[n],s[a+2]=i[r],s[a+3]=i[o]}};default:return null}}function hc(e){if(typeof e=="number")return{count:1,shape:"number",to:n=>[n],from:(n,r=0)=>n[r],add:(n,r)=>n+r[0],write:(n,r,o)=>{r[o]=n}};if(Array.isArray(e))return e.every(n=>typeof n=="number")?{count:e.length,shape:`array:${e.length}`,to:n=>n.slice(),from:(n,r=0)=>{let o=new Array(e.length);for(let i=0;i<o.length;i++)o[i]=n[r+i];return o},add:(n,r)=>{let o=new Array(e.length);for(let i=0;i<o.length;i++)o[i]=n[i]+r[i];return o},write:(n,r,o)=>{for(let i=0;i<e.length;i++)r[o+i]=n[i]}}:null;if(!tn(e))return null;let t=Object.keys(e).sort();return t.length===0||!t.every(n=>typeof e[n]=="number")?null:{count:t.length,shape:`object:${JSON.stringify(t)}`,names:t,to:n=>t.map(r=>n[r]),from:(n,r=0)=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[r+i];return o},...k8(t)??{add:(n,r)=>{let o={};for(let i=0;i<t.length;i++)o[t[i]]=n[t[i]]+r[i];return o},write:(n,r,o)=>{for(let i=0;i<t.length;i++)r[o+i]=n[t[i]]}}}}var v8=new WeakMap,UP=new Float64Array(16),GO=(e,t,n)=>1-e*(1-(1-t)*n);function A8(e,t,n,r,o){let i=e.axes.count,{behind:s}=e;for(let a=0;a<s.length;a++){let l=s[a],{slot:u,adjust:c,kept:d,share:f}=l;if(u)for(let p=0;p<i;p++){let h=u.cols[u.at+p]+(c?c[p]:0);t[n+p]=t[n+p]+(r||d?h*GO(f[p],r?r[o+p]:0,d?d[p]:1):h)}else if(r||d){let p=l.own();for(let h=0;h<i;h++)t[n+h]=t[n+h]-p[h]*(1-GO(f[h],r?r[o+h]:0,d?d[h]:1))}}}function WP(e,t,n){let r=e.axes.count,{slot:o,adjust:i,beside:s}=e;for(let l=0;l<r;l++)t[n+l]=t[n+l]+(o?o.cols[o.at+l]:0)+i[l]+(s?s[l]:0);let a=e.holds;e.behind.length>0&&(e.row||a||e.dimmed)&&A8(e,t,n,a?a.store.cover:null,a?a.row*r:0)}function UO(e,t){let n=e.axes.to(t),r=e.holds;if(!r)return n;let o=r.row*n.length,{store:i}=r;for(let s=0;s<n.length;s++)if(n[s]!==i.at[o+s]){i.refold(r.row);break}for(let s=0;s<n.length;s++)n[s]=n[s]+i.delta[o+s];return n}function R8(e){let t=e.get();if(e.live===0)return t;let{axes:n}=e;if(!n.add||e.holds||e.dimmed){let i=UO(e,t);return WP(e,i,0),n.from(i)}let r=n.count;UP.length<r&&(UP=new Float64Array(r));let o=UP;return o.fill(0,0,r),WP(e,o,0),n.add(t,o)}function N8(e,t,n){let r=e.get(),{axes:o}=e,i=e.live>0;if(o.write&&!(i&&e.holds))o.write(r,t,n);else{let s=i?UO(e,r):o.to(r);for(let a=0;a<s.length;a++)t[n+a]=s[a]}i&&WP(e,t,n)}function VP(e){let t=e.axes??hc(e.get());if(!t)throw new Error("createTarget: `axes` is required for a value that is not a number, an array of numbers, or an object of numeric fields");let n={get:e.get,set:e.set,show:e.show,publish:e.publish,axes:t,write:null,owner:null,discard:!1,held:0,holds:null,behind:[],dimmed:!1,beside:null,parts:new Set,row:null,live:0,slot:null,adjust:new Array(t.count).fill(0),stale:!1},r={read:()=>R8(n),readInto:(o,i=0)=>N8(n,o,i),axisCount:t.count,axes:t,axisIndexes:o=>HO(t,o),committed:e.get,commit:e.set,get active(){return n.live>0},stop(o){let i=n.owner;if(i){n.discard=o?.commit===!1;try{i.stop(n)}finally{n.discard=!1}}}};return v8.set(r,n),r}var Gh="0.16.1";function Uh(e){let t=Symbol.for(`@msb235/blits/${e}`),n=globalThis,r=n[t];return r===void 0&&(r=new WeakMap,n[t]=r),r}var VO={on:Number.MIN_VALUE,off:0},Ft=(e,t,n)=>e+(t-e)*n,I8=Ft,E8=Uh("lerp-into@1");function Wh(e){return E8.get(e)}var M8=(e,t)=>e+t,WO=(e,t)=>e*t,zO=(e,t)=>e*t,KO=(e,t)=>1+(e-1)*t,C8=(e,t)=>e>t?e:t,jO=Uh("numeric@1");function Qn(e){return jO.get(e)}var O8=Uh("width@1");function $O(e){let t=e.rest;return Array.isArray(t)?t.length:O8.get(e)??1}function Fe(e,t,n,r){return e==="sum"?M8(t,WO(n,r)):e==="mul"?zO(t,KO(n,r)):e==="max"?C8(t,WO(n,r)):+n}function YO(e){let t=Qn(e);if(!(t===void 0||t.axes!==1||t.turn!==void 0||e.fold!==void 0)&&typeof e.rest=="number")return t.op==="sum"||t.op==="mul"||t.op==="max"?t.op:void 0}var F8=(e,t)=>t===void 0?e:`${e}[${t[0]}, ${t[1]}]`;function zP(e){let t={kind:F8("mul",e?.bounds),bounds:e?.bounds,rest:1,merge:zO,scale:KO,lerp:I8};return jO.set(t,{op:"mul",axes:1}),t}function Vh(e){return{kind:e?.lerp?void 0:"last",merge:(t,n)=>n,lerp:e?.lerp??((t,n,r)=>r<.5?t:n)}}function Zn(e,t){if(e===0)return[];let n=[.5];for(let r=1;r<e;r++)n.push(.5);for(let r=0;r<e;r++)n[r]=t;return n}function qO(e){let t=e??!1;return t===!0?Number.POSITIVE_INFINITY:t===!1?1:t}var XO=(e,t,n)=>Number.isFinite(n)&&e>=t*n;function Ur(e,t,n){return t>0?XO(e,t,n)?1:e%t/t:0}function er(e,t,n){return t>0?XO(e,t,n)?n-1:Math.floor(e/t):0}function zh(e,t,n,r,o,i,s=Number.POSITIVE_INFINITY){let a=t&&!t.rest&&t.at<r?t.at:r;s<a&&(a=s);let l=a-o;if(i!==null)for(let c=0;c<i.length;c+=2){let d=Math.max(i[c],o),f=Math.min(i[c+1],a);f>d&&(l-=f-d)}let u=l/e;return u>=1?1:n?n(Math.max(0,u)):Math.max(0,u)}function Ta(e,t,n,r,o,i,s=null,a=null){let l=1;if(e>0&&!r&&(l*=zh(e,t,n,o,i,a)),s&&!r){let u=s.from+(o-s.at)/s.over;u<1&&(l*=n?n(Math.max(0,u)):Math.max(0,u))}if(t&&!t.rest){if(r||t.over===0)return 0;let u=1-(o-t.at)/t.over,c=u<0?0:u>1?1:u;l*=n?n(c):c}return l}function Kh(e,t,n,r){return e>=0?n&&e>r?r:e:t?0:Number.NaN}function $t(e,t){return e===t?e!==0||1/e===1/t:Number.isNaN(e)&&Number.isNaN(t)}function Wr(e){return e<0?0:e>1?1:e}function Yt(e,t,n){return Wr(e*(t*n))}function jh(e,t){return!(t>0)&&e.out?.rest!==!0}function Ke(e,t){let n=t-e.anchorNow,r=e.ramp;if(r===null)return e.anchorElapsed+n*e.rate;if(n<=0)return e.anchorElapsed+n*r.from;let o=r.to-r.from;return n<=r.over?e.anchorElapsed+r.from*n+o*n*n/(2*r.over):e.anchorElapsed+r.from*r.over+o*r.over/2+r.to*(n-r.over)}function Cn(e,t){let n=e.anchorElapsed,r=e.ramp;if(r===null)return e.rate>0?e.anchorNow+(t-n)/e.rate:t<=n?e.anchorNow:Number.POSITIVE_INFINITY;if(t<=n)return r.from>0?e.anchorNow+(t-n)/r.from:e.anchorNow;let o=(r.to-r.from)/(2*r.over),i=n+r.from*r.over+o*r.over*r.over,s=r.from>0&&r.to<0?n-r.from*r.from/(4*o):i;if(t<=s){let a=n-t,l=Math.abs(o)<1e-12?-a/r.from:(-r.from+Math.sqrt(Math.max(0,r.from*r.from-4*o*a)))/(2*o);return e.anchorNow+l}return r.to<=0?Number.POSITIVE_INFINITY:e.anchorNow+r.over+(t-i)/r.to}function mc(e,t){let n=e.ramp;return Cn({anchorNow:e.anchorNow,anchorElapsed:-e.anchorElapsed,rate:-e.rate,ramp:n===null?null:{from:-n.from,to:-n.to,over:n.over}},-t)}function JO(e,t){if(!(t>0))return 0;let n=e%t;return(n<0?n+t:n)/t}function Sa(e,t){let n=e.ramp;if(n===null)return e.rate;let r=(t-e.anchorNow)/n.over;return r>=1?n.to:r<=0?n.from:n.from+(n.to-n.from)*r}function KP(e,t){let n=Sa(e,t);e.anchorElapsed=Ke(e,t);let r=e.ramp;if(r!==null){let o=e.anchorNow+r.over-t;e.ramp=o>0?{from:n,to:r.to,over:o}:null}e.anchorNow=t}function ka(e,t,n,r){KP(e,t);let o=Sa(e,t);e.ramp=r>0&&n!==o?{from:o,to:n,over:r}:null,e.rate=n}function Lo(e,t){let n=t.spec.stepMs??e.opts.stepMs;return n!==void 0&&n>0&&!e.reducedNow?n:void 0}var L8=!1,va={u:Number.NaN,ease:void 0,left:0};function Vr(e,t,n){return Math.max(0,e-t)/n}function _o(e,t){return(t!==va.u||e!==va.ease)&&(va.u=t,va.ease=e,va.left=t>=1?0:1-e(t)),va.left}function Do(e,t,n){return n===0?t:t+(e-t)*n}function QO(e,t,n,r,o,i,s,a,l,u){let c=_o(e,n),d=0;if(L8&&n<1){let f=Math.max(0,n-1e-4),p=Math.min(1,n+1e-4);d=(e(p)-e(f))/(p-f)*(1e3/r)}for(let f=0;f<t;f++){let p=o[i+f],h=s[a+f];l[f]=Do(p,h,c),u[f]=-(p-h)*d}return c===0}var ZO=0,eF=1,tF=2;var _8=4,D8=5,ot={y:0,dy:0},St={e:0,e2:0,cos:0,sin:0},B8={form:Number.NaN,k1:Number.NaN,k2:Number.NaN,k3:Number.NaN,t:Number.NaN};function H8(e,t){let n=e[0],r=e[2],o=e[3],i=e[4],s=B8;if(!($t(t,s.t)&&n===s.form&&r===s.k1&&o===s.k2&&i===s.k3))switch(s.form=n,s.k1=r,s.k2=o,s.k3=i,s.t=t,n){case ZO:{let a=e[2],l=e[3],u=e[4];St.e=Math.exp(-a*l*t),St.cos=Math.cos(u*t),St.sin=Math.sin(u*t);return}case eF:{let a=e[3];St.e=Math.exp(-a*t);return}case tF:{St.e=Math.exp(e[2]*t),St.e2=Math.exp(e[3]*t);return}default:St.e=Math.exp(-t/e[2])}}function G8(e,t,n,r){let o=e[0];o===ZO?U8(e,t,n):o===eF?W8(e,t,n,r):o===tF?V8(e,t,n):nF(e,t)}function U8(e,t,n){let r=e[2],o=e[3],i=e[4],s=St.e,a=(n+r*o*t)/i,l=St.cos,u=St.sin,c=s*(t*l+a*u);ot.y=c,ot.dy=-r*o*c+s*i*(a*l-t*u)}function W8(e,t,n,r){let o=e[3],i=St.e,s=n+o*t,a=i*(t+s*r);ot.y=a,ot.dy=i*s-o*a}function V8(e,t,n){let r=e[2],o=e[3],i=(n-o*t)/(r-o),s=t-i,a=St.e,l=St.e2;ot.y=i*a+s*l,ot.dy=i*r*a+s*o*l}function nF(e,t){let n=e[2],r=St.e;ot.y=t*r,ot.dy=-t/n*r}function z8(e,t,n,r,o){let i=e[2],s=t-n,a=t+r*i-n;if(a===0){nF(e,s);return}let l=e[3];if(s*a>0){let h=Math.exp(-l*o),m=r+l*s,y=h*(s+m*o);ot.y=y,ot.dy=h*m-l*y;return}let u=1+s/(r*i),c=u>0?-i*Math.log(u):Number.POSITIVE_INFINITY;if(o<c){let h=St.e;ot.y=s+r*i*(1-h),ot.dy=r*h;return}let d=o-c,f=r*u,p=Math.exp(-l*d);ot.y=p*f*d,ot.dy=p*f*(1-l*d)}function rF(e,t,n,r,o,i,s,a,l,u,c,d,f,p){if(e[0]===_8)return QO(t,n,Vr(d,r,o),o,i,s,u,c,f,p);let h=Math.max(0,d-r)/1e3,m=e[1],y=m>0;H8(e,h);for(let b=0;b<n;b++){let x=u[c+b];e[0]===D8?z8(e,i[s+b],x,a[l+b],h):G8(e,i[s+b]-x,a[l+b],h),f[b]=x+ot.y,p[b]=ot.dy,(Math.abs(ot.y)>m||Math.abs(ot.dy)>m)&&(y=!1)}if(y)for(let b=0;b<n;b++)f[b]=u[c+b],p[b]=0;return y}var oF=1e-4,zr=[0,0];function jP(e,t,n,r){let o=t<oF?n:e,s=(r<oF?e:n)-o;s>Math.PI?s-=2*Math.PI:s<-Math.PI&&(s+=2*Math.PI),zr[0]=o,zr[1]=s}function iF(e,t,n,r,o){let i=e[t+3]??0,s=n[r+3]??0,a=s>0?1/s:0,l=(n[r]??0)*a,u=(n[r+1]??0)*a,c=(n[r+2]??0)*a,d=i>0?1/i:0,f=i>0?(e[t]??0)*d:l,p=i>0?(e[t+1]??0)*d:u,h=i>0?(e[t+2]??0)*d:c,m=s>0?l:f,y=s>0?u:p,b=s>0?c:h,x=Math.sqrt(p*p+h*h),w=Math.sqrt(y*y+b*b);jP(Math.atan2(h,p),x,Math.atan2(b,y),w),o[0]=f,o[1]=x,o[2]=zr[0],o[3]=i,o[4]=m,o[5]=w,o[6]=zr[0]+zr[1],o[7]=s}var Vbe=new Float64Array(8),zbe=new Float64Array(4),Kbe=new Float64Array(4),jbe=new Float64Array(4),$be=new Float64Array(4);function yc(){try{return!0}catch{return!1}}var sF=new WeakSet;function tr(e,t){sF.has(e)||yc()||(sF.add(e),console.warn(`blits: ${t}`))}var Aa=Ft,$8=Array.from({length:256},(e,t)=>{let n=t/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),Y8=$8.map((e,t)=>{let n=(t-.5)/255;return n<=.04045?n/12.92:((n+.055)/1.055)**2.4}),aF=4096,exe=Array.from({length:aF+1},(e,t)=>{let n=0;for(;n<255&&t/aF>=Y8[n+1];)n++;return n});var $h=256,txe=new Int32Array($h).fill(-1),nxe=new Float64Array($h),rxe=new Float64Array($h),oxe=new Float64Array($h);var cF=new Float64Array(8);function q8(e,t,n){let r=cF;iF(e,0,t,0,r);let o=Aa(r[3],r[7],n),i=Aa(r[1],r[5],n),s=r[2]+zr[1]*n;return[Aa(r[0],r[4],n)*o,i*Math.cos(s)*o,i*Math.sin(s)*o,o]}var X8=1e-9;function lF(e,t,n){let r=e.length>4,o=(r?e[4]:e[3])??0,i=o>0?1/o:0,s=(e[1]??0)*i,a=(e[2]??0)*i,l=Math.sqrt(s*s+a*a);t[n]=(e[0]??0)*i,t[n+1]=r?l<X8?0:(e[3]??0)*i:l,t[n+2]=Math.atan2(a,s),t[n+3]=o}function uF(e,t,n){let r=e[1]??0,o=e[2]??0,i=e.length>4;return n[0]=(e[0]??0)*t,n[1]=r*t,n[2]=o*t,n[3]=(i?e[3]??0:Math.sqrt(r*r+o*o))*t,n[4]=((i?e[4]:e[3])??0)*t,n}function J8(e,t,n){if(n===0)return uF(e,1,Zn(5,0));if(n===1)return uF(t,1,Zn(5,0));let r=cF;lF(e,r,0),lF(t,r,4);let o=r[3]>0?0:4,i=r[7]>0?4:0,s=r[o+1],a=r[i+1];jP(r[o+2],s,r[i+2],a);let l=Aa(r[3],r[7],n),u=Aa(s,a,n)*l,c=zr[0]+zr[1]*n;return[Aa(r[o],r[i],n)*l,Math.cos(c)*u,Math.sin(c)*u,u,l]}function $P(e){let t=e.lerp;return t===q8||t===J8}var ixe=Zn(5,0);var qP=e=>e;function fF(e){return e===void 0||e===qP}function gc(e,t,n,r){let o=3*e,i=3*(n-e)-o,s=1-o-i,a=3*t,l=3*(r-t)-a,u=1-a-l,c=p=>((s*p+i)*p+o)*p,d=p=>(3*s*p+2*i)*p+o,f=p=>((u*p+l)*p+a)*p;return p=>{if(p<=0)return 0;if(p>=1)return 1;let h=p;for(let b=0;b<8;b++){let x=c(h)-p;if(Math.abs(x)<1e-7)return f(h);let w=d(h);if(Math.abs(w)<1e-6)break;h-=x/w}let m=0,y=1;for(h=p;y-m>1e-7;)c(h)<p?m=h:y=h,h=(m+y)/2;return f(h)}}var Q8={linear:qP,ease:gc(.25,.1,.25,1),"ease-in":gc(.42,0,1,1),"ease-out":gc(0,0,.58,1),"ease-in-out":gc(.42,0,.58,1)},dF=new WeakMap,YP=new WeakMap([[qP,1]]);function Z8(e,t,n,r){return e>0?t/e:t>0?Number.POSITIVE_INFINITY:n>0?r/n:r>0?Number.POSITIVE_INFINITY:1}function pF(e){let t=YP.get(e);if(t!==void 0)return t;let n=1e-6,r=e(n);return r>.001?Number.POSITIVE_INFINITY:r/n}function Bo(e){if(typeof e=="function")return e;if(typeof e=="string"){let r=Q8[e];if(!r)throw new Error(`blits: no easing named ${e}`);return r}let t=dF.get(e);if(t)return t;let n;if("bezier"in e)n=gc(...e.bezier),YP.set(n,Z8(...e.bezier));else{let r=e.steps,o=e.jump==="start";n=i=>{let s=i<=0?0:i>=1?1:i;return(o?Math.min(r,Math.floor(s*r)+1):Math.floor(s*r))/r},YP.set(n,o?Number.POSITIVE_INFINITY:0)}return dF.set(e,n),n}function hF(e,t){return e==="queue"?1:e==="together"?0:t}function eY(e,t){return{rate:t.map(()=>1),skip:t.map(()=>!1),share:hF(e.order,e.share),allow:0}}function JP(e,t,n){let r=hF(e.order,e.share),o=[],i=0,s=0,a=0;return t.forEach((l,u)=>{let c=n.skip[u]?0:l.natural/n.rate[u],d=l.state==="playing"?0:Math.max(u===0?Number.NEGATIVE_INFINITY:s+(l.overlap?Math.min(n.share,r):r)*a,l.floor??0);o.push(d),i=Math.max(i,d+c),s=d,a=c}),{at:o,length:i}}var nr=(e,t,n)=>JP(e,t,n).length<=e.left+n.allow+1e-9;function XP(e,t,n){if(n(e))return e;if(!n(t))return t;if(t===Number.POSITIVE_INFINITY)for(t=Math.max(e,1)*2;!n(t);)e=t,t*=2;for(let r=0;r<60;r++){let o=(e+t)/2;n(o)?t=o:e=o}return t}function tY(e,t,n){if(!nr(e,t,n)){let s=Math.max(1,...t.map(l=>l.faster)),a=l=>({...n,rate:t.map((u,c)=>Math.max(n.rate[c],Math.min(l,u.faster)))});return a(XP(1,s,l=>nr(e,t,a(l))))}if(!Number.isFinite(e.left))return n;let r=Math.max(1,...t.map(s=>s.slower));if(r===1)return n;let o=s=>({...n,rate:t.map((a,l)=>n.rate[l]/Math.min(s,a.slower))}),i=XP(1,r,s=>!nr(e,t,o(s)));return nr(e,t,o(i))?o(i):o(Math.max(1,i-1e-9))}function nY(){return(e,t,n)=>{if(nr(e,t,n)||!t.some(i=>i.overlap))return n;let r=i=>({...n,share:i}),o=XP(0,n.share,i=>nr(e,t,r(n.share-i)));return r(n.share-o)}}function rY(){return(e,t,n)=>{let r=n;for(let o=t.length-1;o>=0&&!nr(e,t,r);o--){if(!t[o].ballast||r.skip[o])continue;let i=r.skip.slice();i[o]=!0,r={...r,skip:i}}return r}}function oY(...e){return(t,n,r)=>{let o=r;for(let i of e){if(nr(t,n,o))break;o=i(t,n,o)}return o}}var mF=oY(nY(),rY()),Yh={weak:0,strong:1,required:2};function yF(e,t,n,r){let o=n(e,t,tY(e,t,eY(e,t)));return nr(e,t,o)||Yh[e.priority]===0||r==="overrun"?{plan:o,fell:!nr(e,t,o)&&Yh[e.priority]>0}:(o={...o,skip:t.map((i,s)=>o.skip[s]||Yh[i.priority]<Yh[e.priority])},{plan:o,fell:!0})}var Ho=e=>!Number.isNaN(e.restedAt);function On(e,t,n){return{reaches:t,delay:0,since:0,shown:0,weight:0,restedAt:Number.NaN,bands:null,state:n,stepped:-0,ticks:0,probed:Number.NaN,delta:null,phase:0,seeks:0,rebuilt:0,copied:!1,base:void 0,slope:void 0,kept:null,unkept:void 0,snaps:void 0,from:void 0,unknown:void 0,inputs:void 0,replay:void 0,voice:e,next:null,version:Number.NaN,roles:null,slot:-1,run:-1,freed:-1,restored:null}}function iY(){return On(null,!1,void 0)}function gF(e){let t=this.chains.get(e);return t!==void 0&&t.version===this.version?t:this.relink(e,t)}function bF(e,t){let n=this.lanes,r=t!==void 0?t.slot:n!==null?n.number(e):-1;t===void 0&&r>=0&&this.places?.number(e,r);let o=t!==void 0&&r>=0&&n?.renew(r)===!0,i=t===void 0||o?void 0:this.steps.patch(t.voice===null?null:t,t.version,this,e,r);i===void 0&&(i=sY(this,e,r,t??null));let s=i??iY();return s.version=this.version,t!==void 0&&t!==s&&(o||(s.roles=t.roles),t.roles=null,t.slot=-1),s.slot=r,t!==s&&this.chains.set(e,s),s}function ut(e,t){let n=e.chains.get(t);return n!==void 0&&n.slot>=0&&e.lanes?.sought(n.slot)===!0?void 0:n}function sY(e,t,n,r){let o=null,i=r,s=null,a=e.naming===0?void 0:e.named.get(t),l=0,u=e.general;for(let c=0;c<=u.length;c++){let d=c<u.length?u[c]:null;for(;;){let f=a!==void 0&&l<a.length?a[l]:null,p=f!==null&&(d===null||f.id<d.id)?f:d;if(p===null)break;p===f&&l++;let h=i!==null&&i.voice===p?i:null;h!==null&&(i=h.next);let m=e.linkable(p,t,n,h);if(m!==null&&(m.voice=p,m.next=null,s===null?o=m:s.next=m,s=m),p===d)break}}return o}function xF(e,t,n,r=null){let o=e.state;if(o==="done"||o==="pending"&&!e.freezesBefore)return null;if(e.sharing&&this.share.everyoneOf(this,e)!==null)return n>=0&&this.share.sight(e,n,this.lanes.cap),null;let i=this.held(e,t,n,r);return i.reaches?i:null}function wF(e,t){return PF(e,t,this.now)}function PF(e,t,n,r=Number.POSITIVE_INFINITY){let o=e.parted?.get(t);return o!==void 0&&!(n<o.at)&&o.seq<=r?!1:e.named!==null?e.named.has(t):e.spec.target?e.spec.target(t):!0}function qh(e,t,n,r,o){return n!==void 0&&!n.reaches&&PF(e,t,r,o)?void 0:n}function Kr(e,t){if(t.holding!==null){e.lanes?.refill();return}if(e.lanes?.touch(t),t.named===null){e.steps.push(t,++e.version);return}for(let n of t.named.list){let r=ut(e,n);r!==void 0&&bc(e,r)}e.relinks++}function bc(e,t){t.version=Number.NaN;let n=++e.relinks;t.slot>=0&&e.lanes!==null&&(e.lanes.unlinked[t.slot]=n)}function QP(e,t){if(t.holding===null){if(t.named===null){if(e.general.push(t),t.sharing){let n=e.sharers,r=n.length;for(;r>0&&n[r-1].id>t.id;)r--;n.splice(r,0,t)}return}e.naming++;for(let n of t.named.list){let r=e.named.get(n);r===void 0?e.named.set(n,[t]):r.push(t)}}}function TF(e,t){e.naming--;for(let n of t.named.list){let r=e.named.get(n);if(r===void 0)continue;let o=r.indexOf(t);o>=0&&r.splice(o,1),r.length===0&&e.named.delete(n)}}var Xh=class{size=0;every=[];everyTokens=[];spare=[];spareTokens=[];everySorted=!0;at=new Float64Array(64);tokens=new Float64Array(64);voices=[];limit=64;push(t,n,r){if(t===Number.NEGATIVE_INFINITY){this.every.length>=this.limit&&this.pruneEvery(),this.every.push(n),this.everyTokens.push(r);return}this.size>=this.limit&&this.prune(),this.size===this.at.length&&this.grow();let o=this.at,i=this.size++;for(;i>0;){let s=i-1>>1;if(o[s]<=t)break;this.move(s,i),i=s}o[i]=t,this.tokens[i]=r,this.voices[i]=n}first(){return this.every.length>0?Number.NEGATIVE_INFINITY:this.size>0?this.at[0]:Number.POSITIVE_INFINITY}takeEvery(){let t=this.every,n=this.everyTokens,r=0,o=!0,i=Number.NEGATIVE_INFINITY;for(let s=0;s<t.length;s++){let a=t[s];n[s]!==a.dueToken||a.state==="done"||(a.dueToken++,a.id<i&&(o=!1),i=a.id,t[r++]=a)}return t.length=r,n.length=0,this.spare.length=0,this.every=this.spare,this.everyTokens=this.spareTokens,this.spare=t,this.spareTokens=n,this.everySorted=o,t}pop(){let t=this.voices[0],n=this.tokens[0],r=--this.size;return r>0&&this.sink(0,this.at[r],this.tokens[r],this.voices[r]),this.voices[r]=void 0,n===t.dueToken&&t.state!=="done"?t:void 0}clear(){this.size=0,this.every.length=0,this.everyTokens.length=0,this.spare.length=0,this.spareTokens.length=0,this.voices=[],this.limit=64}move(t,n){this.at[n]=this.at[t],this.tokens[n]=this.tokens[t],this.voices[n]=this.voices[t]}sink(t,n,r,o){let i=this.at,s=this.size;for(;;){let a=2*t+1,l=a+1,u=t,c=n;if(a<s&&i[a]<c&&(u=a,c=i[a]),l<s&&i[l]<c&&(u=l),u===t)break;this.move(u,t),t=u}i[t]=n,this.tokens[t]=r,this.voices[t]=o}grow(){let t=new Float64Array(this.at.length*2);t.set(this.at),this.at=t;let n=new Float64Array(this.tokens.length*2);n.set(this.tokens),this.tokens=n}pruneEvery(){let t=this.every,n=this.everyTokens,r=0;for(let o=0;o<t.length;o++){let i=t[o];n[o]===i.dueToken&&(t[r]=i,n[r++]=n[o])}t.length=r,n.length=r,this.limit=Math.max(this.limit,2*r)}prune(){let t=0;for(let n=0;n<this.size;n++){let r=this.voices[n];this.tokens[n]===r.dueToken&&(t!==n&&this.move(n,t),t++)}for(let n=t;n<this.size;n++)this.voices[n]=void 0;this.size=t;for(let n=(t>>1)-1;n>=0;n--)this.sink(n,this.at[n],this.tokens[n],this.voices[n]);this.limit=Math.max(64,2*t)}};function aY(e,t){if(t.state==="done")return Number.POSITIVE_INFINITY;if(Number.isNaN(t.opened)||t.owner!==null||t.holding!==null)return Number.NEGATIVE_INFINITY;let n=Number.POSITIVE_INFINITY;if(t.parts!==null)for(let o of t.parts.values())n=Math.min(n,o.at+o.over);let r=t.back;if(r!==null&&(n=Math.min(n,r.at+(1-r.from)*r.over)),t.state==="pending")return Math.min(n,Number.isNaN(t.start)?n:t.start);if(t.turns)return Number.NEGATIVE_INFINITY;if(t.state==="fading"){let o=t.out;return o===null||o.rest?Number.NEGATIVE_INFINITY:Math.min(n,o.at+o.over)}if(n=Math.min(n,t.outAt),t.state==="frozen"){let o=Number.isNaN(e.now)?Number.NaN:t.elapsedAt(e.now),i=t.ramp;if((i===null?t.rate<=0:i.from<=0&&i.to<=0)&&!t.beginless&&o<=t.soonest)return n;if(t.rate<=0||i!==null||o<t.span+t.latest)return Number.NEGATIVE_INFINITY}return t.state==="live"&&(n=Math.min(n,t.endsAt())),n}function it(e,t){if(e.projecting)return;e.lanes?.voiceChanged(t);let n=++t.dueToken,r=aY(e,t);r!==Number.POSITIVE_INFINITY&&e.due.push(Number.isNaN(r)?Number.NEGATIVE_INFINITY:r,t,n)}function SF(e,t){let n=e.due,r=n.takeEvery(),o=n.everySorted,i=r.length;for(;n.first()<=t;){let s=n.pop();s!==void 0&&(s.dueToken++,r.push(s))}return i===0||!o?ji(r):i===r.length?r:lY(r,i)}function lY(e,t){let n=ji(e.slice(t)),r=[],o=0,i=0;for(;o<t&&i<n.length;){let s=e[o],a=n[i];a.id<s.id?(r.push(a),i++):(r.push(s),o++)}for(;o<t;)r.push(e[o++]);for(;i<n.length;)r.push(n[i++]);return r}var uY=8;function ji(e){if(e.length>uY)return e.sort((t,n)=>t.id-n.id);for(let t=1;t<e.length;t++){let n=e[t],r=t;for(;r>0&&e[r-1].id>n.id;r--)e[r]=e[r-1];e[r]=n}return e}var cn=Symbol("slow");function bt(e){let t=ZP(e,2);for(let n=0;n<Jh;n++)eT[n]=void 0;return Jh=0,t===cn?structuredClone(e):t}var eT=[],Jh=0;function cY(e){for(let t=0;t<Jh;t++)if(eT[t]===e)return!0;return!1}function ZP(e,t){if(typeof e=="symbol"||typeof e=="function")return cn;if(typeof e!="object"||e===null)return e;if(t===0||cY(e))return cn;if(eT[Jh++]=e,Array.isArray(e)){if(Object.getPrototypeOf(e)!==Array.prototype)return cn;let o=[];for(let s=0;s<e.length;s++){if(!(s in e))return cn;let a=ZP(e[s],t-1);if(a===cn)return cn;o.push(a)}let i=0;for(let s in e)if(++i>e.length)return cn;return o}let n=Object.getPrototypeOf(e);if(n!==Object.prototype&&n!==null)return cn;let r={};for(let o in e){if(o==="__proto__")return cn;let i=ZP(e[o],t-1);if(i===cn)return cn;r[o]=i}return r}function Ra(e){return typeof e!="object"||e===null?e:Array.isArray(e)?[...e]:ArrayBuffer.isView(e)?e.slice():vF(e)?bt(e):e}function $i(e){return Array.isArray(e)?[...e]:e}function kF(e){return Array.isArray(e)||ArrayBuffer.isView(e)||vF(e)}function vF(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function qt(e,t,n=!1){return t<e.seq||t===e.seq&&(!e.strict||n)}var AF=new WeakMap,tT=new Map,me=class{weak=AF;strong=tT;oneKey=Na;oneValue=void 0;get(t){return typeof t=="object"&&t!==null?this.weak.get(t):nT(this.oneKey,t)?this.oneValue:this.strong.get(t)}set(t,n){if(typeof t=="object"&&t!==null){this.weak===AF&&(this.weak=new WeakMap),this.weak.set(t,n);return}if(this.strong===tT&&(this.oneKey===Na||nT(this.oneKey,t))){this.oneKey=t,this.oneValue=n;return}this.strong===tT&&(this.strong=new Map),this.oneKey!==Na&&(this.strong.set(this.oneKey,this.oneValue),this.oneKey=Na,this.oneValue=void 0),this.strong.set(t,n)}find(t,n){return this.get(t)}has(t){return this.get(t)!==void 0}delete(t){typeof t=="object"&&t!==null?this.weak.delete(t):nT(this.oneKey,t)?(this.oneKey=Na,this.oneValue=void 0):this.strong.delete(t)}clear(){this.oneKey=Na,this.oneValue=void 0,this.strong.clear()}},xc=class extends me{under;hidden=new me;constructor(t){super(),this.under=t}get(t){return super.get(t)??(this.hidden.get(t)?void 0:this.under.get(t))}delete(t){super.delete(t),this.hidden.set(t,!0)}},Na=Symbol("none"),nT=(e,t)=>e===t||Object.is(e,t),Qh=class extends me{make;gone=null;constructor(t){super(),this.make=t}get(t){let n=super.get(t);return n===void 0&&this.gone?.get(t)!==!0&&(n=this.make(t),n!==void 0&&super.set(t,n)),n}delete(t){super.delete(t),this.gone??=new me,this.gone.set(t,!0)}};var Fn=class e{list=[];head=0;by=new me;static from(t){if(t.length===0)return null;let n=new e;for(let r of t)n.push(r);return n}push(t){this.list.push(t);let n=this.by.get(t.subject);n===void 0?this.by.set(t.subject,[t]):n.push(t)}expire(t,n){let r=this.list,o=this.head;for(;o<r.length&&!(r[o].at>=t);){let i=r[o++];n!==null&&n(i);let s=this.by.get(i.subject);s.length===1?this.by.delete(i.subject):s.shift()}this.head=o,o>=32&&o*2>=r.length&&(this.list=r.slice(o),this.head=0)}at(t,n){let r=this.by.get(t);if(r!==void 0){for(let o of r)if(!qt(n,o.seq,o.sync))return!o.held.reaches&&o.parted!==null&&o.parted.seq>n.seq?void 0:o.held}}after(t){let n=[],r=new Set;for(let o of this.all())!qt(t,o.seq,o.sync)&&!r.has(o.subject)&&(r.add(o.subject),n.push(o));return n}of(t){return this.by.get(t)??[]}all(){return this.head===0?this.list:this.list.slice(this.head)}};function Yi(e,t){let n=e.patch,r=[...t.kept?.values()??[],...t.unkept??[]],o={reaches:t.reaches,delay:t.delay,since:t.since,shown:t.shown,weight:t.weight,rested:Ho(t),restedAt:t.restedAt,bands:t.bands===null?null:Array.from(t.bands),state:t.state===void 0?void 0:n.pack?n.pack(t.state):bt(t.state),stepped:t.stepped,ticks:t.ticks,rebuilt:t.rebuilt,kept:r.length===0?null:r.map(bt)};return t.copied&&(o.copied=!0),t.base!==void 0&&(o.base=bt(t.base)),t.slope!==void 0&&(o.slope=bt(t.slope)),t.snaps!==void 0&&(o.snaps=t.snaps.map(i=>[i.at,i.seq,Yi(e,i.held)])),t.inputs!==void 0&&(o.inputs=t.inputs.map(i=>({...i}))),o}function qi(e,t){let n=e.patch,r=t.bands===null?null:Uint8Array.from(t.bands),o=On(e,t.reaches,t.state===void 0?void 0:n.unpack?n.unpack(t.state):t.state);return o.delay=t.delay,o.since=t.since,o.shown=t.shown,o.weight=t.weight,o.restedAt=t.restedAt,o.bands=r,o.stepped=t.stepped,o.ticks=t.ticks,o.rebuilt=t.rebuilt,o.copied=t.copied===!0,t.kept!==null&&(o.unkept=t.kept),t.base!==void 0&&(o.base=t.base),t.slope!==void 0&&(o.slope=t.slope),t.snaps!==void 0&&(o.snaps=t.snaps.map(([i,s,a])=>({at:i,seq:s,held:qi(e,a)}))),t.inputs!==void 0&&(o.inputs=t.inputs),o}var wc=class extends Error{mix;stream;at;constructor(t,n,r){super(`blits: ${r} reaches past memory into ${n} records of ${t===""?"the mix":t} that were not loaded; await prepare(${r}) first`),this.mix=t,this.stream=n,this.at=r,this.name="HistoryMiss"}},Zh=class{store;loaded=null;last=null;constructor(t){this.store=t}},em=class{of;refs=new Map;gone=new FinalizationRegistry(t=>{let n=this.refs.get(t);n!==void 0&&n.deref()===void 0&&this.refs.delete(t)});constructor(t){this.of=t}key(t){if(t===void 0||typeof t=="string"||typeof t=="number")return t;let n=this.of;if(n===void 0||typeof t!="object"||t===null)throw new Error("blits: a mix whose history has a store pages its subjects by key; give it keyOf for subjects that are not strings or numbers");let r=n(t);return this.refs.get(r)?.deref()!==t&&(this.refs.set(r,new WeakRef(t)),this.gone.register(t,r)),r}subject(t){if(t!==void 0)return this.refs.get(t)?.deref()??t}};function rr(e,t,n,r,o,i,s){if(e.transport.pager===null||o.length===0)return;let l=e.name??"",u=[];for(let c=0;c<o.length;c++){let d=o[c];if(c+1<o.length&&o[c+1].seq===d.seq)continue;let f={mix:l,stream:t,at:d.at,seq:d.seq,data:i(d)};n!==void 0&&(f.voice=n),r!==void 0&&(f.subject=r),u.push(f)}RF(e.transport,u,s)}function RF(e,t,n){let r=e.pager;r.store.page(t);let o=r.loaded;o!==null&&(e.now-o.now>(e.history?.ms??0)?r.loaded=null:o.records.push(...t));let i=t[t.length-1];r.last={mix:i.mix,stream:i.stream},n>e.floor&&(e.floor=n)}function NF(e){let t=e.history;if(t===void 0||e.pager===null)return;let n=e.now-t.ms,r=[];e.frames.shed(n,s=>r.push({mix:"",stream:"frame",at:s.at,seq:s.seq,data:s.u}));let o=e.pace,i=s=>o===null?s:o.reading(s);if(e.announced.some(s=>i(s.at)<n)){let s=[];for(let a of e.announced)i(a.at)<n?r.push({mix:"",stream:"mark",subject:a.order,at:i(a.at),seq:a.seq,data:a}):s.push(a);e.announced=s}if(o!==null)for(let s of o.shed(n))r.push({mix:"",stream:"pace",at:s.anchorElapsed,seq:s.seq,data:s});r.length>0&&RF(e,r,n)}async function IF(e,t){let n=e.pager;if(n===null||e.reaches(t))return;let r=await n.store.load(t);n.loaded={t,now:e.now,records:[...r]}}var tm=class{cued=null;by=new Map;gone=null;goneBy=new Map;versions=new Map;held=new Set};function nm(e,t){let n=e.scored.held;if(n.has(t)||e.dropped)return;n.add(t);let r=e.transport.holders,o=e,i=r.get(t);if(i===void 0){r.set(t,[o]);return}let s=i.findIndex(a=>a.slot>o.slot);s<0?i.push(o):i.splice(s,0,o)}function EF(e,t){return e.transport.holders.get(t)??DF}function rT(e,t){e.scored.held.delete(t);let n=e.transport.holders,r=n.get(t);if(r===void 0)return;let o=r.indexOf(e);o>=0&&r.splice(o,1),r.length===0&&n.delete(t)}function MF(e){for(let t of e.cued)t.spec.score!==void 0&&nm(e,t.spec.score);for(let t of e.gone)t.spec.score!==void 0&&nm(e,t.spec.score)}function CF(e){for(let t of[...e.scored.held])rT(e,t)}function Ia(e,t,n=!1){let r=t.spec.score;if(r===void 0)return;let o=e.scored;if(o.versions.set(r,(o.versions.get(r)??0)+1),!n||t.state!=="done")return;let i=o.goneBy.get(r);i!==void 0&&o.goneBy.set(r,[...i])}function OF(e,t){return e.scored.versions.get(t)??0}function FF(e,t){let n=t.spec.score;if(n===void 0)return;let r=e.get(n);r===void 0?e.set(n,new Set([t])):r.add(t)}function LF(e,t){let n=e.scored;if(n.cued!==e.cued){n.by=new Map;for(let r of e.cued)FF(n.by,r);n.cued=e.cued}return n.by.get(t)??dY}var dY=new Set;function _F(e,t){let n=e.scored;if(n.gone!==e.gone){n.goneBy=new Map;for(let r of e.gone)BF(n.goneBy,r);n.gone=e.gone}return n.goneBy.get(t)??DF}var DF=[];function BF(e,t){let n=t.spec.score;if(n===void 0)return;let r=e.get(n);r===void 0?e.set(n,[t]):r.push(t)}function rm(e,t){t.spec.score!==void 0&&nm(e,t.spec.score);let n=e.scored;n.gone===e.gone&&BF(n.goneBy,t)}function oT(e,t,n){let r=e.scored;if(r.gone!==t)return;r.gone=e.gone;let o=new Map;for(let i of n){let s=i.spec.score;if(s===void 0)continue;let a=o.get(s);a===void 0?o.set(s,new Set([i])):a.add(i)}for(let[i,s]of o){let a=(r.goneBy.get(i)??[]).filter(l=>!s.has(l));a.length===0?r.goneBy.delete(i):r.goneBy.set(i,a)}}function HF(e,t){Ia(e,t),t.spec.score!==void 0&&nm(e,t.spec.score);let n=e.scored;n.cued===e.cued&&FF(n.by,t)}function GF(e,t){for(let r of t)Ia(e,r);let n=e.scored;if(n.cued===e.cued)for(let r of t){let o=r.spec.score;if(o===void 0)continue;let i=n.by.get(o);i!==void 0&&(i.delete(r),i.size===0&&n.by.delete(o))}}var or=Symbol("absent"),UF=Symbol("unit"),om=class{owner;next=0;free=null;refs=[void 0];registry=null;lone=null;loneSlot=-1;constructor(t){this.owner=t}adopt(t){this.owner=t}get size(){return this.next}take(t){let n=this.free?.pop()??this.next++,r=-1;if(typeof t=="object"&&t!==null){let o=new WeakRef(t);if(this.refs[n]=o,this.registry===null){if(this.lone===null)return this.lone=o,this.loneSlot=n,n;this.registry=new FinalizationRegistry(s=>this.release(s));let i=this.lone.deref();i!==void 0?this.registry.register(i,this.loneSlot,this.lone):r=this.loneSlot,this.lone=null}this.registry.register(t,n,o)}else this.refs[n]=t===void 0?UF:t;return r>=0&&this.release(r),n}has(t){return this.refs[t]!==void 0}subject(t){let n=this.refs[t];if(n===void 0)return or;if(n!==UF){if(n instanceof WeakRef){let r=n.deref();return r===void 0?or:r}return n}}move(t,n){let r=this.refs[t],o=this.free;if(r===void 0||n>=this.next||this.refs[n]!==void 0||o===null)return!1;let i=o.lastIndexOf(n);if(i<0)return!1;if(r instanceof WeakRef){let s=r.deref();if(s===void 0)return!1;r===this.lone?this.loneSlot=n:this.registry!==null&&(this.registry.unregister(r),this.registry.register(s,n,r))}return o.splice(i,1),o.push(t),this.refs[n]=r,this.refs[t]=void 0,!0}release(t){let n=this.refs[t];n!==void 0&&(n===this.lone?this.lone=null:n instanceof WeakRef&&this.registry?.unregister(n),this.refs[t]=void 0,this.owner.forget(t),this.free===null?this.free=[t]:this.free.push(t))}};var pe={live:!0,horizon:Number.POSITIVE_INFINITY,kept:0,moved:0,inputs:0,ahead:null,back:null};var fY=(e,t)=>e.seq===void 0||Number.isNaN(e.seq)||qt(t,e.seq,e.early===!0);function pY(e,t){let n=e[e.length-1];if(t>=n.at||e.length===1)return n;if(e[0].at>t)return e[0];let r=0,o=e.length-2;for(;r<o;){let i=r+o+1>>1;e[i].at<=t?r=i:o=i-1}return e[r]}function im(e,t,n,r){let o=e.runThen(t,r)??e.freshRun(t),i=o.stretches,s=o.pending??[],a=[],l=!1;for(let c of[...i.slice(1).map(d=>d.change),...s])c===void 0||fY(c,r)?c!==void 0&&a.push(c):l=!0;l&&(i=[i[0]],s=a.filter(c=>c.at!==void 0).sort((c,d)=>c.at-d.at));let u=pY(i,n);for(let c of s){let d=c.at;if(d===void 0||!(d<=n))break;d>=u.at&&(u=e.applied(t,u,c,d))}return e.evaluateSegment(u,n,e.xs,e.vs),o.flags}var hY=e=>typeof e=="number"?[e]:[...e];var VF=Symbol.for(`@msb235/blits/motions@${Gh}`),WF=new Map,iT=class{motions;writes;constructor(t,n){this.motions=n;let r=WF.get(t);r===void 0&&(r=Object.freeze([t]),WF.set(t,r)),this.writes=r}form="motion";duration=0;get motion(){return this.motions.spec()}get[VF](){return this.motions}at(t,n,r){let o=this.motions,i=pe.back;if(i!==null){let a=im(o,n,r.elapsed,i);return{[this.writes[0]]:o.valueOf(a,o.xs)}}let s=o.slot(n);return o.sample(s,r.elapsed,o.xs,o.vs),{[this.writes[0]]:o.value(s,o.xs)}}set(t,n,r){this.motions.change(t,{at:r,x:hY(n)})}read(t,n){let r=this.motions,o=r.read(t,n);if(o!==void 0)return{value:r.value(o.s,o.x),velocity:r.value(o.s,o.v)}}};function Ln(e){return e instanceof iT?e.motions:e[VF]}var sm=class{list;set;delays=null;latest=0;soonest=0;constructor(t,n){if(Array.isArray(t)&&mY(t)){this.list=t.slice(),this.set=null,n&&(this.delays=zF(this.list,n)),[this.latest,this.soonest]=KF(this.delays);return}let r=[],o=null;for(let i of t)o!==null?o.has(i)||(o.add(i),r.push(i)):r.includes(i)||(r.push(i),r.length>8&&(o=new Set(r)));this.list=r.slice(),this.set=o,n&&(this.delays=zF(this.list,n)),[this.latest,this.soonest]=KF(this.delays)}get size(){return this.list.length}has(t){return this.set===null?this.list.includes(t):this.set.has(t)}};function zF(e,t){let n=new Map;for(let r of e)n.set(r,t(r));return n}function KF(e){let t=0,n=0;for(let r of e?.values()??[])r>t&&(t=r),r<n&&(n=r);return[t,n]}function mY(e){let t=e.length;if(t>8)return!1;for(let n=1;n<t;n++){let r=e[n];for(let o=0;o<n;o++){let i=e[o];if(r===i||Number.isNaN(r)&&Number.isNaN(i))return!1}}return!0}var yY=256;function Go(e,t,n=!1){let r=e.clocks;if(r!==null&&r.length>=yY)return;let o=e.holding!==null||e.spec.stagger!==void 0?Number.POSITIVE_INFINITY:0;if(r!==null&&jF(r,0)>=o&&jF(r,$F(e))>=o)return;let{anchorNow:i,anchorElapsed:s,rate:a,ramp:l,rebuilds:u}=e,c={anchorNow:i,anchorElapsed:s,rate:a,ramp:l,until:t,rebuilds:u,sought:n};r===null?e.clocks=[c]:r.push(c)}function jF(e,t){let n=Number.NEGATIVE_INFINITY;for(let r=t;r<e.length;r++){let o=e[r],i=Ke(o,o.until);i>n&&(n=i)}return n}function $F(e){let t=e.clocks;if(t===null)return 0;let n=0;for(;n<t.length&&t[n].rebuilds!==e.rebuilds;)n++;return n}function gY(e,t,n){for(let r=t.length-1;r>=0;r--)if(t[r].sought&&(t[r+1]?.anchorElapsed??e.anchorElapsed)<n)return r+1;return 0}function am(e,t,n){let r=e.clocks,o=e.beginless?e.start:Number.NaN;if(r!==null&&Number.isNaN(o)){let i=n?Math.max($F(e),gY(e,r,t)):0;for(let s=i;s<r.length;s++){let a=r[s],l=Cn(a,t);if(l<=a.until){o=l;break}}}return Number.isNaN(o)&&(o=Cn(e,t),o===Number.POSITIVE_INFINITY&&(o=e.start+t)),e.owner===null?o:am(e.owner,o,n)}function Uo(e){return e.owner===null?e.start:am(e.owner,e.start,!1)}var Xi=Object.freeze({form:"fn",duration:0,writes:[],at:()=>({})}),Wo=class{children=[];kids=0;played=0;coasts=[];cutSeq=Number.POSITIVE_INFINITY;get coast(){let t=this.coasts.length;return t===0?Number.NEGATIVE_INFINITY:this.coasts[t-1]}left(t,n){t===void 0?n<this.cutSeq&&(this.cutSeq=n):t>this.coast&&this.coasts.push(n,t)}back(t){let n=this.coasts;for(;n.length>0&&n[n.length-2]>t;)n.length-=2;this.cutSeq>t&&(this.cutSeq=Number.POSITIVE_INFINITY)}};function Te(e,t){let n=e.owner===null?t:Te(e.owner,t);return n>=e.start?Ke(e,n):Number.NEGATIVE_INFINITY}function YF(e,t,n){let r=Te(t,n);return r===Number.NEGATIVE_INFINITY?r:Ke(e,r)}function Vo(e,t){let n=e.backs?mc(e,t):Cn(e,t);return e.owner===null?n:Vo(e.owner,n)}function lm(e){let t=!1;for(let n=e.owner;n!==null;n=n.owner)n.backs&&(t=!t);return t}function qF(e,t){let n=e.holding;n.children.push(t),n.kids++}function XF(e,t){let n=e.owner,r=n.holding,o=r.children.indexOf(e);return o>=0&&r.children.splice(o,1),!jr(n,t)&&n.state!=="done"?n:null}function jr(e,t){for(let n of e.holding.children)if(!n.quietAt(t))return!0;return!1}function JF(e,t,n){let r=e.holding;++r.played===r.kids&&e.play(!0,t,n)}function Ji(e,t){for(let n of e.holding.children)t(n),n.holding!==null&&Ji(n,t)}function QF(e){for(let t=e.owner;t!==null;t=t.owner)if(typeof t.spec.weight=="function")return!0;return!1}function ZF(e){for(let t=e.owner;t!==null;t=t.owner){let n=t.spec.weight;if(typeof n=="function"&&n.input)return!0}return!1}function sT(e,t,n,r){let o=typeof e.spec.weight=="function"?r(e):e.weight,i=Uo(e),s=e.freezesBefore&&e.opened<i?e.opened:i;return Wr(o*Ta(e.fade.in??0,e.out,e.ease,n,t,s,e.back,e.stalls))}function eL(e,t,n,r){let o=1,i=e;for(let s=e.owner;s!==null;i=s,s=s.owner)o*=sT(s,t,n,r),s.arc!==null&&(o*=tL(s,i,t,n));return o}function Ea(e,t){let n=new Map;for(let r of e)if(n.set(r.id,r),r.holding!==null){let o=new Wo;o.kids=r.holding.kids,o.played=r.holding.played,o.coasts=r.holding.coasts.slice(),o.cutSeq=r.holding.cutSeq,t!==void 0&&o.back(t),r.holding=o}for(let r of e){let o=r.owner===null?void 0:n.get(r.owner.id);o!==void 0&&(r.owner=o,o.holding.children.push(r))}}function lT(e,t,n){let r=n.writes??(n.kit?Object.keys(n.kit):void 0);if(r===void 0)throw new Error("blits: a patch needs writes, or a kit to take them from");return{form:"fn",duration:e,writes:r,kit:n.kit,reads:n.reads,at:t,state:n.state,step:n.step,pack:n.pack,unpack:n.unpack}}var bY=(e,t,n)=>e+(t-e)*n;function aT(e,t,n){if(typeof e=="number"&&typeof t=="number")return bY(e,t,n);if(Array.isArray(e)&&Array.isArray(t)){let r=new Array(e.length);for(let o=0;o<e.length;o++)r[o]=aT(e[o],t[o],n);return r}return n<.5?e:t}function xY(e,t,n,r){let o=r.ease===void 0?void 0:Bo(r.ease),i=[];for(let s of t){let a=r.easeBy?.(s),l=a===void 0?o:Bo(a),u=[];for(let p of e){let h=p.delta[s];h!==void 0&&u.push({at:p.at,value:Array.isArray(h)?[...h]:ArrayBuffer.isView(h)?h.slice():h,ease:p.ease===void 0?l:Bo(p.ease)})}u.sort((p,h)=>p.at-h.at);let c=u.filter(p=>p.at!==0),d=r.lerpBy?.(s)??r.kit?.[s]?.lerp,f=u.length>0&&(d===void 0||d===Ft)&&u.every(p=>typeof p.value=="number");i.push({channel:s,all:u,tail:c,ats:u.map(p=>p.at),tailAts:null,delay:r.delayBy?.(s)??0,lerp:d,numbers:f?{ats:Float64Array.from(u,p=>p.at),values:Float64Array.from(u,p=>p.value),eases:u.map(p=>p.ease)}:null})}return{tracks:i,duration:n}}var cm=0,Ma=1,wY=2,He={a:void 0,b:void 0,u:0,eased:0,first:!1,len:0,ease:void 0};function uT(e,t,n){return cT(e.delay,t,n)}function cT(e,t,n){return e===0||n===0?t:e>=n?t>=1?1:0:Math.max(0,(t*n-e)/(n-e))}function dT(e,t,n,r,o){return r===0?-2:o<=e[t]?-1:o>=e[t+(r-1)*n]?r:rL(e,t,n,1,r-1,o)}function rL(e,t,n,r,o,i){for(;r<o;){let s=r+o>>1;e[t+s*n]>=i?o=s:r=s+1}return r}function fT(e,t,n){return(e-t)/(n-t)}function pT(e,t,n){let r,o=n===void 0?0:1,i=o===0?e.all:e.tail;if(o===0){let c=i.length;if(r=dT(e.ats,0,1,c,t),r===-2)return cm;if(r===-1||r===c)return He.a=i[r===-1?0:c-1].value,Ma}else{let c=i.length+1;if(t<=0)return He.a=n,Ma;let d=i[i.length-1];if(d===void 0||t>=d.at)return He.a=d===void 0?n:d.value,Ma;e.tailAts??=i.map(f=>f.at),r=rL(e.tailAts,-1,1,1,c-1,t)}let s=i[r-o],a=r-1<o?0:i[r-1-o].at,l=fT(t,a,s.at),u=s.ease?s.ease(l):l;return He.a=r-1<o?n:i[r-1-o].value,He.b=s.value,He.u=l,He.eased=u,He.first=r-1<o,He.len=s.at-a,He.ease=s.ease,wY}function PY(e,t){let n=e.ats,r=e.values,o=n.length;if(t<=n[0])return r[0];if(t>=n[o-1])return r[o-1];let i=1,s=o-1;for(;i<s;){let f=i+s>>1;n[f]>=t?s=f:i=f+1}let a=n[i-1],l=(t-a)/(n[i]-a),u=e.eases[i],c=u?u(l):l,d=r[i-1];return d+(r[i]-d)*c}function TY(e,t,n,r,o,i,s,a){let l=e.numbers;if(l!==null&&n===void 0&&o===void 0&&(r===void 0||r===Ft||e.lerp!==void 0))return PY(l,t);let u=pT(e,t,n);if(u===cm)return;if(u===Ma)return He.a;let c=He.a,d=He.b,f=He.u,p=He.eased,h=He.first,m=He.len,y=He.ease,b;if(s!==void 0)b=s(a,c,d,p),um.wrote=b;else{let g=e.lerp??r;b=g?g(c,d,p):aT(c,d,p)}if(o===void 0||!h)return b;let x=y?pF(y):1;if(x===Number.POSITIVE_INFINITY)return b;let w=(g,P,S)=>(g*i*m-(S-P)*x)*f*(1-f)*(1-f);if(typeof b=="number"&&typeof o=="number")return b+w(o,c,d);if(Array.isArray(b)&&Array.isArray(o)){let g=b===um.wrote?b:new Array(b.length),P,S=()=>{let v=e.lerp??r,A=N=>s!==void 0?s(void 0,c,d,N):v?v(c,d,N):aT(c,d,N);return P=[A(0),A(1)],P};for(let v=0;v<b.length;v++){let A=b[v],N=o[v];if(typeof A!="number"||typeof N!="number"){g[v]=A;continue}let M=c[v],C=d[v];if(typeof M!="number"||typeof C!="number"){let[F,D]=P??S();M=F?.[v],C=D?.[v]}g[v]=typeof M=="number"&&typeof C=="number"?A+w(N,M,C):A}return g}return b}var um={wrote:void 0};function oL(e,t){return e.tracks.map((n,r)=>{let o=t[r];return n.lerp===void 0||n.lerp===o.lerp?Wh(o):void 0})}function dm(e,t,n,r,o,i,s,a){let l=e.duration;for(let u=0;u<e.tracks.length;u++){let c=e.tracks[u],d=i?.[c.channel],f=a===void 0?void 0:s?.[u];um.wrote=void 0;let p=TY(c,uT(c,t,l),r?.[c.channel],o?.[u],l===0?void 0:d,l,f,f===void 0?void 0:a[u]);f!==void 0&&p===um.wrote&&(a[u]=p),p!==void 0?n[c.channel]=p:n[c.channel]!==void 0&&(n[c.channel]=void 0)}return n}var nL=new WeakMap;function iL(e){let t=nL.get(e);return t===void 0&&(t=xY(e.keys,e.writes,e.duration,e),nL.set(e,t)),t}function hT(e){return function(n,r){let o=e.keepOn,i=o===null?e.ownKept:o.kept;if(i===null&&(i=new Map,o===null?e.ownKept=i:o.kept=i),i.has(n))return i.get(n);let s=o?.unkept,a=s===void 0?r():s.shift();return s?.length===0&&o!==null&&(o.unkept=void 0),i.set(n,a),pe.kept++,a}}var fm=class{host;send;voice;timestamp=0;dt=0;elapsed=0;pass=0;weight=0;state=void 0;mark=0;kept=null;constructor(t,n,r){this.host=t,this.send=n,this.voice=r}get keep(){return this.kept===null&&(this.kept=hT(this.voice)),this.kept}};function Pc(e,t){let n=e.named?.delays?.get(t);return n!==void 0?n:e.spec.stagger?e.spec.stagger(t):0}function Tc(e,t){let n=e.unreachedBits;if(n===null||t<0)return!1;let r=t>>>5;return r<n.length&&(n[r]&1<<(t&31))!==0}function $r(e,t,n){let r=e.unreachedBits,o=t>>>5;if(r===null||o>=r.length){if(!n)return;let s=new Uint32Array(Math.max(o+1,(r?.length??0)*2,2));r!==null&&s.set(r),e.unreachedBits=s,r=s}let i=1<<(t&31);r[o]=n?r[o]|i:r[o]&~i}function mT(e,t,n){Tc(e,t)&&($r(e,n,!0),$r(e,t,!1))}function sL(e,t){let n=this.sinceOf(e,0),r=On(e,!1,void 0);return r.since=n,r.shown=this.shownOf(e,n),r.stepped=t,r.rebuilt=e.rebuilds,e.unreached=r,r}function aL(e,t,n,r=null){if(e.sharing){let d=this.share.everyoneOf(this,e);if(d!==null)return d}if(Tc(e,n))return e.unreached;let o=r===null?e.subjects.get(t):e.subjects.find(t,r);if(o!==void 0)return o;let i=this.now;if(!this.aims(e,t)){let d=e.unreached??this.unreachedOf(e,i);return n>=0&&e.named===null?$r(e,n,!0):e.subjects.set(t,d),d}this.keys!==null&&(e.keyed??=new Set,e.keyed.add(this.keys.key(t)));let a=Pc(e,t),l=this.sinceOf(e,a),u=this.shownOf(e,l);o=On(e,!0,e.patch.state?e.patch.state(t):void 0),o.delay=a,o.since=l,o.shown=u;let c=yT(this,e,o,i);return o.rebuilt=e.rebuilds,this.projecting&&(o.from=o.stepped,o.unknown=this.backward&&e.spec.from==="current"||c),e.subjects.set(t,o),gT(e,o,i),e.sighted!==null&&this.share?.sighted(e,n)?this.share.inherit(e,o,n):e.seen++,a>e.latest&&(e.latest=a,e.state==="frozen"&&it(this,e)),a<e.soonest&&(e.soonest=a,it(this,e)),o}function yT(e,t,n,r){let o=n.since;if(!(o<r))return n.stepped=r,!1;if(t.spec.catchUp!=="fresh"||t.patch.step===void 0)return n.stepped=o,!1;let i=Lo(e,t);return i===void 0?n.stepped=r:(n.ticks=Math.floor((r-o)/i+1e-9),n.stepped=o+n.ticks*i),n.stepped>o}function lL(e,t){let n=e.patch;return am(e,t,n.state!==void 0||n.step!==void 0||e.keeping)}function uL(e,t){let n=Uo(e),r=t<n?n:t;return e.freezesBefore&&e.opened<r?e.opened:r}function cL(e,t,n){return!(t.since<=n)||e.motion!==void 0&&!(t.probed>=t.since)}function gT(e,t,n){if(t.since<=n)return;e.early??=[];let r=e.early;if(r.length>=64&&(r.length&r.length-1)===0){let o=0;for(let i of r)cL(e,i,n)&&(r[o++]=i);r.length=o}r.push(t)}function Ca(e,t,n){t.state="live",t.begunSeq=e.transport.seq,t.anchorElapsed!==0&&(t.seeks++,t.rebuilds++,t.note(n,e.transport.seq,!0)),dn(e,t,n),Kr(e,t)}function Oa(e,t,n){let r=n.since;n.since=e.sinceOf(t,n.delay),n.since!==r&&(n.ticks>0||n.stepped>r)&&(n.rebuilt=-1),n.shown=e.shownOf(t,n.since),n.ticks===0&&n.stepped>n.since&&(n.stepped=n.since)}function dn(e,t,n){let r=t.early;if(r===null)return;let o=0;for(let i of r)Oa(e,t,i),cL(t,i,n)&&(r[o++]=i);r.length=o,o===0&&(t.early=null),e.lanes?.reshown(t.id)}var pm=class{of=null;count=0;general=[];named=new me;latest=Number.NEGATIVE_INFINITY;slack=0};function SY(e,t){let n=t.reachedTo;if(n<e.latest?e.slack=Math.max(e.slack,e.latest-n):e.latest=n,t.named===null){e.general.push(t);return}for(let r of t.named.list){let o=e.named.get(r);o===void 0?e.named.set(r,[t]):o.push(t)}}function dL(e,t){let n=!1;for(let r of t){if(r.named===null){n=!0;continue}for(let o of r.named.list){let i=e.named.get(o);if(i===void 0)continue;let s=i.indexOf(r);s>=0&&i.splice(s,1),i.length===0&&e.named.delete(o)}}if(n){let r=new Set(t);e.general=e.general.filter(o=>!r.has(o))}}function zo(e){let t=e.goneIx,n=e.gone;(t.of!==n||t.count>n.length)&&(t.general=[],t.named=new me,t.count=0,t.of=n,t.latest=Number.NEGATIVE_INFINITY,t.slack=0);for(let r=t.count;r<n.length;r++)SY(t,n[r]);return t.count=n.length,t}function fL(e,t){for(let n of t)e.parters.delete(n),e.departed.add(e,n),n.doneAt>e.transport.forgotTo&&(e.transport.forgotTo=n.doneAt)}function bT(e,t){let n=zo(e),r=e.gone,o=0;for(;o<r.length&&t(r[o]);)o++;if(o===r.length)return;let i=r.slice(0,o),s=[r[o]];for(o++;o<r.length;o++){let a=r[o];(t(a)?i:s).push(a)}dL(n,s),fL(e,s),e.gone=i,oT(e,r,s),n.of=i,n.count=i.length}function pL(e,t){let n=zo(e);if(!Number.isFinite(n.slack)){bT(e,u=>u.reachedTo>=t);return}let r=e.gone,o=t+n.slack,i=0,s=!1;for(let u=Number.NEGATIVE_INFINITY;i<r.length&&u<o;i++){let c=r[i].reachedTo;c<t&&(s=!0),c>u&&(u=c)}if(!s)return;let a=[],l=[];for(let u=0;u<i;u++){let c=r[u];(c.reachedTo<t?l:a).push(c)}r.splice(0,i,...a),dL(n,l),fL(e,l),oT(e,r,l),n.count=r.length}var hL=[];function xT(e,t){return e>=0&&(t>0?e<t:Number.isFinite(e))}function mL(e,t){for(let n of e)if(!xT(n.at,t))throw new RangeError(t>0?`blits: a hit's at is voice ms into a pass, 0 up to ${t}, not ${n.at}`:`blits: a hit's at is voice ms, 0 or more, not ${n.at}`)}var hm=class{host;opts;est=Number.NaN;last=Number.NaN;prev=Number.NaN;round=0;canceled=!1;floor=Number.NEGATIVE_INFINITY;marked=new Map;tracks=new Map;due=[];constructor(t,n){this.host=t,this.opts=n}sync(){if(this.canceled)return;let t=this.host,n=t.timestamp,r=this.opts.clock();if(Number.isNaN(this.est))this.est=r;else{let a=this.est+(n-this.last),l=r-a;this.est=Math.abs(l)>50?r:a+l*.05}this.last=n;let o=Number.isNaN(this.prev)?t.now:this.prev;this.prev=t.now,this.round++,this.marks(n),this.hits(n,o);let i=this.due;i.sort((a,l)=>a.time-l.time);let s=this.opts.late;for(let a of i){let l=a.time<n?n-a.time:0;if(l>s)continue;let u=this.est+(a.time-n),c={time:a.time,at:u,taken:void 0};a.into.set(a.key,c),c.taken=this.opts.take(a.item,l>0?r:Math.max(u,r),l)}i.length=0;for(let a of this.tracks.values())for(let[l,u]of a.booked)u.time<=n&&a.booked.delete(l)}cancel(){if(!this.canceled){this.canceled=!0;for(let t of this.marked.values())t.time>this.last&&t.taken?.cancel();for(let t of this.tracks.values())for(let n of t.booked.values())n.time>this.last&&n.taken?.cancel();this.marked.clear(),this.tracks.clear(),this.host.unhook(this)}}sought(){if(this.canceled)return;let t=this.last;for(let r of this.marked.values())r.time>t&&r.taken?.cancel();for(let r of this.tracks.values())for(let o of r.booked.values())o.time>t&&o.taken?.cancel();this.marked.clear(),this.tracks.clear();let n=this.host;this.floor=n.timestamp,this.prev=n.now;for(let r of n.voices)r.spec.hits!==void 0&&r.state!=="done"&&this.tracks.set(r,{seenTo:r.elapsedAt(n.now),jumps:r.jumps,booked:new Map,met:this.round})}at(t){return this.est+(t-this.last)}stands(t,n){return n===void 0||!Number.isFinite(n)?!1:Math.abs(this.est+(n-this.last)-t.at)<=1}fits(t,n){let{tag:r,score:o}=this.opts;return(o===void 0||t===o)&&(r===void 0||n.includes(r))}marks(t){let n=this.host.marks(t-this.opts.late,t+this.opts.ahead),r=this.marked,o=new Set;for(let i of n){if(!this.fits(i.score,i.tags)||i.timestamp<=this.floor)continue;let s=kY(i);o.add(s);let a=r.get(s);if(a!==void 0){if(a.time<=t||this.stands(a,i.timestamp))continue;a.taken?.cancel(),r.delete(s)}let{order:l,...u}=i;this.due.push({time:i.timestamp,item:u,into:r,key:s})}for(let[i,s]of r)o.has(i)||(s.time>t&&s.taken?.cancel(),r.delete(i))}hits(t,n){let r=this.host,o=this.round,{ahead:i,late:s}=this.opts,a=r.readingAt(t+i),l=Number.isFinite(s)?r.readingAt(t-s):Number.NEGATIVE_INFINITY;for(let u of r.voices){let c=u.spec.hits;if(c===void 0||c.length===0||u.state==="done"||!this.fits(u.spec.score,u.spec.tags??hL))continue;let d=this.tracks.get(u);d===void 0&&(d={seenTo:Number.NEGATIVE_INFINITY,jumps:u.jumps,booked:new Map,met:o},this.tracks.set(u,d)),d.met=o,d.jumps!==u.jumps&&(d.jumps=u.jumps,d.seenTo=u.elapsedAt(n));let f=r.endOf(u),p=c.length,h=!1;for(let[w,g]of d.booked){if(g.time<=t)continue;let P=this.timeOfHit(u,c,Math.floor(w/p),w%p,f);this.stands(g,P)||(g.taken?.cancel(),d.booked.delete(w),h=!0)}h&&(d.seenTo=Math.min(d.seenTo,u.elapsedAt(n)));let m=u.elapsedAt(a);if(!(m>d.seenTo))continue;let y=Math.max(d.seenTo,u.elapsedAt(l));if(!(y<=m)){d.seenTo=m;continue}let b=u.duration,x=b>0?Math.min(u.passes-1,Math.floor(m/b)):0;for(let w=b>0?Math.max(0,Math.floor(y/b)):0;w<=x;w++)for(let g=0;g<p;g++){let P=w*b+c[g].at;if(!(P>d.seenTo&&P<=m))continue;let S=w*p+g;if(d.booked.has(S))continue;let v=this.timeOfHit(u,c,w,g,f);if(v===void 0||!Number.isFinite(v))continue;let A={timestamp:v,voice:u.id,hit:g,pass:w,event:c[g].event,score:u.spec.score,name:u.spec.name,tags:u.spec.tags??hL,subjects:u.named?.list};this.due.push({time:v,item:A,into:d.booked,key:S})}d.seenTo=m}for(let[u,c]of this.tracks)if(c.met!==o){for(let d of c.booked.values())d.time>t&&d.taken?.cancel();this.tracks.delete(u)}}timeOfHit(t,n,r,o,i){if(t.state==="done"||r>=t.passes)return;let s=t.timeAt(r*t.duration+n[o].at);if(!(!Number.isFinite(s)||i!==void 0&&s>=i))return this.host.hostOf(s)}};function kY(e){let t=e.order*6;switch(e.mark){case void 0:return t;case"start":return t+1;case"in":return t+2;case"coast":return t+3;case"out":return t+4;case"end":return t+5;default:return`${e.order}\0${e.mark}`}}var Qi=["start","in","coast","out","end"];function bL(e,t){for(let n of Object.keys(e)){if(Qi.includes(n))throw new Error(`blits: ${n} is one of a voice's own marks; a mark placed inside it needs another name`);let r=e[n];if(!xT(r,t))throw new RangeError(t>0?`blits: mark ${n} is voice ms into a pass, 0 up to ${t}, not ${r}`:`blits: mark ${n} is voice ms, 0 or more, not ${r}`)}}function wT(e,t){return(e.pace===null?t:e.pace.timeOf(t))+e.offset}function xL(e,t){return e.pace===null?t:e.pace.reading(t)}function mm(e,t,n){let r=SL(e,t,n);for(let o of TL(e.transport,t,n))(o.score!==void 0||o.slot===e.slot)&&r.push(o.listed);return PL(r)}function wL(e,t,n){let r=[];for(let o of e.members)r.push(...SL(o,t,n));for(let o of TL(e,t,n))r.push(o.listed);return PL(r)}function PL(e){return e.sort((t,n)=>t.timestamp-n.timestamp||t.order-n.order)}function TL(e,t,n){let r=t-e.offset,o=n-e.offset,i=[];for(let s of e.announced)s.at>=r&&s.at<=o&&i.push({score:s.score,slot:s.slot,listed:{timestamp:s.at+e.offset,mark:void 0,voice:void 0,score:s.score,name:s.name,tags:s.tags,mix:s.mix,order:s.order}});return i}function SL(e,t,n){let r=t-e.offset,o=n-e.offset,i=[];for(let s of[...e.cued,...e.gone]){for(let l of Qi)yL(e,s,l,r,o,i);let a=s.spec.marks;if(a!==void 0)for(let l of Object.keys(a))yL(e,s,l,r,o,i)}return i}function yL(e,t,n,r,o,i){let s=Qe(e,t,n),a=s===void 0?s:wT(e,s)-e.offset;a===void 0||a<r||a>o||i.push({timestamp:a+e.offset,mark:n,voice:t.id,score:t.spec.score,name:t.spec.name,tags:t.spec.tags??fn,mix:e.name,order:t.id})}function Qe(e,t,n){if(!Number.isFinite(t.start))return;let r=_n(t);if(!Number.isFinite(r))return;if(n==="start")return r;if(t.arc!==null&&(n==="in"||n==="coast"||n==="out"||n==="end"))return vL(t,r,n);if(n==="in")return r+(t.fade.in??0);if(n==="coast")return AY(e,t,r);if(n!=="out"&&n!=="end")return vY(e,t,r,n);let o=t.out,i,s=!1;if(o!==null)i=o.at;else if(Number.isFinite(t.outAt))i=t.outAt;else if(t.fitting!==null){let l=t.timeAt(t.fitting.end);Number.isFinite(l)&&(i=Math.max(r,l))}else if(t.holding!==null){let l=kL(e,t.holding.children,"end");l!==void 0&&(i=Math.max(r,l),s=!0)}else if(!(t.backs?t.freezesBefore:t.freezesAfter)){let l=t.endsAt();Number.isFinite(l)&&(i=Math.max(r,l))}if(n==="out")return t.state==="done"&&i===void 0?t.doneAt:i;if(t.state==="done")return t.doneAt;if(o!==null)return o.rest?o.deadline===void 0?void 0:o.at+o.deadline:o.at+o.over;if(s)return i;let a=Number.isNaN(t.outOver)?t.fade.out??0:t.outOver;return i===void 0?void 0:i+(e.reduced?0:a)}var gL=1e-9;function vY(e,t,n,r){let o=t.spec.marks;if(o===void 0||!Object.hasOwn(o,r)||t.backs)return;let i=o[r],s=t.elapsedAt(n),a=t.duration,l=0;if(a>0)l=Math.max(0,Math.ceil((s-i)/a-gL));else if(i<s-gL)return;if(l>=t.passes)return;let u=t.timeAt(l*a+i);if(!Number.isFinite(u))return;let c=Qe(e,t,"end");return c!==void 0&&u>=c?void 0:Math.max(n,u)}function AY(e,t,n){if(t.unplayed)return;let r;if(t.fitting!==null)r=t.timeAt(t.fitting.end);else if(t.holding!==null){let i=t.holding;if(i.cutSeq!==Number.POSITIVE_INFINITY)return;i.children.length===0?r=t.state==="done"?i.coast:void 0:(r=kL(e,i.children,"coast"),r!==void 0&&(r=Math.max(r,i.coast)))}else r=t.endsAt();return r===void 0||!Number.isFinite(r)?void 0:(r=Math.max(n,r),(t.out!==null?t.out.at:t.state==="done"?t.doneAt:t.outAt)<r?void 0:r)}function kL(e,t,n){if(t.length===0)return;let r=Number.NEGATIVE_INFINITY;for(let o of t){let i=Qe(e,o,n);if(i===void 0)return;i>r&&(r=i)}return r}var ym=class{start=void 0;in=void 0;coast=void 0;out=void 0;end=void 0};Object.setPrototypeOf(ym.prototype,null);var gm=class{scopes=new Map;all=new Set;add(t,n){if(n.owner?.state==="done")return;let r=new ym;for(let a=0;a<Qi.length;a++){let l=Qi[a];r[l]=Qe(t,n,l)}let o=n.spec.marks;if(o!==void 0)for(let a of Object.keys(o))r[a]=Qe(t,n,a);let i={id:n.id,score:n.spec.score,owner:n.owner?.id??-1,name:n.spec.name,tags:n.spec.tags??fn,writes:n.patch.writes,marks:r,held:0},s=this.scopeOf(i.score,i.owner);s.whole===void 0?(s.whole={first:i,last:i},i.held+=2):this.hold(s.whole,i),i.name!==void 0&&this.keep(s.names,i.name,i);for(let a=0;a<i.tags.length;a++)this.keep(s.tags,i.tags[a],i);for(let a=0;a<i.writes.length;a++)this.keep(s.writes,i.writes[a],i);i.held>0&&this.all.add(i),n.holding!==null&&this.dropOwner(n.id)}dropOwner(t){for(let n of this.scopes.values()){let r=n.get(t);if(r!==void 0){n.delete(t),r.whole!==void 0&&this.forget(r.whole);for(let o of r.names.values())this.forget(o);for(let o of r.tags.values())this.forget(o);for(let o of r.writes.values())this.forget(o)}}}scopeOf(t,n){let r=this.scopes.get(t);r===void 0&&(r=new Map,this.scopes.set(t,r));let o=r.get(n);return o===void 0&&(o={whole:void 0,names:new Map,tags:new Map,writes:new Map},r.set(n,o)),o}keep(t,n,r){let o=t.get(n);o===void 0?(t.set(n,{first:r,last:r}),r.held+=2):this.hold(o,r)}hold(t,n){this.release(t.last),t.last=n,n.held++}forget(t){this.all.delete(t.first),this.all.delete(t.last)}release(t){--t.held===0&&this.all.delete(t)}};function AL(e,t,n,r,o){return e.score===n&&(r||e.owner===o)&&(t.name===void 0||e.name===t.name)&&(t.tag===void 0||e.tags.includes(t.tag))&&(t.writes===void 0||e.writes.includes(t.writes))}function Sc(e,t){return t.owner===null?e.now:Te(t.owner,e.now)}function _n(e){return e.owner===null?e.start:Vo(e.owner,e.start)}function Zi(e,t){return e.pace===null?t:e.pace.at(t,e.u)}function Ko(e,t,n){e.pins??=new Map,e.pins.set(t,n),t.pinned=n}function NL(e){let t=e.pins;for(let[n,r]of t)n.state!=="pending"?t.delete(n):_a(e,n,Zi(e,r))}function _a(e,t,n){return n===t.start?!1:(t.start=n,t.anchorNow=n,t.clocks=null,t.seeks++,dn(e,t,e.now),je(e,t),!0)}function IL(e,t,n,r){if(n.start!==void 0&&n.in!==void 0)throw new Error("blits: a placement anchors start or in, not both");if(n.out!==void 0&&n.end!==void 0)throw new Error("blits: a placement anchors out or end, not both");if(t.start!==void 0&&(n.start!==void 0||n.in!==void 0))throw new Error("blits: a voice takes start or an anchored start, not both");let o={id:e.nextId,spec:t,owner:r,slot:e.slot,writes:t.patch?.writes??fn},i=[o];for(let u of e.transport.members)for(let c of[u.gone,u.cued])for(let d of c)i.push({id:d.id,spec:d.spec,owner:d.owner,slot:u.slot,writes:d.patch.writes});let s=()=>{throw new Error(`blits: ${t.name??"a voice"}'s placement waits on itself`)},a=(u,c)=>{if("all"in c)return c.all.flatMap(g=>a(u,g));if("any"in c)return c.any.flatMap(g=>a(u,g));let d="of"in c?c.of:"after"in c?c.after:"with"in c?c.with:c.before,f="of"in c?c.mark:"after"in c?"end":"start",p=typeof d=="string"?{name:d}:d,h=p.score??u.spec.score,m=p.score!==void 0;u===o&&p.name!==void 0&&p.name===t.name&&h===t.score&&s();let y=i.filter(g=>g!==u&&g.spec.score===h&&(m||g.owner===u.owner&&g.slot===u.slot)&&(p.name===void 0||g.spec.name===p.name)&&(p.tag===void 0||(g.spec.tags??fn).includes(p.tag))&&(p.writes===void 0||g.writes.includes(p.writes))),b=p.resolver??"last",x=y.length>1&&(b==="first"||b==="last")?[y.reduce((g,P)=>(b==="last"?P.id>g.id:P.id<g.id)?P:g)]:y,w=f==="out"||f==="end"?"out":"start";return x.map(g=>({voice:g,side:w}))},l=(u,c)=>{let d=u.spec.anchor,f=c==="start"?[d?.start,d?.in]:[d?.out,d?.end],p=c==="out"?[{voice:u,side:"start"}]:[];for(let h of f)h!==void 0&&typeof h!="number"&&p.push(...a(u,h));return p};for(let u of["start","out"]){let c={start:new Set,out:new Set},d=l(o,u);for(;d.length>0;){let{voice:f,side:p}=d.pop();f===o&&p===u&&s(),!c[p].has(f)&&(c[p].add(f),d.push(...l(f,p)))}}}function Yr(e){for(let t=0;t<=e.cued.length;t++){let n=!1;for(let r of e.cued){let o=r.spec.anchor;if(!(o===void 0||r.state==="done")){if(r.placing&&r.state==="pending"){let i=o.start??o.in,s=i===void 0?void 0:La(e,i,r);if(s!==void 0){let a=r.owner,l=r.fade.in??0,u=o.start!==void 0?s:a===null?s-l:Te(a,Vo(a,s)-l);Number.isFinite(u)&&_a(e,r,u)&&(n=!0)}}if(r.state!=="fading"&&!r.outSet){let i=o.out??o.end,s=i===void 0?void 0:La(e,i,r);if(s!==void 0){let a=r.owner===null?s:Vo(r.owner,s),l=_n(r),u=o.out!==void 0?a:a-(r.fade.out??0),c=Number.NaN;u<l&&Number.isFinite(l)&&(u=l,o.end!==void 0&&(c=a>l?a-l:0,a<l&&!e.projecting&&tr(r,`${r.spec.name??`voice ${r.id}`}'s placement ends before it starts, so it plays as an instant`))),(u!==r.outAt||!$t(c,r.outOver))&&(r.outAt=u,r.outOver=c,je(e,r),n=!0)}}}}if(!n)break}EL(e)}function La(e,t,n,r){let o=n.owner;if(typeof t=="number")return o===null?Zi(e,t-n.offset):t;if("all"in t){let c=Number.NEGATIVE_INFINITY;for(let d of t.all){let f=RL(e,d,n,r);if(f===void 0)return;c=Math.max(c,f)}return t.all.length===0?void 0:c}if("any"in t){let c=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:Sc(e,n),d=Number.POSITIVE_INFINITY,f=!1;for(let p of t.any){let h=RL(e,p,n,r);h===void 0?f=!0:d=Math.min(d,h)}return d===Number.POSITIVE_INFINITY||f&&d>c?void 0:d}let i,s,a=t.by??0;"of"in t?(i=t.of,s=t.mark):"after"in t?(i=t.after,s="end"):"with"in t?(i=t.with,s="start"):(i=t.before,s="start",a=-a);let l=RY(e,i,s,n);if(l===void 0)return;if(o===null)return l+a;let u=Te(o,l);return u===Number.NEGATIVE_INFINITY?r:Number.isFinite(u)?u+a:void 0}function RL(e,t,n,r){let o=La(e,t,n,r);return o===void 0?n.answers?.get(t):(e.projecting||(n.answers??=new Map,n.answers.set(t,o)),o)}var Fa=class{resolver;now;any=!1;firstOrder=Number.POSITIVE_INFINITY;lastOrder=Number.NEGATIVE_INFINITY;first;last;pick;constructor(t,n){this.resolver=t,this.now=n}take(t,n){this.any=!0,t<this.firstOrder&&(this.firstOrder=t,this.first=n),t>this.lastOrder&&(this.lastOrder=t,this.last=n),n!==void 0&&this.consider(n)}merge(t){t.any&&(this.any=!0,t.firstOrder<this.firstOrder&&(this.firstOrder=t.firstOrder,this.first=t.first),t.lastOrder>this.lastOrder&&(this.lastOrder=t.lastOrder,this.last=t.last),t.pick!==void 0&&this.consider(t.pick))}consider(t){let n=this.pick;(this.resolver==="earliest"?n===void 0||t<n:this.resolver==="latest"?n===void 0||t>n:this.resolver==="next"&&t>=this.now&&(n===void 0||t<n))&&(this.pick=t)}answer(){if(this.any)return this.resolver==="first"?this.first:this.resolver==="last"?this.last:this.pick}};function RY(e,t,n,r){let o=typeof t=="string"?{name:t}:t,i=o.score??r.spec.score,s=o.score!==void 0,a=o.resolver??"last",l=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,u=new Fa(a,l),c=m=>m!==r&&m.spec.score===i&&(s||m.owner===r.owner)&&(o.name===void 0||m.spec.name===o.name)&&(o.tag===void 0||(m.spec.tags??fn).includes(o.tag))&&(o.writes===void 0||m.patch.writes.includes(o.writes)),d=s&&i!==void 0&&!e.projecting,f=s?d?EF(e,i):e.transport.members:[e],p=r.owner?.id??-1,h=new Fa(a,l);for(let m=0;m<f.length;m++){let y=f[m],b=!1;for(let v of y.departed.all)AL(v,o,i,s,p)&&(h.take(v.id,v.marks[n]),b=!0);if(i===void 0||y.projecting||e.projecting){for(let v of[...y.gone,...y.cued])c(v)&&u.take(v.id,Qe(y,v,n));continue}let x=LF(y,i),w=_F(y,i);if(x.size===0&&w.length===0&&!b){d&&(rT(y,i),m--);continue}if(a==="next"){for(let v of x)c(v)&&u.take(v.id,Qe(y,v,n));for(let v of w)c(v)&&u.take(v.id,Qe(y,v,n));continue}let g=NY(y,w,t,n,r,a),P=OF(y,i),S=y.reduced;if(g.live===null||g.liveOf!==y.cued||g.liveVersion!==P||g.liveReduced!==S){let v=new Fa(a,Number.NEGATIVE_INFINITY),A=!0;for(let N of x)c(N)&&((N.owner!==null||N.holding!==null||N.fitting!==null)&&(A=!1),v.take(N.id,Qe(y,N,n)));g.live=v,g.liveOf=A?y.cued:null,g.liveVersion=P,g.liveReduced=S}for(u.merge(g.live);g.seen<w.length;g.seen++){let v=w[g.seen];c(v)&&(v.owner===null?g.pick.take(v.id,Qe(y,v,n)):g.owned.push(v))}u.merge(g.pick);for(let v of g.owned)u.take(v.id,Qe(y,v,n))}if(o.writes===void 0&&(s||r.owner===null))for(let m of e.announced)m.score===i&&(i!==void 0||m.slot===e.slot)&&(o.name===void 0||m.name===o.name)&&(o.tag===void 0||m.tags.includes(o.tag))&&u.take(m.order,Number.isNaN(m.at)?void 0:Zi(e,m.at));return(u.any?u:h).answer()}function NY(e,t,n,r,o,i){o.folds??=new Map;let s=o.folds.get(n);s===void 0&&(s=new Map,o.folds.set(n,s));let a=s.get(e);return(a===void 0||a.list!==t||a.mark!==r)&&(a={list:t,mark:r,seen:0,pick:new Fa(i,Number.NEGATIVE_INFINITY),owned:[],live:null,liveOf:null,liveVersion:-1,liveReduced:!1},s.set(e,a)),a}function TT(e){if(!Number.isFinite(e))throw new RangeError(`blits: a voice's rate is a finite number, not ${e}`)}function ST(e){if(Number.isNaN(e))throw new RangeError("blits: a voice\u2019s weight is a number, not NaN")}var qr=class{id;#t;#n=null;#e;constructor(t,n){this.id=t.id,this.#t=t,this.#e=n}static voiceOf(t){return t.#t}static page(t,n){t.#t=null,t.#n=n}static rehome(t,n){t.#t=n,t.#n=null}get state(){return this.#t?.state??"done"}get owner(){return this.#t?.owner?.handle??void 0}get played(){return this.#t?.played??Promise.resolve(this.#n?.played??!1)}get done(){return this.#t?.done??Promise.resolve()}get result(){return this.#t?.fitting?.report}get weight(){return this.#t?.weight??this.#n?.weight??0}get#r(){let t=this.#t;return t===null||t.parked?null:t}set weight(t){ST(t);let n=this.#r;n!==null&&(n.written=!0,n.weight=t,this.#e.changed(n),this.#e.taping()&&this.#e.record(this,"weight",r=>{r.weight=t}))}get rate(){let t=this.#t;return t===null?0:t.rateAt(this.#e.nowFor(t))}set rate(t){this.ramp(t,0)}ramp(t,n){TT(t);let r=this.#r;if(r!==null){if(r.written=!0,r.state==="pending"){let o=r.ramp===null?r.rate:r.ramp.from;r.ramp=n>0&&t!==o?{from:o,to:t,over:n}:null,r.rate=t}else{let o=this.#e.nowFor(r);Go(r,o),ka(r,o,t,n)}this.#e.changed(r),this.#e.taping()&&this.#e.record(this,"rate",o=>o.ramp(t,n))}}seek(t,n){let r=this.#r;if(r===null)return"exact";r.written=!0;let o=!1;if(r.state!=="pending"){let s=this.#e.nowFor(r);Go(r,s,!0),r.rebase(s),o=t>r.anchorElapsed}r.anchorElapsed=t,r.seeks++;let i=this.#e.sought(r,n?.state!=="keep",o);return this.#e.changed(r),this.#e.taping()&&this.#e.record(this,"seek",s=>s.seek(t,n)),i}fade(t){let n=this.#r;n!==null&&(n.written=!0,this.#e.fade(n,t),this.#e.taping()&&this.#e.record(this,"fade",r=>r.fade(t)))}rise(t){let n=this.#r;n!==null&&(n.written=!0,this.#e.rise(n,t),this.#e.taping()&&this.#e.record(this,"rise",r=>r.rise(t)))}release(){let t=this.#r;t!==null&&(t.written=!0,this.#e.release(t),this.#e.taping()&&this.#e.record(this,"release",n=>n.release()))}weightOf(t){let n=this.#t;return n===null?0:this.#e.weightOf(n,t)}to(t,n,r){let o=this.#t;o!==null&&PT(o.patch,"to","a spring or a tween").to(t,n,r)}push(t,n,r){let o=this.#t;o!==null&&PT(o.patch,"push","a spring or a glide").push(t,n,r)}set(t,n,r){let o=this.#t;o!==null&&PT(o.patch,"set","a motion patch").set(t,n,r)}read(t,n){let r=this.#t;if(!(r===null||Ln(r.patch)===void 0))return r.patch.read(t,n)}};function PT(e,t,n){if(Ln(e)===void 0||typeof e[t]!="function")throw new Error(`blits: ${t} needs a voice playing ${n}`);return e}var IY=new WeakSet,ML=e=>IY.has(e);function kc(e,t,n){let r=n===0?0:Math.abs(e*n-t);return r>=1?0:1-r}var xm={transport:e=>e,mix:e=>e},vc=xm,bm;function Da(e){throw new Error(`blits: the tape holds ${e}, which a read ahead cannot play; seek there to see it`)}var CL={apply(){},invert:()=>CL};function OL(e){let t=e.history?.tape;if(t!==void 0)return t(e,{now:()=>Number.isNaN(e.u)?Number.NEGATIVE_INFINITY:e.u,branching:!0,coalesceWindowMs:0})}function Xr(e){return e.tape!==void 0&&!e.replaying&&!e.projecting}function Lt(e,t,n){let r=e.tape;if(r===void 0||!Xr(e))return;let o={label:t,apply(){if(vc===xm)n(vc);else try{n(vc)}catch(i){bm??={error:i}}},invert:()=>CL};r.recordEntry([o],t)}function es(e,t){return e.pace===null?t:e.pace.timeOf(t)}function Jr(e,t){let n=es(e,t);return e.u>n?e.u:n}function Ba(e,t,n=e,r=xm){let o=e.tape;if(o===void 0)return Number.NaN;let i=n.u,s=Number.NaN;try{for(;;){let a=o.timestampAt(o.undoDepth());if(a===void 0||!t(a))return s;if(a!==s){s=a,n.u=a;let l=n.pace===null?a:n.pace.reading(a);if(l>n.now)for(let u of n.members)Qr(u,l);n.tick(n.now)}e.replaying=!0,vc=r;try{o.redo()}finally{e.replaying=!1,vc=xm}if(bm!==void 0){let{error:l}=bm;throw bm=void 0,l}}}finally{n.u=i}}function FL(e,t,n){let r=e.strays.get(n);r===void 0?e.strays.set(n,[t]):r.includes(t)||r.push(t)}function LL(e,t){let n=t.motion;if(n===void 0)return;let r=(e.playing.get(n)??1)-1;if(r<=0){e.playing.delete(n),e.strayAll.delete(n);return}if(e.playing.set(n,r),t.named===null)e.strayAll.add(n);else for(let o of t.named.list)FL(e,n,o)}function _L(e){return{frame(t,n){let r=e.deref(),o=r===void 0?void 0:jo(r,t);return r===void 0||o===void 0?Number.NaN:DL(r,o,n)},now(){return e.deref()?.now??Number.NaN},seq(){return e.deref()?.transport.seq??Number.NaN},early(){let t=e.deref();return t!==void 0&&(t.syncing||!t.looked)},changed(t,n,r,o){let i=e.deref();i!==void 0&&Xr(i)&&EY(i,t,n,r,o)},page(t,n,r,o){let i=e.deref(),s=i?.opts.history?.ms;i===void 0||i.keys===null||s===void 0||rr(i,n,t,i.keys.key(r),o,a=>a.data,i.now-s)},revive(t,n){let r=e.deref();if(r===void 0)return Number.NaN;r.stir();let o=jo(r,t);return o===void 0||(o.motion!==void 0&&o.named!==null&&!o.named.has(n)&&FL(r,o.motion,n),o.parted?.has(n)!==!0)?Number.NaN:(vT(r,o,n),kT(r,o,Pc(o,n)))}}}function EY(e,t,n,r,o){Lt(e,"motion",i=>{let s=i.mix(e);if(s===void 0)return;if(s!==e)return MY(s,t,n,r,o);((jo(e,t)??e.gone.find(l=>l.id===t))?.motion??n).change(r,{...o})})}function MY(e,t,n,r,o){let i=r,s=jo(e,t),a=o.at;if(s!==void 0){let p=s.parted?.has(i)===!0;if(p&&vT(e,s,i),a===void 0){let h=DL(e,s,i),m=p?kT(e,s,Pc(s,i)):h;Number.isNaN(h)?Number.isNaN(m)||(a=m):a=h}}a===void 0&&Da("a change to a motion made before its voice met the subject");let l=a,u=e.transport.ahead,c=u.get(n);c===void 0&&(c=new Map,u.set(n,c));let d=c.get(i),f={at:a,to:o.to,x:o.x,v:o.v};if(d===void 0)c.set(i,[f]);else{let p=d.length;for(;p>0&&d[p-1].at>l;)p--;d.splice(p,0,f)}}function jo(e,t){let n=e.cued,r=0,o=n.length-1;for(;r<=o;){let i=r+o>>1,s=n[i];if(s.id===t)return s;s.id<t?r=i+1:o=i-1}}function DL(e,t,n){let r=t.subjects.get(n);return r===void 0||!r.reaches?Number.NaN:kT(e,t,r.delay)}function kT(e,t,n){if(Number.isNaN(e.now)||t.state==="pending")return Number.NaN;let r=t.elapsedAt(e.now)-n;return r<0?Number.NaN:r}function GL(e,t){if(e.projecting)throw new Error("blits: a projection books nothing");let n={get voices(){return e.cued},get timestamp(){return e.last},get now(){return e.now},hostOf:o=>wT(e,o),readingAt:o=>xL(e,o-e.offset),endOf:o=>Qe(e,o,"end"),marks:(o,i)=>mm(e,o,i),unhook:o=>{let i=(e.bookers??[]).filter(s=>s!==o);e.bookers=i.length===0?null:i}},r=new hm(n,t);return e.bookers=[...e.bookers??[],r],r}function wm(e){return{get voices(){return e.cued},channels:e.channels,names:e.names,clock:e,fits:t=>CY(e,t),meet:(t,n,r,o)=>{for(let i=r;i!==null;i=i.next)if(i.voice===t)return i;return e.held(t,n,o)},forgot:t=>{e.places?.forgot(t);for(let n of e.general)$r(n,t,!1),n.sighted!==null&&e.share?.unsight(n,t);for(let n of zo(e).general)$r(n,t,!1)},passes:(t,n)=>e.passes(t,n),naming:t=>e.naming===0?void 0:e.named.get(t),slotOf:t=>ut(e,t)?.slot??-1,envelope:(t,n)=>t.owner===null?e.envelope(t,e.now,n):e.envelope(t,e.now,n)*e.ownedBy(t,void 0),parting:(t,n)=>e.parting(t,n,e.now),ready:(t,n,r)=>{let o=e.lanes.arg;e.primeLaned(t,r,o),t.setting.weight=o[0],e.sending.voice=t,e.sending.subject=n},signal:(t,n,r,o)=>{let i=e.lanes.arg,s=t.blend===null?Number.NaN:e.laneRead(t,o);if(!Number.isNaN(s)){i[0]=s;return}e.primeLaned(t,r,i);let a=pe.kept,l=e.base(t,n,e.now,r,o);pe.kept!==a&&!t.keeping&&ts(e,t),i[0]=l},horizon:(t,n)=>{t.motion!==void 0&&(pe.horizon=e.horizonFor(t,n,e.now))},keeps:e.opts.history!==void 0,after:(t,n,r)=>Pm(e,t,n,r),kept:t=>ts(e,t)}}function ns(e){return e.named!==null&&e.named.size===1&&e.spec.role===void 0&&(e.slots.length===1||e.motion===void 0)&&e.motion?.round!==!0}function CY(e,t){let n=t.spec,r=t.patch;if(t.keeping||(t.freezesBefore||t.state==="fading")&&t.unstarted(e.now)||t.beginless||t.out?.back===!0||t.owner!==null&&QF(t))return!1;let o=n.weight;if(typeof o=="function"&&o.input&&(e.opts.history?.inputs||!ML(o))||r.reads!==void 0&&r.reads.length>0||n.role!==void 0&&t.motion!==void 0||n.from==="current"||(t.motion!==void 0||n.role!==void 0||ns(t))&&t.slots.some(s=>Qn(e.channels[s])?.op==="last")||t.out?.rest||r.state!==void 0||r.step!==void 0)return!1;let i=t.built;return i===null||i.tracks.every((s,a)=>s.lerp===void 0||s.lerp===t.lerps[a])}var BL={exact:0,stepped:1,held:2};function HL(e,t,n){let r=t.patch;if(r.state===void 0&&r.step===void 0&&!t.keeping)return"exact";if(!n)return"held";let o=t.spec.weight;return r.reads!==void 0&&r.reads.length>0||typeof o=="function"&&o.input?"held":t.keeping?"stepped":r.step===void 0||Lo(e,t)!==void 0&&e.opts.maxDt===void 0?"exact":"stepped"}function ts(e,t){t.keeping||(t.keeping=!0,t.sharing&&e.share?.unshare(e,t,!0,e.sending.subject),e.lanes?.invalidate())}function Ac(e,t){return e.handles??=OY(e),new qr(t,e.handles)}function OY(e){return{nowFor:t=>{if(Number.isNaN(e.now))return t.start;let n=Sc(e,t);return Number.isFinite(n)?n:t.start},changed:t=>{e.frame=st(),dn(e,t,e.now),t.holding!==null&&Ji(t,n=>dn(e,n,e.now)),je(e,t),e.lanes?.refill()},sought:(t,n,r)=>{r&&t.holding!==null&&!e.projecting&&(e.leapt??=new Set,e.leapt.add(t)),n&&t.rebuilds++;let o=HL(e,t,n);return t.holding!==null&&Ji(t,i=>{i.seeks++,n&&i.rebuilds++;let s=HL(e,i,n);BL[s]>BL[o]&&(o=s),it(e,i)}),o},fade:(t,n)=>{if(t.holding!==null&&n!==void 0&&("subject"in n||n.at==="rest"))throw new Error("blits: an owner fades as a whole, not by subject or at rest");n!==void 0&&"subject"in n?UL(e,t,n.subject,n.over):typeof n?.at=="number"?VL(e,t,n.at,n.over):Zr(e,t,n??{})},rise:(t,n)=>WL(e,t,n??{}),release:t=>zL(e,t),weightOf:(t,n)=>{if(t.state==="done")return 0;if(t.holding!==null)return sT(t,e.now,e.reducedNow,i=>e.ownerBase(i,n));let r=e.lanes===null?-1:ut(e,n)?.slot??-1;if(t.laned&&e.lanes!==null){let i=e.lanes.weightOf(t.id,r);if(i!==void 0)return i}let o=t.sharing?void 0:t.subjects.get(n);return o!==void 0?o.weight:e.share===null?0:e.share.weightAt(t,r)},taping:()=>Xr(e),record:(t,n,r)=>Lt(e,n,o=>{let i=o.mix(e);if(i===e)r(t);else if(i!==void 0){let s=jo(i,t.id);s!==void 0&&r(Ac(i,s))}})}}function Rc(e,t){return{by:e,stops:t,members:[],frame:0,subject:void 0,value:0,reads:new me,frames:new Float64Array(0),values:new Float64Array(0)}}function Ha(e){let t=new Map;for(let n of e){if(n.blend===null)continue;let r=t.get(n.blend.of);r===void 0&&(r=Rc(n.blend.of.by,n.blend.of.stops),t.set(n.blend.of,r)),n.blend={of:r,i:n.blend.i},r.members.push(n)}}function KL(e,t,n,r){let{of:o,i}=e.blend,s=this.frame,a;if(r<0){if(o.frame===s&&o.subject===t)return kc(o.value,i,o.stops);if(a=o.reads.get(t),a?.frame===s)return kc(a.value,i,o.stops)}else if(r>=o.frames.length){let c=Math.max(r+1,o.frames.length*2,64),d=new Float64Array(c),f=new Float64Array(c);d.set(o.frames),f.set(o.values),o.frames=d,o.values=f}let l=pe.kept,u=o.by(t,e.setting);return pe.kept!==l&&!this.projecting&&this.shareKept(o,e,t,n),r<0?(o.frame=s,o.subject=t,o.value=u,a===void 0?o.reads.set(t,{frame:s,value:u}):(a.frame=s,a.value=u)):(o.frames[r]=s,o.values[r]=u),kc(u,i,o.stops)}function jL(e,t){let{of:n,i:r}=e.blend;return t<n.frames.length&&n.frames[t]===this.frame?kc(n.values[t],r,n.stops):Number.NaN}function $L(e,t,n,r){for(let o of e.members){let i=o===t?void 0:o.subjects.get(n);i?.reaches&&i.kept===null&&(i.kept=r.kept),ts(this,o)}}var YL=new WeakMap,qL=e=>typeof e=="function"?YL.get(e):void 0;function XL(e,t={}){if(typeof e!="object"||e===null)throw new TypeError("blits: around takes a circle, { x, y, r }");let n=Bo(t.ease??"linear"),r=o=>{let i=this.places;if(i===null)return 0;let s=i.cur>=0?i.cur:i.at.get(o)??-1,a=i.xy;if(s<0||2*s+1>=a.length)return 0;let l=e.r,u=a[2*s]-e.x,c=a[2*s+1]-e.y,d=u*u+c*c;return!(l>0)||!(d<=l*l)?0:n(1-Math.sqrt(d)/l)};return YL.set(r,e),r}var FY=Ra;function LY(e,t){let n=new Uint8Array(t);return e.bands=n,n}function Ic(e,t){return typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<1e-9:Array.isArray(e)&&Array.isArray(t)?e.length===t.length&&e.every((n,r)=>Ic(n,t[r])):e===t}function Nc(e,t,n){let r=e.merge(t,n);if(r!==n||!Array.isArray(r))return r;if(!Array.isArray(t)||t.length!==r.length)return[...r];for(let o=0;o<r.length;o++)t[o]=r[o];return t}function kt(e){e?.bands&&e.bands.fill(2)}function JL(e,t){let{on:n,off:r}=this.band;return t>=n?!0:t<=r?!1:e??t>=n}function QL(e,t,n,r,o){let i=t.slots;for(let s=0;s<i.length;s++){let a=i[s],l=this.names[a],u=r[l];if(u===void 0)continue;let c=this.scalars[a];if(c!==void 0&&typeof u=="number"){e[l]=Fe(c,e[l],u,o);continue}let d=this.channels[a];if(d.rest!==void 0&&d.scale){e[l]=d.fold?d.fold(e[l],u,o):Nc(d,e[l],d.scale(u,o));continue}let f=n.bands??LY(n,i.length),p=f[s],h=this.passes(p===0?void 0:p===1,o);f[s]=h?1:2,h&&(e[l]=e[l]===void 0?$i(u):Nc(d,e[l],u))}}function ZL(e){for(let t of this.bounded){let n=this.names[t];e[n]=_Y(this.channels[t],e[n])}return e}function _Y(e,t){let[n,r]=e.bounds;if(typeof t=="number")return t<n?n:t>r?r:t;if(Array.isArray(t))for(let o=0;o<t.length;o++){let i=t[o];t[o]=i<n?n:i>r?r:i}return t}function e_(e,t,n,r){if(e.sharing){if(t<0)return r;let s=this.lanes;return this.share.weighAt(e,t,n.weight,s.cap),this.share.shut(e,n,t,s.cap),r}let o=this.sharers,i=0;for(;i<o.length&&o[i].id<e.id;)i++;return i}function t_(e,t,n=!1,r){let o=this.folded(e,t,n,r);return this.bounded.length===0?o:this.clamp(o)}function n_(e,t,n=!1,r){let o=this.linked(e);return this.foldWith(e,t??this.pose(),o,this.linkedLaned,n,r)}function r_(e){let t=Number.isNaN(this.now)?null:this.chain(e),n=this.lanes;return t!==null&&n!==null&&n.laned.length===0&&n.frameAt===this.now&&n.qualifiedVersion===this.version&&n.touched.length===0&&!n.filling?(t.slot>=0&&(n.per[t.slot*6+4]=++n.probes),this.linkedLaned=!1,t):(this.linkedLaned=t!==null&&n?.prepare(t.slot,e,this.version,t)===!0,t)}function o_(e,t,n,r,o,i){let s=t,a=this.lanes,l=r?a.copies:null;for(let c=0;c<this.names.length;c++){if(l?.[c])continue;let d=this.channels[c],f=d.rest,p=this.names[c];if(f===void 0){s[p]!==void 0&&(s[p]=void 0);continue}let h=this.lerpsInto[c]===void 0?void 0:s[p];if(Array.isArray(h)&&h!==f&&h.length===f.length)for(let m=0;m<h.length;m++)h[m]=f[m];else s[p]=d.copy?d.copy(f):FY(f)}if(n===null)return s;let u=-1;if(r){let c=a;if(c.copy(n.slot,s),c.owes(n.slot))u=n.slot;else if(c.whole)return s}if(this.detours===0){let c=this.now;for(let d=n;d!==null;d=d.next){let f=d.voice;if(f===null||r&&f.laned&&!this.owedBy(u,f)||f.id===i||f.state==="done")continue;let p=this.read(f,e,c,o,d);u>=0&&f.laned&&a.paid(f.id,u,d.weight),d.weight>0||kt(d),!(p===null||this.w<=0)&&this.apply(s,f,d,p,this.w)}return s}return this.foldDetour(e,s,n,r,o,i,u)}function i_(e,t,n,r,o,i,s){let a=n.version===this.version?n:this.chain(e);if(this.roleVoices!==0)return this.foldRoles(e,t,a,r,o,i,s);let l=this.now,u=this.lanes,c=this.sharers,d=0;for(let f=a;f!==null;f=f.next){let p=f.voice;if(p===null||(d<c.length&&c[d].id<p.id&&(d=this.foldSharers(t,e,a,d,p.id,r,o,i,s)),r&&p.laned&&!this.owedBy(s,p))||p.id===i||p.state==="done")continue;let h=this.read(p,e,l,o,f);s>=0&&p.laned&&u.paid(p.id,s,f.weight),f.weight>0||kt(f),!(h===null||this.w<=0)&&this.apply(t,p,f,h,this.w)}return d<c.length&&this.foldSharers(t,e,a,d,Number.MAX_SAFE_INTEGER,r,o,i,s),t}function s_(e,t,n,r,o,i,s,a,l){let u=this.sharers,c=this.now;for(;r<u.length;){let d=u[r];if(d.id>=o)break;r++;let f=d.state==="pending"?null:d.everyone;if(f===null||i&&d.laned&&!this.owedBy(l,d)||d.id===a||d.state==="done")continue;this.share.open(d,f,n.slot);let p=this.read(d,t,c,s,f);l>=0&&d.laned&&this.lanes.paid(d.id,l,f.weight),r=this.shared(d,n.slot,f,r),!(p===null||this.w<=0)&&this.apply(e,d,f,p,this.w)}return r}function a_(e,t){return e>=0&&this.lanes.owesVoice(e,t.id)}var Tm=5,Sm=new Map,l_=new WeakMap,u_=0,DY=0;function BY(e){if(e===void 0)return 0;let t=l_.get(e);return t===void 0&&(t=++DY,l_.set(e,t)),t}var AT=e=>Object.is(e,-0)?"-0":String(e);function HY(e){let t=AT(e.duration);for(let r of e.tracks){if(r===void 0)return++u_;t+=`|${AT(r.delay)}`;for(let o of r.all)t+=`,${AT(o.at)}:${BY(o.ease)}`}let n=Sm.get(t);return n===void 0&&(Sm.size>=4096&&Sm.clear(),n=++u_,Sm.set(t,n)),n}var Ga=class{data=new Float64Array(64);used=0;eases=[];lastTiming=-1;lastPhase=Number.NaN;found=new Int32Array(4);easedAt=new Float64Array(4);add(t,n){let r=Tm,o=0;for(let l=0;l<t.tracks.length;l++){let u=t.tracks[l],c=n[l];if(u===void 0||c===void 0||!c.plain||!c.straight)return-1;for(let d of u.all)if(!GY(d.value,c))return-1;r+=2+u.all.length*(1+c.axes),o+=u.all.length}let i=this.reserve(r),s=this.data;s[i]=r,s[i+1]=this.eases.length,s[i+2]=t.duration,s[i+3]=o,s[i+4]=HY(t);let a=i+Tm;for(let l=0;l<t.tracks.length;l++){let u=t.tracks[l],c=n[l];s[a++]=u.all.length,s[a++]=u.delay;for(let d of u.all){if(s[a++]=d.at,c.scalar)s[a++]=d.value;else{let f=d.value;for(let p=0;p<c.axes;p++)s[a++]=f[p]??c.rest}this.eases.push(d.ease)}}return i}copy(t,n){let r=t.data[n],o=this.reserve(r);this.data.set(t.data.subarray(n,n+r),o);let i=t.data[n+1],s=t.data[n+3];this.data[o+1]=this.eases.length;for(let a=0;a<s;a++)this.eases.push(t.eases[i+a]);return o}fold(t,n,r,o,i){let s=this.data;(s[t+4]!==this.lastTiming||n!==this.lastPhase||n===0)&&this.search(t,n,r);let l=this.found,u=this.easedAt,c=t+Tm,d=t+s[t];for(let f=0;c<d;f++){let p=r[f],h=p.axes,m=1+h,y=s[c],b=c+2;c=b+y*m;let x=l[f];if(x===-2)continue;let w=p.values,g=o*h;if(x===-1||x===y){let A=b+(x===-1?0:y-1)*m+1;for(let N=0;N<h;N++)w[g+N]=Fe(p.op,w[g+N],s[A+N],i);continue}let P=b+x*m,S=P-m,v=u[f];for(let A=0;A<h;A++){let N=Ft(s[S+1+A],s[P+1+A],v);w[g+A]=Fe(p.op,w[g+A],N,i)}}}search(t,n,r){let o=this.data;this.lastTiming=-1;let i=o[t+2],s=o[t+1],a=t+Tm,l=t+o[t];for(let u=0;a<l;u++){u>=this.found.length&&this.grow(u+1);let c=1+r[u].axes,d=o[a],f=cT(o[a+1],n,i),p=a+2;a=p+d*c;let h=dT(o,p,c,d,f);if(this.found[u]=h,h>=0&&h<d){let m=p+h*c,y=fT(f,o[m-c],o[m]),b=this.eases[s+h];this.easedAt[u]=b?b(y):y}s+=d}this.lastTiming=o[t+4],this.lastPhase=n}grow(t){let n=new Int32Array(t*2);n.set(this.found),this.found=n;let r=new Float64Array(t*2);r.set(this.easedAt),this.easedAt=r}reserve(t){let n=this.used;if(n+t>this.data.length){let r=new Float64Array(Math.max(n+t,this.data.length*2));r.set(this.data.subarray(0,n)),this.data=r}return this.used=n+t,n}};function GY(e,t){if(t.scalar)return typeof e=="number";if(!(Array.isArray(e)||ArrayBuffer.isView(e)))return!1;let n=e;for(let r=0;r<t.axes;r++){let o=n[r];if(o!==void 0&&typeof o!="number")return!1}return!0}function c_(e,t,n){let r=t.voice,o=t.data,i=e.per,s=t.list,a=t.records,l=t.chans[0],u=e.fills,c=e.frameProbes,d=e.lately,f=r.seeks,p=r.elapsedAt(e.now),h=t.flat,m=r.parts!==null,y=typeof r.spec.weight=="function",b=e.probes!==c,x=Wr(r.weight),w=e.arg,g=n.n,P=l.op;if(g>0&&(t.axes!==g&&(t.axes=g,t.samples=new Float64Array(0)),s.length*g>t.samples.length)){let B=new Float64Array(Math.max(s.length,t.samples.length/g*2,4)*g);B.set(t.samples),t.samples=B}let S=t.samples,v=n.xs,A=n.round?void 0:n.ease;n.watcher===null&&(n.watcher=e,n.watchId=r.id);let N=A!==void 0&&!y&&n.watcher===e&&n.watchId===r.id,M=g===l.axes&&l.plain,C=Number.NaN,F=Number.NaN,D=0;for(let B=0;B<s.length;B++){if(y&&r.keeping)return;let K=s[B],W=B*8,Q=K*6;if(_t(o,W,i,Q,u),d>=0&&e.unread(K)){Ua(t,B);continue}let le=o[W+0],ke=p-le;if(!(ke>=0)){Ua(t,B),o[W+2]=0;continue}if(!h){let ee=o[W+1];(!t.weighed||!$t(ee,t.weighedSince))&&(t.fade=e.host.envelope(r,ee),t.weighed=!0,t.weighedSince=ee)}let ue;if(y){if(w[1]=ke,w[3]=er(ke,r.duration,r.passes),w[5]=t.fade,!e.signalled(r,K,a[B])){o[W+2]=0;continue}ue=w[0]}else if(m)ue=Yt(r.weight,t.fade,e.parting(r,K));else if(h)ue=x;else{let ee=t.fade,te=r.weight;(ee!==C||te!==F||ee===0||te===0)&&(C=ee,F=te,D=Yt(te,ee,1)),ue=D}if(o[W+2]=ue,o[W+7]===0){if(Number.isNaN(a[B].probed)){Ua(t,B),e.late.push(K);continue}o[W+7]=1}let ve=o[W+4],G=-1,j=!1;if(ve>=0){G=5+ve*n.stride;let ee=n.runs[G+1];(ee&6)!==0&&(G=-1),j=(ee&1)!==0}if(G<0||b&&(i[Q+3]>c||i[Q+4]>c)){w[1]=ke,w[4]=le,w[0]=ue,Ec(e,t,n,B,K,a[B]);continue}let $=n.runs;if(N&&M&&j===l.scalar){if(o[W+5]!==-2&&(o[W+5]=-2,t.deltas[B]=null),ue<=0)continue;let ee=_o(A,Vr(ke,$[G],$[G+2])),te=l.values,he=K*g,xe=G+3,Le=xe+2*g;for(let Se=0;Se<g;Se++)te[he+Se]=Fe(P,te[he+Se],Do($[xe+Se],$[Le+Se],ee),ue);continue}if(A!==void 0){let ee=_o(A,Vr(ke,$[G],$[G+2])),te=G+3,he=te+2*g;for(let xe=0;xe<g;xe++)v[xe]=Do($[te+xe],$[he+xe],ee)}else n.sampleBare(ve,ke,v,n.vs);for(let ee=0;ee<g;ee++)S[B*g+ee]=v[ee];if(t.deltas[B]!==null&&(t.deltas[B]=null),o[W+5]=u,o[W+6]=f,!(ue<=0))if(M&&j===l.scalar){let ee=l.values,te=K*g;for(let he=0;he<g;he++)ee[te+he]=Fe(P,ee[te+he],v[he],ue)}else w[0]=ue,e.foldInto(l,K,n.value(ve,v))}N&&(t.bareFill=u,t.bareElapsed=p,t.bareSeeks=f)}function Ec(e,t,n,r,o,i){let s=e.arg[1],a=e.arg[4],l=e.arg[0],u=t.voiceAt(r),c=t.data,d=r*8,f=t.chans[0];if(Mc(e,t,r,o,i),!(l>0))return;let p=i.delta;if(p===null||i.probed!==e.now||i.seeks!==u.seeks||!e.probedThisFrame(o)){let h=c[d+4];if(h<0){let y=e.subjectAt(o);if(y===or)return;h=n.slot(y),c[d+4]=h,t.numbered(r,h)}if(e.keeps?e.host.horizon(u,a):pe.horizon=Number.POSITIVE_INFINITY,!n.quiet(h,s)){e.late.push(o);return}n.sample(h,s,n.xs,n.vs);let m=n.n;if(t.keep(r,n.xs,m),t.deltas[r]=null,c[d+5]=e.fills,c[d+6]=u.seeks,l<=0)return;m===f.axes&&n.scalar(h)===f.scalar?e.foldRun(f,o,n.xs):e.foldInto(f,o,n.value(h,n.xs));return}t.deltas[r]=p,c[d+5]=e.fills,c[d+6]=u.seeks,l>0&&e.foldInto(f,o,p[f.name])}function UY(e,t){let n=e.motionAt(t);e.kept(t,n.xs);let r=e.data[t*8+4],o={[e.chans[0].name]:n.value(r,n.xs)};return e.deltas[t]=o,o}function Mc(e,t,n,r,o){t.fix(n);let i=n*8;o.probed===e.now&&o.seeks===t.data[i+6]||!(e.per[r*6+3]>e.frameProbes)||t.data[i+5]!==e.per[r*6+5]||(o.delta=t.deltas[n]??UY(t,n),o.probed=e.now,o.seeks=t.data[i+6])}var f_=new Float64Array(0);function RT(e){return(e&2043)===1211}var km=class{chans;axes;list=[];data=new Float64Array(0);hot=new Float64Array(0);stride;samples=new Float64Array(0);deltas=[];records=[];voices=[];motions=[];eases=[];laws=[];idle=!1;line=Rm.other;cursor=0;dead=0;stale=!1;staleRows=[];xs;vs;delta={};keys=new Ga;scratch=[];bareFill=-1;bareNow=Number.NaN;constructor(t,n){this.chans=t,this.axes=n,this.stride=11+3*n,this.xs=new Float64Array(n),this.vs=new Float64Array(n)}voiceAt(t){return this.voices[t]}fix(t){Am(this,t)}numbered(){}restale(t,n){this.hot[t*this.stride+0]=(n|4)&-2049,this.stale=!0,this.staleRows.push(t)}odd=null;keep(t,n,r){if(r===this.axes){for(let o=0;o<r;o++)this.samples[t*r+o]=n[o];this.odd?.delete(t);return}this.odd??=new Map,this.odd.set(t,n.slice(0,r))}kept(t,n){let r=this.odd?.get(t);if(r!==void 0){n.set(r);return}let o=this.axes;for(let i=0;i<o;i++)n[i]=this.samples[t*o+i]}motionAt(t){return this.motions[t]}get size(){return this.list.length}reserve(t){if(t*8<=this.data.length)return;let n=Math.max(t,this.data.length/8*2,16),r=new Float64Array(n*8);r.set(this.data),this.data=r;let o=new Float64Array(n*this.stride);o.set(this.hot),this.hot=o;let i=new Float64Array(n*this.axes);i.set(this.samples),this.samples=i}};function NT(e,t){if(!e.overlap){for(let n of e.crowds)!n.idle&&n.cursor<n.size&&d_(e,n,t);return}for(;;){let n,r=t,o=t;for(let i of e.crowds){if(i.idle||i.cursor>=i.size)continue;let s=i.hot[i.cursor*i.stride+7];s<r?(o=r,r=s,n=i):s<o&&(o=s)}if(n===void 0)return;d_(e,n,o)}}function d_(e,t,n){let r=t.list,o=t.hot,i=t.cursor;for(;i=m_(e,t,i,n),!(i>=r.length||o[i*t.stride+7]>=n);)i=WY(e,t,i,n);t.cursor=i}function WY(e,t,n,r){let o=t.data,i=t.hot,s=t.stride,a=e.per,l=e.arg,u=t.list,c=t.chans[0],d=t.axes,f=e.fills,p=e.frameProbes,h=e.probes!==p,m=e.now,y=t.xs,b=t.vs,x=t.samples,w=n;for(;w<u.length;w++){let g=w*s;if(i[g+7]>=r)break;let P=i[g+0];if(w>n&&RT(P))break;if(o[w*8+5]===-2&&Am(t,w),(P&64)!==0&&(P=VY(t,w)),(P&1)===0||(P&16)===0)continue;let S=u[w],v=w*8,A=S*6;if(_t(o,v,a,A,f),e.lately>=0&&e.unread(S))continue;let N=o[v+0],M=(P&2)!==0,C=t.voices[w],D=(M?vm(i,g,m):C.elapsedAt(m))-N;if((P&256)!==0&&(D=D>=0?D>C.span?C.hidesPast?Number.NaN:C.freezesAfter?C.span:D:D:C.freezesBefore?0:Number.NaN),!(D>=0)){o[v+2]=0;continue}let B;if(M)B=i[g+4];else if(typeof C.spec.weight=="function"){let W=e.host.envelope(C,o[v+1]);if(l[1]=D,l[3]=er(D,C.duration,C.passes),l[5]=W,!e.signalled(C,S,t.records[w])){o[v+2]=0;continue}B=l[0]}else B=Yt(C.weight,e.host.envelope(C,o[v+1]),e.parting(C,S));if(o[v+2]=B,(P&512)!==0){B>0&&t.keys.fold(i[g+9],Ur(D,i[g+11],i[g+10]),t.chans,S,B);continue}if(l[1]=D,l[4]=N,l[0]=B,(P&128)===0){e.row(t,w,C,S);continue}if(o[v+7]===0){if(Number.isNaN(t.records[w].probed)){e.late.push(S);continue}o[v+7]=1}let K=o[v+4];if(K<0||(P&8)===0||h&&(a[A+3]>p||a[A+4]>p)){let W=t.motions[w];Ec(e,t,W,w,S,t.records[w]),K<0&&t.restale(w,i[g+0]);continue}rF(t.laws[w],t.eases[w],d,i[g+9],i[g+10],i,g+11,i,g+11+d,i,g+11+2*d,D,y,b);for(let W=0;W<d;W++)x[w*d+W]=y[W];t.deltas[w]!==null&&(t.deltas[w]=null),o[v+5]=f,o[v+6]=i[g+5],!(B<=0)&&((P&32)!==0?e.foldRun(c,S,y):e.foldInto(c,S,t.motions[w].value(K,y)))}return w}function p_(e,t,n,r){let o=this.arg,i=o[1],s=n.duration;if(o[2]=Ur(i,s,n.passes),n.built!==null){o[0]>0&&this.foldKeys(n,e.chans,r);return}let a=e.records[t];if(Number.isNaN(a.probed)){this.late.push(r);return}o[3]=er(i,s,n.passes),this.call(n,e.chans,a,r)}function VY(e,t){let n=e.voices[t],r=t*e.stride,o=e.hot[r+0]&-324;return(n.state==="live"||n.state==="frozen"||n.state==="fading")&&(o|=1),(n.freezesBefore||n.freezesAfter||n.motion===void 0&&(n.owner!==null||n.hidesPast))&&(o|=256),n.ramp===null&&n.owner===null&&!((n.fade.in??0)>0)&&n.out===null&&n.back===null&&n.parts===null&&!n.keeping&&typeof n.spec.weight!="function"&&(o|=2),e.hot[r+1]=n.anchorNow,e.hot[r+2]=n.anchorElapsed,e.hot[r+3]=n.rate,e.hot[r+4]=Wr(n.weight),e.hot[r+5]=n.seeks,e.hot[r+0]=o,o}function h_(e){e.stale=!1;let t=e.hot,n=e.stride,r=e.staleRows;e.staleRows=[];for(let o=0;o<r.length;o++){let i=r[o];if(i>=e.list.length)continue;let s=t[i*n+0];if((s&4)===0||(s&128)===0)continue;let a=e.data[i*8+4];a>=0&&zY(e,i,a)}}function zY(e,t,n){Am(e,t);let r=e.motions[t],o=t*e.stride,i=e.hot[o+0]&-45,s=e.chans[0];return r.n===e.axes&&r.stretchInto(n,e.hot,o+9)&&(i|=8,r.scalar(n)===s.scalar&&s.plain&&(i|=32)),e.hot[o+0]=i,i}function vm(e,t,n){return e[t+2]+(n-e[t+1])*e[t+3]}function m_(e,t,n,r){let o=t.data,i=t.hot,s=t.stride,a=e.per,l=t.list,u=t.chans[0],c=t.axes,d=e.fills,f=e.frameProbes,p=e.probes!==f,h=e.lately,m=e.now,y=u.op,b=r!==Number.POSITIVE_INFINITY;for(;n<l.length;n++){let x=n*s,w=i[x+0];if(b&&i[x+7]>=r||!RT(w))break;let g=n*8,P=(w&2048)!==0;if(!P&&(o[g+4]<0||o[g+7]===0))break;let S=l[n],v=S*6;if(p&&(a[v+3]>f||a[v+4]>f)||h>=0&&!(a[v+3]>h||a[v+4]>h))break;let A=P&&m>=i[x+8],N=0;if(!A&&(N=vm(i,x,m)-o[g+0],!(N>=0)))break;_t(o,g,a,v,d);let M=i[x+4];if(o[g+2]=M,P||(o[g+5]!==-2&&(o[g+5]=-2,t.deltas[n]=null),i[x+0]=w|2048,i[x+8]=Number.POSITIVE_INFINITY),M<=0)continue;let C=u.values,F=S*c,D=x+11,B=D+2*c;if(A){for(let Q=0;Q<c;Q++)C[F+Q]=Fe(y,C[F+Q],i[B+Q],M);continue}let K=Vr(N,i[x+9],i[x+10]),W=_o(t.eases[n],K);K>=1&&i[x+3]>0&&(i[x+8]=m);for(let Q=0;Q<c;Q++)C[F+Q]=Fe(y,C[F+Q],Do(i[D+Q],i[B+Q],W),M)}return n}function Am(e,t){let n=t*8,r=e.data;if(r[n+5]!==-2)return;let o=e.hot,i=t*e.stride;o[i+0]=o[i+0]&-2049;let s=e.axes,a=vm(o,i,e.bareNow)-r[n+0],l=_o(e.eases[t],Vr(a,o[i+9],o[i+10])),u=i+11,c=u+2*s;for(let d=0;d<s;d++)e.samples[t*s+d]=Do(o[u+d],o[c+d],l);r[n+5]=e.bareFill,r[n+6]=o[i+5]}function Ua(e,t){let n=t*8,r=e.data;if(r[n+5]!==-2)return;let o=e.motion,i=o.runs,s=o.n,a=o.base(r[n+4]),l=e.bareElapsed-r[n+0],u=_o(o.ease,Vr(l,i[a],i[a+2])),c=a+3,d=c+2*s;for(let f=0;f<s;f++)e.samples[t*s+f]=Do(i[c+f],i[d+f],u);r[n+5]=e.bareFill,r[n+6]=e.bareSeeks}function _t(e,t,n,r,o){let i=e[t+2];(i!==e[t+3]||i===0)&&n[r+5]===o-1&&(e[t+3]=i)}var Rm={keys:{stop:.15,start:.25},other:{stop:.6,start:.8}},Cc=class{voice;list=[];at=new Int32Array(0);idle=!1;line;epoch=0;made=0;data=new Float64Array(0);records=[];deltas=[];samples=new Float64Array(0);axes=0;delta={};scratch=[];chans=[];values=[];nums=new Float64Array(0);kinds=new Uint8Array(0);placed=!1;placedAt=0;phase=0;pass=0;read=!1;readAt=0;weighed=!1;weighedSince=0;fade=1;flat=!1;ran=-1;elapsedNow=0;motion;byMotion=new Int32Array(0);bareFill=-1;bareElapsed=Number.NaN;bareSeeks=Number.NaN;group=null;mark=Number.NaN;every=!1;voiceAt(){return this.voice}fix(t){Ua(this,t)}numbered(t,n){if(n>=this.byMotion.length){let r=new Int32Array(Math.max(n+1,this.byMotion.length*2,64));r.set(this.byMotion),this.byMotion=r}this.byMotion[n]=t+1}positionOfMotion(t){return t<this.byMotion.length?this.byMotion[t]-1:-1}keep(t,n,r){if(this.axes!==r&&(this.axes=r,this.samples=new Float64Array(0)),(t+1)*r>this.samples.length){let o=new Float64Array(Math.max(t+1,this.samples.length/r*2,4)*r);o.set(this.samples),this.samples=o}for(let o=0;o<r;o++)this.samples[t*r+o]=n[o]}kept(t,n){let r=this.axes;for(let o=0;o<r;o++)n[o]=this.samples[t*r+o]}motionAt(){return this.motion}constructor(t){this.voice=t,this.motion=Ln(t.patch),this.line=t.built!==null?Rm.keys:Rm.other}positionOf(t){return t<this.at.length?this.at[t]-1:-1}reserve(t,n){if(t*8>this.data.length){let r=new Float64Array(t*8);r.set(this.data),this.data=r}if(n>this.at.length){let r=new Int32Array(n);r.set(this.at),this.at=r}}add(t,n){let r=this.list.length;if(this.list.push(t),t>=this.at.length){let i=new Int32Array(Math.max(t+1,this.at.length*2,64));i.set(this.at),this.at=i}if(this.at[t]=r+1,(r+1)*8>this.data.length){let i=new Float64Array(Math.max(r+1,this.data.length/8*2,4)*8);i.set(this.data),this.data=i}let o=r*8;this.data[o+0]=n.delay,this.data[o+1]=n.shown,this.data[o+2]=0,this.data[o+3]=0,this.data[o+4]=-1,this.data[o+5]=-1,this.data[o+7]=0,this.records[r]=n,this.deltas[r]=null}renumber(t,n){let r=this.positionOf(t);if(!(r<0)){if(n>=this.at.length){let o=new Int32Array(Math.max(n+1,this.at.length*2,64));o.set(this.at),this.at=o}this.list[r]=n,this.at[n]=r+1,this.at[t]=0}}remove(t){let n=this.positionOf(t);if(n<0)return;let r=this.list.length-1,o=this.data[n*8+4];if(o>=0&&(this.byMotion[o]=0),n!==r){let i=this.data[r*8+4];i>=0&&(this.byMotion[i]=n+1);let s=this.list[r];this.list[n]=s,this.at[s]=n+1,this.data.copyWithin(n*8,r*8,(r+1)*8),this.records[n]=this.records[r],this.deltas[n]=this.deltas[r]??null;let a=this.axes;a>0&&this.samples.copyWithin(n*a,r*a,(r+1)*a)}this.list.pop(),this.at[t]=0,this.records[r]=void 0,this.deltas[r]=null}};var Em=8,Nm=4,IT=class{mix;voice;area;finder;hitAt=new Float64Array(0);marks=0;markedIn=Number.NaN;missed=new Int32Array(Nm);vets;frame=Number.NaN;x=0;y=0;r=0;r2=0;lit=[];spare=[];inAt=new Float64Array(0);litAt=new Float64Array(0);checks;frames=0;checkedAt=-1;constructor(t,n,r){this.mix=t,this.voice=n,this.area=r,this.finder=KY(r)?r:null,this.checks=!yc(),this.vets=this.checks&&this.finder!==null}},KY=e=>typeof e.find=="function";function y_(e,t){let n=t.within;if(n!==void 0){if(typeof n!="object"||n===null)throw new TypeError("blits: within takes a circle, { x, y, r }, or a finder, { find(out) }");if(e.places===null)throw new Error("blits: within needs indices: call mix.place or mix.plot first");if(typeof t.weight!="function")throw new Error("blits: within needs a signal weight; for a hard-edged disk use weight: mix.around(circle, { steps: 1, jump: 'start' })")}}function Mm(e,t){let n=t.spec,r=qL(n.weight),o=n.within??(r!==void 0&&e.places!==null?r:void 0);o!==void 0&&(t.bound=new IT(e,t,o),o===r&&(t.bound.checks=!1))}function g_(e,t){if(e.frame!==t.frame&&(e.frame=t.frame,e.checks&&e.frames++,e.finder===null)){let n=e.area;if(e.x=n.x,e.y=n.y,e.r=n.r,e.r2=n.r*n.r,e.checks&&e.frames%Em===0){let r=t.places;b_(e,r.found,r.ring(e.x,e.y,e.r))}}}function ET(e){let t=e.mix.places;g_(e,e.mix);let n=e.finder;if(n===null)return t.query(e.x,e.y,e.r,e.r2);t.found.length<t.n&&(t.found=new Int32Array(Math.max(t.n,t.found.length*2)));let r=t.found,o=n.find(r);if(!(Number.isInteger(o)&&o>=0&&o<=r.length))throw new RangeError(`blits: within's find returned ${o}, not a count of the indices it wrote, 0 to ${r.length}`);return t.count=o,e.vets&&jY(e,r,o,t.n),e.checks&&e.frames%Em===0&&e.checkedAt!==e.frames&&(e.checkedAt=e.frames,b_(e,e.missed,$Y(e,t,o))),o}function jY(e,t,n,r){for(let o=0;o<n;o++){let i=t[o];if(i>=0&&i<r)continue;e.vets=!1;let s=e.voice;tr(s,`${s.spec.name??`voice ${s.id}`}'s within finder found index ${i}, which place never handed out: it is skipped`);return}}function b_(e,t,n){if(n===0)return;let r=e.mix.places,o=e.voice,i=o.spec.weight,s=e.mix.now,a={timestamp:s,dt:0,elapsed:o.elapsedAt(s),pass:o.setting.pass,weight:0,state:void 0,host:o.setting.host,keep:(f,p)=>p(),send:()=>{}},l=Math.max(1,Math.floor(n/Nm)),u=e.frames/Em%l,c=t.slice(0,n),d=o.named;for(let f=u;f<n;f+=l){let p=r.subjectAt(c[f]);if(p===void 0||d!==null&&!d.has(p))continue;let h=i(p,a);if(h>0){e.checks=!1,tr(o,e.finder===null?`${o.spec.name??`voice ${o.id}`}'s weight signal reads ${h} just outside its within circle (r ${e.r}), which cuts it off there: widen r to where the signal falls to 0`:`${o.spec.name??`voice ${o.id}`}'s weight signal reads ${h} for a subject its within finder did not find, which cuts it off there: find every subject the signal is above 0 for`);return}}}function $Y(e,t,n){let r=x_(e,t,n),o=t.n,i=e.hitAt,s=o===0?0:e.frames/Em*Nm%o,a=0;for(let l=0;l<o&&a<Nm;l++){let u=(s+l)%o;i[u]!==r&&t.subjectAt(u)!==void 0&&(e.missed[a++]=u)}return a}function x_(e,t,n){e.markedIn=e.mix.frame,e.hitAt.length<t.n&&(e.hitAt=new Float64Array(Math.max(t.n,e.hitAt.length*2)));let r=++e.marks,o=t.found,i=e.hitAt;for(let s=0;s<n;s++){let a=o[s];a>=0&&a<i.length&&(i[a]=r)}return r}function YY(e){if(e.markedIn===e.mix.frame)return e.marks;let t=ET(e);return e.markedIn===e.mix.frame?e.marks:x_(e,e.mix.places,t)}function w_(e,t,n){let r=e.places;if(r===null)return!1;if(t.finder!==null){let o=r.at.get(n);if(o===void 0)return!1;let i=YY(t);return t.hitAt[o]===i}if(e.projecting){let o=t.area;return r.inside(n,o.x,o.y,o.r*o.r)}return g_(t,e),r.inside(n,t.x,t.y,t.r2)}function Im(e,t,n){t>=e.litAt.length&&MT(e,t+1),e.litAt[t]!==n&&(e.litAt[t]=n,e.lit.push(t))}function MT(e,t){if(t<=e.inAt.length)return;let n=Math.max(t,e.inAt.length*2,64),r=new Float64Array(n);r.set(e.inAt),e.inAt=r;let o=new Float64Array(n);o.set(e.litAt),e.litAt=o}function P_(e,t,n){let r=n.mix.places,o=ET(n),i=e.fills;MT(n,e.cap);let s=n.lit;n.lit=n.spare,n.lit.length=0,n.spare=s;let a=t.voice,l=n.inAt,u=r.found,c=r.slots;for(let p=0;p<o;p++){let h=c[u[p]]??-1;if(h<0||l[h]===i)continue;l[h]=i;let m=t.positionOf(h);if(!(m<0)){Im(n,h,i),r.cur=u[p];try{e.one(t,m,h)}finally{r.cur=-1}if(a.keeping)return}}let d=t.data,f=e.per;for(let p=0;p<s.length;p++){let h=s[p];if(l[h]===i||l[h]===-i)continue;l[h]=-i;let m=t.positionOf(h);if(m<0)continue;let y=m*8;_t(d,y,f,h*6,i),d[y+2]!==0&&(d[y+2]=0,kt(t.records[m])),d[y+3]!==0&&Im(n,h,i)}}function CT(e,t){let n=t.mix.places,r=ET(t),o=e.fills;MT(t,e.cap);let i=t.inAt,s=n.found,a=n.slots;for(let l=0;l<r;l++){let u=a[s[l]]??-1;u>=0&&(i[u]=o)}}var OT=(e,t,n)=>e.inAt[t]===n;function FT(e,t,n,r){let o=t.data,i=n*8;_t(o,i,e.per,r*6,e.fills),o[i+2]!==0&&(o[i+2]=0,kt(t.records[n]))}function $o(e){e.detours=e.roleVoices+e.sharers.length+(e.unshared?1:0)}function LT(e,t,n){t.spec.role!==void 0&&(e.roleVoices+=n);let r=t.spec.earliest;(t.spec.anchor!==void 0||r!==void 0&&typeof r!="number")&&(e.anchored+=n)}function T_(e,t){t.holding!==null&&(e.owners??=[],e.owners.push(t)),QP(e,t),LT(e,t,1),$o(e)}function S_(e,t){t.named!==null&&TF(e,t),t.holding!==null&&e.owners!==null&&(e.owners=e.owners.filter(n=>n!==t)),LT(e,t,-1),$o(e)}function Yo(e){e.named=new me,e.naming=0,e.general=[],e.sharers=[],e.roleVoices=0,e.anchored=0;for(let t of e.cued)QP(e,t),LT(e,t,1);$o(e),e.steps.push(null,++e.version)}function A_(e,t){let n=_T(e,t),r=n.patch;if(DT(e,n),n.from==="current"&&r.form!=="keys")throw new Error("blits: from: 'current' needs a keys patch");if(n.subjects!==void 0&&n.target!==void 0)throw new Error("blits: a voice takes target or subjects, not both");let o=n.anchor,i=n.owner===void 0?null:eq(e,n.owner);o&&IL(e,n,o,i),n.hits!==void 0&&mL(n.hits,r.duration),n.marks!==void 0&&bL(n.marks,r.duration),y_(e,n);let s=o!==void 0&&(o.start!==void 0||o.in!==void 0),a=i===null?e.now:Te(i,e.now),l=s||i?.fitting?Number.POSITIVE_INFINITY:i!==null?n.start??(a>0?a:0):n.start!==void 0?Zi(e,n.start-e.offset):Number.isNaN(e.now)?0:e.asleep?Number.POSITIVE_INFINITY:e.now,u=new Wa(e.nextId++,n,r,n.fade??qY,a,l,e.slotOf,e.channels,e.opts.host,e.send,i);u.offset=e.offset,r===Xi&&e.fitting!==null&&(u.fitting=e.fitting),r===Xi&&e.arcing!==null&&(u.arc=e.arcing,u.hold=e.arcing.hold),i?.fitting&&I_(n,u),e.pace!==null&&i===null&&n.start!==void 0&&u.state==="pending"&&(u.pinned=n.start-e.offset),l===Number.POSITIVE_INFINITY&&!s&&!i?.fitting&&Number.isNaN(u.pinned)&&(u.waking=!0,e.waking=!0),Mm(e,u),N_(e,u);let c=Ac(e,u);return u.handle=c,Xr(e)&&XY(e,c),c}var qY=Object.freeze({});function XY(e,t){Lt(e,"cue",n=>{let r=qr.voiceOf(t)??ZY(t),o=n.mix(e);o===e?k_(e,r):o!==void 0&&k_(o,QY(o,r))})}function JY(e,t){for(let n of e.writes){if(!(n in t))throw new Error(`blits: kit has no channel ${String(n)}, which this patch writes`);let r=e.kit?.[n],o=t[n],i=o.rest;if(o.fold&&!o.copy&&typeof i=="object"&&i!==null&&!kF(i))throw new Error(`blits: channel ${String(n)} folds into a copy of its rest, which the mix cannot copy; give the channel a copy`);if(r&&r!==o&&(r.kind===void 0||r.kind!==o.kind))throw new Error(`blits: channel ${String(n)} is ${o.kind??"a custom channel"} in this kit, but the patch was written for ${r.kind??"a custom channel"}`)}}function _T(e,t){let n=t;if(n.locus!==void 0){if(n.role!==void 0&&n.role!==n.locus)throw new Error(`blits: a voice plays one role, not both role ${n.role} and locus ${n.locus}; locus is role's old name`);tr(e,"locus is renamed role; cue the voice with role");let{locus:s,...a}=n;n={...a,role:s}}let r=e.roleTags,o=n.tags;if(r===void 0||o===void 0)return n;let i=n.role;for(let s of o)if(!(!r.includes(s)||s===i)){if(i!==void 0)throw new Error(`blits: a voice plays one role, not both ${i} and ${s}`);i=s}return i===n.role?n:{...n,role:i}}function R_(e){let{roles:t,loci:n}=e;if(n===void 0)return t;if(t!==void 0&&(t.length!==n.length||t.some((r,o)=>r!==n[o])))throw new Error("blits: a mix takes roles or loci, not both; loci is roles' old name");return tr(e,"the mix option loci is renamed roles; make the mix with roles"),n}function DT(e,t){let n=t.patch,r=t.loop;if(typeof r=="number"&&!(Number.isInteger(r)&&r>=1))throw new RangeError(`blits: loop takes true, false or a whole number of passes, not ${r}`);if(t.rate!==void 0&&TT(t.rate),t.seek!==void 0&&!Number.isFinite(t.seek))throw new RangeError(`blits: a voice's seek is a finite number of ms, not ${t.seek}`);if(t.stepMs!==void 0&&!(t.stepMs>=0&&t.stepMs<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a voice's stepMs is a finite number of ms, 0 or more, not ${t.stepMs}`);if(t.catchUp!==void 0&&t.catchUp!=="exact"&&t.catchUp!=="fresh")throw new RangeError(`blits: catchUp takes 'exact' or 'fresh', not ${String(t.catchUp)}`);typeof t.weight=="number"&&ST(t.weight),JY(n,e.kit);let o=Ln(n);if(o!==void 0){let i=n.writes[0],s=e.kit[i],a=s.rest;typeof a=="number"?o.cuedOn(String(i),!0):Array.isArray(a)||ArrayBuffer.isView(a)?o.cuedOn(String(i),!1,$P(s)):$P(s)&&o.cuedOn(String(i),!1,!0)}if(n.reads){let i=e.opts.host;for(let s of n.reads)if(typeof i!="object"||i===null||!(s in i))throw new Error(`blits: the patch reads host.${s}, which this mix's host lacks`)}if(e.transport.pager!==null&&(n.state!==void 0||n.step!==void 0)&&(n.pack===void 0||n.unpack===void 0))throw new Error("blits: this mix's history has a store, which keeps a stateful patch's state as data; give the patch pack and unpack");if(t.as!==void 0&&e.transport.pager!==null&&!e.opts.history?.revive)throw new Error("blits: a voice cued with as needs history.revive to rebuild it from")}function k_(e,t){let n=t.owner;!n?.fitting&&(n===null?e.now:Te(n,e.now))>=t.start&&(t.state="live"),N_(e,t)}var v_=new WeakMap;function QY(e,t){let n=t.copy(()=>{});if(t.owner!==null){let r=jo(e,t.owner.id);(r===void 0||r.holding===null)&&Da("a cue under an owner that has left"),n.owner=r}if(n.holding!==null&&(n.holding=new Wo),n.blend!==null){let r=v_.get(e);r===void 0&&(r=new Map,v_.set(e,r));let o=n.blend.of,i=r.get(o);i===void 0&&(i=Rc(n.blend.of.by,n.blend.of.stops),r.set(o,i)),n.blend={of:i,i:n.blend.i},i.members.push(n)}return n}function ZY(e){throw new Error(`blits: voice ${e.id} is paged out, and the seek that plays its cue again did not load it`)}function N_(e,t){let n=t.spec,r=t.owner,o=n.anchor,i=o!==void 0&&(o.start!==void 0||o.in!==void 0),s=t.motion;t.parked=!1,r!==null&&qF(r,t),Number.isNaN(e.now)||(t.cuedAt=e.now,t.cuedSeq=e.transport.seq,t.opened=e.now,t.state!=="pending"&&(t.begunSeq=e.transport.seq)),t.placing=i,!Number.isNaN(t.pinned)&&t.state==="pending"&&Ko(e,t,t.pinned),s!==void 0&&!e.projecting&&(e.playing.set(s,(e.playing.get(s)??0)+1),e.owner??=_L(new WeakRef(e)),s.owner=e.owner,s.ownerId=t.id);let a=e.cued,l=a.length;for(;l>0&&a[l-1].id>t.id;)l--;a.splice(l,0,t),HF(e,t),t.sharing=e.share?.shares(e,t)===!0,T_(e,t),Kr(e,t),e.stir(),n.from==="current"&&(e.wantsPose=!0),o&&(Yr(e),!Number.isNaN(e.now)&&t.state==="pending"&&Sc(e,t)>=t.start&&Ca(e,t,e.now)),r?.fitting&&Dn(e,r),e.opts.history&&(t.log=[],t.note(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY),t.first??=t.log[0]),it(e,t)}function eq(e,t){let n=e.owners?.find(r=>r.handle===t);if(n===void 0)throw new Error("blits: owner is not a handle mix.owns returned on this mix");if(n.state==="done")throw new Error("blits: that owner has left the mix");return n}var Cm=class{out=new Map;gone=new FinalizationRegistry(t=>{this.out.get(t)?.handle.deref()===void 0&&this.out.delete(t)});add(t,n,r){this.out.set(t,{doneAt:n,handle:new WeakRef(r)}),this.gone.register(r,t)}take(t){let n=this.out.get(t);return this.out.delete(t),n?.handle.deref()}missing(t,n){for(let[r,o]of this.out)if(o.doneAt>t&&!n(r))return r}};function tq(e){return e.spec.as!==void 0&&e.owner===null&&e.holding===null&&e.blend===null&&e.answers===null&&e.fitting===null}function E_(e,t,n){if(!tq(t))return!1;let r=e.keys,o=nq(t,r);rr(e,"voice",t.id,void 0,[{at:t.doneAt,seq:t.doneSeq}],()=>o,n);let i=t.handle;return qr.page(i,{weight:t.weight,played:t.settled.played===!0}),e.outs.add(t.id,t.doneAt,i),e.parters.delete(t),!0}function nq(e,t){let n=s=>t.subject(s),r=[],o=[];for(let s of e.keyed??[]){let a=n(s),l=e.subjects.get(a);l?.reaches&&r.push([s,Yi(e,l)]);let u=e.motion?.pack(a);u!==void 0&&o.push([s,u])}let i=e.settled;return{as:e.spec.as,start:e.start,anchorNow:e.anchorNow,anchorElapsed:e.anchorElapsed,rate:e.rate,ramp:e.ramp,weight:e.weight,out:e.out,back:e.back,stalls:e.stalls,outAt:e.outAt,outOver:e.outOver,outSet:e.outSet,rebuilds:e.rebuilds,hold:e.hold,past:e.clocks?.length??0,earlier:e.earlier,later:e.later,clocks:e.clocks,cuedAt:e.cuedAt,cuedSeq:e.cuedSeq,begunSeq:e.begunSeq,doneAt:e.doneAt,doneSeq:e.doneSeq,opened:e.opened,pinned:e.pinned,offset:e.offset,latest:e.latest,soonest:e.soonest,keeping:e.keeping,first:e.first,log:e.log,played:i.played,playedAt:i.at,playedSeq:i.seq,records:r,runs:o,left:(e.left?.all()??[]).map(s=>[t.key(s.subject),s.at,s.seq,Yi(e,s.held),s.sync,s.ramp,s.parted]),parts:[...e.parts??[]].map(([s,a])=>[t.key(s),a.at,a.over,a.seq]),parted:[...e.parted??[]].map(([s,a])=>a.ramp===void 0?[t.key(s),a.at,a.seq]:[t.key(s),a.at,a.seq,a.ramp])}}function M_(e,t,n){let r=e.opts.history?.revive;if(r===void 0)throw new Error("blits: a paged voice needs history.revive");let o=_T(e,{...r(n.as),as:n.as});DT(e,o);let i=new Wa(t,o,o.patch,o.fade??{},Number.NEGATIVE_INFINITY,n.start,e.slotOf,e.channels,e.opts.host,e.send,null);i.clocks=n.clocks,i.take(n),i.cuedAt=n.cuedAt,i.cuedSeq=n.cuedSeq,i.begunSeq=n.begunSeq??Number.POSITIVE_INFINITY,i.doneAt=n.doneAt,i.doneSeq=n.doneSeq,i.opened=n.opened,i.pinned=n.pinned,i.offset=n.offset??0,i.latest=n.latest,i.soonest=n.soonest??0,i.keeping=n.keeping,i.first=n.first,i.log=n.log,i.state="done",n.played!==void 0&&i.play(n.played,n.playedAt,n.playedSeq),i.resolve();let s=e.keys,a=u=>s.subject(u);i.keyed=new Set;for(let[u,c]of n.records)i.subjects.set(a(u),qi(i,c)),i.keyed.add(u);for(let[u,c]of n.runs)i.motion?.unpack(a(u),c);i.left=Fn.from(n.left.map(([u,c,d,f,p,h=null,m=null])=>({subject:a(u),at:c,seq:d,sync:p,held:qi(i,f),ramp:h,parted:m}))),n.parts.length>0&&(i.parts=new Map(n.parts.map(([u,c,d,f])=>[a(u),{at:c,over:d,seq:f}]))),n.parted.length>0&&(i.parted=new Map(n.parted.map(([u,c,d,f])=>[a(u),{at:c,seq:d,ramp:f??void 0}])));let l=e.outs?.take(t);return l===void 0?i.handle=Ac(e,i):(qr.rehome(l,i),i.handle=l),i}var rq=0;function st(){return++rq}function __(e){return e.stirred||e.anchored>0||e.pins!==null&&e.pins.size>0}function Qr(e,t){e.moving=!0;try{oq(e,t)}finally{e.moving=!1}}function oq(e,t){e.now=t,e.looked=!1,e.unshared&&(e.unshared=!1,$o(e)),e.frame=st(),e.reducedNow=e.reduced;for(let i of e.announced)Number.isNaN(i.at)&&(i.at=e.u);if(e.waking&&uq(e,t),e.pins!==null&&e.pins.size>0&&NL(e),e.anchored>0&&Yr(e),e.announced.length>0){let i=e.opts.history===void 0?t:e.transport.keepsFrom();e.announced=e.announced.filter(s=>Zi(e,s.at)>=i)}let n=e.projecting||e.walkAll?e.cued:SF(e,t),r=null;for(let i of n)i.state!=="done"&&Oc(e,i,t,i.owner!==null&&i.owner.fitting!==null)&&(r??=[],r.push(i));let o=e.leapt===null&&r===null?null:iq(e,r,t);e.leapt=null,o===null?D_(e,r,t):sq(e,o,r,t),e.sharers.length>0&&!e.projecting&&e.share?.outgrow(e),e.stirred=!1,e.asleep=!1,e.retired.length>0&&hq(e),yq(e)}function D_(e,t,n){t!==null&&aq(e,t,n),e.owners!==null&&(G_(e,n),U_(e,n))}function iq(e,t,n){let r=null;if(e.leapt!==null)for(let o of e.leapt)r=C_(o,n,r);if(t!==null)for(let o of t)r=C_(o.owner,n,r);return r}function C_(e,t,n){for(let r=e;r!==null;r=r.owner)r.state==="done"||r.owner?.fitting||n?.includes(r)||r.rateAt(r.owner===null?t:Te(r.owner,t))>0||(n??=[],n.push(r));return n}function sq(e,t,n,r){let o=t.map(i=>{let{anchorNow:s,anchorElapsed:a,rate:l,ramp:u,start:c}=i,d=i.owner===null?r:Te(i.owner,r);return i.anchorElapsed=Ke(i,d),i.anchorNow=d,i.rate=1,i.ramp=null,i.start=d-i.anchorElapsed,{anchorNow:s,anchorElapsed:a,rate:l,ramp:u,start:c,logged:i.log?.length??0}});try{if(e.anchored>0){Yr(e);for(let i of t)Ji(i,s=>{s.state==="pending"&&s.spec.anchor!==void 0&&s.owner?.fitting===null&&Oc(e,s,r)})}D_(e,n,r)}finally{t.forEach((i,s)=>{let{logged:a,...l}=o[s];Object.assign(i,l);let u=i.log;if(u!==null)for(let c=a;c<u.length;c++)Object.assign(u[c],l)})}e.frame=st();for(let i of t)i.state!=="done"&&it(e,i),Ji(i,s=>{s.state!=="done"&&(dn(e,s,r),it(e,s))});e.lanes?.refill()}function Oc(e,t,n,r=!1){Number.isNaN(t.opened)&&(t.opened=n),(t.earlier!==null||t.later!==null)&&GT(e,t,n);let o=t.owner===null?n:Te(t.owner,n);if(r&&H_(t,o,n))return!0;if(t.state==="pending"&&B_(t,o,n)&&Ca(e,t,n),(t.state==="live"||t.state==="frozen")&&t.outAt<=n&&!(t.state==="live"&&!t.freezesAfter&&!t.freezesBefore&&t.endsAt()<t.outAt)&&Zr(e,t,{over:Number.isNaN(t.outOver)?void 0:t.outOver},Math.max(Uo(t),t.outAt)),t.state!=="pending"){t.turns&&cq(e,t,n),t.state==="live"&&t.out!==null&&!t.quietAt(n)&&zT(e,t,n);let s=Math.sign(t.rateAt(o))*(t.owner===null?1:HT(t.owner,n)),a=o===Number.NEGATIVE_INFINITY?o:Ke(t,o),l=s<0,u=!t.beginless&&a<=t.soonest,c=t.holding!==null&&jr(t,n);(l?u&&!c:Number.isFinite(t.span)&&a>=t.span+t.latest)?(t.play(!0,n,e.transport.seq),t.state==="live"&&t.out===null&&((l?t.freezesBefore:t.freezesAfter)?t.state="frozen":Zr(e,t,{back:l,stays:t.owner!==null&&e.opts.history!==void 0},Math.max(_n(t),Math.min(n,t.endsAt()))))):t.state==="frozen"&&!(u&&s===0)&&(t.state="live")}if(t.parts!==null&&!e.projecting)for(let[s,a]of t.parts)n-a.at>=a.over&&WT(e,t,s,a.at+a.over);let i=t.back;if(i!==null&&n>=i.at+(1-i.from)*i.over&&!e.projecting&&(t.back=null,e.lanes?.refill()),t.state==="fading"&&t.out){let{at:s,over:a,rest:l,deadline:u}=t.out,c=n-s;if(l){let d=u!==void 0&&c>=u,f=t.seen>0&&t.restedCount>=t.seen;d?Bn(e,t,s+u):f&&Bn(e,t)}else c>=a&&(t.out.stays?VT(e,t,s+a):Bn(e,t,s+a))}return e.projecting||it(e,t),!1}function B_(e,t,n){return t>e.start||t===e.start&&(e.owner===null||HT(e.owner,n)>=0)}function BT(e,t,n){return(t.earlier!==null||t.later!==null)&&GT(e,t,n),H_(t,Te(t.owner,n),n)}function H_(e,t,n){if(e.state==="pending")return B_(e,t,n);if(e.state!=="live")return!1;let r=e.out;if(e.fitting!==null)return r===null&&UT(e,n);if(!Number.isFinite(e.span)||r!==null&&!(r.stays===!0&&r.back===!0))return!1;let o=t===Number.NEGATIVE_INFINITY?t:Ke(e,t),i=r===null?e.span+e.latest:e.soonest;return o>i||o===i&&HT(e,n)>0}function aq(e,t,n){let r=t.length===1?t[0]:null;if(r!==null&&r.state==="pending"&&r.holding===null&&(Ca(e,r,n),!BT(e,r,n))){Oc(e,r,n);return}let o=t,i=[];for(;;){let s,a=Number.POSITIVE_INFINITY;for(let l=0;l<o.length;l++){let u=o[l];if(u.state==="done"||i.includes(u)||!BT(e,u,n))continue;let c=u.state==="pending"?_n(u):u.fitting!==null?lq(u):u.out!==null?u.reaches(u.soonest):u.endsAt();(s===void 0||c<a||c===a&&F_(u)<F_(s))&&(s=u,a=c)}if(s===void 0)break;if(s.state==="pending")Ca(e,s,n),s.holding!==null&&O_(e,s,n,o,i);else if(s.out!==null)zT(e,s,n);else{i.push(s),s.fitting!==null?Fc(e,s,a):Oc(e,s,n);for(let l=s.owner;l?.fitting;l=l.owner)O_(e,l,n,o,i)}}ji(o);for(let s=0;s<o.length;s++){let a=o[s];!i.includes(a)&&a.state!=="done"&&Oc(e,a,n)}}function lq(e){return e.timeAt(e.fitting.budget)}function O_(e,t,n,r,o){let i=t.holding.children;for(let s=0;s<i.length;s++){let a=i[s];a.state!=="done"&&!o.includes(a)&&!r.includes(a)&&BT(e,a,n)&&r.push(a)}}function F_(e){return(e.state==="pending"||e.out!==null?2**40:0)+e.id}function uq(e,t){e.waking=!1;for(let n of e.cued){if(!n.waking||(n.waking=!1,n.state!=="pending"))continue;_a(e,n,t);let r=n.first;r!==null&&(r.start=t,r.anchorNow=t),e.projecting||it(e,n)}}function HT(e,t){let n=1;for(let r=e;r!==null;r=r.owner)n*=Math.sign(r.rateAt(r.owner===null?t:Te(r.owner,t)));return n}function cq(e,t,n){let r=t.ramp,o=t.anchorNow+r.over*r.from/(r.from-r.to);(t.owner===null?n:Te(t.owner,n))<o||(Go(t,o),t.anchorElapsed=Ke(t,o),t.ramp={from:0,to:r.to,over:t.anchorNow+r.over-o},t.anchorNow=o,je(e,t))}var dq=8,fq=32,pq=4;function hq(e){let t=e.retired;e.retired=[];let n=e.cued,r=null;if((t.length<=dq||t.length*fq<=n.length)&&!e.projecting){ji(t),r=[];for(let i=0;i<t.length;i++){let s=t[i],a=s===t[i-1]?-1:mq(n,s);if(a<0){r=null;break}r.push(a)}}let o=!1;if(r!==null){for(let i of t)o=L_(e,i)||o;if(r.length<=pq)for(let i=r.length-1;i>=0;i--)n.splice(r[i],1);else{let i=r[0],s=0;for(let a=i;a<n.length;a++)r[s]===a?s++:n[i++]=n[a];n.length=i}}else{let i=0;for(let s=0;s<n.length;s++){let a=n[s];a.state!=="done"?n[i++]=a:o=L_(e,a)||o}n.length=i}o&&(e.general=e.general.filter(i=>i.state!=="done"),e.sharers.length>0&&(e.sharers=e.sharers.filter(i=>i.state!=="done")),$o(e))}function mq(e,t){let n=0,r=e.length-1;for(;n<=r;){let o=n+r>>>1,i=e[o].id;if(i===t.id)return e[o]===t?o:-1;i<t.id?n=o+1:r=o-1}return-1}function L_(e,t){return GF(e,[t]),e.opts.history?(e.gone.push(t),rm(e,t)):(e.parters.delete(t),e.departed.add(e,t)),LL(e,t),Kr(e,t),S_(e,t),t.named===null}function yq(e){let t=e.opts.history;if(t&&e.gone.length>0)if(e.transport.pager!==null){let n=e.now-t.ms;bT(e,r=>r.reachedTo>=n||!E_(e,r,n))}else pL(e,e.transport.keepsFrom())}var Om=class{budget;claim;fit;spill;end;report;constructor(t){let n=t.duration??Number.POSITIVE_INFINITY;if(!(n>=0))throw new Error("blits: a span lasts 0 ms or more");let r=t.share??.5;if(!(r>=0&&r<=1))throw new Error("blits: a span staggers by a share in 0..1");this.budget=n,this.claim={budget:n,priority:t.priority??"strong",order:t.order??"queue",share:r},this.fit=t.fit??mF,this.spill=t.spill??"instant",this.end=Number.isFinite(n)?n:0,this.report={budget:n,length:0,over:0,skipped:0,fell:!1}}};function I_(e,t){if(e.start!==void 0||e.anchor?.start!==void 0||e.anchor?.in!==void 0)throw new Error("blits: a span places the voices it holds, so one takes no start of its own");if(t.arc!==null){if(!Number.isFinite(Dc(t)))throw new Error("blits: a span cannot fit an arc held open, which never ends")}else if(t.holding!==null){if(t.fitting===null)throw new Error("blits: a span holds voices, spans and arcs, not owners")}else if(!Number.isFinite(t.span))throw new Error("blits: a span cannot fit a voice that never ends")}function gq(e,t){for(let n of e.holding.children)if(n.out?.stays===!0&&(n.out.back===!0||n.start>t))return!0;return!1}function GT(e,t,n){let r=Te(t.owner,n),o=!1;for(let i=t.earlier;i!==null&&r<t.anchorNow;i=t.earlier)t.later={...KT(t),prev:t.later},W_(t,i),t.earlier=i.prev,o=!0;for(let i=t.later;i!==null&&r>=i.anchorNow;i=t.later)t.earlier={...KT(t),prev:t.earlier},W_(t,i),t.later=i.prev,o=!0;o&&(e.frame=st(),dn(e,t,n),je(e,t),e.lanes?.refill())}function KT(e){let{anchorNow:t,anchorElapsed:n,rate:r,ramp:o,skipped:i}=e;return{anchorNow:t,anchorElapsed:n,rate:r,ramp:o,skipped:i}}function W_(e,t){e.anchorNow=t.anchorNow,e.anchorElapsed=t.anchorElapsed,e.rate=t.rate,e.ramp=t.ramp,e.skipped!==t.skipped&&e.seeks++,e.skipped=t.skipped}function bq(e,t){if(Number.isNaN(t))return 0;let n=V_(e,t);return Number.isFinite(n)?Math.max(0,n):0}function V_(e,t){let n=e.owner===null?t:V_(e.owner,t);return n===Number.NEGATIVE_INFINITY||e.state==="pending"&&!(n>=e.start)?Number.NEGATIVE_INFINITY:Ke(e,n)}function Lc(e,t){return e.state!=="pending"||e.start<t}function xq(e,t,n){return Lc(e,n)?Math.max(0,Ke(e,t)):0}function z_(e,t,n){let r=e.fitting!==null?e.fitting.end:e.arc!==null?Dc(e):e.span;return Math.max(0,r-xq(e,t,n))}function Dn(e,t,n=e.now){let r=t.fitting;if(e.projecting||t.state==="done")return;let o=bq(t,n);if(gq(t,o))return;let i=n<e.now?o:Number.NEGATIVE_INFINITY,{kids:s,floors:a,waiting:l}=wq(e,t,o,i),u=s.map((P,S)=>{let v=P.spec;return{floor:a[S],natural:z_(P,o,i)/(v.rate??1),state:Lc(P,i)?"playing":"pending",faster:Math.max(1,v.faster??1),slower:Math.max(1,v.slower??1),overlap:v.overlap===!0,ballast:v.ballast===!0&&P.holding===null,priority:v.priority??"weak"}}),c={...r.claim,left:r.budget-o},{plan:d,fell:f}=yF(c,u,r.fit,r.spill),{at:p,length:h}=JP(c,u,d);s.forEach((P,S)=>{let v=(P.spec.rate??1)*d.rate[S],A=d.skip[S]&&P.holding===null,N=P.skipped;P.skipped=A;let M=!1;if(Lc(P,i))(A||P.rate!==v||P.ramp!==null)&&(P.earlier={...KT(P),skipped:N,prev:P.earlier},P.later=null),A&&(Go(P,o),P.rebase(o),P.anchorElapsed=P.span,P.seeks++,M=!0),(P.rate!==v||P.ramp!==null)&&(Go(P,o),ka(P,o,v,0),M=!0);else{let C=o+p[S],F=A?P.span:0;(P.start!==C||P.rate!==v||P.anchorElapsed!==F||P.ramp!==null)&&(P.start=C,P.anchorNow=C,P.anchorElapsed=F,P.rate=v,P.ramp=null,P.clocks=null,P.earlier=null,P.later=null,M=!0)}M&&(e.frame=st(),dn(e,P,e.now),je(e,P))});for(let P of l)P.start!==Number.POSITIVE_INFINITY&&(P.start=Number.POSITIVE_INFINITY,P.anchorNow=Number.POSITIVE_INFINITY,P.anchorElapsed=0,P.clocks=null,P.earlier=null,P.later=null,e.frame=st(),dn(e,P,e.now),je(e,P));s.length>0&&e.lanes?.refill();let m=o+h,y=Number.isFinite(r.budget)?Math.max(0,m-r.budget):0,b=y<1e-6,x=Number.isFinite(r.budget)&&b?r.budget:m,w=r.report,g={budget:r.budget,length:m,over:b?0:y,skipped:d.skip.filter((P,S)=>P&&s[S]?.holding===null).length,fell:f};r.report=g,x!==r.end?(r.end=x,je(e,t),t.owner?.fitting&&Dn(e,t.owner,n)):(g.length!==w.length||g.over!==w.over||g.skipped!==w.skipped||g.fell!==w.fell)&&je(e,t)}function wq(e,t,n,r){let o=(t.holding?.children??[]).filter(c=>c.state!=="done"&&c.state!=="frozen"&&c.out===null&&z_(c,n,r)>0),i=o.filter(c=>Lc(c,r)),s=i.map(()=>{}),a=[],l=o.filter(c=>!Lc(c,r)).sort((c,d)=>(c.spec.rank??0)-(d.spec.rank??0)),u=t.fitting.claim.order!=="together";for(let c of l){let d=c.spec.earliest,f=d===void 0?void 0:La(e,d,c,Number.NEGATIVE_INFINITY);if(c.floorSeen=f??Number.NaN,d!==void 0&&f===void 0||u&&a.length>0){a.push(c);continue}i.push(c);let p=f===void 0||f===Number.NEGATIVE_INFINITY?void 0:f-n;s.push(p===void 0||c.cuedSeq===e.transport.seq?p:Math.max(0,p))}return{kids:i,floors:s,waiting:a}}function EL(e){if(!e.projecting)for(let t of e.owners??[]){if(t.fitting===null||t.state==="done")continue;(t.holding?.children??[]).some(r=>{let o=r.spec.earliest;if(r.state!=="pending"||o===void 0||typeof o=="number")return!1;let i=La(e,o,r,Number.NEGATIVE_INFINITY)??Number.NaN;return!Object.is(i,r.floorSeen)})&&Dn(e,t)}}function _c(e,t){let n=e.fitting;return n!==null&&Number.isFinite(n.budget)&&Te(e,t)<n.budget}function G_(e,t){let n=e.owners??[];for(let r=n.length-1;r>=0;r--){let o=n[r];o.out?.stays!==!0&&UT(o,t)&&Fc(e,o,o.timeAt(o.fitting.budget))}}function UT(e,t){let n=e.fitting;return n===null||e.state==="done"||!Number.isFinite(n.budget)?!1:!jr(e,t)&&Te(e,t)>=n.budget}var fn=Object.freeze([]),Pq=()=>{},K_=new WeakMap;function Tq(e,t,n){if(e.length!==1)return j_(e,t,n);let r=K_.get(t);r===void 0&&(r=new Map,K_.set(t,r));let o=e[0],i=r.get(o);return i===void 0&&(i=j_(e,t,n),r.set(o,i)),i}function j_(e,t,n){let r=e.map(o=>t.get(o));return{slots:r,lerps:r.map(o=>n[o].lerp)}}var Wa=class e{id;spec;patch;fade;start;owner;state="pending";rate;weight;anchorNow;anchorElapsed=0;ramp=null;out=null;back=null;stalls=null;subjects=new me;named;slots;built;lerps;intos;scratch=[];holder=null;laned=!1;seat=null;seeks=0;written=!1;touches=0;get jumps(){return this.seeks-this.touches}rebuilds=0;skipped=!1;floorSeen=Number.NaN;keeping=!1;parts=null;parted=null;left=null;ease;passes;duration;span;motion;beginless;freezesBefore;freezesAfter;opened=Number.NaN;unchecked=!0;dueToken=0;early=null;clocks=null;earlier=null;later=null;setting;seen=0;latest=0;soonest=0;restedCount=0;parked=!1;cuedAt=Number.NEGATIVE_INFINITY;cuedSeq=Number.NEGATIVE_INFINITY;begunSeq=Number.POSITIVE_INFINITY;doneAt=Number.POSITIVE_INFINITY;doneSeq=Number.POSITIVE_INFINITY;decidedAt=Number.NEGATIVE_INFINITY;get reachedTo(){return this.doneAt>this.decidedAt?this.doneAt:this.decidedAt}log=null;first=null;outAt=Number.POSITIVE_INFINITY;outOver=Number.NaN;outSet=!1;pinned=Number.NaN;offset=0;waking=!1;placing=!1;answers=null;folds=null;keepOn=null;ownKept=null;blend=null;spares=null;unreached=null;unreachedBits=null;sharing=!1;bound=null;shared=0;everyone=null;sighted=null;weights=null;stamps=null;deltas=null;handle=null;keyed=null;holding;fitting=null;arc=null;hold=0;part=-1;finished=!1;playedAs=void 0;playedAt=Number.NaN;playedSeq=Number.NaN;donePromise=null;doneSettle=null;playedPromise=null;playedSettle=null;quiet=!1;get done(){return this.donePromise===null&&(this.donePromise=this.finished?Promise.resolve():new Promise(t=>{this.doneSettle=t})),this.donePromise}get played(){if(this.playedPromise===null){let t=this.playedAs;this.playedPromise=t!==void 0?Promise.resolve(t):new Promise(n=>{this.playedSettle=n})}return this.playedPromise}resolve(){this.quiet||this.finished||(this.finished=!0,this.doneSettle?.())}play(t,n,r){this.quiet||this.playedAs!==void 0||(this.playedAs=t,this.playedAt=n,this.playedSeq=r,this.playedSettle?.(t),t&&this.owner!==null&&JF(this.owner,n,r))}get settled(){return{played:this.playedAs,at:this.playedAt,seq:this.playedSeq}}get passed(){return this.playedAs===!0}get unplayed(){return this.playedAs===!1}reopen(t){let n=!1;return this.playedAs!==void 0&&!(this.playedSeq<=t)&&(n=this.playedAs,this.playedAs=void 0,this.playedPromise=null,this.playedSettle=null),this.finished&&!(this.doneSeq<=t)&&(this.finished=!1,this.donePromise=null,this.doneSettle=null),n}take(t){this.anchorNow=t.anchorNow,this.anchorElapsed=t.anchorElapsed,this.rate=t.rate,this.ramp=t.ramp,this.weight=t.weight,this.out=t.out,this.back=t.back,this.stalls=t.stalls??null,this.start=t.start,this.outAt=t.outAt,this.outOver=t.outOver,this.outSet=t.outSet,this.rebuilds=t.rebuilds,this.hold=t.hold,this.earlier=t.earlier??null,this.later=t.later??null;let n=t.fitted;n&&this.fitting!==null&&(this.fitting.end=n.end,this.fitting.report=n.report);let r=this.clocks;r!==null&&r.length!==t.past&&(this.clocks=t.past===0?null:r.slice(0,t.past))}park(){this.reopen(Number.NEGATIVE_INFINITY),this.take(this.first),this.parked=!0,this.log=null,this.state="pending",this.subjects=new me,this.scratch=[],this.holder=null,this.laned=!1,this.seeks++,this.keeping=!1,this.parts=null,this.parted=null,this.opened=Number.NaN,this.dueToken++,this.early=null,this.seen=0,this.latest=this.named?.latest??0,this.soonest=this.named?.soonest??0,this.restedCount=0,this.cuedAt=Number.NEGATIVE_INFINITY,this.cuedSeq=Number.NEGATIVE_INFINITY,this.begunSeq=Number.POSITIVE_INFINITY,this.doneAt=Number.POSITIVE_INFINITY,this.doneSeq=Number.POSITIVE_INFINITY,this.placing=!1,this.answers=null,this.folds=null,this.keepOn=null,this.ownKept=null,this.unreached=null,this.unreachedBits=null,this.sharing=!1,this.everyone=null,this.sighted=null,this.weights=null,this.stamps=null,this.deltas=null,this.holding!==null&&(this.holding=new Wo)}constructor(t,n,r,o,i,s,a,l,u,c,d){this.id=t,this.spec=n,this.patch=r,this.fade=o,this.start=s,this.owner=d,this.holding=r===Xi?new Wo:null;let f=Tq(r.writes,a,l);this.slots=f.slots,this.named=n.subjects?new sm(n.subjects,n.stagger):null,this.latest=this.named?.latest??0,this.soonest=this.named?.soonest??0,this.built=r.form==="keys"&&r.keys?iL(r):null,this.lerps=f.lerps,this.intos=this.built?oL(this.built,this.slots.map(y=>l[y])):void 0,this.ease=o.ease===void 0?void 0:Bo(o.ease),this.passes=qO(n.loop),this.duration=r.duration,this.span=this.duration>0&&Number.isFinite(this.passes)?this.duration*this.passes:Number.POSITIVE_INFINITY,this.motion=Ln(r);let p=this.motion===void 0?n.freeze:void 0,h=p===void 0&&this.motion===void 0&&d!==null;this.freezesBefore=h?d.freezesBefore:p==="before"||p==="both",this.freezesAfter=h?d.freezesAfter:p==="after"||p==="both",this.setting=new fm(u,c,this),this.rate=n.rate??1,this.weight=typeof n.weight=="number"?n.weight:1;let m=!Number.isFinite(this.span);this.beginless=this.rate<0&&m&&this.motion===void 0,this.anchorNow=s,this.anchorElapsed=n.seek??(this.rate<0&&!m?this.span:0),i>=s&&(this.state="live")}elapsedAt(t){return this.owner===null?Ke(this,t):YF(this,this.owner,t)}timeAt(t){let n=Cn(this,t);return this.owner===null?n:Vo(this.owner,n)}get backs(){let t=this.ramp;return t===null?this.rate<0:t.from<=0&&t.to<=0&&(t.from<0||t.to<0)}get turns(){let t=this.ramp;return t!==null&&t.from*t.to<0}endsAt(){if(this.turns)return Number.POSITIVE_INFINITY;let t=this.backs,n;if(t!==(this.owner!==null&&lm(this))){if(this.beginless)return Number.POSITIVE_INFINITY;n=this.soonest}else{if(!Number.isFinite(this.span))return Number.POSITIVE_INFINITY;n=this.span+this.latest}return this.reaches(n)}reaches(t){let n=this.backs?mc(this,t):Cn(this,t);return this.owner===null?n:Vo(this.owner,n)}stateAt(t,n){let r=this.out;return r!==null?r.stays&&t>=r.at+r.over?"live":"fading":(this.owner===null?t:Te(this.owner,t))<this.start&&!(n!==void 0&&qt(n,this.begunSeq,!0))?"pending":this.freezesAfter&&this.elapsedAt(t)>=this.span+this.latest?"frozen":"live"}quietAt(t){let n=this.out;if(this.state!=="live"||n?.stays!==!0)return!1;if(this.holding!==null&&n.back!==!0)return!jr(this,t)&&!_c(this,t);if(this.skipped&&Te(this.owner,t)<this.start)return!0;let r=this.elapsedAt(t),o=this.span+this.latest,i=this.backs!==(this.owner!==null&&lm(this));return r>o||r===o&&!i?!0:!this.beginless&&(r<this.soonest||r===this.soonest&&i)}ranBackTo(t,n){if(this.beginless||!this.backs||this.owner!==null)return Number.NaN;let r=mc(this,t);return r>=this.anchorNow&&r<=n?r:Number.NaN}unstarted(t){let n=this.state;return n==="pending"?!0:n!=="fading"?!1:!((this.owner===null?t:Te(this.owner,t))>=this.start)}rawAt(t,n){return(this.unstarted(t)?this.anchorElapsed:this.elapsedAt(t))-n}before(t,n){return!(t>=0)&&!this.beginless||this.unstarted(n)}get holdsFirst(){return this.freezesBefore||this.out?.back===!0}get hidesPast(){return!this.freezesAfter&&this.backs!==(this.owner!==null&&lm(this))}shownAt(t){return this.beginless?t:t>this.span&&this.hidesPast?Number.NaN:Kh(t,this.holdsFirst,this.freezesAfter,this.span)}note(t,n,r=!1){this.log?.push({at:t,seq:n,sync:r,anchorNow:this.anchorNow,anchorElapsed:this.anchorElapsed,rate:this.rate,ramp:this.ramp,weight:this.weight,out:this.out,back:this.back,stalls:this.stalls,start:this.start,outAt:this.outAt,outOver:this.outOver,outSet:this.outSet,rebuilds:this.rebuilds,hold:this.hold,past:this.clocks?.length??0,earlier:this.earlier,later:this.later,fitted:this.fitting===null?null:{end:this.fitting.end,report:this.fitting.report}})}copy(t,n,r=!1){let o={__proto__:e.prototype,...this},i=o;i.subjects=new Qh(t),i.setting={...this.setting,keep:hT(o),send:Pq},o.keepOn=null,o.ownKept=null,o.scratch=[],o.holder=null,o.laned=!1,o.seat=null,o.log=null,o.early=null,n&&o.take(n),o.clocks===this.clocks&&o.clocks!==null&&(o.clocks=o.clocks.slice()),o.quiet=!0,o.unreached=null,o.unreachedBits=null;let s=r&&this.sharing?this.everyone:null;return o.sharing=s!==null,o.everyone=s===null?null:{...s,delta:null,probed:Number.NaN,from:s.stepped},o.sighted=null,o.weights=null,o.stamps=null,o.deltas=null,o}rateAt(t){return Sa(this,t)}rebase(t){KP(this,t)}};function $_(e,t){if(e.unchecked=!1,t===null||typeof t!="object")return;let n=e.patch.writes;for(let r in t)n.includes(r)||tr(e.patch,`${e.spec.name??`voice ${e.id}`}'s patch returns ${r} from at(), which is not in its writes, so the mix drops it`)}function Va(e,t,n){return e[jT(e,t,n)]}function jT(e,t,n){let r=0,o=e.length-1,i=-1;for(;r<=o;){let s=r+o>>1,a=e[s];a.at<t||a.at===t&&(typeof n=="function"?n(a):n)?(i=s,r=s+1):o=s-1}return i}function Bc(e,t){let n=0,r=e.length-1,o;for(;n<=r;){let i=n+r>>1,s=e[i];qt(t,s.seq,s.sync)?(o=s,n=i+1):r=i-1}return o}function Y_(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let o of n)if(!Y_(e[o],t[o]))return!1;return!0}function $T(e,t,n){let r=t.log,o=r===null?void 0:Va(r,n,!0);return Ke(o??t,t.owner===null?n:Sq(e,t.owner,n))}function Sq(e,t,n){return $T(e,t,n)}function je(e,t){Ia(e,t,!0),e.stir(),it(e,t);let n=t.log;if(n===null)return;t.note(Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,e.transport.seq,e.moving||!e.looked);let r=e.now-e.opts.history.ms,o=0;for(;o+1<n.length&&n[o+1].at<=r;)o++;o>0&&rr(e,"controls",t.id,void 0,n.splice(0,o),kq,r)}var kq=e=>({...e}),vq=Object.freeze([]);function q_(e,t){let n=X_(e,t);return n===0?vq:e.splice(0,n)}function X_(e,t){let n=0;for(;n+1<e.length&&e[n+1].at<=t;)n++;return n}function za(e,t){let n=e.patch;return n.clone?n.clone(t):bt(t)}function qo(e,t,n=!1){let r=J_(t);return Ka({reaches:t.reaches,delay:t.delay,since:t.since,shown:t.shown,weight:t.weight,restedAt:t.restedAt,bands:t.bands===null?null:t.bands.slice(),state:t.state===void 0||n?t.state:za(e,t.state),stepped:t.stepped,ticks:t.ticks,probed:t.probed,delta:t.delta,phase:t.phase,seeks:t.seeks,rebuilt:t.rebuilt,copied:t.copied,base:t.base===void 0?void 0:bt(t.base),slope:t.slope===void 0?void 0:bt(t.slope),kept:r,unkept:t.unkept?.map(bt),snaps:t.snaps,from:t.from,unknown:t.unknown,inputs:t.inputs,replay:t.replay,voice:t.voice,next:t.next,version:t.version,roles:t.roles,slot:t.slot,run:t.run,freed:t.freed,restored:null})}function J_(e){if(e.kept===null)return null;let t=new Map;for(let[n,r]of e.kept)t.set(n,bt(r));return t}function YT(e,t,n,r=!1){return n.reaches=t.reaches,n.delay=t.delay,n.since=t.since,n.shown=t.shown,n.weight=t.weight,n.restedAt=t.restedAt,n.bands=t.bands===null?null:t.bands.slice(),n.state=t.state===void 0||r?t.state:za(e,t.state),n.stepped=t.stepped,n.ticks=t.ticks,n.rebuilt=t.rebuilt,n.copied=t.copied,n.base=t.base===void 0?void 0:bt(t.base),n.slope=t.slope===void 0?void 0:bt(t.slope),n.kept=J_(t),n.unkept=t.unkept?.map(bt),n.from=t.from,n.unknown=t.unknown,n.replay=t.replay,n.voice=t.voice,n.slot=t.slot,n.run=t.run,n.freed=t.freed,n.restored=null,Ka(n)}function Ka(e){return e.probed=Number.NaN,e.delta=null,e.phase=0,e.seeks=0,e.snaps=void 0,e.inputs=void 0,e.next=null,e.version=Number.NaN,e.roles=null,e}function Q_(e,t){let n=e.hostLog,r=n[n.length-1],o=e.transport.seq;if(r!==void 0&&r.seq===o)return;let i=e.opts.host,s={};for(let l of e.cued)for(let u of l.patch.reads??fn)u in s||(s[u]=bt(i[u]));if(r!==void 0&&Y_(r.fields,s))return;n.push({at:t,seq:o,fields:s});let a=t-e.opts.history.ms;rr(e,"host",void 0,void 0,q_(n,a),l=>l.fields,a)}function Fm(e,t,n,r,o){let i=e.opts.history;if(!i?.inputs||e.projecting)return;let s=r.inputs??[];r.inputs=s;let a=s[s.length-1];if(a!==void 0&&(a.value===o||a.at===e.now)){a.at===e.now&&(a.value=o);return}s.push({at:e.now,seq:e.transport.seq,value:o});let l=e.now-i.ms,u=q_(s,l);u.length>0&&rr(e,"input",t.id,e.keys?.key(n),u,c=>c.value,l)}function Hc(e){return e.every??200}function Aq(e,t,n,r){let o=t.spares?.pop()??r;return o===void 0?{at:e.now,seq:e.transport.seq,held:qo(t,n)}:(o.at=e.now,o.seq=e.transport.seq,YT(t,n,o.held),o)}function Pm(e,t,n,r){let o=e.opts.history;if(!o||e.projecting||t.patch.step===void 0&&(r.kept===null||r.kept.size===0)&&r.base===void 0)return;let i=r.snaps??[];r.snaps=i;let s=i[i.length-1];if(s!==void 0&&e.now-s.at<Hc(o))return;let a=e.now-o.ms,l=X_(i,a),u;l>0&&(e.transport.pager!==null&&rr(e,"snap",t.id,e.keys?.key(n),i.slice(0,l),c=>Yi(t,c.held),a),u=Rq(i,l),l===1?i.shift():i.splice(0,l)),i.push(Aq(e,t,r,u))}function Rq(e,t){for(let n=0;n<t;n++){let r=e[n];if(!r.shared)return r.ahead=void 0,r}}function Lm(e,t,n,r){let o=e.opts.history;if(o===void 0||r===void 0)return;let i=e.now-o.ms,s=t.left??new Fn;t.left=s;let a=e.keys;s.expire(i,a===null?null:l=>rr(e,"left",t.id,a.key(l.subject),[l],u=>[Yi(t,u.held),u.sync,u.ramp,u.parted],i)),s.push({subject:n,at:Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now,seq:e.transport.seq,sync:e.syncing||!e.looked,held:r,ramp:t.parts?.get(n)??null,parted:t.parted?.get(n)??null})}function _m(e){let t=e.opts.history;return t===void 0||Number.isNaN(e.now)?[]:[e.now,e.now-t.ms,e.transport.seq,e.syncing||!e.looked]}function UL(e,t,n,r){if(t.state==="done"||t.parted?.has(n)||t.parts?.has(n))return;e.share?.unshare(e,t),e.stir();let o=e.reduced?0:r??t.fade.out??0,i=Number.isNaN(e.now)?_n(t):e.now;if(o===0){WT(e,t,n,i);return}t.parts??=new Map,t.parts.set(n,{at:i,over:o,seq:e.transport.seq}),e.parters.add(t),it(e,t),e.lanes?.refill()}function Z_(e,t,n){let r=e.parts?.get(t);if(r===void 0)return 1;let o=this.reducedNow,i=Ta(0,{at:r.at,over:r.over,rest:!1},e.ease,o,n,0),s=e.fade.in??0,a=e.subjects.get(t)?.shown;if(!(s>0)||o||a===void 0||!(r.at<n))return i;let l=e.out,u=zh(s,l,e.ease,n,a,e.stalls);return u>0?i*(zh(s,l,e.ease,n,a,e.stalls,r.at)/u):i}function WT(e,t,n,r){let o=t.parts?.get(n);t.parts?.delete(n),t.parts?.size===0&&(t.parts=null),t.parted??=new Map,t.parted.set(n,{at:r,seq:e.transport.seq,ramp:o}),e.parters.add(t),eD(e,t,n);let i=t.motion;i!==void 0&&tD(e,i,t)&&i.release(n,..._m(e))}function vT(e,t,n){if(t.parted?.has(n)!==!0)return;t.subjects.get(n)===void 0&&qT(e,t,n),eD(e,t,n),t.parted.delete(n),t.parted.size===0&&(t.parted=null);let r=ut(e,n)?.slot??-1;r>=0&&e.lanes?.rejoin(r)}function qT(e,t,n){let r=t.subjects.get(n);r!==void 0||t.parted?.has(n)!==!0?Lm(e,t,n,r):Lm(e,t,n,t.unreached??e.unreachedOf(t,e.now))}function Dm(e,t,n){for(let r of t){let o=r.parted;if(o!==null&&o.seq<=n){e.parted??=new Map,e.parted.set(r.subject,o);continue}let i=r.ramp??o?.ramp;i==null||i.seq>n||(e.parts??=new Map,e.parts.set(r.subject,i))}}function eD(e,t,n){let r=ut(e,n);r!==void 0&&r.slot>=0&&($r(t,r.slot,!1),e.share?.unsight(t,r.slot));let o=t.subjects.get(n);o!==void 0&&(Lm(e,t,n,o),t.subjects.delete(n),o.reaches&&t.seen--,Ho(o)&&t.restedCount--,t.holder===o&&(t.holder=null)),r!==void 0&&(bc(e,r),t.laned&&r.slot>=0&&e.lanes?.part(t.id,r.slot),e.lanes?.refill())}function Zr(e,t,n,r){if(t.state==="done"||t.state==="fading")return;let o=e.reduced?0:n.over??t.fade.out??0,i=t.state==="pending";i&&Kr(e,t),n.at==="rest"&&(e.share?.unshare(e,t),t.seeks++),t.state="fading",t.out={from:1,at:r??(Number.isNaN(e.now)?_n(t):e.now),over:o,rest:n.at==="rest",deadline:n.deadline},n.back&&(t.out.back=!0),n.stays&&(t.out.stays=!0),je(e,t),n.at==="rest"||n.back||i?e.lanes?.invalidate():e.lanes?.refill(),o===0&&n.at!=="rest"&&(n.stays?VT(e,t,t.out.at):Bn(e,t,t.out.at))}function VT(e,t,n){t.state="live",e.lanes?.refill();let r=t.owner;if(r.state==="done")return;let o=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now;jr(r,o)||_c(r,n)?r.fitting!==null&&!t.skipped&&Dn(e,r,n):Fc(e,r,n)}function Fc(e,t,n){t.owner!==null&&t.state==="live"&&e.opts.history!==void 0?Zr(e,t,{over:0,stays:!0},n):Bn(e,t,n)}function WL(e,t,n){let r=t.out;if(t.state!=="fading"&&t.outSet){t.outAt=Number.POSITIVE_INFINITY,t.outOver=Number.NaN,t.outSet=!1,je(e,t);return}if(t.state!=="fading"||r===null)return;let o=Number.isNaN(e.now)?_n(t):e.now,i=e.reduced?0:n.over??t.fade.in??t.fade.out??0,s=r.rest||r.over===0?1:1-(o-r.at)/r.over,a=s<0?0:s>1?1:s,l=Number.isNaN(e.now)||(t.owner===null?o:Te(t.owner,o))<t.start;t.out=null,t.outAt=Number.POSITIVE_INFINITY,t.state=l?"pending":"live",l&&(t.begunSeq=Number.POSITIVE_INFINITY),t.back=i>0&&a<1?{from:a,at:o,over:i}:null,!r.rest&&r.at<o&&(t.stalls=[...t.stalls??[],r.at,o]),l&&Kr(e,t),je(e,t),l?e.lanes?.invalidate():e.lanes?.refill()}function VL(e,t,n,r){if(t.state==="done"||t.state==="fading")return;let o=Number.isNaN(e.now)?_n(t):e.now;if(n<=o){Zr(e,t,{over:r},Math.max(Uo(t),n)),e.stir();return}t.outAt=n,t.outOver=r??Number.NaN,t.outSet=!0,je(e,t)}function zT(e,t,n){let r=t.out,o=r.back===!0?t.soonest:t.span+t.latest,i=t.reaches(o),s=Math.max(r.at+r.over,i<=n?i:n),a=e.reduced?0:r.over;t.out=null,t.back=a>0?{from:0,at:s,over:a}:null,je(e,t),e.lanes?.refill()}function tD(e,t,n){return t.owner===e.owner&&t.ownerId===n.id}function Nq(e,t){t.owner.holding.left(t.passed?Qe(e,t,"coast"):void 0,t.doneSeq)}function Bn(e,t,n){t.holding===null&&e.lanes?.touch(t);let r=t.motion;r!==void 0&&tD(e,r,t)&&(r.owner=null),t.state="done",Ia(e,t),t.keepOn=null,e.retired.push(t);let o=Number.isNaN(e.now)?Number.NEGATIVE_INFINITY:e.now;if(t.doneAt=n??o,t.decidedAt=o,t.doneSeq=e.transport.seq,e.transport.settle(),t.play(!1,t.doneAt,t.doneSeq),t.resolve(),t.holding!==null)for(let i of[...t.holding.children])i.state!=="done"&&Bn(e,i,t.doneAt);if(t.owner!==null){let i=t.owner;Nq(e,t);let s=XF(t,o);s!==null&&!_c(s,t.doneAt)?Bn(e,s,t.doneAt):i.fitting!==null&&i.state!=="done"&&!t.skipped&&Dn(e,i,t.doneAt)}}var Iq=["enter","active","exit"],JT=class{enter;exit;blend;has;hold;constructor(t,n,r,o,i){this.enter=t,this.exit=n,this.blend=r,this.has=o,this.hold=i}};function rD(e,t){let n=[0,e.enter,e.enter+t,e.enter+t+e.exit],r=n[3],o=[null,null,null];for(let i=0;i<3;i++){if(!e.has[i])continue;let s=i+1;for(;s<3&&!e.has[s];)s++;o[i]=[n[i],s<3?n[s]:r]}return o}function Dc(e){let t=e.arc;return t.enter+e.hold+t.exit}function nD(e,t,n,r,o){if(t<=e)return 0;let i=r/2,s=e===0,a=t===n;if(!s&&o<e-i||!a&&o>=t+i)return 0;let l=s?1:r>0?Math.min(1,(o-e+i)/r):1,u=a?1:r>0?Math.min(1,(t+i-o)/r):1;return Math.min(l,u)}function tL(e,t,n,r){let o=e.arc,i=Te(e,n);if(!(i>=0))return 0;let s=rD(o,e.hold),a=o.enter+e.hold+o.exit,l=r?0:o.blend,u=s[t.part];if(u==null)return 0;let c=nD(u[0],u[1],a,l,i);if(c<=0)return 0;let d=0;for(let f of s)f!==null&&(d+=nD(f[0],f[1],a,l,i));return d>1?c/d:c}function Eq(e){let t=0;for(let n of e){let r=n.loop,o=r===void 0||r===!1?1:r===!0?1/0:r,i=n.duration??(n.patch.duration>0?n.patch.duration*o:0);if(!(i>=0))throw new RangeError(`blits: an arc's part lasts 0 ms or more, not ${i}`);i>t&&(t=i)}return t}var XT=e=>e===void 0?void 0:Array.isArray(e)?e:[e];function oD(e,t){if((t.rate??1)<0)throw new Error("blits: an arc plays its parts forward from its start, so it is not cued backward");if(t.freeze!==void 0)throw new Error("blits: an arc holds each part\u2019s first and last frames itself, so it takes no freeze");let{enter:n,active:r,exit:o,hold:i,blend:s,...a}=t,l=[XT(n),XT(r),XT(o)],u=l.map(m=>m===void 0?0:Eq(m));for(let m of[0,2])if(!Number.isFinite(u[m]))throw new Error(`blits: an arc's ${Iq[m]} has to end, so it cannot loop for good`);let c=i==="open"?Number.POSITIVE_INFINITY:i??u[1]??0;if(!(c>=0))throw new RangeError(`blits: an arc holds for 0 ms or more, not ${i}`);let d=s??0;if(!(d>=0&&Number.isFinite(d)))throw new RangeError(`blits: an arc blends over 0 ms or more, not ${s}`);let f=new JT(u[0],u[2],d,l.map(m=>m!==void 0),c);e.arcing=f;let p;try{p=e.owns(a)}finally{e.arcing=null}let h=[0,f.enter,f.enter+c];return l.forEach((m,y)=>{for(let b of m??[]){let{duration:x,...w}=b,g={...w,owner:p,start:h[y],freeze:"both"};y===1&&i!==void 0&&b.loop===void 0&&(g.loop=!0),e.cue(g),e.cued[e.cued.length-1].part=y}}),p}function zL(e,t){let n=t.arc;if(n===null)throw new Error("blits: release ends an arc\u2019s hold, and this is no arc");if(t.state==="done"||t.state==="fading")return;let r=Te(t,e.now),o=n.exit>0&&!e.reduced?n.blend/2:0,i=Math.max(n.enter,r+o);if(i<n.enter+t.hold){t.hold=i-n.enter;for(let s of t.holding?.children??[])s.part===2&&s.state==="pending"&&_a(e,s,i);Mq(e,t)}}function Mq(e,t){je(e,t),t.owner?.fitting&&Dn(e,t.owner),e.lanes?.refill()}function U_(e,t){for(let n of e.owners??[]){let r=n.arc;if(r===null||n.state==="done"||n.state==="pending")continue;let o=Te(n,t);if(!Number.isFinite(o))continue;let i=Dc(n);if(o>=i){let l=n.timeAt(i);n.play(!0,l,e.transport.seq),Bn(e,n,l);continue}let s=rD(r,n.hold),a=e.reduced?0:r.blend/2;for(let l of[...n.holding?.children??[]]){let u=s[l.part];u==null||u[1]===i||l.state==="done"||o>=u[1]+a&&Bn(e,l,n.timeAt(u[1]+a))}}}function vL(e,t,n){let r=e.arc,o=u=>{let c=e.timeAt(u);return Number.isFinite(c)?Math.max(t,c):void 0};if(n==="in"){let u=o(r.enter);return u===void 0?u:Math.max(u,t+(e.fade.in??0))}let i=o(r.enter+e.hold),s=e.out,a=s!==null?s.at:Number.isFinite(e.outAt)?e.outAt:void 0,l=a!==void 0&&(i===void 0||a<i);if(n==="coast")return l?void 0:i;if(n==="out")return l?a:e.state==="done"&&i===void 0?e.doneAt:i;if(e.state==="done")return e.doneAt;if(l){if(s!==null)return s.at+s.over;let u=Number.isNaN(e.outOver)?e.fade.out??0:e.outOver;return a+u}return o(Dc(e))}function iD(e,t){let n=[],r=[];for(let s=0;s<e.length;s++){let a=t[s].rest;a!==void 0&&(n.push(e[s]),r.push(typeof a=="number"?a:void 0))}function o(){for(let s=0;s<n.length;s++)this[n[s]]=r[s]}o.prototype=Object.prototype;let i=o;return()=>new i}function sD(e,t,n,r,o){let i,s=pe.back;if(s!==null)i=(im(e,n,r.elapsed,s)&1)!==0;else{let f=o.run;o.freed!==e.freed&&(f=e.slot(n),o.run=f,o.freed=e.freed),e.sample(f,r.elapsed,e.xs,e.vs),i=e.scalar(f)}let a=e.xs,l=o.delta??{};if(i)return l[t]=a[0],l;let u=e.n,c=l[t],d=Array.isArray(c)&&c.length===u?c:Zn(u,0);for(let f=0;f<u;f++)d[f]=a[f];return l[t]=d,l}var aD=Ra;function lD(e,t,n,r,o){o.rebuilt=t.rebuilds;let i=t.patch;i.state===void 0&&i.step===void 0&&o.kept===null||(o.state=i.state?i.state(n):void 0,o.kept=null,o.unkept=void 0,o.since=e.sinceOf(t,o.delay),o.shown=e.shownOf(t,o.since),o.ticks=0,o.stepped=o.since<r?o.since:r,o.probed=Number.NaN)}function Cq(e,t,n){let r=t.patch;return r.state===void 0&&r.step===void 0&&!t.keeping?!1:e.sinceOf(t,n.delay)!==n.since}function uD(e,t,n){return e<0?JO(e,t):Ur(e,t,n)}var Oq=Object.freeze({});function cD(e,t,n,r){if(r.weight=0,!r.reaches)return null;let o=e.bound!==null&&r.replay===void 0&&!w_(this,e.bound,t),i=o&&e.spec.weight.input===!0&&!!this.opts.history?.inputs;if(o&&!i&&e.patch.step===void 0&&e.spec.from!=="current"||e.out?.rest&&Ho(r))return null;r.rebuilt!==e.rebuilds?lD(this,e,t,n,r):r.seeks!==e.seeks&&Cq(this,e,r)&&(lD(this,e,t,n,r),gT(e,r,n));let s=e.rawAt(n,r.delay),a=e.before(s,n);if(a&&!e.holdsFirst)return null;let l=e.shownAt(s);if(Number.isNaN(l))return null;let u=a?-1:e.freezesAfter&&s>e.span?1:0,c=e.duration,d=er(l,c,e.passes),f=this.primed;f[0]=n,f[1]=l,f[2]=d,this.prime(e,r);let p=e.setting,h=pe.kept,m=o?0:this.weigh(e,t,n,r);if(i&&Fm(this,e,t,r,0),pe.kept!==h&&!e.keeping&&ts(this,e),p.weight=m,r.weight=m,r.probed===n&&r.delta&&r.seeks===e.seeks)return e.holder!==r&&e.scratch.length>0&&this.keyed(e,t,r),this.w=m,r.delta;let y=pe.kept,b=this.opts.history;if(b?.inputs&&e.patch.reads!==void 0&&!this.projecting&&Q_(this,n),e.motion!==void 0&&(pe.horizon=this.horizonFor(e,r.delay,n)),e.patch.step&&r.probed!==n){let g=u===0?n:u===1?e.timeAt(r.delay+e.span):e.ranBackTo(r.delay,n),P=r.snaps,S=Number.isNaN(r.probed)&&P!==void 0;if(Number.isNaN(g))S&&QT(e,r);else{r.stepped<r.since&&(r.stepped=r.since,p.dt=this.capped(n-r.since));let v=Lo(this,e);v!==void 0&&S&&Fq(this,e,t,r,P,v,g),S&&QT(e,r),v!==void 0?this.tick(e,t,r,v,g):(u===0?n!==r.stepped:g>r.stepped)&&(u!==0&&(p.dt=this.capped(g-r.stepped)),e.patch.step(r.state,p.dt,t,p),r.stepped=g)}}let x=null,w=!1;if(jh(e,m)&&(e.built===null||e.spec.role===void 0))w=e.spec.role!==void 0,e.built&&e.spec.from==="current"&&r.base===void 0&&(r.base=this.baseFor(e,t),r.slope=this.slopeFor(e,t));else if(e.built)r.phase=uD(l,c,e.passes),x=this.keyed(e,t,r);else if(e.motion!==void 0)x=sD(e.motion,e.patch.writes[0],t,p,r);else{let g=uD(l,c,e.passes);x=e.patch.at(g,t,p),e.unchecked&&$_(e,x)}return r.delta=x,r.probed=n,r.seeks=e.seeks,b!==void 0&&Pm(this,e,t,r),pe.kept!==y&&!e.keeping&&ts(this,e),x===null?w?(this.w=m,Oq):null:e.out?.rest&&this.isRest(x)?(r.weight=0,r.restedAt=n,e.restedCount++,null):(this.w=m,x)}function dD(e,t,n){let r;e.spec.from==="current"&&(n.base===void 0&&(n.base=this.baseFor(e,t),n.slope=this.slopeFor(e,t)),r=n.base);let o=dm(e.built,n.phase,n.delta??{},r,e.lerps,n.slope,e.intos,e.scratch);return n.delta=o,e.scratch.length>0&&(e.holder=n),o}function fD(e,t,n){return Math.floor((n-e.since)/t+1e-9)}function Fq(e,t,n,r,o,i,s){let a=o[o.length-1],l=a?.ahead;if(a===void 0||l===void 0||l.put!==r)return;l.put=null;let u=t.patch.reads;if(e.opts.maxDt!==void 0||u!==void 0&&u.length>0)return;let c=a.held;if(r.ticks!==c.ticks||r.since!==l.since||r.rebuilt!==c.rebuilt)return;let d=l.sought,f=fD(r,i,s),p=l.state!==void 0&&l.ticks<=f;if(l.left!==void 0&&l.leftTicks<=f&&!(p&&l.ticks>l.leftTicks)){r.state=l.left,l.left=void 0,t.setting.state=r.state,r.ticks=l.leftTicks;return}p&&(r.state=za(t,l.state),t.setting.state=r.state,r.ticks=l.ticks);let h=p?l.at:a.at;!(d<s)||d-h<Hc(e.opts.history)||(QT(t,r),e.tick(t,n,r,i,d),l.state=za(t,r.state),l.ticks=r.ticks,l.at=d)}function QT(e,t){let n=t.snaps,r=n[n.length-1];r!==void 0&&t.state!==void 0&&t.state===r.held.state&&(t.state=za(e,t.state),e.setting.state=t.state)}function pD(e,t,n,r,o){let i=this.now,s=e.setting,a=s.dt,l=n.ticks,u=fD(n,r,o),c=this.opts.maxDt;if(c!==void 0){let f=Math.floor(c/r);u-l>f&&(l=u-f)}let d=e.patch.step;for(s.dt=r,l++;l<=u;l++)s.timestamp=n.since+l*r,d(n.state,r,t,s);n.ticks=u>n.ticks?u:n.ticks,n.stepped=n.since+n.ticks*r,s.timestamp=i,s.dt=a}function hD(e,t){let n=this.lastPoses.get(t)?.pose;if(n===void 0&&!this.folding.has(e.id)){this.folding.add(e.id);try{n=this.fold(t,void 0,!1,e.id)}finally{this.folding.delete(e.id)}}let r={};for(let o of e.patch.writes){let i=this.kit[o],s=n?.[o],a=i.rest;s!==void 0?r[o]=aD(s):a!==void 0&&(r[o]=aD(a))}return r}function mD(e,t){let n=this.lastPoses.get(t);if(n?.prev===void 0||!(n.at>n.prevAt))return;let r=n.at-n.prevAt,o=n.pose,i=n.prev,s={};for(let a of e.patch.writes){let l=i[a],u=o[a];typeof l=="number"&&typeof u=="number"?s[a]=(u-l)/r:Array.isArray(l)&&Array.isArray(u)&&l.length===u.length&&(s[a]=u.map((c,d)=>(c-l[d])/r))}return s}function yD(e){for(let t of Object.keys(e)){if(e[t]===void 0)continue;let n=this.kit[t];if(n.rest===void 0||!Ic(e[t],n.rest))return!1}return!0}function gD(e,t,n,r,o){if(r&&o.reaches&&o.probed===n&&o.delta&&o.seeks===e.seeks){let i=e.setting,s=e.shownAt(e.rawAt(n,o.delay));return i.timestamp=n,i.dt=0,i.elapsed=s,i.pass=er(s,e.duration,e.passes),i.weight=0,i.state=o.state,i.mark=0,e.keepOn=o,this.w=this.weigh(e,t,n,o),o.weight=this.w,e.holder!==o&&e.scratch.length>0&&this.keyed(e,t,o),o.delta}return this.contribution(e,t,n,o)}function bD(e){this.frame=st();let t=ut(this,e);t!==void 0&&bc(this,t);let n=this.chains.get(e)?.slot??-1;n>=0&&this.lanes!==null&&this.lanes.release(n),this.projecting&&!(this.lastPoses instanceof xc)&&(this.lastPoses=new xc(this.lastPoses)),this.projecting||this.places?.drop(e),this.lastPoses.delete(e),this.restStamps?.delete(e),this.chains.delete(e),this.stir();let r=_m(this);for(let l of this.general)this.forgetIn(l,e,r);let o=this.named.get(e);if(o!==void 0)for(let l of[...o])this.forgetIn(l,e,r);let i=zo(this);for(let l of i.general)this.forgetIn(l,e,r);let s=i.named.get(e);if(s!==void 0)for(let l of s)this.forgetIn(l,e,r);if(this.owners!==null)for(let l of this.owners)this.forgetIn(l,e,r);for(let l of this.parters)this.forgetIn(l,e,r),l.parts?.size===0&&(l.parts=null),l.parted?.size===0&&(l.parted=null),l.parts===null&&l.parted===null&&this.parters.delete(l);let a=this.strays.get(e);if(a!==void 0)for(let l of a)this.releaseIn(l,e,r);this.strays.delete(e);for(let l of this.strayAll)this.releaseIn(l,e,r);Xr(this)&&this.recordDrop(e)}function xD(e,t,n){qT(this,e,t),e.subjects.delete(t),e.motion!==void 0&&this.releaseIn(e.motion,t,n),e.parts?.delete(t),e.parted?.delete(t),e.blend?.of.reads.delete(t)}function wD(e,t,n){this.projecting?e.holds(t)&&Da("a drop of a subject a motion patch holds"):e.release(t,n[0],n[1],n[2],n[3])}function PD(e){Lt(this,"drop",t=>t.mix(this)?.drop(e))}var Lq=Symbol("unread");function ZT(e,t,n,[r,o]){for(let i=t;i<t+n;i++){let s=e[i];e[i]=s<r?r:s>o?o:s}}function _q(e,t,n){let r=n*e.axes;if(typeof t=="number"&&e.axes===1)e.out[r]=t;else if(Array.isArray(t)&&t.length===e.axes)for(let o=0;o<e.axes;o++)e.out[r+o]=t[o];else if(t===void 0)e.out.fill(Number.NaN,r,r+e.axes);else throw new TypeError(`blits: pull reads ${e.key} as ${e.axes===1?"a number":`${e.axes} numbers`} a subject, and the pose has ${String(t)}`)}function TD(e,t,n){let r;if(n===void 0||this.wantsPose){r={};for(let o of this.names){let i=t[o];i!==void 0&&(r[o]=Ra(i))}}if(r!==void 0){let o=this.lastPoses.get(e);o===void 0?this.lastPoses.set(e,{pose:r,at:this.now,prev:void 0,prevAt:Number.NaN}):o.at===this.now?o.pose=r:(o.prev=o.pose,o.prevAt=o.at,o.pose=r,o.at=this.now)}}function SD(e,t,n){let r=Bq(e,n),o=e.lanes,i=e.now;e.scratch===void 0&&(e.scratch=e.pose());let s=Number.POSITIVE_INFINITY,a="";for(let x of r){let w=Math.floor(x.out.length/x.axes);w<s&&(s=w,a=x.key)}let l;if(Array.isArray(t))l=t;else{let x=[];for(let w of t)if(x.push(w)>s)break;l=x}if(l.length>s)throw new RangeError(`blits: pull's array for ${a} has room for ${s} subjects, and was given more`);let u=o!==null&&!e.wantsPose,c=e.pulled,d=e.pulledHeads;if(e.pulledSlots.length<l.length){let x=new Int32Array(Math.max(64,l.length)).fill(-1);x.set(e.pulledSlots),e.pulledSlots=x}l.length<c.length&&e.pulledSlots.fill(-1,l.length,c.length);for(let x=c.length;x<l.length;x++)c.push(Lq);c.length=l.length,d.length=l.length;let f=e.version,p=e.relinks,h=!Number.isNaN(i),m=h&&e.pulledVersion===f&&e.pulledRelinks===p,y=m?Number.POSITIVE_INFINITY:h&&e.pulledVersion===f?e.pulledRelinks:-1;try{Dq(e,l,r,h,m,y,u)}finally{o!==null&&o.pulls.flush(o)}let b=h&&e.version===f&&e.relinks===p;e.pulledVersion=b?f:Number.NaN,e.pulledRelinks=p}function Dq(e,t,n,r,o,i,s){let a=e.lanes,l=e.now,u=e.scratch,c=e.pulled,d=e.pulledHeads,f=e.pulledSlots,p=e.version,h=r&&s;for(let m=0;m<t.length&&!(h&&(m=a.pulls.pullRun(a,f,t,c,i,m,n,l,e.version),m===t.length));m++){let y=t[m],b=-1;if(r)if(o&&c[m]===y)b=f[m];else{let S=d[m],v=c[m]===y&&S!==void 0&&S.version===p?S:e.chain(y);c[m]=y,d[m]=v,b=v.slot;let A=m===0?0:f[m-1]+1;if(h&&b>=0&&b!==A&&A>=0&&a.pulls.renumber(e,y,v,A)){for(let N=c.indexOf(y);N>=0;N=c.indexOf(y,N+1))f[N]=A;b=A}f[m]=b}let x=r&&a?.prepare(b,y,e.version,d[m]??null)===!0;if(x&&s&&a.whole&&!a.owes(b)){a.pulls.writeLater(a,b,n,m,f);continue}let w=r?d[m]:null,g=e.foldWith(y,u,w,x,!1),P=e.bounded.length===0?g:e.clamp(g);e.keep(y,P,u);for(let S of n)_q(S,P[S.key],m)}}function Bq(e,t){let n=[];e.pullColumns??=new Map;let r=e.pullColumns;for(let o of Object.keys(t)){let i=t[o];if(i===void 0)continue;let s=r.get(o);if(s!==void 0){s.out=i,n.push(s);continue}let a=e.slotOf.get(o);if(a===void 0)throw new Error(`blits: pull was handed ${o}, which the kit lacks`);let l=e.channels[a],u=l.rest,c=$O(l),d=l.bounds,f=new Float64Array(c).fill(Number.NaN);typeof u=="number"?f[0]=u:Array.isArray(u)&&f.set(u),d!==void 0&&ZT(f,0,c,d);let p={key:o,slot:a,axes:c,out:i,rest:f,bounds:d};r.set(o,p),n.push(p)}return n}function kD(e){e.pulled=[],e.pulledHeads=[],e.pulledSlots=new Int32Array(0),e.pulledVersion=Number.NaN,e.pulledRelinks=-1}function AD(e,t,n,r,o,i,s,a,l){if((e.filled(a,l)?1:e.begin(a,l))!==1||!e.whole)return i;let c=e.per,d=e.fills,f=e.busyFill,p=e.wide,h=e.frameProbes,m=e.subjects,y=e.unlinked,b=e.holds,x=e.owed.any(),w=o===Number.POSITIVE_INFINITY;ND(e,s,t),ID(e,e.queued+n.length-i);let g=i,P=-1,S=i;for(;g<n.length;g++){let v=n[g];if(r[g]!==v)break;let A=t[g],N=A*6;if(A<0||!w&&!(y[A]<=o)||c[N+0]>=f||c[N+2]!==0||c[N+1]<p||x&&e.owes(A))break;c[N+3]>h||c[N+4]>h||e.distinct++,c[N+3]=++e.probes,c[N+5]=d,b&&(m[A]=v),A!==P+(g-S)&&(P>=0&&t1(e,P,S,g-S),P=A,S=g)}return P>=0&&t1(e,P,S,g-S),g>i&&b&&(e.holding=!0),g}function RD(e,t,n,r,o){ND(e,n,o),t1(e,t,r,1)}function ND(e,t,n){t===e.queuedFor&&n===e.queueFrom||(rs(e),e.queuedFor=t,e.queueFrom=n)}var vD=16;function t1(e,t,n,r){let o=e.queued;if(o>0){let i=o-1,s=e.queueCounts[i];if(n===e.queueRows[i]+s){let a=e.queueSlots[i];if(a>=0&&t===a+s){e.queueCounts[i]=s+r;return}if(r<vD&&(a<0||s<vD)){e.queueSlots[i]=-1,e.queueCounts[i]=s+r;return}}}ID(e,o+1),e.queueSlots[o]=t,e.queueRows[o]=n,e.queueCounts[o]=r,e.queued=o+1}function ID(e,t){if(t<=e.queueSlots.length)return;let n=Math.max(64,t,e.queueSlots.length*2);e.queueSlots=e1(e.queueSlots,n),e.queueRows=e1(e.queueRows,n),e.queueCounts=e1(e.queueCounts,n)}function e1(e,t){let n=new Int32Array(t);return n.set(e),n}function rs(e){let t=e.queued,n=e.queuedFor;if(!(t===0||n===null)){e.queued=0;for(let r=0;r<n.length;r++){let o=n[r],i=e.bySlot[o.slot];if(i===void 0?Hq(e,o,t):Uq(e,o,i.values,t),o.bounds!==void 0)for(let s=0;s<t;s++)ZT(o.out,e.queueRows[s]*o.axes,e.queueCounts[s]*o.axes,o.bounds)}}}function Hq(e,t,n){let r=e.queueRows,o=e.queueCounts,i=t.out,s=t.axes;if(s===1){let a=t.rest[0];for(let l=0;l<n;l++){let u=r[l],c=u+o[l];if(c-u>64)i.fill(a,u,c);else for(let d=u;d<c;d++)i[d]=a}return}for(let a=0;a<n;a++){let l=r[a]*s,u=l+o[a]*s;for(let c=l;c<u;c+=s)for(let d=0;d<s;d++)i[c+d]=t.rest[d]}}var Gq=256;function Uq(e,t,n,r){let o=e.queueSlots,i=e.queueRows,s=e.queueCounts,a=t.out,l=t.axes,u=e.queueFrom;for(let c=0;c<r;c++){let d=o[c];if(d<0){let m=i[c],y=m+s[c];if(l===1)for(let b=m;b<y;b++)a[b]=n[u[b]];else for(let b=m;b<y;b++){let x=b*l,w=u[b]*l;for(let g=0;g<l;g++)a[x+g]=n[w+g]}continue}let f=i[c]*l,p=d*l,h=s[c]*l;if(h>Gq)a.set(n.subarray(p,p+h),f);else for(let m=0;m<h;m++)a[f+m]=n[p+m]}}function CD(e,t){this.copier===null&&(this.copier=Wq(this.laned)),this.copier(t,e)}function OD(e,t,n){let r=e.start,o=e.axes,i=t*o;if(Array.isArray(n)&&n!==r&&n.length===(r.length>o?r.length:o)){for(let a=0;a<o;a++)n[a]=e.values[i+a];for(let a=o;a<r.length;a++)n[a]=r[a];return n}let s=[...r];for(let a=0;a<o;a++)s[a]=e.values[i+a];return s}var ED=new Map,MD=!1;function Wq(e){let t=[];for(let o=0;o<e.length;o++){let i=e[o],s=`o[${JSON.stringify(i.name)}]`,a=i.scalar?"s":`s * ${i.axes}`,l=`if (${s} !== undefined) ${s} = undefined;`,u=i.scalar?`${s} = v;`:`{ const h = ${s}, a = f(c${o}, s, h); if (a !== h) ${s} = a; }`;t.push(`{ const v = c${o}.values[${a}];`),t.push(i.op==="last"?`if (v !== v) { ${l} } else ${u} }`:`${u} }`)}let n=t.join(`
427
+ `),r=ED.get(n);if(r===void 0&&!MD){let o=e.map((i,s)=>`const c${s} = chans[${s}];`).join(" ");try{r=new Function("chans","f",`${o}
428
428
  return function copyLaned(o, s) {
429
429
  ${n}
430
- };`),w_.set(n,r)}catch{P_=!0}}return r===void 0?(o,i)=>sY(e,o,i):r(e,S_)}function sY(e,t,n){for(let r=0;r<e.length;r++){let o=e[r],i=o.values[o.scalar?n:n*o.axes];if(o.op==="last"&&Number.isNaN(i))t[o.name]!==void 0&&(t[o.name]=void 0);else if(o.scalar)t[o.name]=i;else{let s=t[o.name],a=S_(o,n,s);a!==s&&(t[o.name]=a)}}}function aY(e,t){let n=t.spec,r=t.patch;return e.lanes!==null&&!e.projecting&&e.opts.history===void 0&&t.named===null&&n.target===void 0&&n.stagger===void 0&&n.role===void 0&&n.anchor===void 0&&n.from!=="current"&&typeof n.weight!="function"&&r.state===void 0&&r.step===void 0&&t.motion===void 0&&t.owner===null&&t.holding===null&&t.blend===null&&!t.freezesBefore&&!t.beginless&&t.slots.every(o=>{let i=e.channels[o];return i.rest!==void 0&&Jn(i)?.op!=="last"})}var lY=60;function uY(e){let t=e.sharers;for(let n=t.length-1;n>=0;n--){let r=t[n];r.built!==null||r.state==="pending"||r.state==="done"||++r.shared>=lY&&TT(e,r)}}function cY(e,t){if(t.everyone!==null)return t.everyone;let n=e.sinceOf(t,0);if(!(n<=e.now))return TT(e,t),null;let r=On(t,!0,void 0);return r.since=n,r.shown=e.shownOf(t,n),r.stepped=n,r.rebuilt=t.rebuilds,t.everyone=r,r}function wT(e,t){let n=e.sighted,r=t>>>5;return n!==null&&t>=0&&r<n.length&&(n[r]&1<<(t&31))!==0}function k_(e,t,n){let r=e.sighted,o=t>>>5;if(r===null||o>=r.length){let s=new Uint32Array(Math.max(o+1,(n>>>5)+1));r!==null&&s.set(r),e.sighted=s,r=s}let i=1<<(t&31);(r[o]&i)===0&&(r[o]=r[o]|i,e.seen++)}function PT(e,t){let n=e.weights;return n!==null&&t>=0&&t<n.length?n[t]:0}function gm(e,t,n,r){let o=e.weights;if(o===null||t>=o.length){if(n===0)return;let i=new Float64Array(Math.max(t+1,r));o!==null&&i.set(o),e.weights=i,o=i}o[t]=n}function Ha(e,t,n){if(e.built!==null)return;let r=e.stamps,o=n*2;if(t.stepped=t.since,r===null||o>=r.length){t.probed=Number.NaN,t.seeks=0,t.delta=null;return}let i=r[o+0];t.probed=i,t.seeks=r[o+1],t.delta=Number.isNaN(i)?null:e.deltas[n]??null}function vc(e,t,n,r){if(e.built!==null)return;let o=e.stamps,i=n*2;if(o===null||i>=o.length){if(Number.isNaN(t.probed))return;let s=new Float64Array(Math.max(n+1,r)*2).fill(Number.NaN);o!==null&&s.set(o),e.stamps=s,o=s,e.deltas??=[]}o[i+0]=t.probed,o[i+1]=t.seeks,e.deltas[n]=t.delta}function dY(e,t){let n=e.stamps,r=t*2;n!==null&&t>=0&&r<n.length&&(n[r+1]=-1),e.built!==null&&e.everyone!==null&&(e.everyone.seeks=-1)}function v_(e,t,n,r){if(wT(e,t)){let a=e.seen;k_(e,n,r),e.seen=a}let o=PT(e,t);(o!==0||e.weights!==null&&n<e.weights.length)&&gm(e,n,o,r);let i=e.stamps,s=t*2;if(i!==null&&s<i.length){let a=n*2;if(a>=i.length){let u=new Float64Array(Math.max(n+1,r)*2).fill(Number.NaN);u.set(i),e.stamps=u,i=u}i[a+0]=i[s+0],i[a+1]=i[s+1];let l=e.deltas;l[n]=l[t]??null}bm(e,t)}function bm(e,t){let n=e.sighted,r=t>>>5;n!==null&&r<n.length&&(n[r]=n[r]&~(1<<(t&31)));let o=e.weights;o!==null&&t<o.length&&(o[t]=0);let i=e.stamps,s=t*2;i!==null&&s<i.length&&(i[s+0]=Number.NaN,e.deltas[t]=null)}function TT(e,t,n=!1,r){if(!t.sharing)return;t.sharing=!1;let o=t.everyone;t.everyone=null;let i=e.sharers.indexOf(t);i>=0&&e.sharers.splice(i,1);let s=n?ut(e,r)?.slot??-1:-1;o!==null&&n&&(e.projecting||wT(t,s))?(s>=0&&bm(t,s),t.subjects.set(r,o)):t.holder===o&&(t.holder=null),e.lanes?.rerecord(t.id,(a,l)=>e.held(t,a,l)),t.state!=="done"&&e.steps.push(t,++e.version),e.unshared=!0,Uo(e),e.lanes?.refill()}function fY(e,t,n){t.weight=PT(e,n),Ha(e,t,n),bm(e,n)}var A_={shares:aY,outgrow:uY,everyoneOf:cY,sighted:wT,sight:k_,weightAt:PT,weighAt:gm,open:Ha,shut:vc,restamp:dY,unsight:bm,unshare:TT,inherit:fY};function Ua(e,t){return e-t*Math.round(e/t)}var Ga=Qn(4,0),ST=Qn(4,0);function kT(e,t,n,r){let o=r.length===n?r:Qn(n,0);for(let i=0;i<n;i++)o[i]=e[t+i];return o}function xm(e,t,n,r,o){if(e.turn>0){t[n]=t[n]+Ua(r,e.turn)*o;return}let i=e.axes;Ga=kT(t,n,i,Ga);let s=e.channel.fold(Ga,r,o);for(let a=0;a<i;a++)t[n+a]=s[a]}function R_(e,t,n,r,o,i){if(e.turn>0){xm(e,t,n,r[o],i);return}ST=kT(r,o,e.axes,ST),xm(e,t,n,ST,i)}function N_(e,t,n,r,o,i){if(e.turn>0){let l=t[n],u=r;t[n]=o===0?u:l+Ua(u-l,e.turn)*i;return}let s=e.axes,a=r;(o!==0||a.length!==s)&&(Ga=kT(t,n,s,Ga),a=e.channel.lerp(Ga,r,i));for(let l=0;l<s;l++)t[n+l]=a[l]}function I_(e,t){let n=e.values,r=e.axes;if(e.op!=="own"){n.fill(e.rest,0,t*r);return}let o=e.start;for(let i=0;i<t*r;i+=r)for(let s=0;s<r;s++)n[i+s]=o[s]}function Ac(e,t){if(e.length>=t)return e;let n=new Float64Array(t);return n.set(e),n}function E_(e,t){let n=e.cap;t.met.length<n&&(t.met=Ac(t.met,n),t.first=Ac(t.first,n),t.sum=Ac(t.sum,n));for(let r=0;r<t.values.length;r++){let o=t.values[r],i=t.taken[r],s=e.laned[r].axes;o!==void 0&&(t.values[r]=Ac(o,n*s)),i!==void 0&&(t.taken[r]=Ac(i,n))}if(t.inline=pY(t),!t.inline){e.into=t;try{for(let r of t.members){let o=r.voice;if(r.idle||o.state==="pending"||o.state==="done")continue;e.intoId=o.id,e.reset(r),r.elapsedNow=o.elapsedAt(e.now);let i=r.list,s=o.bound;s!==null&&XP(e,s);let a=e.fills;for(let l=0;l<i.length;l++){let u=i[l];if(s!==null&&!JP(s,u,a)){QP(e,r,l,u);continue}if(e.one(r,l,u)&&(Pm(e,t,u),t.sum[u]=t.sum[u]+r.data[l*8+2]),o.keeping)break}}}finally{e.into=null}}}function Pm(e,t,n){if(t.met[n]===e.fills)return;t.met[n]=e.fills,t.first[n]=e.intoId,t.sum[n]=0;let r=t.taken;for(let o=0;o<r.length;o++){let i=r[o];i!==void 0&&(i[n]=0)}}function wm(e,t,n,r){let o=e.arg,i=o[7],s=t.values[n.index],a=t.taken[n.index];if(s===void 0||a===void 0){M_(e,t,n,r,i);return}let l=o[0];Pm(e,t,r);let u=a[r],c=u+l;s[r]=u===0?i:Ct(s[r],i,l/c),a[r]=c}function M_(e,t,n,r,o){let i=e.arg[0];Pm(e,t,r);let s=n.index,a=t.values[s],l=t.taken[s];(a===void 0||l===void 0)&&(a=new Float64Array(e.cap*n.axes),l=new Float64Array(e.cap),t.values[s]=a,t.taken[s]=l);let u=l[r],c=u+i,d=i/c;if(!n.plain||!n.straight)N_(n,a,r*n.axes,o,u,d);else if(n.scalar)a[r]=u===0?o:Ct(a[r],o,d);else{let f=Array.isArray(o)||ArrayBuffer.isView(o)?o:null,p=r*n.axes;for(let h=0;h<n.axes;h++){let m=f===null?n.rest:f[h]??n.rest;a[p+h]=u===0?m:Ct(a[p+h],m,d)}}l[r]=c}function C_(e,t,n){let r=t.voice.id,o=e.fills,i=t.list;for(let s=0;s<i.length;s++){let a=i[s];n.met[a]!==o||n.first[a]!==r||n.sum[a]>0&&O_(e,n,a)}}function O_(e,t,n){for(let r=0;r<t.values.length;r++){let o=t.taken[r],i=o===void 0?0:o[n];if(!(i>0))continue;let s=i>1?1:i,a=e.laned[r],l=t.values[r],u=a.values,c=n*a.axes;if(!a.plain){R_(a,u,c,l,c,s);continue}for(let d=0;d<a.axes;d++)u[c+d]=Oe(a.op,u[c+d],l[c+d],s)}}function pY(e){if(!e.contiguous)return!1;let t=e.members,n=t[0].list;for(let r of t){let o=r.voice;if(r.idle||o.keeping||o.state==="pending"||o.state==="done")return!1;let i=r.list;if(i!==n){if(i.length!==n.length)return!1;for(let s=0;s<n.length;s++)if(i[s]!==n[s])return!1}}return!0}function F_(e,t){let n=t.members,r=e.arg;for(let s of n){e.reset(s),s.elapsedNow=s.voice.elapsedAt(e.now);let a=s.voice.bound;a!==null&&XP(e,a)}let o=e.fills,i=n[0].list;e.into=t;try{for(let s=0;s<i.length;s++){let a=i[s],l=0;for(let u=0;u<n.length;u++){let c=n[u];if(c.voice.keeping)continue;let d=c.voice.bound;if(d!==null&&!JP(d,a,o)){QP(e,c,s,a);continue}r[6]=c.mark,e.one(c,s,a)&&(Pm(e,t,a),l+=c.data[s*8+2])}l>0&&O_(e,t,a)}}finally{e.into=null}}function L_(e,t){let n=e.chans;for(let r=0;r<n.length;r++)e.values[r]=t[n[r].name]}function __(e,t){let n=e.chans;for(let r=0;r<n.length;r++)this.foldInto(n[r],t,e.values[r])}function D_(e,t,n){let r=e.length,o=this.arg,i=e[0];if(r>0){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Oe(i.op,l[t],s,o[0])}else o[7]=s,wm(this,a,i,t)}else this.foldInto(i,t,s)}if(i=e[1],r>1){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Oe(i.op,l[t],s,o[0])}else o[7]=s,wm(this,a,i,t)}else this.foldInto(i,t,s)}if(i=e[2],r>2){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Oe(i.op,l[t],s,o[0])}else o[7]=s,wm(this,a,i,t)}else this.foldInto(i,t,s)}for(let s=3;s<r;s++){i=e[s];let a=n[i.name];if(typeof a=="number"&&i.scalar&&i.plain){let l=this.into;if(l===null){let u=i.values;u[t]=Oe(i.op,u[t],a,o[0])}else o[7]=a,wm(this,l,i,t)}else this.foldInto(i,t,a)}}function B_(e,t,n){if(!e.plain){this.unplain(e,t,e.scalar?n[0]:n);return}let r=this.arg[0],o=e.values,i=t*e.axes;for(let s=0;s<e.axes;s++)o[i+s]=Oe(e.op,o[i+s],n[s],r)}function H_(e,t,n){if(n===void 0)return;if(this.into!==null){M_(this,this.into,e,t,n);return}if(!e.plain&&!this.unplain(e,t,n))return;let r=this.arg[0],o=e.values;if(e.scalar){o[t]=Oe(e.op,o[t],n,r);return}let i=t*e.axes,s=Array.isArray(n)||ArrayBuffer.isView(n)?n:null;for(let a=0;a<e.axes;a++){let l=s===null?e.rest:s[a]??e.rest;o[i+a]=Oe(e.op,o[i+a],l,r)}}function G_(e){let t=this.arg[0],n=this.folding,r=this.rec,o=n.chans.indexOf(e),i=r.bands??new Uint8Array(n.chans.length);r.bands=i;let s=i[o],a=this.host.passes(s===0?void 0:s===1,t);return i[o]=a?1:2,a}function U_(e,t,n){if(e.op==="last")return this.gate(e);let r=this.arg[0],o=e.values;return e.turn>0?o[t]=o[t]+Ua(n,e.turn)*r:xm(e,o,t*e.axes,n,r),!1}function W_(e,t){let n=t.voice,r=t.data,o=e.per,i=t.list,s=t.records,a=t.chans,l=t.values,u=a.length,c=e.fills,d=e.lately,f=n.elapsedAt(e.now);t.elapsedNow=f;let p=n.duration,h=n.passes,m=n.freezesBefore,g=n.freezesAfter,b=n.span,x=n.hidesPast,w=t.flat,y=n.parts!==null,P=Br(n.weight),S=0;for(let N=0;N<u;N++)S+=a[N].axes;t.nums.length<S&&(t.nums=new Float64Array(S)),t.kinds.length<u&&(t.kinds=new Uint8Array(u));let v=t.nums,A=t.kinds;for(let N=0;N<i.length;N++){let M=i[N],C=N*8;if(Ft(r,C,o,M*6,c),d>=0&&e.unread(M))continue;let F=f-r[C+0],B=F>b&&x?Number.NaN:kh(F,m,g,b);if(!(B>=0)){r[C+2]=0,kt(s[N]);continue}if(!w){let W=r[C+1];(!t.weighed||!Kt(W,t.weighedSince))&&(t.fade=e.host.envelope(n,W),t.weighed=!0,t.weighedSince=W)}let D=w&&!y?P:jt(n.weight,t.fade,e.parting(n,M));if(r[C+2]=D,(!t.read||!Kt(B,t.readAt))&&(e.readKeyed(n,Dr(B,p,h),t.delta,t.scratch),t.read=!0,t.readAt=B,e.gather(t,t.delta),hY(a,l,v,A)),!(D>0)){kt(s[N]);continue}let j=0;for(let W=0;W<u;W++){let J=a[W],se=J.axes,ke=A[W];if(ke===1){let ae=J.values,ve=M*se;for(let G=0;G<se;G++)ae[ve+G]=Oe(J.op,ae[ve+G],v[j+G],D)}else ke===2&&(e.folding=t,e.rec=s[N]??null,e.arg[0]=D,e.foldInto(J,M,l[W]));j+=se}}}function hY(e,t,n,r){let o=0;for(let i=0;i<e.length;i++){let s=e[i],a=t[i];if(a===void 0)r[i]=0;else if(!s.plain)r[i]=mY(s,a,n,o);else if(r[i]=1,s.scalar)n[o]=a;else{let l=Array.isArray(a)||ArrayBuffer.isView(a)?a:null;for(let u=0;u<s.axes;u++)n[o+u]=l===null?s.rest:l[u]??s.rest}o+=s.axes}}function mY(e,t,n,r){return e.turn>0?(n[r]=Ua(t,e.turn),1):2}var Tm=class{lanes;crowd;row;made;constructor(t,n,r,o=0){this.lanes=t,this.crowd=n,this.row=r,this.made=o}};function Hn(e,t){let n=t.seat;return n!==null&&n.lanes===e?n:null}function V_(e,t,n,r){let o=Hn(e,t);return o!==null&&o.crowd===n&&o.row===r}function yY(e,t){if(e.metCrowd||e.owes(t))return!1;let n=e.met,r=e.metN;if(e.owed.last(n,r))return!0;let o=Number.NEGATIVE_INFINITY;for(let i of e.lanes){let s=i.voice.id;if(s<=o)continue;let a=n.indexOf(s);(a<0||a>=r)&&(o=s)}for(let i of e.crowds)i.size>0&&(o=Math.max(o,i.hot[(i.size-1)*i.stride+7]));for(let i=0;i<r;i++){let s=n[i];if(s<=o||e.byId.get(s).group!==null)return!1}return!0}function z_(e,t,n,r,o){let i=e.per[t*6+1],s=i<0?-1-i:i;e.per[t*6+1]=e.epochs;let a=!1;e.metN=0,e.metCrowd=!1;let l=e.dense;for(let f=l.length-1;f>=0;f--){let p=l[f];if(p.epoch<=s)break;if(p.positionOf(t)>=0)continue;let h=e.host.meet(p.voice,n,r,t);h.reaches&&(p.add(t,h),p.idle&&Yt(e,t,1),e.met[e.metN++]=p.voice.id,a=!0)}let u=i<0?e.host.naming(n):void 0;if(u!==void 0)for(let f of u){let p=e.byId.get(f.id);if(p===void 0){xY(e,f,t,n,s,r)&&(a=!0,e.metCrowd=!0);continue}if(p.epoch<=s||p.positionOf(t)>=0)continue;let h=e.host.meet(f,n,r,t);h.reaches&&(p.add(t,h),p.idle&&Yt(e,t,1),e.met[e.metN++]=f.id,a=!0)}if(!a)return o;let c=e.met;for(let f=1;f<e.metN;f++){let p=c[f],h=f-1;for(;h>=0&&c[h]>p;h--)c[h+1]=c[h];c[h+1]=p}let d=t*6;if(o&&e.per[d+2]===0){let f=gY(e,t);if(f||yY(e,t))return bY(e,t,n,f)||e.owed.owe(t,e.met,e.metN),!0}return e.per[d+0]=e.fills,!1}function gY(e,t){if(e.foldsFill!==e.fills||e.metCrowd||e.owes(t))return!1;let n=e.folds,r=e.metN;if(n.length!==r)return!1;for(let o=0;o<r;o++)if(n[o]!==e.met[o])return!1;return!0}function bY(e,t,n,r){if(e.filling)return!1;let o=e.lately,i=t*6;if(o>=0&&!(e.per[i+3]>o||e.per[i+4]>o))return!1;let s=e.met,a=e.metN;for(let l=0;l<a&&!r;l++){let u=e.byId.get(s[l]),c=u.voice;if(u.ran!==e.fills||u.motion!==void 0||c.keeping||typeof c.spec.weight=="function"||c.sharing&&c.everyone===null)return!1}r||(e.folds=s.slice(0,a),e.foldsFill=e.fills),e.subjects[t]===void 0&&(e.subjects[t]=n,e.holding=!0),e.meeting=!0;try{for(let l=0;l<a;l++){let u=e.byId.get(s[l]),c=u.voice,d=u.positionOf(t);if(!c.sharing){e.one(u,d,t);continue}let f=c.everyone;Ha(c,f,t),e.one(u,d,t),c.keeping||vc(c,f,t,e.cap)}}finally{e.meeting=!1}for(let l=0;l<a;l++)e.byId.get(s[l]).voice.keeping&&(e.foldsFill=-1);return!0}function xY(e,t,n,r,o,i){let s=Hn(e,t);if(s===null)return!1;let a=s.crowd,l=s.row,u=l*a.stride,c=a.hot[u+0];if(a.hot[u+6]<=o||(c&16)!==0)return!1;let d=e.host.meet(t,r,i,n);if(!d.reaches)return!1;let f=l*8;return a.list[l]=n,e.placed.add(n,t.id),a.data[f+0]=d.delay,a.data[f+1]=d.shown,a.data[f+2]=0,a.data[f+3]=0,a.data[f+4]=-1,a.data[f+5]=-1,a.data[f+7]=0,a.records[l]=d,a.deltas[l]=null,a.restale(l,c|16),a.idle&&Yt(e,n,1),!0}function Yt(e,t,n){let r=t*6+2;e.per[r]=e.per[r]+n}var wY=Ha,PY=vc,TY=0;function SY(e){if(e<2)return 1;for(let t=e;;t++){let n=!0;for(let r=2;r*r<=t;r++)if(t%r===0){n=!1;break}if(n)return t}}function AT(e,t,n){qi(e);let r=e.host;e.filling=!0;let o=e.lookups;try{e.fills++,e.owed.begin(e.fills),e.now=t,e.filledAt=t,e.filledVersion=n;let i=e.numbers.size;e.keeps=r.keeps;let s=e.fresh;e.fresh=!1;let a=e.live>0?e.lastDistinct/e.live:1;e.lately=a<1?e.lastFrom:-1;let l=!1;for(let u of e.lanes){if(s){let c=u.line,d=u.list.length;d>=64?K_(e,u):d===1&&u.motion===void 0?u.idle||j_(e,u):(u.idle?a>=c.start:a<c.stop)&&vT(e,u)}u.idle||(l=!0)}for(let u of e.crowds)s&&(u.size>=64?K_(e,u):(u.idle?a>=u.line.start:a<u.line.stop)&&vT(e,u)),u.cursor=0,u.stale&&oL(u),!u.idle&&u.size>0&&(l=!0);if(l){for(let u of e.laned)I_(u,i);for(let u of e.roles)E_(e,u);for(let u of e.lanes)u.idle||(e.crowds.length>0&&(e.arg[6]=Number.NaN,jP(e,u.voice.id)),e.run(u));e.crowds.length>0&&(e.arg[6]=Number.NaN,jP(e,Number.POSITIVE_INFINITY));for(let u of e.crowds)u.idle||(u.bareFill=e.fills,u.bareNow=t)}e.busyFill=l?e.fills:0;for(let u of e.late)e.per[u*6+0]=e.fills;e.holding&&(e.subjects.fill(void 0,0,i),e.holding=!1),e.moved=pe.moved,e.inputs=pe.inputs,e.holds=e.lookups!==o}finally{e.filling=!1,e.late.length=0}}function K_(e,t){let n=t.list,r=t.line,o=e.lastFrom,i=e.lastTo,s=SY(Math.floor(n.length/256)),a=0,l=0;for(let c=e.fills%s;c<n.length;c+=s){let d=n[c];if(d<0)continue;let f=e.per[d*6+3],p=e.per[d*6+4];(f>o&&f<=i||p>o&&p<=i)&&l++,a++}let u=a>0?l/a:1;(t.idle?u>=r.start:u<r.stop)&&vT(e,t)}function vT(e,t){t.idle?RT(e,t):j_(e,t)}function j_(e,t){t.idle=!0;let n=t.list,r=t.data;for(let o=0;o<n.length;o++){let i=n[o];i<0||(Yt(e,i,1),Ft(r,o*8,e.per,i*6,e.fills))}}function RT(e,t){t.idle=!1;for(let n of t.list)n>=0&&Yt(e,n,-1)}function $_(e,t,n){let r=this.arg,o=r[5];if(Number.isNaN(n.probed))return this.late.push(t),!1;let i=this.subjectAt(t);return i===rr?(r[0]=0,!0):(this.host.signal(e,i,n,t),r[0]=jt(r[0],o,e.parts===null?1:this.host.parting(e,i)),!0)}function Y_(e,t){if(e.parts===null)return 1;let n=this.subjectAt(t);return n===rr?1:this.host.parting(e,n)}function q_(e){this.lookups++;let t=this.subjects[e];return t===void 0&&(t=this.numbers.subject(e),this.subjects[e]=t,this.holding=!0),t}function X_(e){let t=e.voice;e.placed=!1,this.arg[6]=Number.NaN,e.read=!1,e.weighed=!1,e.flat=!((t.fade.in??0)>0)&&t.out===null&&t.back===null&&t.owner===null,e.fade=1}function J_(e){let t=e.voice;if(t.state==="pending"||t.state==="done")return;let n=e.group;if(n!==null){n.inline?e===n.members[0]&&F_(this,n):C_(this,e,n);return}if(this.reset(e),e.ran=this.fills,e.motion!==void 0&&!t.keeping){eL(this,e,e.motion);return}if(t.built!==null&&typeof t.spec.weight!="function"){W_(this,e);return}e.elapsedNow=t.elapsedAt(this.now);let r=e.list;if(t.sharing){this.runEveryone(e);return}if(t.bound!==null){dL(this,e,t.bound);return}for(let o=0;o<r.length;o++)if(this.one(e,o,r[o]),t.keeping)return}function Q_(e){let t=e.voice,n=t.everyone,r=e.list,o=this.cap;for(let i=0;i<r.length;i++){let s=r[i];if(wY(t,n,s),this.one(e,i,s),t.keeping)return;PY(t,n,s,o)}}function Z_(e,t,n){let r=this.host,o=e.voice,i=e.elapsedNow,s=this.arg,a=e.data,l=t*8;if(Ft(a,l,this.per,n*6,this.fills),this.lately>=0&&this.unread(n))return!1;let u=a[l+0],c=i-u,d=c>=0?c>o.span?o.hidesPast?Number.NaN:o.freezesAfter?o.span:c:c:o.freezesBefore?0:Number.NaN;if(!(d>=0))return a[l+2]=0,kt(e.records[t]),!1;(!e.placed||!Kt(d,e.placedAt))&&(e.placed=!0,e.placedAt=d,e.phase=Dr(d,o.duration,o.passes),e.pass=Zn(d,o.duration,o.passes),s[6]=++TY,e.mark=s[6]);let f=a[l+1];!e.flat&&(!e.weighed||!Kt(f,e.weighedSince))&&(e.fade=r.envelope(o,f),e.weighed=!0,e.weighedSince=f);let p;if(typeof o.spec.weight=="function"){if(s[1]=d,s[3]=e.pass,s[5]=e.fade,!this.signalled(o,n,e.records[t]))return a[l+2]=0,kt(e.records[t]),!1;p=s[0]}else p=jt(o.weight,e.fade,this.parting(o,n));if(a[l+2]=p,p>0||kt(e.records[t]),this.folding=e,this.rec=e.records[t]??null,o.built!==null){if((!e.read||!Kt(d,e.readAt))&&(this.readKeyed(o,e.phase,e.delta,e.scratch),e.read=!0,e.readAt=d,this.gather(e,e.delta)),typeof o.spec.weight=="function"){let m=e.records[t];m.probed=this.now,m.seeks=o.seeks,m.delta=null}return p>0&&(s[0]=p,this.fold(e,n)),!0}let h=e.records[t];return Number.isNaN(h.probed)&&!this.meeting&&!e.every?(this.late.push(n),!1):(s[1]=d,s[4]=u,s[0]=p,e.motion!==void 0?(mc(this,e,e.motion,t,n,h),!0):(s[2]=e.phase,s[3]=e.pass,this.call(o,e.chans,h,n)))}function eD(e,t,n){let r=this.arg[2],o=this.arg[0],i=e.built,s=i.tracks;for(let a=0;a<s.length;a++){let l=s[a],u=t[a],c=MP(l,RP(l,r,i.duration),void 0);if(c===Vh)continue;if(c===ka){this.foldInto(u,n,Be.a);continue}let d=Be.a,f=Be.b,p=Be.eased;if(u.scalar||!u.plain||!u.straight){this.foldInto(u,n,e.lerps[a](d,f,p));continue}let h=d,m=f,g=u.values,b=n*u.axes,x=u.rest;for(let w=0;w<u.axes;w++){let y=Ct(h[w]??x,m[w]??x,p);g[b+w]=Oe(u.op,g[b+w],y,o)}}}function tD(e,t,n,r){zh(e.built,t,n,void 0,e.lerps,void 0,e.intos,r)}function nD(e,t,n,r){let o=this.arg,i=o[2],s=o[4],a=o[0],l=this.host,u=this.subjectAt(r);if(u===rr)return!1;if(n.probed===this.now&&n.delta!==null&&n.seeks===e.seeks)return a>0&&this.foldDelta(t,r,n.delta),!0;if(vh(e,a))return n.delta=null,n.probed=this.now,n.seeks=e.seeks,e.spec.role!==void 0;let c=pe.kept;l.ready(e,u,n),this.keeps?l.horizon(e,s):pe.horizon=Number.POSITIVE_INFINITY;let d=e.patch.at(i,u,e.setting);return n.delta=d,n.probed=this.now,n.seeks=e.seeks,this.keeps&&l.after(e,u,n),pe.kept!==c&&!e.keeping&&l.kept(e),a>0&&this.foldDelta(t,r,d),!0}var Sm=class{fill=new Int32Array(0);at=new Int32Array(0);lists=[];now=0;begin(t){this.now=t,this.lists.length=0}grow(t){let n=new Int32Array(t);n.set(this.fill),this.fill=n;let r=new Int32Array(t);r.set(this.at),this.at=r}any(){return this.lists.length>0}owes(t){return this.lists.length>0&&this.fill[t]===this.now}owesVoice(t,n){return this.lists[this.at[t]].includes(n)}owe(t,n,r){this.last(n,r)||this.lists.push(n.slice(0,r)),this.fill[t]=this.now,this.at[t]=this.lists.length-1}last(t,n){let r=this.lists[this.lists.length-1];if(r===void 0||r.length!==n)return!1;for(let o=0;o<n;o++)if(r[o]!==t[o])return!1;return!0}};var km=class{one=new Int32Array(0);rest=null;grow(t){let n=new Int32Array(t);n.set(this.one),this.one=n}any(t){return this.one[t]|0}all(t){let n=this.any(t);return n===0?[]:[n,...this.rest?.get(t)??[]]}add(t,n){if(this.one[t]===0){this.one[t]=n;return}this.rest??=new Map;let r=this.rest.get(t);r===void 0?this.rest.set(t,[n]):r.push(n)}remove(t,n){let r=this.rest?.get(t);if(this.one[t]===n)this.one[t]=r===void 0?0:r.pop();else if(r!==void 0){let o=r.indexOf(n);if(o<0)return;r[o]=r[r.length-1],r.pop()}else return;r!==void 0&&r.length===0&&this.rest.delete(t)}};function kY(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function IT(e,t,n){let r=t.list[n];r>=0&&(t.idle&&Yt(e,r,-1),e.placed.remove(r,t.voices[n].id)),t.list[n]=-1,t.records[n]=void 0,t.deltas[n]=null;let o=n*t.stride+0;t.hot[o]=t.hot[o]&-2065;let i=n*8;t.data[i+4]=-1,t.data[i+5]=-1,t.data[i+7]=0}function rD(e,t){let n=0;for(let o of t){if(!e.seats.has(o.id))return!1;n++}let r=0;for(let o of e.seats.values())o.crowd.voices[o.row].state!=="done"&&r++;return r===n}function oD(e,t){let n=new Set(t.map(i=>i.id));for(let i of e.crowds)for(let s=0;s<i.size;s++){let a=i.voices[s];(!n.has(a.id)||a.state==="done")&&aD(e,i,s)}let r=e.crowds,o=new Map(e.seats);for(let i of o.values())i.lanes=null;e.crowds=[],e.seats.clear(),e.overlap=!1;for(let i of t){let s=o.get(i.id);ET(e,i,s?.crowd,s?.row,r)}e.crowds.length===0&&(e.lawsByKey.clear(),e.lastLaw=null)}function ET(e,t,n,r,o){let i=t.slots.map(u=>e.bySlot[u]),s=e.crowds.find(u=>kY(u.chans,i));if(s===void 0){s=new rm(i,i[0].axes);let u=i.map(d=>d.name).join(" "),c=o.find(d=>d.chans.map(f=>f.name).join(" ")===u);c!==void 0&&(s.idle=c.idle);for(let d of e.crowds)d.chans.some(f=>i.includes(f))&&(e.overlap=!0);e.crowds.push(s)}let a=s.size;s.reserve(a+1),n!==void 0&&r!==void 0?iD(n,r,s,a):AY(e,s,a,t),s.hot[a*s.stride+6]===0&&t.state!=="pending"&&(s.hot[a*s.stride+6]=vm(e,t));let l=new Tm(e,s,a,n===void 0?e.probes:0);e.seats.set(t.id,l),t.seat=l,t.laned=!0}function MT(e,t,n,r){let o=n*t.stride;t.hot[o+6]===0&&r.state!=="pending"&&(t.hot[o+6]=vm(e,r)),t.hot[o+0]=t.hot[o+0]|64}function CT(e){for(let t of e.crowds)t.dead>64&&t.dead*4>=t.size&&vY(e,t)}function vY(e,t){let n=t.keys;t.keys=new Oa;let r=0;for(let o=0;o<t.size;o++){let i=t.voices[o],s=Hn(e,i);if(s===null||s.crowd!==t||s.row!==o){t.odd?.delete(o);continue}r!==o?(iD(t,o,t,r,n),t.odd?.delete(o),s.row=r):sD(n,t,r),r++}t.list.length=r,t.voices.length=r,t.records.length=r,t.deltas.length=r,t.motions.length=r,t.eases.length=r,t.laws.length=r,t.dead=0}function OT(e,t,n){let r=t.voices[n];aD(e,t,n),t.list[n]=-1,t.records[n]=void 0,t.deltas[n]=null,t.motions[n]=void 0,t.hot[n*t.stride+0]=0,e.seats.delete(r.id);let o=r.seat;o!==null&&o.lanes===e&&(o.lanes=null,r.seat=null),t.dead++}function NT(e,t,n,r,o){for(let i=0;i<o;i++)n[r+i]=e[t+i]}function iD(e,t,n,r,o=e.keys){e.fix(t),n.list[r]=e.list[t],NT(e.data,t*8,n.data,r*8,8),NT(e.hot,t*e.stride,n.hot,r*n.stride,e.stride),sD(o,n,r),(e.hot[t*e.stride+0]&4)!==0&&(n.stale=!0,n.staleRows.push(r)),NT(e.samples,t*e.axes,n.samples,r*n.axes,e.axes),n.deltas[r]=e.deltas[t]??null,n.records[r]=e.records[t],n.voices[r]=e.voices[t],n.motions[r]=e.motions[t],n.eases[r]=e.eases[t],n.laws[r]=e.laws[t];let i=e.odd?.get(t);i!==void 0&&(n.odd??=new Map,n.odd.set(r,i))}function sD(e,t,n){let r=n*t.stride;(t.hot[r+0]&512)!==0&&(t.hot[r+9]=t.keys.copy(e,t.hot[r+9]))}function AY(e,t,n,r){let o=Ln(r.patch),i=n*t.stride;t.hot.fill(0,i,i+t.stride);let s=r.built===null?-1:t.keys.add(r.built,t.chans);s>=0&&(t.hot[i+9]=s,t.hot[i+11]=r.duration,t.hot[i+10]=r.passes),t.restale(n,64|(o===void 0?0:128)|(o?.ease===void 0?0:1024)|(s>=0?512:0)),t.hot[i+7]=r.id,t.list[n]=-1;let a=n*8;if(t.data.fill(0,a,a+8),t.data[a+4]=-1,t.data[a+5]=-1,t.deltas[n]=null,t.records[n]=void 0,t.voices[n]=r,t.motions[n]=o,o===void 0){t.laws[n]=nL,t.eases[n]=void 0;return}t.laws[n]=RY(e,o),t.eases[n]=o.ease;let l=o.watcher===e?e.byId.get(o.watchId):void 0;if(l!==void 0)for(let u=0;u<l.list.length;u++)l.fix(u);o.watcher=e,o.watchId=r.id}function RY(e,t){let n=e.lastLaw;if(n!==null&&t.hasLaw(n))return n;let r=NY(e,t);return e.lastLaw=r,r}function NY(e,t){let n=t.law(),r=n.join(" "),o=e.lawsByKey.get(r);return o!==void 0?o:(e.lawsByKey.set(r,n),n)}function aD(e,t,n){let r=t.list[n],o=t.records[n];if(r>=0){e.placed.remove(r,t.voices[n].id),t.idle&&Yt(e,r,-1);let a=FT(e,t,n,r);o!==void 0&&a!==void 0&&(o.weight=a),o!==void 0&&t.motions[n]!==void 0&&yc(e,t,n,r,o)}let i=t.motions[n],s=t.voices[n];i!==void 0&&i.watcher===e&&i.watchId===s.id&&(i.watcher=null),s.laned=!1}function FT(e,t,n,r){let o=r*6;if(!(e.per[o+3]>e.per[o+4])||t.list[n]!==r)return;let i=Hn(e,t.voices[n])?.made??0;if(e.per[o+3]>i)return t.data[n*8+(e.per[o+5]===e.fills?2:3)]}function lD(e,t){let n=e.slice(),r=!0;for(;r;){r=!1;for(let s of t)if(!(s.fits&&s.slots.every(a=>n[a])))for(let a of s.slots)n[a]&&(n[a]=!1,r=!0)}let o=new Set,i=e.map(()=>!1);for(let s of t)if(!(!s.fits||!s.slots.every(a=>n[a]))){o.add(s.id);for(let a of s.slots)i[a]=!0}return{channels:i,voices:o}}function Am(e,t){qi(e);let n=e.host;e.qualifiedVersion=t,e.filledVersion=Number.NaN;let r=e.touched.slice();e.touched.length=0;let o=n.voices.filter(h=>h.state!=="done"&&h.holding===null);for(let h of o)h.id>e.known&&(e.known=h.id);let i=n.channels.map(h=>Jn(h)!==void 0),s=o.map(h=>h.slots.length>0&&n.fits(h));uD&&EY(o,s,n.channels);let a=()=>o.map((h,m)=>({id:h.id,fits:s[m],slots:h.slots})),{channels:l,voices:u}=lD(i,a());for(let h=!0;h;){h=!1;let m=new Map;o.forEach((g,b)=>{let x=g.spec.role;if(x===void 0)return;let w=m.get(x);w===void 0?m.set(x,[b]):w.push(b)});for(let g of m.values()){let b=g.filter(x=>u.has(o[x].id)).length;if(!(b===0||b===g.length)){for(let x of g)s[x]=!1;h=!0}}h&&({channels:l,voices:u}=lD(i,a()))}for(let h of e.lanes)u.has(h.voice.id)||cD(e,h);let c=[],d=0;for(let h of o){if(!u.has(h.id))continue;if(Yi(h)){d++;continue}let m=e.byId.get(h.id);m===void 0&&(m=new gc(h),m.made=e.probes),h.laned=!0,m.epoch===0&&h.state!=="pending"&&DT(e,m),c.push(m)}e.lanes=c,e.roles=[];let f=new Map;for(let h of c){h.group=null;let m=h.voice.spec.role;if(m===void 0)continue;let g=f.get(m);g===void 0&&(g={members:[],met:new Float64Array(e.cap),first:new Float64Array(e.cap),sum:new Float64Array(e.cap),values:[],taken:[],contiguous:!1,inline:!1},f.set(m,g),e.roles.push(g)),g.members.push(h),h.group=g}for(let[h,m]of f)m.contiguous=_Y(o,u,h,m.members);e.dense=c.filter(h=>h.voice.named===null&&h.epoch>0).sort((h,m)=>h.epoch-m.epoch),e.whole=c.length+d===o.length,e.byId.clear();for(let h of c)e.byId.set(h.voice.id,h);c.length===0&&d===0&&(e.subjects=[]);let p=o.filter(h=>u.has(h.id)&&Yi(h));if(MY(e,l)&&rD(e,p)){for(let h of c)h.chans=h.voice.slots.map(m=>e.bySlot[m]),h.values=h.chans.map(()=>{});for(let h of e.crowds)for(let m=0;m<h.size;m++){let g=h.voices[m];V_(e,g,h,m)&&g.state==="done"&&OT(e,h,m)}for(let h of r){if(h.state==="done")continue;let m=Hn(e,h);m!==null&&MT(e,m.crowd,m.row,h)}CT(e);return}e.laned=[],e.copier=null,e.bySlot=n.channels.map(()=>{}),l.forEach((h,m)=>{if(!h)return;let g=n.channels[m],b=Jn(g),x=g.rest??Number.NaN,w=typeof x=="number"&&b.axes===1,y=b.folds??b.op,P={name:n.names[m],op:y,plain:y!=="last"&&y!=="own"&&b.turn===void 0,straight:b.folds===void 0,turn:b.turn??0,channel:g,scalar:w,rest:typeof x=="number"?x:x[0],axes:b.axes,values:new Float64Array(e.cap*b.axes),start:typeof x=="number"?[]:x,index:e.laned.length};e.laned.push(P),e.bySlot[m]=P}),e.copies.length=0;for(let h of e.bySlot)e.copies.push(h!==void 0);for(let h of c)h.chans=h.voice.slots.map(m=>e.bySlot[m]),h.values=h.chans.map(()=>{});oD(e,p)}var uD=!0;function LT(e,t){return e.built===null&&e.motion===void 0&&e.slots.every(n=>IY(t[n]))}function IY(e){return Array.isArray(e.rest)&&Jn(e)?.op!=="last"}function EY(e,t,n){let r=new Array(n.length).fill(!1),o=new Array(n.length).fill(!1);e.forEach((i,s)=>{if(!t[s])return;let a=Yi(i);if(LT(i,n)){if(!a)for(let l of i.slots)o[l]&&(r[l]=!0),o[l]=!0}else for(let l of i.slots)r[l]=!0}),e.forEach((i,s)=>{t[s]&&LT(i,n)&&!i.slots.some(a=>r[a])&&(t[s]=!1)})}function MY(e,t){let n=e.bySlot;if(n.length!==t.length)return!1;for(let r=0;r<n.length;r++)if(n[r]!==void 0!==t[r])return!1;return!0}function vm(e,t){let n=++e.epochs;if(t.named===null)return e.wide=n,n;for(let r of t.named.list){let o=e.host.slotOf(r);if(o<0||o>=e.cap)continue;let i=o*6+1,s=e.per[i],a=s<0?-1-s:s;e.per[i]=-1-Math.min(a,n-1)}return n}function _T(e){let t=Bi(e.touched);e.touched=[];let n=0;for(let o=0;o<t.length;o++)(o===0||t[o]!==t[o-1])&&(t[n++]=t[o]);t.length=n;let r=()=>(e.touched=t,!1);for(let o of t){let i=o.id<=e.known;o.id>e.known&&(e.known=o.id);let s=Hn(e,o);if(s!==null){if(o.state==="done"){OT(e,s.crowd,s.row);continue}MT(e,s.crowd,s.row,o);continue}if(o.state==="done"&&!i)continue;let a=e.byId.get(o.id);if(a!==void 0){if(!LY(e,a))return r();continue}if(o.state==="done"||o.spec.role!==void 0)return r();let l=o.slots.some(c=>e.bySlot[c]!==void 0),u=o.slots.length>0&&e.host.fits(o);if(!l&&(!u||uD&&Yi(o)&&LT(o,e.host.channels))){e.whole=!1;continue}if(i||!u||!l||o.slots.some(c=>e.bySlot[c]===void 0))return r();Yi(o)?ET(e,o,void 0,void 0,e.crowds):FY(e,o)}return CT(e),e.lanes.length===0&&e.crowds.every(o=>o.dead===o.size)&&(e.subjects=[]),!0}function DT(e,t){let n=t.voice;t.epoch=vm(e,n),n.named===null&&n.spec.target===void 0&&(t.reserve(e.live,e.cap),CY(e,t)&&OY(e,t))}function CY(e,t){let n=t.voice;return n.sharing&&n.everyone!==null&&t.motion===void 0&&!n.keeping&&typeof n.spec.weight!="function"&&t.list.length===0&&e.lastDistinct>=e.live}function OY(e,t){let n=t.voice.everyone,r=e.numbers,o=Math.min(r.size,e.cap);for(let i=0;i<o;i++)r.has(i)&&(t.add(i,n),t.idle&&Yt(e,i,1));t.every=!0}function FY(e,t){let n=new gc(t);n.made=e.probes,t.laned=!0,t.state!=="pending"&&DT(e,n),n.chans=t.slots.map(r=>e.bySlot[r]),n.values=n.chans.map(()=>{}),e.lanes.push(n),e.byId.set(t.id,n),t.named===null&&n.epoch>0&&e.dense.push(n)}function LY(e,t){let n=t.voice;if(n.state!=="done")return t.epoch===0&&n.state!=="pending"&&(DT(e,t),n.named===null&&e.dense.push(t)),!0;if(t.group!==null)return!1;cD(e,t),e.lanes.splice(e.lanes.indexOf(t),1);let r=e.dense.indexOf(t);return r>=0&&e.dense.splice(r,1),e.byId.delete(n.id),!0}function cD(e,t){t.idle&&RT(e,t);let n=t.voice.state==="done";if(!n||t.motion!==void 0)for(let o=0;o<t.list.length;o++){let i=t.records[o],s=t.list[o],a=n?void 0:e.reported(t,s);i!==void 0&&a!==void 0&&(t.voice.sharing?gm(t.voice,s,a,e.cap):i.weight=a),i!==void 0&&t.motion!==void 0&&yc(e,t,o,s,i)}let r=t.motion;if(r!==void 0&&r.watcher===e&&r.watchId===t.voice.id){for(let o=0;o<t.list.length;o++)t.fix(o);r.watcher=null}t.voice.laned=!1}function _Y(e,t,n,r){for(let s=1;s<r.length;s++)if(r[s].voice.id<=r[s-1].voice.id)return!1;let o=r[0].voice.id,i=r[r.length-1].voice.id;for(let s of e)if(s.id>o&&s.id<i&&t.has(s.id)&&s.spec.role!==n)return!1;return!0}function fD(e,t,n,r){let o=e.lanes,i=n.slot;if(i<0||o.filling||o.host.keeps||e.projecting||o.roles.length>0||o.owed.any()||o.lanes.some(u=>u.voice.bound!==null)||!o.numbers.move(i,r))return!1;for(let u of o.lanes)u.renumber(i,r);let s=o.placed;for(let u of s.all(i)){s.remove(i,u);let c=o.seats.get(u);c===void 0||c.crowd.list[c.row]!==i||(c.crowd.list[c.row]=r,s.add(r,u))}let a=o.per;a.copyWithin(r*6,i*6,(i+1)*6),a[i*6+0]=o.fills,o.unlinked[r]=o.unlinked[i],o.subjects[r]=o.subjects[i],o.subjects[i]=void 0;for(let u of o.laned)u.values.copyWithin(r*u.axes,i*u.axes,(i+1)*u.axes);e.places?.forgot(i),e.places?.number(t,r);let l=o.cap;for(let u of e.general)OP(u,i,r),v_(u,i,r,l),dD(e,u,i,r);for(let u of Bo(e).general)OP(u,i,r);for(let u=n;u!==null;u=u.next)u.voice!==null&&dD(e,u.voice,i,r);return n.slot=r,!0}function dD(e,t,n,r){let o=t.blend?.of;if(!(o===void 0||n>=o.frames.length||o.frames[n]!==e.frame)){if(r>=o.frames.length){let i=Math.max(r+1,o.frames.length*2,64),s=new Float64Array(i),a=new Float64Array(i);s.set(o.frames),a.set(o.values),o.frames=s,o.values=a}o.frames[r]=e.frame,o.values[r]=o.values[n],o.frames[n]=Number.NaN}}var Rc=class{host;static share=A_;pulls={pullRun:y_,writeLater:g_,flush:qi,renumber:fD};numbers;lanes=[];dense=[];byId=new Map;crowds=[];seats=new Map;placed=new km;unlinked=new Float64Array(0);overlap=!1;roles=[];folding=null;meeting=!1;folds=[];foldsFill=-1;rec=null;arg=new Float64Array(8);into=null;intoId=0;lawsByKey=new Map;lastLaw=null;met=[];metN=0;metCrowd=!1;owed=new Sm;laned=[];copier=null;bySlot=[];copies=[];whole=!1;cap=0;epochs=0;wide=0;touched=[];known=0;per=new Float64Array(0);fills=0;busyFill=0;probes=0;subjects=[];holding=!1;holds=!0;lookups=0;filling=!1;late=[];queueSlots=new Int32Array(0);queueRows=new Int32Array(0);queueCounts=new Int32Array(0);queued=0;queuedFor=null;queueFrom=null;keeps=!1;now=Number.NaN;filledAt=Number.NaN;moved=0;inputs=0;frameAt=Number.NaN;frameProbes=0;lastFrom=0;lastTo=0;fresh=!1;distinct=0;lastDistinct=0;live=0;lately=-1;filledVersion=Number.NaN;qualifiedVersion=Number.NaN;constructor(t,n){if(this.host=t,n===void 0){this.numbers=new Dh(this);return}this.numbers=n.numbers,this.numbers.adopt(this),this.live=n.live;let r=this.numbers.size;this.grow(r);let o=this.per;for(let i=0;i<r;i++)o[i*6+0]=Number.NaN,o[i*6+1]=-1}invalidate(){this.qualifiedVersion=Number.NaN,this.filledVersion=Number.NaN}refill(){this.filledVersion=Number.NaN}touch(t){this.touched.push(t),this.filledVersion=Number.NaN}number(t){let n=this.numbers.take(t);return this.live++,this.grow(n+1),this.per[n*6+0]=this.fills,this.per[n*6+1]=-1,this.per[n*6+2]=0,this.per[n*6+3]=0,this.per[n*6+4]=0,this.per[n*6+5]=0,this.filling&&this.late.push(n),n}release(t){this.numbers.release(t)}sought(t){return Number.isNaN(this.per[t*6+0])}renew(t){return this.sought(t)?(this.per[t*6+0]=this.fills,this.filling&&this.late.push(t),!0):!1}part(t,n){let r=this.byId.get(t);if(r!==void 0){if(r.positionOf(n)<0)return;r.idle&&Yt(this,n,-1),r.remove(n);return}let o=this.seats.get(t);o!==void 0&&o.crowd.list[o.row]===n&&IT(this,o.crowd,o.row)}rejoin(t){t<this.cap&&(this.per[t*6+1]=-1)}weightOf(t,n){if(n<0)return;let r=this.byId.get(t);if(r!==void 0)return this.reported(r,n);let o=this.seats.get(t);return o===void 0?void 0:FT(this,o.crowd,o.row,n)}reported(t,n){let r=n*6,o=this.per[r+3];if(!(o>this.per[r+4])||!(o>t.made))return;let i=t.positionOf(n);if(!(i<0))return t.data[i*8+(this.per[r+5]===this.fills?2:3)]}prepare(t,n,r,o){let i=this.host.clock.now;if(!this.filled(i,r)&&this.begin(i,r)===0)return this.general(t);if(t<0)return!1;this.probedThisFrame(t)||this.distinct++;let s=++this.probes,a=this.per,l=t*6,u=a[l+0]<this.busyFill&&a[l+2]===0;return a[l+1]<this.wide&&(u=z_(this,t,n,o,u)),u?(a[l+3]=s,a[l+5]=this.fills,this.holds&&(this.subjects[t]=n,this.holding=!0)):a[l+4]=s,u}filled(t,n){return this.frameAt===t&&this.qualifiedVersion===n&&this.touched.length===0&&!this.filling&&this.current(t,n)}current(t,n){return this.filledAt===t&&this.filledVersion===n&&this.moved===pe.moved&&this.inputs===pe.inputs}begin(t,n){if(t!==this.frameAt&&(this.lastFrom=this.frameProbes,this.lastTo=this.probes,this.lastDistinct=this.distinct,this.distinct=0,this.frameAt=t,this.frameProbes=this.probes,this.fresh=!0),this.filling||(this.qualifiedVersion!==n?!Number.isNaN(this.qualifiedVersion)&&this.touched.length>0&&_T(this)?this.qualifiedVersion=n:Am(this,n):this.touched.length>0&&!_T(this)&&Am(this,n),this.laned.length===0))return 0;if(!this.current(t,n)&&(AT(this,t,n),this.qualifiedVersion!==n)){if(Am(this,n),this.laned.length===0)return 0;AT(this,t,n)}return 1}general(t){return t>=0&&(this.per[t*6+4]=++this.probes),!1}unread(t){let n=this.per,r=t*6,o=this.lately;return n[r+3]>o||n[r+4]>o?!1:(n[r+0]=this.fills,!0)}probedThisFrame(t){let n=this.frameProbes,r=t*6;return this.per[r+3]>n||this.per[r+4]>n}owes(t){return this.owed.owes(t)}owesVoice(t,n){return this.owed.owesVoice(t,n)}paid(t,n,r){let o=this.byId.get(t),i=o===void 0?-1:o.positionOf(n);if(i<0)return;o.data[i*8+2]=r;let s=o.voice.bound;s!==null&&r!==0&&lm(s,n,this.fills)}rests(t){for(let n of this.laned){let r=n.values;if(n.op==="last"){if(!Number.isNaN(r[t*n.axes]))return!1;continue}if(n.scalar){if(!(Math.abs(r[t]-n.rest)<1e-9))return!1;continue}if(n.start.length<n.axes)return!1;let o=t*n.axes;for(let i=0;i<n.axes;i++)if(!(Math.abs(r[o+i]-n.start[i])<1e-9))return!1}return!0}forget(t){this.host.forgot(t),this.live--;for(let r of this.lanes)r.remove(t);let n=this.placed;for(let r=n.any(t);r!==0;r=n.any(t)){let o=this.seats.get(r);o!==void 0&&o.crowd.list[o.row]===t?IT(this,o.crowd,o.row):n.remove(t,r)}t<this.cap&&(this.per[t*6+0]=this.fills),this.subjects[t]=void 0}grow(t){if(t<=this.cap)return;let n=Math.max(t,this.cap*2,64),r=new Float64Array(n*6);r.set(this.per),this.per=r,this.owed.grow(n),this.placed.grow(n);let o=new Float64Array(n);o.set(this.unlinked),this.unlinked=o;for(let i of this.laned){let s=new Float64Array(n*i.axes);s.set(i.values),i.values=s}this.cap=n}stretchChanged(t,n){let r=this.seats.get(t);if(r!==void 0){let s=r.crowd;s.restale(r.row,s.hot[r.row*s.stride+0]);return}let o=this.byId.get(t),i=o===void 0?-1:o.positionOfMotion(n);i>=0&&o.fix(i)}rerecord(t,n){let r=this.byId.get(t);if(r!==void 0)for(let o=0;o<r.list.length;o++){let i=r.list[o],s=this.subjectAt(i);s!==rr&&(r.records[o]=n(s,i))}}reshown(t){let n=this.seats.get(t);if(n!==void 0){let o=n.crowd.records[n.row];o!==void 0&&(n.crowd.data[n.row*8+1]=o.shown)}let r=this.byId.get(t);if(r!==void 0)for(let o=0;o<r.list.length;o++){let i=r.records[o];i!==void 0&&(r.data[o*8+1]=i.shown)}}voiceChanged(t){let n=Hn(this,t);if(n===null)return;let r=n.crowd,o=n.row*r.stride+0;r.hot[o]=r.hot[o]|64}},DY={copy:T_,row:rL,signalled:$_,parting:Y_,subjectAt:q_,reset:X_,run:J_,runEveryone:Q_,one:Z_,foldKeys:eD,readKeyed:tD,call:nD,gather:L_,fold:__,foldDelta:D_,foldRun:B_,foldInto:H_,gate:G_,unplain:U_};for(let[e,t]of Object.entries(DY))Object.defineProperty(Rc.prototype,e,{value:t,writable:!0,configurable:!0});var Nm=class{xy=new Float64Array(0);n=0;cell=Number.NaN;dirty=!0;x0=0;y0=0;size=1;cols=0;rows=0;starts=new Int32Array(1);order=new Int32Array(0);home=new Int32Array(0);strays=[];stray=new Uint8Array(0);found=new Int32Array(64);count=0;put(t,n,r){if(this.xy[2*t]=n,this.xy[2*t+1]=r,this.dirty)return;if(this.cols===0||t>=this.home.length){this.dirty=!0;return}let o=Math.floor((n-this.x0)/this.size),i=Math.floor((r-this.y0)/this.size);(o>=0&&o<this.cols&&i>=0&&i<this.rows?i*this.cols+o:-2)===this.home[t]||this.stray[t]===1||(this.stray[t]=1,this.strays.push(t),this.strays.length>Math.max(32,this.n>>4)&&(this.dirty=!0))}build(){this.dirty=!1;for(let m of this.strays)this.stray[m]=0;this.strays.length=0;let t=this.xy,n=Math.min(this.n,t.length>>1),r=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let m=0;m<n;m++){let g=t[2*m],b=t[2*m+1];g<r&&(r=g),g>i&&(i=g),b<o&&(o=b),b>s&&(s=b)}if(!(i>=r)||!(s>=o)){this.cols=0,this.rows=0;return}let a=Number.isNaN(this.cell)?Math.sqrt(2*Math.max(i-r,1e-9)*Math.max(s-o,1e-9)/n):this.cell,l=4*n+64;(Math.floor((i-r)/a)+1)*(Math.floor((s-o)/a)+1)>l&&(a=Math.max(a,Math.sqrt((i-r)*(s-o)/n),(i-r+s-o)/l));let u=Math.floor((i-r)/a)+1,c=Math.floor((s-o)/a)+1;this.x0=r,this.y0=o,this.size=a,this.cols=u,this.rows=c;let d=u*c;this.starts.length<d+1?this.starts=new Int32Array(d+1):this.starts.fill(0,0,d+1),this.order.length<n&&(this.order=new Int32Array(n)),this.home.length<n&&(this.home=new Int32Array(n),this.stray=new Uint8Array(n));let f=this.starts,p=this.order;for(let m=0;m<n;m++){let g=pD(t,m,r,o,a,u);this.home[m]=g,g>=0&&(f[g+1]=f[g+1]+1)}for(let m=0;m<d;m++)f[m+1]=f[m+1]+f[m];let h=f[d];for(let m=n-1;m>=0;m--){let g=pD(t,m,r,o,a,u);if(g<0)continue;let b=f[g+1]-1;f[g+1]=b,p[b]=m}for(let m=0;m<d;m++)f[m]=f[m+1];f[d]=h}push(t,n){if(n===this.found.length){let r=new Int32Array(this.found.length*2);r.set(this.found),this.found=r}return this.found[n]=t,n+1}query(t,n,r,o){if(this.dirty&&this.build(),this.count=0,this.cols===0||!(r>=0))return 0;let i=this.size,s=Math.max(0,Rm((t-r-this.x0)/i,-1)),a=Math.min(this.cols-1,Rm((t+r-this.x0)/i,1)),l=Math.max(0,Rm((n-r-this.y0)/i,-1)),u=Math.min(this.rows-1,Rm((n+r-this.y0)/i,1)),c=this.xy,d=this.order,f=this.starts,p=this.strays.length>0,h=0;for(let m=l;m<=u&&s<=a;m++){let g=f[m*this.cols+s],b=f[m*this.cols+a+1];for(let x=g;x<b;x++){let w=d[x];if(p&&this.stray[w]===1)continue;let y=c[2*w]-t,P=c[2*w+1]-n;y*y+P*P<=o&&(h=this.push(w,h))}}for(let m of this.strays){let g=c[2*m]-t,b=c[2*m+1]-n;g*g+b*b<=o&&(h=this.push(m,h))}return this.count=h,h}ring(t,n,r){if(this.dirty&&this.build(),this.count=0,this.cols===0||!(r>=0))return 0;let o=this.size,i=r+o,s=r*r,a=i*i,l=Math.max(0,Math.floor((t-i-this.x0)/o)),u=Math.min(this.cols-1,Math.floor((t+i-this.x0)/o)),c=Math.max(0,Math.floor((n-i-this.y0)/o)),d=Math.min(this.rows-1,Math.floor((n+i-this.y0)/o)),f=this.xy,p=0;for(let h=c;h<=d;h++)for(let m=l;m<=u;m++){let g=this.x0+m*o-t,b=this.y0+h*o-n;if(Math.max(g*g,(g+o)**2)+Math.max(b*b,(b+o)**2)<=s)continue;let w=h*this.cols+m;for(let y=this.starts[w];y<this.starts[w+1];y++){let P=this.order[y];if(this.stray[P]===1)continue;let S=f[2*P]-t,v=f[2*P+1]-n,A=S*S+v*v;A>s&&A<=a&&(p=this.push(P,p))}}for(let h of this.strays){let m=f[2*h]-t,g=f[2*h+1]-n,b=m*m+g*g;b>s&&b<=a&&(p=this.push(h,p))}return this.count=p,p}};function pD(e,t,n,r,o,i){let s=e[2*t],a=e[2*t+1];return!(s>=n)||!(a>=r)?-1:Math.floor((s-n)/o)+Math.floor((a-r)/o)*i}function Rm(e,t){let n=Math.floor(e);return t<0?e-n<1e-6?n-1:n:n+1-e<1e-6?n+1:n}var Im=class extends Nm{slotOf;keepRefs;at=new me;slots=new Int32Array(0);placeOf=new Int32Array(0);refs=null;cur=-1;free=[];owned=!0;tokens=[];registry=null;constructor(t,n){super(),this.slotOf=t,this.keepRefs=n,this.refs=n?[]:null}set(t,n,r){let o=t.length;this.at=new me;for(let i=0;i<o;i++)this.at.set(t[i],i);this.slots=new Int32Array(Math.max(o,16)).fill(-1),this.placeOf.fill(-1),this.refs=this.keepRefs?[]:null,this.tokens=[],this.free=[];for(let i=0;i<o;i++){let s=t[i];this.at.get(s)===i&&this.hold(s,i)}this.n=o,this.xy=n,this.owned=!1,this.cell=r,this.dirty=!0}place(t){let n=this.at.get(t);if(n!==void 0)return n;let r=this.free.pop()??this.n++;return this.room(r+1),this.at.set(t,r),this.hold(t,r),this.owned&&this.put(r,Number.NaN,Number.NaN),r}hold(t,n){let r=this.slotOf(t);r>=0&&this.numbered(r,n);let o=typeof t=="object"&&t!==null;if(this.refs!==null&&(this.refs[n]=o?new WeakRef(t):t),!o)return;let i={i:n};this.tokens[n]=i,this.registry??=new FinalizationRegistry(s=>{this.tokens[s.i]===s&&this.release(s.i)}),this.registry.register(t,i,i)}room(t){if(this.slots.length<t){let n=new Int32Array(Math.max(t,this.slots.length*2)).fill(-1);n.set(this.slots),this.slots=n}if(this.owned&&this.xy.length<2*t){let n=new Float64Array(Math.max(2*t,this.xy.length*2,32)).fill(Number.NaN);n.set(this.xy),this.xy=n}}number(t,n){let r=this.at.get(t);r!==void 0&&this.numbered(n,r)}numbered(t,n){if(t>=this.placeOf.length){let r=new Int32Array(Math.max(t+1,this.placeOf.length*2,64)).fill(-1);r.set(this.placeOf),this.placeOf=r}this.placeOf[t]=n,this.slots[n]=t}forgot(t){if(t>=this.placeOf.length)return;let n=this.placeOf[t];n<0||(this.placeOf[t]=-1,this.slots[n]===t&&(this.slots[n]=-1))}drop(t){let n=this.at.get(t);if(n===void 0)return;this.at.delete(t);let r=this.tokens[n];r!==void 0&&this.registry?.unregister(r),this.release(n)}release(t){this.tokens[t]=void 0,this.refs!==null&&(this.refs[t]=void 0);let n=this.slots[t];n>=0&&(this.placeOf[n]=-1),this.slots[t]=-1,this.owned&&this.put(t,Number.NaN,Number.NaN),this.free.push(t)}subjectAt(t){let n=this.refs?.[t],r=n instanceof WeakRef?n.deref():n;return r!==void 0&&this.at.get(r)===t?r:void 0}inside(t,n,r,o){let i=this.at.get(t);if(i===void 0||2*i+1>=this.xy.length)return!1;let s=this.xy[2*i]-n,a=this.xy[2*i+1]-r;return s*s+a*a<=o}};function hD(e,t,n){if(t.length<2*e.length)throw new RangeError(`blits: plot takes two numbers a subject, x then y: ${e.length} subjects need ${2*e.length}, not ${t.length}`);if(n!==void 0&&!(n>0&&n<Number.POSITIVE_INFINITY))throw new RangeError(`blits: plot's cell is a size above 0, not ${n}`);yD(this).set(e,t,n??Number.NaN),this.moved()}function mD(e){return yD(this).place(e)}function yD(e){if(e.places!==null)return e.places;let t=new Im(n=>e.chains.get(n)?.slot??-1,!tc());e.places=t;for(let n of e.cued)n.bound===null&&cm(e,n);return t}function gD(){this.places!==null&&(this.places.dirty=!0),this.lanes?.refill(),this.stir()}function bD(e,t,n){let r=this.places,o=r===null?void 0:r.at.get(e);if(r===null||o===void 0)throw new Error("blits: put takes a subject with an index: place or plot it first");if(2*o+1>=r.xy.length)throw new RangeError(`blits: put's subject is at index ${o}, past the positions plot was given: plot again with room for it`);r.put(o,t,n),this.lanes?.refill(),this.stir()}var Em=class{list=[];head=0;get length(){return this.list.length-this.head}push(t){this.list.push(t)}shed(t,n){let r=this.list,o=this.head;for(;o+1<r.length&&r[o+1].at<=t;)n?.(r[o]),o++;o>=512&&o*2>=r.length&&(r.splice(0,o),o=0),this.head=o}at(t){let n=this.list,r=this.head,o=n.length-1,i;for(;r<=o;){let s=r+o>>1,a=n[s];a.at<=t?(i=a,r=s+1):o=s-1}return i}numbered(t){let n=this.list,r=this.head,o=n.length-1;for(;r<=o;){let i=r+o>>1,s=n[i];if(s.seq===t)return s;s.seq<t?r=i+1:o=i-1}}all(){return this.list.slice(this.head)}set(t){this.list=t,this.head=0}};var Mm=class e{keeps;log;constructor(t,n=[{anchorNow:0,anchorElapsed:0,rate:1,ramp:null,seq:Number.NEGATIVE_INFINITY}]){this.keeps=t,this.log=n}get clock(){return this.log[this.log.length-1]}get waiting(){return Number.isNaN(this.clock.anchorNow)}sync(t){return this.waiting&&(this.log=[{...this.clock,anchorNow:t,anchorElapsed:t}]),this.reading(t)}reading(t){if(this.waiting)return t;let n=this.log,r=n.length-1;for(;r>0&&n[r].anchorNow>t;)r--;return ze(n[r],t)}at(t,n){if(!(t>n)||this.waiting)return this.reading(t);let r=this.clock,o=r.ramp;return(o===null?r.rate<=0:o.to<=0&&t>r.anchorNow+o.over)?Number.POSITIVE_INFINITY:ze(r,t)}timeOf(t){if(this.waiting)return t;let n=this.log,r=0;for(;r+1<n.length&&t>n[r+1].anchorElapsed;)r++;return Cn(n[r],t)}rateAt(t){let n=this.clock;return this.waiting||Number.isNaN(t)?n.ramp===null?n.rate:n.ramp.from:ya(n,t)}stopped(t){let n=this.clock,r=n.ramp;return r===null?n.rate===0:r.to===0&&!this.waiting&&t>=n.anchorNow+r.over}change(t,n,r,o,i){let s=this.clock,a={...s,seq:i};if(Number.isNaN(t)||this.waiting){let u=this.rateAt(Number.NaN);a.ramp=r>0&&n!==u?{from:u,to:n,over:r}:null,a.rate=n,a.anchorNow=Number.NaN,this.log=[a];return}ga(a,t,n,r);let l=this.log;this.keeps&&s.anchorNow<t?l.push(a):l[l.length-1]=a,this.shed(o)}shed(t){let n=this.log,r=0;for(;r+1<n.length&&n[r+1].anchorElapsed<=t;)r++;return r>0?n.splice(0,r):[]}unshed(t){let n=this.log[0].anchorNow,r=t.filter(o=>o.anchorNow<n).sort((o,i)=>o.anchorNow-i.anchorNow);r.length>0&&(this.log=[...r,...this.log])}cut(t){let n=this.log,r=1;for(;r<n.length&&n[r].anchorNow<=t;)r++;n.length=r}until(t){let n=this.log,r=1;for(;r<n.length&&n[r].anchorNow<t;)r++;return new e(this.keeps,n.slice(0,r))}};var Cm=e=>({t:Number.NaN,seq:0,up:null,rank:0,left:null,cut:null,of:e}),xD=Cm(null);function BY(e){let t=e,n=t.up;for(;n!==null;){let r=n.up;if(r===null)return n;t.up=r,t=r,n=t.up}return t}var Nc=class extends me{own;now;make;stamp=Cm(this);first=this.stamp;at=new me;roots=[];kept=0;ready=[];aging=[];top=Number.NaN;constructor(t,n,r){super(),this.own=t,this.now=n,this.make=r}back(t,n,r){let o=this.stamp;r!==null&&(o.left=r,o.cut=n);let i=this.roots,s=o,a=null;for(;i.length>0;){let l=i[i.length-1].deref();if(l!==void 0&&l.t<t)break;let u=i.pop();l!==void 0&&(l.rank>s.rank?(s.up=l,s=l,a=u):(l.up=s,l.rank===s.rank&&s.rank++))}s.t=t,s.seq=n.seq,i.push(a??new WeakRef(s)),i.length>2*this.kept+16&&(this.roots=i.filter(l=>l.deref()!==void 0),this.kept=this.roots.length),this.stamp=this.fresh(),this.top=t}fresh(){if(this.ready.length===0){let t=Math.min(64,Math.max(1,this.aging.length*2));this.ready=this.aging.reverse(),this.aging=[];for(let n=0;n<t;n++)this.aging.push(Cm(this))}return this.ready.pop()??Cm(this)}sure=!0;get(t){return this.from(t,this.own.get(t))}find(t,n){let r=n.restored;return r!==null&&r.of===this&&this.sure?this.from(t,n):this.get(t)}from(t,n){let r=n?.reaches,o=(r?n.restored:this.at.get(t))??this.first,i=this.stamp;if(o===i)return n;r?n.restored=i:this.at.set(t,i);let s=BY(o),a=o.left?.at(t,o.cut),l=a??this.now(t,n,s),u=l&&this.make(l,s,a===void 0);return u===void 0?(this.shed(t),r&&this.at.set(t,i)):u!==n?this.set(t,u):u.reaches||this.at.set(t,i),u}set(t,n){let r=this.own.get(t);if(r===n){n.reaches?n.restored=this.stamp:this.at.set(t,this.stamp);return}r?.reaches&&(r.restored=xD),n.reaches&&n.restored!==null&&(this.sure=!1),this.own.set(t,n),n.reaches?n.restored=this.stamp:this.at.set(t,this.stamp)}delete(t){this.shed(t),this.at.set(t,this.stamp)}shed(t){let n=this.own.get(t);n?.reaches&&(n.restored=xD),this.own.delete(t)}clear(){this.sure=!1,this.own.clear(),this.at.clear()}};function Wa(e,t){if(e.reaches(t))return!1;let n=e.pager;if(n===null)throw new Error(`blits: ${t} is older than this mix's history reaches`);let r=n.loaded;if(r===null||r.t>t){let o=n.last;throw new ic(o?.mix??"",o?.stream??"history",t)}for(let o of[...e.members,...e.dropped.map(i=>i.mix)]){let i=o.name??"";if(o.outs?.missing(r.t,a=>r.records.some(l=>l.stream==="voice"&&l.voice===a&&l.mix===i))!==void 0)throw new ic(i,"voice",t)}return n.loaded=null,HY(e,r.records),e.floor=r.t,!0}function Om(e,t){if(!Number.isInteger(t))throw new RangeError(`blits: a frame is a number \`seq\` read, not ${t}`);let n=e.frames.numbered(t),r=e.pager;if(n===void 0&&r!==null&&t<=e.seq){let o=r.loaded?.records.find(i=>i.stream==="frame"&&i.mix===""&&i.seq===t);if(o!==void 0)Wa(e,o.at),n=e.frames.numbered(t);else if(t<(e.frames.all()[0]?.seq??Number.POSITIVE_INFINITY))throw new Error(`blits: frame ${t} reaches past memory; await prepare with its mix time first`)}if(n===void 0)throw new Error(`blits: frame ${t} is not one this mix's history holds: not played yet, let go, or after a moment a seek went back to`);return Wa(e,n.at),n}function PD(e,t){let n=e.pager;if(n===null)return;n.store.cut(t);let r=n.loaded;r!==null&&(r.records=r.records.filter(o=>o.seq<=t))}function HY(e,t){GY(e,t);let n=new Map;for(let o of[...e.members,...e.dropped.map(i=>i.mix)])n.set(o.name??"",o);let r=new Map;for(let o of[...t].sort((i,s)=>i.seq-s.seq)){let i=n.get(o.mix);if(i===void 0)continue;let s=r.get(i);s===void 0?r.set(i,[o]):s.push(o)}for(let[o,i]of r)UY(o,i)}function GY(e,t){let n=t.filter(a=>a.mix===""&&a.voice===void 0),r=n.filter(a=>a.stream==="pace").map(a=>a.data);r.length>0&&e.pace?.unshed(r);let o=n.filter(a=>a.stream==="frame").map(a=>({seq:a.seq,at:a.at,u:a.data}));e.frames.set(Ic(o,e.frames.all()));let i=new Set(e.announced.map(a=>a.order)),s=n.filter(a=>a.stream==="mark"&&!i.has(a.data.order)).map(a=>a.data);s.length>0&&(e.announced=[...s,...e.announced].sort((a,l)=>a.order-l.order))}function UY(e,t){let n=new Map;for(let s of[...e.cued,...e.gone])n.set(s.id,s);for(let s of t)if(s.stream==="voice"&&s.voice!==void 0&&!n.has(s.voice)){let a=PL(e,s.voice,s.data);n.set(a.id,a),e.gone.push(a),_h(e,a)}let r=t.filter(s=>s.stream==="host");e.hostLog=Ic(r.map(s=>({at:s.at,seq:s.seq,fields:s.data})),e.hostLog);let o=new Map;for(let s of t){if(s.voice===void 0)continue;let a=o.get(s.voice);a===void 0?o.set(s.voice,[s]):a.push(s)}let i=e.keys;for(let[s,a]of o){let l=n.get(s);l!==void 0&&WY(l,a,i)}}function WY(e,t,n){let r=s=>t.filter(a=>a.stream===s);e.log!==null&&(e.log=Ic(r("controls").map(s=>s.data),e.log));let o=r("left");if(o.length>0){let s=[...e.left?.all()??[]];for(let a of o){let l=n.subject(a.subject);if(s.some(p=>p.seq===a.seq&&Object.is(p.subject,l)))continue;let[u,c,d=null,f=null]=a.data;s.push({subject:l,at:a.at,seq:a.seq,sync:c,held:Ui(e,u),ramp:d,parted:f})}s.sort((a,l)=>a.seq-l.seq),e.left=Fn.from(s)}for(let[s,a]of BT(r("snap"))){let l=n.subject(s);for(let[u,c]of wD(e,l,a))u.snaps=Ic(c.map(d=>({at:d.at,seq:d.seq,held:Ui(e,d.data)})),u.snaps??[])}for(let[s,a]of BT(r("input"))){let l=n.subject(s);for(let[u,c]of wD(e,l,a))u.inputs=Ic(c.map(d=>({at:d.at,seq:d.seq,value:d.data})),u.inputs??[])}let i=e.motion;if(i!==void 0){for(let s of r("released"))i.reclaim(n.subject(s.subject),s.at,s.seq,s.data);for(let[s,a]of BT(r("stretch")))i.restretch(n.subject(s),a)}}function BT(e){let t=new Map;for(let n of e){let r=t.get(n.subject);r===void 0?t.set(n.subject,[n]):r.push(n)}return t}function wD(e,t,n){let r=e.left?.of(t)??[],o=[],i=Number.NEGATIVE_INFINITY;for(let a of r)o.push([a.held,n.filter(l=>l.seq>i&&l.seq<=a.seq)]),i=a.seq;let s=e.subjects.get(t);return s?.reaches&&o.push([s,n.filter(a=>a.seq>i)]),o}function Ic(e,t){let n=t[0]?.seq??Number.POSITIVE_INFINITY,r=[];for(let o of e)o.seq<n&&(r.length>0&&r[r.length-1].seq===o.seq?r[r.length-1]=o:r.push(o));return r.length===0?t:[...r,...t]}function VY(e,t,n,r,o,i){let s=r.t,a=n.inputs?.filter(P=>P.at<=s),l=n.snaps;if(l===void 0){let P=i&&n.reaches?Ba(n):Vo(t,n);return P.stepped>s&&(P.stepped=s),TD(P,n,s),P.weight=0,P.inputs=a,P.since<=s||Aa(e,t,P),P}let u=l.length,c=u>0&&l[u-1].at<=s?u-1:u>1&&l[u-2].at<=s?u-2:cT(l,s,!0);if(c<0)return;let d=l[c],{ticks:f,since:p,rebuilt:h,state:m,slot:g,restored:b}=n,x;i&&n.reaches?(x=fT(t,d.held,n,!0),x.slot=g,x.restored=b):x=Vo(t,d.held,!0),x.weight=0,TD(x,n,s),d.at<s&&(x.copied=!0);let w=c+1;if(i)zY(t,l,w);else for(let P=0;P<w;P++)l[P].shared=!0;x.snaps=i?l:l.slice(0,w),x.inputs=a,x.since<=d.at||Aa(e,t,x);let y=i&&f>x.ticks&&p===x.since&&h===x.rebuilt;if(t.patch.step!==void 0&&(d.ahead!==void 0||s-d.at>=o||y)){let P=d.ahead;P===void 0||P.since!==x.since?(P={put:x,sought:s,since:x.since,at:d.at,ticks:x.ticks,state:void 0,leftTicks:0,left:void 0},d.ahead=P):(P.put=x,P.sought=s),y&&(P.leftTicks=f,P.left=m)}return x}function TD(e,t,n){e.restedAt=t.restedAt<=n?t.restedAt:Number.NaN}function zY(e,t,n){for(;t.length>n;){let r=t.pop();r.shared||(r.ahead=void 0,e.spares??=[],e.spares.push(r))}}function KY(e,t){let n=t.owner;n?.holding&&(n.holding.kids--,t.passed&&n.holding.played--);let r=t.motion;r!==void 0&&r.owner===e.owner&&r.ownerId===t.id&&(r.owner=null),t.park()}function jY(e,t,n,r){let o={seq:r,strict:!1},i=t.log,s=Sc(i,o)??i[0];if(i.length=i.indexOf(s)+1,t.take(s),t.reopen(r)&&t.owner?.holding&&t.owner.holding.played--,t.doneAt=Number.POSITIVE_INFINITY,t.doneSeq=Number.POSITIVE_INFINITY,t.parts!==null){for(let[c,d]of t.parts)d.seq>r&&t.parts.delete(c);t.parts.size===0&&(t.parts=null)}if(t.parted!==null){for(let[c,d]of t.parted)d.seq<=r||(t.parted.delete(c),!(d.ramp===void 0||d.ramp.seq>r)&&(t.parts??=new Map,t.parts.set(c,d.ramp)));t.parted.size===0&&(t.parted=null)}t.seen=0,t.restedCount=0,t.early=null,t.holder=null,t.keepOn=null,t.laned=!1,t.unreached=null,t.unreachedBits=null,t.seeks++,t.spares=null;let a=t.left?.all()??[];t.left!==null&&ym(t,t.left.after(o),r),t.left=Fn.from(a.filter(c=>c.seq<=r));let l=Fn.from(a.filter(c=>c.seq>r)),u=t.subjects;if(!(u instanceof Nc)){let c=kc(e.opts.history),d=(p,h,m)=>Nh(t,p,h,m.t,m.seq),f=new Nc(u,d,(p,h,m)=>{let g=VY(e,t,p,h,c,m);return g===void 0||(g.reaches&&t.seen++,Oo(g)&&t.restedCount++,g.since<=f.top||(t.early??=[],t.early.push(g))),g});u=f,t.subjects=u}u.back(n,o,l)}function Va(e,t){if(e.projecting)throw new Error("blits: a projection does not seek");if(!e.history)throw new Error("blits: seeking needs a mix made with history");let r=e.tape;if(r===void 0)throw new Error("blits: seeking needs history.tape, which keeps the calls a seek plays again");if(Number.isNaN(e.now))throw new Error("blits: a mix that has never synced has nothing to seek");let o,i;if(typeof t=="number"){if(o=t,o===Number.POSITIVE_INFINITY)throw new RangeError("blits: a mix seeks to a finite time");if(!(o>=e.born))throw new Error(`blits: ${o} is older than this mix's history reaches`);if(Wa(e,o),o<e.now&&(i=e.frames.at(o),i===void 0))throw new Error(`blits: ${o} is older than this mix's history reaches`)}else{let s=Om(e,t.frame);o=s.at,s.seq!==e.seq&&(i=s)}if(i===void 0){let s=Ma(e,c=>(e.pace===null?c:e.pace.reading(c))<=o),a=e.left,l=a!==null&&a.t===o&&a.u>=e.u&&(e.pace===null?a.u:e.pace.reading(a.u))===o?a.u:$r(e,o),u=Number.isNaN(s)?l:Math.max(s,l);if(!Number.isFinite(u))throw new RangeError(`blits: the mix's rate never reaches ${o}`);if(e.u=u,Number.isNaN(s)||e.now!==o)for(let c of e.members)Yr(c,o)}else{let s=i.at===o?i.u:ji(e,o),a=i.seq;e.left={t:e.now,u:e.u},r.goto(r.depthAt(s)),e.undrop(a),e.announced=e.announced.filter(l=>l.seq<=a),e.frames.set(e.frames.all().filter(l=>l.seq<=a)),e.pacedSeq>a?(e.pace=null,e.pacedSeq=Number.POSITIVE_INFINITY):e.pace?.cut(s),e.u=s,e.now=o;for(let l of e.members)$Y(l,o,a,i.at<o);PD(e,a)}e.tick(o),e.offset=e.last-e.u,e.kept();for(let s of e.members){s.stir();let a=s.bookers;if(a!==null)for(let l of a)l.sought()}}function $Y(e,t,n,r){let o=[...e.cued,...e.gone].sort((c,d)=>c.id-d.id),i=[],s=[],a=new Set;for(let c of o)c.motion!==void 0&&a.add(c.motion);for(let c of o)c.cuedSeq>n?KY(e,c):c.doneSeq<=n?s.push(c):i.push(c);for(let c of i)jY(e,c,t,n);let l={seq:n,strict:!1};for(let c of i)c.state=c.stateAt(t,l),c.begunSeq>n&&(c.begunSeq=Number.POSITIVE_INFINITY);e.cued=i,e.gone=s,e.retired=[];for(let c of i)c.holding!==null&&(c.holding.children=i.filter(d=>d.owner===c),c.holding.back(n));let u=e.lanes;u!==null&&e.lanesOf!==null?e.lanes=new e.lanesOf(Zh(e),u):e.chains=new me,e.owners=i.some(c=>c.holding!==null)?i.filter(c=>c.holding!==null):null,Wo(e),e.parters.clear();for(let c of[...i,...s])(c.parts!==null||c.parted!==null)&&e.parters.add(c);e.relinks++,e.lastPoses=new me,e.restStamps!==null&&(e.restStamps=new me),h_(e);for(let c of[...i,...s]){c.unreached=null,c.unreachedBits=null;let d=c.blend?.of;d!==void 0&&(d.frame=0,d.reads=new me,d.frames=new Float64Array(0),d.values=new Float64Array(0))}e.playing.clear();for(let c of i){let d=c.motion;d!==void 0&&(e.playing.set(d,(e.playing.get(d)??0)+1),e.owner!==null&&(d.owner=e.owner,d.ownerId=c.id))}for(let c of a)u!==null&&c.watcher===u&&(c.watcher=null),c.rewind(n);e.hostLog=e.hostLog.filter(c=>c.seq<=n),e.sent=e.sent.filter(c=>c.timestamp<=t),e.sentTo=t,e.pins=null;for(let c of i)c.state==="pending"&&!Number.isNaN(c.pinned)&&(e.pins??=new Map,e.pins.set(c,c.pinned));e.due.clear();for(let c of i)it(e,c);if(e.stir(),r)Yr(e,t);else{e.frame=st(),e.reducedNow=e.reduced;let c=e.opts.history.ms;e.anchored>0&&e.transport.forgotTo>=t-c&&zr(e)}}var GT=Symbol.for("@msb235/blits/watch/1"),UT=globalThis;function WT(){let e=UT[GT];if(e!==void 0)return e;let t=new Map,n=new Set,r=new WeakMap;return e={refs:t,entries_:r,fns:n,labels:new WeakMap,next:1,counted:0,history:void 0,gone:new FinalizationRegistry(o=>{t.delete(o);for(let i of[...n])i({kind:"gone",id:o})}),entries(){let o=[];for(let i of t.values()){let s=i.deref(),a=s===void 0?void 0:r.get(s);a!==void 0&&o.push(a)}return o},on(o){return n.add(o),()=>{n.delete(o)}}},UT[GT]=e,e}var kD=new WeakSet;function vD(e){let t=UT[GT]?.history;return e.history!==void 0||e.transport!==void 0||t===void 0?{history:e.history,added:!1}:{history:t,added:!0}}function AD(e){kD.add(e)}function RD(e){let t=WT(),n=t.next++,r=e.transport,o={id:n,release:xh,name:e.name,mix:e,get history(){let i=r.history;return i===void 0?void 0:{ms:i.ms,tape:r.tape!==void 0,added:kD.has(r)}},get reach(){return MD(r,!1)},channels:e.names,voice:i=>{let s=e.cued.find(a=>a.handle===i)??e.gone.find(a=>a.handle===i);return s===void 0?void 0:{name:s.spec.name,tags:s.spec.tags??[],within:s.bound?.area}},label:i=>YY(e,i),watch:i=>JY(e,i),subjects:()=>XY(e),read:(i,s=e.now)=>e.project(s).probe(i),hold:()=>eq(r)};t.entries_.set(e,o),t.refs.set(n,new WeakRef(e)),t.gone.register(e,n,e);for(let i of[...t.fns])i({kind:"add",entry:o})}function ND(e){let t=WT(),n=t.entries_.get(e);if(n===void 0||!t.refs.has(n.id))return;t.refs.delete(n.id),t.gone.unregister(e),ID(e);let r=e.transport,o=Ec(r).held,i=s=>t.refs.has(t.entries_.get(s)?.id??-1);o!==null&&!r.members.some(i)&&o.free();for(let s of[...t.fns])s({kind:"gone",id:n.id})}function YY(e,t){return e.opts.labelOf?.(t)??qY(t)}function qY(e){if(typeof e!="object"||e===null)return typeof e=="function"?e.name||"function":String(e);let t=globalThis.Element;if(t!==void 0&&e instanceof t){let i=e.id?`#${e.id}`:"",s=[...e.classList].map(a=>`.${a}`).join("");return`${e.tagName.toLowerCase()}${i}${s}`}let n=e;for(let i of["name","id"]){let s=n[i];if(typeof s=="string"&&s!==""||typeof s=="number")return String(s)}let r=WT(),o=r.labels.get(e);return o===void 0&&(o=`${e.constructor?.name||"Object"} #${++r.counted}`,r.labels.set(e,o)),o}function XY(e){let t=or.get(e),n=new Set(t?.was);for(let r of t?.seen??[])n.add(r);for(let r of e.cued)if(r.state!=="done")for(let o of r.spec.subjects??[])n.add(o);return[...n]}var SD=new WeakMap;function Ec(e){let t=SD.get(e);return t===void 0&&(t={tapped:0,held:null,unsync:null},SD.set(e,t)),t}function Fm(e){let t=Ec(e),n=t.tapped>0||t.held!==null;if(n&&t.unsync===null){let r=Lm(e).sync;t.unsync=Xr(e,"sync",o=>{for(let s of e.members)ED(s);let i=t.held;i===null?r.call(e,o):i.sync(o)})}else!n&&t.unsync!==null&&(t.unsync(),t.unsync=null)}function Xr(e,t,n){let r=e,o=r[t];return r[t]=n,()=>{r[t]=o}}function Lm(e){return Object.getPrototypeOf(e)}var or=new WeakMap;function JY(e,t){let n=or.get(e);if(n===void 0){let r=Lm(e),o=r.probe,i=r.pull,s=r.drain,a=[Xr(e,"probe",(l,u)=>{let c=o.call(e,l,u);return HT(e).probed.push({subject:l,pose:ZY(c)}),or.get(e).seen.add(l),c}),Xr(e,"pull",(l,u)=>{let c=Array.isArray(l)?l:[...l];i.call(e,c,u);let d={};for(let[p,h]of Object.entries(u))h!==void 0&&(d[p]=h.slice());HT(e).pulled.push({subjects:[...c],columns:d});let f=or.get(e).seen;for(let p of c)f.add(p)}),Xr(e,"drain",l=>{let u=s.call(e,l);return u.length>0&&HT(e).sent.push(...u),u})];n={fns:new Set,frame:null,seen:new Set,was:new Set,untap:()=>{for(let l of a)l()}},or.set(e,n),Ec(e.transport).tapped++,Fm(e.transport)}return n.fns.add(t),QY(new WeakRef(e),t)}function QY(e,t){return()=>{let n=e.deref(),r=n===void 0?void 0:or.get(n);n===void 0||r===void 0||!r.fns.delete(t)||r.fns.size>0||ID(n)}}function ID(e){let t=or.get(e);t!==void 0&&(t.untap(),or.delete(e),Ec(e.transport).tapped--,Fm(e.transport))}function HT(e){let t=or.get(e);return t.frame!==null&&t.frame.seq===e.transport.seq||(ED(e),t.was=t.seen,t.seen=new Set,t.frame={seq:e.transport.seq,now:e.now,timestamp:e.timestamp,probed:[],pulled:[],sent:[],voices:e.voices()}),t.frame}function ED(e){let t=or.get(e),n=t?.frame;if(!(t===void 0||n==null)){t.frame=null;for(let r of[...t.fns])r(n)}}function ZY(e){try{return globalThis.structuredClone(e)}catch{return{...e}}}function MD(e,t){let n=e.history;if(n===void 0||t&&e.tape===void 0)return e.now;let r=e.pager!==null?Number.NEGATIVE_INFINITY:e.now-n.ms;return Math.max(e.born,e.floor,r)}function eq(e){let t=Ec(e);if(t.held!==null)throw new Error("blits: that mix is held already; free it first");let n=Lm(e),r=n.ramp,o=n.rebase,i=n.sync,s=n.seek,a=[],l=0,u=!1,c=!1,d=e.last,f=e.last,p=y=>{let P=u;u=!0;try{y()}finally{u=P}},h=y=>{e.replaying||u?y():a.push(y)},m=()=>{e.rebasing&&!Number.isNaN(e.last)&&i.call(e,e.last),i.call(e,d)},g=[],b=e.tape;if(b!==void 0){let y=b.recordEntry;g.push(Xr(b,"recordEntry",(...P)=>{u||b.timestampAt(b.undoDepth())!==void 0||y.apply(b,P)}))}g.push(Xr(e,"ramp",(y,P)=>{if(!(y>=0&&y<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a mix's rate is a finite number, 0 or more, not ${y}`);h(()=>r.call(e,y,P))}),Xr(e,"rebase",()=>h(()=>o.call(e))),Xr(e,"seek",y=>h(()=>s.call(e,y))));for(let y of e.members){let P=Lm(y).seek;g.push(Xr(y,"seek",S=>{e.shared?P.call(y,S):h(()=>P.call(y,S))}))}t.held={sync(y){Number.isNaN(d)?d=y:!Number.isNaN(f)&&y>f&&(d+=(y-f)*l),f=y,m()},free:()=>w.free()},Fm(e),e.woke();let x=()=>{if(c)throw new Error("blits: that hold was freed")},w={get mixes(){return[...e.members]},get now(){return e.now},get reach(){return MD(e,!0)},get rate(){return l},set rate(y){if(x(),!(y>=0&&y<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a hold's rate is a finite number, 0 or more, not ${y}`);l=y},seek(y){x(),p(()=>Va(e,y))},step(y){if(x(),!(y>0))return;if(Number.isNaN(d))throw new Error("blits: a mix that has never synced has nothing to step");let P=$r(e,e.now+y);if(!Number.isFinite(P))throw new RangeError("blits: the mix's own rate is 0, so it never moves");d=Math.max(d,P+e.offset),m();for(let S of e.members)S.stir()},free(){if(!c){c=!0;try{o.call(e);for(let y of a)y()}finally{for(let y of g.reverse())y();t.held=null,Fm(e),e.woke()}}}};return w}var tq=1e3,zo=class{history;shared;members=[];dropped=[];slots=0;holders=new Map;wakeFns=[];woken=!1;now=Number.NaN;seq=0;frames=new Em;u=Number.NaN;offset=0;left=null;born=Number.NaN;floor=Number.NEGATIVE_INFINITY;last=Number.NaN;rebasing=!1;taped=Number.NEGATIVE_INFINITY;pace=null;forgotTo=Number.NEGATIVE_INFINITY;settled=Number.NEGATIVE_INFINITY;settle(){this.now>this.settled&&(this.settled=this.now)}pacedSeq=Number.POSITIVE_INFINITY;ahead=new Map;replaying=!1;announced=[];nextId=1;tape;pager;constructor(t,n){this.history=t,this.shared=n,this.tape=SF(this),this.pager=t?.store===void 0?null:new Ch(t.store)}get projecting(){return this.members.some(t=>t.projecting)}join(t,n=this.slots++){t.slot=n;let r=this.members.findIndex(o=>o.slot>n);r<0?this.members.push(t):this.members.splice(r,0,t),PO(t)}drop(t){let n=t,r=this.members.indexOf(n);if(r<0)throw new Error(`blits: ${n.name??"that mix"} is not on this transport`);this.members.splice(r,1),TO(n),n.dropped=!0,this.history!==void 0&&(this.dropped.push({mix:n,at:this.now,seq:this.seq}),Ot(this,"drop",o=>{let i=o.mix(n);i!==void 0&&o.transport(this).drop(i)}))}undrop(t){let n=this.dropped.filter(r=>r.seq>t);if(n.length!==0){this.dropped=this.dropped.filter(r=>r.seq<=t);for(let r of n)r.mix.dropped=!1,this.join(r.mix,r.mix.slot)}}seek(t){Va(this,t)}prepare(t){return xO(this,t)}announce(t,n){if(n?.score===void 0)throw new Error("blits: a transport announces on a named score, which every mix on it sees");VT(this,t,n,-1,void 0)}marks(t,n){return cF(this,t,n).map(({order:r,...o})=>o)}project(t){return _m(this,t)}get live(){return this.members.some(t=>t.live)}get inert(){return this.members.every(t=>t.inert)}onWake(t){let n=this.wakeFns;return n.push(t),()=>{let r=n.indexOf(t);r>=0&&n.splice(r,1)}}woke(){if(!this.woken){this.woken=!0;for(let t of[...this.wakeFns])t()}}sync(t){let n=this.members;for(let r of n)r.syncing=!0;try{this.syncAt(t)}finally{for(let r of n)r.syncing=!1}}syncAt(t){if(Number.isNaN(t))throw new RangeError("blits: sync was given NaN; it takes the host clock as a number");if(t<this.last&&!this.rebasing)throw new RangeError(`blits: sync went back from ${this.last} to ${t}; the host's clock only goes forward, and seek moves the mix`);this.rebasing&&!Number.isNaN(this.last)&&(this.offset+=t-this.last),this.rebasing=!1,this.last=t;let n=t-this.offset,r=this.pace,o=r===null?n:r.sync(n),i=n!==this.u,s=i&&o===this.now;this.u=n,Number.isNaN(this.born)&&(this.born=o);let a=!1;if(this.tape!==void 0&&i&&(a=Ma(this,c=>c<=n)===n,r=this.pace,o=r===null?n:r.reading(n)),!a){this.tick(o);let c=o!==this.now;for(let d of this.members)(c||i&&r!==null&&AL(d))&&Yr(d,o)}let l=this.history;this.kept();let u=this.keepsFrom();if(this.tape!==void 0&&l!==void 0&&!(u-this.taped<tq)){let c=ji(this,u);c<Number.POSITIVE_INFINITY&&this.tape.prune(c),this.taped=u}if(l!==void 0&&this.dropped.length>0&&(this.dropped=this.dropped.filter(c=>c.at>=u)),this.frames.shed(u),bO(this),this.woken=!1,s)for(let c of this.members)c.frame=st(),c.lanes?.refill();for(let c of this.members){let d=c.bookers;if(d!==null)for(let f of d)f.sync()}}tick(t){let n=++this.seq;this.history!==void 0&&this.frames.push({seq:n,at:t,u:this.u});for(let r of this.members)r.looked=!1}rebase(){this.rebasing=!0,this.settle()}kept(){let t=this.history;t!==void 0&&this.pager===null&&this.now-t.ms>this.floor&&(this.floor=this.now-t.ms)}reaches(t){return this.pager!==null?t>=this.floor:t>=this.floor&&t>=this.now-(this.history?.ms??0)}keepsFrom(){let t=this.history;return t===void 0?Number.POSITIVE_INFINITY:this.pager===null?this.now-t.ms:Number.NEGATIVE_INFINITY}get rate(){return this.pace===null?1:this.pace.rateAt(this.u)}set rate(t){this.ramp(t,0)}ramp(t,n){if(!(t>=0&&t<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a mix's rate is a finite number, 0 or more, not ${t}`);if(this.pace===null){this.pace=new Mm(this.history!==void 0||this.projecting),this.pacedSeq=this.seq;for(let o of this.members)for(let i of o.cued)i.state==="pending"&&!i.placing&&i.owner===null&&i.spec.start!==void 0&&Ho(o,i,i.start)}let r=this.history===void 0?Number.NEGATIVE_INFINITY:this.keepsFrom();this.pace.change(this.u,t,n,r,this.seq);for(let o of this.members)o.stir();Ot(this,"rate",o=>o.transport(this).ramp(t,n))}};function VT(e,t,n,r,o){let i=n.at!==void 0?n.at-e.offset:e.u,s={name:t,score:n.score,tags:n.tags??[],at:i,order:e.nextId++,seq:e.seq,slot:r,mix:o};e.announced.push(s),e.settle(),Ot(e,"announce",a=>{let l=a.transport(e);l.announced.push({...s,seq:l.seq})})}function FD(e,t,n,r,o){let i=e.tape,s=i?.undoDepth()??0;try{for(;;){let a=nq(i,t,r);if(!(a<r))break;if(CD(e,t,n,a),!LD(t))continue;for(let u of t.members)u.anchored>0&&zr(u);let l=rq(t);for(let[u,c]of n){let d=new Ko(c.kit,{...c.opts,transport:l},null);d.slot=c.slot,d.projecting=!0,d.share=c.share,zT(c,d);let f=o.get(u);f===void 0?o.set(u,{at:[c],met:new Set}):f.at.push(c),n.set(u,d)}t=l}CD(e,t,n,r)}finally{i!==void 0&&i.undoDepth()!==s&&i.goto(s)}return t}function LD(e){for(let t of e.members)for(let n of t.cued)if(n.state!=="done"&&(n.patch.step!==void 0||typeof n.spec.weight=="function"))return!0;return!1}function nq(e,t,n){let r=t.now,o=Number.POSITIVE_INFINITY,i=e?.timestampAt(e.undoDepth());if(i!==void 0&&(o=t.pace===null?i:t.pace.reading(i)),!LD(t))return o<n?o:Number.POSITIVE_INFINITY;for(let s of t.members)for(let a of s.cued){if(a.state==="done")continue;for(let u of zi){let c=Xe(s,a,u);c!==void 0&&c>r&&c<o&&(o=c)}let l=a.spec.marks;if(l!==void 0)for(let u of Object.keys(l)){let c=Xe(s,a,u);c!==void 0&&c>r&&c<o&&(o=c)}}for(let s of t.announced){let a=t.pace===null?s.at:t.pace.at(s.at,t.u);a>r&&a<o&&(o=a)}return o<n?o:Number.POSITIVE_INFINITY}function CD(e,t,n,r){let o=e.tape,i=a=>(t.pace===null?a:t.pace.reading(a))<=r,s=o?.timestampAt(o.undoDepth());if(t.u=$r(t,r),s!==void 0&&i(s)){for(let l of t.members)for(let u of l.cued)u.parts!==null&&(u.parts=new Map(u.parts)),u.parted!==null&&(u.parted=new Map(u.parted));let a=Ma(e,i,t,{transport:()=>t,mix:l=>n.get(l)});t.u=Math.max(a,$r(t,r))}if(!(t.now>=r))for(let a of t.members)Yr(a,r)}function rq(e){let t=new zo(void 0,!0);return t.offset=e.offset,t.u=e.u,t.nextId=e.nextId,t.now=e.now,t.pace=e.pace===null?null:e.pace.until(Number.POSITIVE_INFINITY),t.announced=e.announced.map(n=>({...n})),t.ahead=e.ahead,t}function zT(e,t){Mc(e,t),t.cued=e.cued.filter(n=>n.state!=="done").map(n=>{let r={mix:e,voice:n,up:OD.get(n),seen:0,shared:!1,filled:!1},o=n.copy(s=>aq(r,s,t,o),void 0,!0);r.seen=o.seen,r.shared=o.sharing,OD.set(o,r);let i=e.pins?.get(n);return i!==void 0&&Ho(t,o,i),o}),t.waking=e.waking,Ca(t.cued),(e.owners!==null||e.projecting&&t.cued.some(n=>n.holding!==null))&&Sa(t.cued),Wo(t)}function Mc(e,t){t.lastPoses=e.lastPoses,t.wantsPose=e.wantsPose,t.reducedNow=e.reducedNow}function Dm(e,t,n){if(t.sharing){let o=ut(e,n)?.slot??-1,i=e.share;if(!i.sighted(t,o))return;let s=t.everyone;return i.open(t,s,o),s.weight=i.weightAt(t,o),s}let r=t.subjects.get(n);return r!==void 0||t.unreachedBits===null?r:ac(t,ut(e,n)?.slot??-1)?t.unreached:void 0}var OD=new WeakMap;function oq(e,t){return e.seen===t.seen&&!t.filled&&!t.shared&&e.unreached===null&&e.unreachedBits===null}function iq(e,t,n){return e.projecting&&n.reaches&&!t.sharing&&n!==t.unreached}function sq(e){return e.restored=null,Ba(e)}function aq(e,t,n,r){let o=e.mix,i=e.voice,s=e;for(;s.up!==void 0&&oq(s.voice,s.up);)s=s.up;if(s!==e&&Dm(s.mix,s.voice,t)===void 0)return;let a=Dm(o,i,t);if(a===void 0)return;let l=iq(o,i,a)?sq(a):Vo(i,a);return l.reaches&&!(l.since<=o.now)&&(l.since=n.sinceOf(r,l.delay),l.shown=n.shownOf(r,l.since)),l.from=l.stepped,e.filled=!0,l}function lq(e,t){let n=t.patch,r=t.spec;if(n.state!==void 0||n.step!==void 0)return"its patch keeps state";if(t.motion!==void 0)return"it plays a motion";if(t.keeping)return"its patch or its weight keeps state";if(r.from==="current")return"it starts from the pose its subjects had";if(t.written)return"its handle has been written to";if(r.anchor!==void 0)return"an anchor places it";if(t.holding!==null)return"it is an owner";if(t.owner!==null)return"it plays under an owner";if(!(typeof r.weight!="function"&&r.role===void 0&&!((t.fade.in??0)>0)&&!((t.fade.out??0)>0))&&t.slots.some(i=>e.channels[i]?.rest===void 0))return"it writes a channel with no rest at a weight that moves"}function _D(e,t){let n=`blits: reading back to ${t} needs a mix made with history`;if(e.pace!==null)throw new Error(`${n}: the mix's rate has been set`);if(t<e.settled)throw new Error(`${n}: a mix changed or a voice left at ${e.settled}, and without history a mix keeps only how it stands now`);for(let r of e.members)for(let o of r.cued){if(o.state==="done")continue;let i=lq(r,o);if(i!==void 0)throw new Error(`${n}: voice ${o.id} is cued, and ${i}`)}}function DD(e,t,n,r){Mc(e,t),t.backward=!0,t.cued=e.cued.filter(o=>o.state!=="done").map(o=>{let i=o.copy(a=>jT(e,o,a,n,r));i.out!==null&&i.out.at>n&&(i.out=null);let s=e.pins?.get(o);return s!==void 0&&Ho(t,i,s),i}),Ca(t.cued),e.owners!==null&&Sa(t.cued),KT(t,n),Wo(t)}function _m(e,t){let n=e.history!==void 0,r,o;if(typeof t=="number")r=t;else{if(!n)throw new Error("blits: reading a frame back needs a mix made with history");o=Om(e,t.frame),r=o.at}let i=o!==void 0?o.seq===e.seq:Number.isNaN(e.now)||r>=e.now,s=e.pace,a={seq:e.seq,strict:!1},l=i?$r(e,r):ji(e,r);if(!i&&n){o===void 0&&Wa(e,r);let m=o??e.frames.at(r);m!==void 0&&(a={seq:m.seq,strict:m.at===r},m.at===r&&(l=m.u))}else i||_D(e,r);let u=new zo(void 0,!0);u.offset=e.offset,u.u=l,u.nextId=e.nextId,u.now=i?e.now:r,u.pace=s===null||!$t(a,e.pacedSeq)?null:s.until(i?Number.POSITIVE_INFINITY:l),u.announced=(i?e.announced:e.announced.filter(m=>$t(a,m.seq))).map(m=>({...m}));let c=new Map;for(let m of e.members){let g=new Ko(m.kit,{...m.opts,history:void 0,lanes:!1,transport:u},null);g.slot=m.slot,g.projecting=!0,g.share=m.share,g.places=m.places,c.set(m,g),i?zT(m,g):n?uq(m,g,r,a):DD(m,g,r,a)}let d=u,f=null;i&&r!==e.now&&(f=new Map,d=FD(e,u,c,r,f));let p=!i&&n?a:null,h=m=>{pe.live=!1,pe.ahead=d.ahead.size>0?d.ahead:null,pe.back=p;try{return m()}finally{pe.live=!0,pe.ahead=null,pe.back=null}};return{timestamp:r,of(m){let g=m,b=c.get(g);if(b===void 0)throw new Error("blits: that mix is not on this transport");let x=f?.get(g),w=x===void 0?null:y=>{if(!x.met.has(y)){x.met.add(y);for(let P of x.at)P.fold(y)}};return{timestamp:r,probe:(y,P)=>h(()=>(w?.(y),b.fold(y,P))),assess:y=>h(()=>(w?.(y),b.fold(y),cq(b,y)))}}}}function uq(e,t,n,r){Mc(e,t),t.backward=!0;let o=Sc(e.hostLog,{seq:r.seq,strict:!1}),i=e.opts.host,s=o&&typeof i=="object"&&i!==null?Object.assign(Object.create(i),o.fields):void 0;o&&(t.hostThen=o),t.cued=[...e.cued,...e.gone].filter(a=>a.cuedSeq<=r.seq&&!$t(r,a.doneSeq,!0)).sort((a,l)=>a.id-l.id).map(a=>{let l=a.log,u=a.copy(c=>jT(e,a,c,n,r,t,u),Sc(l,r)??l[0]);if(s!==void 0&&(u.setting.host=s),a.parts!==null&&(u.parts=new Map(a.parts)),a.parted!==null&&(u.parted=new Map(a.parted)),a.left!==null&&ym(u,a.left.after(r),r.seq),u.parted!==null)for(let[c,d]of u.parted)d.ramp===void 0||!(n<d.at)||(u.parts??=new Map,u.parts.set(c,d.ramp));return u}),Ca(t.cued),e.owners!==null&&Sa(t.cued,r.seq),KT(t,n,r),Wo(t)}function KT(e,t,n){for(let r of e.cued)r.state=r.stateAt(t,n)}function jT(e,t,n,r,o,i,s){let a=t.left?.at(n,o)??Nh(t,n,Dm(e,t,n),r,o.seq);if(a===void 0)return;let l=a.snaps&&_a(a.snaps,r,!0);if(l){let f=Vo(t,l.held);return i!==void 0&&s!==void 0&&!(f.since<=l.at)&&Aa(i,s,f),f.from=f.stepped,f.replay=a.inputs,f}let u=i===void 0||s===void 0?a.since:i.sinceOf(s,a.delay),c=On(t,a.reaches,a.reaches&&t.patch.state?t.patch.state(n):void 0);c.delay=a.delay,c.since=u,c.shown=i===void 0||s===void 0?a.shown:i.shownOf(s,u);let d=FP(e,t,c,r);return c.rebuilt=t.rebuilds,c.from=c.stepped,c.unknown=t.spec.from==="current"||d,c.replay=a.inputs,c}function cq(e,t){let n={};for(let i of e.names)n[i]="exact";let r={exact:0,stepped:1,held:2};for(let i of e.cued){let s=i.spec.anchor;if(!(s===void 0||i.state==="done"||!(i.state==="pending"&&!Number.isFinite(i.start)||i.state!=="pending"&&i.state!=="fading"&&(s.out!==void 0||s.end!==void 0)&&!Number.isFinite(i.outAt))||!e.aims(i,t)))for(let l of i.slots)n[e.names[l]]="held"}let o=(i,s)=>{if(i.state==="done"||s.weight<=0)return;let a=dq(e,i,s);for(let l of i.slots){let u=e.names[l];r[a]>r[n[u]]&&(n[u]=a)}};for(let i=e.chain(t);i!==null;i=i.next)i.voice!==null&&o(i.voice,i);for(let i of e.sharers)i.everyone!==null&&i.state!=="pending"&&o(i,i.everyone);return n}function dq(e,t,n){let r=t.spec.weight;if(n.unknown)return"held";let o=n.replay!==void 0&&_a(n.replay,e.now,!0)!==void 0;if(typeof r=="function"&&r.input&&!o||t.owner!==null&&VO(t))return"held";let i=t.patch.reads;if(i!==void 0&&i.length>0){let s=e.hostThen?.fields;if(s===void 0||!i.every(a=>a in s))return"held"}if(e.now>(n.from??e.now)){let s=Io(e,t)!==void 0,a=n.kept!==null&&n.kept.size>0&&!o&&e.backward;if(t.patch.step&&!s||a)return"stepped"}return n.copied&&n.kept!==null&&n.kept.size>0&&!o?"stepped":"exact"}var Bm=class{list=[];from=0;push(t,n){this.list.length>=64&&(this.list=this.list.slice(32),this.from+=32),this.from+this.list.length!==n-1&&(this.list=[],this.from=n-1),this.list.push(t)}patch(t,n,r,o,i){if(!(n>=this.from))return;let s=this.list;for(let a=n-this.from;a<s.length;a++){let l=s[a];if(l==null)return;let u=null,c=t;for(;c!==null&&c.voice.id<l.id;)u=c,c=c.next;let d=c!==null&&c.voice===l?c:null,f=r.linkable(l,o,i);if(f===d)continue;let p=d===null?c:d.next;f!==null&&(f.voice=l,f.next=p);let h=f??p;u===null?t=h:u.next=h}return t}};function BD(e){this.restStamps??=new me;let t=this.linked(e),n=this.linkedLaned,r=this.lanes;if(n&&this.restsLaned()){let s=t.slot;if(!r.owes(s))return r.rests(s)}let o=(this.restStamps.get(e)??Number.NaN)-2*this.restsKey();if(o>=0)return o===1;this.restScratch??=this.pose();let i=this.foldWith(e,this.restScratch,t,n,!0);return this.rests(this.bounded.length===0?i:this.clamp(i))}function HD(e){for(let t=0;t<this.names.length;t++){let n=this.channels[t],r=e[this.names[t]];if(n.rest===void 0){if(r!==void 0)return!1}else if(!hc(r,n.rest))return!1}return!0}function GD(){return this.pace?.stopped(this.u)?this.cued.every(e=>e.state==="done"||e.state!=="pending"&&typeof e.spec.weight!="function"&&e.spec.anchor===void 0):this.cued.every(e=>this.still(e,this.now))}function UD(e,t){if(e.state==="done")return!0;if(e.state!=="frozen"&&e.state!=="live"||typeof e.spec.weight=="function"||e.parts!==null)return!1;let n=this.reducedNow?0:e.fade.in??0;if(n>0&&t-this.sinceOf(e,e.latest)<n)return!1;if(e.state==="frozen"||e.holding!==null)return!0;let r=e.motion;if(r===void 0||!(e.elapsedAt(t)>=e.latest))return!1;let o=e.early;if(o!==null){for(let i of o)if(i.since<=t&&!(i.probed>=i.since))return!1}return r.landed()}function WD(){return this.lanes.whole&&this.bounded.length===0}function VD(){return(this.frame!==this.restsFrame||this.version!==this.restsVersion||this.relinks!==this.restsRelinks||this.stirs!==this.restsStirs)&&(this.restsEpoch++,this.restsFrame=this.frame,this.restsVersion=this.version,this.restsRelinks=this.relinks,this.restsStirs=this.stirs),this.restsEpoch}function zD(e){return{n:0,voices:[],helds:[],deltas:[],weights:[],groups:[],names:[],m:0,mVoices:[],mDeltas:[],mWeights:[],mGroups:[],values:new Array(e).fill(void 0),taken:new Float64Array(e),heaviest:new Float64Array(e),met:new Uint8Array(e),touched:[],owned:new Array(e).fill(void 0)}}function fq(e,t,n,r){let o=e.owned[t];o===void 0&&(o=r.slice(),e.owned[t]=o);for(let i=0;i<o.length;i++)o[i]=i<n.length?n[i]:r[i];return o}function KD(e,t){e.touched.length=0;let n=0;for(let o=0;o<e.m;o++)e.mGroups[o]===t&&(n+=e.mWeights[o]);if(n<=0)return 0;let r=e.taken;for(let o=0;o<e.m;o++){if(e.mGroups[o]!==t)continue;let i=e.mWeights[o];if(i<=0)continue;let s=e.mDeltas[o],a=e.mVoices[o].slots;for(let l=0;l<a.length;l++){let u=a[l],c=s[this.names[u]];if(c===void 0)continue;let d=this.channels[u];if(e.met[u]===0){e.met[u]=1,e.touched.push(u),r[u]=i,e.heaviest[u]=i,e.values[u]=this.lerpsInto[u]!==void 0&&d.scale&&Array.isArray(c)?fq(e,u,c,d.rest):Hi(c);continue}let f=r[u]+i;if(r[u]=f,d.kind==="last"){i>=e.heaviest[u]&&(e.heaviest[u]=i,e.values[u]=Hi(c));continue}let p=e.values[u],h=this.lerpsInto[u];e.values[u]=h!==void 0&&p===e.owned[u]?h(p,p,c,i/f):d.lerp(p,c,i/f)}}for(let o=0;o<e.touched.length;o++)e.met[e.touched[o]]=0;return n>1?1:n}function pq(e,t,n){return e===null?!1:n>=t.length||e.voice===null?!0:t[n].id>e.voice.id}function jD(e,t,n,r,o,i,s){let a=this.now,l=this.roleScratch[this.roleDepth];l===void 0&&(l=zD(this.channels.length),this.roleScratch[this.roleDepth]=l),this.roleDepth++;try{l.n=0,l.m=0,l.names.length=0;let u=this.sharers,c=0,d=n;for(;d!==null||c<u.length;){let p=pq(d,u,c),h,m;if(p?(m=d,h=m.voice,d=m.next):(h=u[c++],m=h.state==="pending"?null:h.everyone),h===null||m===null||r&&h.laned&&!this.owedBy(s,h)||h.id===i||h.state==="done")continue;let g=m;p||this.share.open(h,g,n.slot);let b=this.read(h,e,a,o,g);s>=0&&h.laned&&this.lanes.paid(h.id,s,g.weight),p||(c=this.shared(h,n.slot,g,c));let x=h.spec.role;if(b===null){x===void 0&&!(g.weight>0)&&kt(g);continue}let w=-1;if(x!==void 0){w=l.names.indexOf(x);let P=l.m++;if(l.mVoices[P]=h,l.mDeltas[P]=b,l.mWeights[P]=this.w,w>=0){l.mGroups[P]=w;continue}w=l.names.length,l.names.push(x),l.mGroups[P]=w}let y=l.n++;l.voices[y]=h,l.helds[y]=g,l.deltas[y]=b,l.weights[y]=x===void 0?this.w:0,l.groups[y]=w}let f=n.roles;f===null&&(f=new Map,n.roles=f);for(let p=0;p<l.n;p++){let h=l.groups[p];if(h<0){let x=l.weights[p];x>0?this.apply(t,l.voices[p],l.helds[p],l.deltas[p],x):kt(l.helds[p]);continue}let m=this.foldRole(l,h),g=l.names[h];if(!(m>0)){f.get(g)?.fill(2);continue}let b=f.get(g);b===void 0&&(b=new Uint8Array(this.channels.length),f.set(g,b));for(let x=0;x<l.touched.length;x++){let w=l.touched[x],y=l.values[w];l.values[w]=void 0;let P=this.names[w],S=this.channels[w],v=l.taken[w],A=v>1?1:v;if(S.rest!==void 0&&S.scale){t[P]=S.fold?S.fold(t[P],y,A):pc(S,t[P],S.scale(y,A));continue}let N=b[w],M=this.passes(N===0?void 0:N===1,A);b[w]=M?1:2,M&&(t[P]=t[P]===void 0?Hi(y):pc(S,t[P],y))}}return t}finally{for(let u=0;u<l.n;u++)l.voices[u]=null,l.helds[u]=null,l.deltas[u]=null;for(let u=0;u<l.m;u++)l.mVoices[u]=null,l.mDeltas[u]=null;for(let u=0;u<l.touched.length;u++){let c=l.touched[u];l.met[c]=0,l.values[c]=void 0}l.touched.length=0,this.roleDepth--}}function $D(e,t){if(e.frame=st(),t===void 0)for(let n of e.cued)n.motion===void 0&&n.holding===null&&(n.seeks++,n.touches++);else{let n=ut(e,t)??null;for(;n!==null;n=n.next)n.seeks=-1;let r=ut(e,t)?.slot??-1;for(let o of e.sharers)e.share?.restamp(o,r)}e.lanes?.refill(),e.stir()}var hq=1e-6,mq=(e,t)=>Math.abs(e-t)<=1e-6*Math.max(1,Math.abs(e),Math.abs(t));function YD(e,t,n,r={}){if(!(t<=n)||!Number.isFinite(t)||!Number.isFinite(n))throw new RangeError(`blits: a trace runs from a time to one no earlier, not ${t} to ${n}`);let o=r.grid??5;if(!(o>0&&o<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a trace's grid is a finite number of ms above 0, not ${o}`);let i=yq(e,t),s=new Map,a=new Map,l=new Map,u=(c,d)=>{let f=a.get(c);f===void 0&&(f=new Map,a.set(c,f));let p=f.get(d);if(p===void 0){let h=s.get(d);h===void 0&&(h=e.project(d),s.set(d,h)),p=h.probe(c,e.pose()),f.set(d,p)}return p};return{from:t,to:n,of(c,d){let f=d,p=e.slotOf.get(f);if(p===void 0)throw new Error(`blits: the mix has no channel ${f}`);let h=N=>{let M=u(c,N)[f];return typeof M=="number"?M:Number.NaN},m=l.get(c);m===void 0&&(m=gq(e,c,t,n),l.set(c,m));let g=e.scalars[p],b=i&&!m.unknown.has(p)&&!e.bounded.includes(p)&&(g==="sum"||g==="mul"&&(m.writers.get(p)??0)<=1),x=m.bent.get(p),w=(N,M)=>b&&(x===void 0||x.every(([C,F])=>!(C<M&&F>N)));if(t===n)return{at:[t],value:[h(t)],exact:b};let y=[],P=[],S=!0,v=(N,M)=>{let C=y.length;C>0&&y[C-1]===N&&mq(P[C-1],M)?P[C-1]=M:(y.push(N),P.push(M))},A=[t,...m.knots.get(p)??[],n];for(let N=0;N+1<A.length;N++){let M=A[N],C=A[N+1];if(w(M,C)){let B=M+(C-M)/3,D=C-(C-M)/3,j=h(B),W=(h(D)-j)/(D-B);v(M,j-W*(B-M)),v(C,j+W*(C-B));continue}S=!1;let F=Math.min(hq,(C-M)/4);v(M,h(M===t?M:M+F));for(let B=Math.max(0,Math.ceil((M-t)/o));;B++){let D=t+B*o;if(D>=C-F)break;D>M+F&&v(D,h(D))}v(C,h(C===n?C:C-F))}return{at:y,value:P,exact:S}}}}function yq(e,t){let n=e.transport;if(!(t>=e.now))return!1;let r=n.tape;return r===void 0||r.timestampAt(r.undoDepth())===void 0}function gq(e,t,n,r){let o={knots:new Map,bent:new Map,unknown:new Set,writers:new Map};for(let i of e.cued)if(!(i.state==="done"||!e.aims(i,t))&&!xq(e,i,t,n,r,o))for(let s of i.slots)o.unknown.add(s);for(let[i,s]of o.knots)o.knots.set(i,s.sort((a,l)=>a-l).filter((a,l,u)=>l===0||a!==u[l-1]));return o}var bq=4096;function xq(e,t,n,r,o,i){let s=t.spec,a=t.built,l=t.patch;if(l.form!=="keys"||a===null||l.step!==void 0||typeof s.weight=="function"||t.owner!==null||t.holding!==null||t.fitting!==null||t.arc!==null||t.blend!==null||s.anchor!==void 0||s.role!==void 0||s.within!==void 0||s.stepMs!==void 0||s.from!==void 0||t.ramp!==null||!(t.rate>0)||t.out!==null||t.back!==null||t.stalls!==null||t.parts!==null||t.parted!==null||t.left!==null||Number.isFinite(t.outAt)||t.state==="fading"||t.state==="pending"&&e.transport.pace!==null)return!1;let u=[],c=[],d=new Map,f=P=>{P>r&&P<o&&u.push(P)},p=e.reduced,h=t.sharing?void 0:t.subjects.get(n),m=h?.delay??(s.stagger?s.stagger(n):0),g=P=>t.timeAt(P+m),b=p?0:t.fade.in??0;if(b>0){if(h===void 0)return!1;h.shown+b>r&&(c.push([h.shown,h.shown+b]),f(h.shown),f(h.shown+b))}let x=t.duration,w=t.span;f(t.start),f(g(0)),Number.isFinite(w)&&f(g(w));let y=t.endsAt();if(f(y),!t.freezesAfter&&Number.isFinite(y)){let P=p?0:Number.isNaN(t.outOver)?t.fade.out??0:t.outOver,S=Math.max(t.start,y);f(S),P>0&&(c.push([S,S+P]),f(S+P)),s.stagger!==void 0&&c.push([g(w),Number.POSITIVE_INFINITY])}if(x>0){let P=Math.max(0,Math.floor((t.elapsedAt(r)-m)/x)),S=Math.min(Math.ceil(t.passes)-1,Math.floor((t.elapsedAt(o)-m)/x)),v=0;for(let A of a.tracks)v+=A.all.length+1;if((S-P+1)*v>bq)return!1;for(let A=P;A<=S;A++){let N=A*x;f(g(N)),f(g(N+x));for(let M of a.tracks){let C=e.slotOf.get(M.channel);if(M.numbers===null)return!1;let F=M.delay;if(F>=x)continue;F>0&&f(g(N+F));let B=Number.NaN;for(let D of M.all){let j=g(N+F+Math.min(1,Math.max(0,D.at))*(x-F));if(f(j),!Number.isNaN(B)&&!nO(D.ease)){let W=d.get(C);W===void 0?d.set(C,[[B,j]]):W.push([B,j])}B=j}}}}for(let P of t.slots){let S=i.knots.get(P);S===void 0?i.knots.set(P,[...u]):S.push(...u),i.writers.set(P,(i.writers.get(P)??0)+1);let v=[...c,...d.get(P)??[]];if(v.length===0)continue;let A=i.bent.get(P);A===void 0?i.bent.set(P,v):A.push(...v)}return!0}function qD(e,t){let n=this.primed[0],r=this.primed[1],o=this.primed[2],i=e.setting;i.timestamp=n,e.patch.step===void 0&&t.probed<n&&(t.stepped=t.probed),i.dt=this.capped(n-t.stepped),i.elapsed=r,i.pass=o,i.weight=0,i.state=t.state,i.mark=0,e.keepOn=t}function XD(e,t,n){let r=this.now,o=e.setting;o.mark!==n[6]&&wq(o,r,n),e.patch.step===void 0&&t.probed<r&&(t.stepped=t.probed),o.dt=this.capped(r-t.stepped),o.weight=0,o.state=t.state,e.keepOn=t}function wq(e,t,n){e.timestamp=t,e.elapsed=n[1],e.pass=n[3],e.mark=n[6]}function JD(e){let t=this.opts.maxDt;return this.reducedNow?Number.POSITIVE_INFINITY:t!==void 0&&e>t?t:e}function QD(e,t,n){let r=this.opts.history;return r===void 0?Number.POSITIVE_INFINITY:dT(this,e,n-r.ms)-t}function ZD(e,t,n){return ma(e.fade.in??0,e.out,e.ease,this.reducedNow,t,n,e.back,e.stalls)}function eB(e,t){return zO(e,this.now,this.reducedNow,n=>this.ownerBase(n,t))}function tB(e,t){let n=this.now,r=this.held(e,t,-1);if(r.probed===this.frame)return r.phase;let o=pe.kept;r.probed=Number.NaN;let i=this.primed;i[0]=n,i[1]=e.elapsedAt(n),i[2]=0,this.prime(e,r);let s=this.base(e,t,n,r);return pe.kept=o,r.stepped=n,r.probed=this.frame,r.phase=s,s}function nB(e,t,n,r){if(e.owner!==null)return this.weighOwned(e,t,n,r);let o=this.base(e,t,n,r),i=this.envelope(e,n,r.shown);return jt(o,i,e.parts===null?1:this.parting(e,t,n))}function rB(e,t,n,r){let o=this.ownedBy(e,t),i=this.base(e,t,n,r),s=this.envelope(e,n,r.shown)*o;return jt(i,s,e.parts===null?1:this.parting(e,t,n))}function oB(e,t,n,r,o=-1){this.sending.voice=e,this.sending.subject=t;let i=typeof e.spec.weight=="function"?e.spec.weight:null;if(i===null)return e.weight;let s=r.replay&&_a(r.replay,n,!0),a=s?s.value:e.blend===null?i(t,e.setting):this.blended(e,t,r,o);return i.input&&!s&&pm(this,e,t,r,a),a}var Pq={lanes:!0},Ko=class{kit;opts;lanesOf;cued=[];gone=[];goneIx=new jh;scored=new Fh;projecting=!1;backward=!1;moving=!1;looked=!1;hostLog=[];hostThen;lastPoses=new me;transport;slot=-1;dropped=!1;name;frame=st();pins=null;wantsPose=!1;scratch;due=new Ih;retired=[];walkAll=!1;leapt=null;pulled=[];pulledHeads=[];pulledSlots=new Int32Array(0);pulledVersion=Number.NaN;pulledRelinks=-1;pullColumns=null;relinks=0;reducedNow=!1;stirred=!1;asleep=!1;waking=!1;stirs=0;syncing=!1;stirFns=null;stir(){if(this.stirs++,this.moving||this.transport.settle(),this.stirred||(this.stirred=!0,this.syncing))return;let t=this.stirFns;if(t!==null)for(let n of[...t])n();this.transport.woke()}onWake(t){this.stirFns===null&&(this.stirFns=[]);let n=this.stirFns;return n.push(t),()=>{let r=n.indexOf(t);r>=0&&n.splice(r,1)}}chains=new me;version=0;places=null;primed=new Float64Array(3);steps=new Bm;named=new me;parters=new Set;departed=new Xh;strays=new me;strayAll=new Set;playing=new Map;naming=0;general=[];sharers=[];unshared=!1;detours=0;roleVoices=0;roleTags;owner=null;anchored=0;sent=[];sending={voice:null,subject:void 0};send=t=>{let{voice:n,subject:r}=this.sending;n===null||this.projecting||n.setting.timestamp<=this.sentTo||this.sent.push({timestamp:n.setting.timestamp,subject:r,voice:n.id,tags:n.spec.tags??fn,event:t})};sentTo=Number.NEGATIVE_INFINITY;w=0;names;channels;bounded;lerpsInto;scalars;roleScratch=[];roleDepth=0;slotOf=new Map;lanes;share;handles=null;bookers=null;fitting=null;arcing=null;owners=null;keys=null;outs=null;pose;constructor(t,n,r){if(this.kit=t,this.opts=n,this.lanesOf=r,this.names=Object.keys(t),this.channels=this.names.map(i=>t[i]),this.bounded=this.channels.flatMap((i,s)=>i.bounds?[s]:[]),this.lerpsInto=this.channels.map(i=>Ph(i)),this.pose=qL(this.names,this.channels),this.scalars=this.channels.map(i=>B2(i)),this.names.forEach((i,s)=>{this.slotOf.set(i,s)}),r===null&&n.lanes===!0)throw new Error("blits: '@msb235/blits/lean' has no lanes; take mix from '@msb235/blits'");this.share=r?.share??null,this.lanes=r!==null&&(n.lanes??Pq.lanes)?new r(Zh(this)):null,this.name=n.name,this.roleTags=gL(n);let o=n.transport;if(o!==void 0){if(n.history!==void 0)throw new Error("blits: a mix on a transport keeps the history the transport keeps, not its own");this.opts={...n,history:o.history},this.transport=o}else this.transport=new zo(n.history,!1);this.transport.pager!==null&&(this.keys=new Oh(n.keyOf),this.outs=new dm,o!==void 0&&Sq(o,n.name)),this.transport.join(this)}own(t){if(this.transport.shared)throw new Error(`blits: ${this.name??"this mix"} plays on a transport, so ${t} goes to the transport`);return this.transport}get now(){return this.transport.now}set now(t){this.transport.now=t}get u(){return this.transport.u}set u(t){this.transport.u=t}get offset(){return this.transport.offset}set offset(t){this.transport.offset=t}get pace(){return this.transport.pace}set pace(t){this.transport.pace=t}get announced(){return this.transport.announced}set announced(t){this.transport.announced=t}get nextId(){return this.transport.nextId}set nextId(t){this.transport.nextId=t}get timestamp(){return this.transport.last}get seq(){return this.transport.seq}get last(){return this.transport.last}get tape(){return this.transport.tape}get replaying(){return this.transport.replaying}get reduced(){let t=this.opts.reduce;return typeof t=="function"?t():t===!0}get band(){return this.opts.band??O2}cue(t){this.attached();let n=this.opts.engine;if(n!==void 0&&!n.runs.has(t.patch.form))throw new Error(`blits: engine ${n.name} does not run ${t.patch.form} patches`);return yL(this,t)}blend(t,n,r={}){let o=`blend:${this.nextId}`,i=fc(n,t.length-1);return t.map((s,a)=>{let l={...r,patch:s,weight:n,role:o};"patch"in s&&(l.patch=s.patch,s.name!==void 0&&(l.name=s.name),s.tags!==void 0&&(l.tags=s.tags),s.hits!==void 0&&(l.hits=s.hits));let u=this.cue(l),c=this.cued[this.cued.length-1];return c.blend={of:i,i:a},i.members.push(c),u})}owns(t){if(t.loop!==void 0)throw new Error("blits: an owner does not loop: a pass would have to restart its children");return this.cue({...t,patch:Wi})}span(t){if((t.rate??1)<0)throw new Error("blits: a span lays out its children forward from its start, so it is not cued backward");this.fitting=new fm(t);try{let n=this.owns(t);return Dn(this,this.owners?.find(r=>r.handle===n)),n}finally{this.fitting=null}}arc(t){return YL(this,t)}sync(t){this.own("sync").sync(t)}book(t){return EF(this,t)}probe(t,n){this.looked=!0;let r=this.fold(t,n);return this.keep(t,r,n),this.restStamps!==null&&!(this.linkedLaned&&this.restsLaned())&&this.restStamps.set(t,2*this.restsKey()+(this.rests(r)?1:0)),r}pull(t,n){this.looked=!0,p_(this,t,n)}seek(t){if(this.projecting)throw new Error("blits: a projection does not seek");Va(this.own("seek"),t)}prepare(t){return this.own("prepare").prepare(t)}project(t){return _m(this.transport,t).of(this)}trace(t,n,r){return YD(this,t,n,r)}announce(t,n={}){this.attached(),VT(this.transport,t,n,this.slot,this.name)}attached(){if(this.dropped)throw new Error(`blits: ${this.name??"this mix"} was dropped from its transport`)}marks(t,n){return Yh(this,t,n).map(({order:r,...o})=>o)}rebase(){this.own("rebase").rebase()}voices(t){let n=[];for(let r of this.cued)r.state!=="done"&&(t===void 0||r.spec.tags?.includes(t))&&n.push(r.handle);return n}get live(){return this.cued.some(t=>t.state!=="done")}get inert(){if(this.stirred)return!1;let t=this.restful();return t&&!Number.isNaN(this.now)&&(this.asleep=!0),t}get rate(){return this.transport.rate}set rate(t){this.own("rate").ramp(t,0)}ramp(t,n){this.own("ramp").ramp(t,n)}close(){ND(this)}mute(t){for(let n of this.cued)n.written=!0,qr(this,n,{over:t?.over});Ot(this,"mute",n=>n.mix(this)?.mute(t))}touch(t){this.attached(),$D(this,t)}drain(t){let n=this.sent;if(n.length===0)return[];let r=n;if(t===void 0)this.sent=[];else{r=[];let o=[];for(let i of n)(i.tags.includes(t)?r:o).push(i);this.sent=o}return r.sort((o,i)=>o.timestamp-i.timestamp)}folding=new Set;linkedLaned=!1;restStamps=null;restsEpoch=0;restsFrame=Number.NaN;restsVersion=Number.NaN;restsRelinks=-1;restsStirs=-1;restScratch},Tq={fold:KF,folded:jF,linked:$F,foldWith:YF,owedBy:JF,foldRoles:jD,foldDetour:qF,foldSharers:XF,shared:zF,read:a_,contribution:e_,keyed:t_,tick:r_,apply:WF,clamp:VF,passes:UF,isRest:s_,baseFor:o_,slopeFor:i_,prime:qD,primeLaned:XD,capped:JD,horizonFor:QD,weigh:nB,weighOwned:rB,base:oB,envelope:ZD,ownedBy:eB,ownerBase:tB,blended:LF,laneRead:_F,shareKept:DF,parting:VL,chain:aO,relink:lO,linkable:uO,aims:cO,held:JO,unreachedOf:XO,sinceOf:QO,shownOf:ZO,keep:f_,foldRole:KD,atRest:BD,rests:HD,restful:GD,still:UD,restsLaned:WD,restsKey:VD,plot:hD,place:mD,moved:gD,put:bD,around:GF,drop:l_,forgetIn:u_,releaseIn:c_,recordDrop:d_};for(let[e,t]of Object.entries(Tq))Object.defineProperty(Ko.prototype,e,{value:t,writable:!0,configurable:!0});function Sq(e,t){if(t===void 0)throw new Error("blits: a mix on a transport whose history has a store needs a name, which its records are keyed by");if([...e.members,...e.dropped.map(r=>r.mix)].some(r=>r.name===t))throw new Error(`blits: a mix named ${t} is already on this transport, or a seek could bring it back`)}function kq(e,t,n){let{history:r,added:o}=vD(t),i=new Ko(e,o?{...t,history:r}:t,n);return o&&AD(i.transport),RD(i),i}var iB={name:"mixer",runs:new Set(["fn","keys","motion"]),create(e,t){return kq(e,t,Rc)}};function $T(e,t={}){return(t.engine??iB).create(e,t)}function Hm(e,t,n){for(let r=t;r!=null;r=n(r))if(e.has(r))return r;return null}function Cc(e,t){if(e.length<2)return e;let n=new Set(e),r=o=>{let i=t(o);return i!=null&&Hm(n,i,t)!==null};return e.some(r)?e.filter(o=>!r(o)):e}Z();var za={getBounds:e=>et(e),remapBounds:(e,t,n)=>Rt(e,hr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height)),fromBounds:e=>({kind:"rect",x:e.x,y:e.y,width:e.width,height:e.height}),translate:(e,t,n)=>Ag(e,t,n),lerp:(e,t,n)=>{if(e.kind==="rect"&&t.kind==="rect")return{kind:"rect",x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,width:e.width+(t.width-e.width)*n,height:e.height+(t.height-e.height)*n};if(e.kind==="polygon"&&t.kind==="polygon"&&e.coords.length===t.coords.length){let r=$e(e),o=$e(t),i=new Float64Array(r.length);for(let c=0;c<r.length;c++)i[c]=r[c]+(o[c]-r[c])*n;let s=At(e.origin,i),{corners:a,...l}=e,u=ig(e.corners,t.corners,n);return u?{...l,coords:s,corners:u}:{...l,coords:s}}throw new Error("pathPoseDescriptor.lerp: incompatible path shapes")},axes:e=>e.kind==="rect"?{count:4,names:["x","y","width","height"],to:t=>t.kind==="rect"?[t.x,t.y,t.width,t.height]:[],from:t=>({kind:"rect",x:t[0],y:t[1],width:t[2],height:t[3]}),add:(t,n)=>t.kind!=="rect"?t:{kind:"rect",x:t.x+n[0],y:t.y+n[1],width:t.width+n[2],height:t.height+n[3]},write:(t,n,r)=>{t.kind==="rect"&&(n[r]=t.x,n[r+1]=t.y,n[r+2]=t.width,n[r+3]=t.height)}}:{count:e.coords.length,to:t=>t.kind==="polygon"?Array.from($e(t)):[],from:t=>({...e,coords:At(e.origin,t)}),add:(t,n)=>{if(t.kind!=="polygon")return t;let r=Float64Array.from($e(t));for(let o=0;o<r.length;o++)r[o]+=n[o];return{...e,coords:At(e.origin,r)}},write:(t,n,r)=>{if(t.kind!=="polygon")return;let o=$e(t);for(let i=0;i<o.length;i++)n[r+i]=o[i]}},supportsRotation:()=>!1};function ir(e){return!!e&&typeof e=="object"&&"kind"in e&&(e.kind==="polygon"||e.kind==="rect")}function Ka(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"}var jo={getBounds:e=>ir(e)?za.getBounds(e):Mt.getBounds(e),remapBounds:(e,t,n)=>ir(e)?za.remapBounds(e,t,n):Mt.remapBounds(e,t,n),fromBounds:(e,t)=>ir(t)?za.fromBounds(e,t):Mt.fromBounds(e,t),translate:(e,t,n)=>ir(e)?za.translate(e,t,n):Mt.translate(e,t,n),axes:e=>Ka(e)?Mt.axes(e):ir(e)?za.axes(e):null,getRotation:e=>{if(ir(e))return 0;let t=e.rotation;return typeof t=="number"?t:0},supportsRotation:e=>!ir(e),withRotation:(e,t)=>ir(e)?e:{...e,rotation:t}};function sB(e){return t=>pa(e,t)}function aB(e,t){let n=sB(e);return(r,o,i,s)=>{let a=s?.inherited??n(r);return a===void 0?t(r,o,i,s):t(r,o,i,{...s,inherited:a})}}function lB(e,t){let n=sB(e);return(r,o,i,s)=>{let a=s?.inherited??n(r);return t(r,o,i,a===void 0?s:{...s,inherited:a})}}Z();function YT(e,t){switch(e){case"union":return Xf(...t);case"intersect":return bx(...t);case"exclude":return wx(...t);case"subtract":{let n=t.length===2?t[1]:Xf(...t.slice(1));return xx(t[0],n)}}}var qT="kit:booleanOfChildren",Aq=new Set(["union","intersect","subtract","exclude"]);function uB(e){let t=e?.boolean;return typeof t=="string"&&Aq.has(t)?t:"union"}var cB=e=>e.path;function dB(e){cB=e}function Rq(e){if(e.node.kind!=="group")return cB(e);let t=fB(e.children??[]);return t.length<=1?t[0]??null:YT("union",t)}function fB(e){let t=[];for(let n of e){if(n===void 0||n.node.hidden===!0)continue;let r=Rq(n);r!==null&&t.push(r)}return t}function XT(e,t){let n=fB(t);if(n.length===0)return null;let r=uB(e.data);return n.length===1&&r!=="subtract"?n[0]:YT(r,n)}Z();var ja="shape:paint";function Gm(e){return(e.dependsOn?.length??0)>0&&e.derivePath!==void 0}Z();Pe();Pe();Z();Bu.subscribe(Xu);function sr(e,t){if(e===null)return{outset:0,inset:0};let n=gu(e),r=(l,u)=>{switch(e.align??"center"){case"inner":return{outset:u,inset:l};case"outer":return{outset:l+u,inset:0};default:return{outset:l/2+u,inset:l/2}}},o=e.width??1,i=Pi(typeof o=="object"?0:at(o,t??1),e.vertexWidths),s=r(i,n.world);if(typeof o!="object"&&!(n.px>0))return s;let a=r(typeof o=="object"?o.px:0,n.px);return{outset:s.outset,inset:s.inset,outsetPx:a.outset,insetPx:a.inset}}function Nq(e,t){let n=sr(e,t);return n.outset+(n.outsetPx??0)/(t>0?t:1)}function Um(e,t){let n=t?.scale??1,r=t?.screen;if(!r){let d=Nq(e,n);return{x:d,y:d}}let o=sr(e,n),i=o.outsetPx??0;if(i===0)return{x:o.outset,y:o.outset};let[s,a,l,u]=r,c=Math.abs(s*u-a*l);return c>0?{x:o.outset+i*Math.hypot(l,u)/c,y:o.outset+i*Math.hypot(s,a)/c}:{x:o.outset,y:o.outset}}function $a(e,t){let n=t?.vertexColors,r=e[0];if(n===void 0||r?.kind!=="path")return e;let o=4*Rg(r.path),i=r.fill?n("fill",r.vertexColors):void 0,s=r.stroke?n("stroke",r.stroke.vertexColors):void 0,a=i?.length===o&&i!==r.vertexColors,l=s?.length===o&&s!==r.stroke?.vertexColors;return!a&&!l?e:[{...r,...a?{vertexColors:i}:{},...l?{stroke:{...r.stroke,vertexColors:s}}:{}},...e.slice(1)]}function JT(e,t){let n=Re(e.stroke,t?.stroke),r=Ne(e.fill,t?.fill);return n!==null?{fill:r,stroke:n}:{fill:r}}function ZT(e,t,n,r){let{sized:o,spaces:i}=r?Eq(e,t,r):Iq(t,n),s=at(o.width??1,1);if(!(s>0))return null;let a=new QT,l=t.align??"center";if(l!=="inner"){let u=l==="outer"?2:1,c=Vs(o,s),d=Ti(e,{...o,width:s*u,align:"center",vertexWidths:t.vertexWidths?.map(m=>Kl(m,u))},{startInset:pB(c.start,i.start,i.ribbon),endInset:pB(c.end,i.end,i.ribbon),...i.ribbon?{metric:i.ribbon.metric}:{}}),f=d.vertices,p=d.origin?.x??0,h=d.origin?.y??0;for(let m=0;m+1<f.length;m+=2)a.add(f[m]+p,f[m+1]+h,0)}for(let{entry:u,path:c,size:d}of yu(e,o,s,void 0,i)){let f=et(c),p=u.outline?u.outline.width*d/2:0;a.add(f.x,f.y,p),a.add(f.x+f.width,f.y+f.height,p)}return a.bounds()}function Iq(e,t){return{sized:{...e,width:at(e.width??1,t)},spaces:{}}}function Eq(e,t,[n,r,o,i]){let s=new Float32Array([n,r,0,o,i,0,0,0,1]),{cmd:a,spaces:l}=Hu(s,{kind:"path",path:e,stroke:t});return{sized:a.stroke,spaces:l}}function pB(e,t,n){return t?.metric===n?.metric?e:{length:e,metric:t?.metric??null}}var QT=class{x0=1/0;y0=1/0;x1=-1/0;y1=-1/0;add(t,n,r){this.x0=Math.min(this.x0,t-r),this.y0=Math.min(this.y0,n-r),this.x1=Math.max(this.x1,t+r),this.y1=Math.max(this.y1,n+r)}bounds(){return this.x0===1/0?null:{x:this.x0,y:this.y0,width:this.x1-this.x0,height:this.y1-this.y0}}},Mq="shape:drawn";function hB(e,t,n){let r=mB(e);if(!t)return r;let o=Um(t,n);return{x:r.x-o.x,y:r.y-o.y,width:r.width+2*o.x,height:r.height+2*o.y}}function Wm(e,t,n,r,o){let i=mB(t);if(n===null)return i;let s=r?.scale??1,a=r?.screen,l=rt(e,Mq,void 0,()=>({width:NaN,height:NaN,scale:NaN,screen:void 0,box:null}));if(l.width!==t.width||l.height!==t.height||l.scale!==s||!Cq(l.screen,a)){let p={x:0,y:0,width:t.width,height:t.height};l.width=t.width,l.height=t.height,l.scale=s,l.screen=a,l.box=ZT(o(p),n,s,a)}if(l.box===null)return i;let u=Math.min(i.x,t.x+l.box.x),c=Math.min(i.y,t.y+l.box.y),d=Math.max(i.x+i.width,t.x+l.box.x+l.box.width),f=Math.max(i.y+i.height,t.y+l.box.y+l.box.height);return{x:u,y:c,width:d-u,height:f-c}}function Cq(e,t){return e===t?!0:!!e&&!!t&&e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function mB(e){return{x:Math.min(e.x,e.x+e.width),y:Math.min(e.y,e.y+e.height),width:Math.abs(e.width),height:Math.abs(e.height)}}Pe();function yB(e,t,n,r){let o=et(e),i=t&&Vt(t,o),s=n&&Fi(n,o);return{kind:"path",path:e,...i?{fill:i}:{},...i&&r?{vertexColors:r}:{},...s?{stroke:s}:{}}}function e1(e,t){let n=t?.derivedPath,r=Re(e.data?.stroke,t?.inherited?.stroke);return n==null||r===null?null:ZT(n,r,t?.scale??1,t?.screen)}function Oq(e,t,n){let{fill:r,stroke:o}=i2(e,t,n);return yB(e.path,r,o,void 0)}var Vm={id:"kit:derived",matches:Gm,paint:(e,t,n)=>{let r=n?.derivedPath;if(r==null)return[];let o=e.data,i=ch(r);if(i!==void 0)return i.map(l=>Oq(l,o,n?.inherited));let s=Re(o?.stroke,n?.inherited?.stroke),a=Ne(o?.fill,n?.inherited?.fill);return $a([yB(r,a,s,o?.vertexColors)],n)},silhouette:(e,t,n)=>n?.derivedPath??null,drawnBounds:(e,t,n)=>e1(e,n),ink:(e,t,n)=>{let r=e.data,o=Re(r?.stroke,n?.inherited?.stroke);return{filled:Ne(r?.fill,n?.inherited?.fill)!==null,...sr(o,n?.scale)}}};Z();function Lt(e){return e===void 0||Ka(e)}function $o(e,t,n){if(!Ka(e))return null;let r=t?Qs(t,n?.scale??1,n?.leastScale):0,o=Math.min(e.x,e.x+e.width),i=Math.min(e.y,e.y+e.height);return{x:o-r,y:i-r,width:Math.abs(e.width)+2*r,height:Math.abs(e.height)+2*r}}function Fq(e,t){return{x:e.x*t.width,y:e.y*t.height,w:e.width*t.width,h:e.height*t.height}}function Lq(e,t,n){if(n&&n>0)return{width:Math.abs(e.width)*n/(t?.width||1),height:Math.abs(e.height)*n/(t?.height||1)}}var gB={id:"kit:image",snapsToBox:!0,matches:e=>{if(!Lt(e.pose))return!1;let t=e.data?.image?.src;return typeof t=="string"&&t.length>0},paint:(e,t,n)=>{let r=e.data,o=t,i=n?.resolveImage?n.resolveImage(e):ra(r.image.src,Lq(o,r.image.source,n?.pixelScale));if(i)return[{kind:"image",image:i,x:o.x,y:o.y,w:o.width,h:o.height,...r.image.opacity!==void 0?{opacity:r.image.opacity}:{},...r.image.source?{source:Fq(r.image.source,i)}:{},...r.image.flipX?{flipX:!0}:{},...r.image.flipY?{flipY:!0}:{}}];let s=n?.resolveImage?!1:W0(r.image.src)==="error",a=s?"#d08a8a":"#bbbbbb",l=[{kind:"path",path:{kind:"rect",x:o.x,y:o.y,width:o.width,height:o.height},stroke:{paint:{color:a},width:1}}];return s&&l.push({kind:"path",path:ng({x:o.x,y:o.y},{x:o.x+o.width,y:o.y+o.height}),stroke:{paint:{color:a},width:1}}),l},silhouette:(e,t)=>{let n=t;return{kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height}},bounds:(e,t,n)=>$o(t,_q,n)},_q={paint:{color:"#000"},width:1};Z();var bB={cut:{paint:{color:"#e23b3b"},width:1,dash:[6,4]},connector:{paint:{color:"#7ba7c7"},width:2,dash:[4,4]},falloff:{paint:{color:"rgba(52, 120, 246, 0.28)"},width:10,cap:"round",join:"round"},measure:{paint:{color:"#1f8fff"},width:1},lock:{paint:{color:"#d9480f"},width:1.5},target:{paint:{color:"#1f8fff"},width:1.5,dash:[5,3]},insert:{paint:{color:"#1f8fff"},width:3,cap:"round"},refused:{paint:{color:"#ff5d5d"},width:3,cap:"round"}};function t1(e){let t=e?.data?.measure;return!t||typeof t!="object"||!t.start||!t.end?null:t}var Dq=5;function Bq(e,t,n){let r={...bB.measure,width:{px:1}},o=Math.hypot(t.x-e.x,t.y-e.y),i=o>0?-(t.y-e.y)/o:0,s=o>0?(t.x-e.x)/o:1,a=Dq*n,l=c=>({kind:"path",path:Td([{x:c.x-i*a,y:c.y-s*a},{x:c.x+i*a,y:c.y+s*a}]),stroke:r}),u=[l(e),l(t)];return o>0&&u.unshift({kind:"path",path:Td([e,t]),stroke:r}),u}var xB={id:"kit:measure",matches:e=>Lt(e.pose)&&t1(e)!==null,paint:(e,t,n)=>{let r=t1(e);if(!r)return[];let o=globalThis.devicePixelRatio||1;return Bq(r.start,r.end,o/(n?.pixelScale??o))}};Z();Pe();var wB={id:"kit:path",matches:e=>Lt(e.pose)?e.data?.path!=null:!1,paint:(e,t,n)=>n?.derivedPath!=null?Vm.paint(e,t,n):$a(rt(e,ja,t,()=>{let r=e.data,o=Ol(r.path,t),{fill:i,stroke:s}=JT(r,n?.inherited),a=i&&Vt(i,t),l=s&&Fi(s,t);return[{kind:"path",path:o,...a?{fill:a}:{},...a&&r.vertexColors?{vertexColors:r.vertexColors}:{},...l?{stroke:l}:{}}]},n?.inherited),n),silhouette:(e,t,n)=>{if(n?.derivedPath!=null)return n.derivedPath;let r=e.data;return Ol(r.path,t)},ink:(e,t,n)=>{let{fill:r,stroke:o}=JT(e.data,n?.inherited);return{filled:r!==null,...sr(o??null,n?.scale)}},bounds:(e,t,n)=>$o(t,Re(e.data.stroke,n?.inherited?.stroke),n),drawnBounds:(e,t,n)=>{if(n?.derivedPath!=null)return e1(e,n);let r=e.data;return Wm(e,t,Re(r.stroke,n?.inherited?.stroke),n,o=>Ol(r.path,o))}};Pe();var PB={id:"kit:rect-fallback",matches:e=>e.kind!=="group"&&Lt(e.pose),paint:(e,t,n)=>{let r=e.data,o=t,i=Ne(r?.fill,n?.inherited?.fill),s=i&&Vt(i,o);return[{kind:"path",path:{kind:"rect",x:o.x,y:o.y,width:o.width,height:o.height},...s?{fill:s}:{}}]},silhouette:(e,t)=>{let n=t;return{kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height}},bounds:(e,t)=>$o(t,null,void 0)};Z();Pe();var TB={id:"kit:shape",matches:e=>{if(!Lt(e.pose))return!1;let t=e.data?.shape;return t!=null&&Hq.has(t)},paint:(e,t,n)=>$a(rt(e,ja,t,()=>{let r=e.data,o=n1(r,t),i=Ne(r.fill,n?.inherited?.fill),s=i&&Vt(i,t),a=Re(r.stroke,n?.inherited?.stroke),l=a&&Fi(a,t);return[{kind:"path",path:o,...s?{fill:s}:{},...l?{stroke:l}:{}}]},n?.inherited),n),silhouette:(e,t)=>{let n=e.data;return n1(n,t)},ink:(e,t,n)=>{let r=e.data;return{filled:Ne(r.fill,n?.inherited?.fill)!==null,...sr(Re(r.stroke,n?.inherited?.stroke),n?.scale)}},bounds:(e,t,n)=>$o(t,Re(e.data.stroke,n?.inherited?.stroke),n),drawnBounds:(e,t,n)=>{let r=e.data,o=Re(r.stroke,n?.inherited?.stroke);return r.shape==="polygon"||r.shape==="star"?Wm(e,t,o,n,i=>n1(r,i)):hB(t,o,n)}},Hq=new Set(["rect","ellipse","polygon","star"]);function n1(e,t){switch(e.shape){case"ellipse":return Zy(t);case"polygon":{let n=t.x+t.width/2,r=t.y+t.height/2,o=Math.min(t.width,t.height)/2;return eg({x:n,y:r},o,e.sides??6)}case"star":{let n=t.x+t.width/2,r=t.y+t.height/2,o=Math.min(t.width,t.height)/2;return tg({x:n,y:r},o,e.points??5)}default:return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height}}}Z();Pe();function Gq(e,t){return{kind:"group",clip:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height},children:[e]}}function Uq(e,t){let n=Math.max(0,e.padding??0),r=Math.min(n,t.width/2),o=Math.min(n,t.height/2);return{x:t.x+r,y:t.y+o,width:t.width-2*r,height:t.height-2*o}}function r1(e,t,n){return{...Uq(e,t),text:e.text,runs:e.runs,style:e.style,fill:e.fill===rn?Ne(e.fill,n?.fill):e.fill,stroke:Re(e.stroke,n?.stroke)??void 0,verticalAlign:e.verticalAlign}}var o1={id:"kit:text",snapsToBox:!0,matches:e=>Lt(e.pose)?e.data?.text!=null:!1,paint:(e,t,n)=>rt(e,ja,t,()=>{let r=e.data,o=Lw(r1(r,t,n?.inherited)),i=r.overflow==="clip"?Gq(o,t):o,s=Ne(r.background);if(!s)return[i];let a=Vt(s,t);return[{kind:"path",path:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height},...a?{fill:a}:{}},i]},n?.inherited),silhouette:(e,t)=>{let n=e.data;if(Ne(n.background))return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height};let r=kp(r1(n,t)),o=n.overflow==="clip"?Wq(r,t):r;return o.length===0?null:zq(o)},ink:(e,t,n)=>{let r=e.data;return{filled:!0,...sr(Re(r.stroke,n?.inherited?.stroke),n?.scale)}},drawnBounds:(e,t,n)=>{let r=e.data,o=Re(r.stroke,n?.inherited?.stroke);return o?Vq(t,kp(r1(r,t,n?.inherited)),Um(o,n)):null}};function Wq(e,t){let n=[];for(let r of e){let o=Math.max(r.x,t.x),i=Math.max(r.y,t.y),s=Math.min(r.x+r.width,t.x+t.width),a=Math.min(r.y+r.height,t.y+t.height);s>o&&a>i&&n.push({x:o,y:i,width:s-o,height:a-i})}return n}function Vq(e,t,n){if(!(n.x>0||n.y>0))return null;let r=e.x,o=e.y,i=e.x+e.width,s=e.y+e.height;for(let a of t){let l=Math.max(a.x,e.x),u=Math.max(a.y,e.y),c=Math.min(a.x+a.width,e.x+e.width),d=Math.min(a.y+a.height,e.y+e.height);c<=l||d<=u||(r=Math.min(r,l-n.x),o=Math.min(o,u-n.y),i=Math.max(i,c+n.x),s=Math.max(s,d+n.y))}return{x:r,y:o,width:i-r,height:s-o}}function zq(e){let t=new Uint8Array(e.length*6),n=new Float32Array(e.length*10),r=0,o=0;for(let i of e){let{x:s,y:a,width:l,height:u}=i;t[o++]=le,n[r++]=s,n[r++]=a,t[o++]=ce,n[r++]=s+l,n[r++]=a,t[o++]=ce,n[r++]=s+l,n[r++]=a+u,t[o++]=ce,n[r++]=s,n[r++]=a+u,t[o++]=ce,n[r++]=s,n[r++]=a,t[o++]=fe}return{kind:"polygon",commands:t,coords:n,fillRule:"nonzero"}}var Vve=Object.freeze({filled:!0,outset:0,inset:0}),Ya={high:[],normal:[]},SB=!1;function i1(){SB||(SB=!0,Qq())}function Xi(e,t={}){i1();let n=t.priority==="high"?Ya.high:Ya.normal;return n.push(e),Xu(),()=>{let r=n.indexOf(e);r>=0&&n.splice(r,1),Xu()}}var Kq="shape:painter",jq="shape:painter:nonrect",$q="shape:painter:derived",Yq="shape:painter:derived:nonrect",qq="shape:silhouette",Xq="shape:silhouette:text";function Oc(e){let t=Lt(e.pose),n=Gm(e)?t?$q:Yq:t?Kq:jq;return rt(e,n,void 0,()=>Jq(e))}function Jq(e){i1();for(let t of Ya.high)if(t.matches(e))return t;for(let t of Ya.normal)if(t.matches(e))return t}function Fc(e,t,n){let r=()=>{let o=Oc(e)?.silhouette?.(e,t,n)??null;return o&&Cl(o,t)};if(n?.derivedPath!=null)return r();if(Oc(e)===o1){let o=qo(),i=rt(e,Xq,t,()=>({epoch:o,path:r()}));return i.epoch!==o&&(i.epoch=o,i.path=r()),i.path}return rt(e,qq,t,r)}dB(e=>Fc(e.node,e.pose,{derivedPath:e.path}));function zm(e,t,n){return Oc(e)?.ink?.(e,t,n)??null}function kB(){return i1(),[...Ya.high,...Ya.normal]}function Qq(){Xi(o1),Xi(xB),Xi(Vm),Xi(wB),Xi(TB),Xi(gB),Xi(PB)}function Km(e){return`scene:${e}`}function vB(e,t){let{layerVisibility:n,layerOrder:r}=t;return n===void 0&&r===void 0?e:(r?r.map(i=>e.find(s=>Km(s.id)===i)).filter(i=>i!==void 0):e).filter(i=>n?.[Km(i.id)]!==!1)}Z();function jm(e){if(e===null)return r=>r;let t=r=>r===void 0?null:e(r),n=new WeakMap;return(r,o,i)=>{let s=t(i),a=Bw(t(o),s);if(a===null)return r;let l=n.get(r);l===void 0&&n.set(r,l=new Map);let u=l.get(s);return u===void 0&&l.set(s,u=Rt(r,Hw(a))),u}}function AB(e,t){let n=Bw(e,t);return n===null?void 0:q.fromAffine(Hw(n))}var RB=Object.freeze({preserveDrawingBuffer:!0,stencil:!0});Z();Z();Z();function NB(e,t){if(e.length===0)return e;let n=Ce(t);return n?[{kind:"group",transform:q.fromAffine(n),children:e}]:e}var EB=new WeakSet;function $m(e){let t={kind:"group",children:e};return EB.add(t),t}function IB(e){return EB.has(e)}var Zq=[];function Ym(e){if(!e.some(IB))return{under:e,over:Zq};let t=[],n=[];for(let r of e)IB(r)?n.push(...r.children):t.push(r);return{under:t,over:n}}function CB(e,t,n){let{under:r,over:o}=Ym(e),i=MB(r,t,n);return o.length>0?[...i,$m(MB(o,t,n))]:i}function MB(e,t,n){let r=NB(e,t);return n!==1&&r.length>0?[{kind:"group",alpha:n,children:r}]:r}function eX(e,t,n){return Fc(e,t,{derivedPath:n?.()??null})}function qm(e,t,n){return typeof e.clipFromPose=="function"?e.clipFromPose(t):e.clip!=="outline"?null:eX(e,t,n)}Z();Z();function FB(e,t,n,r,o,i,s,a){let l=s&&o.inCopy!==void 0?i(e):null;if(l===null||!l.some(f=>a.copiesOf(f).length>0)){if(!o.hits(e,t,n,r))return!1;let f=l??i(e);for(let p=0;p<f.length;p++)if(!OB(a,o,f[p],e,t,n))return!1;return!0}let u=(f,p)=>OB(a,f,p,e,t,n),c=[...l].reverse(),d=(f,p)=>{if(f===c.length)return p.hits(e,t,n,r);let h=c[f];if(u(p,h)&&d(f+1,p))return!0;for(let m of a.copiesOf(h)){let g=p.inCopy?.(m);if(g!==void 0&&u(g,h)&&d(f+1,g))return!0}return!1};return d(0,o)}function OB(e,t,n,r,o,i){let s=e.clipOf(n);return s===null||t.clipAdmits(e.carry(s,n.layer,r.layer),r,o,i)}var ue=e=>e;function tX(e){return e?.annotation===!0}function Xm(e){let t=new Set;for(let n of e??[])tX(n)&&t.add(n.id);return t}function Lc(e){return e.hidden===!0}function qa(e){let t=Jm(e,"hidden"),n=Jm(e,"locked"),r=n===null?a=>a.locked===!0:a=>a.locked===!0||n.has(a.layer),o=a=>{let l=new Map,u=[];return c=>{if(c===null)return!1;let d=!1,f=null;u.length=0;for(let p=c;p!==null;){let h=l.get(p);if(h!==void 0){d=h;break}let m=e.get(p);if(m===void 0)break;if(u.length>64){if(f??=new Set(u),f.has(p))break;f.add(p)}if(u.push(p),a(m)){d=!0;break}p=m.parent??null}for(let p of u)l.set(p,d);return d}},i=o(Lc),s=o(r);return{hidden(a){let l=typeof a=="string"?e.get(a):a;return l===void 0?!1:t?.has(l.layer)===!0||Lc(l)||i(l.parent??null)},locked(a){let l=typeof a=="string"?e.get(a):a;return l===void 0?!1:r(l)||s(l.parent??null)}}}function LB(e,t,n){let r=null,o=0;for(let i=t;i!==null;){let s=e.get(i);if(s===void 0)return!1;if(++o>64){if(r??=new Set,r.has(i))return!1;r.add(i)}if(n(s))return!0;i=s.parent??null}return!1}function Jm(e,t){let n=null;for(let r of e.layers??[])(t==="locked"?r.locked===!0:r.visible===!1)&&(n??=new Set).add(r.id);return n}function _B(e,t){let n=e.get(t);return n===void 0?!1:Jm(e,"hidden")?.has(n.layer)===!0||LB(e,t,Lc)}function DB(e,t){let n=Jm(e,"locked");return LB(e,t,n===null?r=>r.locked===!0:r=>r.locked===!0||n.has(r.layer))}Z();function HB(e,t){let n=Tt(e.overrides,t),r=Xn(e,t);return r===n.pose?n:{...n,pose:r}}function a1(e,t){return n=>t(HB(e,n))}function GB(e,t){return t===void 0?n=>e.overrides.read(n.id)?.path:n=>{let r=e.overrides.read(n.id)?.path;if(r===void 0)return;let o=HB(e,n);return dh(r,o.pose,t(o))}}function _c(e,t){let n=t?a1(e,t):o=>Xn(e,o);if(!Et(e.composition))return n;let r=bh(e,{getPose:o=>{let i=e.get(ue(o));return i?n(i):void 0},getParent:o=>e.get(ue(o))?.parent??null,definesFrame:o=>{let i=e.get(ue(o));return i===void 0||lt(i)}});return o=>zt(r,o.id,e.composition.compose)}function nX(e,t){let n=UB(t,Et(e.composition));if(n===void 0)return o=>Jw(e,o);let r={at:_c(e,t),local:t?a1(e,t):o=>Xn(e,o),slot:n,shown:GB(e,t),childrenOf:o=>e.childrenOf(o),scene:ha(e),lookup:o=>{let i=e.get(o);return i===void 0?void 0:new s1(Tt(e.overrides,i),r)}};return r.lookup}var s1=class{constructor(t,n){this.ctx=n;this.node=t,this.pose=n.at(t)}ctx;node;pose;get path(){let t=this.ctx.shown(this.node);return t!==void 0?fh(t,this.ctx.local(this.node),this.pose):Fr(this.node,this.ctx.lookup,this.ctx.childrenOf,this.ctx.slot)}get inherited(){return pa(this.ctx.scene,this.node)}get children(){return this.ctx.childrenOf(this.node.id).map(this.ctx.lookup)}};function l1(e,t){return t.dependsOn!==void 0||e.overrides.read(t.id)?.path!==void 0}function Dc(e,t){let n=nX(e,t),r=UB(t,Et(e.composition)),o=a=>e.childrenOf(a),i=a=>Fr(a,n,o,r),s=GB(e,t);return a=>s(a)??i(a)}var BB=new WeakMap;function UB(e,t){let n=t?"world":"local";if(e===void 0)return n==="world"?"kit:derivedPath:world":void 0;let r=BB.get(e);return r===void 0&&(r={},BB.set(e,r)),r[n]??=p2()}function WB(e,t,n){let r=Dc(e,n),o=Et(e.composition)?n?a1(e,n):i=>Xn(e,i):null;return(i,s,a,l)=>{if(!l1(e,i))return t(i,s,a,l);let u=r(i);return u!==null&&o!==null&&e.overrides.read(i.id)?.path===void 0&&(u=rX(u,s,o(i))),t(i,s,a,{...l,derivedPath:u})}}function rX(e,t,n){let r=ui(t);if(r===null)return e;let o=t,i=n,s=Ce({x:o.x,y:o.y,width:o.width,height:o.height,rotation:i?.rotation,transform:i?.transform});return Yu(e,s===null?r:ht(r,s))}mv();function oX(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function u1({reads:e=2}={}){if(!(e>=1)||!Number.isInteger(e))throw new RangeError(`createSettledCache: reads must be a positive integer, got ${e}`);let t,n=0,r=null;return{read(o,i){return(t===void 0||!oX(t,o))&&(t=o.slice(),n=0,r=null),r!==null?r.value:++n<e?null:(r={value:i()},r.value)},clear(){t=void 0,n=0,r=null}}}var iX=[];function Qm(e){return t=>{let n=t.parent??null;if(n===null)return iX;let r=[],o=new Set;for(;n!==null&&!o.has(n);){o.add(n);let i=e.get(ue(n));if(!i)break;r.push(i),n=i.parent??null}return r}}function Zm(e){let t=Dc(e);return n=>{let r=n;return l1(e,r)?t(r):null}}Z();Z();Z();function VB(e){let{x:t,y:n,width:r,height:o}=e;return Bc([t,n,t+r,n,t+r,n+o,t,n+o],{x:t,y:n,width:r,height:o},!0)}function Bc(e,t,n=!1){let r=[],o=[],i=1/0,s=1/0,a=-1/0,l=-1/0;for(let u=0;u+1<e.length;u+=2){let c=e[u],d=e[u+1];r.push({x:c,y:d}),o.push(c,d),c<i&&(i=c),d<s&&(s=d),c>a&&(a=c),d>l&&(l=d)}return r.length===0?null:{verts:r,coords:o,bounds:t??{x:i,y:s,width:a-i,height:l-s},isRect:n}}function zB(e){if(e.length<3)return null;let t=[];for(let n of e)t.push(n.x,n.y);return Bc(t)}function KB(e){return e!==null&&typeof e=="object"&&e.kind==="polygon"}function ey(e,t,n){return KB(t)?rt(e,"aabb",t,()=>n.getBounds(t)):Di(t,n)}function jB(e,t){if(Ce(e)){let n=e;return Cl({kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height},e)}return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height}}function c1(e,t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y)||!Number.isFinite(n.width)||!Number.isFinite(n.height))return!1;let r=e.bounds;if(n.x>=r.x+r.width||n.x+n.width<=r.x||n.y>=r.y+r.height||n.y+n.height<=r.y)return!1;if(t==="centers")return Un(e.coords,n.x+n.width/2,n.y+n.height/2);if(t==="intersect"&&e.isRect&&wd([r.x,r.y,r.x+r.width,r.y+r.height],[n.x,n.y,n.x+n.width,n.y+n.height]))return!0}function $B(e,t,n,r,o,i=()=>!0){let s=c1(e,t,r);if(s!==void 0)return s;let a=e.bounds,l=KB(n);if(t==="enclosed")return l&&!wd([a.x,a.y,a.x+a.width,a.y+a.height],[r.x,r.y,r.x+r.width,r.y+r.height])?!1:vg(e.verts,l?n:o());let u=l?n:o();return i()?u.kind==="rect"&&e.isRect?u.x<a.x+a.width&&u.x+u.width>a.x&&u.y<a.y+a.height&&u.y+u.height>a.y:Fd(e.verts,u):Fd(e.verts,u,{filled:!1})}function Hc(e,t,n){let r=t.x+t.width,o=t.y+t.height;e[0]=Math.min(e[0],Math.min(t.x,r)-n),e[1]=Math.min(e[1],Math.min(t.y,o)-n),e[2]=Math.max(e[2],Math.max(t.x,r)+n),e[3]=Math.max(e[3],Math.max(t.y,o)+n)}function sX(e,t,n,r){let o=ir(t)?et(t):n.getBounds(t),i=n===jo?t:nP(t,n),s=Ce(i);if(!s){Hc(e,o,r);return}let a=o.x-r,l=o.y-r,u=o.x+o.width+r,c=o.y+o.height+r;for(let[d,f]of[[a,l],[u,l],[u,c],[a,c]]){let[p,h]=wn(s,d,f);Hc(e,{x:p,y:h,width:0,height:0},0)}}function aX(e){let t=1e-9*(1+Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])));e[0]-=t,e[1]-=t,e[2]+=t,e[3]+=t}var lX=Object.freeze({scale:1});function YB(e,t,n,r,o,i){let s=zm(e,t,r===void 0?lX:{scale:1,inherited:r}),a=Math.max(0,s?.outset??0);if(i[0]=i[1]=1/0,i[2]=i[3]=-1/0,n)Hc(i,et(n),a);else{let l=_r(o,e);o===jo&&l===o&&Ka(t)&&Ce(t)===null?Hc(i,t,a):(Hc(i,ey(e,t,l),a),sX(i,t,o,a))}return aX(i),Math.max(0,s?.outsetPx??0)}var uX=0;var qB=new WeakMap,cX=.5,d1=class{constructor(t,n,r,o){this.built=t;this.trees=n;this.always=r;this.maxOutsetPx=o;this.layers=[...n.keys()],this.order=t,this.marks=new Uint8Array(t.length),this.found=new Int32Array(Math.max(16,r.length))}built;trees;always;maxOutsetPx;layers;order;remap=null;marks;found;rankBy(t){if(t===this.order)return;if(this.order=t,t===this.built){this.remap=null;return}let n=new Map;for(let o=0;o<t.length;o++)n.set(t[o].id,o);let r=new Int32Array(this.built.length);for(let o=0;o<r.length;o++)r[o]=n.get(this.built[o].id)??-1;this.remap=r}candidates(t){let n=Math.floor(this.order.length*cX),r=0,o=i=>{let s=this.remap===null?i:this.remap[i];if(s<0)return!0;if(r===this.found.length){let a=new Int32Array(r*2);a.set(this.found),this.found=a}return this.found[r++]=s,r<=n};for(let i of this.always)if(!o(i))return null;for(let i=0;i<this.layers.length;i++){let s=t[i],a=this.trees.get(this.layers[i]);if(s===null||a===void 0)continue;let{x:l,y:u,width:c,height:d}=s.box,f=s.pxPerWorld,p=this.maxOutsetPx>0&&f!==void 0?f>0?this.maxOutsetPx/f:1/0:0,h=!1;if(a.queryBox([l-p,u-p,l+c+p,u+d+p],m=>o(m)?!0:(h=!0,!1)),h)return null}return this.readOut(r)}readOut(t){let{order:n,found:r}=this,o=new Array(t);if(t*32<n.length){let a=r.subarray(0,t).sort();for(let l=0;l<t;l++)o[l]=n[a[l]];return o}let i=this.marks.length>=n.length?this.marks:new Uint8Array(n.length);for(let a=0;a<t;a++)i[r[a]]=1;let s=0;for(let a=0;s<t&&a<n.length;a++)i[a]!==0&&(i[a]=0,o[s++]=n[a]);return o}};function dX(e){return e.some(t=>typeof t.copiesFromPose=="function")}function fX(e,t,n){uX++;let r=_c(e),o=Zm(e),i=Qm(e),s=new Map,a=[],l=0;for(let c=0;c<n.length;c++){let d=n[c],f=i(d);if(dX(f)){a.push(c);continue}let p=[0,0,0,0],h;try{let g=Ju(d)?fa(d,f):void 0;h=YB(d,r(d),o(d),g,t,p)}catch{a.push(c);continue}if(!Number.isFinite(h)||!p.every(Number.isFinite)){a.push(c);continue}h>l&&(l=h);let m=s.get(d.layer);m===void 0&&s.set(d.layer,m=[]),m.push([c,p])}let u=new Map;for(let[c,d]of s){let f=_g(2,d);if(f.size!==d.length)for(let[p,h]of d)h[0]<=h[2]&&h[1]<=h[3]||a.push(p);u.set(c,f)}return new d1(n,u,Int32Array.from(a),l)}function pX(e,t){kB();let n=e.getVersion(),r=e.overrides.getGeneration(),o=e.scroll?.getGeneration()??0,i=h2(),s=mu(),a=qB.get(e);a===void 0&&qB.set(e,a=new WeakMap);let l=a.get(t);l===void 0&&a.set(t,l=u1());let u=yh(e.overrides,e.renderOrderNodes()),c=l.read([n,r,o,i,s],()=>fX(e,t,u));return c?.rankBy(u),c}function XB(e,t,n){let r=pX(e,t);if(r===null)return null;let o=[];for(let i of r.layers){let s=n(i);if(s===void 0||s!==null&&Number.isNaN(s.box.x+s.box.y+s.box.width+s.box.height))return null;o.push(s)}return r.candidates(o)}function f1(e,t={}){let n=qa(e),r=typeof e.overrides?.ids=="function",o=w=>e.overrides?Tt(e.overrides,w):w,i=w=>r?yh(e.overrides,w):w.map(o),s=Xm(e.layers),{getPose:a,alphaOf:l,layerIsPainted:u}=t,c=null;if(!l&&r)for(let w of e.overrides.ids()){let y=e.overrides.read(w)?.alpha;y!==void 0&&y<=0&&(c??=new Set).add(w)}let d=l??(r?c?w=>c.has(w)?0:1:void 0:w=>e.overrides.read(ue(w))?.alpha??1),f=_c(e),p=a?w=>a(w.id):w=>f(w),h=w=>e.childrenOf(w),m=w=>{let y=e.get(w);if(y===void 0)return;let P=o(y);return{node:P,pose:p(P),get path(){return Fr(P,m,h)}}},g=a?w=>{let y=w;return y.dependsOn===void 0?null:Fr(y,m,h)}:Zm(e),b=t.camera?ty(e.layers,t.camera):null,x=a||typeof e.getVersion!="function"?void 0:t.index;return{...b?{planeOf:b}:{},...x?{candidates:w=>{let y=XB(e,x.descriptor,w);return y===null?null:i(y)}}:{},order:()=>i(e.renderOrderNodes()),derivedPathOf:g,poseOf:p,parentsOf:Qm(e),...d?{alphaOf:d}:{},isLocked:w=>n.locked(w),isHidden:w=>n.hidden(w),...s.size>0||u?{layerIsPainted:w=>!s.has(w)&&(u===void 0||u(w))}:{}}}function ty(e,t){let n=null;for(let o of e??[])o.parallax&&(n??=new Map).set(o.id,rh(t,o.parallax));if(n===null)return null;let r=n;return o=>r.get(o)??null}function JB(e,t){let n=t.includeGroups??!0,r=t.includeLocked===!0?void 0:e.isLocked,o=[],i=new Map,s=jm(e.planeOf??null),a=b=>{let x=i.get(b.id);if(x!==void 0)return x;let w=qm(b,e.poseOf(b),()=>e.derivedPathOf?.(b));return i.set(b.id,w),w},l=new Map,u=b=>{let x=l.get(b.id);if(x===void 0){let w=b.copiesFromPose;x=(w?w(e.poseOf(b),b)??[]:[]).map(pr).filter(P=>P!==null),l.set(b.id,x)}return x},c=new Map,d=b=>{if(b===void 0||e.planeOf===void 0)return t;let x=c.get(b);if(x===void 0){let w=e.planeOf(b);x=w===null?t:t.inPlane?.(w)??null,c.set(b,x)}return x},f={clipOf:a,copiesOf:u,carry:s},p=b=>e.parentsOf(b),h=e.order(),m=h.some(b=>typeof b.copiesFromPose=="function"),g=(t.broad!==void 0?e.candidates?.(b=>{let x=d(b);return x===null?null:x.broad}):null)??h;for(let b of g){if(!n&&b.kind==="group"||b.pickable===!1||e.isHidden?.(b)===!0||b.layer!==void 0&&e.layerIsPainted?.(b.layer)===!1||e.alphaOf!==void 0&&e.alphaOf(b.id)<=0||r!==void 0&&r(b))continue;let x=d(b.layer);if(x===null)continue;let w=e.poseOf(b),y=e.derivedPathOf?.(b),P=Ju(b)?fa(b,e.parentsOf(b)):void 0;FB(b,w,y,P,x,p,m,f)&&o.push(b.id)}return o}function hX(e,t,n,r){let o={kind:"group",children:e};for(let i=t.length-1;i>=0;i--){let s=t[i];o="copy"in s?{kind:"group",children:[o],transform:q.fromAffine(s.copy)}:{kind:"group",children:[o],clip:r(s.path,s.layer,n)}}return o}function QB(e,t,n,r,o,i){let s=e.getLayers(),a=new Map;for(let h of s)h.visible&&a.set(h.id,[]);let l=null;for(let h of s)h.parallax&&(l??=new Map).set(h.id,_w(n,h.parallax));let u=e.composePose?.bind(e),c=u?e.childFrame?.bind(e):void 0,d=jm(l?ty(s,n):null);function f(h,m,g,b){let x=e.getNode(h);if(!x||Lc(x))return;let w=e.getPose(h),y=u&&g!==null?u(g,w):w,P=r===void 0||x.layer===r?a.get(x.layer):void 0,S=l?.get(x.layer)??n,{under:v,over:A}=Ym(P&&(b||!i?.(x,y,S))?t(x,y,S):[]),N=m,M=null,C=x,F=qm(C,y,()=>o?.(x,y));F&&(M={path:F,layer:x.layer},N=[...m,M]);let B=J=>m.length>0?hX(J,m,x.layer,d):{kind:"group",children:J};P&&P.push(B(v));let D=lt(x)?c?c(h,y):y:g,j=x.consumesChildren===!0?[]:e.getChildren(h);for(let J of j)f(J,N,D,b);let W=typeof C.copiesFromPose=="function"?C.copiesFromPose(y,x):null;for(let J of W??[]){let se=[...m,{copy:J},...M?[M]:[]];for(let ke of j)f(ke,se,D,!0)}P&&A.length>0&&P.push(B(A))}for(let h of e.getChildren(null))f(h,[],null,!1);let p=[];for(let h of s){if(!h.visible||r!==void 0&&h.id!==r)continue;let m=a.get(h.id)??[],g=h.parallax?AB(rh(n,h.parallax),null):void 0;p.push(g?{kind:"group",transform:g,children:m}:{kind:"group",children:m})}return p}var Xa=[{field:"clipFromPose",opKey:"clipKey",jsonKey:"clipFromPoseKey",lost:"clip"},{field:"copiesFromPose",opKey:"copiesKey",jsonKey:"copiesFromPoseKey",lost:"copies"},{field:"derivePath",opKey:"derivePathKey",jsonKey:"derivePathKey",lost:"derived path"},{field:"derivePose",opKey:"derivePoseKey",jsonKey:"derivePoseKey",lost:"derived pose"},{field:"layout",opKey:"layoutKey",jsonKey:"layoutKey",lost:"layout"}];function ny(e,t){return Xa.map(n=>{let r=e[n.field],o=new Map;if(r)for(let[i,s]of Object.entries(r))o.set(s,i);return{spec:n,keyOf:i=>o.get(i),fnOf:i=>r?.[i],read:i=>i[n.field],write:(i,s)=>{i[n.field]=s,t?.(n.field,i)}}})}function Gc(e,t,n,r,o){let i=e.fnOf(n);if(i===void 0){o("scene",`${r}: ${e.spec.opKey} "${n}" not in this scene's registry \u2014 node "${t.id}" restored without its ${e.spec.lost}. Register a function with this key in the registry option to restore it.`);return}e.write(t,i)}function Ji(e,t,n,r){let o={};for(let i of e){let s=i.read(t);if(s===void 0)continue;let a=i.keyOf(s);if(a===void 0){r?.(i);continue}o[i.spec[n]]=a}return o}function ry(e){let t=e,n={};for(let r of Xa){let o=t[r.field];o!==void 0&&(n[r.field]=o)}return n}function ar(e){let t={};return e.pickable!==void 0&&(t.pickable=e.pickable),e.hidden===!0&&(t.hidden=!0),e.locked===!0&&(t.locked=!0),e.units!==void 0&&(t.units=e.units),e.clip!==void 0&&(t.clip=e.clip),e.consumesChildren===!0&&(t.consumesChildren=!0),t}function oy(e){let t=n=>n===null?[...e.roots]:[...e.childrenOf(ue(n))];return{getNode:n=>e.get(ue(n)),getParent:n=>e.get(ue(n))?.parent??null,getChildren:t,getRemovalClosure:n=>[...e.removalClosure(n.map(ue))],setPose:(n,r)=>e.setPose(ue(n),r),setParent:(n,r)=>e.move(ue(n),r==null?null:ue(r)),setChildOrder:(n,r)=>{e.batch("Reorder",()=>{for(let o=0;o<r.length;o++)t(n)[o]!==r[o]&&e.reorder(ue(r[o]),o)})},setData:(n,r)=>e.update(ue(n),{data:r}),setLayer:(n,r)=>e.setLayer(ue(n),r),setDependsOn:(n,r)=>e.setDependsOn(ue(n),Array.isArray(r)?r.map(ue):r),setLayout:(n,r)=>e.setLayout(ue(n),r),setHidden:(n,r)=>e.setHidden(ue(n),r),setLocked:(n,r)=>e.setLocked(ue(n),r),removeNode:n=>e.remove(ue(n)),insertNode:(n,r)=>{e.add({kind:n.kind,layer:n.layer,pose:n.pose,data:n.data,id:n.id,...r!==void 0?{index:r}:{},...n.parent!=null?{parent:n.parent}:{},...n.dependsOn!==void 0?{dependsOn:n.dependsOn}:{},...ar(n),...ry(n)})}}}function ZB(e){return{getPose:t=>Lr(e,e.get(ue(t))),getNodes:()=>[...e.renderOrderNodes()]}}function e3(e,t,n){for(let r of t)r.apply(e)}Z();function n3(e,t){let n=e?.get?.();return{...t?{alphaOf:t}:{},...e?.layerIsPainted?{layerIsPainted:r=>e.layerIsPainted(r)}:{},...n?{camera:n}:{}}}function r3(e,t,n,r=jo,o={}){return i3(e,VB(t),"intersect",n,r,o)}function o3(e,t,n,r,o=jo,i={}){let s=zB(t);return s?i3(e,s,n,r,o,i):[]}function t3(e,t){return t?.kind!=="polygon"||e()?t:{...t,openFill:"none"}}function i3(e,t,n,r,o,i){let s=f1(e,{...r,index:{descriptor:o}});return JB(s,p1(t,n,o,i))}function p1(e,t,n,r){return{includeGroups:r.includeGroups===!0,broad:{box:e.bounds},clipAdmits:(o,i,s,a)=>{let l=_r(n,i);return Od(o,a?et(a):Di(s,l))&&Od(o,e.bounds)},hits:(o,i,s,a)=>{let l=_r(n,o),u=s?et(s):ey(o,i,l),c=c1(e,t,u);if(c!==void 0)return c;let d,f=()=>d??=zm(o,i,{inherited:a})?.filled!==!1;return $B(e,t,t3(f,i),u,()=>t3(f,Fc(o,i,{derivedPath:s})??s??jB(i,u)),f)},inPlane:o=>p1(mX(e,o),t,n,r),inCopy:o=>({...p1(yX(e,o),t,n,r),broad:void 0})}}function mX(e,t){let n=[];for(let r of e.verts){let o=Dw(t,r);n.push(o.x,o.y)}return Bc(n,KC(t,e.bounds),e.isRect)}function yX(e,t){let n=[],r=1/0,o=1/0,i=-1/0,s=-1/0;for(let l of e.verts){let[u,c]=wn(t,l.x,l.y);n.push(u,c),r=Math.min(r,u),o=Math.min(o,c),i=Math.max(i,u),s=Math.max(s,c)}let a=t[1]===0&&t[2]===0||t[0]===0&&t[3]===0;return Bc(n,{x:r,y:o,width:i-r,height:s-o},e.isRect&&a)}function gX(e,t,n,r){return r!==void 0?r(t,n):e.get(t)?.kind==="group"}function s3(e,t,n,r){return gX(e,t,n,r)===!0}function a3(e,t,n){return t==null||!e||e.get(t)===void 0?null:s3(e,t,[],n)?t:null}function l3(e,t,n){let r=a3(e,t,n);if(r===null)return{parent:null,layer:e.layers[0]?.id??"default",local:a=>a};let o=e.get(r),i=e.composition;if(i===void 0||!Et(i))return{parent:o.id,layer:o.layer,local:a=>a};let s=aa(bh(e,{getPose:a=>e.get(a).pose,getParent:a=>e.get(a)?.parent??null,definesFrame:a=>lt(e.get(a)??{})}),o.id,i.compose);return{parent:o.id,layer:o.layer,local:a=>i.decompose(s,a)}}function h1(e,t){return e?.axes?.(t)??Zu(t)}var u3=new WeakMap;function bX(e){let t=u3.get(e);return t||(t=()=>e.commit(),u3.set(e,t)),t}function xX(e,t){let n=t(),r=h1(e,n);if(!r)return null;let{count:o,angles:i}=r,s=()=>{let a=t();if(a!==n){let l=h1(e,a);l&&l.count===o&&(r=l),n=a}return r};return{count:o,angles:i,to:a=>s().to(a),from:a=>s().from(a),add:r.add&&((a,l)=>{let u=s();return u.add?u.add(a,l):u.from(u.to(a).map((c,d)=>c+l[d]))}),write:r.write&&((a,l,u)=>{let c=s();c.write?c.write(a,l,u):c.to(a).forEach((d,f)=>{l[u+f]=d})})}}function wX(e,t,n){let{overrides:r}=e,o=e.id,i=xX(e.descriptor,e.get);if(!i)return null;let s={},a=!1,l=null,u=()=>{a=!1,l?.(),l=null,r.clear(o,s),t?.()},c=aP({get:e.get,set:e.set,axes:i,show(d){if(c.active&&n?.()&&c.stop({commit:!1}),!c.active){u();return}s.pose=d,r.has(o,s)||r.set(o,s),a=!0,n&&l===null&&(l=r.subscribe(()=>{!c.active||!n()||(c.stop({commit:!1}),a&&u())}))},publish:bX(r)});return c}var c3=new WeakMap;function d3(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=e,r=t,o=0;for(let i in n)if(Object.hasOwn(n,i)){if(!Object.hasOwn(r,i)||n[i]!==r[i])return!1;o++}for(let i in r)Object.hasOwn(r,i)&&o--;return o===0}function f3(e,t,n){let r=c3.get(e.overrides);r||(r=new Map,c3.set(e.overrides,r));let o=t,i=e.get(o),s=n??Mt,a=r.get(t),l=!a||a.active||!i||h1(s,Lr(e,i))?.count===a.axisCount;if(a&&l)return a;if(!i)return;let u=Lr(e,i),c,d=!1,f=r,p=null;if(p=wX({id:t,descriptor:s,overrides:e.overrides,get(){let h=e.get(o);return h&&(u=Lr(e,h)),h&&!p?.active&&(c=h.pose),u},set(h){let m=e.get(o);if(m){d=!0;try{d3(m.pose,h)||e.untracked(()=>e.setPose(o,h))}finally{d=!1}c=e.get(o)?.pose}}},()=>{e.get(o)||f.delete(t)},()=>{if(d)return!1;let h=e.get(o);return!!h&&c!==void 0&&!d3(h.pose,c)}),!!p)return r.set(t,p),p}function qt(e){return e.children!==void 0&&e.children.length>0}function Ja(e){return Array.isArray(e)?[...e]:e!==null&&typeof e=="object"?{...e}:e}function p3(e,t){let{scene:n}=e,r=ny(n.registry),o=new Set(t),i=new Set,s=[],a=(p,h)=>{if(h)return e.worldPoseOf(p.id);let m=e.frameAtOrAbove(p.parent);return m!==null&&i.has(m)?p.pose:e.worldPoseOf(p.id)},l=(p,h=!1)=>{if(i.has(p))return;let m=n.get(ue(p));if(m&&(i.add(p),s.push({kind:m.kind,id:m.id,layer:m.layer,parent:m.parent,pose:Ja(a(m,h)),data:Ja(m.data),...m.children!==void 0?{children:[...m.children]}:{},...ar(m),...m.dependsOn!==void 0?{dependsOn:Ja(m.dependsOn)}:{},...ry(m),...Ji(r,m,"jsonKey")}),qt(m)))for(let g of n.childrenOf(ue(p)))l(g)},u=p=>n.get(ue(p))?.parent,c=p=>Hm(o,p,u)!==null,d=new Set,f=p=>{if(d.has(p))return;d.add(p);let h=n.get(ue(p));if(h){for(let m of qu(h))i.has(m)||c(m)||n.get(m)?.hidden!==!0||(f(m),l(m,!0));if(qt(h))for(let m of n.childrenOf(ue(p)))f(m)}};for(let p of Cc(t,u))f(p),l(p,!0);return{items:s}}var PX=e=>typeof e=="function"||typeof e=="object"&&e!==null&&Object.values(e).some(t=>typeof t=="function");function TX(e,t){let n={},r=e.registry;for(let o of Xa){let i=t[o.jsonKey],a=(typeof i=="string"?r[o.field]?.[i]:void 0)??(PX(t[o.field])?t[o.field]:void 0);a!==void 0&&(n[o.field]=a)}return n}function SX(e,t){let n=new Map,r=new Set(e.map(o=>o.id));for(let o=!0;o;){o=!1;for(let i of e){if(n.has(i.id))continue;let s,a=qu(i),l=a.filter(c=>!r.has(c)),u=t.get(i.id);i.parent!==null&&n.has(i.parent)?s={id:i.id,reason:"container-not-pasted"}:l.length>0?s={id:i.id,reason:"dependency-not-copied",missing:l}:a.length>0&&u.derivePath===void 0&&u.derivePose===void 0&&(s={id:i.id,reason:"derivation-not-registered"}),s!==void 0&&(n.set(i.id,s),r.delete(i.id),o=!0)}}return n}function h3(e,t,n,r){let o=t.items;if(o.length===0)return[];let i=new Map(o.map(b=>[b.id,TX(e.scene,b)])),s=SX(o,i);if(r?.onOmit)for(let b of o){let x=s.get(b.id);x&&r.onOmit(x)}let a=s.size===0?o:o.filter(b=>!s.has(b.id)),l=new Map;for(let b of a)l.set(b.id,e.scene.mintId());let u=b=>b.parent===null||!l.has(b.parent),c=new Map(a.map(b=>[b.id,b])),d=b=>{let x=b.parent===null?void 0:c.get(b.parent);for(;x!==void 0;){if(lt(x))return!0;x=x.parent===null?void 0:c.get(x.parent)}return!1},f=n.dx,p=n.dy;if(r?.dropPoint){let b=1/0,x=1/0;for(let w of a){if(!u(w))continue;let y=e.poseBounds(w.pose,w);y.x<b&&(b=y.x),y.y<x&&(x=y.y)}Number.isFinite(b)&&Number.isFinite(x)&&(f=r.dropPoint.x-b,p=r.dropPoint.y-x)}let h=e.landing?.(),m=h?.parent!=null?h:null,g=b=>{if(d(b))return Ja(b.pose);let x=e.translate(Ja(b.pose),f,p,b);return m&&u(b)?m.local(x):x};return a.map(b=>({id:l.get(b.id),kind:b.kind,layer:m&&u(b)?m.layer:b.layer,parent:u(b)?m?.parent??null:l.get(b.parent),pose:g(b),data:Ja(b.data),...ar(b),...b.children!==void 0?{children:b.children.filter(x=>l.has(x)).map(x=>l.get(x))}:{},...b.dependsOn==="children"?{dependsOn:"children"}:qu(b).length>0?{dependsOn:qu(b).map(x=>l.get(x))}:{},...i.get(b.id)}))}function kX(e){let t=Et(e.composition),n=YC(e.composition.compose),r=t?oP(e):void 0,o={getParent:i=>e.get(ue(i))?.parent??null,getPose(i){let s=e.get(ue(i));if(!s)throw new Error(`sceneToAdapter: unknown node "${i}"`);return Xn(e,s)},definesFrame(i){let s=e.get(ue(i));return s===void 0||lt(s)},...r?{childFrame:r}:{}};return{getPose:o.getPose,definesFrame:o.definesFrame,getWorldPose:i=>t?zt(o,i,n):o.getPose(i),worldOfStored(i,s){let a=t?qn(o,o.getParent(i)):null;return a===null?s:n(aa(o,a,n),s)},...t?{composePose:n}:{},...r?{childFrame:r}:{}}}function m3(e,t={}){let n=t.selection,r=n?.getSelection??n?.get??(()=>[]),o=n?.setSelection??n?.set??(()=>{}),i=t.poseDescriptor??jo,s=(f,p)=>Di(f,_r(i,p)),a=(f,p,h,m)=>rP(f,p,h,m===void 0?i:_r(i,m)),l={},u=f=>f?{...l,...n3(f,void 0)}:l,c={scene:e,worldPoseOf:f=>d.getWorldPose(f),frameAtOrAbove:f=>qn(d,f),poseBounds:s,translate:a,...t.pasteInto?{landing:()=>l3(e,t.pasteInto())}:{}},d={...oy(e),getNodes(){let f=qa(e);return e.renderOrderNodes().filter(p=>!f.hidden(p.id))},...kX(e),poseTarget:(f,p)=>f3(e,f,p??i),getLayers:()=>e.layers.map(f=>({id:f.id,visible:f.visible,parallax:f.parallax})),subscribeLayers:f=>e.subscribe(f),getLayout:f=>e.layoutOf(ue(f)),applyOps(f,p){p!==void 0?e.applyBatch(f,p,this):e3(this,f)},getSelection:r,setSelection:o,hitTestArea(f,p){return r3(e,f,u(p),i,{includeGroups:!0})},hitTestLasso(f,p,h){return o3(e,f,p,u(h),i,{includeGroups:!0})},...t.commitInsert?{commitInsert:f=>{let p=t.commitInsert(f);if(!p)return null;let h=t.insertLayer??"default";return{kind:"mark",id:p.id===void 0?e.mintId():ue(p.id),layer:h,pose:p.pose,data:p.data,parent:null}}}:{},snapshotSelection(f){return p3(c,f)},commitPaste(f,p,h){return h3(c,f,p,h)},getPasteOffset(){return{dx:12,dy:12}}};return d}var vX=()=>typeof performance<"u"?performance.now():Date.now();function y3(e,t,n=vX){return(r,o,i,s)=>{if(!e.has(r.id))return t(r,o,i,s);let a=n();return t(r,o,i,{...s,vertexColors:(l,u)=>e.resolve(r.id,l,u,a)})}}Z();Z();function g3(e,t,n){let r=t,o=br(t);return(i,s,a=t)=>{a!==r&&(r=a,o=br(a));let l=e(i,s,a);if(!l)return!1;let u=Ce(s),c=u?q.multiply(o,q.fromAffine(u)):o;return C0(l,c,n)}}function x3(e){let t=typeof window<"u"&&window.devicePixelRatio||1;return Math.max(Math.abs(e.scale.x),Math.abs(e.scale.y))*t}var b3,m1={};function AX(e){let t=x3(e);return(e!==b3||m1.pixelScale!==t)&&(b3=e,m1={pixelScale:t}),m1}function w3(e,t,n,r){let o=e.kind==="group"?void 0:Oc(e),i=!n||r?.pixelScale!==void 0?r:r?{...r,pixelScale:x3(n)}:AX(n),s=o?o.paint(e,t,i):[],a=e.data;if(a?.label&&a.text==null){let l=t,u=Fw(l.x+6,l.y+14,[{text:a.label,fill:{paint:{kind:"solid",color:"rgba(0,0,0,0.7)"}}}],{fontFamily:"sans-serif",fontSize:11});return[...s,e.kind==="group"?$m([u]):u]}return s}function P3(e,t){return(n,r,o,i)=>t(Tt(e,n),r,o,i)}function RX(e,t={}){let{getNode:n,getChildren:r,getPose:o,composePose:i,childFrame:s}=m3(e);return{getLayers:()=>vB(e.layers,t).map(a=>({id:a.id,visible:a.visible,parallax:a.parallax})),getNode:n,getChildren:r,getPose:o,...i?{composePose:i}:{},...s?{childFrame:s}:{}}}function T3(e,t,n,r,o,i,s,a){let l=ha(e),u=WB(e,aB(l,n)),c=s?y3(s,u):u,d=Dc(e),f=w=>d(Tt(e.overrides,w)),p=(w,y,P)=>{let S=e.overrides.read(w.id)?.alpha??1;return CB(c(Tt(e.overrides,w),y,P),y,(o?o(w.id):1)*S)},h=RX(e,i),m=a?{x:0,y:0,width:a.width,height:a.height}:void 0,g=m&&a?.paintBounds?g3(P3(e.overrides,lB(l,a.paintBounds)),t,m):void 0,b=QB(h,p,t,void 0,f,g),x=a&&m?M0(b,br(t),m,a.dpr):b;if(r&&r.length>0)for(let w of r)x.push(w);return[{kind:"group",transform:br(t),children:x}]}Z();function S3(e){let t=new Map,n=new Set,r=i=>{i&&n.add(i.kind??"solid")},o=i=>{for(let s of i)if(s.kind==="group")o(s.children);else if(s.kind==="path")r(s.fill?.paint),r(s.stroke?.paint);else if(s.kind==="text")for(let a of s.runs){let l=`${a.fontFamily}|${a.fontWeight}|${a.fontStyle}`;t.has(l)||t.set(l,{family:a.fontFamily,weight:a.fontWeight,style:a.fontStyle}),r(a.fill?.paint),r(a.stroke?.paint)}};return o(e),{fonts:[...t.values()],paintKinds:[...n]}}function k3(e,t,n){let r=NX(e,t,n);return IX(r),r}function NX(e,t,n){let r=t*4,o=new Uint8ClampedArray(e.length);for(let i=0;i<n;i++)o.set(e.subarray((n-1-i)*r,(n-i)*r),i*r);return o}function IX(e){for(let t=0;t<e.length;t+=4){let n=e[t+3];if(n===0||n===255)continue;let r=255/n;e[t]=e[t]*r,e[t+1]=e[t+1]*r,e[t+2]=e[t+2]*r}}function y1(e){let{sourceRect:t,scale:n}=e;for(let[c,d]of[["sourceRect.width",t.width],["sourceRect.height",t.height]])if(!Number.isFinite(d)||d<=0)throw new Error(`renderSceneToPixels: ${c} must be a positive finite number, got ${d}`);for(let[c,d]of[["scale.x",n.x],["scale.y",n.y]])if(!Number.isFinite(d)||d===0)throw new Error(`renderSceneToPixels: ${c} must be a nonzero finite number, got ${d}`);for(let[c,d]of[["sourceRect.x",t.x],["sourceRect.y",t.y]])if(!Number.isFinite(d))throw new Error(`renderSceneToPixels: ${c} must be a finite number, got ${d}`);let r=Math.max(1,Math.round(t.width*Math.abs(n.x))),o=Math.max(1,Math.round(t.height*Math.abs(n.y))),i={x:n.x<0?t.x+t.width:t.x,y:n.y<0?t.y+t.height:t.y,scale:{x:n.x,y:n.y}},s=e.resolveImage,a=e.drawOne??((c,d,f,p)=>w3(c,d,f,{...p,resolveImage:s})),l=[];e.background!==void 0&&l.push({kind:"path",path:{kind:"rect",x:0,y:0,width:r,height:o},fill:{paint:{kind:"solid",color:e.background}}});let u=e.annotations?void 0:{layerVisibility:Object.fromEntries([...Xm(e.scene.layers)].map(c=>[Km(c),!1]))};return l.push(...T3(e.scene,i,a,void 0,e.alphaFor,u,e.colorOverrides)),e.overlay&&l.push(...e.overlay),{width:r,height:o,view:i,commands:l}}function EX(e,t){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,t);if(typeof document<"u"){let n=document.createElement("canvas");return n.width=e,n.height=t,n}throw new Error("renderSceneToPixels: no canvas source in this environment \u2014 supply `gl` or `createCanvas`")}function g1(e={}){if(e.gl&&e.createCanvas)throw new Error("raster session: `gl` and `createCanvas` are mutually exclusive");let t=null,n=e.gl,r=null,o=!1;function i(s,a){if(e.gl||(t?(t.width<s&&(t.width=s),t.height<a&&(t.height=a)):(t=(e.createCanvas??EX)(s,a),t.width=s,t.height=a,n=t.getContext("webgl2",RB)??void 0)),!n||typeof n.enable!="function")throw new Error("raster session: WebGL2 is unavailable \u2014 supply `gl` or a WebGL2-capable `createCanvas`");if(v3(n))throw new Error("raster session: the WebGL2 context is lost \u2014 dispose this session and open another");let{drawingBufferWidth:l,drawingBufferHeight:u}=n;if(l<s||u<a)throw new Error(`raster session: a ${s} \xD7 ${a} render does not fit the context's ${l} \xD7 ${u} drawing buffer \u2014 lower \`scale\` or render the source rect in tiles`);return n}return{render(s){if(o)throw new Error("raster session: render() on a disposed session");let a=y1(s),{width:l,height:u}=a,c=i(l,u),d={px:s.flattenTolerancePx??.25};if(r?(r.resize({width:l,height:u,dpr:1}),r.setFlattenTolerance(d)):r=new ju({gl:c,width:l,height:u,dpr:1,imageMinification:"mipmap",flattenTolerance:d,bakeBudget:1/0}),r.render(a.commands,br(a.view),{screen:s.screen}),v3(c))throw new Error("raster session: the WebGL2 context was lost during render");let f=new Uint8Array(l*u*4);return c.readPixels(0,0,l,u,c.RGBA,c.UNSIGNED_BYTE,f),{width:l,height:u,data:k3(f,l,u)}},dispose(){o||(o=!0,r?.dispose(),r=null,t&&!e.createCanvas&&n?.getExtension("WEBGL_lose_context")?.loseContext(),t=null,n=void 0)}}}function v3(e){return typeof e.isContextLost=="function"&&e.isContextLost()===!0}function b1(e={}){let{families:t,paintKinds:n}=e;if(e.render||e.commands){let r;try{r=e.render?y1(e.render).commands:[]}catch(i){return Promise.reject(i)}let o=S3([...r,...e.commands??[]]);t??=o.fonts,n??=o.paintKinds.filter(L0)}return Promise.all([Ly(t),_0(n)]).then(()=>{})}async function x1(e){let t=new ImageData(new Uint8ClampedArray(e.data),e.width,e.height);if(typeof OffscreenCanvas<"u"){let o=new OffscreenCanvas(e.width,e.height),i=o.getContext("2d");if(!i)throw new Error("rasterToPng: no 2D context");return i.putImageData(t,0,0),o.convertToBlob({type:"image/png"})}if(typeof document>"u")throw new Error("rasterToPng: no canvas in this environment");let n=document.createElement("canvas");n.width=e.width,n.height=e.height;let r=n.getContext("2d");if(!r)throw new Error("rasterToPng: no 2D context");return r.putImageData(t,0,0),new Promise((o,i)=>{n.toBlob(s=>s?o(s):i(new Error("rasterToPng: encoding failed")),"image/png")})}var Qa=class extends Error{arrivals;constructor(t){let n=[...t.keys()].map(r=>`"${r}"`).join(", ");super(`Scene: ${n} refused the nodes joining it`),this.name="SceneArrivalRefused",this.arrivals=t}};var w1=xt(),mIe=w1.reflection;function A3(e,t){w1.set(e,t)}function iy(e,t){let n=w1.get(e);return n?n(t):null}function R3(e,{compose:t,decompose:n},r,o){let i=n(e,e),s=r(i),a=r(e);if(s===null||a===null)return null;let l=o(i,s,{...s,x:a.x+(a.width-s.width)/2,y:a.y+(a.height-s.height)/2}),u=r(l);if(u===null)return null;let c=!No(l,e);return{upright:l,bounds:u,turned:c,toStrategy:d=>c?t(l,n(e,d)):d,toWorld:d=>c?t(e,n(l,d)):d}}function N3(e){let t=e?.data?.pathEffect;return t&&typeof t=="object"&&typeof t.kind=="string"?t:null}var P1="kit:clipNothing",T1=()=>null;var I3="kit:unionOfChildren";function E3(e,t){let n=[];for(let o of t){if(o===void 0)continue;let i=S1(o.pose);if(i===null)return null;n.push(i)}if(n.length===0)return null;let r=v2(n);return r===null?null:r}function S1(e){if(e===null||typeof e!="object")return null;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"?e:null}function M3(e){return{...e,clipFromPose:{[P1]:T1,...e.clipFromPose},derivePath:{[qT]:XT,...e.derivePath},derivePose:{[I3]:E3,...e.derivePose}}}function F3(e,t){let{undoStack:n,redoStack:r,forks:o,floorId:i,nextEntryId:s}=e,a=0,l=b=>(a+=b.length,b.map(x=>MX(x,t))),u=b=>{let x=l(b);return x.slice(x.lastIndexOf(null)+1)},c=u(n),d=u(r),f=c.length===n.length?i:n[n.length-c.length-1].id,p=new Set([f,...[...c,...d].map(b=>b.id)]),h=[...o].flatMap(([b,x])=>x.map(w=>{let y=l(w),P=y.indexOf(null);return{at:b,entries:P<0?y:y.slice(0,P)}})).filter(b=>b.entries.length>0),m=[];for(let b=!0;b;){b=!1;let x=[];for(let w of h){if(!p.has(w.at)){x.push(w);continue}m.push(w);for(let y of w.entries)p.add(y.id);b=!0}h=x}let g=c.length+d.length+m.reduce((b,x)=>b+x.entries.length,0);return{version:1,undoStack:c,redoStack:d,...m.length>0?{branches:m}:{},...f!==0?{floor:f}:{},nextEntryId:s,droppedEntries:a-g}}function L3(e,t,n){let r=u=>OX(u,t,n),o=e.undoStack.map(r),i=e.redoStack.map(r),s=new Map;for(let u of e.branches??[]){let c=u.entries.map(r),d=s.get(u.at);d?d.push(c):s.set(u.at,[c])}let a=e.nextEntryId,l=[o,i,...[...s.values()].flat()];for(let u of l)for(let c of u)c.id>=a&&(a=c.id+1);return{undoStack:o,redoStack:i,forks:s,floorId:e.floor??0,nextEntryId:a}}function Qi(e){let t=new Set;for(let n of e){if(n.args===null||typeof n.args!="object")continue;let r=n.args;if(typeof r.id=="string")t.add(r.id);else if(r.node!==null&&typeof r.node=="object"){let o=r.node;typeof o.id=="string"&&t.add(o.id)}else if(Array.isArray(r.nodes))for(let o of r.nodes){let i=o!==null&&typeof o=="object"?o.id:void 0;typeof i=="string"&&t.add(i)}}return t}function C3(e){return typeof e.name!="string"?null:{name:e.name,args:e.args}}function MX(e,t){let n=[];for(let o of e.forwardOps){let i=C3(o);if(i===null)return t.log(`serialize: dropping entry id=${e.id} "${e.label}" \u2014 forwardOp without name`),null;n.push(i)}let r=[];for(let o of e.baseOps){let i=C3(o);if(i===null)return t.log(`serialize: dropping entry id=${e.id} "${e.label}" \u2014 baseOp without name`),null;r.push(i)}return{id:e.id,label:e.label,forwardOps:n,baseOps:r,pushes:e.pushes,timestamp:e.timestamp,...e.selectionBefore?{selectionBefore:e.selectionBefore}:{},...e.selectionAfter?{selectionAfter:e.selectionAfter}:{}}}function CX(e,t,n){let r={name:e,args:t,label:n,apply:()=>"noop",invert:()=>r};return r}function O3(e,t,n,r){let o=n?n(e.name,e.args):null;return o!==null?o:(r.log(`restore: unknown op name "${e.name}" \u2014 substituting no-op placeholder`),CX(e.name,e.args,t))}function OX(e,t,n){let r=e.forwardOps.map(i=>O3(i,e.label,t,n)),o=e.baseOps.map(i=>O3(i,e.label,t,n));return{id:e.id,label:e.label,forwardOps:r,baseOps:o,timestamp:e.timestamp??0,pushes:e.pushes??1,touchedIds:Qi(r),...e.selectionBefore?{selectionBefore:[...e.selectionBefore]}:{},...e.selectionAfter?{selectionAfter:[...e.selectionAfter]}:{}}}function _3(e,t){if(e.length===0||t.length===0||e.length!==t.length)return!1;let n=new Map;for(let r of e){let o=r.coalesceKey;if(o===void 0)return!1;n.set(o,(n.get(o)??0)+1)}for(let r of t){let o=r.coalesceKey,i=o===void 0?0:n.get(o)??0;if(!i)return!1;n.set(o,i-1)}return!0}function k1(e){return{id:e.id,label:e.label,timestamp:e.timestamp,pushes:e.pushes,touchedIds:e.touchedIds,...e.selectionBefore?{selectionBefore:e.selectionBefore}:{},...e.selectionAfter?{selectionAfter:e.selectionAfter}:{}}}function lr(e,t=[]){return{kind:e,entries:t.map(n=>({id:n.id,label:n.label,ops:n.forwardOps}))}}function D3(e,t){function n(o){for(let i of o)try{i.apply(e)}catch(s){t.warn(`unwinding a failed step: op "${i.name??"?"}" threw: ${String(s)}`)}}function r(o,i,s){let a=!1,l=0;try{for(;l<o.length;l++){let u=o[l].apply(e);u!==!1&&u!=="noop"?a=!0:s?.push(o[l])}}catch(u){throw l>0&&(n(o.slice(0,l).reverse().map(c=>c.invert())),i&&n(i())),u}return a}return r}function B3(e,t,n){let r=e.forwardOps===e.baseOps;e.forwardOps=[...e.forwardOps,...t],e.baseOps=r?e.forwardOps:[...e.baseOps,...t],e.timestamp=n,e.pushes++;let o=new Set(e.touchedIds);for(let i of Qi(t))o.add(i);e.touchedIds=o}function H3(e){for(let t=0;t<e.length;t++)if(e[t].caused!==void 0)return!0;return!1}var sy=new WeakMap;function G3(e){let t=sy.get(e);if(!t)throw new Error("Journal is not resumable (already committed or cancelled)");t()}function U3(e,t,n,r,o={}){let i=Uc(t,{...o,...n.coalesceWindowMs!==void 0?{coalesceWindowMs:n.coalesceWindowMs}:{}}),s=o.selection,a=0,l=Me();function u(){a++,l.emit()}i.subscribe(u);let c=e.currentEntryId(),d=s?[...s.get()]:void 0,f="active",h={targetId:n.targetId,forkedAtEntryId:c,applyBatch(m,g){if(f!=="active")throw new Error("Journal is not active");i.applyOps(m,g)},undo(){if(f!=="active")throw new Error("Journal is not active");i.undo()},redo(){if(f!=="active")throw new Error("Journal is not active");i.redo()},canUndo(){return i.canUndo()},canRedo(){return i.canRedo()},entries(){return i.entries()},seal(){i.seal()},observe:m=>i.observe(m),beginJournal(m){if(f!=="active")throw new Error("Journal is not active");return i.beginJournal(m)},getVersion:()=>a,subscribe:l.subscribe,commit(m){if(f!=="active")throw new Error("Journal is not active");let{forwardOps:g,baseOps:b}=v1(i).appliedOps();v1(e).record(g,b,m,d?{selectionBefore:d}:void 0),f="closed",sy.delete(h),r?.(),u()},cancel(){if(f!=="active")throw new Error("Journal is not active");i.goto(0),f="closed",sy.delete(h),r?.(),u()},suspend(){if(f!=="active")throw new Error("Journal is not active");f="suspended",r?.(),u()},isActive(){return f==="active"}};return sy.set(h,()=>{if(f!=="suspended")throw new Error("Journal is not suspended");f="active",u()}),h}var W3=new WeakMap;function v1(e){let t=W3.get(e);if(!t)throw new Error("Not a history built by createHistory");return t}var FX={log:()=>{},warn:()=>{}};function Uc(e,t={}){let n=[],r=[],o=null,i=t.coalesceWindowMs??0,s=t.now??(()=>Date.now()),a=Math.max(0,t.historyLimit??1/0),l=t.onEvict,u=t.branching??!1,c=new Map,d=0,f=t.rebuildOp,p=t.selection,h=t.debug??FX,m=1,g=0,b=-1,x=Me(),w=Me();function y(G){g++,G&&w.size>0&&w.emit(typeof G=="function"?G():G),x.emit()}function P(G){if(l)for(let K of G)try{l({id:K.id,label:K.label,forwardOps:K.forwardOps,baseOps:K.baseOps})}catch($){h.warn(`onEvict callback threw for entry id=${K.id} "${K.label}": ${String($)}`)}}function S(G){P(G);for(let K of G){let $=c.get(K.id);if($){c.delete(K.id);for(let ee of $)S(ee)}}}function v(G){for(let K of G){l&&P([K]);let $=c.size>0?c.get(d):void 0;if($!==void 0&&c.delete(d),d=K.id,$!==void 0)for(let ee of $)S(ee)}}function A(){return n[n.length-1]?.id??d}function N(G){if(r.length===0)return;let K=r.splice(0);if(!u)return S(K);let $=c.get(G);$?$.push(K.reverse()):c.set(G,[K.reverse()])}function M(){for(;n.length>a;)v([n.shift()])}let C=D3(e,h);function F(G){return[...G.baseOps].reverse().map(K=>K.invert())}function B(){return p?[...p.get()]:void 0}function D(G){let K=B(),$=G.forwardOps!==G.baseOps;C(F(G),$?()=>G.forwardOps:void 0),K&&(G.selectionAfter=K),p&&G.selectionBefore&&p.set(G.selectionBefore)}function j(G){let K=B(),$=G.forwardOps!==G.baseOps;C(G.forwardOps,$?()=>F(G):void 0),K&&(G.selectionBefore=K),p&&G.selectionAfter&&p.set(G.selectionAfter)}function W(G){let K=[];for(;n.length>G;){let $=n[n.length-1];D($),n.pop(),r.push($),K.push($)}for(;n.length<G&&r.length>0;){let $=r[r.length-1];j($),r.pop(),n.push($),K.push($)}return K}function J(G,K){let $=typeof i=="function"?i():i;return!($>0)||G.coalesceKey!==void 0||g!==b||s()-G.timestamp>$?!1:_3(G.forwardOps,K)}function se(G,K){if(G.length===0)return;let $=B(),ee=[],te=C(G,void 0,ee),he=ee.length===0?G:G.filter(vt=>!(vt.elideNoop&&ee.includes(vt))),be=H3(he)?he.flatMap(vt=>vt.caused?.()??[vt]):he.slice();if(!te){h.warn(`'${K}' batch was a no-op \u2014 every op reported false/'noop'. Skipping the undo entry; consider gating the dispatch upstream to avoid the wasted work.`);return}if(be.length===0)return;let Fe=Qi(be),Se=n[n.length-1];if(Se&&J(Se,be)){if(Se.forwardOps=be,Se.timestamp=s(),Se.pushes++,Fe.size>0){let vt=new Set(Se.touchedIds);for(let Xt of Fe)vt.add(Xt);Se.touchedIds=vt}h.log(`coalesce '${K}' into entry id=${Se.id} (${be.length} ops)`),y(()=>({kind:"coalesce",entries:[{id:Se.id,label:Se.label,ops:be}]})),b=g;return}h.log(`push '${K}' (${be.length} ops)`);let ur=A(),Le={id:m++,forwardOps:be,baseOps:be,label:K,timestamp:s(),pushes:1,touchedIds:Fe,...$?{selectionBefore:$}:{}};n.push(Le),N(ur),M(),y(()=>lr("push",[Le])),b=g}function ke(G,K){B3(G,K,s()),y(()=>({kind:"coalesce",entries:[{id:G.id,label:G.label,ops:K}]})),b=g}function ae(G,K,$,ee={}){if(G.length===0)return;let te=ee.coalesceKey,he=n[n.length-1];if(te!==void 0&&he?.coalesceKey===te&&g===b&&G===K)return ke(he,G);let be=A(),Fe={id:m++,forwardOps:G,baseOps:K,label:$,timestamp:s(),pushes:1,touchedIds:Qi(G),...ee.selectionBefore?{selectionBefore:[...ee.selectionBefore]}:{},...te!==void 0?{coalesceKey:te}:{}};n.push(Fe),N(be),M(),y(()=>lr("push",[Fe])),te!==void 0&&(b=g)}let ve={apply(G,K){se([G],K??G.label??"")},applyOps(G,K){se(G,K)},undo(){n.length!==0&&y(lr("undo",W(n.length-1)))},redo(){r.length!==0&&y(lr("redo",W(n.length+1)))},seal(){b=-1},canUndo:()=>n.length>0,canRedo:()=>r.length>0,undoDepth:()=>n.length,redoDepth:()=>r.length,clear:()=>{let G=n.length>0||r.length>0||c.size>0;n.length=0,r.length=0,c.clear(),d=0,G&&y(lr("clear"))},entries(){return{undo:n.map(k1),redo:[...r].reverse().map(k1)}},goto(G){let K=n.length+r.length;if(G<0||G>K||G===n.length)return;let $=n.length,ee;try{ee=W(G)}catch(te){try{W($)}catch(he){h.warn(`goto: returning to depth ${$} threw: ${String(he)}`)}throw n.length!==$&&y(),te}y(lr("goto",ee))},timestampAt(G){if(!(G<0))return G<n.length?n[G].timestamp:r[r.length-1-(G-n.length)]?.timestamp},depthAt(G){let K=n.length;for(;K>0&&n[K-1].timestamp>G;)K--;if(K<n.length)return K;for(let $=r.length-1;$>=0&&r[$].timestamp<=G;$--)K++;return K},prune(G){let K=0;for(;K<n.length&&n[K].timestamp<G;)K++;if(K===0)return;let $=n.splice(0,K);v($),y(lr("prune",$))},branches(){let G=($,ee)=>{let te=$[0];return{id:te.id,label:te.label,timestamp:te.timestamp,length:$.length,current:ee}},K=(c.get(A())??[]).map($=>G($,!1));return r.length>0&&K.push(G([...r].reverse(),!0)),K.sort(($,ee)=>$.id-ee.id)},switchBranch(G){if(r[r.length-1]?.id===G)return;let K=A(),$=c.get(K)??[],ee=$.findIndex(he=>he[0].id===G);if(ee<0)throw new Error(`No branch ${G} forks from entry ${K}`);let[te]=$.splice(ee,1);r.length>0&&$.push(r.splice(0).reverse()),$.length>0?c.set(K,$):c.delete(K),r.push(...[...te].reverse()),y(lr("branch",te))},getVersion:()=>g,subscribe:x.subscribe,observe:w.subscribe,serialize:()=>F3({undoStack:n,redoStack:r,forks:c,floorId:d,nextEntryId:m},h),recordEntry(G,K,$){ae(G,G,K,$)},allForwardOps(){let G=[];for(let K of n)for(let $ of K.forwardOps)G.push($);return G},currentEntryId:()=>m,beginJournal(G){if(o!==null&&o.isActive())throw new Error("A journal is already active \u2014 commit, cancel, or suspend it first");let K=U3(ve,e,G,()=>{o=null},{coalesceWindowMs:i,now:s,debug:h,...p?{selection:p}:{}});return o=K,K},activeJournal:()=>o?.isActive()?o:null,resumeJournal(G){if(o!==null&&o!==G&&o.isActive())throw new Error("A journal is already active \u2014 commit, cancel, or suspend it first");G3(G),o=G},restore(G){let K=L3(G,f,h);n.splice(0,n.length,...K.undoStack),r.splice(0,r.length,...K.redoStack),c.clear();for(let[$,ee]of K.forks)c.set($,ee);d=K.floorId,m=K.nextEntryId,y(lr("restore"))}};return W3.set(ve,{appliedOps:()=>({forwardOps:n.flatMap(G=>G.forwardOps),baseOps:n.flatMap(G=>G.baseOps)}),record:ae}),ve}function V3(e,t){let n=new Map,r=new Set,o=i=>{r.clear();for(let[s,a]of i){r.add(s);let l=n.get(s);if(l){l.pose=a.pose,l.data=a.data,e.has(s,l)||e.set(s,l);continue}let u={pose:a.pose,data:a.data};n.set(s,u),e.set(s,u)}for(let[s,a]of n)r.has(s)||(n.delete(s),e.clear(s,a));e.commit()};return{set(i){o(LX(i))},show:o,others(){let i=new Map;for(let s of e.ids()){let a=t(s)??[],l=n.get(s);for(let u=a.length-1;u>=0;u--){let c=a[u];if(!(c===l||c.pose===void 0)){i.set(s,c.pose);break}}}return i},drop(){if(n.size!==0){for(let[i,s]of n)e.clear(i,s);n.clear(),e.commit()}}}}function*LX(e){for(let[t,n]of e)yield[t,{pose:n}]}var _X=Object.freeze({}),z3=new WeakMap;function DX(e,t){let n=z3.get(e);n===void 0&&z3.set(e,n=new WeakMap);let r=n.get(t);return r===void 0&&n.set(t,r=o=>t(e(o))),r}var BX={merge:DX,lerp:(e,t,n)=>n<.5?e:t};function K3(e){let t=$T({pose:Th(),alpha:lP(),path:Th(),data:BX}),n=[],r=0,o=i=>{for(;n.length>i;)n.pop().fade({over:0});for(;n.length<i;){let s=n.length;n.push(t.cue({patch:AP(0,(a,l)=>e.get(l)?.[s]??_X,{writes:["pose","alpha","path","data"]})}))}t.sync(r++)};return o(1),{probe:(i,s)=>{t.probe(i,s)},publish:o,drop:i=>{t.drop(i)}}}function $3(){let e=new Map,t=new WeakMap,n=0,r=[],o=0,i=(s,a)=>{for(s>0&&r[s]--,a>0&&(r[a]=(r[a]??0)+1),a>o&&(o=a);o>0&&(r[o]??0)===0;)o--};return{plies:e,claim(s,a){let l=e.get(s);l===void 0&&e.set(s,l=[]);let u=l.indexOf(a);u>=0&&l.splice(u,1);let c=u>=0?void 0:t.get(a);c===void 0&&t.set(a,c=++n);let d=l.length;for(;d>0&&t.get(l[d-1])>c;)d--;l.splice(d,0,a),u<0&&i(l.length-1,l.length)},release(s,a){t.delete(a);let l=e.get(s),u=l?.indexOf(a)??-1;return l===void 0||u<0?!1:(l.splice(u,1),i(l.length+1,l.length),l.length===0&&e.delete(s),!0)},drop(s){let a=e.get(s);return a===void 0?!1:(e.delete(s),i(a.length,0),!0)},dropAll(){e.clear(),r.length=0,o=0},depth:()=>Math.max(o,1)}}var j3=e=>{let t=e;return t!==null&&typeof t=="object"&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"?t:null},A1=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height;function Y3(e,t,n){for(let r=e.length-1;r>=0;r--){let o=e[r];if(o.path===void 0)continue;let i=j3(o.pose),s=j3(t);if(i===null||s===null||A1(i,s))return o.path;let a=n.carried;return a!==void 0&&a.source===o.path&&A1(a.from,i)&&A1(a.to,s)?a.path:(n.carried={source:o.path,from:{...i},to:{...s},path:dh(o.path,i,s)},n.carried.path)}}function R1(e,t){let n=$3(),{plies:r}=n,o=K3(r),i=Me(),s=0,a=new Map;function l(f){let p=e(f);if(p){un(p);let h=w2(p);h&&un(h)}t?.(f)}function u(){s++,o.publish(n.depth()),i.emit()}function c(f){a.delete(f),o.drop(f)}let d={set(f,p){n.claim(f,p),l(f),u()},get(f){return r.get(f)?.at(-1)},read(f){let p=r.get(f);if(p===void 0)return;let h=a.get(f);return h===void 0&&(h={out:{},at:-1},a.set(f,h)),h.at!==s&&(o.probe(f,h.out),h.out.path=Y3(p,h.out.pose,h),h.at=s),h.out},has(f,p){let h=r.get(f);return h!==void 0&&(p===void 0||h.includes(p))},ids(){return[...r.keys()]},clear(f,p){(p===void 0?n.drop(f):n.release(f,p))&&(r.has(f)||c(f),l(f),u())},clearAll(){if(r.size!==0){for(let f of r.keys())c(f),l(f);n.dropAll(),u()}},commit(){for(let f of r.keys())l(f);u()},subscribe:i.subscribe,getGeneration(){return s},hold:()=>V3(d,f=>r.get(f))};return d}function ay(e,t,n){let r={...e.placed?{placed:e.placed}:{}};return{name:"arrange",args:r,label:"Arrange",elideNoop:!0,get coalesceKey(){return r.placed===void 0?void 0:`arrange:${r.placed.map(o=>o.id).sort().join(",")}`},apply(o){r.placed===void 0&&(r.placed=t?.()??[]);let i=n??((s,a)=>o.setPose(s,a));for(let s of r.placed)i(s.id,s.to);return r.placed.length>0?void 0:"noop"},invert(){let o=r.placed??[];return ay({placed:[...o].reverse().map(i=>({id:i.id,from:i.to,to:i.from}))},void 0,n)}}}A3("arrange",e=>ay(e));function q3(e,t,n){let r=new Map;for(let[o,i]of t){let s=i.filter(a=>e.get(a)?.parent===o===n);s.length>0&&e.has(o)&&r.set(o,s)}return r}function X3(e){let{nodes:t}=e,n=null,r=!1,o=null,i=new Map,s=new Set,a=null,l=Me(),u=()=>n??(r?e.layoutPass:null);function c(m=!1){return o!==null||!m&&u()===null?!1:(o=new Map,i=new Map,s=new Set,a=null,!0)}function d(){let m=a;a=null,!(m===null||m.length===0)&&l.emit(m)}function f(){let m=o;o=null;let g=u();if(m===null||g===null)return[];let b=q3(t,m,!0),x=q3(t,i,!1);i=new Map;let w=new Set([...s].filter(S=>t.has(S)));if(b.size===0&&w.size===0)return[];let y=g(b,w,x);if(y===null)throw new Qa(b);let P=[];for(let[S,v]of y){let A=t.get(S);A&&P.push({id:S,from:A.pose,to:v})}return a=P,P}function p(){o=null,a=null}function h(m){return c(!0)?{ops:[...m,ay({},f,e.writePose)],owned:!0}:{ops:m,owned:!1}}return{layoutDeclared:()=>{r=!0},setHandler(m){return n=m,()=>{n===m&&(n=null)}},onReflow:l.subscribe,noteArrival(m,g,b){if(o===null||g===null||g===b)return;s.add(g);let x=o.get(g);x===void 0?o.set(g,[m]):x.includes(m)||x.push(m)},noteDeparture(m,g,b){if(o===null||g===null||g===b||(s.add(g),o.get(g)?.includes(m)))return;let x=i.get(g);x===void 0?i.set(g,[m]):x.includes(m)||x.push(m)},noteChange(m){o!==null&&m!==null&&s.add(m)},bareLayoutEdit:()=>u()!==null&&o===null&&e.recordsBareEdits(),open:c,settle:f,emitReflow:d,abandon:p,runEdit(m,g){let{ops:b,owned:x}=h(m);if(!x)return g(b),!0;try{return g(b),d(),!0}catch(w){if(!(w instanceof Qa))throw w;return!1}finally{p()}}}}function J3(){let e=Me(),t=0,n=0,r=!1;return{notify(){if(t++,n>0){r=!0;return}e.emit()},version:()=>t,subscribe:e.subscribe,deferred(o,i){n++;try{return o()}finally{n--,i?.(),n===0&&r&&(r=!1,e.emit())}},muted(o){let i=r;n++;try{return o()}finally{n--,r=i}}}}function Q3(e,t){return{subscribe:e.subscribe,getVersion:e.version,getContentVersion:()=>e.version()-t.changes()}}function Z3(e){let t=new Map;return{seeOff(n,r,o,i){let s=new Map;for(let u of r){let c=s.get(u.parent);c?c.push(u):s.set(u.parent,[u])}let a=u=>{let c=e(u.id);if(!c)return null;let d=(s.get(u.id)??[]).map(a).filter(f=>f!==null);return{node:c.node,pose:c.pose,children:d}},l=n.map(u=>[u,a(u)]);return()=>{let u=new Set;for(let c of r){let d=i.get(c.id);d&&d.from===void 0&&u.add(c.id),i.delete(c.id)}for(let[c,d]of l)d&&!u.has(c.id)&&t.set(c.id,{id:c.id,parent:c.parent,...d,...o})}},takeBack(n){let r=t.get(n);return t.delete(n),r?.pose},drain(){if(t.size===0)return[];let n=[];for(let r of t.values()){let o=r.parent!==null?t.get(r.parent):void 0;o?o.children.push(r):n.push(r)}return t.clear(),n}}}var HX=()=>{};function eH(e){let t=Me(),n=new Map,r=Z3(e.shown),o=null,i="call",s=0,a=0,l=0,u=0,c=()=>u>0&&l===0;function d(x){return s>0?{origin:x?"undo":"redo"}:a>0?{origin:"layout"}:e.untracked()?{origin:"untracked"}:o!==null?{origin:i,label:o}:{origin:"call"}}function f(x,w,y,P){if(!c())return;let S=n.get(x);S?S.to=y:n.set(x,{id:x,from:w,to:y,...d(P)})}function p(x,w){if(c())for(let y of x)n.set(y.id,{id:y.id,from:r.takeBack(y.id),to:y.pose,...d(w)})}let h=(x,w,y)=>c()?r.seeOff(x,w,d(y),n):HX;function m(x,w,y){w();try{return x()}finally{y()}}let g={"kit:setPose":x=>({...x,apply:w=>{x.apply(w);let y=w;f(y.id,y.from,y.to,!1)},revert:w=>{x.revert(w);let y=w;f(y.id,y.to,y.from,!0)}}),"kit:add":x=>({...x,apply:w=>{x.apply(w),c()&&p([w],!1)},revert:w=>{let y=h([w],[w],!0);x.revert(w),y()}}),"kit:remove":x=>({...x,apply:w=>{let y=w,P=h(y.detached,y.nodes,!1);x.apply(w),P()},revert:w=>{x.revert(w),p(w.nodes,!0)}})};function b(){let x=r.drain();if(n.size===0&&x.length===0)return;let w=[...n.values()].filter(y=>!Zr(y.from,y.to));n.clear(),(w.length>0||x.length>0)&&t.emit(w,x)}return e.changes.subscribe(b),{subscribe(x){let w=t.subscribe(x);u++;let y=!0;return()=>{y&&(y=!1,u--,w())}},labeled(x,w,y){if(o!==null)return y();o=x,i=w;try{return y()}finally{o=null}},replaying:x=>m(x,()=>{s++},()=>{s--}),layout:x=>m(x,()=>{a++},()=>{a--}),quiet:x=>m(x,()=>{l++},()=>{l--}),reporting:x=>(w,y)=>x(w,g[w]?.(y)??y)}}function tH(){let e={batch:0,engine:0,untracked:0,own:0},t=0;return{open:()=>t>0,records:()=>e.engine+e.untracked===0,untracked:()=>e.untracked>0,during(n,r){e[n]++,t++;try{return r()}finally{e[n]--,t--}}}}var nH="kit:setDoc";function N1(e,t,n){n===void 0?e.delete(t):e.set(t,n)}function rH(e){return{toJSON(){return e.size===0?void 0:Object.fromEntries(e)},reset(t){e.clear();for(let[n,r]of Object.entries(t??{}))N1(e,n,r)}}}function oH(e){let{values:t}=e;return e.register(nH,{apply:n=>{let{key:r,to:o}=n;N1(t,r,o)},revert:n=>{let{key:r,from:o}=n;N1(t,r,o)}}),{get:n=>t.get(n),set(n,r){let o=t.get(n);Zr(o,r)||e.record(nH,{key:n,from:o,to:r},"setDoc")},keys:()=>[...t.keys()]}}function ly(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,r)=>ly(n,t[r]));if(Zt(e)&&Zt(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(r=>r in t&&ly(e[r],t[r]))}return!1}function iH(e,t,n){n===void 0?delete e[t]:e[t]=n}var sH={units:"kit:setUnits",clip:"kit:setClip"};function aH(e){for(let n of["units","clip"])e.register(sH[n],{apply:r=>{let{id:o,to:i}=r;iH(e.requireNode(o),n,i)},revert:r=>{let{id:o,from:i}=r;iH(e.requireNode(o),n,i)}});let t=(n,r,o)=>(i,s)=>{let a=e.requireNode(i)[n];e.refuse(i,o),!ly(a,s??void 0)&&e.record(sH[n],{id:i,from:a,to:s??void 0},r)};return{setUnits:t("units","setUnits","set the units of"),setClip:t("clip","setClip","set the clip of")}}function lH(e,t,n){let r=N3({data:e}),o=r?.foundHidden;if(!r||!o||o.length===0)return null;let i=Array.isArray(t)?t:[],s=new Set(o.map(u=>i[u])),a=(Array.isArray(n)?n:[]).flatMap((u,c)=>s.has(u)?[c]:[]);if(a.length===o.length&&a.every((u,c)=>u===o[c]))return null;let l={...r,foundHidden:a};return a.length===0&&delete l.foundHidden,{...e,pathEffect:l}}function uH(e){return{bounds:e?.bounds??(t=>{let n=S1(t);return n===null?null:{x:n.x,y:n.y,width:n.width,height:n.height}}),remap:e?.remap??((t,n,r)=>({...t,...r}))}}function I1(e,t,n,r){let o=e.bounds(n,t),i=e.bounds(r,t);return o===null||i===null?o!==i:o.width!==i.width||o.height!==i.height}var GX=16;function cH(e,t,n,r,o,i=new Map){let s=new Map,a=w=>s.get(w)??Lr(e,e.get(w)),l={getPose:w=>a(w),getParent:w=>e.get(w)?.parent??null,definesFrame:w=>{let y=e.get(w);return y===void 0||lt(y)}},{compose:u,decompose:c}=e.composition,d=w=>zt(l,w,u),f=[...new Set([...n.keys(),...r])],p=new Map,h=(w,y)=>{let P=a(w);No(P,y)||(s.set(w,y),w!==m&&t(w)!==null&&I1(o,w,P,y)&&f.push(w))},m=null,g=w=>{let y=R3(d(w),e.composition,S=>o.bounds(S,w),(S,v,A)=>o.remap(S,v,A,w));if(y===null)return null;let P=e.childrenOf(w).map(S=>({id:S,pose:y.toStrategy(d(S))}));return{...y,container:{id:w,bounds:y.bounds},children:P}},b=(w,y,P)=>{if(P.bounds){let S=e.get(w),v=y.toWorld(o.remap(y.upright,y.container.bounds,P.bounds,w));h(w,la(l,v,S.parent,u,c))}for(let[S,v]of P.poses){let A=S;if(e.get(A)?.parent!==w)continue;let N=o.bounds(d(A),A);h(A,la(l,y.toWorld(v),w,u,c)),x(A,N)}},x=(w,y)=>{let P=o.bounds(d(w),w);if(y===null||P===null)return;let S=P.x-y.x,v=P.y-y.y;if(S===0&&v===0)return;let A=N2({childrenOf:N=>e.childrenOf(N),poses:l,composition:e.composition},w,(N,M)=>{let C=o.bounds(N,M);return C===null?null:o.remap(N,C,{...C,x:C.x+S,y:C.y+v},M)});for(let[N,M]of A)h(N,M)};for(;f.length>0;){let w=f.shift();m=w;let y=(p.get(w)??0)+1;if(p.set(w,y),y>GX)continue;let P=t(w);if(P===null||e.get(w)===void 0)continue;let S=y===1?n.get(w):void 0,v=y===1?i.get(w):void 0,A=!1;if(v!==void 0&&P.depart){let N=g(w);if(N===null)continue;let M=new Set(S??[]),C=N.children.filter(F=>!M.has(F.id));b(w,N,P.depart(N.container,C,new Set(v))),A=!0}if(S!==void 0&&P.arrive){let N=g(w);if(N===null)continue;let M=P.arrive(N.container,N.children,new Set(S));if(M===null)return null;b(w,N,M)}else if(!A||S!==void 0){let N=g(w);if(N===null)continue;b(w,N,{poses:P.childPoses(N.container,N.children)})}}return s}function dH(e){let{layoutFrame:t,layoutField:n,layoutRefs:r}=e,{requireNode:o,descendants:i}=e.store,{refuse:s,refuseLayer:a}=e.locks,{requireLayerIndex:l,assertSubtreeLayer:u}=e.layers,{record:c,edit:d,batch:f}=e.recorder,{noteChange:p,layoutDeclared:h}=e.arrivals;return{update(m,g){let b=o(m);s(m,"update"),c("kit:setData",{id:m,from:b.data,to:g.data},"update")},setPose(m,g){let b=o(m);s(m,"set the pose of");let x=b.layout!==void 0&&I1(t,m,b.pose,g),w=b.parent===null?void 0:o(b.parent),y=w?.layout!==void 0?w.id:null;d("setPose",x||y!==null,()=>{x&&p(m),p(y),c("kit:setPose",{id:m,from:b.pose,to:g},"setPose")})},setLayer(m,g){l(g);let b=o(m);if(s(m,"relayer"),b.layer!==g&&a(g,"move nodes onto"),b.parent!==null){let w=o(b.parent);u(m,g,b.parent,w.layer,"relayer")}if(b.layer===g)return;let x=[m];i(m,x);for(let w of x)s(w,"relayer");x.length===1?c("kit:setLayer",{id:m,from:b.layer,to:g},"setLayer"):f("setLayer",()=>{for(let w of x){let y=o(w);y.layer!==g&&c("kit:setLayer",{id:w,from:y.layer,to:g},"setLayer")}})},setDependsOn(m,g){let b=o(m);if(s(m,"retarget"),f2(b.dependsOn,g))return;let x=lH(b.data,b.dependsOn,g);if(x===null)return void c("kit:setDependsOn",{id:m,from:b.dependsOn,to:g},"setDependsOn");f("setDependsOn",()=>{c("kit:setDependsOn",{id:m,from:b.dependsOn,to:g},"setDependsOn"),c("kit:setData",{id:m,from:b.data,to:x},"setDependsOn")})},setLayout(m,g){let b=o(m);s(m,"set the layout of");let x;if(typeof g=="string"){if(x=n.fnOf(g)??null,x===null)throw new Error(`Scene: no layout "${g}" in this scene's registry`)}else x=g;let w=b.layout??null;if(w===x)return;x!==null&&h();let y=w===null?void 0:n.keyOf(w),P=x===null?void 0:n.keyOf(x),S={id:m,...y!==void 0?{fromKey:y}:{},...P!==void 0?{toKey:P}:{}};r.set(S,{from:w,to:x}),d("setLayout",!0,()=>{p(m),c("kit:setLayout",S,"setLayout")})}}}function fH(e,t){t===void 0?delete e.parallax:e.parallax=t}function pH(e){let{state:t,requireLayerIndex:n,rebuildLayerIndex:r}=e;function o(s,a){e.register(s,a)}o("kit:setLayerVisible",{apply:s=>{t.layers[n(s.layer)].visible=s.to,s.to||e.narrowSelection()},revert:s=>{t.layers[n(s.layer)].visible=s.from}}),o("kit:setLayerLocked",{apply:s=>{t.layers[n(s.layer)].locked=s.to,s.to&&e.narrowSelection()},revert:s=>{t.layers[n(s.layer)].locked=s.from}}),o("kit:setLayerParallax",{apply:s=>{fH(t.layers[n(s.layer)],s.to)},revert:s=>{fH(t.layers[n(s.layer)],s.from)}}),o("kit:addLayer",{apply:s=>{t.layers.splice(s.index,0,{...s.record}),r()},revert:s=>{t.layers.splice(s.index,1),r()}}),o("kit:removeLayer",{apply:s=>{t.layers.splice(s.index,1),r()},revert:s=>{t.layers.splice(s.index,0,{...s.record}),r()}}),o("kit:renameLayer",{apply:s=>{t.layers[n(s.layer)].name=s.to},revert:s=>{t.layers[n(s.layer)].name=s.from}});function i(s,a){let[l]=t.layers.splice(n(s),1);t.layers.splice(a,0,l),r()}o("kit:moveLayer",{apply:s=>i(s.layer,s.to),revert:s=>i(s.layer,s.from)})}function UX(e){let{detach:t,attach:n,invalidateChildDerivedFrom:r,invalidateDependents:o}=e.store;return(i,s,a,l)=>{t(i),n(i,a,l),r(s),o(i),s!==a&&e.narrowSelection()}}function hH(e){let{state:t,requireLayerIndex:n,invalidateOrder:r,fnFields:o}=e,{dependents:i,childDerived:s,invalidateDependents:a,invalidateChildDerivedFrom:l,trackChildDerived:u,retarget:c,requireNode:d,detach:f,attach:p,addedFns:h,restoreNodeFunctions:m}=e.store;function g(y,P){e.register(y,P)}let b=UX(e);g("kit:add",{apply:y=>{if(t.nodes.has(y.id))throw new Error(`Scene: id collision on "${y.id}"`);let P={kind:y.kind,id:y.id,layer:y.layer,pose:y.pose,data:y.data,parent:y.parent};t.nodes.set(y.id,P),p(y.id,y.parent,y.index),y.dependsOn!==void 0&&(P.dependsOn=y.dependsOn),Object.assign(P,ar(y)),e.noteWritten(P),i.add(y.id,y.dependsOn==="children"?[]:y.dependsOn??[]),u(y.id,y.dependsOn);let S=P,v=h.get(y);for(let A of o){let N=v?.get(A);if(N!==void 0){A.write(S,N);continue}let M=y[A.spec.opKey];M!==void 0&&Gc(A,S,M,"kit:add",It)}a(y.id)},revert:y=>{e.clearOverride(y.id),f(y.id),t.nodes.delete(y.id),i.remove(y.id),s.delete(y.id),l(y.parent),a(y.id)}}),g("kit:remove",{apply:y=>{for(let P of y.nodes)e.clearOverride(P.id);for(let P of y.detached)f(P.id);for(let P of y.nodes)t.nodes.delete(P.id),i.remove(P.id),s.delete(P.id);for(let P of y.detached)l(P.parent);e.narrowSelection(new Set(y.nodes.map(P=>P.id)))},revert:y=>{let P=new Map((y.fnKeys??[]).map(S=>[S.id,S]));for(let S of y.nodes){let v=S.children?{...S,children:[...S.children]}:{...S};m(v,P.get(S.id)),t.nodes.set(S.id,v),e.noteWritten(v),i.add(S.id,v.dependsOn==="children"?[]:v.dependsOn??[]),u(S.id,v.dependsOn)}for(let S of y.detached)p(S.id,S.parent,S.index);for(let S of y.detached)l(S.parent)}}),g("kit:setPose",{apply:y=>{d(y.id).pose=y.to,a(y.id)},revert:y=>{d(y.id).pose=y.from,a(y.id)}}),g("kit:setData",{apply:y=>{d(y.id).data=y.to,a(y.id)},revert:y=>{d(y.id).data=y.from,a(y.id)}}),g("kit:setLayer",{apply:y=>{n(y.to),d(y.id).layer=y.to,r(),a(y.id)},revert:y=>{d(y.id).layer=y.from,r(),a(y.id)}}),g("kit:setDependsOn",{apply:y=>{c(y.id,y.to)},revert:y=>{c(y.id,y.from)}});let x=new WeakMap;function w(y,P){let S=d(y.id),v=o.find(C=>C.spec.field==="layout"),A=x.get(y),N=P==="from"?y.fromKey:y.toKey;if(A===void 0&&N!==void 0){delete S.layout,Gc(v,S,N,"kit:setLayout",It);return}let M=A?.[P]??null;M===null?delete S.layout:v.write(S,M)}return g("kit:setLayout",{apply:y=>{w(y,"to")},revert:y=>{w(y,"from")}}),g("kit:move",{apply:y=>b(y.id,y.fromParent,y.toParent,y.toIndex),revert:y=>b(y.id,y.toParent,y.fromParent,y.fromIndex)}),pH(e),{layoutRefs:x}}function mH(e,t,n){n?e[t]=!0:delete e[t]}var yH={hidden:"kit:setHidden",locked:"kit:setLocked"};function gH(e){for(let n of["hidden","locked"])e.register(yH[n],{apply:r=>{let{id:o,to:i}=r,s=e.requireNode(o);mH(s,n,i),e.noteWritten(s),n==="hidden"&&e.invalidateDependents(o),i&&e.narrowSelection()},revert:r=>{let{id:o,from:i}=r,s=e.requireNode(o);mH(s,n,i),e.noteWritten(s),n==="hidden"&&e.invalidateDependents(o)}});let t=(n,r)=>(o,i)=>{let s=e.requireNode(o)[n]===!0;s!==i&&e.record(yH[n],{id:o,from:s,to:i},r)};return{setHidden:t("hidden","setHidden"),setLocked:t("locked","setLocked")}}function bH(e,t){function n(s){e.layers.length=0,e.layerIndex.clear(),t();for(let a of s){if(e.layerIndex.has(a.id))throw new Error(`Scene: duplicate ${a.kind} layer id "${a.id}"`);e.layerIndex.set(a.id,e.layers.length),e.layers.push(a)}}function r(s){let a=e.layerIndex.get(s);if(a===void 0)throw new Error(`Scene: unknown layer "${s}"`);return a}function o(){t(),e.layerIndex.clear();for(let s=0;s<e.layers.length;s++)e.layerIndex.set(e.layers[s].id,s)}function i(s,a,l,u,c="place"){if(r(a)<r(u)){let d=c==="place"?`cannot place node '${s??"<new>"}' on layer '${a}' under parent '${l}' on layer '${u}'`:`cannot setLayer('${s??"<new>"}', '${a}') \u2014 node has parent '${l}' on layer '${u}'`;throw new Error(`Scene: ${d} \u2014 a child may not render below its parent's layer`)}}return{reset:n,requireLayerIndex:r,rebuildLayerIndex:o,assertSubtreeLayer:i}}function WX(e,t,n,r){let o=new Map;for(let i=0;i<t.length;i++)o.set(t[i].id,i);for(let i of e.values()){if(i.parent===null)continue;let s=e.get(i.parent);if(s&&o.get(i.layer)<o.get(s.layer))throw new Error(`Scene: moveLayer("${n}", ${r}) \u2014 a child may not render below its parent's layer`)}}function xH(e){let{layers:t,nodes:n,requireLayerIndex:r,record:o}=e;function i(s,a){let l=t[r(s)];if(l.kind!=="user")throw new Error(`Scene: cannot ${a} system layer "${s}"`);return l}return{setLayerVisible(s,a){let l=t[r(s)];o("kit:setLayerVisible",{layer:s,from:l.visible,to:a},"setLayerVisible")},setLayerLocked(s,a){let l=t[r(s)];o("kit:setLayerLocked",{layer:s,from:l.locked,to:a},"setLayerLocked")},setLayerParallax(s,a){let l=t[r(s)];o("kit:setLayerParallax",{layer:s,from:l.parallax,to:a},"setLayerParallax")},addLayer(s){if(e.layerIndex.has(s.id))throw new Error(`Scene: duplicate layer id "${s.id}"`);let a=Math.max(0,Math.min(s.index??t.length,t.length)),l={kind:"user",id:s.id,name:s.name,visible:s.visible??!0,locked:s.locked??!1,...s.parallax?{parallax:s.parallax}:{},...s.annotation?{annotation:!0}:{}};o("kit:addLayer",{record:l,index:a},"addLayer")},removeLayer(s){let a=i(s,"remove");e.lifted(()=>e.batch("removeLayer",()=>{let l=[];for(let[u,c]of n)c.layer===s&&l.push(u);e.removeMany(l),o("kit:removeLayer",{record:a,index:r(s)},"removeLayer")}))},renameLayer(s,a){let l=i(s,"rename");o("kit:renameLayer",{layer:s,from:l.name,to:a},"renameLayer")},moveLayer(s,a){let l=r(s),u=Math.max(0,Math.min(a,t.length-1));if(l===u)return;let c=[...t],[d]=c.splice(l,1);c.splice(u,0,d),WX(n,c,s,a),o("kit:moveLayer",{layer:s,from:l,to:u},"moveLayer")}}}var Za=class extends Error{};function wH(e){let t=0,n=new WeakMap,r=a=>a===null||e.has(a),o=(a,l)=>{let u=e.get(a);return u===void 0||!qt(u)||u.children.every(c=>l?.has(c)===!0)};function i(a,l,u){switch(a){case"kit:add":{let c=l;return u?e.has(c.id)||!r(c.parent):!e.has(c.id)||!o(c.id)}case"kit:remove":{let c=l;if(!u)return c.nodes.some(f=>e.has(f.id))||!c.detached.every(f=>r(f.parent));let d=new Set(c.nodes.map(f=>f.id));return!c.nodes.every(f=>e.has(f.id)&&o(f.id,d))}case"kit:move":{let c=l;return!e.has(c.id)||!r(u?c.toParent:c.fromParent)}case"kit:setPose":case"kit:setData":case"kit:setLayer":case"kit:setDependsOn":case"kit:setLayout":case"kit:setUnits":case"kit:setClip":return!e.has(l.id);default:return!1}}function s(a,l,u){return t===0||typeof l!="object"||l===null?!1:n.get(l)===!u?n.delete(l):i(a,l,u)?(n.set(l,u),!0):!1}return{during(a){t++;try{return a()}finally{t--}},skips:s}}function VX(e,t,n,r){let o=e.map(a=>{let l=n.requireNode(a);return l.children?{...l,children:[...l.children]}:{...l}}),i=o.filter(a=>a.parent===null||!t.has(a.parent)).map(a=>({id:a.id,parent:a.parent,index:n.siblingsOf(a.parent).indexOf(a.id)})).sort((a,l)=>a.index-l.index),s=o.flatMap(a=>{let l=Ji(r,a,"opKey");return Object.keys(l).length===0?[]:[{id:a.id,...l}]});return{nodes:o,detached:i,...s.length>0?{fnKeys:s}:{}}}function PH(e){let{nodes:t,fnFields:n}=e,{requireNode:r,siblingsOf:o,descendants:i,removalClosure:s,patchNodeFunctions:a}=e.store,{refuse:l,refuseLayer:u}=e.locks,{requireLayerIndex:c,assertSubtreeLayer:d}=e.layers,{record:f,edit:p}=e.recorder,{noteArrival:h,noteDeparture:m,noteChange:g}=e.arrivals;function b(w){let y=w.id??e.generateId();if(t.has(y))throw new Za(`Scene: id collision on "${y}"`);c(w.layer),u(w.layer,"add to");let P=w.parent??null;if(P!==null){let v=r(P);d(w.id,w.layer,P,v.layer),l(P,"add under")}let S={id:y,kind:w.kind,layer:w.layer,pose:w.pose,data:w.data,parent:P,index:w.index??o(P).length};return w.dependsOn!==void 0&&(S.dependsOn=w.dependsOn),Object.assign(S,ar(w),Ji(n,w,"opKey"))}function x(w){if(w.length===0)return;let{ids:y,removing:P}=s(w);for(let A of y)l(A,"remove");let S=VX(y,P,e.store,n),{detached:v}=S;p("remove",v.some(A=>A.parent!==null),()=>{for(let A of v)m(A.id,A.parent,null);f("kit:remove",S,"remove")})}return{construct(w){e.locks.lifted(()=>{for(let y of w){let P=b(y);e.runOp("kit:add",P),a(y,P.id,null)}})},add(w){let y=b(w),P=`add ${w.kind}`;return p(P,y.parent!==null,()=>(h(y.id,y.parent,null),f("kit:add",y,P),a(w,y.id,y),y.id))},remove:w=>x([w]),removalClosure:w=>s(w).ids,removeMany:x,move(w,y,P){let S=r(w);if(l(w,"move"),y!==null){l(y,"move nodes into");let A=r(y);if(d(w,S.layer,y,A.layer),y===w)throw new Error("Scene: cannot parent a node to itself");let N=[];if(i(w,N),N.includes(y))throw new Error("Scene: cannot parent a node to its own descendant")}let v=S.parent;p("move",y!==null||v!==null,()=>{let A=o(v).indexOf(w),N=P??o(y).length;h(w,y,v),m(w,v,y),g(v),f("kit:move",{id:w,fromParent:v,fromIndex:A,toParent:y,toIndex:N},"move")})},reorder(w,y){let P=r(w);l(w,"reorder");let S=P.parent;p("reorder",S!==null,()=>{g(S);let v=o(S).indexOf(w);f("kit:move",{id:w,fromParent:S,fromIndex:v,toParent:S,toIndex:y},"reorder")})}}}function TH(e){let{state:t,store:n,locks:r,layers:o,fnFields:i,recorder:s,arrivals:a}=e,{layoutRefs:l}=hH({state:t,register:e.ops.register,store:n,requireLayerIndex:o.requireLayerIndex,rebuildLayerIndex:o.rebuildLayerIndex,invalidateOrder:e.invalidateOrder,fnFields:i,narrowSelection:e.narrowSelection,clearOverride:e.clearOverride,noteWritten:r.noteWritten}),{construct:u,...c}=PH({nodes:t.nodes,generateId:e.generateId,store:n,locks:r,layers:o,fnFields:i,runOp:e.ops.run,recorder:s,arrivals:a}),d=dH({store:n,locks:r,layers:o,recorder:s,arrivals:a,layoutFrame:e.layoutFrame,layoutField:i.find(g=>g.spec.field==="layout"),layoutRefs:l}),f=xH({layers:t.layers,layerIndex:t.layerIndex,nodes:t.nodes,requireLayerIndex:o.requireLayerIndex,record:s.record,lifted:r.lifted,batch:s.batch,removeMany:c.removeMany}),p=gH({register:e.ops.register,requireNode:n.requireNode,record:s.record,narrowSelection:()=>e.narrowSelection(),invalidateDependents:n.invalidateDependents,noteWritten:r.noteWritten}),h=aH({register:e.ops.register,requireNode:n.requireNode,refuse:r.refuse,record:s.record}),m=oH({values:t.docValues,register:e.ops.register,record:s.record});return{construct:u,methods:{...c,...d,...f,...p,...h,doc:m}}}var zX={log:e=>ih("history",e),warn:e=>It("history",e)};function SH(e,t={}){let n=t.rebuildOp;return Uc(e,{debug:zX,...t,rebuildOp:(r,o)=>n?.(r,o)??iy(r,o)})}function kH(e){let t=null;return{atomically(n,r){let o=t,i=[],s=e.getSelection();t=i;try{let a=n();return o&&!r()&&o.push(...i),a}catch(a){throw t=null,e.lifted(()=>{for(let l=i.length-1;l>=0;l--){let{kind:u,payload:c,reverted:d}=i[l],f=e.registered.get(u);(d?f.apply:f.revert)(c)}}),e.setSelection(s),i.length>0&&e.notify(),a}finally{t=o}},logApplied(n,r,o){t?.push(o===void 0?{kind:n,payload:r}:{kind:n,payload:r,reverted:o})}}}var KX=()=>({added:new Set,removed:new Set,posed:new Set,reparented:new Set,dataChanged:new Set,docChanged:new Set}),jX=e=>({added:new Set(e.added),removed:new Set(e.removed),posed:new Set(e.posed),reparented:new Set(e.reparented),dataChanged:new Set(e.dataChanged),docChanged:new Set(e.docChanged)}),vH={name:"editPass",args:{},elideNoop:!0,apply:()=>"noop",invert:()=>vH};function $X(e,t,n){let r=n;switch(t){case"kit:add":e.added.add(r.id);break;case"kit:remove":for(let o of r.nodes??[])e.removed.add(o.id);break;case"kit:setPose":e.posed.add(r.id);break;case"kit:setData":e.dataChanged.add(r.id);break;case"kit:setDoc":e.docChanged.add(r.key);break;case"kit:move":r.fromParent!==r.toParent&&e.reparented.add(r.id);break;default:break}}function AH(e){let t=[],n=null;function r(){let o=n;if(o===null)return 0;let i=0;try{for(let{pass:s}of[...t]){let a=s(jX(o));if(a===null)continue;let l=e.adapter();for(let u of a)u.apply(l),i++}}finally{n=null}return i}return{add(o,i){let s={pass:o,order:i?.order??0},a=t.findIndex(l=>l.order>s.order);return t.splice(a<0?t.length:a,0,s),()=>{let l=t.indexOf(s);l>=0&&t.splice(l,1)}},any:()=>t.length>0,open(){return n!==null||t.length===0?!1:(n=KX(),!0)},note(o,i){n!==null&&!e.untracked()&&$X(n,o,i)},run:r,abandon(){n=null},op(){return{name:"editPass",args:{},label:"Edit pass",elideNoop:!0,apply:()=>r()>0?void 0:"noop",invert:()=>vH}}}}function YX(e,t,n){let{replay:r,notify:o}=t,i={targetId:e.targetId,forkedAtEntryId:e.forkedAtEntryId,applyBatch(s,a){t.labeled(a,()=>t.runArrivalEdit(s,l=>{t.applying(()=>e.applyBatch(l.map(t.causing),a)),o()}))},undo(){r(()=>e.undo()),o()},redo(){r(()=>e.redo()),o()},canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),entries:()=>e.entries(),seal:()=>e.seal(),observe:s=>e.observe(s),beginJournal:s=>n.wrap(e.beginJournal(s)),getVersion:()=>e.getVersion(),subscribe:s=>e.subscribe(s),commit(s){e.commit(s),n.close(i),o()},cancel(){r(()=>e.cancel()),n.close(i),o()},suspend:()=>e.suspend(),isActive:()=>e.isActive()};return i}function RH(e){let t=new WeakMap,n=[],r={wrap(o){let i=YX(o,e,r);return t.set(i,o),n.push(i),i},close(o){let i=n.indexOf(o);i>=0&&n.splice(i,1)}};return{begin(o){let i=e.activeJournal();return r.wrap(i?(t.get(i)??i).beginJournal(o):e.engine.beginJournal(o))},resume:o=>e.engine.resumeJournal(t.get(o)??o),innermost(){for(let o=n.length-1;o>=0;o--)if(n[o].isActive())return n[o];return null}}}function IH(e){let{engine:t,replay:n,notify:r,refuseUntracked:o,runArrivalEdit:i}=e,s=RH(e);function a(d,f){return d()?(n(f),r(),!0):!1}let l=()=>e.activeJournal()??t,u={undo(){let d=e.activeJournal();return d?d.canUndo()?(d.undo(),!0):!1:a(()=>t.canUndo(),()=>t.undo())},redo(){let d=e.activeJournal();return d?d.canRedo()?(d.redo(),!0):!1:a(()=>t.canRedo(),()=>t.redo())},canUndo:()=>l().canUndo(),canRedo:()=>l().canRedo(),historyEntries(){let{undo:d,redo:f}=t.entries();return[...d,...f].map(p=>({id:String(p.id),label:p.label}))},historyIndex:()=>t.undoDepth(),jumpToHistoryIndex(d){let f=t.undoDepth()+t.redoDepth(),p=Math.max(0,Math.min(f,d));return a(()=>p!==t.undoDepth(),()=>t.goto(p))},serializeHistory:()=>({...t.serialize(),form:4}),restoreHistory(d){if(d.form!==4){It("scene","restoreHistory: snapshot is not in the current recorded form \u2014 dropped");return}t.restore(d),r()}};return{history:{apply(d,f){o("history.apply"),e.labeled(f??d.label??"",()=>i([d],p=>{let h=()=>p.length===1?t.apply(e.causing(d),f):t.applyOps(p.map(e.causing),f??d.label??"");e.applying(h),r()}))},applyOps(d,f){o("history.applyOps"),e.labeled(f,()=>i(d,p=>{e.applying(()=>t.applyOps(p.map(e.causing),f)),r()}))},undo:()=>{u.undo()},redo:()=>{u.redo()},goto:d=>{u.jumpToHistoryIndex(d)},clear(){t.clear(),r()},recordEntry(d,f,p){t.recordEntry(d,f,p),r()},prune(d){t.prune(d),r()},switchBranch(d){t.switchBranch(d),r()},restore:u.restoreHistory,canUndo:u.canUndo,canRedo:u.canRedo,undoDepth:()=>t.undoDepth(),redoDepth:()=>t.redoDepth(),entries:()=>t.entries(),timestampAt:d=>t.timestampAt(d),depthAt:d=>t.depthAt(d),branches:()=>t.branches(),getVersion:()=>t.getVersion(),subscribe:d=>t.subscribe(d),observe:d=>t.observe(d),serialize:u.serializeHistory,allForwardOps:()=>t.allForwardOps(),seal:()=>t.seal(),currentEntryId:()=>t.currentEntryId(),beginJournal:s.begin,resumeJournal:s.resume,activeJournal:()=>e.activeJournal()},methods:u,openJournal:s.innermost}}function EH(e){let t=new Map;function n(s){let a=t.get(s);if(!a)throw new Error(`Scene: no registered op for kind "${s}"`);return a}function r(s,a){let l;if(s.startsWith("kit:")){if(a===null||typeof a!="object")return;let u=a;l=typeof u.id=="string"?u.id:typeof u.layer=="string"?u.layer:void 0}else l=t.get(s)?.coalesceKey?.(a);return l===void 0?void 0:`${s}:${l}`}function o(s,a,l){let u=n(s);if(e.skips(s,a,l))return"noop";(l?u.apply:u.revert)(a),e.applied(s,a,!l)}function i(s,a,l=!0){return n(s),{name:s,args:a,coalesceKey:r(s,a),apply:()=>{if(e.driven())return o(s,a,l);let u;return e.replayAlone(()=>{u=o(s,a,l)}),u},invert:()=>i(s,a,!l)}}return{handlers:t,register:(s,a)=>{t.set(s,a)},run:(s,a)=>n(s).apply(a),op:(s,a)=>i(s,a)}}function Wc(e,t){return{name:e.name,args:e.args,label:e.label,get coalesceKey(){return e.coalesceKey},elideNoop:e.elideNoop,apply:()=>e.apply(t),invert:()=>Wc(e.invert(),t)}}function E1(e,t){return{name:e.name,args:e.args,label:e.label,get coalesceKey(){return e.coalesceKey},elideNoop:e.elideNoop,apply:()=>{let n=t();if(!n)return It("scene",`restored op "${e.name??"?"}" has no history adapter \u2014 skipping (setHistoryAdapter was not wired)`),"noop";try{return e.apply(n())}catch(r){return It("scene",`restored op "${e.name??"?"}" failed against the history adapter \u2014 skipping: ${String(r)}`),"noop"}},invert:()=>E1(e.invert(),t)}}function qX(e,t){let n=t===void 0||e.coalesceKey===void 0?void 0:`${t}>${e.coalesceKey}`;return{name:e.name,args:e.args,coalesceKey:n,apply:e.apply,invert:e.invert}}function MH(e){let t=null,n=e.getActiveJournal;function r(o,i=o){if(o.caused)return o;let s=[i];return{get name(){return o.name},get args(){return o.args},label:o.label,get coalesceKey(){return o.coalesceKey},elideNoop:o.elideNoop,apply(a){let{result:l,ops:u}=e.recorder().capturing(()=>i.apply(a));return u.length>0&&(s=u.map(c=>qX(c,o.coalesceKey))),l},caused:()=>s,invert:()=>i.invert()}}return{rebuild(o,i){let s=e.own(o,i);if(s!==null)return s;let a=iy(o,i);return a===null?null:E1(a,()=>t)},causing:o=>r(o),apply(o,i,s,a){if(e.recorder().joins())return e.recorder().join(i,a);let l=e.openJournal()??n?.()??null;e.driving(()=>{let u=i.map(c=>r(c,Wc(c,a)));l?l.applyBatch(u,s):o.applyOps(u,s)})},setHistoryAdapter(o){t=o},setActiveJournalAccessor(o){n=o},activeJournal:()=>e.openJournal()??n?.()??null}}function CH(e){for(let t=e.length-1;t>=0;t--)try{e[t].invert().apply(void 0)}catch{}}function OH(e){let{notifier:t,mode:n,engine:r,log:o,arrivals:i,passes:s}=e,a=null,l=null;function u(f,p,h=!1){let m=f();if(p)for(let g of i.settle())e.writePose(g.id,g.to);return h&&s.run(),m}function c(f,p,h={}){let m=!n.open();m&&(a={label:f,ops:[],outer:[],entry:{selectionBefore:e.selection(),...h}});let g=m&&i.open(!0),b=m&&s.open();return e.labeled(f,"call",()=>t.deferred(()=>n.during("batch",()=>{if(!m)return p();try{let x=o.atomically(()=>u(p,g,b),()=>(a?.ops.length??0)>0);return g&&i.emitReflow(),x}catch(x){throw CH(a?.outer??[]),a=null,x}}),()=>{if(g&&i.abandon(),b&&s.abandon(),!m||!a)return;let x=a;a=null,x.ops.length>0&&r.recordEntry(x.ops,x.label,x.entry)}))}function d(f,p,h){if(n.records()&&!a&&s.any())return void c(h,()=>d(f,p,h));s.note(f,p),e.labeled(h,"call",()=>{n.records()&&!a?n.during("own",()=>r.applyOps([e.makeOp(f,p)],h)):(e.runOp(f,p),o.logApplied(f,p),n.records()?a.ops.push(e.makeOp(f,p)):n.untracked()||l?.push(e.makeOp(f,p)))}),t.notify()}return{record:d,edit:(f,p,h)=>p&&i.bareLayoutEdit()?c(f,h):h(),batch:c,untracked(f){let p=t.version(),h=i.open(!0);return t.deferred(()=>n.during("untracked",()=>{let m=o.atomically(()=>u(f,h),()=>!1);return h&&i.emitReflow(),m}),()=>{h&&i.abandon(),t.version()!==p&&r.seal()})},joins:()=>n.records()&&a!==null,join(f,p){let h=a,m=h.ops.length,g=[];try{o.atomically(()=>{for(let b of f){let x=h.ops.length,w=b.apply(p);h.ops.length>x||w===!1||w==="noop"||(g.push(Wc(b,p)),h.ops.push(g[g.length-1]))}},()=>!1)}catch(b){throw CH(g),h.ops.length=m,b}h.outer.push(...g)},capturing(f){let p=l,h=[];l=h;try{return{result:f(),ops:h}}finally{l=p}},engineDriven:f=>n.during("engine",()=>t.muted(f))}}function FH(e){let{notifier:t,mode:n,stale:r,lifted:o,selection:i,arrivals:s,config:a,poseWrites:l}=e,{notify:u}=t,c=AH({adapter:e.passAdapter,untracked:n.untracked}),d=(M,C)=>s.runEdit(M,F=>{if(!c.open())return C(F);try{C([...F,c.op()])}finally{c.abandon()}}),f=EH({driven:n.open,replayAlone:M=>{P(M),u()},skips:r.skips,applied:(M,C,F)=>{n.records()||b(M,C,F)}}),p=MH({own:(M,C)=>f.handlers.has(M)?f.op(M,C):null,recorder:()=>x,driving:M=>t.deferred(()=>n.during("engine",()=>g(M,()=>!0))),getActiveJournal:a.getActiveJournal??null,openJournal:()=>N()}),h=SH(void 0,{selection:{get:i.get,set:M=>i.set(M)},...a.coalesceWindowMs!==void 0?{coalesceWindowMs:a.coalesceWindowMs}:{},...a.historyLimit!==void 0?{historyLimit:a.historyLimit}:{},rebuildOp:p.rebuild}),m=kH({registered:f.handlers,lifted:o,getSelection:i.get,setSelection:i.replace,notify:u}),{atomically:g,logApplied:b}=m,x=OH({notifier:t,mode:n,engine:h,runOp:f.run,makeOp:f.op,log:m,arrivals:s,passes:c,selection:i.get,writePose:e.writePose,labeled:l.labeled}),{record:w,engineDriven:y}=x;function P(M){l.replaying(()=>g(()=>o(()=>r.during(()=>y(M))),()=>!0))}function S(M){if(n.untracked())throw new Error(`Scene: cannot ${M} inside untracked() \u2014 it records`)}let{history:v,methods:A,openJournal:N}=IH({engine:h,applying:M=>g(()=>y(M),()=>!0),causing:p.causing,replay:P,notify:u,refuseUntracked:S,runArrivalEdit:d,labeled:(M,C)=>l.labeled(M,"ops",C),activeJournal:p.activeJournal});return{ops:f,recorder:x,clearHistory:()=>h.clear(),methods:{registerOp(M,C){if(M.startsWith("kit:"))throw new Error(`Scene: op kind "${M}" is reserved (kit:* prefix)`);f.register(M,C)},recordOp(M){w(M.kind,M.payload,M.kind)},applyBatch(M,C,F){return S("applyBatch"),l.labeled(C,"ops",()=>d(M,B=>p.apply(h,B,C,F)))},history:v,...A,batch:x.batch,untracked:x.untracked,setActiveJournalAccessor:p.setActiveJournalAccessor,setHistoryAdapter:p.setHistoryAdapter,addEditPass:c.add}}}function LH(e,t){let n=s=>Cc(e(s),t),r=[],o=0,i=Me();return{get:()=>r,legal:n,set(s){r=n(s),o++,i.emit()},narrow(s){let a=s!==void 0&&r.some(l=>s.has(l))?r.filter(l=>!s.has(l)):r;r=n(a)},replace(s){r=s},subscribe:i.subscribe,changes:()=>o}}function _H(e){let t=0,n=!1,r={get layers(){return e.layers},get:i=>e.nodes.get(i)},o=i=>(n||e.layers.some(s=>s.locked))&&DB(r,i);return{isLocked:o,isHidden:i=>_B(r,i),refuse(i,s){if(!(t>0||!o(i)))throw new Error(`Scene: cannot ${s} "${i}" \u2014 it is locked`)},refuseLayer(i,s){if(!(t>0||!e.layers[e.layerIndex.get(i)??-1]?.locked))throw new Error(`Scene: cannot ${s} layer "${i}" \u2014 it is locked`)},reachable(i){if(i.length===0)return i;let s=qa(r);return i.some(a=>s.locked(a)||s.hidden(a))?i.filter(a=>!s.locked(a)&&!s.hidden(a)):i},noteWritten(i){i.locked===!0&&(n=!0)},lifted(i){t++;try{return i()}finally{t--}}}}function DH(e,t,n){let r=d2(),o=new Set;function i(x){if(s(e.nodes.get(x)?.parent??null),r.isEmpty())return;let w=[x];p(x,w);for(let y of w)for(let P of r.transitiveDependentsOf(y)){let S=e.nodes.get(P);S!==void 0&&un(S)}}function s(x){if(o.size===0)return;let w=x;for(;w!==null;){let y=e.nodes.get(w);if(y===void 0)return;if(o.has(w)){un(y);for(let P of r.transitiveDependentsOf(w)){let S=e.nodes.get(P);S!==void 0&&un(S)}}w=y.parent}}function a(x,w){w==="children"?o.add(x):o.delete(x)}function l(x,w){let y=u(x);w===void 0?delete y.dependsOn:y.dependsOn=w,r.add(x,w===void 0||w==="children"?[]:w),a(x,w),un(u(x)),i(x)}function u(x){let w=e.nodes.get(x);if(!w)throw new Za(`Scene: unknown node id "${x}"`);return w}function c(x){if(x===null)return e.roots;let w=u(x);return w.children??=[]}function d(x){let w=u(x),y=c(w.parent),P=y.indexOf(x);if(P<0)throw new Error(`Scene: node "${x}" not found in its parent's children`);return y.splice(P,1),t(),{parent:w.parent,index:P}}function f(x,w,y){let P=c(w),S=Math.max(0,Math.min(y,P.length));P.splice(S,0,x);let v=u(x);v.parent=w,t()}function p(x,w){let y=e.nodes.get(x);if(y?.children)for(let P of y.children)w.push(P),p(P,w)}function h(x){let w=[],y=new Set;function P(S){if(y.has(S))return;y.add(S),w.push(S);let v=[];p(S,v);for(let A of v)y.has(A)||(y.add(A),w.push(A))}for(let S of x)P(S);for(let S=0;S<w.length;S++)for(let v of r.transitiveDependentsOf(w[S]))P(v);return{ids:w,removing:y}}let m=new WeakMap;function g(x,w,y){let P=e.nodes.get(w);if(P===void 0)return;let S=new Map;for(let v of n){let A=x[v.spec.field];A!==void 0&&(v.write(P,A),S.set(v,A))}y&&S.size>0&&m.set(y,S)}function b(x,w){if(!w)return;let y=x;for(let P of n){if(P.read(y)!==void 0)continue;let S=w[P.spec.opKey];S!==void 0&&Gc(P,y,S,"kit:remove",It)}}return{dependents:r,childDerived:o,invalidateDependents:i,invalidateChildDerivedFrom:s,trackChildDerived:a,retarget:l,requireNode:u,siblingsOf:c,detach:d,attach:f,descendants:p,removalClosure:h,addedFns:m,patchNodeFunctions:g,restoreNodeFunctions:b}}function BH(e){function t(){return e.layers.length===1?l():c()}function n(){return e.layers.length===1?u():d()}let r=0,o={gen:0};function i(){r++}let s=[];function a(){return o.gen!==r&&(o={gen:r}),o}function l(){let f=e.layers[0].id,p=[],h=[...e.roots].reverse();for(;h.length>0;){let m=h.pop(),g=e.nodes.get(m);if(g&&(g.layer===f&&p.push(m),qt(g)))for(let b=g.children.length-1;b>=0;b--)h.push(g.children[b])}return p}function u(){let f=e.layers[0].id,p=[],h=[...e.roots].reverse();for(;h.length>0;){let m=h.pop(),g=e.nodes.get(m);if(g&&(g.layer===f&&p.push(g),qt(g)))for(let b=g.children.length-1;b>=0;b--)h.push(g.children[b])}return p}function c(){let f=e.layers.map(()=>[]),p=[...e.roots].reverse();for(;p.length>0;){let m=p.pop(),g=e.nodes.get(m);if(!g)continue;let b=f[e.layerIndex.get(g.layer)??-1];if(b&&b.push(m),qt(g))for(let x=g.children.length-1;x>=0;x--)p.push(g.children[x])}let h=[];for(let m of f)for(let g of m)h.push(g);return h}function d(){let f=e.layers.map(()=>[]),p=[...e.roots].reverse();for(;p.length>0;){let m=p.pop(),g=e.nodes.get(m);if(!g)continue;let b=f[e.layerIndex.get(g.layer)??-1];if(b&&b.push(g),qt(g))for(let x=g.children.length-1;x>=0;x--)p.push(g.children[x])}let h=[];for(let m of f)for(let g of m)h.push(g);return h}return{ids(){let f=a();return f.ids??=t()},nodes(){let f=a();return f.nodes??=n()},nodesOnLayer(f){let p=a(),h=p.byLayer;if(!h){h=new Map;for(let m of p.nodes??=n()){let g=h.get(m.layer);g||h.set(m.layer,g=[]),g.push(m)}p.byLayer=h}return h.get(f)??s},invalidate:i}}function HH(e,t){let n=[],r=[...e].reverse();for(;r.length>0;){let o=t.get(r.pop());if(o&&(n.push(o),qt(o)))for(let i=o.children.length-1;i>=0;i--)r.push(o.children[i])}return n}function M1(e,t){let n=new Map;for(let o of e)o.id!==void 0&&n.set(o.id,o);let r=o=>{let i=new Set,s=o.parent==null?void 0:n.get(o.parent);for(;s!==void 0&&s.id!==void 0&&!i.has(s.id);){if(lt(s))return s;i.add(s.id),s=s.parent==null?void 0:n.get(s.parent)}return null};return e.map(o=>{let i=r(o);return i===null?o:{...o,pose:t.decompose(i.pose,o.pose)}})}function O1(e){let t={id:e.id,visible:e.visible??!0,locked:e.locked??!1,...e.parallax?{parallax:e.parallax}:{},...e.annotation?{annotation:!0}:{}};return e.kind==="user"?{...t,kind:"user",name:e.name??e.id}:{...t,kind:"system"}}function GH(e,t,n){let r=[];for(let i of HH(e.roots,e.nodes)){let s=i.id,a={id:s,kind:i.kind,layer:i.layer,pose:i.pose,data:i.data};i.parent!=null&&(a.parent=i.parent),i.dependsOn==="children"?a.dependsOn="children":i.dependsOn&&i.dependsOn.length>0&&(a.dependsOn=i.dependsOn),i.pickable===!1&&(a.pickable=!1),i.hidden===!0&&(a.hidden=!0),i.locked===!0&&(a.locked=!0),i.units!==void 0&&(a.units=i.units),i.clip!==void 0&&(a.clip=i.clip),i.consumesChildren===!0&&(a.consumesChildren=!0),Object.assign(a,Ji(t,i,"jsonKey",l=>{throw new Error(`Scene.toJSON: node '${s}' has ${l.spec.field} but no matching registry key. The function must be registered via createScene's registry option to round-trip.`)})),r.push(a)}return{version:3,systemLayers:e.layers.map(i=>{let s={id:i.id};return i.visible===!1&&(s.visible=!1),i.locked===!0&&(s.locked=!0),i.parallax&&(s.parallax=i.parallax),i.annotation&&(s.annotation=!0),i.kind==="user"&&(s.kind="user",s.name=i.name),s}),nodes:r,...n?{doc:n}:{}}}function uy(e,t,n={}){let r=XX(e,t,n);return e.version===3?r:M1(r,n.composition??sh)}function XX(e,t,n){let r;if(e.version===1)r=e.nodes.map(o=>({n:o,kind:C1(1,o,n.classifyV1)}));else if(e.version===2||e.version===3)r=e.nodes.map(o=>({n:o,kind:C1(2,o)}));else throw new Error(`Scene: unsupported version ${String(Reflect.get(e,"version"))}; versions 1, 2 and 3 are supported`);return r.map(({n:o,kind:i})=>{let s={id:o.id,kind:i,layer:o.layer,pose:o.pose,data:o.data};o.parent!==void 0&&(s.parent=o.parent),o.pickable!==void 0&&(s.pickable=o.pickable),o.hidden===!0&&(s.hidden=!0),o.locked===!0&&(s.locked=!0),o.units!==void 0&&(s.units=o.units),o.clip!==void 0&&(s.clip=o.clip),o.consumesChildren===!0&&(s.consumesChildren=!0),o.dependsOn!==void 0&&(s.dependsOn=o.dependsOn==="children"?"children":o.dependsOn);let a=o;for(let l of Xa){let u=a[l.jsonKey];if(u===void 0)continue;let c=t[l.field]?.[u];if(!c&&n.unknownKeys==="skip"){n.onSkip?.({id:s.id,field:l.field,key:u});continue}if(!c)throw new Error(`Scene: unknown ${l.field} key '${u}'. Register a function with this key in the registry option.`);s[l.field]=c}return JX(e.version,s)&&(s.clip="outline"),s})}function JX(e,t){return e===1&&t.kind==="group"&&t.clipFromPose===void 0}function C1(e,t,n){return e===2?t.kind:t.kind==="leaf"?"mark":n?n(t):"group"}function UH(e){let t=new WeakMap,n=1;return{get:r=>e.get(r),incarnation(r){let o=e.get(r);if(!o)return;let i=t.get(o);return i===void 0&&(i=n++,t.set(o,i)),i},childrenOf(r){return e.get(r)?.children??[]},ancestorsOf(r){let o=[],i=e.get(r)?.parent??null;for(;i!==null;)o.push(i),i=e.get(i)?.parent??null;return o}}}function WH(e,t,n,r){let o={nodes:new Map,roots:[],layers:[],layerIndex:new Map,docValues:new Map},i=BH(o),s=ny(e,f=>{f==="layout"&&n()}),a=DH(o,i.invalidate,s),l=bH(o,i.invalidate);l.reset(t);let u=_H(o),c=rH(o.docValues);c.reset(r);let d={...UH(o.nodes),renderOrder:i.ids,renderOrderNodes:i.nodes,nodesOnLayer:i.nodesOnLayer,isLocked:f=>u.isLocked(f),isHidden:f=>u.isHidden(f),layoutOf(f){return o.nodes.get(f)?.layout??null},toJSON:()=>GH(o,s,c.toJSON())};return{state:o,order:i,locks:u,stale:wH(o.nodes),fnFields:s,store:a,layers:l,reads:d,docValues:c,reset(f,p){c.reset(p),a.dependents.clear(),a.childDerived.clear(),o.nodes.clear(),o.roots.length=0,l.reset(f)}}}function QX(e,t){let n=e.get(t);return n&&{node:n,pose:Xn(e,n)}}var ZX=0,e9=()=>ue(`n${(ZX++).toString(36)}-${Math.random().toString(36).slice(2,8)}`);function t9(e,t){return()=>{for(let n=0;n<1e3;n++){let r=e();if(!t(r))return r}throw new Error("scene: generateId gave 1000 ids the scene already holds")}}function n9(e,t,n,r){if(t.length===0)throw new Error("Scene: systemLayers must declare at least one layer");let o=M3(e.registry??{}),i=WH(o,t,()=>h.layoutDeclared(),r),{state:s,locks:a,reads:l}=i,u=J3(),c=tH(),d=eH({untracked:c.untracked,changes:u,shown:v=>QX(P,v)}),f=(v,A)=>d.layout(()=>P.setPose(ue(v),A)),p=uH(e.layoutFrame),h=X3({nodes:s.nodes,layoutPass:(v,A,N)=>cH(P,l.layoutOf,v,A,p,N),recordsBareEdits:()=>!c.open(),writePose:f}),m=t9(e.generateId??e9,v=>s.nodes.has(v)),g=LH(a.reachable,v=>s.nodes.get(v)?.parent);g.subscribe(u.notify);let b=R1(v=>s.nodes.get(v),i.store.invalidateDependents),x=R2(),w=FH({notifier:u,mode:c,passAdapter:()=>({...oy(P),...ZB(P)}),stale:i.stale,lifted:a.lifted,selection:g,arrivals:h,writePose:f,poseWrites:d,config:e}),y=TH({state:s,store:i.store,locks:a,layers:i.layers,invalidateOrder:i.order.invalidate,fnFields:i.fnFields,ops:{...w.ops,register:d.reporting(w.ops.register)},recorder:w.recorder,arrivals:h,layoutFrame:p,generateId:m,narrowSelection:g.narrow,clearOverride:b.clear});for(let[v,A]of Object.entries(e.ops??{}))w.ops.register(v,A);let P={get nodes(){return s.nodes},get roots(){return s.roots},get layers(){return s.layers},registry:o,...l,mintId:m,composition:e.composition??sh,...y.methods,...w.methods,unlocked:v=>a.lifted(v),setArrivalHandler:h.setHandler,onReflow:h.onReflow,onPoseWrite:d.subscribe,overrides:b,scroll:x,getSelection:g.get,setSelection:v=>g.set([...v]),loadState(v,A){let N=uy(v,o,{composition:P.composition,...A});if(c.open())throw new Error("Scene: cannot loadState inside another edit \u2014 it replaces the state that edit would revert to");b.clearAll(),x.clearAll(),i.reset(v.systemLayers.map(O1),v.doc),w.clearHistory(),d.quiet(()=>y.construct(N)),g.replace(g.legal(g.get().filter(M=>s.nodes.has(M)))),u.notify()},...Q3(u,g)},S=n(o);return S&&(d.quiet(()=>y.construct(S)),u.notify()),P}function cy(e,t={}){return n9(t,e.systemLayers.map(O1),n=>uy(e,n,t),e.doc)}Z();var VH="__weaselHeadless";function zH(e){return zg(e)}var o9=g1();function KH(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}async function i9(e){let{scene:t,screen:n,format:r,overlay:o,...i}=e,s={...i,scene:cy(zH(t)),...o?{overlay:o}:{},...n?{screen:Float64Array.from(n)}:{}};await b1({render:s});let a=o9.render(s);if(r==="png"){let u=await x1(a);return{width:a.width,height:a.height,base64:KH(new Uint8Array(await u.arrayBuffer()))}}let l=new Uint8Array(a.data.buffer,a.data.byteOffset,a.data.byteLength);return{width:a.width,height:a.height,base64:KH(l)}}var s9={render:i9};globalThis[VH]=s9;})();
430
+ };`),ED.set(n,r)}catch{MD=!0}}return r===void 0?(o,i)=>Vq(e,o,i):r(e,OD)}function Vq(e,t,n){for(let r=0;r<e.length;r++){let o=e[r],i=o.values[o.scalar?n:n*o.axes];if(o.op==="last"&&Number.isNaN(i))t[o.name]!==void 0&&(t[o.name]=void 0);else if(o.scalar)t[o.name]=i;else{let s=t[o.name],a=OD(o,n,s);a!==s&&(t[o.name]=a)}}}function zq(e,t){let n=t.spec,r=t.patch;return e.lanes!==null&&!e.projecting&&e.opts.history===void 0&&t.named===null&&n.target===void 0&&n.stagger===void 0&&n.role===void 0&&n.anchor===void 0&&n.from!=="current"&&typeof n.weight!="function"&&r.state===void 0&&r.step===void 0&&t.motion===void 0&&t.owner===null&&t.holding===null&&t.blend===null&&!t.freezesBefore&&!t.beginless&&t.slots.every(o=>{let i=e.channels[o];return i.rest!==void 0&&Qn(i)?.op!=="last"})}var Kq=60;function jq(e){let t=e.sharers;for(let n=t.length-1;n>=0;n--){let r=t[n];r.built!==null||r.state==="pending"||r.state==="done"||++r.shared>=Kq&&o1(e,r)}}function $q(e,t){if(t.everyone!==null)return t.everyone;let n=e.sinceOf(t,0);if(!(n<=e.now))return o1(e,t),null;let r=On(t,!0,void 0);return r.since=n,r.shown=e.shownOf(t,n),r.stepped=n,r.rebuilt=t.rebuilds,t.everyone=r,r}function n1(e,t){let n=e.sighted,r=t>>>5;return n!==null&&t>=0&&r<n.length&&(n[r]&1<<(t&31))!==0}function FD(e,t,n){let r=e.sighted,o=t>>>5;if(r===null||o>=r.length){let s=new Uint32Array(Math.max(o+1,(n>>>5)+1));r!==null&&s.set(r),e.sighted=s,r=s}let i=1<<(t&31);(r[o]&i)===0&&(r[o]=r[o]|i,e.seen++)}function r1(e,t){let n=e.weights;return n!==null&&t>=0&&t<n.length?n[t]:0}function Bm(e,t,n,r){let o=e.weights;if(o===null||t>=o.length){if(n===0)return;let i=new Float64Array(Math.max(t+1,r));o!==null&&i.set(o),e.weights=i,o=i}o[t]=n}function ja(e,t,n){if(e.built!==null)return;let r=e.stamps,o=n*2;if(t.stepped=t.since,r===null||o>=r.length){t.probed=Number.NaN,t.seeks=0,t.delta=null;return}let i=r[o+0];t.probed=i,t.seeks=r[o+1],t.delta=Number.isNaN(i)?null:e.deltas[n]??null}function Gc(e,t,n,r){if(e.built!==null)return;let o=e.stamps,i=n*2;if(o===null||i>=o.length){if(Number.isNaN(t.probed))return;let s=new Float64Array(Math.max(n+1,r)*2).fill(Number.NaN);o!==null&&s.set(o),e.stamps=s,o=s,e.deltas??=[]}o[i+0]=t.probed,o[i+1]=t.seeks,e.deltas[n]=t.delta}function Yq(e,t){let n=e.stamps,r=t*2;n!==null&&t>=0&&r<n.length&&(n[r+1]=-1),e.built!==null&&e.everyone!==null&&(e.everyone.seeks=-1)}function LD(e,t,n,r){if(n1(e,t)){let a=e.seen;FD(e,n,r),e.seen=a}let o=r1(e,t);(o!==0||e.weights!==null&&n<e.weights.length)&&Bm(e,n,o,r);let i=e.stamps,s=t*2;if(i!==null&&s<i.length){let a=n*2;if(a>=i.length){let u=new Float64Array(Math.max(n+1,r)*2).fill(Number.NaN);u.set(i),e.stamps=u,i=u}i[a+0]=i[s+0],i[a+1]=i[s+1];let l=e.deltas;l[n]=l[t]??null}Hm(e,t)}function Hm(e,t){let n=e.sighted,r=t>>>5;n!==null&&r<n.length&&(n[r]=n[r]&~(1<<(t&31)));let o=e.weights;o!==null&&t<o.length&&(o[t]=0);let i=e.stamps,s=t*2;i!==null&&s<i.length&&(i[s+0]=Number.NaN,e.deltas[t]=null)}function o1(e,t,n=!1,r){if(!t.sharing)return;t.sharing=!1;let o=t.everyone;t.everyone=null;let i=e.sharers.indexOf(t);i>=0&&e.sharers.splice(i,1);let s=n?ut(e,r)?.slot??-1:-1;o!==null&&n&&(e.projecting||n1(t,s))?(s>=0&&Hm(t,s),t.subjects.set(r,o)):t.holder===o&&(t.holder=null),e.lanes?.rerecord(t.id,(a,l)=>e.held(t,a,l)),t.state!=="done"&&e.steps.push(t,++e.version),e.unshared=!0,$o(e),e.lanes?.refill()}function qq(e,t,n){t.weight=r1(e,n),ja(e,t,n),Hm(e,n)}var _D={shares:zq,outgrow:jq,everyoneOf:$q,sighted:n1,sight:FD,weightAt:r1,weighAt:Bm,open:ja,shut:Gc,restamp:Yq,unsight:Hm,unshare:o1,inherit:qq};function Ya(e,t){return e-t*Math.round(e/t)}var $a=Zn(4,0),i1=Zn(4,0);function s1(e,t,n,r){let o=r.length===n?r:Zn(n,0);for(let i=0;i<n;i++)o[i]=e[t+i];return o}function Gm(e,t,n,r,o){if(e.turn>0){t[n]=t[n]+Ya(r,e.turn)*o;return}let i=e.axes;$a=s1(t,n,i,$a);let s=e.channel.fold($a,r,o);for(let a=0;a<i;a++)t[n+a]=s[a]}function DD(e,t,n,r,o,i){if(e.turn>0){Gm(e,t,n,r[o],i);return}i1=s1(r,o,e.axes,i1),Gm(e,t,n,i1,i)}function BD(e,t,n,r,o,i){if(e.turn>0){let l=t[n],u=r;t[n]=o===0?u:l+Ya(u-l,e.turn)*i;return}let s=e.axes,a=r;(o!==0||a.length!==s)&&($a=s1(t,n,s,$a),a=e.channel.lerp($a,r,i));for(let l=0;l<s;l++)t[n+l]=a[l]}function HD(e,t){let n=e.values,r=e.axes;if(e.op!=="own"){n.fill(e.rest,0,t*r);return}let o=e.start;for(let i=0;i<t*r;i+=r)for(let s=0;s<r;s++)n[i+s]=o[s]}function Uc(e,t){if(e.length>=t)return e;let n=new Float64Array(t);return n.set(e),n}function GD(e,t){let n=e.cap;t.met.length<n&&(t.met=Uc(t.met,n),t.first=Uc(t.first,n),t.sum=Uc(t.sum,n));for(let r=0;r<t.values.length;r++){let o=t.values[r],i=t.taken[r],s=e.laned[r].axes;o!==void 0&&(t.values[r]=Uc(o,n*s)),i!==void 0&&(t.taken[r]=Uc(i,n))}if(t.inline=Xq(t),!t.inline){e.into=t;try{for(let r of t.members){let o=r.voice;if(r.idle||o.state==="pending"||o.state==="done")continue;e.intoId=o.id,e.reset(r),r.elapsedNow=o.elapsedAt(e.now);let i=r.list,s=o.bound;s!==null&&CT(e,s);let a=e.fills;for(let l=0;l<i.length;l++){let u=i[l];if(s!==null&&!OT(s,u,a)){FT(e,r,l,u);continue}if(e.one(r,l,u)&&(Wm(e,t,u),t.sum[u]=t.sum[u]+r.data[l*8+2]),o.keeping)break}}}finally{e.into=null}}}function Wm(e,t,n){if(t.met[n]===e.fills)return;t.met[n]=e.fills,t.first[n]=e.intoId,t.sum[n]=0;let r=t.taken;for(let o=0;o<r.length;o++){let i=r[o];i!==void 0&&(i[n]=0)}}function Um(e,t,n,r){let o=e.arg,i=o[7],s=t.values[n.index],a=t.taken[n.index];if(s===void 0||a===void 0){UD(e,t,n,r,i);return}let l=o[0];Wm(e,t,r);let u=a[r],c=u+l;s[r]=u===0?i:Ft(s[r],i,l/c),a[r]=c}function UD(e,t,n,r,o){let i=e.arg[0];Wm(e,t,r);let s=n.index,a=t.values[s],l=t.taken[s];(a===void 0||l===void 0)&&(a=new Float64Array(e.cap*n.axes),l=new Float64Array(e.cap),t.values[s]=a,t.taken[s]=l);let u=l[r],c=u+i,d=i/c;if(!n.plain||!n.straight)BD(n,a,r*n.axes,o,u,d);else if(n.scalar)a[r]=u===0?o:Ft(a[r],o,d);else{let f=Array.isArray(o)||ArrayBuffer.isView(o)?o:null,p=r*n.axes;for(let h=0;h<n.axes;h++){let m=f===null?n.rest:f[h]??n.rest;a[p+h]=u===0?m:Ft(a[p+h],m,d)}}l[r]=c}function WD(e,t,n){let r=t.voice.id,o=e.fills,i=t.list;for(let s=0;s<i.length;s++){let a=i[s];n.met[a]!==o||n.first[a]!==r||n.sum[a]>0&&VD(e,n,a)}}function VD(e,t,n){for(let r=0;r<t.values.length;r++){let o=t.taken[r],i=o===void 0?0:o[n];if(!(i>0))continue;let s=i>1?1:i,a=e.laned[r],l=t.values[r],u=a.values,c=n*a.axes;if(!a.plain){DD(a,u,c,l,c,s);continue}for(let d=0;d<a.axes;d++)u[c+d]=Fe(a.op,u[c+d],l[c+d],s)}}function Xq(e){if(!e.contiguous)return!1;let t=e.members,n=t[0].list;for(let r of t){let o=r.voice;if(r.idle||o.keeping||o.state==="pending"||o.state==="done")return!1;let i=r.list;if(i!==n){if(i.length!==n.length)return!1;for(let s=0;s<n.length;s++)if(i[s]!==n[s])return!1}}return!0}function zD(e,t){let n=t.members,r=e.arg;for(let s of n){e.reset(s),s.elapsedNow=s.voice.elapsedAt(e.now);let a=s.voice.bound;a!==null&&CT(e,a)}let o=e.fills,i=n[0].list;e.into=t;try{for(let s=0;s<i.length;s++){let a=i[s],l=0;for(let u=0;u<n.length;u++){let c=n[u];if(c.voice.keeping)continue;let d=c.voice.bound;if(d!==null&&!OT(d,a,o)){FT(e,c,s,a);continue}r[6]=c.mark,e.one(c,s,a)&&(Wm(e,t,a),l+=c.data[s*8+2])}l>0&&VD(e,t,a)}}finally{e.into=null}}function KD(e,t){let n=e.chans;for(let r=0;r<n.length;r++)e.values[r]=t[n[r].name]}function jD(e,t){let n=e.chans;for(let r=0;r<n.length;r++)this.foldInto(n[r],t,e.values[r])}function $D(e,t,n){let r=e.length,o=this.arg,i=e[0];if(r>0){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Fe(i.op,l[t],s,o[0])}else o[7]=s,Um(this,a,i,t)}else this.foldInto(i,t,s)}if(i=e[1],r>1){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Fe(i.op,l[t],s,o[0])}else o[7]=s,Um(this,a,i,t)}else this.foldInto(i,t,s)}if(i=e[2],r>2){let s=n[i.name];if(typeof s=="number"&&i.scalar&&i.plain){let a=this.into;if(a===null){let l=i.values;l[t]=Fe(i.op,l[t],s,o[0])}else o[7]=s,Um(this,a,i,t)}else this.foldInto(i,t,s)}for(let s=3;s<r;s++){i=e[s];let a=n[i.name];if(typeof a=="number"&&i.scalar&&i.plain){let l=this.into;if(l===null){let u=i.values;u[t]=Fe(i.op,u[t],a,o[0])}else o[7]=a,Um(this,l,i,t)}else this.foldInto(i,t,a)}}function YD(e,t,n){if(!e.plain){this.unplain(e,t,e.scalar?n[0]:n);return}let r=this.arg[0],o=e.values,i=t*e.axes;for(let s=0;s<e.axes;s++)o[i+s]=Fe(e.op,o[i+s],n[s],r)}function qD(e,t,n){if(n===void 0)return;if(this.into!==null){UD(this,this.into,e,t,n);return}if(!e.plain&&!this.unplain(e,t,n))return;let r=this.arg[0],o=e.values;if(e.scalar){o[t]=Fe(e.op,o[t],n,r);return}let i=t*e.axes,s=Array.isArray(n)||ArrayBuffer.isView(n)?n:null;for(let a=0;a<e.axes;a++){let l=s===null?e.rest:s[a]??e.rest;o[i+a]=Fe(e.op,o[i+a],l,r)}}function XD(e){let t=this.arg[0],n=this.folding,r=this.rec,o=n.chans.indexOf(e),i=r.bands??new Uint8Array(n.chans.length);r.bands=i;let s=i[o],a=this.host.passes(s===0?void 0:s===1,t);return i[o]=a?1:2,a}function JD(e,t,n){if(e.op==="last")return this.gate(e);let r=this.arg[0],o=e.values;return e.turn>0?o[t]=o[t]+Ya(n,e.turn)*r:Gm(e,o,t*e.axes,n,r),!1}function QD(e,t){let n=t.voice,r=t.data,o=e.per,i=t.list,s=t.records,a=t.chans,l=t.values,u=a.length,c=e.fills,d=e.lately,f=n.elapsedAt(e.now);t.elapsedNow=f;let p=n.duration,h=n.passes,m=n.freezesBefore,y=n.freezesAfter,b=n.span,x=n.hidesPast,w=t.flat,g=n.parts!==null,P=Wr(n.weight),S=0;for(let N=0;N<u;N++)S+=a[N].axes;t.nums.length<S&&(t.nums=new Float64Array(S)),t.kinds.length<u&&(t.kinds=new Uint8Array(u));let v=t.nums,A=t.kinds;for(let N=0;N<i.length;N++){let M=i[N],C=N*8;if(_t(r,C,o,M*6,c),d>=0&&e.unread(M))continue;let F=f-r[C+0],D=F>b&&x?Number.NaN:Kh(F,m,y,b);if(!(D>=0)){r[C+2]=0,kt(s[N]);continue}if(!w){let W=r[C+1];(!t.weighed||!$t(W,t.weighedSince))&&(t.fade=e.host.envelope(n,W),t.weighed=!0,t.weighedSince=W)}let B=w&&!g?P:Yt(n.weight,t.fade,e.parting(n,M));if(r[C+2]=B,(!t.read||!$t(D,t.readAt))&&(e.readKeyed(n,Ur(D,p,h),t.delta,t.scratch),t.read=!0,t.readAt=D,e.gather(t,t.delta),Jq(a,l,v,A)),!(B>0)){kt(s[N]);continue}let K=0;for(let W=0;W<u;W++){let Q=a[W],le=Q.axes,ke=A[W];if(ke===1){let ue=Q.values,ve=M*le;for(let G=0;G<le;G++)ue[ve+G]=Fe(Q.op,ue[ve+G],v[K+G],B)}else ke===2&&(e.folding=t,e.rec=s[N]??null,e.arg[0]=B,e.foldInto(Q,M,l[W]));K+=le}}}function Jq(e,t,n,r){let o=0;for(let i=0;i<e.length;i++){let s=e[i],a=t[i];if(a===void 0)r[i]=0;else if(!s.plain)r[i]=Qq(s,a,n,o);else if(r[i]=1,s.scalar)n[o]=a;else{let l=Array.isArray(a)||ArrayBuffer.isView(a)?a:null;for(let u=0;u<s.axes;u++)n[o+u]=l===null?s.rest:l[u]??s.rest}o+=s.axes}}function Qq(e,t,n,r){return e.turn>0?(n[r]=Ya(t,e.turn),1):2}var Vm=class{lanes;crowd;row;made;constructor(t,n,r,o=0){this.lanes=t,this.crowd=n,this.row=r,this.made=o}};function Hn(e,t){let n=t.seat;return n!==null&&n.lanes===e?n:null}function ZD(e,t,n,r){let o=Hn(e,t);return o!==null&&o.crowd===n&&o.row===r}function Zq(e,t){if(e.metCrowd||e.owes(t))return!1;let n=e.met,r=e.metN;if(e.owed.last(n,r))return!0;let o=Number.NEGATIVE_INFINITY;for(let i of e.lanes){let s=i.voice.id;if(s<=o)continue;let a=n.indexOf(s);(a<0||a>=r)&&(o=s)}for(let i of e.crowds)i.size>0&&(o=Math.max(o,i.hot[(i.size-1)*i.stride+7]));for(let i=0;i<r;i++){let s=n[i];if(s<=o||e.byId.get(s).group!==null)return!1}return!0}function eB(e,t,n,r,o){let i=e.per[t*6+1],s=i<0?-1-i:i;e.per[t*6+1]=e.epochs;let a=!1;e.metN=0,e.metCrowd=!1;let l=e.dense;for(let f=l.length-1;f>=0;f--){let p=l[f];if(p.epoch<=s)break;if(p.positionOf(t)>=0)continue;let h=e.host.meet(p.voice,n,r,t);h.reaches&&(p.add(t,h),p.idle&&Xt(e,t,1),e.met[e.metN++]=p.voice.id,a=!0)}let u=i<0?e.host.naming(n):void 0;if(u!==void 0)for(let f of u){let p=e.byId.get(f.id);if(p===void 0){nX(e,f,t,n,s,r)&&(a=!0,e.metCrowd=!0);continue}if(p.epoch<=s||p.positionOf(t)>=0)continue;let h=e.host.meet(f,n,r,t);h.reaches&&(p.add(t,h),p.idle&&Xt(e,t,1),e.met[e.metN++]=f.id,a=!0)}if(!a)return o;let c=e.met;for(let f=1;f<e.metN;f++){let p=c[f],h=f-1;for(;h>=0&&c[h]>p;h--)c[h+1]=c[h];c[h+1]=p}let d=t*6;if(o&&e.per[d+2]===0){let f=eX(e,t);if(f||Zq(e,t))return tX(e,t,n,f)||e.owed.owe(t,e.met,e.metN),!0}return e.per[d+0]=e.fills,!1}function eX(e,t){if(e.foldsFill!==e.fills||e.metCrowd||e.owes(t))return!1;let n=e.folds,r=e.metN;if(n.length!==r)return!1;for(let o=0;o<r;o++)if(n[o]!==e.met[o])return!1;return!0}function tX(e,t,n,r){if(e.filling)return!1;let o=e.lately,i=t*6;if(o>=0&&!(e.per[i+3]>o||e.per[i+4]>o))return!1;let s=e.met,a=e.metN;for(let l=0;l<a&&!r;l++){let u=e.byId.get(s[l]),c=u.voice;if(u.ran!==e.fills||u.motion!==void 0||c.keeping||typeof c.spec.weight=="function"||c.sharing&&c.everyone===null)return!1}r||(e.folds=s.slice(0,a),e.foldsFill=e.fills),e.subjects[t]===void 0&&(e.subjects[t]=n,e.holding=!0),e.meeting=!0;try{for(let l=0;l<a;l++){let u=e.byId.get(s[l]),c=u.voice,d=u.positionOf(t);if(!c.sharing){e.one(u,d,t);continue}let f=c.everyone;ja(c,f,t),e.one(u,d,t),c.keeping||Gc(c,f,t,e.cap)}}finally{e.meeting=!1}for(let l=0;l<a;l++)e.byId.get(s[l]).voice.keeping&&(e.foldsFill=-1);return!0}function nX(e,t,n,r,o,i){let s=Hn(e,t);if(s===null)return!1;let a=s.crowd,l=s.row,u=l*a.stride,c=a.hot[u+0];if(a.hot[u+6]<=o||(c&16)!==0)return!1;let d=e.host.meet(t,r,i,n);if(!d.reaches)return!1;let f=l*8;return a.list[l]=n,e.placed.add(n,t.id),a.data[f+0]=d.delay,a.data[f+1]=d.shown,a.data[f+2]=0,a.data[f+3]=0,a.data[f+4]=-1,a.data[f+5]=-1,a.data[f+7]=0,a.records[l]=d,a.deltas[l]=null,a.restale(l,c|16),a.idle&&Xt(e,n,1),!0}function Xt(e,t,n){let r=t*6+2;e.per[r]=e.per[r]+n}var rX=ja,oX=Gc,iX=0;function sX(e){if(e<2)return 1;for(let t=e;;t++){let n=!0;for(let r=2;r*r<=t;r++)if(t%r===0){n=!1;break}if(n)return t}}function l1(e,t,n){rs(e);let r=e.host;e.filling=!0;let o=e.lookups;try{e.fills++,e.owed.begin(e.fills),e.now=t,e.filledAt=t,e.filledVersion=n;let i=e.numbers.size;e.keeps=r.keeps;let s=e.fresh;e.fresh=!1;let a=e.live>0?e.lastDistinct/e.live:1;e.lately=a<1?e.lastFrom:-1;let l=!1;for(let u of e.lanes){if(s){let c=u.line,d=u.list.length;d>=64?tB(e,u):d===1&&u.motion===void 0?u.idle||nB(e,u):(u.idle?a>=c.start:a<c.stop)&&a1(e,u)}u.idle||(l=!0)}for(let u of e.crowds)s&&(u.size>=64?tB(e,u):(u.idle?a>=u.line.start:a<u.line.stop)&&a1(e,u)),u.cursor=0,u.stale&&h_(u),!u.idle&&u.size>0&&(l=!0);if(l){for(let u of e.laned)HD(u,i);for(let u of e.roles)GD(e,u);for(let u of e.lanes)u.idle||(e.crowds.length>0&&(e.arg[6]=Number.NaN,NT(e,u.voice.id)),e.run(u));e.crowds.length>0&&(e.arg[6]=Number.NaN,NT(e,Number.POSITIVE_INFINITY));for(let u of e.crowds)u.idle||(u.bareFill=e.fills,u.bareNow=t)}e.busyFill=l?e.fills:0;for(let u of e.late)e.per[u*6+0]=e.fills;e.holding&&(e.subjects.fill(void 0,0,i),e.holding=!1),e.moved=pe.moved,e.inputs=pe.inputs,e.holds=e.lookups!==o}finally{e.filling=!1,e.late.length=0}}function tB(e,t){let n=t.list,r=t.line,o=e.lastFrom,i=e.lastTo,s=sX(Math.floor(n.length/256)),a=0,l=0;for(let c=e.fills%s;c<n.length;c+=s){let d=n[c];if(d<0)continue;let f=e.per[d*6+3],p=e.per[d*6+4];(f>o&&f<=i||p>o&&p<=i)&&l++,a++}let u=a>0?l/a:1;(t.idle?u>=r.start:u<r.stop)&&a1(e,t)}function a1(e,t){t.idle?u1(e,t):nB(e,t)}function nB(e,t){t.idle=!0;let n=t.list,r=t.data;for(let o=0;o<n.length;o++){let i=n[o];i<0||(Xt(e,i,1),_t(r,o*8,e.per,i*6,e.fills))}}function u1(e,t){t.idle=!1;for(let n of t.list)n>=0&&Xt(e,n,-1)}function rB(e,t,n){let r=this.arg,o=r[5];if(Number.isNaN(n.probed))return this.late.push(t),!1;let i=this.subjectAt(t);return i===or?(r[0]=0,!0):(this.host.signal(e,i,n,t),r[0]=Yt(r[0],o,e.parts===null?1:this.host.parting(e,i)),!0)}function oB(e,t){if(e.parts===null)return 1;let n=this.subjectAt(t);return n===or?1:this.host.parting(e,n)}function iB(e){this.lookups++;let t=this.subjects[e];return t===void 0&&(t=this.numbers.subject(e),this.subjects[e]=t,this.holding=!0),t}function sB(e){let t=e.voice;e.placed=!1,this.arg[6]=Number.NaN,e.read=!1,e.weighed=!1,e.flat=!((t.fade.in??0)>0)&&t.out===null&&t.back===null&&t.owner===null,e.fade=1}function aB(e){let t=e.voice;if(t.state==="pending"||t.state==="done")return;let n=e.group;if(n!==null){n.inline?e===n.members[0]&&zD(this,n):WD(this,e,n);return}if(this.reset(e),e.ran=this.fills,e.motion!==void 0&&!t.keeping){c_(this,e,e.motion);return}if(t.built!==null&&typeof t.spec.weight!="function"){QD(this,e);return}e.elapsedNow=t.elapsedAt(this.now);let r=e.list;if(t.sharing){this.runEveryone(e);return}if(t.bound!==null){P_(this,e,t.bound);return}for(let o=0;o<r.length;o++)if(this.one(e,o,r[o]),t.keeping)return}function lB(e){let t=e.voice,n=t.everyone,r=e.list,o=this.cap;for(let i=0;i<r.length;i++){let s=r[i];if(rX(t,n,s),this.one(e,i,s),t.keeping)return;oX(t,n,s,o)}}function uB(e,t,n){let r=this.host,o=e.voice,i=e.elapsedNow,s=this.arg,a=e.data,l=t*8;if(_t(a,l,this.per,n*6,this.fills),this.lately>=0&&this.unread(n))return!1;let u=a[l+0],c=i-u,d=c>=0?c>o.span?o.hidesPast?Number.NaN:o.freezesAfter?o.span:c:c:o.freezesBefore?0:Number.NaN;if(!(d>=0))return a[l+2]=0,kt(e.records[t]),!1;(!e.placed||!$t(d,e.placedAt))&&(e.placed=!0,e.placedAt=d,e.phase=Ur(d,o.duration,o.passes),e.pass=er(d,o.duration,o.passes),s[6]=++iX,e.mark=s[6]);let f=a[l+1];!e.flat&&(!e.weighed||!$t(f,e.weighedSince))&&(e.fade=r.envelope(o,f),e.weighed=!0,e.weighedSince=f);let p;if(typeof o.spec.weight=="function"){if(s[1]=d,s[3]=e.pass,s[5]=e.fade,!this.signalled(o,n,e.records[t]))return a[l+2]=0,kt(e.records[t]),!1;p=s[0]}else p=Yt(o.weight,e.fade,this.parting(o,n));if(a[l+2]=p,p>0||kt(e.records[t]),this.folding=e,this.rec=e.records[t]??null,o.built!==null){if((!e.read||!$t(d,e.readAt))&&(this.readKeyed(o,e.phase,e.delta,e.scratch),e.read=!0,e.readAt=d,this.gather(e,e.delta)),typeof o.spec.weight=="function"){let m=e.records[t];m.probed=this.now,m.seeks=o.seeks,m.delta=null}return p>0&&(s[0]=p,this.fold(e,n)),!0}let h=e.records[t];return Number.isNaN(h.probed)&&!this.meeting&&!e.every?(this.late.push(n),!1):(s[1]=d,s[4]=u,s[0]=p,e.motion!==void 0?(Ec(this,e,e.motion,t,n,h),!0):(s[2]=e.phase,s[3]=e.pass,this.call(o,e.chans,h,n)))}function cB(e,t,n){let r=this.arg[2],o=this.arg[0],i=e.built,s=i.tracks;for(let a=0;a<s.length;a++){let l=s[a],u=t[a],c=pT(l,uT(l,r,i.duration),void 0);if(c===cm)continue;if(c===Ma){this.foldInto(u,n,He.a);continue}let d=He.a,f=He.b,p=He.eased;if(u.scalar||!u.plain||!u.straight){this.foldInto(u,n,e.lerps[a](d,f,p));continue}let h=d,m=f,y=u.values,b=n*u.axes,x=u.rest;for(let w=0;w<u.axes;w++){let g=Ft(h[w]??x,m[w]??x,p);y[b+w]=Fe(u.op,y[b+w],g,o)}}}function dB(e,t,n,r){dm(e.built,t,n,void 0,e.lerps,void 0,e.intos,r)}function fB(e,t,n,r){let o=this.arg,i=o[2],s=o[4],a=o[0],l=this.host,u=this.subjectAt(r);if(u===or)return!1;if(n.probed===this.now&&n.delta!==null&&n.seeks===e.seeks)return a>0&&this.foldDelta(t,r,n.delta),!0;if(jh(e,a))return n.delta=null,n.probed=this.now,n.seeks=e.seeks,e.spec.role!==void 0;let c=pe.kept;l.ready(e,u,n),this.keeps?l.horizon(e,s):pe.horizon=Number.POSITIVE_INFINITY;let d=e.patch.at(i,u,e.setting);return n.delta=d,n.probed=this.now,n.seeks=e.seeks,this.keeps&&l.after(e,u,n),pe.kept!==c&&!e.keeping&&l.kept(e),a>0&&this.foldDelta(t,r,d),!0}var zm=class{fill=new Int32Array(0);at=new Int32Array(0);lists=[];now=0;begin(t){this.now=t,this.lists.length=0}grow(t){let n=new Int32Array(t);n.set(this.fill),this.fill=n;let r=new Int32Array(t);r.set(this.at),this.at=r}any(){return this.lists.length>0}owes(t){return this.lists.length>0&&this.fill[t]===this.now}owesVoice(t,n){return this.lists[this.at[t]].includes(n)}owe(t,n,r){this.last(n,r)||this.lists.push(n.slice(0,r)),this.fill[t]=this.now,this.at[t]=this.lists.length-1}last(t,n){let r=this.lists[this.lists.length-1];if(r===void 0||r.length!==n)return!1;for(let o=0;o<n;o++)if(r[o]!==t[o])return!1;return!0}};var Km=class{one=new Int32Array(0);rest=null;grow(t){let n=new Int32Array(t);n.set(this.one),this.one=n}any(t){return this.one[t]|0}all(t){let n=this.any(t);return n===0?[]:[n,...this.rest?.get(t)??[]]}add(t,n){if(this.one[t]===0){this.one[t]=n;return}this.rest??=new Map;let r=this.rest.get(t);r===void 0?this.rest.set(t,[n]):r.push(n)}remove(t,n){let r=this.rest?.get(t);if(this.one[t]===n)this.one[t]=r===void 0?0:r.pop();else if(r!==void 0){let o=r.indexOf(n);if(o<0)return;r[o]=r[r.length-1],r.pop()}else return;r!==void 0&&r.length===0&&this.rest.delete(t)}};function aX(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function d1(e,t,n){let r=t.list[n];r>=0&&(t.idle&&Xt(e,r,-1),e.placed.remove(r,t.voices[n].id)),t.list[n]=-1,t.records[n]=void 0,t.deltas[n]=null;let o=n*t.stride+0;t.hot[o]=t.hot[o]&-2065;let i=n*8;t.data[i+4]=-1,t.data[i+5]=-1,t.data[i+7]=0}function pB(e,t){let n=0;for(let o of t){if(!e.seats.has(o.id))return!1;n++}let r=0;for(let o of e.seats.values())o.crowd.voices[o.row].state!=="done"&&r++;return r===n}function hB(e,t){let n=new Set(t.map(i=>i.id));for(let i of e.crowds)for(let s=0;s<i.size;s++){let a=i.voices[s];(!n.has(a.id)||a.state==="done")&&gB(e,i,s)}let r=e.crowds,o=new Map(e.seats);for(let i of o.values())i.lanes=null;e.crowds=[],e.seats.clear(),e.overlap=!1;for(let i of t){let s=o.get(i.id);f1(e,i,s?.crowd,s?.row,r)}e.crowds.length===0&&(e.lawsByKey.clear(),e.lastLaw=null)}function f1(e,t,n,r,o){let i=t.slots.map(u=>e.bySlot[u]),s=e.crowds.find(u=>aX(u.chans,i));if(s===void 0){s=new km(i,i[0].axes);let u=i.map(d=>d.name).join(" "),c=o.find(d=>d.chans.map(f=>f.name).join(" ")===u);c!==void 0&&(s.idle=c.idle);for(let d of e.crowds)d.chans.some(f=>i.includes(f))&&(e.overlap=!0);e.crowds.push(s)}let a=s.size;s.reserve(a+1),n!==void 0&&r!==void 0?mB(n,r,s,a):uX(e,s,a,t),s.hot[a*s.stride+6]===0&&t.state!=="pending"&&(s.hot[a*s.stride+6]=jm(e,t));let l=new Vm(e,s,a,n===void 0?e.probes:0);e.seats.set(t.id,l),t.seat=l,t.laned=!0}function p1(e,t,n,r){let o=n*t.stride;t.hot[o+6]===0&&r.state!=="pending"&&(t.hot[o+6]=jm(e,r)),t.hot[o+0]=t.hot[o+0]|64}function h1(e){for(let t of e.crowds)t.dead>64&&t.dead*4>=t.size&&lX(e,t)}function lX(e,t){let n=t.keys;t.keys=new Ga;let r=0;for(let o=0;o<t.size;o++){let i=t.voices[o],s=Hn(e,i);if(s===null||s.crowd!==t||s.row!==o){t.odd?.delete(o);continue}r!==o?(mB(t,o,t,r,n),t.odd?.delete(o),s.row=r):yB(n,t,r),r++}t.list.length=r,t.voices.length=r,t.records.length=r,t.deltas.length=r,t.motions.length=r,t.eases.length=r,t.laws.length=r,t.dead=0}function m1(e,t,n){let r=t.voices[n];gB(e,t,n),t.list[n]=-1,t.records[n]=void 0,t.deltas[n]=null,t.motions[n]=void 0,t.hot[n*t.stride+0]=0,e.seats.delete(r.id);let o=r.seat;o!==null&&o.lanes===e&&(o.lanes=null,r.seat=null),t.dead++}function c1(e,t,n,r,o){for(let i=0;i<o;i++)n[r+i]=e[t+i]}function mB(e,t,n,r,o=e.keys){e.fix(t),n.list[r]=e.list[t],c1(e.data,t*8,n.data,r*8,8),c1(e.hot,t*e.stride,n.hot,r*n.stride,e.stride),yB(o,n,r),(e.hot[t*e.stride+0]&4)!==0&&(n.stale=!0,n.staleRows.push(r)),c1(e.samples,t*e.axes,n.samples,r*n.axes,e.axes),n.deltas[r]=e.deltas[t]??null,n.records[r]=e.records[t],n.voices[r]=e.voices[t],n.motions[r]=e.motions[t],n.eases[r]=e.eases[t],n.laws[r]=e.laws[t];let i=e.odd?.get(t);i!==void 0&&(n.odd??=new Map,n.odd.set(r,i))}function yB(e,t,n){let r=n*t.stride;(t.hot[r+0]&512)!==0&&(t.hot[r+9]=t.keys.copy(e,t.hot[r+9]))}function uX(e,t,n,r){let o=Ln(r.patch),i=n*t.stride;t.hot.fill(0,i,i+t.stride);let s=r.built===null?-1:t.keys.add(r.built,t.chans);s>=0&&(t.hot[i+9]=s,t.hot[i+11]=r.duration,t.hot[i+10]=r.passes),t.restale(n,64|(o===void 0?0:128)|(o?.ease===void 0?0:1024)|(s>=0?512:0)),t.hot[i+7]=r.id,t.list[n]=-1;let a=n*8;if(t.data.fill(0,a,a+8),t.data[a+4]=-1,t.data[a+5]=-1,t.deltas[n]=null,t.records[n]=void 0,t.voices[n]=r,t.motions[n]=o,o===void 0){t.laws[n]=f_,t.eases[n]=void 0;return}t.laws[n]=cX(e,o),t.eases[n]=o.ease;let l=o.watcher===e?e.byId.get(o.watchId):void 0;if(l!==void 0)for(let u=0;u<l.list.length;u++)l.fix(u);o.watcher=e,o.watchId=r.id}function cX(e,t){let n=e.lastLaw;if(n!==null&&t.hasLaw(n))return n;let r=dX(e,t);return e.lastLaw=r,r}function dX(e,t){let n=t.law(),r=n.join(" "),o=e.lawsByKey.get(r);return o!==void 0?o:(e.lawsByKey.set(r,n),n)}function gB(e,t,n){let r=t.list[n],o=t.records[n];if(r>=0){e.placed.remove(r,t.voices[n].id),t.idle&&Xt(e,r,-1);let a=y1(e,t,n,r);o!==void 0&&a!==void 0&&(o.weight=a),o!==void 0&&t.motions[n]!==void 0&&Mc(e,t,n,r,o)}let i=t.motions[n],s=t.voices[n];i!==void 0&&i.watcher===e&&i.watchId===s.id&&(i.watcher=null),s.laned=!1}function y1(e,t,n,r){let o=r*6;if(!(e.per[o+3]>e.per[o+4])||t.list[n]!==r)return;let i=Hn(e,t.voices[n])?.made??0;if(e.per[o+3]>i)return t.data[n*8+(e.per[o+5]===e.fills?2:3)]}function bB(e,t){let n=e.slice(),r=!0;for(;r;){r=!1;for(let s of t)if(!(s.fits&&s.slots.every(a=>n[a])))for(let a of s.slots)n[a]&&(n[a]=!1,r=!0)}let o=new Set,i=e.map(()=>!1);for(let s of t)if(!(!s.fits||!s.slots.every(a=>n[a]))){o.add(s.id);for(let a of s.slots)i[a]=!0}return{channels:i,voices:o}}function $m(e,t){rs(e);let n=e.host;e.qualifiedVersion=t,e.filledVersion=Number.NaN;let r=e.touched.slice();e.touched.length=0;let o=n.voices.filter(h=>h.state!=="done"&&h.holding===null);for(let h of o)h.id>e.known&&(e.known=h.id);let i=n.channels.map(h=>Qn(h)!==void 0),s=o.map(h=>h.slots.length>0&&n.fits(h));xB&&pX(o,s,n.channels);let a=()=>o.map((h,m)=>({id:h.id,fits:s[m],slots:h.slots})),{channels:l,voices:u}=bB(i,a());for(let h=!0;h;){h=!1;let m=new Map;o.forEach((y,b)=>{let x=y.spec.role;if(x===void 0)return;let w=m.get(x);w===void 0?m.set(x,[b]):w.push(b)});for(let y of m.values()){let b=y.filter(x=>u.has(o[x].id)).length;if(!(b===0||b===y.length)){for(let x of y)s[x]=!1;h=!0}}h&&({channels:l,voices:u}=bB(i,a()))}for(let h of e.lanes)u.has(h.voice.id)||wB(e,h);let c=[],d=0;for(let h of o){if(!u.has(h.id))continue;if(ns(h)){d++;continue}let m=e.byId.get(h.id);m===void 0&&(m=new Cc(h),m.made=e.probes),h.laned=!0,m.epoch===0&&h.state!=="pending"&&x1(e,m),c.push(m)}e.lanes=c,e.roles=[];let f=new Map;for(let h of c){h.group=null;let m=h.voice.spec.role;if(m===void 0)continue;let y=f.get(m);y===void 0&&(y={members:[],met:new Float64Array(e.cap),first:new Float64Array(e.cap),sum:new Float64Array(e.cap),values:[],taken:[],contiguous:!1,inline:!1},f.set(m,y),e.roles.push(y)),y.members.push(h),h.group=y}for(let[h,m]of f)m.contiguous=xX(o,u,h,m.members);e.dense=c.filter(h=>h.voice.named===null&&h.epoch>0).sort((h,m)=>h.epoch-m.epoch),e.whole=c.length+d===o.length,e.byId.clear();for(let h of c)e.byId.set(h.voice.id,h);c.length===0&&d===0&&(e.subjects=[]);let p=o.filter(h=>u.has(h.id)&&ns(h));if(hX(e,l)&&pB(e,p)){for(let h of c)h.chans=h.voice.slots.map(m=>e.bySlot[m]),h.values=h.chans.map(()=>{});for(let h of e.crowds)for(let m=0;m<h.size;m++){let y=h.voices[m];ZD(e,y,h,m)&&y.state==="done"&&m1(e,h,m)}for(let h of r){if(h.state==="done")continue;let m=Hn(e,h);m!==null&&p1(e,m.crowd,m.row,h)}h1(e);return}e.laned=[],e.copier=null,e.bySlot=n.channels.map(()=>{}),l.forEach((h,m)=>{if(!h)return;let y=n.channels[m],b=Qn(y),x=y.rest??Number.NaN,w=typeof x=="number"&&b.axes===1,g=b.folds??b.op,P={name:n.names[m],op:g,plain:g!=="last"&&g!=="own"&&b.turn===void 0,straight:b.folds===void 0,turn:b.turn??0,channel:y,scalar:w,rest:typeof x=="number"?x:x[0],axes:b.axes,values:new Float64Array(e.cap*b.axes),start:typeof x=="number"?[]:x,index:e.laned.length};e.laned.push(P),e.bySlot[m]=P}),e.copies.length=0;for(let h of e.bySlot)e.copies.push(h!==void 0);for(let h of c)h.chans=h.voice.slots.map(m=>e.bySlot[m]),h.values=h.chans.map(()=>{});hB(e,p)}var xB=!0;function g1(e,t){return e.built===null&&e.motion===void 0&&e.slots.every(n=>fX(t[n]))}function fX(e){return Array.isArray(e.rest)&&Qn(e)?.op!=="last"}function pX(e,t,n){let r=new Array(n.length).fill(!1),o=new Array(n.length).fill(!1);e.forEach((i,s)=>{if(!t[s])return;let a=ns(i);if(g1(i,n)){if(!a)for(let l of i.slots)o[l]&&(r[l]=!0),o[l]=!0}else for(let l of i.slots)r[l]=!0}),e.forEach((i,s)=>{t[s]&&g1(i,n)&&!i.slots.some(a=>r[a])&&(t[s]=!1)})}function hX(e,t){let n=e.bySlot;if(n.length!==t.length)return!1;for(let r=0;r<n.length;r++)if(n[r]!==void 0!==t[r])return!1;return!0}function jm(e,t){let n=++e.epochs;if(t.named===null)return e.wide=n,n;for(let r of t.named.list){let o=e.host.slotOf(r);if(o<0||o>=e.cap)continue;let i=o*6+1,s=e.per[i],a=s<0?-1-s:s;e.per[i]=-1-Math.min(a,n-1)}return n}function b1(e){let t=ji(e.touched);e.touched=[];let n=0;for(let o=0;o<t.length;o++)(o===0||t[o]!==t[o-1])&&(t[n++]=t[o]);t.length=n;let r=()=>(e.touched=t,!1);for(let o of t){let i=o.id<=e.known;o.id>e.known&&(e.known=o.id);let s=Hn(e,o);if(s!==null){if(o.state==="done"){m1(e,s.crowd,s.row);continue}p1(e,s.crowd,s.row,o);continue}if(o.state==="done"&&!i)continue;let a=e.byId.get(o.id);if(a!==void 0){if(!bX(e,a))return r();continue}if(o.state==="done"||o.spec.role!==void 0)return r();let l=o.slots.some(c=>e.bySlot[c]!==void 0),u=o.slots.length>0&&e.host.fits(o);if(!l&&(!u||xB&&ns(o)&&g1(o,e.host.channels))){e.whole=!1;continue}if(i||!u||!l||o.slots.some(c=>e.bySlot[c]===void 0))return r();ns(o)?f1(e,o,void 0,void 0,e.crowds):gX(e,o)}return h1(e),e.lanes.length===0&&e.crowds.every(o=>o.dead===o.size)&&(e.subjects=[]),!0}function x1(e,t){let n=t.voice;t.epoch=jm(e,n),n.named===null&&n.spec.target===void 0&&(t.reserve(e.live,e.cap),mX(e,t)&&yX(e,t))}function mX(e,t){let n=t.voice;return n.sharing&&n.everyone!==null&&t.motion===void 0&&!n.keeping&&typeof n.spec.weight!="function"&&t.list.length===0&&e.lastDistinct>=e.live}function yX(e,t){let n=t.voice.everyone,r=e.numbers,o=Math.min(r.size,e.cap);for(let i=0;i<o;i++)r.has(i)&&(t.add(i,n),t.idle&&Xt(e,i,1));t.every=!0}function gX(e,t){let n=new Cc(t);n.made=e.probes,t.laned=!0,t.state!=="pending"&&x1(e,n),n.chans=t.slots.map(r=>e.bySlot[r]),n.values=n.chans.map(()=>{}),e.lanes.push(n),e.byId.set(t.id,n),t.named===null&&n.epoch>0&&e.dense.push(n)}function bX(e,t){let n=t.voice;if(n.state!=="done")return t.epoch===0&&n.state!=="pending"&&(x1(e,t),n.named===null&&e.dense.push(t)),!0;if(t.group!==null)return!1;wB(e,t),e.lanes.splice(e.lanes.indexOf(t),1);let r=e.dense.indexOf(t);return r>=0&&e.dense.splice(r,1),e.byId.delete(n.id),!0}function wB(e,t){t.idle&&u1(e,t);let n=t.voice.state==="done";if(!n||t.motion!==void 0)for(let o=0;o<t.list.length;o++){let i=t.records[o],s=t.list[o],a=n?void 0:e.reported(t,s);i!==void 0&&a!==void 0&&(t.voice.sharing?Bm(t.voice,s,a,e.cap):i.weight=a),i!==void 0&&t.motion!==void 0&&Mc(e,t,o,s,i)}let r=t.motion;if(r!==void 0&&r.watcher===e&&r.watchId===t.voice.id){for(let o=0;o<t.list.length;o++)t.fix(o);r.watcher=null}t.voice.laned=!1}function xX(e,t,n,r){for(let s=1;s<r.length;s++)if(r[s].voice.id<=r[s-1].voice.id)return!1;let o=r[0].voice.id,i=r[r.length-1].voice.id;for(let s of e)if(s.id>o&&s.id<i&&t.has(s.id)&&s.spec.role!==n)return!1;return!0}function TB(e,t,n,r){let o=e.lanes,i=n.slot;if(i<0||o.filling||o.host.keeps||e.projecting||o.roles.length>0||o.owed.any()||o.lanes.some(u=>u.voice.bound!==null)||!o.numbers.move(i,r))return!1;for(let u of o.lanes)u.renumber(i,r);let s=o.placed;for(let u of s.all(i)){s.remove(i,u);let c=o.seats.get(u);c===void 0||c.crowd.list[c.row]!==i||(c.crowd.list[c.row]=r,s.add(r,u))}let a=o.per;a.copyWithin(r*6,i*6,(i+1)*6),a[i*6+0]=o.fills,o.unlinked[r]=o.unlinked[i],o.subjects[r]=o.subjects[i],o.subjects[i]=void 0;for(let u of o.laned)u.values.copyWithin(r*u.axes,i*u.axes,(i+1)*u.axes);e.places?.forgot(i),e.places?.number(t,r);let l=o.cap;for(let u of e.general)mT(u,i,r),LD(u,i,r,l),PB(e,u,i,r);for(let u of zo(e).general)mT(u,i,r);for(let u=n;u!==null;u=u.next)u.voice!==null&&PB(e,u.voice,i,r);return n.slot=r,!0}function PB(e,t,n,r){let o=t.blend?.of;if(!(o===void 0||n>=o.frames.length||o.frames[n]!==e.frame)){if(r>=o.frames.length){let i=Math.max(r+1,o.frames.length*2,64),s=new Float64Array(i),a=new Float64Array(i);s.set(o.frames),a.set(o.values),o.frames=s,o.values=a}o.frames[r]=e.frame,o.values[r]=o.values[n],o.frames[n]=Number.NaN}}var Wc=class{host;static share=_D;pulls={pullRun:AD,writeLater:RD,flush:rs,renumber:TB};numbers;lanes=[];dense=[];byId=new Map;crowds=[];seats=new Map;placed=new Km;unlinked=new Float64Array(0);overlap=!1;roles=[];folding=null;meeting=!1;folds=[];foldsFill=-1;rec=null;arg=new Float64Array(8);into=null;intoId=0;lawsByKey=new Map;lastLaw=null;met=[];metN=0;metCrowd=!1;owed=new zm;laned=[];copier=null;bySlot=[];copies=[];whole=!1;cap=0;epochs=0;wide=0;touched=[];known=0;per=new Float64Array(0);fills=0;busyFill=0;probes=0;subjects=[];holding=!1;holds=!0;lookups=0;filling=!1;late=[];queueSlots=new Int32Array(0);queueRows=new Int32Array(0);queueCounts=new Int32Array(0);queued=0;queuedFor=null;queueFrom=null;keeps=!1;now=Number.NaN;filledAt=Number.NaN;moved=0;inputs=0;frameAt=Number.NaN;frameProbes=0;lastFrom=0;lastTo=0;fresh=!1;distinct=0;lastDistinct=0;live=0;lately=-1;filledVersion=Number.NaN;qualifiedVersion=Number.NaN;constructor(t,n){if(this.host=t,n===void 0){this.numbers=new om(this);return}this.numbers=n.numbers,this.numbers.adopt(this),this.live=n.live;let r=this.numbers.size;this.grow(r);let o=this.per;for(let i=0;i<r;i++)o[i*6+0]=Number.NaN,o[i*6+1]=-1}invalidate(){this.qualifiedVersion=Number.NaN,this.filledVersion=Number.NaN}refill(){this.filledVersion=Number.NaN}touch(t){this.touched.push(t),this.filledVersion=Number.NaN}number(t){let n=this.numbers.take(t);return this.live++,this.grow(n+1),this.per[n*6+0]=this.fills,this.per[n*6+1]=-1,this.per[n*6+2]=0,this.per[n*6+3]=0,this.per[n*6+4]=0,this.per[n*6+5]=0,this.filling&&this.late.push(n),n}release(t){this.numbers.release(t)}sought(t){return Number.isNaN(this.per[t*6+0])}renew(t){return this.sought(t)?(this.per[t*6+0]=this.fills,this.filling&&this.late.push(t),!0):!1}part(t,n){let r=this.byId.get(t);if(r!==void 0){if(r.positionOf(n)<0)return;r.idle&&Xt(this,n,-1),r.remove(n);return}let o=this.seats.get(t);o!==void 0&&o.crowd.list[o.row]===n&&d1(this,o.crowd,o.row)}rejoin(t){t<this.cap&&(this.per[t*6+1]=-1)}weightOf(t,n){if(n<0)return;let r=this.byId.get(t);if(r!==void 0)return this.reported(r,n);let o=this.seats.get(t);return o===void 0?void 0:y1(this,o.crowd,o.row,n)}reported(t,n){let r=n*6,o=this.per[r+3];if(!(o>this.per[r+4])||!(o>t.made))return;let i=t.positionOf(n);if(!(i<0))return t.data[i*8+(this.per[r+5]===this.fills?2:3)]}prepare(t,n,r,o){let i=this.host.clock.now;if(!this.filled(i,r)&&this.begin(i,r)===0)return this.general(t);if(t<0)return!1;this.probedThisFrame(t)||this.distinct++;let s=++this.probes,a=this.per,l=t*6,u=a[l+0]<this.busyFill&&a[l+2]===0;return a[l+1]<this.wide&&(u=eB(this,t,n,o,u)),u?(a[l+3]=s,a[l+5]=this.fills,this.holds&&(this.subjects[t]=n,this.holding=!0)):a[l+4]=s,u}filled(t,n){return this.frameAt===t&&this.qualifiedVersion===n&&this.touched.length===0&&!this.filling&&this.current(t,n)}current(t,n){return this.filledAt===t&&this.filledVersion===n&&this.moved===pe.moved&&this.inputs===pe.inputs}begin(t,n){if(t!==this.frameAt&&(this.lastFrom=this.frameProbes,this.lastTo=this.probes,this.lastDistinct=this.distinct,this.distinct=0,this.frameAt=t,this.frameProbes=this.probes,this.fresh=!0),this.filling||(this.qualifiedVersion!==n?!Number.isNaN(this.qualifiedVersion)&&this.touched.length>0&&b1(this)?this.qualifiedVersion=n:$m(this,n):this.touched.length>0&&!b1(this)&&$m(this,n),this.laned.length===0))return 0;if(!this.current(t,n)&&(l1(this,t,n),this.qualifiedVersion!==n)){if($m(this,n),this.laned.length===0)return 0;l1(this,t,n)}return 1}general(t){return t>=0&&(this.per[t*6+4]=++this.probes),!1}unread(t){let n=this.per,r=t*6,o=this.lately;return n[r+3]>o||n[r+4]>o?!1:(n[r+0]=this.fills,!0)}probedThisFrame(t){let n=this.frameProbes,r=t*6;return this.per[r+3]>n||this.per[r+4]>n}owes(t){return this.owed.owes(t)}owesVoice(t,n){return this.owed.owesVoice(t,n)}paid(t,n,r){let o=this.byId.get(t),i=o===void 0?-1:o.positionOf(n);if(i<0)return;o.data[i*8+2]=r;let s=o.voice.bound;s!==null&&r!==0&&Im(s,n,this.fills)}rests(t){for(let n of this.laned){let r=n.values;if(n.op==="last"){if(!Number.isNaN(r[t*n.axes]))return!1;continue}if(n.scalar){if(!(Math.abs(r[t]-n.rest)<1e-9))return!1;continue}if(n.start.length<n.axes)return!1;let o=t*n.axes;for(let i=0;i<n.axes;i++)if(!(Math.abs(r[o+i]-n.start[i])<1e-9))return!1}return!0}forget(t){this.host.forgot(t),this.live--;for(let r of this.lanes)r.remove(t);let n=this.placed;for(let r=n.any(t);r!==0;r=n.any(t)){let o=this.seats.get(r);o!==void 0&&o.crowd.list[o.row]===t?d1(this,o.crowd,o.row):n.remove(t,r)}t<this.cap&&(this.per[t*6+0]=this.fills),this.subjects[t]=void 0}grow(t){if(t<=this.cap)return;let n=Math.max(t,this.cap*2,64),r=new Float64Array(n*6);r.set(this.per),this.per=r,this.owed.grow(n),this.placed.grow(n);let o=new Float64Array(n);o.set(this.unlinked),this.unlinked=o;for(let i of this.laned){let s=new Float64Array(n*i.axes);s.set(i.values),i.values=s}this.cap=n}stretchChanged(t,n){let r=this.seats.get(t);if(r!==void 0){let s=r.crowd;s.restale(r.row,s.hot[r.row*s.stride+0]);return}let o=this.byId.get(t),i=o===void 0?-1:o.positionOfMotion(n);i>=0&&o.fix(i)}rerecord(t,n){let r=this.byId.get(t);if(r!==void 0)for(let o=0;o<r.list.length;o++){let i=r.list[o],s=this.subjectAt(i);s!==or&&(r.records[o]=n(s,i))}}reshown(t){let n=this.seats.get(t);if(n!==void 0){let o=n.crowd.records[n.row];o!==void 0&&(n.crowd.data[n.row*8+1]=o.shown)}let r=this.byId.get(t);if(r!==void 0)for(let o=0;o<r.list.length;o++){let i=r.records[o];i!==void 0&&(r.data[o*8+1]=i.shown)}}voiceChanged(t){let n=Hn(this,t);if(n===null)return;let r=n.crowd,o=n.row*r.stride+0;r.hot[o]=r.hot[o]|64}},wX={copy:CD,row:p_,signalled:rB,parting:oB,subjectAt:iB,reset:sB,run:aB,runEveryone:lB,one:uB,foldKeys:cB,readKeyed:dB,call:fB,gather:KD,fold:jD,foldDelta:$D,foldRun:YD,foldInto:qD,gate:XD,unplain:JD};for(let[e,t]of Object.entries(wX))Object.defineProperty(Wc.prototype,e,{value:t,writable:!0,configurable:!0});var qm=class{xy=new Float64Array(0);n=0;cell=Number.NaN;dirty=!0;x0=0;y0=0;size=1;cols=0;rows=0;starts=new Int32Array(1);order=new Int32Array(0);home=new Int32Array(0);strays=[];stray=new Uint8Array(0);found=new Int32Array(64);count=0;put(t,n,r){if(this.xy[2*t]=n,this.xy[2*t+1]=r,this.dirty)return;if(this.cols===0||t>=this.home.length){this.dirty=!0;return}let o=Math.floor((n-this.x0)/this.size),i=Math.floor((r-this.y0)/this.size);(o>=0&&o<this.cols&&i>=0&&i<this.rows?i*this.cols+o:-2)===this.home[t]||this.stray[t]===1||(this.stray[t]=1,this.strays.push(t),this.strays.length>Math.max(32,this.n>>4)&&(this.dirty=!0))}build(){this.dirty=!1;for(let m of this.strays)this.stray[m]=0;this.strays.length=0;let t=this.xy,n=Math.min(this.n,t.length>>1),r=Number.POSITIVE_INFINITY,o=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let m=0;m<n;m++){let y=t[2*m],b=t[2*m+1];y<r&&(r=y),y>i&&(i=y),b<o&&(o=b),b>s&&(s=b)}if(!(i>=r)||!(s>=o)){this.cols=0,this.rows=0;return}let a=Number.isNaN(this.cell)?Math.sqrt(2*Math.max(i-r,1e-9)*Math.max(s-o,1e-9)/n):this.cell,l=4*n+64;(Math.floor((i-r)/a)+1)*(Math.floor((s-o)/a)+1)>l&&(a=Math.max(a,Math.sqrt((i-r)*(s-o)/n),(i-r+s-o)/l));let u=Math.floor((i-r)/a)+1,c=Math.floor((s-o)/a)+1;this.x0=r,this.y0=o,this.size=a,this.cols=u,this.rows=c;let d=u*c;this.starts.length<d+1?this.starts=new Int32Array(d+1):this.starts.fill(0,0,d+1),this.order.length<n&&(this.order=new Int32Array(n)),this.home.length<n&&(this.home=new Int32Array(n),this.stray=new Uint8Array(n));let f=this.starts,p=this.order;for(let m=0;m<n;m++){let y=SB(t,m,r,o,a,u);this.home[m]=y,y>=0&&(f[y+1]=f[y+1]+1)}for(let m=0;m<d;m++)f[m+1]=f[m+1]+f[m];let h=f[d];for(let m=n-1;m>=0;m--){let y=SB(t,m,r,o,a,u);if(y<0)continue;let b=f[y+1]-1;f[y+1]=b,p[b]=m}for(let m=0;m<d;m++)f[m]=f[m+1];f[d]=h}push(t,n){if(n===this.found.length){let r=new Int32Array(this.found.length*2);r.set(this.found),this.found=r}return this.found[n]=t,n+1}query(t,n,r,o){if(this.dirty&&this.build(),this.count=0,this.cols===0||!(r>=0))return 0;let i=this.size,s=Math.max(0,Ym((t-r-this.x0)/i,-1)),a=Math.min(this.cols-1,Ym((t+r-this.x0)/i,1)),l=Math.max(0,Ym((n-r-this.y0)/i,-1)),u=Math.min(this.rows-1,Ym((n+r-this.y0)/i,1)),c=this.xy,d=this.order,f=this.starts,p=this.strays.length>0,h=0;for(let m=l;m<=u&&s<=a;m++){let y=f[m*this.cols+s],b=f[m*this.cols+a+1];for(let x=y;x<b;x++){let w=d[x];if(p&&this.stray[w]===1)continue;let g=c[2*w]-t,P=c[2*w+1]-n;g*g+P*P<=o&&(h=this.push(w,h))}}for(let m of this.strays){let y=c[2*m]-t,b=c[2*m+1]-n;y*y+b*b<=o&&(h=this.push(m,h))}return this.count=h,h}ring(t,n,r){if(this.dirty&&this.build(),this.count=0,this.cols===0||!(r>=0))return 0;let o=this.size,i=r+o,s=r*r,a=i*i,l=Math.max(0,Math.floor((t-i-this.x0)/o)),u=Math.min(this.cols-1,Math.floor((t+i-this.x0)/o)),c=Math.max(0,Math.floor((n-i-this.y0)/o)),d=Math.min(this.rows-1,Math.floor((n+i-this.y0)/o)),f=this.xy,p=0;for(let h=c;h<=d;h++)for(let m=l;m<=u;m++){let y=this.x0+m*o-t,b=this.y0+h*o-n;if(Math.max(y*y,(y+o)**2)+Math.max(b*b,(b+o)**2)<=s)continue;let w=h*this.cols+m;for(let g=this.starts[w];g<this.starts[w+1];g++){let P=this.order[g];if(this.stray[P]===1)continue;let S=f[2*P]-t,v=f[2*P+1]-n,A=S*S+v*v;A>s&&A<=a&&(p=this.push(P,p))}}for(let h of this.strays){let m=f[2*h]-t,y=f[2*h+1]-n,b=m*m+y*y;b>s&&b<=a&&(p=this.push(h,p))}return this.count=p,p}};function SB(e,t,n,r,o,i){let s=e[2*t],a=e[2*t+1];return!(s>=n)||!(a>=r)?-1:Math.floor((s-n)/o)+Math.floor((a-r)/o)*i}function Ym(e,t){let n=Math.floor(e);return t<0?e-n<1e-6?n-1:n:n+1-e<1e-6?n+1:n}var Xm=class extends qm{slotOf;keepRefs;at=new me;slots=new Int32Array(0);placeOf=new Int32Array(0);refs=null;cur=-1;free=[];owned=!0;tokens=[];registry=null;constructor(t,n){super(),this.slotOf=t,this.keepRefs=n,this.refs=n?[]:null}set(t,n,r){let o=t.length;this.at=new me;for(let i=0;i<o;i++)this.at.set(t[i],i);this.slots=new Int32Array(Math.max(o,16)).fill(-1),this.placeOf.fill(-1),this.refs=this.keepRefs?[]:null,this.tokens=[],this.free=[];for(let i=0;i<o;i++){let s=t[i];this.at.get(s)===i&&this.hold(s,i)}this.n=o,this.xy=n,this.owned=!1,this.cell=r,this.dirty=!0}place(t){let n=this.at.get(t);if(n!==void 0)return n;let r=this.free.pop()??this.n++;return this.room(r+1),this.at.set(t,r),this.hold(t,r),this.owned&&this.put(r,Number.NaN,Number.NaN),r}hold(t,n){let r=this.slotOf(t);r>=0&&this.numbered(r,n);let o=typeof t=="object"&&t!==null;if(this.refs!==null&&(this.refs[n]=o?new WeakRef(t):t),!o)return;let i={i:n};this.tokens[n]=i,this.registry??=new FinalizationRegistry(s=>{this.tokens[s.i]===s&&this.release(s.i)}),this.registry.register(t,i,i)}room(t){if(this.slots.length<t){let n=new Int32Array(Math.max(t,this.slots.length*2)).fill(-1);n.set(this.slots),this.slots=n}if(this.owned&&this.xy.length<2*t){let n=new Float64Array(Math.max(2*t,this.xy.length*2,32)).fill(Number.NaN);n.set(this.xy),this.xy=n}}number(t,n){let r=this.at.get(t);r!==void 0&&this.numbered(n,r)}numbered(t,n){if(t>=this.placeOf.length){let r=new Int32Array(Math.max(t+1,this.placeOf.length*2,64)).fill(-1);r.set(this.placeOf),this.placeOf=r}this.placeOf[t]=n,this.slots[n]=t}forgot(t){if(t>=this.placeOf.length)return;let n=this.placeOf[t];n<0||(this.placeOf[t]=-1,this.slots[n]===t&&(this.slots[n]=-1))}drop(t){let n=this.at.get(t);if(n===void 0)return;this.at.delete(t);let r=this.tokens[n];r!==void 0&&this.registry?.unregister(r),this.release(n)}release(t){this.tokens[t]=void 0,this.refs!==null&&(this.refs[t]=void 0);let n=this.slots[t];n>=0&&(this.placeOf[n]=-1),this.slots[t]=-1,this.owned&&this.put(t,Number.NaN,Number.NaN),this.free.push(t)}subjectAt(t){let n=this.refs?.[t],r=n instanceof WeakRef?n.deref():n;return r!==void 0&&this.at.get(r)===t?r:void 0}inside(t,n,r,o){let i=this.at.get(t);if(i===void 0||2*i+1>=this.xy.length)return!1;let s=this.xy[2*i]-n,a=this.xy[2*i+1]-r;return s*s+a*a<=o}};function kB(e,t,n){if(t.length<2*e.length)throw new RangeError(`blits: plot takes two numbers a subject, x then y: ${e.length} subjects need ${2*e.length}, not ${t.length}`);if(n!==void 0&&!(n>0&&n<Number.POSITIVE_INFINITY))throw new RangeError(`blits: plot's cell is a size above 0, not ${n}`);AB(this).set(e,t,n??Number.NaN),this.moved()}function vB(e){return AB(this).place(e)}function AB(e){if(e.places!==null)return e.places;let t=new Xm(n=>e.chains.get(n)?.slot??-1,!yc());e.places=t;for(let n of e.cued)n.bound===null&&Mm(e,n);return t}function RB(){this.places!==null&&(this.places.dirty=!0),this.lanes?.refill(),this.stir()}function NB(e,t,n){let r=this.places,o=r===null?void 0:r.at.get(e);if(r===null||o===void 0)throw new Error("blits: put takes a subject with an index: place or plot it first");if(2*o+1>=r.xy.length)throw new RangeError(`blits: put's subject is at index ${o}, past the positions plot was given: plot again with room for it`);r.put(o,t,n),this.lanes?.refill(),this.stir()}var Jm=class{list=[];head=0;get length(){return this.list.length-this.head}push(t){this.list.push(t)}shed(t,n){let r=this.list,o=this.head;for(;o+1<r.length&&r[o+1].at<=t;)n?.(r[o]),o++;o>=512&&o*2>=r.length&&(r.splice(0,o),o=0),this.head=o}at(t){let n=this.list,r=this.head,o=n.length-1,i;for(;r<=o;){let s=r+o>>1,a=n[s];a.at<=t?(i=a,r=s+1):o=s-1}return i}numbered(t){let n=this.list,r=this.head,o=n.length-1;for(;r<=o;){let i=r+o>>1,s=n[i];if(s.seq===t)return s;s.seq<t?r=i+1:o=i-1}}all(){return this.list.slice(this.head)}set(t){this.list=t,this.head=0}};var Qm=class e{keeps;log;constructor(t,n=[{anchorNow:0,anchorElapsed:0,rate:1,ramp:null,seq:Number.NEGATIVE_INFINITY}]){this.keeps=t,this.log=n}get clock(){return this.log[this.log.length-1]}get waiting(){return Number.isNaN(this.clock.anchorNow)}sync(t){return this.waiting&&(this.log=[{...this.clock,anchorNow:t,anchorElapsed:t}]),this.reading(t)}reading(t){if(this.waiting)return t;let n=this.log,r=n.length-1;for(;r>0&&n[r].anchorNow>t;)r--;return Ke(n[r],t)}at(t,n){if(!(t>n)||this.waiting)return this.reading(t);let r=this.clock,o=r.ramp;return(o===null?r.rate<=0:o.to<=0&&t>r.anchorNow+o.over)?Number.POSITIVE_INFINITY:Ke(r,t)}timeOf(t){if(this.waiting)return t;let n=this.log,r=0;for(;r+1<n.length&&t>n[r+1].anchorElapsed;)r++;return Cn(n[r],t)}rateAt(t){let n=this.clock;return this.waiting||Number.isNaN(t)?n.ramp===null?n.rate:n.ramp.from:Sa(n,t)}stopped(t){let n=this.clock,r=n.ramp;return r===null?n.rate===0:r.to===0&&!this.waiting&&t>=n.anchorNow+r.over}change(t,n,r,o,i){let s=this.clock,a={...s,seq:i};if(Number.isNaN(t)||this.waiting){let u=this.rateAt(Number.NaN);a.ramp=r>0&&n!==u?{from:u,to:n,over:r}:null,a.rate=n,a.anchorNow=Number.NaN,this.log=[a];return}ka(a,t,n,r);let l=this.log;this.keeps&&s.anchorNow<t?l.push(a):l[l.length-1]=a,this.shed(o)}shed(t){let n=this.log,r=0;for(;r+1<n.length&&n[r+1].anchorElapsed<=t;)r++;return r>0?n.splice(0,r):[]}unshed(t){let n=this.log[0].anchorNow,r=t.filter(o=>o.anchorNow<n).sort((o,i)=>o.anchorNow-i.anchorNow);r.length>0&&(this.log=[...r,...this.log])}cut(t){let n=this.log,r=1;for(;r<n.length&&n[r].anchorNow<=t;)r++;n.length=r}until(t){let n=this.log,r=1;for(;r<n.length&&n[r].anchorNow<t;)r++;return new e(this.keeps,n.slice(0,r))}};var Zm=e=>({t:Number.NaN,seq:0,up:null,rank:0,left:null,cut:null,of:e}),IB=Zm(null);function PX(e){let t=e,n=t.up;for(;n!==null;){let r=n.up;if(r===null)return n;t.up=r,t=r,n=t.up}return t}var Vc=class extends me{own;now;make;stamp=Zm(this);first=this.stamp;at=new me;roots=[];kept=0;ready=[];aging=[];top=Number.NaN;constructor(t,n,r){super(),this.own=t,this.now=n,this.make=r}back(t,n,r){let o=this.stamp;r!==null&&(o.left=r,o.cut=n);let i=this.roots,s=o,a=null;for(;i.length>0;){let l=i[i.length-1].deref();if(l!==void 0&&l.t<t)break;let u=i.pop();l!==void 0&&(l.rank>s.rank?(s.up=l,s=l,a=u):(l.up=s,l.rank===s.rank&&s.rank++))}s.t=t,s.seq=n.seq,i.push(a??new WeakRef(s)),i.length>2*this.kept+16&&(this.roots=i.filter(l=>l.deref()!==void 0),this.kept=this.roots.length),this.stamp=this.fresh(),this.top=t}fresh(){if(this.ready.length===0){let t=Math.min(64,Math.max(1,this.aging.length*2));this.ready=this.aging.reverse(),this.aging=[];for(let n=0;n<t;n++)this.aging.push(Zm(this))}return this.ready.pop()??Zm(this)}sure=!0;get(t){return this.from(t,this.own.get(t))}find(t,n){let r=n.restored;return r!==null&&r.of===this&&this.sure?this.from(t,n):this.get(t)}from(t,n){let r=n?.reaches,o=(r?n.restored:this.at.get(t))??this.first,i=this.stamp;if(o===i)return n;r?n.restored=i:this.at.set(t,i);let s=PX(o),a=o.left?.at(t,o.cut),l=a??this.now(t,n,s),u=l&&this.make(l,s,a===void 0);return u===void 0?(this.shed(t),r&&this.at.set(t,i)):u!==n?this.set(t,u):u.reaches||this.at.set(t,i),u}set(t,n){let r=this.own.get(t);if(r===n){n.reaches?n.restored=this.stamp:this.at.set(t,this.stamp);return}r?.reaches&&(r.restored=IB),n.reaches&&n.restored!==null&&(this.sure=!1),this.own.set(t,n),n.reaches?n.restored=this.stamp:this.at.set(t,this.stamp)}delete(t){this.shed(t),this.at.set(t,this.stamp)}shed(t){let n=this.own.get(t);n?.reaches&&(n.restored=IB),this.own.delete(t)}clear(){this.sure=!1,this.own.clear(),this.at.clear()}};function qa(e,t){if(e.reaches(t))return!1;let n=e.pager;if(n===null)throw new Error(`blits: ${t} is older than this mix's history reaches`);let r=n.loaded;if(r===null||r.t>t){let o=n.last;throw new wc(o?.mix??"",o?.stream??"history",t)}for(let o of[...e.members,...e.dropped.map(i=>i.mix)]){let i=o.name??"";if(o.outs?.missing(r.t,a=>r.records.some(l=>l.stream==="voice"&&l.voice===a&&l.mix===i))!==void 0)throw new wc(i,"voice",t)}return n.loaded=null,TX(e,r.records),e.floor=r.t,!0}function ey(e,t){if(!Number.isInteger(t))throw new RangeError(`blits: a frame is a number \`seq\` read, not ${t}`);let n=e.frames.numbered(t),r=e.pager;if(n===void 0&&r!==null&&t<=e.seq){let o=r.loaded?.records.find(i=>i.stream==="frame"&&i.mix===""&&i.seq===t);if(o!==void 0)qa(e,o.at),n=e.frames.numbered(t);else if(t<(e.frames.all()[0]?.seq??Number.POSITIVE_INFINITY))throw new Error(`blits: frame ${t} reaches past memory; await prepare with its mix time first`)}if(n===void 0)throw new Error(`blits: frame ${t} is not one this mix's history holds: not played yet, let go, or after a moment a seek went back to`);return qa(e,n.at),n}function MB(e,t){let n=e.pager;if(n===null)return;n.store.cut(t);let r=n.loaded;r!==null&&(r.records=r.records.filter(o=>o.seq<=t))}function TX(e,t){SX(e,t);let n=new Map;for(let o of[...e.members,...e.dropped.map(i=>i.mix)])n.set(o.name??"",o);let r=new Map;for(let o of[...t].sort((i,s)=>i.seq-s.seq)){let i=n.get(o.mix);if(i===void 0)continue;let s=r.get(i);s===void 0?r.set(i,[o]):s.push(o)}for(let[o,i]of r)kX(o,i)}function SX(e,t){let n=t.filter(a=>a.mix===""&&a.voice===void 0),r=n.filter(a=>a.stream==="pace").map(a=>a.data);r.length>0&&e.pace?.unshed(r);let o=n.filter(a=>a.stream==="frame").map(a=>({seq:a.seq,at:a.at,u:a.data}));e.frames.set(zc(o,e.frames.all()));let i=new Set(e.announced.map(a=>a.order)),s=n.filter(a=>a.stream==="mark"&&!i.has(a.data.order)).map(a=>a.data);s.length>0&&(e.announced=[...s,...e.announced].sort((a,l)=>a.order-l.order))}function kX(e,t){let n=new Map;for(let s of[...e.cued,...e.gone])n.set(s.id,s);for(let s of t)if(s.stream==="voice"&&s.voice!==void 0&&!n.has(s.voice)){let a=M_(e,s.voice,s.data);n.set(a.id,a),e.gone.push(a),rm(e,a)}let r=t.filter(s=>s.stream==="host");e.hostLog=zc(r.map(s=>({at:s.at,seq:s.seq,fields:s.data})),e.hostLog);let o=new Map;for(let s of t){if(s.voice===void 0)continue;let a=o.get(s.voice);a===void 0?o.set(s.voice,[s]):a.push(s)}let i=e.keys;for(let[s,a]of o){let l=n.get(s);l!==void 0&&vX(l,a,i)}}function vX(e,t,n){let r=s=>t.filter(a=>a.stream===s);e.log!==null&&(e.log=zc(r("controls").map(s=>s.data),e.log));let o=r("left");if(o.length>0){let s=[...e.left?.all()??[]];for(let a of o){let l=n.subject(a.subject);if(s.some(p=>p.seq===a.seq&&Object.is(p.subject,l)))continue;let[u,c,d=null,f=null]=a.data;s.push({subject:l,at:a.at,seq:a.seq,sync:c,held:qi(e,u),ramp:d,parted:f})}s.sort((a,l)=>a.seq-l.seq),e.left=Fn.from(s)}for(let[s,a]of w1(r("snap"))){let l=n.subject(s);for(let[u,c]of EB(e,l,a))u.snaps=zc(c.map(d=>({at:d.at,seq:d.seq,held:qi(e,d.data)})),u.snaps??[])}for(let[s,a]of w1(r("input"))){let l=n.subject(s);for(let[u,c]of EB(e,l,a))u.inputs=zc(c.map(d=>({at:d.at,seq:d.seq,value:d.data})),u.inputs??[])}let i=e.motion;if(i!==void 0){for(let s of r("released"))i.reclaim(n.subject(s.subject),s.at,s.seq,s.data);for(let[s,a]of w1(r("stretch")))i.restretch(n.subject(s),a)}}function w1(e){let t=new Map;for(let n of e){let r=t.get(n.subject);r===void 0?t.set(n.subject,[n]):r.push(n)}return t}function EB(e,t,n){let r=e.left?.of(t)??[],o=[],i=Number.NEGATIVE_INFINITY;for(let a of r)o.push([a.held,n.filter(l=>l.seq>i&&l.seq<=a.seq)]),i=a.seq;let s=e.subjects.get(t);return s?.reaches&&o.push([s,n.filter(a=>a.seq>i)]),o}function zc(e,t){let n=t[0]?.seq??Number.POSITIVE_INFINITY,r=[];for(let o of e)o.seq<n&&(r.length>0&&r[r.length-1].seq===o.seq?r[r.length-1]=o:r.push(o));return r.length===0?t:[...r,...t]}function AX(e,t,n,r,o,i){let s=r.t,a=n.inputs?.filter(P=>P.at<=s),l=n.snaps;if(l===void 0){let P=i&&n.reaches?Ka(n):qo(t,n);return P.stepped>s&&(P.stepped=s),CB(P,n,s),P.weight=0,P.inputs=a,P.since<=s||Oa(e,t,P),P}let u=l.length,c=u>0&&l[u-1].at<=s?u-1:u>1&&l[u-2].at<=s?u-2:jT(l,s,!0);if(c<0)return;let d=l[c],{ticks:f,since:p,rebuilt:h,state:m,slot:y,restored:b}=n,x;i&&n.reaches?(x=YT(t,d.held,n,!0),x.slot=y,x.restored=b):x=qo(t,d.held,!0),x.weight=0,CB(x,n,s),d.at<s&&(x.copied=!0);let w=c+1;if(i)RX(t,l,w);else for(let P=0;P<w;P++)l[P].shared=!0;x.snaps=i?l:l.slice(0,w),x.inputs=a,x.since<=d.at||Oa(e,t,x);let g=i&&f>x.ticks&&p===x.since&&h===x.rebuilt;if(t.patch.step!==void 0&&(d.ahead!==void 0||s-d.at>=o||g)){let P=d.ahead;P===void 0||P.since!==x.since?(P={put:x,sought:s,since:x.since,at:d.at,ticks:x.ticks,state:void 0,leftTicks:0,left:void 0},d.ahead=P):(P.put=x,P.sought=s),g&&(P.leftTicks=f,P.left=m)}return x}function CB(e,t,n){e.restedAt=t.restedAt<=n?t.restedAt:Number.NaN}function RX(e,t,n){for(;t.length>n;){let r=t.pop();r.shared||(r.ahead=void 0,e.spares??=[],e.spares.push(r))}}function NX(e,t){let n=t.owner;n?.holding&&(n.holding.kids--,t.passed&&n.holding.played--);let r=t.motion;r!==void 0&&r.owner===e.owner&&r.ownerId===t.id&&(r.owner=null),t.park()}function IX(e,t,n,r){let o={seq:r,strict:!1},i=t.log,s=Bc(i,o)??i[0];if(i.length=i.indexOf(s)+1,t.take(s),t.reopen(r)&&t.owner?.holding&&t.owner.holding.played--,t.doneAt=Number.POSITIVE_INFINITY,t.doneSeq=Number.POSITIVE_INFINITY,t.parts!==null){for(let[c,d]of t.parts)d.seq>r&&t.parts.delete(c);t.parts.size===0&&(t.parts=null)}if(t.parted!==null){for(let[c,d]of t.parted)d.seq<=r||(t.parted.delete(c),!(d.ramp===void 0||d.ramp.seq>r)&&(t.parts??=new Map,t.parts.set(c,d.ramp)));t.parted.size===0&&(t.parted=null)}t.seen=0,t.restedCount=0,t.early=null,t.holder=null,t.keepOn=null,t.laned=!1,t.unreached=null,t.unreachedBits=null,t.seeks++,t.spares=null;let a=t.left?.all()??[];t.left!==null&&Dm(t,t.left.after(o),r),t.left=Fn.from(a.filter(c=>c.seq<=r));let l=Fn.from(a.filter(c=>c.seq>r)),u=t.subjects;if(!(u instanceof Vc)){let c=Hc(e.opts.history),d=(p,h,m)=>qh(t,p,h,m.t,m.seq),f=new Vc(u,d,(p,h,m)=>{let y=AX(e,t,p,h,c,m);return y===void 0||(y.reaches&&t.seen++,Ho(y)&&t.restedCount++,y.since<=f.top||(t.early??=[],t.early.push(y))),y});u=f,t.subjects=u}u.back(n,o,l)}function Xa(e,t){if(e.projecting)throw new Error("blits: a projection does not seek");if(!e.history)throw new Error("blits: seeking needs a mix made with history");let r=e.tape;if(r===void 0)throw new Error("blits: seeking needs history.tape, which keeps the calls a seek plays again");if(Number.isNaN(e.now))throw new Error("blits: a mix that has never synced has nothing to seek");let o,i;if(typeof t=="number"){if(o=t,o===Number.POSITIVE_INFINITY)throw new RangeError("blits: a mix seeks to a finite time");if(!(o>=e.born))throw new Error(`blits: ${o} is older than this mix's history reaches`);if(qa(e,o),o<e.now&&(i=e.frames.at(o),i===void 0))throw new Error(`blits: ${o} is older than this mix's history reaches`)}else{let s=ey(e,t.frame);o=s.at,s.seq!==e.seq&&(i=s)}if(i===void 0){let s=Ba(e,c=>(e.pace===null?c:e.pace.reading(c))<=o),a=e.left,l=a!==null&&a.t===o&&a.u>=e.u&&(e.pace===null?a.u:e.pace.reading(a.u))===o?a.u:Jr(e,o),u=Number.isNaN(s)?l:Math.max(s,l);if(!Number.isFinite(u))throw new RangeError(`blits: the mix's rate never reaches ${o}`);if(e.u=u,Number.isNaN(s)||e.now!==o)for(let c of e.members)Qr(c,o)}else{let s=i.at===o?i.u:es(e,o),a=i.seq;e.left={t:e.now,u:e.u},r.goto(r.depthAt(s)),e.undrop(a),e.announced=e.announced.filter(l=>l.seq<=a),e.frames.set(e.frames.all().filter(l=>l.seq<=a)),e.pacedSeq>a?(e.pace=null,e.pacedSeq=Number.POSITIVE_INFINITY):e.pace?.cut(s),e.u=s,e.now=o;for(let l of e.members)EX(l,o,a,i.at<o);MB(e,a)}e.tick(o),e.offset=e.last-e.u,e.kept();for(let s of e.members){s.stir();let a=s.bookers;if(a!==null)for(let l of a)l.sought()}}function EX(e,t,n,r){let o=[...e.cued,...e.gone].sort((c,d)=>c.id-d.id),i=[],s=[],a=new Set;for(let c of o)c.motion!==void 0&&a.add(c.motion);for(let c of o)c.cuedSeq>n?NX(e,c):c.doneSeq<=n?s.push(c):i.push(c);for(let c of i)IX(e,c,t,n);let l={seq:n,strict:!1};for(let c of i)c.state=c.stateAt(t,l),c.begunSeq>n&&(c.begunSeq=Number.POSITIVE_INFINITY);e.cued=i,e.gone=s,e.retired=[];for(let c of i)c.holding!==null&&(c.holding.children=i.filter(d=>d.owner===c),c.holding.back(n));let u=e.lanes;u!==null&&e.lanesOf!==null?e.lanes=new e.lanesOf(wm(e),u):e.chains=new me,e.owners=i.some(c=>c.holding!==null)?i.filter(c=>c.holding!==null):null,Yo(e),e.parters.clear();for(let c of[...i,...s])(c.parts!==null||c.parted!==null)&&e.parters.add(c);e.relinks++,e.lastPoses=new me,e.restStamps!==null&&(e.restStamps=new me),kD(e);for(let c of[...i,...s]){c.unreached=null,c.unreachedBits=null;let d=c.blend?.of;d!==void 0&&(d.frame=0,d.reads=new me,d.frames=new Float64Array(0),d.values=new Float64Array(0))}e.playing.clear();for(let c of i){let d=c.motion;d!==void 0&&(e.playing.set(d,(e.playing.get(d)??0)+1),e.owner!==null&&(d.owner=e.owner,d.ownerId=c.id))}for(let c of a)u!==null&&c.watcher===u&&(c.watcher=null),c.rewind(n);e.hostLog=e.hostLog.filter(c=>c.seq<=n),e.sent=e.sent.filter(c=>c.timestamp<=t),e.sentTo=t,e.pins=null;for(let c of i)c.state==="pending"&&!Number.isNaN(c.pinned)&&(e.pins??=new Map,e.pins.set(c,c.pinned));e.due.clear();for(let c of i)it(e,c);if(e.stir(),r)Qr(e,t);else{e.frame=st(),e.reducedNow=e.reduced;let c=e.opts.history.ms;e.anchored>0&&e.transport.forgotTo>=t-c&&Yr(e)}}var T1=Symbol.for("@msb235/blits/watch/1"),S1=globalThis;function k1(){let e=S1[T1];if(e!==void 0)return e;let t=new Map,n=new Set,r=new WeakMap;return e={refs:t,entries_:r,fns:n,labels:new WeakMap,next:1,counted:0,history:void 0,gone:new FinalizationRegistry(o=>{t.delete(o);for(let i of[...n])i({kind:"gone",id:o})}),entries(){let o=[];for(let i of t.values()){let s=i.deref(),a=s===void 0?void 0:r.get(s);a!==void 0&&o.push(a)}return o},on(o){return n.add(o),()=>{n.delete(o)}}},S1[T1]=e,e}var FB=new WeakSet;function LB(e){let t=S1[T1]?.history;return e.history!==void 0||e.transport!==void 0||t===void 0?{history:e.history,added:!1}:{history:t,added:!0}}function _B(e){FB.add(e)}function DB(e){let t=k1(),n=t.next++,r=e.transport,o={id:n,release:Gh,name:e.name,mix:e,get history(){let i=r.history;return i===void 0?void 0:{ms:i.ms,tape:r.tape!==void 0,added:FB.has(r)}},get reach(){return UB(r,!1)},channels:e.names,voice:i=>{let s=e.cued.find(a=>a.handle===i)??e.gone.find(a=>a.handle===i);return s===void 0?void 0:{name:s.spec.name,tags:s.spec.tags??[],within:s.bound?.area}},label:i=>MX(e,i),watch:i=>FX(e,i),subjects:()=>OX(e),read:(i,s=e.now)=>e.project(s).probe(i),hold:()=>DX(r)};t.entries_.set(e,o),t.refs.set(n,new WeakRef(e)),t.gone.register(e,n,e);for(let i of[...t.fns])i({kind:"add",entry:o})}function BB(e){let t=k1(),n=t.entries_.get(e);if(n===void 0||!t.refs.has(n.id))return;t.refs.delete(n.id),t.gone.unregister(e),HB(e);let r=e.transport,o=Kc(r).held,i=s=>t.refs.has(t.entries_.get(s)?.id??-1);o!==null&&!r.members.some(i)&&o.free();for(let s of[...t.fns])s({kind:"gone",id:n.id})}function MX(e,t){return e.opts.labelOf?.(t)??CX(t)}function CX(e){if(typeof e!="object"||e===null)return typeof e=="function"?e.name||"function":String(e);let t=globalThis.Element;if(t!==void 0&&e instanceof t){let i=e.id?`#${e.id}`:"",s=[...e.classList].map(a=>`.${a}`).join("");return`${e.tagName.toLowerCase()}${i}${s}`}let n=e;for(let i of["name","id"]){let s=n[i];if(typeof s=="string"&&s!==""||typeof s=="number")return String(s)}let r=k1(),o=r.labels.get(e);return o===void 0&&(o=`${e.constructor?.name||"Object"} #${++r.counted}`,r.labels.set(e,o)),o}function OX(e){let t=ir.get(e),n=new Set(t?.was);for(let r of t?.seen??[])n.add(r);for(let r of e.cued)if(r.state!=="done")for(let o of r.spec.subjects??[])n.add(o);return[...n]}var OB=new WeakMap;function Kc(e){let t=OB.get(e);return t===void 0&&(t={tapped:0,held:null,unsync:null},OB.set(e,t)),t}function ty(e){let t=Kc(e),n=t.tapped>0||t.held!==null;if(n&&t.unsync===null){let r=ny(e).sync;t.unsync=eo(e,"sync",o=>{for(let s of e.members)GB(s);let i=t.held;i===null?r.call(e,o):i.sync(o)})}else!n&&t.unsync!==null&&(t.unsync(),t.unsync=null)}function eo(e,t,n){let r=e,o=r[t];return r[t]=n,()=>{r[t]=o}}function ny(e){return Object.getPrototypeOf(e)}var ir=new WeakMap;function FX(e,t){let n=ir.get(e);if(n===void 0){let r=ny(e),o=r.probe,i=r.pull,s=r.drain,a=[eo(e,"probe",(l,u)=>{let c=o.call(e,l,u);return P1(e).probed.push({subject:l,pose:_X(c)}),ir.get(e).seen.add(l),c}),eo(e,"pull",(l,u)=>{let c=Array.isArray(l)?l:[...l];i.call(e,c,u);let d={};for(let[p,h]of Object.entries(u))h!==void 0&&(d[p]=h.slice());P1(e).pulled.push({subjects:[...c],columns:d});let f=ir.get(e).seen;for(let p of c)f.add(p)}),eo(e,"drain",l=>{let u=s.call(e,l);return u.length>0&&P1(e).sent.push(...u),u})];n={fns:new Set,frame:null,seen:new Set,was:new Set,untap:()=>{for(let l of a)l()}},ir.set(e,n),Kc(e.transport).tapped++,ty(e.transport)}return n.fns.add(t),LX(new WeakRef(e),t)}function LX(e,t){return()=>{let n=e.deref(),r=n===void 0?void 0:ir.get(n);n===void 0||r===void 0||!r.fns.delete(t)||r.fns.size>0||HB(n)}}function HB(e){let t=ir.get(e);t!==void 0&&(t.untap(),ir.delete(e),Kc(e.transport).tapped--,ty(e.transport))}function P1(e){let t=ir.get(e);return t.frame!==null&&t.frame.seq===e.transport.seq||(GB(e),t.was=t.seen,t.seen=new Set,t.frame={seq:e.transport.seq,now:e.now,timestamp:e.timestamp,probed:[],pulled:[],sent:[],voices:e.voices()}),t.frame}function GB(e){let t=ir.get(e),n=t?.frame;if(!(t===void 0||n==null)){t.frame=null;for(let r of[...t.fns])r(n)}}function _X(e){try{return globalThis.structuredClone(e)}catch{return{...e}}}function UB(e,t){let n=e.history;if(n===void 0||t&&e.tape===void 0)return e.now;let r=e.pager!==null?Number.NEGATIVE_INFINITY:e.now-n.ms;return Math.max(e.born,e.floor,r)}function DX(e){let t=Kc(e);if(t.held!==null)throw new Error("blits: that mix is held already; free it first");let n=ny(e),r=n.ramp,o=n.rebase,i=n.sync,s=n.seek,a=[],l=0,u=!1,c=!1,d=e.last,f=e.last,p=g=>{let P=u;u=!0;try{g()}finally{u=P}},h=g=>{e.replaying||u?g():a.push(g)},m=()=>{e.rebasing&&!Number.isNaN(e.last)&&i.call(e,e.last),i.call(e,d)},y=[],b=e.tape;if(b!==void 0){let g=b.recordEntry;y.push(eo(b,"recordEntry",(...P)=>{u||b.timestampAt(b.undoDepth())!==void 0||g.apply(b,P)}))}y.push(eo(e,"ramp",(g,P)=>{if(!(g>=0&&g<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a mix's rate is a finite number, 0 or more, not ${g}`);h(()=>r.call(e,g,P))}),eo(e,"rebase",()=>h(()=>o.call(e))),eo(e,"seek",g=>h(()=>s.call(e,g))));for(let g of e.members){let P=ny(g).seek;y.push(eo(g,"seek",S=>{e.shared?P.call(g,S):h(()=>P.call(g,S))}))}t.held={sync(g){Number.isNaN(d)?d=g:!Number.isNaN(f)&&g>f&&(d+=(g-f)*l),f=g,m()},free:()=>w.free()},ty(e),e.woke();let x=()=>{if(c)throw new Error("blits: that hold was freed")},w={get mixes(){return[...e.members]},get now(){return e.now},get reach(){return UB(e,!0)},get rate(){return l},set rate(g){if(x(),!(g>=0&&g<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a hold's rate is a finite number, 0 or more, not ${g}`);l=g},seek(g){x(),p(()=>Xa(e,g))},step(g){if(x(),!(g>0))return;if(Number.isNaN(d))throw new Error("blits: a mix that has never synced has nothing to step");let P=Jr(e,e.now+g);if(!Number.isFinite(P))throw new RangeError("blits: the mix's own rate is 0, so it never moves");d=Math.max(d,P+e.offset),m();for(let S of e.members)S.stir()},free(){if(!c){c=!0;try{o.call(e);for(let g of a)g()}finally{for(let g of y.reverse())g();t.held=null,ty(e),e.woke()}}}};return w}var BX=1e3,Xo=class{history;shared;members=[];dropped=[];slots=0;holders=new Map;wakeFns=[];woken=!1;now=Number.NaN;seq=0;frames=new Jm;u=Number.NaN;offset=0;left=null;born=Number.NaN;floor=Number.NEGATIVE_INFINITY;last=Number.NaN;rebasing=!1;taped=Number.NEGATIVE_INFINITY;pace=null;forgotTo=Number.NEGATIVE_INFINITY;settled=Number.NEGATIVE_INFINITY;settle(){this.now>this.settled&&(this.settled=this.now)}pacedSeq=Number.POSITIVE_INFINITY;ahead=new Map;replaying=!1;announced=[];nextId=1;tape;pager;constructor(t,n){this.history=t,this.shared=n,this.tape=OL(this),this.pager=t?.store===void 0?null:new Zh(t.store)}get projecting(){return this.members.some(t=>t.projecting)}join(t,n=this.slots++){t.slot=n;let r=this.members.findIndex(o=>o.slot>n);r<0?this.members.push(t):this.members.splice(r,0,t),MF(t)}drop(t){let n=t,r=this.members.indexOf(n);if(r<0)throw new Error(`blits: ${n.name??"that mix"} is not on this transport`);this.members.splice(r,1),CF(n),n.dropped=!0,this.history!==void 0&&(this.dropped.push({mix:n,at:this.now,seq:this.seq}),Lt(this,"drop",o=>{let i=o.mix(n);i!==void 0&&o.transport(this).drop(i)}))}undrop(t){let n=this.dropped.filter(r=>r.seq>t);if(n.length!==0){this.dropped=this.dropped.filter(r=>r.seq<=t);for(let r of n)r.mix.dropped=!1,this.join(r.mix,r.mix.slot)}}seek(t){Xa(this,t)}prepare(t){return IF(this,t)}announce(t,n){if(n?.score===void 0)throw new Error("blits: a transport announces on a named score, which every mix on it sees");v1(this,t,n,-1,void 0)}marks(t,n){return wL(this,t,n).map(({order:r,...o})=>o)}project(t){return ry(this,t)}get live(){return this.members.some(t=>t.live)}get inert(){return this.members.every(t=>t.inert)}onWake(t){let n=this.wakeFns;return n.push(t),()=>{let r=n.indexOf(t);r>=0&&n.splice(r,1)}}woke(){if(!this.woken){this.woken=!0;for(let t of[...this.wakeFns])t()}}sync(t){let n=this.members;for(let r of n)r.syncing=!0;try{this.syncAt(t)}finally{for(let r of n)r.syncing=!1}}syncAt(t){if(Number.isNaN(t))throw new RangeError("blits: sync was given NaN; it takes the host clock as a number");if(t<this.last&&!this.rebasing)throw new RangeError(`blits: sync went back from ${this.last} to ${t}; the host's clock only goes forward, and seek moves the mix`);this.rebasing&&!Number.isNaN(this.last)&&(this.offset+=t-this.last),this.rebasing=!1,this.last=t;let n=t-this.offset,r=this.pace,o=r===null?n:r.sync(n),i=n!==this.u,s=i&&o===this.now;this.u=n,Number.isNaN(this.born)&&(this.born=o);let a=!1;if(this.tape!==void 0&&i&&(a=Ba(this,c=>c<=n)===n,r=this.pace,o=r===null?n:r.reading(n)),!a){this.tick(o);let c=o!==this.now;for(let d of this.members)(c||i&&r!==null&&__(d))&&Qr(d,o)}let l=this.history;this.kept();let u=this.keepsFrom();if(this.tape!==void 0&&l!==void 0&&!(u-this.taped<BX)){let c=es(this,u);c<Number.POSITIVE_INFINITY&&this.tape.prune(c),this.taped=u}if(l!==void 0&&this.dropped.length>0&&(this.dropped=this.dropped.filter(c=>c.at>=u)),this.frames.shed(u),NF(this),this.woken=!1,s)for(let c of this.members)c.frame=st(),c.lanes?.refill();for(let c of this.members){let d=c.bookers;if(d!==null)for(let f of d)f.sync()}}tick(t){let n=++this.seq;this.history!==void 0&&this.frames.push({seq:n,at:t,u:this.u});for(let r of this.members)r.looked=!1}rebase(){this.rebasing=!0,this.settle()}kept(){let t=this.history;t!==void 0&&this.pager===null&&this.now-t.ms>this.floor&&(this.floor=this.now-t.ms)}reaches(t){return this.pager!==null?t>=this.floor:t>=this.floor&&t>=this.now-(this.history?.ms??0)}keepsFrom(){let t=this.history;return t===void 0?Number.POSITIVE_INFINITY:this.pager===null?this.now-t.ms:Number.NEGATIVE_INFINITY}get rate(){return this.pace===null?1:this.pace.rateAt(this.u)}set rate(t){this.ramp(t,0)}ramp(t,n){if(!(t>=0&&t<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a mix's rate is a finite number, 0 or more, not ${t}`);if(this.pace===null){this.pace=new Qm(this.history!==void 0||this.projecting),this.pacedSeq=this.seq;for(let o of this.members)for(let i of o.cued)i.state==="pending"&&!i.placing&&i.owner===null&&i.spec.start!==void 0&&Ko(o,i,i.start)}let r=this.history===void 0?Number.NEGATIVE_INFINITY:this.keepsFrom();this.pace.change(this.u,t,n,r,this.seq);for(let o of this.members)o.stir();Lt(this,"rate",o=>o.transport(this).ramp(t,n))}};function v1(e,t,n,r,o){let i=n.at!==void 0?n.at-e.offset:e.u,s={name:t,score:n.score,tags:n.tags??[],at:i,order:e.nextId++,seq:e.seq,slot:r,mix:o};e.announced.push(s),e.settle(),Lt(e,"announce",a=>{let l=a.transport(e);l.announced.push({...s,seq:l.seq})})}function zB(e,t,n,r,o){let i=e.tape,s=i?.undoDepth()??0;try{for(;;){let a=HX(i,t,r);if(!(a<r))break;if(WB(e,t,n,a),!KB(t))continue;for(let u of t.members)u.anchored>0&&Yr(u);let l=GX(t);for(let[u,c]of n){let d=new Jo(c.kit,{...c.opts,transport:l},null);d.slot=c.slot,d.projecting=!0,d.share=c.share,A1(c,d);let f=o.get(u);f===void 0?o.set(u,{at:[c],met:new Set}):f.at.push(c),n.set(u,d)}t=l}WB(e,t,n,r)}finally{i!==void 0&&i.undoDepth()!==s&&i.goto(s)}return t}function KB(e){for(let t of e.members)for(let n of t.cued)if(n.state!=="done"&&(n.patch.step!==void 0||typeof n.spec.weight=="function"))return!0;return!1}function HX(e,t,n){let r=t.now,o=Number.POSITIVE_INFINITY,i=e?.timestampAt(e.undoDepth());if(i!==void 0&&(o=t.pace===null?i:t.pace.reading(i)),!KB(t))return o<n?o:Number.POSITIVE_INFINITY;for(let s of t.members)for(let a of s.cued){if(a.state==="done")continue;for(let u of Qi){let c=Qe(s,a,u);c!==void 0&&c>r&&c<o&&(o=c)}let l=a.spec.marks;if(l!==void 0)for(let u of Object.keys(l)){let c=Qe(s,a,u);c!==void 0&&c>r&&c<o&&(o=c)}}for(let s of t.announced){let a=t.pace===null?s.at:t.pace.at(s.at,t.u);a>r&&a<o&&(o=a)}return o<n?o:Number.POSITIVE_INFINITY}function WB(e,t,n,r){let o=e.tape,i=a=>(t.pace===null?a:t.pace.reading(a))<=r,s=o?.timestampAt(o.undoDepth());if(t.u=Jr(t,r),s!==void 0&&i(s)){for(let l of t.members)for(let u of l.cued)u.parts!==null&&(u.parts=new Map(u.parts)),u.parted!==null&&(u.parted=new Map(u.parted));let a=Ba(e,i,t,{transport:()=>t,mix:l=>n.get(l)});t.u=Math.max(a,Jr(t,r))}if(!(t.now>=r))for(let a of t.members)Qr(a,r)}function GX(e){let t=new Xo(void 0,!0);return t.offset=e.offset,t.u=e.u,t.nextId=e.nextId,t.now=e.now,t.pace=e.pace===null?null:e.pace.until(Number.POSITIVE_INFINITY),t.announced=e.announced.map(n=>({...n})),t.ahead=e.ahead,t}function A1(e,t){jc(e,t),t.cued=e.cued.filter(n=>n.state!=="done").map(n=>{let r={mix:e,voice:n,up:VB.get(n),seen:0,shared:!1,filled:!1},o=n.copy(s=>zX(r,s,t,o),void 0,!0);r.seen=o.seen,r.shared=o.sharing,VB.set(o,r);let i=e.pins?.get(n);return i!==void 0&&Ko(t,o,i),o}),t.waking=e.waking,Ha(t.cued),(e.owners!==null||e.projecting&&t.cued.some(n=>n.holding!==null))&&Ea(t.cued),Yo(t)}function jc(e,t){t.lastPoses=e.lastPoses,t.wantsPose=e.wantsPose,t.reducedNow=e.reducedNow}function oy(e,t,n){if(t.sharing){let o=ut(e,n)?.slot??-1,i=e.share;if(!i.sighted(t,o))return;let s=t.everyone;return i.open(t,s,o),s.weight=i.weightAt(t,o),s}let r=t.subjects.get(n);return r!==void 0||t.unreachedBits===null?r:Tc(t,ut(e,n)?.slot??-1)?t.unreached:void 0}var VB=new WeakMap;function UX(e,t){return e.seen===t.seen&&!t.filled&&!t.shared&&e.unreached===null&&e.unreachedBits===null}function WX(e,t,n){return e.projecting&&n.reaches&&!t.sharing&&n!==t.unreached}function VX(e){return e.restored=null,Ka(e)}function zX(e,t,n,r){let o=e.mix,i=e.voice,s=e;for(;s.up!==void 0&&UX(s.voice,s.up);)s=s.up;if(s!==e&&oy(s.mix,s.voice,t)===void 0)return;let a=oy(o,i,t);if(a===void 0)return;let l=WX(o,i,a)?VX(a):qo(i,a);return l.reaches&&!(l.since<=o.now)&&(l.since=n.sinceOf(r,l.delay),l.shown=n.shownOf(r,l.since)),l.from=l.stepped,e.filled=!0,l}function KX(e,t){let n=t.patch,r=t.spec;if(n.state!==void 0||n.step!==void 0)return"its patch keeps state";if(t.motion!==void 0)return"it plays a motion";if(t.keeping)return"its patch or its weight keeps state";if(r.from==="current")return"it starts from the pose its subjects had";if(t.written)return"its handle has been written to";if(r.anchor!==void 0)return"an anchor places it";if(t.holding!==null)return"it is an owner";if(t.owner!==null)return"it plays under an owner";if(!(typeof r.weight!="function"&&r.role===void 0&&!((t.fade.in??0)>0)&&!((t.fade.out??0)>0))&&t.slots.some(i=>e.channels[i]?.rest===void 0))return"it writes a channel with no rest at a weight that moves"}function jB(e,t){let n=`blits: reading back to ${t} needs a mix made with history`;if(e.pace!==null)throw new Error(`${n}: the mix's rate has been set`);if(t<e.settled)throw new Error(`${n}: a mix changed or a voice left at ${e.settled}, and without history a mix keeps only how it stands now`);for(let r of e.members)for(let o of r.cued){if(o.state==="done")continue;let i=KX(r,o);if(i!==void 0)throw new Error(`${n}: voice ${o.id} is cued, and ${i}`)}}function $B(e,t,n,r){jc(e,t),t.backward=!0,t.cued=e.cued.filter(o=>o.state!=="done").map(o=>{let i=o.copy(a=>N1(e,o,a,n,r));i.out!==null&&i.out.at>n&&(i.out=null);let s=e.pins?.get(o);return s!==void 0&&Ko(t,i,s),i}),Ha(t.cued),e.owners!==null&&Ea(t.cued),R1(t,n),Yo(t)}function ry(e,t){let n=e.history!==void 0,r,o;if(typeof t=="number")r=t;else{if(!n)throw new Error("blits: reading a frame back needs a mix made with history");o=ey(e,t.frame),r=o.at}let i=o!==void 0?o.seq===e.seq:Number.isNaN(e.now)||r>=e.now,s=e.pace,a={seq:e.seq,strict:!1},l=i?Jr(e,r):es(e,r);if(!i&&n){o===void 0&&qa(e,r);let m=o??e.frames.at(r);m!==void 0&&(a={seq:m.seq,strict:m.at===r},m.at===r&&(l=m.u))}else i||jB(e,r);let u=new Xo(void 0,!0);u.offset=e.offset,u.u=l,u.nextId=e.nextId,u.now=i?e.now:r,u.pace=s===null||!qt(a,e.pacedSeq)?null:s.until(i?Number.POSITIVE_INFINITY:l),u.announced=(i?e.announced:e.announced.filter(m=>qt(a,m.seq))).map(m=>({...m}));let c=new Map;for(let m of e.members){let y=new Jo(m.kit,{...m.opts,history:void 0,lanes:!1,transport:u},null);y.slot=m.slot,y.projecting=!0,y.share=m.share,y.places=m.places,c.set(m,y),i?A1(m,y):n?jX(m,y,r,a):$B(m,y,r,a)}let d=u,f=null;i&&r!==e.now&&(f=new Map,d=zB(e,u,c,r,f));let p=!i&&n?a:null,h=m=>{pe.live=!1,pe.ahead=d.ahead.size>0?d.ahead:null,pe.back=p;try{return m()}finally{pe.live=!0,pe.ahead=null,pe.back=null}};return{timestamp:r,of(m){let y=m,b=c.get(y);if(b===void 0)throw new Error("blits: that mix is not on this transport");let x=f?.get(y),w=x===void 0?null:g=>{if(!x.met.has(g)){x.met.add(g);for(let P of x.at)P.fold(g)}};return{timestamp:r,probe:(g,P)=>h(()=>(w?.(g),b.fold(g,P))),assess:g=>h(()=>(w?.(g),b.fold(g),$X(b,g)))}}}}function jX(e,t,n,r){jc(e,t),t.backward=!0;let o=Bc(e.hostLog,{seq:r.seq,strict:!1}),i=e.opts.host,s=o&&typeof i=="object"&&i!==null?Object.assign(Object.create(i),o.fields):void 0;o&&(t.hostThen=o),t.cued=[...e.cued,...e.gone].filter(a=>a.cuedSeq<=r.seq&&!qt(r,a.doneSeq,!0)).sort((a,l)=>a.id-l.id).map(a=>{let l=a.log,u=a.copy(c=>N1(e,a,c,n,r,t,u),Bc(l,r)??l[0]);if(s!==void 0&&(u.setting.host=s),a.parts!==null&&(u.parts=new Map(a.parts)),a.parted!==null&&(u.parted=new Map(a.parted)),a.left!==null&&Dm(u,a.left.after(r),r.seq),u.parted!==null)for(let[c,d]of u.parted)d.ramp===void 0||!(n<d.at)||(u.parts??=new Map,u.parts.set(c,d.ramp));return u}),Ha(t.cued),e.owners!==null&&Ea(t.cued,r.seq),R1(t,n,r),Yo(t)}function R1(e,t,n){for(let r of e.cued)r.state=r.stateAt(t,n)}function N1(e,t,n,r,o,i,s){let a=t.left?.at(n,o)??qh(t,n,oy(e,t,n),r,o.seq);if(a===void 0)return;let l=a.snaps&&Va(a.snaps,r,!0);if(l){let f=qo(t,l.held);return i!==void 0&&s!==void 0&&!(f.since<=l.at)&&Oa(i,s,f),f.from=f.stepped,f.replay=a.inputs,f}let u=i===void 0||s===void 0?a.since:i.sinceOf(s,a.delay),c=On(t,a.reaches,a.reaches&&t.patch.state?t.patch.state(n):void 0);c.delay=a.delay,c.since=u,c.shown=i===void 0||s===void 0?a.shown:i.shownOf(s,u);let d=yT(e,t,c,r);return c.rebuilt=t.rebuilds,c.from=c.stepped,c.unknown=t.spec.from==="current"||d,c.replay=a.inputs,c}function $X(e,t){let n={};for(let i of e.names)n[i]="exact";let r={exact:0,stepped:1,held:2};for(let i of e.cued){let s=i.spec.anchor;if(!(s===void 0||i.state==="done"||!(i.state==="pending"&&!Number.isFinite(i.start)||i.state!=="pending"&&i.state!=="fading"&&(s.out!==void 0||s.end!==void 0)&&!Number.isFinite(i.outAt))||!e.aims(i,t)))for(let l of i.slots)n[e.names[l]]="held"}let o=(i,s)=>{if(i.state==="done"||s.weight<=0)return;let a=YX(e,i,s);for(let l of i.slots){let u=e.names[l];r[a]>r[n[u]]&&(n[u]=a)}};for(let i=e.chain(t);i!==null;i=i.next)i.voice!==null&&o(i.voice,i);for(let i of e.sharers)i.everyone!==null&&i.state!=="pending"&&o(i,i.everyone);return n}function YX(e,t,n){let r=t.spec.weight;if(n.unknown)return"held";let o=n.replay!==void 0&&Va(n.replay,e.now,!0)!==void 0;if(typeof r=="function"&&r.input&&!o||t.owner!==null&&ZF(t))return"held";let i=t.patch.reads;if(i!==void 0&&i.length>0){let s=e.hostThen?.fields;if(s===void 0||!i.every(a=>a in s))return"held"}if(e.now>(n.from??e.now)){let s=Lo(e,t)!==void 0,a=n.kept!==null&&n.kept.size>0&&!o&&e.backward;if(t.patch.step&&!s||a)return"stepped"}return n.copied&&n.kept!==null&&n.kept.size>0&&!o?"stepped":"exact"}var iy=class{list=[];from=0;push(t,n){this.list.length>=64&&(this.list=this.list.slice(32),this.from+=32),this.from+this.list.length!==n-1&&(this.list=[],this.from=n-1),this.list.push(t)}patch(t,n,r,o,i){if(!(n>=this.from))return;let s=this.list;for(let a=n-this.from;a<s.length;a++){let l=s[a];if(l==null)return;let u=null,c=t;for(;c!==null&&c.voice.id<l.id;)u=c,c=c.next;let d=c!==null&&c.voice===l?c:null,f=r.linkable(l,o,i);if(f===d)continue;let p=d===null?c:d.next;f!==null&&(f.voice=l,f.next=p);let h=f??p;u===null?t=h:u.next=h}return t}};function YB(e){this.restStamps??=new me;let t=this.linked(e),n=this.linkedLaned,r=this.lanes;if(n&&this.restsLaned()){let s=t.slot;if(!r.owes(s))return r.rests(s)}let o=(this.restStamps.get(e)??Number.NaN)-2*this.restsKey();if(o>=0)return o===1;this.restScratch??=this.pose();let i=this.foldWith(e,this.restScratch,t,n,!0);return this.rests(this.bounded.length===0?i:this.clamp(i))}function qB(e){for(let t=0;t<this.names.length;t++){let n=this.channels[t],r=e[this.names[t]];if(n.rest===void 0){if(r!==void 0)return!1}else if(!Ic(r,n.rest))return!1}return!0}function XB(){return this.pace?.stopped(this.u)?this.cued.every(e=>e.state==="done"||e.state!=="pending"&&typeof e.spec.weight!="function"&&e.spec.anchor===void 0):this.cued.every(e=>this.still(e,this.now))}function JB(e,t){if(e.state==="done")return!0;if(e.state!=="frozen"&&e.state!=="live"||typeof e.spec.weight=="function"||e.parts!==null)return!1;let n=this.reducedNow?0:e.fade.in??0;if(n>0&&t-this.sinceOf(e,e.latest)<n)return!1;if(e.state==="frozen"||e.holding!==null)return!0;let r=e.motion;if(r===void 0||!(e.elapsedAt(t)>=e.latest))return!1;let o=e.early;if(o!==null){for(let i of o)if(i.since<=t&&!(i.probed>=i.since))return!1}return r.landed()}function QB(){return this.lanes.whole&&this.bounded.length===0}function ZB(){return(this.frame!==this.restsFrame||this.version!==this.restsVersion||this.relinks!==this.restsRelinks||this.stirs!==this.restsStirs)&&(this.restsEpoch++,this.restsFrame=this.frame,this.restsVersion=this.version,this.restsRelinks=this.relinks,this.restsStirs=this.stirs),this.restsEpoch}function e3(e){return{n:0,voices:[],helds:[],deltas:[],weights:[],groups:[],names:[],m:0,mVoices:[],mDeltas:[],mWeights:[],mGroups:[],values:new Array(e).fill(void 0),taken:new Float64Array(e),heaviest:new Float64Array(e),met:new Uint8Array(e),touched:[],owned:new Array(e).fill(void 0)}}function qX(e,t,n,r){let o=e.owned[t];o===void 0&&(o=r.slice(),e.owned[t]=o);for(let i=0;i<o.length;i++)o[i]=i<n.length?n[i]:r[i];return o}function t3(e,t){e.touched.length=0;let n=0;for(let o=0;o<e.m;o++)e.mGroups[o]===t&&(n+=e.mWeights[o]);if(n<=0)return 0;let r=e.taken;for(let o=0;o<e.m;o++){if(e.mGroups[o]!==t)continue;let i=e.mWeights[o];if(i<=0)continue;let s=e.mDeltas[o],a=e.mVoices[o].slots;for(let l=0;l<a.length;l++){let u=a[l],c=s[this.names[u]];if(c===void 0)continue;let d=this.channels[u];if(e.met[u]===0){e.met[u]=1,e.touched.push(u),r[u]=i,e.heaviest[u]=i,e.values[u]=this.lerpsInto[u]!==void 0&&d.scale&&Array.isArray(c)?qX(e,u,c,d.rest):$i(c);continue}let f=r[u]+i;if(r[u]=f,d.kind==="last"){i>=e.heaviest[u]&&(e.heaviest[u]=i,e.values[u]=$i(c));continue}let p=e.values[u],h=this.lerpsInto[u];e.values[u]=h!==void 0&&p===e.owned[u]?h(p,p,c,i/f):d.lerp(p,c,i/f)}}for(let o=0;o<e.touched.length;o++)e.met[e.touched[o]]=0;return n>1?1:n}function XX(e,t,n){return e===null?!1:n>=t.length||e.voice===null?!0:t[n].id>e.voice.id}function n3(e,t,n,r,o,i,s){let a=this.now,l=this.roleScratch[this.roleDepth];l===void 0&&(l=e3(this.channels.length),this.roleScratch[this.roleDepth]=l),this.roleDepth++;try{l.n=0,l.m=0,l.names.length=0;let u=this.sharers,c=0,d=n;for(;d!==null||c<u.length;){let p=XX(d,u,c),h,m;if(p?(m=d,h=m.voice,d=m.next):(h=u[c++],m=h.state==="pending"?null:h.everyone),h===null||m===null||r&&h.laned&&!this.owedBy(s,h)||h.id===i||h.state==="done")continue;let y=m;p||this.share.open(h,y,n.slot);let b=this.read(h,e,a,o,y);s>=0&&h.laned&&this.lanes.paid(h.id,s,y.weight),p||(c=this.shared(h,n.slot,y,c));let x=h.spec.role;if(b===null){x===void 0&&!(y.weight>0)&&kt(y);continue}let w=-1;if(x!==void 0){w=l.names.indexOf(x);let P=l.m++;if(l.mVoices[P]=h,l.mDeltas[P]=b,l.mWeights[P]=this.w,w>=0){l.mGroups[P]=w;continue}w=l.names.length,l.names.push(x),l.mGroups[P]=w}let g=l.n++;l.voices[g]=h,l.helds[g]=y,l.deltas[g]=b,l.weights[g]=x===void 0?this.w:0,l.groups[g]=w}let f=n.roles;f===null&&(f=new Map,n.roles=f);for(let p=0;p<l.n;p++){let h=l.groups[p];if(h<0){let x=l.weights[p];x>0?this.apply(t,l.voices[p],l.helds[p],l.deltas[p],x):kt(l.helds[p]);continue}let m=this.foldRole(l,h),y=l.names[h];if(!(m>0)){f.get(y)?.fill(2);continue}let b=f.get(y);b===void 0&&(b=new Uint8Array(this.channels.length),f.set(y,b));for(let x=0;x<l.touched.length;x++){let w=l.touched[x],g=l.values[w];l.values[w]=void 0;let P=this.names[w],S=this.channels[w],v=l.taken[w],A=v>1?1:v;if(S.rest!==void 0&&S.scale){t[P]=S.fold?S.fold(t[P],g,A):Nc(S,t[P],S.scale(g,A));continue}let N=b[w],M=this.passes(N===0?void 0:N===1,A);b[w]=M?1:2,M&&(t[P]=t[P]===void 0?$i(g):Nc(S,t[P],g))}}return t}finally{for(let u=0;u<l.n;u++)l.voices[u]=null,l.helds[u]=null,l.deltas[u]=null;for(let u=0;u<l.m;u++)l.mVoices[u]=null,l.mDeltas[u]=null;for(let u=0;u<l.touched.length;u++){let c=l.touched[u];l.met[c]=0,l.values[c]=void 0}l.touched.length=0,this.roleDepth--}}function r3(e,t){if(e.frame=st(),t===void 0)for(let n of e.cued)n.motion===void 0&&n.holding===null&&(n.seeks++,n.touches++);else{let n=ut(e,t)??null;for(;n!==null;n=n.next)n.seeks=-1;let r=ut(e,t)?.slot??-1;for(let o of e.sharers)e.share?.restamp(o,r)}e.lanes?.refill(),e.stir()}var JX=1e-6,QX=(e,t)=>Math.abs(e-t)<=1e-6*Math.max(1,Math.abs(e),Math.abs(t));function o3(e,t,n,r={}){if(!(t<=n)||!Number.isFinite(t)||!Number.isFinite(n))throw new RangeError(`blits: a trace runs from a time to one no earlier, not ${t} to ${n}`);let o=r.grid??5;if(!(o>0&&o<Number.POSITIVE_INFINITY))throw new RangeError(`blits: a trace's grid is a finite number of ms above 0, not ${o}`);let i=ZX(e,t),s=new Map,a=new Map,l=new Map,u=(c,d)=>{let f=a.get(c);f===void 0&&(f=new Map,a.set(c,f));let p=f.get(d);if(p===void 0){let h=s.get(d);h===void 0&&(h=e.project(d),s.set(d,h)),p=h.probe(c,e.pose()),f.set(d,p)}return p};return{from:t,to:n,of(c,d){let f=d,p=e.slotOf.get(f);if(p===void 0)throw new Error(`blits: the mix has no channel ${f}`);let h=N=>{let M=u(c,N)[f];return typeof M=="number"?M:Number.NaN},m=l.get(c);m===void 0&&(m=e9(e,c,t,n),l.set(c,m));let y=e.scalars[p],b=i&&!m.unknown.has(p)&&!e.bounded.includes(p)&&(y==="sum"||y==="mul"&&(m.writers.get(p)??0)<=1),x=m.bent.get(p),w=(N,M)=>b&&(x===void 0||x.every(([C,F])=>!(C<M&&F>N)));if(t===n)return{at:[t],value:[h(t)],exact:b};let g=[],P=[],S=!0,v=(N,M)=>{let C=g.length;C>0&&g[C-1]===N&&QX(P[C-1],M)?P[C-1]=M:(g.push(N),P.push(M))},A=[t,...m.knots.get(p)??[],n];for(let N=0;N+1<A.length;N++){let M=A[N],C=A[N+1];if(w(M,C)){let D=M+(C-M)/3,B=C-(C-M)/3,K=h(D),W=(h(B)-K)/(B-D);v(M,K-W*(D-M)),v(C,K+W*(C-D));continue}S=!1;let F=Math.min(JX,(C-M)/4);v(M,h(M===t?M:M+F));for(let D=Math.max(0,Math.ceil((M-t)/o));;D++){let B=t+D*o;if(B>=C-F)break;B>M+F&&v(B,h(B))}v(C,h(C===n?C:C-F))}return{at:g,value:P,exact:S}}}}function ZX(e,t){let n=e.transport;if(!(t>=e.now))return!1;let r=n.tape;return r===void 0||r.timestampAt(r.undoDepth())===void 0}function e9(e,t,n,r){let o={knots:new Map,bent:new Map,unknown:new Set,writers:new Map};for(let i of e.cued)if(!(i.state==="done"||!e.aims(i,t))&&!n9(e,i,t,n,r,o))for(let s of i.slots)o.unknown.add(s);for(let[i,s]of o.knots)o.knots.set(i,s.sort((a,l)=>a-l).filter((a,l,u)=>l===0||a!==u[l-1]));return o}var t9=4096;function n9(e,t,n,r,o,i){let s=t.spec,a=t.built,l=t.patch;if(l.form!=="keys"||a===null||l.step!==void 0||typeof s.weight=="function"||t.owner!==null||t.holding!==null||t.fitting!==null||t.arc!==null||t.blend!==null||s.anchor!==void 0||s.role!==void 0||s.within!==void 0||s.stepMs!==void 0||s.from!==void 0||t.ramp!==null||!(t.rate>0)||t.out!==null||t.back!==null||t.stalls!==null||t.parts!==null||t.parted!==null||t.left!==null||Number.isFinite(t.outAt)||t.state==="fading"||t.state==="pending"&&e.transport.pace!==null)return!1;let u=[],c=[],d=new Map,f=P=>{P>r&&P<o&&u.push(P)},p=e.reduced,h=t.sharing?void 0:t.subjects.get(n),m=h?.delay??(s.stagger?s.stagger(n):0),y=P=>t.timeAt(P+m),b=p?0:t.fade.in??0;if(b>0){if(h===void 0)return!1;h.shown+b>r&&(c.push([h.shown,h.shown+b]),f(h.shown),f(h.shown+b))}let x=t.duration,w=t.span;f(t.start),f(y(0)),Number.isFinite(w)&&f(y(w));let g=t.endsAt();if(f(g),!t.freezesAfter&&Number.isFinite(g)){let P=p?0:Number.isNaN(t.outOver)?t.fade.out??0:t.outOver,S=Math.max(t.start,g);f(S),P>0&&(c.push([S,S+P]),f(S+P)),s.stagger!==void 0&&c.push([y(w),Number.POSITIVE_INFINITY])}if(x>0){let P=Math.max(0,Math.floor((t.elapsedAt(r)-m)/x)),S=Math.min(Math.ceil(t.passes)-1,Math.floor((t.elapsedAt(o)-m)/x)),v=0;for(let A of a.tracks)v+=A.all.length+1;if((S-P+1)*v>t9)return!1;for(let A=P;A<=S;A++){let N=A*x;f(y(N)),f(y(N+x));for(let M of a.tracks){let C=e.slotOf.get(M.channel);if(M.numbers===null)return!1;let F=M.delay;if(F>=x)continue;F>0&&f(y(N+F));let D=Number.NaN;for(let B of M.all){let K=y(N+F+Math.min(1,Math.max(0,B.at))*(x-F));if(f(K),!Number.isNaN(D)&&!fF(B.ease)){let W=d.get(C);W===void 0?d.set(C,[[D,K]]):W.push([D,K])}D=K}}}}for(let P of t.slots){let S=i.knots.get(P);S===void 0?i.knots.set(P,[...u]):S.push(...u),i.writers.set(P,(i.writers.get(P)??0)+1);let v=[...c,...d.get(P)??[]];if(v.length===0)continue;let A=i.bent.get(P);A===void 0?i.bent.set(P,v):A.push(...v)}return!0}function i3(e,t){let n=this.primed[0],r=this.primed[1],o=this.primed[2],i=e.setting;i.timestamp=n,e.patch.step===void 0&&t.probed<n&&(t.stepped=t.probed),i.dt=this.capped(n-t.stepped),i.elapsed=r,i.pass=o,i.weight=0,i.state=t.state,i.mark=0,e.keepOn=t}function s3(e,t,n){let r=this.now,o=e.setting;o.mark!==n[6]&&r9(o,r,n),e.patch.step===void 0&&t.probed<r&&(t.stepped=t.probed),o.dt=this.capped(r-t.stepped),o.weight=0,o.state=t.state,e.keepOn=t}function r9(e,t,n){e.timestamp=t,e.elapsed=n[1],e.pass=n[3],e.mark=n[6]}function a3(e){let t=this.opts.maxDt;return this.reducedNow?Number.POSITIVE_INFINITY:t!==void 0&&e>t?t:e}function l3(e,t,n){let r=this.opts.history;return r===void 0?Number.POSITIVE_INFINITY:$T(this,e,n-r.ms)-t}function u3(e,t,n){return Ta(e.fade.in??0,e.out,e.ease,this.reducedNow,t,n,e.back,e.stalls)}function c3(e,t){return eL(e,this.now,this.reducedNow,n=>this.ownerBase(n,t))}function d3(e,t){let n=this.now,r=this.held(e,t,-1);if(r.probed===this.frame)return r.phase;let o=pe.kept;r.probed=Number.NaN;let i=this.primed;i[0]=n,i[1]=e.elapsedAt(n),i[2]=0,this.prime(e,r);let s=this.base(e,t,n,r);return pe.kept=o,r.stepped=n,r.probed=this.frame,r.phase=s,s}function f3(e,t,n,r){if(e.owner!==null)return this.weighOwned(e,t,n,r);let o=this.base(e,t,n,r),i=this.envelope(e,n,r.shown);return Yt(o,i,e.parts===null?1:this.parting(e,t,n))}function p3(e,t,n,r){let o=this.ownedBy(e,t),i=this.base(e,t,n,r),s=this.envelope(e,n,r.shown)*o;return Yt(i,s,e.parts===null?1:this.parting(e,t,n))}function h3(e,t,n,r,o=-1){this.sending.voice=e,this.sending.subject=t;let i=typeof e.spec.weight=="function"?e.spec.weight:null;if(i===null)return e.weight;let s=r.replay&&Va(r.replay,n,!0),a=s?s.value:e.blend===null?i(t,e.setting):this.blended(e,t,r,o);return i.input&&!s&&Fm(this,e,t,r,a),a}var o9={lanes:!0},Jo=class{kit;opts;lanesOf;cued=[];gone=[];goneIx=new pm;scored=new tm;projecting=!1;backward=!1;moving=!1;looked=!1;hostLog=[];hostThen;lastPoses=new me;transport;slot=-1;dropped=!1;name;frame=st();pins=null;wantsPose=!1;scratch;due=new Xh;retired=[];walkAll=!1;leapt=null;pulled=[];pulledHeads=[];pulledSlots=new Int32Array(0);pulledVersion=Number.NaN;pulledRelinks=-1;pullColumns=null;relinks=0;reducedNow=!1;stirred=!1;asleep=!1;waking=!1;stirs=0;syncing=!1;stirFns=null;stir(){if(this.stirs++,this.moving||this.transport.settle(),this.stirred||(this.stirred=!0,this.syncing))return;let t=this.stirFns;if(t!==null)for(let n of[...t])n();this.transport.woke()}onWake(t){this.stirFns===null&&(this.stirFns=[]);let n=this.stirFns;return n.push(t),()=>{let r=n.indexOf(t);r>=0&&n.splice(r,1)}}chains=new me;version=0;places=null;primed=new Float64Array(3);steps=new iy;named=new me;parters=new Set;departed=new gm;strays=new me;strayAll=new Set;playing=new Map;naming=0;general=[];sharers=[];unshared=!1;detours=0;roleVoices=0;roleTags;owner=null;anchored=0;sent=[];sending={voice:null,subject:void 0};send=t=>{let{voice:n,subject:r}=this.sending;n===null||this.projecting||n.setting.timestamp<=this.sentTo||this.sent.push({timestamp:n.setting.timestamp,subject:r,voice:n.id,tags:n.spec.tags??fn,event:t})};sentTo=Number.NEGATIVE_INFINITY;w=0;names;channels;bounded;lerpsInto;scalars;roleScratch=[];roleDepth=0;slotOf=new Map;lanes;share;handles=null;bookers=null;fitting=null;arcing=null;owners=null;keys=null;outs=null;pose;constructor(t,n,r){if(this.kit=t,this.opts=n,this.lanesOf=r,this.names=Object.keys(t),this.channels=this.names.map(i=>t[i]),this.bounded=this.channels.flatMap((i,s)=>i.bounds?[s]:[]),this.lerpsInto=this.channels.map(i=>Wh(i)),this.pose=iD(this.names,this.channels),this.scalars=this.channels.map(i=>YO(i)),this.names.forEach((i,s)=>{this.slotOf.set(i,s)}),r===null&&n.lanes===!0)throw new Error("blits: '@msb235/blits/lean' has no lanes; take mix from '@msb235/blits'");this.share=r?.share??null,this.lanes=r!==null&&(n.lanes??o9.lanes)?new r(wm(this)):null,this.name=n.name,this.roleTags=R_(n);let o=n.transport;if(o!==void 0){if(n.history!==void 0)throw new Error("blits: a mix on a transport keeps the history the transport keeps, not its own");this.opts={...n,history:o.history},this.transport=o}else this.transport=new Xo(n.history,!1);this.transport.pager!==null&&(this.keys=new em(n.keyOf),this.outs=new Cm,o!==void 0&&s9(o,n.name)),this.transport.join(this)}own(t){if(this.transport.shared)throw new Error(`blits: ${this.name??"this mix"} plays on a transport, so ${t} goes to the transport`);return this.transport}get now(){return this.transport.now}set now(t){this.transport.now=t}get u(){return this.transport.u}set u(t){this.transport.u=t}get offset(){return this.transport.offset}set offset(t){this.transport.offset=t}get pace(){return this.transport.pace}set pace(t){this.transport.pace=t}get announced(){return this.transport.announced}set announced(t){this.transport.announced=t}get nextId(){return this.transport.nextId}set nextId(t){this.transport.nextId=t}get timestamp(){return this.transport.last}get seq(){return this.transport.seq}get last(){return this.transport.last}get tape(){return this.transport.tape}get replaying(){return this.transport.replaying}get reduced(){let t=this.opts.reduce;return typeof t=="function"?t():t===!0}get band(){return this.opts.band??VO}cue(t){this.attached();let n=this.opts.engine;if(n!==void 0&&!n.runs.has(t.patch.form))throw new Error(`blits: engine ${n.name} does not run ${t.patch.form} patches`);return A_(this,t)}blend(t,n,r={}){let o=`blend:${this.nextId}`,i=Rc(n,t.length-1);return t.map((s,a)=>{let l={...r,patch:s,weight:n,role:o};"patch"in s&&(l.patch=s.patch,s.name!==void 0&&(l.name=s.name),s.tags!==void 0&&(l.tags=s.tags),s.hits!==void 0&&(l.hits=s.hits));let u=this.cue(l),c=this.cued[this.cued.length-1];return c.blend={of:i,i:a},i.members.push(c),u})}owns(t){if(t.loop!==void 0)throw new Error("blits: an owner does not loop: a pass would have to restart its children");return this.cue({...t,patch:Xi})}span(t){if((t.rate??1)<0)throw new Error("blits: a span lays out its children forward from its start, so it is not cued backward");this.fitting=new Om(t);try{let n=this.owns(t);return Dn(this,this.owners?.find(r=>r.handle===n)),n}finally{this.fitting=null}}arc(t){return oD(this,t)}sync(t){this.own("sync").sync(t)}book(t){return GL(this,t)}probe(t,n){this.looked=!0;let r=this.fold(t,n);return this.keep(t,r,n),this.restStamps!==null&&!(this.linkedLaned&&this.restsLaned())&&this.restStamps.set(t,2*this.restsKey()+(this.rests(r)?1:0)),r}pull(t,n){this.looked=!0,SD(this,t,n)}seek(t){if(this.projecting)throw new Error("blits: a projection does not seek");Xa(this.own("seek"),t)}prepare(t){return this.own("prepare").prepare(t)}project(t){return ry(this.transport,t).of(this)}trace(t,n,r){return o3(this,t,n,r)}announce(t,n={}){this.attached(),v1(this.transport,t,n,this.slot,this.name)}attached(){if(this.dropped)throw new Error(`blits: ${this.name??"this mix"} was dropped from its transport`)}marks(t,n){return mm(this,t,n).map(({order:r,...o})=>o)}rebase(){this.own("rebase").rebase()}voices(t){let n=[];for(let r of this.cued)r.state!=="done"&&(t===void 0||r.spec.tags?.includes(t))&&n.push(r.handle);return n}get live(){return this.cued.some(t=>t.state!=="done")}get inert(){if(this.stirred)return!1;let t=this.restful();return t&&!Number.isNaN(this.now)&&(this.asleep=!0),t}get rate(){return this.transport.rate}set rate(t){this.own("rate").ramp(t,0)}ramp(t,n){this.own("ramp").ramp(t,n)}close(){BB(this)}mute(t){for(let n of this.cued)n.written=!0,Zr(this,n,{over:t?.over});Lt(this,"mute",n=>n.mix(this)?.mute(t))}touch(t){this.attached(),r3(this,t)}drain(t){let n=this.sent;if(n.length===0)return[];let r=n;if(t===void 0)this.sent=[];else{r=[];let o=[];for(let i of n)(i.tags.includes(t)?r:o).push(i);this.sent=o}return r.sort((o,i)=>o.timestamp-i.timestamp)}folding=new Set;linkedLaned=!1;restStamps=null;restsEpoch=0;restsFrame=Number.NaN;restsVersion=Number.NaN;restsRelinks=-1;restsStirs=-1;restScratch},i9={fold:t_,folded:n_,linked:r_,foldWith:o_,owedBy:a_,foldRoles:n3,foldDetour:i_,foldSharers:s_,shared:e_,read:gD,contribution:cD,keyed:dD,tick:pD,apply:QL,clamp:ZL,passes:JL,isRest:yD,baseFor:hD,slopeFor:mD,prime:i3,primeLaned:s3,capped:a3,horizonFor:l3,weigh:f3,weighOwned:p3,base:h3,envelope:u3,ownedBy:c3,ownerBase:d3,blended:KL,laneRead:jL,shareKept:$L,parting:Z_,chain:gF,relink:bF,linkable:xF,aims:wF,held:aL,unreachedOf:sL,sinceOf:lL,shownOf:uL,keep:TD,foldRole:t3,atRest:YB,rests:qB,restful:XB,still:JB,restsLaned:QB,restsKey:ZB,plot:kB,place:vB,moved:RB,put:NB,around:XL,drop:bD,forgetIn:xD,releaseIn:wD,recordDrop:PD};for(let[e,t]of Object.entries(i9))Object.defineProperty(Jo.prototype,e,{value:t,writable:!0,configurable:!0});function s9(e,t){if(t===void 0)throw new Error("blits: a mix on a transport whose history has a store needs a name, which its records are keyed by");if([...e.members,...e.dropped.map(r=>r.mix)].some(r=>r.name===t))throw new Error(`blits: a mix named ${t} is already on this transport, or a seek could bring it back`)}function a9(e,t,n){let{history:r,added:o}=LB(t),i=new Jo(e,o?{...t,history:r}:t,n);return o&&_B(i.transport),DB(i),i}var m3={name:"mixer",runs:new Set(["fn","keys","motion"]),create(e,t){return a9(e,t,Wc)}};function I1(e,t={}){return(t.engine??m3).create(e,t)}function sy(e,t,n){for(let r=t;r!=null;r=n(r))if(e.has(r))return r;return null}function $c(e,t){if(e.length<2)return e;let n=new Set(e),r=o=>{let i=t(o);return i!=null&&sy(n,i,t)!==null};return e.some(r)?e.filter(o=>!r(o)):e}Z();var Ja={getBounds:e=>et(e),remapBounds:(e,t,n)=>Nt(e,mr(t.x,t.y,t.width,t.height,n.x,n.y,n.width,n.height)),fromBounds:e=>({kind:"rect",x:e.x,y:e.y,width:e.width,height:e.height}),translate:(e,t,n)=>sb(e,t,n),lerp:(e,t,n)=>{if(e.kind==="rect"&&t.kind==="rect")return{kind:"rect",x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n,width:e.width+(t.width-e.width)*n,height:e.height+(t.height-e.height)*n};if(e.kind==="polygon"&&t.kind==="polygon"&&e.coords.length===t.coords.length){let r=qe(e),o=qe(t),i=new Float64Array(r.length);for(let c=0;c<r.length;c++)i[c]=r[c]+(o[c]-r[c])*n;let s=At(e.origin,i),{corners:a,...l}=e,u=_g(e.corners,t.corners,n);return u?{...l,coords:s,corners:u}:{...l,coords:s}}throw new Error("pathPoseDescriptor.lerp: incompatible path shapes")},axes:e=>e.kind==="rect"?{count:4,names:["x","y","width","height"],to:t=>t.kind==="rect"?[t.x,t.y,t.width,t.height]:[],from:t=>({kind:"rect",x:t[0],y:t[1],width:t[2],height:t[3]}),add:(t,n)=>t.kind!=="rect"?t:{kind:"rect",x:t.x+n[0],y:t.y+n[1],width:t.width+n[2],height:t.height+n[3]},write:(t,n,r)=>{t.kind==="rect"&&(n[r]=t.x,n[r+1]=t.y,n[r+2]=t.width,n[r+3]=t.height)}}:{count:e.coords.length,to:t=>t.kind==="polygon"?Array.from(qe(t)):[],from:t=>({...e,coords:At(e.origin,t)}),add:(t,n)=>{if(t.kind!=="polygon")return t;let r=Float64Array.from(qe(t));for(let o=0;o<r.length;o++)r[o]+=n[o];return{...e,coords:At(e.origin,r)}},write:(t,n,r)=>{if(t.kind!=="polygon")return;let o=qe(t);for(let i=0;i<o.length;i++)n[r+i]=o[i]}},supportsRotation:()=>!1};function sr(e){return!!e&&typeof e=="object"&&"kind"in e&&(e.kind==="polygon"||e.kind==="rect")}function Qa(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"}var Qo={getBounds:e=>sr(e)?Ja.getBounds(e):Ot.getBounds(e),remapBounds:(e,t,n)=>sr(e)?Ja.remapBounds(e,t,n):Ot.remapBounds(e,t,n),fromBounds:(e,t)=>sr(t)?Ja.fromBounds(e,t):Ot.fromBounds(e,t),translate:(e,t,n)=>sr(e)?Ja.translate(e,t,n):Ot.translate(e,t,n),axes:e=>Qa(e)?Ot.axes(e):sr(e)?Ja.axes(e):null,getRotation:e=>{if(sr(e))return 0;let t=e.rotation;return typeof t=="number"?t:0},supportsRotation:e=>!sr(e),withRotation:(e,t)=>sr(e)?e:{...e,rotation:t}};function y3(e){return t=>wa(e,t)}function g3(e,t){let n=y3(e);return(r,o,i,s)=>{let a=s?.inherited??n(r);return a===void 0?t(r,o,i,s):t(r,o,i,{...s,inherited:a})}}function b3(e,t){let n=y3(e);return(r,o,i,s)=>{let a=s?.inherited??n(r);return t(r,o,i,a===void 0?s:{...s,inherited:a})}}Z();function E1(e,t){switch(e){case"union":return gp(...t);case"intersect":return e0(...t);case"exclude":return n0(...t);case"subtract":{let n=t.length===2?t[1]:gp(...t.slice(1));return t0(t[0],n)}}}var M1="kit:booleanOfChildren",u9=new Set(["union","intersect","subtract","exclude"]);function x3(e){let t=e?.boolean;return typeof t=="string"&&u9.has(t)?t:"union"}var w3=e=>e.path;function P3(e){w3=e}function c9(e){if(e.node.kind!=="group")return w3(e);let t=T3(e.children??[]);return t.length<=1?t[0]??null:E1("union",t)}function T3(e){let t=[];for(let n of e){if(n===void 0||n.node.hidden===!0)continue;let r=c9(n);r!==null&&t.push(r)}return t}function C1(e,t){let n=T3(t);if(n.length===0)return null;let r=x3(e.data);return n.length===1&&r!=="subtract"?n[0]:E1(r,n)}Z();var Za="shape:paint";function ay(e){return(e.dependsOn?.length??0)>0&&e.derivePath!==void 0}Z();Pe();Pe();Z();Zu.subscribe(dc);function ar(e,t){if(e===null)return{outset:0,inset:0};let n=Cu(e),r=(l,u)=>{switch(e.align??"center"){case"inner":return{outset:u,inset:l};case"outer":return{outset:l+u,inset:0};default:return{outset:l/2+u,inset:l/2}}},o=e.width??1,i=Ni(typeof o=="object"?0:at(o,t??1),e.vertexWidths),s=r(i,n.world);if(typeof o!="object"&&!(n.px>0))return s;let a=r(typeof o=="object"?o.px:0,n.px);return{outset:s.outset,inset:s.inset,outsetPx:a.outset,insetPx:a.inset}}function el(e){return e?.trim===void 0?{}:{trim:e.trim}}function d9(e,t){let n=ar(e,t);return n.outset+(n.outsetPx??0)/(t>0?t:1)}function ly(e,t){let n=t?.scale??1,r=t?.screen;if(!r){let d=d9(e,n);return{x:d,y:d}}let o=ar(e,n),i=o.outsetPx??0;if(i===0)return{x:o.outset,y:o.outset};let[s,a,l,u]=r,c=Math.abs(s*u-a*l);return c>0?{x:o.outset+i*Math.hypot(l,u)/c,y:o.outset+i*Math.hypot(s,a)/c}:{x:o.outset,y:o.outset}}function tl(e,t){let n=t?.vertexColors,r=e[0];if(n===void 0||r?.kind!=="path")return e;let o=4*ab(r.path),i=r.fill?n("fill",r.vertexColors):void 0,s=r.stroke?n("stroke",r.stroke.vertexColors):void 0,a=i?.length===o&&i!==r.vertexColors,l=s?.length===o&&s!==r.stroke?.vertexColors;return!a&&!l?e:[{...r,...a?{vertexColors:i}:{},...l?{stroke:{...r.stroke,vertexColors:s}}:{}},...e.slice(1)]}function O1(e,t){let n=t?.trim;if(n===void 0||e.kind!=="path"||!e.stroke)return e;let r=e.stroke.trim,o=n(r);if(o===r||Tr(o)===Tr(r))return e;let{trim:i,...s}=e.stroke;return{...e,stroke:o===void 0?s:{...s,trim:o}}}function nl(e,t){let n=e[0];if(t?.trim===void 0||n===void 0)return e;let r=O1(n,t);return r===n?e:[r,...e.slice(1)]}function F1(e,t){let n=Ne(e.stroke,t?.stroke),r=Ie(e.fill,t?.fill);return n!==null?{fill:r,stroke:n}:{fill:r}}function _1(e,t,n,r){let{sized:o,spaces:i}=r?p9(e,t,r):f9(t,n),s=at(o.width??1,1);if(!(s>0))return null;let a=new L1,l=t.align??"center";if(l!=="inner"){let u=l==="outer"?2:1,c=Xs(o,s),d=Ei(e,{...o,width:s*u,align:"center",vertexWidths:t.vertexWidths?.map(m=>iu(m,u))},{startInset:S3(c.start,i.start,i.ribbon),endInset:S3(c.end,i.end,i.ribbon),...i.ribbon?{metric:i.ribbon.metric}:{}}),f=d.vertices,p=d.origin?.x??0,h=d.origin?.y??0;for(let m=0;m+1<f.length;m+=2)a.add(f[m]+p,f[m+1]+h,0)}for(let{entry:u,path:c,size:d}of Mu(e,o,s,void 0,i)){let f=et(c),p=u.outline?u.outline.width*d/2:0;a.add(f.x,f.y,p),a.add(f.x+f.width,f.y+f.height,p)}return a.bounds()}function f9(e,t){return{sized:{...e,width:at(e.width??1,t)},spaces:{}}}function p9(e,t,[n,r,o,i]){let s=new Float32Array([n,r,0,o,i,0,0,0,1]),{cmd:a,spaces:l}=ec(s,{kind:"path",path:e,stroke:t});return{sized:a.stroke,spaces:l}}function S3(e,t,n){return t?.metric===n?.metric?e:{length:e,metric:t?.metric??null}}var L1=class{x0=1/0;y0=1/0;x1=-1/0;y1=-1/0;add(t,n,r){this.x0=Math.min(this.x0,t-r),this.y0=Math.min(this.y0,n-r),this.x1=Math.max(this.x1,t+r),this.y1=Math.max(this.y1,n+r)}bounds(){return this.x0===1/0?null:{x:this.x0,y:this.y0,width:this.x1-this.x0,height:this.y1-this.y0}}},h9="shape:drawn";function k3(e,t,n){let r=v3(e);if(!t)return r;let o=ly(t,n);return{x:r.x-o.x,y:r.y-o.y,width:r.width+2*o.x,height:r.height+2*o.y}}function uy(e,t,n,r,o){let i=v3(t);if(n===null)return i;let s=r?.scale??1,a=r?.screen,l=rt(e,h9,void 0,()=>({width:NaN,height:NaN,scale:NaN,screen:void 0,box:null}));if(l.width!==t.width||l.height!==t.height||l.scale!==s||!m9(l.screen,a)){let p={x:0,y:0,width:t.width,height:t.height};l.width=t.width,l.height=t.height,l.scale=s,l.screen=a,l.box=_1(o(p),n,s,a)}if(l.box===null)return i;let u=Math.min(i.x,t.x+l.box.x),c=Math.min(i.y,t.y+l.box.y),d=Math.max(i.x+i.width,t.x+l.box.x+l.box.width),f=Math.max(i.y+i.height,t.y+l.box.y+l.box.height);return{x:u,y:c,width:d-u,height:f-c}}function m9(e,t){return e===t?!0:!!e&&!!t&&e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]}function v3(e){return{x:Math.min(e.x,e.x+e.width),y:Math.min(e.y,e.y+e.height),width:Math.abs(e.width),height:Math.abs(e.height)}}Pe();function A3(e,t,n,r){let o=et(e),i=t&&Kt(t,o),s=n&&Wi(n,o);return{kind:"path",path:e,...i?{fill:i}:{},...i&&r?{vertexColors:r}:{},...s?{stroke:s}:{}}}function D1(e,t){let n=t?.derivedPath,r=Ne(e.data?.stroke,t?.inherited?.stroke);return n==null||r===null?null:_1(n,r,t?.scale??1,t?.screen)}function y9(e,t,n){let{fill:r,stroke:o}=mO(e,t,n);return A3(e.path,r,o,void 0)}var cy={id:"kit:derived",matches:ay,paint:(e,t,n)=>{let r=n?.derivedPath;if(r==null)return[];let o=e.data,i=Mh(r);if(i!==void 0)return i.map(l=>{let u=y9(l,o,n?.inherited);return l.stroke===It?O1(u,n):u});let s=Ne(o?.stroke,n?.inherited?.stroke),a=Ie(o?.fill,n?.inherited?.fill);return nl(tl([A3(r,a,s,o?.vertexColors)],n),n)},silhouette:(e,t,n)=>n?.derivedPath??null,drawnBounds:(e,t,n)=>D1(e,n),ink:(e,t,n)=>{let r=e.data,o=Ne(r?.stroke,n?.inherited?.stroke);return{filled:Ie(r?.fill,n?.inherited?.fill)!==null,...ar(o,n?.scale),...el(o)}}};Z();function Dt(e){return e===void 0||Qa(e)}function Zo(e,t,n){if(!Qa(e))return null;let r=t?ia(t,n?.scale??1,n?.leastScale):0,o=Math.min(e.x,e.x+e.width),i=Math.min(e.y,e.y+e.height);return{x:o-r,y:i-r,width:Math.abs(e.width)+2*r,height:Math.abs(e.height)+2*r}}function g9(e,t){return{x:e.x*t.width,y:e.y*t.height,w:e.width*t.width,h:e.height*t.height}}function b9(e,t,n){if(n&&n>0)return{width:Math.abs(e.width)*n/(t?.width||1),height:Math.abs(e.height)*n/(t?.height||1)}}var R3={id:"kit:image",snapsToBox:!0,matches:e=>{if(!Dt(e.pose))return!1;let t=e.data?.image?.src;return typeof t=="string"&&t.length>0},paint:(e,t,n)=>{let r=e.data,o=t,i=n?.resolveImage?n.resolveImage(e):ca(r.image.src,b9(o,r.image.source,n?.pixelScale));if(i)return[{kind:"image",image:i,x:o.x,y:o.y,w:o.width,h:o.height,...r.image.opacity!==void 0?{opacity:r.image.opacity}:{},...r.image.source?{source:g9(r.image.source,i)}:{},...r.image.flipX?{flipX:!0}:{},...r.image.flipY?{flipY:!0}:{}}];let s=n?.resolveImage?!1:kw(r.image.src)==="error",a=s?"#d08a8a":"#bbbbbb",l=[{kind:"path",path:{kind:"rect",x:o.x,y:o.y,width:o.width,height:o.height},stroke:{paint:{color:a},width:1}}];return s&&l.push({kind:"path",path:Og({x:o.x,y:o.y},{x:o.x+o.width,y:o.y+o.height}),stroke:{paint:{color:a},width:1}}),l},silhouette:(e,t)=>{let n=t;return{kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height}},bounds:(e,t,n)=>Zo(t,x9,n)},x9={paint:{color:"#000"},width:1};Z();var N3={cut:{paint:{color:"#e23b3b"},width:1,dash:[6,4]},connector:{paint:{color:"#7ba7c7"},width:2,dash:[4,4]},falloff:{paint:{color:"rgba(52, 120, 246, 0.28)"},width:10,cap:"round",join:"round"},measure:{paint:{color:"#1f8fff"},width:1},lock:{paint:{color:"#d9480f"},width:1.5},target:{paint:{color:"#1f8fff"},width:1.5,dash:[5,3]},insert:{paint:{color:"#1f8fff"},width:3,cap:"round"},refused:{paint:{color:"#ff5d5d"},width:3,cap:"round"}};function B1(e){let t=e?.data?.measure;return!t||typeof t!="object"||!t.start||!t.end?null:t}var w9=5;function P9(e,t,n){let r={...N3.measure,width:{px:1}},o=Math.hypot(t.x-e.x,t.y-e.y),i=o>0?-(t.y-e.y)/o:0,s=o>0?(t.x-e.x)/o:1,a=w9*n,l=c=>({kind:"path",path:Vd([{x:c.x-i*a,y:c.y-s*a},{x:c.x+i*a,y:c.y+s*a}]),stroke:r}),u=[l(e),l(t)];return o>0&&u.unshift({kind:"path",path:Vd([e,t]),stroke:r}),u}var I3={id:"kit:measure",matches:e=>Dt(e.pose)&&B1(e)!==null,paint:(e,t,n)=>{let r=B1(e);if(!r)return[];let o=globalThis.devicePixelRatio||1;return P9(r.start,r.end,o/(n?.pixelScale??o))}};Z();Pe();var E3={id:"kit:path",matches:e=>Dt(e.pose)?e.data?.path!=null:!1,paint:(e,t,n)=>n?.derivedPath!=null?cy.paint(e,t,n):nl(tl(rt(e,Za,t,()=>{let r=e.data,o=$l(r.path,t),{fill:i,stroke:s}=F1(r,n?.inherited),a=i&&Kt(i,t),l=s&&Wi(s,t);return[{kind:"path",path:o,...a?{fill:a}:{},...a&&r.vertexColors?{vertexColors:r.vertexColors}:{},...l?{stroke:l}:{}}]},n?.inherited),n),n),silhouette:(e,t,n)=>{if(n?.derivedPath!=null)return n.derivedPath;let r=e.data;return $l(r.path,t)},ink:(e,t,n)=>{let{fill:r,stroke:o}=F1(e.data,n?.inherited);return{filled:r!==null,...ar(o??null,n?.scale),...el(o??null)}},bounds:(e,t,n)=>Zo(t,Ne(e.data.stroke,n?.inherited?.stroke),n),drawnBounds:(e,t,n)=>{if(n?.derivedPath!=null)return D1(e,n);let r=e.data;return uy(e,t,Ne(r.stroke,n?.inherited?.stroke),n,o=>$l(r.path,o))}};Pe();var M3={id:"kit:rect-fallback",matches:e=>e.kind!=="group"&&Dt(e.pose),paint:(e,t,n)=>{let r=e.data,o=t,i=Ie(r?.fill,n?.inherited?.fill),s=i&&Kt(i,o);return[{kind:"path",path:{kind:"rect",x:o.x,y:o.y,width:o.width,height:o.height},...s?{fill:s}:{}}]},silhouette:(e,t)=>{let n=t;return{kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height}},bounds:(e,t)=>Zo(t,null,void 0)};Z();Pe();var C3={id:"kit:shape",matches:e=>{if(!Dt(e.pose))return!1;let t=e.data?.shape;return t!=null&&T9.has(t)},paint:(e,t,n)=>nl(tl(rt(e,Za,t,()=>{let r=e.data,o=H1(r,t),i=Ie(r.fill,n?.inherited?.fill),s=i&&Kt(i,t),a=Ne(r.stroke,n?.inherited?.stroke),l=a&&Wi(a,t);return[{kind:"path",path:o,...s?{fill:s}:{},...l?{stroke:l}:{}}]},n?.inherited),n),n),silhouette:(e,t)=>{let n=e.data;return H1(n,t)},ink:(e,t,n)=>{let r=e.data,o=Ne(r.stroke,n?.inherited?.stroke);return{filled:Ie(r.fill,n?.inherited?.fill)!==null,...ar(o,n?.scale),...el(o)}},bounds:(e,t,n)=>Zo(t,Ne(e.data.stroke,n?.inherited?.stroke),n),drawnBounds:(e,t,n)=>{let r=e.data,o=Ne(r.stroke,n?.inherited?.stroke);return r.shape==="polygon"||r.shape==="star"?uy(e,t,o,n,i=>H1(r,i)):k3(t,o,n)}},T9=new Set(["rect","ellipse","polygon","star"]);function H1(e,t){switch(e.shape){case"ellipse":return Eg(t);case"polygon":{let n=t.x+t.width/2,r=t.y+t.height/2,o=Math.min(t.width,t.height)/2;return Mg({x:n,y:r},o,e.sides??6)}case"star":{let n=t.x+t.width/2,r=t.y+t.height/2,o=Math.min(t.width,t.height)/2;return Cg({x:n,y:r},o,e.points??5)}default:return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height}}}Z();Pe();function S9(e,t){return{kind:"group",clip:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height},children:[e]}}function k9(e,t){let n=Math.max(0,e.padding??0),r=Math.min(n,t.width/2),o=Math.min(n,t.height/2);return{x:t.x+r,y:t.y+o,width:t.width-2*r,height:t.height-2*o}}function G1(e,t,n){return{...k9(e,t),text:e.text,runs:e.runs,style:e.style,fill:e.fill===It?Ie(e.fill,n?.fill):e.fill,stroke:Ne(e.stroke,n?.stroke)??void 0,verticalAlign:e.verticalAlign}}var U1={id:"kit:text",snapsToBox:!0,matches:e=>Dt(e.pose)?e.data?.text!=null:!1,paint:(e,t,n)=>rt(e,Za,t,()=>{let r=e.data,o=gP(G1(r,t,n?.inherited)),i=r.overflow==="clip"?S9(o,t):o,s=Ie(r.background);if(!s)return[i];let a=Kt(s,t);return[{kind:"path",path:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height},...a?{fill:a}:{}},i]},n?.inherited),silhouette:(e,t)=>{let n=e.data;if(Ie(n.background))return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height};let r=Kp(G1(n,t)),o=n.overflow==="clip"?v9(r,t):r;return o.length===0?null:R9(o)},ink:(e,t,n)=>{let r=e.data;return{filled:!0,...ar(Ne(r.stroke,n?.inherited?.stroke),n?.scale)}},drawnBounds:(e,t,n)=>{let r=e.data,o=Ne(r.stroke,n?.inherited?.stroke);return o?A9(t,Kp(G1(r,t,n?.inherited)),ly(o,n)):null}};function v9(e,t){let n=[];for(let r of e){let o=Math.max(r.x,t.x),i=Math.max(r.y,t.y),s=Math.min(r.x+r.width,t.x+t.width),a=Math.min(r.y+r.height,t.y+t.height);s>o&&a>i&&n.push({x:o,y:i,width:s-o,height:a-i})}return n}function A9(e,t,n){if(!(n.x>0||n.y>0))return null;let r=e.x,o=e.y,i=e.x+e.width,s=e.y+e.height;for(let a of t){let l=Math.max(a.x,e.x),u=Math.max(a.y,e.y),c=Math.min(a.x+a.width,e.x+e.width),d=Math.min(a.y+a.height,e.y+e.height);c<=l||d<=u||(r=Math.min(r,l-n.x),o=Math.min(o,u-n.y),i=Math.max(i,c+n.x),s=Math.max(s,d+n.y))}return{x:r,y:o,width:i-r,height:s-o}}function R9(e){let t=new Uint8Array(e.length*6),n=new Float32Array(e.length*10),r=0,o=0;for(let i of e){let{x:s,y:a,width:l,height:u}=i;t[o++]=se,n[r++]=s,n[r++]=a,t[o++]=ae,n[r++]=s+l,n[r++]=a,t[o++]=ae,n[r++]=s+l,n[r++]=a+u,t[o++]=ae,n[r++]=s,n[r++]=a+u,t[o++]=ae,n[r++]=s,n[r++]=a,t[o++]=fe}return{kind:"polygon",commands:t,coords:n,fillRule:"nonzero"}}var MNe=Object.freeze({filled:!0,outset:0,inset:0}),rl={high:[],normal:[]},O3=!1;function W1(){O3||(O3=!0,_9())}function os(e,t={}){W1();let n=t.priority==="high"?rl.high:rl.normal;return n.push(e),dc(),()=>{let r=n.indexOf(e);r>=0&&n.splice(r,1),dc()}}var N9="shape:painter",I9="shape:painter:nonrect",E9="shape:painter:derived",M9="shape:painter:derived:nonrect",C9="shape:silhouette",O9="shape:silhouette:text";function Yc(e){let t=Dt(e.pose),n=ay(e)?t?E9:M9:t?N9:I9;return rt(e,n,void 0,()=>F9(e))}function F9(e){W1();for(let t of rl.high)if(t.matches(e))return t;for(let t of rl.normal)if(t.matches(e))return t}function qc(e,t,n){let r=()=>{let o=L9(e,t,n);return o&&Is(o,t)};if(n?.derivedPath!=null)return r();if(Yc(e)===U1){let o=ti(),i=rt(e,O9,t,()=>({epoch:o,path:r()}));return i.epoch!==o&&(i.epoch=o,i.path=r()),i.path}return rt(e,C9,t,r)}function L9(e,t,n){return Yc(e)?.silhouette?.(e,t,n)??null}P3(e=>qc(e.node,e.pose,{derivedPath:e.path}));function dy(e,t,n){return Yc(e)?.ink?.(e,t,n)??null}function F3(){return W1(),[...rl.high,...rl.normal]}function _9(){os(U1),os(I3),os(cy),os(E3),os(C3),os(R3),os(M3)}function fy(e){return`scene:${e}`}function L3(e,t){let{layerVisibility:n,layerOrder:r}=t;return n===void 0&&r===void 0?e:(r?r.map(i=>e.find(s=>fy(s.id)===i)).filter(i=>i!==void 0):e).filter(i=>n?.[fy(i.id)]!==!1)}Z();function py(e){if(e===null)return r=>r;let t=r=>r===void 0?null:e(r),n=new WeakMap;return(r,o,i)=>{let s=t(i),a=wP(t(o),s);if(a===null)return r;let l=n.get(r);l===void 0&&n.set(r,l=new Map);let u=l.get(s);return u===void 0&&l.set(s,u=Nt(r,PP(a))),u}}function _3(e,t){let n=wP(e,t);return n===null?void 0:q.fromAffine(PP(n))}var D3=Object.freeze({preserveDrawingBuffer:!0,stencil:!0});Z();Z();Z();function B3(e,t){if(e.length===0)return e;let n=Re(t);return n?[{kind:"group",transform:q.fromAffine(n),children:e}]:e}var G3=new WeakSet;function hy(e){let t={kind:"group",children:e};return G3.add(t),t}function H3(e){return G3.has(e)}var D9=[];function my(e){if(!e.some(H3))return{under:e,over:D9};let t=[],n=[];for(let r of e)H3(r)?n.push(...r.children):t.push(r);return{under:t,over:n}}function W3(e,t,n){let{under:r,over:o}=my(e),i=U3(r,t,n);return o.length>0?[...i,hy(U3(o,t,n))]:i}function U3(e,t,n){let r=B3(e,t);return n!==1&&r.length>0?[{kind:"group",alpha:n,children:r}]:r}function B9(e,t,n){return qc(e,t,{derivedPath:n?.()??null})}function yy(e,t,n){return typeof e.clipFromPose=="function"?e.clipFromPose(t):e.clip!=="outline"?null:B9(e,t,n)}Z();Z();function z3(e,t,n,r,o,i,s,a){let l=s&&o.inCopy!==void 0?i(e):null;if(l===null||!l.some(f=>a.copiesOf(f).length>0)){if(!o.hits(e,t,n,r))return!1;let f=l??i(e);for(let p=0;p<f.length;p++)if(!V3(a,o,f[p],e,t,n))return!1;return!0}let u=(f,p)=>V3(a,f,p,e,t,n),c=[...l].reverse(),d=(f,p)=>{if(f===c.length)return p.hits(e,t,n,r);let h=c[f];if(u(p,h)&&d(f+1,p))return!0;for(let m of a.copiesOf(h)){let y=p.inCopy?.(m);if(y!==void 0&&u(y,h)&&d(f+1,y))return!0}return!1};return d(0,o)}function V3(e,t,n,r,o,i){let s=e.clipOf(n);return s===null||t.clipAdmits(e.carry(s,n.layer,r.layer),r,o,i)}var ce=e=>e;function H9(e){return e?.annotation===!0}function gy(e){let t=new Set;for(let n of e??[])H9(n)&&t.add(n.id);return t}function Xc(e){return e.hidden===!0}function ol(e){let t=by(e,"hidden"),n=by(e,"locked"),r=n===null?a=>a.locked===!0:a=>a.locked===!0||n.has(a.layer),o=a=>{let l=new Map,u=[];return c=>{if(c===null)return!1;let d=!1,f=null;u.length=0;for(let p=c;p!==null;){let h=l.get(p);if(h!==void 0){d=h;break}let m=e.get(p);if(m===void 0)break;if(u.length>64){if(f??=new Set(u),f.has(p))break;f.add(p)}if(u.push(p),a(m)){d=!0;break}p=m.parent??null}for(let p of u)l.set(p,d);return d}},i=o(Xc),s=o(r);return{hidden(a){let l=typeof a=="string"?e.get(a):a;return l===void 0?!1:t?.has(l.layer)===!0||Xc(l)||i(l.parent??null)},locked(a){let l=typeof a=="string"?e.get(a):a;return l===void 0?!1:r(l)||s(l.parent??null)}}}function K3(e,t,n){let r=null,o=0;for(let i=t;i!==null;){let s=e.get(i);if(s===void 0)return!1;if(++o>64){if(r??=new Set,r.has(i))return!1;r.add(i)}if(n(s))return!0;i=s.parent??null}return!1}function by(e,t){let n=null;for(let r of e.layers??[])(t==="locked"?r.locked===!0:r.visible===!1)&&(n??=new Set).add(r.id);return n}function j3(e,t){let n=e.get(t);return n===void 0?!1:by(e,"hidden")?.has(n.layer)===!0||K3(e,t,Xc)}function $3(e,t){let n=by(e,"locked");return K3(e,t,n===null?r=>r.locked===!0:r=>r.locked===!0||n.has(r.layer))}Z();function q3(e,t){let n=Tt(e.overrides,t),r=Jn(e,t);return r===n.pose?n:{...n,pose:r}}function z1(e,t){return n=>t(q3(e,n))}function X3(e,t){return t===void 0?n=>e.overrides.read(n.id)?.path:n=>{let r=e.overrides.read(n.id)?.path;if(r===void 0)return;let o=q3(e,n);return Ch(r,o.pose,t(o))}}function Jc(e,t){let n=t?z1(e,t):o=>Jn(e,o);if(!Ct(e.composition))return n;let r=Hh(e,{getPose:o=>{let i=e.get(ce(o));return i?n(i):void 0},getParent:o=>e.get(ce(o))?.parent??null,definesFrame:o=>{let i=e.get(ce(o));return i===void 0||lt(i)}});return o=>jt(r,o.id,e.composition.compose)}function G9(e,t){let n=J3(t,Ct(e.composition));if(n===void 0)return o=>OP(e,o);let r={at:Jc(e,t),local:t?z1(e,t):o=>Jn(e,o),slot:n,shown:X3(e,t),childrenOf:o=>e.childrenOf(o),scene:Pa(e),lookup:o=>{let i=e.get(o);return i===void 0?void 0:new V1(Tt(e.overrides,i),r)}};return r.lookup}var V1=class{constructor(t,n){this.ctx=n;this.node=t,this.pose=n.at(t)}ctx;node;pose;get path(){let t=this.ctx.shown(this.node);return t!==void 0?Oh(t,this.ctx.local(this.node),this.pose):Br(this.node,this.ctx.lookup,this.ctx.childrenOf,this.ctx.slot)}get inherited(){return wa(this.ctx.scene,this.node)}get children(){return this.ctx.childrenOf(this.node.id).map(this.ctx.lookup)}};function K1(e,t){return t.dependsOn!==void 0||e.overrides.read(t.id)?.path!==void 0}function Qc(e,t){let n=G9(e,t),r=J3(t,Ct(e.composition)),o=a=>e.childrenOf(a),i=a=>Br(a,n,o,r),s=X3(e,t);return a=>s(a)??i(a)}var Y3=new WeakMap;function J3(e,t){let n=t?"world":"local";if(e===void 0)return n==="world"?"kit:derivedPath:world":void 0;let r=Y3.get(e);return r===void 0&&(r={},Y3.set(e,r)),r[n]??=SO()}function Q3(e,t,n){let r=Qc(e,n),o=Ct(e.composition)?n?z1(e,n):i=>Jn(e,i):null;return(i,s,a,l)=>{if(!K1(e,i))return t(i,s,a,l);let u=r(i);return u!==null&&o!==null&&e.overrides.read(i.id)?.path===void 0&&(u=U9(u,s,o(i))),t(i,s,a,{...l,derivedPath:u})}}function U9(e,t,n){let r=mi(t);if(r===null)return e;let o=t,i=n,s=Re({x:o.x,y:o.y,width:o.width,height:o.height,rotation:i?.rotation,transform:i?.transform});return uc(e,s===null?r:ht(r,s))}mA();function W9(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function j1({reads:e=2}={}){if(!(e>=1)||!Number.isInteger(e))throw new RangeError(`createSettledCache: reads must be a positive integer, got ${e}`);let t,n=0,r=null;return{read(o,i){return(t===void 0||!W9(t,o))&&(t=o.slice(),n=0,r=null),r!==null?r.value:++n<e?null:(r={value:i()},r.value)},clear(){t=void 0,n=0,r=null}}}var V9=[];function xy(e){return t=>{let n=t.parent??null;if(n===null)return V9;let r=[],o=new Set;for(;n!==null&&!o.has(n);){o.add(n);let i=e.get(ce(n));if(!i)break;r.push(i),n=i.parent??null}return r}}function wy(e){let t=Qc(e);return n=>{let r=n;return K1(e,r)?t(r):null}}Z();Z();Z();function Z3(e){let{x:t,y:n,width:r,height:o}=e;return Zc([t,n,t+r,n,t+r,n+o,t,n+o],{x:t,y:n,width:r,height:o},!0)}function Zc(e,t,n=!1){let r=[],o=[],i=1/0,s=1/0,a=-1/0,l=-1/0;for(let u=0;u+1<e.length;u+=2){let c=e[u],d=e[u+1];r.push({x:c,y:d}),o.push(c,d),c<i&&(i=c),d<s&&(s=d),c>a&&(a=c),d>l&&(l=d)}return r.length===0?null:{verts:r,coords:o,bounds:t??{x:i,y:s,width:a-i,height:l-s},isRect:n}}function eH(e){if(e.length<3)return null;let t=[];for(let n of e)t.push(n.x,n.y);return Zc(t)}function tH(e){return e!==null&&typeof e=="object"&&e.kind==="polygon"}function Py(e,t,n){return tH(t)?rt(e,"aabb",t,()=>n.getBounds(t)):Ki(t,n)}function nH(e,t){if(Re(e)){let n=e;return Is({kind:"rect",x:n.x,y:n.y,width:n.width,height:n.height},e)}return{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height}}function $1(e,t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y)||!Number.isFinite(n.width)||!Number.isFinite(n.height))return!1;let r=e.bounds;if(n.x>=r.x+r.width||n.x+n.width<=r.x||n.y>=r.y+r.height||n.y+n.height<=r.y)return!1;if(t==="centers")return Wn(e.coords,n.x+n.width/2,n.y+n.height/2);if(t==="intersect"&&e.isRect&&Ld([r.x,r.y,r.x+r.width,r.y+r.height],[n.x,n.y,n.x+n.width,n.y+n.height]))return!0}function rH(e,t,n,r,o,i=()=>!0){let s=$1(e,t,r);if(s!==void 0)return s;let a=e.bounds,l=tH(n);if(t==="enclosed")return l&&!Ld([a.x,a.y,a.x+a.width,a.y+a.height],[r.x,r.y,r.x+r.width,r.y+r.height])?!1:ib(e.verts,l?n:o());let u=l?n:o();return i()?u.kind==="rect"&&e.isRect?u.x<a.x+a.width&&u.x+u.width>a.x&&u.y<a.y+a.height&&u.y+u.height>a.y:tf(e.verts,u):tf(e.verts,u,{filled:!1})}function ed(e,t,n){let r=t.x+t.width,o=t.y+t.height;e[0]=Math.min(e[0],Math.min(t.x,r)-n),e[1]=Math.min(e[1],Math.min(t.y,o)-n),e[2]=Math.max(e[2],Math.max(t.x,r)+n),e[3]=Math.max(e[3],Math.max(t.y,o)+n)}function z9(e,t,n,r){let o=sr(t)?et(t):n.getBounds(t),i=n===Qo?t:BP(t,n),s=Re(i);if(!s){ed(e,o,r);return}let a=o.x-r,l=o.y-r,u=o.x+o.width+r,c=o.y+o.height+r;for(let[d,f]of[[a,l],[u,l],[u,c],[a,c]]){let[p,h]=wn(s,d,f);ed(e,{x:p,y:h,width:0,height:0},0)}}function K9(e){let t=1e-9*(1+Math.max(Math.abs(e[0]),Math.abs(e[1]),Math.abs(e[2]),Math.abs(e[3])));e[0]-=t,e[1]-=t,e[2]+=t,e[3]+=t}var j9=Object.freeze({scale:1});function oH(e,t,n,r,o,i){let s=dy(e,t,r===void 0?j9:{scale:1,inherited:r}),a=Math.max(0,s?.outset??0);if(i[0]=i[1]=1/0,i[2]=i[3]=-1/0,n)ed(i,et(n),a);else{let l=Gr(o,e);o===Qo&&l===o&&Qa(t)&&Re(t)===null?ed(i,t,a):(ed(i,Py(e,t,l),a),z9(i,t,o,a))}return K9(i),Math.max(0,s?.outsetPx??0)}var $9=0;var iH=new WeakMap,Y9=.5,Y1=class{constructor(t,n,r,o){this.built=t;this.trees=n;this.always=r;this.maxOutsetPx=o;this.layers=[...n.keys()],this.order=t,this.marks=new Uint8Array(t.length),this.found=new Int32Array(Math.max(16,r.length))}built;trees;always;maxOutsetPx;layers;order;remap=null;marks;found;rankBy(t){if(t===this.order)return;if(this.order=t,t===this.built){this.remap=null;return}let n=new Map;for(let o=0;o<t.length;o++)n.set(t[o].id,o);let r=new Int32Array(this.built.length);for(let o=0;o<r.length;o++)r[o]=n.get(this.built[o].id)??-1;this.remap=r}candidates(t){let n=Math.floor(this.order.length*Y9),r=0,o=i=>{let s=this.remap===null?i:this.remap[i];if(s<0)return!0;if(r===this.found.length){let a=new Int32Array(r*2);a.set(this.found),this.found=a}return this.found[r++]=s,r<=n};for(let i of this.always)if(!o(i))return null;for(let i=0;i<this.layers.length;i++){let s=t[i],a=this.trees.get(this.layers[i]);if(s===null||a===void 0)continue;let{x:l,y:u,width:c,height:d}=s.box,f=s.pxPerWorld,p=this.maxOutsetPx>0&&f!==void 0?f>0?this.maxOutsetPx/f:1/0:0,h=!1;if(a.queryBox([l-p,u-p,l+c+p,u+d+p],m=>o(m)?!0:(h=!0,!1)),h)return null}return this.readOut(r)}readOut(t){let{order:n,found:r}=this,o=new Array(t);if(t*32<n.length){let a=r.subarray(0,t).sort();for(let l=0;l<t;l++)o[l]=n[a[l]];return o}let i=this.marks.length>=n.length?this.marks:new Uint8Array(n.length);for(let a=0;a<t;a++)i[r[a]]=1;let s=0;for(let a=0;s<t&&a<n.length;a++)i[a]!==0&&(i[a]=0,o[s++]=n[a]);return o}};function q9(e){return e.some(t=>typeof t.copiesFromPose=="function")}function X9(e,t,n){$9++;let r=Jc(e),o=wy(e),i=xy(e),s=new Map,a=[],l=0;for(let c=0;c<n.length;c++){let d=n[c],f=i(d);if(q9(f)){a.push(c);continue}let p=[0,0,0,0],h;try{let y=fc(d)?xa(d,f):void 0;h=oH(d,r(d),o(d),y,t,p)}catch{a.push(c);continue}if(!Number.isFinite(h)||!p.every(Number.isFinite)){a.push(c);continue}h>l&&(l=h);let m=s.get(d.layer);m===void 0&&s.set(d.layer,m=[]),m.push([c,p])}let u=new Map;for(let[c,d]of s){let f=yb(2,d);if(f.size!==d.length)for(let[p,h]of d)h[0]<=h[2]&&h[1]<=h[3]||a.push(p);u.set(c,f)}return new Y1(n,u,Int32Array.from(a),l)}function J9(e,t){F3();let n=e.getVersion(),r=e.overrides.getGeneration(),o=e.scroll?.getGeneration()??0,i=kO(),s=Eu(),a=iH.get(e);a===void 0&&iH.set(e,a=new WeakMap);let l=a.get(t);l===void 0&&a.set(t,l=j1());let u=Dh(e.overrides,e.renderOrderNodes()),c=l.read([n,r,o,i,s],()=>X9(e,t,u));return c?.rankBy(u),c}function sH(e,t,n){let r=J9(e,t);if(r===null)return null;let o=[];for(let i of r.layers){let s=n(i);if(s===void 0||s!==null&&Number.isNaN(s.box.x+s.box.y+s.box.width+s.box.height))return null;o.push(s)}return r.candidates(o)}function q1(e,t={}){let n=ol(e),r=typeof e.overrides?.ids=="function",o=w=>e.overrides?Tt(e.overrides,w):w,i=w=>r?Dh(e.overrides,w):w.map(o),s=gy(e.layers),{getPose:a,alphaOf:l,layerIsPainted:u}=t,c=null;if(!l&&r)for(let w of e.overrides.ids()){let g=e.overrides.read(w)?.alpha;g!==void 0&&g<=0&&(c??=new Set).add(w)}let d=l??(r?c?w=>c.has(w)?0:1:void 0:w=>e.overrides.read(ce(w))?.alpha??1),f=Jc(e),p=a?w=>a(w.id):w=>f(w),h=w=>e.childrenOf(w),m=w=>{let g=e.get(w);if(g===void 0)return;let P=o(g);return{node:P,pose:p(P),get path(){return Br(P,m,h)}}},y=a?w=>{let g=w;return g.dependsOn===void 0?null:Br(g,m,h)}:wy(e),b=t.camera?Ty(e.layers,t.camera):null,x=a||typeof e.getVersion!="function"?void 0:t.index;return{...b?{planeOf:b}:{},...x?{candidates:w=>{let g=sH(e,x.descriptor,w);return g===null?null:i(g)}}:{},order:()=>i(e.renderOrderNodes()),derivedPathOf:y,poseOf:p,parentsOf:xy(e),...d?{alphaOf:d}:{},isLocked:w=>n.locked(w),isHidden:w=>n.hidden(w),...s.size>0||u?{layerIsPainted:w=>!s.has(w)&&(u===void 0||u(w))}:{}}}function Ty(e,t){let n=null;for(let o of e??[])o.parallax&&(n??=new Map).set(o.id,kh(t,o.parallax));if(n===null)return null;let r=n;return o=>r.get(o)??null}function aH(e,t){let n=t.includeGroups??!0,r=t.includeLocked===!0?void 0:e.isLocked,o=[],i=new Map,s=py(e.planeOf??null),a=b=>{let x=i.get(b.id);if(x!==void 0)return x;let w=yy(b,e.poseOf(b),()=>e.derivedPathOf?.(b));return i.set(b.id,w),w},l=new Map,u=b=>{let x=l.get(b.id);if(x===void 0){let w=b.copiesFromPose;x=(w?w(e.poseOf(b),b)??[]:[]).map(hr).filter(P=>P!==null),l.set(b.id,x)}return x},c=new Map,d=b=>{if(b===void 0||e.planeOf===void 0)return t;let x=c.get(b);if(x===void 0){let w=e.planeOf(b);x=w===null?t:t.inPlane?.(w)??null,c.set(b,x)}return x},f={clipOf:a,copiesOf:u,carry:s},p=b=>e.parentsOf(b),h=e.order(),m=h.some(b=>typeof b.copiesFromPose=="function"),y=(t.broad!==void 0?e.candidates?.(b=>{let x=d(b);return x===null?null:x.broad}):null)??h;for(let b of y){if(!n&&b.kind==="group"||b.pickable===!1||e.isHidden?.(b)===!0||b.layer!==void 0&&e.layerIsPainted?.(b.layer)===!1||e.alphaOf!==void 0&&e.alphaOf(b.id)<=0||r!==void 0&&r(b))continue;let x=d(b.layer);if(x===null)continue;let w=e.poseOf(b),g=e.derivedPathOf?.(b),P=fc(b)?xa(b,e.parentsOf(b)):void 0;z3(b,w,g,P,x,p,m,f)&&o.push(b.id)}return o}function Q9(e,t,n,r){let o={kind:"group",children:e};for(let i=t.length-1;i>=0;i--){let s=t[i];o="copy"in s?{kind:"group",children:[o],transform:q.fromAffine(s.copy)}:{kind:"group",children:[o],clip:r(s.path,s.layer,n)}}return o}function lH(e,t,n,r,o,i){let s=e.getLayers(),a=new Map;for(let h of s)h.visible&&a.set(h.id,[]);let l=null;for(let h of s)h.parallax&&(l??=new Map).set(h.id,bP(n,h.parallax));let u=e.composePose?.bind(e),c=u?e.childFrame?.bind(e):void 0,d=py(l?Ty(s,n):null);function f(h,m,y,b){let x=e.getNode(h);if(!x||Xc(x))return;let w=e.getPose(h),g=u&&y!==null?u(y,w):w,P=r===void 0||x.layer===r?a.get(x.layer):void 0,S=l?.get(x.layer)??n,{under:v,over:A}=my(P&&(b||!i?.(x,g,S))?t(x,g,S):[]),N=m,M=null,C=x,F=yy(C,g,()=>o?.(x,g));F&&(M={path:F,layer:x.layer},N=[...m,M]);let D=Q=>m.length>0?Q9(Q,m,x.layer,d):{kind:"group",children:Q};P&&P.push(D(v));let B=lt(x)?c?c(h,g):g:y,K=x.consumesChildren===!0?[]:e.getChildren(h);for(let Q of K)f(Q,N,B,b);let W=typeof C.copiesFromPose=="function"?C.copiesFromPose(g,x):null;for(let Q of W??[]){let le=[...m,{copy:Q},...M?[M]:[]];for(let ke of K)f(ke,le,B,!0)}P&&A.length>0&&P.push(D(A))}for(let h of e.getChildren(null))f(h,[],null,!1);let p=[];for(let h of s){if(!h.visible||r!==void 0&&h.id!==r)continue;let m=a.get(h.id)??[],y=h.parallax?_3(kh(n,h.parallax),null):void 0;p.push(y?{kind:"group",transform:y,children:m}:{kind:"group",children:m})}return p}var il=[{field:"clipFromPose",opKey:"clipKey",jsonKey:"clipFromPoseKey",lost:"clip"},{field:"copiesFromPose",opKey:"copiesKey",jsonKey:"copiesFromPoseKey",lost:"copies"},{field:"derivePath",opKey:"derivePathKey",jsonKey:"derivePathKey",lost:"derived path"},{field:"derivePose",opKey:"derivePoseKey",jsonKey:"derivePoseKey",lost:"derived pose"},{field:"layout",opKey:"layoutKey",jsonKey:"layoutKey",lost:"layout"}];function Sy(e,t){return il.map(n=>{let r=e[n.field],o=new Map;if(r)for(let[i,s]of Object.entries(r))o.set(s,i);return{spec:n,keyOf:i=>o.get(i),fnOf:i=>r?.[i],read:i=>i[n.field],write:(i,s)=>{i[n.field]=s,t?.(n.field,i)}}})}function td(e,t,n,r,o){let i=e.fnOf(n);if(i===void 0){o("scene",`${r}: ${e.spec.opKey} "${n}" not in this scene's registry \u2014 node "${t.id}" restored without its ${e.spec.lost}. Register a function with this key in the registry option to restore it.`);return}e.write(t,i)}function is(e,t,n,r){let o={};for(let i of e){let s=i.read(t);if(s===void 0)continue;let a=i.keyOf(s);if(a===void 0){r?.(i);continue}o[i.spec[n]]=a}return o}function ky(e){let t=e,n={};for(let r of il){let o=t[r.field];o!==void 0&&(n[r.field]=o)}return n}function lr(e){let t={};return e.pickable!==void 0&&(t.pickable=e.pickable),e.hidden===!0&&(t.hidden=!0),e.locked===!0&&(t.locked=!0),e.units!==void 0&&(t.units=e.units),e.clip!==void 0&&(t.clip=e.clip),e.consumesChildren===!0&&(t.consumesChildren=!0),t}function vy(e){let t=n=>n===null?[...e.roots]:[...e.childrenOf(ce(n))];return{getNode:n=>e.get(ce(n)),getParent:n=>e.get(ce(n))?.parent??null,getChildren:t,getRemovalClosure:n=>[...e.removalClosure(n.map(ce))],setPose:(n,r)=>e.setPose(ce(n),r),setParent:(n,r)=>e.move(ce(n),r==null?null:ce(r)),setChildOrder:(n,r)=>{e.batch("Reorder",()=>{for(let o=0;o<r.length;o++)t(n)[o]!==r[o]&&e.reorder(ce(r[o]),o)})},setData:(n,r)=>e.update(ce(n),{data:r}),setLayer:(n,r)=>e.setLayer(ce(n),r),setDependsOn:(n,r)=>e.setDependsOn(ce(n),Array.isArray(r)?r.map(ce):r),setLayout:(n,r)=>e.setLayout(ce(n),r),setHidden:(n,r)=>e.setHidden(ce(n),r),setLocked:(n,r)=>e.setLocked(ce(n),r),removeNode:n=>e.remove(ce(n)),insertNode:(n,r)=>{e.add({kind:n.kind,layer:n.layer,pose:n.pose,data:n.data,id:n.id,...r!==void 0?{index:r}:{},...n.parent!=null?{parent:n.parent}:{},...n.dependsOn!==void 0?{dependsOn:n.dependsOn}:{},...lr(n),...ky(n)})}}}function uH(e){return{getPose:t=>Hr(e,e.get(ce(t))),getNodes:()=>[...e.renderOrderNodes()]}}function cH(e,t,n){for(let r of t)r.apply(e)}Z();function fH(e,t){let n=e?.get?.();return{...t?{alphaOf:t}:{},...e?.layerIsPainted?{layerIsPainted:r=>e.layerIsPainted(r)}:{},...n?{camera:n}:{}}}function pH(e,t,n,r=Qo,o={}){return mH(e,Z3(t),"intersect",n,r,o)}function hH(e,t,n,r,o=Qo,i={}){let s=eH(t);return s?mH(e,s,n,r,o,i):[]}function dH(e,t){return t?.kind!=="polygon"||e()?t:{...t,openFill:"none"}}function mH(e,t,n,r,o,i){let s=q1(e,{...r,index:{descriptor:o}});return aH(s,X1(t,n,o,i))}function X1(e,t,n,r){return{includeGroups:r.includeGroups===!0,broad:{box:e.bounds},clipAdmits:(o,i,s,a)=>{let l=Gr(n,i);return ef(o,a?et(a):Ki(s,l))&&ef(o,e.bounds)},hits:(o,i,s,a)=>{let l=Gr(n,o),u=s?et(s):Py(o,i,l),c=$1(e,t,u);if(c!==void 0)return c;let d,f=()=>d??=dy(o,i,{inherited:a})?.filled!==!1;return rH(e,t,dH(f,i),u,()=>dH(f,qc(o,i,{derivedPath:s})??s??nH(i,u)),f)},inPlane:o=>X1(Z9(e,o),t,n,r),inCopy:o=>({...X1(eJ(e,o),t,n,r),broad:void 0})}}function Z9(e,t){let n=[];for(let r of e.verts){let o=xP(t,r);n.push(o.x,o.y)}return Zc(n,tO(t,e.bounds),e.isRect)}function eJ(e,t){let n=[],r=1/0,o=1/0,i=-1/0,s=-1/0;for(let l of e.verts){let[u,c]=wn(t,l.x,l.y);n.push(u,c),r=Math.min(r,u),o=Math.min(o,c),i=Math.max(i,u),s=Math.max(s,c)}let a=t[1]===0&&t[2]===0||t[0]===0&&t[3]===0;return Zc(n,{x:r,y:o,width:i-r,height:s-o},e.isRect&&a)}function tJ(e,t,n,r){return r!==void 0?r(t,n):e.get(t)?.kind==="group"}function yH(e,t,n,r){return tJ(e,t,n,r)===!0}function gH(e,t,n){return t==null||!e||e.get(t)===void 0?null:yH(e,t,[],n)?t:null}function bH(e,t,n){let r=gH(e,t,n);if(r===null)return{parent:null,layer:e.layers[0]?.id??"default",local:a=>a};let o=e.get(r),i=e.composition;if(i===void 0||!Ct(i))return{parent:o.id,layer:o.layer,local:a=>a};let s=ha(Hh(e,{getPose:a=>e.get(a).pose,getParent:a=>e.get(a)?.parent??null,definesFrame:a=>lt(e.get(a)??{})}),o.id,i.compose);return{parent:o.id,layer:o.layer,local:a=>i.decompose(s,a)}}function J1(e,t){return e?.axes?.(t)??hc(t)}var xH=new WeakMap;function nJ(e){let t=xH.get(e);return t||(t=()=>e.commit(),xH.set(e,t)),t}function rJ(e,t){let n=t(),r=J1(e,n);if(!r)return null;let{count:o,angles:i}=r,s=()=>{let a=t();if(a!==n){let l=J1(e,a);l&&l.count===o&&(r=l),n=a}return r};return{count:o,angles:i,to:a=>s().to(a),from:a=>s().from(a),add:r.add&&((a,l)=>{let u=s();return u.add?u.add(a,l):u.from(u.to(a).map((c,d)=>c+l[d]))}),write:r.write&&((a,l,u)=>{let c=s();c.write?c.write(a,l,u):c.to(a).forEach((d,f)=>{l[u+f]=d})})}}function oJ(e,t,n){let{overrides:r}=e,o=e.id,i=rJ(e.descriptor,e.get);if(!i)return null;let s={},a=!1,l=null,u=()=>{a=!1,l?.(),l=null,r.clear(o,s),t?.()},c=VP({get:e.get,set:e.set,axes:i,show(d){if(c.active&&n?.()&&c.stop({commit:!1}),!c.active){u();return}s.pose=d,r.has(o,s)||r.set(o,s),a=!0,n&&l===null&&(l=r.subscribe(()=>{!c.active||!n()||(c.stop({commit:!1}),a&&u())}))},publish:nJ(r)});return c}var wH=new WeakMap;function PH(e,t){if(e===t)return!0;if(typeof e!="object"||typeof t!="object"||e===null||t===null)return!1;let n=e,r=t,o=0;for(let i in n)if(Object.hasOwn(n,i)){if(!Object.hasOwn(r,i)||n[i]!==r[i])return!1;o++}for(let i in r)Object.hasOwn(r,i)&&o--;return o===0}function TH(e,t,n){let r=wH.get(e.overrides);r||(r=new Map,wH.set(e.overrides,r));let o=t,i=e.get(o),s=n??Ot,a=r.get(t),l=!a||a.active||!i||J1(s,Hr(e,i))?.count===a.axisCount;if(a&&l)return a;if(!i)return;let u=Hr(e,i),c,d=!1,f=r,p=null;if(p=oJ({id:t,descriptor:s,overrides:e.overrides,get(){let h=e.get(o);return h&&(u=Hr(e,h)),h&&!p?.active&&(c=h.pose),u},set(h){let m=e.get(o);if(m){d=!0;try{PH(m.pose,h)||e.untracked(()=>e.setPose(o,h))}finally{d=!1}c=e.get(o)?.pose}}},()=>{e.get(o)||f.delete(t)},()=>{if(d)return!1;let h=e.get(o);return!!h&&c!==void 0&&!PH(h.pose,c)}),!!p)return r.set(t,p),p}function Jt(e){return e.children!==void 0&&e.children.length>0}function sl(e){return Array.isArray(e)?[...e]:e!==null&&typeof e=="object"?{...e}:e}function SH(e,t){let{scene:n}=e,r=Sy(n.registry),o=new Set(t),i=new Set,s=[],a=(p,h)=>{if(h)return e.worldPoseOf(p.id);let m=e.frameAtOrAbove(p.parent);return m!==null&&i.has(m)?p.pose:e.worldPoseOf(p.id)},l=(p,h=!1)=>{if(i.has(p))return;let m=n.get(ce(p));if(m&&(i.add(p),s.push({kind:m.kind,id:m.id,layer:m.layer,parent:m.parent,pose:sl(a(m,h)),data:sl(m.data),...m.children!==void 0?{children:[...m.children]}:{},...lr(m),...m.dependsOn!==void 0?{dependsOn:sl(m.dependsOn)}:{},...ky(m),...is(r,m,"jsonKey")}),Jt(m)))for(let y of n.childrenOf(ce(p)))l(y)},u=p=>n.get(ce(p))?.parent,c=p=>sy(o,p,u)!==null,d=new Set,f=p=>{if(d.has(p))return;d.add(p);let h=n.get(ce(p));if(h){for(let m of cc(h))i.has(m)||c(m)||n.get(m)?.hidden!==!0||(f(m),l(m,!0));if(Jt(h))for(let m of n.childrenOf(ce(p)))f(m)}};for(let p of $c(t,u))f(p),l(p,!0);return{items:s}}var iJ=e=>typeof e=="function"||typeof e=="object"&&e!==null&&Object.values(e).some(t=>typeof t=="function");function sJ(e,t){let n={},r=e.registry;for(let o of il){let i=t[o.jsonKey],a=(typeof i=="string"?r[o.field]?.[i]:void 0)??(iJ(t[o.field])?t[o.field]:void 0);a!==void 0&&(n[o.field]=a)}return n}function aJ(e,t){let n=new Map,r=new Set(e.map(o=>o.id));for(let o=!0;o;){o=!1;for(let i of e){if(n.has(i.id))continue;let s,a=cc(i),l=a.filter(c=>!r.has(c)),u=t.get(i.id);i.parent!==null&&n.has(i.parent)?s={id:i.id,reason:"container-not-pasted"}:l.length>0?s={id:i.id,reason:"dependency-not-copied",missing:l}:a.length>0&&u.derivePath===void 0&&u.derivePose===void 0&&(s={id:i.id,reason:"derivation-not-registered"}),s!==void 0&&(n.set(i.id,s),r.delete(i.id),o=!0)}}return n}function kH(e,t,n,r){let o=t.items;if(o.length===0)return[];let i=new Map(o.map(b=>[b.id,sJ(e.scene,b)])),s=aJ(o,i);if(r?.onOmit)for(let b of o){let x=s.get(b.id);x&&r.onOmit(x)}let a=s.size===0?o:o.filter(b=>!s.has(b.id)),l=new Map;for(let b of a)l.set(b.id,e.scene.mintId());let u=b=>b.parent===null||!l.has(b.parent),c=new Map(a.map(b=>[b.id,b])),d=b=>{let x=b.parent===null?void 0:c.get(b.parent);for(;x!==void 0;){if(lt(x))return!0;x=x.parent===null?void 0:c.get(x.parent)}return!1},f=n.dx,p=n.dy;if(r?.dropPoint){let b=1/0,x=1/0;for(let w of a){if(!u(w))continue;let g=e.poseBounds(w.pose,w);g.x<b&&(b=g.x),g.y<x&&(x=g.y)}Number.isFinite(b)&&Number.isFinite(x)&&(f=r.dropPoint.x-b,p=r.dropPoint.y-x)}let h=e.landing?.(),m=h?.parent!=null?h:null,y=b=>{if(d(b))return sl(b.pose);let x=e.translate(sl(b.pose),f,p,b);return m&&u(b)?m.local(x):x};return a.map(b=>({id:l.get(b.id),kind:b.kind,layer:m&&u(b)?m.layer:b.layer,parent:u(b)?m?.parent??null:l.get(b.parent),pose:y(b),data:sl(b.data),...lr(b),...b.children!==void 0?{children:b.children.filter(x=>l.has(x)).map(x=>l.get(x))}:{},...b.dependsOn==="children"?{dependsOn:"children"}:cc(b).length>0?{dependsOn:cc(b).map(x=>l.get(x))}:{},...i.get(b.id)}))}function lJ(e){let t=Ct(e.composition),n=oO(e.composition.compose),r=t?GP(e):void 0,o={getParent:i=>e.get(ce(i))?.parent??null,getPose(i){let s=e.get(ce(i));if(!s)throw new Error(`sceneToAdapter: unknown node "${i}"`);return Jn(e,s)},definesFrame(i){let s=e.get(ce(i));return s===void 0||lt(s)},...r?{childFrame:r}:{}};return{getPose:o.getPose,definesFrame:o.definesFrame,getWorldPose:i=>t?jt(o,i,n):o.getPose(i),worldOfStored(i,s){let a=t?Xn(o,o.getParent(i)):null;return a===null?s:n(ha(o,a,n),s)},...t?{composePose:n}:{},...r?{childFrame:r}:{}}}function vH(e,t={}){let n=t.selection,r=n?.getSelection??n?.get??(()=>[]),o=n?.setSelection??n?.set??(()=>{}),i=t.poseDescriptor??Qo,s=(f,p)=>Ki(f,Gr(i,p)),a=(f,p,h,m)=>HP(f,p,h,m===void 0?i:Gr(i,m)),l={},u=f=>f?{...l,...fH(f,void 0)}:l,c={scene:e,worldPoseOf:f=>d.getWorldPose(f),frameAtOrAbove:f=>Xn(d,f),poseBounds:s,translate:a,...t.pasteInto?{landing:()=>bH(e,t.pasteInto())}:{}},d={...vy(e),getNodes(){let f=ol(e);return e.renderOrderNodes().filter(p=>!f.hidden(p.id))},...lJ(e),poseTarget:(f,p)=>TH(e,f,p??i),getLayers:()=>e.layers.map(f=>({id:f.id,visible:f.visible,parallax:f.parallax})),subscribeLayers:f=>e.subscribe(f),getLayout:f=>e.layoutOf(ce(f)),applyOps(f,p){p!==void 0?e.applyBatch(f,p,this):cH(this,f)},getSelection:r,setSelection:o,hitTestArea(f,p){return pH(e,f,u(p),i,{includeGroups:!0})},hitTestLasso(f,p,h){return hH(e,f,p,u(h),i,{includeGroups:!0})},...t.commitInsert?{commitInsert:f=>{let p=t.commitInsert(f);if(!p)return null;let h=t.insertLayer??"default";return{kind:"mark",id:p.id===void 0?e.mintId():ce(p.id),layer:h,pose:p.pose,data:p.data,parent:null}}}:{},snapshotSelection(f){return SH(c,f)},commitPaste(f,p,h){return kH(c,f,p,h)},getPasteOffset(){return{dx:12,dy:12}}};return d}function AH(e,t){return t===void 0||t.start===void 0&&t.end===void 0?e:{...e,...t.start!==void 0?{start:t.start}:{},...t.end!==void 0?{end:t.end}:{}}}var uJ=()=>typeof performance<"u"?performance.now():Date.now();function RH(e,t,n=uJ){let r=e?.colorOverrides,o=e?.trimOverrides;return!r&&!o?t:(i,s,a,l)=>{let u=r?.has(i.id)===!0,c=o?.has(i.id)===!0;if(!u&&!c)return t(i,s,a,l);let d={...l};if(u){let f=n();d.vertexColors=(p,h)=>r.resolve(i.id,p,h,f)}if(c){let f=o.resolve(i.id);d.trim=p=>AH(p,f)}return t(i,s,a,d)}}Z();Z();function NH(e,t,n){let r=t,o=Pr(t);return(i,s,a=t)=>{a!==r&&(r=a,o=Pr(a));let l=e(i,s,a);if(!l)return!1;let u=Re(s),c=u?q.multiply(o,q.fromAffine(u)):o;return hw(l,c,n)}}function EH(e){let t=typeof window<"u"&&window.devicePixelRatio||1;return Math.max(Math.abs(e.scale.x),Math.abs(e.scale.y))*t}var IH,Q1={};function cJ(e){let t=EH(e);return(e!==IH||Q1.pixelScale!==t)&&(IH=e,Q1={pixelScale:t}),Q1}function MH(e,t,n,r){let o=e.kind==="group"?void 0:Yc(e),i=!n||r?.pixelScale!==void 0?r:r?{...r,pixelScale:EH(n)}:cJ(n),s=o?o.paint(e,t,i):[],a=e.data;if(a?.label&&a.text==null){let l=t,u=yP(l.x+6,l.y+14,[{text:a.label,fill:{paint:{kind:"solid",color:"rgba(0,0,0,0.7)"}}}],{fontFamily:"sans-serif",fontSize:11});return[...s,e.kind==="group"?hy([u]):u]}return s}function CH(e,t){return(n,r,o,i)=>t(Tt(e,n),r,o,i)}function dJ(e,t={}){let{getNode:n,getChildren:r,getPose:o,composePose:i,childFrame:s}=vH(e);return{getLayers:()=>L3(e.layers,t).map(a=>({id:a.id,visible:a.visible,parallax:a.parallax})),getNode:n,getChildren:r,getPose:o,...i?{composePose:i}:{},...s?{childFrame:s}:{}}}function OH(e,t,n,r,o,i,s,a){let l=Pa(e),u=Q3(e,g3(l,n)),c=RH(s,u),d=Qc(e),f=w=>d(Tt(e.overrides,w)),p=(w,g,P)=>{let S=e.overrides.read(w.id)?.alpha??1;return W3(c(Tt(e.overrides,w),g,P),g,(o?o(w.id):1)*S)},h=dJ(e,i),m=a?{x:0,y:0,width:a.width,height:a.height}:void 0,y=m&&a?.paintBounds?NH(CH(e.overrides,b3(l,a.paintBounds)),t,m):void 0,b=lH(h,p,t,void 0,f,y),x=a&&m?pw(b,Pr(t),m,a.dpr):b;if(r&&r.length>0)for(let w of r)x.push(w);return[{kind:"group",transform:Pr(t),children:x}]}Z();function FH(e){let t=new Map,n=new Set,r=i=>{i&&n.add(i.kind??"solid")},o=i=>{for(let s of i)if(s.kind==="group")o(s.children);else if(s.kind==="path")r(s.fill?.paint),r(s.stroke?.paint);else if(s.kind==="text")for(let a of s.runs){let l=`${a.fontFamily}|${a.fontWeight}|${a.fontStyle}`;t.has(l)||t.set(l,{family:a.fontFamily,weight:a.fontWeight,style:a.fontStyle}),r(a.fill?.paint),r(a.stroke?.paint)}};return o(e),{fonts:[...t.values()],paintKinds:[...n]}}function LH(e,t,n){let r=fJ(e,t,n);return pJ(r),r}function fJ(e,t,n){let r=t*4,o=new Uint8ClampedArray(e.length);for(let i=0;i<n;i++)o.set(e.subarray((n-1-i)*r,(n-i)*r),i*r);return o}function pJ(e){for(let t=0;t<e.length;t+=4){let n=e[t+3];if(n===0||n===255)continue;let r=255/n;e[t]=e[t]*r,e[t+1]=e[t+1]*r,e[t+2]=e[t+2]*r}}function Z1(e){let{sourceRect:t,scale:n}=e;for(let[c,d]of[["sourceRect.width",t.width],["sourceRect.height",t.height]])if(!Number.isFinite(d)||d<=0)throw new Error(`renderSceneToPixels: ${c} must be a positive finite number, got ${d}`);for(let[c,d]of[["scale.x",n.x],["scale.y",n.y]])if(!Number.isFinite(d)||d===0)throw new Error(`renderSceneToPixels: ${c} must be a nonzero finite number, got ${d}`);for(let[c,d]of[["sourceRect.x",t.x],["sourceRect.y",t.y]])if(!Number.isFinite(d))throw new Error(`renderSceneToPixels: ${c} must be a finite number, got ${d}`);let r=Math.max(1,Math.round(t.width*Math.abs(n.x))),o=Math.max(1,Math.round(t.height*Math.abs(n.y))),i={x:n.x<0?t.x+t.width:t.x,y:n.y<0?t.y+t.height:t.y,scale:{x:n.x,y:n.y}},s=e.resolveImage,a=e.drawOne??((c,d,f,p)=>MH(c,d,f,{...p,resolveImage:s})),l=[];e.background!==void 0&&l.push({kind:"path",path:{kind:"rect",x:0,y:0,width:r,height:o},fill:{paint:{kind:"solid",color:e.background}}});let u=e.annotations?void 0:{layerVisibility:Object.fromEntries([...gy(e.scene.layers)].map(c=>[fy(c),!1]))};return l.push(...OH(e.scene,i,a,void 0,e.alphaFor,u,e)),e.overlay&&l.push(...e.overlay),{width:r,height:o,view:i,commands:l}}function hJ(e,t){if(typeof OffscreenCanvas<"u")return new OffscreenCanvas(e,t);if(typeof document<"u"){let n=document.createElement("canvas");return n.width=e,n.height=t,n}throw new Error("renderSceneToPixels: no canvas source in this environment \u2014 supply `gl` or `createCanvas`")}function eS(e={}){if(e.gl&&e.createCanvas)throw new Error("raster session: `gl` and `createCanvas` are mutually exclusive");let t=null,n=e.gl,r=null,o=!1;function i(s,a){if(e.gl||(t?(t.width<s&&(t.width=s),t.height<a&&(t.height=a)):(t=(e.createCanvas??hJ)(s,a),t.width=s,t.height=a,n=t.getContext("webgl2",D3)??void 0)),!n||typeof n.enable!="function")throw new Error("raster session: WebGL2 is unavailable \u2014 supply `gl` or a WebGL2-capable `createCanvas`");if(_H(n))throw new Error("raster session: the WebGL2 context is lost \u2014 dispose this session and open another");let{drawingBufferWidth:l,drawingBufferHeight:u}=n;if(l<s||u<a)throw new Error(`raster session: a ${s} \xD7 ${a} render does not fit the context's ${l} \xD7 ${u} drawing buffer \u2014 lower \`scale\` or render the source rect in tiles`);return n}return{render(s){if(o)throw new Error("raster session: render() on a disposed session");let a=Z1(s),{width:l,height:u}=a,c=i(l,u),d={px:s.flattenTolerancePx??.25};if(r?(r.resize({width:l,height:u,dpr:1}),r.setFlattenTolerance(d)):r=new ac({gl:c,width:l,height:u,dpr:1,imageMinification:"mipmap",flattenTolerance:d,bakeBudget:1/0}),r.render(a.commands,Pr(a.view),{screen:s.screen}),_H(c))throw new Error("raster session: the WebGL2 context was lost during render");let f=new Uint8Array(l*u*4);return c.readPixels(0,0,l,u,c.RGBA,c.UNSIGNED_BYTE,f),{width:l,height:u,data:LH(f,l,u)}},dispose(){o||(o=!0,r?.dispose(),r=null,t&&!e.createCanvas&&n?.getExtension("WEBGL_lose_context")?.loseContext(),t=null,n=void 0)}}}function _H(e){return typeof e.isContextLost=="function"&&e.isContextLost()===!0}function tS(e={}){let{families:t,paintKinds:n}=e;if(e.render||e.commands){let r;try{r=e.render?Z1(e.render).commands:[]}catch(i){return Promise.reject(i)}let o=FH([...r,...e.commands??[]]);t??=o.fonts,n??=o.paintKinds.filter(gw)}return Promise.all([ng(t),bw(n)]).then(()=>{})}async function nS(e){let t=new ImageData(new Uint8ClampedArray(e.data),e.width,e.height);if(typeof OffscreenCanvas<"u"){let o=new OffscreenCanvas(e.width,e.height),i=o.getContext("2d");if(!i)throw new Error("rasterToPng: no 2D context");return i.putImageData(t,0,0),o.convertToBlob({type:"image/png"})}if(typeof document>"u")throw new Error("rasterToPng: no canvas in this environment");let n=document.createElement("canvas");n.width=e.width,n.height=e.height;let r=n.getContext("2d");if(!r)throw new Error("rasterToPng: no 2D context");return r.putImageData(t,0,0),new Promise((o,i)=>{n.toBlob(s=>s?o(s):i(new Error("rasterToPng: encoding failed")),"image/png")})}var al=class extends Error{arrivals;constructor(t){let n=[...t.keys()].map(r=>`"${r}"`).join(", ");super(`Scene: ${n} refused the nodes joining it`),this.name="SceneArrivalRefused",this.arrivals=t}};var rS=xt(),i2e=rS.reflection;function DH(e,t){rS.set(e,t)}function Ay(e,t){let n=rS.get(e);return n?n(t):null}function BH(e,{compose:t,decompose:n},r,o){let i=n(e,e),s=r(i),a=r(e);if(s===null||a===null)return null;let l=o(i,s,{...s,x:a.x+(a.width-s.width)/2,y:a.y+(a.height-s.height)/2}),u=r(l);if(u===null)return null;let c=!Fo(l,e);return{upright:l,bounds:u,turned:c,toStrategy:d=>c?t(l,n(e,d)):d,toWorld:d=>c?t(e,n(l,d)):d}}function HH(e){let t=e?.data?.pathEffect;return t&&typeof t=="object"&&typeof t.kind=="string"?t:null}var oS="kit:clipNothing",iS=()=>null;var GH="kit:unionOfChildren";function UH(e,t){let n=[];for(let o of t){if(o===void 0)continue;let i=sS(o.pose);if(i===null)return null;n.push(i)}if(n.length===0)return null;let r=LO(n);return r===null?null:r}function sS(e){if(e===null||typeof e!="object")return null;let t=e;return typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"?e:null}function WH(e){return{...e,clipFromPose:{[oS]:iS,...e.clipFromPose},derivePath:{[M1]:C1,...e.derivePath},derivePose:{[GH]:UH,...e.derivePose}}}function KH(e,t){let{undoStack:n,redoStack:r,forks:o,floorId:i,nextEntryId:s}=e,a=0,l=b=>(a+=b.length,b.map(x=>mJ(x,t))),u=b=>{let x=l(b);return x.slice(x.lastIndexOf(null)+1)},c=u(n),d=u(r),f=c.length===n.length?i:n[n.length-c.length-1].id,p=new Set([f,...[...c,...d].map(b=>b.id)]),h=[...o].flatMap(([b,x])=>x.map(w=>{let g=l(w),P=g.indexOf(null);return{at:b,entries:P<0?g:g.slice(0,P)}})).filter(b=>b.entries.length>0),m=[];for(let b=!0;b;){b=!1;let x=[];for(let w of h){if(!p.has(w.at)){x.push(w);continue}m.push(w);for(let g of w.entries)p.add(g.id);b=!0}h=x}let y=c.length+d.length+m.reduce((b,x)=>b+x.entries.length,0);return{version:1,undoStack:c,redoStack:d,...m.length>0?{branches:m}:{},...f!==0?{floor:f}:{},nextEntryId:s,droppedEntries:a-y}}function jH(e,t,n){let r=u=>gJ(u,t,n),o=e.undoStack.map(r),i=e.redoStack.map(r),s=new Map;for(let u of e.branches??[]){let c=u.entries.map(r),d=s.get(u.at);d?d.push(c):s.set(u.at,[c])}let a=e.nextEntryId,l=[o,i,...[...s.values()].flat()];for(let u of l)for(let c of u)c.id>=a&&(a=c.id+1);return{undoStack:o,redoStack:i,forks:s,floorId:e.floor??0,nextEntryId:a}}function ss(e){let t=new Set;for(let n of e){if(n.args===null||typeof n.args!="object")continue;let r=n.args;if(typeof r.id=="string")t.add(r.id);else if(r.node!==null&&typeof r.node=="object"){let o=r.node;typeof o.id=="string"&&t.add(o.id)}else if(Array.isArray(r.nodes))for(let o of r.nodes){let i=o!==null&&typeof o=="object"?o.id:void 0;typeof i=="string"&&t.add(i)}}return t}function VH(e){return typeof e.name!="string"?null:{name:e.name,args:e.args}}function mJ(e,t){let n=[];for(let o of e.forwardOps){let i=VH(o);if(i===null)return t.log(`serialize: dropping entry id=${e.id} "${e.label}" \u2014 forwardOp without name`),null;n.push(i)}let r=[];for(let o of e.baseOps){let i=VH(o);if(i===null)return t.log(`serialize: dropping entry id=${e.id} "${e.label}" \u2014 baseOp without name`),null;r.push(i)}return{id:e.id,label:e.label,forwardOps:n,baseOps:r,pushes:e.pushes,timestamp:e.timestamp,...e.selectionBefore?{selectionBefore:e.selectionBefore}:{},...e.selectionAfter?{selectionAfter:e.selectionAfter}:{}}}function yJ(e,t,n){let r={name:e,args:t,label:n,apply:()=>"noop",invert:()=>r};return r}function zH(e,t,n,r){let o=n?n(e.name,e.args):null;return o!==null?o:(r.log(`restore: unknown op name "${e.name}" \u2014 substituting no-op placeholder`),yJ(e.name,e.args,t))}function gJ(e,t,n){let r=e.forwardOps.map(i=>zH(i,e.label,t,n)),o=e.baseOps.map(i=>zH(i,e.label,t,n));return{id:e.id,label:e.label,forwardOps:r,baseOps:o,timestamp:e.timestamp??0,pushes:e.pushes??1,touchedIds:ss(r),...e.selectionBefore?{selectionBefore:[...e.selectionBefore]}:{},...e.selectionAfter?{selectionAfter:[...e.selectionAfter]}:{}}}function $H(e,t){if(e.length===0||t.length===0||e.length!==t.length)return!1;let n=new Map;for(let r of e){let o=r.coalesceKey;if(o===void 0)return!1;n.set(o,(n.get(o)??0)+1)}for(let r of t){let o=r.coalesceKey,i=o===void 0?0:n.get(o)??0;if(!i)return!1;n.set(o,i-1)}return!0}function aS(e){return{id:e.id,label:e.label,timestamp:e.timestamp,pushes:e.pushes,touchedIds:e.touchedIds,...e.selectionBefore?{selectionBefore:e.selectionBefore}:{},...e.selectionAfter?{selectionAfter:e.selectionAfter}:{}}}function ur(e,t=[]){return{kind:e,entries:t.map(n=>({id:n.id,label:n.label,ops:n.forwardOps}))}}function YH(e,t){function n(o){for(let i of o)try{i.apply(e)}catch(s){t.warn(`unwinding a failed step: op "${i.name??"?"}" threw: ${String(s)}`)}}function r(o,i,s){let a=!1,l=0;try{for(;l<o.length;l++){let u=o[l].apply(e);u!==!1&&u!=="noop"?a=!0:s?.push(o[l])}}catch(u){throw l>0&&(n(o.slice(0,l).reverse().map(c=>c.invert())),i&&n(i())),u}return a}return r}function qH(e,t,n){let r=e.forwardOps===e.baseOps;e.forwardOps=[...e.forwardOps,...t],e.baseOps=r?e.forwardOps:[...e.baseOps,...t],e.timestamp=n,e.pushes++;let o=new Set(e.touchedIds);for(let i of ss(t))o.add(i);e.touchedIds=o}function XH(e){for(let t=0;t<e.length;t++)if(e[t].caused!==void 0)return!0;return!1}var Ry=new WeakMap;function JH(e){let t=Ry.get(e);if(!t)throw new Error("Journal is not resumable (already committed or cancelled)");t()}function QH(e,t,n,r,o={}){let i=nd(t,{...o,...n.coalesceWindowMs!==void 0?{coalesceWindowMs:n.coalesceWindowMs}:{}}),s=o.selection,a=0,l=Ce();function u(){a++,l.emit()}i.subscribe(u);let c=e.currentEntryId(),d=s?[...s.get()]:void 0,f="active",h={targetId:n.targetId,forkedAtEntryId:c,applyBatch(m,y){if(f!=="active")throw new Error("Journal is not active");i.applyOps(m,y)},undo(){if(f!=="active")throw new Error("Journal is not active");i.undo()},redo(){if(f!=="active")throw new Error("Journal is not active");i.redo()},canUndo(){return i.canUndo()},canRedo(){return i.canRedo()},entries(){return i.entries()},seal(){i.seal()},observe:m=>i.observe(m),beginJournal(m){if(f!=="active")throw new Error("Journal is not active");return i.beginJournal(m)},getVersion:()=>a,subscribe:l.subscribe,commit(m){if(f!=="active")throw new Error("Journal is not active");let{forwardOps:y,baseOps:b}=lS(i).appliedOps();lS(e).record(y,b,m,d?{selectionBefore:d}:void 0),f="closed",Ry.delete(h),r?.(),u()},cancel(){if(f!=="active")throw new Error("Journal is not active");i.goto(0),f="closed",Ry.delete(h),r?.(),u()},suspend(){if(f!=="active")throw new Error("Journal is not active");f="suspended",r?.(),u()},isActive(){return f==="active"}};return Ry.set(h,()=>{if(f!=="suspended")throw new Error("Journal is not suspended");f="active",u()}),h}var ZH=new WeakMap;function lS(e){let t=ZH.get(e);if(!t)throw new Error("Not a history built by createHistory");return t}var bJ={log:()=>{},warn:()=>{}};function nd(e,t={}){let n=[],r=[],o=null,i=t.coalesceWindowMs??0,s=t.now??(()=>Date.now()),a=Math.max(0,t.historyLimit??1/0),l=t.onEvict,u=t.branching??!1,c=new Map,d=0,f=t.rebuildOp,p=t.selection,h=t.debug??bJ,m=1,y=0,b=-1,x=Ce(),w=Ce();function g(G){y++,G&&w.size>0&&w.emit(typeof G=="function"?G():G),x.emit()}function P(G){if(l)for(let j of G)try{l({id:j.id,label:j.label,forwardOps:j.forwardOps,baseOps:j.baseOps})}catch($){h.warn(`onEvict callback threw for entry id=${j.id} "${j.label}": ${String($)}`)}}function S(G){P(G);for(let j of G){let $=c.get(j.id);if($){c.delete(j.id);for(let ee of $)S(ee)}}}function v(G){for(let j of G){l&&P([j]);let $=c.size>0?c.get(d):void 0;if($!==void 0&&c.delete(d),d=j.id,$!==void 0)for(let ee of $)S(ee)}}function A(){return n[n.length-1]?.id??d}function N(G){if(r.length===0)return;let j=r.splice(0);if(!u)return S(j);let $=c.get(G);$?$.push(j.reverse()):c.set(G,[j.reverse()])}function M(){for(;n.length>a;)v([n.shift()])}let C=YH(e,h);function F(G){return[...G.baseOps].reverse().map(j=>j.invert())}function D(){return p?[...p.get()]:void 0}function B(G){let j=D(),$=G.forwardOps!==G.baseOps;C(F(G),$?()=>G.forwardOps:void 0),j&&(G.selectionAfter=j),p&&G.selectionBefore&&p.set(G.selectionBefore)}function K(G){let j=D(),$=G.forwardOps!==G.baseOps;C(G.forwardOps,$?()=>F(G):void 0),j&&(G.selectionBefore=j),p&&G.selectionAfter&&p.set(G.selectionAfter)}function W(G){let j=[];for(;n.length>G;){let $=n[n.length-1];B($),n.pop(),r.push($),j.push($)}for(;n.length<G&&r.length>0;){let $=r[r.length-1];K($),r.pop(),n.push($),j.push($)}return j}function Q(G,j){let $=typeof i=="function"?i():i;return!($>0)||G.coalesceKey!==void 0||y!==b||s()-G.timestamp>$?!1:$H(G.forwardOps,j)}function le(G,j){if(G.length===0)return;let $=D(),ee=[],te=C(G,void 0,ee),he=ee.length===0?G:G.filter(vt=>!(vt.elideNoop&&ee.includes(vt))),xe=XH(he)?he.flatMap(vt=>vt.caused?.()??[vt]):he.slice();if(!te){h.warn(`'${j}' batch was a no-op \u2014 every op reported false/'noop'. Skipping the undo entry; consider gating the dispatch upstream to avoid the wasted work.`);return}if(xe.length===0)return;let Le=ss(xe),Se=n[n.length-1];if(Se&&Q(Se,xe)){if(Se.forwardOps=xe,Se.timestamp=s(),Se.pushes++,Le.size>0){let vt=new Set(Se.touchedIds);for(let Qt of Le)vt.add(Qt);Se.touchedIds=vt}h.log(`coalesce '${j}' into entry id=${Se.id} (${xe.length} ops)`),g(()=>({kind:"coalesce",entries:[{id:Se.id,label:Se.label,ops:xe}]})),b=y;return}h.log(`push '${j}' (${xe.length} ops)`);let cr=A(),_e={id:m++,forwardOps:xe,baseOps:xe,label:j,timestamp:s(),pushes:1,touchedIds:Le,...$?{selectionBefore:$}:{}};n.push(_e),N(cr),M(),g(()=>ur("push",[_e])),b=y}function ke(G,j){qH(G,j,s()),g(()=>({kind:"coalesce",entries:[{id:G.id,label:G.label,ops:j}]})),b=y}function ue(G,j,$,ee={}){if(G.length===0)return;let te=ee.coalesceKey,he=n[n.length-1];if(te!==void 0&&he?.coalesceKey===te&&y===b&&G===j)return ke(he,G);let xe=A(),Le={id:m++,forwardOps:G,baseOps:j,label:$,timestamp:s(),pushes:1,touchedIds:ss(G),...ee.selectionBefore?{selectionBefore:[...ee.selectionBefore]}:{},...te!==void 0?{coalesceKey:te}:{}};n.push(Le),N(xe),M(),g(()=>ur("push",[Le])),te!==void 0&&(b=y)}let ve={apply(G,j){le([G],j??G.label??"")},applyOps(G,j){le(G,j)},undo(){n.length!==0&&g(ur("undo",W(n.length-1)))},redo(){r.length!==0&&g(ur("redo",W(n.length+1)))},seal(){b=-1},canUndo:()=>n.length>0,canRedo:()=>r.length>0,undoDepth:()=>n.length,redoDepth:()=>r.length,clear:()=>{let G=n.length>0||r.length>0||c.size>0;n.length=0,r.length=0,c.clear(),d=0,G&&g(ur("clear"))},entries(){return{undo:n.map(aS),redo:[...r].reverse().map(aS)}},goto(G){let j=n.length+r.length;if(G<0||G>j||G===n.length)return;let $=n.length,ee;try{ee=W(G)}catch(te){try{W($)}catch(he){h.warn(`goto: returning to depth ${$} threw: ${String(he)}`)}throw n.length!==$&&g(),te}g(ur("goto",ee))},timestampAt(G){if(!(G<0))return G<n.length?n[G].timestamp:r[r.length-1-(G-n.length)]?.timestamp},depthAt(G){let j=n.length;for(;j>0&&n[j-1].timestamp>G;)j--;if(j<n.length)return j;for(let $=r.length-1;$>=0&&r[$].timestamp<=G;$--)j++;return j},prune(G){let j=0;for(;j<n.length&&n[j].timestamp<G;)j++;if(j===0)return;let $=n.splice(0,j);v($),g(ur("prune",$))},branches(){let G=($,ee)=>{let te=$[0];return{id:te.id,label:te.label,timestamp:te.timestamp,length:$.length,current:ee}},j=(c.get(A())??[]).map($=>G($,!1));return r.length>0&&j.push(G([...r].reverse(),!0)),j.sort(($,ee)=>$.id-ee.id)},switchBranch(G){if(r[r.length-1]?.id===G)return;let j=A(),$=c.get(j)??[],ee=$.findIndex(he=>he[0].id===G);if(ee<0)throw new Error(`No branch ${G} forks from entry ${j}`);let[te]=$.splice(ee,1);r.length>0&&$.push(r.splice(0).reverse()),$.length>0?c.set(j,$):c.delete(j),r.push(...[...te].reverse()),g(ur("branch",te))},getVersion:()=>y,subscribe:x.subscribe,observe:w.subscribe,serialize:()=>KH({undoStack:n,redoStack:r,forks:c,floorId:d,nextEntryId:m},h),recordEntry(G,j,$){ue(G,G,j,$)},allForwardOps(){let G=[];for(let j of n)for(let $ of j.forwardOps)G.push($);return G},currentEntryId:()=>m,beginJournal(G){if(o!==null&&o.isActive())throw new Error("A journal is already active \u2014 commit, cancel, or suspend it first");let j=QH(ve,e,G,()=>{o=null},{coalesceWindowMs:i,now:s,debug:h,...p?{selection:p}:{}});return o=j,j},activeJournal:()=>o?.isActive()?o:null,resumeJournal(G){if(o!==null&&o!==G&&o.isActive())throw new Error("A journal is already active \u2014 commit, cancel, or suspend it first");JH(G),o=G},restore(G){let j=jH(G,f,h);n.splice(0,n.length,...j.undoStack),r.splice(0,r.length,...j.redoStack),c.clear();for(let[$,ee]of j.forks)c.set($,ee);d=j.floorId,m=j.nextEntryId,g(ur("restore"))}};return ZH.set(ve,{appliedOps:()=>({forwardOps:n.flatMap(G=>G.forwardOps),baseOps:n.flatMap(G=>G.baseOps)}),record:ue}),ve}function e4(e,t){let n=new Map,r=new Set,o=i=>{r.clear();for(let[s,a]of i){r.add(s);let l=n.get(s);if(l){l.pose=a.pose,l.data=a.data,e.has(s,l)||e.set(s,l);continue}let u={pose:a.pose,data:a.data};n.set(s,u),e.set(s,u)}for(let[s,a]of n)r.has(s)||(n.delete(s),e.clear(s,a));e.commit()};return{set(i){o(xJ(i))},show:o,others(){let i=new Map;for(let s of e.ids()){let a=t(s)??[],l=n.get(s);for(let u=a.length-1;u>=0;u--){let c=a[u];if(!(c===l||c.pose===void 0)){i.set(s,c.pose);break}}}return i},drop(){if(n.size!==0){for(let[i,s]of n)e.clear(i,s);n.clear(),e.commit()}}}}function*xJ(e){for(let[t,n]of e)yield[t,{pose:n}]}var wJ=Object.freeze({}),t4=new WeakMap;function PJ(e,t){let n=t4.get(e);n===void 0&&t4.set(e,n=new WeakMap);let r=n.get(t);return r===void 0&&n.set(t,r=o=>t(e(o))),r}var TJ={merge:PJ,lerp:(e,t,n)=>n<.5?e:t};function n4(e){let t=I1({pose:Vh(),alpha:zP(),path:Vh(),data:TJ}),n=[],r=0,o=i=>{for(;n.length>i;)n.pop().fade({over:0});for(;n.length<i;){let s=n.length;n.push(t.cue({patch:lT(0,(a,l)=>e.get(l)?.[s]??wJ,{writes:["pose","alpha","path","data"]})}))}t.sync(r++)};return o(1),{probe:(i,s)=>{t.probe(i,s)},publish:o,drop:i=>{t.drop(i)}}}function o4(){let e=new Map,t=new WeakMap,n=0,r=[],o=0,i=(s,a)=>{for(s>0&&r[s]--,a>0&&(r[a]=(r[a]??0)+1),a>o&&(o=a);o>0&&(r[o]??0)===0;)o--};return{plies:e,claim(s,a){let l=e.get(s);l===void 0&&e.set(s,l=[]);let u=l.indexOf(a);u>=0&&l.splice(u,1);let c=u>=0?void 0:t.get(a);c===void 0&&t.set(a,c=++n);let d=l.length;for(;d>0&&t.get(l[d-1])>c;)d--;l.splice(d,0,a),u<0&&i(l.length-1,l.length)},release(s,a){t.delete(a);let l=e.get(s),u=l?.indexOf(a)??-1;return l===void 0||u<0?!1:(l.splice(u,1),i(l.length+1,l.length),l.length===0&&e.delete(s),!0)},drop(s){let a=e.get(s);return a===void 0?!1:(e.delete(s),i(a.length,0),!0)},dropAll(){e.clear(),r.length=0,o=0},depth:()=>Math.max(o,1)}}var r4=e=>{let t=e;return t!==null&&typeof t=="object"&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.width=="number"&&typeof t.height=="number"?t:null},uS=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height;function i4(e,t,n){for(let r=e.length-1;r>=0;r--){let o=e[r];if(o.path===void 0)continue;let i=r4(o.pose),s=r4(t);if(i===null||s===null||uS(i,s))return o.path;let a=n.carried;return a!==void 0&&a.source===o.path&&uS(a.from,i)&&uS(a.to,s)?a.path:(n.carried={source:o.path,from:{...i},to:{...s},path:Ch(o.path,i,s)},n.carried.path)}}function cS(e,t){let n=o4(),{plies:r}=n,o=n4(r),i=Ce(),s=0,a=new Map;function l(f){let p=e(f);if(p){un(p);let h=EO(p);h&&un(h)}t?.(f)}function u(){s++,o.publish(n.depth()),i.emit()}function c(f){a.delete(f),o.drop(f)}let d={set(f,p){n.claim(f,p),l(f),u()},get(f){return r.get(f)?.at(-1)},read(f){let p=r.get(f);if(p===void 0)return;let h=a.get(f);return h===void 0&&(h={out:{},at:-1},a.set(f,h)),h.at!==s&&(o.probe(f,h.out),h.out.path=i4(p,h.out.pose,h),h.at=s),h.out},has(f,p){let h=r.get(f);return h!==void 0&&(p===void 0||h.includes(p))},ids(){return[...r.keys()]},clear(f,p){(p===void 0?n.drop(f):n.release(f,p))&&(r.has(f)||c(f),l(f),u())},clearAll(){if(r.size!==0){for(let f of r.keys())c(f),l(f);n.dropAll(),u()}},commit(){for(let f of r.keys())l(f);u()},subscribe:i.subscribe,getGeneration(){return s},hold:()=>e4(d,f=>r.get(f))};return d}function Ny(e,t,n){let r={...e.placed?{placed:e.placed}:{}};return{name:"arrange",args:r,label:"Arrange",elideNoop:!0,get coalesceKey(){return r.placed===void 0?void 0:`arrange:${r.placed.map(o=>o.id).sort().join(",")}`},apply(o){r.placed===void 0&&(r.placed=t?.()??[]);let i=n??((s,a)=>o.setPose(s,a));for(let s of r.placed)i(s.id,s.to);return r.placed.length>0?void 0:"noop"},invert(){let o=r.placed??[];return Ny({placed:[...o].reverse().map(i=>({id:i.id,from:i.to,to:i.from}))},void 0,n)}}}DH("arrange",e=>Ny(e));function s4(e,t,n){let r=new Map;for(let[o,i]of t){let s=i.filter(a=>e.get(a)?.parent===o===n);s.length>0&&e.has(o)&&r.set(o,s)}return r}function a4(e){let{nodes:t}=e,n=null,r=!1,o=null,i=new Map,s=new Set,a=null,l=Ce(),u=()=>n??(r?e.layoutPass:null);function c(m=!1){return o!==null||!m&&u()===null?!1:(o=new Map,i=new Map,s=new Set,a=null,!0)}function d(){let m=a;a=null,!(m===null||m.length===0)&&l.emit(m)}function f(){let m=o;o=null;let y=u();if(m===null||y===null)return[];let b=s4(t,m,!0),x=s4(t,i,!1);i=new Map;let w=new Set([...s].filter(S=>t.has(S)));if(b.size===0&&w.size===0)return[];let g=y(b,w,x);if(g===null)throw new al(b);let P=[];for(let[S,v]of g){let A=t.get(S);A&&P.push({id:S,from:A.pose,to:v})}return a=P,P}function p(){o=null,a=null}function h(m){return c(!0)?{ops:[...m,Ny({},f,e.writePose)],owned:!0}:{ops:m,owned:!1}}return{layoutDeclared:()=>{r=!0},setHandler(m){return n=m,()=>{n===m&&(n=null)}},onReflow:l.subscribe,noteArrival(m,y,b){if(o===null||y===null||y===b)return;s.add(y);let x=o.get(y);x===void 0?o.set(y,[m]):x.includes(m)||x.push(m)},noteDeparture(m,y,b){if(o===null||y===null||y===b||(s.add(y),o.get(y)?.includes(m)))return;let x=i.get(y);x===void 0?i.set(y,[m]):x.includes(m)||x.push(m)},noteChange(m){o!==null&&m!==null&&s.add(m)},bareLayoutEdit:()=>u()!==null&&o===null&&e.recordsBareEdits(),open:c,settle:f,emitReflow:d,abandon:p,runEdit(m,y){let{ops:b,owned:x}=h(m);if(!x)return y(b),!0;try{return y(b),d(),!0}catch(w){if(!(w instanceof al))throw w;return!1}finally{p()}}}}function l4(){let e=Ce(),t=0,n=0,r=!1;return{notify(){if(t++,n>0){r=!0;return}e.emit()},version:()=>t,subscribe:e.subscribe,deferred(o,i){n++;try{return o()}finally{n--,i?.(),n===0&&r&&(r=!1,e.emit())}},muted(o){let i=r;n++;try{return o()}finally{n--,r=i}}}}function u4(e,t){return{subscribe:e.subscribe,getVersion:e.version,getContentVersion:()=>e.version()-t.changes()}}function c4(e){let t=new Map;return{seeOff(n,r,o,i){let s=new Map;for(let u of r){let c=s.get(u.parent);c?c.push(u):s.set(u.parent,[u])}let a=u=>{let c=e(u.id);if(!c)return null;let d=(s.get(u.id)??[]).map(a).filter(f=>f!==null);return{node:c.node,pose:c.pose,children:d}},l=n.map(u=>[u,a(u)]);return()=>{let u=new Set;for(let c of r){let d=i.get(c.id);d&&d.from===void 0&&u.add(c.id),i.delete(c.id)}for(let[c,d]of l)d&&!u.has(c.id)&&t.set(c.id,{id:c.id,parent:c.parent,...d,...o})}},takeBack(n){let r=t.get(n);return t.delete(n),r?.pose},drain(){if(t.size===0)return[];let n=[];for(let r of t.values()){let o=r.parent!==null?t.get(r.parent):void 0;o?o.children.push(r):n.push(r)}return t.clear(),n}}}var SJ=()=>{};function d4(e){let t=Ce(),n=new Map,r=c4(e.shown),o=null,i="call",s=0,a=0,l=0,u=0,c=()=>u>0&&l===0;function d(x){return s>0?{origin:x?"undo":"redo"}:a>0?{origin:"layout"}:e.untracked()?{origin:"untracked"}:o!==null?{origin:i,label:o}:{origin:"call"}}function f(x,w,g,P){if(!c())return;let S=n.get(x);S?S.to=g:n.set(x,{id:x,from:w,to:g,...d(P)})}function p(x,w){if(c())for(let g of x)n.set(g.id,{id:g.id,from:r.takeBack(g.id),to:g.pose,...d(w)})}let h=(x,w,g)=>c()?r.seeOff(x,w,d(g),n):SJ;function m(x,w,g){w();try{return x()}finally{g()}}let y={"kit:setPose":x=>({...x,apply:w=>{x.apply(w);let g=w;f(g.id,g.from,g.to,!1)},revert:w=>{x.revert(w);let g=w;f(g.id,g.to,g.from,!0)}}),"kit:add":x=>({...x,apply:w=>{x.apply(w),c()&&p([w],!1)},revert:w=>{let g=h([w],[w],!0);x.revert(w),g()}}),"kit:remove":x=>({...x,apply:w=>{let g=w,P=h(g.detached,g.nodes,!1);x.apply(w),P()},revert:w=>{x.revert(w),p(w.nodes,!0)}})};function b(){let x=r.drain();if(n.size===0&&x.length===0)return;let w=[...n.values()].filter(g=>!ro(g.from,g.to));n.clear(),(w.length>0||x.length>0)&&t.emit(w,x)}return e.changes.subscribe(b),{subscribe(x){let w=t.subscribe(x);u++;let g=!0;return()=>{g&&(g=!1,u--,w())}},labeled(x,w,g){if(o!==null)return g();o=x,i=w;try{return g()}finally{o=null}},replaying:x=>m(x,()=>{s++},()=>{s--}),layout:x=>m(x,()=>{a++},()=>{a--}),quiet:x=>m(x,()=>{l++},()=>{l--}),reporting:x=>(w,g)=>x(w,y[w]?.(g)??g)}}function f4(){let e={batch:0,engine:0,untracked:0,own:0},t=0;return{open:()=>t>0,records:()=>e.engine+e.untracked===0,untracked:()=>e.untracked>0,during(n,r){e[n]++,t++;try{return r()}finally{e[n]--,t--}}}}var p4="kit:setDoc";function dS(e,t,n){n===void 0?e.delete(t):e.set(t,n)}function h4(e){return{toJSON(){return e.size===0?void 0:Object.fromEntries(e)},reset(t){e.clear();for(let[n,r]of Object.entries(t??{}))dS(e,n,r)}}}function m4(e){let{values:t}=e;return e.register(p4,{apply:n=>{let{key:r,to:o}=n;dS(t,r,o)},revert:n=>{let{key:r,from:o}=n;dS(t,r,o)}}),{get:n=>t.get(n),set(n,r){let o=t.get(n);ro(o,r)||e.record(p4,{key:n,from:o,to:r},"setDoc")},keys:()=>[...t.keys()]}}function Iy(e,t){if(Object.is(e,t))return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((n,r)=>Iy(n,t[r]));if(tn(e)&&tn(t)){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(r=>r in t&&Iy(e[r],t[r]))}return!1}function y4(e,t,n){n===void 0?delete e[t]:e[t]=n}var g4={units:"kit:setUnits",clip:"kit:setClip"};function b4(e){for(let n of["units","clip"])e.register(g4[n],{apply:r=>{let{id:o,to:i}=r;y4(e.requireNode(o),n,i)},revert:r=>{let{id:o,from:i}=r;y4(e.requireNode(o),n,i)}});let t=(n,r,o)=>(i,s)=>{let a=e.requireNode(i)[n];e.refuse(i,o),!Iy(a,s??void 0)&&e.record(g4[n],{id:i,from:a,to:s??void 0},r)};return{setUnits:t("units","setUnits","set the units of"),setClip:t("clip","setClip","set the clip of")}}function x4(e,t,n){let r=HH({data:e}),o=r?.foundHidden;if(!r||!o||o.length===0)return null;let i=Array.isArray(t)?t:[],s=new Set(o.map(u=>i[u])),a=(Array.isArray(n)?n:[]).flatMap((u,c)=>s.has(u)?[c]:[]);if(a.length===o.length&&a.every((u,c)=>u===o[c]))return null;let l={...r,foundHidden:a};return a.length===0&&delete l.foundHidden,{...e,pathEffect:l}}function w4(e){return{bounds:e?.bounds??(t=>{let n=sS(t);return n===null?null:{x:n.x,y:n.y,width:n.width,height:n.height}}),remap:e?.remap??((t,n,r)=>({...t,...r}))}}function fS(e,t,n,r){let o=e.bounds(n,t),i=e.bounds(r,t);return o===null||i===null?o!==i:o.width!==i.width||o.height!==i.height}var kJ=16;function P4(e,t,n,r,o,i=new Map){let s=new Map,a=w=>s.get(w)??Hr(e,e.get(w)),l={getPose:w=>a(w),getParent:w=>e.get(w)?.parent??null,definesFrame:w=>{let g=e.get(w);return g===void 0||lt(g)}},{compose:u,decompose:c}=e.composition,d=w=>jt(l,w,u),f=[...new Set([...n.keys(),...r])],p=new Map,h=(w,g)=>{let P=a(w);Fo(P,g)||(s.set(w,g),w!==m&&t(w)!==null&&fS(o,w,P,g)&&f.push(w))},m=null,y=w=>{let g=BH(d(w),e.composition,S=>o.bounds(S,w),(S,v,A)=>o.remap(S,v,A,w));if(g===null)return null;let P=e.childrenOf(w).map(S=>({id:S,pose:g.toStrategy(d(S))}));return{...g,container:{id:w,bounds:g.bounds},children:P}},b=(w,g,P)=>{if(P.bounds){let S=e.get(w),v=g.toWorld(o.remap(g.upright,g.container.bounds,P.bounds,w));h(w,ma(l,v,S.parent,u,c))}for(let[S,v]of P.poses){let A=S;if(e.get(A)?.parent!==w)continue;let N=o.bounds(d(A),A);h(A,ma(l,g.toWorld(v),w,u,c)),x(A,N)}},x=(w,g)=>{let P=o.bounds(d(w),w);if(g===null||P===null)return;let S=P.x-g.x,v=P.y-g.y;if(S===0&&v===0)return;let A=BO({childrenOf:N=>e.childrenOf(N),poses:l,composition:e.composition},w,(N,M)=>{let C=o.bounds(N,M);return C===null?null:o.remap(N,C,{...C,x:C.x+S,y:C.y+v},M)});for(let[N,M]of A)h(N,M)};for(;f.length>0;){let w=f.shift();m=w;let g=(p.get(w)??0)+1;if(p.set(w,g),g>kJ)continue;let P=t(w);if(P===null||e.get(w)===void 0)continue;let S=g===1?n.get(w):void 0,v=g===1?i.get(w):void 0,A=!1;if(v!==void 0&&P.depart){let N=y(w);if(N===null)continue;let M=new Set(S??[]),C=N.children.filter(F=>!M.has(F.id));b(w,N,P.depart(N.container,C,new Set(v))),A=!0}if(S!==void 0&&P.arrive){let N=y(w);if(N===null)continue;let M=P.arrive(N.container,N.children,new Set(S));if(M===null)return null;b(w,N,M)}else if(!A||S!==void 0){let N=y(w);if(N===null)continue;b(w,N,{poses:P.childPoses(N.container,N.children)})}}return s}function T4(e){let{layoutFrame:t,layoutField:n,layoutRefs:r}=e,{requireNode:o,descendants:i}=e.store,{refuse:s,refuseLayer:a}=e.locks,{requireLayerIndex:l,assertSubtreeLayer:u}=e.layers,{record:c,edit:d,batch:f}=e.recorder,{noteChange:p,layoutDeclared:h}=e.arrivals;return{update(m,y){let b=o(m);s(m,"update"),c("kit:setData",{id:m,from:b.data,to:y.data},"update")},setPose(m,y){let b=o(m);s(m,"set the pose of");let x=b.layout!==void 0&&fS(t,m,b.pose,y),w=b.parent===null?void 0:o(b.parent),g=w?.layout!==void 0?w.id:null;d("setPose",x||g!==null,()=>{x&&p(m),p(g),c("kit:setPose",{id:m,from:b.pose,to:y},"setPose")})},setLayer(m,y){l(y);let b=o(m);if(s(m,"relayer"),b.layer!==y&&a(y,"move nodes onto"),b.parent!==null){let w=o(b.parent);u(m,y,b.parent,w.layer,"relayer")}if(b.layer===y)return;let x=[m];i(m,x);for(let w of x)s(w,"relayer");x.length===1?c("kit:setLayer",{id:m,from:b.layer,to:y},"setLayer"):f("setLayer",()=>{for(let w of x){let g=o(w);g.layer!==y&&c("kit:setLayer",{id:w,from:g.layer,to:y},"setLayer")}})},setDependsOn(m,y){let b=o(m);if(s(m,"retarget"),TO(b.dependsOn,y))return;let x=x4(b.data,b.dependsOn,y);if(x===null)return void c("kit:setDependsOn",{id:m,from:b.dependsOn,to:y},"setDependsOn");f("setDependsOn",()=>{c("kit:setDependsOn",{id:m,from:b.dependsOn,to:y},"setDependsOn"),c("kit:setData",{id:m,from:b.data,to:x},"setDependsOn")})},setLayout(m,y){let b=o(m);s(m,"set the layout of");let x;if(typeof y=="string"){if(x=n.fnOf(y)??null,x===null)throw new Error(`Scene: no layout "${y}" in this scene's registry`)}else x=y;let w=b.layout??null;if(w===x)return;x!==null&&h();let g=w===null?void 0:n.keyOf(w),P=x===null?void 0:n.keyOf(x),S={id:m,...g!==void 0?{fromKey:g}:{},...P!==void 0?{toKey:P}:{}};r.set(S,{from:w,to:x}),d("setLayout",!0,()=>{p(m),c("kit:setLayout",S,"setLayout")})}}}function S4(e,t){t===void 0?delete e.parallax:e.parallax=t}function k4(e){let{state:t,requireLayerIndex:n,rebuildLayerIndex:r}=e;function o(s,a){e.register(s,a)}o("kit:setLayerVisible",{apply:s=>{t.layers[n(s.layer)].visible=s.to,s.to||e.narrowSelection()},revert:s=>{t.layers[n(s.layer)].visible=s.from}}),o("kit:setLayerLocked",{apply:s=>{t.layers[n(s.layer)].locked=s.to,s.to&&e.narrowSelection()},revert:s=>{t.layers[n(s.layer)].locked=s.from}}),o("kit:setLayerParallax",{apply:s=>{S4(t.layers[n(s.layer)],s.to)},revert:s=>{S4(t.layers[n(s.layer)],s.from)}}),o("kit:addLayer",{apply:s=>{t.layers.splice(s.index,0,{...s.record}),r()},revert:s=>{t.layers.splice(s.index,1),r()}}),o("kit:removeLayer",{apply:s=>{t.layers.splice(s.index,1),r()},revert:s=>{t.layers.splice(s.index,0,{...s.record}),r()}}),o("kit:renameLayer",{apply:s=>{t.layers[n(s.layer)].name=s.to},revert:s=>{t.layers[n(s.layer)].name=s.from}});function i(s,a){let[l]=t.layers.splice(n(s),1);t.layers.splice(a,0,l),r()}o("kit:moveLayer",{apply:s=>i(s.layer,s.to),revert:s=>i(s.layer,s.from)})}function vJ(e){let{detach:t,attach:n,invalidateChildDerivedFrom:r,invalidateDependents:o}=e.store;return(i,s,a,l)=>{t(i),n(i,a,l),r(s),o(i),s!==a&&e.narrowSelection()}}function v4(e){let{state:t,requireLayerIndex:n,invalidateOrder:r,fnFields:o}=e,{dependents:i,childDerived:s,invalidateDependents:a,invalidateChildDerivedFrom:l,trackChildDerived:u,retarget:c,requireNode:d,detach:f,attach:p,addedFns:h,restoreNodeFunctions:m}=e.store;function y(g,P){e.register(g,P)}let b=vJ(e);y("kit:add",{apply:g=>{if(t.nodes.has(g.id))throw new Error(`Scene: id collision on "${g.id}"`);let P={kind:g.kind,id:g.id,layer:g.layer,pose:g.pose,data:g.data,parent:g.parent};t.nodes.set(g.id,P),p(g.id,g.parent,g.index),g.dependsOn!==void 0&&(P.dependsOn=g.dependsOn),Object.assign(P,lr(g)),e.noteWritten(P),i.add(g.id,g.dependsOn==="children"?[]:g.dependsOn??[]),u(g.id,g.dependsOn);let S=P,v=h.get(g);for(let A of o){let N=v?.get(A);if(N!==void 0){A.write(S,N);continue}let M=g[A.spec.opKey];M!==void 0&&td(A,S,M,"kit:add",Mt)}a(g.id)},revert:g=>{e.clearOverride(g.id),f(g.id),t.nodes.delete(g.id),i.remove(g.id),s.delete(g.id),l(g.parent),a(g.id)}}),y("kit:remove",{apply:g=>{for(let P of g.nodes)e.clearOverride(P.id);for(let P of g.detached)f(P.id);for(let P of g.nodes)t.nodes.delete(P.id),i.remove(P.id),s.delete(P.id);for(let P of g.detached)l(P.parent);e.narrowSelection(new Set(g.nodes.map(P=>P.id)))},revert:g=>{let P=new Map((g.fnKeys??[]).map(S=>[S.id,S]));for(let S of g.nodes){let v=S.children?{...S,children:[...S.children]}:{...S};m(v,P.get(S.id)),t.nodes.set(S.id,v),e.noteWritten(v),i.add(S.id,v.dependsOn==="children"?[]:v.dependsOn??[]),u(S.id,v.dependsOn)}for(let S of g.detached)p(S.id,S.parent,S.index);for(let S of g.detached)l(S.parent)}}),y("kit:setPose",{apply:g=>{d(g.id).pose=g.to,a(g.id)},revert:g=>{d(g.id).pose=g.from,a(g.id)}}),y("kit:setData",{apply:g=>{d(g.id).data=g.to,a(g.id)},revert:g=>{d(g.id).data=g.from,a(g.id)}}),y("kit:setLayer",{apply:g=>{n(g.to),d(g.id).layer=g.to,r(),a(g.id)},revert:g=>{d(g.id).layer=g.from,r(),a(g.id)}}),y("kit:setDependsOn",{apply:g=>{c(g.id,g.to)},revert:g=>{c(g.id,g.from)}});let x=new WeakMap;function w(g,P){let S=d(g.id),v=o.find(C=>C.spec.field==="layout"),A=x.get(g),N=P==="from"?g.fromKey:g.toKey;if(A===void 0&&N!==void 0){delete S.layout,td(v,S,N,"kit:setLayout",Mt);return}let M=A?.[P]??null;M===null?delete S.layout:v.write(S,M)}return y("kit:setLayout",{apply:g=>{w(g,"to")},revert:g=>{w(g,"from")}}),y("kit:move",{apply:g=>b(g.id,g.fromParent,g.toParent,g.toIndex),revert:g=>b(g.id,g.toParent,g.fromParent,g.fromIndex)}),k4(e),{layoutRefs:x}}function A4(e,t,n){n?e[t]=!0:delete e[t]}var R4={hidden:"kit:setHidden",locked:"kit:setLocked"};function N4(e){for(let n of["hidden","locked"])e.register(R4[n],{apply:r=>{let{id:o,to:i}=r,s=e.requireNode(o);A4(s,n,i),e.noteWritten(s),n==="hidden"&&e.invalidateDependents(o),i&&e.narrowSelection()},revert:r=>{let{id:o,from:i}=r,s=e.requireNode(o);A4(s,n,i),e.noteWritten(s),n==="hidden"&&e.invalidateDependents(o)}});let t=(n,r)=>(o,i)=>{let s=e.requireNode(o)[n]===!0;s!==i&&e.record(R4[n],{id:o,from:s,to:i},r)};return{setHidden:t("hidden","setHidden"),setLocked:t("locked","setLocked")}}function I4(e,t){function n(s){e.layers.length=0,e.layerIndex.clear(),t();for(let a of s){if(e.layerIndex.has(a.id))throw new Error(`Scene: duplicate ${a.kind} layer id "${a.id}"`);e.layerIndex.set(a.id,e.layers.length),e.layers.push(a)}}function r(s){let a=e.layerIndex.get(s);if(a===void 0)throw new Error(`Scene: unknown layer "${s}"`);return a}function o(){t(),e.layerIndex.clear();for(let s=0;s<e.layers.length;s++)e.layerIndex.set(e.layers[s].id,s)}function i(s,a,l,u,c="place"){if(r(a)<r(u)){let d=c==="place"?`cannot place node '${s??"<new>"}' on layer '${a}' under parent '${l}' on layer '${u}'`:`cannot setLayer('${s??"<new>"}', '${a}') \u2014 node has parent '${l}' on layer '${u}'`;throw new Error(`Scene: ${d} \u2014 a child may not render below its parent's layer`)}}return{reset:n,requireLayerIndex:r,rebuildLayerIndex:o,assertSubtreeLayer:i}}function AJ(e,t,n,r){let o=new Map;for(let i=0;i<t.length;i++)o.set(t[i].id,i);for(let i of e.values()){if(i.parent===null)continue;let s=e.get(i.parent);if(s&&o.get(i.layer)<o.get(s.layer))throw new Error(`Scene: moveLayer("${n}", ${r}) \u2014 a child may not render below its parent's layer`)}}function E4(e){let{layers:t,nodes:n,requireLayerIndex:r,record:o}=e;function i(s,a){let l=t[r(s)];if(l.kind!=="user")throw new Error(`Scene: cannot ${a} system layer "${s}"`);return l}return{setLayerVisible(s,a){let l=t[r(s)];o("kit:setLayerVisible",{layer:s,from:l.visible,to:a},"setLayerVisible")},setLayerLocked(s,a){let l=t[r(s)];o("kit:setLayerLocked",{layer:s,from:l.locked,to:a},"setLayerLocked")},setLayerParallax(s,a){let l=t[r(s)];o("kit:setLayerParallax",{layer:s,from:l.parallax,to:a},"setLayerParallax")},addLayer(s){if(e.layerIndex.has(s.id))throw new Error(`Scene: duplicate layer id "${s.id}"`);let a=Math.max(0,Math.min(s.index??t.length,t.length)),l={kind:"user",id:s.id,name:s.name,visible:s.visible??!0,locked:s.locked??!1,...s.parallax?{parallax:s.parallax}:{},...s.annotation?{annotation:!0}:{}};o("kit:addLayer",{record:l,index:a},"addLayer")},removeLayer(s){let a=i(s,"remove");e.lifted(()=>e.batch("removeLayer",()=>{let l=[];for(let[u,c]of n)c.layer===s&&l.push(u);e.removeMany(l),o("kit:removeLayer",{record:a,index:r(s)},"removeLayer")}))},renameLayer(s,a){let l=i(s,"rename");o("kit:renameLayer",{layer:s,from:l.name,to:a},"renameLayer")},moveLayer(s,a){let l=r(s),u=Math.max(0,Math.min(a,t.length-1));if(l===u)return;let c=[...t],[d]=c.splice(l,1);c.splice(u,0,d),AJ(n,c,s,a),o("kit:moveLayer",{layer:s,from:l,to:u},"moveLayer")}}}var ll=class extends Error{};function M4(e){let t=0,n=new WeakMap,r=a=>a===null||e.has(a),o=(a,l)=>{let u=e.get(a);return u===void 0||!Jt(u)||u.children.every(c=>l?.has(c)===!0)};function i(a,l,u){switch(a){case"kit:add":{let c=l;return u?e.has(c.id)||!r(c.parent):!e.has(c.id)||!o(c.id)}case"kit:remove":{let c=l;if(!u)return c.nodes.some(f=>e.has(f.id))||!c.detached.every(f=>r(f.parent));let d=new Set(c.nodes.map(f=>f.id));return!c.nodes.every(f=>e.has(f.id)&&o(f.id,d))}case"kit:move":{let c=l;return!e.has(c.id)||!r(u?c.toParent:c.fromParent)}case"kit:setPose":case"kit:setData":case"kit:setLayer":case"kit:setDependsOn":case"kit:setLayout":case"kit:setUnits":case"kit:setClip":return!e.has(l.id);default:return!1}}function s(a,l,u){return t===0||typeof l!="object"||l===null?!1:n.get(l)===!u?n.delete(l):i(a,l,u)?(n.set(l,u),!0):!1}return{during(a){t++;try{return a()}finally{t--}},skips:s}}function RJ(e,t,n,r){let o=e.map(a=>{let l=n.requireNode(a);return l.children?{...l,children:[...l.children]}:{...l}}),i=o.filter(a=>a.parent===null||!t.has(a.parent)).map(a=>({id:a.id,parent:a.parent,index:n.siblingsOf(a.parent).indexOf(a.id)})).sort((a,l)=>a.index-l.index),s=o.flatMap(a=>{let l=is(r,a,"opKey");return Object.keys(l).length===0?[]:[{id:a.id,...l}]});return{nodes:o,detached:i,...s.length>0?{fnKeys:s}:{}}}function C4(e){let{nodes:t,fnFields:n}=e,{requireNode:r,siblingsOf:o,descendants:i,removalClosure:s,patchNodeFunctions:a}=e.store,{refuse:l,refuseLayer:u}=e.locks,{requireLayerIndex:c,assertSubtreeLayer:d}=e.layers,{record:f,edit:p}=e.recorder,{noteArrival:h,noteDeparture:m,noteChange:y}=e.arrivals;function b(w){let g=w.id??e.generateId();if(t.has(g))throw new ll(`Scene: id collision on "${g}"`);c(w.layer),u(w.layer,"add to");let P=w.parent??null;if(P!==null){let v=r(P);d(w.id,w.layer,P,v.layer),l(P,"add under")}let S={id:g,kind:w.kind,layer:w.layer,pose:w.pose,data:w.data,parent:P,index:w.index??o(P).length};return w.dependsOn!==void 0&&(S.dependsOn=w.dependsOn),Object.assign(S,lr(w),is(n,w,"opKey"))}function x(w){if(w.length===0)return;let{ids:g,removing:P}=s(w);for(let A of g)l(A,"remove");let S=RJ(g,P,e.store,n),{detached:v}=S;p("remove",v.some(A=>A.parent!==null),()=>{for(let A of v)m(A.id,A.parent,null);f("kit:remove",S,"remove")})}return{construct(w){e.locks.lifted(()=>{for(let g of w){let P=b(g);e.runOp("kit:add",P),a(g,P.id,null)}})},add(w){let g=b(w),P=`add ${w.kind}`;return p(P,g.parent!==null,()=>(h(g.id,g.parent,null),f("kit:add",g,P),a(w,g.id,g),g.id))},remove:w=>x([w]),removalClosure:w=>s(w).ids,removeMany:x,move(w,g,P){let S=r(w);if(l(w,"move"),g!==null){l(g,"move nodes into");let A=r(g);if(d(w,S.layer,g,A.layer),g===w)throw new Error("Scene: cannot parent a node to itself");let N=[];if(i(w,N),N.includes(g))throw new Error("Scene: cannot parent a node to its own descendant")}let v=S.parent;p("move",g!==null||v!==null,()=>{let A=o(v).indexOf(w),N=P??o(g).length;h(w,g,v),m(w,v,g),y(v),f("kit:move",{id:w,fromParent:v,fromIndex:A,toParent:g,toIndex:N},"move")})},reorder(w,g){let P=r(w);l(w,"reorder");let S=P.parent;p("reorder",S!==null,()=>{y(S);let v=o(S).indexOf(w);f("kit:move",{id:w,fromParent:S,fromIndex:v,toParent:S,toIndex:g},"reorder")})}}}function O4(e){let{state:t,store:n,locks:r,layers:o,fnFields:i,recorder:s,arrivals:a}=e,{layoutRefs:l}=v4({state:t,register:e.ops.register,store:n,requireLayerIndex:o.requireLayerIndex,rebuildLayerIndex:o.rebuildLayerIndex,invalidateOrder:e.invalidateOrder,fnFields:i,narrowSelection:e.narrowSelection,clearOverride:e.clearOverride,noteWritten:r.noteWritten}),{construct:u,...c}=C4({nodes:t.nodes,generateId:e.generateId,store:n,locks:r,layers:o,fnFields:i,runOp:e.ops.run,recorder:s,arrivals:a}),d=T4({store:n,locks:r,layers:o,recorder:s,arrivals:a,layoutFrame:e.layoutFrame,layoutField:i.find(y=>y.spec.field==="layout"),layoutRefs:l}),f=E4({layers:t.layers,layerIndex:t.layerIndex,nodes:t.nodes,requireLayerIndex:o.requireLayerIndex,record:s.record,lifted:r.lifted,batch:s.batch,removeMany:c.removeMany}),p=N4({register:e.ops.register,requireNode:n.requireNode,record:s.record,narrowSelection:()=>e.narrowSelection(),invalidateDependents:n.invalidateDependents,noteWritten:r.noteWritten}),h=b4({register:e.ops.register,requireNode:n.requireNode,refuse:r.refuse,record:s.record}),m=m4({values:t.docValues,register:e.ops.register,record:s.record});return{construct:u,methods:{...c,...d,...f,...p,...h,doc:m}}}var NJ={log:e=>Ah("history",e),warn:e=>Mt("history",e)};function F4(e,t={}){let n=t.rebuildOp;return nd(e,{debug:NJ,...t,rebuildOp:(r,o)=>n?.(r,o)??Ay(r,o)})}function L4(e){let t=null;return{atomically(n,r){let o=t,i=[],s=e.getSelection();t=i;try{let a=n();return o&&!r()&&o.push(...i),a}catch(a){throw t=null,e.lifted(()=>{for(let l=i.length-1;l>=0;l--){let{kind:u,payload:c,reverted:d}=i[l],f=e.registered.get(u);(d?f.apply:f.revert)(c)}}),e.setSelection(s),i.length>0&&e.notify(),a}finally{t=o}},logApplied(n,r,o){t?.push(o===void 0?{kind:n,payload:r}:{kind:n,payload:r,reverted:o})}}}var IJ=()=>({added:new Set,removed:new Set,posed:new Set,reparented:new Set,dataChanged:new Set,docChanged:new Set}),EJ=e=>({added:new Set(e.added),removed:new Set(e.removed),posed:new Set(e.posed),reparented:new Set(e.reparented),dataChanged:new Set(e.dataChanged),docChanged:new Set(e.docChanged)}),_4={name:"editPass",args:{},elideNoop:!0,apply:()=>"noop",invert:()=>_4};function MJ(e,t,n){let r=n;switch(t){case"kit:add":e.added.add(r.id);break;case"kit:remove":for(let o of r.nodes??[])e.removed.add(o.id);break;case"kit:setPose":e.posed.add(r.id);break;case"kit:setData":e.dataChanged.add(r.id);break;case"kit:setDoc":e.docChanged.add(r.key);break;case"kit:move":r.fromParent!==r.toParent&&e.reparented.add(r.id);break;default:break}}function D4(e){let t=[],n=null;function r(){let o=n;if(o===null)return 0;let i=0;try{for(let{pass:s}of[...t]){let a=s(EJ(o));if(a===null)continue;let l=e.adapter();for(let u of a)u.apply(l),i++}}finally{n=null}return i}return{add(o,i){let s={pass:o,order:i?.order??0},a=t.findIndex(l=>l.order>s.order);return t.splice(a<0?t.length:a,0,s),()=>{let l=t.indexOf(s);l>=0&&t.splice(l,1)}},any:()=>t.length>0,open(){return n!==null||t.length===0?!1:(n=IJ(),!0)},note(o,i){n!==null&&!e.untracked()&&MJ(n,o,i)},run:r,abandon(){n=null},op(){return{name:"editPass",args:{},label:"Edit pass",elideNoop:!0,apply:()=>r()>0?void 0:"noop",invert:()=>_4}}}}function CJ(e,t,n){let{replay:r,notify:o}=t,i={targetId:e.targetId,forkedAtEntryId:e.forkedAtEntryId,applyBatch(s,a){t.labeled(a,()=>t.runArrivalEdit(s,l=>{t.applying(()=>e.applyBatch(l.map(t.causing),a)),o()}))},undo(){r(()=>e.undo()),o()},redo(){r(()=>e.redo()),o()},canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),entries:()=>e.entries(),seal:()=>e.seal(),observe:s=>e.observe(s),beginJournal:s=>n.wrap(e.beginJournal(s)),getVersion:()=>e.getVersion(),subscribe:s=>e.subscribe(s),commit(s){e.commit(s),n.close(i),o()},cancel(){r(()=>e.cancel()),n.close(i),o()},suspend:()=>e.suspend(),isActive:()=>e.isActive()};return i}function B4(e){let t=new WeakMap,n=[],r={wrap(o){let i=CJ(o,e,r);return t.set(i,o),n.push(i),i},close(o){let i=n.indexOf(o);i>=0&&n.splice(i,1)}};return{begin(o){let i=e.activeJournal();return r.wrap(i?(t.get(i)??i).beginJournal(o):e.engine.beginJournal(o))},resume:o=>e.engine.resumeJournal(t.get(o)??o),innermost(){for(let o=n.length-1;o>=0;o--)if(n[o].isActive())return n[o];return null}}}function G4(e){let{engine:t,replay:n,notify:r,refuseUntracked:o,runArrivalEdit:i}=e,s=B4(e);function a(d,f){return d()?(n(f),r(),!0):!1}let l=()=>e.activeJournal()??t,u={undo(){let d=e.activeJournal();return d?d.canUndo()?(d.undo(),!0):!1:a(()=>t.canUndo(),()=>t.undo())},redo(){let d=e.activeJournal();return d?d.canRedo()?(d.redo(),!0):!1:a(()=>t.canRedo(),()=>t.redo())},canUndo:()=>l().canUndo(),canRedo:()=>l().canRedo(),historyEntries(){let{undo:d,redo:f}=t.entries();return[...d,...f].map(p=>({id:String(p.id),label:p.label}))},historyIndex:()=>t.undoDepth(),jumpToHistoryIndex(d){let f=t.undoDepth()+t.redoDepth(),p=Math.max(0,Math.min(f,d));return a(()=>p!==t.undoDepth(),()=>t.goto(p))},serializeHistory:()=>({...t.serialize(),form:4}),restoreHistory(d){if(d.form!==4){Mt("scene","restoreHistory: snapshot is not in the current recorded form \u2014 dropped");return}t.restore(d),r()}};return{history:{apply(d,f){o("history.apply"),e.labeled(f??d.label??"",()=>i([d],p=>{let h=()=>p.length===1?t.apply(e.causing(d),f):t.applyOps(p.map(e.causing),f??d.label??"");e.applying(h),r()}))},applyOps(d,f){o("history.applyOps"),e.labeled(f,()=>i(d,p=>{e.applying(()=>t.applyOps(p.map(e.causing),f)),r()}))},undo:()=>{u.undo()},redo:()=>{u.redo()},goto:d=>{u.jumpToHistoryIndex(d)},clear(){t.clear(),r()},recordEntry(d,f,p){t.recordEntry(d,f,p),r()},prune(d){t.prune(d),r()},switchBranch(d){t.switchBranch(d),r()},restore:u.restoreHistory,canUndo:u.canUndo,canRedo:u.canRedo,undoDepth:()=>t.undoDepth(),redoDepth:()=>t.redoDepth(),entries:()=>t.entries(),timestampAt:d=>t.timestampAt(d),depthAt:d=>t.depthAt(d),branches:()=>t.branches(),getVersion:()=>t.getVersion(),subscribe:d=>t.subscribe(d),observe:d=>t.observe(d),serialize:u.serializeHistory,allForwardOps:()=>t.allForwardOps(),seal:()=>t.seal(),currentEntryId:()=>t.currentEntryId(),beginJournal:s.begin,resumeJournal:s.resume,activeJournal:()=>e.activeJournal()},methods:u,openJournal:s.innermost}}function U4(e){let t=new Map;function n(s){let a=t.get(s);if(!a)throw new Error(`Scene: no registered op for kind "${s}"`);return a}function r(s,a){let l;if(s.startsWith("kit:")){if(a===null||typeof a!="object")return;let u=a;l=typeof u.id=="string"?u.id:typeof u.layer=="string"?u.layer:void 0}else l=t.get(s)?.coalesceKey?.(a);return l===void 0?void 0:`${s}:${l}`}function o(s,a,l){let u=n(s);if(e.skips(s,a,l))return"noop";(l?u.apply:u.revert)(a),e.applied(s,a,!l)}function i(s,a,l=!0){return n(s),{name:s,args:a,coalesceKey:r(s,a),apply:()=>{if(e.driven())return o(s,a,l);let u;return e.replayAlone(()=>{u=o(s,a,l)}),u},invert:()=>i(s,a,!l)}}return{handlers:t,register:(s,a)=>{t.set(s,a)},run:(s,a)=>n(s).apply(a),op:(s,a)=>i(s,a)}}function rd(e,t){return{name:e.name,args:e.args,label:e.label,get coalesceKey(){return e.coalesceKey},elideNoop:e.elideNoop,apply:()=>e.apply(t),invert:()=>rd(e.invert(),t)}}function pS(e,t){return{name:e.name,args:e.args,label:e.label,get coalesceKey(){return e.coalesceKey},elideNoop:e.elideNoop,apply:()=>{let n=t();if(!n)return Mt("scene",`restored op "${e.name??"?"}" has no history adapter \u2014 skipping (setHistoryAdapter was not wired)`),"noop";try{return e.apply(n())}catch(r){return Mt("scene",`restored op "${e.name??"?"}" failed against the history adapter \u2014 skipping: ${String(r)}`),"noop"}},invert:()=>pS(e.invert(),t)}}function OJ(e,t){let n=t===void 0||e.coalesceKey===void 0?void 0:`${t}>${e.coalesceKey}`;return{name:e.name,args:e.args,coalesceKey:n,apply:e.apply,invert:e.invert}}function W4(e){let t=null,n=e.getActiveJournal;function r(o,i=o){if(o.caused)return o;let s=[i];return{get name(){return o.name},get args(){return o.args},label:o.label,get coalesceKey(){return o.coalesceKey},elideNoop:o.elideNoop,apply(a){let{result:l,ops:u}=e.recorder().capturing(()=>i.apply(a));return u.length>0&&(s=u.map(c=>OJ(c,o.coalesceKey))),l},caused:()=>s,invert:()=>i.invert()}}return{rebuild(o,i){let s=e.own(o,i);if(s!==null)return s;let a=Ay(o,i);return a===null?null:pS(a,()=>t)},causing:o=>r(o),apply(o,i,s,a){if(e.recorder().joins())return e.recorder().join(i,a);let l=e.openJournal()??n?.()??null;e.driving(()=>{let u=i.map(c=>r(c,rd(c,a)));l?l.applyBatch(u,s):o.applyOps(u,s)})},setHistoryAdapter(o){t=o},setActiveJournalAccessor(o){n=o},activeJournal:()=>e.openJournal()??n?.()??null}}function V4(e){for(let t=e.length-1;t>=0;t--)try{e[t].invert().apply(void 0)}catch{}}function z4(e){let{notifier:t,mode:n,engine:r,log:o,arrivals:i,passes:s}=e,a=null,l=null;function u(f,p,h=!1){let m=f();if(p)for(let y of i.settle())e.writePose(y.id,y.to);return h&&s.run(),m}function c(f,p,h={}){let m=!n.open();m&&(a={label:f,ops:[],outer:[],entry:{selectionBefore:e.selection(),...h}});let y=m&&i.open(!0),b=m&&s.open();return e.labeled(f,"call",()=>t.deferred(()=>n.during("batch",()=>{if(!m)return p();try{let x=o.atomically(()=>u(p,y,b),()=>(a?.ops.length??0)>0);return y&&i.emitReflow(),x}catch(x){throw V4(a?.outer??[]),a=null,x}}),()=>{if(y&&i.abandon(),b&&s.abandon(),!m||!a)return;let x=a;a=null,x.ops.length>0&&r.recordEntry(x.ops,x.label,x.entry)}))}function d(f,p,h){if(n.records()&&!a&&s.any())return void c(h,()=>d(f,p,h));s.note(f,p),e.labeled(h,"call",()=>{n.records()&&!a?n.during("own",()=>r.applyOps([e.makeOp(f,p)],h)):(e.runOp(f,p),o.logApplied(f,p),n.records()?a.ops.push(e.makeOp(f,p)):n.untracked()||l?.push(e.makeOp(f,p)))}),t.notify()}return{record:d,edit:(f,p,h)=>p&&i.bareLayoutEdit()?c(f,h):h(),batch:c,untracked(f){let p=t.version(),h=i.open(!0);return t.deferred(()=>n.during("untracked",()=>{let m=o.atomically(()=>u(f,h),()=>!1);return h&&i.emitReflow(),m}),()=>{h&&i.abandon(),t.version()!==p&&r.seal()})},joins:()=>n.records()&&a!==null,join(f,p){let h=a,m=h.ops.length,y=[];try{o.atomically(()=>{for(let b of f){let x=h.ops.length,w=b.apply(p);h.ops.length>x||w===!1||w==="noop"||(y.push(rd(b,p)),h.ops.push(y[y.length-1]))}},()=>!1)}catch(b){throw V4(y),h.ops.length=m,b}h.outer.push(...y)},capturing(f){let p=l,h=[];l=h;try{return{result:f(),ops:h}}finally{l=p}},engineDriven:f=>n.during("engine",()=>t.muted(f))}}function K4(e){let{notifier:t,mode:n,stale:r,lifted:o,selection:i,arrivals:s,config:a,poseWrites:l}=e,{notify:u}=t,c=D4({adapter:e.passAdapter,untracked:n.untracked}),d=(M,C)=>s.runEdit(M,F=>{if(!c.open())return C(F);try{C([...F,c.op()])}finally{c.abandon()}}),f=U4({driven:n.open,replayAlone:M=>{P(M),u()},skips:r.skips,applied:(M,C,F)=>{n.records()||b(M,C,F)}}),p=W4({own:(M,C)=>f.handlers.has(M)?f.op(M,C):null,recorder:()=>x,driving:M=>t.deferred(()=>n.during("engine",()=>y(M,()=>!0))),getActiveJournal:a.getActiveJournal??null,openJournal:()=>N()}),h=F4(void 0,{selection:{get:i.get,set:M=>i.set(M)},...a.coalesceWindowMs!==void 0?{coalesceWindowMs:a.coalesceWindowMs}:{},...a.historyLimit!==void 0?{historyLimit:a.historyLimit}:{},rebuildOp:p.rebuild}),m=L4({registered:f.handlers,lifted:o,getSelection:i.get,setSelection:i.replace,notify:u}),{atomically:y,logApplied:b}=m,x=z4({notifier:t,mode:n,engine:h,runOp:f.run,makeOp:f.op,log:m,arrivals:s,passes:c,selection:i.get,writePose:e.writePose,labeled:l.labeled}),{record:w,engineDriven:g}=x;function P(M){l.replaying(()=>y(()=>o(()=>r.during(()=>g(M))),()=>!0))}function S(M){if(n.untracked())throw new Error(`Scene: cannot ${M} inside untracked() \u2014 it records`)}let{history:v,methods:A,openJournal:N}=G4({engine:h,applying:M=>y(()=>g(M),()=>!0),causing:p.causing,replay:P,notify:u,refuseUntracked:S,runArrivalEdit:d,labeled:(M,C)=>l.labeled(M,"ops",C),activeJournal:p.activeJournal});return{ops:f,recorder:x,clearHistory:()=>h.clear(),methods:{registerOp(M,C){if(M.startsWith("kit:"))throw new Error(`Scene: op kind "${M}" is reserved (kit:* prefix)`);f.register(M,C)},recordOp(M){w(M.kind,M.payload,M.kind)},applyBatch(M,C,F){return S("applyBatch"),l.labeled(C,"ops",()=>d(M,D=>p.apply(h,D,C,F)))},history:v,...A,batch:x.batch,untracked:x.untracked,setActiveJournalAccessor:p.setActiveJournalAccessor,setHistoryAdapter:p.setHistoryAdapter,addEditPass:c.add}}}function j4(e,t){let n=s=>$c(e(s),t),r=[],o=0,i=Ce();return{get:()=>r,legal:n,set(s){r=n(s),o++,i.emit()},narrow(s){let a=s!==void 0&&r.some(l=>s.has(l))?r.filter(l=>!s.has(l)):r;r=n(a)},replace(s){r=s},subscribe:i.subscribe,changes:()=>o}}function $4(e){let t=0,n=!1,r={get layers(){return e.layers},get:i=>e.nodes.get(i)},o=i=>(n||e.layers.some(s=>s.locked))&&$3(r,i);return{isLocked:o,isHidden:i=>j3(r,i),refuse(i,s){if(!(t>0||!o(i)))throw new Error(`Scene: cannot ${s} "${i}" \u2014 it is locked`)},refuseLayer(i,s){if(!(t>0||!e.layers[e.layerIndex.get(i)??-1]?.locked))throw new Error(`Scene: cannot ${s} layer "${i}" \u2014 it is locked`)},reachable(i){if(i.length===0)return i;let s=ol(r);return i.some(a=>s.locked(a)||s.hidden(a))?i.filter(a=>!s.locked(a)&&!s.hidden(a)):i},noteWritten(i){i.locked===!0&&(n=!0)},lifted(i){t++;try{return i()}finally{t--}}}}function Y4(e,t,n){let r=PO(),o=new Set;function i(x){if(s(e.nodes.get(x)?.parent??null),r.isEmpty())return;let w=[x];p(x,w);for(let g of w)for(let P of r.transitiveDependentsOf(g)){let S=e.nodes.get(P);S!==void 0&&un(S)}}function s(x){if(o.size===0)return;let w=x;for(;w!==null;){let g=e.nodes.get(w);if(g===void 0)return;if(o.has(w)){un(g);for(let P of r.transitiveDependentsOf(w)){let S=e.nodes.get(P);S!==void 0&&un(S)}}w=g.parent}}function a(x,w){w==="children"?o.add(x):o.delete(x)}function l(x,w){let g=u(x);w===void 0?delete g.dependsOn:g.dependsOn=w,r.add(x,w===void 0||w==="children"?[]:w),a(x,w),un(u(x)),i(x)}function u(x){let w=e.nodes.get(x);if(!w)throw new ll(`Scene: unknown node id "${x}"`);return w}function c(x){if(x===null)return e.roots;let w=u(x);return w.children??=[]}function d(x){let w=u(x),g=c(w.parent),P=g.indexOf(x);if(P<0)throw new Error(`Scene: node "${x}" not found in its parent's children`);return g.splice(P,1),t(),{parent:w.parent,index:P}}function f(x,w,g){let P=c(w),S=Math.max(0,Math.min(g,P.length));P.splice(S,0,x);let v=u(x);v.parent=w,t()}function p(x,w){let g=e.nodes.get(x);if(g?.children)for(let P of g.children)w.push(P),p(P,w)}function h(x){let w=[],g=new Set;function P(S){if(g.has(S))return;g.add(S),w.push(S);let v=[];p(S,v);for(let A of v)g.has(A)||(g.add(A),w.push(A))}for(let S of x)P(S);for(let S=0;S<w.length;S++)for(let v of r.transitiveDependentsOf(w[S]))P(v);return{ids:w,removing:g}}let m=new WeakMap;function y(x,w,g){let P=e.nodes.get(w);if(P===void 0)return;let S=new Map;for(let v of n){let A=x[v.spec.field];A!==void 0&&(v.write(P,A),S.set(v,A))}g&&S.size>0&&m.set(g,S)}function b(x,w){if(!w)return;let g=x;for(let P of n){if(P.read(g)!==void 0)continue;let S=w[P.spec.opKey];S!==void 0&&td(P,g,S,"kit:remove",Mt)}}return{dependents:r,childDerived:o,invalidateDependents:i,invalidateChildDerivedFrom:s,trackChildDerived:a,retarget:l,requireNode:u,siblingsOf:c,detach:d,attach:f,descendants:p,removalClosure:h,addedFns:m,patchNodeFunctions:y,restoreNodeFunctions:b}}function q4(e){function t(){return e.layers.length===1?l():c()}function n(){return e.layers.length===1?u():d()}let r=0,o={gen:0};function i(){r++}let s=[];function a(){return o.gen!==r&&(o={gen:r}),o}function l(){let f=e.layers[0].id,p=[],h=[...e.roots].reverse();for(;h.length>0;){let m=h.pop(),y=e.nodes.get(m);if(y&&(y.layer===f&&p.push(m),Jt(y)))for(let b=y.children.length-1;b>=0;b--)h.push(y.children[b])}return p}function u(){let f=e.layers[0].id,p=[],h=[...e.roots].reverse();for(;h.length>0;){let m=h.pop(),y=e.nodes.get(m);if(y&&(y.layer===f&&p.push(y),Jt(y)))for(let b=y.children.length-1;b>=0;b--)h.push(y.children[b])}return p}function c(){let f=e.layers.map(()=>[]),p=[...e.roots].reverse();for(;p.length>0;){let m=p.pop(),y=e.nodes.get(m);if(!y)continue;let b=f[e.layerIndex.get(y.layer)??-1];if(b&&b.push(m),Jt(y))for(let x=y.children.length-1;x>=0;x--)p.push(y.children[x])}let h=[];for(let m of f)for(let y of m)h.push(y);return h}function d(){let f=e.layers.map(()=>[]),p=[...e.roots].reverse();for(;p.length>0;){let m=p.pop(),y=e.nodes.get(m);if(!y)continue;let b=f[e.layerIndex.get(y.layer)??-1];if(b&&b.push(y),Jt(y))for(let x=y.children.length-1;x>=0;x--)p.push(y.children[x])}let h=[];for(let m of f)for(let y of m)h.push(y);return h}return{ids(){let f=a();return f.ids??=t()},nodes(){let f=a();return f.nodes??=n()},nodesOnLayer(f){let p=a(),h=p.byLayer;if(!h){h=new Map;for(let m of p.nodes??=n()){let y=h.get(m.layer);y||h.set(m.layer,y=[]),y.push(m)}p.byLayer=h}return h.get(f)??s},invalidate:i}}function X4(e,t){let n=[],r=[...e].reverse();for(;r.length>0;){let o=t.get(r.pop());if(o&&(n.push(o),Jt(o)))for(let i=o.children.length-1;i>=0;i--)r.push(o.children[i])}return n}function hS(e,t){let n=new Map;for(let o of e)o.id!==void 0&&n.set(o.id,o);let r=o=>{let i=new Set,s=o.parent==null?void 0:n.get(o.parent);for(;s!==void 0&&s.id!==void 0&&!i.has(s.id);){if(lt(s))return s;i.add(s.id),s=s.parent==null?void 0:n.get(s.parent)}return null};return e.map(o=>{let i=r(o);return i===null?o:{...o,pose:t.decompose(i.pose,o.pose)}})}function yS(e){let t={id:e.id,visible:e.visible??!0,locked:e.locked??!1,...e.parallax?{parallax:e.parallax}:{},...e.annotation?{annotation:!0}:{}};return e.kind==="user"?{...t,kind:"user",name:e.name??e.id}:{...t,kind:"system"}}function J4(e,t,n){let r=[];for(let i of X4(e.roots,e.nodes)){let s=i.id,a={id:s,kind:i.kind,layer:i.layer,pose:i.pose,data:i.data};i.parent!=null&&(a.parent=i.parent),i.dependsOn==="children"?a.dependsOn="children":i.dependsOn&&i.dependsOn.length>0&&(a.dependsOn=i.dependsOn),i.pickable===!1&&(a.pickable=!1),i.hidden===!0&&(a.hidden=!0),i.locked===!0&&(a.locked=!0),i.units!==void 0&&(a.units=i.units),i.clip!==void 0&&(a.clip=i.clip),i.consumesChildren===!0&&(a.consumesChildren=!0),Object.assign(a,is(t,i,"jsonKey",l=>{throw new Error(`Scene.toJSON: node '${s}' has ${l.spec.field} but no matching registry key. The function must be registered via createScene's registry option to round-trip.`)})),r.push(a)}return{version:3,systemLayers:e.layers.map(i=>{let s={id:i.id};return i.visible===!1&&(s.visible=!1),i.locked===!0&&(s.locked=!0),i.parallax&&(s.parallax=i.parallax),i.annotation&&(s.annotation=!0),i.kind==="user"&&(s.kind="user",s.name=i.name),s}),nodes:r,...n?{doc:n}:{}}}function Ey(e,t,n={}){let r=FJ(e,t,n);return e.version===3?r:hS(r,n.composition??Rh)}function FJ(e,t,n){let r;if(e.version===1)r=e.nodes.map(o=>({n:o,kind:mS(1,o,n.classifyV1)}));else if(e.version===2||e.version===3)r=e.nodes.map(o=>({n:o,kind:mS(2,o)}));else throw new Error(`Scene: unsupported version ${String(Reflect.get(e,"version"))}; versions 1, 2 and 3 are supported`);return r.map(({n:o,kind:i})=>{let s={id:o.id,kind:i,layer:o.layer,pose:o.pose,data:o.data};o.parent!==void 0&&(s.parent=o.parent),o.pickable!==void 0&&(s.pickable=o.pickable),o.hidden===!0&&(s.hidden=!0),o.locked===!0&&(s.locked=!0),o.units!==void 0&&(s.units=o.units),o.clip!==void 0&&(s.clip=o.clip),o.consumesChildren===!0&&(s.consumesChildren=!0),o.dependsOn!==void 0&&(s.dependsOn=o.dependsOn==="children"?"children":o.dependsOn);let a=o;for(let l of il){let u=a[l.jsonKey];if(u===void 0)continue;let c=t[l.field]?.[u];if(!c&&n.unknownKeys==="skip"){n.onSkip?.({id:s.id,field:l.field,key:u});continue}if(!c)throw new Error(`Scene: unknown ${l.field} key '${u}'. Register a function with this key in the registry option.`);s[l.field]=c}return LJ(e.version,s)&&(s.clip="outline"),s})}function LJ(e,t){return e===1&&t.kind==="group"&&t.clipFromPose===void 0}function mS(e,t,n){return e===2?t.kind:t.kind==="leaf"?"mark":n?n(t):"group"}function Q4(e){let t=new WeakMap,n=1;return{get:r=>e.get(r),incarnation(r){let o=e.get(r);if(!o)return;let i=t.get(o);return i===void 0&&(i=n++,t.set(o,i)),i},childrenOf(r){return e.get(r)?.children??[]},ancestorsOf(r){let o=[],i=e.get(r)?.parent??null;for(;i!==null;)o.push(i),i=e.get(i)?.parent??null;return o}}}function Z4(e,t,n,r){let o={nodes:new Map,roots:[],layers:[],layerIndex:new Map,docValues:new Map},i=q4(o),s=Sy(e,f=>{f==="layout"&&n()}),a=Y4(o,i.invalidate,s),l=I4(o,i.invalidate);l.reset(t);let u=$4(o),c=h4(o.docValues);c.reset(r);let d={...Q4(o.nodes),renderOrder:i.ids,renderOrderNodes:i.nodes,nodesOnLayer:i.nodesOnLayer,isLocked:f=>u.isLocked(f),isHidden:f=>u.isHidden(f),layoutOf(f){return o.nodes.get(f)?.layout??null},toJSON:()=>J4(o,s,c.toJSON())};return{state:o,order:i,locks:u,stale:M4(o.nodes),fnFields:s,store:a,layers:l,reads:d,docValues:c,reset(f,p){c.reset(p),a.dependents.clear(),a.childDerived.clear(),o.nodes.clear(),o.roots.length=0,l.reset(f)}}}function _J(e,t){let n=e.get(t);return n&&{node:n,pose:Jn(e,n)}}var DJ=0,BJ=()=>ce(`n${(DJ++).toString(36)}-${Math.random().toString(36).slice(2,8)}`);function HJ(e,t){return()=>{for(let n=0;n<1e3;n++){let r=e();if(!t(r))return r}throw new Error("scene: generateId gave 1000 ids the scene already holds")}}function GJ(e,t,n,r){if(t.length===0)throw new Error("Scene: systemLayers must declare at least one layer");let o=WH(e.registry??{}),i=Z4(o,t,()=>h.layoutDeclared(),r),{state:s,locks:a,reads:l}=i,u=l4(),c=f4(),d=d4({untracked:c.untracked,changes:u,shown:v=>_J(P,v)}),f=(v,A)=>d.layout(()=>P.setPose(ce(v),A)),p=w4(e.layoutFrame),h=a4({nodes:s.nodes,layoutPass:(v,A,N)=>P4(P,l.layoutOf,v,A,p,N),recordsBareEdits:()=>!c.open(),writePose:f}),m=HJ(e.generateId??BJ,v=>s.nodes.has(v)),y=j4(a.reachable,v=>s.nodes.get(v)?.parent);y.subscribe(u.notify);let b=cS(v=>s.nodes.get(v),i.store.invalidateDependents),x=DO(),w=K4({notifier:u,mode:c,passAdapter:()=>({...vy(P),...uH(P)}),stale:i.stale,lifted:a.lifted,selection:y,arrivals:h,writePose:f,poseWrites:d,config:e}),g=O4({state:s,store:i.store,locks:a,layers:i.layers,invalidateOrder:i.order.invalidate,fnFields:i.fnFields,ops:{...w.ops,register:d.reporting(w.ops.register)},recorder:w.recorder,arrivals:h,layoutFrame:p,generateId:m,narrowSelection:y.narrow,clearOverride:b.clear});for(let[v,A]of Object.entries(e.ops??{}))w.ops.register(v,A);let P={get nodes(){return s.nodes},get roots(){return s.roots},get layers(){return s.layers},registry:o,...l,mintId:m,composition:e.composition??Rh,...g.methods,...w.methods,unlocked:v=>a.lifted(v),setArrivalHandler:h.setHandler,onReflow:h.onReflow,onPoseWrite:d.subscribe,overrides:b,scroll:x,getSelection:y.get,setSelection:v=>y.set([...v]),loadState(v,A){let N=Ey(v,o,{composition:P.composition,...A});if(c.open())throw new Error("Scene: cannot loadState inside another edit \u2014 it replaces the state that edit would revert to");b.clearAll(),x.clearAll(),i.reset(v.systemLayers.map(yS),v.doc),w.clearHistory(),d.quiet(()=>g.construct(N)),y.replace(y.legal(y.get().filter(M=>s.nodes.has(M)))),u.notify()},...u4(u,y)},S=n(o);return S&&(d.quiet(()=>g.construct(S)),u.notify()),P}function My(e,t={}){return GJ(t,e.systemLayers.map(yS),n=>Ey(e,n,t),e.doc)}Z();var eG="__weaselHeadless";function tG(e){return kb(e)}var WJ=eS();function nG(e){let t="";for(let n=0;n<e.length;n+=32768)t+=String.fromCharCode(...e.subarray(n,n+32768));return btoa(t)}async function VJ(e){let{scene:t,screen:n,format:r,overlay:o,...i}=e,s={...i,scene:My(tG(t)),...o?{overlay:o}:{},...n?{screen:Float64Array.from(n)}:{}};await tS({render:s});let a=WJ.render(s);if(r==="png"){let u=await nS(a);return{width:a.width,height:a.height,base64:nG(new Uint8Array(await u.arrayBuffer()))}}let l=new Uint8Array(a.data.buffer,a.data.byteOffset,a.data.byteLength);return{width:a.width,height:a.height,base64:nG(l)}}var zJ={render:VJ};globalThis[eG]=zJ;})();
431
431
  /*! Bundled license information:
432
432
 
433
433
  polygon-clipping/dist/polygon-clipping.umd.js: