@motionscript/browser 0.1.1-alpha.0 → 0.1.1-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -699,8 +699,8 @@ ${e.stack}`;let t=toString.call(e),n=/\[object ([^\]]+)\]/.exec(t)?.[1];if(n===v
699
699
  ${t}`,r=this.programs.get(n);if(r)return this.programs.delete(n),this.programs.set(n,r),r;if(this.programs.size>=ul){let[o,l]=this.programs.entries().next().value;this.programs.delete(o),l.state!=="compiling"&&this.r.shader_remove(l.id)}let s=this.nextId++,i=ta(this.r.shader_add(s,Wr[e],t)),a={id:s,scope:e,report:i,state:i.ok?"compiling":"failed",browser:[],settled:Promise.resolve()};if(i.ok){let o=this.compile(a).finally(()=>this.pending.delete(o));this.pending.add(o),a.settled=o}return this.programs.set(n,a),a}hasPending(){return this.pending.size>0}async whenReady(){for(;this.pending.size;)await Promise.all([...this.pending])}async compile(e){let t=this.r.gpu_device(),n=e.report.wgsl;try{if(t){let r=t.createShaderModule({code:n}),s=await ai(r.getCompilationInfo(),"compile it");if(e.browser=dl(s.messages,n),s.messages.some(a=>a.type==="error")){e.state="failed",this.r.shader_remove(e.id);return}let i=this.r.shader_formats(Wr[e.scope]);await ai(Promise.all(i.map(a=>t.createRenderPipelineAsync(gl(t,r,e.scope,a)).catch(()=>null))),"build its pipelines"),this.r.shader_build(e.id)}else this.r.shader_build(e.id);e.state="ready",this.onReady()}catch(r){e.state="failed",e.browser.push({line:0,column:0,length:0,message:`error: ${String(r?.message??r)}`,source:"browser"})}}};function dl(e,t){let n=t.indexOf(`// \u2500\u2500 the author's code \u2500\u2500
700
700
  `),r=n<0?0:t.slice(0,n).split(`
701
701
  `).length+1;return e.map(s=>{let i=s.lineNum>=r&&r>0?s.lineNum-r+1:0;return{line:i,column:i?s.linePos:0,length:s.length??0,message:`${s.type}: ${s.message}`,source:"browser"}})}var hl=3,pl={fill:[["uniform","storage","storage","storage","storage","storage","unfilterable-2d-array","storage"],["texture","sampler"],["uniform"]],effect:[["texture","texture","texture","sampler","sampler","uniform","texture"],["uniform"]]},_l={uniform:{buffer:{type:"uniform",hasDynamicOffset:!0}},storage:{buffer:{type:"read-only-storage"}},texture:{texture:{sampleType:"float",viewDimension:"2d"}},sampler:{sampler:{type:"filtering"}},"unfilterable-2d-array":{texture:{sampleType:"unfilterable-float",viewDimension:"2d-array"}}};function ml(e,t){return pl[t].map(n=>e.createBindGroupLayout({entries:n.map((r,s)=>({binding:s,visibility:hl,..._l[r]}))}))}function gl(e,t,n,r){let s={srcFactor:"one",dstFactor:"one-minus-src-alpha",operation:"add"},i=n==="fill";return{layout:e.createPipelineLayout({bindGroupLayouts:ml(e,n)}),vertex:{module:t,entryPoint:i?"ms_vs_quad":"ms_vs_effect",buffers:[]},primitive:{topology:"triangle-list",cullMode:"none"},multisample:{count:1},fragment:{module:t,entryPoint:i?"ms_fs_prim":"ms_fs_effect",targets:[{format:r,...i?{blend:{color:s,alpha:s}}:{},writeMask:15}]}}}var bl={normal:0,multiply:1,screen:2,overlay:3,darken:4,lighten:5,"color-dodge":6,"color-burn":7,"hard-light":8,"soft-light":9,difference:10,exclusion:11,hue:12,saturation:13,color:14,luminosity:15},ra="A shader fill is written in SkSL, which Motion Script no longer runs, so it draws nothing. Port it to WGSL (fn fill(in: FillIn) -> vec4f).",wl="A shader effect is written in SkSL, which Motion Script no longer runs, so it is skipped. Port it to WGSL (fn effect(in: EffectIn) -> vec4f).",Dt=new Map,yl=64;function vl(e,t){let n=`${e}
702
- ${t}`,r=Dt.get(n);if(r===void 0){try{let s=na(e,t);r=s.ok?s.fields.map(i=>i.name):null}catch{return null}Dt.size>=yl&&Dt.delete(Dt.keys().next().value)}else Dt.delete(n);return Dt.set(n,r),r}function xl(e,t){let n=t.source??"",r=fc(t);if(!n.trim()||r===void 0)return[];let s=[];r>zs&&s.push({kind:"shader",feature:`${e}:contract-${r}`,message:`A WGSL shader ${e} is written for shader contract ${r}; this renderer implements ${zs}, so it may not draw as intended.`});let i=vl(e,n);if(!i)return s;let a=ji(t.uniforms??{});for(let o of Object.keys(a))i.includes(o)||s.push({kind:"params",feature:`params:${o}`,message:`A WGSL shader ${e} is given "${o}", which names no member of its struct Params, so the value is ignored.`});for(let o of i)o in a||s.push({kind:"params",feature:`params:${o}`,message:`A WGSL shader ${e}'s Params.${o} is given no value, so it reads 0.`});return s}var kl=32;function xt(e,t){let n=e.p,r=1-t;return e.kind==="line"?[n[0]+(n[2]-n[0])*t,n[1]+(n[3]-n[1])*t]:e.kind==="quad"?[r*r*n[0]+2*r*t*n[2]+t*t*n[4],r*r*n[1]+2*r*t*n[3]+t*t*n[5]]:[r*r*r*n[0]+3*r*r*t*n[2]+3*r*t*t*n[4]+t*t*t*n[6],r*r*r*n[1]+3*r*r*t*n[3]+3*r*t*t*n[5]+t*t*t*n[7]]}function Un(e,t){let n=[0],r=e==="line"?1:kl,s={kind:e,p:t,len:0,table:n},i=xt(s,0);for(let a=1;a<=r;a++){let o=xt(s,a/r);n.push(n[a-1]+Math.hypot(o[0]-i[0],o[1]-i[1])),i=o}return s.len=n[r],s}function Vr(e,t){let n=e.table.length-1;if(t<=0)return 0;if(t>=e.len)return 1;let r=1;for(;e.table[r]<t;)r++;let s=e.table[r-1],i=e.table[r];return(r-1+(i>s?(t-s)/(i-s):0))/n}function Ml(e,t,n){let r=e.p;if(e.kind==="line")return[...xt(e,t),...xt(e,n)];let s=(a,o)=>{let l=a.length/2,c=[a];for(let d=1;d<l;d++){let p=c[d-1],_=[];for(let w=0;w<p.length-2;w+=2)_.push(p[w]+(p[w+2]-p[w])*o,p[w+1]+(p[w+3]-p[w+1])*o);c.push(_)}let u=[],f=[];for(let d=0;d<l;d++)u.push(c[d][0],c[d][1]);for(let d=l-1;d>=0;d--)f.push(c[d][c[d].length-2],c[d][c[d].length-1]);return[u,f]},[i]=n<1?s(r,n):[r];return t<=0?i:s(i,t/n)[1]}function qr(e){let t=[],n=null,r=0,s=0,i=0,a=0,o=0,l=e.points;for(let c of e.verbs)if(c===Ce.move)r=i=l[o++],s=a=l[o++],n={segs:[],closed:!1},t.push(n);else if(c===Ce.line){let u=l[o++],f=l[o++];n.segs.push(Un("line",[r,s,u,f])),r=u,s=f}else if(c===Ce.quad){let u=[r,s,l[o],l[o+1],l[o+2],l[o+3]];o+=4,n.segs.push(Un("quad",u)),r=u[4],s=u[5]}else if(c===Ce.cubic){let u=[r,s,l[o],l[o+1],l[o+2],l[o+3],l[o+4],l[o+5]];o+=6,n.segs.push(Un("cubic",u)),r=u[6],s=u[7]}else c===Ce.close&&(n&&((r!==i||s!==a)&&n.segs.push(Un("line",[r,s,i,a])),n.closed=!0),r=i,s=a);return t.filter(c=>c.segs.length>0)}function Sl(e){let t=0,n=0,r=0,s=0,i=0,a=0,o=e.points,l=(c,u)=>{t+=i*u-c*a,i=c,a=u};for(let c of e.verbs)if(c===Ce.move)l(r,s),r=i=o[n++],s=a=o[n++];else if(c!==Ce.close){let u=c===Ce.line?1:c===Ce.quad?2:3;for(let f=0;f<u;f++,n+=2)l(o[n],o[n+1])}return l(r,s),t/2}function El(e){let t=new rt,n=e.points,r=0,s=0,i=e.verbs;for(;s<i.length;){if(i[s]!==Ce.move){s++;continue}let a=n[r++],o=n[r++],l=[],c=!1;for(s++;s<i.length&&i[s]!==Ce.move;s++){let u=i[s];if(u===Ce.close){c=!0;continue}let f=u===Ce.line?1:u===Ce.quad?2:3,d=[a,o];for(let p=0;p<f;p++,r+=2)d.push(n[r],n[r+1]);a=d[d.length-2],o=d[d.length-1],l.push({v:u,p:d})}t.moveTo(a,o);for(let u=l.length-1;u>=0;u--){let{v:f,p:d}=l[u];f===Ce.line?t.lineTo(d[0],d[1]):f===Ce.quad?t.quadTo(d[2],d[3],d[0],d[1]):t.cubicTo(d[4],d[5],d[2],d[3],d[0],d[1])}c&&t.close()}return t.build()}function oi(e){let t=qr(e);return t.length>0&&t.every(n=>n.closed)}function sa(e,t,n,r){let s=0,i=!1;for(let a of e){let o=s,l=s+a.len;if(s=l,l<=t||o>=n)continue;let c=Ml(a,Vr(a,t-o),Vr(a,n-o));i||(r.moveTo(c[0],c[1]),i=!0),a.kind==="line"?r.lineTo(c[2],c[3]):a.kind==="quad"?r.quadTo(c[2],c[3],c[4],c[5]):r.cubicTo(c[2],c[3],c[4],c[5],c[6],c[7])}return i}function zr(e,t,n){let r=qr(e),s=r.reduce((u,f)=>u+f.segs.reduce((d,p)=>d+p.len,0),0);if(s<=0)return e;let i=t*s,a=n*s,o=new rt,l=0,c=!1;for(let u of r){let f=u.segs.reduce((_,w)=>_+w.len,0),d=l,p=l+f;l=p,p>i&&d<a&&(c=sa(u.segs,Math.max(0,i-d),Math.min(f,a-d),o)||c)}return c?o.build():{verbs:new Uint8Array(0),points:new Float32Array(0)}}function Al(e,t){let n=e.p,r=1-t;return e.kind==="line"?[n[2]-n[0],n[3]-n[1]]:e.kind==="quad"?[2*(r*(n[2]-n[0])+t*(n[4]-n[2])),2*(r*(n[3]-n[1])+t*(n[5]-n[3]))]:[3*(r*r*(n[2]-n[0])+2*r*t*(n[4]-n[2])+t*t*(n[6]-n[4])),3*(r*r*(n[3]-n[1])+2*r*t*(n[5]-n[3])+t*t*(n[7]-n[5]))]}function Tl(e){return qr(e).map(t=>{let n=t.segs.filter(s=>s.len>0),r=n.reduce((s,i)=>s+i.len,0);return{length:r,closed:t.closed,posTan(s){s=Math.max(0,Math.min(r,s));let i=0,a=n[n.length-1];for(let p of n){if(i+p.len>=s){a=p;break}i+=p.len}let o=Vr(a,s-i),[l,c]=xt(a,o),[u,f]=Al(a,o);if(Math.hypot(u,f)<1e-9){let p=xt(a,Math.max(0,o-.001)),_=xt(a,Math.min(1,o+.001));u=_[0]-p[0],f=_[1]-p[1]}let d=Math.hypot(u,f)||1;return[l,c,u/d,f/d]},segment:(s,i,a)=>sa(n,s,i,a)}}).filter(t=>t.length>0)}var Gn=.001;function Pl(e,t){let n=0,r=!1;for(let i of e)n+=i.length,i.closed||(r=!0);let s=Vi.dashScale(t,{length:n,closed:!0},n);return s===null?null:{scale:s,total:n,open:r}}function ia(e,t,n){return e.closed?n.scale:Vi.dashScale(t,{length:e.length,closed:!1},n.total)??n.scale}function aa(e,t,n,r){let s=t.map(p=>p*r),i=s.reduce((p,_)=>p+_,0),a=[];if(!(i>0))return a;let o=(n*r%i+i)%i,l=0,c=0;for(;c+s[l]<=o&&l<s.length&&!(s[l]<=Gn&&Math.abs(o-c)<1e-6||(c+=s[l],l=(l+1)%s.length,l===0)););let u=s[l]-(o-c),f=l%2===0,d=0;for(;d<e.length-1e-6;){let p=Math.min(u,e.length-d);f&&a.push([d,d+p]),d+=p,u-=p,u<=1e-6&&(l=(l+1)%s.length,u=s[l],f=!f)}return f&&u<=1e-6&&!e.closed&&a.push([e.length,e.length]),a}function Il(e,t,n,r,s){let i=new rt,a=!1;for(let o of e)for(let[l,c]of aa(o,t,n,ia(o,t,s)))if(c-l>Gn)a=o.segment(l,c,i)||a;else if(r){let[u,f,d,p]=o.posTan(l),_=l>o.length-Gn?-.001:Gn;i.moveTo(u,f).lineTo(u+d*_,f+p*_),a=!0}return a?i.build():null}function oa(e,t,n,r,s,i,a,o,l,c){if(r===0||s===0){e.lineTo(l,c);return}r=Math.abs(r),s=Math.abs(s);let u=Math.cos(i),f=Math.sin(i),d=(t-l)/2,p=(n-c)/2,_=u*d+f*p,w=-f*d+u*p,A=_*_/(r*r)+w*w/(s*s);A>1&&(r*=Math.sqrt(A),s*=Math.sqrt(A));let B=r*r*s*s-r*r*w*w-s*s*_*_,L=r*r*w*w+s*s*_*_,V=Math.sqrt(Math.max(0,B/L));a===o&&(V=-V);let se=V*r*w/s,X=-V*s*_/r,pe=u*se-f*X+(t+l)/2,ue=f*se+u*X+(n+c)/2,q=(Me,Fe,de,Ae)=>Math.atan2(Me*Ae-Fe*de,Me*de+Fe*Ae),ae=q(1,0,(_-se)/r,(w-X)/s),G=q((_-se)/r,(w-X)/s,(-_-se)/r,(-w-X)/s);!o&&G>0?G-=2*Math.PI:o&&G<0&&(G+=2*Math.PI);let $=Math.ceil(Math.abs(G)/(Math.PI/2)-1e-9),xe=G/$,ve=4/3*Math.tan(xe/4);for(let Me=0;Me<$;Me++){let Fe=ae+Me*xe,de=Fe+xe,Ae=Math.cos(Fe),De=Math.sin(Fe),At=Math.cos(de),Tt=Math.sin(de),xn=pe+r*Ae*u-s*De*f,kn=ue+r*Ae*f+s*De*u,Mn=pe+r*At*u-s*Tt*f,qt=ue+r*At*f+s*Tt*u,Sn=-r*De*u-s*Ae*f,sr=-r*De*f+s*Ae*u,v=-r*Tt*u-s*At*f,Te=-r*Tt*f+s*At*u;e.cubicTo(xn+ve*Sn,kn+ve*sr,Mn-ve*v,qt-ve*Te,Me===$-1?l:Mn,Me===$-1?c:qt)}}function gn(e){let t=new rt,n=e.match(/[a-zA-Z]|-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[],r=0,s="",i=0,a=0,o=0,l=0,c=0,u=0,f=0,d=0,p="",_=()=>Number(n[r++]),w=()=>r<n.length&&!/[a-zA-Z]/.test(n[r]);for(;r<n.length;){/[a-zA-Z]/.test(n[r])&&(s=n[r++]);let A=s===s.toLowerCase(),B=s.toUpperCase(),L=A?i:0,V=A?a:0;switch(B){case"M":i=L+_(),a=V+_(),t.moveTo(i,a),o=i,l=a,s=A?"l":"L";break;case"L":i=L+_(),a=V+_(),t.lineTo(i,a);break;case"H":i=(A?i:0)+_(),t.lineTo(i,a);break;case"V":a=(A?a:0)+_(),t.lineTo(i,a);break;case"C":{let se=L+_(),X=V+_(),pe=L+_(),ue=V+_();i=L+_(),a=V+_(),t.cubicTo(se,X,pe,ue,i,a),c=pe,u=ue;break}case"S":{let se=p==="C"||p==="S",X=se?2*i-c:i,pe=se?2*a-u:a,ue=L+_(),q=V+_();i=L+_(),a=V+_(),t.cubicTo(X,pe,ue,q,i,a),c=ue,u=q;break}case"Q":f=L+_(),d=V+_(),i=L+_(),a=V+_(),t.quadTo(f,d,i,a);break;case"T":{let se=p==="Q"||p==="T";f=se?2*i-f:i,d=se?2*a-d:a,i=L+_(),a=V+_(),t.quadTo(f,d,i,a);break}case"A":{let se=_(),X=_(),pe=_()*Math.PI/180,ue=_()!==0,q=_()!==0,ae=L+_(),G=V+_();oa(t,i,a,se,X,pe,ue,q,ae,G),i=ae,a=G;break}case"Z":t.close(),i=o,a=l;break;default:r++}p=B,B==="Z"&&w()&&(s="L")}return t.build()}var Rl=class{parts=[];move(e,t){this.parts.push(`M ${e} ${t}`)}line(e,t){this.parts.push(`L ${e} ${t}`)}arc(e,t,n,r,s,i){this.parts.push(`A ${e} ${t} 0 ${n} ${r} ${s} ${i}`)}close(){this.parts.push("Z")}toString(){return this.parts.join(" ")}},Cl=class{ok=!0;b=new rt;empty=!0;x=0;y=0;sx=0;sy=0;move(e,t){this.check(e,t),this.x=this.sx=0+e,this.y=this.sy=0+t,this.b.moveTo(this.x,this.y)}line(e,t){this.check(e,t),this.x=0+e,this.y=0+t,this.b.lineTo(this.x,this.y)}arc(e,t,n,r,s,i){this.check(e,t,s,i);let a=0+s,o=0+i;oa(this.b,this.x,this.y,e+0,t+0,0,n!==0,r!==0,a,o),this.x=a,this.y=o}close(){this.empty=!1,this.b.close(),this.x=this.sx,this.y=this.sy}result(){return this.empty?null:this.b.build()}check(...e){this.empty=!1;for(let t of e)Number.isFinite(t)||(this.ok=!1)}};function Je(e){let t=new Rl;return e(t),t.toString()}function ca(e){let t=new Cl;if(e(t),t.ok)return t.result();let n=Je(e);return n?gn(n):null}var Gt=class{fullState;geo;constructor(e){this.fullState=this.resolveState(e)}buildPathData(e){let t=this.buildSVGPath(e);return t?gn(t):null}get geometry(){return this.geo??=this.computeGeometry()}needsTrim(){return this.fullState.start!==0||this.fullState.end!==1}getTrimRange(){return{start:this.fullState.start,end:this.fullState.end}}buildSVGAlignInterior(e){return null}supportsSpread(){return!1}buildSpreadSVGPath(e,t){return null}computeBounds(e){}};function ct(e){return e.radius>0?e.radius:0}function Nn(e,t,n,r,s,i,a,o){o.radius<=0||la(e,t,n,r,s,i,a,o.radius,o.radius,o.style)}function la(e,t,n,r,s,i,a,o,l,c){let u=t+i*o,f=n+a*o;if(c==="angled")return e.line(u,f);let d=r*a-s*i;e.arc(l,l,0,d<0?1:0,u,f)}function Ol(e,t,n,r,s,i,a,o,l){return Je(c=>la(c,e,t,n,r,s,i,a,o,l))}var lt=Math.PI/180,Jr=class extends Gt{resolveState(e){return _c(e)}computeGeometry(){let e=this.fullState,t=e.sweep??360;return{cx:e.x,cy:e.y,halfWidth:e.width/2,halfHeight:e.height/2,sweep:t,isFullShape:Math.abs(t)>=360,startAngle:e.startAngle??0,ratio:Math.max(0,Math.min(1,e.ratio??0))}}buildSVGPath(e){return Je(t=>ci(t,e))}buildPathData(e){return ca(t=>ci(t,e))}ringOutline(e){return e.ratio<1?null:Je(t=>e.isFullShape?pn(t,e.cx,e.cy,e.halfWidth,e.halfHeight,0):Dl(t,e))}buildSVGAlignInterior(e){return e.isFullShape?e.ratio>=1?Je(t=>pn(t,e.cx,e.cy,e.halfWidth,e.halfHeight,0)):null:Je(t=>e.ratio>=1||e.ratio<=0?ua(t,e):fa(t,e))}supportsSpread(){return!0}buildSpreadSVGPath(e,t){if(!e.isFullShape||e.ratio>=1)return null;let n=e.halfWidth+t,r=e.halfHeight+t;return n<=0||r<=0?null:Je(s=>pn(s,e.cx,e.cy,n,r,0))}computeBounds(e){let{cx:t,cy:n,halfWidth:r,halfHeight:s}=e;return{left:t-r,top:n-s,right:t+r,bottom:n+s}}};function ci(e,t){let{cx:n,cy:r,halfWidth:s,halfHeight:i,ratio:a}=t;if(!(a>=1)){if(!t.isFullShape)return a<=0?ua(e,t):fa(e,t);pn(e,n,r,s,i,0),a>0&&pn(e,n,r,s*a,i*a,1)}}function pn(e,t,n,r,s,i){let a=t-r,o=t+r;e.move(a,n),e.arc(r,s,1,i,o,n),e.arc(r,s,1,i,a,n),e.close()}function Yr(e){let{cx:t,cy:n,halfWidth:r,halfHeight:s,startAngle:i,sweep:a}=e,o=i+a,l=Math.abs(a)>180?1:0,c=a>0?1:0,u=t+r*Math.cos(i*lt),f=n+s*Math.sin(i*lt),d=t+r*Math.cos(o*lt),p=n+s*Math.sin(o*lt);return{sx:u,sy:f,arc:_=>_.arc(r,s,l,c,d,p)}}function Dl(e,t){let{sx:n,sy:r,arc:s}=Yr(t);e.move(n,r),s(e)}function ua(e,t){let{sx:n,sy:r,arc:s}=Yr(t);e.move(t.cx,t.cy),e.line(n,r),s(e),e.close()}function fa(e,t){let{cx:n,cy:r,halfWidth:s,halfHeight:i,startAngle:a,sweep:o,ratio:l}=t,{sx:c,sy:u,arc:f}=Yr(t),d=a+o,p=s*l,_=i*l,w=n+p*Math.cos(a*lt),A=r+_*Math.sin(a*lt),B=n+p*Math.cos(d*lt),L=r+_*Math.sin(d*lt),V=Math.abs(o)>180?1:0,se=o>0?0:1;e.move(c,u),f(e),e.line(B,L),e.arc(p,_,V,se,w,A),e.close()}function Ll(e,t,n){if(e.length===0)return"M 0 0";if(e.length===1)return`M ${e[0].x} ${e[0].y}`;let r=Math.max(0,t),s=[],i=e.length,a=(o,l)=>{let c=l.x-o.x,u=l.y-o.y,f=Math.sqrt(c*c+u*u);return f>0?{dx:c/f,dy:u/f,len:f}:{dx:0,dy:0,len:0}};if(r===0){s.push(`M ${e[0].x} ${e[0].y}`);for(let o=1;o<i;o++)s.push(`L ${e[o].x} ${e[o].y}`)}else{let o=n?i:i-1;for(let l=0;l<=o;l++){let c=e[(l-1+i)%i],u=e[l%i],f=e[(l+1)%i];if(!n&&l===0){s.push(`M ${u.x} ${u.y}`);continue}if(!n&&l===i-1){s.push(`L ${u.x} ${u.y}`);continue}let d=a(c,u),p=a(u,f),_=Math.min(r,d.len/2),w=Math.min(r,p.len/2),A=u.x-d.dx*_,B=u.y-d.dy*_,L=u.x+p.dx*w,V=u.y+p.dy*w;s.push(`${l===0&&n?"M":"L"} ${A} ${B}`),s.push(`Q ${u.x} ${u.y} ${L} ${V}`)}}return n&&s.push("Z"),s.join(" ")}var Fl=class extends Gt{resolveState(e){return mc(e)}computeGeometry(){let{points:e,radius:t,closed:n}=this.fullState;return{points:e,radius:t,closed:n}}buildSVGPath(e){return Ll(e.points,e.radius,e.closed)}},Bl=class extends Gt{resolveState(e){return gc(e)}computeGeometry(){return{data:this.fullState.data}}buildSVGPath(e){return Hi(e.data)}};function da(e,t,n){if(t.cornerRadius<=0){let i=e.map(([a,o],l)=>`${l===0?"M":"L"} ${a} ${o}`);return i.push("Z"),i.join(" ")}let r=e.length,s=[];for(let i=0;i<r;i++){let a=e[i];if(!n(i)){s.push(`${s.length===0?"M":"L"} ${a[0]} ${a[1]}`);continue}let o=e[(i-1+r)%r],l=e[(i+1)%r],c=o[0]-a[0],u=o[1]-a[1],f=Math.hypot(c,u),d=c/f,p=u/f,_=l[0]-a[0],w=l[1]-a[1],A=Math.hypot(_,w),B=_/A,L=w/A,V=Math.max(-1,Math.min(1,d*B+p*L)),se=Math.tan(Math.acos(V)/2),X=Math.min(t.cornerRadius/se,Math.min(f,A)/2),pe=X*se;s.push(`${s.length===0?"M":"L"} ${a[0]+d*X} ${a[1]+p*X}`),s.push(Ol(a[0],a[1],d,p,B,L,X,pe,t.cornerStyle))}return s.push("Z"),s.join(" ")}var ha=e=>({left:e.cx-e.rx,top:e.cy-e.ry,right:e.cx+e.rx,bottom:e.cy+e.ry}),$l=class extends Gt{resolveState(e){return bc(e)}computeGeometry(){let e=this.fullState;return{cx:e.x,cy:e.y,rx:e.width/2,ry:e.height/2,sides:Math.max(3,Math.round(e.sides)),ratio:1,cornerRadius:e.cornerRadius,cornerStyle:e.cornerStyle}}buildSVGPath(e){let t=2*Math.PI/e.sides,n=[];for(let r=0;r<e.sides;r++){let s=-Math.PI/2+r*t;n.push([e.cx+e.rx*Math.cos(s),e.cy+e.ry*Math.sin(s)])}return da(n,e,()=>!0)}computeBounds(e){return ha(e)}},Ul=class extends Gt{resolveState(e){return wc(e)}computeGeometry(){let e=this.fullState;return{cx:e.x,cy:e.y,rx:e.width/2,ry:e.height/2,sides:Math.max(3,Math.round(e.sides)),ratio:Math.max(0,Math.min(1,e.ratio)),cornerRadius:e.cornerRadius,cornerStyle:e.cornerStyle}}buildSVGPath(e){let t=Math.PI/e.sides,n=[];for(let r=0;r<e.sides*2;r++){let s=-Math.PI/2+r*t,i=r%2===0?1:e.ratio;n.push([e.cx+e.rx*i*Math.cos(s),e.cy+e.ry*i*Math.sin(s)])}return da(n,e,r=>r%2===0)}computeBounds(e){return ha(e)}};function pa(e,t,n,r,s,i,a,o,l){let c=ct(i),u=ct(a),f=ct(o),d=ct(l);e.move(t+c,n),e.line(r-u,n),Nn(e,r,n,-1,0,0,1,a),e.line(r,s-f),Nn(e,r,s,0,-1,-1,0,o),e.line(t+d,s),Nn(e,t,s,1,0,0,-1,l),e.line(t,n+c),Nn(e,t,n,0,1,1,0,i),e.close()}function _a(e,t,n,r,s){e.move(t,n),e.line(r,n),e.line(r,s),e.line(t,s),e.close()}function li(e,t){let{left:n,top:r,right:s,bottom:i,tl:a,tr:o,br:l,bl:c,isZero:u}=t;u?_a(e,n,r,s,i):pa(e,n,r,s,i,a,o,l,c)}var ma=class extends Gt{resolveState(e){return yc(e)}computeGeometry(){let e=this.fullState,t=e.x-e.width/2,n=e.y-e.height/2,r=e.x+e.width/2,s=e.y+e.height/2,i=Gs.resolve(e.cornerRadius),a=qo.resolve(e.cornerStyle),o={radius:Math.max(0,i.topLeft),style:a.topLeft},l={radius:Math.max(0,i.topRight),style:a.topRight},c={radius:Math.max(0,i.bottomRight),style:a.bottomRight},u={radius:Math.max(0,i.bottomLeft),style:a.bottomLeft},f=ui(e.width,e.height,o,l,c,u);return o.radius*=f,l.radius*=f,c.radius*=f,u.radius*=f,{left:t,top:n,right:r,bottom:s,tl:o,tr:l,br:c,bl:u,isZero:Gs.isZero({topLeft:o.radius,topRight:l.radius,bottomRight:c.radius,bottomLeft:u.radius})}}buildSVGPath(e){return Je(t=>li(t,e))}buildPathData(e){return ca(t=>li(t,e))}supportsSpread(){return!0}buildSpreadSVGPath(e,t){let n=e.left-t,r=e.top-t,s=e.right+t,i=e.bottom+t,a=s-n,o=i-r;if(a<=0||o<=0)return null;let l={...e.tl,radius:Math.max(0,e.tl.radius+t)},c={...e.tr,radius:Math.max(0,e.tr.radius+t)},u={...e.br,radius:Math.max(0,e.br.radius+t)},f={...e.bl,radius:Math.max(0,e.bl.radius+t)},d=ui(a,o,l,c,u,f);return l.radius*=d,c.radius*=d,u.radius*=d,f.radius*=d,l.radius===0&&c.radius===0&&u.radius===0&&f.radius===0?Je(p=>_a(p,n,r,s,i)):Je(p=>pa(p,n,r,s,i,l,c,u,f))}computeBounds(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}};function ui(e,t,n,r,s,i){let a=ct(n),o=ct(r),l=ct(s),c=ct(i),u=a+o>0?Math.min(1,e/(a+o)):1,f=c+l>0?Math.min(1,e/(c+l)):1,d=a+c>0?Math.min(1,t/(a+c)):1,p=o+l>0?Math.min(1,t/(o+l)):1;return Math.min(u,f,d,p)}function fn(e,t,n){let r=ic(e,t,n),{x:s,y:i,pivot:a}=oc(r,t,n);return{...hc(r),x:s,y:-i,pivot:a}}var ga=e=>e==null?e:-e;function ba(e,t){let n=new Float32Array(e.points.length);for(let r=0;r<n.length;r+=2){let s=e.points[r],i=e.points[r+1];n[r]=t[0]*s+t[2]*i+t[4],n[r+1]=t[1]*s+t[3]*i+t[5]}return{...e,points:n}}function Xr(e,t){let n=e.rotation??0,r=e.scale??1;if(n===0&&r===1)return t;let s=e.pivot??{x:0,y:0},i=(e.x??0)+s.x*((e.width??0)/2),a=(e.y??0)-s.y*((e.height??0)/2),o=n*Math.PI/180,l=Math.cos(o)*r,c=Math.sin(o)*r,u=l,f=-c,d=c,p=l;return ba(t,[u,d,f,p,i-u*i-f*a,a-d*i-p*a])}var Nl={left:"left",right:"right",center:"center",justify:"justify",start:"left",end:"right"};function jl(e,t){let n=Ki(fn(e,e.width??0,e.height??0)),r=n.path!=null?gn(Hi(n.path)):void 0,s=n.fontSize==="autofit",i={runs:[{text:n.text,family:n.fontFamily,size:s?100:n.fontSize,weight:n.fontWeight,italic:n.fontStyle==="italic"||n.fontStyle==="oblique",letterSpacing:n.letterSpacing,decoration:n.textDecoration==="underline"?"underline":n.textDecoration==="line-through"?"lineThrough":void 0}],align:Nl[n.textAlign]??"left",verticalAlign:n.verticalAlign,wrap:n.wrap&&n.width>0,width:n.width,height:n.height,lineHeight:n.lineHeight,fontSize:s?"autofit":void 0,minFontSize:n.minFontSize,path:r};if(r)return{spec:i,transform:[1,0,0,1,0,0],size:[n.width,n.height]};let[a,o]=t(i),l=cc(n.pivot),c=n.width>0&&n.height>0,u=c?n.width:a,f=c?n.height:o,d=!c&&l.x!==0?n.x-l.x*(a/2):n.x,p=!c&&l.y!==0?n.y+l.y*(o/2):n.y,_=[1,0,0,1,d,p];if((n.rotation??0)!==0||(n.scale??1)!==1){let w=d+l.x*(u/2),A=p-l.y*(f/2),B=(n.rotation??0)*Math.PI/180,L=n.scale??1,V=Math.cos(B)*L,se=Math.sin(B)*L;_=[V,se,-se,V,w+V*(d-w)-se*(p-A),A+se*(d-w)+V*(p-A)]}return{spec:i,transform:_,size:[u,f]}}function Mr(e,t){return e?Xr(t,gn(e)):null}function tn(e,t){let n=new e(t),r=n.fullState,s=n.geometry,i=n.needsTrim()?n.getTrimRange():null,a=jn(()=>{let d=n.buildPathData(s);return d&&Xr(r,d)}),o=jn(()=>{let d=a();return d&&i?zr(d,i.start,i.end):d}),l=jn(()=>{let d=n instanceof Jr?n.ringOutline(s):null;if(d==null)return o();let p=Mr(d,r);return p&&i?zr(p,i.start,i.end):p}),c=jn(()=>{let d=n.buildSVGAlignInterior(s);return d!=null?Mr(d,r):i?a():o()}),u=n.computeBounds(s),f=n.supportsSpread()?d=>Mr(n.buildSpreadSVGPath(s,d),r):void 0;return{get fill(){return o()},get stroke(){return l()},get interior(){return c()},bounds:u?[u.left,u.top,u.right,u.bottom]:null,spread:f,trimmed:!!i,native:i?void 0:Wl(n,r,s)}}function jn(e){let t=!1,n;return()=>(t||(n=e(),t=!0),n)}function Wl(e,t,n){if(!((t.rotation??0)!==0||(t.scale??1)!==1)){if(e instanceof Jr){if(!n.isFullShape||n.ratio>0)return;let r=n.halfWidth*2,s=n.halfHeight*2;return!(r>0&&s>0)||!Number.isFinite(r+s+n.cx+n.cy)?void 0:{kind:"ellipse",x:n.cx-n.halfWidth,y:n.cy-n.halfHeight,w:r,h:s,radii:[0,0,0,0]}}if(e instanceof ma){let r=n.right-n.left,s=n.bottom-n.top;if(!(r>0&&s>0)||!Number.isFinite(r+s+n.left+n.top))return;let i=[n.tl,n.tr,n.br,n.bl],a=Math.min(r,s)/2;return i.some(o=>!(o.radius>=0&&o.radius<=a)||o.radius>0&&o.style==="angled")?void 0:{kind:"rect",x:n.left,y:n.top,w:r,h:s,radii:i.map(o=>o.radius)}}}}function Vl(e){let t=new Bl(e),n=t.fullState,r=gn(t.buildSVGPath(t.geometry)),[s,i,a,o]=n.centerBounds??it(r),l=ba(r,[1,0,0,1,-(s+(a-s)/2),-(i+(o-i)/2)]),c=Xr({...n,x:0,y:0},l),u=t.needsTrim()?t.getTrimRange():null,f=u?zr(c,u.start,u.end):c;return{fill:f,stroke:f,interior:u?c:f,bounds:null,trimmed:!!u}}var zl=e=>{let t={...e,y:ga(e.y)};if(Array.isArray(e.data)&&(t.data=e.data.map(n=>{switch(n.type){case"M":case"m":case"L":case"l":case"T":case"t":case"V":case"v":return{...n,y:-n.y};case"C":case"c":return{...n,y1:-n.y1,y2:-n.y2,y:-n.y};case"S":case"s":return{...n,y2:-n.y2,y:-n.y};case"Q":case"q":return{...n,y1:-n.y1,y:-n.y};case"A":case"a":return{...n,y:-n.y,sweep:n.sweep===1?0:1};default:return n}}),e.centerBounds)){let[n,r,s,i]=e.centerBounds;t.centerBounds=[n,-i,s,-r]}return t};function Sr(e){let t=e.state;switch(e.kind){case"rect":return tn(ma,fn(t,t.width??0,t.height??0));case"ellipse":{let n=fn(t,t.width??0,t.height??0);return t.startAngle!=null&&(n.startAngle=-t.startAngle),t.sweep!=null&&(n.sweep=-t.sweep),tn(Jr,n)}case"polygon":return tn($l,fn(t,t.width??0,t.height??0));case"polygram":return tn(Ul,fn(t,t.width??0,t.height??0));case"line":{let n=t.points?t.points.map(r=>({x:r.x,y:-r.y})):t.points;return tn(Fl,{...t,y:ga(t.y),points:n})}case"path":return Vl(zl(t))}return null}function Gl(e,t,n){if(n<=0||e.strength<=0||e.length<=0)return null;let r=kt(e.axis),s=e.length/100,i=t.x*n*r.x*s*e.strength,a=t.y*n*r.y*s*e.strength,o=Math.hypot(i,a);return o<.01?null:{angle:Math.atan2(a,i)*180/Math.PI,radius:o,phase:sc(e.alignment),samples:e.samples}}var ut=.5,wa=Math.hypot(1,ut),fi=ut/wa,Hl=1/wa,Kl=.35;function ya(e){return e==="arrow"||e==="triangle"||e==="stealth"}function ql(e,t,n){return ya(e)?Math.min(t,n/(2*ut)):0}function Jl(e,t,n){let r=t/2;switch(e){case"dot":return null;case"triangle":return[0,0,-t,t*ut,-t,-t*ut];case"stealth":return[0,0,-t,t*ut,-t*(1-Kl),0,-t,-t*ut];case"arrow":return Yl(t,n);case"box":return[-r,-r,r,-r,r,r,-r,r];case"diamond":return[r,0,0,r,-r,0,0,-r];case"bar":return[-n/2,-r,n/2,-r,n/2,r,-n/2,r]}}function Yl(e,t){let n=e*ut,r=-e-t*fi,s=n-t*Hl;if(s<=0)return[0,0,-e,n,-e,-n];let i=-t/fi;return[0,0,-e,n,r,s,i,0,r,-s,-e,-n]}function Xl(e,t,n,r){let s=!!e.dash?.length,i=e.startCap??e.cap,a=e.endCap??e.cap,o=s?e.cap:Wt(a)?"butt":a,l=i!==o||a!==o;if(!s&&!l)return{cap:o,ends:[]};let c=Tl(t),u=s?Pl(c,e.dash):null;if(s&&!u)return{cap:o,ends:l?Er(c,e,i,a,o,n,null):[]};if(!u)return{cap:o,ends:Er(c,e,i,a,o,n,null)};let d=l?Er(c,e,i,a,o,n,p=>aa(p,e.dash,e.dashOffset??0,ia(p,e.dash,u))):[];if(r||d.length||u.open){let p=Il(c,e.dash,e.dashOffset??0,e.cap!=="butt",u);return p?{cap:o,ends:d,source:p}:null}return{cap:o,ends:d,dash:e.dash.map(p=>p*u.scale),dashPhase:(e.dashOffset??0)*u.scale}}function Er(e,t,n,r,s,i,a){let o=[],l=(Wt(n)?1:0)+(Wt(r)?1:0),c=i/2,u=Math.min(c,1)/2,f=t.cap!=="butt"?c:0;for(let d of e){if(d.closed)continue;let p=Math.min(t.capScale*i,d.length/Math.max(1,l)),_=a?.(d),w=A=>!_||_.some(([B,L])=>A>=B-f-1e-6&&A<=L+f+1e-6);n!==s&&di(o,d.posTan(0),d.posTan(p),-1,n,p,i,w(u)),r!==s&&di(o,d.posTan(d.length),d.posTan(d.length-p),1,r,p,i,w(d.length-u))}return o}function di(e,[t,n,r,s],i,a,o,l,c,u){let f=a*r,d=a*s;Wt(o)&&ya(o)&&Math.hypot(t-i[0],n-i[1])>1e-6&&(f=t-i[0],d=n-i[1]);let p=Math.hypot(f,d);p<1e-9||e.push({x:t,y:n,dx:f/p,dy:d/p,cap:o,size:l,weight:c,reached:u})}function Ar({x:e,y:t,dx:n,dy:r},s,i){let a=-r*i,o=n*i,l=n*s,c=r*s;return new rt().moveTo(e-a,t-o).lineTo(e-a+l,t-o+c).lineTo(e+a+l,t+o+c).lineTo(e+a,t+o).close().build()}function Zl({x:e,y:t,dx:n,dy:r},s){let i=new rt,a=32;for(let o=0;o<=a;o++){let l=-Math.PI/2+Math.PI*o/a,c=Math.cos(l)*s,u=Math.sin(l)*s,f=e+c*n-u*r,d=t+c*r+u*n;o===0?i.moveTo(f,d):i.lineTo(f,d)}return i.close().build()}function Ql(e,t){let{x:n,y:r,dx:s,dy:i,size:a,weight:o}=e,l=Jl(t,a,o),c=new rt;if(!l){let u=a/2,f=.5522848*u;return c.moveTo(n+u,r).cubicTo(n+u,r+f,n+f,r+u,n,r+u).cubicTo(n-f,r+u,n-u,r+f,n-u,r).cubicTo(n-u,r-f,n-f,r-u,n,r-u).cubicTo(n+f,r-u,n+u,r-f,n+u,r),c.close().build()}for(let u=0;u<l.length;u+=2){let f=n+l[u]*s-l[u+1]*i,d=r+l[u]*i+l[u+1]*s;u===0?c.moveTo(f,d):c.lineTo(f,d)}return c.close().build()}function pt(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((i,a)=>i+a.verbs.length,0)),n=new Float32Array(e.reduce((i,a)=>i+a.points.length,0)),r=0,s=0;for(let i of e)t.set(i.verbs,r),r+=i.verbs.length,n.set(i.points,s),s+=i.points.length;return{verbs:t,points:n}}var eu=class extends Set{node;nodes=new Map;constructor(e){super(),this.node=e}add(e){super.add(e);let t=this.node?.();if(t!==void 0){let n=this.nodes.get(e);n||this.nodes.set(e,n=new Set),n.add(t)}return this}clear(){super.clear(),this.nodes.clear()}},hi=new Set(["rect","ellipse","path","line","polygon","polygram","text","richText"]),pi=e=>e.type==="solid";function tu(e,t){if(t===0)return e;let n=e.w+2*t,r=e.h+2*t;return n>0&&r>0?e.kind==="ellipse"?{...e,x:e.x-t,y:e.y-t,w:n,h:r}:e.radii.some(s=>s>0&&!(s+t>0))?null:{...e,x:e.x-t,y:e.y-t,w:n,h:r,radii:e.radii.map(s=>s>0?s+t:0)}:null}var _t={kind:"solid",color:[0,0,0,1]},Lt={kind:"solid",color:[0,0,0,0]},_i=e=>[-e.size[0]/2,-e.size[1]/2,e.size[0]/2,e.size[1]/2],mi=(e,t)=>`${e}|${t.weight}|${t.align}|${t.join}|${t.cap}|${t.miterLimit}|${t.dash}|${t.dashOffset}`,gi={union:"union",subtract:"cut",intersect:"intersect",exclude:"exclude"};function Tr(e){let t=null;for(let n of e){let r=it(n.path),s=n.op??"union";t?s==="union"||s==="exclude"?t=[Math.min(t[0],r[0]),Math.min(t[1],r[1]),Math.max(t[2],r[2]),Math.max(t[3],r[3])]:s==="intersect"&&(t=[Math.max(t[0],r[0]),Math.max(t[1],r[1]),Math.min(t[2],r[2]),Math.min(t[3],r[3])],(t[2]<t[0]||t[3]<t[1])&&(t=[t[0],t[1],t[0],t[1]])):(s==="union"||s==="exclude")&&(t=r)}return t}function nu(e){let t=e[0]*e[3]-e[1]*e[2];if(!t)return null;let n=e[3]/t,r=-e[1]/t,s=-e[2]/t,i=e[0]/t;return[n,r,s,i,-(n*e[4]+s*e[5]),-(r*e[4]+i*e[5])]}var bi=1<<20;function Pr(e){let t=(e==="plus-lighter"?"plus":e).replace(/-(\w)/g,(n,r)=>r.toUpperCase());return qi.includes(t)?t:null}var wi=new WeakMap,ru=1<<24;function yi(e){let t=wi.get(e);return t===void 0&&wi.set(e,t=ru++),t}var va=class extends Go{width;height;measure;readsSpaceRects=!0;drawsVisibleOnly=!0;pixelRatio=1;doc;missing=new eu(()=>this.currentNodeStack[this.currentNodeStack.length-1]);shaderIssues=[];storage=null;images=new Map;frameImages=new Map;assets={image:e=>this.image(e),scene3d:(e,t,n,r)=>{let s=new Map;ec(e,o=>{if(tc(o)&&!s.has(o)){let l=this.surfaceOf(o);l&&s.set(o,l)}});let i=new Proxy({},{get:(o,l)=>typeof l=="string"?this.image(l)??void 0:void 0}),a=this.doc.addScene3D(e,t,n,{images:i,surfaces:s});return a.scale3d=r,a.version=++bi,a},video:(e,t)=>{let n=this.storage,r=t??this.videoTime(e);if(!n||r===null)return null;let s=n.videoFrame(e.src,r);if(!s)return null;let i=`${wt(e.src)}@${r.toFixed(6)}`,a=this.frameImages.get(i);return a||(a=this.doc.addImage(s,s.width,s.height,{mipmaps:!1}),a.version=yi(s),this.frameImages.set(i,a)),a},imageEdge:(e,t)=>this.storage?.wantImageEdge?.(e,t),deviceScale:()=>{let e=this.device();return Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2]))},time:()=>this.elapsed(),checkShader:e=>this.checkShader("fill",e)};image=e=>{let t=wt(e),n=this.frameImages.get(t);if(n)return n;let r=this.images.get(t);return r?(n=this.doc.addImage(r.bitmap,r.width,r.height),n.version=yi(r.bitmap),this.frameImages.set(t,n),n):null};stack=[];scopes=[];worldAlpha=1;shapes=[];painted=!1;shadows=[];constructor(e,t,n){super(),this.width=e,this.height=t,this.measure=n}get cur(){return this.stack[this.stack.length-1]}measureText(e,t,n,r=400,s=0,i){return this.measure(e,t,n,r,s,i)}execute(e){this.doc=new Ji(this.width,this.height,this.clearColor()),this.frameImages.clear(),this.missing.clear(),this.shaderIssues.length=0;let t=this.doc.group(this.doc.root,{transform:this.rootTransform()}),n=this.frameGroup(t);this.stack=n===t?[t]:[t,n],this.scopes=[],this.worldAlpha=1,this.masks=[],this.cameras=[],this.clips=[],this.booleans=[],this.resetSurface(),e()}rootTransform(){return[1,0,0,1,this.width/2,this.height/2]}clearColor(){return[0,0,0,1]}frameGroup(e){return e}screenshot(){}unmount(){}begin(e){super.begin(e),this.scopes.push({groups:1,worldAlpha:this.worldAlpha}),this.stack.push(this.doc.group(this.cur)),this.resetSurface()}end(){let e=this.scopes.pop();if(e){for(let t=0;t<e.groups;t++)this.stack.pop();this.worldAlpha=e.worldAlpha}super.end()}transform(e){let t=e.x??0,n=e.y??0,r=e.width??0,s=e.height??0,i=e.opacity??1,a=e.blend??"pass-through",o,l=e.matrix;if(l)o=[l.a,l.b,l.c,l.d,l.e,l.f,l.g??0,l.h??0,l.i??1];else{let f=e.pivot??{x:0,y:0},d=f.x*(r/2),p=-f.y*(s/2),_=(e.rotation??0)*Math.PI/180,w=e.scale??1,A=Math.cos(_)*w,B=Math.sin(_)*w;o=[A,B,-B,A,t+d-(A*d-B*p),n+p-(B*d+A*p)]}let c=this.cur;c.transform=hr(c.transform,Vn(o)?o:o.slice(0,6));let u=this.motionBlur((e.effects??[]).filter(f=>f.mode!=="backdrop"));for(let f of u)f.type==="shader"&&this.checkShader("effect",f);if(u.length&&(c.effects=u,c.effectBox=[-r/2,-s/2,r,s],c.effectTime=this.elapsed()),a!=="pass-through"){let f=Pr(a);f||this.missing.add(`blend:${a}`),this.stack.push(this.doc.group(c,{opacity:this.worldAlpha*(i<1?i:1),blend:f??"normal"})),this.scopes[this.scopes.length-1].groups++,this.worldAlpha=1}else i<1&&(this.worldAlpha*=i);return this}resetSurface(){this.shapes=[],this.painted=!1,this.shadows=[]}drawGraphics(e){let t=this.worldAlpha,n=e;if(n.needsGroupLayer?.()){let c=n.groupOpacity();c<1&&(this.worldAlpha*=c)}let r=n.groupTransform?.(),s=null;if(r){let{x:c,y:u}=this.groupCenter(e,r.center),f=r.rotation*Math.PI/180,d=Math.cos(f)*r.scale,p=Math.sin(f)*r.scale;s=this.doc.group(this.cur,{transform:[d,p,-p,d,c-(d*c-p*u),u-(p*c+d*u)]}),this.stack.push(s)}let i=e.ops(),a=this.effectSegments(i),o=null;for(let c=0;c<i.length;c++){let u=i[c],f=a.get(c);switch(f&&(o=this.doc.group(this.cur,{effects:f,effectBox:this.viewportBox(),effectTime:this.elapsed()}),this.stack.push(o)),u.kind){case"rect":case"ellipse":case"polygon":case"polygram":case"line":case"path":{this.painted&&this.resetSurface();let d=Sr(u);if(!d)break;this.booleans.length?this.collect(d):this.shapes.push(d);break}case"cut":this.cut();break;case"richText":this.painted&&this.resetSurface(),this.richText(u.state);break;case"text":{this.painted&&this.resetSurface();let d=jl(u.state,_=>{let w=_.runs[0],A=this.measureText(w.text,w.size,w.family,w.weight,w.letterSpacing,w.italic?"italic":"normal");return[A.width,A.height]}),p=u.state.segments;if(d&&p?.length&&!d.spec.path)this.paintSegments(d,p);else if(d){let[_,w]=d.size,A=d.transform[4],B=d.transform[5];this.shapes.push({fill:null,stroke:null,interior:null,bounds:[A-_/2,B-w/2,A+_/2,B+w/2],text:d})}else this.missing.add("text:path");break}case"fill":this.fill(Qo.resolve(u.fills));break;case"stroke":this.stroke(pc.resolve(u.strokes));break;case"shadow":this.shadows=dc.resolve(u.shadows);break;case"effects":o&&(this.stack.splice(this.stack.lastIndexOf(o)),o=null),this.resetSurface();break;case"mask":this.beginMask(u.options);break;case"applyMask":this.applyMask();break;case"endMask":this.endMask();break;default:this.missing.add(`op:${u.kind}`)}}let l=s??o;l&&this.stack.splice(this.stack.lastIndexOf(l)),this.worldAlpha=t}effectSegments(e){let t=new Map,n=0,r=!1;return e.forEach((s,i)=>{if(hi.has(s.kind))r&&(n=i,r=!1);else if(s.kind==="fill"||s.kind==="stroke"||s.kind==="shadow")r=!0;else if(s.kind==="effects"){let a=this.motionBlur(s.effects.filter(o=>o.mode!=="backdrop"));a.length&&t.set(n,a),n=i+1,r=!1}}),t}motionBlur(e){if(!e.some(n=>n.type==="motionBlur"))return e;let t=this.currentRenderState();return e.flatMap(n=>{if(n.type!=="motionBlur")return[n];let r=t?Gl(n,t.velocity,t.dt):null;return r?((r.phase!==0||Math.round(r.samples)>32)&&this.missing.add("effect:motionBlur-shutter"),[{type:"directionalBlur",radius:r.radius,angle:r.angle}]):[]})}groupCenter(e,t){if(t!==void 0&&typeof t!="string")return{x:t.x,y:t.y};let n=null;for(let a of e.ops()){let o=hi.has(a.kind)&&a.kind!=="text"&&a.kind!=="richText"?Sr(a)?.fill:null;if(!o||!o.verbs.length)continue;let l=it(o);n=n?[Math.min(n[0],l[0]),Math.min(n[1],l[1]),Math.max(n[2],l[2]),Math.max(n[3],l[3])]:l}if(!n)return{x:0,y:0};let r=(n[0]+n[2])/2,s=(n[1]+n[3])/2;if(t===void 0)return{x:r,y:s};let i=Ko.resolve(t);return{x:r+i.x*((n[2]-n[0])/2),y:s-i.y*((n[3]-n[1])/2)}}viewportBox(){let[e,t,n,r]=this.spaceBounds({space:"global"},[0,0,0,0]);return[e,t,n-e,r-t]}surface(e){let t=this.shapes.map(n=>n[e]).filter(n=>!!n&&n.verbs.length>0);return e==="fill"&&t.length>1&&(t=t.map(n=>Sl(n)<0?El(n):n)),t.length?pt(t):null}bounds(e){let t=this.shapes.map(n=>n.bounds).filter(n=>n!==null);return e&&t.length!==this.shapes.length?it(e):t.length?t.reduce((n,r)=>[Math.min(n[0],r[0]),Math.min(n[1],r[1]),Math.max(n[2],r[2]),Math.max(n[3],r[3])]):[0,0,0,0]}leaf(e,t,n){return"members"in t?this.doc.compound(e,{...n,members:t.members}):this.doc.pathNode(e,{...n,path:t.path})}geomBounds(e){return"members"in e?Tr(e.members)??[0,0,0,0]:it(e.path)}spreadGeom(e,t,n){if(!t||"members"in e)return e;let r=[];for(let s of this.shapes){if(s.members||!s.fill||!s.fill.verbs.length)continue;let i=s.spread?s.spread(t):s.fill;i&&i.verbs.length?r.push(i):n||r.push(s.fill)}return r.length?{path:pt(r)}:null}clipTo(e,t){if("path"in t){let[r,s,i,a]=it(t.path);return this.doc.group(e,{clip:{x:r,y:s,w:i-r,h:a-s,r:0,path:t.path}})}let n=this.doc.group(e,{mask:"alpha"});return this.doc.compound(n,{members:t.members,fill:_t}),n}clipOutside(e,t){let n=this.doc.group(e,{mask:"invertAlpha"});return this.leaf(n,t,{fill:_t}),n}fill(e){this.painted=!0,!this.booleans.length&&this.deferring("fill",()=>this.paintFill(e))}deferring(e,t){let n=this.masks[this.masks.length-1],r=n?.apply&&!n.apply.has(e)&&!this.inVectorMask?n.after:null;if(!r)return t();this.stack.push(r);try{t()}finally{this.stack.splice(this.stack.lastIndexOf(r))}}paintFill(e){if(this.paintText(e,null),!e.length||this.fillNative(e))return;let t=this.surface("fill"),n=t?[{path:t}]:[];for(let i of this.shapes)i.members&&n.push({members:i.members});if(!n.length)return;let r=this.bounds(t),s=this.shadows;this.shadows=[];for(let i of n)this.fillGeom(i,r,e,s)}fillNative(e){let t=this.shapes.length===1?this.shapes[0]:null,n=t?.native;if(!t||!n||this.inVectorMask||this.shadows.length||!e.every(pi))return!1;for(let r of e){let s=He(r,t.bounds,this.missing,this.assets);s&&this.native(this.cur,n,{fill:s,opacity:this.worldAlpha*(r.opacity??1),blend:this.blendOf(r)})}return!0}strokeNative(e,t,n,r){let s=this.shapes.length===1?this.shapes[0]:null,i=s?.native;if(!s||!i||t<=0||(e.dash?.length??0)>0||!e.fill.every(pi)||i.kind==="ellipse"&&Math.abs(i.w-i.h)>.001||i.kind==="rect"&&i.radii.some(f=>f===0)&&(e.join!=="miter"||!(e.miterLimit>=Math.SQRT2)))return!1;let a=Math.max(-1,Math.min(1,e.align??0)),o=tu(i,a*t/2);if(!o)return!1;let l=s.bounds,c=this.snapBounds([Math.fround(l[0]),Math.fround(l[1]),Math.fround(l[2]),Math.fround(l[3])],n,r),u=c?this.doc.group(this.cur,{transform:c}):this.cur;for(let f of e.fill){let d=He(f,l,this.missing,this.assets);if(!d)continue;let p={paint:d,width:t,join:e.join,cap:e.cap,miter:e.miterLimit};this.native(u,o,{opacity:this.worldAlpha*(f.opacity??1),stroke:p,...a===0&&{blend:this.blendOf(f)}})}return!0}native(e,t,n){let r={...n,transform:[1,0,0,1,t.x,t.y],w:t.w,h:t.h,radii:t.radii};return t.kind==="rect"?this.doc.rect(e,r):this.doc.ellipse(e,r)}fillGeom(e,t,n,r){if(this.inVectorMask){this.leaf(this.cur,e,{fill:_t});return}let s=[];for(let i of r){if(i.inner)continue;if(i.fill.length===1&&i.fill[0].type==="solid"){let u=Ic(i,this.missing);u&&s.push(u);continue}let a=i.offset?.x??0,o=-(i.offset?.y??0),l=this.doc.group(this.cur,{transform:[1,0,0,1,a,o],filter:i.blur>0?{kind:"blur",sigma:i.blur/2}:void 0}),c=this.spreadGeom(e,i.spread??0,!1);for(let u of i.fill){let f=He(u,this.spaceBounds(u,t),this.missing,this.assets);f&&this.leaf(l,c,{fill:f,opacity:this.worldAlpha*(u.opacity??1)})}}n.forEach((i,a)=>{let o=this.spaceBounds(i,t),l=He(i,o,this.missing,this.assets);if(!l)return;let c=this.worldAlpha*(i.opacity??1),u=a===0?s:[],f=i.type==="video"?i.preset?.adjustments?.find(p=>p.type==="echo"):void 0;if(f&&f.echoes>0&&f.delay>0){this.echoStack(e,i,o,t,l,c,u,f);return}let d=i.preset?.intensity??1;if(d>0&&d<1&&this.pixelAdjustments(i).length){let p=this.doc.group(this.cur,{opacity:c,blend:this.blendOf(i)});this.mediaPreset(this.leaf(p,e,{fill:l,shadows:u}),i,t),this.leaf(p,e,{fill:l,opacity:1-d});return}this.mediaPreset(this.leaf(this.cur,e,{fill:l,opacity:c,shadows:u,blend:this.blendOf(i)}),i,t)});for(let i of r){if(!i.inner)continue;let a=this.spreadGeom(e,-(i.spread??0),!0),o=i.offset?.x??0,l=-(i.offset?.y??0),[c,u,f,d]=this.geomBounds(e),p=Math.abs(o)+Math.abs(l)+i.blur*2+2,_=this.clipTo(this.cur,e);for(let w of i.fill){let A=He(w,this.spaceBounds(w,t),this.missing,this.assets);if(!A)continue;let B=this.doc.group(_,{opacity:this.worldAlpha*(w.opacity??1),filter:i.blur>0?{kind:"blur",sigma:i.blur/2}:void 0}),L=this.doc.group(B,a?{mask:"invertAlpha"}:{});a&&this.leaf(L,a,{transform:[1,0,0,1,o,l],fill:_t}),this.doc.rect(L,{transform:[1,0,0,1,c-p,u-p],w:f-c+2*p,h:d-u+2*p,fill:A})}}}richText(e){let t=vc(e),n=t.spans;if(!n.length)return;let r=[-t.width/2,-t.height/2,t.width/2,t.height/2],s={kind:"solid",color:[0,0,0,0]},i=u=>(u[0]?He(u[0],r,this.missing,this.assets):null)??s,a=n.map(u=>({text:u.text,family:u.fontFamily,size:u.fontSize,weight:u.fontWeight,italic:u.fontStyle==="italic"||u.fontStyle==="oblique",letterSpacing:u.letterSpacing})),o={runs:a,align:{start:"left",end:"right"}[t.textAlign]??t.textAlign,wrap:t.width>0,width:t.width,lineHeight:t.lineHeight},l=Math.max(1,...n.map(u=>u.fill.length));for(let u=0;u<l;u++){let f=a.map((d,p)=>({...d,paint:i(n[p].fill.slice(u,u+1))}));this.doc.textNode(this.cur,{text:{...o,runs:f},fill:s,opacity:this.worldAlpha})}let c=new Map;n.forEach((u,f)=>u.stroke.forEach((d,p)=>{let _=`${p}|${d.weight}|${d.join}|${d.cap}|${d.miterLimit}`,w=c.get(_);w||c.set(_,w={k:p,st:d,paints:n.map(()=>s)}),w.paints[f]=i(d.fill)}));for(let{st:u,paints:f}of[...c.values()].sort((d,p)=>d.k-p.k)){let d=a.map((p,_)=>({...p,paint:f[_]}));this.doc.textNode(this.cur,{text:{...o,runs:d},opacity:this.worldAlpha,stroke:{paint:s,width:u.weight,join:u.join,cap:u.cap,miter:u.miterLimit}})}}paintText(e,t){for(let n of this.shapes){let r=n.text;if(r)for(let s of e){let i=He(s,_i(r),this.missing,this.assets);i&&this.textLayer(r,r.spec,r.spec,i,this.worldAlpha*(s.opacity??1),t)}}}paintSegments(e,t){let n=this.segmentSpec(e,t),r=_i(e),s=(c,u)=>{if(!u||!(c.opacity>0))return Lt;let f=He(u,r,this.missing,this.assets);return f?this.fadePaint(f,c.opacity*(u.opacity??1)):Lt},i=c=>({...n,runs:n.runs.map((u,f)=>({...u,paint:c(t[f])}))}),a={...n,runs:n.runs.map((c,u)=>t[u].opacity>0?c:{...c,paint:Lt})},o=Math.max(0,...t.map(c=>c.fill?.length??0));for(let c=0;c<o;c++)this.textLayer(e,i(u=>s(u,u.fill?.[c])),a,Lt,this.worldAlpha,null);let l=new Map;t.forEach(c=>c.stroke?.forEach((u,f)=>{let d=mi(f,u);l.has(d)||l.set(d,{k:f,st:u})}));for(let[c,{k:u,st:f}]of[...l].sort((d,p)=>d[1].k-p[1].k)){let d=Math.max(...t.map(p=>p.stroke?.[u]?.fill.length??0));for(let p=0;p<d;p++){let _=w=>{let A=w.stroke?.[u];return A&&mi(u,A)===c?s(w,A.fill[p]):Lt};this.textLayer(e,i(_),a,Lt,this.worldAlpha,f)}}}segmentSpec(e,t){let n=e.spec.runs[0],r=1,s=e.spec.wrap,{width:i=0,height:a=0,minFontSize:o=0}=e.spec;if(e.spec.fontSize==="autofit"&&i>0&&a>0){let c=this.measureText(n.text,Fn,n.family,n.weight,n.letterSpacing,n.italic?"italic":"normal"),u=Fn*Math.min(c.width>0?i/c.width:1,c.height>0?a/c.height:1);s&&u<o?r=o/Fn:(r=u/Fn,s=!1)}let l=t.map(c=>({text:c.text,family:c.fontFamily??n.family,size:(c.fontSize??n.size)*r,weight:c.fontWeight,italic:c.fontStyle===void 0?n.italic:c.fontStyle==="italic"||c.fontStyle==="oblique",letterSpacing:c.letterSpacing,decoration:c.textDecoration===void 0?n.decoration:c.textDecoration==="underline"?"underline":c.textDecoration==="line-through"?"lineThrough":void 0}));return{...e.spec,runs:l,wrap:s,fontSize:void 0}}fadePaint(e,t){return t>=1?e:e.kind==="solid"?{...e,color:[e.color[0],e.color[1],e.color[2],e.color[3]*t]}:"stops"in e?{...e,stops:e.stops.map(n=>({...n,color:[n.color[0],n.color[1],n.color[2],n.color[3]*t]}))}:(this.missing.add("text:run-opacity"),e)}textLayer(e,t,n,r,s,i){if(!i){this.doc.textNode(this.cur,{transform:e.transform,text:t,opacity:s,fill:r});return}let a=f=>({paint:r,width:f,join:i.join,cap:i.cap,miter:i.miterLimit,dash:i.dash,dashPhase:i.dashOffset}),o=Math.max(-1,Math.min(1,i.align??0));if(o===0){this.doc.textNode(this.cur,{transform:e.transform,text:t,opacity:s,stroke:a(i.weight)});return}let l=f=>this.doc.textNode(f,{transform:e.transform,text:n,fill:_t}),c=(f,d)=>this.doc.textNode(f,{transform:e.transform,text:n,stroke:{paint:_t,width:d,join:i.join,miter:i.miterLimit}}),u=f=>{if(o>0){let _=this.doc.group(this.cur,{mask:"invertAlpha"}),w=this.doc.group(_,{mask:"invertAlpha"});return c(w,f),l(w),_}let d=this.doc.group(this.cur,{mask:"alpha"}),p=this.doc.group(d);return l(p),c(p,f),d};if(Math.abs(o)>=1){let f=this.doc.group(this.cur,{mask:o>0?"invertAlphaEroded":"alphaDilated"});l(f),this.doc.textNode(f,{transform:e.transform,text:t,opacity:s,stroke:a(2*i.weight)})}else{let f=(1+o)*i.weight/2,d=(1-o)*i.weight/2;this.doc.textNode(u(2*(o>0?d:f)),{transform:e.transform,text:t,opacity:s,stroke:a(2*Math.max(f,d))})}}surfaceOf(e){let t=Math.max(1,Math.min(e.maxPixelRatio??1,4)),n=e.width??512,r=e.height??512,s=Math.max(1,Math.ceil(n*t)),i=Math.max(1,Math.ceil(r*t)),a=this.doc.detached({transform:[t,0,0,t,n*t/2,r*t/2]}),o={stack:this.stack,scopes:this.scopes,alpha:this.worldAlpha,shapes:this.shapes,painted:this.painted,shadows:this.shadows,masks:this.masks,clips:this.clips,cameras:this.cameras};this.stack=[a],this.scopes=[],this.worldAlpha=1,this.masks=[],this.clips=[],this.cameras=[],this.resetSurface();try{let c=lc(e.source);c.kind==="graphics"?this.draw(c.graphics):(c.node.layout({x:0,y:0,width:n,height:r},this),c.node.render(this))}catch(c){this.missing.add("surface:error"),console.warn(c)}finally{Object.assign(this,{stack:o.stack,scopes:o.scopes,worldAlpha:o.alpha,shapes:o.shapes,painted:o.painted,shadows:o.shadows,masks:o.masks,clips:o.clips,cameras:o.cameras})}let l=this.doc.addSurface(a,s,i);return l.version=++bi,l}mediaPreset(e,t,n){let r=this.pixelAdjustments(t);!r.length||(t.preset.intensity??1)<=0||(e.effects=r.map(s=>({...s,clip:!0})),e.effectBox=[n[0],n[1],n[2]-n[0],n[3]-n[1]],e.effectTime=this.elapsed())}pixelAdjustments(e){let t=e;return t.type!=="image"&&t.type!=="video"||!t.preset?[]:(t.preset.adjustments??[]).filter(n=>n.type!=="echo"&&n.type!=="posterizeTime")}echoStack(e,t,n,r,s,i,a,o){let l=Pr(o.blend??"screen")??"screen",c=o.decay??.5,u=Math.min(Math.max(0,Math.floor(o.echoes)),32),f=this.videoTime(t);a.length&&this.leaf(this.cur,e,{fill:{kind:"solid",color:[0,0,0,0]},opacity:i,shadows:a});for(let d=u;d>=1&&f!==null;d--){let p=f-d*o.delay;if(p<0)continue;let _=He(t,n,this.missing,{...this.assets,video:w=>this.assets.video(w,p)});_&&this.leaf(this.cur,e,{fill:_,opacity:i*Math.pow(c,d),blend:l})}this.mediaPreset(this.leaf(this.cur,e,{fill:s,opacity:i,blend:l}),t,r)}videoTime(e){let t=this.storage?.videos.get(wt(e.src));return t?uc(e,this.currentRenderState()?.elapsed??0,t.duration):null}elapsed(){return this.currentRenderState()?.elapsed??0}spaceBounds(e,t){let n=e.space??"local";if(n==="parent"){let r=this.currentSpaceRects().parent;return r?[r.left,r.top,r.right,r.bottom]:t}if(n==="global"){let r=this.device(),s=r[0]*r[3]-r[1]*r[2];if(!s)return t;let i=(u,f)=>{let d=u-r[4],p=f-r[5];return[(r[3]*d-r[2]*p)/s,(-r[1]*d+r[0]*p)/s]},a=this.width*this.pixelRatio,o=this.height*this.pixelRatio,l=i(0,0),c=i(a,o);return[Math.min(l[0],c[0]),Math.min(l[1],c[1]),Math.max(l[0],c[0]),Math.max(l[1],c[1])]}return t}blendOf(e){let t=e.blend;if(!t||t==="normal")return"normal";let n=Pr(t);return n||this.missing.add(`fill:blend:${t}`),n??"normal"}device(){let e=[this.pixelRatio,0,0,this.pixelRatio,0,0];for(let t of this.stack)e=hr(e,t.transform);return e}snap(e,t,n){return this.snapBounds(it(e),t,n)}snapBounds([e,t,n,r],s,i){if(s<=0||Math.abs(i[1])>1e-6||Math.abs(i[2])>1e-6||i[0]===0||i[3]===0||n-e<=0||r-t<=0)return null;let a=i[0],o=i[3],l=i[4],c=i[5],u=l+a*e,f=c+o*t,d=l+a*n,p=c+o*r,_=s%2===0?0:.5,w=Math.round(u-_)+_,A=Math.round(f-_)+_,B=Math.round(d-_)+_,L=Math.round(p-_)+_;if(B-w<1||L-A<1)return null;let V=(B-w)/(d-u),se=(L-A)/(p-f);return Math.abs(V-1)<1e-4&&Math.abs(se-1)<1e-4&&Math.abs(w-u)<1e-4&&Math.abs(A-f)<1e-4?null:[V,0,0,se,(w-l)/a-V*e,(A-c)/o-se*t]}stroke(e){this.painted=!0,!this.booleans.length&&this.deferring("stroke",()=>this.paintStroke(e))}paintStroke(e){for(let a of e)this.paintText(a.fill,a);let t,n=()=>t===void 0?t=this.surface("fill"):t,r=this.device(),s=Math.sqrt(Math.abs(r[0]*r[3]-r[1]*r[2])),i=Vn(r)||Math.abs(r[1])>1e-6||Math.abs(r[2])>1e-6;for(let a of e){let o=a.weight,l=-1;if(!i&&o>0&&s>0&&o*s<2.5&&(l=Math.max(1,Math.round(o*s)),o=l/s),!this.strokeNative(a,o,l,r))for(let c of this.strokeShapes()){let u,f,d={cap:a.cap,ends:[],dash:a.dash,dashPhase:a.dashOffset};if(c.members)u=f={members:c.members};else{if(!c.stroke||!c.stroke.verbs.length)continue;let L=Xl(a,c.stroke,o,l>0);if(!L)continue;d=L,u={path:L.source??c.stroke},f=c.alignInterior?{members:c.alignInterior}:c.interior&&oi(c.interior)?{path:c.interior}:null}let p=this.bounds(n()??("path"in u?u.path:null)),_=Math.max(-1,Math.min(1,a.align??0)),w=_!==0&&f!==null&&!d.ends.some(L=>Wt(L.cap))?[[(1+_)*o,"out"],[(1-_)*o,"in"]]:[[o,"both"]],A=c.fill?this.snap(c.fill,l,r):null,B=A?this.doc.group(this.cur,{transform:A}):this.cur;for(let L of a.fill){let V=He(L,this.spaceBounds(L,p),this.missing,this.assets);if(!V)continue;let se=this.worldAlpha*(L.opacity??1);for(let[X,pe]of w){if(X<=0)continue;let ue={paint:V,width:X,join:a.join,cap:d.cap,miter:a.miterLimit,dash:d.dash,dashPhase:d.dashPhase};pe==="both"?this.strokeLeaf(B,u,{opacity:se,stroke:ue,blend:this.blendOf(L)},d.ends):this.strokeLeaf(pe==="in"?this.clipTo(B,f):this.clipOutside(B,f),u,{opacity:se,stroke:ue},d.ends)}}}}}strokeShapes(){if(this.shapes.length<2||this.shapes.some(r=>r.text))return this.shapes;let e=this.shapes.filter(r=>r.members||r.fill&&r.fill.verbs.length).sort((r,s)=>(s.members?1:0)-(r.members?1:0));if(e.length<2)return this.shapes;let t=[];for(let r of e)r.members?r.members.forEach((s,i)=>t.push({...s,op:i===0?"union":s.op})):t.push({kind:"path",path:r.fill,op:"union"});e.filter(r=>r.members).length>1&&this.missing.add("stroke:union-of-booleans");let n=e.every(r=>r.bounds)?e.map(r=>r.bounds).reduce((r,s)=>[Math.min(r[0],s[0]),Math.min(r[1],s[1]),Math.max(r[2],s[2]),Math.max(r[3],s[3])]):null;return e.some(r=>!r.members&&(r.stroke!==r.fill||r.trimmed||!oi(r.fill)))?e.some(r=>r.members)?this.shapes:[{fill:pt(e.map(r=>r.fill)),stroke:pt(e.map(r=>r.stroke??r.fill)),interior:null,alignInterior:t,bounds:n}]:[{fill:null,stroke:null,interior:null,bounds:n,members:t}]}strokeLeaf(e,t,n,r){if(!r.length)return this.leaf(e,t,n);let s=n.stroke.width/2,i=s*1.01+.5,a=n.stroke.cap!=="butt",o=[],l=[];for(let f of r){if(Wt(f.cap)){let d=ql(f.cap,f.size,f.weight);(d>0||a)&&o.push(Ar({...f,x:f.x-f.dx*d,y:f.y-f.dy*d},d+i,i)),l.push(Ql(f,f.cap));continue}a&&o.push(Ar(f,i,i)),f.reached&&f.cap!=="butt"&&l.push(f.cap==="round"?Zl(f,s):Ar(f,s,s))}let c=this.doc.group(e,{opacity:n.opacity??1,blend:n.blend??"normal"}),u={...n,opacity:1,blend:"normal"};if(o.length){let f=this.doc.group(c,{mask:"invertAlpha"});this.doc.pathNode(f,{path:pt(o),fill:_t}),this.leaf(f,t,u)}else this.leaf(c,t,u);return l.length&&this.doc.pathNode(c,{path:pt(l),fill:n.stroke.paint}),c}booleans=[];beginBoolean(e){this.booleans.push({op:e,base:nu(this.device()),members:[]}),this.resetSurface()}endBoolean(){let e=this.booleans.pop();if(this.resetSurface(),!e||!e.members.length)return;let t=this.booleans[this.booleans.length-1];if(!t){this.shapes.push({fill:null,stroke:null,interior:null,bounds:Tr(e.members),members:e.members});return}let n=this.relative(t.base),r=gi[t.op],s=!t.members.length;!s&&!e.members.slice(1).every(i=>i.op===(r==="cut"?"union":r))&&this.missing.add("boolean:nested"),e.members.forEach((i,a)=>{let o=i.op??"union",l=s?o:a===0||r==="cut"?r:o;t.members.push({kind:"path",path:n?Js(i.path,n):i.path,op:l})})}relative(e){let t=this.device();return!e||Vn(t)?null:hr(e,t)}collect(e){let t=this.booleans[this.booleans.length-1],n=e.fill;if(!n||!n.verbs.length)return;let r=this.relative(t.base);r||this.missing.add("boolean:projective"),t.members.push({kind:"path",path:r?Js(n,r):n,op:t.members.length?gi[t.op]:"union"})}cut(){let e=this.shapes.filter(n=>n.members||n.fill&&n.fill.verbs.length);if(this.resetSurface(),!e.length)return;let t=[];e.forEach((n,r)=>{let s=r>0&&r===e.length-1?"cut":"union";if(!n.members){t.push({kind:"path",path:n.fill,op:s});return}r>0&&this.missing.add("cut:compound"),n.members.forEach((i,a)=>t.push({...i,op:a===0?s:i.op}))}),this.shapes.push({fill:null,stroke:null,interior:null,bounds:Tr(t),members:t})}masks=[];get inVectorMask(){let e=this.masks[this.masks.length-1];return!!e&&e.open&&e.vector}beginMask(e){let t=e?.mode??"alpha",n=t==="luminance",r=e?.inverted?n?"invertLuminance":"invertAlpha":n?"luminance":"alpha",s=this.doc.group(this.cur,{mask:r}),i=e?.apply?new Set(Array.isArray(e.apply)?e.apply:[e.apply]):null,a=i?this.doc.group(this.cur):null;this.stack.push(s,this.doc.group(s)),this.masks.push({vector:t==="vector",open:!0,apply:i,after:a}),this.resetSurface()}applyMask(){let e=this.masks[this.masks.length-1];e?.open&&(e.open=!1,this.stack.pop(),this.resetSurface())}endMask(){let e=this.masks.pop();e&&(e.open&&this.stack.pop(),this.stack.pop(),this.resetSurface())}clips=[];clipGeom(e){let t=[];for(let n of e.ops()){if(n.kind==="cut"){t.length>1&&(t[t.length-1].op="cut");continue}let r=Sr(n)?.fill;r&&r.verbs.length&&t.push({kind:"path",path:r,op:"union"})}return t.length?t.some(n=>n.op==="cut")?{members:t}:{path:pt(t.map(n=>n.path))}:null}beginClip(e){let t=this.clipGeom(e);if(!t){this.clips.push({pushed:0,geom:null});return}let n=this.clipTo(this.cur,t);"members"in t?this.stack.push(n,this.doc.group(n)):this.stack.push(n),this.clips.push({pushed:"members"in t?2:1,geom:t})}endClip(){let e=this.clips.pop()?.pushed??0;for(let t=0;t<e;t++)this.stack.pop()}cameras=[];beginCamera(e,t,n,r){let s=this.doc.group(this.cur,{clip:{x:e.x-e.width/2,y:e.y-e.height/2,w:e.width,h:e.height,r:0}}),i=-r*Math.PI/180,a=Math.cos(i)*n,o=Math.sin(i)*n,l=-t.x,c=t.y,u=this.doc.group(s,{transform:[a,o,-o,a,e.x+a*l-o*c,e.y+o*l+a*c]});this.stack.push(s,u),this.cameras.push(2)}endCamera(){let e=this.cameras.pop()??0;for(let t=0;t<e;t++)this.stack.pop()}beginEffects(e,t,n,r){if(t!=="backdrop")return;for(let i of e)i?.type==="shader"&&this.checkShader("effect",i);let s=this.clips[this.clips.length-1]?.geom;if(!s){let[i,a,o,l]=this.viewportBox();s={path:new rt().moveTo(i,a).lineTo(i+o,a).lineTo(i+o,a+l).lineTo(i,a+l).close().build()}}this.leaf(this.cur,s,{effects:e,effectBox:[-n/2,-r/2,n,r],effectTime:this.elapsed()})}endEffects(){}checkShader(e,t){let n=this.currentNodeStack[this.currentNodeStack.length-1];for(let r of xl(e,t))this.shaderIssues.push(n===void 0?r:{...r,nodeId:n})}rasterize(){return this.missing.add("rasterize"),null}},su=1379091505;function yt(e){if(e===void 0)return{x:0,y:0,z:0};if(typeof e=="number")return{x:e,y:e,z:e};if(Array.isArray(e))return{x:e[0]??0,y:e[1]??0,z:e[2]??0};let t=e;return{x:t.x??0,y:t.y??0,z:t.z??0}}var iu={XYZ:0,YXZ:1,ZXY:2,ZYX:3,YZX:4,XZY:5},au={none:0,linear:1,reinhard:2,cineon:3,aces:4,agx:5,neutral:6},Be={box:0,sphere:1,plane:2,cylinder:3,cone:4,torus:5,torusKnot:6,circle:7,ring:8,buffer:9,capsule:10,polyhedron:11,lathe:12,tube:13,edges:14,wireframe:15},ou={tetrahedron:0,octahedron:1,icosahedron:2,dodecahedron:3},cu={basic:0,standard:1,physical:2,lambert:3,phong:4,normal:5,points:6,lineBasic:7,lineDashed:8,sprite:9,shadow:10,toon:11,matcap:12,depth:13,shader:14},lu={ambient:0,hemisphere:1,directional:2,point:3,spot:4,area:5},uu={front:0,back:1,both:2},fu={normal:0,additive:1,subtractive:2,multiply:3,none:4},du=["map","gradientMap","alphaMap","aoMap","normalMap","roughnessMap","metalnessMap","emissionMap","envMap","lightMap","displacementMap"],hu=class{byKey=new Map;next=1;pending=[];all=new Map;id(e,t){let n=Gi(e),r="src"in n?n.src:n,s=this.byKey.get(r);s||this.byKey.set(r,s=new Map);let i=s.get(t);if(i===void 0){i=this.next++,s.set(t,i);let a={id:i,srgb:t,texture:n};this.pending.push(a),this.all.set(i,a)}return i}},xa=class{buf=new ArrayBuffer(65536);u32=new Uint32Array(this.buf);f32=new Float32Array(this.buf);n=0;room(e){if(this.n+e<=this.u32.length)return;let t=this.buf.byteLength*2;for(;t/4<this.n+e;)t*=2;let n=new ArrayBuffer(t);new Uint32Array(n).set(this.u32.subarray(0,this.n)),this.buf=n,this.u32=new Uint32Array(n),this.f32=new Float32Array(n)}u(e){this.room(1),this.u32[this.n++]=e>>>0}f(e){this.room(1),this.f32[this.n++]=e===void 0?NaN:e}v3(e){this.f(e.x),this.f(e.y),this.f(e.z)}floats(e){this.room(e.length);for(let t=0;t<e.length;t++)this.f32[this.n++]=e[t]}words(e){this.room(e.length);for(let t=0;t<e.length;t++)this.u32[this.n++]=e[t]>>>0}color(e){if(e===void 0){this.u(0),this.f(0),this.f(0),this.f(0),this.f(0);return}let[t,n,r,s]=typeof e=="string"?Wi(e):e;this.u(1),this.f(t),this.f(n),this.f(r),this.f(s??1)}segments(e){if(e===void 0){this.u(0),this.f(NaN),this.f(NaN),this.f(NaN);return}if(typeof e=="number"){this.u(1),this.f(e),this.f(NaN),this.f(NaN);return}this.u(2),this.f(e[0]),this.f(e[1]),this.f(e[2])}result(){return this.u32.slice(0,this.n)}key(e){return Array.prototype.join.call(this.u32.subarray(e,this.n),",")}copy(e){return this.u32.slice(e,this.n)}same(e,t){if(this.n-e!==t.length)return!1;let n=this.u32;for(let r=0;r<t.length;r++)if(n[e+r]!==t[r])return!1;return!0}set(e,t){this.u32[e]=t>>>0}append(e){this.room(e.n),this.u32.set(e.u32.subarray(0,e.n),this.n),this.n+=e.n}};function qe(e,t){if(!t){e.u(0);return}let n=0;if(t.position!==void 0&&(n|=1),t.rotation!==void 0&&(n|=2),t.quaternion!==void 0&&(n|=4),t.scale!==void 0&&(n|=8),t.lookAt!==void 0&&(n|=16),t.visible===!1&&(n|=32),t.shadow!==void 0&&(n|=64),t.renderOrder!==void 0&&(n|=128),e.u(n),n&1&&e.v3(yt(t.position)),n&2&&(e.v3(yt(t.rotation)),e.u(iu[t.rotation.order??"XYZ"]??0)),n&4){let r=t.quaternion;e.f(r.x),e.f(r.y),e.f(r.z),e.f(r.w)}if(n&8&&e.v3(yt(t.scale)),n&16&&e.v3(yt(t.lookAt)),n&64){let r=t.shadow;e.u(r===!1?0:r===!0?1:r==="cast"?2:r==="receive"?3:4)}n&128&&e.f(t.renderOrder)}function Ir(e,t){let n=Math.floor(t.position.length/3),r=(t.normal?1:0)|(t.uv?2:0)|(t.color?4:0)|(t.index?8:0)|(t.computeNormals?16:0);e.u(Be.buffer),e.u(r),e.u(n),e.u(t.index?.length??0),e.floats(t.position),t.normal&&e.floats(t.normal),t.uv&&e.floats(t.uv),t.color&&e.floats(t.color),t.index&&e.words(t.index)}function _n(e,t,n){switch(t.type){case"box":if((t.cornerRadius??0)>0){let[r,s,i]=Hs(t.segments,[1,1,1]);Ir(e,Zo({width:t.width??1,height:t.height??1,depth:t.depth??1,radius:t.cornerRadius,segments:[r,s,i]}));return}e.u(Be.box),e.f(t.width),e.f(t.height),e.f(t.depth),e.segments(t.segments);return;case"sphere":e.u(Be.sphere),e.f(t.radius),e.segments(t.segments),e.f(t.startAngle),e.f(t.sweep),e.f(t.startLatitude),e.f(t.latitudeSweep);return;case"plane":e.u(Be.plane),e.f(t.width),e.f(t.height),e.segments(t.segments);return;case"cylinder":{let[r,s]=Jo(t.radius);e.u(Be.cylinder),e.f(r),e.f(s),e.f(t.height),e.segments(t.segments),e.u(t.capped===!1?0:1),e.f(t.startAngle),e.f(t.sweep);return}case"cone":e.u(Be.cone),e.f(t.radius),e.f(t.height),e.segments(t.segments),e.u(t.capped===!1?0:1),e.f(t.startAngle),e.f(t.sweep);return;case"torus":e.u(Be.torus),e.f(t.radius),e.f(t.thickness),e.segments(t.segments),e.f(t.startAngle),e.f(t.sweep);return;case"torusKnot":e.u(Be.torusKnot),e.f(t.radius),e.f(t.thickness),e.segments(t.segments),e.f(t.windings?.[0]),e.f(t.windings?.[1]);return;case"circle":e.u(Be.circle),e.f(t.radius),e.segments(t.segments),e.f(t.startAngle),e.f(t.sweep);return;case"ring":e.u(Be.ring),e.f(t.radius),e.f(t.innerRadius),e.segments(t.segments),e.f(t.startAngle),e.f(t.sweep);return;case"buffer":Ir(e,t);return;case"parametric":Ir(e,Xo(t));return;case"capsule":e.u(Be.capsule),e.f(t.radius),e.f(t.height),e.segments(t.segments);return;case"polyhedron":e.u(Be.polyhedron),e.u(ou[t.shape??"icosahedron"]??2),e.f(t.radius),e.f(t.segments===void 0?0:Hs(t.segments,[1])[0]);return;case"lathe":e.u(Be.lathe),e.u(t.points.length);for(let r of t.points){let s=yt(r);e.f(s.x),e.f(s.y)}e.segments(t.segments),e.f(t.startAngle),e.f(t.sweep);return;case"tube":e.u(Be.tube),e.u(t.points.length);for(let r of t.points)e.v3(yt(r));e.u(t.closed?1:0),e.f(t.radius),e.segments(t.segments);return;case"edges":e.u(Be.edges),e.f(t.thresholdAngle),_n(e,t.source,n);return;case"wireframe":e.u(Be.wireframe),_n(e,t.source,n);return;default:n.unsupported.add(`geometry:${t.type}`),e.u(255)}}function ka(e){switch(e.type){case"buffer":case"parametric":return"slot";case"box":return(e.cornerRadius??0)>0?"rounded":"fixed";case"edges":case"wireframe":return ka(e.source)==="fixed"?"fixed":"slot";default:return"fixed"}}function Ma(e){let t=e,n=e.type;for(let r of Object.keys(t).sort()){let s=t[r];r==="type"||r==="revision"||r==="staticData"||s===void 0||typeof s=="function"||(r==="source"?n+=`|source=${Ma(s)}`:ArrayBuffer.isView(s)||Array.isArray(s)&&s.length>3?n+=`|${r}#${s.length}`:n+=`|${r}=${typeof s=="object"?JSON.stringify(s):String(s)}`)}return n}function pu(e){return e.type!=="buffer"?[]:[e.position,e.normal,e.uv,e.color,e.index,e.computeNormals]}var _u=class{next=1;byKey=new Map;slots=new Map;live=new Set;nth=new Map;defs=new xa;count=0;begin(){this.live.clear(),this.nth.clear(),this.defs.n=0,this.count=0}end(e){e.u(this.count),e.append(this.defs);for(let[t,n]of this.byKey)this.live.has(n)||this.byKey.delete(t);for(let[t,n]of this.slots)this.live.has(n.id)||this.slots.delete(t)}ref(e,t,n,r){let s=this.defs,i=ka(e);if(i!=="slot"){let _;if(i==="rounded"){let L=e;_=`rounded|${L.width}|${L.height}|${L.depth}|${L.cornerRadius}|${JSON.stringify(L.segments)}`;let V=this.byKey.get(_);if(V!==void 0)return this.use(V)}let w=s.n;s.u(0),_n(s,e,r),_??=s.key(w+1);let A=this.byKey.get(_);if(A!==void 0)return s.n=w,this.use(A);let B=this.add(w);return this.byKey.set(_,B),B}let a=`${t}|${n}|${Ma(e)}`,o=this.nth.get(a)??0;this.nth.set(a,o+1);let l=`${a}|${o}`,c=this.slots.get(l),u=e.revision,f=pu(e);if(c&&c.revision===u){if(e.type==="parametric"&&u!==void 0)return this.use(c.id);if(e.type==="buffer"&&(u!==void 0||e.staticData===!0)&&f.every((_,w)=>_===c.arrays[w]))return this.use(c.id)}let d=s.n;if(s.u(0),_n(s,e,r),c&&s.same(d+1,c.words))return s.n=d,c.revision=u,c.arrays=f,this.use(c.id);let p=this.add(d);return this.slots.set(l,{id:p,revision:u,arrays:f,words:s.copy(d+1)}),p}use(e){return this.live.add(e),e}add(e){let t=this.next++;return this.defs.set(e,t),this.count++,this.use(t)}},vi={clamp:0,repeat:1,mirror:2};function Rr(e,t){if(e===void 0)return[t,t];if(Array.isArray(e))return[e[0]??t,e[1]??t];let n=e;return[n.x??t,n.y??t]}function xi(e,t,n,r){if(t===void 0||!n){t!==void 0&&r.unsupported.add("texture:map"),e.u(0),e.u(0),e.f(1),e.f(0),e.f(0),e.f(0),e.f(1),e.f(0),e.u(0);return}let s=Gi(t),i=s.colorSpace!=="linear";e.u(1),e.u(n.id(t,i));let[a,o]=Rr(s.offset,0),[l,c]=Rr(s.repeat,1),[u,f]=Rr(s.center,0),d=(s.rotation??0)*Math.PI/180,p=Math.cos(d),_=Math.sin(d);e.f(l*p),e.f(l*_),e.f(-l*(p*u+_*f)+u+a),e.f(-c*_),e.f(c*p),e.f(-c*(-_*u+p*f)+f+o);let w=s.flipY??!("data"in s);e.u((vi[s.wrapS??"clamp"]??0)|(vi[s.wrapT??"clamp"]??0)<<2|(w?16:0)|(s.magFilter==="nearest"?32:0)|(s.minFilter==="nearest"?64:0))}function nn(e,t,n,r){let s=t;e.u(cu[t.type]??1),["basic","standard","physical","lambert","phong","normal","lineBasic","lineDashed","sprite","shadow","points","toon","depth"].includes(t.type)||n.unsupported.add(`material:${t.type}`);for(let a of du)a!=="map"&&a!=="gradientMap"&&s[a]!==void 0&&n.unsupported.add(`texture:${a}`);s.gradientMap!==void 0&&t.type!=="toon"&&n.unsupported.add("texture:gradientMap");for(let a of["sheen","iridescence","anisotropy","dispersion"])typeof s[a]=="number"&&s[a]>0&&n.unsupported.add(`physical:${a}`);e.color(s.color),e.f(s.opacity),e.f(s.roughness),e.f(s.metalness),e.color(s.emission),e.f(s.emissionStrength),e.f(s.envMapIntensity);let i=0;s.transparent===!0&&(i|=1),s.wireframe===!0&&(i|=4),s.vertexColors===!0&&(i|=8),s.shading==="flat"&&(i|=16),s.toneMapped===!1&&(i|=32),s.visible===!1&&(i|=64),s.depthTest===!1&&(i|=128),s.depthWrite!==void 0&&(i|=256|(s.depthWrite?512:0)),s.sizeAttenuation===!1&&(i|=1024),e.u(i),e.u(uu[s.faces??"front"]??0),e.u(fu[s.blend??"normal"]??0),e.f(s.alphaTest),e.f(s.size),e.color(s.specular),e.f(s.shininess),xi(e,s.map,r,n),e.f(s.clearcoat),e.f(s.clearcoatRoughness),e.f(s.transmission),e.f(s.thickness),e.f(s.ior),e.f(s.attenuationDistance),e.color(s.attenuationColor),e.f(s.dashSize),e.f(s.gapSize),e.f(s.scale),xi(e,t.type==="toon"?s.gradientMap:void 0,r,n)}function mu(e,t,n){let r=t;e.u(lu[t.type]??0),e.color(r.color),e.f(t.intensity),e.color(r.sky),e.color(r.ground),e.f(r.distance),e.f(r.decay),e.f(r.angle),e.f(r.penumbra);let s=r.target;e.u(s===void 0?0:1),e.v3(yt(s));let i=r.shadow,a=i===void 0?null:ac(i);e.u(a?1:0),e.f(a?.softness),e.f(a?.extent),e.f(r.width),e.f(r.height),qe(e,n)}function gu(e,t){e.u(t.type==="orthographic"?1:0);let n=rc(t);qe(e,{...t,position:n.position,lookAt:n.lookAt}),e.f(t.type==="perspective"?t.fov:void 0),e.f(t.zoom),e.f(t.type==="orthographic"?t.frustumHeight:void 0),e.f(t.near),e.f(t.far),e.f(t.distance)}function bu(e,t={unsupported:new Set},n,r){let s=new xa;r?.begin();let i=[""],a=(d,p)=>{if(!r)return _n(s,d,t);s.u(16),s.u(r.ref(d,i[i.length-1],p,t))};s.u(su),s.u(3);let o=e.toneSettings();s.u(au[o?.mapping??"aces"]??4),s.f(o?.exposure);let l=e.shadowSettings();s.u(l?.enabled===!0?1:0),s.u(l?.quality==="low"?0:l?.quality==="high"?2:1);let c=e.fogDescriptor();s.u(c?c.density!==void 0?2:1:0),s.color(c?.color),s.f(c?.near),s.f(c?.far),s.f(c?.density);let u=e.environmentDescriptor();s.u(u?.preset==="studio"?1:0),s.f(u?.intensity),s.u(u?.background?1:0),s.f(u?.blur),e.postEffects().length>0&&t.unsupported.add("post");let f=e.ops();s.u(f.length);for(let d of f)switch(d.kind){case"push":{let p=d.transform?.key;i.push(p===void 0?`${i[i.length-1]}/${i.length}`:String(p)),s.u(1),qe(s,d.transform);break}case"pop":i.length>1&&i.pop(),s.u(2);break;case"light":s.u(3),mu(s,d.light,d.transform);break;case"camera":s.u(4),gu(s,d.camera);break;case"mesh":{s.u(5),a(d.geometry,d.kind);let p=Array.isArray(d.material)?d.material:[d.material];s.u(Array.isArray(d.material)?p.length:1);for(let _ of p)nn(s,_,t,n);qe(s,d.transform);break}case"instances":{s.u(6),a(d.geometry,d.kind),nn(s,d.material,t,n),qe(s,d.transform),s.u(d.instances.length);for(let _ of d.instances)qe(s,_);let p=d.colors??[];s.u(p.length);for(let _ of p){let[w,A,B,L]=typeof _=="string"?Wi(_):_;s.f(w),s.f(A),s.f(B),s.f(L??1)}break}case"points":s.u(7),a(d.geometry,d.kind),nn(s,d.material,t,n),qe(s,d.transform);break;case"line":s.u(8),a(d.geometry,d.kind),nn(s,d.material,t,n),s.u(d.mode==="segments"?1:d.mode==="loop"?2:0),qe(s,d.transform);break;case"sprite":s.u(9),nn(s,d.material,t,n),qe(s,d.transform);break;case"model":t.unsupported.add("model"),s.u(10),qe(s,d.transform);break}return r?r.end(s):s.u(0),s.result()}var Se={CREATE:1,DESTROY:2,CHILDREN:3,TRANSFORM:4,SIZE:5,RADII:6,FILL:7,STROKE:8,SHADOWS:9,OPACITY:10,BLEND:11,CLIP:12,FILTER:13,PATH:14,MEMBERS:15,MASK:16,TEXT:17,EFFECTS:18,TRANSFORM3:19,DEF_PAINT:20,DEF_PATH:21,DEF_DASH:22,FREE_PATH:24,ROOT:30,VIEWPORT:31},mt=4294967295,wu=class{sink;memory;u32;f32;pos=0;cap=0;written=0;constructor(e,t){this.sink=e,this.memory=t,this.refresh(0)}refresh(e){let t=this.sink.delta_buffer(e);this.cap=this.sink.delta_capacity(),this.u32=new Uint32Array(this.memory.buffer,t,this.cap),this.f32=new Float32Array(this.memory.buffer,t,this.cap)}begin(e){this.u32.buffer!==this.memory.buffer&&this.refresh(0),this.pos+e>this.cap&&(this.flush(),e>this.cap&&this.refresh(e))}u(e){this.u32[this.pos++]=e>>>0}f(e){this.f32[this.pos++]=e}flush(){this.pos>0&&(this.written+=this.pos,this.sink.apply(this.pos),this.pos=0),this.u32.buffer!==this.memory.buffer&&this.refresh(0)}takeCount(){let e=this.written;return this.written=0,e}},yu=oe({MAX_PARAMS:()=>64,definePort:()=>ce,fieldFloats:()=>Sa,layout:()=>Ta}),ki={f32:1,vec2f:2,vec3f:3,vec4f:4},Sa=e=>typeof e=="string"?ki[e]:e.array*ki[e.of],Ea={number:"f32",boolean:"f32",enum:"f32",color:"vec4f",vec2:"vec2f",axis:"vec2f"};function vu(e,t){switch(e.kind){case"number":return t;case"boolean":return t?1:0;case"enum":return Math.max(0,e.options.indexOf(t));case"color":return Mt(t);case"vec2":{let n=t;return[n.x,n.y]}case"axis":{let n=kt(t);return[n.x,n.y]}default:throw new Error(`effect param "${e.name}" (${e.kind}) has no default encoding; give it a value()`)}}function Aa(e,t){let n=Yo(e)?.params.find(r=>r.name===t);if(!n)throw new Error(`effect "${e}": "${t}" is not a parameter of its core spec`);if(!Ea[n.kind])throw new Error(`effect "${e}": "${t}" (${n.kind}) has no default encoding`);return n}function Ta(e){let t=0,n=Object.entries(e.params).map(([r,s])=>{let i=s==="param"?Ea[Aa(e.type,r).kind]:s.type,a=Sa(i),o={name:r,type:i,offset:t,floats:a};return t+=a,o});if(t>64)throw new Error(`effect "${e.type}" lays out ${t} params; a pass takes 64`);return n}function ce(e){let t=Ta(e),n=t.reduce((s,i)=>s+i.floats,0),r=t.map(s=>{let i=e.params[s.name];if(i!=="param")return i.value;let a=Aa(e.type,s.name);return o=>vu(a,o[s.name])});return{type:e.type,surface:e.surface,backdropOnly:e.backdropOnly,spec:e,cases:e.cases,pack(s){let i=e.prepare?e.prepare(s):{};if(i===null)return null;let a=new Array(n).fill(0);return t.forEach((o,l)=>{let c=r[l](s,i),u=typeof c=="number"?1:c.length;if(u>o.floats)throw new Error(`effect "${e.type}": "${o.name}" is ${u} floats, laid out as ${o.floats}`);if(typeof c=="number")a[o.offset]=c;else for(let f=0;f<u;f++)a[o.offset+f]=c[f]}),{params:a,...e.extras?e.extras(s,i):{}}}}}var xu=oe({default:()=>ku}),ku=ce({type:"alpha",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},value:e=>[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,Math.max(0,Math.min(1,e.amount)),0]}},cases:()=>[]}),Mu=oe({default:()=>Pu}),Su="Inter",Eu=e=>typeof document<"u"&&document.fonts.check(`12px "${e}"`),Au=e=>Math.max(4,Math.min(64,Math.round(Math.max(8,e*2)))),st=1;function Tu(e,t,n){let r=[...e].slice(0,256),s=n*st,i=new OffscreenCanvas(s*r.length,s),a=i.getContext("2d",{willReadFrequently:!0});a.fillStyle="#000",a.fillRect(0,0,i.width,i.height),a.fillStyle="#fff",a.font=`${n*.8*st}px "${t}"`,a.textBaseline="alphabetic",a.textAlign="left",a.fontKerning="none",r.forEach((u,f)=>{let d=a.measureText(u).width;a.fillText(u,f*s+(s-d)/2,s*.78)});let o=a.getImageData(0,0,i.width,i.height).data,l=n*r.length,c=new Uint8ClampedArray(l*n*4);for(let u=0;u<n;u++)for(let f=0;f<l;f++){let d=0;for(let w=0;w<st;w++)for(let A=0;A<st;A++)d+=o[((u*st+w)*i.width+f*st+A)*4];let p=d/(st*st),_=(u*l+f)*4;c[_]=c[_+1]=c[_+2]=p,c[_+3]=255}return{glyphs:r.length,pixels:c,width:l}}var Pu=ce({type:"ascii",surface:"shader",params:{size:"param",glyphs:{type:"f32",uses:["charset","fontFamily"],value:(e,t)=>t.atlas.glyphs},cell:{type:"f32",value:(e,t)=>t.cell},ink:"param",background:"param",colored:"param"},prepare(e){let t=nc(e.charset);if(t.length===0)return null;let n=Eu(e.fontFamily)?e.fontFamily:Su,r=Au(e.size);return{family:n,cell:r,charset:t,atlas:Tu(t,n,r)}},extras:(e,t)=>({aux:{key:`ascii|${t.family}|${t.cell}|${t.charset}`,width:t.atlas.width,height:t.cell,pixels:t.atlas.pixels}}),cases:()=>[E.ascii().list[0],E.ascii({size:10,charset:"hex",fontFamily:"Fira Mono",ink:"#6f6",background:"#001",colored:!1}).list[0],E.ascii({size:14,colored:!0,background:"transparent",ink:"white"}).list[0],E.ascii({size:8,ink:"black",background:"white",charset:" .oO@"}).list[0]]}),Iu=oe({default:()=>Ou}),Ru={gameboy:["#0f380f","#306230","#8bac0f","#9bbc0f"],cga:["#000000","#55ffff","#ff55ff","#ffffff"],nes:["#000000","#fcfcfc","#bcbcbc","#7c7c7c","#0000fc","#0078f8","#3cbcfc","#a4e4fc","#b8f818","#00b800","#005800","#f83800","#e40058","#f878f8","#f8b800","#503000"]},Cu=e=>{let t=parseInt(e.slice(1),16);return[16,8,0].map(n=>Number(((t>>n&255)/255).toFixed(4)))},Ou=ce({type:"bitCrush",surface:"shader",params:{bits:"param",amount:"param",count:{type:"f32",uses:["palette"],value:(e,t)=>t.palette.length},palette:{type:{array:16,of:"vec3f"},value:(e,t)=>t.palette.flatMap(Cu)}},prepare(e){return!(e.amount>0)||e.palette==="none"&&e.bits>=8?null:{palette:e.palette==="none"?[]:Ru[e.palette]}},cases:()=>[E.bitCrush().list[0],E.bitCrush({palette:"gameboy"}).list[0],E.bitCrush({palette:"nes",amount:.7}).list[0],E.bitCrush({palette:"cga"}).list[0]]}),Du=oe({default:()=>Lu}),Lu=ce({type:"blockDisplace",surface:"shader",params:{amount:"param",size:"param",density:"param",seed:"param",axis:"param"},prepare(e){if(!(e.amount>0)||!(e.density>0))return null;let t=kt(e.axis);return t.x===0&&t.y===0?null:{}},extras(e){let t=kt(e.axis);return{reach:e.amount*Math.max(Math.abs(t.x),Math.abs(t.y))}},cases:()=>[E.blockDisplace().list[0],E.blockDisplace({amount:40,size:10,density:.6,seed:3}).list[0],E.blockDisplace({amount:30,size:24,axis:"y",seed:1}).list[0]]}),Fu=oe({default:()=>Bu}),Bu=ce({type:"bloom",surface:"filter",params:{scale:{type:"f32",uses:["threshold"],value:(e,t)=>t.scale},bias:{type:"f32",value:(e,t)=>-t.t*t.scale},intensity:"param"},uses:["radius"],prepare(e){if(e.radius<=0||e.intensity<=0)return null;let t=Math.max(0,Math.min(1,e.threshold));return{t,scale:t<1?1/(1-t):1,sigma:e.radius/2}},extras:(e,t)=>({blur:[t.sigma,t.sigma,0],reach:3*t.sigma}),cases:()=>[E.bloom().list[0],E.bloom({threshold:.4,radius:24,intensity:1.5}).list[0],E.bloom({threshold:0,radius:6,intensity:.6}).list[0]]}),$u=oe({default:()=>Uu}),Uu=ce({type:"blur",surface:"filter",params:{},uses:["radius"],prepare:e=>e.radius>0?{}:null,extras(e){let t=e.radius/2;return{blur:[t,t,0],reach:3*t}},cases:()=>[E.blur(8).list[0],E.blur(24).list[0],E.blur(2).list[0]]}),Nu=oe({default:()=>ju}),ju=ce({type:"bulge",surface:"shader",params:{strength:"param",center:"param"},prepare:e=>e.strength===0?null:{},extras(e){let t=2*Math.hypot(e.center.x-.5,e.center.y-.5)*360;if(e.strength<0){let n=e.strength*.8,r=1;for(;r<4&&r*(1+n*r*r)/(1+n)>-1;)r+=.01;t=Math.min((r-1+2*Math.hypot(e.center.x-.5,e.center.y-.5))*360,800)}return{reach:t}},cases:()=>[E.bulge(.6).list[0],E.bulge(-.7).list[0],E.bulge({strength:.9,center:{x:.3,y:.6}}).list[0]]}),Wu=oe({default:()=>Gu}),Vu=[1.4,-.2,-.2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],zu=[0,0,0,0,0,0,0,0,0,0,-.2,-.2,1.4,0,0,0,0,0,1,0],Gu=ce({type:"chromaticAberration",surface:"filter",params:{red:{type:{array:20,of:"f32"},value:()=>Vu},blue:{type:{array:20,of:"f32"},value:()=>zu},offset:{type:"vec2f",uses:["amount","angle"],value(e){let t=e.angle*Math.PI/180;return[Math.cos(t)*e.amount,Math.sin(t)*e.amount]}}},prepare:e=>e.amount<=0?null:{},extras:e=>({reach:e.amount}),cases:()=>[E.chromaticAberration().list[0],E.chromaticAberration({amount:8,angle:45}).list[0],E.chromaticAberration({amount:2.5,angle:200}).list[0]]}),Hu=oe({default:()=>Ju}),vt=.2126,at=.7152,nt=.0722;function Ku(e,t){let n=new Array(20).fill(0);for(let r=0;r<4;r++)for(let s=0;s<5;s++){let i=0;for(let a=0;a<4;a++)i+=e[r*5+a]*t[a*5+s];s===4&&(i+=e[r*5+4]),n[r*5+s]=i}return n}var rn=(e,t)=>[e,0,0,0,t,0,e,0,0,t,0,0,e,0,t,0,0,0,1,0],Mi=(e,t,n)=>[1,0,0,0,e,0,1,0,0,t,0,0,1,0,n,0,0,0,1,0];function Si(e){let t=1-e;return[e+t*vt,t*at,t*nt,0,0,t*vt,e+t*at,t*nt,0,0,t*vt,t*at,e+t*nt,0,0,0,0,0,1,0]}function qu(e){let t=e*Math.PI/180,n=Math.cos(t),r=Math.sin(t);return[vt+n*(1-vt)+r*-.2126,at+n*-.7152+r*-.7152,nt+n*-.0722+r*(1-nt),0,0,vt+n*-.2126+r*.143,at+n*(1-at)+r*.14,nt+n*-.0722+r*-.283,0,0,vt+n*-.2126+r*-.7874,at+n*-.7152+r*at,nt+n*(1-nt)+r*nt,0,0,0,0,0,1,0]}var Ju=ce({type:"colorAdjustment",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},uses:["brightness","contrast","saturation","hue","vibrance","temperature","tint","shadows","highlights"],value:(e,t)=>t.matrix}},prepare(e){let t=rn(1,0),n=!1,r=p=>{t=Ku(p,t),n=!0},s=e.brightness??0;s!==0&&r(rn(1,s));let i=e.contrast??1;i!==1&&r(rn(i,.5*(1-i)));let a=e.saturation??1;a!==1&&r(Si(a));let o=((e.hue??0)%360+360)%360;o!==0&&r(qu(o));let l=e.vibrance??0;l!==0&&r(Si(1+l*.7));let c=e.temperature??0;c!==0&&r(Mi(c*.1,0,-c*.1));let u=e.tint??0;u!==0&&r(Mi(u*.05,-u*.1,u*.05));let f=e.shadows??0;f!==0&&r(rn(1-.2*f,.2*f));let d=e.highlights??0;return d!==0&&r(rn(1+.2*d,-.1*d)),n?{matrix:t}:null},cases:()=>[E.colorAdjustment({brightness:.1,contrast:1.3,saturation:1.4}).list[0],E.colorAdjustment({hue:120,vibrance:.5}).list[0],E.colorAdjustment({temperature:.6,tint:-.4,shadows:.5,highlights:-.5}).list[0],E.colorAdjustment({contrast:.6,saturation:0}).list[0]]}),Yu=oe({default:()=>Xu}),Xu=ce({type:"colorMatrix",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},value:e=>Array.from(e.matrix).slice(0,20)}},cases:()=>[]}),Zu=oe({default:()=>nf}),Hn=32;function Qu(e,t){if(e.length===0)return t;if(t<=e[0][0])return e[0][1];let n=e[e.length-1];if(t>=n[0])return n[1];for(let r=0;r<e.length-1;r++){let[s,i]=e[r],[a,o]=e[r+1];if(t>=s&&t<=a)return i+(o-i)*(a===s?0:(t-s)/(a-s))}return t}function ef(e){let t=[...e].sort((r,s)=>r[0]-s[0]),n=[];for(let r=0;r<=Hn;r++){let s=Qu(t,r/Hn);n.push(Number.isFinite(s)?Math.max(0,Math.min(1,s)):r/Hn)}return n}var tf={r:[1,0,0,0],g:[0,1,0,0],b:[0,0,1,0],a:[0,0,0,1]},nf=ce({type:"curves",surface:"shader",params:{mask:{type:"vec4f",uses:["channel"],value:e=>tf[e.channel??"rgb"]??[1,1,1,0]},curve:{type:{array:33,of:"f32"},uses:["points"],value:(e,t)=>t.values}},prepare(e){let t=ef(e.points??[]);return t.every((n,r)=>Math.abs(n-r/Hn)<1e-4)?null:{values:t}},cases:()=>[E.curves({points:[[0,0],[.25,.15],[.75,.88],[1,1]]}).list[0],E.curves({points:[[0,.2],[.5,.7],[1,1]],channel:"r"}).list[0],E.curves({points:[[0,0],[.6,.3],[1,.8]],channel:"a"}).list[0]]}),rf=oe({default:()=>sf}),sf=ce({type:"directionalBlur",surface:"filter",params:{sigma:{type:"f32",uses:["radius"],value:(e,t)=>t.sigma},axis:{type:"vec2f",uses:["angle"],value:(e,t)=>[Math.cos(t.rad),Math.sin(t.rad)]}},prepare:e=>e.radius<=0?null:{sigma:e.radius/2,rad:e.angle*Math.PI/180},extras:(e,t)=>({blur:[t.sigma,0,t.rad],reach:3*t.sigma}),cases:()=>[E.directionalBlur(20).list[0],E.directionalBlur({radius:30,angle:45}).list[0],E.directionalBlur({radius:12,angle:100}).list[0],E.directionalBlur({radius:120,angle:-20}).list[0]]}),af=oe({default:()=>uf}),of="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",cf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ut=64,Cr=null;function lf(){if(Cr)return Cr;let e=of.replace(/[^A-Za-z0-9+/]/g,""),t=new Uint8Array(e.length*3>>2),n=0,r=0,s=0;for(let a=0;a<e.length;a++)n=n<<6|cf.indexOf(e[a]),r+=6,r>=8&&(r-=8,t[s++]=n>>r&255);let i=new Uint8ClampedArray(Ut*Ut*4);for(let a=0;a<Ut*Ut;a++)i.fill(t[a],a*4,a*4+3),i[a*4+3]=255;return Cr=i}var uf=ce({type:"dither",surface:"shader",params:{levels:"param",scale:"param",monochrome:"param",noise:"param",matrix:{type:"f32",value:e=>e.matrix}},prepare:e=>e.levels>=256?null:{},extras:e=>({aux:e.noise==="blue"?{key:"dither-blue-noise",width:Ut,height:Ut,pixels:lf()}:void 0}),cases:()=>[E.dither().list[0],E.dither({levels:4,matrix:8,scale:2,monochrome:!0}).list[0],E.dither({noise:"blue",levels:3}).list[0],E.dither({matrix:2,levels:6,scale:3}).list[0]]}),ff=oe({default:()=>df}),df=ce({type:"dropShadow",surface:"shader",params:{offset:{type:"vec2f",uses:["offsetX","offsetY"],value:(e,t)=>[t.ox,t.oy]},sigma:{type:"f32",uses:["blur"],value:(e,t)=>t.sigma},color:"param",spread:{type:"f32",value:(e,t)=>t.spread}},prepare(e){if(Mt(e.color)[3]<=0)return null;let t=e.offsetX,n=-e.offsetY,r=Math.max(0,e.blur)/2,s=Math.max(0,e.spread);return t===0&&n===0&&r===0&&s===0?null:{ox:t,oy:n,sigma:r,spread:s}},extras:(e,t)=>({reach:Math.hypot(t.ox,t.oy)+3*t.sigma+t.spread}),cases:()=>[E.dropShadow().list[0],E.dropShadow({offsetX:10,offsetY:10,blur:24,color:"#0008"}).list[0],E.dropShadow({offsetX:0,offsetY:0,blur:0,spread:6,color:"#f40"}).list[0],E.dropShadow({offsetX:-12,offsetY:-6,blur:40,spread:4,color:"#04f"}).list[0]]}),hf=oe({default:()=>gf}),pf=.2126,_f=.7152,mf=.0722,gf=ce({type:"duotone",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},uses:["amount","shadows","highlights"],value(e){let t=Math.max(0,Math.min(1,e.amount)),n=Mt(e.shadows),r=Mt(e.highlights),s=i=>{let a=(r[i]-n[i])*t,o=[a*pf,a*_f,a*mf,0,n[i]*t];return o[i]+=1-t,o};return[...s(0),...s(1),...s(2),0,0,0,1,0]}}},prepare:e=>e.amount<=0?null:{},cases:()=>[E.duotone().list[0],E.duotone({shadows:"#1a0b3d",highlights:"#ffcc66"}).list[0],E.duotone({amount:.5,shadows:"#003344",highlights:"#ff6699"}).list[0]]}),bf=oe({default:()=>wf}),wf=ce({type:"edges",surface:"shader",params:{strength:"param",kernel:"param",colored:"param"},prepare:e=>e.strength>0?{}:null,extras:()=>({reach:1}),cases:()=>[E.edges().list[0],E.edges({strength:2,kernel:"prewitt",colored:!0}).list[0],E.edges({strength:1.5,kernel:"laplacian"}).list[0]]}),yf=oe({default:()=>vf}),vf=ce({type:"exposure",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},value:e=>[e.amount,0,0,0,0,0,e.amount,0,0,0,0,0,e.amount,0,0,0,0,0,1,0]}},cases:()=>[]}),xf=oe({default:()=>Pf}),Ei=e=>Math.min(1,Math.max(0,e)),kf=.35,Mf=1,Sf=.1,Ef=.06,Af=.7,Tf=.3,Ai=.25,Pf=ce({type:"glass",surface:"shader",backdropOnly:!0,params:{depth:"param",refraction:{type:"f32",value:e=>Math.max(0,e.refraction/100)},spread:{type:"f32",uses:["dispersion"],value:e=>Ei(e.dispersion/100)*kf},light:{type:"vec2f",uses:["lightAngle"],value(e){let t=e.lightAngle*Math.PI/180;return[Math.sin(t),-Math.cos(t)]}},rim:{type:"f32",uses:["lightIntensity"],value:(e,t)=>t.light*Mf},shade_near:{type:"f32",uses:["splay"],value:(e,t)=>t.light*Sf*(1-Ai*t.splay)},shade_far:{type:"f32",value:(e,t)=>t.light*Ef*(1-Ai*t.splay)},shade_reach:{type:"f32",value:(e,t)=>Af+Tf*t.splay},frost:{type:"f32",value:(e,t)=>t.frost}},prepare(e){return e.depth>0?{light:Math.max(0,e.lightIntensity/100),splay:Ei(e.splay/100),frost:Math.max(0,e.frost)*.5}:null},extras:(e,t)=>({reach:3*t.frost+2,blur:t.frost>0?[t.frost,t.frost,0]:void 0,field:!0}),cases:()=>[E.glass().list[0],E.glass({dispersion:0,frost:0,depth:30}).list[0]]}),If=oe({default:()=>Cf}),Rf=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Cf=ce({type:"glow",surface:"shader",params:{channel:"param",threshold:"param",spread:{type:"f32",value:e=>Math.max(0,e.spread)},intensity:"param",tint:"param",original:"param",blend:{type:"f32",value:e=>Math.max(0,Rf.indexOf(e.blend))},count:{type:"f32",value:(e,t)=>t.colors.length},cycles:"param",phase:{type:"f32",value:e=>e.phase/360},mirror:{type:"f32",uses:["loopStyle"],value:e=>e.loopStyle==="mirror"?1:0},stops:{type:{array:8,of:"f32"},value(e,t){let n=[],r=0;for(let s=0;s<t.colors.length;s++)r=Math.max(r,Math.min(1,e.stops[s]??s/Math.max(1,t.colors.length-1))),n.push(r);return n}},colors:{type:{array:8,of:"vec4f"},uses:["color"],value:(e,t)=>t.colors.flatMap(n=>Mt(n))}},uses:["radius","axis"],prepare(e){return e.radius<=0&&e.spread<=0||e.intensity<=0?null:{colors:(e.tint==="solid"?[e.color]:e.colors).slice(0,8)}},extras(e){let t=kt(e.axis),n=Math.max(0,e.radius)/2;return{blur:[n*t.x,n*t.y,0],reach:3*n+Math.max(0,e.spread)}},cases:()=>[E.glow().list[0],E.glow({radius:12,threshold:.3,intensity:1.5,original:"front"}).list[0],E.glow({channel:"alpha",radius:20,spread:4,tint:"solid",color:"#4cf"}).list[0],E.glow({radius:30,tint:"ramp",colors:["#ff3","#f0f","#0ff"],stops:[0,.5,1],blend:"lighten"}).list[0]]}),Of=oe({default:()=>Df}),Df=ce({type:"grain",surface:"shader",params:{amount:"param",size:"param",seed:"param",colored:"param",animated:"param"},prepare:e=>e.amount>0?{}:null,cases:()=>[E.grain().list[0],E.grain({amount:.5,size:3,seed:7,colored:!0}).list[0],E.grain({amount:.15,size:2}).list[0]]}),Lf=oe({default:()=>Ff}),Or=.2126,Dr=.7152,Lr=.0722,Ff=ce({type:"grayscale",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},uses:["amount"],value(e){let t=Math.max(0,Math.min(1,e.amount));return[1-t+t*Or,t*Dr,t*Lr,0,0,t*Or,1-t+t*Dr,t*Lr,0,0,t*Or,t*Dr,1-t+t*Lr,0,0,0,0,0,1,0]}}},cases:()=>[E.grayscale(1).list[0],E.grayscale(.5).list[0]]}),Bf=oe({default:()=>$f}),$f=ce({type:"halftone",surface:"shader",params:{size:"param",angle:{type:"f32",value:e=>e.angle*Math.PI/180},shape:"param",separation:"param"},extras:e=>({reach:e.size}),cases:()=>[E.halftone().list[0],E.halftone({size:10,angle:20,shape:"line",separation:"rgb"}).list[0],E.halftone({size:12,shape:"cross",separation:"cmyk"}).list[0]]}),Uf=oe({default:()=>Wf}),Ft=.2126,Bt=.7152,$t=.0722,Nf=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];function jf(e){switch(e){case"red":return[-1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];case"green":return[1,0,0,0,0,0,-1,0,0,1,0,0,1,0,0,0,0,0,1,0];case"blue":return[1,0,0,0,0,0,1,0,0,0,0,0,-1,0,1,0,0,0,1,0];case"alpha":return[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,-1,1];case"hue":return[2*Ft-1,2*Bt,2*$t,0,0,2*Ft,2*Bt-1,2*$t,0,0,2*Ft,2*Bt,2*$t-1,0,0,0,0,0,1,0];case"luminance":return[1-2*Ft,-2*Bt,-2*$t,0,1,-2*Ft,1-2*Bt,-2*$t,0,1,-2*Ft,-2*Bt,1-2*$t,0,1,0,0,0,1,0];default:return[-1,0,0,0,1,0,-1,0,0,1,0,0,-1,0,1,0,0,0,1,0]}}var Wf=ce({type:"invert",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},uses:["channel","strength"],value:(e,t)=>t.matrix}},prepare(e){let t=Math.max(0,Math.min(1,e.strength));if(t===0)return null;let n=jf(e.channel);return{matrix:Nf.map((r,s)=>r+(n[s]-r)*t)}},extras:(e,t)=>t.matrix[19]>0?{reach:4096}:{},cases:()=>[E.invert().list[0],E.invert({channel:"hue",strength:.7}).list[0],E.invert({channel:"luminance"}).list[0],E.invert({channel:"alpha",strength:.5}).list[0]]}),Vf=oe({default:()=>zf}),zf=ce({type:"kaleidoscope",surface:"shader",params:{wedge:{type:"f32",uses:["segments"],value:(e,t)=>2*Math.PI/t.segments},angle:{type:"f32",value:e=>e.angle*Math.PI/180},offset:"param",amount:{type:"f32",value:e=>Math.max(0,Math.min(1,e.amount))},center:"param"},prepare(e){let t=Math.round(e.segments);return t<2||e.amount<=0?null:{segments:t}},extras:e=>({reach:Math.min((Math.SQRT2-1+Math.abs(e.offset)+2*Math.hypot(e.center.x-.5,e.center.y-.5))*360,800)}),cases:()=>[E.kaleidoscope().list[0],E.kaleidoscope({segments:8,angle:20,offset:.15}).list[0],E.kaleidoscope({segments:3,amount:.6,center:{x:.4,y:.55}}).list[0]]}),Gf=oe({default:()=>qf}),Ti=new WeakMap,Hf=0,Fr=e=>Number.isFinite(e)?Math.max(0,Math.min(255,Math.round(e*255))):0;function Kf(e,t){let n=Ti.get(e);if(n&&n.height===t)return n;let r=t*t,s=new Uint8ClampedArray(r*t*4);for(let a=0;a<t;a++)for(let o=0;o<t;o++)for(let l=0;l<t;l++){let c=((a*t+o)*t+l)*3,u=(o*r+a*t+l)*4;s[u+3]=255,!(c+2>=e.length)&&(s[u]=Fr(e[c]),s[u+1]=Fr(e[c+1]),s[u+2]=Fr(e[c+2]))}let i={key:`lut-${Hf++}`,width:r,height:t,pixels:s};return Ti.set(e,i),i}function Pi(e){let t=new Float32Array(e*e*e*3);for(let n=0;n<e;n++)for(let r=0;r<e;r++)for(let s=0;s<e;s++){let[i,a,o]=[s/(e-1),r/(e-1),n/(e-1)],l=((n*e+r)*e+s)*3;t[l]=.05+.95*Math.pow(i,.8),t[l+1]=.85*a+.1*o+.03,t[l+2]=1-Math.pow(1-o,1.4)*.9-.08*i}return t}var Br=null,qf=ce({type:"lut",surface:"shader",params:{size:"param",amount:"param"},uses:["table"],prepare:e=>e.amount<=0||!Number.isInteger(e.size)||e.size<2?null:{},extras:e=>({aux:Kf(e.table,e.size)}),cases:()=>(Br??=[Pi(17),Pi(33)],[E.lut({table:Br[1],size:33}).list[0],E.lut({table:Br[0],size:17,amount:.6}).list[0]])}),Jf=oe({default:()=>Yf}),Yf=ce({type:"magnify",surface:"shader",backdropOnly:!0,params:{scale:"param",center:"param"},prepare:e=>e.scale===1||e.scale<=0?null:{},extras:e=>({reach:e.scale<1?Math.min((1/e.scale-1)*360,800):0}),cases:()=>[E.magnify({scale:2}).list[0],E.magnify({scale:1.6,center:{x:.3,y:.7}}).list[0]]}),Xf=oe({default:()=>Zf}),Zf=ce({type:"oilPaint",surface:"shader",params:{radius:"param"},prepare:e=>e.radius>0?{}:null,extras:e=>({reach:e.radius}),cases:()=>[E.oilPaint().list[0],E.oilPaint({radius:5}).list[0],E.oilPaint({radius:1.5}).list[0]]}),Qf=oe({default:()=>td}),ed={outside:0,inside:1,center:2},td=ce({type:"outline",surface:"shader",params:{width:"param",position:{type:"f32",value:(e,t)=>t.position},color:"param"},prepare(e){return!(e.width>0)||Mt(e.color)[3]<=0?null:{position:ed[e.position]??0}},extras:(e,t)=>({reach:t.position===1?0:t.position===2?e.width/2:e.width}),cases:()=>[E.outline().list[0],E.outline({width:8,color:"#f80",position:"inside"}).list[0],E.outline({width:6,color:"#0cf",position:"center"}).list[0]]}),nd=oe({default:()=>rd}),rd=ce({type:"pixelate",surface:"filter",params:{blocks:"param",sharpColors:"param"},extras:e=>({reach:e.sharpColors?0:100}),cases:()=>[E.pixelate(40).list[0],E.pixelate({blocks:{x:40,y:24},sharpColors:!1}).list[0],E.pixelate({blocks:{x:12.5,y:40/3}}).list[0]]}),sd=oe({default:()=>id}),id=ce({type:"posterize",surface:"shader",params:{levels:"param"},prepare:e=>e.levels<2?null:{},cases:()=>[E.posterize().list[0],E.posterize(2).list[0],E.posterize(7).list[0]]}),ad=oe({default:()=>od}),od=ce({type:"progressiveBlur",surface:"shader",params:{center:"param",direction:{type:"vec2f",uses:["angle"],value(e){let t=e.angle*Math.PI/180;return[Math.cos(t),Math.sin(t)]}},radius:"param",start_radius:{type:"f32",uses:["startRadius"],value:(e,t)=>t.start0},start:"param",end:"param",shape:"param",samples:{type:"f32",value:e=>Math.max(2,Math.min(32,Math.round(e.samples)))}},prepare(e){let t=e.startRadius??0;return e.radius<=0&&t<=0?null:{start0:t}},extras:(e,t)=>({reach:Math.max(e.radius,t.start0,0)}),cases:()=>[E.progressiveBlur().list[0],E.progressiveBlur({radius:30,angle:0,start:.3,end:.9,samples:28}).list[0],E.progressiveBlur({radius:28,startRadius:4,shape:"radial",center:{x:.4,y:.5}}).list[0]]}),cd=oe({default:()=>ld}),ld=ce({type:"radialBlur",surface:"shader",params:{amount:"param",style:"param",center:"param",samples:{type:"f32",value:e=>Math.round(Math.max(2,Math.min(32,e.samples)))}},prepare:e=>e.amount>0?{}:null,extras(e){let t=e.style==="spin"?Math.SQRT2-1:1/Math.max(1-e.amount/2,.25)-1;return{reach:Math.min((t+2*Math.hypot(e.center.x-.5,e.center.y-.5))*360,800)}},cases:()=>[E.radialBlur().list[0],E.radialBlur({amount:.8,style:"spin",samples:24}).list[0],E.radialBlur({amount:.3,center:{x:.3,y:.4},samples:8}).list[0]]}),ud=oe({default:()=>fd}),fd=ce({type:"rgbShift",surface:"shader",params:{red:"param",green:"param",blue:"param"},prepare(e){let{red:t,green:n,blue:r}=e;return!t.x&&!t.y&&!n.x&&!n.y&&!r.x&&!r.y?null:{}},extras:({red:e,green:t,blue:n})=>({reach:Math.max(Math.abs(e.x),Math.abs(e.y),Math.abs(t.x),Math.abs(t.y),Math.abs(n.x),Math.abs(n.y))}),cases:()=>[E.rgbShift().list[0],E.rgbShift({amount:12}).list[0],E.rgbShift({red:{x:6,y:-4},green:{x:-3,y:5},blue:{x:0,y:9}}).list[0]]}),dd=oe({default:()=>hd}),hd=ce({type:"scanlines",surface:"shader",params:{spacing:"param",thickness:"param",darkness:"param",offset:"param",direction:{type:"vec2f",uses:["angle"],value(e){let t=e.angle*Math.PI/180;return[Math.cos(t),Math.sin(t)]}}},prepare:e=>e.darkness>0?{}:null,cases:()=>[E.scanlines().list[0],E.scanlines({spacing:7,thickness:.3,darkness:.8,offset:2,angle:30}).list[0],E.scanlines({spacing:5,thickness:.7,angle:90}).list[0]]}),pd=oe({default:()=>_d}),_d=ce({type:"scatter",surface:"shader",params:{offset:{type:"vec2f",uses:["strength","axis"],value(e){let t=kt(e.axis);return[e.strength*t.x,e.strength*t.y]}}},prepare:e=>e.strength>0?{}:null,extras(e){let t=kt(e.axis);return{reach:e.strength*Math.max(Math.abs(t.x),Math.abs(t.y))}},cases:()=>[E.scatter().list[0],E.scatter({strength:24,axis:"x"}).list[0],E.scatter({strength:6,axis:"y"}).list[0]]}),md=oe({default:()=>gd}),gd=ce({type:"sharpen",surface:"shader",params:{amount:"param",radius:{type:"f32",value:e=>Math.max(e.radius,0)}},prepare:e=>e.amount===0?null:{},cases:()=>[E.sharpen().list[0],E.sharpen({amount:2.5,radius:3}).list[0]]}),bd=oe({default:()=>wd}),wd=ce({type:"streak",surface:"filter",params:{scale:{type:"f32",uses:["threshold"],value:(e,t)=>t.scale},bias:{type:"f32",value:(e,t)=>-t.t*t.scale},intensity:"param",sigma:{type:"f32",uses:["length"],value:(e,t)=>t.sigma},axis:{type:"vec2f",uses:["angle"],value:(e,t)=>[Math.cos(t.rad),Math.sin(t.rad)]}},prepare(e){if(e.intensity<=0||e.length<=0)return null;let t=Math.max(0,Math.min(1,e.threshold));return{t,scale:t<1?1/(1-t):1,sigma:e.length/2,rad:e.angle*Math.PI/180}},extras:(e,t)=>({blur:[t.sigma,.01,t.rad],reach:3*t.sigma}),cases:()=>[E.streak().list[0],E.streak({angle:30,length:80,threshold:.5,intensity:1.5}).list[0],E.streak({angle:90,length:60,threshold:.3,intensity:.7}).list[0]]}),yd=oe({default:()=>vd}),vd=ce({type:"threshold",surface:"shader",params:{level:"param",smoothness:"param"},cases:()=>[E.threshold().list[0],E.threshold({level:.3,smoothness:0}).list[0],E.threshold({level:.6,smoothness:.4}).list[0]]}),xd=oe({default:()=>kd}),kd=ce({type:"twirl",surface:"shader",params:{angle:{type:"f32",value:e=>e.angle*Math.PI/180},radius:"param",center:"param"},prepare:e=>e.angle===0||e.radius<=0?null:{},extras(e){let t=Math.min(e.radius,Math.SQRT2);return{reach:Math.min((Math.max(t-1,0)+2*Math.hypot(e.center.x-.5,e.center.y-.5))*360,800)}},cases:()=>[E.twirl().list[0],E.twirl({angle:-120,radius:.6}).list[0],E.twirl({angle:300,radius:1.4,center:{x:.35,y:.55}}).list[0]]}),Md=oe({default:()=>Sd}),Sd=ce({type:"vignette",surface:"shader",params:{color:"param",amount:"param",radius:"param",softness:"param"},prepare:e=>e.amount<=0||Mt(e.color)[3]<=0?null:{},cases:()=>[E.vignette().list[0],E.vignette({amount:.9,radius:.4,softness:.3}).list[0],E.vignette({amount:.7,color:"#ff8800",radius:.6,softness:.8}).list[0]]}),Ed=oe({default:()=>Ad}),Ad=ce({type:"vintage",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},uses:["amount","warmth"],value(e){let t=Math.max(0,Math.min(1,e.amount)),n=Math.max(-1,Math.min(1,e.warmth)),r=(l,c)=>l+(c-l)*t,s=n>0?n*.15:0,i=n<0?-n*.15:0,a=n<0?-n*.05:0,o=n>0?n*.05:0;return[r(1,.393),r(0,.769),r(0,.189),0,s-a,r(0,.349),r(1,.686),r(0,.168),0,0,r(0,.272),r(0,.534),r(1,.131),0,-i+o,0,0,0,1,0]}}},prepare:e=>e.amount<=0&&e.warmth===0?null:{},cases:()=>[E.vintage().list[0],E.vintage({amount:.5,warmth:-.8}).list[0],E.vintage({amount:0,warmth:1}).list[0]]}),Td=oe({default:()=>Pd}),Pd=ce({type:"wave",surface:"shader",params:{amplitude:"param",wavelength:{type:"f32",value:e=>Math.max(e.wavelength,.01)},phase:{type:"f32",value:e=>(e.phase%360+360)%360*Math.PI/180},direction:{type:"vec2f",uses:["angle"],value(e){let t=e.angle*Math.PI/180;return[Math.cos(t),Math.sin(t)]}},shape:"param",center:"param"},prepare:e=>e.amplitude.x===0&&e.amplitude.y===0?null:{},extras:e=>({reach:Math.max(Math.abs(e.amplitude.x),Math.abs(e.amplitude.y))}),cases:()=>[E.wave().list[0],E.wave({amplitude:{x:8,y:14},wavelength:60,phase:70,angle:35}).list[0],E.wave({amplitude:16,shape:"radial",wavelength:80,center:{x:.4,y:.6}}).list[0]]}),Ii=new Map(Object.entries(Object.assign({"./_pack.ts":yu,"./alpha.ts":xu,"./ascii.ts":Mu,"./bitCrush.ts":Iu,"./blockDisplace.ts":Du,"./bloom.ts":Fu,"./blur.ts":$u,"./bulge.ts":Nu,"./chromaticAberration.ts":Wu,"./colorAdjustment.ts":Hu,"./colorMatrix.ts":Yu,"./curves.ts":Zu,"./directionalBlur.ts":rf,"./dither.ts":af,"./dropShadow.ts":ff,"./duotone.ts":hf,"./edges.ts":bf,"./exposure.ts":yf,"./glass.ts":xf,"./glow.ts":If,"./grain.ts":Of,"./grayscale.ts":Lf,"./halftone.ts":Bf,"./invert.ts":Uf,"./kaleidoscope.ts":Vf,"./lut.ts":Gf,"./magnify.ts":Jf,"./oilPaint.ts":Xf,"./outline.ts":Qf,"./pixelate.ts":nd,"./posterize.ts":sd,"./progressiveBlur.ts":ad,"./radialBlur.ts":cd,"./rgbShift.ts":ud,"./scanlines.ts":dd,"./scatter.ts":pd,"./sharpen.ts":md,"./streak.ts":bd,"./threshold.ts":yd,"./twirl.ts":xd,"./vignette.ts":Md,"./vintage.ts":Ed,"./wave.ts":Td})).filter(([e])=>!e.includes("/_")).map(([,e])=>[e.default.type,e.default])),Id=1073741824,Gr=null;function bn(e){return Gr??=cl(e?{module_or_path:e}:void 0),Gr}var Kn=null;function Zr(){return Kn??=bn().then(()=>Vt.prewarm()).catch(e=>{throw Kn=null,e}),Kn}function Rd(){Kn=null,Gr&&Vt.forget_device()}var Cd={miter:0,round:1,bevel:2},Od={butt:0,round:1,square:2},Ri={clamp:0,repeat:1,mirror:2,decal:3},Dd={rect:1,ellipse:2,path:3},Ld={left:0,right:1,center:2,justify:3},Fd={top:0,center:1,bottom:2},Ci=new TextEncoder,Bd=120;function $d(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619);return t>>>0}function Ud(e){let t=new Uint32Array(e.points.buffer,e.points.byteOffset,e.points.length),n=2166136261,r=16777619^e.points.length;for(let s=0;s<e.verbs.length;s++)n=Math.imul(n^e.verbs[s],16777619),r=Math.imul(r^e.verbs[s],1540483477);for(let s=0;s<t.length;s++)n=Math.imul(n^t[s],16777619),r=Math.imul(r^t[s],1540483477);return`${e.verbs.length}:${t.length}:${n>>>0}:${r>>>0}`}var Qr=class{name="wgpu";r;w;paintIds=new WeakMap;paintByKey=new Map;freePaints=[];pathIds=new WeakMap;pathByKey=new Map;freePaths=[];generation=0;collectUnused=!1;dashIds=new Map;nextPaint=0;nextPath=0;nextDash=0;synced=!1;viewport={w:0,h:0};lastDeltaWords=0;async init(e,t,n){let r=await bn();await Zr().catch(()=>{}),this.attach(await Vt.create(e,t,n),r.memory,t,n)}attach(e,t,n,r){this.r=e,this.w=new wu(this.r,t),this.effectIndex=new Map(this.r.effect_names().map((s,i)=>[s,i])),this.viewport={w:n,h:r},this.shaders=new fl(this.r,()=>this.onShaderReady?.())}shaders;onShaderReady;shaderIssues=new Set;whenShadersReady(){return this.shaders.whenReady()}userProgram(e,t){let n=this.shaders.program(e,t),r=n.report.diagnostics[0]??n.browser.find(s=>s.message.startsWith("error"));return n.state==="failed"&&r&&this.shaderIssues.add(`A WGSL shader ${e} does not compile${r.line?` (line ${r.line}:${r.column})`:""}: ${r.message}`),n}adapterInfo(){return this.r.adapter_info()}gpuDevice(){return this.r.gpu_device()}setOptions(e,t){this.r.set_options(e,t)}resize(e,t){this.r.resize(e,t),this.viewport={w:e,h:t},this.synced=!1}paint(e){if(!e)return mt;let t=this.paintIds.get(e);if(t?.live)return t.used=this.generation,t.id;let n=e.kind==="image"?`image:${e.image.id}:${e.fit??"fill"}:${e.box.join(",")}:${e.matrix?.join(",")??""}:${e.tile??""}`:e.kind==="shader"?`shader:${this.userProgram("fill",e.source).id}:${e.box.join(",")}:${e.time}:${e.texture?.id??""}:${JSON.stringify(e.uniforms)}`:JSON.stringify(e),r=this.paintByKey.get(n);if(r)r.used=this.generation;else{r={id:this.freePaints.pop()??this.nextPaint++,used:this.generation,live:!0},this.paintByKey.set(n,r);let s=r.id,i=this.w;if(e.kind==="procedural")return this.procedural(s,e),this.paintIds.set(e,r),s;if(e.kind==="shader")return this.shaderPaint(s,e),this.paintIds.set(e,r),s;let a=e.kind==="solid"||e.kind==="image"?[]:e.stops;if(i.begin(12+a.length*5),i.u(Se.DEF_PAINT),i.u(s),e.kind==="solid"){i.u(0);for(let o=0;o<4;o++)i.f(0);for(let o of e.color)i.f(o)}else if(e.kind==="image"){let{m:o,tile:l}=Tc(e),c=o[0]*o[3]-o[1]*o[2]||1,u=e.image.width,f=e.image.height,d=o[3]/c,p=-o[1]/c,_=-o[2]/c,w=o[0]/c,A=(o[2]*o[5]-o[3]*o[4])/c,B=(o[1]*o[4]-o[0]*o[5])/c;i.u(4|Ri[l]<<8),i.f(d/u),i.f(p/f),i.f(_/u),i.f(w/f),i.f(A/u),i.f(B/f),i.f(e.image.id),i.f(0)}else{let o=e.kind==="linear"?1:e.kind==="radial"?2:3;i.u(o|Ri[e.tile??"clamp"]<<8),e.kind==="linear"?(i.f(e.from[0]),i.f(e.from[1]),i.f(e.to[0]),i.f(e.to[1])):e.kind==="radial"?(i.f(e.center[0]),i.f(e.center[1]),i.f(e.radius),i.f(0)):(i.f(e.center[0]),i.f(e.center[1]),i.f(e.startAngle),i.f(e.endAngle));for(let l of a[0].color)i.f(l)}i.u(a.length);for(let o of a){i.f(o.offset);for(let l of o.color)i.f(l)}}return this.paintIds.set(e,r),r.id}shaderPaint(e,t){let n=this.userProgram("fill",t.source),r=n.report.ok?si(n.report.fields,n.report.size,t.uniforms):new Uint32Array(0),s=Math.ceil(r.length/4),i=this.w;i.begin(12+s*5),i.u(Se.DEF_PAINT),i.u(e),i.u(10);for(let a of t.box)i.f(a);i.f(t.time),i.f(t.texture?t.texture.id:-1),i.f(n.id),i.f(0),i.u(s);for(let a=0;a<s;a++){i.f(0);for(let o=0;o<4;o++)i.u(r[a*4+o]??0)}}procedural(e,t){let n=t.fill,[r,s,i,a]=t.box,o,l,c,u=[],f=[],d=w=>[Math.round(w[0]*255)/255,Math.round(w[1]*255)/255,Math.round(w[2]*255)/255,w[3]];if(n.type==="dotGrid")o=5,l=[r+n.offset.x,s+n.offset.y,Math.max(.01,n.spacing),Math.max(0,n.radius)],c=[...n.color];else if(n.type==="grid")o=6,l=[r+n.offset.x,s+n.offset.y,i,a],c=[...n.color],u.push([Math.max(1e-4,n.divisions),Math.max(1,Math.round(n.subdivisions)),Math.max(0,n.strokeWidth)*.5,Math.max(0,n.subdivisionWidth)*.5]);else if(n.type==="stripe"){o=7;let w=(n.angle??-45)*Math.PI/180;l=[r,s,Math.max(1,Math.round(n.gap??8)),n.strokeWidth??1],c=d(n.color??[0,0,0,1]),u.push([Math.cos(w),Math.sin(w),r,0])}else if(n.type==="noise"){o=8,l=[r,s,Math.ceil(i),Math.ceil(a)];let w=d(n.color);c=[w[0],w[1],w[2],Math.round(n.color[3]*255)/255],u.push([Math.max(1,Math.round(n.size.x)),Math.max(1,Math.round(n.size.y)),Math.min(1,Math.max(0,n.density)),Math.round(n.seed)])}else{o=9,l=[r,s,i,a];let w=n.angle*Math.PI/180,A={value:0,simplex:1,ridged:2,worley:3}[n.basis]??1;u.push([n.frequency.x,n.frequency.y,n.offset.x,n.offset.y]),u.push([n.lacunarity,n.gain,n.seed,n.contrast]),u.push([Math.cos(w),Math.sin(w),A,n.octaves]);let B=Math.max(2,Math.min(8,n.colors.length));for(let L=0;L<B;L++)f.push({offset:n.stops[Math.min(L,n.stops.length-1)]??L/(B-1),color:[...n.colors[Math.min(L,n.colors.length-1)]]});c=f[0].color}let p=u.length+f.length,_=this.w;_.begin(12+p*5),_.u(Se.DEF_PAINT),_.u(e),_.u(o);for(let w of l)_.f(w);for(let w of c)_.f(w);_.u(p);for(let w of u){_.f(0);for(let A of w)_.f(A)}for(let w of f){_.f(w.offset);for(let A of w.color)_.f(A)}}pathId(e){let t=this.pathIds.get(e);if(t?.live)return t.used=this.generation,t.id;let n=Ud(e),r=this.pathByKey.get(n);if(r)return r.used=this.generation,this.pathIds.set(e,r),r.id;let s={id:this.freePaths.pop()??this.nextPath++,used:this.generation,live:!0};this.pathByKey.set(n,s);let i=s.id,a=this.w,o=Math.ceil(e.verbs.length/4);a.begin(4+o+e.points.length),a.u(Se.DEF_PATH),a.u(i),a.u(e.verbs.length),a.u(e.points.length/2);for(let l=0;l<o;l++){let c=e.verbs,u=l*4;a.u((c[u]??0)|(c[u+1]??0)<<8|(c[u+2]??0)<<16|(c[u+3]??0)<<24)}for(let l=0;l<e.points.length;l++)a.f(e.points[l]);return this.pathIds.set(e,s),i}sweep(){let e=this.generation-Bd;for(let[t,n]of this.pathByKey)n.used>=e||(n.live=!1,this.pathByKey.delete(t),this.w.begin(2),this.w.u(Se.FREE_PATH),this.w.u(n.id),this.freePaths.push(n.id));for(let[t,n]of this.paintByKey)n.used>=e||(n.live=!1,this.paintByKey.delete(t),this.freePaints.push(n.id))}dash(e,t=0){if(!e||e.length===0)return mt;let n=e.join(",")+"@"+t,r=this.dashIds.get(n);if(r===void 0){r=this.nextDash++,this.dashIds.set(n,r);let s=this.w;s.begin(4+e.length),s.u(Se.DEF_DASH),s.u(r),s.u(e.length),s.f(t);for(let i of e)s.f(i)}return r}writeNode(e,t){let n=this.w,r=e.id;if(t&ke.CREATE&&(n.begin(3),n.u(Se.CREATE),n.u(r),n.u(xc[e.kind])),t&ke.TRANSFORM){let s=e.transform;if(Vn(s)){n.begin(11),n.u(Se.TRANSFORM3),n.u(r);for(let i of s)n.f(i)}else{n.begin(8),n.u(Se.TRANSFORM),n.u(r);for(let i=0;i<6;i++)n.f(s[i])}}if(t&ke.EFFECTS&&(e.effects?.length||!(t&ke.CREATE))&&this.writeEffects(e),t&ke.OPACITY&&(e.opacity!==1||!(t&ke.CREATE))&&(n.begin(3),n.u(Se.OPACITY),n.u(r),n.f(e.opacity)),t&ke.BLEND&&(e.blend!=="normal"||!(t&ke.CREATE))&&(n.begin(3),n.u(Se.BLEND),n.u(r),n.u(qi.indexOf(e.blend))),e.kind==="group"){if(t&ke.CLIP&&(e.clip||!(t&ke.CREATE))){let s=e.clip,i=s?.path?this.pathId(s.path):mt,a=s?.path?it(s.path):[s?.x??0,s?.y??0,(s?.x??0)+(s?.w??0),(s?.y??0)+(s?.h??0)];n.begin(10),n.u(Se.CLIP),n.u(r),n.u(s?1:0);for(let o of a)n.f(o);n.f(s?.r??0),n.u(i),n.u(s?.evenOdd?1:0)}if(t&ke.MASK&&(e.mask||!(t&ke.CREATE))&&(n.begin(3),n.u(Se.MASK),n.u(r),n.u(e.mask?Mc[e.mask]:0)),t&ke.FILTER&&(e.filter||!(t&ke.CREATE))){let s=e.filter;if(n.begin(10),n.u(Se.FILTER),n.u(r),s)if(s.kind==="blur"){n.u(1),n.f(s.sigma);for(let i=0;i<6;i++)n.f(0)}else{n.u(2),n.f(s.sigma),n.f(s.dx),n.f(s.dy);for(let i of s.color)n.f(i)}else{n.u(0);for(let i=0;i<7;i++)n.f(0)}}if(t&ke.CHILDREN){n.begin(3+e.children.length),n.u(Se.CHILDREN),n.u(r),n.u(e.children.length);for(let s of e.children)n.u(s.id)}return}if(t&ke.SIZE&&(n.begin(4),n.u(Se.SIZE),n.u(r),n.f(e.w),n.f(e.h)),t&ke.RADII&&e.kind==="rect"){n.begin(6),n.u(Se.RADII),n.u(r);for(let s of e.radii)n.f(s)}if(t&ke.MEMBERS&&e.members){let s=e.members,i=s.map(a=>a.kind==="path"&&a.path?this.pathId(a.path):mt);n.begin(3+s.length*16),n.u(Se.MEMBERS),n.u(r),n.u(s.length),s.forEach((a,o)=>{n.u(Dd[a.kind]),n.u(kc[Ac(a)]);for(let l of a.transform??[1,0,0,1,0,0])n.f(l);n.f(a.w??0),n.f(a.h??0);for(let l of a.radii??[0,0,0,0])n.f(l);n.u(i[o]),n.u(a.evenOdd?1:0)})}if(t&ke.TEXT&&e.text){let s=e.text,i=s.runs.map(c=>[Ci.encode(c.family),Ci.encode(c.text)]),a=i.reduce((c,[u,f])=>c+2+Math.ceil(u.length/4)+Math.ceil(f.length/4)+6,0),o=s.path?this.pathId(s.path):mt,l=s.runs.map(c=>this.paint(c.paint));n.begin(12+a),n.u(Se.TEXT),n.u(r),n.u(Ld[s.align??"center"]),n.u(Fd[s.verticalAlign??"center"]),n.u(s.wrap?1:0),n.f(s.fontSize==="autofit"?0:s.runs.length===1?s.runs[0].size:0),n.f(s.minFontSize??0),n.f(s.lineHeight??0),n.f(s.width??0),n.f(s.height??0),n.u(s.runs.length),s.runs.forEach((c,u)=>{n.u(c.decoration==="underline"?1:c.decoration==="lineThrough"?2:0),n.u(l[u]),n.f(c.size),n.f(c.weight??400),n.u(c.italic?1:0),n.f(c.letterSpacing??0);for(let f of i[u]){n.u(f.length);for(let d=0;d<f.length;d+=4)n.u((f[d]??0)|(f[d+1]??0)<<8|(f[d+2]??0)<<16|(f[d+3]??0)<<24)}}),n.u(o)}if(t&ke.PATH&&e.path){let s=this.pathId(e.path);n.begin(4),n.u(Se.PATH),n.u(r),n.u(s),n.u(e.evenOdd?1:0)}if(t&ke.FILL){let s=this.paint(e.fill);n.begin(3),n.u(Se.FILL),n.u(r),n.u(s)}if(t&ke.STROKE&&(e.stroke||!(t&ke.CREATE))){let s=e.stroke,i=this.paint(s?.paint),a=this.dash(s?.dash,s?.dashPhase);n.begin(8),n.u(Se.STROKE),n.u(r),n.u(i),n.f(s?.width??0),n.u(Cd[s?.join??"miter"]),n.u(Od[s?.cap??"butt"]),n.f(s?.miter??4),n.u(a)}if(t&ke.SHADOWS&&(e.shadows.length||!(t&ke.CREATE))){n.begin(3+e.shadows.length*8),n.u(Se.SHADOWS),n.u(r),n.u(e.shadows.length);for(let s of e.shadows){n.f(s.dx),n.f(s.dy),n.f(s.sigma),n.f(s.spread);for(let i of s.color)n.f(i)}}}uploaded=new Map;missing3d=new Set;textures3d=new Map;geometries3d=new Map;bindTextures3d(e,t){let n=new Set(t.pending.splice(0));for(let r of n){let s=r.texture;"data"in s&&this.r.scene3d_pixels(e.id,r.id,Uint8Array.from(s.data),s.width,s.height,r.srgb)}for(let r of t.all.values()){let s=r.texture;if("data"in s)continue;let i="src"in s?e.links3d?.images?.[s.src]:e.links3d?.surfaces?.get(s);i?this.r.scene3d_bind(e.id,r.id,i.id,r.srgb):n.has(r)&&this.missing3d.add("src"in s?`image:${s.src}`:"surface")}}scene3dSigs=new Map;forgetScene3d(e){this.textures3d.delete(e),this.geometries3d.delete(e),this.scene3dSigs.delete(e)}encode3dMs=0;words3d=0;effectIndex=new Map;auxIds=new Map;missing=new Set;effectTypes(){return[...this.effectIndex.keys()].filter(e=>Ii.has(e))}auxId(e){if(!e)return mt;let t=this.auxIds.get(e.key);if(t===void 0){t=1e6+this.auxIds.size;let n=new OffscreenCanvas(e.width,e.height);n.getContext("2d").putImageData(new ImageData(new Uint8ClampedArray(e.pixels),e.width,e.height),0,0),this.r.upload_image(t,n,!1),this.auxIds.set(e.key,t)}return t}writeEffects(e){let t=e.effects??[],n=[];for(let[i,a]of[["shader",!1],["filter",!1],["filter",!0],["shader",!0]])for(let o of t){if(o.type==="shader"){if(o.mode==="backdrop"!==a||(a?"shader":"filter")!==i)continue;let f=this.userEffect(o);f&&n.push({...f,flags:(o.clip?1:0)|(a?2:0)});continue}let l=Ii.get(o.type),c=this.effectIndex.get(o.type);if(!l||c===void 0){this.missing.has(o.type)||console.info(`effect "${o.type}" has no WGSL port yet; skipped`),this.missing.add(o.type);continue}if(l.surface!==i||o.mode==="backdrop"!==a||l.backdropOnly&&!a)continue;let u=l.pack(o);u&&n.push({index:c,flags:(o.clip?1:0)|(a?2:0)|(a&&i==="filter"?4:0)|(u.field?8:0),aux:this.auxId(u.aux),p:u})}let r=this.w,s=e.effectBox??[0,0,0,0];r.begin(8+n.reduce((i,a)=>i+8+a.p.params.length+(a.words?.length??0),0)),r.u(Se.EFFECTS),r.u(e.id);for(let i of s)r.f(i);r.f(e.effectTime??0),r.u(n.length);for(let i of n){r.u(i.index),r.u(i.flags),r.u(i.aux),r.f(i.p.reach??0);let a=i.p.blur??[0,0,0];r.f(a[0]),r.f(a[1]),r.f(a[2]),r.u(i.p.params.length+(i.words?.length??0));for(let o of i.p.params)r.f(o);if(i.words)for(let o of i.words)r.u(o)}}userEffect(e){if(!e.source?.trim())return null;if(!Ni(e))return this.shaderIssues.add(wl),null;let t=this.userProgram("effect",e.source);if(!t.report.ok)return null;let n=ji(e.uniforms),r=e.mode!=="backdrop"&&e.blendMode?(bl[e.blendMode]??-1)+1:0;return{index:Id+t.id,aux:mt,p:{params:[r],reach:Math.max(0,e.reach??0)},words:si(t.report.fields,t.report.size,n)}}frameCanvases=new Map;colorCorrect(e){if(typeof VideoFrame>"u"||!(e.source instanceof VideoFrame))return e.source;let t=this.frameCanvases.get(e.id);return(!t||t.width!==e.width||t.height!==e.height)&&(t=new OffscreenCanvas(e.width,e.height),this.frameCanvases.set(e.id,t)),t.getContext("2d").drawImage(e.source,0,0),t}sync(e){this.generation++,this.encode3dMs=0,this.words3d=0;for(let n of e.images)if(this.uploaded.get(n.id)!==n.version){if(n.surface)this.forgetScene3d(n.id),this.r.set_surface(n.id,n.surface.id,n.width,n.height);else if(n.scene3d){let r=this.viewport.w/e.width,s={unsupported:new Set},i=this.textures3d.get(n.id);i||this.textures3d.set(n.id,i=new hu);let[a,o]=n.scale3d?[Math.ceil(n.width*n.scale3d),Math.ceil(n.height*n.scale3d)]:[Math.round(n.width*r),Math.round(n.height*r)],l=performance.now(),c=this.geometries3d.get(n.id);c||this.geometries3d.set(n.id,c=new _u);let u=bu(n.scene3d,s,i,c),f=`${a}x${o}:${u.length}:${$d(u)}`;if(this.encode3dMs+=performance.now()-l,this.words3d+=u.length,this.scene3dSigs.get(n.id)!==f){try{this.r.set_scene3d(n.id,a,o,u)}catch(d){throw this.geometries3d.delete(n.id),this.scene3dSigs.delete(n.id),d}this.scene3dSigs.set(n.id,f)}for(let d of s.unsupported)this.missing3d.add(d);this.bindTextures3d(n,i)}else this.forgetScene3d(n.id),this.r.upload_image(n.id,this.colorCorrect(n),n.mipmaps);this.uploaded.set(n.id,n.version)}let t=this.w;if(this.synced)for(let n of e.dirty)this.writeNode(n,n.dirty);else{for(let n of e.nodes)this.writeNode(n,ke.ALL);t.begin(2),t.u(Se.ROOT),t.u(e.root.id),t.begin(8),t.u(Se.VIEWPORT),t.u(this.viewport.w),t.u(this.viewport.h),t.f(this.viewport.w/e.width);for(let n of e.background)t.f(n);this.synced=!0}for(let n of e.dirty)n.dirty=0;e.dirty.clear(),this.collectUnused&&this.generation%30===0&&this.sweep(),t.flush(),this.lastDeltaWords=t.takeCount()}render(){this.r.render()}invalidate(){this.r.invalidate()}waitGpu(){return this.r.wait_gpu()}async readPixels(){return await this.r.read_pixels()}stats(){let e=this.r.stats();return{buildMs:e[0],encodeMs:e[1],applyMs:e[2],prims:e[3],ops:e[4],layers:e[5],passes:e[6],draws:e[7],culled:e[8],tessellated:e[9],poolTextures:e[10],poolMiB:e[11],geomVertices:e[12],reusedPrims:e[13],cleanPrims:e[14],deltaWords:this.lastDeltaWords,scene3dEncodeMs:this.encode3dMs,scene3dWords:this.words3d,scene3dSetMs:e[15],scene3dDrawMs:e[16],scene3dMapsMs:e[17],surfacesDrawn:e[18],surfaces:e[19]}}registerFont(e,t){this.r.register_font(e,t)}destroy(){this.r.free()}},Pa={normal:0,italic:1,oblique:2},Nd={left:0,right:1,center:2,justify:3,start:4,end:5},jd={top:0,center:1,bottom:2},Oi=new WeakMap;function es(e){let t=Oi.get(e);if(!t){let n=t=new Ur;for(let r of e.fonts)n.register_font(r.bytes,r.family);e.onFont(r=>n.register_font(r.bytes,r.family)),Oi.set(e,n)}return t}function ts(e,t,n,r,s=400,i=0,a){let[o,l]=e.measure_text(t,n,r,s,i,Pa[a??"normal"]??0);return{width:o,height:l}}function Ia(e,t){let n=Ki(t);if(n.path!=null)return null;let r=n.fontSize==="autofit",s={text:String(n.text??""),fontFamily:n.fontFamily,fontSize:r?100:n.fontSize,fontWeight:n.fontWeight,fontStyle:n.fontStyle,letterSpacing:n.letterSpacing},i=Array.isArray(n.segments)&&n.segments.length?n.segments:[s];if(i.some(_=>(_.x??0)!==0||(_.y??0)!==0||(_.rotation??0)!==0||(_.scale??1)!==1))return null;let a=[],o=[],l="";for(let _ of i){let w=_.fontFamily??s.fontFamily??"",A=a.indexOf(w);A<0&&(A=a.push(w)-1);let B=String(_.text??"");l+=B,o.push(B.length,_.fontSize??s.fontSize,_.fontWeight??s.fontWeight??400,Pa[_.fontStyle??s.fontStyle??"normal"]??0,_.letterSpacing??s.letterSpacing??0,A)}let c=n.width??0,u=n.height??0,f=e.text_block(l,new Float32Array(o),a.join(`
703
- `),r?NaN:s.fontSize,n.minFontSize??0,n.lineHeight??0,Nd[n.textAlign??"center"]??2,jd[n.verticalAlign??"center"]??1,!!n.wrap&&c>0,c,u);if(!f.length)return null;let d=[],p=3;for(let _=0;_<f[2];_++){let[w,A,B,L,V]=f.subarray(p,p+5);d.push({start:w,end:A,top:B,bottom:L,carets:Array.from(f.subarray(p+5,p+5+V))}),p+=5+V}return{lines:d,width:f[0],height:f[1]}}var Wd=3,Vd=6e4,zd=32,Hr=new Set,mn=new Set,Di=new WeakSet,sn=[],Gd=0,zt=null,Li=!1;function Hd(e){return Hr.add(e),()=>Hr.delete(e)}function Kd(){return zt}function qd(e){return Zd(),mn.add(e),zt!==null&&(e.queueIssue(Ra(zt)),e.halt()),()=>mn.delete(e)}function Jd(e){let t=e;!t||Di.has(t)||(Di.add(t),t.addEventListener?.("uncapturederror",n=>Yd(n.error)),t.lost.then(n=>Xd(n.reason??"unknown",n.message??"")))}function qn(e){for(let t of[...Hr])try{t(e)}catch(n){console.error("[wgpu] a fault listener threw:",n)}}function ns(e){for(let t of mn)t.queueIssue(e)}function Yd(e){if(++Gd>zd)return;let t=e?.constructor?.name??"",n=t==="GPUOutOfMemoryError"?"out-of-memory":t==="GPUInternalError"?"internal":"validation",r=`WebGPU ${n} error: ${e?.message??String(e)}`;ns({kind:"gpu",feature:`gpu:${n}`,message:r}),qn({type:"gpu-error",error:n,message:r})}function Xd(e,t){if(zt!==null)return;Rd();let n=performance.now();for(;sn.length&&n-sn[0]>Vd;)sn.shift();let r=`The GPU device was lost (${e}${t?`: ${t}`:""}); the renderer is drawing on a new one.`;if(qn({type:"device-lost",reason:e,message:r}),sn.length>=Wd){Kr("The GPU device was lost 4 times within a minute; the renderer stopped asking for a new one.");return}sn.push(n),ns({kind:"device-lost",message:r});for(let s of[...mn])s.remount();Zr().then(()=>qn({type:"device-restored"}),s=>Kr(`No GPU device after a loss: ${String(s?.message??s)}`))}function Ra(e){return{kind:"crashed",message:e}}function Kr(e){zt===null&&(zt=e,queueMicrotask(()=>{ns(Ra(e));for(let t of[...mn])t.halt();qn({type:"crashed",message:e})}))}function Zd(){Li||(Li=!0,Rc(e=>Kr(`The renderer panicked and draws nothing more on this page (reload to recover): ${e}`)))}var Fi=new Set,Ca=/-not-(?:decoded|loaded)$/,Wn={"text:path":"Text on a path",rasterize:"rasterize()","boolean:nested":"A boolean nested in one of another kind","boolean:projective":"A boolean under a 3D (projective) transform","cut:compound":"A cut through a compound shape","stroke:union-of-booleans":"One stroke around several booleans","effect:motionBlur-shutter":"Motion blur with an off-centre shutter or over 32 samples","surface:error":"A surface texture that failed to draw","blend:":"The blend mode","fill:blend:":"The fill blend mode","op:":"The drawing op","fill:":"The fill","effect:":"The effect","3d:":"In 3D,"};function jt(e){if(Wn[e])return`${Wn[e]} is not drawn by the WebGPU renderer.`;let t=Object.keys(Wn).filter(n=>n.endsWith(":")&&e.startsWith(n)).sort((n,r)=>r.length-n.length)[0];return t?`${Wn[t]} "${e.slice(t.length)}" is not drawn by the WebGPU renderer.`:`Not drawn by the WebGPU renderer: ${e}.`}var Qd=class extends va{store;view={zoom:1,x:0,y:0};frame=null;clipToFrame=!0;frameBackground="black";canvas=null;size={width:1,height:1};backend=null;starting=null;startFailed=!1;startToken=null;lastDoc=null;viewportKey="";shaper;stopFonts;stopSettle;stopFaults;faults=[];halted=!1;constructor(e,t){let n=es(e);super(t.width,t.height,(r,s,i,a,o,l)=>ts(n,r,s,i,a,o,l)),this.store=e,this.shaper=n,this.storage=e,this.images=e.images,this.stopFonts=e.onFont(r=>this.backend?.registerFont(r.bytes,r.family)),this.stopSettle=e.addSettler(()=>this.starting&&!this.startFailed?this.starting.catch(()=>{}):this.backend?.shaders.hasPending()?this.backend.whenShadersReady():null),this.stopFaults=qd({queueIssue:r=>this.faults.push(r),remount:()=>this.remount(),halt:()=>this.halt()})}stats(){return this.backend?.stats()??null}mount(e){let t=e;if(this.size={width:Math.max(1,t.width),height:Math.max(1,t.height)},t===this.canvas&&(this.backend||this.starting)){this.present();return}if(this.releaseBackend(),this.canvas=t,this.halted||Kd()!==null)return;let n={};this.startToken=n,this.startFailed=!1;let r=this.starting=(async()=>{let s=new Qr;if(await s.init(t,this.size.width,this.size.height),this.startToken!==n){this.halted||s.destroy();return}Jd(s.gpuDevice()),s.setOptions(!1,!1),s.collectUnused=!0,s.onShaderReady=()=>this.present();for(let i of this.store.fonts)s.registerFont(i.bytes,i.family);this.backend=s,this.starting=null,this.present()})();r.catch(s=>{this.starting===r&&(this.startFailed=!0),console.error("[wgpu] the renderer failed to start:",s)})}whenMounted(){return this.starting??Promise.resolve()}unmount(){this.releaseBackend(),this.canvas=null}execute(e){if(!(!this.canvas||this.isDisposed())){this.width=this.size.width/this.pixelRatio,this.height=this.size.height/this.pixelRatio;try{super.execute(e)}finally{this.lastDoc=this.doc,this.present();for(let t of this.missing)Fi.has(t)||t.endsWith("-not-decoded")||(Fi.add(t),console.warn(`[wgpu] not drawn yet: ${t}`))}}}takeRenderIssues(){let e=new Map,t=r=>e.set(zi(r),r);for(let r of this.faults.splice(0))t(r);let n=this.halted?null:this.backend;for(let r of n?.shaderIssues??[])t({kind:"shader",...r==="A shader effect is written in SkSL, which Motion Script no longer runs, so it is skipped. Port it to WGSL (fn effect(in: EffectIn) -> vec4f)."&&{feature:"effect:shader-sksl"},message:r});n?.shaderIssues.clear();for(let r of this.shaderIssues)t(r);for(let r of this.missing){if(Ca.test(r))continue;let s=r==="fill:shader-sksl"?{kind:"shader",feature:r,message:ra}:{kind:"missing",feature:r,message:jt(r)},i=this.missing.nodes.get(r);if(!i?.size)t(s);else for(let a of i)t({...s,nodeId:a})}for(let r of n?.missing??[])t({kind:"missing",feature:`effect:${r}`,message:jt(`effect:${r}`)});for(let r of n?.missing3d??[])t({kind:"missing",feature:`3d:${r}`,message:jt(`3d:${r}`)});return[...e.values()]}whenShadersReady(){return this.backend?.whenShadersReady()??Promise.resolve()}layoutTextBlock(e){return Ia(this.shaper,e)}screenshot(e="image/png",t){return this.snapshotCanvas()?.toDataURL(e,t)}snapshotCanvas(){let e=this.canvas;if(!e||!this.backend||!this.lastDoc)return;this.present();let[t,n,r,s]=[0,0,e.width,e.height];if(this.frame){let o=this.pixelRatio,l=this.view.zoom,c=e.width/2+this.view.x*o,u=e.height/2+this.view.y*o,f=this.frame.width*l*o,d=this.frame.height*l*o;t=Math.max(0,Math.round(c-f/2)),n=Math.max(0,Math.round(u-d/2)),r=Math.max(1,Math.min(e.width-t,Math.round(f))),s=Math.max(1,Math.min(e.height-n,Math.round(d)))}let i=document.createElement("canvas");i.width=r,i.height=s;let a=i.getContext("2d");if(a)return a.drawImage(e,t,n,r,s,0,0,r,s),i}dispose(){this.releaseBackend(),this.stopFonts(),this.stopSettle(),this.stopFaults(),this.canvas=null,this.lastDoc=null,this.store.dispose(),super.dispose()}rootTransform(){let e=this.view.zoom;return[e,0,0,e,this.width/2+this.view.x,this.height/2+this.view.y]}clearColor(){return this.frame?[0,0,0,0]:[0,0,0,1]}frameGroup(e){let t=this.frame;if(!t)return e;let n={x:-t.width/2,y:-t.height/2,w:t.width,h:t.height};return this.frameBackground==="black"&&this.doc.rect(e,{transform:[1,0,0,1,n.x,n.y],w:n.w,h:n.h,fill:{kind:"solid",color:[0,0,0,1]}}),this.clipToFrame?this.doc.group(e,{clip:{...n,r:0}}):e}present(){let e=this.backend,t=this.canvas,n=this.lastDoc;if(!e||!t||!n||this.halted)return;let{width:r,height:s}=this.size,i=`${r}x${s}/${n.width}/${n.background.join(",")}`;(i!==this.viewportKey||t.width!==r||t.height!==s)&&(e.resize(r,s),this.viewportKey=i);try{e.sync(n),e.render()}catch(a){console.error("[wgpu] frame failed:",a)}}releaseBackend(){this.starting=null,this.startToken=null,this.halted||this.backend?.destroy(),this.backend=null,this.viewportKey=""}remount(){let e=this.canvas;!e||this.isDisposed()||this.halted||(this.releaseBackend(),this.mount(e))}halt(){this.halted=!0,this.releaseBackend()}},eh=827872077;var Le={BEGIN:1,APPLY:2,FONT:3,IMAGE:4,SURFACE:5,SCENE3D:6,SCENE3D_BIND:7,SCENE3D_PIXELS:8,FREE_IMAGE:9,SHADER_ADD:10,SHADER_BUILD:11,SHADER_REMOVE:12,OPTIONS:13,RESIZE:14,FRAME:15,AUDIO:16,END:17,INVALIDATE:18,CREATE:19},Jn=Le,Bi=new TextEncoder,th=class{buf=new Uint8Array(1<<20);view=new DataView(this.buf.buffer);pos=0;taken=0;constructor(){this.u32(eh),this.u32(1)}get size(){return this.pos}reserve(e){if(this.pos+e<=this.buf.length)return;let t=this.buf.length*2;for(;t<this.pos+e;)t*=2;let n=new Uint8Array(t);n.set(this.buf.subarray(0,this.pos)),this.buf=n,this.view=new DataView(n.buffer)}u32(e){this.reserve(4),this.view.setUint32(this.pos,e>>>0,!0),this.pos+=4}record(e,t,n){let r=t.length*4+(n?.length??0),s=r+3&-4;this.reserve(8+s),this.view.setUint32(this.pos,e,!0),this.view.setUint32(this.pos+4,r,!0),this.pos+=8;for(let i=0;i<t.length;i++)this.view.setUint32(this.pos,t[i]>>>0,!0),this.pos+=4;n&&(this.buf.set(n,this.pos),this.pos+=n.length),this.buf.fill(0,this.pos,this.pos+s-r),this.pos+=s-r}recordWords(e,t,n){let r=new Uint8Array(n.buffer,n.byteOffset,n.length*4);this.record(e,t,r)}take(){let e=this.buf.slice(0,this.pos);return this.taken+=this.pos,this.pos=0,e}};function nh(e,t){let n=e,r=n.displayWidth??n.naturalWidth??n.videoWidth??n.width??0,s=n.displayHeight??n.naturalHeight??n.videoHeight??n.height??0;if(!r||!s)throw new Error("upload_image: empty source");let i=t.c;(!i||i.width!==r||i.height!==s)&&(i=t.c=new OffscreenCanvas(r,s));let a=i.getContext("2d",{willReadFrequently:!0});a.clearRect(0,0,r,s),a.drawImage(e,0,0);let o=a.getImageData(0,0,r,s).data;return{w:r,h:s,rgba:new Uint8Array(o.buffer,o.byteOffset,o.byteLength)}}var rh=class{out;effects;memory=new WebAssembly.Memory({initial:4});scratch={};imageUploads=0;imageMs=0;constructor(e,t,n,r){this.out=e,this.effects=t,e.record(Le.CREATE,[n,r])}delta_buffer(e){let t=e*4;return this.memory.buffer.byteLength<t&&this.memory.grow(Math.ceil((t-this.memory.buffer.byteLength)/65536)),0}delta_capacity(){return this.memory.buffer.byteLength/4}apply(e){e>0&&this.out.recordWords(Le.APPLY,[],new Uint32Array(this.memory.buffer,0,e))}effect_names(){return[...this.effects]}adapter_info(){return"native export sidecar"}gpu_device(){return null}set_options(e,t){this.out.record(Le.OPTIONS,[+e,+t])}resize(e,t){this.out.record(Le.RESIZE,[e,t])}register_font(e,t){let n=Bi.encode(t),r=new Uint8Array((n.length+3&-4)+e.length);return r.set(n),r.set(e,n.length+3&-4),this.out.record(Le.FONT,[n.length],r),0}upload_image(e,t,n){let r=performance.now(),{w:s,h:i,rgba:a}=nh(t,this.scratch);this.out.record(Le.IMAGE,[e,s,i,n?1:0],a),this.imageUploads++,this.imageMs+=performance.now()-r}set_scene3d(e,t,n,r){this.out.recordWords(Le.SCENE3D,[e,t,n],r instanceof Uint32Array?r:Uint32Array.from(r))}set_surface(e,t,n,r){this.out.record(Le.SURFACE,[e,t,n,r])}scene3d_bind(e,t,n,r){this.out.record(Le.SCENE3D_BIND,[e,t,n,+r])}scene3d_pixels(e,t,n,r,s,i){this.out.record(Le.SCENE3D_PIXELS,[e,t,r,s,+i],n)}scene3d_skipped(e){return[]}free_image(e){this.out.record(Le.FREE_IMAGE,[e])}shader_add(e,t,n){let r=Xi(t,n);return JSON.parse(r).ok&&this.out.record(Le.SHADER_ADD,[e,t],Bi.encode(n)),r}shader_build(e){this.out.record(Le.SHADER_BUILD,[e])}shader_remove(e){this.out.record(Le.SHADER_REMOVE,[e])}shader_formats(e){return[]}render(){}invalidate(){this.out.record(Le.INVALIDATE,[])}wait_gpu(){return Promise.resolve()}read_pixels(){return Promise.reject(new Error("A native export surface cannot be read back."))}stats(){return new Float64Array(20)}free(){}},sh=class extends va{store;out;size;recorder;backend=new Qr;shaper;stopFonts;stopSettle;viewportKey="";frameCount=0;constructor(e,t,n,r,s){let i=es(e);super(t.width,t.height,(o,l,c,u,f,d)=>ts(i,o,l,c,u,f,d)),this.store=e,this.out=n,this.size=s,this.shaper=i,this.storage=e,this.images=e.images,this.recorder=new rh(n,r,s.width,s.height);let a=this.recorder.memory;this.backend.attach(this.recorder,a,s.width,s.height),this.backend.setOptions(!1,!1),this.backend.collectUnused=!0;for(let o of e.fonts)this.backend.registerFont(o.bytes,o.family);this.stopFonts=e.onFont(o=>this.backend.registerFont(o.bytes,o.family)),this.stopSettle=e.addSettler(()=>this.backend.shaders.hasPending()?this.backend.whenShadersReady():null)}mount(){}unmount(){}whenMounted(){return Promise.resolve()}execute(e){if(!this.isDisposed()){this.width=this.size.width/this.pixelRatio,this.height=this.size.height/this.pixelRatio;try{super.execute(e)}finally{let t=this.doc,n=`${this.size.width}x${this.size.height}/${t.width}/${t.background.join(",")}`;n!==this.viewportKey&&(this.backend.resize(this.size.width,this.size.height),this.viewportKey=n),this.backend.sync(t)}}}frameDone(){this.out.record(Le.FRAME,[this.frameCount++])}takeRenderIssues(){let e=new Map,t=n=>e.set(zi(n),n);for(let n of this.backend.shaderIssues)t({kind:"shader",...n==="A shader effect is written in SkSL, which Motion Script no longer runs, so it is skipped. Port it to WGSL (fn effect(in: EffectIn) -> vec4f)."&&{feature:"effect:shader-sksl"},message:n});this.backend.shaderIssues.clear();for(let n of this.shaderIssues)t(n);for(let n of this.missing){if(Ca.test(n))continue;let r=n==="fill:shader-sksl"?{kind:"shader",feature:n,message:ra}:{kind:"missing",feature:n,message:jt(n)},s=this.missing.nodes.get(n);if(!s?.size)t(r);else for(let i of s)t({...r,nodeId:i})}for(let n of this.backend.missing)t({kind:"missing",feature:`effect:${n}`,message:jt(`effect:${n}`)});for(let n of this.backend.missing3d)t({kind:"missing",feature:`3d:${n}`,message:jt(`3d:${n}`)});return[...e.values()]}layoutTextBlock(e){return Ia(this.shaper,e)}dispose(){this.stopFonts(),this.stopSettle(),this.store.dispose(),super.dispose()}},$r=8192,ih=12,an=e=>e.toFixed(4);function dn(e,t,n){let r=e.get(t);if(r)return r;let s=n().finally(()=>e.delete(t));return e.set(t,s),s}async function ah(e){let t=await fetch(e);if(!t.ok)throw new Error(`${e}: HTTP ${t.status}`);return t.blob()}var $i=new WeakMap;function oh(e){let t=$i.get(e);if(!t){let n=new Map;t=r=>dn(n,r,()=>e(r)),$i.set(e,t)}return t}var ch=class extends Ho{fps;images=new Map;videos=new Map;fonts=[];fontListeners=new Set;registeredFamilies=new Set;pending=new Map;vectors=new Map;upgrades=new Map;settlers=new Set;audioData=new Map;imageLoads=new Map;videoLoads=new Map;fontLoads=new Map;frameDecodes=new Map;loadBytes;constructor(e,t,n,r=ah){super(e,t),this.fps=n,this.loadBytes=oh(r)}get size(){return this.viewport}addSettler(e){return this.settlers.add(e),()=>this.settlers.delete(e)}onFont(e){return this.fontListeners.add(e),()=>this.fontListeners.delete(e)}loadImage(e){let t=wt(e);return this.images.has(t)?Promise.resolve():dn(this.imageLoads,t,()=>this.decodeImage(e,t))}async decodeImage(e,t){let n=this.url(e,a=>a.getImageMeta(e)),r=await this.loadBytes(n),s;if(r.type==="image/svg+xml"||/\.svg(\?|#|$)/i.test(n)){let a=new Image;a.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await r.text())}`,await a.decode(),s=await createImageBitmap(a),this.vectors.set(t,{img:a,edge:Math.max(s.width,s.height)})}else s=await createImageBitmap(r,{colorSpaceConversion:"none"});let i=Math.max(s.width,s.height);if(i>$r){let a=$r/i,o=await createImageBitmap(s,{resizeWidth:Math.max(1,Math.round(s.width*a)),resizeHeight:Math.max(1,Math.round(s.height*a)),resizeQuality:"high"});s.close(),s=o}this.images.set(t,{bitmap:s,bytes:new Uint8Array(0),width:s.width,height:s.height})}loadVideo(e){let t=wt(e);return this.videos.has(t)?Promise.resolve():dn(this.videoLoads,t,()=>this.openVideo(e,t))}async openVideo(e,t){let n=this.url(e,a=>a.getVideoMeta(e)),r=new Cn({source:new ks(await this.loadBytes(n)),formats:Ss}),s=await r.getPrimaryVideoTrack();if(!s)throw r.dispose(),new Error(`loadVideo(${e}): no video track`);let i=await r.computeDuration();this.videos.set(t,{duration:i,sink:new Ts(s),input:r,frames:new Map,last:null})}videoFrame(e,t){let n=wt(e),r=this.videos.get(n);if(!r)return null;let s=r.frames.get(an(t));return s||(this.pending.set(`${n}@${an(t)}`,{src:n,time:t}),r.last)}wantImageEdge(e,t){let n=wt(e),r=this.vectors.get(n),s=this.images.get(n);if(!r||!s||t<=r.edge)return;let i=Math.max(s.width,s.height),a=Math.min($r,i*2**Math.ceil(Math.log2(t/i)));a>r.edge&&a>(this.upgrades.get(n)??0)&&this.upgrades.set(n,a)}hasPendingUpgrades(){return this.upgrades.size>0}async warmPendingUpgrades(){if(this.upgrades.size===0)return!1;let e=[...this.upgrades];this.upgrades.clear();for(let[t,n]of e){let r=this.vectors.get(t),s=this.images.get(t);if(!r||!s)continue;let i=n/Math.max(s.width,s.height),a=new OffscreenCanvas(Math.max(1,Math.round(s.width*i)),Math.max(1,Math.round(s.height*i)));a.getContext("2d").drawImage(r.img,0,0,a.width,a.height);let o=s.bitmap;s.bitmap=await createImageBitmap(a),r.edge=n,queueMicrotask(()=>o.close())}return!0}hasPendingDecodes(){return this.pending.size>0}async warmPendingDecodes(){let e=[...this.settlers].map(n=>n()).filter(n=>n!==null);if(this.pending.size===0&&e.length===0)return!1;let t=[...this.pending.values()];return this.pending.clear(),await Promise.all([...t.map(({src:n,time:r})=>dn(this.frameDecodes,`${n}@${an(r)}`,()=>this.decodeFrame(n,r))),...e]),!0}async decodeFrame(e,t){let n=this.videos.get(e);if(!n||n.frames.has(an(t)))return;let r=await n.sink.getSample(t);if(!r)return;let s=r.toVideoFrame(),i;try{i=await createImageBitmap(s)}finally{s.close(),r.close()}for(n.frames.set(an(t),i),n.last=i;n.frames.size>ih;){let[a,o]=n.frames.entries().next().value;n.frames.delete(a),o!==n.last&&queueMicrotask(()=>o.close())}}async loadAudio(){}fetchAudioData(e){let t=this.audioData.get(e);if(!t){let n=this.url(e,r=>{try{return r.getAudioMeta(e)}catch{return r.getVideoMeta(e)}});t=(async()=>(await this.loadBytes(n)).arrayBuffer())(),this.audioData.set(e,t),t.catch(()=>this.audioData.delete(e))}return t.then(n=>n.slice(0))}loadFont(e,t){return this.registeredFamilies.has(t)?Promise.resolve(!0):dn(this.fontLoads,t,()=>this.registerFamily(e,t))}async registerFamily(e,t){let n=this.catalog.getFontFamilyMetas(t);if(n.length===0)return this.getDecodePolicy()==="interactive"&&console.warn(`[WgpuStorageAdapter] No font manifest entry for "${e}".`),!1;let r=[...new Set(n.map(i=>i.src))],s=await Promise.all(r.map(async i=>new Uint8Array(await(await this.loadBytes(i)).arrayBuffer())));if(this.registeredFamilies.has(t))return!0;for(let i of s){let a={bytes:i,family:t};this.fonts.push(a);for(let o of this.fontListeners)o(a)}return this.registeredFamilies.add(t),!0}dispose(){for(let e of this.images.values())e.bitmap.close();this.images.clear();for(let e of this.videos.values()){for(let t of e.frames.values())t.close();e.input.dispose()}this.videos.clear(),this.pending.clear(),this.vectors.clear(),this.upgrades.clear(),this.fontListeners.clear(),this.imageLoads.clear(),this.videoLoads.clear(),this.fontLoads.clear(),this.frameDecodes.clear(),super.dispose()}url(e,t){try{return t(this.catalog).src||e}catch{return e}}};async function lh(e,t,n){return await bn(n),na(e,t)}var uh={fill:`// Provided to every WGSL fill:
702
+ ${t}`,r=Dt.get(n);if(r===void 0){try{let s=na(e,t);r=s.ok?s.fields.map(i=>i.name):null}catch{return null}Dt.size>=yl&&Dt.delete(Dt.keys().next().value)}else Dt.delete(n);return Dt.set(n,r),r}function xl(e,t){let n=t.source??"",r=fc(t);if(!n.trim()||r===void 0)return[];let s=[];r>zs&&s.push({kind:"shader",feature:`${e}:contract-${r}`,message:`A WGSL shader ${e} is written for shader contract ${r}; this renderer implements ${zs}, so it may not draw as intended.`});let i=vl(e,n);if(!i)return s;let a=ji(t.uniforms??{});for(let o of Object.keys(a))i.includes(o)||s.push({kind:"params",feature:`params:${o}`,message:`A WGSL shader ${e} is given "${o}", which names no member of its struct Params, so the value is ignored.`});for(let o of i)o in a||s.push({kind:"params",feature:`params:${o}`,message:`A WGSL shader ${e}'s Params.${o} is given no value, so it reads 0.`});return s}var kl=32;function xt(e,t){let n=e.p,r=1-t;return e.kind==="line"?[n[0]+(n[2]-n[0])*t,n[1]+(n[3]-n[1])*t]:e.kind==="quad"?[r*r*n[0]+2*r*t*n[2]+t*t*n[4],r*r*n[1]+2*r*t*n[3]+t*t*n[5]]:[r*r*r*n[0]+3*r*r*t*n[2]+3*r*t*t*n[4]+t*t*t*n[6],r*r*r*n[1]+3*r*r*t*n[3]+3*r*t*t*n[5]+t*t*t*n[7]]}function Un(e,t){let n=[0],r=e==="line"?1:kl,s={kind:e,p:t,len:0,table:n},i=xt(s,0);for(let a=1;a<=r;a++){let o=xt(s,a/r);n.push(n[a-1]+Math.hypot(o[0]-i[0],o[1]-i[1])),i=o}return s.len=n[r],s}function Vr(e,t){let n=e.table.length-1;if(t<=0)return 0;if(t>=e.len)return 1;let r=1;for(;e.table[r]<t;)r++;let s=e.table[r-1],i=e.table[r];return(r-1+(i>s?(t-s)/(i-s):0))/n}function Ml(e,t,n){let r=e.p;if(e.kind==="line")return[...xt(e,t),...xt(e,n)];let s=(a,o)=>{let l=a.length/2,c=[a];for(let d=1;d<l;d++){let p=c[d-1],_=[];for(let w=0;w<p.length-2;w+=2)_.push(p[w]+(p[w+2]-p[w])*o,p[w+1]+(p[w+3]-p[w+1])*o);c.push(_)}let u=[],f=[];for(let d=0;d<l;d++)u.push(c[d][0],c[d][1]);for(let d=l-1;d>=0;d--)f.push(c[d][c[d].length-2],c[d][c[d].length-1]);return[u,f]},[i]=n<1?s(r,n):[r];return t<=0?i:s(i,t/n)[1]}function qr(e){let t=[],n=null,r=0,s=0,i=0,a=0,o=0,l=e.points;for(let c of e.verbs)if(c===Ce.move)r=i=l[o++],s=a=l[o++],n={segs:[],closed:!1},t.push(n);else if(c===Ce.line){let u=l[o++],f=l[o++];n.segs.push(Un("line",[r,s,u,f])),r=u,s=f}else if(c===Ce.quad){let u=[r,s,l[o],l[o+1],l[o+2],l[o+3]];o+=4,n.segs.push(Un("quad",u)),r=u[4],s=u[5]}else if(c===Ce.cubic){let u=[r,s,l[o],l[o+1],l[o+2],l[o+3],l[o+4],l[o+5]];o+=6,n.segs.push(Un("cubic",u)),r=u[6],s=u[7]}else c===Ce.close&&(n&&((r!==i||s!==a)&&n.segs.push(Un("line",[r,s,i,a])),n.closed=!0),r=i,s=a);return t.filter(c=>c.segs.length>0)}function Sl(e){let t=0,n=0,r=0,s=0,i=0,a=0,o=e.points,l=(c,u)=>{t+=i*u-c*a,i=c,a=u};for(let c of e.verbs)if(c===Ce.move)l(r,s),r=i=o[n++],s=a=o[n++];else if(c!==Ce.close){let u=c===Ce.line?1:c===Ce.quad?2:3;for(let f=0;f<u;f++,n+=2)l(o[n],o[n+1])}return l(r,s),t/2}function El(e){let t=new rt,n=e.points,r=0,s=0,i=e.verbs;for(;s<i.length;){if(i[s]!==Ce.move){s++;continue}let a=n[r++],o=n[r++],l=[],c=!1;for(s++;s<i.length&&i[s]!==Ce.move;s++){let u=i[s];if(u===Ce.close){c=!0;continue}let f=u===Ce.line?1:u===Ce.quad?2:3,d=[a,o];for(let p=0;p<f;p++,r+=2)d.push(n[r],n[r+1]);a=d[d.length-2],o=d[d.length-1],l.push({v:u,p:d})}t.moveTo(a,o);for(let u=l.length-1;u>=0;u--){let{v:f,p:d}=l[u];f===Ce.line?t.lineTo(d[0],d[1]):f===Ce.quad?t.quadTo(d[2],d[3],d[0],d[1]):t.cubicTo(d[4],d[5],d[2],d[3],d[0],d[1])}c&&t.close()}return t.build()}function oi(e){let t=qr(e);return t.length>0&&t.every(n=>n.closed)}function sa(e,t,n,r){let s=0,i=!1;for(let a of e){let o=s,l=s+a.len;if(s=l,l<=t||o>=n)continue;let c=Ml(a,Vr(a,t-o),Vr(a,n-o));i||(r.moveTo(c[0],c[1]),i=!0),a.kind==="line"?r.lineTo(c[2],c[3]):a.kind==="quad"?r.quadTo(c[2],c[3],c[4],c[5]):r.cubicTo(c[2],c[3],c[4],c[5],c[6],c[7])}return i}function zr(e,t,n){let r=qr(e),s=r.reduce((u,f)=>u+f.segs.reduce((d,p)=>d+p.len,0),0);if(s<=0)return e;let i=t*s,a=n*s,o=new rt,l=0,c=!1;for(let u of r){let f=u.segs.reduce((_,w)=>_+w.len,0),d=l,p=l+f;l=p,p>i&&d<a&&(c=sa(u.segs,Math.max(0,i-d),Math.min(f,a-d),o)||c)}return c?o.build():{verbs:new Uint8Array(0),points:new Float32Array(0)}}function Al(e,t){let n=e.p,r=1-t;return e.kind==="line"?[n[2]-n[0],n[3]-n[1]]:e.kind==="quad"?[2*(r*(n[2]-n[0])+t*(n[4]-n[2])),2*(r*(n[3]-n[1])+t*(n[5]-n[3]))]:[3*(r*r*(n[2]-n[0])+2*r*t*(n[4]-n[2])+t*t*(n[6]-n[4])),3*(r*r*(n[3]-n[1])+2*r*t*(n[5]-n[3])+t*t*(n[7]-n[5]))]}function Tl(e){return qr(e).map(t=>{let n=t.segs.filter(s=>s.len>0),r=n.reduce((s,i)=>s+i.len,0);return{length:r,closed:t.closed,posTan(s){s=Math.max(0,Math.min(r,s));let i=0,a=n[n.length-1];for(let p of n){if(i+p.len>=s){a=p;break}i+=p.len}let o=Vr(a,s-i),[l,c]=xt(a,o),[u,f]=Al(a,o);if(Math.hypot(u,f)<1e-9){let p=xt(a,Math.max(0,o-.001)),_=xt(a,Math.min(1,o+.001));u=_[0]-p[0],f=_[1]-p[1]}let d=Math.hypot(u,f)||1;return[l,c,u/d,f/d]},segment:(s,i,a)=>sa(n,s,i,a)}}).filter(t=>t.length>0)}var Gn=.001;function Pl(e,t){let n=0,r=!1;for(let i of e)n+=i.length,i.closed||(r=!0);let s=Vi.dashScale(t,{length:n,closed:!0},n);return s===null?null:{scale:s,total:n,open:r}}function ia(e,t,n){return e.closed?n.scale:Vi.dashScale(t,{length:e.length,closed:!1},n.total)??n.scale}function aa(e,t,n,r){let s=t.map(p=>p*r),i=s.reduce((p,_)=>p+_,0),a=[];if(!(i>0))return a;let o=(n*r%i+i)%i,l=0,c=0;for(;c+s[l]<=o&&l<s.length&&!(s[l]<=Gn&&Math.abs(o-c)<1e-6||(c+=s[l],l=(l+1)%s.length,l===0)););let u=s[l]-(o-c),f=l%2===0,d=0;for(;d<e.length-1e-6;){let p=Math.min(u,e.length-d);f&&a.push([d,d+p]),d+=p,u-=p,u<=1e-6&&(l=(l+1)%s.length,u=s[l],f=!f)}return f&&u<=1e-6&&!e.closed&&a.push([e.length,e.length]),a}function Il(e,t,n,r,s){let i=new rt,a=!1;for(let o of e)for(let[l,c]of aa(o,t,n,ia(o,t,s)))if(c-l>Gn)a=o.segment(l,c,i)||a;else if(r){let[u,f,d,p]=o.posTan(l),_=l>o.length-Gn?-.001:Gn;i.moveTo(u,f).lineTo(u+d*_,f+p*_),a=!0}return a?i.build():null}function oa(e,t,n,r,s,i,a,o,l,c){if(r===0||s===0){e.lineTo(l,c);return}r=Math.abs(r),s=Math.abs(s);let u=Math.cos(i),f=Math.sin(i),d=(t-l)/2,p=(n-c)/2,_=u*d+f*p,w=-f*d+u*p,A=_*_/(r*r)+w*w/(s*s);A>1&&(r*=Math.sqrt(A),s*=Math.sqrt(A));let B=r*r*s*s-r*r*w*w-s*s*_*_,L=r*r*w*w+s*s*_*_,V=Math.sqrt(Math.max(0,B/L));a===o&&(V=-V);let se=V*r*w/s,X=-V*s*_/r,pe=u*se-f*X+(t+l)/2,ue=f*se+u*X+(n+c)/2,q=(Me,Fe,de,Ae)=>Math.atan2(Me*Ae-Fe*de,Me*de+Fe*Ae),ae=q(1,0,(_-se)/r,(w-X)/s),G=q((_-se)/r,(w-X)/s,(-_-se)/r,(-w-X)/s);!o&&G>0?G-=2*Math.PI:o&&G<0&&(G+=2*Math.PI);let $=Math.ceil(Math.abs(G)/(Math.PI/2)-1e-9),xe=G/$,ve=4/3*Math.tan(xe/4);for(let Me=0;Me<$;Me++){let Fe=ae+Me*xe,de=Fe+xe,Ae=Math.cos(Fe),De=Math.sin(Fe),At=Math.cos(de),Tt=Math.sin(de),xn=pe+r*Ae*u-s*De*f,kn=ue+r*Ae*f+s*De*u,Mn=pe+r*At*u-s*Tt*f,qt=ue+r*At*f+s*Tt*u,Sn=-r*De*u-s*Ae*f,sr=-r*De*f+s*Ae*u,v=-r*Tt*u-s*At*f,Te=-r*Tt*f+s*At*u;e.cubicTo(xn+ve*Sn,kn+ve*sr,Mn-ve*v,qt-ve*Te,Me===$-1?l:Mn,Me===$-1?c:qt)}}function gn(e){let t=new rt,n=e.match(/[a-zA-Z]|-?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g)??[],r=0,s="",i=0,a=0,o=0,l=0,c=0,u=0,f=0,d=0,p="",_=()=>Number(n[r++]),w=()=>r<n.length&&!/[a-zA-Z]/.test(n[r]);for(;r<n.length;){/[a-zA-Z]/.test(n[r])&&(s=n[r++]);let A=s===s.toLowerCase(),B=s.toUpperCase(),L=A?i:0,V=A?a:0;switch(B){case"M":i=L+_(),a=V+_(),t.moveTo(i,a),o=i,l=a,s=A?"l":"L";break;case"L":i=L+_(),a=V+_(),t.lineTo(i,a);break;case"H":i=(A?i:0)+_(),t.lineTo(i,a);break;case"V":a=(A?a:0)+_(),t.lineTo(i,a);break;case"C":{let se=L+_(),X=V+_(),pe=L+_(),ue=V+_();i=L+_(),a=V+_(),t.cubicTo(se,X,pe,ue,i,a),c=pe,u=ue;break}case"S":{let se=p==="C"||p==="S",X=se?2*i-c:i,pe=se?2*a-u:a,ue=L+_(),q=V+_();i=L+_(),a=V+_(),t.cubicTo(X,pe,ue,q,i,a),c=ue,u=q;break}case"Q":f=L+_(),d=V+_(),i=L+_(),a=V+_(),t.quadTo(f,d,i,a);break;case"T":{let se=p==="Q"||p==="T";f=se?2*i-f:i,d=se?2*a-d:a,i=L+_(),a=V+_(),t.quadTo(f,d,i,a);break}case"A":{let se=_(),X=_(),pe=_()*Math.PI/180,ue=_()!==0,q=_()!==0,ae=L+_(),G=V+_();oa(t,i,a,se,X,pe,ue,q,ae,G),i=ae,a=G;break}case"Z":t.close(),i=o,a=l;break;default:r++}p=B,B==="Z"&&w()&&(s="L")}return t.build()}var Rl=class{parts=[];move(e,t){this.parts.push(`M ${e} ${t}`)}line(e,t){this.parts.push(`L ${e} ${t}`)}arc(e,t,n,r,s,i){this.parts.push(`A ${e} ${t} 0 ${n} ${r} ${s} ${i}`)}close(){this.parts.push("Z")}toString(){return this.parts.join(" ")}},Cl=class{ok=!0;b=new rt;empty=!0;x=0;y=0;sx=0;sy=0;move(e,t){this.check(e,t),this.x=this.sx=0+e,this.y=this.sy=0+t,this.b.moveTo(this.x,this.y)}line(e,t){this.check(e,t),this.x=0+e,this.y=0+t,this.b.lineTo(this.x,this.y)}arc(e,t,n,r,s,i){this.check(e,t,s,i);let a=0+s,o=0+i;oa(this.b,this.x,this.y,e+0,t+0,0,n!==0,r!==0,a,o),this.x=a,this.y=o}close(){this.empty=!1,this.b.close(),this.x=this.sx,this.y=this.sy}result(){return this.empty?null:this.b.build()}check(...e){this.empty=!1;for(let t of e)Number.isFinite(t)||(this.ok=!1)}};function Je(e){let t=new Rl;return e(t),t.toString()}function ca(e){let t=new Cl;if(e(t),t.ok)return t.result();let n=Je(e);return n?gn(n):null}var Gt=class{fullState;geo;constructor(e){this.fullState=this.resolveState(e)}buildPathData(e){let t=this.buildSVGPath(e);return t?gn(t):null}get geometry(){return this.geo??=this.computeGeometry()}needsTrim(){return this.fullState.start!==0||this.fullState.end!==1}getTrimRange(){return{start:this.fullState.start,end:this.fullState.end}}buildSVGAlignInterior(e){return null}supportsSpread(){return!1}buildSpreadSVGPath(e,t){return null}computeBounds(e){}};function ct(e){return e.radius>0?e.radius:0}function Nn(e,t,n,r,s,i,a,o){o.radius<=0||la(e,t,n,r,s,i,a,o.radius,o.radius,o.style)}function la(e,t,n,r,s,i,a,o,l,c){let u=t+i*o,f=n+a*o;if(c==="angled")return e.line(u,f);let d=r*a-s*i;e.arc(l,l,0,d<0?1:0,u,f)}function Ol(e,t,n,r,s,i,a,o,l){return Je(c=>la(c,e,t,n,r,s,i,a,o,l))}var lt=Math.PI/180,Jr=class extends Gt{resolveState(e){return _c(e)}computeGeometry(){let e=this.fullState,t=e.sweep??360;return{cx:e.x,cy:e.y,halfWidth:e.width/2,halfHeight:e.height/2,sweep:t,isFullShape:Math.abs(t)>=360,startAngle:e.startAngle??0,ratio:Math.max(0,Math.min(1,e.ratio??0))}}buildSVGPath(e){return Je(t=>ci(t,e))}buildPathData(e){return ca(t=>ci(t,e))}ringOutline(e){return e.ratio<1?null:Je(t=>e.isFullShape?pn(t,e.cx,e.cy,e.halfWidth,e.halfHeight,0):Dl(t,e))}buildSVGAlignInterior(e){return e.isFullShape?e.ratio>=1?Je(t=>pn(t,e.cx,e.cy,e.halfWidth,e.halfHeight,0)):null:Je(t=>e.ratio>=1||e.ratio<=0?ua(t,e):fa(t,e))}supportsSpread(){return!0}buildSpreadSVGPath(e,t){if(!e.isFullShape||e.ratio>=1)return null;let n=e.halfWidth+t,r=e.halfHeight+t;return n<=0||r<=0?null:Je(s=>pn(s,e.cx,e.cy,n,r,0))}computeBounds(e){let{cx:t,cy:n,halfWidth:r,halfHeight:s}=e;return{left:t-r,top:n-s,right:t+r,bottom:n+s}}};function ci(e,t){let{cx:n,cy:r,halfWidth:s,halfHeight:i,ratio:a}=t;if(!(a>=1)){if(!t.isFullShape)return a<=0?ua(e,t):fa(e,t);pn(e,n,r,s,i,0),a>0&&pn(e,n,r,s*a,i*a,1)}}function pn(e,t,n,r,s,i){let a=t-r,o=t+r;e.move(a,n),e.arc(r,s,1,i,o,n),e.arc(r,s,1,i,a,n),e.close()}function Yr(e){let{cx:t,cy:n,halfWidth:r,halfHeight:s,startAngle:i,sweep:a}=e,o=i+a,l=Math.abs(a)>180?1:0,c=a>0?1:0,u=t+r*Math.cos(i*lt),f=n+s*Math.sin(i*lt),d=t+r*Math.cos(o*lt),p=n+s*Math.sin(o*lt);return{sx:u,sy:f,arc:_=>_.arc(r,s,l,c,d,p)}}function Dl(e,t){let{sx:n,sy:r,arc:s}=Yr(t);e.move(n,r),s(e)}function ua(e,t){let{sx:n,sy:r,arc:s}=Yr(t);e.move(t.cx,t.cy),e.line(n,r),s(e),e.close()}function fa(e,t){let{cx:n,cy:r,halfWidth:s,halfHeight:i,startAngle:a,sweep:o,ratio:l}=t,{sx:c,sy:u,arc:f}=Yr(t),d=a+o,p=s*l,_=i*l,w=n+p*Math.cos(a*lt),A=r+_*Math.sin(a*lt),B=n+p*Math.cos(d*lt),L=r+_*Math.sin(d*lt),V=Math.abs(o)>180?1:0,se=o>0?0:1;e.move(c,u),f(e),e.line(B,L),e.arc(p,_,V,se,w,A),e.close()}function Ll(e,t,n){if(e.length===0)return"M 0 0";if(e.length===1)return`M ${e[0].x} ${e[0].y}`;let r=Math.max(0,t),s=[],i=e.length,a=(o,l)=>{let c=l.x-o.x,u=l.y-o.y,f=Math.sqrt(c*c+u*u);return f>0?{dx:c/f,dy:u/f,len:f}:{dx:0,dy:0,len:0}};if(r===0){s.push(`M ${e[0].x} ${e[0].y}`);for(let o=1;o<i;o++)s.push(`L ${e[o].x} ${e[o].y}`)}else{let o=n?i:i-1;for(let l=0;l<=o;l++){let c=e[(l-1+i)%i],u=e[l%i],f=e[(l+1)%i];if(!n&&l===0){s.push(`M ${u.x} ${u.y}`);continue}if(!n&&l===i-1){s.push(`L ${u.x} ${u.y}`);continue}let d=a(c,u),p=a(u,f),_=Math.min(r,d.len/2),w=Math.min(r,p.len/2),A=u.x-d.dx*_,B=u.y-d.dy*_,L=u.x+p.dx*w,V=u.y+p.dy*w;s.push(`${l===0&&n?"M":"L"} ${A} ${B}`),s.push(`Q ${u.x} ${u.y} ${L} ${V}`)}}return n&&s.push("Z"),s.join(" ")}var Fl=class extends Gt{resolveState(e){return mc(e)}computeGeometry(){let{points:e,radius:t,closed:n}=this.fullState;return{points:e,radius:t,closed:n}}buildSVGPath(e){return Ll(e.points,e.radius,e.closed)}},Bl=class extends Gt{resolveState(e){return gc(e)}computeGeometry(){return{data:this.fullState.data}}buildSVGPath(e){return Hi(e.data)}};function da(e,t,n){if(t.cornerRadius<=0){let i=e.map(([a,o],l)=>`${l===0?"M":"L"} ${a} ${o}`);return i.push("Z"),i.join(" ")}let r=e.length,s=[];for(let i=0;i<r;i++){let a=e[i];if(!n(i)){s.push(`${s.length===0?"M":"L"} ${a[0]} ${a[1]}`);continue}let o=e[(i-1+r)%r],l=e[(i+1)%r],c=o[0]-a[0],u=o[1]-a[1],f=Math.hypot(c,u),d=c/f,p=u/f,_=l[0]-a[0],w=l[1]-a[1],A=Math.hypot(_,w),B=_/A,L=w/A,V=Math.max(-1,Math.min(1,d*B+p*L)),se=Math.tan(Math.acos(V)/2),X=Math.min(t.cornerRadius/se,Math.min(f,A)/2),pe=X*se;s.push(`${s.length===0?"M":"L"} ${a[0]+d*X} ${a[1]+p*X}`),s.push(Ol(a[0],a[1],d,p,B,L,X,pe,t.cornerStyle))}return s.push("Z"),s.join(" ")}var ha=e=>({left:e.cx-e.rx,top:e.cy-e.ry,right:e.cx+e.rx,bottom:e.cy+e.ry}),$l=class extends Gt{resolveState(e){return bc(e)}computeGeometry(){let e=this.fullState;return{cx:e.x,cy:e.y,rx:e.width/2,ry:e.height/2,sides:Math.max(3,Math.round(e.sides)),ratio:1,cornerRadius:e.cornerRadius,cornerStyle:e.cornerStyle}}buildSVGPath(e){let t=2*Math.PI/e.sides,n=[];for(let r=0;r<e.sides;r++){let s=-Math.PI/2+r*t;n.push([e.cx+e.rx*Math.cos(s),e.cy+e.ry*Math.sin(s)])}return da(n,e,()=>!0)}computeBounds(e){return ha(e)}},Ul=class extends Gt{resolveState(e){return wc(e)}computeGeometry(){let e=this.fullState;return{cx:e.x,cy:e.y,rx:e.width/2,ry:e.height/2,sides:Math.max(3,Math.round(e.sides)),ratio:Math.max(0,Math.min(1,e.ratio)),cornerRadius:e.cornerRadius,cornerStyle:e.cornerStyle}}buildSVGPath(e){let t=Math.PI/e.sides,n=[];for(let r=0;r<e.sides*2;r++){let s=-Math.PI/2+r*t,i=r%2===0?1:e.ratio;n.push([e.cx+e.rx*i*Math.cos(s),e.cy+e.ry*i*Math.sin(s)])}return da(n,e,r=>r%2===0)}computeBounds(e){return ha(e)}};function pa(e,t,n,r,s,i,a,o,l){let c=ct(i),u=ct(a),f=ct(o),d=ct(l);e.move(t+c,n),e.line(r-u,n),Nn(e,r,n,-1,0,0,1,a),e.line(r,s-f),Nn(e,r,s,0,-1,-1,0,o),e.line(t+d,s),Nn(e,t,s,1,0,0,-1,l),e.line(t,n+c),Nn(e,t,n,0,1,1,0,i),e.close()}function _a(e,t,n,r,s){e.move(t,n),e.line(r,n),e.line(r,s),e.line(t,s),e.close()}function li(e,t){let{left:n,top:r,right:s,bottom:i,tl:a,tr:o,br:l,bl:c,isZero:u}=t;u?_a(e,n,r,s,i):pa(e,n,r,s,i,a,o,l,c)}var ma=class extends Gt{resolveState(e){return yc(e)}computeGeometry(){let e=this.fullState,t=e.x-e.width/2,n=e.y-e.height/2,r=e.x+e.width/2,s=e.y+e.height/2,i=Gs.resolve(e.cornerRadius),a=qo.resolve(e.cornerStyle),o={radius:Math.max(0,i.topLeft),style:a.topLeft},l={radius:Math.max(0,i.topRight),style:a.topRight},c={radius:Math.max(0,i.bottomRight),style:a.bottomRight},u={radius:Math.max(0,i.bottomLeft),style:a.bottomLeft},f=ui(e.width,e.height,o,l,c,u);return o.radius*=f,l.radius*=f,c.radius*=f,u.radius*=f,{left:t,top:n,right:r,bottom:s,tl:o,tr:l,br:c,bl:u,isZero:Gs.isZero({topLeft:o.radius,topRight:l.radius,bottomRight:c.radius,bottomLeft:u.radius})}}buildSVGPath(e){return Je(t=>li(t,e))}buildPathData(e){return ca(t=>li(t,e))}supportsSpread(){return!0}buildSpreadSVGPath(e,t){let n=e.left-t,r=e.top-t,s=e.right+t,i=e.bottom+t,a=s-n,o=i-r;if(a<=0||o<=0)return null;let l={...e.tl,radius:Math.max(0,e.tl.radius+t)},c={...e.tr,radius:Math.max(0,e.tr.radius+t)},u={...e.br,radius:Math.max(0,e.br.radius+t)},f={...e.bl,radius:Math.max(0,e.bl.radius+t)},d=ui(a,o,l,c,u,f);return l.radius*=d,c.radius*=d,u.radius*=d,f.radius*=d,l.radius===0&&c.radius===0&&u.radius===0&&f.radius===0?Je(p=>_a(p,n,r,s,i)):Je(p=>pa(p,n,r,s,i,l,c,u,f))}computeBounds(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}};function ui(e,t,n,r,s,i){let a=ct(n),o=ct(r),l=ct(s),c=ct(i),u=a+o>0?Math.min(1,e/(a+o)):1,f=c+l>0?Math.min(1,e/(c+l)):1,d=a+c>0?Math.min(1,t/(a+c)):1,p=o+l>0?Math.min(1,t/(o+l)):1;return Math.min(u,f,d,p)}function fn(e,t,n){let r=ic(e,t,n),{x:s,y:i,pivot:a}=oc(r,t,n);return{...hc(r),x:s,y:-i,pivot:a}}var ga=e=>e==null?e:-e;function ba(e,t){let n=new Float32Array(e.points.length);for(let r=0;r<n.length;r+=2){let s=e.points[r],i=e.points[r+1];n[r]=t[0]*s+t[2]*i+t[4],n[r+1]=t[1]*s+t[3]*i+t[5]}return{...e,points:n}}function Xr(e,t){let n=e.rotation??0,r=e.scale??1;if(n===0&&r===1)return t;let s=e.pivot??{x:0,y:0},i=(e.x??0)+s.x*((e.width??0)/2),a=(e.y??0)-s.y*((e.height??0)/2),o=n*Math.PI/180,l=Math.cos(o)*r,c=Math.sin(o)*r,u=l,f=-c,d=c,p=l;return ba(t,[u,d,f,p,i-u*i-f*a,a-d*i-p*a])}var Nl={left:"left",right:"right",center:"center",justify:"justify",start:"left",end:"right"};function jl(e,t){let n=Ki(fn(e,e.width??0,e.height??0)),r=n.path!=null?gn(Hi(n.path)):void 0,s=n.fontSize==="autofit",i={runs:[{text:n.text,family:n.fontFamily,size:s?100:n.fontSize,weight:n.fontWeight,italic:n.fontStyle==="italic"||n.fontStyle==="oblique",letterSpacing:n.letterSpacing,decoration:n.textDecoration==="underline"?"underline":n.textDecoration==="line-through"?"lineThrough":void 0}],align:Nl[n.textAlign]??"left",verticalAlign:n.verticalAlign,wrap:n.wrap&&n.width>0,width:n.width,height:n.height,lineHeight:n.lineHeight,fontSize:s?"autofit":void 0,minFontSize:n.minFontSize,path:r};if(r)return{spec:i,transform:[1,0,0,1,0,0],size:[n.width,n.height]};let[a,o]=t(i),l=cc(n.pivot),c=n.width>0&&n.height>0,u=c?n.width:a,f=c?n.height:o,d=!c&&l.x!==0?n.x-l.x*(a/2):n.x,p=!c&&l.y!==0?n.y+l.y*(o/2):n.y,_=[1,0,0,1,d,p];if((n.rotation??0)!==0||(n.scale??1)!==1){let w=d+l.x*(u/2),A=p-l.y*(f/2),B=(n.rotation??0)*Math.PI/180,L=n.scale??1,V=Math.cos(B)*L,se=Math.sin(B)*L;_=[V,se,-se,V,w+V*(d-w)-se*(p-A),A+se*(d-w)+V*(p-A)]}return{spec:i,transform:_,size:[u,f]}}function Mr(e,t){return e?Xr(t,gn(e)):null}function tn(e,t){let n=new e(t),r=n.fullState,s=n.geometry,i=n.needsTrim()?n.getTrimRange():null,a=jn(()=>{let d=n.buildPathData(s);return d&&Xr(r,d)}),o=jn(()=>{let d=a();return d&&i?zr(d,i.start,i.end):d}),l=jn(()=>{let d=n instanceof Jr?n.ringOutline(s):null;if(d==null)return o();let p=Mr(d,r);return p&&i?zr(p,i.start,i.end):p}),c=jn(()=>{let d=n.buildSVGAlignInterior(s);return d!=null?Mr(d,r):i?a():o()}),u=n.computeBounds(s),f=n.supportsSpread()?d=>Mr(n.buildSpreadSVGPath(s,d),r):void 0;return{get fill(){return o()},get stroke(){return l()},get interior(){return c()},bounds:u?[u.left,u.top,u.right,u.bottom]:null,spread:f,trimmed:!!i,native:i?void 0:Wl(n,r,s)}}function jn(e){let t=!1,n;return()=>(t||(n=e(),t=!0),n)}function Wl(e,t,n){if(!((t.rotation??0)!==0||(t.scale??1)!==1)){if(e instanceof Jr){if(!n.isFullShape||n.ratio>0)return;let r=n.halfWidth*2,s=n.halfHeight*2;return!(r>0&&s>0)||!Number.isFinite(r+s+n.cx+n.cy)?void 0:{kind:"ellipse",x:n.cx-n.halfWidth,y:n.cy-n.halfHeight,w:r,h:s,radii:[0,0,0,0]}}if(e instanceof ma){let r=n.right-n.left,s=n.bottom-n.top;if(!(r>0&&s>0)||!Number.isFinite(r+s+n.left+n.top))return;let i=[n.tl,n.tr,n.br,n.bl],a=Math.min(r,s)/2;return i.some(o=>!(o.radius>=0&&o.radius<=a)||o.radius>0&&o.style==="angled")?void 0:{kind:"rect",x:n.left,y:n.top,w:r,h:s,radii:i.map(o=>o.radius)}}}}function Vl(e){let t=new Bl(e),n=t.fullState,r=gn(t.buildSVGPath(t.geometry)),[s,i,a,o]=n.centerBounds??it(r),l=ba(r,[1,0,0,1,-(s+(a-s)/2),-(i+(o-i)/2)]),c=Xr({...n,x:0,y:0},l),u=t.needsTrim()?t.getTrimRange():null,f=u?zr(c,u.start,u.end):c;return{fill:f,stroke:f,interior:u?c:f,bounds:null,trimmed:!!u}}var zl=e=>{let t={...e,y:ga(e.y)};if(Array.isArray(e.data)&&(t.data=e.data.map(n=>{switch(n.type){case"M":case"m":case"L":case"l":case"T":case"t":case"V":case"v":return{...n,y:-n.y};case"C":case"c":return{...n,y1:-n.y1,y2:-n.y2,y:-n.y};case"S":case"s":return{...n,y2:-n.y2,y:-n.y};case"Q":case"q":return{...n,y1:-n.y1,y:-n.y};case"A":case"a":return{...n,y:-n.y,sweep:n.sweep===1?0:1};default:return n}}),e.centerBounds)){let[n,r,s,i]=e.centerBounds;t.centerBounds=[n,-i,s,-r]}return t};function Sr(e){let t=e.state;switch(e.kind){case"rect":return tn(ma,fn(t,t.width??0,t.height??0));case"ellipse":{let n=fn(t,t.width??0,t.height??0);return t.startAngle!=null&&(n.startAngle=-t.startAngle),t.sweep!=null&&(n.sweep=-t.sweep),tn(Jr,n)}case"polygon":return tn($l,fn(t,t.width??0,t.height??0));case"polygram":return tn(Ul,fn(t,t.width??0,t.height??0));case"line":{let n=t.points?t.points.map(r=>({x:r.x,y:-r.y})):t.points;return tn(Fl,{...t,y:ga(t.y),points:n})}case"path":return Vl(zl(t))}return null}function Gl(e,t,n){if(n<=0||e.strength<=0||e.length<=0)return null;let r=kt(e.axis),s=e.length/100,i=t.x*n*r.x*s*e.strength,a=t.y*n*r.y*s*e.strength,o=Math.hypot(i,a);return o<.01?null:{angle:Math.atan2(a,i)*180/Math.PI,radius:o,phase:sc(e.alignment),samples:e.samples}}var ut=.5,wa=Math.hypot(1,ut),fi=ut/wa,Hl=1/wa,Kl=.35;function ya(e){return e==="arrow"||e==="triangle"||e==="stealth"}function ql(e,t,n){return ya(e)?Math.min(t,n/(2*ut)):0}function Jl(e,t,n){let r=t/2;switch(e){case"dot":return null;case"triangle":return[0,0,-t,t*ut,-t,-t*ut];case"stealth":return[0,0,-t,t*ut,-t*(1-Kl),0,-t,-t*ut];case"arrow":return Yl(t,n);case"box":return[-r,-r,r,-r,r,r,-r,r];case"diamond":return[r,0,0,r,-r,0,0,-r];case"bar":return[-n/2,-r,n/2,-r,n/2,r,-n/2,r]}}function Yl(e,t){let n=e*ut,r=-e-t*fi,s=n-t*Hl;if(s<=0)return[0,0,-e,n,-e,-n];let i=-t/fi;return[0,0,-e,n,r,s,i,0,r,-s,-e,-n]}function Xl(e,t,n,r){let s=!!e.dash?.length,i=e.startCap??e.cap,a=e.endCap??e.cap,o=s?e.cap:Wt(a)?"butt":a,l=i!==o||a!==o;if(!s&&!l)return{cap:o,ends:[]};let c=Tl(t),u=s?Pl(c,e.dash):null;if(s&&!u)return{cap:o,ends:l?Er(c,e,i,a,o,n,null):[]};if(!u)return{cap:o,ends:Er(c,e,i,a,o,n,null)};let d=l?Er(c,e,i,a,o,n,p=>aa(p,e.dash,e.dashOffset??0,ia(p,e.dash,u))):[];if(r||d.length||u.open){let p=Il(c,e.dash,e.dashOffset??0,e.cap!=="butt",u);return p?{cap:o,ends:d,source:p}:null}return{cap:o,ends:d,dash:e.dash.map(p=>p*u.scale),dashPhase:(e.dashOffset??0)*u.scale}}function Er(e,t,n,r,s,i,a){let o=[],l=(Wt(n)?1:0)+(Wt(r)?1:0),c=i/2,u=Math.min(c,1)/2,f=t.cap!=="butt"?c:0;for(let d of e){if(d.closed)continue;let p=Math.min(t.capScale*i,d.length/Math.max(1,l)),_=a?.(d),w=A=>!_||_.some(([B,L])=>A>=B-f-1e-6&&A<=L+f+1e-6);n!==s&&di(o,d.posTan(0),d.posTan(p),-1,n,p,i,w(u)),r!==s&&di(o,d.posTan(d.length),d.posTan(d.length-p),1,r,p,i,w(d.length-u))}return o}function di(e,[t,n,r,s],i,a,o,l,c,u){let f=a*r,d=a*s;Wt(o)&&ya(o)&&Math.hypot(t-i[0],n-i[1])>1e-6&&(f=t-i[0],d=n-i[1]);let p=Math.hypot(f,d);p<1e-9||e.push({x:t,y:n,dx:f/p,dy:d/p,cap:o,size:l,weight:c,reached:u})}function Ar({x:e,y:t,dx:n,dy:r},s,i){let a=-r*i,o=n*i,l=n*s,c=r*s;return new rt().moveTo(e-a,t-o).lineTo(e-a+l,t-o+c).lineTo(e+a+l,t+o+c).lineTo(e+a,t+o).close().build()}function Zl({x:e,y:t,dx:n,dy:r},s){let i=new rt,a=32;for(let o=0;o<=a;o++){let l=-Math.PI/2+Math.PI*o/a,c=Math.cos(l)*s,u=Math.sin(l)*s,f=e+c*n-u*r,d=t+c*r+u*n;o===0?i.moveTo(f,d):i.lineTo(f,d)}return i.close().build()}function Ql(e,t){let{x:n,y:r,dx:s,dy:i,size:a,weight:o}=e,l=Jl(t,a,o),c=new rt;if(!l){let u=a/2,f=.5522848*u;return c.moveTo(n+u,r).cubicTo(n+u,r+f,n+f,r+u,n,r+u).cubicTo(n-f,r+u,n-u,r+f,n-u,r).cubicTo(n-u,r-f,n-f,r-u,n,r-u).cubicTo(n+f,r-u,n+u,r-f,n+u,r),c.close().build()}for(let u=0;u<l.length;u+=2){let f=n+l[u]*s-l[u+1]*i,d=r+l[u]*i+l[u+1]*s;u===0?c.moveTo(f,d):c.lineTo(f,d)}return c.close().build()}function pt(e){if(e.length===1)return e[0];let t=new Uint8Array(e.reduce((i,a)=>i+a.verbs.length,0)),n=new Float32Array(e.reduce((i,a)=>i+a.points.length,0)),r=0,s=0;for(let i of e)t.set(i.verbs,r),r+=i.verbs.length,n.set(i.points,s),s+=i.points.length;return{verbs:t,points:n}}var eu=class extends Set{node;nodes=new Map;constructor(e){super(),this.node=e}add(e){super.add(e);let t=this.node?.();if(t!==void 0){let n=this.nodes.get(e);n||this.nodes.set(e,n=new Set),n.add(t)}return this}clear(){super.clear(),this.nodes.clear()}},hi=new Set(["rect","ellipse","path","line","polygon","polygram","text","richText"]),pi=e=>e.type==="solid";function tu(e,t){if(t===0)return e;let n=e.w+2*t,r=e.h+2*t;return n>0&&r>0?e.kind==="ellipse"?{...e,x:e.x-t,y:e.y-t,w:n,h:r}:e.radii.some(s=>s>0&&!(s+t>0))?null:{...e,x:e.x-t,y:e.y-t,w:n,h:r,radii:e.radii.map(s=>s>0?s+t:0)}:null}var _t={kind:"solid",color:[0,0,0,1]},Lt={kind:"solid",color:[0,0,0,0]},_i=e=>[-e.size[0]/2,-e.size[1]/2,e.size[0]/2,e.size[1]/2],mi=(e,t)=>`${e}|${t.weight}|${t.align}|${t.join}|${t.cap}|${t.miterLimit}|${t.dash}|${t.dashOffset}`,gi={union:"union",subtract:"cut",intersect:"intersect",exclude:"exclude"};function Tr(e){let t=null;for(let n of e){let r=it(n.path),s=n.op??"union";t?s==="union"||s==="exclude"?t=[Math.min(t[0],r[0]),Math.min(t[1],r[1]),Math.max(t[2],r[2]),Math.max(t[3],r[3])]:s==="intersect"&&(t=[Math.max(t[0],r[0]),Math.max(t[1],r[1]),Math.min(t[2],r[2]),Math.min(t[3],r[3])],(t[2]<t[0]||t[3]<t[1])&&(t=[t[0],t[1],t[0],t[1]])):(s==="union"||s==="exclude")&&(t=r)}return t}function nu(e){let t=e[0]*e[3]-e[1]*e[2];if(!t)return null;let n=e[3]/t,r=-e[1]/t,s=-e[2]/t,i=e[0]/t;return[n,r,s,i,-(n*e[4]+s*e[5]),-(r*e[4]+i*e[5])]}var bi=1<<20;function Pr(e){let t=(e==="plus-lighter"?"plus":e).replace(/-(\w)/g,(n,r)=>r.toUpperCase());return qi.includes(t)?t:null}var wi=new WeakMap,ru=1<<24;function yi(e){let t=wi.get(e);return t===void 0&&wi.set(e,t=ru++),t}var va=class extends Go{width;height;measure;readsSpaceRects=!0;drawsVisibleOnly=!0;pixelRatio=1;doc;missing=new eu(()=>this.currentNodeStack[this.currentNodeStack.length-1]);shaderIssues=[];storage=null;images=new Map;frameImages=new Map;assets={image:e=>this.image(e),scene3d:(e,t,n,r)=>{let s=new Map;ec(e,o=>{if(tc(o)&&!s.has(o)){let l=this.surfaceOf(o);l&&s.set(o,l)}});let i=new Proxy({},{get:(o,l)=>typeof l=="string"?this.image(l)??void 0:void 0}),a=this.doc.addScene3D(e,t,n,{images:i,surfaces:s});return a.scale3d=r,a.version=++bi,a},video:(e,t)=>{let n=this.storage,r=t??this.videoTime(e);if(!n||r===null)return null;let s=n.videoFrame(e.src,r);if(!s)return null;let i=`${wt(e.src)}@${r.toFixed(6)}`,a=this.frameImages.get(i);return a||(a=this.doc.addImage(s,s.width,s.height,{mipmaps:!1}),a.version=yi(s),this.frameImages.set(i,a)),a},imageEdge:(e,t)=>this.storage?.wantImageEdge?.(e,t),deviceScale:()=>{let e=this.device();return Math.sqrt(Math.abs(e[0]*e[3]-e[1]*e[2]))},time:()=>this.elapsed(),checkShader:e=>this.checkShader("fill",e)};image=e=>{let t=wt(e),n=this.frameImages.get(t);if(n)return n;let r=this.images.get(t);return r?(n=this.doc.addImage(r.bitmap,r.width,r.height),n.version=yi(r.bitmap),this.frameImages.set(t,n),n):null};stack=[];scopes=[];worldAlpha=1;shapes=[];painted=!1;shadows=[];constructor(e,t,n){super(),this.width=e,this.height=t,this.measure=n}get cur(){return this.stack[this.stack.length-1]}measureText(e,t,n,r=400,s=0,i){return this.measure(e,t,n,r,s,i)}execute(e){this.doc=new Ji(this.width,this.height,this.clearColor()),this.frameImages.clear(),this.missing.clear(),this.shaderIssues.length=0;let t=this.doc.group(this.doc.root,{transform:this.rootTransform()}),n=this.frameGroup(t);this.stack=n===t?[t]:[t,n],this.scopes=[],this.worldAlpha=1,this.masks=[],this.cameras=[],this.clips=[],this.booleans=[],this.resetSurface(),e()}rootTransform(){return[1,0,0,1,this.width/2,this.height/2]}clearColor(){return[0,0,0,1]}frameGroup(e){return e}screenshot(){}unmount(){}begin(e){super.begin(e),this.scopes.push({groups:1,worldAlpha:this.worldAlpha}),this.stack.push(this.doc.group(this.cur)),this.resetSurface()}end(){let e=this.scopes.pop();if(e){for(let t=0;t<e.groups;t++)this.stack.pop();this.worldAlpha=e.worldAlpha}super.end()}transform(e){let t=e.x??0,n=e.y??0,r=e.width??0,s=e.height??0,i=e.opacity??1,a=e.blend??"pass-through",o,l=e.matrix;if(l)o=[l.a,l.b,l.c,l.d,l.e,l.f,l.g??0,l.h??0,l.i??1];else{let f=e.pivot??{x:0,y:0},d=f.x*(r/2),p=-f.y*(s/2),_=(e.rotation??0)*Math.PI/180,w=e.scale??1,A=Math.cos(_)*w,B=Math.sin(_)*w;o=[A,B,-B,A,t+d-(A*d-B*p),n+p-(B*d+A*p)]}let c=this.cur;c.transform=hr(c.transform,Vn(o)?o:o.slice(0,6));let u=this.motionBlur((e.effects??[]).filter(f=>f.mode!=="backdrop"));for(let f of u)f.type==="shader"&&this.checkShader("effect",f);if(u.length&&(c.effects=u,c.effectBox=[-r/2,-s/2,r,s],c.effectTime=this.elapsed()),a!=="pass-through"){let f=Pr(a);f||this.missing.add(`blend:${a}`),this.stack.push(this.doc.group(c,{opacity:this.worldAlpha*(i<1?i:1),blend:f??"normal"})),this.scopes[this.scopes.length-1].groups++,this.worldAlpha=1}else i<1&&(this.worldAlpha*=i);return this}resetSurface(){this.shapes=[],this.painted=!1,this.shadows=[]}drawGraphics(e){let t=this.worldAlpha,n=e;if(n.needsGroupLayer?.()){let c=n.groupOpacity();c<1&&(this.worldAlpha*=c)}let r=n.groupTransform?.(),s=null;if(r){let{x:c,y:u}=this.groupCenter(e,r.center),f=r.rotation*Math.PI/180,d=Math.cos(f)*r.scale,p=Math.sin(f)*r.scale;s=this.doc.group(this.cur,{transform:[d,p,-p,d,c-(d*c-p*u),u-(p*c+d*u)]}),this.stack.push(s)}let i=e.ops(),a=this.effectSegments(i),o=null;for(let c=0;c<i.length;c++){let u=i[c],f=a.get(c);switch(f&&(o=this.doc.group(this.cur,{effects:f,effectBox:this.viewportBox(),effectTime:this.elapsed()}),this.stack.push(o)),u.kind){case"rect":case"ellipse":case"polygon":case"polygram":case"line":case"path":{this.painted&&this.resetSurface();let d=Sr(u);if(!d)break;this.booleans.length?this.collect(d):this.shapes.push(d);break}case"cut":this.cut();break;case"richText":this.painted&&this.resetSurface(),this.richText(u.state);break;case"text":{this.painted&&this.resetSurface();let d=jl(u.state,_=>{let w=_.runs[0],A=this.measureText(w.text,w.size,w.family,w.weight,w.letterSpacing,w.italic?"italic":"normal");return[A.width,A.height]}),p=u.state.segments;if(d&&p?.length&&!d.spec.path)this.paintSegments(d,p);else if(d){let[_,w]=d.size,A=d.transform[4],B=d.transform[5];this.shapes.push({fill:null,stroke:null,interior:null,bounds:[A-_/2,B-w/2,A+_/2,B+w/2],text:d})}else this.missing.add("text:path");break}case"fill":this.fill(Qo.resolve(u.fills));break;case"stroke":this.stroke(pc.resolve(u.strokes));break;case"shadow":this.shadows=dc.resolve(u.shadows);break;case"effects":o&&(this.stack.splice(this.stack.lastIndexOf(o)),o=null),this.resetSurface();break;case"mask":this.beginMask(u.options);break;case"applyMask":this.applyMask();break;case"endMask":this.endMask();break;default:this.missing.add(`op:${u.kind}`)}}let l=s??o;l&&this.stack.splice(this.stack.lastIndexOf(l)),this.worldAlpha=t}effectSegments(e){let t=new Map,n=0,r=!1;return e.forEach((s,i)=>{if(hi.has(s.kind))r&&(n=i,r=!1);else if(s.kind==="fill"||s.kind==="stroke"||s.kind==="shadow")r=!0;else if(s.kind==="effects"){let a=this.motionBlur(s.effects.filter(o=>o.mode!=="backdrop"));a.length&&t.set(n,a),n=i+1,r=!1}}),t}motionBlur(e){if(!e.some(n=>n.type==="motionBlur"))return e;let t=this.currentRenderState();return e.flatMap(n=>{if(n.type!=="motionBlur")return[n];let r=t?Gl(n,t.velocity,t.dt):null;return r?((r.phase!==0||Math.round(r.samples)>32)&&this.missing.add("effect:motionBlur-shutter"),[{type:"directionalBlur",radius:r.radius,angle:r.angle}]):[]})}groupCenter(e,t){if(t!==void 0&&typeof t!="string")return{x:t.x,y:t.y};let n=null;for(let a of e.ops()){let o=hi.has(a.kind)&&a.kind!=="text"&&a.kind!=="richText"?Sr(a)?.fill:null;if(!o||!o.verbs.length)continue;let l=it(o);n=n?[Math.min(n[0],l[0]),Math.min(n[1],l[1]),Math.max(n[2],l[2]),Math.max(n[3],l[3])]:l}if(!n)return{x:0,y:0};let r=(n[0]+n[2])/2,s=(n[1]+n[3])/2;if(t===void 0)return{x:r,y:s};let i=Ko.resolve(t);return{x:r+i.x*((n[2]-n[0])/2),y:s-i.y*((n[3]-n[1])/2)}}viewportBox(){let[e,t,n,r]=this.spaceBounds({space:"global"},[0,0,0,0]);return[e,t,n-e,r-t]}surface(e){let t=this.shapes.map(n=>n[e]).filter(n=>!!n&&n.verbs.length>0);return e==="fill"&&t.length>1&&(t=t.map(n=>Sl(n)<0?El(n):n)),t.length?pt(t):null}bounds(e){let t=this.shapes.map(n=>n.bounds).filter(n=>n!==null);return e&&t.length!==this.shapes.length?it(e):t.length?t.reduce((n,r)=>[Math.min(n[0],r[0]),Math.min(n[1],r[1]),Math.max(n[2],r[2]),Math.max(n[3],r[3])]):[0,0,0,0]}leaf(e,t,n){return"members"in t?this.doc.compound(e,{...n,members:t.members}):this.doc.pathNode(e,{...n,path:t.path})}geomBounds(e){return"members"in e?Tr(e.members)??[0,0,0,0]:it(e.path)}spreadGeom(e,t,n){if(!t||"members"in e)return e;let r=[];for(let s of this.shapes){if(s.members||!s.fill||!s.fill.verbs.length)continue;let i=s.spread?s.spread(t):s.fill;i&&i.verbs.length?r.push(i):n||r.push(s.fill)}return r.length?{path:pt(r)}:null}clipTo(e,t){if("path"in t){let[r,s,i,a]=it(t.path);return this.doc.group(e,{clip:{x:r,y:s,w:i-r,h:a-s,r:0,path:t.path}})}let n=this.doc.group(e,{mask:"alpha"});return this.doc.compound(n,{members:t.members,fill:_t}),n}clipOutside(e,t){let n=this.doc.group(e,{mask:"invertAlpha"});return this.leaf(n,t,{fill:_t}),n}fill(e){this.painted=!0,!this.booleans.length&&this.deferring("fill",()=>this.paintFill(e))}deferring(e,t){let n=this.masks[this.masks.length-1],r=n?.apply&&!n.apply.has(e)&&!this.inVectorMask?n.after:null;if(!r)return t();this.stack.push(r);try{t()}finally{this.stack.splice(this.stack.lastIndexOf(r))}}paintFill(e){if(this.paintText(e,null),!e.length||this.fillNative(e))return;let t=this.surface("fill"),n=t?[{path:t}]:[];for(let i of this.shapes)i.members&&n.push({members:i.members});if(!n.length)return;let r=this.bounds(t),s=this.shadows;this.shadows=[];for(let i of n)this.fillGeom(i,r,e,s)}fillNative(e){let t=this.shapes.length===1?this.shapes[0]:null,n=t?.native;if(!t||!n||this.inVectorMask||this.shadows.length||!e.every(pi))return!1;for(let r of e){let s=He(r,t.bounds,this.missing,this.assets);s&&this.native(this.cur,n,{fill:s,opacity:this.worldAlpha*(r.opacity??1),blend:this.blendOf(r)})}return!0}strokeNative(e,t,n,r){let s=this.shapes.length===1?this.shapes[0]:null,i=s?.native;if(!s||!i||t<=0||(e.dash?.length??0)>0||!e.fill.every(pi)||i.kind==="ellipse"&&Math.abs(i.w-i.h)>.001||i.kind==="rect"&&i.radii.some(f=>f===0)&&(e.join!=="miter"||!(e.miterLimit>=Math.SQRT2)))return!1;let a=Math.max(-1,Math.min(1,e.align??0)),o=tu(i,a*t/2);if(!o)return!1;let l=s.bounds,c=this.snapBounds([Math.fround(l[0]),Math.fround(l[1]),Math.fround(l[2]),Math.fround(l[3])],n,r),u=c?this.doc.group(this.cur,{transform:c}):this.cur;for(let f of e.fill){let d=He(f,l,this.missing,this.assets);if(!d)continue;let p={paint:d,width:t,join:e.join,cap:e.cap,miter:e.miterLimit};this.native(u,o,{opacity:this.worldAlpha*(f.opacity??1),stroke:p,...a===0&&{blend:this.blendOf(f)}})}return!0}native(e,t,n){let r={...n,transform:[1,0,0,1,t.x,t.y],w:t.w,h:t.h,radii:t.radii};return t.kind==="rect"?this.doc.rect(e,r):this.doc.ellipse(e,r)}fillGeom(e,t,n,r){if(this.inVectorMask){this.leaf(this.cur,e,{fill:_t});return}let s=[];for(let i of r){if(i.inner)continue;if(i.fill.length===1&&i.fill[0].type==="solid"){let u=Ic(i,this.missing);u&&s.push(u);continue}let a=i.offset?.x??0,o=-(i.offset?.y??0),l=this.doc.group(this.cur,{transform:[1,0,0,1,a,o],filter:i.blur>0?{kind:"blur",sigma:i.blur/2}:void 0}),c=this.spreadGeom(e,i.spread??0,!1);for(let u of i.fill){let f=He(u,this.spaceBounds(u,t),this.missing,this.assets);f&&this.leaf(l,c,{fill:f,opacity:this.worldAlpha*(u.opacity??1)})}}n.forEach((i,a)=>{let o=this.spaceBounds(i,t),l=He(i,o,this.missing,this.assets);if(!l)return;let c=this.worldAlpha*(i.opacity??1),u=a===0?s:[],f=i.type==="video"?i.preset?.adjustments?.find(p=>p.type==="echo"):void 0;if(f&&f.echoes>0&&f.delay>0){this.echoStack(e,i,o,t,l,c,u,f);return}let d=i.preset?.intensity??1;if(d>0&&d<1&&this.pixelAdjustments(i).length){let p=this.doc.group(this.cur,{opacity:c,blend:this.blendOf(i)});this.mediaPreset(this.leaf(p,e,{fill:l,shadows:u}),i,t),this.leaf(p,e,{fill:l,opacity:1-d});return}this.mediaPreset(this.leaf(this.cur,e,{fill:l,opacity:c,shadows:u,blend:this.blendOf(i)}),i,t)});for(let i of r){if(!i.inner)continue;let a=this.spreadGeom(e,-(i.spread??0),!0),o=i.offset?.x??0,l=-(i.offset?.y??0),[c,u,f,d]=this.geomBounds(e),p=Math.abs(o)+Math.abs(l)+i.blur*2+2,_=this.clipTo(this.cur,e);for(let w of i.fill){let A=He(w,this.spaceBounds(w,t),this.missing,this.assets);if(!A)continue;let B=this.doc.group(_,{opacity:this.worldAlpha*(w.opacity??1),filter:i.blur>0?{kind:"blur",sigma:i.blur/2}:void 0}),L=this.doc.group(B,a?{mask:"invertAlpha"}:{});a&&this.leaf(L,a,{transform:[1,0,0,1,o,l],fill:_t}),this.doc.rect(L,{transform:[1,0,0,1,c-p,u-p],w:f-c+2*p,h:d-u+2*p,fill:A})}}}richText(e){let t=vc(e),n=t.spans;if(!n.length)return;let r=[-t.width/2,-t.height/2,t.width/2,t.height/2],s={kind:"solid",color:[0,0,0,0]},i=u=>(u[0]?He(u[0],r,this.missing,this.assets):null)??s,a=n.map(u=>({text:u.text,family:u.fontFamily,size:u.fontSize,weight:u.fontWeight,italic:u.fontStyle==="italic"||u.fontStyle==="oblique",letterSpacing:u.letterSpacing})),o={runs:a,align:{start:"left",end:"right"}[t.textAlign]??t.textAlign,wrap:t.width>0,width:t.width,lineHeight:t.lineHeight},l=Math.max(1,...n.map(u=>u.fill.length));for(let u=0;u<l;u++){let f=a.map((d,p)=>({...d,paint:i(n[p].fill.slice(u,u+1))}));this.doc.textNode(this.cur,{text:{...o,runs:f},fill:s,opacity:this.worldAlpha})}let c=new Map;n.forEach((u,f)=>u.stroke.forEach((d,p)=>{let _=`${p}|${d.weight}|${d.join}|${d.cap}|${d.miterLimit}`,w=c.get(_);w||c.set(_,w={k:p,st:d,paints:n.map(()=>s)}),w.paints[f]=i(d.fill)}));for(let{st:u,paints:f}of[...c.values()].sort((d,p)=>d.k-p.k)){let d=a.map((p,_)=>({...p,paint:f[_]}));this.doc.textNode(this.cur,{text:{...o,runs:d},opacity:this.worldAlpha,stroke:{paint:s,width:u.weight,join:u.join,cap:u.cap,miter:u.miterLimit}})}}paintText(e,t){for(let n of this.shapes){let r=n.text;if(r)for(let s of e){let i=He(s,_i(r),this.missing,this.assets);i&&this.textLayer(r,r.spec,r.spec,i,this.worldAlpha*(s.opacity??1),t)}}}paintSegments(e,t){let n=this.segmentSpec(e,t),r=_i(e),s=(c,u)=>{if(!u||!(c.opacity>0))return Lt;let f=He(u,r,this.missing,this.assets);return f?this.fadePaint(f,c.opacity*(u.opacity??1)):Lt},i=c=>({...n,runs:n.runs.map((u,f)=>({...u,paint:c(t[f])}))}),a={...n,runs:n.runs.map((c,u)=>t[u].opacity>0?c:{...c,paint:Lt})},o=Math.max(0,...t.map(c=>c.fill?.length??0));for(let c=0;c<o;c++)this.textLayer(e,i(u=>s(u,u.fill?.[c])),a,Lt,this.worldAlpha,null);let l=new Map;t.forEach(c=>c.stroke?.forEach((u,f)=>{let d=mi(f,u);l.has(d)||l.set(d,{k:f,st:u})}));for(let[c,{k:u,st:f}]of[...l].sort((d,p)=>d[1].k-p[1].k)){let d=Math.max(...t.map(p=>p.stroke?.[u]?.fill.length??0));for(let p=0;p<d;p++){let _=w=>{let A=w.stroke?.[u];return A&&mi(u,A)===c?s(w,A.fill[p]):Lt};this.textLayer(e,i(_),a,Lt,this.worldAlpha,f)}}}segmentSpec(e,t){let n=e.spec.runs[0],r=1,s=e.spec.wrap,{width:i=0,height:a=0,minFontSize:o=0}=e.spec;if(e.spec.fontSize==="autofit"&&i>0&&a>0){let c=this.measureText(n.text,Fn,n.family,n.weight,n.letterSpacing,n.italic?"italic":"normal"),u=Fn*Math.min(c.width>0?i/c.width:1,c.height>0?a/c.height:1);s&&u<o?r=o/Fn:(r=u/Fn,s=!1)}let l=t.map(c=>({text:c.text,family:c.fontFamily??n.family,size:(c.fontSize??n.size)*r,weight:c.fontWeight,italic:c.fontStyle===void 0?n.italic:c.fontStyle==="italic"||c.fontStyle==="oblique",letterSpacing:c.letterSpacing,decoration:c.textDecoration===void 0?n.decoration:c.textDecoration==="underline"?"underline":c.textDecoration==="line-through"?"lineThrough":void 0}));return{...e.spec,runs:l,wrap:s,fontSize:void 0}}fadePaint(e,t){return t>=1?e:e.kind==="solid"?{...e,color:[e.color[0],e.color[1],e.color[2],e.color[3]*t]}:"stops"in e?{...e,stops:e.stops.map(n=>({...n,color:[n.color[0],n.color[1],n.color[2],n.color[3]*t]}))}:(this.missing.add("text:run-opacity"),e)}textLayer(e,t,n,r,s,i){if(!i){this.doc.textNode(this.cur,{transform:e.transform,text:t,opacity:s,fill:r});return}let a=f=>({paint:r,width:f,join:i.join,cap:i.cap,miter:i.miterLimit,dash:i.dash,dashPhase:i.dashOffset}),o=Math.max(-1,Math.min(1,i.align??0));if(o===0){this.doc.textNode(this.cur,{transform:e.transform,text:t,opacity:s,stroke:a(i.weight)});return}let l=f=>this.doc.textNode(f,{transform:e.transform,text:n,fill:_t}),c=(f,d)=>this.doc.textNode(f,{transform:e.transform,text:n,stroke:{paint:_t,width:d,join:i.join,miter:i.miterLimit}}),u=f=>{if(o>0){let _=this.doc.group(this.cur,{mask:"invertAlpha"}),w=this.doc.group(_,{mask:"invertAlpha"});return c(w,f),l(w),_}let d=this.doc.group(this.cur,{mask:"alpha"}),p=this.doc.group(d);return l(p),c(p,f),d};if(Math.abs(o)>=1){let f=this.doc.group(this.cur,{mask:o>0?"invertAlphaEroded":"alphaDilated"});l(f),this.doc.textNode(f,{transform:e.transform,text:t,opacity:s,stroke:a(2*i.weight)})}else{let f=(1+o)*i.weight/2,d=(1-o)*i.weight/2;this.doc.textNode(u(2*(o>0?d:f)),{transform:e.transform,text:t,opacity:s,stroke:a(2*Math.max(f,d))})}}surfaceOf(e){let t=Math.max(1,Math.min(e.maxPixelRatio??1,4)),n=e.width??512,r=e.height??512,s=Math.max(1,Math.ceil(n*t)),i=Math.max(1,Math.ceil(r*t)),a=this.doc.detached({transform:[t,0,0,t,n*t/2,r*t/2]}),o={stack:this.stack,scopes:this.scopes,alpha:this.worldAlpha,shapes:this.shapes,painted:this.painted,shadows:this.shadows,masks:this.masks,clips:this.clips,cameras:this.cameras};this.stack=[a],this.scopes=[],this.worldAlpha=1,this.masks=[],this.clips=[],this.cameras=[],this.resetSurface();try{let c=lc(e.source);c.kind==="graphics"?this.draw(c.graphics):(c.node.layout({x:0,y:0,width:n,height:r},this),c.node.render(this))}catch(c){this.missing.add("surface:error"),console.warn(c)}finally{Object.assign(this,{stack:o.stack,scopes:o.scopes,worldAlpha:o.alpha,shapes:o.shapes,painted:o.painted,shadows:o.shadows,masks:o.masks,clips:o.clips,cameras:o.cameras})}let l=this.doc.addSurface(a,s,i);return l.version=++bi,l}mediaPreset(e,t,n){let r=this.pixelAdjustments(t);!r.length||(t.preset.intensity??1)<=0||(e.effects=r.map(s=>({...s,clip:!0})),e.effectBox=[n[0],n[1],n[2]-n[0],n[3]-n[1]],e.effectTime=this.elapsed())}pixelAdjustments(e){let t=e;return t.type!=="image"&&t.type!=="video"||!t.preset?[]:(t.preset.adjustments??[]).filter(n=>n.type!=="echo"&&n.type!=="posterizeTime")}echoStack(e,t,n,r,s,i,a,o){let l=Pr(o.blend??"screen")??"screen",c=o.decay??.5,u=Math.min(Math.max(0,Math.floor(o.echoes)),32),f=this.videoTime(t);a.length&&this.leaf(this.cur,e,{fill:{kind:"solid",color:[0,0,0,0]},opacity:i,shadows:a});for(let d=u;d>=1&&f!==null;d--){let p=f-d*o.delay;if(p<0)continue;let _=He(t,n,this.missing,{...this.assets,video:w=>this.assets.video(w,p)});_&&this.leaf(this.cur,e,{fill:_,opacity:i*Math.pow(c,d),blend:l})}this.mediaPreset(this.leaf(this.cur,e,{fill:s,opacity:i,blend:l}),t,r)}videoTime(e){let t=this.storage?.videos.get(wt(e.src));return t?uc(e,this.currentRenderState()?.elapsed??0,t.duration):null}elapsed(){return this.currentRenderState()?.elapsed??0}spaceBounds(e,t){let n=e.space??"local";if(n==="parent"){let r=this.currentSpaceRects().parent;return r?[r.left,r.top,r.right,r.bottom]:t}if(n==="global"){let r=this.device(),s=r[0]*r[3]-r[1]*r[2];if(!s)return t;let i=(u,f)=>{let d=u-r[4],p=f-r[5];return[(r[3]*d-r[2]*p)/s,(-r[1]*d+r[0]*p)/s]},a=this.width*this.pixelRatio,o=this.height*this.pixelRatio,l=i(0,0),c=i(a,o);return[Math.min(l[0],c[0]),Math.min(l[1],c[1]),Math.max(l[0],c[0]),Math.max(l[1],c[1])]}return t}blendOf(e){let t=e.blend;if(!t||t==="normal")return"normal";let n=Pr(t);return n||this.missing.add(`fill:blend:${t}`),n??"normal"}device(){let e=[this.pixelRatio,0,0,this.pixelRatio,0,0];for(let t of this.stack)e=hr(e,t.transform);return e}snap(e,t,n){return this.snapBounds(it(e),t,n)}snapBounds([e,t,n,r],s,i){if(s<=0||Math.abs(i[1])>1e-6||Math.abs(i[2])>1e-6||i[0]===0||i[3]===0||n-e<=0||r-t<=0)return null;let a=i[0],o=i[3],l=i[4],c=i[5],u=l+a*e,f=c+o*t,d=l+a*n,p=c+o*r,_=s%2===0?0:.5,w=Math.round(u-_)+_,A=Math.round(f-_)+_,B=Math.round(d-_)+_,L=Math.round(p-_)+_;if(B-w<1||L-A<1)return null;let V=(B-w)/(d-u),se=(L-A)/(p-f);return Math.abs(V-1)<1e-4&&Math.abs(se-1)<1e-4&&Math.abs(w-u)<1e-4&&Math.abs(A-f)<1e-4?null:[V,0,0,se,(w-l)/a-V*e,(A-c)/o-se*t]}stroke(e){this.painted=!0,!this.booleans.length&&this.deferring("stroke",()=>this.paintStroke(e))}paintStroke(e){for(let a of e)this.paintText(a.fill,a);let t,n=()=>t===void 0?t=this.surface("fill"):t,r=this.device(),s=Math.sqrt(Math.abs(r[0]*r[3]-r[1]*r[2])),i=Vn(r)||Math.abs(r[1])>1e-6||Math.abs(r[2])>1e-6;for(let a of e){let o=a.weight,l=-1;if(!i&&o>0&&s>0&&o*s<2.5&&(l=Math.max(1,Math.round(o*s)),o=l/s),!this.strokeNative(a,o,l,r))for(let c of this.strokeShapes()){let u,f,d={cap:a.cap,ends:[],dash:a.dash,dashPhase:a.dashOffset};if(c.members)u=f={members:c.members};else{if(!c.stroke||!c.stroke.verbs.length)continue;let L=Xl(a,c.stroke,o,l>0);if(!L)continue;d=L,u={path:L.source??c.stroke},f=c.alignInterior?{members:c.alignInterior}:c.interior&&oi(c.interior)?{path:c.interior}:null}let p=this.bounds(n()??("path"in u?u.path:null)),_=Math.max(-1,Math.min(1,a.align??0)),w=_!==0&&f!==null&&!d.ends.some(L=>Wt(L.cap))?[[(1+_)*o,"out"],[(1-_)*o,"in"]]:[[o,"both"]],A=c.fill?this.snap(c.fill,l,r):null,B=A?this.doc.group(this.cur,{transform:A}):this.cur;for(let L of a.fill){let V=He(L,this.spaceBounds(L,p),this.missing,this.assets);if(!V)continue;let se=this.worldAlpha*(L.opacity??1);for(let[X,pe]of w){if(X<=0)continue;let ue={paint:V,width:X,join:a.join,cap:d.cap,miter:a.miterLimit,dash:d.dash,dashPhase:d.dashPhase};pe==="both"?this.strokeLeaf(B,u,{opacity:se,stroke:ue,blend:this.blendOf(L)},d.ends):this.strokeLeaf(pe==="in"?this.clipTo(B,f):this.clipOutside(B,f),u,{opacity:se,stroke:ue},d.ends)}}}}}strokeShapes(){if(this.shapes.length<2||this.shapes.some(r=>r.text))return this.shapes;let e=this.shapes.filter(r=>r.members||r.fill&&r.fill.verbs.length).sort((r,s)=>(s.members?1:0)-(r.members?1:0));if(e.length<2)return this.shapes;let t=[];for(let r of e)r.members?r.members.forEach((s,i)=>t.push({...s,op:i===0?"union":s.op})):t.push({kind:"path",path:r.fill,op:"union"});e.filter(r=>r.members).length>1&&this.missing.add("stroke:union-of-booleans");let n=e.every(r=>r.bounds)?e.map(r=>r.bounds).reduce((r,s)=>[Math.min(r[0],s[0]),Math.min(r[1],s[1]),Math.max(r[2],s[2]),Math.max(r[3],s[3])]):null;return e.some(r=>!r.members&&(r.stroke!==r.fill||r.trimmed||!oi(r.fill)))?e.some(r=>r.members)?this.shapes:[{fill:pt(e.map(r=>r.fill)),stroke:pt(e.map(r=>r.stroke??r.fill)),interior:null,alignInterior:t,bounds:n}]:[{fill:null,stroke:null,interior:null,bounds:n,members:t}]}strokeLeaf(e,t,n,r){if(!r.length)return this.leaf(e,t,n);let s=n.stroke.width/2,i=s*1.01+.5,a=n.stroke.cap!=="butt",o=[],l=[];for(let f of r){if(Wt(f.cap)){let d=ql(f.cap,f.size,f.weight);(d>0||a)&&o.push(Ar({...f,x:f.x-f.dx*d,y:f.y-f.dy*d},d+i,i)),l.push(Ql(f,f.cap));continue}a&&o.push(Ar(f,i,i)),f.reached&&f.cap!=="butt"&&l.push(f.cap==="round"?Zl(f,s):Ar(f,s,s))}let c=this.doc.group(e,{opacity:n.opacity??1,blend:n.blend??"normal"}),u={...n,opacity:1,blend:"normal"};if(o.length){let f=this.doc.group(c,{mask:"invertAlpha"});this.doc.pathNode(f,{path:pt(o),fill:_t}),this.leaf(f,t,u)}else this.leaf(c,t,u);return l.length&&this.doc.pathNode(c,{path:pt(l),fill:n.stroke.paint}),c}booleans=[];beginBoolean(e){this.booleans.push({op:e,base:nu(this.device()),members:[]}),this.resetSurface()}endBoolean(){let e=this.booleans.pop();if(this.resetSurface(),!e||!e.members.length)return;let t=this.booleans[this.booleans.length-1];if(!t){this.shapes.push({fill:null,stroke:null,interior:null,bounds:Tr(e.members),members:e.members});return}let n=this.relative(t.base),r=gi[t.op],s=!t.members.length;!s&&!e.members.slice(1).every(i=>i.op===(r==="cut"?"union":r))&&this.missing.add("boolean:nested"),e.members.forEach((i,a)=>{let o=i.op??"union",l=s?o:a===0||r==="cut"?r:o;t.members.push({kind:"path",path:n?Js(i.path,n):i.path,op:l})})}relative(e){let t=this.device();return!e||Vn(t)?null:hr(e,t)}collect(e){let t=this.booleans[this.booleans.length-1],n=e.fill;if(!n||!n.verbs.length)return;let r=this.relative(t.base);r||this.missing.add("boolean:projective"),t.members.push({kind:"path",path:r?Js(n,r):n,op:t.members.length?gi[t.op]:"union"})}cut(){let e=this.shapes.filter(n=>n.members||n.fill&&n.fill.verbs.length);if(this.resetSurface(),!e.length)return;let t=[];e.forEach((n,r)=>{let s=r>0&&r===e.length-1?"cut":"union";if(!n.members){t.push({kind:"path",path:n.fill,op:s});return}r>0&&this.missing.add("cut:compound"),n.members.forEach((i,a)=>t.push({...i,op:a===0?s:i.op}))}),this.shapes.push({fill:null,stroke:null,interior:null,bounds:Tr(t),members:t})}masks=[];get inVectorMask(){let e=this.masks[this.masks.length-1];return!!e&&e.open&&e.vector}beginMask(e){let t=e?.mode??"alpha",n=t==="luminance",r=e?.inverted?n?"invertLuminance":"invertAlpha":n?"luminance":"alpha",s=this.doc.group(this.cur,{mask:r}),i=e?.apply?new Set(Array.isArray(e.apply)?e.apply:[e.apply]):null,a=i?this.doc.group(this.cur):null;this.stack.push(s,this.doc.group(s)),this.masks.push({vector:t==="vector",open:!0,apply:i,after:a}),this.resetSurface()}applyMask(){let e=this.masks[this.masks.length-1];e?.open&&(e.open=!1,this.stack.pop(),this.resetSurface())}endMask(){let e=this.masks.pop();e&&(e.open&&this.stack.pop(),this.stack.pop(),this.resetSurface())}clips=[];clipGeom(e){let t=[];for(let n of e.ops()){if(n.kind==="cut"){t.length>1&&(t[t.length-1].op="cut");continue}let r=Sr(n)?.fill;r&&r.verbs.length&&t.push({kind:"path",path:r,op:"union"})}return t.length?t.some(n=>n.op==="cut")?{members:t}:{path:pt(t.map(n=>n.path))}:null}beginClip(e){let t=this.clipGeom(e);if(!t){this.clips.push({pushed:0,geom:null});return}let n=this.clipTo(this.cur,t);"members"in t?this.stack.push(n,this.doc.group(n)):this.stack.push(n),this.clips.push({pushed:"members"in t?2:1,geom:t})}endClip(){let e=this.clips.pop()?.pushed??0;for(let t=0;t<e;t++)this.stack.pop()}cameras=[];beginCamera(e,t,n,r){let s=this.doc.group(this.cur,{clip:{x:e.x-e.width/2,y:e.y-e.height/2,w:e.width,h:e.height,r:0}}),i=-r*Math.PI/180,a=Math.cos(i)*n,o=Math.sin(i)*n,l=-t.x,c=t.y,u=this.doc.group(s,{transform:[a,o,-o,a,e.x+a*l-o*c,e.y+o*l+a*c]});this.stack.push(s,u),this.cameras.push(2)}endCamera(){let e=this.cameras.pop()??0;for(let t=0;t<e;t++)this.stack.pop()}beginEffects(e,t,n,r){if(t!=="backdrop")return;for(let i of e)i?.type==="shader"&&this.checkShader("effect",i);let s=this.clips[this.clips.length-1]?.geom;if(!s){let[i,a,o,l]=this.viewportBox();s={path:new rt().moveTo(i,a).lineTo(i+o,a).lineTo(i+o,a+l).lineTo(i,a+l).close().build()}}this.leaf(this.cur,s,{effects:e,effectBox:[-n/2,-r/2,n,r],effectTime:this.elapsed()})}endEffects(){}checkShader(e,t){let n=this.currentNodeStack[this.currentNodeStack.length-1];for(let r of xl(e,t))this.shaderIssues.push(n===void 0?r:{...r,nodeId:n})}rasterize(){return this.missing.add("rasterize"),null}},su=1379091505;function yt(e){if(e===void 0)return{x:0,y:0,z:0};if(typeof e=="number")return{x:e,y:e,z:e};if(Array.isArray(e))return{x:e[0]??0,y:e[1]??0,z:e[2]??0};let t=e;return{x:t.x??0,y:t.y??0,z:t.z??0}}var iu={XYZ:0,YXZ:1,ZXY:2,ZYX:3,YZX:4,XZY:5},au={none:0,linear:1,reinhard:2,cineon:3,aces:4,agx:5,neutral:6},Be={box:0,sphere:1,plane:2,cylinder:3,cone:4,torus:5,torusKnot:6,circle:7,ring:8,buffer:9,capsule:10,polyhedron:11,lathe:12,tube:13,edges:14,wireframe:15},ou={tetrahedron:0,octahedron:1,icosahedron:2,dodecahedron:3},cu={basic:0,standard:1,physical:2,lambert:3,phong:4,normal:5,points:6,lineBasic:7,lineDashed:8,sprite:9,shadow:10,toon:11,matcap:12,depth:13,shader:14},lu={ambient:0,hemisphere:1,directional:2,point:3,spot:4,area:5},uu={front:0,back:1,both:2},fu={normal:0,additive:1,subtractive:2,multiply:3,none:4},du=["map","gradientMap","alphaMap","aoMap","normalMap","roughnessMap","metalnessMap","emissionMap","envMap","lightMap","displacementMap"],hu=class{byKey=new Map;next=1;pending=[];all=new Map;id(e,t){let n=Gi(e),r="src"in n?n.src:n,s=this.byKey.get(r);s||this.byKey.set(r,s=new Map);let i=s.get(t);if(i===void 0){i=this.next++,s.set(t,i);let a={id:i,srgb:t,texture:n};this.pending.push(a),this.all.set(i,a)}return i}},xa=class{buf=new ArrayBuffer(65536);u32=new Uint32Array(this.buf);f32=new Float32Array(this.buf);n=0;room(e){if(this.n+e<=this.u32.length)return;let t=this.buf.byteLength*2;for(;t/4<this.n+e;)t*=2;let n=new ArrayBuffer(t);new Uint32Array(n).set(this.u32.subarray(0,this.n)),this.buf=n,this.u32=new Uint32Array(n),this.f32=new Float32Array(n)}u(e){this.room(1),this.u32[this.n++]=e>>>0}f(e){this.room(1),this.f32[this.n++]=e===void 0?NaN:e}v3(e){this.f(e.x),this.f(e.y),this.f(e.z)}floats(e){this.room(e.length);for(let t=0;t<e.length;t++)this.f32[this.n++]=e[t]}words(e){this.room(e.length);for(let t=0;t<e.length;t++)this.u32[this.n++]=e[t]>>>0}color(e){if(e===void 0){this.u(0),this.f(0),this.f(0),this.f(0),this.f(0);return}let[t,n,r,s]=typeof e=="string"?Wi(e):e;this.u(1),this.f(t),this.f(n),this.f(r),this.f(s??1)}segments(e){if(e===void 0){this.u(0),this.f(NaN),this.f(NaN),this.f(NaN);return}if(typeof e=="number"){this.u(1),this.f(e),this.f(NaN),this.f(NaN);return}this.u(2),this.f(e[0]),this.f(e[1]),this.f(e[2])}result(){return this.u32.slice(0,this.n)}key(e){return Array.prototype.join.call(this.u32.subarray(e,this.n),",")}copy(e){return this.u32.slice(e,this.n)}same(e,t){if(this.n-e!==t.length)return!1;let n=this.u32;for(let r=0;r<t.length;r++)if(n[e+r]!==t[r])return!1;return!0}set(e,t){this.u32[e]=t>>>0}append(e){this.room(e.n),this.u32.set(e.u32.subarray(0,e.n),this.n),this.n+=e.n}};function qe(e,t){if(!t){e.u(0);return}let n=0;if(t.position!==void 0&&(n|=1),t.rotation!==void 0&&(n|=2),t.quaternion!==void 0&&(n|=4),t.scale!==void 0&&(n|=8),t.lookAt!==void 0&&(n|=16),t.visible===!1&&(n|=32),t.shadow!==void 0&&(n|=64),t.renderOrder!==void 0&&(n|=128),e.u(n),n&1&&e.v3(yt(t.position)),n&2&&(e.v3(yt(t.rotation)),e.u(iu[t.rotation.order??"XYZ"]??0)),n&4){let r=t.quaternion;e.f(r.x),e.f(r.y),e.f(r.z),e.f(r.w)}if(n&8&&e.v3(yt(t.scale)),n&16&&e.v3(yt(t.lookAt)),n&64){let r=t.shadow;e.u(r===!1?0:r===!0?1:r==="cast"?2:r==="receive"?3:4)}n&128&&e.f(t.renderOrder)}function Ir(e,t){let n=Math.floor(t.position.length/3),r=(t.normal?1:0)|(t.uv?2:0)|(t.color?4:0)|(t.index?8:0)|(t.computeNormals?16:0);e.u(Be.buffer),e.u(r),e.u(n),e.u(t.index?.length??0),e.floats(t.position),t.normal&&e.floats(t.normal),t.uv&&e.floats(t.uv),t.color&&e.floats(t.color),t.index&&e.words(t.index)}function _n(e,t,n){switch(t.type){case"box":if((t.cornerRadius??0)>0){let[r,s,i]=Hs(t.segments,[1,1,1]);Ir(e,Zo({width:t.width??1,height:t.height??1,depth:t.depth??1,radius:t.cornerRadius,segments:[r,s,i]}));return}e.u(Be.box),e.f(t.width),e.f(t.height),e.f(t.depth),e.segments(t.segments);return;case"sphere":e.u(Be.sphere),e.f(t.radius),e.segments(t.segments),e.f(t.startAngle),e.f(t.sweep),e.f(t.startLatitude),e.f(t.latitudeSweep);return;case"plane":e.u(Be.plane),e.f(t.width),e.f(t.height),e.segments(t.segments);return;case"cylinder":{let[r,s]=Jo(t.radius);e.u(Be.cylinder),e.f(r),e.f(s),e.f(t.height),e.segments(t.segments),e.u(t.capped===!1?0:1),e.f(t.startAngle),e.f(t.sweep);return}case"cone":e.u(Be.cone),e.f(t.radius),e.f(t.height),e.segments(t.segments),e.u(t.capped===!1?0:1),e.f(t.startAngle),e.f(t.sweep);return;case"torus":e.u(Be.torus),e.f(t.radius),e.f(t.thickness),e.segments(t.segments),e.f(t.startAngle),e.f(t.sweep);return;case"torusKnot":e.u(Be.torusKnot),e.f(t.radius),e.f(t.thickness),e.segments(t.segments),e.f(t.windings?.[0]),e.f(t.windings?.[1]);return;case"circle":e.u(Be.circle),e.f(t.radius),e.segments(t.segments),e.f(t.startAngle),e.f(t.sweep);return;case"ring":e.u(Be.ring),e.f(t.radius),e.f(t.innerRadius),e.segments(t.segments),e.f(t.startAngle),e.f(t.sweep);return;case"buffer":Ir(e,t);return;case"parametric":Ir(e,Xo(t));return;case"capsule":e.u(Be.capsule),e.f(t.radius),e.f(t.height),e.segments(t.segments);return;case"polyhedron":e.u(Be.polyhedron),e.u(ou[t.shape??"icosahedron"]??2),e.f(t.radius),e.f(t.segments===void 0?0:Hs(t.segments,[1])[0]);return;case"lathe":e.u(Be.lathe),e.u(t.points.length);for(let r of t.points){let s=yt(r);e.f(s.x),e.f(s.y)}e.segments(t.segments),e.f(t.startAngle),e.f(t.sweep);return;case"tube":e.u(Be.tube),e.u(t.points.length);for(let r of t.points)e.v3(yt(r));e.u(t.closed?1:0),e.f(t.radius),e.segments(t.segments);return;case"edges":e.u(Be.edges),e.f(t.thresholdAngle),_n(e,t.source,n);return;case"wireframe":e.u(Be.wireframe),_n(e,t.source,n);return;default:n.unsupported.add(`geometry:${t.type}`),e.u(255)}}function ka(e){switch(e.type){case"buffer":case"parametric":return"slot";case"box":return(e.cornerRadius??0)>0?"rounded":"fixed";case"edges":case"wireframe":return ka(e.source)==="fixed"?"fixed":"slot";default:return"fixed"}}function Ma(e){let t=e,n=e.type;for(let r of Object.keys(t).sort()){let s=t[r];r==="type"||r==="revision"||r==="staticData"||s===void 0||typeof s=="function"||(r==="source"?n+=`|source=${Ma(s)}`:ArrayBuffer.isView(s)||Array.isArray(s)&&s.length>3?n+=`|${r}#${s.length}`:n+=`|${r}=${typeof s=="object"?JSON.stringify(s):String(s)}`)}return n}function pu(e){return e.type!=="buffer"?[]:[e.position,e.normal,e.uv,e.color,e.index,e.computeNormals]}var _u=class{next=1;byKey=new Map;slots=new Map;live=new Set;nth=new Map;defs=new xa;count=0;begin(){this.live.clear(),this.nth.clear(),this.defs.n=0,this.count=0}end(e){e.u(this.count),e.append(this.defs);for(let[t,n]of this.byKey)this.live.has(n)||this.byKey.delete(t);for(let[t,n]of this.slots)this.live.has(n.id)||this.slots.delete(t)}ref(e,t,n,r){let s=this.defs,i=ka(e);if(i!=="slot"){let _;if(i==="rounded"){let L=e;_=`rounded|${L.width}|${L.height}|${L.depth}|${L.cornerRadius}|${JSON.stringify(L.segments)}`;let V=this.byKey.get(_);if(V!==void 0)return this.use(V)}let w=s.n;s.u(0),_n(s,e,r),_??=s.key(w+1);let A=this.byKey.get(_);if(A!==void 0)return s.n=w,this.use(A);let B=this.add(w);return this.byKey.set(_,B),B}let a=`${t}|${n}|${Ma(e)}`,o=this.nth.get(a)??0;this.nth.set(a,o+1);let l=`${a}|${o}`,c=this.slots.get(l),u=e.revision,f=pu(e);if(c&&c.revision===u){if(e.type==="parametric"&&u!==void 0)return this.use(c.id);if(e.type==="buffer"&&(u!==void 0||e.staticData===!0)&&f.every((_,w)=>_===c.arrays[w]))return this.use(c.id)}let d=s.n;if(s.u(0),_n(s,e,r),c&&s.same(d+1,c.words))return s.n=d,c.revision=u,c.arrays=f,this.use(c.id);let p=this.add(d);return this.slots.set(l,{id:p,revision:u,arrays:f,words:s.copy(d+1)}),p}use(e){return this.live.add(e),e}add(e){let t=this.next++;return this.defs.set(e,t),this.count++,this.use(t)}},vi={clamp:0,repeat:1,mirror:2};function Rr(e,t){if(e===void 0)return[t,t];if(Array.isArray(e))return[e[0]??t,e[1]??t];let n=e;return[n.x??t,n.y??t]}function xi(e,t,n,r){if(t===void 0||!n){t!==void 0&&r.unsupported.add("texture:map"),e.u(0),e.u(0),e.f(1),e.f(0),e.f(0),e.f(0),e.f(1),e.f(0),e.u(0);return}let s=Gi(t),i=s.colorSpace!=="linear";e.u(1),e.u(n.id(t,i));let[a,o]=Rr(s.offset,0),[l,c]=Rr(s.repeat,1),[u,f]=Rr(s.center,0),d=(s.rotation??0)*Math.PI/180,p=Math.cos(d),_=Math.sin(d);e.f(l*p),e.f(l*_),e.f(-l*(p*u+_*f)+u+a),e.f(-c*_),e.f(c*p),e.f(-c*(-_*u+p*f)+f+o);let w=s.flipY??!("data"in s);e.u((vi[s.wrapS??"clamp"]??0)|(vi[s.wrapT??"clamp"]??0)<<2|(w?16:0)|(s.magFilter==="nearest"?32:0)|(s.minFilter==="nearest"?64:0))}function nn(e,t,n,r){let s=t;e.u(cu[t.type]??1),["basic","standard","physical","lambert","phong","normal","lineBasic","lineDashed","sprite","shadow","points","toon","depth"].includes(t.type)||n.unsupported.add(`material:${t.type}`);for(let a of du)a!=="map"&&a!=="gradientMap"&&s[a]!==void 0&&n.unsupported.add(`texture:${a}`);s.gradientMap!==void 0&&t.type!=="toon"&&n.unsupported.add("texture:gradientMap");for(let a of["sheen","iridescence","anisotropy","dispersion"])typeof s[a]=="number"&&s[a]>0&&n.unsupported.add(`physical:${a}`);e.color(s.color),e.f(s.opacity),e.f(s.roughness),e.f(s.metalness),e.color(s.emission),e.f(s.emissionStrength),e.f(s.envMapIntensity);let i=0;s.transparent===!0&&(i|=1),s.wireframe===!0&&(i|=4),s.vertexColors===!0&&(i|=8),s.shading==="flat"&&(i|=16),s.toneMapped===!1&&(i|=32),s.visible===!1&&(i|=64),s.depthTest===!1&&(i|=128),s.depthWrite!==void 0&&(i|=256|(s.depthWrite?512:0)),s.sizeAttenuation===!1&&(i|=1024),s.polygonOffset===!0&&(i|=2048),e.u(i),e.u(uu[s.faces??"front"]??0),e.u(fu[s.blend??"normal"]??0),e.f(s.alphaTest),e.f(s.size),e.color(s.specular),e.f(s.shininess),xi(e,s.map,r,n),e.f(s.clearcoat),e.f(s.clearcoatRoughness),e.f(s.transmission),e.f(s.thickness),e.f(s.ior),e.f(s.attenuationDistance),e.color(s.attenuationColor),e.f(s.dashSize),e.f(s.gapSize),e.f(s.scale),xi(e,t.type==="toon"?s.gradientMap:void 0,r,n),e.f(s.polygonOffsetFactor),e.f(s.polygonOffsetUnits)}function mu(e,t,n){let r=t;e.u(lu[t.type]??0),e.color(r.color),e.f(t.intensity),e.color(r.sky),e.color(r.ground),e.f(r.distance),e.f(r.decay),e.f(r.angle),e.f(r.penumbra);let s=r.target;e.u(s===void 0?0:1),e.v3(yt(s));let i=r.shadow,a=i===void 0?null:ac(i);e.u(a?1:0),e.f(a?.softness),e.f(a?.extent),e.f(r.width),e.f(r.height),qe(e,n)}function gu(e,t){e.u(t.type==="orthographic"?1:0);let n=rc(t);qe(e,{...t,position:n.position,lookAt:n.lookAt}),e.f(t.type==="perspective"?t.fov:void 0),e.f(t.zoom),e.f(t.type==="orthographic"?t.frustumHeight:void 0),e.f(t.near),e.f(t.far),e.f(t.distance)}function bu(e,t={unsupported:new Set},n,r){let s=new xa;r?.begin();let i=[""],a=(d,p)=>{if(!r)return _n(s,d,t);s.u(16),s.u(r.ref(d,i[i.length-1],p,t))};s.u(su),s.u(4);let o=e.toneSettings();s.u(au[o?.mapping??"aces"]??4),s.f(o?.exposure);let l=e.shadowSettings();s.u(l?.enabled===!0?1:0),s.u(l?.quality==="low"?0:l?.quality==="high"?2:1);let c=e.fogDescriptor();s.u(c?c.density!==void 0?2:1:0),s.color(c?.color),s.f(c?.near),s.f(c?.far),s.f(c?.density);let u=e.environmentDescriptor();s.u(u?.preset==="studio"?1:0),s.f(u?.intensity),s.u(u?.background?1:0),s.f(u?.blur),e.postEffects().length>0&&t.unsupported.add("post");let f=e.ops();s.u(f.length);for(let d of f)switch(d.kind){case"push":{let p=d.transform?.key;i.push(p===void 0?`${i[i.length-1]}/${i.length}`:String(p)),s.u(1),qe(s,d.transform);break}case"pop":i.length>1&&i.pop(),s.u(2);break;case"light":s.u(3),mu(s,d.light,d.transform);break;case"camera":s.u(4),gu(s,d.camera);break;case"mesh":{s.u(5),a(d.geometry,d.kind);let p=Array.isArray(d.material)?d.material:[d.material];s.u(Array.isArray(d.material)?p.length:1);for(let _ of p)nn(s,_,t,n);qe(s,d.transform);break}case"instances":{s.u(6),a(d.geometry,d.kind),nn(s,d.material,t,n),qe(s,d.transform),s.u(d.instances.length);for(let _ of d.instances)qe(s,_);let p=d.colors??[];s.u(p.length);for(let _ of p){let[w,A,B,L]=typeof _=="string"?Wi(_):_;s.f(w),s.f(A),s.f(B),s.f(L??1)}break}case"points":s.u(7),a(d.geometry,d.kind),nn(s,d.material,t,n),qe(s,d.transform);break;case"line":s.u(8),a(d.geometry,d.kind),nn(s,d.material,t,n),s.u(d.mode==="segments"?1:d.mode==="loop"?2:0),qe(s,d.transform);break;case"sprite":s.u(9),nn(s,d.material,t,n),qe(s,d.transform);break;case"model":t.unsupported.add("model"),s.u(10),qe(s,d.transform);break}return r?r.end(s):s.u(0),s.result()}var Se={CREATE:1,DESTROY:2,CHILDREN:3,TRANSFORM:4,SIZE:5,RADII:6,FILL:7,STROKE:8,SHADOWS:9,OPACITY:10,BLEND:11,CLIP:12,FILTER:13,PATH:14,MEMBERS:15,MASK:16,TEXT:17,EFFECTS:18,TRANSFORM3:19,DEF_PAINT:20,DEF_PATH:21,DEF_DASH:22,FREE_PATH:24,ROOT:30,VIEWPORT:31},mt=4294967295,wu=class{sink;memory;u32;f32;pos=0;cap=0;written=0;constructor(e,t){this.sink=e,this.memory=t,this.refresh(0)}refresh(e){let t=this.sink.delta_buffer(e);this.cap=this.sink.delta_capacity(),this.u32=new Uint32Array(this.memory.buffer,t,this.cap),this.f32=new Float32Array(this.memory.buffer,t,this.cap)}begin(e){this.u32.buffer!==this.memory.buffer&&this.refresh(0),this.pos+e>this.cap&&(this.flush(),e>this.cap&&this.refresh(e))}u(e){this.u32[this.pos++]=e>>>0}f(e){this.f32[this.pos++]=e}flush(){this.pos>0&&(this.written+=this.pos,this.sink.apply(this.pos),this.pos=0),this.u32.buffer!==this.memory.buffer&&this.refresh(0)}takeCount(){let e=this.written;return this.written=0,e}},yu=oe({MAX_PARAMS:()=>64,definePort:()=>ce,fieldFloats:()=>Sa,layout:()=>Ta}),ki={f32:1,vec2f:2,vec3f:3,vec4f:4},Sa=e=>typeof e=="string"?ki[e]:e.array*ki[e.of],Ea={number:"f32",boolean:"f32",enum:"f32",color:"vec4f",vec2:"vec2f",axis:"vec2f"};function vu(e,t){switch(e.kind){case"number":return t;case"boolean":return t?1:0;case"enum":return Math.max(0,e.options.indexOf(t));case"color":return Mt(t);case"vec2":{let n=t;return[n.x,n.y]}case"axis":{let n=kt(t);return[n.x,n.y]}default:throw new Error(`effect param "${e.name}" (${e.kind}) has no default encoding; give it a value()`)}}function Aa(e,t){let n=Yo(e)?.params.find(r=>r.name===t);if(!n)throw new Error(`effect "${e}": "${t}" is not a parameter of its core spec`);if(!Ea[n.kind])throw new Error(`effect "${e}": "${t}" (${n.kind}) has no default encoding`);return n}function Ta(e){let t=0,n=Object.entries(e.params).map(([r,s])=>{let i=s==="param"?Ea[Aa(e.type,r).kind]:s.type,a=Sa(i),o={name:r,type:i,offset:t,floats:a};return t+=a,o});if(t>64)throw new Error(`effect "${e.type}" lays out ${t} params; a pass takes 64`);return n}function ce(e){let t=Ta(e),n=t.reduce((s,i)=>s+i.floats,0),r=t.map(s=>{let i=e.params[s.name];if(i!=="param")return i.value;let a=Aa(e.type,s.name);return o=>vu(a,o[s.name])});return{type:e.type,surface:e.surface,backdropOnly:e.backdropOnly,spec:e,cases:e.cases,pack(s){let i=e.prepare?e.prepare(s):{};if(i===null)return null;let a=new Array(n).fill(0);return t.forEach((o,l)=>{let c=r[l](s,i),u=typeof c=="number"?1:c.length;if(u>o.floats)throw new Error(`effect "${e.type}": "${o.name}" is ${u} floats, laid out as ${o.floats}`);if(typeof c=="number")a[o.offset]=c;else for(let f=0;f<u;f++)a[o.offset+f]=c[f]}),{params:a,...e.extras?e.extras(s,i):{}}}}}var xu=oe({default:()=>ku}),ku=ce({type:"alpha",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},value:e=>[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,Math.max(0,Math.min(1,e.amount)),0]}},cases:()=>[]}),Mu=oe({default:()=>Pu}),Su="Inter",Eu=e=>typeof document<"u"&&document.fonts.check(`12px "${e}"`),Au=e=>Math.max(4,Math.min(64,Math.round(Math.max(8,e*2)))),st=1;function Tu(e,t,n){let r=[...e].slice(0,256),s=n*st,i=new OffscreenCanvas(s*r.length,s),a=i.getContext("2d",{willReadFrequently:!0});a.fillStyle="#000",a.fillRect(0,0,i.width,i.height),a.fillStyle="#fff",a.font=`${n*.8*st}px "${t}"`,a.textBaseline="alphabetic",a.textAlign="left",a.fontKerning="none",r.forEach((u,f)=>{let d=a.measureText(u).width;a.fillText(u,f*s+(s-d)/2,s*.78)});let o=a.getImageData(0,0,i.width,i.height).data,l=n*r.length,c=new Uint8ClampedArray(l*n*4);for(let u=0;u<n;u++)for(let f=0;f<l;f++){let d=0;for(let w=0;w<st;w++)for(let A=0;A<st;A++)d+=o[((u*st+w)*i.width+f*st+A)*4];let p=d/(st*st),_=(u*l+f)*4;c[_]=c[_+1]=c[_+2]=p,c[_+3]=255}return{glyphs:r.length,pixels:c,width:l}}var Pu=ce({type:"ascii",surface:"shader",params:{size:"param",glyphs:{type:"f32",uses:["charset","fontFamily"],value:(e,t)=>t.atlas.glyphs},cell:{type:"f32",value:(e,t)=>t.cell},ink:"param",background:"param",colored:"param"},prepare(e){let t=nc(e.charset);if(t.length===0)return null;let n=Eu(e.fontFamily)?e.fontFamily:Su,r=Au(e.size);return{family:n,cell:r,charset:t,atlas:Tu(t,n,r)}},extras:(e,t)=>({aux:{key:`ascii|${t.family}|${t.cell}|${t.charset}`,width:t.atlas.width,height:t.cell,pixels:t.atlas.pixels}}),cases:()=>[E.ascii().list[0],E.ascii({size:10,charset:"hex",fontFamily:"Fira Mono",ink:"#6f6",background:"#001",colored:!1}).list[0],E.ascii({size:14,colored:!0,background:"transparent",ink:"white"}).list[0],E.ascii({size:8,ink:"black",background:"white",charset:" .oO@"}).list[0]]}),Iu=oe({default:()=>Ou}),Ru={gameboy:["#0f380f","#306230","#8bac0f","#9bbc0f"],cga:["#000000","#55ffff","#ff55ff","#ffffff"],nes:["#000000","#fcfcfc","#bcbcbc","#7c7c7c","#0000fc","#0078f8","#3cbcfc","#a4e4fc","#b8f818","#00b800","#005800","#f83800","#e40058","#f878f8","#f8b800","#503000"]},Cu=e=>{let t=parseInt(e.slice(1),16);return[16,8,0].map(n=>Number(((t>>n&255)/255).toFixed(4)))},Ou=ce({type:"bitCrush",surface:"shader",params:{bits:"param",amount:"param",count:{type:"f32",uses:["palette"],value:(e,t)=>t.palette.length},palette:{type:{array:16,of:"vec3f"},value:(e,t)=>t.palette.flatMap(Cu)}},prepare(e){return!(e.amount>0)||e.palette==="none"&&e.bits>=8?null:{palette:e.palette==="none"?[]:Ru[e.palette]}},cases:()=>[E.bitCrush().list[0],E.bitCrush({palette:"gameboy"}).list[0],E.bitCrush({palette:"nes",amount:.7}).list[0],E.bitCrush({palette:"cga"}).list[0]]}),Du=oe({default:()=>Lu}),Lu=ce({type:"blockDisplace",surface:"shader",params:{amount:"param",size:"param",density:"param",seed:"param",axis:"param"},prepare(e){if(!(e.amount>0)||!(e.density>0))return null;let t=kt(e.axis);return t.x===0&&t.y===0?null:{}},extras(e){let t=kt(e.axis);return{reach:e.amount*Math.max(Math.abs(t.x),Math.abs(t.y))}},cases:()=>[E.blockDisplace().list[0],E.blockDisplace({amount:40,size:10,density:.6,seed:3}).list[0],E.blockDisplace({amount:30,size:24,axis:"y",seed:1}).list[0]]}),Fu=oe({default:()=>Bu}),Bu=ce({type:"bloom",surface:"filter",params:{scale:{type:"f32",uses:["threshold"],value:(e,t)=>t.scale},bias:{type:"f32",value:(e,t)=>-t.t*t.scale},intensity:"param"},uses:["radius"],prepare(e){if(e.radius<=0||e.intensity<=0)return null;let t=Math.max(0,Math.min(1,e.threshold));return{t,scale:t<1?1/(1-t):1,sigma:e.radius/2}},extras:(e,t)=>({blur:[t.sigma,t.sigma,0],reach:3*t.sigma}),cases:()=>[E.bloom().list[0],E.bloom({threshold:.4,radius:24,intensity:1.5}).list[0],E.bloom({threshold:0,radius:6,intensity:.6}).list[0]]}),$u=oe({default:()=>Uu}),Uu=ce({type:"blur",surface:"filter",params:{},uses:["radius"],prepare:e=>e.radius>0?{}:null,extras(e){let t=e.radius/2;return{blur:[t,t,0],reach:3*t}},cases:()=>[E.blur(8).list[0],E.blur(24).list[0],E.blur(2).list[0]]}),Nu=oe({default:()=>ju}),ju=ce({type:"bulge",surface:"shader",params:{strength:"param",center:"param"},prepare:e=>e.strength===0?null:{},extras(e){let t=2*Math.hypot(e.center.x-.5,e.center.y-.5)*360;if(e.strength<0){let n=e.strength*.8,r=1;for(;r<4&&r*(1+n*r*r)/(1+n)>-1;)r+=.01;t=Math.min((r-1+2*Math.hypot(e.center.x-.5,e.center.y-.5))*360,800)}return{reach:t}},cases:()=>[E.bulge(.6).list[0],E.bulge(-.7).list[0],E.bulge({strength:.9,center:{x:.3,y:.6}}).list[0]]}),Wu=oe({default:()=>Gu}),Vu=[1.4,-.2,-.2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0],zu=[0,0,0,0,0,0,0,0,0,0,-.2,-.2,1.4,0,0,0,0,0,1,0],Gu=ce({type:"chromaticAberration",surface:"filter",params:{red:{type:{array:20,of:"f32"},value:()=>Vu},blue:{type:{array:20,of:"f32"},value:()=>zu},offset:{type:"vec2f",uses:["amount","angle"],value(e){let t=e.angle*Math.PI/180;return[Math.cos(t)*e.amount,Math.sin(t)*e.amount]}}},prepare:e=>e.amount<=0?null:{},extras:e=>({reach:e.amount}),cases:()=>[E.chromaticAberration().list[0],E.chromaticAberration({amount:8,angle:45}).list[0],E.chromaticAberration({amount:2.5,angle:200}).list[0]]}),Hu=oe({default:()=>Ju}),vt=.2126,at=.7152,nt=.0722;function Ku(e,t){let n=new Array(20).fill(0);for(let r=0;r<4;r++)for(let s=0;s<5;s++){let i=0;for(let a=0;a<4;a++)i+=e[r*5+a]*t[a*5+s];s===4&&(i+=e[r*5+4]),n[r*5+s]=i}return n}var rn=(e,t)=>[e,0,0,0,t,0,e,0,0,t,0,0,e,0,t,0,0,0,1,0],Mi=(e,t,n)=>[1,0,0,0,e,0,1,0,0,t,0,0,1,0,n,0,0,0,1,0];function Si(e){let t=1-e;return[e+t*vt,t*at,t*nt,0,0,t*vt,e+t*at,t*nt,0,0,t*vt,t*at,e+t*nt,0,0,0,0,0,1,0]}function qu(e){let t=e*Math.PI/180,n=Math.cos(t),r=Math.sin(t);return[vt+n*(1-vt)+r*-.2126,at+n*-.7152+r*-.7152,nt+n*-.0722+r*(1-nt),0,0,vt+n*-.2126+r*.143,at+n*(1-at)+r*.14,nt+n*-.0722+r*-.283,0,0,vt+n*-.2126+r*-.7874,at+n*-.7152+r*at,nt+n*(1-nt)+r*nt,0,0,0,0,0,1,0]}var Ju=ce({type:"colorAdjustment",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},uses:["brightness","contrast","saturation","hue","vibrance","temperature","tint","shadows","highlights"],value:(e,t)=>t.matrix}},prepare(e){let t=rn(1,0),n=!1,r=p=>{t=Ku(p,t),n=!0},s=e.brightness??0;s!==0&&r(rn(1,s));let i=e.contrast??1;i!==1&&r(rn(i,.5*(1-i)));let a=e.saturation??1;a!==1&&r(Si(a));let o=((e.hue??0)%360+360)%360;o!==0&&r(qu(o));let l=e.vibrance??0;l!==0&&r(Si(1+l*.7));let c=e.temperature??0;c!==0&&r(Mi(c*.1,0,-c*.1));let u=e.tint??0;u!==0&&r(Mi(u*.05,-u*.1,u*.05));let f=e.shadows??0;f!==0&&r(rn(1-.2*f,.2*f));let d=e.highlights??0;return d!==0&&r(rn(1+.2*d,-.1*d)),n?{matrix:t}:null},cases:()=>[E.colorAdjustment({brightness:.1,contrast:1.3,saturation:1.4}).list[0],E.colorAdjustment({hue:120,vibrance:.5}).list[0],E.colorAdjustment({temperature:.6,tint:-.4,shadows:.5,highlights:-.5}).list[0],E.colorAdjustment({contrast:.6,saturation:0}).list[0]]}),Yu=oe({default:()=>Xu}),Xu=ce({type:"colorMatrix",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},value:e=>Array.from(e.matrix).slice(0,20)}},cases:()=>[]}),Zu=oe({default:()=>nf}),Hn=32;function Qu(e,t){if(e.length===0)return t;if(t<=e[0][0])return e[0][1];let n=e[e.length-1];if(t>=n[0])return n[1];for(let r=0;r<e.length-1;r++){let[s,i]=e[r],[a,o]=e[r+1];if(t>=s&&t<=a)return i+(o-i)*(a===s?0:(t-s)/(a-s))}return t}function ef(e){let t=[...e].sort((r,s)=>r[0]-s[0]),n=[];for(let r=0;r<=Hn;r++){let s=Qu(t,r/Hn);n.push(Number.isFinite(s)?Math.max(0,Math.min(1,s)):r/Hn)}return n}var tf={r:[1,0,0,0],g:[0,1,0,0],b:[0,0,1,0],a:[0,0,0,1]},nf=ce({type:"curves",surface:"shader",params:{mask:{type:"vec4f",uses:["channel"],value:e=>tf[e.channel??"rgb"]??[1,1,1,0]},curve:{type:{array:33,of:"f32"},uses:["points"],value:(e,t)=>t.values}},prepare(e){let t=ef(e.points??[]);return t.every((n,r)=>Math.abs(n-r/Hn)<1e-4)?null:{values:t}},cases:()=>[E.curves({points:[[0,0],[.25,.15],[.75,.88],[1,1]]}).list[0],E.curves({points:[[0,.2],[.5,.7],[1,1]],channel:"r"}).list[0],E.curves({points:[[0,0],[.6,.3],[1,.8]],channel:"a"}).list[0]]}),rf=oe({default:()=>sf}),sf=ce({type:"directionalBlur",surface:"filter",params:{sigma:{type:"f32",uses:["radius"],value:(e,t)=>t.sigma},axis:{type:"vec2f",uses:["angle"],value:(e,t)=>[Math.cos(t.rad),Math.sin(t.rad)]}},prepare:e=>e.radius<=0?null:{sigma:e.radius/2,rad:e.angle*Math.PI/180},extras:(e,t)=>({blur:[t.sigma,0,t.rad],reach:3*t.sigma}),cases:()=>[E.directionalBlur(20).list[0],E.directionalBlur({radius:30,angle:45}).list[0],E.directionalBlur({radius:12,angle:100}).list[0],E.directionalBlur({radius:120,angle:-20}).list[0]]}),af=oe({default:()=>uf}),of="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",cf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ut=64,Cr=null;function lf(){if(Cr)return Cr;let e=of.replace(/[^A-Za-z0-9+/]/g,""),t=new Uint8Array(e.length*3>>2),n=0,r=0,s=0;for(let a=0;a<e.length;a++)n=n<<6|cf.indexOf(e[a]),r+=6,r>=8&&(r-=8,t[s++]=n>>r&255);let i=new Uint8ClampedArray(Ut*Ut*4);for(let a=0;a<Ut*Ut;a++)i.fill(t[a],a*4,a*4+3),i[a*4+3]=255;return Cr=i}var uf=ce({type:"dither",surface:"shader",params:{levels:"param",scale:"param",monochrome:"param",noise:"param",matrix:{type:"f32",value:e=>e.matrix}},prepare:e=>e.levels>=256?null:{},extras:e=>({aux:e.noise==="blue"?{key:"dither-blue-noise",width:Ut,height:Ut,pixels:lf()}:void 0}),cases:()=>[E.dither().list[0],E.dither({levels:4,matrix:8,scale:2,monochrome:!0}).list[0],E.dither({noise:"blue",levels:3}).list[0],E.dither({matrix:2,levels:6,scale:3}).list[0]]}),ff=oe({default:()=>df}),df=ce({type:"dropShadow",surface:"shader",params:{offset:{type:"vec2f",uses:["offsetX","offsetY"],value:(e,t)=>[t.ox,t.oy]},sigma:{type:"f32",uses:["blur"],value:(e,t)=>t.sigma},color:"param",spread:{type:"f32",value:(e,t)=>t.spread}},prepare(e){if(Mt(e.color)[3]<=0)return null;let t=e.offsetX,n=-e.offsetY,r=Math.max(0,e.blur)/2,s=Math.max(0,e.spread);return t===0&&n===0&&r===0&&s===0?null:{ox:t,oy:n,sigma:r,spread:s}},extras:(e,t)=>({reach:Math.hypot(t.ox,t.oy)+3*t.sigma+t.spread}),cases:()=>[E.dropShadow().list[0],E.dropShadow({offsetX:10,offsetY:10,blur:24,color:"#0008"}).list[0],E.dropShadow({offsetX:0,offsetY:0,blur:0,spread:6,color:"#f40"}).list[0],E.dropShadow({offsetX:-12,offsetY:-6,blur:40,spread:4,color:"#04f"}).list[0]]}),hf=oe({default:()=>gf}),pf=.2126,_f=.7152,mf=.0722,gf=ce({type:"duotone",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},uses:["amount","shadows","highlights"],value(e){let t=Math.max(0,Math.min(1,e.amount)),n=Mt(e.shadows),r=Mt(e.highlights),s=i=>{let a=(r[i]-n[i])*t,o=[a*pf,a*_f,a*mf,0,n[i]*t];return o[i]+=1-t,o};return[...s(0),...s(1),...s(2),0,0,0,1,0]}}},prepare:e=>e.amount<=0?null:{},cases:()=>[E.duotone().list[0],E.duotone({shadows:"#1a0b3d",highlights:"#ffcc66"}).list[0],E.duotone({amount:.5,shadows:"#003344",highlights:"#ff6699"}).list[0]]}),bf=oe({default:()=>wf}),wf=ce({type:"edges",surface:"shader",params:{strength:"param",kernel:"param",colored:"param"},prepare:e=>e.strength>0?{}:null,extras:()=>({reach:1}),cases:()=>[E.edges().list[0],E.edges({strength:2,kernel:"prewitt",colored:!0}).list[0],E.edges({strength:1.5,kernel:"laplacian"}).list[0]]}),yf=oe({default:()=>vf}),vf=ce({type:"exposure",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},value:e=>[e.amount,0,0,0,0,0,e.amount,0,0,0,0,0,e.amount,0,0,0,0,0,1,0]}},cases:()=>[]}),xf=oe({default:()=>Pf}),Ei=e=>Math.min(1,Math.max(0,e)),kf=.35,Mf=1,Sf=.1,Ef=.06,Af=.7,Tf=.3,Ai=.25,Pf=ce({type:"glass",surface:"shader",backdropOnly:!0,params:{depth:"param",refraction:{type:"f32",value:e=>Math.max(0,e.refraction/100)},spread:{type:"f32",uses:["dispersion"],value:e=>Ei(e.dispersion/100)*kf},light:{type:"vec2f",uses:["lightAngle"],value(e){let t=e.lightAngle*Math.PI/180;return[Math.sin(t),-Math.cos(t)]}},rim:{type:"f32",uses:["lightIntensity"],value:(e,t)=>t.light*Mf},shade_near:{type:"f32",uses:["splay"],value:(e,t)=>t.light*Sf*(1-Ai*t.splay)},shade_far:{type:"f32",value:(e,t)=>t.light*Ef*(1-Ai*t.splay)},shade_reach:{type:"f32",value:(e,t)=>Af+Tf*t.splay},frost:{type:"f32",value:(e,t)=>t.frost}},prepare(e){return e.depth>0?{light:Math.max(0,e.lightIntensity/100),splay:Ei(e.splay/100),frost:Math.max(0,e.frost)*.5}:null},extras:(e,t)=>({reach:3*t.frost+2,blur:t.frost>0?[t.frost,t.frost,0]:void 0,field:!0}),cases:()=>[E.glass().list[0],E.glass({dispersion:0,frost:0,depth:30}).list[0]]}),If=oe({default:()=>Cf}),Rf=["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],Cf=ce({type:"glow",surface:"shader",params:{channel:"param",threshold:"param",spread:{type:"f32",value:e=>Math.max(0,e.spread)},intensity:"param",tint:"param",original:"param",blend:{type:"f32",value:e=>Math.max(0,Rf.indexOf(e.blend))},count:{type:"f32",value:(e,t)=>t.colors.length},cycles:"param",phase:{type:"f32",value:e=>e.phase/360},mirror:{type:"f32",uses:["loopStyle"],value:e=>e.loopStyle==="mirror"?1:0},stops:{type:{array:8,of:"f32"},value(e,t){let n=[],r=0;for(let s=0;s<t.colors.length;s++)r=Math.max(r,Math.min(1,e.stops[s]??s/Math.max(1,t.colors.length-1))),n.push(r);return n}},colors:{type:{array:8,of:"vec4f"},uses:["color"],value:(e,t)=>t.colors.flatMap(n=>Mt(n))}},uses:["radius","axis"],prepare(e){return e.radius<=0&&e.spread<=0||e.intensity<=0?null:{colors:(e.tint==="solid"?[e.color]:e.colors).slice(0,8)}},extras(e){let t=kt(e.axis),n=Math.max(0,e.radius)/2;return{blur:[n*t.x,n*t.y,0],reach:3*n+Math.max(0,e.spread)}},cases:()=>[E.glow().list[0],E.glow({radius:12,threshold:.3,intensity:1.5,original:"front"}).list[0],E.glow({channel:"alpha",radius:20,spread:4,tint:"solid",color:"#4cf"}).list[0],E.glow({radius:30,tint:"ramp",colors:["#ff3","#f0f","#0ff"],stops:[0,.5,1],blend:"lighten"}).list[0]]}),Of=oe({default:()=>Df}),Df=ce({type:"grain",surface:"shader",params:{amount:"param",size:"param",seed:"param",colored:"param",animated:"param"},prepare:e=>e.amount>0?{}:null,cases:()=>[E.grain().list[0],E.grain({amount:.5,size:3,seed:7,colored:!0}).list[0],E.grain({amount:.15,size:2}).list[0]]}),Lf=oe({default:()=>Ff}),Or=.2126,Dr=.7152,Lr=.0722,Ff=ce({type:"grayscale",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},uses:["amount"],value(e){let t=Math.max(0,Math.min(1,e.amount));return[1-t+t*Or,t*Dr,t*Lr,0,0,t*Or,1-t+t*Dr,t*Lr,0,0,t*Or,t*Dr,1-t+t*Lr,0,0,0,0,0,1,0]}}},cases:()=>[E.grayscale(1).list[0],E.grayscale(.5).list[0]]}),Bf=oe({default:()=>$f}),$f=ce({type:"halftone",surface:"shader",params:{size:"param",angle:{type:"f32",value:e=>e.angle*Math.PI/180},shape:"param",separation:"param"},extras:e=>({reach:e.size}),cases:()=>[E.halftone().list[0],E.halftone({size:10,angle:20,shape:"line",separation:"rgb"}).list[0],E.halftone({size:12,shape:"cross",separation:"cmyk"}).list[0]]}),Uf=oe({default:()=>Wf}),Ft=.2126,Bt=.7152,$t=.0722,Nf=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];function jf(e){switch(e){case"red":return[-1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];case"green":return[1,0,0,0,0,0,-1,0,0,1,0,0,1,0,0,0,0,0,1,0];case"blue":return[1,0,0,0,0,0,1,0,0,0,0,0,-1,0,1,0,0,0,1,0];case"alpha":return[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,-1,1];case"hue":return[2*Ft-1,2*Bt,2*$t,0,0,2*Ft,2*Bt-1,2*$t,0,0,2*Ft,2*Bt,2*$t-1,0,0,0,0,0,1,0];case"luminance":return[1-2*Ft,-2*Bt,-2*$t,0,1,-2*Ft,1-2*Bt,-2*$t,0,1,-2*Ft,-2*Bt,1-2*$t,0,1,0,0,0,1,0];default:return[-1,0,0,0,1,0,-1,0,0,1,0,0,-1,0,1,0,0,0,1,0]}}var Wf=ce({type:"invert",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},uses:["channel","strength"],value:(e,t)=>t.matrix}},prepare(e){let t=Math.max(0,Math.min(1,e.strength));if(t===0)return null;let n=jf(e.channel);return{matrix:Nf.map((r,s)=>r+(n[s]-r)*t)}},extras:(e,t)=>t.matrix[19]>0?{reach:4096}:{},cases:()=>[E.invert().list[0],E.invert({channel:"hue",strength:.7}).list[0],E.invert({channel:"luminance"}).list[0],E.invert({channel:"alpha",strength:.5}).list[0]]}),Vf=oe({default:()=>zf}),zf=ce({type:"kaleidoscope",surface:"shader",params:{wedge:{type:"f32",uses:["segments"],value:(e,t)=>2*Math.PI/t.segments},angle:{type:"f32",value:e=>e.angle*Math.PI/180},offset:"param",amount:{type:"f32",value:e=>Math.max(0,Math.min(1,e.amount))},center:"param"},prepare(e){let t=Math.round(e.segments);return t<2||e.amount<=0?null:{segments:t}},extras:e=>({reach:Math.min((Math.SQRT2-1+Math.abs(e.offset)+2*Math.hypot(e.center.x-.5,e.center.y-.5))*360,800)}),cases:()=>[E.kaleidoscope().list[0],E.kaleidoscope({segments:8,angle:20,offset:.15}).list[0],E.kaleidoscope({segments:3,amount:.6,center:{x:.4,y:.55}}).list[0]]}),Gf=oe({default:()=>qf}),Ti=new WeakMap,Hf=0,Fr=e=>Number.isFinite(e)?Math.max(0,Math.min(255,Math.round(e*255))):0;function Kf(e,t){let n=Ti.get(e);if(n&&n.height===t)return n;let r=t*t,s=new Uint8ClampedArray(r*t*4);for(let a=0;a<t;a++)for(let o=0;o<t;o++)for(let l=0;l<t;l++){let c=((a*t+o)*t+l)*3,u=(o*r+a*t+l)*4;s[u+3]=255,!(c+2>=e.length)&&(s[u]=Fr(e[c]),s[u+1]=Fr(e[c+1]),s[u+2]=Fr(e[c+2]))}let i={key:`lut-${Hf++}`,width:r,height:t,pixels:s};return Ti.set(e,i),i}function Pi(e){let t=new Float32Array(e*e*e*3);for(let n=0;n<e;n++)for(let r=0;r<e;r++)for(let s=0;s<e;s++){let[i,a,o]=[s/(e-1),r/(e-1),n/(e-1)],l=((n*e+r)*e+s)*3;t[l]=.05+.95*Math.pow(i,.8),t[l+1]=.85*a+.1*o+.03,t[l+2]=1-Math.pow(1-o,1.4)*.9-.08*i}return t}var Br=null,qf=ce({type:"lut",surface:"shader",params:{size:"param",amount:"param"},uses:["table"],prepare:e=>e.amount<=0||!Number.isInteger(e.size)||e.size<2?null:{},extras:e=>({aux:Kf(e.table,e.size)}),cases:()=>(Br??=[Pi(17),Pi(33)],[E.lut({table:Br[1],size:33}).list[0],E.lut({table:Br[0],size:17,amount:.6}).list[0]])}),Jf=oe({default:()=>Yf}),Yf=ce({type:"magnify",surface:"shader",backdropOnly:!0,params:{scale:"param",center:"param"},prepare:e=>e.scale===1||e.scale<=0?null:{},extras:e=>({reach:e.scale<1?Math.min((1/e.scale-1)*360,800):0}),cases:()=>[E.magnify({scale:2}).list[0],E.magnify({scale:1.6,center:{x:.3,y:.7}}).list[0]]}),Xf=oe({default:()=>Zf}),Zf=ce({type:"oilPaint",surface:"shader",params:{radius:"param"},prepare:e=>e.radius>0?{}:null,extras:e=>({reach:e.radius}),cases:()=>[E.oilPaint().list[0],E.oilPaint({radius:5}).list[0],E.oilPaint({radius:1.5}).list[0]]}),Qf=oe({default:()=>td}),ed={outside:0,inside:1,center:2},td=ce({type:"outline",surface:"shader",params:{width:"param",position:{type:"f32",value:(e,t)=>t.position},color:"param"},prepare(e){return!(e.width>0)||Mt(e.color)[3]<=0?null:{position:ed[e.position]??0}},extras:(e,t)=>({reach:t.position===1?0:t.position===2?e.width/2:e.width}),cases:()=>[E.outline().list[0],E.outline({width:8,color:"#f80",position:"inside"}).list[0],E.outline({width:6,color:"#0cf",position:"center"}).list[0]]}),nd=oe({default:()=>rd}),rd=ce({type:"pixelate",surface:"filter",params:{blocks:"param",sharpColors:"param"},extras:e=>({reach:e.sharpColors?0:100}),cases:()=>[E.pixelate(40).list[0],E.pixelate({blocks:{x:40,y:24},sharpColors:!1}).list[0],E.pixelate({blocks:{x:12.5,y:40/3}}).list[0]]}),sd=oe({default:()=>id}),id=ce({type:"posterize",surface:"shader",params:{levels:"param"},prepare:e=>e.levels<2?null:{},cases:()=>[E.posterize().list[0],E.posterize(2).list[0],E.posterize(7).list[0]]}),ad=oe({default:()=>od}),od=ce({type:"progressiveBlur",surface:"shader",params:{center:"param",direction:{type:"vec2f",uses:["angle"],value(e){let t=e.angle*Math.PI/180;return[Math.cos(t),Math.sin(t)]}},radius:"param",start_radius:{type:"f32",uses:["startRadius"],value:(e,t)=>t.start0},start:"param",end:"param",shape:"param",samples:{type:"f32",value:e=>Math.max(2,Math.min(32,Math.round(e.samples)))}},prepare(e){let t=e.startRadius??0;return e.radius<=0&&t<=0?null:{start0:t}},extras:(e,t)=>({reach:Math.max(e.radius,t.start0,0)}),cases:()=>[E.progressiveBlur().list[0],E.progressiveBlur({radius:30,angle:0,start:.3,end:.9,samples:28}).list[0],E.progressiveBlur({radius:28,startRadius:4,shape:"radial",center:{x:.4,y:.5}}).list[0]]}),cd=oe({default:()=>ld}),ld=ce({type:"radialBlur",surface:"shader",params:{amount:"param",style:"param",center:"param",samples:{type:"f32",value:e=>Math.round(Math.max(2,Math.min(32,e.samples)))}},prepare:e=>e.amount>0?{}:null,extras(e){let t=e.style==="spin"?Math.SQRT2-1:1/Math.max(1-e.amount/2,.25)-1;return{reach:Math.min((t+2*Math.hypot(e.center.x-.5,e.center.y-.5))*360,800)}},cases:()=>[E.radialBlur().list[0],E.radialBlur({amount:.8,style:"spin",samples:24}).list[0],E.radialBlur({amount:.3,center:{x:.3,y:.4},samples:8}).list[0]]}),ud=oe({default:()=>fd}),fd=ce({type:"rgbShift",surface:"shader",params:{red:"param",green:"param",blue:"param"},prepare(e){let{red:t,green:n,blue:r}=e;return!t.x&&!t.y&&!n.x&&!n.y&&!r.x&&!r.y?null:{}},extras:({red:e,green:t,blue:n})=>({reach:Math.max(Math.abs(e.x),Math.abs(e.y),Math.abs(t.x),Math.abs(t.y),Math.abs(n.x),Math.abs(n.y))}),cases:()=>[E.rgbShift().list[0],E.rgbShift({amount:12}).list[0],E.rgbShift({red:{x:6,y:-4},green:{x:-3,y:5},blue:{x:0,y:9}}).list[0]]}),dd=oe({default:()=>hd}),hd=ce({type:"scanlines",surface:"shader",params:{spacing:"param",thickness:"param",darkness:"param",offset:"param",direction:{type:"vec2f",uses:["angle"],value(e){let t=e.angle*Math.PI/180;return[Math.cos(t),Math.sin(t)]}}},prepare:e=>e.darkness>0?{}:null,cases:()=>[E.scanlines().list[0],E.scanlines({spacing:7,thickness:.3,darkness:.8,offset:2,angle:30}).list[0],E.scanlines({spacing:5,thickness:.7,angle:90}).list[0]]}),pd=oe({default:()=>_d}),_d=ce({type:"scatter",surface:"shader",params:{offset:{type:"vec2f",uses:["strength","axis"],value(e){let t=kt(e.axis);return[e.strength*t.x,e.strength*t.y]}}},prepare:e=>e.strength>0?{}:null,extras(e){let t=kt(e.axis);return{reach:e.strength*Math.max(Math.abs(t.x),Math.abs(t.y))}},cases:()=>[E.scatter().list[0],E.scatter({strength:24,axis:"x"}).list[0],E.scatter({strength:6,axis:"y"}).list[0]]}),md=oe({default:()=>gd}),gd=ce({type:"sharpen",surface:"shader",params:{amount:"param",radius:{type:"f32",value:e=>Math.max(e.radius,0)}},prepare:e=>e.amount===0?null:{},cases:()=>[E.sharpen().list[0],E.sharpen({amount:2.5,radius:3}).list[0]]}),bd=oe({default:()=>wd}),wd=ce({type:"streak",surface:"filter",params:{scale:{type:"f32",uses:["threshold"],value:(e,t)=>t.scale},bias:{type:"f32",value:(e,t)=>-t.t*t.scale},intensity:"param",sigma:{type:"f32",uses:["length"],value:(e,t)=>t.sigma},axis:{type:"vec2f",uses:["angle"],value:(e,t)=>[Math.cos(t.rad),Math.sin(t.rad)]}},prepare(e){if(e.intensity<=0||e.length<=0)return null;let t=Math.max(0,Math.min(1,e.threshold));return{t,scale:t<1?1/(1-t):1,sigma:e.length/2,rad:e.angle*Math.PI/180}},extras:(e,t)=>({blur:[t.sigma,.01,t.rad],reach:3*t.sigma}),cases:()=>[E.streak().list[0],E.streak({angle:30,length:80,threshold:.5,intensity:1.5}).list[0],E.streak({angle:90,length:60,threshold:.3,intensity:.7}).list[0]]}),yd=oe({default:()=>vd}),vd=ce({type:"threshold",surface:"shader",params:{level:"param",smoothness:"param"},cases:()=>[E.threshold().list[0],E.threshold({level:.3,smoothness:0}).list[0],E.threshold({level:.6,smoothness:.4}).list[0]]}),xd=oe({default:()=>kd}),kd=ce({type:"twirl",surface:"shader",params:{angle:{type:"f32",value:e=>e.angle*Math.PI/180},radius:"param",center:"param"},prepare:e=>e.angle===0||e.radius<=0?null:{},extras(e){let t=Math.min(e.radius,Math.SQRT2);return{reach:Math.min((Math.max(t-1,0)+2*Math.hypot(e.center.x-.5,e.center.y-.5))*360,800)}},cases:()=>[E.twirl().list[0],E.twirl({angle:-120,radius:.6}).list[0],E.twirl({angle:300,radius:1.4,center:{x:.35,y:.55}}).list[0]]}),Md=oe({default:()=>Sd}),Sd=ce({type:"vignette",surface:"shader",params:{color:"param",amount:"param",radius:"param",softness:"param"},prepare:e=>e.amount<=0||Mt(e.color)[3]<=0?null:{},cases:()=>[E.vignette().list[0],E.vignette({amount:.9,radius:.4,softness:.3}).list[0],E.vignette({amount:.7,color:"#ff8800",radius:.6,softness:.8}).list[0]]}),Ed=oe({default:()=>Ad}),Ad=ce({type:"vintage",surface:"filter",params:{matrix:{type:{array:20,of:"f32"},uses:["amount","warmth"],value(e){let t=Math.max(0,Math.min(1,e.amount)),n=Math.max(-1,Math.min(1,e.warmth)),r=(l,c)=>l+(c-l)*t,s=n>0?n*.15:0,i=n<0?-n*.15:0,a=n<0?-n*.05:0,o=n>0?n*.05:0;return[r(1,.393),r(0,.769),r(0,.189),0,s-a,r(0,.349),r(1,.686),r(0,.168),0,0,r(0,.272),r(0,.534),r(1,.131),0,-i+o,0,0,0,1,0]}}},prepare:e=>e.amount<=0&&e.warmth===0?null:{},cases:()=>[E.vintage().list[0],E.vintage({amount:.5,warmth:-.8}).list[0],E.vintage({amount:0,warmth:1}).list[0]]}),Td=oe({default:()=>Pd}),Pd=ce({type:"wave",surface:"shader",params:{amplitude:"param",wavelength:{type:"f32",value:e=>Math.max(e.wavelength,.01)},phase:{type:"f32",value:e=>(e.phase%360+360)%360*Math.PI/180},direction:{type:"vec2f",uses:["angle"],value(e){let t=e.angle*Math.PI/180;return[Math.cos(t),Math.sin(t)]}},shape:"param",center:"param"},prepare:e=>e.amplitude.x===0&&e.amplitude.y===0?null:{},extras:e=>({reach:Math.max(Math.abs(e.amplitude.x),Math.abs(e.amplitude.y))}),cases:()=>[E.wave().list[0],E.wave({amplitude:{x:8,y:14},wavelength:60,phase:70,angle:35}).list[0],E.wave({amplitude:16,shape:"radial",wavelength:80,center:{x:.4,y:.6}}).list[0]]}),Ii=new Map(Object.entries(Object.assign({"./_pack.ts":yu,"./alpha.ts":xu,"./ascii.ts":Mu,"./bitCrush.ts":Iu,"./blockDisplace.ts":Du,"./bloom.ts":Fu,"./blur.ts":$u,"./bulge.ts":Nu,"./chromaticAberration.ts":Wu,"./colorAdjustment.ts":Hu,"./colorMatrix.ts":Yu,"./curves.ts":Zu,"./directionalBlur.ts":rf,"./dither.ts":af,"./dropShadow.ts":ff,"./duotone.ts":hf,"./edges.ts":bf,"./exposure.ts":yf,"./glass.ts":xf,"./glow.ts":If,"./grain.ts":Of,"./grayscale.ts":Lf,"./halftone.ts":Bf,"./invert.ts":Uf,"./kaleidoscope.ts":Vf,"./lut.ts":Gf,"./magnify.ts":Jf,"./oilPaint.ts":Xf,"./outline.ts":Qf,"./pixelate.ts":nd,"./posterize.ts":sd,"./progressiveBlur.ts":ad,"./radialBlur.ts":cd,"./rgbShift.ts":ud,"./scanlines.ts":dd,"./scatter.ts":pd,"./sharpen.ts":md,"./streak.ts":bd,"./threshold.ts":yd,"./twirl.ts":xd,"./vignette.ts":Md,"./vintage.ts":Ed,"./wave.ts":Td})).filter(([e])=>!e.includes("/_")).map(([,e])=>[e.default.type,e.default])),Id=1073741824,Gr=null;function bn(e){return Gr??=cl(e?{module_or_path:e}:void 0),Gr}var Kn=null;function Zr(){return Kn??=bn().then(()=>Vt.prewarm()).catch(e=>{throw Kn=null,e}),Kn}function Rd(){Kn=null,Gr&&Vt.forget_device()}var Cd={miter:0,round:1,bevel:2},Od={butt:0,round:1,square:2},Ri={clamp:0,repeat:1,mirror:2,decal:3},Dd={rect:1,ellipse:2,path:3},Ld={left:0,right:1,center:2,justify:3},Fd={top:0,center:1,bottom:2},Ci=new TextEncoder,Bd=120;function $d(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e[n],16777619),t^=t>>>15;return t>>>0}function Ud(e){let t=new Uint32Array(e.points.buffer,e.points.byteOffset,e.points.length),n=2166136261,r=16777619^e.points.length;for(let s=0;s<e.verbs.length;s++)n=Math.imul(n^e.verbs[s],16777619),r=Math.imul(r^e.verbs[s],1540483477);for(let s=0;s<t.length;s++)n=Math.imul(n^t[s],16777619),n^=n>>>15,r=Math.imul(r^t[s],1540483477),r^=r>>>13;return`${e.verbs.length}:${t.length}:${n>>>0}:${r>>>0}`}var Qr=class{name="wgpu";r;w;paintIds=new WeakMap;paintByKey=new Map;freePaints=[];pathIds=new WeakMap;pathByKey=new Map;freePaths=[];generation=0;collectUnused=!1;dashIds=new Map;nextPaint=0;nextPath=0;nextDash=0;synced=!1;viewport={w:0,h:0};lastDeltaWords=0;async init(e,t,n){let r=await bn();await Zr().catch(()=>{}),this.attach(await Vt.create(e,t,n),r.memory,t,n)}attach(e,t,n,r){this.r=e,this.w=new wu(this.r,t),this.effectIndex=new Map(this.r.effect_names().map((s,i)=>[s,i])),this.viewport={w:n,h:r},this.shaders=new fl(this.r,()=>this.onShaderReady?.())}shaders;onShaderReady;shaderIssues=new Set;whenShadersReady(){return this.shaders.whenReady()}userProgram(e,t){let n=this.shaders.program(e,t),r=n.report.diagnostics[0]??n.browser.find(s=>s.message.startsWith("error"));return n.state==="failed"&&r&&this.shaderIssues.add(`A WGSL shader ${e} does not compile${r.line?` (line ${r.line}:${r.column})`:""}: ${r.message}`),n}adapterInfo(){return this.r.adapter_info()}gpuDevice(){return this.r.gpu_device()}setOptions(e,t){this.r.set_options(e,t)}resize(e,t){this.r.resize(e,t),this.viewport={w:e,h:t},this.synced=!1}paint(e){if(!e)return mt;let t=this.paintIds.get(e);if(t?.live)return t.used=this.generation,t.id;let n=e.kind==="image"?`image:${e.image.id}:${e.fit??"fill"}:${e.box.join(",")}:${e.matrix?.join(",")??""}:${e.tile??""}`:e.kind==="shader"?`shader:${this.userProgram("fill",e.source).id}:${e.box.join(",")}:${e.time}:${e.texture?.id??""}:${JSON.stringify(e.uniforms)}`:JSON.stringify(e),r=this.paintByKey.get(n);if(r)r.used=this.generation;else{r={id:this.freePaints.pop()??this.nextPaint++,used:this.generation,live:!0},this.paintByKey.set(n,r);let s=r.id,i=this.w;if(e.kind==="procedural")return this.procedural(s,e),this.paintIds.set(e,r),s;if(e.kind==="shader")return this.shaderPaint(s,e),this.paintIds.set(e,r),s;let a=e.kind==="solid"||e.kind==="image"?[]:e.stops;if(i.begin(12+a.length*5),i.u(Se.DEF_PAINT),i.u(s),e.kind==="solid"){i.u(0);for(let o=0;o<4;o++)i.f(0);for(let o of e.color)i.f(o)}else if(e.kind==="image"){let{m:o,tile:l}=Tc(e),c=o[0]*o[3]-o[1]*o[2]||1,u=e.image.width,f=e.image.height,d=o[3]/c,p=-o[1]/c,_=-o[2]/c,w=o[0]/c,A=(o[2]*o[5]-o[3]*o[4])/c,B=(o[1]*o[4]-o[0]*o[5])/c;i.u(4|Ri[l]<<8),i.f(d/u),i.f(p/f),i.f(_/u),i.f(w/f),i.f(A/u),i.f(B/f),i.f(e.image.id),i.f(0)}else{let o=e.kind==="linear"?1:e.kind==="radial"?2:3;i.u(o|Ri[e.tile??"clamp"]<<8),e.kind==="linear"?(i.f(e.from[0]),i.f(e.from[1]),i.f(e.to[0]),i.f(e.to[1])):e.kind==="radial"?(i.f(e.center[0]),i.f(e.center[1]),i.f(e.radius),i.f(0)):(i.f(e.center[0]),i.f(e.center[1]),i.f(e.startAngle),i.f(e.endAngle));for(let l of a[0].color)i.f(l)}i.u(a.length);for(let o of a){i.f(o.offset);for(let l of o.color)i.f(l)}}return this.paintIds.set(e,r),r.id}shaderPaint(e,t){let n=this.userProgram("fill",t.source),r=n.report.ok?si(n.report.fields,n.report.size,t.uniforms):new Uint32Array(0),s=Math.ceil(r.length/4),i=this.w;i.begin(12+s*5),i.u(Se.DEF_PAINT),i.u(e),i.u(10);for(let a of t.box)i.f(a);i.f(t.time),i.f(t.texture?t.texture.id:-1),i.f(n.id),i.f(0),i.u(s);for(let a=0;a<s;a++){i.f(0);for(let o=0;o<4;o++)i.u(r[a*4+o]??0)}}procedural(e,t){let n=t.fill,[r,s,i,a]=t.box,o,l,c,u=[],f=[],d=w=>[Math.round(w[0]*255)/255,Math.round(w[1]*255)/255,Math.round(w[2]*255)/255,w[3]];if(n.type==="dotGrid")o=5,l=[r+n.offset.x,s+n.offset.y,Math.max(.01,n.spacing),Math.max(0,n.radius)],c=[...n.color];else if(n.type==="grid")o=6,l=[r+n.offset.x,s+n.offset.y,i,a],c=[...n.color],u.push([Math.max(1e-4,n.divisions),Math.max(1,Math.round(n.subdivisions)),Math.max(0,n.strokeWidth)*.5,Math.max(0,n.subdivisionWidth)*.5]);else if(n.type==="stripe"){o=7;let w=(n.angle??-45)*Math.PI/180;l=[r,s,Math.max(1,Math.round(n.gap??8)),n.strokeWidth??1],c=d(n.color??[0,0,0,1]),u.push([Math.cos(w),Math.sin(w),r,0])}else if(n.type==="noise"){o=8,l=[r,s,Math.ceil(i),Math.ceil(a)];let w=d(n.color);c=[w[0],w[1],w[2],Math.round(n.color[3]*255)/255],u.push([Math.max(1,Math.round(n.size.x)),Math.max(1,Math.round(n.size.y)),Math.min(1,Math.max(0,n.density)),Math.round(n.seed)])}else{o=9,l=[r,s,i,a];let w=n.angle*Math.PI/180,A={value:0,simplex:1,ridged:2,worley:3}[n.basis]??1;u.push([n.frequency.x,n.frequency.y,n.offset.x,n.offset.y]),u.push([n.lacunarity,n.gain,n.seed,n.contrast]),u.push([Math.cos(w),Math.sin(w),A,n.octaves]);let B=Math.max(2,Math.min(8,n.colors.length));for(let L=0;L<B;L++)f.push({offset:n.stops[Math.min(L,n.stops.length-1)]??L/(B-1),color:[...n.colors[Math.min(L,n.colors.length-1)]]});c=f[0].color}let p=u.length+f.length,_=this.w;_.begin(12+p*5),_.u(Se.DEF_PAINT),_.u(e),_.u(o);for(let w of l)_.f(w);for(let w of c)_.f(w);_.u(p);for(let w of u){_.f(0);for(let A of w)_.f(A)}for(let w of f){_.f(w.offset);for(let A of w.color)_.f(A)}}pathId(e){let t=this.pathIds.get(e);if(t?.live)return t.used=this.generation,t.id;let n=Ud(e),r=this.pathByKey.get(n);if(r)return r.used=this.generation,this.pathIds.set(e,r),r.id;let s={id:this.freePaths.pop()??this.nextPath++,used:this.generation,live:!0};this.pathByKey.set(n,s);let i=s.id,a=this.w,o=Math.ceil(e.verbs.length/4);a.begin(4+o+e.points.length),a.u(Se.DEF_PATH),a.u(i),a.u(e.verbs.length),a.u(e.points.length/2);for(let l=0;l<o;l++){let c=e.verbs,u=l*4;a.u((c[u]??0)|(c[u+1]??0)<<8|(c[u+2]??0)<<16|(c[u+3]??0)<<24)}for(let l=0;l<e.points.length;l++)a.f(e.points[l]);return this.pathIds.set(e,s),i}sweep(){let e=this.generation-Bd;for(let[t,n]of this.pathByKey)n.used>=e||(n.live=!1,this.pathByKey.delete(t),this.w.begin(2),this.w.u(Se.FREE_PATH),this.w.u(n.id),this.freePaths.push(n.id));for(let[t,n]of this.paintByKey)n.used>=e||(n.live=!1,this.paintByKey.delete(t),this.freePaints.push(n.id))}dash(e,t=0){if(!e||e.length===0)return mt;let n=e.join(",")+"@"+t,r=this.dashIds.get(n);if(r===void 0){r=this.nextDash++,this.dashIds.set(n,r);let s=this.w;s.begin(4+e.length),s.u(Se.DEF_DASH),s.u(r),s.u(e.length),s.f(t);for(let i of e)s.f(i)}return r}writeNode(e,t){let n=this.w,r=e.id;if(t&ke.CREATE&&(n.begin(3),n.u(Se.CREATE),n.u(r),n.u(xc[e.kind])),t&ke.TRANSFORM){let s=e.transform;if(Vn(s)){n.begin(11),n.u(Se.TRANSFORM3),n.u(r);for(let i of s)n.f(i)}else{n.begin(8),n.u(Se.TRANSFORM),n.u(r);for(let i=0;i<6;i++)n.f(s[i])}}if(t&ke.EFFECTS&&(e.effects?.length||!(t&ke.CREATE))&&this.writeEffects(e),t&ke.OPACITY&&(e.opacity!==1||!(t&ke.CREATE))&&(n.begin(3),n.u(Se.OPACITY),n.u(r),n.f(e.opacity)),t&ke.BLEND&&(e.blend!=="normal"||!(t&ke.CREATE))&&(n.begin(3),n.u(Se.BLEND),n.u(r),n.u(qi.indexOf(e.blend))),e.kind==="group"){if(t&ke.CLIP&&(e.clip||!(t&ke.CREATE))){let s=e.clip,i=s?.path?this.pathId(s.path):mt,a=s?.path?it(s.path):[s?.x??0,s?.y??0,(s?.x??0)+(s?.w??0),(s?.y??0)+(s?.h??0)];n.begin(10),n.u(Se.CLIP),n.u(r),n.u(s?1:0);for(let o of a)n.f(o);n.f(s?.r??0),n.u(i),n.u(s?.evenOdd?1:0)}if(t&ke.MASK&&(e.mask||!(t&ke.CREATE))&&(n.begin(3),n.u(Se.MASK),n.u(r),n.u(e.mask?Mc[e.mask]:0)),t&ke.FILTER&&(e.filter||!(t&ke.CREATE))){let s=e.filter;if(n.begin(10),n.u(Se.FILTER),n.u(r),s)if(s.kind==="blur"){n.u(1),n.f(s.sigma);for(let i=0;i<6;i++)n.f(0)}else{n.u(2),n.f(s.sigma),n.f(s.dx),n.f(s.dy);for(let i of s.color)n.f(i)}else{n.u(0);for(let i=0;i<7;i++)n.f(0)}}if(t&ke.CHILDREN){n.begin(3+e.children.length),n.u(Se.CHILDREN),n.u(r),n.u(e.children.length);for(let s of e.children)n.u(s.id)}return}if(t&ke.SIZE&&(n.begin(4),n.u(Se.SIZE),n.u(r),n.f(e.w),n.f(e.h)),t&ke.RADII&&e.kind==="rect"){n.begin(6),n.u(Se.RADII),n.u(r);for(let s of e.radii)n.f(s)}if(t&ke.MEMBERS&&e.members){let s=e.members,i=s.map(a=>a.kind==="path"&&a.path?this.pathId(a.path):mt);n.begin(3+s.length*16),n.u(Se.MEMBERS),n.u(r),n.u(s.length),s.forEach((a,o)=>{n.u(Dd[a.kind]),n.u(kc[Ac(a)]);for(let l of a.transform??[1,0,0,1,0,0])n.f(l);n.f(a.w??0),n.f(a.h??0);for(let l of a.radii??[0,0,0,0])n.f(l);n.u(i[o]),n.u(a.evenOdd?1:0)})}if(t&ke.TEXT&&e.text){let s=e.text,i=s.runs.map(c=>[Ci.encode(c.family),Ci.encode(c.text)]),a=i.reduce((c,[u,f])=>c+2+Math.ceil(u.length/4)+Math.ceil(f.length/4)+6,0),o=s.path?this.pathId(s.path):mt,l=s.runs.map(c=>this.paint(c.paint));n.begin(12+a),n.u(Se.TEXT),n.u(r),n.u(Ld[s.align??"center"]),n.u(Fd[s.verticalAlign??"center"]),n.u(s.wrap?1:0),n.f(s.fontSize==="autofit"?0:s.runs.length===1?s.runs[0].size:0),n.f(s.minFontSize??0),n.f(s.lineHeight??0),n.f(s.width??0),n.f(s.height??0),n.u(s.runs.length),s.runs.forEach((c,u)=>{n.u(c.decoration==="underline"?1:c.decoration==="lineThrough"?2:0),n.u(l[u]),n.f(c.size),n.f(c.weight??400),n.u(c.italic?1:0),n.f(c.letterSpacing??0);for(let f of i[u]){n.u(f.length);for(let d=0;d<f.length;d+=4)n.u((f[d]??0)|(f[d+1]??0)<<8|(f[d+2]??0)<<16|(f[d+3]??0)<<24)}}),n.u(o)}if(t&ke.PATH&&e.path){let s=this.pathId(e.path);n.begin(4),n.u(Se.PATH),n.u(r),n.u(s),n.u(e.evenOdd?1:0)}if(t&ke.FILL){let s=this.paint(e.fill);n.begin(3),n.u(Se.FILL),n.u(r),n.u(s)}if(t&ke.STROKE&&(e.stroke||!(t&ke.CREATE))){let s=e.stroke,i=this.paint(s?.paint),a=this.dash(s?.dash,s?.dashPhase);n.begin(8),n.u(Se.STROKE),n.u(r),n.u(i),n.f(s?.width??0),n.u(Cd[s?.join??"miter"]),n.u(Od[s?.cap??"butt"]),n.f(s?.miter??4),n.u(a)}if(t&ke.SHADOWS&&(e.shadows.length||!(t&ke.CREATE))){n.begin(3+e.shadows.length*8),n.u(Se.SHADOWS),n.u(r),n.u(e.shadows.length);for(let s of e.shadows){n.f(s.dx),n.f(s.dy),n.f(s.sigma),n.f(s.spread);for(let i of s.color)n.f(i)}}}uploaded=new Map;missing3d=new Set;textures3d=new Map;geometries3d=new Map;bindTextures3d(e,t){let n=new Set(t.pending.splice(0));for(let r of n){let s=r.texture;"data"in s&&this.r.scene3d_pixels(e.id,r.id,Uint8Array.from(s.data),s.width,s.height,r.srgb)}for(let r of t.all.values()){let s=r.texture;if("data"in s)continue;let i="src"in s?e.links3d?.images?.[s.src]:e.links3d?.surfaces?.get(s);i?this.r.scene3d_bind(e.id,r.id,i.id,r.srgb):n.has(r)&&this.missing3d.add("src"in s?`image:${s.src}`:"surface")}}scene3dSigs=new Map;forgetScene3d(e){this.textures3d.delete(e),this.geometries3d.delete(e),this.scene3dSigs.delete(e)}encode3dMs=0;words3d=0;effectIndex=new Map;auxIds=new Map;missing=new Set;effectTypes(){return[...this.effectIndex.keys()].filter(e=>Ii.has(e))}auxId(e){if(!e)return mt;let t=this.auxIds.get(e.key);if(t===void 0){t=1e6+this.auxIds.size;let n=new OffscreenCanvas(e.width,e.height);n.getContext("2d").putImageData(new ImageData(new Uint8ClampedArray(e.pixels),e.width,e.height),0,0),this.r.upload_image(t,n,!1),this.auxIds.set(e.key,t)}return t}writeEffects(e){let t=e.effects??[],n=[];for(let[i,a]of[["shader",!1],["filter",!1],["filter",!0],["shader",!0]])for(let o of t){if(o.type==="shader"){if(o.mode==="backdrop"!==a||(a?"shader":"filter")!==i)continue;let f=this.userEffect(o);f&&n.push({...f,flags:(o.clip?1:0)|(a?2:0)});continue}let l=Ii.get(o.type),c=this.effectIndex.get(o.type);if(!l||c===void 0){this.missing.has(o.type)||console.info(`effect "${o.type}" has no WGSL port yet; skipped`),this.missing.add(o.type);continue}if(l.surface!==i||o.mode==="backdrop"!==a||l.backdropOnly&&!a)continue;let u=l.pack(o);u&&n.push({index:c,flags:(o.clip?1:0)|(a?2:0)|(a&&i==="filter"?4:0)|(u.field?8:0),aux:this.auxId(u.aux),p:u})}let r=this.w,s=e.effectBox??[0,0,0,0];r.begin(8+n.reduce((i,a)=>i+8+a.p.params.length+(a.words?.length??0),0)),r.u(Se.EFFECTS),r.u(e.id);for(let i of s)r.f(i);r.f(e.effectTime??0),r.u(n.length);for(let i of n){r.u(i.index),r.u(i.flags),r.u(i.aux),r.f(i.p.reach??0);let a=i.p.blur??[0,0,0];r.f(a[0]),r.f(a[1]),r.f(a[2]),r.u(i.p.params.length+(i.words?.length??0));for(let o of i.p.params)r.f(o);if(i.words)for(let o of i.words)r.u(o)}}userEffect(e){if(!e.source?.trim())return null;if(!Ni(e))return this.shaderIssues.add(wl),null;let t=this.userProgram("effect",e.source);if(!t.report.ok)return null;let n=ji(e.uniforms),r=e.mode!=="backdrop"&&e.blendMode?(bl[e.blendMode]??-1)+1:0;return{index:Id+t.id,aux:mt,p:{params:[r],reach:Math.max(0,e.reach??0)},words:si(t.report.fields,t.report.size,n)}}frameCanvases=new Map;colorCorrect(e){if(typeof VideoFrame>"u"||!(e.source instanceof VideoFrame))return e.source;let t=this.frameCanvases.get(e.id);return(!t||t.width!==e.width||t.height!==e.height)&&(t=new OffscreenCanvas(e.width,e.height),this.frameCanvases.set(e.id,t)),t.getContext("2d").drawImage(e.source,0,0),t}sync(e){this.generation++,this.encode3dMs=0,this.words3d=0;for(let n of e.images)if(this.uploaded.get(n.id)!==n.version){if(n.surface)this.forgetScene3d(n.id),this.r.set_surface(n.id,n.surface.id,n.width,n.height);else if(n.scene3d){let r=this.viewport.w/e.width,s={unsupported:new Set},i=this.textures3d.get(n.id);i||this.textures3d.set(n.id,i=new hu);let[a,o]=n.scale3d?[Math.ceil(n.width*n.scale3d),Math.ceil(n.height*n.scale3d)]:[Math.round(n.width*r),Math.round(n.height*r)],l=performance.now(),c=this.geometries3d.get(n.id);c||this.geometries3d.set(n.id,c=new _u);let u=bu(n.scene3d,s,i,c),f=`${a}x${o}:${u.length}:${$d(u)}`;if(this.encode3dMs+=performance.now()-l,this.words3d+=u.length,this.scene3dSigs.get(n.id)!==f){try{this.r.set_scene3d(n.id,a,o,u)}catch(d){throw this.geometries3d.delete(n.id),this.scene3dSigs.delete(n.id),d}this.scene3dSigs.set(n.id,f)}for(let d of s.unsupported)this.missing3d.add(d);this.bindTextures3d(n,i)}else this.forgetScene3d(n.id),this.r.upload_image(n.id,this.colorCorrect(n),n.mipmaps);this.uploaded.set(n.id,n.version)}let t=this.w;if(this.synced)for(let n of e.dirty)this.writeNode(n,n.dirty);else{for(let n of e.nodes)this.writeNode(n,ke.ALL);t.begin(2),t.u(Se.ROOT),t.u(e.root.id),t.begin(8),t.u(Se.VIEWPORT),t.u(this.viewport.w),t.u(this.viewport.h),t.f(this.viewport.w/e.width);for(let n of e.background)t.f(n);this.synced=!0}for(let n of e.dirty)n.dirty=0;e.dirty.clear(),this.collectUnused&&this.generation%30===0&&this.sweep(),t.flush(),this.lastDeltaWords=t.takeCount()}render(){this.r.render()}invalidate(){this.r.invalidate()}waitGpu(){return this.r.wait_gpu()}async readPixels(){return await this.r.read_pixels()}stats(){let e=this.r.stats();return{buildMs:e[0],encodeMs:e[1],applyMs:e[2],prims:e[3],ops:e[4],layers:e[5],passes:e[6],draws:e[7],culled:e[8],tessellated:e[9],poolTextures:e[10],poolMiB:e[11],geomVertices:e[12],reusedPrims:e[13],cleanPrims:e[14],deltaWords:this.lastDeltaWords,scene3dEncodeMs:this.encode3dMs,scene3dWords:this.words3d,scene3dSetMs:e[15],scene3dDrawMs:e[16],scene3dMapsMs:e[17],surfacesDrawn:e[18],surfaces:e[19]}}registerFont(e,t){this.r.register_font(e,t)}destroy(){this.r.free()}},Pa={normal:0,italic:1,oblique:2},Nd={left:0,right:1,center:2,justify:3,start:4,end:5},jd={top:0,center:1,bottom:2},Oi=new WeakMap;function es(e){let t=Oi.get(e);if(!t){let n=t=new Ur;for(let r of e.fonts)n.register_font(r.bytes,r.family);e.onFont(r=>n.register_font(r.bytes,r.family)),Oi.set(e,n)}return t}function ts(e,t,n,r,s=400,i=0,a){let[o,l]=e.measure_text(t,n,r,s,i,Pa[a??"normal"]??0);return{width:o,height:l}}function Ia(e,t){let n=Ki(t);if(n.path!=null)return null;let r=n.fontSize==="autofit",s={text:String(n.text??""),fontFamily:n.fontFamily,fontSize:r?100:n.fontSize,fontWeight:n.fontWeight,fontStyle:n.fontStyle,letterSpacing:n.letterSpacing},i=Array.isArray(n.segments)&&n.segments.length?n.segments:[s];if(i.some(_=>(_.x??0)!==0||(_.y??0)!==0||(_.rotation??0)!==0||(_.scale??1)!==1))return null;let a=[],o=[],l="";for(let _ of i){let w=_.fontFamily??s.fontFamily??"",A=a.indexOf(w);A<0&&(A=a.push(w)-1);let B=String(_.text??"");l+=B,o.push(B.length,_.fontSize??s.fontSize,_.fontWeight??s.fontWeight??400,Pa[_.fontStyle??s.fontStyle??"normal"]??0,_.letterSpacing??s.letterSpacing??0,A)}let c=n.width??0,u=n.height??0,f=e.text_block(l,new Float32Array(o),a.join(`
703
+ `),r?NaN:s.fontSize,n.minFontSize??0,n.lineHeight??0,Nd[n.textAlign??"center"]??2,jd[n.verticalAlign??"center"]??1,!!n.wrap&&c>0,c,u);if(!f.length)return null;let d=[],p=3;for(let _=0;_<f[2];_++){let[w,A,B,L,V]=f.subarray(p,p+5);d.push({start:w,end:A,top:B,bottom:L,carets:Array.from(f.subarray(p+5,p+5+V))}),p+=5+V}return{lines:d,width:f[0],height:f[1]}}var Wd=3,Vd=6e4,zd=32,Hr=new Set,mn=new Set,Di=new WeakSet,sn=[],Gd=0,zt=null,Li=!1;function Hd(e){return Hr.add(e),()=>Hr.delete(e)}function Kd(){return zt}function qd(e){return Zd(),mn.add(e),zt!==null&&(e.queueIssue(Ra(zt)),e.halt()),()=>mn.delete(e)}function Jd(e){let t=e;!t||Di.has(t)||(Di.add(t),t.addEventListener?.("uncapturederror",n=>Yd(n.error)),t.lost.then(n=>Xd(n.reason??"unknown",n.message??"")))}function qn(e){for(let t of[...Hr])try{t(e)}catch(n){console.error("[wgpu] a fault listener threw:",n)}}function ns(e){for(let t of mn)t.queueIssue(e)}function Yd(e){if(++Gd>zd)return;let t=e?.constructor?.name??"",n=t==="GPUOutOfMemoryError"?"out-of-memory":t==="GPUInternalError"?"internal":"validation",r=`WebGPU ${n} error: ${e?.message??String(e)}`;ns({kind:"gpu",feature:`gpu:${n}`,message:r}),qn({type:"gpu-error",error:n,message:r})}function Xd(e,t){if(zt!==null)return;Rd();let n=performance.now();for(;sn.length&&n-sn[0]>Vd;)sn.shift();let r=`The GPU device was lost (${e}${t?`: ${t}`:""}); the renderer is drawing on a new one.`;if(qn({type:"device-lost",reason:e,message:r}),sn.length>=Wd){Kr("The GPU device was lost 4 times within a minute; the renderer stopped asking for a new one.");return}sn.push(n),ns({kind:"device-lost",message:r});for(let s of[...mn])s.remount();Zr().then(()=>qn({type:"device-restored"}),s=>Kr(`No GPU device after a loss: ${String(s?.message??s)}`))}function Ra(e){return{kind:"crashed",message:e}}function Kr(e){zt===null&&(zt=e,queueMicrotask(()=>{ns(Ra(e));for(let t of[...mn])t.halt();qn({type:"crashed",message:e})}))}function Zd(){Li||(Li=!0,Rc(e=>Kr(`The renderer panicked and draws nothing more on this page (reload to recover): ${e}`)))}var Fi=new Set,Ca=/-not-(?:decoded|loaded)$/,Wn={"text:path":"Text on a path",rasterize:"rasterize()","boolean:nested":"A boolean nested in one of another kind","boolean:projective":"A boolean under a 3D (projective) transform","cut:compound":"A cut through a compound shape","stroke:union-of-booleans":"One stroke around several booleans","effect:motionBlur-shutter":"Motion blur with an off-centre shutter or over 32 samples","surface:error":"A surface texture that failed to draw","blend:":"The blend mode","fill:blend:":"The fill blend mode","op:":"The drawing op","fill:":"The fill","effect:":"The effect","3d:":"In 3D,"};function jt(e){if(Wn[e])return`${Wn[e]} is not drawn by the WebGPU renderer.`;let t=Object.keys(Wn).filter(n=>n.endsWith(":")&&e.startsWith(n)).sort((n,r)=>r.length-n.length)[0];return t?`${Wn[t]} "${e.slice(t.length)}" is not drawn by the WebGPU renderer.`:`Not drawn by the WebGPU renderer: ${e}.`}var Qd=class extends va{store;view={zoom:1,x:0,y:0};frame=null;clipToFrame=!0;frameBackground="black";canvas=null;size={width:1,height:1};backend=null;starting=null;startFailed=!1;startToken=null;lastDoc=null;viewportKey="";shaper;stopFonts;stopSettle;stopFaults;faults=[];halted=!1;constructor(e,t){let n=es(e);super(t.width,t.height,(r,s,i,a,o,l)=>ts(n,r,s,i,a,o,l)),this.store=e,this.shaper=n,this.storage=e,this.images=e.images,this.stopFonts=e.onFont(r=>this.backend?.registerFont(r.bytes,r.family)),this.stopSettle=e.addSettler(()=>this.starting&&!this.startFailed?this.starting.catch(()=>{}):this.backend?.shaders.hasPending()?this.backend.whenShadersReady():null),this.stopFaults=qd({queueIssue:r=>this.faults.push(r),remount:()=>this.remount(),halt:()=>this.halt()})}stats(){return this.backend?.stats()??null}mount(e){let t=e;if(this.size={width:Math.max(1,t.width),height:Math.max(1,t.height)},t===this.canvas&&(this.backend||this.starting)){this.present();return}if(this.releaseBackend(),this.canvas=t,this.halted||Kd()!==null)return;let n={};this.startToken=n,this.startFailed=!1;let r=this.starting=(async()=>{let s=new Qr;if(await s.init(t,this.size.width,this.size.height),this.startToken!==n){this.halted||s.destroy();return}Jd(s.gpuDevice()),s.setOptions(!1,!1),s.collectUnused=!0,s.onShaderReady=()=>this.present();for(let i of this.store.fonts)s.registerFont(i.bytes,i.family);this.backend=s,this.starting=null,this.present()})();r.catch(s=>{this.starting===r&&(this.startFailed=!0),console.error("[wgpu] the renderer failed to start:",s)})}whenMounted(){return this.starting??Promise.resolve()}unmount(){this.releaseBackend(),this.canvas=null}execute(e){if(!(!this.canvas||this.isDisposed())){this.width=this.size.width/this.pixelRatio,this.height=this.size.height/this.pixelRatio;try{super.execute(e)}finally{this.lastDoc=this.doc,this.present();for(let t of this.missing)Fi.has(t)||t.endsWith("-not-decoded")||(Fi.add(t),console.warn(`[wgpu] not drawn yet: ${t}`))}}}takeRenderIssues(){let e=new Map,t=r=>e.set(zi(r),r);for(let r of this.faults.splice(0))t(r);let n=this.halted?null:this.backend;for(let r of n?.shaderIssues??[])t({kind:"shader",...r==="A shader effect is written in SkSL, which Motion Script no longer runs, so it is skipped. Port it to WGSL (fn effect(in: EffectIn) -> vec4f)."&&{feature:"effect:shader-sksl"},message:r});n?.shaderIssues.clear();for(let r of this.shaderIssues)t(r);for(let r of this.missing){if(Ca.test(r))continue;let s=r==="fill:shader-sksl"?{kind:"shader",feature:r,message:ra}:{kind:"missing",feature:r,message:jt(r)},i=this.missing.nodes.get(r);if(!i?.size)t(s);else for(let a of i)t({...s,nodeId:a})}for(let r of n?.missing??[])t({kind:"missing",feature:`effect:${r}`,message:jt(`effect:${r}`)});for(let r of n?.missing3d??[])t({kind:"missing",feature:`3d:${r}`,message:jt(`3d:${r}`)});return[...e.values()]}whenShadersReady(){return this.backend?.whenShadersReady()??Promise.resolve()}layoutTextBlock(e){return Ia(this.shaper,e)}screenshot(e="image/png",t){return this.snapshotCanvas()?.toDataURL(e,t)}snapshotCanvas(){let e=this.canvas;if(!e||!this.backend||!this.lastDoc)return;this.present();let[t,n,r,s]=[0,0,e.width,e.height];if(this.frame){let o=this.pixelRatio,l=this.view.zoom,c=e.width/2+this.view.x*o,u=e.height/2+this.view.y*o,f=this.frame.width*l*o,d=this.frame.height*l*o;t=Math.max(0,Math.round(c-f/2)),n=Math.max(0,Math.round(u-d/2)),r=Math.max(1,Math.min(e.width-t,Math.round(f))),s=Math.max(1,Math.min(e.height-n,Math.round(d)))}let i=document.createElement("canvas");i.width=r,i.height=s;let a=i.getContext("2d");if(a)return a.drawImage(e,t,n,r,s,0,0,r,s),i}dispose(){this.releaseBackend(),this.stopFonts(),this.stopSettle(),this.stopFaults(),this.canvas=null,this.lastDoc=null,this.store.dispose(),super.dispose()}rootTransform(){let e=this.view.zoom;return[e,0,0,e,this.width/2+this.view.x,this.height/2+this.view.y]}clearColor(){return this.frame?[0,0,0,0]:[0,0,0,1]}frameGroup(e){let t=this.frame;if(!t)return e;let n={x:-t.width/2,y:-t.height/2,w:t.width,h:t.height};return this.frameBackground==="black"&&this.doc.rect(e,{transform:[1,0,0,1,n.x,n.y],w:n.w,h:n.h,fill:{kind:"solid",color:[0,0,0,1]}}),this.clipToFrame?this.doc.group(e,{clip:{...n,r:0}}):e}present(){let e=this.backend,t=this.canvas,n=this.lastDoc;if(!e||!t||!n||this.halted)return;let{width:r,height:s}=this.size,i=`${r}x${s}/${n.width}/${n.background.join(",")}`;(i!==this.viewportKey||t.width!==r||t.height!==s)&&(e.resize(r,s),this.viewportKey=i);try{e.sync(n),e.render()}catch(a){console.error("[wgpu] frame failed:",a)}}releaseBackend(){this.starting=null,this.startToken=null,this.halted||this.backend?.destroy(),this.backend=null,this.viewportKey=""}remount(){let e=this.canvas;!e||this.isDisposed()||this.halted||(this.releaseBackend(),this.mount(e))}halt(){this.halted=!0,this.releaseBackend()}},eh=827872077;var Le={BEGIN:1,APPLY:2,FONT:3,IMAGE:4,SURFACE:5,SCENE3D:6,SCENE3D_BIND:7,SCENE3D_PIXELS:8,FREE_IMAGE:9,SHADER_ADD:10,SHADER_BUILD:11,SHADER_REMOVE:12,OPTIONS:13,RESIZE:14,FRAME:15,AUDIO:16,END:17,INVALIDATE:18,CREATE:19},Jn=Le,Bi=new TextEncoder,th=class{buf=new Uint8Array(1<<20);view=new DataView(this.buf.buffer);pos=0;taken=0;constructor(){this.u32(eh),this.u32(1)}get size(){return this.pos}reserve(e){if(this.pos+e<=this.buf.length)return;let t=this.buf.length*2;for(;t<this.pos+e;)t*=2;let n=new Uint8Array(t);n.set(this.buf.subarray(0,this.pos)),this.buf=n,this.view=new DataView(n.buffer)}u32(e){this.reserve(4),this.view.setUint32(this.pos,e>>>0,!0),this.pos+=4}record(e,t,n){let r=t.length*4+(n?.length??0),s=r+3&-4;this.reserve(8+s),this.view.setUint32(this.pos,e,!0),this.view.setUint32(this.pos+4,r,!0),this.pos+=8;for(let i=0;i<t.length;i++)this.view.setUint32(this.pos,t[i]>>>0,!0),this.pos+=4;n&&(this.buf.set(n,this.pos),this.pos+=n.length),this.buf.fill(0,this.pos,this.pos+s-r),this.pos+=s-r}recordWords(e,t,n){let r=new Uint8Array(n.buffer,n.byteOffset,n.length*4);this.record(e,t,r)}take(){let e=this.buf.slice(0,this.pos);return this.taken+=this.pos,this.pos=0,e}};function nh(e,t){let n=e,r=n.displayWidth??n.naturalWidth??n.videoWidth??n.width??0,s=n.displayHeight??n.naturalHeight??n.videoHeight??n.height??0;if(!r||!s)throw new Error("upload_image: empty source");let i=t.c;(!i||i.width!==r||i.height!==s)&&(i=t.c=new OffscreenCanvas(r,s));let a=i.getContext("2d",{willReadFrequently:!0});a.clearRect(0,0,r,s),a.drawImage(e,0,0);let o=a.getImageData(0,0,r,s).data;return{w:r,h:s,rgba:new Uint8Array(o.buffer,o.byteOffset,o.byteLength)}}var rh=class{out;effects;memory=new WebAssembly.Memory({initial:4});scratch={};imageUploads=0;imageMs=0;constructor(e,t,n,r){this.out=e,this.effects=t,e.record(Le.CREATE,[n,r])}delta_buffer(e){let t=e*4;return this.memory.buffer.byteLength<t&&this.memory.grow(Math.ceil((t-this.memory.buffer.byteLength)/65536)),0}delta_capacity(){return this.memory.buffer.byteLength/4}apply(e){e>0&&this.out.recordWords(Le.APPLY,[],new Uint32Array(this.memory.buffer,0,e))}effect_names(){return[...this.effects]}adapter_info(){return"native export host"}gpu_device(){return null}set_options(e,t){this.out.record(Le.OPTIONS,[+e,+t])}resize(e,t){this.out.record(Le.RESIZE,[e,t])}register_font(e,t){let n=Bi.encode(t),r=new Uint8Array((n.length+3&-4)+e.length);return r.set(n),r.set(e,n.length+3&-4),this.out.record(Le.FONT,[n.length],r),0}upload_image(e,t,n){let r=performance.now(),{w:s,h:i,rgba:a}=nh(t,this.scratch);this.out.record(Le.IMAGE,[e,s,i,n?1:0],a),this.imageUploads++,this.imageMs+=performance.now()-r}set_scene3d(e,t,n,r){this.out.recordWords(Le.SCENE3D,[e,t,n],r instanceof Uint32Array?r:Uint32Array.from(r))}set_surface(e,t,n,r){this.out.record(Le.SURFACE,[e,t,n,r])}scene3d_bind(e,t,n,r){this.out.record(Le.SCENE3D_BIND,[e,t,n,+r])}scene3d_pixels(e,t,n,r,s,i){this.out.record(Le.SCENE3D_PIXELS,[e,t,r,s,+i],n)}scene3d_skipped(e){return[]}free_image(e){this.out.record(Le.FREE_IMAGE,[e])}shader_add(e,t,n){let r=Xi(t,n);return JSON.parse(r).ok&&this.out.record(Le.SHADER_ADD,[e,t],Bi.encode(n)),r}shader_build(e){this.out.record(Le.SHADER_BUILD,[e])}shader_remove(e){this.out.record(Le.SHADER_REMOVE,[e])}shader_formats(e){return[]}render(){}invalidate(){this.out.record(Le.INVALIDATE,[])}wait_gpu(){return Promise.resolve()}read_pixels(){return Promise.reject(new Error("A native export surface cannot be read back."))}stats(){return new Float64Array(20)}free(){}},sh=class extends va{store;out;size;recorder;backend=new Qr;shaper;stopFonts;stopSettle;viewportKey="";frameCount=0;constructor(e,t,n,r,s){let i=es(e);super(t.width,t.height,(o,l,c,u,f,d)=>ts(i,o,l,c,u,f,d)),this.store=e,this.out=n,this.size=s,this.shaper=i,this.storage=e,this.images=e.images,this.recorder=new rh(n,r,s.width,s.height);let a=this.recorder.memory;this.backend.attach(this.recorder,a,s.width,s.height),this.backend.setOptions(!1,!1),this.backend.collectUnused=!0;for(let o of e.fonts)this.backend.registerFont(o.bytes,o.family);this.stopFonts=e.onFont(o=>this.backend.registerFont(o.bytes,o.family)),this.stopSettle=e.addSettler(()=>this.backend.shaders.hasPending()?this.backend.whenShadersReady():null)}mount(){}unmount(){}whenMounted(){return Promise.resolve()}execute(e){if(!this.isDisposed()){this.width=this.size.width/this.pixelRatio,this.height=this.size.height/this.pixelRatio;try{super.execute(e)}finally{let t=this.doc,n=`${this.size.width}x${this.size.height}/${t.width}/${t.background.join(",")}`;n!==this.viewportKey&&(this.backend.resize(this.size.width,this.size.height),this.viewportKey=n),this.backend.sync(t)}}}frameDone(){this.out.record(Le.FRAME,[this.frameCount++])}takeRenderIssues(){let e=new Map,t=n=>e.set(zi(n),n);for(let n of this.backend.shaderIssues)t({kind:"shader",...n==="A shader effect is written in SkSL, which Motion Script no longer runs, so it is skipped. Port it to WGSL (fn effect(in: EffectIn) -> vec4f)."&&{feature:"effect:shader-sksl"},message:n});this.backend.shaderIssues.clear();for(let n of this.shaderIssues)t(n);for(let n of this.missing){if(Ca.test(n))continue;let r=n==="fill:shader-sksl"?{kind:"shader",feature:n,message:ra}:{kind:"missing",feature:n,message:jt(n)},s=this.missing.nodes.get(n);if(!s?.size)t(r);else for(let i of s)t({...r,nodeId:i})}for(let n of this.backend.missing)t({kind:"missing",feature:`effect:${n}`,message:jt(`effect:${n}`)});for(let n of this.backend.missing3d)t({kind:"missing",feature:`3d:${n}`,message:jt(`3d:${n}`)});return[...e.values()]}layoutTextBlock(e){return Ia(this.shaper,e)}dispose(){this.stopFonts(),this.stopSettle(),this.store.dispose(),super.dispose()}},$r=8192,ih=12,an=e=>e.toFixed(4);function dn(e,t,n){let r=e.get(t);if(r)return r;let s=n().finally(()=>e.delete(t));return e.set(t,s),s}async function ah(e){let t=await fetch(e);if(!t.ok)throw new Error(`${e}: HTTP ${t.status}`);return t.blob()}var $i=new WeakMap;function oh(e){let t=$i.get(e);if(!t){let n=new Map;t=r=>dn(n,r,()=>e(r)),$i.set(e,t)}return t}var ch=class extends Ho{fps;images=new Map;videos=new Map;fonts=[];fontListeners=new Set;registeredFamilies=new Set;pending=new Map;vectors=new Map;upgrades=new Map;settlers=new Set;audioData=new Map;imageLoads=new Map;videoLoads=new Map;fontLoads=new Map;frameDecodes=new Map;loadBytes;constructor(e,t,n,r=ah){super(e,t),this.fps=n,this.loadBytes=oh(r)}get size(){return this.viewport}addSettler(e){return this.settlers.add(e),()=>this.settlers.delete(e)}onFont(e){return this.fontListeners.add(e),()=>this.fontListeners.delete(e)}loadImage(e){let t=wt(e);return this.images.has(t)?Promise.resolve():dn(this.imageLoads,t,()=>this.decodeImage(e,t))}async decodeImage(e,t){let n=this.url(e,a=>a.getImageMeta(e)),r=await this.loadBytes(n),s;if(r.type==="image/svg+xml"||/\.svg(\?|#|$)/i.test(n)){let a=new Image;a.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(await r.text())}`,await a.decode(),s=await createImageBitmap(a),this.vectors.set(t,{img:a,edge:Math.max(s.width,s.height)})}else s=await createImageBitmap(r,{colorSpaceConversion:"none"});let i=Math.max(s.width,s.height);if(i>$r){let a=$r/i,o=await createImageBitmap(s,{resizeWidth:Math.max(1,Math.round(s.width*a)),resizeHeight:Math.max(1,Math.round(s.height*a)),resizeQuality:"high"});s.close(),s=o}this.images.set(t,{bitmap:s,bytes:new Uint8Array(0),width:s.width,height:s.height})}loadVideo(e){let t=wt(e);return this.videos.has(t)?Promise.resolve():dn(this.videoLoads,t,()=>this.openVideo(e,t))}async openVideo(e,t){let n=this.url(e,a=>a.getVideoMeta(e)),r=new Cn({source:new ks(await this.loadBytes(n)),formats:Ss}),s=await r.getPrimaryVideoTrack();if(!s)throw r.dispose(),new Error(`loadVideo(${e}): no video track`);let i=await r.computeDuration();this.videos.set(t,{duration:i,sink:new Ts(s),input:r,frames:new Map,last:null})}videoFrame(e,t){let n=wt(e),r=this.videos.get(n);if(!r)return null;let s=r.frames.get(an(t));return s||(this.pending.set(`${n}@${an(t)}`,{src:n,time:t}),r.last)}wantImageEdge(e,t){let n=wt(e),r=this.vectors.get(n),s=this.images.get(n);if(!r||!s||t<=r.edge)return;let i=Math.max(s.width,s.height),a=Math.min($r,i*2**Math.ceil(Math.log2(t/i)));a>r.edge&&a>(this.upgrades.get(n)??0)&&this.upgrades.set(n,a)}hasPendingUpgrades(){return this.upgrades.size>0}async warmPendingUpgrades(){if(this.upgrades.size===0)return!1;let e=[...this.upgrades];this.upgrades.clear();for(let[t,n]of e){let r=this.vectors.get(t),s=this.images.get(t);if(!r||!s)continue;let i=n/Math.max(s.width,s.height),a=new OffscreenCanvas(Math.max(1,Math.round(s.width*i)),Math.max(1,Math.round(s.height*i)));a.getContext("2d").drawImage(r.img,0,0,a.width,a.height);let o=s.bitmap;s.bitmap=await createImageBitmap(a),r.edge=n,queueMicrotask(()=>o.close())}return!0}hasPendingDecodes(){return this.pending.size>0}async warmPendingDecodes(){let e=[...this.settlers].map(n=>n()).filter(n=>n!==null);if(this.pending.size===0&&e.length===0)return!1;let t=[...this.pending.values()];return this.pending.clear(),await Promise.all([...t.map(({src:n,time:r})=>dn(this.frameDecodes,`${n}@${an(r)}`,()=>this.decodeFrame(n,r))),...e]),!0}async decodeFrame(e,t){let n=this.videos.get(e);if(!n||n.frames.has(an(t)))return;let r=await n.sink.getSample(t);if(!r)return;let s=r.toVideoFrame(),i;try{i=await createImageBitmap(s)}finally{s.close(),r.close()}for(n.frames.set(an(t),i),n.last=i;n.frames.size>ih;){let[a,o]=n.frames.entries().next().value;n.frames.delete(a),o!==n.last&&queueMicrotask(()=>o.close())}}async loadAudio(){}fetchAudioData(e){let t=this.audioData.get(e);if(!t){let n=this.url(e,r=>{try{return r.getAudioMeta(e)}catch{return r.getVideoMeta(e)}});t=(async()=>(await this.loadBytes(n)).arrayBuffer())(),this.audioData.set(e,t),t.catch(()=>this.audioData.delete(e))}return t.then(n=>n.slice(0))}loadFont(e,t){return this.registeredFamilies.has(t)?Promise.resolve(!0):dn(this.fontLoads,t,()=>this.registerFamily(e,t))}async registerFamily(e,t){let n=this.catalog.getFontFamilyMetas(t);if(n.length===0)return this.getDecodePolicy()==="interactive"&&console.warn(`[WgpuStorageAdapter] No font manifest entry for "${e}".`),!1;let r=[...new Set(n.map(i=>i.src))],s=await Promise.all(r.map(async i=>new Uint8Array(await(await this.loadBytes(i)).arrayBuffer())));if(this.registeredFamilies.has(t))return!0;for(let i of s){let a={bytes:i,family:t};this.fonts.push(a);for(let o of this.fontListeners)o(a)}return this.registeredFamilies.add(t),!0}dispose(){for(let e of this.images.values())e.bitmap.close();this.images.clear();for(let e of this.videos.values()){for(let t of e.frames.values())t.close();e.input.dispose()}this.videos.clear(),this.pending.clear(),this.vectors.clear(),this.upgrades.clear(),this.fontListeners.clear(),this.imageLoads.clear(),this.videoLoads.clear(),this.fontLoads.clear(),this.frameDecodes.clear(),super.dispose()}url(e,t){try{return t(this.catalog).src||e}catch{return e}}};async function lh(e,t,n){return await bn(n),na(e,t)}var uh={fill:`// Provided to every WGSL fill:
704
704
  struct FillIn {
705
705
  uv: vec2f, // 0\u20131 across the fill's box, y down
706
706
  local: vec2f, // px from the box's top-left