@occluze/umber 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +64 -2
  2. package/dist/chunks/capture.js +2 -0
  3. package/dist/chunks/covers.js +2 -0
  4. package/dist/chunks/flip.js +2 -0
  5. package/dist/chunks/fx.js +102 -0
  6. package/dist/chunks/gl.js +180 -0
  7. package/dist/chunks/glsl.js +239 -0
  8. package/dist/chunks/inspect.js +6 -0
  9. package/dist/chunks/instances.js +93 -0
  10. package/dist/chunks/layers.js +21 -0
  11. package/dist/chunks/licence.js +2 -0
  12. package/dist/chunks/morph.js +2 -0
  13. package/dist/chunks/restore.js +2 -0
  14. package/dist/chunks/shapes.js +2 -0
  15. package/dist/chunks/sim.js +22 -0
  16. package/dist/chunks/text.js +52 -0
  17. package/dist/chunks/video.js +2 -0
  18. package/dist/chunks/views.js +2 -0
  19. package/dist/chunks/warm.js +2 -0
  20. package/dist/modules/debug.js +36 -0
  21. package/dist/modules/debug.mjs +36 -0
  22. package/dist/modules/handoff.js +2 -0
  23. package/dist/modules/handoff.mjs +2 -0
  24. package/dist/modules/input.js +2 -0
  25. package/dist/modules/input.mjs +2 -0
  26. package/dist/modules/router-swap.js +13 -0
  27. package/dist/modules/router.js +2 -0
  28. package/dist/modules/router.mjs +2 -0
  29. package/dist/modules/scroll.js +2 -0
  30. package/dist/modules/scroll.mjs +2 -0
  31. package/dist/modules/scrub.js +8 -0
  32. package/dist/modules/scrub.mjs +8 -0
  33. package/dist/umber.css +2 -0
  34. package/dist/umber.js +2 -0
  35. package/dist/umber.mjs +2 -0
  36. package/docs/npm.md +69 -0
  37. package/package.json +118 -4
  38. package/types/debug.d.ts +27 -0
  39. package/types/esm.d.ts +33 -0
  40. package/types/handoff.d.ts +116 -0
  41. package/types/input.d.ts +235 -0
  42. package/types/router.d.ts +181 -0
  43. package/types/scroll.d.ts +132 -0
  44. package/types/scrub.d.ts +74 -0
  45. package/types/umber.d.ts +1532 -0
@@ -0,0 +1,180 @@
1
+ /*! Umber v0.2.0 | (c) Ravi Klaassens | UNLICENSED */
2
+ var wt={info(){},warn:(n,...t)=>console.warn("[umber]",n,...t),once:(n,...t)=>console.warn("[umber]",n,...t),error:(n,...t)=>console.error("[umber]",n,...t)},T=wt;function Ie(n){n&&(T=n)}var D,me,O,Q,pe,Z,H,V,k,J,ge;function Fe(n){n&&({attr:D,config:me,describe:O,findGL:Q,findMedia:pe,markMedia:Z,unmarkMedia:H,needsLive:V,say:k,tell:J,createEmitter:ge}=n)}function ee(n,t,e,i){let r=1-Math.min(1,Math.max(0,e));return n+(t-n)*(1-Math.pow(r,Math.max(0,i)*60))}var Et=/(swiftshader|llvmpipe|software)|mali-4|mali-t|adreno \(tm\) [2-5]|powervr|intel\(r\) hd graphics [2-5]/i,kt=[1400,1600],Pt=n=>n<2?"low":n<4?"mid":"high";function Tt(n){let t=n.trim().toLowerCase().match(/^(m?)([0-5])$|^(low|mid|high)$/);return t&&(t[3]?{level:"lmh".indexOf(t[3][0])*2+1,mobile:!1}:{level:+t[2],mobile:!!t[1]})}function St(n){let t=String(n.getParameter(n.RENDERER)||"");if(!t||/^(webkit webgl|mozilla|webgl)$/i.test(t.trim())){let e=n.getExtension("WEBGL_debug_renderer_info");e&&(t=String(n.getParameter(e.UNMASKED_RENDERER_WEBGL)||"")||t)}return t}function Rt(n){let t=n.match(Et);return t?[t[1]?0:1,`rule: ${t[0]}`]:[2,"default"]}function Ue(n,t){let e=St(t),i=n.env.isTouch&&Math.min(screen.width,screen.height)<820,r,s="url",a=n.gpu?Tt(n.gpu):null;if(n.gpu&&!a&&n.lib?.say("gpu",[n.gpu]),a)({level:r,mobile:i}=a);else{let[l,u]=Rt(e);r=l<2?l:l+(i?0:2),s=u}let o=r>3;return{level:r,tier:Pt(r),mobile:i,renderer:e,reason:s,maxTexture:Math.min(t.getParameter(t.MAX_TEXTURE_SIZE),o?4096:2048),textureBudget:(o?192:96)*2**20,wide:!i&&kt[r]||1/0}}var Ne="uniformMatrix2fv,uniformMatrix3fv,uniformMatrix4fv,,,,,,,,,uniformMatrix2x3fv,uniformMatrix2x4fv,uniformMatrix3x2fv,uniformMatrix3x4fv,uniformMatrix4x2fv,uniformMatrix4x3fv".split(","),te=class{constructor(t,e,i,r="program"){this.gl=t;this.vertex=e;this.fragment=i;this.label=r;this.uniforms=new Map;this.samplers=[];this.state="pending";this.error=null;this.shaders=[];this.Ka=globalThis.occluzeCapture?.version==1?null:t.getExtension("KHR_parallel_shader_compile");let s=De(t,t.VERTEX_SHADER,e),a=De(t,t.FRAGMENT_SHADER,i),o=t.createProgram();t.attachShader(o,s),t.attachShader(o,a),t.bindAttribLocation(o,0,"aPosition"),t.linkProgram(o),this.program=o,this.shaders=[s,a],this.Ka||this.finalize()}ready(){return this.state!=="pending"?this.state==="ok":this.Ka&&!this.gl.getProgramParameter(this.program,this.Ka.COMPLETION_STATUS_KHR)?!1:(this.finalize(),this.state==="ok")}get failed(){return this.state==="failed"}finalize(){let t=this.gl,e=this.program;if(!t.getProgramParameter(e,t.LINK_STATUS)){let[r,s]=this.shaders;this.error=Oe(t,r,"vertex",this.vertex,this.label)||Oe(t,s,"fragment",this.fragment,this.label)||["link",this.label,t.getProgramInfoLog(e)||"",""],this.Pa(),t.deleteProgram(e),this.state="failed";return}this.Pa();let i=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let r=0;r<i;r++){let s=t.getActiveUniform(e,r);if(!s)continue;let a=s.name.replace(/\[0\]$/,""),o=t.getUniformLocation(e,s.name);o&&(this.uniforms.set(a,{loc:o,type:s.type,size:s.size}),(s.type===t.SAMPLER_2D||s.type===t.UNSIGNED_INT_SAMPLER_2D)&&this.samplers.push(a))}this.state="ok"}Pa(){for(let t of this.shaders)this.gl.deleteShader(t);this.shaders=[]}set(t,e){let i=this.state==="ok"?this.uniforms.get(t):void 0;if(!i||e==null)return;let r=this.gl,s=i.type;if(typeof e=="number"){if(i.last===e)return;i.last=e,s===r.FLOAT?r.uniform1f(i.loc,e):s===r.UNSIGNED_INT?r.uniform1ui(i.loc,e):r.uniform1i(i.loc,e);return}let a=e,o=i.last;if(o?.length===a.length){let l=a.length;for(;l--&&o[l]===a[l];);if(l<0)return}else o=i.last=[];for(let l=0;l<a.length;l++)o[l]=a[l];s===r.FLOAT_VEC2?r.uniform2fv(i.loc,a):s===r.FLOAT_VEC3?r.uniform3fv(i.loc,a,0,Math.min(a.length,i.size*3)):s===r.FLOAT_VEC4?r.uniform4fv(i.loc,a):Ne[s-r.FLOAT_MAT2]?r[Ne[s-r.FLOAT_MAT2]](i.loc,!1,a):s===r.FLOAT?r.uniform1fv(i.loc,a):r[`uniform${a.length/i.size}${s===r.UNSIGNED_INT||s>=r.UNSIGNED_INT_VEC2?"u":""}iv`]?.(i.loc,a)}dispose(){this.Pa(),this.state!=="failed"&&this.gl.deleteProgram(this.program)}};function De(n,t,e){let i=n.createShader(t);return n.shaderSource(i,e),n.compileShader(i),i}function Oe(n,t,e,i,r){return t&&!n.getShaderParameter(t,n.COMPILE_STATUS)?[e,r,n.getShaderInfoLog(t)||"",i]:null}var ie=class{constructor(t,e){this.gl=t;this.segments=e;this.buffers=[];let i=Math.max(1,Math.round(e)),r=new Float32Array((i+1)*(i+1)*2),s=0;for(let h=0;h<=i;h++)for(let c=0;c<=i;c++)r[s++]=c/i,r[s++]=h/i;let a=new Uint16Array(i*i*6),o=0;for(let h=0;h<i;h++)for(let c=0;c<i;c++){let E=h*(i+1)+c,w=E+1,v=E+(i+1),d=v+1;a[o++]=E,a[o++]=v,a[o++]=w,a[o++]=w,a[o++]=v,a[o++]=d}this.vao=t.createVertexArray(),t.bindVertexArray(this.vao);let l=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,l),t.bufferData(t.ARRAY_BUFFER,r,t.STATIC_DRAW),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,2,t.FLOAT,!1,0,0);let u=t.createBuffer();t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,u),t.bufferData(t.ELEMENT_ARRAY_BUFFER,a,t.STATIC_DRAW),t.bindVertexArray(null),this.buffers.push(l,u),this.count=a.length}draw(){let t=this.gl;t.bindVertexArray(this.vao),t.drawElements(t.TRIANGLES,this.count,t.UNSIGNED_SHORT,0)}dispose(){this.gl.deleteVertexArray(this.vao),this.buffers.forEach(t=>this.gl.deleteBuffer(t))}},$=class{constructor(t){this.gl=t;this.ms=-1;this.pending=[];this.active=null;this.ext=t.getExtension("EXT_disjoint_timer_query_webgl2")}get supported(){return!!this.ext}begin(){if(!this.ext||this.active||this.pending.length>3)return;let t=this.gl.createQuery();t&&(this.gl.beginQuery(this.ext.TIME_ELAPSED_EXT,t),this.active=t)}end(){!this.ext||!this.active||(this.gl.endQuery(this.ext.TIME_ELAPSED_EXT),this.pending.push(this.active),this.active=null)}poll(){let t=this.gl;if(!this.ext)return;let e=t.getParameter(this.ext.GPU_DISJOINT_EXT);for(;this.pending.length;){let i=this.pending[0];if(!t.getQueryParameter(i,t.QUERY_RESULT_AVAILABLE))break;let r=t.getQueryParameter(i,t.QUERY_RESULT);e||(this.ms=r/1e6),t.deleteQuery(i),this.pending.shift()}}dispose(){this.active&&this.end(),this.pending.forEach(t=>this.gl.deleteQuery(t)),this.pending=[]}};function Mt(n){let t=n;return[t.displayWidth||t.videoWidth||t.naturalWidth||t.width||0,t.displayHeight||t.videoHeight||t.naturalHeight||t.height||0]}var Lt=n=>n instanceof HTMLVideoElement||"displayWidth"in n,L=class{constructor(t){this.gl=t;this.width=1;this.height=1;this.ready=!1;this.refs=0;this.box=[];this.mipmaps=!1;this.texture=t.createTexture(),t.bindTexture(t.TEXTURE_2D,this.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.params(!1)}params(t){let e=this.gl;e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,t?e.LINEAR_MIPMAP_LINEAR:e.LINEAR)}get bytes(){return this.ready?this.width*this.height*4*(this.mipmaps?4/3:1):0}upload(t,e={}){let i=this.gl,r=e.mipmaps??!Lt(t),[s,a]=Mt(t);return!s||!a?!1:(i.bindTexture(i.TEXTURE_2D,this.texture),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),this.ready&&s===this.width&&a===this.height&&(!r||this.mipmaps)?i.texSubImage2D(i.TEXTURE_2D,0,0,0,i.RGBA,i.UNSIGNED_BYTE,t):i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),r&&i.generateMipmap(i.TEXTURE_2D),(r!==this.mipmaps||!this.ready)&&this.params(r),this.mipmaps=r,this.width=s,this.height=a,this.ready=!0,!0)}dispose(){this.texture&&this.gl.deleteTexture(this.texture),this.texture=null,this.ready=!1}};async function X(n,t,e){let i=[],r,s="",a=(o,l,u)=>{i[2]=o,i[3]=l;let h=i[0]?Math.max(i[0]/o,i[1]/l):1,c=2**Math.floor(Math.log2(h));return h<c*1.1&&(h=c)<=.8&&i[0]&&(i[0]=o*h,i[1]=l*h),h>.8&&!u?(h=1,i[0]=0):i[1]||=i[0]*l/o,Math.min(h,t/Math.max(o,l))};try{let o=await fetch(n,{mode:"cors",credentials:"omit"});if(!o.ok)throw new Error(`HTTP ${o.status}`);let l=await o.blob();s=l.type,e&&(i=e()),r=await createImageBitmap(l,{premultiplyAlpha:"none",colorSpaceConversion:"default"});let u=r.width,h=r.height,c=a(u,h);if(c>=1)return r;let E=await createImageBitmap(r,{resizeWidth:Math.max(1,Math.round(u*c)),resizeHeight:Math.max(1,Math.round(h*c)),resizeQuality:"high"});return r.close(),E}catch(o){r?.close(),T.info("fetch decode failed, trying <img>",n,o);let l=await new Promise((w,v)=>{let d=new Image;d.crossOrigin="anonymous",d.decoding="async",d.onload=()=>w(d),d.onerror=()=>v(new Error(`could not load ${n}`)),d.src=n});e&&!i[2]&&(i=e());let u=l.width,h=l.height,c=a(u,h,/svg/.test(s));if(c==1||!u)return l;let E=document.createElement("canvas");return E.getContext("2d").drawImage(l,0,0,E.width=Math.round(u*c)||1,E.height=Math.round(h*c)||1),E}}var _t=`#version 300 es
3
+ precision highp float;
4
+ layout(location=0)in vec2 aPosition;
5
+ uniform vec2 uViewport;
6
+ uniform vec4 uSurface;
7
+ uniform vec4 uRect;
8
+ uniform vec2 uSize;
9
+ uniform mat3 uPlaneMatrix;
10
+ uniform float uTime;
11
+ uniform float uScrollVelocity;
12
+ uniform vec2 uMouse;
13
+ uniform float uProgress;
14
+ uniform float uBleed;
15
+ out vec2 vUv;
16
+ #define PI 3.141592653589793
17
+ /*__VERTEX_HEAD__*/
18
+ void main(){
19
+ vec2 uv=(aPosition*(uSize+2.0*uBleed)-uBleed)/uSize;
20
+ vUv=uv;
21
+ vec3 pos=vec3(0.0);
22
+ /*__VERTEX_MAIN__*/
23
+ vec3 h=uPlaneMatrix*vec3(uv*uSize+pos.xy,1.0);
24
+ h.xy-=uSurface.xy*h.z;
25
+ gl_Position=vec4(h.x/uSurface.z*2.0-h.z,h.z-h.y/uSurface.w*2.0,pos.z*0.0001*h.z,h.z);
26
+ }
27
+ `,At=`#version 300 es
28
+ precision highp float;
29
+ #define UMBER_FRAGMENT
30
+ in vec2 vUv;
31
+ out vec4 outColor;
32
+ uniform vec2 uViewport;
33
+ uniform vec4 uSurface;
34
+ uniform vec4 uRect;
35
+ uniform vec2 uSize;
36
+ uniform float uTime;
37
+ uniform float uScrollVelocity;
38
+ uniform vec2 uMouse;
39
+ uniform float uProgress;
40
+ uniform float uAlpha;
41
+ uniform vec4 uRadius;
42
+ uniform float uRadiusKy;
43
+ uniform float uDpr;
44
+ uniform vec2 uCanvas;
45
+ uniform int uUmberClips;
46
+ uniform mat3 uUmberClipXf[2];
47
+ uniform vec4 uUmberClipBox[2];
48
+ uniform vec4 uUmberClipRadius[2];
49
+ uniform vec4 uUmberClipPoly[4];
50
+ uniform vec2 uUmberClipPolyInfo;
51
+ uniform sampler2D uImage;
52
+ uniform vec2 uImageSize;
53
+ uniform float uFit;
54
+ uniform vec2 uFitPosition;
55
+ #define PI 3.141592653589793
56
+ vec2 fitUv(vec2 uv){
57
+ if(uFit>2.5)return(uv*uSize-uFitPosition)/uImageSize;
58
+ if(uFit>1.5)return uv;
59
+ vec2 ratio=uSize/max(uImageSize,vec2(1.0));
60
+ float s=uFit<0.5?max(ratio.x,ratio.y):min(ratio.x,ratio.y);
61
+ vec2 scaled=uImageSize*s;
62
+ vec2 offset=(uSize-scaled)*uFitPosition;
63
+ return(uv*uSize-offset)/scaled;
64
+ }
65
+ vec4 sampleImage(vec2 uv){
66
+ vec2 f=fitUv(uv);
67
+ vec4 c=texture(uImage,f);
68
+ if(uFit>0.5&&uFit<1.5&&(f.x<0.0||f.y<0.0||f.x>1.0||f.y>1.0))c=vec4(0.0);
69
+ if(uFit>2.5)c.rgb/=max(c.a,1e-5);
70
+ return c;
71
+ }
72
+ float roundedBox(vec2 p,vec2 size,vec4 r){
73
+ vec4 s=max(r+r.yzwx,1e-5);
74
+ r*=min(1.0,min(min(size.x/s.x,size.y/s.y),min(size.x/s.z,size.y/s.w)));
75
+ vec2 h=size*0.5;
76
+ vec2 d=abs(p-h)-h;
77
+ float o=length(max(d,0.0))+min(max(d.x,d.y),0.0);
78
+ vec2 q=p;
79
+ if(max(q.x,q.y)<r.x)o=max(o,length(q-r.x)-r.x);
80
+ q=vec2(size.x-p.x,p.y);
81
+ if(max(q.x,q.y)<r.y)o=max(o,length(q-r.y)-r.y);
82
+ q=size-p;
83
+ if(max(q.x,q.y)<r.z)o=max(o,length(q-r.z)-r.z);
84
+ q=vec2(p.x,size.y-p.y);
85
+ if(max(q.x,q.y)<r.w)o=max(o,length(q-r.w)-r.w);
86
+ return o;
87
+ }
88
+ vec2 umberClipPoint(int i){
89
+ vec4 v=uUmberClipPoly[i/2];
90
+ return(i-(i/2)*2)==0?v.xy:v.zw;
91
+ }
92
+ float umberPolygon(vec2 p){
93
+ int n=int(uUmberClipPolyInfo.y+0.5);
94
+ float d=1e20;
95
+ float s=1.0;
96
+ for(int i=0;i<8;i++){
97
+ if(i>=n)break;
98
+ vec2 a=umberClipPoint(i);
99
+ vec2 b=umberClipPoint(i==0?n-1:i-1);
100
+ vec2 e=b-a;
101
+ vec2 w=p-a;
102
+ vec2 q=w-e*clamp(dot(w,e)/max(dot(e,e),1e-8),0.0,1.0);
103
+ d=min(d,dot(q,q));
104
+ bvec3 c=bvec3(p.y>=a.y,p.y<b.y,e.x*w.y>e.y*w.x);
105
+ if(all(c)||all(not(c)))s= -s;
106
+ }
107
+ return s*sqrt(d);
108
+ }
109
+ float umberClip(){
110
+ float cover=1.0;
111
+ for(int i=0;i<2;i++){
112
+ if(i>=uUmberClips)break;
113
+ vec3 q=uUmberClipXf[i]*vec3(gl_FragCoord.xy,1.0);
114
+ vec2 p=q.xy/q.z;
115
+ float d=float(i)==uUmberClipPolyInfo.x
116
+ ?umberPolygon(p)
117
+ :roundedBox(p-uUmberClipBox[i].xy,uUmberClipBox[i].zw,uUmberClipRadius[i]);
118
+ float k=clamp(0.5-d/max(length(vec2(dFdx(d),dFdy(d))),1e-4),0.0,1.0);
119
+ cover*=q.z<0.0?1.0-k:k;
120
+ }
121
+ return cover;
122
+ }
123
+ /*__FRAGMENT_HEAD__*/
124
+ void main(){
125
+ vec2 uv=vUv;
126
+ /*__FRAGMENT_UV__*/
127
+ vec4 color= /*__FRAGMENT_SOURCE__*/;
128
+ /*__FRAGMENT_COLOR__*/
129
+ float edge=1.0/max(uDpr,1.0);
130
+ float alpha=uAlpha;
131
+ if(uRadius.x+uRadius.y+uRadius.z+uRadius.w>0.0){
132
+ vec2 k=vec2(1.0,uRadiusKy>0.0?uRadiusKy:1.0);
133
+ alpha*=1.0-smoothstep(-edge,edge,roundedBox(vUv*uSize*k,uSize*k,uRadius));
134
+ }
135
+ /*__FRAGMENT_ALPHA__*/
136
+ if(uUmberClips>0)alpha*=umberClip();
137
+ float a=clamp(color.a*alpha,0.0,1.0);
138
+ outColor=vec4(color.rgb*a,a);
139
+ }
140
+ `,I={},Ge=/\b(umberHash|noise|fbm|rotate2d|screenUv|screenPx|samplePrev)\s*\(|\buScreen\b/;function He(n){let t=new Set,e=i=>{let r=I[i];if(!(t.has(i)||r.defined.test(n))){for(let s of r.needs||[])e(s);t.add(i)}};for(let i in I)I[i].used.test(n)&&e(i);return[...t].map(i=>I[i].code).join(`
141
+
142
+ `)}function We({kind:n,effects:t,shader:e,uniforms:i,chunks:r={vertex:"",fragment:""}}){let s=(m,p)=>t.map(({name:b,def:x})=>{let S=m(x);return S?`// ${p}: ${b}
143
+ {
144
+ ${Be(S)}
145
+ }`:""}).filter(Boolean).join(`
146
+
147
+ `),a=m=>t.map(({name:p,def:b})=>{let x=m(b);return x?`// ${p}
148
+ ${x}`:""}).filter(Boolean).join(`
149
+
150
+ `),o=t.map(({def:m})=>`${m.vertex?.head||""}
151
+ ${m.vertex?.main||""}`).join(`
152
+ `)+r.vertex,l=He(o),u=_t.replace("/*__VERTEX_HEAD__*/",[l?`// helpers
153
+ ${l}`:"",r.vertex,a(m=>m.vertex?.head)].filter(Boolean).join(`
154
+
155
+ `)).replace("/*__VERTEX_MAIN__*/",s(m=>m.vertex?.main,"vertex")),h="sampleImage(uv)",c="";n==="shader"&&e&&(c=`// shader: ${e.name}
156
+ ${e.def.head||""}
157
+ vec4 umberSurface(vec2 uv) {
158
+ vec4 color = vec4(0.0);
159
+ {
160
+ ${Be(e.def.fragment)}
161
+ }
162
+ return color;
163
+ }`,h="umberSurface(uv)");let E=[...t.map(({def:m})=>`${m.vertex?.head||""}
164
+ ${m.fragment?.head||""}`),e?.def.head||"",r.vertex+r.fragment].join(`
165
+ `),w=Ct(i,E),v=[...t.map(({def:m})=>Object.values(m.fragment||{}).join(`
166
+ `)),e?`${e.def.head||""}
167
+ ${e.def.fragment}`:"",r.fragment].join(`
168
+ `),d=He(v),y=/\bsampleRaw\s*\(/.test(v)&&!/vec4\s+sampleRaw\s*\(/.test(v)?"vec4 sampleRaw(vec2 uv) { vec4 c = sampleImage(uv); return vec4(c.rgb * c.a, c.a); }":"",P=At.replace("/*__FRAGMENT_HEAD__*/",[d?`// helpers
169
+ ${d}`:"",y,r.fragment,c,a(m=>m.fragment?.head)].filter(Boolean).join(`
170
+
171
+ `)).replace("/*__FRAGMENT_UV__*/",s(m=>m.fragment?.uv,"uv")).replace("/*__FRAGMENT_SOURCE__*/",h).replace("/*__FRAGMENT_COLOR__*/",s(m=>m.fragment?.color,"color")).replace("/*__FRAGMENT_ALPHA__*/",s(m=>m.fragment?.alpha,"alpha"));return P=P.replace("#define PI 3.141592653589793",`#define PI 3.141592653589793
172
+
173
+ ${w}`),{vertex:u.replace("#define PI 3.141592653589793",`#define PI 3.141592653589793
174
+
175
+ ${w.split(`
176
+ `).filter(m=>!m.includes("sampler2D")).join(`
177
+ `)}`),fragment:P}}function Be(n){return n.trim().split(`
178
+ `).map(t=>` ${t}`).join(`
179
+ `)}var se=new Set(["uViewport","uSurface","uRect","uSize","uTime","uScrollVelocity","uMouse","uProgress","uAlpha","uRadius","uRadiusKy","uDpr","uImage","uImageSize","uFit","uFitPosition","uGlyphIndex","uGlyphData","uPlaneMatrix","uCanvas","uBleed","uUmberClips","uUmberClipXf","uUmberClipBox","uUmberClipRadius","uUmberClipPoly","uUmberClipPolyInfo"]),ze=/\bglyph\s*\(/;function ye(n){if(typeof n=="number"||typeof n=="boolean")return"float";if(Array.isArray(n)||ArrayBuffer.isView(n)){let t=n.length;return t===2?"vec2":t===3?"vec3":t===4?"vec4":t===9?"mat3":t===16?"mat4":null}return typeof n=="string"?"sampler2D":n&&typeof n=="object"?"highp sampler2D":null}function Ve(n,t){let e=r=>r.charAt(0).toUpperCase()+r.slice(1),i=r=>r.split(/[-_\s]+/).map(e).join("");return`u${i(n)}${i(t)}`}function Ct(n,t){let e=[];for(let i in n){if(se.has(i)||new RegExp(`uniform\\s+\\w+\\s+${i}\\b`).test(t))continue;let r=ye(n[i]);r&&e.push(`uniform ${r} ${i};`)}return e.join(`
180
+ `)}var $e=/\b(?:(?:quad|cubic|quart|quint|sine|expo|circ)(?:In|Out|B)|stagger|[sp]noise|cellular|sd[A-Z]|op[A-Z]|aa|blend[A-Z]|bayer|blueNoise|dither|srgbTo|linearTo|oklabTo|mixOklab|umber[A-Z])\w*\s*\(/;var It=n=>n,Xe=(n,t)=>{let e=3*n,i=3*(t-n)-e,r=1-e-i;return s=>((r*s+i)*s+e)*s};function qe(n,t,e,i){let r=Xe(n,e),s=Xe(t,i);return a=>{if(a<=0||a>=1)return a;let o=0,l=1;for(let u=0;u<24;u++){let h=(o+l)/2;r(h)<a?o=h:l=h}return s((o+l)/2)}}function Ft(n){let t=[],e=[];for(let r of n.split(",")){let[s,...a]=r.trim().split(/\s+/);if(a.length>2||!(parseFloat(s)>=-1/0)||a.some(o=>!o.endsWith("%")))return null;for(let o of a.length?a:[""])t.push(o?parseFloat(o)/100:NaN),e.push(+s)}let i=t.length;if(i<2)return null;t[0]>=-1/0||(t[0]=0),t[i-1]>=-1/0||(t[i-1]=Math.max(1,...t.filter(r=>r>=-1/0)));for(let r=1;r<i;r++){let s=r;for(;!(t[s]>=-1/0);)s++;t[r]=t[r-1]+Math.max(0,t[s]-t[r-1])/(s-r+1)}return r=>{let s=0;for(let l=0;l<i;l++)t[l]<=r&&(s=l);s===i-1&&s--;let a=t[s],o=t[s+1];return a===o?e[s+1]:e[s]+(r-a)/(o-a)*(e[s+1]-e[s])}}function ne(n,t,e,i,r){let s=t*Math.sqrt(Math.max(1-n*n,1e-8)),a=Math.exp(-n*t*r),o=(i+n*t*e)/s,l=Math.cos(s*r),u=Math.sin(s*r),h=a*(e*l+o*u);return[h,-n*t*h+a*s*(o*l-e*u)]}function Ut(n){let t=1-Math.min(.95,Math.max(0,n||0)),e=0;for(let r=0;r<12/t;r+=.01)Math.abs(ne(t,1,1,0,r)[0])>.001&&(e=r);let i=r=>r>=1?1:1-ne(t,e,1,0,r)[0];return i.k=[t,e],i}var re=n=>t=>Math.pow(t,n),Nt={quad:re(2),cubic:re(3),quart:re(4),quint:re(5),sine:n=>1-Math.cos(n*Math.PI/2),expo:n=>n===0?0:Math.pow(2,10*n-10),circ:n=>1-Math.sqrt(1-n*n)},Dt={power1:"quad",power2:"cubic",power3:"quart",power4:"quint"},Ot=n=>t=>1-n(1-t),Ht=n=>t=>t<.5?n(t*2)/2:1-n((1-t)*2)/2,F="umber",Bt={umber:[.625,.05,0,1],ease:[.25,.1,.25,1],"ease-in":[.42,0,1,1],"ease-out":[0,0,.58,1],"ease-in-out":[.42,0,.58,1]},Ye=new Map;function je(n){if(n==="linear"||n==="none")return It;let t=Bt[n];if(t)return qe(...t);let e=n.match(/^linear\((.*)\)$/);if(e)return Ft(e[1]);let i=n.match(/^spring(?:\(([^)]*)\))?$/);if(i)return Ut(i[1]?parseFloat(i[1]):.2);let r=n.match(/^cubic-bezier\(([^)]*)\)$/)||n.match(/^([-\d.\s]+,[-\d.\s]+,[-\d.\s]+,[-\d.\s]+)$/);if(r){let l=r[1].split(",").map(u=>parseFloat(u));return l.length===4&&l.every(Number.isFinite)&&l[0]>=0&&l[0]<=1&&l[2]>=0&&l[2]<=1?qe(l[0],l[1],l[2],l[3]):null}let s=n.match(/^([a-z]+\d?)(?:\.(in|out|inout))?$/);if(!s)return null;let a=Nt[Dt[s[1]]||s[1]];if(!a)return null;let o=s[2]||"out";return o==="in"?a:o==="out"?Ot(a):Ht(a)}function oe(n){if(typeof n=="function")return n;let t=String(n??F).trim().toLowerCase(),e=Ye.get(t);return e||(e=je(t||F)||void 0,e||(k("ease",[n]),e=je(F)),Ye.set(t,e),e)}var ve=class{constructor(t,e,i=0){this.vars=e;this.v0=i;this.from=0;this.progress=0;this.done=!1;this.paused=!1;this.startAt=NaN;this.velocity=0;this.at=1/0;this.now=NaN;this.list=null;this.resolve=null;this.promise=null;this.target=t,this.to=Number(e.value),this.duration=Math.max(0,Number(e.duration??1)||0),this.delay=Math.max(0,Number(e.delay??0)||0),this.ease=oe(e.ease)}step(t){if(this.done)return!1;if(this.now=t,this.paused)return!0;Number.isNaN(this.startAt)&&(this.startAt=t);let e=t-this.startAt-this.delay;if(e<0)return!0;this.progress===0&&(this.from=Number(this.target.value)||0),this.progress=this.duration>0?Math.min(1,e/this.duration):1;let i=this.ease.k,r=this.progress>=1,s;if(i&&this.duration>0){let a=i[1]/this.duration,o=this.from-this.to,[l,u]=ne(i[0],a,o,this.v0,e),h=.001*Math.max(Math.abs(o),Math.abs(this.v0)/a,1e-9);r=Math.abs(l)<h&&Math.abs(u)<h*a,s=r?this.to:this.to+l,this.velocity=r?0:u}else s=this.from+(this.to-this.from)*this.ease(this.progress),t>this.at&&(this.velocity=(s-(Number(this.target.value)||0))/(t-this.at));return this.at=t,this.target.value=s,this.vars.onUpdate?.(),r?(this.finish(),this.vars.onComplete?.(),!1):!0}pause(){return!this.done&&!this.paused&&(this.paused=!0,this.startAt=this.time-this.startAt),this}play(){return this.paused&&(this.paused=!1,this.startAt=this.time-this.startAt,this.list?.wake()),this}get time(){return this.list?this.list.now:this.now}kill(){return this.finish(),this}then(t,e){return this.promise||=new Promise(i=>{this.done?i():this.resolve=i}),this.promise.then(t,e)}finish(){this.done||(this.done=!0,this.resolve?.(),this.resolve=null)}},B=class{constructor(t=()=>{},e=null){this.wake=t;this.clock=e;this.list=[];this.time=0;this.stepped=!1}get now(){return this.clock?this.clock():this.time}to(t,e){(typeof e?.value!="number"||!Number.isFinite(e.value))&&k("tween",[e?.value]);let i=this.of(t);this.killTweensOf(t);let r=new ve(t,e,i&&!(Number(e.delay)>0)?i.velocity:0);return r.duration===0&&r.delay===0?(r.step(this.time),r):(r.startAt=this.clock||this.stepped?this.now:NaN,r.list=this,this.list.push(r),this.wake(),r)}step(t){if(this.time=t,this.stepped=!0,!this.list.length)return!1;let e=!1;for(let i of this.list.slice())i.step(t)&&!i.paused&&(e=!0);return this.list=this.list.filter(i=>!i.done),e}killTweensOf(t){let e=new Set(Array.isArray(t)?t:[t]);for(let i of this.list)e.has(i.target)&&i.kill();this.list=this.list.filter(i=>!i.done)}of(t){return this.list.find(e=>e.target===t&&!e.done)||null}get size(){return this.list.length}clear(){this.list.forEach(t=>t.kill()),this.list=[]}};var G=null,Ke=(n,t)=>n.replace(/var\(\s*(--[\w-]+)\s*(?:,((?:[^()]|\([^()]*\))*))?\)/g,(e,i,r="")=>getComputedStyle(t).getPropertyValue(i).trim()||Ke(r,t));function q(n,t){let e=Ke(n,t).trim().replace(/currentcolor/gi,getComputedStyle(t).color);return typeof CSS>"u"||e.includes("var(")||!CSS.supports("color",e)?n.includes("var(")?(k("var",[n],t),new Float32Array(4)):null:(G||=document.createElement("canvas").getContext("2d",{willReadFrequently:!0}),G?(G.clearRect(0,0,1,1),G.fillStyle=e,G.fillRect(0,0,1,1),Float32Array.from(G.getImageData(0,0,1,1).data,i=>i/255)):null)}var W=class{constructor(t,e){this.ma=e;this.v=t}get value(){return this.v}set value(t){t!==this.v&&(this.v=t,this.ma())}},U=class extends W{constructor(e,i){super(e.value,i);this.source=e;this.last=[];this.changed()}get value(){return this.source.value}set value(e){this.source.value=e,this.ma()}changed(){let e=this.source.value,i=this.last;if(typeof e=="number"||typeof e=="boolean"){let r=Number(e);return i.length===1&&i[0]===r?!1:(i.length=1,i[0]=r,!0)}if(Array.isArray(e)||ArrayBuffer.isView(e)){let r=e,s=i.length===r.length;for(let a=0;a<r.length;a++)i[a]!==r[a]&&(s=!1),i[a]=r[a];return i.length=r.length,!s}return!1}};function we(n){return!!n&&typeof n=="object"&&!Array.isArray(n)&&!ArrayBuffer.isView(n)&&"value"in n&&typeof n.value!="string"}var Gt=0,z=class{constructor(t,e,i,r){this.id=++Gt;this.order=0;this.effects=[];this.shader=null;this.uniforms={};this.missing=[];this.backdrop=null;this.doc={x:0,y:0,w:0,h:0};this.rect=new Float32Array(4);this.size=new Float32Array(2);this.level=0;this.nodes=[];this.dynamic=[];this.boxW=0;this.boxH=0;this.xf=new Float64Array(9);this.edge=new Float64Array([1,1]);this.xfDraw=new Float64Array(9);this.invDraw=new Float64Array(9);this.drawXf=new Float32Array([1,0,0,0,1,0,0,0,1]);this.lastXf=new Float32Array(9);this.shaderRect=new Float32Array(4);this.backHidden=!1;this.scene=null;this.chainReason=null;this.xfReason=null;this.clipReason=null;this.sceneReason=null;this.cornerReason=null;this.radiusKy=1;this.warned=new Set;this.animUntil=0;this.animInfinite=!1;this.scrollLinked=!1;this.animTargets=[];this.animLabel="";this.heldMoved=!1;this.verifyMiss=0;this.lastRect=new Float32Array([NaN,NaN,NaN,NaN]);this.progress=0;this.scrolls=!0;this.clips=null;this.chained=!1;this.domReason=null;this.textReason=null;this.bends=!1;this.shapeWait=!1;this.inBody=!1;this.stale=!0;this.gen=-1;this.measured=!1;this.live=!1;this.pinned=!1;this.near=!1;this.farAt=0;this.loadingSince=0;this.autoPaused=!1;this.inView=!1;this.soon=!1;this.visible=!1;this.listed=-1;this.drawn=!1;this.opacity=1;this.calm=!1;this.lastOpacity=-1;this.radius=new Float32Array(4);this.fit=0;this.fitPosition=new Float32Array([.5,.5]);this.media=null;this._layer=null;this.pad=0;this.bleed=0;this.wrap=null;this.layoutW=0;this.layoutH=0;this._raster=null;this.texture=null;this.prev=null;this.fly=null;this.textureState="none";this.loads=0;this.videoFrame=!1;this.videoCleanup=null;this._mods=new xe;this.status="loading";this.readyFrame=-1;this.isLoaded=!1;this.destroyed=!1;this._play=new be;this.morphIn=!1;this.morphHidden=!1;this.vt=!1;this.listeners=[];this.busyReasons=new Set;this.mouseTracking=!1;this.mouse=new Float32Array([.5,.5]);this.mouseTarget=new Float32Array([.5,.5]);this.usesVelocity=!1;this.usesTime=!1;this.usesProgress=!1;this.usesGlyph=!1;this.hasSignals=!1;this.programKey="";this.program=null;this.grid=null;this.segments=1;this.handlers=ge(!1,"plane ");this.el=t,this.kind=e,this.index=i,this.host=r,this.geomEl=t,this.loaded=new Promise(s=>{this.resolveLoaded=()=>{this.isLoaded=!0,s()}})}get tweens(){return this.host.tweens||=new B(()=>this.host.wake())}set(t,e){typeof e=="string"&&(e=q(e,this.el)??e);let i=this.uniforms[t];return we(e)&&!(i instanceof U&&i.source===e)?(!i&&!se.has(t)&&this.Tb(t),this.uniforms[t]=new U(e,()=>this.host.markDirty()),this.hasSignals=!0):i?i.value=e:(se.has(t)||this.Tb(t),this.uniforms[t]=new W(e,()=>this.host.markDirty())),this.host.markDirty(),this}Tb(t){k("set",[this.el,t,Object.keys(this.uniforms),this.effects.map(e=>e.name).join(", ")||"none"],this.el)}get(t){return this.uniforms[t]?.value}tween(t,e){return this.uniforms[t]||this.set(t,0),this.tweens.to(this.uniforms[t],e)}play(t={}){let{uniform:e,...i}=t,r=e?[e]:[...this._play.playables.keys()];if(!r.length)return k("play",[],this.el),null;let s=null;for(let a of r){let o=this._play.playables.get(a)||{},l=this.host.reducedMotion?this.tween(a,{value:1,...i,duration:0,delay:0}):this.tween(a,{value:1,duration:o.duration??1.4,delay:o.delay,ease:o.ease??F,...i});!l.done&&!this.isLoaded&&(l.pause(),this.loaded.then(()=>{l.play(),this.host.wake()})),s||=l}return s}lift(){return this.host.loadFlip().then(t=>t&&!this.destroyed?t.lift(this):null)}land(t){return this.host.loadFlip().then(e=>e?.land(this,t))}on(t,e){return this.handlers.on(t,e)}off(t,e){this.handlers.off(t,e)}emit(t){this.handlers.emit(t,this)}destroy(){this.destroyed||this.host.removePlane?.(this)}revert(){this.destroy()}wake(t=1){this.host.wake(t)}parts(){return[this._play,this._layer,this._mods,this._raster]}setStatus(t,e){let i=this.status;t&&(this.status=t),t===null?this.el.removeAttribute("data-gl-status"):this.el.setAttribute("data-gl-status",t),t&&t!==i&&(t==="ready"||t==="error"&&!this.textReason)&&(this.emit(t),t==="error"&&this.host.fallback?.(this,e))}};function Ee(n){for(let t of n)try{t()}catch(e){T.error("plane cleanup failed",e)}}var be=class{constructor(){this.playables=new Map;this.cleanups=[]}dispose(){Ee(this.cleanups),this.cleanups=[]}},xe=class{constructor(){this.list=[];this.feed=null;this.frames=null}tell(t){for(let e of this.list)try{t(e.binding)}catch(i){T.error(`module "${e.name}" failed`,i)}}lost(){this.frames?.forget(),this.tell(t=>t.lost?.())}dispose(t){this.tell(e=>e.destroy?.()),this.list=[],this.feed=null,this.frames&&(this.frames.dispose(),this.frames=null,t.texture=null)}};function ke(n,t,e,i){if(!n||n===document.documentElement||e&&n.contains(e))return 1;let r=getComputedStyle(n);if(!i&&r.visibility==="hidden")return 0;let s=t.get(n);if(s!==void 0)return s;let a=r.display==="none"?0:parseFloat(r.opacity);Number.isFinite(a)||(a=1);let o=a===0?0:a*ke(n.parentElement,t,e,1);return t.set(n,o),o}function Ze(n){if(n.cornerReason=null,n.kind==="text"||n.kind==="layer"){n.fit=2,n.radius.fill(0);return}let t=n.el,e=n.media,i=getComputedStyle(t),r=e&&e!==t?getComputedStyle(e):i,s=n.boxW,a=n.boxH,o=n.level?n.edge[0]:s>0&&a>0&&Math.abs(n.doc.w-s)>.01?Math.min(n.doc.w/s,n.doc.h/a):1,l=s>0?s:n.doc.w,u=a>0?a:n.doc.h,h=n.geomEl===t?i:n.geomEl===e?r:getComputedStyle(n.geomEl),c=["borderTopLeftRadius","borderTopRightRadius","borderBottomRightRadius","borderBottomLeftRadius"],E=(b,x)=>b.endsWith("%")?parseFloat(b)/100*x:parseFloat(b)||0,w=[],v=[],d=0,y=!1;c.forEach((b,x)=>{let[S,g=S]=(h[b]||"0px").trim().split(/\s+/);w[x]=E(S,l),v[x]=E(g,u),w[x]>0&&v[x]>0?d?y||=Math.abs(w[x]-v[x]*d)>1:d=w[x]/v[x]:w[x]=v[x]=0}),n.radiusKy=d||1;let P=(b,x)=>x>0?b/x:1,f=Math.min(1,P(l,w[0]+w[1]),P(u,v[1]+v[2]),P(l,w[2]+w[3]),P(u,v[3]+v[0]));for(let b=0;b<4;b++)n.radius[b]=w[b]*f*o;y&&(n.warned.add(n.cornerReason="oval"),k("oval",[n.geomEl],n.el));let m=t.getAttribute("data-gl-fit"),p=m||r.objectFit;n.fit=p==="contain"?1:p==="fill"&&m?2:0,n.objectPosition=(r.objectPosition||"50% 50%").split(/\s+/),N(n)}function N(n){let t=n.objectPosition;if(!t)return;let e=n.boxW>0?n.boxW:n.doc.w,i=n.boxH>0?n.boxH:n.doc.h,r=n.texture?.ready&&n.texture,s=n.media,a=r?r.box?.[2]||r.width:s?.naturalWidth||s?.videoWidth,o=r?r.box?.[3]||r.height:s?.naturalHeight||s?.videoHeight,l=(n.fit?Math.min:Math.max)(e/a,i/o);t.forEach((u,h)=>{let c=parseFloat(u),E=h?i-o*l:e-a*l;n.fitPosition[h]=u.endsWith("%")?c/100:u.endsWith("px")?E*E>.25?c/E:0:.5})}function Je(n){let t=n.media;return(n.kind==="image"||n.kind==="video")&&t&&t!==n.el&&n.el.contains(t)&&t.getClientRects().length>0?t:n.el}function et(n,t,e,i=n.rect){if(i[0]=n.doc.x-t,i[1]=n.doc.y-e,i[2]=n.doc.w,i[3]=n.doc.h,n.pad){let r=n.pad*(n.layoutW?n.doc.w/n.layoutW:1),s=n.pad*(n.layoutH?n.doc.h/n.layoutH:1);i[0]-=r,i[1]-=s,i[2]+=r*2,i[3]+=s*2}return i}var Wt=/^(transform|translate|rotate|scale|perspective|offset[A-Z]|left|top|right|bottom|inset|width|height|min[WH]|max[WH]|margin|padding|flex|grid|clipPath|clip$|opacity|visibility|display|fontSize|letterSpacing|lineHeight|border\w*(Width|Radius)|all$|zoom)/,zt=/^(rotate|perspective|offset|clip|display|border\w*Radius|all$|zoom)/,Vt={transform:/^(none|((translate[XY]?\([^()]*\)|scale[XY]?\([^()-]*\)) ?)+)$/,translate:/^\S+( \S+)?$/,scale:/^[^-\s]+( [^-\s]+)?$/},Qe=new WeakMap;function Pe(n){let t=Qe.get(n);if(t!==void 0)return t;try{let e=n.effect.getKeyframes();t=0;for(let i of new Set(e.flatMap(r=>Object.keys(r)))){if(!Wt.test(i))continue;let r=e.map(a=>a[i]).filter(a=>a!=null),s=Vt[i];t=Math.max(t,zt.test(i)||s&&!(r.length&&r.every(a=>s.test(String(a).trim())))?2:1)}}catch{t=2}return Qe.set(n,t),t}function tt(n,t){let e=(t-n[1])/Math.max(t+n[3],1);return e<0?0:e>1?1:e}var C=n=>parseFloat(n||"0")||0;function $t(n){try{return n.matches(":modal")||n.matches(":popover-open")}catch{return!1}}function Te(n,t){let e=t.get(n);if(e)return e;let i=getComputedStyle(n),r=i.maskImage&&i.maskImage!=="none"||i.webkitMaskImage&&i.webkitMaskImage!=="none"||i.maskBorderSource&&i.maskBorderSource!=="none"||i.webkitMaskBoxImageSource&&i.webkitMaskBoxImageSource!=="none";return e={el:n,tag:n.localName||n.tagName.toLowerCase(),display:i.display,position:i.position||"static",overflowX:i.overflowX||"visible",overflowY:i.overflowY||"visible",contain:i.contain||"none",contentVisibility:i.contentVisibility||"visible",willChange:i.willChange||"auto",filter:i.filter||"none",backdropFilter:i.backdropFilter||i.webkitBackdropFilter||"none",clipPath:i.clipPath||"none",clip:i.clip||"auto",mask:!!r,transform:i.transform||"none",translate:i.translate||"none",rotate:i.rotate||"none",scale:i.scale||"none",perspective:i.perspective||"none",transformOrigin:i.transformOrigin||"",perspectiveOrigin:i.perspectiveOrigin||"",transformStyle:i.transformStyle||"flat",backfaceVisibility:i.backfaceVisibility||i.webkitBackfaceVisibility||"visible",offsetPath:i.offsetPath||"none",opacity:i.opacity||"1",isolation:i.isolation||"auto",mixBlendMode:i.mixBlendMode||"normal",zoom:i.zoom||"1",topLayer:$t(n)},t.set(n,e),e}var Oi=new Float64Array(64);var Xt=n=>(n.overflowY==="auto"||n.overflowY==="scroll")&&n.el.scrollHeight>n.el.clientHeight;function it(n){let t=/px$/.test(n.width)?C(n.width):NaN,e=/px$/.test(n.height)?C(n.height):NaN;return n.boxSizing!=="border-box"&&(t+=C(n.paddingLeft)+C(n.paddingRight)+C(n.borderLeftWidth)+C(n.borderRightWidth),e+=C(n.paddingTop)+C(n.paddingBottom)+C(n.borderTopWidth)+C(n.borderBottomWidth)),[t,e]}function qt(n){return n.assignedSlot??n.parentElement??(n.parentNode?.host||null)}function st(n,t){let e=[],i=n;for(;i;){let r=Te(i,t);if(e.push(r),r.tag==="html"||r.topLayer)break;i=qt(i)}return e}var Se=(n,...t)=>t.some(e=>new RegExp(`\\b${e}\\b`).test(n)),rt=n=>n.tag==="html",Yt=n=>{let t=rt(n)?n.willChange.replace(/(^|,)\s*(backdrop-)?filter\s*(?=,|$)/g,"$1"):n.willChange;return Se(t,"transform","perspective","filter","translate","rotate","scale")},jt=["transform","translate","rotate","scale","perspective","filter","backdropFilter"];function Re(n,t=!0){for(let i of jt)if(n[i]!=="none"&&!(rt(n)&&i.endsWith("ilter")))return`${i==="backdropFilter"?"backdrop-filter":i}: ${n[i]}`;if(Se(n.contain,"layout","paint","strict","content"))return`contain: ${n.contain}`;if(n.contentVisibility==="auto"||n.contentVisibility==="hidden")return`content-visibility: ${n.contentVisibility}`;if(Yt(n))return`will-change: ${n.willChange}`;let e=parseFloat(n.zoom||"1");return t&&Number.isFinite(e)&&Math.abs(e-1)>1e-6?`zoom: ${n.zoom}`:null}var Kt=n=>Re(n,!1)!==null;function nt(n,t=null){for(let e=0;e<n.length;e++){let i=n[e];if(i.tag==="html")break;if(i.tag!=="body"&&i.el.classList?.contains("pin-spacer"))return!0;if(i.position==="fixed"){let r=!1;for(let s=e+1;s<n.length&&!r;s++)r=Kt(n[s]);if(!r)return!0}else if(i.position==="sticky"){let r=null;for(let s=e+1;s<n.length&&!r;s++){let a=n[s];(a.el===t||a.tag==="html"||a.tag==="body"||Zt(a))&&(r=a)}if(!r||r.el===t||r.tag==="html"||r.tag==="body")return!0}}return!1}function Qt(n){if(n==="none"||n==="")return!0;let t=/^matrix\((.*)\)$/.exec(n);if(!t)return!1;let[e,i,r,s]=t[1].split(",").map(Number);return Math.abs(i)<=1e-9&&Math.abs(r)<=1e-9&&e>1e-9&&s>1e-9}function ot(n,t=()=>!1){let e=n[n.length-1],i=e.tag!=="html"||e.overflowX==="visible"&&e.overflowY==="visible";for(let r=0;r<n.length;r++){let s=n[r];if(s.mask||s.clipPath!=="none"||s.clip!=="auto"&&s.clip!==""||s.topLayer||s.rotate!=="none"||s.perspective!=="none"||s.offsetPath!=="none"&&s.offsetPath!==""||s.el.namespaceURI==="http://www.w3.org/2000/svg")return!1;let a=s.scale.split(" ");if(!Qt(s.transform)||s.translate.split(" ").length>2||s.scale!=="none"&&(a.length>2||!a.every(o=>parseFloat(o)>1e-9))||r>0&&Jt(s)&&s.tag!=="html"&&!(s.tag==="body"&&(i||Xt(s)||s.zoom==="1"&&t(s))))return!1}return!0}function Zt(n){let t=e=>e==="hidden"||e==="auto"||e==="scroll"||e==="overlay";return n.display!=="inline"&&n.display!=="contents"&&(t(n.overflowX)||t(n.overflowY))}function Jt(n){return n.display==="inline"?!1:n.overflowX!=="visible"||n.overflowY!=="visible"||Se(n.contain,"paint","strict","content")||n.contentVisibility==="auto"||n.contentVisibility==="hidden"}var at=[1,.85,.7,.55],lt={high:2,mid:1.5,low:1},ei=.8;function ut(n,t,e,i,r=12e6,s=1/0){let a=0,o;typeof n=="number"&&n>0?o=n:Array.isArray(n)?(a=Math.max(0,n[0]||0),o=n[1]||lt[t]):o={...lt,...n&&typeof n=="object"?n:{}}[t]??2,e>s&&(o=Math.min(o,ei));let l=Math.max(a,Math.min(typeof devicePixelRatio=="number"&&devicePixelRatio||1,o));return e*i*l*l>r&&(l=Math.sqrt(r/Math.max(e*i,1))),l}var ae=class{constructor(){this.scale=1;this.index=0;this.settle=30;this.oa=0;this.sa=0;this.dts=[];this.eb=150;this.Db=-1}frame(t,e,i,r){let s=t.frame-this.Db===1;this.Db=t.frame;let a=this.dts;a.push(t.dt),a.length>120&&a.shift();let o=t.dt*60;if(this.settle>0||e)return this.settle=Math.max(0,this.settle-o),!1;if(!s||a.length<30)return!1;let l=a[0];for(let h of a)h<l&&(l=h);t.dt>Math.max(l*1.5,1/40)?((i<0||i>l*1e3*.6)&&this.oa++,this.sa=0):t.dt<l*1.2&&(this.sa+=o,this.oa=Math.max(0,this.oa-o));let u=r?45:150;return this.oa>u&&this.index<at.length-1?(this.eb=Math.min(this.eb*2,2400),this.Rb(this.index+1),!0):this.sa>this.eb&&this.index>0?(this.Rb(this.index-1),!0):!1}onResize(){this.settle=30,this.oa=0,this.sa=0}rest(t){this.settle=Math.max(this.settle,t)}reset(){this.dts.length=0,this.settle=30}Rb(t){this.index=t,this.scale=at[t],this.oa=0,this.sa=0,this.settle=30}};var dt=()=>{let n=typeof window<"u"&&window.occluzeCapture;return n?.version==1?n:null},ht=()=>new Promise(n=>{let t=new MessageChannel;t.port1.onmessage=n,t.port2.postMessage(0)});var Y=1.25,ti=1.5,ct=n=>dt()?ht().then(n):"requestIdleCallback"in window?requestIdleCallback(n,{timeout:2e3}):setTimeout(n,200);var le=class{constructor(t){this.stage=t;this.place=N;this.uploads=[];this.xa=new Map;this.textureUrls=new Map;this.images=new Map;this.warned=!1}get cachedTextures(){return this.xa.size+this.images.size}get imageBytes(){let t=0;return this.images.forEach(e=>t+=e.bytes),t}release(t){let e=t.texture;return t.texture=null,this.free(e)}free(t){return!t||--t.refs>0?!1:(this.images.forEach((e,i)=>e===t&&this.images.delete(i)),t.dispose(),!0)}loadImage(t,e){if(e&&t.textureState=="error")return;let i=this.stage,r=t.media,s=t.el.getAttribute("data-gl-src"),a=()=>s||r?.currentSrc||r?.src||"",o=a(),l=++t.loads;t.textureState="loading";let u=h=>{if(l!=t.loads||t.destroyed||i.lost)return;if(t.loads++,!h){k("image",[]),t.textureState="error",t.setStatus("error");return}let c=this.images.get(h);if(!c||t.texture!==c){e&&t.texture?.ready&&!t.prev?(t.prev=t.texture,t.texture=null):this.release(t);let E=!c;c||this.images.set(h,c=new L(i.gl)),c.refs++,t.texture=c,E&&this.fetch(h,c)}this.sharpen(t),c.ready&&(t.textureState="ready",N(t),t.resolveLoaded(),t.prev&&i.swap(t),i.markDirty())};if(!s&&r&&(e||!r.currentSrc)&&!r.complete){let h=()=>u(a());r.addEventListener("load",h,{once:!0}),r.addEventListener("error",h,{once:!0}),setTimeout(()=>r.currentSrc||u(r.src),4e3);return}u(o)}fetch(t,e,i){let r=this.stage,s=()=>r.planes.filter(l=>l.texture===e),a=[0,0],o=()=>{for(let l of s())a[0]=Math.max(a[0],l.doc.w*r.dpr*Y),a[1]=Math.max(a[1],l.doc.h*r.dpr*Y);return a[0]?a:this.cap(a)};X(t,r.maxTexture,o).then(l=>{e.box=a,(a[2]>r.maxTexture||a[3]>r.maxTexture)&&r.loadWarm().then(h=>h?.note(t,a));let u=s().find(h=>h.status!=="error"||e.ready&&h.domReason);if(!u){if("close"in l&&l.close(),e.ready)return void(e.box=i);this.images.get(t)===e&&this.images.delete(t);for(let h of s())h.domReason&&h.textureState==="loading"&&(h.textureState="none");return}for(let h of s())h.textureState==="loading"&&(h.textureState="queued");this.queueUpload(u,l,e),s().some(h=>h.visible||h.inView)?r.markDirty():r.request()}).catch(l=>{if(e.ready)return void(e.box=i);this.images.get(t)===e&&this.images.delete(t);for(let u of s())k("cors",[u.el,t],l),u.textureState="error",u.setStatus("error")})}cap(t,e=0){let i=this.stage.dpr*Y;return t[0]=(e||innerWidth)*i,t[1]=e?0:innerHeight*i,t}sharpen(t){let e=this.stage,i=t.texture,r=e.dpr;if(!i?.box[2]||!i.ready)return;let s=i.box;if(s[0]&&(t.doc.w*r>s[0]||t.doc.h*r>s[1]))return this.again(i);let[,,a,o]=s,l=this.need(i,a,o);if(!l||(s[0]||a)<=ti*l*a)return;i.box=[];let u=h=>{if(e.destroyed||!i.texture)return;let c=this.need(i,a,o);e.morph?.busy||c&&c!==h?ct(()=>u(c)):this.again(i,s)};ct(()=>u(l))}need(t,e,i){let r=this.stage.dpr,s=0;for(let a of this.stage.planes)if(a.texture===t){if(!a.measured)return 0;s=Math.max(s,a.doc.w*r*Y/e,a.doc.h*r*Y/i)}return s}again(t,e=t.box){t.box=[];for(let[i,r]of this.images)if(r===t)return this.fetch(i,r,e)}forget(t){let e=this.uploads.findIndex(r=>r.plane===t&&!r.tex);if(e<0)return;let[i]=this.uploads.splice(e,1);"close"in i.source&&i.source.close()}queueUpload(t,e,i){let r=this.uploads.find(s=>i?s.tex==i:!s.tex&&s.plane==t);if(!r)return void this.uploads.push({plane:t,source:e,tex:i});r.source!==e&&"close"in r.source&&r.source.close(),r.source=e}uploadNext(t,e){if(!this.uploads.length||!(e<8||t%30===0))return!1;let i=this.stage,r=this.uploads.findIndex(l=>!(l.tex||l.plane.texture)?.ready),s=this.uploads.splice(Math.max(0,r),1)[0],a=!1,o=s.tex?s.tex.texture&&s.tex:i.planes.includes(s.plane)&&s.plane.status!=="error"&&(s.plane.texture||=new L(i.gl));if(o){o.upload(s.source,s.plane.usesGlyph?{mipmaps:!1}:{}),s.plane._raster?.upload(i.gl),i.stats.uploads++;for(let l of i.planes)l.texture!==o||l.textureState=="error"||(l.textureState="ready",N(l),l.resolveLoaded(),l.prev&&i.swap(l),a||=l.visible||l.inView);this.evictFar()}return"close"in s.source&&s.source.close(),a}evictFar(){let t=this.stage,e=t.textureBudget,i=t.fx,r=t.video,s=0;for(let l of t.planes)l.texture?.refs||(s+=l.texture?.bytes||0);s+=this.imageBytes;let a=i?.pool.bytes||0,o=r?.frameBytes()||0;if(i&&s+a+o>e&&(a-=i.pool.trim()),s+a+o>e){let l=t.planes.filter(u=>u.kind==="image"&&!u.near&&!u.soon&&u.texture?.ready).sort((u,h)=>u.farAt-h.farAt);for(let u of l){if(s+a+o<=e)break;let h=u.texture.bytes;this.release(u)&&(s-=h),u.textureState!="error"&&(u.textureState="none"),u.status!="error"&&(u.status="loading",u.setStatus(null),u.readyFrame=-1)}}r&&(o-=r.fit(e-s-a)),s+a+o>e&&!this.warned&&(this.warned=!!t.loadWarm().then(l=>l?.note("",[s,a+o]))),t.stats.textureMB=Math.round(s/2**20)}textureFromUrl(t){let e=this.stage,i=this.xa.get(t);if(i)return i;i=new L(e.gl),this.xa.set(t,i),this.textureUrls.set(i,t);let r=i;return X(t,e.maxTexture).then(s=>{r.upload(s),"close"in s&&s.close(),e.markDirty()}).catch(s=>k("uniformImage",[],t,s)),i}onLost(){this.xa.clear(),this.images.clear();for(let t of this.uploads)"close"in t.source&&t.source.close();this.uploads.length=0}dispose(){this.xa.forEach(t=>t.dispose()),this.images.forEach(t=>t.dispose()),this.textureUrls.clear(),this.onLost()}};function ft(n){if(!(!n||typeof navigator<"u"&&/apple/i.test(navigator.vendor||"")))try{n.isContextLost?.()||n.getExtension("WEBGL_lose_context")?.loseContext()}catch{}}var j={duration:1.4,delay:0,ease:F,start:"top 90%",trigger:"auto"};function ii(n){let t=String(n??"").trim().toLowerCase();return t==="scroll"||t==="load"||t==="manual"||t==="hover"?t:(t===""||t==="auto"||k("trigger",[n]),"auto")}function Me(n){let t=n.getBoundingClientRect();return(t.width>0||t.height>0)&&t.top<window.innerHeight&&t.bottom>0}function si(n){let t=String(n??j.start).trim().toLowerCase().split(/\s+/),e=t[0]||"top",i=t[1]??"bottom",r=e==="center"?.5:e==="bottom"?1:0;e!=="top"&&e!=="center"&&e!=="bottom"&&k("edge",[n]);let s="0px";return i==="top"?s="-100%":i==="center"?s="-50%":i==="bottom"?s="0px":/^-?[\d.]+%$/.test(i)?s=`-${Math.max(0,100-parseFloat(i))}%`:/^-?[\d.]+(px)?$/.test(i)?s=`${-Math.max(0,(window.innerHeight||800)-parseFloat(i))}px`:k("line",[n]),{rootMargin:`${r?1e3:0}% 0px ${s} 0px`,threshold:r}}var mt=(n,t)=>typeof n=="number"&&Number.isFinite(n)?n:t;function pt(n,t,e,i){let r=n.uniforms[t];if(!r)return()=>{};let s=ii(e.trigger),a=mt(e.delay,0),o=(w,v)=>i.tweens.to(r,{value:w,duration:i.reducedMotion?0:mt(e.duration,j.duration),delay:v,ease:e.ease||j.ease});if(s==="hover"){let w=n.el.closest("a, button")||n.el,v=()=>o(1,a),d=()=>o(0,0);return w.addEventListener("pointerenter",v),w.addEventListener("pointerleave",d),()=>{w.removeEventListener("pointerenter",v),w.removeEventListener("pointerleave",d)}}if(n.morphIn||i.reducedMotion)return r.value=1,()=>{};if(s==="manual")return()=>{};let l=!0,u=null,h=w=>n.loaded.then(()=>{l&&o(1,Math.max(0,a-(performance.now()-w)/1e3))}),c=()=>{if(!l)return;let w=performance.now();if(s==="load"||s==="auto"&&Me(n.el))return void h(w);let{rootMargin:v,threshold:d}=si(e.start);u=new IntersectionObserver(y=>{y.some(P=>P.isIntersecting&&P.intersectionRatio>=d)&&(u?.disconnect(),u=null,h(performance.now()))},{rootMargin:v,threshold:d}),u.observe(n.el)},E=i.clock.whenOpen(c);return()=>{l=!1,E(),u?.disconnect()}}var gt={scrub:"modules/scrub.js"};var ue=class{constructor(){this.dirty=!0;this.forced=2;this.la=0;this.Za=!1;this.Ea=0;this.changing=0;this.paused=!1}markDirty(){this.dirty=!0,this.Ea=0,this.request()}request(){this.inactive||document.hidden||this.host.ticker.wake(1)}wake(t=1){this.forced=Math.max(this.forced,t),this.markDirty()}live(t){typeof t=="number"?(this.Za=!1,this.la=Math.max(this.la,performance.now()+t*1e3)):(this.Za=t,t||(this.la=0)),this.markDirty()}extendLive(t){this.la=Math.max(this.la,performance.now()+t*1e3),this.markDirty()}isLive(t){return this.Za||this.changing>0||t<this.la}pause(){this.paused=!0,this.morph?.cancel(),this.showDom(),this.stats.state="paused"}resume(){if(!(!this.paused||this.hostReason)){this.paused=!1;for(let t of this.planes)t.status!=="error"&&t.setStatus("loading"),t.loadingSince=0;this.invalidate(),this.wake(2)}}get inactive(){return this.paused||this.failed||this.lost||this.destroyed}keepGoing(t){let e=performance.now();t?this.Ea=0:this.Ea++;let i=()=>this.planes.some(s=>s.inView);t||this.forced>0||this.media.uploads.length>0||this.tweening||this.morph?.busy||this.isLive(e)||this.planes.some(s=>s.visible&&s.status==="loading"&&(s.near||s.soon)&&!s._raster?.empty)||this.planes.some(s=>e<s.animUntil&&(s.animUntil===1/0?s.inView:s.soon))||this.animWait||this.Ea<60&&i()?this.request():(this.stats.state=i()?"asleep":"dormant",this.stats.busy=[])}};var de=class{constructor(t,e=new Map){this.gl=t;this.chunks=e;this.da=new Map;this.grids=new Map;this.included=new Map;this.glsl=null}get size(){return this.da.size}prepare(t){let e=t.kind==="shader"||t.kind==="video"?t.kind:"image",i=`${e}|${t.shader?.name||""}|${t.effects.map(a=>a.name).join(",")}${t._inst?.key||""}`;t.programKey=i;let r=this.da.get(i);if(!r){let a={};for(let c in t.uniforms)a[c]=t.uniforms[c].value;let o={kind:e,effects:t.effects.map(c=>({name:c.name,def:c.def})),shader:t.shader?{name:t.shader.name,def:t.shader.def}:void 0,uniforms:a};if(t.glsl){let c=this.glsl?.(o,t,this.chunks);if(!c)return!1;this.included.set(i,c.included),o=c}t._inst&&(o=t._inst.build(o));let{vertex:l,fragment:u}=We(o),h=i+","+l+u;if(r=this.da.get(h),!r){try{r=new te(this.gl,l,u,i)}catch(c){return T.error(c instanceof Error?c.message:c),t.setStatus("error"),!1}r.failed&&J("glsl",r.error,T.error),this.da.set(r.failed?h:i,r)}}if(r.failed)return t.setStatus("error"),!1;t.program=r;let s=this.grid(t.segments);return t.grid=t._inst?t._inst.wrap(s):s,t.bends=!!t._inst||t.effects.some(a=>!!a.def.vertex?.main),!0}grid(t){let e=this.grids.get(t);return e||(e=new ie(this.gl,t),this.grids.set(t,e)),e}failed(t,e){let i=t.program;J("glsl",i.error,T.error),this.da.delete(t.programKey);for(let r of e)r.program===i&&r.setStatus("error")}drop(t,e){let i=[];for(let[r,s]of this.da){let[,a,o]=r.split("|");(t==="effect"?o.split(",").includes(e):t==="shader"?a===e:t==="chunk"&&this.included.get(r)?.includes(e))&&(this.da.delete(r),i.push(s))}return i}lost(){this.da.clear(),this.grids.clear(),this.included.clear()}dispose(t){t&&(this.da.forEach(e=>e.dispose()),this.grids.forEach(e=>e.dispose())),this.lost()}};var ri=(n,t)=>n.order-t.order||n.index-t.index,he=class{constructor(t){this.host=t;this.list=[];this.adaptive=new ae;this.ka=null;this.program=null;this.unit=0;this.bound=[];this.fixed=!1;this.ga=-1;this.pc=new Int32Array(4);this.view=new Int32Array(2);this.Wb=new Float32Array(2);this.qa=new Float32Array(2);this.imageSize=new Float32Array(2);this.surface=new Float32Array(4);this.draws=0;this.probe=null;this.Zb=t=>{t.kind==="layer"||!t.program?.ready()||!t.grid||t.kind!=="shader"&&!t.texture?.ready||this.drawPlane(t,!0)};this.blank=new L(t.gl),this.timer=new $(t.gl)}draw(t){let e=this.host,i=e.gl,r=e.canvas,s=this.list;s.length=0;for(let h of e.visibleList)h.destroyed||s.push(h);s.sort(ri);let a=this.probe;this.timer.poll(),a||this.timer.begin(),this.bound[this.unit]=void 0;let o=e.layers;if(o){for(let h of e.planes)if(h._layer){o.begin(s,t),this.reset();break}}let l=this.view;(l[0]!==r.width||l[1]!==r.height)&&i.viewport(0,0,l[0]=r.width,l[1]=r.height),this.scissor(null),this.fixed||(i.bindFramebuffer(i.FRAMEBUFFER,null),i.clearColor(0,0,0,0),i.enable(i.BLEND),i.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA),i.disable(i.DEPTH_TEST),this.fixed=!0),e.fx?.pre(s),i.clear(i.COLOR_BUFFER_BIT),this.draws=0;let u=this.Wb;u[0]=e.viewport.width,u[1]=e.viewport.height,this.surface[2]=u[0],this.surface[3]=u[1],this.qa[0]=r.width,this.qa[1]=r.height;for(let h of s)if(!(h.morphHidden||h.vt||h.hush||h.group)){if(h._mods.frames)h._mods.frames.pick(h)&&N(h);else if(h.kind==="video"){if(!e.video?.upload(h))continue;this.bound[this.unit]=void 0}if(h.kind==="layer"){if(!h._layer?.ready)continue;a?.(h),o.render(h,t),this.reset(),e.fx?.bind(),this.draws++}else{if(!(h.kind==="shader"||!!(h.texture?.ready||h.prev?.ready))||!h.program||!h.grid)continue;if(!h.program.ready()){h.program.failed?e.programs.failed(h,e.planes):e.forced=Math.max(e.forced,1);continue}if(h.backdrop){if(!e.fx?.copy(h))continue;this.bound[this.unit]=void 0}a?.(h),this.drawPlane(h)}h.lastRect.set(h.rect),h.lastXf.set(h.drawXf),h.lastOpacity=h.opacity,h.readyFrame===-1&&h.status==="loading"&&(h.readyFrame=t.frame)}return e.fx?.leave?.frame(),e.morph?.draw(this.Zb),e.fx?.post(),a?.(null),this.scissor(null),i.bindVertexArray(null),a||this.timer.end(),this.draws}reset(){this.program=null,this.unit=0,this.bound.length=0,this.fixed=!1,this.ga=-1,this.view[0]=-1}scissor(t){let e=this.host.gl,i=t?1:0;this.ga!==i&&(t?e.enable(e.SCISSOR_TEST):e.disable(e.SCISSOR_TEST));let r=this.pc;t&&(this.ga!==i||r[0]!==t[0]||r[1]!==t[1]||r[2]!==t[2]||r[3]!==t[3])&&(e.scissor(t[0],t[1],t[2],t[3]),r.set(t)),this.ga=i}bind(t,e,i,r){let s=this.host.gl;this.bound[r]!==i.texture&&(this.unit!==r&&s.activeTexture(s.TEXTURE0+(this.unit=r)),s.bindTexture(s.TEXTURE_2D,this.bound[r]=i.texture)),t.set(e,r)}drawPlane(t,e=!1){let i=this.host,r=i.gl,s=t.program;t.usesGlyph&&!this.ka&&(this.ka=i.text.blank(r),this.bound[this.unit]=void 0);let a=e?null:t.clips;this.scissor(a?.ga?a.scissorPx:null),this.program!==s.program&&r.useProgram(this.program=s.program),s.set("uViewport",this.Wb),s.set("uSurface",this.surface),s.set("uCanvas",this.qa),s.set("uRect",t.level&&!t.xfReason?t.shaderRect:t.rect),s.set("uSize",t.size),s.set("uBleed",t.bleed),s.set("uPlaneMatrix",t.drawXf),s.set("uTime",i.time),s.set("uScrollVelocity",i.velocity),s.set("uMouse",t.mouse),s.set("uProgress",t.progress),s.set("uAlpha",t.opacity),s.set("uRadius",t.radius),s.set("uRadiusKy",t.radiusKy),s.set("uUmberClips",a?a.count:0),a?.count&&(s.set("uUmberClipXf",a.xf),s.set("uUmberClipBox",a.box),s.set("uUmberClipRadius",a.radius),s.set("uUmberClipPoly",a.poly),s.set("uUmberClipPolyInfo",a.polyInfo)),s.set("uDpr",i.dpr*this.adaptive.scale),s.set("uFit",t.fit),s.set("uFitPosition",t.fitPosition);let o=t.texture?.ready?t.texture:t.prev?.ready?t.prev:this.blank;this.bind(s,"uImage",o,0);let l=this.imageSize;l[0]=o.box?.[2]||o.width,l[1]=o.box?.[3]||o.height,s.set("uImageSize",l);let u=1;for(let h in t.uniforms){let c=t.uniforms[h].value;c?.texture!==void 0?this.bind(s,h,c,u++):s.set(h,typeof c=="boolean"?Number(c):c)}if(t.usesGlyph){let h=this.ka,c=t._raster,E=c?.glyphIndex?.ready&&c.glyphData?.ready;this.bind(s,"uGlyphIndex",E?c.glyphIndex:h.index,u++),this.bind(s,"uGlyphData",E?c.glyphData:h.data,u++)}if(t._mods.frames){let h=t._mods.frames.next;this.bind(s,"uFrameNext",h||o,u++),s.set("uFrameMix",h?t._mods.frames.mix:0)}t.grid.draw(),this.draws++}adapt(t){let e=this.host;if(e.options.adaptive===!1||e.cap)return!1;let i=e.host.clock.held||e.isLive(performance.now())||e.media.uploads.length>0;return this.adaptive.frame(t,i,this.timer.ms,this.timer.supported)?(e.stats.scale=this.adaptive.scale,T.info(`GL render scale ${this.adaptive.scale}`),!0):!1}lost(){this.ka=null}restored(){this.reset(),this.blank=new L(this.host.gl),this.timer=new $(this.host.gl),this.adaptive.reset()}dispose(){this.timer.dispose(),this.blank.dispose(),this.ka?.index.dispose(),this.ka?.data.dispose()}};var ni=2;function yt(n,t){++n.losses<=ni?t.preventDefault():(k("losses",[n.losses]),n.failed=!0,document.documentElement.classList.remove("has-gl"),n.stats.state="off (context lost)"),oi(n),n.failed&&n.host.off("context-lost")}function oi(n){n.lost=!0,n.morph?.cancel();for(let t of n.planes){t.setStatus(null),t.readyFrame=-1,t.el.removeAttribute("data-gl-morphing"),t.textureState!=="error"&&(t.videoCleanup?.(),t.videoCleanup=null,t.textureState="none"),t.texture=t.prev=null,t.program=null,t.grid=null;for(let e of t.parts())e?.lost?.()}for(let t of n.subsystems)t.lost?.();n.layers?.fade.forget(),n.media.onLost(),n.views?.lost(),n.host.emit("lost"),n.failed||k("lost",[])}function ce(n,t,e){if(!n.failed){T.error(`GL ${t} failed; the plain DOM shows for the rest of this visit.`,e),n.failed=!0;try{n.morph?.cancel()}catch{}Le(n),document.documentElement.classList.remove("has-gl"),n.stats.state="off (error)",n.host.off("error")}}function Le(n){for(let t of n.planes)t.status!=="error"&&(t.setStatus(null),t.status="loading"),t.readyFrame=-1,t.el.removeAttribute("data-gl-morphing");if(!n.lost)try{n.gl.clearColor(0,0,0,0),n.gl.clear(n.gl.COLOR_BUFFER_BIT)}catch{}}var _e=3e3,vt=3e3,ai=1.5,li=6,ui=5e3,di=100,bt={texture:null},xt=n=>{for(let[t,e]of n._play.playables)if(e.trigger==="hover"&&n.uniforms[t]?.value>0)return!0;return!1},fe=class extends ue{constructor(e,i,r,s,a=!1){super();this.host=e;this.ownHost=a;this.planes=[];this.ba=new WeakMap;this.ya=new WeakMap;this.text=null;this.textWaiting=new Set;this.glyphWaiting=new Set;this.ib=null;this.shapes=null;this.tc=null;this.shapesError=null;this.animWait=!1;this.layers=null;this.views=null;this.hc=null;this.video=null;this.Ac=null;this.videoWaiting=new Set;this.ec=null;this.morph=null;this.Gb=null;this.fx=null;this.cc=null;this.flow=null;this.warm=null;this.Bc=null;this.ac=null;this.Ra=null;this.ja=null;this.Wa=new Set;this.gc=null;this.cap=null;this.gone=new Map;this.onScreen=Me;this.ease=oe;this.Texture=L;this.Plane=z;this.bitmap=X;this.lost=!1;this.failed=!1;this.destroyed=!1;this.losses=0;this.ea=!0;this.jb=0;this.viewport={width:1,height:1};this.screen={width:1,height:1};this.dpr=1;this.ratio=1;this.tier="high";this.maxTexture=4096;this.textureBudget=192*2**20;this.wide=1/0;this.Xb=!1;this.userPause=!1;this.forcedPause=!1;this.hostReason=null;this.hostPause=!1;this.scrollX=0;this.scrollY=0;this.pageX=0;this.pageY=0;this.velocity=0;this.pointer={x:-1,y:-1};this.vb=0;this.watched=null;this.time=0;this.Xa=0;this.cleanups=[];this.tb=null;this.stats={state:"dormant",backend:"webgl2",tier:"high",gpu:null,fps:0,frameMs:0,renders:0,skipped:0,rendersPerSec:0,draws:0,planes:0,visible:0,textures:0,textureMB:0,gpuMB:0,uploads:0,programs:0,busy:[],dpr:1,scale:1,width:0,height:0};this.fa=[];this.settles=0;this.landing=[];this.Kb=new Map;this.chainMemo=new Map;this.gen=0;this.va=new Set;this.animCheck=!1;this.Ta=0;this.Da=null;this.Ca=null;this.scrolled=!1;this.hb=!1;this.Eb=NaN;this.Ya=NaN;this.Bb=!1;this.measure=e=>{if(!this.inactive)try{this.kc(e)}catch(i){ce(this,"measure",i)}};this.slides=new WeakMap;this.pb=null;this.Ia=!1;this.visibleList=[];this.tweening=!1;this.update=e=>{if(!this.inactive)try{this.zc(e)}catch(i){ce(this,"update",i)}};this.render=e=>{if(!this.inactive)try{this.oc(e)}catch(i){ce(this,"render",i)}};this.canvas=i,this.gl=r,this.hostEl=s,this.options=e.options,this.registry=e.registry,this.tweens=new B(()=>this.markDirty(),()=>this.host.ticker.frame.time),this.renderer=new he(this),this.media=new le(this),this.programs=new de(r,e.registry.chunks),this.subsystems=[this.programs,this.renderer];let o=Ue(e,r);this.tier=this.stats.tier=o.tier,this.maxTexture=o.maxTexture,this.textureBudget=o.textureBudget,this.wide=o.wide,this.stats.gpu=o,T.info("GL tier",o),this.io=new IntersectionObserver(f=>{let m=!1,p=!1;for(let b of f){let x=this.ba.get(b.target);if(!x)continue;let S=x.animUntil===1/0&&!x.inView;S||(m=!0),!S&&(x.inView||x.visible)&&(p=!0),b.isIntersecting&&!x.soon&&!S&&(this.animCheck=!0),x.soon=b.isIntersecting,(b.isIntersecting&&x.gen!==this.domGen||this.transitioning)&&(x.stale=!0),x._mods.feed||(b.isIntersecting&&x.kind==="video"&&(x.videoFrame=!0),x.kind==="video"&&x.media&&this.video?.autoPause(x,b.isIntersecting))}p?this.markDirty():m&&this.request()},{rootMargin:"25% 0px 25% 0px"}),this.Ha=new IntersectionObserver(f=>{for(let m of f){let p=this.ba.get(m.target);!p||p.inView===m.isIntersecting||p.wrap?.[1]||(p.inView=m.isIntersecting,p._mods.tell(b=>b.visible?.(p.inView)),p.emit(p.inView?"enter":"leave"))}this.markDirty()}),this.Ga=new IntersectionObserver(f=>{for(let m of f){let p=this.ba.get(m.target);if(p){if(!m.isIntersecting&&!p.wrap){p.near&&p._mods.tell(b=>b.near?.(!1)),p.near=!1,p.farAt=performance.now();continue}p.near||p._mods.tell(b=>b.near?.(!0)),p.near=!0,this.loadMedia(p)}}},{rootMargin:"150%"}),this.ro=new ResizeObserver(f=>{for(let m of f){if(m.target===this.hostEl){this.ea=!0,this.invalidate();continue}if(m.target===document.documentElement){this.invalidate();continue}let p=this.ba.get(m.target)||this.ya.get(m.target);p&&(p.stale=!0)}this.markDirty()}),this.ro.observe(this.hostEl),this.ro.observe(document.documentElement);let l=()=>{let f=matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`),m=()=>{this.ea=!0,this.markDirty(),l()};f.addEventListener?.("change",m,{once:!0}),this.tb=()=>f.removeEventListener?.("change",m)};l(),this.cleanups.push(()=>this.tb?.()),this.listen(window,"resize",()=>{this.ea=!0,(!this.host.env.isTouch||innerWidth!=this.screen.width)&&this.invalidate()}),this.listen(window,"pointermove",f=>{let m=f;this.pointer.x=m.clientX,this.pointer.y=m.clientY,this.jb>0&&this.request()}),this.listen(document,"visibilitychange",()=>{if(!document.hidden){for(let f of this.planes)f.loadingSince=0;this.renderer.adaptive.rest(30),this.invalidate(),this.wake(2)}}),this.listen(i,"webglcontextlost",f=>yt(this,f),!1),this.listen(i,"webglcontextrestored",()=>this.chunk(this.host.loadRestore,"restore","the DOM shows for the rest of this visit.",f=>f.restored(this))),document.fonts?.addEventListener&&this.listen(document.fonts,"loadingdone",()=>{for(let f of this.planes)f._raster&&(f._raster.textDirty=!0);this.invalidate()});let u=f=>f instanceof Element&&this.planes.some(m=>f===m.el||f.contains(m.geomEl)),h=f=>{u(f.target)&&(this.animCheck=!0,this.markDirty())},c=f=>{let m=f.target;if(!(m instanceof Element))return;let p=!1;for(let b of this.planes)(m===b.el||m.contains(b.geomEl))&&(b.stale=p=!0);p&&(this.animCheck=!0,this.markDirty())};for(let f of["transitionrun","animationstart"])this.listen(document,f,h);for(let f of["transitionend","animationend","transitioncancel","animationcancel"])this.listen(document,f,c);let E=f=>{if(!this.planes.some(S=>S.inView))return;let m=f.target;if((f.type==="pointerover"||f.type==="pointerout")&&(this.scrolled||this.hb)&&m instanceof Element){f.type==="pointerout"?this.Da||=m:this.Ca=m;return}let b=!1;m instanceof Element&&f.type!=="keydown"&&f.type!=="pointerdown"&&f.type!=="input"&&(b=this.Ua(m));let x=performance.now();(b||x-this.Ta>=di)&&(this.Ta=x,this.animCheck=!0,this.request())};for(let f of["pointerover","pointerout","pointerdown","focusin","focusout","keydown","input"])this.listen(document,f,E);let w=typeof Element<"u"?Element.prototype:null,v=w?.animate;if(w&&typeof v=="function"){let f=this,m=function(...p){let b=v.apply(this,p);try{f.onAnimate(this)}catch{}return b};w.animate=m,this.cleanups.push(()=>{w.animate===m&&(w.animate=v)})}let d=typeof Animation<"u"?Animation.prototype:null;if(d){let f=this,m=p=>{try{f.Jb(p)}catch{}};for(let p of["play","pause","finish","reverse","cancel","updatePlaybackRate"]){let b=d[p];if(typeof b!="function")continue;let x=function(...S){let g=b.apply(this,S);return m(this),g};d[p]=x,this.cleanups.push(()=>{d[p]===x&&(d[p]=b)})}for(let p of["currentTime","startTime","playbackRate"]){let b=Object.getOwnPropertyDescriptor(d,p),x=b?.set;if(!b||!x||!b.configurable)continue;let S={...b,set(g){x.call(this,g),m(this)}};Object.defineProperty(d,p,S),this.cleanups.push(()=>{Object.getOwnPropertyDescriptor(d,p)?.set===S.set&&Object.defineProperty(d,p,b)})}}let y=f=>{let m=f.target;!(m instanceof Element)||m===this.host.scroll.root||m===document.documentElement||m===document.body||(this.gen++,this.planes.some(p=>p.soon&&m.contains(p.el))&&(this.va.add(m),this.markDirty()))};document.addEventListener("scroll",y,{capture:!0,passive:!0}),this.cleanups.push(()=>document.removeEventListener("scroll",y,{capture:!0})),this.cleanups.push(e.env.onForcedColorsChange(f=>this.hold("forcedPause",f))),this.checkHost(),this.options.busy&&this.Dc(this.options.busy),this.cleanups.push(e.ticker.add(this.measure,{phase:"measure"})),this.cleanups.push(e.ticker.add(this.update,{phase:"update"})),this.cleanups.push(e.ticker.add(this.render,{phase:"render"}));let P=window.occluzeCapture;P?.version==1&&this.chunk(e.loadCapture,"capture","frames wait for nothing.",f=>this.cap=f.capture(this,P))}listen(e,i,r,s=!0){e.addEventListener(i,r,{passive:s}),this.cleanups.push(()=>e.removeEventListener(i,r))}get scale(){return this.renderer.adaptive.scale}get reducedMotion(){return this.options.reducedMotion!=="off"&&this.host.env.reducedMotion}get now(){return this.host.ticker.frame.time*1e3}get transitioning(){return this.host.clock.held||this.isLive(performance.now())}apply(e){e.still||this.gen++,(e.styles||e.added.length)&&this.Ib();let i=!1;for(let s of e.rebuild){let a=this.ba.get(s);a&&this.removePlane(a)}for(let s of e.sources){let a=this.ba.get(s);a?.kind==="image"&&a.textureState!=="none"?this.media.loadImage(a,!0):a?.kind==="video"&&this.video?.renew(a,e.rebuild)}let r=[...e.added,...e.rebuild];if(r.length){let s=[...new Set(r.flatMap(o=>Q(o)))];this.fx?.groups.moved();for(let o of s){let l=this.ba.get(o);l&&(l.stale=!0),l&&this.morph?.forget(l)&&this.attach(l)}let a=s.filter(o=>!this.ba.has(o));if(a.length){a.some(o=>o.hasAttribute("data-gl-id"))&&this.morph?.capture(null,!0);for(let o of a)this.create(o);this.morph?.settle(!1),i=e.added.some(o=>o!==document.documentElement)}}if(e.removed||e.detached&&this.planes.some(s=>!s.el.isConnected)){let s=this.planes.length;this.prune(),this.planes.length<s&&(i=!0,this.retry())}if(i&&(this.extendLive(ai),this.fx?.leave?.swap()),e.touched.length){let s=!1,a=new Map;for(let o of this.planes)for(let l of e.touched)if(l===o.el||l.contains(o.geomEl)&&(o.soon||o.visible||l!==document.documentElement&&l!==document.body)){if(o.status==="error")this.vb||=setTimeout(()=>{this.vb=0;for(let u of this.planes)u.status==="error"&&(u.stale=!0);this.request()},250);else{let u=l===o.el||o.level?null:a.has(l)?a.get(l):a.set(l,this.slid(l)).get(l);u?(o.doc.x+=u[0],o.doc.y+=u[1],this.va.add(l)):o.stale=!0,s=!0,this.watched=l}break}s&&(this.animCheck=!0,this.markDirty())}if(e.look)for(let s of this.planes)s.status==="error"&&(s.stale=!0);if(e.styles){for(let s of this.planes)s.stale=!0;this.animCheck=!0,this.markDirty()}(e.styles||e.touched.some(s=>s===document.documentElement||s===document.body))&&this.checkHost(),i&&(this.animCheck=!0)}Ib(){!this.shapes&&document.querySelector("[data-gl-occlude]")&&this.loadShapes(),document.querySelector("[data-gl-pass]")&&this.loadFx()}scan(e){this.Ib();for(let i of Q(e))this.ba.has(i)||this.create(i);this.markDirty()}create(e){try{this.Oa(e)}catch(i){T.error("could not create a GL plane",e,i),e.setAttribute("data-gl-status","error")}}plane(e){return this.ba.get(e)}info(){let e=0,i=0;for(let s of this.planes)s.texture?.refs||(e+=s.texture?.bytes||0,s.texture?.ready&&i++);e+=this.media.imageBytes,this.stats.planes=this.planes.length;let r=performance.now();for(;this.fa.length&&r-this.fa[0]>1e3;)this.fa.shift();return this.stats.rendersPerSec=this.fa.length,this.stats.textures=i+this.media.cachedTextures,this.stats.textureMB=Math.round(e/2**20),e+=(this.fx?.pool.bytes||0)+(this.video?.frameBytes()||0)+this.canvas.width*this.canvas.height*4,this.stats.gpuMB=Math.round(e/2**20),this.stats}list(e){return!e||e===document?this.planes.slice():this.planes.filter(i=>e.contains(i.el))}Oa(e){let i=(e.getAttribute("data-gl")||"").trim().toLowerCase(),r=pe(e),s=["image","video","shader","layer","text","group"],a=s.indexOf(i)>1?i:i==="video"||!i&&r instanceof HTMLVideoElement?"video":"image";i&&!s.includes(i)&&k("type",[e,i,s],e);let o=new z(e,a,this.planes.length,this),l=a==="group";o.media=a==="shader"||a==="text"||l?null:r,l||H(e),o.media&&Z(e,o.media),e.hasAttribute("data-gl-placeholder")&&this.loadWarm().then(d=>d?.paint(e)),o.order=D.num(e,"data-gl-order",0);let u=e.closest("[data-gl-wrap]");if(u&&(o.wrap=[+(u.getAttribute("data-gl-wrap")==="y"),0,0]),o.live=D.bool(e,"data-gl-live")||V(e),o.scrolls=this.host.scroll.contains(e),o.setStatus(this.inactive?null:"loading"),a==="text"&&(this.text?this.text.units(o):this.loadText()),a==="layer"){this.layers?this.layers.create(o)?this.track(o):this.track(o,!1):(this.loadLayers(),this.track(o,!1),this.gone.get("layers")?.());return}if(!this.video&&(a==="video"||this.modulesOf(e).length)){this.videoWaiting.add(o),this.loadVideo(),this.track(o,!1);return}let h=1,c="";for(let{name:d,binding:y}of this.ob(o))y.effect&&(this.addUniforms(o,y.effect.uniforms||{}),h=Math.max(h,y.effect.segments||1),c+=JSON.stringify([y.effect.vertex,y.effect.fragment]),o.effects.push({name:d,def:y.effect,options:{},ctx:null}));let E=D.list(e,"data-gl-effect");for(let d of E){let y=this.registry.effects.get(d);if(!y){o.missing.push(d),k("effect",[e,d,[...this.registry.effects.keys()]],e);continue}let P=y.play||"",f=this.ub(e,d,y);this.addUniforms(o,y.uniforms||{}),P&&!o.uniforms[P]&&this.addUniforms(o,{[P]:0}),this.optionUniforms(o,d,f),y.reduced&&this.reducedMotion&&this.addUniforms(o,y.reduced),h=Math.max(h,y.segments||1),c+=JSON.stringify([y.vertex,y.fragment]),o.effects.push({name:d,def:y,options:f,ctx:null}),P&&!o._play.playables.has(P)&&o._play.playables.set(P,f)}if(o._play.playables.size)e.setAttribute("data-gl-play","");else{if(o.missing.length&&e.hasAttribute("data-gl-play"))return o.sizeCheck=setTimeout(()=>o.setStatus(null),_e),this.track(o,!1);e.removeAttribute("data-gl-play")}if(a==="shader"){let d=e.getAttribute("data-gl-shader")||"",y=this.registry.shaders.get(d);if(!y){o.missing.push(`shader:${d}`),k("shader",[e,d,[...this.registry.shaders.keys()]],e),o.setStatus("error"),this.track(o,!1);return}let P=this.Sb(e,y);this.addUniforms(o,y.uniforms||{}),this.optionUniforms(o,"",P),c+=y.fragment+(y.head||""),o.shader={name:d,def:y,options:P,ctx:null}}let w=o.shader?.def.head?1:0;for(let{def:d}of o.effects)(d.vertex?.head||d.fragment?.head)&&w++;o.glsl=w>1||c.includes("#include")||Ge.test(c)||$e.test(c),o.usesVelocity=c.includes("uScrollVelocity"),o.usesTime=c.includes("uTime"),o.usesProgress=c.includes("uProgress"),o.usesGlyph=ze.test(c);for(let d in o.uniforms){let y=o.uniforms[d].value;ArrayBuffer.isView(y)&&!ye(y)&&c.includes(d)&&!new RegExp(`uniform[^;]*\\b${d}\\b`).test(c)&&k("texture",[d])}if(c.includes("uBackdrop")&&(this.addUniforms(o,{uBackdrop:o.backdrop={texture:null}}),this.loadFx()),c.includes("uFlow")&&(this.addUniforms(o,{uFlow:this.flow||={texture:this.renderer.blank.texture}}),this.loadFx().then(d=>d?.flow())),/\b(uPrev|uSwap|samplePrev)\b/.test(c)&&(this.addUniforms(o,{uPrev:bt,uPrevSize:[1,1],uSwap:1}),this.loadFlip()),o.usesGlyph&&a!=="text"&&k("glyph",[],e),o.segments=h,o.usesGlyph&&!this.text){this.glyphWaiting.add(o),this.loadText(),this.track(o,!1);return}if(o.glsl&&!this.programs.glsl){o.missing.push("chunk:"),this.ec||=this.chunk(this.host.loadGlsl,"glsl","planes whose effects #include a chunk or share a helper name show their DOM.",d=>{this.programs.glsl=d.glsl(this),Object.assign(I,d.GLSL_HELPERS),this.defined("chunk","")},()=>{for(let d of this.planes)d.missing.includes("chunk:")&&d.setStatus("error")}),this.track(o,!1),this.gone.get("glsl")?.();return}let v=e.getAttribute("data-gl-instances")??o.effects.find(d=>d.def.instances!=null)?.def.instances;if(v!=null){if(!this.ja){this.Wa.add(o),this.gc||=this.chunk(this.host.loadInstances,"instances","planes with instances show their DOM.",d=>{this.ja=d.instances(this),this.remake(this.Wa)},()=>this.remake(this.Wa,!0)),this.gone.get("instances")?.(),this.track(o,!1);return}this.ja.part(o,v)}if(!this.programs.prepare(o)){this.track(o,!1);return}this.track(o),o.backdrop&&this.gone.get("fx")?.(),l&&(o.textureState="ready",o.resolveLoaded(),this.loadFx()),e.hasAttribute("data-gl-id")&&this.loadMorph(),this.changing&&this.named(o),(!o.vt&&this.morph?.claim(o)||o.wrap)&&(o.near=!0,a!=="shader"&&this.loadMedia(o));for(let d of o.effects){d.ctx=this.context(o,d.name,d.options);try{d.cleanup=d.def.setup?.(d.ctx)}catch(y){T.error(`effect "${d.name}" setup failed`,y)}}for(let[d,y]of o._play.playables)o._play.cleanups.push(pt(o,d,y,{clock:this.host.clock,reducedMotion:this.reducedMotion,tweens:this.tweens}));if(o.shader){o.shader.ctx=this.context(o,o.shader.name,o.shader.options);try{o.shader.cleanup=o.shader.def.setup?.(o.shader.ctx)}catch(d){T.error(`shader "${o.shader.name}" setup failed`,d)}o.textureState="ready",o.resolveLoaded()}}track(e,i=!0){this.planes.push(e),this.ba.set(e.el,e),i&&(e.sizeCheck=setTimeout(()=>this.rb(e),vt),this.io.observe(e.el),this.Ha.observe(e.el),this.Ga.observe(e.el),this.ro.observe(e.el))}rb(e){e.sizeCheck=void 0,!(e.destroyed||!e.measured||!e.el.isConnected||e.status==="error")&&(e.doc.w>0&&e.doc.h>0||this.host.loadInspect?.().then(i=>T.warn(i.zero(e,vt),e.el),()=>{}))}addView(e,i){let r=new z(e,"layer",this.planes.length,this);return r.live=V(e),r.scrolls=this.host.scroll.contains(e),r.setStatus("loading"),this.layers.build(r,"view",i,{}),this.track(r),this.markDirty(),r}defined(e,i){let r=e==="effect"?i:`${e}:${i}`;for(let s of this.planes.slice())(s.missing.includes(r)||e==="layer"&&s.kind==="layer"&&!s._layer&&s.el.getAttribute("data-gl-layer")===i)&&s.el.isConnected&&this.rebuild(s)}rebuild(e){this.removePlane(e),this.create(e.el)}redefined(e,i){let r=this.programs.drop(e,i),s=a=>e==="effect"?a.effects.some(o=>o.name===i):e==="shader"?a.shader?.name===i:e==="chunk"?r.includes(a.program):a.kind==="layer"&&!!a._layer&&a.el.getAttribute("data-gl-layer")===i;for(let a of this.planes.slice())s(a)&&a.el.isConnected&&this.rebuild(a);if(!this.morph?.busy)for(let a of r)this.planes.some(o=>o.program===a)||a.dispose()}loadMedia(e){if(!(e.textureState!=="none"||this.lost)){if(e._mods.feed){e.textureState="loading";return}if(e.kind==="video")return this.video?.load(e);if(e.kind==="layer")return e._layer?this.layers.setup(e):void 0;if(e.kind==="text")return this.text?this.text.load(e):(e.textureState="loading",this.textWaiting.add(e),this.loadText());this.media.loadImage(e)}}loadText(){if(!this.text){if(this.ib)return this.gone.get("text")?.();this.ib=this.chunk(this.host.loadText,"text",'data-gl="text" stays normal DOM text.',(e,i)=>(I.glyph=e.GLYPH_HELPER,e.textPlanes(this,i),!0),()=>this.wc()).then(e=>{e||(this.gone.delete("text"),this.ib=null)})}}loadLayers(){return this.hc||=this.chunk(this.host.loadLayers,"layers",'three.js layers (data-gl="layer", gl.view()) stay off and keep their DOM content.',e=>e.layers(this),()=>{for(let e of this.planes)e.kind==="layer"&&!e._layer&&e.setStatus("error")})}chunk(e,i,r,s,a,o=a?ui:0){let l=!1,u=(h,c)=>{if(this.destroyed||l)return null;l=!0;let E=e?`chunks/${i}.js ${c?`took more than ${c} s to load`:"failed to load"}`:`this build has no chunks/${i}.js`;return T.error(`${E}; ${r}`,h),this.gone.set(i,a),a?.(E),null};return o&&setTimeout(u,o,"",o/1e3),(e?e():Promise.reject()).then(h=>(l=!0,this.destroyed?null:s(h,this.gone.delete(i))),u)}swap(e){let i=e.prev,r=e.uniforms,s=()=>{e.prev!==i||!e.texture?.ready||(this.media.free(i),e.prev=null,r.uPrev&&(r.uPrev.value=bt),this.markDirty())};if(!r.uSwap||this.reducedMotion||!this.Ra)return s();this.Ra.swap(e,i,s)}loadFlip(){return this.ac||=this.chunk(this.host.loadFlip,"flip","elements jump to their new place and pictures change at once.",e=>this.Ra=e.flip(this))}where(e){let i=new Float32Array(9);return i.set(e.rect),i[0]+=e.scrolls?this.scrollX:this.pageX,i[1]+=e.scrolls?this.scrollY:this.pageY,i.set(e.radius,4),i[8]=e.radiusKy,i}flip(e,i,r){let s=Array.from((typeof e=="string"?document.querySelectorAll(e):e instanceof Element?[e]:e)||[]),a=this.planes.filter(l=>l.measured&&s.some(u=>u.contains(l.el))),o=a.map(l=>{let u=this.where(l);return l.fly=(h,c,E)=>(h[0]=u[0]-c,h[1]=u[1]-E,h[2]=u[2],h[3]=u[3]),l.stale=!0,u});try{i?.()}catch(l){T.error("gl.flip(): change() threw",l)}return this.markDirty(),this.loadFlip().then(l=>{if(l)return l.fly(a,o,r);for(let u of a)u.fly=null})}loadFx(){return this.cc||=this.chunk(this.host.loadFx,"fx","render targets stay off and backdrop planes show their DOM.",(e,i)=>e.fx(this,I,i),()=>{for(let e of this.planes)e.backdrop&&e.setStatus("error")})}loadWarm(){return this.Bc||=this.chunk(this.host.loadWarm,"warm","nothing is loaded ahead and placeholders stay off.",e=>this.warm=e.warm(this))}loadMorph(){return this.Gb||=this.chunk(this.host.loadMorph,"morph","data-gl-id images reveal on their own page instead of flying.",e=>e.morph(this))}loadVideo(){this.Ac||=this.chunk(this.host.loadVideo,"video","GL videos and module elements show their DOM.",e=>e.video(this),()=>this.remake(this.videoWaiting,!0)),this.gone.get("video")?.()}remake(e,i){for(let r of e)r.destroyed?e.delete(r):i?r.setStatus("error"):r.el.isConnected&&this.rebuild(r);i||e.clear()}capture(e,i=!1){let r=a=>i?a?.known(e):a?.capture(e),s=this.settles;this.morph?r(this.morph):this.Gb?.then(a=>s===this.settles&&r(a))}settle(){this.settles++,this.morph?.settle()}retry(){for(let e of this.morph?.retry()||[])e.near=!0,this.loadMedia(e)}Dc(e){let i=null,r=document.documentElement,s=()=>{let o=!1;try{o=r.matches(e)}catch{k("busy",[e]),a.disconnect()}o&&!i?i=this.host.engine.transition():!o&&i&&(i(),i=null)},a=new MutationObserver(s);a.observe(r,{attributes:!0}),this.cleanups.push(()=>a.disconnect()),s()}begin(){this.changing++,this.markDirty(),this.fx?.leave?.arm();for(let e of this.planes)this.named(e)}end(){if(--this.changing<1){this.changing=0,this.extendLive(1),this.retry(),this.settle(),this.fx?.leave?.play();for(let e of this.planes)this.named(e)}return new Promise(e=>{this.landing.push(e),setTimeout(e,4e3),this.markDirty()})}mb(e,i){e.readyFrame=-1,e.setStatus(i?"loading":null),e.status="loading"}named(e){let i=this.changing>0&&e.kind!=="layer"&&!/^(none)?$/.test(getComputedStyle(e.el).getPropertyValue("view-transition-name"));i!==e.vt&&(e.vt=i,e.status!=="error"&&(this.mb(e,!i),this.markDirty()))}wc(){this.textWaiting.clear(),this.remake(this.glyphWaiting,!0);for(let e of this.planes)e.kind!=="text"||e.status==="error"||(e.textureState="error",e.setStatus("error"))}readOptions(e,i,r){return me(e,i,r)}ub(e,i,r){return this.readOptions(e,`data-gl-${i}`,r.play?{...j,...r.options}:r.options||{})}Sb(e,i){return this.readOptions(e,"data-gl-shader",i.options||{})}Pb(e){let i=(r,s,a)=>{let o={};for(let l in r.options)JSON.stringify(s[l])!==JSON.stringify(r.options[l])&&(o[l]=r.options[l]=s[l]);this.optionUniforms(e,a,o)};for(let r of e.effects)i(r,this.ub(e.el,r.name,r.def),r.name);e.shader&&i(e.shader,this.Sb(e.el,e.shader.def),"")}optionUniforms(e,i,r){for(let s in r){let a=r[s],o=typeof a=="string"?q(a,e.el)||(a.includes("/")?a:null):a;s==="bleed"&&(e.bleed=Math.max(e.bleed,+o||0)),(typeof o=="number"||typeof o=="boolean"||typeof o=="string"||Array.isArray(o)||o instanceof Float32Array)&&this.addUniforms(e,{[Ve(i,s)]:typeof o=="boolean"?Number(o):o})}}addUniforms(e,i){for(let r in i){let s=i[r];if(we(s)){e.uniforms[r]=new U(s,()=>this.markDirty()),e.hasSignals=!0;continue}Array.isArray(s)&&(s=new Float32Array(s)),typeof s=="string"?s=q(s,e.el)||this.media.textureFromUrl(s):s instanceof Object&&!("texture"in s)&&!(s.length<897&&s instanceof Float32Array)&&k("texture",[r]),e.uniforms[r]=new W(s,()=>this.markDirty())}}context(e,i,r){let s=this;return{name:i,el:e.el,plane:e,engine:this.host.engine,options:r,uniforms:e.uniforms,get reducedMotion(){return s.reducedMotion},viewport:this.viewport,frame:null,trackMouse(a){if(a!==e.mouseTracking){if(e.mouseTracking=a,s.jb+=a?1:-1,a){let o=e.rect;e.mouse[0]=e.mouseTarget[0]=(s.pointer.x-o[0])/Math.max(o[2],1),e.mouse[1]=e.mouseTarget[1]=(s.pointer.y-o[1])/Math.max(o[3],1)}s.markDirty()}},busy(a){a?e.busyReasons.add(i):e.busyReasons.delete(i),s.markDirty()},wake(a){s.wake(a)},listen(a,o){for(let h in o)a.addEventListener(h,o[h]);let l=!1,u=()=>{if(!l){l=!0;for(let h in o)a.removeEventListener(h,o[h])}};return e.listeners.push(u),u}}}modulesOf(e){return[...this.registry.modules].filter(([i,r])=>r.module.plane&&(r.module.attributes?.length?r.module.attributes:[i]).some(s=>e.hasAttribute(`data-gl-${s}`)))}ob(e){let i=e.el;this.video?.bind(e);for(let r in gt)this.registry.modules.has(r)||!i.hasAttribute(`data-gl-${r}`)||(e.missing.push(`module:${r}`),k("module",[i,r],i));return e._mods.list}detach(e){let i=this.planes.indexOf(e);i!==-1&&this.planes.splice(i,1),this.markDirty()}attach(e){this.planes.includes(e)||this.planes.push(e),e.stale=!0,this.markDirty()}discard(e){this.detach(e),e.el.isConnected||this.video?.release(e),this.Aa(e)}drawable(e){return e.status==="error"||e.textureState==="error"?!1:e.kind==="layer"?!!e._layer?.ready:(e.kind==="shader"||!!e.texture?.ready)&&!!e.grid&&!!e.program?.ready()}invalidate(e){for(let i of e?[this.ba.get(e)]:this.planes)i&&(i.stale=!0,this.Pb(i));this.markDirty()}checkHost(){if(this.destroyed)return;let i=/^(static|relative)$/.test(getComputedStyle(this.hostEl).position)?"umber.css":null,r=document.documentElement,s=document.body,a=new Map,o=l=>Re(Te(l,a));this.ownHost&&s&&this.hostEl.parentElement===s&&o(s)?.startsWith("zoom:")&&r.insertBefore(this.hostEl,s);for(let l=this.hostEl.parentElement;l&&!i;l=l.parentElement){let u=o(l);u&&(i=`${l===r?"<html>":l===s?"<body>":O(l)} has ${u}`)}i!==this.hostReason&&(this.hostReason=i,this.canvas.style.display=i?"none":"",i&&k("host",[i,this.ownHost]),this.hold("hostPause",!!i),i&&(this.stats.state="off (canvas host)"))}hold(e,i){this[e]=i,this.userPause||this.forcedPause||this.hostPause?this.paused||this.pause():this.resume()}keep(){if(this.failed||this.destroyed)return!1;let e=document.documentElement;e.classList.contains("has-gl")||e.classList.add("has-gl");let i=this.canvas;if(i.isConnected)return!1;document.querySelectorAll("[data-gl-canvas]").forEach(l=>(this.ownHost&&l.parentElement?.hasAttribute("data-gl-host")?l.parentElement:l).remove());let r=this.hostEl,s=this.options.host,a=this.ownHost?null:s instanceof HTMLElement?s:document.querySelector(typeof s=="string"?s:"[data-gl-host]"),o=a?.isConnected?a:r;return o.isConnected||(document.body.prepend(o),this.ownHost||this.host.loadInspect?.().then(l=>T.warn(l.hostLeft),()=>{})),o!==r&&(this.ro.unobserve(r),this.ro.observe(o),this.hostEl=o),i.parentElement!==o&&o.appendChild(i),this.ea=!0,this.checkHost(),this.invalidate(),!0}showDom(){Le(this)}get domGen(){return this.gen+(this.host.changes?.()||0)}kc(e){let i=performance.now(),r=this.isLive(i);if(this.Xb&&!r)for(let u of this.planes)u.stale=!0;this.Xb=r,this.ea&&this.resize(),this.screen.width=window.innerWidth||this.viewport.width,this.screen.height=window.innerHeight||this.viewport.height,this.scrollX=e.scroll.x,this.scrollY=e.scroll.y,this.host.scroll.root?(this.pageX=window.scrollX||0,this.pageY=window.scrollY||0):(this.pageX=this.scrollX,this.pageY=this.scrollY),this.hb=this.scrolled,this.scrolled=this.scrollX!==this.Eb||this.scrollY!==this.Ya;let s=Math.abs(this.scrollY-this.Ya)>this.screen.height/4;this.Eb=this.scrollX,this.Ya=this.scrollY,this.Kb.clear(),this.chainMemo.clear(),this.pb=null;let a=e.frame%12===0;!this.scrolled&&(this.Ca||this.Da)&&this.hovered(i),e.woke&&(this.animCheck=!0);let o=this.animCheck||e.frame%li===0&&this.planes.some(u=>u.soon);this.shapes?this.shapes.start(i,o):o&&this.ic(i);let l=!1;for(let u of this.planes){if(u.destroyed||!u.el.isConnected||!u.program&&u.kind!=="layer")continue;let h=u.inView&&u.status==="loading"&&!u.backHidden;h&&this.dc(u,i);let c=u._raster,E=u.soon&&!!c?.wantKey,w=u.kind==="text"&&u.soon&&!!c&&i<c.colorUntil,v=u.soon||u.visible||s||!!u.wrap;this.animWait&&v&&(u.stale=!0);let d=this.va.size>0&&v&&this.fc(u),y=u.heldMoved;u.heldMoved=!1,u.animUntil&&(i<u.animUntil?y||=u.animUntil===1/0?u.inView||this.scrolled&&v||u.visible:v:(u.animUntil=0,u.stale=!0));let P=u.scrollLinked&&v&&(this.scrolled||this.hb);if(u.status==="error"&&!u.stale&&!u.morphHidden&&!y&&!P&&!d)continue;let f=u.live&&v,m=u.stale||r&&u.soon||h||f||E||u.morphHidden||d||y||P,p=m&&(u.stale||r||h||E||u.morphHidden||y||P),b=a&&u.soon&&!u.calm,x=p||w||b;if(!m&&!x)continue;let S=m&&(u.stale||!u.chained||y&&this.shapesError!==null);if(m){S&&(this.rc(u,Je(u)),u.gen=this.domGen);let g=u.geomEl.getBoundingClientRect(),R=u.scrolls?this.scrollX:this.pageX,M=u.scrolls?this.scrollY:this.pageY,_=u.doc.w!==g.width||u.doc.h!==g.height;u.doc.x=g.left+R,u.doc.y=g.top+M,u.doc.w=g.width,u.doc.h=g.height,u.measured=!0,_&&(u.lastOpacity!==-1&&u.emit("resize"),this.media.sharpen(u)),this.shapes?this.shapes.measureTransform(u,S,p,g,R,M,i):this.jc(u,S,g),S&&(u.live=(u.pinned=nt(u.nodes,this.host.scroll.root))||D.bool(u.el,"data-gl-live"));let A=u.wrap;if(S&&A){let K=u.el.closest("[data-gl-wrap]"),Ae=K.getBoundingClientRect(),Ce=new DOMMatrixReadOnly(getComputedStyle(K).transform);A[1]=A[0]?K.offsetHeight:K.offsetWidth,A[2]=A[0]?Ae.top-Ce.m42+M:Ae.left-Ce.m41+R}u.scene&&(l=!0)}if(x){let g=ke(u.media===u.el?u.el.parentElement:u.el,this.Kb,this.hostEl);u.calm=!p&&g===u.opacity,u.opacity=g}u.stale&&Ze(u),m&&(u.clipReason=this.shapes?this.shapes.measureClips(u,S,p):null,this.decide(u)),u.kind==="text"&&this.text&&u.near&&u.textureState!=="loading"&&u.textureState!=="error"&&this.text.check(u,i,b),u.stale=!1}(l||this.Bb)&&this.shapes?.checkScenes(),this.Bb=l,this.va.clear()}rc(e,i){i!==e.geomEl&&(e.geomEl!==e.el&&(this.ro.unobserve(e.geomEl),this.ya.delete(e.geomEl)),e.geomEl=i,i!==e.el&&(this.ya.set(i,e),this.ro.observe(i)))}Ua(e){let i=this.host.scroll.root;if(e===document.documentElement||e===document.body||e===i)return!1;let r=!1;for(let s of this.planes)s.inView&&(s.el.contains(e)||e.contains(s.el))&&(s.stale=r=!0);return r}hovered(e){let i=this.Da,r=this.Ca;this.Da=this.Ca=null;let s=!1;i?.isConnected&&(s=this.Ua(i)),r?.isConnected&&this.Ua(r)&&(s=!0),s&&(this.animCheck=!0),this.Ta=e}fc(e){for(let i of this.va)if(i.contains(e.geomEl))return!0;return!1}slid(e){let i=getComputedStyle(e).transform.split(","),r=i.splice(i.length>6?12:4,2).map(parseFloat),s=e.getAttribute("class")+(e.getAttribute("style")||"").replace(/(^|;)\s*(transform|translate)\s*:[^;]*/g,"")+i,a=this.slides.get(e);return this.slides.set(e,{key:s,move:r}),a?.key===s&&r.length>1?[r[0]-a.move[0],r[1]-a.move[1]]:null}jc(e,i,r){let s;if(i){let o=e.nodes=st(e.geomEl,this.chainMemo);e.chained=!0;let[l,u]=it(getComputedStyle(e.geomEl));e.boxW=Number.isFinite(l)&&l>0?l:r.width,e.boxH=Number.isFinite(u)&&u>0?u:r.height,e.inBody=!1,s=!ot(o,h=>e.inBody=this.inBody(h.el,r))}else if(e.inBody)s=!this.inBody(document.body,r);else return;s&&this.loadShapes(),e.xfReason=e.chainReason=s&&this.shapesError?`${O(e.el)}: it is cut, turned or tilted by CSS, and ${this.shapesError}, so its DOM shows. Serve chunks/shapes.js next to chunks/gl.js.`:null;let a=s&&!this.shapesError;a!==e.shapeWait&&(e.shapeWait=a,a&&e.status==="ready"&&this.mb(e),this.markDirty())}inBody(e,i){let r=this.pb||=e.getBoundingClientRect(),{clientLeft:s,clientTop:a,clientWidth:o,clientHeight:l}=e;return!/[1-9]/.test(getComputedStyle(e).borderRadius)&&i.left>=r.left+s-.5&&i.top>=r.top+a-.5&&i.right<=r.left+s+o+.5&&i.bottom<=r.top+a+l+.5}loadShapes(){this.tc||=this.chunk(this.host.loadShapes,"shapes","GL elements cut, turned or tilted by CSS show their DOM.",e=>{this.animWait=!1,e.shapes(this)},e=>this.sc(e))}sc(e){this.shapesError=e,this.animWait=!1;for(let i of this.planes)i.shapeWait&&(i.stale=!0);this.markDirty()}turnedText(e){return this.shapes?.turnedText(e)??null}warnOnce(e,i){e.warned.has(i)||(e.warned.add(i),T.warn(i,e.el))}decide(e){if(e.kind==="layer"){e.level&&this.layers?.upright(e);return}this.Ba(e,e.xfReason||e.sceneReason||e.clipReason||e.cornerReason||e.textReason)}fallback(e,i=e.domReason){this.host.emit("fallback",{el:e.el,reason:i==="oval"?"its rounded corners have different shapes, so its DOM shows":i})}Ba(e,i){if(i===e.domReason)return;let r=e.domReason;e.domReason=i,i?(this.warnOnce(e,i),e.readyFrame=-1,e.setStatus("error"),r&&r===e.textReason&&(e.emit("error"),this.fallback(e)),H(e.el)):r&&e.textureState!=="error"&&(e.media&&Z(e.el,e.media),e.loadingSince=0,this.mb(e),e.near&&e.textureState==="none"&&this.loadMedia(e)),(!i||!r)&&this.markDirty()}ic(e){if(this.animCheck=!1,typeof document.getAnimations!="function")return;for(let r of this.planes)(r.animInfinite=r.animUntil===1/0)&&(r.animUntil=0);let i=typeof DocumentTimeline<"u"?DocumentTimeline:null;for(let r of document.getAnimations()){let s=r.effect,a=s?.target,o=a&&!s.pseudoElement&&r.playState!=="idle"?Pe(r):0;if(!o||!a)continue;let l=r.playState==="running"&&!!r.playbackRate,u=!!(r.timeline&&i&&!(r.timeline instanceof i));for(let h of this.planes){if(!h.soon||!(a===h.el||a.contains(h.geomEl)))continue;if(!this.shapesError&&(u||!l||h.shapeWait||o>1))return this.animWait=!0,this.loadShapes();if(!l)continue;let c=s.getComputedTiming(),E=Number(c.endTime),w=Number(c.localTime)||0,v=u||E===1/0?1/0:e+Math.max(0,r.playbackRate<0?w:E-w)/Math.abs(r.playbackRate)+50;v>h.animUntil&&(h.animUntil=v,h.animLabel=`animation on ${O(a)}`)}}for(let r of this.planes)r.animInfinite&&(r.animInfinite=!1,r.animUntil!==1/0&&(r.stale=!0))}Jb(e){if(this.inactive)return;if(this.shapes)return this.shapes.Jb(e);let i=e.effect?.target;i&&Pe(e)&&this.onAnimate(i)}onAnimate(e){if(!(this.inactive||!(e instanceof Element))){for(let i of this.planes)if(i.soon&&(e===i.el||e.contains(i.geomEl))){this.animCheck=!0,this.request();return}}}dc(e,i){let r=(e.textureState==="none"||e.textureState==="loading"||e.textureState==="queued")&&!e._raster?.empty,s=!e._mods.feed||e._play.playables.size>0;if(e.kind==="layer"||!e.visible||!e.opacity||!r||!s||e.el.getAttribute("data-gl-status")!=="loading"){e.loadingSince=0;return}e.loadingSince||(e.loadingSince=i,e.emit("wait")),!(i-e.loadingSince<_e)&&(k("slow",[_e/1e3],e.el),e.textureState="error",e.setStatus("error"),H(e.el))}resize(){this.ea=!1,this.renderer.adaptive.onResize();let e=this.hostEl.clientWidth||window.innerWidth,i=this.hostEl.clientHeight||window.innerHeight;this.viewport.width=e,this.viewport.height=i;let r=this.cap?this.cap.dpr(e,i):ut(this.options.dpr,this.tier,e,i,this.options.pixelBudget||12e6,this.wide);this.dpr=r,devicePixelRatio!=this.ratio&&(this.ratio=devicePixelRatio,this.planes.forEach(l=>this.media.sharpen(l)));let s=r*this.scale,a=Math.max(1,Math.round(e*s)),o=Math.max(1,Math.round(i*s));(this.canvas.width!==a||this.canvas.height!==o)&&(this.canvas.width=a,this.canvas.height=o,this.views?.resized(a,o)),this.stats.dpr=Math.round(r*100)/100,this.stats.width=a,this.stats.height=o,this.forced=Math.max(this.forced,1)}zc(e){let i=this.reducedMotion;i||(this.time=e.time);let r=this.viewport.width,s=this.viewport.height;this.tweening=this.tweens.step(e.time);let a=i?0:Math.max(-1,Math.min(1,(e.scroll.velocity||0)/3600)),o=this.velocity;this.velocity=ee(this.velocity,a,.12,e.dt),Math.abs(this.velocity)<5e-4&&a===0&&(this.velocity=0),this.host.velocity.value=this.velocity;let l=this.dirty||this.forced>0||this.tweening,u=!1;this.shapes?.frame(r,s);let h=this.visibleList,c=h.length;h.length=0;for(let d of this.planes){if(d.destroyed)continue;let y=d.scrolls?this.scrollX:this.pageX,P=d.scrolls?this.scrollY:this.pageY,f=et(d,y,P),m=d.wrap;if(m&&m[1]){let g=m[0],R=f[g+2],M=m[2]-(g?P:y);f[g]=M+((f[g]-M+R)%m[1]+m[1])%m[1]-R;let _=f[0]<r&&f[0]+f[2]>0&&f[1]<s&&f[1]+f[3]>0;_!==d.inView&&(d.inView=_,d._mods.tell(A=>A.visible?.(_)),d.emit(_?"enter":"leave")),!_&&d.status==="loading"&&d.texture?.ready&&d.program?.ready()&&d.setStatus("ready")}if(d.fly?.(f,y,P),d.level&&!d.xfReason&&this.shapes)this.shapes.placeDraw(d,y,P);else{let g=d.drawXf;g[0]=g[4]=g[8]=1,g[1]=g[2]=g[3]=g[5]=0,g[6]=f[0],g[7]=f[1],d.size[0]=f[2],d.size[1]=f[3]}if(d._mods.list.length&&(d.near||d.soon)&&d.status!=="error"){for(let g of d._mods.list)if(g.binding.update)try{g.binding.update(e,f,this.screen)&&(l=!0)}catch(R){T.error(`module "${g.name}" update failed`,R),g.binding.update=void 0}}if(d.visible=d.el.isConnected&&d.status!=="error"&&d.textureState!=="error"&&(!!d.program||!!d._layer)&&f[2]>0&&f[3]>0&&(d.opacity>.001||d._layer?.def.followOpacity===!1)&&!d.backHidden&&!d.shapeWait&&f[0]<r&&f[0]+f[2]>0&&f[1]<s&&f[1]+f[3]>0,d.clips&&this.shapes&&(d.clips.cutBy=null,d.visible)){let g=this.shapes.clip(d,f);g&2&&(l=!0),g&1||(d.visible=!1)}let p=d.visible?h.push(d)-1:-1;if(p!==d.listed&&(d.listed=p,l=!0),p<0)continue;let b=d.kind==="video"&&!d._mods.feed?d.media:null;if(!(!d._mods.feed&&d.kind!=="shader"&&d.kind!=="layer"&&!d.texture?.ready&&!d.prev?.ready&&!(b&&d.videoFrame&&(b.readyState??0)>=2))){if((f[0]!==d.lastRect[0]||f[1]!==d.lastRect[1]||f[2]!==d.lastRect[2]||f[3]!==d.lastRect[3])&&(l=!0),d.level&&!l){let g=d.drawXf,R=d.lastXf;for(let M=0;M<9;M++)g[M]!==R[M]&&(l=!0)}d.opacity!==d.lastOpacity&&(l=!0)}let S=tt(f,this.screen.height);if(S!==d.progress&&(d.progress=S,d.usesProgress&&(l=!0)),d.hasSignals)for(let g in d.uniforms){let R=d.uniforms[g];R instanceof U&&R.changed()&&(l=!0)}if(d.kind==="video"&&d.busyReasons.has("video")&&(d.videoFrame=!0),d.mouseTracking){d.level&&!d.xfReason&&this.shapes?this.shapes.pointer(d,this.pointer.x+y,this.pointer.y+P):(d.mouseTarget[0]=(this.pointer.x-f[0])/Math.max(f[2],1),d.mouseTarget[1]=(this.pointer.y-f[1])/Math.max(f[3],1));let g=d.mouseTarget[0],R=d.mouseTarget[1],M=Math.abs(g-d.mouse[0])+Math.abs(R-d.mouse[1])<5e-4,_=M?g:ee(d.mouse[0],g,.15,e.dt),A=M?R:ee(d.mouse[1],R,.15,e.dt);(Math.fround(_)!==d.mouse[0]||Math.fround(A)!==d.mouse[1])&&(d.mouse[0]=_,d.mouse[1]=A,l=!0)}for(let g of d.effects)if(g.def.update){g.ctx.frame=e;try{g.def.update(g.ctx)}catch(R){T.error(`effect "${g.name}" update failed`,R),g.def={...g.def,update:void 0}}}if(d.shader?.def.update){d.shader.ctx.frame=e;try{d.shader.def.update(d.shader.ctx)}catch(g){T.error(`shader "${d.shader.name}" update failed`,g),d.shader.def={...d.shader.def,update:void 0}}}(d.busyReasons.size||!i&&d.usesTime&&xt(d))&&(u=!0),!i&&(d.shader&&d.shader.def.animate!==!1||d._layer?.ready&&d._layer.def.animate!==!1)&&(u=!0),d.kind==="video"&&d.videoFrame&&(d.media?.readyState??0)>=2&&(l=!0),(this.velocity!==0||o!==0)&&(d.usesVelocity||d._layer)&&(l=!0)}if(!u)for(let d of this.media.uploads)(d.plane.visible||d.plane.inView)&&(u=!0);h.length!==c&&(l=!0);let E=this.morph?.update(this.now);E&&(l=!0),this.landing.length&&!E&&!h.some(d=>d.status==="loading"&&!d.vt)&&(this.landing.forEach(d=>d()),this.landing.length=0);for(let d of h)d.readyFrame!==-1&&d.readyFrame<e.frame&&d.status!=="ready"&&d.setStatus("ready"),d.morphIn&&d.status==="ready"&&!d.morphHidden&&d.el.removeAttribute("data-gl-morphing");let w=this.isLive(performance.now());this.Ia=l||u||w||this.dirty;let v=[];w&&v.push("live"),this.media.uploads.length&&v.push("upload"),this.velocity!==0&&v.push("scroll"),E&&v.push("morph"),this.tweening&&v.push("tween"),this.watched&&v.push(`dom-watch:${O(this.watched)}`),this.watched=null;for(let d of h)d.busyReasons.forEach(y=>v.push(y)),d.usesTime&&xt(d)&&v.push("hover"),d.shader&&d.shader.def.animate!==!1&&v.push(`shader:${d.shader.name}`);this.stats.busy=v}oc(e){let i=performance.now();this.stats.planes=this.planes.length,this.stats.visible=this.visibleList.length,this.stats.programs=this.programs.size;do this.media.uploadNext(e.frame,this.cap?0:this.Xa)&&(this.Ia=!0);while(this.cap&&this.media.uploads.length);for(let a of this.planes)a._mods.frames?.pending&&this.video.feed(a)&&(this.Ia=!0);if(!this.Ia){this.Xa=0,this.stats.skipped++,this.stats.state="idle",this.keepGoing(!1);return}let r=this.renderer.draw(e);for(let a of this.planes)a.visible||(a.lastRect[0]=NaN);this.dirty=!1,this.forced>0&&this.forced--;for(let a of this.renderer.list)a.status==="loading"&&a.readyFrame!==-1&&(this.forced=Math.max(this.forced,1));let s=performance.now();for(this.Xa=s-i,this.stats.renders++,this.stats.draws=r,this.stats.state="active",this.stats.frameMs=Math.round(e.dt*1e4)/10,this.stats.fps=Math.round(1/e.dt),this.fa.push(s);this.fa.length&&s-this.fa[0]>1e3;)this.fa.shift();this.stats.rendersPerSec=this.fa.length,this.renderer.adapt(e)&&(this.ea=!0),this.keepGoing(!0)}prune(){let e=[];for(let i of this.planes)if(i.el.isConnected)e.push(i);else{if(this.morph?.holds(i)||this.morph?.keep(i))continue;this.video?.release(i),this.Aa(i)}this.planes=e,this.markDirty()}removePlane(e){this.planes=this.planes.filter(i=>i!==e),this.Aa(e),this.markDirty()}remove(e){let i=this.ba.get(e);i&&this.removePlane(i)}Aa(e){if(!e.destroyed){e.destroyed=!0,clearTimeout(e.sizeCheck);for(let i of e.effects)try{typeof i.cleanup=="function"&&i.cleanup()}catch(r){T.error(`effect "${i.name}" cleanup failed`,r)}Ee(e.listeners),e.listeners=[];try{e.shader&&typeof e.shader.cleanup=="function"&&e.shader.cleanup()}catch(i){T.error(`shader "${e.shader?.name}" cleanup failed`,i)}for(let i of e.parts())i?.dispose(e);e.mouseTracking&&this.jb--,e.mouseTracking=!1,e.videoCleanup?.(),e.videoCleanup=null,this.media.forget(e),this.media.release(e),this.media.free(e.prev),e.prev=null,this.io.unobserve(e.el),this.Ha.unobserve(e.el),this.Ga.unobserve(e.el),this.ro.unobserve(e.el),e.geomEl!==e.el&&(this.ro.unobserve(e.geomEl),this.ya.delete(e.geomEl)),this.ba.get(e.el)===e&&this.ba.delete(e.el),this.tweens.killTweensOf(Object.values(e.uniforms)),e.status!=="error"&&e.setStatus(null),e.readyFrame=-1,e.el.removeAttribute("data-gl-morphing"),e.el.removeAttribute("data-gl-play"),H(e.el),e.emit("destroy")}}destroy(){if(!this.destroyed){this.morph?.cancel();for(let e of this.planes)this.Aa(e);this.planes=[],this.textWaiting.clear(),this.glyphWaiting.clear(),this.videoWaiting.clear(),this.destroyed=!0,this.tweens.clear(),this.io.disconnect(),this.Ha.disconnect(),this.Ga.disconnect(),this.ro.disconnect(),this.cleanups.forEach(e=>e()),this.cleanups=[],this.lost||(this.renderer.dispose(),this.layers?.fade.dispose(),this.media.dispose(),this.views?.dispose(),ft(this.gl)),this.programs.dispose(!this.lost),this.canvas.remove()}}};function Ws(n){Ie(n.log),Fe(n.lib);let{el:t,created:e}=hi(n.options),i=document.createElement("canvas");i.setAttribute("aria-hidden","true"),i.setAttribute("data-gl-canvas",""),i.setAttribute("data-engine",`umber ${n.engine&&n.engine.version}`);let r=null;try{r=i.getContext("webgl2",{alpha:!0,premultipliedAlpha:!0,antialias:!0,depth:!0,stencil:!1,powerPreference:"high-performance",preserveDrawingBuffer:!1})}catch{r=null}if(!r)return k("webgl2",[]),e&&t.remove(),null;t.appendChild(i);let s=new fe(n,i,r,t,e),a={apply:o=>s.apply(o),scan:o=>s.scan(o),prune:()=>s.prune(),remove:o=>s.remove(o),invalidate:o=>s.invalidate(o),live:o=>s.live(o),wake:o=>s.wake(o),keep:()=>s.keep(),begin:(o,l)=>{l||s.begin(),s.capture(o,l)},end:()=>s.end(),pause:()=>s.hold("userPause",!0),resume:()=>s.hold("userPause",!1),plane:o=>s.plane(o),stage:s,planes:o=>s.list(o),defined:(o,l)=>s.defined(o,l),redefined:(o,l)=>s.redefined(o,l),morph:{capture:o=>s.capture(o),settle:()=>s.settle()},renderer:(o,l)=>s.loadLayers().then(u=>u&&u.create(o,l)),view:o=>s.loadLayers().then(l=>l&&!o.destroyed?l.view(o):null),fx:(o,l)=>(o==="preload"||o==="warm"||o==="placeholder"?s.loadWarm():s.loadFx()).then(u=>u&&u[o](l)),flip:(o,l,u)=>s.flip(o,l,u),get info(){return s.info()},destroy(){s.destroy(),e&&t.remove()},get gl(){return s.lost?null:s.gl},get canvas(){return s.canvas}};return T.info("GL mounted",{tier:s.tier}),a}function hi(n){if(n.host instanceof HTMLElement)return{el:n.host,created:!1};let t=document.querySelector(typeof n.host=="string"?n.host:"[data-gl-host]");if(t)return{el:t,created:!1};typeof n.host=="string"&&k("hostless",[n.host]);let e=document.createElement("div");return e.setAttribute("data-gl-host",""),e.style.zIndex=String(n.zIndex??(n.layer==="under"?-1:1)),document.body?document.body.prepend(e):document.documentElement.appendChild(e),{el:e,created:!0}}export{Ws as mount};